2 * Copyright 1995 Martin von Loewis
19 /* #define DEBUG_RELAY */
22 WIN32_builtin
*WIN32_builtin_list
;
24 /* Functions are in generated code */
31 void WINPROCS32_Init();
33 int RELAY32_Init(void)
36 /* Add a call for each DLL */
45 /* Why should it fail, anyways? */
49 WIN32_builtin
*RELAY32_GetBuiltinDLL(char *name
)
55 len
= (cp
=strchr(name
,'.')) ? (cp
-name
) : strlen(name
);
56 for(it
=WIN32_builtin_list
;it
;it
=it
->next
)
57 if(strncasecmp(name
,it
->name
,len
)==0)
62 void RELAY32_Unimplemented(char *dll
, int item
)
65 fprintf( stderr
, "No handler for routine %s.%d", dll
, item
);
66 Dll
=RELAY32_GetBuiltinDLL(dll
);
67 if(Dll
&& Dll
->functions
[item
].name
)
68 fprintf(stderr
, "(%s?)\n", Dll
->functions
[item
].name
);
70 fprintf(stderr
, "\n");
75 void *RELAY32_GetEntryPoint(char *dll_name
, char *item
, int hint
)
81 u_char
** name
, *ename
;
82 struct PE_Export_Directory
* pe_exports
;
83 unsigned int load_addr
;
85 dprintf_module(stddeb
, "Looking for %s in %s, hint %x\n",
86 item
? item
: "(no name)", dll_name
, hint
);
87 dll
=RELAY32_GetBuiltinDLL(dll_name
);
89 if(!wine_files
|| !wine_files
->name
||
90 strcasecmp(dll_name
, wine_files
->name
)) {
91 LoadModule(dll_name
, (LPVOID
) -1);
92 if(!wine_files
|| !wine_files
->name
||
93 strcasecmp(dll_name
, wine_files
->name
))
96 load_addr
= wine_files
->load_addr
;
97 pe_exports
= wine_files
->pe
->pe_export
;
98 ordinal
= (u_short
*) (((char *) load_addr
) + (int) pe_exports
->Address_Of_Name_Ordinals
);
99 function
= (u_long
*) (((char *) load_addr
) + (int) pe_exports
->AddressOfFunctions
);
100 name
= (u_char
**) (((char *) load_addr
) + (int) pe_exports
->AddressOfNames
);
101 /* import by ordinal */
105 /* hint is correct */
107 if(hint
&& hint
<dll
->size
&&
108 dll
->functions
[hint
].name
&&
109 strcmp(item
,dll
->functions
[hint
].name
)==0)
110 return dll
->functions
[hint
].definition
;
112 /* hint is incorrect, search for name */
113 for(i
=0;i
<pe_exports
->Number_Of_Functions
;i
++)
114 if (name
[i
] && !strcmp(item
,name
[i
]+load_addr
))
115 return function
[i
]+(char *)load_addr
;
117 /* function at hint has no name (unimplemented) */
119 if(hint
&& hint
<dll
->size
&& !dll
->functions
[hint
].name
)
121 dll
->functions
[hint
].name
=strdup(item
);
122 dprintf_module(stddeb
, "Returning unimplemented function %s.%d\n",
124 return dll
->functions
[hint
].definition
;
127 printf("Not found\n");
130 /* import by ordinal */
132 if(hint
&& hint
<dll
->size
)return dll
->functions
[hint
].definition
;
135 /* hint is correct */
136 if(hint
&& hint
<dll
->size
&&
137 dll
->functions
[hint
].name
&&
138 strcmp(item
,dll
->functions
[hint
].name
)==0)
139 return dll
->functions
[hint
].definition
;
140 /* hint is incorrect, search for name */
141 for(i
=0;i
<dll
->size
;i
++)
142 if (dll
->functions
[i
].name
&& !strcmp(item
,dll
->functions
[i
].name
))
143 return dll
->functions
[i
].definition
;
145 /* function at hint has no name (unimplemented) */
146 if(hint
&& hint
<dll
->size
&& !dll
->functions
[hint
].name
)
148 dll
->functions
[hint
].name
=strdup(item
);
149 dprintf_module(stddeb
, "Returning unimplemented function %s.%d\n",
151 return dll
->functions
[hint
].definition
;
153 printf("Not found\n");
157 void RELAY32_DebugEnter(char *dll
,char *name
)
159 dprintf_relay(stddeb
, "Entering %s.%s\n",dll
,name
);
162 LONG
RELAY32_CallWindowProc( WNDPROC func
, int hwnd
, int message
,
163 int wParam
, int lParam
)
173 : "g" (lParam
), "g" (wParam
), "g" (message
), "g" (hwnd
), "g" (func
)