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.

169 lines
6.0 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();
  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. #define PORT_COM1A _T("/debugport=COM1")
  56. #define PORT_COM2A _T("/debugport=COM2")
  57. #define PORT_COM3A _T("/debugport=COM3")
  58. #define PORT_COM4A _T("/debugport=COM4")
  59. #define PORT_1394A _T("/debugport=1394")
  60. //#ifdef _WIN64
  61. #define PARTITION_TABLE_OFFSET 446
  62. #define PART_NAME_LEN 36
  63. #define GPT_PART_SIGNATURE 0x5452415020494645
  64. #define TOKEN_BACKSLASH4 _T("\\\\")
  65. #define SUBKEY1 _T("SYSTEM\\SETUP")
  66. #define IDENTIFIER_VALUE2 _T("SystemPartition")
  67. #define IDENTIFIER_VALUE3 _T("OsLoaderPath")
  68. typedef struct _GPT_ENTRY
  69. {
  70. GUID PartitionTypeGUID; // declartion of this partition's type
  71. GUID UniquePartitionGUID; // Unique ID for this particular partition
  72. // (unique to this instance)
  73. UINT64 StartingLBA; // 0 based block (sector) address of the
  74. // first block included in the partition.
  75. UINT64 EndingLBA; // 0 based block (sector) address of the
  76. // last block included in the partition.
  77. // If StartingLBA == EndingLBA then the
  78. // partition is 1 block long. this is legal.
  79. UINT64 Attributes; // Always ZERO for now
  80. WCHAR PartitionName[PART_NAME_LEN]; // 36 unicode characters of name
  81. struct _GPT_ENTRY *NextGPTEntry;
  82. } GPT_ENTRY, *PGPT_ENTRY;
  83. typedef struct _GPT_HEADER
  84. {
  85. UINT64 Signature; // GPT PART
  86. UINT32 Revision;
  87. UINT32 HeaderSize;
  88. UINT32 HeaderCRC32; // computed using 0 for own init value
  89. UINT32 Reserved0;
  90. UINT64 MyLBA; // 0 based sector number of the first
  91. // sector of this structure
  92. UINT64 AlternateLBA; // 0 based sector (block) number of the
  93. // first sector of the secondary
  94. // GPT_HEADER, or 0 if this is the
  95. // secondary.
  96. UINT64 FirstUsableLBA; // 0 based sector number of the first
  97. // sector that may be included in a partition.
  98. UINT64 LastUsableLBA; // last legal LBA, inclusive.
  99. GUID DiskGUID; // The unique ID of this LUN/spindle/disk
  100. UINT64 PartitionEntryLBA; // The start of the table of entries...
  101. UINT32 NumberOfPartitionEntries; // Number of entries in the table, this is
  102. // how many allocated, NOT how many used.
  103. UINT32 SizeOfPartitionEntry; // sizeof(GPT_ENTRY) always mult. of 8
  104. UINT32 PartitionEntryArrayCRC32; // CRC32 of the table.
  105. // Reserved and zeros to the end of the block
  106. // Don't declare an array or sizeof() gives a nonsense answer..
  107. // Computed data
  108. UINT32 ComputedHeaderCRC32;
  109. UINT32 ComputedPartitionEntryArrayCRC32;
  110. UINT32 UsedPartitionEntries;
  111. PGPT_ENTRY FirstGPTEntry;
  112. BOOLEAN Healthy;
  113. } GPT_HEADER, *PGPT_HEADER;
  114. UINT32 ScanGPT(DWORD nPhysicalDisk);
  115. DWORD ProcessMirrorSwitch_IA64(DWORD argc,LPCTSTR argv[]) ;
  116. DWORD GetBootFilePath(LPTSTR szComputerName,LPTSTR szBootPath);
  117. BOOL GetARCSignaturePath(LPTSTR szString,LPTSTR szFinalPath);
  118. //DWORD ProcessMirrorBootEntry(PBOOT_ENTRY bootEntry, LPTSTR lpBootFilePath,LPTSTR OsFilePath);
  119. DWORD ProcessMirrorBootEntry(PBOOT_ENTRY bootEntry, PWSTR lpBootFilePath,LPTSTR OsFilePath);
  120. DWORD GetDeviceInfo(LPTSTR szGUID,LPTSTR szFinalStr);
  121. PBOOT_ENTRY FillBootEntry(PBOOT_ENTRY bootEntry,LPTSTR szBootPath,LPTSTR szArcPath);
  122. LPVOID MEMALLOC( ULONG size );
  123. VOID MEMFREE ( LPVOID block );
  124. LONG LowNtAddBootEntry(
  125. IN WCHAR *pwszLoaderPath,
  126. IN WCHAR *pwszArcString
  127. );
  128. DWORD FormARCPath(LPTSTR szGUID,LPTSTR szFinalStr);
  129. LONG LowNtAddBootEntry( IN WCHAR *pwszLoaderPath,IN WCHAR *pwszArcString) ;