dll communicating between each other

This is a discussion on dll communicating between each other within the C++ Programming forums, part of the General Programming Boards category; Hi all, I have installed a global hook and injected my dll into all running processes. The exe file that ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    100

    dll communicating between each other

    Hi all,

    I have installed a global hook and injected my dll into all running processes. The exe file that installed the hook calls one of the dll's callback functions when one of its variables reaches a certain amount. But the dll that the exe file calls is the one that is attached to its own process. If i know the HMODULE of a certain dll that is attached to another process (by putting it in the shared area) then is there away that i can call a function in that dll from the other dll? I know that sounds confusing so i'll try an example. Lets say i have 2 processes running

    1. MyProg.exe
    2. Notepad.exe

    and i use MyProg.exe to inject a dll called MyDll.dll into all running processes (so just into the two above). Now the dll injected into Notepad.exe stores its HMODULE into the shared area so the dll in MyProg.exe can also see it.

    Now when MyProg changes state (like if a variable gets larger than 10). The MyProg calls a function in the dll module that it is attached to (say it executes a function called function1() in the dll). The function1() of the dll attached to MyProg cheacks the shared data for the HMODULE of the other dll attached in Notepad.exe and it wants to call a funcation (say function2()) of that dll. That is what im trying to do but im not sure how to. I can get as far as making the MyProg.exe call the function1() of its dll (which works fine) but i dont know how the function1() will then use the HMODULE of the other dll to call its function2()

    Thanks for your time

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,660
    You can not call a function of a DLL within another process. You'll have to use some form a inter-process communication to get the other DLL instances to do something.

    gg

  3. #3
    #include<xErath.h> xErath's Avatar
    Join Date
    Jun 2004
    Posts
    722
    Quote Originally Posted by Codeplug
    You can not call a function of a DLL within another process. You'll have to use some form a inter-process communication to get the other DLL instances to do something.

    gg
    Also that wouldn't do much would it ? Usually dlls only contain generic helper functions, because the core of a process relies on global vars and stuff for which dlls don't have acess.
    Correct me if wrong please.

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    9
    Quote Originally Posted by Codeplug
    You can not call a function of a DLL within another process. You'll have to use some form a inter-process communication to get the other DLL instances to do something.
    well, let me say, that's not true...
    In fact DLL's with shared sections can be used as an alternative implementation of inter-process communication...
    for a sample code, please look at http://www.ourcode.net/vc/vckbase/en...Segs.shtml.htm

    Regards, bilbo

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,660
    >> well, let me say, that's not true...
    I assume you're addressing xErath even though you quoted me

    http://blogs.msdn.com/oldnewthing/ar...04/208003.aspx

    gg

  6. #6
    Registered User
    Join Date
    Jun 2005
    Posts
    9
    Nice link, thanks Codeplug.
    Unfortunately, security holes are everywhere, especially in Windows platforms and IPC; but anyway...

    Regards, bilbo

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. non-MFC DLL with MFC app question.
    By Kempelen in forum Windows Programming
    Replies: 10
    Last Post: 08-20-2008, 07:11 AM
  2. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 12:34 PM
  3. Using class with DLL
    By greg2 in forum C++ Programming
    Replies: 2
    Last Post: 09-12-2003, 05:24 AM
  4. .lib vs .h vs .dll
    By Shadow12345 in forum C++ Programming
    Replies: 13
    Last Post: 01-01-2003, 04:29 AM
  5. Passing parameters from VB to C++ through ActiveX DLL
    By torbjorn in forum Windows Programming
    Replies: 0
    Last Post: 12-10-2002, 02:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21