Solved How to mod libil2cpp.so when its returning double?

Status
Not open for further replies.

timmyyy19977

Platinian
Original poster
Apr 25, 2021
16
1
1
30
japoan
Hi, I am new to modding games, and I found it very interesting. I have tried modding a game, and I successfully changed the return value for int types.

For any method returning int, I made the following hex code and had a success.
00 00 A0 E1 1E FF 2F E1 = NOP
00 00 A0 E3 1E FF 2F E1 = False or number 0
01 00 A0 E3 1E FF 2F E1 = True or number 1
02 00 A0 E3 1E FF 2F E1 = number 2
0A 00 A0 E3 1E FF 2F E1 = number 10
96 00 A0 E3 1E FF 2F E1 = number 150
C8 00 A0 E3 1E FF 2F E1 = number 200
2C 01 00 E3 1E FF 2F E1 = 300 (12C)
E7 03 00 E3 1E FF 2F E1 = 999 (3E7)
DC 0F 00 E3 1E FF 2F E1 = number 4060
DC 0F 0F E3 1E FF 2F E1 = number 65500

However, when it comes to float type and double type. it never worked. Like the following method:
1619932185444.png

I tried:
return 999float: 7A 04 04 E3 1E FF 2F E1.
In game it showed '0' instead.
I also tried return 999double
01 00 A0 E3
10 0A 00 EE
C0 0A B8 EE
10 0A 10 EE
1E FF 2F E1
Again, its a zero return.

Same goes with float returns:
1619932593039.png

I tried:
return 999float
7A 04 04 E3 1E FF 2F E1.
It never worked, always a wrong number. For the second float method, it is possible that the game logic won't allow modding.

What is the correct way of getting the hex code for returning a double or float? What do I need to learn or are there templates?
 

Tiahh

Solid & Active Platinian
Jan 12, 2018
75
45
18
37
Always better to hook, you can still doing this. Try to use Game Guardian for see if it works. Set the value and copy the hex that Game Guardian tells you. You can calculate offsets with Game Guardian so it should be more easier.
 

xyzhunter

PMT Modder
Staff member
Modding-Team
Oct 28, 2020
2,085
108,476
1,213
Indonesia
@timmyyy19977 i'm not sure what the result is , but i will tell you how return double
float = 80 0e 44 E3 1E FF 2F E1.
double = 80 1e 44 E3 1E FF 2F E1.

that's it
 
Last edited:

Galaxy169

Approved Modder
Approved Modder
Apr 28, 2020
29
953
78
Home
You can use this website to Floating Point to Hex Converter to convert Double & Float to Hex.

It could be possible the function you are modifying has much more going inside it, skipping the whole code using bx lr will break the function and cause problems.
In this case, Hook the function, or use IDA to understand the whole code and then modify it.
 

timmyyy19977

Platinian
Original poster
Apr 25, 2021
16
1
1
30
japoan
You can use this website to Floating Point to Hex Converter to convert Double & Float to Hex.

It could be possible the function you are modifying has much more going inside it, skipping the whole code using bx lr will break the function and cause problems.
In this case, Hook the function, or use IDA to understand the whole code and then modify it.
This is probably true. I need to learn more about how to hook and how to understand it. Thanks!
 

timmyyy19977

Platinian
Original poster
Apr 25, 2021
16
1
1
30
japoan
@timmyyy19977 just try this and tell me what happen
7A 14 04 E3 1E FF 2F E1.
I tried on this method.
1620703590170.png

double = 80 1e 44 E3 1E FF 2F E1. returns a large number:
1620703627834.png

7A 14 04 E3 1E FF 2F E1:
1620703735772.png


This is what i get. The above double number is working! However, I can't see how do we get this number from double to hex..
 

xyzhunter

PMT Modder
Staff member
Modding-Team
Oct 28, 2020
2,085
108,476
1,213
Indonesia

timmyyy19977

Platinian
Original poster
Apr 25, 2021
16
1
1
30
japoan
I found my final answer.

return 2.000xxxxxx
00 10 44 E3 1E FF 2F E1

return 131072.070218983
00 11 44 E3 1E FF 2F E1

return 8.5c
00 12 44 E3 1E FF 2F E1

Honestly, I still don't understand how the hex code "00 11 44 E3 1E FF 2F E1" translates to "return 131072.070218983". I understand the return part, but not the number part. Will try to dig deeper. Thanks for your help!
 

xyzhunter

PMT Modder
Staff member
Modding-Team
Oct 28, 2020
2,085
108,476
1,213
Indonesia
I found my final answer.

return 2.000xxxxxx
00 10 44 E3 1E FF 2F E1

return 131072.070218983
00 11 44 E3 1E FF 2F E1

return 8.5c
00 12 44 E3 1E FF 2F E1

Honestly, I still don't understand how the hex code "00 11 44 E3 1E FF 2F E1" translates to "return 131072.070218983". I understand the return part, but not the number part. Will try to dig deeper. Thanks for your help!
@timmyyy19977 then change help to solved
 
Status
Not open for further replies.