Changeset 3625 for trunk/src/kernel32
- Timestamp:
- May 28, 2000, 6:45:14 PM (25 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/KERNEL32.DEF
r3461 r3625 1 ; $Id: KERNEL32.DEF,v 1.8 0 2000-04-29 18:26:56sandervl Exp $1 ; $Id: KERNEL32.DEF,v 1.81 2000-05-28 16:45:11 sandervl Exp $ 2 2 3 3 ;Created by BLAST for IBM's compiler … … 1085 1085 CPUFeatures @2005 1086 1086 InitSystemAndRegistry__Fv @2006 1087 _ConvertResourceToOS2@12 @2007 1087 1088 1088 1089 ;registry apis imported by advapi32 -
trunk/src/kernel32/cvtcursorgrp.cpp
r3101 r3625 1 /* $Id: cvtcursorgrp.cpp,v 1. 9 2000-03-13 13:10:09sandervl Exp $ */1 /* $Id: cvtcursorgrp.cpp,v 1.10 2000-05-28 16:45:12 sandervl Exp $ */ 2 2 3 3 /* … … 23 23 #include <string.h> 24 24 #include <win32type.h> 25 #include <win32api.h> 26 #include <winconst.h> 25 27 #include <wincursor.h> 26 #include <winres.h>27 28 #include <misc.h> 28 29 #include "cvtresource.h" 30 #include <winres.h> 29 31 30 32 #define DBG_LOCALLOG DBG_cvtcursorgrp 31 33 #include "dbglocal.h" 32 33 HRSRC WIN32API FindResourceA(HINSTANCE hModule, LPCSTR lpszName, LPCSTR lpszType);34 34 35 35 //****************************************************************************** … … 41 41 BITMAPARRAYFILEHEADER2 *bafh, *orgbafh; 42 42 CursorComponent *cursorhdr; 43 Win32Resource *winres;44 43 void *os2cursor; 44 HRSRC hRes; 45 45 46 46 dprintf(("ConvertCursorGroup")); … … 53 53 dprintf2(("Bits : %d", rdir->wBitCount)); 54 54 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); 59 59 rdir++; 60 60 } … … 68 68 bafh->cxDisplay = 0; 69 69 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) { 74 74 dprintf(("Can't find cursor!")); 75 75 rdir++; … … 77 77 } 78 78 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)); 81 81 82 82 if(os2cursor == NULL) { 83 83 dprintf(("Can't convert cursor!")); 84 delete winres;85 84 rdir++; 86 85 continue; … … 96 95 97 96 bafh = (BITMAPARRAYFILEHEADER2 *)((int)&bafh->bfh2 + os2cursorsize); 98 delete winres;99 97 100 98 rdir++; -
trunk/src/kernel32/cvticongrp.cpp
r2802 r3625 1 /* $Id: cvticongrp.cpp,v 1. 6 2000-02-16 14:25:37sandervl Exp $ */1 /* $Id: cvticongrp.cpp,v 1.7 2000-05-28 16:45:12 sandervl Exp $ */ 2 2 3 3 /* … … 23 23 #include <string.h> 24 24 #include <win32type.h> 25 #include <win32api.h> 26 #include <winconst.h> 25 27 #include <winicon.h> 26 #include <winres.h>27 28 #include <misc.h> 28 29 #include "cvtresource.h" 30 #include <winres.h> 29 31 30 32 #define DBG_LOCALLOG DBG_cvticongrp 31 33 #include "dbglocal.h" 32 33 HRSRC WIN32API FindResourceA(HINSTANCE hModule, LPCSTR lpszName, LPCSTR lpszType);34 34 35 35 //****************************************************************************** … … 41 41 BITMAPARRAYFILEHEADER2 *bafh, *orgbafh; 42 42 WINBITMAPINFOHEADER *iconhdr; 43 Win32Resource *winres;44 43 void *os2icon; 44 HRSRC hRes; 45 45 46 46 dprintf(("Icon Group type :%d", ihdr->wType)); … … 53 53 dprintf2(("Bits : %d", rdir->wBitCount)); 54 54 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); 59 59 rdir++; 60 60 } … … 68 68 bafh->cxDisplay = 0; 69 69 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) { 74 74 dprintf(("Can't find icon!")); 75 75 rdir++; … … 77 77 } 78 78 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)); 81 81 82 82 if(os2icon == NULL) { 83 83 dprintf(("Can't convert icon!")); 84 delete winres;85 84 rdir++; 86 85 continue; … … 96 95 97 96 bafh = (BITMAPARRAYFILEHEADER2 *)((int)&bafh->bfh2 + os2iconsize); 98 delete winres;99 97 100 98 rdir++; -
trunk/src/kernel32/directory.cpp
r3611 r3625 1 /* $Id: directory.cpp,v 1.2 1 2000-05-26 18:53:18sandervl Exp $ */1 /* $Id: directory.cpp,v 1.22 2000-05-28 16:45:12 sandervl Exp $ */ 2 2 3 3 /* … … 381 381 tmp[len -1] = 0; 382 382 383 dprintf(("RemoveDirectory % S", arg1));383 dprintf(("RemoveDirectory %s", arg1)); 384 384 385 385 return O32_RemoveDirectory(tmp); -
trunk/src/kernel32/pefile.cpp
r2802 r3625 1 /* $Id: pefile.cpp,v 1. 7 2000-02-16 14:23:11sandervl Exp $ */1 /* $Id: pefile.cpp,v 1.8 2000-05-28 16:45:12 sandervl Exp $ */ 2 2 3 3 /* … … 15 15 #include <pefile.h> 16 16 #include <misc.h> 17 #include <winres.h>18 17 19 18 #define DBG_LOCALLOG DBG_pefile -
trunk/src/kernel32/resource.cpp
r2803 r3625 1 /* $Id: resource.cpp,v 1.1 5 2000-02-16 14:25:45sandervl Exp $ */1 /* $Id: resource.cpp,v 1.16 2000-05-28 16:45:12 sandervl Exp $ */ 2 2 3 3 /* … … 13 13 #include <os2win.h> 14 14 #include <unicode.h> 15 #include "winres.h"16 15 #include <winimagebase.h> 17 16 #include <winexebase.h> … … 71 70 *****************************************************************************/ 72 71 73 HRSRC 74 72 HRSRC WIN32API FindResourceExA( HMODULE hModule, LPCSTR lpType, 73 LPCSTR lpName, WORD wLanguage) 75 74 { 76 75 Win32ImageBase *module; … … 105 104 *****************************************************************************/ 106 105 107 HRSRC 108 109 110 106 HRSRC WIN32API FindResourceExW(HMODULE hModule, 107 LPCWSTR lpType, 108 LPCWSTR lpName, 109 WORD wLanguage) 111 110 { 112 111 Win32ImageBase *module; … … 117 116 return(NULL); 118 117 } 119 120 118 return module->findResourceW((LPWSTR)lpName, (LPWSTR)lpType, wLanguage); 121 119 } … … 128 126 } 129 127 //****************************************************************************** 128 //hRes == returned by FindResource(Ex) = PIMAGE_RESOURCE_DATA_ENTRY for resource 129 //****************************************************************************** 130 HGLOBAL 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 //****************************************************************************** 130 151 //hRes == returned by FindResource(Ex) 131 152 //****************************************************************************** 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 //******************************************************************************148 153 DWORD WIN32API SizeofResource(HINSTANCE hModule, HRSRC hRes) 149 154 { 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); 157 172 } 158 173 //****************************************************************************** -
trunk/src/kernel32/winimagebase.cpp
r3609 r3625 1 /* $Id: winimagebase.cpp,v 1.2 0 2000-05-26 18:42:56sandervl Exp $ */1 /* $Id: winimagebase.cpp,v 1.21 2000-05-28 16:45:12 sandervl Exp $ */ 2 2 3 3 /* … … 32 32 #include <pefile.h> 33 33 #include <unicode.h> 34 #include <winres.h>35 34 #include "oslibmisc.h" 36 35 #include "oslibdos.h" … … 47 46 errorState(NO_ERROR), entryPoint(0), fullpath(NULL), 48 47 tlsAddress(0), tlsIndexAddr(0), tlsInitSize(0), tlsTotalSize(0), 49 tlsCallBackAddr(0), tlsIndex(-1), winres(NULL),pResDir(NULL),48 tlsCallBackAddr(0), tlsIndex(-1), pResDir(NULL), 50 49 ulRVAResourceSection(0) 51 50 { … … 78 77 Win32ImageBase::~Win32ImageBase() 79 78 { 80 Win32Resource *res;81 82 while(winres)83 {84 res = winres->next;85 delete(winres);86 winres = res;87 }88 79 if(fullpath) 89 80 free(fullpath); -
trunk/src/kernel32/winimagebase.h
r3609 r3625 1 /* $Id: winimagebase.h,v 1. 9 2000-05-26 18:42:56sandervl Exp $ */1 /* $Id: winimagebase.h,v 1.10 2000-05-28 16:45:12 sandervl Exp $ */ 2 2 3 3 /* … … 67 67 char *getModuleName() { return szModule; }; 68 68 69 //findResource returns the pointer of the resource's IMAGE_RESOURCE_DATA_ENTRY structure 69 70 virtual HRSRC findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG lang = LANG_GETFIRST); 70 71 HRSRC findResourceW(LPWSTR lpszName, LPWSTR lpszType, ULONG lang = LANG_GETFIRST); 72 71 73 virtual ULONG getResourceSizeA(LPCSTR lpszName, LPSTR lpszType, ULONG lang = LANG_GETFIRST); 72 74 ULONG getResourceSizeW(LPCWSTR lpszName, LPWSTR lpszType, ULONG lang = LANG_GETFIRST); … … 80 82 virtual ULONG getVersionSize(); 81 83 virtual 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); 82 88 83 89 static BOOL isPEImage(char *szFileName); … … 118 124 void tlsAlloc(); //Allocate TLS index for this module 119 125 void tlsDelete(); //Destroy TLS index for this module 120 121 Win32Resource *winres;122 126 123 127 ULONG errorState, entryPoint; -
trunk/src/kernel32/winimagelx.cpp
r2802 r3625 1 /* $Id: winimagelx.cpp,v 1. 6 2000-02-16 14:22:12sandervl Exp $ */1 /* $Id: winimagelx.cpp,v 1.7 2000-05-28 16:45:13 sandervl Exp $ */ 2 2 3 3 /* … … 33 33 #include <pefile.h> 34 34 #include <unicode.h> 35 #include <winres.h>36 35 #include "oslibmisc.h" 37 36 #include "initterm.h" -
trunk/src/kernel32/winimagepeldr.cpp
r3609 r3625 1 /* $Id: winimagepeldr.cpp,v 1.4 3 2000-05-26 18:42:56sandervl Exp $ */1 /* $Id: winimagepeldr.cpp,v 1.44 2000-05-28 16:45:13 sandervl Exp $ */ 2 2 3 3 /* … … 43 43 #include <pefile.h> 44 44 #include <unicode.h> 45 #include <winres.h>46 45 #include "oslibmisc.h" 47 46 #include "initterm.h" -
trunk/src/kernel32/winimgres.cpp
r3588 r3625 1 /* $Id: winimgres.cpp,v 1.3 7 2000-05-22 19:08:00sandervl Exp $ */1 /* $Id: winimgres.cpp,v 1.38 2000-05-28 16:45:13 sandervl Exp $ */ 2 2 3 3 /* … … 23 23 #include <misc.h> 24 24 #include <winimagebase.h> 25 #include <winres.h>26 25 #include <unicode.h> 27 26 #include <heapstring.h> … … 31 30 #define DBG_LOCALLOG DBG_winimgres 32 31 #include "dbglocal.h" 32 33 #define MAX_RES 17 34 char *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"}; 33 38 34 39 //SvL: VPBuddy bugfix, seems to load bitmaps with type name 'DIB' … … 262 267 } 263 268 //****************************************************************************** 269 //Returns pointer to data of resource handle 270 //****************************************************************************** 271 char *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 //****************************************************************************** 286 ULONG 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 264 298 //****************************************************************************** 265 299 HRSRC Win32ImageBase::findResourceA(LPCSTR lpszName, LPSTR lpszType, ULONG langid) 266 300 { 267 301 PIMAGE_RESOURCE_DATA_ENTRY pData = NULL; 268 Win32Resource *res;269 302 BOOL fNumType; 270 303 char *winres = NULL; … … 334 367 } 335 368 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; 343 371 } 344 372 //****************************************************************************** … … 359 387 else astring2 = (char *)lpszType; 360 388 361 hres = (HRSRC)findResourceA(astring1, astring2, lang);389 hres = findResourceA(astring1, astring2, lang); 362 390 363 391 if(HIWORD(astring1)) FreeAsciiString(astring1); -
trunk/src/kernel32/winres.cpp
r2802 r3625 1 /* $Id: winres.cpp,v 1.2 6 2000-02-16 14:22:12sandervl Exp $ */1 /* $Id: winres.cpp,v 1.27 2000-05-28 16:45:14 sandervl Exp $ */ 2 2 3 3 /* … … 26 26 #define INCL_WINRES 27 27 #include <win32type.h> 28 #include <win32api.h> 29 #include <winconst.h> 28 30 #include <winres.h> 29 31 #include <misc.h> 30 #include <winexepe2lx.h> 31 #include <windllpe2lx.h> 32 #include <winimagebase.h> 33 #include <winexebase.h> 34 #include <windllbase.h> 32 35 #include "cvtresource.h" 33 #include <vmutex.h>34 36 35 37 #define DBG_LOCALLOG DBG_winres 36 38 #include "dbglocal.h" 37 39 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 45 40 //****************************************************************************** 46 41 //****************************************************************************** 47 Win32Resource::Win32Resource() : 48 os2resdata(NULL), winresdata(NULL), resType(RSRC_CUSTOMNODATA) 42 PVOID WIN32API ConvertResourceToOS2(HINSTANCE hInstance, LPSTR restype, HRSRC hResource) 49 43 { 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; 52 48 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; 107 51 } 108 52 else { 109 while(res->next != this) { 110 res = res->next; 111 } 112 if(res) 113 res->next = next; 53 module = (Win32ImageBase *)Win32DllBase::findModule(hInstance); 114 54 } 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); 122 57 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) { 148 59 case NTRT_NEWBITMAP: 149 60 case NTRT_BITMAP: 150 return QueryConvertedBitmapSize((WINBITMAPINFOHEADER *)winresdata,ressize);61 return ConvertBitmap((WINBITMAPINFOHEADER *)resdata, ressize, (PULONG)&cvtressize); 151 62 152 63 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); 154 71 155 72 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); 199 74 200 75 case NTRT_ACCELERATORS: 201 return ConvertAccelerator((WINACCEL *) win32res, ressize);76 return ConvertAccelerator((WINACCEL *)resdata, ressize); 202 77 203 78 case NTRT_NEWMENU: … … 216 91 break; 217 92 } 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)); 219 94 return 0; 220 95 } 221 96 //****************************************************************************** 222 97 //****************************************************************************** 223 void Win32Resource::destroyAll(Win32ImageBase *module)98 ULONG WIN32API QueryConvertedResourceSize(HINSTANCE hInstance, LPSTR restype, HRSRC hResource) 224 99 { 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; 226 104 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; 232 143 } 233 144 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.