Ignore:
Timestamp:
Dec 14, 1999, 8:14:28 PM (26 years ago)
Author:
sandervl
Message:

cmd line fix, mmap fix + EB's string fixes

File:
1 edited

Legend:

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

    r2053 r2077  
    1 /* $Id: wprocess.cpp,v 1.57 1999-12-10 14:06:12 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.58 1999-12-14 19:14:28 sandervl Exp $ */
    22
    33/*
     
    88 *
    99 * NOTE: Even though Odin32 OS/2 apps don't switch FS selectors,
    10  *       we still allocate a TEB to store misc information. 
     10 *       we still allocate a TEB to store misc information.
    1111 *
    1212 * Project Odin Software License can be found in LICENSE.TXT
     
    4646//******************************************************************************
    4747BOOL      fFreeLibrary = FALSE;
    48 BOOL      fIsOS2Image = FALSE;  //TRUE  -> Odin32 OS/2 application (not converted!)
    49                                 //FALSE -> otherwise
     48BOOL      fIsOS2Image = FALSE;  //TRUE  -> Odin32 OS/2 application (not converted!)
     49                            //FALSE -> otherwise
    5050//Process database
    5151PDB       ProcessPDB = {0};
     
    5858{
    5959  if(TIBFlatPtr == NULL)
    60         return 0;
     60    return 0;
    6161
    6262  return (TEB *)*TIBFlatPtr;
     
    7070
    7171  if(TIBFlatPtr == NULL)
    72         return 0;
     72    return 0;
    7373
    7474  winteb = (TEB *)*TIBFlatPtr;
    7575  if(winteb == NULL) {
    76         return NULL;
     76    return NULL;
    7777  }
    7878  thdb = (THDB *)(winteb+1);
     
    9292   //Allocate one dword to store the flat address of our TEB
    9393   if(fMainThread) {
    94         TIBFlatPtr = (DWORD *)OSLibAllocThreadLocalMemory(1);
    95         if(TIBFlatPtr == 0) {
    96                 dprintf(("InitializeTIB: local thread memory alloc failed!!"));
    97                 DebugInt3();
    98                 return NULL;
    99         }
     94    TIBFlatPtr = (DWORD *)OSLibAllocThreadLocalMemory(1);
     95    if(TIBFlatPtr == 0) {
     96        dprintf(("InitializeTIB: local thread memory alloc failed!!"));
     97        DebugInt3();
     98        return NULL;
     99    }
    100100   }
    101101   if(OSLibAllocSel(PAGE_SIZE, &tibsel) == FALSE)
    102102   {
    103         dprintf(("InitializeTIB: selector alloc failed!!"));
    104         DebugInt3();
    105         return NULL;
     103    dprintf(("InitializeTIB: selector alloc failed!!"));
     104    DebugInt3();
     105    return NULL;
    106106   }
    107107   winteb = (TEB *)OSLibSelToFlat(tibsel);
    108108   if(winteb == NULL)
    109109   {
    110         dprintf(("InitializeTIB: DosSelToFlat failed!!"));
    111         DebugInt3();
    112         return NULL;
     110    dprintf(("InitializeTIB: DosSelToFlat failed!!"));
     111    DebugInt3();
     112    return NULL;
    113113   }
    114114   memset(winteb, 0, PAGE_SIZE);
     
    136136   if(OSLibGetPIB(PIB_TASKTYPE) == TASKTYPE_PM)
    137137   {
    138         thdb->flags      = 0;  //todo gui
     138    thdb->flags      = 0;  //todo gui
    139139   }
    140140   else thdb->flags      = 0;  //todo textmode
     
    142142   if(fMainThread)
    143143   {
    144         //todo initialize PDB during process creation
     144    //todo initialize PDB during process creation
    145145        //todo: initialize TLS array if required
    146146        //TLS in executable always TLS index 0?
    147         ProcessTIBSel = tibsel;
    148         ProcessPDB.exit_code       = 0x103; /* STILL_ACTIVE */
    149         ProcessPDB.threads         = 1;
    150         ProcessPDB.running_threads = 1;
    151         ProcessPDB.ring0_threads   = 1;
    152         ProcessPDB.system_heap     = GetProcessHeap();
    153         ProcessPDB.parent          = 0;
    154         ProcessPDB.group           = &ProcessPDB;
    155         ProcessPDB.priority        = 8;  /* Normal */
    156         ProcessPDB.heap            = ProcessPDB.system_heap;  /* will be changed later on */
    157         ProcessPDB.next            = NULL;
    158         ProcessPDB.winver          = 0xffff; /* to be determined */
     147    ProcessTIBSel = tibsel;
     148        ProcessPDB.exit_code       = 0x103; /* STILL_ACTIVE */
     149        ProcessPDB.threads         = 1;
     150        ProcessPDB.running_threads = 1;
     151        ProcessPDB.ring0_threads   = 1;
     152        ProcessPDB.system_heap     = GetProcessHeap();
     153        ProcessPDB.parent          = 0;
     154        ProcessPDB.group           = &ProcessPDB;
     155        ProcessPDB.priority        = 8;  /* Normal */
     156        ProcessPDB.heap            = ProcessPDB.system_heap;  /* will be changed later on */
     157        ProcessPDB.next            = NULL;
     158        ProcessPDB.winver          = 0xffff; /* to be determined */
    159159        ProcessPDB.server_pid      = (void *)GetCurrentProcessId();
    160160
    161         GetSystemTime(&ProcessPDB.creationTime);
     161    GetSystemTime(&ProcessPDB.creationTime);
    162162
    163163        /* Initialize the critical section */
     
    182182   winteb = (TEB *)*TIBFlatPtr;
    183183   if(winteb) {
    184         thdb = (THDB *)(winteb+1);
    185         orgtibsel = thdb->OrgTIBSel;
    186 
    187         //Restore our original FS selector
    188         SetFS(orgtibsel);
    189 
    190         //And free our own
    191         OSLibFreeSel(thdb->teb_sel);
     184    thdb = (THDB *)(winteb+1);
     185    orgtibsel = thdb->OrgTIBSel;
     186
     187    //Restore our original FS selector
     188        SetFS(orgtibsel);
     189
     190        //And free our own
     191        OSLibFreeSel(thdb->teb_sel);
    192192   }
    193193   else dprintf(("Already destroyed TIB"));
     
    214214   //we don't switch FS selectors
    215215   if(fIsOS2Image) {
    216         return;
     216    return;
    217217   }
    218218
    219219   winteb = (TEB *)*TIBFlatPtr;
    220220   if(winteb) {
    221         thdb = (THDB *)(winteb+1);
    222         orgtibsel = thdb->OrgTIBSel;
    223 
    224         //Restore our original FS selector
    225         SetFS(orgtibsel);
     221    thdb = (THDB *)(winteb+1);
     222    orgtibsel = thdb->OrgTIBSel;
     223
     224    //Restore our original FS selector
     225        SetFS(orgtibsel);
    226226   }
    227227}
     
    237237   //we don't switch FS selectors
    238238   if(fIsOS2Image) {
    239         return GetFS();
     239    return GetFS();
    240240   }
    241241
    242242   winteb = (TEB *)*TIBFlatPtr;
    243243   if(winteb) {
    244         thdb = (THDB *)(winteb+1);
    245         win32tibsel = thdb->teb_sel;
    246 
    247         //Restore our win32 FS selector
    248         return SetReturnFS(win32tibsel);
     244    thdb = (THDB *)(winteb+1);
     245    win32tibsel = thdb->teb_sel;
     246
     247    //Restore our win32 FS selector
     248        return SetReturnFS(win32tibsel);
    249249   }
    250250   else {
    251         //we didn't create this thread, so allocate a selector now
    252         //NOTE: Possible memory leak (i.e. DART threads in WINMM)
    253         winteb = InitializeTIB();
    254         if(winteb == NULL) {
    255                 DebugInt3();
    256                 return GetFS();
    257         }
    258         thdb = (THDB *)(winteb+1);
    259         win32tibsel = thdb->teb_sel;
    260 
    261         //Restore our win32 FS selector
    262         return SetReturnFS(win32tibsel);
     251    //we didn't create this thread, so allocate a selector now
     252    //NOTE: Possible memory leak (i.e. DART threads in WINMM)
     253    winteb = InitializeTIB();
     254    if(winteb == NULL) {
     255        DebugInt3();
     256        return GetFS();
     257    }
     258    thdb = (THDB *)(winteb+1);
     259    win32tibsel = thdb->teb_sel;
     260
     261    //Restore our win32 FS selector
     262        return SetReturnFS(win32tibsel);
    263263   }
    264264   // nested calls are OK, OS2ToWinCallback for instance
     
    289289
    290290  Win32DllExitList(0);
    291  
     291
    292292  //Note: Needs to be done after Win32DllExitList (destruction of exe + dll objects)
    293293  //Flush and delete all open memory mapped files
     
    316316  winmod = Win32DllBase::findModule(hinstance);
    317317  if(winmod) {
    318         winmod->Release();
    319         return(TRUE);
     318        winmod->Release();
     319        return(TRUE);
    320320  }
    321321  dprintf(("KERNEL32: FreeLibrary %s %X\n", OSLibGetDllName(hinstance), hinstance));
     
    338338  module = Win32DllBase::findModule((LPSTR)lpszLibFile);
    339339  if(module) {
    340         module->AddRef();
    341         dprintf(("iLoadLibrary: found %s -> handle %x", lpszLibFile, module->getInstanceHandle()));
    342         return module->getInstanceHandle();
     340        module->AddRef();
     341    dprintf(("iLoadLibrary: found %s -> handle %x", lpszLibFile, module->getInstanceHandle()));
     342        return module->getInstanceHandle();
    343343  }
    344344
     
    359359
    360360  if(!strstr(modname, ".")) {
    361         strcat(modname,".DLL");
     361    strcat(modname,".DLL");
    362362  }
    363363
    364364  if(Win32ImageBase::isPEImage((char *)modname))
    365365  {
    366         module = Win32DllBase::findModule((char *)modname);
    367         if(module) {//don't load it again
    368                 module->AddRef();
    369                 return module->getInstanceHandle();
    370         }
    371 
    372         Win32PeLdrDll *peldrDll = new Win32PeLdrDll((char *)modname);
    373         if(peldrDll == NULL)
    374                 return(0);
    375 
    376         peldrDll->init(0);
    377         if(peldrDll->getError() != NO_ERROR) {
    378                 dprintf(("LoadLibary %s failed (::init)\n", lpszLibFile));
    379                 delete(peldrDll);
    380                 return(0);
    381         }
    382         if(dwFlags & DONT_RESOLVE_DLL_REFERENCES) {
    383                 peldrDll->setNoEntryCalls();
    384         }
    385 
    386         if(peldrDll->attachProcess() == FALSE) {
    387                 dprintf(("LoadLibary %s failed (::attachProcess)\n", lpszLibFile));
    388                 delete(peldrDll);
    389                 return(0);
    390         }
    391         peldrDll->AddRef();
    392         return peldrDll->getInstanceHandle();
     366        module = Win32DllBase::findModule((char *)modname);
     367        if(module) {//don't load it again
     368            module->AddRef();
     369            return module->getInstanceHandle();
     370        }
     371
     372        Win32PeLdrDll *peldrDll = new Win32PeLdrDll((char *)modname);
     373        if(peldrDll == NULL)
     374            return(0);
     375
     376        peldrDll->init(0);
     377        if(peldrDll->getError() != NO_ERROR) {
     378            dprintf(("LoadLibary %s failed (::init)\n", lpszLibFile));
     379            delete(peldrDll);
     380            return(0);
     381        }
     382        if(dwFlags & DONT_RESOLVE_DLL_REFERENCES) {
     383            peldrDll->setNoEntryCalls();
     384        }
     385
     386        if(peldrDll->attachProcess() == FALSE) {
     387            dprintf(("LoadLibary %s failed (::attachProcess)\n", lpszLibFile));
     388            delete(peldrDll);
     389            return(0);
     390        }
     391        peldrDll->AddRef();
     392        return peldrDll->getInstanceHandle();
    393393  }
    394394  else  return(0);
     
    528528  dprintf(("GetModuleFileName %X", hinstModule));
    529529  if(hinstModule == 0 || hinstModule == -1 || (WinExe && hinstModule == WinExe->getInstanceHandle())) {
    530         module = (Win32ImageBase *)WinExe;
     530        module = (Win32ImageBase *)WinExe;
    531531  }
    532532  else {
    533         module = (Win32ImageBase *)Win32DllBase::findModule(hinstModule);
     533        module = (Win32ImageBase *)Win32DllBase::findModule(hinstModule);
    534534  }
    535535
    536536  if(module) {
    537         fpath = module->getFullPath();
     537        fpath = module->getFullPath();
    538538  }
    539539  if(fpath) {
    540         //SvL: 13-9-98: +1
    541         rc = min(strlen(fpath)+1, cchPath);
    542         strncpy(lpszPath, fpath, rc);
     540        //SvL: 13-9-98: +1
     541        rc = min(strlen(fpath)+1, cchPath);
     542        strncpy(lpszPath, fpath, rc);
    543543  }
    544544  else  rc = O32_GetModuleFileName(hinstModule, lpszPath, cchPath);
     
    574574
    575575  if(lpszModule == NULL) {
    576         if(WinExe)
    577                 hMod = WinExe->getInstanceHandle();
    578         else    hMod = -1;
     576    if(WinExe)
     577        hMod = WinExe->getInstanceHandle();
     578    else    hMod = -1;
    579579  }
    580580  else {
    581         strcpy(szModule, OSLibStripPath((char *)lpszModule));
    582         strupr(szModule);
    583         if(strstr(szModule, ".DLL")) {
    584                 fDllModule = TRUE;
    585         }
    586         else {
    587                 if(!strstr(szModule, ".")) {
    588                         //if there's no extension or trainling dot, we
     581    strcpy(szModule, OSLibStripPath((char *)lpszModule));
     582    strupr(szModule);
     583    if(strstr(szModule, ".DLL")) {
     584        fDllModule = TRUE;
     585    }
     586    else {
     587        if(!strstr(szModule, ".")) {
     588            //if there's no extension or trainling dot, we
    589589                        //assume it's a dll (see Win32 SDK docs)
    590                         fDllModule = TRUE;
    591                 }
    592         }
    593         char *dot = strstr(szModule, ".");
    594         if(dot)
    595                 *dot = 0;
    596 
    597         if(!fDllModule && WinExe && !strcmpi(szModule, WinExe->getModuleName())) {
    598                 hMod = WinExe->getInstanceHandle();
    599         }
    600         else {
    601                 windll = Win32DllBase::findModule(szModule);
    602                 if(windll) {
    603                         hMod = windll->getInstanceHandle();
    604                 }
    605                 else    hMod = OSLibiGetModuleHandleA((char *)lpszModule);
    606         }
     590            fDllModule = TRUE;
     591        }
     592    }
     593    char *dot = strstr(szModule, ".");
     594    if(dot)
     595        *dot = 0;
     596
     597    if(!fDllModule && WinExe && !strcmpi(szModule, WinExe->getModuleName())) {
     598        hMod = WinExe->getInstanceHandle();
     599    }
     600    else {
     601        windll = Win32DllBase::findModule(szModule);
     602        if(windll) {
     603            hMod = windll->getInstanceHandle();
     604        }
     605        else    hMod = OSLibiGetModuleHandleA((char *)lpszModule);
     606    }
    607607  }
    608608
     
    634634{
    635635 BOOL  rc;
    636  char *cmdline;
    637  BOOL  fAllocStr = FALSE;
     636 char *cmdline = NULL;
    638637
    639638    dprintf(("KERNEL32: CreateProcessA %s cline:%s inherit:%d cFlags:%x Env:%x CurDir:%s StartupFlags:%x\n",
     
    645644                         lpEnvironment, lpCurrentDirectory, lpStartupInfo,
    646645                         lpProcessInfo) == TRUE)
    647         return(TRUE);
     646        return(TRUE);
    648647
    649648    //probably a win32 exe, so run it in the pe loader
    650649    if(lpApplicationName) {
    651        if(lpCommandLine) {
    652           cmdline = (char *)malloc(strlen(lpApplicationName)+strlen(lpCommandLine) + 16);
    653           sprintf(cmdline, "PE.EXE %s %s", lpApplicationName, lpCommandLine);
    654                 fAllocStr = TRUE;
    655          }
    656          else {
    657           cmdline = (char *)malloc(strlen(lpApplicationName) + 16);
    658           sprintf(cmdline, "PE.EXE %s", lpApplicationName);
    659                 fAllocStr = TRUE;
    660          }
     650        if(lpCommandLine) {
     651            //skip exe name in lpCommandLine
     652            while(*lpCommandLine != 0 && *lpCommandLine != ' ')
     653                lpCommandLine++;
     654
     655            if(*lpCommandLine != 0) {
     656                lpCommandLine++;
     657            }
     658            cmdline = (char *)malloc(strlen(lpApplicationName)+strlen(lpCommandLine) + 16);
     659            sprintf(cmdline, "PE.EXE %s %s", lpApplicationName, lpCommandLine);
     660         }
     661         else {
     662            cmdline = (char *)malloc(strlen(lpApplicationName) + 16);
     663            sprintf(cmdline, "PE.EXE %s", lpApplicationName);
     664        }
    661665    }
    662666    else {
    663667        cmdline = (char *)malloc(strlen(lpCommandLine) + 16);
    664668        sprintf(cmdline, "PE.EXE %s", lpCommandLine);
    665         fAllocStr = TRUE;
    666669    }
    667670    dprintf(("KERNEL32:  CreateProcess %s\n", cmdline));
     
    670673                         lpEnvironment, lpCurrentDirectory, lpStartupInfo,
    671674                         lpProcessInfo);
    672     if(fAllocStr)
    673         free(cmdline);
     675    if(cmdline)
     676        free(cmdline);
    674677
    675678    if(lpProcessInfo)
     
    697700    astring2 = UnicodeToAsciiString(arg2);
    698701    astring3 = UnicodeToAsciiString((LPWSTR)arg8);
    699     // NOTE: This will not work as is (needs UNICODE support)
    700702    rc = CreateProcessA(astring1, astring2, arg3, arg4, arg5, arg6, arg7,
    701703                           astring3, (LPSTARTUPINFOA)arg9, arg10);
     
    715717    startinfo.dwFlags = nCmdShow;
    716718    if(CreateProcessA(NULL, (LPSTR)lpCmdLine, NULL, NULL, FALSE, 0, NULL, NULL,
    717                       &startinfo, &procinfo) == FALSE) 
     719                      &startinfo, &procinfo) == FALSE)
    718720    {
    719         return 0;
     721    return 0;
    720722    }
    721723    return procinfo.hProcess; //correct?
     
    730732
    731733  if(hModule == 0 || hModule == -1 || (WinExe && hModule == WinExe->getInstanceHandle())) {
    732         winmod = WinExe;
     734    winmod = WinExe;
    733735  }
    734736  else  winmod = (Win32ImageBase *)Win32DllBase::findModule((HINSTANCE)hModule);
    735737
    736738  if(winmod) {
    737         ulAPIOrdinal = (ULONG)lpszProc;
    738         if (ulAPIOrdinal <= 0x0000FFFF) {
    739                 proc = (FARPROC)winmod->getApi((int)ulAPIOrdinal);
    740         }
    741         else    proc = (FARPROC)winmod->getApi((char *)lpszProc);
    742         if(proc == 0) {
    743                 SetLastError(ERROR_PROC_NOT_FOUND);
    744         }
    745         return proc;
     739        ulAPIOrdinal = (ULONG)lpszProc;
     740        if (ulAPIOrdinal <= 0x0000FFFF) {
     741            proc = (FARPROC)winmod->getApi((int)ulAPIOrdinal);
     742        }
     743        else    proc = (FARPROC)winmod->getApi((char *)lpszProc);
     744    if(proc == 0) {
     745        SetLastError(ERROR_PROC_NOT_FOUND);
     746    }
     747    return proc;
    746748  }
    747749  proc = O32_GetProcAddress(hModule, lpszProc);
    748   if(HIWORD(lpszProc)) 
    749         dprintf(("KERNEL32:  GetProcAddress %s from %X returned %X\n", lpszProc, hModule, proc));
     750  if(HIWORD(lpszProc))
     751    dprintf(("KERNEL32:  GetProcAddress %s from %X returned %X\n", lpszProc, hModule, proc));
    750752  else  dprintf(("KERNEL32:  GetProcAddress %x from %X returned %X\n", lpszProc, hModule, proc));
    751753  return(proc);
     
    761763  dprintf(("GetVersionStruct of module %s", lpszModName));
    762764  if(WinExe && !stricmp(WinExe->getFullPath(), lpszModName)) {
    763         winimage = (Win32ImageBase *)WinExe;
     765        winimage = (Win32ImageBase *)WinExe;
    764766  }
    765767  else {
    766         winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName);
    767         if(winimage == NULL)
     768        winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName);
     769        if(winimage == NULL)
    768770        {
    769         char modname[CCHMAXPATH];
    770 
    771                 strcpy(modname, lpszModName);
    772                 //rename dll if necessary (i.e. OLE32 -> OLE32OS2)
    773                 Win32DllBase::renameDll(modname);
    774                
    775                 if(Win32ImageBase::isPEImage(modname) == FALSE)
     771    char modname[CCHMAXPATH];
     772
     773        strcpy(modname, lpszModName);
     774        //rename dll if necessary (i.e. OLE32 -> OLE32OS2)
     775        Win32DllBase::renameDll(modname);
     776
     777        if(Win32ImageBase::isPEImage(modname) == FALSE)
    776778                {
    777                 HINSTANCE hInstance;
    778                  
    779                         //must be an LX dll, just load it (app will probably load it anyway)
    780                         hInstance = LoadLibraryA(modname);
    781                         if(hInstance == 0)
    782                                 return 0;
    783                         winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
    784                         if(winimage) {
    785                                 return winimage->getVersionStruct(verstruct, bufLength);
    786                         }
    787                         return 0;
    788                 }
    789                 //SvL: Try to load it
    790                 rsrcimg = new Win32PeLdrRsrcImg(modname);
    791                 if(rsrcimg == NULL)
    792                         return 0;
    793 
    794                 rsrcimg->init(0);
    795                 if(rsrcimg->getError() != NO_ERROR)
    796                 {
    797                         dprintf(("GetVersionStruct can't load %s\n", modname));
    798                         delete rsrcimg;
    799                         return(FALSE);
    800                 }
    801                 BOOL rc = rsrcimg->getVersionStruct(verstruct, bufLength);
    802                 delete rsrcimg;
    803                 return rc;
    804         }
     779        HINSTANCE hInstance;
     780
     781            //must be an LX dll, just load it (app will probably load it anyway)
     782            hInstance = LoadLibraryA(modname);
     783            if(hInstance == 0)
     784                return 0;
     785                winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
     786                if(winimage) {
     787                return winimage->getVersionStruct(verstruct, bufLength);
     788            }
     789            return 0;
     790        }
     791        //SvL: Try to load it
     792        rsrcimg = new Win32PeLdrRsrcImg(modname);
     793        if(rsrcimg == NULL)
     794            return 0;
     795
     796            rsrcimg->init(0);
     797        if(rsrcimg->getError() != NO_ERROR)
     798        {
     799                dprintf(("GetVersionStruct can't load %s\n", modname));
     800            delete rsrcimg;
     801                return(FALSE);
     802        }
     803        BOOL rc = rsrcimg->getVersionStruct(verstruct, bufLength);
     804        delete rsrcimg;
     805        return rc;
     806        }
    805807  }
    806808  return winimage->getVersionStruct(verstruct, bufLength);
     
    816818
    817819  if(WinExe && !stricmp(WinExe->getFullPath(), lpszModName)) {
    818         winimage = (Win32ImageBase *)WinExe;
     820        winimage = (Win32ImageBase *)WinExe;
    819821  }
    820822  else {
    821         winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName);
    822         if(winimage == NULL)
     823        winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName);
     824        if(winimage == NULL)
    823825        {
    824         char modname[CCHMAXPATH];
    825 
    826                 strcpy(modname, lpszModName);
    827                 //rename dll if necessary (i.e. OLE32 -> OLE32OS2)
    828                 Win32DllBase::renameDll(modname);
    829 
    830                 if(Win32ImageBase::isPEImage(modname) == FALSE)
     826    char modname[CCHMAXPATH];
     827
     828        strcpy(modname, lpszModName);
     829        //rename dll if necessary (i.e. OLE32 -> OLE32OS2)
     830        Win32DllBase::renameDll(modname);
     831
     832        if(Win32ImageBase::isPEImage(modname) == FALSE)
    831833                {
    832                 HINSTANCE hInstance;
    833                  
    834                         //must be an LX dll, just load it (app will probably load it anyway)
    835                         hInstance = LoadLibraryA(modname);
    836                         if(hInstance == 0)
    837                                 return 0;
    838                         winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
    839                         if(winimage) {
    840                                 return winimage->getVersionSize();
    841                         }
    842                         return 0;
    843                 }
    844 
    845                 //SvL: Try to load it
    846                 rsrcimg = new Win32PeLdrRsrcImg(modname);
    847                 if(rsrcimg == NULL)
    848                         return 0;
    849 
    850                 rsrcimg->init(0);
    851                 if(rsrcimg->getError() != NO_ERROR)
    852                 {
    853                         dprintf(("GetVersionSize can't load %s\n", modname));
    854                         delete rsrcimg;
    855                         return(FALSE);
    856                 }
    857                 int size = rsrcimg->getVersionSize();
    858                 delete rsrcimg;
    859                 return size;
    860         }
     834        HINSTANCE hInstance;
     835
     836            //must be an LX dll, just load it (app will probably load it anyway)
     837            hInstance = LoadLibraryA(modname);
     838            if(hInstance == 0)
     839                return 0;
     840                winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
     841                if(winimage) {
     842                return winimage->getVersionSize();
     843            }
     844            return 0;
     845        }
     846
     847        //SvL: Try to load it
     848        rsrcimg = new Win32PeLdrRsrcImg(modname);
     849        if(rsrcimg == NULL)
     850            return 0;
     851
     852            rsrcimg->init(0);
     853        if(rsrcimg->getError() != NO_ERROR)
     854        {
     855                dprintf(("GetVersionSize can't load %s\n", modname));
     856            delete rsrcimg;
     857                return(FALSE);
     858        }
     859        int size = rsrcimg->getVersionSize();
     860        delete rsrcimg;
     861        return size;
     862        }
    861863  }
    862864  return winimage->getVersionSize();
Note: See TracChangeset for help on using the changeset viewer.