]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Fix the mount issue for 2K10 Win7x64 PE
authorlongpanda <admin@ventoy.net>
Sun, 15 Aug 2021 16:00:21 +0000 (00:00 +0800)
committerlongpanda <admin@ventoy.net>
Sun, 15 Aug 2021 16:00:21 +0000 (00:00 +0800)
INSTALL/ventoy/vtoyjump32.exe
INSTALL/ventoy/vtoyjump64.exe
vtoyjump/vtoyjump/vtoyjump.c

index 6cc493453a7703e716985e7f73e310fb93d44bc7..347cd65c0574c8a3ba942d41554053b476228840 100644 (file)
Binary files a/INSTALL/ventoy/vtoyjump32.exe and b/INSTALL/ventoy/vtoyjump32.exe differ
index eb7639b272de5171170ed6c3c792541a84f047d5..caa41c4d2cb560ec479578262f56f93c52c5175f 100644 (file)
Binary files a/INSTALL/ventoy/vtoyjump64.exe and b/INSTALL/ventoy/vtoyjump64.exe differ
index 65e958976dec967dde42d81d6df4d8cef1159796..9f6443ec4c1c3c1b89324aa78f4058a7b2d827e2 100644 (file)
@@ -698,12 +698,45 @@ static int VentoyFatDiskRead(uint32 Sector, uint8 *Buffer, uint32 SectorCount)
        return 1;\r
 }\r
 \r
+static BOOL Is2K10PE(void)\r
+{\r
+       BOOL bRet = FALSE;\r
+       FILE *fp = NULL;\r
+       CHAR szLine[1024];\r
+\r
+       fopen_s(&fp, "X:\\Windows\\System32\\PECMD.INI", "r");\r
+       if (!fp)\r
+       {\r
+               return FALSE;\r
+       }\r
+\r
+       memset(szLine, 0, sizeof(szLine));\r
+       while (fgets(szLine, sizeof(szLine) - 1, fp))\r
+       {\r
+               if (strstr(szLine, "\\2k10\\"))\r
+               {\r
+                       bRet = TRUE;\r
+                       break;\r
+               }\r
+       }\r
+\r
+       fclose(fp);\r
+       return bRet;\r
+}\r
+\r
 static CHAR GetMountLogicalDrive(void)\r
 {\r
        CHAR Letter = 'Y';\r
        DWORD Drives;\r
        DWORD Mask = 0x1000000;\r
 \r
+       // fixed use M as mountpoint for 2K10 PE\r
+       if (Is2K10PE())\r
+       {\r
+               Log("Use M: for 2K10 PE");\r
+               return 'M';\r
+       }\r
+\r
        Drives = GetLogicalDrives();\r
     Log("Drives=0x%x", Drives);\r
     \r
@@ -770,20 +803,68 @@ UINT64 GetVentoyEfiPartStartSector(HANDLE hDrive)
        return StartSector;\r
 }\r
 \r
+static int VentoyRunImdisk(const char *IsoPath, const char *imdiskexe)\r
+{\r
+       CHAR Letter;\r
+       CHAR Cmdline[512];\r
+       WCHAR CmdlineW[512];\r
+       PROCESS_INFORMATION Pi;\r
+\r
+       Log("VentoyRunImdisk <%s> <%s>", IsoPath, imdiskexe);\r
+\r
+       Letter = GetMountLogicalDrive();\r
+       sprintf_s(Cmdline, sizeof(Cmdline), "%s -a -o ro -f \"%s\" -m %C:", imdiskexe, IsoPath, Letter);\r
+       Log("mount iso to %C: use imdisk cmd <%s>", Letter, Cmdline);\r
+\r
+       if (IsUTF8Encode(IsoPath))\r
+       {\r
+               STARTUPINFOW Si;\r
+               GetStartupInfoW(&Si);\r
+               Si.dwFlags |= STARTF_USESHOWWINDOW;\r
+               Si.wShowWindow = SW_HIDE;\r
+\r
+               Utf8ToUtf16(Cmdline, CmdlineW);\r
+               CreateProcessW(NULL, CmdlineW, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi);\r
+\r
+               Log("This is UTF8 encoding");\r
+       }\r
+       else\r
+       {\r
+               STARTUPINFOA Si;\r
+               GetStartupInfoA(&Si);\r
+               Si.dwFlags |= STARTF_USESHOWWINDOW;\r
+               Si.wShowWindow = SW_HIDE;\r
+\r
+               CreateProcessA(NULL, Cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi);\r
+\r
+               Log("This is ANSI encoding");\r
+       }\r
+\r
+       Log("Wait for imdisk process ...");\r
+       WaitForSingleObject(Pi.hProcess, INFINITE);\r
+       Log("imdisk process finished");\r
+\r
+       return 0;\r
+}\r
+\r
 int VentoyMountISOByImdisk(const char *IsoPath, DWORD PhyDrive)\r
 {\r
        int rc = 1;\r
        BOOL bRet;\r
-       CHAR Letter;\r
        DWORD dwBytes;\r
        HANDLE hDrive;\r
        CHAR PhyPath[MAX_PATH];\r
-       WCHAR PhyPathW[MAX_PATH];\r
-       PROCESS_INFORMATION Pi;\r
        GET_LENGTH_INFORMATION LengthInfo;\r
 \r
        Log("VentoyMountISOByImdisk %s", IsoPath);\r
 \r
+       if (IsFileExist("X:\\Windows\\System32\\imdisk.exe"))\r
+       {\r
+               Log("imdisk.exe exist, use it directly...");\r
+               VentoyRunImdisk(IsoPath, "imdisk.exe");\r
+               return 0;\r
+       }\r
+\r
        sprintf_s(PhyPath, sizeof(PhyPath), "\\\\.\\PhysicalDrive%d", PhyDrive);\r
     hDrive = CreateFileA(PhyPath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);\r
        if (hDrive == INVALID_HANDLE_VALUE)\r
@@ -826,37 +907,8 @@ int VentoyMountISOByImdisk(const char *IsoPath, DWORD PhyDrive)
 \r
                if (LoadNtDriver(PhyPath) == 0)\r
                {\r
+                       VentoyRunImdisk(IsoPath, "ventoy\\imdisk.exe");\r
                        rc = 0;\r
-\r
-                       Letter = GetMountLogicalDrive();\r
-            sprintf_s(PhyPath, sizeof(PhyPath), "ventoy\\imdisk.exe -a -o ro -f \"%s\" -m %C:", IsoPath, Letter);\r
-            Log("mount iso to %C: use imdisk cmd <%s>", Letter, PhyPath);\r
-\r
-            if (IsUTF8Encode(IsoPath))\r
-            {\r
-                STARTUPINFOW Si;\r
-                GetStartupInfoW(&Si);\r
-                Si.dwFlags |= STARTF_USESHOWWINDOW;\r
-                Si.wShowWindow = SW_HIDE;\r
-\r
-                Utf8ToUtf16(PhyPath, PhyPathW);\r
-                CreateProcessW(NULL, PhyPathW, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi);\r
-\r
-                Log("This is UTF8 encoding");\r
-            }\r
-            else\r
-            {\r
-                STARTUPINFOA Si;\r
-                GetStartupInfoA(&Si);\r
-                Si.dwFlags |= STARTF_USESHOWWINDOW;\r
-                Si.wShowWindow = SW_HIDE;\r
-\r
-                CreateProcessA(NULL, PhyPath, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi);\r
-\r
-                Log("This is ANSI encoding");\r
-            }\r
-\r
-                       WaitForSingleObject(Pi.hProcess, INFINITE);\r
                }\r
        }\r
        fl_shutdown();\r