首页
社区
课程
招聘
[求助] R3 下不能用“NtUnmapViewOfSection”吗?
发表于: 2009-11-11 00:16 4090

[求助] R3 下不能用“NtUnmapViewOfSection”吗?

2009-11-11 00:16
4090
请问大家一下:

R3 下不能用“NtUnmapViewOfSection”吗?

function MyUnLoadModules(dwProcessId : DWORD; BaseAddress : PVOID) : DWORD;
var
  ProcessHandle : THANDLE;
  status : NTSTATUS;
begin
  Result:=0;
  ProcessHandle:=MyOpenProcess(PROCESS_ALL_ACCESS, dwProcessId);

  if ProcessHandle > 0 then
  begin
  status :=NtUnmapViewOfSection(ProcessHandle, BaseAddress);
    if STATUS_SUCCESS = status then Result:=1;
  ZwClose(ProcessHandle);
  end;
end;

  试了一下,在 Delphi 7 中运行时,能返回 1 , 但实际上“卸载进程模块”也是不成功的。

单独运行(不在 Delphi 7  环境中),返回 0 , 但 程序在启动时, 我就设了“SeDebugPrivilege:

function GetSystemPrivilege(TokenName: PChar) : Boolean;
var
  hToken : THandle;
  ReturnLength: DWORD;
  tkp, PrevTokenPriv: TTokenPrivileges;
  luid: TLargeInteger;
begin
  Result := False;
  if OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then
  begin
    try
      if not LookupPrivilegeValue(nil, TokenName, luid) then Exit;
      tkp.PrivilegeCount := 1;
      tkp.Privileges[0].luid := luid;
      tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
      if not AdjustTokenPrivileges(hToken, False, tkp, SizeOf(TTOKENPRIVILEGES), PrevTokenPriv, ReturnLength) then Exit;
      Result:=GetLastError = ERROR_SUCCESS;
    finally
      CloseHandle(hToken);
    end;
  end;
end;

[课程]Android-CTF解题方法汇总!

收藏
免费 0
支持
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回
//