cnd
cnd

Reputation: 33774

DllImport - C types to .NET types

I've got dll function

DLLExport int PatchSomething(char*, char*, DWORD, unsigned char*, unsigned short int);

but can't fully transfer parameters to .NET

F# :

module RNInvoke

open System
open System.Runtime.InteropServices
open Microsoft.FSharp.NativeInterop
open Microsoft.FSharp.Math

module Native =
    [<System.Runtime.InteropServices.DllImport("DesuDLL.dll",EntryPoint="add")>]
    extern int PatchSomething(char*, char*, DWORD, unsigned char*, unsigned short int);

or C#

[DllImport("DesuDLL.dll")]
private static extern int PatchSomething(char*, char*, DWORD, unsigned char*, unsigned short int);

errors on unsigned char* and unsigned short int

Upvotes: 3

Views: 3166

Answers (1)

Lloyd
Lloyd

Reputation: 29668

Try something like:

[DllImport("DesuDLL.dll")]
private static extern int PatchSomething(string a,string b,uint c,string d,ushort e);

You might need to throw CharSet = Auto into the attribute too. My only concerns are on the unsigned char pointer.

Upvotes: 2

Related Questions