LB_GETTEXT: Handle passed NULL buffer.
[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 "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 "stackframe.h"
18 #include "debug.h"
19
20 /**********************************************************************
21  *           WOWGetDescriptor        (KERNEL32.88) (WOW32.1)
22  */
23 BOOL32 WINAPI WOWGetDescriptor(SEGPTR segptr,LPLDT_ENTRY ldtent)
24 {
25     return GetThreadSelectorEntry(GetCurrentThreadId(),segptr>>16,ldtent);
26 }
27
28
29 /***********************************************************************
30  *           GetProcessDword    (KERNEL32.18) (KERNEL.485)
31  * 'Of course you cannot directly access Windows internal structures'
32  */
33 DWORD WINAPI GetProcessDword(DWORD processid,DWORD action)
34 {
35         PDB32   *process = processid? PROCESS_IdToPDB( processid )
36                                     : PROCESS_Current();
37         TDB     *pTask;
38
39         action+=56;
40         TRACE(win32,"(%ld,%ld+0x38)\n",processid,action);
41         if (!process || action>56)
42                 return 0;
43         switch (action) {
44         case 0: /* return app compat flags */
45                 pTask = (TDB*)GlobalLock16(process->task);
46                 if (!pTask)
47                         return 0;
48                 return pTask->compat_flags;
49         case 4: /* returns offset 0xb8 of process struct... dunno what it is */
50                 return 0;
51         case 8: /* return hinstance16 */
52                 pTask = (TDB*)GlobalLock16(process->task);
53                 if (!pTask)
54                         return 0;
55                 return pTask->hInstance;
56         case 12:/* return expected windows version */
57                 pTask = (TDB*)GlobalLock16(process->task);
58                 if (!pTask)
59                         return 0;
60                 return pTask->version;
61         case 16:/* return uncrypted pointer to current thread */
62                 return (DWORD)THREAD_Current();
63         case 20:/* return uncrypted pointer to process */
64                 return (DWORD)process;
65         case 24:/* return stdoutput handle from startupinfo */
66                 return (DWORD)(process->env_db->startup_info->hStdOutput);
67         case 28:/* return stdinput handle from startupinfo */
68                 return (DWORD)(process->env_db->startup_info->hStdInput);
69         case 32:/* get showwindow flag from startupinfo */
70                 return (DWORD)(process->env_db->startup_info->wShowWindow);
71         case 36:{/* return startup x and y sizes */
72                 LPSTARTUPINFO32A si = process->env_db->startup_info;
73                 DWORD x,y;
74
75                 x=si->dwXSize;if (x==0x80000000) x=0x8000;
76                 y=si->dwYSize;if (y==0x80000000) y=0x8000;
77                 return (y<<16)+x;
78         }
79         case 40:{/* return startup x and y */
80                 LPSTARTUPINFO32A si = process->env_db->startup_info;
81                 DWORD x,y;
82
83                 x=si->dwX;if (x==0x80000000) x=0x8000;
84                 y=si->dwY;if (y==0x80000000) y=0x8000;
85                 return (y<<16)+x;
86         }
87         case 44:/* return startup flags */
88                 return process->env_db->startup_info->dwFlags;
89         case 48:/* return uncrypted pointer to parent process (if any) */
90                 return (DWORD)process->parent;
91         case 52:/* return process flags */
92                 return process->flags;
93         case 56:/* unexplored */
94                 return process->process_dword;
95         default:
96                 WARN(win32,"Unknown offset (%ld)\n",action);
97                 return 0;
98         }
99         /* shouldn't come here */
100 }
101
102 /***********************************************************************
103  *           SetProcessDword    (KERNEL.484)
104  * 'Of course you cannot directly access Windows internal structures'
105  */
106 VOID WINAPI SetProcessDword(DWORD processid,DWORD action,DWORD value)
107 {
108         PDB32   *process = processid? PROCESS_IdToPDB( processid )
109                                     : PROCESS_Current();
110
111         action+=56;
112         TRACE(win32,"(%ld,%ld+0x38)\n",processid,action);
113         if (!process || action>56) return;
114
115         switch (action) {
116         case 56: process->process_dword = value; break;
117         default:
118                 FIXME(win32,"Unknown offset (%ld)\n",action);
119                 break;
120         }
121 }
122
123 /***********************************************************************
124  *              GetWin16DOSEnv                  (KERNEL32.34)
125  * Returns some internal value.... probably the default environment database?
126  */
127 DWORD WINAPI GetWin16DOSEnv()
128 {
129         FIXME(dosmem,"stub, returning 0\n");
130         return 0;
131 }
132
133 /**********************************************************************
134  *           GetPK16SysVar    (KERNEL32.92)
135  */
136 LPVOID WINAPI GetPK16SysVar(void)
137 {
138     static BYTE PK16SysVar[128];
139
140     FIXME(win32, "()\n");
141     return PK16SysVar;
142 }
143
144 /**********************************************************************
145  *           CommonUnimpStub    (KERNEL32.17)
146  */
147 REGS_ENTRYPOINT(CommonUnimpStub)
148 {
149     if (EAX_reg(context))
150         MSG( "*** Unimplemented Win32 API: %s\n", EAX_reg(context) );
151
152     switch ((ECX_reg(context) >> 4) & 0x0f)
153     {
154     case 15:  EAX_reg(context) = -1;   break;
155     case 14:  EAX_reg(context) = 0x78; break;
156     case 13:  EAX_reg(context) = 0x32; break;
157     case 1:   EAX_reg(context) = 1;    break;
158     default:  EAX_reg(context) = 0;    break;
159     }
160
161     ESP_reg(context) += (ECX_reg(context) & 0x0f) * 4;
162 }
163
164 /**********************************************************************
165  *           HouseCleanLogicallyDeadHandles    (KERNEL32.33)
166  */
167 void WINAPI HouseCleanLogicallyDeadHandles(void)
168 {
169     /* Whatever this is supposed to do, our handles probably
170        don't need it :-) */
171 }
172
173
174 BOOL32 WINAPI _KERNEL32_100(HANDLE32 threadid,DWORD exitcode,DWORD x) {
175         FIXME(thread,"(%d,%ld,0x%08lx): stub\n",threadid,exitcode,x);
176         return TRUE;
177 }
178
179 DWORD WINAPI _KERNEL32_99(DWORD x) {
180         FIXME(win32,"(0x%08lx): stub\n",x);
181         return 1;
182 }
183 /***********************************************************************
184  *           PrivateExtractIconExA                      [USER32.442]
185  */
186 HRESULT WINAPI PrivateExtractIconExA ( DWORD u, DWORD v, DWORD w, DWORD x ,DWORD y )
187 {       FIXME(win,"0x%08lx 0x%08lx 0x%08lx 0x%08lx 0x%08lx stub\n",u,v,w,x,y);
188         return 0;
189         
190 }
191 /***********************************************************************
192  *           PrivateExtractIconExW                      [USER32.443]
193  */
194 HRESULT WINAPI PrivateExtractIconExW ( DWORD u, DWORD v, DWORD w, DWORD x ,DWORD y )
195 {       FIXME(win,"0x%08lx 0x%08lx 0x%08lx 0x%08lx 0x%08lx stub\n",u,v,w,x,y);
196         return 0;
197         
198 }
199 /***********************************************************************
200  *           PrivateExtractIconsW                       [USER32.445]
201  */
202 HRESULT WINAPI PrivateExtractIconsW ( DWORD r, DWORD s, DWORD t, DWORD u, DWORD v, DWORD w, DWORD x, DWORD y )
203 {       FIXME(win,"0x%08lx 0x%08lx 0x%08lx 0x%08lx 0x%08lx 0x%08lx 0x%08lx 0x%08lx stub\n",r,s,t,u,v,w,x,y );
204         return 0;
205         
206 }
207 /***********************************************************************
208  *           RegisterShellHookWindow                    [USER32.459]
209  */
210 HRESULT WINAPI RegisterShellHookWindow ( DWORD u )
211 {       FIXME(win,"0x%08lx stub\n",u);
212         return 0;
213         
214 }
215 /***********************************************************************
216  *           DeregisterShellHookWindow                  [USER32.132]
217  */
218 HRESULT WINAPI DeregisterShellHookWindow ( DWORD u )
219 {       FIXME(win,"0x%08lx stub\n",u);
220         return 0;
221         
222 }
223 /***********************************************************************
224  *           RegisterTaskList32                         [USER23.436]
225  */
226 DWORD WINAPI RegisterTaskList32 (DWORD x)
227 {       FIXME(win,"0x%08lx\n",x);
228         return TRUE;
229 }
230