tags:

views:

45

answers:

1

I have the following C function

typedef struct ekeycore_ctx_ ekeycore_ctx;

typedef struct ekeycore_enum_ ekeycore_enum;

typedef struct ekeycore_device_ {
    char *serial;
    char *portname;
    char *node;
    BOOL present;
    BOOL used;
} ekeycore_device;

typedef struct ekeycore_simple_ ekeycore_simple;

typedef enum {
    EKEYCORE_OK = 0,              /* everything was fine */
    EKEYCORE_NOMEM = 1,           /* out of memory */
    EKEYCORE_NODEVICE = 2,        /* no devices are available */
    EKEYCORE_TIMEOUT = 3,         /* key did not respond to request */
    EKEYCORE_FAULTY = 4,          /* device has reported faulty/attacked */
    EKEYCORE_UNKNOWN = 5          /* unknown error */
} ekeycore_result;

EKEYCORE_API ekeycore_result ekeycore_simple_get(ekeycore_simple *ctx, unsigned char *buff, size_t buffz)

I need to call this function (ekeycore_simple_get) from C#, how would I go about it? How would the variable types above convert?

A: 

You're probably asking a bit much of StackOverflow for someone to work all that out for you, but there is good information about marshalling structs on MSDN (see link below)

These are the places I use for reference to P/invoke techniques:

Will Dean