This commit is contained in:
Sardelka 2022-08-05 16:13:56 +08:00
commit 8c10d24842
3 changed files with 0 additions and 135 deletions

View File

@ -46,7 +46,6 @@
<Compile Include="Scripting\API.cs" /> <Compile Include="Scripting\API.cs" />
<Compile Include="Scripting\BaseScript.cs" /> <Compile Include="Scripting\BaseScript.cs" />
<Compile Include="Scripting\ClientScript.cs" /> <Compile Include="Scripting\ClientScript.cs" />
<Compile Include="Scripting\ResourceDomain.cs" />
<Compile Include="Scripting\Resources.cs" /> <Compile Include="Scripting\Resources.cs" />
<Compile Include="Security.cs" /> <Compile Include="Security.cs" />
<Compile Include="Settings.cs" /> <Compile Include="Settings.cs" />
@ -243,17 +242,6 @@
<ItemGroup> <ItemGroup>
<Content Include="FodyWeavers.xml" /> <Content Include="FodyWeavers.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<COMReference Include="mscoree">
<Guid>{5477469E-83B1-11D2-8B49-00A0C9B7C9C4}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>4</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.6.6.3\build\Fody.targets" Condition="Exists('..\packages\Fody.6.6.3\build\Fody.targets')" /> <Import Project="..\packages\Fody.6.6.3\build\Fody.targets" Condition="Exists('..\packages\Fody.6.6.3\build\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

View File

@ -1,92 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RageCoop.Core;
using System.IO;
using System.Reflection;
namespace RageCoop.Client.Scripting
{
internal class ResourceDomain:MarshalByRefObject
{
public AppDomain Domain;
public ResourceDomain()
{
}
public static void CleanUp()
{
foreach(var d in Util.GetAppDomains())
{
if (d.FriendlyName.StartsWith("RageCoop"))
{
AppDomain.Unload(d);
}
}
}
public static ResourceDomain Create()
{
// AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(Resolve);
AppDomainSetup ads = new AppDomainSetup
{
ApplicationBase = Directory.GetParent(typeof(ResourceDomain).Assembly.Location).FullName,
DisallowBindingRedirects = false,
DisallowCodeDownload = true,
ConfigurationFile =
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile,
ShadowCopyFiles = "true",
};
// Create the second AppDomain.
AppDomain ad = AppDomain.CreateDomain("RageCoop.ResourceDomain", null, ads);
ad.AssemblyResolve+=Resolve;
// ad.AssemblyResolve+=Resolve;
ResourceDomain domain=(ResourceDomain)ad.CreateInstanceAndUnwrap(
typeof(ResourceDomain).Assembly.FullName,
typeof(ResourceDomain).FullName
);
domain.Domain=ad;
Main.Logger.Debug("Hi:"+domain.Hi());
return domain;
}
private static Assembly Resolve(object sender, ResolveEventArgs args)
{
var assemblyName = new AssemblyName(args.Name);
var refed=typeof(ResourceDomain).Assembly.GetReferencedAssemblies();
if (args.Name==typeof(SHVDN.ScriptDomain).Assembly.FullName)
{
return typeof(SHVDN.ScriptDomain).Assembly;
}
else if (args.Name==typeof(GTA.Native.Function).Assembly.FullName)
{
return typeof(GTA.Native.Function).Assembly;
}
foreach (var a in refed)
{
if (a.Name.Equals(assemblyName))
{
return Assembly.Load(a);
}
}
if (assemblyName.Equals(typeof(ResourceDomain).Assembly.FullName))
{
return typeof(ResourceDomain).Assembly;
}
return null;
}
public static void Destroy(ResourceDomain d)
{
AppDomain.Unload(d.Domain);
}
public string Hi()
{
GTA.UI.Notification.Show("Hi");
return AppDomain.CurrentDomain.FriendlyName;
}
}
}

View File

@ -12,7 +12,6 @@ using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml.Serialization; using System.Xml.Serialization;
using System.Collections.Generic; using System.Collections.Generic;
using mscoree;
namespace RageCoop.Client namespace RageCoop.Client
{ {
@ -222,36 +221,6 @@ namespace RageCoop.Client
Function.Call(Hash.SET_RADIO_TO_STATION_INDEX, index); Function.Call(Hash.SET_RADIO_TO_STATION_INDEX, index);
} }
public static IList<AppDomain> GetAppDomains()
{
IList<AppDomain> _IList = new List<AppDomain>();
IntPtr enumHandle = IntPtr.Zero;
var host = new CorRuntimeHost();
try
{
host.EnumDomains(out enumHandle);
object domain = null;
while (true)
{
host.NextDomain(enumHandle, out domain);
if (domain == null) break;
AppDomain appDomain = (AppDomain)domain;
_IList.Add(appDomain);
}
return _IList;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return null;
}
finally
{
host.CloseEnum(enumHandle);
Marshal.ReleaseComObject(host);
}
}
#region WIN32 #region WIN32
const UInt32 WM_KEYDOWN = 0x0100; const UInt32 WM_KEYDOWN = 0x0100;