예제 #1
0
파일: getpathp.c 프로젝트: cpcloud/cpython
int
_Py_CheckPython3()
{
    wchar_t py3path[MAXPATHLEN+1];
    wchar_t *s;
    if (python3_checked)
        return hPython3 != NULL;
    python3_checked = 1;

    /* If there is a python3.dll next to the python3y.dll,
       assume this is a build tree; use that DLL */
    wcscpy(py3path, dllpath);
    s = wcsrchr(py3path, L'\\');
    if (!s)
        s = py3path;
    wcscpy(s, L"\\python3.dll");
    hPython3 = LoadLibraryExW(py3path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
    if (hPython3 != NULL)
        return 1;

    /* Check sys.prefix\DLLs\python3.dll */
    wcscpy(py3path, Py_GetPrefix());
    wcscat(py3path, L"\\DLLs\\python3.dll");
    hPython3 = LoadLibraryExW(py3path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
    return hPython3 != NULL;
}
예제 #2
0
static void *_load_dll(const wchar_t *lib_path, const wchar_t *dll_search_path)
{
    void *result;

    typedef PVOID(WINAPI *AddDllDirectoryF)  (PCWSTR);
    typedef BOOL(WINAPI *RemoveDllDirectoryF)(PVOID);
    AddDllDirectoryF pAddDllDirectory;
    RemoveDllDirectoryF pRemoveDllDirectory;
    pAddDllDirectory = (AddDllDirectoryF)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "AddDllDirectory");
    pRemoveDllDirectory = (RemoveDllDirectoryF)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "RemoveDllDirectory");

    if (pAddDllDirectory && pRemoveDllDirectory) {

        result = LoadLibraryExW(lib_path, NULL,
                               LOAD_LIBRARY_SEARCH_SYSTEM32);

        if (!result) {
            PVOID cookie = pAddDllDirectory(dll_search_path);
            result = LoadLibraryExW(lib_path, NULL,
                                    LOAD_LIBRARY_SEARCH_SYSTEM32 |
                                    LOAD_LIBRARY_SEARCH_USER_DIRS);
            pRemoveDllDirectory(cookie);
        }
    } else {
        result = LoadLibraryW(lib_path);
        if (!result) {
            SetDllDirectoryW(dll_search_path);
            result = LoadLibraryW(lib_path);
            SetDllDirectoryW(L"");
        }
    }

    return result;
}
예제 #3
0
XAudio2Thread::XAudio2Thread()
{
	if (!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL))
	{
		LOG_ERROR(GENERAL, "XAudio: failed to increase thread priority");
	}

	if (auto lib2_9 = LoadLibraryExW(L"XAudio2_9.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32))
	{
		// xa28* implementation is fully compatible with library 2.9
		xa28_init(lib2_9);

		m_funcs.destroy = &xa28_destroy;
		m_funcs.play    = &xa28_play;
		m_funcs.flush   = &xa28_flush;
		m_funcs.stop    = &xa28_stop;
		m_funcs.open    = &xa28_open;
		m_funcs.add     = &xa28_add;

		LOG_SUCCESS(GENERAL, "XAudio 2.9 initialized");
		return;
	}

	if (auto lib2_7 = LoadLibraryExW(L"XAudio2_7.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32))
	{
		xa27_init(lib2_7);

		m_funcs.destroy = &xa27_destroy;
		m_funcs.play    = &xa27_play;
		m_funcs.flush   = &xa27_flush;
		m_funcs.stop    = &xa27_stop;
		m_funcs.open    = &xa27_open;
		m_funcs.add     = &xa27_add;

		LOG_SUCCESS(GENERAL, "XAudio 2.7 initialized");
		return;
	}
	
	if (auto lib2_8 = LoadLibraryExW(L"XAudio2_8.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32))
	{
		xa28_init(lib2_8);

		m_funcs.destroy = &xa28_destroy;
		m_funcs.play    = &xa28_play;
		m_funcs.flush   = &xa28_flush;
		m_funcs.stop    = &xa28_stop;
		m_funcs.open    = &xa28_open;
		m_funcs.add     = &xa28_add;

		LOG_SUCCESS(GENERAL, "XAudio 2.8 initialized");
		return;
	}

	fmt::throw_exception("No supported XAudio2 library found");
}
예제 #4
0
static void real_init(void) {
#ifdef VS_TARGET_OS_WINDOWS
    // portable
    const std::wstring pythonDllName = L"python37.dll";
    HMODULE module;
    GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)&real_init, &module);
    std::vector<wchar_t> pathBuf(65536);
    GetModuleFileNameW(module, pathBuf.data(), (DWORD)pathBuf.size());
    std::wstring dllPath = pathBuf.data();
    dllPath.resize(dllPath.find_last_of('\\') + 1);
    std::wstring portableFilePath = dllPath + L"portable.vs";
    FILE *portableFile = _wfopen(portableFilePath.c_str(), L"rb");
    bool isPortable = !!portableFile;
    if (portableFile)
        fclose(portableFile);

    HMODULE pythonDll = nullptr;

    if (isPortable) {
        std::wstring pyPath = dllPath + L"\\" + pythonDllName;
        pythonDll = LoadLibraryExW(pyPath.c_str(), nullptr, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
    } else {
        DWORD dwType = REG_SZ;
        HKEY hKey = 0;

        wchar_t value[1024];
        DWORD valueLength = 1000;
        if (RegOpenKeyW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\VapourSynth", &hKey) != ERROR_SUCCESS)
            return;
        LSTATUS status = RegQueryValueExW(hKey, L"PythonPath", nullptr, &dwType, (LPBYTE)&value, &valueLength);
        RegCloseKey(hKey);
        if (status != ERROR_SUCCESS)
            return;

        std::wstring pyPath = value;
        pyPath += L"\\" + pythonDllName;

        pythonDll = LoadLibraryExW(pyPath.c_str(), nullptr, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
    }
    if (!pythonDll)
        return;
#endif
    int preInitialized = Py_IsInitialized();
    if (!preInitialized)
        Py_InitializeEx(0);
    s = PyGILState_Ensure();
    if (import_vapoursynth())
        return;
    if (vpy_initVSScript())
        return;
    ts = PyEval_SaveThread();
    initialized = true;
}
예제 #5
0
bool Win32DllLoader::Load()
{
  if (m_dllHandle != NULL)
    return true;

  CStdString strFileName = GetFileName();

  CStdStringW strDllW;
  g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(strFileName), strDllW);
  m_dllHandle = LoadLibraryExW(strDllW.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
  if (!m_dllHandle)
  {
    LPVOID lpMsgBuf;
    DWORD dw = GetLastError(); 

    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, 0, (LPTSTR) &lpMsgBuf, 0, NULL );
    CLog::Log(LOGERROR, "%s: Failed to load %s with error %d:%s", __FUNCTION__, CSpecialProtocol::TranslatePath(strFileName).c_str(), dw, lpMsgBuf);
    LocalFree(lpMsgBuf);
    return false;
  }

  // handle functions that the dll imports
  if (NeedsHooking(strFileName.c_str()))
    OverrideImports(strFileName);
  else
    bIsSystemDll = true;

  return true;
}
예제 #6
0
BOOL WINAPI PickIconDlg(
    HWND hwndOwner,
    LPWSTR lpstrFile,
    UINT nMaxFile,
    INT* lpdwIconIndex)
{
    HMODULE hLibrary;
    int res;
    PICK_ICON_CONTEXT IconContext;

    hLibrary = LoadLibraryExW(lpstrFile, NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE);
    IconContext.hLibrary = hLibrary;
    IconContext.Index = *lpdwIconIndex;
    wcscpy(IconContext.szName, lpstrFile);

    res = DialogBoxParamW(shell32_hInstance, MAKEINTRESOURCEW(IDD_PICK_ICON), hwndOwner, PickIconProc, (LPARAM)&IconContext);
    if (res)
    {
        wcscpy(lpstrFile, IconContext.szName);
        *lpdwIconIndex = IconContext.Index;
    }

    FreeLibrary(hLibrary);
    return res;
}
예제 #7
0
tt_result_t tt_dll_create_ntv(IN tt_dll_ntv_t *dll,
                              IN const tt_char_t *path,
                              IN OPT tt_dll_attr_t *attr)
{
    void *handle;
    DWORD dwFlags = 0;
    wchar_t *w_path;

    TT_ASSERT(dll != NULL);
    TT_ASSERT(path != NULL);

    // may set mode according to attr;
    // dwFlags |= ...;

    w_path = tt_wchar_create(path, 0, NULL);
    if (w_path == NULL) {
        return TT_FAIL;
    }

    handle = LoadLibraryExW(w_path, NULL, dwFlags);
    tt_wchar_destroy(w_path);
    if (handle == NULL) {
        TT_ERROR_NTV("LoadLibraryExW failed: %s");
        return TT_FAIL;
    }

    dll->handle = handle;
    return TT_SUCCESS;
}
예제 #8
0
void LOCATOR::SYMSRV::Init()
{
    AutoLock lock(&m_cs);

    if (m_fInit) {
        return;
    }

    m_fInit = true;

    PREFAST_SUPPRESS(6321, "It's ok");
    HMODULE hmod = LoadLibraryExW(L"SYMSRV.DLL", NULL, 0);

    if ((UINT_PTR) hmod < 32) {
        return;
    }

    m_hmod = hmod;

    m_pfnsymbolserverw =
        PFNSYMBOLSERVERW(GetProcAddress(m_hmod, "SymbolServerW"));

    m_pfnsymbolserversetoptions =
        PFNSYMBOLSERVERSETOPTIONS(GetProcAddress(m_hmod, "SymbolServerSetOptions"));

    m_pfnsymbolserverstorefilew = 
        PFNSYMBOLSERVERSTOREFILEW(GetProcAddress(m_hmod, "SymbolServerStoreFileW"));
}
예제 #9
0
HMODULE LoadCoreClrFromPath(const std::wstring& coreclr_dir, dnx::trace_writer& trace_writer)
{
    auto loader_module = LoadLoaderModule(trace_writer);
    if (!loader_module)
    {
        trace_writer.write(L"Failed to load loader module", false);
        return nullptr;
    }

    auto pfnAddDllDirectory = (FnAddDllDirectory)GetProcAddress(loader_module, "AddDllDirectory");
    auto pfnSetDefaultDllDirectories = (FnSetDefaultDllDirectories)GetProcAddress(loader_module, "SetDefaultDllDirectories");
    if (!pfnAddDllDirectory || !pfnSetDefaultDllDirectories)
    {
        trace_writer.write(std::wstring(L"Failed to find function: ")
            .append(pfnAddDllDirectory ? L"SetDefaultDllDirectories" : L"AddDllDirectory"), false);
        return nullptr;
    }

    pfnAddDllDirectory(coreclr_dir.c_str());

    // Modify the default dll flags so that dependencies can be found in this path
    pfnSetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_USER_DIRS);

    return LoadLibraryExW(dnx::utils::path_combine(coreclr_dir, L"coreclr.dll").c_str(), NULL, 0);
}
예제 #10
0
파일: pyi_utils.c 프로젝트: cbgp/diyabc
/* Load the shared dynamic library (DLL) */
dylib_t pyi_utils_dlopen(const char *dllpath)
{

#ifdef _WIN32
    wchar_t * dllpath_w;
    dylib_t ret;
#else
    int dlopenMode = RTLD_NOW | RTLD_GLOBAL;
#endif

#ifdef AIX
    /* Append the RTLD_MEMBER to the open mode for 'dlopen()'
     * in order to load shared object member from library.
     */
    dlopenMode |= RTLD_MEMBER;
#endif

#ifdef _WIN32
    dllpath_w = pyi_win32_utils_from_utf8(NULL, dllpath, 0);
	ret = LoadLibraryExW(dllpath_w, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
	free(dllpath_w);
	return ret;
#else
	return dlopen(dllpath, dlopenMode);
#endif

}
예제 #11
0
파일: loader.c 프로젝트: RareHare/reactos
/*
 * @implemented
 */
HINSTANCE
WINAPI
LoadLibraryW(LPCWSTR lpLibFileName)
{
    /* Call Ex version of the API */
    return LoadLibraryExW (lpLibFileName, 0, 0);
}
예제 #12
0
파일: start.c 프로젝트: ABI-Software/py2exe
/*
  Load the Python DLL, either from the resource in the library file (if found),
  or from the file system.
  
  This function should also be used to get all the function pointers that
  python3.c needs at once.
 */
HMODULE load_pythondll(void)
{
	HMODULE hmod_pydll;
	HANDLE hrsrc;
	HMODULE hmod = LoadLibraryExW(libfilename, NULL, LOAD_LIBRARY_AS_DATAFILE);

	// Try to locate pythonxy.dll as resource in the exe
	hrsrc = FindResource(hmod, MAKEINTRESOURCE(1), PYTHONDLL);
	if (hrsrc) {
		HGLOBAL hgbl;
		DWORD size;
		char *ptr;
		hgbl = LoadResource(hmod, hrsrc);
		size = SizeofResource(hmod, hrsrc);
		ptr = LockResource(hgbl);
		hmod_pydll = MyLoadLibrary(PYTHONDLL, ptr, NULL);
	} else
		/*
		  XXX We should probably call LoadLibraryEx with
		  LOAD_WITH_ALTERED_SEARCH_PATH so that really our own one is
		  used.
		 */
		hmod_pydll = LoadLibrary(PYTHONDLL);
	FreeLibrary(hmod);
	return hmod_pydll;
}
예제 #13
0
/*
 * Class:     com_kenai_jffi_Foreign
 * Method:    dlopen
 * Signature: (Ljava/lang/String;I)J
 */
JNIEXPORT jlong JNICALL
Java_com_kenai_jffi_Foreign_dlopen(JNIEnv* env, jobject self, jstring jPath, jint jFlags)
{
#ifdef _WIN32
    wchar_t path[PATH_MAX];
    getWideString(env, path, jstr, sizeof(path) / sizeof(path[0]));
    return p2j(LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH));
#else
    char path_[PATH_MAX];
    const char* path = NULL; // Handle dlopen(NULL, flags);
    int flags = 0;
#define F(x) (jFlags & com_kenai_jffi_Foreign_RTLD_##x) != 0 ? RTLD_##x : 0;
    flags |= F(LAZY);
    flags |= F(GLOBAL);
    flags |= F(LOCAL);
    flags |= F(NOW);
#undef F

#ifdef _AIX
    flags |= RTLD_MEMBER; //  Needed for AIX
#endif
    
    if (jPath != NULL) {
        path = path_;
        getMultibyteString(env, path_, jPath, sizeof(path_));
    }
    return p2j(dl_open(path, flags));
#endif
}
예제 #14
0
int32_t CSystem::GetSystemVersionNum()
{
	DWORD dwVersion = 0;
	HMODULE hinstDLL = LoadLibraryExW(L"kernel32.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
	if (hinstDLL != NULL)
	{
		HRSRC hResInfo = FindResource(hinstDLL, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION);
		if (hResInfo != NULL)
		{
			HGLOBAL hResData = LoadResource(hinstDLL, hResInfo);
			if (hResData != NULL)
			{
				static const WCHAR wszVerInfo[] = L"VS_VERSION_INFO";
				struct VS_VERSIONINFO {
					WORD wLength;
					WORD wValueLength;
					WORD wType;
					WCHAR szKey[ARRAYSIZE(wszVerInfo)];
					VS_FIXEDFILEINFO Value;
					WORD Children[];
				} *lpVI = (struct VS_VERSIONINFO *)LockResource(hResData);
				if ((lpVI != NULL) && (lstrcmpiW(lpVI->szKey, wszVerInfo) == 0) && (lpVI->wValueLength > 0))
				{
					dwVersion = lpVI->Value.dwFileVersionMS;
				}
			}
		}
		FreeLibrary(hinstDLL);
	}
	return dwVersion;
}
예제 #15
0
파일: aereg.cpp 프로젝트: cnh/BitMate
JNIEXPORT jboolean JNICALL 
Java_org_gudy_azureus2_platform_win32_access_impl_AEWin32AccessInterface_testNativeAvailabilityW(
	JNIEnv *env, 
	jclass	cla, 
	jstring _name )
{
	WCHAR		name[2048];
    
	if ( !jstringToCharsW( env, _name, name, sizeof( name )-1)){

		return( 0 );
	}


	HMODULE	mod = 
		LoadLibraryExW( 
			name,
			NULL,
			LOAD_LIBRARY_AS_DATAFILE );

	if ( mod == NULL ){

		return( 0 );

	}else{

		FreeLibrary( mod );

		return( 1 );
	}
}
예제 #16
0
/*
    Win2KDisable : DisallowWin32kSystemCalls
    SET DNX_WIN32K_DISABLE=1
*/
void Win32KDisable(dnx::trace_writer& trace_writer)
{
    wchar_t buff[2] = { 0 , 0 };

    if (GetEnvironmentVariable(L"DNX_WIN32K_DISABLE", buff, 2) != 1 || buff[0] != L'1')
    {
        return;
    }

    auto process_threads_module = LoadLibraryExW(L"api-ms-win-core-processthreads-l1-1-1.dll", NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
    if (process_threads_module)
    {
        auto SetProcessMitigationPolicy_function = (FnSetProcessMitigationPolicy)GetProcAddress(process_threads_module, "SetProcessMitigationPolicy");
        if (SetProcessMitigationPolicy_function)
        {
            PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY system_call_disable_policy = {};
            system_call_disable_policy.DisallowWin32kSystemCalls = 1;

            if (SetProcessMitigationPolicy_function(ProcessSystemCallDisablePolicy,
                &system_call_disable_policy, sizeof(system_call_disable_policy)))
            {
                trace_writer.write(L"DNX_WIN32K_DISABLE successful", false);
            }
        }
    }

    FreeLibrary(process_threads_module);
}
예제 #17
0
파일: File.cpp 프로젝트: jetlive/skiaming
bool File::LoadFromResource(const wstring& sFileName, int nResId, SafeXMLReader xml)
{
	HMODULE hLib = LoadLibraryExW(sFileName.c_str(), NULL, LOAD_LIBRARY_AS_DATAFILE);
	if (NULL == hLib) return false;

	HRSRC hResourceInfo = FindResourceExW(hLib, RT_MANIFEST, MAKEINTRESOURCE(nResId) ,0);
	if (NULL == hResourceInfo) return false;

	HGLOBAL hGlobal = ::LoadResource(hLib, hResourceInfo);
	bool bResult = true;

	if (NULL == hGlobal) {
		bResult = false;			
	}
	else {
		int nResSize = SizeofResource(hLib, hResourceInfo);	
		LPVOID pResValue = LockResource(hGlobal);

		if (pResValue != NULL) {
			if (S_OK != xml->LoadFromBuffer(reinterpret_cast<const BYTE *>(pResValue), nResSize)) {
				bResult = false;	
			}
		}
		else bResult = false;
	}

	FreeLibrary(hLib);

	return bResult;
}
예제 #18
0
파일: run.cpp 프로젝트: CoolOppo/ezgdi
int WINAPI wWinMain(HINSTANCE ins, HINSTANCE prev, LPWSTR cmd, int show)
{
   _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
   OleInitialize(NULL);

   WCHAR path [MAX_PATH];
   if(GetModuleFileNameW(NULL, path, _countof(path))) {
      PathRenameExtensionW(path, L".dll");
      //DONT_RESOLVE_DLL_REFERENCESを指定すると依存関係の解決や
      //DllMainの呼び出しが行われない
      hinstDLL = LoadLibraryExW(path, NULL, DONT_RESOLVE_DLL_REFERENCES);
   }
   if(!hinstDLL) {
      errmsg(IDS_DLL, HresultFromLastError());
   } else {
      PathRemoveFileSpecW(path);
      SetCurrentDirectoryW(path);

      HRESULT hr = HookAndExecute(show);
      if(hr != S_OK) {
         errmsg(IDC_EXEC, hr);
      }
   }

   OleUninitialize();
   return 0;
}
예제 #19
0
파일: dlload.c 프로젝트: JuliaLang/julia
JL_DLLEXPORT void *jl_dlopen(const char *filename, unsigned flags)
{
#if defined(_OS_WINDOWS_)
    needsSymRefreshModuleList = 1;
    size_t len = MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
    if (!len) return NULL;
    WCHAR *wfilename = (WCHAR*)alloca(len * sizeof(WCHAR));
    if (!MultiByteToWideChar(CP_UTF8, 0, filename, -1, wfilename, len)) return NULL;
    return LoadLibraryExW(wfilename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
#else
    dlerror(); /* Reset error status. */
    return dlopen(filename,
                  (flags & JL_RTLD_NOW ? RTLD_NOW : RTLD_LAZY)
                  | JL_RTLD(flags, LOCAL)
                  | JL_RTLD(flags, GLOBAL)
#ifdef RTLD_NODELETE
                  | JL_RTLD(flags, NODELETE)
#endif
#ifdef RTLD_NOLOAD
                  | JL_RTLD(flags, NOLOAD)
#endif
#if defined(RTLD_DEEPBIND) && !defined(JL_ASAN_ENABLED)
                  | JL_RTLD(flags, DEEPBIND)
#endif
#ifdef RTLD_FIRST
                  | JL_RTLD(flags, FIRST)
#endif
                  );
#endif
}
예제 #20
0
bool Win32DllLoader::Load()
{
  if (m_dllHandle != NULL)
    return true;

  CStdString strFileName = GetFileName();
  CLog::Log(LOGDEBUG, "%s(%s)\n", __FUNCTION__, strFileName.c_str());

  CStdStringW strDllW;
  g_charsetConverter.utf8ToW(_P(strFileName), strDllW);
  m_dllHandle = LoadLibraryExW(strDllW.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
  if (!m_dllHandle)
  {
    CLog::Log(LOGERROR, "%s: Unable to load %s (%d)", __FUNCTION__, strFileName.c_str(), GetLastError());
    return false;
  }

  // handle functions that the dll imports
  if (NeedsHooking(strFileName.c_str()))
    OverrideImports(strFileName);
  else
    bIsSystemDll = true;

  return true;
}
예제 #21
0
HMODULE LoadCoreClr(const std::wstring& runtime_directory, dnx::trace_writer& trace_writer)
{
    HMODULE coreclr_module;

    wchar_t coreclr_dir_buffer[MAX_PATH];
    auto result = GetEnvironmentVariableW(L"CORECLR_DIR", coreclr_dir_buffer, MAX_PATH);
    if (result > MAX_PATH)
    {
        trace_writer.write(L"The value of the 'CORECLR_DIR' variable is invalid. Aborting loading coreclr.dll.", true);
        return nullptr;
    }

    if (result)
    {
        coreclr_module = LoadCoreClrFromPath(coreclr_dir_buffer, trace_writer);
    }
    else
    {
        coreclr_module = LoadLibraryExW(dnx::utils::path_combine(runtime_directory, L"coreclr.dll").c_str(), NULL, 0);
    }

    if (coreclr_module)
    {
        if (PinModule(coreclr_module, trace_writer))
        {
            return coreclr_module;
        }

        FreeLibrary(coreclr_module);
    }

    return nullptr;
}
예제 #22
0
파일: errouthk.c 프로젝트: jbornema/errout
HMODULE WINAPI MyLoadLibraryExW( LPCWSTR lpFileName, HANDLE hFile,
				 DWORD dwFlags )
{
  HMODULE hMod = LoadLibraryExW( lpFileName, hFile, dwFlags );
  if (hMod && hMod != hKernel && !(dwFlags & LOAD_LIBRARY_AS_DATA))
    HookAPIOneMod( hMod, Hooks, FALSE );
  return hMod;
}
예제 #23
0
static void *ll_load(lua_State *L, const wchar_t *path, int seeglb)
{
	HMODULE lib = LoadLibraryExW(path, NULL, LUA_LLE_FLAGS);
	(void)(seeglb);  /* not used: symbols are 'global' by default */

	if(lib == NULL) pusherror(L);

	return lib;
}
예제 #24
0
static HRESULT RegisterServer(BOOL fInstall) {
  // Manual loading of advpack not to load it when DLL used in normal opertion.
  HMODULE hAdvPack = LoadLibraryExW(L"advpack.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
  if (hAdvPack == NULL) {
    TRACE("Couldn't load advpack.dll\n");
    return E_UNEXPECTED;
  }

  // Note: RegInstallA/W not available on Windows XP with MSIE6.
  // Using ANSI version doesn't matter, as the "unicodeness" of the _MOD_PATH
  // depends only on the "unicodeness" of the *.inf file, while other
  // substitutions are ASCII.
  RegInstallFuncA pRegInstallA = (RegInstallFuncA)GetProcAddress(hAdvPack, "RegInstall");
  if (!pRegInstallA) {
    TRACE("Couldn't find RegInstall in advpack.dll\n");
    return E_UNEXPECTED;
  }

  STRENTRYA entries[1] = {
    {"PhotoDir", "Windows Photo Viewer"}
  };
  STRTABLEA strings;
  strings.cEntries = sizeof(entries)/sizeof(entries[0]);
  strings.pse = entries;
  if (LOWORD(GetVersion()) == 0x0006)
    entries[0].pszValue = "Windows Photo Gallery";

  LPCSTR section;
  if (LOBYTE(GetVersion()) < 6) {
    section = (fInstall ? "PrevistaInstall" : "PrevistaUninstall");
  } else {
    section = (fInstall ? "DefaultInstall" : "DefaultUninstall");
  }
  TRACE3("Registering install=%d (using %ws) v=%x\n", fInstall, section, GetVersion());
  if (FAILED(pRegInstallA(MAIN_hSelf, section, &strings)))
    return E_UNEXPECTED;

  // Invalidate caches.
  HMODULE hShell32 = LoadLibraryExW(L"shell32.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
  SHChangeNotifyFunc pSHChangeNotify = (SHChangeNotifyFunc)GetProcAddress(hShell32, "SHChangeNotify");
  if (pSHChangeNotify)
    pSHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
  return S_OK;
}
 HMODULE
 WINAPI
 MyLoadLibraryExA(
     __in       LPCSTR lpLibFileName,
     __reserved HANDLE hFile,
     __in       DWORD dwFlags
     )
 {
     return LoadLibraryExW( FromUTF8( lpLibFileName ), hFile, dwFlags );
 }
예제 #26
0
HINSTANCE get_shdoclc(void)
{
    static const WCHAR wszShdoclc[] =
        {'s','h','d','o','c','l','c','.','d','l','l',0};

    if(shdoclc)
        return shdoclc;

    return shdoclc = LoadLibraryExW(wszShdoclc, NULL, LOAD_LIBRARY_AS_DATAFILE);
}
예제 #27
0
파일: ANSI.c 프로젝트: aliking/ansicon
HMODULE WINAPI MyLoadLibraryExW( LPCWSTR lpFileName, HANDLE hFile,
				 DWORD dwFlags )
{
  HMODULE hMod = LoadLibraryExW( lpFileName, hFile, dwFlags );
  if (hMod && hMod != hKernel && !(dwFlags & LOAD_LIBRARY_AS_DATAFILE))
  {
    DEBUGSTR( L"Hooking in %s (LoadLibraryExW)", lpFileName );
    HookAPIOneMod( hMod, Hooks, FALSE );
  }
  return hMod;
}
예제 #28
0
BOOL My_LoadLibraryExW()
{
	LPCWSTR lpLibFileName=NULL;
	HANDLE hFile=NULL;
	DWORD dwFlags=NULL;
	HMODULE returnVal_Real = NULL;
	HMODULE returnVal_Intercepted = NULL;

	DWORD error_Real = 0;
	DWORD error_Intercepted = 0;
	__try{
	disableInterception();
	returnVal_Real = LoadLibraryExW (lpLibFileName,hFile,dwFlags);
	error_Real = GetLastError();
	enableInterception();
	returnVal_Intercepted = LoadLibraryExW (lpLibFileName,hFile,dwFlags);
	error_Intercepted = GetLastError();
	}__except(puts("in filter"), 1){puts("exception caught");}
	return ((returnVal_Real == returnVal_Intercepted) && (error_Real == error_Intercepted));
}
예제 #29
0
bool ResourceBundle::LoadLocaleResources(
    const base::FilePath& locale_resource_path)
{
    DCHECK(NULL == locale_resources_data_) << "locale dll already loaded";

    // 纯资源DLL, 没有可执行代码.
    locale_resources_data_ = LoadLibraryExW(locale_resource_path.value(),
        NULL, GetDataDllLoadFlags());

    return locale_resources_data_ != NULL;
}
예제 #30
0
/***********************************************************************
 *		get_hook_proc
 *
 * Retrieve the hook procedure real value for a module-relative proc
 */
void *get_hook_proc( void *proc, const WCHAR *module )
{
    HMODULE mod;

    if (!(mod = GetModuleHandleW(module)))
    {
        TRACE( "loading %s\n", debugstr_w(module) );
        /* FIXME: the library will never be freed */
        if (!(mod = LoadLibraryExW(module, NULL, LOAD_WITH_ALTERED_SEARCH_PATH))) return NULL;
    }
    return (char *)mod + (ULONG_PTR)proc;
}