加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi – 如何定义,DEP在系统中是ON

发布时间:2020-12-15 09:43:57 所属栏目:大数据 来源:网络整理
导读:DelphiXe; XP,VISTA,Win7的,WSrv2008R2; 支持0.DEP(数据执行保护)CPU Function isCpuDEP:bool; beginResult:=... //???end; 1.如何定义,DEP在系统中是ON? Function isEnableDEP:bool; // Win Xp comparablebeginResult:=false;if isCpuDEP=false then exit;
DelphiXe; XP,VISTA,Win7的,WSrv2008R2;

支持0.DEP(数据执行保护)CPU

Function isCpuDEP:bool; 
begin
Result:=... //???
end;

1.如何定义,DEP在系统中是ON?

Function isEnableDEP:bool; // Win Xp comparable
begin
Result:=false;if isCpuDEP=false then exit;
Result:=... //???
end;

2.定义,如果DEP已启用,并且还启用了所有程序和服务?

Function isEnableDEPForAllProgram:bool;
begin
Result:=false;if isEnableDEP=false then exit;
Result:=... //???
end;

3.获取DEP程序列表?

Function GetDEPProgramList:TStringList;
begin
Result:=nil;if isEnableDEPForAllProgram=false then exit;
Result:=Tstringlist.Create;
Result:=... //???
end;

解决方法

以下使用 GetProcessDEPPolicy作为点(1):

type
  TGetProcessDEPPolicy =
      function(Process: THandle; out Flags: DWORD; out Permanent: Bool): Bool; stdcall;
const
  PROCESS_DEP_ENABLE = $00000001;
  PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION = $00000002;

procedure TForm1.Button1Click(Sender: TObject);
var
  GetProcessDEPPolicy: TGetProcessDEPPolicy;
  DEPFlags: DWORD;
  IsPermanent: Bool;
begin
  @GetProcessDEPPolicy :=
      GetProcAddress(GetModuleHandle(kernel32),'GetProcessDEPPolicy');
  if Assigned(GetProcessDEPPolicy) then begin
    if GetProcessDEPPolicy(GetCurrentProcess,DEPFlags,IsPermanent) then begin

      if (DEPFlags and PROCESS_DEP_ENABLE) = PROCESS_DEP_ENABLE then
        ShowMessage('DEP enabled')
      else
        ShowMessage('DEP disabled');

    end else
      raise EOSError.Create(SysErrorMessage(GetLastError));
  end else
    raise EOSError.Create('Unsupported OS');
end;

对于第(2)点,您可以以类似的方式使用GetSystemDEPPolicy.

对于第(3)点,您可以枚举进程并找出使用DEP运行的进程.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读