破解typemock 流水账


下载了typemock。却要我license。老子才不尿你。打开reflector开始破解。

 

大概看了源码,主要是

 

MockManager.Init() 里面调用了注册类。 bi.e()

 

比较另类的验证机制。

 

其他的TypeMock.Integration / Interceptors 似乎没有什么意义。

 

找到IL里面的:

 

.class public auto ansi sealed TypeMock.MockManager

       extends [mscorlib]System.Object

 

   .method public hidebysig static void  Init(bool collectAllCalls) cil managed

 

具体内容:

 

代码
     //  代码大小       149 (0x95)
    .maxstack   2
    .locals init (valuetype gk V_0)
    IL_0000:  call       valuetype gk gk::b()
    IL_0005:  stloc.
0
    .
try
    {
      IL_0006:  call       
void  bi::e()
      IL_000b:  ldsfld     
string  TypeMock.MockManager::i
      IL_0010:  ldsfld     
string  TypeMock.MockManager::h
      IL_0015:  call       int32 TypeMock.MockManager::SetEnvironmentVariable(
string ,
                                                                              
string )
      IL_001a:  pop
      IL_001b:  ldsfld     
bool  TypeMock.MockManager::z
      IL_0020:  brtrue.s   IL_0035

      IL_0022:  call       
bool  TypeMock.AutoFake.TyphoonConfiguration::IsInAutoFake()
      IL_0027:  brtrue.s   IL_0035

      IL_0029:  ldc.i4.
1
      IL_002a:  stsfld     
bool  TypeMock.MockManager::z
      IL_002f:  call       valuetype hs g6::f()
      IL_0034:  pop
      IL_0035:  call       
class  ay TypeMock.MockManager::k()
      IL_003a:  callvirt   instance 
void  ay::a()
      IL_003f:  ldsfld     
class  dp TypeMock.MockManager::v
      IL_0044:  callvirt   instance 
void  dp::a()
      IL_0049:  ldsfld     
class  hf TypeMock.MockManager::w
      IL_004e:  callvirt   instance 
void  hf::a()
      IL_0053:  call       
void  TypeMock.RecorderManager::k()
      IL_0058:  ldarg.
0
      IL_0059:  call       
void  TypeMock.MockManager::set_CollectAllCalls( bool )
      IL_005e:  ldc.i4.
1
      IL_005f:  stsfld     
bool  TypeMock.MockManager::m
      IL_0064:  ldc.i4.
0
      IL_0065:  stsfld     int32 TypeMock.MockManager::y
      IL_006a:  ldc.i4.
0
      IL_006b:  stsfld     
bool  TypeMock.MockManager::o
      IL_0070:  call       
void  TypeMock.ExpectationBlock::a()
      IL_0075:  call       
void  TypeMock.MockManager::i()
      IL_007a:  call       
void  TypeMock.MockManager::j()
      IL_007f:  call       
void  f9::b()
      IL_0084:  leave.s    IL_0094

    }  
//  end .try
     finally
    {
      IL_0086:  ldloca.s   V_0
      IL_0088:  constrained. gk
      IL_008e:  callvirt   instance 
void  [mscorlib]System.IDisposable::Dispose()
      IL_0093:  endfinally
    }  
//  end handler
    IL_0094:  ret
  } 
//  end of method MockManager::Init

 

 

关键地方是:

       IL_0006:  call       void bi::e()

跨越了5个IL,那么添加nop就可以了。

 

 

 

你可能感兴趣的:(type)