ReactOS 0.4.16-dev-197-g92996da
apc.c File Reference
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <ndk/ntndk.h>
Include dependency graph for apc.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define NTOS_MODE_USER
 

Functions

VOID WINAPI ApcRoutine (PVOID Context, PIO_STATUS_BLOCK IoStatus, ULONG Reserved)
 
int main (int argc, char *argv[])
 

Variables

HANDLE OutputHandle
 
HANDLE InputHandle
 

Macro Definition Documentation

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 5 of file apc.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 3 of file apc.c.

Function Documentation

◆ ApcRoutine()

VOID WINAPI ApcRoutine ( PVOID  Context,
PIO_STATUS_BLOCK  IoStatus,
ULONG  Reserved 
)

Definition at line 12 of file apc.c.

15{
16 printf("(apc.exe) ApcRoutine(Context %p)\n", Context);
17}
#define printf
Definition: freeldr.h:97

◆ main()

int main ( int argc  ,
char argv[] 
)

Definition at line 20 of file apc.c.

21{
27 CHAR Buffer[256];
29 LARGE_INTEGER off;
30
34
35 printf("APC test program\n");
36
38 FALSE,
39 FALSE,
40 NULL);
42 {
43 printf("Failed to create event\n");
44 return 0;
45 }
46
47 printf("Opening file\n");
49 &FileName,
50 0,
51 NULL,
52 NULL);
53
54 printf("Creating file\n");
55 FileHandle = CreateFileW(L"C:\\a.txt",
57 0,
58 NULL,
61 NULL);
62
64 {
65
66 printf("Open failed last err 0x%lx\n",GetLastError());
67 return 0;
68 }
69
70 off.QuadPart = 0;
71
72 printf("Reading file\n");
73 Status = ZwReadFile(FileHandle,
74 NULL,
76 (PVOID) 0xdeadbeef,
77 &IoStatus,
78 Buffer,
79 256,//len
80 &off ,//offset must exist if file was opened for asynch. i/o aka. OVERLAPPED
81 NULL);
82
83 if (!NT_SUCCESS(Status))
84 {
85 printf("Read failed status 0x%lx\n",Status);
86 }
87 printf("Waiting\n");
89 printf("Returned from wait\n");
91 printf("Program finished\n");
92 return 0;
93}
LONG NTSTATUS
Definition: precomp.h:26
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
BOOL WINAPI AllocConsole(VOID)
Definition: console.c:74
Definition: bufpool.h:45
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileW
Definition: compat.h:741
#define INFINITE
Definition: serial.h:102
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
Status
Definition: gdiplustypes.h:25
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
HANDLE InputHandle
Definition: apc.c:9
HANDLE OutputHandle
Definition: apc.c:8
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE ApcRoutine
Definition: iofuncs.h:726
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
VOID(* PIO_APC_ROUTINE)(IN PVOID ApcContext, IN PIO_STATUS_BLOCK IoStatusBlock, IN ULONG Reserved)
Definition: nt_native.h:877
#define FILE_GENERIC_READ
Definition: nt_native.h:653
#define FILE_GENERIC_WRITE
Definition: nt_native.h:660
#define L(x)
Definition: ntvdm.h:50
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
LONGLONG QuadPart
Definition: typedefs.h:114
#define STD_OUTPUT_HANDLE
Definition: winbase.h:293
#define STD_INPUT_HANDLE
Definition: winbase.h:292
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_Out_ PHANDLE EventHandle
Definition: iofuncs.h:857
char CHAR
Definition: xmlstorage.h:175

Variable Documentation

◆ InputHandle

◆ OutputHandle

HANDLE OutputHandle