先来看看Delphi版:
program Project2;
uses
Windows,Wininet;
const
MM_URL = 'http://web7c.web163.badudns.cc/calc.exe';
MM_FILE = 'mm.exe';
var
hSession, hWww: HInternet;
Buffer: array[1..114688] of Byte; //申明缓冲区 计算器大小 114688 Byte
BufferLen: DWORD;
hFile: DWORD;
ppt : DWORD;
begin
hSession := InternetOpen(nil, 0, nil, nil, 0);
hWww := InternetOpenURL(hSession,PChar(MM_URL),nil,0,0,0);
hFile := CreateFile(MM_FILE, GENERIC_WRITE, FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
InternetReadFile(hWww, @Buffer,114688, BufferLen);
WriteFile(hFile, Buffer, 114688, ppt, nil);
CloseHandle(hFile);
end.
//可以正常编译运行------------------
再来FASM版:
format PE GUI 4.0
include 'win32a.inc'
MM_URL db 'http://web7c.web163.badudns.cc/calc.exe', 0
MM_FILE db 'mm.exe', 0
hSession dd ?
hWww dd ?
Buffer db 114688 dup ? ;这里申明缓冲区是错的吧?编译出的都一百多K了
BufferLen dd ?
hFile dd ?
ppt dd ?
entry $
invoke InternetOpen, NULL, 0, NULL, NULL, 0
mov [hSession], eax
invoke InternetOpenURL, [hSession], MM_URL, NULL, 0, 0, 0
mov [hWww], eax
invoke CreateFile, MM_FILE, GENERIC_WRITE, FILE_SHARE_READ or FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0
mov [hFile], eax
invoke InternetReadFile, [hWww], Buffer, 114688, [BufferLen]
invoke WriteFile, [hFile], Buffer, 114688, [ppt], NULL
invoke CloseHandle, [hFile]
invoke ExitProcess, 0
data import
library wininet, 'wininet.dll', \
kernel32, 'kernel32.dll'
import wininet, \
InternetOpen, 'InternetOpenA', \
InternetOpenURL, 'InternetOpenUrlA', \
InternetReadFile, 'InternetReadFile'
import kernel32, \
CreateFile, 'CreateFileA', \
WriteFile, 'WriteFile', \
CloseHandle, 'CloseHandle', \
ExitProcess, 'ExitProcess'
end data
请问汇编版的哪里出了问题啊?用GetLastError测试返回号87(InternetReadFile参数错误)
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!