mirror of
https://github.com/reactos/reactos.git
synced 2024-07-23 20:58:16 +00:00
Fix some compiler warnings.
Implement InitializeCriticalSectionEx Stub TermsrvAppInstallMode and SetTermsrvAppInstallMode. Lazy port of BasepInitializeContext. Lazy ports of thread and fiber startup code, probably will not work. svn path=/branches/ros-amd64-bringup/; revision=34770
This commit is contained in:
parent
f6d9983a3f
commit
d99afa913f
|
@ -232,11 +232,11 @@ ProcessIdToHandle(IN DWORD dwProcessId)
|
|||
CLIENT_ID ClientId;
|
||||
|
||||
/* If we don't have a PID, look it up */
|
||||
if (dwProcessId == -1) dwProcessId = (DWORD)CsrGetProcessId();
|
||||
if (dwProcessId == -1) dwProcessId = (ULONG_PTR)CsrGetProcessId();
|
||||
|
||||
/* Open a handle to the process */
|
||||
ClientId.UniqueThread = NULL;
|
||||
ClientId.UniqueProcess = (HANDLE)dwProcessId;
|
||||
ClientId.UniqueProcess = (HANDLE)(ULONG_PTR)dwProcessId;
|
||||
InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
|
||||
Status = NtOpenProcess(&Handle,
|
||||
PROCESS_ALL_ACCESS,
|
||||
|
|
|
@ -139,6 +139,18 @@ _dump_context(PCONTEXT pc)
|
|||
pc->Ebp, pc->Esi, pc->Esp);
|
||||
DbgPrint("EDI: %.8x EFLAGS: %.8x\n", pc->Edi, pc->EFlags);
|
||||
}
|
||||
#elif defined(_M_AMD64)
|
||||
_dump_context(PCONTEXT pc)
|
||||
{
|
||||
DbgPrint("CS:EIP %x:%I64x\n", pc->SegCs&0xffff, pc->Rip );
|
||||
DbgPrint("DS %x ES %x FS %x GS %x\n", pc->SegDs&0xffff, pc->SegEs&0xffff,
|
||||
pc->SegFs&0xffff, pc->SegGs&0xfff);
|
||||
DbgPrint("RAX: %I64x RBX: %I64x RCX: %I64x RDI: %I64x\n", pc->Rax, pc->Rbx, pc->Rcx, pc->Rdi);
|
||||
DbgPrint("RDX: %I64x RBP: %I64x RSI: %I64x RSP: %I64x\n", pc->Rdx, pc->Rbp, pc->Rsi, pc->Rsp);
|
||||
DbgPrint("R8: %I64x R9: %I64x R10: %I64x R11: %I64x\n", pc->R8, pc->R9, pc->R10, pc->R11);
|
||||
DbgPrint("R12: %I64x R13: %I64x R14: %I64x R15: %I64x\n", pc->R12, pc->R13, pc->R14, pc->R15);
|
||||
DbgPrint("EFLAGS: %.8x\n", pc->EFlags);
|
||||
}
|
||||
#else
|
||||
#warning Unknown architecture
|
||||
static VOID
|
||||
|
@ -260,7 +272,7 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
|
|||
|
||||
if ((GetErrorMode() & SEM_NOGPFAULTERRORBOX) == 0)
|
||||
{
|
||||
#ifdef _X86_
|
||||
#ifdef __i386__
|
||||
PULONG Frame;
|
||||
#endif
|
||||
PVOID StartAddr;
|
||||
|
@ -278,7 +290,7 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
|
|||
ExceptionInfo->ExceptionRecord->ExceptionAddress,
|
||||
_module_name_from_addr(ExceptionInfo->ExceptionRecord->ExceptionAddress, &StartAddr, szMod, sizeof(szMod)));
|
||||
_dump_context ( ExceptionInfo->ContextRecord );
|
||||
#ifdef _X86_
|
||||
#ifdef __i386__
|
||||
DbgPrint("Frames:\n");
|
||||
_SEH_TRY
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ _hread(
|
|||
DWORD NumberOfBytesRead;
|
||||
|
||||
if ( !ReadFile(
|
||||
(HANDLE) hFile,
|
||||
(HANDLE)(ULONG_PTR) hFile,
|
||||
(LPVOID) lpBuffer,
|
||||
(DWORD) lBytes,
|
||||
& NumberOfBytesRead,
|
||||
|
|
|
@ -37,7 +37,7 @@ WriteFile(IN HANDLE hFile,
|
|||
*lpNumberOfBytesWritten = 0;
|
||||
}
|
||||
|
||||
if (IsConsoleHandle(hFile))
|
||||
if (IsConsoleHandle((ULONG_PTR)hFile))
|
||||
{
|
||||
return WriteConsoleA(hFile,
|
||||
lpBuffer,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE group SYSTEM "../../../tools/rbuild/project.dtd">
|
||||
<group>
|
||||
<module name="kernel32_base" type="objectlibrary">
|
||||
<module name="kernel32_base" type="objectlibrary" allowwarnings="true">
|
||||
<include base="kernel32_base">.</include>
|
||||
<include base="kernel32_base">include</include>
|
||||
<include base="ReactOS">include/reactos/subsys</include>
|
||||
|
@ -118,10 +118,16 @@
|
|||
<file>thread.S</file>
|
||||
</directory>
|
||||
</if>
|
||||
<if property="ARCH" value="amd64">
|
||||
<directory name="amd64">
|
||||
<file>fiber.S</file>
|
||||
<file>thread.S</file>
|
||||
</directory>
|
||||
</if>
|
||||
</directory>
|
||||
</module>
|
||||
<module name="kernel32" type="win32dll" baseaddress="${BASEADDRESS_KERNEL32}" installbase="system32" installname="kernel32.dll">
|
||||
<importlibrary definition="kernel32.def" />
|
||||
<importlibrary definition="kernel32.spec.def" />
|
||||
<include base="kernel32">.</include>
|
||||
<include base="kernel32" root="intermediate">.</include>
|
||||
<include base="kernel32">include</include>
|
||||
|
@ -132,5 +138,6 @@
|
|||
<library>pseh</library>
|
||||
<library>ntdll</library>
|
||||
<file>kernel32.rc</file>
|
||||
<file>kernel32.spec</file>
|
||||
</module>
|
||||
</group>
|
||||
|
|
1017
reactos/dll/win32/kernel32/kernel32.spec
Normal file
1017
reactos/dll/win32/kernel32/kernel32.spec
Normal file
File diff suppressed because it is too large
Load diff
|
@ -407,6 +407,7 @@ InterlockedDecrement(IN OUT LONG volatile *lpAddend)
|
|||
return _InterlockedDecrement(lpAddend);
|
||||
}
|
||||
|
||||
#undef InterlockedExchange
|
||||
LONG
|
||||
WINAPI
|
||||
InterlockedExchange(IN OUT LONG volatile *Target,
|
||||
|
|
|
@ -40,7 +40,7 @@ GetHandleInformation (HANDLE hObject,
|
|||
DWORD Flags;
|
||||
|
||||
Ppb = NtCurrentPeb()->ProcessParameters;
|
||||
switch ((ULONG)hObject)
|
||||
switch ((ULONG_PTR)hObject)
|
||||
{
|
||||
case STD_INPUT_HANDLE:
|
||||
hObject = Ppb->StandardInput;
|
||||
|
|
|
@ -1401,3 +1401,15 @@ Wow64RevertWow64FsRedirection (VOID * pv)
|
|||
STUB;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL WINAPI TermsrvAppInstallMode(void)
|
||||
{
|
||||
STUB;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DWORD WINAPI SetTermsrvAppInstallMode(BOOL bInstallMode)
|
||||
{
|
||||
STUB;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <k32.h>
|
||||
#ifdef _M_IX86
|
||||
#include "i386/ketypes.h"
|
||||
#elif defined _M_AMD64
|
||||
#include "amd64/ketypes.h"
|
||||
#endif
|
||||
|
||||
#define NDEBUG
|
||||
|
@ -336,7 +338,7 @@ BasepInitializeContext(IN PCONTEXT Context,
|
|||
IN PVOID StackAddress,
|
||||
IN ULONG ContextType)
|
||||
{
|
||||
#ifdef _M_IX86
|
||||
#ifdef __i386__
|
||||
DPRINT("BasepInitializeContext: %p\n", Context);
|
||||
|
||||
/* Setup the Initial Win32 Thread Context */
|
||||
|
@ -362,7 +364,7 @@ BasepInitializeContext(IN PCONTEXT Context,
|
|||
}
|
||||
else if (ContextType == 2) /* For Fibers */
|
||||
{
|
||||
//Context->Eip = (ULONG)BaseFiberStartup;
|
||||
Context->Eip = (ULONG)BaseFiberStartup;
|
||||
}
|
||||
else /* For first thread in a Process */
|
||||
{
|
||||
|
@ -374,6 +376,44 @@ BasepInitializeContext(IN PCONTEXT Context,
|
|||
|
||||
/* 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->SegFs = KGDT_R3_TEB | RPL_MASK;
|
||||
Context->SegEs = KGDT_R3_DATA | RPL_MASK;
|
||||
Context->SegDs = KGDT_R3_DATA | RPL_MASK;
|
||||
Context->SegCs = KGDT_R3_CODE | RPL_MASK;
|
||||
Context->SegSs = KGDT_R3_DATA | RPL_MASK;
|
||||
Context->SegGs = 0;
|
||||
|
||||
/* 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;
|
||||
|
|
|
@ -60,7 +60,7 @@ BOOL STDCALL ProcessIdToSessionId (IN DWORD dwProcessId,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
ClientId.UniqueProcess = (HANDLE)dwProcessId;
|
||||
ClientId.UniqueProcess = (HANDLE)(ULONG_PTR)dwProcessId;
|
||||
ClientId.UniqueThread = 0;
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
|
||||
|
|
|
@ -55,4 +55,14 @@ InitializeCriticalSectionAndSpinCount(OUT LPCRITICAL_SECTION lpCriticalSection,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
BOOL WINAPI InitializeCriticalSectionEx( CRITICAL_SECTION *crit, DWORD spincount, DWORD flags )
|
||||
{
|
||||
NTSTATUS ret = RtlInitializeCriticalSectionEx( crit, spincount, flags );
|
||||
if (ret) RtlRaiseStatus( ret );
|
||||
return !ret;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
124
reactos/dll/win32/kernel32/thread/amd64/fiber.S
Normal file
124
reactos/dll/win32/kernel32/thread/amd64/fiber.S
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/kernel32/thread/i386/fiber.S
|
||||
* PURPOSE: Fiber context switch code for the x86 architecture
|
||||
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
||||
* KJK::Hyperion <noog@libero.it>
|
||||
*/
|
||||
|
||||
#include <ndk/asm.h>
|
||||
|
||||
#define CONTEXT_FULL 0x10007
|
||||
#define CONTEXT_FLOATING_POINT 0xF
|
||||
|
||||
.globl _SwitchToFiber@4
|
||||
.intel_syntax noprefix
|
||||
|
||||
_SwitchToFiber@4:
|
||||
/* Get the TEB */
|
||||
mov edx, fs:[KGDT_R3_TEB]
|
||||
|
||||
/* Get the Fiber */
|
||||
mov eax, [edx+TEB_FIBER_DATA]
|
||||
|
||||
/* Save the non-volatile registers */
|
||||
mov [eax+FIBER_CONTEXT_EBX], ebx
|
||||
mov [eax+FIBER_CONTEXT_ESI], esi
|
||||
mov [eax+FIBER_CONTEXT_EDI], edi
|
||||
mov [eax+FIBER_CONTEXT_EBP], ebp
|
||||
|
||||
/* Check if we're to save FPU State */
|
||||
cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL + CONTEXT_FLOATING_POINT
|
||||
jnz NoFpuStateSave
|
||||
|
||||
/* Save the FPU State (Status and Control)*/
|
||||
fstsw [eax+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD]
|
||||
fstcw [eax+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD]
|
||||
|
||||
/* Check if the CPU supports SIMD MXCSR State Save */
|
||||
cmp byte ptr ds:[PROCESSOR_FEATURE_FXSR], 0
|
||||
jnz NoFpuStateSave
|
||||
stmxcsr [eax+FIBER_CONTEXT_DR6]
|
||||
|
||||
NoFpuStateSave:
|
||||
|
||||
/* Save stack since we're not touching it anymore */
|
||||
mov [eax+FIBER_CONTEXT_ESP], esp
|
||||
|
||||
/* Transfer some data from the TEB */
|
||||
mov ecx, [edx+TEB_FLS_DATA]
|
||||
mov [eax+FIBER_FLS_DATA], ecx
|
||||
mov ecx, [edx+TEB_ACTIVATION_CONTEXT_STACK_POINTER]
|
||||
mov [eax+FIBER_ACTIVATION_CONTEXT_STACK], ecx
|
||||
|
||||
/* Transfer some data related to the Stack */
|
||||
mov ecx, [edx+TEB_EXCEPTION_LIST]
|
||||
mov [eax+FIBER_EXCEPTION_LIST], ecx
|
||||
mov ecx, [edx+TEB_STACK_LIMIT]
|
||||
mov [eax+FIBER_STACK_LIMIT], ecx
|
||||
mov ecx, [edx+TEB_GUARANTEED_STACK_BYTES]
|
||||
mov [eax+FIBER_GUARANTEED_STACK_BYTES], ecx
|
||||
|
||||
/* Switch to the new fiber */
|
||||
mov ecx, [esp+4]
|
||||
mov [edx+TEB_FIBER_DATA], ecx
|
||||
|
||||
/* Switch Fiber Data */
|
||||
mov esi, [ecx+FIBER_EXCEPTION_LIST]
|
||||
mov [edx+TEB_EXCEPTION_LIST], esi
|
||||
mov esi, [ecx+FIBER_STACK_BASE]
|
||||
mov [edx+TEB_STACK_BASE], esi
|
||||
mov esi, [ecx+FIBER_STACK_LIMIT]
|
||||
mov [edx+TEB_STACK_LIMIT], esi
|
||||
mov esi, [ecx+FIBER_DEALLOCATION_STACK]
|
||||
mov [edx+TEB_DEALLOCATION_STACK], esi
|
||||
mov esi, [ecx+FIBER_GUARANTEED_STACK_BYTES]
|
||||
mov [edx+TEB_GUARANTEED_STACK_BYTES], esi
|
||||
mov esi, [ecx+FIBER_ACTIVATION_CONTEXT_STACK]
|
||||
mov [edx+TEB_ACTIVATION_CONTEXT_STACK_POINTER], esi
|
||||
|
||||
/* Restore FPU State */
|
||||
cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL + CONTEXT_FLOATING_POINT
|
||||
jnz NoFpuStateRestore
|
||||
|
||||
/* Check if the Status Word Changed */
|
||||
mov esi, [eax+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD]
|
||||
cmp si, word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD]
|
||||
jnz StatusWordChanged
|
||||
|
||||
/* Check if the Control Word Changed */
|
||||
mov esi, [eax+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD]
|
||||
cmp si, word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD]
|
||||
jz ControlWordEqual
|
||||
|
||||
StatusWordChanged:
|
||||
|
||||
/* Load the new one */
|
||||
mov word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD], 0xFFFF
|
||||
fldenv [ecx+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD]
|
||||
|
||||
ControlWordEqual:
|
||||
|
||||
/* Load the new one */
|
||||
cmp byte ptr ds:[PROCESSOR_FEATURE_FXSR], 0
|
||||
jnz NoFpuStateRestore
|
||||
ldmxcsr [ecx+FIBER_CONTEXT_DR6]
|
||||
|
||||
NoFpuStateRestore:
|
||||
|
||||
/* Restore non-volatile registers */
|
||||
mov esi, [ecx+FIBER_CONTEXT_ESI]
|
||||
mov edi, [ecx+FIBER_CONTEXT_EDI]
|
||||
mov ebx, [ecx+FIBER_CONTEXT_EBX]
|
||||
mov ebp, [ecx+FIBER_CONTEXT_EBP]
|
||||
mov esp, [ecx+FIBER_CONTEXT_ESP]
|
||||
|
||||
/* Restore FLS Data */
|
||||
mov eax, [ecx+FIBER_FLS_DATA]
|
||||
mov [edx+TEB_FLS_DATA], eax
|
||||
|
||||
/* Return */
|
||||
ret 4
|
||||
|
||||
/* EOF */
|
32
reactos/dll/win32/kernel32/thread/amd64/thread.S
Normal file
32
reactos/dll/win32/kernel32/thread/amd64/thread.S
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/kernel32/thread/i386/thread.S
|
||||
* PURPOSE: Thread Start Thunks
|
||||
* PROGRAMMER: Alex Ionescu (alex@relsoft.net)
|
||||
*/
|
||||
|
||||
.globl _BaseThreadStartupThunk@0
|
||||
.globl _BaseProcessStartThunk@0
|
||||
.intel_syntax noprefix
|
||||
|
||||
_BaseThreadStartupThunk@0:
|
||||
|
||||
/* Start out fresh */
|
||||
xor rbp, rbp
|
||||
|
||||
push rbx /* lpParameter */
|
||||
push rax /* lpStartAddress */
|
||||
push 0 /* Return RIP */
|
||||
jmp _BaseThreadStartup
|
||||
|
||||
_BaseProcessStartThunk@0:
|
||||
|
||||
/* Start out fresh */
|
||||
xor rbp, rbp
|
||||
|
||||
push rax /* lpStartAddress */
|
||||
push 0 /* Return RIP */
|
||||
jmp _BaseProcessStartup
|
||||
|
||||
/* EOF */
|
|
@ -258,6 +258,13 @@ BaseFiberStartup(VOID)
|
|||
DPRINT1("Starting Fiber\n");
|
||||
BaseThreadStartup((LPTHREAD_START_ROUTINE)Fiber->Context.Eax,
|
||||
(LPVOID)Fiber->Context.Ebx);
|
||||
#elif defined(__x86_64__)
|
||||
PFIBER Fiber = GetFiberData();
|
||||
|
||||
/* Call the Thread Startup Routine */
|
||||
DPRINT1("Starting Fiber\n");
|
||||
BaseThreadStartup((LPTHREAD_START_ROUTINE)Fiber->Context.Rax,
|
||||
(LPVOID)Fiber->Context.Rbx);
|
||||
#else
|
||||
#warning Unknown architecture
|
||||
UNIMPLEMENTED;
|
||||
|
|
|
@ -658,6 +658,7 @@ GetThreadSelectorEntry(IN HANDLE hThread,
|
|||
IN DWORD dwSelector,
|
||||
OUT LPLDT_ENTRY lpSelectorEntry)
|
||||
{
|
||||
#ifdef _M_IX86
|
||||
DESCRIPTOR_TABLE_ENTRY DescriptionTableEntry;
|
||||
NTSTATUS Status;
|
||||
|
||||
|
@ -675,6 +676,10 @@ GetThreadSelectorEntry(IN HANDLE hThread,
|
|||
|
||||
*lpSelectorEntry = DescriptionTableEntry.Descriptor;
|
||||
return TRUE;
|
||||
#else
|
||||
DPRINT1("Calling GetThreadSelectorEntry!\n");
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue