I have created two different Visual C# dll's that make use of DeviceIOControl calls and I have defined them as below:
In first dll:
[DllImport("kernel32.dll", SetLastError = true)]
static extern BOOL DeviceIoControl(
HANDLE hDevice,
DWORD dwIoControlCode,
ref Internal_COMMAND lpInBuffer,
DWORD nInBufferSize,
ref ulong lpOutBuffer,
DWORD nOutBufferSize,
ref DWORD lpBytesReturned,
LPOVERLAPPED lpOverlapped);
public struct Internal_COMMAND
{
public ulong Address;
public ulong Command;
};
In second dll:
[DllImport("kernel32.dll", SetLastError = true)]
static extern BOOL DeviceIoControl(
HANDLE hDevice,
DWORD dwIoControlCode,
ref char[] lpInBuffer,
DWORD nInBufferSize,
ref char[] lpOutBuffer,
DWORD nOutBufferSize,
ref DWORD lpBytesReturned,
LPOVERLAPPED lpOverlapped);
But now I have to make them as a single dll within the same class. So I tried to use the below.
[DllImport("kernel32.dll", SetLastError = true)]
static extern BOOL DeviceIoControl(
HANDLE hDevice,
DWORD dwIoControlCode,
ref char[] lpInBuffer,
DWORD nInBufferSize,
ref char[] lpOutBuffer,
DWORD nOutBufferSize,
ref DWORD lpBytesReturned,
LPOVERLAPPED lpOverlapped);
as common definition and passed the variables by converting structure to character array. But the driver does not work as expected
Please guide me with the correct procedure to follow