1 /* 2 * Copyright (C) 2005-2018 Team Kodi 3 * This file is part of Kodi - https://kodi.tv 4 * 5 * SPDX-License-Identifier: GPL-2.0-or-later 6 * See LICENSES/README.md for more information. 7 */ 8 9 #pragma once 10 11 #include "LibraryLoader.h" 12 13 #include <vector> 14 15 class Win32DllLoader : public LibraryLoader 16 { 17 public: 18 class Import 19 { 20 public: 21 void *table; 22 uintptr_t function; 23 }; 24 25 Win32DllLoader(const std::string& dll, bool isSystemDll); 26 ~Win32DllLoader(); 27 28 virtual bool Load(); 29 virtual void Unload(); 30 31 virtual int ResolveExport(const char* symbol, void** ptr, bool logging = true); 32 virtual bool IsSystemDll(); 33 virtual HMODULE GetHModule(); 34 virtual bool HasSymbols(); 35 36 private: 37 void OverrideImports(const std::string &dll); 38 void RestoreImports(); 39 static bool ResolveImport(const char *dllName, const char *functionName, void **fixup); 40 static bool ResolveOrdinal(const char *dllName, unsigned long ordinal, void **fixup); 41 bool NeedsHooking(const char *dllName); 42 43 HMODULE m_dllHandle; 44 bool bIsSystemDll; 45 46 std::vector<Import> m_overriddenImports; 47 std::vector<HMODULE> m_referencedDlls; 48 }; 49 50