forked from Baron-von-Riedesel/ExplASM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugout.inc
More file actions
139 lines (124 loc) · 2.22 KB
/
Debugout.inc
File metadata and controls
139 lines (124 loc) · 2.22 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
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
;--- define macros for debugging output
;--- DebugOutNoLF: printf format OutputDebugStringA
;--- DebugOut: printf format OutputDebugStringA
;--- @trace: output a string via OutputDebugStringA
;--- @tracew: output a wide string via OutputDebugStringW
;--- @tracedw: output a dword (use __dw2aDebug)
ifndef CStr
CStr macro y:req
local sym,xxx
xxx textequ @CurSeg
.const
ifidni <y>,<"">
sym db 0
else
sym db y,0
endif
ifidni xxx,<_TEXT>
.code
else
.data
endif
exitm <offset sym>
endm
endif
ifndef wsprintf
wsprintfAproto typedef PROTO C :DWORD,:DWORD,:VARARG
externdef c _imp__wsprintfA:ptr wsprintfAproto
wsprintf equ <_imp__wsprintfA>
endif
ifndef _DEBUG
DEBUG = 0
else
DEBUG = 1
endif
DebugOutNoLF Macro x:req,y:VARARG
local sym,ii
if DEBUG
.const
sym db x,0
.code
pushad
if 0;def DEBUGPREFIX
invoke OutputDebugString,DEBUGPREFIX
popad
pushad
endif
ifnb <y>
sub esp,256
ii = 0
for parname,<y>
ii = ii + 4
endm
push esp
invoke wsprintf,[esp+ii+4],addr sym,y
pop esp
invoke OutputDebugString,esp
add esp,256
else
invoke OutputDebugString,addr sym
endif
popad
endif
endm
DebugOut macro x:req,y:VARARG
ifnb <y>
DebugOutNoLF <x,0dh,0ah>,y
else
DebugOutNoLF <x,0dh,0ah>
endif
endm
;--- simple string output if wsprintf is not available
@trace macro x
local y, defConst
ifdef _DEBUG
defConst = 1
for operand,<x>
if (OPATTR(operand)) and 10010y
defConst = 0
endif
endm
pushad
if defConst
.const
y db x, 0
.code
invoke OutputDebugString, offset y
else
invoke OutputDebugString, x
endif
popad
endif
endm
;--- same for wide chars (OutputDebugStringW doesnt work for win9x)
@tracew macro x
ifdef _DEBUG
OutputDebugStringW proto stdcall :ptr WORD
defConst = 1
for operand,<x>
if (OPATTR(operand)) and 10010y
defConst = 0
endif
endm
pushad
if defConst
.const
y dw L(x)
.code
invoke OutputDebugStringW, offset y
else
invoke OutputDebugStringW, x
endif
popad
endif
endm
;--- simple number output if wsprintf is not available
@tracedw macro x
ifdef _DEBUG
__dw2aDebug proto stdcall
pushad
mov eax, x
call __dw2aDebug
popad
endif
endm