Core: Separate guessing width and type

This commit is contained in:
Vicki Pfau 2017-10-14 17:22:48 -07:00
parent 8385869652
commit db69256ce9
3 changed files with 38 additions and 22 deletions

View File

@ -137,9 +137,9 @@ static size_t _searchGuess(const void* mem, size_t size, const struct mCoreMemor
// Decimal: // Decimal:
value = strtoll(params->valueStr, &end, 10); value = strtoll(params->valueStr, &end, 10);
if (end && !end[0]) { if (end && !end[0]) {
if (value > 0x10000) { if ((params->width == -1 && value > 0x10000) || params->width == 4) {
found += _search32(mem, size, block, value, params->op, out, limit ? limit - found : 0); found += _search32(mem, size, block, value, params->op, out, limit ? limit - found : 0);
} else if (value > 0x100) { } else if ((params->width == -1 && value > 0x100) || params->width == 2) {
found += _search16(mem, size, block, value, params->op, out, limit ? limit - found : 0); found += _search16(mem, size, block, value, params->op, out, limit ? limit - found : 0);
} else { } else {
found += _search8(mem, size, block, value, params->op, out, limit ? limit - found : 0); found += _search8(mem, size, block, value, params->op, out, limit ? limit - found : 0);
@ -151,9 +151,9 @@ static size_t _searchGuess(const void* mem, size_t size, const struct mCoreMemor
value /= 10; value /= 10;
divisor *= 10; divisor *= 10;
if (value > 0x10000) { if ((params->width == -1 && value > 0x10000) || params->width == 4) {
found += _search32(mem, size, block, value, params->op, &tmp, limit ? limit - found : 0); found += _search32(mem, size, block, value, params->op, &tmp, limit ? limit - found : 0);
} else if (value > 0x100) { } else if ((params->width == -1 && value > 0x100) || params->width == 2) {
found += _search16(mem, size, block, value, params->op, &tmp, limit ? limit - found : 0); found += _search16(mem, size, block, value, params->op, &tmp, limit ? limit - found : 0);
} else { } else {
found += _search8(mem, size, block, value, params->op, &tmp, limit ? limit - found : 0); found += _search8(mem, size, block, value, params->op, &tmp, limit ? limit - found : 0);
@ -170,9 +170,9 @@ static size_t _searchGuess(const void* mem, size_t size, const struct mCoreMemor
// Hex: // Hex:
value = strtoll(params->valueStr, &end, 16); value = strtoll(params->valueStr, &end, 16);
if (end && !end[0]) { if (end && !end[0]) {
if (value > 0x10000) { if ((params->width == -1 && value > 0x10000) || params->width == 4) {
found += _search32(mem, size, block, value, params->op, out, limit ? limit - found : 0); found += _search32(mem, size, block, value, params->op, out, limit ? limit - found : 0);
} else if (value > 0x100) { } else if ((params->width == -1 && value > 0x100) || params->width == 2) {
found += _search16(mem, size, block, value, params->op, out, limit ? limit - found : 0); found += _search16(mem, size, block, value, params->op, out, limit ? limit - found : 0);
} else { } else {
found += _search8(mem, size, block, value, params->op, out, limit ? limit - found : 0); found += _search8(mem, size, block, value, params->op, out, limit ? limit - found : 0);
@ -184,9 +184,9 @@ static size_t _searchGuess(const void* mem, size_t size, const struct mCoreMemor
value >>= 4; value >>= 4;
divisor <<= 4; divisor <<= 4;
if (value > 0x10000) { if ((params->width == -1 && value > 0x10000) || params->width == 4) {
found += _search32(mem, size, block, value, params->op, &tmp, limit ? limit - found : 0); found += _search32(mem, size, block, value, params->op, &tmp, limit ? limit - found : 0);
} else if (value > 0x100) { } else if ((params->width == -1 && value > 0x100) || params->width == 2) {
found += _search16(mem, size, block, value, params->op, &tmp, limit ? limit - found : 0); found += _search16(mem, size, block, value, params->op, &tmp, limit ? limit - found : 0);
} else { } else {
found += _search8(mem, size, block, value, params->op, &tmp, limit ? limit - found : 0); found += _search8(mem, size, block, value, params->op, &tmp, limit ? limit - found : 0);

View File

@ -61,6 +61,9 @@ bool MemorySearch::createParams(mCoreMemorySearchParams* params) {
if (m_ui.bits32->isChecked()) { if (m_ui.bits32->isChecked()) {
params->width = 4; params->width = 4;
} }
if (m_ui.bitsGuess->isChecked()) {
params->width = -1;
}
if (m_ui.numHex->isChecked()) { if (m_ui.numHex->isChecked()) {
uint32_t v = m_ui.value->text().toUInt(&ok, 16); uint32_t v = m_ui.value->text().toUInt(&ok, 16);
if (ok) { if (ok) {

View File

@ -114,6 +114,19 @@
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="1">
<widget class="QRadioButton" name="bitsGuess">
<property name="text">
<string>Guess</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">width</string>
</attribute>
</widget>
</item>
<item row="5" column="1">
<widget class="QRadioButton" name="bits8"> <widget class="QRadioButton" name="bits8">
<property name="text"> <property name="text">
<string>1 Byte (8-bit)</string> <string>1 Byte (8-bit)</string>
@ -123,7 +136,7 @@
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="6" column="1">
<widget class="QRadioButton" name="bits16"> <widget class="QRadioButton" name="bits16">
<property name="text"> <property name="text">
<string>2 Bytes (16-bit)</string> <string>2 Bytes (16-bit)</string>
@ -133,34 +146,34 @@
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="7" column="1">
<widget class="QRadioButton" name="bits32"> <widget class="QRadioButton" name="bits32">
<property name="text"> <property name="text">
<string>4 Bytes (32-bit)</string> <string>4 Bytes (32-bit)</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>false</bool>
</property> </property>
<attribute name="buttonGroup"> <attribute name="buttonGroup">
<string notr="true">width</string> <string notr="true">width</string>
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item row="7" column="0" colspan="2"> <item row="8" column="0" colspan="2">
<widget class="Line" name="line_2"> <widget class="Line" name="line_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0"> <item row="9" column="0">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="text"> <property name="text">
<string>Number type</string> <string>Number type</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1"> <item row="9" column="1">
<widget class="QRadioButton" name="numGuess"> <widget class="QRadioButton" name="numGuess">
<property name="text"> <property name="text">
<string>Guess</string> <string>Guess</string>
@ -170,35 +183,35 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="1"> <item row="10" column="1">
<widget class="QRadioButton" name="numDec"> <widget class="QRadioButton" name="numDec">
<property name="text"> <property name="text">
<string>Decimal</string> <string>Decimal</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="1"> <item row="11" column="1">
<widget class="QRadioButton" name="numHex"> <widget class="QRadioButton" name="numHex">
<property name="text"> <property name="text">
<string>Hexadecimal</string> <string>Hexadecimal</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="0" colspan="2"> <item row="12" column="0" colspan="2">
<widget class="Line" name="line_3"> <widget class="Line" name="line_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="12" column="0"> <item row="13" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
<string>Compare</string> <string>Compare</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="12" column="1"> <item row="13" column="1">
<widget class="QRadioButton" name="opEqual"> <widget class="QRadioButton" name="opEqual">
<property name="text"> <property name="text">
<string>Equal</string> <string>Equal</string>
@ -211,7 +224,7 @@
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item row="13" column="1"> <item row="14" column="1">
<widget class="QRadioButton" name="opGreater"> <widget class="QRadioButton" name="opGreater">
<property name="text"> <property name="text">
<string>Greater</string> <string>Greater</string>
@ -221,7 +234,7 @@
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item row="14" column="1"> <item row="15" column="1">
<widget class="QRadioButton" name="opLess"> <widget class="QRadioButton" name="opLess">
<property name="text"> <property name="text">
<string>Less</string> <string>Less</string>
@ -231,7 +244,7 @@
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item row="15" column="1"> <item row="16" column="1">
<widget class="QRadioButton" name="opDelta"> <widget class="QRadioButton" name="opDelta">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>