Release 950522
[wine.git] / if1632 / relay32.c
blob960d73908a150e72bc19c50daa24f36422fd3668
1 /*
2 * Copyright 1995 Martin von Loewis
3 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <sys/types.h>
9 #include <sys/stat.h>
10 #include <fcntl.h>
11 #include <unistd.h>
12 #include <errno.h>
13 #include "windows.h"
14 #include "dlls.h"
15 #include "pe_image.h"
16 #include "stddebug.h"
17 /* #define DEBUG_RELAY */
18 #include "debug.h"
20 WIN32_builtin *WIN32_builtin_list;
22 int RELAY32_Init(void)
24 #ifndef WINELIB
25 /* Add a call for each DLL */
26 GDI32_Init();
27 KERNEL32_Init();
28 SHELL32_Init();
29 USER32_Init();
30 WINPROCS32_Init();
31 #endif
32 /* Why should it fail, anyways? */
33 return 1;
36 WIN32_builtin *RELAY32_GetBuiltinDLL(char *name)
38 WIN32_builtin *it;
39 for(it=WIN32_builtin_list;it;it=it->next)
40 if(strcmp(name,it->name)==0)
41 return it;
42 return NULL;
45 void RELAY32_Unimplemented(char *dll, int item)
47 WIN32_builtin *Dll;
48 fprintf( stderr, "No handler for routine %s.%d", dll, item);
49 Dll=RELAY32_GetBuiltinDLL(dll);
50 if(Dll && Dll->functions[item].name)
51 fprintf(stderr, "(%s?)\n", Dll->functions[item].name);
52 else
53 fprintf(stderr, "\n");
54 fflush(stderr);
55 exit(1);
58 void *RELAY32_GetEntryPoint(char *dll_name, char *item, int hint)
60 WIN32_builtin *dll;
61 int i;
62 dprintf_module(stddeb, "Looking for %s in %s, hint %x\n",
63 item ? item: "(no name)", dll_name, hint);
64 dll=RELAY32_GetBuiltinDLL(dll_name);
65 if(!dll)return 0;
66 /* import by ordinal */
67 if(!item){
68 if(hint && hint<dll->size)return dll->functions[hint].definition;
69 return 0;
71 /* hint is correct */
72 if(hint && hint<dll->size &&
73 dll->functions[hint].name &&
74 strcmp(item,dll->functions[hint].name)==0)
75 return dll->functions[hint].definition;
76 /* hint is incorrect, search for name */
77 for(i=1;i<dll->size;i++)
78 if(strcmp(item,dll->functions[i].name)==0)
79 return dll->functions[i].definition;
80 /* function at hint has no name (unimplemented) */
81 if(hint && hint<dll->size && !dll->functions[hint].name)
83 dll->functions[hint].name=strdup(item);
84 dprintf_module(stddeb, "Returning unimplemented function %s.%d\n",
85 dll_name,hint);
86 return dll->functions[hint].definition;
88 printf("Not found\n");
89 return 0;
92 void RELAY32_DebugEnter(char *dll,char *name)
94 dprintf_relay(stddeb, "Entering %s.%s\n",dll,name);
97 LONG RELAY32_CallWindowProc( WNDPROC func, int hwnd, int message,
98 int wParam, int lParam )
100 int ret;
101 SpyMessage(hwnd, message, wParam, lParam);
102 __asm__ (
103 "push %1;"
104 "push %2;"
105 "push %3;"
106 "push %4;"
107 "call %5;"
108 : "=a" (ret)
109 : "g" (lParam), "g" (wParam), "g" (message), "g" (hwnd), "g" (func)
111 return ret;