Changeset 597


Ignore:
Timestamp:
Aug 20, 1999, 1:52:44 PM (26 years ago)
Author:
sandervl
Message:

PE loader resource fixes

Location:
trunk/src/kernel32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/kernel32/kernel32exp.def

    r581 r597  
    1 ; $Id: kernel32exp.def,v 1.11 1999-08-19 14:19:14 sandervl Exp $
     1; $Id: kernel32exp.def,v 1.12 1999-08-20 11:52:44 sandervl Exp $
    22
    33;Created by BLAST for IBM's compiler
     
    800800_lstrlenA@4                 @779
    801801_lstrlenW@4                 @780
     802_lstrcpynAtoW@12            @781
     803_lstrcpynWtoA@12            @782
     804_lstrcpyAtoW@8              @783
     805_lstrcpyWtoA@8              @784
     806_lstrncmpA@12               @785
     807_lstrncmpW@12               @786
    802808
    803809OS2memmove                    @906
  • TabularUnified trunk/src/kernel32/winimgres.cpp

    r589 r597  
    1 /* $Id: winimgres.cpp,v 1.10 1999-08-19 19:50:40 sandervl Exp $ */
     1/* $Id: winimgres.cpp,v 1.11 1999-08-20 11:52:44 sandervl Exp $ */
    22
    33/*
     
    99 * Project Odin Software License can be found in LICENSE.TXT
    1010 *
     11 * TODO: Check created resource objects before loading the resource!
     12 *
    1113 */
    1214#include <os2win.h>
     
    1517#include <string.h>
    1618
    17 #include "misc.h"
    18 #include "nameid.h"
    19 #include "winimage.h"
    20 #include "windll.h"
    21 #include "winexe.h"
    22 #include "winres.h"
     19#include <misc.h>
     20#include <nameid.h>
     21#include <winimage.h>
     22#include <windll.h>
     23#include <winexe.h>
     24#include <winres.h>
     25#include <unicode.h>
     26#include <heapstring.h>
    2327#include "pefile.h"
    24 #include "unicode.h"
    2528
    2629char *ResTypes[MAX_RES] =
     
    3942 PIMAGE_RESOURCE_DIRECTORY       prdType;
    4043 PIMAGE_RESOURCE_DIRECTORY_ENTRY prde;
     44 PIMAGE_RESOURCE_DIR_STRING_U    pstring;
    4145 PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
    42  ULONG  nodeData[3], i, j;
     46 ULONG  nodeData[3], i, j, nameOffset;
    4347 BOOL  fFound = FALSE, fNumType;
    4448
     
    7377    {//name or id entry?
    7478        //SvL: 30-10-'97, high bit is set, so clear to get real offset
    75         prde->u1.Name &= ~0x80000000;
    76         char *typename = UnicodeToAsciiStringN((WCHAR *)((ULONG)pResDir + (ULONG)prde->u1.Name + sizeof(WCHAR)), *(WCHAR *)((ULONG)pResDir + (ULONG)prde->u1.Name));  // first word = string length
    77 
     79        nameOffset = prde->u1.Name & ~0x80000000;
     80
     81        pstring = (PIMAGE_RESOURCE_DIR_STRING_U)((ULONG)pResDir + nameOffset);
     82        char *typename = (char *)malloc(pstring->Length+1);
     83        lstrcpynWtoA(typename, pstring->NameString, pstring->Length);
     84        typename[pstring->Length] = 0;
     85       
    7886        if(!fNumType) {
    7987            if(stricmp(typename, (char *)type) == 0) {
     
    9098            }
    9199        }
    92         FreeAsciiString(typename);
     100        free(typename);
    93101    }
    94102    else {
     
    125133 PIMAGE_RESOURCE_DATA_ENTRY      pData;
    126134 BOOL  fFound = FALSE, fNumId;
    127  ULONG nrres;
     135 ULONG nrres, nameOffset;
    128136 char *resname;
    129137 int   i;
     
    155163
    156164        if(!fNumId) {//name or id entry?
     165                nameOffset = prde->u1.Name;
    157166                if(prde->u1.s.NameIsString) //unicode directory string /*PLF Sat  97-06-21 22:30:35*/
    158                         prde->u1.Name &= ~0x80000000;
    159 
    160                 pstring = (PIMAGE_RESOURCE_DIR_STRING_U)((ULONG)pResDir + (ULONG)prde->u1.Name);
    161                 resname = UnicodeToAsciiStringN(pstring->NameString, pstring->Length);
     167                        nameOffset &= ~0x80000000;
     168
     169                pstring = (PIMAGE_RESOURCE_DIR_STRING_U)((ULONG)pResDir + nameOffset);
     170
     171                resname = (char *)malloc(pstring->Length+1);
     172                lstrcpynWtoA(resname, pstring->NameString, pstring->Length);
     173                resname[pstring->Length] = 0;
    162174                if(stricmp(resname, (char *)*nodeData) == 0) {
    163175                        fFound = TRUE;
    164176                }
    165                 FreeAsciiString(resname);
     177                free(resname);
    166178        }
    167179        else {
     
    229241    if(type == NTRT_STRING) {
    230242        stringid = id & 0xF;
    231         id       = (id >> 4);
     243        id       = (id >> 4)+1;
    232244    }
    233245  }
     
    235247    if(stricmp((char *)type, ResTypes[NTRT_STRING]) == 0) {
    236248        stringid = id & 0xF;
    237         id       = (id >> 4);
     249        id       = (id >> 4)+1;
    238250    }
    239251  }
     
    250262
    251263        for(i=0;i<stringid;i++) {
    252                 unicodestr += *unicodestr;
     264                unicodestr += *unicodestr+1;
    253265        }
    254         res = new Win32Resource(this, id, NTRT_STRING, (ULONG)*unicodestr, (char *)unicodestr);
     266        res = new Win32Resource(this, id, NTRT_STRING, (*unicodestr+1)*sizeof(WCHAR),
     267                                (char *)(unicodestr+1));
    255268        if(res == NULL) {
    256269                dprintf(("new Win32Resource failed!\n"));
  • TabularUnified trunk/src/kernel32/winres.cpp

    r589 r597  
    1 /* $Id: winres.cpp,v 1.9 1999-08-19 19:50:41 sandervl Exp $ */
     1/* $Id: winres.cpp,v 1.10 1999-08-20 11:52:44 sandervl Exp $ */
    22
    33/*
     
    88 *
    99 * Project Odin Software License can be found in LICENSE.TXT
     10 *
    1011 *
    1112 */
     
    3132#include "cvtresource.h"
    3233
     34//******************************************************************************
     35//******************************************************************************
    3336static ULONG CalcBitmapSize(ULONG cBits, LONG cx, LONG cy)
    3437{
     
    155158    return;
    156159  }
    157   memcpy(winresdata, resdata, size);
     160  OS2ResHandle = 0;
     161
     162  if(type == NTRT_STRING) {
     163        memcpy(winresdata, resdata, size-sizeof(WCHAR));
     164        ((USHORT *)winresdata)[size/sizeof(WCHAR)-1] = 0;
     165  }
     166  else  memcpy(winresdata, resdata, size);
    158167}
    159168//******************************************************************************
     
    253262
    254263  if(winresdata == NULL) {
    255     rc = DosGetResource((HMODULE)module->hinstance, os2type, id, (PPVOID)&resdata);
    256     if(rc) {
    257         dprintf(("Can't find original string!!!\n"));
    258         return(NULL);
    259     }
    260     winresdata = (char *)malloc(ressize);
    261     memcpy(winresdata, resdata, ressize);
     264        rc = DosGetResource((HMODULE)module->hinstance, os2type, id, (PPVOID)&resdata);
     265        if(rc) {
     266                dprintf(("Can't find original resource!!!\n"));
     267                return(NULL);
     268        }
     269        winresdata = (char *)malloc(ressize);
     270        memcpy(winresdata, resdata, ressize);
    262271  }
    263272  if(resdata)
    264     DosFreeResource(resdata);
     273        DosFreeResource(resdata);
     274
    265275  return winresdata;
    266276}
     
    321331    case NTRT_FONT:
    322332    case NTRT_MESSAGETABLE:
    323     case NTRT_STRING:
    324333    case NTRT_RCDATA:
    325334    case NTRT_VERSION:
     335    case NTRT_STRING:
     336        break;
     337
    326338    default:
    327339        break;
Note: See TracChangeset for help on using the changeset viewer.