参考代码:
#include <winternl.h>
typedef
NTSTATUS(__stdcall* NTQUERYINFORMATIONPROCESS)(
HANDLE
ProcessHandle,
DWORD
ProcessInformationClass,
PVOID
ProcessInformation,
ULONG
ProcessInformationLength,
PULONG_PTR
ReturnLength
);
NTQUERYINFORMATIONPROCESS ntQueryInformationProcess;
int
main()
{
ULONG_PTR
debugPort = 0;
HMODULE
hModule = LoadLibrary(
"ntdll.dll"
);
ntQueryInformationProcess =
(NTQUERYINFORMATIONPROCESS)GetProcAddress(hModule,
"NtQueryInformationProcess"
);
ULONG_PTR
rets = ntQueryInformationProcess(GetCurrentProcess(), 0x1E, &debugPort,
sizeof
(debugPort), NULL);
printf
(
"debugPort:%d ntQueryInformationProcess返回值:%llx\n"
, debugPort, rets);
cout <<
"正常退出"
<< endl;
system
(
"pause"
);
}