1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | //***************************************************************************** |
5 | // dbgutil.h |
6 | // |
7 | |
8 | // |
9 | //***************************************************************************** |
10 | |
11 | #pragma once |
12 | #include <cor.h> |
13 | #include <cordebug.h> |
14 | #include <metahost.h> |
15 | |
16 | // |
17 | // Various common helpers used by multiple debug components. |
18 | // |
19 | |
20 | // Returns the RVA of the resource section for the module specified by the given data target and module base. |
21 | // Returns failure if the module doesn't have a resource section. |
22 | // |
23 | // Arguments |
24 | // pDataTarget - dataTarget for the process we are inspecting |
25 | // moduleBaseAddress - base address of a module we should inspect |
26 | // pwImageFileMachine - updated with the Machine from the IMAGE_FILE_HEADER |
27 | // pdwResourceSectionRVA - updated with the resultant RVA on success |
28 | HRESULT GetMachineAndResourceSectionRVA(ICorDebugDataTarget* pDataTarget, |
29 | ULONG64 moduleBaseAddress, |
30 | WORD* pwImageFileMachine, |
31 | DWORD* pdwResourceSectionRVA); |
32 | |
33 | HRESULT GetResourceRvaFromResourceSectionRva(ICorDebugDataTarget* pDataTarget, |
34 | ULONG64 moduleBaseAddress, |
35 | DWORD resourceSectionRva, |
36 | DWORD type, |
37 | DWORD name, |
38 | DWORD language, |
39 | DWORD* pResourceRva, |
40 | DWORD* pResourceSize); |
41 | |
42 | HRESULT GetResourceRvaFromResourceSectionRvaByName(ICorDebugDataTarget* pDataTarget, |
43 | ULONG64 moduleBaseAddress, |
44 | DWORD resourceSectionRva, |
45 | DWORD type, |
46 | LPCWSTR pwszName, |
47 | DWORD language, |
48 | DWORD* pResourceRva, |
49 | DWORD* pResourceSize); |
50 | |
51 | // Traverses down one level in the PE resource tree structure |
52 | // |
53 | // Arguments: |
54 | // pDataTarget - the data target for inspecting this process |
55 | // id - the id of the next node in the resource tree you want |
56 | // moduleBaseAddress - the base address of the module being inspected |
57 | // resourceDirectoryRVA - the base address of the beginning of the resource directory for this |
58 | // level of the tree |
59 | // pNextLevelRVA - out - The RVA for the next level tree directory or the RVA of the resource entry |
60 | // |
61 | // Returns: |
62 | // S_OK if succesful or an appropriate failing HRESULT |
63 | HRESULT GetNextLevelResourceEntryRVA(ICorDebugDataTarget* pDataTarget, |
64 | DWORD id, |
65 | ULONG64 moduleBaseAddress, |
66 | DWORD resourceDirectoryRVA, |
67 | DWORD* pNextLevelRVA); |
68 | |
69 | // Traverses down one level in the PE resource tree structure |
70 | // |
71 | // Arguments: |
72 | // pDataTarget - the data target for inspecting this process |
73 | // name - the name of the next node in the resource tree you want |
74 | // moduleBaseAddress - the base address of the module being inspected |
75 | // resourceDirectoryRVA - the base address of the beginning of the resource directory for this |
76 | // level of the tree |
77 | // resourceSectionRVA - the rva of the beginning of the resource section of the PE file |
78 | // pNextLevelRVA - out - The RVA for the next level tree directory or the RVA of the resource entry |
79 | // |
80 | // Returns: |
81 | // S_OK if succesful or an appropriate failing HRESULT |
82 | HRESULT GetNextLevelResourceEntryRVAByName(ICorDebugDataTarget* pDataTarget, |
83 | LPCWSTR pwzName, |
84 | ULONG64 moduleBaseAddress, |
85 | DWORD resourceDirectoryRva, |
86 | DWORD resourceSectionRva, |
87 | DWORD* pNextLevelRva); |
88 | |
89 | // A small wrapper that reads from the data target and throws on error |
90 | HRESULT ReadFromDataTarget(ICorDebugDataTarget* pDataTarget, |
91 | ULONG64 addr, |
92 | BYTE* pBuffer, |
93 | ULONG32 bytesToRead); |
94 | |