VirtualBox

Changeset 46561 in vbox for trunk/src


Ignore:
Timestamp:
Jun 14, 2013 1:39:16 PM (12 years ago)
Author:
vboxsync
Message:

Runtime/r3/win: rtldrNative restriction

File:
1 edited

Legend:

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

    r44528 r46561  
    3636#include <iprt/err.h>
    3737#include <iprt/alloca.h>
     38#include <iprt/once.h>
    3839#include <iprt/string.h>
    3940#include "internal/ldr.h"
    4041
     42static RTONCE g_Once = RTONCE_INITIALIZER;
     43
     44static DECLCALLBACK(int) rtldrOnceSetDllDirectory(void *pvUser)
     45{
     46    HMODULE hmod = GetModuleHandle(TEXT("kernel32.dll"));
     47    if (hmod)
     48    {
     49        typedef BOOLEAN (WINAPI *PFNSETDLLDIRECTORY)(LPCWSTR);
     50        PFNSETDLLDIRECTORY pfn = (PFNSETDLLDIRECTORY)GetProcAddress(hmod, "SetDllDirectoryW");
     51        if (pfn)
     52        {
     53            BOOL fOk = pfn(L"");
     54            if (!fOk)
     55                return RTErrConvertFromWin32(GetLastError());
     56        }
     57    }
     58    return VINF_SUCCESS;
     59}
    4160
    4261int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo)
     
    6079
    6180    /*
     81     * Don't allow loading DLLs from the current directory.
     82     */
     83#if 0
     84    int rc = RTOnce(&g_Once, rtldrOnceSetDllDirectory, NULL);
     85    if (RT_FAILURE(rc))
     86        return rc;
     87#else
     88    int rc = VINF_SUCCESS;
     89#endif
     90
     91    /*
    6292     * Attempt load.
    6393     */
     
    73103     */
    74104    DWORD dwErr = GetLastError();
    75     int   rc    = RTErrConvertFromWin32(dwErr);
     105    rc = RTErrConvertFromWin32(dwErr);
    76106    return RTErrInfoSetF(pErrInfo, rc, "GetLastError=%u", dwErr);
    77107}
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