mirror of
https://github.com/reactos/reactos.git
synced 2025-06-06 09:50:43 +00:00
[WIN32K][USER32]
Chnge return type of ClientLoadLibrary to BOOL. Previously it returned HMODULE in both the load and unload case, being a meaningless value in the latter case. All users of this function were using it as a boolean parameter only. svn path=/trunk/; revision=57507
This commit is contained in:
parent
9c2bfc5ecd
commit
0c4428ca06
4 changed files with 65 additions and 60 deletions
|
@ -78,7 +78,7 @@ IntCleanupThreadCallbacks(PTHREADINFO W32Thread)
|
|||
ListEntry);
|
||||
|
||||
/* Free memory */
|
||||
ExFreePool(Mem);
|
||||
ExFreePoolWithTag(Mem, USERTAG_CALLBACK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,8 @@ IntRestoreTebWndCallback (HWND hWnd, PWND pWnd, PVOID pActCtx)
|
|||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
/* Calls ClientLoadLibrary in user32 */
|
||||
HMODULE
|
||||
BOOL
|
||||
NTAPI
|
||||
co_IntClientLoadLibrary(PUNICODE_STRING pstrLibName,
|
||||
PUNICODE_STRING pstrInitFunc,
|
||||
BOOL Unload,
|
||||
|
@ -126,7 +127,7 @@ co_IntClientLoadLibrary(PUNICODE_STRING pstrLibName,
|
|||
ULONG ArgumentLength;
|
||||
PCLIENT_LOAD_LIBRARY_ARGUMENTS pArguments;
|
||||
NTSTATUS Status;
|
||||
HMODULE Result;
|
||||
BOOL bResult;
|
||||
ULONG_PTR pLibNameBuffer = 0, pInitFuncBuffer = 0;
|
||||
|
||||
TRACE("co_IntClientLoadLibrary: %S, %S, %d, %d\n", pstrLibName->Buffer, pstrLibName->Buffer, Unload, ApiHook);
|
||||
|
@ -209,17 +210,17 @@ co_IntClientLoadLibrary(PUNICODE_STRING pstrLibName,
|
|||
|
||||
_SEH2_TRY
|
||||
{
|
||||
/* Probe and copy the usermode result data */
|
||||
ProbeForRead(ResultPointer, sizeof(HMODULE), 1);
|
||||
/* Simulate old behaviour: copy into our local buffer */
|
||||
Result = *(HMODULE*)ResultPointer;
|
||||
bResult = *(BOOL*)ResultPointer;
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Result = 0;
|
||||
bResult = FALSE;
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
return Result;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
VOID APIENTRY
|
||||
|
|
|
@ -55,9 +55,10 @@ HMENU APIENTRY co_IntCallLoadMenu(HINSTANCE,PUNICODE_STRING);
|
|||
|
||||
NTSTATUS APIENTRY co_IntClientThreadSetup(VOID);
|
||||
|
||||
HMODULE
|
||||
co_IntClientLoadLibrary(PUNICODE_STRING strLibName,
|
||||
PUNICODE_STRING strInitFunc,
|
||||
BOOL
|
||||
NTAPI
|
||||
co_IntClientLoadLibrary(PUNICODE_STRING strLibName,
|
||||
PUNICODE_STRING strInitFunc,
|
||||
BOOL Unload,
|
||||
BOOL ApiHook);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ BOOL
|
|||
IntLoadHookModule(int iHookID, HHOOK hHook, BOOL Unload)
|
||||
{
|
||||
PPROCESSINFO ppi;
|
||||
HMODULE hmod;
|
||||
BOOL bResult;
|
||||
|
||||
ppi = PsGetCurrentProcessWin32Process();
|
||||
|
||||
|
@ -49,26 +49,24 @@ IntLoadHookModule(int iHookID, HHOOK hHook, BOOL Unload)
|
|||
ppi->W32PF_flags |= W32PF_APIHOOKLOADED;
|
||||
|
||||
/* Call ClientLoadLibrary in user32 */
|
||||
hmod = co_IntClientLoadLibrary(&strUahModule, &strUahInitFunc, Unload, TRUE);
|
||||
TRACE("co_IntClientLoadLibrary returned %d\n", hmod );
|
||||
if(hmod == 0)
|
||||
bResult = co_IntClientLoadLibrary(&strUahModule, &strUahInitFunc, Unload, TRUE);
|
||||
TRACE("co_IntClientLoadLibrary returned %d\n", bResult );
|
||||
if (!bResult)
|
||||
{
|
||||
/* Remove the flag we set before */
|
||||
ppi->W32PF_flags &= ~W32PF_APIHOOKLOADED;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
return bResult;
|
||||
}
|
||||
else if(Unload && (ppi->W32PF_flags & W32PF_APIHOOKLOADED))
|
||||
{
|
||||
/* Call ClientLoadLibrary in user32 */
|
||||
hmod = co_IntClientLoadLibrary(NULL, NULL, Unload, TRUE);
|
||||
if(hmod != 0)
|
||||
bResult = co_IntClientLoadLibrary(NULL, NULL, Unload, TRUE);
|
||||
if (bResult)
|
||||
{
|
||||
ppi->W32PF_flags &= ~W32PF_APIHOOKLOADED;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -500,7 +498,7 @@ co_IntCallDebugHook(PHOOK Hook,
|
|||
if (BadChk)
|
||||
{
|
||||
ERR("HOOK WH_DEBUG read from Debug.lParam ERROR!\n");
|
||||
ExFreePool(HooklParam);
|
||||
ExFreePoolWithTag(HooklParam, TAG_HOOK);
|
||||
return lResult;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -427,104 +427,109 @@ SetWindowsHookExW(
|
|||
return IntSetWindowsHook(idHook, lpfn, hMod, dwThreadId, FALSE);
|
||||
}
|
||||
|
||||
HINSTANCE ClientLoadLibrary(PUNICODE_STRING pstrLibName,
|
||||
PUNICODE_STRING pstrInitFunc,
|
||||
BOOL Unload,
|
||||
BOOL ApiHook)
|
||||
static
|
||||
BOOL
|
||||
ClientLoadLibrary(
|
||||
PUNICODE_STRING pstrLibName,
|
||||
PUNICODE_STRING pstrInitFunc,
|
||||
BOOL bUnload,
|
||||
BOOL bApiHook)
|
||||
{
|
||||
HINSTANCE hLibrary;
|
||||
PVOID pInitFunction;
|
||||
//NTSTATUS Status;
|
||||
NTSTATUS Status;
|
||||
ANSI_STRING InitFuncName;
|
||||
BOOL Result = FALSE;
|
||||
BOOL bResult = FALSE;
|
||||
|
||||
TRACE("ClientLoadLibrary: pid: %d, strLibraryName: %S, "
|
||||
"strInitFuncName: %S, Unload: %d, ApiHook:%d\n",
|
||||
"strInitFuncName: %S, bUnload: %d, bApiHook:%d\n",
|
||||
GetCurrentProcessId(),
|
||||
pstrLibName->Buffer,
|
||||
pstrInitFunc->Buffer,
|
||||
Unload,
|
||||
ApiHook);
|
||||
bUnload,
|
||||
bApiHook);
|
||||
|
||||
/* Check if we have to load the module */
|
||||
if(Unload == FALSE)
|
||||
if (bUnload == FALSE)
|
||||
{
|
||||
ASSERT(pstrLibName->Buffer != NULL);
|
||||
|
||||
/* Load it */
|
||||
hLibrary = LoadLibrary(pstrLibName->Buffer);
|
||||
if(hLibrary == 0)
|
||||
if (hLibrary == 0)
|
||||
{
|
||||
return hLibrary;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(ApiHook == FALSE)
|
||||
if (!bApiHook)
|
||||
{
|
||||
/* There is nothing more to do for a global hook*/
|
||||
return hLibrary;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Initialize the user api hook */
|
||||
ASSERT(pstrInitFunc->Buffer);
|
||||
|
||||
/*Status = */ RtlUnicodeStringToAnsiString(&InitFuncName,
|
||||
Status = RtlUnicodeStringToAnsiString(&InitFuncName,
|
||||
pstrInitFunc,
|
||||
TRUE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
FreeLibrary(hLibrary);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Get the address of the initialization routine */
|
||||
pInitFunction = GetProcAddress(hLibrary, InitFuncName.Buffer);
|
||||
if(pInitFunction)
|
||||
if (pInitFunction)
|
||||
{
|
||||
/* Call the initialization routine */
|
||||
Result = InitUserApiHook(hLibrary, (USERAPIHOOKPROC)pInitFunction);
|
||||
bResult = InitUserApiHook(hLibrary, (USERAPIHOOKPROC)pInitFunction);
|
||||
}
|
||||
|
||||
RtlFreeAnsiString(&InitFuncName);
|
||||
|
||||
/* In case of error unload the library */
|
||||
if(Result == FALSE)
|
||||
if (bResult == FALSE)
|
||||
{
|
||||
FreeLibrary(hLibrary);
|
||||
hLibrary = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Cleanup user api hook before unloading */
|
||||
if(ApiHook == TRUE)
|
||||
if (bApiHook)
|
||||
{
|
||||
hLibrary = ghmodUserApiHook;
|
||||
Result = ClearUserApiHook(ghmodUserApiHook);
|
||||
bResult = ClearUserApiHook(ghmodUserApiHook);
|
||||
|
||||
/* Check if we can we unload it now */
|
||||
if(Result == FALSE)
|
||||
if (!bResult)
|
||||
{
|
||||
/* Return success because we are going to free
|
||||
the library in EndUserApiHook*/
|
||||
return hLibrary;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the library handle from the name */
|
||||
hLibrary = GetModuleHandle(pstrLibName->Buffer);
|
||||
Result = (hLibrary != 0);
|
||||
}
|
||||
|
||||
if(Result == TRUE)
|
||||
{
|
||||
Result = FreeLibrary(hLibrary);
|
||||
if(Result == FALSE)
|
||||
if (hLibrary == NULL)
|
||||
{
|
||||
hLibrary = 0;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
bResult = FreeLibrary(hLibrary);
|
||||
}
|
||||
|
||||
return hLibrary;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
NTSTATUS WINAPI
|
||||
User32CallClientLoadLibraryFromKernel(PVOID Arguments, ULONG ArgumentLength)
|
||||
{
|
||||
HINSTANCE Result;
|
||||
BOOL bResult;
|
||||
PCLIENT_LOAD_LIBRARY_ARGUMENTS Argument;
|
||||
|
||||
/* Retireve the callback parameters */
|
||||
|
@ -539,12 +544,12 @@ User32CallClientLoadLibraryFromKernel(PVOID Arguments, ULONG ArgumentLength)
|
|||
}
|
||||
|
||||
/* Call the implementation of the callback */
|
||||
Result = ClientLoadLibrary(&Argument->strLibraryName,
|
||||
&Argument->strInitFuncName,
|
||||
Argument->Unload,
|
||||
Argument->ApiHook);
|
||||
bResult = ClientLoadLibrary(&Argument->strLibraryName,
|
||||
&Argument->strInitFuncName,
|
||||
Argument->Unload,
|
||||
Argument->ApiHook);
|
||||
|
||||
return ZwCallbackReturn(&Result, sizeof(HINSTANCE), STATUS_SUCCESS);
|
||||
return ZwCallbackReturn(&bResult, sizeof(HINSTANCE), STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS WINAPI
|
||||
|
|
Loading…
Reference in a new issue