#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
◆ main()
Definition at line 11 of file p_dup_handle.c.
11 {
13 HANDLE h_process_in_parent;
14
16
19 } else {
23 &h_process,
24 0,
27 fprintf(
stderr,
"%lu: Could not duplicate my own process handle.\n",
29 return 101;
30 }
31 }
32
37
38 memset( &si, 0,
sizeof( si ) );
40
46 return 5;
47 }
48
50 fprintf(
stderr,
"%lu: Failed to wait for child process to terminate.\n",
52 return 6;
53 }
54 } else {
57 h_process,
58 &h_process_in_parent,
59 0,
62 fprintf(
stderr,
"%lu: Could not duplicate my handle into the parent.\n",
64 return 102;
65 }
66 }
67
68 return 0;
69}
#define GetCurrentProcess()
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define sprintf(buf, format,...)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
DWORD WINAPI GetCurrentProcessId(void)
#define DUPLICATE_SAME_ACCESS