reactos/subsys/win32k/include
diff -u -r1.2 -r1.3
--- cleanup.h 13 Dec 2003 15:49:32 -0000 1.2
+++ cleanup.h 19 May 2004 19:09:20 -0000 1.3
@@ -7,4 +7,8 @@
IntSafeCopyUnicodeString(PUNICODE_STRING Dest,
PUNICODE_STRING Source);
+NTSTATUS FASTCALL
+IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest,
+ PUNICODE_STRING Source);
+
#endif /* ndef _SUBSYS_WIN32K_INCLUDE_CLEANUP_H */
reactos/subsys/win32k/ntuser
diff -u -r1.73 -r1.74
--- misc.c 14 May 2004 23:57:32 -0000 1.73
+++ misc.c 19 May 2004 19:09:20 -0000 1.74
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.73 2004/05/14 23:57:32 weiden Exp $
+/* $Id: misc.c,v 1.74 2004/05/19 19:09:20 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -1132,3 +1132,51 @@
return STATUS_SUCCESS;
}
+NTSTATUS FASTCALL
+IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest,
+ PUNICODE_STRING Source)
+{
+ NTSTATUS Status;
+ PWSTR Src;
+
+ Status = MmCopyFromCaller(Dest, Source, sizeof(UNICODE_STRING));
+ if(!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+
+ if(Dest->Length > 0x4000)
+ {
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ Src = Dest->Buffer;
+ Dest->Buffer = NULL;
+
+ if(Dest->Length > 0 && Src)
+ {
+ Dest->Buffer = ExAllocatePoolWithTag(NonPagedPool, Dest->Length + sizeof(WCHAR), TAG_STRING);
+ if(!Dest->Buffer)
+ {
+ return STATUS_NO_MEMORY;
+ }
+
+ Status = MmCopyFromCaller(Dest->Buffer, Src, Dest->Length);
+ if(!NT_SUCCESS(Status))
+ {
+ ExFreePool(Dest->Buffer);
+ Dest->Buffer = NULL;
+ return Status;
+ }
+
+ /* make sure the string is null-terminated */
+ Src = (PWSTR)((PBYTE)Dest->Buffer + Dest->Length);
+ *Src = L'\0';
+
+ return STATUS_SUCCESS;
+ }
+
+ /* string is empty */
+ return STATUS_SUCCESS;
+}
+
reactos/subsys/win32k/ntuser
diff -u -r1.233 -r1.234
--- window.c 16 May 2004 19:31:09 -0000 1.233
+++ window.c 19 May 2004 19:09:20 -0000 1.234
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: window.c,v 1.233 2004/05/16 19:31:09 navaraf Exp $
+/* $Id: window.c,v 1.234 2004/05/19 19:09:20 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -3572,76 +3572,21 @@
UINT STDCALL
NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe)
{
-#if 0
- PLIST_ENTRY Current;
- PREGISTERED_MESSAGE NewMsg, RegMsg;
- UINT Msg = REGISTERED_MESSAGE_MIN;
- UNICODE_STRING MessageName;
+ UNICODE_STRING SafeMessageName;
NTSTATUS Status;
-
- Status = MmCopyFromCaller(&MessageName, MessageNameUnsafe, sizeof(UNICODE_STRING));
- if (! NT_SUCCESS(Status))
- {
- SetLastNtError(Status);
- return 0;
- }
-
- NewMsg = ExAllocatePoolWithTag(PagedPool,
- sizeof(REGISTERED_MESSAGE) +
- MessageName.Length,
- TAG_WNAM);
- if (NULL == NewMsg)
- {
- SetLastNtError(STATUS_NO_MEMORY);
- return 0;
- }
-
- Status = MmCopyFromCaller(NewMsg->MessageName, MessageName.Buffer, MessageName.Length);
- if (! NT_SUCCESS(Status))
- {
- ExFreePool(NewMsg);
- SetLastNtError(Status);
- return 0;
- }
- NewMsg->MessageName[MessageName.Length / sizeof(WCHAR)] = L'\0';
- if (wcslen(NewMsg->MessageName) != MessageName.Length / sizeof(WCHAR))
- {
- ExFreePool(NewMsg);
- SetLastNtError(STATUS_INVALID_PARAMETER);
- return 0;
- }
-
- Current = RegisteredMessageListHead.Flink;
- while (Current != &RegisteredMessageListHead)
- {
- RegMsg = CONTAINING_RECORD(Current, REGISTERED_MESSAGE, ListEntry);
- if (0 == wcscmp(NewMsg->MessageName, RegMsg->MessageName))
- {
- ExFreePool(NewMsg);
- return Msg;
- }
- Msg++;
- Current = Current->Flink;
- }
-
- if (REGISTERED_MESSAGE_MAX < Msg)
- {
- ExFreePool(NewMsg);
- SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
- return 0;
- }
-
- InsertTailList(&RegisteredMessageListHead, &(NewMsg->ListEntry));
-
- return Msg;
-#else
- /*
- * Notes:
- * - There's no need to call MmSafe*, because it should be done in kernel.
- * - The passed UNICODE_STRING is expected to be NULL-terminated.
- */
- return (UINT)IntAddAtom(MessageNameUnsafe->Buffer);
-#endif
+ UINT Ret;
+
+ Status = IntSafeCopyUnicodeStringTerminateNULL(&SafeMessageName, MessageNameUnsafe);
+ if(!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ return 0;
+ }
+
+ Ret = (UINT)IntAddAtom(SafeMessageName.Buffer);
+
+ RtlFreeUnicodeString(&SafeMessageName);
+ return Ret;
}