metasm 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/BUGS +11 -0
- data/CREDITS +17 -0
- data/README +270 -0
- data/TODO +114 -0
- data/doc/code_organisation.txt +146 -0
- data/doc/const_missing.txt +16 -0
- data/doc/core_classes.txt +75 -0
- data/doc/feature_list.txt +53 -0
- data/doc/index.txt +59 -0
- data/doc/install_notes.txt +170 -0
- data/doc/style.css +3 -0
- data/doc/use_cases.txt +18 -0
- data/lib/metasm.rb +80 -0
- data/lib/metasm/arm.rb +12 -0
- data/lib/metasm/arm/debug.rb +39 -0
- data/lib/metasm/arm/decode.rb +167 -0
- data/lib/metasm/arm/encode.rb +77 -0
- data/lib/metasm/arm/main.rb +75 -0
- data/lib/metasm/arm/opcodes.rb +177 -0
- data/lib/metasm/arm/parse.rb +130 -0
- data/lib/metasm/arm/render.rb +55 -0
- data/lib/metasm/compile_c.rb +1457 -0
- data/lib/metasm/dalvik.rb +8 -0
- data/lib/metasm/dalvik/decode.rb +196 -0
- data/lib/metasm/dalvik/main.rb +60 -0
- data/lib/metasm/dalvik/opcodes.rb +366 -0
- data/lib/metasm/decode.rb +213 -0
- data/lib/metasm/decompile.rb +2659 -0
- data/lib/metasm/disassemble.rb +2068 -0
- data/lib/metasm/disassemble_api.rb +1280 -0
- data/lib/metasm/dynldr.rb +1329 -0
- data/lib/metasm/encode.rb +333 -0
- data/lib/metasm/exe_format/a_out.rb +194 -0
- data/lib/metasm/exe_format/autoexe.rb +82 -0
- data/lib/metasm/exe_format/bflt.rb +189 -0
- data/lib/metasm/exe_format/coff.rb +455 -0
- data/lib/metasm/exe_format/coff_decode.rb +901 -0
- data/lib/metasm/exe_format/coff_encode.rb +1078 -0
- data/lib/metasm/exe_format/dex.rb +457 -0
- data/lib/metasm/exe_format/dol.rb +145 -0
- data/lib/metasm/exe_format/elf.rb +923 -0
- data/lib/metasm/exe_format/elf_decode.rb +979 -0
- data/lib/metasm/exe_format/elf_encode.rb +1375 -0
- data/lib/metasm/exe_format/macho.rb +827 -0
- data/lib/metasm/exe_format/main.rb +228 -0
- data/lib/metasm/exe_format/mz.rb +164 -0
- data/lib/metasm/exe_format/nds.rb +172 -0
- data/lib/metasm/exe_format/pe.rb +437 -0
- data/lib/metasm/exe_format/serialstruct.rb +246 -0
- data/lib/metasm/exe_format/shellcode.rb +114 -0
- data/lib/metasm/exe_format/xcoff.rb +167 -0
- data/lib/metasm/gui.rb +23 -0
- data/lib/metasm/gui/cstruct.rb +373 -0
- data/lib/metasm/gui/dasm_coverage.rb +199 -0
- data/lib/metasm/gui/dasm_decomp.rb +369 -0
- data/lib/metasm/gui/dasm_funcgraph.rb +103 -0
- data/lib/metasm/gui/dasm_graph.rb +1354 -0
- data/lib/metasm/gui/dasm_hex.rb +543 -0
- data/lib/metasm/gui/dasm_listing.rb +599 -0
- data/lib/metasm/gui/dasm_main.rb +906 -0
- data/lib/metasm/gui/dasm_opcodes.rb +291 -0
- data/lib/metasm/gui/debug.rb +1228 -0
- data/lib/metasm/gui/gtk.rb +884 -0
- data/lib/metasm/gui/qt.rb +495 -0
- data/lib/metasm/gui/win32.rb +3004 -0
- data/lib/metasm/gui/x11.rb +621 -0
- data/lib/metasm/ia32.rb +14 -0
- data/lib/metasm/ia32/compile_c.rb +1523 -0
- data/lib/metasm/ia32/debug.rb +193 -0
- data/lib/metasm/ia32/decode.rb +1167 -0
- data/lib/metasm/ia32/decompile.rb +564 -0
- data/lib/metasm/ia32/encode.rb +314 -0
- data/lib/metasm/ia32/main.rb +233 -0
- data/lib/metasm/ia32/opcodes.rb +872 -0
- data/lib/metasm/ia32/parse.rb +327 -0
- data/lib/metasm/ia32/render.rb +91 -0
- data/lib/metasm/main.rb +1193 -0
- data/lib/metasm/mips.rb +11 -0
- data/lib/metasm/mips/compile_c.rb +7 -0
- data/lib/metasm/mips/decode.rb +253 -0
- data/lib/metasm/mips/encode.rb +51 -0
- data/lib/metasm/mips/main.rb +72 -0
- data/lib/metasm/mips/opcodes.rb +443 -0
- data/lib/metasm/mips/parse.rb +51 -0
- data/lib/metasm/mips/render.rb +43 -0
- data/lib/metasm/os/gnu_exports.rb +270 -0
- data/lib/metasm/os/linux.rb +1112 -0
- data/lib/metasm/os/main.rb +1686 -0
- data/lib/metasm/os/remote.rb +527 -0
- data/lib/metasm/os/windows.rb +2027 -0
- data/lib/metasm/os/windows_exports.rb +745 -0
- data/lib/metasm/parse.rb +876 -0
- data/lib/metasm/parse_c.rb +3938 -0
- data/lib/metasm/pic16c/decode.rb +42 -0
- data/lib/metasm/pic16c/main.rb +17 -0
- data/lib/metasm/pic16c/opcodes.rb +68 -0
- data/lib/metasm/ppc.rb +11 -0
- data/lib/metasm/ppc/decode.rb +264 -0
- data/lib/metasm/ppc/decompile.rb +251 -0
- data/lib/metasm/ppc/encode.rb +51 -0
- data/lib/metasm/ppc/main.rb +129 -0
- data/lib/metasm/ppc/opcodes.rb +410 -0
- data/lib/metasm/ppc/parse.rb +52 -0
- data/lib/metasm/preprocessor.rb +1277 -0
- data/lib/metasm/render.rb +130 -0
- data/lib/metasm/sh4.rb +8 -0
- data/lib/metasm/sh4/decode.rb +336 -0
- data/lib/metasm/sh4/main.rb +292 -0
- data/lib/metasm/sh4/opcodes.rb +381 -0
- data/lib/metasm/x86_64.rb +12 -0
- data/lib/metasm/x86_64/compile_c.rb +1025 -0
- data/lib/metasm/x86_64/debug.rb +59 -0
- data/lib/metasm/x86_64/decode.rb +268 -0
- data/lib/metasm/x86_64/encode.rb +264 -0
- data/lib/metasm/x86_64/main.rb +135 -0
- data/lib/metasm/x86_64/opcodes.rb +118 -0
- data/lib/metasm/x86_64/parse.rb +68 -0
- data/misc/bottleneck.rb +61 -0
- data/misc/cheader-findpppath.rb +58 -0
- data/misc/hexdiff.rb +74 -0
- data/misc/hexdump.rb +55 -0
- data/misc/metasm-all.rb +13 -0
- data/misc/objdiff.rb +47 -0
- data/misc/objscan.rb +40 -0
- data/misc/pdfparse.rb +661 -0
- data/misc/ppc_pdf2oplist.rb +192 -0
- data/misc/tcp_proxy_hex.rb +84 -0
- data/misc/txt2html.rb +440 -0
- data/samples/a.out.rb +31 -0
- data/samples/asmsyntax.rb +77 -0
- data/samples/bindiff.rb +555 -0
- data/samples/compilation-steps.rb +49 -0
- data/samples/cparser_makestackoffset.rb +55 -0
- data/samples/dasm-backtrack.rb +38 -0
- data/samples/dasmnavig.rb +318 -0
- data/samples/dbg-apihook.rb +228 -0
- data/samples/dbghelp.rb +143 -0
- data/samples/disassemble-gui.rb +102 -0
- data/samples/disassemble.rb +133 -0
- data/samples/dump_upx.rb +95 -0
- data/samples/dynamic_ruby.rb +1929 -0
- data/samples/elf_list_needed.rb +46 -0
- data/samples/elf_listexports.rb +33 -0
- data/samples/elfencode.rb +25 -0
- data/samples/exeencode.rb +128 -0
- data/samples/factorize-headers-elfimports.rb +77 -0
- data/samples/factorize-headers-peimports.rb +109 -0
- data/samples/factorize-headers.rb +43 -0
- data/samples/gdbclient.rb +583 -0
- data/samples/generate_libsigs.rb +102 -0
- data/samples/hotfix_gtk_dbg.rb +59 -0
- data/samples/install_win_env.rb +78 -0
- data/samples/lindebug.rb +924 -0
- data/samples/linux_injectsyscall.rb +95 -0
- data/samples/machoencode.rb +31 -0
- data/samples/metasm-shell.rb +91 -0
- data/samples/pe-hook.rb +69 -0
- data/samples/pe-ia32-cpuid.rb +203 -0
- data/samples/pe-mips.rb +35 -0
- data/samples/pe-shutdown.rb +78 -0
- data/samples/pe-testrelocs.rb +51 -0
- data/samples/pe-testrsrc.rb +24 -0
- data/samples/pe_listexports.rb +31 -0
- data/samples/peencode.rb +19 -0
- data/samples/peldr.rb +494 -0
- data/samples/preprocess-flatten.rb +19 -0
- data/samples/r0trace.rb +308 -0
- data/samples/rubstop.rb +399 -0
- data/samples/scan_pt_gnu_stack.rb +54 -0
- data/samples/scanpeexports.rb +62 -0
- data/samples/shellcode-c.rb +40 -0
- data/samples/shellcode-dynlink.rb +146 -0
- data/samples/source.asm +34 -0
- data/samples/struct_offset.rb +47 -0
- data/samples/testpe.rb +32 -0
- data/samples/testraw.rb +45 -0
- data/samples/win32genloader.rb +132 -0
- data/samples/win32hooker-advanced.rb +169 -0
- data/samples/win32hooker.rb +96 -0
- data/samples/win32livedasm.rb +33 -0
- data/samples/win32remotescan.rb +133 -0
- data/samples/wintrace.rb +92 -0
- data/tests/all.rb +8 -0
- data/tests/dasm.rb +39 -0
- data/tests/dynldr.rb +35 -0
- data/tests/encodeddata.rb +132 -0
- data/tests/ia32.rb +82 -0
- data/tests/mips.rb +116 -0
- data/tests/parse_c.rb +239 -0
- data/tests/preprocessor.rb +269 -0
- data/tests/x86_64.rb +62 -0
- metadata +255 -0
@@ -0,0 +1,621 @@
|
|
1
|
+
# This file is part of Metasm, the Ruby assembly manipulation suite
|
2
|
+
# Copyright (C) 2006-2009 Yoann GUILLOT
|
3
|
+
#
|
4
|
+
# Licence is LGPL, see LICENCE in the top-level directory
|
5
|
+
|
6
|
+
require 'metasm/dynldr'
|
7
|
+
|
8
|
+
module Metasm
|
9
|
+
module Gui
|
10
|
+
class XGui < DynLdr
|
11
|
+
new_api_c <<EOS, 'libX11.so'
|
12
|
+
#define KeyPressMask (1L<<0)
|
13
|
+
#define KeyReleaseMask (1L<<1)
|
14
|
+
#define ButtonPressMask (1L<<2)
|
15
|
+
#define ButtonReleaseMask (1L<<3)
|
16
|
+
#define EnterWindowMask (1L<<4)
|
17
|
+
#define LeaveWindowMask (1L<<5)
|
18
|
+
#define PointerMotionMask (1L<<6)
|
19
|
+
#define PointerMotionHintMask (1L<<7)
|
20
|
+
#define Button1MotionMask (1L<<8)
|
21
|
+
#define Button2MotionMask (1L<<9)
|
22
|
+
#define Button3MotionMask (1L<<10)
|
23
|
+
#define Button4MotionMask (1L<<11)
|
24
|
+
#define Button5MotionMask (1L<<12)
|
25
|
+
#define ButtonMotionMask (1L<<13)
|
26
|
+
#define KeymapStateMask (1L<<14)
|
27
|
+
#define ExposureMask (1L<<15)
|
28
|
+
#define VisibilityChangeMask (1L<<16)
|
29
|
+
#define StructureNotifyMask (1L<<17)
|
30
|
+
#define ResizeRedirectMask (1L<<18)
|
31
|
+
#define SubstructureNotifyMask (1L<<19)
|
32
|
+
#define SubstructureRedirectMask (1L<<20)
|
33
|
+
#define FocusChangeMask (1L<<21)
|
34
|
+
#define PropertyChangeMask (1L<<22)
|
35
|
+
#define ColormapChangeMask (1L<<23)
|
36
|
+
#define OwnerGrabButtonMask (1L<<24)
|
37
|
+
|
38
|
+
#define KeyPress 2
|
39
|
+
#define KeyRelease 3
|
40
|
+
#define ButtonPress 4
|
41
|
+
#define ButtonRelease 5
|
42
|
+
#define MotionNotify 6
|
43
|
+
#define EnterNotify 7
|
44
|
+
#define LeaveNotify 8
|
45
|
+
#define FocusIn 9
|
46
|
+
#define FocusOut 10
|
47
|
+
#define KeymapNotify 11
|
48
|
+
#define Expose 12
|
49
|
+
#define GraphicsExpose 13
|
50
|
+
#define NoExpose 14
|
51
|
+
#define VisibilityNotify 15
|
52
|
+
#define CreateNotify 16
|
53
|
+
#define DestroyNotify 17
|
54
|
+
#define UnmapNotify 18
|
55
|
+
#define MapNotify 19
|
56
|
+
#define MapRequest 20
|
57
|
+
#define ReparentNotify 21
|
58
|
+
#define ConfigureNotify 22
|
59
|
+
#define ConfigureRequest 23
|
60
|
+
#define GravityNotify 24
|
61
|
+
#define ResizeRequest 25
|
62
|
+
#define CirculateNotify 26
|
63
|
+
#define CirculateRequest 27
|
64
|
+
#define PropertyNotify 28
|
65
|
+
#define SelectionClear 29
|
66
|
+
#define SelectionRequest 30
|
67
|
+
#define SelectionNotify 31
|
68
|
+
#define ColormapNotify 32
|
69
|
+
#define ClientMessage 33
|
70
|
+
#define MappingNotify 34
|
71
|
+
#define GenericEvent 35
|
72
|
+
#define LASTEvent 36 /* must be bigger than any event # */
|
73
|
+
|
74
|
+
typedef unsigned long Atom;
|
75
|
+
typedef unsigned long Time;
|
76
|
+
typedef unsigned long XID;
|
77
|
+
struct _XDisplay;
|
78
|
+
|
79
|
+
typedef XID Colormap;
|
80
|
+
typedef struct _XDisplay Display;
|
81
|
+
typedef XID Drawable;
|
82
|
+
typedef XID Font;
|
83
|
+
typedef struct _XGC *GC;
|
84
|
+
typedef XID Pixmap;
|
85
|
+
typedef XID Window;
|
86
|
+
|
87
|
+
typedef
|
88
|
+
struct {
|
89
|
+
int type;
|
90
|
+
unsigned long serial;
|
91
|
+
int send_event;
|
92
|
+
Display *display;
|
93
|
+
Window window;
|
94
|
+
} XAnyEvent;
|
95
|
+
typedef
|
96
|
+
struct {
|
97
|
+
int type;
|
98
|
+
unsigned long serial;
|
99
|
+
int send_event;
|
100
|
+
Display *display;
|
101
|
+
Window window;
|
102
|
+
Window root;
|
103
|
+
Window subwindow;
|
104
|
+
Time time;
|
105
|
+
int x;
|
106
|
+
int y;
|
107
|
+
int x_root;
|
108
|
+
int y_root;
|
109
|
+
unsigned int state;
|
110
|
+
unsigned int button;
|
111
|
+
int same_screen;
|
112
|
+
} XButtonEvent;
|
113
|
+
typedef
|
114
|
+
struct {
|
115
|
+
int type;
|
116
|
+
unsigned long serial;
|
117
|
+
int send_event;
|
118
|
+
Display *display;
|
119
|
+
Window event;
|
120
|
+
Window window;
|
121
|
+
int place;
|
122
|
+
} XCirculateEvent;
|
123
|
+
typedef
|
124
|
+
struct {
|
125
|
+
int type;
|
126
|
+
unsigned long serial;
|
127
|
+
int send_event;
|
128
|
+
Display *display;
|
129
|
+
Window parent;
|
130
|
+
Window window;
|
131
|
+
int place;
|
132
|
+
} XCirculateRequestEvent;
|
133
|
+
typedef
|
134
|
+
struct {
|
135
|
+
int type;
|
136
|
+
unsigned long serial;
|
137
|
+
int send_event;
|
138
|
+
Display *display;
|
139
|
+
Window window;
|
140
|
+
Atom message_type;
|
141
|
+
int format;
|
142
|
+
|
143
|
+
union {
|
144
|
+
char b[20];
|
145
|
+
short s[10];
|
146
|
+
long l[5];
|
147
|
+
} data;
|
148
|
+
} XClientMessageEvent;
|
149
|
+
typedef
|
150
|
+
struct {
|
151
|
+
int type;
|
152
|
+
unsigned long serial;
|
153
|
+
int send_event;
|
154
|
+
Display *display;
|
155
|
+
Window window;
|
156
|
+
Colormap colormap;
|
157
|
+
int new;
|
158
|
+
int state;
|
159
|
+
} XColormapEvent;
|
160
|
+
typedef
|
161
|
+
struct {
|
162
|
+
int type;
|
163
|
+
unsigned long serial;
|
164
|
+
int send_event;
|
165
|
+
Display *display;
|
166
|
+
Window event;
|
167
|
+
Window window;
|
168
|
+
int x;
|
169
|
+
int y;
|
170
|
+
int width;
|
171
|
+
int height;
|
172
|
+
int border_width;
|
173
|
+
Window above;
|
174
|
+
int override_redirect;
|
175
|
+
} XConfigureEvent;
|
176
|
+
typedef
|
177
|
+
struct {
|
178
|
+
int type;
|
179
|
+
unsigned long serial;
|
180
|
+
int send_event;
|
181
|
+
Display *display;
|
182
|
+
Window parent;
|
183
|
+
Window window;
|
184
|
+
int x;
|
185
|
+
int y;
|
186
|
+
int width;
|
187
|
+
int height;
|
188
|
+
int border_width;
|
189
|
+
Window above;
|
190
|
+
int detail;
|
191
|
+
unsigned long value_mask;
|
192
|
+
} XConfigureRequestEvent;
|
193
|
+
typedef
|
194
|
+
struct {
|
195
|
+
int type;
|
196
|
+
unsigned long serial;
|
197
|
+
int send_event;
|
198
|
+
Display *display;
|
199
|
+
Window parent;
|
200
|
+
Window window;
|
201
|
+
int x;
|
202
|
+
int y;
|
203
|
+
int width;
|
204
|
+
int height;
|
205
|
+
int border_width;
|
206
|
+
int override_redirect;
|
207
|
+
} XCreateWindowEvent;
|
208
|
+
typedef
|
209
|
+
struct {
|
210
|
+
int type;
|
211
|
+
unsigned long serial;
|
212
|
+
int send_event;
|
213
|
+
Display *display;
|
214
|
+
Window window;
|
215
|
+
Window root;
|
216
|
+
Window subwindow;
|
217
|
+
Time time;
|
218
|
+
int x;
|
219
|
+
int y;
|
220
|
+
int x_root;
|
221
|
+
int y_root;
|
222
|
+
int mode;
|
223
|
+
int detail;
|
224
|
+
int same_screen;
|
225
|
+
int focus;
|
226
|
+
unsigned int state;
|
227
|
+
} XCrossingEvent;
|
228
|
+
typedef
|
229
|
+
struct {
|
230
|
+
int type;
|
231
|
+
unsigned long serial;
|
232
|
+
int send_event;
|
233
|
+
Display *display;
|
234
|
+
Window event;
|
235
|
+
Window window;
|
236
|
+
} XDestroyWindowEvent;
|
237
|
+
typedef
|
238
|
+
struct {
|
239
|
+
int type;
|
240
|
+
Display *display;
|
241
|
+
XID resourceid;
|
242
|
+
unsigned long serial;
|
243
|
+
unsigned char error_code;
|
244
|
+
unsigned char request_code;
|
245
|
+
unsigned char minor_code;
|
246
|
+
} XErrorEvent;
|
247
|
+
typedef
|
248
|
+
struct {
|
249
|
+
int type;
|
250
|
+
unsigned long serial;
|
251
|
+
int send_event;
|
252
|
+
Display *display;
|
253
|
+
Window window;
|
254
|
+
int x;
|
255
|
+
int y;
|
256
|
+
int width;
|
257
|
+
int height;
|
258
|
+
int count;
|
259
|
+
} XExposeEvent;
|
260
|
+
typedef
|
261
|
+
struct {
|
262
|
+
int type;
|
263
|
+
unsigned long serial;
|
264
|
+
int send_event;
|
265
|
+
Display *display;
|
266
|
+
Window window;
|
267
|
+
int mode;
|
268
|
+
int detail;
|
269
|
+
} XFocusChangeEvent;
|
270
|
+
typedef
|
271
|
+
struct {
|
272
|
+
int function;
|
273
|
+
unsigned long plane_mask;
|
274
|
+
unsigned long foreground;
|
275
|
+
unsigned long background;
|
276
|
+
int line_width;
|
277
|
+
int line_style;
|
278
|
+
int cap_style;
|
279
|
+
int join_style;
|
280
|
+
int fill_style;
|
281
|
+
int fill_rule;
|
282
|
+
int arc_mode;
|
283
|
+
Pixmap tile;
|
284
|
+
Pixmap stipple;
|
285
|
+
int ts_x_origin;
|
286
|
+
int ts_y_origin;
|
287
|
+
Font font;
|
288
|
+
int subwindow_mode;
|
289
|
+
int graphics_exposures;
|
290
|
+
int clip_x_origin;
|
291
|
+
int clip_y_origin;
|
292
|
+
Pixmap clip_mask;
|
293
|
+
int dash_offset;
|
294
|
+
char dashes;
|
295
|
+
} XGCValues;
|
296
|
+
typedef
|
297
|
+
struct {
|
298
|
+
int type;
|
299
|
+
unsigned long serial;
|
300
|
+
int send_event;
|
301
|
+
Display *display;
|
302
|
+
int extension;
|
303
|
+
int evtype;
|
304
|
+
} XGenericEvent;
|
305
|
+
typedef
|
306
|
+
struct {
|
307
|
+
int type;
|
308
|
+
unsigned long serial;
|
309
|
+
int send_event;
|
310
|
+
Display *display;
|
311
|
+
int extension;
|
312
|
+
int evtype;
|
313
|
+
unsigned int cookie;
|
314
|
+
void *data;
|
315
|
+
} XGenericEventCookie;
|
316
|
+
typedef
|
317
|
+
struct {
|
318
|
+
int type;
|
319
|
+
unsigned long serial;
|
320
|
+
int send_event;
|
321
|
+
Display *display;
|
322
|
+
Drawable drawable;
|
323
|
+
int x;
|
324
|
+
int y;
|
325
|
+
int width;
|
326
|
+
int height;
|
327
|
+
int count;
|
328
|
+
int major_code;
|
329
|
+
int minor_code;
|
330
|
+
} XGraphicsExposeEvent;
|
331
|
+
typedef
|
332
|
+
struct {
|
333
|
+
int type;
|
334
|
+
unsigned long serial;
|
335
|
+
int send_event;
|
336
|
+
Display *display;
|
337
|
+
Window event;
|
338
|
+
Window window;
|
339
|
+
int x;
|
340
|
+
int y;
|
341
|
+
} XGravityEvent;
|
342
|
+
typedef
|
343
|
+
struct {
|
344
|
+
int type;
|
345
|
+
unsigned long serial;
|
346
|
+
int send_event;
|
347
|
+
Display *display;
|
348
|
+
Window window;
|
349
|
+
Window root;
|
350
|
+
Window subwindow;
|
351
|
+
Time time;
|
352
|
+
int x;
|
353
|
+
int y;
|
354
|
+
int x_root;
|
355
|
+
int y_root;
|
356
|
+
unsigned int state;
|
357
|
+
unsigned int keycode;
|
358
|
+
int same_screen;
|
359
|
+
} XKeyEvent;
|
360
|
+
typedef
|
361
|
+
struct {
|
362
|
+
int type;
|
363
|
+
unsigned long serial;
|
364
|
+
int send_event;
|
365
|
+
Display *display;
|
366
|
+
Window window;
|
367
|
+
char key_vector[32];
|
368
|
+
} XKeymapEvent;
|
369
|
+
typedef
|
370
|
+
struct {
|
371
|
+
int type;
|
372
|
+
unsigned long serial;
|
373
|
+
int send_event;
|
374
|
+
Display *display;
|
375
|
+
Window event;
|
376
|
+
Window window;
|
377
|
+
int override_redirect;
|
378
|
+
} XMapEvent;
|
379
|
+
typedef
|
380
|
+
struct {
|
381
|
+
int type;
|
382
|
+
unsigned long serial;
|
383
|
+
int send_event;
|
384
|
+
Display *display;
|
385
|
+
Window parent;
|
386
|
+
Window window;
|
387
|
+
} XMapRequestEvent;
|
388
|
+
typedef
|
389
|
+
struct {
|
390
|
+
int type;
|
391
|
+
unsigned long serial;
|
392
|
+
int send_event;
|
393
|
+
Display *display;
|
394
|
+
Window window;
|
395
|
+
int request;
|
396
|
+
int first_keycode;
|
397
|
+
int count;
|
398
|
+
} XMappingEvent;
|
399
|
+
typedef
|
400
|
+
struct {
|
401
|
+
int type;
|
402
|
+
unsigned long serial;
|
403
|
+
int send_event;
|
404
|
+
Display *display;
|
405
|
+
Window window;
|
406
|
+
Window root;
|
407
|
+
Window subwindow;
|
408
|
+
Time time;
|
409
|
+
int x;
|
410
|
+
int y;
|
411
|
+
int x_root;
|
412
|
+
int y_root;
|
413
|
+
unsigned int state;
|
414
|
+
char is_hint;
|
415
|
+
int same_screen;
|
416
|
+
} XMotionEvent;
|
417
|
+
typedef
|
418
|
+
struct {
|
419
|
+
int type;
|
420
|
+
unsigned long serial;
|
421
|
+
int send_event;
|
422
|
+
Display *display;
|
423
|
+
Drawable drawable;
|
424
|
+
int major_code;
|
425
|
+
int minor_code;
|
426
|
+
} XNoExposeEvent;
|
427
|
+
typedef
|
428
|
+
struct {
|
429
|
+
int type;
|
430
|
+
unsigned long serial;
|
431
|
+
int send_event;
|
432
|
+
Display *display;
|
433
|
+
Window window;
|
434
|
+
Atom atom;
|
435
|
+
Time time;
|
436
|
+
int state;
|
437
|
+
} XPropertyEvent;
|
438
|
+
typedef
|
439
|
+
struct {
|
440
|
+
int type;
|
441
|
+
unsigned long serial;
|
442
|
+
int send_event;
|
443
|
+
Display *display;
|
444
|
+
Window event;
|
445
|
+
Window window;
|
446
|
+
Window parent;
|
447
|
+
int x;
|
448
|
+
int y;
|
449
|
+
int override_redirect;
|
450
|
+
} XReparentEvent;
|
451
|
+
typedef
|
452
|
+
struct {
|
453
|
+
int type;
|
454
|
+
unsigned long serial;
|
455
|
+
int send_event;
|
456
|
+
Display *display;
|
457
|
+
Window window;
|
458
|
+
int width;
|
459
|
+
int height;
|
460
|
+
} XResizeRequestEvent;
|
461
|
+
typedef
|
462
|
+
struct {
|
463
|
+
int type;
|
464
|
+
unsigned long serial;
|
465
|
+
int send_event;
|
466
|
+
Display *display;
|
467
|
+
Window window;
|
468
|
+
Atom selection;
|
469
|
+
Time time;
|
470
|
+
} XSelectionClearEvent;
|
471
|
+
typedef
|
472
|
+
struct {
|
473
|
+
int type;
|
474
|
+
unsigned long serial;
|
475
|
+
int send_event;
|
476
|
+
Display *display;
|
477
|
+
Window requestor;
|
478
|
+
Atom selection;
|
479
|
+
Atom target;
|
480
|
+
Atom property;
|
481
|
+
Time time;
|
482
|
+
} XSelectionEvent;
|
483
|
+
typedef
|
484
|
+
struct {
|
485
|
+
int type;
|
486
|
+
unsigned long serial;
|
487
|
+
int send_event;
|
488
|
+
Display *display;
|
489
|
+
Window owner;
|
490
|
+
Window requestor;
|
491
|
+
Atom selection;
|
492
|
+
Atom target;
|
493
|
+
Atom property;
|
494
|
+
Time time;
|
495
|
+
} XSelectionRequestEvent;
|
496
|
+
typedef
|
497
|
+
struct {
|
498
|
+
int type;
|
499
|
+
unsigned long serial;
|
500
|
+
int send_event;
|
501
|
+
Display *display;
|
502
|
+
Window event;
|
503
|
+
Window window;
|
504
|
+
int from_configure;
|
505
|
+
} XUnmapEvent;
|
506
|
+
typedef
|
507
|
+
struct {
|
508
|
+
int type;
|
509
|
+
unsigned long serial;
|
510
|
+
int send_event;
|
511
|
+
Display *display;
|
512
|
+
Window window;
|
513
|
+
int state;
|
514
|
+
} XVisibilityEvent;
|
515
|
+
|
516
|
+
union _XEvent {
|
517
|
+
int type;
|
518
|
+
XAnyEvent xany;
|
519
|
+
XKeyEvent xkey;
|
520
|
+
XButtonEvent xbutton;
|
521
|
+
XMotionEvent xmotion;
|
522
|
+
XCrossingEvent xcrossing;
|
523
|
+
XFocusChangeEvent xfocus;
|
524
|
+
XExposeEvent xexpose;
|
525
|
+
XGraphicsExposeEvent xgraphicsexpose;
|
526
|
+
XNoExposeEvent xnoexpose;
|
527
|
+
XVisibilityEvent xvisibility;
|
528
|
+
XCreateWindowEvent xcreatewindow;
|
529
|
+
XDestroyWindowEvent xdestroywindow;
|
530
|
+
XUnmapEvent xunmap;
|
531
|
+
XMapEvent xmap;
|
532
|
+
XMapRequestEvent xmaprequest;
|
533
|
+
XReparentEvent xreparent;
|
534
|
+
XConfigureEvent xconfigure;
|
535
|
+
XGravityEvent xgravity;
|
536
|
+
XResizeRequestEvent xresizerequest;
|
537
|
+
XConfigureRequestEvent xconfigurerequest;
|
538
|
+
XCirculateEvent xcirculate;
|
539
|
+
XCirculateRequestEvent xcirculaterequest;
|
540
|
+
XPropertyEvent xproperty;
|
541
|
+
XSelectionClearEvent xselectionclear;
|
542
|
+
XSelectionRequestEvent xselectionrequest;
|
543
|
+
XSelectionEvent xselection;
|
544
|
+
XColormapEvent xcolormap;
|
545
|
+
XClientMessageEvent xclient;
|
546
|
+
XMappingEvent xmapping;
|
547
|
+
XErrorEvent xerror;
|
548
|
+
XKeymapEvent xkeymap;
|
549
|
+
XGenericEvent xgeneric;
|
550
|
+
XGenericEventCookie xcookie;
|
551
|
+
long pad[24];
|
552
|
+
};
|
553
|
+
|
554
|
+
|
555
|
+
typedef union _XEvent XEvent;
|
556
|
+
|
557
|
+
int XCloseDisplay(Display*);
|
558
|
+
Window XCreateSimpleWindow(Display*, Window, int, int, unsigned int, unsigned int, unsigned int, unsigned long, unsigned long);
|
559
|
+
int XDestroyWindow(Display*, Window);
|
560
|
+
Display *XOpenDisplay(const char*);
|
561
|
+
int XSelectInput(Display*, Window, long);
|
562
|
+
int XSetForeground(Display*, GC, unsigned long);
|
563
|
+
int XStoreName(Display*, Window, const char*);
|
564
|
+
GC XCreateGC(Display*, Drawable, unsigned long, XGCValues*);
|
565
|
+
int XNextEvent(Display*, XEvent*);
|
566
|
+
int XDefaultScreen(Display*);
|
567
|
+
int XDefaultRootWindow(Display*);
|
568
|
+
int XRootWindow(Display*, int);
|
569
|
+
int XDefaultColormap(Display*, int);
|
570
|
+
int XBlackPixel(Display*, int);
|
571
|
+
int XWhitePixel(Display*, int);
|
572
|
+
int XMapWindow(Display*, Window);
|
573
|
+
int XFillRectangle(Display*, Window, GC, int, int, int, int);
|
574
|
+
int XDrawLine(Display*, Window, GC, int, int, int, int);
|
575
|
+
int XDrawString(Display*, Drawable, GC, int, int, const char*, int);
|
576
|
+
int XLookupKeysym(XEvent*, int);
|
577
|
+
EOS
|
578
|
+
|
579
|
+
def self.test
|
580
|
+
d = xopendisplay(nil)
|
581
|
+
s = xdefaultscreen(d)
|
582
|
+
cmap = xdefaultcolormap(d, s)
|
583
|
+
w = xcreatesimplewindow(d, xdefaultrootwindow(d), 0, 0, 28, 28, 0, xblackpixel(d, s), xblackpixel(d, s))
|
584
|
+
xstorename(d, w, "lol")
|
585
|
+
gc = xcreategc(d, w, 0, 0)
|
586
|
+
xsetforeground(d, gc, xwhitepixel(d, s))
|
587
|
+
xselectinput(d, w, EXPOSUREMASK|KEYPRESSMASK|BUTTONPRESSMASK)
|
588
|
+
xmapwindow(d, w)
|
589
|
+
msg = alloc_c_struct('XEvent')
|
590
|
+
str = 'llllmmmml'
|
591
|
+
x = 12
|
592
|
+
y = 20
|
593
|
+
loop {
|
594
|
+
xnextevent(d, msg)
|
595
|
+
case msg['type']
|
596
|
+
when EXPOSE
|
597
|
+
#xsetforeground(d, gc, col)
|
598
|
+
#xdrawrectangle(d, w, gc, x, y+8, 30, 30)
|
599
|
+
xfillrectangle(d, w, gc, x, y+8, 30, 30)
|
600
|
+
xdrawline(d, w, gc, x, y+38, x+30, y+53)
|
601
|
+
xdrawstring(d, w, gc, x, y, str, str.length)
|
602
|
+
when KEYPRESS
|
603
|
+
k = xlookupkeysym(msg, 0)
|
604
|
+
p k
|
605
|
+
when BUTTONPRESS
|
606
|
+
break
|
607
|
+
end
|
608
|
+
}
|
609
|
+
xdestroywindow(d, w)
|
610
|
+
xclosedisplay(d)
|
611
|
+
end
|
612
|
+
|
613
|
+
test
|
614
|
+
|
615
|
+
end
|
616
|
+
end
|
617
|
+
end
|
618
|
+
|
619
|
+
#require 'metasm/gui/dasm_main'
|
620
|
+
#require 'metasm/gui/debug'
|
621
|
+
|