Skip to content

Commit

Permalink
Show extended scan preview for strings.
Browse files Browse the repository at this point in the history
Scan preview for strings will be unbounded; their length will be
determined solely by the null character.

Bonus: Non-printable characters in scanned or watched strings will be
replaced with the � character (the unrepresentable character).

Fixed aldelaro5#79.
  • Loading branch information
cristian64 committed Apr 28, 2024
1 parent 02f35d7 commit 5fd3e62
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,5 +1,6 @@
#include "MemoryCommon.h"

#include <cctype>
#include <bitset>
#include <cstring>
#include <iomanip>
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 5fd3e62

Please sign in to comment.