本文整理汇总了C++中DbgHelp::SymFromAddrW方法的典型用法代码示例。如果您正苦于以下问题:C++ DbgHelp::SymFromAddrW方法的具体用法?C++ DbgHelp::SymFromAddrW怎么用?C++ DbgHelp::SymFromAddrW使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbgHelp
的用法示例。
在下文中一共展示了DbgHelp::SymFromAddrW方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getModuleForAddr
const std::wstring SymbolInfo::getProcForAddr(PROFILER_ADDR addr,
std::wstring& procfilepath_out, int& proclinenum_out)
{
procfilepath_out = L"";
proclinenum_out = 0;
Module *mod = getModuleForAddr(addr);
DbgHelp *dbgHelp = mod ? mod->dbghelp : &dbgHelpMs;
unsigned char buffer[1024];
//blame MS for this abomination of a coding technique
SYMBOL_INFOW* symbol_info = (SYMBOL_INFOW*)buffer;
symbol_info->SizeOfStruct = sizeof(SYMBOL_INFOW);
symbol_info->MaxNameLen = ((sizeof(buffer) - sizeof(SYMBOL_INFOW)) / sizeof(WCHAR)) - 1;
DWORD64 displacement = 0;
BOOL result = dbgHelp->SymFromAddrW(process_handle, (DWORD64)addr, &displacement, symbol_info);
if(!result)
{
DWORD err = GetLastError();
wchar_t buf[256];
#if defined(_WIN64)
if(is64BitProcess)
swprintf(buf, 256, L"[%016llX]", addr);
else
swprintf(buf, 256, L"[%08X]", unsigned __int32(addr));
#else
swprintf(buf, 256, L"[%08X]", addr);
#endif
return buf;
}
示例2: getFunctionName
LPCWSTR CallStack::getFunctionName(SIZE_T programCounter, DWORD64& displacement64,
SYMBOL_INFO* functionInfo, CriticalSectionLocker<DbgHelp>& locker) const
{
// Initialize structures passed to the symbol handler.
functionInfo->SizeOfStruct = sizeof(SYMBOL_INFO);
functionInfo->MaxNameLen = MAX_SYMBOL_NAME_LENGTH;
// Try to get the name of the function containing this program
// counter address.
displacement64 = 0;
LPCWSTR functionName;
DbgTrace(L"dbghelp32.dll %i: SymFromAddrW\n", GetCurrentThreadId());
if (g_DbgHelp.SymFromAddrW(g_currentProcess, programCounter, &displacement64, functionInfo, locker)) {
functionName = functionInfo->Name;
}
else {
// GetFormattedMessage( GetLastError() );
fmt::WArrayWriter wf(functionInfo->Name, MAX_SYMBOL_NAME_LENGTH);
wf.write(L"" ADDRESSCPPFORMAT, programCounter);
functionName = wf.c_str();
displacement64 = 0;
}
return functionName;
}