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.

171 lines
3.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 "unctrans.h"
  15. typedef struct {
  16. PCTSTR Name;
  17. TRANSPORT_ENTRYPOINTS EntryPoints;
  18. } TRANSPORT_TABLE, *PTRANSPORT_TABLE;
  19. #define NOPROGBAR NULL
  20. #define NORESET NULL
  21. #define NORESUME NULL
  22. //
  23. // Add an entry for each transport module in the DLL
  24. //
  25. TRANSPORT_TABLE g_TransportEntryPoints[] = {
  26. { TEXT("INF_BASED_UNC_TRANSPORT"), ISM_VERSION,
  27. InfTransTransportInitialize,
  28. InfTransTransportEstimateProgressBar,
  29. InfTransTransportQueryCapabilities,
  30. InfTransTransportSetStorage,
  31. NORESET,
  32. InfTransTransportTerminate,
  33. InfTransTransportSaveState,
  34. NORESUME,
  35. InfTransTransportBeginApply,
  36. NORESUME,
  37. InfTransTransportAcquireObject,
  38. InfTransTransportReleaseObject,
  39. InfTransTransportEndApply
  40. },
  41. { TEXT("OPAQUE_UNC_TRANSPORT"), ISM_VERSION,
  42. OpaqueTransportInitialize,
  43. OpaqueTransportEstimateProgressBar,
  44. OpaqueTransportQueryCapabilities,
  45. OpaqueTransportSetStorage,
  46. NORESET,
  47. OpaqueTransportTerminate,
  48. OpaqueTransportSaveState,
  49. NORESUME,
  50. OpaqueTransportBeginApply,
  51. NORESUME,
  52. OpaqueTransportAcquireObject,
  53. OpaqueTransportReleaseObject,
  54. OpaqueTransportEndApply
  55. },
  56. {NULL}
  57. };
  58. EXPORT
  59. BOOL
  60. WINAPI
  61. DllMain (
  62. IN HINSTANCE hInstance,
  63. IN DWORD dwReason,
  64. IN LPVOID lpReserved
  65. )
  66. {
  67. if (dwReason == DLL_PROCESS_ATTACH) {
  68. g_hInst = hInstance;
  69. }
  70. return TRUE;
  71. }
  72. EXPORT
  73. BOOL
  74. WINAPI
  75. ModuleInitialize (
  76. VOID
  77. )
  78. {
  79. TCHAR memDbDir[MAX_PATH];
  80. UtInitialize (NULL);
  81. IsmGetTempDirectory (memDbDir, ARRAYSIZE (memDbDir));
  82. if (!MemDbInitializeEx (memDbDir)) {
  83. DEBUGMSG ((DBG_ERROR, "Failing to initialize unc transports because MemDb failed to initialize"));
  84. IsmSetCancel();
  85. return FALSE;
  86. }
  87. InfGlobalInit (FALSE);
  88. return TRUE;
  89. }
  90. EXPORT
  91. VOID
  92. WINAPI
  93. ModuleTerminate (
  94. VOID
  95. )
  96. {
  97. InfGlobalInit (TRUE);
  98. MemDbTerminateEx (TRUE);
  99. UtTerminate ();
  100. }
  101. BOOL
  102. WINAPI
  103. pFindModule (
  104. IN PCTSTR ModuleId,
  105. OUT PVOID IsmBuffer,
  106. IN PCTSTR *TableEntry,
  107. IN UINT StructureSize
  108. )
  109. {
  110. while (*TableEntry) {
  111. if (StringIMatch (*TableEntry, ModuleId)) {
  112. CopyMemory (
  113. IsmBuffer,
  114. (PBYTE) (TableEntry + 1),
  115. StructureSize
  116. );
  117. return TRUE;
  118. }
  119. TableEntry = (PCTSTR *) ((PBYTE) (TableEntry + 1) + StructureSize);
  120. }
  121. return FALSE;
  122. }
  123. EXPORT
  124. BOOL
  125. WINAPI
  126. TransportModule (
  127. IN PCTSTR ModuleId,
  128. IN OUT PTRANSPORT_ENTRYPOINTS TransportEntryPoints
  129. )
  130. {
  131. return pFindModule (
  132. ModuleId,
  133. (PVOID) TransportEntryPoints,
  134. (PCTSTR *) g_TransportEntryPoints,
  135. sizeof (TRANSPORT_ENTRYPOINTS)
  136. );
  137. }