Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <winternl.h>
- #include <stdio.h>
- __declspec(noinline)
- __declspec(naked)
- typedef struct _PROCESS_BASIC_INFORMATION
- {
- NTSTATUS ExitStatus;
- PPEB PebBaseAddress;
- ULONG_PTR AffinityMask;
- KPRIORITY BasePriority;
- HANDLE UniqueProcessId;
- HANDLE InheritedFromUniqueProcessId;
- } PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION;
- NTSTATUS CallNtQueryInformationProcess(
- NTSTATUS NtQueryInformationProcess(
- __in HANDLE ProcessHandle,
- __in PROCESSINFOCLASS ProcessInformationClass,
- __out_bcount(ProcessInformationLength) PVOID ProcessInformation,
- __in ULONG ProcessInformationLength,
- __out_opt PULONG ReturnLength
- )
- )
- {
- __asm {
- mov eax, 0x00A1 /* WIndows Server 2003 SP1 */
- mov edx, 0x7FFE0300 /* KUSER_SHARED_DATA syscall stub */
- call dword ptr [edx] /* call the stub code */
- ret
- }
- }
- int main(int argc, char *argv[])
- {
- int i =0;
- PROCESS_BASIC_INFORMATION basicInfo;
- __try {
- NTSTATUS i= CallNtQueryInformationProcess(NtCurrentProcess(),ProcessInformationClass, &basicInfo, sizeof(basicInfo), NULL);
- i=basicInfo.UniqueProcessId;
- }
- __finally{
- }
- return i;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement