Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTFSD

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

short file names creation

OSR_Community_UserOSR_Community_User Member Posts: 110,217
Hi,

Could anybody shed light on the short file names creation algorithm?
How can I reproduce it?

As far as I can understand, there are two routines which can be used for
that:
RtlIsNameLegalDOS8Dot3 and RtlGenerate8dot3Name.

First, RtlIsNameLegalDOS8Dot3 can be used for name checking. If it returns
FALSE or indicates that the name contains spaces, a short name should be
generated using RtlGenerate8dot3Name (allowing extended characters on FAT
and disabling them on NTFS).

The question is about the case when RtlIsNameLegalDOS8Dot3 returns TRUE
and the name does not contain spaces. Even in this case the file system
sometimes
generates a short name. I do not know exact circumstances, but seems it
happens
when the name contains non-ASCII symbols (something else?). Results on FAT
and
NTFS are different in this case. On NTFS the short name appears as generated
by
RtlGenerate8dot3Name, while on FAT it looks the same as the OEM name
returned
from RtlIsNameLegalDOS8Dot3.

So, can I use the following algorithm?

if (!RtlIsNameLegalDOS8Dot3(&Name, &OemName, &ContainsSpaces) ||
ContainsSpaces == TRUE) {
if (NTFS) {
RtlGenerate8dot3Name(&Name, FALSE, &Context, &Name8dot3);
}
else {
RtlGenerate8dot3Name(&Name, TRUE, &Context, &Name8dot3);
}
}
else if (At least one character in OemName is greater than 0x7F) {
if (NTFS) {
RtlGenerate8dot3Name(&Name, FALSE, &Context, &Name8dot3);
}
else {
RtlOemStringToCountedUnicodeString(&Name8dot3, &OemName, FALSE);
}
}


I will appreciate any comments on this subject.

Thanks in advance.
Leonid.

Comments

  • john_8998john_8998 Member Posts: 2

    Also, it seems NTFS algo for shortname creation is somewhat different from RtlGenerate8dot3Name. In the case of file extension longer than 3 chars, RtlGenerate8dot3Name tend to put a "~" (tilde) in the extension also, wheres the NTFS does not.

  • Scott_Noone_(OSR)Scott_Noone_(OSR) Administrator Posts: 3,465

    19 year old post...Start a new discussion if you have a question.

    -scott
    OSR

This discussion has been closed.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 24 January 2022 Live, Online
Internals & Software Drivers 7 February 2022 Live, Online
Kernel Debugging 21 March 2022 Live, Online
Developing Minifilters 23 May 2022 Live, Online