2003-12-14 17:59:17 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
2009-10-27 10:34:16 +00:00
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2003-12-14 17:59:17 +00:00
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
*/
|
|
|
|
|
2004-05-10 17:07:20 +00:00
|
|
|
#include <w32k.h>
|
|
|
|
|
2003-12-14 17:59:17 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
RTL_ATOM FASTCALL
|
|
|
|
IntAddAtom(LPWSTR AtomName)
|
|
|
|
{
|
2004-11-21 19:51:37 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
2008-10-16 17:52:38 +00:00
|
|
|
PTHREADINFO pti;
|
2003-12-14 17:59:17 +00:00
|
|
|
RTL_ATOM Atom;
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2008-10-16 17:52:38 +00:00
|
|
|
pti = PsGetCurrentThreadWin32Thread();
|
2010-01-14 02:52:12 +00:00
|
|
|
if (pti->rpdesk == NULL)
|
2003-12-14 17:59:17 +00:00
|
|
|
{
|
2005-05-08 02:11:54 +00:00
|
|
|
SetLastNtError(Status);
|
2003-12-14 17:59:17 +00:00
|
|
|
return (RTL_ATOM)0;
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-03-08 13:31:33 +00:00
|
|
|
Status = RtlAddAtomToAtomTable(gAtomTable, AtomName, &Atom);
|
|
|
|
|
2003-12-14 17:59:17 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2005-05-08 02:11:54 +00:00
|
|
|
SetLastNtError(Status);
|
2003-12-14 17:59:17 +00:00
|
|
|
return (RTL_ATOM)0;
|
|
|
|
}
|
|
|
|
return Atom;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG FASTCALL
|
|
|
|
IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG nSize)
|
|
|
|
{
|
2004-11-21 19:51:37 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
2008-10-16 17:52:38 +00:00
|
|
|
PTHREADINFO pti;
|
2003-12-14 17:59:17 +00:00
|
|
|
ULONG Size = nSize;
|
|
|
|
|
2008-10-16 17:52:38 +00:00
|
|
|
pti = PsGetCurrentThreadWin32Thread();
|
2010-01-14 02:52:12 +00:00
|
|
|
if (pti->rpdesk == NULL)
|
2003-12-14 17:59:17 +00:00
|
|
|
{
|
2005-05-08 02:11:54 +00:00
|
|
|
SetLastNtError(Status);
|
2003-12-14 17:59:17 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2007-03-08 13:31:33 +00:00
|
|
|
|
|
|
|
Status = RtlQueryAtomInAtomTable(gAtomTable, nAtom, NULL, NULL, lpBuffer, &Size);
|
|
|
|
|
2003-12-14 17:59:17 +00:00
|
|
|
if (Size < nSize)
|
|
|
|
*(lpBuffer + Size) = 0;
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2005-05-08 02:11:54 +00:00
|
|
|
SetLastNtError(Status);
|
2003-12-14 17:59:17 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return Size;
|
|
|
|
}
|
|
|
|
|
2009-06-30 19:12:02 +00:00
|
|
|
RTL_ATOM FASTCALL
|
|
|
|
IntAddGlobalAtom(LPWSTR lpBuffer, BOOL PinAtom)
|
|
|
|
{
|
|
|
|
RTL_ATOM Atom;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
Status = RtlAddAtomToAtomTable(gAtomTable, lpBuffer, &Atom);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("Error init Global Atom.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( Atom && PinAtom ) RtlPinAtomInAtomTable(gAtomTable, Atom);
|
|
|
|
|
|
|
|
return Atom;
|
|
|
|
}
|
|
|
|
|
2003-12-14 17:59:17 +00:00
|
|
|
/* EOF */
|