I am trying to write into a (shared) named file mapping object like so:
//ENTER CRITICAL SECTION FIRST
int ncbSzMapping = 0x92B8; //Size of a shared struct
hFileMapping = CreateFileMapping((HANDLE)INVALID_HANDLE_VALUE,
NULL, PAGE_READWRITE,
0, ncbSzMapping,
_T("mapping_name"));
if(hFileMapping)
{
BYTE* pRWData = MapViewOfFile(hFileMapping,
FILE_MAP_ALL_ACCESS, 0, 0, ncbSzMapping);
if(pRWData)
{
//Write data into 'pRWData' of 'ncbSzMapping' bytes
UnmapViewOfFile(pRWData);
}
}
...
//LEAVE CRITICAL SECTION
The code above works without a problem. But when I change the ncbSzMapping to 0x8A8B8 the code above succeeds but later down the code I get an exception c00000fd right before a function call that makes no sense to me.
Any idea why that size increase makes a difference and how to fix it?
0xc00000fd is a stack overflow. Are you declaring a buffer as a local variable with that size? If so, that’s your problem. Move the buffer off the stack by making it a global or static, or allocate it dynamically using new/delete.