@@ -50,13 +50,15 @@ private void HandleByteFragments(StringBuilder sb, string secondFragment, string
50
50
{
51
51
var byteFragments = secondFragment . Split ( ' ' ) ;
52
52
53
+ bool offsetWildcarded = false ;
54
+
53
55
for ( var i = 0 ; i < byteFragments . Length ; i ++ )
54
56
{
55
57
var byteFragment = byteFragments [ i ] ;
56
58
switch ( byteFragment . Length )
57
59
{
58
60
case 2 :
59
- if ( alsoWildcardOffsets && i == byteFragments . Length - 1 && thirdFragment . Contains ( "+" + byteFragment ) )
61
+ if ( alsoWildcardOffsets && i == byteFragments . Length - 1 && thirdFragment . Contains ( "+" + byteFragment ) && ! offsetWildcarded )
60
62
{
61
63
sb . Append ( "?? " ) ;
62
64
}
@@ -72,8 +74,9 @@ private void HandleByteFragments(StringBuilder sb, string secondFragment, string
72
74
case 8 :
73
75
// offset or RIP relative block
74
76
// We convert the byteFragment to a hexadecimal number. If that number is present in third fragment, it's not a RIP relative address but an offset.
75
- if ( CheckIfShouldBeWildcarded ( byteFragment . ToLowerInvariant ( ) , thirdFragment , alsoWildcardOffsets ) )
77
+ if ( CheckIfShouldBeWildcarded ( byteFragment . ToLowerInvariant ( ) , thirdFragment , alsoWildcardOffsets , out bool performedOffsetWildcard ) )
76
78
{
79
+ offsetWildcarded |= performedOffsetWildcard ;
77
80
sb . Append ( "?? ?? ?? ?? " ) ;
78
81
}
79
82
else
@@ -111,12 +114,12 @@ private string HandleCheatEngine(string[] lines, bool alsoWildcardOffsets)
111
114
continue ;
112
115
}
113
116
114
- var indexFirstHyphen = l . IndexOf ( '-' ) ;
117
+ var indexFirstHyphen = l . IndexOf ( " - " , StringComparison . InvariantCulture ) ;
115
118
if ( indexFirstHyphen < 0 )
116
119
{
117
120
continue ;
118
121
}
119
- var indexOfSecondHyphen = l . IndexOf ( '-' , indexFirstHyphen + 1 ) ;
122
+ var indexOfSecondHyphen = l . IndexOf ( " - " , indexFirstHyphen + 1 , StringComparison . InvariantCulture ) ;
120
123
if ( indexOfSecondHyphen < 0 )
121
124
{
122
125
continue ;
@@ -162,20 +165,24 @@ private string HandleX64Dbg(string[] lines, bool alsoWildcardOffsets)
162
165
/// <param name="byteFragment"></param>
163
166
/// <param name="thirdFragment"></param>
164
167
/// <param name="alsoWildcardOffsets"></param>
168
+ /// <param name="performedOffsetWildcard"></param>
165
169
/// <returns></returns>
166
- private bool CheckIfShouldBeWildcarded ( string byteFragment , string thirdFragment , bool alsoWildcardOffsets )
170
+ private bool CheckIfShouldBeWildcarded ( string byteFragment , string thirdFragment , bool alsoWildcardOffsets , out bool performedOffsetWildcard )
167
171
{
172
+ performedOffsetWildcard = false ;
168
173
// convert the byte fragment to a hexadecimal number. then check if that number is present in thirdfragment.
169
174
// aabbccdd becomes ddccbbaa
170
175
var numberAsLittleEndian = new string ( new char [ ] { byteFragment [ 6 ] , byteFragment [ 7 ] , byteFragment [ 4 ] , byteFragment [ 5 ] , byteFragment [ 2 ] , byteFragment [ 3 ] , byteFragment [ 0 ] , byteFragment [ 1 ] } ) ;
171
176
// strip off all 0's at the front, so convert it to an int and then back to a hex string
172
177
uint bytes = uint . Parse ( numberAsLittleEndian , NumberStyles . HexNumber ) ;
173
178
string bytesAsHex = bytes . ToString ( "X" ) ;
179
+ var fragmentIsRIPRelativeAddress = ! thirdFragment . Contains ( bytesAsHex ) && ! thirdFragment . Contains ( numberAsLittleEndian ) ;
174
180
if ( alsoWildcardOffsets )
175
181
{
176
- return thirdFragment . Contains ( bytesAsHex ) || thirdFragment . Contains ( numberAsLittleEndian ) ;
182
+ performedOffsetWildcard = true ;
183
+ return fragmentIsRIPRelativeAddress || thirdFragment . Contains ( bytesAsHex ) || thirdFragment . Contains ( numberAsLittleEndian ) ;
177
184
}
178
- return ! thirdFragment . Contains ( bytesAsHex ) && ! thirdFragment . Contains ( numberAsLittleEndian ) ;
185
+ return fragmentIsRIPRelativeAddress ;
179
186
}
180
187
181
188
}
0 commit comments