aboutsummaryrefslogtreecommitdiff
path: root/ChocolArm64/Instruction
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-03-12 01:04:52 -0300
committergdkchan <gab.dark.100@gmail.com>2018-03-12 01:14:12 -0300
commit7a27990faa557c5c93f52e5cb082d551ad119ed0 (patch)
treea0800fded014a4a6afe738e5a65a17bc78cf0c19 /ChocolArm64/Instruction
parent3aaa4717b6f7400bac862e589a1f345e70e78d56 (diff)
Allow more than one process, free resources on process dispose, implement SvcExitThread
Diffstat (limited to 'ChocolArm64/Instruction')
-rw-r--r--ChocolArm64/Instruction/AInstEmitException.cs16
1 files changed, 16 insertions, 0 deletions
diff --git a/ChocolArm64/Instruction/AInstEmitException.cs b/ChocolArm64/Instruction/AInstEmitException.cs
index fe348edd..3964c949 100644
--- a/ChocolArm64/Instruction/AInstEmitException.cs
+++ b/ChocolArm64/Instruction/AInstEmitException.cs
@@ -34,6 +34,22 @@ namespace ChocolArm64.Instruction
Context.EmitCall(MthdInfo);
+ //Check if the thread should still be running, if it isn't then we return 0
+ //to force a return to the dispatcher and then exit the thread.
+ Context.EmitLdarg(ATranslatedSub.StateArgIdx);
+
+ Context.EmitCallPropGet(typeof(AThreadState), nameof(AThreadState.Running));
+
+ AILLabel LblEnd = new AILLabel();
+
+ Context.Emit(OpCodes.Brtrue_S, LblEnd);
+
+ Context.EmitLdc_I8(0);
+
+ Context.Emit(OpCodes.Ret);
+
+ Context.MarkLabel(LblEnd);
+
if (Context.CurrBlock.Next != null)
{
Context.EmitLoadState(Context.CurrBlock.Next);