2Pascal-新时代的Pascal

 找回密码
 立即注册
搜索
热搜: fastreport
查看: 1067|回复: 2
打印 上一主题 下一主题

ZwQuerySystemInformation 安全使用心得 Delphi 版

[复制链接]

90

主题

293

帖子

8万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
81901
跳转到指定楼层
楼主
发表于 2018-1-16 01:54:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
京东购书支持本站
请不要用复制代码按钮。

作为 DELPHI 版本,需要引用 jwaNative, JwaWinType ,他们是 JEDI API 的一部分。JEDI 官网有下载。

先给出 2 个辅助函数 和 一些结构体。

[mw_shl_code=delphi,true]type        
  PRecord = ^TRecord;  
  TRecord = record
  end;  
        
  PSystemInformationList = ^TSystemInformationList;  
  TSystemInformationList = record
    Count: ULONG;  
    List: array [0 .. 0] of TRecord;  
  end;  
        
  PSYSTEM_HANDLE_Informations = ^TSYSTEM_HANDLE_Informations;  
  _SYSTEM_HANDLE_Informations = record
    Count: ULONG;  
    SH: array [0 .. 0] of _SYSTEM_HANDLE_INFORMATION;  
  end;  
        
  TSYSTEM_HANDLE_Informations = _SYSTEM_HANDLE_Informations;  
  SYSTEM_HANDLE_Informations = _SYSTEM_HANDLE_Informations;  
        
  PNM_INFO = ^TNM_INFO;  
        
  _NM_INFO = record
    hFile: THandle;  
    Info: _FILE_NAME_Information;  
    Name: array [0 .. MAX_PATH - 1] of WideChar;  
  end;  
        
  TNM_INFO = _NM_INFO;  
  NM_INFO = _NM_INFO;  
        
Function GetSystemInformationClassSize(Const ATableType: SYSTEM_INFORMATION_CLASS; Const Count: ULONG): ULONG;  
begin
  Result := 0;  
  case ATableType of
    SystemBasicInformation:  
      Result := $002C;  
    SystemProcessorInformation:  
      Result := $0000C;  
    SystemPerformanceInformation:  
      Result := $0138;  
    // SystemTimeInformation: Result := $0020;  
    // SystemPathInformation: Result := $0;  
    // SystemProcessInformation: Result := $00C8 + Count;  
    // SystemCallInformation: Result := $0018 + (Count * $0004);  
    SystemConfigurationInformation:  
      Result := $0018;  
    // SystemProcessorCounters: Result := $0030 + Count;//per cpu  
    SystemGlobalFlag:  
      Result := $0004; // (fails if size != 4)  
    // SystemCallTimeInformation: Result := $0;  
    SystemModuleInformation:  
      Result := $0004 + (Count * Sizeof(SYSTEM_MODULE_INFORMATION)); //(n * 0x011C)  
    SystemLockInformation:  
      Result := $0004 + (Count * Sizeof(SYSTEM_LOCK_INFORMATION)); //(n * 0x0024)  
    // SystemStackTraceInformation: Result := $0;  
    // SystemPagedPoolInformation: Result := $0;  
    // SystemNonPagedPoolInformation: Result := $0;  
    SystemHandleInformation:  
      Result := $0004 + (Count * Sizeof(SYSTEM_HANDLE_INFORMATION)); //(n * 0x0010)  
    // SystemObjectTypeInformation: Result := $0038+ + (Count * $0030);// +)  
    SystemPageFileInformation:  
      Result := $0018 + (Count * Sizeof(SYSTEM_PAGEFILE_INFORMATION));  
    // SystemVdmInstemulInformation: Result := $0088;  
    // SystemVdmBopInformation: Result := $0;  
    SystemCacheInformation:  
      Result := $0024;  
    SystemPoolTagInformation:  
      Result := $0004 + (Count * Sizeof(SYSTEM_POOL_TAG_INFORMATION)); // (n * 0x001C)  
    // SystemInterruptInformation: Result := $0000 + Count;//, or 0x0018 per cpu  
    SystemDpcInformation:  
      Result := $0014;  
    // SystemFullMemoryInformation: Result := $0;  
    // SystemLoadDriver: Result := $0018;//, set mode only  
    // SystemUnloadDriver: Result := $0004;//, set mode only  
    // SystemTimeAdjustmentInformation: Result := $000C;//, 0x0008 writeable  
    // SystemSummaryMemoryInformation: Result := $0;  
    // SystemNextEventIdInformation: Result := $0;  
    // SystemEventIdsInformation: Result := $0;  
    SystemCrashDumpInformation:  
      Result := $0004;  
    SystemExceptionInformation:  
      Result := $0010;  
    SystemCrashDumpStateInformation:  
      Result := $0004;  
    // SystemDebuggerInformation: Result := $0002;  
    SystemContextSwitchInformation:  
      Result := $0030;  
    SystemRegistryQuotaInformation:  
      Result := $000C;  
    // SystemAddDriver: Result := $0008;//, set mode only  
    // SystemPrioritySeparationInformatio: Result := $0004;//, set mode only  
    // SystemPlugPlayBusInformation: Result := $0;  
    // SystemDockInformation: Result := $0;  
    // SystemPowerInfo: Result := $0060;// (XP only!)  
    // SystemProcessorSpeedInformation: Result := $000C;// (XP only!)  
    SystemTimeZoneInformation:  
      Result := $00AC;  
    SystemLookasideInformation:  
      Result := Count * $0020;  
    SystemSetTimeSlipEvent:  
      Result := $0;  
    SystemCreateSession:  
      Result := $0;  
    SystemDeleteSession:  
      Result := $0;  
    SystemInvalidInfoClass1:  
      Result := $0;  
    SystemRangeStartInformation:  
      Result := $0004; // (fails if size != 4)  
    SystemVerifierInformation:  
      Result := $0;  
    SystemAddVerifier:  
      Result := $0;  
    SystemSessionProcessesInformation:  
      Result := $0;  
  end;  
end;  
        
Function GetSystemInformationClassHasCount(Const ATableType: SYSTEM_INFORMATION_CLASS): BOOL;  
begin
  Result := False;  
  case ATableType of
    // SystemProcessInformation,  
    // SystemCallInformation,  
    // SystemProcessorCounters,  
    SystemModuleInformation,  
    SystemLockInformation,  
    SystemHandleInformation,  
    // SystemObjectTypeInformation,  
    //SystemPageFileInformation, //好像这个还不确定。  
    // SystemInterruptInformation,  
    SystemPoolTagInformation:  
      Result := True;  
  end;  
  //可以 和 GetSystemInformationClassSize 配合使用。  
end;[/mw_shl_code]

上面的 NM_INFO 和本文无关。

大家 可以 方便的使用 GetSystemInformationTable 来 获取所需的系统信息数据。

游客,如果您要查看本帖隐藏内容请回复




特别声明
禁止 win2003 (楚凡) QQ635887 使用本人修改的内容

禁止 qiuyan81 (苦恋树) QQ46494153 使用本人修改的内容。

禁止 gfuchao  QQ82715485 使用本人修改的内容。

禁止 supersk QQ未知,使用本人修改的内容。

禁止 yesin119 QQ未知,使用本人修改的内容。

禁止 263378440 使用本人修改的内容。

禁止 yanse 使用本人修改的内容。

禁止 ltshdp、ltsh、(禁卫军) 使用本人修改的内容

禁止 www123 使用本人修改的内容

禁止 eliyh 使用本人修改的内容

禁止 zwjchinazwj (蒲石) 使用本人修改的内容

禁止 zhipu QQ:2001972  使用本人修改的内容

禁止 jackalan (nVicen) QQ:875271757  使用本人修改的内容

禁止 kencc2016 (小宇) QQ:2601759381 使用本人修改的内容

以上用户名均为 2CCC 的

禁止 QQ:191909837 使用本人修改的内容
禁止 QQ 81604691 使用本人修改的版内容
禁止 QQ:122742470(菜根) 使用本人修改或建立的代码或工具。

当然,如果你们脸皮比较厚,就偷偷的用吧。

凡是想要骂我的,都可以偷偷的用,反正我是控制不了。
只要你们不鄙视自己就行。
(C)(P)Flying Wang
回复

使用道具 举报

0

主题

7

帖子

28

积分

新手上路

Rank: 1

积分
28
沙发
发表于 2018-10-7 07:57:14 | 只看该作者
京东数码购物支持本站
亲亲,给看一下吧
回复 支持 反对

使用道具 举报

0

主题

2

帖子

10

积分

新手上路

Rank: 1

积分
10
板凳
发表于 2018-10-27 08:37:05 | 只看该作者
京东购书支持本站
有个性的猫
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|新时代Pascal论坛

GMT+8, 2024-4-30 12:39 , Processed in 0.061915 second(s), 23 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表