Sorry, but that's still buggy. Asking for page 4294967295 doesn't produce a NULL pointer, it produces a very big pointer. The function shouldn't try to paper over invalid arguments in any case, the caller should not call it with wrong pages (which I see you added).
The new logic is good. I still have style quips, and as pgrel cannot return negative values, it should be an u32. Maybe call it screenpixels instead?
- a space on both sides of +, -, ==, !=, and other such math operators
- a space between if and (
- a space after a cast
- moving the zoomedh line is not needed
edit: Above was for scroll2.patch, but also applies to v3.