Commit d1481392 authored by longpanda's avatar longpanda
Browse files

Add QT GUI install program

parent dd2411d7
...@@ -588,6 +588,7 @@ static int VentoyAttachVirtualDisk(HANDLE Handle, const char *IsoPath) ...@@ -588,6 +588,7 @@ static int VentoyAttachVirtualDisk(HANDLE Handle, const char *IsoPath)
int VentoyMountISOByAPI(const char *IsoPath) int VentoyMountISOByAPI(const char *IsoPath)
{ {
int i;
HANDLE Handle; HANDLE Handle;
DWORD Status; DWORD Status;
WCHAR wFilePath[512] = { 0 }; WCHAR wFilePath[512] = { 0 };
...@@ -598,10 +599,12 @@ int VentoyMountISOByAPI(const char *IsoPath) ...@@ -598,10 +599,12 @@ int VentoyMountISOByAPI(const char *IsoPath)
if (IsUTF8Encode(IsoPath)) if (IsUTF8Encode(IsoPath))
{ {
Log("This is UTF8 encoding");
MultiByteToWideChar(CP_UTF8, 0, IsoPath, (int)strlen(IsoPath), wFilePath, (int)(sizeof(wFilePath) / sizeof(WCHAR))); MultiByteToWideChar(CP_UTF8, 0, IsoPath, (int)strlen(IsoPath), wFilePath, (int)(sizeof(wFilePath) / sizeof(WCHAR)));
} }
else else
{ {
Log("This is ANSI encoding");
MultiByteToWideChar(CP_ACP, 0, IsoPath, (int)strlen(IsoPath), wFilePath, (int)(sizeof(wFilePath) / sizeof(WCHAR))); MultiByteToWideChar(CP_ACP, 0, IsoPath, (int)strlen(IsoPath), wFilePath, (int)(sizeof(wFilePath) / sizeof(WCHAR)));
} }
...@@ -610,19 +613,36 @@ int VentoyMountISOByAPI(const char *IsoPath) ...@@ -610,19 +613,36 @@ int VentoyMountISOByAPI(const char *IsoPath)
OpenParameters.Version = OPEN_VIRTUAL_DISK_VERSION_1; OpenParameters.Version = OPEN_VIRTUAL_DISK_VERSION_1;
Status = OpenVirtualDisk(&StorageType, wFilePath, VIRTUAL_DISK_ACCESS_READ, 0, &OpenParameters, &Handle); for (i = 0; i < 10; i++)
if (Status != ERROR_SUCCESS) {
{ Status = OpenVirtualDisk(&StorageType, wFilePath, VIRTUAL_DISK_ACCESS_READ, 0, &OpenParameters, &Handle);
if (ERROR_VIRTDISK_PROVIDER_NOT_FOUND == Status) if (ERROR_FILE_NOT_FOUND == Status || ERROR_PATH_NOT_FOUND == Status)
{ {
Log("VirtualDisk for ISO file is not supported in current system"); Log("OpenVirtualDisk ErrorCode:%u, now wait and retry...", Status);
} Sleep(1000);
else }
{ else
Log("Failed to open virtual disk ErrorCode:%u", Status); {
} if (ERROR_SUCCESS == Status)
return 1; {
} Log("OpenVirtualDisk success");
}
else if (ERROR_VIRTDISK_PROVIDER_NOT_FOUND == Status)
{
Log("VirtualDisk for ISO file is not supported in current system");
}
else
{
Log("Failed to open virtual disk ErrorCode:%u", Status);
}
break;
}
}
if (Status != ERROR_SUCCESS)
{
return 1;
}
Log("OpenVirtualDisk success"); Log("OpenVirtualDisk success");
...@@ -1210,48 +1230,68 @@ static int ProcessUnattendedInstallation(const char *script) ...@@ -1210,48 +1230,68 @@ static int ProcessUnattendedInstallation(const char *script)
static int VentoyHook(ventoy_os_param *param) static int VentoyHook(ventoy_os_param *param)
{ {
int i;
int rc; int rc;
CHAR Letter = 'A'; BOOL find = FALSE;
CHAR Letter;
DWORD Drives;
DISK_EXTENT DiskExtent; DISK_EXTENT DiskExtent;
DWORD Drives = GetLogicalDrives();
UINT8 UUID[16]; UINT8 UUID[16];
CHAR IsoPath[MAX_PATH]; CHAR IsoPath[MAX_PATH];
Log("Logical Drives=0x%x Path:<%s>", Drives, param->vtoy_img_path); Log("VentoyHook Path:<%s>", param->vtoy_img_path);
if (IsUTF8Encode(param->vtoy_img_path)) if (IsUTF8Encode(param->vtoy_img_path))
{ {
Log("This file is UTF8 encoding\n"); Log("This file is UTF8 encoding\n");
} }
while (Drives) for (i = 0; i < 5; i++)
{ {
if (Drives & 0x01) Letter = 'A';
Drives = GetLogicalDrives();
Log("Logic Drives: 0x%x", Drives);
while (Drives)
{ {
sprintf_s(IsoPath, sizeof(IsoPath), "%C:\\%s", Letter, param->vtoy_img_path); if (Drives & 0x01)
if (IsFileExist("%s", IsoPath))
{ {
Log("File exist under %C:", Letter); sprintf_s(IsoPath, sizeof(IsoPath), "%C:\\%s", Letter, param->vtoy_img_path);
if (GetPhyDiskUUID(Letter, UUID, &DiskExtent) == 0) if (IsFileExist("%s", IsoPath))
{ {
if (memcmp(UUID, param->vtoy_disk_guid, 16) == 0) Log("File exist under %C:", Letter);
if (GetPhyDiskUUID(Letter, UUID, &DiskExtent) == 0)
{ {
Log("Disk UUID match"); if (memcmp(UUID, param->vtoy_disk_guid, 16) == 0)
break; {
Log("Disk UUID match");
find = TRUE;
break;
}
} }
} }
else
{
Log("File NOT exist under %C:", Letter);
}
} }
else
{ Drives >>= 1;
Log("File NOT exist under %C:", Letter); Letter++;
}
} }
Drives >>= 1; if (find)
Letter++; {
} break;
}
else
{
Log("Now wait and retry ...");
Sleep(1000);
}
}
if (Drives == 0) if (find == FALSE)
{ {
Log("Failed to find ISO file"); Log("Failed to find ISO file");
return 1; return 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment