Merge pull request #49 from jazzwolf/main

Use utils:nt::handle instead of raw process handle
This commit is contained in:
Maurice Heumann 2022-10-07 19:00:27 +02:00 committed by GitHub
commit a4016c8c53

View File

@ -1,5 +1,4 @@
#define WIN32_LEAN_AND_MEAN #include <utils/nt.hpp>
#include <Windows.h>
#include <cstdlib> #include <cstdlib>
int __stdcall WinMain(HINSTANCE, HINSTANCE, PSTR, int) int __stdcall WinMain(HINSTANCE, HINSTANCE, PSTR, int)
@ -10,11 +9,10 @@ int __stdcall WinMain(HINSTANCE, HINSTANCE, PSTR, int)
if (parent_proc) if (parent_proc)
{ {
const auto pid = DWORD(atoi(parent_proc + strlen(command))); const auto pid = DWORD(atoi(parent_proc + strlen(command)));
auto* const process_handle = OpenProcess(SYNCHRONIZE, FALSE, pid); const utils::nt::handle<> process_handle = OpenProcess(SYNCHRONIZE, FALSE, pid);
if (process_handle) if (process_handle)
{ {
WaitForSingleObject(process_handle, INFINITE); WaitForSingleObject(process_handle, INFINITE);
CloseHandle(process_handle);
return 0; return 0;
} }
} }