]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Optimization for Lenovo Recovery Image (USB unplug process)
authorlongpanda <admin@ventoy.net>
Thu, 5 Jan 2023 14:18:39 +0000 (22:18 +0800)
committerlongpanda <admin@ventoy.net>
Thu, 5 Jan 2023 14:18:39 +0000 (22:18 +0800)
INSTALL/ventoy/vtoyjump32.exe
INSTALL/ventoy/vtoyjump64.exe
vtoyjump/vtoyjump/vtoyjump.c

index ae791443016c57a0d474d8c2d904d115d9176d70..073f56fe8e4d765038e631ac8f6aad59a7a3ac96 100644 (file)
Binary files a/INSTALL/ventoy/vtoyjump32.exe and b/INSTALL/ventoy/vtoyjump32.exe differ
index af643e4312174050101ace99ea272decbe2df8cd..6a78cfb485bc3cf17361a60ebcc5471626f48da7 100644 (file)
Binary files a/INSTALL/ventoy/vtoyjump64.exe and b/INSTALL/ventoy/vtoyjump64.exe differ
index 2d9a8a6a402ce331527d8178326da7419c23cd0f..d56f23dcb969704deda6e01ce79ebce05b45ab59 100644 (file)
@@ -2362,7 +2362,10 @@ static BOOL VentoyIsLenovoRecovery(CHAR *IsoPath, CHAR *VTLRIPath)
 \r
 static int MountVTLRI(CHAR *ImgPath, DWORD PhyDrive)\r
 {\r
-    CHAR ImDiskPath[256];\r
+    STARTUPINFOA Si;\r
+    PROCESS_INFORMATION Pi;\r
+    CHAR Cmdline[256]; \r
+    CHAR ImDiskPath[256];    \r
     \r
     Log("MountVTLRI <%s> %u", ImgPath, PhyDrive);\r
 \r
@@ -2370,6 +2373,18 @@ static int MountVTLRI(CHAR *ImgPath, DWORD PhyDrive)
 \r
     VentoyRunImdisk("VTLRI", ImgPath, ImDiskPath, "ro,rem");\r
 \r
+    CopyFileA(g_prog_full_path, "ventoy\\VTLRISRV.exe", FALSE);\r
+\r
+    sprintf_s(Cmdline, sizeof(Cmdline), "ventoy\\VTLRISRV.exe VTLRI_SRV %C Z", ImgPath[0]);\r
+\r
+\r
+    GetStartupInfoA(&Si);\r
+    Si.dwFlags |= STARTF_USESHOWWINDOW;\r
+    Si.wShowWindow = SW_HIDE;\r
+    CreateProcessA(NULL, Cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi);\r
+\r
+    Log("Process cmdline <%s>", Cmdline);\r
+\r
     return 0;\r
 }\r
 \r
@@ -2939,6 +2954,52 @@ static int vtoy_remove_duplicate_file(char *File)
     return 0;\r
 }\r
 \r
+static int VTLRI_ServiceMain(int argc, char **argv)\r
+{\r
+    int n = 0;\r
+    DWORD Err;\r
+    BOOL bRet = TRUE;\r
+    CHAR Drive[16];\r
+    CHAR FsType[64];\r
+    CHAR Cmdline[256];\r
+    PROCESS_INFORMATION Pi;\r
+    STARTUPINFOA Si;\r
+\r
+    //XXX.exe VTLRI_SRV D Z\r
+    Log("VTLRI_ServiceMain start %s %s %s ...", argv[0], argv[1], argv[2]);\r
+\r
+    sprintf_s(Drive, sizeof(Drive), "%C:\\", argv[2][0]);\r
+\r
+    while (n < 3)\r
+    {\r
+        bRet = GetVolumeInformationA(Drive, NULL, 0, NULL, NULL, NULL, FsType, sizeof(FsType));\r
+        if (bRet)\r
+        {\r
+            Sleep(400);\r
+        }\r
+        else\r
+        {\r
+            Err = LASTERR;\r
+            if (Err == ERROR_PATH_NOT_FOUND)\r
+            {\r
+                Log("%s not found", Drive);\r
+                n++;\r
+            }\r
+        }\r
+    }\r
+\r
+    sprintf_s(Cmdline, sizeof(Cmdline), "ventoy\\imdisk.exe -d -m %C:", argv[3][0]);\r
+    Log("Remove disk by <%s>", Cmdline);\r
+\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
+    WaitForSingleObject(Pi.hProcess, INFINITE);\r
+    return 0;\r
+}\r
+\r
 int main(int argc, char **argv)\r
 {\r
     int i;\r
@@ -2953,6 +3014,11 @@ int main(int argc, char **argv)
 \r
     Log("######## VentoyJump %dbit ##########", g_system_bit);\r
 \r
+    if (argc > 1 && strcmp(argv[1], "VTLRI_SRV") == 0)\r
+    {\r
+        return VTLRI_ServiceMain(argc, argv);\r
+    }\r
+\r
     GetCurrentDirectoryA(sizeof(CurDir), CurDir);\r
     Log("Current directory is <%s>", CurDir);\r
     \r