I am trying to figure out how to solve the following. I have two ARM .SO libraries (32 bit and 64 bit) with the same functions. There is a method which returns const char* , it looks like this in ARM32:
.text:0006F264 PUSH {LR}
.text:0006F266 SUB SP, SP, #0xC
.text:0006F268 STR R0, [SP,#0x10+var_C]
.text:0006F26A LDR R3, =(dword_9A030 - 0x6F270)
.text:0006F26C ADD R3, PC ; dword_9A030
.text:0006F26E LDR.W R3, [R3,#(dword_9A250 - 0x9A030)]
.text:0006F272 LDR R0, [SP,#0x10+var_C]
.text:0006F274 BLX R3
.text:0006F276 MOV R3, R0
.text:0006F278 NOP
.text:0006F27A MOV R0, R3
.text:0006F27C ADD SP, SP, #0xC
.text:0006F27E LDR.W PC, [SP+4+var_4],#4
And here in ARM64:
.text:0000000000079CAC SUB SP, SP, #0x20
.text:0000000000079CB0 STR X30, [SP,#0x20+var_20]
.text:0000000000079CB4 STR X0, [SP,#0x20+var_8]
.text:0000000000079CB8 ADRP X0, #dword_DE080@PAGE
.text:0000000000079CBC ADD X0, X0, #dword_DE080@PAGEOFF
.text:0000000000079CC0 LDR X1, [X0,#(qword_DE4C0 - 0xDE080)]
.text:0000000000079CC4 LDR X0, [SP,#0x20+var_8]
.text:0000000000079CC8 BLR X1
.text:0000000000079CCC NOP
.text:0000000000079CD0 LDR X30, [SP,#0x20+var_20]
.text:0000000000079CD4 ADD SP, SP, #0x20
.text:0000000000079CD8 RET
This is the ASM code of a function
const char* GetStatus ( const DetailsHandle obj )
This function can return one of 3 string values "abcd", "kowewqzb", or "jvbrnbfghert" (as char*). I want it to return always "kowewqzb" regardless of the call happening within this function, which leads to an entire bunch of dynamically loaded functions. So how could I:
1) write the code for making it always return the address of "kowewqzb" (which needs to be put somewhere into memory first) and don't do any other calls (so basically the entire instruction set besides of SP manipulations could be replaced with other instructions
2) if there is not enough space for making it work directly there, how could I inject some new code without destroying existing code, are there any suitable places for that in the .SO library? E.g. putting BL to some unused areas (how to get them?) and having there further code pieces.
Ideally if this could be outlined for both ARM32 and ARM64 I'd be more than happy. Huge thanks in advance!!!