Due to the lack of a good assistant such as boundschecker, when we use wxdev-C ++ for programming, If we accidentally access the memory out of bounds, we may not find it,
The program often gets incorrect running results. If the domain name is out of the permitted range (for example, the address is 0), it will pop up immediately.
. If a small range of "legal zone" is out of bounds, it will be less sensitive. It is often because the program does not respond at all, but the actual program running result is already
It is not in line with the original design intention. Without the help of boundschecker, how can we find such a problem. Pageheap is such a tool software,
It finds out memory out-of-bounds Errors for EXE files instead of source code. If you do not have the source code or the IDE you are using does not have a plug-in such as boundschecker,
Using pageheap is a good choice. First, we will download pageheap.exe on a soft website. Then we enter the command line status, assuming
Put pageheap.exe on drive C. After your application is called myapp.exe and you enter drive C, run the following command:
Enter pageheap.exe/enable myapp.exe.
Enter pageheap and press enter to check whether monitoring of myapp.exe is enabled. Note that pageheap identifies whether monitoring is required based on the EXE name
Instead of specifying the path, you cannot specify the path. Once an exename is specified, all programs called myapp.exe will be included.
Monitoring scope. Of course, this coincidence is rare. Generally, other programs will not be monitored. To disable monitoring of this program, use
“Pageheap.exe/disable Application name command.
Then run your program and you will find that things have changed.
For example, the following code indicates that the access to the heap memory is obviously out of bounds:
/*
* Wxbutton4click
*/
Void project1dlg: wxbutton4click (wxcommandevent & event)
{
// Insert your code here
Char * P = new char [5];
P [-1] = 0;
Delete [] P;
}
Enabling pageheap monitoring is totally different from enabling pageheap monitoring. When monitoring is enabled, an error will be reported immediately after this step is executed to help you identify the problem.
If you do not enable monitoring, the execution of this section will not respond, which masks the problem. It is not a good phenomenon and will cause the running result to go wrong and crash under special conditions.
Pageheap cannot monitor a running program. Therefore, you need to restart the program to activate or stop monitoring for a program.
Pageheap cannot monitor the memory in the stack.
The principle of pageheap is that when a heap is allocated, several guard bytes are placed after the allocated memory ),
And the previous memory page marked as page_noaccess. In this way, the memory of page_noaccess will be touched Once access is out of bounds,
Windows reports. How many bytes are there for these protected bytes? If these protected bytes are directly crossed to access the memory space
(For example, in the above Code, change to P [100] = 0), will it make monitoring ineffective? This idea is correct. If you directly cross the daemon byte,
It is indeed not monitored. Of course, we generally think that most out-of-the-box requests are sequential. For example, in a for loop, there will always be backbyte requests,
Therefore, it is rare to bypass the protection byte directly.
This method is applicable not only to programs developed by wxdev-C ++, but also to VC ++ programs. It is only because boundschecker exists that pageheap is not necessary.
Too large. It can play a major role in the absence of source code.