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.

285 lines
5.3 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. osfiles.c
  5. Abstract:
  6. <abstract>
  7. Author:
  8. Calin Negreanu (calinn) 08 Mar 2000
  9. Revision History:
  10. <alias> <date> <comments>
  11. --*/
  12. //
  13. // Includes
  14. //
  15. #include "pch.h"
  16. #include "logmsg.h"
  17. #include "osfiles.h"
  18. #define DBG_OSFILES "OsFiles"
  19. //
  20. // Strings
  21. //
  22. // None
  23. //
  24. // Constants
  25. //
  26. // None
  27. //
  28. // Macros
  29. //
  30. // None
  31. //
  32. // Types
  33. //
  34. // None
  35. //
  36. // Globals
  37. //
  38. MIG_ATTRIBUTEID g_OsFileAttribute;
  39. PCTSTR g_InfPath = NULL;
  40. //
  41. // Macro expansion list
  42. //
  43. // None
  44. //
  45. // Private function prototypes
  46. //
  47. // None
  48. //
  49. // Macro expansion definition
  50. //
  51. // None
  52. //
  53. // Private prototypes
  54. //
  55. SGMENUMERATIONCALLBACK SgmOsFilesCallback;
  56. VCMENUMERATIONCALLBACK VcmOsFilesCallback;
  57. //
  58. // Code
  59. //
  60. BOOL
  61. WINAPI
  62. OsFilesSgmInitialize (
  63. IN PMIG_LOGCALLBACK LogCallback,
  64. IN PVOID Reserved
  65. )
  66. {
  67. HINF infHandle;
  68. UINT sizeNeeded;
  69. ENVENTRY_TYPE dataType;
  70. LogReInit (NULL, NULL, NULL, (PLOGCALLBACK) LogCallback);
  71. g_OsFileAttribute = IsmRegisterAttribute (S_ATTRIBUTE_OSFILE, FALSE);
  72. if (IsmGetEnvironmentValue (
  73. IsmGetRealPlatform (),
  74. NULL,
  75. S_GLOBAL_INF_HANDLE,
  76. (PBYTE)(&infHandle),
  77. sizeof (HINF),
  78. &sizeNeeded,
  79. &dataType
  80. ) &&
  81. (sizeNeeded == sizeof (HINF)) &&
  82. (dataType == ENVENTRY_BINARY)
  83. ) {
  84. if (!InitMigDbEx (infHandle)) {
  85. DEBUGMSG((DBG_ERROR, "Error initializing OsFiles database"));
  86. return FALSE;
  87. }
  88. }
  89. return TRUE;
  90. }
  91. BOOL
  92. WINAPI
  93. OsFilesSgmQueueEnumeration (
  94. IN PVOID Reserved
  95. )
  96. {
  97. ENCODEDSTRHANDLE pattern;
  98. pattern = IsmCreateSimpleObjectPattern (NULL, TRUE, NULL, TRUE);
  99. IsmHookEnumeration (MIG_FILE_TYPE, pattern, SgmOsFilesCallback, (ULONG_PTR) 0, TEXT("OsFiles"));
  100. IsmDestroyObjectHandle (pattern);
  101. return TRUE;
  102. }
  103. BOOL
  104. WINAPI
  105. OsFilesSgmQueueHighPriorityEnumeration (
  106. IN PVOID Reserved
  107. )
  108. {
  109. ENCODEDSTRHANDLE pattern;
  110. pattern = IsmCreateSimpleObjectPattern (NULL, TRUE, NULL, TRUE);
  111. IsmHookEnumeration (MIG_FILE_TYPE, pattern, SgmOsFilesCallback, (ULONG_PTR) 0, TEXT("OsFiles"));
  112. IsmDestroyObjectHandle (pattern);
  113. return TRUE;
  114. }
  115. UINT
  116. SgmOsFilesCallback (
  117. PCMIG_OBJECTENUMDATA Data,
  118. ULONG_PTR CallerArg
  119. )
  120. {
  121. FILE_HELPER_PARAMS params;
  122. params.ObjectName = Data->ObjectName;
  123. params.NativeObjectName = Data->NativeObjectName;
  124. params.Handled = FALSE;
  125. params.FindData = (PWIN32_FIND_DATA)(Data->Details.DetailsData);
  126. params.ObjectNode = Data->ObjectNode;
  127. params.ObjectLeaf = Data->ObjectLeaf;
  128. params.IsNode = Data->IsNode;
  129. params.IsLeaf = Data->IsLeaf;
  130. MigDbTestFile (&params);
  131. return CALLBACK_ENUM_CONTINUE;
  132. }
  133. BOOL
  134. WINAPI
  135. OsFilesVcmInitialize (
  136. IN PMIG_LOGCALLBACK LogCallback,
  137. IN PVOID Reserved
  138. )
  139. {
  140. HINF infHandle;
  141. UINT sizeNeeded;
  142. ENVENTRY_TYPE dataType;
  143. LogReInit (NULL, NULL, NULL, (PLOGCALLBACK) LogCallback);
  144. if (IsmGetRealPlatform () == PLATFORM_DESTINATION) {
  145. // we don't have any work to do
  146. SetLastError (ERROR_SUCCESS);
  147. return FALSE;
  148. }
  149. g_OsFileAttribute = IsmRegisterAttribute (S_ATTRIBUTE_OSFILE, FALSE);
  150. if (IsmGetEnvironmentValue (
  151. IsmGetRealPlatform (),
  152. NULL,
  153. S_GLOBAL_INF_HANDLE,
  154. (PBYTE)(&infHandle),
  155. sizeof (HINF),
  156. &sizeNeeded,
  157. &dataType
  158. ) &&
  159. (sizeNeeded == sizeof (HINF)) &&
  160. (dataType == ENVENTRY_BINARY)
  161. ) {
  162. if (!InitMigDbEx (infHandle)) {
  163. DEBUGMSG((DBG_ERROR, "Error initializing OsFiles database"));
  164. return FALSE;
  165. }
  166. }
  167. return TRUE;
  168. }
  169. BOOL
  170. WINAPI
  171. OsFilesVcmQueueEnumeration (
  172. IN PVOID Reserved
  173. )
  174. {
  175. ENCODEDSTRHANDLE pattern;
  176. pattern = IsmCreateSimpleObjectPattern (NULL, TRUE, NULL, TRUE);
  177. IsmHookEnumeration (MIG_FILE_TYPE, pattern, VcmOsFilesCallback, (ULONG_PTR) 0, TEXT("OsFiles"));
  178. IsmDestroyObjectHandle (pattern);
  179. return TRUE;
  180. }
  181. BOOL
  182. WINAPI
  183. OsFilesVcmQueueHighPriorityEnumeration (
  184. IN PVOID Reserved
  185. )
  186. {
  187. ENCODEDSTRHANDLE pattern;
  188. pattern = IsmCreateSimpleObjectPattern (NULL, TRUE, NULL, TRUE);
  189. IsmHookEnumeration (MIG_FILE_TYPE, pattern, VcmOsFilesCallback, (ULONG_PTR) 0, TEXT("OsFiles"));
  190. IsmDestroyObjectHandle (pattern);
  191. return TRUE;
  192. }
  193. UINT
  194. VcmOsFilesCallback (
  195. PCMIG_OBJECTENUMDATA Data,
  196. ULONG_PTR CallerArg
  197. )
  198. {
  199. FILE_HELPER_PARAMS params;
  200. params.ObjectName = Data->ObjectName;
  201. params.NativeObjectName = Data->NativeObjectName;
  202. params.Handled = FALSE;
  203. params.FindData = (PWIN32_FIND_DATA)(Data->Details.DetailsData);
  204. params.ObjectNode = Data->ObjectNode;
  205. params.ObjectLeaf = Data->ObjectLeaf;
  206. params.IsNode = Data->IsNode;
  207. params.IsLeaf = Data->IsLeaf;
  208. MigDbTestFile (&params);
  209. return CALLBACK_ENUM_CONTINUE;
  210. }
  211. BOOL
  212. OsFilesInitialize (
  213. VOID
  214. )
  215. {
  216. return TRUE;
  217. }
  218. VOID
  219. OsFilesTerminate (
  220. VOID
  221. )
  222. {
  223. DoneMigDbEx ();
  224. }