/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
- * FILE: lib/kernel32/misc/utils.c
+ * FILE: dll/win32/kernel32/client/utils.c
* PURPOSE: Utility and Support Functions
* PROGRAMMER: Alex Ionescu (alex@relsoft.net)
* Pierre Schweitzer (pierre.schweitzer@reactos.org)
if (dwMilliseconds == INFINITE) return NULL;
/* Otherwise, convert the time to NT Format */
- Timeout->QuadPart = UInt32x32To64(dwMilliseconds, -10000);
+ Timeout->QuadPart = dwMilliseconds * -10000LL;
return Timeout;
}
Attributes,
RootDirectory,
SecurityDescriptor);
- DPRINT("Attributes: %lx, RootDirectory: %lx, SecurityDescriptor: %p\n",
+ DPRINT("Attributes: %lx, RootDirectory: %p, SecurityDescriptor: %p\n",
Attributes, RootDirectory, SecurityDescriptor);
return ObjectAttributes;
}
NTSTATUS
WINAPI
BaseCreateStack(HANDLE hProcess,
- SIZE_T StackReserve,
SIZE_T StackCommit,
+ SIZE_T StackReserve,
PINITIAL_TEB InitialTeb)
{
NTSTATUS Status;
BOOLEAN UseGuard;
ULONG PageSize, Dummy, AllocationGranularity;
SIZE_T StackReserveHeader, StackCommitHeader, GuardPageSize, GuaranteedStackCommit;
- DPRINT("BaseCreateStack (hProcess: %lx, Max: %lx, Current: %lx)\n",
+ DPRINT("BaseCreateStack (hProcess: %p, Max: %lx, Current: %lx)\n",
hProcess, StackReserve, StackCommit);
/* Read page size */
StackCommit = ROUND_UP(StackCommit, PageSize);
StackReserve = ROUND_UP(StackReserve, AllocationGranularity);
- /* ROS Hack until we support guard page stack expansion */
- StackCommit = StackReserve;
-
/* Reserve memory for the stack */
Stack = 0;
Status = NtAllocateVirtualMemory(hProcess,
/* Is FPU state required? */
Context->ContextFlags |= ContextFlags;
- if (ContextFlags == CONTEXT_FLOATING_POINT)
+ if ((ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT)
{
/* Set an initial state */
Context->FloatSave.ControlWord = 0x27F;
/* Give it some room for the Parameter */
Context->Rsp -= sizeof(PVOID);
+#elif defined(_M_ARM)
+ DPRINT("BaseInitializeContext: %p\n", Context);
+
+ // FIXME: check if this is correct!
+ /* Setup the Initial Win32 Thread Context */
+ Context->R0 = (ULONG_PTR)StartAddress;
+ Context->R1 = (ULONG_PTR)Parameter;
+ Context->Sp = (ULONG_PTR)StackAddress;
+
+ if (ContextType == 1) /* For Threads */
+ {
+ Context->Pc = (ULONG_PTR)BaseThreadStartupThunk;
+ }
+ else if (ContextType == 2) /* For Fibers */
+ {
+ Context->Pc = (ULONG_PTR)BaseFiberStartup;
+ }
+ else /* For first thread in a Process */
+ {
+ Context->Pc = (ULONG_PTR)BaseProcessStartThunk;
+ }
+
+ /* Set the Context Flags */
+ Context->ContextFlags = CONTEXT_FULL;
+
+ /* Give it some room for the Parameter */
+ Context->Sp -= sizeof(PVOID);
#else
#warning Unknown architecture
UNIMPLEMENTED;
/*
* Checks if the privilege for Real-Time Priority is there
+ * Beware about this function behavior:
+ * - In case Keep is set to FALSE, then the function will only check
+ * whether real time is allowed and won't grant the privilege. In that case
+ * it will return TRUE if allowed, FALSE otherwise. Not a state!
+ * It means you don't have to release privilege when calling with FALSE.
*/
PVOID
WINAPI
Status = RtlAcquirePrivilege(&Privilege, 1, 0, &State);
if (!NT_SUCCESS(Status)) return NULL;
- if (Keep)
+ if (!Keep)
{
RtlReleasePrivilege(State);
State = (PVOID)TRUE;
NtClose(hFile);
/* Return status */
- DPRINT("Section: %lx for file: %lx\n", *hSection, hFile);
+ DPRINT("Section: %p for file: %p\n", *hSection, hFile);
return Status;
}
FileDispositionInformation);
}
-/*
- * @unimplemented
- */
-BOOL
-WINAPI
-BaseCheckRunApp(IN DWORD Unknown1,
- IN DWORD Unknown2,
- IN DWORD Unknown3,
- IN DWORD Unknown4,
- IN DWORD Unknown5,
- IN DWORD Unknown6,
- IN DWORD Unknown7,
- IN DWORD Unknown8,
- IN DWORD Unknown9,
- IN DWORD Unknown10)
-{
- STUB;
- return FALSE;
-}
-
/*
* @unimplemented
*/
OUT PHANDLE JobHandle)
{
NTSTATUS Status;
-
+
/* Validate that there's a name */
if ((ApplicationName) && *(ApplicationName))
{
if ((InJob) && (NewToken) && (JobHandle))
{
/* Do the work (one day...) */
- UNIMPLEMENTED;
+ DPRINT("BasepCheckWinSaferRestrictions is UNIMPLEMENTED\n");
Status = STATUS_SUCCESS;
}
else