Changeset 22016


Ignore:
Timestamp:
Sep 17, 2012, 4:46:24 PM (8 years ago)
Author:
dmik
Message:

pe: Don't add .exe if there is an extension or path in the file name spec.

Some Win32 applications (e.g. installers) start executables which have
custom extensions using the full path. Adding .exe in this case obviously
breaks them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/peldr/pe.c

    r21943 r22016  
    199199        win32cmdline = pszTemp;
    200200
    201         // add the .EXE extension if missing
    202         int i = strlen(exeName);
    203         if (i < 4 || !((exeName[i-1] == 'E' || exeName[i-1] == 'e') &&
    204                        (exeName[i-2] == 'X' || exeName[i-2] == 'x') &&
    205                        (exeName[i-3] == 'E' || exeName[i-3] == 'e') &&
    206                        exeName[i-4] == '.'))
    207         {
    208             if (i + 4 < CCHMAXPATH)
    209                 strcat(exeName, ".exe");
     201        // add the .EXE extension if missing (only if there's no path)
     202        if (*str_find_char(exeName, '.') == '\0' &&
     203            *str_find_char(exeName, '\\') == '\0' &&
     204            *str_find_char(exeName, '/') == '\0')
     205        {
     206            int i = strlen(exeName);
     207            if (i < 4 || !((exeName[i-1] == 'E' || exeName[i-1] == 'e') &&
     208                           (exeName[i-2] == 'X' || exeName[i-2] == 'x') &&
     209                           (exeName[i-3] == 'E' || exeName[i-3] == 'e') &&
     210                           exeName[i-4] == '.'))
     211            {
     212                if (i + 4 < CCHMAXPATH)
     213                    strcat(exeName, ".exe");
     214            }
    210215        }
    211216
Note: See TracChangeset for help on using the changeset viewer.