(((unsigned long *)(0x483069E0))[0] | 0x00000003)
=
(unsigned long *0x483069E0)[0] | 0x00000003.
Also could someone explain to me the concatenation of the array? I have not seen that syntax before.
Thanks in advance
Printable View
(((unsigned long *)(0x483069E0))[0] | 0x00000003)
=
(unsigned long *0x483069E0)[0] | 0x00000003.
Also could someone explain to me the concatenation of the array? I have not seen that syntax before.
Thanks in advance
> Are these expressions = ?
Compile them, run them, find out.
And no, they're not the same.
> Also could someone explain to me the concatenation of the array?
I've no idea what you're talking about. There is no standard way to append one array onto the end of another array.
The only exception being where you have arrays of char terminated by \0, in which case there is 'strcat'
The person is making a pointer to a long, then dereferencing it with an offset of 0 ( [0] ), giving you the long at that the pointer points to.
In the first expression, it appears as though they're taking that magical number, casting it to an unsigned long pointer, then dereferencing it at the head, then bitwise or'ing that with 3.
In essence, say there's an array of longs which starts at addr 0x483069E0 - ending unknown (or known somewhere else). It takes that address, casts it to an unsigned long pointer (probably to satisfy a compiler), then goes to the value at that address, and bitwise OR's it with 3.
If I'm understanding it correctly, another way of doing the first would be:Code:0x483069E0 --> 0
--> 0
--> 0
AFTER
0x483069E0 --> 3
--> 0
--> 0
Note: The value isn't saved anywhere, it's non-destructive, this has to go as a function arg or be returned to something or something.Code:unsigned long* tmpPtr = 0x483069E0;
*tmpPtr | 3;
Which looks much better, but doesn't spend time on the stack, allocating space for the tmpPtr variable, could be important in a time critical environment...but time is typically not THAT important. Even on embedded systems the latter should work without issue.
The second doesn't appear to be a valid expression. Without parenthesis around the "unsigned long*" or "unsigned long" - it's a type specification, which needs to be followed by a name. Not quite sure what that second one is getting at.