Release 980628
[wine/gsoc-2012-control.git] / win32 / ordinals.c
bloba1077a6c2697a5d3f5992faee8f7792b38ba1cb9
1 /*
2 * Win32 ordinal only exported functions that can't be stuffed somehwere else.
4 * Copyright 1997 Marcus Meissner
5 */
7 #include "thread.h"
8 #include "winerror.h"
9 #include "heap.h"
10 #include "selectors.h"
11 #include "miscemu.h"
12 #include "winnt.h"
13 #include "process.h"
14 #include "module.h"
15 #include "task.h"
16 #include "callback.h"
17 #include "debug.h"
19 static CRITICAL_SECTION Win16Mutex;
20 static SEGPTR segWin16Mutex = (SEGPTR)NULL;
23 /***********************************************
24 * GetpWin16Lock (KERNEL32.93)
25 * Return the infamous Win16Mutex.
27 VOID WINAPI GetpWin16Lock(CRITICAL_SECTION **lock)
29 FIXME(win32, "(%p)\n",lock);
30 *lock = &Win16Mutex;
33 /***********************************************
34 * _ConfirmWin16Lock (KERNEL32.96)
36 DWORD WINAPI _ConfirmWin16Lock(void)
38 FIXME(win32, "()\n");
39 return 1;
42 /***********************************************
43 * _EnterSysLevel (KERNEL32.97)
45 VOID WINAPI _EnterSysLevel(CRITICAL_SECTION *lock)
47 FIXME(win32, "(%p)\n", lock);
50 /***********************************************
51 * _EnterSysLevel (KERNEL32.98)
53 VOID WINAPI _LeaveSysLevel(CRITICAL_SECTION *lock)
55 FIXME(win32, "(%p)\n", lock);
58 /***********************************************
59 * ReleaseThunkLock (KERNEL32.48)
61 VOID WINAPI ReleaseThunkLock(DWORD *mutex_count)
63 _LeaveSysLevel(&Win16Mutex);
65 *mutex_count = (DWORD) NtCurrentTeb()->mutex_count;
66 NtCurrentTeb()->mutex_count = 0xFFFF;
69 /***********************************************
70 * RestoreThunkLock (KERNEL32.49)
72 VOID WINAPI RestoreThunkLock(DWORD mutex_count)
74 NtCurrentTeb()->mutex_count = (WORD)mutex_count;
76 _EnterSysLevel(&Win16Mutex);
79 /***********************************************
80 * GetPK16SysVar (KERNEL32.92)
82 LPVOID WINAPI GetPK16SysVar(void)
84 static BYTE PK16SysVar[128];
86 FIXME(win32, "()\n");
87 return PK16SysVar;
91 /**********************************************************************
92 * WOWGetDescriptor (KERNEL32.88) (WOW32.1)
94 BOOL32 WINAPI WOWGetDescriptor(SEGPTR segptr,LPLDT_ENTRY ldtent)
96 return GetThreadSelectorEntry(GetCurrentThreadId(),segptr>>16,ldtent);
100 /***********************************************************************
101 * GetProcessDword (KERNEL32.18)
102 * 'Of course you cannot directly access Windows internal structures'
104 DWORD WINAPI GetProcessDword(DWORD processid,DWORD action)
106 PDB32 *process = processid? PROCESS_IdToPDB( processid )
107 : PROCESS_Current();
108 TDB *pTask;
110 action+=56;
111 TRACE(win32,"(%ld,%ld+0x38)\n",processid,action);
112 if (!process || action>56)
113 return 0;
114 switch (action) {
115 case 0: /* return app compat flags */
116 pTask = (TDB*)GlobalLock16(process->task);
117 if (!pTask)
118 return 0;
119 return pTask->compat_flags;
120 case 4: /* returns offset 0xb8 of process struct... dunno what it is */
121 return 0;
122 case 8: /* return hinstance16 */
123 pTask = (TDB*)GlobalLock16(process->task);
124 if (!pTask)
125 return 0;
126 return pTask->hInstance;
127 case 12:/* return expected windows version */
128 pTask = (TDB*)GlobalLock16(process->task);
129 if (!pTask)
130 return 0;
131 return pTask->version;
132 case 16:/* return uncrypted pointer to current thread */
133 return (DWORD)THREAD_Current();
134 case 20:/* return uncrypted pointer to process */
135 return (DWORD)process;
136 case 24:/* return stdoutput handle from startupinfo */
137 return (DWORD)(process->env_db->startup_info->hStdOutput);
138 case 28:/* return stdinput handle from startupinfo */
139 return (DWORD)(process->env_db->startup_info->hStdInput);
140 case 32:/* get showwindow flag from startupinfo */
141 return (DWORD)(process->env_db->startup_info->wShowWindow);
142 case 36:{/* return startup x and y sizes */
143 LPSTARTUPINFO32A si = process->env_db->startup_info;
144 DWORD x,y;
146 x=si->dwXSize;if (x==0x80000000) x=0x8000;
147 y=si->dwYSize;if (y==0x80000000) y=0x8000;
148 return (y<<16)+x;
150 case 40:{/* return startup x and y */
151 LPSTARTUPINFO32A si = process->env_db->startup_info;
152 DWORD x,y;
154 x=si->dwX;if (x==0x80000000) x=0x8000;
155 y=si->dwY;if (y==0x80000000) y=0x8000;
156 return (y<<16)+x;
158 case 44:/* return startup flags */
159 return process->env_db->startup_info->dwFlags;
160 case 48:/* return uncrypted pointer to parent process (if any) */
161 return (DWORD)process->parent;
162 case 52:/* return process flags */
163 return process->flags;
164 case 56:/* unexplored */
165 return 0;
166 default:
167 WARN(win32,"Unknown offset (%ld)\n",action);
168 return 0;
170 /* shouldn't come here */
173 /***********************************************************************
174 * GetWin16DOSEnv (KERNEL32.34)
175 * Returns some internal value.... probably the default environment database?
177 DWORD WINAPI GetWin16DOSEnv()
179 FIXME(dosmem,"stub, returning 0\n");
180 return 0;
183 BOOL32 WINAPI _KERNEL32_100(HANDLE32 threadid,DWORD exitcode,DWORD x) {
184 FIXME(thread,"(%d,%ld,0x%08lx): stub\n",threadid,exitcode,x);
185 return TRUE;
188 DWORD WINAPI _KERNEL32_99(DWORD x) {
189 FIXME(win32,"(0x%08lx): stub\n",x);
190 return 1;
193 /************************************************************************
194 * KERNEL_449 (KERNEL.449)
195 * This returns a segmented static pointer to a linear pointer to a critical
196 * section in kernel32 address space. This is most likely the Win16 Lock,
197 * but I am not sure.
199 SEGPTR WINAPI KERNEL_449(void) {
200 if (!segWin16Mutex) {
201 LPDWORD w16m = SEGPTR_ALLOC(4);
203 *w16m = (DWORD)&Win16Mutex;
204 segWin16Mutex = SEGPTR_GET(w16m);
206 return segWin16Mutex;