2017-07-27 58 views
0

LastError值的值發生更改時,有沒有辦法打破windbgvisual studio調試器的執行?LastError更改時打破

編輯: 發現在ntdll!RtlSetLastWin32Error設置斷點的方式。

有沒有人知道另一種方式,或者這是最好的方式?

+0

[GetLastError()](https://msdn.microsoft.com/de-de/library/windows/desktop/ms679360(v = vs.85).aspx)是一種方法。你的代碼是否已經調用過,或者你期望VS或WinDbg調用它?你想多久檢查一次?每毫秒一次?每微秒一次? –

+0

這是一種檢查線程的TEB中的值的方法。我想在這個價值被改變的時候突破。現在我只是在'ntdll!RtlSetLastWin32Error'上放置了一個條件斷點,但我想知道是否有更好的方法來實現這一點。 – Train

+0

如果你知道地址,你可以在WinDbg中設置一個內存斷點('ba w') –

回答

1

設置寫斷點的teb-地址>的LastErrorValue

ba w4 @@c++(&(@$thread->LastErrorValue)) 

快樂斷裂時的誤差值變化 可以加條件的基點,打破只有當你想太多

0:000> ba w4 @@c++(&(@$thread->LastErrorValue)) "!gle;gc" 
breakpoint 0 redefined 
0:000> g 

LastErrorValue: (Win32) 0 (0) - The operation completed successfully. 
LastStatusValue: (NTSTATUS) 0xc000008a - Indicates the specified resource type cannot be found in the image file. 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
LastErrorValue: (Win32) 0 (0) - The operation completed successfully. 
LastStatusValue: (NTSTATUS) 0 - STATUS_WAIT_0 
LastErrorValue: (Win32) 0 (0) - The operation completed successfully. 
LastStatusValue: (NTSTATUS) 0xc0000034 - Object Name not found. 
LastErrorValue: (Win32) 0 (0) - The operation completed successfully. 
LastStatusValue: (NTSTATUS) 0 - STATUS_WAIT_0 
LastErrorValue: (Win32) 0 (0) - The operation completed successfully. 
LastStatusValue: (NTSTATUS) 0xc0000034 - Object Name not found. 
LastErrorValue: (Win32) 0 (0) - The operation completed successfully. 
LastStatusValue: (NTSTATUS) 0xc0000034 - Object Name not found. 
LastErrorValue: (Win32) 0 (0) - The operation completed successfully. 
LastStatusValue: (NTSTATUS) 0xc0000034 - Object Name not found. 
LastErrorValue: (Win32) 0 (0) - The operation completed successfully. 
LastStatusValue: (NTSTATUS) 0xc0000034 - Object Name not found.