News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Calling C# dll exports from asm

Started by K_F, July 04, 2015, 06:54:52 AM

Previous topic - Next topic

K_F

Does anyone know of any Asm examples for calling C# dll exports dynamically.. ?
A C++ example would be ok as well,  I can convert it.

Thanks
:idea:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

Tedd

Potato2

K_F

Yeah.. I've been looking at that - thought there might be an Asm example lying around... not to worry though I'll make one.
:biggrin:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

Zen

VAN,
You're referring to an exported .NET Framework class ???
VERTOGRAD wrote an exploratory app about a year ago: Finally I did it ...
VERTOGRAD explains in great detail: Here's the sequence of calls for obtaining the pointer to virtual functions table of _AppDomain interface,...

K_F

Actually I was thinking of writing a small mod for a game.. which unfortunately is written in C# (heaven knows why ?)
The thing is that I'm not sure whether the game exports functions outside .NET..

So I'm going to have to fiddle with COM and check if the GUIs are available.
The developers supply the interface (API) code for modders and I can extract the GUIs with IDA.
I'll give it a try.. otherwise I have to resort to ....ssshhh... keep quiet...Scripting in C# :-)
:shock: :icon_rolleyes: :greensml:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

Zen

#5
Hi, VAN,   
DirectX can be accessed as managed (.NET Framework) code,...which is probably why the game was written in C#.
I just assumed that since you are interoperating with a C# module that it was a .NET Framework class or component. The .NET Framework is designed so that you can execute native code from within the C# module. The whole Interop syntax (it was engineered primarily for COM and NET interoperability) is a pain in the ass,...and, very easy to get wrong. I don't even know how you would do it in MASM (but, I'll bet EDGAR or QWORD does). I assume that it's possible, but, prototyping the various C# routines would be a challenge.
It's been years since I wrote any NET Framework code, but, as I recall there is a utility that uses MetaData to disassemble a NET Framework app.
I think it's: (Ildasm.exe, IL Disassembler).

These sites might be helpful:
Ildasm.exe Tutorial, MSDN
Reflection in the .NET Framework, MSDN
Interoperating with Unmanaged Code. MSDN