Author: jimtabor
Date: Mon Nov 4 01:31:19 2013
New Revision: 60862
URL:
http://svn.reactos.org/svn/reactos?rev=60862&view=rev
Log:
- Use LoadLibrary and only free it only when loaded.
Modified:
trunk/reactos/win32ss/user/user32/windows/class.c
trunk/reactos/win32ss/user/user32/windows/hook.c
Modified: trunk/reactos/win32ss/user/user32/windows/class.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
==============================================================================
--- trunk/reactos/win32ss/user/user32/windows/class.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/user32/windows/class.c [iso-8859-1] Mon Nov 4 01:31:19
2013
@@ -241,8 +241,7 @@
{
_SEH2_TRY
{
- hLibModule = GetModuleHandleW( comctl32W );
- if (!hLibModule) hLibModule = LoadLibraryW(comctl32W);
+ hLibModule = LoadLibraryW(comctl32W);
if ( hLibModule )
{
if ((pRegisterClassNameW = (void*) GetProcAddress(hLibModule,
"RegisterClassNameW")))
Modified: trunk/reactos/win32ss/user/user32/windows/hook.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
==============================================================================
--- trunk/reactos/win32ss/user/user32/windows/hook.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/user32/windows/hook.c [iso-8859-1] Mon Nov 4 01:31:19
2013
@@ -571,8 +571,9 @@
WPARAM wParam = 0;
LPARAM lParam = 0;
LRESULT Result = 0;
- BOOL Hit = FALSE;
+ BOOL Hit = FALSE, Loaded = FALSE;
HMODULE mod = NULL;
+ NTSTATUS Status = STATUS_SUCCESS;
Common = (PHOOKPROC_CALLBACK_ARGUMENTS) Arguments;
@@ -586,6 +587,10 @@
if (!(mod = LoadLibraryExW((LPCWSTR)Common->ModuleName, NULL,
LOAD_WITH_ALTERED_SEARCH_PATH)))
{
ERR("Failed to load Hook Module.\n");
+ }
+ else
+ {
+ Loaded = TRUE; // Free it only when loaded.
}
}
if (mod)
@@ -634,7 +639,7 @@
lParam = Common->lParam;
break;
default:
- if (mod) FreeLibrary(mod);
+ if (Loaded) FreeLibrary(mod);
ERR("HCBT_ not supported = %d\n", Common->Code);
return ZwCallbackReturn(NULL, 0, STATUS_NOT_SUPPORTED);
}
@@ -758,15 +763,16 @@
_SEH2_END;
break;
default:
- if (mod) FreeLibrary(mod);
+ if (Loaded) FreeLibrary(mod);
return ZwCallbackReturn(NULL, 0, STATUS_NOT_SUPPORTED);
}
if (Hit)
{
ERR("Hook Exception! Id: %d, Code %d, Proc
0x%x\n",Common->HookId,Common->Code,Proc);
- }
- if (mod) FreeLibrary(mod);
- return ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS);
+ Status = STATUS_UNSUCCESSFUL;
+ }
+ if (Loaded) FreeLibrary(mod);
+ return ZwCallbackReturn(&Result, sizeof(LRESULT), Status);
}
NTSTATUS WINAPI