Functions and pointers
-
How can I get the unmanaged pointer of a managed method in C# so that I can store it in an integer within unmanaged memory? Also, how can I wrap an object around a pointer, with In/Out capabilities? It sounds kind of complicated, but I believe it is possible somehow. I'm trying to use a DLL in my program, which creates and uses a custom structure (in this case in the unmanaged memory). Luckily, there is a function in the DLL which allows me to retrieve the address of the structure, and I know all of the members in that structure through documentation. The part that trips me up is that the structure stores pointers to functions, and in order to use the DLL the way I would like, I want to change those pointers to my managed C# methods. As for the structure itself, I would like to wrap a managed structure around a pointer so that I can access the fields within it as well as write to those fields, kind of like a two-way link between the managed and unmanaged memory... I only wish there were an easier way to explain all this. Does anybody know what I'm talking about?
-
How can I get the unmanaged pointer of a managed method in C# so that I can store it in an integer within unmanaged memory? Also, how can I wrap an object around a pointer, with In/Out capabilities? It sounds kind of complicated, but I believe it is possible somehow. I'm trying to use a DLL in my program, which creates and uses a custom structure (in this case in the unmanaged memory). Luckily, there is a function in the DLL which allows me to retrieve the address of the structure, and I know all of the members in that structure through documentation. The part that trips me up is that the structure stores pointers to functions, and in order to use the DLL the way I would like, I want to change those pointers to my managed C# methods. As for the structure itself, I would like to wrap a managed structure around a pointer so that I can access the fields within it as well as write to those fields, kind of like a two-way link between the managed and unmanaged memory... I only wish there were an easier way to explain all this. Does anybody know what I'm talking about?
look up "unsafe" and Marshal.ReadIntxxx and WriteIntxxx (among the other Marshal.xxx functions). Marc Latest AAL Article My blog Join my forum!