Windows NT 4.0 source code leak
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.

87 lines
2.2 KiB

4 years ago
  1. "/*\n\
  2. ** Wrapper.C\n\
  3. **\n\
  4. ** Wrapper Internals\n\
  5. **\n\
  6. ** This helps Wrapper work. DO NOT MODIFY!!!\n\
  7. **\n\
  8. ** Copyright(C) 1994 Microsoft Corporation\n\
  9. ** All rights reserved.\n\
  10. **\n\
  11. */\n\
  12. #include <windows.h>\n\
  13. #include \"wrapper.h\"\n\
  14. #include \"wapi.h\"\n\
  15. \n\
  16. /* API Adresses */\n\
  17. FARPROC adwAPIAddress[WRAPPER_MAX_ID] ;\n\
  18. \n\
  19. /* CALLSTACK */\n\
  20. typedef struct _callstack {\n\
  21. \tDWORD dwReturnAddress ;\n\
  22. \tBYTE abArgs[1] ;\n\
  23. } CALLSTACK, *PCALLSTACK ;\n\
  24. \n\
  25. /* API Data Stack */\n\
  26. typedef struct _apidatastack {\n\
  27. \tWORD\t\twTop ;\n\
  28. \tAPICALLDATA aStackEntries[MAX_WRAPPER_LEVEL] ;\n\
  29. } APIDATASTACK, *PAPIDATASTACK ;\n\
  30. \n\
  31. /* Prototypes */\n\
  32. BOOL WINAPI _WrapperDLLInit( HINSTANCE hInst, DWORD dwReason, LPVOID lpRes ) ;\n\
  33. FARPROC\t _prelude( DWORD dwId, PCALLSTACK pStack ) ;\n\
  34. RETVAL\t\t_postlude( RETVAL Ret, PDWORD pdwReturnAddress ) ;\n\
  35. BOOL WINAPI WrapperNothing(void) ;\n\
  36. \n\
  37. /* Stack routine prototypes */\n\
  38. BOOL\t\tInitStack() ;\n\
  39. void\t\tFreeStack() ;\n\
  40. void\t\tPushStack( PAPICALLDATA pData ) ;\n\
  41. void\t\tPopStack( PAPICALLDATA pData ) ;\n\
  42. DWORD\t\tGetStackDepth() ;\n\
  43. \n\
  44. /* For profiled library */\n\
  45. HMODULE hMod = NULL ;\n\
  46. \n\
  47. /* Process instance thread data */\n\
  48. static DWORD dwTlsIndex;\n\
  49. \n\
  50. /*\n\
  51. ** _WrapperDLLInit\n\
  52. **\tDLL Init routine.\n\
  53. */\n\
  54. BOOL WINAPI _WrapperDLLInit( HINSTANCE hInst, DWORD dwReason, LPVOID lpRes ) {\n\
  55. \tint\t i ;\n\
  56. \tFARPROC fp ;\n\
  57. \n\
  58. \tswitch ( dwReason ) {\n\
  59. \t case DLL_PROCESS_ATTACH:\n\
  60. \t\t /* For each entry in the names table find it's address and\n\
  61. \t\t ** enter it into dwAPIAddress.\n\
  62. \t\t */\n\
  63. \t\t if( !hMod )\n\
  64. \t\t\thMod = LoadLibrary( pLibraryName ) ;\n\
  65. \n\
  66. \t\t if( NULL == hMod )\n\
  67. \t\t\treturn FALSE ;\n\
  68. \n\
  69. \t\t for( i=0; i < API_COUNT; i++ )\n\
  70. \t\t\tadwAPIAddress[i] = (FARPROC)GetProcAddress( hMod, apAPINames[i] ) ;\n\
  71. \n\
  72. \t\t adwAPIAddress[API_COUNT] = (FARPROC)&WrapperNothing ;\n\
  73. \n\
  74. \t\t if ((dwTlsIndex = TlsAlloc()) == 0xFFFFFFFF)\n\
  75. \t\t\treturn FALSE;\n\
  76. \t\t // Fall through to DLL_THREAD_ATTACH\n\
  77. \n\
  78. \t case DLL_THREAD_ATTACH:\n\
  79. \t\t if( !InitStack() )\n\
  80. \t\t\treturn FALSE ;\n\
  81. \t\t break ;\n\
  82. \n\
  83. \t case DLL_THREAD_DETACH:\n\
  84. \t\t FreeStack() ;\n\
  85. \t\t break ;\n\
  86. \n"