-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmore.inc
569 lines (445 loc) · 16.3 KB
/
more.inc
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
szText macro name, value
.data
&name db &value, 0
.code
endm
szText$ macro name,value
.data
&name db &value, 0
.code
exitm <offset &name>
endm
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
ListProc proc hWin:QWORD,uMsg:QWORD,wParam:QWORD,lParam:QWORD
USING r13
; -----------------------------------
; subclass procedure for the list box
; -----------------------------------
LOCAL indx :QWORD ; list box index variable
LOCAL pbuf :QWORD ; buffer pointer
LOCAL buffer0[248]:BYTE ; allocate space for text
LOCAL buffer1[248]:BYTE ; allocate space for command
.switch uMsg
.case WM_KEYUP
; -----------------
; single press keys
; -----------------
.switch wParam
.case VK_RETURN
jmp beginrun
.endsw
.case WM_LBUTTONDBLCLK
beginrun:
mov EscapeLock, 1
mov pbuf, ptr$(buffer0) ; get buffer address
mov indx, rv(SendMessage,hWin,LB_GETCURSEL,0,0) ; get index of current selection
invoke SendMessage, hWin, LB_GETTEXT, indx, pbuf ; load selected text into "pbuf"
mov indx, ptr$(buffer1)
cst indx, pbuf
mov indx, rv(get_pattern, indx)
fn szCmp, indx, "exe"
test eax, eax
jz @F
invoke MessageBox, hWin, "Binaries will not run from here", addr caption, MB_OK
.return 0
@@:
fn szCmp, indx, "bat"
test eax, eax
jz @F
mov prevented, 1
invoke ShellExecute, hWin, 0, addr EditorBat, pbuf, 0, SW_RESTORE
jmp result
@@:
fn szCmp, indx, "cmd"
test eax, eax
jz @F
mov prevented, 2
invoke ShellExecute, hWin, 0, addr EditorCmd, pbuf, 0, SW_RESTORE
jmp result
@@:
fn szCmp, indx, "js"
test eax, eax
jz @F
mov prevented, 3
invoke ShellExecute, hWin, 0, addr EditorJs, pbuf, 0, SW_RESTORE
jmp result
@@:
fn szCmp, indx, "sh"
test eax, eax
jz @F
mov prevented, 1
invoke ShellExecute, hWin, 0, addr EditorBat, pbuf, 0, SW_RESTORE
jmp result
@@:
mov prevented, 0
invoke ShellExecute, hWin, "open", pbuf, 0, 0, SW_RESTORE
result:
.if eax {= 32
.if eax == SE_ERR_NOASSOC
lea rdx, err1
.elseif eax == ERROR_FILE_NOT_FOUND
.if prevented == 0
lea rdx, err2
.else
if 0
SaveRegs
lea r13, buffer0
mcat r13, addr err3, addr default_editor
mov rdx, r13
RestoreRegs
endif
invoke DialogBoxParam, hInstance, 1000, hWin, ADDR AssocDlg, 0
.return 0
.endif
.else
lea rdx, err0
.endif
mov EscapeLock, 1
invoke MessageBox, hWin, rdx, addr caption, MB_OK
.endif
.return 0
.endsw
invoke CallWindowProc,lpListProc,hWin,uMsg,wParam,lParam
ret
ListProc endp
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
IntProc proc hWin:QWORD,uMsg:QWORD,wParam:QWORD,lParam:QWORD
.if uMsg == WM_CHAR
.if wParam == 8 ; backspace
jmp accept
.endif
.if wParam { "0"
.return 0
.endif
.if wParam } "9"
.return 0
.endif
.elseif uMsg == WM_KEYUP
.if wParam == VK_RETURN
invoke SendMessage, hWnd, WM_COMMAND, 201, 0
.return 0
.endif
.endif
accept:
invoke CallWindowProc,lpfnIntProc,hWin,uMsg,wParam,lParam
ret
IntProc endp
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
DecProc proc hWin:QWORD,uMsg:QWORD,wParam:QWORD,lParam:QWORD
LOCAL cBuffer[32]:BYTE
USING rsi
; With DednDave and Biterider help
; https://masm32.com/board/index.php?topic=4453.0
.if uMsg == WM_CHAR
.if wParam == 8 ; backspace
jmp accept
.endif
.if wParam == "." ; only allow one decimal point
SaveRegs
invoke CallWindowProc, lpfnDecProc, hWin, WM_GETTEXT, lengthof cBuffer, addr cBuffer
mov ecx, lengthof cBuffer ; byte count in rcx
lea rsi, cBuffer ; address in rsi
@xxx:
lodsb ; load byte into al
cmp al, "." ; if decimal point already in Buffer
jne @xx1
.return 0 ; throw it away
@xx1:
dec rcx
cmp rcx, 0
jne @xxx
RestoreRegs
.if eax } 0
.return 0
.endif
jmp accept
.endif
.if wParam { "0"
.return 0
.endif
.if wParam } "9"
.return 0
.endif
.elseif uMsg == WM_KEYUP
.if wParam == VK_RETURN
invoke SendMessage, hWnd, WM_COMMAND, 201, 0
.return 0
.endif
.endif
accept:
invoke CallWindowProc,lpfnDecProc,hWin,uMsg,wParam,lParam
ret
DecProc endp
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
EditProc proc hWin:QWORD,uMsg:QWORD,wParam:QWORD,lParam:QWORD
.if uMsg == WM_KEYUP
.if wParam == VK_RETURN
invoke SendMessage, hWnd, WM_COMMAND, 201, 0
.return 0
.endif
.endif
accept:
invoke CallWindowProc,lpfnEditProc,hWin,uMsg,wParam,lParam
ret
EditProc endp
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
list proc instance:QWORD,parent:QWORD,topx:QWORD, \
topy:QWORD,wid:QWORD,hgt:QWORD,idnum:QWORD
LOCAL hklist :QWORD
invoke CreateWindowEx,WS_EX_LEFT,"LISTBOX",0, \
WS_CHILD or WS_VISIBLE or WS_EX_RIGHTSCROLLBAR or WS_VSCROLL or \
LBS_HASSTRINGS or LBS_NOTIFY or WS_TABSTOP or WS_BORDER or LBS_NOINTEGRALHEIGHT or WS_CLIPSIBLINGS,\
topx,topy,wid,hgt,parent,idnum,instance,0
mov hklist, rax
invoke SendMessage, hklist, WM_SETFONT, rv(GetStockObject, ANSI_VAR_FONT), 0
mov rax, hklist
ret
list endp
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
target_combo proc instance:QWORD,parent:QWORD,topx:QWORD, \
topy:QWORD,wid:QWORD,hgt:QWORD,idnum:QWORD
invoke CreateWindowEx,WS_EX_LEFT,"COMBOBOX",0, WS_CHILD or WS_VISIBLE or \
CBS_HASSTRINGS or WS_VSCROLL or CBS_DROPDOWN or \
CBS_NOINTEGRALHEIGHT or WS_TABSTOP, \
topx,topy,wid,hgt,parent,idnum,instance,0
ret
target_combo endp
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
select_combo proc instance:QWORD,parent:QWORD,topx:QWORD, \
topy:QWORD,wid:QWORD,hgt:QWORD,idnum:QWORD
invoke CreateWindowEx,WS_EX_LEFT,"COMBOBOX",0, WS_CHILD or WS_VISIBLE or \
CBS_HASSTRINGS or WS_VSCROLL or CBS_DROPDOWNLIST or \
CBS_NOINTEGRALHEIGHT or CBS_DISABLENOSCROLL , \
topx,topy,wid,hgt,parent,idnum,instance,0
ret
select_combo endp
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
staticr proc instance:QWORD,hparent:QWORD,text:QWORD,topx:QWORD,topy:QWORD,wid:QWORD,hgt:QWORD
invoke CreateWindowEx,WS_EX_RIGHT,"STATIC",text, \
WS_CHILD or WS_VISIBLE,\
topx,topy,wid,hgt,hparent,-1,instance,0
ret
staticr endp
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
static proc instance:QWORD,hparent:QWORD,text:QWORD,topx:QWORD,topy:QWORD,wid:QWORD,hgt:QWORD
invoke CreateWindowEx,WS_EX_LEFT,"STATIC",text, \
WS_CHILD or WS_VISIBLE,\
topx,topy,wid,hgt,hparent,-1,instance,0
ret
static endp
static2 proc instance:QWORD,hparent:QWORD,text:QWORD,topx:QWORD,topy:QWORD,wid:QWORD,hgt:QWORD
invoke CreateWindowEx,WS_EX_LEFT,"STATIC",text, \
WS_CHILD or WS_VISIBLE or WS_CLIPSIBLINGS or SS_SIMPLE ,\
topx,topy,wid,hgt,hparent,-1,instance,0
ret
static2 endp
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
buttonp proc instance:QWORD,hparent:QWORD,text:QWORD,topx:QWORD,topy:QWORD,wid:QWORD,hgt:QWORD,idnum:QWORD
invoke CreateWindowEx,WS_EX_LEFT,"BUTTON",text, \
WS_CHILD or WS_VISIBLE or WS_TABSTOP or WS_CLIPSIBLINGS ,\
topx,topy,wid,hgt,hparent,idnum,instance,0
ret
buttonp endp
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
editboxl proc hparent:QWORD,instance:QWORD,text:QWORD,topx:QWORD,topy:QWORD,wid:QWORD,hgt:QWORD,idnum:QWORD
LOCAL hedit : QWORD
invoke CreateWindowEx,WS_EX_LEFT,"EDIT",text, \
WS_CHILD or WS_VISIBLE or WS_BORDER or ES_LEFT or WS_TABSTOP or ES_AUTOHSCROLL,\
topx,topy,wid,hgt,hparent,idnum,instance,0
mov hedit, rax
invoke SendMessage, hedit, EM_SETLIMITTEXT, 256, 0
mov rax, hedit
ret
editboxl endp
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
editboxc proc hparent:QWORD,instance:QWORD,text:QWORD,topx:QWORD,topy:QWORD,wid:QWORD,hgt:QWORD,idnum:QWORD
invoke CreateWindowEx,WS_EX_LEFT,"EDIT",text, \
WS_CHILD or WS_VISIBLE or WS_BORDER or ES_CENTER or WS_TABSTOP,\
topx,topy,wid,hgt,hparent,idnum,instance,0
ret
editboxc endp
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
m2m macro a1, a2
mov rax, a2
mov a1, rax
endm
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
RRegistroOption macro clave, opcion, defecto
mov szBuff, 0
invoke GetPrivateProfileString, addr clave, addr opcion, addr defecto,\
addr szBuff, sizeof szBuff, addr CurDir
endm
RRegSize macro clave, opcion, defecto, variable
RRegistroOption clave, opcion, defecto
invoke atou_ex, addr szBuff
mov &variable, rax
endm
RRegEdit macro clave, opcion, defecto, edit
RRegistroOption clave, opcion, defecto
invoke SendMessage, edit, WM_SETTEXT, 0, addr szBuff
endm
RRegMode macro clave, opcion, defecto, combo
RRegistroOption clave, opcion, defecto
invoke atou_ex, addr szBuff
invoke SendMessage, combo, CB_SETCURSEL, rax, 0
endm
WRegistroOption macro clave, opcion
invoke WritePrivateProfileString, addr clave, addr opcion, r14, r15
endm
WRegSize macro clave, opcion, dato
invoke WritePrivateProfileString, addr clave, addr opcion, str$(dato), r15
endm
WRegEdit macro clave, opcion, edit
invoke SendMessage, edit, WM_GETTEXT, 256, r14
WRegistroOption clave, opcion
endm
WRegMode macro clave, opcion, combo
invoke SendMessage, combo, CB_GETCURSEL, 0, 0
WRegSize clave, opcion, rax
endm
RRegAssoc macro clave, opcion, defecto, namebuf
mov namebuf, 0
invoke GetPrivateProfileString, ADDR clave, addr opcion, addr defecto,\
addr namebuf, sizeof namebuf, addr CurDir
endm
WRegAssoc macro clave, opcion, namebuf
invoke WritePrivateProfileString, addr clave, addr opcion, addr namebuf, addr CurDir
endm
fill_cb macro hcombo:req, sel1:req, args:VARARG
count = 0
FOR item, <args>
invoke SendMessage, &hcombo, CB_ADDSTRING, count, <item>
count = count + 1
ENDM
invoke SendMessage, &hcombo, CB_SETCURSEL, &sel1, 0
endm
; いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
SaveTargets proc
USING rbx, r12, r13
ANNOTATION prv: r15 ; in app_run
LOCAL opcion[8]:byte
LOCAL sCreation[32]:byte
SaveRegs
mov r12, 0
mov rbx, TheTargets
loop1i:
.if rbx {} 0
mov opcion, 0
invoke szappend, addr opcion, "tgt", 0
mov r13, rax
invoke szappend, addr opcion, str$(r12), r13
mov szBuff, 0
mov r8, [rbx].TheTarget.thestring
invoke szappend, addr szBuff, r8, 0
mov r13, rax
fn szappend, addr szBuff, ";", r13
mov r13, rax
mov r8, [rbx].TheTarget.thecreation
invoke szappend, addr szBuff, sstr$(r8), r13
mov r13, rax
invoke szappend, addr szBuff, ";", r13
mov r13, rax
mov r8, [rbx].TheTarget.theuse
invoke szappend, addr szBuff, str$(r8), r13
invoke WritePrivateProfileString, addr key3, addr opcion, addr szBuff, r15
mov rbx, [rbx].TheTarget.thenext
add r12, 1
jmp loop1i
.endif
loop1f:
ret
SaveTargets endp
; --------------------------------------------------------------------------------------------------
RetrieveTargets proc
USING r12, r13
LOCAL opciont[8]:byte
SaveRegs
mov r12, 0
mov TheTargets, 0
loop1i:
mov opciont, 0
invoke szappend, addr opciont, "tgt", 0
mov r13, rax
invoke szappend, addr opciont, str$(r12), r13
RRegistroOption key3, opciont, empty
invoke szCheckTarget, addr szBuff
.if rax == 0
jmp loop1f
.endif
invoke RetrieveTarget, addr szBuff
invoke SendMessage, hedit1, CB_INSERTSTRING, r12, addr szBuff
add r12, 1
jmp loop1i
loop1f:
RestoreRegs
ret
RetrieveTargets endp
; --------------------------------------------------------------------------------------------------
LoadTargets proc
USING rbx
SaveRegs
mov rbx, TheTargets
loop1i:
.if rbx {} 0
mov r9, [rbx].TheTarget.thestring
invoke SendMessage, hedit1, CB_ADDSTRING, 0, r9
mov rbx, [rbx].TheTarget.thenext
jmp loop1i
.endif
loop1f:
RestoreRegs
ret
LoadTargets endp
; --------------------------------------------------------------------------------------------------
ShowTargets proc
USING rbx
SaveRegs
mov rbx, TheTargets
loop1i:
.if rbx == 0
jmp loop1f
.endif
mov r9, [rbx].TheTarget.thestring
conout r9, lf
mov rbx, [rbx].TheTarget.thenext
jmp loop1i
loop1f:
RestoreRegs
ret
ShowTargets endp
;***************************************************************************************************
RetrieveAssoc proc
RRegAssoc key4, opt001, default_editor, EditorBat
RRegAssoc key4, opt002, default_editor, EditorCmd
RRegAssoc key4, opt003, default_editor, EditorJs
ret
RetrieveAssoc endp
SaveAssoc proc
WRegAssoc key4, opt001, EditorBat
WRegAssoc key4, opt002, EditorCmd
WRegAssoc key4, opt003, EditorJs
ret
SaveAssoc endp
;***************************************************************************************************
setsortingorder proc; sort1:qword
local sort1:qword
mov sort1, rcx
.switch sort1
.case 0
mov sort_asc, 0
.case 1
mov sort_asc, 1
.case 2
mov sort_asc, 1
.case 3
mov sort_asc, 0
.case 4
mov sort_asc, 0
.case 5
mov sort_asc, 1
.endsw
mov rax, sort1
shr rax, 1
mov sort_kind, rax
ret
setsortingorder endp