@@ -179,9 +179,11 @@ private void ProcessMethod(
179179 case Code . Ldarg_3 :
180180 case Code . Ldarg_S :
181181 case Code . Ldarg :
182+ HandleLoadArgument ( instruction , false ) ;
183+ break ;
182184 case Code . Ldarga_S :
183185 case Code . Ldarga :
184- HandleLoadArgument ( instruction ) ;
186+ HandleLoadArgument ( instruction , true ) ;
185187 break ;
186188
187189 case Code . Stloc_0 :
@@ -199,14 +201,18 @@ private void ProcessMethod(
199201 case Code . Ldloc_3 :
200202 case Code . Ldloc_S :
201203 case Code . Ldloc :
204+ HandleLoadLocal ( instruction , false ) ;
205+ break ;
202206 case Code . Ldloca_S :
203207 case Code . Ldloca :
204- HandleLoadLocal ( instruction ) ;
208+ HandleLoadLocal ( instruction , true ) ;
205209 break ;
206210
207211 case Code . Ldfld :
212+ HandleLoadField ( instruction , false ) ;
213+ break ;
208214 case Code . Ldflda :
209- HandleLoadField ( instruction ) ;
215+ HandleLoadField ( instruction , true ) ;
210216 break ;
211217
212218 case Code . Stfld :
@@ -255,9 +261,9 @@ void HandleReturnInstruction(Instruction instruction) {
255261 }
256262 }
257263
258- void HandleLoadArgument ( Instruction instruction ) {
264+ void HandleLoadArgument ( Instruction instruction , bool isAddress ) {
259265 var parameter = MonoModCommon . IL . GetReferencedParameter ( method , instruction ) ;
260- if ( parameter . ParameterType . IsTruelyValueType ( ) ) return ;
266+ if ( parameter . ParameterType . IsTruelyValueType ( ) && ! isAddress ) return ;
261267
262268 ParameterTracingChain chain = new ParameterTracingChain ( parameter , [ ] , [ ] ) ;
263269 var stackKey = ParameterUsageTrack . GenerateStackKey ( method , instruction ) ;
@@ -285,9 +291,9 @@ void HandleStoreLocal(Instruction instruction) {
285291 }
286292 }
287293
288- void HandleLoadLocal ( Instruction instruction ) {
294+ void HandleLoadLocal ( Instruction instruction , bool isAddress ) {
289295 var variable = MonoModCommon . IL . GetReferencedVariable ( method , instruction ) ;
290- if ( variable . VariableType . IsTruelyValueType ( ) ) return ;
296+ if ( variable . VariableType . IsTruelyValueType ( ) && ! isAddress ) return ;
291297
292298 if ( localTrace . TryGetTrace ( variable , out var trace ) ) {
293299 var stackKey = ParameterUsageTrack . GenerateStackKey ( method , instruction ) ;
@@ -297,9 +303,9 @@ void HandleLoadLocal(Instruction instruction) {
297303 }
298304 }
299305
300- void HandleLoadField ( Instruction instruction ) {
306+ void HandleLoadField ( Instruction instruction , bool isAddress ) {
301307 FieldReference fieldRef = ( FieldReference ) instruction . Operand ;
302- if ( fieldRef . FieldType . IsTruelyValueType ( ) ) return ;
308+ if ( fieldRef . FieldType . IsTruelyValueType ( ) && ! isAddress ) return ;
303309
304310 foreach ( var path in MonoModCommon . Stack . AnalyzeInstructionArgsSources ( method , instruction , jumpSites ) ) {
305311 foreach ( var instanceLoad in MonoModCommon . Stack . AnalyzeStackTopTypeAllPaths ( method , path . ParametersSources [ 0 ] . Instructions . Last ( ) , jumpSites ) ) {
0 commit comments