mirror of
				https://github.com/ventoy/Ventoy.git
				synced 2025-10-30 00:05:09 -04:00 
			
		
		
		
	Make injection plugin available in WIMBOOT mode. (#1834)
This commit is contained in:
		
							parent
							
								
									c81b49807b
								
							
						
					
					
						commit
						0c310c5bd8
					
				
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -36,6 +36,7 @@ static ventoy_guid g_ventoy_guid = VENTOY_GUID; | |||||||
| static HANDLE g_vtoylog_mutex = NULL; | static HANDLE g_vtoylog_mutex = NULL; | ||||||
| static HANDLE g_vtoyins_mutex = NULL; | static HANDLE g_vtoyins_mutex = NULL; | ||||||
| 
 | 
 | ||||||
|  | static INT g_winpeshl_ini_updated = 0; | ||||||
| static DWORD g_vtoy_disk_drive; | static DWORD g_vtoy_disk_drive; | ||||||
| 
 | 
 | ||||||
| static CHAR g_prog_full_path[MAX_PATH]; | static CHAR g_prog_full_path[MAX_PATH]; | ||||||
| @ -51,6 +52,8 @@ static CHAR g_prog_name[MAX_PATH]; | |||||||
| 
 | 
 | ||||||
| #define VTOY_AUTO_FILE   "X:\\_vtoy_auto_install" | #define VTOY_AUTO_FILE   "X:\\_vtoy_auto_install" | ||||||
| 
 | 
 | ||||||
|  | #define WINPESHL_INI    "X:\\Windows\\system32\\winpeshl.ini" | ||||||
|  | 
 | ||||||
| #define LOG_FILE  "X:\\Windows\\system32\\ventoy.log" | #define LOG_FILE  "X:\\Windows\\system32\\ventoy.log" | ||||||
| #define MUTEX_LOCK(hmutex)  if (hmutex != NULL) LockStatus = WaitForSingleObject(hmutex, INFINITE) | #define MUTEX_LOCK(hmutex)  if (hmutex != NULL) LockStatus = WaitForSingleObject(hmutex, INFINITE) | ||||||
| #define MUTEX_UNLOCK(hmutex)  if (hmutex != NULL && WAIT_OBJECT_0 == LockStatus) ReleaseMutex(hmutex) | #define MUTEX_UNLOCK(hmutex)  if (hmutex != NULL && WAIT_OBJECT_0 == LockStatus) ReleaseMutex(hmutex) | ||||||
| @ -1962,6 +1965,31 @@ static BOOL CheckVentoyDisk(DWORD DiskNum) | |||||||
|     return FALSE; |     return FALSE; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static int GetWinpeshlIniFileAttr(WinpeshlIniAttr *pAttr) | ||||||
|  | { | ||||||
|  |     HANDLE hFile; | ||||||
|  |     SYSTEMTIME systime; | ||||||
|  | 
 | ||||||
|  |     hFile = CreateFileA(WINPESHL_INI, FILE_READ_EA, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); | ||||||
|  |     if (hFile == INVALID_HANDLE_VALUE) | ||||||
|  |     { | ||||||
|  |         Log("Could not open the file<%s>, error:%u", WINPESHL_INI, GetLastError()); | ||||||
|  |         return 1; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     pAttr->FileSize = (INT)GetFileSize(hFile, NULL); | ||||||
|  |     GetFileTime(hFile, &pAttr->CreateTime, &pAttr->LastAccessTime, &pAttr->LastWriteTime); | ||||||
|  | 
 | ||||||
|  |     FileTimeToSystemTime(&pAttr->LastWriteTime, &systime); | ||||||
|  |     Log("Winpeshl.ini size:%d LastWriteTime:<%04u/%02u/%02u %02u:%02u:%02u.%03u>",  | ||||||
|  |         pAttr->FileSize, | ||||||
|  |         systime.wYear, systime.wMonth, systime.wDay,  | ||||||
|  |         systime.wHour, systime.wMinute, systime.wSecond,  | ||||||
|  |         systime.wMilliseconds); | ||||||
|  | 
 | ||||||
|  |     CloseHandle(hFile); | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| static int VentoyHook(ventoy_os_param *param) | static int VentoyHook(ventoy_os_param *param) | ||||||
| { | { | ||||||
| @ -1984,6 +2012,8 @@ static int VentoyHook(ventoy_os_param *param) | |||||||
| 
 | 
 | ||||||
| 	Log("VentoyHook Path:<%s>", param->vtoy_img_path); | 	Log("VentoyHook Path:<%s>", param->vtoy_img_path); | ||||||
| 
 | 
 | ||||||
|  |     g_winpeshl_ini_updated = 0; | ||||||
|  | 
 | ||||||
|     if (IsUTF8Encode(param->vtoy_img_path)) |     if (IsUTF8Encode(param->vtoy_img_path)) | ||||||
|     { |     { | ||||||
|         Log("This file is UTF8 encoding"); |         Log("This file is UTF8 encoding"); | ||||||
| @ -2180,9 +2210,35 @@ static int VentoyHook(ventoy_os_param *param) | |||||||
|         sprintf_s(IsoPath, sizeof(IsoPath), "%C:%s", VtoyLetter, g_windows_data.injection_archive); |         sprintf_s(IsoPath, sizeof(IsoPath), "%C:%s", VtoyLetter, g_windows_data.injection_archive); | ||||||
|         if (IsFileExist("%s", IsoPath)) |         if (IsFileExist("%s", IsoPath)) | ||||||
|         { |         { | ||||||
|  |             int rc1 = -1, rc2 = -1; | ||||||
|  |             WinpeshlIniAttr Attr1, Attr2; | ||||||
|  |             memset(&Attr1, 0, sizeof(Attr1)); | ||||||
|  |             memset(&Attr2, 0, sizeof(Attr2)); | ||||||
|  | 
 | ||||||
|             Log("decompress injection archive %s...", IsoPath); |             Log("decompress injection archive %s...", IsoPath); | ||||||
|  | 
 | ||||||
|  |             if (IsFileExist(WINPESHL_INI)) | ||||||
|  |             { | ||||||
|  |                 rc1 = GetWinpeshlIniFileAttr(&Attr1); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|             DecompressInjectionArchive(IsoPath, VtoyDiskNum); |             DecompressInjectionArchive(IsoPath, VtoyDiskNum); | ||||||
| 
 | 
 | ||||||
|  |             if (IsFileExist(WINPESHL_INI)) | ||||||
|  |             { | ||||||
|  |                 rc2 = GetWinpeshlIniFileAttr(&Attr2); | ||||||
|  |                 if (rc1 == rc2 && rc1 == 0) | ||||||
|  |                 { | ||||||
|  |                     if (Attr1.FileSize != Attr2.FileSize || | ||||||
|  |                         Attr1.LastWriteTime.dwHighDateTime != Attr2.LastWriteTime.dwHighDateTime || | ||||||
|  |                         Attr1.LastWriteTime.dwLowDateTime != Attr2.LastWriteTime.dwLowDateTime) | ||||||
|  |                     { | ||||||
|  |                         Log("winpeshl.ini file updated"); | ||||||
|  |                         g_winpeshl_ini_updated = 1; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|             if (IsFileExist("%s", AUTO_RUN_BAT)) |             if (IsFileExist("%s", AUTO_RUN_BAT)) | ||||||
|             { |             { | ||||||
|                 HANDLE hOut; |                 HANDLE hOut; | ||||||
| @ -2441,6 +2497,7 @@ int real_main(int argc, char **argv) | |||||||
| { | { | ||||||
| 	int i = 0; | 	int i = 0; | ||||||
| 	int rc = 0; | 	int rc = 0; | ||||||
|  |     int wimboot = 0; | ||||||
| 	CHAR NewFile[MAX_PATH]; | 	CHAR NewFile[MAX_PATH]; | ||||||
| 	CHAR LunchFile[MAX_PATH]; | 	CHAR LunchFile[MAX_PATH]; | ||||||
| 	CHAR CallParam[1024] = { 0 }; | 	CHAR CallParam[1024] = { 0 }; | ||||||
| @ -2468,6 +2525,7 @@ int real_main(int argc, char **argv) | |||||||
| 
 | 
 | ||||||
| 	if (strstr(argv[0], "vtoyjump.exe")) | 	if (strstr(argv[0], "vtoyjump.exe")) | ||||||
| 	{ | 	{ | ||||||
|  |         wimboot = 1; | ||||||
| 		rc = VentoyJumpWimboot(argc, argv, LunchFile); | 		rc = VentoyJumpWimboot(argc, argv, LunchFile); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| @ -2490,6 +2548,11 @@ int real_main(int argc, char **argv) | |||||||
| 		sprintf_s(LunchFile, sizeof(LunchFile), "%s", g_prog_full_path); | 		sprintf_s(LunchFile, sizeof(LunchFile), "%s", g_prog_full_path); | ||||||
| 		Log("Final lunchFile is <%s>", LunchFile); | 		Log("Final lunchFile is <%s>", LunchFile); | ||||||
| 	} | 	} | ||||||
|  |     else if (wimboot && g_winpeshl_ini_updated) | ||||||
|  |     { | ||||||
|  |         sprintf_s(LunchFile, MAX_PATH, "X:\\Windows\\system32\\winpeshl.exe"); | ||||||
|  |         Log("Recall winpeshl.exe"); | ||||||
|  |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|         Log("We don't need to recover original <%s>", g_prog_name); |         Log("We don't need to recover original <%s>", g_prog_name); | ||||||
|  | |||||||
| @ -152,6 +152,14 @@ typedef struct VTOY_GPT_INFO | |||||||
| #pragma pack() | #pragma pack() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | typedef struct WinpeshlIniAttr | ||||||
|  | { | ||||||
|  |     INT FileSize; | ||||||
|  |     FILETIME CreateTime; | ||||||
|  |     FILETIME LastAccessTime; | ||||||
|  |     FILETIME LastWriteTime; | ||||||
|  | }WinpeshlIniAttr; | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| typedef struct VarDiskInfo | typedef struct VarDiskInfo | ||||||
| { | { | ||||||
| @ -187,4 +195,5 @@ int unxz(unsigned char *in, int in_size, | |||||||
|     unsigned char *out, int *in_used, |     unsigned char *out, int *in_used, | ||||||
|     void(*error)(char *x)); |     void(*error)(char *x)); | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| #endif | #endif | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user