diff options
author | Andrew Shadura <andrew@shadura.me> | 2014-06-17 11:57:32 +0200 |
---|---|---|
committer | Andrew Shadura <andrew@shadura.me> | 2014-06-17 11:57:32 +0200 |
commit | d1e7e16224c881ee3093658fe4cbf14db244cec7 (patch) | |
tree | 8850e7a55b4b1589a7a08e2364e9c12dad31962c /src/libmowgli/platform/win32/fork.c | |
parent | 246fb6b81eef837f1269073255373bf0a3d5c27a (diff) |
Update to the latest upstream snapshot
Diffstat (limited to 'src/libmowgli/platform/win32/fork.c')
-rw-r--r-- | src/libmowgli/platform/win32/fork.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/libmowgli/platform/win32/fork.c b/src/libmowgli/platform/win32/fork.c index c644122..a55d99c 100644 --- a/src/libmowgli/platform/win32/fork.c +++ b/src/libmowgli/platform/win32/fork.c @@ -31,17 +31,18 @@ #ifdef NOTYET -#ifdef _WIN32 +# ifdef _WIN32 -#ifndef _WIN32_WINNT +# ifndef _WIN32_WINNT -int fork(void) +int +fork(void) { -#warning fork is not possible on your platform in any sane way, sorry :( +# warning fork is not possible on your platform in any sane way, sorry :( return -ENOSYS; } -#else +# else extern NTSTATUS NTAPI CsrCallClientServer(void *message, void *userdata, uint32_t opcode, uint32_t size); @@ -50,7 +51,8 @@ extern NTSTATUS NTAPI CsrCallClientServer(void *message, void *userdata, uint32_ * * Not sure what dummy1/dummy2 do, but they're junk as far as I can see. */ -struct csrss_message { +struct csrss_message +{ uint32_t dummy1; uint32_t opcode; uint32_t status; @@ -77,10 +79,8 @@ inherit_handles(void) pid = GetCurrentProcessId(); for (i = 0; i < *p; i++) - { if (info[i].ProcessId == pid) SetHandleInformation((HANDLE) h[i].Handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT); - } mowgli_free(p); } @@ -88,27 +88,34 @@ inherit_handles(void) static inline void request_csrss_session(HANDLE proc_handle, HANDLE thread_handle, uint32_t pid, uint32_t tid) { - struct { + struct + { PORT_MESSAGE port_message; struct csrss_message csrss_message; + PROCESS_INFORMATION process_information; CLIENT_ID debugger; uint32_t flags; uint32_t vdminfo[2]; - } csrmsg = {{0}, {0}, {proc_handle, thread_handle, pid, tid}, {0}, 0, {0}}; + } csrmsg = + { + { 0 }, { 0 }, { proc_handle, thread_handle, pid, tid }, { 0 }, 0, { 0 } + }; CsrCallClientServer(&csrmsg, NULL, 0x10000, sizeof csrmsg); } -int child(void) +int +child(void) { typedef BOOL (*CsrpConnectToServer)(PWSTR); - CsrpConnectToServer (0x77F8F65D) (L"\\Windows"); + CsrpConnectToServer(0x77F8F65D) (L"\\Windows"); __asm__("mov eax, 0; mov esp, ebp; pop ebp; ret"); } -int fork(void) +int +fork(void) { HANDLE proc_handle, thread_handle; OBJECT_ATTRIBUTES oa = { sizeof(oa) }; @@ -133,8 +140,8 @@ int fork(void) ZwQueryVirtualMemory(NtCurrentProcess(), (void *) context.Esp, MemoryBasicInformation, &mbi, sizeof mbi, 0); - stack = (USER_STACK){0, 0, ((char *) mbi.BaseAddress) + mbi.RegionSize, - mbi.BaseAddress, mbi.AllocationBase}; + stack = (USER_STACK) { 0, 0, ((char *) mbi.BaseAddress) + mbi.RegionSize, + mbi.BaseAddress, mbi.AllocationBase }; /* now spawn the thread! */ ZwCreateThread(&thread_handle, THREAD_ALL_ACCESS, &oa, proc_handle, &cid, &context, &stack, TRUE); @@ -159,8 +166,8 @@ int fork(void) return (int) cid.UniqueProcess; } -#endif +# endif -#endif +# endif #endif |