22using System . Collections . Generic ;
33using System . Diagnostics . Contracts ;
44using System . Linq ;
5- using System . Text ;
6- using System . Threading . Tasks ;
75using ReClassNET . Memory ;
86using ReClassNET . UI ;
97using ReClassNET . Util ;
@@ -12,19 +10,22 @@ namespace ReClassNET.Nodes
1210{
1311 public class FunctionNode : BaseNode
1412 {
15- private int memorySize = IntPtr . Size ;
16-
1713 private IntPtr address = IntPtr . Zero ;
18- private readonly List < string > disassembledCode = new List < string > ( ) ;
14+ private readonly List < string > instructions = new List < string > ( ) ;
15+
16+ private string signature = "void function()" ;
1917
18+ public ClassNode BelongsToClass { get ; set ; }
19+
20+ private int memorySize = IntPtr . Size ;
2021 /// <summary>Size of the node in bytes.</summary>
2122 public override int MemorySize => memorySize ;
2223
2324 public override string GetToolTipText ( HotSpot spot , MemoryBuffer memory )
2425 {
2526 DisassembleRemoteCode ( memory , spot . Address ) ;
2627
27- return string . Join ( "\n " , disassembledCode ) ;
28+ return string . Join ( "\n " , instructions ) ;
2829 }
2930
3031 public override int Draw ( ViewInfo view , int x , int y )
@@ -43,10 +44,11 @@ public override int Draw(ViewInfo view, int x, int y)
4344 x += TextPadding ;
4445
4546 x = AddIcon ( view , x , y , Icons . Function , - 1 , HotSpotType . None ) ;
46- x = AddAddressOffset ( view , x , y ) ;
4747
4848 var tx = x ;
4949
50+ x = AddAddressOffset ( view , x , y ) ;
51+
5052 x = AddText ( view , x , y , Program . Settings . TypeColor , HotSpot . NoneId , "Function" ) + view . Font . Width ;
5153 x = AddText ( view , x , y , Program . Settings . NameColor , HotSpot . NameId , Name ) + view . Font . Width ;
5254
@@ -60,7 +62,16 @@ public override int Draw(ViewInfo view, int x, int y)
6062
6163 if ( levelsOpen [ view . Level ] )
6264 {
63- foreach ( var line in disassembledCode )
65+ y += view . Font . Height ;
66+ x = AddText ( view , tx , y , Program . Settings . TypeColor , HotSpot . NoneId , "Signature:" ) + view . Font . Width ;
67+ x = AddText ( view , x , y , Program . Settings . ValueColor , 0 , signature ) ;
68+
69+ y += view . Font . Height ;
70+ x = AddText ( view , tx , y , Program . Settings . TextColor , HotSpot . NoneId , "Belongs to: " ) ;
71+ x = AddText ( view , x , y , Program . Settings . ValueColor , HotSpot . NoneId , BelongsToClass == null ? "<None>" : $ "<{ BelongsToClass . Name } >") ;
72+ x = AddIcon ( view , x , y , Icons . Change , 1 , HotSpotType . ChangeType ) ;
73+
74+ foreach ( var line in instructions )
6475 {
6576 y += view . Font . Height ;
6677
@@ -81,18 +92,32 @@ public override int CalculateHeight(ViewInfo view)
8192 var h = view . Font . Height ;
8293 if ( levelsOpen [ view . Level ] )
8394 {
84- h += disassembledCode . Count ( ) * view . Font . Height ;
95+ h += instructions . Count ( ) * view . Font . Height ;
8596 }
8697 return h ;
8798 }
8899
100+ public override void Update ( HotSpot spot )
101+ {
102+ base . Update ( spot ) ;
103+
104+ if ( spot . Id == 0 ) // Signature
105+ {
106+ signature = spot . Text ;
107+ }
108+ else if ( spot . Id == 1 )
109+ {
110+
111+ }
112+ }
113+
89114 private void DisassembleRemoteCode ( MemoryBuffer memory , IntPtr address )
90115 {
91116 Contract . Requires ( memory != null ) ;
92117
93118 if ( this . address != address )
94119 {
95- disassembledCode . Clear ( ) ;
120+ instructions . Clear ( ) ;
96121
97122 this . address = address ;
98123
@@ -108,9 +133,9 @@ private void DisassembleRemoteCode(MemoryBuffer memory, IntPtr address)
108133 {
109134 memorySize += l ;
110135#if WIN64
111- disassembledCode . Add ( $ "{ a . ToString ( "X08" ) } { i } ") ;
136+ instructions . Add ( $ "{ a . ToString ( "X08" ) } { i } ") ;
112137#else
113- disassembledCode . Add ( $ "{ a . ToString ( "X04" ) } { i } ") ;
138+ instructions . Add ( $ "{ a . ToString ( "X04" ) } { i } ") ;
114139#endif
115140 }
116141 ) ;
0 commit comments