From fc65d4400f5075e993787b8bc6c1840ad59bfc7e Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sat, 20 Nov 2010 22:05:42 +0000 Subject: [PATCH 01/75] [NTDLL] - Fix LdrVerifyImageMatchesChecksum() prototype. svn path=/trunk/; revision=49676 --- reactos/dll/ntdll/ldr/utils.c | 6 +++--- reactos/include/ndk/umfuncs.h | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/reactos/dll/ntdll/ldr/utils.c b/reactos/dll/ntdll/ldr/utils.c index 1cfb8c85505..4b085391e92 100644 --- a/reactos/dll/ntdll/ldr/utils.c +++ b/reactos/dll/ntdll/ldr/utils.c @@ -3236,9 +3236,9 @@ LdrpGetResidentSize(PIMAGE_NT_HEADERS NTHeaders) */ NTSTATUS NTAPI LdrVerifyImageMatchesChecksum (IN HANDLE FileHandle, - ULONG Unknown1, - ULONG Unknown2, - ULONG Unknown3) + IN PLDR_CALLBACK Callback, + IN PVOID CallbackContext, + OUT PUSHORT ImageCharacterstics) { FILE_STANDARD_INFORMATION FileInfo; IO_STATUS_BLOCK IoStatusBlock; diff --git a/reactos/include/ndk/umfuncs.h b/reactos/include/ndk/umfuncs.h index 4cbee159ca7..a3721733e3a 100644 --- a/reactos/include/ndk/umfuncs.h +++ b/reactos/include/ndk/umfuncs.h @@ -295,13 +295,14 @@ LdrUnloadDll( IN PVOID BaseAddress ); +typedef VOID NTAPI (*PLDR_CALLBACK)(PVOID CallbackContext, PVOID Name); NTSTATUS NTAPI LdrVerifyImageMatchesChecksum( IN HANDLE FileHandle, - ULONG Unknown1, - ULONG Unknown2, - ULONG Unknown3 + IN PLDR_CALLBACK Callback, + IN PVOID CallbackContext, + OUT PUSHORT ImageCharacterstics ); #endif From 2b6a79d9c9a474eface435b40c64252a7464cecb Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 21 Nov 2010 16:04:52 +0000 Subject: [PATCH 02/75] =?UTF-8?q?[NTOSKRNL]=20Previously,=20in=20ReactOS'?= =?UTF-8?q?=20stories:=20ReactOS=20was=20broken=20since=20more=20a=20hundr?= =?UTF-8?q?ed=20of=20commits=20when=20two=20devs=20decided=20it=20was=20en?= =?UTF-8?q?ough.=20One=20(we=20will=20name=20him=20Timo)=20fixed=20the=20c?= =?UTF-8?q?ontext=20switch.=20The=20second,=20with=20the=20help=20of=20a?= =?UTF-8?q?=20third=20dev=20(Pierre=20&=20Herv=C3=A9)=20decided=20to=20run?= =?UTF-8?q?=20tests=20by=20disabling=20some=20stuff=20(ie=20INIT=5FFUNCTIO?= =?UTF-8?q?N).=20This=20magically=20made=20testbot=20going=20back=20to=20l?= =?UTF-8?q?ife.=20But,=20some=20complains=20came=20from=20the=20ML,=20so?= =?UTF-8?q?=20trying=20to=20appease=20world,=20Pierre=20decided=20to=20rev?= =?UTF-8?q?ert=20half=20of=20his=20changes,=20thinking=20this=20would=20be?= =?UTF-8?q?=20OK.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ~~ Now, after a night. It appears that half revert was a pretty bad idea. Testbot keeps being broken. So, this commit reverts r49665 (which was half reverting r49662). That way, testbot should be back, able to run tests. BUT, due to a NPFS issue, some tests are broken. Eric has been nicely mailed about that issue, with an idea of fix (thanks go here to Aleksey). ~~ For those who like that, drama to follow on ML. I turn into being S/M... svn path=/trunk/; revision=49691 --- reactos/ntoskrnl/include/internal/ntoskrnl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/include/internal/ntoskrnl.h b/reactos/ntoskrnl/include/internal/ntoskrnl.h index e4b8bd6b9ab..ceb4800423f 100644 --- a/reactos/ntoskrnl/include/internal/ntoskrnl.h +++ b/reactos/ntoskrnl/include/internal/ntoskrnl.h @@ -5,7 +5,7 @@ */ #define PLACE_IN_SECTION(s) __attribute__((section (s))) #ifdef __GNUC__ -#define INIT_FUNCTION PLACE_IN_SECTION("INIT") +#define INIT_FUNCTION #define PAGE_LOCKED_FUNCTION PLACE_IN_SECTION("pagelk") #define PAGE_UNLOCKED_FUNCTION PLACE_IN_SECTION("pagepo") #else From 8b5175e0abc1ba98981bb17e40d7e7a6fd7fba8f Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 21 Nov 2010 23:15:11 +0000 Subject: [PATCH 03/75] [NPFS/KERNEL32] Switch back to the old pipe wait code but keep the new code in place (disabled). svn path=/trunk/; revision=49701 --- reactos/dll/win32/kernel32/file/npipe.c | 101 +++++++++++++++++++++- reactos/drivers/filesystems/npfs/create.c | 26 ++++-- reactos/drivers/filesystems/npfs/fsctrl.c | 18 +++- 3 files changed, 137 insertions(+), 8 deletions(-) diff --git a/reactos/dll/win32/kernel32/file/npipe.c b/reactos/dll/win32/kernel32/file/npipe.c index 7112ffbcbda..629b69b678f 100644 --- a/reactos/dll/win32/kernel32/file/npipe.c +++ b/reactos/dll/win32/kernel32/file/npipe.c @@ -14,7 +14,7 @@ #include DEBUG_CHANNEL(kernel32file); -#define USING_PROPER_NPFS_WAIT_SEMANTICS +//#define USING_PROPER_NPFS_WAIT_SEMANTICS /* FUNCTIONS ****************************************************************/ @@ -264,6 +264,16 @@ WaitNamedPipeA(LPCSTR lpNamedPipeName, } +/* + * When NPFS will work properly, use this code instead. It is compatible with + * Microsoft's NPFS.SYS. The main difference is that: + * - This code actually respects the timeout instead of ignoring it! + * - This code validates and creates the proper names for both UNC and local pipes + * - On NT, you open the *root* pipe directory (either \DosDevices\Pipe or + * \DosDevices\Unc\Server\Pipe) and then send the pipe to wait on in the + * FILE_PIPE_WAIT_FOR_BUFFER structure. + */ +#ifdef USING_PROPER_NPFS_WAIT_SEMANTICS /* * @implemented */ @@ -448,6 +458,95 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName, /* Success */ return TRUE; } +#else +/* + * @implemented + */ +BOOL +WINAPI +WaitNamedPipeW(LPCWSTR lpNamedPipeName, + DWORD nTimeOut) +{ + UNICODE_STRING NamedPipeName; + NTSTATUS Status; + OBJECT_ATTRIBUTES ObjectAttributes; + FILE_PIPE_WAIT_FOR_BUFFER WaitPipe; + HANDLE FileHandle; + IO_STATUS_BLOCK Iosb; + + if (RtlDosPathNameToNtPathName_U(lpNamedPipeName, + &NamedPipeName, + NULL, + NULL) == FALSE) + { + return FALSE; + } + + InitializeObjectAttributes(&ObjectAttributes, + &NamedPipeName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = NtOpenFile(&FileHandle, + FILE_READ_ATTRIBUTES | SYNCHRONIZE, + &ObjectAttributes, + &Iosb, + FILE_SHARE_READ | FILE_SHARE_WRITE, + FILE_SYNCHRONOUS_IO_NONALERT); + if (!NT_SUCCESS(Status)) + { + SetLastErrorByStatus(Status); + RtlFreeUnicodeString(&NamedPipeName); + return FALSE; + } + + /* Check what timeout we got */ + if (nTimeOut == NMPWAIT_USE_DEFAULT_WAIT) + { + /* Don't use a timeout */ + WaitPipe.TimeoutSpecified = FALSE; + } + else + { + /* Check if we should wait forever */ + if (nTimeOut == NMPWAIT_WAIT_FOREVER) + { + /* Set the max */ + WaitPipe.Timeout.LowPart = 0; + WaitPipe.Timeout.HighPart = 0x80000000; + } + else + { + /* Convert to NT format */ + WaitPipe.Timeout.QuadPart = UInt32x32To64(-10000, nTimeOut); + } + + /* In both cases, we do have a timeout */ + WaitPipe.TimeoutSpecified = TRUE; + } + + Status = NtFsControlFile(FileHandle, + NULL, + NULL, + NULL, + &Iosb, + FSCTL_PIPE_WAIT, + &WaitPipe, + sizeof(WaitPipe), + NULL, + 0); + NtClose(FileHandle); + if (!NT_SUCCESS(Status)) + { + SetLastErrorByStatus(Status); + RtlFreeUnicodeString(&NamedPipeName); + return FALSE; + } + + RtlFreeUnicodeString(&NamedPipeName); + return TRUE; +} +#endif /* diff --git a/reactos/drivers/filesystems/npfs/create.c b/reactos/drivers/filesystems/npfs/create.c index 0462003f97e..dbcbaa1bd73 100644 --- a/reactos/drivers/filesystems/npfs/create.c +++ b/reactos/drivers/filesystems/npfs/create.c @@ -13,6 +13,8 @@ #define NDEBUG #include +//#define USING_PROPER_NPFS_WAIT_SEMANTICS + /* FUNCTIONS *****************************************************************/ PNPFS_FCB @@ -146,6 +148,9 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject, PNPFS_VCB Vcb; ACCESS_MASK DesiredAccess; NTSTATUS Status; +#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS + BOOLEAN SpecialAccess; +#endif DPRINT("NpfsCreate(DeviceObject %p Irp %p)\n", DeviceObject, Irp); @@ -161,6 +166,14 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject, Irp->IoStatus.Information = 0; +#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS + SpecialAccess = ((DesiredAccess & SPECIFIC_RIGHTS_ALL) == FILE_READ_ATTRIBUTES); + if (SpecialAccess) + { + DPRINT("NpfsCreate() open client end for special use!\n"); + } +#endif + if (FileName->Length == 2 && FileName->Buffer[0] == L'\\' && RelatedFileObject == NULL) { DPRINT("Open the root directory\n"); @@ -217,8 +230,11 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject, ClientCcb->Fcb = Fcb; ClientCcb->PipeEnd = FILE_PIPE_CLIENT_END; ClientCcb->OtherSide = NULL; -// ClientCcb->PipeState = SpecialAccess ? 0 : FILE_PIPE_DISCONNECTED_STATE; +#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS + ClientCcb->PipeState = SpecialAccess ? 0 : FILE_PIPE_DISCONNECTED_STATE; +#else ClientCcb->PipeState = FILE_PIPE_DISCONNECTED_STATE; +#endif InitializeListHead(&ClientCcb->ReadRequestListHead); DPRINT("CCB: %p\n", ClientCcb); @@ -256,10 +272,10 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject, /* * Step 3. Search for listening server CCB. */ -/* +#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS if (!SpecialAccess) { -*/ +#endif /* * WARNING: Point of no return! Once we get the server CCB it's * possible that we completed a wait request and so we have to @@ -315,7 +331,7 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject, /* FIXME: Merge this with the NpfsFindListeningServerInstance routine. */ NpfsSignalAndRemoveListeningServerInstance(Fcb, ServerCcb); } -/* +#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS } else if (IsListEmpty(&Fcb->ServerCcbListHead)) { @@ -333,7 +349,7 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject, IoCompleteRequest(Irp, IO_NO_INCREMENT); return STATUS_UNSUCCESSFUL; } -*/ +#endif /* * Step 4. Add the client CCB to a list and connect it if possible. diff --git a/reactos/drivers/filesystems/npfs/fsctrl.c b/reactos/drivers/filesystems/npfs/fsctrl.c index c177969f850..9055bb1f902 100644 --- a/reactos/drivers/filesystems/npfs/fsctrl.c +++ b/reactos/drivers/filesystems/npfs/fsctrl.c @@ -15,6 +15,8 @@ #define NDEBUG #include +//#define USING_PROPER_NPFS_WAIT_SEMANTICS + /* FUNCTIONS *****************************************************************/ static DRIVER_CANCEL NpfsListeningCancelRoutine; @@ -293,18 +295,21 @@ NpfsWaitPipe(PIRP Irp, PNPFS_CCB Ccb) { PLIST_ENTRY current_entry; - PNPFS_VCB Vcb; PNPFS_FCB Fcb; PNPFS_CCB ServerCcb; PFILE_PIPE_WAIT_FOR_BUFFER WaitPipe; LARGE_INTEGER TimeOut; - UNICODE_STRING PipeName; NTSTATUS Status; +#ifdef USING_PROPER_NPFS_WAIT_SEMANTICS + PNPFS_VCB Vcb; + UNICODE_STRING PipeName; +#endif DPRINT("NpfsWaitPipe\n"); WaitPipe = (PFILE_PIPE_WAIT_FOR_BUFFER)Irp->AssociatedIrp.SystemBuffer; +#ifdef USING_PROPER_NPFS_WAIT_SEMANTICS /* Fail, if the CCB does not represent the root directory */ if (Ccb->Type != CCB_DIRECTORY) return STATUS_ILLEGAL_FUNCTION; @@ -352,6 +357,15 @@ NpfsWaitPipe(PIRP Irp, } DPRINT("Fcb %p\n", Fcb); +#else + Fcb = Ccb->Fcb; + + if (Ccb->PipeState != 0) + { + DPRINT("Pipe is not in passive (waiting) state!\n"); + return STATUS_UNSUCCESSFUL; + } +#endif /* search for listening server */ current_entry = Fcb->ServerCcbListHead.Flink; From 9b693d8c6901c2a1d442f00a25ff16870d7ce4b0 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Mon, 22 Nov 2010 20:10:56 +0000 Subject: [PATCH 04/75] [win32k] - Fix one of the greatest hacks in message handling: do not wake up every message queue when there is mouse or keyboard input ( wake only the thread that must take input) - rewrite co_WinPosWindowFromPoint, co_MsqInsertMouseMessage and co_MsqPeekHardwareMessage - port co_IntProcessMouseMessage and MsqSendParentNotify from wine - call co_IntProcessHardwareMessage from co_MsqPeekHardwareMessage, and not from co_IntPeekMessage - move co_IntProcessHardwareMessage, co_IntProcessKeyboardMessage and co_IntProcessMouseMessage to msgqueue.c svn path=/trunk/; revision=49710 --- .../win32/win32k/include/msgqueue.h | 35 +- .../subsystems/win32/win32k/include/winpos.h | 5 +- .../subsystems/win32/win32k/ntuser/message.c | 407 +------ .../subsystems/win32/win32k/ntuser/msgqueue.c | 1044 ++++++++--------- .../subsystems/win32/win32k/ntuser/window.c | 3 +- .../subsystems/win32/win32k/ntuser/winpos.c | 199 ++-- 6 files changed, 573 insertions(+), 1120 deletions(-) diff --git a/reactos/subsystems/win32/win32k/include/msgqueue.h b/reactos/subsystems/win32/win32k/include/msgqueue.h index 621195ca562..6bda51dc7ed 100644 --- a/reactos/subsystems/win32/win32k/include/msgqueue.h +++ b/reactos/subsystems/win32/win32k/include/msgqueue.h @@ -58,8 +58,12 @@ typedef struct _USER_MESSAGE_QUEUE LIST_ENTRY HardwareMessagesListHead; /* Lock for the hardware message list. */ KMUTEX HardwareLock; - /* Pointer to the current WM_MOUSEMOVE message */ - PUSER_MESSAGE MouseMoveMsg; + /* True if a WM_MOUSEMOVE is pending */ + BOOLEAN MouseMoved; + /* Current WM_MOUSEMOVE message */ + MSG MouseMoveMsg; + /* Last click message for translating double clicks */ + MSG msgDblClk; /* True if a WM_QUIT message is pending. */ BOOLEAN QuitPosted; /* The quit exit code. */ @@ -122,18 +126,25 @@ VOID FASTCALL MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue, ULONG ExitCode); BOOLEAN APIENTRY MsqPeekMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, - IN BOOLEAN Remove, - IN PWND Window, - IN UINT MsgFilterLow, - IN UINT MsgFilterHigh, - OUT PMSG Message); + IN BOOLEAN Remove, + IN PWND Window, + IN UINT MsgFilterLow, + IN UINT MsgFilterHigh, + OUT PMSG Message); BOOL APIENTRY co_MsqPeekHardwareMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, - IN BOOL Remove, - IN PWND Window, - IN UINT MsgFilterLow, - IN UINT MsgFilterHigh, - OUT MSG* pMsg); + IN BOOL Remove, + IN PWND Window, + IN UINT MsgFilterLow, + IN UINT MsgFilterHigh, + OUT MSG* pMsg); +BOOL APIENTRY +co_MsqPeekMouseMove(IN PUSER_MESSAGE_QUEUE MessageQueue, + IN BOOL Remove, + IN PWND Window, + IN UINT MsgFilterLow, + IN UINT MsgFilterHigh, + OUT MSG* pMsg); BOOLEAN FASTCALL MsqInitializeMessageQueue(struct _ETHREAD *Thread, PUSER_MESSAGE_QUEUE MessageQueue); VOID FASTCALL diff --git a/reactos/subsystems/win32/win32k/include/winpos.h b/reactos/subsystems/win32/win32k/include/winpos.h index cee93ab0465..b21b9107616 100644 --- a/reactos/subsystems/win32/win32k/include/winpos.h +++ b/reactos/subsystems/win32/win32k/include/winpos.h @@ -27,9 +27,8 @@ BOOLEAN FASTCALL co_WinPosShowWindow(PWND Window, INT Cmd); void FASTCALL co_WinPosSendSizeMove(PWND Window); -USHORT FASTCALL -co_WinPosWindowFromPoint(PWND ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint, - PWND* Window); +PWND FASTCALL +co_WinPosWindowFromPoint(PWND ScopeWin, POINT *WinPoint, USHORT* HitTest); VOID FASTCALL co_WinPosActivateOtherWindow(PWND Window); VOID FASTCALL WinPosInitInternalPos(PWND WindowObject, diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 8cabf9fbdf2..89ad044b9e1 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -502,387 +502,6 @@ IntDispatchMessage(PMSG pMsg) return retval; } -VOID FASTCALL -co_IntSendHitTestMessages(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg) -{ - if(!Msg->hwnd || ThreadQueue->CaptureWindow) - { - return; - } - - switch(Msg->message) - { - case WM_MOUSEMOVE: - { - co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message)); - break; - } - case WM_NCMOUSEMOVE: - { - co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message)); - break; - } - case WM_LBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_XBUTTONDOWN: - case WM_LBUTTONDBLCLK: - case WM_MBUTTONDBLCLK: - case WM_RBUTTONDBLCLK: - case WM_XBUTTONDBLCLK: - { - WPARAM wParam; - PSYSTEM_CURSORINFO CurInfo; - CurInfo = IntGetSysCursorInfo(); - - wParam = (WPARAM)(CurInfo->ButtonsDown); - - co_IntSendMessage(Msg->hwnd, WM_MOUSEMOVE, wParam, Msg->lParam); - co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message)); - break; - } - case WM_NCLBUTTONDOWN: - case WM_NCMBUTTONDOWN: - case WM_NCRBUTTONDOWN: - case WM_NCXBUTTONDOWN: - case WM_NCLBUTTONDBLCLK: - case WM_NCMBUTTONDBLCLK: - case WM_NCRBUTTONDBLCLK: - case WM_NCXBUTTONDBLCLK: - { - co_IntSendMessage(Msg->hwnd, WM_NCMOUSEMOVE, (WPARAM)Msg->wParam, Msg->lParam); - co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message)); - break; - } - } -} - -BOOL FASTCALL -co_IntActivateWindowMouse( PUSER_MESSAGE_QUEUE ThreadQueue, - LPMSG Msg, - PWND MsgWindow, - USHORT *HitTest) -{ - ULONG Result; - PWND Parent; - - ASSERT_REFS_CO(MsgWindow); - - if(*HitTest == (USHORT)HTTRANSPARENT) - { - /* eat the message, search again! */ - return TRUE; - } - - Parent = IntGetParent(MsgWindow);//fixme: deref retval? - - /* If no parent window, pass MsgWindows HWND as wParam. Fixes bug #3111 */ - Result = co_IntSendMessage(MsgWindow->head.h, - WM_MOUSEACTIVATE, - (WPARAM) (Parent ? Parent->head.h : MsgWindow->head.h), - (LPARAM)MAKELONG(*HitTest, Msg->message) - ); - - switch (Result) - { - case MA_NOACTIVATEANDEAT: - return TRUE; - case MA_NOACTIVATE: - break; - case MA_ACTIVATEANDEAT: - co_IntMouseActivateWindow(MsgWindow); - return TRUE; - default: - /* MA_ACTIVATE */ - co_IntMouseActivateWindow(MsgWindow); - break; - } - - return FALSE; -} - -BOOL FASTCALL -co_IntTranslateMouseMessage( PUSER_MESSAGE_QUEUE ThreadQueue, - LPMSG Msg, - USHORT *HitTest, - BOOL Remove) -{ - PWND Window; - USER_REFERENCE_ENTRY Ref, DesktopRef; - - if(!(Window = UserGetWindowObject(Msg->hwnd))) - { - /* let's just eat the message?! */ - return TRUE; - } - - *HitTest = HTCLIENT; - - UserRefObjectCo(Window, &Ref); - - if ( ThreadQueue == Window->head.pti->MessageQueue && - ThreadQueue->CaptureWindow != Window->head.h) - { - /* only send WM_NCHITTEST messages if we're not capturing the window! */ - if (Remove ) - { - *HitTest = co_IntSendMessage(Window->head.h, WM_NCHITTEST, 0, - MAKELONG(Msg->pt.x, Msg->pt.y)); - } - /* else we are going to see this message again, but then with Remove == TRUE */ - - if (*HitTest == (USHORT)HTTRANSPARENT) - { - PWND DesktopWindow; - HWND hDesktop = IntGetDesktopWindow(); - - if ((DesktopWindow = UserGetWindowObject(hDesktop))) - { - PWND Wnd; - - UserRefObjectCo(DesktopWindow, &DesktopRef); - - co_WinPosWindowFromPoint(DesktopWindow, Window->head.pti->MessageQueue, &Msg->pt, &Wnd); - if (Wnd) - { - if (Wnd != Window) - { - /* post the message to the other window */ - Msg->hwnd = Wnd->head.h; - if(!(Wnd->state & WNDS_DESTROYED)) - { - MsqPostMessage(Wnd->head.pti->MessageQueue, Msg, FALSE, - Msg->message == WM_MOUSEMOVE ? QS_MOUSEMOVE : - QS_MOUSEBUTTON); - } - - /* eat the message */ - UserDereferenceObject(Wnd); - UserDerefObjectCo(DesktopWindow); - UserDerefObjectCo(Window); - return TRUE; - } - UserDereferenceObject(Wnd); - } - - UserDerefObjectCo(DesktopWindow); - } - } - } - - if ( gspv.bMouseClickLock && - ((Msg->message == WM_LBUTTONUP) || - (Msg->message == WM_LBUTTONDOWN) ) ) - { - if (MsqIsClkLck(Msg, Remove)) - { - // FIXME: drop the message, hack: use WM_NULL - Msg->message = WM_NULL; - } - } - - if (IS_BTN_MESSAGE(Msg->message, DOWN)) - { - /* generate double click messages, if necessary */ - if ((((*HitTest) != HTCLIENT) || - (Window->pcls->style & CS_DBLCLKS)) && - MsqIsDblClk(Msg, Remove)) - { - Msg->message += WM_LBUTTONDBLCLK - WM_LBUTTONDOWN; - } - } - - if(Msg->message != WM_MOUSEWHEEL) - { - - if ((*HitTest) != HTCLIENT) - { - Msg->message += WM_NCMOUSEMOVE - WM_MOUSEMOVE; - if ( (Msg->message == WM_NCRBUTTONUP) && - (((*HitTest) == HTCAPTION) || ((*HitTest) == HTSYSMENU)) ) - { - Msg->message = WM_CONTEXTMENU; - Msg->wParam = (WPARAM)Window->head.h; - } - else - { - Msg->wParam = *HitTest; - } - Msg->lParam = MAKELONG(Msg->pt.x, Msg->pt.y); - } - else if ( ThreadQueue->MoveSize == NULL && - ThreadQueue->MenuOwner == NULL ) - { - /* NOTE: Msg->pt should remain in screen coordinates. -- FiN */ - Msg->lParam = MAKELONG( - Msg->pt.x - (WORD)Window->rcClient.left, - Msg->pt.y - (WORD)Window->rcClient.top); - } - } - - UserDerefObjectCo(Window); - return FALSE; -} - -BOOL ProcessMouseMessage(MSG* Msg, BOOLEAN RemoveMessages) -{ - MOUSEHOOKSTRUCT MHook; - EVENTMSG Event; - PTHREADINFO pti; - PUSER_MESSAGE_QUEUE ThreadQueue; - USER_REFERENCE_ENTRY Ref; - USHORT HitTest = HTNOWHERE; - - pti = PsGetCurrentThreadWin32Thread(); - ThreadQueue = pti->MessageQueue; - - if(RemoveMessages) - { - PWND MsgWindow = NULL; - - /* Mouse message process */ - - if( Msg->hwnd && - ( MsgWindow = UserGetWindowObject(Msg->hwnd) ) && - Msg->message >= WM_MOUSEFIRST && - Msg->message <= WM_MOUSELAST ) - { - USHORT HitTest; - - UserRefObjectCo(MsgWindow, &Ref); - - if ( co_IntTranslateMouseMessage( ThreadQueue, - Msg, - &HitTest, - TRUE)) - /* FIXME - check message filter again, if the message doesn't match anymore, - search again */ - { - UserDerefObjectCo(MsgWindow); - /* eat the message, search again */ - return FALSE; - } - - if(ThreadQueue->CaptureWindow == NULL) - { - co_IntSendHitTestMessages(ThreadQueue, Msg); - - if ( ( Msg->message != WM_MOUSEMOVE && - Msg->message != WM_NCMOUSEMOVE ) && - IS_BTN_MESSAGE(Msg->message, DOWN) && - co_IntActivateWindowMouse(ThreadQueue, Msg, MsgWindow, &HitTest) ) - { - UserDerefObjectCo(MsgWindow); - /* eat the message, search again */ - return FALSE; - } - } - - UserDerefObjectCo(MsgWindow); - } - else - { - co_IntSendHitTestMessages(ThreadQueue, Msg); - } - - return TRUE; - } - - if ( ( Msg->hwnd && - Msg->message >= WM_MOUSEFIRST && - Msg->message <= WM_MOUSELAST ) && - co_IntTranslateMouseMessage( ThreadQueue, - Msg, - &HitTest, - FALSE) ) - /* FIXME - check message filter again, if the message doesn't match anymore, - search again */ - { - /* eat the message, search again */ - return FALSE; - } - - pti->rpdesk->htEx = HitTest; /* Now set the capture hit. */ - - Event.message = Msg->message; - Event.time = Msg->time; - Event.hwnd = Msg->hwnd; - Event.paramL = Msg->pt.x; - Event.paramH = Msg->pt.y; - co_HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&Event); - - - MHook.pt = Msg->pt; - MHook.hwnd = Msg->hwnd; - MHook.wHitTestCode = HitTest; - MHook.dwExtraInfo = 0; - if (co_HOOK_CallHooks( WH_MOUSE, - RemoveMessages ? HC_ACTION : HC_NOREMOVE, - Msg->message, - (LPARAM)&MHook )) - { - MHook.pt = Msg->pt; - MHook.hwnd = Msg->hwnd; - MHook.wHitTestCode = HitTest; - MHook.dwExtraInfo = 0; - co_HOOK_CallHooks( WH_CBT, - HCBT_CLICKSKIPPED, - Msg->message, - (LPARAM)&MHook); - DPRINT1("MouseMessage WH_CBT Call Hook return!\n"); - return FALSE; - } - - return TRUE; -} - -BOOL ProcessKeyboardMessage(MSG* Msg, BOOLEAN RemoveMessages) -{ - EVENTMSG Event; - - Event.message = Msg->message; - Event.hwnd = Msg->hwnd; - Event.time = Msg->time; - Event.paramL = (Msg->wParam & 0xFF) | (HIWORD(Msg->lParam) << 8); - Event.paramH = Msg->lParam & 0x7FFF; - if (HIWORD(Msg->lParam) & 0x0100) Event.paramH |= 0x8000; - co_HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&Event); - - if (co_HOOK_CallHooks( WH_KEYBOARD, - RemoveMessages ? HC_ACTION : HC_NOREMOVE, - LOWORD(Msg->wParam), - Msg->lParam)) - { - /* skip this message */ - co_HOOK_CallHooks( WH_CBT, - HCBT_KEYSKIPPED, - LOWORD(Msg->wParam), - Msg->lParam ); - DPRINT1("KeyboardMessage WH_CBT Call Hook return!\n"); - return FALSE; - } - return TRUE; -} - -BOOL ProcessHardwareMessage(MSG* Msg, BOOLEAN RemoveMessages) -{ - if ( IS_MOUSE_MESSAGE(Msg->message)) - { - if (!ProcessMouseMessage(Msg, RemoveMessages)) - { - return FALSE; - } - } - else if ( IS_KBD_MESSAGE(Msg->message)) - { - if(!ProcessKeyboardMessage(Msg, RemoveMessages)) - { - return FALSE; - } - } - - return TRUE; -} /* * Internal version of PeekMessage() doing all the work */ @@ -933,27 +552,33 @@ co_IntPeekMessage( PMSG Msg, /* Now check for normal messages. */ if (MsqPeekMessage( ThreadQueue, - RemoveMessages, - Window, - MsgFilterMin, - MsgFilterMax, - Msg )) + RemoveMessages, + Window, + MsgFilterMin, + MsgFilterMax, + Msg )) { return TRUE; } /* Check for hardware events. */ - if(co_MsqPeekHardwareMessage( ThreadQueue, + if(co_MsqPeekMouseMove(ThreadQueue, + RemoveMessages, + Window, + MsgFilterMin, + MsgFilterMax, + Msg )) + { + return TRUE; + } + + if(co_MsqPeekHardwareMessage(ThreadQueue, RemoveMessages, Window, MsgFilterMin, MsgFilterMax, Msg)) { - - if(!ProcessHardwareMessage(Msg, RemoveMessages)) - continue; - return TRUE; } diff --git a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c index f705aed4e2a..d4a7f22401a 100644 --- a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c +++ b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c @@ -22,6 +22,8 @@ * PURPOSE: Message queues * FILE: subsystems/win32/win32k/ntuser/msgqueue.c * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net) + Alexandre Julliard + Maarten Lankhorst * REVISION HISTORY: * 06-06-2001 CSH Created */ @@ -35,31 +37,8 @@ /* GLOBALS *******************************************************************/ -#define SYSTEM_MESSAGE_QUEUE_SIZE (256) - -static MSG SystemMessageQueue[SYSTEM_MESSAGE_QUEUE_SIZE]; -static ULONG SystemMessageQueueHead = 0; -static ULONG SystemMessageQueueTail = 0; -static ULONG SystemMessageQueueCount = 0; -static KSPIN_LOCK SystemMessageQueueLock; - -static ULONG volatile HardwareMessageQueueStamp = 0; -static LIST_ENTRY HardwareMessageQueueHead; -static KMUTANT HardwareMessageQueueLock; - -static KEVENT HardwareMessageEvent; - static PAGED_LOOKASIDE_LIST MessageLookasideList; -#define IntLockSystemMessageQueue(OldIrql) \ - KeAcquireSpinLock(&SystemMessageQueueLock, &OldIrql) - -#define IntUnLockSystemMessageQueue(OldIrql) \ - KeReleaseSpinLock(&SystemMessageQueueLock, OldIrql) - -#define IntUnLockSystemHardwareMessageQueueLock(Wait) \ - KeReleaseMutant(&HardwareMessageQueueLock, IO_NO_INCREMENT, FALSE, Wait) - /* FUNCTIONS *****************************************************************/ HANDLE FASTCALL @@ -135,12 +114,6 @@ NTSTATUS NTAPI MsqInitializeImpl(VOID) { - /*CurrentFocusMessageQueue = NULL;*/ - InitializeListHead(&HardwareMessageQueueHead); - KeInitializeEvent(&HardwareMessageEvent, NotificationEvent, 0); - KeInitializeSpinLock(&SystemMessageQueueLock); - KeInitializeMutant(&HardwareMessageQueueLock, 0); - ExInitializePagedLookasideList(&MessageLookasideList, NULL, NULL, @@ -152,13 +125,20 @@ MsqInitializeImpl(VOID) return(STATUS_SUCCESS); } +VOID FASTCALL +MsqPostMouseMove(PUSER_MESSAGE_QUEUE MessageQueue, MSG* Msg) +{ + MessageQueue->MouseMoveMsg = *Msg; + MessageQueue->MouseMoved = TRUE; + MsqWakeQueue(MessageQueue, QS_MOUSEMOVE); +} + VOID FASTCALL co_MsqInsertMouseMessage(MSG* Msg) { LARGE_INTEGER LargeTickCount; - KIRQL OldIrql; - ULONG Prev; MSLLHOOKSTRUCT MouseHookData; + PWND pwnd, pwndDesktop; KeQueryTickCount(&LargeTickCount); Msg->time = MsqCalculateMessageTime(&LargeTickCount); @@ -191,556 +171,47 @@ co_MsqInsertMouseMessage(MSG* Msg) if (co_HOOK_CallHooks(WH_MOUSE_LL, HC_ACTION, Msg->message, (LPARAM) &MouseHookData)) return; - /* - * If we got WM_MOUSEMOVE and there are already messages in the - * system message queue, check if the last message is mouse move - * and if it is then just overwrite it. - */ - IntLockSystemMessageQueue(OldIrql); + /* Get the desktop window */ + pwndDesktop = UserGetDesktopWindow(); + if(!pwndDesktop) + return; - /* - * Bail out if the queue is full. FIXME: We should handle this case - * more gracefully. - */ - - if (SystemMessageQueueCount == SYSTEM_MESSAGE_QUEUE_SIZE) + /* Check if the mouse is captured */ + Msg->hwnd = IntGetCaptureWindow(); + if(Msg->hwnd != NULL) { - IntUnLockSystemMessageQueue(OldIrql); - return; - } - - if (Msg->message == WM_MOUSEMOVE && SystemMessageQueueCount) - { - if (SystemMessageQueueTail == 0) - Prev = SYSTEM_MESSAGE_QUEUE_SIZE - 1; - else - Prev = SystemMessageQueueTail - 1; - if (SystemMessageQueue[Prev].message == WM_MOUSEMOVE) - { - SystemMessageQueueTail = Prev; - SystemMessageQueueCount--; - } - } - - /* - * Actually insert the message into the system message queue. - */ - - SystemMessageQueue[SystemMessageQueueTail] = *Msg; - SystemMessageQueueTail = - (SystemMessageQueueTail + 1) % SYSTEM_MESSAGE_QUEUE_SIZE; - SystemMessageQueueCount++; - - IntUnLockSystemMessageQueue(OldIrql); - - KeSetEvent(&HardwareMessageEvent, IO_NO_INCREMENT, FALSE); -} - -BOOL FASTCALL -MsqIsClkLck(LPMSG Msg, BOOL Remove) -{ - PTHREADINFO pti; - PSYSTEM_CURSORINFO CurInfo; - BOOL Res = FALSE; - - pti = PsGetCurrentThreadWin32Thread(); - if (pti->rpdesk == NULL) - { - return FALSE; - } - - CurInfo = IntGetSysCursorInfo(); - - switch (Msg->message) - { - case WM_LBUTTONUP: - Res = ((Msg->time - CurInfo->ClickLockTime) >= gspv.dwMouseClickLockTime); - if (Res && (!CurInfo->ClickLockActive)) - { - CurInfo->ClickLockActive = TRUE; - } - break; - case WM_LBUTTONDOWN: - if (CurInfo->ClickLockActive) - { - Res = TRUE; - CurInfo->ClickLockActive = FALSE; - CurInfo->ClickLockTime = 0; - } - else - { - CurInfo->ClickLockTime = Msg->time; - } - break; - } - return Res; -} - -BOOL FASTCALL -MsqIsDblClk(LPMSG Msg, BOOL Remove) -{ - PTHREADINFO pti; - PSYSTEM_CURSORINFO CurInfo; - LONG dX, dY; - BOOL Res; - - pti = PsGetCurrentThreadWin32Thread(); - if (pti->rpdesk == NULL) - { - return FALSE; - } - - CurInfo = IntGetSysCursorInfo(); - Res = (Msg->hwnd == (HWND)CurInfo->LastClkWnd) && - ((Msg->time - CurInfo->LastBtnDown) < gspv.iDblClickTime); - if(Res) - { - - dX = CurInfo->LastBtnDownX - Msg->pt.x; - dY = CurInfo->LastBtnDownY - Msg->pt.y; - if(dX < 0) - dX = -dX; - if(dY < 0) - dY = -dY; - - Res = (dX <= gspv.iDblClickWidth) && - (dY <= gspv.iDblClickHeight); - - if(Res) - { - if(CurInfo->ButtonsDown) - Res = (CurInfo->ButtonsDown == Msg->message); - } - } - - if(Remove) - { - CurInfo->LastBtnDownX = Msg->pt.x; - CurInfo->LastBtnDownY = Msg->pt.y; - CurInfo->ButtonsDown = Msg->message; - if (Res) - { - CurInfo->LastBtnDown = 0; - CurInfo->LastClkWnd = NULL; - } - else - { - CurInfo->LastClkWnd = (HANDLE)Msg->hwnd; - CurInfo->LastBtnDown = Msg->time; - } - } - - return Res; -} - -static BOOL APIENTRY -co_MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, PWND Window, UINT FilterLow, UINT FilterHigh, - PUSER_MESSAGE Message, BOOL Remove, PBOOL Freed, - PWND ScopeWin, PPOINT ScreenPoint, BOOL FromGlobalQueue, PLIST_ENTRY *Next) -{ - USHORT Msg = Message->Msg.message; - PWND CaptureWindow = NULL; - HWND hCaptureWin; - - /* FIXME: Mouse message can be sent before the Desktop is up and running in which case ScopeWin (Desktop) is 0. - Is this the best fix? */ - if (ScopeWin == 0) return FALSE; - - ASSERT_REFS_CO(ScopeWin); - - /* - co_WinPosWindowFromPoint can return a Window, and in that case - that window has a ref that we need to deref. Thats why we add "dummy" - refs in all other cases. - */ - - hCaptureWin = IntGetCaptureWindow(); - if (hCaptureWin == NULL) - { - if (Msg == WM_MOUSEWHEEL) - { - CaptureWindow = UserGetWindowObject(IntGetFocusWindow()); - if (CaptureWindow) UserReferenceObject(CaptureWindow); - } - else - { - co_WinPosWindowFromPoint(ScopeWin, NULL, &Message->Msg.pt, &CaptureWindow); - if(CaptureWindow == NULL) - { - CaptureWindow = ScopeWin; - if (CaptureWindow) UserReferenceObject(CaptureWindow); - } - else - { - /* this is the one case where we dont add a ref, since the returned - window is already referenced */ - } - } + pwnd = UserGetWindowObject(Msg->hwnd); } else { - /* FIXME - window messages should go to the right window if no buttons are - pressed */ - CaptureWindow = UserGetWindowObject(hCaptureWin); - if (CaptureWindow) UserReferenceObject(CaptureWindow); + /* Loop all top level windows to find which one should receive input */ + for( pwnd = pwndDesktop->spwndChild; + pwnd != NULL; + pwnd = pwnd->spwndNext ) + { + if((pwnd->style & WS_VISIBLE) && + IntPtInWindow(pwnd, Msg->pt.x, Msg->pt.y)) + { + Msg->hwnd = pwnd->head.h; + break; + } + } } - - - if (CaptureWindow == NULL) + /* Check if we found a window */ + if(Msg->hwnd != NULL && pwnd != NULL) { - if(!FromGlobalQueue) - { - RemoveEntryList(&Message->ListEntry); - if(MessageQueue->MouseMoveMsg == Message) - { - MessageQueue->MouseMoveMsg = NULL; - } - } - // when FromGlobalQueue is true, the caller has already removed the Message - ExFreePool(Message); - *Freed = TRUE; - return(FALSE); + if(Msg->message == WM_MOUSEMOVE) + { + /* Mouse move is a special case*/ + MsqPostMouseMove(pwnd->head.pti->MessageQueue, Msg); + } + else + { + DPRINT("Posting mouse message to hwnd=0x%x!\n", UserHMGetHandle(pwnd)); + MsqPostMessage(pwnd->head.pti->MessageQueue, Msg, TRUE, QS_MOUSEBUTTON); + } } - - if (CaptureWindow->head.pti->MessageQueue != MessageQueue) - { - if (! FromGlobalQueue) - { - DPRINT("Moving msg between private queues\n"); - /* This message is already queued in a private queue, but we need - * to move it to a different queue, perhaps because a new window - * was created which now covers the screen area previously taken - * by another window. To move it, we need to take it out of the - * old queue. Note that we're already holding the lock mutexes of the - * old queue */ - RemoveEntryList(&Message->ListEntry); - - /* remove the pointer for the current WM_MOUSEMOVE message in case we - just removed it */ - if(MessageQueue->MouseMoveMsg == Message) - { - MessageQueue->MouseMoveMsg = NULL; - } - } - - /* lock the destination message queue, so we don't get in trouble with other - threads, messing with it at the same time */ - IntLockHardwareMessageQueue(CaptureWindow->head.pti->MessageQueue); - InsertTailList(&CaptureWindow->head.pti->MessageQueue->HardwareMessagesListHead, - &Message->ListEntry); - if(Message->Msg.message == WM_MOUSEMOVE) - { - if(CaptureWindow->head.pti->MessageQueue->MouseMoveMsg) - { - /* remove the old WM_MOUSEMOVE message, we're processing a more recent - one */ - RemoveEntryList(&CaptureWindow->head.pti->MessageQueue->MouseMoveMsg->ListEntry); - ExFreePool(CaptureWindow->head.pti->MessageQueue->MouseMoveMsg); - } - /* save the pointer to the WM_MOUSEMOVE message in the new queue */ - CaptureWindow->head.pti->MessageQueue->MouseMoveMsg = Message; - - MsqWakeQueue(CaptureWindow->head.pti->MessageQueue, QS_MOUSEMOVE); - } - else - { - MsqWakeQueue(CaptureWindow->head.pti->MessageQueue, QS_MOUSEBUTTON); - } - IntUnLockHardwareMessageQueue(CaptureWindow->head.pti->MessageQueue); - - *Freed = FALSE; - UserDereferenceObject(CaptureWindow); - return(FALSE); - } - - /* From here on, we're in the same message queue as the caller! */ - - *ScreenPoint = Message->Msg.pt; - - if((Window != NULL && PtrToInt(Window) != 1 && CaptureWindow->head.h != Window->head.h) || - ((FilterLow != 0 || FilterHigh != 0) && (Msg < FilterLow || Msg > FilterHigh))) - { - /* Reject the message because it doesn't match the filter */ - - if(FromGlobalQueue) - { - /* Lock the message queue so no other thread can mess with it. - Our own message queue is not locked while fetching from the global - queue, so we have to make sure nothing interferes! */ - IntLockHardwareMessageQueue(CaptureWindow->head.pti->MessageQueue); - /* if we're from the global queue, we need to add our message to our - private queue so we don't loose it! */ - InsertTailList(&CaptureWindow->head.pti->MessageQueue->HardwareMessagesListHead, - &Message->ListEntry); - } - - if (Message->Msg.message == WM_MOUSEMOVE) - { - if(CaptureWindow->head.pti->MessageQueue->MouseMoveMsg && - (CaptureWindow->head.pti->MessageQueue->MouseMoveMsg != Message)) - { - /* delete the old message */ - RemoveEntryList(&CaptureWindow->head.pti->MessageQueue->MouseMoveMsg->ListEntry); - ExFreePool(CaptureWindow->head.pti->MessageQueue->MouseMoveMsg); - if (!FromGlobalQueue) - { - // We might have deleted the next one in our queue, so fix next - *Next = Message->ListEntry.Flink; - } - } - /* always save a pointer to this WM_MOUSEMOVE message here because we're - sure that the message is in the private queue */ - CaptureWindow->head.pti->MessageQueue->MouseMoveMsg = Message; - } - if(FromGlobalQueue) - { - IntUnLockHardwareMessageQueue(CaptureWindow->head.pti->MessageQueue); - } - - UserDereferenceObject(CaptureWindow); - *Freed = FALSE; - return(FALSE); - } - - /* FIXME - only assign if removing? */ - Message->Msg.hwnd = CaptureWindow->head.h; - Message->Msg.message = Msg; - Message->Msg.lParam = MAKELONG(Message->Msg.pt.x, Message->Msg.pt.y); - - /* remove the reference to the current WM_(NC)MOUSEMOVE message, if this message - is it */ - if (Message->Msg.message == WM_MOUSEMOVE || - Message->Msg.message == WM_NCMOUSEMOVE) - { - if(FromGlobalQueue) - { - /* Lock the message queue so no other thread can mess with it. - Our own message queue is not locked while fetching from the global - queue, so we have to make sure nothing interferes! */ - IntLockHardwareMessageQueue(CaptureWindow->head.pti->MessageQueue); - if(CaptureWindow->head.pti->MessageQueue->MouseMoveMsg) - { - /* delete the WM_(NC)MOUSEMOVE message in the private queue, we're dealing - with one that's been sent later */ - RemoveEntryList(&CaptureWindow->head.pti->MessageQueue->MouseMoveMsg->ListEntry); - ExFreePool(CaptureWindow->head.pti->MessageQueue->MouseMoveMsg); - /* our message is not in the private queue so we can remove the pointer - instead of setting it to the current message we're processing */ - CaptureWindow->head.pti->MessageQueue->MouseMoveMsg = NULL; - } - IntUnLockHardwareMessageQueue(CaptureWindow->head.pti->MessageQueue); - } - else if (CaptureWindow->head.pti->MessageQueue->MouseMoveMsg == Message) - { - CaptureWindow->head.pti->MessageQueue->MouseMoveMsg = NULL; - } - } - - UserDereferenceObject(CaptureWindow); - *Freed = FALSE; - return(TRUE); -} - -BOOL APIENTRY -co_MsqPeekHardwareMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, - IN BOOL Remove, - IN PWND Window, - IN UINT FilterLow, - IN UINT FilterHigh, - OUT PMSG Message) -{ - KIRQL OldIrql; - POINT ScreenPoint; - BOOL Accept, Freed; - PLIST_ENTRY CurrentEntry; - PWND DesktopWindow = NULL; - PVOID WaitObjects[2]; - NTSTATUS WaitStatus; - DECLARE_RETURN(BOOL); - USER_REFERENCE_ENTRY Ref; - PDESKTOPINFO Desk = NULL; - - WaitObjects[1] = MessageQueue->NewMessages; - WaitObjects[0] = &HardwareMessageQueueLock; - do - { - UserLeaveCo(); - - WaitStatus = KeWaitForMultipleObjects(2, WaitObjects, WaitAny, UserRequest, - UserMode, FALSE, NULL, NULL); - - UserEnterCo(); - } - while (NT_SUCCESS(WaitStatus) && STATUS_WAIT_0 != WaitStatus); - - DesktopWindow = UserGetWindowObject(IntGetDesktopWindow()); - - if (DesktopWindow) - { - UserRefObjectCo(DesktopWindow, &Ref); - Desk = DesktopWindow->head.pti->pDeskInfo; - } - - /* Process messages in the message queue itself. */ - IntLockHardwareMessageQueue(MessageQueue); - CurrentEntry = MessageQueue->HardwareMessagesListHead.Flink; - while (CurrentEntry != &MessageQueue->HardwareMessagesListHead) - { - PUSER_MESSAGE Current = - CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry); - CurrentEntry = CurrentEntry->Flink; - if (Current->Msg.message >= WM_MOUSEFIRST && - Current->Msg.message <= WM_MOUSELAST) - { - - - Accept = co_MsqTranslateMouseMessage(MessageQueue, Window, FilterLow, FilterHigh, - Current, Remove, &Freed, - DesktopWindow, &ScreenPoint, FALSE, &CurrentEntry); - if (Accept) - { - *Message = Current->Msg; - if (Remove) - { - RemoveEntryList(&Current->ListEntry); - MsqDestroyMessage(Current); - } - IntUnLockHardwareMessageQueue(MessageQueue); - IntUnLockSystemHardwareMessageQueueLock(FALSE); - - if (Desk) - Desk->LastInputWasKbd = FALSE; - - RETURN(TRUE); - } - - } - else - { - *Message = Current->Msg; - if (Remove) - { - RemoveEntryList(&Current->ListEntry); - MsqDestroyMessage(Current); - } - IntUnLockHardwareMessageQueue(MessageQueue); - IntUnLockSystemHardwareMessageQueueLock(FALSE); - - RETURN(TRUE); - } - } - IntUnLockHardwareMessageQueue(MessageQueue); - - /* Now try the global queue. */ - - /* Transfer all messages from the DPC accessible queue to the main queue. */ - IntLockSystemMessageQueue(OldIrql); - while (SystemMessageQueueCount > 0) - { - PUSER_MESSAGE UserMsg; - MSG Msg; - - ASSERT(SystemMessageQueueHead < SYSTEM_MESSAGE_QUEUE_SIZE); - Msg = SystemMessageQueue[SystemMessageQueueHead]; - SystemMessageQueueHead = - (SystemMessageQueueHead + 1) % SYSTEM_MESSAGE_QUEUE_SIZE; - SystemMessageQueueCount--; - IntUnLockSystemMessageQueue(OldIrql); - - UserMsg = ExAllocateFromPagedLookasideList(&MessageLookasideList); - /* What to do if out of memory? For now we just panic a bit in debug */ - ASSERT(UserMsg); - UserMsg->Msg = Msg; - InsertTailList(&HardwareMessageQueueHead, &UserMsg->ListEntry); - - IntLockSystemMessageQueue(OldIrql); - } - HardwareMessageQueueStamp++; - IntUnLockSystemMessageQueue(OldIrql); - - /* Process messages in the queue until we find one to return. */ - CurrentEntry = HardwareMessageQueueHead.Flink; - while (CurrentEntry != &HardwareMessageQueueHead) - { - PUSER_MESSAGE Current = - CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry); - CurrentEntry = CurrentEntry->Flink; - RemoveEntryList(&Current->ListEntry); - HardwareMessageQueueStamp++; - if (Current->Msg.message >= WM_MOUSEFIRST && - Current->Msg.message <= WM_MOUSELAST) - { - const ULONG ActiveStamp = HardwareMessageQueueStamp; - /* Translate the message. */ - Accept = co_MsqTranslateMouseMessage(MessageQueue, Window, FilterLow, FilterHigh, - Current, Remove, &Freed, - DesktopWindow, &ScreenPoint, TRUE, NULL); - if (Accept) - { - /* Check for no more messages in the system queue. */ - IntLockSystemMessageQueue(OldIrql); - if (SystemMessageQueueCount == 0 && - IsListEmpty(&HardwareMessageQueueHead)) - { - KeClearEvent(&HardwareMessageEvent); - } - IntUnLockSystemMessageQueue(OldIrql); - - /* - If we aren't removing the message then add it to the private - queue. - */ - if (!Remove) - { - IntLockHardwareMessageQueue(MessageQueue); - if(Current->Msg.message == WM_MOUSEMOVE) - { - if(MessageQueue->MouseMoveMsg) - { - RemoveEntryList(&MessageQueue->MouseMoveMsg->ListEntry); - ExFreePool(MessageQueue->MouseMoveMsg); - } - MessageQueue->MouseMoveMsg = Current; - } - InsertTailList(&MessageQueue->HardwareMessagesListHead, - &Current->ListEntry); - IntUnLockHardwareMessageQueue(MessageQueue); - } - IntUnLockSystemHardwareMessageQueueLock(FALSE); - *Message = Current->Msg; - - if (Remove) - { - MsqDestroyMessage(Current); - } - - RETURN(TRUE); - } - /* If the contents of the queue changed then restart processing. */ - if (HardwareMessageQueueStamp != ActiveStamp) - { - CurrentEntry = HardwareMessageQueueHead.Flink; - continue; - } - } - } - - /* Check if the system message queue is now empty. */ - IntLockSystemMessageQueue(OldIrql); - if (SystemMessageQueueCount == 0 && IsListEmpty(&HardwareMessageQueueHead)) - { - KeClearEvent(&HardwareMessageEvent); - } - IntUnLockSystemMessageQueue(OldIrql); - IntUnLockSystemHardwareMessageQueueLock(FALSE); - - RETURN(FALSE); - -CLEANUP: - if (DesktopWindow) UserDerefObjectCo(DesktopWindow); - - END_CLEANUP; } // @@ -1323,6 +794,420 @@ MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue, ULONG ExitCode) MsqWakeQueue(MessageQueue, QS_POSTMESSAGE); } +/*********************************************************************** + * MsqSendParentNotify + * + * Send a WM_PARENTNOTIFY to all ancestors of the given window, unless + * the window has the WS_EX_NOPARENTNOTIFY style. + */ +static void MsqSendParentNotify( PWND pwnd, WORD event, WORD idChild, POINT pt ) +{ + PWND pwndDesktop = UserGetWindowObject(IntGetDesktopWindow()); + + /* pt has to be in the client coordinates of the parent window */ + pt.x += pwndDesktop->rcClient.left - pwnd->rcClient.left; + pt.y += pwndDesktop->rcClient.top - pwnd->rcClient.top; + + for (;;) + { + PWND pwndParent; + + if (!(pwnd->style & WS_CHILD)) break; + if (pwnd->ExStyle & WS_EX_NOPARENTNOTIFY) break; + if (!(pwndParent = IntGetParent(pwnd))) break; + if (pwndParent == pwndDesktop) break; + pt.x += pwnd->rcClient.left - pwndParent->rcClient.left; + pt.y += pwnd->rcClient.top - pwndParent->rcClient.top; + + pwnd = pwndParent; + co_IntSendMessage( UserHMGetHandle(pwnd), WM_PARENTNOTIFY, + MAKEWPARAM( event, idChild ), MAKELPARAM( pt.x, pt.y ) ); + } +} + +BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT last) +{ + MSG clk_msg; + POINT pt; + UINT message; + USHORT hittest; + EVENTMSG event; + MOUSEHOOKSTRUCT hook; + BOOL eatMsg; + + PWND pwndMsg, pwndDesktop; + PUSER_MESSAGE_QUEUE MessageQueue; + PTHREADINFO pti; + PSYSTEM_CURSORINFO CurInfo; + DECLARE_RETURN(BOOL); + + pti = PsGetCurrentThreadWin32Thread(); + pwndDesktop = UserGetDesktopWindow(); + MessageQueue = pti->MessageQueue; + CurInfo = IntGetSysCursorInfo(); + pwndMsg = UserGetWindowObject(msg->hwnd); + clk_msg = MessageQueue->msgDblClk; + + /* find the window to dispatch this mouse message to */ + if (MessageQueue->CaptureWindow) + { + hittest = HTCLIENT; + pwndMsg = IntGetWindowObject(MessageQueue->CaptureWindow); + } + else + { + pwndMsg = co_WinPosWindowFromPoint(pwndMsg, &msg->pt, &hittest); + } + + DPRINT("Got mouse message for 0x%x, hittest: 0x%x\n", msg->hwnd, hittest ); + + if (pwndMsg == NULL || pwndMsg->head.pti != pti) + { + /* Remove and ignore the message */ + *RemoveMessages = TRUE; + RETURN(FALSE); + } + + msg->hwnd = UserHMGetHandle(pwndMsg); + + /* FIXME: is this really the right place for this hook? */ + event.message = msg->message; + event.time = msg->time; + event.hwnd = msg->hwnd; + event.paramL = msg->pt.x; + event.paramH = msg->pt.y; + co_HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&event ); + +#if 0 + if (!check_hwnd_filter( msg, hwnd_filter )) RETURN(FALSE); +#endif + + pt = msg->pt; + message = msg->message; + /* Note: windows has no concept of a non-client wheel message */ + if (message != WM_MOUSEWHEEL) + { + if (hittest != HTCLIENT) + { + message += WM_NCMOUSEMOVE - WM_MOUSEMOVE; + msg->wParam = hittest; + } + else + { + /* coordinates don't get translated while tracking a menu */ + /* FIXME: should differentiate popups and top-level menus */ + if (!(MessageQueue->MenuOwner)) + { + pt.x += pwndDesktop->rcClient.left - pwndMsg->rcClient.left; + pt.y += pwndDesktop->rcClient.top - pwndMsg->rcClient.top; + } + } + } + msg->lParam = MAKELONG( pt.x, pt.y ); + + /* translate double clicks */ + + if ((msg->message == WM_LBUTTONDOWN) || + (msg->message == WM_RBUTTONDOWN) || + (msg->message == WM_MBUTTONDOWN) || + (msg->message == WM_XBUTTONDOWN)) + { + BOOL update = *RemoveMessages; + + /* translate double clicks - + * note that ...MOUSEMOVEs can slip in between + * ...BUTTONDOWN and ...BUTTONDBLCLK messages */ + + if ((MessageQueue->MenuOwner || MessageQueue->MoveSize) || + hittest != HTCLIENT || + (pwndMsg->pcls->style & CS_DBLCLKS)) + { + if ((msg->message == clk_msg.message) && + (msg->hwnd == clk_msg.hwnd) && + (msg->wParam == clk_msg.wParam) && + (msg->time - clk_msg.time < gspv.iDblClickTime) && + (abs(msg->pt.x - clk_msg.pt.x) < UserGetSystemMetrics(SM_CXDOUBLECLK)/2) && + (abs(msg->pt.y - clk_msg.pt.y) < UserGetSystemMetrics(SM_CYDOUBLECLK)/2)) + { + message += (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN); + if (update) + { + MessageQueue->msgDblClk.message = 0; /* clear the double click conditions */ + update = FALSE; + } + } + } + + if (!((first == 0 && last == 0) || (message >= first || message <= last))) + { + DPRINT("Message out of range!!!\n"); + RETURN(FALSE); + } + + /* update static double click conditions */ + if (update) MessageQueue->msgDblClk = *msg; + } + else + { + if (!((first == 0 && last == 0) || (message >= first || message <= last))) + { + DPRINT("Message out of range!!!\n"); + RETURN(FALSE); + } + } + + if(gspv.bMouseClickLock) + { + BOOL IsClkLck = FALSE; + + if(msg->message == WM_LBUTTONUP) + { + IsClkLck = ((msg->time - CurInfo->ClickLockTime) >= gspv.dwMouseClickLockTime); + if (IsClkLck && (!CurInfo->ClickLockActive)) + { + CurInfo->ClickLockActive = TRUE; + } + } + else if (msg->message == WM_LBUTTONDOWN) + { + if (CurInfo->ClickLockActive) + { + IsClkLck = TRUE; + CurInfo->ClickLockActive = FALSE; + } + + CurInfo->ClickLockTime = msg->time; + } + + if(IsClkLck) + { + /* Remove and ignore the message */ + *RemoveMessages = TRUE; + RETURN(FALSE); + } + } + + /* message is accepted now (but may still get dropped) */ + + hook.pt = msg->pt; + hook.hwnd = msg->hwnd; + hook.wHitTestCode = hittest; + hook.dwExtraInfo = 0/*extra_info*/; + if (co_HOOK_CallHooks( WH_MOUSE, *RemoveMessages ? HC_ACTION : HC_NOREMOVE, + message, (LPARAM)&hook )) + { + hook.pt = msg->pt; + hook.hwnd = msg->hwnd; + hook.wHitTestCode = hittest; + hook.dwExtraInfo = 0/*extra_info*/; + co_HOOK_CallHooks( WH_CBT, HCBT_CLICKSKIPPED, message, (LPARAM)&hook ); + + DPRINT1("WH_MOUSE dorpped mouse message!\n"); + + /* Remove and skip message */ + *RemoveMessages = TRUE; + RETURN(FALSE); + } + + if ((hittest == HTERROR) || (hittest == HTNOWHERE)) + { + co_IntSendMessage( msg->hwnd, WM_SETCURSOR, (WPARAM)msg->hwnd, + MAKELONG( hittest, msg->message )); + + /* Remove and skip message */ + *RemoveMessages = TRUE; + RETURN(FALSE); + } + + if ((*RemoveMessages == FALSE) || MessageQueue->CaptureWindow) + { + /* Accept the message */ + msg->message = message; + RETURN(TRUE); + } + + eatMsg = FALSE; + + if ((msg->message == WM_LBUTTONDOWN) || + (msg->message == WM_RBUTTONDOWN) || + (msg->message == WM_MBUTTONDOWN) || + (msg->message == WM_XBUTTONDOWN)) + { + /* Send the WM_PARENTNOTIFY, + * note that even for double/nonclient clicks + * notification message is still WM_L/M/RBUTTONDOWN. + */ + MsqSendParentNotify(pwndMsg, msg->message, 0, msg->pt ); + + /* Activate the window if needed */ + + if (msg->hwnd != MessageQueue->ActiveWindow) + { + PWND pwndTop = pwndMsg; + while (pwndTop) + { + if ((pwndTop->style & (WS_POPUP|WS_CHILD)) != WS_CHILD) break; + pwndTop = IntGetParent( pwndTop ); + } + + if (pwndTop && pwndTop != pwndDesktop) + { + LONG ret = co_IntSendMessage( msg->hwnd, + WM_MOUSEACTIVATE, + (WPARAM)UserHMGetHandle(pwndTop), + MAKELONG( hittest, msg->message)); + switch(ret) + { + case MA_NOACTIVATEANDEAT: + eatMsg = TRUE; + /* fall through */ + case MA_NOACTIVATE: + break; + case MA_ACTIVATEANDEAT: + eatMsg = TRUE; + /* fall through */ + case MA_ACTIVATE: + case 0: + if(!co_IntMouseActivateWindow(pwndMsg)) eatMsg = TRUE; + break; + default: + DPRINT1( "unknown WM_MOUSEACTIVATE code %d\n", ret ); + break; + } + } + } + } + + /* send the WM_SETCURSOR message */ + + /* Windows sends the normal mouse message as the message parameter + in the WM_SETCURSOR message even if it's non-client mouse message */ + co_IntSendMessage( msg->hwnd, WM_SETCURSOR, (WPARAM)msg->hwnd, MAKELONG( hittest, msg->message )); + + msg->message = message; + RETURN(!eatMsg); + +CLEANUP: + if(pwndMsg) + UserDereferenceObject(pwndMsg); + + END_CLEANUP; +} + +BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages) +{ + EVENTMSG Event; + + Event.message = Msg->message; + Event.hwnd = Msg->hwnd; + Event.time = Msg->time; + Event.paramL = (Msg->wParam & 0xFF) | (HIWORD(Msg->lParam) << 8); + Event.paramH = Msg->lParam & 0x7FFF; + if (HIWORD(Msg->lParam) & 0x0100) Event.paramH |= 0x8000; + co_HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&Event); + + if (co_HOOK_CallHooks( WH_KEYBOARD, + *RemoveMessages ? HC_ACTION : HC_NOREMOVE, + LOWORD(Msg->wParam), + Msg->lParam)) + { + /* skip this message */ + co_HOOK_CallHooks( WH_CBT, + HCBT_KEYSKIPPED, + LOWORD(Msg->wParam), + Msg->lParam ); + DPRINT1("KeyboardMessage WH_CBT Call Hook return!\n"); + return FALSE; + } + return TRUE; +} + +BOOL co_IntProcessHardwareMessage(MSG* Msg, BOOL* RemoveMessages, UINT first, UINT last) +{ + if ( IS_MOUSE_MESSAGE(Msg->message)) + { + return co_IntProcessMouseMessage(Msg, RemoveMessages, first, last); + } + else if ( IS_KBD_MESSAGE(Msg->message)) + { + return co_IntProcessKeyboardMessage(Msg, RemoveMessages); + } + + return TRUE; +} + +BOOL APIENTRY +co_MsqPeekMouseMove(IN PUSER_MESSAGE_QUEUE MessageQueue, + IN BOOL Remove, + IN PWND Window, + IN UINT MsgFilterLow, + IN UINT MsgFilterHigh, + OUT MSG* pMsg) +{ + BOOL AcceptMessage; + MSG msg; + + if(!(MessageQueue->MouseMoved)) + return FALSE; + + msg = MessageQueue->MouseMoveMsg; + + AcceptMessage = co_IntProcessMouseMessage(&msg, &Remove, MsgFilterLow, MsgFilterHigh); + + if(AcceptMessage) + *pMsg = msg; + + if(Remove) + MessageQueue->MouseMoved = FALSE; + + return AcceptMessage; +} + +BOOL APIENTRY +co_MsqPeekHardwareMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, + IN BOOL Remove, + IN PWND Window, + IN UINT MsgFilterLow, + IN UINT MsgFilterHigh, + OUT MSG* pMsg) +{ + + BOOL AcceptMessage; + PUSER_MESSAGE CurrentMessage; + PLIST_ENTRY ListHead, CurrentEntry = NULL; + MSG msg; + + ListHead = &MessageQueue->HardwareMessagesListHead; + CurrentEntry = ListHead->Flink; + + while(CurrentEntry != ListHead) + { + CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, + ListEntry); + + msg = CurrentMessage->Msg; + + AcceptMessage = co_IntProcessHardwareMessage(&msg, &Remove, MsgFilterLow, MsgFilterHigh); + + CurrentEntry = CurrentMessage->ListEntry.Flink; + + if (Remove) + { + RemoveEntryList(&CurrentMessage->ListEntry); + MsqDestroyMessage(CurrentMessage); + } + + if(AcceptMessage) + { + *pMsg = msg; + return TRUE; + } + + } + + return FALSE; +} + BOOLEAN APIENTRY MsqPeekMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, IN BOOLEAN Remove, @@ -1368,19 +1253,14 @@ NTSTATUS FASTCALL co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, PWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax) { - PVOID WaitObjects[2] = {MessageQueue->NewMessages, &HardwareMessageEvent}; NTSTATUS ret; UserLeaveCo(); - - ret = KeWaitForMultipleObjects(2, - WaitObjects, - WaitAny, - Executive, - UserMode, - FALSE, - NULL, - NULL); + ret = KeWaitForSingleObject(MessageQueue->NewMessages, + Executive, + UserMode, + FALSE, + NULL); UserEnterCo(); return ret; } diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index 7cab141bf0e..adc82e98bf1 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -4424,6 +4424,7 @@ NtUserWindowFromPoint(LONG X, LONG Y) POINT pt; HWND Ret; PWND DesktopWindow = NULL, Window = NULL; + USHORT hittest; DECLARE_RETURN(HWND); USER_REFERENCE_ENTRY Ref; @@ -4442,7 +4443,7 @@ NtUserWindowFromPoint(LONG X, LONG Y) UserRefObjectCo(DesktopWindow, &Ref); pti = PsGetCurrentThreadWin32Thread(); - co_WinPosWindowFromPoint(DesktopWindow, pti->MessageQueue, &pt, &Window); + Window = co_WinPosWindowFromPoint(DesktopWindow, &pt, &hittest); if(Window) { diff --git a/reactos/subsystems/win32/win32k/ntuser/winpos.c b/reactos/subsystems/win32/win32k/ntuser/winpos.c index 04c0fd7263f..b80c9db2e18 100644 --- a/reactos/subsystems/win32/win32k/ntuser/winpos.c +++ b/reactos/subsystems/win32/win32k/ntuser/winpos.c @@ -1578,162 +1578,99 @@ co_WinPosShowWindow(PWND Wnd, INT Cmd) return(WasVisible); } - -#if 0 - -/* find child of 'parent' that contains the given point (in parent-relative coords) */ -PWND child_window_from_point(PWND parent, int x, int y ) -{ - PWND Wnd;// = parent->spwndChild; - -// LIST_FOR_EACH_ENTRY( Wnd, &parent->children, struct window, entry ) - for (Wnd = parent->spwndChild; Wnd; Wnd = Wnd->spwndNext) - { - if (!IntPtInWindow( Wnd, x, y )) continue; /* skip it */ - - /* if window is minimized or disabled, return at once */ - if (Wnd->style & (WS_MINIMIZE|WS_DISABLED)) return Wnd; - - /* if point is not in client area, return at once */ - if (x < Wnd->rcClient.left || x >= Wnd->rcClient.right || - y < Wnd->rcClient.top || y >= Wnd->rcClient.bottom) - return Wnd; - - return child_window_from_point( Wnd, x - Wnd->rcClient.left, y - Wnd->rcClient.top ); - } - return parent; /* not found any child */ -} -#endif - -/* wine server: child_window_from_point - -Caller must dereference the "returned" Window -*/ static -VOID FASTCALL +PWND FASTCALL co_WinPosSearchChildren( PWND ScopeWin, - PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *Point, - PWND* Window, USHORT *HitTest ) { - PWND Current; - HWND *List, *phWnd; - USER_REFERENCE_ENTRY Ref; + PWND pwndChild; + HWND *List, *phWnd; - ASSERT_REFS_CO(ScopeWin); + if (!(ScopeWin->style & WS_VISIBLE)) + { + return NULL; + } - if ((List = IntWinListChildren(ScopeWin))) - { - for (phWnd = List; *phWnd; ++phWnd) - { - if (!(Current = UserGetWindowObject(*phWnd))) - continue; + if ((ScopeWin->style & WS_DISABLED)) + { + return NULL; + } - if (!(Current->style & WS_VISIBLE)) - { - continue; - } + if (!IntPtInWindow(ScopeWin, Point->x, Point->y)) + { + return NULL; + } - if ((Current->style & (WS_POPUP | WS_CHILD | WS_DISABLED)) == - (WS_CHILD | WS_DISABLED)) - { - continue; - } + UserReferenceObject(ScopeWin); - if (!IntPtInWindow(Current, Point->x, Point->y)) - { - continue; - } - - if (*Window) UserDereferenceObject(*Window); - *Window = Current; - UserReferenceObject(*Window); - - if (Current->style & WS_MINIMIZE) - { - *HitTest = HTCAPTION; - break; - } - - if (Current->style & WS_DISABLED) - { - *HitTest = HTERROR; - break; - } - - UserRefObjectCo(Current, &Ref); - - if (OnlyHitTests && (Current->head.pti->MessageQueue == OnlyHitTests)) - { - *HitTest = co_IntSendMessage(Current->head.h, WM_NCHITTEST, 0, - MAKELONG(Point->x, Point->y)); - if ((*HitTest) == (USHORT)HTTRANSPARENT) + if (Point->x - ScopeWin->rcClient.left < ScopeWin->rcClient.right && + Point->y - ScopeWin->rcClient.top < ScopeWin->rcClient.bottom ) + { + List = IntWinListChildren(ScopeWin); + if(List) + { + for (phWnd = List; *phWnd; ++phWnd) { - UserDerefObjectCo(Current); - continue; + if (!(pwndChild = UserGetWindowObject(*phWnd))) + { + continue; + } + + pwndChild = co_WinPosSearchChildren(pwndChild, Point, HitTest); + + if(pwndChild != NULL) + { + /* We found a window. Don't send any more WM_NCHITTEST messages */ + UserDereferenceObject(ScopeWin); + return pwndChild; + } } - } - else - *HitTest = HTCLIENT; + } - if (Point->x >= Current->rcClient.left && - Point->x < Current->rcClient.right && - Point->y >= Current->rcClient.top && - Point->y < Current->rcClient.bottom) - { - co_WinPosSearchChildren(Current, OnlyHitTests, Point, Window, HitTest); - } + ExFreePool(List); + } - UserDerefObjectCo(Current); - - break; - } - ExFreePool(List); - } + *HitTest = co_IntSendMessage(ScopeWin->head.h, WM_NCHITTEST, 0, + MAKELONG(Point->x, Point->y)); + if ((*HitTest) == (USHORT)HTTRANSPARENT) + { + UserDereferenceObject(ScopeWin); + return NULL; + } + + return ScopeWin; } -/* wine: WINPOS_WindowFromPoint */ -USHORT FASTCALL -co_WinPosWindowFromPoint(PWND ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint, - PWND* Window) +PWND FASTCALL +co_WinPosWindowFromPoint(PWND ScopeWin, POINT *WinPoint, USHORT* HitTest) { - HWND DesktopWindowHandle; - PWND DesktopWindow; + PWND Window; POINT Point = *WinPoint; - USHORT HitTest; + USER_REFERENCE_ENTRY Ref; + + if( ScopeWin == NULL ) + { + ScopeWin = UserGetDesktopWindow(); + if(ScopeWin == NULL) + return NULL; + } + + *HitTest = HTNOWHERE; ASSERT_REFS_CO(ScopeWin); + UserRefObjectCo(ScopeWin, &Ref); - *Window = NULL; + Window = co_WinPosSearchChildren(ScopeWin, &Point, HitTest); - if(!ScopeWin) - { - DPRINT1("WinPosWindowFromPoint(): ScopeWin == NULL!\n"); - return(HTERROR); - } + UserDerefObjectCo(ScopeWin); + if(Window) + ASSERT_REFS_CO(Window); + ASSERT_REFS_CO(ScopeWin); - if (ScopeWin->style & WS_DISABLED) - { - return(HTERROR); - } - - /* Translate the point to the space of the scope window. */ - DesktopWindowHandle = IntGetDesktopWindow(); - if((DesktopWindowHandle != ScopeWin->head.h) && - (DesktopWindow = UserGetWindowObject(DesktopWindowHandle))) - { - Point.x += ScopeWin->rcClient.left - DesktopWindow->rcClient.left; - Point.y += ScopeWin->rcClient.top - DesktopWindow->rcClient.top; - } - - HitTest = HTNOWHERE; - - co_WinPosSearchChildren(ScopeWin, OnlyHitTests, &Point, Window, &HitTest); - - return ((*Window) ? HitTest : HTNOWHERE); + return Window; } BOOL From 4f335ab6b0310981440e0559e1709e4b5ac9f45a Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 22 Nov 2010 21:38:23 +0000 Subject: [PATCH 05/75] [NTOSKRNL] - Add missing PAGED_CODE() where needed - Removed a wrong ASSERT in FsRtlIsNameInExpressionPrivate() and replace it by the right one - Mark FsRtlIsDbcsInExpression() as halfplemented svn path=/trunk/; revision=49711 --- reactos/ntoskrnl/fsrtl/dbcsname.c | 11 +++++++++-- reactos/ntoskrnl/fsrtl/name.c | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/reactos/ntoskrnl/fsrtl/dbcsname.c b/reactos/ntoskrnl/fsrtl/dbcsname.c index 64359a50c01..da0fd71cb47 100644 --- a/reactos/ntoskrnl/fsrtl/dbcsname.c +++ b/reactos/ntoskrnl/fsrtl/dbcsname.c @@ -48,6 +48,7 @@ FsRtlDissectDbcs(IN ANSI_STRING Name, { ULONG FirstPosition, i; ULONG SkipFirstSlash = 0; + PAGED_CODE(); /* Zero the strings before continuing */ RtlZeroMemory(FirstPart, sizeof(ANSI_STRING)); @@ -116,6 +117,7 @@ NTAPI FsRtlDoesDbcsContainWildCards(IN PANSI_STRING Name) { ULONG i; + PAGED_CODE(); /* Check every character */ for (i = 0; i < Name->Length; i++) @@ -138,7 +140,7 @@ FsRtlDoesDbcsContainWildCards(IN PANSI_STRING Name) /*++ * @name FsRtlIsDbcsInExpression - * @implemented + * @halfplemented * * Check if the Name string is in the Expression string. * @@ -150,7 +152,7 @@ FsRtlDoesDbcsContainWildCards(IN PANSI_STRING Name) * * @return TRUE if Name is found in Expression, FALSE otherwise * - * @remarks None + * @remarks Implementation should be fixed to handle wildcards * *--*/ BOOLEAN @@ -159,7 +161,10 @@ FsRtlIsDbcsInExpression(IN PANSI_STRING Expression, IN PANSI_STRING Name) { ULONG ExpressionPosition, NamePosition, MatchingChars = 0; + PAGED_CODE(); + ASSERT(Name->Length); + ASSERT(Expression->Length); ASSERT(!FsRtlDoesDbcsContainWildCards(Name)); /* One can't be null, both can be */ @@ -242,6 +247,7 @@ FsRtlIsFatDbcsLegal(IN ANSI_STRING DbcsName, ANSI_STRING FirstPart, RemainingPart, Name; BOOLEAN LastDot; ULONG i; + PAGED_CODE(); /* Just quit if the string is empty */ if (!DbcsName.Length) @@ -378,6 +384,7 @@ FsRtlIsHpfsDbcsLegal(IN ANSI_STRING DbcsName, { ANSI_STRING FirstPart, RemainingPart, Name; ULONG i; + PAGED_CODE(); /* Just quit if the string is empty */ if (!DbcsName.Length) diff --git a/reactos/ntoskrnl/fsrtl/name.c b/reactos/ntoskrnl/fsrtl/name.c index 1405b9f99c4..291ecf7f12a 100644 --- a/reactos/ntoskrnl/fsrtl/name.c +++ b/reactos/ntoskrnl/fsrtl/name.c @@ -23,8 +23,9 @@ FsRtlIsNameInExpressionPrivate(IN PUNICODE_STRING Expression, IN PWCHAR UpcaseTable OPTIONAL) { ULONG i = 0, j, k = 0; + PAGED_CODE(); - ASSERT(!FsRtlDoesNameContainWildCards(Name)); + ASSERT(!IgnoreCase || UpcaseTable); while (i < Name->Length / sizeof(WCHAR) && k < Expression->Length / sizeof(WCHAR)) { @@ -119,6 +120,7 @@ FsRtlAreNamesEqual(IN PCUNICODE_STRING Name1, BOOLEAN StringsAreEqual, MemoryAllocated = FALSE; ULONG i; NTSTATUS Status; + PAGED_CODE(); /* Well, first check their size */ if (Name1->Length != Name2->Length) return FALSE; @@ -210,6 +212,7 @@ FsRtlDissectName(IN UNICODE_STRING Name, { ULONG FirstPosition, i; ULONG SkipFirstSlash = 0; + PAGED_CODE(); /* Zero the strings before continuing */ RtlZeroMemory(FirstPart, sizeof(UNICODE_STRING)); @@ -272,6 +275,7 @@ NTAPI FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name) { PWCHAR Ptr; + PAGED_CODE(); /* Loop through every character */ if (Name->Length) From e69e3b27ee82b013b5d603d445bb08a1fe9eee12 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 22 Nov 2010 22:18:02 +0000 Subject: [PATCH 06/75] [NTOSKRNL] - Renamed MmIsFileAPagingFile() to MmIsFileObjectAPagingFile() its appropriated name - Added it to internal headers - Implemented FsRtlIsPagingFile() svn path=/trunk/; revision=49712 --- reactos/ntoskrnl/fsrtl/filtrctx.c | 5 ++--- reactos/ntoskrnl/include/internal/mm.h | 4 ++++ reactos/ntoskrnl/mm/pagefile.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/reactos/ntoskrnl/fsrtl/filtrctx.c b/reactos/ntoskrnl/fsrtl/filtrctx.c index 24d88c45c4e..9d5bdf60c32 100644 --- a/reactos/ntoskrnl/fsrtl/filtrctx.c +++ b/reactos/ntoskrnl/fsrtl/filtrctx.c @@ -16,7 +16,7 @@ /*++ * @name FsRtlIsPagingFile - * @implemented NT 4.0 + * @implemented NT 5.2 * * The FsRtlIsPagingFile routine checks if the FileObject is a Paging File. * @@ -32,8 +32,7 @@ LOGICAL NTAPI FsRtlIsPagingFile(IN PFILE_OBJECT FileObject) { - KeBugCheck(FILE_SYSTEM); - return FALSE; + return MmIsFileObjectAPagingFile(FileObject); } /* diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index 7499571f550..3c194f5684d 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -778,6 +778,10 @@ VOID NTAPI MmInitPagingFile(VOID); +BOOLEAN +NTAPI +MmIsFileObjectAPagingFile(PFILE_OBJECT FileObject); + NTSTATUS NTAPI MmReadFromSwapPage( diff --git a/reactos/ntoskrnl/mm/pagefile.c b/reactos/ntoskrnl/mm/pagefile.c index 2b3274aad67..cfa5d9cc6c5 100644 --- a/reactos/ntoskrnl/mm/pagefile.c +++ b/reactos/ntoskrnl/mm/pagefile.c @@ -132,7 +132,7 @@ MmBuildMdlFromPages(PMDL Mdl, PPFN_NUMBER Pages) BOOLEAN NTAPI -MmIsFileAPagingFile(PFILE_OBJECT FileObject) +MmIsFileObjectAPagingFile(PFILE_OBJECT FileObject) { ULONG i; From d828ba929be31c49e3149a1f57c05591f796c9db Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 22 Nov 2010 23:08:11 +0000 Subject: [PATCH 07/75] [NPFS] Add an FCB that represents the file system (volume/device) and support absolute and relative open, cleanup and close. svn path=/trunk/; revision=49713 --- reactos/drivers/filesystems/npfs/create.c | 70 +++++++++++++++++++++++ reactos/drivers/filesystems/npfs/npfs.c | 10 +++- reactos/drivers/filesystems/npfs/npfs.h | 1 + 3 files changed, 78 insertions(+), 3 deletions(-) diff --git a/reactos/drivers/filesystems/npfs/create.c b/reactos/drivers/filesystems/npfs/create.c index dbcbaa1bd73..dc70991447e 100644 --- a/reactos/drivers/filesystems/npfs/create.c +++ b/reactos/drivers/filesystems/npfs/create.c @@ -105,6 +105,35 @@ NpfsSignalAndRemoveListeningServerInstance(PNPFS_FCB Fcb, } +static VOID +NpfsOpenFileSystem(PNPFS_FCB Fcb, + PFILE_OBJECT FileObject, + PIO_STATUS_BLOCK IoStatus) +{ + PNPFS_CCB Ccb; + + DPRINT("NpfsOpenFileSystem()\n"); + + Ccb = ExAllocatePool(NonPagedPool, sizeof(NPFS_CCB)); + if (Ccb == NULL) + { + IoStatus->Status = STATUS_NO_MEMORY; + return; + } + + Ccb->Type = CCB_DEVICE; + Ccb->Fcb = Fcb; + + FileObject->FsContext = Fcb; + FileObject->FsContext2 = Ccb; + + IoStatus->Information = FILE_OPENED; + IoStatus->Status = STATUS_SUCCESS; + + return; +} + + static VOID NpfsOpenRootDirectory(PNPFS_FCB Fcb, PFILE_OBJECT FileObject, @@ -174,6 +203,24 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject, } #endif + DPRINT("FileName->Length: %hu RelatedFileObject: %p\n", FileName->Length, RelatedFileObject); + + /* Open the file system */ + if (FileName->Length == 0 && + (RelatedFileObject == NULL || ((PNPFS_CCB)RelatedFileObject->FsContext2)->Type == CCB_DEVICE)) + { + DPRINT("Open the file system\n"); + + NpfsOpenFileSystem(Vcb->DeviceFcb, + FileObject, + &Irp->IoStatus); + + Status = Irp->IoStatus.Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return Status; + } + + /* Open the root directory */ if (FileName->Length == 2 && FileName->Buffer[0] == L'\\' && RelatedFileObject == NULL) { DPRINT("Open the root directory\n"); @@ -662,6 +709,15 @@ NpfsCleanup(PDEVICE_OBJECT DeviceObject, return STATUS_SUCCESS; } + if (Ccb->Type == CCB_DEVICE) + { + DPRINT("Cleanup the file system!\n"); + Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = 0; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_SUCCESS; + } + if (Ccb->Type == CCB_DIRECTORY) { DPRINT("Cleanup the root directory!\n"); @@ -806,6 +862,20 @@ NpfsClose(PDEVICE_OBJECT DeviceObject, return STATUS_SUCCESS; } + if (Ccb->Type == CCB_DEVICE) + { + DPRINT("Closing the file system!\n"); + + ExFreePool(Ccb); + FileObject->FsContext = NULL; + FileObject->FsContext2 = NULL; + + Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = 0; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_SUCCESS; + } + if (Ccb->Type == CCB_DIRECTORY) { DPRINT("Closing the root directory!\n"); diff --git a/reactos/drivers/filesystems/npfs/npfs.c b/reactos/drivers/filesystems/npfs/npfs.c index 825abe3e21e..74fe99baeb6 100644 --- a/reactos/drivers/filesystems/npfs/npfs.c +++ b/reactos/drivers/filesystems/npfs/npfs.c @@ -85,12 +85,16 @@ DriverEntry(PDRIVER_OBJECT DriverObject, Vcb->DefaultQuota = 8 * PAGE_SIZE; Vcb->MaxQuota = 64 * PAGE_SIZE; + /* Create the device FCB */ + Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB)); + Fcb->Type = FCB_DEVICE; + Fcb->Vcb = Vcb; + Vcb->DeviceFcb = Fcb; + + /* Create the root directory FCB */ Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB)); Fcb->Type = FCB_DIRECTORY; Fcb->Vcb = Vcb; - - - Vcb->RootFcb = Fcb; return STATUS_SUCCESS; diff --git a/reactos/drivers/filesystems/npfs/npfs.h b/reactos/drivers/filesystems/npfs/npfs.h index cb37cb0564d..2e47e6858c4 100644 --- a/reactos/drivers/filesystems/npfs/npfs.h +++ b/reactos/drivers/filesystems/npfs/npfs.h @@ -28,6 +28,7 @@ typedef struct _NPFS_VCB ULONG MinQuota; ULONG DefaultQuota; ULONG MaxQuota; + struct _NPFS_FCB *DeviceFcb; struct _NPFS_FCB *RootFcb; } NPFS_VCB, *PNPFS_VCB; From 332a782a372de0be6bdb8530e5dc198aa8afc0e4 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 22 Nov 2010 23:18:59 +0000 Subject: [PATCH 08/75] [GDI32] Don't make the wrong assumption that POINT and POINTL are identical. svn path=/trunk/; revision=49714 --- reactos/dll/win32/gdi32/objects/coord.c | 2 +- reactos/dll/win32/gdi32/objects/dc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/reactos/dll/win32/gdi32/objects/coord.c b/reactos/dll/win32/gdi32/objects/coord.c index 93381e79ece..866108530b9 100644 --- a/reactos/dll/win32/gdi32/objects/coord.c +++ b/reactos/dll/win32/gdi32/objects/coord.c @@ -255,7 +255,7 @@ GetViewportExtEx( if ((Dc_Attr->flXform & PAGE_EXTENTS_CHANGED) && (Dc_Attr->iMapMode == MM_ISOTROPIC)) // Something was updated, go to kernel. - return NtGdiGetDCPoint( hdc, GdiGetViewPortExt, (LPPOINT) lpSize ); + return NtGdiGetDCPoint( hdc, GdiGetViewPortExt, (PPOINTL) lpSize ); else { lpSize->cx = Dc_Attr->szlViewportExt.cx; diff --git a/reactos/dll/win32/gdi32/objects/dc.c b/reactos/dll/win32/gdi32/objects/dc.c index eb9dcf2ff30..7693dcc9592 100644 --- a/reactos/dll/win32/gdi32/objects/dc.c +++ b/reactos/dll/win32/gdi32/objects/dc.c @@ -746,7 +746,7 @@ GetAspectRatioFilterEx( LPSIZE lpAspectRatio ) { - return NtGdiGetDCPoint( hdc, GdiGetAspectRatioFilter, (LPPOINT) lpAspectRatio ); + return NtGdiGetDCPoint( hdc, GdiGetAspectRatioFilter, (PPOINTL) lpAspectRatio ); } @@ -760,7 +760,7 @@ GetDCOrgEx( LPPOINT lpPoint ) { - return NtGdiGetDCPoint( hdc, GdiGetDCOrg, lpPoint ); + return NtGdiGetDCPoint( hdc, GdiGetDCOrg, (PPOINTL)lpPoint ); } From e08f002f4096c8b3c5d07158b6c752d0802af198 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 22 Nov 2010 23:20:50 +0000 Subject: [PATCH 09/75] [WIN32K] Apply workaround for POINT / POINTL, like for the others svn path=/trunk/; revision=49715 --- reactos/subsystems/win32/win32k/pch.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reactos/subsystems/win32/win32k/pch.h b/reactos/subsystems/win32/win32k/pch.h index 90075c80058..339918377a1 100644 --- a/reactos/subsystems/win32/win32k/pch.h +++ b/reactos/subsystems/win32/win32k/pch.h @@ -33,6 +33,9 @@ typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES; #define PRECT PRECTL #define LPRECT LPRECTL #define LPCRECT LPCRECTL +#define POINT POINTL +#define LPPOINT PPOINTL +#define PPOINT PPOINTL #include #include From c06fd57e9cc64253d6946b7a8d41af19328e78e6 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 22 Nov 2010 23:30:01 +0000 Subject: [PATCH 10/75] [NTOSKRNL] - Implemented FsRtlLookupPerStreamContextInternal(), FsRtlInsertPerStreamContext(), FsRtlRemovePerStreamContext(), FsRtlTeardownPerStreamContexts() Based on my previous work on pierre-fsd branch. svn path=/trunk/; revision=49716 --- reactos/ntoskrnl/fsrtl/filtrctx.c | 157 ++++++++++++++++++++++++++---- 1 file changed, 139 insertions(+), 18 deletions(-) diff --git a/reactos/ntoskrnl/fsrtl/filtrctx.c b/reactos/ntoskrnl/fsrtl/filtrctx.c index 9d5bdf60c32..458d907468d 100644 --- a/reactos/ntoskrnl/fsrtl/filtrctx.c +++ b/reactos/ntoskrnl/fsrtl/filtrctx.c @@ -3,7 +3,7 @@ * LICENSE: GPL - See COPYING in the top level directory * FILE: ntoskrnl/fsrtl/filtrctx.c * PURPOSE: File Stream Filter Context support for File System Drivers - * PROGRAMMERS: None. + * PROGRAMMERS: Pierre Schweitzer (pierre.schweitzer@reactos.org) */ /* INCLUDES ******************************************************************/ @@ -36,16 +36,51 @@ FsRtlIsPagingFile(IN PFILE_OBJECT FileObject) } /* - * @unimplemented + * @implemented */ PFSRTL_PER_STREAM_CONTEXT NTAPI -FsRtlLookupPerStreamContextInternal(IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, +FsRtlLookupPerStreamContextInternal(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader, IN PVOID OwnerId OPTIONAL, IN PVOID InstanceId OPTIONAL) { - KeBugCheck(FILE_SYSTEM); - return FALSE; + PLIST_ENTRY NextEntry; + PFSRTL_PER_STREAM_CONTEXT TmpPerStreamContext, PerStreamContext = NULL; + + ASSERT(AdvFcbHeader); + ASSERT(FlagOn(AdvFcbHeader->Flags2, FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS)); + + ExAcquireFastMutex(AdvFcbHeader->FastMutex); + + /* If list is empty, no need to browse it */ + if (!IsListEmpty(&(AdvFcbHeader->FilterContexts))) + { + for (NextEntry = AdvFcbHeader->FilterContexts.Flink; + NextEntry != &(AdvFcbHeader->FilterContexts); + NextEntry = NextEntry->Flink) + { + /* If we don't have any criteria for search, first entry will be enough */ + if (!OwnerId && !InstanceId) + { + PerStreamContext = (PFSRTL_PER_STREAM_CONTEXT)NextEntry; + break; + } + /* Else, we've to find something that matches with the parameters. */ + else + { + TmpPerStreamContext = CONTAINING_RECORD(NextEntry, FSRTL_PER_STREAM_CONTEXT, Links); + if ((InstanceId && TmpPerStreamContext->InstanceId == InstanceId && TmpPerStreamContext->OwnerId == OwnerId) || + (OwnerId && TmpPerStreamContext->OwnerId == OwnerId)) + { + PerStreamContext = TmpPerStreamContext; + break; + } + } + } + } + ExReleaseFastMutex(AdvFcbHeader->FastMutex); + + return PerStreamContext; } /* @@ -62,28 +97,77 @@ FsRtlLookupPerFileObjectContext(IN PFILE_OBJECT FileObject, } /* - * @unimplemented + * @implemented */ NTSTATUS NTAPI -FsRtlInsertPerStreamContext(IN PFSRTL_ADVANCED_FCB_HEADER PerStreamContext, - IN PFSRTL_PER_STREAM_CONTEXT Ptr) +FsRtlInsertPerStreamContext(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader, + IN PFSRTL_PER_STREAM_CONTEXT PerStreamContext) { - KeBugCheck(FILE_SYSTEM); - return STATUS_NOT_IMPLEMENTED; + if (!(AdvFcbHeader) || !(AdvFcbHeader->Flags2 & FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS)) + { + return STATUS_INVALID_DEVICE_REQUEST; + } + + ExAcquireFastMutex(AdvFcbHeader->FastMutex); + InsertHeadList(&(AdvFcbHeader->FilterContexts), &(PerStreamContext->Links)); + ExReleaseFastMutex(AdvFcbHeader->FastMutex); + return STATUS_SUCCESS; } /* - * @unimplemented + * @implemented */ PFSRTL_PER_STREAM_CONTEXT NTAPI -FsRtlRemovePerStreamContext(IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, +FsRtlRemovePerStreamContext(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader, IN PVOID OwnerId OPTIONAL, IN PVOID InstanceId OPTIONAL) { - KeBugCheck(FILE_SYSTEM); - return NULL; + PLIST_ENTRY NextEntry; + PFSRTL_PER_STREAM_CONTEXT TmpPerStreamContext, PerStreamContext = NULL; + + if (!(AdvFcbHeader) || !(AdvFcbHeader->Flags2 & FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS)) + { + return NULL; + } + + ExAcquireFastMutex(AdvFcbHeader->FastMutex); + /* If list is empty, no need to browse it */ + if (!IsListEmpty(&(AdvFcbHeader->FilterContexts))) + { + for (NextEntry = AdvFcbHeader->FilterContexts.Flink; + NextEntry != &(AdvFcbHeader->FilterContexts); + NextEntry = NextEntry->Flink) + { + /* If we don't have any criteria for search, first entry will be enough */ + if (!OwnerId && !InstanceId) + { + PerStreamContext = (PFSRTL_PER_STREAM_CONTEXT)NextEntry; + break; + } + /* Else, we've to find something that matches with the parameters. */ + else + { + TmpPerStreamContext = CONTAINING_RECORD(NextEntry, FSRTL_PER_STREAM_CONTEXT, Links); + if ((InstanceId && TmpPerStreamContext->InstanceId == InstanceId && TmpPerStreamContext->OwnerId == OwnerId) || + (OwnerId && TmpPerStreamContext->OwnerId == OwnerId)) + { + PerStreamContext = TmpPerStreamContext; + break; + } + } + } + /* Finally remove entry from list */ + if (PerStreamContext) + { + RemoveEntryList(&(PerStreamContext->Links)); + } + } + ExReleaseFastMutex(AdvFcbHeader->FastMutex); + + return PerStreamContext; + } /* @@ -112,12 +196,49 @@ FsRtlRemovePerFileObjectContext(IN PFILE_OBJECT PerFileObjectContext, } /* - * @unimplemented + * @implemented */ VOID NTAPI -FsRtlTeardownPerStreamContexts(IN PFSRTL_ADVANCED_FCB_HEADER AdvancedHeader) +FsRtlTeardownPerStreamContexts(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader) { - KeBugCheck(FILE_SYSTEM); -} + PLIST_ENTRY NextEntry; + BOOLEAN IsMutexLocked = FALSE; + PFSRTL_PER_STREAM_CONTEXT PerStreamContext; + _SEH2_TRY + { + /* Acquire mutex to deal with the list */ + ExAcquireFastMutex(AdvFcbHeader->FastMutex); + IsMutexLocked = TRUE; + + /* While there are items... */ + while (!IsListEmpty(&(AdvFcbHeader->FilterContexts))) + { + /* ...remove one */ + NextEntry = RemoveHeadList(&(AdvFcbHeader->FilterContexts)); + PerStreamContext = CONTAINING_RECORD(NextEntry, FSRTL_PER_STREAM_CONTEXT, Links); + + /* Release mutex before calling callback */ + ExReleaseFastMutex(AdvFcbHeader->FastMutex); + IsMutexLocked = FALSE; + + /* Call the callback */ + ASSERT(PerStreamContext->FreeCallback); + (*PerStreamContext->FreeCallback)(PerStreamContext); + + /* Relock the list to continue */ + ExAcquireFastMutex(AdvFcbHeader->FastMutex); + IsMutexLocked = TRUE; + } + } + _SEH2_FINALLY + { + /* If mutex was locked, release */ + if (IsMutexLocked) + { + ExReleaseFastMutex(AdvFcbHeader->FastMutex); + } + } + _SEH2_END; +} From 4aa271271e2a23c1c76542ea9aaa129dbc44d84c Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 22 Nov 2010 23:51:00 +0000 Subject: [PATCH 11/75] [NTOSKRNL] Add missing prototype and define svn path=/trunk/; revision=49717 --- reactos/ntoskrnl/fsrtl/filtrctx.c | 74 ++++++++++++++++++------------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/reactos/ntoskrnl/fsrtl/filtrctx.c b/reactos/ntoskrnl/fsrtl/filtrctx.c index 458d907468d..15bff1c2637 100644 --- a/reactos/ntoskrnl/fsrtl/filtrctx.c +++ b/reactos/ntoskrnl/fsrtl/filtrctx.c @@ -12,6 +12,20 @@ #define NDEBUG #include +/* PRIVATE FUNCTIONS *********************************************************/ + +typedef struct _FILE_OBJECT_FILTER_CONTEXTS +{ + FAST_MUTEX FilterContextsMutex; + LIST_ENTRY FilterContexts; +} FILE_OBJECT_FILTER_CONTEXTS, *PFILE_OBJECT_FILTER_CONTEXTS; + +VOID +FsRtlPTeardownPerFileObjectContexts(IN PFILE_OBJECT FileObject) +{ +} + + /* PUBLIC FUNCTIONS **********************************************************/ /*++ @@ -35,6 +49,19 @@ FsRtlIsPagingFile(IN PFILE_OBJECT FileObject) return MmIsFileObjectAPagingFile(FileObject); } +/* + * @unimplemented + */ +PFSRTL_PER_FILEOBJECT_CONTEXT +NTAPI +FsRtlLookupPerFileObjectContext(IN PFILE_OBJECT FileObject, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL) +{ + KeBugCheck(FILE_SYSTEM); + return FALSE; +} + /* * @implemented */ @@ -86,14 +113,13 @@ FsRtlLookupPerStreamContextInternal(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader, /* * @unimplemented */ -PFSRTL_PER_FILEOBJECT_CONTEXT +NTSTATUS NTAPI -FsRtlLookupPerFileObjectContext(IN PFILE_OBJECT FileObject, - IN PVOID OwnerId OPTIONAL, - IN PVOID InstanceId OPTIONAL) +FsRtlInsertPerFileObjectContext(IN PFILE_OBJECT FileObject, + IN PFSRTL_PER_FILEOBJECT_CONTEXT Ptr) { KeBugCheck(FILE_SYSTEM); - return FALSE; + return STATUS_NOT_IMPLEMENTED; } /* @@ -115,6 +141,19 @@ FsRtlInsertPerStreamContext(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader, return STATUS_SUCCESS; } +/* + * @unimplemented + */ +PFSRTL_PER_FILEOBJECT_CONTEXT +NTAPI +FsRtlRemovePerFileObjectContext(IN PFILE_OBJECT PerFileObjectContext, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL) +{ + KeBugCheck(FILE_SYSTEM); + return NULL; +} + /* * @implemented */ @@ -170,31 +209,6 @@ FsRtlRemovePerStreamContext(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader, } -/* - * @unimplemented - */ -NTSTATUS -NTAPI -FsRtlInsertPerFileObjectContext(IN PFILE_OBJECT FileObject, - IN PFSRTL_PER_FILEOBJECT_CONTEXT Ptr) -{ - KeBugCheck(FILE_SYSTEM); - return STATUS_NOT_IMPLEMENTED; -} - -/* - * @unimplemented - */ -PFSRTL_PER_FILEOBJECT_CONTEXT -NTAPI -FsRtlRemovePerFileObjectContext(IN PFILE_OBJECT PerFileObjectContext, - IN PVOID OwnerId OPTIONAL, - IN PVOID InstanceId OPTIONAL) -{ - KeBugCheck(FILE_SYSTEM); - return NULL; -} - /* * @implemented */ From b9ced2b73b678ce0fa9ece8ff7d7aeb1d94da8f9 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 23 Nov 2010 00:06:01 +0000 Subject: [PATCH 12/75] [PSDK] Partly sync windef.h with mingw-w64 and add specstrings.h svn path=/trunk/; revision=49718 --- reactos/include/psdk/specstrings.h | 273 +++++++++++ reactos/include/psdk/windef.h | 731 +++++++++++++++-------------- reactos/include/psdk/winnt.h | 56 +++ 3 files changed, 720 insertions(+), 340 deletions(-) create mode 100644 reactos/include/psdk/specstrings.h diff --git a/reactos/include/psdk/specstrings.h b/reactos/include/psdk/specstrings.h new file mode 100644 index 00000000000..568bb983e04 --- /dev/null +++ b/reactos/include/psdk/specstrings.h @@ -0,0 +1,273 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ +#define __specstrings + +#ifdef __cplusplus +#ifndef __nothrow +#define __nothrow __declspec(nothrow) +#endif +#else +#ifndef __nothrow +#define __nothrow +#endif +#endif + +#define __deref_in +#define __deref_in_ecount(size) +#define __deref_in_bcount(size) +#define __deref_in_opt +#define __deref_in_ecount_opt(size) +#define __deref_in_bcount_opt(size) +#define __deref_opt_in +#define __deref_opt_in_ecount(size) +#define __deref_opt_in_bcount(size) +#define __deref_opt_in_opt +#define __deref_opt_in_ecount_opt(size) +#define __deref_opt_in_bcount_opt(size) +#define __out_awcount(expr,size) +#define __in_awcount(expr,size) +#define __null +#define __notnull +#define __maybenull +#define __readonly +#define __notreadonly +#define __maybereadonly +#define __valid +#define __notvalid +#define __maybevalid +#define __readableTo(extent) +#define __elem_readableTo(size) +#define __byte_readableTo(size) +#define __writableTo(size) +#define __elem_writableTo(size) +#define __byte_writableTo(size) +#define __deref +#define __pre +#define __post +#define __precond(expr) +#define __postcond(expr) +#define __exceptthat +#define __execeptthat +#define __inner_success(expr) +#define __inner_checkReturn +#define __inner_typefix(ctype) +#define __inner_override +#define __inner_callback +#define __inner_blocksOn(resource) +#define __inner_fallthrough_dec +#define __inner_fallthrough +#define __refparam +#define __inner_control_entrypoint(category) +#define __inner_data_entrypoint(category) +#define __ecount(size) +#define __bcount(size) +#define __in +#define __in_opt +#define __in_nz +#define __in_nz_opt +#define __in_z +#define __in_z_opt +#define __in_ecount(size) +#define __in_ecount_nz(size) +#define __in_ecount_z(size) +#define __in_bcount(size) +#define __in_bcount_z(size) +#define __in_bcount_nz(size) +#define __in_ecount_opt(size) +#define __in_bcount_opt(size) +#define __in_ecount_z_opt(size) +#define __in_bcount_z_opt(size) +#define __in_ecount_nz_opt(size) +#define __in_bcount_nz_opt(size) +#define __out +#define __out_ecount(size) +#define __out_z +#define __out_nz +#define __out_nz_opt +#define __out_z_opt +#define __out_ecount_part(size,length) +#define __out_ecount_full(size) +#define __out_ecount_nz(size) +#define __out_ecount_z(size) +#define __out_ecount_part_z(size,length) +#define __out_ecount_full_z(size) +#define __out_bcount(size) +#define __out_bcount_part(size,length) +#define __out_bcount_full(size) +#define __out_bcount_z(size) +#define __out_bcount_part_z(size,length) +#define __out_bcount_full_z(size) +#define __out_bcount_nz(size) +#define __inout +#define __inout_ecount(size) +#define __inout_bcount(size) +#define __inout_ecount_part(size,length) +#define __inout_bcount_part(size,length) +#define __inout_ecount_full(size) +#define __inout_bcount_full(size) +#define __inout_z +#define __inout_ecount_z(size) +#define __inout_bcount_z(size) +#define __inout_nz +#define __inout_ecount_nz(size) +#define __inout_bcount_nz(size) +#define __ecount_opt(size) +#define __bcount_opt(size) +#define __out_opt +#define __out_ecount_opt(size) +#define __out_bcount_opt(size) +#define __out_ecount_part_opt(size,length) +#define __out_bcount_part_opt(size,length) +#define __out_ecount_full_opt(size) +#define __out_bcount_full_opt(size) +#define __out_ecount_z_opt(size) +#define __out_bcount_z_opt(size) +#define __out_ecount_part_z_opt(size,length) +#define __out_bcount_part_z_opt(size,length) +#define __out_ecount_full_z_opt(size) +#define __out_bcount_full_z_opt(size) +#define __out_ecount_nz_opt(size) +#define __out_bcount_nz_opt(size) +#define __inout_opt +#define __inout_ecount_opt(size) +#define __inout_bcount_opt(size) +#define __inout_ecount_part_opt(size,length) +#define __inout_bcount_part_opt(size,length) +#define __inout_ecount_full_opt(size) +#define __inout_bcount_full_opt(size) +#define __inout_z_opt +#define __inout_ecount_z_opt(size) +#define __inout_bcount_z_opt(size) +#define __inout_nz_opt +#define __inout_ecount_nz_opt(size) +#define __inout_bcount_nz_opt(size) +#define __deref_ecount(size) +#define __deref_bcount(size) +#define __deref_out +#define __deref_out_ecount(size) +#define __deref_out_bcount(size) +#define __deref_out_ecount_part(size,length) +#define __deref_out_bcount_part(size,length) +#define __deref_out_ecount_full(size) +#define __deref_out_bcount_full(size) +#define __deref_out_z +#define __deref_out_ecount_z(size) +#define __deref_out_bcount_z(size) +#define __deref_out_nz +#define __deref_out_ecount_nz(size) +#define __deref_out_bcount_nz(size) +#define __deref_inout +#define __deref_inout_ecount(size) +#define __deref_inout_bcount(size) +#define __deref_inout_ecount_part(size,length) +#define __deref_inout_bcount_part(size,length) +#define __deref_inout_ecount_full(size) +#define __deref_inout_bcount_full(size) +#define __deref_inout_z +#define __deref_inout_ecount_z(size) +#define __deref_inout_bcount_z(size) +#define __deref_inout_nz +#define __deref_inout_ecount_nz(size) +#define __deref_inout_bcount_nz(size) +#define __deref_ecount_opt(size) +#define __deref_bcount_opt(size) +#define __deref_out_opt +#define __deref_out_ecount_opt(size) +#define __deref_out_bcount_opt(size) +#define __deref_out_ecount_part_opt(size,length) +#define __deref_out_bcount_part_opt(size,length) +#define __deref_out_ecount_full_opt(size) +#define __deref_out_bcount_full_opt(size) +#define __deref_out_z_opt +#define __deref_out_ecount_z_opt(size) +#define __deref_out_bcount_z_opt(size) +#define __deref_out_nz_opt +#define __deref_out_ecount_nz_opt(size) +#define __deref_out_bcount_nz_opt(size) +#define __deref_inout_opt +#define __deref_inout_ecount_opt(size) +#define __deref_inout_bcount_opt(size) +#define __deref_inout_ecount_part_opt(size,length) +#define __deref_inout_bcount_part_opt(size,length) +#define __deref_inout_ecount_full_opt(size) +#define __deref_inout_bcount_full_opt(size) +#define __deref_inout_z_opt +#define __deref_inout_ecount_z_opt(size) +#define __deref_inout_bcount_z_opt(size) +#define __deref_inout_nz_opt +#define __deref_inout_ecount_nz_opt(size) +#define __deref_inout_bcount_nz_opt(size) +#define __deref_opt_ecount(size) +#define __deref_opt_bcount(size) +#define __deref_opt_out +#define __deref_opt_out_z +#define __deref_opt_out_ecount(size) +#define __deref_opt_out_bcount(size) +#define __deref_opt_out_ecount_part(size,length) +#define __deref_opt_out_bcount_part(size,length) +#define __deref_opt_out_ecount_full(size) +#define __deref_opt_out_bcount_full(size) +#define __deref_opt_inout +#define __deref_opt_inout_ecount(size) +#define __deref_opt_inout_bcount(size) +#define __deref_opt_inout_ecount_part(size,length) +#define __deref_opt_inout_bcount_part(size,length) +#define __deref_opt_inout_ecount_full(size) +#define __deref_opt_inout_bcount_full(size) +#define __deref_opt_inout_z +#define __deref_opt_inout_ecount_z(size) +#define __deref_opt_inout_bcount_z(size) +#define __deref_opt_inout_nz +#define __deref_opt_inout_ecount_nz(size) +#define __deref_opt_inout_bcount_nz(size) +#define __deref_opt_ecount_opt(size) +#define __deref_opt_bcount_opt(size) +#define __deref_opt_out_opt +#define __deref_opt_out_ecount_opt(size) +#define __deref_opt_out_bcount_opt(size) +#define __deref_opt_out_ecount_part_opt(size,length) +#define __deref_opt_out_bcount_part_opt(size,length) +#define __deref_opt_out_ecount_full_opt(size) +#define __deref_opt_out_bcount_full_opt(size) +#define __deref_opt_out_z_opt +#define __deref_opt_out_ecount_z_opt(size) +#define __deref_opt_out_bcount_z_opt(size) +#define __deref_opt_out_nz_opt +#define __deref_opt_out_ecount_nz_opt(size) +#define __deref_opt_out_bcount_nz_opt(size) +#define __deref_opt_inout_opt +#define __deref_opt_inout_ecount_opt(size) +#define __deref_opt_inout_bcount_opt(size) +#define __deref_opt_inout_ecount_part_opt(size,length) +#define __deref_opt_inout_bcount_part_opt(size,length) +#define __deref_opt_inout_ecount_full_opt(size) +#define __deref_opt_inout_bcount_full_opt(size) +#define __deref_opt_inout_z_opt +#define __deref_opt_inout_ecount_z_opt(size) +#define __deref_opt_inout_bcount_z_opt(size) +#define __deref_opt_inout_nz_opt +#define __deref_opt_inout_ecount_nz_opt(size) +#define __deref_opt_inout_bcount_nz_opt(size) +#define __success(expr) +#define __nullterminated +#define __nullnullterminated +#define __reserved +#define __checkReturn +#define __typefix(ctype) +#define __override +#define __callback +#define __format_string +#define __blocksOn(resource) +#define __control_entrypoint(category) +#define __data_entrypoint(category) +#ifndef __fallthrough +#define __fallthrough +#endif +#ifndef __analysis_assume +#define __analysis_assume(expr) +#endif + + diff --git a/reactos/include/psdk/windef.h b/reactos/include/psdk/windef.h index a29a959e747..2412dc75705 100644 --- a/reactos/include/psdk/windef.h +++ b/reactos/include/psdk/windef.h @@ -1,5 +1,17 @@ -#ifndef _WINDEF_H -#define _WINDEF_H +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ +#ifndef _WINDEF_ +#define _WINDEF_ + +#define _WINDEF_H // wine ... + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4255) +#endif #ifndef _M_AMD64 #if !defined(__ROS_LONG64__) @@ -9,62 +21,68 @@ #endif #endif +#ifndef NO_STRICT +#ifndef STRICT +#define STRICT 1 +#endif +#endif + +#ifndef WIN32 +#define WIN32 +#endif + +#if defined(_MAC) && !defined(_WIN32) +#define _WIN32 +#endif + #ifdef __cplusplus extern "C" { #endif -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4255) +#ifndef WINVER +#define WINVER 0x0502 #endif -#ifndef WINVER -#define WINVER 0x0400 -/* - * If you need Win32 API features newer the Win95 and WinNT then you must - * define WINVER before including windows.h or any other method of including - * the windef.h header. - */ -#endif -#ifndef _WIN32_WINNT -#define _WIN32_WINNT WINVER -/* - * There may be the need to define _WIN32_WINNT to a value different from - * the value of WINVER. I don't have any example of why you would do that. - * However, if you must then define _WIN32_WINNT to the value required before - * including windows.h or any other method of including the windef.h header. - */ -#endif -#ifndef WIN32 -#define WIN32 -#endif -#ifndef _WIN32 -#define _WIN32 -#endif -#define FAR -#define far -#define NEAR -#define near -#ifndef CONST -#define CONST const +#ifndef BASETYPES +#define BASETYPES +#ifndef __ROS_LONG64__ +typedef unsigned long ULONG; +#else +typedef unsigned int ULONG; #endif +typedef ULONG *PULONG; +typedef unsigned short USHORT; +typedef USHORT *PUSHORT; +typedef unsigned char UCHAR; +typedef UCHAR *PUCHAR; +typedef char *PSZ; +typedef int INT; +#endif /* BASETYPES */ + #undef MAX_PATH #define MAX_PATH 260 #ifndef NULL #ifdef __cplusplus +#ifndef _WIN64 #define NULL 0 #else -#define NULL ((void*)0) +#define NULL 0LL +#endif /* W64 */ +#else +#define NULL ((void *)0) #endif #endif + #ifndef FALSE #define FALSE 0 #endif + #ifndef TRUE #define TRUE 1 #endif +#ifndef _NO_W32_PSEUDO_MODIFIERS #ifndef IN #define IN #endif @@ -74,6 +92,307 @@ extern "C" { #ifndef OPTIONAL #define OPTIONAL #endif +#endif + +#ifdef __GNUC__ +#define PACKED __attribute__((packed)) +#ifndef __declspec +#define __declspec(e) __attribute__((e)) +#endif +#ifndef _declspec +#define _declspec(e) __attribute__((e)) +#endif +#elif defined(__WATCOMC__) +#define PACKED +#else +#define PACKED +#define _cdecl +#define __cdecl +#endif + +#ifdef __GNUC__ +#define DECLSPEC_NORETURN __declspec(noreturn) +#define DECLARE_STDCALL_P( type ) __stdcall type +#elif defined(__WATCOMC__) +#define DECLSPEC_NORETURN +#define DECLARE_STDCALL_P( type ) type __stdcall +#elif defined(_MSC_VER) +#define DECLSPEC_NORETURN __declspec(noreturn) +#define DECLARE_STDCALL_P( type ) type __stdcall +#endif /* __GNUC__/__WATCOMC__ */ + +#define DECLSPEC_IMPORT __declspec(dllimport) +#define DECLSPEC_EXPORT __declspec(dllexport) +#ifndef DECLSPEC_NOINLINE +#if (_MSC_VER >= 1300) +#define DECLSPEC_NOINLINE __declspec(noinline) +#elif defined(__GNUC__) +#define DECLSPEC_NOINLINE __attribute__((noinline)) +#else +#define DECLSPEC_NOINLINE +#endif +#endif + +#undef far +#undef near +#undef pascal + +#define far +#define near +#define pascal __stdcall + +//#define cdecl _cdecl +#ifndef CDECL +#define CDECL _cdecl +#endif + +#if !defined(__x86_64__) //defined(_STDCALL_SUPPORTED) +#ifndef CALLBACK +#define CALLBACK __stdcall +#endif +#ifndef WINAPI +#define WINAPI __stdcall +#endif +#define WINAPIV __cdecl +#define APIENTRY WINAPI +#define APIPRIVATE WINAPI +#define PASCAL WINAPI +#else +#define CALLBACK +#define WINAPI +#define WINAPIV +#define APIENTRY WINAPI +#define APIPRIVATE +#define PASCAL pascal +#endif + +#undef FAR +#undef NEAR +#define FAR +#define NEAR + +#ifndef CONST +#define CONST const +#endif + +#ifndef _DEF_WINBOOL_ +#define _DEF_WINBOOL_ +typedef int WINBOOL; +#pragma push_macro("BOOL") +#undef BOOL +#if !defined(__OBJC__) && !defined(__OBJC_BOOL) && !defined(__objc_INCLUDE_GNU) +typedef int BOOL; +#endif +#define BOOL WINBOOL +typedef BOOL *PBOOL; +typedef BOOL *LPBOOL; +#pragma pop_macro("BOOL") +#endif /* _DEF_WINBOOL_ */ + +typedef unsigned char BYTE; +typedef unsigned short WORD; +#ifndef __ROS_LONG64__ + typedef unsigned long DWORD; +#else + typedef unsigned int DWORD; +#endif +typedef float FLOAT; +typedef FLOAT *PFLOAT; +typedef BYTE *PBYTE; +typedef BYTE *LPBYTE; +typedef int *PINT; +typedef int *LPINT; +typedef WORD *PWORD; +typedef WORD *LPWORD; +#ifndef __ROS_LONG64__ +typedef long *LPLONG; +#else +typedef int *LPLONG; +#endif +typedef DWORD *PDWORD; +typedef DWORD *LPDWORD; +typedef void *LPVOID; +#ifndef _LPCVOID_DEFINED +#define _LPCVOID_DEFINED +typedef CONST void *LPCVOID; +#endif +//typedef int INT; +typedef unsigned int UINT; +typedef unsigned int *PUINT; +typedef unsigned int *LPUINT; + + + + +#ifndef NT_INCLUDED +#include +#endif + +#include + +typedef UINT_PTR WPARAM; +typedef LONG_PTR LPARAM; +typedef LONG_PTR LRESULT; +#ifndef _HRESULT_DEFINED +typedef LONG HRESULT; +#define _HRESULT_DEFINED +#endif + +#ifndef NOMINMAX +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif +#endif + +#define MAKEWORD(a,b) ((WORD)(((BYTE)((DWORD_PTR)(a) & 0xff)) | ((WORD)((BYTE)((DWORD_PTR)(b) & 0xff))) << 8)) +#define MAKELONG(a,b) ((LONG)(((WORD)((DWORD_PTR)(a) & 0xffff)) | ((DWORD)((WORD)((DWORD_PTR)(b) & 0xffff))) << 16)) +#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xffff)) +#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16)) +#define LOBYTE(w) ((BYTE)((DWORD_PTR)(w) & 0xff)) +#define HIBYTE(w) ((BYTE)((DWORD_PTR)(w) >> 8)) + +#ifndef WIN_INTERNAL +DECLARE_HANDLE (HWND); +//DECLARE_HANDLE (HHOOK); +#ifdef WINABLE +DECLARE_HANDLE (HEVENT); +#endif +#endif + +typedef WORD ATOM; + +typedef HANDLE *SPHANDLE; +typedef HANDLE *LPHANDLE; +typedef HANDLE HGLOBAL; +typedef HANDLE HLOCAL; +typedef HANDLE GLOBALHANDLE; +typedef HANDLE LOCALHANDLE; +#ifdef _WIN64 +typedef INT_PTR (WINAPI *FARPROC)(); +typedef INT_PTR (WINAPI *NEARPROC)(); +typedef INT_PTR (WINAPI *PROC)(); +#else +typedef int (WINAPI *FARPROC)(); +typedef int (WINAPI *NEARPROC)(); +typedef int (WINAPI *PROC)(); +#endif + +typedef void *HGDIOBJ; + +DECLARE_HANDLE(HKEY); +typedef HKEY *PHKEY; + +DECLARE_HANDLE(HACCEL); +DECLARE_HANDLE(HBITMAP); +DECLARE_HANDLE(HBRUSH); +DECLARE_HANDLE(HCOLORSPACE); +DECLARE_HANDLE(HDC); +DECLARE_HANDLE(HGLRC); +DECLARE_HANDLE(HDESK); +DECLARE_HANDLE(HENHMETAFILE); +DECLARE_HANDLE(HFONT); +DECLARE_HANDLE(HICON); +DECLARE_HANDLE(HMENU); +DECLARE_HANDLE(HMETAFILE); +DECLARE_HANDLE(HINSTANCE); +typedef HINSTANCE HMODULE; +DECLARE_HANDLE(HPALETTE); +DECLARE_HANDLE(HPEN); +DECLARE_HANDLE(HRGN); +DECLARE_HANDLE(HRSRC); +DECLARE_HANDLE(HSTR); +DECLARE_HANDLE(HTASK); +DECLARE_HANDLE(HWINSTA); +DECLARE_HANDLE(HKL); +DECLARE_HANDLE(HMONITOR); +DECLARE_HANDLE(HWINEVENTHOOK); +DECLARE_HANDLE(HUMPD); + +typedef int HFILE; +typedef HICON HCURSOR; +typedef DWORD COLORREF; +typedef DWORD *LPCOLORREF; + +#define HFILE_ERROR ((HFILE)-1) + +typedef struct tagRECT { + LONG left; + LONG top; + LONG right; + LONG bottom; +} RECT,*PRECT,*NPRECT,*LPRECT; + +typedef const RECT *LPCRECT; + +typedef struct _RECTL { + LONG left; + LONG top; + LONG right; + LONG bottom; +} RECTL,*PRECTL,*LPRECTL; + +typedef const RECTL *LPCRECTL; + +typedef struct tagPOINT { + LONG x; + LONG y; +} POINT,*PPOINT,*NPPOINT,*LPPOINT; + +typedef struct _POINTL { + LONG x; + LONG y; +} POINTL,*PPOINTL; + +typedef struct tagSIZE { + LONG cx; + LONG cy; +} SIZE,*PSIZE,*LPSIZE; + +typedef SIZE SIZEL; +typedef SIZE *PSIZEL,*LPSIZEL; + +typedef struct tagPOINTS { + SHORT x; + SHORT y; +} POINTS,*PPOINTS,*LPPOINTS; + +typedef struct _FILETIME { + DWORD dwLowDateTime; + DWORD dwHighDateTime; +} FILETIME,*PFILETIME,*LPFILETIME; +#define _FILETIME_ + +#define DM_UPDATE 1 +#define DM_COPY 2 +#define DM_PROMPT 4 +#define DM_MODIFY 8 + +#define DM_IN_BUFFER DM_MODIFY +#define DM_IN_PROMPT DM_PROMPT +#define DM_OUT_BUFFER DM_COPY +#define DM_OUT_DEFAULT DM_UPDATE + +#define DC_FIELDS 1 +#define DC_PAPERS 2 +#define DC_PAPERSIZE 3 +#define DC_MINEXTENT 4 +#define DC_MAXEXTENT 5 +#define DC_BINS 6 +#define DC_DUPLEX 7 +#define DC_SIZE 8 +#define DC_EXTRA 9 +#define DC_VERSION 10 +#define DC_DRIVER 11 +#define DC_BINNAMES 12 +#define DC_ENUMRESOLUTIONS 13 +#define DC_FILEDEPENDENCIES 14 +#define DC_TRUETYPE 15 +#define DC_PAPERNAMES 16 +#define DC_ORIENTATION 17 +#define DC_COPIES 18 /* needed by header files generated by WIDL */ #ifdef __WINESRC__ @@ -98,26 +417,41 @@ extern "C" { # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type; #endif +#define UNREFERENCED_PARAMETER(P) {(P)=(P);} +#define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} +#define DBG_UNREFERENCED_PARAMETER(P) +#define DBG_UNREFERENCED_LOCAL_VARIABLE(L) + +#ifndef __WATCOMC__ +#ifndef _export +#define _export +#endif +#ifndef __export +#define __export +#endif +#endif + +#if 0 #ifdef __GNUC__ #define PACKED __attribute__((packed)) -#ifndef _fastcall -#define _fastcall __attribute__((fastcall)) -#endif -#ifndef __fastcall -#define __fastcall __attribute__((fastcall)) -#endif -#ifndef _stdcall -#define _stdcall __attribute__((stdcall)) -#endif -#ifndef __stdcall -#define __stdcall __attribute__((stdcall)) -#endif -#ifndef _cdecl -#define _cdecl __attribute__((cdecl)) -#endif -#ifndef __cdecl -#define __cdecl __attribute__((cdecl)) -#endif +//#ifndef _fastcall +//#define _fastcall __attribute__((fastcall)) +//#endif +//#ifndef __fastcall +//#define __fastcall __attribute__((fastcall)) +//#endif +//#ifndef _stdcall +//#define _stdcall __attribute__((stdcall)) +//#endif +//#ifndef __stdcall +//#define __stdcall __attribute__((stdcall)) +//#endif +//#ifndef _cdecl +//#define _cdecl __attribute__((cdecl)) +//#endif +//#ifndef __cdecl +//#define __cdecl __attribute__((cdecl)) +//#endif #ifndef __declspec #define __declspec(e) __attribute__((e)) #endif @@ -131,186 +465,9 @@ extern "C" { #define _cdecl #define __cdecl #endif - -#undef pascal -#undef _pascal -#undef __pascal -#define pascal __stdcall -#define _pascal __stdcall -#define __pascal __stdcall - -#define CDECL _cdecl - -#if !defined(__x86_64__) //defined(_STDCALL_SUPPORTED) -#define CALLBACK __stdcall -#define WINAPI __stdcall -#define WINAPIV __cdecl -#define APIENTRY WINAPI -#define APIPRIVATE __stdcall -#define PASCAL __stdcall -#else -#define CALLBACK -#define WINAPI -#define WINAPIV -#define APIENTRY WINAPI -#define APIPRIVATE -#define PASCAL pascal #endif -#define DECLSPEC_IMPORT __declspec(dllimport) -#define DECLSPEC_EXPORT __declspec(dllexport) -#ifndef DECLSPEC_NOINLINE -#if (_MSC_VER >= 1300) -#define DECLSPEC_NOINLINE __declspec(noinline) -#elif defined(__GNUC__) -#define DECLSPEC_NOINLINE __attribute__((noinline)) -#else -#define DECLSPEC_NOINLINE -#endif -#endif -#ifdef __GNUC__ -#define DECLSPEC_NORETURN __declspec(noreturn) -#define DECLARE_STDCALL_P( type ) __stdcall type -#elif defined(__WATCOMC__) -#define DECLSPEC_NORETURN -#define DECLARE_STDCALL_P( type ) type __stdcall -#elif defined(_MSC_VER) -#define DECLSPEC_NORETURN __declspec(noreturn) -#define DECLARE_STDCALL_P( type ) type __stdcall -#endif /* __GNUC__/__WATCOMC__ */ -#define MAKEWORD(a,b) ((WORD)(((BYTE)(a))|(((WORD)((BYTE)(b)))<<8))) -#define MAKELONG(a,b) ((LONG)(((WORD)(a))|(((DWORD)((WORD)(b)))<<16))) -#define LOWORD(l) ((WORD)((DWORD_PTR)(l))) -#define HIWORD(l) ((WORD)(((DWORD_PTR)(l)>>16)&0xFFFF)) -#define LOBYTE(w) ((BYTE)(w)) -#define HIBYTE(w) ((BYTE)(((WORD)(w)>>8)&0xFF)) - -#ifndef __WATCOMC__ -#ifndef _export -#define _export -#endif -#ifndef __export -#define __export -#endif -#endif - -#ifndef NOMINMAX - #ifndef max - #define max(a,b) ((a)>(b)?(a):(b)) - #endif - - #ifndef min - #define min(a,b) ((a)<(b)?(a):(b)) - #endif -#endif - -#define UNREFERENCED_PARAMETER(P) {(P)=(P);} -#define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} -#define DBG_UNREFERENCED_PARAMETER(P) -#define DBG_UNREFERENCED_LOCAL_VARIABLE(L) - -#ifndef __ANONYMOUS_DEFINED -#define __ANONYMOUS_DEFINED - -#ifndef NONAMELESSUNION -#ifdef __GNUC__ -#define _ANONYMOUS_UNION __extension__ -#define _ANONYMOUS_STRUCT __extension__ -#elif defined(__WATCOMC__) || defined(_MSC_VER) -#define _ANONYMOUS_UNION -#define _ANONYMOUS_STRUCT -#endif /* __GNUC__/__WATCOMC__ */ -#endif /* NONAMELESSUNION */ - -#ifndef _ANONYMOUS_UNION -#define _ANONYMOUS_UNION -#define _UNION_NAME(x) x -#define DUMMYUNIONNAME u -#define DUMMYUNIONNAME1 u1 -#define DUMMYUNIONNAME2 u2 -#define DUMMYUNIONNAME3 u3 -#define DUMMYUNIONNAME4 u4 -#define DUMMYUNIONNAME5 u5 -#define DUMMYUNIONNAME6 u6 -#define DUMMYUNIONNAME7 u7 -#define DUMMYUNIONNAME8 u8 -#else -#define _UNION_NAME(x) -#define DUMMYUNIONNAME -#define DUMMYUNIONNAME1 -#define DUMMYUNIONNAME2 -#define DUMMYUNIONNAME3 -#define DUMMYUNIONNAME4 -#define DUMMYUNIONNAME5 -#define DUMMYUNIONNAME6 -#define DUMMYUNIONNAME7 -#define DUMMYUNIONNAME8 -#endif -#ifndef _ANONYMOUS_STRUCT -#define _ANONYMOUS_STRUCT -#define _STRUCT_NAME(x) x -#define DUMMYSTRUCTNAME s -#define DUMMYSTRUCTNAME1 s1 -#define DUMMYSTRUCTNAME2 s2 -#define DUMMYSTRUCTNAME3 s3 -#define DUMMYSTRUCTNAME4 s4 -#define DUMMYSTRUCTNAME5 s5 -#else -#define _STRUCT_NAME(x) -#define DUMMYSTRUCTNAME -#define DUMMYSTRUCTNAME1 -#define DUMMYSTRUCTNAME2 -#define DUMMYSTRUCTNAME3 -#define DUMMYSTRUCTNAME4 -#define DUMMYSTRUCTNAME5 -#endif - -#endif /* __ANONYMOUS_DEFINED */ - -#ifndef NO_STRICT -#ifndef STRICT -#define STRICT 1 -#endif -#endif - -#ifndef DWORD_DEFINED -#define DWORD_DEFINED -#ifndef __ROS_LONG64__ - typedef unsigned long DWORD; -#else - typedef unsigned int DWORD; -#endif -#endif//DWORD_DEFINED - -typedef int WINBOOL,*PWINBOOL,*LPWINBOOL; -/* FIXME: Is there a good solution to this? */ -#ifndef XFree86Server -#ifndef __OBJC__ -typedef WINBOOL BOOL; -#else -#define BOOL WINBOOL -#endif -typedef unsigned char BYTE; -#endif /* ndef XFree86Server */ -typedef BOOL *PBOOL,*LPBOOL; -typedef unsigned short WORD; -typedef float FLOAT; -typedef FLOAT *PFLOAT; -typedef BYTE *PBYTE,*LPBYTE; -typedef int *PINT,*LPINT; -typedef WORD *PWORD,*LPWORD; -#ifndef __ROS_LONG64__ -typedef long *LPLONG; -#else -typedef int *LPLONG; -#endif -typedef DWORD *PDWORD,*LPDWORD; -typedef CONST void *LPCVOID; - -typedef unsigned int UINT,*PUINT,*LPUINT; - -typedef void *LPVOID; - +#if 1 // needed by shlwapi.h #ifndef __ms_va_list # if defined(__x86_64__) && defined (__GNUC__) # define __ms_va_list __builtin_ms_va_list @@ -322,115 +479,7 @@ typedef void *LPVOID; # define __ms_va_end(list) va_end(list) # endif #endif - -// -// Check if ntdef.h already defined these for us -// -#ifndef BASETYPES -#define BASETYPES -#ifndef __ROS_LONG64__ -typedef unsigned long ULONG, *PULONG; -#else -typedef unsigned int ULONG, *PULONG; #endif -typedef unsigned short USHORT, *PUSHORT; -typedef unsigned char UCHAR, *PUCHAR; -typedef char *PSZ; -typedef int INT; -#endif /* BASETYPES */ - -#ifndef NT_INCLUDED -#include -#endif - -typedef HANDLE *LPHANDLE; -typedef UINT_PTR WPARAM; -typedef LONG_PTR LPARAM; -typedef LONG_PTR LRESULT; -#ifndef _HRESULT_DEFINED -typedef LONG HRESULT; -#define _HRESULT_DEFINED -#endif -#ifndef XFree86Server -typedef WORD ATOM; -#endif /* XFree86Server */ -typedef HANDLE HGLOBAL; -typedef HANDLE HLOCAL; -typedef HANDLE GLOBALHANDLE; -typedef HANDLE LOCALHANDLE; -typedef void *HGDIOBJ; -DECLARE_HANDLE(HACCEL); -DECLARE_HANDLE(HBITMAP); -DECLARE_HANDLE(HBRUSH); -DECLARE_HANDLE(HCOLORSPACE); -DECLARE_HANDLE(HDC); -DECLARE_HANDLE(HGLRC); -DECLARE_HANDLE(HDESK); -DECLARE_HANDLE(HENHMETAFILE); -DECLARE_HANDLE(HFONT); -DECLARE_HANDLE(HICON); -DECLARE_HANDLE(HKEY); -/* FIXME: How to handle these. SM_CMONITORS etc in winuser.h also. */ -/* #if (WINVER >= 0x0500) */ -DECLARE_HANDLE(HMONITOR); -DECLARE_HANDLE(HUMPD); -#define HMONITOR_DECLARED 1 -DECLARE_HANDLE(HTERMINAL); -DECLARE_HANDLE(HWINEVENTHOOK); -/* #endif */ -typedef HKEY *PHKEY; -DECLARE_HANDLE(HMENU); -DECLARE_HANDLE(HMETAFILE); -DECLARE_HANDLE(HINSTANCE); -typedef HINSTANCE HMODULE; -DECLARE_HANDLE(HPALETTE); -DECLARE_HANDLE(HPEN); -DECLARE_HANDLE(HRGN); -DECLARE_HANDLE(HRSRC); -DECLARE_HANDLE(HSTR); -DECLARE_HANDLE(HTASK); -DECLARE_HANDLE(HWND); -DECLARE_HANDLE(HWINSTA); -DECLARE_HANDLE(HKL); -typedef int HFILE; -typedef HICON HCURSOR; -typedef DWORD COLORREF; -typedef DWORD* LPCOLORREF; -#ifdef _WIN64 -typedef INT_PTR (FAR WINAPI *FARPROC)(); -typedef INT_PTR (NEAR WINAPI *NEARPROC)(); -typedef INT_PTR (WINAPI *PROC)(); -#else -typedef int (FAR WINAPI *FARPROC)(); -typedef int (NEAR WINAPI *NEARPROC)(); -typedef int (WINAPI *PROC)(); -#endif -typedef struct tagRECT { - LONG left; - LONG top; - LONG right; - LONG bottom; -} RECT,*PRECT,*LPRECT; -typedef const RECT *LPCRECT; -typedef struct tagRECTL { - LONG left; - LONG top; - LONG right; - LONG bottom; -} RECTL,*PRECTL,*LPRECTL; -typedef const RECTL *LPCRECTL; -typedef struct tagPOINT { - LONG x; - LONG y; -} POINT,POINTL,*PPOINT,*LPPOINT,*PPOINTL,*LPPOINTL; -typedef struct tagSIZE { - LONG cx; - LONG cy; -} SIZE,SIZEL,*PSIZE,*LPSIZE,*PSIZEL,*LPSIZEL; -typedef struct tagPOINTS { - SHORT x; - SHORT y; -} POINTS,*PPOINTS,*LPPOINTS; #ifdef _MSC_VER #pragma warning(pop) @@ -439,4 +488,6 @@ typedef struct tagPOINTS { #ifdef __cplusplus } #endif -#endif + +#endif /* _WINDEF_ */ + diff --git a/reactos/include/psdk/winnt.h b/reactos/include/psdk/winnt.h index 7967047c4d1..7b2070948a5 100644 --- a/reactos/include/psdk/winnt.h +++ b/reactos/include/psdk/winnt.h @@ -11,6 +11,62 @@ #include #endif +#ifndef __ANONYMOUS_DEFINED +#define __ANONYMOUS_DEFINED +#ifndef NONAMELESSUNION +#ifdef __GNUC__ +#define _ANONYMOUS_UNION __extension__ +#define _ANONYMOUS_STRUCT __extension__ +#elif defined(__WATCOMC__) || defined(_MSC_VER) +#define _ANONYMOUS_UNION +#define _ANONYMOUS_STRUCT +#endif /* __GNUC__/__WATCOMC__ */ +#endif /* NONAMELESSUNION */ +#ifndef _ANONYMOUS_UNION +#define _ANONYMOUS_UNION +#define _UNION_NAME(x) x +#define DUMMYUNIONNAME u +#define DUMMYUNIONNAME1 u1 +#define DUMMYUNIONNAME2 u2 +#define DUMMYUNIONNAME3 u3 +#define DUMMYUNIONNAME4 u4 +#define DUMMYUNIONNAME5 u5 +#define DUMMYUNIONNAME6 u6 +#define DUMMYUNIONNAME7 u7 +#define DUMMYUNIONNAME8 u8 +#else +#define _UNION_NAME(x) +#define DUMMYUNIONNAME +#define DUMMYUNIONNAME1 +#define DUMMYUNIONNAME2 +#define DUMMYUNIONNAME3 +#define DUMMYUNIONNAME4 +#define DUMMYUNIONNAME5 +#define DUMMYUNIONNAME6 +#define DUMMYUNIONNAME7 +#define DUMMYUNIONNAME8 +#endif +#ifndef _ANONYMOUS_STRUCT +#define _ANONYMOUS_STRUCT +#define _STRUCT_NAME(x) x +#define DUMMYSTRUCTNAME s +#define DUMMYSTRUCTNAME1 s1 +#define DUMMYSTRUCTNAME2 s2 +#define DUMMYSTRUCTNAME3 s3 +#define DUMMYSTRUCTNAME4 s4 +#define DUMMYSTRUCTNAME5 s5 +#else +#define _STRUCT_NAME(x) +#define DUMMYSTRUCTNAME +#define DUMMYSTRUCTNAME1 +#define DUMMYSTRUCTNAME2 +#define DUMMYSTRUCTNAME3 +#define DUMMYSTRUCTNAME4 +#define DUMMYSTRUCTNAME5 +#endif +#endif /* __ANONYMOUS_DEFINED */ + + #ifndef DECLSPEC_ALIGN # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS) # define DECLSPEC_ALIGN(x) __declspec(align(x)) From e690f5af927f50daea225f139039980aacc46289 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Tue, 23 Nov 2010 01:16:58 +0000 Subject: [PATCH 13/75] [Win32k] - Restore capturing the hit test in the desktop structure. Move journal record hook before sending the mouse hook. svn path=/trunk/; revision=49719 --- .../subsystems/win32/win32k/ntuser/msgqueue.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c index d4a7f22401a..17841567055 100644 --- a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c +++ b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c @@ -870,14 +870,6 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT msg->hwnd = UserHMGetHandle(pwndMsg); - /* FIXME: is this really the right place for this hook? */ - event.message = msg->message; - event.time = msg->time; - event.hwnd = msg->hwnd; - event.paramL = msg->pt.x; - event.paramH = msg->pt.y; - co_HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&event ); - #if 0 if (!check_hwnd_filter( msg, hwnd_filter )) RETURN(FALSE); #endif @@ -989,6 +981,15 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT /* message is accepted now (but may still get dropped) */ + pti->rpdesk->htEx = hittest; /* Now set the capture hit. */ + + event.message = msg->message; + event.time = msg->time; + event.hwnd = msg->hwnd; + event.paramL = msg->pt.x; + event.paramH = msg->pt.y; + co_HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&event ); + hook.pt = msg->pt; hook.hwnd = msg->hwnd; hook.wHitTestCode = hittest; From 2ce6020471b73149bb5edb21d8288b6d0bb98533 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 23 Nov 2010 01:20:05 +0000 Subject: [PATCH 14/75] revert r49718 svn path=/trunk/; revision=49720 --- reactos/include/psdk/specstrings.h | 273 ----------- reactos/include/psdk/windef.h | 731 ++++++++++++++--------------- reactos/include/psdk/winnt.h | 56 --- 3 files changed, 340 insertions(+), 720 deletions(-) delete mode 100644 reactos/include/psdk/specstrings.h diff --git a/reactos/include/psdk/specstrings.h b/reactos/include/psdk/specstrings.h deleted file mode 100644 index 568bb983e04..00000000000 --- a/reactos/include/psdk/specstrings.h +++ /dev/null @@ -1,273 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#define __specstrings - -#ifdef __cplusplus -#ifndef __nothrow -#define __nothrow __declspec(nothrow) -#endif -#else -#ifndef __nothrow -#define __nothrow -#endif -#endif - -#define __deref_in -#define __deref_in_ecount(size) -#define __deref_in_bcount(size) -#define __deref_in_opt -#define __deref_in_ecount_opt(size) -#define __deref_in_bcount_opt(size) -#define __deref_opt_in -#define __deref_opt_in_ecount(size) -#define __deref_opt_in_bcount(size) -#define __deref_opt_in_opt -#define __deref_opt_in_ecount_opt(size) -#define __deref_opt_in_bcount_opt(size) -#define __out_awcount(expr,size) -#define __in_awcount(expr,size) -#define __null -#define __notnull -#define __maybenull -#define __readonly -#define __notreadonly -#define __maybereadonly -#define __valid -#define __notvalid -#define __maybevalid -#define __readableTo(extent) -#define __elem_readableTo(size) -#define __byte_readableTo(size) -#define __writableTo(size) -#define __elem_writableTo(size) -#define __byte_writableTo(size) -#define __deref -#define __pre -#define __post -#define __precond(expr) -#define __postcond(expr) -#define __exceptthat -#define __execeptthat -#define __inner_success(expr) -#define __inner_checkReturn -#define __inner_typefix(ctype) -#define __inner_override -#define __inner_callback -#define __inner_blocksOn(resource) -#define __inner_fallthrough_dec -#define __inner_fallthrough -#define __refparam -#define __inner_control_entrypoint(category) -#define __inner_data_entrypoint(category) -#define __ecount(size) -#define __bcount(size) -#define __in -#define __in_opt -#define __in_nz -#define __in_nz_opt -#define __in_z -#define __in_z_opt -#define __in_ecount(size) -#define __in_ecount_nz(size) -#define __in_ecount_z(size) -#define __in_bcount(size) -#define __in_bcount_z(size) -#define __in_bcount_nz(size) -#define __in_ecount_opt(size) -#define __in_bcount_opt(size) -#define __in_ecount_z_opt(size) -#define __in_bcount_z_opt(size) -#define __in_ecount_nz_opt(size) -#define __in_bcount_nz_opt(size) -#define __out -#define __out_ecount(size) -#define __out_z -#define __out_nz -#define __out_nz_opt -#define __out_z_opt -#define __out_ecount_part(size,length) -#define __out_ecount_full(size) -#define __out_ecount_nz(size) -#define __out_ecount_z(size) -#define __out_ecount_part_z(size,length) -#define __out_ecount_full_z(size) -#define __out_bcount(size) -#define __out_bcount_part(size,length) -#define __out_bcount_full(size) -#define __out_bcount_z(size) -#define __out_bcount_part_z(size,length) -#define __out_bcount_full_z(size) -#define __out_bcount_nz(size) -#define __inout -#define __inout_ecount(size) -#define __inout_bcount(size) -#define __inout_ecount_part(size,length) -#define __inout_bcount_part(size,length) -#define __inout_ecount_full(size) -#define __inout_bcount_full(size) -#define __inout_z -#define __inout_ecount_z(size) -#define __inout_bcount_z(size) -#define __inout_nz -#define __inout_ecount_nz(size) -#define __inout_bcount_nz(size) -#define __ecount_opt(size) -#define __bcount_opt(size) -#define __out_opt -#define __out_ecount_opt(size) -#define __out_bcount_opt(size) -#define __out_ecount_part_opt(size,length) -#define __out_bcount_part_opt(size,length) -#define __out_ecount_full_opt(size) -#define __out_bcount_full_opt(size) -#define __out_ecount_z_opt(size) -#define __out_bcount_z_opt(size) -#define __out_ecount_part_z_opt(size,length) -#define __out_bcount_part_z_opt(size,length) -#define __out_ecount_full_z_opt(size) -#define __out_bcount_full_z_opt(size) -#define __out_ecount_nz_opt(size) -#define __out_bcount_nz_opt(size) -#define __inout_opt -#define __inout_ecount_opt(size) -#define __inout_bcount_opt(size) -#define __inout_ecount_part_opt(size,length) -#define __inout_bcount_part_opt(size,length) -#define __inout_ecount_full_opt(size) -#define __inout_bcount_full_opt(size) -#define __inout_z_opt -#define __inout_ecount_z_opt(size) -#define __inout_bcount_z_opt(size) -#define __inout_nz_opt -#define __inout_ecount_nz_opt(size) -#define __inout_bcount_nz_opt(size) -#define __deref_ecount(size) -#define __deref_bcount(size) -#define __deref_out -#define __deref_out_ecount(size) -#define __deref_out_bcount(size) -#define __deref_out_ecount_part(size,length) -#define __deref_out_bcount_part(size,length) -#define __deref_out_ecount_full(size) -#define __deref_out_bcount_full(size) -#define __deref_out_z -#define __deref_out_ecount_z(size) -#define __deref_out_bcount_z(size) -#define __deref_out_nz -#define __deref_out_ecount_nz(size) -#define __deref_out_bcount_nz(size) -#define __deref_inout -#define __deref_inout_ecount(size) -#define __deref_inout_bcount(size) -#define __deref_inout_ecount_part(size,length) -#define __deref_inout_bcount_part(size,length) -#define __deref_inout_ecount_full(size) -#define __deref_inout_bcount_full(size) -#define __deref_inout_z -#define __deref_inout_ecount_z(size) -#define __deref_inout_bcount_z(size) -#define __deref_inout_nz -#define __deref_inout_ecount_nz(size) -#define __deref_inout_bcount_nz(size) -#define __deref_ecount_opt(size) -#define __deref_bcount_opt(size) -#define __deref_out_opt -#define __deref_out_ecount_opt(size) -#define __deref_out_bcount_opt(size) -#define __deref_out_ecount_part_opt(size,length) -#define __deref_out_bcount_part_opt(size,length) -#define __deref_out_ecount_full_opt(size) -#define __deref_out_bcount_full_opt(size) -#define __deref_out_z_opt -#define __deref_out_ecount_z_opt(size) -#define __deref_out_bcount_z_opt(size) -#define __deref_out_nz_opt -#define __deref_out_ecount_nz_opt(size) -#define __deref_out_bcount_nz_opt(size) -#define __deref_inout_opt -#define __deref_inout_ecount_opt(size) -#define __deref_inout_bcount_opt(size) -#define __deref_inout_ecount_part_opt(size,length) -#define __deref_inout_bcount_part_opt(size,length) -#define __deref_inout_ecount_full_opt(size) -#define __deref_inout_bcount_full_opt(size) -#define __deref_inout_z_opt -#define __deref_inout_ecount_z_opt(size) -#define __deref_inout_bcount_z_opt(size) -#define __deref_inout_nz_opt -#define __deref_inout_ecount_nz_opt(size) -#define __deref_inout_bcount_nz_opt(size) -#define __deref_opt_ecount(size) -#define __deref_opt_bcount(size) -#define __deref_opt_out -#define __deref_opt_out_z -#define __deref_opt_out_ecount(size) -#define __deref_opt_out_bcount(size) -#define __deref_opt_out_ecount_part(size,length) -#define __deref_opt_out_bcount_part(size,length) -#define __deref_opt_out_ecount_full(size) -#define __deref_opt_out_bcount_full(size) -#define __deref_opt_inout -#define __deref_opt_inout_ecount(size) -#define __deref_opt_inout_bcount(size) -#define __deref_opt_inout_ecount_part(size,length) -#define __deref_opt_inout_bcount_part(size,length) -#define __deref_opt_inout_ecount_full(size) -#define __deref_opt_inout_bcount_full(size) -#define __deref_opt_inout_z -#define __deref_opt_inout_ecount_z(size) -#define __deref_opt_inout_bcount_z(size) -#define __deref_opt_inout_nz -#define __deref_opt_inout_ecount_nz(size) -#define __deref_opt_inout_bcount_nz(size) -#define __deref_opt_ecount_opt(size) -#define __deref_opt_bcount_opt(size) -#define __deref_opt_out_opt -#define __deref_opt_out_ecount_opt(size) -#define __deref_opt_out_bcount_opt(size) -#define __deref_opt_out_ecount_part_opt(size,length) -#define __deref_opt_out_bcount_part_opt(size,length) -#define __deref_opt_out_ecount_full_opt(size) -#define __deref_opt_out_bcount_full_opt(size) -#define __deref_opt_out_z_opt -#define __deref_opt_out_ecount_z_opt(size) -#define __deref_opt_out_bcount_z_opt(size) -#define __deref_opt_out_nz_opt -#define __deref_opt_out_ecount_nz_opt(size) -#define __deref_opt_out_bcount_nz_opt(size) -#define __deref_opt_inout_opt -#define __deref_opt_inout_ecount_opt(size) -#define __deref_opt_inout_bcount_opt(size) -#define __deref_opt_inout_ecount_part_opt(size,length) -#define __deref_opt_inout_bcount_part_opt(size,length) -#define __deref_opt_inout_ecount_full_opt(size) -#define __deref_opt_inout_bcount_full_opt(size) -#define __deref_opt_inout_z_opt -#define __deref_opt_inout_ecount_z_opt(size) -#define __deref_opt_inout_bcount_z_opt(size) -#define __deref_opt_inout_nz_opt -#define __deref_opt_inout_ecount_nz_opt(size) -#define __deref_opt_inout_bcount_nz_opt(size) -#define __success(expr) -#define __nullterminated -#define __nullnullterminated -#define __reserved -#define __checkReturn -#define __typefix(ctype) -#define __override -#define __callback -#define __format_string -#define __blocksOn(resource) -#define __control_entrypoint(category) -#define __data_entrypoint(category) -#ifndef __fallthrough -#define __fallthrough -#endif -#ifndef __analysis_assume -#define __analysis_assume(expr) -#endif - - diff --git a/reactos/include/psdk/windef.h b/reactos/include/psdk/windef.h index 2412dc75705..a29a959e747 100644 --- a/reactos/include/psdk/windef.h +++ b/reactos/include/psdk/windef.h @@ -1,17 +1,5 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#ifndef _WINDEF_ -#define _WINDEF_ - -#define _WINDEF_H // wine ... - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4255) -#endif +#ifndef _WINDEF_H +#define _WINDEF_H #ifndef _M_AMD64 #if !defined(__ROS_LONG64__) @@ -21,68 +9,62 @@ #endif #endif -#ifndef NO_STRICT -#ifndef STRICT -#define STRICT 1 -#endif -#endif - -#ifndef WIN32 -#define WIN32 -#endif - -#if defined(_MAC) && !defined(_WIN32) -#define _WIN32 -#endif - #ifdef __cplusplus extern "C" { #endif +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4255) +#endif + #ifndef WINVER -#define WINVER 0x0502 +#define WINVER 0x0400 +/* + * If you need Win32 API features newer the Win95 and WinNT then you must + * define WINVER before including windows.h or any other method of including + * the windef.h header. + */ #endif - -#ifndef BASETYPES -#define BASETYPES -#ifndef __ROS_LONG64__ -typedef unsigned long ULONG; -#else -typedef unsigned int ULONG; +#ifndef _WIN32_WINNT +#define _WIN32_WINNT WINVER +/* + * There may be the need to define _WIN32_WINNT to a value different from + * the value of WINVER. I don't have any example of why you would do that. + * However, if you must then define _WIN32_WINNT to the value required before + * including windows.h or any other method of including the windef.h header. + */ +#endif +#ifndef WIN32 +#define WIN32 +#endif +#ifndef _WIN32 +#define _WIN32 +#endif +#define FAR +#define far +#define NEAR +#define near +#ifndef CONST +#define CONST const #endif -typedef ULONG *PULONG; -typedef unsigned short USHORT; -typedef USHORT *PUSHORT; -typedef unsigned char UCHAR; -typedef UCHAR *PUCHAR; -typedef char *PSZ; -typedef int INT; -#endif /* BASETYPES */ - #undef MAX_PATH #define MAX_PATH 260 #ifndef NULL #ifdef __cplusplus -#ifndef _WIN64 #define NULL 0 #else -#define NULL 0LL -#endif /* W64 */ -#else -#define NULL ((void *)0) +#define NULL ((void*)0) #endif #endif - #ifndef FALSE #define FALSE 0 #endif - #ifndef TRUE #define TRUE 1 #endif -#ifndef _NO_W32_PSEUDO_MODIFIERS #ifndef IN #define IN #endif @@ -92,307 +74,6 @@ typedef int INT; #ifndef OPTIONAL #define OPTIONAL #endif -#endif - -#ifdef __GNUC__ -#define PACKED __attribute__((packed)) -#ifndef __declspec -#define __declspec(e) __attribute__((e)) -#endif -#ifndef _declspec -#define _declspec(e) __attribute__((e)) -#endif -#elif defined(__WATCOMC__) -#define PACKED -#else -#define PACKED -#define _cdecl -#define __cdecl -#endif - -#ifdef __GNUC__ -#define DECLSPEC_NORETURN __declspec(noreturn) -#define DECLARE_STDCALL_P( type ) __stdcall type -#elif defined(__WATCOMC__) -#define DECLSPEC_NORETURN -#define DECLARE_STDCALL_P( type ) type __stdcall -#elif defined(_MSC_VER) -#define DECLSPEC_NORETURN __declspec(noreturn) -#define DECLARE_STDCALL_P( type ) type __stdcall -#endif /* __GNUC__/__WATCOMC__ */ - -#define DECLSPEC_IMPORT __declspec(dllimport) -#define DECLSPEC_EXPORT __declspec(dllexport) -#ifndef DECLSPEC_NOINLINE -#if (_MSC_VER >= 1300) -#define DECLSPEC_NOINLINE __declspec(noinline) -#elif defined(__GNUC__) -#define DECLSPEC_NOINLINE __attribute__((noinline)) -#else -#define DECLSPEC_NOINLINE -#endif -#endif - -#undef far -#undef near -#undef pascal - -#define far -#define near -#define pascal __stdcall - -//#define cdecl _cdecl -#ifndef CDECL -#define CDECL _cdecl -#endif - -#if !defined(__x86_64__) //defined(_STDCALL_SUPPORTED) -#ifndef CALLBACK -#define CALLBACK __stdcall -#endif -#ifndef WINAPI -#define WINAPI __stdcall -#endif -#define WINAPIV __cdecl -#define APIENTRY WINAPI -#define APIPRIVATE WINAPI -#define PASCAL WINAPI -#else -#define CALLBACK -#define WINAPI -#define WINAPIV -#define APIENTRY WINAPI -#define APIPRIVATE -#define PASCAL pascal -#endif - -#undef FAR -#undef NEAR -#define FAR -#define NEAR - -#ifndef CONST -#define CONST const -#endif - -#ifndef _DEF_WINBOOL_ -#define _DEF_WINBOOL_ -typedef int WINBOOL; -#pragma push_macro("BOOL") -#undef BOOL -#if !defined(__OBJC__) && !defined(__OBJC_BOOL) && !defined(__objc_INCLUDE_GNU) -typedef int BOOL; -#endif -#define BOOL WINBOOL -typedef BOOL *PBOOL; -typedef BOOL *LPBOOL; -#pragma pop_macro("BOOL") -#endif /* _DEF_WINBOOL_ */ - -typedef unsigned char BYTE; -typedef unsigned short WORD; -#ifndef __ROS_LONG64__ - typedef unsigned long DWORD; -#else - typedef unsigned int DWORD; -#endif -typedef float FLOAT; -typedef FLOAT *PFLOAT; -typedef BYTE *PBYTE; -typedef BYTE *LPBYTE; -typedef int *PINT; -typedef int *LPINT; -typedef WORD *PWORD; -typedef WORD *LPWORD; -#ifndef __ROS_LONG64__ -typedef long *LPLONG; -#else -typedef int *LPLONG; -#endif -typedef DWORD *PDWORD; -typedef DWORD *LPDWORD; -typedef void *LPVOID; -#ifndef _LPCVOID_DEFINED -#define _LPCVOID_DEFINED -typedef CONST void *LPCVOID; -#endif -//typedef int INT; -typedef unsigned int UINT; -typedef unsigned int *PUINT; -typedef unsigned int *LPUINT; - - - - -#ifndef NT_INCLUDED -#include -#endif - -#include - -typedef UINT_PTR WPARAM; -typedef LONG_PTR LPARAM; -typedef LONG_PTR LRESULT; -#ifndef _HRESULT_DEFINED -typedef LONG HRESULT; -#define _HRESULT_DEFINED -#endif - -#ifndef NOMINMAX -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif -#endif - -#define MAKEWORD(a,b) ((WORD)(((BYTE)((DWORD_PTR)(a) & 0xff)) | ((WORD)((BYTE)((DWORD_PTR)(b) & 0xff))) << 8)) -#define MAKELONG(a,b) ((LONG)(((WORD)((DWORD_PTR)(a) & 0xffff)) | ((DWORD)((WORD)((DWORD_PTR)(b) & 0xffff))) << 16)) -#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xffff)) -#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16)) -#define LOBYTE(w) ((BYTE)((DWORD_PTR)(w) & 0xff)) -#define HIBYTE(w) ((BYTE)((DWORD_PTR)(w) >> 8)) - -#ifndef WIN_INTERNAL -DECLARE_HANDLE (HWND); -//DECLARE_HANDLE (HHOOK); -#ifdef WINABLE -DECLARE_HANDLE (HEVENT); -#endif -#endif - -typedef WORD ATOM; - -typedef HANDLE *SPHANDLE; -typedef HANDLE *LPHANDLE; -typedef HANDLE HGLOBAL; -typedef HANDLE HLOCAL; -typedef HANDLE GLOBALHANDLE; -typedef HANDLE LOCALHANDLE; -#ifdef _WIN64 -typedef INT_PTR (WINAPI *FARPROC)(); -typedef INT_PTR (WINAPI *NEARPROC)(); -typedef INT_PTR (WINAPI *PROC)(); -#else -typedef int (WINAPI *FARPROC)(); -typedef int (WINAPI *NEARPROC)(); -typedef int (WINAPI *PROC)(); -#endif - -typedef void *HGDIOBJ; - -DECLARE_HANDLE(HKEY); -typedef HKEY *PHKEY; - -DECLARE_HANDLE(HACCEL); -DECLARE_HANDLE(HBITMAP); -DECLARE_HANDLE(HBRUSH); -DECLARE_HANDLE(HCOLORSPACE); -DECLARE_HANDLE(HDC); -DECLARE_HANDLE(HGLRC); -DECLARE_HANDLE(HDESK); -DECLARE_HANDLE(HENHMETAFILE); -DECLARE_HANDLE(HFONT); -DECLARE_HANDLE(HICON); -DECLARE_HANDLE(HMENU); -DECLARE_HANDLE(HMETAFILE); -DECLARE_HANDLE(HINSTANCE); -typedef HINSTANCE HMODULE; -DECLARE_HANDLE(HPALETTE); -DECLARE_HANDLE(HPEN); -DECLARE_HANDLE(HRGN); -DECLARE_HANDLE(HRSRC); -DECLARE_HANDLE(HSTR); -DECLARE_HANDLE(HTASK); -DECLARE_HANDLE(HWINSTA); -DECLARE_HANDLE(HKL); -DECLARE_HANDLE(HMONITOR); -DECLARE_HANDLE(HWINEVENTHOOK); -DECLARE_HANDLE(HUMPD); - -typedef int HFILE; -typedef HICON HCURSOR; -typedef DWORD COLORREF; -typedef DWORD *LPCOLORREF; - -#define HFILE_ERROR ((HFILE)-1) - -typedef struct tagRECT { - LONG left; - LONG top; - LONG right; - LONG bottom; -} RECT,*PRECT,*NPRECT,*LPRECT; - -typedef const RECT *LPCRECT; - -typedef struct _RECTL { - LONG left; - LONG top; - LONG right; - LONG bottom; -} RECTL,*PRECTL,*LPRECTL; - -typedef const RECTL *LPCRECTL; - -typedef struct tagPOINT { - LONG x; - LONG y; -} POINT,*PPOINT,*NPPOINT,*LPPOINT; - -typedef struct _POINTL { - LONG x; - LONG y; -} POINTL,*PPOINTL; - -typedef struct tagSIZE { - LONG cx; - LONG cy; -} SIZE,*PSIZE,*LPSIZE; - -typedef SIZE SIZEL; -typedef SIZE *PSIZEL,*LPSIZEL; - -typedef struct tagPOINTS { - SHORT x; - SHORT y; -} POINTS,*PPOINTS,*LPPOINTS; - -typedef struct _FILETIME { - DWORD dwLowDateTime; - DWORD dwHighDateTime; -} FILETIME,*PFILETIME,*LPFILETIME; -#define _FILETIME_ - -#define DM_UPDATE 1 -#define DM_COPY 2 -#define DM_PROMPT 4 -#define DM_MODIFY 8 - -#define DM_IN_BUFFER DM_MODIFY -#define DM_IN_PROMPT DM_PROMPT -#define DM_OUT_BUFFER DM_COPY -#define DM_OUT_DEFAULT DM_UPDATE - -#define DC_FIELDS 1 -#define DC_PAPERS 2 -#define DC_PAPERSIZE 3 -#define DC_MINEXTENT 4 -#define DC_MAXEXTENT 5 -#define DC_BINS 6 -#define DC_DUPLEX 7 -#define DC_SIZE 8 -#define DC_EXTRA 9 -#define DC_VERSION 10 -#define DC_DRIVER 11 -#define DC_BINNAMES 12 -#define DC_ENUMRESOLUTIONS 13 -#define DC_FILEDEPENDENCIES 14 -#define DC_TRUETYPE 15 -#define DC_PAPERNAMES 16 -#define DC_ORIENTATION 17 -#define DC_COPIES 18 /* needed by header files generated by WIDL */ #ifdef __WINESRC__ @@ -417,41 +98,26 @@ typedef struct _FILETIME { # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type; #endif -#define UNREFERENCED_PARAMETER(P) {(P)=(P);} -#define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} -#define DBG_UNREFERENCED_PARAMETER(P) -#define DBG_UNREFERENCED_LOCAL_VARIABLE(L) - -#ifndef __WATCOMC__ -#ifndef _export -#define _export -#endif -#ifndef __export -#define __export -#endif -#endif - -#if 0 #ifdef __GNUC__ #define PACKED __attribute__((packed)) -//#ifndef _fastcall -//#define _fastcall __attribute__((fastcall)) -//#endif -//#ifndef __fastcall -//#define __fastcall __attribute__((fastcall)) -//#endif -//#ifndef _stdcall -//#define _stdcall __attribute__((stdcall)) -//#endif -//#ifndef __stdcall -//#define __stdcall __attribute__((stdcall)) -//#endif -//#ifndef _cdecl -//#define _cdecl __attribute__((cdecl)) -//#endif -//#ifndef __cdecl -//#define __cdecl __attribute__((cdecl)) -//#endif +#ifndef _fastcall +#define _fastcall __attribute__((fastcall)) +#endif +#ifndef __fastcall +#define __fastcall __attribute__((fastcall)) +#endif +#ifndef _stdcall +#define _stdcall __attribute__((stdcall)) +#endif +#ifndef __stdcall +#define __stdcall __attribute__((stdcall)) +#endif +#ifndef _cdecl +#define _cdecl __attribute__((cdecl)) +#endif +#ifndef __cdecl +#define __cdecl __attribute__((cdecl)) +#endif #ifndef __declspec #define __declspec(e) __attribute__((e)) #endif @@ -465,9 +131,186 @@ typedef struct _FILETIME { #define _cdecl #define __cdecl #endif + +#undef pascal +#undef _pascal +#undef __pascal +#define pascal __stdcall +#define _pascal __stdcall +#define __pascal __stdcall + +#define CDECL _cdecl + +#if !defined(__x86_64__) //defined(_STDCALL_SUPPORTED) +#define CALLBACK __stdcall +#define WINAPI __stdcall +#define WINAPIV __cdecl +#define APIENTRY WINAPI +#define APIPRIVATE __stdcall +#define PASCAL __stdcall +#else +#define CALLBACK +#define WINAPI +#define WINAPIV +#define APIENTRY WINAPI +#define APIPRIVATE +#define PASCAL pascal #endif -#if 1 // needed by shlwapi.h +#define DECLSPEC_IMPORT __declspec(dllimport) +#define DECLSPEC_EXPORT __declspec(dllexport) +#ifndef DECLSPEC_NOINLINE +#if (_MSC_VER >= 1300) +#define DECLSPEC_NOINLINE __declspec(noinline) +#elif defined(__GNUC__) +#define DECLSPEC_NOINLINE __attribute__((noinline)) +#else +#define DECLSPEC_NOINLINE +#endif +#endif +#ifdef __GNUC__ +#define DECLSPEC_NORETURN __declspec(noreturn) +#define DECLARE_STDCALL_P( type ) __stdcall type +#elif defined(__WATCOMC__) +#define DECLSPEC_NORETURN +#define DECLARE_STDCALL_P( type ) type __stdcall +#elif defined(_MSC_VER) +#define DECLSPEC_NORETURN __declspec(noreturn) +#define DECLARE_STDCALL_P( type ) type __stdcall +#endif /* __GNUC__/__WATCOMC__ */ +#define MAKEWORD(a,b) ((WORD)(((BYTE)(a))|(((WORD)((BYTE)(b)))<<8))) +#define MAKELONG(a,b) ((LONG)(((WORD)(a))|(((DWORD)((WORD)(b)))<<16))) +#define LOWORD(l) ((WORD)((DWORD_PTR)(l))) +#define HIWORD(l) ((WORD)(((DWORD_PTR)(l)>>16)&0xFFFF)) +#define LOBYTE(w) ((BYTE)(w)) +#define HIBYTE(w) ((BYTE)(((WORD)(w)>>8)&0xFF)) + +#ifndef __WATCOMC__ +#ifndef _export +#define _export +#endif +#ifndef __export +#define __export +#endif +#endif + +#ifndef NOMINMAX + #ifndef max + #define max(a,b) ((a)>(b)?(a):(b)) + #endif + + #ifndef min + #define min(a,b) ((a)<(b)?(a):(b)) + #endif +#endif + +#define UNREFERENCED_PARAMETER(P) {(P)=(P);} +#define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} +#define DBG_UNREFERENCED_PARAMETER(P) +#define DBG_UNREFERENCED_LOCAL_VARIABLE(L) + +#ifndef __ANONYMOUS_DEFINED +#define __ANONYMOUS_DEFINED + +#ifndef NONAMELESSUNION +#ifdef __GNUC__ +#define _ANONYMOUS_UNION __extension__ +#define _ANONYMOUS_STRUCT __extension__ +#elif defined(__WATCOMC__) || defined(_MSC_VER) +#define _ANONYMOUS_UNION +#define _ANONYMOUS_STRUCT +#endif /* __GNUC__/__WATCOMC__ */ +#endif /* NONAMELESSUNION */ + +#ifndef _ANONYMOUS_UNION +#define _ANONYMOUS_UNION +#define _UNION_NAME(x) x +#define DUMMYUNIONNAME u +#define DUMMYUNIONNAME1 u1 +#define DUMMYUNIONNAME2 u2 +#define DUMMYUNIONNAME3 u3 +#define DUMMYUNIONNAME4 u4 +#define DUMMYUNIONNAME5 u5 +#define DUMMYUNIONNAME6 u6 +#define DUMMYUNIONNAME7 u7 +#define DUMMYUNIONNAME8 u8 +#else +#define _UNION_NAME(x) +#define DUMMYUNIONNAME +#define DUMMYUNIONNAME1 +#define DUMMYUNIONNAME2 +#define DUMMYUNIONNAME3 +#define DUMMYUNIONNAME4 +#define DUMMYUNIONNAME5 +#define DUMMYUNIONNAME6 +#define DUMMYUNIONNAME7 +#define DUMMYUNIONNAME8 +#endif +#ifndef _ANONYMOUS_STRUCT +#define _ANONYMOUS_STRUCT +#define _STRUCT_NAME(x) x +#define DUMMYSTRUCTNAME s +#define DUMMYSTRUCTNAME1 s1 +#define DUMMYSTRUCTNAME2 s2 +#define DUMMYSTRUCTNAME3 s3 +#define DUMMYSTRUCTNAME4 s4 +#define DUMMYSTRUCTNAME5 s5 +#else +#define _STRUCT_NAME(x) +#define DUMMYSTRUCTNAME +#define DUMMYSTRUCTNAME1 +#define DUMMYSTRUCTNAME2 +#define DUMMYSTRUCTNAME3 +#define DUMMYSTRUCTNAME4 +#define DUMMYSTRUCTNAME5 +#endif + +#endif /* __ANONYMOUS_DEFINED */ + +#ifndef NO_STRICT +#ifndef STRICT +#define STRICT 1 +#endif +#endif + +#ifndef DWORD_DEFINED +#define DWORD_DEFINED +#ifndef __ROS_LONG64__ + typedef unsigned long DWORD; +#else + typedef unsigned int DWORD; +#endif +#endif//DWORD_DEFINED + +typedef int WINBOOL,*PWINBOOL,*LPWINBOOL; +/* FIXME: Is there a good solution to this? */ +#ifndef XFree86Server +#ifndef __OBJC__ +typedef WINBOOL BOOL; +#else +#define BOOL WINBOOL +#endif +typedef unsigned char BYTE; +#endif /* ndef XFree86Server */ +typedef BOOL *PBOOL,*LPBOOL; +typedef unsigned short WORD; +typedef float FLOAT; +typedef FLOAT *PFLOAT; +typedef BYTE *PBYTE,*LPBYTE; +typedef int *PINT,*LPINT; +typedef WORD *PWORD,*LPWORD; +#ifndef __ROS_LONG64__ +typedef long *LPLONG; +#else +typedef int *LPLONG; +#endif +typedef DWORD *PDWORD,*LPDWORD; +typedef CONST void *LPCVOID; + +typedef unsigned int UINT,*PUINT,*LPUINT; + +typedef void *LPVOID; + #ifndef __ms_va_list # if defined(__x86_64__) && defined (__GNUC__) # define __ms_va_list __builtin_ms_va_list @@ -479,7 +322,115 @@ typedef struct _FILETIME { # define __ms_va_end(list) va_end(list) # endif #endif + +// +// Check if ntdef.h already defined these for us +// +#ifndef BASETYPES +#define BASETYPES +#ifndef __ROS_LONG64__ +typedef unsigned long ULONG, *PULONG; +#else +typedef unsigned int ULONG, *PULONG; #endif +typedef unsigned short USHORT, *PUSHORT; +typedef unsigned char UCHAR, *PUCHAR; +typedef char *PSZ; +typedef int INT; +#endif /* BASETYPES */ + +#ifndef NT_INCLUDED +#include +#endif + +typedef HANDLE *LPHANDLE; +typedef UINT_PTR WPARAM; +typedef LONG_PTR LPARAM; +typedef LONG_PTR LRESULT; +#ifndef _HRESULT_DEFINED +typedef LONG HRESULT; +#define _HRESULT_DEFINED +#endif +#ifndef XFree86Server +typedef WORD ATOM; +#endif /* XFree86Server */ +typedef HANDLE HGLOBAL; +typedef HANDLE HLOCAL; +typedef HANDLE GLOBALHANDLE; +typedef HANDLE LOCALHANDLE; +typedef void *HGDIOBJ; +DECLARE_HANDLE(HACCEL); +DECLARE_HANDLE(HBITMAP); +DECLARE_HANDLE(HBRUSH); +DECLARE_HANDLE(HCOLORSPACE); +DECLARE_HANDLE(HDC); +DECLARE_HANDLE(HGLRC); +DECLARE_HANDLE(HDESK); +DECLARE_HANDLE(HENHMETAFILE); +DECLARE_HANDLE(HFONT); +DECLARE_HANDLE(HICON); +DECLARE_HANDLE(HKEY); +/* FIXME: How to handle these. SM_CMONITORS etc in winuser.h also. */ +/* #if (WINVER >= 0x0500) */ +DECLARE_HANDLE(HMONITOR); +DECLARE_HANDLE(HUMPD); +#define HMONITOR_DECLARED 1 +DECLARE_HANDLE(HTERMINAL); +DECLARE_HANDLE(HWINEVENTHOOK); +/* #endif */ +typedef HKEY *PHKEY; +DECLARE_HANDLE(HMENU); +DECLARE_HANDLE(HMETAFILE); +DECLARE_HANDLE(HINSTANCE); +typedef HINSTANCE HMODULE; +DECLARE_HANDLE(HPALETTE); +DECLARE_HANDLE(HPEN); +DECLARE_HANDLE(HRGN); +DECLARE_HANDLE(HRSRC); +DECLARE_HANDLE(HSTR); +DECLARE_HANDLE(HTASK); +DECLARE_HANDLE(HWND); +DECLARE_HANDLE(HWINSTA); +DECLARE_HANDLE(HKL); +typedef int HFILE; +typedef HICON HCURSOR; +typedef DWORD COLORREF; +typedef DWORD* LPCOLORREF; +#ifdef _WIN64 +typedef INT_PTR (FAR WINAPI *FARPROC)(); +typedef INT_PTR (NEAR WINAPI *NEARPROC)(); +typedef INT_PTR (WINAPI *PROC)(); +#else +typedef int (FAR WINAPI *FARPROC)(); +typedef int (NEAR WINAPI *NEARPROC)(); +typedef int (WINAPI *PROC)(); +#endif +typedef struct tagRECT { + LONG left; + LONG top; + LONG right; + LONG bottom; +} RECT,*PRECT,*LPRECT; +typedef const RECT *LPCRECT; +typedef struct tagRECTL { + LONG left; + LONG top; + LONG right; + LONG bottom; +} RECTL,*PRECTL,*LPRECTL; +typedef const RECTL *LPCRECTL; +typedef struct tagPOINT { + LONG x; + LONG y; +} POINT,POINTL,*PPOINT,*LPPOINT,*PPOINTL,*LPPOINTL; +typedef struct tagSIZE { + LONG cx; + LONG cy; +} SIZE,SIZEL,*PSIZE,*LPSIZE,*PSIZEL,*LPSIZEL; +typedef struct tagPOINTS { + SHORT x; + SHORT y; +} POINTS,*PPOINTS,*LPPOINTS; #ifdef _MSC_VER #pragma warning(pop) @@ -488,6 +439,4 @@ typedef struct _FILETIME { #ifdef __cplusplus } #endif - -#endif /* _WINDEF_ */ - +#endif diff --git a/reactos/include/psdk/winnt.h b/reactos/include/psdk/winnt.h index 7b2070948a5..7967047c4d1 100644 --- a/reactos/include/psdk/winnt.h +++ b/reactos/include/psdk/winnt.h @@ -11,62 +11,6 @@ #include #endif -#ifndef __ANONYMOUS_DEFINED -#define __ANONYMOUS_DEFINED -#ifndef NONAMELESSUNION -#ifdef __GNUC__ -#define _ANONYMOUS_UNION __extension__ -#define _ANONYMOUS_STRUCT __extension__ -#elif defined(__WATCOMC__) || defined(_MSC_VER) -#define _ANONYMOUS_UNION -#define _ANONYMOUS_STRUCT -#endif /* __GNUC__/__WATCOMC__ */ -#endif /* NONAMELESSUNION */ -#ifndef _ANONYMOUS_UNION -#define _ANONYMOUS_UNION -#define _UNION_NAME(x) x -#define DUMMYUNIONNAME u -#define DUMMYUNIONNAME1 u1 -#define DUMMYUNIONNAME2 u2 -#define DUMMYUNIONNAME3 u3 -#define DUMMYUNIONNAME4 u4 -#define DUMMYUNIONNAME5 u5 -#define DUMMYUNIONNAME6 u6 -#define DUMMYUNIONNAME7 u7 -#define DUMMYUNIONNAME8 u8 -#else -#define _UNION_NAME(x) -#define DUMMYUNIONNAME -#define DUMMYUNIONNAME1 -#define DUMMYUNIONNAME2 -#define DUMMYUNIONNAME3 -#define DUMMYUNIONNAME4 -#define DUMMYUNIONNAME5 -#define DUMMYUNIONNAME6 -#define DUMMYUNIONNAME7 -#define DUMMYUNIONNAME8 -#endif -#ifndef _ANONYMOUS_STRUCT -#define _ANONYMOUS_STRUCT -#define _STRUCT_NAME(x) x -#define DUMMYSTRUCTNAME s -#define DUMMYSTRUCTNAME1 s1 -#define DUMMYSTRUCTNAME2 s2 -#define DUMMYSTRUCTNAME3 s3 -#define DUMMYSTRUCTNAME4 s4 -#define DUMMYSTRUCTNAME5 s5 -#else -#define _STRUCT_NAME(x) -#define DUMMYSTRUCTNAME -#define DUMMYSTRUCTNAME1 -#define DUMMYSTRUCTNAME2 -#define DUMMYSTRUCTNAME3 -#define DUMMYSTRUCTNAME4 -#define DUMMYSTRUCTNAME5 -#endif -#endif /* __ANONYMOUS_DEFINED */ - - #ifndef DECLSPEC_ALIGN # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS) # define DECLSPEC_ALIGN(x) __declspec(align(x)) From afe4af1acf88a3da8376097da8626ef4ce3bcfda Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 23 Nov 2010 11:30:17 +0000 Subject: [PATCH 15/75] [PSDK] Partly sync windef.h with mingw-w64 and add specstrings.h reverts the previous revert, fixed definition of NULL to __null in stddef.h svn path=/trunk/; revision=49722 --- reactos/include/crt/stddef.h | 19 +- reactos/include/psdk/specstrings.h | 273 +++++++++++ reactos/include/psdk/windef.h | 731 +++++++++++++++-------------- reactos/include/psdk/winnt.h | 56 +++ 4 files changed, 726 insertions(+), 353 deletions(-) create mode 100644 reactos/include/psdk/specstrings.h diff --git a/reactos/include/crt/stddef.h b/reactos/include/crt/stddef.h index 9482677272d..0c366e977fd 100644 --- a/reactos/include/crt/stddef.h +++ b/reactos/include/crt/stddef.h @@ -372,20 +372,13 @@ typedef __WCHAR_TYPE__ wchar_t; #endif /* __sys_stdtypes_h */ /* A null pointer constant. */ - -#if defined (_STDDEF_H) || defined (__need_NULL) -#undef NULL /* in case has defined it. */ -#ifdef __GNUG__ -#define NULL __null -#else /* G++ */ -#ifndef __cplusplus -#define NULL ((void *)0) -#else /* C++ */ +#ifndef NULL +#ifdef __cplusplus #define NULL 0 -#endif /* C++ */ -#endif /* G++ */ -#endif /* NULL not defined and or need NULL. */ -#undef __need_NULL +#else +#define NULL ((void*)0) +#endif +#endif #ifndef offsetof diff --git a/reactos/include/psdk/specstrings.h b/reactos/include/psdk/specstrings.h new file mode 100644 index 00000000000..568bb983e04 --- /dev/null +++ b/reactos/include/psdk/specstrings.h @@ -0,0 +1,273 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ +#define __specstrings + +#ifdef __cplusplus +#ifndef __nothrow +#define __nothrow __declspec(nothrow) +#endif +#else +#ifndef __nothrow +#define __nothrow +#endif +#endif + +#define __deref_in +#define __deref_in_ecount(size) +#define __deref_in_bcount(size) +#define __deref_in_opt +#define __deref_in_ecount_opt(size) +#define __deref_in_bcount_opt(size) +#define __deref_opt_in +#define __deref_opt_in_ecount(size) +#define __deref_opt_in_bcount(size) +#define __deref_opt_in_opt +#define __deref_opt_in_ecount_opt(size) +#define __deref_opt_in_bcount_opt(size) +#define __out_awcount(expr,size) +#define __in_awcount(expr,size) +#define __null +#define __notnull +#define __maybenull +#define __readonly +#define __notreadonly +#define __maybereadonly +#define __valid +#define __notvalid +#define __maybevalid +#define __readableTo(extent) +#define __elem_readableTo(size) +#define __byte_readableTo(size) +#define __writableTo(size) +#define __elem_writableTo(size) +#define __byte_writableTo(size) +#define __deref +#define __pre +#define __post +#define __precond(expr) +#define __postcond(expr) +#define __exceptthat +#define __execeptthat +#define __inner_success(expr) +#define __inner_checkReturn +#define __inner_typefix(ctype) +#define __inner_override +#define __inner_callback +#define __inner_blocksOn(resource) +#define __inner_fallthrough_dec +#define __inner_fallthrough +#define __refparam +#define __inner_control_entrypoint(category) +#define __inner_data_entrypoint(category) +#define __ecount(size) +#define __bcount(size) +#define __in +#define __in_opt +#define __in_nz +#define __in_nz_opt +#define __in_z +#define __in_z_opt +#define __in_ecount(size) +#define __in_ecount_nz(size) +#define __in_ecount_z(size) +#define __in_bcount(size) +#define __in_bcount_z(size) +#define __in_bcount_nz(size) +#define __in_ecount_opt(size) +#define __in_bcount_opt(size) +#define __in_ecount_z_opt(size) +#define __in_bcount_z_opt(size) +#define __in_ecount_nz_opt(size) +#define __in_bcount_nz_opt(size) +#define __out +#define __out_ecount(size) +#define __out_z +#define __out_nz +#define __out_nz_opt +#define __out_z_opt +#define __out_ecount_part(size,length) +#define __out_ecount_full(size) +#define __out_ecount_nz(size) +#define __out_ecount_z(size) +#define __out_ecount_part_z(size,length) +#define __out_ecount_full_z(size) +#define __out_bcount(size) +#define __out_bcount_part(size,length) +#define __out_bcount_full(size) +#define __out_bcount_z(size) +#define __out_bcount_part_z(size,length) +#define __out_bcount_full_z(size) +#define __out_bcount_nz(size) +#define __inout +#define __inout_ecount(size) +#define __inout_bcount(size) +#define __inout_ecount_part(size,length) +#define __inout_bcount_part(size,length) +#define __inout_ecount_full(size) +#define __inout_bcount_full(size) +#define __inout_z +#define __inout_ecount_z(size) +#define __inout_bcount_z(size) +#define __inout_nz +#define __inout_ecount_nz(size) +#define __inout_bcount_nz(size) +#define __ecount_opt(size) +#define __bcount_opt(size) +#define __out_opt +#define __out_ecount_opt(size) +#define __out_bcount_opt(size) +#define __out_ecount_part_opt(size,length) +#define __out_bcount_part_opt(size,length) +#define __out_ecount_full_opt(size) +#define __out_bcount_full_opt(size) +#define __out_ecount_z_opt(size) +#define __out_bcount_z_opt(size) +#define __out_ecount_part_z_opt(size,length) +#define __out_bcount_part_z_opt(size,length) +#define __out_ecount_full_z_opt(size) +#define __out_bcount_full_z_opt(size) +#define __out_ecount_nz_opt(size) +#define __out_bcount_nz_opt(size) +#define __inout_opt +#define __inout_ecount_opt(size) +#define __inout_bcount_opt(size) +#define __inout_ecount_part_opt(size,length) +#define __inout_bcount_part_opt(size,length) +#define __inout_ecount_full_opt(size) +#define __inout_bcount_full_opt(size) +#define __inout_z_opt +#define __inout_ecount_z_opt(size) +#define __inout_bcount_z_opt(size) +#define __inout_nz_opt +#define __inout_ecount_nz_opt(size) +#define __inout_bcount_nz_opt(size) +#define __deref_ecount(size) +#define __deref_bcount(size) +#define __deref_out +#define __deref_out_ecount(size) +#define __deref_out_bcount(size) +#define __deref_out_ecount_part(size,length) +#define __deref_out_bcount_part(size,length) +#define __deref_out_ecount_full(size) +#define __deref_out_bcount_full(size) +#define __deref_out_z +#define __deref_out_ecount_z(size) +#define __deref_out_bcount_z(size) +#define __deref_out_nz +#define __deref_out_ecount_nz(size) +#define __deref_out_bcount_nz(size) +#define __deref_inout +#define __deref_inout_ecount(size) +#define __deref_inout_bcount(size) +#define __deref_inout_ecount_part(size,length) +#define __deref_inout_bcount_part(size,length) +#define __deref_inout_ecount_full(size) +#define __deref_inout_bcount_full(size) +#define __deref_inout_z +#define __deref_inout_ecount_z(size) +#define __deref_inout_bcount_z(size) +#define __deref_inout_nz +#define __deref_inout_ecount_nz(size) +#define __deref_inout_bcount_nz(size) +#define __deref_ecount_opt(size) +#define __deref_bcount_opt(size) +#define __deref_out_opt +#define __deref_out_ecount_opt(size) +#define __deref_out_bcount_opt(size) +#define __deref_out_ecount_part_opt(size,length) +#define __deref_out_bcount_part_opt(size,length) +#define __deref_out_ecount_full_opt(size) +#define __deref_out_bcount_full_opt(size) +#define __deref_out_z_opt +#define __deref_out_ecount_z_opt(size) +#define __deref_out_bcount_z_opt(size) +#define __deref_out_nz_opt +#define __deref_out_ecount_nz_opt(size) +#define __deref_out_bcount_nz_opt(size) +#define __deref_inout_opt +#define __deref_inout_ecount_opt(size) +#define __deref_inout_bcount_opt(size) +#define __deref_inout_ecount_part_opt(size,length) +#define __deref_inout_bcount_part_opt(size,length) +#define __deref_inout_ecount_full_opt(size) +#define __deref_inout_bcount_full_opt(size) +#define __deref_inout_z_opt +#define __deref_inout_ecount_z_opt(size) +#define __deref_inout_bcount_z_opt(size) +#define __deref_inout_nz_opt +#define __deref_inout_ecount_nz_opt(size) +#define __deref_inout_bcount_nz_opt(size) +#define __deref_opt_ecount(size) +#define __deref_opt_bcount(size) +#define __deref_opt_out +#define __deref_opt_out_z +#define __deref_opt_out_ecount(size) +#define __deref_opt_out_bcount(size) +#define __deref_opt_out_ecount_part(size,length) +#define __deref_opt_out_bcount_part(size,length) +#define __deref_opt_out_ecount_full(size) +#define __deref_opt_out_bcount_full(size) +#define __deref_opt_inout +#define __deref_opt_inout_ecount(size) +#define __deref_opt_inout_bcount(size) +#define __deref_opt_inout_ecount_part(size,length) +#define __deref_opt_inout_bcount_part(size,length) +#define __deref_opt_inout_ecount_full(size) +#define __deref_opt_inout_bcount_full(size) +#define __deref_opt_inout_z +#define __deref_opt_inout_ecount_z(size) +#define __deref_opt_inout_bcount_z(size) +#define __deref_opt_inout_nz +#define __deref_opt_inout_ecount_nz(size) +#define __deref_opt_inout_bcount_nz(size) +#define __deref_opt_ecount_opt(size) +#define __deref_opt_bcount_opt(size) +#define __deref_opt_out_opt +#define __deref_opt_out_ecount_opt(size) +#define __deref_opt_out_bcount_opt(size) +#define __deref_opt_out_ecount_part_opt(size,length) +#define __deref_opt_out_bcount_part_opt(size,length) +#define __deref_opt_out_ecount_full_opt(size) +#define __deref_opt_out_bcount_full_opt(size) +#define __deref_opt_out_z_opt +#define __deref_opt_out_ecount_z_opt(size) +#define __deref_opt_out_bcount_z_opt(size) +#define __deref_opt_out_nz_opt +#define __deref_opt_out_ecount_nz_opt(size) +#define __deref_opt_out_bcount_nz_opt(size) +#define __deref_opt_inout_opt +#define __deref_opt_inout_ecount_opt(size) +#define __deref_opt_inout_bcount_opt(size) +#define __deref_opt_inout_ecount_part_opt(size,length) +#define __deref_opt_inout_bcount_part_opt(size,length) +#define __deref_opt_inout_ecount_full_opt(size) +#define __deref_opt_inout_bcount_full_opt(size) +#define __deref_opt_inout_z_opt +#define __deref_opt_inout_ecount_z_opt(size) +#define __deref_opt_inout_bcount_z_opt(size) +#define __deref_opt_inout_nz_opt +#define __deref_opt_inout_ecount_nz_opt(size) +#define __deref_opt_inout_bcount_nz_opt(size) +#define __success(expr) +#define __nullterminated +#define __nullnullterminated +#define __reserved +#define __checkReturn +#define __typefix(ctype) +#define __override +#define __callback +#define __format_string +#define __blocksOn(resource) +#define __control_entrypoint(category) +#define __data_entrypoint(category) +#ifndef __fallthrough +#define __fallthrough +#endif +#ifndef __analysis_assume +#define __analysis_assume(expr) +#endif + + diff --git a/reactos/include/psdk/windef.h b/reactos/include/psdk/windef.h index a29a959e747..2412dc75705 100644 --- a/reactos/include/psdk/windef.h +++ b/reactos/include/psdk/windef.h @@ -1,5 +1,17 @@ -#ifndef _WINDEF_H -#define _WINDEF_H +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ +#ifndef _WINDEF_ +#define _WINDEF_ + +#define _WINDEF_H // wine ... + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4255) +#endif #ifndef _M_AMD64 #if !defined(__ROS_LONG64__) @@ -9,62 +21,68 @@ #endif #endif +#ifndef NO_STRICT +#ifndef STRICT +#define STRICT 1 +#endif +#endif + +#ifndef WIN32 +#define WIN32 +#endif + +#if defined(_MAC) && !defined(_WIN32) +#define _WIN32 +#endif + #ifdef __cplusplus extern "C" { #endif -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4255) +#ifndef WINVER +#define WINVER 0x0502 #endif -#ifndef WINVER -#define WINVER 0x0400 -/* - * If you need Win32 API features newer the Win95 and WinNT then you must - * define WINVER before including windows.h or any other method of including - * the windef.h header. - */ -#endif -#ifndef _WIN32_WINNT -#define _WIN32_WINNT WINVER -/* - * There may be the need to define _WIN32_WINNT to a value different from - * the value of WINVER. I don't have any example of why you would do that. - * However, if you must then define _WIN32_WINNT to the value required before - * including windows.h or any other method of including the windef.h header. - */ -#endif -#ifndef WIN32 -#define WIN32 -#endif -#ifndef _WIN32 -#define _WIN32 -#endif -#define FAR -#define far -#define NEAR -#define near -#ifndef CONST -#define CONST const +#ifndef BASETYPES +#define BASETYPES +#ifndef __ROS_LONG64__ +typedef unsigned long ULONG; +#else +typedef unsigned int ULONG; #endif +typedef ULONG *PULONG; +typedef unsigned short USHORT; +typedef USHORT *PUSHORT; +typedef unsigned char UCHAR; +typedef UCHAR *PUCHAR; +typedef char *PSZ; +typedef int INT; +#endif /* BASETYPES */ + #undef MAX_PATH #define MAX_PATH 260 #ifndef NULL #ifdef __cplusplus +#ifndef _WIN64 #define NULL 0 #else -#define NULL ((void*)0) +#define NULL 0LL +#endif /* W64 */ +#else +#define NULL ((void *)0) #endif #endif + #ifndef FALSE #define FALSE 0 #endif + #ifndef TRUE #define TRUE 1 #endif +#ifndef _NO_W32_PSEUDO_MODIFIERS #ifndef IN #define IN #endif @@ -74,6 +92,307 @@ extern "C" { #ifndef OPTIONAL #define OPTIONAL #endif +#endif + +#ifdef __GNUC__ +#define PACKED __attribute__((packed)) +#ifndef __declspec +#define __declspec(e) __attribute__((e)) +#endif +#ifndef _declspec +#define _declspec(e) __attribute__((e)) +#endif +#elif defined(__WATCOMC__) +#define PACKED +#else +#define PACKED +#define _cdecl +#define __cdecl +#endif + +#ifdef __GNUC__ +#define DECLSPEC_NORETURN __declspec(noreturn) +#define DECLARE_STDCALL_P( type ) __stdcall type +#elif defined(__WATCOMC__) +#define DECLSPEC_NORETURN +#define DECLARE_STDCALL_P( type ) type __stdcall +#elif defined(_MSC_VER) +#define DECLSPEC_NORETURN __declspec(noreturn) +#define DECLARE_STDCALL_P( type ) type __stdcall +#endif /* __GNUC__/__WATCOMC__ */ + +#define DECLSPEC_IMPORT __declspec(dllimport) +#define DECLSPEC_EXPORT __declspec(dllexport) +#ifndef DECLSPEC_NOINLINE +#if (_MSC_VER >= 1300) +#define DECLSPEC_NOINLINE __declspec(noinline) +#elif defined(__GNUC__) +#define DECLSPEC_NOINLINE __attribute__((noinline)) +#else +#define DECLSPEC_NOINLINE +#endif +#endif + +#undef far +#undef near +#undef pascal + +#define far +#define near +#define pascal __stdcall + +//#define cdecl _cdecl +#ifndef CDECL +#define CDECL _cdecl +#endif + +#if !defined(__x86_64__) //defined(_STDCALL_SUPPORTED) +#ifndef CALLBACK +#define CALLBACK __stdcall +#endif +#ifndef WINAPI +#define WINAPI __stdcall +#endif +#define WINAPIV __cdecl +#define APIENTRY WINAPI +#define APIPRIVATE WINAPI +#define PASCAL WINAPI +#else +#define CALLBACK +#define WINAPI +#define WINAPIV +#define APIENTRY WINAPI +#define APIPRIVATE +#define PASCAL pascal +#endif + +#undef FAR +#undef NEAR +#define FAR +#define NEAR + +#ifndef CONST +#define CONST const +#endif + +#ifndef _DEF_WINBOOL_ +#define _DEF_WINBOOL_ +typedef int WINBOOL; +#pragma push_macro("BOOL") +#undef BOOL +#if !defined(__OBJC__) && !defined(__OBJC_BOOL) && !defined(__objc_INCLUDE_GNU) +typedef int BOOL; +#endif +#define BOOL WINBOOL +typedef BOOL *PBOOL; +typedef BOOL *LPBOOL; +#pragma pop_macro("BOOL") +#endif /* _DEF_WINBOOL_ */ + +typedef unsigned char BYTE; +typedef unsigned short WORD; +#ifndef __ROS_LONG64__ + typedef unsigned long DWORD; +#else + typedef unsigned int DWORD; +#endif +typedef float FLOAT; +typedef FLOAT *PFLOAT; +typedef BYTE *PBYTE; +typedef BYTE *LPBYTE; +typedef int *PINT; +typedef int *LPINT; +typedef WORD *PWORD; +typedef WORD *LPWORD; +#ifndef __ROS_LONG64__ +typedef long *LPLONG; +#else +typedef int *LPLONG; +#endif +typedef DWORD *PDWORD; +typedef DWORD *LPDWORD; +typedef void *LPVOID; +#ifndef _LPCVOID_DEFINED +#define _LPCVOID_DEFINED +typedef CONST void *LPCVOID; +#endif +//typedef int INT; +typedef unsigned int UINT; +typedef unsigned int *PUINT; +typedef unsigned int *LPUINT; + + + + +#ifndef NT_INCLUDED +#include +#endif + +#include + +typedef UINT_PTR WPARAM; +typedef LONG_PTR LPARAM; +typedef LONG_PTR LRESULT; +#ifndef _HRESULT_DEFINED +typedef LONG HRESULT; +#define _HRESULT_DEFINED +#endif + +#ifndef NOMINMAX +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif +#endif + +#define MAKEWORD(a,b) ((WORD)(((BYTE)((DWORD_PTR)(a) & 0xff)) | ((WORD)((BYTE)((DWORD_PTR)(b) & 0xff))) << 8)) +#define MAKELONG(a,b) ((LONG)(((WORD)((DWORD_PTR)(a) & 0xffff)) | ((DWORD)((WORD)((DWORD_PTR)(b) & 0xffff))) << 16)) +#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xffff)) +#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16)) +#define LOBYTE(w) ((BYTE)((DWORD_PTR)(w) & 0xff)) +#define HIBYTE(w) ((BYTE)((DWORD_PTR)(w) >> 8)) + +#ifndef WIN_INTERNAL +DECLARE_HANDLE (HWND); +//DECLARE_HANDLE (HHOOK); +#ifdef WINABLE +DECLARE_HANDLE (HEVENT); +#endif +#endif + +typedef WORD ATOM; + +typedef HANDLE *SPHANDLE; +typedef HANDLE *LPHANDLE; +typedef HANDLE HGLOBAL; +typedef HANDLE HLOCAL; +typedef HANDLE GLOBALHANDLE; +typedef HANDLE LOCALHANDLE; +#ifdef _WIN64 +typedef INT_PTR (WINAPI *FARPROC)(); +typedef INT_PTR (WINAPI *NEARPROC)(); +typedef INT_PTR (WINAPI *PROC)(); +#else +typedef int (WINAPI *FARPROC)(); +typedef int (WINAPI *NEARPROC)(); +typedef int (WINAPI *PROC)(); +#endif + +typedef void *HGDIOBJ; + +DECLARE_HANDLE(HKEY); +typedef HKEY *PHKEY; + +DECLARE_HANDLE(HACCEL); +DECLARE_HANDLE(HBITMAP); +DECLARE_HANDLE(HBRUSH); +DECLARE_HANDLE(HCOLORSPACE); +DECLARE_HANDLE(HDC); +DECLARE_HANDLE(HGLRC); +DECLARE_HANDLE(HDESK); +DECLARE_HANDLE(HENHMETAFILE); +DECLARE_HANDLE(HFONT); +DECLARE_HANDLE(HICON); +DECLARE_HANDLE(HMENU); +DECLARE_HANDLE(HMETAFILE); +DECLARE_HANDLE(HINSTANCE); +typedef HINSTANCE HMODULE; +DECLARE_HANDLE(HPALETTE); +DECLARE_HANDLE(HPEN); +DECLARE_HANDLE(HRGN); +DECLARE_HANDLE(HRSRC); +DECLARE_HANDLE(HSTR); +DECLARE_HANDLE(HTASK); +DECLARE_HANDLE(HWINSTA); +DECLARE_HANDLE(HKL); +DECLARE_HANDLE(HMONITOR); +DECLARE_HANDLE(HWINEVENTHOOK); +DECLARE_HANDLE(HUMPD); + +typedef int HFILE; +typedef HICON HCURSOR; +typedef DWORD COLORREF; +typedef DWORD *LPCOLORREF; + +#define HFILE_ERROR ((HFILE)-1) + +typedef struct tagRECT { + LONG left; + LONG top; + LONG right; + LONG bottom; +} RECT,*PRECT,*NPRECT,*LPRECT; + +typedef const RECT *LPCRECT; + +typedef struct _RECTL { + LONG left; + LONG top; + LONG right; + LONG bottom; +} RECTL,*PRECTL,*LPRECTL; + +typedef const RECTL *LPCRECTL; + +typedef struct tagPOINT { + LONG x; + LONG y; +} POINT,*PPOINT,*NPPOINT,*LPPOINT; + +typedef struct _POINTL { + LONG x; + LONG y; +} POINTL,*PPOINTL; + +typedef struct tagSIZE { + LONG cx; + LONG cy; +} SIZE,*PSIZE,*LPSIZE; + +typedef SIZE SIZEL; +typedef SIZE *PSIZEL,*LPSIZEL; + +typedef struct tagPOINTS { + SHORT x; + SHORT y; +} POINTS,*PPOINTS,*LPPOINTS; + +typedef struct _FILETIME { + DWORD dwLowDateTime; + DWORD dwHighDateTime; +} FILETIME,*PFILETIME,*LPFILETIME; +#define _FILETIME_ + +#define DM_UPDATE 1 +#define DM_COPY 2 +#define DM_PROMPT 4 +#define DM_MODIFY 8 + +#define DM_IN_BUFFER DM_MODIFY +#define DM_IN_PROMPT DM_PROMPT +#define DM_OUT_BUFFER DM_COPY +#define DM_OUT_DEFAULT DM_UPDATE + +#define DC_FIELDS 1 +#define DC_PAPERS 2 +#define DC_PAPERSIZE 3 +#define DC_MINEXTENT 4 +#define DC_MAXEXTENT 5 +#define DC_BINS 6 +#define DC_DUPLEX 7 +#define DC_SIZE 8 +#define DC_EXTRA 9 +#define DC_VERSION 10 +#define DC_DRIVER 11 +#define DC_BINNAMES 12 +#define DC_ENUMRESOLUTIONS 13 +#define DC_FILEDEPENDENCIES 14 +#define DC_TRUETYPE 15 +#define DC_PAPERNAMES 16 +#define DC_ORIENTATION 17 +#define DC_COPIES 18 /* needed by header files generated by WIDL */ #ifdef __WINESRC__ @@ -98,26 +417,41 @@ extern "C" { # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type; #endif +#define UNREFERENCED_PARAMETER(P) {(P)=(P);} +#define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} +#define DBG_UNREFERENCED_PARAMETER(P) +#define DBG_UNREFERENCED_LOCAL_VARIABLE(L) + +#ifndef __WATCOMC__ +#ifndef _export +#define _export +#endif +#ifndef __export +#define __export +#endif +#endif + +#if 0 #ifdef __GNUC__ #define PACKED __attribute__((packed)) -#ifndef _fastcall -#define _fastcall __attribute__((fastcall)) -#endif -#ifndef __fastcall -#define __fastcall __attribute__((fastcall)) -#endif -#ifndef _stdcall -#define _stdcall __attribute__((stdcall)) -#endif -#ifndef __stdcall -#define __stdcall __attribute__((stdcall)) -#endif -#ifndef _cdecl -#define _cdecl __attribute__((cdecl)) -#endif -#ifndef __cdecl -#define __cdecl __attribute__((cdecl)) -#endif +//#ifndef _fastcall +//#define _fastcall __attribute__((fastcall)) +//#endif +//#ifndef __fastcall +//#define __fastcall __attribute__((fastcall)) +//#endif +//#ifndef _stdcall +//#define _stdcall __attribute__((stdcall)) +//#endif +//#ifndef __stdcall +//#define __stdcall __attribute__((stdcall)) +//#endif +//#ifndef _cdecl +//#define _cdecl __attribute__((cdecl)) +//#endif +//#ifndef __cdecl +//#define __cdecl __attribute__((cdecl)) +//#endif #ifndef __declspec #define __declspec(e) __attribute__((e)) #endif @@ -131,186 +465,9 @@ extern "C" { #define _cdecl #define __cdecl #endif - -#undef pascal -#undef _pascal -#undef __pascal -#define pascal __stdcall -#define _pascal __stdcall -#define __pascal __stdcall - -#define CDECL _cdecl - -#if !defined(__x86_64__) //defined(_STDCALL_SUPPORTED) -#define CALLBACK __stdcall -#define WINAPI __stdcall -#define WINAPIV __cdecl -#define APIENTRY WINAPI -#define APIPRIVATE __stdcall -#define PASCAL __stdcall -#else -#define CALLBACK -#define WINAPI -#define WINAPIV -#define APIENTRY WINAPI -#define APIPRIVATE -#define PASCAL pascal #endif -#define DECLSPEC_IMPORT __declspec(dllimport) -#define DECLSPEC_EXPORT __declspec(dllexport) -#ifndef DECLSPEC_NOINLINE -#if (_MSC_VER >= 1300) -#define DECLSPEC_NOINLINE __declspec(noinline) -#elif defined(__GNUC__) -#define DECLSPEC_NOINLINE __attribute__((noinline)) -#else -#define DECLSPEC_NOINLINE -#endif -#endif -#ifdef __GNUC__ -#define DECLSPEC_NORETURN __declspec(noreturn) -#define DECLARE_STDCALL_P( type ) __stdcall type -#elif defined(__WATCOMC__) -#define DECLSPEC_NORETURN -#define DECLARE_STDCALL_P( type ) type __stdcall -#elif defined(_MSC_VER) -#define DECLSPEC_NORETURN __declspec(noreturn) -#define DECLARE_STDCALL_P( type ) type __stdcall -#endif /* __GNUC__/__WATCOMC__ */ -#define MAKEWORD(a,b) ((WORD)(((BYTE)(a))|(((WORD)((BYTE)(b)))<<8))) -#define MAKELONG(a,b) ((LONG)(((WORD)(a))|(((DWORD)((WORD)(b)))<<16))) -#define LOWORD(l) ((WORD)((DWORD_PTR)(l))) -#define HIWORD(l) ((WORD)(((DWORD_PTR)(l)>>16)&0xFFFF)) -#define LOBYTE(w) ((BYTE)(w)) -#define HIBYTE(w) ((BYTE)(((WORD)(w)>>8)&0xFF)) - -#ifndef __WATCOMC__ -#ifndef _export -#define _export -#endif -#ifndef __export -#define __export -#endif -#endif - -#ifndef NOMINMAX - #ifndef max - #define max(a,b) ((a)>(b)?(a):(b)) - #endif - - #ifndef min - #define min(a,b) ((a)<(b)?(a):(b)) - #endif -#endif - -#define UNREFERENCED_PARAMETER(P) {(P)=(P);} -#define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} -#define DBG_UNREFERENCED_PARAMETER(P) -#define DBG_UNREFERENCED_LOCAL_VARIABLE(L) - -#ifndef __ANONYMOUS_DEFINED -#define __ANONYMOUS_DEFINED - -#ifndef NONAMELESSUNION -#ifdef __GNUC__ -#define _ANONYMOUS_UNION __extension__ -#define _ANONYMOUS_STRUCT __extension__ -#elif defined(__WATCOMC__) || defined(_MSC_VER) -#define _ANONYMOUS_UNION -#define _ANONYMOUS_STRUCT -#endif /* __GNUC__/__WATCOMC__ */ -#endif /* NONAMELESSUNION */ - -#ifndef _ANONYMOUS_UNION -#define _ANONYMOUS_UNION -#define _UNION_NAME(x) x -#define DUMMYUNIONNAME u -#define DUMMYUNIONNAME1 u1 -#define DUMMYUNIONNAME2 u2 -#define DUMMYUNIONNAME3 u3 -#define DUMMYUNIONNAME4 u4 -#define DUMMYUNIONNAME5 u5 -#define DUMMYUNIONNAME6 u6 -#define DUMMYUNIONNAME7 u7 -#define DUMMYUNIONNAME8 u8 -#else -#define _UNION_NAME(x) -#define DUMMYUNIONNAME -#define DUMMYUNIONNAME1 -#define DUMMYUNIONNAME2 -#define DUMMYUNIONNAME3 -#define DUMMYUNIONNAME4 -#define DUMMYUNIONNAME5 -#define DUMMYUNIONNAME6 -#define DUMMYUNIONNAME7 -#define DUMMYUNIONNAME8 -#endif -#ifndef _ANONYMOUS_STRUCT -#define _ANONYMOUS_STRUCT -#define _STRUCT_NAME(x) x -#define DUMMYSTRUCTNAME s -#define DUMMYSTRUCTNAME1 s1 -#define DUMMYSTRUCTNAME2 s2 -#define DUMMYSTRUCTNAME3 s3 -#define DUMMYSTRUCTNAME4 s4 -#define DUMMYSTRUCTNAME5 s5 -#else -#define _STRUCT_NAME(x) -#define DUMMYSTRUCTNAME -#define DUMMYSTRUCTNAME1 -#define DUMMYSTRUCTNAME2 -#define DUMMYSTRUCTNAME3 -#define DUMMYSTRUCTNAME4 -#define DUMMYSTRUCTNAME5 -#endif - -#endif /* __ANONYMOUS_DEFINED */ - -#ifndef NO_STRICT -#ifndef STRICT -#define STRICT 1 -#endif -#endif - -#ifndef DWORD_DEFINED -#define DWORD_DEFINED -#ifndef __ROS_LONG64__ - typedef unsigned long DWORD; -#else - typedef unsigned int DWORD; -#endif -#endif//DWORD_DEFINED - -typedef int WINBOOL,*PWINBOOL,*LPWINBOOL; -/* FIXME: Is there a good solution to this? */ -#ifndef XFree86Server -#ifndef __OBJC__ -typedef WINBOOL BOOL; -#else -#define BOOL WINBOOL -#endif -typedef unsigned char BYTE; -#endif /* ndef XFree86Server */ -typedef BOOL *PBOOL,*LPBOOL; -typedef unsigned short WORD; -typedef float FLOAT; -typedef FLOAT *PFLOAT; -typedef BYTE *PBYTE,*LPBYTE; -typedef int *PINT,*LPINT; -typedef WORD *PWORD,*LPWORD; -#ifndef __ROS_LONG64__ -typedef long *LPLONG; -#else -typedef int *LPLONG; -#endif -typedef DWORD *PDWORD,*LPDWORD; -typedef CONST void *LPCVOID; - -typedef unsigned int UINT,*PUINT,*LPUINT; - -typedef void *LPVOID; - +#if 1 // needed by shlwapi.h #ifndef __ms_va_list # if defined(__x86_64__) && defined (__GNUC__) # define __ms_va_list __builtin_ms_va_list @@ -322,115 +479,7 @@ typedef void *LPVOID; # define __ms_va_end(list) va_end(list) # endif #endif - -// -// Check if ntdef.h already defined these for us -// -#ifndef BASETYPES -#define BASETYPES -#ifndef __ROS_LONG64__ -typedef unsigned long ULONG, *PULONG; -#else -typedef unsigned int ULONG, *PULONG; #endif -typedef unsigned short USHORT, *PUSHORT; -typedef unsigned char UCHAR, *PUCHAR; -typedef char *PSZ; -typedef int INT; -#endif /* BASETYPES */ - -#ifndef NT_INCLUDED -#include -#endif - -typedef HANDLE *LPHANDLE; -typedef UINT_PTR WPARAM; -typedef LONG_PTR LPARAM; -typedef LONG_PTR LRESULT; -#ifndef _HRESULT_DEFINED -typedef LONG HRESULT; -#define _HRESULT_DEFINED -#endif -#ifndef XFree86Server -typedef WORD ATOM; -#endif /* XFree86Server */ -typedef HANDLE HGLOBAL; -typedef HANDLE HLOCAL; -typedef HANDLE GLOBALHANDLE; -typedef HANDLE LOCALHANDLE; -typedef void *HGDIOBJ; -DECLARE_HANDLE(HACCEL); -DECLARE_HANDLE(HBITMAP); -DECLARE_HANDLE(HBRUSH); -DECLARE_HANDLE(HCOLORSPACE); -DECLARE_HANDLE(HDC); -DECLARE_HANDLE(HGLRC); -DECLARE_HANDLE(HDESK); -DECLARE_HANDLE(HENHMETAFILE); -DECLARE_HANDLE(HFONT); -DECLARE_HANDLE(HICON); -DECLARE_HANDLE(HKEY); -/* FIXME: How to handle these. SM_CMONITORS etc in winuser.h also. */ -/* #if (WINVER >= 0x0500) */ -DECLARE_HANDLE(HMONITOR); -DECLARE_HANDLE(HUMPD); -#define HMONITOR_DECLARED 1 -DECLARE_HANDLE(HTERMINAL); -DECLARE_HANDLE(HWINEVENTHOOK); -/* #endif */ -typedef HKEY *PHKEY; -DECLARE_HANDLE(HMENU); -DECLARE_HANDLE(HMETAFILE); -DECLARE_HANDLE(HINSTANCE); -typedef HINSTANCE HMODULE; -DECLARE_HANDLE(HPALETTE); -DECLARE_HANDLE(HPEN); -DECLARE_HANDLE(HRGN); -DECLARE_HANDLE(HRSRC); -DECLARE_HANDLE(HSTR); -DECLARE_HANDLE(HTASK); -DECLARE_HANDLE(HWND); -DECLARE_HANDLE(HWINSTA); -DECLARE_HANDLE(HKL); -typedef int HFILE; -typedef HICON HCURSOR; -typedef DWORD COLORREF; -typedef DWORD* LPCOLORREF; -#ifdef _WIN64 -typedef INT_PTR (FAR WINAPI *FARPROC)(); -typedef INT_PTR (NEAR WINAPI *NEARPROC)(); -typedef INT_PTR (WINAPI *PROC)(); -#else -typedef int (FAR WINAPI *FARPROC)(); -typedef int (NEAR WINAPI *NEARPROC)(); -typedef int (WINAPI *PROC)(); -#endif -typedef struct tagRECT { - LONG left; - LONG top; - LONG right; - LONG bottom; -} RECT,*PRECT,*LPRECT; -typedef const RECT *LPCRECT; -typedef struct tagRECTL { - LONG left; - LONG top; - LONG right; - LONG bottom; -} RECTL,*PRECTL,*LPRECTL; -typedef const RECTL *LPCRECTL; -typedef struct tagPOINT { - LONG x; - LONG y; -} POINT,POINTL,*PPOINT,*LPPOINT,*PPOINTL,*LPPOINTL; -typedef struct tagSIZE { - LONG cx; - LONG cy; -} SIZE,SIZEL,*PSIZE,*LPSIZE,*PSIZEL,*LPSIZEL; -typedef struct tagPOINTS { - SHORT x; - SHORT y; -} POINTS,*PPOINTS,*LPPOINTS; #ifdef _MSC_VER #pragma warning(pop) @@ -439,4 +488,6 @@ typedef struct tagPOINTS { #ifdef __cplusplus } #endif -#endif + +#endif /* _WINDEF_ */ + diff --git a/reactos/include/psdk/winnt.h b/reactos/include/psdk/winnt.h index 7967047c4d1..7b2070948a5 100644 --- a/reactos/include/psdk/winnt.h +++ b/reactos/include/psdk/winnt.h @@ -11,6 +11,62 @@ #include #endif +#ifndef __ANONYMOUS_DEFINED +#define __ANONYMOUS_DEFINED +#ifndef NONAMELESSUNION +#ifdef __GNUC__ +#define _ANONYMOUS_UNION __extension__ +#define _ANONYMOUS_STRUCT __extension__ +#elif defined(__WATCOMC__) || defined(_MSC_VER) +#define _ANONYMOUS_UNION +#define _ANONYMOUS_STRUCT +#endif /* __GNUC__/__WATCOMC__ */ +#endif /* NONAMELESSUNION */ +#ifndef _ANONYMOUS_UNION +#define _ANONYMOUS_UNION +#define _UNION_NAME(x) x +#define DUMMYUNIONNAME u +#define DUMMYUNIONNAME1 u1 +#define DUMMYUNIONNAME2 u2 +#define DUMMYUNIONNAME3 u3 +#define DUMMYUNIONNAME4 u4 +#define DUMMYUNIONNAME5 u5 +#define DUMMYUNIONNAME6 u6 +#define DUMMYUNIONNAME7 u7 +#define DUMMYUNIONNAME8 u8 +#else +#define _UNION_NAME(x) +#define DUMMYUNIONNAME +#define DUMMYUNIONNAME1 +#define DUMMYUNIONNAME2 +#define DUMMYUNIONNAME3 +#define DUMMYUNIONNAME4 +#define DUMMYUNIONNAME5 +#define DUMMYUNIONNAME6 +#define DUMMYUNIONNAME7 +#define DUMMYUNIONNAME8 +#endif +#ifndef _ANONYMOUS_STRUCT +#define _ANONYMOUS_STRUCT +#define _STRUCT_NAME(x) x +#define DUMMYSTRUCTNAME s +#define DUMMYSTRUCTNAME1 s1 +#define DUMMYSTRUCTNAME2 s2 +#define DUMMYSTRUCTNAME3 s3 +#define DUMMYSTRUCTNAME4 s4 +#define DUMMYSTRUCTNAME5 s5 +#else +#define _STRUCT_NAME(x) +#define DUMMYSTRUCTNAME +#define DUMMYSTRUCTNAME1 +#define DUMMYSTRUCTNAME2 +#define DUMMYSTRUCTNAME3 +#define DUMMYSTRUCTNAME4 +#define DUMMYSTRUCTNAME5 +#endif +#endif /* __ANONYMOUS_DEFINED */ + + #ifndef DECLSPEC_ALIGN # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS) # define DECLSPEC_ALIGN(x) __declspec(align(x)) From eb64df8ebdc2c2d06c141c0a352acb4152a2a862 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 23 Nov 2010 11:47:50 +0000 Subject: [PATCH 16/75] [PSDK] Don't define __in and __null on c++ build. as long as we keep using host headers, this won't work svn path=/trunk/; revision=49723 --- reactos/include/psdk/specstrings.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/reactos/include/psdk/specstrings.h b/reactos/include/psdk/specstrings.h index 568bb983e04..de2c0bae219 100644 --- a/reactos/include/psdk/specstrings.h +++ b/reactos/include/psdk/specstrings.h @@ -29,7 +29,9 @@ #define __deref_opt_in_bcount_opt(size) #define __out_awcount(expr,size) #define __in_awcount(expr,size) +#ifndef __cplusplus #define __null +#endif #define __notnull #define __maybenull #define __readonly @@ -64,7 +66,9 @@ #define __inner_data_entrypoint(category) #define __ecount(size) #define __bcount(size) +#ifndef __cplusplus #define __in +#endif #define __in_opt #define __in_nz #define __in_nz_opt @@ -270,4 +274,5 @@ #define __analysis_assume(expr) #endif +//#endif From 90b23eee60c7116b3624df4c5ad40a25a7a1980e Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Tue, 23 Nov 2010 16:08:39 +0000 Subject: [PATCH 17/75] [PSDK] Comment out specstrings.h inclusion in windef.h as per Timo's request. Fixes build. svn path=/trunk/; revision=49724 --- reactos/include/psdk/windef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/include/psdk/windef.h b/reactos/include/psdk/windef.h index 2412dc75705..1fa768b2ecd 100644 --- a/reactos/include/psdk/windef.h +++ b/reactos/include/psdk/windef.h @@ -228,7 +228,7 @@ typedef unsigned int *LPUINT; #include #endif -#include +//#include typedef UINT_PTR WPARAM; typedef LONG_PTR LPARAM; From 49914debb9d014c9849b4a23f4f91c7c5fcf8200 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Tue, 23 Nov 2010 16:32:18 +0000 Subject: [PATCH 18/75] [ARM]: Our new target is the ZOOM2 OMAP3, instead of Beagle (but we'll keep testing both). svn path=/trunk/; revision=49725 --- reactos/config-arm.template.rbuild | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/config-arm.template.rbuild b/reactos/config-arm.template.rbuild index dca25d53c0f..08000f9f6e7 100644 --- a/reactos/config-arm.template.rbuild +++ b/reactos/config-arm.template.rbuild @@ -15,10 +15,10 @@ - + + + + + + + + + + From 1a6196d960424f6850b6a6a5e00c382bfbe1f982 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 24 Nov 2010 16:09:19 +0000 Subject: [PATCH 65/75] [NTOS]: Add MiGetPteOffset for ARM. All of the kernel compiles, but does not link yet. svn path=/trunk/; revision=49778 --- reactos/ntoskrnl/include/internal/arm/mm.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/arm/mm.h b/reactos/ntoskrnl/include/internal/arm/mm.h index f70f5c46f21..b73179c6359 100644 --- a/reactos/ntoskrnl/include/internal/arm/mm.h +++ b/reactos/ntoskrnl/include/internal/arm/mm.h @@ -150,8 +150,9 @@ PULONG MmGetPageDirectory(VOID); #define MiAddressToPte(x) MiGetPteAddress(x) /* Retrives the PDE offset for the given VA */ -#define MiGetPdeOffset(x) (((ULONG)(x)) >> 20) -//#define MiGetPteOffset(x) (((ULONG)(x)) >> 12) +#define MiGetPdeOffset(x) (((ULONG)(x)) >> 20) +#define MiGetPteOffset(x) ((((ULONG)(x)) << 12) >> 24) +#define MiAddressToPteOffset(x) MiGetPteOffset(x) /* Convert a PTE into a corresponding address */ #define MiPteToAddress(x) ((PVOID)((ULONG)(x) << 10)) From 85adb4ff8048f1dbb3dbe8aad8f7bed8e4a2c6a1 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Wed, 24 Nov 2010 17:24:54 +0000 Subject: [PATCH 66/75] [NTOSKRNL] That's not because ARM will rule the world on a day that you're obliged to break x86 build. Fixed build. Will it work? Only God knows. svn path=/trunk/; revision=49779 --- reactos/ntoskrnl/include/internal/i386/mm.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/include/internal/i386/mm.h b/reactos/ntoskrnl/include/internal/i386/mm.h index e8cfd55ae77..2f70fd5e2f3 100644 --- a/reactos/ntoskrnl/include/internal/i386/mm.h +++ b/reactos/ntoskrnl/include/internal/i386/mm.h @@ -39,6 +39,7 @@ PULONG MmGetPageDirectory(VOID); // Convert a PTE into a corresponding address // #define MiPteToAddress(PTE) ((PVOID)((ULONG)(PTE) << 10)) +#define MiPdeToAddress(PDE) ((PVOID)((ULONG)(PDE) << 18)) #define ADDR_TO_PAGE_TABLE(v) (((ULONG)(v)) / (1024 * PAGE_SIZE)) #define ADDR_TO_PDE_OFFSET(v) ((((ULONG)(v)) / (1024 * PAGE_SIZE))) @@ -55,7 +56,7 @@ PULONG MmGetPageDirectory(VOID); #define MI_PAGE_DISABLE_CACHE(x) ((x)->u.Hard.CacheDisable = 1) #define MI_PAGE_WRITE_THROUGH(x) ((x)->u.Hard.WriteThrough = 1) #define MI_PAGE_WRITE_COMBINED(x) ((x)->u.Hard.WriteThrough = 0) -#define MI_IS_PAGE_LARGE(x) ((x)->u.Hard.Large == 1) +#define MI_IS_PAGE_LARGE(x) ((x)->u.Hard.LargePage == 1) #if !defined(CONFIG_SMP) #define MI_IS_PAGE_WRITEABLE(x) ((x)->u.Hard.Write == 1) #else @@ -81,6 +82,18 @@ PULONG MmGetPageDirectory(VOID); #define TEB_BASE 0x7FFDE000 +#define MI_HYPERSPACE_PTES (256 - 1) +#define MI_ZERO_PTES (32) +#define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE +#define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \ + MI_HYPERSPACE_PTES * PAGE_SIZE) +#define MI_DUMMY_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \ + PAGE_SIZE) +#define MI_VAD_BITMAP (PMMPTE)(MI_DUMMY_PTE + \ + PAGE_SIZE) +#define MI_WORKING_SET_LIST (PMMPTE)(MI_VAD_BITMAP + \ + PAGE_SIZE) + /* On x86, these two are the same */ #define MMPDE MMPTE #define PMMPDE PMMPTE From a19af9c7cb42ea6a9957d108f7e066a458d02bd8 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 24 Nov 2010 17:26:30 +0000 Subject: [PATCH 67/75] [NDK]: Fix definition of ARM PTE/PDE structure. [NTOS]: Fix up ARM code to match recent ARM3 changes. [NTOS]: Do not use initguid inside every single file to zillionplicate the GUIDs! Why doesn't the x86 linker catch this?!!? [ARMDDK]: Define some spinlock functions. svn path=/trunk/; revision=49780 --- .../freeldr/freeldr/windows/arm/wlmemory.c | 2 +- reactos/include/ddk/wdm.h | 2 +- reactos/include/ndk/arm/mmtypes.h | 74 +++++----- reactos/include/reactos/arm/armddk.h | 29 ++++ reactos/ntoskrnl/include/internal/po.h | 2 +- reactos/ntoskrnl/mm/ARM3/arm/init.c | 13 +- reactos/ntoskrnl/mm/ARM3/miarm.h | 20 ++- reactos/ntoskrnl/mm/arm/page.c | 131 ++++++++++++++---- reactos/ntoskrnl/mm/arm/stubs.c | 36 ----- reactos/ntoskrnl/po/power.c | 1 + 10 files changed, 189 insertions(+), 121 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/windows/arm/wlmemory.c b/reactos/boot/freeldr/freeldr/windows/arm/wlmemory.c index 994089bdb0b..37356a4107f 100644 --- a/reactos/boot/freeldr/freeldr/windows/arm/wlmemory.c +++ b/reactos/boot/freeldr/freeldr/windows/arm/wlmemory.c @@ -200,7 +200,7 @@ MempAllocatePageTables(VOID) PFN_NUMBER Pfn; /* Setup templates */ - TempPte.Accessed = TempPte.Valid = TempLargePte.LargePage = TempLargePte.Accessed = TempPde.Valid = 1; + TempPte.Sbo = TempPte.Valid = TempLargePte.LargePage = TempLargePte.Sbo = TempPde.Valid = 1; /* Allocate the 1MB "PDR" (Processor Data Region). Must be 1MB aligned */ PdrPage = MmAllocateMemoryAtAddress(sizeof(KPDR_PAGE), diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index 233a0c96a4b..05f57a0d23f 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -9726,7 +9726,7 @@ KeQuerySystemTime( OUT PLARGE_INTEGER CurrentTime); #endif /* !_M_AMD64 */ -#if !defined(_X86_) +#if !defined(_X86_) && !defined(_M_ARM) NTKERNELAPI KIRQL NTAPI diff --git a/reactos/include/ndk/arm/mmtypes.h b/reactos/include/ndk/arm/mmtypes.h index febadda1cd5..371b1594368 100644 --- a/reactos/include/ndk/arm/mmtypes.h +++ b/reactos/include/ndk/arm/mmtypes.h @@ -68,7 +68,7 @@ typedef struct _HARDWARE_LARGE_PTE_ARMV6 ULONG NoExecute:1; ULONG Domain:4; ULONG Ecc:1; - ULONG Accessed:1; + ULONG Sbo:1; ULONG Owner:1; ULONG CacheAttributes:3; ULONG ReadOnly:1; @@ -85,7 +85,7 @@ typedef struct _HARDWARE_PTE_ARMV6 ULONG Valid:1; ULONG Buffered:1; ULONG Cached:1; - ULONG Accessed:1; + ULONG Sbo:1; ULONG Owner:1; ULONG CacheAttributes:3; ULONG ReadOnly:1; @@ -100,9 +100,9 @@ C_ASSERT(sizeof(HARDWARE_PTE_ARMV6) == sizeof(ULONG)); typedef struct _MMPTE_SOFTWARE { - ULONG Valid:1; + ULONG Valid:2; ULONG PageFileLow:4; - ULONG Protection:5; + ULONG Protection:4; ULONG Prototype:1; ULONG Transition:1; ULONG PageFileHigh:20; @@ -110,12 +110,12 @@ typedef struct _MMPTE_SOFTWARE typedef struct _MMPTE_TRANSITION { - ULONG Valid:1; - ULONG Write:1; + ULONG Valid:2; + ULONG Buffered:1; + ULONG Cached:1; ULONG Owner:1; - ULONG WriteThrough:1; - ULONG CacheDisable:1; - ULONG Protection:5; + ULONG Protection:4; + ULONG ReadOnly:1; ULONG Prototype:1; ULONG Transition:1; ULONG PageFrameNumber:20; @@ -123,19 +123,18 @@ typedef struct _MMPTE_TRANSITION typedef struct _MMPTE_PROTOTYPE { - ULONG Valid:1; + ULONG Valid:2; ULONG ProtoAddressLow:7; ULONG ReadOnly:1; - ULONG WhichPool:1; ULONG Prototype:1; ULONG ProtoAddressHigh:21; } MMPTE_PROTOTYPE; typedef struct _MMPTE_SUBSECTION { - ULONG Valid:1; + ULONG Valid:2; ULONG SubsectionAddressLow:4; - ULONG Protection:5; + ULONG Protection:4; ULONG Prototype:1; ULONG SubsectionAddressHigh:20; ULONG WhichPool:1; @@ -143,47 +142,38 @@ typedef struct _MMPTE_SUBSECTION typedef struct _MMPTE_LIST { - ULONG Valid:1; + ULONG Valid:2; ULONG OneEntry:1; ULONG filler0:8; ULONG NextEntry:20; ULONG Prototype:1; - ULONG filler1:1; } MMPTE_LIST; typedef union _MMPTE_HARDWARE { - struct - { - ULONG NoExecute:1; - ULONG Valid:1; - ULONG Buffered:1; - ULONG Cached:1; - ULONG Access:1; - ULONG Owner:1; - ULONG CacheAttributes:3; - ULONG ReadOnly:1; - ULONG Shared:1; - ULONG NonGlobal:1; - ULONG PageFrameNumber:20; - }; - ULONG AsUlong; + ULONG NoExecute:1; + ULONG Valid:1; + ULONG Buffered:1; + ULONG Cached:1; + ULONG Sbo:1; + ULONG Owner:1; + ULONG CacheAttributes:3; + ULONG ReadOnly:1; + ULONG Prototype:1; + ULONG NonGlobal:1; + ULONG PageFrameNumber:20; } MMPTE_HARDWARE, *PMMPTE_HARDWARE; typedef union _MMPDE_HARDWARE { - struct - { - ULONG Valid:1; - ULONG LargePage:1; - ULONG Buffered:1; - ULONG Cached:1; - ULONG NoExecute:1; - ULONG Domain:4; - ULONG Ecc:1; - ULONG PageFrameNumber:22; - }; - ULONG AsUlong; + ULONG Valid:1; + ULONG LargePage:1; + ULONG Buffered:1; + ULONG Cached:1; + ULONG NoExecute:1; + ULONG Domain:4; + ULONG Ecc:1; + ULONG PageFrameNumber:22; } MMPDE_HARDWARE, *PMMPDE_HARDWARE; typedef struct _MMPDE diff --git a/reactos/include/reactos/arm/armddk.h b/reactos/include/reactos/arm/armddk.h index e068e5c9643..97d7298b717 100644 --- a/reactos/include/reactos/arm/armddk.h +++ b/reactos/include/reactos/arm/armddk.h @@ -252,6 +252,35 @@ KeRaiseIrqlToDpcLevel( #define KeLowerIrql(NewIrql) KfLowerIrql(NewIrql) #define KeRaiseIrql(NewIrql, OldIrql) *(OldIrql) = KfRaiseIrql(NewIrql) +NTHALAPI +KIRQL +FASTCALL +KfAcquireSpinLock( + IN OUT PKSPIN_LOCK SpinLock); +#define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a) + +NTHALAPI +VOID +FASTCALL +KfReleaseSpinLock( + IN OUT PKSPIN_LOCK SpinLock, + IN KIRQL NewIrql); +#define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b) + +NTKERNELAPI +VOID +FASTCALL +KefAcquireSpinLockAtDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); +#define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock) + +NTKERNELAPI +VOID +FASTCALL +KefReleaseSpinLockFromDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); +#define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock) + // // Cache clean and flush // diff --git a/reactos/ntoskrnl/include/internal/po.h b/reactos/ntoskrnl/include/internal/po.h index ef4ee1a5ff1..86e25595164 100644 --- a/reactos/ntoskrnl/include/internal/po.h +++ b/reactos/ntoskrnl/include/internal/po.h @@ -6,7 +6,7 @@ * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) */ -#include "initguid.h" +#include #include // diff --git a/reactos/ntoskrnl/mm/ARM3/arm/init.c b/reactos/ntoskrnl/mm/ARM3/arm/init.c index b7bfd841220..1e44b767d35 100644 --- a/reactos/ntoskrnl/mm/ARM3/arm/init.c +++ b/reactos/ntoskrnl/mm/ARM3/arm/init.c @@ -24,10 +24,7 @@ ULONG MmMaximumNonPagedPoolInBytes; PVOID MmNonPagedSystemStart; PVOID MmNonPagedPoolStart; PVOID MmNonPagedPoolExpansionStart; -PVOID MmNonPagedPoolEnd = MI_NONPAGED_POOL_END; -PVOID MmPagedPoolStart = MI_PAGED_POOL_START; PVOID MmPagedPoolEnd; -ULONG MmSizeOfPagedPoolInBytes = MI_MIN_INIT_PAGED_POOLSIZE; PVOID MiSessionSpaceEnd; PVOID MiSessionImageEnd; PVOID MiSessionImageStart; @@ -49,7 +46,7 @@ RTL_BITMAP MiPfnBitMap; PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock; PMEMORY_ALLOCATION_DESCRIPTOR MxFreeDescriptor; MEMORY_ALLOCATION_DESCRIPTOR MxOldFreeDescriptor; -ULONG MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage = -1; +ULONG MmNumberOfPhysicalPages, MmHighestPhysicalPage; ULONG MmBootImageSize; ULONG MmUserProbeAddress; PVOID MmHighestUserAddress; @@ -61,17 +58,17 @@ PVOID MmHyperSpaceEnd; /* PRIVATE FUNCTIONS **********************************************************/ -BOOLEAN +NTSTATUS NTAPI -MmArmInitSystem(IN ULONG Phase, - IN PLOADER_PARAMETER_BLOCK LoaderBlock) +INIT_FUNCTION +MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { // // Always return success for now // DPRINT1("NEVER TELL ME THE ODDS!\n"); while (TRUE); - return TRUE; + return STATUS_SUCCESS; } /* EOF */ diff --git a/reactos/ntoskrnl/mm/ARM3/miarm.h b/reactos/ntoskrnl/mm/ARM3/miarm.h index 07e2224dc3d..cfa99d77330 100644 --- a/reactos/ntoskrnl/mm/ARM3/miarm.h +++ b/reactos/ntoskrnl/mm/ARM3/miarm.h @@ -130,12 +130,12 @@ C_ASSERT(SYSTEM_PD_SIZE == PAGE_SIZE); // // Access Flags // -#define PTE_READONLY 0 +#define PTE_READONLY 0 // Doesn't exist on x86 #define PTE_EXECUTE 0 // Not worrying about NX yet #define PTE_EXECUTE_READ 0 // Not worrying about NX yet #define PTE_READWRITE 0x2 #define PTE_WRITECOPY 0x200 -#define PTE_EXECUTE_READWRITE 0x0 +#define PTE_EXECUTE_READWRITE 0x2 // Not worrying about NX yet #define PTE_EXECUTE_WRITECOPY 0x200 #define PTE_PROTOTYPE 0x400 // @@ -145,6 +145,20 @@ C_ASSERT(SYSTEM_PD_SIZE == PAGE_SIZE); #define PTE_DISABLE_CACHE 0x10 #define PTE_WRITECOMBINED_CACHE 0x10 #elif defined(_M_ARM) +#define PTE_READONLY 0x200 +#define PTE_EXECUTE 0 // Not worrying about NX yet +#define PTE_EXECUTE_READ 0 // Not worrying about NX yet +#define PTE_READWRITE 0 // Doesn't exist on ARM +#define PTE_WRITECOPY 0 // Doesn't exist on ARM +#define PTE_EXECUTE_READWRITE 0 // Not worrying about NX yet +#define PTE_EXECUTE_WRITECOPY 0 // Not worrying about NX yet +#define PTE_PROTOTYPE 0x400 // Using the Shared bit +// +// Cache flags +// +#define PTE_ENABLE_CACHE 0 +#define PTE_DISABLE_CACHE 0x10 +#define PTE_WRITECOMBINED_CACHE 0x10 #else #error Define these please! #endif @@ -179,7 +193,7 @@ extern const ULONG MmProtectToValue[32]; #ifdef _M_IX86 #define MM_PTE_SOFTWARE_PROTECTION_BITS 5 #elif _M_ARM -#define MM_PTE_SOFTWARE_PROTECTION_BITS 5 +#define MM_PTE_SOFTWARE_PROTECTION_BITS 6 #elif _M_AMD64 #define MM_PTE_SOFTWARE_PROTECTION_BITS 5 #else diff --git a/reactos/ntoskrnl/mm/arm/page.c b/reactos/ntoskrnl/mm/arm/page.c index c24115a049d..549b65a9613 100644 --- a/reactos/ntoskrnl/mm/arm/page.c +++ b/reactos/ntoskrnl/mm/arm/page.c @@ -12,10 +12,111 @@ #define NDEBUG #include +#line 15 "ARMĀ³::ARMPAGE" +#define MODULE_INVOLVED_IN_ARM3 +#include "../ARM3/miarm.h" + /* GLOBALS ********************************************************************/ +const +ULONG +MmProtectToPteMask[32] = +{ + // + // These are the base MM_ protection flags + // + 0, + PTE_READONLY | PTE_ENABLE_CACHE, + PTE_EXECUTE | PTE_ENABLE_CACHE, + PTE_EXECUTE_READ | PTE_ENABLE_CACHE, + PTE_READWRITE | PTE_ENABLE_CACHE, + PTE_WRITECOPY | PTE_ENABLE_CACHE, + PTE_EXECUTE_READWRITE | PTE_ENABLE_CACHE, + PTE_EXECUTE_WRITECOPY | PTE_ENABLE_CACHE, + // + // These OR in the MM_NOCACHE flag + // + 0, + PTE_READONLY | PTE_DISABLE_CACHE, + PTE_EXECUTE | PTE_DISABLE_CACHE, + PTE_EXECUTE_READ | PTE_DISABLE_CACHE, + PTE_READWRITE | PTE_DISABLE_CACHE, + PTE_WRITECOPY | PTE_DISABLE_CACHE, + PTE_EXECUTE_READWRITE | PTE_DISABLE_CACHE, + PTE_EXECUTE_WRITECOPY | PTE_DISABLE_CACHE, + // + // These OR in the MM_DECOMMIT flag, which doesn't seem supported on x86/64/ARM + // + 0, + PTE_READONLY | PTE_ENABLE_CACHE, + PTE_EXECUTE | PTE_ENABLE_CACHE, + PTE_EXECUTE_READ | PTE_ENABLE_CACHE, + PTE_READWRITE | PTE_ENABLE_CACHE, + PTE_WRITECOPY | PTE_ENABLE_CACHE, + PTE_EXECUTE_READWRITE | PTE_ENABLE_CACHE, + PTE_EXECUTE_WRITECOPY | PTE_ENABLE_CACHE, + // + // These OR in the MM_NOACCESS flag, which seems to enable WriteCombining? + // + 0, + PTE_READONLY | PTE_WRITECOMBINED_CACHE, + PTE_EXECUTE | PTE_WRITECOMBINED_CACHE, + PTE_EXECUTE_READ | PTE_WRITECOMBINED_CACHE, + PTE_READWRITE | PTE_WRITECOMBINED_CACHE, + PTE_WRITECOPY | PTE_WRITECOMBINED_CACHE, + PTE_EXECUTE_READWRITE | PTE_WRITECOMBINED_CACHE, + PTE_EXECUTE_WRITECOPY | PTE_WRITECOMBINED_CACHE, +}; + +const +ULONG MmProtectToValue[32] = +{ + PAGE_NOACCESS, + PAGE_READONLY, + PAGE_EXECUTE, + PAGE_EXECUTE_READ, + PAGE_READWRITE, + PAGE_WRITECOPY, + PAGE_EXECUTE_READWRITE, + PAGE_EXECUTE_WRITECOPY, + PAGE_NOACCESS, + PAGE_NOCACHE | PAGE_READONLY, + PAGE_NOCACHE | PAGE_EXECUTE, + PAGE_NOCACHE | PAGE_EXECUTE_READ, + PAGE_NOCACHE | PAGE_READWRITE, + PAGE_NOCACHE | PAGE_WRITECOPY, + PAGE_NOCACHE | PAGE_EXECUTE_READWRITE, + PAGE_NOCACHE | PAGE_EXECUTE_WRITECOPY, + PAGE_NOACCESS, + PAGE_GUARD | PAGE_READONLY, + PAGE_GUARD | PAGE_EXECUTE, + PAGE_GUARD | PAGE_EXECUTE_READ, + PAGE_GUARD | PAGE_READWRITE, + PAGE_GUARD | PAGE_WRITECOPY, + PAGE_GUARD | PAGE_EXECUTE_READWRITE, + PAGE_GUARD | PAGE_EXECUTE_WRITECOPY, + PAGE_NOACCESS, + PAGE_WRITECOMBINE | PAGE_READONLY, + PAGE_WRITECOMBINE | PAGE_EXECUTE, + PAGE_WRITECOMBINE | PAGE_EXECUTE_READ, + PAGE_WRITECOMBINE | PAGE_READWRITE, + PAGE_WRITECOMBINE | PAGE_WRITECOPY, + PAGE_WRITECOMBINE | PAGE_EXECUTE_READWRITE, + PAGE_WRITECOMBINE | PAGE_EXECUTE_WRITECOPY +}; + ULONG MmGlobalKernelPageDirectory[4096]; -MMPDE HyperTemplatePde; + +/* Template PTE and PDE for a kernel page */ +MMPDE ValidKernelPde = {.u.Hard.Valid = 1}; +MMPTE ValidKernelPte = {.u.Hard.Valid = 1, .u.Hard.Sbo = 1}; + +/* Template PDE for a demand-zero page */ +MMPDE DemandZeroPde = {.u.Long = (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS)}; +MMPTE DemandZeroPte = {.u.Long = (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS)}; + +/* Template PTE for prototype page */ +MMPTE PrototypePte = {.u.Long = (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS) | PTE_PROTOTYPE | (MI_PTE_LOOKUP_NEEDED << PAGE_SHIFT)}; /* PRIVATE FUNCTIONS **********************************************************/ @@ -49,25 +150,6 @@ MmUpdatePageDir(IN PEPROCESS Process, return; } -NTSTATUS -NTAPI -Mmi386ReleaseMmInfo(IN PEPROCESS Process) -{ - UNIMPLEMENTED; - while (TRUE); - return 0; -} - -NTSTATUS -NTAPI -MmInitializeHandBuiltProcess(IN PEPROCESS Process, - IN PULONG DirectoryTableBase) -{ - UNIMPLEMENTED; - while (TRUE); - return STATUS_SUCCESS; -} - PULONG NTAPI MmGetPageDirectory(VOID) @@ -246,16 +328,7 @@ MmInitGlobalKernelPageDirectory(VOID) { ULONG i; PULONG CurrentPageDirectory = (PULONG)PDE_BASE; - extern MMPTE HyperTemplatePte; - - /* Setup PTE template */ - HyperTemplatePte.u.Long = 0; - HyperTemplatePte.u.Hard.Valid = 1; - HyperTemplatePte.u.Hard.Access = 1; - /* Setup PDE template */ - HyperTemplatePde.u.Long = 0; - HyperTemplatePde.u.Hard.Valid = 1; /* Loop the 2GB of address space which belong to the kernel */ for (i = MiGetPdeOffset(MmSystemRangeStart); i < 2048; i++) diff --git a/reactos/ntoskrnl/mm/arm/stubs.c b/reactos/ntoskrnl/mm/arm/stubs.c index 55178c747aa..781ea284e05 100644 --- a/reactos/ntoskrnl/mm/arm/stubs.c +++ b/reactos/ntoskrnl/mm/arm/stubs.c @@ -367,18 +367,6 @@ MmCreateProcessAddressSpace(IN ULONG MinWs, return TRUE; } -VOID -NTAPI -MmUpdatePageDir(IN PEPROCESS Process, - IN PVOID Address, - IN ULONG Size) -{ - // - // Nothing to do - // - return; -} - NTSTATUS NTAPI Mmi386ReleaseMmInfo(IN PEPROCESS Process) @@ -391,30 +379,6 @@ Mmi386ReleaseMmInfo(IN PEPROCESS Process) return 0; } -NTSTATUS -NTAPI -MmInitializeHandBuiltProcess(IN PEPROCESS Process, - IN PULONG DirectoryTableBase) -{ - // - // Share the directory base with the idle process - // - DirectoryTableBase[0] = PsGetCurrentProcess()->Pcb.DirectoryTableBase[0]; - DirectoryTableBase[1] = PsGetCurrentProcess()->Pcb.DirectoryTableBase[1]; - - // - // Initialize the Addresss Space - // - KeInitializeGuardedMutex(&Process->AddressCreationLock); - Process->VadRoot.BalancedRoot.u1.Parent = NULL; - - // - // The process now has an address space - // - Process->HasAddressSpace = TRUE; - return STATUS_SUCCESS; -} - PULONG NTAPI MmGetPageDirectory(VOID) diff --git a/reactos/ntoskrnl/po/power.c b/reactos/ntoskrnl/po/power.c index 359a035f294..42a0bb854db 100644 --- a/reactos/ntoskrnl/po/power.c +++ b/reactos/ntoskrnl/po/power.c @@ -9,6 +9,7 @@ /* INCLUDES ******************************************************************/ +#include "initguid.h" #include #define NDEBUG #include From ae6d759f4c266d300b6ce700c6af1dafadd46b11 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 24 Nov 2010 17:49:52 +0000 Subject: [PATCH 68/75] [NTOS]: Some more ARM build and linker fixes, moving some of the new x86 C code into ARM. This should really be shared later. [NTOS]: Totally broke thread context switching on ARM for now. It's a Good Thing. svn path=/trunk/; revision=49781 --- reactos/ntoskrnl/ke/arm/cpu.c | 9 ++ reactos/ntoskrnl/ke/arm/ctxswtch.s | 20 +++ reactos/ntoskrnl/ke/arm/thrdini.c | 230 +++++++++++++++++++++++++++++ reactos/ntoskrnl/ntoskrnl.pspec | 2 +- 4 files changed, 260 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/ke/arm/cpu.c b/reactos/ntoskrnl/ke/arm/cpu.c index 275df6c3854..37d8a1569fd 100644 --- a/reactos/ntoskrnl/ke/arm/cpu.c +++ b/reactos/ntoskrnl/ke/arm/cpu.c @@ -57,6 +57,15 @@ KeFlushCurrentTb(VOID) KeFlushTb(); } +VOID +FASTCALL +KeZeroPages(IN PVOID Address, + IN ULONG Size) +{ + /* Not using XMMI in this routine */ + RtlZeroMemory(Address, Size); +} + VOID NTAPI KiSaveProcessorControlState(OUT PKPROCESSOR_STATE ProcessorState) diff --git a/reactos/ntoskrnl/ke/arm/ctxswtch.s b/reactos/ntoskrnl/ke/arm/ctxswtch.s index a8f391f8ec3..0d6bb54f27c 100644 --- a/reactos/ntoskrnl/ke/arm/ctxswtch.s +++ b/reactos/ntoskrnl/ke/arm/ctxswtch.s @@ -13,6 +13,10 @@ TEXTAREA NESTED_ENTRY KiSwapContext PROLOG_END KiSwapContext + + // BUSTEDDDD + b . + // // a1 = Old Thread // a2 = New Thread @@ -104,3 +108,19 @@ b . ENTRY_END KiThreadStartup + + NESTED_ENTRY KiSwitchThreads + PROLOG_END KiSwitchThreads + + // BUSTEDDDD + b . + + ENTRY_END KiSwitchThreads + + NESTED_ENTRY KiSwapContextInternal + PROLOG_END KiSwapContextInternal + + // BUSTEDDDD + b . + + ENTRY_END KiSwapContextInternal diff --git a/reactos/ntoskrnl/ke/arm/thrdini.c b/reactos/ntoskrnl/ke/arm/thrdini.c index 16700f54470..cae9b75deb1 100644 --- a/reactos/ntoskrnl/ke/arm/thrdini.c +++ b/reactos/ntoskrnl/ke/arm/thrdini.c @@ -14,6 +14,13 @@ /* GLOBALS ********************************************************************/ +typedef struct _KSWITCHFRAME +{ + PVOID ExceptionList; + BOOLEAN ApcBypassDisable; + PVOID RetAddr; +} KSWITCHFRAME, *PKSWITCHFRAME; + typedef struct _KUINIT_FRAME { KEXCEPTION_FRAME CtxSwitchFrame; @@ -32,6 +39,15 @@ VOID NTAPI KiThreadStartup(VOID); +VOID +FASTCALL +KiSwitchThreads( + IN PKTHREAD OldThread, + IN PKTHREAD NewThread +); + + +/* FIXME: THIS IS TOTALLY BUSTED NOW */ VOID NTAPI KiInitializeContextThread(IN PKTHREAD Thread, @@ -131,3 +147,217 @@ KiInitializeContextThread(IN PKTHREAD Thread, // Thread->KernelStack = (PVOID)CtxSwitchFrame; } + +VOID +FASTCALL +KiIdleLoop(VOID) +{ + PKPRCB Prcb = KeGetCurrentPrcb(); + PKTHREAD OldThread, NewThread; + + /* Initialize the idle loop: disable interrupts */ + _enable(); + YieldProcessor(); + YieldProcessor(); + _disable(); + + /* Now loop forever */ + while (TRUE) + { + /* Check for pending timers, pending DPCs, or pending ready threads */ + if ((Prcb->DpcData[0].DpcQueueDepth) || + (Prcb->TimerRequest) || + (Prcb->DeferredReadyListHead.Next)) + { + /* Quiesce the DPC software interrupt */ + HalClearSoftwareInterrupt(DISPATCH_LEVEL); + + /* Handle it */ + KiRetireDpcList(Prcb); + } + + /* Check if a new thread is scheduled for execution */ + if (Prcb->NextThread) + { + /* Enable interupts */ + _enable(); + + /* Capture current thread data */ + OldThread = Prcb->CurrentThread; + NewThread = Prcb->NextThread; + + /* Set new thread data */ + Prcb->NextThread = NULL; + Prcb->CurrentThread = NewThread; + + /* The thread is now running */ + NewThread->State = Running; + + /* Switch away from the idle thread */ + KiSwapContext(APC_LEVEL, OldThread); + + /* We are back in the idle thread -- disable interrupts again */ + _enable(); + YieldProcessor(); + YieldProcessor(); + _disable(); + } + else + { + /* Continue staying idle. Note the HAL returns with interrupts on */ + Prcb->PowerState.IdleFunction(&Prcb->PowerState); + } + } +} + +BOOLEAN +FASTCALL +KiSwapContextExit(IN PKTHREAD OldThread, + IN PKSWITCHFRAME SwitchFrame) +{ + PKIPCR Pcr = (PKIPCR)KeGetPcr(); + PKPROCESS OldProcess, NewProcess; + PKTHREAD NewThread; + ARM_TTB_REGISTER TtbRegister; + + /* We are on the new thread stack now */ + NewThread = Pcr->PrcbData.CurrentThread; + + /* Now we are the new thread. Check if it's in a new process */ + OldProcess = OldThread->ApcState.Process; + NewProcess = NewThread->ApcState.Process; + if (OldProcess != NewProcess) + { + TtbRegister.AsUlong = NewProcess->DirectoryTableBase[0]; + ASSERT(TtbRegister.Reserved == 0); + KeArmTranslationTableRegisterSet(TtbRegister); + } + + /* Increase thread context switches */ + NewThread->ContextSwitches++; + + /* Load data from switch frame */ + Pcr->NtTib.ExceptionList = SwitchFrame->ExceptionList; + + /* DPCs shouldn't be active */ + if (Pcr->PrcbData.DpcRoutineActive) + { + /* Crash the machine */ + KeBugCheckEx(ATTEMPTED_SWITCH_FROM_DPC, + (ULONG_PTR)OldThread, + (ULONG_PTR)NewThread, + (ULONG_PTR)OldThread->InitialStack, + 0); + } + + /* Kernel APCs may be pending */ + if (NewThread->ApcState.KernelApcPending) + { + /* Are APCs enabled? */ + if (!NewThread->SpecialApcDisable) + { + /* Request APC delivery */ + if (SwitchFrame->ApcBypassDisable) HalRequestSoftwareInterrupt(APC_LEVEL); + return TRUE; + } + } + + /* Return */ + return FALSE; +} + +VOID +FASTCALL +KiSwapContextEntry(IN PKSWITCHFRAME SwitchFrame, + IN ULONG_PTR OldThreadAndApcFlag) +{ + PKIPCR Pcr = (PKIPCR)KeGetPcr(); + PKTHREAD OldThread, NewThread; + + /* Save APC bypass disable */ + SwitchFrame->ApcBypassDisable = OldThreadAndApcFlag & 3; + SwitchFrame->ExceptionList = Pcr->NtTib.ExceptionList; + + /* Increase context switch count and check if tracing is enabled */ + Pcr->ContextSwitches++; + if (Pcr->PerfGlobalGroupMask) + { + /* We don't support this yet on x86 either */ + DPRINT1("WMI Tracing not supported\n"); + ASSERT(FALSE); + } + + /* Get thread pointers */ + OldThread = (PKTHREAD)(OldThreadAndApcFlag & ~3); + NewThread = Pcr->PrcbData.CurrentThread; + + /* Get the old thread and set its kernel stack */ + OldThread->KernelStack = SwitchFrame; + + /* Do the switch */ + KiSwitchThreads(OldThread, NewThread->KernelStack); +} + +VOID +NTAPI +KiDispatchInterrupt(VOID) +{ + PKIPCR Pcr = (PKIPCR)KeGetPcr(); + PKPRCB Prcb = &Pcr->PrcbData; + PVOID OldHandler; + PKTHREAD NewThread, OldThread; + + /* Disable interrupts */ + _disable(); + + /* Check for pending timers, pending DPCs, or pending ready threads */ + if ((Prcb->DpcData[0].DpcQueueDepth) || + (Prcb->TimerRequest) || + (Prcb->DeferredReadyListHead.Next)) + { + /* Switch to safe execution context */ + OldHandler = Pcr->NtTib.ExceptionList; + Pcr->NtTib.ExceptionList = EXCEPTION_CHAIN_END; + + /* Retire DPCs while under the DPC stack */ + //KiRetireDpcListInDpcStack(Prcb, Prcb->DpcStack); + // FIXME!!! // + KiRetireDpcList(Prcb); + + /* Restore context */ + Pcr->NtTib.ExceptionList = OldHandler; + } + + /* Re-enable interrupts */ + _enable(); + + /* Check for quantum end */ + if (Prcb->QuantumEnd) + { + /* Handle quantum end */ + Prcb->QuantumEnd = FALSE; + KiQuantumEnd(); + } + else if (Prcb->NextThread) + { + /* Capture current thread data */ + OldThread = Prcb->CurrentThread; + NewThread = Prcb->NextThread; + + /* Set new thread data */ + Prcb->NextThread = NULL; + Prcb->CurrentThread = NewThread; + + /* The thread is now running */ + NewThread->State = Running; + OldThread->WaitReason = WrDispatchInt; + + /* Make the old thread ready */ + KxQueueReadyThread(OldThread, Prcb); + + /* Swap to the new thread */ + KiSwapContext(APC_LEVEL, OldThread); + } +} + +/* EOF */ diff --git a/reactos/ntoskrnl/ntoskrnl.pspec b/reactos/ntoskrnl/ntoskrnl.pspec index 12a4139acfb..1c65cc24145 100644 --- a/reactos/ntoskrnl/ntoskrnl.pspec +++ b/reactos/ntoskrnl/ntoskrnl.pspec @@ -112,7 +112,7 @@ @ FASTCALL ExInterlockedAddLargeStatistic(ptr long) #endif @ stdcall ExInterlockedAddUlong(ptr long ptr) -#ifndef __x86_64__ +#ifdef __x86__ @ FASTCALL ExInterlockedCompareExchange64(ptr ptr ptr ptr) @ stdcall ExInterlockedDecrementLong(ptr ptr) @ stdcall ExInterlockedExchangeUlong(ptr long ptr) From 889287242f08c856a3df46302b6a9d77dd8d985b Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 24 Nov 2010 18:19:42 +0000 Subject: [PATCH 69/75] [NTOS]: Fix 16-bit interlocked operations on ARM (GCC doesn't provide built-ins). ARM should build now. svn path=/trunk/; revision=49782 --- reactos/include/crt/mingw32/intrin_arm.h | 34 +++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/reactos/include/crt/mingw32/intrin_arm.h b/reactos/include/crt/mingw32/intrin_arm.h index 12ced3ebb4b..f5a07b381fb 100644 --- a/reactos/include/crt/mingw32/intrin_arm.h +++ b/reactos/include/crt/mingw32/intrin_arm.h @@ -67,12 +67,40 @@ __INTRIN_INLINE char _InterlockedCompareExchange8(volatile char * const Destinat __INTRIN_INLINE short _InterlockedCompareExchange16(volatile short * const Destination, const short Exchange, const short Comperand) { - return __sync_val_compare_and_swap(Destination, Comperand, Exchange); + short a, b; + + __asm__ __volatile__ ( "0:\n\t" + "ldr %1, [%2]\n\t" + "cmp %1, %4\n\t" + "bne 1f\n\t" + "swp %0, %3, [%2]\n\t" + "cmp %0, %1\n\t" + "swpne %3, %0, [%2]\n\t" + "bne 0b\n\t" + "1:" + : "=&r" (a), "=&r" (b) + : "r" (Destination), "r" (Exchange), "r" (Comperand) + : "cc", "memory"); + + return a; } -__INTRIN_INLINE long _InterlockedExchangeAdd16(volatile short * const Addend, const short Value) +__INTRIN_INLINE short _InterlockedExchangeAdd16(volatile short * const Addend, const short Value) { - return __sync_fetch_and_add(Addend, Value); + short a, b, c; + + __asm__ __volatile__ ( "0:\n\t" + "ldr %0, [%3]\n\t" + "add %1, %0, %4\n\t" + "swp %2, %1, [%3]\n\t" + "cmp %0, %2\n\t" + "swpne %1, %2, [%3]\n\t" + "bne 0b" + : "=&r" (a), "=&r" (b), "=&r" (c) + : "r" (Value), "r" (Addend) + : "cc", "memory"); + + return a; } __INTRIN_INLINE long _InterlockedCompareExchange(volatile long * const dest, const long exch, const long comp) From ec2d741f31864e9f90969828ad7a107f2ca0f3ad Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 24 Nov 2010 18:30:12 +0000 Subject: [PATCH 70/75] [SERVICES] Fix a typo (|| instead of |). Found by clang. svn path=/trunk/; revision=49783 --- reactos/base/system/services/rpcserver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/base/system/services/rpcserver.c b/reactos/base/system/services/rpcserver.c index 30df18d071f..cc45ff5f1e4 100644 --- a/reactos/base/system/services/rpcserver.c +++ b/reactos/base/system/services/rpcserver.c @@ -834,8 +834,8 @@ DWORD RQueryServiceObjectSecurity( return ERROR_INVALID_HANDLE; } - if (dwSecurityInformation & (DACL_SECURITY_INFORMATION || - GROUP_SECURITY_INFORMATION || + if (dwSecurityInformation & (DACL_SECURITY_INFORMATION | + GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION)) DesiredAccess |= READ_CONTROL; From a5dbee0b8f18425ff739bafc0efa89ee35e37ad8 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 24 Nov 2010 18:53:47 +0000 Subject: [PATCH 71/75] [NTOS]: STATUS_SUCCESS is not the only succesful return code. svn path=/trunk/; revision=49785 --- reactos/ntoskrnl/ke/arm/trapc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/ke/arm/trapc.c b/reactos/ntoskrnl/ke/arm/trapc.c index d2ff8c426e4..9f731bb578b 100644 --- a/reactos/ntoskrnl/ke/arm/trapc.c +++ b/reactos/ntoskrnl/ke/arm/trapc.c @@ -529,7 +529,7 @@ KiDataAbortHandler(IN PKTRAP_FRAME TrapFrame) Address, KiGetPreviousMode(TrapFrame), TrapFrame); - if (Status == STATUS_SUCCESS) return Status; + if (NT_SUCCESS(Status)) return Status; } // From 5f47e1ddd0ee29547985abb268e8d0ee2ca0df18 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 24 Nov 2010 18:56:35 +0000 Subject: [PATCH 72/75] [NTOS]: Seems like cpsr_c doesn't work in this case? Need to investigate. Put an infinite loop in the entrypoint on ARM. svn path=/trunk/; revision=49786 --- reactos/ntoskrnl/ke/arm/boot.s | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/ke/arm/boot.s b/reactos/ntoskrnl/ke/arm/boot.s index eff065cacbc..5bce7356a16 100644 --- a/reactos/ntoskrnl/ke/arm/boot.s +++ b/reactos/ntoskrnl/ke/arm/boot.s @@ -15,7 +15,10 @@ PROLOG_END KiSystemStartup /* Put us in FIQ mode, set IRQ stack */ - msr cpsr_c, #CPSR_FIQ_MODE + b . + mrs r3, cpsr + orr r3, r1, #CPSR_FIQ_MODE + msr cpsr, r3 ldr sp, [a1, #LpbInterruptStack] /* Repeat for IRQ mode */ From cea642beb383f1c2c4de3da4474b47513d55813e Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Wed, 24 Nov 2010 20:55:15 +0000 Subject: [PATCH 73/75] [FREELDR] poor little printf causes boot break, nuff said. svn path=/trunk/; revision=49789 --- reactos/boot/freeldr/freeldr/windows/winldr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/boot/freeldr/freeldr/windows/winldr.c b/reactos/boot/freeldr/freeldr/windows/winldr.c index 073a00a6b5f..95ac954005f 100644 --- a/reactos/boot/freeldr/freeldr/windows/winldr.c +++ b/reactos/boot/freeldr/freeldr/windows/winldr.c @@ -624,7 +624,7 @@ LoadAndBootWindows(PCSTR OperatingSystemName, /* Save final value of LoaderPagesSpanned */ LoaderBlockVA->Extension->LoaderPagesSpanned = LoaderPagesSpanned; - printf( "Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n", + DPRINTM(DPRINT_WINDOWS, "Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n", KiSystemStartup, LoaderBlockVA); WinLdrpDumpMemoryDescriptors(LoaderBlockVA); From fb04d4fd236caf06cf6d055dff6b57f1264eea61 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Wed, 24 Nov 2010 22:51:03 +0000 Subject: [PATCH 74/75] [NTOSKRNL] Fix the fix, ie fix x86. Everything should work now ~ svn path=/trunk/; revision=49790 --- reactos/ntoskrnl/include/internal/i386/mm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/include/internal/i386/mm.h b/reactos/ntoskrnl/include/internal/i386/mm.h index 2f70fd5e2f3..83b48efef56 100644 --- a/reactos/ntoskrnl/include/internal/i386/mm.h +++ b/reactos/ntoskrnl/include/internal/i386/mm.h @@ -39,7 +39,7 @@ PULONG MmGetPageDirectory(VOID); // Convert a PTE into a corresponding address // #define MiPteToAddress(PTE) ((PVOID)((ULONG)(PTE) << 10)) -#define MiPdeToAddress(PDE) ((PVOID)((ULONG)(PDE) << 18)) +#define MiPdeToAddress(PDE) ((PVOID)((ULONG)(PDE) << 10)) #define ADDR_TO_PAGE_TABLE(v) (((ULONG)(v)) / (1024 * PAGE_SIZE)) #define ADDR_TO_PDE_OFFSET(v) ((((ULONG)(v)) / (1024 * PAGE_SIZE))) From cc202fdc318d0cc3df2a4d359c2972bab3250b9f Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 25 Nov 2010 22:03:56 +0000 Subject: [PATCH 75/75] [FREELDR] - Conditionally enable heap-related debugging and validation checks by an MM_DBG define for all architectures. Inspired by 49744. svn path=/trunk/; revision=49792 --- reactos/boot/freeldr/freeldr/rtl/bget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/boot/freeldr/freeldr/rtl/bget.c b/reactos/boot/freeldr/freeldr/rtl/bget.c index 60f0dcae93e..fb6c2d49d34 100644 --- a/reactos/boot/freeldr/freeldr/rtl/bget.c +++ b/reactos/boot/freeldr/freeldr/rtl/bget.c @@ -407,7 +407,7 @@ all buffers allocated are a multiple of this size. This MUST be a power of two. */ -#ifndef _M_ARM +#ifdef MM_DBG #define BufDump 1 /* Define this symbol to enable the bpoold() function which dumps the