Skip to content

Commit

Permalink
Fixes: I think it works now?!
Browse files Browse the repository at this point in the history
  • Loading branch information
JayFoxRox committed Nov 8, 2018
1 parent f4b4d0f commit 6f8e1f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions emulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ Address CreateHlt() {

// Fill guest_registers
"mov guest_registers, %%esp\n"
"add $32, %%esp\n"
"pusha\n"

// Move to host space
Expand All @@ -395,15 +396,15 @@ Address CreateHlt() {

*code++ = 0xc7; // mov code_address, [guest_eip]
*code++ = 0x05;
*(uint32_t*)code = &host_eip;
*(uint32_t*)code = (uintptr_t)&host_eip;
code += 4;
*(uint32_t*)code = code_address + 1;
code += 4;

//FIXME: Use another ESP
//FIXME: Keep copy of EIP
*code++ = 0xE8; // call __return_to_host
*(uint32_t*)code = __return_to_host - (uintptr_t)code - 4; //((uintptr_t)__return_to_host - (uintptr_t)code) - 5;
*code++ = 0xE9; // jmp __return_to_host
*(uint32_t*)code = (uintptr_t)__return_to_host - (uintptr_t)code - 4;
code += 4;
#else
Address code_address = Allocate(2);
Expand Down
3 changes: 1 addition & 2 deletions uc_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,8 @@ uc_err uc_emu_start(uc_engine *uc, uint64_t begin, uint64_t until, uint64_t time
"pusha\n"
"mov %%esp, host_esp\n"

// Load all registers, except ESP
// Load all registers
"mov guest_registers, %%esp\n"
"add $32, %%esp\n"
"popa\n"
"mov guest_registers_esp, %%esp\n"
//FIXME: Fixup ESP too
Expand Down

0 comments on commit 6f8e1f0

Please sign in to comment.