Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.6 KiB

  1. #define MODULE_TEMPLATE2(mod, fname) \
  2. \
  3. \
  4. static HMODULE hMod = NULL; \
  5. static PROCDATA *pList = NULL; \
  6. \
  7. static TCHAR szMod[] = TEXT( #fname ); \
  8. \
  9. void __ ## mod ## dynlink(PROCDATA *p) \
  10. { \
  11. PROCDATA *head; \
  12. \
  13. if (!hMod) { \
  14. UINT errmode = SetErrorMode(SEM_NOOPENFILEERRORBOX \
  15. | SEM_FAILCRITICALERRORS); \
  16. hMod = LoadLibrary(szMod); \
  17. SetErrorMode(errmode); \
  18. } \
  19. if (hMod) { \
  20. if (p->ord) \
  21. p->fp = GetProcAddress(hMod, (LPCSTR)(p->ord)); \
  22. else \
  23. p->fp = GetProcAddress(hMod, p->name); \
  24. } \
  25. if (p->fp) { \
  26. head = pList; \
  27. pList = p; \
  28. p->next = head; \
  29. } \
  30. } \
  31. \
  32. void __ ## mod ## unlink(void) \
  33. { \
  34. if (hMod) { \
  35. FreeLibrary(hMod); \
  36. hMod = NULL; \
  37. \
  38. while(pList) { \
  39. PROCDATA *head; \
  40. pList->fp = NULL; \
  41. head = pList->next; \
  42. pList->next = NULL; \
  43. pList = head; \
  44. } \
  45. } \
  46. } \
  47. \
  48. void _Unlink ## mod(void) {__ ## mod ## unlink();}
  49. #define MODULE_TEMPLATE(mod, fname) MODULE_TEMPLATE2(mod, fname)
  50.