修改Explorer模块中的函数为自己定义的监视函数…… (100分)

  • 主题发起人 主题发起人 paulorwys
  • 开始时间 开始时间
P

paulorwys

Unregistered / Unconfirmed
GUEST, unregistred user!
通过不可中断的Explorer程序中的函数来达到如何都中断不了自己编写的应用程序,<br>监视函数中,如果找不到指定的进程模块就启动之,<br><br>现在是如何改写explorer函数,而且应该替换其中什么函数才好?<br>以前记得用过CreateRemoteThread函数,但是现在具体不知道改写哪个函数了,<br>请指教,<br>e-mail:foolstudio@yahoo.com.cn
 
邮箱:foolstudio@yahoo.com.cn
 
没看懂!<br><br>是想把你的程序注入到exploer里作为子进程吗?搜索一下,多了。
 
呵呵,搞定了,远程函数就行,原来使用了本地的地址空间,就出错啦。<br>新的内容,分不够再加?<br>如何读取EXE文件里头的内容,比如:要导入的一些库文件,以及一些库函数。<br>例如,用notepad.exe打开notepad.exe文件,就可以发现导入了一些.dll文件,<br>以及.dll文件里头的一些函数,<br><br>前提是,以文件形式打开,不用运行。<br><br>mail:foolstudio@yahoo.com<br><br>分不够再加!!<br><br>
 
没这必要吧,自己写个服务行不?
 
有关于exe和dll文件结构的参考吗??给分都不行吗??
 
还是请问.exe和.dll文件的结构哦!!<br><br>加分可以商量哦!!
 
PE的导入表与导出表,自己看吧<br><br>unit UPEEntry;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls, Buttons, Menus;<br><br>type<br>&nbsp; {PE导出表声明}<br>&nbsp; PImageExportDirectory = ^TImageExportDirectory;<br>&nbsp; TImageExportDirectory = packed record<br>&nbsp; &nbsp; Characteristics: DWORD;<br>&nbsp; &nbsp; TimeDateStamp: DWORD;<br>&nbsp; &nbsp; MajorVersion: WORD;<br>&nbsp; &nbsp; MinorVersion: WORD;<br>&nbsp; &nbsp; Name: DWORD;<br>&nbsp; &nbsp; Base: DWORD;<br>&nbsp; &nbsp; NumberOfFunctions: DWORD;<br>&nbsp; &nbsp; NumberOfNames: DWORD;<br>&nbsp; &nbsp; AddressOfFunctions: DWORD;<br>&nbsp; &nbsp; AddressOfNames: DWORD;<br>&nbsp; &nbsp; AddressOfNameOrdinals: DWORD;<br>&nbsp; end;<br><br>&nbsp; PImportByName=^TImportByName;<br>&nbsp; TImportByName =Packed &nbsp;record<br>&nbsp; &nbsp; ProcedureHint: word;<br>&nbsp; &nbsp; ProcedureName: array[0..1]of char;<br>&nbsp; end;<br><br>&nbsp; PImageImportDescriptor = ^TImageImportDescriptor;<br>&nbsp; TImageImportDescriptor = packed record<br>&nbsp; &nbsp; OriginalFirstThunk: DWord;<br>&nbsp; &nbsp; TimeDateStamp &nbsp;: DWord;<br>&nbsp; &nbsp; ForwarderChain : DWord;<br>&nbsp; &nbsp; DLLName &nbsp; &nbsp; &nbsp; &nbsp;: DWord;<br>&nbsp; &nbsp; FirstThunk &nbsp; &nbsp; : DWord;<br>&nbsp; end;<br><br>&nbsp; PImageThunkData=^TImageThunkData;<br>&nbsp; TImageThunkData = record<br>&nbsp; case integer of<br>&nbsp; &nbsp; 1:( ForwarderString : DWord; );<br>&nbsp; &nbsp; 2:( Function_ &nbsp; &nbsp; &nbsp; : DWord; );<br>&nbsp; &nbsp; 3:( Ordinal &nbsp; &nbsp; &nbsp; &nbsp; : DWord; );<br>&nbsp; &nbsp; 4:( AddressOfData &nbsp; : DWord; );<br>&nbsp; end;<br>&nbsp; PImageBaseRelocation=^TImageBaseRelocation;<br>&nbsp; TImageBaseRelocation=Packed Record<br>&nbsp; &nbsp; &nbsp;VirtualAddress: Dword;<br>&nbsp; &nbsp; &nbsp;SizeOfBlock: Dword;<br>&nbsp; &nbsp; &nbsp;TypeOffset: array[0..1] of Word; //不定长<br>&nbsp; end;<br><br>&nbsp; TPESection = record &nbsp; &nbsp;//自定义<br>&nbsp; &nbsp; ObjectName: string;<br>&nbsp; &nbsp; Address: PChar;<br>&nbsp; &nbsp; PhysicalSize: Integer;<br>// &nbsp; &nbsp;VirtualSize: Integer;<br>// &nbsp; &nbsp;Characteristics: Cardinal;<br>&nbsp; &nbsp; PointerToRawData: Integer;<br>&nbsp; end;<br><br>&nbsp; TNameOrID = (niName, niID); &nbsp;<br>&nbsp; TPEImport = record<br>&nbsp; &nbsp; NameOrID: TNameOrID;<br>&nbsp; &nbsp; Name: string;<br>&nbsp; &nbsp; ID: Integer;<br>// &nbsp; &nbsp;PAddress: PChar; {指向导入表函数用于执行此函数}<br>&nbsp; end;<br>&nbsp; TPEImports = record {记录一个Dll文件所调用的函数个数}<br>&nbsp; &nbsp; DLLName: string;<br>&nbsp; &nbsp; Entries: array of TPEImport; {函数数据}<br>&nbsp; end;<br><br>&nbsp; TPEExport = record<br>&nbsp; &nbsp; Name: string;<br>&nbsp; &nbsp; RelativeID: Integer;<br>&nbsp; &nbsp; ID: Integer;<br>&nbsp; &nbsp; Address: DWORD;{相对地址}<br>&nbsp; end;<br><br>&nbsp; TfrmPEEntry = class(TForm)<br>&nbsp; &nbsp; GroupBox1: TGroupBox;<br>&nbsp; &nbsp; ListBox1: TListBox;<br>&nbsp; &nbsp; GroupBox2: TGroupBox;<br>&nbsp; &nbsp; ListBox2: TListBox;<br>&nbsp; &nbsp; GroupBox3: TGroupBox;<br>&nbsp; &nbsp; BitBtn2: TBitBtn;<br>&nbsp; &nbsp; procedure BitBtn2Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; &nbsp; PEImports: array of TPEImports;<br>&nbsp; &nbsp; PEExport: array of TPEExport;<br>&nbsp; &nbsp; Section: array of TPESection;<br>&nbsp; &nbsp; procedure Load(FileName:string);<br>&nbsp; end;<br><br>var<br>&nbsp; frmPEEntry: TfrmPEEntry;<br><br>implementation<br><br>uses UMain;<br><br>{$R *.DFM}<br><br>procedure TfrmPEEntry.Load(FileName:string);<br>type<br>&nbsp; &nbsp;TImageSectionHeaderArray=array[0..1]of TImageSectionHeader;<br>&nbsp; &nbsp;PImageSectionHeaderArray=^TImageSectionHeaderArray;<br>var<br>&nbsp; FileStream: TFileStream;<br>&nbsp; ImageDosHeader:TImageDosHeader;<br>&nbsp; ImageNtHeaders:TImageNtHeaders;<br>&nbsp; ImageBase: PChar;<br>&nbsp; FileBase: PChar;<br>&nbsp; ImageSize: Integer;<br>&nbsp; HeaderSize: Integer;<br>&nbsp; NTHeader: PImageNtHeaders;<br>&nbsp; I,J: integer;<br>&nbsp; ImportEntry: PImageImportDescriptor;<br>&nbsp; LookupEntry: PDWord;<br>&nbsp; ImportByName: PImportByName;<br>&nbsp; SectionTable:PImageSectionHeaderArray;<br><br>&nbsp; ExportEntry: PImageExportDirectory;<br>&nbsp; AddressOfFunctions: PChar;<br>&nbsp; AddressOfNames: PChar;<br>&nbsp; AddressOfNameOrdinals: PChar;<br>&nbsp; Found:boolean;<br>begin<br>&nbsp; ListBox1.Clear;<br>&nbsp; ListBox2.clear;<br>&nbsp; for I := 0 to High(PEImports) do<br>&nbsp; &nbsp; &nbsp;SetLength(PEImports.Entries, 0);<br>&nbsp; SetLength(PEImports,0);<br>&nbsp; FileStream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);<br>&nbsp; with FileStream do<br>&nbsp; begin<br>&nbsp; &nbsp; ReadBuffer(ImageDosHeader,sizeof(TImageDosHeader));<br>&nbsp; &nbsp; {以下检验是否是合法的PE文件}<br>&nbsp; &nbsp; if ImageDosHeader.e_magic&lt;&gt;IMAGE_DOS_SIGNATURE then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;showmessage('未知的文件格式.');<br>&nbsp; &nbsp; &nbsp; &nbsp;FileStream.free;<br>&nbsp; &nbsp; &nbsp; &nbsp;exit;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; if ImageDosHeader._lfanew &gt;= Size then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;showmessage('未知的文件格式.');<br>&nbsp; &nbsp; &nbsp; &nbsp;FileStream.free;<br>&nbsp; &nbsp; &nbsp; &nbsp;exit;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; Position := ImageDosHeader._lfanew;<br>&nbsp; &nbsp; ReadBuffer(ImageNtHeaders,sizeof(TImageNtHeaders));<br>&nbsp; &nbsp; {检验 NT Header.}<br>&nbsp; &nbsp; if ImageNtHeaders.Signature&lt;&gt;IMAGE_NT_SIGNATURE then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;showmessage('此文件不是WIN32 PE可执行文件.');<br>&nbsp; &nbsp; &nbsp; &nbsp;FileStream.free;<br>&nbsp; &nbsp; &nbsp; &nbsp;exit;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; ImageBase:=pointer(ImageNtHeaders.OptionalHeader.ImageBase);<br>&nbsp; &nbsp; ImageSize:=ImageNtHeaders.OptionalHeader.SizeOfImage;<br>&nbsp; &nbsp; HeaderSize:=ImageNtHeaders.OptionalHeader.SizeOfHeaders;<br>&nbsp; &nbsp; {在ImageBaseAdress中分配内存}<br>&nbsp; &nbsp; FileBase := VirtualAlloc(ImageBase, ImageSize, MEM_RESERVE or MEM_COMMIT, PAGE_READWRITE);<br>&nbsp; &nbsp; {返回映射后的基地址}<br>&nbsp; &nbsp; if FileBase = nil then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;{由系统自动分配内存页}<br>&nbsp; &nbsp; &nbsp; &nbsp;FileBase := VirtualAlloc(nil, ImageSize, MEM_RESERVE or MEM_COMMIT, PAGE_READWRITE);<br>&nbsp; &nbsp; &nbsp; &nbsp;if FileBase = nil then<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage('不能分配内存');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FileStream.free;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit;<br>&nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; Position := 0;<br>&nbsp; &nbsp; ReadBuffer(PPointer(FileBase)^, HeaderSize); {读取数据到文件头中}<br>&nbsp; &nbsp; {把文件指针定位到NtHeader}<br>&nbsp; &nbsp; NTHeader := PImageNtHeaders(FileBase + PImageDosHeader(FileBase)^._lfanew);<br>&nbsp; &nbsp; {保存栈}<br>// &nbsp; &nbsp;StackCommitSize := NTHeader^.OptionalHeader.SizeOfStackCommit;<br>&nbsp; &nbsp; {保存保留栈}<br>// &nbsp; &nbsp;StackReserveSize := NTHeader^.OptionalHeader.SizeOfStackReserve;<br>&nbsp; &nbsp; {保存切入点}<br>// &nbsp; &nbsp;EntryPoint := FileBase + NTHeader^.OptionalHeader.AddressOfEntryPoint;<br>&nbsp; &nbsp; {保存代码大小}<br>// &nbsp; &nbsp;CodeSize := NTHeader^.OptionalHeader.SizeOfCode;<br>&nbsp; &nbsp; {保存代码地址}<br>// &nbsp; &nbsp;Code := FileBase + NTHeader^.OptionalHeader.BaseOfCode;<br>&nbsp; &nbsp; {保存数据大小}<br>// &nbsp; &nbsp;DataSize := NTHeader^.OptionalHeader.SizeOfInitializedData;<br>&nbsp; &nbsp; {保存数据地址}<br>// &nbsp; &nbsp;Data := FileBase + NTHeader^.OptionalHeader.BaseOfData;<br>&nbsp; &nbsp; {从文件中读取信息并保存在变量中}<br>&nbsp; &nbsp; SetLength(Section, NTHeader^.FileHeader.NumberOfSections);<br>&nbsp; &nbsp; SectionTable:= PImageSectionHeaderArray(longword(NtHeader)+sizeof(TImageNtHeaders));<br>&nbsp; &nbsp; for I := 0 to High(Section) do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;SetLength(Section.ObjectName, 8);<br>&nbsp; &nbsp; &nbsp; &nbsp;Move(SectionTable^.Name, Section.ObjectName[1], 8);<br>&nbsp; &nbsp; &nbsp; &nbsp;SetLength(Section.ObjectName, StrLen(PChar(Section.ObjectName)));<br>&nbsp; &nbsp; &nbsp; &nbsp;Section.PhysicalSize := SectionTable^.SizeOfRawData;<br>// &nbsp; &nbsp; &nbsp; Section.VirtualSize := SectionTable^.Misc.VirtualSize;<br>&nbsp; &nbsp; &nbsp; &nbsp;Section.Address := FileBase + SectionTable^.VirtualAddress;<br>&nbsp; &nbsp; &nbsp; &nbsp;Section.PointerToRawData := SectionTable^.PointerToRawData;<br>&nbsp; &nbsp; &nbsp; &nbsp;Position := SectionTable^.PointerToRawData;<br>&nbsp; &nbsp; &nbsp; &nbsp;ReadBuffer(PPointer(Section.Address)^, Section.PhysicalSize);<br>// &nbsp; &nbsp; &nbsp; Section.Characteristics := SectionTable^.Characteristics;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; if NTHeader^.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress&lt;&gt;0 then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;ImportEntry := PImageImportDescriptor(FileBase +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NTHeader^.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);<br>&nbsp; &nbsp; &nbsp; &nbsp;{读取导入表入口,直到空为止}<br>&nbsp; &nbsp; &nbsp; &nbsp;while ImportEntry^.DLLName &lt;&gt; 0 do<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {新导入表入口}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetLength(PEImports, Length(PEImports) + 1);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PEImports[High(PEImports)].DLLName := FileBase + ImportEntry^.DLLName;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ImportEntry^.OriginalFirstThunk&lt;&gt;0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LookupEntry := PDWord(FileBase + ImportEntry^.OriginalFirstThunk)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else LookupEntry := PDWord(FileBase + ImportEntry^.FirstThunk);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {继续读取此Dll直到为空}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while LookupEntry^ &lt;&gt; 0 do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{函数入口}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetLength(PEImports[High(PEImports)].Entries, Length(PEImports[High(PEImports)].Entries) + 1);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;with PEImports[High(PEImports)].Entries[High(PEImports[High(PEImports)].Entries)] do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (LookupEntry^ and $80000000) &lt;&gt; 0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NameOrID := niID;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ID := LookupEntry^ and $7FFFFFFF; {为ID,屏蔽最高位}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; frmPEEntry.listbox1.items.add(format('函数编号:%-34d 来自的DLL:%-28s 地址:%.8X',[id,PEImports[High(PEImports)].DllName, LookupEntry^]));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NameOrID := niName;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ImportByName:=PImportByName(FileBase + LookupEntry^);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Name := ImportByName^.ProcedureName; {头两个字节存储ID,其后紧跟为名字}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;frmPEEntry.listbox1.items.add(format('函数名:%-36s 来自的DLL:%-18s Hint:%.4X 地址:%.8X',[ImportByName^.ProcedureName, PEImports[High(PEImports)].DllName, ImportByName^.ProcedureHint, LookupEntry^]));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PAddress := PChar(LookupEntry);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Inc(LookupEntry);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; //end with<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inc(ImportEntry);<br>&nbsp; &nbsp; &nbsp; &nbsp;end; //end while<br>&nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; if NTHeader^.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress &lt;&gt; 0 then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;ExportEntry := PImageExportDirectory(FileBase +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NTHeader^.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);<br>&nbsp; &nbsp; &nbsp; &nbsp;{ExportEntry指向导出表的位置}<br>&nbsp; &nbsp; &nbsp; &nbsp;AddressOfNames := FileBase + ExportEntry^.AddressOfNames;<br>&nbsp; &nbsp; &nbsp; &nbsp;AddressOfNameOrdinals := FileBase + ExportEntry^.AddressOfNameOrdinals;<br>&nbsp; &nbsp; &nbsp; &nbsp;AddressOfFunctions := FileBase + ExportEntry^.AddressOfFunctions;<br><br>&nbsp; &nbsp; &nbsp; &nbsp;{导出的函数的个数}<br>&nbsp; &nbsp; &nbsp; &nbsp;setlength(PEExport,ExportEntry^.NumberOfFunctions);<br>// &nbsp; &nbsp; &nbsp; FillChar(FList^, FCount * SizeOf(TpeExport), 0);<br>&nbsp; &nbsp; &nbsp; &nbsp;for I := 0 to ExportEntry^.NumberOfNames &nbsp;- 1 do {以名字导出的函数的个数}<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {保存导出地址}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PEExport.Name := FileBase + PDWord(AddressOfNames + I * 4)^;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {以ID来查找的导出函数}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PEExport.RelativeID := PWord(AddressOfNameOrdinals + I * 2)^ ;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PEExport.ID := PEExport.RelativeID + integer(ExportEntry^.Base-1);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {函数所处一地址}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PEExport.Address := PDword(AddressOfFunctions + PEExport.RelativeID * 4)^; &nbsp;//相对地址,+FileBase=绝对地址<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; listbox2.items.add(format('函数名:%-36s 编号:%.5d 地址:%.8X',[PEExport.name,PEExport.ID ,Dword(PEExport.address)]));<br>&nbsp; &nbsp; &nbsp; &nbsp;end;<br><br>&nbsp; &nbsp; &nbsp; &nbsp;for I := 0 to ExportEntry^.NumberOfFunctions - 1 do {搜索以编号导出的函数}<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Found:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for J := 0 to ExportEntry^.NumberOfNames - 1 do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if I=PEExport[J].RelativeID then //if I+(Base-1)=PEExport[J].ID then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Found:=true;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not Found then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PEExport.Name := '';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PEExport.RelativeID := I;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PEExport.ID := PEExport.RelativeID + integer(ExportEntry^.Base-1);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PEExport.Address := PDword(AddressOfFunctions + PEExport.ID * 4)^; &nbsp;//相对地址,+FileBase=绝对地址<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;listbox2.items.add(format('函数名:%-36s 编号:%.5d 地址:%.8X',['',PEExport.ID-integer(ExportEntry^.Base-1) ,Dword(PEExport.address)]));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>&nbsp; VirtualFree(FileBase, 0, MEM_RELEASE);<br>&nbsp; FileStream.free;<br>end;<br><br>procedure TfrmPEEntry.BitBtn2Click(Sender: TObject);<br>begin<br>&nbsp; close;<br>end;<br><br>end.
 
后退
顶部