//  
// VC6 Code By PiaoYun
typedef enum _PROCESS_INFORMATION_CLASS {
    ProcessBasicInformation,
        ProcessQuotaLimits,
        ProcessIoCounters,
        ProcessVmCounters,
        ProcessTimes,
        ProcessBasePriority,
        ProcessRaisePriority,
        ProcessDebugPort,
        ProcessExceptionPort,
        ProcessAccessToken,
        ProcessLdtInformation,
        ProcessLdtSize,
        ProcessDefaultHardErrorMode,
        ProcessIoPortHandlers,
        ProcessPooledUsageAndLimits,
        ProcessWorkingSetWatch,
        ProcessUserModeIOPL,
        ProcessEnableAlignmentFaultFixup,
        ProcessPriorityClass,
        ProcessWx86Information,
        ProcessHandleCount,
        ProcessAffinityMask,
        ProcessPriorityBoost,
        MaxProcessInfoClass
        
        
} PROCESS_INFORMATION_CLASS, *PPROCESS_INFORMATION_CLASS;

typedef LONG  NTSTATUS; 

void GetNtAPI()
{
    HMODULE NtHandle = NULL;
    typedef NTSTATUS (NTAPI *pfnNtQueryInformationProcess)(
        IN HANDLE               ProcessHandle,
        IN PROCESS_INFORMATION_CLASS ProcessInformationClass,
        OUT PVOID               ProcessInformation,
        IN ULONG                ProcessInformationLength,
        OUT PULONG              ReturnLength );

    typedef NTSTATUS (NTAPI *pfnNtReadVirtualMemory)(
        IN HANDLE               ProcessHandle,
        IN PVOID                BaseAddress,
        OUT PVOID               Buffer,
        IN ULONG                NumberOfBytesToRead,
        OUT PULONG              NumberOfBytesReaded OPTIONAL);

    typedef NTSTATUS (NTAPI *pfnNtWriteVirtualMemory)(
        IN HANDLE               ProcessHandle,
        IN PVOID                BaseAddress,
        IN PVOID                Buffer,
        IN ULONG                NumberOfBytesToWrite,
        OUT PULONG              NumberOfBytesWritten OPTIONAL );

    pfnNtQueryInformationProcess NtQueryInformationProcess = NULL;
    pfnNtReadVirtualMemory NtReadVirtualMemory = NULL;
    pfnNtWriteVirtualMemory NtWriteVirtualMemory = NULL;

    NtHandle = GetModuleHandleA(TEXT("ntdll.dll"));
    NtQueryInformationProcess = (pfnNtQueryInformationProcess)(GetProcAddress(NtHandle, TEXT("NtQueryInformationProcess")));
    NtReadVirtualMemory = (pfnNtReadVirtualMemory)(GetProcAddress(NtHandle, TEXT("NtReadVirtualMemory")));
    NtWriteVirtualMemory = (pfnNtWriteVirtualMemory)(GetProcAddress(NtHandle, TEXT("NtWriteVirtualMemory")));
}
/*
00401000  /$  56            PUSH    ESI
00401001  |.  57            PUSH    EDI
00401002  |.  68 60204000   PUSH    WinMain.00402060                                                    ; /pModule = "ntdll.dll"
00401007  |.  FF15 00204000 CALL    NEAR DWORD PTR DS:[<&KERNEL32.GetModuleHandleA>]                    ; \GetModuleHandleA
0040100D  |.  8B3D 08204000 MOV     EDI, DWORD PTR DS:[<&KERNEL32.GetProcAddress>]                      ;  kernel32.GetProcAddress
00401013  |.  8BF0          MOV     ESI, EAX
00401015  |.  68 44204000   PUSH    WinMain.00402044                                                    ; /ProcNameOrOrdinal = "NtQueryInformationProcess"
0040101A  |.  56            PUSH    ESI                                                                 ; |hModule
0040101B  |.  FFD7          CALL    NEAR EDI                                                            ; \GetProcAddress
0040101D  |.  68 30204000   PUSH    WinMain.00402030                                                    ; /ProcNameOrOrdinal = "NtReadVirtualMemory"
00401022  |.  56            PUSH    ESI                                                                 ; |hModule
00401023  |.  FFD7          CALL    NEAR EDI                                                            ; \GetProcAddress
00401025  |.  68 18204000   PUSH    WinMain.00402018                                                    ; /ProcNameOrOrdinal = "NtWriteVirtualMemory"
0040102A  |.  56            PUSH    ESI                                                                 ; |hModule
0040102B  |.  FFD7          CALL    NEAR EDI                                                            ; \GetProcAddress
0040102D  |.  5F            POP     EDI
0040102E  |.  5E            POP     ESI
0040102F  \.  C3            RETN
*/


你可能感兴趣的文章

评论区

发表评论

必填

选填

选填

必填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

您好,欢迎到访网站!
  [查看权限]

«   2018年9月   »
12
3456789
10111213141516
17181920212223
24252627282930