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
29 #include "wine/debug.h"
33 #include "ntdll_misc.h"
34 #include "wine/server.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
42 /******************************************************************************
43 * NtTerminateProcess [NTDLL.@]
45 * Native applications must kill themselves when done
47 NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
51 SERVER_START_REQ( terminate_process )
54 req->exit_code = exit_code;
55 ret = wine_server_call( req );
56 self = !ret && reply->self;
59 if (self) exit( exit_code );
63 /******************************************************************************
64 * NtQueryInformationProcess [NTDLL.@]
65 * ZwQueryInformationProcess [NTDLL.@]
68 NTSTATUS WINAPI NtQueryInformationProcess(
69 IN HANDLE ProcessHandle,
70 IN PROCESSINFOCLASS ProcessInformationClass,
71 OUT PVOID ProcessInformation,
72 IN ULONG ProcessInformationLength,
73 OUT PULONG ReturnLength)
75 NTSTATUS ret = STATUS_SUCCESS;
78 TRACE("(%p,0x%08x,%p,0x%08lx,%p)\n",
79 ProcessHandle,ProcessInformationClass,
80 ProcessInformation,ProcessInformationLength,
83 switch (ProcessInformationClass)
85 case ProcessBasicInformation:
87 PROCESS_BASIC_INFORMATION pbi;
89 if (ProcessInformationLength >= sizeof(PROCESS_BASIC_INFORMATION))
91 if (!ProcessInformation)
92 ret = STATUS_ACCESS_VIOLATION;
93 else if (!ProcessHandle)
94 ret = STATUS_INVALID_HANDLE;
97 SERVER_START_REQ(get_process_info)
99 req->handle = ProcessHandle;
100 if ((ret = wine_server_call( req )) == STATUS_SUCCESS)
102 pbi.ExitStatus = reply->exit_code;
103 pbi.PebBaseAddress = (DWORD)reply->peb;
104 pbi.AffinityMask = reply->process_affinity;
105 pbi.BasePriority = reply->priority;
106 pbi.UniqueProcessId = reply->pid;
107 pbi.InheritedFromUniqueProcessId = reply->ppid;
112 memcpy(ProcessInformation, &pbi, sizeof(PROCESS_BASIC_INFORMATION));
114 len = sizeof(PROCESS_BASIC_INFORMATION);
117 if (ProcessInformationLength > sizeof(PROCESS_BASIC_INFORMATION))
118 ret = STATUS_INFO_LENGTH_MISMATCH;
120 else ret = STATUS_INFO_LENGTH_MISMATCH;
123 case ProcessIoCounters:
127 if (ProcessInformationLength >= sizeof(IO_COUNTERS))
129 if (!ProcessInformation)
130 ret = STATUS_ACCESS_VIOLATION;
131 else if (!ProcessHandle)
132 ret = STATUS_INVALID_HANDLE;
135 /* FIXME : real data */
136 memset(&pii, 0 , sizeof(IO_COUNTERS));
138 memcpy(ProcessInformation, &pii, sizeof(IO_COUNTERS));
140 len = sizeof(IO_COUNTERS);
143 if (ProcessInformationLength > sizeof(IO_COUNTERS))
144 ret = STATUS_INFO_LENGTH_MISMATCH;
146 else ret = STATUS_INFO_LENGTH_MISMATCH;
149 case ProcessVmCounters:
153 if (ProcessInformationLength >= sizeof(VM_COUNTERS))
155 if (!ProcessInformation)
156 ret = STATUS_ACCESS_VIOLATION;
157 else if (!ProcessHandle)
158 ret = STATUS_INVALID_HANDLE;
161 /* FIXME : real data */
162 memset(&pvmi, 0 , sizeof(VM_COUNTERS));
164 memcpy(ProcessInformation, &pvmi, sizeof(VM_COUNTERS));
166 len = sizeof(VM_COUNTERS);
169 if (ProcessInformationLength > sizeof(VM_COUNTERS))
170 ret = STATUS_INFO_LENGTH_MISMATCH;
172 else ret = STATUS_INFO_LENGTH_MISMATCH;
177 KERNEL_USER_TIMES pti;
179 if (ProcessInformationLength >= sizeof(KERNEL_USER_TIMES))
181 if (!ProcessInformation)
182 ret = STATUS_ACCESS_VIOLATION;
183 else if (!ProcessHandle)
184 ret = STATUS_INVALID_HANDLE;
187 /* FIXME : real data */
188 memset(&pti, 0, sizeof(KERNEL_USER_TIMES));
190 memcpy(ProcessInformation, &pti, sizeof(KERNEL_USER_TIMES));
192 len = sizeof(KERNEL_USER_TIMES);
195 if (ProcessInformationLength > sizeof(KERNEL_USER_TIMES))
196 ret = STATUS_INFO_LENGTH_MISMATCH;
198 else ret = STATUS_INFO_LENGTH_MISMATCH;
201 case ProcessDebugPort:
202 /* "These are not the debuggers you are looking for." *
203 * set it to 0 aka "no debugger" to satisfy copy protections */
204 if (ProcessInformationLength == 4)
206 memset(ProcessInformation, 0, ProcessInformationLength);
209 else ret = STATUS_INFO_LENGTH_MISMATCH;
211 case ProcessHandleCount:
212 if (ProcessInformationLength >= 4)
214 if (!ProcessInformation)
215 ret = STATUS_ACCESS_VIOLATION;
216 else if (!ProcessHandle)
217 ret = STATUS_INVALID_HANDLE;
220 memset(ProcessInformation, 0, 4);
226 if (ProcessInformationLength > 4)
227 ret = STATUS_INFO_LENGTH_MISMATCH;
229 else ret = STATUS_INFO_LENGTH_MISMATCH;
231 case ProcessWow64Information:
232 if (ProcessInformationLength == 4)
234 memset(ProcessInformation, 0, ProcessInformationLength);
237 else ret = STATUS_INFO_LENGTH_MISMATCH;
240 FIXME("(%p,0x%08x,%p,0x%08lx,%p),stub!\n",
241 ProcessHandle,ProcessInformationClass,
242 ProcessInformation,ProcessInformationLength,
244 ret = STATUS_INVALID_INFO_CLASS;
248 if (ReturnLength) *ReturnLength = len;
253 /******************************************************************************
254 * NtSetInformationProcess [NTDLL.@]
255 * ZwSetInformationProcess [NTDLL.@]
257 NTSTATUS WINAPI NtSetInformationProcess(
258 IN HANDLE ProcessHandle,
259 IN PROCESSINFOCLASS ProcessInformationClass,
260 IN PVOID ProcessInformation,
261 IN ULONG ProcessInformationLength)
263 FIXME("(%p,0x%08x,%p,0x%08lx) stub\n",
264 ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength);
268 /******************************************************************************
269 * NtFlushInstructionCache [NTDLL.@]
270 * ZwFlushInstructionCache [NTDLL.@]
272 NTSTATUS WINAPI NtFlushInstructionCache(
273 IN HANDLE ProcessHandle,
274 IN LPCVOID BaseAddress,
278 TRACE("%p %p %ld - no-op on x86\n", ProcessHandle, BaseAddress, Size );
280 FIXME("%p %p %ld\n", ProcessHandle, BaseAddress, Size );
282 return STATUS_SUCCESS;