Source code of Windows XP (NT5)
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.

378 lines
8.3 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, NONOTIFY
  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. FileEnumInitialize ();
  183. RegInitialize (); // for accessibility and ras
  184. InfGlobalInit (FALSE); // for os files
  185. IsmGetTempDirectory (memDbDir, ARRAYSIZE (memDbDir));
  186. if (!MemDbInitializeEx (memDbDir)) {
  187. DEBUGMSG ((DBG_ERROR, "Failing to initialize unc transports because MemDb failed to initialize"));
  188. IsmSetCancel();
  189. return FALSE;
  190. }
  191. #define DEFMAC(prefix) if (!prefix##Initialize()) return FALSE;
  192. MODULE_LIST
  193. #undef DEFMAC
  194. return TRUE;
  195. }
  196. EXPORT
  197. VOID
  198. WINAPI
  199. ModuleTerminate (
  200. VOID
  201. )
  202. {
  203. #define DEFMAC(prefix) prefix##Terminate();
  204. MODULE_LIST
  205. #undef DEFMAC
  206. InfGlobalInit (TRUE);
  207. RegTerminate ();
  208. MemDbTerminateEx (TRUE);
  209. FileEnumTerminate ();
  210. UtTerminate ();
  211. }
  212. BOOL
  213. WINAPI
  214. pFindModule (
  215. IN PCTSTR ModuleId,
  216. OUT PVOID IsmBuffer,
  217. IN PCTSTR *TableEntry,
  218. IN UINT StructureSize
  219. )
  220. {
  221. while (*TableEntry) {
  222. if (StringIMatch (*TableEntry, ModuleId)) {
  223. CopyMemory (
  224. IsmBuffer,
  225. (PBYTE) (TableEntry + 1),
  226. StructureSize
  227. );
  228. return TRUE;
  229. }
  230. TableEntry = (PCTSTR *) ((PBYTE) (TableEntry + 1) + StructureSize);
  231. }
  232. return FALSE;
  233. }
  234. EXPORT
  235. BOOL
  236. WINAPI
  237. TypeModule (
  238. IN PCTSTR ModuleId,
  239. IN OUT PTYPE_ENTRYPOINTS TypeEntryPoints
  240. )
  241. {
  242. return pFindModule (
  243. ModuleId,
  244. (PVOID) TypeEntryPoints,
  245. (PCTSTR *) g_EtmEntryPoints,
  246. sizeof (TYPE_ENTRYPOINTS)
  247. );
  248. }
  249. EXPORT
  250. BOOL
  251. WINAPI
  252. VirtualComputerModule (
  253. IN PCTSTR ModuleId,
  254. IN OUT PVIRTUAL_COMPUTER_ENTRYPOINTS VirtualComputerEntryPoints
  255. )
  256. {
  257. return pFindModule (
  258. ModuleId,
  259. (PVOID) VirtualComputerEntryPoints,
  260. (PCTSTR *) g_VcmEntryPoints,
  261. sizeof (VIRTUAL_COMPUTER_ENTRYPOINTS)
  262. );
  263. }
  264. EXPORT
  265. BOOL
  266. WINAPI
  267. SourceModule (
  268. IN PCTSTR ModuleId,
  269. IN OUT PSOURCE_ENTRYPOINTS SourceEntryPoints
  270. )
  271. {
  272. return pFindModule (
  273. ModuleId,
  274. (PVOID) SourceEntryPoints,
  275. (PCTSTR *) g_SourceEntryPoints,
  276. sizeof (SOURCE_ENTRYPOINTS)
  277. );
  278. }
  279. EXPORT
  280. BOOL
  281. WINAPI
  282. DestinationModule (
  283. IN PCTSTR ModuleId,
  284. IN OUT PDESTINATION_ENTRYPOINTS DestinationEntryPoints
  285. )
  286. {
  287. return pFindModule (
  288. ModuleId,
  289. (PVOID) DestinationEntryPoints,
  290. (PCTSTR *) g_DestinationEntryPoints,
  291. sizeof (DESTINATION_ENTRYPOINTS)
  292. );
  293. }