-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCallerCutFix_290.pbp
51 lines (44 loc) · 1.17 KB
/
CallerCutFix_290.pbp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
; This patch fixes CallerID not showing
; when utf8 string with non-even bytes count
; gets cut at 32bytes (buffer size).
#ver 290
; patch function phone_ui_set_callerid_name
38 b5 08 4b @ 01 46 1d 68 20 22 05 f5 b6 74 {
; was: MOV R1,R0; LDR R5,[R3]
B.W my_code
global cont
}
{
proc my_code
; in R0 we have a pointer to string
; R3 is occupied, others are unused
MOV R1, R0 ; save original pointer
findend:
LDRB R2, [R0]
CBZ R2, end_found
ADD R0, 1
B findend
end_found:
SUB R0, 1
; now R0 points to last significant byte of the string
; if strlen < 31 then string was not trimmed - don't do anything with it
SUB R2, R0, R1 ; strlen-1
CMP R2, 30
BLT good ; lesser than
LDRB R2, [R0]
; one-byte?
LSR R4, R2, 7 ; R4 = R2 >> 7
CBZ R4, good ; one-byte character
; continuation? (FIXME: maybe need more than one continuation)
LSR R4, R2, 6 ; R4 = R2 >> 6
AND R4, R4, 1 ; 6th bit will be 0 for continuation byte
CBZ R4, good ; continuation - consider it normal (FIXME)
; now we know it is a lonely starting byte; something is wrong, so clear it!
MOV R2, 0
STRB R2, [R0]
good:
; re-execute overwriten operations
; -- already done: MOV R1, R0
LDR R5, [R3]
B.W cont
}