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.

173 lines
3.2 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. FileEnumInitialize ();
  82. IsmGetTempDirectory (memDbDir, ARRAYSIZE (memDbDir));
  83. if (!MemDbInitializeEx (memDbDir)) {
  84. DEBUGMSG ((DBG_ERROR, "Failing to initialize unc transports because MemDb failed to initialize"));
  85. IsmSetCancel();
  86. return FALSE;
  87. }
  88. InfGlobalInit (FALSE);
  89. return TRUE;
  90. }
  91. EXPORT
  92. VOID
  93. WINAPI
  94. ModuleTerminate (
  95. VOID
  96. )
  97. {
  98. InfGlobalInit (TRUE);
  99. MemDbTerminateEx (TRUE);
  100. FileEnumTerminate ();
  101. UtTerminate ();
  102. }
  103. BOOL
  104. WINAPI
  105. pFindModule (
  106. IN PCTSTR ModuleId,
  107. OUT PVOID IsmBuffer,
  108. IN PCTSTR *TableEntry,
  109. IN UINT StructureSize
  110. )
  111. {
  112. while (*TableEntry) {
  113. if (StringIMatch (*TableEntry, ModuleId)) {
  114. CopyMemory (
  115. IsmBuffer,
  116. (PBYTE) (TableEntry + 1),
  117. StructureSize
  118. );
  119. return TRUE;
  120. }
  121. TableEntry = (PCTSTR *) ((PBYTE) (TableEntry + 1) + StructureSize);
  122. }
  123. return FALSE;
  124. }
  125. EXPORT
  126. BOOL
  127. WINAPI
  128. TransportModule (
  129. IN PCTSTR ModuleId,
  130. IN OUT PTRANSPORT_ENTRYPOINTS TransportEntryPoints
  131. )
  132. {
  133. return pFindModule (
  134. ModuleId,
  135. (PVOID) TransportEntryPoints,
  136. (PCTSTR *) g_TransportEntryPoints,
  137. sizeof (TRANSPORT_ENTRYPOINTS)
  138. );
  139. }