-2

I want to convert the following code to C++.

        .globl _start
_start:
.set DLLLoaderHook, 0x823326A8
.set LoadLibraryA, 0x82332B10
.set DLLLoaderString, 0x82000870

.long DLLLoaderString
.long (9f-0f)/4
0:
    .string "game:\\Tesseract.dll"
    .align 1
9:

.long DLLLoaderHook
.long (9f-0f)/4
0:
    lis %r11, DLLLoaderString@h
    ori %r3, %r11, DLLLoaderString@l
    bl (LoadLibraryA - (DLLLoaderHook + 0x8))
9:
.long 0xFFFFFFFF

I know that I need to understand what each line of this assembly code does before I can begin to think about converting it to C++. Currently I have little to no understanding of this code. I'm not asking anyone to convert this to c++, I am asking what each line of this code does so I can gain the understanding to convert it myself. For clarification, I believe this is PowerPC Assembly. I did a fair amount of googling before I came here to ask about this. I was hoping google would help me understand what I needed, but I don't feel like I understand it.

1 Answers1

0
lis %r11, DLLLoaderString@h
ori %r3, %r11, DLLLoaderString@l

These two above are loading %r3 with a pointer to DLLLoaderString. DLLLoaderString is set to "game:\Tesseract.dll"

bl (LoadLibraryA - (DLLLoaderHook + 0x8))

This above is branching and linking (ie. a function call) to some location. It looks like the location is LoadLibraryA.

%r3 is defined in the PowerPC ISA as the first parameter to a function. So..

Looks like it's calling the LoadLibraryA function with a pointer to string "game:\Tesseract.dll" as the first argument (first argument is %r3). ie

char *DLLLoaderString = "game:\\Tesseract.dll";
LoadLibraryA(DLLLoaderString);
Mikey
  • 167
  • 4