ReactOS 0.4.15-dev-7842-g558ab78
sectest.c File Reference
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <tchar.h>
Include dependency graph for sectest.c:

Go to the source code of this file.

Macros

#define UNICODE
 
#define _UNICODE
 

Functions

int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ _UNICODE

#define _UNICODE

Definition at line 2 of file sectest.c.

◆ UNICODE

Definition at line 1 of file sectest.c.

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)

Definition at line 9 of file sectest.c.

10{
12 HANDLE Section;
14
15 printf("Section Test\n");
16
17 hFile = CreateFile(_T("sectest.txt"),
19 0,
20 NULL,
22 0,
23 0);
25 {
26 printf("Failed to create file (err=%ld)", GetLastError());
27 return 1;
28 }
29
30 Section = CreateFileMapping(hFile,
31 NULL,
33 0,
34 4096,
35 NULL);
36 if (Section == NULL)
37 {
38 printf("Failed to create section (err=%ld)", GetLastError());
39 return 1;
40 }
41
42 printf("Mapping view of section\n");
43 BaseAddress = MapViewOfFile(Section,
45 0,
46 0,
47 4096);
48 printf("BaseAddress %x\n", (UINT) BaseAddress);
49 if (BaseAddress == NULL)
50 {
51 printf("Failed to map section (%ld)\n", GetLastError());
52 return 1;
53 }
54
55 printf("Clearing section\n");
56 FillMemory(BaseAddress, 4096, ' ');
57 printf("Copying test data to section\n");
58 strcpy(BaseAddress, "test data");
59
61 {
62 printf("Failed to unmap view of file (%ld)\n", GetLastError());
63 return 1;
64 }
65
66 if (!CloseHandle(hFile))
67 {
68 printf("Failed to close file (%ld)\n", GetLastError());
69 return 1;
70 }
71
72 return 0;
73}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define UnmapViewOfFile
Definition: compat.h:746
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define MapViewOfFile
Definition: compat.h:745
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define printf
Definition: freeldr.h:93
#define CREATE_ALWAYS
Definition: disk.h:72
_In_ HANDLE hFile
Definition: mswsock.h:90
unsigned int UINT
Definition: ndis.h:50
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define GENERIC_WRITE
Definition: nt_native.h:90
#define _T(x)
Definition: vfdio.h:22
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CreateFileMapping
Definition: winbase.h:3685
#define FILE_MAP_ALL_ACCESS
Definition: winbase.h:156
#define CreateFile
Definition: winbase.h:3684