_IRP Statement bugfix
Referring to MSDN, it has been compiled and passed after the correction
union IRP__AssociatedIrp
MasterIrp as PIRP
IrpCount as LONG
SystemBuffer as PVOID
end union
type IRP__Overlay__AsynchronousParameters
UserApcRoutine as PIO_APC_ROUTINE
IssuingProcess as PVOID
UserApcContext as PVOID
IoRing as any ptr '_IORING_OBJECT ptr |Can't Find _IORING_OBJECT Info!
end type
union IRP__Overlay
AsynchronousParameters as IRP__Overlay__AsynchronousParameters
AllocationSize as LARGE_INTEGER
end union
type IRP__Tail__Overlay
DeviceQueueEntry as KDEVICE_QUEUE_ENTRY
DriverContext(3) as PVOID
Thread as PETHREAD
AuxiliaryBuffer as PCHAR
ListEntry as LIST_ENTRY
CurrentStackLocation as PIO_STACK_LOCATION
PacketType as ULONG
OriginalFileObject as PFILE_OBJECT
end type
union IRP__Tail
Overlay as IRP__Tail__Overlay
Apc as KAPC
CompletionKey as PVOID
end union
type _IRP
Type as _CSHORT
Size as USHORT
MdlAddress as PMDL
Flags as ULONG
AssociatedIrp as IRP__AssociatedIrp 'UNION IRP__AssociatedIrp
ThreadListEntry as LIST_ENTRY
IoStatus as IO_STATUS_BLOCK
RequestorMode as KPROCESSOR_MODE
PendingReturned as BOOLEAN
StackCount as CHAR
CurrentLocation as CHAR
Cancel as BOOLEAN
CancelIrql as KIRQL
ApcEnvironment as CCHAR
AllocationFlags as UCHAR
UserIosb as PIO_STATUS_BLOCK 'UNION NoName
IoRingContext as PVOID 'UNION NoName
UserEvent as PKEVENT
Overlay as IRP__Overlay 'UNION IRP__Overlay
CancelRoutine as PDRIVER_CANCEL
UserBuffer as PVOID
Tail as IRP__Tail 'UNION IRP__Tail
end type
fix type IO_STATUS_BLOCK as IO_STATUS_BLOCK__u
Reminder: use ``` around code to format it as code. I edited your post again.
Thanks but your translation seems to have some mistakes. You are mixing up types and unions. For example in C++:
struct {
union {
KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
struct {
PVOID DriverContext[4];
};
};
PETHREAD Thread;
...
} Overlay;
while you wrote
type IRP__Tail__Overlay
DeviceQueueEntry as KDEVICE_QUEUE_ENTRY
DriverContext(3) as PVOID
Thread as PETHREAD
...
end type
IRP__Overlay__AsynchronousParameters is similarly wrong. Please check everything.
But the existing FB declaration of _IRP seems to be way off!
basic default 0 to 3=4
Please read about what a union is. FB's documentation is here.
I tried to compile a test program that simply does #include "win/ddk/winddk.bi" but I get the error:
/home/ralph/local/fbc-git/include/freebasic/win/ntdef.bi(30) error 23: File not found, "excpt.bi" in '#include once "excpt.bi"'
There is no excpt.bi file. Does anyone know why it's missing? How did you get to compile?
Regardless, I used fbfrog to translate the C++ definition I linked to. It only took me a couple minutes (I had to make a couple small edits like removing __volatile), and I recommend you use fbfrog or other tool to do large or complex translations, to avoid introducing errors by hand. Then I slightly renamed the types to match how they are named in FB's existing winddk.bi. I got:
union IRP__AssociatedIrp
MasterIrp as IRP ptr
IrpCount as LONG
SystemBuffer as PVOID
end union
type IRP__Overlay__AsynchronousParameters
union
UserApcRoutine as PIO_APC_ROUTINE
IssuingProcess as PVOID
end union
union
UserApcContext as PVOID
'IoRing as _IORING_OBJECT ptr
IoRing as PVOID
end union
end type
union IRP__Overlay
AsynchronousParameters as IRP__Overlay__AsynchronousParameters
AllocationSize as LARGE_INTEGER
end union
type IRP__Tail__Overlay
union
DeviceQueueEntry as KDEVICE_QUEUE_ENTRY
type
DriverContext(0 to 3) as PVOID
end type
end union
Thread as PETHREAD
AuxiliaryBuffer as PCHAR
union
type
ListEntry as LIST_ENTRY
union
CurrentStackLocation as _IO_STACK_LOCATION ptr
PacketType as ULONG
end union
end type
end union
OriginalFileObject as PFILE_OBJECT
end type
union IRP__Tail
Overlay as IRP__Tail__Overlay
Apc as KAPC
CompletionKey as PVOID
end union
type _IRP
as CSHORT Type
Size as USHORT
MdlAddress as PMDL
Flags as ULONG
AssociatedIrp as IRP__AssociatedIrp
ThreadListEntry as LIST_ENTRY
IoStatus as IO_STATUS_BLOCK
RequestorMode as KPROCESSOR_MODE
PendingReturned as BOOLEAN
StackCount as CHAR
CurrentLocation as CHAR
Cancel as BOOLEAN
CancelIrql as KIRQL
ApcEnvironment as CCHAR
AllocationFlags as UCHAR
union
UserIosb as PIO_STATUS_BLOCK
IoRingContext as PVOID
end union
UserEvent as PKEVENT
Overlay as IRP__Overlay
CancelRoutine as PDRIVER_CANCEL
UserBuffer as PVOID
Tail as IRP__Tail
end type
Does this work for you?
Oh, I see you wrote about it in a forum thread, very nice. You wrote you needed to make fixes to the headers to get around the missing excpt.bi and other problems. It would be great if you could contribute your fixes.
Please read about what a union is. FB's documentation is here.
I tried to compile a test program that simply does
#include "win/ddk/winddk.bi"but I get the error:/home/ralph/local/fbc-git/include/freebasic/win/ntdef.bi(30) error 23: File not found, "excpt.bi" in '#include once "excpt.bi"'There is no excpt.bi file. Does anyone know why it's missing? How did you get to compile?Regardless, I used fbfrog to translate the C++ definition I linked to. It only took me a couple minutes (I had to make a couple small edits like removing
__volatile), and I recommend you use fbfrog or other tool to do large or complex translations, to avoid introducing errors by hand. Then I slightly renamed the types to match how they are named in FB's existing winddk.bi. I got:union IRP__AssociatedIrp MasterIrp as IRP ptr IrpCount as LONG SystemBuffer as PVOID end union type IRP__Overlay__AsynchronousParameters union UserApcRoutine as PIO_APC_ROUTINE IssuingProcess as PVOID end union union UserApcContext as PVOID 'IoRing as _IORING_OBJECT ptr IoRing as PVOID end union end type union IRP__Overlay AsynchronousParameters as IRP__Overlay__AsynchronousParameters AllocationSize as LARGE_INTEGER end union type IRP__Tail__Overlay union DeviceQueueEntry as KDEVICE_QUEUE_ENTRY type DriverContext(0 to 3) as PVOID end type end union Thread as PETHREAD AuxiliaryBuffer as PCHAR union type ListEntry as LIST_ENTRY union CurrentStackLocation as _IO_STACK_LOCATION ptr PacketType as ULONG end union end type end union OriginalFileObject as PFILE_OBJECT end type union IRP__Tail Overlay as IRP__Tail__Overlay Apc as KAPC CompletionKey as PVOID end union type _IRP as CSHORT Type Size as USHORT MdlAddress as PMDL Flags as ULONG AssociatedIrp as IRP__AssociatedIrp ThreadListEntry as LIST_ENTRY IoStatus as IO_STATUS_BLOCK RequestorMode as KPROCESSOR_MODE PendingReturned as BOOLEAN StackCount as CHAR CurrentLocation as CHAR Cancel as BOOLEAN CancelIrql as KIRQL ApcEnvironment as CCHAR AllocationFlags as UCHAR union UserIosb as PIO_STATUS_BLOCK IoRingContext as PVOID end union UserEvent as PKEVENT Overlay as IRP__Overlay CancelRoutine as PDRIVER_CANCEL UserBuffer as PVOID Tail as IRP__Tail end typeDoes this work for you?
I am now modifying the BI file after https://www.freebasic.net/forum/viewtopic.php?t=31647 PS: There are still quite a few fixes and updates, but you can compile the sample driver.