short file names creation

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.

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.

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