Archived

This topic is now archived and is closed to further replies.

silvermace

GetProcAddress Not Owrking in Release Mode!?

Recommended Posts

i can compile the library in release mode, and my app finds all the functions BUT ONLY IN DEBUG MODE. as soon as i try to use the un-modded code in release mode, GetProcAddress returns NULL (fails) heres the Library code:
  
#define EXPORT_FUNCTION extern "C" __declspec(dllexport)

using namespace std;
vector<script_variable*> curVars;
EXPORT_FUNCTION int SetVariables(script_variable *vars)
{
	printf("SetVar!\n");
	curVars.push_back(vars); 
	return 1;
}

EXPORT_FUNCTION int CL_DLLTest(script_function *F)
{
	printf("libfunc(%s)\n",F->argv[0].line);
	F->call_return.idata.clear();
	F->call_return.idata.push_back(452);
	F->call_return.type = F_INT;
	return 1;
}
EXPORT_FUNCTION int init(int read,int write)
{
	printf("CLi LibTest.dll Init!\n");
	return 1;
}
  
this is the App side source
  
typedef int (*F_LIBINITF) ( int read_pipe,int write_pipe);
typedef int (*F_LIBFUNC_NP) ( script_function*F);
typedef int (*F_LIBSETVAR) ( script_variable*F);

// loading function ...

	unsigned int &sz = scLibs[_cur].f_count;			
	scLibs[_cur].functions_np[sz] = (F_LIBFUNC_NP) GetProcAddress((HMODULE) scLibs[_cur].hLib, libOpp);
	string_t namp = libOpp;
	scLibs[_cur].functions_names[sz] = namp.line;
	scLibs[_cur].f_count++;

	if(scLibs[_cur].functions_np[sz]==NULL){
	  printf("Error Loading Function [%s]\n",libOpp);
	  scLibs[_cur].f_count--; // remove this one

	} else {
	printf("Loaded Function [%s]\n",libOpp);
	}
// end ...

  

Share this post


Link to post
Share on other sites
possibly the dll you are trting to load the functions from is not being loaded. why not make sure the dll is loaded before blaming GetProcAddress() since i have had it only fail on two occasions.
1. dll was not loaded due to the wrong path given to LoadLibrary()
2. function was not exported/forgot to use extern C{}

seems like number 1 is happneing to you.

Share this post


Link to post
Share on other sites