Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

atom.c

Go to the documentation of this file.
00001 /****************************** Module Header ******************************\ 00002 * Module Name: atom.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * This file contains the common code to implement atom tables. 00007 * 00008 \***************************************************************************/ 00009 00010 #include "precomp.h" 00011 #pragma hdrstop 00012 00013 #pragma alloc_text(INIT, UserRtlCreateAtomTable) 00014 00015 PVOID UserAtomTableHandle; 00016 00017 NTSTATUS 00018 UserRtlCreateAtomTable( 00019 IN ULONG NumberOfBuckets 00020 ) 00021 { 00022 NTSTATUS Status; 00023 00024 if (UserAtomTableHandle == NULL) { 00025 Status = RtlCreateAtomTable( NumberOfBuckets, &UserAtomTableHandle ); 00026 } else { 00027 RIPMSG0(RIP_VERBOSE, "UserRtlCreateAtomTable: table alread exists"); 00028 Status = STATUS_SUCCESS; 00029 } 00030 00031 return Status; 00032 } 00033 00034 00035 ATOM UserAddAtom( 00036 LPCWSTR ccxlpAtom, BOOL bPin) 00037 { 00038 NTSTATUS Status; 00039 ATOM atom; 00040 00041 UserAssert(IS_PTR(ccxlpAtom)); 00042 00043 /* 00044 * Rtl routines protect accesses to strings with their 00045 * own try/except blocks. 00046 */ 00047 atom = 0; 00048 Status = RtlAddAtomToAtomTable( UserAtomTableHandle, 00049 (PWSTR)ccxlpAtom, 00050 &atom 00051 ); 00052 if (!NT_SUCCESS(Status)) { 00053 RIPNTERR0(Status, RIP_VERBOSE, "UserAddAtom: add failed"); 00054 } 00055 00056 if (atom && bPin) 00057 RtlPinAtomInAtomTable(UserAtomTableHandle,atom); 00058 00059 return atom; 00060 } 00061 00062 ATOM UserFindAtom( 00063 LPCWSTR ccxlpAtom) 00064 { 00065 NTSTATUS Status; 00066 ATOM atom; 00067 00068 /* 00069 * Rtl routines protect accesses to strings with their 00070 * own try/except blocks. 00071 */ 00072 atom = 0; 00073 Status = RtlLookupAtomInAtomTable( UserAtomTableHandle, 00074 (PWSTR)ccxlpAtom, 00075 &atom 00076 ); 00077 if (!NT_SUCCESS(Status)) { 00078 RIPNTERR0(Status, RIP_VERBOSE, "UserFindAtom: lookup failed"); 00079 } 00080 00081 return atom; 00082 } 00083 00084 ATOM UserDeleteAtom( 00085 ATOM atom) 00086 { 00087 NTSTATUS Status; 00088 00089 if ((atom >= gatomFirstPinned) && (atom <= gatomLastPinned)) 00090 return 0; // if pinned, just return 00091 00092 Status = RtlDeleteAtomFromAtomTable( UserAtomTableHandle, atom ); 00093 if (NT_SUCCESS(Status)) { 00094 return 0; 00095 } else { 00096 RIPNTERR0(Status, RIP_VERBOSE, "UserDeleteAtom: delete failed"); 00097 return atom; 00098 } 00099 } 00100 00101 UINT UserGetAtomName( 00102 ATOM atom, 00103 LPWSTR ccxlpch, 00104 int cchMax) 00105 { 00106 NTSTATUS Status; 00107 ULONG AtomNameLength; 00108 00109 AtomNameLength = cchMax * sizeof(WCHAR); 00110 Status = RtlQueryAtomInAtomTable( UserAtomTableHandle, 00111 atom, 00112 NULL, 00113 NULL, 00114 ccxlpch, 00115 &AtomNameLength 00116 ); 00117 if (!NT_SUCCESS(Status)) { 00118 RIPNTERR0(Status, RIP_VERBOSE, "UserGetAtomName: query failed"); 00119 return 0; 00120 } else { 00121 return AtomNameLength / sizeof(WCHAR); 00122 } 00123 }

Generated on Sat May 15 19:39:17 2004 for test by doxygen 1.3.7