charme - 2009-6-24 20:37:00
只是简单的代码:
#include<windows.h>
#include<stdio.h>
void main()
{
HANDLE hFile= CreateFile(
"d:\\ho.exe",
GENERIC_READ, // access mode
FILE_SHARE_READ, // share mode
NULL, // SD
OPEN_EXISTING, // how to create
FILE_ATTRIBUTE_NORMAL, // file attributes
0 // handle to template file
);
HANDLE hObject=CreateFileMapping(
hFile, // handle to file
NULL, // security
PAGE_READONLY, // protection
0, // high-order DWORD of size
0, // low-order DWORD of size
NULL // object name
);
LPVOID buff=MapViewOfFile(
hObject, // handle to file-mapping object
FILE_MAP_READ, // access mode
0, // high-order DWORD of offset
0, // low-order DWORD of offset
GetFileSize(
hFile, // handle to file
NULL // high-order word of file size
) // number of bytes to map
);
printf("%s\n",(unsigned long)buff);
}
此时运行的结果是:MZ。。这是正确的,,当把ho.exe放在桌面上,,改代码为
HANDLE hFile= CreateFile(
"C:\\Documents and Settings\\voldemort\\桌面[url=file://\\ho.exe]\\ho.exe[/url]",
GENERIC_READ, // access mode
FILE_SHARE_READ, // share mode
NULL, // SD
OPEN_EXISTING, // how to create
FILE_ATTRIBUTE_NORMAL, // file attributes
0 // handle to template file
);
此时的结果是:<null>。。。。
不知道这是为什么?
用户系统信息:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 551; .NET CLR 2.0.50727)
windowsSDK - 2009-6-30 17:43:00
C:\\Documents and Settings\\voldemort\\桌面[url=file://\\ho.exe]\\ho.exe[/url]",
-------------
……桌面[url=file://\\ho.exe……
这段错了\\ho.exe已经不是目录了~
© 2000 - 2025 Rising Corp. Ltd.