Changeset 13952


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

GetFileAttributes, pe loader & command line fixes

Location:
tags/trunk/src/kernel32
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified tags/trunk/src/kernel32/Fileio.cpp

    r13846 r13952  
    1 /* $Id: Fileio.cpp,v 1.27 2000-03-29 15:17:27 cbratschi Exp $ */
     1/* $Id: Fileio.cpp,v 1.28 2000-04-14 22:35:25 sandervl Exp $ */
    22
    33/*
     
    398398    if((NULL!=lpszFileName) && strlen(lpszFileName)==2 && lpszFileName[1] == ':')
    399399    {
    400          char szDrive[4];
    401          szDrive[0] = lpszFileName[0];
    402          szDrive[1] = lpszFileName[1];
    403          szDrive[2] = '\\';
    404          szDrive[3] = 0x00;
    405          rc = O32_GetFileAttributes((LPSTR)szDrive);
     400        char szDrive[4];
     401        szDrive[0] = lpszFileName[0];
     402        szDrive[1] = lpszFileName[1];
     403        szDrive[2] = '\\';
     404        szDrive[3] = 0x00;
     405        rc = O32_GetFileAttributes((LPSTR)szDrive);
    406406    }
    407     else rc = O32_GetFileAttributes((LPSTR)lpszFileName);
     407    else {
     408        rc = O32_GetFileAttributes((LPSTR)lpszFileName);
     409        if(rc == -1 && lpszFileName[strlen(lpszFileName)-1] != '\\') {
     410                char *filename = (char *)alloca(strlen(lpszFileName)+1);
     411                strcpy(filename, lpszFileName);
     412                strcat(filename, "\\");
     413                rc = O32_GetFileAttributes((LPSTR)filename);
     414        }
     415    }
    408416
    409417#if 0 // need more tests, maybe there is also a better way to hide simulated b:
  • TabularUnified tags/trunk/src/kernel32/directory.cpp

    r13924 r13952  
    1 /* $Id: directory.cpp,v 1.18 2000-04-07 19:43:46 sandervl Exp $ */
     1/* $Id: directory.cpp,v 1.19 2000-04-14 22:35:26 sandervl Exp $ */
    22
    33/*
     
    1313 *
    1414 * Copyright 1995 Alexandre Julliard
     15 *
     16 * TODO: System/window directories should be created by install program!
    1517 *
    1618 * Project Odin Software License can be found in LICENSE.TXT
     
    229231                                       UINT,uSize)
    230232{
    231   LPSTR lpstrEnv = getenv("WIN32.DIR.SYSTEM");          /* query environment */
    232   CHAR  buf[255];
    233 
    234   if (lpstrEnv != NULL)
    235   {
    236         if(lpBuffer)
    237                 lstrcpynA(lpBuffer, lpstrEnv, uSize);
    238 
    239         return (lstrlenA(lpstrEnv));                /* return number of copies bytes */
    240   }
    241   else
    242   {
    243     int len;
    244 
    245     len = ODIN_PROFILE_GetOdinIniString(ODINDIRECTORIES,"SYSTEM","",buf,sizeof(buf));
    246     if (len > 2) {
    247         if(buf[len-1] == '\\') {
    248                 buf[len-1] = 0;
    249                 len--;
    250         }
    251         if(lpBuffer)
    252                 lstrcpynA(lpBuffer, buf, uSize);
    253 
    254         return len;
    255     }
    256     else {//SvL: Use path of kernel32.dll instead of calling Open32 api (which returns \OS2\SYSTEM)
    257         lstrcpynA(buf, kernel32Path, sizeof(buf)-1);
     233  char buf[255];
     234  int  len;
     235
     236        lstrcpynA(buf, kernel32Path, sizeof(buf)-1);
    258237        len = lstrlenA(buf);;
    259238        if(buf[len-1] == '\\') {
     
    264243                lstrcpynA(lpBuffer, buf, uSize);
    265244        return len;
    266     }
    267   }
    268245}
    269246
     
    315292                                        UINT,uSize)
    316293{
    317   LPSTR lpstrEnv = getenv("WIN32.DIR.WINDOWS");         /* query environment */
     294  static int fWindirExists = FALSE;
    318295  CHAR  buf[255];
    319 
    320   if (lpstrEnv != NULL)
    321   {
    322         if(lpBuffer)
    323                 lstrcpynA(lpBuffer, lpstrEnv, uSize);
    324 
    325         return (lstrlenA(lpstrEnv));                /* return number of copies bytes */
    326   }
    327   else
    328   {
    329     int len;
    330 
    331     len = ODIN_PROFILE_GetOdinIniString(ODINDIRECTORIES,"WINDOWS","",buf,sizeof(buf));
    332     if (len > 2) {
    333         if(buf[len-1] == '\\') {
    334                 buf[len-1] = 0;
    335                 len--;
    336         }
    337         if(lpBuffer)
    338                 lstrcpynA(lpBuffer, buf, uSize);
    339 
    340         return len;
    341     }
    342     else {//SvL: Use path of kernel32.dll instead of calling Open32 api (which returns \OS2\SYSTEM)
    343 
     296  int   len;
     297 
     298        //SvL: Use path of kernel32.dll instead of calling Open32 api (which returns \OS2\SYSTEM)
    344299        lstrcpynA(buf, kernel32Path, sizeof(buf)-1);
    345300        strcat(buf, "WIN");
    346         O32_CreateDirectory(buf, NULL);
     301        if(!fWindirExists) {
     302                O32_CreateDirectory(buf, NULL);
     303                fWindirExists = TRUE;
     304        }
    347305
    348306        len = lstrlenA(buf);;
     
    354312                lstrcpynA(lpBuffer, buf, uSize);
    355313        return len;
    356     }
    357   }
    358314}
    359315
  • TabularUnified tags/trunk/src/kernel32/exceptions.cpp

    r13751 r13952  
    1 /* $Id: exceptions.cpp,v 1.38 2000-03-20 20:32:40 sandervl Exp $ */
     1/* $Id: exceptions.cpp,v 1.39 2000-04-14 22:35:27 sandervl Exp $ */
    22
    33/*
     
    967967                        pCtxRec->ctx_stack[0].signexp = 0;
    968968                }
    969         dprintf(("KERNEL32: OS2ExceptionHandler: fix and continue\n"));
     969                dprintf(("KERNEL32: OS2ExceptionHandler: fix and continue\n"));
    970970                return (XCPT_CONTINUE_EXECUTION);
    971971        }
    972972        else
    973973        {
    974           dprintf(("KERNEL32: OS2ExceptionHandler: continue search\n"));
    975           return (XCPT_CONTINUE_SEARCH);
     974                dprintf(("KERNEL32: OS2ExceptionHandler: continue search\n"));
     975                return (XCPT_CONTINUE_SEARCH);
    976976        }
    977977
  • TabularUnified tags/trunk/src/kernel32/initterm.cpp

    r13707 r13952  
    1 /* $Id: initterm.cpp,v 1.39 2000-03-16 19:20:39 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.40 2000-04-14 22:35:27 sandervl Exp $ */
    22
    33/*
     
    133133            //     the reference count here
    134134            Win32DllBase *module = Win32DllBase::findModule(hModule);
    135             if(module && !fPe2Lx) {
     135            if(module) {
    136136                module->AddRef();
    137137                module->DisableUnload();
  • TabularUnified tags/trunk/src/kernel32/kernel32.def

    r13858 r13952  
    1 ; $Id: kernel32.def,v 1.78 2000-03-30 15:37:14 cbratschi Exp $
     1; $Id: kernel32.def,v 1.79 2000-04-14 22:35:26 sandervl Exp $
    22
    33;Created by BLAST for IBM's compiler
     
    972972    _RegisterPe2LxDll@12                                          @1209
    973973
    974     _CreateWin32PeLdrExe@8                                        @1236
     974    _CreateWin32PeLdrExe@12                                       @1236
    975975
    976976    _RegisterLxExe@8                                              @1237
  • TabularUnified tags/trunk/src/kernel32/windlllx.cpp

    r13638 r13952  
    1 /* $Id: windlllx.cpp,v 1.9 2000-03-09 19:03:21 sandervl Exp $ */
     1/* $Id: windlllx.cpp,v 1.10 2000-04-14 22:35:27 sandervl Exp $ */
    22
    33/*
     
    3030#include <windlllx.h>
    3131#include "winexepe2lx.h"
     32#include "winexepeldr.h"
    3233#include <odinlx.h>
    3334#include "oslibmisc.h"
     
    6061        return FALSE;
    6162   }
    62    if(fPe2Lx) {
     63   if(!fPeLoader) {
    6364        windll->AddRef();
    6465
     
    121122   //Don't proceed for pe2lx/win32k (os/2 dll unload dependency bug)
    122123   //Don't do it either after ExitProcess has been called
    123    if(fPe2Lx || WinExe == NULL)
     124   if(!fPeLoader || WinExe == NULL)
    124125        return TRUE;
    125126
     
    194195#endif
    195196
    196   if(fPe2Lx)
     197  if(!fPeLoader)
    197198        return ret;
    198199
  • TabularUnified tags/trunk/src/kernel32/winexelx.cpp

    r13382 r13952  
    1 /* $Id: winexelx.cpp,v 1.5 2000-02-16 14:22:11 sandervl Exp $ */
     1/* $Id: winexelx.cpp,v 1.6 2000-04-14 22:35:27 sandervl Exp $ */
    22
    33/*
     
    6666
    6767  if(winexe) {
    68         winexe->setCommandLine(ppib->pib_pchcmd);
     68        char *cmdline;
     69        int   cmdlen = strlen(ppib->pib_pchcmd);
     70
     71        cmdlen += strlen(ppib->pib_pchcmd+cmdlen+1);
     72        cmdline = (char *)malloc(cmdlen+2); //term. 0 + space
     73        strcpy(cmdline, ppib->pib_pchcmd);
     74        strcat(cmdline, " ");
     75        strcat(cmdline, ppib->pib_pchcmd+strlen(ppib->pib_pchcmd)+1);
     76        winexe->setCommandLine(cmdline);
     77        free(cmdline);
    6978        winexe->setEntryPoint((ULONG)EntryPoint);
    7079        winexe->start();
  • TabularUnified tags/trunk/src/kernel32/winexepe2lx.cpp

    r13638 r13952  
    1 /* $Id: winexepe2lx.cpp,v 1.5 2000-03-09 19:03:22 sandervl Exp $ */
     1/* $Id: winexepe2lx.cpp,v 1.6 2000-04-14 22:35:27 sandervl Exp $ */
    22
    33/*
     
    3737
    3838
    39 BOOL fPe2Lx = FALSE;
    40 
    4139/**
    4240 * Register a Pe2Lx Executable module.
     
    5856{
    5957    Win32Pe2LxExe *pWinPe2LxExe;
    60 
    61     fPe2Lx = TRUE;
    6258
    6359    /* I/O init. */
  • TabularUnified tags/trunk/src/kernel32/winexepe2lx.h

    r13638 r13952  
    1 /* $Id: winexepe2lx.h,v 1.1 2000-03-09 19:03:22 sandervl Exp $ */
     1/* $Id: winexepe2lx.h,v 1.2 2000-04-14 22:35:28 sandervl Exp $ */
    22
    33/*
     
    3232};
    3333
    34 extern BOOL fPe2Lx;
    35 
    3634#endif //__WINEXEPE2LX_H__
  • TabularUnified tags/trunk/src/kernel32/winexepeldr.cpp

    r13382 r13952  
    1 /* $Id: winexepeldr.cpp,v 1.7 2000-02-16 14:22:11 sandervl Exp $ */
     1/* $Id: winexepeldr.cpp,v 1.8 2000-04-14 22:35:28 sandervl Exp $ */
    22
    33/*
     
    4242extern char szErrorModule[];
    4343
     44BOOL fPeLoader = FALSE;
     45
    4446//******************************************************************************
    4547//Called by ring 3 pe loader to create win32 executable
    4648//******************************************************************************
    47 BOOL WIN32API CreateWin32PeLdrExe(char *szFileName, ULONG reservedMem)
     49BOOL WIN32API CreateWin32PeLdrExe(char *szFileName, char *szCmdLine, ULONG reservedMem)
    4850{
    4951 APIRET  rc;
     
    5254 WINEXCEPTION_FRAME exceptFrame;
    5355 Win32PeLdrExe *WinExe;
    54  char  *szCmdLine;
     56 char   *szFullCmdLine;
     57
     58  fPeLoader = TRUE;
    5559
    5660  WinExe = new Win32PeLdrExe(szFileName);
     
    6266        return FALSE;
    6367  }
    64   //TODO: Create full path for executable?
    65   szCmdLine = ppib->pib_pchcmd + strlen(ppib->pib_pchcmd) + 1;
    66   while(*szCmdLine != 0 && *szCmdLine == ' ')
    67     szCmdLine++;
    6868
    69   WinExe->setCommandLine(szCmdLine);
    70   dprintf(("Cmd line: %s", szCmdLine));
     69  szFullCmdLine = (char *)malloc(strlen(szFileName) + 1 + strlen(szCmdLine) + 1);
     70  strcpy(szFullCmdLine, szFileName);
     71  strcat(szFullCmdLine, " ");
     72  strcat(szFullCmdLine, szCmdLine);
     73  WinExe->setCommandLine(szFullCmdLine);
     74  dprintf(("Cmd line: %s", szFullCmdLine));
     75  free(szFullCmdLine);
    7176
    7277  if(getenv("WIN32_IOPL2")) {
  • TabularUnified tags/trunk/src/kernel32/winexepeldr.h

    r13653 r13952  
    1 /* $Id: winexepeldr.h,v 1.1 2000-03-10 16:12:02 sandervl Exp $ */
     1/* $Id: winexepeldr.h,v 1.2 2000-04-14 22:35:28 sandervl Exp $ */
    22
    33/*
     
    1616#include <winimagepeldr.h>
    1717
    18 typedef BOOL (* WIN32API WIN32CTOR)(char *, ULONG);
     18typedef BOOL (* WIN32API WIN32CTOR)(char *, char *, ULONG);
    1919
    2020//Class for executables run by the ring 3 PE loader
     
    3939extern char szInteralErrorMsg[];
    4040
     41extern BOOL fPeLoader;
     42
    4143#endif //__WINEXEPELDR_H__
  • TabularUnified tags/trunk/src/kernel32/winimagebase.cpp

    r13638 r13952  
    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 */
  • TabularUnified tags/trunk/src/kernel32/winimagebase.h

    r13638 r13952  
    1 /* $Id: winimagebase.h,v 1.1 2000-03-09 19:03:22 sandervl Exp $ */
     1/* $Id: winimagebase.h,v 1.2 2000-04-14 22:35:28 sandervl Exp $ */
    22
    33/*
     
    8282
    8383static  BOOL  isPEImage(char *szFileName);
     84static  void  findDll(char *szFileName, char *szFullName, int cchFullFileName);
    8485
    8586        void  setEntryPoint(ULONG startAddress) { entryPoint = startAddress; };
  • TabularUnified tags/trunk/src/kernel32/winimagepeldr.cpp

    r13836 r13952  
    1 /* $Id: winimagepeldr.cpp,v 1.38 2000-03-28 17:11:50 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.39 2000-04-14 22:35:28 sandervl Exp $ */
    22
    33/*
     
    129129  }
    130130  else {
    131         if(!strchr(szFileName, '.')) {
    132                 strcat(szFileName,".DLL");
    133         }
    134         dllfile = OSLibDosOpen(szFileName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    135         if(dllfile == NULL) {//search in libpath for dll
    136                 strcpy(szModule, kernel32Path);
    137                 strcat(szModule, szFileName);
    138                 strcpy(szFileName, szModule);
    139 
    140                 dllfile = OSLibDosOpen(szFileName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    141                 if(dllfile == NULL) {
    142                         if(!strstr(szFileName, ".DLL")) {
    143                                 strcat(szFileName,".DLL");
    144                                 dllfile = OSLibDosOpen(szFileName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    145                                 if(dllfile == NULL) {
    146                                         strcpy(szModule, kernel32Path);
    147                                         strcat(szModule, szFileName);
    148                                         strcpy(szFileName, szModule);
    149                                 }
    150                                 else    OSLibDosClose(dllfile);
    151                         }
    152                         dllfile = OSLibDosOpen(szFileName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
    153                         if(dllfile == NULL) {
    154                                 strcpy(szFileName, pszFileName);
    155                                 strupr(szFileName);
    156                                 OSLibDosSearchPath(OSLIB_SEARCHENV, "PATH", szFileName, szFileName, sizeof(szFileName));
    157                         }
    158                         else    OSLibDosClose(dllfile);
    159                 }
    160                 else    OSLibDosClose(dllfile);
    161         }
    162         else    OSLibDosClose(dllfile);
     131        findDll(szFileName, szModule, sizeof(szModule));
     132        strcpy(szFileName, szModule);
    163133  }
    164134  strcpy(szModule, OSLibStripPath(szFileName));
  • TabularUnified tags/trunk/src/kernel32/wprocess.cpp

    r13739 r13952  
    1 /* $Id: wprocess.cpp,v 1.75 2000-03-18 19:49:44 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.76 2000-04-14 22:35:29 sandervl Exp $ */
    22
    33/*
     
    2323#include "winexebase.h"
    2424#include "windllpeldr.h"
    25 #include "winexepe2lx.h"
     25#include "winexepeldr.h"
    2626#include "winfakepeldr.h"
    2727#include <vmutex.h>
     
    423423    module = Win32DllBase::findModule((LPSTR)lpszLibFile);
    424424    if(module) {
    425         if(module->isLxDll() && !module->isLoaded() && !fPe2Lx) {
     425        if(module->isLxDll() && !module->isLoaded() && fPeLoader) {
    426426            //can happen with i.e. wininet
    427427            //wininet depends on wsock32; when the app loads wsock32 afterwards
     
    449449    {
    450450        module = Win32DllBase::findModule(hDll);
    451         if(module && module->isLxDll() && !fPe2Lx) {
     451        if(module && module->isLxDll() && fPeLoader) {
    452452            module->setLoadLibrary();
    453453            module->AddRef();
Note: See TracChangeset for help on using the changeset viewer.