- Fix DEVICE_NODE definition to remove ROS-only fields

- Move RTL_HEAP_PARAMETERS to umtypes.h
- Fix PROCESS_PRIORITY_CLASS_XXX definitions.
- Use PROCESS_PRIORITY_CLASS_INVALID in process creation code.
- Move and correct EX_PUSH_LOCK definition to ntifs.h
- Define KQUEUE along with KAPC_STATE if ntifs.h is not used, so that we don't force its usage
- Enable usage of EX_QUEUE_WORKER_INFO and EX_WORK_QUEUE without requiring the IFS.
- Fix definition of CsrClientConnectToServer
- Update NDK FIXME list
- Define and use a list of Bus Type GUIDs instead of saving the GUID in a ROS-only field of DEVICE_NODE.
- Use a IRP_MN_QUERY_CAPABILITIES PnP IRP to get the Address of a DeviceNode, intead of saving it inside a ROS-only field.

svn path=/trunk/; revision=17272
This commit is contained in:
Alex Ionescu 2005-08-11 00:01:17 +00:00
parent 4a6a9d5dd2
commit be97362b23
13 changed files with 239 additions and 113 deletions

View file

@ -38,10 +38,9 @@ extern NTOSAPI POBJECT_TYPE ExTimerType;
/* You'll need the IFS for this, so use an equivalent version */
#ifndef _NTIFS_
typedef PVOID EX_RUNDOWN_REF;
typedef PVOID EX_PUSH_LOCK;
#endif
/* You'll need the IFS for these, so let's not force everyone to have it */
#ifdef _NTIFS_
typedef struct _EX_QUEUE_WORKER_INFO
{
UCHAR QueueDisabled:1;
@ -59,7 +58,6 @@ typedef struct _EX_WORK_QUEUE
ULONG QueueDepthLastPass;
EX_QUEUE_WORKER_INFO Info;
} EX_WORK_QUEUE, *PEX_WORK_QUEUE;
#endif
typedef struct _EX_FAST_REF
{
@ -71,21 +69,6 @@ typedef struct _EX_FAST_REF
};
} EX_FAST_REF, *PEX_FAST_REF;
typedef struct _EX_PUSH_LOCK
{
union
{
struct
{
ULONG Waiting:1;
ULONG Exclusive:1;
ULONG Shared:30;
};
ULONG Value;
PVOID Ptr;
};
} EX_PUSH_LOCK, *PEX_PUSH_LOCK;
typedef struct _HANDLE_TABLE_ENTRY_INFO
{
ULONG AuditMask;

View file

@ -2,8 +2,8 @@ NDK FIXMES
-----------
Order:
* Priority 1 = Easiest to fix.
* Priority 5 = Hardest to fix.
* Priority 1 = Most important to fix.
* Priority 5 = Least important to fix.
Format:
<Priority Level>
@ -19,7 +19,7 @@ List:
- FIXED: Some files need cleanup (Alex + Eric) [zwfuncs.h, rtlfuncs.h, rtltypes.h]
Priority 2:
- DEVICE_NODE has 2 fields not part of NT's defintion [iotypes.h]
- FIXED: DEVICE_NODE has 2 fields not part of NT's defintion (Alex) [iotypes.h]
- Object Callbacks don't match NT's (Alex) [obtypes.h]
- Remove Create Callback Hack (Alex) [obtypes.h]
- Object header doesn't match NT (Alex) [obtypes.h] blocks on ->
@ -32,9 +32,9 @@ List:
Priority 4:
- FIXED: Kernel and Memory Types are not architecture-specific (Eric) [ketypes.h, mmtypes.h]
- Win32K Builds with windows.h (Filip, bugzilla id 666) [extypes.h, ketypes.h]
- FIXED: Win32K Builds with windows.h (Filip) [extypes.h, ketypes.h]
Priority 5:
- LPC Types are totally wrong. [lpctypes.h]
- Missing System Info Classes [zwtypes.h]
- Process Priority Classes are messed up (Alex) [pstypes.h]
- FIXED: Process Priority Classes are messed up (Alex) [pstypes.h]

View file

@ -207,10 +207,6 @@ typedef struct _DEVICE_NODE
ULONG DriverUnloadRetryCount;
struct _DEVICE_NODE *PreviousParent;
ULONG DeletedChidren;
/* FIXME: Not NT's */
GUID BusTypeGuid;
ULONG Address;
} DEVICE_NODE, *PDEVICE_NODE;
typedef struct _PI_RESOURCE_ARBITER_ENTRY

View file

@ -63,7 +63,7 @@ typedef enum _KAPC_ENVIRONMENT
CurrentApcEnvironment
} KAPC_ENVIRONMENT;
/* We don't want to force NTIFS usage only for a single structure */
/* We don't want to force NTIFS usage only for two structures */
#ifndef _NTIFS_
typedef struct _KAPC_STATE
{
@ -73,6 +73,15 @@ typedef struct _KAPC_STATE
BOOLEAN KernelApcPending;
BOOLEAN UserApcPending;
} KAPC_STATE, *PKAPC_STATE, *RESTRICTED_POINTER PRKAPC_STATE;
typedef struct _KQUEUE
{
DISPATCHER_HEADER Header;
LIST_ENTRY EntryListHead;
ULONG CurrentCount;
ULONG MaximumCount;
LIST_ENTRY ThreadListHead;
} KQUEUE, *PKQUEUE, *RESTRICTED_POINTER PRKQUEUE;
#endif
typedef struct _KNODE

View file

@ -36,12 +36,13 @@ extern NTOSAPI POBJECT_TYPE PsThreadType;
#define USER_SHARED_DATA (0x7FFE0000)
/* Process priority classes */
#define PROCESS_PRIORITY_CLASS_IDLE 0
#define PROCESS_PRIORITY_CLASS_BELOW_NORMAL 1
#define PROCESS_PRIORITY_CLASS_INVALID 0
#define PROCESS_PRIORITY_CLASS_IDLE 1
#define PROCESS_PRIORITY_CLASS_NORMAL 2
#define PROCESS_PRIORITY_CLASS_ABOVE_NORMAL 3
#define PROCESS_PRIORITY_CLASS_HIGH 4
#define PROCESS_PRIORITY_CLASS_REALTIME 5
#define PROCESS_PRIORITY_CLASS_HIGH 3
#define PROCESS_PRIORITY_CLASS_REALTIME 4
#define PROCESS_PRIORITY_CLASS_BELOW_NORMAL 5
#define PROCESS_PRIORITY_CLASS_ABOVE_NORMAL 6
/* Global Flags */
#define FLG_STOP_ON_EXCEPTION 0x00000001

View file

@ -109,20 +109,16 @@ typedef VOID
PVOID Parameter
);
#ifndef _NTIFS_
typedef NTSTATUS
(NTAPI * PRTL_HEAP_COMMIT_ROUTINE) (
IN PVOID Base,
IN OUT PVOID *CommitAddress,
IN OUT PSIZE_T CommitSize
);
#endif
/* TYPES *********************************************************************/
typedef unsigned short RTL_ATOM;
typedef unsigned short *PRTL_ATOM;
/* Once again, we don't want to force NTIFS for something like this */
#if !defined(_NTIFS_) && !defined(NTOS_MODE_USER)
typedef PVOID PRTL_HEAP_PARAMETERS;
#endif
typedef ACL_REVISION_INFORMATION *PACL_REVISION_INFORMATION;
typedef ACL_SIZE_INFORMATION *PACL_SIZE_INFORMATION;
typedef struct _ACE
@ -402,22 +398,6 @@ typedef struct _RTL_ATOM_TABLE
PRTL_ATOM_TABLE_ENTRY Buckets[1];
} RTL_ATOM_TABLE, *PRTL_ATOM_TABLE;
#ifndef _NTIFS_
typedef struct _RTL_HEAP_PARAMETERS {
ULONG Length;
SIZE_T SegmentReserve;
SIZE_T SegmentCommit;
SIZE_T DeCommitFreeBlockThreshold;
SIZE_T DeCommitTotalFreeThreshold;
SIZE_T MaximumAllocationSize;
SIZE_T VirtualMemoryThreshold;
SIZE_T InitialCommit;
SIZE_T InitialReserve;
PRTL_HEAP_COMMIT_ROUTINE CommitRoutine;
SIZE_T Reserved[2];
} RTL_HEAP_PARAMETERS, *PRTL_HEAP_PARAMETERS;
#endif
/* Let Kernel Drivers use this */
#ifndef _WINBASE_
typedef struct _SYSTEMTIME

View file

@ -25,7 +25,7 @@ CsrClientConnectToServer(
PVOID Unknown,
PVOID Context,
ULONG ContextLength,
PULONG Unknown2
PBOOLEAN ServerToServerCall
);
NTSTATUS

View file

@ -48,7 +48,7 @@
#define NT_WARNING(x) ((ULONG)(x)>>30==2)
#define NT_ERROR(x) ((ULONG)(x)>>30==3)
/* Object Access Rights FIXME: Some are in w32api's psdk..,is that normal ?*/
/* Object Access Rights */
#define DIRECTORY_QUERY (0x0001)
#define DIRECTORY_TRAVERSE (0x0002)
#define DIRECTORY_CREATE_OBJECT (0x0004)
@ -1418,7 +1418,28 @@ typedef struct _UNICODE_PREFIX_TABLE
PUNICODE_PREFIX_TABLE_ENTRY LastNextEntry;
} UNICODE_PREFIX_TABLE, *PUNICODE_PREFIX_TABLE;
/* FIXME - need FAST_MUTEX and PHANDLE_TABLE for RTL_ATOM_TABLE in umode! */
typedef NTSTATUS
(NTAPI * PRTL_HEAP_COMMIT_ROUTINE)(
IN PVOID Base,
IN OUT PVOID *CommitAddress,
IN OUT PSIZE_T CommitSize
);
typedef struct _RTL_HEAP_PARAMETERS
{
ULONG Length;
SIZE_T SegmentReserve;
SIZE_T SegmentCommit;
SIZE_T DeCommitFreeBlockThreshold;
SIZE_T DeCommitTotalFreeThreshold;
SIZE_T MaximumAllocationSize;
SIZE_T VirtualMemoryThreshold;
SIZE_T InitialCommit;
SIZE_T InitialReserve;
PRTL_HEAP_COMMIT_ROUTINE CommitRoutine;
SIZE_T Reserved[2];
} RTL_HEAP_PARAMETERS, *PRTL_HEAP_PARAMETERS;
typedef void *FAST_MUTEX;
typedef void *PHANDLE_TABLE;

View file

@ -263,7 +263,7 @@ BasepConvertPriorityClass(IN ULONG dwCreationFlags)
}
else
{
ReturnClass = 0 /* FIXME */;
ReturnClass = PROCESS_PRIORITY_CLASS_INVALID;
}
return ReturnClass;

View file

@ -107,7 +107,7 @@ CsrClientConnectToServer(PWSTR ObjectDirectory,
PVOID Unknown,
PVOID Context,
ULONG ContextLength,
PULONG Unknown2)
PBOOLEAN ServerToServerCall)
{
NTSTATUS Status;
UNICODE_STRING PortName = RTL_CONSTANT_STRING(L"\\Windows\\ApiPort");

View file

@ -23,6 +23,15 @@ typedef struct _IO_COMPLETION_PACKET
IO_STATUS_BLOCK IoStatus;
} IO_COMPLETION_PACKET, *PIO_COMPLETION_PACKET;
/* List of Bus Type GUIDs */
typedef struct _IO_BUS_TYPE_GUID_LIST
{
ULONG GuidCount;
FAST_MUTEX Lock;
GUID Guids[1];
} IO_BUS_TYPE_GUID_LIST, *PIO_BUS_TYPE_GUID_LIST;
extern PIO_BUS_TYPE_GUID_LIST IopBusTypeGuidList;
/* Packet Types */
#define IrpCompletionPacket 0x1
#define IrpMiniCompletionPacket 0x2

View file

@ -22,6 +22,7 @@ KSPIN_LOCK IopDeviceTreeLock;
/* DATA **********************************************************************/
PDRIVER_OBJECT IopRootDriverObject;
PIO_BUS_TYPE_GUID_LIST IopBusTypeGuidList = NULL;
/* FUNCTIONS *****************************************************************/
@ -32,6 +33,32 @@ IopGetDeviceNode(
return DeviceObject->DeviceObjectExtension->DeviceNode;
}
NTSTATUS
STDCALL
IopQueryDeviceCapabilities(PDEVICE_NODE DeviceNode,
PDEVICE_CAPABILITIES DeviceCaps)
{
IO_STATUS_BLOCK StatusBlock;
IO_STACK_LOCATION Stack;
/* Set up the Header */
RtlZeroMemory(DeviceCaps, sizeof(DEVICE_CAPABILITIES));
DeviceCaps->Size = sizeof(DEVICE_CAPABILITIES);
DeviceCaps->Version = 1;
DeviceCaps->Address = -1;
DeviceCaps->UINumber = -1;
/* Set up the Stack */
RtlZeroMemory(&Stack, sizeof(IO_STACK_LOCATION));
Stack.Parameters.DeviceCapabilities.Capabilities = DeviceCaps;
/* Send the IRP */
return IopInitiatePnpIrp(DeviceNode->PhysicalDeviceObject,
&StatusBlock,
IRP_MN_QUERY_CAPABILITIES,
&Stack);
}
/*
* @implemented
*/
@ -57,9 +84,11 @@ IoGetDeviceProperty(
OUT PULONG ResultLength)
{
PDEVICE_NODE DeviceNode = IopGetDeviceNode(DeviceObject);
DEVICE_CAPABILITIES DeviceCaps;
ULONG Length;
PVOID Data = NULL;
PWSTR Ptr;
NTSTATUS Status;
DPRINT("IoGetDeviceProperty(0x%p %d)\n", DeviceObject, DeviceProperty);
@ -75,23 +104,30 @@ IoGetDeviceProperty(
/* Complete, untested */
case DevicePropertyBusTypeGuid:
*ResultLength = 39 * sizeof(WCHAR);
if (BufferLength < (39 * sizeof(WCHAR)))
/* Sanity check */
if ((DeviceNode->ChildBusTypeIndex != 0xFFFF) &&
(DeviceNode->ChildBusTypeIndex < IopBusTypeGuidList->GuidCount))
{
/* Return the GUID */
*ResultLength = sizeof(GUID);
/* Check if the buffer given was large enough */
if (BufferLength < *ResultLength)
{
return STATUS_BUFFER_TOO_SMALL;
swprintf((PWSTR)PropertyBuffer,
L"{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
DeviceNode->BusTypeGuid.Data1,
DeviceNode->BusTypeGuid.Data2,
DeviceNode->BusTypeGuid.Data3,
DeviceNode->BusTypeGuid.Data4[0],
DeviceNode->BusTypeGuid.Data4[1],
DeviceNode->BusTypeGuid.Data4[2],
DeviceNode->BusTypeGuid.Data4[3],
DeviceNode->BusTypeGuid.Data4[4],
DeviceNode->BusTypeGuid.Data4[5],
DeviceNode->BusTypeGuid.Data4[6],
DeviceNode->BusTypeGuid.Data4[7]);
}
/* Copy the GUID */
RtlCopyMemory(PropertyBuffer,
&(IopBusTypeGuidList->Guids[DeviceNode->ChildBusTypeIndex]),
sizeof(GUID));
return STATUS_SUCCESS;
}
else
{
return STATUS_OBJECT_NAME_NOT_FOUND;
}
break;
case DevicePropertyLegacyBusType:
Length = sizeof(INTERFACE_TYPE);
@ -99,8 +135,28 @@ IoGetDeviceProperty(
break;
case DevicePropertyAddress:
Length = sizeof(ULONG);
Data = &DeviceNode->Address;
/* Query the device caps */
Status = IopQueryDeviceCapabilities(DeviceNode, &DeviceCaps);
if (NT_SUCCESS(Status) && (DeviceCaps.Address != -1))
{
/* Return length */
*ResultLength = sizeof(ULONG);
/* Check if the buffer given was large enough */
if (BufferLength < *ResultLength)
{
return STATUS_BUFFER_TOO_SMALL;
}
/* Return address */
*(PULONG)PropertyBuffer = DeviceCaps.Address;
return STATUS_SUCCESS;
}
else
{
return STATUS_OBJECT_NAME_NOT_FOUND;
}
break;
// case DevicePropertyUINumber:
@ -453,6 +509,66 @@ IopGetSystemPowerDeviceObject(PDEVICE_OBJECT *DeviceObject)
return STATUS_UNSUCCESSFUL;
}
USHORT
STDCALL
IopGetBusTypeGuidIndex(LPGUID BusTypeGuid)
{
USHORT i = 0, FoundIndex = 0xFFFF;
ULONG NewSize;
PVOID NewList;
/* Acquire the lock */
ExAcquireFastMutex(&IopBusTypeGuidList->Lock);
/* Loop all entries */
while (i < IopBusTypeGuidList->GuidCount)
{
/* Try to find a match */
if (RtlCompareMemory(BusTypeGuid,
&IopBusTypeGuidList->Guids[i],
sizeof(GUID)))
{
/* Found it */
FoundIndex = i;
goto Quickie;
}
}
/* Check if we have to grow the list */
if (IopBusTypeGuidList->GuidCount)
{
/* Calculate the new size */
NewSize = sizeof(IO_BUS_TYPE_GUID_LIST) +
(sizeof(GUID) * IopBusTypeGuidList->GuidCount);
/* Allocate the new copy */
NewList = ExAllocatePool(PagedPool, NewSize);
/* Now copy them, decrease the size too */
NewSize -= sizeof(GUID);
RtlCopyMemory(NewList, IopBusTypeGuidList, NewSize);
/* Free the old list */
ExFreePool(IopBusTypeGuidList);
/* Use the new buffer */
IopBusTypeGuidList = NewList;
}
/* Copy the new GUID */
RtlCopyMemory(&IopBusTypeGuidList->Guids[IopBusTypeGuidList->GuidCount],
BusTypeGuid,
sizeof(GUID));
/* The new entry is the index */
FoundIndex = IopBusTypeGuidList->GuidCount;
IopBusTypeGuidList->GuidCount++;
Quickie:
ExReleaseFastMutex(&IopBusTypeGuidList->Lock);
return FoundIndex;
}
/*
* DESCRIPTION
* Creates a device node
@ -1212,28 +1328,13 @@ IopActionInterrogateDeviceStack(
DPRINT("IopInitiatePnpIrp() failed (Status %x)\n", Status);
}
RtlZeroMemory(&DeviceCapabilities, sizeof(DEVICE_CAPABILITIES));
DeviceCapabilities.Size = sizeof(DEVICE_CAPABILITIES);
DeviceCapabilities.Version = 1;
DeviceCapabilities.Address = -1;
DeviceCapabilities.UINumber = -1;
Stack.Parameters.DeviceCapabilities.Capabilities = &DeviceCapabilities;
Status = IopInitiatePnpIrp(
DeviceNode->PhysicalDeviceObject,
&IoStatusBlock,
IRP_MN_QUERY_CAPABILITIES,
&Stack);
Status = IopQueryDeviceCapabilities(DeviceNode, &DeviceCapabilities);
if (NT_SUCCESS(Status))
{
}
else
{
DPRINT("IopInitiatePnpIrp() failed (Status %x)\n", Status);
}
DeviceNode->CapabilityFlags = *(PULONG)((ULONG_PTR)&DeviceCapabilities + 4);
DeviceNode->Address = DeviceCapabilities.Address;
if (!DeviceCapabilities.UniqueID)
{
@ -1457,20 +1558,16 @@ IopActionInterrogateDeviceStack(
DeviceNode->ChildBusNumber = BusInformation->BusNumber;
DeviceNode->ChildInterfaceType = BusInformation->LegacyBusType;
memcpy(&DeviceNode->BusTypeGuid,
&BusInformation->BusTypeGuid,
sizeof(GUID));
DeviceNode->ChildBusTypeIndex = IopGetBusTypeGuidIndex(&BusInformation->BusTypeGuid);
ExFreePool(BusInformation);
}
else
{
DPRINT("IopInitiatePnpIrp() failed (Status %x)\n", Status);
DeviceNode->ChildBusNumber = -1;
DeviceNode->ChildInterfaceType = -1;
memset(&DeviceNode->BusTypeGuid,
0,
sizeof(GUID));
DeviceNode->ChildBusNumber = 0xFFFFFFF0;
DeviceNode->ChildInterfaceType = InterfaceTypeUndefined;
DeviceNode->ChildBusTypeIndex = -1;
}
DPRINT("Sending IRP_MN_QUERY_RESOURCES to device stack\n");
@ -2026,6 +2123,11 @@ PnpInit(VOID)
KeInitializeSpinLock(&IopDeviceTreeLock);
/* Initialize the Bus Type GUID List */
IopBusTypeGuidList = ExAllocatePool(PagedPool, sizeof(IO_BUS_TYPE_GUID_LIST));
RtlZeroMemory(IopBusTypeGuidList, sizeof(IO_BUS_TYPE_GUID_LIST));
ExInitializeFastMutex(&IopBusTypeGuidList->Lock);
/* Initialize PnP-Event notification support */
Status = IopInitPlugPlayEvents();
if (!NT_SUCCESS(Status))

View file

@ -627,6 +627,31 @@ typedef struct _EX_RUNDOWN_REF {
} DUMMYUNIONNAME;
} EX_RUNDOWN_REF, *PEX_RUNDOWN_REF;
#define EX_PUSH_LOCK_LOCK_V ((ULONG_PTR)0x0)
#define EX_PUSH_LOCK_LOCK ((ULONG_PTR)0x1)
#define EX_PUSH_LOCK_WAITING ((ULONG_PTR)0x2)
#define EX_PUSH_LOCK_WAKING ((ULONG_PTR)0x4)
#define EX_PUSH_LOCK_MULTIPLE_SHARED ((ULONG_PTR)0x8)
#define EX_PUSH_LOCK_SHARE_INC ((ULONG_PTR)0x10)
#define EX_PUSH_LOCK_PTR_BITS ((ULONG_PTR)0xf)
typedef struct _EX_PUSH_LOCK
{
union
{
struct
{
ULONG_PTR Locked:1;
ULONG_PTR Waiting:1;
ULONG_PTR Waking:1;
ULONG_PTR MultipleShared:1;
ULONG_PTR Shared:sizeof (ULONG_PTR) * 8 - 4;
};
ULONG_PTR Value;
PVOID Ptr;
};
} EX_PUSH_LOCK, *PEX_PUSH_LOCK;
typedef struct _FILE_ACCESS_INFORMATION {
ACCESS_MASK AccessFlags;
} FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION;