Hi,

I've create an application which injects some code in each method which it
finds in a give assembly.
everything works find, but a single method, behaves in a way that CLR throws
"invalid program exception"
as i investigated by comparing my generated code with what must be
generated, there were no difference but the max stack which has grown from 4
to 130!
this increase in maxStack is not normal, max stack of any other method as
increased by one!

any suggestions?

Here is attached original IL and the one with injected code:

*ORIGINAL CODE


*.method private hidebysig instance void  Init() cil managed
{
  // Code size       1049 (0x419)
  .maxstack  4
  .locals init (int32 V_0,
           int32 V_1,
           bool V_2)
  IL_0000:  nop
  IL_0001:  ldarg.0
  IL_0002:  call       class
[System]System.Collections.Specialized.NameValueCollection
[System.Configuration]System.Configuration.ConfigurationManager::get_AppSettings()
*////////////and many more lines of IL**

END OF ORIGINAL IL




OUTPUT OF MY APPLICATION

*.method private hidebysig instance void  Init() cil managed
{
  // Code size       1116 (0x45c)
*  .maxstack  130*
  *.locals init (int32 V_0,**
           int32 V_1,
           bool V_2)
  IL_0000:  nop
  IL_0001:  call       valuetype [mscorlib]System.DateTime
[mscorlib]System.DateTime::get_Now()
  IL_0006:  ldc.i4     0x7d8
  IL_000b:  ldc.i4     0xb
  IL_0010:  ldc.i4     0x12
  IL_0015:  newobj     instance void [mscorlib]System.DateTime::.ctor(int32,
                                                                      int32,
                                                                      int32)
  IL_001a:  call       bool
[mscorlib]System.DateTime::op_GreaterThan(valuetype
[mscorlib]System.DateTime,

valuetype [mscorlib]System.DateTime)
  IL_001f:  ldc.i4.0
  IL_0020:  ceq
  IL_0022:  brtrue.s   IL_0034
  IL_0024:  ldstr      "WW91ciBMaWNlbnNlIElzIEV4cGlyZWQ="
  IL_0029:  call       string
Negasht.Avl.App.MapControls.MapControl::d809d35285984881a241ab0519a9c147(string)
  IL_002e:  newobj     instance void
[mscorlib]System.Exception::.ctor(string)
  IL_0033:  throw*
*////////////////////CODE BELOW IS INTACT *
  IL_0034:  nop
  IL_0035:  ldarg.0
  IL_0036:  call       class
[System]System.Collections.Specialized.NameValueCollection
[System.Configuration]System.Configuration.ConfigurationManager::get_AppSettings()
*///////////////AND MANY MORE LINES....**

END OF OUTPUT OF MY APPLICATION

*

--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to