Non NTDLL Nt Functions

Introduction

In NTDLL Unhooking: User-Mode I covered the disk-read approach: map a clean ntdll.dll, copy .text over the hooked one, restore protection. This post is bypassing hook for specific functions rather then replacing ntdll. Goal is we will call the same Nt*/Zw* stubs from a different system DLL.

tprtdll.dll (execution host)

Shared with ntdll:

  • Syscalls: NtAllocateVirtualMemoryEx, ZwProtectVirtualMemory, ZwFreeVirtualMemory, ZwQueryVirtualMemory, NtClose, NtTerminateProcess, NtQueryInformationProcess, NtQueryInformationThread, ZwQuerySystemInformation, ZwOpenKey, ZwQueryValueKey, NtCreateEvent, NtSetEvent, NtResetEvent, NtDelayExecution, NtFlushProcessWriteBuffers, NtGetNextThread, ZwSetInformationThread
  • Loader: LdrLoadDll (divergent impl), LdrInitializeThunk, LdrDisableThreadCalloutsForDll
  • Threads: RtlCreateUserThread
  • Heap: RtlCreateHeap, RtlAllocateHeap, RtlReAllocateHeap, RtlFreeHeap, RtlDestroyHeap, RtlSizeHeap, RtlValidateHeap
  • Entropy: RtlRandom, RtlRandomEx

Check out https://github.com/ivancabrera02/tprtdll-Injection

vertdll.dll (I/O host)

VBS Enclave Runtime. Shared with ntdll:

  • Syscalls: NtClose, NtDeviceIoControlFile, NtOpenFile, NtOpenKey, NtQueryInformationProcess, NtQueryValueKey, NtTerminateProcess
  • Loader: LdrDisableThreadCalloutsForDll, LdrResolveDelayLoadedAPI (no LdrLoadDll)
  • Heap: RtlAllocateHeap, RtlFreeHeap

IumSdk.dll (ETW and token host)

Isolated User Mode SDK component. Shared with ntdll:

  • Syscalls: NtAlertThreadByThreadId, NtOpenProcessToken, NtOpenThreadToken, NtQueryInformationProcess, NtQueryInformationThread, NtQueryInformationToken, NtSetInformationProcess, NtSetInformationThread, NtTraceControl, NtTraceEvent, NtWaitForAlertByThreadId
  • Crypto / RNG: RtlRandom, RtlRandomEx

Comparison

Capability classtprtdllvertdllIumSdk
Memory alloc / protect / free✓
Cross-process memory write
Thread creation✓
Dynamic DLL load (LdrLoadDll)✓ (divergent impl)
Open file / device / pipe✓
Device IOCTL✓
Open process / thread token✓
Registry open / querypartial✓
ETW primitives (NtTrace*)✓
Process / thread set-informationpartial✓
Modern thread sync (NtAlertThreadByThreadId)✓

← Back to blog