2 * Copyright 1995 Martin von Loewis
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(lstrncmpi(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
)
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
);
88 /* FIXME: This should deal with built-in DLLs only. See pe_module on
94 if(!wine_files
|| !wine_files
->name
||
95 lstrcmpi(dll_name
, wine_files
->name
)) {
96 LoadModule(dll_name
, (LPVOID
) -1);
97 if(!wine_files
|| !wine_files
->name
||
98 lstrcmpi(dll_name
, wine_files
->name
))
101 load_addr
= wine_files
->load_addr
;
102 pe_exports
= wine_files
->pe
->pe_export
;
103 ordinal
= (u_short
*) (((char *) load_addr
) + (int) pe_exports
->Address_Of_Name_Ordinals
);
104 function
= (u_long
*) (((char *) load_addr
) + (int) pe_exports
->AddressOfFunctions
);
105 name
= (u_char
**) (((char *) load_addr
) + (int) pe_exports
->AddressOfNames
);
106 /* import by ordinal */
110 /* hint is correct */
112 if(hint
&& hint
<dll
->size
&&
113 dll
->functions
[hint
].name
&&
114 strcmp(item
,dll
->functions
[hint
].name
)==0)
115 return dll
->functions
[hint
].definition
;
117 /* hint is incorrect, search for name */
118 for(i
=0;i
<pe_exports
->Number_Of_Functions
;i
++)
119 if (name
[i
] && !strcmp(item
,name
[i
]+load_addr
))
120 return function
[i
]+(char *)load_addr
;
122 /* function at hint has no name (unimplemented) */
124 if(hint
&& hint
<dll
->size
&& !dll
->functions
[hint
].name
)
126 dll
->functions
[hint
].name
=xstrdup(item
);
127 dprintf_module(stddeb
, "Returning unimplemented function %s.%d\n",
129 return dll
->functions
[hint
].definition
;
132 printf("Not found\n");
136 /* import by ordinal */
138 if(hint
&& hint
<dll
->size
)return dll
->functions
[hint
].definition
;
141 /* hint is correct */
142 if(hint
&& hint
<dll
->size
&&
143 dll
->functions
[hint
].name
&&
144 strcmp(item
,dll
->functions
[hint
].name
)==0)
145 return dll
->functions
[hint
].definition
;
146 /* hint is incorrect, search for name */
147 for(i
=0;i
<dll
->size
;i
++)
148 if (dll
->functions
[i
].name
&& !strcmp(item
,dll
->functions
[i
].name
))
149 return dll
->functions
[i
].definition
;
151 /* function at hint has no name (unimplemented) */
152 if(hint
&& hint
<dll
->size
&& !dll
->functions
[hint
].name
)
154 dll
->functions
[hint
].name
=xstrdup(item
);
155 dprintf_module(stddeb
, "Returning unimplemented function %s.%d\n",
157 return dll
->functions
[hint
].definition
;
162 void RELAY32_DebugEnter(char *dll
,char *name
)
164 dprintf_relay(stddeb
, "Entering %s.%s\n",dll
,name
);
167 LONG
RELAY32_CallWindowProc( WNDPROC func
, int hwnd
, int message
,
168 int wParam
, int lParam
)
178 : "g" (lParam
), "g" (wParam
), "g" (message
), "g" (hwnd
), "g" (func
)