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.

215 lines
3.9 KiB

  1. /*++
  2. Copyright (c) 1999 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 "v1p.h"
  15. typedef struct {
  16. PCTSTR Name;
  17. TYPE_ENTRYPOINTS EntryPoints;
  18. } ETM_TABLE, *PETM_TABLE;
  19. typedef struct {
  20. PCTSTR Name;
  21. VIRTUAL_COMPUTER_ENTRYPOINTS EntryPoints;
  22. } VCM_TABLE, *PVCM_TABLE;
  23. typedef struct {
  24. PCTSTR Name;
  25. SOURCE_ENTRYPOINTS EntryPoints;
  26. } SOURCE_TABLE, *PSOURCE_TABLE;
  27. typedef struct {
  28. PCTSTR Name;
  29. DESTINATION_ENTRYPOINTS EntryPoints;
  30. } DESTINATION_TABLE, *PDESTINATION_TABLE;
  31. //
  32. // Add an entry for each ETM module in the DLL
  33. //
  34. ETM_TABLE g_EtmEntryPoints[] = {
  35. { TEXT("SCRIPT"), ISM_VERSION,
  36. ScriptEtmInitialize, ScriptEtmParse, ScriptEtmTerminate, NULL
  37. },
  38. {NULL}
  39. };
  40. //
  41. // Add an entry for each VCM module in the DLL
  42. //
  43. VCM_TABLE g_VcmEntryPoints[] = {
  44. { TEXT("SCRIPT"), ISM_VERSION,
  45. ScriptVcmInitialize, ScriptVcmParse, ScriptVcmQueueEnumeration, NULL, ScriptTerminate
  46. },
  47. {NULL}
  48. };
  49. //
  50. // Add an entry for each source module in the DLL
  51. //
  52. SOURCE_TABLE g_SourceEntryPoints[] = {
  53. { TEXT("SCRIPT"), ISM_VERSION,
  54. ScriptSgmInitialize, ScriptSgmParse, ScriptSgmQueueEnumeration, NULL, (PSGMTERMINATE) ScriptTerminate,
  55. NULL, NULL, NULL, NULL
  56. },
  57. {NULL}
  58. };
  59. //
  60. // Add an entry for each destination module in the DLL
  61. //
  62. DESTINATION_TABLE g_DestinationEntryPoints[] = {
  63. { TEXT("SCRIPT"), ISM_VERSION,
  64. ScriptDgmInitialize, ScriptDgmQueueEnumeration, NULL, NULL,
  65. NULL, NULL, NULL, NULL,
  66. ScriptCsmInitialize, ScriptCsmExecute, NULL, ScriptCsmTerminate,
  67. ScriptOpmInitialize, ScriptOpmTerminate
  68. },
  69. {NULL}
  70. };
  71. EXPORT
  72. BOOL
  73. WINAPI
  74. DllMain (
  75. IN HINSTANCE hInstance,
  76. IN DWORD dwReason,
  77. IN LPVOID lpReserved
  78. )
  79. {
  80. if (dwReason == DLL_PROCESS_ATTACH) {
  81. g_hInst = hInstance;
  82. }
  83. return TRUE;
  84. }
  85. BOOL
  86. WINAPI
  87. pFindModule (
  88. IN PCTSTR ModuleId,
  89. OUT PVOID IsmBuffer,
  90. IN PCTSTR *TableEntry,
  91. IN UINT StructureSize
  92. )
  93. {
  94. while (*TableEntry) {
  95. if (StringIMatch (*TableEntry, ModuleId)) {
  96. CopyMemory (
  97. IsmBuffer,
  98. (PBYTE) (TableEntry + 1),
  99. StructureSize
  100. );
  101. return TRUE;
  102. }
  103. TableEntry = (PCTSTR *) ((PBYTE) (TableEntry + 1) + StructureSize);
  104. }
  105. return FALSE;
  106. }
  107. EXPORT
  108. BOOL
  109. WINAPI
  110. TypeModule (
  111. IN PCTSTR ModuleId,
  112. IN OUT PTYPE_ENTRYPOINTS TypeEntryPoints
  113. )
  114. {
  115. return pFindModule (
  116. ModuleId,
  117. (PVOID) TypeEntryPoints,
  118. (PCTSTR *) g_EtmEntryPoints,
  119. sizeof (TYPE_ENTRYPOINTS)
  120. );
  121. }
  122. EXPORT
  123. BOOL
  124. WINAPI
  125. VirtualComputerModule (
  126. IN PCTSTR ModuleId,
  127. IN OUT PVIRTUAL_COMPUTER_ENTRYPOINTS VirtualComputerEntryPoints
  128. )
  129. {
  130. return pFindModule (
  131. ModuleId,
  132. (PVOID) VirtualComputerEntryPoints,
  133. (PCTSTR *) g_VcmEntryPoints,
  134. sizeof (VIRTUAL_COMPUTER_ENTRYPOINTS)
  135. );
  136. }
  137. EXPORT
  138. BOOL
  139. WINAPI
  140. SourceModule (
  141. IN PCTSTR ModuleId,
  142. IN OUT PSOURCE_ENTRYPOINTS SourceEntryPoints
  143. )
  144. {
  145. return pFindModule (
  146. ModuleId,
  147. (PVOID) SourceEntryPoints,
  148. (PCTSTR *) g_SourceEntryPoints,
  149. sizeof (SOURCE_ENTRYPOINTS)
  150. );
  151. }
  152. EXPORT
  153. BOOL
  154. WINAPI
  155. DestinationModule (
  156. IN PCTSTR ModuleId,
  157. IN OUT PDESTINATION_ENTRYPOINTS DestinationEntryPoints
  158. )
  159. {
  160. return pFindModule (
  161. ModuleId,
  162. (PVOID) DestinationEntryPoints,
  163. (PCTSTR *) g_DestinationEntryPoints,
  164. sizeof (DESTINATION_ENTRYPOINTS)
  165. );
  166. }