Fix indentation and coding style. No code changes.

svn path=/trunk/; revision=45018
This commit is contained in:
Eric Kohl 2010-01-09 20:51:33 +00:00
parent ce0ab52c93
commit 1145a26d92
14 changed files with 983 additions and 886 deletions

View file

@ -27,8 +27,9 @@ static BOOL bCommandLineInitialized = FALSE;
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
static VOID static
InitCommandLines (VOID) VOID
InitCommandLines(VOID)
{ {
PRTL_USER_PROCESS_PARAMETERS Params; PRTL_USER_PROCESS_PARAMETERS Params;
@ -42,7 +43,7 @@ InitCommandLines (VOID)
CommandLineStringW.Length = Params->CommandLine.Length; CommandLineStringW.Length = Params->CommandLine.Length;
CommandLineStringW.MaximumLength = CommandLineStringW.Length + sizeof(WCHAR); CommandLineStringW.MaximumLength = CommandLineStringW.Length + sizeof(WCHAR);
CommandLineStringW.Buffer = RtlAllocateHeap(GetProcessHeap(), CommandLineStringW.Buffer = RtlAllocateHeap(GetProcessHeap(),
HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY, HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY,
CommandLineStringW.MaximumLength); CommandLineStringW.MaximumLength);
if (CommandLineStringW.Buffer == NULL) if (CommandLineStringW.Buffer == NULL)
{ {
@ -51,18 +52,18 @@ InitCommandLines (VOID)
RtlInitAnsiString(&CommandLineStringA, NULL); RtlInitAnsiString(&CommandLineStringA, NULL);
// copy command line /* Copy command line */
RtlCopyUnicodeString (&CommandLineStringW, RtlCopyUnicodeString(&CommandLineStringW,
&(Params->CommandLine)); &(Params->CommandLine));
CommandLineStringW.Buffer[CommandLineStringW.Length / sizeof(WCHAR)] = 0; CommandLineStringW.Buffer[CommandLineStringW.Length / sizeof(WCHAR)] = 0;
/* convert unicode string to ansi (or oem) */ /* convert unicode string to ansi (or oem) */
if (bIsFileApiAnsi) if (bIsFileApiAnsi)
RtlUnicodeStringToAnsiString (&CommandLineStringA, RtlUnicodeStringToAnsiString(&CommandLineStringA,
&CommandLineStringW, &CommandLineStringW,
TRUE); TRUE);
else else
RtlUnicodeStringToOemString (&CommandLineStringA, RtlUnicodeStringToOemString(&CommandLineStringA,
&CommandLineStringW, &CommandLineStringW,
TRUE); TRUE);
@ -75,32 +76,36 @@ InitCommandLines (VOID)
/* /*
* @implemented * @implemented
*/ */
LPSTR WINAPI GetCommandLineA(VOID) LPSTR
WINAPI
GetCommandLineA(VOID)
{ {
if (bCommandLineInitialized == FALSE) if (bCommandLineInitialized == FALSE)
{ {
InitCommandLines (); InitCommandLines();
} }
DPRINT ("CommandLine \'%s\'\n", CommandLineStringA.Buffer); DPRINT("CommandLine \'%s\'\n", CommandLineStringA.Buffer);
return(CommandLineStringA.Buffer); return CommandLineStringA.Buffer;
} }
/* /*
* @implemented * @implemented
*/ */
LPWSTR WINAPI GetCommandLineW (VOID) LPWSTR
WINAPI
GetCommandLineW(VOID)
{ {
if (bCommandLineInitialized == FALSE) if (bCommandLineInitialized == FALSE)
{ {
InitCommandLines (); InitCommandLines();
} }
DPRINT ("CommandLine \'%S\'\n", CommandLineStringW.Buffer); DPRINT("CommandLine \'%S\'\n", CommandLineStringW.Buffer);
return(CommandLineStringW.Buffer); return CommandLineStringW.Buffer;
} }
/* EOF */ /* EOF */

View file

@ -31,13 +31,13 @@ CreateJobObjectA(LPSECURITY_ATTRIBUTES lpJobAttributes,
ANSI_STRING AnsiName; ANSI_STRING AnsiName;
UNICODE_STRING UnicodeName; UNICODE_STRING UnicodeName;
if(lpName != NULL) if (lpName != NULL)
{ {
NTSTATUS Status; NTSTATUS Status;
RtlInitAnsiString(&AnsiName, lpName); RtlInitAnsiString(&AnsiName, lpName);
Status = RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE); Status = RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE);
if(!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return FALSE; return FALSE;
@ -47,10 +47,11 @@ CreateJobObjectA(LPSECURITY_ATTRIBUTES lpJobAttributes,
hJob = CreateJobObjectW(lpJobAttributes, hJob = CreateJobObjectW(lpJobAttributes,
((lpName != NULL) ? UnicodeName.Buffer : NULL)); ((lpName != NULL) ? UnicodeName.Buffer : NULL));
if(lpName != NULL) if (lpName != NULL)
{ {
RtlFreeUnicodeString(&UnicodeName); RtlFreeUnicodeString(&UnicodeName);
} }
return hJob; return hJob;
} }
@ -70,17 +71,18 @@ CreateJobObjectW(LPSECURITY_ATTRIBUTES lpJobAttributes,
HANDLE hJob; HANDLE hJob;
NTSTATUS Status; NTSTATUS Status;
if(lpName != NULL) if (lpName != NULL)
{ {
RtlInitUnicodeString(&JobName, lpName); RtlInitUnicodeString(&JobName, lpName);
} }
if(lpJobAttributes != NULL) if (lpJobAttributes != NULL)
{ {
if(lpJobAttributes->bInheritHandle) if (lpJobAttributes->bInheritHandle)
{ {
Attributes |= OBJ_INHERIT; Attributes |= OBJ_INHERIT;
} }
SecurityDescriptor = lpJobAttributes->lpSecurityDescriptor; SecurityDescriptor = lpJobAttributes->lpSecurityDescriptor;
} }
else else
@ -97,7 +99,7 @@ CreateJobObjectW(LPSECURITY_ATTRIBUTES lpJobAttributes,
Status = NtCreateJobObject(&hJob, Status = NtCreateJobObject(&hJob,
JOB_OBJECT_ALL_ACCESS, JOB_OBJECT_ALL_ACCESS,
&ObjectAttributes); &ObjectAttributes);
if(!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return NULL; return NULL;
@ -121,7 +123,7 @@ OpenJobObjectW(DWORD dwDesiredAccess,
HANDLE hJob; HANDLE hJob;
NTSTATUS Status; NTSTATUS Status;
if(lpName == NULL) if (lpName == NULL)
{ {
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
return NULL; return NULL;
@ -138,8 +140,7 @@ OpenJobObjectW(DWORD dwDesiredAccess,
Status = NtOpenJobObject(&hJob, Status = NtOpenJobObject(&hJob,
dwDesiredAccess, dwDesiredAccess,
&ObjectAttributes); &ObjectAttributes);
if (!NT_SUCCESS(Status))
if(!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return NULL; return NULL;
@ -163,7 +164,7 @@ OpenJobObjectA(DWORD dwDesiredAccess,
HANDLE hJob; HANDLE hJob;
NTSTATUS Status; NTSTATUS Status;
if(lpName == NULL) if (lpName == NULL)
{ {
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
return NULL; return NULL;
@ -171,7 +172,7 @@ OpenJobObjectA(DWORD dwDesiredAccess,
RtlInitAnsiString(&AnsiName, lpName); RtlInitAnsiString(&AnsiName, lpName);
Status = RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE); Status = RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE);
if(!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return FALSE; return FALSE;
@ -198,7 +199,7 @@ IsProcessInJob(HANDLE ProcessHandle,
NTSTATUS Status; NTSTATUS Status;
Status = NtIsProcessInJob(ProcessHandle, JobHandle); Status = NtIsProcessInJob(ProcessHandle, JobHandle);
if(NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
*Result = (Status == STATUS_PROCESS_IN_JOB); *Result = (Status == STATUS_PROCESS_IN_JOB);
return TRUE; return TRUE;
@ -220,11 +221,12 @@ AssignProcessToJobObject(HANDLE hJob,
NTSTATUS Status; NTSTATUS Status;
Status = NtAssignProcessToJobObject(hJob, hProcess); Status = NtAssignProcessToJobObject(hJob, hProcess);
if(!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
@ -247,14 +249,16 @@ QueryInformationJobObject(HANDLE hJob,
lpJobObjectInformation, lpJobObjectInformation,
cbJobObjectInformationLength, cbJobObjectInformationLength,
lpReturnLength); lpReturnLength);
if(NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
PJOBOBJECT_BASIC_LIMIT_INFORMATION BasicInfo; PJOBOBJECT_BASIC_LIMIT_INFORMATION BasicInfo;
switch(JobObjectInformationClass)
switch (JobObjectInformationClass)
{ {
case JobObjectBasicLimitInformation: case JobObjectBasicLimitInformation:
BasicInfo = (PJOBOBJECT_BASIC_LIMIT_INFORMATION)lpJobObjectInformation; BasicInfo = (PJOBOBJECT_BASIC_LIMIT_INFORMATION)lpJobObjectInformation;
break; break;
case JobObjectExtendedLimitInformation: case JobObjectExtendedLimitInformation:
BasicInfo = &((PJOBOBJECT_EXTENDED_LIMIT_INFORMATION)lpJobObjectInformation)->BasicLimitInformation; BasicInfo = &((PJOBOBJECT_EXTENDED_LIMIT_INFORMATION)lpJobObjectInformation)->BasicLimitInformation;
break; break;
@ -264,31 +268,37 @@ QueryInformationJobObject(HANDLE hJob,
break; break;
} }
if(BasicInfo != NULL) if (BasicInfo != NULL)
{ {
/* we need to convert the process priority classes in the /* we need to convert the process priority classes in the
JOBOBJECT_BASIC_LIMIT_INFORMATION structure the same way as JOBOBJECT_BASIC_LIMIT_INFORMATION structure the same way as
GetPriorityClass() converts it! */ GetPriorityClass() converts it! */
switch(BasicInfo->PriorityClass) switch (BasicInfo->PriorityClass)
{ {
case PROCESS_PRIORITY_CLASS_IDLE: case PROCESS_PRIORITY_CLASS_IDLE:
BasicInfo->PriorityClass = IDLE_PRIORITY_CLASS; BasicInfo->PriorityClass = IDLE_PRIORITY_CLASS;
break; break;
case PROCESS_PRIORITY_CLASS_BELOW_NORMAL: case PROCESS_PRIORITY_CLASS_BELOW_NORMAL:
BasicInfo->PriorityClass = BELOW_NORMAL_PRIORITY_CLASS; BasicInfo->PriorityClass = BELOW_NORMAL_PRIORITY_CLASS;
break; break;
case PROCESS_PRIORITY_CLASS_NORMAL: case PROCESS_PRIORITY_CLASS_NORMAL:
BasicInfo->PriorityClass = NORMAL_PRIORITY_CLASS; BasicInfo->PriorityClass = NORMAL_PRIORITY_CLASS;
break; break;
case PROCESS_PRIORITY_CLASS_ABOVE_NORMAL: case PROCESS_PRIORITY_CLASS_ABOVE_NORMAL:
BasicInfo->PriorityClass = ABOVE_NORMAL_PRIORITY_CLASS; BasicInfo->PriorityClass = ABOVE_NORMAL_PRIORITY_CLASS;
break; break;
case PROCESS_PRIORITY_CLASS_HIGH: case PROCESS_PRIORITY_CLASS_HIGH:
BasicInfo->PriorityClass = HIGH_PRIORITY_CLASS; BasicInfo->PriorityClass = HIGH_PRIORITY_CLASS;
break; break;
case PROCESS_PRIORITY_CLASS_REALTIME: case PROCESS_PRIORITY_CLASS_REALTIME:
BasicInfo->PriorityClass = REALTIME_PRIORITY_CLASS; BasicInfo->PriorityClass = REALTIME_PRIORITY_CLASS;
break; break;
default: default:
BasicInfo->PriorityClass = NORMAL_PRIORITY_CLASS; BasicInfo->PriorityClass = NORMAL_PRIORITY_CLASS;
break; break;
@ -318,25 +328,27 @@ SetInformationJobObject(HANDLE hJob,
PVOID ObjectInfo; PVOID ObjectInfo;
NTSTATUS Status; NTSTATUS Status;
switch(JobObjectInformationClass) switch (JobObjectInformationClass)
{ {
case JobObjectBasicLimitInformation: case JobObjectBasicLimitInformation:
if(cbJobObjectInformationLength != sizeof(JOBOBJECT_BASIC_LIMIT_INFORMATION)) if (cbJobObjectInformationLength != sizeof(JOBOBJECT_BASIC_LIMIT_INFORMATION))
{ {
SetLastError(ERROR_BAD_LENGTH); SetLastError(ERROR_BAD_LENGTH);
return FALSE; return FALSE;
} }
ObjectInfo = &ExtendedLimitInfo.BasicLimitInformation; ObjectInfo = &ExtendedLimitInfo.BasicLimitInformation;
BasicInfo = (PJOBOBJECT_BASIC_LIMIT_INFORMATION)ObjectInfo; BasicInfo = (PJOBOBJECT_BASIC_LIMIT_INFORMATION)ObjectInfo;
RtlCopyMemory(ObjectInfo, lpJobObjectInformation, cbJobObjectInformationLength); RtlCopyMemory(ObjectInfo, lpJobObjectInformation, cbJobObjectInformationLength);
break; break;
case JobObjectExtendedLimitInformation: case JobObjectExtendedLimitInformation:
if(cbJobObjectInformationLength != sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION)) if (cbJobObjectInformationLength != sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION))
{ {
SetLastError(ERROR_BAD_LENGTH); SetLastError(ERROR_BAD_LENGTH);
return FALSE; return FALSE;
} }
ObjectInfo = &ExtendedLimitInfo; ObjectInfo = &ExtendedLimitInfo;
BasicInfo = &ExtendedLimitInfo.BasicLimitInformation; BasicInfo = &ExtendedLimitInfo.BasicLimitInformation;
RtlCopyMemory(ObjectInfo, lpJobObjectInformation, cbJobObjectInformationLength); RtlCopyMemory(ObjectInfo, lpJobObjectInformation, cbJobObjectInformationLength);
@ -348,7 +360,7 @@ SetInformationJobObject(HANDLE hJob,
break; break;
} }
if(BasicInfo != NULL) if (BasicInfo != NULL)
{ {
/* we need to convert the process priority classes in the /* we need to convert the process priority classes in the
JOBOBJECT_BASIC_LIMIT_INFORMATION structure the same way as JOBOBJECT_BASIC_LIMIT_INFORMATION structure the same way as
@ -358,21 +370,27 @@ SetInformationJobObject(HANDLE hJob,
case IDLE_PRIORITY_CLASS: case IDLE_PRIORITY_CLASS:
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_IDLE; BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_IDLE;
break; break;
case BELOW_NORMAL_PRIORITY_CLASS: case BELOW_NORMAL_PRIORITY_CLASS:
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_BELOW_NORMAL; BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_BELOW_NORMAL;
break; break;
case NORMAL_PRIORITY_CLASS: case NORMAL_PRIORITY_CLASS:
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL; BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
break; break;
case ABOVE_NORMAL_PRIORITY_CLASS: case ABOVE_NORMAL_PRIORITY_CLASS:
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_ABOVE_NORMAL; BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_ABOVE_NORMAL;
break; break;
case HIGH_PRIORITY_CLASS: case HIGH_PRIORITY_CLASS:
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_HIGH; BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_HIGH;
break; break;
case REALTIME_PRIORITY_CLASS: case REALTIME_PRIORITY_CLASS:
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_REALTIME; BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_REALTIME;
break; break;
default: default:
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL; BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
break; break;
@ -383,7 +401,7 @@ SetInformationJobObject(HANDLE hJob,
JobObjectInformationClass, JobObjectInformationClass,
ObjectInfo, ObjectInfo,
cbJobObjectInformationLength); cbJobObjectInformationLength);
if(!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return FALSE; return FALSE;
@ -404,7 +422,7 @@ TerminateJobObject(HANDLE hJob,
NTSTATUS Status; NTSTATUS Status;
Status = NtTerminateJobObject(hJob, uExitCode); Status = NtTerminateJobObject(hJob, uExitCode);
if(!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return FALSE; return FALSE;
@ -413,5 +431,4 @@ TerminateJobObject(HANDLE hJob,
return TRUE; return TRUE;
} }
/* EOF */ /* EOF */

View file

@ -33,8 +33,9 @@ RegisterWaitForInputIdle(WaitForInputIdleType lpfnRegisterWaitForInputIdle);
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
GetProcessAffinityMask (HANDLE hProcess, WINAPI
GetProcessAffinityMask(HANDLE hProcess,
LPDWORD lpProcessAffinityMask, LPDWORD lpProcessAffinityMask,
LPDWORD lpSystemAffinityMask) LPDWORD lpSystemAffinityMask)
{ {
@ -48,18 +49,18 @@ GetProcessAffinityMask (HANDLE hProcess,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus (Status); SetLastErrorByStatus(Status);
return FALSE; return FALSE;
} }
Status = NtQueryInformationProcess (hProcess, Status = NtQueryInformationProcess(hProcess,
ProcessBasicInformation, ProcessBasicInformation,
(PVOID)&ProcessInfo, (PVOID)&ProcessInfo,
sizeof(PROCESS_BASIC_INFORMATION), sizeof(PROCESS_BASIC_INFORMATION),
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus (Status); SetLastErrorByStatus(Status);
return FALSE; return FALSE;
} }
@ -73,19 +74,20 @@ GetProcessAffinityMask (HANDLE hProcess,
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
SetProcessAffinityMask (HANDLE hProcess, WINAPI
SetProcessAffinityMask(HANDLE hProcess,
DWORD dwProcessAffinityMask) DWORD dwProcessAffinityMask)
{ {
NTSTATUS Status; NTSTATUS Status;
Status = NtSetInformationProcess (hProcess, Status = NtSetInformationProcess(hProcess,
ProcessAffinityMask, ProcessAffinityMask,
(PVOID)&dwProcessAffinityMask, (PVOID)&dwProcessAffinityMask,
sizeof(DWORD)); sizeof(DWORD));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus (Status); SetLastErrorByStatus(Status);
return FALSE; return FALSE;
} }
@ -96,8 +98,9 @@ SetProcessAffinityMask (HANDLE hProcess,
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
GetProcessShutdownParameters (LPDWORD lpdwLevel, WINAPI
GetProcessShutdownParameters(LPDWORD lpdwLevel,
LPDWORD lpdwFlags) LPDWORD lpdwFlags)
{ {
CSR_API_MESSAGE CsrRequest; CSR_API_MESSAGE CsrRequest;
@ -111,22 +114,23 @@ GetProcessShutdownParameters (LPDWORD lpdwLevel,
sizeof(CSR_API_MESSAGE)); sizeof(CSR_API_MESSAGE));
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status)) if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status))
{ {
SetLastErrorByStatus (Status); SetLastErrorByStatus(Status);
return(FALSE); return FALSE;
} }
*lpdwLevel = CsrRequest.Data.GetShutdownParametersRequest.Level; *lpdwLevel = CsrRequest.Data.GetShutdownParametersRequest.Level;
*lpdwFlags = CsrRequest.Data.GetShutdownParametersRequest.Flags; *lpdwFlags = CsrRequest.Data.GetShutdownParametersRequest.Flags;
return(TRUE); return TRUE;
} }
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
SetProcessShutdownParameters (DWORD dwLevel, WINAPI
SetProcessShutdownParameters(DWORD dwLevel,
DWORD dwFlags) DWORD dwFlags)
{ {
CSR_API_MESSAGE CsrRequest; CSR_API_MESSAGE CsrRequest;
@ -143,19 +147,20 @@ SetProcessShutdownParameters (DWORD dwLevel,
sizeof(CSR_API_MESSAGE)); sizeof(CSR_API_MESSAGE));
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status)) if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status))
{ {
SetLastErrorByStatus (Status); SetLastErrorByStatus(Status);
return(FALSE); return FALSE;
} }
return(TRUE); return TRUE;
} }
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
GetProcessWorkingSetSize (HANDLE hProcess, WINAPI
GetProcessWorkingSetSize(HANDLE hProcess,
PSIZE_T lpMinimumWorkingSetSize, PSIZE_T lpMinimumWorkingSetSize,
PSIZE_T lpMaximumWorkingSetSize) PSIZE_T lpMaximumWorkingSetSize)
{ {
@ -170,20 +175,21 @@ GetProcessWorkingSetSize (HANDLE hProcess,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return(FALSE); return FALSE;
} }
*lpMinimumWorkingSetSize = QuotaLimits.MinimumWorkingSetSize; *lpMinimumWorkingSetSize = QuotaLimits.MinimumWorkingSetSize;
*lpMaximumWorkingSetSize = QuotaLimits.MaximumWorkingSetSize; *lpMaximumWorkingSetSize = QuotaLimits.MaximumWorkingSetSize;
return(TRUE); return TRUE;
} }
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
WINAPI
SetProcessWorkingSetSize(HANDLE hProcess, SetProcessWorkingSetSize(HANDLE hProcess,
SIZE_T dwMinimumWorkingSetSize, SIZE_T dwMinimumWorkingSetSize,
SIZE_T dwMaximumWorkingSetSize) SIZE_T dwMaximumWorkingSetSize)
@ -201,17 +207,18 @@ SetProcessWorkingSetSize(HANDLE hProcess,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return(FALSE); return FALSE;
} }
return(TRUE); return TRUE;
} }
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
WINAPI
GetProcessTimes(HANDLE hProcess, GetProcessTimes(HANDLE hProcess,
LPFILETIME lpCreationTime, LPFILETIME lpCreationTime,
LPFILETIME lpExitTime, LPFILETIME lpExitTime,
@ -229,7 +236,7 @@ GetProcessTimes(HANDLE hProcess,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return(FALSE); return FALSE;
} }
lpCreationTime->dwLowDateTime = Kut.CreateTime.u.LowPart; lpCreationTime->dwLowDateTime = Kut.CreateTime.u.LowPart;
@ -244,44 +251,48 @@ GetProcessTimes(HANDLE hProcess,
lpUserTime->dwLowDateTime = Kut.UserTime.u.LowPart; lpUserTime->dwLowDateTime = Kut.UserTime.u.LowPart;
lpUserTime->dwHighDateTime = Kut.UserTime.u.HighPart; lpUserTime->dwHighDateTime = Kut.UserTime.u.HighPart;
return(TRUE); return TRUE;
} }
/* /*
* @implemented * @implemented
*/ */
HANDLE WINAPI HANDLE
WINAPI
GetCurrentProcess(VOID) GetCurrentProcess(VOID)
{ {
return((HANDLE)NtCurrentProcess()); return (HANDLE)NtCurrentProcess();
} }
/* /*
* @implemented * @implemented
*/ */
HANDLE WINAPI HANDLE
WINAPI
GetCurrentThread(VOID) GetCurrentThread(VOID)
{ {
return((HANDLE)NtCurrentThread()); return (HANDLE)NtCurrentThread();
} }
/* /*
* @implemented * @implemented
*/ */
DWORD WINAPI DWORD
WINAPI
GetCurrentProcessId(VOID) GetCurrentProcessId(VOID)
{ {
return((DWORD)GetTeb()->ClientId.UniqueProcess); return (DWORD)GetTeb()->ClientId.UniqueProcess;
} }
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
WINAPI
GetExitCodeProcess(HANDLE hProcess, GetExitCodeProcess(HANDLE hProcess,
LPDWORD lpExitCode) LPDWORD lpExitCode)
{ {
@ -296,12 +307,12 @@ GetExitCodeProcess(HANDLE hProcess,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return(FALSE); return FALSE;
} }
*lpExitCode = (DWORD)ProcessBasic.ExitStatus; *lpExitCode = (DWORD)ProcessBasic.ExitStatus;
return(TRUE); return TRUE;
} }
@ -333,7 +344,8 @@ GetProcessId(HANDLE Process)
/* /*
* @implemented * @implemented
*/ */
HANDLE WINAPI HANDLE
WINAPI
OpenProcess(DWORD dwDesiredAccess, OpenProcess(DWORD dwDesiredAccess,
BOOL bInheritHandle, BOOL bInheritHandle,
DWORD dwProcessId) DWORD dwProcessId)
@ -358,9 +370,10 @@ OpenProcess(DWORD dwDesiredAccess,
&ClientId); &ClientId);
if (!NT_SUCCESS(errCode)) if (!NT_SUCCESS(errCode))
{ {
SetLastErrorByStatus (errCode); SetLastErrorByStatus(errCode);
return NULL; return NULL;
} }
return ProcessHandle; return ProcessHandle;
} }
@ -368,7 +381,8 @@ OpenProcess(DWORD dwDesiredAccess,
/* /*
* @implemented * @implemented
*/ */
UINT WINAPI UINT
WINAPI
WinExec(LPCSTR lpCmdLine, WinExec(LPCSTR lpCmdLine,
UINT uCmdShow) UINT uCmdShow)
{ {
@ -381,7 +395,7 @@ WinExec(LPCSTR lpCmdLine,
StartupInfo.wShowWindow = (WORD)uCmdShow; StartupInfo.wShowWindow = (WORD)uCmdShow;
StartupInfo.dwFlags = 0; StartupInfo.dwFlags = 0;
if (! CreateProcessA(NULL, if (!CreateProcessA(NULL,
(PVOID)lpCmdLine, (PVOID)lpCmdLine,
NULL, NULL,
NULL, NULL,
@ -395,13 +409,13 @@ WinExec(LPCSTR lpCmdLine,
dosErr = GetLastError(); dosErr = GetLastError();
return dosErr < 32 ? dosErr : ERROR_BAD_FORMAT; return dosErr < 32 ? dosErr : ERROR_BAD_FORMAT;
} }
if (NULL != lpfnGlobalRegisterWaitForInputIdle) if (NULL != lpfnGlobalRegisterWaitForInputIdle)
{ {
lpfnGlobalRegisterWaitForInputIdle ( lpfnGlobalRegisterWaitForInputIdle(ProcessInformation.hProcess,
ProcessInformation.hProcess, 10000);
10000
);
} }
NtClose(ProcessInformation.hProcess); NtClose(ProcessInformation.hProcess);
NtClose(ProcessInformation.hThread); NtClose(ProcessInformation.hThread);
@ -412,10 +426,9 @@ WinExec(LPCSTR lpCmdLine,
/* /*
* @implemented * @implemented
*/ */
VOID WINAPI VOID
RegisterWaitForInputIdle ( WINAPI
WaitForInputIdleType lpfnRegisterWaitForInputIdle RegisterWaitForInputIdle(WaitForInputIdleType lpfnRegisterWaitForInputIdle)
)
{ {
lpfnGlobalRegisterWaitForInputIdle = lpfnRegisterWaitForInputIdle; lpfnGlobalRegisterWaitForInputIdle = lpfnRegisterWaitForInputIdle;
return; return;
@ -424,7 +437,8 @@ RegisterWaitForInputIdle (
/* /*
* @implemented * @implemented
*/ */
VOID WINAPI VOID
WINAPI
GetStartupInfoW(LPSTARTUPINFOW lpStartupInfo) GetStartupInfoW(LPSTARTUPINFOW lpStartupInfo)
{ {
PRTL_USER_PROCESS_PARAMETERS Params; PRTL_USER_PROCESS_PARAMETERS Params;
@ -461,7 +475,8 @@ GetStartupInfoW(LPSTARTUPINFOW lpStartupInfo)
/* /*
* @implemented * @implemented
*/ */
VOID WINAPI VOID
WINAPI
GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo) GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
{ {
PRTL_USER_PROCESS_PARAMETERS Params; PRTL_USER_PROCESS_PARAMETERS Params;
@ -481,12 +496,12 @@ GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
if (lpLocalStartupInfo == NULL) if (lpLocalStartupInfo == NULL)
{ {
/* create new local startup info (ansi) */ /* create new local startup info (ansi) */
lpLocalStartupInfo = RtlAllocateHeap (RtlGetProcessHeap (), lpLocalStartupInfo = RtlAllocateHeap(RtlGetProcessHeap(),
0, 0,
sizeof(STARTUPINFOA)); sizeof(STARTUPINFOA));
if (lpLocalStartupInfo == NULL) if (lpLocalStartupInfo == NULL)
{ {
RtlReleasePebLock (); RtlReleasePebLock();
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return; return;
} }
@ -494,19 +509,19 @@ GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
lpLocalStartupInfo->cb = sizeof(STARTUPINFOA); lpLocalStartupInfo->cb = sizeof(STARTUPINFOA);
/* copy window title string */ /* copy window title string */
RtlUnicodeStringToAnsiString (&AnsiString, RtlUnicodeStringToAnsiString(&AnsiString,
&Params->WindowTitle, &Params->WindowTitle,
TRUE); TRUE);
lpLocalStartupInfo->lpTitle = AnsiString.Buffer; lpLocalStartupInfo->lpTitle = AnsiString.Buffer;
/* copy desktop info string */ /* copy desktop info string */
RtlUnicodeStringToAnsiString (&AnsiString, RtlUnicodeStringToAnsiString(&AnsiString,
&Params->DesktopInfo, &Params->DesktopInfo,
TRUE); TRUE);
lpLocalStartupInfo->lpDesktop = AnsiString.Buffer; lpLocalStartupInfo->lpDesktop = AnsiString.Buffer;
/* copy shell info string */ /* copy shell info string */
RtlUnicodeStringToAnsiString (&AnsiString, RtlUnicodeStringToAnsiString(&AnsiString,
&Params->ShellInfo, &Params->ShellInfo,
TRUE); TRUE);
lpLocalStartupInfo->lpReserved = AnsiString.Buffer; lpLocalStartupInfo->lpReserved = AnsiString.Buffer;
@ -528,10 +543,10 @@ GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
lpLocalStartupInfo->hStdError = Params->StandardError; lpLocalStartupInfo->hStdError = Params->StandardError;
} }
RtlReleasePebLock (); RtlReleasePebLock();
/* copy local startup info data to external startup info */ /* copy local startup info data to external startup info */
memcpy (lpStartupInfo, memcpy(lpStartupInfo,
lpLocalStartupInfo, lpLocalStartupInfo,
sizeof(STARTUPINFOA)); sizeof(STARTUPINFOA));
} }
@ -540,8 +555,9 @@ GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
FlushInstructionCache (HANDLE hProcess, WINAPI
FlushInstructionCache(HANDLE hProcess,
LPCVOID lpBaseAddress, LPCVOID lpBaseAddress,
DWORD dwSize) DWORD dwSize)
{ {
@ -555,6 +571,7 @@ FlushInstructionCache (HANDLE hProcess,
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
@ -562,7 +579,8 @@ FlushInstructionCache (HANDLE hProcess,
/* /*
* @implemented * @implemented
*/ */
VOID WINAPI VOID
WINAPI
ExitProcess(UINT uExitCode) ExitProcess(UINT uExitCode)
{ {
CSR_API_MESSAGE CsrRequest; CSR_API_MESSAGE CsrRequest;
@ -570,10 +588,10 @@ ExitProcess(UINT uExitCode)
NTSTATUS Status; NTSTATUS Status;
/* kill sibling threads ... we want to be alone at this point */ /* kill sibling threads ... we want to be alone at this point */
NtTerminateProcess (NULL, 0); NtTerminateProcess(NULL, 0);
/* unload all dll's */ /* unload all dll's */
LdrShutdownProcess (); LdrShutdownProcess();
/* notify csrss of process termination */ /* notify csrss of process termination */
Request = TERMINATE_PROCESS; Request = TERMINATE_PROCESS;
@ -586,8 +604,7 @@ ExitProcess(UINT uExitCode)
DPRINT("Failed to tell csrss about terminating process\n"); DPRINT("Failed to tell csrss about terminating process\n");
} }
NtTerminateProcess(NtCurrentProcess (),
NtTerminateProcess (NtCurrentProcess (),
uExitCode); uExitCode);
/* should never get here */ /* should never get here */
@ -599,8 +616,9 @@ ExitProcess(UINT uExitCode)
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
TerminateProcess (HANDLE hProcess, WINAPI
TerminateProcess(HANDLE hProcess,
UINT uExitCode) UINT uExitCode)
{ {
NTSTATUS Status; NTSTATUS Status;
@ -610,12 +628,13 @@ TerminateProcess (HANDLE hProcess,
return FALSE; return FALSE;
} }
Status = NtTerminateProcess (hProcess, uExitCode); Status = NtTerminateProcess(hProcess, uExitCode);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
return TRUE; return TRUE;
} }
SetLastErrorByStatus (Status);
SetLastErrorByStatus(Status);
return FALSE; return FALSE;
} }
@ -623,29 +642,31 @@ TerminateProcess (HANDLE hProcess,
/* /*
* @unimplemented * @unimplemented
*/ */
VOID WINAPI VOID
WINAPI
FatalAppExitA(UINT uAction, FatalAppExitA(UINT uAction,
LPCSTR lpMessageText) LPCSTR lpMessageText)
{ {
UNICODE_STRING MessageTextU; UNICODE_STRING MessageTextU;
ANSI_STRING MessageText; ANSI_STRING MessageText;
RtlInitAnsiString (&MessageText, (LPSTR) lpMessageText); RtlInitAnsiString(&MessageText, (LPSTR)lpMessageText);
RtlAnsiStringToUnicodeString (&MessageTextU, RtlAnsiStringToUnicodeString(&MessageTextU,
&MessageText, &MessageText,
TRUE); TRUE);
FatalAppExitW (uAction, MessageTextU.Buffer); FatalAppExitW(uAction, MessageTextU.Buffer);
RtlFreeUnicodeString (&MessageTextU); RtlFreeUnicodeString(&MessageTextU);
} }
/* /*
* @unimplemented * @unimplemented
*/ */
VOID WINAPI VOID
WINAPI
FatalAppExitW(UINT uAction, FatalAppExitW(UINT uAction,
LPCWSTR lpMessageText) LPCWSTR lpMessageText)
{ {
@ -657,7 +678,7 @@ FatalAppExitW(UINT uAction,
DPRINT1("AppExit\n"); DPRINT1("AppExit\n");
if (hModule) if (hModule)
pMessageBoxW = (MessageBoxW_Proc) GetProcAddress(hModule, "MessageBoxW"); pMessageBoxW = (MessageBoxW_Proc)GetProcAddress(hModule, "MessageBoxW");
if (pMessageBoxW) if (pMessageBoxW)
pMessageBoxW(0, lpMessageText, NULL, MB_SYSTEMMODAL | MB_OK); pMessageBoxW(0, lpMessageText, NULL, MB_SYSTEMMODAL | MB_OK);
@ -671,8 +692,9 @@ FatalAppExitW(UINT uAction,
/* /*
* @implemented * @implemented
*/ */
VOID WINAPI VOID
FatalExit (int ExitCode) WINAPI
FatalExit(int ExitCode)
{ {
ExitProcess(ExitCode); ExitProcess(ExitCode);
} }
@ -681,8 +703,9 @@ FatalExit (int ExitCode)
/* /*
* @implemented * @implemented
*/ */
DWORD WINAPI DWORD
GetPriorityClass (HANDLE hProcess) WINAPI
GetPriorityClass(HANDLE hProcess)
{ {
NTSTATUS Status; NTSTATUS Status;
PROCESS_PRIORITY_CLASS PriorityClass; PROCESS_PRIORITY_CLASS PriorityClass;
@ -727,14 +750,15 @@ GetPriorityClass (HANDLE hProcess)
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
SetPriorityClass (HANDLE hProcess, WINAPI
SetPriorityClass(HANDLE hProcess,
DWORD dwPriorityClass) DWORD dwPriorityClass)
{ {
NTSTATUS Status; NTSTATUS Status;
PROCESS_PRIORITY_CLASS PriorityClass; PROCESS_PRIORITY_CLASS PriorityClass;
switch(dwPriorityClass) switch (dwPriorityClass)
{ {
case IDLE_PRIORITY_CLASS: case IDLE_PRIORITY_CLASS:
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_IDLE; PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_IDLE;
@ -771,8 +795,7 @@ SetPriorityClass (HANDLE hProcess,
ProcessPriorityClass, ProcessPriorityClass,
&PriorityClass, &PriorityClass,
sizeof(PROCESS_PRIORITY_CLASS)); sizeof(PROCESS_PRIORITY_CLASS));
if (!NT_SUCCESS(Status))
if(!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return FALSE; return FALSE;
@ -785,7 +808,8 @@ SetPriorityClass (HANDLE hProcess,
/* /*
* @implemented * @implemented
*/ */
DWORD WINAPI DWORD
WINAPI
GetProcessVersion(DWORD ProcessId) GetProcessVersion(DWORD ProcessId)
{ {
DWORD Version = 0; DWORD Version = 0;
@ -801,17 +825,18 @@ GetProcessVersion(DWORD ProcessId)
_SEH2_TRY _SEH2_TRY
{ {
/* Caller's */
if (0 == ProcessId || GetCurrentProcessId() == ProcessId) if (0 == ProcessId || GetCurrentProcessId() == ProcessId)
{ {
/* Caller's */
BaseAddress = (PVOID) NtCurrentPeb()->ImageBaseAddress; BaseAddress = (PVOID) NtCurrentPeb()->ImageBaseAddress;
NtHeader = RtlImageNtHeader(BaseAddress); NtHeader = RtlImageNtHeader(BaseAddress);
Version = (NtHeader->OptionalHeader.MajorOperatingSystemVersion << 16) | Version = (NtHeader->OptionalHeader.MajorOperatingSystemVersion << 16) |
(NtHeader->OptionalHeader.MinorOperatingSystemVersion); (NtHeader->OptionalHeader.MinorOperatingSystemVersion);
} }
else /* other process */ else
{ {
/* Other process */
ProcessHandle = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, ProcessHandle = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION,
FALSE, FALSE,
ProcessId); ProcessId);
@ -823,14 +848,16 @@ GetProcessVersion(DWORD ProcessId)
&ProcessBasicInfo, &ProcessBasicInfo,
sizeof(ProcessBasicInfo), sizeof(ProcessBasicInfo),
NULL); NULL);
if (!NT_SUCCESS(Status)) goto Error; if (!NT_SUCCESS(Status))
goto Error;
Status = NtReadVirtualMemory(ProcessHandle, Status = NtReadVirtualMemory(ProcessHandle,
ProcessBasicInfo.PebBaseAddress, ProcessBasicInfo.PebBaseAddress,
&Peb, &Peb,
sizeof(Peb), sizeof(Peb),
&Count); &Count);
if (!NT_SUCCESS(Status) || Count != sizeof(Peb)) goto Error; if (!NT_SUCCESS(Status) || Count != sizeof(Peb))
goto Error;
memset(&DosHeader, 0, sizeof(DosHeader)); memset(&DosHeader, 0, sizeof(DosHeader));
Status = NtReadVirtualMemory(ProcessHandle, Status = NtReadVirtualMemory(ProcessHandle,
@ -839,8 +866,11 @@ GetProcessVersion(DWORD ProcessId)
sizeof(DosHeader), sizeof(DosHeader),
&Count); &Count);
if (!NT_SUCCESS(Status) || Count != sizeof(DosHeader)) goto Error; if (!NT_SUCCESS(Status) || Count != sizeof(DosHeader))
if (DosHeader.e_magic != IMAGE_DOS_SIGNATURE) goto Error; goto Error;
if (DosHeader.e_magic != IMAGE_DOS_SIGNATURE)
goto Error;
memset(&NtHeaders, 0, sizeof(NtHeaders)); memset(&NtHeaders, 0, sizeof(NtHeaders));
Status = NtReadVirtualMemory(ProcessHandle, Status = NtReadVirtualMemory(ProcessHandle,
@ -849,8 +879,11 @@ GetProcessVersion(DWORD ProcessId)
sizeof(NtHeaders), sizeof(NtHeaders),
&Count); &Count);
if (!NT_SUCCESS(Status) || Count != sizeof(NtHeaders)) goto Error; if (!NT_SUCCESS(Status) || Count != sizeof(NtHeaders))
if (NtHeaders.Signature != IMAGE_NT_SIGNATURE) goto Error; goto Error;
if (NtHeaders.Signature != IMAGE_NT_SIGNATURE)
goto Error;
Version = MAKELONG(NtHeaders.OptionalHeader.MinorSubsystemVersion, Version = MAKELONG(NtHeaders.OptionalHeader.MinorSubsystemVersion,
NtHeaders.OptionalHeader.MajorSubsystemVersion); NtHeaders.OptionalHeader.MajorSubsystemVersion);
@ -864,7 +897,8 @@ Error:
} }
_SEH2_FINALLY _SEH2_FINALLY
{ {
if (ProcessHandle) CloseHandle(ProcessHandle); if (ProcessHandle)
CloseHandle(ProcessHandle);
} }
_SEH2_END; _SEH2_END;
@ -877,8 +911,7 @@ Error:
*/ */
BOOL BOOL
WINAPI WINAPI
GetProcessIoCounters( GetProcessIoCounters(HANDLE hProcess,
HANDLE hProcess,
PIO_COUNTERS lpIoCounters) PIO_COUNTERS lpIoCounters)
{ {
NTSTATUS Status; NTSTATUS Status;
@ -891,7 +924,7 @@ GetProcessIoCounters(
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return(FALSE); return FALSE;
} }
return TRUE; return TRUE;
@ -982,10 +1015,8 @@ GetProcessHandleCount(HANDLE hProcess,
*/ */
BOOL BOOL
WINAPI WINAPI
IsWow64Process( IsWow64Process(HANDLE hProcess,
HANDLE hProcess, PBOOL Wow64Process)
PBOOL Wow64Process
)
{ {
ULONG pbi; ULONG pbi;
NTSTATUS Status; NTSTATUS Status;
@ -995,7 +1026,6 @@ IsWow64Process(
&pbi, &pbi,
sizeof(pbi), sizeof(pbi),
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
SetLastError(RtlNtStatusToDosError(Status)); SetLastError(RtlNtStatusToDosError(Status));
@ -1003,6 +1033,7 @@ IsWow64Process(
} }
*Wow64Process = (pbi != 0); *Wow64Process = (pbi != 0);
return TRUE; return TRUE;
} }
@ -1044,9 +1075,11 @@ QueryFullProcessImageNameW(HANDLE hProcess,
&Needed); &Needed);
Result = DynamicBuffer; Result = DynamicBuffer;
} }
else Result = (PUNICODE_STRING)Buffer; else
Result = (PUNICODE_STRING)Buffer;
if (!NT_SUCCESS(Status)) goto Cleanup; if (!NT_SUCCESS(Status))
goto Cleanup;
if (Result->Length / sizeof(WCHAR) + 1 > *pdwSize) if (Result->Length / sizeof(WCHAR) + 1 > *pdwSize)
{ {
@ -1065,6 +1098,7 @@ Cleanup:
{ {
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
} }
return !Status; return !Status;
} }
@ -1101,6 +1135,7 @@ QueryFullProcessImageNameA(HANDLE hProcess,
lpExeName, lpExeName,
*pdwSize, *pdwSize,
NULL, NULL)); NULL, NULL));
if (Result) if (Result)
*pdwSize = strlen(lpExeName); *pdwSize = strlen(lpExeName);

View file

@ -294,7 +294,8 @@ BasepDuplicateAndWriteHandle(IN HANDLE ProcessHandle,
"Address: %p\n", ProcessHandle, StandardHandle, Address); "Address: %p\n", ProcessHandle, StandardHandle, Address);
/* Don't touch Console Handles */ /* Don't touch Console Handles */
if (IsConsoleHandle(StandardHandle)) return; if (IsConsoleHandle(StandardHandle))
return;
/* Duplicate the handle */ /* Duplicate the handle */
Status = NtDuplicateObject(NtCurrentProcess(), Status = NtDuplicateObject(NtCurrentProcess(),
@ -1017,7 +1018,8 @@ GetAppName:
CmdLineLength = wcslen(CMD_STRING) + wcslen(lpCommandLine) + 1; CmdLineLength = wcslen(CMD_STRING) + wcslen(lpCommandLine) + 1;
/* If we found quotes, then add them into the length size */ /* If we found quotes, then add them into the length size */
if (CmdLineIsAppName || FoundQuotes) CmdLineLength += 2; if (CmdLineIsAppName || FoundQuotes)
CmdLineLength += 2;
CmdLineLength *= sizeof(WCHAR); CmdLineLength *= sizeof(WCHAR);
/* Allocate space for the new command line */ /* Allocate space for the new command line */
@ -1177,7 +1179,7 @@ GetAppName:
hSection, hSection,
hDebug, hDebug,
NULL); NULL);
if(!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("Unable to create process, status 0x%x\n", Status); DPRINT1("Unable to create process, status 0x%x\n", Status);
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
@ -1311,7 +1313,8 @@ GetAppName:
if(lpEnvironment && !(dwCreationFlags & CREATE_UNICODE_ENVIRONMENT)) if(lpEnvironment && !(dwCreationFlags & CREATE_UNICODE_ENVIRONMENT))
{ {
lpEnvironment = BasepConvertUnicodeEnvironment(&EnvSize, lpEnvironment); lpEnvironment = BasepConvertUnicodeEnvironment(&EnvSize, lpEnvironment);
if (!lpEnvironment) goto Cleanup; if (!lpEnvironment)
goto Cleanup;
} }
/* Create Process Environment */ /* Create Process Environment */
@ -1419,21 +1422,31 @@ GetAppName:
Cleanup: Cleanup:
/* De-allocate heap strings */ /* De-allocate heap strings */
if (NameBuffer) RtlFreeHeap(RtlGetProcessHeap(), 0, NameBuffer); if (NameBuffer)
RtlFreeHeap(RtlGetProcessHeap(), 0, NameBuffer);
if (ApplicationName.Buffer) if (ApplicationName.Buffer)
RtlFreeHeap(RtlGetProcessHeap(), 0, ApplicationName.Buffer); RtlFreeHeap(RtlGetProcessHeap(), 0, ApplicationName.Buffer);
if (CurrentDirectory) RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentDirectory);
if (QuotedCmdLine) RtlFreeHeap(RtlGetProcessHeap(), 0, QuotedCmdLine); if (CurrentDirectory)
RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentDirectory);
if (QuotedCmdLine)
RtlFreeHeap(RtlGetProcessHeap(), 0, QuotedCmdLine);
/* Kill any handles still alive */ /* Kill any handles still alive */
if (hSection) NtClose(hSection); if (hSection)
NtClose(hSection);
if (hThread) if (hThread)
{ {
/* We don't know any more details then this */ /* We don't know any more details then this */
NtTerminateProcess(hProcess, STATUS_UNSUCCESSFUL); NtTerminateProcess(hProcess, STATUS_UNSUCCESSFUL);
NtClose(hThread); NtClose(hThread);
} }
if (hProcess) NtClose(hProcess);
if (hProcess)
NtClose(hProcess);
/* Return Success */ /* Return Success */
return Ret; return Ret;

View file

@ -19,8 +19,11 @@ DWORD ActiveConsoleSessionId = 0;
/* /*
* @unimplemented * @unimplemented
*/ */
DWORD WINAPI DWORD
DosPathToSessionPathW (DWORD SessionID, LPWSTR InPath, LPWSTR * OutPath) WINAPI
DosPathToSessionPathW(DWORD SessionID,
LPWSTR InPath,
LPWSTR *OutPath)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
return 0; return 0;
@ -39,8 +42,11 @@ DosPathToSessionPathW (DWORD SessionID, LPWSTR InPath, LPWSTR * OutPath)
* *
* @unimplemented * @unimplemented
*/ */
DWORD WINAPI DWORD
DosPathToSessionPathA (DWORD SessionId, LPSTR InPath, LPSTR * OutPath) WINAPI
DosPathToSessionPathA(DWORD SessionId,
LPSTR InPath,
LPSTR *OutPath)
{ {
//DosPathToSessionPathW (SessionId,InPathW,OutPathW); //DosPathToSessionPathW (SessionId,InPathW,OutPathW);
UNIMPLEMENTED; UNIMPLEMENTED;
@ -50,8 +56,10 @@ DosPathToSessionPathA (DWORD SessionId, LPSTR InPath, LPSTR * OutPath)
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI ProcessIdToSessionId (IN DWORD dwProcessId, BOOL
OUT DWORD* pSessionId) WINAPI
ProcessIdToSessionId(IN DWORD dwProcessId,
OUT DWORD *pSessionId)
{ {
PROCESS_SESSION_INFORMATION SessionInformation; PROCESS_SESSION_INFORMATION SessionInformation;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
@ -59,7 +67,7 @@ BOOL WINAPI ProcessIdToSessionId (IN DWORD dwProcessId,
HANDLE ProcessHandle; HANDLE ProcessHandle;
NTSTATUS Status; NTSTATUS Status;
if(IsBadWritePtr(pSessionId, sizeof(DWORD))) if (IsBadWritePtr(pSessionId, sizeof(DWORD)))
{ {
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
return FALSE; return FALSE;
@ -74,7 +82,7 @@ BOOL WINAPI ProcessIdToSessionId (IN DWORD dwProcessId,
PROCESS_QUERY_INFORMATION, PROCESS_QUERY_INFORMATION,
&ObjectAttributes, &ObjectAttributes,
&ClientId); &ClientId);
if(NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
Status = NtQueryInformationProcess(ProcessHandle, Status = NtQueryInformationProcess(ProcessHandle,
ProcessSessionInformation, ProcessSessionInformation,
@ -83,7 +91,7 @@ BOOL WINAPI ProcessIdToSessionId (IN DWORD dwProcessId,
NULL); NULL);
NtClose(ProcessHandle); NtClose(ProcessHandle);
if(NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
*pSessionId = SessionInformation.SessionId; *pSessionId = SessionInformation.SessionId;
return TRUE; return TRUE;
@ -97,8 +105,9 @@ BOOL WINAPI ProcessIdToSessionId (IN DWORD dwProcessId,
/* /*
* @implemented * @implemented
*/ */
DWORD WINAPI DWORD
WTSGetActiveConsoleSessionId (VOID) WINAPI
WTSGetActiveConsoleSessionId(VOID)
{ {
return ActiveConsoleSessionId; return ActiveConsoleSessionId;
} }

View file

@ -27,7 +27,8 @@ InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
/* Initialize the critical section and raise an exception if we failed */ /* Initialize the critical section and raise an exception if we failed */
Status = RtlInitializeCriticalSection( Status = RtlInitializeCriticalSection(
(PRTL_CRITICAL_SECTION)lpCriticalSection); (PRTL_CRITICAL_SECTION)lpCriticalSection);
if (!NT_SUCCESS(Status)) RtlRaiseStatus(Status); if (!NT_SUCCESS(Status))
RtlRaiseStatus(Status);
} }
/* /*

View file

@ -75,7 +75,8 @@ CreateMutexExW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL,
BOOLEAN InitialOwner; BOOLEAN InitialOwner;
/* Now check if we got a name */ /* Now check if we got a name */
if (lpName) RtlInitUnicodeString(&ObjectName, lpName); if (lpName)
RtlInitUnicodeString(&ObjectName, lpName);
if (dwFlags & ~(CREATE_MUTEX_INITIAL_OWNER)) if (dwFlags & ~(CREATE_MUTEX_INITIAL_OWNER))
{ {
@ -257,7 +258,8 @@ ReleaseMutex(IN HANDLE hMutex)
/* Release the mutant */ /* Release the mutant */
Status = NtReleaseMutant(hMutex, NULL); Status = NtReleaseMutant(hMutex, NULL);
if (NT_SUCCESS(Status)) return TRUE; if (NT_SUCCESS(Status))
return TRUE;
/* If we got here, then we failed */ /* If we got here, then we failed */
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);

View file

@ -80,7 +80,8 @@ CreateSemaphoreExW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL,
UNICODE_STRING ObjectName; UNICODE_STRING ObjectName;
/* Now check if we got a name */ /* Now check if we got a name */
if (lpName) RtlInitUnicodeString(&ObjectName, lpName); if (lpName)
RtlInitUnicodeString(&ObjectName, lpName);
if (dwFlags != 0) if (dwFlags != 0)
{ {
@ -260,7 +261,8 @@ ReleaseSemaphore(IN HANDLE hSemaphore,
/* Release the semaphore */ /* Release the semaphore */
Status = NtReleaseSemaphore(hSemaphore, lReleaseCount, lpPreviousCount); Status = NtReleaseSemaphore(hSemaphore, lReleaseCount, lpPreviousCount);
if (NT_SUCCESS(Status)) return TRUE; if (NT_SUCCESS(Status))
return TRUE;
/* If we got here, then we failed */ /* If we got here, then we failed */
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);

View file

@ -75,7 +75,8 @@ CreateWaitableTimerExW(IN LPSECURITY_ATTRIBUTES lpTimerAttributes OPTIONAL,
TIMER_TYPE TimerType; TIMER_TYPE TimerType;
/* Now check if we got a name */ /* Now check if we got a name */
if (lpTimerName) RtlInitUnicodeString(&ObjectName, lpTimerName); if (lpTimerName)
RtlInitUnicodeString(&ObjectName, lpTimerName);
if (dwFlags & ~(CREATE_WAITABLE_TIMER_MANUAL_RESET)) if (dwFlags & ~(CREATE_WAITABLE_TIMER_MANUAL_RESET))
{ {
@ -268,7 +269,8 @@ SetWaitableTimer(IN HANDLE hTimer,
(BOOLEAN)fResume, (BOOLEAN)fResume,
lPeriod, lPeriod,
NULL); NULL);
if (NT_SUCCESS(Status)) return TRUE; if (NT_SUCCESS(Status))
return TRUE;
/* If we got here, then we failed */ /* If we got here, then we failed */
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
@ -286,7 +288,8 @@ CancelWaitableTimer(IN HANDLE hTimer)
/* Cancel the timer */ /* Cancel the timer */
Status = NtCancelTimer(hTimer, NULL); Status = NtCancelTimer(hTimer, NULL);
if (NT_SUCCESS(Status)) return TRUE; if (NT_SUCCESS(Status))
return TRUE;
/* If we got here, then we failed */ /* If we got here, then we failed */
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);

View file

@ -37,7 +37,7 @@ ConvertFiberToThread(VOID)
DPRINT1("Converting Fiber to Thread\n"); DPRINT1("Converting Fiber to Thread\n");
/* the current thread isn't running a fiber: failure */ /* the current thread isn't running a fiber: failure */
if(!pTeb->HasFiberData) if (!pTeb->HasFiberData)
{ {
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
return FALSE; return FALSE;
@ -47,7 +47,7 @@ ConvertFiberToThread(VOID)
pTeb->HasFiberData = FALSE; pTeb->HasFiberData = FALSE;
/* free the fiber */ /* free the fiber */
if(pTeb->Tib.FiberData != NULL) if (pTeb->Tib.FiberData != NULL)
{ {
RtlFreeHeap(GetProcessHeap(), 0, pTeb->Tib.FiberData); RtlFreeHeap(GetProcessHeap(), 0, pTeb->Tib.FiberData);
} }
@ -69,7 +69,8 @@ ConvertThreadToFiberEx(LPVOID lpParameter,
DPRINT1("Converting Thread to Fiber\n"); DPRINT1("Converting Thread to Fiber\n");
/* the current thread is already a fiber */ /* the current thread is already a fiber */
if(pTeb->HasFiberData && pTeb->Tib.FiberData) return pTeb->Tib.FiberData; if (pTeb->HasFiberData && pTeb->Tib.FiberData)
return pTeb->Tib.FiberData;
/* allocate the fiber */ /* allocate the fiber */
pfCurFiber = (PFIBER)RtlAllocateHeap(GetProcessHeap(), pfCurFiber = (PFIBER)RtlAllocateHeap(GetProcessHeap(),
@ -77,7 +78,7 @@ ConvertThreadToFiberEx(LPVOID lpParameter,
sizeof(FIBER)); sizeof(FIBER));
/* failure */ /* failure */
if(pfCurFiber == NULL) if (pfCurFiber == NULL)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return NULL; return NULL;
@ -150,17 +151,17 @@ CreateFiberEx(SIZE_T dwStackCommitSize,
PVOID ActivationContextStack = NULL; PVOID ActivationContextStack = NULL;
DPRINT1("Creating Fiber\n"); DPRINT1("Creating Fiber\n");
#ifdef SXS_SUPPORT_ENABLED #ifdef SXS_SUPPORT_ENABLED
/* Allocate the Activation Context Stack */ /* Allocate the Activation Context Stack */
nErrCode = RtlAllocateActivationContextStack(&ActivationContextStack); nErrCode = RtlAllocateActivationContextStack(&ActivationContextStack);
#endif #endif
/* Allocate the fiber */ /* Allocate the fiber */
pfCurFiber = (PFIBER)RtlAllocateHeap(GetProcessHeap(), pfCurFiber = (PFIBER)RtlAllocateHeap(GetProcessHeap(),
0, 0,
sizeof(FIBER)); sizeof(FIBER));
/* Failure */ /* Failure */
if(pfCurFiber == NULL) if (pfCurFiber == NULL)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return NULL; return NULL;
@ -227,7 +228,8 @@ DeleteFiber(LPVOID lpFiber)
RtlFreeHeap(GetProcessHeap(), 0, lpFiber); RtlFreeHeap(GetProcessHeap(), 0, lpFiber);
/* the fiber is deleting itself: let the system deallocate the stack */ /* the fiber is deleting itself: let the system deallocate the stack */
if(NtCurrentTeb()->Tib.FiberData == lpFiber) ExitThread(1); if (NtCurrentTeb()->Tib.FiberData == lpFiber)
ExitThread(1);
/* deallocate the stack */ /* deallocate the stack */
NtFreeVirtualMemory(NtCurrentProcess(), NtFreeVirtualMemory(NtCurrentProcess(),

View file

@ -18,7 +18,9 @@
/* /*
* @unimplemented * @unimplemented
*/ */
DWORD WINAPI FlsAlloc(PFLS_CALLBACK_FUNCTION lpCallback) DWORD
WINAPI
FlsAlloc(PFLS_CALLBACK_FUNCTION lpCallback)
{ {
(void)lpCallback; (void)lpCallback;
@ -31,7 +33,9 @@ DWORD WINAPI FlsAlloc(PFLS_CALLBACK_FUNCTION lpCallback)
/* /*
* @unimplemented * @unimplemented
*/ */
BOOL WINAPI FlsFree(DWORD dwFlsIndex) BOOL
WINAPI
FlsFree(DWORD dwFlsIndex)
{ {
(void)dwFlsIndex; (void)dwFlsIndex;
@ -44,16 +48,20 @@ BOOL WINAPI FlsFree(DWORD dwFlsIndex)
/* /*
* @implemented * @implemented
*/ */
PVOID WINAPI FlsGetValue(DWORD dwFlsIndex) PVOID
WINAPI
FlsGetValue(DWORD dwFlsIndex)
{ {
PVOID * ppFlsSlots; PVOID *ppFlsSlots;
PVOID pRetVal; PVOID pRetVal;
if(dwFlsIndex >= 128) goto l_InvalidParam; if (dwFlsIndex >= 128)
goto l_InvalidParam;
ppFlsSlots = NtCurrentTeb()->FlsData; ppFlsSlots = NtCurrentTeb()->FlsData;
if(ppFlsSlots == NULL) goto l_InvalidParam; if (ppFlsSlots == NULL)
goto l_InvalidParam;
SetLastError(0); SetLastError(0);
pRetVal = ppFlsSlots[dwFlsIndex + 2]; pRetVal = ppFlsSlots[dwFlsIndex + 2];
@ -69,27 +77,27 @@ l_InvalidParam:
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI FlsSetValue(DWORD dwFlsIndex, PVOID lpFlsData) BOOL
WINAPI
FlsSetValue(DWORD dwFlsIndex, PVOID lpFlsData)
{ {
PVOID * ppFlsSlots; PVOID *ppFlsSlots;
TEB * pTeb = NtCurrentTeb(); TEB *pTeb = NtCurrentTeb();
if(dwFlsIndex >= 128) goto l_InvalidParam; if (dwFlsIndex >= 128)
goto l_InvalidParam;
ppFlsSlots = pTeb->FlsData; ppFlsSlots = pTeb->FlsData;
if(ppFlsSlots == NULL) if (ppFlsSlots == NULL)
{ {
PEB * pPeb = pTeb->ProcessEnvironmentBlock; PEB *pPeb = pTeb->ProcessEnvironmentBlock;
ppFlsSlots = RtlAllocateHeap ppFlsSlots = RtlAllocateHeap(pPeb->ProcessHeap,
(
pPeb->ProcessHeap,
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
(128 + 2) * sizeof(PVOID) (128 + 2) * sizeof(PVOID));
); if (ppFlsSlots == NULL)
goto l_OutOfMemory;
if(ppFlsSlots == NULL) goto l_OutOfMemory;
pTeb->FlsData = ppFlsSlots; pTeb->FlsData = ppFlsSlots;