@@ -102,9 +102,15 @@ private static Expression GenerateMethodBody(IExpression expression, Expression
102102 {
103103 var addressParameter = GenerateMethodBody ( readMemoryExpression . Expression , processParameter ) ;
104104
105- var readRemoteIntPtrFn = typeof ( IRemoteMemoryReaderExtension ) . GetRuntimeMethod ( nameof ( IRemoteMemoryReaderExtension . ReadRemoteIntPtr ) , new [ ] { typeof ( IRemoteMemoryReader ) , typeof ( IntPtr ) } ) ;
105+ var functionName = readMemoryExpression . ByteCount == 4 ? nameof ( IRemoteMemoryReaderExtension . ReadRemoteInt32 ) : nameof ( IRemoteMemoryReaderExtension . ReadRemoteInt64 ) ;
106+ var readRemoteIntPtrFn = typeof ( IRemoteMemoryReaderExtension ) . GetRuntimeMethod ( functionName , new [ ] { typeof ( IRemoteMemoryReader ) , typeof ( IntPtr ) } ) ;
106107
107- return Expression . Call ( null , readRemoteIntPtrFn , processParameter , addressParameter ) ;
108+ var callExpression = Expression . Call ( null , readRemoteIntPtrFn , processParameter , addressParameter ) ;
109+ 110+ var paramType = readMemoryExpression . ByteCount == 4 ? typeof ( int ) : typeof ( long ) ;
111+ var convertFn = typeof ( IntPtrExtension ) . GetRuntimeMethod ( nameof ( IntPtrExtension . From ) , new [ ] { paramType } ) ;
112+ 113+ return Expression . Call ( null , convertFn , callExpression ) ;
108114 }
109115 }
110116
0 commit comments