简体   繁体   中英

How to truncate an hex address?

So im writing an exploit and im getting an address such as 0x00708001e9ab0b10 which is obviously a 64 bit hex address. The address I need is 0x1e9ab0b10 to my calculations this is the upper 28 bits but some told me this is 48 bits and up so i dont know but i basically need to remove 0x0070800 the first 7 numbers of the hex string/number and give me something like 0x00000001e9ab0b10 which i would prefer!!! or something like 0x1e9ab0b10 mind you as well i need this done in JavaScript which is what my exploit is for

Not sure I properly understand what you want, but if that hex is a string, you can call String.prototype.slice(x) on it which returns a copy of the string with the first x characters removed.

    truncate = (hexString) => '0x0000000' + hexString.slice(9);

    truncate('0x00708001e9ab0b10');

如果实际数字没有任何影响,则将其转换为字符串并对其进行切片。

 console.log('0x'+0x00708001e9ab0b10.toString(16).slice(5))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM