-
July 26th, 2004, 03:28 AM
#1
Load DLL
I am hoping someone can help me .
I want to use some functions from system DLL,"rsaenh.dll",
but there are no exported functions from the DLL when main app performs a LoadLibrary on the DLL,(dynamic import),
there are some codes I want to use the CPAcquirecontext() from rsaenh.dll)
typedef BOOL (WINAPI * CPAcquireContext_DLL)(OUT HCRYPTPROV *phProv, IN LPCSTR szContainer, IN DWORD dwFlags , IN PVTableProvStruc pVTable);
_declspec(dllimport) BOOL WINAPI CPAcquireContext(OUT HCRYPTPROV *phProv, IN LPCSTR szContainer, IN DWORD dwFlags, IN PVTableProvStruc pVTable);
HINSTANCE hmod;
hmod = ::LoadLibrary ("c:\\windows\\system32\\rsaenh.dll");
if(hmod==NULL)
{
AfxMessageBox("Fail");
}
CPAcquireContext_DLL *lpproc;
lpproc = (CPAcquireContext_DLL*)GetProcAddress (hmod,"CPAcquireContext");
PVTableProvStruc pvTable=new VTableProvStruc;
pvTable->Version=3;
pvTable->FuncVerifyImage=(FARPROC ) (ProvVerifyImage);
pvTable->FuncReturnhWnd=NULL;
pvTable->dwProvType=PROV_RSA_FULL;
pvTable->pbContextInfo=NULL;
pvTable->cbContextInfo=0;
if((*lpproc)(&hCryptProv, NULL, 0, pvTable))
{
printf("A cryptographic provider has been acquired. \n");
}
else
{
if((*lpproc)(&hCryptProv, NULL, CRYPT_NEWKEYSET, pvTable))
{
printf("A new key container has been created.\n");
}
else
{
HandleError("Could not create a new key container.\n");
}
}
I find that it fails during the((*lpproc)(&hCryptProv, NULL, 0, pvTable)) call. It seems that it can not call the function.
Is there something that I don't know about loading DLL?
or can not load rsaenh.dll?
Thanks for the advice
-
July 26th, 2004, 04:03 AM
#2
Originally Posted by lfcgz
I am hoping someone can help me .
I want to use some functions from system DLL,"rsaenh.dll",
but there are no exported functions from the DLL when main app performs a LoadLibrary on the DLL,(dynamic import),
there are some codes I want to use the CPAcquirecontext() from rsaenh.dll)
typedef BOOL (WINAPI * CPAcquireContext_DLL)(OUT HCRYPTPROV *phProv, IN LPCSTR szContainer, IN DWORD dwFlags , IN PVTableProvStruc pVTable);
_declspec(dllimport) BOOL WINAPI CPAcquireContext(OUT HCRYPTPROV *phProv, IN LPCSTR szContainer, IN DWORD dwFlags, IN PVTableProvStruc pVTable);
HINSTANCE hmod;
hmod = ::LoadLibrary ("c:\\windows\\system32\\rsaenh.dll");
if(hmod==NULL)
{
AfxMessageBox("Fail");
}
CPAcquireContext_DLL *lpproc;
lpproc = (CPAcquireContext_DLL*)GetProcAddress (hmod,"CPAcquireContext");
PVTableProvStruc pvTable=new VTableProvStruc;
pvTable->Version=3;
pvTable->FuncVerifyImage=(FARPROC ) (ProvVerifyImage);
pvTable->FuncReturnhWnd=NULL;
pvTable->dwProvType=PROV_RSA_FULL;
pvTable->pbContextInfo=NULL;
pvTable->cbContextInfo=0;
if((*lpproc)(&hCryptProv, NULL, 0, pvTable))
{
printf("A cryptographic provider has been acquired. \n");
}
else
{
if((*lpproc)(&hCryptProv, NULL, CRYPT_NEWKEYSET, pvTable))
{
printf("A new key container has been created.\n");
}
else
{
HandleError("Could not create a new key container.\n");
}
}
I find that it fails during the((*lpproc)(&hCryptProv, NULL, 0, pvTable)) call. It seems that it can not call the function.
Is there something that I don't know about loading DLL?
or can not load rsaenh.dll?
Thanks for the advice
First of all USE CODE TAGS plz.
Secondly check if the return of GetProcAddress is NULL or something valid.
Lastly call it like
Code:
if( !lpproc(&hCryptProv, NULL, 0, pvTable) )
{
// Error...
}
else
{
// Success...
}
Hope this helps,
Regards,
Usman.
-
July 26th, 2004, 04:15 AM
#3
try the following and post the results.
Code:
HINSTANCE hInstance = LoadLibrary("c:\\windows\\system32\\rsaenh.dll");
if (!hInstance)
AfxMessageBox("The .dll library could not be loaded!");
BOOL (*pFunction)(HCRYPTPROV *, CHAR *, DWORD, PVTableProvStruc);
pFunction = (BOOL (*)(HCRYPTPROV *, CHAR *, DWORD, PVTableProvStruc)) GetProcAddress(hInstance, "CPAcquireContext");
if (!pFunction)
AfxMessageBox("The function \"CPAcquireContext\" could not be found!");
// call the function
//(*pFunction)(HCRYPTPROV *, CHAR *, DWORD, PVTableProvStruc);
-
July 26th, 2004, 04:21 AM
#4
Bah, Alin beat it to me.
Need help with anything related to audio programming? I can help!
-
July 26th, 2004, 04:25 AM
#5
Originally Posted by Ness
Bah, Alin beat it to me.
i did what ?
-
July 26th, 2004, 04:27 AM
#6
Originally Posted by Alin
i did what ?
I was about to post similar code, but you posted right before I did.
Need help with anything related to audio programming? I can help!
-
July 26th, 2004, 04:29 AM
#7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|