forked from jrsoftware/issrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebugStruct.pas
168 lines (149 loc) · 5.9 KB
/
DebugStruct.pas
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
168
unit DebugStruct;
{
Inno Setup
Copyright (C) 1997-2020 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
Debug info stuff
}
interface
uses
Windows, Messages, SysUtils;
const
{ Debug client -> debugger messages }
WM_Debugger_Hello = WM_USER + $700;
WM_Debugger_Goodbye = WM_USER + $701;
WM_Debugger_Stepped = WM_USER + $702;
WM_Debugger_SteppedIntermediate = WM_USER + $703;
WM_Debugger_Exception = WM_USER + $704;
WM_Debugger_SetForegroundWindow = WM_USER + $705;
WM_Debugger_QueryVersion = WM_USER + $706;
WM_Debugger_CallStackCount = WM_USER + $707;
{ Debug client -> debugger WM_COPYDATA messages }
CD_Debugger_ReplyW = $700;
CD_Debugger_ExceptionW = $701;
CD_Debugger_UninstExeW = $702;
CD_Debugger_LogMessageW = $703;
CD_Debugger_TempDirW = $704;
CD_Debugger_CallStackW = $705;
{ Debugger -> debug client messages }
WM_DebugClient_Detach = WM_USER + $800;
WM_DebugClient_Continue = WM_USER + $801;
WM_DebugClient_SetForegroundWindow = WM_USER + $803;
{ List of all messages the debugger may send the debug client }
DebugClientMessages: array[0..3] of UINT = (
WM_COPYDATA,
WM_DebugClient_Detach,
WM_DebugClient_Continue,
WM_DebugClient_SetForegroundWindow);
{ Debugger -> debug client WM_COPYDATA messages }
CD_DebugClient_EvaluateConstantW = $800;
CD_DebugClient_EvaluateVariableEntry = $801;
CD_DebugClient_CompiledCodeTextA = $802;
CD_DebugClient_CompiledCodeDebugInfoA = $803;
{ The current format of the 'debug info' is as follows:
1. A TDebugInfoHeader record.
2. A variable number (TDebugInfoHeader.DebugEntryCount) of TDebugEntry
records.
3. A variable number (TDebugInfoHeader.VariableDebugEntryCount) of
TVariableDebugEntry records.
4. The ROPS compiled code, the format of which is defined by ROPS.
TDebugInfoHeader.CompiledCodeTextLength specifies the size in bytes.
5. Additional debug info for the ROPS compiled code, the format of which is
defined by ROPS. TDebugInfoHeader.CompiledCodeDebugInfoLength specifies
the size in bytes.
}
const
DebugInfoHeaderID = $64787369;
DebugInfoHeaderVersion = 5;
type
PDebugInfoHeader = ^TDebugInfoHeader;
TDebugInfoHeader = packed record
ID: Cardinal; { = DebugInfoHeaderID }
Version: Integer; { = DebugInfoHeaderVersion }
DebugEntryCount: Integer;
VariableDebugEntryCount: Integer;
CompiledCodeTextLength: Integer;
CompiledCodeDebugInfoLength: Integer;
end;
{ TDebugEntrys associate section entries with files and line numbers }
TDebugEntryKind = (deDir, deFile, deIcon, deIni, deRegistry, deInstallDelete,
deUninstallDelete, deRun, deUninstallRun, deCodeLine);
PDebugEntry = ^TDebugEntry;
TDebugEntry = packed record
FileIndex: Integer; { -1: Main script, >=0: Include file index }
LineNumber: Integer; { Starts at 1 - decreased by one by the Compiler IDE on receive }
Kind: Integer; { TDebugEntryKind }
Index: Integer;
StepOutMarker: Boolean;
end;
{ TVariableDebugEntrys associate [Code] section variable references with line
numbers & column positions }
PVariableDebugEntry = ^TVariableDebugEntry;
TVariableDebugEntry = packed record
FileIndex, LineNumber, Col: Integer; { Used by the Compiler IDE - also see TDebugEntry }
Param1, Param2, Param3: Integer; { Used by Setup }
Param4: array [0..127] of AnsiChar; { Used by Setup }
end;
function GetThreadTopWindow: HWND;
function SendCopyDataMessage(DestWnd, SourceWnd: HWND; CopyDataMsg: DWORD;
Data: Pointer; Size: Cardinal): LRESULT;
function SendCopyDataMessageStr(DestWnd, SourceWnd: HWND; CopyDataMsg: DWORD;
Data: AnsiString): LRESULT;{$IFDEF UNICODE} overload;{$ENDIF}
{$IFDEF UNICODE}
function SendCopyDataMessageStr(DestWnd, SourceWnd: HWND; CopyDataMsg: DWORD;
Data: UnicodeString): LRESULT; overload;
{$ENDIF}
implementation
function EnumProc(Wnd: HWND; lParam: LPARAM): BOOL; stdcall;
begin
if IsWindowVisible(Wnd) then begin
HWND(Pointer(lParam)^) := Wnd;
Result := False;
end
else
Result := True;
end;
function GetThreadTopWindow: HWND;
begin
Result := 0;
EnumThreadWindows(GetCurrentThreadId, @EnumProc, LPARAM(@Result));
end;
function SendCopyDataMessage(DestWnd, SourceWnd: HWND; CopyDataMsg: DWORD;
Data: Pointer; Size: Cardinal): LRESULT;
var
CopyDataStruct: TCopyDataStruct;
begin
CopyDataStruct.dwData := CopyDataMsg;
CopyDataStruct.cbData := Size;
CopyDataStruct.lpData := Data;
Result := SendMessage(DestWnd, WM_COPYDATA, WPARAM(SourceWnd),
LPARAM(@CopyDataStruct));
end;
function SendCopyDataMessageStr(DestWnd, SourceWnd: HWND; CopyDataMsg: DWORD;
Data: AnsiString): LRESULT;
begin
{ Windows 95/98/Me bug workaround: Call UniqueString to ensure the string is
in writable memory. Amazingly enough, sending a WM_COPYDATA message with a
read-only buffer causes a fatal page fault error. }
if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and
IsBadWritePtr(Pointer(Data), Length(Data)*SizeOf(Data[1])) then
UniqueString(Data);
Result := SendCopyDataMessage(DestWnd, SourceWnd, CopyDataMsg,
Pointer(Data), Length(Data)*SizeOf(Data[1]));
end;
{$IFDEF UNICODE}
function SendCopyDataMessageStr(DestWnd, SourceWnd: HWND; CopyDataMsg: DWORD;
Data: UnicodeString): LRESULT;
begin
{ Windows 95/98/Me bug workaround: Call UniqueString to ensure the string is
in writable memory. Amazingly enough, sending a WM_COPYDATA message with a
read-only buffer causes a fatal page fault error. }
if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and
IsBadWritePtr(Pointer(Data), Length(Data)*SizeOf(Data[1])) then
UniqueString(Data);
Result := SendCopyDataMessage(DestWnd, SourceWnd, CopyDataMsg,
Pointer(Data), Length(Data)*SizeOf(Data[1]));
end;
{$ENDIF}
end.