VirtualBox

Changeset 34251 in vbox


Ignore:
Timestamp:
Nov 22, 2010 3:23:32 PM (14 years ago)
Author:
vboxsync
Message:

IPRT/process-win: Added mapping function for specific Windows error codes.

File:
1 edited

Legend:

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

    r33540 r34251  
    264264                          NULL /*pszAsUser*/, NULL /* pszPassword*/,
    265265                          pProcess);
     266}
     267
     268
     269/**
     270 * Map some important or much used Windows error codes
     271 * to our error codes.
     272 *
     273 * @return  Mapped IPRT status code.
     274 * @param   dwError                         Windows error code to map to IPRT code.
     275 */
     276static int rtProcMapErrorCodes(DWORD dwError)
     277{
     278    int rc;
     279    switch (dwError)
     280    {
     281        case ERROR_NOACCESS:
     282        case ERROR_PRIVILEGE_NOT_HELD:
     283            rc = VERR_PERMISSION_DENIED;
     284            break;
     285
     286        case ERROR_PASSWORD_EXPIRED:
     287        case ERROR_ACCOUNT_RESTRICTION: /* See: http://support.microsoft.com/kb/303846/ */
     288        case ERROR_PASSWORD_RESTRICTION:
     289            rc = VERR_AUTHENTICATION_FAILURE;
     290            break;
     291
     292        default:
     293            /* Could trigger a debug assertion! */
     294            rc = RTErrConvertFromWin32(dwError);
     295            break;
     296    }
     297    return rc;
    266298}
    267299
     
    505537static int rtProcUserLogon(PRTUTF16 pwszUser, PRTUTF16 pwszPassword, PRTUTF16 pwszDomain, HANDLE *phToken)
    506538{
    507     int rc = VINF_SUCCESS;
    508539    /** @todo Add domain support! */
    509540    BOOL fRc = LogonUserW(pwszUser,
     
    521552                          phToken);
    522553    if (!fRc)
    523         rc = RTErrConvertFromWin32(GetLastError());
    524     return rc;
     554        return rtProcMapErrorCodes(GetLastError());
     555    return VINF_SUCCESS;
    525556}
    526557
     
    904935        && dwErr != NO_ERROR)
    905936    {
    906         /*
    907          * Map some important or much used Windows error codes
    908          * to our error codes.
    909          */
    910         switch (dwErr)
    911         {
    912             case ERROR_NOACCESS:
    913             case ERROR_PRIVILEGE_NOT_HELD:
    914                 rc = VERR_PERMISSION_DENIED;
    915                 break;
    916 
    917             case ERROR_PASSWORD_EXPIRED:
    918             case ERROR_ACCOUNT_RESTRICTION: /* See: http://support.microsoft.com/kb/303846/ */
    919                 rc = VERR_AUTHENTICATION_FAILURE;
    920                 break;
    921 
    922             default:
    923                 /* Could trigger a debug assertion! */
    924                 rc = RTErrConvertFromWin32(dwErr);
    925                 break;
    926         }
     937        rc = rtProcMapErrorCodes(dwErr);
    927938    }
    928939    return rc;
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