Stub implementations for ProcessVmCounters, ProcessTimes and
[wine/wine-kai.git] / dlls / ntdll / process.c
blobb8899aeae8e3fb1133e486389b01f5df2d81519c
1 /*
2 * NT basis DLL
4 * This file contains the Nt* API functions of NTDLL.DLL.
5 * In the original ntdll.dll they all seem to just call int 0x2e (down to the NTOSKRNL)
7 * Copyright 1996-1998 Marcus Meissner
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <time.h>
29 #include "wine/debug.h"
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winternl.h"
34 #include "ntdll_misc.h"
35 #include "wine/server.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
40 * Process object
43 /******************************************************************************
44 * NtTerminateProcess [NTDLL.@]
46 * Native applications must kill themselves when done
48 NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
50 NTSTATUS ret;
51 BOOL self;
52 SERVER_START_REQ( terminate_process )
54 req->handle = handle;
55 req->exit_code = exit_code;
56 ret = wine_server_call( req );
57 self = !ret && reply->self;
59 SERVER_END_REQ;
60 if (self) exit( exit_code );
61 return ret;
64 /******************************************************************************
65 * NtQueryInformationProcess [NTDLL.@]
66 * ZwQueryInformationProcess [NTDLL.@]
69 NTSTATUS WINAPI NtQueryInformationProcess(
70 IN HANDLE ProcessHandle,
71 IN PROCESSINFOCLASS ProcessInformationClass,
72 OUT PVOID ProcessInformation,
73 IN ULONG ProcessInformationLength,
74 OUT PULONG ReturnLength)
76 NTSTATUS ret = STATUS_SUCCESS;
77 ULONG len = 0;
79 TRACE("(%p,0x%08x,%p,0x%08lx,%p)\n",
80 ProcessHandle,ProcessInformationClass,
81 ProcessInformation,ProcessInformationLength,
82 ReturnLength);
84 switch (ProcessInformationClass)
86 case ProcessBasicInformation:
87 if (ProcessInformationLength == sizeof(PROCESS_BASIC_INFORMATION))
89 if (!ProcessInformation) ret = STATUS_ACCESS_VIOLATION;
90 else
92 SERVER_START_REQ(get_process_info)
94 req->handle = ProcessHandle;
95 if ((ret = wine_server_call( req )) == STATUS_SUCCESS)
97 PROCESS_BASIC_INFORMATION* pbi = (PROCESS_BASIC_INFORMATION*)ProcessInformation;
98 pbi->ExitStatus = reply->exit_code;
99 pbi->PebBaseAddress = (DWORD)reply->peb;
100 pbi->AffinityMask = reply->process_affinity;
101 pbi->BasePriority = reply->priority;
102 pbi->UniqueProcessId = reply->pid;
103 pbi->InheritedFromUniqueProcessId = reply->ppid;
104 len = sizeof(PROCESS_BASIC_INFORMATION);
107 SERVER_END_REQ;
110 else ret = STATUS_INFO_LENGTH_MISMATCH;
111 break;
112 case ProcessIoCounters:
114 IO_COUNTERS pii;
116 if (ProcessInformationLength >= sizeof(IO_COUNTERS))
118 if (!ProcessInformation)
119 ret = STATUS_ACCESS_VIOLATION;
120 else if (!ProcessHandle)
121 ret = STATUS_INVALID_HANDLE;
122 else
124 /* FIXME : real data */
125 memset(&pii, 0 , sizeof(IO_COUNTERS));
127 if (ProcessInformationLength > sizeof(IO_COUNTERS))
128 ret = STATUS_INFO_LENGTH_MISMATCH;
130 memcpy(ProcessInformation, &pii, sizeof(IO_COUNTERS));
132 len = sizeof(IO_COUNTERS);
135 else ret = STATUS_INFO_LENGTH_MISMATCH;
137 break;
138 case ProcessVmCounters:
140 VM_COUNTERS pvmi;
142 if (ProcessInformationLength >= sizeof(VM_COUNTERS))
144 if (!ProcessInformation)
145 ret = STATUS_ACCESS_VIOLATION;
146 else if (!ProcessHandle)
147 ret = STATUS_INVALID_HANDLE;
148 else
150 /* FIXME : real data */
151 memset(&pvmi, 0 , sizeof(VM_COUNTERS));
153 if (ProcessInformationLength > sizeof(VM_COUNTERS))
154 ret = STATUS_INFO_LENGTH_MISMATCH;
156 memcpy(ProcessInformation, &pvmi, sizeof(VM_COUNTERS));
158 len = sizeof(VM_COUNTERS);
161 else ret = STATUS_INFO_LENGTH_MISMATCH;
163 break;
164 case ProcessTimes:
165 if (ProcessInformationLength >= 32)
167 if (!ProcessInformation)
168 ret = STATUS_ACCESS_VIOLATION;
169 else if (!ProcessHandle)
170 ret = STATUS_INVALID_HANDLE;
171 else
173 memset(ProcessInformation, 0, 32);
175 if (ProcessInformationLength > 32)
176 ret = STATUS_INFO_LENGTH_MISMATCH;
178 len = 32;
181 else ret = STATUS_INFO_LENGTH_MISMATCH;
182 break;
183 case ProcessDebugPort:
184 /* "These are not the debuggers you are looking for." *
185 * set it to 0 aka "no debugger" to satisfy copy protections */
186 if (ProcessInformationLength == 4)
188 memset(ProcessInformation, 0, ProcessInformationLength);
189 len = 4;
191 else ret = STATUS_INFO_LENGTH_MISMATCH;
192 break;
193 case ProcessHandleCount:
194 if (ProcessInformationLength >= 4)
196 if (!ProcessInformation)
197 ret = STATUS_ACCESS_VIOLATION;
198 else if (!ProcessHandle)
199 ret = STATUS_INVALID_HANDLE;
200 else
202 memset(ProcessInformation, 0, 4);
204 if (ProcessInformationLength > 4)
205 ret = STATUS_INFO_LENGTH_MISMATCH;
207 len = 4;
210 else ret = STATUS_INFO_LENGTH_MISMATCH;
211 break;
212 case ProcessWow64Information:
213 if (ProcessInformationLength == 4)
215 memset(ProcessInformation, 0, ProcessInformationLength);
216 len = 4;
218 else ret = STATUS_INFO_LENGTH_MISMATCH;
219 break;
220 default:
221 FIXME("(%p,0x%08x,%p,0x%08lx,%p),stub!\n",
222 ProcessHandle,ProcessInformationClass,
223 ProcessInformation,ProcessInformationLength,
224 ReturnLength);
225 ret = STATUS_INVALID_INFO_CLASS;
226 break;
229 if (ReturnLength) *ReturnLength = len;
231 return ret;
234 /******************************************************************************
235 * NtSetInformationProcess [NTDLL.@]
236 * ZwSetInformationProcess [NTDLL.@]
238 NTSTATUS WINAPI NtSetInformationProcess(
239 IN HANDLE ProcessHandle,
240 IN PROCESSINFOCLASS ProcessInformationClass,
241 IN PVOID ProcessInformation,
242 IN ULONG ProcessInformationLength)
244 FIXME("(%p,0x%08x,%p,0x%08lx) stub\n",
245 ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength);
246 return 0;
249 /******************************************************************************
250 * NtFlushInstructionCache [NTDLL.@]
251 * ZwFlushInstructionCache [NTDLL.@]
253 NTSTATUS WINAPI NtFlushInstructionCache(
254 IN HANDLE ProcessHandle,
255 IN LPCVOID BaseAddress,
256 IN ULONG Size)
258 #ifdef __i386__
259 TRACE("%p %p %ld - no-op on x86\n", ProcessHandle, BaseAddress, Size );
260 #else
261 FIXME("%p %p %ld\n", ProcessHandle, BaseAddress, Size );
262 #endif
263 return STATUS_SUCCESS;