Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
M

magnat69

@magnat69
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Unmanaged C#, c++ compiled dll
    M magnat69

    Hope you can give me a little bit more help anyway here is code snippet how i would use the functions / structs in c++ and create a simple TCP packet. #include int main(int argc, char **argv) { libnet_t *lib_pointer = NULL; //type from libnet.h libnet_ptag_t tcp,ip; //type from libnet.h char *device = NULL; char errbuff[1024]; write int; lib_pointer = libnet_init(LIBNET_RAW4, device, errbuff); //build TCP tcp = libnet_build_tcp(..,..,..,.,lib_pointer,...); //build IP ip = libnet_build_ip(..,..,..,lib_pointer,.....); //lets put the packet on the wire write=libnet_write(lib_pointer); My main question is how can i use the types, consts which are defined in libnet.h ala the .dll file i compiled in vc++. You made the statement about this IntPtr, which i marshal to a PtrToStruct, well so i could also create a PtrToStruct type in c# and let it point to eg. libnet_t? What i did not really understand is the interface thing you mentioned, could you explain this a bit more deeply? Thanks for your time again.

    C# question csharp c++ help tutorial

  • Unmanaged C#, c++ compiled dll
    M magnat69

    Hi, i have a dynamic link library (compiled in VC++ 7.0) and want to use the functions(and types,structs) in my c# program, i already read some articles on this msg-board about unmanaged code, just those only show easy functions with simple return-paramaters. eg.: [DllImport("kernel32")] public static extern void Sleep(int dwMilliseconds); What if the functions return parameter is a pointer to a complex structure(eg.: chained lists)? As example, i am trying to import functions from a packet construction library called libnet, alone the init function of this library looks like this: libnet_t * libnet_init(int injection_type, int8_t *device, int8_t *err_buf); My question now is can someone explain/show/link me how i marshall such return/call by reference variables, will i have to write a wrapper class which acts as a interface between my c# program and the c++ dll, if yes how? If you can help provide an easy code snippet and show me how i need to start or point me to a book/website/etc. Thanks in advance....

    C# question csharp c++ help tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups