Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

de4dot.blocks.cflow.InstructionEmulator

Featured Replies

Posted

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 by extonoxt

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

  • Author
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

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.