c - Convert pointer address to char array and make it little-endian -
in c, if have a:
char *ptr;
and if, let's say, ptr
points address 0xbfc70753
, how can convert array of char end array of char addr
contain:
char addr[4] = "\x53\x07\xc7\xbf"
that is, convert address pointed @ ptr
array of char , make little-endian.
(kali linux, 32 bit, intel)
if on little-endian machine, nice way it:
void foo(uint32_t* adr, uint32_t value){*adr = value;} int main(int argc, char** argc) { char *ptr = ... char adr[4]; foo((uint32_t*)adr,(uint32_t)ptr); }
the idea 32-bit unsigned integers in little-endian, when copy them char array, each byte goes place want.
Comments
Post a Comment