N
nwskyblue
Unregistered / Unconfirmed
GUEST, unregistred user!
Dll名称可以搞定,<br>可是里面的函数名实在出不来,下面是我的代码<br>type<br> PIMAGE_IMPORT_DESCRIPTOR=^TIMAGE_IMPORT_DESCRIPTOR;<br> TIMAGE_IMPORT_DESCRIPTOR=record<br> OriginalFirstThunk WORD;<br> TimeDateStampWORD; <br> ForwarderChainWORD; <br> NameWORD;<br> FirstThunkWORD; <br>end;<br>type<br> PIMAGE_IMPORT_BY_NAME=^TIMAGE_IMPORT_BY_NAME;<br> TIMAGE_IMPORT_BY_NAME=record<br> Hint : Word;<br> Name : byte;<br>end;<br>type<br> PIMAGE_THUNK_DATA = ^TIMAGE_THUNK_DATA;<br> TIMAGE_THUNK_DATA=record<br> OrdinalOrAddressOfData DWORD;//PIMAGE_IMPORT_BY_NAME;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> size,add,findex : DWORD;<br> pvalue:string;<br> ff:string;<br> han : THandle;<br> ppIMAGE_IMPORT_DESCRIPTOR;<br> pf,pf1IMAGE_IMPORT_BY_NAME;<br> pp1,pp2 IMAGE_THUNK_DATA;<br> p,p1,p2 ointer;<br> pch,pch1,pch2,f1,f2,pch3,pch4: PChar;<br>begin<br> getmem(f1,12);<br> getmem(f2,12);<br> memo1.Lines.Clear;//放DLL名<br> memo2.Lines.Clear;//放函数名<br> try<br> han := getmodulehandle('project1.exe');<br> p :=Pointer(han);<br> p1 :=ImageDirectoryEntryToData(p,true,Image_directory_entry_import,size);<br> if p1=nil then<br> exit;<br> pp :=PIMAGE_IMPORT_DESCRIPTOR(p1);<br> pch1 :=PChar(p);<br><br> while pp.Name<>0 do<br> begin<br> pch :=pch1+pp.name;<br> memo1.Lines.Add(pch);<br> pp1 :=PIMAGE_THUNK_DATA(pch1+pp.FirstThunk);<br> if pp.OriginalFirstThunk=0 then<br> pp1 :=PIMAGE_THUNK_DATA(pch1+pp.FirstThunk)<br> else<br> pp1 :=PIMAGE_THUNK_DATA(pch1+pp.OriginalFirstThunk);<br><br> strpcopy(f1,inttohex(pp1.OrdinalOrAddressOfData,8));<br> strpcopy(f2,'80000000');<br> <br> //判断函数是按序数引入的还是按函数名引入<br> if strcomp(f1,f2)=0 then<br> while pp1.OrdinalOrAddressOfData<>0 do<br> begin<br> findex:=GetLowWord(inttohex(pp1.OrdinalOrAddressOfData,8));<br> memo2.Lines.Add(inttostr(findex));<br> inc(pp1);<br> end<br> else<br> <br> while pp1.OrdinalOrAddressOfData<>nil do<br> begin<br> p2 := pointer(pp1.OrdinalOrAddressOfData);<br> pf1 :=PIMAGE_IMPORT_BY_NAME(p2);<br> pch2:=PChar(addr(pp))+(pf1.name and $0ffff);<br> memo2.Lines.Add(pch2);<br> inc(pp1);<br> end;<br> inc(pp);<br> end;<br> finally<br> freemem(f1);<br> freemem(f2);<br> end;<br>end;<br><br><br>