Use ULONG_PTR instead of ULONG when doing pointer arithmetics.