Release 950216
[wine] / toolkit / sup.c
1 #include <stdio.h>
2 #include "prototypes.h"
3 #include "windows.h"
4 #include "callback.h"
5 #include "wine.h"
6 #include "arch.h"
7
8 /* HANDLE hSysRes = 1; */
9
10 LONG CallWindowProc (WNDPROC func, HWND hwnd, WORD message,
11                      WORD wParam, LONG lParam)
12 {
13     (*func)(hwnd, message, wParam, lParam);
14 }
15
16 CallLineDDAProc (FARPROC back, int x, int y, long lParam)
17 {
18     (*back)(x, y, lParam);
19 }
20
21 DWORD CallHookProc (HOOKPROC func, short code, WPARAM wParam, LPARAM lParam)
22 {
23     (*func)(code, wParam, lParam);
24 }
25
26 BOOL CallGrayStringProc (FARPROC func, HDC hdc, LPARAM lParam, INT cch)
27 {
28     return (*func) (hdc, lParam, cch);
29 }
30
31 /*
32  * Header loading routines for WineLib.
33  */
34
35 /* LOADSHORT Calls LOAD and swaps the high and the low bytes */
36
37 #define LOAD(x)  read (fd, &TAB->x, sizeof (TAB->x))
38 #define LOADSHORT(x) LOAD(x); TAB->x = CONV_SHORT (TAB->x);
39 #define LOADLONG(x) LOAD(x);  TAB->x = CONV_LONG (TAB->x);
40
41 void load_mz_header (int fd, struct mz_header_s *mz_header)
42 {
43 #define TAB mz_header
44     LOAD (dont_care1);
45     LOAD (must_be_0x40);
46     LOAD (dont_care2);
47     LOADSHORT (ne_offset);
48 }
49
50 void load_ne_header (int fd, struct ne_header_s *ne_header)
51 {
52 #undef TAB
53 #define TAB ne_header
54     LOAD (header_type);
55     LOADSHORT (linker_version);
56     LOADSHORT (linker_revision);
57     LOADSHORT (entry_tab_offset);
58     LOADSHORT (entry_tab_length);
59     LOAD (reserved1);
60     LOADSHORT (format_flags);
61     LOADSHORT (auto_data_seg);
62     LOADSHORT (local_heap_length);
63     LOADSHORT (stack_length);
64     LOADSHORT (ip);
65     LOADSHORT (cs);
66     LOADSHORT (sp);
67     LOADSHORT (ss);
68     LOADSHORT (n_segment_tab);
69     LOADSHORT (n_mod_ref_tab);
70     LOADSHORT (nrname_tab_length);
71     LOADSHORT (segment_tab_offset);
72     LOADSHORT (resource_tab_offset);
73     LOADSHORT (rname_tab_offset);
74     LOADSHORT (moduleref_tab_offset);
75     LOADSHORT (iname_tab_offset);
76     LOADLONG (nrname_tab_offset);
77     LOADSHORT (n_mov_entry_points);
78     LOADSHORT (align_shift_count);
79     LOADSHORT (n_resource_seg);
80     LOAD (operating_system);
81     LOAD (additional_flags);
82     LOADSHORT (fastload_offset);
83     LOADSHORT (fastload_length);
84     LOADSHORT (reserved2);
85     LOADSHORT (expect_version);
86 }
87
88 /*
89  * Typeinfo loading routines for non PC-architectures.
90  */
91
92 int load_typeinfo (int fd, struct resource_typeinfo_s *typeinfo)
93 {
94 #undef TAB
95 #define TAB typeinfo
96     LOADSHORT (type_id);
97     LOADSHORT (count);
98     LOADLONG  (reserved);
99     return 1;
100 }
101
102 int load_nameinfo (int fd, struct resource_nameinfo_s *nameinfo)
103 {
104 #undef TAB
105 #define TAB nameinfo
106     LOADSHORT (offset);
107     LOADSHORT (length);
108     LOADSHORT (flags);
109     LOADSHORT (id);
110     LOADSHORT (handle);
111     LOADSHORT (usage);
112 }