-
Notifications
You must be signed in to change notification settings - Fork 179
/
Copy pathCNodeClass.cpp
121 lines (100 loc) · 3.57 KB
/
CNodeClass.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "stdafx.h"
#include "CNodeClass.h"
#include "CClassFrame.h"
CNodeClass::CNodeClass( )
{
TCHAR szOffset[128];
m_nodeType = nt_class;
m_Offset = GetBaseAddress( );
#if defined(_M_AMD64)
_ui64tot_s( m_Offset, szOffset, 128, 16 );
#else
_ultot_s( m_Offset, szOffset, 128, 16 );
#endif
m_strOffset.SetString( szOffset );
m_RequestPosition = -1;
m_Idx = 0;
m_pChildClassFrame = NULL;
}
void CNodeClass::Update( const PHOTSPOT Spot )
{
StandardUpdate( Spot );
if (Spot->Id == 0)
{
m_strOffset.SetString( Spot->Text.GetString( ) );
m_Offset = ConvertStrToAddress( m_strOffset );
}
else if (Spot->Id == 1)
{
m_RequestPosition = _tcstol( Spot->Text.GetString( ), NULL, 10 ); // m_RequestPosition = ConvertStrToAddress( Spot->Text );
}
}
ULONG CNodeClass::GetMemorySize( )
{
int size = 0;
for (UINT i = 0; i < m_ChildNodes.size( ); i++)
size += m_ChildNodes[i]->GetMemorySize( );
return size;
}
NODESIZE CNodeClass::Draw( const PVIEWINFO View, int x, int y )
{
NODESIZE DrawSize;
NODESIZE ChildDrawSize;
int tx;
DrawSize.x = 0;
DrawSize.y = 0;
AddSelection( View, x, y, g_FontHeight );
x = AddOpenClose( View, x, y );
// Save tx here
tx = x;
x = AddIcon( View, x, y, ICON_CLASS, -1, -1 );
x = AddText( View, x, y, g_clrOffset, 0, _T( "%s" ), m_strOffset ) + g_FontWidth;
// x += ( NumDigits( m_Offset ) ) * FontWidth;
// TODO, figure this out better
// x += ( ( NumDigits( m_Offset ) - 7 ) * FontWidth ) / 2;
// printf( "Print %s at %d\n", m_strOffset, x );
x = AddText( View, x, y, g_clrIndex, HS_NONE, _T( "(" ) );
x = AddText( View, x, y, g_clrIndex, HS_OPENCLOSE, _T( "%i" ), m_Idx );
x = AddText( View, x, y, g_clrIndex, HS_NONE, _T( ")" ) );
x = AddText( View, x, y, g_clrType, HS_NONE, _T( "Class " ) );
x = AddText( View, x, y, g_clrName, HS_NAME, m_strName ) + g_FontWidth;
x = AddText( View, x, y, g_clrValue, HS_NONE, _T( "[%i]" ), GetMemorySize( ) ) + g_FontWidth;
x = AddComment( View, x, y );
DrawSize.x = x;
y += g_FontHeight;
if (m_LevelsOpen[View->Level])
{
VIEWINFO ViewInfo;
memcpy( &ViewInfo, View, sizeof( ViewInfo ) );
ViewInfo.Level++;
for (UINT i = 0; i < m_ChildNodes.size( ); i++)
{
CNodeBase* pNode = m_ChildNodes[i];
if (!pNode)
{
PrintOutDbg( _T( "Node %d is NULL in class %s!" ), i, m_strName.GetString( ) );
continue;
}
if (pNode->GetType( ) == nt_vtable)
{
CNodeVTable* VTableNode = static_cast<CNodeVTable*>(pNode);
if (!VTableNode->IsInitialized( ) && m_pChildClassFrame != NULL)
VTableNode->Initialize( static_cast<CWnd*>(m_pChildClassFrame->GetChildView( )) );
}
if (pNode->GetType( ) == nt_function)
{
CNodeFunction* FunctionNode = static_cast<CNodeFunction*>(pNode);
if (!FunctionNode->IsInitialized( ) && m_pChildClassFrame != NULL)
FunctionNode->Initialize( m_pChildClassFrame->GetChildView( ), m_Offset + FunctionNode->GetOffset( ) );
}
ChildDrawSize = pNode->Draw( &ViewInfo, tx, y );
y = ChildDrawSize.y;
if (ChildDrawSize.x > DrawSize.x)
{
DrawSize.x = ChildDrawSize.x;
}
}
}
DrawSize.y = y;
return DrawSize;
}