ReactOS  0.4.14-dev-599-g2d4d3f5
namesup.c File Reference
#include "fatprocs.h"
Include dependency graph for namesup.c:

Go to the source code of this file.

Macros

#define Dbg   (DEBUG_TRACE_NAMESUP)
 

Functions

BOOLEAN FatIsNameInExpression (IN PIRP_CONTEXT IrpContext, IN OEM_STRING Expression, IN OEM_STRING Name)
 
VOID FatStringTo8dot3 (_In_ PIRP_CONTEXT IrpContext, _In_ OEM_STRING InputString, _Out_writes_bytes_(11) PFAT8DOT3 Output8dot3)
 
VOID Fat8dot3ToString (_In_ PIRP_CONTEXT IrpContext, _In_ PDIRENT Dirent, _In_ BOOLEAN RestoreCase, _Out_ POEM_STRING OutputString)
 
 _Requires_lock_held_ (_Global_critical_region_)
 
VOID FatUnicodeToUpcaseOem (IN PIRP_CONTEXT IrpContext, IN POEM_STRING OemString, IN PUNICODE_STRING UnicodeString)
 
VOID FatEvaluateNameCase (IN PIRP_CONTEXT IrpContext, IN PUNICODE_STRING UnicodeName, IN OUT BOOLEAN *AllLowerComponent, IN OUT BOOLEAN *AllLowerExtension, IN OUT BOOLEAN *CreateLfn)
 
BOOLEAN FatSpaceInName (IN PIRP_CONTEXT IrpContext, IN PUNICODE_STRING UnicodeName)
 
VOID FatUnicodeRestoreShortNameCase (IN PUNICODE_STRING ShortNameWithCase, IN BOOLEAN LowerCase8, IN BOOLEAN LowerCase3)
 

Macro Definition Documentation

◆ Dbg

#define Dbg   (DEBUG_TRACE_NAMESUP)

Definition at line 18 of file namesup.c.

Function Documentation

◆ _Requires_lock_held_()

_Requires_lock_held_ ( _Global_critical_region_  )

Definition at line 376 of file namesup.c.

405 {
406  PDIRENT Dirent;
407  PBCB DirentBcb = NULL;
409 
410  CCB LocalCcb;
411 
412  PAGED_CODE();
413 
414  NT_ASSERT((MAX_LFN_CHARACTERS * sizeof( WCHAR)) == Lfn->MaximumLength);
415 
416  //
417  // We'll start by locating the dirent for the name.
418  //
419 
420  FatStringTo8dot3( IrpContext,
422  &LocalCcb.OemQueryTemplate.Constant );
423 
424  LocalCcb.Flags = 0;
425  LocalCcb.UnicodeQueryTemplate.Length = 0;
426  LocalCcb.ContainsWildCards = FALSE;
427 
428  FatLocateDirent( IrpContext,
429  Fcb->ParentDcb,
430  &LocalCcb,
432  NULL,
433  &Dirent,
434  &DirentBcb,
436  NULL,
437  Lfn,
438  NULL );
439  _SEH2_TRY {
440 
441  //
442  // If we didn't find the Dirent, something is terribly wrong.
443  //
444 
445  if ((DirentBcb == NULL) ||
447 
448  FatRaiseStatus( IrpContext, STATUS_FILE_INVALID );
449  }
450 
451  //
452  // Check for the easy case.
453  //
454 
455  if (Lfn->Length == 0) {
456 
459  UCHAR ShortNameBuffer[12];
460 
461  //
462  // If we thought that there was an LFN here and didn't find one,
463  // we're as dead. This shouldn't happen in normal operation, but
464  // if someone scrambles a directory by hand ...
465  //
466 
468 
470 
471  FatRaiseStatus( IrpContext, STATUS_FILE_INVALID );
472  }
473 
474  //
475  // There is no LFN, so manufacture a UNICODE name.
476  //
477 
478  ShortName.Length = 0;
479  ShortName.MaximumLength = 12;
480  ShortName.Buffer = (PCHAR)ShortNameBuffer;
481 
482  Fat8dot3ToString( IrpContext, Dirent, TRUE, &ShortName );
483 
484  //
485  // OK, now convert this string to UNICODE
486  //
487 
488 #ifdef _MSC_VER
489 #pragma prefast( suppress:28931, "needed for debug build" )
490 #endif
492  &ShortName,
493  FALSE );
494 
496  }
497 
498  } _SEH2_FINALLY {
499 
500  FatUnpinBcb( IrpContext, DirentBcb );
501  } _SEH2_END;
502 }
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING ShortName
Definition: fatprocs.h:1294
#define TRUE
Definition: types.h:120
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING Lfn
Definition: create.c:4157
Definition: cdstruc.h:1073
BOOLEAN ContainsWildCards
Definition: fatstruc.h:1374
LONG NTSTATUS
Definition: precomp.h:26
UNICODE_STRING UnicodeQueryTemplate
Definition: fatstruc.h:1425
NTSTATUS NTAPI RtlOemStringToCountedUnicodeString(IN OUT PUNICODE_STRING UniDest, IN PCOEM_STRING OemSource, IN BOOLEAN AllocateDestinationString)
Definition: unicode.c:1463
#define STATUS_FILE_INVALID
Definition: ntstatus.h:374
STRING OEM_STRING
Definition: umtypes.h:203
#define FatRaiseStatus(IRPCONTEXT, STATUS)
Definition: fatprocs.h:2965
struct _FCB * ParentDcb
Definition: fatstruc.h:835
_SEH2_TRY
Definition: create.c:4250
#define FatUnpinBcb(IRPCONTEXT, BCB)
Definition: fatprocs.h:537
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG DirentByteOffset
Definition: create.c:4157
smooth NULL
Definition: ftsmooth.c:416
ULONG Flags
Definition: cdstruc.h:1086
OEM_STRING Oem
Definition: fatstruc.h:692
#define PCHAR
Definition: match.c:90
__wchar_t WCHAR
Definition: xmlstorage.h:180
VBO LfnOffsetWithinDirectory
Definition: fatstruc.h:912
union _CCB::@712::@714::@716 OemQueryTemplate
#define MAX_LFN_CHARACTERS
Definition: lfn.h:50
PAGED_CODE()
unsigned char UCHAR
Definition: xmlstorage.h:181
VBO * PVBO
Definition: fat.h:39
union _FILE_NAME_NODE::@707 Name
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
VBO DirentOffsetWithinDirectory
Definition: fatstruc.h:905
VOID FatStringTo8dot3(_In_ PIRP_CONTEXT IrpContext, _In_ OEM_STRING InputString, _Out_writes_bytes_(11) PFAT8DOT3 Output8dot3)
Definition: namesup.c:79
_SEH2_FINALLY
Definition: create.c:4395
unsigned int ULONG
Definition: retypes.h:1
_In_ PFCB _In_ PDIRENT_ENUM_CONTEXT _Inout_ PDIRENT Dirent
Definition: cdprocs.h:429
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2938
FILE_NAME_NODE ShortName
Definition: fatstruc.h:1114
VOID Fat8dot3ToString(_In_ PIRP_CONTEXT IrpContext, _In_ PDIRENT Dirent, _In_ BOOLEAN RestoreCase, _Out_ POEM_STRING OutputString)
Definition: namesup.c:179
#define NT_ASSERT
Definition: rtlfuncs.h:3312

◆ Fat8dot3ToString()

VOID Fat8dot3ToString ( _In_ PIRP_CONTEXT  IrpContext,
_In_ PDIRENT  Dirent,
_In_ BOOLEAN  RestoreCase,
_Out_ POEM_STRING  OutputString 
)

Definition at line 179 of file namesup.c.

208 {
209  ULONG StringIndex;
210  ULONG BaseLength, ExtensionLength;
211 
212  PAGED_CODE();
213 
214  DebugTrace(+1, Dbg, "Fat8dot3ToString\n", 0);
215 
216  //
217  // First, find the length of the base component.
218  //
219 
220  for (BaseLength = 8; BaseLength > 0; BaseLength -= 1) {
221 
222  if (Dirent->FileName[BaseLength - 1] != UCHAR_SP) {
223 
224  break;
225  }
226  }
227 
228  //
229  // Now find the length of the extension.
230  //
231 
232  for (ExtensionLength = 3; ExtensionLength > 0; ExtensionLength -= 1) {
233 
234  if (Dirent->FileName[8 + ExtensionLength - 1] != UCHAR_SP) {
235 
236  break;
237  }
238  }
239 
240  //
241  // If there was a base part, copy it and check the case. Don't forget
242  // if the first character needs to be changed from 0x05 to 0xe5.
243  //
244 
245  if (BaseLength != 0) {
246 
247  RtlCopyMemory( OutputString->Buffer, Dirent->FileName, BaseLength );
248 
249  if (OutputString->Buffer[0] == FAT_DIRENT_REALLY_0E5) {
250 
251  OutputString->Buffer[0] = 0xe5;
252  }
253 
254  //
255  // Now if we are to restore case, look for A-Z
256  //
257 
258  if (FatData.ChicagoMode &&
259  RestoreCase &&
261 
262  for (StringIndex = 0; StringIndex < BaseLength; StringIndex += 1) {
263 
264  //
265  // Depending on whether the media was built in a system that was
266  // running with "code page invariance" (see FatEvaluateNameCase),
267  // there could be double-byte OEM characters lying in wait here.
268  // Gotta skip them.
269  //
270 
271  if (FsRtlIsLeadDbcsCharacter(OutputString->Buffer[StringIndex])) {
272 
273  StringIndex += 1;
274  continue;
275  }
276 
277  if ((OutputString->Buffer[StringIndex] >= 'A') &&
278  (OutputString->Buffer[StringIndex] <= 'Z')) {
279 
280  OutputString->Buffer[StringIndex] += 'a' - 'A';
281  }
282  }
283  }
284  }
285 
286  //
287  // If there was an extension, copy that over. Else we now know the
288  // size of the string.
289  //
290 
291  if (ExtensionLength != 0) {
292 
293  PUCHAR o, d;
294 
295  //
296  // Now add the dot
297  //
298 
299  OutputString->Buffer[BaseLength++] = '.';
300 
301  //
302  // Copy over the extension into the output buffer.
303  //
304 
305  o = (PUCHAR)&OutputString->Buffer[BaseLength];
306  d = &Dirent->FileName[8];
307 
308  switch (ExtensionLength) {
309  case 3:
310  *o++ = *d++;
311  case 2:
312  *o++ = *d++;
313  case 1:
314  *o++ = *d++;
315  }
316 
317  //
318  // Set the output string length
319  //
320 
321  OutputString->Length = (USHORT)(BaseLength + ExtensionLength);
322 
323  //
324  // Now if we are to restore case, look for A-Z
325  //
326 
327  if (FatData.ChicagoMode &&
328  RestoreCase &&
330 
331  for (StringIndex = BaseLength;
332  StringIndex < OutputString->Length;
333  StringIndex++ ) {
334 
335  //
336  // Depending on whether the media was built in a system that was
337  // running with "code page invariance" (see FatEvaluateNameCase),
338  // there could be double-byte OEM characters lying in wait here.
339  // Gotta skip them.
340  //
341 
342  if (FsRtlIsLeadDbcsCharacter(OutputString->Buffer[StringIndex])) {
343 
344  StringIndex += 1;
345  continue;
346  }
347 
348  if ((OutputString->Buffer[StringIndex] >= 'A') &&
349  (OutputString->Buffer[StringIndex] <= 'Z')) {
350 
351  OutputString->Buffer[StringIndex] += 'a' - 'A';
352  }
353  }
354  }
355 
356  } else {
357 
358  //
359  // Set the output string length
360  //
361 
362  OutputString->Length = (USHORT)BaseLength;
363  }
364 
365  //
366  // And return to our caller
367  //
368 
369  DebugTrace(-1, Dbg, "Fat8dot3ToString, OutputString = \"%Z\" -> VOID\n", OutputString);
370 
371  UNREFERENCED_PARAMETER( IrpContext );
372 
373  return;
374 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
unsigned char * PUCHAR
Definition: retypes.h:3
#define FAT_DIRENT_REALLY_0E5
Definition: fat.h:335
#define DebugTrace(INDENT, LEVEL, X, Y)
Definition: fatdata.h:313
BOOLEAN ChicagoMode
Definition: fatstruc.h:86
#define FAT_DIRENT_NT_BYTE_8_LOWER_CASE
Definition: fat.h:361
switch(r->id)
Definition: btrfs.c:2904
FAT_DATA FatData
Definition: fatdata.c:56
#define d
Definition: ke_i.h:81
#define UCHAR_SP
Definition: nodetype.h:143
PAGED_CODE()
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define FAT_DIRENT_NT_BYTE_3_LOWER_CASE
Definition: fat.h:362
unsigned short USHORT
Definition: pedump.c:61
#define Dbg
Definition: namesup.c:18
unsigned int ULONG
Definition: retypes.h:1
_In_ PFCB _In_ PDIRENT_ENUM_CONTEXT _Inout_ PDIRENT Dirent
Definition: cdprocs.h:429
#define FsRtlIsLeadDbcsCharacter(DBCS_CHAR)
Definition: init.c:417
UNREFERENCED_PARAMETER(IrpContext)

Referenced by _Requires_lock_held_(), and FatConstructNamesInFcb().

◆ FatEvaluateNameCase()

VOID FatEvaluateNameCase ( IN PIRP_CONTEXT  IrpContext,
IN PUNICODE_STRING  UnicodeName,
IN OUT BOOLEAN AllLowerComponent,
IN OUT BOOLEAN AllLowerExtension,
IN OUT BOOLEAN CreateLfn 
)

Definition at line 891 of file namesup.c.

922 {
923  ULONG i;
924  UCHAR Uppers = 0;
925  UCHAR Lowers = 0;
926 
927  BOOLEAN ExtensionPresent = FALSE;
928 
929  PAGED_CODE();
930  UNREFERENCED_PARAMETER( IrpContext );
931 
932  *CreateLfn = FALSE;
933 
934  for (i = 0; i < UnicodeName->Length / sizeof(WCHAR); i++) {
935 
936  WCHAR c;
937 
938  c = UnicodeName->Buffer[i];
939 
940  if ((c >= 'A') && (c <= 'Z')) {
941 
942  Uppers += 1;
943 
944  } else if ((c >= 'a') && (c <= 'z')) {
945 
946  Lowers += 1;
947 
948  } else if ((c >= 0x0080) && FatData.CodePageInvariant) {
949 
950  break;
951  }
952 
953  //
954  // If we come to a period, figure out if the extension was
955  // all one case.
956  //
957 
958  if (c == L'.') {
959 
960  *CreateLfn = (Lowers != 0) && (Uppers != 0);
961 
962  *AllLowerComponent = !(*CreateLfn) && (Lowers != 0);
963 
964  ExtensionPresent = TRUE;
965 
966  //
967  // Now reset the uppers and lowers count.
968  //
969 
970  Uppers = Lowers = 0;
971  }
972  }
973 
974  //
975  // Now check again for creating an LFN.
976  //
977 
978  *CreateLfn = (*CreateLfn ||
979  (i != UnicodeName->Length / sizeof(WCHAR)) ||
980  ((Lowers != 0) && (Uppers != 0)));
981 
982  //
983  // Now we know the final state of CreateLfn, update the two
984  // "AllLower" booleans.
985  //
986 
987  if (ExtensionPresent) {
988 
989  *AllLowerComponent = !(*CreateLfn) && *AllLowerComponent;
990  *AllLowerExtension = !(*CreateLfn) && (Lowers != 0);
991 
992  } else {
993 
994  *AllLowerComponent = !(*CreateLfn) && (Lowers != 0);
996  }
997 
998  return;
999 }
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING IN PUNICODE_STRING SuggestedShortName IN OUT BOOLEAN IN OUT BOOLEAN * AllLowerExtension
Definition: fatprocs.h:1294
#define TRUE
Definition: types.h:120
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING IN PUNICODE_STRING SuggestedShortName IN OUT BOOLEAN * AllLowerComponent
Definition: fatprocs.h:1294
IN PDCB IN POEM_STRING IN PUNICODE_STRING UnicodeName
Definition: fatprocs.h:1294
BOOLEAN CodePageInvariant
Definition: fatstruc.h:114
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned char BOOLEAN
FAT_DATA FatData
Definition: fatdata.c:56
__wchar_t WCHAR
Definition: xmlstorage.h:180
const GLubyte * c
Definition: glext.h:8905
PAGED_CODE()
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING IN PUNICODE_STRING SuggestedShortName IN OUT BOOLEAN IN OUT BOOLEAN IN OUT BOOLEAN * CreateLfn
Definition: fatprocs.h:1294
#define c
Definition: ke_i.h:80
unsigned int ULONG
Definition: retypes.h:1
UNREFERENCED_PARAMETER(IrpContext)

Referenced by FatSetRenameInfo().

◆ FatIsNameInExpression()

BOOLEAN FatIsNameInExpression ( IN PIRP_CONTEXT  IrpContext,
IN OEM_STRING  Expression,
IN OEM_STRING  Name 
)

Definition at line 35 of file namesup.c.

64 {
65  PAGED_CODE();
66 
67  //
68  // Call the appropriate FsRtl routine do to the real work
69  //
70 
72  &Name );
73 
74  UNREFERENCED_PARAMETER( IrpContext );
75 }
PCWSTR Expression
BOOLEAN NTAPI FsRtlIsDbcsInExpression(IN PANSI_STRING Expression, IN PANSI_STRING Name)
Definition: dbcsname.c:160
PAGED_CODE()
UNREFERENCED_PARAMETER(IrpContext)

◆ FatSpaceInName()

BOOLEAN FatSpaceInName ( IN PIRP_CONTEXT  IrpContext,
IN PUNICODE_STRING  UnicodeName 
)

Definition at line 1003 of file namesup.c.

1024 {
1025  ULONG i;
1026 
1027  PAGED_CODE();
1028  UNREFERENCED_PARAMETER( IrpContext );
1029 
1030  for (i=0; i < UnicodeName->Length/sizeof(WCHAR); i++) {
1031 
1032  if (UnicodeName->Buffer[i] == L' ') {
1033  return TRUE;
1034  }
1035  }
1036 
1037  return FALSE;
1038 }
#define TRUE
Definition: types.h:120
IN PDCB IN POEM_STRING IN PUNICODE_STRING UnicodeName
Definition: fatprocs.h:1294
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
__wchar_t WCHAR
Definition: xmlstorage.h:180
PAGED_CODE()
static const WCHAR L[]
Definition: oid.c:1250
unsigned int ULONG
Definition: retypes.h:1
UNREFERENCED_PARAMETER(IrpContext)

Referenced by FatSetRenameInfo().

◆ FatStringTo8dot3()

VOID FatStringTo8dot3 ( _In_ PIRP_CONTEXT  IrpContext,
_In_ OEM_STRING  InputString,
_Out_writes_bytes_(11) PFAT8DOT3  Output8dot3 
)

Definition at line 79 of file namesup.c.

105 {
106  ULONG i;
107  ULONG j;
108 
109  PAGED_CODE();
110 
111  DebugTrace(+1, Dbg, "FatStringTo8dot3\n", 0);
112  DebugTrace( 0, Dbg, "InputString = %Z\n", &InputString);
113 
114  NT_ASSERT( InputString.Length <= 12 );
115 
116  //
117  // Make the output name all blanks
118  //
119 
120  RtlFillMemory( Output8dot3, 11, UCHAR_SP );
121 
122  //
123  // Copy over the first part of the file name. Stop when we get to
124  // the end of the input string or a dot.
125  //
126 
127  for (i = 0;
128  (i < (ULONG)InputString.Length) && (InputString.Buffer[i] != '.') && (i < 11);
129  i += 1) {
130 
131  (*Output8dot3)[i] = InputString.Buffer[i];
132  }
133 
134  //
135  // Check if we need to process an extension
136  //
137 
138  if (i < (ULONG)InputString.Length) {
139 
140  //
141  // Make sure we have a dot and then skip over it.
142  //
143 
144  NT_ASSERT( (InputString.Length - i) <= 4 );
145  NT_ASSERT( InputString.Buffer[i] == '.' );
146 
147  i += 1;
148 
149  //
150  // Copy over the extension. Stop when we get to the
151  // end of the input string.
152  //
153 
154  for (j = 8; (i < (ULONG)InputString.Length); j += 1, i += 1) {
155 
156  (*Output8dot3)[j] = InputString.Buffer[i];
157  }
158  }
159 
160  //
161  // Before we return check if we should translate the first character
162  // from 0xe5 to 0x5.
163  //
164 
165  if ((*Output8dot3)[0] == 0xe5) {
166 
167  (*Output8dot3)[0] = FAT_DIRENT_REALLY_0E5;
168  }
169 
170  DebugTrace(-1, Dbg, "FatStringTo8dot3 -> (VOID)\n", 0);
171 
172  UNREFERENCED_PARAMETER( IrpContext );
173 
174  return;
175 }
#define FAT_DIRENT_REALLY_0E5
Definition: fat.h:335
#define DebugTrace(INDENT, LEVEL, X, Y)
Definition: fatdata.h:313
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define UCHAR_SP
Definition: nodetype.h:143
PAGED_CODE()
#define Dbg
Definition: namesup.c:18
unsigned int ULONG
Definition: retypes.h:1
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
UNREFERENCED_PARAMETER(IrpContext)
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by _Requires_lock_held_(), FatConstructDirent(), and FatSetRenameInfo().

◆ FatUnicodeRestoreShortNameCase()

VOID FatUnicodeRestoreShortNameCase ( IN PUNICODE_STRING  ShortNameWithCase,
IN BOOLEAN  LowerCase8,
IN BOOLEAN  LowerCase3 
)

Definition at line 1041 of file namesup.c.

1064 {
1065  USHORT i;
1066  UNICODE_STRING DownCaseSeg;
1067 
1068  PAGED_CODE();
1069 
1070  NT_ASSERT( ShortNameWithCase->Length <= 24 );
1071 
1072  //
1073  // Have to repair the case of the short name
1074  //
1075 
1076  for (i = 0; i < (ShortNameWithCase->Length/sizeof(WCHAR)) &&
1077  ShortNameWithCase->Buffer[i] != L'.'; i++);
1078 
1079  //
1080  // Now pointing at the '.', or otherwise the end of name component
1081  //
1082 
1083  if (LowerCase8) {
1084 
1085  DownCaseSeg.Buffer = ShortNameWithCase->Buffer;
1086  DownCaseSeg.MaximumLength = DownCaseSeg.Length = i*sizeof(WCHAR);
1087 
1088  RtlDowncaseUnicodeString(&DownCaseSeg, &DownCaseSeg, FALSE);
1089  }
1090 
1091  i++;
1092 
1093  //
1094  // Now pointing at first wchar of the extension.
1095  //
1096 
1097  if (LowerCase3) {
1098 
1099  //
1100  // It is not neccesarily the case that we can rely on the flag
1101  // indicating that we really have an extension.
1102  //
1103 
1104  if ((i*sizeof(WCHAR)) < ShortNameWithCase->Length) {
1105  DownCaseSeg.Buffer = &ShortNameWithCase->Buffer[i];
1106  DownCaseSeg.MaximumLength = DownCaseSeg.Length = ShortNameWithCase->Length - i*sizeof(WCHAR);
1107 
1108  RtlDowncaseUnicodeString(&DownCaseSeg, &DownCaseSeg, FALSE);
1109  }
1110  }
1111 
1112 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
__wchar_t WCHAR
Definition: xmlstorage.h:180
PAGED_CODE()
static const WCHAR L[]
Definition: oid.c:1250
unsigned short USHORT
Definition: pedump.c:61
NTSYSAPI NTSTATUS WINAPI RtlDowncaseUnicodeString(UNICODE_STRING *, const UNICODE_STRING *, BOOLEAN)
#define NT_ASSERT
Definition: rtlfuncs.h:3312

◆ FatUnicodeToUpcaseOem()

VOID FatUnicodeToUpcaseOem ( IN PIRP_CONTEXT  IrpContext,
IN POEM_STRING  OemString,
IN PUNICODE_STRING  UnicodeString 
)

Definition at line 632 of file namesup.c.

662 {
664 
665  PAGED_CODE();
666 
669  FALSE );
670 
672 
673  OemString->Buffer = NULL;
674  OemString->Length = 0;
675  OemString->MaximumLength = 0;
676 
679  TRUE );
680  }
681 
682  if (!NT_SUCCESS(Status)) {
683 
685 
686  OemString->Length = 0;
687 
688  } else {
689 
690  FatNormalizeAndRaiseStatus( IrpContext, Status );
691  }
692  }
693 
694  return;
695 }
*BytesInOemString PCHAR OemString
Definition: rtlfuncs.h:1561
#define TRUE
Definition: types.h:120
#define FatNormalizeAndRaiseStatus(IRPCONTEXT, STATUS)
Definition: fatprocs.h:2983
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PAGED_CODE()
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define STATUS_UNMAPPABLE_CHARACTER
Definition: ntstatus.h:576
NTSYSAPI NTSTATUS WINAPI RtlUpcaseUnicodeStringToCountedOemString(STRING *, const UNICODE_STRING *, BOOLEAN)

Referenced by FatSetRenameInfo().