If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

2 programs, 1 dll sharing variable.

hello again, just wondering if you guys could help me again.

my goal:
have 1 program handle the UI
have that program store variables to a DLL
have the 2nd program grab the stored variables to reform some number crunching, without interfering with the UI program, and once done, have it drop the answers back into that DLL, so that the UI can grab it when it's ready.

I have made the 2 programs, + dll (sorry, there is a lot of code, so I won't post it, unless you have a theory, to wich I can post how I achieved, whatever it is your theory is about)

What I've Achieved:

the first program accesses the dll, and loads up a variable (and stays connected to the dll, so that the Dll instance doesn't reset)

I've gotten the DLL to output the variable to make sure it's received it, and stored it to it's own global variable.

the second program connects to the dll successfully, but when it tries to retrieve the data, it returns 0's (NULL's)

My research:
from what I've read, so long the dll is connected to a program, all additional programs will attach to the same instance.

how do I make the global variable in the dll be accessible to both programs? (without resorting to saving it to the HDD Idealy)

Re: 2 programs, 1 dll sharing variable.

@Codeplug:
It's true, but it's also somewhat of a bogus argument. This will only protect you from unauthorised access from other windows users.
Oops, did that guy forget to mention that you can apply the same type of security descriptors on the DLL as you can on the mapped file. If user-level restriction is needed, then both the shared section in a dll and the mapped file can be protected.

But yes, shared memory has several issues, regardless of how you try to protect it.
THe DLL shared section can be an issue on a terminal server with multiple users havign active desktop sessions on the same machine at the same time. But without care, even the mapped file will have issues with this.

ANd with the right tools and capabilities, you can make any exe do just about anything you want. Give a capable user a proper debugger and a basic compiler, and they can do all sorts of nasty stuff if they get enough privileges on the machine.
something to Always be aware of

Re: 2 programs, 1 dll sharing variable.

@Codeplug:
It's true, but it's also somewhat of a bogus argument. This will only protect you from unauthorised access from other windows users.
Oops, did that guy forget to mention that you can apply the same type of security descriptors on the DLL as you can on the mapped file. If user-level restriction is needed, then both the shared section in a dll and the mapped file can be protected.

But yes, shared memory has several issues, regardless of how you try to protect it.
THe DLL shared section can be an issue on a terminal server with multiple users havign active desktop sessions on the same machine at the same time. But without care, even the mapped file will have issues with this.

ANd with the right tools and capabilities, you can make any exe do just about anything you want. Give a capable user a proper debugger and a basic compiler, and they can do all sorts of nasty stuff if they get enough privileges on the machine.
something to Always be aware of