Changeset 106413 in vbox for trunk/src/VBox/Additions/WINNT
- Timestamp:
- Oct 17, 2024 8:16:26 AM (4 months ago)
- svn:sync-xref-src-repo-rev:
- 165232
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp
r106411 r106413 80 80 81 81 /********************************************************************************************************************************* 82 * Structures and Typedefs * 83 *********************************************************************************************************************************/ 84 typedef BOOL (WINAPI *PFNALLOCCONSOLE)(VOID); 85 typedef BOOL (WINAPI *PFNATTACHCONSOLE)(DWORD); 86 87 88 /********************************************************************************************************************************* 82 89 * Global Variables * 83 90 *********************************************************************************************************************************/ … … 96 103 97 104 uint32_t g_fGuestDisplaysChanged = 0; 105 106 107 /********************************************************************************************************************************* 108 * Global Variables * 109 *********************************************************************************************************************************/ 110 DECL_HIDDEN_DATA(PFNALLOCCONSOLE) g_pfnAllocConsole = NULL; /* For W2K+. */ 111 DECL_HIDDEN_DATA(PFNATTACHCONSOLE) g_pfnAttachConsole = NULL; /* For W2K+. */ 98 112 99 113 … … 859 873 static int vboxTrayAttachConsole(void) 860 874 { 861 if (g_fHasConsole) /* Console already attached? Bail out. */ 875 if ( g_fHasConsole /* Console already attached? Bail out. */ 876 || !g_pfnAttachConsole) /* AttachConsole() not available (NT <= 4.0)? */ 862 877 return VINF_SUCCESS; 863 878 … … 865 880 * to get any stdout / stderr output. */ 866 881 bool fAllocConsole = false; 867 if (! AttachConsole(ATTACH_PARENT_PROCESS))882 if (!g_pfnAttachConsole(ATTACH_PARENT_PROCESS)) 868 883 fAllocConsole = true; 869 884 870 885 if (fAllocConsole) 871 886 { 872 if (!AllocConsole()) 887 AssertPtrReturn(g_pfnAllocConsole, VERR_NOT_AVAILABLE); 888 if (!g_pfnAllocConsole()) 873 889 VBoxTrayShowError("Unable to attach to or allocate a console!"); 874 890 /* Continue running. */ … … 903 919 { 904 920 g_fHasConsole = false; 921 } 922 923 /** 924 * Early initialization code, required for resolving dynamic symbols and such. 925 * 926 * @returns VBox status code. 927 */ 928 static int vboxTrayPreInit() 929 { 930 RTLDRMOD hMod; 931 int rc = RTLdrLoadSystem("kernel32.dll", true /*fNoUnload*/, &hMod); 932 if (RT_SUCCESS(rc)) 933 { 934 /* only W2K+, ignore rc */ RTLdrGetSymbol(hMod, "AllocConsole", (void **)&g_pfnAllocConsole); 935 /* only W2K+, ignore rc */ RTLdrGetSymbol(hMod, "AttachConsole", (void **)&g_pfnAttachConsole); 936 937 RTLdrClose(hMod); 938 } 939 940 return rc; 905 941 } 906 942 … … 999 1035 return RTMsgInitFailure(rc); 1000 1036 1037 rc = vboxTrayPreInit(); 1038 if (RT_FAILURE(rc)) 1039 return VBoxTrayShowError(VBOX_VBOXTRAY_TITLE " Pre-init failed: %Rrc\n", rc); 1040 1001 1041 /* If a debugger is present, we always want to attach a console. */ 1002 1042 if (IsDebuggerPresent())
Note:
See TracChangeset
for help on using the changeset viewer.