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.
10 EXTERN_C void GetRuntimeStackWalkInfo(IN ULONG64 ControlPc,
11 OUT UINT_PTR* pModuleBase,
12 OUT UINT_PTR* pFuncEntry);
14 //---------------------------------------------------------------------------------------
16 // Given a control PC, return the base of the module it is in. For jitted managed code, this is the
17 // start of the code heap.
20 // address - the specified address
21 // pdwBase - out parameter; returns the module base
24 // S_OK if we retrieve the module base successfully;
28 HRESULT OOPStackUnwinder::GetModuleBase( DWORD64 address,
29 __out PDWORD64 pdwBase)
31 GetRuntimeStackWalkInfo(address, reinterpret_cast<UINT_PTR *>(pdwBase), NULL);
32 return ((*pdwBase == NULL) ? E_FAIL : S_OK);
35 //---------------------------------------------------------------------------------------
37 // Given a control PC, return the function entry of the function it is in.
40 // address - the specified IP
41 // pBuffer - the buffer to store the retrieved function entry
42 // cbBuffer - the size of the buffer
45 // S_OK if we retrieve the function entry successfully;
46 // E_INVALIDARG if the buffer is too small;
50 HRESULT OOPStackUnwinder::GetFunctionEntry( DWORD64 address,
51 __out_ecount(cbBuffer) PVOID pBuffer,
54 if (cbBuffer < sizeof(T_RUNTIME_FUNCTION))
59 PVOID pFuncEntry = NULL;
60 GetRuntimeStackWalkInfo(address, NULL, reinterpret_cast<UINT_PTR *>(&pFuncEntry));
61 if (pFuncEntry == NULL)
66 memcpy(pBuffer, pFuncEntry, cbBuffer);