Advertisement
dllbridge

Untitled

Dec 1st, 2023
808
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1.  
  2.  
  3. /*
  4. 0) extern "C" __declspec(dllexport)
  5.    - - - - - - - - - - - - - - - - -
  6. 1) int (*_rr)();
  7. 2) HMODULE  hDll = 0;
  8. 3) hDll = LoadLibrary("dll/for.dll");
  9. 4) _rr = (int(*)())GetProcAddress(hDll, "_rr");
  10. 5) FreeLibrary(hDll);
  11. */
  12.  
  13.  
  14.  
  15.  
  16.  
  17. #include     <stdio.h>
  18. #include   <windows.h>
  19.  
  20.  
  21.  
  22. HMODULE  hDll = 0;
  23.  
  24.  
  25. int (*_foo)(int n);
  26.  
  27.  
  28.  
  29.  
  30. ////////////////////////////////////////////////////
  31. int main()                                        //
  32. {
  33.  
  34.     hDll = LoadLibrary("F_dll/my.dll");
  35.  
  36.     printf("%d\n", hDll);
  37.    
  38.    _foo = (int(*)(int))GetProcAddress(hDll, "_foo");
  39.  
  40.     printf("_foo = %d\n", _foo);
  41.  
  42.     int nRes = _foo(2);
  43.    
  44.     printf("foo return %d", nRes);
  45.    
  46.    
  47.     FreeLibrary(hDll);
  48. }
  49.  
  50.  
  51.  
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement