[ros-diffs] [jimtabor] 41614: - Implement HCBT_CREATEWND support. Tested with user32 cross wine tests, still hangs on win test. For Christoph.

jimtabor at svn.reactos.org jimtabor at svn.reactos.org
Thu Jun 25 22:39:33 CEST 2009


Author: jimtabor
Date: Fri Jun 26 00:39:32 2009
New Revision: 41614

URL: http://svn.reactos.org/svn/reactos?rev=41614&view=rev
Log:
- Implement HCBT_CREATEWND support. Tested with user32 cross wine tests, still hangs on win test. For Christoph.

Modified:
    trunk/reactos/subsystems/win32/win32k/ntuser/callback.c
    trunk/reactos/subsystems/win32/win32k/ntuser/hook.c

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/callback.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/callback.c?rev=41614&r1=41613&r2=41614&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/callback.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/callback.c [iso-8859-1] Fri Jun 26 00:39:32 2009
@@ -347,8 +347,10 @@
    CBT_CREATEWNDW *CbtCreateWnd =NULL;
    PCHAR Extra;
    PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS CbtCreatewndExtra ;
-   PUNICODE_STRING WindowName = NULL;
-   PUNICODE_STRING ClassName = NULL;
+   UNICODE_STRING WindowName;
+   UNICODE_STRING ClassName;
+   PANSI_STRING asWindowName;
+   PANSI_STRING asClassName;
 
    ArgumentLength = sizeof(HOOKPROC_CALLBACK_ARGUMENTS) - sizeof(WCHAR)
                     + ModuleName->Length;
@@ -360,12 +362,29 @@
             case HCBT_CREATEWND:
                CbtCreateWnd = (CBT_CREATEWNDW *) lParam;
                ArgumentLength += sizeof(HOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS);
-               WindowName = (PUNICODE_STRING) (CbtCreateWnd->lpcs->lpszName);
-               ArgumentLength += WindowName->Length + sizeof(WCHAR);
-               ClassName = (PUNICODE_STRING) (CbtCreateWnd->lpcs->lpszClass);
-               if (! IS_ATOM(ClassName->Buffer))
+
+               asWindowName = (PANSI_STRING)&WindowName;
+               asClassName = (PANSI_STRING)&ClassName;
+
+               if (Ansi)
                {
-                  ArgumentLength += ClassName->Length + sizeof(WCHAR);
+                  RtlInitAnsiString(asWindowName, (PCSZ)CbtCreateWnd->lpcs->lpszName);
+                  ArgumentLength += WindowName.Length + sizeof(CHAR);
+               }
+               else
+               {
+                  RtlInitUnicodeString(&WindowName, CbtCreateWnd->lpcs->lpszName);
+                  ArgumentLength += WindowName.Length + sizeof(WCHAR);
+               }
+
+               if (Ansi)
+                  RtlInitAnsiString(asClassName, (PCSZ)CbtCreateWnd->lpcs->lpszClass);
+               else
+                  RtlInitUnicodeString(&ClassName, CbtCreateWnd->lpcs->lpszClass);
+
+               if (! IS_ATOM(ClassName.Buffer))
+               {
+                  ArgumentLength += ClassName.Length + sizeof(WCHAR);
                }
                break;
             default:
@@ -430,19 +449,32 @@
                CbtCreatewndExtra->Cs = *(CbtCreateWnd->lpcs);
                CbtCreatewndExtra->WndInsertAfter = CbtCreateWnd->hwndInsertAfter;
                Extra = (PCHAR) (CbtCreatewndExtra + 1);
-               RtlCopyMemory(Extra, WindowName->Buffer, WindowName->Length);
+               RtlCopyMemory(Extra, WindowName.Buffer, WindowName.Length);
                CbtCreatewndExtra->Cs.lpszName = (LPCWSTR) (Extra - (PCHAR) CbtCreatewndExtra);
-               CbtCreatewndExtra->Cs.lpszClass = ClassName->Buffer;
-               Extra += WindowName->Length;
-               *((WCHAR *) Extra) = L'\0';
-               Extra += sizeof(WCHAR);
-               if (! IS_ATOM(ClassName->Buffer))
+               CbtCreatewndExtra->Cs.lpszClass = ClassName.Buffer;
+               Extra += WindowName.Length;
+               if (Ansi)
                {
-                  RtlCopyMemory(Extra, ClassName->Buffer, ClassName->Length);
+                 *((CHAR *) Extra) = '\0';
+                 Extra += sizeof(CHAR);
+               }
+               else
+               {
+                 *((WCHAR *) Extra) = L'\0';
+                 Extra += sizeof(WCHAR);
+               }
+
+               if (! IS_ATOM(ClassName.Buffer))
+               {
+                  RtlCopyMemory(Extra, ClassName.Buffer, ClassName.Length);
                   CbtCreatewndExtra->Cs.lpszClass =
                      (LPCWSTR) MAKELONG(Extra - (PCHAR) CbtCreatewndExtra, 1);
-                  Extra += ClassName->Length;
-                  *((WCHAR *) Extra) = L'\0';
+                  Extra += ClassName.Length;
+
+                  if (Ansi)
+                     *((CHAR *) Extra) = '\0';
+                  else
+                     *((WCHAR *) Extra) = L'\0';
                }
                break;
          }

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/hook.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/hook.c?rev=41614&r1=41613&r2=41614&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/hook.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/hook.c [iso-8859-1] Fri Jun 26 00:39:32 2009
@@ -788,10 +788,66 @@
             DPRINT1("HOOK WH_CBT!\n");
             switch (Code)
             {
-                case HCBT_CREATEWND: /* Use Ansi. */
+                case HCBT_CREATEWND:
+                {
+                    LPCBT_CREATEWNDW pcbtcww = (LPCBT_CREATEWNDW)lParam;
+
                     DPRINT1("HOOK HCBT_CREATEWND\n");
-                    /* lResult = co_HOOK_CallHookNext(Hook, Code, wParam, lParam); */
+                    _SEH2_TRY
+                    {
+                        if (Ansi)
+                        {
+                            ProbeForRead( pcbtcww,
+                                          sizeof(CBT_CREATEWNDA),
+                                          1);
+                            ProbeForWrite(pcbtcww->lpcs,
+                                          sizeof(CREATESTRUCTA),
+                                          1);
+                            ProbeForRead( pcbtcww->lpcs->lpszName,
+                                          sizeof(CHAR),
+                                          1);
+
+                            if (!IS_ATOM(pcbtcww->lpcs->lpszClass))
+                            {
+                               ProbeForRead( pcbtcww->lpcs->lpszClass,
+                                             sizeof(CHAR),
+                                             1);
+                            }
+                        }
+                        else
+                        {
+                            ProbeForRead( pcbtcww,
+                                          sizeof(CBT_CREATEWNDW),
+                                          1);
+                            ProbeForWrite(pcbtcww->lpcs,
+                                          sizeof(CREATESTRUCTW),
+                                          1);
+                            ProbeForRead( pcbtcww->lpcs->lpszName,
+                                          sizeof(WCHAR),
+                                          1);
+
+                            if (!IS_ATOM(pcbtcww->lpcs->lpszClass))
+                            {
+                               ProbeForRead( pcbtcww->lpcs->lpszClass,
+                                             sizeof(WCHAR),
+                                             1);
+                            }
+                        }
+                    }
+                    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+                    {
+                        BadChk = TRUE;
+                    }
+                    _SEH2_END;
+
+                    if (BadChk)
+                    {
+                        DPRINT1("HOOK HCBT_CREATEWND write ERROR!\n");
+                    }
+                    /* The next call handles the structures. */
+                    if (!BadChk) lResult = co_HOOK_CallHookNext(Hook, Code, wParam, lParam);
                     break;
+                }
 
                 case HCBT_MOVESIZE:
                 {



More information about the Ros-diffs mailing list