- Add some missing/internal definitions to proper headers.

- Get rid of FLUSH_TLB macros and use KeFlushCurrentTb and the MSVC_compatible instrinsic __invlpg;
- Fix some prototypes.
- Fixed unsigned/signed mismatches.
- Fix SEH usage in ExAllocatePoolWithQuotaTag.

svn path=/trunk/; revision=24652
This commit is contained in:
Alex Ionescu 2006-10-25 18:23:45 +00:00
parent a900757d83
commit 6497d295c3
19 changed files with 130 additions and 111 deletions

View file

@ -71,6 +71,30 @@ extern LARGE_INTEGER IoReadTransferCount;
extern LARGE_INTEGER IoWriteTransferCount;
extern LARGE_INTEGER IoOtherTransferCount;
typedef STRING LSA_STRING, *PLSA_STRING;
typedef ULONG LSA_OPERATIONAL_MODE, *PLSA_OPERATIONAL_MODE;
typedef enum _SECURITY_LOGON_TYPE
{
UndefinedLogonType = 0,
Interactive = 2,
Network,
Batch,
Service,
Proxy,
Unlock,
NetworkCleartext,
NewCredentials,
#if (_WIN32_WINNT >= 0x0501)
RemoteInteractive,
CachedInteractive,
#endif
#if (_WIN32_WINNT >= 0x0502)
CachedRemoteInteractive,
CachedUnlock
#endif
} SECURITY_LOGON_TYPE, *PSECURITY_LOGON_TYPE;
#define ANSI_DOS_STAR ('<')
#define ANSI_DOS_QM ('>')
#define ANSI_DOS_DOT ('"')
@ -378,6 +402,7 @@ extern LARGE_INTEGER IoOtherTransferCount;
#define TOKEN_HAS_BACKUP_PRIVILEGE 0x02
#define TOKEN_HAS_RESTORE_PRIVILEGE 0x04
#define TOKEN_HAS_ADMIN_GROUP 0x08
#define TOKEN_WRITE_RESTRICTED 0x08
#define TOKEN_IS_RESTRICTED 0x10
#define VACB_MAPPING_GRANULARITY (0x40000)
@ -1993,7 +2018,7 @@ CcMapData (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
IN ULONG Flags,
OUT PVOID *Bcb,
OUT PVOID *Buffer
);
@ -2026,6 +2051,8 @@ CcMdlWriteComplete (
IN PMDL MdlChain
);
#define MAP_WAIT 1
NTKERNELAPI
BOOLEAN
NTAPI
@ -2033,11 +2060,7 @@ CcPinMappedData (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
#if (VER_PRODUCTBUILD >= 2195)
IN ULONG Flags,
#else
IN BOOLEAN Wait,
#endif
IN OUT PVOID *Bcb
);
@ -2048,11 +2071,7 @@ CcPinRead (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
#if (VER_PRODUCTBUILD >= 2195)
IN ULONG Flags,
#else
IN BOOLEAN Wait,
#endif
OUT PVOID *Bcb,
OUT PVOID *Buffer
);
@ -2076,11 +2095,7 @@ CcPreparePinWrite (
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Zero,
#if (VER_PRODUCTBUILD >= 2195)
IN ULONG Flags,
#else
IN BOOLEAN Wait,
#endif
OUT PVOID *Bcb,
OUT PVOID *Buffer
);

View file

@ -186,13 +186,18 @@ extern POBJECT_TYPE NTSYSAPI IoDriverObjectType;
#define DNUF_DONT_SHOW_IN_UI 0x0002
#define DNUF_NOT_DISABLEABLE 0x0008
//
// Internal Option Flags
//
#define IO_ATTACH_DEVICE_API 0x80000000
//
// Undocumented WMI Registration Flags
//
#define WMIREG_FLAG_TRACE_PROVIDER 0x00010000
#define WMIREG_FLAG_TRACE_NOTIFY_MASK 0x00F00000
#define WMIREG_NOTIFY_DISK_IO 0x00100000
#define WMIREG_NOTIFY_TDI_IO 0x00200000
#define WMIREG_FLAG_TRACE_PROVIDER 0x00010000
#define WMIREG_FLAG_TRACE_NOTIFY_MASK 0x00F00000
#define WMIREG_NOTIFY_DISK_IO 0x00100000
#define WMIREG_NOTIFY_TDI_IO 0x00200000
//
// I/O Completion Information Class for NtQueryIoCompletionInformation

View file

@ -67,6 +67,11 @@ Author:
#define LDR_LOCK_LOADER_LOCK_FLAG_RAISE_STATUS 0x00000001
#define LDR_LOCK_LOADER_LOCK_FLAG_TRY_ONLY 0x00000002
//
// FIXME: THIS SHOULD *NOT* BE USED!
//
#define IMAGE_SCN_TYPE_NOLOAD 0x00000002
//
// Loader Data stored in the PEB
//

View file

@ -1130,7 +1130,7 @@ typedef enum
#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
#define IMAGE_SCN_TYPE_REG 0
#define IMAGE_SCN_TYPE_DSECT 1
#define IMAGE_SCN_TYPE_NOLOAD 2
//#define IMAGE_SCN_TYPE_NOLOAD 2
#define IMAGE_SCN_TYPE_GROUP 4
#define IMAGE_SCN_TYPE_NO_PAD 8
#define IMAGE_SCN_CNT_CODE 32

View file

@ -27,7 +27,7 @@ BOOLEAN STDCALL
CcMapData (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
IN ULONG Flags,
OUT PVOID *pBcb,
OUT PVOID *pBuffer)
{
@ -39,9 +39,9 @@ CcMapData (IN PFILE_OBJECT FileObject,
PINTERNAL_BCB iBcb;
ULONG ROffset;
DPRINT("CcMapData(FileObject 0x%p, FileOffset %I64x, Length %d, Wait %d,"
DPRINT("CcMapData(FileObject 0x%p, FileOffset %I64x, Length %d, Flags %d,"
" pBcb 0x%p, pBuffer 0x%p)\n", FileObject, FileOffset->QuadPart,
Length, Wait, pBcb, pBuffer);
Length, Flags, pBcb, pBuffer);
ReadOffset = (ULONG)FileOffset->QuadPart;
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
@ -67,7 +67,7 @@ CcMapData (IN PFILE_OBJECT FileObject,
}
if (!Valid)
{
if (!Wait)
if (!(Flags & MAP_WAIT))
{
CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE);
return(FALSE);

View file

@ -62,7 +62,7 @@ FsRtlInsertPerFileObjectContext(IN PFILE_OBJECT FileObject,
*/
PFSRTL_PER_FILEOBJECT_CONTEXT
NTAPI
FsRtlRemovePerFileObjectContext(IN PFSRTL_ADVANCED_FCB_HEADER PerFileObjectContext,
FsRtlRemovePerFileObjectContext(IN PFILE_OBJECT PerFileObjectContext,
IN PVOID OwnerId OPTIONAL,
IN PVOID InstanceId OPTIONAL)
{

View file

@ -514,10 +514,10 @@ _ExRundownCompleted(IN PEX_RUNDOWN_REF RunRef)
*--*/
VOID
FORCEINLINE
ExInitializePushLock(IN PEX_PUSH_LOCK PushLock)
ExInitializePushLock(IN PULONG_PTR PushLock)
{
/* Set the value to 0 */
PushLock->Value = 0;
*PushLock = 0;
}
/*++

View file

@ -39,6 +39,13 @@
: /* no outputs */ \
: "q" (X));
#define Ke386SetTr(X) __asm__ __volatile__("ltr %%ax" : :"a" (X));
#define Ke386GetTr(X) \
__asm__("str %0\n\t" \
: /* no outputs */ \
: "m" (X));
#define Ke386SaveFlags(x) __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */)
#define Ke386RestoreFlags(x) __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
@ -58,8 +65,6 @@
#define _Ke386SetDr(N,X) __asm__ __volatile__("movl %0,%%dr" #N : :"r" (X));
#define Ke386SetTr(X) __asm__ __volatile__("ltr %%ax" : :"a" (X));
#define Ke386GetTr(X) __asm__ __volatile__("str %%ax" : :"a" (X));
static inline void Ki386Cpuid(ULONG Op, PULONG Eax, PULONG Ebx, PULONG Ecx, PULONG Edx)
{
@ -69,25 +74,11 @@ static inline void Ki386Cpuid(ULONG Op, PULONG Eax, PULONG Ebx, PULONG Ecx, PULO
}
#define Ke386Rdmsr(msr,val1,val2) __asm__ __volatile__("rdmsr" : "=a" (val1), "=d" (val2) : "c" (msr))
#define Ke386Wrmsr(msr,val1,val2) __asm__ __volatile__("wrmsr" : /* no outputs */ : "c" (msr), "a" (val1), "d" (val2))
#define FLUSH_TLB { \
unsigned int tmp; \
__asm__ __volatile__( \
"movl %%cr3,%0\n\t" \
"movl %0,%%cr3\n\t" \
: "=r" (tmp) \
:: "memory"); \
}
#define Ke386HaltProcessor() __asm__("hlt\n\t");
#define FLUSH_TLB_ONE(addr) __asm__ __volatile__( \
"invlpg %0" \
: \
: "m" (*(volatile long *) (addr)))
#define Ke386HaltProcessor() __asm__("hlt\n\t");
#define Ke386FnInit() __asm__("fninit\n\t");
#define Ke386FnInit() __asm__("fninit\n\t");
//
// DR Macros

View file

@ -197,14 +197,14 @@ LONG
FASTCALL
ObDereferenceObjectEx(
IN PVOID Object,
IN ULONG Count
IN LONG Count
);
LONG
FASTCALL
ObReferenceObjectEx(
IN PVOID Object,
IN ULONG Count
IN LONG Count
);
BOOLEAN

View file

@ -314,11 +314,9 @@ IopSaveBootLogToFile(VOID)
ExReleaseResourceLite(&IopBootLogResource);
return;
}
#if defined (__GNUC__)
Status = IopWriteLogFile(L"ReactOS "KERNEL_VERSION_STR);
#elif defined (_MSC_VER)
Status = IopWriteLogFile("ReactOS "KERNEL_VERSION_STR);
#endif
//Status = IopWriteLogFile(L"ReactOS "KERNEL_VERSION_STR);
if (!NT_SUCCESS(Status))
{
DPRINT1("IopWriteLogFile() failed (Status %lx)\n", Status);

View file

@ -1331,7 +1331,7 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
DPRINT("Thread %p acquired mutex\n", PsGetCurrentThread());
/* Disable hardware debugging while we are inside the stub */
_Ke386SetDr(7, 0);
Ke386SetDr7(0);
GspUnloadBreakpoints(TrapFrame);
/* Make sure we're debugging the current thread. */

View file

@ -525,7 +525,7 @@ KiGetMachineBootPointers(IN PKGDTENTRY *Gdt,
*Idt = (PKIDTENTRY)IdtDescriptor.Base;
/* Get TSS and FS Selectors */
Ke386GetTr(&Tr);
Ke386GetTr(Tr);
if (Tr != KGDT_TSS) Tr = KGDT_TSS; // FIXME: HACKHACK
Fs = Ke386GetFs();

View file

@ -33,7 +33,7 @@ KeSetBaseGdtSelector(ULONG Entry,
KeAcquireSpinLock(&GdtLock, &oldIrql);
Gdt = KeGetPcr()->GDT;
Gdt = (PUSHORT)KeGetPcr()->GDT;
Entry = (Entry & (~0x3)) / 2;
Gdt[Entry + 1] = (USHORT)(((ULONG)Base) & 0xffff);

View file

@ -85,11 +85,11 @@ MiFlushTlbIpiRoutine(PVOID Address)
}
else if (Address == (PVOID)0xfffffffe)
{
FLUSH_TLB;
KeFlushCurrentTb();
}
else
{
FLUSH_TLB_ONE(Address);
__invlpg(Address);
}
}
@ -112,7 +112,7 @@ MiFlushTlb(PULONG Pt, PVOID Address)
#else
if ((Pt && MmUnmapPageTable(Pt)) || Address >= MmSystemRangeStart)
{
FLUSH_TLB_ONE(Address);
__invlpg(Address);
}
#endif
}
@ -2220,7 +2220,7 @@ MmCreateHyperspaceMapping(PFN_TYPE Page)
}
}
Address = (PVOID)((ULONG_PTR)HYPERSPACE + i * PAGE_SIZE);
FLUSH_TLB_ONE(Address);
__invlpg(Address);
return Address;
}
@ -2242,7 +2242,7 @@ MmChangeHyperspaceMapping(PVOID Address, PFN_TYPE NewPage)
Entry = InterlockedExchange((PLONG)ADDR_TO_PTE(Address), PFN_TO_PTE(NewPage) | PA_PRESENT | PA_READWRITE);
Pfn = PTE_TO_PFN(Entry);
}
FLUSH_TLB_ONE(Address);
__invlpg(Address);
return Pfn;
}
@ -2264,7 +2264,7 @@ MmDeleteHyperspaceMapping(PVOID Address)
Entry = InterlockedExchange((PLONG)ADDR_TO_PTE(Address), 0);
Pfn = PTE_TO_PFN(Entry);
}
FLUSH_TLB_ONE(Address);
__invlpg(Address);
return Pfn;
}

View file

@ -140,7 +140,7 @@ VOID STDCALL
MmUnmapIoSpace (IN PVOID BaseAddress,
IN ULONG NumberOfBytes)
{
ULONG Offset;
LONG Offset;
PVOID Address = BaseAddress;
Offset = (ULONG_PTR)Address % PAGE_SIZE;

View file

@ -161,41 +161,51 @@ ExAllocatePoolWithTagPriority(
return ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag);
}
_SEH_DEFINE_LOCALS(ExQuotaPoolVars)
{
PVOID Block;
};
_SEH_FILTER(FreeAndGoOn)
{
_SEH_ACCESS_LOCALS(ExQuotaPoolVars);
/* Couldn't charge, so free the pool and let the caller SEH manage */
ExFreePool(_SEH_VAR(Block));
return EXCEPTION_CONTINUE_SEARCH;
}
/*
* @implemented
*/
PVOID STDCALL
PVOID
NTAPI
ExAllocatePoolWithQuotaTag (IN POOL_TYPE PoolType,
IN ULONG NumberOfBytes,
IN ULONG Tag)
IN ULONG NumberOfBytes,
IN ULONG Tag)
{
PVOID Block;
PEPROCESS Process;
_SEH_DECLARE_LOCALS(ExQuotaPoolVars);
/* Allocate the Pool First */
Block = EiAllocatePool(PoolType,
NumberOfBytes,
Tag,
&ExAllocatePoolWithQuotaTag);
_SEH_VAR(Block) = EiAllocatePool(PoolType,
NumberOfBytes,
Tag,
&ExAllocatePoolWithQuotaTag);
/* "Quota is not charged to the thread for allocations >= PAGE_SIZE" - OSR Docs */
if (!(NumberOfBytes >= PAGE_SIZE)) {
if (!(NumberOfBytes >= PAGE_SIZE))
{
/* Get the Current Process */
Process = PsGetCurrentProcess();
/* PsChargePoolQuota returns an exception, so this needs SEH */
_SEH_FILTER(FreeAndGoOn)
{
/* Couldn't charge, so free the pool and let the caller SEH manage */
ExFreePool(Block);
return EXCEPTION_CONTINUE_SEARCH;
}
_SEH_TRY
{
//* FIXME: Is there a way to get the actual Pool size allocated from the pool header? */
PsChargePoolQuota(Process, PoolType & PAGED_POOL_MASK, NumberOfBytes);
/* FIXME: Is there a way to get the actual Pool size allocated from the pool header? */
PsChargePoolQuota(Process,
PoolType & PAGED_POOL_MASK,
NumberOfBytes);
}
_SEH_EXCEPT(FreeAndGoOn)
{
@ -205,7 +215,8 @@ ExAllocatePoolWithQuotaTag (IN POOL_TYPE PoolType,
_SEH_END;
}
return Block;
/* Return the allocated block */
return _SEH_VAR(Block);
}
/*

View file

@ -70,7 +70,7 @@ ObpDeferObjectDeletion(IN PVOID Object)
LONG
FASTCALL
ObReferenceObjectEx(IN PVOID Object,
IN ULONG Count)
IN LONG Count)
{
/* Increment the reference count and return the count now */
return InterlockedExchangeAdd(&OBJECT_TO_OBJECT_HEADER(Object)->
@ -81,10 +81,10 @@ ObReferenceObjectEx(IN PVOID Object,
LONG
FASTCALL
ObDereferenceObjectEx(IN PVOID Object,
IN ULONG Count)
IN LONG Count)
{
POBJECT_HEADER Header;
ULONG NewCount;
LONG NewCount;
/* Extract the object header */
Header = OBJECT_TO_OBJECT_HEADER(Object);

View file

@ -12,7 +12,6 @@
#define NDEBUG
#include <internal/debug.h>
/* LsaCallAuthenticationPackage@28 */
/*
* @unimplemented
*/
@ -29,7 +28,6 @@ NTSTATUS STDCALL LsaCallAuthenticationPackage (
return STATUS_NOT_IMPLEMENTED;
}
/* LsaDeregisterLogonProcess@8 */
/*
* @unimplemented
*/
@ -41,7 +39,6 @@ NTSTATUS STDCALL LsaDeregisterLogonProcess (
return STATUS_NOT_IMPLEMENTED;
}
/* LsaFreeReturnBuffer@4 */
/*
* @implemented
*/
@ -57,31 +54,29 @@ NTSTATUS STDCALL LsaFreeReturnBuffer (PVOID Buffer)
);
}
/* LsaLogonUser@56 */
/*
* @unimplemented
*/
NTSTATUS STDCALL LsaLogonUser (
ULONG Unknown0,
ULONG Unknown1,
ULONG Unknown2,
ULONG Unknown3,
ULONG Unknown4,
ULONG Unknown5,
ULONG Unknown6,
ULONG Unknown7,
ULONG Unknown8,
ULONG Unknown9,
ULONG Unknown10,
ULONG Unknown11,
ULONG Unknown12,
ULONG Unknown13
)
NTSTATUS
NTAPI
LsaLogonUser(IN HANDLE LsaHandle,
IN PLSA_STRING OriginName,
IN SECURITY_LOGON_TYPE LogonType,
IN ULONG AuthenticationPackage,
IN PVOID AuthenticationInformation,
IN ULONG AuthenticationInformationLength,
IN PTOKEN_GROUPS LocalGroups OPTIONAL,
IN PTOKEN_SOURCE SourceContext,
OUT PVOID *ProfileBuffer,
OUT PULONG ProfileBufferLength,
OUT PLUID LogonId,
OUT PHANDLE Token,
OUT PQUOTA_LIMITS Quotas,
OUT PNTSTATUS SubStatus)
{
return STATUS_NOT_IMPLEMENTED;
}
/* LsaLookupAuthenticationPackage@12 */
/*
* @unimplemented
*/
@ -94,15 +89,14 @@ NTSTATUS STDCALL LsaLookupAuthenticationPackage (
return STATUS_NOT_IMPLEMENTED;
}
/* LsaRegisterLogonProcess@12 */
/*
* @unimplemented
*/
NTSTATUS STDCALL LsaRegisterLogonProcess (
ULONG Unknown0,
ULONG Unknown1,
ULONG Unknown2
)
NTSTATUS
NTAPI
LsaRegisterLogonProcess (IN PLSA_STRING LogonProcessName,
OUT PHANDLE LsaHandle,
OUT PLSA_OPERATIONAL_MODE SecurityMode)
{
return STATUS_NOT_IMPLEMENTED;
}

View file

@ -2415,7 +2415,7 @@ SeTokenIsAdmin(
)
{
PAGED_CODE();
return (((PTOKEN)Token)->TokenFlags & TOKEN_HAS_ADMIN_GROUP) != 0;
return (((PTOKEN)Token)->TokenFlags & TOKEN_WRITE_RESTRICTED) != 0;
}
/*