8 int main(int argc
, char* argv
[])
14 printf("Section Test\n");
16 hFile
= CreateFile(_T("sectest.txt"),
17 GENERIC_READ
| GENERIC_WRITE
,
23 if (hFile
== INVALID_HANDLE_VALUE
)
25 printf("Failed to create file (err=%ld)", GetLastError());
29 Section
= CreateFileMapping(hFile
,
37 printf("Failed to create section (err=%ld)", GetLastError());
41 printf("Mapping view of section\n");
42 BaseAddress
= MapViewOfFile(Section
,
47 printf("BaseAddress %x\n", (UINT
) BaseAddress
);
48 if (BaseAddress
== NULL
)
50 printf("Failed to map section (%ld)\n", GetLastError());
54 printf("Clearing section\n");
55 FillMemory(BaseAddress
, 4096, ' ');
56 printf("Copying test data to section\n");
57 strcpy(BaseAddress
, "test data");
59 if (!UnmapViewOfFile(BaseAddress
))
61 printf("Failed to unmap view of file (%ld)\n", GetLastError());
65 if (!CloseHandle(hFile
))
67 printf("Failed to close file (%ld)\n", GetLastError());