#ifndef TDKPIN_WIN16_H #define TDKPIN_WIN16_H #include /* * Source-level Win16 model used by the readable reconstruction. * Handles and scalar API arguments are 16-bit. A segmented far pointer is * stored as offset:selector in one 32-bit value, matching the NE image and * Borland stack representation rather than a host pointer. */ typedef uint16_t Win16Handle; typedef uint16_t HBRUSH16; typedef uint16_t HBITMAP16; typedef uint16_t HDC16; typedef uint16_t HGDIOBJ16; typedef uint16_t HGLOBAL16; typedef uint16_t HCURSOR16; typedef uint16_t HICON16; typedef uint16_t HINSTANCE16; typedef uint16_t HPALETTE16; typedef uint16_t HRSRC16; typedef uint16_t HACCEL16; typedef uint16_t HMENU16; typedef uint16_t HWND16; typedef uint16_t WPARAM16; typedef uint16_t UINT16; typedef int16_t BOOL16; typedef int16_t INT16; typedef int16_t HFILE16; typedef int32_t LPARAM16; typedef int32_t LRESULT16; typedef uint32_t Win16FarPtr; typedef uint32_t COLORREF16; #pragma pack(push, 1) typedef struct { INT16 left; INT16 top; INT16 right; INT16 bottom; } RECT16; typedef struct { HDC16 dc; BOOL16 erase; RECT16 paint; BOOL16 restore; BOOL16 incremental_update; uint8_t reserved[16]; } PAINTSTRUCT16; typedef struct { INT16 x; INT16 y; } POINT16; typedef struct { HWND16 window; UINT16 message; WPARAM16 wparam; LPARAM16 lparam; uint32_t time; POINT16 point; } MSG16; typedef struct { POINT16 reserved; POINT16 maximum_size; POINT16 maximum_position; POINT16 minimum_track_size; POINT16 maximum_track_size; } MINMAXINFO16; typedef struct { Win16FarPtr class_name; Win16FarPtr title; HINSTANCE16 owner; INT16 x; INT16 y; INT16 width; INT16 height; uint32_t style; LPARAM16 parameter; } MDICREATESTRUCT16; typedef struct { INT16 height; INT16 ascent; INT16 descent; INT16 internal_leading; INT16 external_leading; INT16 average_character_width; INT16 maximum_character_width; INT16 weight; uint8_t italic; uint8_t underlined; uint8_t struck_out; uint8_t first_character; uint8_t last_character; uint8_t default_character; uint8_t break_character; uint8_t pitch_and_family; uint8_t character_set; INT16 overhang; INT16 digitized_aspect_x; INT16 digitized_aspect_y; } TEXTMETRIC16; /* Windows 3.1 packed layout passed by TDKPIN to waveOutGetDevCaps. */ typedef struct { UINT16 manufacturer_id; UINT16 product_id; UINT16 driver_version; char product_name[32]; uint32_t formats; UINT16 channels; uint32_t support; } WAVEOUTCAPS16; #pragma pack(pop) _Static_assert(sizeof(RECT16) == 8, "Win16 RECT layout drift"); _Static_assert(sizeof(PAINTSTRUCT16) == 32, "Win16 PAINTSTRUCT layout drift"); _Static_assert(sizeof(POINT16) == 4, "Win16 POINT layout drift"); _Static_assert(sizeof(MSG16) == 18, "Win16 MSG layout drift"); _Static_assert(sizeof(MINMAXINFO16) == 20, "Win16 MINMAXINFO layout drift"); _Static_assert(sizeof(MDICREATESTRUCT16) == 26, "Win16 MDICREATESTRUCT layout drift"); _Static_assert(sizeof(TEXTMETRIC16) == 31, "Win16 TEXTMETRIC layout drift"); _Static_assert(sizeof(WAVEOUTCAPS16) == 48, "Win16 WAVEOUTCAPS layout drift"); static inline uint16_t win16_far_offset(Win16FarPtr pointer) { return (uint16_t)pointer; } static inline uint16_t win16_far_selector(Win16FarPtr pointer) { return (uint16_t)(pointer >> 16); } static inline Win16FarPtr win16_make_far_pointer(uint16_t selector, uint16_t offset) { return ((uint32_t)selector << 16) | offset; } static inline Win16FarPtr win16_far_add_offset(Win16FarPtr pointer, uint16_t delta) { return win16_make_far_pointer( win16_far_selector(pointer), (uint16_t)(win16_far_offset(pointer) + delta)); } #pragma pack(push, 1) typedef struct { UINT16 style; Win16FarPtr window_proc; INT16 class_extra_bytes; INT16 window_extra_bytes; HINSTANCE16 instance; HICON16 icon; HCURSOR16 cursor; HBRUSH16 background_brush; Win16FarPtr menu_name; Win16FarPtr class_name; } WNDCLASS16; #pragma pack(pop) _Static_assert(sizeof(WNDCLASS16) == 26, "Win16 WNDCLASS layout drift"); enum Win16WindowMessage { WIN16_WM_CREATE = 0x0001, WIN16_WM_DESTROY = 0x0002, WIN16_WM_SIZE = 0x0005, WIN16_WM_SETFOCUS = 0x0007, WIN16_WM_KILLFOCUS = 0x0008, WIN16_WM_PAINT = 0x000f, WIN16_WM_GETMINMAXINFO = 0x0024, WIN16_WM_KEYDOWN = 0x0100, WIN16_WM_CHAR = 0x0102, WIN16_WM_HSCROLL = 0x0114, WIN16_WM_VSCROLL = 0x0115, }; /* USER ordinal 107, Wine 11.15 user.exe16.spec. */ LRESULT16 DefWindowProc16(HWND16 window, UINT16 message, WPARAM16 wparam, LPARAM16 lparam); INT16 MessageBox16( HWND16 owner, Win16FarPtr text, Win16FarPtr caption, UINT16 type); void PostQuitMessage16(INT16 exit_code); BOOL16 CreateCaret16(HWND16 window, HBITMAP16 bitmap, INT16 width, INT16 height); BOOL16 DestroyCaret16(void); BOOL16 SetCaretPos16(INT16 x, INT16 y); BOOL16 ShowCaret16(HWND16 window); INT16 SetScrollPos16(HWND16 window, INT16 bar, INT16 position, BOOL16 redraw); BOOL16 SetScrollRange16( HWND16 window, INT16 bar, INT16 minimum, INT16 maximum, BOOL16 redraw); BOOL16 ScrollWindow16( HWND16 window, INT16 delta_x, INT16 delta_y, Win16FarPtr scroll_rect, Win16FarPtr clip_rect); BOOL16 UpdateWindow16(HWND16 window); BOOL16 GetClientRect16(HWND16 window, Win16FarPtr rectangle); BOOL16 InvalidateRect16( HWND16 window, Win16FarPtr rectangle, BOOL16 erase); INT16 GetKeyState16(INT16 virtual_key); HMENU16 GetSystemMenu16(HWND16 window, BOOL16 revert); BOOL16 EnableMenuItem16(HMENU16 menu, UINT16 item, UINT16 flags); HDC16 GetDC16(HWND16 window); INT16 ReleaseDC16(HWND16 window, HDC16 dc); HDC16 BeginPaint16(HWND16 window, Win16FarPtr paint); BOOL16 EndPaint16(HWND16 window, Win16FarPtr paint); HGDIOBJ16 GetStockObject16(INT16 object); HPALETTE16 CreatePalette16(Win16FarPtr logical_palette); HPALETTE16 SelectPalette16( HDC16 dc, HPALETTE16 palette, BOOL16 force_background); UINT16 RealizePalette16(HDC16 dc); BOOL16 UpdateColors16(HDC16 dc); BOOL16 UnrealizeObject16(HGDIOBJ16 object); BOOL16 DeleteObject16(HGDIOBJ16 object); BOOL16 DeleteDC16(HDC16 dc); HDC16 CreateDC16( Win16FarPtr driver, Win16FarPtr device, Win16FarPtr output, Win16FarPtr initialization_data); HBITMAP16 CreateDIBitmap16( HDC16 dc, Win16FarPtr header, uint32_t initialization, Win16FarPtr bits, Win16FarPtr bitmap_info, UINT16 color_usage); HGDIOBJ16 SelectObject16(HDC16 dc, HGDIOBJ16 object); HDC16 CreateCompatibleDC16(HDC16 dc); HBITMAP16 CreateCompatibleBitmap16( HDC16 dc, INT16 width, INT16 height); BOOL16 BitBlt16( HDC16 destination, INT16 destination_x, INT16 destination_y, INT16 width, INT16 height, HDC16 source, INT16 source_x, INT16 source_y, uint32_t raster_operation); COLORREF16 GetSysColor16(INT16 index); COLORREF16 SetTextColor16(HDC16 dc, COLORREF16 color); COLORREF16 GetTextColor16(HDC16 dc); UINT16 SetTextAlign16(HDC16 dc, UINT16 alignment); INT16 SetBkMode16(HDC16 dc, INT16 mode); COLORREF16 SetBkColor16(HDC16 dc, COLORREF16 color); BOOL16 TextOut16( HDC16 dc, INT16 x, INT16 y, Win16FarPtr text, INT16 character_count); BOOL16 GetTextMetrics16(HDC16 dc, Win16FarPtr metrics); INT16 GetSystemMetrics16(INT16 index); uint32_t GetTickCount16(void); HFILE16 LCreate16(Win16FarPtr file_name, INT16 attributes); HFILE16 LOpen16(Win16FarPtr file_name, INT16 mode); UINT16 LRead16(HFILE16 file, Win16FarPtr bytes, UINT16 byte_count); UINT16 LWrite16(HFILE16 file, Win16FarPtr bytes, UINT16 byte_count); HFILE16 LClose16(HFILE16 file); HGLOBAL16 GlobalAlloc16(UINT16 flags, uint32_t bytes); Win16FarPtr GlobalLock16(HGLOBAL16 allocation); HGLOBAL16 GlobalHandle16(uint16_t selector); BOOL16 GlobalUnlock16(HGLOBAL16 allocation); HGLOBAL16 GlobalFree16(HGLOBAL16 allocation); HRSRC16 FindResource16( HINSTANCE16 instance, Win16FarPtr name, Win16FarPtr type); HGLOBAL16 LoadResource16(HINSTANCE16 instance, HRSRC16 resource); Win16FarPtr LockResource16(HGLOBAL16 resource); BOOL16 FreeResource16(HGLOBAL16 resource); UINT16 GetPrivateProfileInt16( Win16FarPtr section, Win16FarPtr key, INT16 default_value, Win16FarPtr file_name); UINT16 WaveOutGetNumDevs16(void); UINT16 WaveOutGetDevCaps16( UINT16 device_id, Win16FarPtr capabilities, UINT16 byte_count); UINT16 WaveOutGetVolume16(UINT16 device_id, Win16FarPtr volume); uint16_t TimeKillEvent16(uint16_t timer_id); uint16_t SystemTimerMake16( HWND16 recipient, uint16_t delay_ms, uint16_t resolution_ms, uint16_t one_shot); uint16_t AllocCStoDSAlias16(uint16_t code_selector); uint16_t FreeSelector16(uint16_t selector); uint16_t PrestoChangoSelector16( uint16_t source_selector, uint16_t destination_selector); Win16FarPtr MakeProcInstance16( Win16FarPtr procedure, HINSTANCE16 instance); void FreeProcInstance16(Win16FarPtr procedure); BOOL16 PeekMessage16( MSG16 *message, HWND16 window, UINT16 minimum_message, UINT16 maximum_message, UINT16 remove_message); BOOL16 WaitMessage16(void); BOOL16 GetMessage16( MSG16 *message, HWND16 window, UINT16 minimum_message, UINT16 maximum_message); BOOL16 TranslateMessage16(const MSG16 *message); LRESULT16 DispatchMessage16(const MSG16 *message); BOOL16 IsDialogMessage16(HWND16 dialog, MSG16 *message); INT16 TranslateAccelerator16( HWND16 window, HACCEL16 accelerator, MSG16 *message); BOOL16 TranslateMDISysAccel16(HWND16 client, MSG16 *message); BOOL16 ShowWindow16(HWND16 window, INT16 command); int32_t GetWindowLong16(HWND16 window, INT16 index); HWND16 GetDlgItem16(HWND16 dialog, INT16 control_id); LRESULT16 SendMessage16( HWND16 window, UINT16 message, WPARAM16 wparam, LPARAM16 lparam); HWND16 GetFocus16(void); HWND16 GetParent16(HWND16 window); uint16_t GetWindowWord16(HWND16 window, INT16 index); BOOL16 DestroyWindow16(HWND16 window); BOOL16 IsChild16(HWND16 parent, HWND16 child); BOOL16 IsIconic16(HWND16 window); BOOL16 IsZoomed16(HWND16 window); BOOL16 IsWindow16(HWND16 window); HWND16 SetFocus16(HWND16 window); HWND16 SetCapture16(HWND16 window); BOOL16 ReleaseCapture16(void); BOOL16 GetWindowRect16(HWND16 window, Win16FarPtr rectangle); BOOL16 ScreenToClient16(HWND16 window, Win16FarPtr point); INT16 GetWindowText16(HWND16 window, char *text, INT16 maximum); BOOL16 SetWindowText16(HWND16 window, const char *text); BOOL16 SetWindowTextFar16(HWND16 window, Win16FarPtr text); BOOL16 SetDlgItemText16( HWND16 dialog, INT16 control_id, Win16FarPtr text); LRESULT16 SendDlgItemMessage16( HWND16 dialog, INT16 control_id, UINT16 message, WPARAM16 wparam, LPARAM16 lparam); HWND16 CreateWindow16( Win16FarPtr class_name, Win16FarPtr window_name, uint32_t style, INT16 x, INT16 y, INT16 width, INT16 height, HWND16 parent, HMENU16 menu, HINSTANCE16 instance, Win16FarPtr parameter); HWND16 CreateWindowEx16( uint32_t extended_style, Win16FarPtr class_name, Win16FarPtr window_name, uint32_t style, INT16 x, INT16 y, INT16 width, INT16 height, HWND16 parent, HMENU16 menu, HINSTANCE16 instance, Win16FarPtr parameter); int32_t SetWindowLong16(HWND16 window, INT16 index, int32_t value); Win16FarPtr win16_def_window_proc_pointer(void); Win16FarPtr win16_def_mdi_child_proc_pointer(void); LRESULT16 CallWindowProc16( Win16FarPtr procedure, HWND16 window, UINT16 message, WPARAM16 wparam, LPARAM16 lparam); BOOL16 GetClassInfo16( HINSTANCE16 instance, Win16FarPtr class_name, WNDCLASS16 *window_class); uint16_t RegisterClass16(const WNDCLASS16 *window_class); BOOL16 EndDialog16(HWND16 dialog, INT16 result); HICON16 LoadIcon16(HINSTANCE16 instance, Win16FarPtr resource); HCURSOR16 LoadCursor16(HINSTANCE16 instance, Win16FarPtr resource); HBITMAP16 LoadBitmap16(HINSTANCE16 instance, Win16FarPtr resource); HCURSOR16 SetCursor16(HCURSOR16 cursor); UINT16 GetDlgItemTextFar16( HWND16 dialog, INT16 control_id, Win16FarPtr buffer, INT16 maximum); INT16 AnsiToOem16(Win16FarPtr source, Win16FarPtr destination); INT16 OemToAnsi16(Win16FarPtr source, Win16FarPtr destination); BOOL16 MessageBeep16(UINT16 type); INT16 wvsprintf16( char *output, const char *format, const uint16_t *arguments); INT16 win16_call_message_box( Win16FarPtr procedure, HWND16 owner, const char *text, const char *caption, UINT16 type); INT16 win16_call_message_box_far( Win16FarPtr procedure, HWND16 owner, Win16FarPtr text, Win16FarPtr caption, UINT16 type); HWND16 win16_call_create_dialog_param( Win16FarPtr procedure, HINSTANCE16 instance, Win16FarPtr template_name, HWND16 parent, Win16FarPtr dialog_proc, LPARAM16 init_parameter); INT16 win16_call_dialog_box_param( Win16FarPtr procedure, HINSTANCE16 instance, Win16FarPtr template_name, HWND16 parent, Win16FarPtr dialog_proc, LPARAM16 init_parameter); UINT16 SetErrorMode16(UINT16 mode); HINSTANCE16 LoadLibrary16(const char *library_name); Win16FarPtr GetProcAddress16( HINSTANCE16 module, const char *procedure_name); UINT16 GetWindowsDirectory16(char *buffer, UINT16 size); UINT16 GetWindowsDirectoryFar16(Win16FarPtr buffer, UINT16 size); UINT16 GetSystemDirectory16(char *buffer, UINT16 size); UINT16 GetSystemDirectoryFar16(Win16FarPtr buffer, UINT16 size); HINSTANCE16 GetModuleHandle16(Win16FarPtr module_name); UINT16 GetModuleFileName16( HINSTANCE16 module, char *buffer, UINT16 size); UINT16 GetModuleFileNameFar16( HINSTANCE16 module, Win16FarPtr buffer, UINT16 size); uint32_t GetFreeSpace16(UINT16 flags); uint32_t GlobalCompact16(uint32_t requested_bytes); BOOL16 FreeLibrary16(HINSTANCE16 module); Win16Handle GetCurrentTask16(void); uint32_t GetVersion16(void); Win16FarPtr GetDOSEnvironment16(void); void WaitEvent16(uint16_t event); uint16_t InitApp16(HINSTANCE16 instance); uint32_t GetWinFlags16(void); #endif