Use mask and flags to check if value data is resident
Use mask and flags to check if value data is resident, rather than weird arithmetic operations modulo 0x80000000.
for example: https://github.com/williballenthin/python-registry/blob/master/Registry/RegistryParse.py#L762
I just set a bool, dataIsResident, in my project based on the high bit being set. much easier vs >= stuff
0x80000000 is used in multiple places and should probably be declared as an const instead? In some places maybe decoding as an int instead of dword and then checking for negative would be preferable?
best IMO to convert it to 32 char binary string and check the left most flag. if 1, then its resident. Thats the point of the thing. checking > than 0x80000000 just makes it muddy
bool dataIsResident = Convert.ToString(_dataLengthInternal, 2).PadLeft(32, '0').StartsWith("1");
Involving strings is an terrible idea when working with bits/flags.
instead check for the bit (psuedo/C mix)
Const DWORD_SIGN_MASK = 0x80000000
Const DWORD_VALUE_MASK = 0xefffffff
....
dataIsResident = _dataLengthInternal & DWORD_SIGN_MASK == DWORD_SIGN_MASK
dataLength = _dataLengthInternal & DWORD_VALUE_MASK
Using absolute value of signed ints in some places where the flag is not used (an example of this is cell size) would be clerear to a reader that does not understand binary operations.
swapped out string stuff for bitwise ANDING. thanks!