提交 362f2b69 编写于 作者: R Richard Levitte

Jeffrey Altman reminds us to initialize some variables and ercommends the use...

Jeffrey Altman reminds us to initialize some variables and ercommends the use of LOadLibrary instead of GetModuleHandle
上级 3c184d81
...@@ -184,17 +184,17 @@ int RAND_poll(void) ...@@ -184,17 +184,17 @@ int RAND_poll(void)
HWND h; HWND h;
HMODULE advapi, kernel, user, netapi; HMODULE advapi, kernel, user, netapi;
CRYPTACQUIRECONTEXT acquire; CRYPTACQUIRECONTEXT acquire = 0;
CRYPTGENRANDOM gen; CRYPTGENRANDOM gen = 0;
CRYPTRELEASECONTEXT release; CRYPTRELEASECONTEXT release = 0;
NETSTATGET netstatget; NETSTATGET netstatget = 0;
NETFREE netfree; NETFREE netfree = 0;
/* load functions dynamically - not available on all systems */ /* load functions dynamically - not available on all systems */
advapi = GetModuleHandle("ADVAPI32.DLL"); advapi = LoadLibrary("ADVAPI32.DLL");
kernel = GetModuleHandle("KERNEL32.DLL"); kernel = LoadLibrary("KERNEL32.DLL");
user = GetModuleHandle("USER32.DLL"); user = LoadLibrary("USER32.DLL");
netapi = GetModuleHandle("NETAPI32.DLL"); netapi = LoadLibrary("NETAPI32.DLL");
if (netapi) if (netapi)
{ {
...@@ -218,6 +218,9 @@ int RAND_poll(void) ...@@ -218,6 +218,9 @@ int RAND_poll(void)
} }
} }
if (netapi)
FreeLibrary(netapi);
/* Read Performance Statistics from NT/2000 registry */ /* Read Performance Statistics from NT/2000 registry */
/* The size of the performance data can vary from call to call */ /* 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 */ /* so we must guess the size of the buffer to use and increase */
...@@ -289,6 +292,9 @@ int RAND_poll(void) ...@@ -289,6 +292,9 @@ int RAND_poll(void)
} }
} }
if (advapi)
FreeLibrary(advapi);
/* timer data */ /* timer data */
readtimer(); readtimer();
...@@ -347,6 +353,8 @@ int RAND_poll(void) ...@@ -347,6 +353,8 @@ int RAND_poll(void)
w = queue(QS_ALLEVENTS); w = queue(QS_ALLEVENTS);
RAND_add(&w, sizeof(w), 0); RAND_add(&w, sizeof(w), 0);
} }
FreeLibrary(user);
} }
/* Toolhelp32 snapshot: enumerate processes, threads, modules and heap /* Toolhelp32 snapshot: enumerate processes, threads, modules and heap
...@@ -443,6 +451,8 @@ int RAND_poll(void) ...@@ -443,6 +451,8 @@ int RAND_poll(void)
CloseHandle(handle); CloseHandle(handle);
} }
FreeLibrary(kernel);
} }
#ifdef DEBUG #ifdef DEBUG
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册