c++ – Vb .net unmanaged dll and all all all


There is a dll for working with the j2534 protocol from the open port2.0 package, there is a working sample for it on the cpp, there is no project on the wb pillbox. Question: how to transfer structures to wb there is no dot if in the original sample the function call is organized as follows: passthruioctl (unsigned long devid, unsigned long ioctl, const void * pInput, void * pOut)


Ps tried to marshal through unmanaged chunks of memory, crashes on write protection


right like this:

  <StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Ansi)> Public Structure inbuf
    <MarshalAs(UnmanagedType.U4)> Public length As UInt32
    <MarshalAs(UnmanagedType.U4)> Public svcid As UInt32
    <MarshalAs(UnmanagedType.U2)> Public infosvcid As UInt16
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1)> Public Structure outbuf
    <MarshalAs(UnmanagedType.U4)> Public length As UInt32
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=256)> Public data() As Byte
End Structure

marshal structures, specify them in the wrapper byref

Public Declare Function serialNum Lib "op20pt32.dll" Alias "PassThruIoctl" (ByVal ChannelID As UInt32, ByVal IoctlID As UInt32, ByRef pInput As inbuf, ByRef pOutput As outbuf) As Integer

and the call is like this:

serialNum(DevID, TX_IOCTL_APP_SERVICE, inbuf1, outbuf1)
Scroll to Top