-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOffset.cpp
52 lines (44 loc) · 1 KB
/
Offset.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <ntddk.h>
#include "Offset.h"
// ntoskrnl.exe
// ImageName : System
// PID : 4
// PLIST_ENTRY = PID + sizeof(PID)
extern "C"
ULONG CalcPIDOffset()
{
PEPROCESS peprocess = IoGetCurrentProcess();
HANDLE pid = PsGetCurrentProcessId();
PLIST_ENTRY list = NULL;
int i;
for (i = 0; i < PAGE_SIZE; i += 4)
{
if (*(PHANDLE)((PCHAR)peprocess + i) == pid)
{
// PLIST_ENTRY- PID
list = (PLIST_ENTRY)((unsigned char*)peprocess + i + sizeof(HANDLE));
if (MmIsAddressValid(list))
{
if (list == list->Flink->Blink)
{
return i;
}
}
}
}
return 0;
}
extern "C"
ULONG CalcProcessNameOffset()
{
PEPROCESS ntosKrnl = PsInitialSystemProcess;
int i = 0;
for (i = 0; i < PAGE_SIZE; i++)
{
if (RtlCompareMemory((PCHAR)ntosKrnl + i, "System", 6) == 6)
{
return i;
}
}
return 0;
}