Created
April 12, 2026 20:54
-
-
Save CX330Blake/59a430b8e022a3522142b7f00d06720f to your computer and use it in GitHub Desktop.
Prove that Nt and Zw Windows API are the same implementation inside.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <windows.h> | |
| typedef NTSTATUS (NTAPI *NtAllocateVirtualMemory_t)( | |
| HANDLE ProcessHandle, | |
| PVOID *BaseAddress, | |
| ULONG_PTR ZeroBits, | |
| PSIZE_T RegionSize, | |
| ULONG AllocationType, | |
| ULONG Protect | |
| ); | |
| int main() { | |
| HMODULE ntdll = GetModuleHandleA("ntdll.dll"); | |
| if (!ntdll) { | |
| printf("Failed to load ntdll.dll\n"); | |
| return 1; | |
| } | |
| FARPROC pNt = GetProcAddress(ntdll, "NtAllocateVirtualMemory"); | |
| FARPROC pZw = GetProcAddress(ntdll, "ZwAllocateVirtualMemory"); | |
| if (!pNt || !pZw) { | |
| printf("Failed to get function addresses.\n"); | |
| return 1; | |
| } | |
| printf("NtAllocateVirtualMemory address: %p\n", pNt); | |
| printf("ZwAllocateVirtualMemory address: %p\n", pZw); | |
| if (pNt == pZw) { | |
| printf("[+] They point to the same function!\n"); | |
| } else { | |
| printf("[-] They are different!\n"); | |
| } | |
| return 0; | |
| } | |
| // Output: | |
| // NtAllocateVirtualMemory address: 00007ffc24b8d7e0 | |
| // ZwAllocateVirtualMemory address: 00007ffc24b8d7e0 | |
| // [+] They point to the same function! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment