29 Jan
2023
29 Jan
'23
4:19 p.m.
Jinoh Kang (@iamahuman) commented about dlls/ntdll/rtl.c:
- result = result + (~result & 1); - } else { - result = (result + (result & 1)) & MAXLONG; - } /* if */ + product = (ULONGLONG)*seed * 0x7fffffed + 0x7fffffc3; + + /* + * The following is equivalent to: + * + * result = (product & ((1ui64 << 63) - 1)) % ((1u << 31) - 1); + * + * Since product is never greater than 2^63, it is the same as: + * + * result = product % ((1u << 31) - 1); + * + * This is due to the following identity:
* The folllowing algorithm relies on the following identity:
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/821#note_22259