Author: gadamopoulos Date: Tue Jul 12 08:37:40 2011 New Revision: 52649
URL: http://svn.reactos.org/svn/reactos?rev=52649&view=rev Log: [win32k] - Implement co_IntClientLoadLibrary that calls ClientLoadLibrary in user32
Modified: branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/include/callback.h branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/callback.c
Modified: branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/include/callback.h URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/subsyste... ============================================================================== --- branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/include/callback.h [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/include/callback.h [iso-8859-1] Tue Jul 12 08:37:40 2011 @@ -56,3 +56,9 @@ HMENU APIENTRY co_IntCallLoadMenu(HINSTANCE,PUNICODE_STRING);
NTSTATUS APIENTRY co_IntClientThreadSetup(VOID); + +HMODULE +co_IntClientLoadLibrary(PUNICODE_STRING strLibName, + PUNICODE_STRING strInitFunc, + BOOL Unload, + BOOL ApiHook);
Modified: branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/callback.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/subsyste... ============================================================================== --- branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/callback.c [iso-8859-1] (original) +++ branches/GSoC_2011/ThemesSupport/subsystems/win32/win32k/ntuser/callback.c [iso-8859-1] Tue Jul 12 08:37:40 2011 @@ -116,6 +116,111 @@ }
/* FUNCTIONS *****************************************************************/ + +/* calls ClientLoadLibrary in user32 */ +HMODULE +co_IntClientLoadLibrary(PUNICODE_STRING pstrLibName, + PUNICODE_STRING pstrInitFunc, + BOOL Unload, + BOOL ApiHook) +{ + PVOID ResultPointer; + ULONG ResultLength; + ULONG ArgumentLength; + PCLIENT_LOAD_LIBRARY_ARGUMENTS pArguments; + NTSTATUS Status; + HMODULE Result; + ULONG_PTR pLibNameBuffer = 0, pInitFuncBuffer = 0; + + DPRINT("co_IntClientLoadLibrary: %S, %S, %d, %d\n", pstrLibName->Buffer, pstrLibName->Buffer, Unload, ApiHook); + + /* Calculate the size of the argument */ + ArgumentLength = sizeof(CLIENT_LOAD_LIBRARY_ARGUMENTS); + if(pstrLibName) + { + pLibNameBuffer = ArgumentLength; + ArgumentLength += pstrLibName->Length + sizeof(WCHAR); + } + if(pstrInitFunc) + { + pInitFuncBuffer = ArgumentLength; + ArgumentLength += pstrInitFunc->Length + sizeof(WCHAR); + } + + /* Allocate the argument*/ + pArguments = IntCbAllocateMemory(ArgumentLength); + if(pArguments == NULL) + { + return FALSE; + } + + /* Fill the argument */ + pArguments->Unload = Unload; + pArguments->ApiHook = ApiHook; + if(pstrLibName) + { + /* Copy the string to the callback memory */ + pLibNameBuffer += (ULONG_PTR)pArguments; + pArguments->strLibraryName.Buffer = (PWCHAR)pLibNameBuffer; + pArguments->strLibraryName.MaximumLength = pstrLibName->Length + sizeof(WCHAR); + RtlCopyUnicodeString(&pArguments->strLibraryName, pstrLibName); + + /* Fix argument pointer to be relative to the argument */ + pLibNameBuffer -= (ULONG_PTR)pArguments; + pArguments->strLibraryName.Buffer = (PWCHAR)(pLibNameBuffer); + } + else + { + RtlZeroMemory(&pArguments->strLibraryName, sizeof(UNICODE_STRING)); + } + + if(pstrInitFunc) + { + /* Copy the strings to the callback memory */ + pInitFuncBuffer += (ULONG_PTR)pArguments; + pArguments->strInitFuncName.Buffer = (PWCHAR)pInitFuncBuffer; + pArguments->strInitFuncName.MaximumLength = pstrInitFunc->Length + sizeof(WCHAR); + RtlCopyUnicodeString(&pArguments->strInitFuncName, pstrInitFunc); + + /* Fix argument pointers to be relative to the argument */ + pInitFuncBuffer -= (ULONG_PTR)pArguments; + pArguments->strInitFuncName.Buffer = (PWCHAR)(pInitFuncBuffer); + } + else + { + RtlZeroMemory(&pArguments->strInitFuncName, sizeof(UNICODE_STRING)); + } + + /* Do the callback */ + UserLeaveCo(); + + Status = KeUserModeCallback(USER32_CALLBACK_CLIENTLOADLIBRARY, + pArguments, + ArgumentLength, + &ResultPointer, + &ResultLength); + + UserEnterCo(); + + if(!NT_SUCCESS(Status)) + { + return FALSE; + } + + _SEH2_TRY + { + ProbeForRead(ResultPointer, sizeof(HMODULE), 1); + /* Simulate old behaviour: copy into our local buffer */ + Result = *(HMODULE*)ResultPointer; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Result = 0; + } + _SEH2_END; + + return Result; +}
VOID APIENTRY co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback,