示例#1
0
            public void Convert(ref Win16.CREATESTRUCT cs16, out Win32.CREATESTRUCT cs32)
            {
                if (cs16.lpCreateParams != 0 && !WindowClass.IsRegistered(_machine.ReadString(cs16.lpszClassName)))
                {
                    throw new NotImplementedException("CREATESTRUCT.lpCreateParams not supported");
                }

                // Convert it
                cs32.lpCreateParams = BitUtils.DWordToIntPtr(cs16.lpCreateParams);
                cs32.hInstance      = IntPtr.Zero;
                cs32.x             = (short)(cs16.cx == Win16.CW_USEDEFAULT ? Win16.CW_USEDEFAULT : cs16.x);
                cs32.y             = (short)(cs16.cx == Win16.CW_USEDEFAULT ? Win16.CW_USEDEFAULT : cs16.y);
                cs32.cx            = (short)(cs16.cx == Win16.CW_USEDEFAULT ? Win16.CW_USEDEFAULT : cs16.cx);
                cs32.cy            = (short)(cs16.cx == Win16.CW_USEDEFAULT ? Win16.CW_USEDEFAULT : cs16.cy);
                cs32.dwExStyle     = cs16.dwExStyle;
                cs32.style         = cs16.style;
                cs32.lpszClassName = GetString(cs16.lpszClassName);
                cs32.lpszName      = GetString(cs16.lpszName);

                if ((cs16.style & Win16.WS_CHILD) != 0)
                {
                    cs32.hMenu = (IntPtr)cs16.hMenu;
                }
                else
                {
                    cs32.hMenu = HMENU.Map.To32(cs16.hMenu);
                }

                cs32.hWndParent = HWND.Map.To32(cs16.hWndParent);
            }
示例#2
0
        public override IntPtr Call16from32(Machine machine, bool hook, bool dlgproc, ref Win32.MSG msg32, ref Win16.MSG msg16, Func <uint> callback)
        {
            if (!hook)
            {
                if (hInstanceDialog != 0)
                {
                    HWND.RegisterHWndToHInstance(msg32.hWnd, hInstanceDialog);
                }

                var hWndChild = User.GetWindow(msg32.hWnd, Win32.GW_CHILD);
                while (hWndChild.value != IntPtr.Zero)
                {
                    if (hInstanceDialog != 0)
                    {
                        HWND.RegisterHWndToHInstance(hWndChild.value, hInstanceDialog);
                    }

                    uint exStyle = User._GetWindowLong(hWndChild, Win32.GWL_EXSTYLE);
                    uint style   = User._GetWindowLong(hWndChild, Win32.GWL_STYLE);
                    if ((exStyle & Win32.WS_EX_CLIENTEDGE) != 0)
                    {
                        User._SetWindowLong(hWndChild.value, Win32.GWL_EXSTYLE, exStyle & ~Win32.WS_EX_CLIENTEDGE);
                        User._SetWindowLong(hWndChild.value, Win32.GWL_STYLE, User._GetWindowLong(hWndChild.value, Win32.GWL_STYLE) | Win32.WS_BORDER);
                        User.SetWindowPos(hWndChild.value, IntPtr.Zero, 0, 0, 0, 0, Win32.SWP_FRAMECHANGED | Win32.SWP_NOMOVE | Win32.SWP_NOSIZE | Win32.SWP_NOZORDER | Win32.SWP_NOOWNERZORDER);
                    }

                    // Is it a static
                    if (hInstanceDialog != 0)
                    {
                        if (User.GetClassName(hWndChild).ToLowerInvariant() == "static")
                        {
                            // It it an icon?
                            if ((style & 0x0F) == 0x03)
                            {
                                var iconName = User.GetWindowText(hWndChild);
                                if (!string.IsNullOrEmpty(iconName))
                                {
                                    var icon = machine.User.LoadIcon(hInstanceDialog, new StringOrId(iconName));
                                    if (icon.value != IntPtr.Zero)
                                    {
                                        User._SendMessage(hWndChild.value, Win32.STM_SETICON, icon.value, IntPtr.Zero);
                                    }
                                }
                            }
                        }
                    }


                    // Next
                    hWndChild = User.GetWindow(hWndChild, Win32.GW_HWNDNEXT);
                }

                hInstanceDialog = 0;
            }

            msg16.wParam = HWND.Map.To16(msg32.wParam);
            msg16.lParam = msg32.lParam.DWord();
            return(BitUtils.DWordToIntPtr(callback()));
        }
示例#3
0
        public void IntPtr_dword()
        {
            var x = (IntPtr)0x12345678U;

            Assert.AreEqual(x.DWord(), (uint)0x12345678);

            x = BitUtils.DWordToIntPtr(0x82348989U);
            Assert.AreEqual(x.DWord(), (uint)0x82348989);
        }
示例#4
0
            public override uint Call32from16(Machine machine, bool hook, bool dlgproc, ref Win16.MSG msg16, ref Win32.MSG msg32, Func <IntPtr> callback)
            {
                if (HasStrings(msg32.hWnd))
                {
                    return(base.Call32from16(machine, hook, dlgproc, ref msg16, ref msg32, callback));
                }

                msg32.wParam = BitUtils.DWordToIntPtr(msg16.wParam);
                msg32.lParam = BitUtils.DWordToIntPtr(msg16.lParam);
                return(callback().DWord());
            }
示例#5
0
            public override IntPtr Call16from32(Machine machine, bool hook, bool dlgproc, ref Win32.MSG msg32, ref Win16.MSG msg16, Func <uint> callback)
            {
                if (HasStrings(msg32.hWnd))
                {
                    return(base.Call16from32(machine, hook, dlgproc, ref msg32, ref msg16, callback));
                }

                msg16.wParam = msg32.wParam.Loword();
                msg16.lParam = msg32.lParam.Loword();
                return(BitUtils.DWordToIntPtr(callback()));
            }
示例#6
0
        public override IntPtr Call16from32(Machine machine, bool hook, bool dlgproc, ref Win32.MSG msg32, ref Win16.MSG msg16, Func <uint> callback)
        {
            // Convert info
            var info32 = Marshal.PtrToStructure <Win32.MDINEXTMENU>(msg32.lParam);
            var info16 = info32.Convert();

            // Setup message
            msg16.wParam = msg32.lParam.Loword();
            msg16.lParam = machine.SysAlloc(info16);

            try
            {
                // Do it
                return(BitUtils.DWordToIntPtr(callback()));
            }
            finally
            {
                // Clean up
                machine.SysFree(msg16.lParam);
            }
        }
示例#7
0
 public override uint Call32from16(Machine machine, bool hook, bool dlgproc, ref Win16.MSG msg16, ref Win32.MSG msg32, Func <IntPtr> callback)
 {
     msg32.wParam = HWND.Map.To32(msg16.wParam);
     msg32.lParam = BitUtils.DWordToIntPtr(msg16.lParam);
     return(callback().DWord());
 }