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 central processing center, there is a project for Wi-Fi Dot there. Question: how to transfer structures to a WB dot is not available 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 Marshall through uncontrollable pieces of memory tried, crashes to protect the record

  • Give an example of how they tried. If it crashes, it means that the <<>> unmanaged transfer is not implemented correctly. - αλεχολυτ
  • added the code in the answer to himself - Dow Jhob
  • @DowJhob don't do that. Add parts of the question directly to the question. - D-side

1 answer 1

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, in a wrapper point them 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 call like this:

 serialNum(DevID, TX_IOCTL_APP_SERVICE, inbuf1, outbuf1)