Skip to content

Commit 9a68f10

Browse files
committed
Added unrestricted permissions to script appdomain
1 parent 7249e95 commit 9a68f10

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/ScriptDomain.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ namespace GTA
5050
{
5151
return Reflection::Assembly::GetAssembly(GTA::Script::typeid);
5252
}
53-
else
54-
{
55-
return nullptr;
56-
}
53+
54+
return nullptr;
5755
}
5856
void UnhandledExceptionHandler(Object ^sender, UnhandledExceptionEventArgs ^args)
5957
{
@@ -88,14 +86,18 @@ namespace GTA
8886
{
8987
path = IO::Path::GetFullPath(path);
9088

91-
System::AppDomain ^appdomain = System::AppDomain::CreateDomain("ScriptDomain_" + path->GetHashCode().ToString("X"));
89+
AppDomainSetup ^setup = gcnew AppDomainSetup();
90+
setup->ApplicationBase = path;
91+
Security::PermissionSet ^permissions = gcnew Security::PermissionSet(Security::Permissions::PermissionState::Unrestricted);
92+
93+
System::AppDomain ^appdomain = System::AppDomain::CreateDomain("ScriptDomain_" + path->GetHashCode().ToString("X"), nullptr, setup, permissions);
9294
appdomain->InitializeLifetimeService();
9395

9496
ScriptDomain ^scriptdomain = nullptr;
9597

9698
try
9799
{
98-
scriptdomain = static_cast<ScriptDomain ^>(appdomain->CreateInstanceFromAndUnwrap(Reflection::Assembly::GetAssembly(ScriptDomain::typeid)->Location, ScriptDomain::typeid->FullName));
100+
scriptdomain = static_cast<ScriptDomain ^>(appdomain->CreateInstanceFromAndUnwrap(ScriptDomain::typeid->Assembly->Location, ScriptDomain::typeid->FullName));
99101
}
100102
catch (Exception ^ex)
101103
{
@@ -161,7 +163,7 @@ namespace GTA
161163
compilerOptions->ReferencedAssemblies->Add("System.dll");
162164
compilerOptions->ReferencedAssemblies->Add("System.Drawing.dll");
163165
compilerOptions->ReferencedAssemblies->Add("System.Windows.Forms.dll");
164-
compilerOptions->ReferencedAssemblies->Add(Reflection::Assembly::GetAssembly(GTA::Script::typeid)->Location);
166+
compilerOptions->ReferencedAssemblies->Add(GTA::Script::typeid->Assembly->Location);
165167

166168
CodeDom::Compiler::CompilerResults ^compilerResult = compiler->CompileAssemblyFromFile(compilerOptions, filename);
167169

0 commit comments

Comments
 (0)