-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanRam.cpp
More file actions
107 lines (107 loc) · 2.24 KB
/
cleanRam.cpp
File metadata and controls
107 lines (107 loc) · 2.24 KB
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
#include "G.h"
RAM G::mGetRam( void )
{
RAM ram;
xStr text;
ram.name = ramName_TXT->GetValue();
ram.ptrDepth = ramPtr_SN->GetValue();
ram.byte = GetHex( ramByte_TXT->GetValue() );
ram.size = GetHex( ramSize_TXT->GetValue() );
return ram;
}
u64 G::mGetRamByte( s8 index )
{
u64 byte = 0u;
BIN bin = gGetBin();
if ( index >= 0 && index < bin.GetCount() )
{
RAM ram = bin[ index ];
byte = ram.byte;
u64 nextByte = 0u;
u8 ptrDepth = ram.ptrDepth;
if ( hookApp )
{
for ( u8 i = 0u; i < ptrDepth; ++i )
{
GetRamX( appHandle, byte, &nextByte, 4u );
if ( nextByte < byte )
{
GetRamX( appHandle, byte, &nextByte, 8u );
}
byte = nextByte;
}
}
else
{
for ( u8 i = 0u; i < ptrDepth; ++i )
{
bin_BF.Seek( byte, wxFromStart );
bin_BF.Read( &nextByte, 4u );
if ( nextByte < byte )
{
bin_BF.Read( &nextByte, 8u );
}
byte = nextByte;
}
bin_BF.Seek( 0u );
}
}
return byte;
}
u64 G::mGetRamSize( s8 index )
{
u64 size = 0u;
u64 binSize = 0u;
if ( hookApp )
{
GetAppSize( appHandle, binSize );
}
else
{
binSize = bin_BF.Length();
}
if ( index >= 0 )
{
RAM ram = gGetBin()[ index ];
size = ram.size;
}
size = ( size == 0u || size > binSize ) ? binSize : size;
return size;
}
void G::mShowRam( void )
{
xStr text;
BIN bin = gGetBin();
s8 index = ramName_D->GetSelection();
RAM ram = bin[ index ];
ramName_TXT->ChangeValue( ram.name );
ramPtr_SN->SetValue( ram.ptrDepth );
text.Printf( hexVLL, ram.byte );
ramByte_TXT->ChangeValue( text );
text.Printf( hexVLL, ram.size );
ramSize_TXT->ChangeValue( text );
}
void G::NewRam_BOnClick( wxCommandEvent& event )
{
BIN bin = gGetBin();
RAM ram = mGetRam();
s8 index = bin.Append( ram );
gSetBin( bin );
mShowBin();
ramName_D->Select( index );
mShowRam();
}
void G::SetRam_BOnClick( wxCommandEvent& event )
{
BIN bin = gGetBin();
RAM ram = mGetRam();
s8 index = ramName_D->GetSelection();
bin[ index ] = ram;
ramName_D->SetString( index, ram.name );
ramName_D->Select( index );
gSetBin( bin );
}
void G::ramName_DOnChoice( wxCommandEvent& event )
{
mShowRam();
}