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,10 +613,21 @@ int VentoyMountISOByAPI(const char *IsoPath) ...@@ -610,10 +613,21 @@ int VentoyMountISOByAPI(const char *IsoPath)
OpenParameters.Version = OPEN_VIRTUAL_DISK_VERSION_1; OpenParameters.Version = OPEN_VIRTUAL_DISK_VERSION_1;
for (i = 0; i < 10; i++)
{
Status = OpenVirtualDisk(&StorageType, wFilePath, VIRTUAL_DISK_ACCESS_READ, 0, &OpenParameters, &Handle); Status = OpenVirtualDisk(&StorageType, wFilePath, VIRTUAL_DISK_ACCESS_READ, 0, &OpenParameters, &Handle);
if (Status != ERROR_SUCCESS) if (ERROR_FILE_NOT_FOUND == Status || ERROR_PATH_NOT_FOUND == Status)
{
Log("OpenVirtualDisk ErrorCode:%u, now wait and retry...", Status);
Sleep(1000);
}
else
{ {
if (ERROR_VIRTDISK_PROVIDER_NOT_FOUND == Status) if (ERROR_SUCCESS == Status)
{
Log("OpenVirtualDisk success");
}
else if (ERROR_VIRTDISK_PROVIDER_NOT_FOUND == Status)
{ {
Log("VirtualDisk for ISO file is not supported in current system"); Log("VirtualDisk for ISO file is not supported in current system");
} }
...@@ -621,6 +635,12 @@ int VentoyMountISOByAPI(const char *IsoPath) ...@@ -621,6 +635,12 @@ int VentoyMountISOByAPI(const char *IsoPath)
{ {
Log("Failed to open virtual disk ErrorCode:%u", Status); Log("Failed to open virtual disk ErrorCode:%u", Status);
} }
break;
}
}
if (Status != ERROR_SUCCESS)
{
return 1; return 1;
} }
...@@ -1210,20 +1230,28 @@ static int ProcessUnattendedInstallation(const char *script) ...@@ -1210,20 +1230,28 @@ 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");
} }
for (i = 0; i < 5; i++)
{
Letter = 'A';
Drives = GetLogicalDrives();
Log("Logic Drives: 0x%x", Drives);
while (Drives) while (Drives)
{ {
if (Drives & 0x01) if (Drives & 0x01)
...@@ -1237,6 +1265,7 @@ static int VentoyHook(ventoy_os_param *param) ...@@ -1237,6 +1265,7 @@ static int VentoyHook(ventoy_os_param *param)
if (memcmp(UUID, param->vtoy_disk_guid, 16) == 0) if (memcmp(UUID, param->vtoy_disk_guid, 16) == 0)
{ {
Log("Disk UUID match"); Log("Disk UUID match");
find = TRUE;
break; break;
} }
} }
...@@ -1251,7 +1280,18 @@ static int VentoyHook(ventoy_os_param *param) ...@@ -1251,7 +1280,18 @@ static int VentoyHook(ventoy_os_param *param)
Letter++; Letter++;
} }
if (Drives == 0) if (find)
{
break;
}
else
{
Log("Now wait and retry ...");
Sleep(1000);
}
}
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