Author |
Message |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Fri Aug 11, 2006 1:27 am Post subject: Invoking Mono from an ASSS Module |
 |
|
|
|
Just a small test I did to see if I could, I was somewhat successful in running c# code from a c module.
Basically all it does when you type ?length <something> it calls a c# function contained in test.dll to get the length of the string and it returns that value to be displayed in log.
In the original mono version I had, there was a bug that caused a segfault any time you try to load the jit from a non-main thread. I updated to a more recent version and that problem was solved. The command executes fine, the only problem now is that it segfaults any time I try to destroy the jit (like in MM_UNLOAD). I'm probably doing something wrong from either end, but I don't know what it is.
For anyone that wishes to experiment, here's how I set it up (on linux):
Compile test.dll and stick it in your root asss folder
In the module makefile you'll also need to include the output from in your cflags and
in your ldflags
I put all of the log messages as 'E' so they would display on the screen, most of them aren't errors though.
Once its ready, insmod it and ?length something
While this is somewhat neat, I doubt it will go very far because I have absolutely no idea how to make a module loader. _________________
ASSS module
cs.c - 3.25 KB
File downloaded or viewed 65 time(s)
C# class (remove the .txt)
test.cs.txt - 0.23 KB
File downloaded or viewed 76 time(s)
|
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri Aug 11, 2006 10:14 am Post subject: |
 |
|
|
|
HULK SMASH PUNY HUMAN! HULK ANGRY! HULK!
 _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
|
|
Back to top |
|
 |
Elnino Newbie
Joined: Aug 10 2006 Posts: 14 Offline
|
Posted: Fri Aug 11, 2006 10:56 am Post subject: |
 |
|
|
|
Whoa that's really hawt !
Can't wait for the C# full interface =)
|
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Sat Aug 12, 2006 12:31 pm Post subject: |
 |
|
|
|
If I knew enough C and ASSS to be able to write a full C# interface, I wouldn't need to write one
|
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Sun Aug 13, 2006 7:39 am Post subject: |
 |
|
|
|
Just an update, still haven't tracked down why it fails to clean up but I did manage to get Length() to call lm->Log() itself
cs.c
mono_add_internal_call("NS.MonoEmbed::Log", lm->Log);
|
test.cs
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern void Log(char filter, IntPtr msg);
public int Length(string s)
{
string msg = "string has length of "+ s.Length;
MonoEmbed.Log('E', Marshal.StringToHGlobalAnsi(msg));
return s.Length;
}
|
D1st0rt> ?length how long is this string
E string has length of 23
|
|
Back to top |
|
 |
|