Close the implicitely opened registry key.
[openssl.git] / crypto / rand / rand_win.c
index a688467e022e8b55a366aae996a3cf58624aeb94..242febe270ba40320b138f6cdfa0bda9269755c0 100644 (file)
@@ -287,9 +287,18 @@ int RAND_poll(void)
                        {
                         /* For entropy count assume only least significant
                         * byte of each DWORD is random.
-                         */
+                        */
                        RAND_add(&length, sizeof(length), 0);
                        RAND_add(buf, length, length / 4.0);
+
+                       /* Close the Registry Key to allow Windows to cleanup/close
+                        * the open handle
+                        * Note: The 'HKEY_PERFORMANCE_DATA' key is implicitly opened
+                        *       when the RegQueryValueEx above is done.  However, if
+                        *       it is not explicitly closed, it can cause disk
+                        *       partition manipulation problems.
+                        */
+                       RegCloseKey(HKEY_PERFORMANCE_DATA);
                        }
                if (buf)
                        free(buf);
@@ -316,7 +325,7 @@ int RAND_poll(void)
                        if (gen(hProvider, sizeof(buf), buf) != 0)
                                {
                                RAND_add(buf, sizeof(buf), 0);
-#ifdef DEBUG
+#if 0
                                printf("randomness from PROV_RSA_FULL\n");
 #endif
                                }
@@ -329,7 +338,7 @@ int RAND_poll(void)
                        if (gen(hProvider, sizeof(buf), buf) != 0)
                                {
                                RAND_add(buf, sizeof(buf), sizeof(buf));
-#ifdef DEBUG
+#if 0
                                printf("randomness from PROV_INTEL_SEC\n");
 #endif
                                }
@@ -515,7 +524,7 @@ int RAND_poll(void)
                FreeLibrary(kernel);
                }
 
-#ifdef DEBUG
+#if 0
        printf("Exiting RAND_poll\n");
 #endif
 
@@ -582,7 +591,8 @@ static void readtimer(void)
        if (have_tsc) {
          __try {
            __asm {
-             rdtsc
+             _emit 0x0f
+             _emit 0x31
              mov cyclecount, eax
              }
            RAND_add(&cyclecount, sizeof(cyclecount), 1);