一个关于READFILE的问题,(10分)

  • 主题发起人 主题发起人 wp231957
  • 开始时间 开始时间
W

wp231957

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure fileisexe(filename:string);stdcall;<br>var<br> &nbsp;readbuffer:pchar;<br> &nbsp;numberofbytesrw:dword;<br> &nbsp;HFILE:thandle;<br>label openfileerr;<br>label fileisnotexe;<br>label filenotpe;<br>label filemaybedll;<br>label exita;<br>begin<br> &nbsp;hfile:=createfile(pchar(filename),GENERIC_READ AND GENERIC_WRITE,FILE_SHARE_READ,nil,3,FILE_ATTRIBUTE_NORMAL,0);<br> &nbsp;if hfile=invalid_handle_value then goto openfileerr;<br> &nbsp;setfilepointer(hfile,0,nil,file_begin);<br> &nbsp;getmem(readbuffer,2);<br> &nbsp;readfile(hfile,readbuffer^,2,numberofbytesrw,nil);<br> &nbsp;showmessage(readbuffer); &nbsp;//请问,我这里为什么SHOW的是乱码呢,想像中应该是MZ才对啊,取PE文件的头2个字节<br> &nbsp;freemem(readbuffer);<br> &nbsp;goto exita;<br>openfileerr:<br> &nbsp;showmessage(filename+' open error!');<br> &nbsp;goto exita;<br>fileisnotexe:<br> &nbsp;showmessage(filename+' is not a exe file');<br> &nbsp;goto exita;<br>filenotpe:<br> &nbsp;showmessage(filename+' is not a pe file');<br> &nbsp;goto exita;<br>filemaybedll:<br> &nbsp;showmessage(filename+' may be a dll file');<br> &nbsp;goto exita;<br>exita:<br>end;
 
后退
顶部