Release 970928
[wine] / win32 / ordinals.c
1 /*
2  * Win32 ordinal only exported functions that can't be stuffed somehwere else.
3  *
4  * Copyright 1997 Marcus Meissner
5  */
6
7 #include <stdio.h>
8 #include "thread.h"
9 #include "winerror.h"
10 #include "heap.h"
11 #include "selectors.h"
12 #include "miscemu.h"
13 #include "winnt.h"
14 #include "module.h"
15 #include "callback.h"
16 #include "debug.h"
17 #include "stddebug.h"
18
19 extern THDB     *pCurrentThread;
20 extern PDB32    *pCurrentProcess;
21
22 static CRITICAL_SECTION Win16Mutex;
23
24 /***********************************************
25  *           GetPWinLock    (KERNEL32)
26  * Return the infamous Win16Mutex.
27  */
28 VOID WINAPI GetPWinLock(CRITICAL_SECTION **lock)
29 {
30         fprintf(stderr,"GetPWinlock(%p)\n",lock);
31         *lock = &Win16Mutex;
32 }
33
34 /**********************************************************************
35  *           _KERNEL32_88
36  */
37 BOOL32 WINAPI WOW32_1(SEGPTR segptr,LPLDT_ENTRY ldtent)
38 {
39     return GetThreadSelectorEntry(GetCurrentThreadId(),segptr>>16,ldtent);
40 }
41
42
43 /***********************************************************************
44  *           _KERNEL32_18    (KERNEL32.18)
45  * 'Of course you cannot directly access Windows internal structures'
46  */
47
48 DWORD WINAPI _KERNEL32_18(DWORD processid,DWORD action)
49 {
50         PDB32   *process;
51         TDB     *pTask;
52
53         action+=56;
54         fprintf(stderr,"KERNEL32_18(%ld,%ld+0x38)\n",processid,action);
55         if (action>56)
56                 return 0;
57         if (!processid) {
58                 process=pCurrentProcess;
59                 /* check if valid process */
60         } else
61                 process=(PDB32*)pCurrentProcess; /* decrypt too, if needed */
62         switch (action) {
63         case 0: /* return app compat flags */
64                 pTask = (TDB*)GlobalLock16(process->task);
65                 if (!pTask)
66                         return 0;
67                 return pTask->compat_flags;
68         case 4: /* returns offset 0xb8 of process struct... dunno what it is */
69                 return 0;
70         case 8: /* return hinstance16 */
71                 pTask = (TDB*)GlobalLock16(process->task);
72                 if (!pTask)
73                         return 0;
74                 return pTask->hInstance;
75         case 12:/* return expected windows version */
76                 pTask = (TDB*)GlobalLock16(process->task);
77                 if (!pTask)
78                         return 0;
79                 return pTask->version;
80         case 16:/* return uncrypted pointer to current thread */
81                 return (DWORD)pCurrentThread;
82         case 20:/* return uncrypted pointer to process */
83                 return (DWORD)process;
84         case 24:/* return stdoutput handle from startupinfo */
85                 return (DWORD)(process->env_db->startup_info->hStdOutput);
86         case 28:/* return stdinput handle from startupinfo */
87                 return (DWORD)(process->env_db->startup_info->hStdInput);
88         case 32:/* get showwindow flag from startupinfo */
89                 return (DWORD)(process->env_db->startup_info->wShowWindow);
90         case 36:{/* return startup x and y sizes */
91                 LPSTARTUPINFO32A si = process->env_db->startup_info;
92                 DWORD x,y;
93
94                 x=si->dwXSize;if (x==0x80000000) x=0x8000;
95                 y=si->dwYSize;if (y==0x80000000) y=0x8000;
96                 return (y<<16)+x;
97         }
98         case 40:{/* return startup x and y */
99                 LPSTARTUPINFO32A si = process->env_db->startup_info;
100                 DWORD x,y;
101
102                 x=si->dwX;if (x==0x80000000) x=0x8000;
103                 y=si->dwY;if (y==0x80000000) y=0x8000;
104                 return (y<<16)+x;
105         }
106         case 44:/* return startup flags */
107                 return process->env_db->startup_info->dwFlags;
108         case 48:/* return uncrypted pointer to parent process (if any) */
109                 return (DWORD)process->parent;
110         case 52:/* return process flags */
111                 return process->flags;
112         case 56:/* unexplored */
113                 return 0;
114         default:
115                 fprintf(stderr,"_KERNEL32_18:unknown offset (%ld)\n",action);
116                 return 0;
117         }
118         /* shouldn't come here */
119 }
120
121
122 /***********************************************************************
123  *                                                      (KERNEL32.33)
124  * Returns some internal value.... probably the default environment database?
125  */
126 DWORD WINAPI _KERNEL32_34()
127 {
128         fprintf(stderr,"KERNEL32_34(), STUB returning 0\n");
129         return 0;
130 }
131
132 BOOL32 WINAPI _KERNEL32_99(HANDLE32 threadid,DWORD exitcode,DWORD x) {
133         fprintf(stderr,"KERNEL32_99(%d,%ld,0x%08lx),stub\n",threadid,exitcode,x);
134         return TRUE;
135 }
136
137 DWORD WINAPI _KERNEL32_98(DWORD x) {
138         fprintf(stderr,"KERNEL32_98(0x%08lx),stub\n",x);
139         return 1;
140 }