Leaked source code of windows server 2003
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.

376 lines
8.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. entry.c
  5. Abstract:
  6. Implements the DLL entry point that provides all Cobra module entry points
  7. to the engine.
  8. Author:
  9. Jim Schmidt (jimschm) 11-Aug-2000
  10. Revision History:
  11. <alias> <date> <comments>
  12. --*/
  13. #include "pch.h"
  14. #include "sysmod.h"
  15. #define NOPARSE NULL
  16. #define NOQUEUE NULL
  17. #define NOINIT NULL
  18. #define NOTERMINATE NULL
  19. #define NOHIGHPRIQUEUE NULL
  20. #define NOEXECUTE NULL
  21. #define NOPROGBAR NULL
  22. #define NONOTIFY NULL
  23. #define NO_SGM NOINIT,NOPARSE,NOQUEUE,NOHIGHPRIQUEUE,NOTERMINATE
  24. #define NO_SAM NOINIT,NOEXECUTE,NOPROGBAR,NOTERMINATE
  25. #define NO_DGM NOINIT,NOQUEUE,NOHIGHPRIQUEUE,NOTERMINATE
  26. #define NO_DAM NOINIT,NOEXECUTE,NOPROGBAR,NOTERMINATE
  27. #define NO_CSM NOINIT,NOEXECUTE,NOPROGBAR,NOTERMINATE
  28. #define NO_OPM NOINIT,NOTERMINATE
  29. typedef struct {
  30. PCTSTR Name;
  31. TYPE_ENTRYPOINTS EntryPoints;
  32. } ETM_TABLE, *PETM_TABLE;
  33. typedef struct {
  34. PCTSTR Name;
  35. VIRTUAL_COMPUTER_ENTRYPOINTS EntryPoints;
  36. } VCM_TABLE, *PVCM_TABLE;
  37. typedef struct {
  38. PCTSTR Name;
  39. SOURCE_ENTRYPOINTS EntryPoints;
  40. } SOURCE_TABLE, *PSOURCE_TABLE;
  41. typedef struct {
  42. PCTSTR Name;
  43. DESTINATION_ENTRYPOINTS EntryPoints;
  44. } DESTINATION_TABLE, *PDESTINATION_TABLE;
  45. //
  46. // Add an entry for each ETM module in the DLL
  47. //
  48. ETM_TABLE g_EtmEntryPoints[] = {
  49. { TEXT("ACCESSIBILITY"), ISM_VERSION,
  50. AccessibilityEtmInitialize, NOPARSE, NOTERMINATE, NONOTIFY
  51. },
  52. { TEXT("COOKIES"), ISM_VERSION,
  53. CookiesEtmInitialize, NOPARSE, NOTERMINATE, CookiesEtmNewUserCreated
  54. },
  55. { TEXT("NETDRIVES"), ISM_VERSION,
  56. NetDrivesEtmInitialize, NOPARSE, NOTERMINATE, NetDrivesEtmNewUserCreated
  57. },
  58. { TEXT("NETSHARES"), ISM_VERSION,
  59. NetSharesEtmInitialize, NOPARSE, NOTERMINATE, NONOTIFY
  60. },
  61. { TEXT("PRINTERS"), ISM_VERSION,
  62. PrintersEtmInitialize, NOPARSE, NOTERMINATE, PrintersEtmNewUserCreated
  63. },
  64. { TEXT("RAS"), ISM_VERSION,
  65. RasMigEtmInitialize, NOPARSE, NOTERMINATE, RasMigEtmNewUserCreated
  66. },
  67. {NULL}
  68. };
  69. //
  70. // Add an entry for each VCM module in the DLL
  71. //
  72. VCM_TABLE g_VcmEntryPoints[] = {
  73. { TEXT("ACCESSIBILITY"), ISM_VERSION,
  74. AccessibilitySourceInitialize, NOPARSE, NOQUEUE, NOHIGHPRIQUEUE, NOTERMINATE
  75. },
  76. { TEXT("COOKIES"), ISM_VERSION,
  77. CookiesSourceInitialize, CookiesVcmParse, CookiesVcmQueueEnumeration, NOHIGHPRIQUEUE, NOTERMINATE
  78. },
  79. { TEXT("LNKMIG"), ISM_VERSION,
  80. LnkMigVcmInitialize, NOPARSE, LnkMigVcmQueueEnumeration, NOHIGHPRIQUEUE, NOTERMINATE
  81. },
  82. { TEXT("NETDRIVES"), ISM_VERSION,
  83. NetDrivesVcmInitialize, NetDrivesVcmParse, NetDrivesVcmQueueEnumeration, NOHIGHPRIQUEUE, NOTERMINATE
  84. },
  85. { TEXT("NETSHARES"), ISM_VERSION,
  86. NetSharesVcmInitialize, NetSharesVcmParse, NetSharesVcmQueueEnumeration, NOHIGHPRIQUEUE, NOTERMINATE
  87. },
  88. { TEXT("OSFILES"), ISM_VERSION,
  89. OsFilesVcmInitialize, NOPARSE, OsFilesVcmQueueEnumeration, OsFilesVcmQueueHighPriorityEnumeration, NOTERMINATE
  90. },
  91. { TEXT("PRINTERS"), ISM_VERSION,
  92. PrintersVcmInitialize, PrintersVcmParse, PrintersVcmQueueEnumeration, NOHIGHPRIQUEUE, NOTERMINATE
  93. },
  94. { TEXT("RAS"), ISM_VERSION,
  95. RasMigVcmInitialize, RasMigVcmParse, RasMigVcmQueueEnumeration, NOHIGHPRIQUEUE, NOTERMINATE
  96. },
  97. {NULL}
  98. };
  99. //
  100. // Add an entry for each source module in the DLL
  101. //
  102. SOURCE_TABLE g_SourceEntryPoints[] = {
  103. { TEXT("ACCESSIBILITY"), ISM_VERSION,
  104. (PSGMINITIALIZE) AccessibilitySourceInitialize, NOPARSE, NOQUEUE, NOHIGHPRIQUEUE, NOTERMINATE,
  105. NO_SAM
  106. },
  107. { TEXT("COOKIES"), ISM_VERSION,
  108. (PSGMINITIALIZE) CookiesSourceInitialize, CookiesSgmParse, CookiesSgmQueueEnumeration, NOHIGHPRIQUEUE, NOTERMINATE,
  109. NO_SAM
  110. },
  111. { TEXT("LNKMIG"), ISM_VERSION,
  112. LnkMigSgmInitialize, NOPARSE, LnkMigSgmQueueEnumeration, NOHIGHPRIQUEUE, NOTERMINATE,
  113. NO_SAM
  114. },
  115. { TEXT("NETDRIVES"), ISM_VERSION,
  116. NetDrivesSgmInitialize, NetDrivesSgmParse, NetDrivesSgmQueueEnumeration, NOHIGHPRIQUEUE, NOTERMINATE,
  117. NO_SAM
  118. },
  119. { TEXT("NETSHARES"), ISM_VERSION,
  120. NetSharesSgmInitialize, NetSharesSgmParse, NetSharesSgmQueueEnumeration, NOHIGHPRIQUEUE, NOTERMINATE,
  121. NO_SAM
  122. },
  123. { TEXT("OSFILES"), ISM_VERSION,
  124. OsFilesSgmInitialize, NOPARSE, OsFilesSgmQueueEnumeration, OsFilesSgmQueueHighPriorityEnumeration, NOTERMINATE,
  125. NO_SAM
  126. },
  127. { TEXT("PRINTERS"), ISM_VERSION,
  128. PrintersSgmInitialize, PrintersSgmParse, PrintersSgmQueueEnumeration, NOHIGHPRIQUEUE, NOTERMINATE,
  129. NO_SAM
  130. },
  131. { TEXT("RAS"), ISM_VERSION,
  132. RasMigSgmInitialize, RasMigSgmParse, RasMigSgmQueueEnumeration, NOHIGHPRIQUEUE, NOTERMINATE,
  133. NO_SAM
  134. },
  135. {NULL}
  136. };
  137. //
  138. // Add an entry for each destination module in the DLL
  139. //
  140. DESTINATION_TABLE g_DestinationEntryPoints[] = {
  141. { TEXT("ACCESSIBILITY"), ISM_VERSION,
  142. NO_DGM, NO_DAM, NO_CSM, NO_OPM
  143. },
  144. { TEXT("LNKMIG"), ISM_VERSION,
  145. NO_DGM, NO_DAM, NO_CSM,
  146. LnkMigOpmInitialize, NOTERMINATE
  147. },
  148. { TEXT("NETDRIVES"), ISM_VERSION,
  149. NO_DGM, NO_DAM,
  150. NetDrivesCsmInitialize, NetDrivesCsmExecute, NOPROGBAR, NOTERMINATE,
  151. NetDrivesOpmInitialize, NOTERMINATE
  152. },
  153. { TEXT("RAS"), ISM_VERSION,
  154. NO_DGM, NO_DAM, NO_CSM,
  155. RasMigOpmInitialize, NOTERMINATE
  156. },
  157. {NULL}
  158. };
  159. EXPORT
  160. BOOL
  161. WINAPI
  162. DllMain (
  163. IN HINSTANCE hInstance,
  164. IN DWORD dwReason,
  165. IN LPVOID lpReserved
  166. )
  167. {
  168. if (dwReason == DLL_PROCESS_ATTACH) {
  169. g_hInst = hInstance;
  170. }
  171. return TRUE;
  172. }
  173. EXPORT
  174. BOOL
  175. WINAPI
  176. ModuleInitialize (
  177. VOID
  178. )
  179. {
  180. TCHAR memDbDir[MAX_PATH];
  181. UtInitialize (NULL);
  182. RegInitialize (); // for accessibility and ras
  183. InfGlobalInit (FALSE); // for os files
  184. IsmGetTempDirectory (memDbDir, ARRAYSIZE (memDbDir));
  185. if (!MemDbInitializeEx (memDbDir)) {
  186. DEBUGMSG ((DBG_ERROR, "Failing to initialize unc transports because MemDb failed to initialize"));
  187. IsmSetCancel();
  188. return FALSE;
  189. }
  190. #define DEFMAC(prefix) if (!prefix##Initialize()) return FALSE;
  191. MODULE_LIST
  192. #undef DEFMAC
  193. return TRUE;
  194. }
  195. EXPORT
  196. VOID
  197. WINAPI
  198. ModuleTerminate (
  199. VOID
  200. )
  201. {
  202. #define DEFMAC(prefix) prefix##Terminate();
  203. MODULE_LIST
  204. #undef DEFMAC
  205. InfGlobalInit (TRUE);
  206. RegTerminate ();
  207. MemDbTerminateEx (TRUE);
  208. UtTerminate ();
  209. }
  210. BOOL
  211. WINAPI
  212. pFindModule (
  213. IN PCTSTR ModuleId,
  214. OUT PVOID IsmBuffer,
  215. IN PCTSTR *TableEntry,
  216. IN UINT StructureSize
  217. )
  218. {
  219. while (*TableEntry) {
  220. if (StringIMatch (*TableEntry, ModuleId)) {
  221. CopyMemory (
  222. IsmBuffer,
  223. (PBYTE) (TableEntry + 1),
  224. StructureSize
  225. );
  226. return TRUE;
  227. }
  228. TableEntry = (PCTSTR *) ((PBYTE) (TableEntry + 1) + StructureSize);
  229. }
  230. return FALSE;
  231. }
  232. EXPORT
  233. BOOL
  234. WINAPI
  235. TypeModule (
  236. IN PCTSTR ModuleId,
  237. IN OUT PTYPE_ENTRYPOINTS TypeEntryPoints
  238. )
  239. {
  240. return pFindModule (
  241. ModuleId,
  242. (PVOID) TypeEntryPoints,
  243. (PCTSTR *) g_EtmEntryPoints,
  244. sizeof (TYPE_ENTRYPOINTS)
  245. );
  246. }
  247. EXPORT
  248. BOOL
  249. WINAPI
  250. VirtualComputerModule (
  251. IN PCTSTR ModuleId,
  252. IN OUT PVIRTUAL_COMPUTER_ENTRYPOINTS VirtualComputerEntryPoints
  253. )
  254. {
  255. return pFindModule (
  256. ModuleId,
  257. (PVOID) VirtualComputerEntryPoints,
  258. (PCTSTR *) g_VcmEntryPoints,
  259. sizeof (VIRTUAL_COMPUTER_ENTRYPOINTS)
  260. );
  261. }
  262. EXPORT
  263. BOOL
  264. WINAPI
  265. SourceModule (
  266. IN PCTSTR ModuleId,
  267. IN OUT PSOURCE_ENTRYPOINTS SourceEntryPoints
  268. )
  269. {
  270. return pFindModule (
  271. ModuleId,
  272. (PVOID) SourceEntryPoints,
  273. (PCTSTR *) g_SourceEntryPoints,
  274. sizeof (SOURCE_ENTRYPOINTS)
  275. );
  276. }
  277. EXPORT
  278. BOOL
  279. WINAPI
  280. DestinationModule (
  281. IN PCTSTR ModuleId,
  282. IN OUT PDESTINATION_ENTRYPOINTS DestinationEntryPoints
  283. )
  284. {
  285. return pFindModule (
  286. ModuleId,
  287. (PVOID) DestinationEntryPoints,
  288. (PCTSTR *) g_DestinationEntryPoints,
  289. sizeof (DESTINATION_ENTRYPOINTS)
  290. );
  291. }