- Timestamp:
- Oct 26, 1999, 1:16:15 PM (26 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/KERNEL32.DEF
r1440 r1454 1 ; $Id: KERNEL32.DEF,v 1.4 4 1999-10-25 18:20:52 achimhaExp $1 ; $Id: KERNEL32.DEF,v 1.45 1999-10-26 11:15:32 sandervl Exp $ 2 2 3 3 ;Created by BLAST for IBM's compiler … … 1024 1024 OS2UnsetExceptionHandler @1254 1025 1025 1026 __ct__12Win32MenuResFP14Win32ImageBaseUlN22 @12601027 __ct__12Win32MenuResFP14Win32ImageBaseUlN22Pc @12611028 __ct__12Win32MenuResFUl @12621029 __ct__12Win32MenuResFPv @12631030 1031 1026 ; Odin ini management 1032 1027 -
trunk/src/kernel32/cvtresource.h
r956 r1454 1 /* $Id: cvtresource.h,v 1. 4 1999-09-15 23:38:01sandervl Exp $ */1 /* $Id: cvtresource.h,v 1.5 1999-10-26 11:15:33 sandervl Exp $ */ 2 2 3 3 #ifndef _CVTRESOURCE_H_ 4 4 #define _CVTRESOURCE_H_ 5 5 6 #include <winmenu.h>7 6 #include <winicon.h> 8 7 #include <winaccel.h> … … 16 15 void *ConvertIcon(WINBITMAPINFOHEADER *bmpHdr, int size, int *os2size, int offsetBits = 0); 17 16 void *ConvertIconGroup(IconHeader *ihdr, int size, Win32ImageBase *module); 18 void *ConvertMenu(MenuHeader *menu, int size, int cp = 0);19 17 20 18 ULONG QueryConvertedBitmapSize(WINBITMAPINFOHEADER *pBHdr, ULONG ulSize); -
trunk/src/kernel32/makefile
r1432 r1454 1 # $Id: makefile,v 1.4 6 1999-10-24 22:51:21sandervl Exp $1 # $Id: makefile,v 1.47 1999-10-26 11:15:33 sandervl Exp $ 2 2 3 3 # … … 26 26 LFILE.OBJ NPIPE.OBJ oslibdos.obj oslibmisc.obj MISC.OBJ EXCEPTUTIL.OBJ \ 27 27 LANG.OBJ ICCIO.OBJ MAP.OBJ WIN32UTIL.OBJ heap.OBJ heapstring.obj \ 28 os2heap.OBJ vmutex.OBJ initterm.OBJ handlemanager.OBJ winresmenu.obj\28 os2heap.OBJ vmutex.OBJ initterm.OBJ handlemanager.OBJ \ 29 29 hmdevice.obj hmopen32.obj hmobjects.obj hmevent.obj hmmutex.obj \ 30 30 hmsemaphore.obj wprocess.OBJ conprop.OBJ winimagelx.obj \ … … 34 34 pefile.OBJ winimgres.OBJ wintls.obj async.OBJ fileio.obj \ 35 35 atom.obj disk.obj directory.obj cvtbitmap.obj hmmmap.obj winfakepeldr.obj \ 36 cvt menu.obj cvtaccel.obj cvticon.obj cvticongrp.obj oslibexcept.obj \36 cvtaccel.obj cvticon.obj cvticongrp.obj oslibexcept.obj \ 37 37 cvtcursor.obj cvtcursorgrp.obj stubs.obj interlock.obj toolhelp.obj 38 38 … … 257 257 .\winres.cpp \ 258 258 cvtresource.h \ 259 $(PDWIN32_INCLUDE)\winresmenu.h \260 259 $(PDWIN32_INCLUDE)\winres.h \ 261 260 $(PDWIN32_INCLUDE)\winimagebase.h \ … … 349 348 stubs.obj: stubs.cpp stubs.h 350 349 351 winresmenu.obj: winresmenu.cpp $(PDWIN32_INCLUDE)\winresmenu.h $(PDWIN32_INCLUDE)\winres.h352 353 350 cvtbitmap.obj: cvtbitmap.cpp $(PDWIN32_INCLUDE)\winicon.h $(PDWIN32_INCLUDE)\misc.h cvtresource.h 354 cvtmenu.obj: cvtmenu.cpp $(PDWIN32_INCLUDE)\winmenu.h $(PDWIN32_INCLUDE)\misc.h cvtresource.h355 351 cvtaccel.obj: cvtaccel.cpp $(PDWIN32_INCLUDE)\winaccel.h $(PDWIN32_INCLUDE)\misc.h cvtresource.h 356 352 cvticon.obj: cvticon.cpp $(PDWIN32_INCLUDE)\winicon.h $(PDWIN32_INCLUDE)\misc.h cvtresource.h -
trunk/src/kernel32/winimgres.cpp
r1356 r1454 1 /* $Id: winimgres.cpp,v 1.2 4 1999-10-19 12:51:25sandervl Exp $ */1 /* $Id: winimgres.cpp,v 1.25 1999-10-26 11:15:33 sandervl Exp $ */ 2 2 3 3 /* … … 26 26 #include <winimagelx.h> 27 27 #include <winres.h> 28 #include <winresmenu.h>29 28 #include <unicode.h> 30 29 #include <heapstring.h> … … 306 305 else 307 306 { 308 switch(type) { 309 case NTRT_MENU: 310 res = new Win32MenuRes(this, id, type, pData->Size, resdata); 311 break; 312 default: 313 res = new Win32Resource(this, id, type, pData->Size, resdata); 314 break; 315 } 316 307 res = new Win32Resource(this, id, type, pData->Size, resdata); 317 308 } 318 309 -
trunk/src/kernel32/winres.cpp
r1356 r1454 1 /* $Id: winres.cpp,v 1.2 0 1999-10-19 12:51:25sandervl Exp $ */1 /* $Id: winres.cpp,v 1.21 1999-10-26 11:15:33 sandervl Exp $ */ 2 2 3 3 /* … … 42 42 //****************************************************************************** 43 43 //****************************************************************************** 44 static ULONG CalcBitmapSize(ULONG cBits, LONG cx, LONG cy)45 {46 ULONG alignment;47 ULONG factor;48 BOOL flag = TRUE; //true: '*' false: '/'49 50 cy = cy < 0 ? -cy : cy;51 52 switch(cBits)53 {54 case 1:55 factor = 8;56 flag = FALSE;57 break;58 59 case 4:60 factor = 2;61 flag = FALSE;62 break;63 64 case 8:65 factor = 1;66 break;67 68 case 16:69 factor = 2;70 break;71 72 case 24:73 factor = 3;74 break;75 76 case 32:77 return cx*cy;78 79 default:80 return 0;81 }82 83 if (flag)84 alignment = (cx = (cx*factor)) % 4;85 else86 alignment = (cx = ((cx+factor-1)/factor)) % 4;87 88 if (alignment != 0)89 cx += 4 - alignment;90 91 return cx*cy;92 }93 94 //******************************************************************************95 //******************************************************************************96 44 Win32Resource::Win32Resource() : 97 45 os2resdata(NULL), winresdata(NULL), resType(RSRC_CUSTOMNODATA) … … 103 51 type = -1; 104 52 hres = 0; 105 orgos2type = -1;106 53 OS2ResHandle = 0; 107 54 //resources are in Unicode format by default; indirectly created resources … … 111 58 //****************************************************************************** 112 59 //****************************************************************************** 113 Win32Resource::Win32Resource(Win32ImageBase *module, HRSRC hRes, ULONG id, ULONG type) : 114 os2resdata(NULL), winresdata(NULL), resType(RSRC_PE2LX) 115 { 116 APIRET rc; 117 60 Win32Resource::Win32Resource(Win32ImageBase *module, ULONG id, ULONG type, 61 ULONG size, char *resdata) : hres(NULL), 62 os2resdata(NULL), winresdata(NULL), resType(RSRC_PELOADER) 63 { 118 64 resmutex.enter(); 119 65 next = module->winres; … … 124 70 this->id = id; 125 71 this->type = type; 126 this->hres = hRes;127 128 switch(type) {129 case NTRT_NEWBITMAP:130 case NTRT_BITMAP:131 orgos2type = RT_BITMAP;132 break;133 case NTRT_CURSOR:134 case NTRT_GROUP_CURSOR:135 case NTRT_GROUP_ICON:136 case NTRT_ICON:137 orgos2type = RT_POINTER;138 break;139 case NTRT_ACCELERATORS:140 orgos2type = RT_ACCELTABLE;141 break;142 case NTRT_NEWMENU:143 case NTRT_MENU:144 orgos2type = RT_MENU;145 break;146 case NTRT_NEWDIALOG:147 case NTRT_DIALOG:148 orgos2type = RT_DIALOG;149 break;150 case NTRT_FONTDIR:151 case NTRT_FONT:152 case NTRT_MESSAGETABLE:153 case NTRT_STRING:154 case NTRT_RCDATA:155 case NTRT_VERSION:156 default:157 orgos2type = RT_RCDATA;158 break;159 }160 OS2ResHandle = 0;161 162 rc = DosQueryResourceSize(module->hinstance, orgos2type, id, &ressize);163 if(rc) {164 dprintf(("Win32Resource ctor: DosQueryResourceSize %x %d %d returned %X\n", module->hinstance, type, id, rc));165 ressize = 0;166 }167 //resources are in Unicode format by default168 isUnicode = TRUE;169 }170 //******************************************************************************171 //******************************************************************************172 Win32Resource::Win32Resource(Win32ImageBase *module, ULONG id, ULONG type,173 ULONG size, char *resdata) : hres(NULL),174 os2resdata(NULL), winresdata(NULL), resType(RSRC_PELOADER)175 {176 resmutex.enter();177 next = module->winres;178 module->winres = this;179 resmutex.leave();180 181 this->module = module;182 this->id = id;183 this->type = type;184 orgos2type = -1;185 72 this->ressize = size; 186 73 winresdata = (char *)malloc(size); … … 206 93 Win32Resource *res = module->winres; 207 94 208 //returned by DosGetResource, so we don't (and mustn't) free it209 95 if(os2resdata && (resType == RSRC_PELOADER || resType == RSRC_CUSTOMINDIRECT)) 210 96 free(os2resdata); … … 229 115 PVOID Win32Resource::lockResource() 230 116 { 231 int restype = 0, newid;232 void *resdata = NULL;233 APIRET rc;234 ULONG os2type = RT_RCDATA;235 236 117 dprintf(("Win32Resource::lockResource %d\n", id)); 237 118 … … 239 120 return(winresdata); 240 121 241 switch(type) { 242 case NTRT_BITMAP: 243 rc = DosGetResource((HMODULE)module->hinstance, RT_BITMAP, id, (PPVOID)&resdata); 244 if(rc) return(NULL); 245 winresdata = convertOS2Bitmap((BITMAPFILEHEADER2 *)resdata); 246 break; 247 248 case NTRT_ACCELERATORS: 249 case NTRT_MENU: 250 case NTRT_DIALOG: 251 { 252 //TODO->!!!! 253 // newid = ((Win32Pe2LxImage *)module)->getWin32ResourceId(id); 254 //TODO->!!!! 255 256 rc = DosGetResource((HMODULE)module->hinstance, RT_RCDATA, (int)newid, (PPVOID)&resdata); 257 if(rc) { 258 dprintf(("Can't find original resource!!!\n")); 259 return(NULL); 260 } 261 winresdata = (char *)malloc(ressize); 262 memcpy(winresdata, resdata, ressize); 263 break; 264 } 265 266 //TODO:not yet implemented 267 case NTRT_FONTDIR: 268 case NTRT_FONT: 269 case NTRT_MESSAGETABLE: 270 case NTRT_NEWBITMAP: 271 case NTRT_NEWMENU: 272 case NTRT_NEWDIALOG: 273 os2type = RT_RCDATA; 274 break; 275 276 //Can't do this right now (all group icons stored into a single one) 277 case NTRT_CURSOR: 278 case NTRT_GROUP_CURSOR: 279 case NTRT_GROUP_ICON: 280 case NTRT_ICON: 281 dprintf(("Can't convert this resource!!!!!\n")); 282 os2type = RT_POINTER; 283 break; 284 285 case NTRT_STRING: 286 rc = DosGetResource((HMODULE)module->hinstance, RT_RCDATA, id, (PPVOID)&resdata); 287 if(rc) { 288 dprintf(("Can't find original string!!!\n")); 289 return(NULL); 290 } 291 winresdata = malloc(ressize+sizeof(WCHAR)); 292 memcpy(winresdata, resdata, ressize); 293 *(USHORT *)(&((char *)winresdata)[ressize]) = 0; 294 DosFreeResource(resdata); 295 return((PVOID)((ULONG)winresdata+2)); //skip length word 296 297 //no conversion necessary 298 case NTRT_RCDATA: 299 case NTRT_VERSION: 300 default: 301 os2type = RT_RCDATA; 302 break; 303 } 304 305 if(winresdata == NULL) { 306 rc = DosGetResource((HMODULE)module->hinstance, os2type, id, (PPVOID)&resdata); 307 if(rc) { 308 dprintf(("Can't find original resource!!!\n")); 309 return(NULL); 310 } 311 winresdata = (char *)malloc(ressize); 312 memcpy(winresdata, resdata, ressize); 313 } 314 if(resdata) 315 DosFreeResource(resdata); 316 317 return winresdata; 122 dprintf(("Win32Resource::lockResource: NO windows resource!")); 123 return NULL; 318 124 } 319 125 //****************************************************************************** … … 326 132 dprintf(("Win32Resource::lockOS2Resource %d\n", id)); 327 133 if(os2resdata == NULL) { 328 if(resType == RSRC_PELOADER || resType == RSRC_CUSTOMINDIRECT) {329 134 os2resdata = convertResource(winresdata); 330 }331 else {332 rc = DosGetResource((HMODULE)module->hinstance, orgos2type, id, (PPVOID)&resdata);333 if(rc) return(NULL);334 os2resdata = resdata;335 }336 135 } 337 136 return os2resdata; … … 345 144 case NTRT_NEWBITMAP: 346 145 case NTRT_BITMAP: 347 return QueryConvertedBitmapSize((WINBITMAPINFOHEADER *)winresdata, ressize);146 return QueryConvertedBitmapSize((WINBITMAPINFOHEADER *)winresdata, ressize); 348 147 349 148 case NTRT_CURSOR: 350 return QueryConvertedCursorSize((CursorComponent *)winresdata, ressize);149 return QueryConvertedCursorSize((CursorComponent *)winresdata, ressize); 351 150 352 151 case NTRT_ICON: 353 return QueryConvertedIconSize((WINBITMAPINFOHEADER *)winresdata, ressize);152 return QueryConvertedIconSize((WINBITMAPINFOHEADER *)winresdata, ressize); 354 153 355 154 case NTRT_GROUP_ICON: … … 367 166 case NTRT_STRING: 368 167 default: 369 dprintf(("Win32Resource::getOS2Size SHOULDN'T BE CALLED for this resource type (%d) (NOT IMPLEMENTED)!!", type));370 break;168 dprintf(("Win32Resource::getOS2Size SHOULDN'T BE CALLED for this resource type (%d) (NOT IMPLEMENTED)!!", type)); 169 break; 371 170 } 372 171 return 0; … … 381 180 case NTRT_NEWBITMAP: 382 181 case NTRT_BITMAP: 383 return ConvertBitmap((WINBITMAPINFOHEADER *)win32res, ressize, &ressize);182 return ConvertBitmap((WINBITMAPINFOHEADER *)win32res, ressize, &ressize); 384 183 385 184 case NTRT_CURSOR: 386 return ConvertCursor((CursorComponent *)win32res, ressize, &cvtressize);185 return ConvertCursor((CursorComponent *)win32res, ressize, &cvtressize); 387 186 388 187 case NTRT_GROUP_CURSOR: 389 return ConvertCursorGroup((CursorHeader *)win32res, ressize, module);188 return ConvertCursorGroup((CursorHeader *)win32res, ressize, module); 390 189 391 190 case NTRT_GROUP_ICON: 392 return ConvertIconGroup((IconHeader *)win32res, ressize, module);191 return ConvertIconGroup((IconHeader *)win32res, ressize, module); 393 192 394 193 case NTRT_ICON: 395 return ConvertIcon((WINBITMAPINFOHEADER *)win32res, ressize, &cvtressize);194 return ConvertIcon((WINBITMAPINFOHEADER *)win32res, ressize, &cvtressize); 396 195 397 196 case NTRT_ACCELERATORS: 398 return ConvertAccelerator((WINACCEL *)win32res, ressize);197 return ConvertAccelerator((WINACCEL *)win32res, ressize); 399 198 400 199 case NTRT_NEWMENU: 401 200 case NTRT_MENU: 402 return ConvertMenu((MenuHeader *)win32res, ressize, isUnicode);403 404 201 case NTRT_NEWDIALOG: 405 202 case NTRT_DIALOG: 406 break;407 203 case NTRT_FONTDIR: 408 204 case NTRT_FONT: … … 411 207 case NTRT_VERSION: 412 208 case NTRT_STRING: 413 break;209 break; 414 210 415 211 default: … … 418 214 dprintf(("Win32Resource::convertResource: Can't convert resource %d (type %d)", id, type)); 419 215 return 0; 420 }421 //******************************************************************************422 //NOTE: Will be removed once pe2lx rewrite has been completed423 //******************************************************************************424 PVOID Win32Resource::convertOS2Bitmap(void *bmpdata)425 {426 BITMAPFILEHEADER2 *bmphdr = (BITMAPFILEHEADER2 *)bmpdata;427 WINBITMAPINFOHEADER *winbmphdr;428 RGBQUAD *rgb;429 RGB2 *os2rgb;430 int palsize = 0;431 int imgsize;432 433 if(bmphdr->cbSize != sizeof(BITMAPFILEHEADER2)) {434 PVOID bmpdat = malloc(ressize);435 memcpy(bmpdat, bmpdata, ressize);436 return(bmpdat); //don't convert OS/2 1.x bitmap437 }438 439 if(bmphdr->bmp2.cBitCount < 16) {440 palsize = (1 << bmphdr->bmp2.cBitCount) * sizeof(RGBQUAD);441 }442 443 //SvL: Always recalculate bitmap size (donut.exe has wrong size)444 imgsize = CalcBitmapSize(bmphdr->bmp2.cBitCount,445 bmphdr->bmp2.cx,446 bmphdr->bmp2.cy);447 448 winbmphdr = (WINBITMAPINFOHEADER *)malloc(sizeof(WINBITMAPINFOHEADER) +449 imgsize + palsize);450 memset((char *)winbmphdr, 0, sizeof(WINBITMAPINFOHEADER) + imgsize + palsize);451 452 winbmphdr->biSize = sizeof(WINBITMAPINFOHEADER);453 winbmphdr->biWidth = bmphdr->bmp2.cx;454 winbmphdr->biHeight = bmphdr->bmp2.cy;455 winbmphdr->biPlanes = bmphdr->bmp2.cPlanes;456 winbmphdr->biBitCount = bmphdr->bmp2.cBitCount;457 //TODO: Identical except for BI_BITFIELDS (3L) type!458 winbmphdr->biCompression = bmphdr->bmp2.ulCompression;459 winbmphdr->biSizeImage = imgsize;460 //TODO: Doesn't seem to be completely identical..461 winbmphdr->biClrUsed = bmphdr->bmp2.cclrUsed;462 winbmphdr->biClrImportant = bmphdr->bmp2.cclrImportant;463 winbmphdr->biXPelsPerMeter = bmphdr->bmp2.cxResolution;464 winbmphdr->biYPelsPerMeter = bmphdr->bmp2.cyResolution;465 466 os2rgb = (RGB2 *)(bmphdr+1);467 rgb = (RGBQUAD *)(winbmphdr+1);468 469 if(palsize) {470 memcpy((char *)rgb, (char *)os2rgb, palsize);471 os2rgb = (RGB2 *)((int)os2rgb + palsize);472 rgb = (RGBQUAD *)((int)rgb + palsize);473 }474 memcpy((char *)rgb, (char *)os2rgb, imgsize);475 return((PVOID)winbmphdr);476 216 } 477 217 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.