11 ApcRoutine(PVOID Context,
12 PIO_STATUS_BLOCK IoStatus,
15 printf("(apc.exe) ApcRoutine(Context %p)\n", Context);
18 int main(int argc, char* argv[])
22 OBJECT_ATTRIBUTES ObjectAttributes;
23 UNICODE_STRING FileName = UNICODE_STRING_INITIALIZER(L"\\C:\\a.txt");
24 IO_STATUS_BLOCK IoStatus;
29 InputHandle = GetStdHandle(STD_INPUT_HANDLE);
30 OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
32 printf("APC test program\n");
34 EventHandle = CreateEventW(NULL,
38 if (EventHandle == INVALID_HANDLE_VALUE)
40 printf("Failed to create event\n");
44 printf("Opening file\n");
45 InitializeObjectAttributes(&ObjectAttributes,
51 printf("Creating file\n");
52 FileHandle = CreateFileW(L"C:\\a.txt",
53 FILE_GENERIC_READ | FILE_GENERIC_WRITE,
59 if (FileHandle == INVALID_HANDLE_VALUE)
61 printf("Open failed\n");
64 printf("Reading file\n");
65 Status = ZwReadFile(FileHandle,
67 (PIO_APC_ROUTINE)ApcRoutine,
74 if (!NT_SUCCESS(Status))
76 printf("Read failed\n");
79 WaitForSingleObjectEx(EventHandle, INFINITE, TRUE);
80 printf("Returned from wait\n");
82 printf("Program finished\n");