Skip to content

Commit

Permalink
Merge pull request #122 from cristian64/extended_preview_strings
Browse files Browse the repository at this point in the history
Show extended scan preview for strings.
  • Loading branch information
dreamsyntax authored Apr 28, 2024
2 parents 02f35d7 + ebf0c66 commit cd16d39
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
19 changes: 15 additions & 4 deletions Source/Common/MemoryCommon.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "MemoryCommon.h"

#include <bitset>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <sstream>
Expand Down Expand Up @@ -624,13 +625,23 @@ std::string formatMemoryToString(const char* memory, const MemType type, const s
}
case Common::MemType::type_string:
{
int actualLength = 0;
for (actualLength; actualLength < length; ++actualLength)
std::string text;
for (std::string::size_type i{0}; i < length; ++i)
{
if (*(memory + actualLength) == 0x00)
const char c{memory[i]};
if (c == '\0')
break;

if (std::isprint(c))
{
text.push_back(c);
}
else
{
text += "";
}
}
return std::string(memory, actualLength);
return text;
}
case Common::MemType::type_byteArray:
{
Expand Down
3 changes: 2 additions & 1 deletion Source/MemoryScanner/MemoryScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,8 @@ std::string MemScanner::getFormattedScannedValueAt(const int index) const
bool aramAccessible = DolphinComm::DolphinAccessor::isARAMAccessible();
u32 offset = Common::dolphinAddrToOffset(m_resultsConsoleAddr.at(index), aramAccessible);
u32 ramIndex = Common::offsetToCacheIndex(offset, aramAccessible);
return Common::formatMemoryToString(&m_scanRAMCache[ramIndex], m_memType, m_memSize, m_memBase,
const size_t length{m_memType == Common::MemType::type_string ? ~0ULL : m_memSize};
return Common::formatMemoryToString(&m_scanRAMCache[ramIndex], m_memType, length, m_memBase,
!m_memIsSigned, Common::shouldBeBSwappedForType(m_memType));
}

Expand Down

0 comments on commit cd16d39

Please sign in to comment.