This change updates phlib with broader native API compatibility shims, new CRC32/CRC32C tables, and safer utility helpers. It also fixes a number of synchronization, formatting, environment, and process-creation edge cases, adds correlation-vector support, hardens SID conversion and image-resource loading, and cleans up several Windows compatibility fixes across the library.
Improve Rich header validation/robustness:
- Simplified/decrypted rich header loop and compute buffer end pointer; use PhMappedImageProbe and SEH to guard mapped memory accesses.
- Validate richHeaderLength alignment to PRODITEM size and derive entry count from length instead of scanning.
- Reworked hash handling to use a length variable returned by PhFinalHash and pass the actual hash length to PhBufferToHexString.
- Replace ProdIdHeader number/count assignment to use the finalized entry array count/items.
- Implement full Rich checksum computation (DOS header + entries) with rotations and per-entry contribution, validate against stored key and return STATUS_INVALID_IMAGE_HASH on mismatch.
- Make Rich total-length vs NT headers offset non-fatal (keep an assert in DEBUG builds) and fall back to NT headers offset as boundary.
- Minor bounds-check and formatting fixes in dynamic relocations and other hash output conversions.
These changes improve safety against malformed or tampered PE Rich headers and reduce crash potential when parsing mapped images.
Some images (GOG GalaxyClient.exe) have LoadConfig directory smaller than size
provided inside `IMAGE_LOAD_CONFIG_DIRECTORY` structure.
We need to make sure to to access only valid part of buffer returned by
`PhGetRemoteMappedImageDirectoryEntry`.
Found using ApplicationVerifier.