Changeset 3625 for trunk/src/kernel32


Ignore:
Timestamp:
May 28, 2000, 6:45:14 PM (25 years ago)
Author:
sandervl
Message:

resource handling changes

Location:
trunk/src/kernel32
Files:
12 edited

Legend:

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

    r3461 r3625  
    1 ; $Id: KERNEL32.DEF,v 1.80 2000-04-29 18:26:56 sandervl Exp $
     1; $Id: KERNEL32.DEF,v 1.81 2000-05-28 16:45:11 sandervl Exp $
    22
    33;Created by BLAST for IBM's compiler
     
    10851085    CPUFeatures          @2005
    10861086    InitSystemAndRegistry__Fv @2006
     1087    _ConvertResourceToOS2@12  @2007
    10871088
    10881089;registry apis imported by advapi32
  • trunk/src/kernel32/cvtcursorgrp.cpp

    r3101 r3625  
    1 /* $Id: cvtcursorgrp.cpp,v 1.9 2000-03-13 13:10:09 sandervl Exp $ */
     1/* $Id: cvtcursorgrp.cpp,v 1.10 2000-05-28 16:45:12 sandervl Exp $ */
    22
    33/*
     
    2323#include <string.h>
    2424#include <win32type.h>
     25#include <win32api.h>
     26#include <winconst.h>
    2527#include <wincursor.h>
    26 #include <winres.h>
    2728#include <misc.h>
    2829#include "cvtresource.h"
     30#include <winres.h>
    2931
    3032#define DBG_LOCALLOG    DBG_cvtcursorgrp
    3133#include "dbglocal.h"
    32 
    33 HRSRC WIN32API FindResourceA(HINSTANCE hModule, LPCSTR lpszName, LPCSTR lpszType);
    3434
    3535//******************************************************************************
     
    4141 BITMAPARRAYFILEHEADER2 *bafh, *orgbafh;
    4242 CursorComponent       *cursorhdr;
    43  Win32Resource         *winres;
    4443 void                  *os2cursor;
     44 HRSRC                  hRes;
    4545
    4646  dprintf(("ConvertCursorGroup"));
     
    5353        dprintf2(("Bits    : %d", rdir->wBitCount));
    5454        dprintf2(("ResBytes: %d", rdir->lBytesInRes));
    55         winres     = (Win32Resource *)FindResourceA(module->getInstanceHandle(),
    56                                                     (LPCSTR)rdir->wNameOrdinal,
    57                                                     (LPSTR)NTRT_CURSOR);
    58         groupsize += winres->getOS2Size();
     55        hRes = FindResourceA(module->getInstanceHandle(),
     56                            (LPCSTR)rdir->wNameOrdinal, (LPSTR)NTRT_CURSOR);
     57
     58        groupsize += QueryConvertedResourceSize(module->getInstanceHandle(), (char *)NTRT_CURSOR, hRes);
    5959        rdir++;
    6060  }
     
    6868        bafh->cxDisplay = 0;
    6969        bafh->cyDisplay = 0;
    70         winres          = (Win32Resource *)FindResourceA(module->getInstanceHandle(),
    71                                                          (LPCSTR)rdir->wNameOrdinal,
    72                                                          (LPSTR)NTRT_CURSOR);
    73         if(winres == NULL) {
     70        hRes = FindResourceA(module->getInstanceHandle(),
     71                            (LPCSTR)rdir->wNameOrdinal, (LPSTR)NTRT_CURSOR);
     72
     73        if(hRes == NULL) {
    7474                dprintf(("Can't find cursor!"));
    7575                rdir++;
     
    7777        }
    7878
    79         cursorhdr = (CursorComponent *)winres->lockResource();
    80         os2cursor = ConvertCursor(cursorhdr, winres->getSize(), &os2cursorsize, (int)bafh - (int)orgbafh + sizeof(BITMAPARRAYFILEHEADER2)-sizeof(BITMAPFILEHEADER2));
     79        cursorhdr = (CursorComponent *)LockResource(LoadResource(module->getInstanceHandle(), hRes));
     80        os2cursor = ConvertCursor(cursorhdr, SizeofResource(module->getInstanceHandle(), hRes), &os2cursorsize, (int)bafh - (int)orgbafh + sizeof(BITMAPARRAYFILEHEADER2)-sizeof(BITMAPFILEHEADER2));
    8181
    8282        if(os2cursor == NULL) {
    8383                dprintf(("Can't convert cursor!"));
    84                 delete winres;
    8584                rdir++;
    8685                continue;
     
    9695
    9796        bafh = (BITMAPARRAYFILEHEADER2 *)((int)&bafh->bfh2 + os2cursorsize);
    98         delete winres;
    9997
    10098        rdir++;
  • trunk/src/kernel32/cvticongrp.cpp

    r2802 r3625  
    1 /* $Id: cvticongrp.cpp,v 1.6 2000-02-16 14:25:37 sandervl Exp $ */
     1/* $Id: cvticongrp.cpp,v 1.7 2000-05-28 16:45:12 sandervl Exp $ */
    22
    33/*
     
    2323#include <string.h>
    2424#include <win32type.h>
     25#include <win32api.h>
     26#include <winconst.h>
    2527#include <winicon.h>
    26 #include <winres.h>
    2728#include <misc.h>
    2829#include "cvtresource.h"
     30#include <winres.h>
    2931
    3032#define DBG_LOCALLOG    DBG_cvticongrp
    3133#include "dbglocal.h"
    32 
    33 HRSRC WIN32API FindResourceA(HINSTANCE hModule, LPCSTR lpszName, LPCSTR lpszType);
    3434
    3535//******************************************************************************
     
    4141 BITMAPARRAYFILEHEADER2 *bafh, *orgbafh;
    4242 WINBITMAPINFOHEADER    *iconhdr;
    43  Win32Resource          *winres;
    4443 void                   *os2icon;
     44 HRSRC                   hRes;
    4545
    4646  dprintf(("Icon Group type :%d", ihdr->wType));
     
    5353        dprintf2(("Bits    : %d", rdir->wBitCount));
    5454        dprintf2(("ResBytes: %d", rdir->lBytesInRes));
    55         winres     = (Win32Resource *)FindResourceA(module->getInstanceHandle(),
    56                                                    (LPCSTR)rdir->wNameOrdinal,
    57                                                    (LPSTR)NTRT_ICON);
    58         groupsize += winres->getOS2Size();
     55        hRes = FindResourceA(module->getInstanceHandle(),
     56                             (LPCSTR)rdir->wNameOrdinal, (LPSTR)NTRT_ICON);
     57
     58        groupsize += QueryConvertedResourceSize(module->getInstanceHandle(), (char *)NTRT_ICON, hRes);
    5959        rdir++;
    6060  }
     
    6868        bafh->cxDisplay = 0;
    6969        bafh->cyDisplay = 0;
    70         winres          = (Win32Resource *)FindResourceA(module->getInstanceHandle(),
    71                                                          (LPCSTR)rdir->wNameOrdinal,
    72                                                          (LPSTR)NTRT_ICON);
    73         if(winres == NULL) {
     70        hRes = FindResourceA(module->getInstanceHandle(),
     71                             (LPCSTR)rdir->wNameOrdinal, (LPSTR)NTRT_ICON);
     72
     73        if(hRes == NULL) {
    7474                dprintf(("Can't find icon!"));
    7575                rdir++;
     
    7777        }
    7878
    79         iconhdr = (WINBITMAPINFOHEADER *)winres->lockResource();
    80         os2icon = ConvertIcon(iconhdr, winres->getSize(), &os2iconsize, (int)bafh - (int)orgbafh + sizeof(BITMAPARRAYFILEHEADER2)-sizeof(BITMAPFILEHEADER2));
     79        iconhdr = (WINBITMAPINFOHEADER *)LockResource(LoadResource(module->getInstanceHandle(), hRes));
     80        os2icon = ConvertIcon(iconhdr, SizeofResource(module->getInstanceHandle(), hRes), &os2iconsize, (int)bafh - (int)orgbafh + sizeof(BITMAPARRAYFILEHEADER2)-sizeof(BITMAPFILEHEADER2));
    8181
    8282        if(os2icon == NULL) {
    8383                dprintf(("Can't convert icon!"));
    84                 delete winres;
    8584                rdir++;
    8685                continue;
     
    9695
    9796        bafh = (BITMAPARRAYFILEHEADER2 *)((int)&bafh->bfh2 + os2iconsize);
    98         delete winres;
    9997
    10098        rdir++;
  • trunk/src/kernel32/directory.cpp

    r3611 r3625  
    1 /* $Id: directory.cpp,v 1.21 2000-05-26 18:53:18 sandervl Exp $ */
     1/* $Id: directory.cpp,v 1.22 2000-05-28 16:45:12 sandervl Exp $ */
    22
    33/*
     
    381381    tmp[len -1] = 0;
    382382
    383   dprintf(("RemoveDirectory %S", arg1));
     383  dprintf(("RemoveDirectory %s", arg1));
    384384
    385385  return O32_RemoveDirectory(tmp);
  • trunk/src/kernel32/pefile.cpp

    r2802 r3625  
    1 /* $Id: pefile.cpp,v 1.7 2000-02-16 14:23:11 sandervl Exp $ */
     1/* $Id: pefile.cpp,v 1.8 2000-05-28 16:45:12 sandervl Exp $ */
    22
    33/*
     
    1515#include <pefile.h>
    1616#include <misc.h>
    17 #include <winres.h>
    1817
    1918#define DBG_LOCALLOG    DBG_pefile
  • trunk/src/kernel32/resource.cpp

    r2803 r3625  
    1 /* $Id: resource.cpp,v 1.15 2000-02-16 14:25:45 sandervl Exp $ */
     1/* $Id: resource.cpp,v 1.16 2000-05-28 16:45:12 sandervl Exp $ */
    22
    33/*
     
    1313#include <os2win.h>
    1414#include <unicode.h>
    15 #include "winres.h"
    1615#include <winimagebase.h>
    1716#include <winexebase.h>
     
    7170 *****************************************************************************/
    7271
    73 HRSRC  WIN32API FindResourceExA( HMODULE hModule, LPCSTR lpType,
    74                                     LPCSTR lpName, WORD wLanguage)
     72HRSRC WIN32API FindResourceExA( HMODULE hModule, LPCSTR lpType,
     73                                LPCSTR lpName, WORD wLanguage)
    7574{
    7675 Win32ImageBase *module;
     
    105104 *****************************************************************************/
    106105
    107 HRSRC  WIN32API FindResourceExW(HMODULE hModule,
    108                                 LPCWSTR lpType,
    109                                 LPCWSTR lpName,
    110                                 WORD    wLanguage)
     106HRSRC WIN32API FindResourceExW(HMODULE hModule,
     107                               LPCWSTR lpType,
     108                               LPCWSTR lpName,
     109                               WORD    wLanguage)
    111110{
    112111 Win32ImageBase *module;
     
    117116          return(NULL);
    118117    }
    119 
    120118    return module->findResourceW((LPWSTR)lpName, (LPWSTR)lpType, wLanguage);
    121119}
     
    128126}
    129127//******************************************************************************
     128//hRes == returned by FindResource(Ex) = PIMAGE_RESOURCE_DATA_ENTRY for resource
     129//******************************************************************************
     130HGLOBAL WIN32API LoadResource(HINSTANCE hModule, HRSRC hRes)
     131{
     132  Win32ImageBase *module;
     133
     134  /* @@@PH */
     135  if(HIWORD(hRes) == NULL) {
     136        dprintf(("ERROR: LoadResource %x: invalid hRes %x", hModule, hRes));
     137        return 0;
     138  }
     139
     140  dprintf(("LoadResource %x %X\n", hModule, hRes));
     141  if(hModule == 0 || hModule == -1 || (WinExe && hModule == WinExe->getInstanceHandle())) {
     142        module = (Win32ImageBase *)WinExe;
     143  }
     144  else {
     145        module = (Win32ImageBase *)Win32DllBase::findModule(hModule);
     146  }
     147
     148  return (HGLOBAL)module->getResourceAddr(hRes);
     149}
     150//******************************************************************************
    130151//hRes == returned by FindResource(Ex)
    131152//******************************************************************************
    132 HGLOBAL WIN32API LoadResource(HINSTANCE hModule, HRSRC hRes)
    133 {
    134   Win32Resource *res = (Win32Resource *)hRes;
    135 
    136   dprintf(("LoadResource %x %X\n", hModule, hRes));
    137 
    138   /* @@@PH */
    139   if (HIWORD(res) == NULL) {
    140    dprintf(("LoadResource %x: invalid hRes %x", hModule, hRes));
    141    return 0;
    142   }
    143   else  return (HGLOBAL)res->lockResource();
    144 }
    145 //******************************************************************************
    146 //hRes == returned by FindResource(Ex)
    147 //******************************************************************************
    148153DWORD WIN32API SizeofResource(HINSTANCE hModule, HRSRC hRes)
    149154{
    150  Win32Resource *res = (Win32Resource *)hRes;
    151 
    152     dprintf(("OS2SizeofResource\n"));
    153     if(res == NULL)
    154     return(0);
    155 
    156     return res->getSize();
     155 Win32ImageBase *module;
     156
     157  if(hRes == NULL) {
     158        dprintf(("ERROR: SizeofResource %x: invalid hRes %x", hModule, hRes));
     159        return(0);
     160  }
     161
     162  dprintf(("SizeofResource %x %x", hModule, hRes));
     163
     164  if(hModule == 0 || hModule == -1 || (WinExe && hModule == WinExe->getInstanceHandle())) {
     165        module = (Win32ImageBase *)WinExe;
     166  }
     167  else {
     168        module = (Win32ImageBase *)Win32DllBase::findModule(hModule);
     169  }
     170
     171  return module->getResourceSize(hRes);
    157172}
    158173//******************************************************************************
  • trunk/src/kernel32/winimagebase.cpp

    r3609 r3625  
    1 /* $Id: winimagebase.cpp,v 1.20 2000-05-26 18:42:56 sandervl Exp $ */
     1/* $Id: winimagebase.cpp,v 1.21 2000-05-28 16:45:12 sandervl Exp $ */
    22
    33/*
     
    3232#include <pefile.h>
    3333#include <unicode.h>
    34 #include <winres.h>
    3534#include "oslibmisc.h"
    3635#include "oslibdos.h"
     
    4746    errorState(NO_ERROR), entryPoint(0), fullpath(NULL),
    4847    tlsAddress(0), tlsIndexAddr(0), tlsInitSize(0), tlsTotalSize(0),
    49     tlsCallBackAddr(0), tlsIndex(-1), winres(NULL), pResDir(NULL),
     48    tlsCallBackAddr(0), tlsIndex(-1), pResDir(NULL),
    5049    ulRVAResourceSection(0)
    5150{
     
    7877Win32ImageBase::~Win32ImageBase()
    7978{
    80  Win32Resource *res;
    81 
    82   while(winres)
    83   {
    84         res    = winres->next;
    85         delete(winres);
    86         winres = res;
    87   }
    8879  if(fullpath)
    8980        free(fullpath);
  • trunk/src/kernel32/winimagebase.h

    r3609 r3625  
    1 /* $Id: winimagebase.h,v 1.9 2000-05-26 18:42:56 sandervl Exp $ */
     1/* $Id: winimagebase.h,v 1.10 2000-05-28 16:45:12 sandervl Exp $ */
    22
    33/*
     
    6767        char *getModuleName()         { return szModule; };
    6868
     69        //findResource returns the pointer of the resource's IMAGE_RESOURCE_DATA_ENTRY structure
    6970virtual HRSRC findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang = LANG_GETFIRST);
    7071        HRSRC findResourceW(LPWSTR lpszName, LPWSTR lpszType, ULONG lang = LANG_GETFIRST);
     72
    7173virtual ULONG getResourceSizeA(LPCSTR lpszName, LPSTR lpszType, ULONG lang = LANG_GETFIRST);
    7274        ULONG getResourceSizeW(LPCWSTR lpszName, LPWSTR lpszType, ULONG lang = LANG_GETFIRST);
     
    8082virtual ULONG getVersionSize();
    8183virtual BOOL  getVersionStruct(char *verstruct, ULONG bufLength);
     84
     85        //Returns pointer to data of resource handle
     86        char *getResourceAddr(HRSRC hResource);
     87        ULONG getResourceSize(HRSRC hResource);
    8288
    8389static  BOOL  isPEImage(char *szFileName);
     
    118124        void tlsAlloc();                //Allocate TLS index for this module
    119125        void tlsDelete();               //Destroy TLS index for this module
    120 
    121         Win32Resource        *winres;
    122126
    123127        ULONG                 errorState, entryPoint;
  • trunk/src/kernel32/winimagelx.cpp

    r2802 r3625  
    1 /* $Id: winimagelx.cpp,v 1.6 2000-02-16 14:22:12 sandervl Exp $ */
     1/* $Id: winimagelx.cpp,v 1.7 2000-05-28 16:45:13 sandervl Exp $ */
    22
    33/*
     
    3333#include <pefile.h>
    3434#include <unicode.h>
    35 #include <winres.h>
    3635#include "oslibmisc.h"
    3736#include "initterm.h"
  • trunk/src/kernel32/winimagepeldr.cpp

    r3609 r3625  
    1 /* $Id: winimagepeldr.cpp,v 1.43 2000-05-26 18:42:56 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.44 2000-05-28 16:45:13 sandervl Exp $ */
    22
    33/*
     
    4343#include <pefile.h>
    4444#include <unicode.h>
    45 #include <winres.h>
    4645#include "oslibmisc.h"
    4746#include "initterm.h"
  • trunk/src/kernel32/winimgres.cpp

    r3588 r3625  
    1 /* $Id: winimgres.cpp,v 1.37 2000-05-22 19:08:00 sandervl Exp $ */
     1/* $Id: winimgres.cpp,v 1.38 2000-05-28 16:45:13 sandervl Exp $ */
    22
    33/*
     
    2323#include <misc.h>
    2424#include <winimagebase.h>
    25 #include <winres.h>
    2625#include <unicode.h>
    2726#include <heapstring.h>
     
    3130#define DBG_LOCALLOG    DBG_winimgres
    3231#include "dbglocal.h"
     32
     33#define MAX_RES 17
     34char *ResTypes[MAX_RES] =
     35      {"niks", "CURSOR", "BITMAP", "ICON", "MENU", "DIALOG", "STRING",
     36       "FONTDIR", "FONT", "ACCELERATOR", "RCDATA",  "MESSAGETABLE",
     37       "GROUP_CURSOR", "niks", "GROUP_ICON", "niks", "VERSION"};
    3338
    3439//SvL: VPBuddy bugfix, seems to load bitmaps with type name 'DIB'
     
    262267}
    263268//******************************************************************************
     269//Returns pointer to data of resource handle
     270//******************************************************************************
     271char *Win32ImageBase::getResourceAddr(HRSRC hResource)
     272{
     273 PIMAGE_RESOURCE_DATA_ENTRY pData = (PIMAGE_RESOURCE_DATA_ENTRY)hResource;
     274
     275  if(pData == NULL) {
     276        DebugInt3();
     277        return NULL;
     278  }
     279  //ulRVAResourceSection contains the relative virtual address (relative to the start of the image)
     280  //for the resource section (images loaded by the pe.exe and pe2lx/win32k)
     281  //For LX images, this is 0 as OffsetToData contains a relative offset
     282  return (char *)((char *)pResDir + (pData->OffsetToData - ulRVAResourceSection));
     283}
     284//******************************************************************************
     285//******************************************************************************
     286ULONG Win32ImageBase::getResourceSize(HRSRC hResource)
     287{
     288 PIMAGE_RESOURCE_DATA_ENTRY pData = (PIMAGE_RESOURCE_DATA_ENTRY)hResource;
     289
     290  if(pData == NULL) {
     291        DebugInt3();
     292        return NULL;
     293  }
     294  return pData->Size;
     295}
     296//******************************************************************************
     297//findResource returns the pointer of the resource's IMAGE_RESOURCE_DATA_ENTRY structure
    264298//******************************************************************************
    265299HRSRC Win32ImageBase::findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG langid)
    266300{
    267301 PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
    268  Win32Resource                  *res;
    269302 BOOL   fNumType;
    270303 char  *winres = NULL;
     
    334367    }
    335368    else    dprintf(("FindResource %s: resource %d (type %d, lang %x)", szModule, id, type, lang));
    336     //ulRVAResourceSection contains the relative virtual address (relative to the start of the image)
    337     //for the resource section (images loaded by the pe.exe and pe2lx/win32k)
    338     //For LX images, this is 0 as OffsetToData contains a relative offset
    339     char *resdata = (char *)((char *)pResDir + (pData->OffsetToData - ulRVAResourceSection));
    340     res = new Win32Resource(this, id, type, pData->Size, resdata);
    341 
    342     return (HRSRC) res;
     369
     370    return (HRSRC) pData;
    343371}
    344372//******************************************************************************
     
    359387    else    astring2 = (char *)lpszType;
    360388
    361     hres = (HRSRC) findResourceA(astring1, astring2, lang);
     389    hres = findResourceA(astring1, astring2, lang);
    362390
    363391    if(HIWORD(astring1)) FreeAsciiString(astring1);
  • trunk/src/kernel32/winres.cpp

    r2802 r3625  
    1 /* $Id: winres.cpp,v 1.26 2000-02-16 14:22:12 sandervl Exp $ */
     1/* $Id: winres.cpp,v 1.27 2000-05-28 16:45:14 sandervl Exp $ */
    22
    33/*
     
    2626#define INCL_WINRES
    2727#include <win32type.h>
     28#include <win32api.h>
     29#include <winconst.h>
    2830#include <winres.h>
    2931#include <misc.h>
    30 #include <winexepe2lx.h>
    31 #include <windllpe2lx.h>
     32#include <winimagebase.h>
     33#include <winexebase.h>
     34#include <windllbase.h>
    3235#include "cvtresource.h"
    33 #include <vmutex.h>
    3436
    3537#define DBG_LOCALLOG    DBG_winres
    3638#include "dbglocal.h"
    3739
    38 VMutex resmutex;
    39 
    40 char *ResTypes[MAX_RES] =
    41       {"niks", "CURSOR", "BITMAP", "ICON", "MENU", "DIALOG", "STRING",
    42        "FONTDIR", "FONT", "ACCELERATOR", "RCDATA",  "MESSAGETABLE",
    43        "GROUP_CURSOR", "niks", "GROUP_ICON", "niks", "VERSION"};
    44 
    4540//******************************************************************************
    4641//******************************************************************************
    47 Win32Resource::Win32Resource() :
    48         os2resdata(NULL), winresdata(NULL), resType(RSRC_CUSTOMNODATA)
     42PVOID WIN32API ConvertResourceToOS2(HINSTANCE hInstance, LPSTR restype, HRSRC hResource)
    4943{
    50   next       = NULL;
    51   module     = NULL;
     44 PIMAGE_RESOURCE_DATA_ENTRY pData = (PIMAGE_RESOURCE_DATA_ENTRY)hResource;
     45 Win32ImageBase *module;
     46 char           *resdata;
     47 int             ressize, cvtressize;
    5248
    53   id         = -1;
    54   type       = -1;
    55   hres       = 0;
    56   OS2ResHandle = 0;
    57   //resources are in Unicode format by default; indirectly created resources
    58   //can also be in ascii format
    59   isUnicode  = TRUE;
    60 }
    61 //******************************************************************************
    62 //******************************************************************************
    63 Win32Resource::Win32Resource(Win32ImageBase *module, ULONG id, ULONG type,
    64                  ULONG size, char *resdata) : hres(NULL),
    65         os2resdata(NULL), winresdata(NULL), resType(RSRC_PELOADER)
    66 {
    67   resmutex.enter();
    68   next           = module->winres;
    69   module->winres = this;
    70   resmutex.leave();
    71 
    72   this->module   = module;
    73   this->id       = id;
    74   this->type     = type;
    75   this->ressize  = size;
    76   winresdata     = (char *)malloc(size+sizeof(WCHAR));
    77   if(winresdata == NULL) {
    78     DebugInt3();
    79     return;
    80   }
    81   OS2ResHandle = 0;
    82 
    83   if(type == NTRT_STRING) {
    84         memcpy(winresdata, resdata, size);
    85         ((USHORT *)winresdata)[size/sizeof(WCHAR)] = 0;
    86 //        ((USHORT *)winresdata)[size/sizeof(WCHAR)-1] = 0;
    87   }
    88   else  memcpy(winresdata, resdata, size);
    89 
    90   //resources are in Unicode format by default
    91   isUnicode  = TRUE;
    92 }
    93 //******************************************************************************
    94 //******************************************************************************
    95 Win32Resource::~Win32Resource()
    96 {
    97  Win32Resource *res = module->winres;
    98 
    99   if(os2resdata && (resType == RSRC_PELOADER || resType == RSRC_CUSTOMINDIRECT))
    100     free(os2resdata);
    101 
    102   if(winresdata)    free(winresdata);
    103 
    104   resmutex.enter();
    105   if(res == this) {
    106     module->winres = res->next;
     49  if(hInstance == 0 || hInstance == -1 || (WinExe && hInstance == WinExe->getInstanceHandle())) {
     50        module = (Win32ImageBase *)WinExe;
    10751  }
    10852  else {
    109     while(res->next != this) {
    110         res  = res->next;
    111     }
    112     if(res)
    113         res->next = next;
     53        module = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
    11454  }
    115   resmutex.leave();
    116 }
    117 //******************************************************************************
    118 //******************************************************************************
    119 PVOID Win32Resource::lockResource()
    120 {
    121   dprintf(("Win32Resource::lockResource %d %x\n", id, winresdata));
     55  resdata = (char *)LockResource(LoadResource(hInstance, hResource));
     56  ressize = SizeofResource(hInstance, hResource);
    12257
    123   if(winresdata)
    124     return(winresdata);
    125 
    126   dprintf(("Win32Resource::lockResource: NO windows resource!"));
    127   return NULL;
    128 }
    129 //******************************************************************************
    130 //******************************************************************************
    131 PVOID Win32Resource::lockOS2Resource()
    132 {
    133  APIRET rc;
    134  PVOID  resdata;
    135 
    136    dprintf(("Win32Resource::lockOS2Resource %d\n", id));
    137    if(os2resdata == NULL) {
    138         os2resdata = convertResource(winresdata);
    139    }
    140    return os2resdata;
    141 }
    142 //******************************************************************************
    143 //return size of converted win32 resource
    144 //******************************************************************************
    145 ULONG Win32Resource::getOS2Size()
    146 {
    147   switch(type) {
     58  switch((int)restype) {
    14859    case NTRT_NEWBITMAP:
    14960    case NTRT_BITMAP:
    150         return QueryConvertedBitmapSize((WINBITMAPINFOHEADER *)winresdata, ressize);
     61        return ConvertBitmap((WINBITMAPINFOHEADER *)resdata, ressize, (PULONG)&cvtressize);
    15162
    15263    case NTRT_CURSOR:
    153         return QueryConvertedCursorSize((CursorComponent *)winresdata, ressize);
     64        return ConvertCursor((CursorComponent *)resdata, ressize, &cvtressize);
     65
     66    case NTRT_GROUP_CURSOR:
     67        return ConvertCursorGroup((CursorHeader *)resdata, ressize, module);
     68
     69    case NTRT_GROUP_ICON:
     70        return ConvertIconGroup((IconHeader *)resdata, ressize, module);
    15471
    15572    case NTRT_ICON:
    156         return QueryConvertedIconSize((WINBITMAPINFOHEADER *)winresdata, ressize);
    157 
    158     case NTRT_GROUP_ICON:
    159     case NTRT_GROUP_CURSOR:
    160     case NTRT_ACCELERATORS:
    161     case NTRT_NEWMENU:
    162     case NTRT_MENU:
    163     case NTRT_NEWDIALOG:
    164     case NTRT_DIALOG:
    165     case NTRT_FONTDIR:
    166     case NTRT_FONT:
    167     case NTRT_MESSAGETABLE:
    168     case NTRT_RCDATA:
    169     case NTRT_VERSION:
    170     case NTRT_STRING:
    171     default:
    172         dprintf(("Win32Resource::getOS2Size SHOULDN'T BE CALLED for this resource type (%d) (NOT IMPLEMENTED)!!", type));
    173         break;
    174   }
    175   return 0;
    176 }
    177 //******************************************************************************
    178 //******************************************************************************
    179 PVOID Win32Resource::convertResource(void *win32res)
    180 {
    181  int cvtressize;
    182 
    183   switch(type) {
    184     case NTRT_NEWBITMAP:
    185     case NTRT_BITMAP:
    186         return ConvertBitmap((WINBITMAPINFOHEADER *)win32res, ressize, &ressize);
    187 
    188     case NTRT_CURSOR:
    189         return ConvertCursor((CursorComponent *)win32res, ressize, &cvtressize);
    190 
    191     case NTRT_GROUP_CURSOR:
    192         return ConvertCursorGroup((CursorHeader *)win32res, ressize, module);
    193 
    194     case NTRT_GROUP_ICON:
    195         return ConvertIconGroup((IconHeader *)win32res, ressize, module);
    196 
    197     case NTRT_ICON:
    198         return ConvertIcon((WINBITMAPINFOHEADER *)win32res, ressize, &cvtressize);
     73        return ConvertIcon((WINBITMAPINFOHEADER *)resdata, ressize, &cvtressize);
    19974
    20075    case NTRT_ACCELERATORS:
    201         return ConvertAccelerator((WINACCEL *)win32res, ressize);
     76        return ConvertAccelerator((WINACCEL *)resdata, ressize);
    20277
    20378    case NTRT_NEWMENU:
     
    21691        break;
    21792  }
    218   dprintf(("Win32Resource::convertResource: Can't convert resource %d (type %d)", id, type));
     93  dprintf(("ConvertResourceToOS2: Can't convert resource %x (inst %x)", hResource, hInstance));
    21994  return 0;
    22095}
    22196//******************************************************************************
    22297//******************************************************************************
    223 void Win32Resource::destroyAll(Win32ImageBase *module)
     98ULONG WIN32API QueryConvertedResourceSize(HINSTANCE hInstance, LPSTR restype, HRSRC hResource)
    22499{
    225  Win32Resource *res = module->winres, *next;
     100 PIMAGE_RESOURCE_DATA_ENTRY pData = (PIMAGE_RESOURCE_DATA_ENTRY)hResource;
     101 Win32ImageBase *module;
     102 char           *resdata;
     103 int             ressize, cvtressize;
    226104
    227    while(res) {
    228     next = res->next;
    229     delete(res);
    230     res  = next;
    231    }
     105  if(hInstance == 0 || hInstance == -1 || (WinExe && hInstance == WinExe->getInstanceHandle())) {
     106        module = (Win32ImageBase *)WinExe;
     107  }
     108  else {
     109        module = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
     110  }
     111  resdata = (char *)LockResource(LoadResource(hInstance, hResource));
     112  ressize = SizeofResource(hInstance, hResource);
     113
     114  switch((int)restype) {
     115    case NTRT_NEWBITMAP:
     116    case NTRT_BITMAP:
     117        return QueryConvertedBitmapSize((WINBITMAPINFOHEADER *)resdata, ressize);
     118
     119    case NTRT_CURSOR:
     120        return QueryConvertedCursorSize((CursorComponent *)resdata, ressize);
     121
     122    case NTRT_ICON:
     123        return QueryConvertedIconSize((WINBITMAPINFOHEADER *)resdata, ressize);
     124
     125    case NTRT_GROUP_ICON:
     126    case NTRT_GROUP_CURSOR:
     127    case NTRT_ACCELERATORS:
     128    case NTRT_NEWMENU:
     129    case NTRT_MENU:
     130    case NTRT_NEWDIALOG:
     131    case NTRT_DIALOG:
     132    case NTRT_FONTDIR:
     133    case NTRT_FONT:
     134    case NTRT_MESSAGETABLE:
     135    case NTRT_RCDATA:
     136    case NTRT_VERSION:
     137    case NTRT_STRING:
     138    default:
     139        dprintf(("Win32Resource::getOS2Size SHOULDN'T BE CALLED for this resource type (%d) (NOT IMPLEMENTED)!!", restype));
     140        break;
     141  }
     142  return 0;
    232143}
    233144//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.