Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
ef058b30
Commit
ef058b30
authored
Mar 14, 2010
by
Henri Verbeet
Committed by
Alexandre Julliard
Mar 15, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Implement CheckRemoteDebuggerPresent().
parent
f0a50452
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
4 deletions
+56
-4
debugger.c
dlls/kernel32/debugger.c
+14
-2
debugger.c
dlls/kernel32/tests/debugger.c
+42
-2
No files found.
dlls/kernel32/debugger.c
View file @
ef058b30
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "winerror.h"
#include "winerror.h"
#include "wine/server.h"
#include "wine/server.h"
#include "kernel_private.h"
#include "kernel_private.h"
...
@@ -432,13 +434,23 @@ BOOL WINAPI IsDebuggerPresent(void)
...
@@ -432,13 +434,23 @@ BOOL WINAPI IsDebuggerPresent(void)
*/
*/
BOOL
WINAPI
CheckRemoteDebuggerPresent
(
HANDLE
process
,
PBOOL
DebuggerPresent
)
BOOL
WINAPI
CheckRemoteDebuggerPresent
(
HANDLE
process
,
PBOOL
DebuggerPresent
)
{
{
NTSTATUS
status
;
DWORD_PTR
port
;
if
(
!
process
||
!
DebuggerPresent
)
if
(
!
process
||
!
DebuggerPresent
)
{
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
return
FALSE
;
}
}
FIXME
(
"(%p)->(%p): Stub!
\n
"
,
process
,
DebuggerPresent
);
*
DebuggerPresent
=
FALSE
;
status
=
NtQueryInformationProcess
(
process
,
ProcessDebugPort
,
&
port
,
sizeof
(
port
),
NULL
);
if
(
status
!=
STATUS_SUCCESS
)
{
SetLastError
(
RtlNtStatusToDosError
(
status
));
return
FALSE
;
}
*
DebuggerPresent
=
!!
port
;
return
TRUE
;
return
TRUE
;
}
}
...
...
dlls/kernel32/tests/debugger.c
View file @
ef058b30
...
@@ -44,6 +44,7 @@ static char** myARGV;
...
@@ -44,6 +44,7 @@ static char** myARGV;
static
BOOL
(
WINAPI
*
pCheckRemoteDebuggerPresent
)(
HANDLE
,
PBOOL
);
static
BOOL
(
WINAPI
*
pCheckRemoteDebuggerPresent
)(
HANDLE
,
PBOOL
);
static
BOOL
(
WINAPI
*
pDebugActiveProcessStop
)(
DWORD
);
static
BOOL
(
WINAPI
*
pDebugActiveProcessStop
)(
DWORD
);
static
BOOL
(
WINAPI
*
pDebugSetProcessKillOnExit
)(
BOOL
);
static
BOOL
(
WINAPI
*
pDebugSetProcessKillOnExit
)(
BOOL
);
static
struct
_TEB
*
(
WINAPI
*
pNtCurrentTeb
)(
void
);
static
LONG
child_failures
;
static
LONG
child_failures
;
...
@@ -498,6 +499,7 @@ static void doChild(int argc, char **argv)
...
@@ -498,6 +499,7 @@ static void doChild(int argc, char **argv)
const
char
*
blackbox_file
;
const
char
*
blackbox_file
;
HANDLE
parent
;
HANDLE
parent
;
DWORD
ppid
;
DWORD
ppid
;
BOOL
debug
;
BOOL
ret
;
BOOL
ret
;
blackbox_file
=
argv
[
4
];
blackbox_file
=
argv
[
4
];
...
@@ -506,15 +508,46 @@ static void doChild(int argc, char **argv)
...
@@ -506,15 +508,46 @@ static void doChild(int argc, char **argv)
parent
=
OpenProcess
(
PROCESS_QUERY_INFORMATION
,
FALSE
,
ppid
);
parent
=
OpenProcess
(
PROCESS_QUERY_INFORMATION
,
FALSE
,
ppid
);
child_ok
(
!!
parent
,
"OpenProcess failed, last error %#x.
\n
"
,
GetLastError
());
child_ok
(
!!
parent
,
"OpenProcess failed, last error %#x.
\n
"
,
GetLastError
());
ret
=
pCheckRemoteDebuggerPresent
(
parent
,
&
debug
);
child_ok
(
ret
,
"CheckRemoteDebuggerPresent failed, last error %#x.
\n
"
,
GetLastError
());
child_ok
(
!
debug
,
"Expected debug == 0, got %#x.
\n
"
,
debug
);
ret
=
DebugActiveProcess
(
ppid
);
ret
=
DebugActiveProcess
(
ppid
);
child_ok
(
ret
,
"DebugActiveProcess failed, last error %#x.
\n
"
,
GetLastError
());
child_ok
(
ret
,
"DebugActiveProcess failed, last error %#x.
\n
"
,
GetLastError
());
ret
=
pCheckRemoteDebuggerPresent
(
parent
,
&
debug
);
child_ok
(
ret
,
"CheckRemoteDebuggerPresent failed, last error %#x.
\n
"
,
GetLastError
());
child_ok
(
debug
,
"Expected debug != 0, got %#x.
\n
"
,
debug
);
ret
=
pDebugActiveProcessStop
(
ppid
);
ret
=
pDebugActiveProcessStop
(
ppid
);
child_ok
(
ret
,
"DebugActiveProcessStop failed, last error %#x.
\n
"
,
GetLastError
());
child_ok
(
ret
,
"DebugActiveProcessStop failed, last error %#x.
\n
"
,
GetLastError
());
ret
=
pCheckRemoteDebuggerPresent
(
parent
,
&
debug
);
child_ok
(
ret
,
"CheckRemoteDebuggerPresent failed, last error %#x.
\n
"
,
GetLastError
());
child_ok
(
!
debug
,
"Expected debug == 0, got %#x.
\n
"
,
debug
);
ret
=
CloseHandle
(
parent
);
ret
=
CloseHandle
(
parent
);
child_ok
(
ret
,
"CloseHandle failed, last error %#x.
\n
"
,
GetLastError
());
child_ok
(
ret
,
"CloseHandle failed, last error %#x.
\n
"
,
GetLastError
());
ret
=
IsDebuggerPresent
();
child_ok
(
ret
,
"Expected ret != 0, got %#x.
\n
"
,
ret
);
ret
=
pCheckRemoteDebuggerPresent
(
GetCurrentProcess
(),
&
debug
);
child_ok
(
ret
,
"CheckRemoteDebuggerPresent failed, last error %#x.
\n
"
,
GetLastError
());
child_ok
(
debug
,
"Expected debug != 0, got %#x.
\n
"
,
debug
);
if
(
pNtCurrentTeb
)
{
pNtCurrentTeb
()
->
Peb
->
BeingDebugged
=
FALSE
;
ret
=
IsDebuggerPresent
();
child_ok
(
!
ret
,
"Expected ret != 0, got %#x.
\n
"
,
ret
);
ret
=
pCheckRemoteDebuggerPresent
(
GetCurrentProcess
(),
&
debug
);
child_ok
(
ret
,
"CheckRemoteDebuggerPresent failed, last error %#x.
\n
"
,
GetLastError
());
child_ok
(
debug
,
"Expected debug != 0, got %#x.
\n
"
,
debug
);
pNtCurrentTeb
()
->
Peb
->
BeingDebugged
=
TRUE
;
}
blackbox
.
failures
=
child_failures
;
blackbox
.
failures
=
child_failures
;
save_blackbox
(
blackbox_file
,
&
blackbox
,
sizeof
(
blackbox
));
save_blackbox
(
blackbox_file
,
&
blackbox
,
sizeof
(
blackbox
));
}
}
...
@@ -526,13 +559,14 @@ static void test_debug_loop(int argc, char **argv)
...
@@ -526,13 +559,14 @@ static void test_debug_loop(int argc, char **argv)
char
blackbox_file
[
MAX_PATH
];
char
blackbox_file
[
MAX_PATH
];
PROCESS_INFORMATION
pi
;
PROCESS_INFORMATION
pi
;
STARTUPINFOA
si
;
STARTUPINFOA
si
;
BOOL
debug
;
DWORD
pid
;
DWORD
pid
;
char
*
cmd
;
char
*
cmd
;
BOOL
ret
;
BOOL
ret
;
if
(
!
pDebugActiveProcessStop
)
if
(
!
pDebugActiveProcessStop
||
!
pCheckRemoteDebuggerPresent
)
{
{
win_skip
(
"DebugActiveProcessStop not available, skipping test.
\n
"
);
win_skip
(
"DebugActiveProcessStop
or CheckRemoteDebuggerPresent
not available, skipping test.
\n
"
);
return
;
return
;
}
}
...
@@ -551,6 +585,10 @@ static void test_debug_loop(int argc, char **argv)
...
@@ -551,6 +585,10 @@ static void test_debug_loop(int argc, char **argv)
HeapFree
(
GetProcessHeap
(),
0
,
cmd
);
HeapFree
(
GetProcessHeap
(),
0
,
cmd
);
ret
=
pCheckRemoteDebuggerPresent
(
pi
.
hProcess
,
&
debug
);
ok
(
ret
,
"CheckRemoteDebuggerPresent failed, last error %#x.
\n
"
,
GetLastError
());
ok
(
debug
,
"Expected debug != 0, got %#x.
\n
"
,
debug
);
for
(;;)
for
(;;)
{
{
DEBUG_EVENT
ev
;
DEBUG_EVENT
ev
;
...
@@ -586,6 +624,8 @@ START_TEST(debugger)
...
@@ -586,6 +624,8 @@ START_TEST(debugger)
pCheckRemoteDebuggerPresent
=
(
void
*
)
GetProcAddress
(
hdll
,
"CheckRemoteDebuggerPresent"
);
pCheckRemoteDebuggerPresent
=
(
void
*
)
GetProcAddress
(
hdll
,
"CheckRemoteDebuggerPresent"
);
pDebugActiveProcessStop
=
(
void
*
)
GetProcAddress
(
hdll
,
"DebugActiveProcessStop"
);
pDebugActiveProcessStop
=
(
void
*
)
GetProcAddress
(
hdll
,
"DebugActiveProcessStop"
);
pDebugSetProcessKillOnExit
=
(
void
*
)
GetProcAddress
(
hdll
,
"DebugSetProcessKillOnExit"
);
pDebugSetProcessKillOnExit
=
(
void
*
)
GetProcAddress
(
hdll
,
"DebugSetProcessKillOnExit"
);
hdll
=
GetModuleHandle
(
"ntdll.dll"
);
if
(
hdll
)
pNtCurrentTeb
=
(
void
*
)
GetProcAddress
(
hdll
,
"NtCurrentTeb"
);
myARGC
=
winetest_get_mainargs
(
&
myARGV
);
myARGC
=
winetest_get_mainargs
(
&
myARGV
);
if
(
myARGC
>=
3
&&
strcmp
(
myARGV
[
2
],
"crash"
)
==
0
)
if
(
myARGC
>=
3
&&
strcmp
(
myARGV
[
2
],
"crash"
)
==
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment