Quantcast
Channel: LabWindows/CVI topics
Viewing all articles
Browse latest Browse all 5340

Dynamic DLL loading makes program crash

$
0
0

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?


Viewing all articles
Browse latest Browse all 5340

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>