daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extern "C" __declspec(dllexport) void setValue(float * a, float * b);
  2. void setValue(float * a, float * b){
  3.     printf("Enter value of a and b");
  4.     scanf("%f %f", a,b);
  5. }
  6.    
  7. typedef void (__cdecl * setValDll)(float *,float *);
  8. extern "C" __declspec(dllexport) float Add(void);
  9. float firstIp;
  10. float secondIp;
  11.  
  12. float Add(void){
  13. HMODULE  hmodule;
  14. setValDll setValDllFunc;
  15. hmodule = LoadLibrary("consoleIP.dll" );
  16.     if(hmodule == NULL){
  17.         printf("DLL load Failedn");
  18.         return 101;
  19.     }
  20.  
  21.     setValDllFunc = (setValDll)GetProcAddress(hmodule, "setValue");
  22.     setValDllFunc(&firstIp, &secondIp);
  23.    
  24. HMODULE dllModule;
  25. typedef float (__cdecl * addVal)(void);
  26. typedef void (__cdecl * setValDll)(float *,float *);
  27.  
  28. main(){
  29. addVal addFuncAddr;
  30. setValDll setValFromDll;
  31. float test1;
  32. float test2;
  33.  
  34. dllModule = LoadLibrary(calcFunc.dll");
  35. addFuncAddr = (addVal)GetProcAddress(dllModule, "Add");
  36. returnVal = addFuncAddr(); // Works fine
  37. setValFromDll = (setValDll)(dllModule,"setValue");
  38. setValFromDll(&test1, &test2); // Access Violation exception
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top