J
Juan Pedro Gonzalez
Helo,
I'm having problems here with the input buffer.... Ive defined the API call
as:
<System.Runtime.InteropServices.DllImport("kernel32", SetLastError:=True)> _
Private Shared Function DeviceIoControl(ByVal hDevice As IntPtr, ByVal
dwIoControlCode As Integer, ByVal lpInBuffer As IntPtr, ByVal nInBuffer As
Integer, ByRef lpOutBuffer As IntPtr, ByVal nOutBufferSize As Integer, ByRef
lbBytesResturned As Integer, ByVal lpOverlapped As IntPtr) As Boolean
End Function
<System.Runtime.InteropServices.DllImport("kernel32", SetLastError:=True)> _
Private Shared Function DeviceIoControl(ByVal hDevice As IntPtr, ByVal
dwIoControlCode As Integer, ByVal lpInBuffer As IntPtr, ByVal nInBuffer As
Integer, ByRef lpOutBuffer As Object, ByVal nOutBufferSize As Integer, ByRef
lbBytesResturned As Integer, ByVal lpOverlapped As IntPtr) As Boolean
End Function
Al right, use CreateFile to get a handle to my device, I issue
DeviceIoControl(Me.m_Handle, IOCTL_NDISUIO_BIND_WAIT, IntPtr.Zero, 0,
IntPtr.Zero, 0, nBytesReturned, IntPtr.Zero)
wich works fine, but when I can't figure how to query the device. For
example:
DeviceIoControl(Me.m_Handle, IOCTL_NDISUIO_QUERY_BINDING, p,
System.Runtime.Interop.Marshal.sizeof(p), oBuffer, Me.m_Buffer.Length,
dwBytesWritten, IntPtr.Zero)
(Where p is a structure). This fails all the time at, it seems to throw an
exception at System.Runtime.Interop.Marshal.sizeof(p), .
This code also exists in C# where the code is:
fixed (byte* buf = Buffer)
{
...
NDISUIO_QUERY_BINDING* p = (NDISUIO_QUERY_BINDING*)buf;
...
DeviceIoControl(DriverHandle, IOCTL_NDISUIO_QUERY_BINDING, new
IntPtr(p), sizeof(NDISUIO_QUERY_BINDING), new IntPtr(buf), Buffer.Length,
out dwBytesWritten, IntPtr.Zero)
...
}
I cann't manage to port this code to VB .NET and would be pleased to receive
some help on this issue. I'm having problems to get around those pointers...
Thanyou in advance,
Juan Pedro Gonzalez
I'm having problems here with the input buffer.... Ive defined the API call
as:
<System.Runtime.InteropServices.DllImport("kernel32", SetLastError:=True)> _
Private Shared Function DeviceIoControl(ByVal hDevice As IntPtr, ByVal
dwIoControlCode As Integer, ByVal lpInBuffer As IntPtr, ByVal nInBuffer As
Integer, ByRef lpOutBuffer As IntPtr, ByVal nOutBufferSize As Integer, ByRef
lbBytesResturned As Integer, ByVal lpOverlapped As IntPtr) As Boolean
End Function
<System.Runtime.InteropServices.DllImport("kernel32", SetLastError:=True)> _
Private Shared Function DeviceIoControl(ByVal hDevice As IntPtr, ByVal
dwIoControlCode As Integer, ByVal lpInBuffer As IntPtr, ByVal nInBuffer As
Integer, ByRef lpOutBuffer As Object, ByVal nOutBufferSize As Integer, ByRef
lbBytesResturned As Integer, ByVal lpOverlapped As IntPtr) As Boolean
End Function
Al right, use CreateFile to get a handle to my device, I issue
DeviceIoControl(Me.m_Handle, IOCTL_NDISUIO_BIND_WAIT, IntPtr.Zero, 0,
IntPtr.Zero, 0, nBytesReturned, IntPtr.Zero)
wich works fine, but when I can't figure how to query the device. For
example:
DeviceIoControl(Me.m_Handle, IOCTL_NDISUIO_QUERY_BINDING, p,
System.Runtime.Interop.Marshal.sizeof(p), oBuffer, Me.m_Buffer.Length,
dwBytesWritten, IntPtr.Zero)
(Where p is a structure). This fails all the time at, it seems to throw an
exception at System.Runtime.Interop.Marshal.sizeof(p), .
This code also exists in C# where the code is:
fixed (byte* buf = Buffer)
{
...
NDISUIO_QUERY_BINDING* p = (NDISUIO_QUERY_BINDING*)buf;
...
DeviceIoControl(DriverHandle, IOCTL_NDISUIO_QUERY_BINDING, new
IntPtr(p), sizeof(NDISUIO_QUERY_BINDING), new IntPtr(buf), Buffer.Length,
out dwBytesWritten, IntPtr.Zero)
...
}
I cann't manage to port this code to VB .NET and would be pleased to receive
some help on this issue. I'm having problems to get around those pointers...
Thanyou in advance,
Juan Pedro Gonzalez