Bytes PyValue::asBytes() { if (m_symbolGroup) return Bytes(); ULONG64 address = 0; if (FAILED(m_symbolGroup->GetSymbolOffset(m_index, &address))) return Bytes(); ULONG size; if (FAILED(m_symbolGroup->GetSymbolSize(m_index, &size))) return Bytes(); Bytes bytes(size); unsigned long received; auto data = ExtensionCommandContext::instance()->dataSpaces(); if (FAILED(data->ReadVirtual(address, bytes.data(), size, &received))) return Bytes(); bytes.resize(received); return bytes; }
// // reads a struct from a virtual address // the struct data is placed in pStructData and should be freed when done // the pStruct should be a cloned structure which will have its fieldData // pointers updated to point to the the appropriate location in pStructData // HRESULT ReadVirtualStruct(PCMD_CTX ctx, WDBG_PTR addr, PSYM_FIELD pStruct, PVOID *pStructData) { HRESULT ret; ULONG structLen = GetReadStructLength(pStruct); PBYTE buf = (PBYTE) malloc(structLen); if (buf == NULL) return E_OUTOFMEMORY; if (SUCCEEDED(ret = ReadVirtual(ctx, addr, buf, structLen))) { // assign the fieldData pointer to the proper location in buf PSYM_FIELD pField = pStruct; while (pField->fieldName != NULL) { pField->fieldData = buf + pField->fieldOffset; pField++; } *pStructData = buf; } return ret; }