ReactOS  0.4.15-dev-4922-ge8ccc85
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[] 
)

hosttype.c Copyright (C) 2002 by Brian Palmer brian.nosp@m.p@sg.nosp@m.inet..nosp@m.com

Definition at line 9 of file sectest.c.

10 {
11  HANDLE hFile;
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 }
#define CloseHandle
Definition: compat.h:598
#define MapViewOfFile
Definition: compat.h:604
#define CreateFileMapping
Definition: winbase.h:3611
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define GENERIC_WRITE
Definition: nt_native.h:90
#define FILE_MAP_ALL_ACCESS
Definition: winbase.h:156
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define _T(x)
Definition: vfdio.h:22
#define printf
Definition: freeldr.h:94
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define GENERIC_READ
Definition: compat.h:135
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CREATE_ALWAYS
Definition: disk.h:72
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define UnmapViewOfFile
Definition: compat.h:605
#define PAGE_READWRITE
Definition: nt_native.h:1304