I'm looking at some simple anti-debug measures as listed in this article http://www.codeproject.com/Articles/30815/An-Anti-Reverse-Engineering-Guide#BpMem
I've implemented a simple check for int 3 breakpoints in a given function so that the function testForInt3Breakpoints returns true if a breakpoint is set anywhere within thisIsADummyFunction.
int thisIsADummyFunction()
{
int i = rand();
++i;
return i;
}
bool testForInt3Breakpoints()
{
bool breakPointPresent = false;
unsigned char* memPtr = reinterpret_cast<unsigned char*>( thisIsADummyFunction );
auto size = 0x16; //this value determined by manual inspection of compiled code
for ( size_t i = 0; i < size; i++ ) {
if ( memPtr[ i ] == 0xCC ) { //see if byte equals int 3 instruction
breakPointPresent = true;
break;
}
}
return breakPointPresent;
}
The function above works fine for me for that one specific function but I would like to be able to monitor multiple functions without having to check the compiled code each time.
My question is are there any methods for getting a function's memory footprint in order to know what memory to monitor ?
I understand there is no general cross platform way to do it at runtime: How to get the length of a function in bytes?
but I am running on windows x64 and visual studio 2015 and quite happy for platform specific answers or anything that could automate the process in some way.