VirtualBox

Changeset 70345 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Dec 26, 2017 3:51:56 PM (7 years ago)
Author:
vboxsync
Message:

IPRT: More NT 3.1 compatibility tweaking.

Location:
trunk/src/VBox/Runtime
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r70336 r70345  
    15551555        r3/win/vcc100-ntdll-fakesA.asm \
    15561556        r3/win/vcc100-ws2_32-fakes.cpp \
    1557         r3/win/vcc100-ws2_32-fakesA.asm
     1557        r3/win/vcc100-ws2_32-fakesA.asm \
     1558        r3/win/vcc100-shell32-fakes.cpp \
     1559        r3/win/vcc100-shell32-fakesA.asm \
    15581560
    15591561#
  • trunk/src/VBox/Runtime/r3/init.cpp

    r69970 r70345  
    292292               unicode main function.  So, we have to use CommandLineToArgvW to get
    293293               something similar. It should do the same conversion... :-) */
     294            /** @todo Replace this CommandLineToArgvW call with a call into
     295             *        getoptargv.cpp so we don't depend on shell32 and an API not present
     296             *        in NT 3.1.  */
    294297            int    cArgsW     = -1;
    295298            PWSTR *papwszArgs = NULL;
  • trunk/src/VBox/Runtime/r3/win/init-win.cpp

    r70215 r70345  
    7575/** The previous unhandled exception filter. */
    7676static LPTOP_LEVEL_EXCEPTION_FILTER         g_pfnUnhandledXcptFilter = NULL;
     77/** SystemTimeToTzSpecificLocalTime. */
     78decltype(SystemTimeToTzSpecificLocalTime)  *g_pfnSystemTimeToTzSpecificLocalTime = NULL;
    7779
    7880/** The native ntdll.dll handle. */
     
    525527    if (g_pfnGetSystemWindowsDirectoryW)
    526528        g_pfnGetSystemWindowsDirectoryW = (PFNGETWINSYSDIR)GetProcAddress(g_hModKernel32, "GetWindowsDirectoryW");
     529    g_pfnSystemTimeToTzSpecificLocalTime = (decltype(SystemTimeToTzSpecificLocalTime) *)GetProcAddress(g_hModKernel32, "SystemTimeToTzSpecificLocalTime");
    527530
    528531    /*
     
    531534    g_pfnNtQueryFullAttributesFile = (PFNNTQUERYFULLATTRIBUTESFILE)GetProcAddress(g_hModNtDll, "NtQueryFullAttributesFile");
    532535    g_pfnNtDuplicateToken          = (PFNNTDUPLICATETOKEN)GetProcAddress(         g_hModNtDll, "NtDuplicateToken");
     536
    533537
    534538    /*
  • trunk/src/VBox/Runtime/r3/win/internal-r3-win.h

    r70215 r70345  
    9797extern DECLHIDDEN(RTWINOSTYPE)      g_enmWinVer;
    9898#ifdef _WINDEF_
    99 extern DECLHIDDEN(HMODULE)          g_hModKernel32;
     99extern DECLHIDDEN(OSVERSIONINFOEXW) g_WinOsInfoEx;
     100
     101extern DECLHIDDEN(HMODULE)                         g_hModKernel32;
     102typedef UINT (WINAPI *PFNGETWINSYSDIR)(LPWSTR,UINT);
     103extern DECLHIDDEN(PFNGETWINSYSDIR)                 g_pfnGetSystemWindowsDirectoryW;
     104extern decltype(SystemTimeToTzSpecificLocalTime)  *g_pfnSystemTimeToTzSpecificLocalTime;
     105
    100106extern DECLHIDDEN(HMODULE)          g_hModNtDll;
    101 
    102 extern DECLHIDDEN(OSVERSIONINFOEXW) g_WinOsInfoEx;
    103 typedef UINT (WINAPI *PFNGETWINSYSDIR)(LPWSTR,UINT);
    104 extern DECLHIDDEN(PFNGETWINSYSDIR)  g_pfnGetSystemWindowsDirectoryW;
    105107typedef NTSTATUS (NTAPI *PFNNTQUERYFULLATTRIBUTESFILE)(struct _OBJECT_ATTRIBUTES *, struct _FILE_NETWORK_OPEN_INFORMATION *);
    106108extern DECLHIDDEN(PFNNTQUERYFULLATTRIBUTESFILE) g_pfnNtQueryFullAttributesFile;
    107109typedef NTSTATUS (NTAPI *PFNNTDUPLICATETOKEN)(HANDLE, ACCESS_MASK, struct _OBJECT_ATTRIBUTES *, BOOLEAN, TOKEN_TYPE, PHANDLE);
    108 extern DECLHIDDEN(PFNNTDUPLICATETOKEN)          g_pfnNtDuplicateToken;
     110extern DECLHIDDEN(PFNNTDUPLICATETOKEN)             g_pfnNtDuplicateToken;
    109111
    110112extern DECLHIDDEN(HMODULE)                         g_hModWinSock;
  • trunk/src/VBox/Runtime/r3/win/process-win.cpp

    r70215 r70345  
    144144static decltype(CreateProcessAsUserW)  *g_pfnCreateProcessAsUserW       = NULL;
    145145static decltype(LsaNtStatusToWinError) *g_pfnLsaNtStatusToWinError      = NULL;
     146/* user32.dll: */
     147static decltype(OpenWindowStationW)    *g_pfnOpenWindowStationW         = NULL;
     148static decltype(CloseWindowStation)    *g_pfnCloseWindowStation        = NULL;
    146149/* userenv.dll: */
    147150static PFNCREATEENVIRONMENTBLOCK        g_pfnCreateEnvironmentBlock     = NULL;
     
    361364        rc = RTLdrGetSymbol(hMod, "LsaNtStatusToWinError", (void **)&g_pfnLsaNtStatusToWinError);
    362365        if (RT_FAILURE(rc)) { g_pfnLsaNtStatusToWinError = NULL; Assert(g_enmWinVer <= kRTWinOSType_NT350); }
     366
     367        RTLdrClose(hMod);
     368    }
     369
     370    /*
     371     * user32.dll APIs.
     372     */
     373    rc = RTLdrLoadSystem("user32.dll", true /*fNoUnload*/, &hMod);
     374    if (RT_SUCCESS(rc))
     375    {
     376        rc = RTLdrGetSymbol(hMod, "OpenWindowStationW", (void **)&g_pfnOpenWindowStationW);
     377        if (RT_FAILURE(rc)) { g_pfnOpenWindowStationW = NULL; Assert(g_enmWinVer <= kRTWinOSType_NT310); }
     378
     379        rc = RTLdrGetSymbol(hMod, "CloseWindowStation", (void **)&g_pfnCloseWindowStation);
     380        if (RT_FAILURE(rc)) { g_pfnCloseWindowStation = NULL; Assert(g_enmWinVer <= kRTWinOSType_NT310); }
    363381
    364382        RTLdrClose(hMod);
     
    12991317    /** @todo Always mess with the interactive one? Maybe it's not there...  */
    13001318    *phWinStationOld = GetProcessWindowStation();
    1301     HWINSTA hWinStation0 = OpenWindowStationW(L"winsta0", FALSE /*fInherit*/, READ_CONTROL | WRITE_DAC);
     1319    HWINSTA hWinStation0;
     1320    if (g_pfnOpenWindowStationW)
     1321        hWinStation0 = g_pfnOpenWindowStationW(L"winsta0", FALSE /*fInherit*/, READ_CONTROL | WRITE_DAC);
     1322    else
     1323        hWinStation0 = OpenWindowStationA("winsta0", FALSE /*fInherit*/, READ_CONTROL | WRITE_DAC); /* (for NT3.1) */
    13021324    if (hWinStation0)
    13031325    {
     
    13261348        else
    13271349            AssertFailed();
    1328         CloseWindowStation(hWinStation0);
     1350        if (g_pfnCloseWindowStation)
     1351            g_pfnCloseWindowStation(hWinStation0);
    13291352    }
    13301353    else
     
    17111734                            {
    17121735                                HWINSTA hOldWinStation = NULL;
    1713                                 if (!fFound && g_enmWinVer <= kRTWinOSType_NT4) /** @todo test newer versions... */
     1736                                if (   !fFound
     1737                                    && g_enmWinVer <= kRTWinOSType_NT4) /** @todo test newer versions... */
    17141738                                    rtProcWinStationPrep(hTokenToUse, pStartupInfo, &hOldWinStation);
    17151739
  • trunk/src/VBox/Runtime/r3/win/time2-win.cpp

    r69111 r70345  
    3939#include "internal/time.h"
    4040
     41#include "internal-r3-win.h"
    4142
    4243
     
    5657RTDECL(PRTTIME) RTTimeLocalExplode(PRTTIME pTime, PCRTTIMESPEC pTimeSpec)
    5758{
    58     /*
    59      * FileTimeToLocalFileTime does not do the right thing, so we'll have
    60      * to convert to system time and SystemTimeToTzSpecificLocalTime instead.
    61      */
    6259    RTTIMESPEC LocalTime;
    63     SYSTEMTIME SystemTimeIn;
    64     FILETIME FileTime;
    65     if (FileTimeToSystemTime(RTTimeSpecGetNtFileTime(pTimeSpec, &FileTime), &SystemTimeIn))
     60    if (g_pfnSystemTimeToTzSpecificLocalTime)
    6661    {
    67         SYSTEMTIME SystemTimeOut;
    68         if (SystemTimeToTzSpecificLocalTime(NULL /* use current TZI */,
    69                                             &SystemTimeIn,
    70                                             &SystemTimeOut))
     62        /*
     63         * FileTimeToLocalFileTime does not do the right thing, so we'll have
     64         * to convert to system time and SystemTimeToTzSpecificLocalTime instead.
     65         */
     66        SYSTEMTIME SystemTimeIn;
     67        FILETIME FileTime;
     68        if (FileTimeToSystemTime(RTTimeSpecGetNtFileTime(pTimeSpec, &FileTime), &SystemTimeIn))
    7169        {
    72             if (SystemTimeToFileTime(&SystemTimeOut, &FileTime))
     70            SYSTEMTIME SystemTimeOut;
     71            if (g_pfnSystemTimeToTzSpecificLocalTime(NULL /* use current TZI */, &SystemTimeIn, &SystemTimeOut))
    7372            {
    74                 RTTimeSpecSetNtFileTime(&LocalTime, &FileTime);
    75                 pTime = RTTimeExplode(pTime, &LocalTime);
    76                 if (pTime)
    77                     pTime->fFlags = (pTime->fFlags & ~RTTIME_FLAGS_TYPE_MASK) | RTTIME_FLAGS_TYPE_LOCAL;
    78                 return pTime;
     73                if (SystemTimeToFileTime(&SystemTimeOut, &FileTime))
     74                {
     75                    RTTimeSpecSetNtFileTime(&LocalTime, &FileTime);
     76                    pTime = RTTimeExplode(pTime, &LocalTime);
     77                    if (pTime)
     78                        pTime->fFlags = (pTime->fFlags & ~RTTIME_FLAGS_TYPE_MASK) | RTTIME_FLAGS_TYPE_LOCAL;
     79                    return pTime;
     80                }
    7981            }
    8082        }
  • trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakes.cpp

    r70343 r70345  
    6868#define SetThreadAffinityMask                   Ignore_SetThreadAffinityMask
    6969#define GetProcessAffinityMask                  Ignore_GetProcessAffinityMask
    70 #define CommandLineToArgvW                      Ignore_CommandLineToArgvW
     70#define GetHandleInformation                    Ignore_GetHandleInformation
     71#define SetHandleInformation                    Ignore_SetHandleInformation
    7172
    7273#include <iprt/nt/nt-and-windows.h>
     
    100101#undef SetThreadAffinityMask
    101102#undef GetProcessAffinityMask
    102 #undef CommandLineToArgvW
     103#undef GetHandleInformation
     104#undef SetHandleInformation
    103105
    104106
     
    745747
    746748
    747 /** @todo This is actually in SHELL32. */
    748 DECL_KERNEL32(LPWSTR *) CommandLineToArgvW(LPCWSTR pwszCmdLine, int *pcArgs)
    749 {
    750     RESOLVE_ME(CommandLineToArgvW);
    751     if (pfnApi)
    752         return pfnApi(pwszCmdLine, pcArgs);
    753 
    754     *pcArgs = 0;
    755     return NULL;
     749DECL_KERNEL32(BOOL) GetHandleInformation(HANDLE hObject, DWORD *pfFlags)
     750{
     751    RESOLVE_ME(GetHandleInformation);
     752    if (pfnApi)
     753        return pfnApi(hObject, pfFlags);
     754
     755
     756    OBJECT_HANDLE_FLAG_INFORMATION  Info  = { 0, 0 };
     757    DWORD                           cbRet = sizeof(Info);
     758    NTSTATUS rcNt = NtQueryObject(hObject, ObjectHandleFlagInformation, &Info, sizeof(Info), &cbRet);
     759    if (NT_SUCCESS(rcNt))
     760    {
     761        *pfFlags = (Info.Inherit          ? HANDLE_FLAG_INHERIT : 0)
     762                 | (Info.ProtectFromClose ? HANDLE_FLAG_PROTECT_FROM_CLOSE : 0);
     763        return TRUE;
     764    }
     765    *pfFlags = 0;
     766    AssertMsg(rcNt == STATUS_INVALID_HANDLE, ("rcNt=%#x\n", rcNt));
     767    SetLastError(rcNt == STATUS_INVALID_HANDLE ? ERROR_INVALID_HANDLE : ERROR_INVALID_FUNCTION);
     768    return FALSE;
     769}
     770
     771
     772DECL_KERNEL32(BOOL) SetHandleInformation(HANDLE hObject, DWORD fMask, DWORD fFlags)
     773{
     774    RESOLVE_ME(SetHandleInformation);
     775    if (pfnApi)
     776        return pfnApi(hObject, fMask, fFlags);
     777
     778    SetLastError(ERROR_INVALID_FUNCTION);
     779    return FALSE;
    756780}
    757781
  • trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakesA.asm

    r70341 r70345  
    11; $Id$
    22;; @file
    3 ; IPRT - Wrappers for kernel32 APIs misisng NT4.
     3; IPRT - Wrappers for kernel32 APIs missing in NT4 and earlier.
    44;
    55
     
    7777MAKE_IMPORT_ENTRY SetThreadAffinityMask, 8
    7878MAKE_IMPORT_ENTRY GetProcessAffinityMask, 12
    79 MAKE_IMPORT_ENTRY CommandLineToArgvW, 8 ; Lazy bird: this lives in shell32.
     79MAKE_IMPORT_ENTRY GetHandleInformation, 8
     80MAKE_IMPORT_ENTRY SetHandleInformation, 12
    8081
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