//Make sure there are only two calling functions: unsigned lEIP = 0; //return address is [EBP + 4] __asm { mov ecx, [ebp + 4] mov [lEIP], ecx } static unsigned lFirstEIP = lEIP; if(lFirstEIP != lEIP) { //There should only be two functions that call this: static unsigned lSecondEIP = lEIP; if(lEIP != lFirstEIP && lEIP != lSecondEIP) __debugbreak(); }
Just goes to show that it doesn't matter what types of hacks you do while debugging. Do anything it takes to get the information you need. In debugging, there's no such thing as a bad hack :)
EDIT:
Oh yeah, and I also found out a while ago about the _ReturnAddress() intrinsic and StackWalk64(). These are MUCH more reliable tools to acquire this information.
Haha, Ramon just made me realize that for what I was needing all I had to do was change the name of the function and see where it didn't compile.
ReplyDeleteOh well, it was the first idea I had to debug the situation. At least the intent of the post remains.