File tree Expand file tree Collapse file tree 1 file changed +20
-13
lines changed Expand file tree Collapse file tree 1 file changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ static std::pair<uintptr_t, const char*> TH_FASTCALL str_to_addr_impl(uintptr_t
32
32
flags = 0 ;
33
33
TH_FALLTHROUGH ;
34
34
case '0' :
35
- switch ( *++ str_read) {
35
+ switch (c = *++ str_read) {
36
36
case 'x' : case 'X' :
37
37
number_base = 16 ;
38
38
c = *++ str_read ;
@@ -42,10 +42,9 @@ static std::pair<uintptr_t, const char*> TH_FASTCALL str_to_addr_impl(uintptr_t
42
42
c = *++ str_read ;
43
43
break ;
44
44
default:
45
- if (! flags ) {
46
- goto fail ;
47
- }
48
- TH_FALLTHROUGH ;
45
+ return flags == is_not_relative
46
+ ? std ::make_pair( 0 , (const char * )str_read)
47
+ : std ::make_pair( std ::numeric_limits<uintptr_t>::max() , str ) ;
49
48
case '0' ... '9' :
50
49
break ;
51
50
}
@@ -126,31 +125,28 @@ fail:
126
125
LEA EAX , [ ECX - '1' ]
127
126
CMP AL , 9
128
127
JB is_base_ten
129
- CMP AL , '0' - '1 '
128
+ CMP CL , '0'
130
129
JE is_leading_zero
131
130
OR CL , 0x20
132
131
CMP CL , 'r'
133
132
JNE failA
134
133
XOR BL , BL
135
134
is_leading_zero:
136
135
MOVZX ECX , BYTE PTR [ EDX + 1 ]
137
- INC ESI
136
+ ADD ESI , 1
138
137
LEA EAX , [ ECX - '0' ]
139
138
CMP AL , 10
140
139
JB is_base_ten
141
140
MOV BH , 16
142
141
OR CL , 0x20
143
142
CMP CL , 'x'
144
143
JE is_zero_prefix
145
- MOV BH , 2
146
144
CMP CL , 'b'
147
- JE is_zero_prefix
148
- TEST BL , BL / * Make sure th at a single 0 is valid but a single R is not * /
149
- JZ failA
150
- DEC ESI / * Don 't index the string twice if there isn' t a b/x character * /
145
+ JNE standalone_zero
146
+ MOV BH , 2
151
147
is_zero_prefix:
152
148
MOVZX ECX , BYTE PTR [ EDX + 2 ]
153
- INC ESI
149
+ ADD ESI , 1
154
150
is_base_ten:
155
151
/ *
156
152
; EAX: ret
@@ -219,3 +215,14 @@ failA:
219
215
POP EBX
220
216
RET
221
217
INT3
218
+ INT3
219
+ standalone_zero:
220
+ CMP BL , 1 / * Make sure th at a single 0 is valid but a single R is not * /
221
+ CMOVE EDX , ESI
222
+ SBB EAX , EAX / * Returns 0 or - 1 * /
223
+ POP EDI
224
+ POP ESI
225
+ POP EBP
226
+ POP EBX
227
+ RET
228
+ INT3
You can’t perform that action at this time.
0 commit comments