Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/RA_Integration.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<ClCompile Include="services\impl\WindowsHttpRequester.cpp" />
<ClCompile Include="services\Initialization.cpp" />
<ClCompile Include="services\PerformanceCounter.cpp" />
<ClCompile Include="services\PointerFinder.cpp" />
<ClCompile Include="services\SearchResults.cpp" />
<ClCompile Include="services\search\SearchImpl.cpp" />
<ClCompile Include="ui\drawing\gdi\GDIBitmapSurface.cpp" />
Expand Down Expand Up @@ -237,6 +238,7 @@
<ClInclude Include="services\impl\WindowsHttpRequester.hh" />
<ClInclude Include="services\Initialization.hh" />
<ClInclude Include="services\PerformanceCounter.hh" />
<ClInclude Include="services\PointerFinder.hh" />
<ClInclude Include="services\search\SearchImpl.hh" />
<ClInclude Include="services\search\SearchImpl_16bit.hh" />
<ClInclude Include="services\search\SearchImpl_16bit_aligned.hh" />
Expand Down
6 changes: 6 additions & 0 deletions src/RA_Integration.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@
<ClCompile Include="ui\win32\TriggerSummaryDialog.cpp">
<Filter>UI\Win32</Filter>
</ClCompile>
<ClCompile Include="services\PointerFinder.cpp">
<Filter>Services</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="RA_Resource.h">
Expand Down Expand Up @@ -932,6 +935,9 @@
<ClInclude Include="ui\win32\TriggerSummaryDialog.hh">
<Filter>UI\Win32</Filter>
</ClInclude>
<ClInclude Include="services\PointerFinder.hh">
<Filter>Services</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="RA_Shared.rc">
Expand Down
2 changes: 1 addition & 1 deletion src/RA_Shared.rc
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ BEGIN
COMBOBOX IDC_RA_SEARCHTYPE,7,19,71,13,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "&Find",IDC_RA_RESET_FILTER,6,33,72,13
PUSHBUTTON "Book&mark Selected",IDC_RA_RESULTS_BOOKMARK,6,65,72,13
PUSHBUTTON "E&xport",IDC_RA_RESULTS_EXPORT,6,78,72,13
PUSHBUTTON "&Copy Chain",IDC_RA_COPY_ALL,6,78,72,13
CONTROL "",IDC_RA_RESULTS,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_BORDER | WS_VSCROLL | WS_TABSTOP,80,9,312,81
GROUPBOX "State 1",IDC_RA_GBX_STATE_1,4,94,392,59
LTEXT "Address:",IDC_RA_LBL_ADDRESS_1,8,103,32,9
Expand Down
83 changes: 52 additions & 31 deletions src/devkit/data/CapturedMemoryBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,46 +335,67 @@ ra::data::ByteAddress CapturedMemoryBlock::GetMatchingAddress(gsl::index nIndex)
if (AreAllAddressesMatching())
return m_nFirstAddress + gsl::narrow_cast<ra::data::ByteAddress>(nIndex);

const auto nAddressesSize = (m_nAddressCount + 7) / 8;
const uint8_t* pAddresses = (nAddressesSize > sizeof(m_vAddresses)) ? m_pAddresses : &m_vAddresses[0];
ra::data::ByteAddress nAddress = 0;
EnumerateMatchingAddressesInternal([&nAddress, &nIndex](ra::data::ByteAddress nScanAddress) noexcept {
if (nIndex == 0)
{
nAddress = nScanAddress;
return false;
}

--nIndex;
return true;
});

return nAddress;
}

bool CapturedMemoryBlock::EnumerateMatchingAddresses(std::function<bool(ra::data::ByteAddress)> fCallback) const
{
if (!AreAllAddressesMatching())
return EnumerateMatchingAddressesInternal(fCallback);

for (auto nAddress = m_nFirstAddress; nAddress < m_nFirstAddress + m_nAddressCount; ++nAddress)
{
if (!fCallback(nAddress))
return false;
}

return true;
}

bool CapturedMemoryBlock::EnumerateMatchingAddressesInternal(std::function<bool(ra::data::ByteAddress)> fCallback) const
{
const uint8_t* pAddresses = GetMatchingAddressPointer();
if (GSL_UNLIKELY(pAddresses == nullptr))
return false;

ra::data::ByteAddress nAddress = m_nFirstAddress;
const ra::data::ByteAddress nStop = m_nFirstAddress + m_nAddressCount;
uint8_t nMask = 0x01;
const ra::data::ByteAddress nStop = nAddress + m_nAddressCount;

if (pAddresses != nullptr)
do
{
do
uint8_t nValue = *pAddresses++;
if (nValue)
{
if (*pAddresses & nMask)
ra::data::ByteAddress nScanAddress = nAddress;
do
{
if (nIndex-- == 0)
return nAddress;
}

if (nMask == 0x80)
{
nMask = 0x01;
pAddresses++;

while (!*pAddresses)
if (nValue & 1)
{
nAddress += 8;
if (nAddress >= nStop)
break;

pAddresses++;
if (!fCallback(nScanAddress))
return false;
}
}
else
{
nMask <<= 1;
}

nAddress++;
} while (nAddress < nStop);
}
++nScanAddress;
nValue >>= 1;
} while (nValue);
}

nAddress += 8;
} while (nAddress < nStop);

return 0;
return true;
}

} // namespace data
Expand Down
8 changes: 8 additions & 0 deletions src/devkit/data/CapturedMemoryBlock.hh
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ public:
return (pMatchingAddresses[nIndex >> 3] & nBit);
}

/// <summary>
/// Calls the provided callback for each matching address.
/// </summary>
/// <param name="fCallback">Callback to call for each element, returns <c>true</c> to continue iterating, or <c>false</c> to stop.</param>
bool EnumerateMatchingAddresses(std::function<bool(ra::data::ByteAddress)> fCallback) const;

/// <summary>
/// Attempts to minimize memory allocations by detecting and sharing large blocks of repeated data.
/// </summary>
Expand All @@ -175,6 +181,8 @@ public:
private:
bool IsBytesAllocated() const noexcept { return GetBytesSize() > sizeof(m_vBytes); }

bool EnumerateMatchingAddressesInternal(std::function<bool(ra::data::ByteAddress)> fCallback) const;

void ShareMemory(const std::vector<CapturedMemoryBlock>& vBlocks, uint32_t nHash) noexcept;
//void SetRepeat(uint32_t nCount, uint32_t nValue) noexcept;

Expand Down
Loading
Loading