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 | // ShimDataTarget.h |
6 | // |
7 | |
8 | // |
9 | // header for liveproc data targets |
10 | //***************************************************************************** |
11 | |
12 | #ifndef SHIMDATATARGET_H_ |
13 | #define SHIMDATATARGET_H_ |
14 | |
15 | |
16 | // Function to invoke for |
17 | typedef HRESULT (*FPContinueStatusChanged)(void * pUserData, DWORD dwThreadId, CORDB_CONTINUE_STATUS dwContinueStatus); |
18 | |
19 | |
20 | //--------------------------------------------------------------------------------------- |
21 | // Data target for a live process. This is used by Shim. |
22 | // |
23 | class ShimDataTarget : public ICorDebugMutableDataTarget, ICorDebugDataTarget4 |
24 | { |
25 | public: |
26 | virtual ~ShimDataTarget() {} |
27 | |
28 | // Allow hooking an implementation for ContinueStatusChanged. |
29 | void HookContinueStatusChanged(FPContinueStatusChanged fpContinueStatusChanged, void * pUserData); |
30 | |
31 | // Release any resources. Also called by destructor. |
32 | virtual void Dispose() = 0; |
33 | |
34 | // Set data-target into an error mode. This can be used to mark that the process |
35 | // is unavailable because it's running |
36 | void SetError(HRESULT hr); |
37 | |
38 | // Get the OS Process ID that this DataTarget is for. |
39 | DWORD GetPid(); |
40 | |
41 | // |
42 | // IUnknown. |
43 | // |
44 | virtual HRESULT STDMETHODCALLTYPE QueryInterface( |
45 | REFIID InterfaceId, |
46 | PVOID* Interface); |
47 | |
48 | virtual ULONG STDMETHODCALLTYPE AddRef(); |
49 | |
50 | virtual ULONG STDMETHODCALLTYPE Release(); |
51 | |
52 | // |
53 | // ICorDebugMutableDataTarget. |
54 | // |
55 | |
56 | virtual HRESULT STDMETHODCALLTYPE GetPlatform( |
57 | CorDebugPlatform * pPlatform) = 0; |
58 | |
59 | virtual HRESULT STDMETHODCALLTYPE ReadVirtual( |
60 | CORDB_ADDRESS address, |
61 | BYTE * pBuffer, |
62 | ULONG32 request, |
63 | ULONG32 * pcbRead) = 0; |
64 | |
65 | virtual HRESULT STDMETHODCALLTYPE WriteVirtual( |
66 | CORDB_ADDRESS address, |
67 | const BYTE * pBuffer, |
68 | ULONG32 request) = 0; |
69 | |
70 | virtual HRESULT STDMETHODCALLTYPE GetThreadContext( |
71 | DWORD dwThreadID, |
72 | ULONG32 contextFlags, |
73 | ULONG32 contextSize, |
74 | BYTE * context) = 0; |
75 | |
76 | virtual HRESULT STDMETHODCALLTYPE SetThreadContext( |
77 | DWORD dwThreadID, |
78 | ULONG32 contextSize, |
79 | const BYTE * context) = 0; |
80 | |
81 | virtual HRESULT STDMETHODCALLTYPE ContinueStatusChanged( |
82 | DWORD dwThreadId, |
83 | CORDB_CONTINUE_STATUS dwContinueStatus) = 0; |
84 | |
85 | // @dbgtodo - add Native Patch Table support |
86 | |
87 | // |
88 | // ICorDebugDataTarget4 |
89 | // |
90 | |
91 | // Unwind to the next stack frame |
92 | virtual HRESULT STDMETHODCALLTYPE VirtualUnwind( |
93 | DWORD threadId, ULONG32 contextSize, PBYTE context) = 0; |
94 | |
95 | protected: |
96 | // Pid of the target process. |
97 | DWORD m_processId; |
98 | |
99 | // If this HRESULT != S_OK, then all interface methods will return this. |
100 | // This provides a way to mark the debugggee as stopped / dead. |
101 | HRESULT m_hr; |
102 | |
103 | FPContinueStatusChanged m_fpContinueStatusChanged; |
104 | void * m_pContinueStatusChangedUserData; |
105 | |
106 | // Reference count. |
107 | LONG m_ref; |
108 | }; |
109 | |
110 | //--------------------------------------------------------------------------------------- |
111 | // |
112 | // Construction method for data-target |
113 | // |
114 | // Arguments: |
115 | // machineInfo - used for Mac debugging; uniquely identifies the debugger proxy on the remote machine |
116 | // processId - (input) live OS process ID to build a data-target for. |
117 | // ppDataTarget - (output) new data-target instance. This gets addreffed. |
118 | // |
119 | // Return Value: |
120 | // S_OK on success. |
121 | // |
122 | // Assumptions: |
123 | // pid must be for local, same architecture, process. |
124 | // Caller must have security permissions for OpenProcess() |
125 | // Caller must release *ppDataTarget. |
126 | // |
127 | |
128 | HRESULT BuildPlatformSpecificDataTarget(MachineInfo machineInfo, |
129 | const ProcessDescriptor * pProcessDescriptor, |
130 | ShimDataTarget ** ppDataTarget); |
131 | |
132 | #endif // SHIMDATATARGET_H_ |
133 | |
134 | |