Index: trunk/src/kernel32/cvtaccel.cpp
===================================================================
--- trunk/src/kernel32/cvtaccel.cpp	(revision 581)
+++ trunk/src/kernel32/cvtaccel.cpp	(revision 581)
@@ -0,0 +1,67 @@
+/* $Id: cvtaccel.cpp,v 1.1 1999-08-19 14:19:14 sandervl Exp $ */
+
+/*
+ * PE2LX accelerator resource support code
+ *
+ * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
+ *
+ * Project Odin Software License can be found in LICENSE.TXT
+ *
+ */
+#define INCL_GPIBITMAPS
+#define INCL_BITMAPFILEFORMAT
+#define INCL_DOSFILEMGR          /* File Manager values      */
+#define INCL_DOSERRORS           /* DOS Error values         */
+#define INCL_DOSPROCESS          /* DOS Process values       */
+#define INCL_DOSMISC             /* DOS Miscellanous values  */
+#define INCL_DOSNLS
+#define INCL_WIN
+#include <os2wrap.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <string.h>
+#include <win32type.h>
+#include <winaccel.h>
+#include <misc.h>
+
+//******************************************************************************
+//******************************************************************************
+void *ConvertAccelerator(WINACCEL *accdata, int size, int cp)
+{
+ ACCELTABLE *OS2Acc;
+ int         os2size,i;
+ ULONG       ulCpSize, ulCP;
+
+   os2size = sizeof(ACCELTABLE) + ((size/8)-1)*sizeof(ACCEL);
+   OS2Acc  = (ACCELTABLE *)malloc(os2size);
+   memset(OS2Acc, 0, os2size);
+   OS2Acc->cAccel   = size/8;
+   if(cp == 0) {
+    	OS2Acc->codepage = 437;
+   }
+   else
+   {
+    	DosQueryCp(sizeof(ulCP), &ulCP, &ulCpSize);
+    	OS2Acc->codepage = ulCP;
+   }
+
+
+   for(i=0;i<OS2Acc->cAccel;i++) {
+    	OS2Acc->aaccel[i].key = accdata->key;
+    	OS2Acc->aaccel[i].cmd = accdata->cmd;
+    	if(accdata[i].fVirt & FVIRTKEY)
+        	OS2Acc->aaccel[i].fs |= AF_VIRTUALKEY;
+    	if(accdata[i].fVirt & FNOINVERT)
+        	OS2Acc->aaccel[i].fs |= AF_CHAR;
+    	if(accdata[i].fVirt & FSHIFT)
+        	OS2Acc->aaccel[i].fs |= AF_SHIFT;
+    	if(accdata[i].fVirt & FCONTROL)
+        	OS2Acc->aaccel[i].fs |= AF_CONTROL;
+    	if(accdata[i].fVirt & FALT)
+        	OS2Acc->aaccel[i].fs |= AF_ALT;
+   }
+   return (void *)OS2Acc;
+}
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/kernel32/cvtbitmap.cpp
===================================================================
--- trunk/src/kernel32/cvtbitmap.cpp	(revision 581)
+++ trunk/src/kernel32/cvtbitmap.cpp	(revision 581)
@@ -0,0 +1,598 @@
+/* $Id: cvtbitmap.cpp,v 1.1 1999-08-19 14:19:14 sandervl Exp $ */
+
+/*
+ * PE2LX bitmap conversion code
+ *
+ * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
+ * Copyright 1998 Knut St. Osmundsen
+ *
+ *
+ * Project Odin Software License can be found in LICENSE.TXT
+ *
+ */
+#define INCL_GPIBITMAPS
+#define INCL_BITMAPFILEFORMAT
+#define INCL_DOSFILEMGR          /* File Manager values      */
+#define INCL_DOSERRORS           /* DOS Error values         */
+#define INCL_DOSPROCESS          /* DOS Process values       */
+#define INCL_DOSMISC             /* DOS Miscellanous values  */
+#define INCL_WIN
+#include <os2wrap.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <win32type.h>
+#include <winicon.h>
+#include <misc.h>
+#include "cvtresource.h"
+
+#define __StackToFlat(a) a
+#define ltassert(a)
+#define MAXPTR
+#define MINPTR
+
+/**********/
+/* Macros */
+/**********/
+#define Need1BitTo4BitConvertWIN(pBHdr)         \
+        (                                                                                                               \
+                pBHdr->biBitCount == 1                                          \
+                && !(                                                                                           \
+                        (((PULONG)pBHdr)[10] == 0x00000000 && (pBHdr->biClrUsed == 1 || ((PULONG)pBHdr)[11] == 0x00ffffff))  /*black and white*/  \
+                || (((PULONG)pBHdr)[10] == 0x00ffffff && (pBHdr->biClrUsed == 1 || ((PULONG)pBHdr)[11] == 0x00000000))  /*white and black*/  \
+                )                                                                                                       \
+        )
+
+#define Need1BitTo4BitConvertOS2(pBIH)                  \
+        (                                                                                                               \
+                pBIH->cBitCount == 1                                                    \
+                && !(                                                                                           \
+                        (((PULONG)pBIH)[3] == 0x0ff00000 && ((PUSHORT)pBIH)[8] == 0xffff)  /*black and white*/  \
+                || (((PULONG)pBIH)[3] == 0x00ffffff && ((PUSHORT)pBIH)[8] == 0x0000)  /*white and black*/  \
+                )                                                                                                       \
+        )
+
+static ULONG Convert1BitTo4Bit(void *pNewData, PBYTE pbOldData, LONG cx, LONG cy);
+static ULONG QueryPaletteSize(WINBITMAPINFOHEADER *pBHdr);
+static ULONG QueryPaletteSize(BITMAPINFOHEADER *pBHdr);
+static ULONG QueryPaletteSize(BITMAPINFOHEADER2 *pBHdr);
+static ULONG CalcBitmapSize(ULONG cBits, LONG cx, LONG cy);
+
+//******************************************************************************
+//******************************************************************************
+void *ConvertBitmap(WINBITMAPINFOHEADER *pBHdr, ULONG ulSize, PULONG pulSize)
+{
+        ltassert((ULONG)pBHdr > MINPTR && (ULONG)pBHdr+ulSize < MAXPTR);
+
+  	switch (pBHdr->biSize)
+        {
+        /**************************************/
+        /* Windows v3.0 bitmap                */
+        /**************************************/
+      	case sizeof(WINBITMAPINFOHEADER):
+        {//convert to OS/2 v2.0 bitmap
+        	PBITMAPFILEHEADER2 pBFH;
+                ULONG cbPalette;
+                ULONG cbImage;
+                BOOL fConvert1Bit = FALSE;
+
+                dprintf(("Windows v3.0 bitmap"));
+                dprintf(("  Size:     %d", pBHdr->biSizeImage));
+                dprintf(("  Width:    %d", pBHdr->biWidth));
+                dprintf(("  Height:   %d", pBHdr->biHeight));
+                dprintf(("  Bitcount: %d", pBHdr->biBitCount));
+                dprintf(("  Compress: %d", pBHdr->biCompression));
+
+                fConvert1Bit = Need1BitTo4BitConvertWIN(pBHdr);
+
+                cbPalette = QueryPaletteSize(pBHdr);
+                ltassert(cbPalette != -1);
+                dprintf(("  PaletteSize: %d",  cbPalette));
+
+                /* calc bitmap size and allocate */
+#ifdef BITFIELDS
+                if (pBHdr->biCompression == BI_RGB || pBHdr->biCompression == BI_BITFIELDS)
+#else
+                if (pBHdr->biCompression == BI_RGB)
+#endif
+                {
+                    	/* recalc for non-compressed images */
+                        if (fConvert1Bit)
+                        	cbImage = CalcBitmapSize(4, pBHdr->biWidth, pBHdr->biHeight);
+                        else    cbImage = CalcBitmapSize(pBHdr->biBitCount, pBHdr->biWidth, pBHdr->biHeight);
+                }
+                else
+                {
+                        ltassert(!fConvert1Bit);
+                        cbImage = pBHdr->biSizeImage;
+                        if (cbImage == 0)
+                          	cbImage = ulSize - sizeof(WINBITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER2);
+                        }
+                        ltassert(cbImage != 0);
+
+                        //bounds checking
+                        if (!fConvert1Bit)
+                        {       /* brackets must not be removed! */
+                                ltassert(cbImage <= ulSize - sizeof(WINBITMAPINFOHEADER) - cbPalette);
+                        }
+                        else    ltassert(CalcBitmapSize(pBHdr->biBitCount, pBHdr->biWidth, pBHdr->biHeight) <= ulSize - sizeof(WINBITMAPINFOHEADER) - cbPalette);
+
+                        *pulSize =  sizeof(BITMAPFILEHEADER2) + cbPalette + cbImage;
+
+                        dprintf(("  Debug: Size(recalced): %d",  cbImage));
+                        dprintf(("  Debug: Size in       : %d",  ulSize));
+                        dprintf(("  Debug: Size out      : %D",  *pulSize));
+
+                        pBFH = (PBITMAPFILEHEADER2)malloc(*pulSize + 0x10);//allocate more than we need!
+                        ltassert(pBFH);
+
+                        /* file header */
+                        pBFH->usType     = BFT_BMAP;
+                        pBFH->cbSize     = sizeof(BITMAPFILEHEADER2);
+                        pBFH->xHotspot   = 0;
+                        pBFH->yHotspot   = 0;
+                        pBFH->offBits    = sizeof(BITMAPFILEHEADER2) +  cbPalette;
+
+                        /* info header*/
+                        memset((void*)&pBFH->bmp2, 0, sizeof(BITMAPINFOHEADER2));
+                        memcpy((void*)&pBFH->bmp2, (void*)pBHdr, sizeof(WINBITMAPINFOHEADER));
+                        pBFH->bmp2.cbFix = sizeof(BITMAPINFOHEADER2);
+
+                        /* bitfields */
+                        if (pBFH->bmp2.ulCompression == BI_BITFIELDS)
+                        {//TODO: Identical except for BI_BITFIELDS (3L) type! - cast a warning note
+                                /* KSO: I need files to test it on */
+#ifndef BITFIELDS
+                                dprintf(("Warning: ulCompression = BI_BITFIELDS"));
+                                pBFH->bmp2.ulCompression = BCA_UNCOMP; //since BI_BITFIELDS == BCA_RLE24
+#else
+#error("Sorry, BITFIELDS are not implmented yet.")
+               /* generate new palette */
+               /* convert bitmap data */
+               /* update fileheader */
+#endif //#ifdef BITFIELDS
+                        }
+
+                        /* palette */
+                        if (cbPalette > 0)
+                                memcpy((void*)((ULONG)pBFH + sizeof(BITMAPFILEHEADER2)), (void*)((ULONG)pBHdr + sizeof(WINBITMAPINFOHEADER)), cbPalette);
+
+                        /* bitmap data */
+                        if (fConvert1Bit)
+                        {
+                                /* convert */
+                                Convert1BitTo4Bit(
+                                        (PVOID)((ULONG)pBFH + sizeof(BITMAPFILEHEADER2)   + cbPalette),
+                                        (PBYTE)((ULONG)pBHdr + sizeof(WINBITMAPINFOHEADER)+ cbPalette),
+                                        pBFH->bmp2.cx,
+                                        pBFH->bmp2.cy
+                                        );
+
+                                /* update some infoheader fields */
+                                pBFH->bmp2.cBitCount = 4;
+                                if (pBFH->bmp2.cclrUsed == 0)
+                                        pBFH->bmp2.cclrUsed = 2;
+                                if (pBFH->bmp2.cbImage != 0)
+                                        pBFH->bmp2.cbImage = cbImage;
+                        }
+                        else  	memcpy((void*)((ULONG)pBFH + sizeof(BITMAPFILEHEADER2) + cbPalette), (void*)((ULONG)pBHdr + sizeof(WINBITMAPINFOHEADER) + cbPalette), cbImage);
+
+                        return pBFH;
+                }
+
+      	/**************************************/
+	/* Windows v4.0 bitmap                */
+      	/**************************************/
+        case sizeof(BITMAPV4HEADER):
+        {//convert to OS/2 v2.0 bitmap - some other day when I find the specs.
+                dprintf(("Windows v4.0 bitmap"));
+                dprintf(("  Not supported yet!"));
+                ltassert(FALSE && "Windows v4.0 bitmap");
+	        break;
+        }
+
+        /**************************************/
+        /* OS/2 v1.x bitmap                   */
+        /**************************************/
+        case sizeof(BITMAPINFOHEADER):
+        {//no conversion needed - only build fileheader
+         	PBITMAPINFOHEADER pBIH = (PBITMAPINFOHEADER)pBHdr;
+         	PBITMAPFILEHEADER pBFH ;
+         	BOOL fConvert1Bit;
+                ULONG cbPalette;
+
+                cbPalette = QueryPaletteSize(pBIH);
+                ltassert(cbPalette != -1);
+                *pulSize = ulSize + sizeof(BITMAPFILEHEADER) - sizeof(BITMAPINFOHEADER);
+
+                fConvert1Bit = Need1BitTo4BitConvertOS2(pBIH);
+                if (fConvert1Bit)
+                   	*pulSize += (ulSize - cbPalette - sizeof(BITMAPINFOHEADER))*3 + 14 * sizeof(RGB);
+
+                pBFH = (PBITMAPFILEHEADER)malloc(*pulSize);
+                ltassert(pBFH != NULL);
+
+                if (fConvert1Bit)
+                {
+                     	/* copy infoheader */
+                        memcpy(&pBFH->bmp, pBIH, sizeof(pBFH->bmp));
+                        memset((void*)((ULONG)pBFH + sizeof(*pBFH)), 0, 16*sizeof(RGB));
+                        memcpy((void*)((ULONG)pBFH + sizeof(*pBFH)), (void*)((ULONG)pBIH + sizeof(*pBIH)), 2*sizeof(RGB));
+                        *pulSize  = Convert1BitTo4Bit(
+                                        (PVOID)((ULONG)pBFH + sizeof(BITMAPFILEHEADER) + 16 * sizeof(RGB)),
+                                        (PBYTE)((ULONG)pBHdr + sizeof(BITMAPINFOHEADER) + cbPalette),
+                                        pBFH->bmp.cx,
+                                        pBFH->bmp.cy
+                                        );
+
+                        /* update infoheader */
+                        pBFH->bmp.cBitCount = 4;
+                        cbPalette = 16 * sizeof(RGB); //used in fileheader
+                }
+                else
+                {
+                        /* copy entire bitmap from infoheader */
+                        memcpy(&pBFH->bmp, pBIH, ulSize);
+                        *pulSize  = CalcBitmapSize(pBIH->cBitCount, pBIH->cx, pBIH->cy);
+                        ltassert(*pulSize != 0);
+                }
+                *pulSize += sizeof(BITMAPFILEHEADER) + cbPalette;
+
+                /* fileheader */
+                pBFH->usType     = BFT_BMAP;
+                pBFH->cbSize     = sizeof(BITMAPFILEHEADER);
+                pBFH->xHotspot   = 0;
+                pBFH->yHotspot   = 0;
+                pBFH->offBits    = sizeof(BITMAPFILEHEADER) + cbPalette;
+
+                /* log info */
+                dprintf(("OS/2 v1.x bitmap"));
+                dprintf(("  Width:       %d",  pBFH->bmp.cx));
+                dprintf(("  Height:      %d",  pBFH->bmp.cy));
+                dprintf(("  Bitcount:    %d",  pBFH->bmp.cBitCount));
+                dprintf(("  PaletteSize: %d",  cbPalette));
+                dprintf(("debug 1"));
+
+                return (void*)pBFH;
+        }
+
+        /**************************************/
+        /* OS/2 v2.0 bitmap - highly unlikely!*/
+        /**************************************/
+        case sizeof(BITMAPINFOHEADER2):
+        {//no conversion needed - only build fileheader
+         	PBITMAPFILEHEADER2 pBFH;
+
+                pBFH = (PBITMAPFILEHEADER2)malloc(ulSize + sizeof(BITMAPFILEHEADER2) - sizeof(BITMAPINFOHEADER2));
+                ltassert(pBFH != NULL);
+
+                memcpy(&pBFH->bmp2, pBHdr, ulSize);
+
+                pBFH->usType     = BFT_BMAP;
+                pBFH->cbSize     = sizeof(BITMAPFILEHEADER2);
+                pBFH->xHotspot   = 0;
+                pBFH->yHotspot   = 0;
+                pBFH->offBits    = sizeof(BITMAPFILEHEADER2);
+
+                dprintf(("OS/2 v2.0 bitmap"));
+                dprintf(("  Width:    %d",  pBFH->bmp2.cx));
+                dprintf(("  Height:   %d",  pBFH->bmp2.cy));
+                dprintf(("  Bitcount: %d",  pBFH->bmp2.cBitCount));
+
+                if (pBFH->bmp2.cBitCount < 24)
+                    	pBFH->offBits += ( 1,  pBFH->bmp2.cBitCount ) * sizeof(RGB2);
+                else    pBFH->offBits += pBFH->bmp2.cclrUsed;
+
+                return pBFH;
+        }
+
+
+        /**************************************/
+        /* Unknown                            */
+        /**************************************/
+        default: //fail
+                dprintf(("ConvertBitmap - default - fail!"));
+                return NULL;
+        }
+
+        return NULL;
+}
+//******************************************************************************
+//******************************************************************************
+/* Converting 1 bit bitmaps to 4 bit bitmaps
+ */
+//******************************************************************************
+//******************************************************************************
+static ULONG  Convert1BitTo4Bit(void *pNewData, PBYTE pbOldData, LONG cx, LONG cy)
+{
+        PBYTE pbNewData = (PBYTE)pNewData;
+
+        dprintf(("  1->4 convert"));
+
+        //negative height
+        cy = cy < 0 ? -cy : cy;
+
+        *pbNewData = 0;
+        for (int y = 0; y < cy; y++)
+        {//outer loop: lines
+                int x;
+
+                for (x = 0; x < cx; x++)
+                {//inner loop: scanline
+                        int iBit = 7-(x%8);
+                        *pbNewData |= (((0x1,  iBit) & *pbOldData) >> iBit),  (iBit%2)*4;
+
+                        if (x % 2)
+                        {
+                                pbNewData++;
+                                *pbNewData = 0;
+                        }
+
+                        if ((x+1) % 8 == 0)
+                                pbOldData++;
+                }
+
+                //next byte
+                if (x % 2)
+                {
+                        pbNewData++;
+                        *pbNewData = 0;
+                }
+                if ((x+1) % 8 == 0)
+                        pbOldData++;
+
+                //aligning
+                for (int a = ((x+1)/2)%4; a < 4 && a != 0; a++)
+                {
+                        pbNewData++;
+                        *pbNewData = 0;
+                }
+                for (int b = ((x+7)/8)%4; b < 4 && b != 0; b++)
+                        pbOldData++;
+        }
+
+        return (int)pbNewData - (int)pNewData;
+}
+//******************************************************************************
+//******************************************************************************
+static ULONG QueryPaletteSize(WINBITMAPINFOHEADER *pBHdr)
+{
+        ULONG cbPalette;
+
+        switch (pBHdr->biBitCount)
+        {
+                case 1:
+                case 4:
+                case 8:
+                        /* Windows Bitmaps seems to have a full palette even when it don't use all of it - OS/2 does not...
+                           Good for us, the fileheader holds the offset to the bitmap data - which means that this not should be a problem, luckily. */
+                        //cbPalette = ((pBHdr->biClrUsed != 0) ? pBHdr->biClrUsed : 1,  pBHdr->biBitCount) * sizeof(RGB2);
+                        cbPalette =  (1,  pBHdr->biBitCount) * sizeof(RGB2);
+                        break;
+
+                case 16:
+                case 32:
+                        #ifdef BITFIELDS
+                                if (pBHdr->biCompression == BI_BITFIELDS)
+                                {
+                                        cbPalette = 3* sizeof(DWORD);
+                                        break;
+                                }
+                        #endif
+                case 24:
+                        /* docs have it that there may be a palette used for optmizing processing of 16, 24 and 32 bits bitmaps */
+                        /* the size of the palette is contained in biClrUsed  - don't know if it stored as number of colors or as bytes... */
+                        cbPalette = pBHdr->biClrUsed; //size in bytes or in (*sizeof(RGB2))?
+                        break;
+
+                default:
+                        dprintf(("QueryPaletteSize: error pBHdr->biBitCount = %d",  pBHdr->biBitCount));
+                        cbPalette = -1;
+        }
+
+   return cbPalette;
+}
+//******************************************************************************
+//******************************************************************************
+static ULONG QueryPaletteSize(BITMAPINFOHEADER *pBHdr)
+{
+        ULONG cbPalette;
+
+        switch (pBHdr->cBitCount)
+        {
+                case 1:
+                case 4:
+                case 8:
+                        cbPalette = (1,  pBHdr->cBitCount) * sizeof(RGB);
+                        break;
+
+                case 16:
+                case 24:
+                case 32:
+                        cbPalette = 0;
+                        break;
+
+                default:
+                        dprintf(("QueryPaletteSize: error pBHdr->biBitCount = %d",  pBHdr->cBitCount));
+                        cbPalette = -1;
+        }
+
+   return cbPalette;
+}
+//******************************************************************************
+//******************************************************************************
+static ULONG QueryPaletteSize(BITMAPINFOHEADER2 *pBHdr)
+{
+        ULONG cbPalette;
+
+        switch (pBHdr->cBitCount)
+        {
+                case 1:
+                case 4:
+                case 8:
+                        cbPalette = ((pBHdr->cclrUsed != 0) ? pBHdr->cclrUsed : 1,  pBHdr->cBitCount) * sizeof(RGB2);
+                        //cbPalette =  (1,  pBHdr->cBitCount) * sizeof(RGB2);
+                        break;
+
+                case 16:
+                case 32:
+                case 24:
+                        /* docs have it that there may be a palette used for optmizing processing of 16, 24 and 32 bits bitmaps */
+                        /* the size of the palette is contained in biClrUsed  - don't know if it stored as number of colors or as bytes... */
+                        cbPalette = pBHdr->cclrUsed; //size in bytes or in (*sizeof(RGB2))?
+                        break;
+
+                default:
+                        dprintf(("QueryPaletteSize: error pBHdr->biBitCount = %d",  pBHdr->cBitCount));
+                        cbPalette = -1;
+        }
+
+        return cbPalette;
+}
+//******************************************************************************
+//******************************************************************************
+static ULONG CalcBitmapSize(ULONG cBits, LONG cx, LONG cy)
+{
+        ULONG alignment;
+        ULONG factor;
+        BOOL flag = TRUE;       //true: '*'     false: '/'
+
+        cy = cy < 0 ? -cy : cy;
+
+        switch(cBits)
+        {
+                case 1:
+                        factor = 8;
+                        flag = FALSE;
+                        break;
+
+                case 4:
+                        factor = 2;
+                        flag = FALSE;
+                        break;
+
+                case 8:
+                        factor = 1;
+                        break;
+
+                case 16:
+                        factor = 2;
+                        break;
+
+                case 24:
+                        factor = 3;
+                        break;
+
+                case 32:
+                        return cx*cy;
+
+                default:
+                        return 0;
+        }
+
+        if (flag)
+                alignment = (cx = (cx*factor)) % 4;
+        else
+                alignment = (cx = ((cx+factor-1)/factor)) % 4;
+
+        if (alignment != 0)
+                cx += 4 - alignment;
+
+        return cx*cy;
+}
+//******************************************************************************
+//******************************************************************************
+ULONG QuerySizeBitmap(WINBITMAPINFOHEADER *pBHdr, ULONG ulSize)
+{
+        ULONG retSize;
+        ltassert((ULONG)pBHdr > MINPTR && (ULONG)pBHdr+ulSize < MAXPTR);
+
+        switch (pBHdr->biSize)
+        {
+        /**************************************/
+        /* Windows v3.0 bitmap                */
+        /**************************************/
+        case sizeof(WINBITMAPINFOHEADER):
+        {//convert to OS/2 v2.0 bitmap
+#ifdef BITFIELDS
+        	if (pBHdr->biCompression == BI_RGB || pBHdr->biCompression == BI_BITFIELDS)
+#else
+                if (pBHdr->biCompression == BI_RGB)
+#endif
+                {
+	                if (Need1BitTo4BitConvertWIN(pBHdr))
+        		        retSize = CalcBitmapSize(4, pBHdr->biWidth, pBHdr->biHeight);
+                        else    retSize = CalcBitmapSize(pBHdr->biBitCount, pBHdr->biWidth, pBHdr->biHeight);
+                }
+                else
+                {
+                        retSize = pBHdr->biSizeImage;
+                        if (retSize == 0)
+                	        retSize = ulSize - sizeof(WINBITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER2);
+                }
+                ltassert(retSize != 0);
+
+                ULONG a = QueryPaletteSize(pBHdr);
+                ltassert(a != -1);
+                retSize += sizeof(BITMAPFILEHEADER2) + a;
+                break;
+        }
+
+        /**************************************/
+        /* Windows v4.0 bitmap                */
+        /**************************************/
+        case sizeof(BITMAPV4HEADER):
+        {//convert to OS/2 v2.0 bitmap - some other day when I find the specs.
+                ltassert(FALSE && "Windows v4.0 bitmap");
+                break;
+        }
+
+        /**************************************/
+        /* OS/2 v1.x bitmap                   */
+        /**************************************/
+        case sizeof(BITMAPINFOHEADER):
+        {//no conversion needed - only build fileheader
+                PBITMAPINFOHEADER pBIH = (PBITMAPINFOHEADER)pBHdr;
+
+                if (Need1BitTo4BitConvertOS2(pBIH))
+                {
+    	            retSize = CalcBitmapSize(4, pBIH->cx, pBIH->cy);
+                    ltassert(retSize != 0);
+
+                    retSize += sizeof(RGB)*16; //palette
+                }
+                else
+                {
+                    retSize = CalcBitmapSize(pBIH->cBitCount, pBIH->cx, pBIH->cy);
+                    ltassert(retSize != 0);
+
+                    ULONG a = QueryPaletteSize(pBIH);
+                    ltassert(a != -1);
+                    retSize += a;
+                }
+
+                retSize += sizeof(BITMAPFILEHEADER);
+        }
+
+        /**************************************/
+        /* OS/2 v2.0 bitmap - highly unlikely!*/
+        /**************************************/
+        case sizeof(BITMAPINFOHEADER2):
+        {//no conversion needed - only build fileheader
+                return ulSize + sizeof(BITMAPFILEHEADER2) - sizeof(BITMAPINFOHEADER2);
+        }
+
+        /**************************************/
+        /* Unknown                            */
+        /**************************************/
+        default: //fail
+                dprintf(("QuerySizeBitmap - default - fail!"));
+                return 0;
+        }
+
+        return retSize;
+}
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/kernel32/cvticon.cpp
===================================================================
--- trunk/src/kernel32/cvticon.cpp	(revision 581)
+++ trunk/src/kernel32/cvticon.cpp	(revision 581)
@@ -0,0 +1,146 @@
+/* $Id: cvticon.cpp,v 1.1 1999-08-19 14:19:14 sandervl Exp $ */
+
+/*
+ * PE2LX icons
+ *
+ * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
+ *
+ *
+ * Project Odin Software License can be found in LICENSE.TXT
+ *
+ */
+#define INCL_GPIBITMAPS
+#define INCL_BITMAPFILEFORMAT
+#define INCL_DOSFILEMGR          /* File Manager values      */
+#define INCL_DOSERRORS           /* DOS Error values         */
+#define INCL_DOSPROCESS          /* DOS Process values       */
+#define INCL_DOSMISC             /* DOS Miscellanous values  */
+#define INCL_WIN
+#include <os2wrap.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <string.h>
+#include <win32type.h>
+#include <winicon.h>
+#include <misc.h>
+
+//******************************************************************************
+//******************************************************************************
+void *ConvertIcon(WINBITMAPINFOHEADER *bmpHdr, int size)
+{
+ RGBQUAD *rgb;
+ RGB2    *os2rgb;
+ int bwsize, i, colorsize, rgbsize, iconsize;
+ BITMAPFILEHEADER2 *iconhdr;
+ BITMAPFILEHEADER2 *iconhdr2;
+
+  bwsize   = (bmpHdr->biWidth*(bmpHdr->biHeight/2))/8;
+  colorsize = bmpHdr->biWidth*(bmpHdr->biHeight/2);
+  //SvL: 28-09-'98: only for <= 8
+  if(bmpHdr->biBitCount <= 8)
+        rgbsize = (1<<bmpHdr->biBitCount)*sizeof(RGB2);
+  else  rgbsize = 0;
+
+  switch(bmpHdr->biBitCount) {
+        case 1:
+                colorsize /= 8;
+                break;
+        case 4:
+                colorsize /= 2;
+                break;
+        case 8:
+                break;
+        case 16:
+                colorsize *= 2;
+                break;
+        case 24:
+                colorsize *= 3;
+                break;
+        case 32:
+                colorsize *= 4;
+                break;
+  }
+  if(bmpHdr->biSizeImage == 0 && bmpHdr->biCompression == 0) {
+        bmpHdr->biSizeImage = bwsize + colorsize;
+  }
+  dprintf(("Icon size    : %d", bmpHdr->biSizeImage));
+  dprintf(("Icon Width   : %d", bmpHdr->biWidth));
+  //height for both the XOR and AND bitmap (color & BW)
+  dprintf(("Height       : %d", bmpHdr->biHeight));
+  dprintf(("Icon Bitcount: %d", bmpHdr->biBitCount));
+  dprintf(("Icon Compress: %d", bmpHdr->biCompression));
+
+  //SvL: 28-09-'98: cllngenu.dll has an incorrect size in the header
+  if(bmpHdr->biSizeImage < colorsize) {
+        bmpHdr->biSizeImage = colorsize;
+  }
+  //bitmapfileheader for AndXor mask + 2 RGB structs + bitmapfileheader
+  //for color bitmap + RGB structs for all the colors
+  //SvL, 3-3-98: 2*bwsize
+  iconsize = 2*sizeof(BITMAPFILEHEADER2) + 2*sizeof(RGB2) +
+             rgbsize + 2*bwsize + bmpHdr->biSizeImage;
+  //There are icons without an XOR mask, so check for it
+  if(bmpHdr->biSizeImage == colorsize) {
+        iconsize += bwsize;
+  }
+  iconhdr  = (BITMAPFILEHEADER2 *)malloc(iconsize);
+  memset(iconhdr, 0, iconsize);
+  iconhdr->usType        = BFT_COLORICON;
+  iconhdr->cbSize        = sizeof(BITMAPFILEHEADER2);
+  iconhdr->xHotspot      = 0;
+  iconhdr->yHotspot      = 0;
+  iconhdr->offBits       = 2*sizeof(BITMAPFILEHEADER2) +
+                           2*sizeof(RGB2) + rgbsize;
+  iconhdr->bmp2.cbFix    = sizeof(BITMAPINFOHEADER2);
+  iconhdr->bmp2.cx       = (USHORT)bmpHdr->biWidth;
+  iconhdr->bmp2.cy       = (USHORT)bmpHdr->biHeight;
+  iconhdr->bmp2.cPlanes  = 1;
+  iconhdr->bmp2.cBitCount= 1;
+  iconhdr->bmp2.ulCompression   = BCA_UNCOMP;
+  iconhdr->bmp2.ulColorEncoding = BCE_RGB;
+  os2rgb                 = (RGB2 *)(iconhdr+1);
+  memset(os2rgb, 0, sizeof(RGB2));
+  memset(os2rgb+1, 0xff, sizeof(RGB2)); //not reserved byte
+  iconhdr2               = (BITMAPFILEHEADER2 *)(os2rgb+2);
+  iconhdr2->usType       = BFT_COLORICON;
+  iconhdr2->cbSize       = sizeof(BITMAPFILEHEADER2);
+  iconhdr2->xHotspot     = 0;
+  iconhdr2->yHotspot     = 0;
+  iconhdr2->offBits      = 2*sizeof(BITMAPFILEHEADER2) +
+                           2*sizeof(RGB2) + rgbsize + 2*bwsize;
+  iconhdr2->bmp2.cbFix   = sizeof(BITMAPINFOHEADER2);
+  iconhdr2->bmp2.cx      = (USHORT)bmpHdr->biWidth;
+  iconhdr2->bmp2.cy      = (USHORT)(bmpHdr->biHeight/2);
+  iconhdr2->bmp2.cPlanes = bmpHdr->biPlanes;
+  iconhdr2->bmp2.cBitCount= bmpHdr->biBitCount;
+  iconhdr2->bmp2.ulCompression   = BCA_UNCOMP;
+  iconhdr2->bmp2.ulColorEncoding = BCE_RGB;
+  os2rgb                 = (RGB2 *)(iconhdr2+1);
+  rgb                    = (RGBQUAD *)(bmpHdr+1);
+  if(bmpHdr->biBitCount < 24) {
+        for(i=0;i<(1<<bmpHdr->biBitCount);i++) {
+                os2rgb->bRed   = rgb->red;
+                os2rgb->bBlue  = rgb->blue;
+                os2rgb->bGreen = rgb->green;
+                os2rgb++;
+                rgb++;
+        }
+  }
+  //write 2*mono pixels + color pixels
+  //There are icons without an XOR mask, so check for it
+  if(bmpHdr->biSizeImage == colorsize) 
+  {
+        memset((char *)os2rgb, 0, bwsize);
+        memset((char *)os2rgb+bwsize, 0, bwsize);
+        memcpy((char *)os2rgb+2*bwsize, (char *)rgb, colorsize);
+  }
+  else {
+        memcpy((char *)os2rgb, (char *)rgb+colorsize, bwsize);
+        memcpy((char *)os2rgb+bwsize, (char *)rgb+colorsize, bwsize);
+        memcpy((char *)os2rgb+2*bwsize, (char *)rgb, colorsize);
+  }
+  return (void *)iconhdr;
+}
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/kernel32/cvtmenu.cpp
===================================================================
--- trunk/src/kernel32/cvtmenu.cpp	(revision 581)
+++ trunk/src/kernel32/cvtmenu.cpp	(revision 581)
@@ -0,0 +1,280 @@
+/* $Id: cvtmenu.cpp,v 1.1 1999-08-19 14:19:14 sandervl Exp $ */
+
+/*
+ * PE2LX menu conversion code
+ *
+ * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
+ *
+ *
+ * Project Odin Software License can be found in LICENSE.TXT
+ *
+ */
+#define INCL_DOSFILEMGR          /* File Manager values      */
+#define INCL_DOSERRORS           /* DOS Error values         */
+#define INCL_DOSPROCESS          /* DOS Process values       */
+#define INCL_DOSMISC             /* DOS Miscellanous values  */
+#define INCL_DOSNLS
+#define INCL_WIN
+#include <os2wrap.h>
+#include <pmmenu.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <string.h>
+#include <win32type.h>
+#include <winmenu.h>
+#include <misc.h>
+#include "cvtresource.h"
+
+static int  ProcessSubMenu(PopupMenuItem *popupitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size, int cp);
+static int  ProcessMenuItem(NormalMenuItem *popupitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size, int cp);
+static void menustrcpy(char *dest, char *src);
+//******************************************************************************
+//******************************************************************************
+void *ConvertMenu(MenuHeader *menu, int size, int cp)
+{
+  PopupMenuItem  *popupitem = (PopupMenuItem *)((char *)menu + sizeof(MenuHeader));
+  NormalMenuItem *normalitem = (NormalMenuItem *)((char *)menu + sizeof(MenuHeader));
+  MT_OS2  *os2menu, *submenu;
+  MTI_OS2 *menuitem;
+  int newsize;
+  ULONG   ulCpSize, ulCP;
+
+  os2menu           = (MT_OS2 *)malloc(size*4); //should always be sufficient
+  os2menu->len      = sizeof(MT_OS2) - sizeof(MTI_OS2);
+  if(cp == 0) {
+    	os2menu->codepage = 437;
+  }
+  else
+  {
+    	DosQueryCp(sizeof(ulCP), &ulCP, &ulCpSize);
+    	os2menu->codepage = ulCP;
+  }
+  os2menu->reserved = 4;
+  os2menu->cMti     = 0;
+  menuitem          = &os2menu->rgMti[0];
+  submenu           = os2menu;
+  while(size > 4) 
+  {
+    	if(popupitem->fItemFlags & POPUP) {
+         	dprintf(("POPUP "));
+         	newsize = ProcessSubMenu(popupitem, os2menu, menuitem, size, cp);
+    	}
+    	else 	newsize = ProcessMenuItem(normalitem, os2menu, menuitem, size, cp);
+
+    	if(popupitem->fItemFlags & ENDMENU) break;
+
+    	popupitem  = (PopupMenuItem *)((char *)popupitem + (size - newsize));
+    	normalitem = (NormalMenuItem *)((char *)normalitem + (size - newsize));
+
+    	menuitem   = (MTI_OS2 *)((int)os2menu + os2menu->len);
+    	size       = newsize;
+  }
+  return (void *)os2menu;
+}
+//******************************************************************************
+//******************************************************************************
+static int ProcessSubMenu(PopupMenuItem *popupitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size, int cp)
+{
+ static          int uniqueid = 0;
+ NormalMenuItem *normalitem;
+ MT_OS2         *submenu;
+ int             len = 0, newsize;
+ ULONG           ulCpSize, ulCP;
+ char           *menuname;
+
+  menuitem->afStyle = MIS_SUBMENU;
+
+  //A unique id is sufficient, since it's not possible to get info about
+  //the SUBMENU item being selected with the (win32) WM_INITMENU message
+  //(this is possible in OS/2)
+  menuitem->idItem  = (USHORT)uniqueid++;
+  menuitem->pad     = 0;
+
+  if(popupitem->fItemFlags & GRAYED) {
+    	dprintf(("GRAYED "));
+    	menuitem->pad     |= MIA_DISABLED;
+  }
+  if(popupitem->fItemFlags & INACTIVE) {
+    	dprintf(("INACTIVE "));
+    	menuitem->pad     |= MIA_DISABLED;
+  }
+  if(popupitem->fItemFlags & BITMAP) {
+    	dprintf(("BITMAP "));
+    	//where's the bitmap stored? (same id as id of this menu item?)
+    	menuitem->afStyle |= MIS_BITMAP;
+  }
+  if(popupitem->fItemFlags & OWNERDRAW) {
+    	dprintf(("OWNERDRAW "));
+    	menuitem->afStyle |= MIS_OWNERDRAW;
+  }
+  if(popupitem->fItemFlags & CHECKED) {
+    	menuitem->pad     |= MIA_CHECKED;
+    	dprintf(("CHECKED "));
+  }
+  if(popupitem->fItemFlags & MENUBREAK) {
+    	menuitem->afStyle |= MIS_BREAK;
+    	menuitem->pad     |= MIA_DISABLED;
+    	dprintf(("MENUBREAK "));
+  }
+  if(popupitem->fItemFlags & MENUBARBREAK) {
+    	dprintf(("MENUBARBREAK"));
+    	menuitem->afStyle |= MIS_BREAKSEPARATOR;
+    	menuitem->pad     |= MIA_DISABLED;
+    	menuitem->c[0]     = 0;
+    	menuitem->c[1]     = 0;
+  }
+  else {
+    	len = (UniStrlen(popupitem->szItemText)+1)*2;
+	menuname = UnicodeToAsciiString(popupitem->szItemText);
+    	dprintf(("%s", menuname));
+    	menustrcpy(menuitem->c, menuname);
+	FreeAsciiString(menuname);
+  }
+  os2menu->len += sizeof(MTI_OS2);
+  if(len > 4) os2menu->len += (len/2 - sizeof(menuitem->c));
+  os2menu->cMti++;
+
+  size -= (sizeof(PopupMenuItem)-2 + len);  /*PLF Sat  97-06-21 22:17:51*/
+  //process next menu item
+  submenu = (MT_OS2 *)(menuitem+1);
+  if(len > 4) {
+        submenu = (MT_OS2 *)((char *)submenu + len/2 - sizeof(menuitem->c));
+  }
+
+  submenu->len = sizeof(MT_OS2) - sizeof(MTI_OS2);
+
+  if(cp == 0) {
+    	submenu->codepage = 437;
+  }
+  else
+  {
+    DosQueryCp(sizeof(ulCP), &ulCP, &ulCpSize);
+    submenu->codepage = ulCP;
+  }
+
+  submenu->reserved = 4;
+  submenu->cMti     = 0;
+  menuitem          = &submenu->rgMti[0];
+
+  //normalitem = (NormalMenuItem *)(popupitem + 1);
+  normalitem = (NormalMenuItem *)((char*)popupitem + sizeof(PopupMenuItem)-2);  /*PLF Sat  97-06-21 23:54:50*/
+  normalitem = (NormalMenuItem *)((int)normalitem + len);
+
+  while(size > 4) {
+        if(normalitem->fItemFlags & POPUP) {
+            	dprintf(("POPUP "));
+            	newsize = ProcessSubMenu((PopupMenuItem *)normalitem, submenu, menuitem, size, cp);
+        }
+        else    newsize = ProcessMenuItem(normalitem, submenu, menuitem, size, cp);
+
+        menuitem = (MTI_OS2 *)((int)submenu + submenu->len);
+        if(normalitem->fItemFlags & ENDMENU) {
+            	os2menu->len += submenu->len;
+            	return(newsize);
+        }
+        normalitem = (NormalMenuItem *)((char *)normalitem + (size - newsize));
+        size       = newsize;
+  }
+  os2menu->len += submenu->len;
+  return(size);
+}
+//******************************************************************************
+//******************************************************************************
+static int ProcessMenuItem(NormalMenuItem *normalitem, MT_OS2 *os2menu, MTI_OS2 *menuitem, int size, int cp)
+{
+ WCHAR *menustring;
+ int    len = 0;
+ char  *menuname;
+
+  dprintf(("ID %d ", normalitem->wMenuID));
+  menustring        = normalitem->szItemText;
+  menuitem->afStyle = MIS_TEXT;
+  menuitem->idItem  = normalitem->wMenuID;
+  menuitem->pad     = 0;
+
+  if(normalitem->fItemFlags & ENDMENU) {
+    	//signals the end of a (sub)menu
+    	dprintf(("ENDMENU"));
+    	len   = (UniStrlen(normalitem->szItemText)+1)*2;
+    	//don't store this menu item, is it's empty
+    	if(len == 2) {
+        	size -= (sizeof(NormalMenuItem)-2 + len);
+        	return(size);
+    	}
+  }
+  if(normalitem->fItemFlags & GRAYED) {
+    	dprintf(("GRAYED "));
+    	menuitem->pad     |= MIA_DISABLED;
+  }
+  if(normalitem->fItemFlags & INACTIVE) {
+    	dprintf(("INACTIVE "));
+    	menuitem->pad     |= MIA_DISABLED;
+  }
+  if(normalitem->fItemFlags & BITMAP) {
+    	dprintf(("BITMAP "));
+    	//where's the bitmap stored? (same id as id of this menu item?)
+    	menuitem->afStyle |= MIS_BITMAP;
+  }
+  if(normalitem->fItemFlags & OWNERDRAW) {
+    	dprintf(("OWNERDRAW "));
+    	menuitem->afStyle |= MIS_OWNERDRAW;
+  }
+  if(normalitem->fItemFlags & CHECKED) {
+    	menuitem->pad     |= MIA_CHECKED;
+    	dprintf(("CHECKED "));
+  }
+  if(normalitem->fItemFlags & MENUBREAK) {
+    	menuitem->afStyle |= MIS_BREAK;
+    	menuitem->pad     |= MIA_DISABLED;
+    	dprintf(("MENUBREAK "));
+  }
+  if(normalitem->fItemFlags & MENUBARBREAK) {
+    	dprintf(("MENUBARBREAK"));
+    	menuitem->afStyle |= MIS_BREAKSEPARATOR;
+    	menuitem->pad     |= MIA_DISABLED;
+    	menuitem->c[0]     = 0;
+    	menuitem->c[1]     = 0;
+  }
+  else {
+    	len = (UniStrlen(normalitem->szItemText)+1)*2;
+        if(normalitem->fItemFlags == 0 && len == 2) {
+        	dprintf(("SEPARATOR"));
+        	menuitem->afStyle  = MIS_SEPARATOR;
+        	menuitem->pad      = MIA_DISABLED;
+        	menuitem->idItem   = 0xFFFF;
+        	menuitem->c[0]     = 0;
+        	menuitem->c[1]     = 0;
+    	}
+    	else {
+		menuname = UnicodeToAsciiString(normalitem->szItemText);
+	    	dprintf(("%s", menuname));
+	    	menustrcpy(menuitem->c, menuname);
+		FreeAsciiString(menuname);
+    	}
+  }
+  os2menu->len += sizeof(MTI_OS2);
+  //SvL: Bugfix (>4), 19-10-'97
+  if(len >= 4) os2menu->len += (len/2 - sizeof(menuitem->c));
+  else         os2menu->len -= 2;   //REQUIRED (even though mi->c[2])
+
+  os2menu->cMti++;
+
+  size -= (sizeof(NormalMenuItem)-2 + len); /*PLF Sat  97-06-21 22:19:57*/
+
+  return(size);
+}
+//******************************************************************************
+//******************************************************************************
+static void menustrcpy(char *dest, char *src)
+{
+ int i, len = strlen(src);
+
+  for(i=0;i<len;i++) {
+    	if(src[i] == '&')   	dest[i] = '~';
+    	else            	dest[i] = src[i];
+  }
+  dest[len] = 0;
+}
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/kernel32/cvtresource.h
===================================================================
--- trunk/src/kernel32/cvtresource.h	(revision 581)
+++ trunk/src/kernel32/cvtresource.h	(revision 581)
@@ -0,0 +1,17 @@
+/* $Id: cvtresource.h,v 1.1 1999-08-19 14:19:14 sandervl Exp $ */
+
+#ifndef _CVTRESOURCE_H_
+#define _CVTRESOURCE_H_
+
+#include <winmenu.h>
+#include <winicon.h>
+#include <winaccel.h>
+
+void *ConvertAccelerator(WINACCEL *accdata, int size, int cp = 0);
+void *ConvertBitmap(WINBITMAPINFOHEADER *pBHdr, ULONG ulSize, PULONG pulSize);
+void *ConvertMenu(MenuHeader *menu, int size, int cp = 0);
+void *ConvertIcon(WINBITMAPINFOHEADER *bmpHdr, int size);
+
+
+#endif /* _CVTRESOURCE_H_ */
+
Index: trunk/src/kernel32/kernel32exp.def
===================================================================
--- trunk/src/kernel32/kernel32exp.def	(revision 579)
+++ trunk/src/kernel32/kernel32exp.def	(revision 581)
@@ -1,3 +1,3 @@
-; $Id: kernel32exp.def,v 1.10 1999-08-18 17:18:00 sandervl Exp $
+; $Id: kernel32exp.def,v 1.11 1999-08-19 14:19:14 sandervl Exp $
 
 ;Created by BLAST for IBM's compiler
@@ -841,2 +841,3 @@
    _GetThreadTHDB@0			   @1235
 
+   _CreateWin32Exe@4                       @1236
Index: trunk/src/kernel32/makefile
===================================================================
--- trunk/src/kernel32/makefile	(revision 579)
+++ trunk/src/kernel32/makefile	(revision 581)
@@ -1,3 +1,3 @@
-# $Id: makefile,v 1.19 1999-08-19 12:53:18 sandervl Exp $
+# $Id: makefile,v 1.20 1999-08-19 14:19:15 sandervl Exp $
 
 #
@@ -76,4 +76,8 @@
        disk.obj \
        directory.obj \
+       cvtbitmap.obj \
+       cvtmenu.obj \
+       cvtaccel.obj \
+       cvticon.obj \
        stubs.obj
 
@@ -349,4 +353,8 @@
 stubs.obj:     stubs.cpp stubs.h
 
+cvtbitmap.obj: cvtbitmap.cpp $(PDWIN32_INCLUDE)\winicon.h $(PDWIN32_INCLUDE)\misc.h cvtresource.h
+cvtmenu.obj: cvtmenu.cpp $(PDWIN32_INCLUDE)\winmenu.h $(PDWIN32_INCLUDE)\misc.h cvtresource.h
+cvtaccel.obj: cvtaccel.cpp $(PDWIN32_INCLUDE)\winaccel.h $(PDWIN32_INCLUDE)\misc.h cvtresource.h
+cvticon.obj: cvticon.cpp $(PDWIN32_INCLUDE)\winicon.h $(PDWIN32_INCLUDE)\misc.h cvtresource.h
 
 clean:
Index: trunk/src/kernel32/winres.cpp
===================================================================
--- trunk/src/kernel32/winres.cpp	(revision 579)
+++ trunk/src/kernel32/winres.cpp	(revision 581)
@@ -1,3 +1,3 @@
-/* $Id: winres.cpp,v 1.7 1999-08-19 12:53:19 sandervl Exp $ */
+/* $Id: winres.cpp,v 1.8 1999-08-19 14:19:15 sandervl Exp $ */
 
 /*
@@ -29,4 +29,5 @@
 #include <nameid.h>
 #include <winexe.h>
+#include "cvtresource.h"
 
 static ULONG CalcBitmapSize(ULONG cBits, LONG cx, LONG cy)
@@ -196,5 +197,5 @@
         rc = DosGetResource((HMODULE)module->hinstance, RT_BITMAP, id, (PPVOID)&resdata);
         if(rc)  return(NULL);
-        winresdata = ConvertBitmap((BITMAPFILEHEADER2 *)resdata);
+        winresdata = convertOS2Bitmap((BITMAPFILEHEADER2 *)resdata);
         break;
 
@@ -273,7 +274,12 @@
    dprintf(("Win32Resource::lockOS2Resource %d\n", id));
    if(os2resdata == NULL) {
-	rc = DosGetResource((HMODULE)module->hinstance, orgos2type, id, (PPVOID)&resdata);
-	if(rc)  return(NULL);
-	os2resdata = resdata;
+	if(resType == RSRC_PELOADER) {
+		os2resdata = convertResource(winresdata);
+	}
+	else {
+		rc = DosGetResource((HMODULE)module->hinstance, orgos2type, id, (PPVOID)&resdata);
+		if(rc)  return(NULL);
+		os2resdata = resdata;
+	}
    }
    return os2resdata;
@@ -281,5 +287,45 @@
 //******************************************************************************
 //******************************************************************************
-PVOID Win32Resource::ConvertBitmap(void *bmpdata)
+PVOID Win32Resource::convertResource(void *win32res)
+{
+ ULONG cvtressize;
+
+  switch(type) {
+    case NTRT_NEWBITMAP:
+    case NTRT_BITMAP:
+	return ConvertBitmap((WINBITMAPINFOHEADER *)win32res, ressize, &ressize);
+
+    case NTRT_CURSOR:
+    case NTRT_GROUP_CURSOR:
+    case NTRT_GROUP_ICON:
+    case NTRT_ICON:
+	return ConvertIcon((WINBITMAPINFOHEADER *)win32res, ressize);
+
+    case NTRT_ACCELERATORS:
+	return ConvertAccelerator((WINACCEL *)win32res, ressize);
+
+    case NTRT_NEWMENU:
+    case NTRT_MENU:
+	return ConvertMenu((MenuHeader *)win32res, ressize);
+
+    case NTRT_NEWDIALOG:
+    case NTRT_DIALOG:
+	break;
+    case NTRT_FONTDIR:
+    case NTRT_FONT:
+    case NTRT_MESSAGETABLE:
+    case NTRT_STRING:
+    case NTRT_RCDATA:
+    case NTRT_VERSION:
+    default:
+        break;
+  }
+  dprintf(("Win32Resource::convertResource: Can't convert resource %d (type %d)", id, type));
+  return 0;
+}
+//******************************************************************************
+//NOTE: Will be removed once pe2lx rewrite has been completed
+//******************************************************************************
+PVOID Win32Resource::convertOS2Bitmap(void *bmpdata)
 {
  BITMAPFILEHEADER2   *bmphdr = (BITMAPFILEHEADER2 *)bmpdata;
