Reputation: 21
The code involves integrating a usage monitoring dll to an existing host dll. The host dll is loaded by the WX GUI application for callbacks. The usage monitoring dll works as follows.
Initialize //f1
usageexportfrequency //f2
export usage signal to server // f3
deinit //f4
f1 is integrated to my host dlls initialization routine, f2 to the event based function in the host dll and likewise deinit to my host dll deinit.
when I integrate only f1 and f3 , the gui doesnt crash and works fine. when i Integrate the main f2 function to signal the usage of the call back function in my host dll and run the GUI application, It crashes immediately when i change the widget values.
However when i use the "usage" dll in a sample program(EXE not a host dll)it works like a charm.
HINSTANCE hGetProcIDDLL;
typedef void (__stdcall *lgUsgIn)(bool);
typedef void (__stdcall *SetMinInt)(long);
typedef bool (__stdcall *lgUsgSnd)(const char*,const char*,const char*);
typedef void(__stdcall *waitforCom)(void);
lgUsgIn LogUsageInit;
lgUsgSnd LogUsageSend;
SetMinInt SetMinInterval;
waitforCom WaitForCompletion;
hGetProcIDDLL = LoadLibrary("D:\\HTA_NG_DevEnvironment\\Utilization\\LogUsage.dll");
LogUsageInit = (lgUsgIn)GetProcAddress(hGetProcIDDLL, "LogUsageInit");
SetMinInterval = (SetMinInt)GetProcAddress(hGetProcIDDLL, "SetMinInterval");
LogUsageSend = (lgUsgSnd)GetProcAddress(hGetProcIDDLL, "LogUsageSend");
WaitForCompletion = (waitforCom)GetProcAddress(hGetProcIDDLL, "WaitForCompletion");
LogUsageInit(1);
SetMinInterval(600);
const char tool[] = "tooln1";
const char opt[] = "remoteValidation";
const char tag[] = "none";
bool OutCome = LogUsageSend(tool,opt,tag); // **crash happens when this function is included**
WaitForCompletion();
FreeLibrary(hGetProcIDDLL);
Also Function used to Load the Host Dll to the WX GUI Application is function Load()
from wxDynamicLibrary
class.
Upvotes: 0
Views: 51
Reputation: 21
Thanks for your input guys, I've found an answer within codeblocks something similar to your suggestions.
We can attach a host application to the DLL. And debug from the DLL project itself.
Upvotes: 0
Reputation: 61341
If you've developed your DLL in Visual Studio, you can designate the GUI application as the startup file for debugging. It's under project properties, Debug. This way, when you Debug your project, the GUI app will start and you'll hit the breakpoints in the DLL when they fire.
That said, there's a possibility the crash happens before your functions get control. Calling convention mismatch is a common culprit here; make sure the exported functions are __stdcall
and extern "C"
.
Upvotes: 0
Reputation: 3323
With visual studio (provided you have the dll pdb file (symbols)) you can attach to any process (eg the GUI application) and debug a part of it (the dll part for instance) If you add a breakpoint on bool OutCome = LogUsageSend(tool,opt,tag)
you should be able to step into it.
Upvotes: 2