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.

172 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 1990-2000 Microsoft Corporation
  3. Module Name:
  4. Cufat.cxx
  5. Abstract:
  6. This module contains run-time, global support for the
  7. FAT Conversion library (CUFAT). This support includes:
  8. - creation of CLASS_DESCRIPTORs
  9. - Global objects
  10. Author:
  11. Ramon Juan San Andres (ramonsa) 23-Sep-1991
  12. Environment:
  13. User Mode
  14. Notes:
  15. --*/
  16. #include <pch.cxx>
  17. #include "ulib.hxx"
  18. //
  19. // Local prototypes
  20. //
  21. STATIC
  22. BOOLEAN
  23. DefineClassDescriptors(
  24. );
  25. STATIC
  26. BOOLEAN
  27. UndefineClassDescriptors(
  28. );
  29. extern "C" BOOLEAN
  30. InitializeCufat (
  31. PVOID DllHandle,
  32. ULONG Reason,
  33. PCONTEXT Context
  34. );
  35. BOOLEAN
  36. InitializeCufat (
  37. PVOID DllHandle,
  38. ULONG Reason,
  39. PCONTEXT Context
  40. )
  41. /*++
  42. Routine Description:
  43. Initialize Cufat by constructing and initializing all
  44. global objects. These include:
  45. - all CLASS_DESCRIPTORs (class_cd)
  46. Arguments:
  47. None.
  48. Return Value:
  49. BOOLEAN - Returns TRUE if all global objects were succesfully constructed
  50. and initialized.
  51. --*/
  52. {
  53. UNREFERENCED_PARAMETER( DllHandle );
  54. UNREFERENCED_PARAMETER( Context );
  55. #if defined( _AUTOCHECK_ ) || defined( _SETUP_LOADER_ )
  56. UNREFERENCED_PARAMETER( Reason );
  57. if (!DefineClassDescriptors()) {
  58. UndefineClassDescriptors();
  59. DebugAbort( "Cufat initialization failed!!!\n" );
  60. return( FALSE );
  61. }
  62. DebugPrint("CUFAT.DLL got attached.\n");
  63. #else // _AUTOCHECK_ and _SETUP_LOADER_ not defined
  64. STATIC ULONG count = 0;
  65. switch (Reason) {
  66. case DLL_PROCESS_ATTACH:
  67. case DLL_THREAD_ATTACH:
  68. if (count > 0) {
  69. ++count;
  70. DebugPrintTrace(("CUFAT.DLL got attached %d times.\n", count));
  71. return TRUE;
  72. }
  73. if (!DefineClassDescriptors()) {
  74. UndefineClassDescriptors();
  75. DebugAbort( "Cufat initialization failed!!!\n" );
  76. return( FALSE );
  77. }
  78. DebugPrint("CUFAT.DLL got attached.\n");
  79. count++;
  80. break;
  81. case DLL_PROCESS_DETACH:
  82. case DLL_THREAD_DETACH:
  83. if (count > 1) {
  84. --count;
  85. DebugPrintTrace(("CUFAT.DLL got detached. %d time(s) left.\n", count));
  86. return TRUE;
  87. }
  88. if (count == 1) {
  89. DebugPrint("CUFAT.DLL got detached.\n");
  90. UndefineClassDescriptors();
  91. count--;
  92. } else
  93. DebugPrint("CUFAT.DLL detached more than attached\n");
  94. break;
  95. }
  96. #endif // _AUTOCHECK || _SETUP_LOADER_
  97. return TRUE;
  98. }
  99. DECLARE_CLASS( FAT_NTFS );
  100. STATIC
  101. BOOLEAN
  102. DefineClassDescriptors(
  103. )
  104. {
  105. if ( DEFINE_CLASS_DESCRIPTOR( FAT_NTFS ) &&
  106. TRUE ) {
  107. return TRUE;
  108. } else {
  109. DebugPrint( "Could not initialize class descriptors!");
  110. return FALSE;
  111. }
  112. }
  113. STATIC
  114. BOOLEAN
  115. UndefineClassDescriptors(
  116. )
  117. {
  118. UNDEFINE_CLASS_DESCRIPTOR( FAT_NTFS );
  119. return TRUE;
  120. }