Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Invoking Mono from an ASSS Module

 
Post new topic   Reply to topic Printable version
 View previous topic  Building asss 1.4.3 in MSVC 7.1 (.NET ... Post :: Post chatmenu  View next topic  
Author Message
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Fri Aug 11, 2006 1:27 am    Post subject: Invoking Mono from an ASSS Module Reply to topic Reply with quote

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
Code: Show/Hide
mcs -t:library test.cs

In the module makefile you'll also need to include the output from
Code: Show/Hide
pkg-config --cflags mono
in your cflags and
Code: Show/Hide
pkg-config --libs mono
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 59 time(s)

C# class (remove the .txt)

test.cs.txt - 0.23 KB
File downloaded or viewed 66 time(s)
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Cyan~Fire
I'll count you!
I'll count you!


Age:36
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Fri Aug 11, 2006 10:14 am    Post subject: Reply to topic Reply with quote

HULK SMASH PUNY HUMAN! HULK ANGRY! HULK!

icon_sad.gif
_________________
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
View users profile Send private message Add User to Ignore List Visit posters website
Elnino
Newbie


Joined: Aug 10 2006
Posts: 14
Offline

PostPosted: Fri Aug 11, 2006 10:56 am    Post subject: Reply to topic Reply with quote

Whoa that's really hawt !

Can't wait for the C# full interface =)
Back to top
View users profile Send private message Add User to Ignore List
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Sat Aug 12, 2006 12:31 pm    Post subject: Reply to topic Reply with quote

If I knew enough C and ASSS to be able to write a full C# interface, I wouldn't need to write one biggrin.gif
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Sun Aug 13, 2006 7:39 am    Post subject: Reply to topic Reply with quote

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
Code: Show/Hide
mono_add_internal_call("NS.MonoEmbed::Log", lm->Log);

test.cs
Code: Show/Hide
[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
View users profile Send private message Add User to Ignore List Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Custom Projects All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 675 page(s) served in previous 5 minutes.

phpBB Created this page in 0.485065 seconds : 32 queries executed (80.6%): GZIP compression disabled