+ advapi = LoadLibrary("ADVAPI32.DLL");
+ kernel = LoadLibrary("KERNEL32.DLL");
+ user = LoadLibrary("USER32.DLL");
+ netapi = LoadLibrary("NETAPI32.DLL");
+
+#if 0 /* This part is disabled until a fix for the problem with the
+ * definition of NETSTATGET is found. Also, note that VC6 doesn't
+ * understand strings starting with L".
+ */
+ if (netapi)
+ {
+ netstatget = (NETSTATGET) GetProcAddress(netapi,"NetStatisticsGet");
+ netfree = (NETFREE) GetProcAddress(netapi,"NetApiBufferFree");
+ }
+
+ if (netstatget && netfree)
+ {
+ LPBYTE outbuf;
+ /* NetStatisticsGet() is a Unicode only function */
+ if (netstatget(NULL, L"LanmanWorkstation", 0, 0, &outbuf) == 0)
+ {
+ RAND_add(outbuf, sizeof(STAT_WORKSTATION_0), 0);
+ netfree(outbuf);
+ }
+ if (netstatget(NULL, L"LanmanServer", 0, 0, &outbuf) == 0)
+ {
+ RAND_add(outbuf, sizeof(STAT_SERVER_0), 0);
+ netfree(outbuf);
+ }
+ }
+
+ if (netapi)
+ FreeLibrary(netapi);
+#endif
+
+ /* Read Performance Statistics from NT/2000 registry */
+ /* The size of the performance data can vary from call to call */
+ /* so we must guess the size of the buffer to use and increase */
+ /* its size if we get an ERROR_MORE_DATA return instead of */
+ /* ERROR_SUCCESS. */
+ {
+ LONG rc=ERROR_MORE_DATA;
+ char * buf=NULL;
+ DWORD bufsz=0;
+ DWORD length;
+
+ while (rc == ERROR_MORE_DATA)
+ {
+ buf = realloc(buf,bufsz+8192);
+ if (!buf)
+ break;
+ bufsz += 8192;
+
+ length = bufsz;
+ rc = RegQueryValueEx(HKEY_PERFORMANCE_DATA, "Global",
+ NULL, NULL, buf, &length);
+ }
+ if (rc == ERROR_SUCCESS)
+ {
+ RAND_add(&length, sizeof(length), 0);
+ RAND_add(buf, length, 0);
+ }
+ if (buf)
+ free(buf);
+ }