Assuming *Instruction * is a *ILProcessor, *you need to pass the
instruction you want to jump to Create(OpCodes.Brtrue)  (instead of a
string)
something like this:

var target = Instruction.Create(OpCodes.Nop); // you can use any
instruction.. to simplify I am adding a *nop* as the target
// add other instructions
Instuction.Emit(OpCodes.Brtrue, target);

// some more instructions
Instruction.Append(target);

// More instructions


Best

Adriano



On Fri, Sep 7, 2018 at 1:33 PM Hi_ImKyle <[email protected]> wrote:

> Ok so I've been using Mono.Cecil for a bit now and all is good till i
> needed to create the brtrue instruction.
>
> So this is what i have setup so far.
>
> Instruction.Create(OpCodes.Ldsfld, ILUtils.GetField(Assembly.MainModule,
> "****.****", "****")),
> Instruction.Create(OpCodes.Call,
> Assembly.MainModule.ImportReference(typeof(MainTest).GetMethod("Chat_Hook"))),
> Instruction.Create(OpCodes.Brtrue, "")
>
> This is what I'm trying to recreate
>
> <https://i.imgur.com/mBJajY4.png>
>
>
>
>
>
>
>
>
>
>
>
>
> But whenever i try to create a brtrue instruction I always get an
> exception with the error message "opcode" which isnt useful at all.
>
> Is there a way to have that operand in IL_01AD in Instruction.Create?
>
> --
> --
> --
> mono-cecil
> ---
> You received this message because you are subscribed to the Google Groups
> "mono-cecil" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>


-- 
*Adriano Carlos Verona*
http://programing-fun.blogspot.com

M: +1 (514) 771-0190
500 Françóis Street, #310, H3E 1G4
Montreal, Canada
Contact Me [image: Linkedin] <http://www.linkedin.com/in/adrianoc>

-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to