mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
[KERNEL32]: Rearrange and rename some base functions.
[KERNEL32]: Fix some error cases in the helper string functions. [KERNEL32]: Implement BasepIsRealtimeAllowed. [KERNEL32]: Don't need RPL_MASK when setting up the CONTEXT, this now matches what Windows sets up (and also helps us validate the kernel is doing the right thing). svn path=/trunk/; revision=54284
This commit is contained in:
parent
b63701a2c9
commit
e5f31ab0a9
10 changed files with 205 additions and 177 deletions
|
@ -62,60 +62,6 @@ BOOLEAN InWindows = FALSE;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
WINAPI
|
|
||||||
BaseGetNamedObjectDirectory(VOID)
|
|
||||||
{
|
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
|
||||||
&BaseStaticServerData->NamedObjectDirectory,
|
|
||||||
OBJ_CASE_INSENSITIVE,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
Status = NtOpenDirectoryObject(&BaseNamedObjectDirectory,
|
|
||||||
DIRECTORY_ALL_ACCESS &
|
|
||||||
~(DELETE | WRITE_DAC | WRITE_OWNER),
|
|
||||||
&ObjectAttributes);
|
|
||||||
if (!NT_SUCCESS(Status)) return Status;
|
|
||||||
|
|
||||||
DPRINT("Opened BNO: %lx\n", BaseNamedObjectDirectory);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @unimplemented
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
WINAPI
|
|
||||||
BaseQueryModuleData(IN LPSTR ModuleName,
|
|
||||||
IN LPSTR Unknown,
|
|
||||||
IN PVOID Unknown2,
|
|
||||||
IN PVOID Unknown3,
|
|
||||||
IN PVOID Unknown4)
|
|
||||||
{
|
|
||||||
DPRINT1("BaseQueryModuleData called: %s %s %x %x %x\n",
|
|
||||||
ModuleName,
|
|
||||||
Unknown,
|
|
||||||
Unknown2,
|
|
||||||
Unknown3,
|
|
||||||
Unknown4);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @unimplemented
|
|
||||||
*/
|
|
||||||
NTSTATUS
|
|
||||||
WINAPI
|
|
||||||
BaseProcessInitPostImport(VOID)
|
|
||||||
{
|
|
||||||
/* FIXME: Initialize TS pointers */
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
WINAPI
|
WINAPI
|
||||||
BasepInitConsole(VOID)
|
BasepInitConsole(VOID)
|
||||||
|
@ -388,9 +334,6 @@ DllMain(HANDLE hDll,
|
||||||
RtlDeleteCriticalSection (&ConsoleLock);
|
RtlDeleteCriticalSection (&ConsoleLock);
|
||||||
}
|
}
|
||||||
RtlDeleteCriticalSection (&BaseDllDirectoryLock);
|
RtlDeleteCriticalSection (&BaseDllDirectoryLock);
|
||||||
|
|
||||||
/* Close object base directory */
|
|
||||||
NtClose(hBaseDir);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ GetEnvironmentVariableA(IN LPCSTR lpName,
|
||||||
Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, UniSize * sizeof(WCHAR));
|
Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, UniSize * sizeof(WCHAR));
|
||||||
if (!Buffer)
|
if (!Buffer)
|
||||||
{
|
{
|
||||||
Status = STATUS_NO_MEMORY;;
|
Status = STATUS_NO_MEMORY;
|
||||||
goto Quickie;
|
goto Quickie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,11 +237,11 @@ CreateFiberEx(SIZE_T dwStackCommitSize,
|
||||||
Fiber->Context.ContextFlags = (dwFlags & FIBER_FLAG_FLOAT_SWITCH) ? CONTEXT_FLOATING_POINT : 0;
|
Fiber->Context.ContextFlags = (dwFlags & FIBER_FLAG_FLOAT_SWITCH) ? CONTEXT_FLOATING_POINT : 0;
|
||||||
|
|
||||||
/* initialize the context for the fiber */
|
/* initialize the context for the fiber */
|
||||||
BasepInitializeContext(&Fiber->Context,
|
BaseInitializeContext(&Fiber->Context,
|
||||||
lpParameter,
|
lpParameter,
|
||||||
lpStartAddress,
|
lpStartAddress,
|
||||||
InitialTeb.StackBase,
|
InitialTeb.StackBase,
|
||||||
2);
|
2);
|
||||||
|
|
||||||
/* Return the Fiber */
|
/* Return the Fiber */
|
||||||
return Fiber;
|
return Fiber;
|
||||||
|
|
|
@ -80,7 +80,7 @@ CreateFileMappingW(HANDLE hFile,
|
||||||
if (lpName) RtlInitUnicodeString(&SectionName, lpName);
|
if (lpName) RtlInitUnicodeString(&SectionName, lpName);
|
||||||
|
|
||||||
/* Now convert the object attributes */
|
/* Now convert the object attributes */
|
||||||
ObjectAttributes = BasepConvertObjectAttributes(&LocalAttributes,
|
ObjectAttributes = BaseFormatObjectAttributes(&LocalAttributes,
|
||||||
lpFileMappingAttributes,
|
lpFileMappingAttributes,
|
||||||
lpName ? &SectionName : NULL);
|
lpName ? &SectionName : NULL);
|
||||||
|
|
||||||
|
@ -244,6 +244,7 @@ UnmapViewOfFile(LPCVOID lpBaseAddress)
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
/* FIXME: Convert to the new macros */
|
||||||
HANDLE
|
HANDLE
|
||||||
NTAPI
|
NTAPI
|
||||||
OpenFileMappingA(DWORD dwDesiredAccess,
|
OpenFileMappingA(DWORD dwDesiredAccess,
|
||||||
|
@ -286,6 +287,7 @@ OpenFileMappingA(DWORD dwDesiredAccess,
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
/* FIXME: Convert to the new macros */
|
||||||
HANDLE
|
HANDLE
|
||||||
NTAPI
|
NTAPI
|
||||||
OpenFileMappingW(DWORD dwDesiredAccess,
|
OpenFileMappingW(DWORD dwDesiredAccess,
|
||||||
|
|
|
@ -1175,4 +1175,35 @@ VOID WINAPI UTUnRegister( HMODULE hModule )
|
||||||
STUB;
|
STUB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @unimplemented
|
||||||
|
*/
|
||||||
|
BOOL
|
||||||
|
WINAPI
|
||||||
|
BaseQueryModuleData(IN LPSTR ModuleName,
|
||||||
|
IN LPSTR Unknown,
|
||||||
|
IN PVOID Unknown2,
|
||||||
|
IN PVOID Unknown3,
|
||||||
|
IN PVOID Unknown4)
|
||||||
|
{
|
||||||
|
DPRINT1("BaseQueryModuleData called: %s %s %x %x %x\n",
|
||||||
|
ModuleName,
|
||||||
|
Unknown,
|
||||||
|
Unknown2,
|
||||||
|
Unknown3,
|
||||||
|
Unknown4);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @unimplemented
|
||||||
|
*/
|
||||||
|
NTSTATUS
|
||||||
|
WINAPI
|
||||||
|
BaseProcessInitPostImport(VOID)
|
||||||
|
{
|
||||||
|
/* FIXME: Initialize TS pointers */
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -193,14 +193,14 @@ BasepCreateFirstThread(HANDLE ProcessHandle,
|
||||||
&InitialTeb);
|
&InitialTeb);
|
||||||
|
|
||||||
/* Create the Thread's Context */
|
/* Create the Thread's Context */
|
||||||
BasepInitializeContext(&Context,
|
BaseInitializeContext(&Context,
|
||||||
NtCurrentPeb(),
|
NtCurrentPeb(),
|
||||||
SectionImageInfo->TransferAddress,
|
SectionImageInfo->TransferAddress,
|
||||||
InitialTeb.StackBase,
|
InitialTeb.StackBase,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
/* Convert the thread attributes */
|
/* Convert the thread attributes */
|
||||||
ObjectAttributes = BasepConvertObjectAttributes(&LocalObjectAttributes,
|
ObjectAttributes = BaseFormatObjectAttributes(&LocalObjectAttributes,
|
||||||
lpThreadAttributes,
|
lpThreadAttributes,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ BasepConvertPriorityClass(IN ULONG dwCreationFlags)
|
||||||
else if(dwCreationFlags & REALTIME_PRIORITY_CLASS)
|
else if(dwCreationFlags & REALTIME_PRIORITY_CLASS)
|
||||||
{
|
{
|
||||||
/* Check for Privilege First */
|
/* Check for Privilege First */
|
||||||
if (BasepCheckRealTimePrivilege())
|
if (BasepIsRealtimeAllowed(TRUE))
|
||||||
{
|
{
|
||||||
ReturnClass = PROCESS_PRIORITY_CLASS_REALTIME;
|
ReturnClass = PROCESS_PRIORITY_CLASS_REALTIME;
|
||||||
}
|
}
|
||||||
|
@ -2654,7 +2654,7 @@ GetAppName:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the process object attributes */
|
/* Initialize the process object attributes */
|
||||||
ObjectAttributes = BasepConvertObjectAttributes(&LocalObjectAttributes,
|
ObjectAttributes = BaseFormatObjectAttributes(&LocalObjectAttributes,
|
||||||
lpProcessAttributes,
|
lpProcessAttributes,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|
|
@ -149,14 +149,14 @@ CreateRemoteThread(HANDLE hProcess,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create Initial Context */
|
/* Create Initial Context */
|
||||||
BasepInitializeContext(&Context,
|
BaseInitializeContext(&Context,
|
||||||
lpParameter,
|
lpParameter,
|
||||||
lpStartAddress,
|
lpStartAddress,
|
||||||
InitialTeb.StackBase,
|
InitialTeb.StackBase,
|
||||||
1);
|
1);
|
||||||
|
|
||||||
/* initialize the attributes for the thread object */
|
/* initialize the attributes for the thread object */
|
||||||
ObjectAttributes = BasepConvertObjectAttributes(&LocalObjectAttributes,
|
ObjectAttributes = BaseFormatObjectAttributes(&LocalObjectAttributes,
|
||||||
lpThreadAttributes,
|
lpThreadAttributes,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ CreateRemoteThread(HANDLE hProcess,
|
||||||
TRUE);
|
TRUE);
|
||||||
if(!NT_SUCCESS(Status))
|
if(!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
BasepFreeStack(hProcess, &InitialTeb);
|
BaseFreeThreadStack(hProcess, &InitialTeb);
|
||||||
BaseSetLastNTError(Status);
|
BaseSetLastNTError(Status);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* Pierre Schweitzer (pierre.schweitzer@reactos.org)
|
* Pierre Schweitzer (pierre.schweitzer@reactos.org)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ****************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
#include <k32.h>
|
#include <k32.h>
|
||||||
#ifdef _M_IX86
|
#ifdef _M_IX86
|
||||||
|
@ -19,11 +19,34 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
/* GLOBALS ********************************************************************/
|
||||||
|
|
||||||
PRTL_CONVERT_STRING Basep8BitStringToUnicodeString;
|
PRTL_CONVERT_STRING Basep8BitStringToUnicodeString;
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
WINAPI
|
||||||
|
BaseGetNamedObjectDirectory(VOID)
|
||||||
|
{
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&BaseStaticServerData->NamedObjectDirectory,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
Status = NtOpenDirectoryObject(&BaseNamedObjectDirectory,
|
||||||
|
DIRECTORY_ALL_ACCESS &
|
||||||
|
~(DELETE | WRITE_DAC | WRITE_OWNER),
|
||||||
|
&ObjectAttributes);
|
||||||
|
if (!NT_SUCCESS(Status)) return Status;
|
||||||
|
|
||||||
|
DPRINT("Opened BNO: %lx\n", BaseNamedObjectDirectory);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
|
@ -66,21 +89,29 @@ Basep8BitStringToStaticUnicodeString(IN LPCSTR String)
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
/* Initialize an ANSI String */
|
/* Initialize an ANSI String */
|
||||||
if (!NT_SUCCESS(RtlInitAnsiStringEx(&AnsiString, String)))
|
Status = RtlInitAnsiStringEx(&AnsiString, String);
|
||||||
{
|
|
||||||
SetLastError(ERROR_FILENAME_EXCED_RANGE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Convert it */
|
|
||||||
Status = Basep8BitStringToUnicodeString(StaticString, &AnsiString, FALSE);
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
BaseSetLastNTError(Status);
|
Status = STATUS_BUFFER_OVERFLOW;
|
||||||
return NULL;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Convert it */
|
||||||
|
Status = Basep8BitStringToUnicodeString(StaticString, &AnsiString, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return StaticString;
|
if (NT_SUCCESS(Status)) return StaticString;
|
||||||
|
|
||||||
|
if (Status == STATUS_BUFFER_OVERFLOW)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_FILENAME_EXCED_RANGE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -94,32 +125,36 @@ Basep8BitStringToDynamicUnicodeString(OUT PUNICODE_STRING UnicodeString,
|
||||||
ANSI_STRING AnsiString;
|
ANSI_STRING AnsiString;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("Basep8BitStringToDynamicUnicodeString\n");
|
|
||||||
|
|
||||||
/* Initialize an ANSI String */
|
/* Initialize an ANSI String */
|
||||||
if (!NT_SUCCESS(RtlInitAnsiStringEx(&AnsiString, String)))
|
Status = RtlInitAnsiStringEx(&AnsiString, String);
|
||||||
{
|
|
||||||
SetLastError(ERROR_BUFFER_OVERFLOW);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Convert it */
|
|
||||||
Status = Basep8BitStringToUnicodeString(UnicodeString, &AnsiString, TRUE);
|
|
||||||
|
|
||||||
/* Handle failure */
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
BaseSetLastNTError(Status);
|
Status = STATUS_BUFFER_OVERFLOW;
|
||||||
return FALSE;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Convert it */
|
||||||
|
Status = Basep8BitStringToUnicodeString(UnicodeString, &AnsiString, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return Status */
|
if (NT_SUCCESS(Status)) return TRUE;
|
||||||
return TRUE;
|
|
||||||
|
if (Status == STATUS_BUFFER_OVERFLOW)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_FILENAME_EXCED_RANGE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocates space from the Heap and converts an Ansi String into it
|
* Allocates space from the Heap and converts an Ansi String into it
|
||||||
*/
|
*/
|
||||||
|
/*NOTE: API IS A HACK */
|
||||||
VOID
|
VOID
|
||||||
WINAPI
|
WINAPI
|
||||||
BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString,
|
BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString,
|
||||||
|
@ -163,16 +198,14 @@ BaseFormatTimeOut(OUT PLARGE_INTEGER Timeout,
|
||||||
*/
|
*/
|
||||||
POBJECT_ATTRIBUTES
|
POBJECT_ATTRIBUTES
|
||||||
WINAPI
|
WINAPI
|
||||||
BasepConvertObjectAttributes(OUT POBJECT_ATTRIBUTES ObjectAttributes,
|
BaseFormatObjectAttributes(OUT POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
IN PSECURITY_ATTRIBUTES SecurityAttributes OPTIONAL,
|
IN PSECURITY_ATTRIBUTES SecurityAttributes OPTIONAL,
|
||||||
IN PUNICODE_STRING ObjectName)
|
IN PUNICODE_STRING ObjectName)
|
||||||
{
|
{
|
||||||
ULONG Attributes = 0;
|
ULONG Attributes;
|
||||||
HANDLE RootDirectory = 0;
|
HANDLE RootDirectory;
|
||||||
PVOID SecurityDescriptor = NULL;
|
PVOID SecurityDescriptor;
|
||||||
BOOLEAN NeedOba = FALSE;
|
DPRINT("BaseFormatObjectAttributes. Security: %p, Name: %p\n",
|
||||||
|
|
||||||
DPRINT("BasepConvertObjectAttributes. Security: %p, Name: %p\n",
|
|
||||||
SecurityAttributes, ObjectName);
|
SecurityAttributes, ObjectName);
|
||||||
|
|
||||||
/* Get the attributes if present */
|
/* Get the attributes if present */
|
||||||
|
@ -180,32 +213,33 @@ BasepConvertObjectAttributes(OUT POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
{
|
{
|
||||||
Attributes = SecurityAttributes->bInheritHandle ? OBJ_INHERIT : 0;
|
Attributes = SecurityAttributes->bInheritHandle ? OBJ_INHERIT : 0;
|
||||||
SecurityDescriptor = SecurityAttributes->lpSecurityDescriptor;
|
SecurityDescriptor = SecurityAttributes->lpSecurityDescriptor;
|
||||||
NeedOba = TRUE;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!ObjectName) return NULL;
|
||||||
|
Attributes = 0;
|
||||||
|
SecurityDescriptor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjectName)
|
if (ObjectName)
|
||||||
{
|
{
|
||||||
Attributes |= OBJ_OPENIF;
|
Attributes |= OBJ_OPENIF;
|
||||||
RootDirectory = hBaseDir;
|
RootDirectory = hBaseDir;
|
||||||
NeedOba = TRUE;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
DPRINT("Attributes: %lx, RootDirectory: %lx, SecurityDescriptor: %p\n",
|
{
|
||||||
Attributes, RootDirectory, SecurityDescriptor);
|
RootDirectory = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create the Object Attributes */
|
/* Create the Object Attributes */
|
||||||
if (NeedOba)
|
InitializeObjectAttributes(ObjectAttributes,
|
||||||
{
|
ObjectName,
|
||||||
InitializeObjectAttributes(ObjectAttributes,
|
Attributes,
|
||||||
ObjectName,
|
RootDirectory,
|
||||||
Attributes,
|
SecurityDescriptor);
|
||||||
RootDirectory,
|
DPRINT("Attributes: %lx, RootDirectory: %lx, SecurityDescriptor: %p\n",
|
||||||
SecurityDescriptor);
|
Attributes, RootDirectory, SecurityDescriptor);
|
||||||
return ObjectAttributes;
|
return ObjectAttributes;
|
||||||
}
|
|
||||||
|
|
||||||
/* Nothing to return */
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -340,8 +374,8 @@ BasepCreateStack(HANDLE hProcess,
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
WINAPI
|
WINAPI
|
||||||
BasepFreeStack(HANDLE hProcess,
|
BaseFreeThreadStack(IN HANDLE hProcess,
|
||||||
PINITIAL_TEB InitialTeb)
|
IN PINITIAL_TEB InitialTeb)
|
||||||
{
|
{
|
||||||
SIZE_T Dummy = 0;
|
SIZE_T Dummy = 0;
|
||||||
|
|
||||||
|
@ -357,7 +391,7 @@ BasepFreeStack(HANDLE hProcess,
|
||||||
*/
|
*/
|
||||||
VOID
|
VOID
|
||||||
WINAPI
|
WINAPI
|
||||||
BasepInitializeContext(IN PCONTEXT Context,
|
BaseInitializeContext(IN PCONTEXT Context,
|
||||||
IN PVOID Parameter,
|
IN PVOID Parameter,
|
||||||
IN PVOID StartAddress,
|
IN PVOID StartAddress,
|
||||||
IN PVOID StackAddress,
|
IN PVOID StackAddress,
|
||||||
|
@ -365,7 +399,7 @@ BasepInitializeContext(IN PCONTEXT Context,
|
||||||
{
|
{
|
||||||
#ifdef _M_IX86
|
#ifdef _M_IX86
|
||||||
ULONG ContextFlags;
|
ULONG ContextFlags;
|
||||||
DPRINT("BasepInitializeContext: %p\n", Context);
|
DPRINT("BaseInitializeContext: %p\n", Context);
|
||||||
|
|
||||||
/* Setup the Initial Win32 Thread Context */
|
/* Setup the Initial Win32 Thread Context */
|
||||||
Context->Eax = (ULONG)StartAddress;
|
Context->Eax = (ULONG)StartAddress;
|
||||||
|
@ -374,11 +408,11 @@ BasepInitializeContext(IN PCONTEXT Context,
|
||||||
/* The other registers are undefined */
|
/* The other registers are undefined */
|
||||||
|
|
||||||
/* Setup the Segments */
|
/* Setup the Segments */
|
||||||
Context->SegFs = KGDT_R3_TEB | RPL_MASK;
|
Context->SegFs = KGDT_R3_TEB;
|
||||||
Context->SegEs = KGDT_R3_DATA | RPL_MASK;
|
Context->SegEs = KGDT_R3_DATA;
|
||||||
Context->SegDs = KGDT_R3_DATA | RPL_MASK;
|
Context->SegDs = KGDT_R3_DATA;
|
||||||
Context->SegCs = KGDT_R3_CODE | RPL_MASK;
|
Context->SegCs = KGDT_R3_CODE;
|
||||||
Context->SegSs = KGDT_R3_DATA | RPL_MASK;
|
Context->SegSs = KGDT_R3_DATA;
|
||||||
Context->SegGs = 0;
|
Context->SegGs = 0;
|
||||||
|
|
||||||
/* Set the Context Flags */
|
/* Set the Context Flags */
|
||||||
|
@ -426,7 +460,7 @@ BasepInitializeContext(IN PCONTEXT Context,
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(_M_AMD64)
|
#elif defined(_M_AMD64)
|
||||||
DPRINT("BasepInitializeContext: %p\n", Context);
|
DPRINT("BaseInitializeContext: %p\n", Context);
|
||||||
|
|
||||||
/* Setup the Initial Win32 Thread Context */
|
/* Setup the Initial Win32 Thread Context */
|
||||||
Context->Rax = (ULONG_PTR)StartAddress;
|
Context->Rax = (ULONG_PTR)StartAddress;
|
||||||
|
@ -473,11 +507,24 @@ BasepInitializeContext(IN PCONTEXT Context,
|
||||||
/*
|
/*
|
||||||
* Checks if the privilege for Real-Time Priority is there
|
* Checks if the privilege for Real-Time Priority is there
|
||||||
*/
|
*/
|
||||||
BOOLEAN
|
PVOID
|
||||||
WINAPI
|
WINAPI
|
||||||
BasepCheckRealTimePrivilege(VOID)
|
BasepIsRealtimeAllowed(IN BOOLEAN Keep)
|
||||||
{
|
{
|
||||||
return TRUE;
|
ULONG Privilege = SE_INC_BASE_PRIORITY_PRIVILEGE;
|
||||||
|
PVOID State;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = RtlAcquirePrivilege(&Privilege, TRUE, FALSE, &State);
|
||||||
|
if (!NT_SUCCESS(Status)) return NULL;
|
||||||
|
|
||||||
|
if (Keep)
|
||||||
|
{
|
||||||
|
RtlReleasePrivilege(State);
|
||||||
|
State = (PVOID)TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return State;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
// wraps the usual code path required to create an NT object based on a Unicode
|
// wraps the usual code path required to create an NT object based on a Unicode
|
||||||
// (Wide) Win32 object creation API.
|
// (Wide) Win32 object creation API.
|
||||||
//
|
//
|
||||||
// It makes use of BasepConvertObjectAttributes and allows for a custom access
|
// It makes use of BaseFormatObjectAttributes and allows for a custom access
|
||||||
// mode to be used, and also sets the correct error codes in case of a collision
|
// mode to be used, and also sets the correct error codes in case of a collision
|
||||||
//
|
//
|
||||||
#define CreateNtObjectFromWin32ApiPrologue \
|
#define CreateNtObjectFromWin32ApiPrologue \
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes = &LocalAttributes;
|
POBJECT_ATTRIBUTES ObjectAttributes = &LocalAttributes;
|
||||||
#define CreateNtObjectFromWin32ApiBody(ntobj, sec, name, access, ...) \
|
#define CreateNtObjectFromWin32ApiBody(ntobj, sec, name, access, ...) \
|
||||||
if (name) RtlInitUnicodeString(&ObjectName, name); \
|
if (name) RtlInitUnicodeString(&ObjectName, name); \
|
||||||
ObjectAttributes = BasepConvertObjectAttributes(&LocalAttributes, \
|
ObjectAttributes = BaseFormatObjectAttributes(&LocalAttributes, \
|
||||||
sec, \
|
sec, \
|
||||||
name ? &ObjectName : NULL); \
|
name ? &ObjectName : NULL); \
|
||||||
Status = NtCreate##ntobj(&Handle, access, ObjectAttributes, ##__VA_ARGS__);
|
Status = NtCreate##ntobj(&Handle, access, ObjectAttributes, ##__VA_ARGS__);
|
||||||
|
|
|
@ -167,7 +167,7 @@ BaseFormatTimeOut(OUT PLARGE_INTEGER Timeout,
|
||||||
|
|
||||||
POBJECT_ATTRIBUTES
|
POBJECT_ATTRIBUTES
|
||||||
WINAPI
|
WINAPI
|
||||||
BasepConvertObjectAttributes(OUT POBJECT_ATTRIBUTES ObjectAttributes,
|
BaseFormatObjectAttributes(OUT POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
IN PSECURITY_ATTRIBUTES SecurityAttributes OPTIONAL,
|
IN PSECURITY_ATTRIBUTES SecurityAttributes OPTIONAL,
|
||||||
IN PUNICODE_STRING ObjectName);
|
IN PUNICODE_STRING ObjectName);
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ BasepCreateStack(HANDLE hProcess,
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
WINAPI
|
WINAPI
|
||||||
BasepInitializeContext(IN PCONTEXT Context,
|
BaseInitializeContext(IN PCONTEXT Context,
|
||||||
IN PVOID Parameter,
|
IN PVOID Parameter,
|
||||||
IN PVOID StartAddress,
|
IN PVOID StartAddress,
|
||||||
IN PVOID StackAddress,
|
IN PVOID StackAddress,
|
||||||
|
@ -202,8 +202,8 @@ BaseThreadStartup(LPTHREAD_START_ROUTINE lpStartAddress,
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
WINAPI
|
WINAPI
|
||||||
BasepFreeStack(HANDLE hProcess,
|
BaseFreeThreadStack(IN HANDLE hProcess,
|
||||||
PINITIAL_TEB InitialTeb);
|
IN PINITIAL_TEB InitialTeb);
|
||||||
|
|
||||||
__declspec(noreturn)
|
__declspec(noreturn)
|
||||||
VOID
|
VOID
|
||||||
|
@ -216,9 +216,9 @@ VOID
|
||||||
WINAPI
|
WINAPI
|
||||||
BaseProcessStartup(PPROCESS_START_ROUTINE lpStartAddress);
|
BaseProcessStartup(PPROCESS_START_ROUTINE lpStartAddress);
|
||||||
|
|
||||||
BOOLEAN
|
PVOID
|
||||||
WINAPI
|
WINAPI
|
||||||
BasepCheckRealTimePrivilege(VOID);
|
BasepIsRealtimeAllowed(IN BOOLEAN Keep);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
WINAPI
|
WINAPI
|
||||||
|
@ -241,6 +241,11 @@ typedef NTSTATUS (NTAPI *PRTL_CONVERT_STRING)(IN PUNICODE_STRING UnicodeString,
|
||||||
IN BOOLEAN AllocateMemory);
|
IN BOOLEAN AllocateMemory);
|
||||||
|
|
||||||
extern PRTL_CONVERT_STRING Basep8BitStringToUnicodeString;
|
extern PRTL_CONVERT_STRING Basep8BitStringToUnicodeString;
|
||||||
|
extern HANDLE BaseNamedObjectDirectory;
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
WINAPI
|
||||||
|
BaseGetNamedObjectDirectory(VOID);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
WINAPI
|
WINAPI
|
||||||
|
|
Loading…
Reference in a new issue