Calculation Method of jmp offset address

Source: Internet
Author: User

Calculation of jmp distance of E9: distance = destination address-(current address + 5) (plus 5 is because the JMP command occupies a total of 5 words, actually the destination address minus the end address of the JMP command, that is, the current address + 5
If the target address is f1e0b63e
The current address is 8093c6d8.
Distance = f1e0b63e-8093c6d8-5 = 714cef61
Jmp is
Current address current encoding assembly instruction
8093c6d8 e961ef4c71 (written backwards) jmp f1e0b63e

Encoded in C ++

  1. # Include "stdafx. h"
  2. # Include <iostream>
  3. Using namespace std;
  4. Int _ tmain (int argc, _ TCHAR * argv [])
  5. {
  6. Unsigned long a = 0xf1e0b63e;
  7. Unsigned long B = 0x8093c6d8;
  8. Unsigned c = a-b-5;
  9. Int d [4];
  10. For (INT I = 0; I <4; I ++)
  11. {
  12. D [I] = 0;
  13. D [I] + = C % 16;
  14. C = C/16;
  15. D [I] + = C % 16*16;
  16. C = C/16;
  17. Cout
  18. }
  19. Return 0;
  20. }
  21. // E9 d [0] d [1] d [2] d [3] Is e961ef4c71

If the destination address is smaller than the current address, the distance is-5

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.