@@ -9,68 +9,68 @@ namespace ReClassNET.AddressParser
99{
1010 public class DynamicCompiler : IExecuter
1111 {
12- public IntPtr Execute ( IExpression operation , RemoteProcess process )
12+ public IntPtr Execute ( IExpression operation , IProcessReader processReader )
1313 {
1414 Contract . Requires ( operation != null ) ;
15- Contract . Requires ( process != null ) ;
15+ Contract . Requires ( processReader != null ) ;
1616
17- return CompileAddressFormula ( operation ) ( process ) ;
17+ return CompileAddressFormula ( operation ) ( processReader ) ;
1818 }
1919
20- public static Func < RemoteProcess , IntPtr > CompileAddressFormula ( IExpression expression )
20+ public static Func < IProcessReader , IntPtr > CompileAddressFormula ( IExpression expression )
2121 {
2222 Contract . Requires ( expression != null ) ;
2323
24- var processParameter = Expression . Parameter ( typeof ( RemoteProcess ) ) ;
24+ var processParameter = Expression . Parameter ( typeof ( IProcessReader ) ) ;
2525
26- return Expression . Lambda < Func < RemoteProcess , IntPtr > > (
26+ return Expression . Lambda < Func < IProcessReader , IntPtr > > (
2727 GenerateMethodBody ( expression , processParameter ) ,
2828 processParameter
2929 ) . Compile ( ) ;
3030 }
3131
32- private static Expression GenerateMethodBody ( IExpression operation , ParameterExpression processParameter )
32+ private static Expression GenerateMethodBody ( IExpression operation , Expression parameter )
3333 {
3434 Contract . Requires ( operation != null ) ;
35- Contract . Requires ( processParameter != null ) ;
35+ Contract . Requires ( parameter != null ) ;
3636
3737 switch ( operation )
3838 {
3939 case AddExpression addExpression :
4040 {
41- var argument1 = GenerateMethodBody ( addExpression . Lhs , processParameter ) ;
42- var argument2 = GenerateMethodBody ( addExpression . Rhs , processParameter ) ;
41+ var argument1 = GenerateMethodBody ( addExpression . Lhs , parameter ) ;
42+ var argument2 = GenerateMethodBody ( addExpression . Rhs , parameter ) ;
4343
4444 return Expression . Call ( null , GetIntPtrExtension ( nameof ( IntPtrExtension . Add ) ) , argument1 , argument2 ) ;
4545 }
4646 case SubtractExpression subtractExpression :
4747 {
48- var argument1 = GenerateMethodBody ( subtractExpression . Lhs , processParameter ) ;
49- var argument2 = GenerateMethodBody ( subtractExpression . Rhs , processParameter ) ;
48+ var argument1 = GenerateMethodBody ( subtractExpression . Lhs , parameter ) ;
49+ var argument2 = GenerateMethodBody ( subtractExpression . Rhs , parameter ) ;
5050
5151 return Expression . Call ( null , GetIntPtrExtension ( nameof ( IntPtrExtension . Sub ) ) , argument1 , argument2 ) ;
5252 }
5353 case MultiplyExpression multiplyExpression :
5454 {
55- var argument1 = GenerateMethodBody ( multiplyExpression . Lhs , processParameter ) ;
56- var argument2 = GenerateMethodBody ( multiplyExpression . Rhs , processParameter ) ;
55+ var argument1 = GenerateMethodBody ( multiplyExpression . Lhs , parameter ) ;
56+ var argument2 = GenerateMethodBody ( multiplyExpression . Rhs , parameter ) ;
5757
5858 return Expression . Call ( null , GetIntPtrExtension ( nameof ( IntPtrExtension . Mul ) ) , argument1 , argument2 ) ;
5959 }
6060 case DivideExpression divideExpression :
6161 {
62- var argument1 = GenerateMethodBody ( divideExpression . Lhs , processParameter ) ;
63- var argument2 = GenerateMethodBody ( divideExpression . Rhs , processParameter ) ;
62+ var argument1 = GenerateMethodBody ( divideExpression . Lhs , parameter ) ;
63+ var argument2 = GenerateMethodBody ( divideExpression . Rhs , parameter ) ;
6464
6565 return Expression . Call ( null , GetIntPtrExtension ( nameof ( IntPtrExtension . Div ) ) , argument1 , argument2 ) ;
6666 }
6767 case ModuleExpression moduleExpression :
6868 {
69- var getModuleByNameFunc = typeof ( RemoteProcess ) . GetRuntimeMethod ( nameof ( RemoteProcess . GetModuleByName ) , new [ ] { typeof ( string ) } ) ;
69+ var getModuleByNameFunc = typeof ( IProcessReader ) . GetRuntimeMethod ( nameof ( IProcessReader . GetModuleByName ) , new [ ] { typeof ( string ) } ) ;
7070 var moduleNameConstant = Expression . Constant ( moduleExpression . Name ) ;
7171
7272 var moduleVariable = Expression . Variable ( typeof ( Memory . Module ) ) ;
73- var assignExpression = Expression . Assign ( moduleVariable , Expression . Call ( processParameter , getModuleByNameFunc , moduleNameConstant ) ) ;
73+ var assignExpression = Expression . Assign ( moduleVariable , Expression . Call ( parameter , getModuleByNameFunc , moduleNameConstant ) ) ;
7474
7575 return Expression . Block (
7676 new [ ] { moduleVariable } ,
@@ -90,12 +90,12 @@ private static Expression GenerateMethodBody(IExpression operation, ParameterExp
9090 }
9191 case ReadMemoryExpression readMemoryExpression :
9292 {
93- var argument = GenerateMethodBody ( readMemoryExpression . Expression , processParameter ) ;
93+ var argument = GenerateMethodBody ( readMemoryExpression . Expression , parameter ) ;
9494
95- var functionName = readMemoryExpression . ByteCount == 4 ? nameof ( RemoteProcess . ReadRemoteInt32 ) : nameof ( RemoteProcess . ReadRemoteInt64 ) ;
96- var readRemoteIntFn = typeof ( RemoteProcess ) . GetRuntimeMethod ( functionName , new [ ] { typeof ( IntPtr ) } ) ;
95+ var functionName = readMemoryExpression . ByteCount == 4 ? nameof ( IProcessReader . ReadRemoteInt32 ) : nameof ( IProcessReader . ReadRemoteInt64 ) ;
96+ var readRemoteIntFn = typeof ( IProcessReader ) . GetRuntimeMethod ( functionName , new [ ] { typeof ( IntPtr ) } ) ;
9797
98- var callExpression = Expression . Call ( processParameter , readRemoteIntFn , argument ) ;
98+ var callExpression = Expression . Call ( parameter , readRemoteIntFn , argument ) ;
9999
100100 var paramType = readMemoryExpression . ByteCount == 4 ? typeof ( int ) : typeof ( long ) ;
101101 var convertFn = typeof ( IntPtrExtension ) . GetRuntimeMethod ( nameof ( IntPtrExtension . From ) , new [ ] { paramType } ) ;
0 commit comments