@@ -569,7 +569,62 @@ int ISOSDacInterface.GetMethodDescName(ulong methodDesc, uint count, char* name,
569
569
int ISOSDacInterface . GetMethodDescPtrFromFrame ( ulong frameAddr , ulong * ppMD )
570
570
=> _legacyImpl is not null ? _legacyImpl . GetMethodDescPtrFromFrame ( frameAddr , ppMD ) : HResults . E_NOTIMPL ;
571
571
int ISOSDacInterface . GetMethodDescPtrFromIP ( ulong ip , ulong * ppMD )
572
- => _legacyImpl is not null ? _legacyImpl . GetMethodDescPtrFromIP ( ip , ppMD ) : HResults . E_NOTIMPL ;
572
+ {
573
+ if ( ip == 0 || ppMD == null )
574
+ return HResults . E_INVALIDARG ;
575
+
576
+ int hr = HResults . E_NOTIMPL ;
577
+
578
+ try
579
+ {
580
+ IExecutionManager executionManager = _target . Contracts . ExecutionManager ;
581
+ IRuntimeTypeSystem rts = _target . Contracts . RuntimeTypeSystem ;
582
+
583
+ CodeBlockHandle ? handle = executionManager . GetCodeBlockHandle ( new TargetCodePointer ( ip ) ) ;
584
+ if ( handle is CodeBlockHandle codeHandle )
585
+ {
586
+ TargetPointer methodDescAddr = executionManager . GetMethodDesc ( codeHandle ) ;
587
+
588
+ try
589
+ {
590
+ // Runs validation of MethodDesc
591
+ // if validation fails, should return E_INVALIDARG
592
+ rts . GetMethodDescHandle ( methodDescAddr ) ;
593
+
594
+ * ppMD = methodDescAddr . Value ;
595
+ hr = HResults . S_OK ;
596
+ }
597
+ catch ( System . Exception )
598
+ {
599
+ hr = HResults . E_INVALIDARG ;
600
+ }
601
+ }
602
+ else
603
+ {
604
+ hr = HResults . E_FAIL ;
605
+ }
606
+ }
607
+ catch ( System . Exception ex )
608
+ {
609
+ hr = ex . HResult ;
610
+ }
611
+
612
+ #if DEBUG
613
+ if ( _legacyImpl is not null )
614
+ {
615
+ ulong ppMDLocal ;
616
+ int hrLocal = _legacyImpl . GetMethodDescPtrFromIP ( ip , & ppMDLocal ) ;
617
+
618
+ Debug . Assert ( hrLocal == hr ) ;
619
+ if ( hr == HResults . S_OK )
620
+ {
621
+ Debug . Assert ( * ppMD == ppMDLocal ) ;
622
+ }
623
+ }
624
+ #endif
625
+ return hr ;
626
+ }
627
+
573
628
int ISOSDacInterface . GetMethodDescTransparencyData ( ulong methodDesc , void * data )
574
629
=> _legacyImpl is not null ? _legacyImpl . GetMethodDescTransparencyData ( methodDesc , data ) : HResults . E_NOTIMPL ;
575
630
int ISOSDacInterface . GetMethodTableData ( ulong mt , DacpMethodTableData * data )
0 commit comments