6 int main(int argc, char* argv[])
\r
12 printf("Section Test\n");
\r
14 hFile = CreateFile(_T("sectest.txt"),
\r
15 GENERIC_READ | GENERIC_WRITE,
\r
21 if (hFile == INVALID_HANDLE_VALUE)
\r
23 printf("Failed to create file (err=%d)", GetLastError());
\r
27 Section = CreateFileMapping(hFile,
\r
33 if (Section == NULL)
\r
35 printf("Failed to create section (err=%d)", GetLastError());
\r
39 printf("Mapping view of section\n");
\r
40 BaseAddress = MapViewOfFile(Section,
\r
41 FILE_MAP_ALL_ACCESS,
\r
45 printf("BaseAddress %x\n", (UINT) BaseAddress);
\r
46 if (BaseAddress == NULL)
\r
48 printf("Failed to map section (%d)\n", GetLastError());
\r
52 printf("Clearing section\n");
\r
53 FillMemory(BaseAddress, 4096, ' ');
\r
54 printf("Copying test data to section\n");
\r
55 strcpy(BaseAddress, "test data");
\r
57 if (!UnmapViewOfFile(BaseAddress))
\r
59 printf("Failed to unmap view of file (%d)\n", GetLastError());
\r
63 if (!CloseHandle(hFile))
\r
65 printf("Failed to close file (%d)\n", GetLastError());
\r