Changeset 956 for trunk/src


Ignore:
Timestamp:
Sep 16, 1999, 1:39:08 AM (26 years ago)
Author:
sandervl
Message:

Rewrite for new win32 image classes

Location:
trunk/src/kernel32
Files:
12 added
5 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/KERNEL32.DEF

    r922 r956  
    1 ; $Id: KERNEL32.DEF,v 1.37 1999-09-13 14:57:07 phaller Exp $
     1; $Id: KERNEL32.DEF,v 1.38 1999-09-15 23:38:01 sandervl Exp $
    22
    33;Created by BLAST for IBM's compiler
     
    943943    memmove                    = _OS2memmove                      @906
    944944
    945     ConvertNameId                 = ConvertNameId                 @1200
     945
    946946    DebugErrorBox                 = DebugErrorBox                 @1201
    947947    WriteLog                      = WriteLog                      @1202
     
    949949
    950950;Used by tibfix page in exe (change ordinal in lx.cpp too!!)
    951     RegisterExe                   = _RegisterExe@48               @1203
     951    _RegisterPe2LxExe@48                                          @1203
     952    _RegisterPe2LxDll@48                                          @1209
     953
     954    _CreateWin32PeLdrExe@8                                        @1236
     955
     956    _RegisterLxExe@8                                              @1237
     957    _RegisterLxDll@12                                             @1238
     958    _UnregisterLxDll@4                                            @1239
     959
    952960;VMutex
    953961   enter__6VMutexFUl                                              @1204
     
    955963   __ct__6VMutexFi                                                @1206
    956964   __dt__6VMutexFv                                                @1207
    957 ;Used by tibfix page in dll (change ordinal in lx.cpp too!!)
    958 ;   DLLExitList                   = _DLLExitList@4                @1208
    959     RegisterDll                   = _RegisterDll@48               @1209
     965
    960966;Unicode
    961967   UnicodeToAsciiString = _UnicodeToAsciiString@4                 @1210
     
    966972   AsciiToUnicodeN      = _AsciiToUnicodeN@12                     @1216
    967973
    968 ;Win32Exe constructor
    969    __ct__8Win32ExeFPc                                             @1220
    970 
    971974;Get version resource
    972975   GetVersionStruct     = GetVersionStruct                        @1221
     
    993996   GetThreadTEB         = _GetThreadTEB@0                         @1234
    994997   GetThreadTHDB        = _GetThreadTHDB@0                        @1235
    995 
    996    CreateWin32Exe       = _CreateWin32Exe@4                       @1236
    997998
    998999; HEAP Management (heap.cpp, heapstring.cpp)
     
    10151016    OS2UnsetExceptionHandler                                      @1254
    10161017
    1017     __ct__12Win32MenuResFP10Win32ImageUlN22                       @1260
    1018     __ct__12Win32MenuResFP10Win32ImageUlN22Pc                     @1261
     1018    __ct__12Win32MenuResFP14Win32ImageBaseUlN22                   @1260
     1019    __ct__12Win32MenuResFP14Win32ImageBaseUlN22Pc                 @1261
    10191020    __ct__12Win32MenuResFUl                                       @1262
    10201021    __ct__12Win32MenuResFPv                                       @1263
  • trunk/src/kernel32/cvtcursorgrp.cpp

    r816 r956  
    1 /* $Id: cvtcursorgrp.cpp,v 1.2 1999-09-04 12:41:45 sandervl Exp $ */
     1/* $Id: cvtcursorgrp.cpp,v 1.3 1999-09-15 23:38:00 sandervl Exp $ */
    22
    33/*
     
    3232//******************************************************************************
    3333//******************************************************************************
    34 void *ConvertCursorGroup(CursorHeader *chdr, int size, Win32Image *module)
     34void *ConvertCursorGroup(CursorHeader *chdr, int size, Win32ImageBase *module)
    3535{
    3636 CursorResDir *rdir = (CursorResDir *)(chdr + 1);
  • trunk/src/kernel32/cvticongrp.cpp

    r816 r956  
    1 /* $Id: cvticongrp.cpp,v 1.2 1999-09-04 12:41:46 sandervl Exp $ */
     1/* $Id: cvticongrp.cpp,v 1.3 1999-09-15 23:38:01 sandervl Exp $ */
    22
    33/*
     
    3232//******************************************************************************
    3333//******************************************************************************
    34 void *ConvertIconGroup(IconHeader *ihdr, int size, Win32Image *module)
     34void *ConvertIconGroup(IconHeader *ihdr, int size, Win32ImageBase *module)
    3535{
    3636 ResourceDirectory *rdir = (ResourceDirectory *)(ihdr + 1);
  • trunk/src/kernel32/cvtresource.h

    r816 r956  
    1 /* $Id: cvtresource.h,v 1.3 1999-09-04 12:41:46 sandervl Exp $ */
     1/* $Id: cvtresource.h,v 1.4 1999-09-15 23:38:01 sandervl Exp $ */
    22
    33#ifndef _CVTRESOURCE_H_
     
    88#include <winaccel.h>
    99#include <wincursor.h>
    10 #include <winimage.h>
     10#include <winimagebase.h>
    1111
    1212void *ConvertAccelerator(WINACCEL *accdata, int size, int cp = 0);
    1313void *ConvertBitmap(WINBITMAPINFOHEADER *pBHdr, ULONG ulSize, PULONG pulSize);
    1414void *ConvertCursor(CursorComponent *curHdr, int size, int *os2size, int offsetBits = 0);
    15 void *ConvertCursorGroup(CursorHeader *chdr, int size, Win32Image *module);
     15void *ConvertCursorGroup(CursorHeader *chdr, int size, Win32ImageBase *module);
    1616void *ConvertIcon(WINBITMAPINFOHEADER *bmpHdr, int size, int *os2size, int offsetBits = 0);
    17 void *ConvertIconGroup(IconHeader *ihdr, int size, Win32Image *module);
     17void *ConvertIconGroup(IconHeader *ihdr, int size, Win32ImageBase *module);
    1818void *ConvertMenu(MenuHeader *menu, int size, int cp = 0);
    1919
  • trunk/src/kernel32/makefile

    r862 r956  
    1 # $Id: makefile,v 1.40 1999-09-07 20:27:44 phaller Exp $
     1# $Id: makefile,v 1.41 1999-09-15 23:38:01 sandervl Exp $
    22
    33#
     
    2323CONBUFFER.OBJ CONOUT.OBJ UNICODE.OBJ network.OBJ DEVIO.OBJ \
    2424profile.obj THREAD.OBJ virtual.obj THUNK.OBJ OBSOLETE.OBJ COMM.OBJ\
    25 MESSAGE.OBJ RESOURCE.OBJ NAMEID.OBJ WINRES.OBJ WINMOD.OBJ EXCEPTIONS.OBJ \
     25MESSAGE.OBJ RESOURCE.OBJ EXCEPTIONS.OBJ \
    2626LFILE.OBJ NPIPE.OBJ oslibdos.obj oslibmisc.obj MISC.OBJ EXCEPTUTIL.OBJ \
    2727LANG.OBJ ICCIO.OBJ MAP.OBJ WIN32UTIL.OBJ heap.OBJ heapstring.obj \
    2828os2heap.OBJ vmutex.OBJ initterm.OBJ handlemanager.OBJ winresmenu.obj \
    2929hmdevice.obj hmopen32.obj hmobjects.obj hmevent.obj hmmutex.obj \
    30 hmsemaphore.obj wprocess.OBJ conprop.OBJ \
    31 winimage.OBJ windll.OBJ winexe.OBJ time.obj mmap.obj \
     30hmsemaphore.obj wprocess.OBJ conprop.OBJ winimagelx.obj \
     31winimagebase.OBJ windllbase.OBJ winexebase.OBJ time.obj mmap.obj \
     32winimagepe2lx.obj winimagepeldr.obj windllpe2lx.obj windlllx.obj windllpeldr.obj \
     33winexepe2lx.obj winexelx.obj winexepeldr.obj WINRES.OBJ \
    3234pefile.OBJ winimgres.OBJ wintls.obj async.OBJ fileio.obj \
    3335atom.obj disk.obj directory.obj cvtbitmap.obj hmmmap.obj \
     
    7981    $(PDWIN32_INCLUDE)\unicode.h \
    8082    $(PDWIN32_INCLUDE)\heap.h \
    81     $(PDWIN32_INCLUDE)\wprocess.h \
    82     $(PDWIN32_INCLUDE)\nameid.h
     83    $(PDWIN32_INCLUDE)\wprocess.h
    8384
    8485kobjects.obj: kobjects.cpp
     
    103104    $(PDWIN32_INCLUDE)\unicode.h
    104105
    105 wintls.obj: wintls.cpp $(PDWIN32_INCLUDE)\winimage.h $(PDWIN32_INCLUDE)\winexe.h $(PDWIN32_INCLUDE)\windll.h
     106wintls.obj: wintls.cpp $(PDWIN32_INCLUDE)\winimagebase.h $(PDWIN32_INCLUDE)\winexebase.h $(PDWIN32_INCLUDE)\windllbase.h
    106107
    107108fileio.obj: fileio.cpp \
     
    111112    .\thread.cpp \
    112113    $(PDWIN32_INCLUDE)\wprocess.h \
    113     $(PDWIN32_INCLUDE)\winimage.h $(PDWIN32_INCLUDE)\winexe.h $(PDWIN32_INCLUDE)\windll.h \
     114    $(PDWIN32_INCLUDE)\winimagebase.h $(PDWIN32_INCLUDE)\winexebase.h $(PDWIN32_INCLUDE)\windllbase.h \
    114115    thread.h
    115116
     
    161162wprocess.OBJ: \
    162163    .\wprocess.cpp \
    163     $(PDWIN32_INCLUDE)\nameid.h \
    164164    $(PDWIN32_INCLUDE)\unicode.h \
    165     $(PDWIN32_INCLUDE)\winexe.h \
    166     $(PDWIN32_INCLUDE)\windll.h \
    167     $(PDWIN32_INCLUDE)\winimage.h \
     165    $(PDWIN32_INCLUDE)\winexebase.h \
     166    $(PDWIN32_INCLUDE)\windllbase.h \
     167    $(PDWIN32_INCLUDE)\winexepeldr.h \
     168    $(PDWIN32_INCLUDE)\windllpeldr.h \
     169    $(PDWIN32_INCLUDE)\winimagebase.h \
    168170    $(PDWIN32_INCLUDE)\versionos2.h \
    169171    $(PDWIN32_INCLUDE)\wprocess.h \
     
    230232    .\obsolete.cpp
    231233
    232 nameid.OBJ: \
    233     .\nameid.cpp \
    234     $(PDWIN32_INCLUDE)\nameid.h \
    235     $(PDWIN32_INCLUDE)\win32util.h \
    236     $(PDWIN32_INCLUDE)\winimage.h \
    237     $(PDWIN32_INCLUDE)\winexe.h \
    238     $(PDWIN32_INCLUDE)\windll.h \
    239     $(PDWIN32_INCLUDE)\misc.h
    240 
    241234resource.OBJ: \
    242235    .\resource.cpp \
    243     $(PDWIN32_INCLUDE)\nameid.h \
    244236    $(PDWIN32_INCLUDE)\unicode.h \
    245     $(PDWIN32_INCLUDE)\winimage.h \
     237    $(PDWIN32_INCLUDE)\winimagebase.h \
    246238    $(PDWIN32_INCLUDE)\winres.h \
    247239    $(PDWIN32_INCLUDE)\misc.h
     
    258250    $(PDWIN32_INCLUDE)\winresmenu.h \
    259251    $(PDWIN32_INCLUDE)\winres.h \
    260     $(PDWIN32_INCLUDE)\nameid.h \
    261     $(PDWIN32_INCLUDE)\winimage.h \
    262     $(PDWIN32_INCLUDE)\winexe.h \
    263     $(PDWIN32_INCLUDE)\windll.h \
    264     $(PDWIN32_INCLUDE)\misc.h
    265 
    266 winmod.OBJ: \
    267     .\winmod.cpp \
    268     $(PDWIN32_INCLUDE)\winimage.h \
    269     $(PDWIN32_INCLUDE)\winexe.h \
    270     $(PDWIN32_INCLUDE)\windll.h \
    271     $(PDWIN32_INCLUDE)\winimage.h \
     252    $(PDWIN32_INCLUDE)\winimagebase.h \
     253    $(PDWIN32_INCLUDE)\winexebase.h \
     254    $(PDWIN32_INCLUDE)\windllbase.h \
    272255    $(PDWIN32_INCLUDE)\misc.h
    273256
     
    334317mmap.obj:      mmap.cpp mmap.h $(PDWIN32_INCLUDE)\vmutex.h oslibdos.h
    335318
    336 pefile.OBJ:    pefile.cpp $(PDWIN32_INCLUDE)\pefile.h
    337 winimage.OBJ:  winimage.cpp $(PDWIN32_INCLUDE)\winimage.h $(PDWIN32_INCLUDE)\windll.h $(PDWIN32_INCLUDE)\pefile.h $(PDWIN32_INCLUDE)\winres.h initterm.h $(PDWIN32_INCLUDE)\win\virtual.h oslibmisc.h
    338 winimgres.OBJ: winimgres.cpp $(PDWIN32_INCLUDE)\winimage.h $(PDWIN32_INCLUDE)\windll.h $(PDWIN32_INCLUDE)\pefile.h $(PDWIN32_INCLUDE)\winexe.h $(PDWIN32_INCLUDE)\winres.h
    339 windll.OBJ:    windll.cpp $(PDWIN32_INCLUDE)\winimage.h $(PDWIN32_INCLUDE)\windll.h oslibmisc.h
    340 winexe.OBJ:    winexe.cpp $(PDWIN32_INCLUDE)\winimage.h $(PDWIN32_INCLUDE)\windll.h $(PDWIN32_INCLUDE)\winexe.h
     319pefile.OBJ:    pefile.cpp $(PDWIN32_INCLUDE)\pefile.h $(PDWIN32_INCLUDE)\winres.h
     320
     321winimagebase.obj:  winimagebase.cpp $(PDWIN32_INCLUDE)\winimagebase.h
     322winimagepe2lx.obj: winimagepe2lx.cpp $(PDWIN32_INCLUDE)\winimagebase.h $(PDWIN32_INCLUDE)\winimagepe2lx.h
     323winimagepeldr.obj: winimagepeldr.cpp $(PDWIN32_INCLUDE)\winimagebase.h $(PDWIN32_INCLUDE)\winimagepeldr.h
     324winimagelx.obj:    winimagelx.cpp $(PDWIN32_INCLUDE)\winimagebase.h $(PDWIN32_INCLUDE)\winimagelx.h
     325windllbase.obj:    windllbase.cpp $(PDWIN32_INCLUDE)\windllbase.h $(PDWIN32_INCLUDE)\winimagebase.h
     326windllpe2lx.obj:   windllpe2lx.cpp $(PDWIN32_INCLUDE)\windllbase.h $(PDWIN32_INCLUDE)\windllpe2lx.h $(PDWIN32_INCLUDE)\winimagepe2lx.h
     327windlllx.obj:      windlllx.cpp $(PDWIN32_INCLUDE)\windllbase.h $(PDWIN32_INCLUDE)\windlllx.h $(PDWIN32_INCLUDE)\winimagelx.h $(PDWIN32_INCLUDE)\odinlx.h
     328windllpeldr.obj:   windllpeldr.cpp $(PDWIN32_INCLUDE)\windllbase.h $(PDWIN32_INCLUDE)\windllpeldr.h $(PDWIN32_INCLUDE)\winimagepeldr.h
     329winexebase.obj:    winexebase.cpp $(PDWIN32_INCLUDE)\winexebase.h $(PDWIN32_INCLUDE)\winimagebase.h
     330winexepe2lx.obj:   winexepe2lx.cpp $(PDWIN32_INCLUDE)\winexebase.h $(PDWIN32_INCLUDE)\winexepe2lx.h $(PDWIN32_INCLUDE)\winimagepe2lx.h
     331winexelx.obj:      winexelx.cpp $(PDWIN32_INCLUDE)\winexebase.h $(PDWIN32_INCLUDE)\winexelx.h $(PDWIN32_INCLUDE)\winimagelx.h $(PDWIN32_INCLUDE)\odinlx.h
     332winexepeldr.obj:   winexepeldr.cpp $(PDWIN32_INCLUDE)\winexebase.h $(PDWIN32_INCLUDE)\winexepeldr.h $(PDWIN32_INCLUDE)\winimagepeldr.h
     333
     334winimgres.OBJ: winimgres.cpp $(PDWIN32_INCLUDE)\winimagebase.h $(PDWIN32_INCLUDE)\pefile.h $(PDWIN32_INCLUDE)\winimagepe2lx.h $(PDWIN32_INCLUDE)\winimagepeldr.h $(PDWIN32_INCLUDE)\winimagelx.h $(PDWIN32_INCLUDE)\winres.h
    341335stubs.obj:     stubs.cpp stubs.h
    342336
  • trunk/src/kernel32/oslibmisc.cpp

    r705 r956  
    1 /* $Id: oslibmisc.cpp,v 1.1 1999-08-26 12:56:02 sandervl Exp $ */
     1/* $Id: oslibmisc.cpp,v 1.2 1999-09-15 23:38:01 sandervl Exp $ */
    22
    33/*
     
    5959 static char modname[CCHMAXPATH] = {0};
    6060
    61   DosQueryModuleName(hModule, CCHMAXPATH, modname);
     61  if(DosQueryModuleName(hModule, CCHMAXPATH, modname) != 0) {
     62        return NULL;
     63  }
    6264  return(modname);
    6365}
  • trunk/src/kernel32/pefile.cpp

    r120 r956  
    1 /* $Id: pefile.cpp,v 1.4 1999-06-19 10:54:43 sandervl Exp $ */
     1/* $Id: pefile.cpp,v 1.5 1999-09-15 23:38:01 sandervl Exp $ */
    22
    33/*
     
    1818#include <pefile.h>
    1919#include <misc.h>
    20 #include <winimage.h>
     20#include <winres.h>
    2121
    2222//******************************************************************************
  • trunk/src/kernel32/resource.cpp

    r589 r956  
    1 /* $Id: resource.cpp,v 1.8 1999-08-19 19:50:40 sandervl Exp $ */
     1/* $Id: resource.cpp,v 1.9 1999-09-15 23:38:01 sandervl Exp $ */
    22
    33/*
     
    1212 */
    1313#include <os2win.h>
    14 #include "unicode.h"
     14#include <unicode.h>
    1515#include "winres.h"
    16 #include "winimage.h"
    17 #include "winexe.h"
     16#include <winimagebase.h>
     17#include <winexebase.h>
     18#include <windllbase.h>
    1819
    1920//******************************************************************************
     
    2324HRSRC WIN32API FindResourceA(HINSTANCE hModule, LPCSTR lpszName, LPCSTR lpszType)
    2425{
    25  Win32Image *module;
     26 Win32ImageBase *module;
    2627
    2728    dprintf(("FindResourceA %X", hModule));
     
    2930       WinExe->getInstanceHandle()))
    3031    {
    31          module = (Win32Image *)WinExe;
     32         module = (Win32ImageBase *)WinExe;
    3233    }
    33     else module = (Win32Image *)Win32Dll::findModule(hModule);
     34    else module = (Win32ImageBase *)Win32DllBase::findModule(hModule);
    3435
    3536    if(module == NULL)
     
    4344                             LPCWSTR lpszType)
    4445{
    45  Win32Image *module;
     46 Win32ImageBase *module;
    4647
    4748    dprintf(("FindResourceW %X", hModule));
     
    4950       WinExe->getInstanceHandle()))
    5051    {
    51          module = (Win32Image *)WinExe;
     52         module = (Win32ImageBase *)WinExe;
    5253    }
    53     else module = (Win32Image *)Win32Dll::findModule(hModule);
     54    else module = (Win32ImageBase *)Win32DllBase::findModule(hModule);
    5455
    5556    if(module == NULL)
  • trunk/src/kernel32/thread.cpp

    r919 r956  
    1 /* $Id: thread.cpp,v 1.13 1999-09-13 13:16:21 phaller Exp $ */
     1/* $Id: thread.cpp,v 1.14 1999-09-15 23:38:02 sandervl Exp $ */
    22
    33/*
     
    1212#include <os2win.h>
    1313#include <stdarg.h>
     14#include <string.h>
    1415#include "thread.h"
    1516#include "exceptutil.h"
    1617#include <misc.h>
    1718#include <wprocess.h>
    18 #include <windll.h>
    19 #include <winexe.h>
     19#include <windllbase.h>
     20#include <winexebase.h>
    2021#include <except.h>
    2122
     
    9798             hThread));
    9899
    99   /* @@@PH: map os/2 priority model to win32 priority model */
    100 
    101100    return O32_GetThreadPriority(hThread);
    102101}
     
    118117             priority));
    119118
    120   /* @@@PH: map win32 priority model to os/2 priority model */
    121 
    122119    return O32_SetThreadPriority(hThread, priority);
    123120}
     
    147144           exitcode));
    148145
    149   Win32Dll::detachThreadFromAllDlls();  //send DLL_THREAD_DETACH message to all dlls
    150   Win32Dll::tlsDetachThreadFromAllDlls(); //destroy TLS structures of all dlls
     146  Win32DllBase::detachThreadFromAllDlls();      //send DLL_THREAD_DETACH message to all dlls
     147  Win32DllBase::tlsDetachThreadFromAllDlls(); //destroy TLS structures of all dlls
    151148  WinExe->tlsDetachThread();                    //destroy TLS structure of main exe
    152149  DestroyTIB();
     
    200197  SetWin32TIB();
    201198  WinExe->tlsAttachThread();              //setup TLS structure of main exe
    202   Win32Dll::tlsAttachThreadToAllDlls(); //setup TLS structures of all dlls
    203   Win32Dll::attachThreadToAllDlls();      //send DLL_THREAD_ATTACH message to all dlls
     199  Win32DllBase::tlsAttachThreadToAllDlls(); //setup TLS structures of all dlls
     200  Win32DllBase::attachThreadToAllDlls();          //send DLL_THREAD_ATTACH message to all dlls
    204201
    205202  //Note: The Win32 exception structure references by FS:[0] is the same
     
    209206  OS2UnsetExceptionHandler((void *)&exceptFrame);
    210207
    211   Win32Dll::detachThreadFromAllDlls();  //send DLL_THREAD_DETACH message to all dlls
    212   Win32Dll::tlsDetachThreadFromAllDlls(); //destroy TLS structures of all dlls
     208  Win32DllBase::detachThreadFromAllDlls();  //send DLL_THREAD_DETACH message to all dlls
     209  Win32DllBase::tlsDetachThreadFromAllDlls(); //destroy TLS structures of all dlls
    213210  WinExe->tlsDetachThread();              //destroy TLS structure of main exe
    214211  DestroyTIB();
  • trunk/src/kernel32/winimgres.cpp

    r752 r956  
    1 /* $Id: winimgres.cpp,v 1.13 1999-08-31 14:36:46 sandervl Exp $ */
     1/* $Id: winimgres.cpp,v 1.14 1999-09-15 23:38:02 sandervl Exp $ */
    22
    33/*
     
    1010 *
    1111 * TODO: Check created resource objects before loading the resource!
     12 * TODO: Is the name id of the version resource always 1?
     13 * TODO: Once the resource handling in PE2LX/win32k is changed,
     14 *       getVersionStruct/Size can be moved into the Win32ImageBase class
    1215 *
    1316 */
     
    1821
    1922#include <misc.h>
    20 #include <nameid.h>
    21 #include <winimage.h>
    22 #include <windll.h>
    23 #include <winexe.h>
     23#include <winimagebase.h>
     24#include <winimagepe2lx.h>
     25#include <winimagepeldr.h>
     26#include <winimagelx.h>
    2427#include <winres.h>
    2528#include <winresmenu.h>
     
    2730#include <heapstring.h>
    2831#include "pefile.h"
    29 
    30 char *ResTypes[MAX_RES] =
    31       {"niks", "CURSOR", "BITMAP", "ICON", "MENU", "DIALOG", "STRING",
    32        "FONTDIR", "FONT", "ACCELERATOR", "RCDATA",  "MESSAGETABLE",
    33        "GROUP_CURSOR", "niks", "GROUP_ICON", "niks", "VERSION"};
    34 
     32#include "oslibmisc.h"
    3533
    3634//******************************************************************************
     
    3937//******************************************************************************
    4038PIMAGE_RESOURCE_DATA_ENTRY
    41  Win32Image::getPEResourceEntry(ULONG id, ULONG type, ULONG lang)
     39 Win32PeLdrImage::getPEResourceEntry(ULONG id, ULONG type, ULONG lang)
    4240{
    4341 PIMAGE_RESOURCE_DIRECTORY       prdType;
     
    126124//******************************************************************************
    127125PIMAGE_RESOURCE_DATA_ENTRY
    128     Win32Image::ProcessResSubDir(PIMAGE_RESOURCE_DIRECTORY prdType,
     126    Win32PeLdrImage::ProcessResSubDir(PIMAGE_RESOURCE_DIRECTORY prdType,
    129127                                 ULONG *nodeData, int level)
    130128{
     
    203201//******************************************************************************
    204202//******************************************************************************
    205 ULONG Win32Image::getPEResourceSize(ULONG id, ULONG type, ULONG lang)
     203ULONG Win32PeLdrImage::getPEResourceSize(ULONG id, ULONG type, ULONG lang)
    206204{
    207205 PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
     
    209207  pData = getPEResourceEntry(id, type, lang);
    210208  if(pData == NULL) {
    211         dprintf(("Win32Image::getPEResourceSize: couldn't find resource %d (type %d, lang %d)", id, type, lang));
     209        dprintf(("Win32ImageBase::getPEResourceSize: couldn't find resource %d (type %d, lang %d)", id, type, lang));
    212210        return 0;
    213211  }
     
    216214//******************************************************************************
    217215//******************************************************************************
    218 Win32Resource *Win32Image::getPEResource(ULONG id, ULONG type, ULONG lang)
     216HRSRC Win32PeLdrImage::findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
    219217{
    220218 PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
     
    222220 BOOL   fNumType;
    223221 char  *winres = NULL;
     222 ULONG  id, type;
    224223 int    i, stringid = -1, j;
    225224
    226225  fNumType = TRUE;    //assume numeric
    227   if(HIWORD(type) != 0) {//string id?
    228     for(i=0;i<MAX_RES;i++) {
    229          if(stricmp((char *)type, ResTypes[i]) == 0)
    230                 break;
    231     }
    232     if(i == MAX_RES) {//custom resource type
    233          fNumType = FALSE;
    234     }
    235     else type   = i;
    236   }
     226  if(HIWORD(lpszType) != 0) {//string id?
     227        for(i=0;i<MAX_RES;i++) {
     228                if(stricmp(lpszType, ResTypes[i]) == 0)
     229                        break;
     230        }
     231        if(i == MAX_RES) {//custom resource type
     232                fNumType = FALSE;
     233                type = (ULONG)lpszType;
     234        }
     235        else    type = i;
     236  }
     237  else  type = (ULONG)lpszType;
    237238
    238239  //String format: tables of 16 strings stored as one resource
     
    241242  if(fNumType) {
    242243    if(type == NTRT_STRING) {
    243         stringid = id & 0xF;
    244         id       = (id >> 4)+1;
    245     }
     244         stringid = (ULONG)lpszName & 0xF;
     245         id       = (((ULONG)lpszName) >> 4)+1;
     246    }
     247    else id = (ULONG)lpszName;
    246248  }
    247249  else {
    248250    if(stricmp((char *)type, ResTypes[NTRT_STRING]) == 0) {
    249         stringid = id & 0xF;
    250         id       = (id >> 4)+1;
    251     }
     251         stringid = (ULONG)lpszName & 0xF;
     252         id       = (((ULONG)lpszName) >> 4)+1;
     253    }
     254    else id = (ULONG)lpszName;
    252255  }
    253256
     
    255258  if(pData == NULL) {
    256259        if(HIWORD(id)) {
    257                 dprintf(("Win32Image::getPEResource: couldn't find resource %s (type %d, lang %d)", id, type, lang));
     260                dprintf(("Win32ImageBase::getPEResource: couldn't find resource %s (type %d, lang %d)", id, type, lang));
    258261        }
    259         else    dprintf(("Win32Image::getPEResource: couldn't find resource %d (type %d, lang %d)", id, type, lang));
     262        else    dprintf(("Win32ImageBase::getPEResource: couldn't find resource %d (type %d, lang %d)", id, type, lang));
    260263        return 0;
    261264  }
     
    287290  }
    288291
    289   return res;
    290 }
    291 //******************************************************************************
    292 //******************************************************************************
    293 HRSRC Win32Image::findResourceA(LPCSTR lpszName, LPSTR lpszType)
     292  return (HRSRC) res;
     293}
     294//******************************************************************************
     295//******************************************************************************
     296HRSRC Win32Pe2LxImage::findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
    294297{
    295298 Win32Resource *res = NULL;
     
    297300 int   i;
    298301 LPSTR szType = (LPSTR)lpszType;
    299 
    300     if(fNativePEImage == TRUE) {
    301         return (HRSRC) getPEResource((ULONG)lpszName, (ULONG)lpszType);
    302     }
    303     //else converted win32 exe/dll
    304302
    305303    if(HIWORD(lpszType) != 0) {//type name, translate to id
     
    347345                lpszName = (LPCSTR)atoi(&lpszName[1]);
    348346        }
    349         else    lpszName = (LPCSTR)ConvertNameId(hinstance, (char *)lpszName);
     347        else    lpszName = (LPCSTR)convertNameId((char *)lpszName);
    350348    }
    351349    else dprintf(("FindResource %d\n", (int)lpszName));
     
    377375}
    378376//******************************************************************************
    379 //******************************************************************************
    380 HRSRC Win32Image::findResourceW(LPWSTR lpszName, LPWSTR lpszType)
    381 {
    382  Win32Resource *res = NULL;
     377//TODO:
     378//******************************************************************************
     379HRSRC Win32LxImage::findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
     380{
     381    return 0;
     382}
     383//******************************************************************************
     384//******************************************************************************
     385HRSRC Win32ImageBase::findResourceW(LPWSTR lpszName, LPWSTR lpszType, ULONG lang)
     386{
    383387 HRSRC hres;
    384  LPSTR szType = (LPSTR)lpszType;
    385  int   i;
    386388 char *astring1 = NULL, *astring2 = NULL;
    387389
    388     if(fNativePEImage == TRUE) {//load resources directly from res section
    389         if(HIWORD(lpszType) != 0) {
    390                 char *resname = UnicodeToAsciiString(lpszType);
    391         }
    392         else    astring1 = (char *)lpszType;
    393 
    394         if(HIWORD(lpszName) != 0) {
    395                 astring2 = UnicodeToAsciiString(lpszName);
    396         }
    397         else    astring2 = (char *)lpszName;
    398 
    399         hres = (HRSRC) getPEResource((ULONG)astring1, (ULONG)astring1);
    400         if(astring1) FreeAsciiString(astring1);
    401         if(astring2) FreeAsciiString(astring2);
    402 
    403         return(hres);
    404     }
    405     //else converted win32 exe/dll
    406     if(HIWORD(lpszType) != 0) {//type name, translate to id
    407         char *resname = UnicodeToAsciiString(lpszType);
    408         for(i=0;i<MAX_RES;i++) {
    409             if(strcmp(resname, ResTypes[i]) == 0)
    410                 break;
    411         }
    412         if(i == MAX_RES) {//custom resource type, stored as rcdata
    413                 dprintf(("FindResourceW custom type %s\n", resname));
    414             i = NTRT_RCDATA;
    415         }
    416         FreeAsciiString(resname);
    417         lpszType = (LPWSTR)i;
    418 
    419         szType = (LPSTR)lpszType;
    420     }
    421     switch((int)szType) {
    422     case NTRT_GROUP_ICON:
    423         szType = (LPSTR)NTRT_ICON;
    424         break;
    425     case NTRT_GROUP_CURSOR:
    426         szType = (LPSTR)NTRT_CURSOR;
    427         break;
    428     case NTRT_VERSION:
    429         szType = (LPSTR)NTRT_RCDATA;
    430         break;
    431     case NTRT_STRING:
    432     case NTRT_MENU:
    433     case NTRT_ICON:
    434     case NTRT_BITMAP:
    435     case NTRT_CURSOR:
    436     case NTRT_DIALOG:
    437     case NTRT_RCDATA:
    438     case NTRT_ACCELERATORS:
    439         szType = (LPSTR)lpszType;
    440         break;
    441     default: //unknown are stored as rcdata
    442         szType = (LPSTR)NTRT_RCDATA;
    443         break;
    444     }
    445     dprintf(("FindResourceW type %d\n", szType));
    446 
    447     if(HIWORD(lpszName) != 0) {//convert string name identifier to numeric id
    448         astring1 = UnicodeToAsciiString(lpszName);
    449         dprintf(("FindResourceW %X %s\n", hinstance, astring1));
    450         if(astring1[0] == '#') {// #344
    451                 lpszName = (LPWSTR)atoi(&astring1[1]);
    452         }
    453         else    lpszName = (LPWSTR)ConvertNameId(hinstance, (char *)astring1);
    454     }
    455     else dprintf(("FindResourceW %X %d\n", hinstance, (int)lpszName));
    456 
    457     hres = O32_FindResource(hinstance, (LPCSTR)lpszName, (LPCSTR)szType);
    458     if(hres)
    459     {
    460         switch((ULONG)szType) {
    461         case NTRT_MENU:
    462                 res = new Win32MenuRes(this, hres, (ULONG)lpszName, (ULONG)szType);
    463                 break;
    464         default:
    465                 res = new Win32Resource(this, hres, (ULONG)lpszName, (ULONG)szType);
    466                 break;
    467         }
    468     }
    469 
    470     if(hres == NULL && HIWORD(lpszName) == 0 && (int)szType == NTRT_STRING) {
    471         hres = O32_FindResource(hinstance, (LPCSTR)(((ULONG)lpszName - 1)*16), (LPCSTR)NTRT_RCDATA);
    472         if(hres)
    473         {
    474                 res = new Win32Resource(this, hres, (ULONG)lpszName, (ULONG)szType);
    475         }
    476         else    dprintf(("FindResourceW can't find string %d\n", (int)lpszName));
    477     }
    478     if(astring1)    FreeAsciiString(astring1);
    479 
    480     dprintf(("FindResourceW returned %X (%X)\n", hres, GetLastError()));
    481 
    482     return (HRSRC)res;
    483 }
    484 //******************************************************************************
    485 //******************************************************************************
    486 ULONG Win32Image::getResourceSizeA(LPCSTR lpszName, LPSTR lpszType)
    487 {
    488     if(fNativePEImage == TRUE) {
    489         return getPEResourceSize((ULONG)lpszName, (ULONG)lpszType);
    490     }
     390    if(HIWORD(lpszType) != 0) {
     391                astring1 = UnicodeToAsciiString(lpszType);
     392    }
     393    else        astring1 = (char *)lpszType;
     394
     395    if(HIWORD(lpszName) != 0) {
     396                astring2 = UnicodeToAsciiString(lpszName);
     397    }
     398    else        astring2 = (char *)lpszName;
     399
     400    hres = (HRSRC) findResourceA(astring1, astring2);
     401    if(astring1) FreeAsciiString(astring1);
     402    if(astring2) FreeAsciiString(astring2);
     403
     404    return(hres);
     405}
     406//******************************************************************************
     407//TODO:
     408//******************************************************************************
     409ULONG Win32Pe2LxImage::getResourceSizeA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
     410{
    491411    DebugInt3();
    492412    return 0;
    493413}
    494414//******************************************************************************
    495 //******************************************************************************
    496 ULONG Win32Image::getResourceSizeW(LPCWSTR lpszName, LPWSTR lpszType)
     415//TODO:
     416//******************************************************************************
     417ULONG Win32LxImage::getResourceSizeA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
     418{
     419    DebugInt3();
     420    return 0;
     421}
     422//******************************************************************************
     423//******************************************************************************
     424ULONG Win32PeLdrImage::getResourceSizeA(LPCSTR lpszName, LPSTR lpszType, ULONG lang)
     425{
     426    return getPEResourceSize((ULONG)lpszName, (ULONG)lpszType, lang);
     427}
     428//******************************************************************************
     429//******************************************************************************
     430ULONG Win32ImageBase::getResourceSizeW(LPCWSTR lpszName, LPWSTR lpszType, ULONG lang)
    497431{
    498432 char *astring1 = NULL, *astring2 = NULL;
    499433 ULONG ressize;
    500434
    501     if(fNativePEImage == TRUE) {//load resources directly from res section
    502         if(HIWORD(lpszType) != 0) {
     435    if(HIWORD(lpszType) != 0) {
    503436                char *resname = UnicodeToAsciiString(lpszType);
    504         }
    505         else    astring1 = (char *)lpszType;
    506 
    507         if(HIWORD(lpszName) != 0) {
     437    }
     438    else        astring1 = (char *)lpszType;
     439
     440    if(HIWORD(lpszName) != 0) {
    508441                astring2 = UnicodeToAsciiString((LPWSTR)lpszName);
    509         }
    510         else    astring2 = (char *)lpszName;
    511 
    512         ressize =  getPEResourceSize((ULONG)astring1, (ULONG)astring1);
    513         if(astring1) FreeAsciiString(astring1);
    514         if(astring2) FreeAsciiString(astring2);
    515 
    516         return(ressize);
    517     }
    518     DebugInt3();
    519     return 0;
    520 }
    521 //******************************************************************************
    522 //******************************************************************************
     442    }
     443    else        astring2 = (char *)lpszName;
     444
     445    ressize =  getResourceSizeA(astring1, astring2, lang);
     446    if(astring1) FreeAsciiString(astring1);
     447    if(astring2) FreeAsciiString(astring2);
     448
     449    return(ressize);
     450}
     451//******************************************************************************
     452//******************************************************************************
     453ULONG Win32Pe2LxImage::getVersionSize()
     454{
     455    if(getVersionId() == -1) {
     456        dprintf(("GetVersionSize: %s has no version resource!\n", szModule));
     457        return(0);
     458    }
     459    return OSLibGetResourceSize(hinstance, getVersionId());
     460}
     461//******************************************************************************
     462//******************************************************************************
     463BOOL Win32Pe2LxImage::getVersionStruct(char *verstruct, ULONG bufLength)
     464{
     465    if(getVersionId() == -1) {
     466        dprintf(("GetVersionStruct: %s has no version resource!\n", szModule));
     467        return(FALSE);
     468    }
     469    return OSLibGetResource(hinstance, getVersionId(), verstruct, bufLength);
     470}
     471//******************************************************************************
     472//******************************************************************************
     473ULONG Win32PeLdrImage::getVersionSize()
     474{
     475    return getResourceSizeA((LPCSTR)1, (LPSTR)NTRT_VERSION);
     476}
     477//******************************************************************************
     478//******************************************************************************
     479BOOL Win32PeLdrImage::getVersionStruct(char *verstruct, ULONG bufLength)
     480{
     481 PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
     482
     483  pData = getPEResourceEntry(1, NTRT_VERSION);
     484  if(pData == NULL) {
     485        dprintf(("Win32PeLdrImage::getVersionStruct: couldn't find version resource!"));
     486        return 0;
     487  }
     488  return pData->Size;
     489}
     490//******************************************************************************
     491//******************************************************************************
     492ULONG Win32LxImage::getVersionSize()
     493{
     494//    return getResourceSizeA((LPCSTR)1, (LPSTR)NTRT_VERSION);
     495  return 0;
     496}
     497//******************************************************************************
     498//******************************************************************************
     499BOOL Win32LxImage::getVersionStruct(char *verstruct, ULONG bufLength)
     500{
     501 PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
     502
     503//  pData = getPEResourceEntry(1, NTRT_VERSION);
     504  if(pData == NULL) {
     505        dprintf(("Win32PeLdrImage::getVersionStruct: couldn't find version resource!"));
     506        return 0;
     507  }
     508  return pData->Size;
     509}
     510//******************************************************************************
     511//******************************************************************************
  • trunk/src/kernel32/winres.cpp

    r933 r956  
    1 /* $Id: winres.cpp,v 1.18 1999-09-14 16:56:08 sandervl Exp $ */
     1/* $Id: winres.cpp,v 1.19 1999-09-15 23:38:02 sandervl Exp $ */
    22
    33/*
     
    2828#include <winres.h>
    2929#include <misc.h>
    30 #include <nameid.h>
    31 #include <winexe.h>
     30#include <winexepe2lx.h>
     31#include <windllpe2lx.h>
    3232#include "cvtresource.h"
    3333#include <vmutex.h>
    3434
    3535VMutex resmutex;
     36
     37char *ResTypes[MAX_RES] =
     38      {"niks", "CURSOR", "BITMAP", "ICON", "MENU", "DIALOG", "STRING",
     39       "FONTDIR", "FONT", "ACCELERATOR", "RCDATA",  "MESSAGETABLE",
     40       "GROUP_CURSOR", "niks", "GROUP_ICON", "niks", "VERSION"};
    3641
    3742//******************************************************************************
     
    9297        os2resdata(NULL), winresdata(NULL), resType(RSRC_CUSTOMNODATA)
    9398{
    94   resmutex.enter();
    95   next           = module->winres;
    96   module->winres = this;
    97   resmutex.leave();
    98 
     99  next       = NULL;
    99100  module     = NULL;
     101
    100102  id         = -1;
    101103  type       = -1;
     
    109111//******************************************************************************
    110112//******************************************************************************
    111 Win32Resource::Win32Resource(Win32Image *module, HRSRC hRes, ULONG id, ULONG type) :
     113Win32Resource::Win32Resource(Win32ImageBase *module, HRSRC hRes, ULONG id, ULONG type) :
    112114        os2resdata(NULL), winresdata(NULL), resType(RSRC_PE2LX)
    113115{
     
    168170//******************************************************************************
    169171//******************************************************************************
    170 Win32Resource::Win32Resource(Win32Image *module, ULONG id, ULONG type,
     172Win32Resource::Win32Resource(Win32ImageBase *module, ULONG id, ULONG type,
    171173                 ULONG size, char *resdata) : hres(NULL),
    172174        os2resdata(NULL), winresdata(NULL), resType(RSRC_PELOADER)
     
    246248    case NTRT_MENU:
    247249    case NTRT_DIALOG:
    248         newid = module->getWin32ResourceId(id);
     250    {
     251//TODO->!!!!
     252//        newid = ((Win32Pe2LxImage *)module)->getWin32ResourceId(id);
     253//TODO->!!!!
    249254
    250255        rc = DosGetResource((HMODULE)module->hinstance, RT_RCDATA, (int)newid, (PPVOID)&resdata);
     
    256261        memcpy(winresdata, resdata, ressize);
    257262        break;
     263    }
    258264
    259265    //TODO:not yet implemented
     
    329335   }
    330336   return os2resdata;
     337}
     338//******************************************************************************
     339//return size of converted win32 resource
     340//******************************************************************************
     341ULONG Win32Resource::getOS2Size()
     342{
     343  switch(type) {
     344    case NTRT_NEWBITMAP:
     345    case NTRT_BITMAP:
     346        return QueryConvertedBitmapSize((WINBITMAPINFOHEADER *)winresdata, ressize);
     347
     348    case NTRT_CURSOR:
     349        return QueryConvertedCursorSize((CursorComponent *)winresdata, ressize);
     350
     351    case NTRT_ICON:
     352        return QueryConvertedIconSize((WINBITMAPINFOHEADER *)winresdata, ressize);
     353
     354    case NTRT_GROUP_ICON:
     355    case NTRT_GROUP_CURSOR:
     356    case NTRT_ACCELERATORS:
     357    case NTRT_NEWMENU:
     358    case NTRT_MENU:
     359    case NTRT_NEWDIALOG:
     360    case NTRT_DIALOG:
     361    case NTRT_FONTDIR:
     362    case NTRT_FONT:
     363    case NTRT_MESSAGETABLE:
     364    case NTRT_RCDATA:
     365    case NTRT_VERSION:
     366    case NTRT_STRING:
     367    default:
     368        dprintf(("Win32Resource::getOS2Size SHOULDN'T BE CALLED for this resource type (%d) (NOT IMPLEMENTED)!!", type));
     369        break;
     370  }
     371  return 0;
    331372}
    332373//******************************************************************************
     
    435476//******************************************************************************
    436477//******************************************************************************
    437 void Win32Resource::destroyAll(Win32Image *module)
     478void Win32Resource::destroyAll(Win32ImageBase *module)
    438479{
    439480 Win32Resource *res = module->winres, *next;
  • trunk/src/kernel32/winresmenu.cpp

    r761 r956  
    1 /* $Id: winresmenu.cpp,v 1.2 1999-08-31 17:15:30 sandervl Exp $ */
     1/* $Id: winresmenu.cpp,v 1.3 1999-09-15 23:38:02 sandervl Exp $ */
    22
    33/*
     
    2323#include <winresmenu.h>
    2424#include <misc.h>
    25 #include <nameid.h>
    26 #include <winexe.h>
     25#include <winexebase.h>
    2726#include "cvtresource.h"
    2827
    2928//******************************************************************************
    3029//******************************************************************************
    31 Win32MenuRes::Win32MenuRes(Win32Image *module, HRSRC hRes, ULONG id, ULONG type)
     30Win32MenuRes::Win32MenuRes(Win32ImageBase *module, HRSRC hRes, ULONG id, ULONG type)
    3231               : Win32Resource(module, hRes, id, type)
    3332{
     
    3534//******************************************************************************
    3635//******************************************************************************
    37 Win32MenuRes::Win32MenuRes(Win32Image *module, ULONG id, ULONG type,
     36Win32MenuRes::Win32MenuRes(Win32ImageBase *module, ULONG id, ULONG type,
    3837                           ULONG size, char *resdata)
    3938               : Win32Resource(module, id, type, size, resdata)
  • trunk/src/kernel32/wintls.cpp

    r617 r956  
    1 /* $Id: wintls.cpp,v 1.4 1999-08-22 11:11:11 sandervl Exp $ */
     1/* $Id: wintls.cpp,v 1.5 1999-09-15 23:38:02 sandervl Exp $ */
    22/*
    33 * Win32 TLS API functions
     
    1010 */
    1111#include <os2win.h>
    12 #include <winimage.h>
     12#include <string.h>
     13#include <winimagebase.h>
    1314#include <thread.h>
    1415#include <wprocess.h>
     
    1819//******************************************************************************
    1920//******************************************************************************
    20 void Win32Image::tlsAlloc()     //Allocate TLS index for this module
     21void Win32ImageBase::tlsAlloc() //Allocate TLS index for this module
    2122{
    2223   if(!tlsAddress)
     
    2930        return;         
    3031   }
    31    dprintf(("Win32Image::tlsAlloc (%d) for module %x", tlsIndex, hinstance));
     32   dprintf(("Win32ImageBase::tlsAlloc (%d) for module %x", tlsIndex, hinstance));
    3233}
    3334//******************************************************************************
    3435//******************************************************************************
    35 void Win32Image::tlsDelete()    //Free TLS index for this module
     36void Win32ImageBase::tlsDelete()        //Free TLS index for this module
    3637{
    3738   if(!tlsAddress)
     
    4344        return;         
    4445   }
    45    dprintf(("Win32Image::tlsDestroy (%d) for module %x", tlsIndex, hinstance));
     46   dprintf(("Win32ImageBase::tlsDestroy (%d) for module %x", tlsIndex, hinstance));
    4647   TlsFree(tlsIndex);
    4748   tlsIndex = -1;
     
    4950//******************************************************************************
    5051//******************************************************************************
    51 void Win32Image::tlsAttachThread()      //setup TLS structures for new thread
     52void Win32ImageBase::tlsAttachThread()  //setup TLS structures for new thread
    5253{
    5354 EXCEPTION_FRAME exceptFrame;
     
    6667   }
    6768
    68    dprintf(("Win32Image::tlsAttachThread for module %x, thread id %x", hinstance, GetCurrentThreadId()));
     69   dprintf(("Win32ImageBase::tlsAttachThread for module %x, thread id %x", hinstance, GetCurrentThreadId()));
    6970   dprintf(("tlsAddress:      %x", tlsAddress));
    7071   dprintf(("tlsInitSize:     %x", tlsInitSize));
     
    105106//******************************************************************************
    106107//******************************************************************************
    107 void Win32Image::tlsDetachThread()      //destroy TLS structures
     108void Win32ImageBase::tlsDetachThread()  //destroy TLS structures
    108109{
    109110 EXCEPTION_FRAME exceptFrame;
     
    115116        return;
    116117
    117    dprintf(("Win32Image::tlsDetachThread for module %x, thread id %x", hinstance, GetCurrentThreadId()));
     118   dprintf(("Win32ImageBase::tlsDetachThread for module %x, thread id %x", hinstance, GetCurrentThreadId()));
    118119
    119120   if((ULONG)*tlsCallBackAddr != 0) {
  • trunk/src/kernel32/wprocess.cpp

    r712 r956  
    1 /* $Id: wprocess.cpp,v 1.30 1999-08-27 16:51:01 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.31 1999-09-15 23:38:03 sandervl Exp $ */
    22
    33/*
     
    1515#include <string.h>
    1616
    17 #include "unicode.h"
    18 #include "windll.h"
    19 #include "winexe.h"
     17#include <unicode.h>
     18#include <windllbase.h>
     19#include <winexebase.h>
     20#include <windllpeldr.h>
    2021
    2122#ifdef __IBMCPP__
     
    3233#include "mmap.h"
    3334
    34 BOOL      fExeStarted = FALSE;
    3535BOOL      fFreeLibrary = FALSE;
    3636
     
    199199   return GetFS();
    200200}
    201 /******************************************************************************/
    202 //******************************************************************************
    203 void WIN32API RegisterExe(WIN32EXEENTRY EntryPoint, PIMAGE_TLS_CALLBACK *TlsCallbackAddr,
    204                           LPDWORD TlsIndexAddr, ULONG TlsInitSize,
    205                           ULONG TlsTotalSize, LPVOID TlsAddress,
    206                           LONG Win32TableId, LONG NameTableId, LONG VersionResId,
    207                          LONG Pe2lxVersion, HINSTANCE hinstance, ULONG dwReserved)
    208 {
    209   if(WinExe != NULL) //should never happen
    210         delete(WinExe);
    211 
    212   CheckVersion(Pe2lxVersion, OSLibGetDllName(hinstance));
    213 
    214   if(getenv("WIN32_IOPL2")) {
    215     io_init1();
    216   }
    217 
    218   Win32Exe *winexe;
    219 
    220   winexe = new Win32Exe(hinstance, NameTableId, Win32TableId);
    221 
    222   if(winexe) {
    223         dprintf(("RegisterExe Win32TableId = %x", Win32TableId));
    224         dprintf(("RegisterExe NameTableId  = %x", NameTableId));
    225         dprintf(("RegisterExe VersionResId = %x", VersionResId));
    226         dprintf(("RegisterExe Pe2lxVersion = %x", Pe2lxVersion));
    227 
    228         winexe->setVersionId(VersionResId);
    229         winexe->setEntryPoint((ULONG)EntryPoint);
    230         winexe->setTLSAddress(TlsAddress);
    231         winexe->setTLSInitSize(TlsInitSize);
    232         winexe->setTLSTotalSize(TlsTotalSize);
    233         winexe->setTLSIndexAddr(TlsIndexAddr);
    234         winexe->setTLSCallBackAddr(TlsCallbackAddr);
    235 
    236         winexe->start();
    237   }
    238   else {
    239         eprintf(("Win32Exe creation failed!\n"));
    240         DebugInt3();
    241         return;
    242   }
    243 }
    244 //******************************************************************************
    245 //******************************************************************************
    246 ULONG WIN32API RegisterDll(WIN32DLLENTRY pfnDllEntry, PIMAGE_TLS_CALLBACK *TlsCallbackAddr,
    247                            LPDWORD TlsIndexAddr, ULONG TlsInitSize,
    248                            ULONG TlsTotalSize, LPVOID TlsAddress,
    249                            LONG Win32TableId, LONG NameTableId, LONG VersionResId,
    250                            LONG Pe2lxVersion, HINSTANCE hinstance, ULONG dwAttachType)
    251 {
    252  char *name;
    253 
    254   Win32Dll *winmod = Win32Dll::findModule(hinstance);
    255   if(dwAttachType == 0)
    256   { //Process attach
    257         if(getenv("WIN32_IOPL2")) {
    258                 io_init1();
    259         }
    260         name = OSLibGetDllName(hinstance);
    261         CheckVersion(Pe2lxVersion, name);
    262 
    263         dprintf(("RegisterDll %X %s reason %d\n", hinstance, name, dwAttachType));
    264         dprintf(("RegisterDll Win32TableId = %x", Win32TableId));
    265         dprintf(("RegisterDll NameTableId  = %x", NameTableId));
    266         dprintf(("RegisterDll VersionResId = %x", VersionResId));
    267         dprintf(("RegisterDll Pe2lxVersion = %x", Pe2lxVersion));
    268 
    269         if(winmod != NULL) {
    270                 //dll manually loaded by PE loader (Win32Dll::init)
    271                 winmod->OS2DllInit(hinstance, NameTableId, Win32TableId, pfnDllEntry);
    272         }
    273         else {
    274                 //converted win32 dll loaded by OS/2 loader
    275                 winmod = new Win32Dll(hinstance, NameTableId, Win32TableId, pfnDllEntry);
    276                 if(winmod == NULL) {
    277                         eprintf(("Failed to allocate module object!\n"));
    278                         DebugInt3();
    279                         return 0;                    //fail dll load
    280                 }
    281         }
    282         winmod->setTLSAddress(TlsAddress);
    283         winmod->setTLSInitSize(TlsInitSize);
    284         winmod->setTLSTotalSize(TlsTotalSize);
    285         winmod->setTLSIndexAddr(TlsIndexAddr);
    286         winmod->setTLSCallBackAddr(TlsCallbackAddr);
    287 
    288         /* @@@PH 1998/03/17 console devices initialization */
    289         iConsoleDevicesRegister();
    290 
    291         //SvL: 19-8-'98
    292         winmod->AddRef();
    293         winmod->setVersionId(VersionResId);
    294 
    295         winmod->attachProcess();
    296    }
    297    else {//process detach
    298         if(winmod != NULL && !fFreeLibrary) {
    299                 return 0;   //don't unload (OS/2 dll unload bug)
    300         }
    301         //Runtime environment could already be gone, so don't do this
    302         // dprintf(("KERNEL32: Dll Removed by FreeLibrary or ExitProcess\n"));
    303    }
    304    return 1;   //success
    305 }
    306201//******************************************************************************
    307202//******************************************************************************
     
    346241BOOL WIN32API FreeLibrary(HINSTANCE hinstance)
    347242{
    348  Win32Dll *winmod;
     243 Win32DllBase *winmod;
    349244 BOOL rc;
    350245
    351246  dprintf(("FreeLibrary"));
    352   winmod = Win32Dll::findModule(hinstance);
     247  winmod = Win32DllBase::findModule(hinstance);
    353248  if(winmod) {
    354     winmod->Release();
    355     return(TRUE);
     249        winmod->Release();
     250        return(TRUE);
    356251  }
    357252  dprintf(("KERNEL32: FreeLibrary %s %X\n", OSLibGetDllName(hinstance), hinstance));
     
    366261/******************************************************************************/
    367262/******************************************************************************/
    368 static HINSTANCE iLoadLibraryA(LPCTSTR lpszLibFile)
     263static HINSTANCE iLoadLibraryA(LPCTSTR lpszLibFile, DWORD dwFlags)
    369264{
    370265 char        modname[CCHMAXPATH];
    371266 HINSTANCE   hDll;
    372  Win32Dll  *module;
     267 Win32DllBase *module;
    373268
    374269  hDll = O32_LoadLibrary(lpszLibFile);
     
    388283  }
    389284
    390   if(Win32Image::isPEImage((char *)modname)) {
    391     module = Win32Dll::findModule((char *)modname);
    392     if(module) {//don't load it again
    393         module->AddRef();
    394         return module->getInstanceHandle();
    395     }
    396 
    397     module = new Win32Dll((char *)modname);
    398     if(module == NULL)
    399         return(0);
    400 
    401     module->init(0);
    402     if(module->getError() != NO_ERROR) {
    403         dprintf(("LoadLibary %s failed (::init)\n", lpszLibFile));
    404         delete(module);
    405         return(0);
    406     }
    407     if(module->attachProcess() == FALSE) {
    408         dprintf(("LoadLibary %s failed (::attachProcess)\n", lpszLibFile));
    409         delete(module);
    410         return(0);
    411     }
    412     module->AddRef();
    413     return module->getInstanceHandle();
    414   }
    415   else
    416     return(0);
    417 }
    418 
    419 
     285  if(Win32ImageBase::isPEImage((char *)modname))
     286  {
     287        module = Win32DllBase::findModule((char *)modname);
     288        if(module) {//don't load it again
     289                module->AddRef();
     290                return module->getInstanceHandle();
     291        }
     292
     293        Win32PeLdrDll *peldrDll = new Win32PeLdrDll((char *)modname);
     294        if(peldrDll == NULL)
     295                return(0);
     296
     297        peldrDll->init(0);
     298        if(peldrDll->getError() != NO_ERROR) {
     299                dprintf(("LoadLibary %s failed (::init)\n", lpszLibFile));
     300                delete(peldrDll);
     301                return(0);
     302        }
     303        if(dwFlags & DONT_RESOLVE_DLL_REFERENCES) {
     304                peldrDll->setNoEntryCalls();
     305        }
     306
     307        if(peldrDll->attachProcess() == FALSE) {
     308                dprintf(("LoadLibary %s failed (::attachProcess)\n", lpszLibFile));
     309                delete(peldrDll);
     310                return(0);
     311        }
     312        peldrDll->AddRef();
     313        return peldrDll->getInstanceHandle();
     314  }
     315  else  return(0);
     316}
     317//******************************************************************************
     318//******************************************************************************
    420319HINSTANCE WIN32API LoadLibraryA(LPCTSTR lpszLibFile)
    421320{
     
    425324           lpszLibFile));
    426325
    427   hDll = iLoadLibraryA(lpszLibFile);
     326  hDll = iLoadLibraryA(lpszLibFile, 0);
    428327  if (hDll == 0)
    429328  {
     
    438337
    439338      // now try again without fully qualified path
    440       hDll = iLoadLibraryA(pszName);
     339      hDll = iLoadLibraryA(pszName, 0);
    441340    }
    442341  }
     
    448347HINSTANCE WIN32API LoadLibraryExA(LPCTSTR lpszLibFile, HANDLE hFile, DWORD dwFlags)
    449348{
    450  Win32Dll   *module;
    451  HINSTANCE   hDll;
     349 HINSTANCE     hDll;
    452350
    453351  dprintf(("KERNEL32:  LoadLibraryExA %s (%X)\n", lpszLibFile, dwFlags));
    454   hDll = O32_LoadLibrary(lpszLibFile);
    455   if(hDll) {
    456         return hDll;    //converted dll or win32k took care of it
    457   }
    458 
    459   if(Win32Image::isPEImage((char *)lpszLibFile)) {
    460     module = Win32Dll::findModule((char *)lpszLibFile);
    461     if(module) {//don't load it again
    462         module->AddRef();
    463         return module->getInstanceHandle();
     352  hDll = iLoadLibraryA(lpszLibFile, dwFlags);
     353  if (hDll == 0)
     354  {
     355    char * pszName;
     356
     357    // remove path from the image name
     358    pszName = strrchr((char *)lpszLibFile,
     359                      '\\');
     360    if (pszName != NULL)
     361    {
     362      pszName++;                // skip backslash
     363
     364      // now try again without fully qualified path
     365      hDll = iLoadLibraryA(pszName, dwFlags);
    464366    }
    465 
    466     module = new Win32Dll((char *)lpszLibFile);
    467 
    468     if(module == NULL)
    469         return(0);
    470 
    471     module->init(0);
    472     if(module->getError() != NO_ERROR) {
    473         dprintf(("LoadLibary %s failed (::init)\n", lpszLibFile));
    474         delete(module);
    475         return(0);
    476     }
    477     if(dwFlags & DONT_RESOLVE_DLL_REFERENCES) {
    478         module->setNoEntryCalls();
    479     }
    480     if(module->attachProcess() == FALSE) {
    481         dprintf(("LoadLibary %s failed (::attachProcess)\n", lpszLibFile));
    482         delete(module);
    483         return(0);
    484     }
    485     module->AddRef();
    486     return module->getInstanceHandle();
    487   }
    488   return(0);
     367  }
     368
     369  return hDll;
    489370}
    490371//******************************************************************************
     
    562443{
    563444 DWORD rc;
    564  Win32Image *module;
     445 Win32ImageBase *module;
    565446 char *fpath = NULL;
    566447
    567448  dprintf(("GetModuleFileName %X", hinstModule));
    568449  if(hinstModule == 0 || hinstModule == -1 || (WinExe && hinstModule == WinExe->getInstanceHandle())) {
    569         module = (Win32Image *)WinExe;
     450        module = (Win32ImageBase *)WinExe;
    570451  }
    571452  else {
    572         module = (Win32Image *)Win32Dll::findModule(hinstModule);
     453        module = (Win32ImageBase *)Win32DllBase::findModule(hinstModule);
    573454  }
    574455
     
    608489{
    609490 HANDLE    hMod;
    610  Win32Dll *windll;
     491 Win32DllBase *windll;
    611492 char      szModule[CCHMAXPATH];
    612493 BOOL      fDllModule = FALSE;
     
    636517        }
    637518        else {
    638                 windll = Win32Dll::findModule(szModule);
     519                windll = Win32DllBase::findModule(szModule);
    639520                if(windll) {
    640521                        hMod = windll->getInstanceHandle();
     
    722603FARPROC WIN32API GetProcAddress(HMODULE hModule, LPCSTR lpszProc)
    723604{
    724  Win32Dll *winmod;
     605 Win32DllBase *winmod;
    725606 FARPROC   proc;
    726607 ULONG     ulAPIOrdinal;
    727608
    728   winmod = Win32Dll::findModule((HINSTANCE)hModule);
     609  winmod = Win32DllBase::findModule((HINSTANCE)hModule);
    729610  if(winmod) {
    730     ulAPIOrdinal = (ULONG)lpszProc;
    731     if (ulAPIOrdinal <= 0x0000FFFF) {
    732         return (FARPROC)winmod->getApi((int)ulAPIOrdinal);
    733     }
    734     else    return (FARPROC)winmod->getApi((char *)lpszProc);
     611        ulAPIOrdinal = (ULONG)lpszProc;
     612        if (ulAPIOrdinal <= 0x0000FFFF) {
     613                proc = (FARPROC)winmod->getApi((int)ulAPIOrdinal);
     614        }
     615        else    proc = (FARPROC)winmod->getApi((char *)lpszProc);
     616        if(proc == 0) {
     617                SetLastError(ERROR_PROC_NOT_FOUND);
     618        }
     619        return proc;
    735620  }
    736621  proc = O32_GetProcAddress(hModule, lpszProc);
     
    743628BOOL SYSTEM GetVersionStruct(char *modname, char *verstruct, ULONG bufLength)
    744629{
    745  HINSTANCE   hinstance;
    746  Win32Image *winimage;
     630 HINSTANCE       hinstance;
     631 Win32ImageBase *winimage;
    747632
    748633  dprintf(("GetVersionStruct"));
     
    753638  }
    754639  if(WinExe && WinExe->getInstanceHandle() == hinstance) {
    755         winimage = (Win32Image *)WinExe;
     640        winimage = (Win32ImageBase *)WinExe;
    756641  }
    757642  else {
    758         winimage = (Win32Image *)Win32Dll::findModule(hinstance);
     643        winimage = (Win32ImageBase *)Win32DllBase::findModule(hinstance);
    759644        if(winimage == NULL) {
    760645                dprintf(("GetVersionStruct can't find Win32Image for %s\n", modname));
     
    762647        }
    763648  }
    764   if(winimage->getVersionId() == -1) {
    765     dprintf(("GetVersionStruct: %s has no version resource!\n", modname));
    766     return(FALSE);
    767   }
    768   return OSLibGetResource(hinstance, winimage->getVersionId(), verstruct, bufLength);
     649  return winimage->getVersionStruct(verstruct, bufLength);
    769650}
    770651//******************************************************************************
     
    772653ULONG SYSTEM GetVersionSize(char *modname)
    773654{
    774  HINSTANCE   hinstance;
    775  Win32Image *winimage;
     655 HINSTANCE       hinstance;
     656 Win32ImageBase *winimage;
    776657
    777658  dprintf(("GetVersionSize of %s\n", modname));
    778659  hinstance = OSLibQueryModuleHandle(modname);
    779660  if(hinstance == 0) {
    780     dprintf(("GetVersionSize can't find handle for %s\n", modname));
    781     return(FALSE);
     661        dprintf(("GetVersionSize can't find handle for %s\n", modname));
     662        return(FALSE);
    782663  }
    783664
    784665  if(WinExe && WinExe->getInstanceHandle() == hinstance) {
    785         winimage = (Win32Image *)WinExe;
     666        winimage = (Win32ImageBase *)WinExe;
    786667  }
    787668  else {
    788         winimage = (Win32Image *)Win32Dll::findModule(hinstance);
     669        winimage = (Win32ImageBase *)Win32DllBase::findModule(hinstance);
    789670        if(winimage == NULL) {
    790671                dprintf(("GetVersionSize can't find Win32Image for %s\n", modname));
     
    792673        }
    793674  }
    794   if(winimage->getVersionId() == -1) {
    795         dprintf(("GetVersionSize: %s has no version resource!\n", modname));
    796         return(FALSE);
    797   }
    798   ULONG size = OSLibGetResourceSize(hinstance, winimage->getVersionId());
    799 
    800   dprintf(("Version resource size = %d, id %d\n", size, winimage->getVersionId()));
    801   return(size);
     675  return winimage->getVersionSize();
    802676}
    803677//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.