I'm trying to convert an address to its equivalent in Little-Endians using the following code :
void AddressToLittleEndian(UINT32* adr, UINT32 value) { *adr = value; }
int main()
{
char *ptr = (char*) 0x41424344;
char Adr[4];
AddressToLittleEndian((UINT32*)Adr, (UINT32)ptr);
cout << Adr;
_getch();
return 0;
}
It works without error but gives me the following result :
DCBA╠╠╠╠╠╠╠╠DCBA╠╠╠╠<,ö∩╨≈Å
The desired result is DCBA
and I can somehow substring the first 4 character but actually I'm curious to know why this happens? It seems the junk code comes from the stack but I wonder what's wrong with this code that causes the stack leak ?