Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dbghelp.cpp
Go to the documentation of this file.
1 /* Copyright (c) 2010 Wildfire Games
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining
4  * a copy of this software and associated documentation files (the
5  * "Software"), to deal in the Software without restriction, including
6  * without limitation the rights to use, copy, modify, merge, publish,
7  * distribute, sublicense, and/or sell copies of the Software, and to
8  * permit persons to whom the Software is furnished to do so, subject to
9  * the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 #include "precompiled.h"
24 
25 #if OS_WIN
26 
27 #include "lib/sysdep/sysdep.h"
30 
31 // define extension function pointers
32 extern "C"
33 {
34 #define FUNC(ret, name, params) ret (__stdcall *p##name) params;
36 #undef FUNC
37 }
38 
40 {
41  // for reasons unknown, LoadLibrary first checks the Dropbox shell
42  // extension's directory (instead of "The directory from which the
43  // application loaded.") and then the system directory, whose
44  // dbghelp.dll is too old. we therefore specify the full path
45  // to our executable directory, which contains a newer dbghelp.dll.
46  const OsPath pathname = sys_ExecutablePathname().Parent()/"dbghelp.dll";
47  HMODULE hDbghelp = LoadLibraryW(OsString(pathname).c_str());
48  ENSURE(hDbghelp);
49 #define FUNC(ret, name, params) p##name = (ret (__stdcall*) params)GetProcAddress(hDbghelp, #name);
51 #undef FUNC
52 
53  // if this function is missing, the DLL is too old.
54  ENSURE(pSymInitializeW);
55 }
56 
57 #endif // OS_WIN
Path Parent() const
Definition: path.h:150
void dbghelp_ImportFunctions()
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
Definition: debug.h:282
Definition: path.h:75
OsPath sys_ExecutablePathname()
Definition: bsd.cpp:33
static std::string OsString(const OsPath &path)
Definition: os_path.h:42