lemme just write a python script to talk to a cross-platform c++ program through shared memory on win32.
this certainly won't be an infinite nightmare, right?
I'm using pywin32 which doesn't give me the ability to distinguish between opening a named shared memory area and creating one, so it succeeds but just because it creates a new shared memory area for me full of nothing
the C++ code calls CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, memory_map_size, "DWD_GAMELINK_MMAP_R4");
and then on python, I call
OpenFileMappingA(FILE_MAP_ALL_ACCESS, False, "DWD_GAMELINK_MMAP_R4") and get a File Not Found error.
hmmm.
yeah I don't think pywin32's mmapfile lets you use an ASCII filename, and windows apparently matches named shared memory by the bytes of the name, not the value of the characters. so a unicode "foo" and an ascii "foo" are different mappings
@whitequark yeah I think you might be right. I think I was converting it incorrectly somehow
or maybe it was just that I was calling OpenFileMappingA with a unicode string, which is obviously wrong.
That still doesn't explain why pywin32 wasn't working, and since I've already written the ctypes equivalent, I'm not gonna look into it
cancel the celebrations, I've mapped the named shared memory supposedly properly but when I read from it I get a 0.
it should be a 4. So this isn't working
I'm definitely opening the mapping, though. if I change the name to "foobar" I get a FileNotFound error. HMMM
ugh I'm probably gonna have to write some C++ code to get it working, and then once I know what's wrong, I can translate that to python
I used cheat engine to explore the memory regions of my python script, and it DOES have an appropriately-sized mapped region, but it similarly seems to be full of zeros.
and then I spied on DOSBox-X, which is supposed to be the program filling out that shared mapping, and... it's empty there too!
@foone i am loathe to ask this, but is there not a generic mmap implementation for python that unfucks whatever infelicities befall the win32 API?
@nabijaczleweli there is, but it doesn't support the kind of named shared region I need
static void shared_memory_init()
{
if (sdl.gamelink.snoop) return;
if you're in snoop mode, it doesn't initialize the segment.
WHY THE FUCK NOT
yep. I turned off snoop mode and now it works. I see a 4 where I expect it
well I think this debugging session used up all my energy I was going to write some software that used this shit, but hey. at least step 1 works now