Jump to content
  • Advertisement
Sign in to follow this  
BleedingBlue

Shared DLL?

This topic is 4862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well what I want to do is link the same dll to two different applications, and have them share memory across this DLL, IE one app which is linked to a game will call a function and fill in a list of prices for objects in the game, I want another application to then be able to call a function and retrieve this list, how would I go about that?

Share this post


Link to post
Share on other sites
Advertisement
From what I understand, you can't, or at least shan't :-)

Each executable that runs has its own memory addressing space. That is, two executables could simultaneously have pointers to 0x3003fa12, but they actually point to separate areas of physical (or virtual) memory. The operating system makes sure that you don't overstep your bounds into other peoples' memory. Poking around outside your space is likely to result in segmentation faults (read: catastrophic failure).

The answer is to have some kind of third party communicate between the two. A database (probably not for a game), a TCP/IP socket connection (very reliable and fast on the localhost), or something like that.

Correct me if I'm wrong.



~BenDilts( void );

Share this post


Link to post
Share on other sites
Well your right about the memory I knew about that problem already. However I was hoping to keep this as simple as possible, and did not want to have to resort to some TCP sockets, or file access.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
A quick and dirty hack would be to send a WM_USER type of window message across applications to that your server dumps a file to a specific location (i.e. PostMessage(HWND_BROADCAST, ...) ). The server can send a WM_USER type of window message once this is done so you can pick up the file. You need to register your WM_xxxx message first with RegisterWindowMessage().

Share this post


Link to post
Share on other sites
Here's a very simplistic method of sharing memory in a DLL:



#pragma data_seg(".shared")
int g_sharedInteger = 0;
CHAR g_sharedArray[64][64] = {0};
#pragma data_seg()

#pragma comment(linker, "/SECTION:.shared,RWS")



Shared memory blocks in code have to be initialized -- so when you declare the variables you must also assign them to something.

Robert

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!