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.

210 lines
6.1 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1998.
  3. Microsoft Windows
  4. Module Name:
  5. RECOVERY.H
  6. Abstract:
  7. Author:
  8. 09-Jan-99 ShaoYin
  9. Environment:
  10. Kernel Mode - Win32
  11. Revision History:
  12. 09-Jan-99 ShaoYin Created Initial File.
  13. 07-July-2000 ShaoYin Add API to retrieve next available RID from registry
  14. --*/
  15. //////////////////////////////////////////////////////////////////////////
  16. // //
  17. // Global Variables and Private Routines //
  18. // //
  19. //////////////////////////////////////////////////////////////////////////
  20. #ifndef _RECOVERY_
  21. #define _RECOVERY_
  22. //
  23. // Exported API
  24. //
  25. #define REGISTRY_KEY_NAME_LENGTH_MAX 512
  26. //
  27. // The following API is exported to System Recovery Tool and Restore Utility.
  28. //
  29. // 1. will run in Kernel Mode if used by System Recovery Tool.
  30. // run in User Mode if used by Restore Utility
  31. //
  32. // 2. Parameters:
  33. //
  34. // Rid - Logon User's Relative ID
  35. //
  36. // hSecurityRootKey - Handle of the Root of SECURITY hive
  37. //
  38. // hSamRootKey - Handle of the Root of SAM hive
  39. //
  40. // hSystemRootKey - Handle of the root of system hive
  41. //
  42. // caller should Load the SAM hive and System hive,
  43. // and Unload them after this API returns.
  44. //
  45. //
  46. // BootKey -- OPTIONAL. During the first call of this API, should provide
  47. // NULL. Then SAM will query registry, check how the machine is
  48. // syskey'd.
  49. //
  50. // If the BootKey is stored in registry or the local machine is
  51. // not syskey'd yet, no further caller's side work.
  52. //
  53. // If the BootKey is stored in floppy disk, this API will fail
  54. // with error code STATUS_SAM_NEED_BOOTKEY_FLOPPY, the caller
  55. // should handle it by reading the syskey from floppy disk, the
  56. // try this API with the BootKey parameter filled correctly.
  57. // The syskey (the data) read from the floppy disk should be copy
  58. // to the BootKey->Buffer, and BootKey->Length indicate the
  59. // length of the data.
  60. //
  61. // If the BootKey is derived from Boot Password, this API will
  62. // fail with error code STATUS_SAM_NEED_BOOTKEY_PASSWORD, then
  63. // the caller should prompt the logon user to enter Boot Password,
  64. // then try this API with the BootPassword again.
  65. // In this case BootKey should be the entered password.
  66. // BootKey->Buffer should be the WCHAR password,
  67. // BootKey->Length should be the length of password in byte.
  68. //
  69. // BootKeyType -- OPTIONAL. Accociated with BootKey, only used when
  70. // BootKey is Not NULL.
  71. // Valid Values:
  72. //
  73. // SamBootKeyDisk - means BootKey->Buffer contains the actual
  74. // syskey read from floppy disk,
  75. // BootKey->Length should be the length of
  76. // syskey in byte
  77. //
  78. // SamBootKeyPassword - means BootKey contains the UNICODE_STRING
  79. // format boot password.
  80. //
  81. //
  82. // NtOwfPassword -- when SUCCEED, it will be filled with the logon user's
  83. // Clear NT OWF Password. If the logon user's password is blank.
  84. // NtOwfPassword will be filled with NULL NT OWF Password.
  85. // no meaning when this API fails.
  86. //
  87. // NtPasswordPresent -- Meaningful only when the API succeeds. Indicate whether
  88. // the logon user's NT OWF Password present in registry or not.
  89. // TRUE - present in registry
  90. //
  91. //
  92. // NtPasswordNonNull -- When this API succeeds, indicates whether the clear
  93. // NT OWF Password is Null or not.
  94. // TRUE -- not NULL password.
  95. //
  96. // 3. more information (including the algorithm and implementaion),
  97. // please reference
  98. // $(BASEDIR)\private\ds\src\newsam2\recovery\recovery.c
  99. //
  100. // 4. Return Values:
  101. //
  102. // STATUS_SUCCESS
  103. // STATUS_SAM_NEED_BOOTKEY_PASSWORD
  104. // STATUS_SAM_NEED_BOOTKEY_FLOPPY
  105. // STATUS_NO_MEMORY
  106. // STATUS_INTERNAL_ERROR
  107. // STATUS_INVALID_PARAMETER
  108. // STATUS_INVALID_HANDLE
  109. // STATUS_NO_SUCH_USER
  110. // ...
  111. //
  112. NTSTATUS
  113. SamRetrieveOwfPasswordUser(
  114. IN ULONG Rid,
  115. IN HANDLE hSecurityRootKey,
  116. IN HANDLE hSamRootKey,
  117. IN HANDLE hSystemRootKey,
  118. IN PUNICODE_STRING BootKey OPTIONAL,
  119. IN USHORT BootKeyType OPTIONAL,
  120. OUT PNT_OWF_PASSWORD NtOwfPassword,
  121. OUT PBOOLEAN NtPasswordPresent,
  122. OUT PBOOLEAN NtPasswordNonNull
  123. );
  124. //
  125. // Routine Description:
  126. //
  127. // This routine reads the SAM Account Domain infomation from SAM hive, passed
  128. // in through hSamRootKey, and returns the value of next available RID of
  129. // this account domain.
  130. //
  131. // Parameters:
  132. //
  133. // hSamRootKey - Handle of the Root of SAM hive
  134. //
  135. // SAM hive is located in %windir%\system32\config, name is SAM
  136. //
  137. // pNextRid - Return the value of next available Rid if success.
  138. //
  139. // Return Values:
  140. //
  141. // STATUS_SUCCESS
  142. // or other error status code
  143. //
  144. NTSTATUS
  145. SamGetNextAvailableRid(
  146. IN HANDLE hSamRootKey,
  147. OUT PULONG pNextRid
  148. );
  149. //
  150. // Routine Description:
  151. //
  152. // This routine queries the Account Domain's Fixed Length Attribute stored
  153. // in registry. Update it with the passed in NextRid value.
  154. //
  155. // Parameters:
  156. //
  157. // hSamRootKey - Handle of the Root of the hive
  158. //
  159. // NextRid - Set the domain next available rid to the passed in value
  160. //
  161. // Return Values:
  162. //
  163. NTSTATUS
  164. SamSetNextAvailableRid(
  165. IN HANDLE hSamRootKey,
  166. IN ULONG NextRid
  167. );
  168. #endif // _RECOVERY_