直接从内存装载DLL并调用的API函数库(0分)

  • 主题发起人 主题发起人 风铃夜思雨
  • 开始时间 开始时间

风铃夜思雨

Unregistered / Unconfirmed
GUEST, unregistred user!
内存装载DLL并调用 函数库<br>版本:1.0.0.1<br>作者:风铃夜思雨<br>网站:Http://Www.SkyGz.Com<br>日期:2008-06-05<br><br>说明:该函数库只提供D5、D6、D7版本,不提供源码。<br><br>函数原型<br>Function _LoadLibraryA(FileName: PAnsiChar): hModule; stdcall;<br>Function _LoadLibraryW(FileName: PWideChar): hModule; stdcall;<br>Function _LoadLibraryFromResourceA(Instance: THandle; Name, ResType: PAnsiChar): hModule; stdcall;<br>Function _LoadLibraryFromResourceW(Instance: THandle; Name, ResType: PWideChar): hModule; stdcall;<br>Function _LoadLibraryFromResourceIDA(Instance: THandle; ResID: Integer; ResType: PAnsiChar): hModule; stdcall;<br>Function _LoadLibraryFromResourceIDW(Instance: THandle; ResID: Integer; ResType: PWideChar): hModule; stdcall;<br>Function _LoadLibraryMem(lpMemory: Pointer): hModule; stdcall;<br>Function _GetProcAddress(hModule: hModule; lpProcName: LPCSTR): Pointer; stdcall;<br>Procedure _FreeLibrary(hModule: hModule); stdcall;<br><br><br><br>示例代码<br><br>Uses<br>&nbsp; MemLibLoader;<br><br>Var<br>&nbsp; DllHandle: THandle;<br>&nbsp; MsgBox: Function(lpText, LpCaption: PAnsiChar): Integer; Stdcall;<br>&nbsp; MsgBoxEx: Function(lpText, LpCaption: PAnsiChar; UType: UINT): Integer; Stdcall;<br><br>Procedure TFrmMain.FormCreate(Sender: TObject);<br>Begin<br>&nbsp; Mem := TMemoryStream.Create;<br>&nbsp; Mem.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'MyDll.Dll');<br>&nbsp; DllHandle := _LoadLibraryMem(Mem.Memory);<br>&nbsp; If DllHandle &lt;&gt; 0 Then<br>&nbsp; Begin<br>&nbsp; &nbsp; @MsgBox := _GetProcAddress(DllHandle, 'MsgBox');<br>&nbsp; &nbsp; @MsgBoxEx := _GetProcAddress(DllHandle, MakeIntResource($1));<br>&nbsp; End;<br>End;<br><br>Procedure TFrmMain.FormClose(Sender: TObject; Var Action: TCloseAction);<br>Begin<br>&nbsp; _FreeLibrary(DllHandle);<br>&nbsp; Mem.Free;<br>End;<br><br>Procedure TFrmMain.Button1Click(Sender: TObject);<br>Begin<br>&nbsp; If @MsgBox &lt;&gt; Nil Then<br>&nbsp; &nbsp; MsgBox('这是按名称调用的函数', '提示');<br>End;<br><br>Procedure TFrmMain.Button2Click(Sender: TObject);<br>Begin<br>&nbsp; If @MsgBoxEx &lt;&gt; Nil Then<br>&nbsp; &nbsp; MsgBoxEx('这是按序号调用的函数', '提示', MB_ICONINFORMATION Or MB_OKCANCEL);<br>End;<br><br><br>网盘的下载地址:http://u.skygz.com/?skygz 产品目录下
 
顶一个。<br>仿LoadLibrary还是要做不少手工的,比如重定位,修正基地址等
 
这个东西以前见过<br><br>不知道你的load 全局钩子功能的dll是否还有效果
 
后退
顶部