1 /* $Id: sectest.c 19171 2005-11-12 08:40:47Z sedwards $ */
10 int main(int argc
, char* argv
[])
16 printf("Section Test\n");
18 hFile
= CreateFile(_T("sectest.txt"),
19 GENERIC_READ
| GENERIC_WRITE
,
25 if (hFile
== INVALID_HANDLE_VALUE
)
27 printf("Failed to create file (err=%ld)", GetLastError());
31 Section
= CreateFileMapping(hFile
,
39 printf("Failed to create section (err=%ld)", GetLastError());
43 printf("Mapping view of section\n");
44 BaseAddress
= MapViewOfFile(Section
,
49 printf("BaseAddress %x\n", (UINT
) BaseAddress
);
50 if (BaseAddress
== NULL
)
52 printf("Failed to map section (%ld)\n", GetLastError());
56 printf("Clearing section\n");
57 FillMemory(BaseAddress
, 4096, ' ');
58 printf("Copying test data to section\n");
59 strcpy(BaseAddress
, "test data");
61 if (!UnmapViewOfFile(BaseAddress
))
63 printf("Failed to unmap view of file (%ld)\n", GetLastError());
67 if (!CloseHandle(hFile
))
69 printf("Failed to close file (%ld)\n", GetLastError());