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"
34 #include "ntdll_misc.h"
35 #include "wine/server.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(ntdll
);
43 /******************************************************************************
44 * NtTerminateProcess [NTDLL.@]
46 * Native applications must kill themselves when done
48 NTSTATUS WINAPI
NtTerminateProcess( HANDLE handle
, LONG exit_code
)
52 SERVER_START_REQ( terminate_process
)
55 req
->exit_code
= exit_code
;
56 ret
= wine_server_call( req
);
57 self
= !ret
&& reply
->self
;
60 if (self
) exit( exit_code
);
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
;
79 TRACE("(%p,0x%08x,%p,0x%08lx,%p)\n",
80 ProcessHandle
,ProcessInformationClass
,
81 ProcessInformation
,ProcessInformationLength
,
84 switch (ProcessInformationClass
)
86 case ProcessBasicInformation
:
87 if (ProcessInformationLength
== sizeof(PROCESS_BASIC_INFORMATION
))
89 if (!ProcessInformation
) ret
= STATUS_ACCESS_VIOLATION
;
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
);
110 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
112 case ProcessIoCounters
:
116 if (ProcessInformationLength
>= sizeof(IO_COUNTERS
))
118 if (!ProcessInformation
)
119 ret
= STATUS_ACCESS_VIOLATION
;
120 else if (!ProcessHandle
)
121 ret
= STATUS_INVALID_HANDLE
;
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
;
138 case ProcessVmCounters
:
142 if (ProcessInformationLength
>= sizeof(VM_COUNTERS
))
144 if (!ProcessInformation
)
145 ret
= STATUS_ACCESS_VIOLATION
;
146 else if (!ProcessHandle
)
147 ret
= STATUS_INVALID_HANDLE
;
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
;
165 if (ProcessInformationLength
>= 32)
167 if (!ProcessInformation
)
168 ret
= STATUS_ACCESS_VIOLATION
;
169 else if (!ProcessHandle
)
170 ret
= STATUS_INVALID_HANDLE
;
173 memset(ProcessInformation
, 0, 32);
175 if (ProcessInformationLength
> 32)
176 ret
= STATUS_INFO_LENGTH_MISMATCH
;
181 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
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
);
191 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
193 case ProcessHandleCount
:
194 if (ProcessInformationLength
>= 4)
196 if (!ProcessInformation
)
197 ret
= STATUS_ACCESS_VIOLATION
;
198 else if (!ProcessHandle
)
199 ret
= STATUS_INVALID_HANDLE
;
202 memset(ProcessInformation
, 0, 4);
204 if (ProcessInformationLength
> 4)
205 ret
= STATUS_INFO_LENGTH_MISMATCH
;
210 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
212 case ProcessWow64Information
:
213 if (ProcessInformationLength
== 4)
215 memset(ProcessInformation
, 0, ProcessInformationLength
);
218 else ret
= STATUS_INFO_LENGTH_MISMATCH
;
221 FIXME("(%p,0x%08x,%p,0x%08lx,%p),stub!\n",
222 ProcessHandle
,ProcessInformationClass
,
223 ProcessInformation
,ProcessInformationLength
,
225 ret
= STATUS_INVALID_INFO_CLASS
;
229 if (ReturnLength
) *ReturnLength
= len
;
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
);
249 /******************************************************************************
250 * NtFlushInstructionCache [NTDLL.@]
251 * ZwFlushInstructionCache [NTDLL.@]
253 NTSTATUS WINAPI
NtFlushInstructionCache(
254 IN HANDLE ProcessHandle
,
255 IN LPCVOID BaseAddress
,
259 TRACE("%p %p %ld - no-op on x86\n", ProcessHandle
, BaseAddress
, Size
);
261 FIXME("%p %p %ld\n", ProcessHandle
, BaseAddress
, Size
);
263 return STATUS_SUCCESS
;