• Welcome to Valhalla Legends Archive.
 

Copy Memory

Started by Nub_1, November 20, 2003, 08:32 PM

Previous topic - Next topic

Nub_1

I'v been seeing the CopyMemory() a lot resently in source code, and I don't understand exactly what it's point is. can anyone tell me what exactly the point of CopyMemory is?

Banana fanna fo fanna

Battle.net's binary interface uses little-endian numbers, and so does Intel's CPU. By copying the representation of the integer into a buffer, you effectively get it in little-endian with no work.

Nub_1

#2
Little-endian numbers? what are those?

iago

#3
1, in four bytes, looks like this:
Little-endian:
01 00 00 00
Big-endian
00 00 00 01

256 (0x100) in 4 bytes
Little-endian
00 01 00 00
Big-endian
00 00 01 00

123456 (0x1e240) in 4 bytes:
Little-endian:
40 e2 01 00
Bit-endian:
00 01 e2 40


There's good reasons for using little-endian, even though it's counter-intuitive, but they are irrelevant here.

Copy memory is just what it says, it copies memory from one place to another.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*