PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/xbmc/win32/Win32DelayedDllLoad.cpp

http://github.com/xbmc/xbmc
C++ | 84 lines | 60 code | 4 blank | 20 comment | 12 complexity | c175c29de47b2efe6a53cbfc3df4de65 MD5 | raw file
 1/*
 2 *      Copyright (C) 2005-2013 Team XBMC
 3 *      http://xbmc.org
 4 *
 5 *  This Program is free software; you can redistribute it and/or modify
 6 *  it under the terms of the GNU General Public License as published by
 7 *  the Free Software Foundation; either version 2, or (at your option)
 8 *  any later version.
 9 *
10 *  This Program is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *  GNU General Public License for more details.
14 *
15 *  You should have received a copy of the GNU General Public License
16 *  along with XBMC; see the file COPYING.  If not, see
17 *  <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#include <DelayImp.h>
22#include "DllPaths_win32.h"
23#include "filesystem/SpecialProtocol.h"
24#include "Application.h"
25#include "windowing/WindowingFactory.h"
26
27FARPROC WINAPI delayHookNotifyFunc (unsigned dliNotify, PDelayLoadInfo pdli)
28{
29  switch (dliNotify)
30  {
31    case dliNotePreLoadLibrary:
32      if (stricmp(pdli->szDll, "libmicrohttpd-5.dll") == 0)
33      {
34        CStdString strDll = CSpecialProtocol::TranslatePath(DLL_PATH_LIBMICROHTTP);
35        HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
36        return (FARPROC)hMod;
37      }
38      if (stricmp(pdli->szDll, "ssh.dll") == 0)
39      {
40        CStdString strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/ssh.dll");
41        HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
42        return (FARPROC)hMod;
43      }
44      if (stricmp(pdli->szDll, "sqlite3.dll") == 0)
45      {
46        CStdString strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/sqlite3.dll");
47        HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
48        return (FARPROC)hMod;
49      }
50      if (stricmp(pdli->szDll, "libsamplerate-0.dll") == 0)
51      {
52        CStdString strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/libsamplerate-0.dll");
53        HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
54        return (FARPROC)hMod;
55      }
56      if (stricmp(pdli->szDll, "dnssd.dll") == 0)
57      {
58        CStdString strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/dnssd.dll");
59        HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
60        return (FARPROC)hMod;
61      }
62      break;
63  }
64  return NULL;
65}
66
67FARPROC WINAPI delayHookFailureFunc (unsigned dliNotify, PDelayLoadInfo pdli)
68{
69  switch (dliNotify)
70  {
71    case dliFailLoadLib:
72      g_application.Stop(1);
73      CStdString strError;
74      strError.Format("Uh oh, can't load %s, exiting.", pdli->szDll);
75      MessageBox(NULL, strError.c_str(), "XBMC: Fatal Error", MB_OK|MB_ICONERROR);
76      exit(1);
77      break;
78  }
79  return NULL;
80}
81
82// assign hook functions
83PfnDliHook __pfnDliNotifyHook2 = delayHookNotifyFunc;
84PfnDliHook __pfnDliFailureHook2 = delayHookFailureFunc;