@@ -49,20 +49,52 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
4949 std::string command = " show" ;
5050 std::string editor_type = " smartprop" ;
5151
52- for (int i = 1 ; i < argc; i++) {
53- // Handle Velopack hooks by exiting immediately.
54- // Logic moved to main application.
55- if (wcscmp (argv[i], L" --squirrel-install" ) == 0 ||
56- wcscmp (argv[i], L" --squirrel-updated" ) == 0 ||
57- wcscmp (argv[i], L" --squirrel-uninstall" ) == 0 ||
58- wcscmp (argv[i], L" --squirrel-obsoleted" ) == 0 ||
59- wcscmp (argv[i], L" --velopack-install" ) == 0 ||
60- wcscmp (argv[i], L" --velopack-updated" ) == 0 ||
61- wcscmp (argv[i], L" --velopack-uninstall" ) == 0 ||
62- wcscmp (argv[i], L" --velopack-obsoleted" ) == 0 ) {
63- LocalFree (argv);
64- return 0 ;
52+ // Check if this is a Velopack hook that needs to be forwarded to main app
53+ const wchar_t * HOOKS [] = {
54+ L" --velopack-install" , L" --velopack-updated" ,
55+ L" --velopack-uninstall" , L" --velopack-obsoleted" , L" --velopack-obsolete" ,
56+ L" --squirrel-install" , L" --squirrel-updated" ,
57+ L" --squirrel-uninstall" , L" --squirrel-obsoleted" , L" --squirrel-obsolete" ,
58+ nullptr
59+ };
60+
61+ bool is_hook = false ;
62+ for (int i = 1 ; i < argc && !is_hook; i++) {
63+ for (int j = 0 ; HOOKS [j]; j++) {
64+ if (wcscmp (argv[i], HOOKS [j]) == 0 ) {
65+ is_hook = true ;
66+ break ;
67+ }
68+ }
69+ }
70+
71+ // If this is a hook, forward it to Hammer5Tools.exe and wait for completion
72+ if (is_hook) {
73+ wchar_t buf[MAX_PATH ];
74+ GetModuleFileNameW (NULL , buf, MAX_PATH );
75+ fs::path app_exe = fs::path (buf).parent_path () / L" Hammer5Tools.exe" ;
76+
77+ if (fs::exists (app_exe)) {
78+ STARTUPINFOW si = { sizeof (si) };
79+ PROCESS_INFORMATION pi = {};
80+ std::wstring cmd = L" \" " + app_exe.wstring () + L" \" " + GetCommandLineW ();
81+ std::vector<wchar_t > cmdBuf (cmd.begin (), cmd.end ());
82+ cmdBuf.push_back (0 );
83+
84+ if (CreateProcessW (NULL , cmdBuf.data (), NULL , NULL , FALSE ,
85+ CREATE_NO_WINDOW , NULL , NULL , &si, &pi)) {
86+ // Wait up to 30 seconds for the process to complete (backup/hook handling)
87+ WaitForSingleObject (pi.hProcess , 30000 );
88+ CloseHandle (pi.hProcess );
89+ CloseHandle (pi.hThread );
90+ }
6591 }
92+
93+ LocalFree (argv);
94+ return 0 ;
95+ }
96+
97+ for (int i = 1 ; i < argc; i++) {
6698
6799 if (wcscmp (argv[i], L" --create-vmdl" ) == 0 && i + 1 < argc) {
68100 command = " create_vmdl" ;
0 commit comments