Skip to content

Instantly share code, notes, and snippets.

@rbmm
Created November 28, 2025 08:06
Show Gist options
  • Select an option

  • Save rbmm/d7418d854594e2ec71d4464da4f8df07 to your computer and use it in GitHub Desktop.

Select an option

Save rbmm/d7418d854594e2ec71d4464da4f8df07 to your computer and use it in GitHub Desktop.
void TestDllReloc()
{
if (HMODULE hmod = GetModuleHandleW(L"kernel32.dll"))
{
STARTUPINFOW si = { sizeof(si) };
PROCESS_INFORMATION pi;
WCHAR cmd[] = L"notepad.exe";
if (CreateProcessW(0, cmd, 0, 0, FALSE, CREATE_SUSPENDED, 0, 0, &si, &pi))
{
VirtualAllocEx(pi.hProcess, hmod, 1, MEM_RESERVE, PAGE_NOACCESS);
ResumeThread(pi.hThread);
NtClose(pi.hThread);
NtClose(pi.hProcess);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment