You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Special Hex String Construct for Mobile Label Addresses #33
The issue is that CleoA uses a label search strategy to find structure addresses so scripts are compatible with multiple versions of the game. The hex constructs used to store the label string won't decompile without IGNORE_UNKNOWN, and is returned as a hex bytes. which works, but provides little useful information on how to adapt the code.
These constructs are always used in combination with a label used by opcode 0DD0:. I'm wondering if that's enough information for Sanny to format the hex construct as a null terminated string. Or maybe there's a better solution, because this "Magic Hex" construct is extremely common in CleoA scripts - anything that accesses memory and isn't complete garbage.
Example (used in script body):
// Markuza97's any-version address codes - read once
0DD0: 6@ = get_label_addr @_ZN6CRadar13ms_RadarTraceE
0DD1: 6@ = get_func_addr_by_cstr_name 6@ // start of marker structure
0DD0: 7@ = get_label_addr @gMobileMenu
0DD1: 7@ = get_func_addr_by_cstr_name 7@ // start of... menu data?
000A: 7@ += 0x48 // offset to marker index
Labels (traditionally appended to the end of the script):
// Markuza97's magic hex codes
:gMobileMenu
hex
"gMobileMenu" 00
end
:_ZN6CRadar13ms_RadarTraceE
hex
"_ZN6CRadar13ms_RadarTraceE" 00
end
The code becomes unreadable hexadecimal. Although you can open it with Notepad to see the character names. As OrionSR said.
I hope SB can decompile the correct string. As for the ASM assembly code in the example. . . . . . . . This is just my wishful thinking, haha, it would be nice if the compiled assembly code can also be decompiled. How about giving SB a function of automatic assembly and machine code conversion? Write the assembly directly when writing in this way, and automatically convert to machine code after compilation?
When only using a function, put the function name at the end. Decompilation does not affect the sorting of the previous CLEO code.
But when you use multiple functions or allocate a piece of static memory space, the decompiled code will be worse:
Here I have a "real time CLEO" that I wrote before (the game time is synchronized with the phone system time). The decompilation is very bad... In fact, I really like the structure of Android CLEO, even though the SB tool is currently used for Android GTA scripts Compilation/decompilation is bad.
In fact, if the string {function name} cannot be decompiled correctly. So is it possible to add a function of importing strings to SB (only for Android GTA). To make it decompile correctly.
Thanks for all the examples. I don't think this can be solved in a general way, i.e. it would be impossible to cover all possible use cases with hex.end input. But particularly for 0DD0 I think we could make another debug flag that will allow to treat the content at the referenced label as a null-terminated character sequence.
How about giving SB a function of automatic assembly and machine code conversion? Write the assembly directly when writing in this way, and automatically convert to machine code after compilation?
I believe @Deji69 had this feature in his Scrambl compiler. We might discuss this in a separate ticket if you will.
Finally, there is an Android CLEO issue.
I am trying to implement static injection of ARM assembly code in Android CLEO. I succeeded, but there is an architectural problem. I very much hope that the SB tool can add a function to solve the problem:
{$CLEO .csa}
0000:
jump @1
:ASM
hex
AEF12D00 //SUB R0, LR, #0x2D
F746 //MOV PC, LR
end
:1
wait 0
0DD0: 39@ = get_label_addr @ASM
0DD8: 1@ = read_mem_addr 39@ size 4 add_ib 0
39@ += 4
0DD8: 2@ = read_mem_addr 39@ size 2 add_ib 0
39@ -= 4
0DD9: write_mem_addr 39@ value 1@ size 4 add_ib 0 protect 1
39@ += 4
0DD9: write_mem_addr 39@ value 2@ size 2 add_ib 0 protect 1
39@ -= 4
//It must be read first, and then written as protect 1.
//Because what Android CLEO.so is loaded is not the game memory space,
// but the static memory space allocated by the Android system,
//which cannot be accessed directly.
//This may be because of the rigor of the Android system
39@ += 1
//Because it is a thumb instruction, the return address is automatically +1
//BLX will automatically recognize the switching instruction set
//The lowest bit of BLX address is 1 for Thumb, and 0 for Arm
//Android GTA uses ARMV7 and Thumb mixed instructions
0DD2: context_call_func 39@
0DD4: 0@ = context_get_reg 0 //0@= asm call addr
0DD8: 10@ = read_mem_addr 0@ size 1 add_ib 0
01E5: show_text_1number_highpriority GXT 'NUMBER' number 10@ time 10000 flag 1
end_thread
The above code gets the memory address of the function asm_call in CLEO.SO in the Android cleo library, and reads its first byte for display.
Just test the code, in fact, 0DD2 CALL calls itself to access its own address. This is also the OP implementation of ODD2.
But the problem is not here. The ASM assembly code at the beginning must be placed at the beginning of CLEO. If placed at the end, the game will crash and report an error.
After I spent time researching, the error code is as follows:
If you do not add hex 00 end here to fill a byte to align the data, the game will crash. I noticed that this problem only occurs in Android, which is also the particularity of the architecture. It seems that the CLEO code will affect the alignment in memory?
It would be better if SB can automatically add extra bytes when compiling Android CLEO, but this is only suitable for advanced Android CLEO development
:ASM
hex
AEF12D00 //SUB R0, LR, #0x2D
F746 //MOV PC, LR
end
I think disabling Extra Info was added to Mobile Coding 101 back when storage space on mobile devices was considerably more limited. I have seen very few examples of advanced mobile scripts that use this option.
Even on PC, Extra Info is usually only included with scripts from beginners that haven't explored SB's options yet, or scripts designed with the explicit intent of sharing the original code.
I suspect the basic player instinct is to disable Extra Info to hide your sloppy coding strategies, or to discourage people from stealing what you worked so hard to create.
I think disabling Extra Info was added to Mobile Coding 101 back when storage space on mobile devices was considerably more limited. I have seen very few examples of advanced mobile scripts that use this option.
Even on PC, Extra Info is usually only included with scripts from beginners that haven't explored SB's options yet, or scripts designed with the explicit intent of sharing the original code.
I suspect the basic player instinct is to disable Extra Info to hide your sloppy coding strategies, or to discourage people from stealing what you worked so hard to create.
Yes. Usually not checked. Because it affects the lock. There are also some encrypted CLEOs in the writing of Android CLEO. But there is nothing advanced. They use the compilation mechanism of the SB tool to hide their code. I have studied this encryption method. However, Android CLEO is largely limited, and I don't like the so-called deliberate concealment of code. For example, I provided the method for reading and writing the Android configuration ini file before, but others have encrypted their CLEO when they know it.
I guess another problem with the mobile hex strings is that it encourages players to think too much about locking strategies. I usually recommend tossing any script that is deliberately locked but for mobile scripts it's often hard to tell the difference. So for this particular case, I'm really hoping that a better strategy can be developed.
@XMDS in v3.8.0-beta.1 disassembler should be able to write the content of a hex..end block as a string. Please try it and share your feedback with me.
there is "Add extra info" option in Sanny Builder to get better decompilation results with hex.end specifically. Does it help?
Yes, the source code will be retained if you check to add additional information. This is indeed a good way. But not everyone does it
I think disabling Extra Info was added to Mobile Coding 101 back when storage space on mobile devices was considerably more limited. I have seen very few examples of advanced mobile scripts that use this option.
Even on PC, Extra Info is usually only included with scripts from beginners that haven't explored SB's options yet, or scripts designed with the explicit intent of sharing the original code.
I suspect the basic player instinct is to disable Extra Info to hide your sloppy coding strategies, or to discourage people from stealing what you worked so hard to create.
Yes. Usually not checked. Because it affects the lock. There are also some encrypted CLEOs in the writing of Android CLEO. But there is nothing advanced. They use the compilation mechanism of the SB tool to hide their code. I have studied this encryption method. However, Android CLEO is largely limited, and I don't like the so-called deliberate concealment of code. For example, I provided the method for reading and writing the Android configuration ini file before, but others have encrypted their CLEO when they know it.
Finally, there is an Android CLEO issue. I am trying to implement static injection of ARM assembly code in Android CLEO. I succeeded, but there is an architectural problem. I very much hope that the SB tool can add a function to solve the problem:
{$CLEO .csa}
0000:
jump @1
:ASM
hex
AEF12D00 //SUB R0, LR, #0x2D
F746 //MOV PC, LR
end
:1
wait 0
0DD0: 39@ = get_label_addr @ASM
0DD8: 1@ = read_mem_addr 39@ size 4 add_ib 0
39@ += 4
0DD8: 2@ = read_mem_addr 39@ size 2 add_ib 0
39@ -= 4
0DD9: write_mem_addr 39@ value 1@ size 4 add_ib 0 protect 1
39@ += 4
0DD9: write_mem_addr 39@ value 2@ size 2 add_ib 0 protect 1
39@ -= 4
//It must be read first, and then written as protect 1.
//Because what Android CLEO.so is loaded is not the game memory space,
// but the static memory space allocated by the Android system,
//which cannot be accessed directly.
//This may be because of the rigor of the Android system
39@ += 1
//Because it is a thumb instruction, the return address is automatically +1
//BLX will automatically recognize the switching instruction set
//The lowest bit of BLX address is 1 for Thumb, and 0 for Arm
//Android GTA uses ARMV7 and Thumb mixed instructions
0DD2: context_call_func 39@
0DD4: 0@ = context_get_reg 0 //0@= asm call addr
0DD8: 10@ = read_mem_addr 0@ size 1 add_ib 0
01E5: show_text_1number_highpriority GXT 'NUMBER' number 10@ time 10000 flag 1
end_thread
The above code gets the memory address of the function asm_call in CLEO.SO in the Android cleo library, and reads its first byte for display. Just test the code, in fact, 0DD2 CALL calls itself to access its own address. This is also the OP implementation of ODD2.
But the problem is not here. The ASM assembly code at the beginning must be placed at the beginning of CLEO. If placed at the end, the game will crash and report an error. After I spent time researching, the error code is as follows:
If you do not add hex 00 end here to fill a byte to align the data, the game will crash. I noticed that this problem only occurs in Android, which is also the particularity of the architecture. It seems that the CLEO code will affect the alignment in memory? It would be better if SB can automatically add extra bytes when compiling Android CLEO, but this is only suitable for advanced Android CLEO development
:ASM
hex
AEF12D00 //SUB R0, LR, #0x2D
F746 //MOV PC, LR
end
Finally, there is an Android CLEO issue. I am trying to implement static injection of ARM assembly code in Android CLEO. I succeeded, but there is an architectural problem. I very much hope that the SB tool can add a function to solve the problem:
{$CLEO .csa}
0000:
jump @1
:ASM
hex
AEF12D00 //SUB R0, LR, #0x2D
F746 //MOV PC, LR
end
:1
wait 0
0DD0: 39@ = get_label_addr @ASM
0DD8: 1@ = read_mem_addr 39@ size 4 add_ib 0
39@ += 4
0DD8: 2@ = read_mem_addr 39@ size 2 add_ib 0
39@ -= 4
0DD9: write_mem_addr 39@ value 1@ size 4 add_ib 0 protect 1
39@ += 4
0DD9: write_mem_addr 39@ value 2@ size 2 add_ib 0 protect 1
39@ -= 4
//It must be read first, and then written as protect 1.
//Because what Android CLEO.so is loaded is not the game memory space,
// but the static memory space allocated by the Android system,
//which cannot be accessed directly.
//This may be because of the rigor of the Android system
39@ += 1
//Because it is a thumb instruction, the return address is automatically +1
//BLX will automatically recognize the switching instruction set
//The lowest bit of BLX address is 1 for Thumb, and 0 for Arm
//Android GTA uses ARMV7 and Thumb mixed instructions
0DD2: context_call_func 39@
0DD4: 0@ = context_get_reg 0 //0@= asm call addr
0DD8: 10@ = read_mem_addr 0@ size 1 add_ib 0
01E5: show_text_1number_highpriority GXT 'NUMBER' number 10@ time 10000 flag 1
end_thread
The above code gets the memory address of the function asm_call in CLEO.SO in the Android cleo library, and reads its first byte for display. Just test the code, in fact, 0DD2 CALL calls itself to access its own address. This is also the OP implementation of ODD2.
But the problem is not here. The ASM assembly code at the beginning must be placed at the beginning of CLEO. If placed at the end, the game will crash and report an error. After I spent time researching, the error code is as follows:
If you do not add hex 00 end here to fill a byte to align the data, the game will crash. I noticed that this problem only occurs in Android, which is also the particularity of the architecture. It seems that the CLEO code will affect the alignment in memory? It would be better if SB can automatically add extra bytes when compiling Android CLEO, but this is only suitable for advanced Android CLEO development
:ASM
hex
AEF12D00 //SUB R0, LR, #0x2D
F746 //MOV PC, LR
end
Activity
XMDS commentedon Jul 21, 2020
In fact, SB will always turn the string contained in hex into hexadecimal after decompilation. This makes the code unreadable
XMDS commentedon Jul 21, 2020
On the PC version:
After decompilation:
The code becomes unreadable hexadecimal. Although you can open it with Notepad to see the character names. As OrionSR said.
I hope SB can decompile the correct string. As for the ASM assembly code in the example. . . . . . . . This is just my wishful thinking, haha, it would be nice if the compiled assembly code can also be decompiled. How about giving SB a function of automatic assembly and machine code conversion? Write the assembly directly when writing in this way, and automatically convert to machine code after compilation?
XMDS commentedon Jul 21, 2020
Even on Android CLEO:
For example, the pointer structure of the player obtained above, after decompilation:
They are very messy, this kind of bad code
XMDS commentedon Jul 21, 2020
When only using a function, put the function name at the end. Decompilation does not affect the sorting of the previous CLEO code.
But when you use multiple functions or allocate a piece of static memory space, the decompiled code will be worse:
https://github.com/XMDS/Cleo-source-code/blob/master/XMDS/Android/SA/Realtime.txt
Here I have a "real time CLEO" that I wrote before (the game time is synchronized with the phone system time). The decompilation is very bad... In fact, I really like the structure of Android CLEO, even though the SB tool is currently used for Android GTA scripts Compilation/decompilation is bad.
In fact, if the string {function name} cannot be decompiled correctly. So is it possible to add a function of importing strings to SB (only for Android GTA). To make it decompile correctly.
x87 commentedon Jul 21, 2020
Thanks for all the examples. I don't think this can be solved in a general way, i.e. it would be impossible to cover all possible use cases with hex.end input. But particularly for
0DD0I think we could make another debug flag that will allow to treat the content at the referenced label as a null-terminated character sequence.x87 commentedon Jul 21, 2020
@XMDS
I believe @Deji69 had this feature in his Scrambl compiler. We might discuss this in a separate ticket if you will.
x87 commentedon Jul 21, 2020
there is "Add extra info" option in Sanny Builder to get better decompilation results with hex.end specifically. Does it help?
XMDS commentedon Jul 21, 2020
Finally, there is an Android CLEO issue.
I am trying to implement static injection of ARM assembly code in Android CLEO. I succeeded, but there is an architectural problem. I very much hope that the SB tool can add a function to solve the problem:
The above code gets the memory address of the function asm_call in CLEO.SO in the Android cleo library, and reads its first byte for display.
Just test the code, in fact, 0DD2 CALL calls itself to access its own address. This is also the OP implementation of ODD2.
But the problem is not here. The ASM assembly code at the beginning must be placed at the beginning of CLEO. If placed at the end, the game will crash and report an error.
After I spent time researching, the error code is as follows:
When accessing memory, the data is not aligned
The new code is placed at the end:
If you do not add hex 00 end here to fill a byte to align the data, the game will crash. I noticed that this problem only occurs in Android, which is also the particularity of the architecture. It seems that the CLEO code will affect the alignment in memory?
It would be better if SB can automatically add extra bytes when compiling Android CLEO, but this is only suitable for advanced Android CLEO development
XMDS commentedon Jul 21, 2020
Yes, the source code will be retained if you check to add additional information. This is indeed a good way. But not everyone does it
x87 commentedon Jul 21, 2020
let's continue in #36
OrionSR commentedon Jul 21, 2020
I think disabling Extra Info was added to Mobile Coding 101 back when storage space on mobile devices was considerably more limited. I have seen very few examples of advanced mobile scripts that use this option.
Even on PC, Extra Info is usually only included with scripts from beginners that haven't explored SB's options yet, or scripts designed with the explicit intent of sharing the original code.
I suspect the basic player instinct is to disable Extra Info to hide your sloppy coding strategies, or to discourage people from stealing what you worked so hard to create.
XMDS commentedon Jul 21, 2020
Yes. Usually not checked. Because it affects the lock. There are also some encrypted CLEOs in the writing of Android CLEO. But there is nothing advanced. They use the compilation mechanism of the SB tool to hide their code. I have studied this encryption method. However, Android CLEO is largely limited, and I don't like the so-called deliberate concealment of code. For example, I provided the method for reading and writing the Android configuration ini file before, but others have encrypted their CLEO when they know it.
OrionSR commentedon Jul 22, 2020
I guess another problem with the mobile hex strings is that it encourages players to think too much about locking strategies. I usually recommend tossing any script that is deliberately locked but for mobile scripts it's often hard to tell the difference. So for this particular case, I'm really hoping that a better strategy can be developed.
x87 commentedon Jul 25, 2021
@XMDS in v3.8.0-beta.1 disassembler should be able to write the content of a hex..end block as a string. Please try it and share your feedback with me.
XMDS commentedon Jul 27, 2021
After a short period of testing, I have not found any problems for the time being. The string is currently decompiled correctly
Vehicle-ped commentedon Dec 16, 2024
Where do I get this 0×2D