CryptGenRandom is deprecated by Microsoft and may be removed in future releases. They recommend to use the next generation API instead. See https://learn.microsoft.com/en-us/windows/win32/seccng/cng-portal for more details. Also, refactor the random functions to return error codes rather than aborting the program if they fail.