Ignore:
Timestamp:
Oct 23, 2000, 3:42:47 PM (25 years ago)
Author:
sandervl
Message:

Vio fix for high memory + fixes&updates for dll name lookup with extension

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/winimagebase.cpp

    r4474 r4523  
    1 /* $Id: winimagebase.cpp,v 1.29 2000-10-10 17:14:07 sandervl Exp $ */
     1/* $Id: winimagebase.cpp,v 1.30 2000-10-23 13:42:44 sandervl Exp $ */
    22
    33/*
     
    6464    name = strrchr(szFileName, '\\')+1;
    6565    strcpy(szModule, name);
    66 
    67     char *dot = strrchr(szModule, '.');
    68     if(dot)
    69         *dot = 0;
    7066  }
    7167  else {
     
    154150 char  *imagepath;
    155151
    156   strcpy(szFullName, szFileName);
    157   strupr(szFullName);
    158   if(!strchr(szFullName, (int)'.')) {
    159         strcat(szFullName,".DLL");
    160   }
    161 
    162   //search order:
    163   //1) exe dir
    164   //2) current dir
    165   //3) windows system dir (kernel32 path)
    166   //4) windows dir
    167   //5) path
    168   if(WinExe) {
    169     strcpy(modname, WinExe->getFullPath());
    170     //remove file name from full path
    171     imagepath = modname + strlen(modname) - 1;
    172     while(*imagepath != '\\') imagepath--;
    173     imagepath[1] = 0;
    174     strcat(modname, szFullName);
    175     dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    176   }
    177   if(dllfile == NULL) {
    178     strcpy(modname, szFullName);
    179     dllfile = OSLibDosOpen(szFullName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    180     if(dllfile == NULL) {
     152    strcpy(szFullName, szFileName);
     153    strupr(szFullName);
     154    if(!strchr(szFullName, (int)'.')) {
     155        strcat(szFullName, DLL_EXTENSION);
     156    }
     157
     158    //search order:
     159    //1) exe dir
     160    //2) current dir
     161    //3) windows system dir (kernel32 path)
     162    //4) windows dir
     163    //5) path
     164    if(WinExe) {
     165        strcpy(modname, WinExe->getFullPath());
     166        //remove file name from full path
     167        imagepath = modname + strlen(modname) - 1;
     168        while(*imagepath != '\\')
     169            imagepath--;
     170        imagepath[1] = 0;
     171        strcat(modname, szFullName);
     172        dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
     173    }
     174    if(dllfile == NULL)
     175    {
     176        strcpy(modname, szFullName);
     177        dllfile = OSLibDosOpen(szFullName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
     178        if(dllfile == NULL)
     179        {
    181180            strcpy(modname, InternalGetSystemDirectoryA());
    182         strcat(modname, "\\");
     181            strcat(modname, "\\");
    183182            strcat(modname, szFullName);
    184         dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    185         if(dllfile == NULL) {
    186             strcpy(modname, InternalGetWindowsDirectoryA());
    187             strcat(modname, "\\");
     183            dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
     184            if(dllfile == NULL)
     185            {
     186                strcpy(modname, InternalGetWindowsDirectoryA());
     187                strcat(modname, "\\");
    188188                strcat(modname, szFullName);
    189             dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    190             if(dllfile == NULL) {
    191                 if(OSLibDosSearchPath(OSLIB_SEARCHENV, "PATH", szFullName, modname, sizeof(modname)) == 0) {
    192                     return FALSE;
     189                dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
     190                if(dllfile == NULL) {
     191                    if(OSLibDosSearchPath(OSLIB_SEARCHENV, "PATH", szFullName, modname, sizeof(modname)) == 0)
     192                        return FALSE;
    193193                }
    194194            }
    195195        }
    196196    }
    197   }
    198   strcpy(szFullName, modname);
    199   if(dllfile) OSLibDosClose(dllfile);
    200   return TRUE;
     197    strcpy(szFullName, modname);
     198    if(dllfile) OSLibDosClose(dllfile);
     199    return TRUE;
    201200}
    202201
     
    254253  rc = DosRead(win32handle, pdoshdr, sizeof(IMAGE_DOS_HEADER), &ulRead);
    255254  if(rc != NO_ERROR || ulRead != sizeof(IMAGE_DOS_HEADER)) {
    256     free(pdoshdr);
     255        free(pdoshdr);
    257256        DosClose(win32handle);                /* Close the file */
    258257        return ERROR_INVALID_EXE_SIGNATURE_W;
    259258  }
    260259  if(pdoshdr->e_magic != IMAGE_DOS_SIGNATURE) {
    261     free(pdoshdr);
     260        free(pdoshdr);
    262261        DosClose(win32handle);                /* Close the file */
    263262        return ERROR_INVALID_EXE_SIGNATURE_W;
     
    294293  }
    295294  if(Characteristics) {
    296         *Characteristics = fh.Characteristics;
     295        *Characteristics = fh.Characteristics;
    297296  }
    298297  DosClose(win32handle);
     
    346345 * @remark      Just a clarification:
    347346 *              A module name is the filename of a executable image without
    348  *              path and without extention.
     347 *              path, but *with* extention.
    349348 */
    350349BOOL Win32ImageBase::matchModName(const char *pszFilename) const
     
    365364           )
    366365    {
    367         if (ch == '.' && pszModNameEnd == NULL)
    368             pszModNameEnd = pszModName;
    369366        pszModName--;
    370367    }
    371368    pszModName++;
    372    
     369
    373370    /** @sketch
    374371     * Compare the names caseinsensitivly.
    375372     */
    376     if (pszModNameEnd)
    377         return strnicmp(pszModName, szModule, pszModNameEnd - pszModName) == 0;
    378373    return stricmp(pszModName, szModule) == 0;
    379374}
Note: See TracChangeset for help on using the changeset viewer.