public override uint Call32from16(Machine machine, bool hook, bool dlgproc, ref Win16.MSG msg16, ref Win32.MSG msg32, Func <IntPtr> callback) { msg32.wParam = IntPtr.Zero; msg32.lParam = IntPtr.Zero; callback(); return(0); }
public override void To32(Machine machine, ref Win16.MSG msg16, ref Win32.MSG msg32) { msg32.lParam = HMENU.Map.To32(msg16.lParam.Hiword()); if ((msg16.lParam & Win16.MF_POPUP) != 0) { // Get the menu handle IntPtr hPopup = HMENU.Map.To32(msg16.wParam); // Need to convert back to index int i; for (i = 0; i < User.GetMenuItemCount(msg32.lParam); i++) { if (User.GetSubMenu(msg32.lParam, i).value == hPopup) { break; } } msg32.wParam = (IntPtr)(int)BitUtils.MakeDWord((ushort)i, msg16.lParam.Loword()); } else { msg32.wParam = (IntPtr)(int)BitUtils.MakeDWord(msg16.wParam, msg16.lParam.Loword()); } }
public override uint Call32from16(Machine machine, bool hook, bool dlgproc, ref Win16.MSG msg16, ref Win32.MSG msg32, Func <IntPtr> callback) { unsafe { msg32.wParam = IntPtr.Zero; msg32.lParam = IntPtr.Zero; return(HGDIOBJ.To16(callback())); } }
public override void To32(Machine machine, ref Win16.MSG msg16, ref Win32.MSG msg32) { if (msg16.lParam == 0) { msg32.wParam = (IntPtr)msg16.wParam; msg32.lParam = (IntPtr)(int)msg16.lParam; } else { throw new NotImplementedException("lParam must be zero"); } }
public override uint Call32from16(Machine machine, bool hook, bool dlgproc, ref Win16.MSG msg16, ref Win32.MSG msg32, Func <IntPtr> callback) { unsafe { var mmi32 = machine.ReadStruct <Win16.MINMAXINFO>(msg16.lParam).Convert(); msg32.wParam = IntPtr.Zero; msg32.lParam = new IntPtr(&mmi32); var ret = callback(); machine.WriteStruct(msg16.lParam, mmi32.Convert()); return((uint)ret); } }
public override void To16(Machine machine, ref Win32.MSG msg32, ref Win16.MSG msg16) { if (msg32.wParam.Loword() == Win16.WM_CREATE || msg32.wParam.Loword() == Win16.WM_DESTROY) { msg16.wParam = msg32.wParam.ToInt32().Loword(); msg16.lParam = BitUtils.MakeDWord(HWND.Map.To16(msg32.lParam), msg32.wParam.ToInt32().Hiword()); } else { msg16.wParam = (ushort)msg32.wParam.ToInt32(); msg16.lParam = (uint)msg32.lParam.ToInt32(); } }
public override uint Call32from16(Machine machine, bool hook, bool dlgproc, ref Win16.MSG msg16, ref Win32.MSG msg32, Func <IntPtr> callback) { unsafe { var str = machine.ReadString(msg16.lParam); fixed(char *psz = str) { msg32.wParam = (IntPtr)msg16.wParam; msg32.lParam = (IntPtr)psz; return((uint)(callback())); } } }
public override uint Call32from16(Machine machine, bool hook, bool dlgproc, ref Win16.MSG msg16, ref Win32.MSG msg32, Func <IntPtr> callback) { var di16 = machine.ReadStruct <Win16.DRAWITEMSTRUCT>(msg16.lParam); unsafe { Win16.DRAWITEMSTRUCT *ptr = &di16; msg32.wParam = (IntPtr)msg16.wParam; msg32.lParam = (IntPtr)ptr; var retv = callback(); return((uint)retv.ToInt32()); } }
public override uint Call32from16(Machine machine, bool hook, bool dlgproc, ref Win16.MSG msg16, ref Win32.MSG msg32, Func <IntPtr> callback) { var ptr = Marshal.AllocHGlobal(0xFFFF); Marshal.WriteInt16(ptr, 0, 0); msg32.wParam = (IntPtr)msg16.wParam; msg32.lParam = (IntPtr)ptr; var retv = callback(); machine.WriteString(msg16.lParam, Marshal.PtrToStringUni(ptr), 0xFFFF); Marshal.FreeHGlobal(ptr); return(retv.DWord()); }
public override void To16(Machine machine, ref Win32.MSG msg32, ref Win16.MSG msg16) { if (msg32.lParam == IntPtr.Zero) { msg16.wParam = (ushort)msg32.wParam.ToInt32(); msg16.lParam = 0; } else { return; throw new NotImplementedException("lParam must be zero"); } }
public override void To32(Machine machine, ref Win16.MSG msg16, ref Win32.MSG msg32) { if (msg16.wParam == Win16.WM_CREATE || msg16.wParam == Win16.WM_DESTROY) { // MessageSemantics.command msg32.wParam = (IntPtr)BitUtils.MakeDWord(msg16.wParam, msg16.lParam.Hiword()); msg32.lParam = HWND.Map.To32(msg16.lParam.Loword()); } else { // MessageSemantics.copy msg32.wParam = (IntPtr)msg16.wParam; msg32.lParam = (IntPtr)msg16.lParam; } }
public override void To16(Machine machine, ref Win32.MSG msg32, ref Win16.MSG msg16) { uint uwParam = (uint)msg32.wParam.ToUInt32(); if ((uwParam.Hiword() & Win16.MF_POPUP) != 0) { IntPtr hSubMenu = User.GetSubMenu(msg32.lParam, (int)uwParam.Loword()).value; msg16.wParam = HMENU.Map.To16(hSubMenu); } else { msg16.wParam = uwParam.Loword(); } msg16.lParam = BitUtils.MakeDWord(uwParam.Hiword(), HMENU.Map.To16(msg32.lParam)); }
public override uint Call32from16(Machine machine, bool hook, bool dlgproc, ref Win16.MSG msg16, ref Win32.MSG msg32, Func <IntPtr> callback) { System.Diagnostics.Debug.Assert(msg16.message == WM_CTLCOLOR16); System.Diagnostics.Debug.Assert(msg16.lParam.Hiword() >= 0 && msg16.lParam.Hiword() <= 6); msg32.message = WM_CTLCOLORMSGBOX + msg16.lParam.Hiword(); msg32.wParam = HDC.To32(msg16.wParam).value; msg32.lParam = HWND.To32(msg16.lParam.Loword()).value; // Call 32-bit proc IntPtr hBrush = callback(); // Map it return(HGDIOBJ.To16(hBrush)); }
public override uint Call32from16(Machine machine, bool hook, bool dlgproc, ref Win16.MSG msg16, ref Win32.MSG msg32, Func <IntPtr> callback) { // Convert info var info16 = machine.ReadStruct <Win16.MDINEXTMENU>(msg16.lParam); var info32 = info16.Convert(); unsafe { // Setup message msg32.wParam = (IntPtr)msg16.wParam; msg32.lParam = (IntPtr)(&info32); // Do it return(callback().DWord()); } }
public override uint Call32from16(Machine machine, bool hook, bool dlgproc, ref Win16.MSG msg16, ref Win32.MSG msg32, Func <IntPtr> callback) { // UGH! WM_SETTEXT(hIcon) -> static SS_ICON control loword of lParam is a HICN if (!hook) { if (msg16.lParam.Hiword() == 0 && msg16.lParam.Loword() != 0) { if (WindowClassKind.Get(msg32.hWnd) == WndClassKind.Static && (User._GetWindowLong(msg32.hWnd, Win32.GWL_STYLE) & 0x0F) == 0x03) { HGDIOBJ hIcon = HGDIOBJ.To32(msg16.lParam.Loword()); User._SendMessage(msg32.hWnd, Win32.STM_SETICON, hIcon.value, IntPtr.Zero); return(0); } } } return(base.Call32from16(machine, hook, dlgproc, ref msg16, ref msg32, callback)); }
public override uint Call32from16(Machine machine, bool hook, bool dlgproc, ref Win16.MSG msg16, ref Win32.MSG msg32, Func <IntPtr> callback) { unsafe { // Convert var mi16 = machine.ReadStruct <Win16.DELETEITEMSTRUCT>(msg16.lParam); var mi32 = mi16.Convert(); // Call msg32.wParam = (IntPtr)msg16.wParam; msg32.lParam = (IntPtr)(&mi32); var retv = callback(); // Convert back mi16 = mi32.Convert(); machine.WriteStruct(msg16.lParam, mi16); return((uint)retv.ToInt32()); } }
public override uint Call32from16(Machine machine, bool hook, bool dlgproc, ref Win16.MSG msg16, ref Win32.MSG msg32, Func <IntPtr> callback) { // Get info var info = GetInfo(machine, msg32.hWnd); // Make sure no funny business going on // (ie: the same CREATESTRUCT is passed out from 16-bit code as was passed in) System.Diagnostics.Debug.Assert(info.Struct32 != IntPtr.Zero); System.Diagnostics.Debug.Assert(info.Struct16 != 0); System.Diagnostics.Debug.Assert(info.Struct16 == msg16.lParam); // Convert Win16.CREATESTRUCT cs16 = machine.ReadStruct <Win16.CREATESTRUCT>(msg16.lParam); Win32.CREATESTRUCT cs32; info.Convert(ref cs16, out cs32); Marshal.StructureToPtr(cs32, info.Struct32, false); // Call msg32.wParam = IntPtr.Zero; msg32.lParam = info.Struct32; IntPtr retv = callback(); // Convert back cs32 = Marshal.PtrToStructure <Win32.CREATESTRUCT>(info.Struct32); info.Convert(ref cs32, out cs16); machine.WriteStruct(info.Struct16, ref cs16); // Return value depends on WM_CREATE/WM_NCCREATE if (_nc) { return(retv != IntPtr.Zero ? 1U : 0U); } else { return(retv.ToInt64() < 0 ? unchecked ((uint)-1) : 0U); } }
public override uint Call32from16(Machine machine, bool hook, bool dlgproc, ref Win16.MSG msg16, ref Win32.MSG msg32, Func <IntPtr> callback) { unsafe { var buf = new char[msg16.wParam]; fixed(char *psz = buf) { msg32.wParam = (IntPtr)msg16.wParam; msg32.lParam = (IntPtr)psz; var len = callback().ToInt32(); if (len >= 0) { var str = new String(psz, 0, len); return(machine.WriteString(msg16.lParam, str, msg16.wParam)); } else { return((uint)(len)); } } } }
public override void To32(Machine machine, ref Win16.MSG msg16, ref Win32.MSG msg32) { msg32.wParam = (IntPtr)msg16.wParam; msg32.lParam = (IntPtr)(int)msg16.lParam; }
public override IntPtr Call16from32(Machine machine, bool hook, bool dlgproc, ref Win32.MSG msg32, ref Win16.MSG msg16, Func <uint> callback) { var saveSP = machine.sp; try { // Convert var mi32 = Marshal.PtrToStructure <Win32.DELETEITEMSTRUCT>(msg32.lParam); var mi16 = mi32.Convert(); var ptr = machine.StackAlloc(mi16); msg16.wParam = 0; msg16.lParam = ptr; var retv = callback(); // Copy back mi32 = mi16.Convert(); Marshal.StructureToPtr(mi32, msg32.lParam, false); return((IntPtr)retv); } finally { machine.sp = saveSP; } }
public override void To16(Machine machine, ref Win32.MSG msg32, ref Win16.MSG msg16) { msg16.wParam = msg32.wParam.Loword(); msg16.lParam = BitUtils.MakeDWord(HWND.Map.To16(msg32.lParam), msg32.wParam.Hiword()); }
public override void To32(Machine machine, ref Win16.MSG msg16, ref Win32.MSG msg32) { msg32.wParam = (IntPtr)BitUtils.MakeDWord(msg16.wParam, msg16.lParam.Hiword()); msg32.lParam = HWND.Map.To32(msg16.lParam.Loword()); }
public override IntPtr Call16from32(Machine machine, bool hook, bool dlgproc, ref Win32.MSG msg32, ref Win16.MSG msg16, Func <uint> callback) { if (msg32.wParam != IntPtr.Zero) { // 16bit windows didn't support this if (!hook) { return(User.DefWindowProc(msg32.hWnd, msg32.message, msg32.wParam, msg32.lParam)); } return(IntPtr.Zero); } else { var rc = Marshal.PtrToStructure <Win32.RECT>(msg32.lParam); var ptr = machine.SysAlloc(rc.Convert()); msg16.wParam = 0; msg16.lParam = ptr; var ret = callback(); rc = machine.SysReadAndFree <Win16.RECT>(ptr).Convert(); Marshal.StructureToPtr(rc, msg32.lParam, true); return(IntPtr.Zero); } }
public override void To32(Machine machine, ref Win16.MSG msg16, ref Win32.MSG msg32) { throw new NotImplementedException($"Message type not implemented: {MessageNames.NameOfMessage(msg16.message)}"); }
public override void To16(Machine machine, ref Win32.MSG msg32, ref Win16.MSG msg16) { msg16.wParam = msg32.wParam.Loword(); msg16.lParam = msg32.lParam.ToUInt32(); }
public override void To16(Machine machine, ref Win32.MSG msg32, ref Win16.MSG msg16) { msg16.wParam = 0; msg16.lParam = 0; }
public override void To32(Machine machine, ref Win16.MSG msg16, ref Win32.MSG msg32) { msg32.wParam = IntPtr.Zero; msg32.lParam = IntPtr.Zero; }
public override void To16(Machine machine, ref Win32.MSG msg32, ref Win16.MSG msg16) { msg16.message = msg32.wParam.Hiword(); msg16.wParam = msg32.wParam.Loword(); msg16.lParam = msg32.lParam.DWord(); }
public override IntPtr Call16from32(Machine machine, bool hook, bool dlgproc, ref Win32.MSG msg32, ref Win16.MSG msg16, Func <uint> callback) { // Get the Win32 struct var mmi = Marshal.PtrToStructure <Win32.MINMAXINFO>(msg32.lParam); // Call 16 bit function var ptr = machine.SysAlloc(mmi.Convert()); msg16.wParam = 0; msg16.lParam = ptr; var ret = callback(); mmi = machine.SysReadAndFree <Win16.MINMAXINFO>(ptr).Convert(); // Return it to Win32 Marshal.StructureToPtr(mmi, msg32.lParam, true); return(IntPtr.Zero); }
public override void To32(Machine machine, ref Win16.MSG msg16, ref Win32.MSG msg32) { msg32.message = WM_PACKANDPOST; msg32.wParam = BitUtils.MakeIntPtr(msg16.wParam, msg16.message); msg32.lParam = (IntPtr)(int)msg16.lParam; }