How to capture a SetLastError (VS2008) / debug?
-
Something in my app. (C/Win32)is setting SetLastError and I want to debug it, eg capture all calls in my process to this function. Any idea how I'd configure VS to break here? Thanks
-
Something in my app. (C/Win32)is setting SetLastError and I want to debug it, eg capture all calls in my process to this function. Any idea how I'd configure VS to break here? Thanks
Maybe try hooking SetLastError, check out API hooking revealed[^] for details.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <
-
Something in my app. (C/Win32)is setting SetLastError and I want to debug it, eg capture all calls in my process to this function. Any idea how I'd configure VS to break here? Thanks
This is how I do this - Start
Windbg.exe
. Open your executable. Set the break point -bp kernel32!SetLastError
When it breaks issue any of the stack backtrace commands -k, kp, kP
etc.«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
Something in my app. (C/Win32)is setting SetLastError and I want to debug it, eg capture all calls in my process to this function. Any idea how I'd configure VS to break here? Thanks
Just call
SetLastError(0);
by starting of you process. Set a breakpoint there and then - by stopping - take the "Go to Disassembly" from the context menu... Now - step by F10 to "call", then - F11 to "jmp", then - F11 to "mov". Set your second breakpoint here to keep all calls ofSetLastError(..)
and press F5 to get it :) -
Just call
SetLastError(0);
by starting of you process. Set a breakpoint there and then - by stopping - take the "Go to Disassembly" from the context menu... Now - step by F10 to "call", then - F11 to "jmp", then - F11 to "mov". Set your second breakpoint here to keep all calls ofSetLastError(..)
and press F5 to get it :)Thanks for the responses. I managed to find a breakpoint for some function that releases memory. Need to brush up on my assembly perhaps? :-D Not quite what I asked, however a chap at work suggested typing $err into the watch window, this dispays the current value of GetLastError so I can step through code seeing where it changes.