]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Add experimental support for Non-destructive Installation in Windows.
authorlongpanda <admin@ventoy.net>
Wed, 10 Nov 2021 09:53:21 +0000 (17:53 +0800)
committerlongpanda <admin@ventoy.net>
Wed, 10 Nov 2021 09:53:21 +0000 (17:53 +0800)
14 files changed:
INSTALL/Ventoy2Disk.exe
INSTALL/Ventoy2Disk_ARM.exe
INSTALL/Ventoy2Disk_ARM64.exe
INSTALL/Ventoy2Disk_X64.exe
LANGUAGES/languages.json
LinuxGUI/build_qt.sh
Ventoy2Disk/Ventoy2Disk/DiskService.h
Ventoy2Disk/Ventoy2Disk/DiskService_vds.c
Ventoy2Disk/Ventoy2Disk/Language.h
Ventoy2Disk/Ventoy2Disk/PhyDrive.c
Ventoy2Disk/Ventoy2Disk/Utility.c
Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.c
Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h
Ventoy2Disk/Ventoy2Disk/WinDialog.c

index 8af8442b2b735dc695bad05c45e158e7a600f3d4..76c1080d72e2aa5d68777ec882e30dec32b157d3 100644 (file)
Binary files a/INSTALL/Ventoy2Disk.exe and b/INSTALL/Ventoy2Disk.exe differ
index 47a651210fac1cc3726bfa6c9969b79d0d40dfe9..55fd765229f8be546e0a81e4b9c6712faf183982 100644 (file)
Binary files a/INSTALL/Ventoy2Disk_ARM.exe and b/INSTALL/Ventoy2Disk_ARM.exe differ
index fa844917bb00f784e9d45f595ca53a76446c20ab..47727bd0a376e0ae860c9b6f0bee22113fc97615 100644 (file)
Binary files a/INSTALL/Ventoy2Disk_ARM64.exe and b/INSTALL/Ventoy2Disk_ARM64.exe differ
index 924df5ab94d43de1a5523bcc866c716fe274c09e..88fd252028811525a064365c8424ebae2e28d78a 100644 (file)
Binary files a/INSTALL/Ventoy2Disk_X64.exe and b/INSTALL/Ventoy2Disk_X64.exe differ
index 13511f1ea1536beda37fa67fcd5852ce38497180..a10757939b0d44a5a75f5d1739efa684e6642fb6 100644 (file)
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"이번에는 장치에 쓰지 않고 VTSI 파일#@만 생성합니다.#@계속하시겠습니까?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI 파일이 성공적으로 생성되었습니다!#@Rufus(3.15+)를 사용하여 장치에 기록하여 Ventoy 설치를 완료할 수 있습니다.",
         "STR_VTSI_CREATE_FAILED":"VTSI 파일을 생성하지 못했습니다.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"本操作不会向设备中写入数据,而只会生成一个 VTSI 文件#@是否继续?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI 文件创建成功,你可以使用Rufus(3.15+)将其写入对应设备,从而完成Ventoy的安装",
         "STR_VTSI_CREATE_FAILED":"VTSI 文件创建失败",
+        "STR_MENU_PART_RESIZE":"无损安装",
+        "STR_PART_RESIZE_TIP":"Ventoy将尝试进行无损安装。注意:任何磁盘操作都有一定的风险,对于重要数据建议做好备份。#@是否继续?",
+        "STR_PART_RESIZE_SUCCESS":"恭喜你! Ventoy 成功完成了无损安装。",
+        "STR_PART_RESIZE_FAILED":"Ventoy 无损安装失败。详细信息请查阅 log.txt 文件。",
+        "STR_PART_RESIZE_UNSUPPORTED":"条件不满足,无法进行无损安装。详细信息请查阅 log.txt 文件。",
+
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"Şu an aygıta yazılmayacak,sadece bir VTSI dosyası oluşturulacak#@Devam edilsin mi?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI dosyası başarılı bir şekilde oluşturuldu!#@Ventoy'un aygıta kurulumunu tamamlamak için Rufus(3.15+) programını kullanabilirsiniz.",
         "STR_VTSI_CREATE_FAILED":"VTSI dosyası oluşturma başarısız oldu!",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"Aqueste còp cap d’escritura al disc, generacion del fichiet VTSI sonque#@Contunhar ?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"Fracàs de la creacion del fichièr VTSI.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"Esta vez no se escribirá al dispositivo, pero solo generará un archivo VTSI#@¿Continuar?",
         "STR_VTSI_CREATE_SUCCESS":"¡Archivo VTSI creado exitosamente!#@Puedes usar Rufus(3.15+) para escribirlo al dispositivo a fin de completar la instalación de Ventoy.",
         "STR_VTSI_CREATE_FAILED":"Fallo en el archivo VTSI creado.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"На этот раз Ventoy не будет установлен на устройство, а будет только создан файл VTSI#@Продолжить?",
         "STR_VTSI_CREATE_SUCCESS":"Файл VTSI создан успешно!#@Вы можете использовать Rufus(3.15+), чтобы записать его на устройство, для завершения установки Ventoy.",
         "STR_VTSI_CREATE_FAILED":"Ошибка создания файла VTSI.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"Deze keer wordt er niet naar het apparaat geschreven, maar wordt er alleen een VTSI-bestand gegenereerd#@Doorgaan?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI-bestand met succes aangemaakt!#@U kunt Rufus(3.15+) gebruiken om het bestand naar het apparaat te schrijven om de installatie van Ventoy te voltooien.",
         "STR_VTSI_CREATE_FAILED":"Aanmaken van VTSI-bestand mislukt.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"VTSIファイルを生成し,記憶装置への書き込みは行いません。#@続行しますか?",
         "STR_VTSI_CREATE_SUCCESS":"VTSIファイルが生成されました。#@Rufus(3.15以上の版)を使って記憶装置に書き込んで,Ventoyの導入を完遂しましょう。",
         "STR_VTSI_CREATE_FAILED":"VTSIファイルを生成できませんでした。",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"Questa volta non scriverà sul dispositivo, ma genererà solo un file VTSI#@Continuare?",
         "STR_VTSI_CREATE_SUCCESS":"File VTSI creato con successo!#@Puoi usare Rufus (versione 3.15 o successiva) per scrivere sul dispositivo in modo da completare l'installazione di Ventoy.",
         "STR_VTSI_CREATE_FAILED":"Creazione File VTSI non riuscito.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_WEB_SERVICE_UNAVAILABLE":"Lỗi giao tiếp: Dịch vụ không sẵn có",
         "STR_WEB_TOKEN_MISMATCH":"Đã cập nhật trạng thái Daemon, vui lòng thử lại sau.",
         "STR_WEB_SERVICE_BUSY":"Dịch vụ bận, vui lòng thử lại sau.",
-       "STR_MENU_VTSI_CREATE":"Tạo tệp VTSI",
+        "STR_MENU_VTSI_CREATE":"Tạo tệp VTSI",
         "STR_VTSI_CREATE_TIP":"Lần này sẽ không ghi vào thiết bị, chỉ tạo một tệp VTSI#@Bạn muốn tiếp tục?",
         "STR_VTSI_CREATE_SUCCESS":"Tạo tệp VTSI thành công!#@Để hoàn thành cài đặt Ventoy, bạn có thể dùng Rufus (3.15+) để ghi tệp này vào thiết bị.",
         "STR_VTSI_CREATE_FAILED":"Tạo tệp VTSI đã gặp lỗi.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"Овој пат ништо нема да се запише на уредот туку само ќе се генерира VTSI датотека#@Продолжи?",
         "STR_VTSI_CREATE_SUCCESS":"Успешно креирана VTSI датотека!#@Можете да го користите Rufus(3.15+) за да ја запишете на уредот како и да ја комплетирате инсталацијата на Ventoy.",
         "STR_VTSI_CREATE_FAILED":"Креирањето на VTSI датотека е неуспешно.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"Desta vez não irá gravar no dispositivo, mas apenas gerar um ficheiro VTSI#@Continuar?",
         "STR_VTSI_CREATE_SUCCESS":"Ficheiro VTSI criado com sucesso!#@Pode utilizar o Rufus(3.15+) para o gravar no dispositivo de modo a completar a instalação do Ventoy.",
         "STR_VTSI_CREATE_FAILED":"Falha no ficheiro VTSI criado.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"Saat ini tidak akan menuliskan di perangkat, tetapi hanya membuat berkas VTSI #@Lanjutkan?",
         "STR_VTSI_CREATE_SUCCESS":"Berkas VTSI berhasil dibuat#@Anda bisa menggunakan Rufus(3.15+) untuk menulisnya ke perangkat untuk menyelesaikan instalasi Ventoy.",
         "STR_VTSI_CREATE_FAILED":"Berkas VTSI gagal dibuat.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"Dette vil ikke skrive til enheten, men kun generere en VTSIfil#@Fortsett?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI-fil opprettet.#@Du kan bruke Rufus(3.15+) til å skrive den til enheten for å fullføre installasjonen av Ventoy.",
         "STR_VTSI_CREATE_FAILED":"Noe gikk galt under opprettelse av VTSI-fil.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"Цього разу Ventoy не буде встановлено на пристрій, а лише буде створено файл VTSI#@Продовжити?",
         "STR_VTSI_CREATE_SUCCESS":"Файл VTSI створено успішно!#@Ви можете використати Rufus(3.15+), щоб записати його на пристрій, для завершення встановлення Ventoy",
         "STR_VTSI_CREATE_FAILED":"Не вдалося створити файл VTSI.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"Den här gången skrivs det inget till enheten, utan det skapas endast en VTSI-fil#@Fortsätta?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI-filen skapad!#@Använd Rufus (3.15+) till att skriva till enheten för att slutföra installationen av Ventoy.",
         "STR_VTSI_CREATE_FAILED":"Misslyckades med att skapa VTSI-filen.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"Сега няма да се записва на диска, само ще се генерира VTSI файл#@Продължаваме?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI файла бе създаден успешно!#@Може да използвате Rufus(3.15+) да го запишете на устройството за инсталацията с Ventoy.",
         "STR_VTSI_CREATE_FAILED":"VTSI файла създаване се провали.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"Այս անգամ չի գրվի կրիչի վրա, այլ միայն կստեղծվի VTSI ֆայլ#@Շարունակել?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI ֆայլը հաջողությամբ ստեղծվեց!#@Դուք կարող եք օգտագործել Rufus (3.15+) կրիչում ձայնագրելու համար, որպեսզի ավարտեք Ventoy-ի տեղադրումը:",
         "STR_VTSI_CREATE_FAILED":"VTSI ֆայլի ստեղծումը ձախողվեց։",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     },
     {
         "STR_VTSI_CREATE_TIP":"Tällä kerralla laitteeseen ei kirjoiteta, vaan luodaan ainoastaan VTSI -tiedosto#@Jatketaanko?",
         "STR_VTSI_CREATE_SUCCESS":"VTSI -tiedosto luotiin onnistuneesti!#@Voit käyttää Rufus-ohjelmaa(3.15+) kirjoittaaksesi sen laitteeseen viimeistelläksesi Ventoy-asennuksen.",
         "STR_VTSI_CREATE_FAILED":"VTSI -tiedoston luominen epäonnistui.",
+        "STR_MENU_PART_RESIZE":"Non-destructive Install",
+        "STR_PART_RESIZE_TIP":"Ventoy will try non-destructive installation if possible. #@Continue?",
+        "STR_PART_RESIZE_SUCCESS":"Congratulations!#@Ventoy non-destructive installation successfully finished.",
+        "STR_PART_RESIZE_FAILED":"Non-destructive installation failed, Check log.txt for details.",
+        "STR_PART_RESIZE_UNSUPPORTED":"Ventoy non-destructive installation stopped because some conditions cannot be met. Check log.txt for details.",
+        
         "STRXXX":""
     }
-]
+]
\ No newline at end of file
index dd5b44c1710bc2afc96e645cee9b4a1b04453a9c..df5fab579eb2dbcebc09513729b9345fe47b9b14 100644 (file)
@@ -157,7 +157,9 @@ if [ "$1" = "VENTOY_I386_QT_BUILD" ]; then
     exit 0
 fi
 
-
+if [ ! -f /opt/CentOS8/LinuxGUI/build.sh ]; then
+    mount --bind /home/share/Ventoy/LinuxGUI /opt/CentOS8/LinuxGUI
+fi
 
 chroot /opt/CentOS8 sh /buildqt.sh
 force_copy ./Ventoy2Disk.qt5_32 ../INSTALL/tool/i386/Ventoy2Disk.qt5
index 95b8bbc48126150369cf1ffbfc0b1bb58a708e42..3ccbc99925598f6a2f580ab64e5622b98a24e36b 100644 (file)
@@ -42,6 +42,7 @@ BOOL VDS_CreateVtoyEFIPart(int DriveIndex, UINT64 Offset);
 BOOL VDS_ChangeVtoyEFI2ESP(int DriveIndex, UINT64 Offset);\r
 BOOL VDS_ChangeVtoyEFI2Basic(int DriveIndex, UINT64 Offset);\r
 BOOL VDS_FormatVtoyEFIPart(int DriveIndex, UINT64 Offset);\r
+BOOL VDS_ShrinkVolume(const char* VolumeGuid, UINT64 ReduceBytes);\r
 \r
 //diskpart.exe\r
 BOOL DSPT_CleanDisk(int DriveIndex);\r
index 55fd70a8ea2bf4def1a99768f9ee57b270053698..c53cc44aff952fa135382cd46d45d34b28661968 100644 (file)
 // 3. Filter out the crap we don't need.\r
 static const char *GetVdsError(DWORD error_code)\r
 {\r
+       static char code[32];\r
+\r
+       sprintf_s(code, sizeof(code), "[0x%08x]", error_code);\r
+\r
        switch (error_code) {\r
        case 0x80042400:        // VDS_E_NOT_SUPPORTED\r
                return "The operation is not supported by the object.";\r
@@ -450,7 +454,7 @@ static const char *GetVdsError(DWORD error_code)
        case 0x80042918:        // VDS_E_COMPRESSION_NOT_SUPPORTED\r
                return "The specified file system does not support compression.";\r
        default:\r
-               return NULL;\r
+               return code;\r
        }\r
 }\r
 \r
@@ -537,6 +541,8 @@ const char *WindowsErrorString(DWORD error_code)
 #define INTF_ADVANCEDDISK2  2\r
 #define INTF_CREATEPARTITIONEX  3\r
 #define INTF_PARTITIONMF 4\r
+#define INTF_VOLUME 5\r
+#define INTF_VOLUME_MF3 6\r
 \r
 /* \r
  * Some code and functions in the file are copied from rufus.\r
@@ -588,6 +594,8 @@ const char *WindowsErrorString(DWORD error_code)
 #define IVdsAsync_Wait(This,pHrResult,pAsyncOut) (This)->lpVtbl->Wait(This,pHrResult,pAsyncOut)\r
 #define IVdsAsync_Release(This) (This)->lpVtbl->Release(This)\r
 \r
+#define IVdsVolume_Shrink(This, ullNumberOfBytesToRemove, ppAsync) (This)->lpVtbl->Shrink(This, ullNumberOfBytesToRemove, ppAsync)\r
+\r
 #define IUnknown_QueryInterface(This, a, b) (This)->lpVtbl->QueryInterface(This,a,b)\r
 #define IUnknown_Release(This) (This)->lpVtbl->Release(This)\r
 \r
@@ -635,6 +643,162 @@ STATIC IVdsService * VDS_InitService(void)
     return pService;\r
 }\r
 \r
+STATIC BOOL VDS_VolumeCommProc(int intf, const WCHAR* wVolumeGuid, VDS_Callback_PF callback, UINT64 data)\r
+{\r
+       int Pos = 0;\r
+       BOOL Find = FALSE;\r
+       BOOL r = FALSE;\r
+       HRESULT hr;\r
+       ULONG ulFetched;\r
+       IUnknown* pUnk = NULL;\r
+       IEnumVdsObject* pEnum = NULL;\r
+       IVdsService* pService = NULL;\r
+\r
+       pService = VDS_InitService();\r
+       if (!pService)\r
+       {\r
+               Log("Could not query VDS Service");\r
+               goto out;\r
+       }\r
+\r
+       // Query the VDS Service Providers\r
+       hr = IVdsService_QueryProviders(pService, VDS_QUERY_SOFTWARE_PROVIDERS, &pEnum);\r
+       if (hr != S_OK)\r
+       {\r
+               VDS_SET_ERROR(hr);\r
+               Log("Could not query VDS Service Providers: 0x%lx %u", hr, LASTERR);\r
+               goto out;\r
+       }\r
+\r
+       while (IEnumVdsObject_Next(pEnum, 1, &pUnk, &ulFetched) == S_OK)\r
+       {\r
+               IVdsProvider* pProvider;\r
+               IVdsSwProvider* pSwProvider;\r
+               IEnumVdsObject* pEnumPack;\r
+               IUnknown* pPackUnk;\r
+\r
+               // Get VDS Provider\r
+               hr = IUnknown_QueryInterface(pUnk, &IID_IVdsProvider, (void**)&pProvider);\r
+               IUnknown_Release(pUnk);\r
+               if (hr != S_OK)\r
+               {\r
+                       VDS_SET_ERROR(hr);\r
+                       Log("Could not get VDS Provider: %u", LASTERR);\r
+                       goto out;\r
+               }\r
+\r
+               // Get VDS Software Provider\r
+               hr = IVdsSwProvider_QueryInterface(pProvider, &IID_IVdsSwProvider, (void**)&pSwProvider);\r
+               IVdsProvider_Release(pProvider);\r
+               if (hr != S_OK)\r
+               {\r
+                       VDS_SET_ERROR(hr);\r
+                       Log("Could not get VDS Software Provider: %u", LASTERR);\r
+                       goto out;\r
+               }\r
+\r
+               // Get VDS Software Provider Packs\r
+               hr = IVdsSwProvider_QueryPacks(pSwProvider, &pEnumPack);\r
+               IVdsSwProvider_Release(pSwProvider);\r
+               if (hr != S_OK)\r
+               {\r
+                       VDS_SET_ERROR(hr);\r
+                       Log("Could not get VDS Software Provider Packs: %u", LASTERR);\r
+                       goto out;\r
+               }\r
+\r
+               // Enumerate Provider Packs\r
+               while (IEnumVdsObject_Next(pEnumPack, 1, &pPackUnk, &ulFetched) == S_OK)\r
+               {\r
+                       IVdsPack* pPack;\r
+                       IEnumVdsObject* pEnumVolume;\r
+                       IUnknown* pVolumeUnk;\r
+\r
+                       hr = IUnknown_QueryInterface(pPackUnk, &IID_IVdsPack, (void**)&pPack);\r
+                       IUnknown_Release(pPackUnk);\r
+                       if (hr != S_OK)\r
+                       {\r
+                               VDS_SET_ERROR(hr);\r
+                               Log("Could not query VDS Software Provider Pack: %u", LASTERR);\r
+                               goto out;\r
+                       }\r
+\r
+                       // Use the pack interface to access the volume\r
+                       hr = IVdsPack_QueryVolumes(pPack, &pEnumVolume);;\r
+                       if (hr != S_OK) {\r
+                               VDS_SET_ERROR(hr);\r
+                               Log("Could not query VDS volume: %u", LASTERR);\r
+                               goto out;\r
+                       }\r
+\r
+                       // List disks\r
+                       while (IEnumVdsObject_Next(pEnumVolume, 1, &pVolumeUnk, &ulFetched) == S_OK)\r
+                       {\r
+                               IVdsVolume* pVolume;\r
+                               IVdsVolumeMF3* pVolumeMF3;\r
+                               LPWSTR* wszPathArray;\r
+                               ULONG ulNumberOfPaths;\r
+\r
+                               // Get the disk interface.\r
+                               hr = IUnknown_QueryInterface(pVolumeUnk, &IID_IVdsVolumeMF3, (void**)&pVolumeMF3);\r
+                               if (hr != S_OK) {\r
+                                       VDS_SET_ERROR(hr);\r
+                                       Log("Could not query VDS Volume Interface: %u", LASTERR);\r
+                                       goto out;\r
+                               }\r
+\r
+                               // Get the volume properties\r
+                               hr = IVdsVolumeMF3_QueryVolumeGuidPathnames(pVolumeMF3, &wszPathArray, &ulNumberOfPaths);\r
+                               if ((hr != S_OK) && (hr != VDS_S_PROPERTIES_INCOMPLETE)) \r
+                               {\r
+                                       Log("Could not query VDS VolumeMF3 GUID PathNames: %s", GetVdsError(hr));\r
+                                       IVdsVolume_Release(pVolumeMF3);\r
+                                       IUnknown_Release(pVolumeUnk);\r
+                                       continue;\r
+                               }\r
+\r
+                               Log("Get Volume %d %lu <%S>", intf, ulNumberOfPaths, wszPathArray[0]);\r
+\r
+                               if ((ulNumberOfPaths >= 1) && wcsstr(wszPathArray[0], wVolumeGuid))\r
+                               {\r
+                                       Find = TRUE;\r
+                                       Log("Call back for this Volume %d <%S>", intf, wVolumeGuid);\r
+\r
+                                       if (INTF_VOLUME_MF3 == intf)\r
+                                       {\r
+                                               r = callback(pVolumeMF3, NULL, data);\r
+                                       }\r
+                                       else if (INTF_VOLUME == intf)\r
+                                       {\r
+                                               // Get the disk interface.\r
+                                               hr = IUnknown_QueryInterface(pVolumeUnk, &IID_IVdsVolume, (void**)&pVolume);\r
+                                               if (hr != S_OK) {\r
+                                                       VDS_SET_ERROR(hr);\r
+                                                       Log("Could not query VDS Volume Interface: %u", LASTERR);\r
+                                               }\r
+                                               else {\r
+                                                       r = callback(pVolume, NULL, data);\r
+                                                       IVdsVolume_Release(pVolume);\r
+                                               }\r
+                                       }\r
+                               }\r
+\r
+                               CoTaskMemFree(wszPathArray);\r
+                               IVdsVolume_Release(pVolumeMF3);\r
+                               IUnknown_Release(pVolumeUnk);\r
+\r
+                               if (Find)\r
+                               {\r
+                                       goto out;\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+out:\r
+       return r;\r
+}\r
+\r
 \r
 STATIC BOOL VDS_DiskCommProc(int intf, int DriveIndex, VDS_Callback_PF callback, UINT64 data)\r
 {\r
@@ -1222,3 +1386,72 @@ BOOL VDS_FormatVtoyEFIPart(int DriveIndex, UINT64 Offset)
        return ret;\r
 }\r
 \r
+STATIC BOOL VDS_CallBack_ShrinkVolume(void* pInterface, VDS_DISK_PROP* pDiskProp, UINT64 data)\r
+{\r
+       HRESULT hr, hr2;\r
+       IVdsVolume* pVolume = (IVdsVolume*)pInterface;\r
+       ULONG completed;\r
+       IVdsAsync* pAsync;\r
+\r
+       (void)pDiskProp;\r
+\r
+       Log("VDS_CallBack_ShrinkVolume (%llu) ...", (ULONGLONG)data);\r
+\r
+       hr = IVdsVolume_Shrink(pVolume, (ULONGLONG)data, &pAsync);\r
+\r
+       while (SUCCEEDED(hr))\r
+       {\r
+               hr = IVdsAsync_QueryStatus(pAsync, &hr2, &completed);\r
+               if (SUCCEEDED(hr))\r
+               {\r
+                       hr = hr2;\r
+                       if (hr == S_OK)\r
+                       {\r
+                               Log("ShrinkVolume QueryStatus OK, %lu%%", completed);\r
+                               break;\r
+                       }\r
+                       else if (hr == VDS_E_OPERATION_PENDING)\r
+                       {\r
+                               Log("ShrinkVolume: %lu%%", completed);\r
+                               hr = S_OK;\r
+                       }\r
+                       else\r
+                       {\r
+                               Log("ShrinkVolume invalid status:0x%lx", hr);\r
+                       }\r
+               }\r
+               Sleep(1000);\r
+       }\r
+\r
+       if (hr != S_OK)\r
+       {\r
+               VDS_SET_ERROR(hr);\r
+               Log("Could not ShrinkVolume, 0x%x err:0x%lx (%s)", hr, LASTERR, WindowsErrorString(hr));\r
+               return FALSE;\r
+       }\r
+\r
+       return TRUE;\r
+}\r
+\r
+BOOL VDS_ShrinkVolume(const char* VolumeGuid, UINT64 ReduceBytes)\r
+{\r
+       int i;\r
+       BOOL ret = FALSE;\r
+       WCHAR wGuid[128] = { 0 };\r
+       const char *guid = NULL;\r
+\r
+       guid = strstr(VolumeGuid, "{");\r
+       if (!guid)\r
+       {\r
+               return FALSE;\r
+       }\r
+\r
+       for (i = 0; i < 128 && guid[i]; i++)\r
+       {\r
+               wGuid[i] = guid[i];\r
+       }\r
+\r
+       ret = VDS_VolumeCommProc(INTF_VOLUME, wGuid, VDS_CallBack_ShrinkVolume, ReduceBytes);\r
+       Log("VDS_ShrinkVolume ret:%d (%s)", ret, ret ? "SUCCESS" : "FAIL");\r
+       return ret;\r
+}
\ No newline at end of file
index 72491a38753992e71398d89a095f5bfade9848fb..00c4618d4a74bc889f112715bbc3ded21f2eb907 100644 (file)
@@ -77,6 +77,12 @@ typedef enum STR_ID
     STR_VTSI_CREATE_SUCCESS, //41\r
     STR_VTSI_CREATE_FAILED, //42\r
 \r
+       STR_MENU_PART_RESIZE,//43\r
+       STR_PART_RESIZE_TIP,//44\r
+       STR_PART_RESIZE_SUCCESS,//45\r
+       STR_PART_RESIZE_FAILED,//46\r
+       STR_PART_RESIZE_UNSUPPORTED,//47\r
+\r
        STR_ID_MAX\r
 }STR_ID;\r
 \r
@@ -90,6 +96,7 @@ extern BOOL g_SecureBoot;
 #define VTOY_MENU_PART_GPT        0xA005\r
 #define VTOY_MENU_ALL_DEV         0xA006\r
 #define VTOY_MENU_VTSI            0xA007\r
+#define VTOY_MENU_PART_RESIZE     0xA008\r
 \r
 \r
 typedef enum OPT_SUBMENU\r
@@ -100,6 +107,7 @@ typedef enum OPT_SUBMENU
     OPT_SUBMENU_CLEAR,\r
     OPT_SUBMENU_ALL_DEV,\r
     OPT_SUBMENU_VTSI,\r
+       OPT_SUBMENU_PART_RESIZE,\r
 \r
     OPT_SUBMENU_MAX\r
 }OPT_SUBMENU;\r
index 774cf9cae7101c23128c5040be2a7455e454e29a..182a718e5af1dfad45559ce4eac91ec8e53b5759 100644 (file)
 \r
 static int g_backup_bin_index = 0;\r
 \r
+\r
+static BOOL WriteDataToPhyDisk(HANDLE hDrive, UINT64 Offset, VOID *buffer, DWORD len)\r
+{\r
+       BOOL bRet;\r
+       DWORD dwSize = 0;\r
+       LARGE_INTEGER liCurPosition;\r
+       LARGE_INTEGER liNewPosition;\r
+\r
+       liCurPosition.QuadPart = (LONGLONG)Offset;\r
+       liNewPosition.QuadPart = 0;\r
+       if (0 == SetFilePointerEx(hDrive, liCurPosition, &liNewPosition, FILE_BEGIN) ||\r
+               liNewPosition.QuadPart != liCurPosition.QuadPart)\r
+       {\r
+               Log("SetFilePointerEx Failed %u", LASTERR);\r
+               return FALSE;\r
+       }\r
+\r
+       bRet = WriteFile(hDrive, buffer, len, &dwSize, NULL);\r
+       if (bRet == FALSE || dwSize != len)\r
+       {\r
+               Log("Write file error %u %u", dwSize, LASTERR);\r
+               return FALSE;\r
+       }\r
+\r
+       return TRUE;\r
+}\r
+\r
+\r
 static DWORD GetVentoyVolumeName(int PhyDrive, UINT64 StartSectorId, CHAR *NameBuf, UINT32 BufLen, BOOL DelSlash)\r
 {\r
     size_t len;\r
@@ -129,7 +157,7 @@ static int GetLettersBelongPhyDrive(int PhyDrive, char *DriveLetters, size_t Len
 \r
     for (Pos = StringBuf; *Pos; Pos += strlen(Pos) + 1)\r
     {\r
-        if (n < (int)Length && PhyDrive == GetPhyDriveByLogicalDrive(Pos[0]))\r
+        if (n < (int)Length && PhyDrive == GetPhyDriveByLogicalDrive(Pos[0], NULL))\r
         {\r
             Log("%C: is belong to phydrive%d", Pos[0], PhyDrive);\r
             DriveLetters[n++] = Pos[0];\r
@@ -140,7 +168,7 @@ static int GetLettersBelongPhyDrive(int PhyDrive, char *DriveLetters, size_t Len
     return 0;\r
 }\r
 \r
-static HANDLE GetPhysicalHandle(int Drive, BOOLEAN bLockDrive, BOOLEAN bWriteAccess, BOOLEAN bWriteShare)\r
+HANDLE GetPhysicalHandle(int Drive, BOOLEAN bLockDrive, BOOLEAN bWriteAccess, BOOLEAN bWriteShare)\r
 {\r
     int i;\r
     DWORD dwSize;\r
@@ -260,7 +288,7 @@ End:
     return hDrive;\r
 }\r
 \r
-int GetPhyDriveByLogicalDrive(int DriveLetter)\r
+int GetPhyDriveByLogicalDrive(int DriveLetter, UINT64 *Offset)\r
 {\r
     BOOL Ret;\r
     DWORD dwSize;\r
@@ -301,6 +329,11 @@ int GetPhyDriveByLogicalDrive(int DriveLetter)
         DiskExtents.Extents[0].ExtentLength.QuadPart\r
         );\r
 \r
+       if (Offset)\r
+       {\r
+               *Offset = (UINT64)(DiskExtents.Extents[0].StartingOffset.QuadPart);\r
+       }\r
+\r
     return (int)DiskExtents.Extents[0].DiskNumber;\r
 }\r
 \r
@@ -335,7 +368,7 @@ int GetAllPhysicalDriveInfo(PHY_DRIVE_INFO *pDriveList, DWORD *pDriveCount)
     {\r
         if (dwBytes & 0x01)\r
         {\r
-            id = GetPhyDriveByLogicalDrive(Letter);\r
+                       id = GetPhyDriveByLogicalDrive(Letter, NULL);\r
             Log("%C --> %d", Letter, id);\r
             if (id >= 0)\r
             {\r
@@ -842,7 +875,7 @@ static int FormatPart2Fat(HANDLE hDrive, UINT64 StartSectorId)
        LARGE_INTEGER liNewPosition;\r
     BYTE *CheckBuf = NULL;\r
 \r
-       Log("FormatPart2Fat %llu...", StartSectorId);\r
+       Log("FormatPart2Fat %llu...", (ULONGLONG)StartSectorId);\r
 \r
     CheckBuf = malloc(SIZE_1MB);\r
     if (!CheckBuf)\r
@@ -1830,6 +1863,269 @@ End:
     return rc;\r
 }\r
 \r
+\r
+int PartitionResizeForVentoy(PHY_DRIVE_INFO *pPhyDrive)\r
+{\r
+       int i, j;\r
+       int rc = 1;\r
+       int PhyDrive;\r
+       int PartStyle;\r
+       INT64 ReservedValue;\r
+       UINT64 RecudeBytes;\r
+       GUID Guid;\r
+       MBR_HEAD MBR;\r
+       VTOY_GPT_INFO *pGPT;\r
+       MBR_HEAD *pMBR;\r
+       DWORD dwSize = 0;\r
+       VTOY_GPT_HDR BackupHead;\r
+       HANDLE hDrive = INVALID_HANDLE_VALUE;\r
+       GUID ZeroGuid = { 0 };\r
+       static GUID WindowsDataPartType = { 0xebd0a0a2, 0xb9e5, 0x4433, { 0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 } };\r
+       static GUID EspPartType = { 0xc12a7328, 0xf81f, 0x11d2, { 0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b } };\r
+       static GUID BiosGrubPartType = { 0x21686148, 0x6449, 0x6e6f, { 0x74, 0x4e, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } };\r
+\r
+       Log("#####################################################");\r
+       Log("PartitionResizeForVentoy PhyDrive%d <<%s %s %dGB>>",\r
+               pPhyDrive->PhyDrive, pPhyDrive->VendorId, pPhyDrive->ProductId,\r
+               GetHumanReadableGBSize(pPhyDrive->SizeInBytes));\r
+       Log("#####################################################");\r
+\r
+       pGPT = &(pPhyDrive->Gpt);\r
+       pMBR = &(pPhyDrive->Gpt.MBR);\r
+       Log("Disksize:%llu Part2Start:%llu", pPhyDrive->SizeInBytes, pPhyDrive->ResizePart2StartSector * 512);\r
+\r
+       if (pMBR->PartTbl[0].FsFlag == 0xEE && memcmp(pGPT->Head.Signature, "EFI PART", 8) == 0)\r
+       {\r
+               PartStyle = 1;\r
+       }\r
+       else\r
+       {\r
+               PartStyle = 0;\r
+       }\r
+\r
+       PROGRESS_BAR_SET_POS(PT_LOCK_FOR_CLEAN);\r
+\r
+       RecudeBytes = VENTOY_EFI_PART_SIZE;\r
+       ReservedValue = GetReservedSpaceInMB();\r
+       if (ReservedValue > 0)\r
+       {\r
+               Log("Reduce add reserved space %lldMB", (LONGLONG)ReservedValue);\r
+               RecudeBytes += (UINT64)(ReservedValue * SIZE_1MB);\r
+       }\r
+\r
+\r
+       if (pPhyDrive->ResizeNoShrink == FALSE)\r
+       {\r
+               Log("Need to shrink the volume");\r
+               if (VDS_ShrinkVolume(pPhyDrive->ResizeVolumeGuid, RecudeBytes))\r
+               {\r
+                       Log("Shrink volume success, now check again");\r
+\r
+                       hDrive = GetPhysicalHandle(pPhyDrive->PhyDrive, TRUE, TRUE, FALSE);\r
+                       if (hDrive == INVALID_HANDLE_VALUE)\r
+                       {\r
+                               Log("Failed to GetPhysicalHandle for update.");\r
+                               goto End;\r
+                       }\r
+\r
+                       //Refresh Drive Layout\r
+                       DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &dwSize, NULL);\r
+\r
+                       CHECK_CLOSE_HANDLE(hDrive);\r
+\r
+\r
+                       if (PartResizePreCheck(NULL) && pPhyDrive->ResizeNoShrink)\r
+                       {\r
+                               Log("Recheck after Shrink volume success");\r
+                               Log("After shrink Disksize:%llu Part2Start:%llu", pPhyDrive->SizeInBytes, pPhyDrive->ResizePart2StartSector * 512);\r
+                       }\r
+                       else\r
+                       {\r
+                               Log("Recheck after Shrink volume failed %u", pPhyDrive->ResizeNoShrink);\r
+                               goto End;\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       Log("Shrink volume failed");\r
+                       goto End;\r
+               }\r
+       }\r
+\r
+\r
+       //Now try write data\r
+       hDrive = GetPhysicalHandle(pPhyDrive->PhyDrive, TRUE, TRUE, FALSE);\r
+       if (hDrive == INVALID_HANDLE_VALUE)\r
+       {\r
+               Log("Failed to GetPhysicalHandle for update.");\r
+               goto End;\r
+       }\r
+\r
+\r
+       //Write partition 2 data\r
+       PROGRESS_BAR_SET_POS(PT_FORMAT_PART2);\r
+       if (0 != FormatPart2Fat(hDrive, pPhyDrive->ResizePart2StartSector))\r
+       {\r
+               Log("FormatPart2Fat failed.");\r
+               goto End;\r
+       }\r
+\r
+       //Write grub stage2 gap\r
+       PROGRESS_BAR_SET_POS(PT_WRITE_STG1_IMG);\r
+       Log("Writing Boot Image ............................. ");\r
+       if (WriteGrubStage1ToPhyDrive(hDrive, PartStyle) != 0)\r
+       {\r
+               Log("WriteGrubStage1ToPhyDrive failed.");\r
+               goto End;\r
+       }\r
+\r
+\r
+       //Write partition table\r
+       PROGRESS_BAR_SET_POS(PT_WRITE_PART_TABLE);\r
+       Log("Writing partition table ............................. ");\r
+\r
+       VentoyGetLocalBootImg(&MBR);\r
+       CoCreateGuid(&Guid);\r
+       memcpy(MBR.BootCode + 0x180, &Guid, 16);\r
+       memcpy(pMBR->BootCode, MBR.BootCode, 440);\r
+\r
+       if (PartStyle == 0)\r
+       {\r
+               for (i = 1; i < 4; i++)\r
+               {\r
+                       if (pMBR->PartTbl[i].SectorCount == 0)\r
+                       {\r
+                               break;\r
+                       }\r
+               }\r
+\r
+               if (i >= 4)\r
+               {\r
+                       Log("Can not find MBR free partition table");\r
+                       goto End;\r
+               }\r
+\r
+               for (j = i - 1; j > 0; j--)\r
+               {\r
+                       Log("Move MBR partition table %d --> %d", j + 1, j + 2);\r
+                       memcpy(pMBR->PartTbl + (j + 1), pMBR->PartTbl + j, sizeof(PART_TABLE));\r
+               }\r
+\r
+               VentoyFillMBRLocation(pPhyDrive->SizeInBytes, (UINT32)pPhyDrive->ResizePart2StartSector, VENTOY_EFI_PART_SIZE / 512, pMBR->PartTbl + 1);\r
+               pMBR->PartTbl[0].Active = 0x80; // bootable\r
+               pMBR->PartTbl[1].Active = 0x00;\r
+               pMBR->PartTbl[1].FsFlag = 0xEF; // EFI System Partition\r
+\r
+               if (!WriteDataToPhyDisk(hDrive, 0, pMBR, 512))\r
+               {\r
+                       Log("Legacy BIOS write MBR failed");\r
+                       goto End;\r
+               }\r
+       }\r
+       else\r
+       {\r
+               for (i = 1; i < 128; i++)\r
+               {\r
+                       if (memcmp(&(pGPT->PartTbl[i].PartGuid), &ZeroGuid, sizeof(GUID)) == 0)\r
+                       {\r
+                               break;\r
+                       }\r
+               }\r
+\r
+               if (i >= 128)\r
+               {\r
+                       Log("Can not find GPT free partition table");\r
+                       goto End;\r
+               }\r
+\r
+               for (j = i - 1; j > 0; j--)\r
+               {\r
+                       Log("Move GPT partition table %d --> %d", j + 1, j + 2);\r
+                       memcpy(pGPT->PartTbl + (j + 1), pGPT->PartTbl + j, sizeof(VTOY_GPT_PART_TBL));\r
+               }\r
+\r
+\r
+               pMBR->BootCode[92] = 0x22;\r
+\r
+               // to fix windows issue\r
+               memcpy(&(pGPT->PartTbl[1].PartType), &WindowsDataPartType, sizeof(GUID));\r
+               CoCreateGuid(&(pGPT->PartTbl[1].PartGuid));\r
+\r
+               pGPT->PartTbl[1].StartLBA = pGPT->PartTbl[0].LastLBA + 1;\r
+               pGPT->PartTbl[1].LastLBA = pGPT->PartTbl[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1;\r
+               pGPT->PartTbl[1].Attr = 0xC000000000000001ULL;\r
+               memcpy(pGPT->PartTbl[1].Name, L"VTOYEFI", 7 * 2);\r
+\r
+               //Update CRC\r
+               pGPT->Head.PartTblCrc = VentoyCrc32(pGPT->PartTbl, sizeof(pGPT->PartTbl));\r
+               pGPT->Head.Crc = VentoyCrc32(&(pGPT->Head), pGPT->Head.Length);\r
+\r
+               Log("pGPT->Head.EfiStartLBA=%llu", (ULONGLONG)pGPT->Head.EfiStartLBA);\r
+               Log("pGPT->Head.EfiBackupLBA=%llu", (ULONGLONG)pGPT->Head.EfiBackupLBA);\r
+\r
+               VentoyFillBackupGptHead(pGPT, &BackupHead);\r
+               if (!WriteDataToPhyDisk(hDrive, pGPT->Head.EfiBackupLBA * 512, &BackupHead, 512))\r
+               {\r
+                       Log("UEFI write backup head failed");\r
+                       goto End;\r
+               }\r
+\r
+               if (!WriteDataToPhyDisk(hDrive, (pGPT->Head.EfiBackupLBA - 32) * 512, pGPT->PartTbl, 512 * 32))\r
+               {\r
+                       Log("UEFI write backup partition table failed");\r
+                       goto End;\r
+               }\r
+\r
+               if (!WriteDataToPhyDisk(hDrive, 0, pGPT, 512 * 34))\r
+               {\r
+                       Log("UEFI write MBR & Main partition table failed");\r
+                       goto End;\r
+               }\r
+       }\r
+\r
+\r
+\r
+       //Refresh Drive Layout\r
+       DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &dwSize, NULL);\r
+       \r
+       //We must close handle here, because it will block the refresh bellow\r
+       CHECK_CLOSE_HANDLE(hDrive);\r
+\r
+       Sleep(2000);\r
+\r
+       //Refresh disk list\r
+       PhyDrive = pPhyDrive->PhyDrive;\r
+\r
+       Log("#### Now Refresh PhyDrive ####");\r
+       Ventoy2DiskDestroy();\r
+       Ventoy2DiskInit();\r
+       \r
+       pPhyDrive = GetPhyDriveInfoByPhyDrive(PhyDrive);\r
+       if (pPhyDrive)\r
+       {\r
+               if (pPhyDrive->VentoyVersion[0] == 0)\r
+               {\r
+                       Log("After process the Ventoy version is still invalid");\r
+                       goto End;\r
+               }\r
+\r
+               Log("### Ventoy non-destructive installation successfully finished <%s>", pPhyDrive->VentoyVersion);\r
+       }\r
+       else\r
+       {\r
+               Log("### Ventoy non-destructive installation successfully finished <not found>");\r
+       }\r
+\r
+       InitComboxCtrl(g_DialogHwnd, PhyDrive);\r
+\r
+       rc = 0;\r
+\r
+End:\r
+       CHECK_CLOSE_HANDLE(hDrive);\r
+       return rc;\r
+}\r
+\r
+\r
 static BOOL DiskCheckWriteAccess(HANDLE hDrive)\r
 {\r
        DWORD dwSize;\r
index 1fbe9f4434ac37beaaeeb855e999ba315a3ec3b1..d2d31887ef6b6d6f32e4cd8338306ac3c8acc21d 100644 (file)
@@ -583,6 +583,7 @@ void DumpWindowsVersion(void)
     return;\r
 }\r
 \r
+\r
 BOOL IsVentoyLogicalDrive(CHAR DriveLetter)\r
 {\r
     int i;\r
@@ -666,6 +667,7 @@ int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR, int PartStyle)
     Log("Disk signature: 0x%08x", DiskSignature);\r
 \r
     *((UINT32 *)(pMBR->BootCode + 0x1B8)) = DiskSignature;\r
+       memcpy(pMBR->BootCode + 0x180, &Guid, 16);\r
 \r
     if (DiskSizeBytes / 512 > 0xFFFFFFFF)\r
     {\r
@@ -742,6 +744,7 @@ static int VentoyFillProtectMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR)
     Log("Disk signature: 0x%08x", DiskSignature);\r
 \r
     *((UINT32 *)(pMBR->BootCode + 0x1B8)) = DiskSignature;\r
+       memcpy(pMBR->BootCode + 0x180, &Guid, 16);\r
 \r
     DiskSectorCount = DiskSizeBytes / 512 - 1;\r
     if (DiskSectorCount > 0xFFFFFFFF)\r
index 5ba9e71ae7f1adbb0fe1d8f72bc942462e4aa29b..2f7d23346b3f89d6dff8cc69b1561cbde40e942b 100644 (file)
@@ -110,7 +110,7 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UIN
 \r
        for (i = 0; i < 4; i++)\r
        {\r
-               Log("=========== Partition Table %d ============", i + 1);\r
+               Log("=========== Disk%d Partition Table %d ============", PhyDrive, i + 1);\r
                Log("PartTbl.Active = 0x%x", MBR.PartTbl[i].Active);\r
                Log("PartTbl.FsFlag = 0x%x", MBR.PartTbl[i].FsFlag);\r
                Log("PartTbl.StartSectorId = %u", MBR.PartTbl[i].StartSectorId);\r
@@ -246,7 +246,7 @@ static int FilterPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount)
         if (LogDrive & 0x01)\r
         {\r
             LogLetter[LetterCount] = Letter;\r
-            PhyDriveId[LetterCount] = GetPhyDriveByLogicalDrive(Letter);\r
+                       PhyDriveId[LetterCount] = GetPhyDriveByLogicalDrive(Letter, NULL);\r
 \r
             Log("Logical Drive:%C  ===> PhyDrive:%d", LogLetter[LetterCount], PhyDriveId[LetterCount]);\r
             LetterCount++;\r
@@ -332,6 +332,23 @@ PHY_DRIVE_INFO * GetPhyDriveInfoById(int Id)
     return NULL;\r
 }\r
 \r
+\r
+PHY_DRIVE_INFO * GetPhyDriveInfoByPhyDrive(int PhyDrive)\r
+{\r
+       DWORD i;\r
+       for (i = 0; i < g_PhyDriveCount; i++)\r
+       {\r
+               if (g_PhyDriveList[i].PhyDrive == PhyDrive)\r
+               {\r
+                       return g_PhyDriveList + i;\r
+               }\r
+       }\r
+\r
+       return NULL;\r
+}\r
+\r
+\r
+\r
 int SortPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount)\r
 {\r
        DWORD i, j;\r
@@ -398,5 +415,8 @@ int Ventoy2DiskInit(void)
 int Ventoy2DiskDestroy(void)\r
 {\r
     free(g_PhyDriveList);\r
+       g_PhyDriveList = NULL;\r
+       g_PhyDriveCount = 0;\r
+\r
     return 0;\r
 }\r
index 8b77ea1e9b19eb0a33bd38cddadcc187d8726ded..fedcd0bad21f683032d8f725828370ca253a2eb4 100644 (file)
@@ -23,6 +23,7 @@
 \r
 #include <stdio.h>\r
 \r
+#define SIZE_1GB                                       (1024 * 1024 * 1024)\r
 #define SIZE_1MB                    (1024 * 1024)\r
 #define SIZE_2MB                    (2048 * 1024)\r
 #define VENTOY_EFI_PART_SIZE       (32 * SIZE_1MB)\r
 #define safe_sprintf(dst, fmt, ...) sprintf_s(dst, sizeof(dst), fmt, __VA_ARGS__)\r
 #define safe_strcpy(dst, src)  strcpy_s(dst, sizeof(dst), src)\r
 \r
+#define CHECK_FREE(p) \\r
+{\\r
+    if (p)\\r
+    {\\r
+        free(p); \\r
+        (p) = NULL; \\r
+    }\\r
+}\r
+\r
 #define CHECK_CLOSE_HANDLE(Handle) \\r
 {\\r
     if (Handle != INVALID_HANDLE_VALUE) \\r
@@ -155,6 +165,13 @@ typedef struct PHY_DRIVE_INFO
     BOOL SecureBootSupport;\r
     MBR_HEAD MBR;\r
     UINT64 Part2GPTAttr;\r
+\r
+       BOOL ResizeNoShrink;\r
+    CHAR ResizeVolumeGuid[64];\r
+       CHAR FsName[64];\r
+       UINT64 ResizePart2StartSector;\r
+       VTOY_GPT_INFO Gpt;\r
+\r
 }PHY_DRIVE_INFO;\r
 \r
 typedef enum PROGRESS_POINT\r
@@ -206,13 +223,15 @@ BOOL IsVentoyLogicalDrive(CHAR DriveLetter);
 int GetRegDwordValue(HKEY Key, LPCSTR SubKey, LPCSTR ValueName, DWORD *pValue);\r
 int GetPhysicalDriveCount(void);\r
 int GetAllPhysicalDriveInfo(PHY_DRIVE_INFO *pDriveList, DWORD *pDriveCount);\r
-int GetPhyDriveByLogicalDrive(int DriveLetter);\r
+int GetPhyDriveByLogicalDrive(int DriveLetter, UINT64*Offset);\r
 int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, UINT64 Part2StartSector, CHAR *VerBuf, size_t BufLen, BOOL *pSecureBoot);\r
 int Ventoy2DiskInit(void);\r
 int Ventoy2DiskDestroy(void);\r
 PHY_DRIVE_INFO * GetPhyDriveInfoById(int Id);\r
+PHY_DRIVE_INFO * GetPhyDriveInfoByPhyDrive(int PhyDrive);\r
 int ParseCmdLineOption(LPSTR lpCmdLine);\r
 int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle, int TryId);\r
+int PartitionResizeForVentoy(PHY_DRIVE_INFO *pPhyDrive);\r
 int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId);\r
 int VentoyFillBackupGptHead(VTOY_GPT_INFO *pInfo, VTOY_GPT_HDR *pHead);\r
 int VentoyFillWholeGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo);\r
@@ -232,6 +251,7 @@ int FindProcessOccupyDisk(HANDLE hDrive, PHY_DRIVE_INFO *pPhyDrive);
 int VentoyFillMBRLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table);\r
 int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLetter);\r
 UINT32 VentoyCrc32(void *Buffer, UINT32 Length);\r
+BOOL PartResizePreCheck(PHY_DRIVE_INFO** ppPhyDrive);\r
 \r
 #define SET_FILE_POS(pos) \\r
     liCurrentPosition.QuadPart = pos; \\r
@@ -290,12 +310,15 @@ typedef struct {
 #pragma pack()\r
 extern int __static_assert__[sizeof(VTSI_FOOTER) == 512 ? 1 : -1];\r
 \r
+extern HWND g_DialogHwnd;\r
 \r
 #define SAFE_FREE(ptr) if (ptr) { free(ptr); (ptr) = NULL; }\r
 int InstallVentoy2FileImage(PHY_DRIVE_INFO *pPhyDrive, int PartStyle);\r
 void disk_io_set_imghook(FILE *fp, VTSI_SEGMENT *segment, int maxseg, UINT64 data_offset);\r
 void disk_io_reset_imghook(int *psegnum, UINT64 *pDataOffset);\r
 \r
+HANDLE GetPhysicalHandle(int Drive, BOOLEAN bLockDrive, BOOLEAN bWriteAccess, BOOLEAN bWriteShare);\r
+void InitComboxCtrl(HWND hWnd, int PhyDrive);\r
 \r
 #define VTSI_SUPPORT 1\r
 \r
index 63cf2fee3e76d56e704a01c3a01007f74f228655..9cebd76ccba0a5ca3c27cdd60921a563d2ae6644 100644 (file)
Binary files a/Ventoy2Disk/Ventoy2Disk/WinDialog.c and b/Ventoy2Disk/Ventoy2Disk/WinDialog.c differ