Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenattrib.c
Go to the documentation of this file.
00001 /* 00002 * ReactOS kernel 00003 * Copyright (C) 2002,2003 ReactOS Team 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 00018 * 00019 * COPYRIGHT: See COPYING in the top level directory 00020 * PROJECT: ReactOS kernel 00021 * FILE: drivers/filesystem/ntfs/attrib.c 00022 * PURPOSE: NTFS filesystem driver 00023 * PROGRAMMER: Eric Kohl 00024 * Updated by Valentin Verkhovsky 2003/09/12 00025 */ 00026 00027 /* INCLUDES *****************************************************************/ 00028 00029 #include "ntfs.h" 00030 00031 #define NDEBUG 00032 #include <debug.h> 00033 00034 /* GLOBALS *****************************************************************/ 00035 00036 00037 /* FUNCTIONS ****************************************************************/ 00038 00039 00040 00041 static ULONG 00042 RunLength(PUCHAR run) 00043 { 00044 return(*run & 0x0f) + ((*run >> 4) & 0x0f) + 1; 00045 } 00046 00047 00048 static LONGLONG 00049 RunLCN(PUCHAR run) 00050 { 00051 UCHAR n1 = *run & 0x0f; 00052 UCHAR n2 = (*run >> 4) & 0x0f; 00053 LONGLONG lcn = (n2 == 0) ? 0 : (CHAR)(run[n1 + n2]); 00054 LONG i = 0; 00055 00056 for (i = n1 +n2 - 1; i > n1; i--) 00057 lcn = (lcn << 8) + run[i]; 00058 return lcn; 00059 } 00060 00061 00062 00063 static ULONGLONG 00064 RunCount(PUCHAR run) 00065 { 00066 UCHAR n = *run & 0xf; 00067 ULONGLONG count = 0; 00068 ULONG i = 0; 00069 00070 for (i = n; i > 0; i--) 00071 count = (count << 8) + run[i]; 00072 return count; 00073 } 00074 00075 00076 BOOLEAN 00077 FindRun (PNONRESIDENT_ATTRIBUTE NresAttr, 00078 ULONGLONG vcn, 00079 PULONGLONG lcn, 00080 PULONGLONG count) 00081 { 00082 PUCHAR run; 00083 00084 ULONGLONG base = NresAttr->StartVcn; 00085 00086 if (vcn < NresAttr->StartVcn || vcn > NresAttr->LastVcn) 00087 return FALSE; 00088 00089 *lcn = 0; 00090 00091 for (run = (PUCHAR)((ULONG_PTR)NresAttr + NresAttr->RunArrayOffset); 00092 *run != 0; run += RunLength(run)) 00093 { 00094 *lcn += RunLCN(run); 00095 *count = RunCount(run); 00096 00097 if (base <= vcn && vcn < base + *count) 00098 { 00099 *lcn = (RunLCN(run) == 0) ? 0 : *lcn + vcn - base; 00100 *count -= (ULONG)(vcn - base); 00101 00102 return TRUE; 00103 } 00104 else 00105 { 00106 base += *count; 00107 } 00108 } 00109 00110 return FALSE; 00111 } 00112 00113 00114 static VOID 00115 NtfsDumpFileNameAttribute(PATTRIBUTE Attribute) 00116 { 00117 PRESIDENT_ATTRIBUTE ResAttr; 00118 PFILENAME_ATTRIBUTE FileNameAttr; 00119 00120 DbgPrint(" $FILE_NAME "); 00121 00122 ResAttr = (PRESIDENT_ATTRIBUTE)Attribute; 00123 // DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset); 00124 00125 FileNameAttr = (PFILENAME_ATTRIBUTE)((ULONG_PTR)ResAttr + ResAttr->ValueOffset); 00126 DbgPrint(" '%.*S' ", FileNameAttr->NameLength, FileNameAttr->Name); 00127 } 00128 00129 00130 static VOID 00131 NtfsDumpVolumeNameAttribute(PATTRIBUTE Attribute) 00132 { 00133 PRESIDENT_ATTRIBUTE ResAttr; 00134 PWCHAR VolumeName; 00135 00136 DbgPrint(" $VOLUME_NAME "); 00137 00138 ResAttr = (PRESIDENT_ATTRIBUTE)Attribute; 00139 // DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset); 00140 00141 VolumeName = (PWCHAR)((ULONG_PTR)ResAttr + ResAttr->ValueOffset); 00142 DbgPrint(" '%.*S' ", ResAttr->ValueLength / sizeof(WCHAR), VolumeName); 00143 } 00144 00145 00146 static VOID 00147 NtfsDumpVolumeInformationAttribute(PATTRIBUTE Attribute) 00148 { 00149 PRESIDENT_ATTRIBUTE ResAttr; 00150 PVOLINFO_ATTRIBUTE VolInfoAttr; 00151 00152 DbgPrint(" $VOLUME_INFORMATION "); 00153 00154 ResAttr = (PRESIDENT_ATTRIBUTE)Attribute; 00155 // DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset); 00156 00157 VolInfoAttr = (PVOLINFO_ATTRIBUTE)((ULONG_PTR)ResAttr + ResAttr->ValueOffset); 00158 DbgPrint(" NTFS Version %u.%u Flags 0x%04hx ", 00159 VolInfoAttr->MajorVersion, 00160 VolInfoAttr->MinorVersion, 00161 VolInfoAttr->Flags); 00162 } 00163 00164 00165 static VOID 00166 NtfsDumpAttribute (PATTRIBUTE Attribute) 00167 { 00168 PNONRESIDENT_ATTRIBUTE NresAttr; 00169 UNICODE_STRING Name; 00170 00171 ULONGLONG lcn = 0; 00172 ULONGLONG runcount = 0; 00173 00174 switch (Attribute->AttributeType) 00175 { 00176 case AttributeFileName: 00177 NtfsDumpFileNameAttribute(Attribute); 00178 break; 00179 00180 case AttributeStandardInformation: 00181 DbgPrint(" $STANDARD_INFORMATION "); 00182 break; 00183 00184 case AttributeAttributeList: 00185 DbgPrint(" $ATTRIBUTE_LIST "); 00186 break; 00187 00188 case AttributeObjectId: 00189 DbgPrint(" $OBJECT_ID "); 00190 break; 00191 00192 case AttributeSecurityDescriptor: 00193 DbgPrint(" $SECURITY_DESCRIPTOR "); 00194 break; 00195 00196 case AttributeVolumeName: 00197 NtfsDumpVolumeNameAttribute(Attribute); 00198 break; 00199 00200 case AttributeVolumeInformation: 00201 NtfsDumpVolumeInformationAttribute(Attribute); 00202 break; 00203 00204 case AttributeData: 00205 DbgPrint(" $DATA "); 00206 //DataBuf = ExAllocatePool(NonPagedPool,AttributeLengthAllocated(Attribute)); 00207 break; 00208 00209 case AttributeIndexRoot: 00210 DbgPrint(" $INDEX_ROOT "); 00211 break; 00212 00213 case AttributeIndexAllocation: 00214 DbgPrint(" $INDEX_ALLOCATION "); 00215 break; 00216 00217 case AttributeBitmap: 00218 DbgPrint(" $BITMAP "); 00219 break; 00220 00221 case AttributeReparsePoint: 00222 DbgPrint(" $REPARSE_POINT "); 00223 break; 00224 00225 case AttributeEAInformation: 00226 DbgPrint(" $EA_INFORMATION "); 00227 break; 00228 00229 case AttributeEA: 00230 DbgPrint(" $EA "); 00231 break; 00232 00233 case AttributePropertySet: 00234 DbgPrint(" $PROPERTY_SET "); 00235 break; 00236 00237 case AttributeLoggedUtilityStream: 00238 DbgPrint(" $LOGGED_UTILITY_STREAM "); 00239 break; 00240 00241 default: 00242 DbgPrint(" Attribute %lx ", 00243 Attribute->AttributeType); 00244 break; 00245 } 00246 00247 if (Attribute->NameLength != 0) 00248 { 00249 Name.Length = Attribute->NameLength * sizeof(WCHAR); 00250 Name.MaximumLength = Name.Length; 00251 Name.Buffer = (PWCHAR)((ULONG_PTR)Attribute + Attribute->NameOffset); 00252 00253 DbgPrint("'%wZ' ", &Name); 00254 } 00255 00256 DbgPrint("(%s)\n", 00257 Attribute->Nonresident ? "non-resident" : "resident"); 00258 00259 if (Attribute->Nonresident) 00260 { 00261 NresAttr = (PNONRESIDENT_ATTRIBUTE)Attribute; 00262 00263 FindRun (NresAttr,0,&lcn, &runcount); 00264 00265 DbgPrint (" AllocatedSize %I64u DataSize %I64u\n", 00266 NresAttr->AllocatedSize, NresAttr->DataSize); 00267 DbgPrint (" logical clusters: %I64u - %I64u\n", 00268 lcn, lcn + runcount - 1); 00269 } 00270 } 00271 00272 00273 VOID 00274 NtfsDumpFileAttributes (PFILE_RECORD_HEADER FileRecord) 00275 { 00276 PATTRIBUTE Attribute; 00277 00278 Attribute = (PATTRIBUTE)((ULONG_PTR)FileRecord + FileRecord->AttributeOffset); 00279 while (Attribute < (PATTRIBUTE)((ULONG_PTR)FileRecord + FileRecord->BytesInUse) && 00280 Attribute->AttributeType != (ATTRIBUTE_TYPE)-1) 00281 { 00282 NtfsDumpAttribute (Attribute); 00283 00284 Attribute = (PATTRIBUTE)((ULONG_PTR)Attribute + Attribute->Length); 00285 } 00286 } 00287 00288 /* EOF */ Generated on Fri May 25 2012 04:16:27 for ReactOS by
1.7.6.1
|