extonoxt Posted March 26 Posted March 26 (edited) Hello All, I am trying to add two methods in de4dot.blocks.cflow.InstructionEmulator. private void Emulate_Stelem_I4(Instruction instr) { Value value = this.valueStack.Pop(); bool flag = value.IsInt32(); if (flag) { Int32Value int32Value = (Int32Value)this.valueStack.Pop(); List<Value> list = this.valueStack.Pop(); list[int32Value.Value] = (Int32Value)value; } else { this.valueStack.Pop(); this.valueStack.Pop(); } private void Emulate_Ldelem_I4(Instruction instr) { Int32Value int32Value = (Int32Value)this.valueStack.Pop(); List<Value> list = this.valueStack.Pop(); Value value = list[int32Value.Value]; bool flag = value.IsInt32(); if (flag) { this.valueStack.Push(list[int32Value.Value]); } else { this.valueStack.Push(Int32Value.CreateUnknown()); } } Ref: https://github.com/mobile46/de4dot/blob/master/de4dot.blocks/cflow/InstructionEmulator.cs I am getting the following error Unhandled Exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) at System.Collections.Generic.List`1.get_Item(Int32 index) at de4dot.blocks.cflow.InstructionEmulator.Emulate_Ldelem_I4(Instruction instr) at de4dot.blocks.cflow.InstructionEmulator.Emulate(Instruction instr) What am I doing wrong? What is the correct way to do it? Thank you Edited March 27 by extonoxt
jackyjask Posted March 27 Posted March 27 the issue is that >ThrowArgumentOutOfRangeException is unhappy that for example you have a list with 3 elements [1,2,3] but for some reason you want to access a element with index 5 as you have just 3 elements in your list you are beating by this kind of exception Value value = list[int32Value.Value]; << here is hits the exception 2
extonoxt Posted March 27 Author Posted March 27 3 hours ago, jackyjask said: Value value = list[int32Value.Value]; << here is hits the exception Thank you jackyjask, I solved it by using GetValue of the same class 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now