VirtualBox

source: vbox/trunk/include/iprt/win/lazy-dbghelp.h@ 68113

Last change on this file since 68113 was 66823, checked in by vboxsync, 8 years ago

include/iprt: Adjustments for Visual C++ v12 / Visual Studio 2013. Most to do with using SDK 7.1 and sal_supp.h there clashing slightly with a related compiler include.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1/** @file
2 * Symbols from dbghelp.dll, allowing us to select which one to load.
3 */
4
5/*
6 * Copyright (C) 2013-2016 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_win_lazy_dbghelp_h
27#define ___iprt_win_lazy_dbghelp_h
28
29#include <iprt/ldrlazy.h>
30#include <iprt/path.h>
31#include <iprt/env.h>
32#include <iprt/err.h>
33
34
35/**
36 * Custom loader callback.
37 * @returns Module handle or NIL_RTLDRMOD.
38 */
39static int rtLdrLazyLoadDbgHelp(const char *pszFile, PRTLDRMOD phMod)
40{
41 static const struct
42 {
43 const char *pszEnv;
44 const char *pszSubDir;
45 } s_aLocations[] =
46 {
47#ifdef RT_ARCH_AMD64
48 { "ProgramFiles(x86)", "Windows Kits\\8.1\\Debuggers\\x64\\dbghelp.dll" },
49 { "ProgramFiles(x86)", "Windows Kits\\8.0\\Debuggers\\x64\\dbghelp.dll" },
50 { "ProgramFiles", "Debugging Tools for Windows (x64)\\dbghelp.dll" },
51#else
52 { "ProgramFiles", "Windows Kits\\8.1\\Debuggers\\x86\\dbghelp.dll" },
53 { "ProgramFiles", "Windows Kits\\8.0\\Debuggers\\x86\\dbghelp.dll" },
54 { "ProgramFiles", "Debugging Tools for Windows (x86)\\dbghelp.dll" },
55#endif /** @todo More places we should look? */
56 };
57 uint32_t i;
58 for (i = 0; i < RT_ELEMENTS(s_aLocations); i++)
59 {
60 char szPath[RTPATH_MAX];
61 size_t cchPath;
62 int rc = RTEnvGetEx(RTENV_DEFAULT, s_aLocations[i].pszEnv, szPath, sizeof(szPath), &cchPath);
63 if (RT_SUCCESS(rc))
64 {
65 rc = RTPathAppend(szPath, sizeof(szPath), s_aLocations[i].pszSubDir);
66 if (RT_SUCCESS(rc))
67 {
68 rc = RTLdrLoad(szPath, phMod);
69 if (RT_SUCCESS(rc))
70 return rc;
71 }
72 }
73 }
74
75 /* Fall back on the system one, if present. */
76 return RTLdrLoadSystem(pszFile, true /*fNoUnload*/, phMod);
77}
78
79RTLDRLAZY_MODULE_EX(dbghelp, "dbghelp.dll", rtLdrLazyLoadDbgHelp);
80
81RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymInitialize, (HANDLE a1, PCWSTR a2, BOOL a3), (a1, a2, a3), FALSE);
82#undef SymInitialize
83#define SymInitialize RTLDRLAZY_FUNC_NAME(dbghelp, SymInitialize)
84
85RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymCleanup, (HANDLE a1), (a1), FALSE);
86#undef SymCleanup
87#define SymCleanup RTLDRLAZY_FUNC_NAME(dbghelp, SymCleanup)
88
89RTLDRLAZY_FUNC(dbghelp, DWORD, WINAPI, SymGetOptions, (VOID), (), 0);
90#undef SymGetOptions
91#define SymGetOptions RTLDRLAZY_FUNC_NAME(dbghelp, SymGetOptions)
92
93RTLDRLAZY_FUNC(dbghelp, DWORD, WINAPI, SymSetOptions, (DWORD a1), (a1), 0);
94#undef SymSetOptions
95#define SymSetOptions RTLDRLAZY_FUNC_NAME(dbghelp, SymSetOptions)
96
97RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymRegisterCallback64, (HANDLE a1, PSYMBOL_REGISTERED_CALLBACK64 a2, ULONG64 a3),
98 (a1, a2, a3), FALSE);
99#undef SymRegisterCallback64
100#define SymRegisterCallback64 RTLDRLAZY_FUNC_NAME(dbghelp, SymRegisterCallback64)
101
102RTLDRLAZY_FUNC(dbghelp, DWORD64, WINAPI, SymLoadModuleEx,
103 (HANDLE a1, HANDLE a2, PCSTR a3, PCSTR a4, DWORD64 a5, DWORD a6, PMODLOAD_DATA a7, DWORD a8),
104 (a1, a2, a3, a4, a5, a6, a7, a8), 0);
105#undef SymLoadModuleEx
106#define SymLoadModuleEx RTLDRLAZY_FUNC_NAME(dbghelp, SymLoadModuleEx)
107
108RTLDRLAZY_FUNC(dbghelp, DWORD64, WINAPI, SymLoadModuleExW,
109 (HANDLE a1, HANDLE a2, PCWSTR a3, PCWSTR a4, DWORD64 a5, DWORD a6, PMODLOAD_DATA a7, DWORD a8),
110 (a1, a2, a3, a4, a5, a6, a7, a8), 0);
111#undef SymLoadModuleExW
112#define SymLoadModuleExW RTLDRLAZY_FUNC_NAME(dbghelp, SymLoadModuleExW)
113
114RTLDRLAZY_FUNC(dbghelp, DWORD64, WINAPI, SymUnloadModule64, (HANDLE a1, DWORD64 a2), (a1, a2), 0);
115#undef SymUnloadModule64
116#define SymUnloadModule64 RTLDRLAZY_FUNC_NAME(dbghelp, SymUnloadModule64)
117
118RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymEnumSymbols,
119 (HANDLE a1, ULONG64 a2, PCSTR a3, PSYM_ENUMERATESYMBOLS_CALLBACK a4, PVOID a5),
120 (a1, a2, a3, a4, a5), FALSE);
121#undef SymEnumSymbols
122#define SymEnumSymbols RTLDRLAZY_FUNC_NAME(dbghelp, SymEnumSymbols)
123
124RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymEnumLinesW,
125 (HANDLE a1, ULONG64 a2, PCWSTR a3, PCWSTR a4, PSYM_ENUMLINES_CALLBACKW a5, PVOID a6),
126 (a1, a2, a3, a4, a5, a6), FALSE);
127#undef SymEnumLinesW
128#define SymEnumLinesW RTLDRLAZY_FUNC_NAME(dbghelp, SymEnumLinesW)
129
130RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymGetModuleInfo64, (HANDLE a1, DWORD64 a2, PIMAGEHLP_MODULE64 a3), (a1, a2, a3), FALSE);
131#undef SymGetModuleInfo64
132#define SymGetModuleInfo64 RTLDRLAZY_FUNC_NAME(dbghelp, SymGetModuleInfo64)
133
134
135
136
137#endif
138
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette