EXE文件和DLL文件同样是PE文件结构,那如何区别它们呢? ( 积分: 50 )

  • 主题发起人 主题发起人 l0v3_y1n9
  • 开始时间 开始时间
L

l0v3_y1n9

Unregistered / Unconfirmed
GUEST, unregistred user!
如题...<br>PS:不要和我说用单纯的判断文件扩展名方法...^_^
 
Function&nbsp;IsDll(FileName&nbsp;:&nbsp;String):Boolean;<br>var<br>&nbsp;&nbsp;hFile&nbsp;:&nbsp;THandle;<br>&nbsp;&nbsp;Mem&nbsp;:&nbsp;TMemoryStream;<br>&nbsp;&nbsp;DosHeader&nbsp;:&nbsp;PImageDosHeader;<br>&nbsp;&nbsp;NtHeader&nbsp;:&nbsp;PImageNtHeaders;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;Mem&nbsp;:=&nbsp;TMemoryStream.Create;<br>&nbsp;&nbsp;Mem.LoadFromFile(FileName);<br>&nbsp;&nbsp;DosHeader&nbsp;:=&nbsp;PImageDosHeader(Mem.Memory);<br>&nbsp;&nbsp;NtHeader&nbsp;:=&nbsp;PImageNtHeaders(PChar(DosHeader)&nbsp;+&nbsp;DosHeader^._lfanew);<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;((NtHeader^.FileHeader.Characteristics&nbsp;and&nbsp;IMAGE_FILE_DLL)=&nbsp;IMAGE_FILE_DLL);<br><br>&nbsp;&nbsp;Mem.Free;<br>end;
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
770
import
I
I
回复
0
查看
601
import
I
后退
顶部