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.

203 lines
7.5 KiB

  1. #define ADD_OFFSET(_p,_o) (PVOID)((PUCHAR)(_p) + (_p)->_o)
  2. #define ALIGN_DOWN(length, type) \
  3. ((ULONG)(length) & ~(sizeof(type) - 1))
  4. #define ALIGN_UP(length, type) \
  5. (ALIGN_DOWN(((ULONG)(length) + sizeof(type) - 1), type))
  6. #define MBE_STATUS_IS_NT 0x00000001
  7. #define MBE_IS_NT(_be) (((_be)->Status & MBE_STATUS_IS_NT) != 0)
  8. #define MBE_SET_IS_NT(_be) ((_be)->Status |= MBE_STATUS_IS_NT)
  9. typedef struct _MY_BOOT_ENTRY {
  10. LIST_ENTRY ListEntry;
  11. PLIST_ENTRY ListHead;
  12. PUCHAR AllocationEnd;
  13. ULONG Ordered;
  14. ULONG Status;
  15. ULONG myId;
  16. ULONG Id;
  17. ULONG Attributes;
  18. PWSTR FriendlyName;
  19. ULONG FriendlyNameLength;
  20. PWSTR OsLoadOptions;
  21. ULONG OsLoadOptionsLength;
  22. PFILE_PATH BootFilePath;
  23. PFILE_PATH OsFilePath;
  24. PUCHAR ForeignOsOptions;
  25. ULONG ForeignOsOptionsLength;
  26. BOOT_ENTRY NtBootEntry;
  27. } MY_BOOT_ENTRY, *PMY_BOOT_ENTRY;
  28. DWORD InitializeEFI(void);
  29. BOOL QueryBootIniSettings_IA64(DWORD argc, LPCTSTR argv[]);
  30. DWORD DeleteBootIniSettings_IA64(DWORD argc, LPCTSTR argv[]);
  31. DWORD CopyBootIniSettings_IA64(DWORD argc, LPCTSTR argv[]);
  32. DWORD ChangeTimeOut_IA64(DWORD argc, LPCTSTR argv[]);
  33. DWORD RawStringOsOptions_IA64(DWORD argc, LPCTSTR argv[]);
  34. DWORD ChangeDefaultBootEntry_IA64(DWORD argc, LPCTSTR argv[]);
  35. NTSTATUS BootCfg_EnumerateBootEntries(PBOOT_ENTRY_LIST *ntBootEntries);
  36. NTSTATUS BootCfg_QueryBootOptions(PBOOT_OPTIONS *ppBootOptions);
  37. PWSTR GetNtNameForFilePath (IN PFILE_PATH FilePath);
  38. DWORD ChangeBootEntry(PBOOT_ENTRY bootEntry, LPTSTR lpNewFriendlyName, LPTSTR lpOSLoadOptions);
  39. //DWORD CopyBootEntry(PBOOT_ENTRY bootEntry, LPTSTR lpNewFriendlyName);
  40. DWORD ModifyBootOptions(ULONG Timeout, LPTSTR pHeadlessRedirection, ULONG NextBootEntryID, ULONG Flag);
  41. PMY_BOOT_ENTRY CreateBootEntryFromBootEntry (IN PMY_BOOT_ENTRY OldBootEntry);
  42. BOOL IsBootEntryWindows(PBOOT_ENTRY bootEntry);
  43. PWSTR
  44. GetNtNameForFilePath (IN PFILE_PATH FilePath);
  45. DWORD ConvertBootEntries (PBOOT_ENTRY_LIST BootEntries);
  46. VOID DisplayBootEntry();
  47. DWORD DisplayBootOptions();
  48. DWORD GetCurrentBootEntryID(DWORD Id);
  49. DWORD ProcessDebugSwitch_IA64( DWORD argc, LPCTSTR argv[] );
  50. VOID GetComPortType_IA64( LPTSTR szString,LPTSTR szTemp );
  51. DWORD ProcessEmsSwitch_IA64( DWORD argc, LPCTSTR argv[] );
  52. DWORD ProcessAddSwSwitch_IA64( DWORD argc, LPCTSTR argv[] );
  53. DWORD ProcessRmSwSwitch_IA64( DWORD argc, LPCTSTR argv[] );
  54. DWORD ProcessDbg1394Switch_IA64(DWORD argc,LPCTSTR argv[]);
  55. VOID displayListUsage_IA64();
  56. VOID displayUpdateUsage_IA64();
  57. DWORD ProcessUpdateSwitch_IA64( DWORD argc, LPCTSTR argv[] );
  58. #define PORT_COM1A _T("/debugport=COM1")
  59. #define PORT_COM2A _T("/debugport=COM2")
  60. #define PORT_COM3A _T("/debugport=COM3")
  61. #define PORT_COM4A _T("/debugport=COM4")
  62. #define PORT_1394A _T("/debugport=1394")
  63. //#ifdef _WIN64
  64. #define PARTITION_TABLE_OFFSET 446
  65. #define PART_NAME_LEN 36
  66. #define GPT_PART_SIGNATURE 0x5452415020494645
  67. #define TOKEN_BACKSLASH4 _T("\\\\")
  68. #define SUBKEY1 _T("SYSTEM\\SETUP")
  69. #define IDENTIFIER_VALUE2 _T("SystemPartition")
  70. #define IDENTIFIER_VALUE3 _T("OsLoaderPath")
  71. #define ARC_SIGNATURE _T("signature({%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}-%08x-%016I64x-%016I64x)")
  72. typedef struct _GPT_ENTRY
  73. {
  74. GUID PartitionTypeGUID; // declartion of this partition's type
  75. GUID UniquePartitionGUID; // Unique ID for this particular partition
  76. // (unique to this instance)
  77. UINT64 StartingLBA; // 0 based block (sector) address of the
  78. // first block included in the partition.
  79. UINT64 EndingLBA; // 0 based block (sector) address of the
  80. // last block included in the partition.
  81. // If StartingLBA == EndingLBA then the
  82. // partition is 1 block long. this is legal.
  83. UINT64 Attributes; // Always ZERO for now
  84. WCHAR PartitionName[PART_NAME_LEN]; // 36 unicode characters of name
  85. struct _GPT_ENTRY *NextGPTEntry;
  86. } GPT_ENTRY, *PGPT_ENTRY;
  87. typedef struct _GPT_HEADER
  88. {
  89. UINT64 Signature; // GPT PART
  90. UINT32 Revision;
  91. UINT32 HeaderSize;
  92. UINT32 HeaderCRC32; // computed using 0 for own init value
  93. UINT32 Reserved0;
  94. UINT64 MyLBA; // 0 based sector number of the first
  95. // sector of this structure
  96. UINT64 AlternateLBA; // 0 based sector (block) number of the
  97. // first sector of the secondary
  98. // GPT_HEADER, or 0 if this is the
  99. // secondary.
  100. UINT64 FirstUsableLBA; // 0 based sector number of the first
  101. // sector that may be included in a partition.
  102. UINT64 LastUsableLBA; // last legal LBA, inclusive.
  103. GUID DiskGUID; // The unique ID of this LUN/spindle/disk
  104. UINT64 PartitionEntryLBA; // The start of the table of entries...
  105. UINT32 NumberOfPartitionEntries; // Number of entries in the table, this is
  106. // how many allocated, NOT how many used.
  107. UINT32 SizeOfPartitionEntry; // sizeof(GPT_ENTRY) always mult. of 8
  108. UINT32 PartitionEntryArrayCRC32; // CRC32 of the table.
  109. // Reserved and zeros to the end of the block
  110. // Don't declare an array or sizeof() gives a nonsense answer..
  111. // Computed data
  112. UINT32 ComputedHeaderCRC32;
  113. UINT32 ComputedPartitionEntryArrayCRC32;
  114. UINT32 UsedPartitionEntries;
  115. PGPT_ENTRY FirstGPTEntry;
  116. BOOLEAN Healthy;
  117. } GPT_HEADER, *PGPT_HEADER;
  118. UINT32 ScanGPT(DWORD nPhysicalDisk);
  119. DWORD ProcessMirrorSwitch_IA64(DWORD argc,LPCTSTR argv[]) ;
  120. DWORD GetBootFilePath(LPTSTR szComputerName,LPTSTR szBootPath);
  121. BOOL GetARCSignaturePath(LPTSTR szString,LPTSTR szFinalPath);
  122. DWORD ProcessMirrorBootEntry(PBOOT_ENTRY bootEntry, PWSTR lpBootFilePath,LPTSTR OsFilePath);
  123. DWORD GetDeviceInfo(LPTSTR szGUID,LPTSTR szFinalStr,DWORD dwDriveNum,DWORD dwActuals);
  124. PBOOT_ENTRY FillBootEntry(PBOOT_ENTRY bootEntry,LPTSTR szBootPath,LPTSTR szArcPath);
  125. LPVOID MEMALLOC( ULONG size );
  126. VOID MEMFREE ( LPVOID block );
  127. LONG LowNtAddBootEntry(
  128. IN WCHAR *pwszLoaderPath,
  129. IN WCHAR *pwszArcString
  130. );
  131. DWORD FormARCPath(LPTSTR szGUID,LPTSTR szFinalStr);
  132. LONG LowNtAddBootEntry( IN WCHAR *pwszLoaderPath,IN WCHAR *pwszArcString) ;
  133. DWORD GetBootPath(LPTSTR szValue,LPTSTR szResult);
  134. LONG AddBootEntry( IN WCHAR *pwszLoaderPath,IN WCHAR *pwszArcString );
  135. NTSTATUS LowGetPartitionInfo( IN HANDLE handle,OUT PARTITION_INFORMATION_EX *partitionData );
  136. LONG DmCommonNtOpenFile(IN PWSTR Name, IN ULONG access, IN PHANDLE Handle );
  137. DWORD AddMirrorPlex(LPTSTR szOsLoadPath , LPTSTR szLoaderPath , LPTSTR szValue ,BOOL bFlag,LPTSTR szFriendlyName);
  138. BOOL FormatAccToLocale( NUMBERFMT *pNumberFmt,LPTSTR* pszGroupSep,LPTSTR* pszDecimalSep,LPTSTR* pszGroupThousSep);
  139. BOOL GetInfo( LCTYPE lctype, LPTSTR* pszData );
  140. DWORD
  141. ConvertintoLocale( IN LPWSTR szTempBuf,
  142. OUT LPWSTR szOutputStr );
  143. DWORD CopyBootEntry(PBOOT_ENTRY bootEntry, LPTSTR lpNewFriendlyName,BOOL bFlag);
  144. #define SAFEMEMFREE(pVal) \
  145. if ( pVal ) { \
  146. MEMFREE(pVal);\
  147. pVal = NULL ; \
  148. }
  149. DWORD IsAdminGroup( BOOL *bAdmin );
  150. BOOL GetTokenHandle(OUT PHANDLE hTokenHandle);
  151. BOOL CheckAdminAccess( LPCTSTR pszMachine );
  152. VOID Freelist();
  153. PWSTR GetDefaultBootEntry();