Am Sonntag, 16. März 2014 09:35:08 UTC+1 schrieb Jb Evain:
>
> * Make sure you have no peverify error before injecting your code, and 
> compare after. 
>

It's an application compiled by Visual Studio, so I assume it's error-free. 
PEVerify confirms this.
 

> * Cecil will update the branches target, but will currently not change 
> the kind of opcode, so you can overflow. You can workaround it easily 
> with the Simplify/Optimize Macros extension methods of 
> Mono.Cecil.Rocks. 
>

Yes, I've found that already and am using it.

I've meanwhile found a workaround to avoid the error. Instead of replacing 
the ldstr instruction, I could only add new instructions after it. First a 
pop to remove the string from the stack, then my real string-pushing 
function. A further enhancement was to change the ldstr to a nop, so I 
don't need the pop anymore and the original string also disappears from the 
code. I can change the ldstr any way I want, I just cannot remove or 
replace it. I could even replace the operand from the original to an empty 
string, that would work, too. Are there some references held on the ldstr 
instruction that won't be updated when it's removed or replaced?

I'll try to make a small testcase for this. Right now I'm working on the 
complete (non-public) application to find any problems my actions may cause.

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