Ignore:
Timestamp:
Apr 15, 2000, 12:35:29 AM (25 years ago)
Author:
sandervl
Message:

GetFileAttributes, pe loader & command line fixes

File:
1 edited

Legend:

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

    r3059 r3375  
    1 /* $Id: winimagebase.cpp,v 1.10 2000-03-09 19:03:22 sandervl Exp $ */
     1/* $Id: winimagebase.cpp,v 1.11 2000-04-14 22:35:28 sandervl Exp $ */
    22
    33/*
     
    133133//******************************************************************************
    134134//******************************************************************************
     135void Win32ImageBase::findDll(char *szFileName, char *szFullName, int cchFullFileName)
     136{
     137 char   modname[CCHMAXPATH];
     138 HFILE  dllfile;
     139 char  *imagepath;
     140
     141  strcpy(szFullName, szFileName);
     142  strupr(szFullName);
     143  if(!strchr(szFullName, (int)'.')) {
     144        strcat(szFullName,".DLL");
     145  }
     146  //search order:
     147  //1) current dir
     148  //2) exe dir
     149  //3) windows system dir (kernel32 path)
     150  //4) path
     151  dllfile = OSLibDosOpen(szFullName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
     152  if(dllfile == NULL) {//search in libpath for dll
     153        strcpy(modname, WinExe->getFullPath());
     154        //remove file name from full path
     155        imagepath = modname + strlen(modname) - 1;
     156        while(*imagepath != '\\') imagepath--;
     157        imagepath[1] = 0;
     158        strcat(modname, szFileName);
     159        dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
     160        if(dllfile == NULL) {
     161                strcpy(modname, kernel32Path);
     162                strcat(modname, szFileName);
     163                dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
     164                if(dllfile == NULL) {
     165                        OSLibDosSearchPath(OSLIB_SEARCHENV, "PATH", modname, szFullName, cchFullFileName);
     166                }
     167                else {
     168                        strcpy(szFullName, modname);
     169                        OSLibDosClose(dllfile);
     170                }
     171        }
     172        else {
     173                strcpy(szFullName, modname);
     174                OSLibDosClose(dllfile);
     175        }
     176  }
     177  else  OSLibDosClose(dllfile);
     178}
     179//******************************************************************************
     180//******************************************************************************
    135181BOOL Win32ImageBase::isPEImage(char *szFileName)
    136182{
    137  char   modname[CCHMAXPATH];
    138183 char   filename[CCHMAXPATH];
    139184 char  *syspath;
     
    148193 int    nSections, i;
    149194
    150   strcpy(filename, szFileName);
    151   strupr(filename);
    152   if(!strchr(filename, (int)'.')) {
    153     strcat(filename,".DLL");
    154   }
    155   dllfile = OSLibDosOpen(filename, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    156   if(dllfile == NULL) {//search in libpath for dll
    157         strcpy(modname, kernel32Path);
    158         strcat(modname, filename);
    159         dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    160         if(dllfile == NULL) {
    161                 OSLibDosSearchPath(OSLIB_SEARCHENV, "PATH", filename, filename, sizeof(filename));
    162         }
    163         else {
    164                 strcpy(filename, modname);
    165                 OSLibDosClose(dllfile);
    166         }
    167   }
    168   else  OSLibDosClose(dllfile);
    169 
     195  findDll(szFileName, filename, sizeof(filename));
    170196  rc = DosOpen(filename,                       /* File path name */
    171            &win32handle,                       /* File handle */
     197               &win32handle,                   /* File handle */
    172198               &ulAction,                      /* Action taken */
    173199               0L,                             /* File primary allocation */
Note: See TracChangeset for help on using the changeset viewer.