minor corrections by M.Taguchi
[reactos.git] / reactos / apps / tests / shm / shmclt.c
1 #include <ddk/ntddk.h>
2 #include <windows.h>
3 #include <stdarg.h>
4 #include <string.h>
5 #include <stdio.h>
6
7 HANDLE OutputHandle;
8 HANDLE InputHandle;
9
10 void debug_printf(char* fmt, ...)
11 {
12 va_list args;
13 char buffer[255];
14
15 va_start(args,fmt);
16 vsprintf(buffer,fmt,args);
17 WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
18 va_end(args);
19 }
20
21
22 int
23 main(int argc, char* argv[])
24 {
25 HANDLE Section;
26 PVOID BaseAddress;
27 char buffer[256];
28
29 printf("Shm test server\n");
30
31 Section = OpenFileMappingW (
32 // PAGE_EXECUTE_READWRITE, invalid parameter
33 FILE_MAP_WRITE,
34 FALSE,
35 L"TestSection"
36 );
37 if (Section == NULL)
38 {
39 printf("Failed to open section (err=%d)", GetLastError());
40 return 1;
41 }
42
43 BaseAddress = MapViewOfFile(Section,
44 FILE_MAP_ALL_ACCESS,
45 0,
46 0,
47 8192);
48 if (BaseAddress == NULL)
49 {
50 printf("Failed to map section (err=%d)\n", GetLastError());
51 return 1;
52 }
53 printf("BaseAddress %x\n", (UINT) BaseAddress);
54 printf("Copying from section\n");
55 strcpy(buffer, BaseAddress);
56 printf("Copyed <%s>\n", buffer);
57
58 // for(;;);
59 return 0;
60 }
61