Disable the net statistics gathering code, since different compilers
[openssl.git] / crypto / rand / rand_win.c
index 5ef197341f0f0c9974bd8b7f7f7f69eaa2b87a8e..2a4f76781305036e847ca96217abc211b0a79656 100644 (file)
@@ -171,9 +171,13 @@ typedef BOOL (WINAPI *MODULE32)(HANDLE, LPMODULEENTRY32);
 
 #include <lmcons.h>
 #include <lmstats.h>
+#if 0 /* Some compilers use LMSTR, others (VC6, for example) use LPTSTR.
+       * This part is disabled until a fix is found.
+       */
 typedef NET_API_STATUS (NET_API_FUNCTION * NETSTATGET)
         (LMSTR, LMSTR, DWORD, DWORD, LPBYTE*);
 typedef NET_API_STATUS (NET_API_FUNCTION * NETFREE)(LPBYTE);
+#endif
 
 int RAND_poll(void)
 {
@@ -184,18 +188,26 @@ int RAND_poll(void)
        HWND h;
 
        HMODULE advapi, kernel, user, netapi;
-       CRYPTACQUIRECONTEXT acquire;
-       CRYPTGENRANDOM gen;
-       CRYPTRELEASECONTEXT release;
-       NETSTATGET netstatget;
-       NETFREE netfree;
+       CRYPTACQUIRECONTEXT acquire = 0;
+       CRYPTGENRANDOM gen = 0;
+       CRYPTRELEASECONTEXT release = 0;
+#if 0 /* This part is disabled until a fix for the problem with the
+       * definition of NETSTATGET is found.
+       */
+       NETSTATGET netstatget = 0;
+       NETFREE netfree = 0;
+#endif
 
        /* load functions dynamically - not available on all systems */
-       advapi = GetModuleHandle("ADVAPI32.DLL");
-       kernel = GetModuleHandle("KERNEL32.DLL");
-       user = GetModuleHandle("USER32.DLL");
-       netapi = GetModuleHandle("NETAPI32.DLL");
-
+       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");
@@ -218,6 +230,10 @@ int RAND_poll(void)
                        }
                }
 
+       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 */
@@ -245,7 +261,7 @@ int RAND_poll(void)
                RAND_add(&length, sizeof(length), 0);
                RAND_add(buf, length, 0);
                }
-       if ( buf )
+       if (buf)
                free(buf);
        }
 
@@ -289,6 +305,9 @@ int RAND_poll(void)
                        }
                }
 
+        if (advapi)
+               FreeLibrary(advapi);
+
        /* timer data */
        readtimer();
        
@@ -347,6 +366,8 @@ int RAND_poll(void)
                        w = queue(QS_ALLEVENTS);
                        RAND_add(&w, sizeof(w), 0);
                        }
+
+               FreeLibrary(user);
                }
 
        /* Toolhelp32 snapshot: enumerate processes, threads, modules and heap
@@ -443,6 +464,8 @@ int RAND_poll(void)
                        
                        CloseHandle(handle);
                        }
+
+               FreeLibrary(kernel);
                }
 
 #ifdef DEBUG