I'd like to write to shared memory and then dump the contents to a file in the win32 api. Currently I have this code:
HANDLE hFile, hMapFile;
LPVOID lpMapAddress;
hFile = CreateFile("input.map",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
hMapFile = CreateFileMapping(hFile,
NULL,
PAGE_READWRITE,
0,
0,
TEXT("SharedObject"));
lpMapAddress = MapViewOfFile(hMapFile,
FILE_MAP_ALL_ACCESS,
0,
0,
0);
sprintf(MapViewOfFile, "<output 1>");
UnmapViewOfFile(lpMapAddress);
CloseHandle(hFile);
CloseHandle(hMapFile);
However, line 31 (the sprintf call) gives the error:
error: cannot convert `void*(*)(void*, DWORD, DWORD, DWORD, DWORD)'
to `char*' for argument `1' to `int sprintf(char*, const char*, ...)'
I've tried casting the lpMapAddress to LPTSTR, but it has no effect. What am I doing wrong? Or is there a better way to do it?