Author: jimtabor
Date: Wed Jul 1 21:19:16 2009
New Revision: 41727
URL:
http://svn.reactos.org/svn/reactos?rev=41727&view=rev
Log:
- Add more vista types. Added another window message type, based on winproc.c. Added two
vista prototypes for ntuser.
- Implemented new PostMessage and SendNotifyMessage, this is for bug 4646. I realize the
need to update/sync dde code from wine. This relates to the new post and send functions
and the use of MsgiKMToUMMessage. Trying to understand this mess.
- CreateDesktop is used to create the HWND_MESSAGE for the desktop. This is a work in
progress. The ntuser prototype is updated too. Now pass the correct data from user to
kernel space.
- Major update to event code and testing with user32 wine test msg. ATM, only two ntuser
notifications are sent if the app has a event hook. Need to add more notifications at the
correct points.
- Code arranging in hooks. Testing with user32 cross test works, need to add more ntuser
hook calls at the correct points.
- Testing: More is required! User32 cross tests win and msg, win test hangs at
flush_events. FF 1.5.x (Still has that funny minimize bug. Play with it and see. Missing
one more check I think.) and AbiWord 2.4.1. Notepad lite is doing something very naughty
inside it's hook call, with out the source, testing it will be imposable, so someone
needs to find an open source program that does the same thing.
- Reference: Drag and drop file into window: winproc.c WM_COPYGLOBALDATA
http://wiki.winprog.org/wiki/Windows_messages
Modified:
trunk/reactos/dll/win32/user32/misc/desktop.c
trunk/reactos/dll/win32/user32/windows/defwnd.c
trunk/reactos/dll/win32/user32/windows/hook.c
trunk/reactos/dll/win32/user32/windows/message.c
trunk/reactos/include/reactos/win32k/callback.h
trunk/reactos/include/reactos/win32k/ntuser.h
trunk/reactos/subsystems/win32/win32k/include/desktop.h
trunk/reactos/subsystems/win32/win32k/include/hook.h
trunk/reactos/subsystems/win32/win32k/include/window.h
trunk/reactos/subsystems/win32/win32k/ntuser/callback.c
trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c
trunk/reactos/subsystems/win32/win32k/ntuser/event.c
trunk/reactos/subsystems/win32/win32k/ntuser/message.c
trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c
trunk/reactos/subsystems/win32/win32k/ntuser/window.c
Modified: trunk/reactos/dll/win32/user32/misc/desktop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/desk…
==============================================================================
--- trunk/reactos/dll/win32/user32/misc/desktop.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/misc/desktop.c [iso-8859-1] Wed Jul 1 21:19:16 2009
@@ -356,19 +356,35 @@
ACCESS_MASK dwDesiredAccess,
LPSECURITY_ATTRIBUTES lpsa)
{
- UNICODE_STRING DesktopName;
+ OBJECT_ATTRIBUTES oas;
+ UNICODE_STRING DesktopName, DesktopDevice;
HWINSTA hWinSta;
HDESK hDesktop;
-
+ ULONG Attributes = (OBJ_OPENIF|OBJ_CASE_INSENSITIVE);
+
+ /* Retrive WinStation handle. */
hWinSta = NtUserGetProcessWindowStation();
+ /* Initialize the strings. */
RtlInitUnicodeString(&DesktopName, lpszDesktop);
-
- hDesktop = NtUserCreateDesktop(&DesktopName,
- dwFlags,
- dwDesiredAccess,
- lpsa,
- hWinSta);
+ RtlInitUnicodeString(&DesktopDevice, lpszDevice);
+
+ /* Check for process is inherited, set flag if set. */
+ if (lpsa && lpsa->bInheritHandle) Attributes |= OBJ_INHERIT;
+
+ /* Initialize the attributes for the desktop. */
+ InitializeObjectAttributes( &oas,
+ &DesktopName,
+ Attributes,
+ hWinSta,
+ lpsa ? lpsa->lpSecurityDescriptor : NULL);
+
+ /* Send the request and call to win32k. */
+ hDesktop = NtUserCreateDesktop( &oas,
+ &DesktopDevice,
+ pDevmode,
+ dwFlags,
+ dwDesiredAccess);
return(hDesktop);
}
Modified: trunk/reactos/dll/win32/user32/windows/defwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/d…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/defwnd.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/defwnd.c [iso-8859-1] Wed Jul 1 21:19:16 2009
@@ -670,8 +670,9 @@
//#if 0
// if (ISITHOOKED(WH_CBT))
{
- if (NtUserMessageCall( hwnd, WM_CBT, HCBT_MOVESIZE, (LPARAM)&sizingRect, 0,
FNID_DEFWINDOWPROC, FALSE))
- moved = FALSE;
+ LRESULT lResult;
+ NtUserMessageCall( hwnd, WM_CBT, HCBT_MOVESIZE, (LPARAM)&sizingRect,
(ULONG_PTR)&lResult, FNID_DEFWINDOWPROC, FALSE);
+ if (lResult) moved = FALSE;
}
//#endif
(void)NtUserSetGUIThreadHandle(MSQ_STATE_MOVESIZE, NULL);
@@ -758,8 +759,9 @@
//#if 0
// if (ISITHOOKED(WH_CBT))
{
- if (NtUserMessageCall( hWnd, WM_SYSCOMMAND, wParam, lParam, 0, FNID_DEFWINDOWPROC,
FALSE))
- return 0;
+ LRESULT lResult;
+ NtUserMessageCall( hWnd, WM_SYSCOMMAND, wParam, lParam, (ULONG_PTR)&lResult,
FNID_DEFWINDOWPROC, FALSE);
+ if (lResult) return 0;
}
//#endif
switch (wParam & 0xfff0)
Modified: trunk/reactos/dll/win32/user32/windows/hook.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/h…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/hook.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/hook.c [iso-8859-1] Wed Jul 1 21:19:16 2009
@@ -219,13 +219,13 @@
{
PCWPSTRUCT pCWP = (PCWPSTRUCT)lParam;
- lResult = NtUserMessageCall( pCWP->hwnd,
- pCWP->message,
- pCWP->wParam,
- pCWP->lParam,
- 0,
- FNID_CALLWNDPROC,
- pHook->Ansi);
+ NtUserMessageCall( pCWP->hwnd,
+ pCWP->message,
+ pCWP->wParam,
+ pCWP->lParam,
+ (ULONG_PTR)&lResult,
+ FNID_CALLWNDPROC,
+ pHook->Ansi);
}
else
{
@@ -233,13 +233,13 @@
ClientInfo->dwHookData = pCWPR->lResult;
- lResult = NtUserMessageCall( pCWPR->hwnd,
- pCWPR->message,
- pCWPR->wParam,
- pCWPR->lParam,
- 0,
- FNID_CALLWNDPROCRET,
- pHook->Ansi);
+ NtUserMessageCall( pCWPR->hwnd,
+ pCWPR->message,
+ pCWPR->wParam,
+ pCWPR->lParam,
+ (ULONG_PTR)&lResult,
+ FNID_CALLWNDPROCRET,
+ pHook->Ansi);
}
ClientInfo->CI_flags ^= ((ClientInfo->CI_flags ^ Flags) &
CI_CURTHPRHOOK);
ClientInfo->dwHookData = Save;
@@ -429,8 +429,9 @@
Common = (PHOOKPROC_CALLBACK_ARGUMENTS) Arguments;
switch(Common->HookId)
+ {
+ case WH_CBT:
{
- case WH_CBT:
switch(Common->Code)
{
case HCBT_CREATEWND:
@@ -494,7 +495,6 @@
{
ERR("Common = 0x%x, Proc = 0x%x\n",Common,Common->Proc);
}
-
switch(Common->Code)
{
case HCBT_CREATEWND:
@@ -502,6 +502,7 @@
break;
}
break;
+ }
case WH_KEYBOARD_LL:
KeyboardLlData = (PKBDLLHOOKSTRUCT)((PCHAR) Common + Common->lParam);
Result = Common->Proc(Common->Code, Common->wParam, (LPARAM)
KeyboardLlData);
@@ -536,7 +537,7 @@
break;
default:
return ZwCallbackReturn(NULL, 0, STATUS_NOT_SUPPORTED);
- }
+ }
return ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS);
}
@@ -547,15 +548,15 @@
PEVENTPROC_CALLBACK_ARGUMENTS Common;
Common = (PEVENTPROC_CALLBACK_ARGUMENTS) Arguments;
-
+
Common->Proc(Common->hook,
- Common->event,
+ Common->event,
Common->hwnd,
- Common->idObject,
- Common->idChild,
- Common->dwEventThread,
- Common->dwmsEventTime);
-
+ Common->idObject,
+ Common->idChild,
+ Common->dwEventThread,
+ Common->dwmsEventTime);
+
return ZwCallbackReturn(NULL, 0, STATUS_SUCCESS);
}
Modified: trunk/reactos/dll/win32/user32/windows/message.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/m…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] Wed Jul 1 21:19:16
2009
@@ -1700,6 +1700,74 @@
return Result;
}
+BOOL
+WINAPI
+PostMessageWX(
+ HWND hWnd,
+ UINT Msg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ LRESULT Ret;
+
+ /* Check for combo box or a list box to send names. */
+ if (Msg == CB_DIR || Msg == LB_DIR)
+ {
+ /*
+ Set DDL_POSTMSGS, so use the PostMessage function to send messages to the
+ combo/list box. Forces a call like DlgDirListComboBox.
+ */
+ wParam |= DDL_POSTMSGS;
+ return NtUserPostMessage(hWnd, Msg, wParam, lParam);
+ }
+
+ /* No drop files or current Process, just post message. */
+ if ( (Msg != WM_DROPFILES) ||
+ ( NtUserQueryWindow( hWnd, QUERY_WINDOW_UNIQUE_PROCESS_ID) ==
+ PtrToUint(NtCurrentTeb()->ClientId.UniqueProcess) ) )
+ {
+ return NtUserPostMessage(hWnd, Msg, wParam, lParam);
+ }
+
+ /* We have drop files or this is not the same process for this window. */
+
+ /* Just incase, check wParam for Global memory handle and send size. */
+ Ret = SendMessageW( hWnd,
+ WM_COPYGLOBALDATA,
+ (WPARAM)GlobalSize((HGLOBAL)wParam), // Zero if not a handle.
+ (LPARAM)wParam); // Send wParam as lParam.
+
+ if ( Ret ) return NtUserPostMessage(hWnd, Msg, (WPARAM)Ret, lParam);
+
+ return FALSE;
+}
+BOOL
+WINAPI
+PostMessageAX(
+ HWND hWnd,
+ UINT Msg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ MSG AnsiMsg, UcMsg;
+ BOOL Ret;
+
+ AnsiMsg.hwnd = hWnd;
+ AnsiMsg.message = Msg;
+ AnsiMsg.wParam = wParam;
+ AnsiMsg.lParam = lParam;
+
+ if (!MsgiAnsiToUnicodeMessage(&UcMsg, &AnsiMsg))
+ {
+ return FALSE;
+ }
+
+ Ret = PostMessageWX( hWnd, UcMsg.message, UcMsg.wParam, UcMsg.lParam);
+
+ MsgiAnsiToUnicodeCleanup(&UcMsg, &AnsiMsg);
+
+ return Ret;
+}
/*
* @implemented
@@ -2113,6 +2181,43 @@
return Result;
}
+BOOL
+WINAPI
+SendNotifyMessageAX(
+ HWND hWnd,
+ UINT Msg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ BOOL Ret;
+ MSG AnsiMsg, UcMsg;
+
+ AnsiMsg.hwnd = hWnd;
+ AnsiMsg.message = Msg;
+ AnsiMsg.wParam = wParam;
+ AnsiMsg.lParam = lParam;
+ if (! MsgiAnsiToUnicodeMessage(&UcMsg, &AnsiMsg))
+ {
+ return FALSE;
+ }
+ /* ATM, ReactOS does not support Ansi in win32k. */
+ Ret = NtUserMessageCall(hWnd, UcMsg.message, UcMsg.wParam, UcMsg.lParam, 0,
FNID_SENDNOTIFYMESSAGE, FALSE);
+
+ MsgiAnsiToUnicodeCleanup(&UcMsg, &AnsiMsg);
+
+ return Ret;
+}
+
+BOOL
+WINAPI
+SendNotifyMessageWX(
+ HWND hWnd,
+ UINT Msg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ return NtUserMessageCall(hWnd, Msg, wParam, lParam, 0, FNID_SENDNOTIFYMESSAGE, FALSE);
+}
/*
* @implemented
Modified: trunk/reactos/include/reactos/win32k/callback.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/cal…
==============================================================================
--- trunk/reactos/include/reactos/win32k/callback.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/callback.h [iso-8859-1] Wed Jul 1 21:19:16 2009
@@ -61,9 +61,6 @@
DWORD dwEventThread;
DWORD dwmsEventTime;
WINEVENTPROC Proc;
- BOOLEAN Ansi;
- UINT ModuleNameLength;
- WCHAR ModuleName[1];
} EVENTPROC_CALLBACK_ARGUMENTS, *PEVENTPROC_CALLBACK_ARGUMENTS;
NTSTATUS WINAPI
Modified: trunk/reactos/include/reactos/win32k/ntuser.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntu…
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Wed Jul 1 21:19:16 2009
@@ -268,6 +268,8 @@
#define FNID_IME 0x02A9
#define FNID_CALLWNDPROC 0x02AA
#define FNID_CALLWNDPROCRET 0x02AB
+#define FNID_HKINLPCWPEXSTRUCT 0x02AC
+#define FNID_HKINLPCWPRETEXSTRUCT 0x02AD
#define FNID_SENDMESSAGE 0x02B0
// Kernel has option to use TimeOut or normal msg send, based on type of msg.
#define FNID_SENDMESSAGEWTOOPTION 0x02B1
@@ -308,8 +310,15 @@
#define ICLS_SWITCH 19
#define ICLS_ICONTITLE 20
#define ICLS_TOOLTIPS 21
+#if (_WIN32_WINNT <= 0x0501)
#define ICLS_UNKNOWN 22
#define ICLS_NOTUSED 23
+#else
+#define ICLS_SYSSHADOW 22
+#define ICLS_HWNDMESSAGE 23
+#define ICLS_UNKNOWN 24
+#define ICLS_NOTUSED 25
+#endif
#define ICLS_END 31
#define COLOR_LAST COLOR_MENUBAR
@@ -327,7 +336,7 @@
typedef struct tagMBSTRING
{
- WCHAR szName[15];
+ WCHAR szName[16];
UINT uID;
UINT uStr;
} MBSTRING, *PMBSTRING;
@@ -389,8 +398,8 @@
DWORD dwSRVIFlags;
ULONG_PTR cHandleEntries;
PFN_FNID mpFnidPfn[FNID_NUM];
-// WNDPROC aStoCidPfn[7];
-// USHORT mpFnid_serverCBWndProc[31];
+ WNDPROC aStoCidPfn[7];
+ USHORT mpFnid_serverCBWndProc[FNID_NUM];
PFNCLIENT apfnClientA;
PFNCLIENT apfnClientW;
PFNCLIENTWORKER apfnClientWorker;
@@ -553,6 +562,7 @@
//
// Non SDK Window Message types.
//
+#define WM_COPYGLOBALDATA 73
#define WM_SYSTIMER 280
#define WM_POPUPSYSTEMMENU 787
#define WM_CBT 1023 // ReactOS only.
@@ -1072,6 +1082,18 @@
DWORD dwflags,
LPVOID lParam);
+BOOL
+NTAPI
+NtUserCheckDesktopByThreadId(
+ DWORD dwThreadId);
+
+BOOL
+NTAPI
+NtUserCheckWindowThreadDesktop(
+ HWND hwnd,
+ DWORD dwThreadId,
+ ULONG ReturnValue);
+
DWORD
NTAPI
NtUserCheckImeHotKey(
@@ -1145,11 +1167,11 @@
HDESK
NTAPI
NtUserCreateDesktop(
- PUNICODE_STRING lpszDesktopName,
+ POBJECT_ATTRIBUTES poa,
+ PUNICODE_STRING lpszDesktopDevice,
+ LPDEVMODEW lpdmw,
DWORD dwFlags,
- ACCESS_MASK dwDesiredAccess,
- LPSECURITY_ATTRIBUTES lpSecurity,
- HWINSTA hWindowStation);
+ ACCESS_MASK dwDesiredAccess);
DWORD
NTAPI
@@ -1936,7 +1958,7 @@
UINT transType,
DWORD keyboardId,
HKL dwhkl );
-LRESULT
+BOOL
NTAPI
NtUserMessageCall(
HWND hWnd,
Modified: trunk/reactos/subsystems/win32/win32k/include/desktop.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/desktop.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/desktop.h [iso-8859-1] Wed Jul 1
21:19:16 2009
@@ -28,6 +28,7 @@
PWIN32HEAP pheapDesktop;
PSECTION_OBJECT DesktopHeapSection;
PDESKTOPINFO DesktopInfo;
+ HWND spwndMessage;
} DESKTOP, *PDESKTOP;
extern PDESKTOP InputDesktop;
@@ -134,6 +135,7 @@
&(OBJECT_HEADER_TO_NAME_INFO(OBJECT_TO_OBJECT_HEADER(d))->Name) : \
NULL
+HWND FASTCALL IntGetMessageWindow(VOID);
static __inline PVOID
DesktopHeapAlloc(IN PDESKTOP Desktop,
Modified: trunk/reactos/subsystems/win32/win32k/include/hook.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/hook.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/hook.h [iso-8859-1] Wed Jul 1 21:19:16
2009
@@ -36,8 +36,9 @@
DWORD idProcess;
DWORD idThread;
WINEVENTPROC Proc; /* Event function */
- BOOLEAN Ansi; /* Is it an Ansi event? */
ULONG Flags; /* Some internal flags */
+ ULONG_PTR offPfn;
+ INT ihmod;
UNICODE_STRING ModuleName; /* Module name for global events */
} EVENTHOOK, *PEVENTHOOK;
Modified: trunk/reactos/subsystems/win32/win32k/include/window.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/window.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/window.h [iso-8859-1] Wed Jul 1
21:19:16 2009
@@ -12,6 +12,8 @@
#include <include/dce.h>
#include <include/prop.h>
#include <include/scroll.h>
+
+extern ATOM AtomMessage;
BOOL FASTCALL UserUpdateUiState(PWINDOW Wnd, WPARAM wParam);
@@ -167,8 +169,9 @@
LRESULT FASTCALL
IntDefWindowProc( PWINDOW_OBJECT Window, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL
Ansi);
-VOID FASTCALL IntNotifyWinEvent(DWORD, PWINDOW_OBJECT, 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);
#endif /* _WIN32K_WINDOW_H */
/* EOF */
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/callback.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/callback.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/callback.c [iso-8859-1] Wed Jul 1
21:19:16 2009
@@ -605,6 +605,9 @@
return Result;
}
+//
+// Events are notifications w/o results.
+//
LRESULT
APIENTRY
co_IntCallEventProc(HWINEVENTHOOK hook,
@@ -616,11 +619,11 @@
DWORD dwmsEventTime,
WINEVENTPROC Proc)
{
- LRESULT Result;
+ LRESULT Result = 0;
NTSTATUS Status;
PEVENTPROC_CALLBACK_ARGUMENTS Common;
ULONG ArgumentLength, ResultLength;
- PVOID Argument, ResultPointer, pWnd;
+ PVOID Argument, ResultPointer;
ArgumentLength = sizeof(EVENTPROC_CALLBACK_ARGUMENTS);
@@ -643,8 +646,6 @@
ResultPointer = NULL;
ResultLength = sizeof(LRESULT);
- IntSetTebWndCallback (&hWnd, &pWnd);
-
UserLeaveCo();
Status = KeUserModeCallback(USER32_CALLBACK_EVENTPROC,
@@ -653,12 +654,7 @@
&ResultPointer,
&ResultLength);
- /* Simulate old behaviour: copy into our local buffer */
- Result = *(LRESULT*)ResultPointer;
-
UserEnterCo();
-
- IntRestoreTebWndCallback (hWnd, pWnd);
IntCbFreeMemory(Argument);
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c [iso-8859-1] Wed Jul 1
21:19:16 2009
@@ -556,6 +556,17 @@
return UserGetWindowObject(pdo->DesktopWindow);
}
+HWND FASTCALL IntGetMessageWindow(VOID)
+{
+ PDESKTOP pdo = IntGetActiveDesktop();
+
+ if (!pdo)
+ {
+ DPRINT("No active desktop\n");
+ return NULL;
+ }
+ return pdo->spwndMessage;
+}
HWND FASTCALL IntGetCurrentThreadDesktopWindow(VOID)
{
@@ -829,8 +840,14 @@
* Creates a new desktop.
*
* Parameters
- * lpszDesktopName
- * Name of the new desktop.
+ * poaAttribs
+ * Object Attributes.
+ *
+ * lpszDesktopDevice
+ * Name of the device.
+ *
+ * pDeviceMode
+ * Device Mode.
*
* dwFlags
* Interaction flags.
@@ -838,11 +855,6 @@
* dwDesiredAccess
* Requested type of access.
*
- * lpSecurity
- * Security descriptor.
- *
- * hWindowStation
- * Handle to window station on which to create the desktop.
*
* Return Value
* If the function succeeds, the return value is a handle to the newly
@@ -857,17 +869,19 @@
HDESK APIENTRY
NtUserCreateDesktop(
- PUNICODE_STRING lpszDesktopName,
+ POBJECT_ATTRIBUTES poa,
+ PUNICODE_STRING lpszDesktopDevice,
+ LPDEVMODEW lpdmw,
DWORD dwFlags,
- ACCESS_MASK dwDesiredAccess,
- LPSECURITY_ATTRIBUTES lpSecurity,
- HWINSTA hWindowStation)
+ ACCESS_MASK dwDesiredAccess)
{
OBJECT_ATTRIBUTES ObjectAttributes;
+ PTHREADINFO W32Thread;
+// HWND hwndMessage;
PWINSTATION_OBJECT WinStaObject;
PDESKTOP DesktopObject;
UNICODE_STRING DesktopName;
- NTSTATUS Status;
+ NTSTATUS Status = STATUS_SUCCESS;
HDESK Desktop;
CSR_API_MESSAGE Request;
PVOID DesktopHeapSystemBase = NULL;
@@ -875,11 +889,35 @@
UNICODE_STRING SafeDesktopName;
ULONG DummyContext;
ULONG_PTR HeapSize = 4 * 1024 * 1024; /* FIXME */
+ HWINSTA hWindowStation = NULL ;
+ PUNICODE_STRING lpszDesktopName = NULL;
+// UNICODE_STRING AtomName;
DECLARE_RETURN(HDESK);
-
DPRINT("Enter NtUserCreateDesktop: %wZ\n", lpszDesktopName);
UserEnterExclusive();
+
+ _SEH2_TRY
+ {
+ ProbeForRead( poa,
+ sizeof(OBJECT_ATTRIBUTES),
+ 1);
+
+ hWindowStation = poa->RootDirectory;
+ lpszDesktopName = poa->ObjectName;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status =_SEH2_GetExceptionCode();
+ }
+ _SEH2_END
+
+ if (! NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed reading Object Attributes from user space.\n");
+ SetLastNtError(Status);
+ RETURN( NULL);
+ }
Status = IntValidateWindowStationHandle(
hWindowStation,
@@ -1037,6 +1075,52 @@
RETURN( NULL);
}
+ W32Thread = PsGetCurrentThreadWin32Thread();
+
+ if (!W32Thread->Desktop) IntSetThreadDesktop(DesktopObject,FALSE);
+
+#if 0
+ /*
+ Based on wine/server/window.c line 1804 in get_desktop_window.
+ We create an atom to be used for create desktop to create
+ the message window.
+ */
+ // FIXME!
+ // ReactOS CreateWindow does not know how to correctly use Atom Classes.
+ // So we have this HAX!
+ { // Warning! HACK! Yes it is very wrong!
+
+ // Normally, this would have been performed during the win32k init phase.
+ // AtomMessage = IntAddGlobalAtom(L"Message", TRUE); // <- correct, but
should be in ntuser.c
+
+ AtomMessage =
+ }
+ AtomName.Buffer = ((PWSTR)((ULONG_PTR)(WORD)(AtomMessage)));
+ AtomName.Length = 0;
+
+ hwndMessage = co_IntCreateWindowEx( 0,
+ &AtomName,
+ NULL,
+ (WS_POPUP|WS_CLIPCHILDREN),
+ 0,
+ 0,
+ 100,
+ 100,
+ NULL,
+ NULL,
+ NULL,//hModuleWin, // pi->hModUser; ? no!
+ NULL,
+ 0,
+ TRUE);
+ if (!hwndMessage)
+ {
+ DPRINT1("Failed to create Message window handle\n");
+ }
+ else
+ {
+ DesktopObject->spwndMessage = hwndMessage;
+ }
+#endif
RETURN( Desktop);
CLEANUP:
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/event.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/event.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/event.c [iso-8859-1] Wed Jul 1 21:19:16
2009
@@ -165,14 +165,14 @@
FASTCALL
IntNotifyWinEvent(
DWORD Event,
- PWINDOW_OBJECT Window,
+ HWND hWnd,
LONG idObject,
LONG idChild)
{
PEVENTHOOK pEH;
LRESULT Result;
- if (!GlobalEvents->Counts) return;
+ if (!GlobalEvents || !GlobalEvents->Counts) return;
pEH = (PEVENTHOOK)GlobalEvents->Events.Flink;
@@ -187,7 +187,7 @@
if (!(pEH->idProcess) || !(pEH->idThread) ||
(NtCurrentTeb()->ClientId.UniqueProcess == (PVOID)pEH->idProcess))
{
- Result = IntCallLowLevelEvent(pEH, Event, Window->hSelf, idObject,
idChild);
+ Result = IntCallLowLevelEvent(pEH, Event, hWnd, idObject, idChild);
}
}// if ^skip own thread && ((Pid && CPid == Pid && ^skip
own process) || all process)
else if ( !(pEH->Flags & WINEVENT_SKIPOWNTHREAD) &&
@@ -198,7 +198,7 @@
{
Result = co_IntCallEventProc( pEH->Self,
Event,
- Window->hSelf,
+ hWnd,
idObject,
idChild,
PtrToUint(NtCurrentTeb()->ClientId.UniqueThread),
@@ -234,7 +234,7 @@
if (gpsi->dwInstalledEventHooks & GetMaskFromEvent(Event))
{
UserRefObjectCo(Window, &Ref);
- IntNotifyWinEvent( Event, Window, idObject, idChild);
+ IntNotifyWinEvent( Event, Window->hSelf, idObject, idChild);
UserDerefObjectCo(Window);
}
UserLeave();
@@ -259,6 +259,8 @@
HANDLE Handle;
PETHREAD Thread = NULL;
+ DPRINT("NtUserSetWinEventHook hmod 0x%x, pfn 0x%x\n",hmodWinEventProc,
lpfnWinEventProc);
+
UserEnterExclusive();
if ( !GlobalEvents )
@@ -316,7 +318,6 @@
pEH->eventMax = eventMax;
pEH->idProcess = idProcess;
pEH->idThread = idThread;
- pEH->Ansi = FALSE;
pEH->Flags = dwflags;
@@ -363,7 +364,9 @@
pEH->ModuleName.Length = ModuleName.Length;
- pEH->Proc = (void *)((char *)lpfnWinEventProc - (char *)hmodWinEventProc);
+ pEH->offPfn = (ULONG_PTR)((char *)lpfnWinEventProc - (char
*)hmodWinEventProc);
+ pEH->ihmod = (INT)hmodWinEventProc;
+ pEH->Proc = lpfnWinEventProc;
}
else
pEH->Proc = lpfnWinEventProc;
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] Wed Jul 1
21:19:16 2009
@@ -154,6 +154,10 @@
case WM_COPYDATA:
Size = sizeof(COPYDATASTRUCT) + ((PCOPYDATASTRUCT)lParam)->cbData;
+ break;
+
+ case WM_COPYGLOBALDATA:
+ Size = wParam;
break;
default:
@@ -2023,7 +2027,7 @@
}
-LRESULT APIENTRY
+BOOL APIENTRY
NtUserMessageCall(
HWND hWnd,
UINT Msg,
@@ -2034,6 +2038,8 @@
BOOL Ansi)
{
LRESULT lResult = 0;
+ BOOL Ret = FALSE;
+ BOOL BadChk = FALSE;
PWINDOW_OBJECT Window = NULL;
USER_REFERENCE_ENTRY Ref;
@@ -2043,21 +2049,23 @@
if (hWnd && (hWnd != INVALID_HANDLE_VALUE) && !(Window =
UserGetWindowObject(hWnd)))
{
UserLeave();
- return 0;
+ return FALSE;
}
switch(dwType)
{
case FNID_DEFWINDOWPROC:
UserRefObjectCo(Window, &Ref);
lResult = IntDefWindowProc(Window, Msg, wParam, lParam, Ansi);
+ Ret = TRUE;
UserDerefObjectCo(Window);
break;
+ case FNID_SENDNOTIFYMESSAGE:
+ Ret = UserSendNotifyMessage(hWnd, Msg, wParam, lParam);
+ break;
case FNID_BROADCASTSYSTEMMESSAGE:
{
PBROADCASTPARM parm;
- BOOL BadChk = FALSE;
DWORD_PTR RetVal = 0;
- lResult = -1;
if (ResultInfo)
{
@@ -2119,11 +2127,11 @@
}
else if (parm->flags & BSF_POSTMESSAGE)
{
- lResult = UserPostMessage(HWND_BROADCAST, Msg, wParam, lParam);
+ Ret = UserPostMessage(HWND_BROADCAST, Msg, wParam, lParam);
}
else if ( parm->flags & BSF_SENDNOTIFYMESSAGE)
{
- lResult = UserSendNotifyMessage(HWND_BROADCAST, Msg, wParam, lParam);
+ Ret = UserSendNotifyMessage(HWND_BROADCAST, Msg, wParam, lParam);
}
}
}
@@ -2189,8 +2197,33 @@
}
break;
}
+
+ switch(dwType)
+ {
+ case FNID_DEFWINDOWPROC:
+ case FNID_CALLWNDPROC:
+ case FNID_CALLWNDPROCRET:
+ if (ResultInfo)
+ {
+ _SEH2_TRY
+ {
+ ProbeForWrite((PVOID)ResultInfo, sizeof(LRESULT), 1);
+ RtlCopyMemory((PVOID)ResultInfo, &lResult, sizeof(LRESULT));
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ BadChk = TRUE;
+ }
+ _SEH2_END;
+ }
+ break;
+ default:
+ break;
+ }
+
UserLeave();
- return lResult;
+
+ return BadChk ? FALSE : Ret;
}
#define INFINITE 0xFFFFFFFF
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/ntuser.c [iso-8859-1] Wed Jul 1 21:19:16
2009
@@ -34,6 +34,7 @@
#include <debug.h>
ERESOURCE UserLock;
+ATOM AtomMessage; // Window Message atom.
BOOL gbInitialized;
BOOL
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Wed Jul 1 21:19:16
2009
@@ -392,6 +392,8 @@
BelongsToThreadData = IntWndBelongsToThread(Window, ThreadData);
IntDeRegisterShellHookWindow(Window->hSelf);
+
+ IntNotifyWinEvent(EVENT_OBJECT_DESTROY, Window->hSelf, OBJID_WINDOW, 0);
if(SendMessages)
{
@@ -1552,7 +1554,7 @@
RTL_ATOM ClassAtom;
PWINDOW_OBJECT Window = NULL;
PWINDOW_OBJECT ParentWindow = NULL, OwnerWindow;
- HWND ParentWindowHandle;
+ HWND ParentWindowHandle = NULL;
HWND OwnerWindowHandle;
PMENU_OBJECT SystemMenu;
HWND hWnd;
@@ -1576,7 +1578,12 @@
PTHREADINFO pti;
pti = PsGetCurrentThreadWin32Thread();
- ParentWindowHandle = pti->Desktop->DesktopWindow;
+
+ if (pti->Desktop)
+ {
+ ParentWindowHandle = pti->Desktop->DesktopWindow;
+ }
+
OwnerWindowHandle = NULL;
if (hWndParent == HWND_MESSAGE)
@@ -1585,8 +1592,8 @@
* native ole32.OleInitialize uses HWND_MESSAGE to create the
* message window (style: WS_POPUP|WS_DISABLED)
*/
- DPRINT("FIXME - Parent is HWND_MESSAGE\n");
- // ParentWindowHandle set already.
+ DPRINT1("FIXME - Parent is HWND_MESSAGE\n");
+ // ParentWindowHandle = IntGetMessageWindow();
}
else if (hWndParent)
{
@@ -1605,16 +1612,16 @@
RETURN( (HWND)0); /* WS_CHILD needs a parent, but WS_POPUP doesn't */
}
-// if (NULL != ParentWindowHandle)
-// {
- ParentWindow = UserGetWindowObject(ParentWindowHandle);
-
- if (ParentWindow) UserRefObjectCo(ParentWindow, &ParentRef);
-// }
-// else
-// {
-// ParentWindow = NULL;
-// }
+ if (ParentWindowHandle)
+ {
+ ParentWindow = UserGetWindowObject(ParentWindowHandle);
+
+ if (ParentWindow) UserRefObjectCo(ParentWindow, &ParentRef);
+ }
+ else
+ {
+ ParentWindow = NULL;
+ }
/* FIXME: parent must belong to the current process */
@@ -2123,17 +2130,9 @@
IntUnlinkWindow(Window);
RETURN((HWND)0);
}
-#if 0
- Result = IntNotifyWinEvent(EVENT_OBJECT_CREATE, Window, OBJID_WINDOW, 0);
-
- if (Result == (LRESULT)-1)
- {
- /* FIXME: Cleanup. */
- DPRINT1("IntCreateWindowEx(): event CREATE hook failed. No cleanup
performed!\n");
- IntUnlinkWindow(Window);
- RETURN((HWND)0);
- }
-#endif
+
+ IntNotifyWinEvent(EVENT_OBJECT_CREATE, Window->hSelf, OBJID_WINDOW, 0);
+
/* Send move and size messages. */
if (!(Window->Flags & WINDOWOBJECT_NEED_SIZE))
{
@@ -2417,6 +2416,12 @@
return FALSE;
}
+ /* Call hooks */
+ if (ISITHOOKED(WH_CBT))
+ {
+ if (co_HOOK_CallHooks(WH_CBT, HCBT_DESTROYWND, (WPARAM) hWnd, 0)) return FALSE;
+ }
+
/* Look whether the focus is within the tree of windows we will
* be destroying.
*/
@@ -2436,11 +2441,6 @@
Window->MessageQueue->CaptureWindow = NULL;
IntDereferenceMessageQueue(Window->MessageQueue);
- /* Call hooks */
- if (ISITHOOKED(WH_CBT))
- {
- if (co_HOOK_CallHooks(WH_CBT, HCBT_DESTROYWND, (WPARAM) hWnd, 0)) return FALSE;
- }
IntEngWindowChanged(Window, WOC_DELETE);
isChild = (0 != (Wnd->Style & WS_CHILD));
@@ -3224,6 +3224,18 @@
DPRINT("Enter NtUserSetParent\n");
UserEnterExclusive();
+
+ /*
+ Check Parent first from user space, set it here.
+ */
+ if (!hWndNewParent)
+ {
+ hWndNewParent = IntGetDesktopWindow();
+ }
+ else if (hWndNewParent == HWND_MESSAGE)
+ {
+ // hWndNewParent = IntGetMessageWindow();
+ }
RETURN( co_UserSetParent(hWndChild, hWndNewParent));