11using System ;
2- using System . Collections . Generic ;
32using System . Diagnostics . Contracts ;
43using System . Linq ;
54using ReClassNET . Memory ;
87
98namespace ReClassNET . Nodes
109{
11- public class FunctionNode : BaseNode
10+ public class FunctionNode : BaseFunctionNode
1211 {
13- private IntPtr address = IntPtr . Zero ;
14- private readonly List < string > instructions = new List < string > ( ) ;
15-
1612 public string Signature { get ; set ; } = "void function()" ;
1713
1814 public ClassNode BelongsToClass { get ; set ; }
@@ -25,7 +21,7 @@ public override string GetToolTipText(HotSpot spot, MemoryBuffer memory)
2521 {
2622 DisassembleRemoteCode ( memory , spot . Address ) ;
2723
28- return string . Join ( "\n " , instructions ) ;
24+ return string . Join ( "\n " , instructions . Select ( i => i . Instruction ) ) ;
2925 }
3026
3127 public override int Draw ( ViewInfo view , int x , int y )
@@ -71,13 +67,7 @@ public override int Draw(ViewInfo view, int x, int y)
7167 x = AddText ( view , x , y , view . Settings . ValueColor , HotSpot . NoneId , BelongsToClass == null ? "<None>" : $ "<{ BelongsToClass . Name } >") ;
7268 x = AddIcon ( view , x , y , Icons . Change , 1 , HotSpotType . ChangeType ) ;
7369
74- y += view . Font . Height ;
75- foreach ( var line in instructions )
76- {
77- y += view . Font . Height ;
78-
79- AddText ( view , tx , y , view . Settings . NameColor , HotSpot . ReadOnlyId , line ) ;
80- }
70+ y = DrawInstructions ( view , tx , y + 4 ) + 4 ;
8171 }
8272
8373 return y + view . Font . Height ;
@@ -120,18 +110,10 @@ private void DisassembleRemoteCode(MemoryBuffer memory, IntPtr address)
120110
121111 if ( ! address . IsNull ( ) && memory . Process . IsValid )
122112 {
123- memorySize = 0 ;
124-
125- var disassembler = new Disassembler ( memory . Process . CoreFunctions ) ;
126- foreach ( var instruction in disassembler . RemoteDisassembleFunction ( memory . Process , address , 8192 ) )
127- {
128- memorySize += instruction . Length ;
129-
130- instructions . Add ( $ "{ instruction . Address . ToString ( Constants . StringHexFormat ) } { instruction . Instruction } ") ;
131- }
132-
133- ParentNode ? . ChildHasChanged ( this ) ;
113+ DisassembleRemoteCode ( memory , address , out memorySize ) ;
134114 }
115+
116+ ParentNode ? . ChildHasChanged ( this ) ;
135117 }
136118 }
137119 }
0 commit comments