mirror of
https://github.com/reactos/reactos.git
synced 2024-08-30 23:28:58 +00:00
Fix indentation and coding style. No code changes.
svn path=/trunk/; revision=45018
This commit is contained in:
parent
ce0ab52c93
commit
1145a26d92
|
@ -27,80 +27,85 @@ static BOOL bCommandLineInitialized = FALSE;
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
static VOID
|
static
|
||||||
InitCommandLines (VOID)
|
VOID
|
||||||
|
InitCommandLines(VOID)
|
||||||
{
|
{
|
||||||
PRTL_USER_PROCESS_PARAMETERS Params;
|
PRTL_USER_PROCESS_PARAMETERS Params;
|
||||||
|
|
||||||
/* FIXME - not thread-safe! */
|
/* FIXME - not thread-safe! */
|
||||||
|
|
||||||
// get command line
|
// get command line
|
||||||
Params = NtCurrentPeb()->ProcessParameters;
|
Params = NtCurrentPeb()->ProcessParameters;
|
||||||
RtlNormalizeProcessParams (Params);
|
RtlNormalizeProcessParams (Params);
|
||||||
|
|
||||||
// initialize command line buffers
|
// initialize command line buffers
|
||||||
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)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
CommandLineStringA.Buffer[CommandLineStringA.Length] = 0;
|
CommandLineStringA.Buffer[CommandLineStringA.Length] = 0;
|
||||||
|
|
||||||
bCommandLineInitialized = TRUE;
|
bCommandLineInitialized = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @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 */
|
||||||
|
|
|
@ -27,31 +27,32 @@ WINAPI
|
||||||
CreateJobObjectA(LPSECURITY_ATTRIBUTES lpJobAttributes,
|
CreateJobObjectA(LPSECURITY_ATTRIBUTES lpJobAttributes,
|
||||||
LPCSTR lpName)
|
LPCSTR lpName)
|
||||||
{
|
{
|
||||||
HANDLE hJob;
|
HANDLE hJob;
|
||||||
ANSI_STRING AnsiName;
|
ANSI_STRING AnsiName;
|
||||||
UNICODE_STRING UnicodeName;
|
UNICODE_STRING UnicodeName;
|
||||||
|
|
||||||
if(lpName != NULL)
|
if (lpName != NULL)
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
RtlInitAnsiString(&AnsiName, lpName);
|
|
||||||
Status = RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE);
|
|
||||||
if(!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
NTSTATUS Status;
|
||||||
return FALSE;
|
|
||||||
|
RtlInitAnsiString(&AnsiName, lpName);
|
||||||
|
Status = RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,47 +64,48 @@ WINAPI
|
||||||
CreateJobObjectW(LPSECURITY_ATTRIBUTES lpJobAttributes,
|
CreateJobObjectW(LPSECURITY_ATTRIBUTES lpJobAttributes,
|
||||||
LPCWSTR lpName)
|
LPCWSTR lpName)
|
||||||
{
|
{
|
||||||
UNICODE_STRING JobName;
|
UNICODE_STRING JobName;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
ULONG Attributes = 0;
|
ULONG Attributes = 0;
|
||||||
PVOID SecurityDescriptor;
|
PVOID SecurityDescriptor;
|
||||||
HANDLE hJob;
|
HANDLE hJob;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
if(lpName != NULL)
|
if (lpName != NULL)
|
||||||
{
|
|
||||||
RtlInitUnicodeString(&JobName, lpName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lpJobAttributes != NULL)
|
|
||||||
{
|
|
||||||
if(lpJobAttributes->bInheritHandle)
|
|
||||||
{
|
{
|
||||||
Attributes |= OBJ_INHERIT;
|
RtlInitUnicodeString(&JobName, lpName);
|
||||||
}
|
}
|
||||||
SecurityDescriptor = lpJobAttributes->lpSecurityDescriptor;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SecurityDescriptor = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
if (lpJobAttributes != NULL)
|
||||||
((lpName != NULL) ? &JobName : NULL),
|
{
|
||||||
Attributes,
|
if (lpJobAttributes->bInheritHandle)
|
||||||
NULL,
|
{
|
||||||
SecurityDescriptor);
|
Attributes |= OBJ_INHERIT;
|
||||||
|
}
|
||||||
|
|
||||||
Status = NtCreateJobObject(&hJob,
|
SecurityDescriptor = lpJobAttributes->lpSecurityDescriptor;
|
||||||
JOB_OBJECT_ALL_ACCESS,
|
}
|
||||||
&ObjectAttributes);
|
else
|
||||||
if(!NT_SUCCESS(Status))
|
{
|
||||||
{
|
SecurityDescriptor = NULL;
|
||||||
SetLastErrorByStatus(Status);
|
}
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hJob;
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
((lpName != NULL) ? &JobName : NULL),
|
||||||
|
Attributes,
|
||||||
|
NULL,
|
||||||
|
SecurityDescriptor);
|
||||||
|
|
||||||
|
Status = NtCreateJobObject(&hJob,
|
||||||
|
JOB_OBJECT_ALL_ACCESS,
|
||||||
|
&ObjectAttributes);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,36 +118,35 @@ OpenJobObjectW(DWORD dwDesiredAccess,
|
||||||
BOOL bInheritHandle,
|
BOOL bInheritHandle,
|
||||||
LPCWSTR lpName)
|
LPCWSTR lpName)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
UNICODE_STRING JobName;
|
UNICODE_STRING JobName;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlInitUnicodeString(&JobName, lpName);
|
RtlInitUnicodeString(&JobName, lpName);
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&JobName,
|
&JobName,
|
||||||
(bInheritHandle ? OBJ_INHERIT : 0),
|
(bInheritHandle ? OBJ_INHERIT : 0),
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
Status = NtOpenJobObject(&hJob,
|
Status = NtOpenJobObject(&hJob,
|
||||||
dwDesiredAccess,
|
dwDesiredAccess,
|
||||||
&ObjectAttributes);
|
&ObjectAttributes);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if(!NT_SUCCESS(Status))
|
return hJob;
|
||||||
{
|
|
||||||
SetLastErrorByStatus(Status);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hJob;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,31 +159,31 @@ OpenJobObjectA(DWORD dwDesiredAccess,
|
||||||
BOOL bInheritHandle,
|
BOOL bInheritHandle,
|
||||||
LPCSTR lpName)
|
LPCSTR lpName)
|
||||||
{
|
{
|
||||||
ANSI_STRING AnsiName;
|
ANSI_STRING AnsiName;
|
||||||
UNICODE_STRING UnicodeName;
|
UNICODE_STRING UnicodeName;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
hJob = OpenJobObjectW(dwDesiredAccess,
|
hJob = OpenJobObjectW(dwDesiredAccess,
|
||||||
bInheritHandle,
|
bInheritHandle,
|
||||||
UnicodeName.Buffer);
|
UnicodeName.Buffer);
|
||||||
|
|
||||||
RtlFreeUnicodeString(&UnicodeName);
|
RtlFreeUnicodeString(&UnicodeName);
|
||||||
return hJob;
|
return hJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,17 +196,17 @@ IsProcessInJob(HANDLE ProcessHandle,
|
||||||
HANDLE JobHandle,
|
HANDLE JobHandle,
|
||||||
PBOOL Result)
|
PBOOL Result)
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -217,15 +218,16 @@ WINAPI
|
||||||
AssignProcessToJobObject(HANDLE hJob,
|
AssignProcessToJobObject(HANDLE hJob,
|
||||||
HANDLE hProcess)
|
HANDLE hProcess)
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -240,66 +242,74 @@ QueryInformationJobObject(HANDLE hJob,
|
||||||
DWORD cbJobObjectInformationLength,
|
DWORD cbJobObjectInformationLength,
|
||||||
LPDWORD lpReturnLength)
|
LPDWORD lpReturnLength)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
Status = NtQueryInformationJobObject(hJob,
|
Status = NtQueryInformationJobObject(hJob,
|
||||||
JobObjectInformationClass,
|
JobObjectInformationClass,
|
||||||
lpJobObjectInformation,
|
lpJobObjectInformation,
|
||||||
cbJobObjectInformationLength,
|
cbJobObjectInformationLength,
|
||||||
lpReturnLength);
|
lpReturnLength);
|
||||||
if(NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
|
||||||
PJOBOBJECT_BASIC_LIMIT_INFORMATION BasicInfo;
|
|
||||||
switch(JobObjectInformationClass)
|
|
||||||
{
|
{
|
||||||
case JobObjectBasicLimitInformation:
|
PJOBOBJECT_BASIC_LIMIT_INFORMATION BasicInfo;
|
||||||
BasicInfo = (PJOBOBJECT_BASIC_LIMIT_INFORMATION)lpJobObjectInformation;
|
|
||||||
break;
|
|
||||||
case JobObjectExtendedLimitInformation:
|
|
||||||
BasicInfo = &((PJOBOBJECT_EXTENDED_LIMIT_INFORMATION)lpJobObjectInformation)->BasicLimitInformation;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
switch (JobObjectInformationClass)
|
||||||
BasicInfo = NULL;
|
{
|
||||||
break;
|
case JobObjectBasicLimitInformation:
|
||||||
|
BasicInfo = (PJOBOBJECT_BASIC_LIMIT_INFORMATION)lpJobObjectInformation;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JobObjectExtendedLimitInformation:
|
||||||
|
BasicInfo = &((PJOBOBJECT_EXTENDED_LIMIT_INFORMATION)lpJobObjectInformation)->BasicLimitInformation;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
BasicInfo = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BasicInfo != NULL)
|
||||||
|
{
|
||||||
|
/* we need to convert the process priority classes in the
|
||||||
|
JOBOBJECT_BASIC_LIMIT_INFORMATION structure the same way as
|
||||||
|
GetPriorityClass() converts it! */
|
||||||
|
switch (BasicInfo->PriorityClass)
|
||||||
|
{
|
||||||
|
case PROCESS_PRIORITY_CLASS_IDLE:
|
||||||
|
BasicInfo->PriorityClass = IDLE_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROCESS_PRIORITY_CLASS_BELOW_NORMAL:
|
||||||
|
BasicInfo->PriorityClass = BELOW_NORMAL_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROCESS_PRIORITY_CLASS_NORMAL:
|
||||||
|
BasicInfo->PriorityClass = NORMAL_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROCESS_PRIORITY_CLASS_ABOVE_NORMAL:
|
||||||
|
BasicInfo->PriorityClass = ABOVE_NORMAL_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROCESS_PRIORITY_CLASS_HIGH:
|
||||||
|
BasicInfo->PriorityClass = HIGH_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROCESS_PRIORITY_CLASS_REALTIME:
|
||||||
|
BasicInfo->PriorityClass = REALTIME_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
BasicInfo->PriorityClass = NORMAL_PRIORITY_CLASS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(BasicInfo != NULL)
|
SetLastErrorByStatus(Status);
|
||||||
{
|
return FALSE;
|
||||||
/* we need to convert the process priority classes in the
|
|
||||||
JOBOBJECT_BASIC_LIMIT_INFORMATION structure the same way as
|
|
||||||
GetPriorityClass() converts it! */
|
|
||||||
switch(BasicInfo->PriorityClass)
|
|
||||||
{
|
|
||||||
case PROCESS_PRIORITY_CLASS_IDLE:
|
|
||||||
BasicInfo->PriorityClass = IDLE_PRIORITY_CLASS;
|
|
||||||
break;
|
|
||||||
case PROCESS_PRIORITY_CLASS_BELOW_NORMAL:
|
|
||||||
BasicInfo->PriorityClass = BELOW_NORMAL_PRIORITY_CLASS;
|
|
||||||
break;
|
|
||||||
case PROCESS_PRIORITY_CLASS_NORMAL:
|
|
||||||
BasicInfo->PriorityClass = NORMAL_PRIORITY_CLASS;
|
|
||||||
break;
|
|
||||||
case PROCESS_PRIORITY_CLASS_ABOVE_NORMAL:
|
|
||||||
BasicInfo->PriorityClass = ABOVE_NORMAL_PRIORITY_CLASS;
|
|
||||||
break;
|
|
||||||
case PROCESS_PRIORITY_CLASS_HIGH:
|
|
||||||
BasicInfo->PriorityClass = HIGH_PRIORITY_CLASS;
|
|
||||||
break;
|
|
||||||
case PROCESS_PRIORITY_CLASS_REALTIME:
|
|
||||||
BasicInfo->PriorityClass = REALTIME_PRIORITY_CLASS;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
BasicInfo->PriorityClass = NORMAL_PRIORITY_CLASS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetLastErrorByStatus(Status);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -313,83 +323,91 @@ SetInformationJobObject(HANDLE hJob,
|
||||||
LPVOID lpJobObjectInformation,
|
LPVOID lpJobObjectInformation,
|
||||||
DWORD cbJobObjectInformationLength)
|
DWORD cbJobObjectInformationLength)
|
||||||
{
|
{
|
||||||
JOBOBJECT_EXTENDED_LIMIT_INFORMATION ExtendedLimitInfo;
|
JOBOBJECT_EXTENDED_LIMIT_INFORMATION ExtendedLimitInfo;
|
||||||
PJOBOBJECT_BASIC_LIMIT_INFORMATION BasicInfo;
|
PJOBOBJECT_BASIC_LIMIT_INFORMATION BasicInfo;
|
||||||
PVOID ObjectInfo;
|
PVOID ObjectInfo;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
switch(JobObjectInformationClass)
|
switch (JobObjectInformationClass)
|
||||||
{
|
|
||||||
case JobObjectBasicLimitInformation:
|
|
||||||
if(cbJobObjectInformationLength != sizeof(JOBOBJECT_BASIC_LIMIT_INFORMATION))
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_BAD_LENGTH);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
ObjectInfo = &ExtendedLimitInfo.BasicLimitInformation;
|
|
||||||
BasicInfo = (PJOBOBJECT_BASIC_LIMIT_INFORMATION)ObjectInfo;
|
|
||||||
RtlCopyMemory(ObjectInfo, lpJobObjectInformation, cbJobObjectInformationLength);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case JobObjectExtendedLimitInformation:
|
|
||||||
if(cbJobObjectInformationLength != sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION))
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_BAD_LENGTH);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
ObjectInfo = &ExtendedLimitInfo;
|
|
||||||
BasicInfo = &ExtendedLimitInfo.BasicLimitInformation;
|
|
||||||
RtlCopyMemory(ObjectInfo, lpJobObjectInformation, cbJobObjectInformationLength);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
ObjectInfo = lpJobObjectInformation;
|
|
||||||
BasicInfo = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(BasicInfo != NULL)
|
|
||||||
{
|
|
||||||
/* we need to convert the process priority classes in the
|
|
||||||
JOBOBJECT_BASIC_LIMIT_INFORMATION structure the same way as
|
|
||||||
SetPriorityClass() converts it! */
|
|
||||||
switch(BasicInfo->PriorityClass)
|
|
||||||
{
|
{
|
||||||
case IDLE_PRIORITY_CLASS:
|
case JobObjectBasicLimitInformation:
|
||||||
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_IDLE;
|
if (cbJobObjectInformationLength != sizeof(JOBOBJECT_BASIC_LIMIT_INFORMATION))
|
||||||
break;
|
{
|
||||||
case BELOW_NORMAL_PRIORITY_CLASS:
|
SetLastError(ERROR_BAD_LENGTH);
|
||||||
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_BELOW_NORMAL;
|
return FALSE;
|
||||||
break;
|
}
|
||||||
case NORMAL_PRIORITY_CLASS:
|
|
||||||
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
|
ObjectInfo = &ExtendedLimitInfo.BasicLimitInformation;
|
||||||
break;
|
BasicInfo = (PJOBOBJECT_BASIC_LIMIT_INFORMATION)ObjectInfo;
|
||||||
case ABOVE_NORMAL_PRIORITY_CLASS:
|
RtlCopyMemory(ObjectInfo, lpJobObjectInformation, cbJobObjectInformationLength);
|
||||||
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_ABOVE_NORMAL;
|
break;
|
||||||
break;
|
|
||||||
case HIGH_PRIORITY_CLASS:
|
case JobObjectExtendedLimitInformation:
|
||||||
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_HIGH;
|
if (cbJobObjectInformationLength != sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION))
|
||||||
break;
|
{
|
||||||
case REALTIME_PRIORITY_CLASS:
|
SetLastError(ERROR_BAD_LENGTH);
|
||||||
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_REALTIME;
|
return FALSE;
|
||||||
break;
|
}
|
||||||
default:
|
|
||||||
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
|
ObjectInfo = &ExtendedLimitInfo;
|
||||||
break;
|
BasicInfo = &ExtendedLimitInfo.BasicLimitInformation;
|
||||||
|
RtlCopyMemory(ObjectInfo, lpJobObjectInformation, cbJobObjectInformationLength);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ObjectInfo = lpJobObjectInformation;
|
||||||
|
BasicInfo = NULL;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Status = NtSetInformationJobObject(hJob,
|
if (BasicInfo != NULL)
|
||||||
JobObjectInformationClass,
|
{
|
||||||
ObjectInfo,
|
/* we need to convert the process priority classes in the
|
||||||
cbJobObjectInformationLength);
|
JOBOBJECT_BASIC_LIMIT_INFORMATION structure the same way as
|
||||||
if(!NT_SUCCESS(Status))
|
SetPriorityClass() converts it! */
|
||||||
{
|
switch(BasicInfo->PriorityClass)
|
||||||
SetLastErrorByStatus(Status);
|
{
|
||||||
return FALSE;
|
case IDLE_PRIORITY_CLASS:
|
||||||
}
|
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_IDLE;
|
||||||
|
break;
|
||||||
|
|
||||||
return TRUE;
|
case BELOW_NORMAL_PRIORITY_CLASS:
|
||||||
|
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_BELOW_NORMAL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NORMAL_PRIORITY_CLASS:
|
||||||
|
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ABOVE_NORMAL_PRIORITY_CLASS:
|
||||||
|
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_ABOVE_NORMAL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HIGH_PRIORITY_CLASS:
|
||||||
|
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_HIGH;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case REALTIME_PRIORITY_CLASS:
|
||||||
|
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_REALTIME;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
BasicInfo->PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = NtSetInformationJobObject(hJob,
|
||||||
|
JobObjectInformationClass,
|
||||||
|
ObjectInfo,
|
||||||
|
cbJobObjectInformationLength);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -401,17 +419,16 @@ WINAPI
|
||||||
TerminateJobObject(HANDLE hJob,
|
TerminateJobObject(HANDLE hJob,
|
||||||
UINT uExitCode)
|
UINT uExitCode)
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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;
|
||||||
|
|
|
@ -19,11 +19,14 @@ 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,68 +42,74 @@ 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;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @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;
|
||||||
CLIENT_ID ClientId;
|
CLIENT_ID ClientId;
|
||||||
HANDLE ProcessHandle;
|
HANDLE ProcessHandle;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
if(IsBadWritePtr(pSessionId, sizeof(DWORD)))
|
if (IsBadWritePtr(pSessionId, sizeof(DWORD)))
|
||||||
{
|
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientId.UniqueProcess = (HANDLE)dwProcessId;
|
|
||||||
ClientId.UniqueThread = 0;
|
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
|
|
||||||
|
|
||||||
Status = NtOpenProcess(&ProcessHandle,
|
|
||||||
PROCESS_QUERY_INFORMATION,
|
|
||||||
&ObjectAttributes,
|
|
||||||
&ClientId);
|
|
||||||
if(NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
Status = NtQueryInformationProcess(ProcessHandle,
|
|
||||||
ProcessSessionInformation,
|
|
||||||
&SessionInformation,
|
|
||||||
sizeof(SessionInformation),
|
|
||||||
NULL);
|
|
||||||
NtClose(ProcessHandle);
|
|
||||||
|
|
||||||
if(NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
*pSessionId = SessionInformation.SessionId;
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return TRUE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SetLastErrorByStatus(Status);
|
ClientId.UniqueProcess = (HANDLE)dwProcessId;
|
||||||
return FALSE;
|
ClientId.UniqueThread = 0;
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
|
||||||
|
|
||||||
|
Status = NtOpenProcess(&ProcessHandle,
|
||||||
|
PROCESS_QUERY_INFORMATION,
|
||||||
|
&ObjectAttributes,
|
||||||
|
&ClientId);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Status = NtQueryInformationProcess(ProcessHandle,
|
||||||
|
ProcessSessionInformation,
|
||||||
|
&SessionInformation,
|
||||||
|
sizeof(SessionInformation),
|
||||||
|
NULL);
|
||||||
|
NtClose(ProcessHandle);
|
||||||
|
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
*pSessionId = SessionInformation.SessionId;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
DWORD WINAPI
|
DWORD
|
||||||
WTSGetActiveConsoleSessionId (VOID)
|
WINAPI
|
||||||
|
WTSGetActiveConsoleSessionId(VOID)
|
||||||
{
|
{
|
||||||
return ActiveConsoleSessionId;
|
return ActiveConsoleSessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -26,8 +26,9 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -72,10 +72,10 @@ CreateEventExW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL,
|
||||||
/* Now check if we got a name */
|
/* Now check if we got a name */
|
||||||
if (lpName) RtlInitUnicodeString(&ObjectName, lpName);
|
if (lpName) RtlInitUnicodeString(&ObjectName, lpName);
|
||||||
|
|
||||||
/* Check for invalid flags */
|
/* Check for invalid flags */
|
||||||
if (dwFlags & ~(CREATE_EVENT_INITIAL_SET | CREATE_EVENT_MANUAL_RESET))
|
if (dwFlags & ~(CREATE_EVENT_INITIAL_SET | CREATE_EVENT_MANUAL_RESET))
|
||||||
{
|
{
|
||||||
/* Fail */
|
/* Fail */
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -36,9 +36,9 @@ WaitForSingleObjectEx(IN HANDLE hHandle,
|
||||||
IN DWORD dwMilliseconds,
|
IN DWORD dwMilliseconds,
|
||||||
IN BOOL bAlertable)
|
IN BOOL bAlertable)
|
||||||
{
|
{
|
||||||
PLARGE_INTEGER TimePtr;
|
PLARGE_INTEGER TimePtr;
|
||||||
LARGE_INTEGER Time;
|
LARGE_INTEGER Time;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
/* Get real handle */
|
/* Get real handle */
|
||||||
hHandle = TranslateStdHandle(hHandle);
|
hHandle = TranslateStdHandle(hHandle);
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -93,7 +94,7 @@ ConvertThreadToFiberEx(LPVOID lpParameter,
|
||||||
pfCurFiber->GuaranteedStackBytes = pTeb->GuaranteedStackBytes;
|
pfCurFiber->GuaranteedStackBytes = pTeb->GuaranteedStackBytes;
|
||||||
pfCurFiber->ActivationContextStack = pTeb->ActivationContextStackPointer;
|
pfCurFiber->ActivationContextStack = pTeb->ActivationContextStackPointer;
|
||||||
pfCurFiber->Context.ContextFlags = CONTEXT_FULL;
|
pfCurFiber->Context.ContextFlags = CONTEXT_FULL;
|
||||||
|
|
||||||
/* Save FPU State if requsted */
|
/* Save FPU State if requsted */
|
||||||
if (dwFlags & FIBER_FLAG_FLOAT_SWITCH)
|
if (dwFlags & FIBER_FLAG_FLOAT_SWITCH)
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
|
@ -181,10 +182,10 @@ CreateFiberEx(SIZE_T dwStackCommitSize,
|
||||||
SetLastErrorByStatus(nErrCode);
|
SetLastErrorByStatus(nErrCode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the context */
|
/* Clear the context */
|
||||||
RtlZeroMemory(&pfCurFiber->Context, sizeof(CONTEXT));
|
RtlZeroMemory(&pfCurFiber->Context, sizeof(CONTEXT));
|
||||||
|
|
||||||
/* copy the data into the fiber */
|
/* copy the data into the fiber */
|
||||||
pfCurFiber->StackBase = usFiberInitialTeb.StackBase;
|
pfCurFiber->StackBase = usFiberInitialTeb.StackBase;
|
||||||
pfCurFiber->StackLimit = usFiberInitialTeb.StackLimit;
|
pfCurFiber->StackLimit = usFiberInitialTeb.StackLimit;
|
||||||
|
@ -195,20 +196,20 @@ CreateFiberEx(SIZE_T dwStackCommitSize,
|
||||||
pfCurFiber->FlsData = NULL;
|
pfCurFiber->FlsData = NULL;
|
||||||
pfCurFiber->ActivationContextStack = ActivationContextStack;
|
pfCurFiber->ActivationContextStack = ActivationContextStack;
|
||||||
pfCurFiber->Context.ContextFlags = CONTEXT_FULL;
|
pfCurFiber->Context.ContextFlags = CONTEXT_FULL;
|
||||||
|
|
||||||
/* Save FPU State if requsted */
|
/* Save FPU State if requsted */
|
||||||
if (dwFlags & FIBER_FLAG_FLOAT_SWITCH)
|
if (dwFlags & FIBER_FLAG_FLOAT_SWITCH)
|
||||||
{
|
{
|
||||||
pfCurFiber->Context.ContextFlags |= CONTEXT_FLOATING_POINT;
|
pfCurFiber->Context.ContextFlags |= CONTEXT_FLOATING_POINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize the context for the fiber */
|
/* initialize the context for the fiber */
|
||||||
BasepInitializeContext(&ctxFiberContext,
|
BasepInitializeContext(&ctxFiberContext,
|
||||||
lpParameter,
|
lpParameter,
|
||||||
lpStartAddress,
|
lpStartAddress,
|
||||||
usFiberInitialTeb.StackBase,
|
usFiberInitialTeb.StackBase,
|
||||||
2);
|
2);
|
||||||
|
|
||||||
/* Return the Fiber */
|
/* Return the Fiber */
|
||||||
return pfCurFiber;
|
return pfCurFiber;
|
||||||
}
|
}
|
||||||
|
@ -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(),
|
||||||
|
|
|
@ -18,101 +18,109 @@
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
DWORD WINAPI FlsAlloc(PFLS_CALLBACK_FUNCTION lpCallback)
|
DWORD
|
||||||
|
WINAPI
|
||||||
|
FlsAlloc(PFLS_CALLBACK_FUNCTION lpCallback)
|
||||||
{
|
{
|
||||||
(void)lpCallback;
|
(void)lpCallback;
|
||||||
|
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FLS_OUT_OF_INDEXES;
|
return FLS_OUT_OF_INDEXES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI FlsFree(DWORD dwFlsIndex)
|
BOOL
|
||||||
|
WINAPI
|
||||||
|
FlsFree(DWORD dwFlsIndex)
|
||||||
{
|
{
|
||||||
(void)dwFlsIndex;
|
(void)dwFlsIndex;
|
||||||
|
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @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];
|
||||||
|
|
||||||
return pRetVal;
|
return pRetVal;
|
||||||
|
|
||||||
l_InvalidParam:
|
l_InvalidParam:
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @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,
|
||||||
(
|
HEAP_ZERO_MEMORY,
|
||||||
pPeb->ProcessHeap,
|
(128 + 2) * sizeof(PVOID));
|
||||||
HEAP_ZERO_MEMORY,
|
if (ppFlsSlots == NULL)
|
||||||
(128 + 2) * sizeof(PVOID)
|
goto l_OutOfMemory;
|
||||||
);
|
|
||||||
|
|
||||||
if(ppFlsSlots == NULL) goto l_OutOfMemory;
|
pTeb->FlsData = ppFlsSlots;
|
||||||
|
|
||||||
pTeb->FlsData = ppFlsSlots;
|
RtlAcquirePebLock();
|
||||||
|
|
||||||
RtlAcquirePebLock();
|
/* TODO: initialization */
|
||||||
|
|
||||||
/* TODO: initialization */
|
RtlReleasePebLock();
|
||||||
|
}
|
||||||
|
|
||||||
RtlReleasePebLock();
|
ppFlsSlots[dwFlsIndex + 2] = lpFlsData;
|
||||||
}
|
|
||||||
|
|
||||||
ppFlsSlots[dwFlsIndex + 2] = lpFlsData;
|
return TRUE;
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
l_OutOfMemory:
|
l_OutOfMemory:
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
goto l_Fail;
|
goto l_Fail;
|
||||||
|
|
||||||
l_InvalidParam:
|
l_InvalidParam:
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
|
||||||
l_Fail:
|
l_Fail:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -82,7 +82,7 @@ WINAPI
|
||||||
TlsFree(DWORD Index)
|
TlsFree(DWORD Index)
|
||||||
{
|
{
|
||||||
BOOL BitSet;
|
BOOL BitSet;
|
||||||
|
|
||||||
if (Index >= TLS_EXPANSION_SLOTS + TLS_MINIMUM_AVAILABLE)
|
if (Index >= TLS_EXPANSION_SLOTS + TLS_MINIMUM_AVAILABLE)
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
|
SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
|
||||||
|
|
Loading…
Reference in a new issue