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

exatom.c File Reference

#include "exp.h"

Go to the source code of this file.

Functions

PVOID ExpGetGlobalAtomTable ()
NTSYSAPI NTSTATUS NTAPI NtAddAtom (IN PWSTR AtomName, IN ULONG Length, OUT PRTL_ATOM Atom OPTIONAL)
NTSYSAPI NTSTATUS NTAPI NtFindAtom (IN PWSTR AtomName, IN ULONG Length, OUT PRTL_ATOM Atom OPTIONAL)
NTSYSAPI NTSTATUS NTAPI NtDeleteAtom (IN RTL_ATOM Atom)
NTSYSAPI NTSTATUS NTAPI NtQueryInformationAtom (IN RTL_ATOM Atom, IN ATOM_INFORMATION_CLASS AtomInformationClass, OUT PVOID AtomInformation, IN ULONG AtomInformationLength, OUT PULONG ReturnLength OPTIONAL)

Variables

PKWIN32_GLOBALATOMTABLE_CALLOUT ExGlobalAtomTableCallout


Function Documentation

PVOID ExpGetGlobalAtomTable  ) 
 

Definition at line 442 of file exatom.c.

References DbgPrint, ExGlobalAtomTableCallout, and NULL.

Referenced by NtAddAtom(), NtDeleteAtom(), NtFindAtom(), and NtQueryInformationAtom().

00447 : 00448 00449 Arguments: 00450 00451 Return Value: 00452 00453 --*/ 00454 00455 { 00456 if (ExGlobalAtomTableCallout != NULL) { 00457 00458 return ((*ExGlobalAtomTableCallout)()); 00459 00460 } else { 00461 00462 #if DBG 00463 DbgPrint( "EX: ExpGetGlobalAtomTable is about to return NULL!\n" ); 00464 DbgBreakPoint(); 00465 #endif 00466 return NULL; 00467 } 00468 } }

NTSYSAPI NTSTATUS NTAPI NtAddAtom IN PWSTR  AtomName,
IN ULONG  Length,
OUT PRTL_ATOM Atom  OPTIONAL
 

Definition at line 45 of file exatom.c.

References ExAllocatePoolWithTag, EXCEPTION_EXECUTE_HANDLER, ExFreePool(), ExpGetGlobalAtomTable(), KernelMode, KPROCESSOR_MODE, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, PagedPool, ProbeForRead, ProbeForWriteUshort, RtlAddAtomToAtomTable(), and Status.

00053 : 00054 00055 Arguments: 00056 00057 Return Value: 00058 00059 --*/ 00060 00061 { 00062 NTSTATUS Status; 00063 RTL_ATOM ReturnAtom; 00064 PVOID AtomTable = ExpGetGlobalAtomTable(); 00065 KPROCESSOR_MODE PreviousMode; 00066 PWSTR CapturedAtomNameBuffer; 00067 ULONG AllocLength; 00068 00069 PAGED_CODE(); 00070 00071 if (AtomTable == NULL) { 00072 00073 return STATUS_ACCESS_DENIED; 00074 } 00075 00076 if (Length > (RTL_ATOM_MAXIMUM_NAME_LENGTH * sizeof(WCHAR))) { 00077 00078 return STATUS_INVALID_PARAMETER; 00079 } 00080 00081 PreviousMode = KeGetPreviousMode(); 00082 CapturedAtomNameBuffer = NULL; 00083 00084 Status = STATUS_SUCCESS; 00085 00086 if (PreviousMode != KernelMode) { 00087 00088 try { 00089 00090 if (ARGUMENT_PRESENT( AtomName )) { 00091 00092 AllocLength = (Length + sizeof( UNICODE_NULL ))&~(sizeof (WCHAR)-1); 00093 ProbeForRead( AtomName, Length, sizeof( WCHAR ) ); 00094 CapturedAtomNameBuffer = ExAllocatePoolWithTag( PagedPool, AllocLength, 'motA' ); 00095 00096 if (CapturedAtomNameBuffer == NULL) { 00097 00098 return STATUS_INSUFFICIENT_RESOURCES; 00099 } 00100 00101 RtlMoveMemory( CapturedAtomNameBuffer, AtomName, Length ); 00102 CapturedAtomNameBuffer[Length / sizeof (WCHAR)] = '\0'; 00103 } 00104 00105 if (ARGUMENT_PRESENT( Atom )) { 00106 00107 ProbeForWriteUshort( Atom ); 00108 } 00109 00110 } except (EXCEPTION_EXECUTE_HANDLER) { 00111 00112 Status = GetExceptionCode(); 00113 } 00114 00115 } else { 00116 00117 if (ARGUMENT_PRESENT( AtomName )) { 00118 00119 CapturedAtomNameBuffer = AtomName; 00120 } 00121 } 00122 00123 if (NT_SUCCESS( Status )) { 00124 00125 Status = RtlAddAtomToAtomTable( AtomTable, CapturedAtomNameBuffer, &ReturnAtom ); 00126 00127 if (NT_SUCCESS( Status ) && ARGUMENT_PRESENT( Atom )) { 00128 00129 try { 00130 00131 *Atom = ReturnAtom; 00132 00133 } except (EXCEPTION_EXECUTE_HANDLER) { 00134 00135 Status = GetExceptionCode(); 00136 } 00137 } 00138 } 00139 00140 if ((CapturedAtomNameBuffer != NULL) && (CapturedAtomNameBuffer != AtomName)) { 00141 00142 ExFreePool( CapturedAtomNameBuffer ); 00143 } 00144 00145 return Status; 00146 }

NTSYSAPI NTSTATUS NTAPI NtDeleteAtom IN RTL_ATOM  Atom  ) 
 

Definition at line 260 of file exatom.c.

References ExpGetGlobalAtomTable(), NTSTATUS(), NULL, PAGED_CODE, RtlDeleteAtomFromAtomTable(), and Status.

00266 : 00267 00268 Arguments: 00269 00270 Return Value: 00271 00272 --*/ 00273 00274 { 00275 NTSTATUS Status; 00276 PVOID AtomTable = ExpGetGlobalAtomTable(); 00277 00278 PAGED_CODE(); 00279 00280 if (AtomTable == NULL) { 00281 00282 return STATUS_ACCESS_DENIED; 00283 } 00284 00285 Status = RtlDeleteAtomFromAtomTable( AtomTable, Atom ); 00286 00287 return Status; 00288 }

NTSYSAPI NTSTATUS NTAPI NtFindAtom IN PWSTR  AtomName,
IN ULONG  Length,
OUT PRTL_ATOM Atom  OPTIONAL
 

Definition at line 152 of file exatom.c.

References ExAllocatePoolWithTag, EXCEPTION_EXECUTE_HANDLER, ExFreePool(), ExpGetGlobalAtomTable(), KernelMode, KPROCESSOR_MODE, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, PagedPool, ProbeForRead, ProbeForWriteUshort, RtlLookupAtomInAtomTable(), and Status.

00160 : 00161 00162 Arguments: 00163 00164 Return Value: 00165 00166 --*/ 00167 00168 { 00169 NTSTATUS Status; 00170 RTL_ATOM ReturnAtom; 00171 PVOID AtomTable = ExpGetGlobalAtomTable(); 00172 KPROCESSOR_MODE PreviousMode; 00173 PWSTR CapturedAtomNameBuffer; 00174 ULONG AllocLength; 00175 00176 PAGED_CODE(); 00177 00178 if (AtomTable == NULL) { 00179 00180 return STATUS_ACCESS_DENIED; 00181 } 00182 00183 if (Length > (RTL_ATOM_MAXIMUM_NAME_LENGTH * sizeof(WCHAR))) { 00184 00185 return STATUS_INVALID_PARAMETER; 00186 } 00187 00188 PreviousMode = KeGetPreviousMode(); 00189 CapturedAtomNameBuffer = NULL; 00190 00191 Status = STATUS_SUCCESS; 00192 00193 if (PreviousMode != KernelMode) { 00194 00195 try { 00196 00197 if (ARGUMENT_PRESENT( AtomName )) { 00198 00199 AllocLength = (Length + sizeof( UNICODE_NULL ))&~(sizeof (WCHAR)-1); 00200 ProbeForRead( AtomName, Length, sizeof( WCHAR ) ); 00201 CapturedAtomNameBuffer = ExAllocatePoolWithTag( PagedPool, AllocLength, 'motA' ); 00202 00203 if (CapturedAtomNameBuffer == NULL) { 00204 00205 return STATUS_INSUFFICIENT_RESOURCES; 00206 } 00207 00208 RtlMoveMemory( CapturedAtomNameBuffer, AtomName, Length ); 00209 CapturedAtomNameBuffer[Length / sizeof (WCHAR)] = '\0'; 00210 00211 } 00212 00213 if (ARGUMENT_PRESENT( Atom )) { 00214 00215 ProbeForWriteUshort( Atom ); 00216 } 00217 00218 } except (EXCEPTION_EXECUTE_HANDLER) { 00219 00220 Status = GetExceptionCode(); 00221 } 00222 00223 } else { 00224 00225 if (ARGUMENT_PRESENT( AtomName )) { 00226 00227 CapturedAtomNameBuffer = AtomName; 00228 } 00229 } 00230 00231 if (NT_SUCCESS( Status )) { 00232 00233 Status = RtlLookupAtomInAtomTable( AtomTable, CapturedAtomNameBuffer, &ReturnAtom ); 00234 00235 if (NT_SUCCESS( Status ) && ARGUMENT_PRESENT( Atom )) { 00236 00237 try { 00238 00239 *Atom = ReturnAtom; 00240 00241 } except (EXCEPTION_EXECUTE_HANDLER) { 00242 00243 Status = GetExceptionCode(); 00244 } 00245 } 00246 } 00247 00248 if (CapturedAtomNameBuffer != NULL && CapturedAtomNameBuffer != AtomName) { 00249 00250 ExFreePool( CapturedAtomNameBuffer ); 00251 } 00252 00253 return Status; 00254 }

NTSYSAPI NTSTATUS NTAPI NtQueryInformationAtom IN RTL_ATOM  Atom,
IN ATOM_INFORMATION_CLASS  AtomInformationClass,
OUT PVOID  AtomInformation,
IN ULONG  AtomInformationLength,
OUT PULONG ReturnLength  OPTIONAL
 

Definition at line 294 of file exatom.c.

References EXCEPTION_EXECUTE_HANDLER, ExpGetGlobalAtomTable(), KernelMode, KPROCESSOR_MODE, Name, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, ProbeForWrite(), ProbeForWriteUlong, RtlQueryAtomInAtomTable(), RtlQueryAtomsInAtomTable(), Status, and USHORT.

00304 : 00305 00306 Arguments: 00307 00308 Return Value: 00309 00310 --*/ 00311 00312 { 00313 NTSTATUS Status; 00314 KPROCESSOR_MODE PreviousMode; 00315 ULONG RequiredLength; 00316 ULONG UsageCount; 00317 ULONG NameLength; 00318 ULONG AtomFlags; 00319 PATOM_BASIC_INFORMATION BasicInfo; 00320 PATOM_TABLE_INFORMATION TableInfo; 00321 PVOID AtomTable = ExpGetGlobalAtomTable(); 00322 00323 PAGED_CODE(); 00324 00325 if (AtomTable == NULL) { 00326 00327 return STATUS_ACCESS_DENIED; 00328 } 00329 00330 // 00331 // Assume successful completion. 00332 // 00333 00334 Status = STATUS_SUCCESS; 00335 00336 try { 00337 00338 // 00339 // Get previous processor mode and probe output argument if necessary. 00340 // 00341 00342 PreviousMode = KeGetPreviousMode(); 00343 00344 if (PreviousMode != KernelMode) { 00345 00346 ProbeForWrite( AtomInformation, 00347 AtomInformationLength, 00348 sizeof( ULONG )); 00349 00350 if (ARGUMENT_PRESENT( ReturnLength )) { 00351 00352 ProbeForWriteUlong( ReturnLength ); 00353 } 00354 } 00355 00356 RequiredLength = 0; 00357 00358 switch (AtomInformationClass) { 00359 00360 case AtomBasicInformation: 00361 00362 RequiredLength = FIELD_OFFSET( ATOM_BASIC_INFORMATION, Name ); 00363 00364 if (AtomInformationLength < RequiredLength) { 00365 00366 return STATUS_INFO_LENGTH_MISMATCH; 00367 } 00368 00369 BasicInfo = (PATOM_BASIC_INFORMATION)AtomInformation; 00370 UsageCount = 0; 00371 NameLength = AtomInformationLength - RequiredLength; 00372 BasicInfo->Name[ 0 ] = UNICODE_NULL; 00373 00374 Status = RtlQueryAtomInAtomTable( AtomTable, 00375 Atom, 00376 &UsageCount, 00377 &AtomFlags, 00378 &BasicInfo->Name[0], 00379 &NameLength ); 00380 00381 if (NT_SUCCESS(Status)) { 00382 00383 BasicInfo->UsageCount = (USHORT)UsageCount; 00384 BasicInfo->Flags = (USHORT)AtomFlags; 00385 BasicInfo->NameLength = (USHORT)NameLength; 00386 RequiredLength += NameLength + sizeof( UNICODE_NULL ); 00387 } 00388 00389 break; 00390 00391 case AtomTableInformation: 00392 00393 RequiredLength = FIELD_OFFSET( ATOM_TABLE_INFORMATION, Atoms ); 00394 00395 if (AtomInformationLength < RequiredLength) { 00396 00397 return STATUS_INFO_LENGTH_MISMATCH; 00398 } 00399 00400 TableInfo = (PATOM_TABLE_INFORMATION)AtomInformation; 00401 00402 Status = RtlQueryAtomsInAtomTable( AtomTable, 00403 (AtomInformationLength - RequiredLength) / sizeof( RTL_ATOM ), 00404 &TableInfo->NumberOfAtoms, 00405 &TableInfo->Atoms[0] ); 00406 00407 if (NT_SUCCESS(Status)) { 00408 00409 RequiredLength += TableInfo->NumberOfAtoms * sizeof( RTL_ATOM ); 00410 } 00411 00412 break; 00413 00414 default: 00415 00416 Status = STATUS_INVALID_INFO_CLASS; 00417 00418 break; 00419 } 00420 00421 if (ARGUMENT_PRESENT( ReturnLength )) { 00422 00423 *ReturnLength = RequiredLength; 00424 } 00425 00426 } except (EXCEPTION_EXECUTE_HANDLER) { 00427 00428 Status = GetExceptionCode(); 00429 } 00430 00431 return Status; 00432 }


Variable Documentation

PKWIN32_GLOBALATOMTABLE_CALLOUT ExGlobalAtomTableCallout
 

Definition at line 439 of file exatom.c.

Referenced by ExpGetGlobalAtomTable(), and PsEstablishWin32Callouts().


Generated on Sat May 15 19:43:34 2004 for test by doxygen 1.3.7