From b36fd06b702a0ec6e28553935ac18f7c13a2aaf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 27 Apr 2026 19:59:54 +0200 Subject: [PATCH] [MKSHELLLINK] Don't care about the DOS name of PIDL path elements (#8936) Keep the old code just for reference purposes. --- sdk/tools/mkshelllink/mkshelllink.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/sdk/tools/mkshelllink/mkshelllink.c b/sdk/tools/mkshelllink/mkshelllink.c index ed22c1878c1..4380991f40f 100644 --- a/sdk/tools/mkshelllink/mkshelllink.c +++ b/sdk/tools/mkshelllink/mkshelllink.c @@ -170,6 +170,8 @@ typedef struct _ID_LIST_FILE uint16_t uFileDate; uint16_t uFileTime; uint16_t uFileAttribs; + /* Here are coming two strings. The first is the long name. + The second the dos name when needed or just 0x00 */ char szName[0]; } ID_LIST_FILE; @@ -334,10 +336,11 @@ int main(int argc, const char *argv[]) if (Header.Flags & LINK_ID_LIST) { - ID_LIST_FILE IdListFile; ID_LIST_GUID IdListGuid; ID_LIST_DRIVE IdListDrive; - unsigned cbListSize = sizeof(IdListGuid) + sizeof(uint16_t), cchName; + ID_LIST_FILE IdListFile; + unsigned int cbListSize = sizeof(IdListGuid) + sizeof(uint16_t); + unsigned int cchName; const char *pszName = pszTarget; size_t specialPathLen = 0; const struct SPECIALFOLDER *special = get_special_folder(pszTarget); @@ -370,7 +373,11 @@ int main(int argc, const char *argv[]) ++cchName; if (cchName != 1 || pszName[0] != '.') - cbListSize += sizeof(IdListFile) + 2 * (cchName + 1); + { + /* Don't care about the DOS name */ + //cbListSize += sizeof(IdListFile) + 2 * (cchName + 1); + cbListSize += sizeof(IdListFile) + (cchName + 1) + 1; + } if (special && ((pszName+cchName)-pszTarget == specialPathLen)) { @@ -417,16 +424,19 @@ int main(int argc, const char *argv[]) if (cchName != 1 || pszName[0] != '.') { memset(&IdListFile, 0, sizeof(IdListFile)); - IdListFile.Size = sizeof(IdListFile) + 2 * (cchName + 1); + /* Don't care about the DOS name */ + //IdListFile.Size = sizeof(IdListFile) + 2 * (cchName + 1); + IdListFile.Size = sizeof(IdListFile) + (cchName + 1) + 1; if (!pszName[cchName]) IdListFile.Type = PT_VALUE; // File else IdListFile.Type = PT_FOLDER; fwrite(&IdListFile, sizeof(IdListFile), 1, pFile); fwrite(pszName, cchName, 1, pFile); - fputc(0, pFile); - fwrite(pszName, cchName, 1, pFile); - fputc(0, pFile); + fputc(0, pFile); // NUL-terminate + /* Don't care about the DOS name */ + //fwrite(pszName, cchName, 1, pFile); + fputc(0, pFile); // NUL-terminate } pszName += cchName;