ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

useratom.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:        See COPYING in the top level directory
00003  * PROJECT:          ReactOS kernel
00004  * PURPOSE:          User Atom helper routines
00005  * FILE:             subsys/win32k/ntuser/useratom.c
00006  * PROGRAMER:        Filip Navara <xnavara@volny.cz>
00007  */
00008 
00009 #include <win32k.h>
00010 DBG_DEFAULT_CHANNEL(UserMisc);
00011 
00012 RTL_ATOM FASTCALL
00013 IntAddAtom(LPWSTR AtomName)
00014 {
00015    NTSTATUS Status = STATUS_SUCCESS;
00016    PTHREADINFO pti;
00017    RTL_ATOM Atom;
00018 
00019    pti = PsGetCurrentThreadWin32Thread();
00020    if (pti->rpdesk == NULL)
00021    {
00022       SetLastNtError(Status);
00023       return (RTL_ATOM)0;
00024    }
00025 
00026    Status = RtlAddAtomToAtomTable(gAtomTable, AtomName, &Atom);
00027 
00028    if (!NT_SUCCESS(Status))
00029    {
00030       SetLastNtError(Status);
00031       return (RTL_ATOM)0;
00032    }
00033    return Atom;
00034 }
00035 
00036 ULONG FASTCALL
00037 IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG nSize)
00038 {
00039    NTSTATUS Status = STATUS_SUCCESS;
00040    PTHREADINFO pti;
00041    ULONG Size = nSize;
00042 
00043    pti = PsGetCurrentThreadWin32Thread();
00044    if (pti->rpdesk == NULL)
00045    {
00046       SetLastNtError(Status);
00047       return 0;
00048    }
00049 
00050    Status = RtlQueryAtomInAtomTable(gAtomTable, nAtom, NULL, NULL, lpBuffer, &Size);
00051 
00052    if (Size < nSize)
00053       *(lpBuffer + Size/sizeof(WCHAR)) = 0;
00054    if (!NT_SUCCESS(Status))
00055    {
00056       SetLastNtError(Status);
00057       return 0;
00058    }
00059    return Size;
00060 }
00061 
00062 RTL_ATOM FASTCALL
00063 IntAddGlobalAtom(LPWSTR lpBuffer, BOOL PinAtom)
00064 {
00065    RTL_ATOM Atom;
00066    NTSTATUS Status = STATUS_SUCCESS;
00067 
00068    Status = RtlAddAtomToAtomTable(gAtomTable, lpBuffer, &Atom);
00069 
00070    if (!NT_SUCCESS(Status))
00071    {
00072       ERR("Error init Global Atom.\n");
00073       return 0;
00074    }
00075 
00076    if ( Atom && PinAtom ) RtlPinAtomInAtomTable(gAtomTable, Atom);
00077 
00078    return Atom;
00079 }
00080 
00081 DWORD
00082 APIENTRY
00083 NtUserGetAtomName(
00084     ATOM nAtom,
00085     PUNICODE_STRING pBuffer)
00086 {
00087    DWORD Ret;
00088    WCHAR Buffer[256];
00089    UNICODE_STRING CapturedName = {0};
00090    UserEnterShared();
00091    CapturedName.Buffer = (LPWSTR)&Buffer;
00092    CapturedName.MaximumLength = sizeof(Buffer);
00093    Ret = IntGetAtomName((RTL_ATOM)nAtom, CapturedName.Buffer, (ULONG)CapturedName.Length);
00094    _SEH2_TRY
00095    {
00096       RtlCopyMemory(pBuffer->Buffer, &Buffer, pBuffer->MaximumLength);
00097    }
00098    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
00099    {
00100       Ret = 0;
00101    }
00102    _SEH2_END
00103    UserLeave();
00104    return Ret;
00105 }
00106 
00107 /* EOF */

Generated on Wed May 23 2012 04:36:21 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.