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.

177 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. Ntfsexp.c
  5. Abstract:
  6. This module implements the exported routines for Ntfs
  7. Author:
  8. Jeff Havens [JHavens] 20-Dec-1995
  9. Revision History:
  10. --*/
  11. #include "NtfsProc.h"
  12. #ifdef ALLOC_PRAGMA
  13. #pragma alloc_text(PAGE, NtfsLoadAddOns)
  14. #pragma alloc_text(PAGE, NtOfsRegisterCallBacks)
  15. #endif
  16. NTSTATUS
  17. EfsInitialization(
  18. void
  19. );
  20. VOID
  21. NtfsLoadAddOns (
  22. IN PDRIVER_OBJECT DriverObject,
  23. IN PVOID Context,
  24. IN ULONG Count
  25. )
  26. /*++
  27. Routine Description:
  28. This routine attempts to initialize the efs support library.
  29. Arguments:
  30. DriverObject - Driver object for NTFS
  31. Context - Unused, required by I/O system.
  32. Count - Unused, required by I/O system.
  33. Return Value:
  34. None.
  35. --*/
  36. {
  37. NTSTATUS Status;
  38. UNREFERENCED_PARAMETER(Context);
  39. UNREFERENCED_PARAMETER(Count);
  40. UNREFERENCED_PARAMETER(DriverObject);
  41. //
  42. // do any efs initialization
  43. // we ignore the status return bedcause there really
  44. // isn't anything we can do about it and ntfs will work
  45. // fine without it.
  46. //
  47. if (!FlagOn( NtfsData.Flags, NTFS_FLAGS_PERSONAL )) {
  48. Status = EfsInitialization();
  49. }
  50. //
  51. // return to caller
  52. //
  53. return;
  54. }
  55. NTSTATUS
  56. NtOfsRegisterCallBacks (
  57. NTFS_ADDON_TYPES NtfsAddonType,
  58. PVOID CallBackTable
  59. )
  60. /*++
  61. Routine Description:
  62. This routine is called by one of the NTFS add-ons to register its
  63. callback routines. These routines are call by NTFS at the appropriate
  64. times.
  65. Arguments:
  66. NtfsAddonType - Indicates the type of callback table.
  67. CallBackTable - Pointer to call back routines for addon.
  68. Return Value:
  69. Returns a status indicating if the callbacks were accepted.
  70. --*/
  71. {
  72. NTSTATUS Status;
  73. PAGED_CODE();
  74. switch (NtfsAddonType) {
  75. case Encryption :
  76. {
  77. Status = STATUS_INVALID_PARAMETER;
  78. //
  79. // Bail if Ntfs has not been initialized.
  80. //
  81. if (SafeNodeType( &NtfsData ) != NTFS_NTC_DATA_HEADER) {
  82. return STATUS_DEVICE_DOES_NOT_EXIST;
  83. } else {
  84. //
  85. // Only allow one encryption driver to register.
  86. //
  87. NtfsLockNtfsData();
  88. if (!FlagOn( NtfsData.Flags, NTFS_FLAGS_ENCRYPTION_DRIVER )) {
  89. ENCRYPTION_CALL_BACK *EncryptionCallBackTable = CallBackTable;
  90. //
  91. // The caller must pass a callback table and the version must be correct.
  92. //
  93. if ((EncryptionCallBackTable != NULL) &&
  94. (EncryptionCallBackTable->InterfaceVersion == ENCRYPTION_CURRENT_INTERFACE_VERSION)) {
  95. //
  96. // Save the call back values.
  97. //
  98. RtlCopyMemory( &NtfsData.EncryptionCallBackTable,
  99. EncryptionCallBackTable,
  100. sizeof( ENCRYPTION_CALL_BACK ));
  101. #ifdef EFSDBG
  102. NtfsData.EncryptionCallBackTable.AfterReadProcess = NtfsDummyEfsRead;
  103. NtfsData.EncryptionCallBackTable.BeforeWriteProcess = NtfsDummyEfsWrite;
  104. #endif
  105. SetFlag( NtfsData.Flags, NTFS_FLAGS_ENCRYPTION_DRIVER );
  106. Status = STATUS_SUCCESS;
  107. }
  108. }
  109. NtfsUnlockNtfsData();
  110. return Status;
  111. }
  112. }
  113. default :
  114. return STATUS_INVALID_PARAMETER;
  115. }
  116. }