Changeset 3005 for trunk/src/kernel32


Ignore:
Timestamp:
Mar 4, 2000, 8:52:37 PM (25 years ago)
Author:
sandervl
Message:

DosOpen (file handle error) & dll destruction bugfixes

Location:
trunk/src/kernel32
Files:
7 edited

Legend:

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

    r2973 r3005  
    1 /* $Id: directory.cpp,v 1.16 2000-03-02 19:17:20 sandervl Exp $ */
     1/* $Id: directory.cpp,v 1.17 2000-03-04 19:52:35 sandervl Exp $ */
    22
    33/*
     
    55 *
    66 * Copyright 1998 Sander van Leeuwen
     7 *
     8 * NOTE: Directory creation has to be done in install program (odin\win)
    79 *
    810 * Parts based on Wine code (991031) (files\directory.c)
  • trunk/src/kernel32/hmdevio.cpp

    r2952 r3005  
    1 /* $Id: hmdevio.cpp,v 1.3 2000-02-29 22:44:02 sandervl Exp $ */
     1/* $Id: hmdevio.cpp,v 1.4 2000-03-04 19:52:36 sandervl Exp $ */
    22
    33/*
     
    114114  }
    115115
     116tryopen:
    116117  rc = DosOpen( szOS2Name,                        /* File path name */
    117118                &hfFileHandle,                  /* File handle */
     
    123124                0L);                            /* No extended attribute */
    124125
     126  if(rc == ERROR_TOO_MANY_OPEN_FILES) {
     127   ULONG CurMaxFH;
     128   LONG  ReqCount = 32;
     129
     130        rc = DosSetRelMaxFH(&ReqCount, &CurMaxFH);
     131        if(rc) {
     132                dprintf(("DosSetRelMaxFH returned %d", rc));
     133                return rc;
     134        }
     135        dprintf(("DosOpen failed -> increased nr open files to %d", CurMaxFH));
     136        goto tryopen;
     137  }
     138
    125139  dprintf(("DosOpen %s returned %d\n", szOS2Name, rc));
    126140
  • trunk/src/kernel32/initsystem.cpp

    r2984 r3005  
    1 /* $Id: initsystem.cpp,v 1.6 2000-03-03 11:15:57 sandervl Exp $ */
     1/* $Id: initsystem.cpp,v 1.7 2000-03-04 19:52:36 sandervl Exp $ */
    22/*
    33 * Odin system initialization (registry & directories)
     
    113113//   if(RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hkey) != ERROR_SUCCESS)
    114114//   {
    115         strcpy(shellpath, InternalGetSystemDirectoryA());
    116         strcat(shellpath, "\\WIN\\Favorites");
     115        strcpy(shellpath, InternalGetWindowsDirectoryA());
     116        strcat(shellpath, "\\Favorites");
    117117        CreateDirectoryA(shellpath, NULL);
    118118        RegSetValueExA(hkey,"Favorites",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    119         strcpy(shellpath, InternalGetSystemDirectoryA());
    120         strcat(shellpath, "\\WIN\\Programs\\Startup");
     119        strcpy(shellpath, InternalGetWindowsDirectoryA());
     120        strcat(shellpath, "\\Programs\\Startup");
    121121        CreateDirectoryA(shellpath, NULL);
    122122        RegSetValueExA(hkey,"Startup",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    123         strcpy(shellpath, InternalGetSystemDirectoryA());
    124         strcat(shellpath, "\\WIN\\Desktop");
     123        strcpy(shellpath, InternalGetWindowsDirectoryA());
     124        strcat(shellpath, "\\Desktop");
    125125        CreateDirectoryA(shellpath, NULL);
    126126        RegSetValueExA(hkey,"Desktop",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    127         strcpy(shellpath, InternalGetSystemDirectoryA());
    128         strcat(shellpath, "\\WIN\\Start Menu\\Programs");
     127        strcpy(shellpath, InternalGetWindowsDirectoryA());
     128        strcat(shellpath, "\\Start Menu\\Programs");
    129129        CreateDirectoryA(shellpath, NULL);
    130130        RegSetValueExA(hkey,"Programs",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    131         strcpy(shellpath, InternalGetSystemDirectoryA());
    132         strcat(shellpath, "\\WIN\\Fonts");
     131        strcpy(shellpath, InternalGetWindowsDirectoryA());
     132        strcat(shellpath, "\\Fonts");
    133133        CreateDirectoryA(shellpath, NULL);
    134134        RegSetValueExA(hkey,"Fonts",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    135         strcpy(shellpath, InternalGetSystemDirectoryA());
    136         strcat(shellpath, "\\WIN\\SendTo");
     135        strcpy(shellpath, InternalGetWindowsDirectoryA());
     136        strcat(shellpath, "\\SendTo");
    137137        CreateDirectoryA(shellpath, NULL);
    138138        RegSetValueExA(hkey,"SendTo",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    139         strcpy(shellpath, InternalGetSystemDirectoryA());
    140         strcat(shellpath, "\\WIN\\Start Menu");
     139        strcpy(shellpath, InternalGetWindowsDirectoryA());
     140        strcat(shellpath, "\\Start Menu");
    141141        CreateDirectoryA(shellpath, NULL);
    142142        RegSetValueExA(hkey,"Start Menu",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    143         strcpy(shellpath, InternalGetSystemDirectoryA());
    144         strcat(shellpath, "\\WIN\\ShellNew");
     143        strcpy(shellpath, InternalGetWindowsDirectoryA());
     144        strcat(shellpath, "\\ShellNew");
    145145        CreateDirectoryA(shellpath, NULL);
    146146        RegSetValueExA(hkey,"Templates",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    147         strcpy(shellpath, InternalGetSystemDirectoryA());
    148         strcat(shellpath, "\\WIN\\Recent");
     147        strcpy(shellpath, InternalGetWindowsDirectoryA());
     148        strcat(shellpath, "\\Recent");
    149149        CreateDirectoryA(shellpath, NULL);
    150150        RegSetValueExA(hkey,"Recent",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    151         strcpy(shellpath, InternalGetSystemDirectoryA());
    152         strcat(shellpath, "\\WIN\\NetHood");
     151        strcpy(shellpath, InternalGetWindowsDirectoryA());
     152        strcat(shellpath, "\\NetHood");
    153153        CreateDirectoryA(shellpath, NULL);
    154154        RegSetValueExA(hkey,"NetHood",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
    155         strcpy(shellpath, InternalGetSystemDirectoryA());
    156         strcat(shellpath, "\\WIN\\My Documents");
     155        strcpy(shellpath, InternalGetWindowsDirectoryA());
     156        strcat(shellpath, "\\My Documents");
    157157        CreateDirectoryA(shellpath, NULL);
    158158        RegSetValueExA(hkey,"Personal",0,REG_SZ, (LPBYTE)shellpath, strlen(shellpath)+1);
  • trunk/src/kernel32/windllbase.cpp

    r2802 r3005  
    1 /* $Id: windllbase.cpp,v 1.9 2000-02-16 14:22:11 sandervl Exp $ */
     1/* $Id: windllbase.cpp,v 1.10 2000-03-04 19:52:36 sandervl Exp $ */
    22
    33/*
     
    4949                 : Win32ImageBase(hinstance),
    5050                   referenced(0), fSkipEntryCalls(FALSE),
    51                    fAttachedToProcess(FALSE), fUnloaded(FALSE)
     51                   fAttachedToProcess(FALSE), fUnloaded(FALSE), fDynamicLoad(FALSE)
    5252{
    5353  dllEntryPoint = DllEntryPoint;
     
    9696Win32DllBase::~Win32DllBase()
    9797{
    98  Win32DllBase *dll = head;
    99 
    10098  dprintf(("Win32DllBase::~Win32DllBase %s", szModule));
    10199
     
    110108  }
    111109  else {
     110        Win32DllBase *dll = head;
    112111        while(dll && dll->next != this) {
    113112                dll = dll->next;
     
    294293//******************************************************************************
    295294//******************************************************************************
    296 void Win32DllBase::deleteAll()
    297 {
     295void Win32DllBase::deleteAll(BOOL fDynamicLoad)
     296{
     297 Win32DllBase *dll = Win32DllBase::head, *tmp;
     298
    298299#ifdef DEBUG
    299300  dlllistmutex.enter();
    300   Win32DllBase *dll = head;
    301301
    302302  dprintf(("Win32DllBase::deleteAll: List of loaded dlls:"));
     
    306306  }
    307307  dlllistmutex.leave();
     308  dll = Win32DllBase::head;
    308309#endif
    309310
    310   while(Win32DllBase::head) {
    311         delete Win32DllBase::head;
     311  while(dll) {
     312        if(fDynamicLoad || !dll->fDynamicLoad) {
     313                tmp = dll->next;
     314                dll->Release();
     315                dll = tmp;
     316        }
     317        else    dll = dll->next;
    312318  }
    313319}
  • trunk/src/kernel32/winexebase.cpp

    r2802 r3005  
    1 /* $Id: winexebase.cpp,v 1.5 2000-02-16 14:22:11 sandervl Exp $ */
     1/* $Id: winexebase.cpp,v 1.6 2000-03-04 19:52:36 sandervl Exp $ */
    22
    33/*
     
    5959Win32ExeBase::~Win32ExeBase()
    6060{
     61  //First delete all dlls that were loaded by the exe or dlls
     62  //Then delete all dlls loaded by LoadLibrary (to avoid that we
     63  //delete some dlls before the dll, that loaded it, is destroyed)
    6164  Win32DllBase::deleteAll();
     65  Win32DllBase::deleteAll(TRUE);
     66
    6267  WinExe = NULL;
    6368  if(cmdLineA)
  • trunk/src/kernel32/winimagepeldr.cpp

    r2863 r3005  
    1 /* $Id: winimagepeldr.cpp,v 1.33 2000-02-22 23:53:03 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.34 2000-03-04 19:52:36 sandervl Exp $ */
    22
    33/*
     
    3636#define PRIVATE_LOGGING
    3737#include <misc.h>
    38 #include <win32type.h>
     38#include <win32api.h>
    3939#include <winimagebase.h>
    4040#include <winimagepeldr.h>
     
    569569 APIRET   rc;
    570570
     571  //Round down to nearest page boundary
     572  virtAddress = virtAddress & ~0xFFF;
     573 
    571574  section = findSectionByOS2Addr(virtAddress);
    572575  if(section == NULL) {
     
    14081411                    return(FALSE);
    14091412                }
    1410                 WinDll->AddRef();
    14111413        }
    14121414        dprintf((LOG, "**********************************************************************" ));
     
    15551557
    15561558  if( r != MBID_IGNORE )
    1557      exit(987);
     1559        ExitProcess(987);
    15581560
    15591561  fIgnore = TRUE;
  • trunk/src/kernel32/wprocess.cpp

    r2984 r3005  
    1 /* $Id: wprocess.cpp,v 1.70 2000-03-03 11:16:00 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.71 2000-03-04 19:52:37 sandervl Exp $ */
    22
    33/*
     
    344344//******************************************************************************
    345345//******************************************************************************
    346 static void _System Win32DllExitList(ULONG reason)
    347 {
    348   dprintf(("Win32DllExitList %d\n", reason));
    349 
    350   if(WinExe) {
    351     delete(WinExe);
    352     WinExe = NULL;
    353   }
    354   return;
    355 }
    356 //******************************************************************************
    357 //******************************************************************************
    358346VOID WIN32API ExitProcess(DWORD exitcode)
    359347{
     
    363351  SetOS2ExceptionChain(-1);
    364352
    365   Win32DllExitList(0);
    366 
    367   //Note: Needs to be done after Win32DllExitList (destruction of exe + dll objects)
     353  if(WinExe) {
     354        delete(WinExe);
     355        WinExe = NULL;
     356  }
     357
     358  //Note: Needs to be done after deleting WinExe (destruction of exe + dll objects)
    368359  //Flush and delete all open memory mapped files
    369360  Win32MemMap::deleteAll();
     
    458449            peldrDll->setNoEntryCalls();
    459450        }
     451        //Set flag so this dll doesn't get automatically deleted in ExitProcess
     452        //(the first time); give application the chance to free it first
     453        //If it's not freed, we delete it the 2nd time in ExitProcess
     454        peldrDll->SetDynamicallyLoaded();
    460455
    461456        if(peldrDll->attachProcess() == FALSE) {
Note: See TracChangeset for help on using the changeset viewer.