ReactOS  0.4.13-dev-544-gede3fdd
process.c File Reference
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wincon.h"
#include "winnls.h"
#include "winternl.h"
#include "tlhelp32.h"
#include "wine/test.h"
#include "winnt.h"
Include dependency graph for process.c:

Go to the source code of this file.

Classes

struct  proc_thread_attr
 
struct  _PROC_THREAD_ATTRIBUTE_LIST
 

Macros

#define WIN32_NO_STATUS
 
#define PROCESS_ALL_ACCESS_NT4   (PROCESS_ALL_ACCESS & ~0xf000)
 
#define THREAD_ALL_ACCESS_NT4   (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3ff)
 
#define expect_eq_d(expected, actual)
 
#define expect_eq_s(expected, actual)
 
#define expect_eq_ws_i(expected, actual)
 
#define MAX_LISTED_ENV_VAR   128
 
#define okChildString(sect, key, expect)   ok_child_string(__LINE__, (sect), (key), (expect), 1 )
 
#define okChildIString(sect, key, expect)   ok_child_string(__LINE__, (sect), (key), (expect), 0 )
 
#define okChildStringWA(sect, key, expect)   ok_child_stringWA(__LINE__, (sect), (key), (expect), 1 )
 
#define okChildInt(sect, key, expect)   ok_child_int(__LINE__, (sect), (key), (expect))
 
#define INIT_STR   "Just some words"
 
#define test_completion(a, b, c, d, e)   _test_completion(__LINE__, a, b, c, d, e)
 
#define create_process(cmd, pi)   _create_process(__LINE__, cmd, pi)
 
#define test_assigned_proc(job, ...)   _test_assigned_proc(__LINE__, job, __VA_ARGS__)
 
#define test_accounting(job, total_proc, active_proc, terminated_proc)   _test_accounting(__LINE__, job, total_proc, active_proc, terminated_proc)
 

Functions

static void (WINAPI *pGetNativeSystemInfo)(LPSYSTEM_INFO)
 
static BOOL (WINAPI *pGetSystemRegistryQuota)(PDWORD
 
static LPVOID (WINAPI *pVirtualAllocEx)(HANDLE
 
static DWORD (WINAPI *pK32GetProcessImageFileNameA)(HANDLE
 
static HANDLE (WINAPI *pCreateJobObjectW)(LPSECURITY_ATTRIBUTES sa
 
static NTSTATUS (WINAPI *pNtQueryInformationProcess)(HANDLE
 
static PROCESSENTRY32 *static PROCESSENTRY32 *static THREADENTRY32 *static THREADENTRY32 *static SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX DWORD *static SIZE_T (WINAPI *pGetLargePageMinimum)(void)
 
static chargrab_memory (size_t len)
 
static void release_memory (void)
 
static const charencodeA (const char *str)
 
static const charencodeW (const WCHAR *str)
 
static unsigned decode_char (char c)
 
static chardecodeA (const char *str)
 
static WCHARdecodeW (const char *str)
 
static BOOL init (void)
 
static void get_file_name (char *buf)
 
static void WINETEST_PRINTF_ATTR (2, 3)
 
static void doChild (const char *file, const char *option)
 
static chargetChildString (const char *sect, const char *key)
 
static WCHARgetChildStringW (const char *sect, const char *key)
 
static int wtstrcasecmp (const char *p1, const char *p2)
 
static int strCmp (const char *s1, const char *s2, BOOL sensitive)
 
static void ok_child_string (int line, const char *sect, const char *key, const char *expect, int sensitive)
 
static void ok_child_stringWA (int line, const char *sect, const char *key, const char *expect, int sensitive)
 
static void ok_child_int (int line, const char *sect, const char *key, UINT expect)
 
static void test_Startup (void)
 
static void test_CommandLine (void)
 
static void test_Directory (void)
 
static void test_Toolhelp (void)
 
static BOOL is_str_env_drive_dir (const char *str)
 
static void cmpEnvironment (const char *gesA)
 
static void test_Environment (void)
 
static void test_SuspendFlag (void)
 
static void test_DebuggingFlag (void)
 
static BOOL is_console (HANDLE h)
 
static void test_Console (void)
 
static void test_ExitCode (void)
 
static void test_OpenProcess (void)
 
static void test_GetProcessVersion (void)
 
static void test_GetProcessImageFileNameA (void)
 
static void test_QueryFullProcessImageNameA (void)
 
static void test_QueryFullProcessImageNameW (void)
 
static void test_Handles (void)
 
static void test_IsWow64Process (void)
 
static void test_SystemInfo (void)
 
static void test_RegistryQuota (void)
 
static void test_TerminateProcess (void)
 
static void test_DuplicateHandle (void)
 
static void _test_completion (int line, HANDLE port, DWORD ekey, ULONG_PTR evalue, ULONG_PTR eoverlapped, DWORD wait)
 
static void _create_process (int line, const char *command, LPPROCESS_INFORMATION pi)
 
static void _test_assigned_proc (int line, HANDLE job, int expected_count,...)
 
static void _test_accounting (int line, HANDLE job, int total_proc, int active_proc, int terminated_proc)
 
static void test_IsProcessInJob (void)
 
static void test_TerminateJobObject (void)
 
static void test_QueryInformationJobObject (void)
 
static void test_CompletionPort (void)
 
static void test_KillOnJobClose (void)
 
static void test_WaitForJobObject (void)
 
static HANDLE test_AddSelfToJob (void)
 
static void test_jobInheritance (HANDLE job)
 
static void test_BreakawayOk (HANDLE job)
 
static void test_StartupNoConsole (void)
 
static void test_DetachConsoleHandles (void)
 
static void test_SuspendProcessNewThread (void)
 
static void test_SuspendProcessState (void)
 
static void test_DetachStdHandles (void)
 
static void test_GetNumaProcessorNode (void)
 
static void test_session_info (void)
 
static void test_process_info (void)
 
static void test_GetLogicalProcessorInformationEx (void)
 
static void test_largepages (void)
 
static void test_ProcThreadAttributeList (void)
 
static void test_GetActiveProcessorCount (void)
 
 START_TEST (process)
 

Variables

static HINSTANCE hkernel32
 
static HINSTANCE hntdll
 
static PDWORD
 
static PBOOL
 
static LPVOID
 
static SIZE_T
 
static DWORD
 
static DWORD dwFlags
 
static DWORD LPSTR lpExeName
 
static DWORD LPSTR PDWORD lpdwSize
 
static LPSTR
 
static LPCWSTR name
 
static HANDLE process
 
static HANDLE job
 
static HANDLE PBOOL result
 
static UINT exit_code
 
static JOBOBJECTINFOCLASS class
 
static JOBOBJECTINFOCLASS LPVOID info
 
static JOBOBJECTINFOCLASS LPVOID DWORD len
 
static JOBOBJECTINFOCLASS LPVOID DWORD LPDWORD ret_len
 
static HANDLE existing_port
 
static HANDLE ULONG_PTR key
 
static HANDLE ULONG_PTR DWORD threads
 
static PUCHAR
 
static PROCESSINFOCLASS
 
static PVOID
 
static ULONG
 
static PULONG
 
static SIZE_T *static DWORD_PTR
 
static char base [MAX_PATH]
 
static char selfname [MAX_PATH]
 
static charexename
 
static char resfile [MAX_PATH]
 
static int myARGC
 
static char ** myARGV
 
static char memory [1024 *256]
 
static charmemory_index = memory
 

Macro Definition Documentation

◆ create_process

#define create_process (   cmd,
  pi 
)    _create_process(__LINE__, cmd, pi)

Definition at line 2388 of file process.c.

◆ expect_eq_d

#define expect_eq_d (   expected,
  actual 
)
Value:
do { \
int value = (actual); \
ok((expected) == value, "Expected " #actual " to be %d (" #expected ") is %d\n", \
(expected), value); \
} while (0)
BOOL expected
Definition: store.c:2063

Definition at line 47 of file process.c.

◆ expect_eq_s

#define expect_eq_s (   expected,
  actual 
)
Value:
do { \
LPCSTR value = (actual); \
ok(lstrcmpA((expected), value) == 0, "Expected " #actual " to be L\"%s\" (" #expected ") is L\"%s\"\n", \
} while (0)
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
BOOL expected
Definition: store.c:2063

Definition at line 53 of file process.c.

◆ expect_eq_ws_i

#define expect_eq_ws_i (   expected,
  actual 
)
Value:
do { \
LPCWSTR value = (actual); \
ok(lstrcmpiW((expected), value) == 0, "Expected " #actual " to be L\"%s\" (" #expected ") is L\"%s\"\n", \
} while (0)
#define wine_dbgstr_w
Definition: kernel32.h:34
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
BOOL expected
Definition: store.c:2063

Definition at line 59 of file process.c.

◆ INIT_STR

#define INIT_STR   "Just some words"

◆ MAX_LISTED_ENV_VAR

#define MAX_LISTED_ENV_VAR   128

Definition at line 112 of file process.c.

◆ okChildInt

#define okChildInt (   sect,
  key,
  expect 
)    ok_child_int(__LINE__, (sect), (key), (expect))

Definition at line 600 of file process.c.

◆ okChildIString

#define okChildIString (   sect,
  key,
  expect 
)    ok_child_string(__LINE__, (sect), (key), (expect), 0 )

Definition at line 598 of file process.c.

◆ okChildString

#define okChildString (   sect,
  key,
  expect 
)    ok_child_string(__LINE__, (sect), (key), (expect), 1 )

Definition at line 597 of file process.c.

◆ okChildStringWA

#define okChildStringWA (   sect,
  key,
  expect 
)    ok_child_stringWA(__LINE__, (sect), (key), (expect), 1 )

Definition at line 599 of file process.c.

◆ PROCESS_ALL_ACCESS_NT4

#define PROCESS_ALL_ACCESS_NT4   (PROCESS_ALL_ACCESS & ~0xf000)

Definition at line 43 of file process.c.

◆ test_accounting

#define test_accounting (   job,
  total_proc,
  active_proc,
  terminated_proc 
)    _test_accounting(__LINE__, job, total_proc, active_proc, terminated_proc)

Definition at line 2437 of file process.c.

◆ test_assigned_proc

#define test_assigned_proc (   job,
  ... 
)    _test_assigned_proc(__LINE__, job, __VA_ARGS__)

Definition at line 2401 of file process.c.

◆ test_completion

#define test_completion (   a,
  b,
  c,
  d,
  e 
)    _test_completion(__LINE__, a, b, c, d, e)

Definition at line 2369 of file process.c.

◆ THREAD_ALL_ACCESS_NT4

#define THREAD_ALL_ACCESS_NT4   (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3ff)

Definition at line 45 of file process.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 29 of file process.c.

Function Documentation

◆ _create_process()

static void _create_process ( int  line,
const char command,
LPPROCESS_INFORMATION  pi 
)
static

Definition at line 2389 of file process.c.

2390 {
2391  BOOL ret;
2392  char buffer[MAX_PATH];
2393  STARTUPINFOA si = {0};
2394 
2395  sprintf(buffer, "\"%s\" tests/process.c %s", selfname, command);
2396 
2397  ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, pi);
2398  ok_(__FILE__, line)(ret, "CreateProcess error %u\n", GetLastError());
2399 }
#define ok_(x1, x2)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
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:4772
#define MAX_PATH
Definition: compat.h:26
static DWORD pi
Definition: protocol.c:150
int ret
static char selfname[MAX_PATH]
Definition: process.c:100

◆ _test_accounting()

static void _test_accounting ( int  line,
HANDLE  job,
int  total_proc,
int  active_proc,
int  terminated_proc 
)
static

Definition at line 2438 of file process.c.

2439 {
2440  JOBOBJECT_BASIC_ACCOUNTING_INFORMATION basic_accounting;
2441  DWORD ret_len;
2442  BOOL ret;
2443 
2444  memset(&basic_accounting, 0, sizeof(basic_accounting));
2445  ret = pQueryInformationJobObject(job, JobObjectBasicAccountingInformation, &basic_accounting, sizeof(basic_accounting), &ret_len);
2446  ok_(__FILE__, line)(ret, "QueryInformationJobObject error %u\n", GetLastError());
2447  if (ret)
2448  {
2449  /* Not going to check process times or page faults */
2450 
2451  todo_wine_if(total_proc)
2452  ok_(__FILE__, line)(total_proc == basic_accounting.TotalProcesses,
2453  "Expected basic_accounting.TotalProcesses to be %d (total_proc) is %d\n",
2454  total_proc, basic_accounting.TotalProcesses);
2455  todo_wine_if(active_proc)
2456  ok_(__FILE__, line)(active_proc == basic_accounting.ActiveProcesses,
2457  "Expected basic_accounting.ActiveProcesses to be %d (active_proc) is %d\n",
2458  active_proc, basic_accounting.ActiveProcesses);
2459  ok_(__FILE__, line)(terminated_proc == basic_accounting.TotalTerminatedProcesses,
2460  "Expected basic_accounting.TotalTerminatedProcesses to be %d (terminated_proc) is %d\n",
2461  terminated_proc, basic_accounting.TotalTerminatedProcesses);
2462  }
2463 }
static HANDLE job
Definition: process.c:77
#define ok_(x1, x2)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
#define todo_wine_if(is_todo)
Definition: test.h:155
unsigned long DWORD
Definition: ntddk_ex.h:95
static JOBOBJECTINFOCLASS LPVOID DWORD LPDWORD ret_len
Definition: process.c:79
int ret
#define memset(x, y, z)
Definition: compat.h:39

◆ _test_assigned_proc()

static void _test_assigned_proc ( int  line,
HANDLE  job,
int  expected_count,
  ... 
)
static

Definition at line 2402 of file process.c.

2403 {
2404  char buf[sizeof(JOBOBJECT_BASIC_PROCESS_ID_LIST) + sizeof(ULONG_PTR) * 20];
2406  DWORD ret_len, pid;
2407  va_list valist;
2408  int n;
2409  BOOL ret;
2410 
2411  memset(buf, 0, sizeof(buf));
2412  ret = pQueryInformationJobObject(job, JobObjectBasicProcessIdList, pid_list, sizeof(buf), &ret_len);
2413  ok_(__FILE__, line)(ret, "QueryInformationJobObject error %u\n", GetLastError());
2414  if (ret)
2415  {
2417  ok_(__FILE__, line)(expected_count == pid_list->NumberOfAssignedProcesses,
2418  "Expected NumberOfAssignedProcesses to be %d (expected_count) is %d\n",
2421  ok_(__FILE__, line)(expected_count == pid_list->NumberOfProcessIdsInList,
2422  "Expected NumberOfProcessIdsInList to be %d (expected_count) is %d\n",
2424 
2426  for (n = 0; n < min(expected_count, pid_list->NumberOfProcessIdsInList); ++n)
2427  {
2428  pid = va_arg(valist, DWORD);
2429  ok_(__FILE__, line)(pid == pid_list->ProcessIdList[n],
2430  "Expected pid_list->ProcessIdList[%d] to be %x is %lx\n",
2431  n, pid, pid_list->ProcessIdList[n]);
2432  }
2433  va_end(valist);
2434  }
2435 }
static HANDLE job
Definition: process.c:77
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
#define ok_(x1, x2)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble n
Definition: glext.h:7729
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define va_end(ap)
Definition: acmsvcex.h:90
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
char * va_list
Definition: acmsvcex.h:78
#define todo_wine_if(is_todo)
Definition: test.h:155
unsigned long DWORD
Definition: ntddk_ex.h:95
static JOBOBJECTINFOCLASS LPVOID DWORD LPDWORD ret_len
Definition: process.c:79
int ret
#define va_arg(ap, T)
Definition: acmsvcex.h:89
#define min(a, b)
Definition: monoChain.cc:55
#define va_start(ap, A)
Definition: acmsvcex.h:91
static int expected_count(int *sink)
struct _JOBOBJECT_BASIC_PROCESS_ID_LIST JOBOBJECT_BASIC_PROCESS_ID_LIST
static __ms_va_list valist
Definition: printf.c:59
#define memset(x, y, z)
Definition: compat.h:39

◆ _test_completion()

static void _test_completion ( int  line,
HANDLE  port,
DWORD  ekey,
ULONG_PTR  evalue,
ULONG_PTR  eoverlapped,
DWORD  wait 
)
static

Definition at line 2370 of file process.c.

2371 {
2373  ULONG_PTR value;
2374  DWORD key;
2375  BOOL ret;
2376 
2378 
2379  ok_(__FILE__, line)(ret, "GetQueuedCompletionStatus: %x\n", GetLastError());
2380  if (ret)
2381  {
2382  ok_(__FILE__, line)(key == ekey, "unexpected key %x\n", key);
2383  ok_(__FILE__, line)(value == evalue, "unexpected value %p\n", (void *)value);
2384  ok_(__FILE__, line)(overlapped == (LPOVERLAPPED)eoverlapped, "unexpected overlapped %p\n", overlapped);
2385  }
2386 }
#define ok_(x1, x2)
struct _OVERLAPPED * LPOVERLAPPED
BOOL WINAPI GetQueuedCompletionStatus(IN HANDLE CompletionHandle, IN LPDWORD lpNumberOfBytesTransferred, OUT PULONG_PTR lpCompletionKey, OUT LPOVERLAPPED *lpOverlapped, IN DWORD dwMilliseconds)
Definition: iocompl.c:114
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static HANDLE ULONG_PTR key
Definition: process.c:81
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLsizei const GLfloat * value
Definition: glext.h:6069
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:82
USHORT port
Definition: uri.c:227
Definition: path.c:42

◆ BOOL()

static BOOL ( WINAPI pGetSystemRegistryQuota)
static

◆ cmpEnvironment()

static void cmpEnvironment ( const char gesA)
static

Definition at line 1255 of file process.c.

1256 {
1257  int i, clen;
1258  const char* ptrA;
1259  char* res;
1260  char key[32];
1261  BOOL found;
1262 
1263  clen = GetPrivateProfileIntA("EnvironmentA", "len", 0, resfile);
1264 
1265  /* now look each parent env in child */
1266  if ((ptrA = gesA) != NULL)
1267  {
1268  while (*ptrA)
1269  {
1270  for (i = 0; i < clen; i++)
1271  {
1272  sprintf(key, "env%d", i);
1273  res = getChildString("EnvironmentA", key);
1274  if (strncmp(ptrA, res, MAX_LISTED_ENV_VAR - 1) == 0)
1275  break;
1276  }
1277  found = i < clen;
1278  ok(found, "Parent-env string %s isn't in child process\n", ptrA);
1279 
1280  ptrA += strlen(ptrA) + 1;
1281  release_memory();
1282  }
1283  }
1284  /* and each child env in parent */
1285  for (i = 0; i < clen; i++)
1286  {
1287  sprintf(key, "env%d", i);
1288  res = getChildString("EnvironmentA", key);
1289  if ((ptrA = gesA) != NULL)
1290  {
1291  while (*ptrA)
1292  {
1293  if (strncmp(res, ptrA, MAX_LISTED_ENV_VAR - 1) == 0)
1294  break;
1295  ptrA += strlen(ptrA) + 1;
1296  }
1297  if (!*ptrA) ptrA = NULL;
1298  }
1299 
1300  if (!is_str_env_drive_dir(res))
1301  {
1302  found = ptrA != NULL;
1303  ok(found, "Child-env string %s isn't in parent process\n", res);
1304  }
1305  /* else => should also test we get the right per drive default directory here... */
1306  }
1307 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static char resfile[MAX_PATH]
Definition: process.c:102
#define sprintf(buf, format,...)
Definition: sprintf.c:55
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static char * getChildString(const char *sect, const char *key)
Definition: process.c:506
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MAX_LISTED_ENV_VAR
Definition: process.c:112
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
static void release_memory(void)
Definition: process.c:129
static BOOL is_str_env_drive_dir(const char *str)
Definition: process.c:1246
GLuint res
Definition: glext.h:9613
UINT WINAPI GetPrivateProfileIntA(LPCSTR section, LPCSTR entry, INT def_val, LPCSTR filename)
Definition: profile.c:1326
Definition: path.c:42

Referenced by test_Environment().

◆ decode_char()

static unsigned decode_char ( char  c)
static

Definition at line 165 of file process.c.

166 {
167  if (c >= '0' && c <= '9') return c - '0';
168  if (c >= 'a' && c <= 'f') return c - 'a' + 10;
169  assert(c >= 'A' && c <= 'F');
170  return c - 'A' + 10;
171 }
#define assert(x)
Definition: debug.h:53
const GLubyte * c
Definition: glext.h:8905

Referenced by decodeA(), and decodeW().

◆ decodeA()

static char* decodeA ( const char str)
static

Definition at line 173 of file process.c.

174 {
175  char* ptr;
176  size_t len,i;
177 
178  len = strlen(str) / 2;
179  if (!len--) return NULL;
180  ptr = grab_memory(len + 1);
181  for (i = 0; i < len; i++)
182  ptr[i] = (decode_char(str[2 * i]) << 4) | decode_char(str[2 * i + 1]);
183  ptr[len] = '\0';
184  return ptr;
185 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
static char * grab_memory(size_t len)
Definition: process.c:119
static unsigned decode_char(char c)
Definition: process.c:165
static JOBOBJECTINFOCLASS LPVOID DWORD len
Definition: process.c:79
GLenum GLsizei len
Definition: glext.h:6722

Referenced by getChildString().

◆ decodeW()

static WCHAR* decodeW ( const char str)
static

Definition at line 190 of file process.c.

191 {
192  size_t len;
193  WCHAR* ptr;
194  int i;
195 
196  len = strlen(str) / 4;
197  if (!len--) return NULL;
198  ptr = (WCHAR*)grab_memory(len * 2 + 1);
199  for (i = 0; i < len; i++)
200  ptr[i] = (decode_char(str[4 * i]) << 12) |
201  (decode_char(str[4 * i + 1]) << 8) |
202  (decode_char(str[4 * i + 2]) << 4) |
203  (decode_char(str[4 * i + 3]) << 0);
204  ptr[len] = '\0';
205  return ptr;
206 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
static char * grab_memory(size_t len)
Definition: process.c:119
static unsigned decode_char(char c)
Definition: process.c:165
__wchar_t WCHAR
Definition: xmlstorage.h:180
static JOBOBJECTINFOCLASS LPVOID DWORD len
Definition: process.c:79
GLenum GLsizei len
Definition: glext.h:6722

Referenced by getChildStringW().

◆ doChild()

static void doChild ( const char file,
const char option 
)
static

Definition at line 306 of file process.c.

307 {
308  RTL_USER_PROCESS_PARAMETERS *params = NtCurrentTeb()->Peb->ProcessParameters;
309  STARTUPINFOA siA;
310  STARTUPINFOW siW;
311  int i;
312  char *ptrA, *ptrA_save;
313  WCHAR *ptrW, *ptrW_save;
314  char bufA[MAX_PATH];
315  WCHAR bufW[MAX_PATH];
318  PROCESSENTRY32 pe;
319  BOOL ret;
320 
321  if (hFile == INVALID_HANDLE_VALUE) return;
322 
323  /* output of startup info (Ansi) */
324  GetStartupInfoA(&siA);
325  childPrintf(hFile,
326  "[StartupInfoA]\ncb=%08u\nlpDesktop=%s\nlpTitle=%s\n"
327  "dwX=%u\ndwY=%u\ndwXSize=%u\ndwYSize=%u\n"
328  "dwXCountChars=%u\ndwYCountChars=%u\ndwFillAttribute=%u\n"
329  "dwFlags=%u\nwShowWindow=%u\n"
330  "hStdInput=%lu\nhStdOutput=%lu\nhStdError=%lu\n\n",
331  siA.cb, encodeA(siA.lpDesktop), encodeA(siA.lpTitle),
332  siA.dwX, siA.dwY, siA.dwXSize, siA.dwYSize,
334  siA.dwFlags, siA.wShowWindow,
336 
337  /* check the console handles in the TEB */
338  childPrintf(hFile, "[TEB]\nhStdInput=%lu\nhStdOutput=%lu\nhStdError=%lu\n\n",
339  (DWORD_PTR)params->hStdInput, (DWORD_PTR)params->hStdOutput,
340  (DWORD_PTR)params->hStdError);
341 
342  /* since GetStartupInfoW is only implemented in win2k,
343  * zero out before calling so we can notice the difference
344  */
345  memset(&siW, 0, sizeof(siW));
346  GetStartupInfoW(&siW);
347  childPrintf(hFile,
348  "[StartupInfoW]\ncb=%08u\nlpDesktop=%s\nlpTitle=%s\n"
349  "dwX=%u\ndwY=%u\ndwXSize=%u\ndwYSize=%u\n"
350  "dwXCountChars=%u\ndwYCountChars=%u\ndwFillAttribute=%u\n"
351  "dwFlags=%u\nwShowWindow=%u\n"
352  "hStdInput=%lu\nhStdOutput=%lu\nhStdError=%lu\n\n",
353  siW.cb, encodeW(siW.lpDesktop), encodeW(siW.lpTitle),
354  siW.dwX, siW.dwY, siW.dwXSize, siW.dwYSize,
356  siW.dwFlags, siW.wShowWindow,
358 
359  /* Arguments */
360  childPrintf(hFile, "[Arguments]\nargcA=%d\n", myARGC);
361  for (i = 0; i < myARGC; i++)
362  {
363  childPrintf(hFile, "argvA%d=%s\n", i, encodeA(myARGV[i]));
364  }
365  childPrintf(hFile, "CommandLineA=%s\n", encodeA(GetCommandLineA()));
366  childPrintf(hFile, "CommandLineW=%s\n\n", encodeW(GetCommandLineW()));
367 
368  /* output toolhelp information */
369  snapshot = pCreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
370  ok(snapshot != INVALID_HANDLE_VALUE, "CreateToolhelp32Snapshot failed %u\n", GetLastError());
371  memset(&pe, 0, sizeof(pe));
372  pe.dwSize = sizeof(pe);
373  if (pProcess32First(snapshot, &pe))
374  {
375  while (pe.th32ProcessID != GetCurrentProcessId())
376  if (!pProcess32Next(snapshot, &pe)) break;
377  }
379  ok(pe.th32ProcessID == GetCurrentProcessId(), "failed to find current process in snapshot\n");
380  childPrintf(hFile,
381  "[Toolhelp]\ncntUsage=%u\nth32DefaultHeapID=%lu\n"
382  "th32ModuleID=%u\ncntThreads=%u\nth32ParentProcessID=%u\n"
383  "pcPriClassBase=%u\ndwFlags=%u\nszExeFile=%s\n\n",
386  pe.dwFlags, encodeA(pe.szExeFile));
387 
388  /* output of environment (Ansi) */
389  ptrA_save = ptrA = GetEnvironmentStringsA();
390  if (ptrA)
391  {
393 
394  childPrintf(hFile, "[EnvironmentA]\n");
395  i = 0;
396  while (*ptrA)
397  {
399  childPrintf(hFile, "env%d=%s\n", i, encodeA(env_var));
400  i++;
401  ptrA += strlen(ptrA) + 1;
402  }
403  childPrintf(hFile, "len=%d\n\n", i);
404  FreeEnvironmentStringsA(ptrA_save);
405  }
406 
407  /* output of environment (Unicode) */
408  ptrW_save = ptrW = GetEnvironmentStringsW();
409  if (ptrW)
410  {
412 
413  childPrintf(hFile, "[EnvironmentW]\n");
414  i = 0;
415  while (*ptrW)
416  {
418  env_var[MAX_LISTED_ENV_VAR - 1] = '\0';
419  childPrintf(hFile, "env%d=%s\n", i, encodeW(env_var));
420  i++;
421  ptrW += lstrlenW(ptrW) + 1;
422  }
423  childPrintf(hFile, "len=%d\n\n", i);
424  FreeEnvironmentStringsW(ptrW_save);
425  }
426 
427  childPrintf(hFile, "[Misc]\n");
428  if (GetCurrentDirectoryA(sizeof(bufA), bufA))
429  childPrintf(hFile, "CurrDirA=%s\n", encodeA(bufA));
430  if (GetCurrentDirectoryW(sizeof(bufW) / sizeof(bufW[0]), bufW))
431  childPrintf(hFile, "CurrDirW=%s\n", encodeW(bufW));
432  childPrintf(hFile, "\n");
433 
434  if (option && strcmp(option, "console") == 0)
435  {
439  DWORD modeIn, modeOut;
440 
441  childPrintf(hFile, "[Console]\n");
442  if (GetConsoleScreenBufferInfo(hConOut, &sbi))
443  {
444  childPrintf(hFile, "SizeX=%d\nSizeY=%d\nCursorX=%d\nCursorY=%d\nAttributes=%d\n",
445  sbi.dwSize.X, sbi.dwSize.Y, sbi.dwCursorPosition.X, sbi.dwCursorPosition.Y, sbi.wAttributes);
446  childPrintf(hFile, "winLeft=%d\nwinTop=%d\nwinRight=%d\nwinBottom=%d\n",
447  sbi.srWindow.Left, sbi.srWindow.Top, sbi.srWindow.Right, sbi.srWindow.Bottom);
448  childPrintf(hFile, "maxWinWidth=%d\nmaxWinHeight=%d\n",
450  }
451  childPrintf(hFile, "InputCP=%d\nOutputCP=%d\n",
453  if (GetConsoleMode(hConIn, &modeIn))
454  childPrintf(hFile, "InputMode=%u\n", modeIn);
455  if (GetConsoleMode(hConOut, &modeOut))
456  childPrintf(hFile, "OutputMode=%u\n", modeOut);
457 
458  /* now that we have written all relevant information, let's change it */
459  SetLastError(0xdeadbeef);
460  ret = SetConsoleCP(1252);
462  {
463  win_skip("Setting the codepage is not implemented\n");
464  }
465  else
466  {
467  ok(ret, "Setting CP\n");
468  ok(SetConsoleOutputCP(1252), "Setting SB CP\n");
469  }
470 
471  ret = SetConsoleMode(hConIn, modeIn ^ 1);
472  ok( ret, "Setting mode (%d)\n", GetLastError());
473  ret = SetConsoleMode(hConOut, modeOut ^ 1);
474  ok( ret, "Setting mode (%d)\n", GetLastError());
475  sbi.dwCursorPosition.X ^= 1;
476  sbi.dwCursorPosition.Y ^= 1;
478  ok( ret, "Setting cursor position (%d)\n", GetLastError());
479  }
480  if (option && strcmp(option, "stdhandle") == 0)
481  {
484 
486  {
487  char buf[1024];
488  DWORD r, w;
489 
490  ok(ReadFile(hStdIn, buf, sizeof(buf), &r, NULL) && r > 0, "Reading message from input pipe\n");
491  childPrintf(hFile, "[StdHandle]\nmsg=%s\n\n", encodeA(buf));
492  ok(WriteFile(hStdOut, buf, r, &w, NULL) && w == r, "Writing message to output pipe\n");
493  }
494  }
495 
496  if (option && strcmp(option, "exit_code") == 0)
497  {
498  childPrintf(hFile, "[ExitCode]\nvalue=%d\n\n", 123);
500  ExitProcess(123);
501  }
502 
504 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
DWORD dwXSize
Definition: winbase.h:802
DWORD dwXSize
Definition: winbase.h:823
BOOL WINAPI SetConsoleOutputCP(IN UINT wCodepage)
Definition: console.c:644
DWORD dwXCountChars
Definition: winbase.h:804
DWORD cntThreads
Definition: tlhelp32.h:66
#define CloseHandle
Definition: compat.h:398
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
LPSTR lpTitle
Definition: winbase.h:799
DWORD th32ParentProcessID
Definition: tlhelp32.h:67
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1571
DWORD dwYSize
Definition: winbase.h:824
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:413
DWORD dwYCountChars
Definition: winbase.h:805
CHAR szExeFile[MAX_PATH]
Definition: tlhelp32.h:70
VOID WINAPI GetStartupInfoA(IN LPSTARTUPINFOA lpStartupInfo)
Definition: proc.c:1350
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1517
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI FreeEnvironmentStringsA(IN LPSTR EnvironmentStrings)
Definition: environ.c:379
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
HANDLE hStdOutput
Definition: winbase.h:833
DWORD dwFlags
Definition: winbase.h:807
static const char * encodeW(const WCHAR *str)
Definition: process.c:150
#define lstrlenW
Definition: compat.h:407
const char * env_var
Definition: db.cpp:868
DWORD dwY
Definition: winbase.h:801
struct snapshot snapshot
#define lstrcpynW
Definition: compat.h:397
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD dwY
Definition: winbase.h:822
GLenum const GLfloat * params
Definition: glext.h:5645
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1608
LPWSTR WINAPI GetCommandLineW(VOID)
Definition: proc.c:2043
#define GENERIC_WRITE
Definition: nt_native.h:90
HANDLE hStdOut
Definition: more.c:45
#define MAX_LISTED_ENV_VAR
Definition: process.c:112
LPWSTR lpDesktop
Definition: winbase.h:819
#define ok(value,...)
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP(VOID)
Definition: console.c:2453
smooth NULL
Definition: ftsmooth.c:416
Definition: getopt.h:108
LPWSTR lpTitle
Definition: winbase.h:820
BOOL WINAPI SetConsoleCursorPosition(IN HANDLE hConsoleOutput, IN COORD dwCursorPosition)
Definition: console.c:590
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleCP(VOID)
Definition: console.c:2393
#define STD_INPUT_HANDLE
Definition: winbase.h:264
DWORD dwYCountChars
Definition: winbase.h:826
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
SHORT Left
Definition: blue.h:25
ULONG X
Definition: bl.h:1340
DWORD dwYSize
Definition: winbase.h:803
DWORD dwX
Definition: winbase.h:800
DWORD cb
Definition: winbase.h:796
DWORD cb
Definition: winbase.h:817
SHORT Bottom
Definition: blue.h:28
BOOL WINAPI FreeEnvironmentStringsW(IN LPWSTR EnvironmentStrings)
Definition: environ.c:389
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
HANDLE hStdOutput
Definition: winbase.h:812
HANDLE hStdInput
Definition: winbase.h:832
#define SetLastError(x)
Definition: compat.h:409
SHORT Top
Definition: blue.h:26
DWORD dwFillAttribute
Definition: winbase.h:806
DWORD th32ProcessID
Definition: tlhelp32.h:63
LPSTR WINAPI GetCommandLineA(VOID)
Definition: proc.c:2033
DWORD dwXCountChars
Definition: winbase.h:825
int ret
DWORD th32DefaultHeapID
Definition: tlhelp32.h:64
DWORD th32ModuleID
Definition: tlhelp32.h:65
WORD wShowWindow
Definition: winbase.h:829
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
static const char * encodeA(const char *str)
Definition: process.c:136
uint32_t DWORD_PTR
Definition: typedefs.h:63
_In_ HANDLE hFile
Definition: mswsock.h:90
DWORD dwX
Definition: winbase.h:821
LPSTR WINAPI GetEnvironmentStringsA(VOID)
Definition: environ.c:293
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCP(UINT wCodePageID)
Definition: console.c:2422
HANDLE hStdIn
Definition: more.c:45
#define CREATE_ALWAYS
Definition: disk.h:72
DWORD dwFillAttribute
Definition: winbase.h:827
LPSTR lpDesktop
Definition: winbase.h:798
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
HANDLE hStdInput
Definition: winbase.h:811
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
HANDLE hStdError
Definition: winbase.h:834
static int myARGC
Definition: process.c:104
#define TH32CS_SNAPPROCESS
Definition: tlhelp32.h:26
WORD wShowWindow
Definition: winbase.h:808
#define lstrcpynA
Definition: compat.h:408
LPWSTR WINAPI GetEnvironmentStringsW(VOID)
Definition: environ.c:344
static char ** myARGV
Definition: process.c:105
LONG pcPriClassBase
Definition: tlhelp32.h:68
VOID WINAPI GetStartupInfoW(IN LPSTARTUPINFOW lpStartupInfo)
Definition: proc.c:1309
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
DWORD dwFlags
Definition: winbase.h:828
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
SHORT Right
Definition: blue.h:27
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
ULONG Y
Definition: bl.h:1341
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141
HANDLE hStdError
Definition: winbase.h:813
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1188
Definition: fci.c:126

Referenced by START_TEST().

◆ DWORD()

static DWORD ( WINAPI pK32GetProcessImageFileNameA)
static

◆ encodeA()

static const char* encodeA ( const char str)
static

Definition at line 136 of file process.c.

137 {
138  char* ptr;
139  size_t len,i;
140 
141  if (!str) return "";
142  len = strlen(str) + 1;
143  ptr = grab_memory(len * 2 + 1);
144  for (i = 0; i < len; i++)
145  sprintf(&ptr[i * 2], "%02x", (unsigned char)str[i]);
146  ptr[2 * len] = '\0';
147  return ptr;
148 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define sprintf(buf, format,...)
Definition: sprintf.c:55
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
static char * grab_memory(size_t len)
Definition: process.c:119
static JOBOBJECTINFOCLASS LPVOID DWORD len
Definition: process.c:79
GLenum GLsizei len
Definition: glext.h:6722

Referenced by doChild().

◆ encodeW()

static const char* encodeW ( const WCHAR str)
static

Definition at line 150 of file process.c.

151 {
152  char* ptr;
153  size_t len,i;
154 
155  if (!str) return "";
156  len = lstrlenW(str) + 1;
157  ptr = grab_memory(len * 4 + 1);
158  assert(ptr);
159  for (i = 0; i < len; i++)
160  sprintf(&ptr[i * 4], "%04x", (unsigned int)(unsigned short)str[i]);
161  ptr[4 * len] = '\0';
162  return ptr;
163 }
#define assert(x)
Definition: debug.h:53
#define lstrlenW
Definition: compat.h:407
#define sprintf(buf, format,...)
Definition: sprintf.c:55
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
static char * grab_memory(size_t len)
Definition: process.c:119
static JOBOBJECTINFOCLASS LPVOID DWORD len
Definition: process.c:79
GLenum GLsizei len
Definition: glext.h:6722

Referenced by doChild().

◆ get_file_name()

static void get_file_name ( char buf)
static

Definition at line 275 of file process.c.

276 {
277  char path[MAX_PATH];
278 
279  buf[0] = '\0';
280  GetTempPathA(sizeof(path), path);
281  GetTempFileNameA(path, "wt", 0, buf);
282 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define MAX_PATH
Definition: compat.h:26
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
Definition: services.c:325
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26

Referenced by test_CommandLine(), test_Console(), test_DebuggingFlag(), test_DetachConsoleHandles(), test_DetachStdHandles(), test_Directory(), test_Environment(), test_ExitCode(), test_Startup(), test_StartupNoConsole(), test_SuspendFlag(), and test_Toolhelp().

◆ getChildString()

static char* getChildString ( const char sect,
const char key 
)
static

Definition at line 506 of file process.c.

507 {
508  char buf[1024+4*MAX_LISTED_ENV_VAR];
509  char* ret;
510 
511  GetPrivateProfileStringA(sect, key, "-", buf, sizeof(buf), resfile);
512  if (buf[0] == '\0' || (buf[0] == '-' && buf[1] == '\0')) return NULL;
513  assert(!(strlen(buf) & 1));
514  ret = decodeA(buf);
515  return ret;
516 }
static char * decodeA(const char *str)
Definition: process.c:173
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define assert(x)
Definition: debug.h:53
static char resfile[MAX_PATH]
Definition: process.c:102
INT WINAPI GetPrivateProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR def_val, LPSTR buffer, UINT len, LPCSTR filename)
Definition: profile.c:1204
#define MAX_LISTED_ENV_VAR
Definition: process.c:112
smooth NULL
Definition: ftsmooth.c:416
int ret
Definition: path.c:42

Referenced by cmpEnvironment(), ok_child_string(), test_Console(), test_DebuggingFlag(), test_Startup(), and test_SuspendFlag().

◆ getChildStringW()

static WCHAR* getChildStringW ( const char sect,
const char key 
)
static

Definition at line 518 of file process.c.

519 {
520  char buf[1024+4*MAX_LISTED_ENV_VAR];
521  WCHAR* ret;
522 
523  GetPrivateProfileStringA(sect, key, "-", buf, sizeof(buf), resfile);
524  if (buf[0] == '\0' || (buf[0] == '-' && buf[1] == '\0')) return NULL;
525  assert(!(strlen(buf) & 1));
526  ret = decodeW(buf);
527  return ret;
528 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define assert(x)
Definition: debug.h:53
static char resfile[MAX_PATH]
Definition: process.c:102
static WCHAR * decodeW(const char *str)
Definition: process.c:190
INT WINAPI GetPrivateProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR def_val, LPSTR buffer, UINT len, LPCSTR filename)
Definition: profile.c:1204
#define MAX_LISTED_ENV_VAR
Definition: process.c:112
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
Definition: path.c:42

Referenced by ok_child_stringWA().

◆ grab_memory()

static char* grab_memory ( size_t  len)
static

Definition at line 119 of file process.c.

120 {
121  char* ret = memory_index;
122  /* align on dword */
123  len = (len + 3) & ~3;
124  memory_index += len;
125  assert(memory_index <= memory + sizeof(memory));
126  return ret;
127 }
#define assert(x)
Definition: debug.h:53
static char memory[1024 *256]
Definition: process.c:116
static JOBOBJECTINFOCLASS LPVOID DWORD len
Definition: process.c:79
static char * memory_index
Definition: process.c:117
int ret
GLenum GLsizei len
Definition: glext.h:6722

Referenced by decodeA(), decodeW(), encodeA(), and encodeW().

◆ HANDLE()

static HANDLE ( WINAPI pCreateJobObjectW)
static

◆ init()

static BOOL init ( void  )
static

Definition at line 217 of file process.c.

218 {
219  char *p;
220 
222  if (!GetCurrentDirectoryA(sizeof(base), base)) return FALSE;
223  strcpy(selfname, myARGV[0]);
224 
225  /* Strip the path of selfname */
226  if ((p = strrchr(selfname, '\\')) != NULL) exename = p + 1;
227  else exename = selfname;
228 
229  if ((p = strrchr(exename, '/')) != NULL) exename = p + 1;
230 
231  hkernel32 = GetModuleHandleA("kernel32");
232  hntdll = GetModuleHandleA("ntdll.dll");
233 
234  pNtQueryInformationProcess = (void *)GetProcAddress(hntdll, "NtQueryInformationProcess");
235 
236  pGetNativeSystemInfo = (void *) GetProcAddress(hkernel32, "GetNativeSystemInfo");
237  pGetSystemRegistryQuota = (void *) GetProcAddress(hkernel32, "GetSystemRegistryQuota");
238  pIsWow64Process = (void *) GetProcAddress(hkernel32, "IsWow64Process");
239  pVirtualAllocEx = (void *) GetProcAddress(hkernel32, "VirtualAllocEx");
240  pVirtualFreeEx = (void *) GetProcAddress(hkernel32, "VirtualFreeEx");
241  pQueryFullProcessImageNameA = (void *) GetProcAddress(hkernel32, "QueryFullProcessImageNameA");
242  pQueryFullProcessImageNameW = (void *) GetProcAddress(hkernel32, "QueryFullProcessImageNameW");
243  pK32GetProcessImageFileNameA = (void *) GetProcAddress(hkernel32, "K32GetProcessImageFileNameA");
244  pCreateJobObjectW = (void *)GetProcAddress(hkernel32, "CreateJobObjectW");
245  pAssignProcessToJobObject = (void *)GetProcAddress(hkernel32, "AssignProcessToJobObject");
246  pIsProcessInJob = (void *)GetProcAddress(hkernel32, "IsProcessInJob");
247  pTerminateJobObject = (void *)GetProcAddress(hkernel32, "TerminateJobObject");
248  pQueryInformationJobObject = (void *)GetProcAddress(hkernel32, "QueryInformationJobObject");
249  pSetInformationJobObject = (void *)GetProcAddress(hkernel32, "SetInformationJobObject");
250  pCreateIoCompletionPort = (void *)GetProcAddress(hkernel32, "CreateIoCompletionPort");
251  pGetNumaProcessorNode = (void *)GetProcAddress(hkernel32, "GetNumaProcessorNode");
252  pProcessIdToSessionId = (void *)GetProcAddress(hkernel32, "ProcessIdToSessionId");
253  pWTSGetActiveConsoleSessionId = (void *)GetProcAddress(hkernel32, "WTSGetActiveConsoleSessionId");
254  pCreateToolhelp32Snapshot = (void *)GetProcAddress(hkernel32, "CreateToolhelp32Snapshot");
255  pProcess32First = (void *)GetProcAddress(hkernel32, "Process32First");
256  pProcess32Next = (void *)GetProcAddress(hkernel32, "Process32Next");
257  pThread32First = (void *)GetProcAddress(hkernel32, "Thread32First");
258  pThread32Next = (void *)GetProcAddress(hkernel32, "Thread32Next");
259  pGetLogicalProcessorInformationEx = (void *)GetProcAddress(hkernel32, "GetLogicalProcessorInformationEx");
260  pGetLargePageMinimum = (void *)GetProcAddress(hkernel32, "GetLargePageMinimum");
261  pInitializeProcThreadAttributeList = (void *)GetProcAddress(hkernel32, "InitializeProcThreadAttributeList");
262  pUpdateProcThreadAttribute = (void *)GetProcAddress(hkernel32, "UpdateProcThreadAttribute");
263  pDeleteProcThreadAttributeList = (void *)GetProcAddress(hkernel32, "DeleteProcThreadAttributeList");
264  pGetActiveProcessorCount = (void *)GetProcAddress(hkernel32, "GetActiveProcessorCount");
265 
266  return TRUE;
267 }
#define TRUE
Definition: types.h:120
static HINSTANCE hkernel32
Definition: process.c:66
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
smooth NULL
Definition: ftsmooth.c:416
int winetest_get_mainargs(char ***pargv)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
static int myARGC
Definition: process.c:104
static HINSTANCE hntdll
Definition: process.c:66
static char ** myARGV
Definition: process.c:105
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define GetProcAddress(x, y)
Definition: compat.h:410
GLfloat GLfloat p
Definition: glext.h:8902
static char * exename
Definition: process.c:101
static char selfname[MAX_PATH]
Definition: process.c:100

Referenced by START_TEST().

◆ is_console()

static BOOL is_console ( HANDLE  h)
static

Definition at line 1510 of file process.c.

1511 {
1512  return h != INVALID_HANDLE_VALUE && ((ULONG_PTR)h & 3) == 3;
1513 }
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define ULONG_PTR
Definition: config.h:101

Referenced by test_Console(), and test_DuplicateHandle().

◆ is_str_env_drive_dir()

static BOOL is_str_env_drive_dir ( const char str)
static

Definition at line 1246 of file process.c.

1247 {
1248  return str[0] == '=' && str[1] >= 'A' && str[1] <= 'Z' && str[2] == ':' &&
1249  str[3] == '=' && str[4] == str[1];
1250 }
const WCHAR * str

Referenced by cmpEnvironment(), and test_Environment().

◆ LPVOID()

static LPVOID ( WINAPI pVirtualAllocEx)
static

◆ NTSTATUS()

static NTSTATUS ( WINAPI pNtQueryInformationProcess)
static

◆ ok_child_int()

static void ok_child_int ( int  line,
const char sect,
const char key,
UINT  expect 
)
static

Definition at line 591 of file process.c.

592 {
594  ok_(__FILE__, line)( result == expect, "%s:%s expected %u, but got %u\n", sect, key, expect, result );
595 }
#define ok_(x1, x2)
static char resfile[MAX_PATH]
Definition: process.c:102
static HANDLE ULONG_PTR key
Definition: process.c:81
Definition: parser.c:48
static HANDLE PBOOL result
Definition: process.c:77
#define expect(expected, got)
Definition: combo.c:36
unsigned int UINT
Definition: ndis.h:50
UINT WINAPI GetPrivateProfileIntA(LPCSTR section, LPCSTR entry, INT def_val, LPCSTR filename)
Definition: profile.c:1326
GLuint64EXT * result
Definition: glext.h:11304
Definition: path.c:42

◆ ok_child_string()

static void ok_child_string ( int  line,
const char sect,
const char key,
const char expect,
int  sensitive 
)
static

Definition at line 557 of file process.c.

559 {
560  char* result = getChildString( sect, key );
561  ok_(__FILE__, line)( strCmp(result, expect, sensitive) == 0, "%s:%s expected '%s', got '%s'\n",
562  sect, key, expect ? expect : "(null)", result );
563 }
static int strCmp(const char *s1, const char *s2, BOOL sensitive)
Definition: process.c:549
#define ok_(x1, x2)
static HANDLE ULONG_PTR key
Definition: process.c:81
static char * getChildString(const char *sect, const char *key)
Definition: process.c:506
Definition: parser.c:48
static HANDLE PBOOL result
Definition: process.c:77
#define expect(expected, got)
Definition: combo.c:36
GLuint64EXT * result
Definition: glext.h:11304
Definition: path.c:42

◆ ok_child_stringWA()

static void ok_child_stringWA ( int  line,
const char sect,
const char key,
const char expect,
int  sensitive 
)
static

Definition at line 565 of file process.c.

567 {
568  WCHAR* expectW;
569  CHAR* resultA;
570  DWORD len;
571  WCHAR* result = getChildStringW( sect, key );
572 
573  len = MultiByteToWideChar( CP_ACP, 0, expect, -1, NULL, 0);
574  expectW = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR));
575  MultiByteToWideChar( CP_ACP, 0, expect, -1, expectW, len);
576 
577  len = WideCharToMultiByte( CP_ACP, 0, result, -1, NULL, 0, NULL, NULL);
578  resultA = HeapAlloc(GetProcessHeap(),0,len*sizeof(CHAR));
579  WideCharToMultiByte( CP_ACP, 0, result, -1, resultA, len, NULL, NULL);
580 
581  if (sensitive)
582  ok_(__FILE__, line)( lstrcmpW(result, expectW) == 0, "%s:%s expected '%s', got '%s'\n",
583  sect, key, expect ? expect : "(null)", resultA );
584  else
585  ok_(__FILE__, line)( lstrcmpiW(result, expectW) == 0, "%s:%s expected '%s', got '%s'\n",
586  sect, key, expect ? expect : "(null)", resultA );
587  HeapFree(GetProcessHeap(),0,expectW);
588  HeapFree(GetProcessHeap(),0,resultA);
589 }
#define WideCharToMultiByte
Definition: compat.h:101
#define ok_(x1, x2)
#define CP_ACP
Definition: compat.h:99
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
char CHAR
Definition: xmlstorage.h:175
static HANDLE ULONG_PTR key
Definition: process.c:81
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static JOBOBJECTINFOCLASS LPVOID DWORD len
Definition: process.c:79
GLenum GLsizei len
Definition: glext.h:6722
#define expect(expected, got)
Definition: combo.c:36
#define MultiByteToWideChar
Definition: compat.h:100
static WCHAR * getChildStringW(const char *sect, const char *key)
Definition: process.c:518
GLuint64EXT * result
Definition: glext.h:11304
#define HeapFree(x, y, z)
Definition: compat.h:394
Definition: path.c:42

◆ release_memory()

static void release_memory ( void  )
static

◆ SIZE_T()

static PROCESSENTRY32* static PROCESSENTRY32* static THREADENTRY32* static THREADENTRY32* static SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX DWORD* static SIZE_T ( WINAPI pGetLargePageMinimum)
static

◆ START_TEST()

START_TEST ( process  )

Definition at line 3908 of file process.c.

3909 {
3910  HANDLE job;
3911  BOOL b = init();
3912  ok(b, "Basic init of CreateProcess test\n");
3913  if (!b) return;
3914 
3915  if (myARGC >= 3)
3916  {
3917  if (!strcmp(myARGV[2], "dump") && myARGC >= 4)
3918  {
3919  doChild(myARGV[3], (myARGC >= 5) ? myARGV[4] : NULL);
3920  return;
3921  }
3922  else if (!strcmp(myARGV[2], "wait"))
3923  {
3924  Sleep(30000);
3925  ok(0, "Child process not killed\n");
3926  return;
3927  }
3928  else if (!strcmp(myARGV[2], "exit"))
3929  {
3930  Sleep(100);
3931  return;
3932  }
3933  else if (!strcmp(myARGV[2], "nested") && myARGC >= 4)
3934  {
3935  char buffer[MAX_PATH];
3938 
3939  memset(&startup, 0, sizeof(startup));
3940  startup.cb = sizeof(startup);
3941  startup.dwFlags = STARTF_USESHOWWINDOW;
3942  startup.wShowWindow = SW_SHOWNORMAL;
3943 
3944  sprintf(buffer, "\"%s\" tests/process.c dump \"%s\"", selfname, myARGV[3]);
3945  ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &startup, &info), "CreateProcess failed\n");
3946  CloseHandle(info.hProcess);
3947  CloseHandle(info.hThread);
3948  return;
3949  }
3950 
3951  ok(0, "Unexpected command %s\n", myARGV[2]);
3952  return;
3953  }
3954 
3957  test_Startup();
3958  test_CommandLine();
3959  test_Directory();
3960  test_Toolhelp();
3961  test_Environment();
3962  test_SuspendFlag();
3964  test_Console();
3965  test_ExitCode();
3966  test_OpenProcess();
3971  test_Handles();
3973  test_SystemInfo();
3983  test_largepages();
3987 
3988  /* things that can be tested:
3989  * lookup: check the way program to be executed is searched
3990  * handles: check the handle inheritance stuff (+sec options)
3991  * console: check if console creation parameters work
3992  */
3993 
3994  if (!pCreateJobObjectW)
3995  {
3996  win_skip("No job object support\n");
3997  return;
3998  }
3999 
4006  job = test_AddSelfToJob();
4009  CloseHandle(job);
4010 }
static HANDLE job
Definition: process.c:77
static void test_WaitForJobObject(void)
Definition: process.c:2799
static void test_IsProcessInJob(void)
Definition: process.c:2465
static void test_Startup(void)
Definition: process.c:602
#define CloseHandle
Definition: compat.h:398
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
static void test_SuspendFlag(void)
Definition: process.c:1400
static void test_CommandLine(void)
Definition: process.c:888
static void test_TerminateProcess(void)
Definition: process.c:2235
static void test_largepages(void)
Definition: process.c:3759
static void test_ProcThreadAttributeList(void)
Definition: process.c:3789
GLuint buffer
Definition: glext.h:5915
int startup(int argc, const char *argv[])
Definition: startup.c:430
static void test_StartupNoConsole(void)
Definition: process.c:3015
static void test_ExitCode(void)
Definition: process.c:1703
static void test_Console(void)
Definition: process.c:1515
static JOBOBJECTINFOCLASS LPVOID info
Definition: process.c:79
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define CREATE_SUSPENDED
Definition: winbase.h:178
static void doChild(const char *file, const char *option)
Definition: process.c:306
static void test_session_info(void)
Definition: process.c:3551
unsigned int BOOL
Definition: ntddk_ex.h:94
static void test_CompletionPort(void)
Definition: process.c:2721
static void test_DetachConsoleHandles(void)
Definition: process.c:3043
#define ok(value,...)
static void test_QueryFullProcessImageNameW(void)
Definition: process.c:1977
smooth NULL
Definition: ftsmooth.c:416
static void test_Directory(void)
Definition: process.c:1096
#define STARTF_USESHOWWINDOW
Definition: winbase.h:472
static void test_KillOnJobClose(void)
Definition: process.c:2760
static void test_BreakawayOk(HANDLE job)
Definition: process.c:2937
static void test_DebuggingFlag(void)
Definition: process.c:1448
static void test_GetLogicalProcessorInformationEx(void)
Definition: process.c:3727
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
static void test_QueryInformationJobObject(void)
Definition: process.c:2600
static void test_Toolhelp(void)
Definition: process.c:1140
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:4772
#define MAX_PATH
Definition: compat.h:26
static void test_OpenProcess(void)
Definition: process.c:1732
static void test_GetNumaProcessorNode(void)
Definition: process.c:3518
static void test_SuspendProcessNewThread(void)
Definition: process.c:3458
static void test_jobInheritance(HANDLE job)
Definition: process.c:2904
static void test_QueryFullProcessImageNameA(void)
Definition: process.c:1922
static void test_Handles(void)
Definition: process.c:2067
static void test_DuplicateHandle(void)
Definition: process.c:2272
static HANDLE test_AddSelfToJob(void)
Definition: process.c:2888
static void test_DetachStdHandles(void)
Definition: process.c:3466
#define SW_SHOWNORMAL
Definition: winuser.h:764
static int myARGC
Definition: process.c:104
static BOOL init(void)
Definition: process.c:217
static char ** myARGV
Definition: process.c:105
static void test_SuspendProcessState(void)
Definition: process.c:3461
static void test_IsWow64Process(void)
Definition: process.c:2113
static void test_SystemInfo(void)
Definition: process.c:2169
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static void test_GetActiveProcessorCount(void)
Definition: process.c:3888
static void test_Environment(void)
Definition: process.c:1309
#define memset(x, y, z)
Definition: compat.h:39
static void test_GetProcessImageFileNameA(void)
Definition: process.c:1881
#define win_skip
Definition: test.h:141
static void test_process_info(void)
Definition: process.c:3570
static void test_GetProcessVersion(void)
Definition: process.c:1846
static char selfname[MAX_PATH]
Definition: process.c:100
static void test_TerminateJobObject(void)
Definition: process.c:2545
static void test_RegistryQuota(void)
Definition: process.c:2207

◆ strCmp()

static int strCmp ( const char s1,
const char s2,
BOOL  sensitive 
)
static

Definition at line 549 of file process.c.

550 {
551  if (!s1 && !s2) return 0;
552  if (!s2) return -1;
553  if (!s1) return 1;
554  return (sensitive) ? strcmp(s1, s2) : wtstrcasecmp(s1, s2);
555 }
struct S2 s2
struct S1 s1
static int wtstrcasecmp(const char *p1, const char *p2)
Definition: process.c:533
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by ok_child_string(), test_Console(), test_DebuggingFlag(), test_Startup(), and test_SuspendFlag().

◆ test_AddSelfToJob()

static HANDLE test_AddSelfToJob ( void  )
static

Definition at line 2888 of file process.c.

2889 {
2890  HANDLE job;
2891  BOOL ret;
2892 
2893  job = pCreateJobObjectW(NULL, NULL);
2894  ok(job != NULL, "CreateJobObject error %u\n", GetLastError());
2895 
2896  ret = pAssignProcessToJobObject(job, GetCurrentProcess());
2897  ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
2899  test_accounting(job, 1, 1, 0);
2900 
2901  return job;
2902 }
static HANDLE job
Definition: process.c:77
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
int ret
#define test_assigned_proc(job,...)
Definition: process.c:2401
#define test_accounting(job, total_proc, active_proc, terminated_proc)
Definition: process.c:2437
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1188

Referenced by START_TEST().

◆ test_BreakawayOk()

static void test_BreakawayOk ( HANDLE  job)
static

Definition at line 2937 of file process.c.

2938 {
2941  STARTUPINFOA si = {0};
2942  char buffer[MAX_PATH];
2943  BOOL ret, out;
2944  DWORD dwret;
2945 
2946  if (!pIsProcessInJob)
2947  {
2948  win_skip("IsProcessInJob not available.\n");
2949  return;
2950  }
2951 
2952  sprintf(buffer, "\"%s\" tests/process.c %s", selfname, "exit");
2953 
2955  ok(!ret, "CreateProcessA expected failure\n");
2958  test_accounting(job, 2, 1, 0);
2959 
2960  if (ret)
2961  {
2962  TerminateProcess(pi.hProcess, 0);
2963 
2964  dwret = WaitForSingleObject(pi.hProcess, 1000);
2965  ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", dwret);
2966 
2967  CloseHandle(pi.hProcess);
2968  CloseHandle(pi.hThread);
2969  }
2970 
2972  ret = pSetInformationJobObject(job, JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info));
2973  ok(ret, "SetInformationJobObject error %u\n", GetLastError());
2974 
2976  ok(ret, "CreateProcessA error %u\n", GetLastError());
2977 
2978  ret = pIsProcessInJob(pi.hProcess, job, &out);
2979  ok(ret, "IsProcessInJob error %u\n", GetLastError());
2980  ok(!out, "IsProcessInJob returned out=%u\n", out);
2982  test_accounting(job, 2, 1, 0);
2983 
2984  dwret = WaitForSingleObject(pi.hProcess, 1000);
2985  ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", dwret);
2986 
2987  CloseHandle(pi.hProcess);
2988  CloseHandle(pi.hThread);
2989 
2991  ret = pSetInformationJobObject(job, JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info));
2992  ok(ret, "SetInformationJobObject error %u\n", GetLastError());
2993 
2994  ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
2995  ok(ret, "CreateProcess error %u\n", GetLastError());
2996 
2997  ret = pIsProcessInJob(pi.hProcess, job, &out);
2998  ok(ret, "IsProcessInJob error %u\n", GetLastError());
2999  ok(!out, "IsProcessInJob returned out=%u\n", out);
3001  test_accounting(job, 2, 1, 0);
3002 
3003  dwret = WaitForSingleObject(pi.hProcess, 1000);
3004  ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", dwret);
3005 
3006  CloseHandle(pi.hProcess);
3007  CloseHandle(pi.hThread);
3008 
3009  /* unset breakaway ok */
3010  limit_info.BasicLimitInformation.LimitFlags = 0;
3011  ret = pSetInformationJobObject(job, JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info));
3012  ok(ret, "SetInformationJobObject error %u\n", GetLastError());
3013 }
#define expect_eq_d(expected, actual)
Definition: process.c:47
static HANDLE job
Definition: process.c:77
#define CloseHandle
Definition: compat.h:398
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define JOB_OBJECT_LIMIT_BREAKAWAY_OK
Definition: pstypes.h:215
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation
Definition: pstypes.h:1533
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#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:4772
#define MAX_PATH
Definition: compat.h:26
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD pi
Definition: protocol.c:150
int ret
#define test_assigned_proc(job,...)
Definition: process.c:2401
#define test_accounting(job, total_proc, active_proc, terminated_proc)
Definition: process.c:2437
#define JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK
Definition: pstypes.h:216
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1562
#define CREATE_BREAKAWAY_FROM_JOB
Definition: winbase.h:192
#define win_skip
Definition: test.h:141
static char selfname[MAX_PATH]
Definition: process.c:100
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1188

Referenced by START_TEST().

◆ test_CommandLine()

static void test_CommandLine ( void  )
static

Definition at line 888 of file process.c.

889 {
890  char buffer[MAX_PATH], fullpath[MAX_PATH], *lpFilePart, *p;
891  char buffer2[MAX_PATH];
894  BOOL ret;
895 
896  memset(&startup, 0, sizeof(startup));
897  startup.cb = sizeof(startup);
898  startup.dwFlags = STARTF_USESHOWWINDOW;
899  startup.wShowWindow = SW_SHOWNORMAL;
900 
901  /* the basics */
903  sprintf(buffer, "\"%s\" tests/process.c dump \"%s\" \"C:\\Program Files\\my nice app.exe\"", selfname, resfile);
904  ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
905  /* wait for child to terminate */
906  ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
907  /* child process has changed result file, so let profile functions know about it */
909  CloseHandle(info.hThread);
910  CloseHandle(info.hProcess);
911 
912  okChildInt("Arguments", "argcA", 5);
913  okChildString("Arguments", "argvA4", "C:\\Program Files\\my nice app.exe");
914  okChildString("Arguments", "argvA5", NULL);
915  okChildString("Arguments", "CommandLineA", buffer);
916  release_memory();
918 
919  memset(&startup, 0, sizeof(startup));
920  startup.cb = sizeof(startup);
921  startup.dwFlags = STARTF_USESHOWWINDOW;
922  startup.wShowWindow = SW_SHOWNORMAL;
923 
924  /* from François */
926  sprintf(buffer, "\"%s\" tests/process.c dump \"%s\" \"a\\\"b\\\\\" c\\\" d", selfname, resfile);
927  ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
928  /* wait for child to terminate */
929  ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
930  /* child process has changed result file, so let profile functions know about it */
932  CloseHandle(info.hThread);
933  CloseHandle(info.hProcess);
934 
935  okChildInt("Arguments", "argcA", 7);
936  okChildString("Arguments", "argvA4", "a\"b\\");
937  okChildString("Arguments", "argvA5", "c\"");
938  okChildString("Arguments", "argvA6", "d");
939  okChildString("Arguments", "argvA7", NULL);
940  okChildString("Arguments", "CommandLineA", buffer);
941  release_memory();
943 
944  /* Test for Bug1330 to show that XP doesn't change '/' to '\\' in argv[0]*/
946  /* Use exename to avoid buffer containing things like 'C:' */
947  sprintf(buffer, "./%s tests/process.c dump \"%s\" \"a\\\"b\\\\\" c\\\" d", exename, resfile);
948  SetLastError(0xdeadbeef);
950  ok(ret, "CreateProcess (%s) failed : %d\n", buffer, GetLastError());
951  /* wait for child to terminate */
952  ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
953  /* child process has changed result file, so let profile functions know about it */
955  CloseHandle(info.hThread);
956  CloseHandle(info.hProcess);
957  sprintf(buffer, "./%s", exename);
958  okChildString("Arguments", "argvA0", buffer);
959  release_memory();
961 
963  /* Use exename to avoid buffer containing things like 'C:' */
964  sprintf(buffer, ".\\%s tests/process.c dump \"%s\" \"a\\\"b\\\\\" c\\\" d", exename, resfile);
965  SetLastError(0xdeadbeef);
967  ok(ret, "CreateProcess (%s) failed : %d\n", buffer, GetLastError());
968  /* wait for child to terminate */
969  ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
970  /* child process has changed result file, so let profile functions know about it */
972  CloseHandle(info.hThread);
973  CloseHandle(info.hProcess);
974  sprintf(buffer, ".\\%s", exename);
975  okChildString("Arguments", "argvA0", buffer);
976  release_memory();
978 
981  assert ( lpFilePart != 0);
982  *(lpFilePart -1 ) = 0;
983  p = strrchr(fullpath, '\\');
984  /* Use exename to avoid buffer containing things like 'C:' */
985  if (p) sprintf(buffer, "..%s/%s tests/process.c dump \"%s\" \"a\\\"b\\\\\" c\\\" d", p, exename, resfile);
986  else sprintf(buffer, "./%s tests/process.c dump \"%s\" \"a\\\"b\\\\\" c\\\" d", exename, resfile);
987  SetLastError(0xdeadbeef);
989  ok(ret, "CreateProcess (%s) failed : %d\n", buffer, GetLastError());
990  /* wait for child to terminate */
991  ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
992  /* child process has changed result file, so let profile functions know about it */
994  CloseHandle(info.hThread);
995  CloseHandle(info.hProcess);
996  if (p) sprintf(buffer, "..%s/%s", p, exename);
997  else sprintf(buffer, "./%s", exename);
998  okChildString("Arguments", "argvA0", buffer);
999  release_memory();
1001 
1002  /* Using AppName */
1005  assert ( lpFilePart != 0);
1006  *(lpFilePart -1 ) = 0;
1007  p = strrchr(fullpath, '\\');
1008  /* Use exename to avoid buffer containing things like 'C:' */
1009  if (p) sprintf(buffer, "..%s/%s", p, exename);
1010  else sprintf(buffer, "./%s", exename);
1011  sprintf(buffer2, "dummy tests/process.c dump \"%s\" \"a\\\"b\\\\\" c\\\" d", resfile);
1012  SetLastError(0xdeadbeef);
1013  ret = CreateProcessA(buffer, buffer2, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
1014  ok(ret, "CreateProcess (%s) failed : %d\n", buffer, GetLastError());
1015  /* wait for child to terminate */
1016  ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
1017  /* child process has changed result file, so let profile functions know about it */
1019  CloseHandle(info.hThread);
1020  CloseHandle(info.hProcess);
1021  sprintf(buffer, "tests/process.c dump %s", resfile);
1022  okChildString("Arguments", "argvA0", "dummy");
1023  okChildString("Arguments", "CommandLineA", buffer2);
1024  okChildStringWA("Arguments", "CommandLineW", buffer2);
1025  release_memory();
1027 
1028  if (0) /* Test crashes on NT-based Windows. */
1029  {
1030  /* Test NULL application name and command line parameters. */
1031  SetLastError(0xdeadbeef);
1033  ok(!ret, "CreateProcessA unexpectedly succeeded\n");
1035  "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
1036  }
1037 
1038  buffer[0] = '\0';
1039 
1040  /* Test empty application name parameter. */
1041  SetLastError(0xdeadbeef);
1043  ok(!ret, "CreateProcessA unexpectedly succeeded\n");
1045  broken(GetLastError() == ERROR_FILE_NOT_FOUND) /* Win9x/WinME */ ||
1046  broken(GetLastError() == ERROR_ACCESS_DENIED) /* Win98 */,
1047  "Expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
1048 
1049  buffer2[0] = '\0';
1050 
1051  /* Test empty application name and command line parameters. */
1052  SetLastError(0xdeadbeef);
1053  ret = CreateProcessA(buffer, buffer2, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
1054  ok(!ret, "CreateProcessA unexpectedly succeeded\n");
1056  broken(GetLastError() == ERROR_FILE_NOT_FOUND) /* Win9x/WinME */ ||
1057  broken(GetLastError() == ERROR_ACCESS_DENIED) /* Win98 */,
1058  "Expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
1059 
1060  /* Test empty command line parameter. */
1061  SetLastError(0xdeadbeef);
1062  ret = CreateProcessA(NULL, buffer2, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
1063  ok(!ret, "CreateProcessA unexpectedly succeeded\n");
1065  GetLastError() == ERROR_PATH_NOT_FOUND /* NT4 */ ||
1066  GetLastError() == ERROR_BAD_PATHNAME /* Win98 */ ||
1067  GetLastError() == ERROR_INVALID_PARAMETER /* Win7 */,
1068  "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
1069 
1070  strcpy(buffer, "doesnotexist.exe");
1071  strcpy(buffer2, "does not exist.exe");
1072 
1073  /* Test nonexistent application name. */
1074  SetLastError(0xdeadbeef);
1076  ok(!ret, "CreateProcessA unexpectedly succeeded\n");
1077  ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
1078 
1079  SetLastError(0xdeadbeef);
1080  ret = CreateProcessA(buffer2, NULL, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
1081  ok(!ret, "CreateProcessA unexpectedly succeeded\n");
1082  ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
1083 
1084  /* Test nonexistent command line parameter. */
1085  SetLastError(0xdeadbeef);
1087  ok(!ret, "CreateProcessA unexpectedly succeeded\n");
1088  ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
1089 
1090  SetLastError(0xdeadbeef);
1091  ret = CreateProcessA(NULL, buffer2, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
1092  ok(!ret, "CreateProcessA unexpectedly succeeded\n");
1093  ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
1094 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD _Out_opt_ LPSTR * lpFilePart
Definition: winbase.h:3015
#define CloseHandle
Definition: compat.h:398
#define assert(x)
Definition: debug.h:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
static char resfile[MAX_PATH]
Definition: process.c:102
int startup(int argc, const char *argv[])
Definition: startup.c:430
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
static JOBOBJECTINFOCLASS LPVOID info
Definition: process.c:79
DWORD WINAPI GetFullPathNameA(IN LPCSTR lpFileName, IN DWORD nBufferLength, OUT LPSTR lpBuffer, OUT LPSTR *lpFilePart)
Definition: path.c:992
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
static void get_file_name(char *buf)
Definition: process.c:275
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define STARTF_USESHOWWINDOW
Definition: winbase.h:472
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#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:4772
#define MAX_PATH
Definition: compat.h:26
#define okChildStringWA(sect, key, expect)
Definition: process.c:599
#define SetLastError(x)
Definition: compat.h:409
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define broken(x)
Definition: _sntprintf.h:21
#define SW_SHOWNORMAL
Definition: winuser.h:764
static void release_memory(void)
Definition: process.c:129
#define okChildString(sect, key, expect)
Definition: process.c:597
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define okChildInt(sect, key, expect)
Definition: process.c:600
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
GLfloat GLfloat p
Definition: glext.h:8902
BOOL WINAPI DECLSPEC_HOTPATCH WritePrivateProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR string, LPCSTR filename)
Definition: profile.c:1484
static char * exename
Definition: process.c:101
#define memset(x, y, z)
Definition: compat.h:39
#define ERROR_BAD_PATHNAME
Definition: winerror.h:233
static char selfname[MAX_PATH]
Definition: process.c:100

Referenced by START_TEST().

◆ test_CompletionPort()

static void test_CompletionPort ( void  )
static

Definition at line 2721 of file process.c.

2722 {
2725  HANDLE job, port;
2726  DWORD dwret;
2727  BOOL ret;
2728 
2729  job = pCreateJobObjectW(NULL, NULL);
2730  ok(job != NULL, "CreateJobObject error %u\n", GetLastError());
2731 
2732  port = pCreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1);
2733  ok(port != NULL, "CreateIoCompletionPort error %u\n", GetLastError());
2734 
2735  port_info.CompletionKey = job;
2736  port_info.CompletionPort = port;
2737  ret = pSetInformationJobObject(job, JobObjectAssociateCompletionPortInformation, &port_info, sizeof(port_info));
2738  ok(ret, "SetInformationJobObject error %u\n", GetLastError());
2739 
2740  create_process("wait", &pi);
2741 
2742  ret = pAssignProcessToJobObject(job, pi.hProcess);
2743  ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
2744 
2746 
2747  TerminateProcess(pi.hProcess, 0);
2748  dwret = WaitForSingleObject(pi.hProcess, 1000);
2749  ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", dwret);
2750 
2753 
2754  CloseHandle(pi.hProcess);
2755  CloseHandle(pi.hThread);
2756  CloseHandle(job);
2757  CloseHandle(port);
2758 }
static HANDLE job
Definition: process.c:77
#define CloseHandle
Definition: compat.h:398
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
unsigned int BOOL
Definition: ntddk_ex.h:94
#define JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO
Definition: winnt_old.h:3538
#define test_completion(a, b, c, d, e)
Definition: process.c:2369
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
struct port_info port_info
static DWORD pi
Definition: protocol.c:150
int ret
uint32_t DWORD_PTR
Definition: typedefs.h:63
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1562
#define JOB_OBJECT_MSG_EXIT_PROCESS
Definition: winnt_old.h:3540
#define JOB_OBJECT_MSG_NEW_PROCESS
Definition: winnt_old.h:3539
USHORT port
Definition: uri.c:227
#define create_process(cmd, pi)
Definition: process.c:2388

Referenced by START_TEST().

◆ test_Console()

static void test_Console ( void  )
static

Definition at line 1515 of file process.c.

1516 {
1517  char buffer[MAX_PATH];
1521  CONSOLE_SCREEN_BUFFER_INFO sbi, sbiC;
1522  DWORD modeIn, modeOut, modeInC, modeOutC;
1523  DWORD cpIn, cpOut, cpInC, cpOutC;
1524  DWORD w;
1525  HANDLE hChildIn, hChildInInh, hChildOut, hChildOutInh, hParentIn, hParentOut;
1526  const char* msg = "This is a std-handle inheritance test.";
1527  unsigned msg_len;
1528  BOOL run_tests = TRUE;
1529  char *result;
1530 
1531  memset(&startup, 0, sizeof(startup));
1532  startup.cb = sizeof(startup);
1534  startup.wShowWindow = SW_SHOWNORMAL;
1535 
1536  sa.nLength = sizeof(sa);
1537  sa.lpSecurityDescriptor = NULL;
1538  sa.bInheritHandle = TRUE;
1539 
1540  startup.hStdInput = CreateFileA("CONIN$", GENERIC_READ|GENERIC_WRITE, 0, &sa, OPEN_EXISTING, 0, 0);
1541  startup.hStdOutput = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, &sa, OPEN_EXISTING, 0, 0);
1542 
1543  /* first, we need to be sure we're attached to a console */
1544  if (!is_console(startup.hStdInput) || !is_console(startup.hStdOutput))
1545  {
1546  /* we're not attached to a console, let's do it */
1547  AllocConsole();
1548  startup.hStdInput = CreateFileA("CONIN$", GENERIC_READ|GENERIC_WRITE, 0, &sa, OPEN_EXISTING, 0, 0);
1549  startup.hStdOutput = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, &sa, OPEN_EXISTING, 0, 0);
1550  }
1551  /* now verify everything's ok */
1552  ok(startup.hStdInput != INVALID_HANDLE_VALUE, "Opening ConIn\n");
1553  ok(startup.hStdOutput != INVALID_HANDLE_VALUE, "Opening ConOut\n");
1554  startup.hStdError = startup.hStdOutput;
1555 
1556  ok(GetConsoleScreenBufferInfo(startup.hStdOutput, &sbi), "Getting sb info\n");
1557  ok(GetConsoleMode(startup.hStdInput, &modeIn), "Getting console in mode\n");
1558  ok(GetConsoleMode(startup.hStdOutput, &modeOut), "Getting console out mode\n");
1559  cpIn = GetConsoleCP();
1560  cpOut = GetConsoleOutputCP();
1561 
1563  sprintf(buffer, "\"%s\" tests/process.c dump \"%s\" console", selfname, resfile);
1564  ok(CreateProcessA(NULL, buffer, NULL, NULL, TRUE, 0, NULL, NULL, &startup, &info), "CreateProcess\n");
1565 
1566  /* wait for child to terminate */
1567  ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
1568  /* child process has changed result file, so let profile functions know about it */
1570 
1571  /* now get the modification the child has made, and resets parents expected values */
1572  ok(GetConsoleScreenBufferInfo(startup.hStdOutput, &sbiC), "Getting sb info\n");
1573  ok(GetConsoleMode(startup.hStdInput, &modeInC), "Getting console in mode\n");
1574  ok(GetConsoleMode(startup.hStdOutput, &modeOutC), "Getting console out mode\n");
1575 
1576  SetConsoleMode(startup.hStdInput, modeIn);
1577  SetConsoleMode(startup.hStdOutput, modeOut);
1578 
1579  cpInC = GetConsoleCP();
1580  cpOutC = GetConsoleOutputCP();
1581 
1582  /* Try to set invalid CP */
1583  SetLastError(0xdeadbeef);
1584  ok(!SetConsoleCP(0), "Shouldn't succeed\n");
1587  "GetLastError: expecting %u got %u\n",
1590  run_tests = FALSE;
1591 
1592 
1593  SetLastError(0xdeadbeef);
1594  ok(!SetConsoleOutputCP(0), "Shouldn't succeed\n");
1597  "GetLastError: expecting %u got %u\n",
1599 
1600  SetConsoleCP(cpIn);
1601  SetConsoleOutputCP(cpOut);
1602 
1603  GetStartupInfoA(&us);
1604 
1605  okChildInt("StartupInfoA", "cb", startup.cb);
1606  okChildString("StartupInfoA", "lpDesktop", us.lpDesktop);
1607  result = getChildString( "StartupInfoA", "lpTitle" );
1608  ok( broken(!result) || (result && !strCmp( result, selfname, 0 )),
1609  "expected '%s' or null, got '%s'\n", selfname, result );
1610  okChildInt("StartupInfoA", "dwX", startup.dwX);
1611  okChildInt("StartupInfoA", "dwY", startup.dwY);
1612  okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
1613  okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
1614  okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
1615  okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
1616  okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
1617  okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
1618  okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
1619 
1620  /* check child correctly inherited the console */
1621  okChildInt("StartupInfoA", "hStdInput", (DWORD_PTR)startup.hStdInput);
1622  okChildInt("StartupInfoA", "hStdOutput", (DWORD_PTR)startup.hStdOutput);
1623  okChildInt("StartupInfoA", "hStdError", (DWORD_PTR)startup.hStdError);
1624  okChildInt("Console", "SizeX", (DWORD)sbi.dwSize.X);
1625  okChildInt("Console", "SizeY", (DWORD)sbi.dwSize.Y);
1626  okChildInt("Console", "CursorX", (DWORD)sbi.dwCursorPosition.X);
1627  okChildInt("Console", "CursorY", (DWORD)sbi.dwCursorPosition.Y);
1628  okChildInt("Console", "Attributes", sbi.wAttributes);
1629  okChildInt("Console", "winLeft", (DWORD)sbi.srWindow.Left);
1630  okChildInt("Console", "winTop", (DWORD)sbi.srWindow.Top);
1631  okChildInt("Console", "winRight", (DWORD)sbi.srWindow.Right);
1632  okChildInt("Console", "winBottom", (DWORD)sbi.srWindow.Bottom);
1633  okChildInt("Console", "maxWinWidth", (DWORD)sbi.dwMaximumWindowSize.X);
1634  okChildInt("Console", "maxWinHeight", (DWORD)sbi.dwMaximumWindowSize.Y);
1635  okChildInt("Console", "InputCP", cpIn);
1636  okChildInt("Console", "OutputCP", cpOut);
1637  okChildInt("Console", "InputMode", modeIn);
1638  okChildInt("Console", "OutputMode", modeOut);
1639 
1640  if (run_tests)
1641  {
1642  ok(cpInC == 1252, "Wrong console CP (expected 1252 got %d/%d)\n", cpInC, cpIn);
1643  ok(cpOutC == 1252, "Wrong console-SB CP (expected 1252 got %d/%d)\n", cpOutC, cpOut);
1644  }
1645  else
1646  win_skip("Setting the codepage is not implemented\n");
1647 
1648  ok(modeInC == (modeIn ^ 1), "Wrong console mode\n");
1649  ok(modeOutC == (modeOut ^ 1), "Wrong console-SB mode\n");
1650  trace("cursor position(X): %d/%d\n",sbi.dwCursorPosition.X, sbiC.dwCursorPosition.X);
1651  ok(sbiC.dwCursorPosition.Y == (sbi.dwCursorPosition.Y ^ 1), "Wrong cursor position\n");
1652 
1653  release_memory();
1655 
1656  ok(CreatePipe(&hParentIn, &hChildOut, NULL, 0), "Creating parent-input pipe\n");
1658  &hChildOutInh, 0, TRUE, DUPLICATE_SAME_ACCESS),
1659  "Duplicating as inheritable child-output pipe\n");
1660  CloseHandle(hChildOut);
1661 
1662  ok(CreatePipe(&hChildIn, &hParentOut, NULL, 0), "Creating parent-output pipe\n");
1664  &hChildInInh, 0, TRUE, DUPLICATE_SAME_ACCESS),
1665  "Duplicating as inheritable child-input pipe\n");
1666  CloseHandle(hChildIn);
1667 
1668  memset(&startup, 0, sizeof(startup));
1669  startup.cb = sizeof(startup);
1671  startup.wShowWindow = SW_SHOWNORMAL;
1672  startup.hStdInput = hChildInInh;
1673  startup.hStdOutput = hChildOutInh;
1674  startup.hStdError = hChildOutInh;
1675 
1677  sprintf(buffer, "\"%s\" tests/process.c dump \"%s\" stdhandle", selfname, resfile);
1678  ok(CreateProcessA(NULL, buffer, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &startup, &info), "CreateProcess\n");
1679  ok(CloseHandle(hChildInInh), "Closing handle\n");
1680  ok(CloseHandle(hChildOutInh), "Closing handle\n");
1681 
1682  msg_len = strlen(msg) + 1;
1683  ok(WriteFile(hParentOut, msg, msg_len, &w, NULL), "Writing to child\n");
1684  ok(w == msg_len, "Should have written %u bytes, actually wrote %u\n", msg_len, w);
1685  memset(buffer, 0, sizeof(buffer));
1686  ok(ReadFile(hParentIn, buffer, sizeof(buffer), &w, NULL), "Reading from child\n");
1687  ok(strcmp(buffer, msg) == 0, "Should have received '%s'\n", msg);
1688 
1689  /* the child may also send the final "n tests executed" string, so read it to avoid a deadlock */
1690  ReadFile(hParentIn, buffer, sizeof(buffer), &w, NULL);
1691 
1692  /* wait for child to terminate */
1693  ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
1694  /* child process has changed result file, so let profile functions know about it */
1696 
1697  okChildString("StdHandle", "msg", msg);
1698 
1699  release_memory();
1701 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define trace(...)
Definition: kmt_test.h:217
BOOL WINAPI SetConsoleOutputCP(IN UINT wCodepage)
Definition: console.c:644
#define TRUE
Definition: types.h:120
BOOL WINAPI AllocConsole(VOID)
Definition: console.c:48
#define CloseHandle
Definition: compat.h:398
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
static int strCmp(const char *s1, const char *s2, BOOL sensitive)
Definition: process.c:549
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static const BYTE us[]
Definition: encode.c:689
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1571
VOID WINAPI GetStartupInfoA(IN LPSTARTUPINFOA lpStartupInfo)
Definition: proc.c:1350
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
static char resfile[MAX_PATH]
Definition: process.c:102
int startup(int argc, const char *argv[])
Definition: startup.c:430
static BOOL is_console(HANDLE h)
Definition: process.c:1510
static JOBOBJECTINFOCLASS LPVOID info
Definition: process.c:79
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
static char * getChildString(const char *sect, const char *key)
Definition: process.c:506
#define DUPLICATE_SAME_ACCESS
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1608
#define GENERIC_WRITE
Definition: nt_native.h:90
#define ok(value,...)
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP(VOID)
Definition: console.c:2453
smooth NULL
Definition: ftsmooth.c:416
static void get_file_name(char *buf)
Definition: process.c:275
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleCP(VOID)
Definition: console.c:2393
#define STARTF_USESHOWWINDOW
Definition: winbase.h:472
#define OPEN_EXISTING
Definition: compat.h:426
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
SHORT Left
Definition: blue.h:25
ULONG X
Definition: bl.h:1340
#define STARTF_USESTDHANDLES
Definition: winbase.h:480
#define WAIT_OBJECT_0
Definition: winbase.h:387
SHORT Bottom
Definition: blue.h:28
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
static HANDLE PBOOL result
Definition: process.c:77
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:4772
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
SHORT Top
Definition: blue.h:26
#define GENERIC_READ
Definition: compat.h:124
uint32_t DWORD_PTR
Definition: typedefs.h:63
BOOL WINAPI CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize)
Definition: npipe.c:117
#define broken(x)
Definition: _sntprintf.h:21
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCP(UINT wCodePageID)
Definition: console.c:2422
#define SW_SHOWNORMAL
Definition: winuser.h:764
static void release_memory(void)
Definition: process.c:129
#define DETACHED_PROCESS
Definition: winbase.h:179
static BOOL run_tests(void)
Definition: run.c:2419
#define msg(x)
Definition: auth_time.c:54
#define okChildString(sect, key, expect)
Definition: process.c:597
#define okChildInt(sect, key, expect)
Definition: process.c:600
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
SHORT Right
Definition: blue.h:27
BOOL WINAPI DECLSPEC_HOTPATCH WritePrivateProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR string, LPCSTR filename)
Definition: profile.c:1484
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
ULONG Y
Definition: bl.h:1341
GLuint64EXT * result
Definition: glext.h:11304
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149
static char selfname[MAX_PATH]
Definition: process.c:100

Referenced by START_TEST().

◆ test_DebuggingFlag()

static void test_DebuggingFlag ( void  )
static

Definition at line 1448 of file process.c.

1449 {
1450  char buffer[MAX_PATH];
1451  void *processbase = NULL;
1454  DEBUG_EVENT de;
1455  unsigned dbg = 0;
1456  char *result;
1457 
1458  /* let's start simplistic */
1459  memset(&startup, 0, sizeof(startup));
1460  startup.cb = sizeof(startup);
1461  startup.dwFlags = STARTF_USESHOWWINDOW;
1462  startup.wShowWindow = SW_SHOWNORMAL;
1463 
1465  sprintf(buffer, "\"%s\" tests/process.c dump \"%s\"", selfname, resfile);
1466  ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, DEBUG_PROCESS, NULL, NULL, &startup, &info), "CreateProcess\n");
1467 
1468  /* get all startup events up to the entry point break exception */
1469  do
1470  {
1471  ok(WaitForDebugEvent(&de, INFINITE), "reading debug event\n");
1473  if (!dbg)
1474  {
1476  "first event: %d\n", de.dwDebugEventCode);
1477  processbase = de.u.CreateProcessInfo.lpBaseOfImage;
1478  }
1479  if (de.dwDebugEventCode != EXCEPTION_DEBUG_EVENT) dbg++;
1481  de.u.LoadDll.lpBaseOfDll != processbase, "got LOAD_DLL for main module\n");
1483 
1484  ok(dbg, "I have seen a debug event\n");
1485  /* wait for child to terminate */
1486  ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
1487  /* child process has changed result file, so let profile functions know about it */
1489 
1490  GetStartupInfoA(&us);
1491 
1492  okChildInt("StartupInfoA", "cb", startup.cb);
1493  okChildString("StartupInfoA", "lpDesktop", us.lpDesktop);
1494  result = getChildString( "StartupInfoA", "lpTitle" );
1495  ok( broken(!result) || (result && !strCmp( result, selfname, 0 )),
1496  "expected '%s' or null, got '%s'\n", selfname, result );
1497  okChildInt("StartupInfoA", "dwX", startup.dwX);
1498  okChildInt("StartupInfoA", "dwY", startup.dwY);
1499  okChildInt("StartupInfoA", "dwXSize", startup.dwXSize);
1500  okChildInt("StartupInfoA", "dwYSize", startup.dwYSize);
1501  okChildInt("StartupInfoA", "dwXCountChars", startup.dwXCountChars);
1502  okChildInt("StartupInfoA", "dwYCountChars", startup.dwYCountChars);
1503  okChildInt("StartupInfoA", "dwFillAttribute", startup.dwFillAttribute);
1504  okChildInt("StartupInfoA", "dwFlags", startup.dwFlags);
1505  okChildInt("StartupInfoA", "wShowWindow", startup.wShowWindow);
1506  release_memory();
1508 }
DWORD dwThreadId
Definition: winbase.h:768
static int strCmp(const char *s1, const char *s2, BOOL sensitive)
Definition: process.c:549
static const BYTE us[]
Definition: encode.c:689
DWORD dwProcessId
Definition: winbase.h:767
BOOL WINAPI ContinueDebugEvent(IN DWORD dwProcessId, IN DWORD dwThreadId, IN DWORD dwContinueStatus)
Definition: debugger.c:448
VOID WINAPI GetStartupInfoA(IN LPSTARTUPINFOA lpStartupInfo)
Definition: proc.c:1350
GLuint buffer
Definition: glext.h:5915
static char resfile[MAX_PATH]
Definition: process.c:102
int startup(int argc, const char *argv[])
Definition: startup.c:430
#define LOAD_DLL_DEBUG_EVENT
Definition: winbase.h:107
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
static char * getChildString(const char *sect, const char *key)
Definition: process.c:506
#define ok(value,...)
DWORD dwDebugEventCode
Definition: winbase.h:766
union _DEBUG_EVENT::@3139 u
smooth NULL
Definition: ftsmooth.c:416
static void get_file_name(char *buf)
Definition: process.c:275
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
CREATE_PROCESS_DEBUG_INFO CreateProcessInfo
Definition: winbase.h:772
#define STARTF_USESHOWWINDOW
Definition: winbase.h:472
#define EXIT_PROCESS_DEBUG_EVENT
Definition: winbase.h:106
#define WAIT_OBJECT_0
Definition: winbase.h:387
static HANDLE PBOOL result
Definition: process.c:77
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:4772
#define MAX_PATH
Definition: compat.h:26
#define DEBUG_PROCESS
Definition: winbase.h:176
BOOL WINAPI WaitForDebugEvent(IN LPDEBUG_EVENT lpDebugEvent, IN DWORD dwMilliseconds)
Definition: debugger.c:625
#define broken(x)
Definition: _sntprintf.h:21
#define SW_SHOWNORMAL
Definition: winuser.h:764
static void release_memory(void)
Definition: process.c:129
#define EXCEPTION_DEBUG_EVENT
Definition: winbase.h:102
#define okChildString(sect, key, expect)
Definition: process.c:597
#define okChildInt(sect, key, expect)
Definition: process.c:600
#define CREATE_PROCESS_DEBUG_EVENT
Definition: winbase.h:104
BOOL WINAPI DECLSPEC_HOTPATCH WritePrivateProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR string, LPCSTR filename)
Definition: profile.c:1484
#define INFINITE
Definition: serial.h:102
GLuint64EXT * result
Definition: glext.h:11304
#define memset(x, y, z)
Definition: compat.h:39
LOAD_DLL_DEBUG_INFO LoadDll
Definition: winbase.h:775
static char selfname[MAX_PATH]
Definition: process.c:100

Referenced by START_TEST().

◆ test_DetachConsoleHandles()

static void test_DetachConsoleHandles ( void  )
static

Definition at line 3043 of file process.c.

3044 {
3045 #ifndef _WIN64
3046  char buffer[MAX_PATH];
3049  UINT result;
3050 
3051  memset(&startup, 0, sizeof(startup));
3052  startup.cb = sizeof(startup);
3054  startup.wShowWindow = SW_SHOWNORMAL;
3055  startup.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
3056  startup.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
3057  startup.hStdError = GetStdHandle(STD_ERROR_HANDLE);
3059  sprintf(buffer, "\"%s\" tests/process.c dump \"%s\"", selfname, resfile);
3061  &info), "CreateProcess\n");
3062  ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
3064 
3065  result = GetPrivateProfileIntA("StartupInfoA", "hStdInput", 0, resfile);
3066  ok(result != 0 && result != (UINT)INVALID_HANDLE_VALUE, "bad handle %x\n", result);
3067  result = GetPrivateProfileIntA("StartupInfoA", "hStdOutput", 0, resfile);
3068  ok(result != 0 && result != (UINT)INVALID_HANDLE_VALUE, "bad handle %x\n", result);
3069  result = GetPrivateProfileIntA("StartupInfoA", "hStdError", 0, resfile);
3070  ok(result != 0 && result != (UINT)INVALID_HANDLE_VALUE, "bad handle %x\n", result);
3071  result = GetPrivateProfileIntA("TEB", "hStdInput", 0, resfile);
3072  ok(result != 0 && result != (UINT)INVALID_HANDLE_VALUE, "bad handle %x\n", result);
3073  result = GetPrivateProfileIntA("TEB", "hStdOutput", 0, resfile);
3074  ok(result != 0 && result != (UINT)INVALID_HANDLE_VALUE, "bad handle %x\n", result);
3075  result = GetPrivateProfileIntA("TEB", "hStdError", 0, resfile);
3076  ok(result != 0 && result != (UINT)INVALID_HANDLE_VALUE, "bad handle %x\n", result);
3077 
3078  release_memory();
3080 #endif
3081 }
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
GLuint buffer
Definition: glext.h:5915
static char resfile[MAX_PATH]
Definition: process.c:102
int startup(int argc, const char *argv[])
Definition: startup.c:430
static JOBOBJECTINFOCLASS LPVOID info
Definition: process.c:79
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
static void get_file_name(char *buf)
Definition: process.c:275
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define STARTF_USESHOWWINDOW
Definition: winbase.h:472
#define STD_INPUT_HANDLE
Definition: winbase.h:264
#define STARTF_USESTDHANDLES
Definition: winbase.h:480
#define WAIT_OBJECT_0
Definition: winbase.h:387
static HANDLE PBOOL result
Definition: process.c:77
#define STD_ERROR_HANDLE
Definition: winbase.h:266
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:4772
#define MAX_PATH
Definition: compat.h:26
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
#define SW_SHOWNORMAL
Definition: winuser.h:764
static void release_memory(void)
Definition: process.c:129
#define DETACHED_PROCESS
Definition: winbase.h:179
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI DECLSPEC_HOTPATCH WritePrivateProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR string, LPCSTR filename)
Definition: profile.c:1484
UINT WINAPI GetPrivateProfileIntA(LPCSTR section, LPCSTR entry, INT def_val, LPCSTR filename)
Definition: profile.c:1326
GLuint64EXT * result
Definition: glext.h:11304
#define memset(x, y, z)
Definition: compat.h:39
static char selfname[MAX_PATH]
Definition: process.c:100

Referenced by START_TEST().

◆ test_DetachStdHandles()

static void test_DetachStdHandles ( void  )
static

Definition at line 3466 of file process.c.

3467 {
3468 #ifndef _WIN64
3469  char buffer[MAX_PATH], tempfile[MAX_PATH];
3472  HANDLE hstdin, hstdout, hstderr, htemp;
3473  BOOL res;
3474 
3475  hstdin = GetStdHandle(STD_INPUT_HANDLE);
3476  hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
3477  hstderr = GetStdHandle(STD_ERROR_HANDLE);
3478 
3479  get_file_name(tempfile);
3480  htemp = CreateFileA(tempfile, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
3481  ok(htemp != INVALID_HANDLE_VALUE, "failed opening temporary file\n");
3482 
3483  memset(&startup, 0, sizeof(startup));
3484  startup.cb = sizeof(startup);
3485  startup.dwFlags = STARTF_USESHOWWINDOW;
3486  startup.wShowWindow = SW_SHOWNORMAL;
3488  sprintf(buffer, "\"%s\" tests/process.c dump \"%s\"", selfname, resfile);
3489 
3493 
3495  &info);
3496 
3497  SetStdHandle(STD_INPUT_HANDLE, hstdin);
3498  SetStdHandle(STD_OUTPUT_HANDLE, hstdout);
3499  SetStdHandle(STD_ERROR_HANDLE, hstderr);
3500 
3501  ok(res, "CreateProcess failed\n");
3502  ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
3504  okChildInt("StartupInfoA", "hStdInput", (UINT)INVALID_HANDLE_VALUE);
3505  okChildInt("StartupInfoA", "hStdOutput", (UINT)INVALID_HANDLE_VALUE);
3506  okChildInt("StartupInfoA", "hStdError", (UINT)INVALID_HANDLE_VALUE);
3507  okChildInt("TEB", "hStdInput", 0);
3508  okChildInt("TEB", "hStdOutput", 0);
3509  okChildInt("TEB", "hStdError", 0);
3510  release_memory();
3512 
3513  CloseHandle(htemp);
3514  DeleteFileA(tempfile);
3515 #endif
3516 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
GLuint buffer
Definition: glext.h:5915
static char resfile[MAX_PATH]
Definition: process.c:102
int startup(int argc, const char *argv[])
Definition: startup.c:430
static JOBOBJECTINFOCLASS LPVOID info
Definition: process.c:79
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
static void get_file_name(char *buf)
Definition: process.c:275
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define STARTF_USESHOWWINDOW
Definition: winbase.h:472
#define STD_INPUT_HANDLE
Definition: winbase.h:264
#define OPEN_EXISTING
Definition: compat.h:426
#define WAIT_OBJECT_0
Definition: winbase.h:387
#define STD_ERROR_HANDLE
Definition: winbase.h:266
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:4772
#define MAX_PATH
Definition: compat.h:26
BOOL WINAPI DECLSPEC_HOTPATCH SetStdHandle(DWORD nStdHandle, HANDLE hHandle)
Definition: console.c:1213
#define GENERIC_READ
Definition: compat.h:124
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
#define SW_SHOWNORMAL
Definition: winuser.h:764
static void release_memory(void)
Definition: process.c:129
#define DETACHED_PROCESS
Definition: winbase.h:179
unsigned int UINT
Definition: ndis.h:50
GLuint res
Definition: glext.h:9613
#define okChildInt(sect, key, expect)
Definition: process.c:600
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
BOOL WINAPI DECLSPEC_HOTPATCH WritePrivateProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR string, LPCSTR filename)
Definition: profile.c:1484
#define memset(x, y, z)
Definition: compat.h:39
static char selfname[MAX_PATH]
Definition: process.c:100

Referenced by START_TEST().

◆ test_Directory()

static void test_Directory ( void  )
static

Definition at line 1096 of file process.c.

1097 {
1098  char buffer[MAX_PATH];
1101  char windir[MAX_PATH];
1102  static CHAR cmdline[] = "winver.exe";
1103 
1104  memset(&startup, 0, sizeof(startup));
1105  startup.cb = sizeof(startup);
1106  startup.dwFlags = STARTF_USESHOWWINDOW;
1107  startup.wShowWindow = SW_SHOWNORMAL;
1108 
1109  /* the basics */
1111  sprintf(buffer, "\"%s\" tests/process.c dump \"%s\"", selfname, resfile);
1112  GetWindowsDirectoryA( windir, sizeof(windir) );
1113  ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, windir, &startup, &info), "CreateProcess\n");
1114  /* wait for child to terminate */
1115  ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
1116  /* child process has changed result file, so let profile functions know about it */
1118  CloseHandle(info.hThread);
1119  CloseHandle(info.hProcess);
1120 
1121  okChildIString("Misc", "CurrDirA", windir);
1122  release_memory();
1124 
1125  /* search PATH for the exe if directory is NULL */
1126  ok(CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
1127  ok(TerminateProcess(info.hProcess, 0), "Child process termination\n");
1128  CloseHandle(info.hThread);
1129  CloseHandle(info.hProcess);
1130 
1131  /* if any directory is provided, don't search PATH, error on bad directory */
1132  SetLastError(0xdeadbeef);
1133  memset(&info, 0, sizeof(info));
1135  NULL, "non\\existent\\directory", &startup, &info), "CreateProcess\n");
1136  ok(GetLastError() == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", GetLastError());
1137  ok(!TerminateProcess(info.hProcess, 0), "Child process should not exist\n");
1138 }
#define CloseHandle
Definition: compat.h:398
char CHAR
Definition: xmlstorage.h:175
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
static char resfile[MAX_PATH]
Definition: process.c:102
int startup(int argc, const char *argv[])
Definition: startup.c:430
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define ERROR_DIRECTORY
Definition: winerror.h:295
static JOBOBJECTINFOCLASS LPVOID info
Definition: process.c:79
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
static void get_file_name(char *buf)
Definition: process.c:275
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define STARTF_USESHOWWINDOW
Definition: winbase.h:472
#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:4772
#define MAX_PATH
Definition: compat.h:26
#define SetLastError(x)
Definition: compat.h:409
#define okChildIString(sect, key, expect)
Definition: process.c:598
static const WCHAR L[]
Definition: oid.c:1250
#define SW_SHOWNORMAL
Definition: winuser.h:764
static void release_memory(void)
Definition: process.c:129
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1562
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2336
BOOL WINAPI DECLSPEC_HOTPATCH WritePrivateProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR string, LPCSTR filename)
Definition: profile.c:1484
#define memset(x, y, z)
Definition: compat.h:39
static char selfname[MAX_PATH]
Definition: process.c:100

Referenced by START_TEST().

◆ test_DuplicateHandle()

static void test_DuplicateHandle ( void  )
static

Definition at line 2272 of file process.c.

2273 {
2274  char path[MAX_PATH], file_name[MAX_PATH];
2275  HANDLE f, fmin, out;
2276  DWORD info;
2277  BOOL r;
2278 
2280  GetCurrentProcess(), &out, 0, FALSE,
2282  ok(r, "DuplicateHandle error %u\n", GetLastError());
2284  ok(r, "GetHandleInformation error %u\n", GetLastError());
2285  ok(info == 0, "info = %x\n", info);
2286  ok(out != GetCurrentProcess(), "out = GetCurrentProcess()\n");
2287  CloseHandle(out);
2288 
2290  GetCurrentProcess(), &out, 0, TRUE,
2292  ok(r, "DuplicateHandle error %u\n", GetLastError());
2294  ok(r, "GetHandleInformation error %u\n", GetLastError());
2295  ok(info == HANDLE_FLAG_INHERIT, "info = %x\n", info);
2296  ok(out != GetCurrentProcess(), "out = GetCurrentProcess()\n");
2297  CloseHandle(out);
2298 
2300  GetTempFileNameA(path, "wt", 0, file_name);
2302  if (f == INVALID_HANDLE_VALUE)
2303  {
2304  ok(0, "could not create %s\n", file_name);
2305  return;
2306  }
2307 
2310  ok(r, "DuplicateHandle error %u\n", GetLastError());
2311  ok(f == out, "f != out\n");
2313  ok(r, "GetHandleInformation error %u\n", GetLastError());
2314  ok(info == 0, "info = %x\n", info);
2315 
2318  ok(r, "DuplicateHandle error %u\n", GetLastError());
2319  ok(f == out, "f != out\n");
2321  ok(r, "GetHandleInformation error %u\n", GetLastError());
2322  ok(info == HANDLE_FLAG_INHERIT, "info = %x\n", info);
2323 
2325  ok(r, "SetHandleInformation error %u\n", GetLastError());
2328  ok(r, "DuplicateHandle error %u\n", GetLastError());
2329  ok(f != out, "f == out\n");
2331  ok(r, "GetHandleInformation error %u\n", GetLastError());
2332  ok(info == HANDLE_FLAG_INHERIT, "info = %x\n", info);
2334  ok(r, "SetHandleInformation error %u\n", GetLastError());
2335 
2336  /* Test if DuplicateHandle allocates first free handle */
2337  if (f > out)
2338  {
2339  fmin = out;
2340  }
2341  else
2342  {
2343  fmin = f;
2344  f = out;
2345  }
2346  CloseHandle(fmin);
2349  ok(r, "DuplicateHandle error %u\n", GetLastError());
2350  ok(f == out, "f != out\n");
2351  CloseHandle(out);
2353 
2354  f = CreateFileA("CONIN$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
2355  if (!is_console(f))
2356  {
2357  skip("DuplicateHandle on console handle\n");
2358  CloseHandle(f);
2359  return;
2360  }
2361 
2364  ok(r, "DuplicateHandle error %u\n", GetLastError());
2365  todo_wine ok(f != out, "f == out\n");
2366  CloseHandle(out);
2367 }
#define DUPLICATE_CLOSE_SOURCE
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static BOOL is_console(HANDLE h)
Definition: process.c:1510
static JOBOBJECTINFOCLASS LPVOID info
Definition: process.c:79
#define DUPLICATE_SAME_ACCESS
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define HANDLE_FLAG_INHERIT
Definition: winbase.h:261
#define OPEN_EXISTING
Definition: compat.h:426
GLfloat f
Definition: glext.h:7540
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
#define MAX_PATH
Definition: compat.h:26
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
double __cdecl fmin(double, double)
#define todo_wine
Definition: test.h:154
#define GENERIC_READ
Definition: compat.h:124
#define CREATE_ALWAYS
Definition: disk.h:72
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
#define f
Definition: ke_i.h:83
Definition: services.c:325
#define HANDLE_FLAG_PROTECT_FROM_CLOSE
Definition: winbase.h:262
static LPCWSTR file_name
Definition: protocol.c:146
#define skip(...)
BOOL WINAPI GetHandleInformation(IN HANDLE hObject, OUT LPDWORD lpdwFlags)
Definition: handle.c:40
BOOL WINAPI SetHandleInformation(IN HANDLE hObject, IN DWORD dwMask, IN DWORD dwFlags)
Definition: handle.c:78
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149

Referenced by START_TEST().

◆ test_Environment()

static void test_Environment ( void  )
static

Definition at line 1309 of file process.c.

1310 {
1311  char buffer[MAX_PATH];
1314  char *child_env;
1315  int child_env_len;
1316  char *ptr;
1317  char *ptr2;
1318  char *env;
1319  int slen;
1320 
1321  memset(&startup, 0, sizeof(startup));
1322  startup.cb = sizeof(startup);
1323  startup.dwFlags = STARTF_USESHOWWINDOW;
1324  startup.wShowWindow = SW_SHOWNORMAL;
1325 
1326  /* the basics */
1328  sprintf(buffer, "\"%s\" tests/process.c dump \"%s\"", selfname, resfile);
1329  ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
1330  /* wait for child to terminate */
1331  ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
1332  /* child process has changed result file, so let profile functions know about it */
1334 
1337  release_memory();
1339 
1340  memset(&startup, 0, sizeof(startup));
1341  startup.cb = sizeof(startup);
1342  startup.dwFlags = STARTF_USESHOWWINDOW;
1343  startup.wShowWindow = SW_SHOWNORMAL;
1344 
1345  /* the basics */
1347  sprintf(buffer, "\"%s\" tests/process.c dump \"%s\"", selfname, resfile);
1348 
1349  child_env_len = 0;
1350  ptr = env;
1351