How can a DLL execute a function of the main app?
-
write 0xAD to port 0x64 oh wait... pass a pointer to the function to the DLL. I know of no "reverse export" mechanism.
we are here to help each other get through this thing, whatever it is Vonnegut jr.
boost your code || Fold With Us! || sighist | doxygenSo it's impossible? Isn't there some possibility of generating a .lib file of main app or something like that? How can I write a plugin architecture then? The DLL must be somehow be able to execute class functions of the main app...
_outp(0x64, 0xAD);
and__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do?? ;) (doesn't work on NT) -
So it's impossible? Isn't there some possibility of generating a .lib file of main app or something like that? How can I write a plugin architecture then? The DLL must be somehow be able to execute class functions of the main app...
_outp(0x64, 0xAD);
and__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do?? ;) (doesn't work on NT)Wooo! It is more than possible! The person who has the information at the tip of his tong is just not online. If we have not done anything like that in a while, then we have to try to remember enough to figure it out (if we have the time to go through the trouble). There are articles at CP on plugins, DLLs and COMM (also in the MSDN Library). When I first read your post (ealier today) the first thing I thought about was callback functions, but that was not what you where asking about. If you can pass a callback function you can pass a class pointer. Heck we pass class pointers and references to DLLs all the time, otherwise we could not use MFC. Your question is resonable and someone may yet answer it. I am no expert on DLLs, so I did not try to figure out what the problem was. INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
-
Wooo! It is more than possible! The person who has the information at the tip of his tong is just not online. If we have not done anything like that in a while, then we have to try to remember enough to figure it out (if we have the time to go through the trouble). There are articles at CP on plugins, DLLs and COMM (also in the MSDN Library). When I first read your post (ealier today) the first thing I thought about was callback functions, but that was not what you where asking about. If you can pass a callback function you can pass a class pointer. Heck we pass class pointers and references to DLLs all the time, otherwise we could not use MFC. Your question is resonable and someone may yet answer it. I am no expert on DLLs, so I did not try to figure out what the problem was. INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
The person who has the information at the tip of his tong is just not online. Let's hope he'll get online soon :) There are articles at CP on plugins, DLLs and COMM (also in the MSDN Library). I've read most of them, but actually many of them are for C# only and the others for C++ never have the problem that the DLL wants to call something that is in the EXE. They'll just describe how to load and call a DLL, the DLL then does many things, like creating new windows, sending windows messages, etc. but never calls something of the EXE... Thanks and best regards, Dominik
_outp(0x64, 0xAD);
and__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do?? ;) (doesn't work on NT) -
The person who has the information at the tip of his tong is just not online. Let's hope he'll get online soon :) There are articles at CP on plugins, DLLs and COMM (also in the MSDN Library). I've read most of them, but actually many of them are for C# only and the others for C++ never have the problem that the DLL wants to call something that is in the EXE. They'll just describe how to load and call a DLL, the DLL then does many things, like creating new windows, sending windows messages, etc. but never calls something of the EXE... Thanks and best regards, Dominik
_outp(0x64, 0xAD);
and__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do?? ;) (doesn't work on NT)I have looked into this quite some time back and I'm afraid I can't remember what the outcome was, but I vaguely recall it was possible. You need to create a lib for the .exe and use that in the DLL. Also declare the functions as exported. One issue that comes to mind though is DLL's are (can be) shared by .EXE's so which EXE would the exported function be in. I guess this info lives in the export information. Another way to do this is for the .EXE to expose an array of functions DLL's can call. You could do this with delegates and probably signals and slots. Have a look at the truly excellent FastDelegate here on CP. In my programmers editor (see sig) I enabled interpreted C functions to call C/C++ functions in my .EXE. This is done by my C compiler resolving function addresses via. the .EXE's MAP file. This works very well and allows extensions to the editor to do most anything that the .exe can. Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
-
I have looked into this quite some time back and I'm afraid I can't remember what the outcome was, but I vaguely recall it was possible. You need to create a lib for the .exe and use that in the DLL. Also declare the functions as exported. One issue that comes to mind though is DLL's are (can be) shared by .EXE's so which EXE would the exported function be in. I guess this info lives in the export information. Another way to do this is for the .EXE to expose an array of functions DLL's can call. You could do this with delegates and probably signals and slots. Have a look at the truly excellent FastDelegate here on CP. In my programmers editor (see sig) I enabled interpreted C functions to call C/C++ functions in my .EXE. This is done by my C compiler resolving function addresses via. the .EXE's MAP file. This works very well and allows extensions to the editor to do most anything that the .exe can. Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
Also declare the functions as exported. Doh :) I've searched the whole IDE, all subdialogs, etc. at least 2 hours for a setting to generate a .lib of the .exe file... Didn't find anything. I have almost given it up and then just prefixed some of the functions with __declspec(dllexport). Compiled it, and think what? It generated the .lib, .exp and exported the functions very nicely as one could see in the Dependency Viewer. Yay!!! Added the .lib to the test plugin project (the DLL), compiled it, and everything works!! Many many thanks!!! Dominik
_outp(0x64, 0xAD);
and__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do?? ;) (doesn't work on NT) -
Also declare the functions as exported. Doh :) I've searched the whole IDE, all subdialogs, etc. at least 2 hours for a setting to generate a .lib of the .exe file... Didn't find anything. I have almost given it up and then just prefixed some of the functions with __declspec(dllexport). Compiled it, and think what? It generated the .lib, .exp and exported the functions very nicely as one could see in the Dependency Viewer. Yay!!! Added the .lib to the test plugin project (the DLL), compiled it, and everything works!! Many many thanks!!! Dominik
_outp(0x64, 0xAD);
and__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do?? ;) (doesn't work on NT):-DNot bad at all! An expert did not show up but someone who could get you looking in the right direction did. :doh:It never occured to me that you were not using export. :(Now if I can just understand how to do basicaly the same thing via COM thru the IUnknow interface. Thats what I've been working on. INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
-
:-DNot bad at all! An expert did not show up but someone who could get you looking in the right direction did. :doh:It never occured to me that you were not using export. :(Now if I can just understand how to do basicaly the same thing via COM thru the IUnknow interface. Thats what I've been working on. INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
John R. Shaw wrote: Not bad at all! An expert did not show up but someone who could get you looking in the right direction did. Hey who said I'm not an expert.:-D Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
-
Also declare the functions as exported. Doh :) I've searched the whole IDE, all subdialogs, etc. at least 2 hours for a setting to generate a .lib of the .exe file... Didn't find anything. I have almost given it up and then just prefixed some of the functions with __declspec(dllexport). Compiled it, and think what? It generated the .lib, .exp and exported the functions very nicely as one could see in the Dependency Viewer. Yay!!! Added the .lib to the test plugin project (the DLL), compiled it, and everything works!! Many many thanks!!! Dominik
_outp(0x64, 0xAD);
and__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do?? ;) (doesn't work on NT)Dominik Reichl wrote: Added the .lib to the test plugin project (the DLL), compiled it, and everything works!! Many many thanks!!! Glad to be of help. Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
-
John R. Shaw wrote: Not bad at all! An expert did not show up but someone who could get you looking in the right direction did. Hey who said I'm not an expert.:-D Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
Neville Franks wrote: Hey who said I'm not an expert.:-D :laugh:You know what I mean! Some one who writes DLLs all the time and can answer questions about them in his sleep. By that deffinition most of us are not experts on DLLs.:-D INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
-
Hello! I'm currently writing some application, that contains a class A. It loads a DLL and passes a pointer to A to the DLL. The DLL includes the header file of A. Anyway, when I try to compile this, I get LNK2001: unresolved external symbol errors for all A class function calls... When I include all *.obj files as library files in the DLL settings, it compiles. But it doesn't really execute the actual functions of the main application then, it just compiles the whole code again into the DLL. It shouldn't do this, it should just call the real functions of the main application. What must I do that the DLL can execute the functions of A? Thanks and best regards, Dominik
_outp(0x64, 0xAD);
and__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do?? ;) (doesn't work on NT)Well, the most simple way is to move all 'exported' functionality (i.e. that part of the application the plugins should be able to access) into a separate dll itself. Plugins then just need to link to that dll in order to use them, as does the main application. (This would most likely be done via implicit linkage) That way you also have enforced a modular concept for your application, which I'd recommend anyway as soon as your appication gets complex. Many of my bigger projects evolved to a main exe that only served as 'launcher' for the dlls that contain the 'real application'. Hope that helps, Nick