VirtualBox

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

Last change on this file since 46126 was 46126, checked in by vboxsync, 12 years ago

Baka tori!

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 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 char szPath[RTPATH_MAX];
41 size_t cchPath;
42 int rc = RTEnvGetEx(RTENV_DEFAULT, "ProgramFiles", szPath, sizeof(szPath), &cchPath);
43 if (RT_SUCCESS(rc))
44 {
45 /** @todo try Windows SDK location. */
46#ifdef RT_ARCH_X86
47 rc = RTPathAppend(szPath, sizeof(szPath), "Debugging Tools for Windows (x86)\\dbghelp.dll");
48#else
49 rc = RTPathAppend(szPath, sizeof(szPath), "Debugging Tools for Windows (x64)\\dbghelp.dll");
50#endif
51 if (RTPathExists(szPath))
52 {
53 rc = RTLdrLoad(szPath, phMod);
54 if (RT_SUCCESS(rc))
55 return rc;
56 }
57 }
58
59 return RTLdrLoad(pszFile, phMod);
60}
61
62RTLDRLAZY_MODULE_EX(dbghelp, "dbghelp.dll", rtLdrLazyLoadDbgHelp);
63
64RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymInitialize, (HANDLE a1, PCWSTR a2, BOOL a3), (a1, a2, a3), FALSE);
65#undef SymInitialize
66#define SymInitialize RTLDRLAZY_FUNC_NAME(dbghelp, SymInitialize)
67
68RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymCleanup, (HANDLE a1), (a1), FALSE);
69#undef SymCleanup
70#define SymCleanup RTLDRLAZY_FUNC_NAME(dbghelp, SymCleanup)
71
72RTLDRLAZY_FUNC(dbghelp, DWORD, WINAPI, SymGetOptions, (VOID), (), 0);
73#undef SymGetOptions
74#define SymGetOptions RTLDRLAZY_FUNC_NAME(dbghelp, SymGetOptions)
75
76RTLDRLAZY_FUNC(dbghelp, DWORD, WINAPI, SymSetOptions, (DWORD a1), (a1), 0);
77#undef SymSetOptions
78#define SymSetOptions RTLDRLAZY_FUNC_NAME(dbghelp, SymSetOptions)
79
80RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymRegisterCallback64, (HANDLE a1, PSYMBOL_REGISTERED_CALLBACK64 a2, ULONG64 a3),
81 (a1, a2, a3), FALSE);
82#undef SymRegisterCallback64
83#define SymRegisterCallback64 RTLDRLAZY_FUNC_NAME(dbghelp, SymRegisterCallback64)
84
85RTLDRLAZY_FUNC(dbghelp, DWORD64, WINAPI, SymLoadModuleEx,
86 (HANDLE a1, HANDLE a2, PCSTR a3, PCSTR a4, DWORD64 a5, DWORD a6, PMODLOAD_DATA a7, DWORD a8),
87 (a1, a2, a3, a4, a5, a6, a7, a8), 0);
88#undef SymLoadModuleEx
89#define SymLoadModuleEx RTLDRLAZY_FUNC_NAME(dbghelp, SymLoadModuleEx)
90
91RTLDRLAZY_FUNC(dbghelp, DWORD64, WINAPI, SymLoadModuleExW,
92 (HANDLE a1, HANDLE a2, PCWSTR a3, PCWSTR a4, DWORD64 a5, DWORD a6, PMODLOAD_DATA a7, DWORD a8),
93 (a1, a2, a3, a4, a5, a6, a7, a8), 0);
94#undef SymLoadModuleExW
95#define SymLoadModuleExW RTLDRLAZY_FUNC_NAME(dbghelp, SymLoadModuleExW)
96
97RTLDRLAZY_FUNC(dbghelp, DWORD64, WINAPI, SymUnloadModule64, (HANDLE a1, DWORD64 a2), (a1, a2), 0);
98#undef SymUnloadModule64
99#define SymUnloadModule64 RTLDRLAZY_FUNC_NAME(dbghelp, SymUnloadModule64)
100
101RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymEnumSymbols,
102 (HANDLE a1, ULONG64 a2, PCSTR a3, PSYM_ENUMERATESYMBOLS_CALLBACK a4, PVOID a5),
103 (a1, a2, a3, a4, a5), FALSE);
104#undef SymEnumSymbols
105#define SymEnumSymbols RTLDRLAZY_FUNC_NAME(dbghelp, SymEnumSymbols)
106
107RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymEnumLinesW,
108 (HANDLE a1, ULONG64 a2, PCWSTR a3, PCWSTR a4, PSYM_ENUMLINES_CALLBACKW a5, PVOID a6),
109 (a1, a2, a3, a4, a5, a6), FALSE);
110#undef SymEnumLinesW
111#define SymEnumLinesW RTLDRLAZY_FUNC_NAME(dbghelp, SymEnumLinesW)
112
113RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymGetModuleInfo64, (HANDLE a1, DWORD64 a2, PIMAGEHLP_MODULE64 a3), (a1, a2, a3), FALSE);
114#undef SymGetModuleInfo64
115#define SymGetModuleInfo64 RTLDRLAZY_FUNC_NAME(dbghelp, SymGetModuleInfo64)
116
117
118
119
120#endif
121
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