|
2 | 2 | title: "IDebugBinder3::GetMemoryContext64 | Microsoft Docs"
|
3 | 3 | ms.date: "11/04/2016"
|
4 | 4 | ms.topic: "conceptual"
|
5 |
| -helpviewer_keywords: |
| 5 | +helpviewer_keywords: |
6 | 6 | - "GetMemoryContext64"
|
7 | 7 | - "IDebugBinder3::GetMemoryContext64"
|
8 | 8 | ms.assetid: f021fd16-9fc7-4c41-86af-e54e6224cfbb
|
9 | 9 | author: "gregvanl"
|
10 | 10 | ms.author: "gregvanl"
|
11 | 11 | manager: jillfra
|
12 |
| -ms.workload: |
| 12 | +ms.workload: |
13 | 13 | - "vssdk"
|
14 | 14 | ---
|
15 | 15 | # IDebugBinder3::GetMemoryContext64
|
16 |
| -Converts either an object location or a 64-bit memory address to a memory context. |
17 |
| - |
18 |
| -## Syntax |
19 |
| - |
20 |
| -```cpp |
21 |
| -HRESULT GetMemoryContext64 ( |
22 |
| - IDebugField* pField, |
23 |
| - UINT64 uConstant, |
24 |
| - IDebugMemoryContext2** ppMemCxt |
25 |
| -); |
26 |
| -``` |
27 |
| - |
28 |
| -```csharp |
29 |
| -int GetMemoryContext64 ( |
30 |
| - IDebugField pField, |
31 |
| - ulong uConstant, |
32 |
| - out IDebugMemoryContext2 ppMemCxt |
33 |
| -); |
34 |
| -``` |
35 |
| - |
36 |
| -#### Parameters |
37 |
| - `pField` |
38 |
| - [in] An [IDebugField](../../../extensibility/debugger/reference/idebugfield.md) that describes the object to locate. If `NULL`, then use `dwConstant` instead. |
39 |
| - |
40 |
| - `uConstant` |
41 |
| - [in] A 64-bit memory address, such as 0x50000000. |
42 |
| - |
43 |
| - `ppMemCxt` |
44 |
| - [out] Returns the [IDebugMemoryContext2](../../../extensibility/debugger/reference/idebugmemorycontext2.md) interface that represents the address of the object, or the address in memory. |
45 |
| - |
46 |
| -## Return Value |
47 |
| - If successful, returns `S_OK`; otherwise, returns an error code. |
48 |
| - |
49 |
| -## Example |
50 |
| - The following examples creates an object that implements the [IDebugBinder3](../../../extensibility/debugger/reference/idebugbinder3.md) interface and uses this method to retrieve the memory context. |
51 |
| - |
52 |
| -```cpp |
53 |
| -HRESULT CValueProperty::GetMemoryContext ( IDebugMemoryContext2** out_ppMemoryContext ) |
54 |
| -{ |
55 |
| - // precondition |
56 |
| - REQUIRE( NULL != out_ppMemoryContext ); |
57 |
| - |
58 |
| - if (NULL == out_ppMemoryContext) |
59 |
| - return E_POINTER; |
60 |
| - |
61 |
| - *out_ppMemoryContext = NULL; |
62 |
| - |
63 |
| - INVARIANT( this ); |
64 |
| - |
65 |
| - if (!this->ClassInvariant()) |
66 |
| - return E_UNEXPECTED; |
67 |
| - |
68 |
| - if (VT_EMPTY == this->m_VarValue.vt) |
69 |
| - { |
70 |
| - return E_FAIL; |
71 |
| - } |
72 |
| - |
73 |
| - // function body |
74 |
| - if (NULL != this->m_pBinder) |
75 |
| - { |
76 |
| - UINT64 dwOffset = 0; |
77 |
| - |
78 |
| - DEBUG_PROPERTY_INFO dpInfo; |
79 |
| - HRESULT HR = this->GetPropertyInfo(DEBUGPROP_INFO_VALUE, |
80 |
| - 10, // RADIX |
81 |
| - DEFAULT_TIMEOUT, |
82 |
| - NULL, |
83 |
| - 0, |
84 |
| - &dpInfo); |
85 |
| - if (ENSURE( S_OK == HR )) |
86 |
| - { |
87 |
| - REQUIRE( NULL != dpInfo.bstrValue ); |
88 |
| - REQUIRE( NULL == dpInfo.bstrName ); |
89 |
| - REQUIRE( NULL == dpInfo.bstrFullName ); |
90 |
| - REQUIRE( NULL == dpInfo.bstrType ); |
91 |
| - REQUIRE( NULL == dpInfo.pProperty ); |
92 |
| - |
93 |
| - wchar_t * end; |
94 |
| - dwOffset = _wcstoui64(dpInfo.bstrValue, &end, 0); // base 0 to allow 0x if it's ever output |
95 |
| - ::SysFreeString(dpInfo.bstrValue); |
96 |
| - } |
97 |
| - |
98 |
| - if (CComQIPtr<IDebugBinder3> binder3 = this->m_pBinder) |
99 |
| - HR = binder3->GetMemoryContext64(NULL, dwOffset, out_ppMemoryContext); |
100 |
| - else |
101 |
| - HR = this->m_pBinder->GetMemoryContext(NULL, (DWORD)(__int32)dwOffset, out_ppMemoryContext); |
102 |
| - |
103 |
| - if (ENSURE( S_OK == HR )) |
104 |
| - { |
105 |
| - REQUIRE( NULL != *out_ppMemoryContext ); |
106 |
| - } |
107 |
| - } |
108 |
| - |
109 |
| - // postcondition |
110 |
| - INVARIANT( this ); |
111 |
| - |
112 |
| - HRESULT HR = E_FAIL; |
113 |
| - |
114 |
| - if (NULL != *out_ppMemoryContext) |
115 |
| - { |
116 |
| - HR = S_OK; |
117 |
| - } |
118 |
| - |
119 |
| - return HR; |
120 |
| -} |
121 |
| -``` |
122 |
| - |
123 |
| -## See Also |
124 |
| - [IDebugBinder3](../../../extensibility/debugger/reference/idebugbinder3.md) |
| 16 | +Converts either an object location or a 64-bit memory address to a memory context. |
| 17 | + |
| 18 | +## Syntax |
| 19 | + |
| 20 | +```cpp |
| 21 | +HRESULT GetMemoryContext64 ( |
| 22 | + IDebugField* pField, |
| 23 | + UINT64 uConstant, |
| 24 | + IDebugMemoryContext2** ppMemCxt |
| 25 | +); |
| 26 | +``` |
| 27 | + |
| 28 | +```csharp |
| 29 | +int GetMemoryContext64 ( |
| 30 | + IDebugField pField, |
| 31 | + ulong uConstant, |
| 32 | + out IDebugMemoryContext2 ppMemCxt |
| 33 | +); |
| 34 | +``` |
| 35 | + |
| 36 | +#### Parameters |
| 37 | +`pField` |
| 38 | +[in] An [IDebugField](../../../extensibility/debugger/reference/idebugfield.md) that describes the object to locate. If `NULL`, then use `dwConstant` instead. |
| 39 | + |
| 40 | +`uConstant` |
| 41 | +[in] A 64-bit memory address, such as 0x50000000. |
| 42 | + |
| 43 | +`ppMemCxt` |
| 44 | +[out] Returns the [IDebugMemoryContext2](../../../extensibility/debugger/reference/idebugmemorycontext2.md) interface that represents the address of the object, or the address in memory. |
| 45 | + |
| 46 | +## Return Value |
| 47 | +If successful, returns `S_OK`; otherwise, returns an error code. |
| 48 | + |
| 49 | +## Example |
| 50 | +The following examples creates an object that implements the [IDebugBinder3](../../../extensibility/debugger/reference/idebugbinder3.md) interface and uses this method to retrieve the memory context. |
| 51 | + |
| 52 | +```cpp |
| 53 | +HRESULT CValueProperty::GetMemoryContext ( IDebugMemoryContext2** out_ppMemoryContext ) |
| 54 | +{ |
| 55 | + // precondition |
| 56 | + REQUIRE( NULL != out_ppMemoryContext ); |
| 57 | + |
| 58 | + if (NULL == out_ppMemoryContext) |
| 59 | + return E_POINTER; |
| 60 | + |
| 61 | + *out_ppMemoryContext = NULL; |
| 62 | + |
| 63 | + INVARIANT( this ); |
| 64 | + |
| 65 | + if (!this->ClassInvariant()) |
| 66 | + return E_UNEXPECTED; |
| 67 | + |
| 68 | + if (VT_EMPTY == this->m_VarValue.vt) |
| 69 | + { |
| 70 | + return E_FAIL; |
| 71 | + } |
| 72 | + |
| 73 | + // function body |
| 74 | + if (NULL != this->m_pBinder) |
| 75 | + { |
| 76 | + UINT64 dwOffset = 0; |
| 77 | + |
| 78 | + DEBUG_PROPERTY_INFO dpInfo; |
| 79 | + HRESULT HR = this->GetPropertyInfo(DEBUGPROP_INFO_VALUE, |
| 80 | + 10, // RADIX |
| 81 | + DEFAULT_TIMEOUT, |
| 82 | + NULL, |
| 83 | + 0, |
| 84 | + &dpInfo); |
| 85 | + if (ENSURE( S_OK == HR )) |
| 86 | + { |
| 87 | + REQUIRE( NULL != dpInfo.bstrValue ); |
| 88 | + REQUIRE( NULL == dpInfo.bstrName ); |
| 89 | + REQUIRE( NULL == dpInfo.bstrFullName ); |
| 90 | + REQUIRE( NULL == dpInfo.bstrType ); |
| 91 | + REQUIRE( NULL == dpInfo.pProperty ); |
| 92 | + |
| 93 | + wchar_t * end; |
| 94 | + dwOffset = _wcstoui64(dpInfo.bstrValue, &end, 0); // base 0 to allow 0x if it's ever output |
| 95 | + ::SysFreeString(dpInfo.bstrValue); |
| 96 | + } |
| 97 | + |
| 98 | + if (CComQIPtr<IDebugBinder3> binder3 = this->m_pBinder) |
| 99 | + HR = binder3->GetMemoryContext64(NULL, dwOffset, out_ppMemoryContext); |
| 100 | + else |
| 101 | + HR = this->m_pBinder->GetMemoryContext(NULL, (DWORD)(__int32)dwOffset, out_ppMemoryContext); |
| 102 | + |
| 103 | + if (ENSURE( S_OK == HR )) |
| 104 | + { |
| 105 | + REQUIRE( NULL != *out_ppMemoryContext ); |
| 106 | + } |
| 107 | + } |
| 108 | + |
| 109 | + // postcondition |
| 110 | + INVARIANT( this ); |
| 111 | + |
| 112 | + HRESULT HR = E_FAIL; |
| 113 | + |
| 114 | + if (NULL != *out_ppMemoryContext) |
| 115 | + { |
| 116 | + HR = S_OK; |
| 117 | + } |
| 118 | + |
| 119 | + return HR; |
| 120 | +} |
| 121 | +``` |
| 122 | +
|
| 123 | +## See Also |
| 124 | +[IDebugBinder3](../../../extensibility/debugger/reference/idebugbinder3.md) |
0 commit comments