Scripts are working again. Scripts are now loaded into limited AppDomains (no security yet).
*phew* that only took me 12 hours of coding...afrisby
parent
6faa8d8d68
commit
240712ca9f
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.ScriptEngine.Common
|
||||||
|
{
|
||||||
|
class Executor
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,7 +61,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
|
|
||||||
string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
|
string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
|
||||||
string rootPathSE = Path.GetDirectoryName(this.GetType().Assembly.Location);
|
string rootPathSE = Path.GetDirectoryName(this.GetType().Assembly.Location);
|
||||||
Console.WriteLine("Assembly location: " + rootPath);
|
//Console.WriteLine("Assembly location: " + rootPath);
|
||||||
parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Common.dll"));
|
parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Common.dll"));
|
||||||
parameters.ReferencedAssemblies.Add(Path.Combine(rootPathSE, "OpenSim.Region.ScriptEngine.DotNetEngine.dll"));
|
parameters.ReferencedAssemblies.Add(Path.Combine(rootPathSE, "OpenSim.Region.ScriptEngine.DotNetEngine.dll"));
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ using System.Text;
|
||||||
using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler;
|
using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler;
|
||||||
using OpenSim.Region.ScriptEngine.Common;
|
using OpenSim.Region.ScriptEngine.Common;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
{
|
{
|
||||||
|
@ -46,6 +48,33 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ExecuteEvent(string FunctionName, object[] args)
|
||||||
|
{
|
||||||
|
//foreach (MemberInfo mi in this.GetType().GetMembers())
|
||||||
|
//{
|
||||||
|
//if (mi.ToString().ToLower().Contains("default"))
|
||||||
|
//{
|
||||||
|
// Console.WriteLine("Member found: " + mi.ToString());
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
|
||||||
|
Type type = this.GetType();
|
||||||
|
|
||||||
|
Console.WriteLine("ScriptEngine Invoke: \"" + this.State() + "_event_" + FunctionName + "\"");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
type.InvokeMember(this.State() + "_event_" + FunctionName, BindingFlags.InvokeMethod, null, this, args);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// TODO: Send to correct place
|
||||||
|
Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -226,96 +226,102 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
{
|
{
|
||||||
|
|
||||||
//LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceAndUnwrap(FileName, "SecondLife.Script");
|
//LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceAndUnwrap(FileName, "SecondLife.Script");
|
||||||
Console.WriteLine("Base directory: " + AppDomain.CurrentDomain.BaseDirectory);
|
//Console.WriteLine("Base directory: " + AppDomain.CurrentDomain.BaseDirectory);
|
||||||
|
|
||||||
//LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script");
|
LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script");
|
||||||
LSL_BuiltIn_Commands_Interface mbrt = (LSL_BuiltIn_Commands_Interface)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script");
|
//LSL_BuiltIn_Commands_Interface mbrt = (LSL_BuiltIn_Commands_Interface)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script");
|
||||||
Type mytype = mbrt.GetType();
|
Type mytype = mbrt.GetType();
|
||||||
|
|
||||||
Console.WriteLine("is proxy={0}", RemotingServices.IsTransparentProxy(mbrt));
|
Console.WriteLine("is proxy={0}", RemotingServices.IsTransparentProxy(mbrt));
|
||||||
|
|
||||||
|
|
||||||
//mbrt.Start();
|
//mbrt.Start();
|
||||||
return (LSL_BaseClass)mbrt;
|
return mbrt;
|
||||||
|
//return (LSL_BaseClass)mbrt;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Loading Assembly " + FileName);
|
// //myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Loading Assembly " + FileName);
|
||||||
// Load .Net Assembly (.dll)
|
// // Load .Net Assembly (.dll)
|
||||||
// Initialize and return it
|
// // Initialize and return it
|
||||||
|
|
||||||
// TODO: Add error handling
|
// // TODO: Add error handling
|
||||||
// Script might not follow our rules since users can upload -anything-
|
// // Script might not follow our rules since users can upload -anything-
|
||||||
|
|
||||||
Assembly a;
|
// Assembly a;
|
||||||
//try
|
// //try
|
||||||
//{
|
// //{
|
||||||
|
|
||||||
|
|
||||||
// Load to default appdomain (temporary)
|
// // Load to default appdomain (temporary)
|
||||||
a = Assembly.LoadFrom(FileName);
|
// a = Assembly.LoadFrom(FileName);
|
||||||
// Load to specified appdomain
|
// // Load to specified appdomain
|
||||||
// TODO: Insert security
|
// // TODO: Insert security
|
||||||
//a = FreeAppDomain.Load(FileName);
|
// //a = FreeAppDomain.Load(FileName);
|
||||||
//}
|
// //}
|
||||||
//catch (Exception e)
|
// //catch (Exception e)
|
||||||
//{
|
// //{
|
||||||
//}
|
// //}
|
||||||
|
|
||||||
|
|
||||||
//foreach (Type _t in a.GetTypes())
|
// //foreach (Type _t in a.GetTypes())
|
||||||
//{
|
// //{
|
||||||
// Console.WriteLine("Type: " + _t.ToString());
|
// // Console.WriteLine("Type: " + _t.ToString());
|
||||||
//}
|
// //}
|
||||||
|
|
||||||
Type t;
|
// Type t;
|
||||||
//try
|
// //try
|
||||||
//{
|
// //{
|
||||||
t = a.GetType("SecondLife.Script", true);
|
// t = a.GetType("SecondLife.Script", true);
|
||||||
//}
|
// //}
|
||||||
//catch (Exception e)
|
// //catch (Exception e)
|
||||||
//{
|
// //{
|
||||||
//}
|
// //}
|
||||||
|
|
||||||
// Create constructor arguments
|
// // Create constructor arguments
|
||||||
object[] args = new object[]
|
// object[] args = new object[]
|
||||||
{
|
// {
|
||||||
// this,
|
//// this,
|
||||||
// host
|
//// host
|
||||||
};
|
// };
|
||||||
|
|
||||||
return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t, args );
|
// return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t, args );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void ExecuteFunction(IScriptHost ObjectID, string ScriptID, string FunctionName, object[] args)
|
internal void ExecuteFunction(IScriptHost ObjectID, string ScriptID, string FunctionName, object[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Execute a function in the script
|
||||||
m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function ObjectID: " + ObjectID + ", ScriptID: " + ScriptID + ", FunctionName: " + FunctionName);
|
m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function ObjectID: " + ObjectID + ", ScriptID: " + ScriptID + ", FunctionName: " + FunctionName);
|
||||||
OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = m_scriptEngine.myScriptManager.GetScript(ObjectID, ScriptID);
|
OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = m_scriptEngine.myScriptManager.GetScript(ObjectID, ScriptID);
|
||||||
|
|
||||||
Type type = Script.GetType();
|
Script.ExecuteEvent(FunctionName, args);
|
||||||
|
|
||||||
|
//Type type = Script.GetType();
|
||||||
|
|
||||||
|
|
||||||
m_scriptEngine.Log.Verbose("ScriptEngine", "Invoke: \"" + Script.State() + "_event_" + FunctionName + "\"");
|
////foreach (MemberInfo mi in type.GetMembers())
|
||||||
|
////{
|
||||||
|
//// Common.SendToDebug("Member found: " + mi.ToString());
|
||||||
|
////}
|
||||||
|
|
||||||
try
|
//m_scriptEngine.Log.Verbose("ScriptEngine", "Invoke: \"" + Script.State() + "_event_" + FunctionName + "\"");
|
||||||
{
|
|
||||||
type.InvokeMember(Script.State() + "_event_" + FunctionName, BindingFlags.InvokeMethod, null, Script, args);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_scriptEngine.Log.Error("ScriptEngine", "Exception attempting to executing script function: " + e.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//try
|
||||||
//foreach (MemberInfo mi in type.GetMembers())
|
|
||||||
//{
|
//{
|
||||||
// Common.SendToDebug("Member found: " + mi.ToString());
|
// type.InvokeMember(Script.State() + "_event_" + FunctionName, BindingFlags.InvokeMethod, null, Script, args);
|
||||||
//}
|
//}
|
||||||
|
//catch (Exception e)
|
||||||
|
//{
|
||||||
|
// m_scriptEngine.Log.Error("ScriptEngine", "Exception attempting to executing script function: " + e.ToString());
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue