I am trying to alter a jnz in IDA but it wont allow me. It says:

Cannot Reach Destination From current location

Any reason for this problem ?

Edit: The Program is Trying to CreateFileA. It Then makes a cmp between eax and 0FFFFFFFFh( i am guessing it returns -1 if file doesnt exist ). More Information jnz short FileExist ; Jump if Not Zero (ZF=0) Changing that to jmp short FileExist

Edit 2: So I changed the hex code for the jmp and it works but when i do it by assembly it doesnt , still yet to find out why.

  • Tell more about the context, your explanation is too short. – perror May 30 '14 at 7:18
  • 1
    The most common opcode for jnz is 0x75, which takes one parameter in the range -128 .. +127. Your new jnz destination is probably outside that range. There is another jnz (opcode 0x0f 0x85) that has a longer parameter, but if your current instruction is the 0x75, you have only 2 bytes, and you don't have space for the longer one. See, for example, mathemainzel.info/files/x86asmref.html#jne – Guntram Blohm May 30 '14 at 7:40
  • @GuntramBlohm: after the question has been edited, it seems the OP is trying to change a jnz to jmp without altering the destination, and it works fine when done manually, so the issue sounds more like a flaw in IDA's assembly generation. – DCoder May 30 '14 at 15:39
  • This doesn't answer your question, but it does solve your problem. Why not change the comparison to something like xor eax, eax? (And fill in any extra bytes with nop)That will set your flags appropriately and it's much easier than computing jump targets. – bad_decoy Jun 1 '14 at 12:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.