00809 :
00810
00811 This routine returns information
for all
the object in
the
00812 system. It enuermates through all
the object types and in
00813 each
type it enumerates through their
type list.
00814
00815 Arguments:
00816
00817 UserModeBufferAddress - Supplies
the address of
the query buffer
00818 as specified by
the user.
00819
00820 ObjectInformation - Supplies a buffer to receive
the object
00821
type information. This
is essentially
the same as
the first
00822 parameter except that one
is a system address and
the other
00823
is in
the user's address space.
00824
00825 Length - Supplies
the length, in bytes, of
the object information
00826 buffer
00827
00828 ReturnLength - Optionally receives
the total length, in bytes,
00829 needed to store
the object information
00830
00831
00832 Return Value:
00833
00834 An appropriate status value
00835
00836 --*/
00837
00838 {
00839
NTSTATUS ReturnStatus,
Status;
00840 PLIST_ENTRY Next, Head;
00841 PLIST_ENTRY Next1, Head1;
00842
POBJECT_TYPE ObjectType;
00843
POBJECT_HEADER ObjectHeader;
00844
POBJECT_HEADER_CREATOR_INFO CreatorInfo;
00845
POBJECT_HEADER_QUOTA_INFO QuotaInfo;
00846 PVOID Object;
00847 BOOLEAN FirstObjectForType;
00848 PSYSTEM_OBJECTTYPE_INFORMATION TypeInfo;
00849 PSYSTEM_OBJECT_INFORMATION ObjectInfo;
00850 ULONG TotalSize, NameSize;
00851
POBJECT_HEADER ObjectTypeHeader;
00852 WCHAR NameBuffer[ 260 + 4 ];
00853 POBJECT_NAME_INFORMATION NameInformation;
00854
extern POBJECT_TYPE IoFileObjectType;
00855 PWSTR TempBuffer;
00856
USHORT TempMaximumLength;
00857
POBJECT_TYPE_ARRAY ObjectTypeArray;
00858 ULONG i;
00859
00860
PAGED_CODE();
00861
00862
00863
00864
00865
00866 NameInformation = (POBJECT_NAME_INFORMATION)NameBuffer;
00867 ReturnStatus = STATUS_SUCCESS;
00868 TotalSize = 0;
00869 TypeInfo =
NULL;
00870
00871
00872
00873
00874
00875
00876
ObpEnterObjectTypeMutex( ObpTypeObjectType );
00877
00878
try {
00879
00880
00881
00882
00883
00884
00885 Head = &
ObpTypeObjectType->
TypeList;
00886 Next = Head->Flink;
00887
00888
while (Next != Head) {
00889
00890
00891
00892
00893
00894
00895
00896 CreatorInfo = CONTAINING_RECORD( Next,
00897
OBJECT_HEADER_CREATOR_INFO,
00898 TypeList );
00899
00900 ObjectTypeHeader = (
POBJECT_HEADER)(CreatorInfo+1);
00901 ObjectType = (
POBJECT_TYPE)&ObjectTypeHeader->
Body;
00902
00903
00904
00905
00906
00907
00908
00909
if (ObjectType !=
ObpTypeObjectType) {
00910
00911
00912
00913
00914
00915 ObjectTypeArray =
ObpCreateTypeArray ( ObjectType );
00916
00917
00918
00919
00920
00921
00922
if (ObjectTypeArray !=
NULL) {
00923
00924
00925
00926
00927
00928
00929 FirstObjectForType =
TRUE;
00930
00931
for ( i = 0; i < ObjectTypeArray->
Size; i++) {
00932
00933
00934
00935
00936
00937
00938 CreatorInfo = ObjectTypeArray->
CreatorInfoArray[i];
00939
00940 ObjectHeader = (
POBJECT_HEADER)(CreatorInfo+1);
00941
00942 Object = &ObjectHeader->
Body;
00943
00944
00945
00946
00947
00948
00949
if (FirstObjectForType) {
00950
00951 FirstObjectForType =
FALSE;
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
if ((TypeInfo !=
NULL) && (TotalSize < Length)) {
00962
00963 TypeInfo->NextEntryOffset = TotalSize;
00964 }
00965
00966
00967
00968
00969
00970
00971
00972
00973 TypeInfo = (PSYSTEM_OBJECTTYPE_INFORMATION)((PCHAR)ObjectInformation + TotalSize);
00974
00975 TotalSize += FIELD_OFFSET( SYSTEM_OBJECTTYPE_INFORMATION, TypeName );
00976
00977
00978
00979
00980
00981
00982
if (TotalSize >= Length) {
00983
00984 ReturnStatus = STATUS_INFO_LENGTH_MISMATCH;
00985
00986 }
else {
00987
00988 TypeInfo->NextEntryOffset = 0;
00989 TypeInfo->NumberOfObjects = ObjectType->
TotalNumberOfObjects;
00990 TypeInfo->NumberOfHandles = ObjectType->
TotalNumberOfHandles;
00991 TypeInfo->TypeIndex = ObjectType->
Index;
00992 TypeInfo->InvalidAttributes = ObjectType->
TypeInfo.
InvalidAttributes;
00993 TypeInfo->GenericMapping = ObjectType->
TypeInfo.
GenericMapping;
00994 TypeInfo->ValidAccessMask = ObjectType->
TypeInfo.
ValidAccessMask;
00995 TypeInfo->PoolType = ObjectType->
TypeInfo.
PoolType;
00996 TypeInfo->SecurityRequired = ObjectType->
TypeInfo.
SecurityRequired;
00997 }
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011 NameSize = 0;
01012
01013
Status =
ObQueryTypeName( Object,
01014 &TypeInfo->TypeName,
01015 TotalSize < Length ? Length - TotalSize : 0,
01016 &NameSize );
01017
01018
01019
01020
01021
01022 NameSize = (NameSize +
sizeof( ULONG ) - 1) & (~(
sizeof( ULONG ) - 1));
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
if (
NT_SUCCESS( Status )) {
01033
01034 TypeInfo->TypeName.MaximumLength = (
USHORT)
01035 (NameSize -
sizeof( TypeInfo->TypeName ));
01036 TypeInfo->TypeName.Buffer = (PWSTR)
01037 (UserModeBufferAddress +
01038 ((PCHAR)TypeInfo->TypeName.Buffer - (PCHAR)ObjectInformation)
01039 );
01040
01041 }
else {
01042
01043 ReturnStatus =
Status;
01044 }
01045
01046
01047
01048
01049
01050
01051 TotalSize += NameSize;
01052
01053 }
else {
01054
01055
01056
01057
01058
01059
01060
01061
01062
if (TotalSize < Length) {
01063
01064 ObjectInfo->NextEntryOffset = TotalSize;
01065 }
01066 }
01067
01068
01069
01070
01071
01072
01073
01074
01075 ObjectInfo = (PSYSTEM_OBJECT_INFORMATION)((PCHAR)ObjectInformation + TotalSize);
01076
01077 TotalSize += FIELD_OFFSET( SYSTEM_OBJECT_INFORMATION, NameInfo );
01078
01079
01080
01081
01082
01083
01084
if (TotalSize >= Length) {
01085
01086 ReturnStatus = STATUS_INFO_LENGTH_MISMATCH;
01087
01088 }
else {
01089
01090 ObjectInfo->NextEntryOffset = 0;
01091 ObjectInfo->Object = Object;
01092 ObjectInfo->CreatorUniqueProcess = CreatorInfo->
CreatorUniqueProcess;
01093 ObjectInfo->CreatorBackTraceIndex = CreatorInfo->
CreatorBackTraceIndex;
01094 ObjectInfo->PointerCount = ObjectHeader->
PointerCount;
01095 ObjectInfo->HandleCount = ObjectHeader->
HandleCount;
01096 ObjectInfo->Flags = (
USHORT)ObjectHeader->
Flags;
01097 ObjectInfo->SecurityDescriptor = ObjectHeader->
SecurityDescriptor;
01098
01099
01100
01101
01102
01103
01104 QuotaInfo =
OBJECT_HEADER_TO_QUOTA_INFO( ObjectHeader );
01105
01106
if (QuotaInfo !=
NULL) {
01107
01108 ObjectInfo->PagedPoolCharge = QuotaInfo->
PagedPoolCharge;
01109 ObjectInfo->NonPagedPoolCharge = QuotaInfo->
NonPagedPoolCharge;
01110
01111
if (QuotaInfo->
ExclusiveProcess !=
NULL) {
01112
01113 ObjectInfo->ExclusiveProcessId = QuotaInfo->
ExclusiveProcess->
UniqueProcessId;
01114 }
01115
01116 }
else {
01117
01118 ObjectInfo->PagedPoolCharge = ObjectType->
TypeInfo.
DefaultPagedPoolCharge;
01119 ObjectInfo->NonPagedPoolCharge = ObjectType->
TypeInfo.
DefaultNonPagedPoolCharge;
01120 }
01121 }
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131 NameSize = 0;
01132
Status = STATUS_SUCCESS;
01133
01134
if ((ObjectType->
TypeInfo.
QueryNameProcedure ==
NULL) ||
01135 (ObjectType !=
IoFileObjectType)) {
01136
01137
Status =
ObQueryNameString( Object,
01138 NameInformation,
01139
sizeof( NameBuffer ),
01140 &NameSize );
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150 }
else if (ObjectType ==
IoFileObjectType) {
01151
01152 NameInformation->Name = ((
PFILE_OBJECT)Object)->FileName;
01153
01154
if ((NameInformation->Name.Length != 0) &&
01155 (NameInformation->Name.Buffer !=
NULL)) {
01156
01157 NameSize = NameInformation->Name.Length +
sizeof( UNICODE_NULL );
01158
01159
01160
01161
01162
01163
01164
if (NameSize > (260 *
sizeof( WCHAR ))) {
01165
01166 NameSize = (260 *
sizeof( WCHAR ));
01167 NameInformation->Name.Length = (
USHORT)(NameSize -
sizeof( UNICODE_NULL ));
01168 }
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179 RtlMoveMemory( (NameInformation+1),
01180 NameInformation->Name.Buffer,
01181 NameSize -
sizeof( UNICODE_NULL) );
01182
01183 NameInformation->Name.Buffer = (PWSTR)(NameInformation+1);
01184 NameInformation->Name.MaximumLength = (
USHORT)NameSize;
01185 NameInformation->Name.Buffer[ NameInformation->Name.Length /
sizeof( WCHAR )] = UNICODE_NULL;
01186
01187
01188
01189
01190
01191
01192 NameSize +=
sizeof( *NameInformation );
01193
01194 }
else {
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204 NameSize = 0;
01205 }
01206 }
01207
01208
01209
01210
01211
01212
01213
01214
if (NameSize != 0) {
01215
01216
01217
01218
01219
01220
01221
01222 NameSize = (NameSize +
sizeof( ULONG ) - 1) & (~(
sizeof( ULONG ) - 1));
01223 TotalSize += NameSize;
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
if ((
NT_SUCCESS( Status )) &&
01235 (NameInformation->Name.Length != 0) &&
01236 (TotalSize < Length)) {
01237
01238
01239
01240
01241
01242 TempBuffer = (PWSTR)((&ObjectInfo->NameInfo)+1);
01243 TempMaximumLength = (
USHORT)
01244 (NameInformation->Name.Length +
sizeof( UNICODE_NULL ));
01245
01246 ObjectInfo->NameInfo.Name.Length = NameInformation->Name.Length;
01247
01248 RtlMoveMemory( TempBuffer,
01249 NameInformation->Name.Buffer,
01250 TempMaximumLength);
01251
01252 ObjectInfo->NameInfo.Name.Buffer = (PWSTR)
01253 (UserModeBufferAddress +
01254 ((PCHAR)TempBuffer - (PCHAR)ObjectInformation));
01255 ObjectInfo->NameInfo.Name.MaximumLength = TempMaximumLength;
01256
01257
01258
01259
01260
01261
01262
01263
01264 }
else if (
NT_SUCCESS( Status )) {
01265
01266
if ((NameInformation->Name.Length != 0) ||
01267 (TotalSize >= Length)) {
01268
01269 ReturnStatus = STATUS_INFO_LENGTH_MISMATCH;
01270
01271 }
else {
01272
01273
RtlInitUnicodeString( &ObjectInfo->NameInfo.Name, NULL );
01274 }
01275
01276
01277
01278
01279
01280
01281
01282
01283 }
else {
01284
01285 TotalSize +=
sizeof( ObjectInfo->NameInfo.Name );
01286
01287
if (TotalSize >= Length) {
01288
01289 ReturnStatus = STATUS_INFO_LENGTH_MISMATCH;
01290
01291 }
else {
01292
01293
RtlInitUnicodeString( &ObjectInfo->NameInfo.Name, NULL );
01294
01295 ReturnStatus =
Status;
01296 }
01297 }
01298
01299
01300
01301
01302
01303
01304
01305
01306 }
else {
01307
01308 TotalSize +=
sizeof( ObjectInfo->NameInfo.Name );
01309
01310
if (TotalSize >= Length) {
01311
01312 ReturnStatus = STATUS_INFO_LENGTH_MISMATCH;
01313
01314 }
else {
01315
01316
RtlInitUnicodeString( &ObjectInfo->NameInfo.Name, NULL );
01317 }
01318 }
01319
01320 }
01321
01322
01323
01324
01325
01326
ObpDestroyTypeArray(ObjectTypeArray);
01327 ObjectTypeArray =
NULL;
01328 }
01329 }
01330
01331
01332
01333
01334
01335
01336 Next = Next->Flink;
01337 }
01338
01339
01340
01341
01342
01343
01344
if (ARGUMENT_PRESENT( ReturnLength )) {
01345
01346 *ReturnLength = TotalSize;
01347 }
01348
01349
01350 } finally {
01351
01352
if (ObjectTypeArray !=
NULL) {
01353
01354
ObpDestroyTypeArray(ObjectTypeArray);
01355 }
01356
01357
01358
01359
01360
ObpLeaveObjectTypeMutex( ObpTypeObjectType );
01361 }
01362
01363
01364
return( ReturnStatus );
01365 }