forked from strivexjun/DriverInjectDll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc.cpp
29 lines (27 loc) · 967 Bytes
/
misc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "misc.h"
#include "undocumented.h"
ULONG Misc::GetProcessIDFromProcessHandle(HANDLE ProcessHandle)
{
PROCESS_BASIC_INFORMATION PBI;
if(NT_SUCCESS(Undocumented::ZwQueryInformationProcess(ProcessHandle, ProcessBasicInformation, &PBI, sizeof(PBI), NULL)))
return (ULONG)PBI.UniqueProcessId;
else
return 0;
}
ULONG Misc::GetProcessIDFromThreadHandle(HANDLE ThreadHandle)
{
typedef struct _THREAD_BASIC_INFORMATION
{
NTSTATUS ExitStatus;
PVOID TebBaseAddress;
CLIENT_ID ClientId;
KAFFINITY AffinityMask;
KPRIORITY Priority;
KPRIORITY BasePriority;
} THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION;
THREAD_BASIC_INFORMATION TBI;
if(NT_SUCCESS(Undocumented::ZwQueryInformationThread(ThreadHandle, ThreadBasicInformation, &TBI, sizeof(TBI), NULL)))
return PtrToUlong(TBI.ClientId.UniqueProcess);
else
return 0;
}