VirtualBox

Ignore:
Timestamp:
Apr 30, 2014 12:29:47 PM (11 years ago)
Author:
vboxsync
Message:

Installer/win/VBoxStub: Bugfixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/win/Stub/VBoxStub.cpp

    r51171 r51172  
    1919*   Header Files                                                               *
    2020*******************************************************************************/
     21#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0501
     22# undef  _WIN32_WINNT
     23# define _WIN32_WINNT 0x0501 /* AttachConsole() / FreeConsole(). */
     24#endif
     25
    2126#include <Windows.h>
    2227#include <commctrl.h>
     
    5863#endif
    5964
    60 #ifdef DEBUG
    61 /* Use an own console window if run in debug mode. */
     65#ifndef TARGET_NT4
     66/* Use an own console window if run in verbose mode. */
    6267# define VBOX_STUB_WITH_OWN_CONSOLE
    6368#endif
     
    816821        return RTMsgInitFailure(vrc);
    817822    }
    818 
    819 #if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0501
    820 # ifndef VBOX_STUB_WITH_OWN_CONSOLE /* Use an own console window if run in debug mode. */
    821     if (!AllocConsole())
    822     {
    823         DWORD dwErr = GetLastError();
    824         ShowError("Unable to allocate console, error = %ld\n",
    825                   dwErr);
    826 
    827         /* Close the mutex for this application instance. */
    828         CloseHandle(hMutexAppRunning);
    829         hMutexAppRunning = NULL;
    830         return RTEXITCODE_FAILURE;
    831     }
    832 # else
    833     if (!AttachConsole(ATTACH_PARENT_PROCESS))
    834     {
    835         DWORD dwErr = GetLastError();
    836         /* Does the program have a console to attach to? */
    837         if (dwErr != ERROR_INVALID_HANDLE)
    838         {
    839             ShowError("Unable to attach to console, error = %ld\n",
    840                       dwErr);
    841 
    842             /* Close the mutex for this application instance. */
    843             CloseHandle(hMutexAppRunning);
    844             hMutexAppRunning = NULL;
    845             return RTEXITCODE_FAILURE;
    846         }
    847     }
    848 # endif /* DEBUG */
    849 
    850     long lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
    851     int iConHandleStdOut = _open_osfhandle(lStdHandle, _O_TEXT);
    852     FILE *hFileStdOut = _fdopen(iConHandleStdOut, "w");
    853     *stdout = *hFileStdOut;
    854 
    855     lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
    856     int iConHandleStdErr = _open_osfhandle(lStdHandle, _O_TEXT);
    857     FILE *hFileStdErr = _fdopen(iConHandleStdErr, "w");
    858     *stderr = *hFileStdErr;
    859 
    860 setvbuf( stdout, NULL, _IONBF, 0 );
    861 
    862 #endif
    863823
    864824    /*
     
    1035995        vrc = VERR_PARSE_ERROR;
    1036996
     997#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0501
     998# ifdef VBOX_STUB_WITH_OWN_CONSOLE /* Use an own console window if run in debug mode. */
     999    if (   RT_SUCCESS(vrc)
     1000        && g_iVerbosity)
     1001    {
     1002        if (!AllocConsole())
     1003        {
     1004            DWORD dwErr = GetLastError();
     1005            ShowError("Unable to allocate console, error = %ld\n",
     1006                      dwErr);
     1007
     1008            /* Close the mutex for this application instance. */
     1009            CloseHandle(hMutexAppRunning);
     1010            hMutexAppRunning = NULL;
     1011            return RTEXITCODE_FAILURE;
     1012        }
     1013
     1014        freopen("CONOUT$", "w", stdout);
     1015        setvbuf(stdout, NULL, _IONBF, 0);
     1016
     1017        freopen("CONOUT$", "w", stderr);
     1018    }
     1019# endif /* VBOX_STUB_WITH_OWN_CONSOLE */
     1020#endif
     1021
    10371022    if (   RT_SUCCESS(vrc)
    10381023        && g_iVerbosity)
     
    11291114
    11301115#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0501
    1131 # ifndef VBOX_STUB_WITH_OWN_CONSOLE
    1132     if (iConHandleStdErr)
    1133         _close(iConHandleStdErr);
    1134     if (hFileStdErr)
    1135         fclose(hFileStdErr);
    1136     if (iConHandleStdOut)
    1137         _close(iConHandleStdOut);
    1138     if (hFileStdOut)
    1139         fclose(hFileStdOut);
     1116# ifdef VBOX_STUB_WITH_OWN_CONSOLE
     1117    FreeConsole();
    11401118# endif /* VBOX_STUB_WITH_OWN_CONSOLE */
    1141     FreeConsole();
    11421119#endif
    11431120
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette