How Gmod send/receive to external application in real via the memory
2 replies, posted
Hello,
I am thinking of way to interface Gmod with an external C++ application in realtime. For example I need to sore the data from Gmod in a place the other APP can read it. So far I've done it using steaming files on my ramdrive via Windows 7 junction folder, but I want to ask is there a better way, that writes the data directly in the memory at specified address which I can later retrieve.
Imagine if you have a value like "55". You write that value using some fancy Gmod API, and it gives you pointer for example 0x0034f768. Then using another application you read:
[code]
int *pAmount = 0x0034f768;
int iAmount = *pAmount
/*
Use "iAmount" variable and do something with it.
*/
[/code]
And yes, I know it is wrong very wrong to hard-code a pointer, that's why I am looking for another way to transfer the value 55 across the memory.
Posix systems have mmap and some other crap for creating memory mapped files, which can be used to map a block of shared memory that multiple processes can access.
The Windows API is more complex and harder to understand as usual, but the same thing appears to be possible.
In general though I'd recommend a socket, pipe, or some other IPC mechanism. Even within a single process, shared memory is hard to do correctly, and I honestly don't know off the top of my head how to use it for message passing between two processes.
If you are looking to store data I would look into a database.
Or use this guy here -> https://github.com/grpc/grpc
Sorry, you need to Log In to post a reply to this thread.