Changeset 1118 for trunk/src/kernel32


Ignore:
Timestamp:
Oct 4, 1999, 11:56:04 AM (26 years ago)
Author:
sandervl
Message:

Lots of changes by several people (see changelog for 4 October

Location:
trunk/src/kernel32
Files:
4 edited

Legend:

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

    r1104 r1118  
    1 /* $Id: os2heap.cpp,v 1.10 1999-10-01 16:03:10 sandervl Exp $ */
     1/* $Id: os2heap.cpp,v 1.11 1999-10-04 09:55:56 sandervl Exp $ */
    22
    33/*
     
    150150  heapelem->flags   = 0;    //only used when allocated with LocalAlloc
    151151  heapelem->lockCnt = 0;    //..    ..
     152  heapelem->magic   = MAGIC_NR_HEAP;
    152153
    153154  if(hmutex) {
     
    179180    return(FALSE);
    180181
     182  if(helem->magic != MAGIC_NR_HEAP)
     183  {
     184    dprintf(("OS2Heap::Lock ERROR BAD HEAP POINTER:%X\n", lpMem));
     185    return FALSE;
     186  }
     187
    181188  helem->lockCnt++;
    182189
     
    195202    return(FALSE);
    196203
     204  if(helem->magic != MAGIC_NR_HEAP)
     205  {
     206    dprintf(("OS2Heap::UnLock ERROR BAD HEAP POINTER:%X\n", lpMem));
     207    return FALSE;
     208  }
     209
    197210  helem->lockCnt--;
    198211
     
    208221    return(FALSE);
    209222
     223  if(helem->magic != MAGIC_NR_HEAP)
     224  {
     225    dprintf(("OS2Heap::GetFlags ERROR BAD HEAP POINTER:%X\n", lpMem));
     226    return FALSE;
     227  }
     228
    210229  return(helem->flags);
    211230}
     
    219238    return(666);
    220239
     240  if(helem->magic != MAGIC_NR_HEAP)
     241  {
     242    dprintf(("OS2Heap::GetLockCnt ERROR BAD HEAP POINTER:%X\n", lpMem));
     243    return FALSE;
     244  }
     245
    221246  return(helem->lockCnt);
    222247}
     
    235260LPVOID OS2Heap::ReAlloc(DWORD dwFlags, LPVOID lpMem, DWORD dwBytes)
    236261{
     262  HEAPELEM *helem = (HEAPELEM *)((char *)lpMem - sizeof(HEAPELEM));
    237263  LPVOID lpNewMem;
    238264  int    i;
     
    245271//  if (lpMem == 0)   return NULL;
    246272
     273  if (helem->magic != MAGIC_NR_HEAP)
     274  {
     275    dprintf(("OS2Heap::ReAlloc ERROR BAD HEAP POINTER:%X\n", lpMem));
     276    return lpMem;
     277  }
     278
    247279  if (Size(0,lpMem) == dwBytes) return lpMem; // if reallocation with same size
    248280                                                // don't do anything
     
    267299    return(FALSE);
    268300  }
     301
     302  if(helem->magic != MAGIC_NR_HEAP)
     303  {
     304    dprintf(("OS2Heap::Free ERROR BAD HEAP POINTER:%X\n", lpMem));
     305    return FALSE;
     306  }
     307
    269308#ifdef DEBUG1
    270309  int size = Size(0, lpMem);
  • trunk/src/kernel32/os2heap.h

    r99 r1118  
    1 /* $Id: os2heap.h,v 1.3 1999-06-10 19:11:30 phaller Exp $ */
     1/* $Id: os2heap.h,v 1.4 1999-10-04 09:55:57 sandervl Exp $ */
    22
    33/*
     
    1717#include "vmutex.h"
    1818
     19#define MAGIC_NR_HEAP  0x87654321
    1920typedef struct _tagHEAPELEM {
     21  DWORD  magic;     //magic number
    2022  struct _tagHEAPELEM *prev;
    2123  struct _tagHEAPELEM *next;
  • trunk/src/kernel32/winimgres.cpp

    r1016 r1118  
    1 /* $Id: winimgres.cpp,v 1.17 1999-09-23 14:12:14 phaller Exp $ */
     1/* $Id: winimgres.cpp,v 1.18 1999-10-04 09:55:57 sandervl Exp $ */
    22
    33/*
     
    1111 * TODO: Check created resource objects before loading the resource!
    1212 * TODO: Is the name id of the version resource always 1?
    13  * TODO: Once the resource handling in PE2LX/win32k is changed,
     13 * TODO: Once the resource handling in PE2LX/win32k is changed, 
    1414 *       getVersionStruct/Size can be moved into the Win32ImageBase class
    1515 *
     
    3636//PE spec says names & ids are sorted; keep on searching just to be sure
    3737//******************************************************************************
    38 PIMAGE_RESOURCE_DATA_ENTRY
     38PIMAGE_RESOURCE_DATA_ENTRY 
    3939 Win32ImageBase::getPEResourceEntry(ULONG id, ULONG type, ULONG lang)
    4040{
     
    7373    prdType = (PIMAGE_RESOURCE_DIRECTORY)((int)pResDir + (int)prde->u2.OffsetToData);
    7474
    75     if(i < pResDir->NumberOfNamedEntries)
     75    if(i < pResDir->NumberOfNamedEntries) 
    7676    {//name or id entry?
    7777        //SvL: 30-10-'97, high bit is set, so clear to get real offset
     
    8282        lstrcpynWtoA(typename, pstring->NameString, pstring->Length+1);
    8383        typename[pstring->Length] = 0;
    84 
     84       
    8585        if(!fNumType) {
    8686            if(stricmp(typename, (char *)type) == 0) {
     
    380380HRSRC Win32ImageBase::findResourceW(LPWSTR lpszName, LPWSTR lpszType, ULONG lang)
    381381{
    382   HRSRC hres;
    383   char *astring1 = NULL,
    384        *astring2 = NULL;
    385   BOOL fAllocated1 = FALSE;
    386   BOOL fAllocated2 = FALSE;
    387 
    388   if(HIWORD(lpszName) != 0)
    389   {
    390     astring1 = UnicodeToAsciiString((LPWSTR)lpszName);
    391     fAllocated1 = TRUE;
    392   }
    393   else
    394     astring1 = (char *)lpszName;
    395 
    396   if(HIWORD(lpszType) != 0)
    397   {
    398     astring2 = UnicodeToAsciiString(lpszType);
    399     fAllocated2 = TRUE;
    400   }
    401   else
    402     astring2 = (char *)lpszType;
    403   hres = (HRSRC) findResourceA(astring1, astring2);
    404 
    405    /* do NOT free untranslated numerical Resource IDs */
    406   if(fAllocated1) FreeAsciiString(astring1);
    407   if(fAllocated2) FreeAsciiString(astring2);
    408 
    409   return(hres);
     382 HRSRC hres;
     383 char *astring1 = NULL, *astring2 = NULL;
     384
     385    if(HIWORD(lpszName) != 0) {
     386                astring1 = UnicodeToAsciiString(lpszName);
     387    }
     388    else        astring1 = (char *)lpszName;
     389
     390    if(HIWORD(lpszType) != 0) {
     391                astring2 = UnicodeToAsciiString(lpszType);
     392    }
     393    else        astring2 = (char *)lpszType;
     394
     395    hres = (HRSRC) findResourceA(astring1, astring2);
     396
     397    if(HIWORD(astring1)) FreeAsciiString(astring1);
     398    if(HIWORD(astring2)) FreeAsciiString(astring2);
     399
     400    return(hres);
    410401}
    411402//******************************************************************************
     
    427418ULONG Win32ImageBase::getResourceSizeW(LPCWSTR lpszName, LPWSTR lpszType, ULONG lang)
    428419{
    429   char *astring1 = NULL,
    430        *astring2 = NULL;
    431   ULONG ressize;
    432   BOOL fAllocated1 = FALSE;
    433   BOOL fAllocated2 = FALSE;
    434 
    435   if(HIWORD(lpszName) != 0)
    436   {
    437     astring1 = UnicodeToAsciiString((LPWSTR)lpszName);
    438     fAllocated1 = TRUE;
    439   }
    440   else
    441     astring1 = (char *)lpszName;
    442 
    443   if(HIWORD(lpszType) != 0)
    444   {
    445     astring2 = UnicodeToAsciiString(lpszType);
    446     fAllocated2 = TRUE;
    447   }
    448   else
    449     astring2 = (char *)lpszType;
    450 
    451   ressize =  getResourceSizeA(astring1, astring2, lang);
    452 
    453   /* do NOT free untranslated numerical Resource IDs */
    454   if(fAllocated1) FreeAsciiString(astring1);
    455   if(fAllocated2) FreeAsciiString(astring2);
    456 
    457   return(ressize);
     420 char *astring1 = NULL, *astring2 = NULL;
     421 ULONG ressize;
     422
     423    if(HIWORD(lpszName) != 0) {
     424                astring1 = UnicodeToAsciiString((LPWSTR)lpszName);
     425    }
     426    else        astring1 = (char *)lpszName;
     427
     428    if(HIWORD(lpszType) != 0) {
     429                astring2 = UnicodeToAsciiString(lpszType);
     430    }
     431    else        astring2 = (char *)lpszType;
     432
     433    ressize =  getResourceSizeA(astring2, astring1, lang);
     434
     435    if(HIWORD(astring1)) FreeAsciiString(astring1);
     436    if(HIWORD(astring2)) FreeAsciiString(astring2);
     437
     438    return(ressize);
    458439}
    459440//******************************************************************************
     
    489470 PIMAGE_RESOURCE_DATA_ENTRY      pData = NULL;
    490471
     472  if(verstruct == NULL || bufLength == 0) {
     473        SetLastError(ERROR_INVALID_PARAMETER);
     474        return FALSE;
     475  }
    491476  pData = getPEResourceEntry(1, NTRT_VERSION);
    492477  if(pData == NULL) {
     
    494479        return 0;
    495480  }
    496   return pData->Size;
    497 }
    498 //******************************************************************************
    499 //******************************************************************************
     481  char *resdata = (char *)((char *)pResDir + pData->OffsetToData - pResourceSectionStart);
     482  memcpy(verstruct, resdata, min(bufLength, pData->Size));
     483  return TRUE;
     484}
     485//******************************************************************************
     486//******************************************************************************
  • trunk/src/kernel32/wprocess.cpp

    r1052 r1118  
    1 /* $Id: wprocess.cpp,v 1.33 1999-09-25 17:55:21 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.34 1999-10-04 09:55:57 sandervl Exp $ */
    22
    33/*
     
    646646BOOL SYSTEM GetVersionStruct(char *modname, char *verstruct, ULONG bufLength)
    647647{
    648  HINSTANCE       hinstance;
    649648 Win32ImageBase *winimage;
    650649
    651650  dprintf(("GetVersionStruct"));
    652   hinstance = OSLibQueryModuleHandle(modname);
    653   if(hinstance == 0) {
    654         dprintf(("GetVersionStruct can't find handle for %s\n", modname));
    655         return(FALSE);
    656   }
    657   if(WinExe && WinExe->getInstanceHandle() == hinstance) {
     651  if(WinExe && !strcmp(WinExe->getFullPath(), modname)) {
    658652        winimage = (Win32ImageBase *)WinExe;
    659653  }
    660654  else {
    661         winimage = (Win32ImageBase *)Win32DllBase::findModule(hinstance);
     655        winimage = (Win32ImageBase *)Win32DllBase::findModule(modname);
    662656        if(winimage == NULL) {
    663657                dprintf(("GetVersionStruct can't find Win32Image for %s\n", modname));
     
    671665ULONG SYSTEM GetVersionSize(char *modname)
    672666{
    673  HINSTANCE       hinstance;
    674667 Win32ImageBase *winimage;
    675668
    676669  dprintf(("GetVersionSize of %s\n", modname));
    677   hinstance = OSLibQueryModuleHandle(modname);
    678   if(hinstance == 0) {
    679         dprintf(("GetVersionSize can't find handle for %s\n", modname));
    680         return(FALSE);
    681   }
    682 
    683   if(WinExe && WinExe->getInstanceHandle() == hinstance) {
     670
     671  if(WinExe && !strcmp(WinExe->getFullPath(), modname)) {
    684672        winimage = (Win32ImageBase *)WinExe;
    685673  }
    686674  else {
    687         winimage = (Win32ImageBase *)Win32DllBase::findModule(hinstance);
     675        winimage = (Win32ImageBase *)Win32DllBase::findModule(modname);
    688676        if(winimage == NULL) {
    689677                dprintf(("GetVersionSize can't find Win32Image for %s\n", modname));
Note: See TracChangeset for help on using the changeset viewer.