]> glassweightruler.freedombox.rocks Git - Ventoy.git/blobdiff - Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h
update README.md
[Ventoy.git] / Ventoy2Disk / Ventoy2Disk / Ventoy2Disk.h
index ad8bb526c00e794500feafbf118b6e882a7b363f..dd426179c0e0104de4c9520ae170360f9ca8cf9e 100644 (file)
@@ -79,6 +79,43 @@ typedef struct MBR_HEAD
     UINT8 Byte55;
     UINT8 ByteAA;
 }MBR_HEAD;
+
+typedef struct VTOY_GPT_HDR
+{
+    CHAR   Signature[8]; /* EFI PART */
+    UINT8  Version[4];
+    UINT32 Length;
+    UINT32 Crc;
+    UINT8  Reserved1[4];
+    UINT64 EfiStartLBA;
+    UINT64 EfiBackupLBA;
+    UINT64 PartAreaStartLBA;
+    UINT64 PartAreaEndLBA;
+    GUID   DiskGuid;
+    UINT64 PartTblStartLBA;
+    UINT32 PartTblTotNum;
+    UINT32 PartTblEntryLen;
+    UINT32 PartTblCrc;
+    UINT8  Reserved2[420];
+}VTOY_GPT_HDR;
+
+typedef struct VTOY_GPT_PART_TBL
+{
+    GUID   PartType;
+    GUID   PartGuid;
+    UINT64 StartLBA;
+    UINT64 LastLBA;
+    UINT64 Attr;
+    UINT16 Name[36];
+}VTOY_GPT_PART_TBL;
+
+typedef struct VTOY_GPT_INFO
+{
+    MBR_HEAD MBR;
+    VTOY_GPT_HDR Head;
+    VTOY_GPT_PART_TBL PartTbl[128];
+}VTOY_GPT_INFO;
+
 #pragma pack()
 
 #define VENTOY_MAX_PHY_DRIVE  128
@@ -87,6 +124,7 @@ typedef struct PHY_DRIVE_INFO
 {
     int Id;
     int PhyDrive;
+    int PartStyle;//0:MBR 1:GPT
     UINT64 SizeInBytes;
     BYTE DeviceType;
     BOOL RemovableMedia;
@@ -138,19 +176,21 @@ const CHAR * GetBusTypeString(STORAGE_BUS_TYPE Type);
 int VentoyGetLocalBootImg(MBR_HEAD *pMBR);
 int GetHumanReadableGBSize(UINT64 SizeBytes);
 void TrimString(CHAR *String);
-int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR);
+int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR, int PartStyle);
+int VentoyFillGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo);
 BOOL IsVentoyLogicalDrive(CHAR DriveLetter);
 int GetRegDwordValue(HKEY Key, LPCSTR SubKey, LPCSTR ValueName, DWORD *pValue);
 int GetPhysicalDriveCount(void);
 int GetAllPhysicalDriveInfo(PHY_DRIVE_INFO *pDriveList, DWORD *pDriveCount);
 int GetPhyDriveByLogicalDrive(int DriveLetter);
-int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, CHAR *VerBuf, size_t BufLen);
+int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, UINT64 Part2StartSector, CHAR *VerBuf, size_t BufLen);
 int Ventoy2DiskInit(void);
 int Ventoy2DiskDestroy(void);
 PHY_DRIVE_INFO * GetPhyDriveInfoById(int Id);
 int ParseCmdLineOption(LPSTR lpCmdLine);
-int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive);
+int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle);
 int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive);
+int VentoyFillBackupGptHead(VTOY_GPT_INFO *pInfo, VTOY_GPT_HDR *pHead);
 void SetProgressBarPos(int Pos);
 int ReadWholeFileToBuf(const CHAR *FileName, int ExtLen, void **Bufer, int *BufLen);
 int INIT unxz(unsigned char *in, int in_size,
@@ -159,5 +199,16 @@ int INIT unxz(unsigned char *in, int in_size,
     unsigned char *out, int *in_used,
     void(*error)(char *x));
 void disk_io_set_param(HANDLE Handle, UINT64 SectorCount);
+INT_PTR CALLBACK PartDialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
+int GetReservedSpaceInMB(void);
+int FindProcessOccupyDisk(HANDLE hDrive, PHY_DRIVE_INFO *pPhyDrive);
+int VentoyFillLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table);
+int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLetter);
+UINT32 VentoyCrc32(void *Buffer, UINT32 Length);
+
+#define SET_FILE_POS(pos) \
+    liCurrentPosition.QuadPart = pos; \
+    SetFilePointerEx(hDrive, liCurrentPosition, &liCurrentPosition, FILE_BEGIN)\
+
 
 #endif