Partial merge from the ROX-U branch (various fixes for Visual C++ compilation, see...
authorKJK::Hyperion <hackbunny@reactos.org>
Tue, 21 Jun 2005 23:42:58 +0000 (23:42 +0000)
committerKJK::Hyperion <hackbunny@reactos.org>
Tue, 21 Jun 2005 23:42:58 +0000 (23:42 +0000)
svn path=/trunk/; revision=16212

41 files changed:
reactos/ntoskrnl/cc/copy.c
reactos/ntoskrnl/cc/fs.c
reactos/ntoskrnl/ex/evtpair.c
reactos/ntoskrnl/ex/init.c
reactos/ntoskrnl/ex/sysinfo.c
reactos/ntoskrnl/fs/name.c
reactos/ntoskrnl/include/internal/arch/ke.h
reactos/ntoskrnl/include/internal/arch/mm.h
reactos/ntoskrnl/include/internal/arch/ps.h
reactos/ntoskrnl/include/internal/i386/ke.h
reactos/ntoskrnl/include/internal/ke.h
reactos/ntoskrnl/include/internal/ps.h
reactos/ntoskrnl/io/driver.c
reactos/ntoskrnl/io/iomgr.c
reactos/ntoskrnl/io/irp.c
reactos/ntoskrnl/io/wmi.c
reactos/ntoskrnl/ke/ipi.c
reactos/ntoskrnl/ke/kqueue.c
reactos/ntoskrnl/ke/main.c
reactos/ntoskrnl/ke/profile.c
reactos/ntoskrnl/ldr/loader.c
reactos/ntoskrnl/ldr/resource.c
reactos/ntoskrnl/ldr/rtl.c
reactos/ntoskrnl/mm/iospace.c
reactos/ntoskrnl/mm/process.c
reactos/ntoskrnl/mm/section.c
reactos/ntoskrnl/ob/handle.c
reactos/ntoskrnl/ps/kill.c
reactos/ntoskrnl/ps/psmgr.c
reactos/ntoskrnl/se/acl.c
reactos/ntoskrnl/se/luid.c
reactos/ntoskrnl/se/semgr.c
reactos/ntoskrnl/se/token.c
reactos/w32api/include/ddk/batclass.h
reactos/w32api/include/ddk/ntddk.h
reactos/w32api/include/ddk/ntifs.h
reactos/w32api/include/ddk/ntpoapi.h
reactos/w32api/include/ddk/winddk.h
reactos/w32api/include/ntdef.h
reactos/w32api/include/windef.h
reactos/w32api/include/winnt.h

index 224564f..07b1cae 100644 (file)
@@ -136,7 +136,7 @@ ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length,
          while (current2 != NULL && !current2->Valid && current_size < MAX_RW_LENGTH)
            {
              PVOID address = current2->BaseAddress;
-             for (i = 0; i < (Bcb->CacheSegmentSize / PAGE_SIZE); i++, address += PAGE_SIZE)
+             for (i = 0; i < (Bcb->CacheSegmentSize / PAGE_SIZE); i++, address = RVA(address, PAGE_SIZE))
                {
                  *MdlPages++ = MmGetPfnForProcess(NULL, address);
                }
index 170f061..bc5f3ba 100644 (file)
@@ -39,9 +39,8 @@ CcGetDirtyPages (
        IN      PVOID                   Context2
        )
 {
-       UNIMPLEMENTED;
-
        LARGE_INTEGER i;
+       UNIMPLEMENTED;
        i.QuadPart = 0;
        return i;
 }
@@ -69,9 +68,8 @@ CcGetLsnForFileObject (
        OUT     PLARGE_INTEGER  OldestLsn OPTIONAL
        )
 {
-       UNIMPLEMENTED;
-
        LARGE_INTEGER i;
+       UNIMPLEMENTED;
        i.QuadPart = 0;
        return i;
 }
index b3fd84f..a7467fd 100644 (file)
@@ -18,7 +18,7 @@
 
 /* GLOBALS *******************************************************************/
 
-POBJECT_TYPE EXPORTED ExEventPairObjectType = NULL;
+POBJECT_TYPE ExEventPairObjectType = NULL;
 
 static GENERIC_MAPPING ExEventPairMapping = {
     STANDARD_RIGHTS_READ,
index 765d0f8..2faf8a6 100644 (file)
@@ -496,7 +496,7 @@ ExpInitializeExecutive(VOID)
         KeCreateApplicationProcessorIdleThread(KeNumberProcessors);
 
         /* Allocate a stack for use when booting the processor */
-        ProcessorStack = Ki386InitialStackArray[((int)KeNumberProcessors)] + MM_STACK_SIZE;
+        ProcessorStack = RVA(Ki386InitialStackArray[((int)KeNumberProcessors)], MM_STACK_SIZE);
 
         /* Tell HAL a new CPU is being started */
         HalStartNextProcessor(0, (ULONG)ProcessorStack - 2*sizeof(FX_SAVE_AREA));
index 1288081..7a59fee 100644 (file)
@@ -835,6 +835,10 @@ ObpGetNextHandleByProcessCount(PSYSTEM_HANDLE_TABLE_ENTRY_INFO pshi,
 /* Class 16 - Handle Information */
 QSI_DEF(SystemHandleInformation)
 {
+       PEPROCESS pr, syspr;
+       int curSize, i = 0;
+       ULONG hCount = 0;
+
         PSYSTEM_HANDLE_INFORMATION Shi =
                (PSYSTEM_HANDLE_INFORMATION) Buffer;
 
@@ -848,10 +852,6 @@ QSI_DEF(SystemHandleInformation)
 
        DPRINT("SystemHandleInformation 1\n");
 
-       PEPROCESS pr, syspr;
-       int curSize, i = 0;
-       ULONG hCount = 0;
-
         /* First Calc Size from Count. */
         syspr = PsGetNextProcess(NULL);
        pr = syspr;
@@ -937,6 +937,7 @@ QSI_DEF(SystemObjectInformation)
 /* Class 18 -  Information */
 QSI_DEF(SystemPageFileInformation)
 {
+       UNICODE_STRING FileName; /* FIXME */
        SYSTEM_PAGEFILE_INFORMATION *Spfi = (SYSTEM_PAGEFILE_INFORMATION *) Buffer;
 
        if (Size < sizeof (SYSTEM_PAGEFILE_INFORMATION))
@@ -945,7 +946,6 @@ QSI_DEF(SystemPageFileInformation)
                return (STATUS_INFO_LENGTH_MISMATCH);
        }
 
-       UNICODE_STRING FileName; /* FIXME */
        RtlInitUnicodeString(&FileName, NULL); /* FIXME */
 
        /* FIXME */
index 821c1d3..31f54d1 100644 (file)
@@ -149,7 +149,7 @@ static UCHAR LegalAnsiCharacterArray[] =
   FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL     /*         0x7f */
 };
 
-PUCHAR EXPORTED FsRtlLegalAnsiCharacterArray = LegalAnsiCharacterArray;
+PUCHAR FsRtlLegalAnsiCharacterArray = LegalAnsiCharacterArray;
 
 /* FUNCTIONS *****************************************************************/
 
index 2973640..8cdcf9c 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_ARCH_KE_H
 #define __NTOSKRNL_INCLUDE_INTERNAL_ARCH_KE_H
 
-#ifdef i386
+#ifdef _M_IX86
 #include "../i386/ke.h"
 #else
 #error "Unknown processor"
index 1622a69..aded673 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_ARCH_MM_H
 #define __NTOSKRNL_INCLUDE_INTERNAL_ARCH_MM_H
 
-#ifdef i386
+#ifdef _M_IX86
 #include <internal/i386/mm.h>
 #else
 #error "Unknown processor"
index 028bb8c..f4b8bf6 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_ARCH_PS_H
 #define __NTOSKRNL_INCLUDE_INTERNAL_ARCH_PS_H
 
-#ifdef i386
+#ifdef _M_IX86
 #include <internal/i386/ps.h>
 #define KiArchContextSwitch          KiSwapContext
 #define KiArchInitThreadWithContext  Ke386InitThreadWithContext
index 1d79b32..1d71f29 100644 (file)
@@ -189,8 +189,7 @@ KeCreateApplicationProcessorIdleThread(ULONG Id);
 
 typedef
 VOID
-STDCALL
-(*PKSYSTEM_ROUTINE)(PKSTART_ROUTINE StartRoutine,
+(STDCALL*PKSYSTEM_ROUTINE)(PKSTART_ROUTINE StartRoutine,
                     PVOID StartContext);
 
 VOID
@@ -215,7 +214,7 @@ KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine,
 #define LOCK "lock ; "
 #else
 #define LOCK ""
-#define KeGetCurrentIrql(X) (((PKPCR)KPCR_BASE)->Irql)
+#define KeGetCurrentIrql() (((PKPCR)KPCR_BASE)->Irql)
 #endif
 
 #if defined(__GNUC__)
index 0484737..df46642 100644 (file)
@@ -224,13 +224,13 @@ struct _KEXCEPTION_FRAME;
 
 /* MACROS *************************************************************************/
 
-#define KeEnterCriticalRegion(X) \
+#define KeEnterCriticalRegion() \
 { \
     PKTHREAD _Thread = KeGetCurrentThread(); \
     if (_Thread) _Thread->KernelApcDisable--; \
 }
 
-#define KeLeaveCriticalRegion(X) \
+#define KeLeaveCriticalRegion() \
 { \
     PKTHREAD _Thread = KeGetCurrentThread(); \
     if((_Thread) && (++_Thread->KernelApcDisable == 0)) \
@@ -354,8 +354,8 @@ extern PLOADER_MODULE CachedModules[MaximumCachedModuleType];
 VOID STDCALL
 DbgBreakPointNoBugCheck(VOID);
 
-STDCALL
 VOID
+STDCALL
 KeInitializeProfile(struct _KPROFILE* Profile,
                     struct _KPROCESS* Process,
                     PVOID ImageBase,
@@ -364,21 +364,21 @@ KeInitializeProfile(struct _KPROFILE* Profile,
                     KPROFILE_SOURCE ProfileSource,
                     KAFFINITY Affinity);
 
-STDCALL
 VOID
+STDCALL
 KeStartProfile(struct _KPROFILE* Profile,
                PVOID Buffer);
 
-STDCALL
 VOID
+STDCALL
 KeStopProfile(struct _KPROFILE* Profile);
 
-STDCALL
 ULONG
+STDCALL
 KeQueryIntervalProfile(KPROFILE_SOURCE ProfileSource);
 
-STDCALL
 VOID
+STDCALL
 KeSetIntervalProfile(KPROFILE_SOURCE ProfileSource,
                      ULONG Interval);
 
index 9a74afb..e0392dc 100644 (file)
@@ -160,7 +160,7 @@ typedef struct _ETHREAD
            ULONG                   OwnsSessionWorkingSetShared:1;
            ULONG                   ApcNeeded:1;
         };
-        ULONG                      SameThreadPassiveFlags;      /* 248 */
+        ULONG                      SameThreadApcFlags;          /* 248 */
     };
     UCHAR                          ForwardClusterOnly;          /* 24C */
     UCHAR                          DisablePageFaultClustering;  /* 24D */
index ae6e22e..73d0106 100644 (file)
@@ -337,8 +337,8 @@ INIT_FUNCTION
 IopDisplayLoadingMessage(PVOID ServiceName, 
                          BOOLEAN Unicode)
 {
-    if (SetupMode) return;
     CHAR TextBuffer[256];
+    if (SetupMode) return;
     if (Unicode) 
     {
         sprintf(TextBuffer, "Loading %S...\n", (PWCHAR)ServiceName);
index 995d792..b5615aa 100644 (file)
 
 /* DATA ********************************************************************/
 
-POBJECT_TYPE EXPORTED IoDeviceObjectType = NULL;
-POBJECT_TYPE EXPORTED IoFileObjectType = NULL;
+POBJECT_TYPE IoDeviceObjectType = NULL;
+POBJECT_TYPE IoFileObjectType = NULL;
 extern POBJECT_TYPE IoControllerObjectType;
-ULONG         EXPORTED IoReadOperationCount = 0;
-LARGE_INTEGER EXPORTED IoReadTransferCount = {{0, 0}};
-ULONG         EXPORTED IoWriteOperationCount = 0;
-LARGE_INTEGER EXPORTED IoWriteTransferCount = {{0, 0}};
-ULONG                  IoOtherOperationCount = 0;
-LARGE_INTEGER          IoOtherTransferCount = {{0, 0}};
-KSPIN_LOCK    EXPORTED IoStatisticsLock = 0;
+ULONG IoReadOperationCount = 0;
+LARGE_INTEGER IoReadTransferCount = {{0, 0}};
+ULONG IoWriteOperationCount = 0;
+LARGE_INTEGER IoWriteTransferCount = {{0, 0}};
+ULONG IoOtherOperationCount = 0;
+LARGE_INTEGER IoOtherTransferCount = {{0, 0}};
+KSPIN_LOCK IoStatisticsLock = 0;
 
 GENERIC_MAPPING IopFileMapping = {
     FILE_GENERIC_READ,
index 2758e35..7b67572 100644 (file)
@@ -619,13 +619,6 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
             }
 
             /* Probe and Lock */
-            _SEH_FILTER(FreeAndGoOn)
-            {
-                /* Free the IRP and its MDL */
-                IoFreeMdl(Irp->MdlAddress);
-                IoFreeIrp(Irp);
-                return EXCEPTION_CONTINUE_SEARCH;
-             }
             _SEH_TRY
             {
                 /* Do the probe */
index 61ff4b3..d1894c4 100644 (file)
@@ -19,8 +19,8 @@
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 IoWMIRegistrationControl(
     IN PDEVICE_OBJECT DeviceObject,
     IN ULONG Action
@@ -33,8 +33,8 @@ IoWMIRegistrationControl(
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 IoWMIAllocateInstanceIds(
     IN GUID *Guid,
     IN ULONG InstanceCount,
@@ -48,8 +48,8 @@ IoWMIAllocateInstanceIds(
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 IoWMISuggestInstanceName(
     IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
     IN PUNICODE_STRING SymbolicLinkName OPTIONAL,
@@ -64,8 +64,8 @@ IoWMISuggestInstanceName(
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 IoWMIWriteEvent(
     IN PVOID WnodeEventItem
     )
@@ -77,8 +77,8 @@ IoWMIWriteEvent(
 /*
  * @unimplemented
  */
-STDCALL
-NTSTATUS IoWMIOpenBlock(
+NTSTATUS
+STDCALL IoWMIOpenBlock(
     IN GUID *DataBlockGuid,
     IN ULONG DesiredAccess,
     OUT PVOID *DataBlockObject
@@ -91,8 +91,8 @@ NTSTATUS IoWMIOpenBlock(
 /*
  * @unimplemented
  */
-STDCALL
-NTSTATUS IoWMIQueryAllData(
+NTSTATUS
+STDCALL IoWMIQueryAllData(
     IN PVOID DataBlockObject,
     IN OUT ULONG *InOutBufferSize,
     OUT PVOID OutBuffer
@@ -105,8 +105,8 @@ NTSTATUS IoWMIQueryAllData(
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 IoWMIQueryAllDataMultiple(
     IN PVOID *DataBlockObjectList,
     IN ULONG ObjectCount,
@@ -121,8 +121,8 @@ IoWMIQueryAllDataMultiple(
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 IoWMIQuerySingleInstance(
     IN PVOID DataBlockObject,
     IN PUNICODE_STRING InstanceName,
@@ -137,8 +137,8 @@ IoWMIQuerySingleInstance(
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 IoWMIQuerySingleInstanceMultiple(
     IN PVOID *DataBlockObjectList,
     IN PUNICODE_STRING InstanceNames,
@@ -154,8 +154,8 @@ IoWMIQuerySingleInstanceMultiple(
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 IoWMISetSingleInstance(
     IN PVOID DataBlockObject,
     IN PUNICODE_STRING InstanceName,
@@ -171,8 +171,8 @@ IoWMISetSingleInstance(
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 IoWMISetSingleItem(
     IN PVOID DataBlockObject,
     IN PUNICODE_STRING InstanceName,
@@ -189,8 +189,8 @@ IoWMISetSingleItem(
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 IoWMIExecuteMethod(
     IN PVOID DataBlockObject,
     IN PUNICODE_STRING InstanceName,
@@ -207,8 +207,8 @@ IoWMIExecuteMethod(
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 IoWMISetNotificationCallback(
     IN PVOID Object,
     IN WMI_NOTIFICATION_CALLBACK Callback,
@@ -222,8 +222,8 @@ IoWMISetNotificationCallback(
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 IoWMIHandleToInstanceName(
     IN PVOID DataBlockObject,
     IN HANDLE FileHandle,
@@ -237,8 +237,8 @@ IoWMIHandleToInstanceName(
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 IoWMIDeviceObjectToInstanceName(
     IN PVOID DataBlockObject,
     IN PDEVICE_OBJECT DeviceObject,
index 4aae8a6..1402e20 100644 (file)
@@ -89,7 +89,7 @@ KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame,
 #endif
          }
       }
-      ((VOID STDCALL(*)(PVOID))(Prcb->SignalDone->WorkerRoutine))(Prcb->SignalDone->CurrentPacket[0]);
+      ((VOID (STDCALL*)(PVOID))(Prcb->SignalDone->WorkerRoutine))(Prcb->SignalDone->CurrentPacket[0]);
       Ke386TestAndClearBit(KeGetCurrentProcessorNumber(), &Prcb->SignalDone->TargetSet);
       if (InterlockedCompareExchangeUL(&Prcb->SignalDone->CurrentPacket[2], 0, 0))
       {
@@ -116,7 +116,7 @@ KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame,
 
 VOID
 STDCALL
-KiIpiSendPacket(ULONG TargetSet, VOID STDCALL (*WorkerRoutine)(PVOID), PVOID Argument, ULONG Count, BOOLEAN Synchronize)
+KiIpiSendPacket(ULONG TargetSet, VOID (STDCALL*WorkerRoutine)(PVOID), PVOID Argument, ULONG Count, BOOLEAN Synchronize)
 {
     ULONG i, Processor, CurrentProcessor;
     PKPRCB Prcb, CurrentPrcb;
index 1ef6d26..168f465 100644 (file)
@@ -245,8 +245,8 @@ KeRemoveByKeyDeviceQueue (IN PKDEVICE_QUEUE DeviceQueue,
 /*
  * @unimplemented
  */
-STDCALL
 PKDEVICE_QUEUE_ENTRY
+STDCALL
 KeRemoveByKeyDeviceQueueIfBusy(IN PKDEVICE_QUEUE DeviceQueue,
                                IN ULONG SortKey)
 {
index cb2dba1..75f1a6c 100644 (file)
@@ -82,7 +82,9 @@ KeGetRecommendedSharedDataAlignment(VOID)
 }
 
 VOID
+#ifdef __GNUC__
 __attribute((noinline))
+#endif
 KiSystemStartup(BOOLEAN BootProcessor)
 {
     DPRINT("KiSystemStartup(%d)\n", BootProcessor);
index 25ba7fc..ca79123 100644 (file)
@@ -22,8 +22,8 @@ ULONG KiProfileTimeInterval = 78125; /* Default resolution 7.8ms (sysinternals)
 
 /* FUNCTIONS *****************************************************************/
 
-STDCALL
 VOID
+STDCALL
 KeInitializeProfile(PKPROFILE Profile,
                     PKPROCESS Process,
                     PVOID ImageBase,
@@ -40,14 +40,14 @@ KeInitializeProfile(PKPROFILE Profile,
     Profile->Process = Process;
     Profile->RegionStart = ImageBase;
     Profile->BucketShift = BucketSize - 2; /* See ntinternals.net -- Alex */
-    Profile->RegionEnd = (PVOID)(ULONG_PTR)ImageBase + ImageSize;
+    Profile->RegionEnd = (PVOID)((ULONG_PTR)ImageBase + ImageSize);
     Profile->Active = FALSE;
     Profile->Source = ProfileSource;
     Profile->Affinity = Affinity;
 }
 
-STDCALL
 VOID
+STDCALL
 KeStartProfile(PKPROFILE Profile,
                PVOID Buffer)
 {
@@ -133,8 +133,8 @@ KeStartProfile(PKPROFILE Profile,
     if (!FreeBuffer) ExFreePool(SourceBuffer);
 }
 
-STDCALL
 VOID
+STDCALL
 KeStopProfile(PKPROFILE Profile)
 {
     KIRQL OldIrql;
@@ -178,8 +178,8 @@ KeStopProfile(PKPROFILE Profile)
     if (CurrentSource) ExFreePool(CurrentSource);
 }
 
-STDCALL
 ULONG
+STDCALL
 KeQueryIntervalProfile(KPROFILE_SOURCE ProfileSource)
 {
     /* Check if this is the timer profile */
@@ -200,8 +200,8 @@ KeQueryIntervalProfile(KPROFILE_SOURCE ProfileSource)
     }
 }
 
-STDCALL
 VOID
+STDCALL
 KeSetIntervalProfile(KPROFILE_SOURCE ProfileSource,
                      ULONG Interval)
 {
@@ -224,8 +224,8 @@ KeSetIntervalProfile(KPROFILE_SOURCE ProfileSource,
 /*
  * @implemented
  */
-STDCALL
 VOID
+STDCALL
 KeProfileInterrupt(PKTRAP_FRAME TrapFrame)
 {
     /* Called from HAL for Timer Profiling */
@@ -257,7 +257,7 @@ KiParseProfileList(IN PKTRAP_FRAME TrapFrame,
         }
 
         /* Get the Pointer to the Bucket Value representing this EIP */
-        BucketValue = (PULONG)(((ULONG_PTR)(Profile->Buffer +
+        BucketValue = (PULONG)((((ULONG_PTR)Profile->Buffer +
                                (TrapFrame->Eip - (ULONG_PTR)Profile->RegionStart))
                                 >> Profile->BucketShift) &~ 0x3);
 
@@ -276,8 +276,8 @@ KiParseProfileList(IN PKTRAP_FRAME TrapFrame,
  *         from the trap frame into the buffer, while using buckets and
  *         shifting like we specified. -- Alex
  */
-STDCALL
 VOID
+STDCALL
 KeProfileInterruptWithSource(IN PKTRAP_FRAME TrapFrame,
                              IN KPROFILE_SOURCE Source)
 {
@@ -291,8 +291,8 @@ KeProfileInterruptWithSource(IN PKTRAP_FRAME TrapFrame,
 /*
  * @implemented
  */
-STDCALL
 VOID
+STDCALL
 KeSetProfileIrql(IN KIRQL ProfileIrql)
 {
     /* Set the IRQL at which Profiling will run */
index 416a18c..6a5d6b1 100644 (file)
@@ -910,7 +910,7 @@ LdrPEProcessModule(
             Protect = PAGE_EXECUTE_READWRITE;
         }
 #endif
-        if (PageAddress < DriverBase + DriverSize)
+        if (PageAddress < RVA(DriverBase, DriverSize))
         {
             MmSetPageProtect(NULL, PageAddress, Protect);
         }
@@ -937,14 +937,14 @@ LdrPEProcessModule(
         PageAddress = (PVOID)((ULONG_PTR)PageAddress + PAGE_SIZE);
         while ((ULONG_PTR)PageAddress + PAGE_SIZE < (ULONG_PTR)BaseAddress + Length)
         {
-            if (PageAddress < DriverBase + DriverSize)
+            if (PageAddress < RVA(DriverBase, DriverSize))
             {
                 MmSetPageProtect(NULL, PageAddress, Protect);
             }
             PageAddress = (PVOID)((ULONG_PTR)PageAddress + PAGE_SIZE);
         }
         if (PageAddress < (PVOID)((ULONG_PTR)BaseAddress + Length) &&
-            PageAddress < DriverBase + DriverSize)
+            PageAddress < RVA(DriverBase, DriverSize))
         {
             Protect = LdrLookupPageProtection(PageAddress, DriverBase, &PENtHeaders->FileHeader, PESectionHeaders);
             MmSetPageProtect(NULL, PageAddress, Protect);
@@ -1214,20 +1214,20 @@ LdrPEPerformRelocations (
     Delta = (ULONG_PTR)DriverBase - NtHeaders->OptionalHeader.ImageBase;
     RelocationDir = (PIMAGE_BASE_RELOCATION)((ULONG_PTR)DriverBase + RelocationDDir->VirtualAddress);
     RelocationEnd = (PIMAGE_BASE_RELOCATION)((ULONG_PTR)RelocationDir + RelocationDDir->Size);
-    MaxAddress = DriverBase + DriverSize;
+    MaxAddress = RVA(DriverBase, DriverSize);
 
     while (RelocationDir < RelocationEnd &&
         RelocationDir->SizeOfBlock > 0)
     {
         Count = (RelocationDir->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / sizeof(USHORT);
-        Address = DriverBase + RelocationDir->VirtualAddress;
+        Address = RVA(DriverBase, RelocationDir->VirtualAddress);
         TypeOffset = (PUSHORT)(RelocationDir + 1);
 
         for (i = 0; i < Count; i++)
         {
             Offset = *TypeOffset & 0xFFF;
             Type = *TypeOffset >> 12;
-            ShortPtr = (PUSHORT)(Address + Offset);
+            ShortPtr = (PUSHORT)(RVA(Address, Offset));
 
             /* Don't relocate after the end of the loaded driver */
             if ((PVOID)ShortPtr >= MaxAddress)
@@ -1276,6 +1276,9 @@ LdrPEPerformRelocations (
 
     return STATUS_SUCCESS;
 }
+#ifndef PATH_MAX
+#define PATH_MAX 260
+#endif
 
 static NTSTATUS
 LdrPEGetOrLoadModule (
@@ -1552,16 +1555,16 @@ LdrPEProcessImportDirectoryEntry(
     }
 
     /* Get the import address list. */
-    ImportAddressList = (PVOID*)(DriverBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk);
+    ImportAddressList = (PVOID*)RVA(DriverBase, ImportModuleDirectory->FirstThunk);
 
     /* Get the list of functions to import. */
     if (ImportModuleDirectory->OriginalFirstThunk != 0)
     {
-        FunctionNameList = (PULONG) (DriverBase + (ULONG_PTR)ImportModuleDirectory->OriginalFirstThunk);
+        FunctionNameList = (PULONG)RVA(DriverBase, ImportModuleDirectory->OriginalFirstThunk);
     }
     else
     {
-        FunctionNameList = (PULONG)(DriverBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk);
+        FunctionNameList = (PULONG)RVA(DriverBase, ImportModuleDirectory->FirstThunk);
     }
 
     /* Walk through function list and fixup addresses. */
index feffb09..a4444f6 100644 (file)
@@ -195,8 +195,8 @@ found:;
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 LdrFindResourceDirectory_U(
        IN PVOID        BaseAddress,
        IN PLDR_RESOURCE_INFO                   ResourceInfo,
@@ -211,8 +211,8 @@ LdrFindResourceDirectory_U(
 /*
  * @unimplemented
  */
-STDCALL
 NTSTATUS
+STDCALL
 LdrEnumResources(
        IN PVOID        BaseAddress,
        IN PLDR_RESOURCE_INFO                   ResourceInfo,
index af5e2c7..cd6a542 100644 (file)
@@ -17,8 +17,6 @@
 
 /* FUNCTIONS ****************************************************************/
 
-#define RVA(m, b) ((ULONG)b + m)
-
 NTSTATUS STDCALL
 LdrGetProcedureAddress (IN PVOID BaseAddress,
                         IN PANSI_STRING Name,
index 8e12f1c..7e8e4a7 100644 (file)
@@ -145,7 +145,7 @@ MmUnmapIoSpace (IN PVOID BaseAddress,
    PVOID Address = BaseAddress;
 
    Offset = (ULONG_PTR)Address % PAGE_SIZE;
-   Address -= Offset;
+   Address = RVA(Address, - Offset);
    NumberOfBytes += Offset;
 
    MmLockAddressSpace(MmGetKernelAddressSpace());
index b4b4bf8..1139e05 100644 (file)
@@ -28,8 +28,8 @@ MiCreatePebOrTeb(PEPROCESS Process,
     PMADDRESS_SPACE ProcessAddressSpace = &Process->AddressSpace;
     PMEMORY_AREA MemoryArea;
     PHYSICAL_ADDRESS BoundaryAddressMultiple;
-    BoundaryAddressMultiple.QuadPart = 0;
     PVOID AllocatedBase = BaseAddress;
+    BoundaryAddressMultiple.QuadPart = 0;
 
     /* Acquire the Lock */
     MmLockAddressSpace(ProcessAddressSpace);
@@ -54,7 +54,7 @@ MiCreatePebOrTeb(PEPROCESS Process,
                                     TRUE,
                                     FALSE,
                                     BoundaryAddressMultiple);
-        AllocatedBase = AllocatedBase - PAGE_SIZE;
+        AllocatedBase = RVA(AllocatedBase, -PAGE_SIZE);
     } while (Status != STATUS_SUCCESS);
 
     /* Initialize the Region */
@@ -69,7 +69,7 @@ MiCreatePebOrTeb(PEPROCESS Process,
     /* Unlock Address Space */
     DPRINT("Returning\n");
     MmUnlockAddressSpace(ProcessAddressSpace);
-    return AllocatedBase + PAGE_SIZE;
+    return RVA(AllocatedBase, PAGE_SIZE);
 }
 
 VOID
@@ -345,9 +345,9 @@ MmCreateProcessAddressSpace(IN PEPROCESS Process,
     PVOID BaseAddress;
     PMEMORY_AREA MemoryArea;
     PHYSICAL_ADDRESS BoundaryAddressMultiple;
-    BoundaryAddressMultiple.QuadPart = 0;
     ULONG ViewSize = 0;
     PVOID ImageBase = 0;
+    BoundaryAddressMultiple.QuadPart = 0;
 
     /* Initialize the Addresss Space */
     MmInitializeAddressSpace(Process, ProcessAddressSpace);
index 82842f8..fa26807 100644 (file)
@@ -1952,7 +1952,7 @@ MmQuerySectionView(PMEMORY_AREA MemoryArea,
    if (Section->AllocationAttributes & SEC_IMAGE)
    {
       Segment = MemoryArea->Data.SectionData.Segment;
-      Info->AllocationBase = MemoryArea->StartingAddress - Segment->VirtualAddress;
+      Info->AllocationBase = (PBYTE)MemoryArea->StartingAddress - Segment->VirtualAddress;
       Info->Type = MEM_IMAGE;
    }
    else
index 21e7bd7..f732cfa 100644 (file)
@@ -60,8 +60,8 @@ static VOID
 ObpDecrementHandleCount(PVOID ObjectBody)
 {
   POBJECT_HEADER ObjectHeader = BODY_TO_HEADER(ObjectBody);
-  DPRINT("Header: %x\n", ObjectHeader);
   LONG NewHandleCount = InterlockedDecrement(&ObjectHeader->HandleCount);
+  DPRINT("Header: %x\n", ObjectHeader);
   DPRINT("NewHandleCount: %x\n", NewHandleCount);
   DPRINT("HEADER_TO_OBJECT_NAME: %x\n", HEADER_TO_OBJECT_NAME(ObjectHeader));
 
@@ -1008,15 +1008,15 @@ ObInsertObject(IN PVOID Object,
     if (FoundHeader && FoundHeader->Type == ObDirectoryType &&
         RemainingPath.Buffer)
     {
-        ObpAddEntryDirectory(FoundObject, Header, NULL);
-        ObjectAttached = TRUE;
-        
         /* The name was changed so let's update it */
         /* FIXME: TEMPORARY HACK This will go in ObFindObject in the next commit */
         PVOID NewName;
         PWSTR BufferPos = RemainingPath.Buffer;
         ULONG Delta = 0;
         
+        ObpAddEntryDirectory(FoundObject, Header, NULL);
+        ObjectAttached = TRUE;
+        
         ObjectNameInfo = HEADER_TO_OBJECT_NAME(Header);
         
         if (BufferPos[0] == L'\\')
index b4cc394..a54252e 100644 (file)
@@ -24,8 +24,8 @@ extern FAST_MUTEX PspActiveProcessMutex;
 
 /* FUNCTIONS *****************************************************************/
 
-STDCALL
 VOID
+STDCALL
 PspReapRoutine(PVOID Context)
 {
     KIRQL OldIrql;
index a19d8ea..45d9436 100644 (file)
@@ -173,8 +173,7 @@ PsInitProcessManagment(VOID)
                                ProcessObject,
                                sizeof(EPROCESS),
                                FALSE);
-   PsIdleProcess->Pcb.DirectoryTableBase =
-     (LARGE_INTEGER)(LONGLONG)(ULONG)MmGetPageDirectory();
+   PsIdleProcess->Pcb.DirectoryTableBase.QuadPart = (ULONG_PTR)MmGetPageDirectory();
    strcpy(PsIdleProcess->ImageFileName, "Idle");
 
    /*
@@ -234,6 +233,7 @@ PsInitProcessManagment(VOID)
    InitializeListHead(&PsInitialSystemProcess->ThreadListHead);
 
 #ifndef SCHED_REWRITE
+    {
     PTOKEN BootToken;
 
     /* No parent, this is the Initial System Process. Assign Boot Token */
@@ -241,6 +241,7 @@ PsInitProcessManagment(VOID)
     BootToken->TokenInUse = TRUE;
     PsInitialSystemProcess->Token.Object = BootToken; /* FIXME */
     ObReferenceObject(BootToken);
+       }
 #endif
 }
 
index ad72525..95ff38e 100644 (file)
@@ -15,8 +15,8 @@
 
 /* GLOBALS ******************************************************************/
 
-PACL EXPORTED SePublicDefaultDacl = NULL;
-PACL EXPORTED SeSystemDefaultDacl = NULL;
+PACL SePublicDefaultDacl = NULL;
+PACL SeSystemDefaultDacl = NULL;
 
 PACL SePublicDefaultUnrestrictedDacl = NULL;
 PACL SePublicOpenDacl = NULL;
index a247174..6631c85 100644 (file)
@@ -39,7 +39,7 @@ ExpAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
   /* atomically increment the luid */
   do
   {
-    PrevLuid = (volatile LARGE_INTEGER)LuidValue;
+    PrevLuid = LuidValue;
     NewLuid = RtlLargeIntegerAdd(PrevLuid,
                                  LuidIncrement);
   } while(ExfInterlockedCompareExchange64(&LuidValue.QuadPart,
index f58be6a..3278bbc 100644 (file)
@@ -16,7 +16,7 @@
 
 /* GLOBALS ******************************************************************/
 
-PSE_EXPORTS EXPORTED SeExports = NULL;
+PSE_EXPORTS SeExports = NULL;
 SE_EXPORTS SepExports;
 
 static ERESOURCE SepSubjectContextLock;
index fcf4849..ad41dd4 100644 (file)
@@ -1820,17 +1820,19 @@ SepCreateSystemProcessToken(VOID)
   NTSTATUS Status;
   ULONG uSize;
   ULONG i;
+  ULONG uLocalSystemLength;
+  ULONG uWorldLength;
+  ULONG uAuthUserLength;
+  ULONG uAdminsLength;
+  PTOKEN AccessToken;
+  PVOID SidArea;
 
   PAGED_CODE();
 
-  ULONG uLocalSystemLength = RtlLengthSid(SeLocalSystemSid);
-  ULONG uWorldLength       = RtlLengthSid(SeWorldSid);
-  ULONG uAuthUserLength    = RtlLengthSid(SeAuthenticatedUserSid);
-  ULONG uAdminsLength      = RtlLengthSid(SeAliasAdminsSid);
-
-  PTOKEN AccessToken;
-
-  PVOID SidArea;
+  uLocalSystemLength = RtlLengthSid(SeLocalSystemSid);
+  uWorldLength       = RtlLengthSid(SeWorldSid);
+  uAuthUserLength    = RtlLengthSid(SeAuthenticatedUserSid);
+  uAdminsLength      = RtlLengthSid(SeAliasAdminsSid);
 
  /*
   * Initialize the token
index 065886c..769bfe9 100644 (file)
@@ -183,12 +183,12 @@ typedef struct _BATTERY_WAIT_STATUS {
   CTL_CODE(FILE_DEVICE_BATTERY, 0x13, METHOD_BUFFERED, FILE_READ_ACCESS)
 
 
-typedef NTSTATUS DDKAPI
-(*BCLASS_DISABLE_STATUS_NOTIFY)(
+typedef NTSTATUS
+(DDKAPI*BCLASS_DISABLE_STATUS_NOTIFY)(
   IN PVOID  Context);
 
-typedef NTSTATUS DDKAPI
-(*BCLASS_QUERY_INFORMATION)(
+typedef NTSTATUS
+(DDKAPI*BCLASS_QUERY_INFORMATION)(
   IN PVOID  Context,
   IN ULONG  BatteryTag,
   IN BATTERY_QUERY_INFORMATION_LEVEL  Level,
@@ -197,26 +197,26 @@ typedef NTSTATUS DDKAPI
   IN ULONG  BufferLength,
   OUT PULONG  ReturnedLength);
 
-typedef NTSTATUS DDKAPI
-(*BCLASS_QUERY_STATUS)(
+typedef NTSTATUS
+(DDKAPI*BCLASS_QUERY_STATUS)(
   IN PVOID  Context,
   IN ULONG  BatteryTag,
   OUT PBATTERY_STATUS  BatteryStatus);
 
-typedef NTSTATUS DDKAPI
-(*BCLASS_QUERY_TAG)(
+typedef NTSTATUS
+(DDKAPI*BCLASS_QUERY_TAG)(
   IN PVOID  Context,
   OUT PULONG  BatteryTag);
 
-typedef NTSTATUS DDKAPI
-(*BCLASS_SET_INFORMATION)(
+typedef NTSTATUS
+(DDKAPI*BCLASS_SET_INFORMATION)(
   IN PVOID  Context,
   IN ULONG  BatteryTag,
   IN BATTERY_SET_INFORMATION_LEVEL  Level,
   IN PVOID  Buffer  OPTIONAL);
 
-typedef NTSTATUS DDKAPI
-(*BCLASS_SET_STATUS_NOTIFY)(
+typedef NTSTATUS
+(DDKAPI*BCLASS_SET_STATUS_NOTIFY)(
   IN PVOID  Context,
   IN ULONG  BatteryTag,
   IN PBATTERY_NOTIFY  BatteryNotify);
index 20a3ac2..5162deb 100644 (file)
@@ -50,11 +50,11 @@ typedef CONST char *PCSZ;
 #endif
 
 #ifndef DECL_IMPORT
-#define DECL_IMPORT __attribute__((dllimport))
+#define DECL_IMPORT __declspec(dllimport)
 #endif
 
 #ifndef DECL_EXPORT
-#define DECL_EXPORT __attribute__((dllexport))
+#define DECL_EXPORT __declspec(dllexport)
 #endif
 
 /* Windows NT status codes */
index 40a4169..305e9bd 100644 (file)
@@ -585,7 +585,7 @@ typedef struct _KAPC_STATE {
     BOOLEAN     KernelApcInProgress;
     BOOLEAN     KernelApcPending;
     BOOLEAN     UserApcPending;
-} KAPC_STATE, *PKAPC_STATE, *__restrict PRKAPC_STATE;
+} KAPC_STATE, *PKAPC_STATE, *RESTRICTED_POINTER PRKAPC_STATE;
 
 #if (VER_PRODUCTBUILD >= 2600)
 
@@ -2291,15 +2291,15 @@ FsRtlCheckLockForWriteAccess (
 );
 
 typedef
-VOID NTAPI
-(*POPLOCK_WAIT_COMPLETE_ROUTINE) (
+VOID
+(NTAPI*POPLOCK_WAIT_COMPLETE_ROUTINE) (
     IN PVOID    Context,
     IN PIRP     Irp
 );
 
 typedef
-VOID NTAPI
-(*POPLOCK_FS_PREPOST_IRP) (
+VOID
+(NTAPI*POPLOCK_FS_PREPOST_IRP) (
     IN PVOID    Context,
     IN PIRP     Irp
 );
index 1e56fd4..3dacf56 100644 (file)
@@ -43,8 +43,8 @@ typedef struct _PROCESSOR_IDLE_TIMES {
        ULONG  IdleHandlerReserved[4];
 } PROCESSOR_IDLE_TIMES, *PPROCESSOR_IDLE_TIMES;
 
-typedef BOOLEAN DDKFASTAPI
-(*PPROCESSOR_IDLE_HANDLER)(
+typedef BOOLEAN
+(DDKFASTAPI*PPROCESSOR_IDLE_HANDLER)(
   IN OUT PPROCESSOR_IDLE_TIMES IdleTimes);
 
 typedef struct _PROCESSOR_IDLE_HANDLER_INFO {
@@ -52,12 +52,12 @@ typedef struct _PROCESSOR_IDLE_HANDLER_INFO {
   PPROCESSOR_IDLE_HANDLER  Handler;
 } PROCESSOR_IDLE_HANDLER_INFO, *PPROCESSOR_IDLE_HANDLER_INFO;
 
-typedef VOID DDKFASTAPI
-(*PSET_PROCESSOR_THROTTLE)(
+typedef VOID
+(DDKFASTAPI*PSET_PROCESSOR_THROTTLE)(
   IN UCHAR  Throttle);
 
-typedef NTSTATUS DDKFASTAPI
-(*PSET_PROCESSOR_THROTTLE2)(
+typedef NTSTATUS
+(DDKFASTAPI*PSET_PROCESSOR_THROTTLE2)(
   IN UCHAR  Throttle);
 
 #define MAX_IDLE_HANDLERS                 3
@@ -81,12 +81,12 @@ typedef enum _POWER_STATE_HANDLER_TYPE {
        PowerStateMaximum
 } POWER_STATE_HANDLER_TYPE, *PPOWER_STATE_HANDLER_TYPE;
 
-typedef NTSTATUS DDKAPI
-(*PENTER_STATE_SYSTEM_HANDLER)(
+typedef NTSTATUS
+(DDKAPI*PENTER_STATE_SYSTEM_HANDLER)(
   IN PVOID  SystemContext);
 
-typedef NTSTATUS DDKAPI
-(*PENTER_STATE_HANDLER)(
+typedef NTSTATUS
+(DDKAPI*PENTER_STATE_HANDLER)(
   IN PVOID  Context,
   IN PENTER_STATE_SYSTEM_HANDLER  SystemHandler  OPTIONAL,
   IN PVOID  SystemContext,
@@ -101,8 +101,8 @@ typedef struct _POWER_STATE_HANDLER {
        PVOID  Context;
 } POWER_STATE_HANDLER, *PPOWER_STATE_HANDLER;
 
-typedef NTSTATUS STDCALL
-(*PENTER_STATE_NOTIFY_HANDLER)(
+typedef NTSTATUS
+(STDCALL*PENTER_STATE_NOTIFY_HANDLER)(
   IN POWER_STATE_HANDLER_TYPE  State,
   IN PVOID  Context,
   IN BOOLEAN  Entering);
index 66c6bd5..0bb6292 100644 (file)
@@ -34,9 +34,9 @@ extern "C" {
 /*
 ** Definitions specific to this Device Driver Kit
 */
-#define DDKAPI __attribute__((stdcall))
-#define DDKFASTAPI __attribute__((fastcall))
-#define DDKCDECLAPI __attribute__((cdecl))
+#define DDKAPI __stdcall
+#define DDKFASTAPI __fastcall
+#define DDKCDECLAPI __cdecl
 
 #if defined(_NTOSKRNL_)
 #ifndef NTOSAPI
@@ -128,11 +128,15 @@ static __inline struct _KPCR * KeGetCurrentKPCR(
   VOID)
 {
   ULONG Value;
-
+#if defined(__GNUC__)
   __asm__ __volatile__ ("movl %%fs:0x1C, %0\n\t"
          : "=r" (Value)
     : /* no inputs */
   );
+#elif defined(_MSC_VER)
+  __asm mov eax, fs:[1Ch]
+  __asm mov [Value], eax
+#endif
   return (struct _KPCR *) Value;
 }
 
@@ -140,11 +144,15 @@ static __inline struct _KPRCB * KeGetCurrentPrcb(
   VOID)
 {
   ULONG Value;
-
+#if defined(__GNUC__)
   __asm__ __volatile__ ("movl %%fs:0x20, %0\n\t"
          : "=r" (Value)
     : /* no inputs */
   );
+#elif defined(_MSC_VER)
+  __asm mov eax, fs:[20h]
+  __asm mov [Value], eax
+#endif
   return (struct _KPRCB *) Value;
 }
 
@@ -4331,8 +4339,8 @@ typedef struct _DISK_SIGNATURE {
   } DUMMYUNIONNAME;
 } DISK_SIGNATURE, *PDISK_SIGNATURE;
 
-typedef VOID DDKFASTAPI
-(*PTIME_UPDATE_NOTIFY_ROUTINE)(
+typedef VOID
+(DDKFASTAPI*PTIME_UPDATE_NOTIFY_ROUTINE)(
   IN HANDLE  ThreadId,
   IN KPROCESSOR_MODE  Mode);
 
@@ -8088,7 +8096,11 @@ KeMemoryBarrier(
   VOID)
 {
   volatile LONG Barrier;
+#if defined(__GNUC__)
   __asm__ __volatile__ ("xchg %%eax, %0" : : "m" (Barrier) : "%eax");
+#elif defined(_MSC_VER)
+  __asm xchg [Barrier], eax
+#endif
 }
 
 NTOSAPI
index 6579264..087e1a3 100644 (file)
@@ -3,6 +3,9 @@
 #if __GNUC__ >=3
 #pragma GCC system_header
 #endif
+/* TODO: some compilers support this */
+#define RESTRICTED_POINTER
 
 #define NTAPI __stdcall
 #define OBJ_INHERIT          0x00000002
index 0fc53b6..9260130 100644 (file)
@@ -118,6 +118,9 @@ extern "C" {
 #elif defined(__WATCOMC__)
 #define DECLSPEC_NORETURN
 #define DECLARE_STDCALL_P( type ) type __stdcall
+#elif defined(_MSC_VER)
+#define DECLSPEC_NORETURN __declspec(noreturn)
+#define DECLARE_STDCALL_P( type ) type __stdcall
 #endif /* __GNUC__/__WATCOMC__ */
 #define MAKEWORD(a,b)  ((WORD)(((BYTE)(a))|(((WORD)((BYTE)(b)))<<8)))
 #define MAKELONG(a,b)  ((LONG)(((WORD)(a))|(((DWORD)((WORD)(b)))<<16)))
@@ -160,7 +163,7 @@ extern "C" {
 #endif /* __cplusplus */
 #endif /* __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) */
 #endif /* NONAMELESSUNION */
-#elif defined(__WATCOMC__)
+#elif defined(__WATCOMC__) || defined(_MSC_VER)
 #define _ANONYMOUS_UNION
 #define _ANONYMOUS_STRUCT
 #endif /* __GNUC__/__WATCOMC__ */
index 4734ed4..29d698b 100644 (file)
@@ -1358,7 +1358,7 @@ typedef struct _GUID {
        unsigned short Data3;
        unsigned char  Data4[8];
 } GUID, *REFGUID, *LPGUID;
-#define SYSTEM_LUID { QuadPart:999 }
+#define SYSTEM_LUID { 0x3E7, 0x0 }
 #endif /* GUID_DEFINED */
 
 /* ACE Access Types, also in ntifs.h */
@@ -2039,7 +2039,10 @@ typedef union _ULARGE_INTEGER {
 #endif /* NONAMELESSUNION */
   ULONGLONG QuadPart;
 } ULARGE_INTEGER, *PULARGE_INTEGER;
-typedef LARGE_INTEGER LUID,*PLUID;
+typedef struct _LUID {
+    DWORD LowPart;
+    LONG HighPart;
+} LUID, *PLUID;
 #pragma pack(push,4)
 typedef struct _LUID_AND_ATTRIBUTES {
        LUID   Luid;
@@ -3413,17 +3416,6 @@ static __inline__ PVOID GetCurrentFiber(void)
     return ret;
 }
 
-static __inline__ PVOID GetFiberData(void)
-{
-    void* ret;
-    __asm__ __volatile__ (
-       "movl   %%fs:0x10,%0\n"
-       "movl   (%0),%0"
-       : "=r" (ret) /* allow use of reg eax,ebx,ecx,edx,esi,edi */
-       );
-    return ret;
-}
-
 static __inline__ struct _TEB * NtCurrentTeb(void)
 {
     struct _TEB *ret;
@@ -3437,7 +3429,7 @@ static __inline__ struct _TEB * NtCurrentTeb(void)
     return ret;
 }
 
-#else
+#elif defined(__WATCOMC__)
 
 extern PVOID GetCurrentFiber(void);
 #pragma aux GetCurrentFiber = \
@@ -3445,14 +3437,36 @@ extern PVOID GetCurrentFiber(void);
         value [eax] \
         modify [eax];
 
-extern PVOID GetFiberData(void);
-#pragma aux GetFiberData = \
-       "mov    eax, dword ptr fs:0x10" \
-       "mov    eax, [eax]" \
+extern struct _TEB * NtCurrentTeb(void);
+#pragma aux NtCurrentTeb = \
+        "mov   eax, dword ptr fs:0x18" \
         value [eax] \
         modify [eax];
 
-#endif /* __GNUC__ */
+#elif defined(_MSC_VER)
+
+static __inline PVOID GetCurrentFiber(void)
+{
+    PVOID p;
+       __asm mov eax, fs:[10h]
+       __asm mov [p], eax
+    return p;
+}
+
+static __inline struct _TEB * NtCurrentTeb(void)
+{
+    struct _TEB *p;
+       __asm mov eax, fs:[18h]
+       __asm mov [p], eax
+    return p;
+}
+
+#endif /* __GNUC__/__WATCOMC__/_MSC_VER */
+
+static __inline PVOID GetFiberData(void)
+{
+       return *((PVOID *)GetCurrentFiber());
+}
 
 #endif /* RC_INVOKED */