I'm tasked with integrating my code with a
company using the Cygnus C compiler. I've got the correct runtime set up
for crypto.dll but I can't seem to get the calling conventions right to call the
SHA function. The code I'm supposed to compile has a single call to the
SHA function in crypto.dll. Seems like I should be able to just load the
dll dynamically and call it. Can anyone see what I'm doing wrong in the
code below?
// Explicitly Load
Library
HINSTANCE loadRet=AfxLoadLibrary("crypto.dll"); if (loadRet==NULL) cout << "load failed"; FARPROC getRet=GetProcAddress(loadRet,
"SHA1");
if (getRet==NULL) cout << "get failed"; // typedef used for casting function pointer to match signature of SHA // based on the following declaration in sha.h // unsigned char *SHA(const unsigned char *d, unsigned long n,unsigned char *md); typedef unsigned char * (FAR WINAPI *TYPESHA)(const unsigned char *, unsigned long, unsigned char *); TYPESHA
fpSha=(TYPESHA)getRet;
// function crashes on this line unsigned char *retSha= fpSha((unsigned char *)texttosign, (unsigned long)strlen(texttosign), NULL); //Explicitly unload library AfxFreeLibrary(loadRet); |