The following C code:
typedef unsigned char byte;
byte temp[8] = {...};
unsigned long iONE = 0;
unsigned long iTWO = 0;
memcpy(((byte *)&iONE)+sizeof(unsigned long)-4, temp, 4);
memcpy(((byte *)&iTWO)+sizeof(unsigned long)-4, temp+4, 4);
What is the significance of +sizeof(unsigned long)-4?
Could the memcpy statements be written as:
memcpy((byte *)&iONE, temp, 4);
memcpy((byte *)&iTWO, temp+4, 4);
And is the Delphi conversion valid:
var
temp: array[0..7] of Byte;
iONE: Cardinal;
iTWO: Cardinal;
begin
temp := ...;
iONE := 0;
iTWO := 0;
CopyMemory(iOne, temp[0], SizeOf(Cardinal));
CopyMemory(iTwo, temp[4], SizeOf(Cardinal));
end;
sizeof(unsigned long)is greater than 4 octets (think 8, then do the math). You may also consider the ramifications of running this on a big-vs-little endian system.sizeof(unsigned long), that at least I am not able to decipher in purpose.