VirtualBox

Changeset 73097 in vbox for trunk/src/VBox/Runtime/r3/win


Ignore:
Timestamp:
Jul 12, 2018 9:06:33 PM (7 years ago)
Author:
vboxsync
Message:

*: Made RT_UOFFSETOF, RT_OFFSETOF, RT_UOFFSETOF_ADD and RT_OFFSETOF_ADD work like builtin_offsetof() and require compile time resolvable requests, adding RT_UOFFSETOF_DYN for the dynamic questions that can only be answered at runtime.

Location:
trunk/src/VBox/Runtime/r3/win
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/RTSystemShutdown-win.cpp

    r70615 r73097  
    7676                                       FALSE /*DisableAllPrivileges*/,
    7777                                       &u.TokenPriv,
    78                                        RT_OFFSETOF(TOKEN_PRIVILEGES, Privileges[1]),
     78                                       RT_UOFFSETOF(TOKEN_PRIVILEGES, Privileges[1]),
    7979                                       NULL,
    8080                                       NULL) )
  • trunk/src/VBox/Runtime/r3/win/direnum-win.cpp

    r69753 r73097  
    161161        if (cbDirEntry < RT_UOFFSETOF(RTDIRENTRY, szName[2]))
    162162        {
    163             AssertMsgFailed(("Invalid *pcbDirEntry=%d (min %d)\n", *pcbDirEntry, RT_OFFSETOF(RTDIRENTRY, szName[2])));
     163            AssertMsgFailed(("Invalid *pcbDirEntry=%zu (min %zu)\n", *pcbDirEntry, RT_UOFFSETOF(RTDIRENTRY, szName[2])));
    164164            return VERR_INVALID_PARAMETER;
    165165        }
     
    203203    const char  *pszName    = pDir->pszName;
    204204    const size_t cchName    = pDir->cchName;
    205     const size_t cbRequired = RT_OFFSETOF(RTDIRENTRY, szName[1]) + cchName;
     205    const size_t cbRequired = RT_UOFFSETOF(RTDIRENTRY, szName[1]) + cchName;
    206206    if (pcbDirEntry)
    207207        *pcbDirEntry = cbRequired;
     
    255255        if (cbDirEntry < RT_UOFFSETOF(RTDIRENTRYEX, szName[2]))
    256256        {
    257             AssertMsgFailed(("Invalid *pcbDirEntry=%d (min %d)\n", *pcbDirEntry, RT_OFFSETOF(RTDIRENTRYEX, szName[2])));
     257            AssertMsgFailed(("Invalid *pcbDirEntry=%zu (min %zu)\n", *pcbDirEntry, RT_UOFFSETOF(RTDIRENTRYEX, szName[2])));
    258258            return VERR_INVALID_PARAMETER;
    259259        }
     
    297297    const char  *pszName    = pDir->pszName;
    298298    const size_t cchName    = pDir->cchName;
    299     const size_t cbRequired = RT_OFFSETOF(RTDIRENTRYEX, szName[1]) + cchName;
     299    const size_t cbRequired = RT_UOFFSETOF(RTDIRENTRYEX, szName[1]) + cchName;
    300300    if (pcbDirEntry)
    301301        *pcbDirEntry = cbRequired;
  • trunk/src/VBox/Runtime/r3/win/fileaio-win.cpp

    r69111 r73097  
    122122#define AIO_CONTEXT_WAKEUP_EVENT 1
    123123/** Converts a pointer to an OVERLAPPED structure to a internal request. */
    124 #define OVERLAPPED_2_RTFILEAIOREQINTERNAL(pOverlapped) ( (PRTFILEAIOREQINTERNAL)((uintptr_t)(pOverlapped) - RT_OFFSETOF(RTFILEAIOREQINTERNAL, Overlapped)) )
     124#define OVERLAPPED_2_RTFILEAIOREQINTERNAL(pOverlapped) ( (PRTFILEAIOREQINTERNAL)((uintptr_t)(pOverlapped) - RT_UOFFSETOF(RTFILEAIOREQINTERNAL, Overlapped)) )
    125125
    126126RTR3DECL(int) RTFileAioGetLimits(PRTFILEAIOLIMITS pAioLimits)
  • trunk/src/VBox/Runtime/r3/win/krnlmod-win.cpp

    r69434 r73097  
    9595    if (NT_SUCCESS(rcNt) || rcNt == STATUS_INFO_LENGTH_MISMATCH)
    9696    {
    97         ULONG cbKrnlMods = RT_OFFSETOF(RTL_PROCESS_MODULES, Modules[KrnlModsSize.NumberOfModules]);
     97        ULONG cbKrnlMods = RT_UOFFSETOF_DYN(RTL_PROCESS_MODULES, Modules[KrnlModsSize.NumberOfModules]);
    9898        PRTL_PROCESS_MODULES pKrnlMods = (PRTL_PROCESS_MODULES)RTMemAllocZ(cbKrnlMods);
    9999        if (RT_LIKELY(pKrnlMods))
     
    127127    RT_NOREF2(pModInfo, phKrnlModInfo);
    128128    size_t cchFilePath = strlen((const char *)&pModInfo->FullPathName[0]) + 1;
    129     PRTKRNLMODINFOINT pThis = (PRTKRNLMODINFOINT)RTMemAllocZ(RT_OFFSETOF(RTKRNLMODINFOINT, achFilePath[cchFilePath]));
     129    PRTKRNLMODINFOINT pThis = (PRTKRNLMODINFOINT)RTMemAllocZ(RT_UOFFSETOF_DYN(RTKRNLMODINFOINT, achFilePath[cchFilePath]));
    130130    if (RT_LIKELY(pThis))
    131131    {
  • trunk/src/VBox/Runtime/r3/win/localipc-win.cpp

    r69536 r73097  
    401401         * Allocate and initialize the instance data.
    402402         */
    403         size_t cbThis = RT_OFFSETOF(RTLOCALIPCSERVERINT, wszName[cwcFullName + 1]);
     403        size_t cbThis = RT_UOFFSETOF_DYN(RTLOCALIPCSERVERINT, wszName[cwcFullName + 1]);
    404404        PRTLOCALIPCSERVERINT pThis = (PRTLOCALIPCSERVERINT)RTMemAllocVar(cbThis);
    405405        AssertReturn(pThis, VERR_NO_MEMORY);
  • trunk/src/VBox/Runtime/r3/win/process-win.cpp

    r70486 r73097  
    831831            uOld = uNew;
    832832            SetLastError(NO_ERROR);
    833             DWORD cbActual = RT_OFFSETOF(TOKEN_PRIVILEGES, Privileges[1]);
     833            DWORD cbActual = RT_UOFFSETOF(TOKEN_PRIVILEGES, Privileges[1]);
    834834            AdjustTokenPrivileges(hToken, FALSE /*fDisableAllPrivileges*/, &uNew.TokPriv, cbActual, &uOld.TokPriv, &cbActual);
    835835            if (GetLastError() != NO_ERROR)
     
    11241124    } AceBuf;
    11251125    RT_ZERO(AceBuf);
    1126     uint32_t const cbAllowedAce = RT_OFFSETOF(ACCESS_ALLOWED_ACE, SidStart) + cbSid;
     1126    uint32_t const cbAllowedAce = RT_UOFFSETOF(ACCESS_ALLOWED_ACE, SidStart) + cbSid;
    11271127    AssertReturn(cbAllowedAce <= sizeof(AceBuf), false);
    11281128
     
    18481848                    SIZE_T cbCopied = 0;
    18491849                    if (!ReadProcessMemory(hDstProcess,
    1850                                            (char *)BasicInfo.PebBaseAddress + RT_OFFSETOF(PEB_COMMON, ProcessParameters),
     1850                                           (char *)BasicInfo.PebBaseAddress + RT_UOFFSETOF(PEB_COMMON, ProcessParameters),
    18511851                                           ppvDstProcParamCache, sizeof(*ppvDstProcParamCache), &cbCopied))
    18521852                    {
     
    20062006                PVOID pvDstProcParamCache = NULL;
    20072007                rtProcWinDupStdHandleIntoChild(pStartupInfo->hStdInput, pProcInfo->hProcess,
    2008                                                RT_OFFSETOF(RTL_USER_PROCESS_PARAMETERS, StandardInput), &pvDstProcParamCache);
     2008                                               RT_UOFFSETOF(RTL_USER_PROCESS_PARAMETERS, StandardInput), &pvDstProcParamCache);
    20092009                rtProcWinDupStdHandleIntoChild(pStartupInfo->hStdOutput, pProcInfo->hProcess,
    2010                                                RT_OFFSETOF(RTL_USER_PROCESS_PARAMETERS, StandardOutput), &pvDstProcParamCache);
     2010                                               RT_UOFFSETOF(RTL_USER_PROCESS_PARAMETERS, StandardOutput), &pvDstProcParamCache);
    20112011                rtProcWinDupStdHandleIntoChild(pStartupInfo->hStdError,  pProcInfo->hProcess,
    2012                                                RT_OFFSETOF(RTL_USER_PROCESS_PARAMETERS, StandardError), &pvDstProcParamCache);
     2012                                               RT_UOFFSETOF(RTL_USER_PROCESS_PARAMETERS, StandardError), &pvDstProcParamCache);
    20132013
    20142014                if (ResumeThread(pProcInfo->hThread) != ~(DWORD)0)
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