Index: lib/Support/Windows/Process.inc =================================================================== --- lib/Support/Windows/Process.inc +++ lib/Support/Windows/Process.inc @@ -417,16 +417,23 @@ return 0; } +// Include GetLastError() in a fatal error message. +static void ReportLastErrorFatal(const char *msg) { + std::string ErrMsg; + MakeErrMsg(&ErrMsg, msg); + report_fatal_error(ErrMsg); +} + unsigned Process::GetRandomNumber() { HCRYPTPROV HCPC; if (!::CryptAcquireContextW(&HCPC, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) - report_fatal_error("Could not acquire a cryptographic context"); + ReportLastErrorFatal("Could not acquire a cryptographic context"); ScopedCryptContext CryptoProvider(HCPC); unsigned Ret; if (!::CryptGenRandom(CryptoProvider, sizeof(Ret), reinterpret_cast(&Ret))) - report_fatal_error("Could not generate a random number"); + ReportLastErrorFatal("Could not generate a random number"); return Ret; }