ReactOS  0.4.15-dev-1386-g5cb9f87
process.c File Reference
#include <stdio.h>
#include "ntdll_test.h"
#include "windef.h"
#include "winbase.h"
Include dependency graph for process.c:

Go to the source code of this file.

Functions

static NTSTATUS (WINAPI *pNtResumeProcess)(HANDLE)
 
static void test_NtSuspendProcess (char *process_name)
 
static void dummy_process (char *event_name)
 
 START_TEST (process)
 

Variables

static PULONG
 

Function Documentation

◆ dummy_process()

static void dummy_process ( char event_name)
static

Definition at line 171 of file process.c.

172 {
173  HANDLE event = OpenEventA(EVENT_ALL_ACCESS, FALSE, event_name);
174 
175  while (TRUE)
176  {
177  SetEvent(event);
178  OutputDebugStringA("test");
179  Sleep(5);
180  }
181 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define TRUE
Definition: types.h:120
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define FALSE
Definition: types.h:117
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventA(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpName)
Definition: synch.c:669
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
struct _cl_event * event
Definition: glext.h:7739
void WINAPI SHIM_OBJ_NAME() OutputDebugStringA(LPCSTR lpOutputString)
Definition: ignoredbgout.c:18

Referenced by START_TEST().

◆ NTSTATUS()

static NTSTATUS ( WINAPI pNtResumeProcess)
static

◆ START_TEST()

START_TEST ( process  )

Definition at line 183 of file process.c.

184 {
185  HMODULE mod;
186  char **argv;
187  int argc;
188 
190  if (argc >= 4 && strcmp(argv[2], "dummy_process") == 0)
191  {
192  dummy_process(argv[3]);
193  return;
194  }
195 
196  mod = GetModuleHandleA("ntdll.dll");
197  if (!mod)
198  {
199  win_skip("Not running on NT, skipping tests\n");
200  return;
201  }
202 
203  pNtResumeProcess = (void*)GetProcAddress(mod, "NtResumeProcess");
204  pNtSuspendProcess = (void*)GetProcAddress(mod, "NtSuspendProcess");
205  pNtResumeThread = (void*)GetProcAddress(mod, "NtResumeThread");
206  pNtSuspendThread = (void*)GetProcAddress(mod, "NtSuspendThread");
207 
209 }
static int argc
Definition: ServiceArgs.c:12
static void dummy_process(char *event_name)
Definition: process.c:171
#define argv
Definition: mplay32.c:18
static void test_NtSuspendProcess(char *process_name)
Definition: process.c:33
int winetest_get_mainargs(char ***pargv)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define GetProcAddress(x, y)
Definition: compat.h:612
#define win_skip
Definition: test.h:149
static int mod
Definition: i386-dis.c:1281

◆ test_NtSuspendProcess()

static void test_NtSuspendProcess ( char process_name)
static

Definition at line 33 of file process.c.

34 {
36  DEBUG_EVENT ev;
39  HANDLE event;
40  char buffer[MAX_PATH];
41  ULONG count;
42  DWORD ret;
43 
44  status = pNtResumeProcess(GetCurrentProcess());
45  ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status);
46 
47  event = CreateEventA(NULL, TRUE, FALSE, "wine_suspend_event");
48  ok(!!event, "Failed to create event: %u\n", GetLastError());
49 
50  memset(&startup, 0, sizeof(startup));
51  startup.cb = sizeof(startup);
52 
53  sprintf(buffer, "%s tests/process.c dummy_process wine_suspend_event", process_name);
55  ok(ret, "CreateProcess failed with error %u\n", GetLastError());
56 
58  ok(ret == WAIT_OBJECT_0, "Event was not signaled: %d\n", ret);
59 
60  status = pNtSuspendProcess(info.hProcess);
61  ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status);
62 
64 
66  ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret);
67 
68  status = NtResumeThread(info.hThread, &count);
69  ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status);
70  ok(count == 1, "Expected count 1, got %d\n", count);
71 
73  ok(ret == WAIT_OBJECT_0, "Event was not signaled: %d\n", ret);
74 
75  status = pNtResumeProcess(info.hProcess);
76  ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status);
77 
78  status = pNtSuspendThread(info.hThread, &count);
79  ok(status == STATUS_SUCCESS, "NtSuspendThread failed: %x\n", status);
80  ok(count == 0, "Expected count 0, got %d\n", count);
81 
83 
85  ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret);
86 
87  status = pNtResumeProcess(info.hProcess);
88  ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status);
89 
91  ok(ret == WAIT_OBJECT_0, "Event was not signaled: %d\n", ret);
92 
93  status = pNtSuspendThread(info.hThread, &count);
94  ok(status == STATUS_SUCCESS, "NtSuspendThread failed: %x\n", status);
95  ok(count == 0, "Expected count 0, got %d\n", count);
96 
97  status = pNtSuspendThread(info.hThread, &count);
98  ok(status == STATUS_SUCCESS, "NtSuspendThread failed: %x\n", status);
99  ok(count == 1, "Expected count 1, got %d\n", count);
100 
101  ResetEvent(event);
102 
103  ret = WaitForSingleObject(event, 200);
104  ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret);
105 
106  status = pNtResumeProcess(info.hProcess);
107  ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status);
108 
109  ret = WaitForSingleObject(event, 200);
110  ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret);
111 
112  status = pNtResumeProcess(info.hProcess);
113  ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status);
114 
115  ret = WaitForSingleObject(event, 200);
116  ok(ret == WAIT_OBJECT_0, "Event was not signaled: %d\n", ret);
117 
118  ret = DebugActiveProcess(info.dwProcessId);
119  ok(ret, "Failed to debug process: %d\n", GetLastError());
120 
121  ResetEvent(event);
122 
123  ret = WaitForSingleObject(event, 200);
124  ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret);
125 
127  for (;;)
128  {
130  ok(ret, "WaitForDebugEvent failed, last error %#x.\n", GetLastError());
131  if (!ret) break;
132 
134 
136  ok(ret, "ContinueDebugEvent failed, last error %#x.\n", GetLastError());
137  if (!ret) break;
138  }
139 
140  ResetEvent(event);
141 
142  ret = WaitForSingleObject(event, 200);
143  ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret);
144 
145  status = pNtResumeProcess(info.hProcess);
146  ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status);
147 
148  ret = WaitForSingleObject(event, 200);
149  ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret);
150 
151  status = NtResumeThread(info.hThread, &count);
152  ok(status == STATUS_SUCCESS, "NtResumeProcess failed: %x\n", status);
153  ok(count == 0, "Expected count 0, got %d\n", count);
154 
155  ret = WaitForSingleObject(event, 200);
156  ok(ret == WAIT_TIMEOUT, "Expected timeout, got: %d\n", ret);
157 
159  ok(ret, "ContinueDebugEvent failed, last error %#x.\n", GetLastError());
160 
161  ret = WaitForSingleObject(event, 200);
163  ok(ret == WAIT_OBJECT_0, "Event was not signaled: %d\n", ret);
164 
165  TerminateProcess(info.hProcess, 0);
166 
167  CloseHandle(info.hProcess);
168  CloseHandle(info.hThread);
169 }
#define CloseHandle
Definition: compat.h:598
DWORD dwThreadId
Definition: winbase.h:768
#define TRUE
Definition: types.h:120
DWORD dwProcessId
Definition: winbase.h:767
GLuint GLuint GLsizei count
Definition: gl.h:1545
LONG NTSTATUS
Definition: precomp.h:26
BOOL WINAPI ContinueDebugEvent(IN DWORD dwProcessId, IN DWORD dwThreadId, IN DWORD dwContinueStatus)
Definition: debugger.c:448
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
int startup(int argc, const char *argv[])
Definition: startup.c:430
static JOBOBJECTINFOCLASS LPVOID info
Definition: process.c:79
#define DBG_CONTINUE
Definition: ntstatus.h:47
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
DWORD dwDebugEventCode
Definition: winbase.h:766
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
NTSTATUS NTAPI NtResumeThread(IN HANDLE ThreadHandle, OUT PULONG SuspendCount OPTIONAL)
Definition: state.c:290
#define WAIT_OBJECT_0
Definition: winbase.h:387
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4744
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define disable_success_count
Definition: test.h:170
#define WAIT_TIMEOUT
Definition: dderror.h:14
BOOL WINAPI WaitForDebugEvent(IN LPDEBUG_EVENT lpDebugEvent, IN DWORD dwMilliseconds)
Definition: debugger.c:625
int ret
#define GetCurrentProcess()
Definition: compat.h:618
struct _cl_event * event
Definition: glext.h:7739
#define ros_skip_flaky
Definition: test.h:166
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
unsigned int ULONG
Definition: retypes.h:1
#define OUTPUT_DEBUG_STRING_EVENT
Definition: winbase.h:109
#define STATUS_SUCCESS
Definition: shellext.h:65
BOOL WINAPI DebugActiveProcess(IN DWORD dwProcessId)
Definition: debugger.c:480
#define INFINITE
Definition: serial.h:102
#define memset(x, y, z)
Definition: compat.h:39
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by START_TEST().

Variable Documentation

◆ PULONG

Definition at line 30 of file process.c.