vxug-WinAPI-Tricks/Kernel32/GetCurrentProcessId.c
2021-05-28 12:40:53 -05:00

22 lines
373 B
C

#include <windows.h>
#include "TEB.h"
#define HandleToUlong ( h ) ((ULONG)(ULONG_PTR)(h) )
PTEB GetTeb(VOID)
{
#if defined(_WIN64)
return (PTEB)__readgsqword(0x30);
#elif define(_WIN32)
return (PTEB)__readfsdword(0x18);
#endif
}
DWORD GetCurrentProcessId(VOID)
{
PTEB Teb = GetTeb();
return HandleToUlong(Teb->ClientId.UniqueProcess);
}