#include <k32.h>
#ifdef _M_IX86
#include "i386/ketypes.h"
-#elif defined _M_AMD64
-#include "amd64/ketypes.h"
#endif
#define NDEBUG
/* Now set up some basic Initial TEB Parameters */
InitialTeb->AllocatedStackBase = (PVOID)Stack;
InitialTeb->StackBase = (PVOID)(Stack + StackReserve);
+ InitialTeb->PreviousStackBase = NULL;
+ InitialTeb->PreviousStackLimit = NULL;
/* Update the Stack Position */
Stack += StackReserve - StackCommit;
BasepFreeStack(HANDLE hProcess,
PINITIAL_TEB InitialTeb)
{
- SIZE_T Dummy = 0;
+ ULONG Dummy = 0;
/* Free the Stack */
NtFreeVirtualMemory(hProcess,
IN PVOID StackAddress,
IN ULONG ContextType)
{
-#ifdef __i386__
+#ifdef _M_IX86
DPRINT("BasepInitializeContext: %p\n", Context);
/* Setup the Initial Win32 Thread Context */
}
else if (ContextType == 2) /* For Fibers */
{
- Context->Eip = (ULONG)BaseFiberStartup;
+ //Context->Eip = (ULONG)BaseFiberStartup;
}
else /* For first thread in a Process */
{
/* Give it some room for the Parameter */
Context->Esp -= sizeof(PVOID);
-#elif defined(__x86_64__)
- DPRINT("BasepInitializeContext: %p\n", Context);
-
- /* Setup the Initial Win32 Thread Context */
- Context->Rax = (ULONG_PTR)StartAddress;
- Context->Rbx = (ULONG_PTR)Parameter;
- Context->Rsp = (ULONG_PTR)StackAddress;
- /* The other registers are undefined */
-
- /* Setup the Segments */
- Context->SegGs = KGDT_64_DATA | RPL_MASK;
- Context->SegEs = KGDT_64_DATA | RPL_MASK;
- Context->SegDs = KGDT_64_DATA | RPL_MASK;
- Context->SegCs = KGDT_64_R3_CODE | RPL_MASK;
- Context->SegSs = KGDT_64_DATA | RPL_MASK;
- Context->SegFs = KGDT_32_R3_TEB;
-
- /* Set the EFLAGS */
- Context->EFlags = 0x3000; /* IOPL 3 */
-
- if (ContextType == 1) /* For Threads */
- {
- Context->Rip = (ULONG_PTR)BaseThreadStartupThunk;
- }
- else if (ContextType == 2) /* For Fibers */
- {
- Context->Rip = (ULONG_PTR)BaseFiberStartup;
- }
- else /* For first thread in a Process */
- {
- Context->Rip = (ULONG_PTR)BaseProcessStartThunk;
- }
-
- /* Set the Context Flags */
- Context->ContextFlags = CONTEXT_FULL;
-
- /* Give it some room for the Parameter */
- Context->Rsp -= sizeof(PVOID);
#else
#warning Unknown architecture
UNIMPLEMENTED;
RelativeName.Handle = NULL;
/* Find the application name */
- RtlDosPathNameToNtPathName_U(lpApplicationName,
- ApplicationName,
- NULL,
- &RelativeName);
+ if (!RtlDosPathNameToNtPathName_U(lpApplicationName,
+ ApplicationName,
+ NULL,
+ &RelativeName))
+ {
+ return STATUS_OBJECT_PATH_NOT_FOUND;
+ }
+
DPRINT("ApplicationName %wZ\n", ApplicationName);
DPRINT("RelativeName %wZ\n", &RelativeName.DosPath);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to open file\n");
- SetLastErrorByStatus (Status);
+ SetLastErrorByStatus(Status);
return Status;
}