diff options
Diffstat (limited to 'tools/fwpatcher')
-rw-r--r-- | tools/fwpatcher/main.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tools/fwpatcher/main.c b/tools/fwpatcher/main.c index 7f2eda8fd3..ca11fbaefd 100644 --- a/tools/fwpatcher/main.c +++ b/tools/fwpatcher/main.c | |||
@@ -337,18 +337,72 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | |||
337 | TEXT("Success"), MB_OK); | 337 | TEXT("Success"), MB_OK); |
338 | } | 338 | } |
339 | break; | 339 | break; |
340 | case WM_USER: | ||
341 | /* command line driven patch button */ | ||
342 | SetWindowText(controls[EDIT_FILENAME], (LPCTSTR)wParam); | ||
343 | SendMessage(hwnd, WM_COMMAND, 0, (LPARAM)(controls[BUTTON_PATCH]) ); | ||
344 | break; | ||
340 | default: | 345 | default: |
341 | return DefWindowProc(hwnd, msg, wParam, lParam); | 346 | return DefWindowProc(hwnd, msg, wParam, lParam); |
342 | } | 347 | } |
343 | return 0; | 348 | return 0; |
344 | } | 349 | } |
345 | 350 | ||
351 | void getargs(LPTSTR p, int * argc, LPCTSTR * argv, int MAXARGS) | ||
352 | { | ||
353 | int quote=FALSE,whitespace=FALSE; | ||
354 | LPCTSTR tok=p; | ||
355 | *argc=0; | ||
356 | while(*argc<MAXARGS) | ||
357 | { | ||
358 | if((*p==TEXT(' ') || *p==TEXT('\0')) && !quote) | ||
359 | { | ||
360 | if(!whitespace) | ||
361 | { | ||
362 | whitespace=TRUE; | ||
363 | *argv++ = tok; | ||
364 | (*argc)++; | ||
365 | }; | ||
366 | if(*p==TEXT('\0')) | ||
367 | break; // end of cmd line | ||
368 | *p=TEXT('\0'); | ||
369 | p++; | ||
370 | } | ||
371 | else | ||
372 | { | ||
373 | if(whitespace) | ||
374 | tok=p; | ||
375 | whitespace=FALSE; | ||
376 | if(*p==TEXT('\"')) | ||
377 | { | ||
378 | *p=TEXT(' '); | ||
379 | if(!quote) | ||
380 | { | ||
381 | p++; | ||
382 | tok=p; | ||
383 | } | ||
384 | quote = !quote; | ||
385 | } | ||
386 | else p++; | ||
387 | } | ||
388 | } | ||
389 | } | ||
390 | |||
391 | #define MAXARGC 4 | ||
392 | |||
346 | int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance, | 393 | int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance, |
347 | LPSTR command_line, int command_show) | 394 | LPSTR command_line, int command_show) |
348 | { | 395 | { |
349 | HWND window; | 396 | HWND window; |
350 | WNDCLASSEX wc; | 397 | WNDCLASSEX wc; |
351 | MSG msg; | 398 | MSG msg; |
399 | int argc; | ||
400 | LPCTSTR argv[MAXARGC] = { NULL }; | ||
401 | LPTSTR cmdline = GetCommandLine(); | ||
402 | |||
403 | getargs(cmdline, &argc, argv, MAXARGC); | ||
404 | if (argc > 1) | ||
405 | command_show = SW_HIDE; | ||
352 | 406 | ||
353 | rbicon = LoadIcon(instance, MAKEINTRESOURCE(IDI_RBICON)); | 407 | rbicon = LoadIcon(instance, MAKEINTRESOURCE(IDI_RBICON)); |
354 | ZeroMemory(&wc, sizeof(wc)); | 408 | ZeroMemory(&wc, sizeof(wc)); |
@@ -368,6 +422,12 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance, | |||
368 | if (!window) return 0; | 422 | if (!window) return 0; |
369 | 423 | ||
370 | ShowWindow(window, command_show); | 424 | ShowWindow(window, command_show); |
425 | |||
426 | if (argc > 1) { | ||
427 | SendMessage(window, WM_USER, (WPARAM)(argv[1]), 0); | ||
428 | SendMessage(window, WM_CLOSE, 0, 0); | ||
429 | } | ||
430 | |||
371 | while (GetMessage(&msg, 0, 0, 0) > 0) { | 431 | while (GetMessage(&msg, 0, 0, 0) > 0) { |
372 | if (!IsDialogMessage(window, &msg)) { | 432 | if (!IsDialogMessage(window, &msg)) { |
373 | TranslateMessage(&msg); | 433 | TranslateMessage(&msg); |