Dmitry Timoshkov : kernel32: Replace Peb-> BeingDebugged check by CheckRemoteDebuggerPresent().

Alexandre Julliard julliard at winehq.org
Thu Apr 20 12:35:11 CDT 2017


Module: wine
Branch: stable
Commit: c0f1b3816d44ff5e3fdb48f7515fc0e078fc2a92
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c0f1b3816d44ff5e3fdb48f7515fc0e078fc2a92

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Fri Feb 10 17:21:32 2017 +0100

kernel32: Replace Peb->BeingDebugged check by CheckRemoteDebuggerPresent().

misctool.dll from AmiBroker intentionally sets PEB->BeingDebugged
to a random value returned by RDTSC instruction on PROCESS_ATTACH.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 8de06f12dd267cd56284c4f307852486e867b229)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/kernel32/process.c | 6 +++++-
 include/winbase.h       | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index cef21ad..793f3ef 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -1085,6 +1085,7 @@ static inline DWORD call_process_entry( PEB *peb, LPTHREAD_START_ROUTINE entry )
  */
 static DWORD WINAPI start_process( LPTHREAD_START_ROUTINE entry )
 {
+    BOOL being_debugged;
     PEB *peb = NtCurrentTeb()->Peb;
 
     if (!entry)
@@ -1098,8 +1099,11 @@ static DWORD WINAPI start_process( LPTHREAD_START_ROUTINE entry )
         DPRINTF( "%04x:Starting process %s (entryproc=%p)\n", GetCurrentThreadId(),
                  debugstr_w(peb->ProcessParameters->ImagePathName.Buffer), entry );
 
+    if (!CheckRemoteDebuggerPresent( GetCurrentProcess(), &being_debugged ))
+        being_debugged = FALSE;
+
     SetLastError( 0 );  /* clear error code */
-    if (peb->BeingDebugged) DbgBreakPoint();
+    if (being_debugged) DbgBreakPoint();
     return call_process_entry( peb, entry );
 }
 
diff --git a/include/winbase.h b/include/winbase.h
index eff5972..d8320e6 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -1737,6 +1737,7 @@ WINBASEAPI BOOL        WINAPI CancelTimerQueueTimer(HANDLE,HANDLE);
 WINBASEAPI BOOL        WINAPI CancelWaitableTimer(HANDLE);
 WINBASEAPI BOOL        WINAPI CheckNameLegalDOS8Dot3A(const char*,char*,DWORD,BOOL*,BOOL*);
 WINBASEAPI BOOL        WINAPI CheckNameLegalDOS8Dot3W(const WCHAR*, char*,DWORD,BOOL*,BOOL*);
+WINBASEAPI BOOL        WINAPI CheckRemoteDebuggerPresent(HANDLE,BOOL*);
 WINBASEAPI BOOL        WINAPI ChangeTimerQueueTimer(HANDLE,HANDLE,ULONG,ULONG);
 WINADVAPI  BOOL        WINAPI CheckTokenMembership(HANDLE,PSID,PBOOL);
 WINBASEAPI BOOL        WINAPI ClearCommBreak(HANDLE);




More information about the wine-cvs mailing list