美文网首页
使用未导出函数ZwQuerySystemInformation获

使用未导出函数ZwQuerySystemInformation获

作者: f675b1a02698 | 来源:发表于2017-09-14 16:15 被阅读0次

#include

#include

#include

typedef struct _UNICODE_STRING {

USHORT Length;//UNICODE占用的内存字节数,个数*2;

USHORT MaximumLength;

PWSTR Buffer;

} UNICODE_STRING, *PUNICODE_STRING;

typedef struct _SYSTEM_BASIC_INFORMATION{

ULONG Reserved;

ULONG TimerResolution;

ULONG PageSize;

ULONG NumberOfPhysicalPages;

ULONG LowestPhysicalPageNumber;

ULONG HighestPhysicalPageNumber;

ULONG AllocationGranularity;

ULONG_PTR MinimumUserModeAddress;

ULONG_PTR MaximumUserModeAddress;

ULONG_PTR ActiveProcessorsAffinityMask;

CCHAR NumberOfProcessors;

}SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION;

typedef enum _SYSTEM_INFORMATION_CLASS {

SystemBasicInformation,// 0 Y N

SystemProcessorInformation,// 1 Y N

SystemPerformanceInformation,// 2 Y N

SystemTimeOfDayInformation,// 3 Y N

SystemNotImplemented1,// 4 Y N // SystemPathInformation

SystemProcessesAndThreadsInformation,// 5 Y N

SystemCallCounts,// 6 Y N

SystemConfigurationInformation,// 7 Y N

SystemProcessorTimes,// 8 Y N

SystemGlobalFlag,// 9 Y Y

SystemNotImplemented2,// 10 YN // SystemCallTimeInformation

SystemModuleInformation,// 11 YN

SystemLockInformation,// 12 YN

SystemNotImplemented3,// 13 YN // SystemStackTraceInformation

SystemNotImplemented4,// 14 YN // SystemPagedPoolInformation

SystemNotImplemented5,// 15 YN // SystemNonPagedPoolInformation

SystemHandleInformation,// 16 YN

SystemObjectInformation,// 17 YN

SystemPagefileInformation,// 18 YN

SystemInstructionEmulationCounts,// 19 YN

SystemInvalidInfoClass1,// 20

SystemCacheInformation,// 21 YY

SystemPoolTagInformation,// 22 YN

SystemProcessorStatistics,// 23 YN

SystemDpcInformation,// 24 YY

SystemNotImplemented6,// 25 YN // SystemFullMemoryInformation

SystemLoadImage,// 26 NY // SystemLoadGdiDriverInformation

SystemUnloadImage,// 27 NY

SystemTimeAdjustment,// 28 YY

SystemNotImplemented7,// 29 YN // SystemSummaryMemoryInformation

SystemNotImplemented8,// 30 YN // SystemNextEventIdInformation

SystemNotImplemented9,// 31 YN // SystemEventIdsInformation

SystemCrashDumpInformation,// 32 YN

SystemExceptionInformation,// 33 YN

SystemCrashDumpStateInformation,// 34 YY/N

SystemKernelDebuggerInformation,// 35 YN

SystemContextSwitchInformation,// 36 YN

SystemRegistryQuotaInformation,// 37 YY

SystemLoadAndCallImage,// 38 NY // SystemExtendServiceTableInformation

SystemPrioritySeparation,// 39 NY

SystemNotImplemented10,// 40 YN // SystemPlugPlayBusInformation

SystemNotImplemented11,// 41 YN // SystemDockInformation

SystemInvalidInfoClass2,// 42 // SystemPowerInformation

SystemInvalidInfoClass3,// 43 // SystemProcessorSpeedInformation

SystemTimeZoneInformation,// 44 YN

SystemLookasideInformation,// 45 YN

SystemSetTimeSlipEvent,// 46 NY

SystemCreateSession,// 47 NY

SystemDeleteSession,// 48 NY

SystemInvalidInfoClass4,// 49

SystemRangeStartInformation,// 50 YN

SystemVerifierInformation,// 51 YY

SystemAddVerifier,// 52 NY

SystemSessionProcessesInformation// 53 YN

} SYSTEM_INFORMATION_CLASS;

int main(int argc, PCHAR argv[]){

NTSTATUS hModule;

hModule = LoadLibrary("ntdll.dll");

DWORD dizhi = GetProcAddress(hModule, "KiFastSystemCall");

printf("地址是: %p KiFastSystemCall地址是: %p\n", hModule, dizhi);

//定义一个函数指针类型,参数符合对应函数

typedef NTSTATUS (WINAPI *SIFC)(IN SYSTEM_INFORMATION_CLASS, IN PVOID, IN ULONG, OUT PULONG);

//这样就可以用这个没有声明的函数了 NTSTATUS WINAPI ZwQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS, IN PVOID, IN ULONG, OUT PULONG);

SIFC ZwQuerySystemInformation = (SIFC)GetProcAddress(hModule, "ZwQuerySystemInformation");

SYSTEM_INFORMATION_CLASS SystemInformationClass = 1;//要检索的系统信息的类型 所有进程信息

ULONG SystemInformationLength = sizeof(SYSTEM_BASIC_INFORMATION);//一个进程信息的结构大小

LPVOID processinfo = VirtualAlloc(NULL, SystemInformationLength, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);//分配默认大小的内存

if (processinfo == NULL){

printf("分配虚拟内存失败: %d\n", GetLastError());

} else{

printf("分配虚拟内存成功\n");

}

ZwQuerySystemInformation(SystemInformationClass, &processinfo, SystemInformationLength, NULL);

PSYSTEM_BASIC_INFORMATION proinfo;

proinfo = (PSYSTEM_BASIC_INFORMATION)processinfo;

printf("处理器个数 = %d\n", proinfo->NumberOfProcessors);

VirtualFree(processinfo, SystemInformationLength, MEM_DECOMMIT);//释放内存

//MessageBoxA(NULL, "hello world", "默认的弹窗", MB_OK);

getchar();

return 0;

}

相关文章

  • 使用未导出函数ZwQuerySystemInformation获

    #include #include #include typedef struct _UNICODE_STRING...

  • 补丁与插件

    DLL怎么导出函数?1.1 使用关键字_decslpec(dllexport)1.2 使用def文件导出 在函数前...

  • 2018-04-25

    总结 签名导出:使用extern "C"导出函数对函数名有约束,也可以使用struct包装所有函数签名 版本控制:...

  • 5.ES6模块导出导入

    导出变量和函数calc.js 导入变量和函数,并加以使用 另一种导入方法 默认导出(多个函数或变量只能导出一个默认...

  • JavaScript语言编程规范(ES6)

    代码风格 导出的默认函数使用驼峰命名、文件名与函数完全一致。 导出单例、函数库、空对象时使用帕斯卡式命名(帕斯卡式...

  • mysql查询结果导出excel

    1.使用into outfile函数导出 2.出现导出中文乱码,需要用到convert函数,转码 3.保存的目录必...

  • export 导出与import 导入

    导出变量用法1 导出变量用法2 导出函数用法1 导出函数用法2 导出类

  • Vue export(导出)、import(导入)

    一、第一种方式导入/导出 js文件导出 Vue实例导入js Vue实例使用js(使用flag和sum函数) 二、第...

  • golang如何修改struct的未导出的域

    golang如何修改struct的未导出的域 这里例子说明如何使用reflect包来访问修改未导出的域。假设定义了...

  • JavaScript es6 模块语法

    导出的变量、函数可以被外界访问到,没有导出的变量或函数不能被外界访问,只能在模块内使用。从而保证了模块内的变量不会...

网友评论

      本文标题:使用未导出函数ZwQuerySystemInformation获

      本文链接:https://www.haomeiwen.com/subject/rcgqsxtx.html