ı could'nt understand

if((((char*)&n64Offset)[chOffsetSz-1])&0x80)
for(int i=sizeof(LONGLONG)-1;i>(chOffsetSz-1);i--)
((char*)&n64Offset)[i] = 0xff;


what does it mean please help adn answer with detailed explanation
closed account (zb0S216C)
spy man wrote:
if((((char*)&n64Offset)[chOffsetSz-1])&0x80)

The address of n64Offset is converted into a pointer to a character (char*). The address is then offset by chOffsetSz - 1. The resulting value is tested to see if the bits that correspond to 0x80 are set. If they are, the if statement evaluates to true.

spy man wrote:
1
2
for(int i=sizeof(LONGLONG)-1;i>(chOffsetSz-1);i--)
((char*)&n64Offset)[i] = 0xff;

This is a for loop. i is pushed onto the stack, and initialised with its own length - 1. While the value of i is greater than the value of chOffsetSz - 1, the address of n64Offset is once again converted to a pointer to a character. The resulting address is offset by the value of i, and the bits of the resulting element are set to 1. i is then reduced by 1.

Wazzak
Last edited on
chLenSz = chLenOffSz & 0x0F;
chOffsetSz = (chLenOffSz & 0xF0) >> 4;

what does it mean please answer
closed account (zb0S216C)
spy man wrote:
chLenSz = chLenOffSz & 0x0F;
chLenOffSz is tested to see if the bits that correspond to 0x0F (0000 1111) are set. If they are, chLenSz is assigned to the character equivalent to the Boolean expression returned by the test.

spy man wrote:
chOffsetSz = (chLenOffSz & 0xF0) >> 4;
chLenOffSz is tested to see if the bits that correspond to 0xF0 (1111 0000) are set. If they are, the test returns true. The Boolean expression returned by the test is shifted 4 places to the right. The result of the shift is assigned to chOffsetSz.

Wazzak
When you dont understand a piece of code, you should first space it out nicley, this code snippet seems to make very poor use of whitespace.
1
2
3
4
5
6
7
if((((char*) & n64Offset)[chOffsetSz-1]) & 0x80)
{
    for(int i = sizeof(LONGLONG) -1; i > (chOffsetSz - 1); i --)
    {
        ((char*) & n64Offset)[i] = 0xff;
    }
}
The braces are not needed in this code snippet, but I always use them, because it makes the code easier to scan over
When you dont understand a piece of code, you should first space it out nicley, this code snippet seems to make very poor use of whitespace.



if((((char*) & n64Offset)[chOffsetSz-1]) & 0x80)
{
for(int i = sizeof(LONGLONG) -1; i > (chOffsetSz - 1); i --)
{
((char*) & n64Offset)[i] = 0xff;
}
}

The braces are not needed in this code snippet, but I always use them, because it makes the code easier to scan over


No, this isn't like that , Framework understood what ı mean but thanks for your help
Last edited on
Topic archived. No new replies allowed.