Release 980413
[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 "process.h"
15 #include "module.h"
16 #include "task.h"
17 #include "callback.h"
18 #include "debug.h"
19
20 static CRITICAL_SECTION Win16Mutex;
21 static SEGPTR segWin16Mutex = NULL;
22
23 /***********************************************
24  *           GetPWinLock    (KERNEL32.93)
25  * Return the infamous Win16Mutex.
26  */
27 VOID WINAPI GetPWinLock(CRITICAL_SECTION **lock)
28 {
29         fprintf(stderr,"GetPWinlock(%p)\n",lock);
30         *lock = &Win16Mutex;
31 }
32
33 /**********************************************************************
34  *           WOW32_1        (KERNEL32.88)
35  */
36 BOOL32 WINAPI WOW32_1(SEGPTR segptr,LPLDT_ENTRY ldtent)
37 {
38     return GetThreadSelectorEntry(GetCurrentThreadId(),segptr>>16,ldtent);
39 }
40
41
42 /***********************************************************************
43  *           GetProcessDWORD    (KERNEL32.18)
44  * 'Of course you cannot directly access Windows internal structures'
45  */
46
47 DWORD WINAPI GetProcessDWORD(DWORD processid,DWORD action)
48 {
49         PDB32   *process;
50         TDB     *pTask;
51
52         action+=56;
53         fprintf(stderr,"KERNEL32_18(%ld,%ld+0x38)\n",processid,action);
54         if (action>56)
55                 return 0;
56         if (!(process = PROCESS_IdToPDB( processid ))) return 0;
57         switch (action) {
58         case 0: /* return app compat flags */
59                 pTask = (TDB*)GlobalLock16(process->task);
60                 if (!pTask)
61                         return 0;
62                 return pTask->compat_flags;
63         case 4: /* returns offset 0xb8 of process struct... dunno what it is */
64                 return 0;
65         case 8: /* return hinstance16 */
66                 pTask = (TDB*)GlobalLock16(process->task);
67                 if (!pTask)
68                         return 0;
69                 return pTask->hInstance;
70         case 12:/* return expected windows version */
71                 pTask = (TDB*)GlobalLock16(process->task);
72                 if (!pTask)
73                         return 0;
74                 return pTask->version;
75         case 16:/* return uncrypted pointer to current thread */
76                 return (DWORD)THREAD_Current();
77         case 20:/* return uncrypted pointer to process */
78                 return (DWORD)process;
79         case 24:/* return stdoutput handle from startupinfo */
80                 return (DWORD)(process->env_db->startup_info->hStdOutput);
81         case 28:/* return stdinput handle from startupinfo */
82                 return (DWORD)(process->env_db->startup_info->hStdInput);
83         case 32:/* get showwindow flag from startupinfo */
84                 return (DWORD)(process->env_db->startup_info->wShowWindow);
85         case 36:{/* return startup x and y sizes */
86                 LPSTARTUPINFO32A si = process->env_db->startup_info;
87                 DWORD x,y;
88
89                 x=si->dwXSize;if (x==0x80000000) x=0x8000;
90                 y=si->dwYSize;if (y==0x80000000) y=0x8000;
91                 return (y<<16)+x;
92         }
93         case 40:{/* return startup x and y */
94                 LPSTARTUPINFO32A si = process->env_db->startup_info;
95                 DWORD x,y;
96
97                 x=si->dwX;if (x==0x80000000) x=0x8000;
98                 y=si->dwY;if (y==0x80000000) y=0x8000;
99                 return (y<<16)+x;
100         }
101         case 44:/* return startup flags */
102                 return process->env_db->startup_info->dwFlags;
103         case 48:/* return uncrypted pointer to parent process (if any) */
104                 return (DWORD)process->parent;
105         case 52:/* return process flags */
106                 return process->flags;
107         case 56:/* unexplored */
108                 return 0;
109         default:
110                 fprintf(stderr,"_KERNEL32_18:unknown offset (%ld)\n",action);
111                 return 0;
112         }
113         /* shouldn't come here */
114 }
115
116
117 /***********************************************************************
118  *              GetWin16DOSEnv                  (KERNEL32.34)
119  * Returns some internal value.... probably the default environment database?
120  */
121 DWORD WINAPI GetWin16DOSEnv()
122 {
123         fprintf(stderr,"GetWin16DOSEnv(), STUB returning 0\n");
124         return 0;
125 }
126
127 BOOL32 WINAPI _KERNEL32_100(HANDLE32 threadid,DWORD exitcode,DWORD x) {
128         fprintf(stderr,"KERNEL32_100(%d,%ld,0x%08lx),stub\n",threadid,exitcode,x);
129         return TRUE;
130 }
131
132 DWORD WINAPI _KERNEL32_99(DWORD x) {
133         fprintf(stderr,"KERNEL32_99(0x%08lx),stub\n",x);
134         return 1;
135 }
136
137 /************************************************************************
138  *              KERNEL_449              (KERNEL.449)
139  * This returns a segmented static pointer to a linear pointer to a critical
140  * section in kernel32 address space. This is most likely the Win16 Lock,
141  * but I am not sure.
142  */
143 SEGPTR WINAPI KERNEL_449(void) { 
144         if (!segWin16Mutex) {
145                 LPDWORD w16m = SEGPTR_ALLOC(4);
146                 
147                 *w16m = (DWORD)&Win16Mutex;
148                 segWin16Mutex = SEGPTR_GET(w16m);
149         }
150         return segWin16Mutex;
151 }