出于某种原因,我的回调OVERLAPPED
在调用ReadFileEx
. 什么会导致这种情况?
更新——例如:
#include <stdio.h>
#include <Windows.h>
void __stdcall completion_routine(
unsigned long dwErrorCode,
unsigned long dwNumberOfBytesTransfered,
OVERLAPPED *lpOverlapped)
{
printf("Overlapped = %p\n", lpOverlapped);
}
int _tmain(int argc, LPTSTR argv[])
{
HANDLE hvolume = CreateFile(
_T("C:\\Windows\\Notepad.exe"), FILE_READ_DATA,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, OPEN_EXISTING, 0, NULL);
char tempbuf[512];
OVERLAPPED tempoverlapped = { };
printf("%p\n", &tempoverlapped);
if (ReadFileEx(hvolume, tempbuf, sizeof(tempbuf),
&tempoverlapped, &completion_routine)
&& GetLastError() == ERROR_SUCCESS)
{
SleepEx(INFINITE, TRUE);
}
}