Created
October 19, 2016 03:08
-
-
Save toptensoftware/0be3db0021661daec318d1d685315d89 to your computer and use it in GitHub Desktop.
MessageBox using reflection for parameters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // The real API method imported from Windows | |
| [DllImport(“user32.dll”)] | |
| static extern uint MessageBox(IntPtr hWndParent, string msg, string title, uint options); | |
| // Implementation method exported to 16-bit code | |
| [EntryPoint(0x0001)] | |
| public ushort MessageBox(ushort hWndParent, string msg, string title, ushort options) | |
| { | |
| // No more messing around with the VM stack for parameters | |
| // nor with the ax register for the return value. Nice! | |
| return (ushort)MessageBox(IntPtr.Zero, msg, title, (uint)options); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment