9 int main(int argc
, char* argv
[])
15 printf("Section Test\n");
17 hFile
= CreateFile(_T("sectest.txt"),
18 GENERIC_READ
| GENERIC_WRITE
,
24 if (hFile
== INVALID_HANDLE_VALUE
)
26 printf("Failed to create file (err=%ld)", GetLastError());
30 Section
= CreateFileMapping(hFile
,
38 printf("Failed to create section (err=%ld)", GetLastError());
42 printf("Mapping view of section\n");
43 BaseAddress
= MapViewOfFile(Section
,
48 printf("BaseAddress %x\n", (UINT
) BaseAddress
);
49 if (BaseAddress
== NULL
)
51 printf("Failed to map section (%ld)\n", GetLastError());
55 printf("Clearing section\n");
56 FillMemory(BaseAddress
, 4096, ' ');
57 printf("Copying test data to section\n");
58 strcpy(BaseAddress
, "test data");
60 if (!UnmapViewOfFile(BaseAddress
))
62 printf("Failed to unmap view of file (%ld)\n", GetLastError());
66 if (!CloseHandle(hFile
))
68 printf("Failed to close file (%ld)\n", GetLastError());