德尔福Xe; XP、Vista、Win7、WAR 2008R2;
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 http://msdn.microsoft.com/en-us/library/bb736297%28v=vs.85%29.aspx对于第 (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 http://msdn.microsoft.com/en-us/library/bb736298%28v=vs.85%29.aspx以类似的方式。
对于第 (3) 点,您可以枚举进程并找出使用 DEP 运行的进程。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)