LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic DLL loading makes program crash

Dear NI Community,

 

I'm having a problem with a client's DLL. The DLL is created (by another of the client's supplier) using LabView / LabWindows.

 

I have a C++ code with dynamic dll loading looking like:

 

#include "'clientDLL.h"

...


typedef ViStatus regFunction(char*, unsigned long*);
char strPter[128];
int res;

...

void ext_call_getKernel(){

                res = getKernelVersion(strPter);
                cout<<"Kernel_Version returned "<<res<<" version = "<<strPter<<endl;

}

 

void loadDLL(){

        hinstLib = LoadLibrary("C:/Prober_Suss.dll");  
        if (hinstLib != NULL)
        {
            cout<<"HINSTANCE = "<<hinstLib<<endl;
            functionAddress = (LPTSTR) GetProcAddress(hinstLib, (LPCSTR)"clientsDLL_Register");
            localRegister = (regFunction*)functionAddress;
            
        if (*localRegister != NULL){
            cout<<"procAddr Register = "<<functionAddress<<endl;
            res = localRegister(AppName, &sessionLong);
            cout<<"Register returned "<<res<<" session = "<<sessionLong<<endl;
                    if(sessionLong != 0){
                functionAddress = (LPTSTR) GetProcAddress(hinstLib, (LPCSTR)"Kernel_Version");
                getKernelVersion = (getStringFunction*)functionAddress;

                for(int i = 0; i < 12; i++){
                    res = getKernelVersion(strPter);
                    cout<<"Kernel_Version returned "<<res<<" version = "<<strPter<<endl;

                }

                ext_call_getKernel();

...

 

 

This code works until ext_call_getKernel(), the whole program stops with (gcc)debugger message :


RUN FAILED (exit value 1 875 677 888, total time: 4s)

 


        Any idea on what could make this kind of problem appear, and how to resolve it?

0 Kudos
Message 1 of 3
(4,343 Views)

Hello Sylvio,
Is it possible to update a little project that reproduce the error?
BR,

Jovan N. - Application Engineering
0 Kudos
Message 2 of 3
(4,241 Views)

Dear Jovan,

 

Unfortunately I cannot send the client DLL so it would be useless...

 

By the way, we have been given a new version of clientDLL which loads in static (#include "clientDLL.h"); this way we avoid the problem.

 

Thank you for your answer;

Regards,

HS

0 Kudos
Message 3 of 3
(4,231 Views)