Changeset 96770 in vbox
- Timestamp:
- Sep 16, 2022 2:55:30 PM (2 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Installer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/Makefile.kmk
r96451 r96770 50 50 VBoxGuestInstallHelper.cpp \ 51 51 VBoxGuestInstallHelper.rc 52 VBoxGuestInstallHelper_VBOX_IMPORT_CHECKER.win.x86 := nt4 52 53 53 54 include $(FILE_KBUILD_SUB_FOOTER) -
trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/VBoxGuestInstallHelper.cpp
r96452 r96770 35 35 #endif 36 36 #include <iprt/win/windows.h> 37 #include <iprt/win/commctrl.h> 37 38 #include "exdll.h" 38 39 40 #include <iprt/alloca.h> 39 41 #include <iprt/errcore.h> 40 42 #include <iprt/initterm.h> … … 463 465 } 464 466 467 /** 468 * Dumps the UI log to a file in UTF-8 format. 469 * 470 * Does not return any values on the stack. 471 * 472 * @param hWndParent Window handle of parent. 473 * @param string_size Size of variable string. 474 * @param variables The actual variable string. 475 * @param stacktop Pointer to a pointer to the current stack. 476 * @param extra Extra parameters. 477 */ 478 VBOXINSTALLHELPER_EXPORT DumpLog(HWND hWndParent, int string_size, WCHAR *variables, stack_t **stacktop, 479 extra_parameters *extra) 480 { 481 RT_NOREF(string_size, variables, extra); 482 483 /* 484 * Get parameters from the stack. 485 */ 486 stack_t * const pFilename = vboxPopStack(stacktop); 487 if (pFilename) 488 { 489 /* 490 * Open the output file. 491 */ 492 HANDLE hFile = CreateFileW(pFilename->text, GENERIC_WRITE, FILE_SHARE_READ, NULL /*pSecAttr*/, CREATE_ALWAYS, 493 FILE_ATTRIBUTE_NORMAL, NULL /*hTemplateFile*/); 494 if (hFile != NULL) 495 { 496 DWORD dwIgn; 497 498 /* 499 * Locate the list view widget. 500 */ 501 HWND hWndDialog = FindWindowExW(hWndParent, NULL /*hWndChildAfter*/, L"#32770" /*pwszClass*/, NULL /*pwszTitle*/); 502 if (hWndDialog) 503 { 504 HWND hWndList = FindWindowExW(hWndDialog, NULL /*hWndChildAfter*/, L"SysListView32", NULL /*pwszTitle*/); 505 if (hWndList != NULL) 506 { 507 uint32_t const cLines = (uint32_t)SendMessageW(hWndList, LVM_GETITEMCOUNT, 0, 0); 508 if (cLines > 0) 509 { 510 /* Allocate a buffer for retriving the text. */ 511 uint32_t cwcBuf = RT_MAX(string_size + 16, _8K); 512 wchar_t *pwszBuf = (wchar_t *)RTMemTmpAlloc(cwcBuf * sizeof(wchar_t)); 513 wchar_t * const pwszBufFree = pwszBuf; 514 if (!pwszBuf) 515 { 516 cwcBuf = _4K; 517 pwszBuf = (wchar_t *)alloca(cwcBuf * sizeof(wchar_t)); 518 } 519 520 /* 521 * Retreive the lines and write them to the output file. 522 */ 523 for (uint32_t iLine = 0; iLine < cLines; iLine++) 524 { 525 LVITEMW Item = 526 { 527 /* .mask = */ 0, 528 /* .iItem = */ (int)iLine, 529 /* .iSubItem = */ 0, 530 /* .state = */ 0, 531 /* .stateMask = */ 0, 532 /* .pszText = */ pwszBuf, 533 /* .cchTextMax = */ (int)cwcBuf, 534 }; 535 uint32_t const cwcRet = (uint32_t)SendMessageW(hWndList, LVM_GETITEMTEXT, iLine, (LPARAM)&Item); 536 if (cwcRet < cwcBuf) 537 { 538 pwszBuf[cwcRet] = '\0'; 539 bool fNeedsNewline = cwcRet + 2 >= cwcBuf; 540 if (!fNeedsNewline) 541 { 542 pwszBuf[cwcRet + 0] = '\r'; 543 pwszBuf[cwcRet + 1] = '\n'; 544 pwszBuf[cwcRet + 2] = '\0'; 545 } 546 547 char *pszUtf8; 548 int rc = RTUtf16ToUtf8(pwszBuf, &pszUtf8); 549 if (RT_SUCCESS(rc)) 550 { 551 WriteFile(hFile, pszUtf8, strlen(pszUtf8), &dwIgn, NULL); 552 if (fNeedsNewline) 553 WriteFile(hFile, RT_STR_TUPLE("\r\n"), &dwIgn, NULL); 554 RTStrFree(pszUtf8); 555 } 556 else 557 WriteFile(hFile, RT_STR_TUPLE("!RTUtf16ToUtf8 failed!\r\n"), &dwIgn, NULL); 558 } 559 else 560 WriteFile(hFile, RT_STR_TUPLE("!LVM_GETITEMTEXT overflow!\r\n"), &dwIgn, NULL); 561 } /* for loop*/ 562 563 RTMemTmpFree(pwszBufFree); 564 } 565 else 566 WriteFile(hFile, RT_STR_TUPLE("Log is empty.\r\n"), &dwIgn, NULL); 567 } 568 else 569 WriteFile(hFile, RT_STR_TUPLE("FindWindowEx failed to locate the log control!\r\n"), &dwIgn, NULL); 570 } 571 else 572 WriteFile(hFile, RT_STR_TUPLE("FindWindowEx failed to locate dialog windows!\r\n"), &dwIgn, NULL); 573 CloseHandle(hFile); 574 } 575 } 576 vboxFreeStackEntry(pFilename); 577 } 578 465 579 BOOL WINAPI DllMain(HANDLE hInst, ULONG uReason, LPVOID pReserved) 466 580 { -
trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditions.nsi
r96697 r96770 193 193 194 194 ; Must come after MUI includes to have certain defines set for DumpLog 195 !include "dumplog.nsh" ; Dump log to file function 195 !if $%VBOX_WITH_GUEST_INSTALL_HELPER% != "1" 196 !include "dumplog.nsh" ; Dump log to file function 197 !endif 196 198 197 199 ; Language files … … 870 872 ; 871 873 ${IfNot} ${Silent} 874 !if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1" 875 VBoxGuestInstallHelper::DumpLog "$INSTDIR\install_ui.log" 876 !else 872 877 StrCpy $0 "$INSTDIR\install_ui.log" 873 878 Push $0 874 879 Call DumpLog 880 !endif 875 881 ${EndIf} 876 882 … … 925 931 ; Dump UI log to see what happend. Only works with non-silent installs. 926 932 ${IfNot} ${Silent} 933 !if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1" 934 VBoxGuestInstallHelper::DumpLog "$INSTDIR\install_ui.log" 935 !else 927 936 StrCpy $0 "$INSTDIR\install_ui.log" 928 937 Push $0 929 938 Call DumpLog 939 !endif 930 940 ${EndIf} 931 941
Note:
See TracChangeset
for help on using the changeset viewer.