- [Win32k] Make co_IntCreateWindowEx return pointer to public window structure.

svn path=/trunk/; revision=42092
This commit is contained in:
James Tabor 2009-07-19 21:18:08 +00:00
parent 6a16259ee6
commit 95d1d17ba9
4 changed files with 54 additions and 38 deletions

View file

@ -28,7 +28,7 @@ typedef struct _DESKTOP
PWIN32HEAP pheapDesktop; PWIN32HEAP pheapDesktop;
PSECTION_OBJECT DesktopHeapSection; PSECTION_OBJECT DesktopHeapSection;
PDESKTOPINFO DesktopInfo; PDESKTOPINFO DesktopInfo;
HWND spwndMessage; PWINDOW spwndMessage;
} DESKTOP, *PDESKTOP; } DESKTOP, *PDESKTOP;
extern PDESKTOP InputDesktop; extern PDESKTOP InputDesktop;

View file

@ -171,7 +171,7 @@ IntDefWindowProc( PWINDOW_OBJECT Window, UINT Msg, WPARAM wParam, LPARAM lParam,
VOID FASTCALL IntNotifyWinEvent(DWORD, HWND, LONG, LONG); VOID FASTCALL IntNotifyWinEvent(DWORD, HWND, LONG, LONG);
HWND APIENTRY co_IntCreateWindowEx(DWORD,PUNICODE_STRING,PUNICODE_STRING,DWORD,LONG,LONG,LONG,LONG,HWND,HMENU,HINSTANCE,LPVOID,DWORD,BOOL); PWINDOW APIENTRY co_IntCreateWindowEx(DWORD,PUNICODE_STRING,PUNICODE_STRING,DWORD,LONG,LONG,LONG,LONG,HWND,HMENU,HINSTANCE,LPVOID,DWORD,BOOL);
#endif /* _WIN32K_WINDOW_H */ #endif /* _WIN32K_WINDOW_H */
/* EOF */ /* EOF */

View file

@ -566,7 +566,7 @@ HWND FASTCALL IntGetMessageWindow(VOID)
DPRINT("No active desktop\n"); DPRINT("No active desktop\n");
return NULL; return NULL;
} }
return pdo->spwndMessage; return pdo->spwndMessage->hdr.Handle;
} }
HWND FASTCALL IntGetCurrentThreadDesktopWindow(VOID) HWND FASTCALL IntGetCurrentThreadDesktopWindow(VOID)
@ -898,7 +898,6 @@ NtUserCreateDesktop(
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
PTHREADINFO W32Thread; PTHREADINFO W32Thread;
HWND hwndMessage;
PWINSTATION_OBJECT WinStaObject; PWINSTATION_OBJECT WinStaObject;
PDESKTOP DesktopObject; PDESKTOP DesktopObject;
UNICODE_STRING DesktopName; UNICODE_STRING DesktopName;
@ -916,6 +915,7 @@ NtUserCreateDesktop(
PPROCESSINFO pi = GetW32ProcessInfo(); PPROCESSINFO pi = GetW32ProcessInfo();
WNDCLASSEXW wc; WNDCLASSEXW wc;
PWINDOWCLASS Class; PWINDOWCLASS Class;
PWINDOW pWnd;
DECLARE_RETURN(HDESK); DECLARE_RETURN(HDESK);
DPRINT("Enter NtUserCreateDesktop: %wZ\n", lpszDesktopName); DPRINT("Enter NtUserCreateDesktop: %wZ\n", lpszDesktopName);
@ -1149,27 +1149,27 @@ NtUserCreateDesktop(
DPRINT1("!!! Registering Message system class failed!\n"); DPRINT1("!!! Registering Message system class failed!\n");
} }
hwndMessage = co_IntCreateWindowEx( 0, pWnd = co_IntCreateWindowEx( 0,
&ClassName, &ClassName,
&WindowName, &WindowName,
(WS_POPUP|WS_CLIPCHILDREN), (WS_POPUP|WS_CLIPCHILDREN),
0, 0,
0, 0,
100, 100,
100, 100,
NULL, NULL,
NULL, NULL,
pi->hModUser, // hModClient; pi->hModUser, // hModClient;
NULL, NULL,
0, 0,
TRUE); TRUE);
if (!hwndMessage) if (!pWnd)
{ {
DPRINT1("Failed to create Message window handle\n"); DPRINT1("Failed to create Message window handle\n");
} }
else else
{ {
DesktopObject->spwndMessage = hwndMessage; DesktopObject->spwndMessage = pWnd;
} }
RETURN( Desktop); RETURN( Desktop);

View file

@ -1518,7 +1518,7 @@ IntCalcDefPosSize(PWINDOW_OBJECT Parent, PWINDOW_OBJECT Window, RECTL *rc, BOOL
/* /*
* @implemented * @implemented
*/ */
HWND APIENTRY PWINDOW APIENTRY
co_IntCreateWindowEx(DWORD dwExStyle, co_IntCreateWindowEx(DWORD dwExStyle,
PUNICODE_STRING ClassName, PUNICODE_STRING ClassName,
PUNICODE_STRING WindowName, PUNICODE_STRING WindowName,
@ -1558,7 +1558,7 @@ co_IntCreateWindowEx(DWORD dwExStyle,
CBT_CREATEWNDW CbtCreate; CBT_CREATEWNDW CbtCreate;
LRESULT Result; LRESULT Result;
BOOL MenuChanged; BOOL MenuChanged;
DECLARE_RETURN(HWND); DECLARE_RETURN(PWINDOW);
BOOL HasOwner; BOOL HasOwner;
USER_REFERENCE_ENTRY ParentRef, Ref; USER_REFERENCE_ENTRY ParentRef, Ref;
PTHREADINFO pti; PTHREADINFO pti;
@ -1595,7 +1595,7 @@ co_IntCreateWindowEx(DWORD dwExStyle,
else if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD) else if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD)
{ {
SetLastWin32Error(ERROR_TLW_WITH_WSCHILD); SetLastWin32Error(ERROR_TLW_WITH_WSCHILD);
RETURN( (HWND)0); /* WS_CHILD needs a parent, but WS_POPUP doesn't */ RETURN( (PWINDOW)0); /* WS_CHILD needs a parent, but WS_POPUP doesn't */
} }
if (ParentWindowHandle) if (ParentWindowHandle)
@ -1616,7 +1616,7 @@ co_IntCreateWindowEx(DWORD dwExStyle,
if (ti == NULL || pti->Desktop == NULL) if (ti == NULL || pti->Desktop == NULL)
{ {
DPRINT1("Thread is not attached to a desktop! Cannot create window!\n"); DPRINT1("Thread is not attached to a desktop! Cannot create window!\n");
RETURN( (HWND)0); RETURN( (PWINDOW)0);
} }
/* Check the class. */ /* Check the class. */
@ -1639,7 +1639,7 @@ co_IntCreateWindowEx(DWORD dwExStyle,
} }
SetLastWin32Error(ERROR_CANNOT_FIND_WND_CLASS); SetLastWin32Error(ERROR_CANNOT_FIND_WND_CLASS);
RETURN((HWND)0); RETURN((PWINDOW)0);
} }
Class = IntReferenceClass(Class, Class = IntReferenceClass(Class,
@ -1657,9 +1657,10 @@ co_IntCreateWindowEx(DWORD dwExStyle,
ObReferenceObjectByPointer(WinSta, KernelMode, ExWindowStationObjectType, 0); ObReferenceObjectByPointer(WinSta, KernelMode, ExWindowStationObjectType, 0);
/* Create the window object. */ /* Create the window object. */
Window = (PWINDOW_OBJECT) Window = (PWINDOW_OBJECT) UserCreateObject( gHandleTable,
UserCreateObject(gHandleTable, (PHANDLE)&hWnd, (PHANDLE)&hWnd,
otWindow, sizeof(WINDOW_OBJECT)); otWindow,
sizeof(WINDOW_OBJECT));
if (Window) if (Window)
{ {
Window->Wnd = DesktopHeapAlloc(pti->Desktop, Window->Wnd = DesktopHeapAlloc(pti->Desktop,
@ -1668,7 +1669,7 @@ co_IntCreateWindowEx(DWORD dwExStyle,
goto AllocErr; goto AllocErr;
RtlZeroMemory(Window->Wnd, RtlZeroMemory(Window->Wnd,
sizeof(WINDOW) + Class->WndExtra); sizeof(WINDOW) + Class->WndExtra);
Window->Wnd->hdr.Handle = hWnd; /* FIXME: Remove hack */ Window->Wnd->hdr.Handle = hWnd; /* FIXME: Remove hack , are you sure?*/
Wnd = Window->Wnd; Wnd = Window->Wnd;
Wnd->ti = ti; Wnd->ti = ti;
@ -1683,7 +1684,7 @@ co_IntCreateWindowEx(DWORD dwExStyle,
AllocErr: AllocErr:
ObDereferenceObject(WinSta); ObDereferenceObject(WinSta);
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
RETURN( (HWND)0); RETURN( (PWINDOW)0);
} }
UserRefObjectCo(Window, &Ref); UserRefObjectCo(Window, &Ref);
@ -1775,7 +1776,7 @@ AllocErr:
if (Wnd->WindowName.Buffer == NULL) if (Wnd->WindowName.Buffer == NULL)
{ {
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
RETURN( (HWND)0); RETURN( (PWINDOW)0);
} }
Wnd->WindowName.Buffer[WindowName->Length / sizeof(WCHAR)] = L'\0'; Wnd->WindowName.Buffer[WindowName->Length / sizeof(WCHAR)] = L'\0';
@ -1885,7 +1886,7 @@ AllocErr:
/* FIXME - Delete window object and remove it from the thread windows list */ /* FIXME - Delete window object and remove it from the thread windows list */
/* FIXME - delete allocated DCE */ /* FIXME - delete allocated DCE */
DPRINT1("CBT-hook returned !0\n"); DPRINT1("CBT-hook returned !0\n");
RETURN( (HWND) NULL); RETURN( (PWINDOW) NULL);
} }
} }
x = Cs.x; x = Cs.x;
@ -2052,7 +2053,7 @@ AllocErr:
{ {
/* FIXME: Cleanup. */ /* FIXME: Cleanup. */
DPRINT1("IntCreateWindowEx(): NCCREATE message failed. No cleanup performed!\n"); DPRINT1("IntCreateWindowEx(): NCCREATE message failed. No cleanup performed!\n");
RETURN((HWND)0); RETURN((PWINDOW)0);
} }
/* Calculate the non-client size. */ /* Calculate the non-client size. */
@ -2116,7 +2117,7 @@ AllocErr:
/* FIXME: Cleanup. */ /* FIXME: Cleanup. */
DPRINT1("IntCreateWindowEx(): send CREATE message failed. No cleanup performed!\n"); DPRINT1("IntCreateWindowEx(): send CREATE message failed. No cleanup performed!\n");
IntUnlinkWindow(Window); IntUnlinkWindow(Window);
RETURN((HWND)0); RETURN((PWINDOW)0);
} }
IntNotifyWinEvent(EVENT_OBJECT_CREATE, Window->hSelf, OBJID_WINDOW, 0); IntNotifyWinEvent(EVENT_OBJECT_CREATE, Window->hSelf, OBJID_WINDOW, 0);
@ -2254,7 +2255,7 @@ AllocErr:
DPRINT("IntCreateWindow(): = %X\n", hWnd); DPRINT("IntCreateWindow(): = %X\n", hWnd);
DPRINT("WindowObject->SystemMenu = 0x%x\n", Window->SystemMenu); DPRINT("WindowObject->SystemMenu = 0x%x\n", Window->SystemMenu);
RETURN(hWnd); RETURN( Wnd);
CLEANUP: CLEANUP:
if (!_ret_ && Window && Window->Wnd && ti) if (!_ret_ && Window && Window->Wnd && ti)
@ -2297,7 +2298,8 @@ NtUserCreateWindowEx(DWORD dwExStyle,
NTSTATUS Status; NTSTATUS Status;
UNICODE_STRING WindowName; UNICODE_STRING WindowName;
UNICODE_STRING ClassName; UNICODE_STRING ClassName;
HWND NewWindow; HWND NewWindow = NULL;
PWINDOW pNewWindow;
DECLARE_RETURN(HWND); DECLARE_RETURN(HWND);
DPRINT("Enter NtUserCreateWindowEx(): (%d,%d-%d,%d)\n", x, y, nWidth, nHeight); DPRINT("Enter NtUserCreateWindowEx(): (%d,%d-%d,%d)\n", x, y, nWidth, nHeight);
@ -2344,8 +2346,22 @@ NtUserCreateWindowEx(DWORD dwExStyle,
RtlInitUnicodeString(&WindowName, NULL); RtlInitUnicodeString(&WindowName, NULL);
} }
NewWindow = co_IntCreateWindowEx(dwExStyle, &ClassName, &WindowName, dwStyle, x, y, nWidth, nHeight, pNewWindow = co_IntCreateWindowEx( dwExStyle,
hWndParent, hMenu, hInstance, lpParam, dwShowMode, bUnicodeWindow); &ClassName,
&WindowName,
dwStyle,
x,
y,
nWidth,
nHeight,
hWndParent,
hMenu,
hInstance,
lpParam,
dwShowMode,
bUnicodeWindow);
if (pNewWindow) NewWindow = pNewWindow->hdr.Handle;
if (WindowName.Buffer) if (WindowName.Buffer)
{ {