Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 239 of file atom.c.
Referenced by InternalFindAtom().
{ PRTL_ATOM_TABLE AtomTable = ExpGetGlobalAtomTable(); NTSTATUS Status; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); LPWSTR CapturedName = NULL; ULONG CapturedSize; RTL_ATOM SafeAtom; PAGED_CODE(); /* Check for the table */ if (AtomTable == NULL) return STATUS_ACCESS_DENIED; /* Check for valid name */ if (AtomNameLength > (RTL_MAXIMUM_ATOM_LENGTH * sizeof(WCHAR))) { /* Fail */ DPRINT1("Atom name too long\n"); return STATUS_INVALID_PARAMETER; } /* Re-use the given name if kernel mode or no atom name */ CapturedName = AtomName; /* Check if we're called from user-mode*/ if (PreviousMode != KernelMode) { /* Enter SEH */ _SEH2_TRY { /* Check if we have a name */ if (AtomName) { /* Probe the atom */ ProbeForRead(AtomName, AtomNameLength, sizeof(WCHAR)); /* Allocate an aligned buffer + the null char */ CapturedSize = ((AtomNameLength + sizeof(WCHAR)) &~ (sizeof(WCHAR) -1)); CapturedName = ExAllocatePoolWithTag(PagedPool, CapturedSize, TAG_ATOM); if (!CapturedName) { /* Fail the call */ Status = STATUS_INSUFFICIENT_RESOURCES; } else { /* Copy the name and null-terminate it */ RtlCopyMemory(CapturedName, AtomName, AtomNameLength); CapturedName[AtomNameLength / sizeof(WCHAR)] = UNICODE_NULL; } /* Probe the atom too */ if (Atom) ProbeForWriteUshort(Atom); } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { /* Return the exception code */ _SEH2_YIELD(return _SEH2_GetExceptionCode()); } _SEH2_END; } /* Call the runtime function */ Status = RtlLookupAtomInAtomTable(AtomTable, CapturedName, &SafeAtom); if (NT_SUCCESS(Status) && (Atom)) { /* Success and caller wants the atom back.. .enter SEH */ _SEH2_TRY { /* Return the atom */ *Atom = SafeAtom; } _SEH2_EXCEPT(ExSystemExceptionFilter()) { Status = _SEH2_GetExceptionCode(); } _SEH2_END; } /* If we captured anything, free it */ if ((CapturedName) && (CapturedName != AtomName)) ExFreePoolWithTag(CapturedName, TAG_ATOM); /* Return to caller */ return Status; }