mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
Optimize BroadcastSystemMessage with Environment parameter. Minimize processing when UserModeMsg->lParam is NULL and KernelModeMsg->message != WM_WININICHANGE Make sure that we have a UNICODE_NULL within lParamMsg based on comment from @whindsaks
This commit is contained in:
parent
a1bff5b94e
commit
07abea90d9
1 changed files with 10 additions and 16 deletions
|
@ -453,7 +453,7 @@ CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY MsgMemoryEnt
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
PVOID KernelMem;
|
PVOID KernelMem;
|
||||||
UINT Size, i;
|
UINT Size;
|
||||||
|
|
||||||
*KernelModeMsg = *UserModeMsg;
|
*KernelModeMsg = *UserModeMsg;
|
||||||
|
|
||||||
|
@ -483,23 +483,15 @@ CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY MsgMemoryEnt
|
||||||
{
|
{
|
||||||
TRACE("Copy Message %u from usermode buffer\n", KernelModeMsg->message);
|
TRACE("Copy Message %u from usermode buffer\n", KernelModeMsg->message);
|
||||||
/* Don't do extra testing for 1 word messages. For examples see
|
/* Don't do extra testing for 1 word messages. For examples see
|
||||||
* https://wiki.winehq.org/List_Of_Windows_Messages. */
|
* https://wiki.winehq.org/List_Of_Windows_Messages and
|
||||||
if (Size > 1)
|
* we are just handling WM_WININICHANGE here. */
|
||||||
|
if (Size > 1 && UserModeMsg->lParam &&
|
||||||
|
KernelModeMsg->message == WM_WININICHANGE)
|
||||||
{
|
{
|
||||||
WCHAR lParamMsg[_countof(StrUserKernel[0]) + 1] = { 0 };
|
WCHAR lParamMsg[_countof(StrUserKernel[0]) + 1] = { 0 };
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
if (UserModeMsg->lParam)
|
RtlCopyMemory(lParamMsg, (WCHAR*)UserModeMsg->lParam, sizeof(lParamMsg));
|
||||||
RtlCopyMemory(lParamMsg, (WCHAR*)UserModeMsg->lParam, sizeof(lParamMsg));
|
|
||||||
/* Make sure that the last WCHAR is a UNICODE_NULL */
|
|
||||||
for (i = 0; i < ARRAYSIZE(lParamMsg); ++i)
|
|
||||||
{
|
|
||||||
if (lParamMsg[i] == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* If we did not find a UNICODE_NULL, then set last WCHAR to one */
|
|
||||||
if (i == ARRAYSIZE(lParamMsg))
|
|
||||||
lParamMsg[_countof(StrUserKernel[0])] = UNICODE_NULL;
|
|
||||||
}
|
}
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
|
@ -507,8 +499,10 @@ CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY MsgMemoryEnt
|
||||||
}
|
}
|
||||||
_SEH2_END;
|
_SEH2_END;
|
||||||
|
|
||||||
if (UserModeMsg->lParam && !UserModeMsg->wParam &&
|
/* Make sure that we have a UNICODE_NULL within lParamMsg */
|
||||||
PosInArray(lParamMsg) >= 0)
|
lParamMsg[ARRAYSIZE(lParamMsg) - 1] = UNICODE_NULL;
|
||||||
|
|
||||||
|
if (!UserModeMsg->wParam && PosInArray(lParamMsg) >= 0)
|
||||||
{
|
{
|
||||||
TRACE("Copy String '%S' from usermode buffer\n", lParamMsg);
|
TRACE("Copy String '%S' from usermode buffer\n", lParamMsg);
|
||||||
wcscpy(KernelMem, lParamMsg);
|
wcscpy(KernelMem, lParamMsg);
|
||||||
|
|
Loading…
Reference in a new issue