- Implementation of [NtUser]GetClipboardFormatName[A/W].

svn path=/trunk/; revision=7044
This commit is contained in:
Filip Navara 2003-12-14 17:59:17 +00:00
parent ca0cd5480e
commit 41b0a75f9a
6 changed files with 133 additions and 25 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: clipboard.c,v 1.8 2003/12/14 13:55:01 weiden Exp $ /* $Id: clipboard.c,v 1.9 2003/12/14 17:59:15 navaraf Exp $
* *
* PROJECT: ReactOS user32.dll * PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/input.c * FILE: lib/user32/windows/input.c
@ -110,8 +110,10 @@ GetClipboardFormatNameA(UINT format, LPSTR lpszFormatName, int cchMaxCount)
FormatName.MaximumLength = cchMaxCount * sizeof(WCHAR); FormatName.MaximumLength = cchMaxCount * sizeof(WCHAR);
FormatName.Buffer = lpBuffer; FormatName.Buffer = lpBuffer;
Length = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount); Length = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount);
DbgPrint("GetClipboardFormatNameA(%x): %S\n", format, lpBuffer);
HEAP_strcpyWtoA(lpszFormatName, lpBuffer, Length); HEAP_strcpyWtoA(lpszFormatName, lpBuffer, Length);
HEAP_free(lpBuffer); HEAP_free(lpBuffer);
DbgPrint("GetClipboardFormatNameA(%x): returning %s\n", format, lpszFormatName);
return Length; return Length;
} }
@ -123,11 +125,14 @@ INT STDCALL
GetClipboardFormatNameW(UINT format, LPWSTR lpszFormatName, INT cchMaxCount) GetClipboardFormatNameW(UINT format, LPWSTR lpszFormatName, INT cchMaxCount)
{ {
UNICODE_STRING FormatName; UNICODE_STRING FormatName;
ULONG Ret;
FormatName.Length = 0; FormatName.Length = 0;
FormatName.MaximumLength = cchMaxCount * sizeof(WCHAR); FormatName.MaximumLength = cchMaxCount * sizeof(WCHAR);
FormatName.Buffer = (PWSTR)lpszFormatName; FormatName.Buffer = (PWSTR)lpszFormatName;
return NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount); Ret = NtUserGetClipboardFormatName(format, &FormatName, cchMaxCount);
DbgPrint("GetClipboardFormatNameW(%x): returning %S\n", format, lpszFormatName);
return Ret;
} }
/* /*
@ -190,7 +195,9 @@ IsClipboardFormatAvailable(UINT format)
UINT STDCALL UINT STDCALL
RegisterClipboardFormatA(LPCSTR lpszFormat) RegisterClipboardFormatA(LPCSTR lpszFormat)
{ {
return RegisterWindowMessageA(lpszFormat); ULONG Ret = RegisterWindowMessageA(lpszFormat);
DbgPrint("RegisterClipboardFormatA(%s) - %x\n", lpszFormat, Ret);
return Ret;
} }
/* /*
@ -199,7 +206,9 @@ RegisterClipboardFormatA(LPCSTR lpszFormat)
UINT STDCALL UINT STDCALL
RegisterClipboardFormatW(LPCWSTR lpszFormat) RegisterClipboardFormatW(LPCWSTR lpszFormat)
{ {
return RegisterClipboardFormatW(lpszFormat); ULONG Ret = RegisterClipboardFormatW(lpszFormat);
DbgPrint("RegisterClipboardFormatW(%S) - %x\n", lpszFormat, Ret);
return Ret;
} }
/* /*

View file

@ -0,0 +1,11 @@
#ifndef _WIN32K_USERATOM_H
#define _WIN32K_USERATOM_H
#include <windows.h>
RTL_ATOM FASTCALL
IntAddAtom(LPWSTR AtomName);
ULONG FASTCALL
IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG nSize);
#endif /* _WIN32K_USERATOM_H */

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.89 2003/12/14 12:39:32 navaraf Exp $ # $Id: makefile,v 1.90 2003/12/14 17:59:16 navaraf Exp $
PATH_TO_TOP = ../.. PATH_TO_TOP = ../..
@ -54,8 +54,9 @@ NTUSER_OBJECTS = ntuser/accelerator.o ntuser/callback.o ntuser/caret.o ntuser/cl
ntuser/hook.o ntuser/hotkey.o ntuser/input.o ntuser/keyboard.o \ ntuser/hook.o ntuser/hotkey.o ntuser/input.o ntuser/keyboard.o \
ntuser/menu.o ntuser/message.o ntuser/metric.o ntuser/misc.o \ ntuser/menu.o ntuser/message.o ntuser/metric.o ntuser/misc.o \
ntuser/msgqueue.o ntuser/painting.o ntuser/prop.o ntuser/scrollbar.o \ ntuser/msgqueue.o ntuser/painting.o ntuser/prop.o ntuser/scrollbar.o \
ntuser/stubs.o ntuser/timer.o ntuser/vis.o ntuser/windc.o \ ntuser/stubs.o ntuser/timer.o ntuser/useratom.o ntuser/vis.o \
ntuser/window.o ntuser/winlock.o ntuser/winpos.o ntuser/winsta.o ntuser/windc.o ntuser/window.o ntuser/winlock.o ntuser/winpos.o \
ntuser/winsta.o
OBJECTS_OBJECTS = objects/bitmaps.o objects/brush.o objects/cliprgn.o \ OBJECTS_OBJECTS = objects/bitmaps.o objects/brush.o objects/cliprgn.o \
objects/color.o objects/coord.o objects/dc.o \ objects/color.o objects/coord.o objects/dc.o \

View file

@ -24,14 +24,13 @@
* PROGRAMER: Filip Navara <xnavara@volny.cz> * PROGRAMER: Filip Navara <xnavara@volny.cz>
*/ */
#include <ddk/ntddk.h>
#include <ddk/ntddmou.h>
#include <win32k/win32k.h> #include <win32k/win32k.h>
#include <windows.h> #include <windows.h>
#include <internal/safe.h> #include <internal/safe.h>
#include <include/clipboard.h> #include <include/clipboard.h>
#include <include/cleanup.h> #include <include/cleanup.h>
#include <include/error.h> #include <include/error.h>
#include <include/useratom.h>
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -40,11 +39,11 @@ PW32THREAD ClipboardThread;
HWND ClipboardWindow; HWND ClipboardWindow;
#endif #endif
INT FASTCALL ULONG FASTCALL
IntGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName) IntGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName)
{ {
UNIMPLEMENTED; return IntGetAtomName((RTL_ATOM)format, FormatName->Buffer,
return 0; FormatName->MaximumLength);
} }
UINT FASTCALL UINT FASTCALL
@ -132,10 +131,11 @@ INT STDCALL
NtUserGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName, NtUserGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName,
INT cchMaxCount) INT cchMaxCount)
{ {
INT Ret; #if 1
NTSTATUS Status; NTSTATUS Status;
PWSTR Buf; PWSTR Buf;
UNICODE_STRING SafeFormatName, BufFormatName; UNICODE_STRING SafeFormatName, BufFormatName;
ULONG Ret;
if((cchMaxCount < 1) || !FormatName) if((cchMaxCount < 1) || !FormatName)
{ {
@ -196,6 +196,9 @@ NtUserGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName,
ExFreePool(Buf); ExFreePool(Buf);
return Ret; return Ret;
#else
return IntGetClipboardFormatName(format, FormatName);
#endif
} }
HWND STDCALL HWND STDCALL

View file

@ -0,0 +1,85 @@
/*
* ReactOS W32 Subsystem
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: User Atom helper routines
* FILE: subsys/win32k/ntuser/useratom.c
* PROGRAMER: Filip Navara <xnavara@volny.cz>
*/
#include <include/useratom.h>
#include <include/winsta.h>
#include <include/error.h>
#define NDEBUG
#include <debug.h>
RTL_ATOM FASTCALL
IntAddAtom(LPWSTR AtomName)
{
PWINSTATION_OBJECT WinStaObject;
NTSTATUS Status;
RTL_ATOM Atom;
Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
KernelMode, 0, &WinStaObject);
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return (RTL_ATOM)0;
}
Status = RtlAddAtomToAtomTable(WinStaObject->AtomTable,
AtomName, &Atom);
ObDereferenceObject(WinStaObject);
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return (RTL_ATOM)0;
}
return Atom;
}
ULONG FASTCALL
IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG nSize)
{
PWINSTATION_OBJECT WinStaObject;
NTSTATUS Status;
ULONG Size = nSize;
Status = IntValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
KernelMode, 0, &WinStaObject);
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return 0;
}
Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
nAtom, NULL, NULL, lpBuffer, &Size);
if (Size < nSize)
*(lpBuffer + Size) = 0;
ObDereferenceObject(WinStaObject);
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return 0;
}
return Size;
}
/* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: window.c,v 1.162 2003/12/14 14:26:50 weiden Exp $ /* $Id: window.c,v 1.163 2003/12/14 17:59:16 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -51,6 +51,7 @@
#include <include/hotkey.h> #include <include/hotkey.h>
#include <include/focus.h> #include <include/focus.h>
#include <include/hook.h> #include <include/hook.h>
#include <include/useratom.h>
#define NDEBUG #define NDEBUG
#include <win32k/debug1.h> #include <win32k/debug1.h>
@ -58,18 +59,8 @@
#define TAG_WNAM TAG('W', 'N', 'A', 'M') #define TAG_WNAM TAG('W', 'N', 'A', 'M')
typedef struct _REGISTERED_MESSAGE
{
LIST_ENTRY ListEntry;
WCHAR MessageName[1];
} REGISTERED_MESSAGE, *PREGISTERED_MESSAGE;
static LIST_ENTRY RegisteredMessageListHead;
static WndProcHandle *WndProcHandlesArray = 0; static WndProcHandle *WndProcHandlesArray = 0;
static WORD WndProcHandlesArraySize = 0; static WORD WndProcHandlesArraySize = 0;
#define REGISTERED_MESSAGE_MIN 0xc000
#define REGISTERED_MESSAGE_MAX 0xffff
#define WPH_SIZE 0x40 /* the size to add to the WndProcHandle array each time */ #define WPH_SIZE 0x40 /* the size to add to the WndProcHandle array each time */
/* PRIVATE FUNCTIONS **********************************************************/ /* PRIVATE FUNCTIONS **********************************************************/
@ -83,7 +74,6 @@ static WORD WndProcHandlesArraySize = 0;
NTSTATUS FASTCALL NTSTATUS FASTCALL
InitWindowImpl(VOID) InitWindowImpl(VOID)
{ {
InitializeListHead(&RegisteredMessageListHead);
WndProcHandlesArray = ExAllocatePool(PagedPool,WPH_SIZE * sizeof(WndProcHandle)); WndProcHandlesArray = ExAllocatePool(PagedPool,WPH_SIZE * sizeof(WndProcHandle));
WndProcHandlesArraySize = WPH_SIZE; WndProcHandlesArraySize = WPH_SIZE;
return STATUS_SUCCESS; return STATUS_SUCCESS;
@ -2790,6 +2780,7 @@ NtUserRealChildWindowFromPoint(DWORD Unknown0,
UINT STDCALL UINT STDCALL
NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe) NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe)
{ {
#if 0
PLIST_ENTRY Current; PLIST_ENTRY Current;
PREGISTERED_MESSAGE NewMsg, RegMsg; PREGISTERED_MESSAGE NewMsg, RegMsg;
UINT Msg = REGISTERED_MESSAGE_MIN; UINT Msg = REGISTERED_MESSAGE_MIN;
@ -2851,6 +2842,14 @@ NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe)
InsertTailList(&RegisteredMessageListHead, &(NewMsg->ListEntry)); InsertTailList(&RegisteredMessageListHead, &(NewMsg->ListEntry));
return Msg; 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
} }