Beispiel #1
0
 public static Win16.BITMAP To16(Win32.BITMAP p32)
 {
     return(new Win16.BITMAP()
     {
         bmType = (short)p32.bmType,
         bmWidth = (short)p32.bmWidth,
         bmHeight = (short)p32.bmHeight,
         bmWidthBytes = (short)p32.bmWidthBytes,
         bmPlanes = (byte)p32.bmPlanes,
         bmBitsPixel = (byte)p32.bmBitsPixel,
         bmBits = 0,
     });
 }
Beispiel #2
0
        public short GetObject(HGDIOBJ hgdiobj, short cbBuffer, uint ptr)
        {
            unsafe
            {
                var objectType = GetObjectType(hgdiobj);
                switch (objectType)
                {
                case Win32.OBJ_PEN:
                {
                    if (ptr == 0)
                    {
                        return((short)Marshal.SizeOf <Win16.LOGPEN>());
                    }

                    // Check if buffer big enough
                    if (cbBuffer < Marshal.SizeOf <Win16.LOGPEN>())
                    {
                        return(0);
                    }

                    // Get it
                    var lp32  = new Win32.LOGPEN();
                    var plp32 = &lp32;
                    var size  = GetObject(hgdiobj, Marshal.SizeOf <Win32.LOGPEN>(), (IntPtr)plp32);

                    // Convert and write it back
                    _machine.WriteStruct(ptr, Win32.LOGPEN.To16(lp32));

                    return((short)Marshal.SizeOf <Win16.LOGPEN>());
                }

                case Win32.OBJ_BRUSH:
                {
                    if (ptr == 0)
                    {
                        return((short)Marshal.SizeOf <Win16.LOGBRUSH>());
                    }

                    if (cbBuffer < Marshal.SizeOf <Win16.LOGBRUSH>())
                    {
                        return(0);
                    }

                    var lb32  = new Win32.LOGBRUSH();
                    var plb32 = &lb32;
                    var size  = GetObject(hgdiobj, Marshal.SizeOf <Win32.LOGBRUSH>(), (IntPtr)plb32);

                    _machine.WriteStruct(ptr, Win32.LOGBRUSH.To16(lb32));
                    return((short)Marshal.SizeOf <Win16.LOGBRUSH>());
                }

                case Win32.OBJ_BITMAP:
                {
                    // Just asking for size?
                    if (ptr == 0)
                    {
                        return((short)Marshal.SizeOf <Win16.BITMAP>());
                    }

                    // Check if buffer big enough
                    if (cbBuffer < Marshal.SizeOf <Win16.BITMAP>())
                    {
                        return(0);
                    }

                    // Get it
                    var bmp32  = new Win32.BITMAP();
                    var pbmp32 = &bmp32;
                    var size   = GetObject(hgdiobj, Marshal.SizeOf <Win32.BITMAP>(), (IntPtr)pbmp32);

                    // Convert and write it back
                    _machine.WriteStruct(ptr, Win32.BITMAP.To16(bmp32));

                    // Return size
                    return((short)Marshal.SizeOf <Win16.BITMAP>());
                }

                case Win32.OBJ_FONT:
                {
                    // Just asking for size?
                    if (ptr == 0)
                    {
                        return((short)Marshal.SizeOf <Win16.LOGFONT>());
                    }

                    // Check if buffer big enough
                    if (cbBuffer < Marshal.SizeOf <Win16.LOGFONT>())
                    {
                        return(0);
                    }

                    // Get it
                    var lf32 = new Win32.LOGFONT();
                    var size = GetObject(hgdiobj, Marshal.SizeOf <Win32.LOGFONT>(), out lf32);

                    // Convert and write it back
                    _machine.WriteStruct(ptr, Win32.LOGFONT.To16(lf32));

                    // Return size
                    return((short)Marshal.SizeOf <Win16.LOGFONT>());
                }

                default:
                    throw new NotImplementedException("Unsupported object type passed to GetObject");
                }
            }
        }