|
28 | 28 |
|
29 | 29 | #ifdef WIN32 |
30 | 30 | #include <windows.h> |
31 | | -#include <winreg.h> |
32 | 31 | #else |
33 | 32 | #include <fcntl.h> |
34 | 33 | #include <netinet/in.h> |
@@ -64,45 +63,6 @@ extern char** environ; // NOLINT(readability-redundant-declaration): Necessary o |
64 | 63 |
|
65 | 64 | namespace { |
66 | 65 |
|
67 | | -void RandAddSeedPerfmon(CSHA512& hasher) |
68 | | -{ |
69 | | -#ifdef WIN32 |
70 | | - // Seed with the entire set of perfmon data |
71 | | - |
72 | | - // This can take up to 2 seconds, so only do it every 10 minutes. |
73 | | - // Initialize last_perfmon to 0 seconds, we don't skip the first call. |
74 | | - static std::atomic<SteadyClock::time_point> last_perfmon{SteadyClock::time_point{0s}}; |
75 | | - auto last_time = last_perfmon.load(); |
76 | | - auto current_time = SteadyClock::now(); |
77 | | - if (current_time < last_time + 10min) return; |
78 | | - last_perfmon = current_time; |
79 | | - |
80 | | - std::vector<unsigned char> vData(250000, 0); |
81 | | - long ret = 0; |
82 | | - unsigned long nSize = 0; |
83 | | - const size_t nMaxSize = 10000000; // Bail out at more than 10MB of performance data |
84 | | - while (true) { |
85 | | - nSize = vData.size(); |
86 | | - ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", nullptr, nullptr, vData.data(), &nSize); |
87 | | - if (ret != ERROR_MORE_DATA || vData.size() >= nMaxSize) |
88 | | - break; |
89 | | - vData.resize(std::min((vData.size() * 3) / 2, nMaxSize)); // Grow size of buffer exponentially |
90 | | - } |
91 | | - RegCloseKey(HKEY_PERFORMANCE_DATA); |
92 | | - if (ret == ERROR_SUCCESS) { |
93 | | - hasher.Write(vData.data(), nSize); |
94 | | - memory_cleanse(vData.data(), nSize); |
95 | | - } else { |
96 | | - // Performance data is only a best-effort attempt at improving the |
97 | | - // situation when the OS randomness (and other sources) aren't |
98 | | - // adequate. As a result, failure to read it is isn't considered critical, |
99 | | - // so we don't call RandFailure(). |
100 | | - // TODO: Add logging when the logger is made functional before global |
101 | | - // constructors have been invoked. |
102 | | - } |
103 | | -#endif |
104 | | -} |
105 | | - |
106 | 66 | /** Helper to easily feed data into a CSHA512. |
107 | 67 | * |
108 | 68 | * Note that this does not serialize the passed object (like stream.h's << operators do). |
@@ -227,8 +187,6 @@ void AddAllCPUID(CSHA512& hasher) |
227 | 187 |
|
228 | 188 | void RandAddDynamicEnv(CSHA512& hasher) |
229 | 189 | { |
230 | | - RandAddSeedPerfmon(hasher); |
231 | | - |
232 | 190 | // Various clocks |
233 | 191 | #ifdef WIN32 |
234 | 192 | FILETIME ftime; |
|
0 commit comments