From df0efd555671aaf4db36b785697267a865567f1f Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 11 May 2014 23:11:16 +0000 Subject: [PATCH] [DDK/XDK/NTOSKRNL/DRIVERS] Fix incompatible definition of a number of NTOSKRNL data imports. These imports are declared in MS DDK in a way that is usually not how you would declare data imports. The proper way of doing it is using _DECLSPEC_INTRIN_TYPE(dllimport) or in this case NTKERNELAPI, which will cause the compiler to directly dereference the __imp__FooBar symbol. MS has declared some of these variables directly as pointers without using dllimport. This works with MS DDK, since it's import libraries contain aliases (like _FooBar) to the import symbols (__imp__FooBar). Neither MS LINK nor DLLTOOL create these aliases in the import libs, which is good, since hacks like these are dangerous. To make the original declarations work without using macros (which can conflict with other things, like for example the KdDebuggerEnabled member in KUSER_SHARED_DATA) these aliases have to be generated differently. Luckily both MSVC and GCC support a pragma that does exactly this. Fix the incompatible use in our drivers and the broen(!) use of KdDebuggerEnabled in kdcom (which was writing a PBOOLEAN value (FALSE == 0 == NULL, so no warning) into the location that is really a BOOLEAN, possibly overwriting other data. Finally get rid of a number of hacks in ntoskrnl, where prefixed versions were used to not conflict with the DDK definitions. svn path=/trunk/; revision=63247 --- reactos/drivers/base/kdcom/kdserial.c | 6 +- reactos/drivers/bus/acpi/compbatt/compmisc.c | 16 +-- reactos/drivers/filters/mountmgr/device.c | 2 +- reactos/drivers/ksfilter/ks/event.c | 6 +- reactos/drivers/ksfilter/ks/pin.c | 10 +- reactos/drivers/network/afd/afd/bind.c | 2 +- reactos/drivers/network/afd/afd/select.c | 4 +- reactos/drivers/network/afd/afd/tdi.c | 2 +- .../drivers/network/tcpip/tcpip/dispatch.c | 14 +-- reactos/drivers/storage/floppy/floppy.c | 6 +- .../drivers/wdm/audio/legacy/wdmaud/control.c | 8 +- .../wdm/audio/legacy/wdmaud/deviface.c | 4 +- .../drivers/wdm/audio/legacy/wdmaud/mmixer.c | 4 +- reactos/drivers/wdm/audio/legacy/wdmaud/sup.c | 2 +- reactos/drivers/wdm/audio/sysaudio/deviface.c | 2 +- reactos/drivers/wdm/audio/sysaudio/pin.c | 8 +- reactos/include/ddk/ntddk.h | 10 +- reactos/include/ddk/ntifs.h | 79 +++++-------- reactos/include/ddk/wdm.h | 109 +++++++++++++----- reactos/include/reactos/libs/pseh/pseh3.h | 14 +-- reactos/include/xdk/ccfuncs.h | 2 +- reactos/include/xdk/extypes.h | 2 +- reactos/include/xdk/fsrtlfuncs.h | 21 ++-- reactos/include/xdk/haltypes.h | 10 +- reactos/include/xdk/ia64/ke.h | 2 +- reactos/include/xdk/iotypes.h | 36 ++---- reactos/include/xdk/kdfuncs.h | 27 ++--- reactos/include/xdk/ketypes.h | 1 + reactos/include/xdk/mmtypes.h | 7 +- reactos/include/xdk/ntifs.template.h | 13 ++- reactos/include/xdk/obtypes.h | 25 ++++ reactos/include/xdk/rtltypes.h | 20 +++- reactos/include/xdk/sefuncs.h | 1 + reactos/include/xdk/wdm.template.h | 28 ++++- reactos/lib/rtl/nls.c | 3 +- reactos/ntoskrnl/ex/event.c | 2 +- reactos/ntoskrnl/ex/sem.c | 2 +- reactos/ntoskrnl/fsrtl/fsrtlpc.c | 4 +- reactos/ntoskrnl/include/internal/fsrtl.h | 1 - reactos/ntoskrnl/include/internal/kd.h | 7 -- reactos/ntoskrnl/include/internal/kd64.h | 2 - reactos/ntoskrnl/include/ntoskrnl.h | 23 ---- reactos/ntoskrnl/kd64/kdapi.c | 2 - reactos/ntoskrnl/kd64/kddata.c | 4 +- reactos/ntoskrnl/kd64/kdinit.c | 2 - reactos/ntoskrnl/ntoskrnl.spec | 20 ++-- reactos/tools/spec2def/spec2def.c | 14 +-- reactos/win32ss/gdi/eng/engevent.c | 2 +- reactos/win32ss/user/ntuser/main.c | 2 +- reactos/win32ss/user/ntuser/message.c | 8 +- reactos/win32ss/user/ntuser/misc.c | 10 +- 51 files changed, 318 insertions(+), 293 deletions(-) diff --git a/reactos/drivers/base/kdcom/kdserial.c b/reactos/drivers/base/kdcom/kdserial.c index 2837900a299..bb37a3d9228 100644 --- a/reactos/drivers/base/kdcom/kdserial.c +++ b/reactos/drivers/base/kdcom/kdserial.c @@ -38,7 +38,7 @@ KdpSendBuffer( * \brief Receives data from the KD port and fills a buffer. * \param Buffer Pointer to a buffer that receives the data. * \param Size Size of data to receive in bytes. - * \return KDP_PACKET_RECEIVED if successful. + * \return KDP_PACKET_RECEIVED if successful. * KDP_PACKET_TIMEOUT if the receice timed out. */ KDP_STATUS @@ -69,7 +69,7 @@ KdpReceiveBuffer( * \name KdpReceivePacketLeader * \brief Receives a packet leadr from the KD port. * \param PacketLeader Pointer to an ULONG that receives the packet leader. - * \return KDP_PACKET_RECEIVED if successful. + * \return KDP_PACKET_RECEIVED if successful. * KDP_PACKET_TIMEOUT if the receive timed out. * KDP_PACKET_RESEND if a breakin byte was detected. */ @@ -141,7 +141,7 @@ KdpReceivePacketLeader( while (Index < 4); /* Enable the debugger */ - KdDebuggerNotPresent = FALSE; + KD_DEBUGGER_NOT_PRESENT = FALSE; SharedUserData->KdDebuggerEnabled |= 0x00000002; /* Return the received packet leader */ diff --git a/reactos/drivers/bus/acpi/compbatt/compmisc.c b/reactos/drivers/bus/acpi/compbatt/compmisc.c index f34aa9af0c2..337c521835c 100644 --- a/reactos/drivers/bus/acpi/compbatt/compmisc.c +++ b/reactos/drivers/bus/acpi/compbatt/compmisc.c @@ -14,7 +14,7 @@ NTSTATUS NTAPI -BatteryIoctl(IN ULONG IoControlCode, +BatteryIoctl(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, @@ -50,11 +50,11 @@ BatteryIoctl(IN ULONG IoControlCode, KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); Status = IoStatusBlock.Status; } - + /* Print failure */ if (!(NT_SUCCESS(Status)) && (CompBattDebug & 8)) DbgPrint("BatteryIoctl: Irp failed - %x\n", Status); - + /* Done */ if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING BatteryIoctl\n"); } @@ -64,7 +64,7 @@ BatteryIoctl(IN ULONG IoControlCode, if (CompBattDebug & 8) DbgPrint("BatteryIoctl: couldn't create Irp\n"); Status = STATUS_INSUFFICIENT_RESOURCES; } - + /* Return status */ return Status; } @@ -82,7 +82,7 @@ CompBattGetDeviceObjectPointer(IN PUNICODE_STRING DeviceName, PFILE_OBJECT LocalFileObject; HANDLE DeviceHandle; PAGED_CODE(); - + /* Open a file object handle to the device */ InitializeObjectAttributes(&ObjectAttributes, DeviceName, 0, NULL, NULL); Status = ZwCreateFile(&DeviceHandle, @@ -101,7 +101,7 @@ CompBattGetDeviceObjectPointer(IN PUNICODE_STRING DeviceName, /* Reference the file object */ Status = ObReferenceObjectByHandle(DeviceHandle, 0, - IoFileObjectType, + *IoFileObjectType, KernelMode, (PVOID)&LocalFileObject, NULL); @@ -111,11 +111,11 @@ CompBattGetDeviceObjectPointer(IN PUNICODE_STRING DeviceName, *FileObject = LocalFileObject; *DeviceObject = IoGetRelatedDeviceObject(LocalFileObject); } - + /* Close the handle */ ZwClose(DeviceHandle); } - + /* Return status */ return Status; } diff --git a/reactos/drivers/filters/mountmgr/device.c b/reactos/drivers/filters/mountmgr/device.c index c86df7a5426..4ee8096c7e6 100644 --- a/reactos/drivers/filters/mountmgr/device.c +++ b/reactos/drivers/filters/mountmgr/device.c @@ -1552,7 +1552,7 @@ MountMgrVolumeMountPointChanged(IN PDEVICE_EXTENSION DeviceExtension, } /* Reference it */ - Status = ObReferenceObjectByHandle(Handle, 0, IoFileObjectType, KernelMode, (PVOID *)&FileObject, NULL); + Status = ObReferenceObjectByHandle(Handle, 0, *IoFileObjectType, KernelMode, (PVOID *)&FileObject, NULL); if (!NT_SUCCESS(Status)) { goto Cleanup; diff --git a/reactos/drivers/ksfilter/ks/event.c b/reactos/drivers/ksfilter/ks/event.c index 32999b90409..96f01464760 100644 --- a/reactos/drivers/ksfilter/ks/event.c +++ b/reactos/drivers/ksfilter/ks/event.c @@ -99,7 +99,7 @@ KspEnableEvent( KSEVENT Event; PKSEVENT_ITEM EventItem, FoundEventItem; PKSEVENTDATA EventData; - const KSEVENT_SET* FoundEventSet; + const KSEVENT_SET *FoundEventSet; PKSEVENT_ENTRY EventEntry; ULONG Index, SubIndex, Size; PVOID Object; @@ -234,7 +234,7 @@ KspEnableEvent( if (EventData->NotificationType == KSEVENTF_SEMAPHORE_HANDLE) { /* get semaphore object handle */ - Status = ObReferenceObjectByHandle(EventData->SemaphoreHandle.Semaphore, SEMAPHORE_MODIFY_STATE, ExSemaphoreObjectType, Irp->RequestorMode, &Object, NULL); + Status = ObReferenceObjectByHandle(EventData->SemaphoreHandle.Semaphore, SEMAPHORE_MODIFY_STATE, *ExSemaphoreObjectType, Irp->RequestorMode, &Object, NULL); if (!NT_SUCCESS(Status)) { @@ -245,7 +245,7 @@ KspEnableEvent( else if (EventData->NotificationType == KSEVENTF_EVENT_HANDLE) { /* get event object handle */ - Status = ObReferenceObjectByHandle(EventData->EventHandle.Event, EVENT_MODIFY_STATE, ExEventObjectType, Irp->RequestorMode, &Object, NULL); + Status = ObReferenceObjectByHandle(EventData->EventHandle.Event, EVENT_MODIFY_STATE, *ExEventObjectType, Irp->RequestorMode, &Object, NULL); if (!NT_SUCCESS(Status)) { diff --git a/reactos/drivers/ksfilter/ks/pin.c b/reactos/drivers/ksfilter/ks/pin.c index 0865b3b7b8c..2226223c90c 100644 --- a/reactos/drivers/ksfilter/ks/pin.c +++ b/reactos/drivers/ksfilter/ks/pin.c @@ -193,7 +193,7 @@ IKsPin_PinMasterClock( { Mode = ExGetPreviousMode(); - Status = ObReferenceObjectByHandle(*Handle, SYNCHRONIZE | DIRECTORY_QUERY, IoFileObjectType, Mode, (PVOID*)&FileObject, NULL); + Status = ObReferenceObjectByHandle(*Handle, SYNCHRONIZE | DIRECTORY_QUERY, *IoFileObjectType, Mode, (PVOID*)&FileObject, NULL); DPRINT("IKsPin_PinMasterClock ObReferenceObjectByHandle %lx\n", Status); if (NT_SUCCESS(Status)) @@ -2221,7 +2221,7 @@ IKsPin_DispatchCreateClock( pResolution = &Resolution; } - Status = KsAllocateDefaultClockEx(&This->DefaultClock, + Status = KsAllocateDefaultClockEx(&This->DefaultClock, (PVOID)&This->Pin, (PFNKSSETTIMER)This->Pin.Descriptor->Dispatch->Clock->SetTimer, (PFNKSCANCELTIMER)This->Pin.Descriptor->Dispatch->Clock->CancelTimer, @@ -2265,7 +2265,7 @@ IKsPin_DispatchCreateNode( return STATUS_NOT_IMPLEMENTED; } -static KSDISPATCH_TABLE PinDispatchTable = +static KSDISPATCH_TABLE PinDispatchTable = { IKsPin_DispatchDeviceIoControl, KsDispatchInvalidDeviceRequest, @@ -2329,10 +2329,10 @@ KspCreatePin( DPRINT("KspCreatePin Index %lu FileAlignment %lx\n", Index, Descriptor->AllocatorFraming->FramingItem[Index].FileAlignment); DPRINT("KspCreatePin Index %lu MemoryTypeWeight %lx\n", Index, Descriptor->AllocatorFraming->FramingItem[Index].MemoryTypeWeight); DPRINT("KspCreatePin Index %lu PhysicalRange MinFrameSize %lu MaxFrameSize %lu Stepping %lu\n", Index, Descriptor->AllocatorFraming->FramingItem[Index].PhysicalRange.MinFrameSize, - Descriptor->AllocatorFraming->FramingItem[Index].PhysicalRange.MaxFrameSize, + Descriptor->AllocatorFraming->FramingItem[Index].PhysicalRange.MaxFrameSize, Descriptor->AllocatorFraming->FramingItem[Index].PhysicalRange.Stepping); - DPRINT("KspCreatePin Index %lu FramingRange MinFrameSize %lu MaxFrameSize %lu Stepping %lu InPlaceWeight %lu NotInPlaceWeight %lu\n", + DPRINT("KspCreatePin Index %lu FramingRange MinFrameSize %lu MaxFrameSize %lu Stepping %lu InPlaceWeight %lu NotInPlaceWeight %lu\n", Index, Descriptor->AllocatorFraming->FramingItem[Index].FramingRange.Range.MinFrameSize, Descriptor->AllocatorFraming->FramingItem[Index].FramingRange.Range.MaxFrameSize, diff --git a/reactos/drivers/network/afd/afd/bind.c b/reactos/drivers/network/afd/afd/bind.c index 5bc13bf51a9..21a64fe53f1 100644 --- a/reactos/drivers/network/afd/afd/bind.c +++ b/reactos/drivers/network/afd/afd/bind.c @@ -105,7 +105,7 @@ AfdBindSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, 0, NULL, MAXIMUM_ALLOWED, - IoFileObjectType, + *IoFileObjectType, Irp->RequestorMode, &UserHandle); if (NT_SUCCESS(Status)) diff --git a/reactos/drivers/network/afd/afd/select.c b/reactos/drivers/network/afd/afd/select.c index 66b8ac846ca..2e30ca3ba2b 100644 --- a/reactos/drivers/network/afd/afd/select.c +++ b/reactos/drivers/network/afd/afd/select.c @@ -289,7 +289,7 @@ AfdEventSelect( PDEVICE_OBJECT DeviceObject, PIRP Irp, Status = ObReferenceObjectByHandle( (PVOID)EventSelectInfo-> EventObject, EVENT_ALL_ACCESS, - ExEventObjectType, + *ExEventObjectType, UserMode, (PVOID *)&FCB->EventSelect, NULL ); @@ -346,7 +346,7 @@ AfdEnumEvents( PDEVICE_OBJECT DeviceObject, PIRP Irp, Status = ObReferenceObjectByHandle(EnumReq->Event, EVENT_ALL_ACCESS, - ExEventObjectType, + *ExEventObjectType, UserMode, (PVOID *)&UserEvent, NULL); diff --git a/reactos/drivers/network/afd/afd/tdi.c b/reactos/drivers/network/afd/afd/tdi.c index 60040e16d39..a36a09dc841 100644 --- a/reactos/drivers/network/afd/afd/tdi.c +++ b/reactos/drivers/network/afd/afd/tdi.c @@ -144,7 +144,7 @@ static NTSTATUS TdiOpenDevice( if (NT_SUCCESS(Status)) { Status = ObReferenceObjectByHandle(*Handle, /* Handle to open file */ GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, /* Access mode */ - IoFileObjectType, /* Object type */ + *IoFileObjectType, /* Object type */ KernelMode, /* Access mode */ (PVOID*)Object, /* Pointer to object */ NULL); /* Handle information */ diff --git a/reactos/drivers/network/tcpip/tcpip/dispatch.c b/reactos/drivers/network/tcpip/tcpip/dispatch.c index 94d127db46b..69ed6bf2bf6 100644 --- a/reactos/drivers/network/tcpip/tcpip/dispatch.c +++ b/reactos/drivers/network/tcpip/tcpip/dispatch.c @@ -173,7 +173,7 @@ VOID NTAPI DispCancelRequest( case TDI_CONNECT: DequeuedIrp = TCPRemoveIRP(TranContext->Handle.ConnectionContext, Irp); break; - + case TDI_DISCONNECT: Connection = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext; @@ -303,7 +303,7 @@ NTSTATUS DispTdiAssociateAddress( Status = ObReferenceObjectByHandle( Parameters->AddressHandle, 0, - IoFileObjectType, + *IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); @@ -511,7 +511,7 @@ NTSTATUS DispTdiDisconnect( Status = STATUS_INVALID_PARAMETER; goto done; } - + Status = DispPrepareIrpForCancel (TranContext->Handle.ConnectionContext, Irp, @@ -716,7 +716,7 @@ NTSTATUS DispTdiQueryInformation( case TDI_CONNECTION_FILE: Endpoint = (PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext; - + Address->TAAddressCount = 1; Address->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP; Address->Address[0].AddressType = TDI_ADDRESS_TYPE_IP; @@ -761,12 +761,12 @@ NTSTATUS DispTdiQueryInformation( case TDI_QUERY_MAX_DATAGRAM_INFO: { PTDI_MAX_DATAGRAM_INFO MaxDatagramInfo; - + if (MmGetMdlByteCount(Irp->MdlAddress) < sizeof(*MaxDatagramInfo)) { TI_DbgPrint(MID_TRACE, ("MDL buffer too small.\n")); return STATUS_BUFFER_TOO_SMALL; } - + MaxDatagramInfo = (PTDI_MAX_DATAGRAM_INFO) MmGetSystemAddressForMdl(Irp->MdlAddress); @@ -1560,7 +1560,7 @@ NTSTATUS DispTdiSetIPAddress( PIRP Irp, PIO_STACK_LOCATION IrpSp ) { IF->Netmask.Type = IP_ADDRESS_V4; IF->Netmask.Address.IPv4Address = IpAddrChange->Netmask; - + IF->Broadcast.Type = IP_ADDRESS_V4; IF->Broadcast.Address.IPv4Address = IF->Unicast.Address.IPv4Address | diff --git a/reactos/drivers/storage/floppy/floppy.c b/reactos/drivers/storage/floppy/floppy.c index 740fd9e18e4..ea4a2be1fa1 100644 --- a/reactos/drivers/storage/floppy/floppy.c +++ b/reactos/drivers/storage/floppy/floppy.c @@ -761,9 +761,9 @@ InitController(PCONTROLLER_INFO ControllerInfo) HeadLoadTime = SPECIFY_HLT_500K; HeadUnloadTime = SPECIFY_HUT_500K; StepRateTime = SPECIFY_SRT_500K; - + INFO_(FLOPPY, "InitController: setting data rate\n"); - + /* Set data rate */ if(HwSetDataRate(ControllerInfo, DRSR_DSEL_500KBPS) != STATUS_SUCCESS) { @@ -1176,7 +1176,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) return STATUS_INSUFFICIENT_RESOURCES; } - if(ObReferenceObjectByHandle(ThreadHandle, STANDARD_RIGHTS_ALL, PsThreadType, KernelMode, &QueueThreadObject, NULL) != STATUS_SUCCESS) + if(ObReferenceObjectByHandle(ThreadHandle, STANDARD_RIGHTS_ALL, *PsThreadType, KernelMode, &QueueThreadObject, NULL) != STATUS_SUCCESS) { WARN_(FLOPPY, "Unable to reference returned thread handle; failing init\n"); return STATUS_UNSUCCESSFUL; diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/control.c b/reactos/drivers/wdm/audio/legacy/wdmaud/control.c index 1b6a90d355e..89d85fd1618 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/control.c +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/control.c @@ -97,7 +97,7 @@ WdmAudControlDeviceState( DPRINT("WdmAudControlDeviceState\n"); - Status = ObReferenceObjectByHandle(DeviceInfo->hDevice, GENERIC_READ | GENERIC_WRITE, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); + Status = ObReferenceObjectByHandle(DeviceInfo->hDevice, GENERIC_READ | GENERIC_WRITE, *IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) { DPRINT1("Error: invalid device handle provided %p Type %x\n", DeviceInfo->hDevice, DeviceInfo->DeviceType); @@ -197,7 +197,7 @@ WdmAudFrameSize( NTSTATUS Status; /* Get sysaudio pin file object */ - Status = ObReferenceObjectByHandle(DeviceInfo->hDevice, GENERIC_WRITE, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); + Status = ObReferenceObjectByHandle(DeviceInfo->hDevice, GENERIC_WRITE, *IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) { DPRINT1("Invalid buffer handle %p\n", DeviceInfo->hDevice); @@ -290,7 +290,7 @@ WdmAudResetStream( DPRINT("WdmAudResetStream\n"); - Status = ObReferenceObjectByHandle(DeviceInfo->hDevice, GENERIC_READ | GENERIC_WRITE, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); + Status = ObReferenceObjectByHandle(DeviceInfo->hDevice, GENERIC_READ | GENERIC_WRITE, *IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) { DPRINT1("Error: invalid device handle provided %p Type %x\n", DeviceInfo->hDevice, DeviceInfo->DeviceType); @@ -528,7 +528,7 @@ WdmAudReadWrite( ASSERT(DeviceInfo); /* now get sysaudio file object */ - Status = ObReferenceObjectByHandle(DeviceInfo->hDevice, GENERIC_WRITE, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); + Status = ObReferenceObjectByHandle(DeviceInfo->hDevice, GENERIC_WRITE, *IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) { DPRINT1("Invalid pin handle %p\n", DeviceInfo->hDevice); diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/deviface.c b/reactos/drivers/wdm/audio/legacy/wdmaud/deviface.c index 4363a03b1c3..477ac30fc0b 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/deviface.c +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/deviface.c @@ -165,7 +165,7 @@ WdmAudOpenSysAudioDevices( } /* get the file object */ - Status = ObReferenceObjectByHandle(hSysAudio, FILE_READ_DATA | FILE_WRITE_DATA, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); + Status = ObReferenceObjectByHandle(hSysAudio, FILE_READ_DATA | FILE_WRITE_DATA, *IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) { DPRINT1("Failed to reference FileObject %x\n", Status); @@ -200,7 +200,7 @@ WdmAudRegisterDeviceInterface( } /* failed to register device interface - * create a symbolic link instead + * create a symbolic link instead */ DeviceExtension->DeviceInterfaceSupport = FALSE; diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c b/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c index 6642447d73a..deafa02aa40 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c @@ -202,7 +202,7 @@ Control( PFILE_OBJECT FileObject; /* get file object */ - Status = ObReferenceObjectByHandle(hMixer, GENERIC_READ | GENERIC_WRITE, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); + Status = ObReferenceObjectByHandle(hMixer, GENERIC_READ | GENERIC_WRITE, *IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) { DPRINT("failed to reference %p with %lx\n", hMixer, Status); @@ -420,7 +420,7 @@ WdmAudControlOpenMixer( if (DeviceInfo->u.hNotifyEvent) { - Status = ObReferenceObjectByHandle(DeviceInfo->u.hNotifyEvent, EVENT_MODIFY_STATE, ExEventObjectType, UserMode, (LPVOID*)&EventObject, NULL); + Status = ObReferenceObjectByHandle(DeviceInfo->u.hNotifyEvent, EVENT_MODIFY_STATE, *ExEventObjectType, UserMode, (LPVOID*)&EventObject, NULL); if (!NT_SUCCESS(Status)) { diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/sup.c b/reactos/drivers/wdm/audio/legacy/wdmaud/sup.c index c7c33a53005..f19178980d8 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/sup.c +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/sup.c @@ -420,7 +420,7 @@ OpenDevice( if (FileObject) { - Status = ObReferenceObjectByHandle(hDevice, FILE_READ_DATA | FILE_WRITE_DATA, IoFileObjectType, KernelMode, (PVOID*)FileObject, NULL); + Status = ObReferenceObjectByHandle(hDevice, FILE_READ_DATA | FILE_WRITE_DATA, *IoFileObjectType, KernelMode, (PVOID*)FileObject, NULL); if (!NT_SUCCESS(Status)) { diff --git a/reactos/drivers/wdm/audio/sysaudio/deviface.c b/reactos/drivers/wdm/audio/sysaudio/deviface.c index 8db29770753..5e5bb098092 100644 --- a/reactos/drivers/wdm/audio/sysaudio/deviface.c +++ b/reactos/drivers/wdm/audio/sysaudio/deviface.c @@ -50,7 +50,7 @@ OpenDevice( return Status; } - Status = ObReferenceObjectByHandle(NodeHandle, GENERIC_READ | GENERIC_WRITE, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); + Status = ObReferenceObjectByHandle(NodeHandle, GENERIC_READ | GENERIC_WRITE, *IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) { ZwClose(NodeHandle); diff --git a/reactos/drivers/wdm/audio/sysaudio/pin.c b/reactos/drivers/wdm/audio/sysaudio/pin.c index f0c7f444214..1b688aac936 100644 --- a/reactos/drivers/wdm/audio/sysaudio/pin.c +++ b/reactos/drivers/wdm/audio/sysaudio/pin.c @@ -35,7 +35,7 @@ Pin_fnDeviceIoControl( ASSERT(Context); /* acquire real pin file object */ - Status = ObReferenceObjectByHandle(Context->Handle, GENERIC_WRITE, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); + Status = ObReferenceObjectByHandle(Context->Handle, GENERIC_WRITE, *IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) { Irp->IoStatus.Information = 0; @@ -94,7 +94,7 @@ Pin_fnWrite( } /* acquire real pin file object */ - Status = ObReferenceObjectByHandle(Context->Handle, GENERIC_WRITE, IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); + Status = ObReferenceObjectByHandle(Context->Handle, GENERIC_WRITE, *IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) { DPRINT1("failed\n"); @@ -235,8 +235,8 @@ CreateMixerPinAndSetFormat( } Status = ObReferenceObjectByHandle(PinHandle, - GENERIC_READ | GENERIC_WRITE, - IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); + GENERIC_READ | GENERIC_WRITE, + *IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) { diff --git a/reactos/include/ddk/ntddk.h b/reactos/include/ddk/ntddk.h index b8e4e03d995..8cf5a48f28a 100644 --- a/reactos/include/ddk/ntddk.h +++ b/reactos/include/ddk/ntddk.h @@ -1666,14 +1666,12 @@ typedef struct { #endif } HAL_DISPATCH, *PHAL_DISPATCH; -/* GCC/MSVC and WDK compatible declaration */ -extern NTKERNELAPI HAL_DISPATCH HalDispatchTable; - -#if defined(_NTOSKRNL_) || defined(_BLDR_) +#ifdef _NTSYSTEM_ +extern HAL_DISPATCH HalDispatchTable; #define HALDISPATCH (&HalDispatchTable) #else -/* This is a WDK compatibility definition */ -#define HalDispatchTable (&HalDispatchTable) +extern PHAL_DISPATCH HalDispatchTable; +__CREATE_NTOS_DATA_IMPORT_ALIAS(HalDispatchTable) #define HALDISPATCH HalDispatchTable #endif diff --git a/reactos/include/ddk/ntifs.h b/reactos/include/ddk/ntifs.h index df190c10d0a..7c4ce754313 100644 --- a/reactos/include/ddk/ntifs.h +++ b/reactos/include/ddk/ntifs.h @@ -870,11 +870,11 @@ typedef VOID (NTAPI *PRTL_FREE_STRING_ROUTINE)( _In_ __drv_freesMem(Mem) _Post_invalid_ PVOID Buffer); -extern const PRTL_ALLOCATE_STRING_ROUTINE RtlAllocateStringRoutine; -extern const PRTL_FREE_STRING_ROUTINE RtlFreeStringRoutine; +extern NTKERNELAPI const PRTL_ALLOCATE_STRING_ROUTINE RtlAllocateStringRoutine; +extern NTKERNELAPI const PRTL_FREE_STRING_ROUTINE RtlFreeStringRoutine; #if _WIN32_WINNT >= 0x0600 -extern const PRTL_REALLOCATE_STRING_ROUTINE RtlReallocateStringRoutine; +extern NTKERNELAPI const PRTL_REALLOCATE_STRING_ROUTINE RtlReallocateStringRoutine; #endif _Function_class_(RTL_HEAP_COMMIT_ROUTINE) @@ -4937,35 +4937,13 @@ FsRtlNotifyStreamFileObject( _In_ BOOLEAN SafeToRecurse); #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ -#define DO_VERIFY_VOLUME 0x00000002 -#define DO_BUFFERED_IO 0x00000004 -#define DO_EXCLUSIVE 0x00000008 -#define DO_DIRECT_IO 0x00000010 -#define DO_MAP_IO_BUFFER 0x00000020 -#define DO_DEVICE_HAS_NAME 0x00000040 -#define DO_DEVICE_INITIALIZING 0x00000080 -#define DO_SYSTEM_BOOT_PARTITION 0x00000100 -#define DO_LONG_TERM_REQUESTS 0x00000200 -#define DO_NEVER_LAST_DEVICE 0x00000400 -#define DO_SHUTDOWN_REGISTERED 0x00000800 -#define DO_BUS_ENUMERATED_DEVICE 0x00001000 -#define DO_POWER_PAGABLE 0x00002000 -#define DO_POWER_INRUSH 0x00004000 -#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000 -#define DO_SUPPORTS_TRANSACTIONS 0x00040000 -#define DO_FORCE_NEITHER_IO 0x00080000 -#define DO_VOLUME_DEVICE_OBJECT 0x00100000 -#define DO_SYSTEM_SYSTEM_PARTITION 0x00200000 -#define DO_SYSTEM_CRITICAL_PARTITION 0x00400000 -#define DO_DISALLOW_EXECUTE 0x00800000 - -extern KSPIN_LOCK IoStatisticsLock; -extern ULONG IoReadOperationCount; -extern ULONG IoWriteOperationCount; -extern ULONG IoOtherOperationCount; -extern LARGE_INTEGER IoReadTransferCount; -extern LARGE_INTEGER IoWriteTransferCount; -extern LARGE_INTEGER IoOtherTransferCount; +extern NTKERNELAPI KSPIN_LOCK IoStatisticsLock; +extern NTKERNELAPI ULONG IoReadOperationCount; +extern NTKERNELAPI ULONG IoWriteOperationCount; +extern NTKERNELAPI ULONG IoOtherOperationCount; +extern NTKERNELAPI LARGE_INTEGER IoReadTransferCount; +extern NTKERNELAPI LARGE_INTEGER IoWriteTransferCount; +extern NTKERNELAPI LARGE_INTEGER IoOtherTransferCount; #define IO_FILE_OBJECT_NON_PAGED_POOL_CHARGE 64 #define IO_FILE_OBJECT_PAGED_POOL_CHARGE 1024 @@ -5731,6 +5709,7 @@ SeLocateProcessImageName( ((PSECURITY_SUBJECT_CONTEXT) SubjectContext)->PrimaryToken ) extern NTKERNELAPI PSE_EXPORTS SeExports; + /****************************************************************************** * Process Manager Functions * ******************************************************************************/ @@ -8413,26 +8392,31 @@ FsRtlRemovePerFileObjectContext( (InterlockedDecrement((LONG volatile *)&((FL)->LockRequestsInProgress)));\ } -/* GCC compatible definition, MS one is retarded */ -extern NTKERNELAPI const UCHAR * const FsRtlLegalAnsiCharacterArray; -#define LEGAL_ANSI_CHARACTER_ARRAY FsRtlLegalAnsiCharacterArray +#ifdef _NTSYSTEM_ +extern const UCHAR * const FsRtlLegalAnsiCharacterArray; +#define LEGAL_ANSI_CHARACTER_ARRAY FsRtlLegalAnsiCharacterArray +#else +extern const UCHAR * const *FsRtlLegalAnsiCharacterArray; +__CREATE_NTOS_DATA_IMPORT_ALIAS(FsRtlLegalAnsiCharacterArray) +#define LEGAL_ANSI_CHARACTER_ARRAY (*FsRtlLegalAnsiCharacterArray) +#endif #define FsRtlIsAnsiCharacterWild(C) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], FSRTL_WILD_CHARACTER ) \ + FlagOn(LEGAL_ANSI_CHARACTER_ARRAY[(UCHAR)(C)], FSRTL_WILD_CHARACTER ) \ ) #define FsRtlIsAnsiCharacterLegalFat(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_FAT_LEGAL) | \ + FlagOn(LEGAL_ANSI_CHARACTER_ARRAY[(UCHAR)(C)], (FSRTL_FAT_LEGAL) | \ ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ ) #define FsRtlIsAnsiCharacterLegalHpfs(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_HPFS_LEGAL) | \ + FlagOn(LEGAL_ANSI_CHARACTER_ARRAY[(UCHAR)(C)], (FSRTL_HPFS_LEGAL) | \ ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ ) #define FsRtlIsAnsiCharacterLegalNtfs(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_NTFS_LEGAL) | \ + FlagOn(LEGAL_ANSI_CHARACTER_ARRAY[(UCHAR)(C)], (FSRTL_NTFS_LEGAL) | \ ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ ) @@ -8460,7 +8444,7 @@ extern NTKERNELAPI const UCHAR * const FsRtlLegalAnsiCharacterArray; #define FsRtlIsUnicodeCharacterWild(C) ( \ (((C) >= 0x40) ? \ FALSE : \ - FlagOn(FsRtlLegalAnsiCharacterArray[(C)], FSRTL_WILD_CHARACTER )) \ + FlagOn(LEGAL_ANSI_CHARACTER_ARRAY[(C)], FSRTL_WILD_CHARACTER )) \ ) #define FsRtlInitPerFileContext( _fc, _owner, _inst, _cb) \ @@ -8623,7 +8607,7 @@ typedef VOID (((PSECTION_OBJECT_POINTERS)(FO)->SectionObjectPointer)->SharedCacheMap != NULL) \ ) -extern ULONG CcFastMdlReadWait; +extern NTKERNELAPI ULONG CcFastMdlReadWait; #if (NTDDI_VERSION >= NTDDI_WIN2K) @@ -11005,13 +10989,14 @@ HalGetDmaAlignmentRequirement( #define HalGetDmaAlignmentRequirement() 1L #endif -extern NTKERNELAPI PUSHORT NlsOemLeadByteInfo; -#define NLS_OEM_LEAD_BYTE_INFO NlsOemLeadByteInfo - -#ifdef NLS_MB_CODE_PAGE_TAG -#undef NLS_MB_CODE_PAGE_TAG +#ifdef _NTSYSTEM_ +extern PUSHORT NlsOemLeadByteInfo; +#define NLS_OEM_LEAD_BYTE_INFO NlsOemLeadByteInfo +#else +extern PUSHORT *NlsOemLeadByteInfo; +__CREATE_NTOS_DATA_IMPORT_ALIAS(NlsOemLeadByteInfo) +#define NLS_OEM_LEAD_BYTE_INFO (*NlsOemLeadByteInfo) #endif -#define NLS_MB_CODE_PAGE_TAG NlsMbOemCodePageTag #if (NTDDI_VERSION >= NTDDI_VISTA) diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index 124e45b4012..26ebbf394c9 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -25,6 +25,9 @@ #ifndef _WDMDDK_ #define _WDMDDK_ +// TEMP HACK! +#define _PROPER_NT_EXPORTS 1 + #define WDM_MAJORVERSION 0x06 #define WDM_MINORVERSION 0x00 @@ -82,10 +85,13 @@ extern "C" { #endif /* For ReactOS */ -#if !defined(_NTOSKRNL_) && !defined(_BLDR_) +#if !defined(_NTOSKRNL_) && !defined(_BLDR_) && !defined(_NTSYSTEM_) #define NTKERNELAPI DECLSPEC_IMPORT #else #define NTKERNELAPI +#ifndef _NTSYSTEM_ +#define _NTSYSTEM_ +#endif #endif #if defined(_X86_) && !defined(_NTHAL_) @@ -129,6 +135,29 @@ extern "C" { #define ALLOC_DATA_PRAGMA 1 #endif +#endif /* _MSC_VER */ + +/* These macros are used to create aliases for imported data. We need to do + this to have declarations that are compatible with MS DDK */ +#ifdef _M_IX86 +#define __SYMBOL(_Name) "_"#_Name +#define __IMPORTSYMBOL(_Name) "__imp__"#_Name +#define __IMPORTNAME(_Name) _imp__##_Name +#else +#define __SYMBOL(_Name) #_Name +#define __IMPORTSYMBOL(_Name) "__imp_"#_Name +#define __IMPORTNAME(_Name) __imp_##_Name +#endif +#ifdef _MSC_VER +#define __CREATE_NTOS_DATA_IMPORT_ALIAS(_Name) \ + __pragma(comment(linker, "/alternatename:"__SYMBOL(_Name) "=" __IMPORTSYMBOL(_Name))) +#else /* !_MSC_VER */ +#ifndef __STRINGIFY +#define __STRINGIFY(_exp) #_exp +#endif +#define _Pragma_redifine_extname(_Name, _Target) _Pragma(__STRINGIFY(redefine_extname _Name _Target)) +#define __CREATE_NTOS_DATA_IMPORT_ALIAS(_Name) \ + _Pragma_redifine_extname(_Name,__IMPORTNAME(_Name)) #endif #if defined(_WIN64) @@ -599,11 +628,19 @@ typedef struct _EXCEPTION_POINTERS { PCONTEXT ContextRecord; } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; -/* MS definition is broken! */ -extern BOOLEAN NTSYSAPI NlsMbCodePageTag; -extern BOOLEAN NTSYSAPI NlsMbOemCodePageTag; +#ifdef _NTSYSTEM_ +extern BOOLEAN NlsMbCodePageTag; #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag +extern BOOLEAN NlsMbOemCodePageTag; #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag +#else +extern BOOLEAN *NlsMbCodePageTag; +__CREATE_NTOS_DATA_IMPORT_ALIAS(NlsMbCodePageTag) +#define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag) +extern BOOLEAN *NlsMbOemCodePageTag; +__CREATE_NTOS_DATA_IMPORT_ALIAS(NlsMbOemCodePageTag) +#define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag) +#endif #define SHORT_LEAST_SIGNIFICANT_BIT 0 #define SHORT_MOST_SIGNIFICANT_BIT 1 @@ -1673,6 +1710,7 @@ extern NTSYSAPI volatile CCHAR KeNumberProcessors; extern NTSYSAPI CCHAR KeNumberProcessors; #else extern PCCHAR KeNumberProcessors; +__CREATE_NTOS_DATA_IMPORT_ALIAS(KeNumberProcessors) #endif @@ -1824,8 +1862,11 @@ typedef enum _MM_SYSTEM_SIZE { MmLargeSystem } MM_SYSTEMSIZE; -extern NTKERNELAPI BOOLEAN Mm64BitPhysicalAddress; -extern PVOID MmBadPointer; +#ifndef _NTSYSTEM_ +extern PBOOLEAN Mm64BitPhysicalAddress; +__CREATE_NTOS_DATA_IMPORT_ALIAS(Mm64BitPhysicalAddress) +#endif +extern NTKERNELAPI PVOID MmBadPointer; /****************************************************************************** @@ -2098,7 +2139,7 @@ typedef struct _RESOURCE_PERFORMANCE_DATA { /* Global debug flag */ #if DEVL -extern ULONG NtGlobalFlag; +extern NTKERNELAPI ULONG NtGlobalFlag; #define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_##FlagName)) #else #define IF_NTOS_DEBUG(FlagName) if(FALSE) @@ -7857,6 +7898,7 @@ typedef struct _OBJECT_NAME_INFORMATION { } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION; /* Exported object types */ +#ifdef _NTSYSTEM_ extern POBJECT_TYPE NTSYSAPI CmKeyObjectType; extern POBJECT_TYPE NTSYSAPI ExEventObjectType; extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType; @@ -7864,6 +7906,30 @@ extern POBJECT_TYPE NTSYSAPI IoFileObjectType; extern POBJECT_TYPE NTSYSAPI PsThreadType; extern POBJECT_TYPE NTSYSAPI SeTokenObjectType; extern POBJECT_TYPE NTSYSAPI PsProcessType; +#else +extern POBJECT_TYPE *CmKeyObjectType; +extern POBJECT_TYPE *IoFileObjectType; +extern POBJECT_TYPE *ExEventObjectType; +extern POBJECT_TYPE *ExSemaphoreObjectType; +extern POBJECT_TYPE *TmTransactionManagerObjectType; +extern POBJECT_TYPE *TmResourceManagerObjectType; +extern POBJECT_TYPE *TmEnlistmentObjectType; +extern POBJECT_TYPE *TmTransactionObjectType; +extern POBJECT_TYPE *PsProcessType; +extern POBJECT_TYPE *PsThreadType; +extern POBJECT_TYPE *SeTokenObjectType; +__CREATE_NTOS_DATA_IMPORT_ALIAS(CmKeyObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(IoFileObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(ExEventObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(ExSemaphoreObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(TmTransactionManagerObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(TmResourceManagerObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(TmEnlistmentObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(TmTransactionObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(PsProcessType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(PsThreadType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(SeTokenObjectType) +#endif /****************************************************************************** @@ -8339,7 +8405,7 @@ KeRestoreFloatingPointState(PVOID FloatingState) #define HIGH_LEVEL 15 #define KI_USER_SHARED_DATA ((ULONG_PTR)(KADDRESS_BASE + 0xFFFE0000)) -extern volatile LARGE_INTEGER KeTickCount; +extern NTKERNELAPI volatile LARGE_INTEGER KeTickCount; #define PAUSE_PROCESSOR __yield(); @@ -15770,27 +15836,18 @@ DbgSetDebugPrintCallback( #endif /* !DBG */ -#if defined(__GNUC__) - -extern NTKERNELAPI BOOLEAN KdDebuggerNotPresent; -extern NTKERNELAPI BOOLEAN KdDebuggerEnabled; -#define KD_DEBUGGER_ENABLED KdDebuggerEnabled -#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent - -#elif defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_) - -extern NTKERNELAPI PBOOLEAN KdDebuggerNotPresent; -extern NTKERNELAPI PBOOLEAN KdDebuggerEnabled; -#define KD_DEBUGGER_ENABLED *KdDebuggerEnabled -#define KD_DEBUGGER_NOT_PRESENT *KdDebuggerNotPresent - -#else - -extern BOOLEAN KdDebuggerNotPresent; +#ifdef _NTSYSTEM_ extern BOOLEAN KdDebuggerEnabled; #define KD_DEBUGGER_ENABLED KdDebuggerEnabled +extern BOOLEAN KdDebuggerNotPresent; #define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent - +#else +extern BOOLEAN *KdDebuggerEnabled; +__CREATE_NTOS_DATA_IMPORT_ALIAS(KdDebuggerEnabled) +#define KD_DEBUGGER_ENABLED (*KdDebuggerEnabled) +extern BOOLEAN *KdDebuggerNotPresent; +__CREATE_NTOS_DATA_IMPORT_ALIAS(KdDebuggerNotPresent) +#define KD_DEBUGGER_NOT_PRESENT (*KdDebuggerNotPresent) #endif #if (NTDDI_VERSION >= NTDDI_WIN2K) diff --git a/reactos/include/reactos/libs/pseh/pseh3.h b/reactos/include/reactos/libs/pseh/pseh3.h index 6aa15dd9c15..8337b41522a 100644 --- a/reactos/include/reactos/libs/pseh/pseh3.h +++ b/reactos/include/reactos/libs/pseh/pseh3.h @@ -120,7 +120,7 @@ void * __cdecl __attribute__((error("Can only be used inside an exception filter #define _SEH3$_EnforceFramePointer() asm volatile ("#\n" : : "m"(*(char*)__builtin_alloca(4)) : "%esp", "memory") /* CLANG doesn't have asm goto! */ -#define _SEH3$_ASM_GOTO(_Label, ...) +#define _SEH3$_ASM_GOTO(...) int __attribute__((regparm(3))) @@ -167,7 +167,7 @@ _SEH3$_RegisterTryLevelWithNonVolatiles( /* This will make GCC use ebp, even if it was disabled by -fomit-frame-pointer */ #define _SEH3$_EnforceFramePointer() asm volatile ("#\n" : : "m"(*(char*)__builtin_alloca(0)) : "%esp", "memory") -#define _SEH3$_ASM_GOTO(_Label, ...) asm goto ("#\n" : : : "memory", ## __VA_ARGS__ : _Label) +#define _SEH3$_ASM_GOTO(...) asm goto ("#\n" : : : "memory" : __VA_ARGS__) #ifdef __cplusplus #define _SEH3$_CALL_WRAPPER(_Function, _TrylevelFrame, _DataTable) \ @@ -177,7 +177,7 @@ _SEH3$_RegisterTryLevelWithNonVolatiles( : \ : "m" (*(_TrylevelFrame)), "m" (*(_DataTable)), "c"(__builtin_alloca(0)) \ : "eax", "edx", "memory" \ - : _SEH3$_l_HandlerTarget, _SEH3$_l_FilterOrFinally) + : _SEH3$_l_BeforeTry, _SEH3$_l_HandlerTarget, _SEH3$_l_OnException, _SEH3$_l_BeforeFilterOrFinally, _SEH3$_l_FilterOrFinally) #else #define _SEH3$_CALL_WRAPPER(_Function, _TrylevelFrame, _DataTable) \ @@ -187,7 +187,7 @@ _SEH3$_RegisterTryLevelWithNonVolatiles( : \ : "m" (*(_TrylevelFrame)), "m" (*(_DataTable)) \ : "eax", "edx", "ecx", "memory" \ - : _SEH3$_l_HandlerTarget) + : _SEH3$_l_BeforeTry, _SEH3$_l_HandlerTarget, _SEH3$_l_OnException, _SEH3$_l_BeforeFilterOrFinally, _SEH3$_l_FilterOrFinally) #endif /* This is an asm wrapper around _SEH3$_RegisterFrame */ @@ -202,10 +202,8 @@ _SEH3$_RegisterTryLevelWithNonVolatiles( around into places that are never executed. */ #define _SEH3$_SCARE_GCC() \ void *plabel; \ - _SEH3$_ASM_GOTO(_SEH3$_l_BeforeTry); \ - _SEH3$_ASM_GOTO(_SEH3$_l_HandlerTarget); \ - _SEH3$_ASM_GOTO(_SEH3$_l_OnException); \ - asm volatile ("#" : "=a"(plabel) : "p"(&&_SEH3$_l_BeforeTry), "p"(&&_SEH3$_l_HandlerTarget), "p"(&&_SEH3$_l_OnException) \ + _SEH3$_ASM_GOTO(_SEH3$_l_BeforeTry, _SEH3$_l_HandlerTarget, _SEH3$_l_OnException, _SEH3$_l_BeforeFilterOrFinally, _SEH3$_l_FilterOrFinally); \ + asm volatile ("#" : "=a"(plabel) : "p"(&&_SEH3$_l_BeforeTry), "p"(&&_SEH3$_l_HandlerTarget), "p"(&&_SEH3$_l_OnException), "p"(&&_SEH3$_l_FilterOrFinally) \ : "ebx", "ecx", "edx", "esi", "edi", "flags", "memory" ); \ goto _SEH3$_l_OnException; diff --git a/reactos/include/xdk/ccfuncs.h b/reactos/include/xdk/ccfuncs.h index 9192381f5f4..5e998d89ed3 100644 --- a/reactos/include/xdk/ccfuncs.h +++ b/reactos/include/xdk/ccfuncs.h @@ -6,7 +6,7 @@ $if (_NTIFS_) (((PSECTION_OBJECT_POINTERS)(FO)->SectionObjectPointer)->SharedCacheMap != NULL) \ ) -extern ULONG CcFastMdlReadWait; +extern NTKERNELAPI ULONG CcFastMdlReadWait; #if (NTDDI_VERSION >= NTDDI_WIN2K) diff --git a/reactos/include/xdk/extypes.h b/reactos/include/xdk/extypes.h index ae252d375ed..548dceee203 100644 --- a/reactos/include/xdk/extypes.h +++ b/reactos/include/xdk/extypes.h @@ -271,7 +271,7 @@ typedef struct _RESOURCE_PERFORMANCE_DATA { /* Global debug flag */ #if DEVL -extern ULONG NtGlobalFlag; +extern NTKERNELAPI ULONG NtGlobalFlag; #define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_##FlagName)) #else #define IF_NTOS_DEBUG(FlagName) if(FALSE) diff --git a/reactos/include/xdk/fsrtlfuncs.h b/reactos/include/xdk/fsrtlfuncs.h index b98897c0bb8..24465b8e2ea 100644 --- a/reactos/include/xdk/fsrtlfuncs.h +++ b/reactos/include/xdk/fsrtlfuncs.h @@ -1580,26 +1580,31 @@ FsRtlRemovePerFileObjectContext( (InterlockedDecrement((LONG volatile *)&((FL)->LockRequestsInProgress)));\ } -/* GCC compatible definition, MS one is retarded */ -extern NTKERNELAPI const UCHAR * const FsRtlLegalAnsiCharacterArray; -#define LEGAL_ANSI_CHARACTER_ARRAY FsRtlLegalAnsiCharacterArray +#ifdef _NTSYSTEM_ +extern const UCHAR * const FsRtlLegalAnsiCharacterArray; +#define LEGAL_ANSI_CHARACTER_ARRAY FsRtlLegalAnsiCharacterArray +#else +extern const UCHAR * const *FsRtlLegalAnsiCharacterArray; +__CREATE_NTOS_DATA_IMPORT_ALIAS(FsRtlLegalAnsiCharacterArray) +#define LEGAL_ANSI_CHARACTER_ARRAY (*FsRtlLegalAnsiCharacterArray) +#endif #define FsRtlIsAnsiCharacterWild(C) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], FSRTL_WILD_CHARACTER ) \ + FlagOn(LEGAL_ANSI_CHARACTER_ARRAY[(UCHAR)(C)], FSRTL_WILD_CHARACTER ) \ ) #define FsRtlIsAnsiCharacterLegalFat(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_FAT_LEGAL) | \ + FlagOn(LEGAL_ANSI_CHARACTER_ARRAY[(UCHAR)(C)], (FSRTL_FAT_LEGAL) | \ ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ ) #define FsRtlIsAnsiCharacterLegalHpfs(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_HPFS_LEGAL) | \ + FlagOn(LEGAL_ANSI_CHARACTER_ARRAY[(UCHAR)(C)], (FSRTL_HPFS_LEGAL) | \ ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ ) #define FsRtlIsAnsiCharacterLegalNtfs(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_NTFS_LEGAL) | \ + FlagOn(LEGAL_ANSI_CHARACTER_ARRAY[(UCHAR)(C)], (FSRTL_NTFS_LEGAL) | \ ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ ) @@ -1627,7 +1632,7 @@ extern NTKERNELAPI const UCHAR * const FsRtlLegalAnsiCharacterArray; #define FsRtlIsUnicodeCharacterWild(C) ( \ (((C) >= 0x40) ? \ FALSE : \ - FlagOn(FsRtlLegalAnsiCharacterArray[(C)], FSRTL_WILD_CHARACTER )) \ + FlagOn(LEGAL_ANSI_CHARACTER_ARRAY[(C)], FSRTL_WILD_CHARACTER )) \ ) #define FsRtlInitPerFileContext( _fc, _owner, _inst, _cb) \ diff --git a/reactos/include/xdk/haltypes.h b/reactos/include/xdk/haltypes.h index 941daef32be..db308060e03 100644 --- a/reactos/include/xdk/haltypes.h +++ b/reactos/include/xdk/haltypes.h @@ -269,14 +269,12 @@ typedef struct { #endif } HAL_DISPATCH, *PHAL_DISPATCH; -/* GCC/MSVC and WDK compatible declaration */ -extern NTKERNELAPI HAL_DISPATCH HalDispatchTable; - -#if defined(_NTOSKRNL_) || defined(_BLDR_) +#ifdef _NTSYSTEM_ +extern HAL_DISPATCH HalDispatchTable; #define HALDISPATCH (&HalDispatchTable) #else -/* This is a WDK compatibility definition */ -#define HalDispatchTable (&HalDispatchTable) +extern PHAL_DISPATCH HalDispatchTable; +__CREATE_NTOS_DATA_IMPORT_ALIAS(HalDispatchTable) #define HALDISPATCH HalDispatchTable #endif diff --git a/reactos/include/xdk/ia64/ke.h b/reactos/include/xdk/ia64/ke.h index 2920636bf54..27ff06ad3f0 100644 --- a/reactos/include/xdk/ia64/ke.h +++ b/reactos/include/xdk/ia64/ke.h @@ -17,7 +17,7 @@ $if (_WDMDDK_) #define HIGH_LEVEL 15 #define KI_USER_SHARED_DATA ((ULONG_PTR)(KADDRESS_BASE + 0xFFFE0000)) -extern volatile LARGE_INTEGER KeTickCount; +extern NTKERNELAPI volatile LARGE_INTEGER KeTickCount; #define PAUSE_PROCESSOR __yield(); diff --git a/reactos/include/xdk/iotypes.h b/reactos/include/xdk/iotypes.h index 4b375154977..41954a5a121 100644 --- a/reactos/include/xdk/iotypes.h +++ b/reactos/include/xdk/iotypes.h @@ -7037,35 +7037,13 @@ FsRtlNotifyStreamFileObject( _In_ BOOLEAN SafeToRecurse); #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ -#define DO_VERIFY_VOLUME 0x00000002 -#define DO_BUFFERED_IO 0x00000004 -#define DO_EXCLUSIVE 0x00000008 -#define DO_DIRECT_IO 0x00000010 -#define DO_MAP_IO_BUFFER 0x00000020 -#define DO_DEVICE_HAS_NAME 0x00000040 -#define DO_DEVICE_INITIALIZING 0x00000080 -#define DO_SYSTEM_BOOT_PARTITION 0x00000100 -#define DO_LONG_TERM_REQUESTS 0x00000200 -#define DO_NEVER_LAST_DEVICE 0x00000400 -#define DO_SHUTDOWN_REGISTERED 0x00000800 -#define DO_BUS_ENUMERATED_DEVICE 0x00001000 -#define DO_POWER_PAGABLE 0x00002000 -#define DO_POWER_INRUSH 0x00004000 -#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000 -#define DO_SUPPORTS_TRANSACTIONS 0x00040000 -#define DO_FORCE_NEITHER_IO 0x00080000 -#define DO_VOLUME_DEVICE_OBJECT 0x00100000 -#define DO_SYSTEM_SYSTEM_PARTITION 0x00200000 -#define DO_SYSTEM_CRITICAL_PARTITION 0x00400000 -#define DO_DISALLOW_EXECUTE 0x00800000 - -extern KSPIN_LOCK IoStatisticsLock; -extern ULONG IoReadOperationCount; -extern ULONG IoWriteOperationCount; -extern ULONG IoOtherOperationCount; -extern LARGE_INTEGER IoReadTransferCount; -extern LARGE_INTEGER IoWriteTransferCount; -extern LARGE_INTEGER IoOtherTransferCount; +extern NTKERNELAPI KSPIN_LOCK IoStatisticsLock; +extern NTKERNELAPI ULONG IoReadOperationCount; +extern NTKERNELAPI ULONG IoWriteOperationCount; +extern NTKERNELAPI ULONG IoOtherOperationCount; +extern NTKERNELAPI LARGE_INTEGER IoReadTransferCount; +extern NTKERNELAPI LARGE_INTEGER IoWriteTransferCount; +extern NTKERNELAPI LARGE_INTEGER IoOtherTransferCount; #define IO_FILE_OBJECT_NON_PAGED_POOL_CHARGE 64 #define IO_FILE_OBJECT_PAGED_POOL_CHARGE 1024 diff --git a/reactos/include/xdk/kdfuncs.h b/reactos/include/xdk/kdfuncs.h index e05c86500d8..b5e908ba35a 100644 --- a/reactos/include/xdk/kdfuncs.h +++ b/reactos/include/xdk/kdfuncs.h @@ -119,27 +119,18 @@ DbgSetDebugPrintCallback( #endif /* !DBG */ -#if defined(__GNUC__) - -extern NTKERNELAPI BOOLEAN KdDebuggerNotPresent; -extern NTKERNELAPI BOOLEAN KdDebuggerEnabled; -#define KD_DEBUGGER_ENABLED KdDebuggerEnabled -#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent - -#elif defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_) - -extern NTKERNELAPI PBOOLEAN KdDebuggerNotPresent; -extern NTKERNELAPI PBOOLEAN KdDebuggerEnabled; -#define KD_DEBUGGER_ENABLED *KdDebuggerEnabled -#define KD_DEBUGGER_NOT_PRESENT *KdDebuggerNotPresent - -#else - -extern BOOLEAN KdDebuggerNotPresent; +#ifdef _NTSYSTEM_ extern BOOLEAN KdDebuggerEnabled; #define KD_DEBUGGER_ENABLED KdDebuggerEnabled +extern BOOLEAN KdDebuggerNotPresent; #define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent - +#else +extern BOOLEAN *KdDebuggerEnabled; +__CREATE_NTOS_DATA_IMPORT_ALIAS(KdDebuggerEnabled) +#define KD_DEBUGGER_ENABLED (*KdDebuggerEnabled) +extern BOOLEAN *KdDebuggerNotPresent; +__CREATE_NTOS_DATA_IMPORT_ALIAS(KdDebuggerNotPresent) +#define KD_DEBUGGER_NOT_PRESENT (*KdDebuggerNotPresent) #endif #if (NTDDI_VERSION >= NTDDI_WIN2K) diff --git a/reactos/include/xdk/ketypes.h b/reactos/include/xdk/ketypes.h index 1ef6473ba2e..7b14d0ae09b 100644 --- a/reactos/include/xdk/ketypes.h +++ b/reactos/include/xdk/ketypes.h @@ -987,6 +987,7 @@ extern NTSYSAPI volatile CCHAR KeNumberProcessors; extern NTSYSAPI CCHAR KeNumberProcessors; #else extern PCCHAR KeNumberProcessors; +__CREATE_NTOS_DATA_IMPORT_ALIAS(KeNumberProcessors) #endif $endif (_WDMDDK_) diff --git a/reactos/include/xdk/mmtypes.h b/reactos/include/xdk/mmtypes.h index 2b98aeef5ae..ae665cca59a 100644 --- a/reactos/include/xdk/mmtypes.h +++ b/reactos/include/xdk/mmtypes.h @@ -147,8 +147,11 @@ typedef enum _MM_SYSTEM_SIZE { MmLargeSystem } MM_SYSTEMSIZE; -extern NTKERNELAPI BOOLEAN Mm64BitPhysicalAddress; -extern PVOID MmBadPointer; +#ifndef _NTSYSTEM_ +extern PBOOLEAN Mm64BitPhysicalAddress; +__CREATE_NTOS_DATA_IMPORT_ALIAS(Mm64BitPhysicalAddress) +#endif +extern NTKERNELAPI PVOID MmBadPointer; $endif (_WDMDDK_) $if (_NTDDK_) diff --git a/reactos/include/xdk/ntifs.template.h b/reactos/include/xdk/ntifs.template.h index dfff253e59e..68957892ec6 100644 --- a/reactos/include/xdk/ntifs.template.h +++ b/reactos/include/xdk/ntifs.template.h @@ -1124,13 +1124,14 @@ HalGetDmaAlignmentRequirement( #define HalGetDmaAlignmentRequirement() 1L #endif -extern NTKERNELAPI PUSHORT NlsOemLeadByteInfo; -#define NLS_OEM_LEAD_BYTE_INFO NlsOemLeadByteInfo - -#ifdef NLS_MB_CODE_PAGE_TAG -#undef NLS_MB_CODE_PAGE_TAG +#ifdef _NTSYSTEM_ +extern PUSHORT NlsOemLeadByteInfo; +#define NLS_OEM_LEAD_BYTE_INFO NlsOemLeadByteInfo +#else +extern PUSHORT *NlsOemLeadByteInfo; +__CREATE_NTOS_DATA_IMPORT_ALIAS(NlsOemLeadByteInfo) +#define NLS_OEM_LEAD_BYTE_INFO (*NlsOemLeadByteInfo) #endif -#define NLS_MB_CODE_PAGE_TAG NlsMbOemCodePageTag #if (NTDDI_VERSION >= NTDDI_VISTA) diff --git a/reactos/include/xdk/obtypes.h b/reactos/include/xdk/obtypes.h index 7063ab1d1e3..482ab193979 100644 --- a/reactos/include/xdk/obtypes.h +++ b/reactos/include/xdk/obtypes.h @@ -125,6 +125,7 @@ typedef struct _OBJECT_NAME_INFORMATION { } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION; /* Exported object types */ +#ifdef _NTSYSTEM_ extern POBJECT_TYPE NTSYSAPI CmKeyObjectType; extern POBJECT_TYPE NTSYSAPI ExEventObjectType; extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType; @@ -132,6 +133,30 @@ extern POBJECT_TYPE NTSYSAPI IoFileObjectType; extern POBJECT_TYPE NTSYSAPI PsThreadType; extern POBJECT_TYPE NTSYSAPI SeTokenObjectType; extern POBJECT_TYPE NTSYSAPI PsProcessType; +#else +extern POBJECT_TYPE *CmKeyObjectType; +extern POBJECT_TYPE *IoFileObjectType; +extern POBJECT_TYPE *ExEventObjectType; +extern POBJECT_TYPE *ExSemaphoreObjectType; +extern POBJECT_TYPE *TmTransactionManagerObjectType; +extern POBJECT_TYPE *TmResourceManagerObjectType; +extern POBJECT_TYPE *TmEnlistmentObjectType; +extern POBJECT_TYPE *TmTransactionObjectType; +extern POBJECT_TYPE *PsProcessType; +extern POBJECT_TYPE *PsThreadType; +extern POBJECT_TYPE *SeTokenObjectType; +__CREATE_NTOS_DATA_IMPORT_ALIAS(CmKeyObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(IoFileObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(ExEventObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(ExSemaphoreObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(TmTransactionManagerObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(TmResourceManagerObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(TmEnlistmentObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(TmTransactionObjectType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(PsProcessType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(PsThreadType) +__CREATE_NTOS_DATA_IMPORT_ALIAS(SeTokenObjectType) +#endif $endif (_WDMDDK_) $if (_NTIFS_) diff --git a/reactos/include/xdk/rtltypes.h b/reactos/include/xdk/rtltypes.h index 0b61c724921..7e56f8c9e1f 100644 --- a/reactos/include/xdk/rtltypes.h +++ b/reactos/include/xdk/rtltypes.h @@ -197,11 +197,19 @@ typedef struct _EXCEPTION_POINTERS { PCONTEXT ContextRecord; } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; -/* MS definition is broken! */ -extern BOOLEAN NTSYSAPI NlsMbCodePageTag; -extern BOOLEAN NTSYSAPI NlsMbOemCodePageTag; +#ifdef _NTSYSTEM_ +extern BOOLEAN NlsMbCodePageTag; #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag +extern BOOLEAN NlsMbOemCodePageTag; #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag +#else +extern BOOLEAN *NlsMbCodePageTag; +__CREATE_NTOS_DATA_IMPORT_ALIAS(NlsMbCodePageTag) +#define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag) +extern BOOLEAN *NlsMbOemCodePageTag; +__CREATE_NTOS_DATA_IMPORT_ALIAS(NlsMbOemCodePageTag) +#define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag) +#endif #define SHORT_LEAST_SIGNIFICANT_BIT 0 #define SHORT_MOST_SIGNIFICANT_BIT 1 @@ -551,11 +559,11 @@ typedef VOID (NTAPI *PRTL_FREE_STRING_ROUTINE)( _In_ __drv_freesMem(Mem) _Post_invalid_ PVOID Buffer); -extern const PRTL_ALLOCATE_STRING_ROUTINE RtlAllocateStringRoutine; -extern const PRTL_FREE_STRING_ROUTINE RtlFreeStringRoutine; +extern NTKERNELAPI const PRTL_ALLOCATE_STRING_ROUTINE RtlAllocateStringRoutine; +extern NTKERNELAPI const PRTL_FREE_STRING_ROUTINE RtlFreeStringRoutine; #if _WIN32_WINNT >= 0x0600 -extern const PRTL_REALLOCATE_STRING_ROUTINE RtlReallocateStringRoutine; +extern NTKERNELAPI const PRTL_REALLOCATE_STRING_ROUTINE RtlReallocateStringRoutine; #endif _Function_class_(RTL_HEAP_COMMIT_ROUTINE) diff --git a/reactos/include/xdk/sefuncs.h b/reactos/include/xdk/sefuncs.h index 44e5fedfa9e..c7e27666159 100644 --- a/reactos/include/xdk/sefuncs.h +++ b/reactos/include/xdk/sefuncs.h @@ -588,4 +588,5 @@ SeLocateProcessImageName( ((PSECURITY_SUBJECT_CONTEXT) SubjectContext)->PrimaryToken ) extern NTKERNELAPI PSE_EXPORTS SeExports; + $endif (_NTIFS_) diff --git a/reactos/include/xdk/wdm.template.h b/reactos/include/xdk/wdm.template.h index fa472156785..4d9e8f1d000 100644 --- a/reactos/include/xdk/wdm.template.h +++ b/reactos/include/xdk/wdm.template.h @@ -82,10 +82,13 @@ extern "C" { #endif /* For ReactOS */ -#if !defined(_NTOSKRNL_) && !defined(_BLDR_) +#if !defined(_NTOSKRNL_) && !defined(_BLDR_) && !defined(_NTSYSTEM_) #define NTKERNELAPI DECLSPEC_IMPORT #else #define NTKERNELAPI +#ifndef _NTSYSTEM_ +#define _NTSYSTEM_ +#endif #endif #if defined(_X86_) && !defined(_NTHAL_) @@ -129,6 +132,29 @@ extern "C" { #define ALLOC_DATA_PRAGMA 1 #endif +#endif /* _MSC_VER */ + +/* These macros are used to create aliases for imported data. We need to do + this to have declarations that are compatible with MS DDK */ +#ifdef _M_IX86 +#define __SYMBOL(_Name) "_"#_Name +#define __IMPORTSYMBOL(_Name) "__imp__"#_Name +#define __IMPORTNAME(_Name) _imp__##_Name +#else +#define __SYMBOL(_Name) #_Name +#define __IMPORTSYMBOL(_Name) "__imp_"#_Name +#define __IMPORTNAME(_Name) __imp_##_Name +#endif +#ifdef _MSC_VER +#define __CREATE_NTOS_DATA_IMPORT_ALIAS(_Name) \ + __pragma(comment(linker, "/alternatename:"__SYMBOL(_Name) "=" __IMPORTSYMBOL(_Name))) +#else /* !_MSC_VER */ +#ifndef __STRINGIFY +#define __STRINGIFY(_exp) #_exp +#endif +#define _Pragma_redifine_extname(_Name, _Target) _Pragma(__STRINGIFY(redefine_extname _Name _Target)) +#define __CREATE_NTOS_DATA_IMPORT_ALIAS(_Name) \ + _Pragma_redifine_extname(_Name,__IMPORTNAME(_Name)) #endif #if defined(_WIN64) diff --git a/reactos/lib/rtl/nls.c b/reactos/lib/rtl/nls.c index 49a8fa13f43..ee892a09324 100644 --- a/reactos/lib/rtl/nls.c +++ b/reactos/lib/rtl/nls.c @@ -31,13 +31,12 @@ BOOLEAN NlsMbOemCodePageTag = FALSE; /* exported */ PWCHAR NlsOemToUnicodeTable = NULL; PCHAR NlsUnicodeToOemTable =NULL; PWCHAR NlsDbcsUnicodeToOemTable = NULL; -PUSHORT _NlsOemLeadByteInfo = NULL; /* exported */ +PUSHORT NlsOemLeadByteInfo = NULL; /* exported */ USHORT NlsOemDefaultChar = '\0'; USHORT NlsUnicodeDefaultChar = 0; -#define NlsOemLeadByteInfo _NlsOemLeadByteInfo #define INIT_FUNCTION /* FUNCTIONS *****************************************************************/ diff --git a/reactos/ntoskrnl/ex/event.c b/reactos/ntoskrnl/ex/event.c index 4238a82115f..26cbda90f34 100644 --- a/reactos/ntoskrnl/ex/event.c +++ b/reactos/ntoskrnl/ex/event.c @@ -19,7 +19,7 @@ /* GLOBALS *******************************************************************/ -POBJECT_TYPE _ExEventObjectType = NULL; +POBJECT_TYPE ExEventObjectType = NULL; GENERIC_MAPPING ExpEventMapping = { diff --git a/reactos/ntoskrnl/ex/sem.c b/reactos/ntoskrnl/ex/sem.c index 7b07b906a0d..98464685589 100644 --- a/reactos/ntoskrnl/ex/sem.c +++ b/reactos/ntoskrnl/ex/sem.c @@ -19,7 +19,7 @@ /* GLOBALS ******************************************************************/ -POBJECT_TYPE _ExSemaphoreObjectType; +POBJECT_TYPE ExSemaphoreObjectType; GENERIC_MAPPING ExSemaphoreMapping = { diff --git a/reactos/ntoskrnl/fsrtl/fsrtlpc.c b/reactos/ntoskrnl/fsrtl/fsrtlpc.c index b5a68a4075e..0150a5582ee 100644 --- a/reactos/ntoskrnl/fsrtl/fsrtlpc.c +++ b/reactos/ntoskrnl/fsrtl/fsrtlpc.c @@ -18,7 +18,7 @@ PERESOURCE FsRtlPagingIoResources; ULONG FsRtlPagingIoResourceSelector; NTSTATUS NTAPI INIT_FUNCTION FsRtlInitializeWorkerThread(VOID); -static UCHAR LegalAnsiCharacterArray[] = +static const UCHAR LegalAnsiCharacterArray[] = { 0, /* CTRL+@, 0x00 */ 0, /* CTRL+A, 0x01 */ @@ -150,7 +150,7 @@ static UCHAR LegalAnsiCharacterArray[] = FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL /* 0x7f */ }; -PUCHAR FsRtlLegalAnsiCharacterArray = LegalAnsiCharacterArray; +const UCHAR * const FsRtlLegalAnsiCharacterArray = LegalAnsiCharacterArray; /* PRIVATE FUNCTIONS *********************************************************/ diff --git a/reactos/ntoskrnl/include/internal/fsrtl.h b/reactos/ntoskrnl/include/internal/fsrtl.h index cca4e8faeb1..86ce04e840a 100644 --- a/reactos/ntoskrnl/include/internal/fsrtl.h +++ b/reactos/ntoskrnl/include/internal/fsrtl.h @@ -133,5 +133,4 @@ FsRtlInitSystem( // Global data inside the File System Runtime Library // extern PERESOURCE FsRtlPagingIoResources; -extern PUCHAR _FsRtlLegalAnsiCharacterArray; extern PAGED_LOOKASIDE_LIST FsRtlFileLockLookasideList; diff --git a/reactos/ntoskrnl/include/internal/kd.h b/reactos/ntoskrnl/include/internal/kd.h index 0943e546962..3bb0dc3e59c 100644 --- a/reactos/ntoskrnl/include/internal/kd.h +++ b/reactos/ntoskrnl/include/internal/kd.h @@ -2,18 +2,11 @@ #include -#ifdef _M_PPC -#define KdDebuggerEnabled _KdDebuggerEnabled -#define KdDebuggerNotPresent _KdDebuggerNotPresent -#endif - // // Kernel Debugger Port Definition // struct _KD_DISPATCH_TABLE; extern CPPORT GdbPortInfo; -extern BOOLEAN _KdDebuggerEnabled; -extern BOOLEAN _KdDebuggerNotPresent; extern BOOLEAN KdBreakAfterSymbolLoad; extern BOOLEAN KdPitchDebugger; extern BOOLEAN KdIgnoreUmExceptions; diff --git a/reactos/ntoskrnl/include/internal/kd64.h b/reactos/ntoskrnl/include/internal/kd64.h index 444afbb51df..9cae4fa60c4 100644 --- a/reactos/ntoskrnl/include/internal/kd64.h +++ b/reactos/ntoskrnl/include/internal/kd64.h @@ -494,8 +494,6 @@ extern PKDEBUG_ROUTINE KiDebugRoutine; extern PKDEBUG_SWITCH_ROUTINE KiDebugSwitchRoutine; extern BOOLEAN KdBreakAfterSymbolLoad; extern BOOLEAN KdPitchDebugger; -extern BOOLEAN _KdDebuggerNotPresent; -extern BOOLEAN _KdDebuggerEnabled; extern BOOLEAN KdAutoEnableOnEvent; extern BOOLEAN KdBlockEnable; extern BOOLEAN KdIgnoreUmExceptions; diff --git a/reactos/ntoskrnl/include/ntoskrnl.h b/reactos/ntoskrnl/include/ntoskrnl.h index 9e7f37dd596..dc5772c66a8 100644 --- a/reactos/ntoskrnl/include/ntoskrnl.h +++ b/reactos/ntoskrnl/include/ntoskrnl.h @@ -90,31 +90,8 @@ // // Define the internal versions of external and public global data // -#define IoFileObjectType _IoFileObjectType -#define PsThreadType _PsThreadType -#define PsProcessType _PsProcessType -#define ExEventObjectType _ExEventObjectType -#define ExSemaphoreObjectType _ExSemaphoreObjectType -#define KdDebuggerEnabled _KdDebuggerEnabled -#define KdDebuggerNotPresent _KdDebuggerNotPresent -#define NlsOemLeadByteInfo _NlsOemLeadByteInfo -extern PUSHORT _NlsOemLeadByteInfo; #define KeNumberProcessors _KeNumberProcessors extern UCHAR _KeNumberProcessors; -#define FsRtlLegalAnsiCharacterArray _FsRtlLegalAnsiCharacterArray -#undef LEGAL_ANSI_CHARACTER_ARRAY -#undef NLS_MB_CODE_PAGE_TAG -#undef NLS_OEM_LEAD_BYTE_INFO -#define LEGAL_ANSI_CHARACTER_ARRAY FsRtlLegalAnsiCharacterArray -#define NLS_MB_CODE_PAGE_TAG NlsMbOemCodePageTag -#define NLS_OEM_LEAD_BYTE_INFO _NlsOemLeadByteInfo -#undef KD_DEBUGGER_ENABLED -#undef KD_DEBUGGER_NOT_PRESENT -#define KD_DEBUGGER_ENABLED KdDebuggerEnabled -#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent -#define HalDispatchTable _HalDispatchTable -#undef HALDISPATCH -#define HALDISPATCH (&HalDispatchTable) #define ExRaiseStatus RtlRaiseStatus /* Internal Headers */ diff --git a/reactos/ntoskrnl/kd64/kdapi.c b/reactos/ntoskrnl/kd64/kdapi.c index c0a1650faa4..5ea86413fd8 100644 --- a/reactos/ntoskrnl/kd64/kdapi.c +++ b/reactos/ntoskrnl/kd64/kdapi.c @@ -1903,9 +1903,7 @@ KdDisableDebuggerWithLock(IN BOOLEAN NeedLock) /* We are disabled now */ KdDebuggerEnabled = FALSE; -#undef KdDebuggerEnabled SharedUserData->KdDebuggerEnabled = FALSE; -#define KdDebuggerEnabled _KdDebuggerEnabled } } diff --git a/reactos/ntoskrnl/kd64/kddata.c b/reactos/ntoskrnl/kd64/kddata.c index d6b0107fcb9..5a1e10ea065 100644 --- a/reactos/ntoskrnl/kd64/kddata.c +++ b/reactos/ntoskrnl/kd64/kddata.c @@ -79,8 +79,8 @@ PKDEBUG_SWITCH_ROUTINE KiDebugSwitchRoutine; // BOOLEAN KdBreakAfterSymbolLoad; BOOLEAN KdPitchDebugger; -BOOLEAN _KdDebuggerNotPresent; -BOOLEAN _KdDebuggerEnabled; +BOOLEAN KdDebuggerNotPresent; +BOOLEAN KdDebuggerEnabled; BOOLEAN KdAutoEnableOnEvent; BOOLEAN KdBlockEnable; BOOLEAN KdIgnoreUmExceptions; diff --git a/reactos/ntoskrnl/kd64/kdinit.c b/reactos/ntoskrnl/kd64/kdinit.c index 89d57fb089b..723a18ca323 100644 --- a/reactos/ntoskrnl/kd64/kdinit.c +++ b/reactos/ntoskrnl/kd64/kdinit.c @@ -310,9 +310,7 @@ KdInitSystem(IN ULONG BootPhase, KdDebuggerEnabled = TRUE; /* Let user-mode know that it's enabled as well */ -#undef KdDebuggerEnabled SharedUserData->KdDebuggerEnabled = TRUE; -#define KdDebuggerEnabled _KdDebuggerEnabled /* Check if the debugger should be disabled initially */ if (DisableKdAfterInit) diff --git a/reactos/ntoskrnl/ntoskrnl.spec b/reactos/ntoskrnl/ntoskrnl.spec index e5d8eeebdf7..5f7a0725804 100644 --- a/reactos/ntoskrnl/ntoskrnl.spec +++ b/reactos/ntoskrnl/ntoskrnl.spec @@ -82,7 +82,7 @@ @ stdcall ExEnterCriticalRegionAndAcquireResourceShared(ptr) @ stdcall ExEnterCriticalRegionAndAcquireSharedWaitForExclusive(ptr) @ stdcall ExEnumHandleTable(ptr ptr ptr ptr) -@ extern ExEventObjectType _ExEventObjectType +@ extern ExEventObjectType @ stdcall ExExtendZone(ptr ptr long) @ stdcall ExFreeCacheAwareRundownProtection(ptr) @ stdcall ExFreePool(ptr) @@ -144,7 +144,7 @@ @ fastcall ExReleaseRundownProtectionEx(ptr long) ExfReleaseRundownProtectionEx @ fastcall ExRundownCompleted(ptr) ExfRundownCompleted @ fastcall ExRundownCompletedCacheAware(ptr) ExfRundownCompletedCacheAware -@ extern ExSemaphoreObjectType _ExSemaphoreObjectType +@ extern ExSemaphoreObjectType @ stdcall ExSetResourceOwnerPointer(ptr ptr) @ stdcall ExSetTimerResolution(long long) @ stdcall ExSizeOfRundownProtectionCacheAware() @@ -241,7 +241,7 @@ @ stdcall FsRtlIsNtstatusExpected(long) @ stdcall FsRtlIsPagingFile(ptr) @ stdcall FsRtlIsTotalDeviceFailure(ptr) -@ extern FsRtlLegalAnsiCharacterArray _FsRtlLegalAnsiCharacterArray +@ extern FsRtlLegalAnsiCharacterArray @ stdcall FsRtlLookupBaseMcbEntry(ptr long long ptr ptr ptr ptr ptr) @ stdcall FsRtlLookupLargeMcbEntry(ptr long long ptr ptr ptr ptr ptr) @ stdcall FsRtlLookupLastBaseMcbEntry(ptr ptr ptr) @@ -302,7 +302,7 @@ @ stdcall FsRtlUninitializeLargeMcb(ptr) @ stdcall FsRtlUninitializeMcb(ptr) @ stdcall FsRtlUninitializeOplock(ptr) -@ extern HalDispatchTable _HalDispatchTable +@ extern HalDispatchTable @ fastcall HalExamineMBR(ptr long long ptr) @ extern HalPrivateDispatchTable @ stdcall HeadlessDispatch(long ptr long ptr ptr) @@ -393,7 +393,7 @@ @ stdcall IoEnumerateDeviceObjectList(ptr ptr long ptr) @ stdcall IoEnumerateRegisteredFiltersList(ptr long ptr) @ stdcall IoFastQueryNetworkAttributes(ptr long long ptr ptr) -@ extern IoFileObjectType _IoFileObjectType +@ extern IoFileObjectType @ stdcall IoForwardAndCatchIrp(ptr ptr) IoForwardIrpSynchronously @ stdcall IoForwardIrpSynchronously(ptr ptr) @ stdcall IoFreeController(ptr) @@ -533,8 +533,8 @@ @ fastcall IofCallDriver(ptr ptr) @ fastcall IofCompleteRequest(ptr long) @ stdcall KdChangeOption(long long ptr long ptr ptr) -@ extern KdDebuggerEnabled _KdDebuggerEnabled -@ extern KdDebuggerNotPresent _KdDebuggerNotPresent +@ extern KdDebuggerEnabled +@ extern KdDebuggerNotPresent @ stdcall KdDisableDebugger() @ stdcall KdEnableDebugger() @ extern KdEnteredDebugger @@ -830,7 +830,7 @@ @ extern NlsMbCodePageTag @ extern NlsMbOemCodePageTag @ extern NlsOemCodePage -@ extern NlsOemLeadByteInfo _NlsOemLeadByteInfo +@ extern NlsOemLeadByteInfo @ stdcall NtAddAtom(wstr long ptr) @ stdcall NtAdjustPrivilegesToken(ptr long ptr long ptr ptr) @ stdcall -arch=i386,arm NtAlertThread(ptr) @@ -1011,7 +1011,7 @@ @ stdcall PsLookupProcessByProcessId(ptr ptr) @ stdcall PsLookupProcessThreadByCid(ptr ptr ptr) @ stdcall PsLookupThreadByThreadId(ptr ptr) -@ extern PsProcessType _PsProcessType +@ extern PsProcessType @ stdcall PsReferenceImpersonationToken(ptr ptr ptr ptr) @ stdcall PsReferencePrimaryToken(ptr) @ stdcall PsRemoveCreateThreadNotifyRoutine(ptr) @@ -1036,7 +1036,7 @@ @ stdcall PsSetThreadHardErrorsAreDisabled(ptr long) @ stdcall PsSetThreadWin32Thread(ptr ptr ptr) @ stdcall PsTerminateSystemThread(long) -@ extern PsThreadType _PsThreadType +@ extern PsThreadType ;PsWrapApcWow64Thread @ stdcall -arch=i386,arm READ_REGISTER_BUFFER_UCHAR(ptr ptr long) @ stdcall -arch=i386,arm READ_REGISTER_BUFFER_ULONG(ptr ptr long) diff --git a/reactos/tools/spec2def/spec2def.c b/reactos/tools/spec2def/spec2def.c index 5a5b5fc94aa..c197cf5ef43 100644 --- a/reactos/tools/spec2def/spec2def.c +++ b/reactos/tools/spec2def/spec2def.c @@ -52,7 +52,6 @@ enum FL_STUB = 2, FL_NONAME = 4, FL_ORDINAL = 8, - FL_DATA_ALIAS = 16 }; enum @@ -508,9 +507,7 @@ OutputLine_def(FILE *fileDest, EXPORT *pexp) fprintf(fileDest, " PRIVATE"); } - /* Make this a data export, unless this is MSVC and -withalias was given */ - if ((pexp->nCallingConvention == CC_EXTERN) && - !(gbMSComp && (pexp->uFlags & FL_DATA_ALIAS))) + if (pexp->nCallingConvention == CC_EXTERN) { fprintf(fileDest, " DATA"); } @@ -663,15 +660,6 @@ ParseFile(char* pcStart, FILE *fileDest, PFNOUTLINE OutputLine) { exp.uFlags |= FL_STUB; } - else if (CompareToken(pc, "-withalias")) - { - /* This flag is to create a nin _imp_ prefixed alias for a - data export, so that the hacked DDK declarations work */ - if (exp.nCallingConvention != CC_EXTERN) - fprintf(stderr, "error: line %d -withalias on non-data export\n", nLine); - else - exp.uFlags |= FL_DATA_ALIAS; - } else if (CompareToken(pc, "-norelay") || CompareToken(pc, "-register") || CompareToken(pc, "-ret64")) diff --git a/reactos/win32ss/gdi/eng/engevent.c b/reactos/win32ss/gdi/eng/engevent.c index ab6e8acb48d..77b00a4006f 100644 --- a/reactos/win32ss/gdi/eng/engevent.c +++ b/reactos/win32ss/gdi/eng/engevent.c @@ -134,7 +134,7 @@ EngMapEvent( /* Create a handle, and have Ob fill out the pKEvent field */ Status = ObReferenceObjectByHandle(EngEvent, EVENT_ALL_ACCESS, - ExEventObjectType, + *ExEventObjectType, UserMode, &EngEvent->pKEvent, NULL); diff --git a/reactos/win32ss/user/ntuser/main.c b/reactos/win32ss/user/ntuser/main.c index 4485c5d4929..905fa04e503 100644 --- a/reactos/win32ss/user/ntuser/main.c +++ b/reactos/win32ss/user/ntuser/main.c @@ -320,7 +320,7 @@ UserCreateThreadInfo(struct _ETHREAD *Thread) goto error; } Status = ObReferenceObjectByHandle(ptiCurrent->hEventQueueClient, 0, - ExEventObjectType, KernelMode, + *ExEventObjectType, KernelMode, (PVOID*)&ptiCurrent->pEventQueueServer, NULL); if (!NT_SUCCESS(Status)) { diff --git a/reactos/win32ss/user/ntuser/message.c b/reactos/win32ss/user/ntuser/message.c index a9e2256d3eb..c458230a0c9 100644 --- a/reactos/win32ss/user/ntuser/message.c +++ b/reactos/win32ss/user/ntuser/message.c @@ -1548,7 +1548,7 @@ co_IntSendMessageWithCallBack( HWND hWnd, { RETURN(FALSE); } - + ptiSendTo = IntSendTo(Window, Win32Thread, Msg); if (Msg & 0x80000000 && @@ -2755,7 +2755,7 @@ NtUserMessageCall( HWND hWnd, ((ClientInfo->CI_flags & CI_CURTHPRHOOK) ? 1 : 0), (LPARAM)&CWP, Hook->Proc, - Hook->ihmod, + Hook->ihmod, Hook->offPfn, Hook->Ansi, &Hook->ModuleName); @@ -2774,7 +2774,7 @@ NtUserMessageCall( HWND hWnd, ((ClientInfo->CI_flags & CI_CURTHPRHOOK) ? 1 : 0), (LPARAM)&CWPR, Hook->Proc, - Hook->ihmod, + Hook->ihmod, Hook->offPfn, Hook->Ansi, &Hook->ModuleName); @@ -2833,7 +2833,7 @@ NtUserWaitForInputIdle( IN HANDLE hProcess, Status = ObReferenceObjectByHandle(hProcess, PROCESS_QUERY_INFORMATION, - PsProcessType, + *PsProcessType, UserMode, (PVOID*)&Process, NULL); diff --git a/reactos/win32ss/user/ntuser/misc.c b/reactos/win32ss/user/ntuser/misc.c index 52f0abe377c..4b64a13a89c 100644 --- a/reactos/win32ss/user/ntuser/misc.c +++ b/reactos/win32ss/user/ntuser/misc.c @@ -223,7 +223,7 @@ NtUserGetThreadState( break; case THREADSTATE_INSENDMESSAGE: { - PUSER_SENT_MESSAGE Message = + PUSER_SENT_MESSAGE Message = ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->pusmCurrent; ERR("THREADSTATE_INSENDMESSAGE\n"); @@ -243,7 +243,7 @@ NtUserGetThreadState( if (Message->QS_Flags & QS_SMRESULT) ret |= ISMEX_REPLIED; } - break; + break; } case THREADSTATE_GETMESSAGETIME: ret = ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->timeLast; @@ -289,7 +289,7 @@ NtUserSetThreadState( DWORD Ret = 0; // Test the only flags user can change. if (Set & ~(QF_FF10STATUS|QF_DIALOGACTIVE|QF_TABSWITCHING|QF_FMENUSTATUS|QF_FMENUSTATUSBREAK)) return 0; - if (Flags & ~(QF_FF10STATUS|QF_DIALOGACTIVE|QF_TABSWITCHING|QF_FMENUSTATUS|QF_FMENUSTATUSBREAK)) return 0; + if (Flags & ~(QF_FF10STATUS|QF_DIALOGACTIVE|QF_TABSWITCHING|QF_FMENUSTATUS|QF_FMENUSTATUSBREAK)) return 0; UserEnterExclusive(); pti = PsGetCurrentThreadWin32Thread(); if (pti->MessageQueue) @@ -448,7 +448,7 @@ NtUserGetGuiResources( Status = ObReferenceObjectByHandle(hProcess, PROCESS_QUERY_INFORMATION, - PsProcessType, + *PsProcessType, ExGetPreviousMode(), (PVOID*)&Process, NULL); @@ -656,7 +656,7 @@ void UserDbgAssertThreadInfo(BOOL showCaller) ASSERT(pci->ulClientDelta == DesktopHeapGetUserDelta()); if (pti->pcti && pci->pDeskInfo) ASSERT(pci->pClientThreadInfo == (PVOID)((ULONG_PTR)pti->pcti - pci->ulClientDelta)); - if (pti->KeyboardLayout) + if (pti->KeyboardLayout) ASSERT(pci->hKL == pti->KeyboardLayout->hkl); if(pti->rpdesk != NULL) ASSERT(pti->pDeskInfo == pti->rpdesk->pDeskInfo);