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.

187 lines
5.0 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. confdisk.h
  5. Abstract:
  6. Utility program to create an ASR state-file (asr.sif), or restore
  7. non-critical disk layout based on a previously created asr.sif.
  8. Author:
  9. Guhan Suriyanarayanan (guhans) 15-April-2001
  10. Environment:
  11. User-mode only.
  12. Revision History:
  13. 15-Apr-2001 guhans
  14. Initial creation
  15. --*/
  16. //
  17. // --------
  18. // typedefs and constants
  19. // --------
  20. //
  21. #define BUFFER_LENGTH 1024
  22. //
  23. // Indices for fields in the [COMMANDS] section. This is from
  24. // base\ntsetup\syssetup\setupasr.c.
  25. //
  26. typedef enum _SIF_COMMANDS_FIELD_INDEX {
  27. CmdKey = 0,
  28. SystemKey, // Must always be "1"
  29. SequenceNumber,
  30. CriticalApp,
  31. CmdString,
  32. CmdParams, // May be NULL
  33. CmdNumFields // Must always be last
  34. } SIF_SYSTEM_FIELD_INDEX;
  35. //
  36. // One ASR_RECOVERY_APP_NODE struct is created for each entry
  37. // in the [COMMANDS] section of asr.sif.
  38. //
  39. typedef struct _ASR_RECOVERY_APP_NODE {
  40. struct _ASR_RECOVERY_APP_NODE *Next;
  41. //
  42. // Expect this to always be 1
  43. //
  44. INT SystemKey;
  45. //
  46. // The sequence number according to which the apps are run. If
  47. // two apps have the same sequence number, the app that appears
  48. // first in the sif file is run.
  49. //
  50. INT SequenceNumber;
  51. //
  52. // The "actionOnCompletion" field for the app. If CriticalApp is
  53. // non-zero, and the app returns an non-zero exit-code, we shall
  54. // consider it a fatal failure and quit out of ASR.
  55. //
  56. INT CriticalApp;
  57. //
  58. // The app to be launched
  59. //
  60. PWSTR RecoveryAppCommand;
  61. //
  62. // The paramaters for the app. This is just concatenated to the
  63. // string above. May be NULL.
  64. //
  65. PWSTR RecoveryAppParams;
  66. } ASR_RECOVERY_APP_NODE, *PASR_RECOVERY_APP_NODE;
  67. //
  68. // This contains our list of entries in the COMMANDS section,
  69. // sorted in order of sequence numbers.
  70. //
  71. typedef struct _ASR_RECOVERY_APP_LIST {
  72. PASR_RECOVERY_APP_NODE First; // Head
  73. PASR_RECOVERY_APP_NODE Last; // Tail
  74. LONG AppCount; // NumEntries
  75. } ASR_RECOVERY_APP_LIST, *PASR_RECOVERY_APP_LIST;
  76. //
  77. // --------
  78. // function declarations
  79. // --------
  80. //
  81. VOID
  82. AsrpPrintError(
  83. IN CONST DWORD dwLineNumber,
  84. IN CONST DWORD dwErrorCode
  85. );
  86. //
  87. // --------
  88. // macro declarations
  89. // --------
  90. //
  91. /*++
  92. Macro Description:
  93. This macro wraps calls that are expected to return ERROR_SUCCESS.
  94. If ErrorCondition occurs, it sets the LocalStatus to the ErrorCode
  95. passed in, calls SetLastError() to set the Last Error to ErrorCode,
  96. and jumps to the EXIT label in the calling function
  97. Arguments:
  98. ErrorCondition - Expression to be tested
  99. LocalStatus - Status variable in the calling function
  100. ErrorCode - Win 32 error code
  101. --*/
  102. #define ErrExitCode( ErrorCondition, LocalStatus, ErrorCode ) { \
  103. \
  104. if ((BOOL) ErrorCondition) { \
  105. \
  106. if (!g_fErrorMessageDone) { \
  107. \
  108. AsrpPrintError(__LINE__, ErrorCode); \
  109. \
  110. g_fErrorMessageDone = TRUE; \
  111. \
  112. } \
  113. \
  114. LocalStatus = (DWORD) ErrorCode; \
  115. \
  116. SetLastError((DWORD) ErrorCode); \
  117. \
  118. goto EXIT; \
  119. } \
  120. }
  121. //
  122. // Simple macro to allocate and set memory to zero
  123. //
  124. #define Alloc( p, t, cb ) \
  125. p = (t) HeapAlloc(g_hHeap, HEAP_ZERO_MEMORY, cb)
  126. //
  127. // Simple macro to check a pointer, free it if non-NULL, and set it to NULL.
  128. //
  129. #define Free( p ) \
  130. if ( p ) { \
  131. HeapFree(g_hHeap, 0L, p); \
  132. p = NULL; \
  133. }
  134. //
  135. // Simple macro to check if a handle is valid and close it
  136. //
  137. #define _AsrpCloseHandle( h ) \
  138. if ((h) && (INVALID_HANDLE_VALUE != h)) { \
  139. CloseHandle(h); \
  140. h = NULL; \
  141. }