本文整理汇总了C++中IDiaSymbol::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IDiaSymbol::Release方法的具体用法?C++ IDiaSymbol::Release怎么用?C++ IDiaSymbol::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDiaSymbol
的用法示例。
在下文中一共展示了IDiaSymbol::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//------------------------------------------------------------------------
// pSymbol 타입의 정보를 srcPtr 주소에서 가져온다.
// pSymbol 은 srcPtr 에 저장된 심볼의 타입을 가르킨다.
// pSymbol 은 SymTagData 이거나 SymTagBaseType 타입이어야 한다.
// isApplyOffset : false 이면 변수의 offset을 적용하지 않는다.
// 이미 계산된 상태라면 할필요 없음
//------------------------------------------------------------------------
_variant_t dia::GetValueFromSymbol(void *srcPtr, IDiaSymbol *pSymbol )
{
_variant_t value;
void *ptr = (BYTE*)srcPtr;
enum SymTagEnum symTag;
HRESULT hr = pSymbol->get_symTag((DWORD*)&symTag);
ASSERT_RETV((S_OK == hr), value);
bool isReleaseBaseType=false;
IDiaSymbol *pBaseType;
if (SymTagData == symTag)
{
hr = pSymbol->get_type(&pBaseType);
ASSERT_RETV((S_OK == hr), value);
pSymbol = pBaseType;
isReleaseBaseType = true;
}
else
{
pBaseType = pSymbol;
}
enum SymTagEnum baseSymTag;
hr = pBaseType->get_symTag((DWORD*)&baseSymTag);
ASSERT_RETV(S_OK==hr, value);
BasicType btype;
switch (baseSymTag)
{
case SymTagBaseType:
hr = pBaseType->get_baseType((DWORD*)&btype);
ASSERT_RETV((S_OK == hr), value );
break;
case SymTagPointerType:
btype = btULong;
break;
default:
if (isReleaseBaseType)
pBaseType->Release();
return value;
}
ULONGLONG length = 0;
hr = pBaseType->get_length(&length);
ASSERT_RETV((S_OK == hr), value );
value = dia::GetValueFromAddress(ptr, btype, length);
if (isReleaseBaseType)
pBaseType->Release();
return value;
}
示例2: for_all_children
//----------------------------------------------------------------------
static HRESULT for_all_children(
IDiaSymbol *sym,
enum SymTagEnum type,
children_visitor_t &cv)
{
IDiaEnumSymbols *pEnumSymbols;
HRESULT hr = sym->findChildren(type, NULL, nsNone, &pEnumSymbols);
if ( SUCCEEDED(hr) )
{
while ( true )
{
ULONG celt = 0;
IDiaSymbol *pChild;
hr = pEnumSymbols->Next(1, &pChild, &celt);
if ( FAILED(hr) || celt != 1 )
{
hr = S_OK; // end of enumeration
break;
}
hr = cv.visit_child(pChild);
pChild->Release();
if ( FAILED(hr) )
break;
}
pEnumSymbols->Release();
}
return hr;
}
示例3: Enum
IDiaSymbol* CSym::Enum(
__in IDiaSymbol* symParent,
__in enum SymTagEnum enTag,
__in EnumProc cbEnum,
__in_opt PVOID param)
{
if (NULL == symParent)
return NULL;
CComPtr<IDiaEnumSymbols> pEnum = NULL;
HRESULT hr = symParent->findChildren(enTag, NULL, nsNone, &pEnum);
if (SUCCEEDED(hr) && pEnum)
{
ULONG count = 1;
IDiaSymbol* curItem = NULL;
pEnum->Next(1, &curItem, &count);
do
{
if (NULL != curItem)
{
if (cbEnum(curItem, param))
return curItem;
curItem->Release();
}
pEnum->Next(1, &curItem, &count);
} while (0 != count);
}
return NULL;
}
示例4: DumpTypes
static void DumpTypes(IDiaSession *session)
{
IDiaSymbol * globalScope = NULL;
IDiaEnumSymbols * enumSymbols = NULL;
IDiaSymbol * symbol = NULL;
HRESULT hr = session->get_globalScope(&globalScope);
if (FAILED(hr))
return;
AddReportSepLine();
g_report.Append("Types:\n");
DWORD flags = nsfCaseInsensitive|nsfUndecoratedName; // nsNone ?
hr = globalScope->findChildren(SymTagUDT, 0, flags, &enumSymbols);
if (FAILED(hr))
goto Exit;
ULONG celt = 0;
for (;;)
{
hr = enumSymbols->Next(1, &symbol, &celt);
if (FAILED(hr) || (celt != 1))
break;
DumpType(symbol, 0);
symbol->Release();
}
Exit:
UnkReleaseSafe(enumSymbols);
UnkReleaseSafe(globalScope);
}
示例5: DumpType
static void DumpType(IDiaSymbol *symbol, int deep)
{
IDiaEnumSymbols * enumChilds = NULL;
HRESULT hr;
const char * nameStr = NULL;
const char * type;
LONG offset;
ULONGLONG length;
ULONG celt = 0;
ULONG symtag;
DWORD locType;
bool typeSeen;
#if 0
if (deep > 2)
return;
#endif
if (symbol->get_symTag(&symtag) != S_OK)
return;
nameStr = GetTypeName(symbol);
g_typesSeen.Intern(nameStr, &typeSeen);
if (typeSeen)
return;
symbol->get_length(&length);
symbol->get_offset(&offset);
if (SymTagData == symtag) {
if (symbol->get_locationType(&locType) != S_OK)
return; // must be a symbol in optimized code
// TODO: use get_offsetInUdt (http://msdn.microsoft.com/en-us/library/dd997149.aspx) ?
// TODO: use get_type (http://msdn.microsoft.com/en-US/library/cwx3656b(v=vs.80).aspx) ?
// TODO: see what else we can get http://msdn.microsoft.com/en-US/library/w8ae4k32(v=vs.80).aspx
if (LocIsThisRel == locType) {
g_report.AppendFmt("%s%s|%d\n", spaces(deep), nameStr, (int)offset);
}
} else if (SymTagUDT == symtag) {
// TODO: why is it always "struct" even for classes?
type = GetUdtType(symbol);
g_report.AppendFmt("%s%s|%s|%d\n", spaces(deep), type, nameStr, (int)length);
hr = symbol->findChildren(SymTagNull, NULL, nsNone, &enumChilds);
if (!SUCCEEDED(hr))
return;
IDiaSymbol* child;
while (SUCCEEDED(enumChilds->Next(1, &child, &celt)) && (celt == 1))
{
DumpType(child, deep+1);
child->Release();
}
enumChilds->Release();
} else {
if (symbol->get_locationType(&locType) != S_OK)
return; // must be a symbol in optimized code
// TODO: assert?
}
}
示例6: close
void close()
{
if ( pGlobal != NULL )
{
pGlobal->Release();
pGlobal = NULL;
}
if ( pSession != NULL )
{
pSession->Release();
pSession = NULL;
}
if ( pSource != NULL )
{
pSource->Release();
pSource = NULL;
}
if ( dia_hmod != NULL )
{
FreeLibrary(dia_hmod);
dia_hmod = NULL;
}
}
示例7: DumpSymbols
static void DumpSymbols(IDiaSession *session)
{
HRESULT hr;
IDiaEnumSymbolsByAddr * enumByAddr = NULL;
IDiaSymbol * symbol = NULL;
hr = session->getSymbolsByAddr(&enumByAddr);
if (!SUCCEEDED(hr))
goto Exit;
// get first symbol to get first RVA (argh)
hr = enumByAddr->symbolByAddr(1, 0, &symbol);
if (!SUCCEEDED(hr))
goto Exit;
DWORD rva;
hr = symbol->get_relativeVirtualAddress(&rva);
if (S_OK != hr)
goto Exit;
symbol->Release();
symbol = NULL;
// enumerate by rva
hr = enumByAddr->symbolByRVA(rva, &symbol);
if (!SUCCEEDED(hr))
goto Exit;
AddReportSepLine();
g_report.Append("Symbols:\n");
ULONG numFetched;
for (;;)
{
DumpSymbol(symbol);
symbol->Release();
symbol = NULL;
hr = enumByAddr->Next(1, &symbol, &numFetched);
if (FAILED(hr) || (numFetched != 1))
break;
}
Exit:
UnkReleaseSafe(symbol);
UnkReleaseSafe(enumByAddr);
}
示例8: DumpSymbol
static void DumpSymbol(IDiaSymbol *symbol)
{
DWORD section, offset, rva;
DWORD dwTag;
enum SymTagEnum tag;
ULONGLONG length = 0;
const char * typeName = NULL;
char * dataTypeName = NULL;
const char * thunkTypeName = NULL;
symbol->get_symTag(&dwTag);
tag = (enum SymTagEnum)dwTag;
typeName = GetSymTypeName(tag);
symbol->get_relativeVirtualAddress(&rva);
symbol->get_addressSection(§ion);
symbol->get_addressOffset(&offset);
// for data, get length from type
if (SymTagData == tag)
{
IDiaSymbol *type = NULL;
if (symbol->get_type(&type) == S_OK) // no SUCCEEDED test as may return S_FALSE!
{
type->get_length(&length);
const char *s = GetUndecoratedSymbolName(type, "");
if (s && *s)
dataTypeName = str::Dup(s);
type->Release();
}
} if (SymTagThunk == tag) {
DWORD dwThunkKind;
if (S_OK == symbol->get_thunkOrdinal(&dwThunkKind))
thunkTypeName = GetThunkTypeName(dwThunkKind);
} else {
symbol->get_length(&length);
}
const char *nameStr = GetUndecoratedSymbolName(symbol);
if (SymTagData == tag) {
// type | section | length | offset | rva | name | dataTypeName
char *tmp = dataTypeName ? dataTypeName : "";
g_report.AppendFmt("%s|%d|%d|%d|%d|%s|%s\n", typeName, (int)section, (int)length, (int)offset, (int)rva, nameStr, tmp);
free(dataTypeName);
} else if (SymTagThunk == tag) {
const char *tmp = thunkTypeName ? thunkTypeName : "";
// type | section | length | offset | rva | name | thunkTypeName
g_report.AppendFmt("%s|%d|%d|%d|%d|%s|%s\n", typeName, (int)section, (int)length, (int)offset, (int)rva, nameStr, tmp);
} else {
// type | section | length | offset | rva | name
g_report.AppendFmt("%s|%d|%d|%d|%d|%s\n", typeName, (int)section, (int)length, (int)offset, (int)rva, nameStr);
}
}
示例9: BStrToString
// the result doesn't have to be free()d but is only valid until the next call to this function
static const char *GetObjFileName(IDiaSectionContrib *item)
{
static str::Str<char> strTmp;
BSTR name = 0;
IDiaSymbol * compiland = 0;
item->get_compiland(&compiland);
if (compiland) {
compiland->get_name(&name);
compiland->Release();
}
BStrToString(strTmp, name, "<noobjfile>");
SysFreeStringSafe(name);
return strTmp.Get();
}
示例10: get_symbol_length
//----------------------------------------------------------------------
size_t get_symbol_length(IDiaSymbol *sym)
{
DWORD64 size = 0;
DWORD tag = 0;
sym->get_symTag(&tag);
if ( tag == SymTagData )
{
IDiaSymbol *pType;
if ( sym->get_type(&pType) == S_OK )
{
pType->get_length(&size);
pType->Release();
}
}
else
{
sym->get_length(&size);
}
return size_t(size);
}
示例11: GetBaseTypeSymbol
/**
@brief pSymbol 의 타입 심볼을 리턴한다.
UDT, BaseClass, Data, TypeDef 타입일 경우 타입심볼을
리턴한다.
그 밖에 타입은 option에 따라 결정된다.
option = 0:
pointer, array 타입 등은 NULL 을 리턴한다.
option = 1:
pointer, array 타입을 리턴한다.
option = 2:
pointer, array 타입이라면, 실제 한번 더 baseType을 구해
포인터가 가르키는 데이타를 리턴하게 한다.
pSymbol 자신일 경우 result = PARAM_SYMBOL
새 심볼을 생성해서 리턴할 경우 result = NEW_SYMBOL
찾지 못했을 경우 NULL을 리턴한다.
*/
IDiaSymbol* dia::GetBaseTypeSymbol( IDiaSymbol *pSymbol, DWORD option, OUT SymbolState &result )
{
RETV(!pSymbol, NULL);
enum SymTagEnum tag;
HRESULT hr = pSymbol->get_symTag((DWORD*)&tag);
ASSERT_RETV(S_OK == hr, NULL);
IDiaSymbol *pRet = NULL;
switch (tag)
{
case SymTagUDT:
case SymTagBaseClass:
case SymTagBaseType:
pRet = pSymbol;
result = PARAM_SYMBOL;
break;
case SymTagPointerType:
case SymTagArrayType:
if (0 == option)
{
// nothing
}
else if (1 == option)
{
pRet = pSymbol;
result = PARAM_SYMBOL;
}
else if (2 == option)
{
IDiaSymbol *pBaseType;
hr = pSymbol->get_type(&pBaseType);
ASSERT_RETV(S_OK == hr, NULL);
SymbolState rs;
pRet = GetBaseTypeSymbol(pBaseType, 1, rs);
if (!pRet)
break;
if (PARAM_SYMBOL != rs)
pBaseType->Release();
result = NEW_SYMBOL;
}
break;
case SymTagTypedef:
case SymTagData:
{
IDiaSymbol *pBaseType;
hr = pSymbol->get_type(&pBaseType);
ASSERT_RETV(S_OK == hr, NULL);
SymbolState rs;
pRet = GetBaseTypeSymbol(pBaseType, option, rs);
if (!pRet)
break;
if (PARAM_SYMBOL != rs)
pBaseType->Release();
result = NEW_SYMBOL;
}
break;
default:
break;
}
return pRet;
}
示例12: ProcessSymbol
void PDBFileReader::ProcessSymbol(IDiaSymbol *symbol,DebugInfo &to)
{
DWORD section,offset,rva;
enum SymTagEnum tag;
ULONGLONG length = 0;
sU32 compilandId;
IDiaSymbol *compiland = 0;
BSTR name = 0, sourceName = 0;
sBool codeFlag;
symbol->get_symTag((DWORD *) &tag);
symbol->get_relativeVirtualAddress(&rva);
symbol->get_length(&length);
symbol->get_addressSection(§ion);
symbol->get_addressOffset(&offset);
// is the previous symbol desperately looking for a length? we can help!
if(DanglingLengthStart)
{
to.Symbols[to.Symbols.Count - 1].Size = rva - DanglingLengthStart;
DanglingLengthStart = 0;
}
// get length from type for data
if(tag == SymTagData)
{
IDiaSymbol *type;
if(symbol->get_type(&type) == S_OK)
{
type->get_length(&length);
type->Release();
}
// if length still zero, just guess and take number of bytes between
// this symbol and the next one.
if(!length)
DanglingLengthStart = rva;
}
compilandId = CompilandFromSectionOffset(section,offset,codeFlag);
Session->symbolById(compilandId,&compiland);
if(compiland)
compiland->get_name(&sourceName);
symbol->get_name(&name);
// fill out structure
sChar *nameStr = BStrToString(name,"<no name>");
sChar *sourceStr = BStrToString(sourceName,"<no source>");
if(tag == SymTagPublicSymbol)
{
length = 0;
DanglingLengthStart = rva;
}
DISymbol *outSym = to.Symbols.Add();
outSym->Name.Index = outSym->MangledName.Index = to.MakeString(nameStr);
outSym->FileNum = to.GetFileByName(sourceStr);
outSym->VA = rva;
outSym->Size = (sU32) length;
outSym->Class = codeFlag ? DIC_CODE : DIC_DATA;
outSym->NameSpNum = to.GetNameSpaceByName(nameStr);
// clean up
delete[] nameStr;
delete[] sourceStr;
if(compiland) compiland->Release();
if(sourceName) SysFreeString(sourceName);
if(name) SysFreeString(name);
}
示例13: GetAddr
AddrInfo GetAddr(wstring req)
{
uint32_t module;
uint64_t addr;
int charsRead = swscanf_s(req.c_str(), L"%d %llu", &module, &addr);
AddrInfo ret;
ZeroMemory(&ret, sizeof(ret));
if(module > 0 && module < modules.size())
{
SymTagEnum tag = SymTagFunction;
IDiaSymbol *pFunc = NULL;
HRESULT hr = modules[module].pSession->findSymbolByVA(addr, tag, &pFunc);
if(hr != S_OK)
{
if(pFunc)
pFunc->Release();
// try again looking for public symbols
tag = SymTagPublicSymbol;
hr = modules[module].pSession->findSymbolByVA(addr, tag, &pFunc);
if(hr != S_OK)
{
if(pFunc)
pFunc->Release();
return ret;
}
}
DWORD opts = 0;
opts |= UNDNAME_NO_LEADING_UNDERSCORES;
opts |= UNDNAME_NO_MS_KEYWORDS;
opts |= UNDNAME_NO_FUNCTION_RETURNS;
opts |= UNDNAME_NO_ALLOCATION_MODEL;
opts |= UNDNAME_NO_ALLOCATION_LANGUAGE;
opts |= UNDNAME_NO_THISTYPE;
opts |= UNDNAME_NO_ACCESS_SPECIFIERS;
opts |= UNDNAME_NO_THROW_SIGNATURES;
opts |= UNDNAME_NO_MEMBER_TYPE;
opts |= UNDNAME_NO_RETURN_UDT_MODEL;
opts |= UNDNAME_32_BIT_DECODE;
opts |= UNDNAME_NO_LEADING_UNDERSCORES;
// first try undecorated name
BSTR file;
hr = pFunc->get_undecoratedNameEx(opts, &file);
// if not, just try name
if(hr != S_OK)
{
hr = pFunc->get_name(&file);
if(hr != S_OK)
{
pFunc->Release();
SysFreeString(file);
return ret;
}
wcsncpy_s(ret.funcName, file, 126);
}
else
{
wcsncpy_s(ret.funcName, file, 126);
wchar_t *voidparam = wcsstr(ret.funcName, L"(void)");
// remove stupid (void) for empty parameters
if(voidparam != NULL)
{
*(voidparam + 1) = L')';
*(voidparam + 2) = 0;
}
}
pFunc->Release();
pFunc = NULL;
SysFreeString(file);
// find the line numbers touched by this address.
IDiaEnumLineNumbers *lines = NULL;
hr = modules[module].pSession->findLinesByVA(addr, DWORD(4), &lines);
if(FAILED(hr))
{
if(lines)
lines->Release();
return ret;
}
IDiaLineNumber *line = NULL;
ULONG count = 0;
// just take the first one
if(SUCCEEDED(lines->Next(1, &line, &count)) && count == 1)
{
IDiaSourceFile *dia_source = NULL;
//.........这里部分代码省略.........
示例14: ProcessSymbol
void PDBFileReader::ProcessSymbol(IDiaSymbol *symbol,DebugInfo &to)
{
// print a dot for each 1000 symbols processed
static int counter = 0;
++counter;
if( counter == 1000 ) {
fputc( '.', stderr );
counter = 0;
}
DWORD section,offset,rva;
enum SymTagEnum tag;
ULONGLONG length = 0;
BSTR name = 0, srcFileName = 0;
symbol->get_symTag((DWORD *) &tag);
symbol->get_relativeVirtualAddress(&rva);
symbol->get_length(&length);
symbol->get_addressSection(§ion);
symbol->get_addressOffset(&offset);
// get length from type for data
if( tag == SymTagData )
{
IDiaSymbol *type = NULL;
if( symbol->get_type(&type) == S_OK ) // no SUCCEEDED test as may return S_FALSE!
{
if( FAILED(type->get_length(&length)) )
length = 0;
type->Release();
}
else
length = 0;
}
const SectionContrib *contrib = ContribFromSectionOffset(section,offset);
sInt objFile = 0;
sInt sectionType = DIC_UNKNOWN;
if(contrib)
{
objFile = contrib->ObjFile;
sectionType = contrib->Type;
}
symbol->get_name(&name);
// fill out structure
sChar *nameStr = BStrToString( name, "<noname>", true);
to.Symbols.push_back( DISymbol() );
DISymbol *outSym = &to.Symbols.back();
outSym->name = outSym->mangledName = to.MakeString(nameStr);
outSym->objFileNum = objFile;
outSym->VA = rva;
outSym->Size = (sU32) length;
outSym->Class = sectionType;
outSym->NameSpNum = to.GetNameSpaceByName(nameStr);
// clean up
delete[] nameStr;
if(name) SysFreeString(name);
}
示例15: ReadEverything
void PDBFileReader::ReadEverything(DebugInfo &to)
{
ULONG celt;
Contribs = 0;
nContribs = 0;
DanglingLengthStart = 0;
// read section table
IDiaEnumTables *enumTables;
if(Session->getEnumTables(&enumTables) == S_OK)
{
VARIANT vIndex;
vIndex.vt = VT_BSTR;
vIndex.bstrVal = SysAllocString(L"Sections");
IDiaTable *secTable;
if(enumTables->Item(vIndex,&secTable) == S_OK)
{
LONG count;
secTable->get_Count(&count);
Contribs = new SectionContrib[count];
nContribs = 0;
IDiaSectionContrib *item;
while(SUCCEEDED(secTable->Next(1,(IUnknown **)&item,&celt)) && celt == 1)
{
SectionContrib &contrib = Contribs[nContribs++];
item->get_addressOffset(&contrib.Offset);
item->get_addressSection(&contrib.Section);
item->get_length(&contrib.Length);
item->get_compilandId(&contrib.Compiland);
item->get_execute(&contrib.CodeFlag);
item->Release();
}
secTable->Release();
}
SysFreeString(vIndex.bstrVal);
enumTables->Release();
}
// enumerate symbols by (virtual) address
IDiaEnumSymbolsByAddr *enumByAddr;
if(SUCCEEDED(Session->getSymbolsByAddr(&enumByAddr)))
{
IDiaSymbol *symbol;
// get first symbol to get first RVA (argh)
if(SUCCEEDED(enumByAddr->symbolByAddr(1,0,&symbol)))
{
DWORD rva;
if(symbol->get_relativeVirtualAddress(&rva) == S_OK)
{
symbol->Release();
// now, enumerate by rva.
if(SUCCEEDED(enumByAddr->symbolByRVA(rva,&symbol)))
{
do
{
ProcessSymbol(symbol,to);
symbol->Release();
if(FAILED(enumByAddr->Next(1,&symbol,&celt)))
break;
}
while(celt == 1);
}
}
else
symbol->Release();
}
enumByAddr->Release();
}
// clean up
delete[] Contribs;
}