#include "llvm/Support/Endian.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Process.h"
#include <cctype>
#include <cstdio>
#include <cstring>
// needed if the randomly chosen path already exists.
SmallVector<wchar_t, 128> random_path_utf16;
- // Get a Crypto Provider for CryptGenRandom.
- HCRYPTPROV HCPC;
- if (!::CryptAcquireContextW(&HCPC,
- NULL,
- NULL,
- PROV_RSA_FULL,
- CRYPT_VERIFYCONTEXT))
- return windows_error(::GetLastError());
- ScopedCryptContext CryptoProvider(HCPC);
-
retry_random_path:
random_path_utf16.set_size(0);
for (SmallVectorImpl<wchar_t>::const_iterator i = model_utf16.begin(),
e = model_utf16.end();
i != e; ++i) {
if (*i == L'%') {
- BYTE val = 0;
- if (!::CryptGenRandom(CryptoProvider, 1, &val))
- return windows_error(::GetLastError());
+ unsigned val = sys::Process::GetRandomNumber();
random_path_utf16.push_back(L"0123456789abcdef"[val & 15]);
}
else