Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save spnow/d2e7ba26e180b9063c7b28ea505b89e0 to your computer and use it in GitHub Desktop.
Save spnow/d2e7ba26e180b9063c7b28ea505b89e0 to your computer and use it in GitHub Desktop.
#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <stdio.h>
#include <Winternl.h>
typedef DWORD (WINAPI *PFZWQUERYINFORMATIONPROCESS) (
HANDLE ProcessHandle,
DWORD ProcessInformationClass, // Origianl : _PROCESS_INFORMATION_CLASS
PVOID ProcessInformation,
ULONG ProcessInformationLength,
PULONG ReturnLength
);
int main(int argc, char **argv)
{
PROCESS_BASIC_INFORMATION pPib;
PFZWQUERYINFORMATIONPROCESS pfZwQueryInformationProcess;
HMODULE h_ntdll = GetModuleHandle("ntdll.dll");
pfZwQueryInformationProcess = (PFZWQUERYINFORMATIONPROCESS)GetProcAddress(h_ntdll, "ZwQueryInformationProcess");
pfZwQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pPib, sizeof(PROCESS_BASIC_INFORMATION), 0); // 0x0 : ProcessBasicInformation
printf("PEB Address Is : %p\n", pPib.PebBaseAddress);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment