请下载7K的源代码,帮我看看是什么地方出问题,谢谢,有分,和winapi有关系(50分)

  • 主题发起人 主题发起人 zjlcc
  • 开始时间 开始时间
Z

zjlcc

Unregistered / Unconfirmed
GUEST, unregistred user!
http://redskyhome.myetang.com/version.dpr
 
你似乎想对函数进行拦截
 
差不多,我用version.dll作为实验对象,主要是因为它内部的输出函数较少,程序好做<br><br><br>我想试验dll替换技术,虽然在高版本操作系统下,可能不能用(要身份准许了)<br>用处应该很大的,其实我们都在自觉不自觉的的情况下被类似伪sock dll的技术所服务<br><br>分少了可以提!!欢迎大家讨论。。。。。。
 
我怎么看不到<br>http://redskyhome.myetang.com<br>找不到
 
一个朋友废弃的主页空间,我占用他的空间<br>
 
我以前上传的太匆忙,在dpr里面,所有的myFreeDll;都应该为//myFreeDll;<br><br>本问题我自己已经解决,不会出错了,是引用的问题<br>现在问题变为: )<br>为什么我不能像下面那样做<br>function GetFileVersionInfoA(lptstrFilename:PAnsiChar;dwHandle,dwLen:DWORD;lpData:Pointer):BOOL;export;<br>begin<br>&nbsp; myLoadDll;//没这行不会出错<br>&nbsp; @myGetFileVersionInfoA:=GetProcAddress(hDll,'GetFileVersionInfoA');<br>&nbsp; RESULT:=myGetFileVersionInfoA(lptstrFilename,dwHandle,dwLen,lpData);<br>&nbsp; myFreeDll;//没这行不会出错<br>end;<br>
 
//下面是模拟程序<br>program Ptestdll;//调用testdll_load.dll<br>uses<br>&nbsp; Forms,testdllUnit1 in 'testdllUnit1.pas' {Form1};<br>{$R *.RES}<br>begin<br>&nbsp; Application.CreateForm(TForm1, Form1);<br>&nbsp; Application.Run;<br>end.<br>//===========================================<br>unit testdllUnit1;<br>interface<br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Controls, StdCtrls,forms;<br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; public<br>&nbsp; end;<br><br>&nbsp; Tzj=procedure;stdcall;<br><br>var<br>&nbsp; Form1: TForm1;<br>&nbsp; hDll:HMODULE;<br>&nbsp; myzj:Tzj;<br>implementation<br>{$R *.DFM}<br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; hDll:=loadlibrary('testdll_load.dll');<br>&nbsp; @myzj:=GetProcAddress(hDll,'zj');<br>&nbsp; myzj;<br>&nbsp; FreeLibrary(hDll);<br>end;<br><br>end.<br><br>//===========================================<br>//我不能在DLL里面接收消息<br>library testdll_load;//替换testdll<br>uses<br>&nbsp; windows,messages;<br>type<br>&nbsp; Tzj=procedure;stdcall;<br>var<br>&nbsp; hDll:HMODULE;<br>&nbsp; myzj:Tzj;<br>&nbsp; a:integer;<br>&nbsp; ht:integer;<br>&nbsp; one:boolean;<br>&nbsp; hW:integer;<br>&nbsp; Msg:TMsg;<br>&nbsp; wClass:TWndClass;<br>&nbsp; ThreadId2:DWORD;<br><br>procedure TimeProc;<br>begin<br>&nbsp; messagebeep(0);//这里根本就不进入!!<br>end;<br><br>//只能收到36,129,131,1消息,以后就再也收不到了<br>function WindowProc(hWnd,Msg,wParam,lParam:longint):LRESULT; stdcall;<br>begin<br>&nbsp; Result:=DefWindowProc(hWnd,Msg,wParam,lParam);<br>&nbsp; case Msg of<br>&nbsp; &nbsp; 1:begin<br>&nbsp; &nbsp; &nbsp; &nbsp; ht:=SetTimer(hW,0,500,@TimeProc);<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; wm_destroy:<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; halt;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; end;<br>end;<br><br>procedure run;stdcall;<br>begin<br>&nbsp; wClass.lpfnWndProc:=@WindowProc;<br>&nbsp; wClass.hInstance:=hInstance;<br>&nbsp; wClass.lpszClassName:=' ';<br>&nbsp; RegisterClass(wClass);<br>&nbsp; hw:=CreateWindowEx(0,' ',' ',0,0,0,0,0,0,0,hInstance,nil);<br>&nbsp; while(GetMessage(Msg,hW,0,0))do begin<br>&nbsp; &nbsp; TranslateMessage(Msg);<br>&nbsp; &nbsp; DispatchMessage(Msg);<br>&nbsp; end;<br>end;<br><br>procedure doMyHideProc;<br>begin<br>&nbsp; if ht=0 then begin<br>&nbsp; &nbsp; &nbsp;run;<br>&nbsp; end;<br>end;<br><br>procedure zj;stdcall;<br>begin<br>&nbsp; CreateThread(nil,0,@doMyHideProc,nil,0,ThreadId2);<br>&nbsp; hDll:=loadlibrary('testdll.dll');<br>&nbsp; @myzj:=GetProcAddress(hDll,'zj');<br>&nbsp; myzj;<br>&nbsp; FreeLibrary(hDll);<br>end;<br><br>exports<br>&nbsp; zj index 0;<br><br>begin<br>&nbsp; ht:=0;<br>end.<br>//===========================================<br>library testdll;//原始dll,被testdll_load替换<br>uses windows;<br><br>procedure zj;stdcall;<br>begin<br>&nbsp; messagebox(0,'我在这里','zj',0);<br>end;<br><br>exports<br>&nbsp; zj index 0;<br><br>end.<br>
 
多人接受答案了。
 
后退
顶部