Basically I'm just trying to copy a cpu register by injecting bytecode into wow.exe
wow.exe
0x00554433 mov eax, [ecx + 100] I want to copy ecx
Pseudocode
1.Create code cave (which copies register, re-writes original wow.exe code back into 00554433, and jumps back to 00554433 to continue execution as normal)
2. over_write wow.00554433 with a JMP command to our codecave
3. (code-cave eventually gets run by wow.exe)
4. _myVariable = ReadInt(codeCave.returnValueLocation)
But I don't thinking I'm doing the asm correctly...more specificly, using [ ]
_codeCaveLoc = VirtualAlloc(200)
_rtnValueLoc = _codeCaveLoc + 100 //stores register here
_stackLoc = _codeCaveLoc + 125 //stores orig wow code here (..only 8 bytes)
.AppendLine("push eax")
.AppendLine("push ebx")
'copy our rtnValueLoc to a register
.AppendLine("mov eax, 0x" & (_rtnValueLoc.ToInt32 + registerOffset).ToString("X"))
'copy value stored at register eax into the value at rtnValueLoc
.AppendLine("mov [eax], " & registerAsString) //in my case, passing in ecx at the moment.
'clean-up
.AppendLine("mov eax, 0x" & sourceLoc.ToString("X"))
.AppendLine("mov ebx, 0x" & _stackLoc.ToString("X"))
.AppendLine("mov [eax], ebx")
.AppendLine("add ebx, 0x4")
.AppendLine("add eax, 0x4")
.AppendLine("mov [eax], ebx")
.AppendLine("pop ebx")
.AppendLine("pop eax")
//.AppendLine("jmp sourceLoc")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
set break point right before .ExecuteCodeCave
actual asm (w/ no variable names) comes out to..
push eax
push ebx
mov eax, 0xC4800AF 'rtnValueLoc
mov [eax] ecx
mov eax, 0x5B534B 'wow.exeLoc
mov ebx, 0xC480064 'wow.exe_backup_orig
mov [eax], ebx
add ebx, 0x4
add eax, 0x4
mov [eax], ebx
pop ebx
pop eax
I keep crashing wow. I think it's the 3rd line under 'clean-up..
Any thoughts would be much appreciated. If i can't figure it out, I'll probably end up making a super basic C++ app and trying to inject to it.
I know its fugly..like the alloc(200) instead of alloc(needed_size) etc etc...work in progress: first time working with assembly.
The problem isn't Read/WriteProcess..tested..both work fine...I think the trouble is with my use of MOV, specifically in the clean-up section.
ps. I know I'm not using IntPtr correctly. .ToInt32 lol. I'll make it x64 when i have an x64 machine..
Thanks.