How to replace a store of EAX with a store of an immediate constant?

100 Views Asked by At

From my previous question, I asked how to change the nation code to what I needed it to be. I explored in the disassembly more and I found out exactly where I needed this change to be. In other files, the code seems to be:

mov ds:dword_73A9C8, 1

Where the file I'm trying to edit has it like

mov ds:dword_73A9C8, eax

I've tried to edit the file in IDA by hex to match it to the first line of code, however, the function, even after extending its length, seems to break each time I edit it.

The question I have is how can I change it from having eax being moved to having 1 being moved without breaking the function

1

There are 1 best solutions below

0
Sep Roland On
sub_4A2B60 proc near
  arg_0= dword ptr 4
  mov eax, [esp+arg_0]
  mov ds:dword_73A9C8, eax
  retn
sub_4A2B60 endp 

You could replace the 4 byte instruction mov eax, [esp + 4] with the sequence xor eax, eax inc eax nop that also has 4 bytes.

If 1 is what you want, then the return value in EAX should probably also be 1.