-
Notifications
You must be signed in to change notification settings - Fork 225
/
CXrefs.cpp
167 lines (155 loc) · 5.31 KB
/
CXrefs.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
void __fastcall TFMain_11011981::ShowCodeXrefs(DWORD Adr, int selIdx)
{
lbCXrefs->Clear();
PInfoRec recN = GetInfoRec(Adr);
if (recN && recN->xrefs)
{
int wid, maxwid = 0;
TCanvas *canvas = lbCXrefs->Canvas;
DWORD pAdr = 0;
char f = 2;
lbCXrefs->Items->BeginUpdate();
for (int m = 0; m < recN->xrefs->Count; m++)
{
PXrefRec recX = (PXrefRec)recN->xrefs->Items[m];
String line = " " + Val2Str8(recX->adr + recX->offset) + " " + recX->type;
wid = canvas->TextWidth(line); if (wid > maxwid) maxwid = wid;
PUnitRec recU = GetUnit(recX->adr);
if (recU && recU->kb) line[1] ^= 1;
if (pAdr != recX->adr) f ^= 2; line[1] ^= f;
pAdr = recX->adr;
lbCXrefs->Items->Add(line);
}
lbCXrefs->ScrollWidth = maxwid + 2;
lbCXrefs->ItemIndex = selIdx;
lbCXrefs->ItemHeight = lbCXrefs->Canvas->TextHeight("T");
lbCXrefs->Items->EndUpdate();
}
}
//---------------------------------------------------------------------------
void __fastcall TFMain_11011981::lbXrefsMouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
TListBox *lb = (TListBox*)Sender;
if (lb->CanFocus()) ActiveControl = lb;
}
//---------------------------------------------------------------------------
void __fastcall TFMain_11011981::lbXrefsDblClick(TObject *Sender)
{
char type[2];
DWORD adr;
PROCHISTORYREC rec;
TListBox *lb = (TListBox*)Sender;
if (lb->ItemIndex < 0) return;
String item = lb->Items->Strings[lb->ItemIndex];
sscanf(item.c_str() + 1, "%lX%2c", &adr, type);
if (type[1] == 'D')
{
PInfoRec recN = GetInfoRec(adr);
if (recN && recN->kind == ikVMT)
{
ShowClassViewer(adr);
WhereSearch = SEARCH_CLASSVIEWER;
if (!rgViewerMode->ItemIndex)
{
TreeSearchFrom = tvClassesFull->Items->Item[0];
}
else
{
BranchSearchFrom = tvClassesShort->Items->Item[0];
}
//Ñíà÷àëà èùåì êëàññ
String text = "#" + Val2Str8(adr);
FindText(text);
//Ïîòîì - òåêóùóþ ïðîöåäóðó
if (!rgViewerMode->ItemIndex)
{
if (tvClassesFull->Selected)
TreeSearchFrom = tvClassesFull->Selected;
else
TreeSearchFrom = tvClassesFull->Items->Item[0];
}
else
{
if (tvClassesShort->Selected)
BranchSearchFrom = tvClassesShort->Selected;
else
BranchSearchFrom = tvClassesShort->Items->Item[0];
}
text = "#" + Val2Str8(CurProcAdr);
FindText(text);
return;
}
}
for (int m = Adr2Pos(adr); m >= 0; m--)
{
if (IsFlagSet(cfProcStart, m))
{
rec.adr = CurProcAdr;
rec.itemIdx = lbCode->ItemIndex;
rec.xrefIdx = lbCXrefs->ItemIndex;
rec.topIdx = lbCode->TopIndex;
ShowCode(Pos2Adr(m), adr, -1, -1);
CodeHistoryPush(&rec);
break;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TFMain_11011981::lbXrefsKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if (Key == VK_RETURN) lbXrefsDblClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TFMain_11011981::lbXrefsDrawItem(TWinControl *Control,
int Index, TRect &Rect, TOwnerDrawState State)
{
int flags;
TColor _color;
TListBox *lb;
TCanvas *canvas;
String text, str;
lb = (TListBox*)Control;
canvas = lb->Canvas;
SaveCanvas(canvas);
if (Index < lb->Count)
{
flags = Control->DrawTextBiDiModeFlags(DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX);
if (!Control->UseRightToLeftAlignment())
Rect.Left += 2;
else
Rect.Right -= 2;
text = lb->Items->Strings[Index];
//lb->ItemHeight = canvas->TextHeight(text);
str = text.SubString(2, text.Length() - 1);
if (text[1] & 2)
{
if (!State.Contains(odSelected))
canvas->Brush->Color = TColor(0xE7E7E7);
else
canvas->Brush->Color = TColor(0xFF0000);
}
canvas->FillRect(Rect);
//Xrefs to Kb units
if (text[1] & 1)
{
if (!State.Contains(odSelected))
_color = TColor(0xC08000); //Blue
else
_color = TColor(0xBBBBBB); //LightGray
}
//Others
else
{
if (!State.Contains(odSelected))
_color = TColor(0x00B000); //Green
else
_color = TColor(0xBBBBBB); //LightGray
}
Rect.Right = Rect.Left;
DrawOneItem(str, canvas, Rect, _color, flags);
}
RestoreCanvas(canvas);
}
//---------------------------------------------------------------------------