Skip to content

Instantly share code, notes, and snippets.

@borrrden
Created June 23, 2017 00:55
Show Gist options
  • Save borrrden/58b6b7e49053395e18684ed7f4971f32 to your computer and use it in GitHub Desktop.
Save borrrden/58b6b7e49053395e18684ed7f4971f32 to your computer and use it in GitHub Desktop.
Disassembly of C++ vs C# calling native method
# There is no direct call to the method (everything is looked up dynamically by the C# runtime) so I don't know where to start. I just copied a good sized chunk so it might be best to start from the bottom of it.
059B2282 vcvt.u32.f32 d17,d29,#1
059B2286 str r6,[r5,#0x2C]
059B2288 subs r0,r7,#6
059B228A lsls r0,r0,#0x17
059B228C push {r2-r4,r10,r11,lr}
059B2290 add r11,sp,#0x10
059B2294 str r0,[sp]
059B2296 mov r3,#0xBBE4
059B229A movt r3,#0x1B
059B229E ldr r3,[r3]
059B22A0 cmp r3,#0
059B22A2 beq 059B22AE
059B22A4 mov r3,#0x865D
059B22A8 movt r3,#0x688A
059B22AC blx r3
059B22AE nop
059B22B0 ldr r3,[sp]
059B22B2 ldr r0,[r3,#4]
059B22B4 mov r3,#0x6B8D
059B22B8 movt r3,#0x681D
059B22BC blx r3
059B22BE str r0,[sp,#4]
059B22C0 ldr r0,[sp,#4]
059B22C2 mov r3,#0x1631
059B22C6 movt r3,#0x6817
059B22CA blx r3
059B22CC nop
059B22CE ldr r3,[sp]
059B22D0 movs r2,#0
059B22D2 str r2,[r3,#4]
059B22D4 nop
059B22D6 pop {r2-r4,r10,r11,lr}
059B22DA bx lr
059B22DC movs r0,r5
059B22DE movs r0,#0x90
059B22E0 movs r5,r4
059B22E2 lsls r0,r4,#0xF
059B22E4 adds r4,r5,#2
059B22E6 add r4,sp,#0x3FC
059B22E8 ldc2 p15,c15,[r12,#-0x3FC]
059B22EC subs r5,r7,#4
059B22EE str r6,[r5,#0x2C]
059B22F0 movs r0,#0xE8
059B22F2 lsls r0,r0,#0x17
059B22F4 push {r4-r11,lr}
059B22F8 sub sp,sp,#0x24
059B22FA add r11,sp,#0x40
059B22FE str r12,[r11,#-0x24]
059B2302 add r4,sp,#4
059B2304 mov r5,#0xD01D
059B2308 movt r5,#0x1A
059B230C blx r5
059B230E ldr r1,[sp,#0x1C]
059B2310 ldr r1,[r1,#0x14]
059B2312 ldr r1,[r1]
059B2314 movs r4,#0
059B2316 str r4,[sp,#0xC]
059B2318 adr r4,059B2325
059B231C str r4,[sp,#0x14]
059B231E movs r4,#0
059B2320 strb r4,[r5,#8]
059B2322 blx r1
059B2324 movs r3,#1
059B2326 strb r3,[r5,#8]
059B2328 mov r3,#0xF2E0
059B232C movt r3,#0x68B8
059B2330 ldr r3,[r3]
059B2332 cmp r3,#0
059B2334 beq 059B2340
059B2336 mov r3,#0x1A75
059B233A movt r3,#0x687F
059B233E blx r3
059B2340 movs r3,#0
059B2342 str r3,[sp,#0x14]
059B2344 sxtb r3,r0
059B2346 cmp r3,#0
059B2348 bne 059B234E
059B234A movs r3,#0
059B234C b 059B2350
059B234E movs r3,#1
059B2350 mov r0,r3
059B2352 ldr r4,[sp,#8]
059B2354 str r4,[r5,#0xC]
059B2356 uxtb r0,r0
059B2358 add sp,sp,#0x24
059B235A pop {r4-r11,lr}
059B235E bx lr
059B2360 movs r6,r6
059B2362 movs r0,#0x90
059B2364 movs r2,r6
059B2366 lsls r0,r4,#0xF
059B2368 svc #9
059B236A lsrs r7,r7,#7
059B236C ldc2l p15,c15,059B276C
059B2370 subs r5,r7,#4
059B2372 str r6,[r5,#0x2C]
059B2374 movs r1,#4
059B2376 lsls r0,r0,#0x17
059B2378 push {r4,r5,r11,lr}
059B237C add r11,sp,#8
059B2380 mov r5,r0
059B2382 mov r0,#0xCB48
059B2386 movt r0,#0x572
059B238A mov r3,#0x586D
059B238E movt r3,#0x688A
059B2392 blx r3
059B2394 mov r4,r0
059B2396 mov r0,r4
059B2398 mov r3,#0x1885
059B239C movt r3,#0x59B
059B23A0 blx r3
059B23A2 mov r1,r4
059B23A4 adds r0,r5,#4
059B23A6 mov r3,#0x103D
059B23AA movt r3,#0x687F
059B23AE blx r3
059B23B0 mov r0,r5
059B23B2 mov r3,#0x15F9
059B23B6 movt r3,#0x59B
059B23BA blx r3
059B23BC pop {r4,r5,r11,lr}
059B23C0 bx lr
059B23C2 movs r0,r0
059B23C4 movs r5,r4
059B23C6 movs r0,#0x90
059B23C8 movs r2,r4
059B23CA lsls r0,r4,#0xF
059B23CC adds r0,r0,#0xA8
059B23CE add r0,sp,#0x3FC
059B23D0 ldc2 p15,c15,[r0,#-0x3FC]!
059B23D4 subs r5,r7,#4
059B23D6 str r6,[r5,#0x2C]
059B23D8 movs r1,#0xA0
059B23DA lsls r0,r0,#0x17
059B23DC push {r4-r11,lr}
059B23E0 sub sp,sp,#0x24
059B23E2 add r11,sp,#0x40
059B23E6 str r12,[r11,#-0x24]
059B23EA add r4,sp,#4
059B23EC mov r5,#0xD01D
059B23F0 movt r5,#0x1A
059B23F4 blx r5
059B23F6 ldr r3,[sp,#0x1C]
059B23F8 ldr r3,[r3,#0x14]
059B23FA ldr r3,[r3]
059B23FC movs r2,#0
059B23FE str r2,[sp,#0xC]
059B2400 adr r2,059B240D
059B2404 str r2,[sp,#0x14]
059B2406 movs r2,#0
059B2408 strb r2,[r5,#8]
059B240A blx r3
059B240C movs r3,#1
059B240E strb r3,[r5,#8]
059B2410 mov r3,#0xF2E0
059B2414 movt r3,#0x68B8
059B2418 ldr r3,[r3]
059B241A cmp r3,#0
059B241C beq 059B2428
059B241E mov r3,#0x1A75
059B2422 movt r3,#0x687F
059B2426 blx r3
059B2428 movs r3,#0
059B242A str r3,[sp,#0x14]
059B242C sxtb r3,r0
059B242E cmp r3,#0
059B2430 bne 059B2436
059B2432 movs r3,#0
059B2434 b 059B2438
059B2436 movs r3,#1
059B2438 mov r0,r3
059B243A ldr r4,[sp,#8]
059B243C str r4,[r5,#0xC]
059B243E uxtb r0,r0
059B2440 add sp,sp,#0x24
059B2442 pop {r4-r11,lr}
059B2446 bx lr
059B2448 movs r6,r6
059B244A movs r0,#0x90
059B244C movs r2,r6
059B244E lsls r0,r4,#0xF
059B2450 svc #9
059B2452 lsrs r7,r7,#7
059B2454 ldc2l p15,c15,059B2854
059B2458 subs r5,r7,#4
059B245A str r6,[r5,#0x2C]
059B245C movs r1,#0xC4
059B245E lsls r0,r0,#0x17
059B2460 push {r4-r11,lr}
059B2464 sub sp,sp,#0x34
059B2466 add r11,sp,#0x50
059B246A str r12,[r11,#-0x30]
059B246E add r4,sp,#8
059B2470 mov r5,#0xD01D
059B2474 movt r5,#0x1A
059B2478 blx r5
059B247A str r0,[sp,#0x24]
059B247C ldr r3,[sp,#0x20]
059B247E ldr r3,[r3,#0x14]
059B2480 ldr r3,[r3]
059B2482 mov r0,r1
059B2484 mov r1,r2
059B2486 movs r2,#0
059B2488 str r2,[sp,#0x10]
059B248A adr r2,059B2497
059B248E str r2,[sp,#0x18]
059B2490 movs r2,#0
059B2492 strb r2,[r5,#8]
059B2494 blx r3
# FLSliceResult FLEncoder_Finish(FLEncoder e, FLError *outError) {
67DC5D28 push {r0-r3}
67DC5D2A push {r7,r11,lr}
67DC5D2E add r11,sp,#4
67DC5D32 sub sp,sp,#0x7C
67DC5D34 mov r7,sp
67DC5D36 mvn r3,#1
67DC5D3A strd r3,r3,[r7,#0x70]
67DC5D3E movs r3,#0
67DC5D40 str r3,[r7]
# (method body)
67DC5E5C ldr r0,[r7,#0x38]
67DC5E5E add sp,sp,#0x7C
67DC5E60 pop {r7,r11}
67DC5E64 ldr pc,[sp],#0x14
00C23070 adds r2,r7,#8
00C23074 ldr r1,[r7,#enc]
00C23076 adds r0,r7,#0x38
00C2307A bl FLEncoder_Finish (0CAD54Ch)
00CAD54C mov r12,#0x2014
00CAD550 movt r12,#0xD4
00CAD554 ldr pc,[r12]
# 354: FLSliceResult FLEncoder_Finish(FLEncoder e, FLError *outError) {
68A15D28 push {r0-r3}
68A15D2A push {r7,r11,lr}
68A15D2E add r11,sp,#4
68A15D32 sub sp,sp,#0x7C
68A15D34 mov r7,sp
68A15D36 mvn r3,#1
68A15D3A strd r3,r3,[r7,#0x70]
68A15D3E movs r3,#0
68A15D40 str r3,[r7]
# (method body)
68A15E5C ldr r0,[r7,#0x38]
68A15E5E add sp,sp,#0x7C
68A15E60 pop {r7,r11}
68A15E64 ldr pc,[sp],#0x14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment