VirtualBox

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

Last change on this file since 47791 was 47236, checked in by vboxsync, 11 years ago

lazy-dbghelp.h: Use RTLdrLoadSystem.

  • 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 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
33
34/**
35 * Custom loader callback.
36 * @returns Module handle or NIL_RTLDRMOD.
37 */
38static int rtLdrLazyLoadDbgHelp(const char *pszFile, PRTLDRMOD phMod)
39{
40 static const struct
41 {
42 const char *pszEnv;
43 const char *pszSubDir;
44 } s_aLocations[] =
45 {
46#ifdef RT_ARCH_AMD64
47 { "ProgramFiles(x86)", "Windows Kits\\8.1\\Debuggers\\x64\\dbghelp.dll" },
48 { "ProgramFiles(x86)", "Windows Kits\\8.0\\Debuggers\\x64\\dbghelp.dll" },
49 { "ProgramFiles", "Debugging Tools for Windows (x64)\\dbghelp.dll" },
50#else
51 { "ProgramFiles", "Windows Kits\\8.1\\Debuggers\\x86\\dbghelp.dll" },
52 { "ProgramFiles", "Windows Kits\\8.0\\Debuggers\\x86\\dbghelp.dll" },
53 { "ProgramFiles", "Debugging Tools for Windows (x86)\\dbghelp.dll" },
54#endif /** @todo More places we should look? */
55 };
56 uint32_t i;
57 for (i = 0; i < RT_ELEMENTS(s_aLocations); i++)
58 {
59 char szPath[RTPATH_MAX];
60 size_t cchPath;
61 int rc = RTEnvGetEx(RTENV_DEFAULT, s_aLocations[i].pszEnv, szPath, sizeof(szPath), &cchPath);
62 if (RT_SUCCESS(rc))
63 {
64 rc = RTPathAppend(szPath, sizeof(szPath), s_aLocations[i].pszSubDir);
65 if (RT_SUCCESS(rc))
66 {
67 rc = RTLdrLoad(szPath, phMod);
68 if (RT_SUCCESS(rc))
69 return rc;
70 }
71 }
72 }
73
74 /* Fall back on the system one, if present. */
75 return RTLdrLoadSystem(pszFile, true /*fNoUnload*/, phMod);
76}
77
78RTLDRLAZY_MODULE_EX(dbghelp, "dbghelp.dll", rtLdrLazyLoadDbgHelp);
79
80RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymInitialize, (HANDLE a1, PCWSTR a2, BOOL a3), (a1, a2, a3), FALSE);
81#undef SymInitialize
82#define SymInitialize RTLDRLAZY_FUNC_NAME(dbghelp, SymInitialize)
83
84RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymCleanup, (HANDLE a1), (a1), FALSE);
85#undef SymCleanup
86#define SymCleanup RTLDRLAZY_FUNC_NAME(dbghelp, SymCleanup)
87
88RTLDRLAZY_FUNC(dbghelp, DWORD, WINAPI, SymGetOptions, (VOID), (), 0);
89#undef SymGetOptions
90#define SymGetOptions RTLDRLAZY_FUNC_NAME(dbghelp, SymGetOptions)
91
92RTLDRLAZY_FUNC(dbghelp, DWORD, WINAPI, SymSetOptions, (DWORD a1), (a1), 0);
93#undef SymSetOptions
94#define SymSetOptions RTLDRLAZY_FUNC_NAME(dbghelp, SymSetOptions)
95
96RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymRegisterCallback64, (HANDLE a1, PSYMBOL_REGISTERED_CALLBACK64 a2, ULONG64 a3),
97 (a1, a2, a3), FALSE);
98#undef SymRegisterCallback64
99#define SymRegisterCallback64 RTLDRLAZY_FUNC_NAME(dbghelp, SymRegisterCallback64)
100
101RTLDRLAZY_FUNC(dbghelp, DWORD64, WINAPI, SymLoadModuleEx,
102 (HANDLE a1, HANDLE a2, PCSTR a3, PCSTR a4, DWORD64 a5, DWORD a6, PMODLOAD_DATA a7, DWORD a8),
103 (a1, a2, a3, a4, a5, a6, a7, a8), 0);
104#undef SymLoadModuleEx
105#define SymLoadModuleEx RTLDRLAZY_FUNC_NAME(dbghelp, SymLoadModuleEx)
106
107RTLDRLAZY_FUNC(dbghelp, DWORD64, WINAPI, SymLoadModuleExW,
108 (HANDLE a1, HANDLE a2, PCWSTR a3, PCWSTR a4, DWORD64 a5, DWORD a6, PMODLOAD_DATA a7, DWORD a8),
109 (a1, a2, a3, a4, a5, a6, a7, a8), 0);
110#undef SymLoadModuleExW
111#define SymLoadModuleExW RTLDRLAZY_FUNC_NAME(dbghelp, SymLoadModuleExW)
112
113RTLDRLAZY_FUNC(dbghelp, DWORD64, WINAPI, SymUnloadModule64, (HANDLE a1, DWORD64 a2), (a1, a2), 0);
114#undef SymUnloadModule64
115#define SymUnloadModule64 RTLDRLAZY_FUNC_NAME(dbghelp, SymUnloadModule64)
116
117RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymEnumSymbols,
118 (HANDLE a1, ULONG64 a2, PCSTR a3, PSYM_ENUMERATESYMBOLS_CALLBACK a4, PVOID a5),
119 (a1, a2, a3, a4, a5), FALSE);
120#undef SymEnumSymbols
121#define SymEnumSymbols RTLDRLAZY_FUNC_NAME(dbghelp, SymEnumSymbols)
122
123RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymEnumLinesW,
124 (HANDLE a1, ULONG64 a2, PCWSTR a3, PCWSTR a4, PSYM_ENUMLINES_CALLBACKW a5, PVOID a6),
125 (a1, a2, a3, a4, a5, a6), FALSE);
126#undef SymEnumLinesW
127#define SymEnumLinesW RTLDRLAZY_FUNC_NAME(dbghelp, SymEnumLinesW)
128
129RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymGetModuleInfo64, (HANDLE a1, DWORD64 a2, PIMAGEHLP_MODULE64 a3), (a1, a2, a3), FALSE);
130#undef SymGetModuleInfo64
131#define SymGetModuleInfo64 RTLDRLAZY_FUNC_NAME(dbghelp, SymGetModuleInfo64)
132
133
134
135
136#endif
137
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