J
Jake Thompson
Hello I created a DLL that has a function that is called from my main c
program.
In my exe I first get a a pointer to the address of the function by
using GetProcAddress and on the dll side I make sure that my function
is being exported by adding a line to the .def file.
This seems to work because when I debug it recognizes the dll and once
it hits the function it goes right into the proper location of the dll.
The problem that I am having is that the function passes a structure as
part of it's three parameters. The structure appears to have all the
correct data in in while its in the main c program. However once it
goes over to the dll the structure no longer has the proper data in it.
It's almost like it was corrupted. What I find odd is that I am
passing a Tag as one of the parameters and that seems to make it over
fine. Can someone tell me what I am doing wrong? My understanding of
GetProcAddress is that once it gets a pointer to the address that it's
just like going from one function to another within the same project.
Of course I could have that misunderstood. Any help would be
appreciated. Below is a sample of my code.
C program
static GENERICCM gencm;
gencm.pszDBName = cszConnect_s;
gencm.pszApplicationName = NULL;
gencm.pszUserID = cu_dbvi__szUserName;
gencm.pszPassword = cu_dbvi__szPassword;
gencm.pszNewPassword = (strlen(cu_dbvi__szNewPassword) ?
cu_dbvi__szNewPassword : NULL);
gencm.pszProxyID = NULL;
gencm.pszProxyScope = NULL;
gencm.fSession = SIM_SS_NORMAL;
gencm.pAsyncCtl = NULL;
lstat = u_generic_cm_call(L"Logon", &gencm, &rc); <--- function that
that is setup to be the pointer to the address in the dll - The first
value is a Tag the second is the structure I am having trouble passing
and the third is a structure that should be passed back
C DLL
struct GENERICCM gencm; <---- identical to the structure that is
passed so that it can be recieved properly
u_dll_generic_cm_call(Tag, gencm, pRC) <-- function that has an
address pointed to it in the C program
if(!wcscmp(Tag,L"Logon"))
{
l_stat = SimLibLogon( gencm.pszDBName, gencm.pszApplicationName,
gencm.pszUserID, gencm.pszPassword, gencm.pszNewPassword,
gencm.pszProxyID, gencm.pszProxyScope, gencm.fSession, gencm.pAsyncCtl,
pRC );
}
As I said I am not sure If I have to do something special to pass the
data. If that is the case can someone enlighten me? Also will I run
into the same problem with the return structure?
Thanks for your help
Jake
program.
In my exe I first get a a pointer to the address of the function by
using GetProcAddress and on the dll side I make sure that my function
is being exported by adding a line to the .def file.
This seems to work because when I debug it recognizes the dll and once
it hits the function it goes right into the proper location of the dll.
The problem that I am having is that the function passes a structure as
part of it's three parameters. The structure appears to have all the
correct data in in while its in the main c program. However once it
goes over to the dll the structure no longer has the proper data in it.
It's almost like it was corrupted. What I find odd is that I am
passing a Tag as one of the parameters and that seems to make it over
fine. Can someone tell me what I am doing wrong? My understanding of
GetProcAddress is that once it gets a pointer to the address that it's
just like going from one function to another within the same project.
Of course I could have that misunderstood. Any help would be
appreciated. Below is a sample of my code.
C program
static GENERICCM gencm;
gencm.pszDBName = cszConnect_s;
gencm.pszApplicationName = NULL;
gencm.pszUserID = cu_dbvi__szUserName;
gencm.pszPassword = cu_dbvi__szPassword;
gencm.pszNewPassword = (strlen(cu_dbvi__szNewPassword) ?
cu_dbvi__szNewPassword : NULL);
gencm.pszProxyID = NULL;
gencm.pszProxyScope = NULL;
gencm.fSession = SIM_SS_NORMAL;
gencm.pAsyncCtl = NULL;
lstat = u_generic_cm_call(L"Logon", &gencm, &rc); <--- function that
that is setup to be the pointer to the address in the dll - The first
value is a Tag the second is the structure I am having trouble passing
and the third is a structure that should be passed back
C DLL
struct GENERICCM gencm; <---- identical to the structure that is
passed so that it can be recieved properly
u_dll_generic_cm_call(Tag, gencm, pRC) <-- function that has an
address pointed to it in the C program
if(!wcscmp(Tag,L"Logon"))
{
l_stat = SimLibLogon( gencm.pszDBName, gencm.pszApplicationName,
gencm.pszUserID, gencm.pszPassword, gencm.pszNewPassword,
gencm.pszProxyID, gencm.pszProxyScope, gencm.fSession, gencm.pAsyncCtl,
pRC );
}
As I said I am not sure If I have to do something special to pass the
data. If that is the case can someone enlighten me? Also will I run
into the same problem with the return structure?
Thanks for your help
Jake