吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 828|回复: 2
收起左侧

[求助] 两种方法都不行呢?加的位置有问题么?

[复制链接]
冥界3大法王 发表于 2023-8-1 10:20
原文在这:https://blog.csdn.net/farrellcn/article/details/51496595




原代码方案2:
在下面:

Library MoreTool;
{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
{$WEAKLINKRTTI ON}


{ Based on source code CleanupEx by quygia128 }
uses
  Windows,
  Messages,
  bridgemain in 'plugin\bridgemain.pas',
  _plugins in 'plugin\_plugins.pas',
  Unit1 in 'Unit1.pas' {Form1};


{$ALIGN 1}
{$WARN UNSAFE_CODE OFF}
{$WARN UNSAFE_TYPE OFF}
{$WARN UNSAFE_CAST OFF}
{$IFDEF WIN64}
{$E dp64}
{$ELSE}
{$E dp32}
{$ENDIF}


var
  SaveDLLProc: TDLLProc;
  g_pluginHandle: THandle = 0;
  g_hMenu: Cardinal = 0;
  g_hMenuDisasm: Cardinal = 0;
  g_Inst: Cardinal = 0;
  g_hWnD: Cardinal = 0;


  g_loadedname: array [0 .. 8] of PAnsiChar;
function ShellExecuteA(hWnd: hWnd; Operation, FileName, Parameters,
  Directory: PAnsiChar; ShowCmd: Integer): HINST; stdcall;
  external 'shell32.dll' name 'ShellExecuteA';


const
  PLUGIN_NAME: PAChar = 'MoreTool';
  PLUGIN_AUTH: PAChar = 'remek002';
  PLUGIN_VERS: Integer = 01;


  MENU_CALC = 1;
  MENU_NOTEPAD = 2;
  MENU_DISASM_CALC = 3;
  MENU_DISASM_NOTEPAD = 4;


{$R MoreTool.res}


//下面是我加的它的,其他为原来的
function load(): Boolean;
begin
  if Form1 = nil then
  begin
    Form1 := TForm1.Create(nil);
    Form1.Visible := not Form1.Visible;
  end;


end;


//下面是我加的它的,其他为原来的
// 所以必须写一个加载卸载处理函数
procedure DllEnterProc(reason: Integer);
begin
  case reason of
       Windows.DLL_PROCESS_ATTACH:
      begin
      end;
       Windows.DLL_PROCESS_DETACH:
      begin
        Form1.Free;
      end;
  end;
end;


procedure RegisterInitProc(cbType: cbType; callbackInfo: Pointer); cdecl;
var
  info: PPLUG_CB_INITDEBUG;


begin
  ZeroMemory(@g_loadedname, SizeOf(g_loadedname));
  info := PPLUG_CB_INITDEBUG(callbackInfo);
  g_loadedname[0] := info^.szFileName;
  BridgeSettingSet('Last File', 'Last', g_loadedname[0]);
end;


procedure RegisterMenuProc(cbType: cbType; callbackInfo: Pointer); cdecl;
var
  info: PPLUG_CB_MENUENTRY;
begin
  info := PPLUG_CB_MENUENTRY(callbackInfo);
  case (info^.hEntry) of
    MENU_CALC:
      begin
        ShellExecuteA(GuiGetWindowHandle, 'OPEN', 'calc.exe', '',
          'C:\Windows\system32', SW_SHOWNORMAL);
        load;
        Form1.Show;
      end;
    MENU_NOTEPAD:
      begin
        ShellExecuteA(GuiGetWindowHandle, 'OPEN', 'notepad.exe', '',
          'C:\Windows\system32', SW_SHOWNORMAL);
       load;
       Form1.Show;
      end;
    MENU_DISASM_CALC:
      begin
        ShellExecuteA(GuiGetWindowHandle, 'OPEN', 'calc.exe', '',
          'C:\Windows\system32', SW_SHOWNORMAL);
       load;
        Form1.Show;
      end;
    MENU_DISASM_NOTEPAD:
      begin
        ShellExecuteA(GuiGetWindowHandle, 'OPEN', 'notepad.exe', '',
          'C:\Windows\system32', SW_SHOWNORMAL);
       load;
        Form1.Show;
      end;
  end;
end;


function calc(argc: Integer; argv: PPAnsiChar): Boolean; cdecl;
begin
  ShellExecuteA(GuiGetWindowHandle, 'OPEN', 'calc.exe', '',
    'C:\Windows\system32', SW_SHOWNORMAL);
  load;
  Form1.Show;
end;


function notepad(argc: Integer; argv: PPAnsiChar): Boolean; cdecl;
begin
  ShellExecuteA(GuiGetWindowHandle, 'OPEN', 'notepad.exe', '',
    'C:\Windows\system32', SW_SHOWNORMAL);
load;
  Form1.Show;
end;


function x_dbg_Plugininit(PlugInitInfo: PPLUG_INITSTRUCT): Boolean; cdecl;
begin
  g_pluginHandle := PlugInitInfo^.pluginHandle; // Address: 0043E7DC
  PlugInitInfo^.sdkVersion := PLUG_SDKVERSION;
  PlugInitInfo^.PluginVersion := PLUGIN_VERS;
  lstrcpyA(PlugInitInfo^.pluginName, PLUGIN_NAME);
  _plugin_registercallback(g_pluginHandle, CB_MENUENTRY, RegisterMenuProc);
  _plugin_registercallback(g_pluginHandle, CB_INITDEBUG, RegisterInitProc);
  Result := True;
end;


procedure x_dbg_Pluginsetup(PlugSetupInfo: PPLUG_SETUPSTRUCT); cdecl;
begin
  g_hMenu := PlugSetupInfo^.hMenu;
  g_hMenuDisasm := PlugSetupInfo^.hMenuDisasm;


  _plugin_menuaddentry(g_hMenuDisasm, MENU_DISASM_CALC, 'Open Calc');
  _plugin_menuaddseparator(g_hMenuDisasm);
  _plugin_menuaddentry(g_hMenuDisasm, MENU_DISASM_NOTEPAD, 'Open Notepad');


  _plugin_menuaddentry(g_hMenu, MENU_CALC, 'Open Calc');
  _plugin_menuaddseparator(g_hMenu);
  _plugin_menuaddentry(g_hMenu, MENU_NOTEPAD, 'Open Notepad');


  if not(_plugin_registercommand(g_pluginHandle, 'Calc', calc, false)) then
    _plugin_logputs('[MapMaster] ErroR Registering The "Calc" command! ');
  if not(_plugin_registercommand(g_pluginHandle, 'Notepad', notepad, false))
  then
    _plugin_logputs('[MapMaster] ErroR Registering The "Notepad" command! ');
  // Add Plugin info
  _plugin_logprintf('[***] %s Plugin v%i by %s '#10, PLUGIN_NAME, PLUGIN_VERS,
    PLUGIN_AUTH);
end;


function x_dbg_plugstop(): Boolean; cdecl;
begin
  //
  _plugin_unregistercallback(g_pluginHandle, CB_MENUENTRY);
  _plugin_unregistercallback(g_pluginHandle, CB_INITDEBUG);
  Result := True;
end;


exports
  x_dbg_Plugininit name 'pluginit',
  x_dbg_Pluginsetup name 'plugsetup',
  x_dbg_plugstop name 'plugstop';


procedure DLLEntryPoint(dwReason: DWORD);
var
  szPluginName: array [0 .. MAX_PATH - 1] of ACHAR;
begin
  if (dwReason = DLL_PROCESS_DETACH) then
  begin
    // Uninitialize code here
    lstrcatA(szPluginName, PLUGIN_NAME);
    lstrcatA(szPluginName, ' Unloaded By DLL_PROCESS_DETACH');
    OutputDebugStringA(szPluginName);
  end;
  // Call saved entry point procedure
  if Assigned(SaveDLLProc) then
    SaveDLLProc(dwReason);
end;


begin
  // Initialize code here
  g_Inst := HInstance;
  SaveDLLProc := @DLLProc;
  DLLProc := @DLLEntryPoint;


end.




下面是方案1的完整代码:
Library MoreTool;
{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
{$WEAKLINKRTTI ON}


{ Based on source code CleanupEx by quygia128 }
uses
  Windows,
  Messages,
  Forms,
  bridgemain in 'plugin\bridgemain.pas',
  _plugins in 'plugin\_plugins.pas',
  Unit1 in 'Unit1.pas' {Form1};


{$ALIGN 1}
{$WARN UNSAFE_CODE OFF}
{$WARN UNSAFE_TYPE OFF}
{$WARN UNSAFE_CAST OFF}
{$IFDEF WIN64}
{$E dp64}
{$ELSE}
{$E dp32}
{$ENDIF}


var
  SaveDLLProc: TDLLProc;
  g_pluginHandle: THandle = 0;
  g_hMenu: Cardinal = 0;
  g_hMenuDisasm: Cardinal = 0;
  g_Inst: Cardinal = 0;
  g_hWnD: Cardinal = 0;


  g_loadedname: array [0 .. 8] of PAnsiChar;
function ShellExecuteA(hWnd: hWnd; Operation, FileName, Parameters,
  Directory: PAnsiChar; ShowCmd: Integer): HINST; stdcall;
  external 'shell32.dll' name 'ShellExecuteA';


const
  PLUGIN_NAME: PAChar = 'MoreTool';
  PLUGIN_AUTH: PAChar = 'remek002';
  PLUGIN_VERS: Integer = 01;


  MENU_CALC = 1;
  MENU_NOTEPAD = 2;
  MENU_DISASM_CALC = 3;
  MENU_DISASM_NOTEPAD = 4;


Procedure ShowForm; stdcall;
begin
  Form1 := TForm1.Create(Application);
  Form1.show;
end;


procedure SynApp(App: THandle); stdcall;
begin
  Application.Handle := App;
end;


{$R MoreTool.res}


procedure RegisterInitProc(cbType: cbType; callbackInfo: Pointer); cdecl;
var
  info: PPLUG_CB_INITDEBUG;
begin
  ZeroMemory(@g_loadedname, SizeOf(g_loadedname));
  info := PPLUG_CB_INITDEBUG(callbackInfo);
  g_loadedname[0] := info^.szFileName;
  BridgeSettingSet('Last File', 'Last', g_loadedname[0]);
end;


procedure RegisterMenuProc(cbType: cbType; callbackInfo: Pointer); cdecl;
var
  info: PPLUG_CB_MENUENTRY;
begin
  info := PPLUG_CB_MENUENTRY(callbackInfo);
  case (info^.hEntry) of
    MENU_CALC:
      begin
        ShellExecuteA(GuiGetWindowHandle, 'OPEN', 'calc.exe', '',
          'C:\Windows\system32', SW_SHOWNORMAL);


        SynApp(Application.Handle);
        ShowForm;
      end;
    MENU_NOTEPAD:
      begin
        ShellExecuteA(GuiGetWindowHandle, 'OPEN', 'notepad.exe', '',
          'C:\Windows\system32', SW_SHOWNORMAL);
        SynApp(Application.Handle);
        ShowForm;
      end;
    MENU_DISASM_CALC:
      begin
        ShellExecuteA(GuiGetWindowHandle, 'OPEN', 'calc.exe', '',
          'C:\Windows\system32', SW_SHOWNORMAL);
        SynApp(Application.Handle);
        ShowForm;
      end;
    MENU_DISASM_NOTEPAD:
      begin
        ShellExecuteA(GuiGetWindowHandle, 'OPEN', 'notepad.exe', '',
          'C:\Windows\system32', SW_SHOWNORMAL);
        SynApp(Application.Handle);
        ShowForm;
      end;
  end;
end;


function calc(argc: Integer; argv: PPAnsiChar): Boolean; cdecl;
begin
  ShellExecuteA(GuiGetWindowHandle, 'OPEN', 'calc.exe', '',
    'C:\Windows\system32', SW_SHOWNORMAL);
  SynApp(Application.Handle);
  ShowForm;
end;


function notepad(argc: Integer; argv: PPAnsiChar): Boolean; cdecl;
begin
  ShellExecuteA(GuiGetWindowHandle, 'OPEN', 'notepad.exe', '',
    'C:\Windows\system32', SW_SHOWNORMAL);
  SynApp(Application.Handle);
  ShowForm;
end;


function x_dbg_Plugininit(PlugInitInfo: PPLUG_INITSTRUCT): Boolean; cdecl;
begin
  g_pluginHandle := PlugInitInfo^.pluginHandle; // Address: 0043E7DC
  PlugInitInfo^.sdkVersion := PLUG_SDKVERSION;
  PlugInitInfo^.PluginVersion := PLUGIN_VERS;
  lstrcpyA(PlugInitInfo^.pluginName, PLUGIN_NAME);
  _plugin_registercallback(g_pluginHandle, CB_MENUENTRY, RegisterMenuProc);
  _plugin_registercallback(g_pluginHandle, CB_INITDEBUG, RegisterInitProc);
  Result := True;
end;


procedure x_dbg_Pluginsetup(PlugSetupInfo: PPLUG_SETUPSTRUCT); cdecl;
begin
  g_hMenu := PlugSetupInfo^.hMenu;
  g_hMenuDisasm := PlugSetupInfo^.hMenuDisasm;


  _plugin_menuaddentry(g_hMenuDisasm, MENU_DISASM_CALC, 'Open Calc');
  _plugin_menuaddseparator(g_hMenuDisasm);
  _plugin_menuaddentry(g_hMenuDisasm, MENU_DISASM_NOTEPAD, 'Open Notepad');


  _plugin_menuaddentry(g_hMenu, MENU_CALC, 'Open Calc');
  _plugin_menuaddseparator(g_hMenu);
  _plugin_menuaddentry(g_hMenu, MENU_NOTEPAD, 'Open Notepad');


  if not(_plugin_registercommand(g_pluginHandle, 'Calc', calc, false)) then
    _plugin_logputs('[MapMaster] ErroR Registering The "Calc" command! ');
  if not(_plugin_registercommand(g_pluginHandle, 'Notepad', notepad, false))
  then
    _plugin_logputs('[MapMaster] ErroR Registering The "Notepad" command! ');
  // Add Plugin info
  _plugin_logprintf('[***] %s Plugin v%i by %s '#10, PLUGIN_NAME, PLUGIN_VERS,
    PLUGIN_AUTH);
end;


function x_dbg_plugstop(): Boolean; cdecl;
begin
  //
  _plugin_unregistercallback(g_pluginHandle, CB_MENUENTRY);
  _plugin_unregistercallback(g_pluginHandle, CB_INITDEBUG);
  Result := True;
end;


exports
  SynApp,  
ShowForm,
  x_dbg_Plugininit name 'pluginit',
  x_dbg_Pluginsetup name 'plugsetup',
  x_dbg_plugstop name 'plugstop';


procedure DLLEntryPoint(dwReason: DWORD);
var
  szPluginName: array [0 .. MAX_PATH - 1] of ACHAR;
begin
  if (dwReason = DLL_PROCESS_DETACH) then
  begin
    // Uninitialize code here
    lstrcatA(szPluginName, PLUGIN_NAME);
    lstrcatA(szPluginName, ' Unloaded By DLL_PROCESS_DETACH');
    OutputDebugStringA(szPluginName);
  end;
  // Call saved entry point procedure
  if Assigned(SaveDLLProc) then
    SaveDLLProc(dwReason);
end;


begin
  // Initialize code here
  g_Inst := HInstance;
  SaveDLLProc := @DLLProc;
  DLLProc := @DLLEntryPoint;


end.
无论 是哪一种,退出程序后,都会
image.png
困扰了半年了。

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| 冥界3大法王 发表于 2023-8-1 10:22
头像被屏蔽
chensz 发表于 2023-8-3 16:37
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-24 19:29

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表