-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCopyToAsm.asm
2415 lines (2030 loc) · 84.9 KB
/
CopyToAsm.asm
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
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;=====================================================================================
; x64dbg plugin SDK for Masm - fearless 2015
;
; CopyToAsm.asm
;
;-------------------------------------------------------------------------------------
.686
.MMX
.XMM
.x64
option casemap : none
option win64 : 11
option frame : auto
option stackbase : rsp
_WIN64 EQU 1
WINVER equ 0501h
;DEBUG64 EQU 1
;
;IFDEF DEBUG64
; PRESERVEXMMREGS equ 1
; includelib \JWasm\lib\x64\Debug64.lib
; DBG64LIB equ 1
; DEBUGEXE textequ <'\Jwasm\bin\DbgWin.exe'>
; include \JWasm\include\debug64.inc
; .DATA
; RDBG_DbgWin DB DEBUGEXE,0
; .CODE
;ENDIF
Include x64dbgpluginsdk.inc ; Main x64dbg Plugin SDK for your program, and prototypes for the main exports
include x64dbgpluginsdk_x64.inc
includelib x64dbgpluginsdk_x64.lib
Include CopyToAsm.inc ; plugin's include file
Include CopyToAsmIni.asm
Include CopyToAsmOptions.asm
pluginit PROTO :QWORD ; Required prototype and export for x64dbg plugin SDK
plugstop PROTO ; Required prototype and export for x64dbg plugin SDK
plugsetup PROTO :QWORD ; Required prototype and export for x64dbg plugin SDK
;=====================================================================================
.CONST
PLUGIN_VERSION EQU 1
.DATA
align 01
PLUGIN_NAME DB "CopyToAsm x64",0
.DATA?
;-------------------------------------------------------------------------------------
; GLOBAL Plugin SDK variables
;-------------------------------------------------------------------------------------
align 08
PUBLIC pluginHandle
PUBLIC hwndDlg
PUBLIC hMenu
PUBLIC hMenuDisasm
PUBLIC hMenuDump
PUBLIC hMenuStack
pluginHandle DD ?
hwndDlg DQ ?
hMenu DD ?
hMenuDisasm DD ?
hMenuDump DD ?
hMenuStack DD ?
hMenuOptions DD ?
;-------------------------------------------------------------------------------------
.CODE
;=====================================================================================
; Main entry function for a DLL file - required.
;-------------------------------------------------------------------------------------
DllMain PROC hInst:HINSTANCE, fdwReason:DWORD, lpvReserved:LPVOID
.IF fdwReason == DLL_PROCESS_ATTACH
mov rax, hInst
mov hInstance, rax
.ENDIF
mov rax,TRUE
ret
DllMain Endp
;=====================================================================================
; pluginit - Called by debugger when plugin.dp64 is loaded - needs to be EXPORTED
;
; Arguments: initStruct - a pointer to a PLUG_INITSTRUCT structure
;
; Notes: you must fill in the pluginVersion, sdkVersion and pluginName members.
; The pluginHandle is obtained from the same structure - it may be needed in
; other function calls.
;
; you can call your own setup routine from within this function to setup
; menus and commands, and pass the initStruct parameter to this function.
;
;-------------------------------------------------------------------------------------
pluginit PROC FRAME USES RBX initStruct:QWORD
mov rbx, initStruct
; Fill in required information of initStruct, which is a pointer to a PLUG_INITSTRUCT structure
mov eax, PLUGIN_VERSION
mov [rbx].PLUG_INITSTRUCT.pluginVersion, eax
mov eax, PLUG_SDKVERSION
mov [rbx].PLUG_INITSTRUCT.sdkVersion, eax
Invoke lstrcpy, Addr [rbx].PLUG_INITSTRUCT.pluginName, Addr PLUGIN_NAME
mov rbx, initStruct
mov eax, [rbx].PLUG_INITSTRUCT.pluginHandle
mov pluginHandle, eax
; Do any other initialization here
; Construct plugin's .ini file from module filename
Invoke GetModuleFileName, 0, Addr szModuleFilename, SIZEOF szModuleFilename
Invoke GetModuleFileName, hInstance, Addr CopyToAsmIni, SIZEOF CopyToAsmIni
Invoke szLen, Addr CopyToAsmIni
lea rbx, CopyToAsmIni
add rbx, rax
sub rbx, 4 ; move back past 'dp64' extention
mov byte ptr [rbx], 0 ; null so we can use lstrcat
Invoke lstrcat, rbx, Addr szIni ; add 'ini' to end of string instead
mov rax, TRUE
ret
pluginit endp
;=====================================================================================
; plugstop - Called by debugger when the plugin.dp64 is unloaded - needs to be EXPORTED
;
; Arguments: none
;
; Notes: perform cleanup operations here, clearing menus and other housekeeping
;
;-------------------------------------------------------------------------------------
plugstop PROC FRAME
; remove any menus, unregister any callbacks etc
Invoke _plugin_menuclear, hMenu
Invoke GuiAddLogMessage, Addr szCopyToAsmUnloaded
mov eax, TRUE
ret
plugstop endp
;=====================================================================================
; plugsetup - Called by debugger to initialize your plugins setup - needs to be EXPORTED
;
; Arguments: setupStruct - a pointer to a PLUG_SETUPSTRUCT structure
;
; Notes: setupStruct contains useful handles for use within x64dbg, mainly Qt
; menu handles (which are not supported with win32 api) and the main window
; handle with this information you can add your own menus and menu items
; to an existing menu, or one of the predefined supported right click
; context menus: hMenuDisam, hMenuDump & hMenuStack
;
; plugsetup is called after pluginit.
;-------------------------------------------------------------------------------------
plugsetup PROC FRAME USES RBX setupStruct:QWORD
LOCAL hIconData:ICONDATA
LOCAL hIconDataOptions:ICONDATA
mov rbx, setupStruct
; Extract handles from setupStruct which is a pointer to a PLUG_SETUPSTRUCT structure
mov rax, [rbx].PLUG_SETUPSTRUCT.hwndDlg
mov hwndDlg, rax
mov eax, [rbx].PLUG_SETUPSTRUCT.hMenu
mov hMenu, eax
mov eax, [rbx].PLUG_SETUPSTRUCT.hMenuDisasm
mov hMenuDisasm, eax
mov eax, [rbx].PLUG_SETUPSTRUCT.hMenuDump
mov hMenuDump, eax
mov eax, [rbx].PLUG_SETUPSTRUCT.hMenuStack
mov hMenuStack, eax
; Do any setup here: add menus, menu items, callback and commands etc
Invoke _plugin_menuaddentry, hMenu, MENU_COPYTOASM_CLPB1, Addr szCopyToAsmMenuClip
Invoke _plugin_menuaddentry, hMenu, MENU_COPYTOASM_REFV1, Addr szCopyToAsmMenuRefv
Invoke _plugin_menuaddseparator, hMenu
Invoke _plugin_menuadd, hMenu, Addr szCTACommentOptions
Invoke _plugin_menuaddentry, hMenu, MENU_COPYTOASM_OPTIONS1, Addr szCTACommentOptions
; mov hMenuOptions, eax
; ;Invoke _plugin_menuaddentry, hMenu, MENU_COPYTOASM_FMT1, Addr szCopyToAsmFormat
; Invoke _plugin_menuaddentry, hMenuOptions, MENU_CTARANGELABELS1, Addr szCTAOutsideRangeLabels
; Invoke _plugin_menuaddseparator, hMenuOptions
; Invoke _plugin_menuaddentry, hMenuOptions, MENU_CTACMTRANGE1, Addr szCTACmntOutsideRange
; Invoke _plugin_menuaddentry, hMenuOptions, MENU_CTACMTJMPDEST1, Addr szCTACmntJmpDest
; Invoke _plugin_menuaddentry, hMenuOptions, MENU_CTACMTCALLDEST1, Addr szCTACmntCallDest
; Invoke _plugin_menuaddseparator, hMenuOptions
; Invoke _plugin_menuaddentry, hMenuOptions, MENU_CTALBLUSEADDRESS1, Addr szCTALblsUseAddress
; Invoke _plugin_menuaddentry, hMenuOptions, MENU_CTALBLUSELABEL1, Addr szCTALblsUseLabel
; Invoke _plugin_menuaddseparator, hMenuOptions
; Invoke _plugin_menuaddentry, hMenuOptions, MENU_COPYTOASM_FMT1, Addr szCopyToAsmFormat
; Invoke CTALoadMenuIcon, IMG_MENU_OPTIONS, Addr hIconDataOptions
; Invoke _plugin_menuseticon, hMenuOptions, Addr hIconDataOptions
Invoke _plugin_menuaddentry, hMenuDisasm, MENU_COPYTOASM_CLPB2, Addr szCopyToAsmMenuClip
Invoke _plugin_menuaddentry, hMenuDisasm, MENU_COPYTOASM_REFV2, Addr szCopyToAsmMenuRefv
Invoke _plugin_menuaddseparator, hMenuDisasm
Invoke _plugin_menuaddentry, hMenuDisasm, MENU_COPYTOASM_OPTIONS2, Addr szCTACommentOptions
; Invoke _plugin_menuadd, hMenuDisasm, Addr szCTACommentOptions
; mov hMenuOptions, eax
; ;Invoke _plugin_menuaddentry, hMenuDisasm, MENU_COPYTOASM_FMT2, Addr szCopyToAsmFormat
; Invoke _plugin_menuaddentry, hMenuOptions, MENU_CTARANGELABELS2, Addr szCTAOutsideRangeLabels
; Invoke _plugin_menuaddseparator, hMenuOptions
; Invoke _plugin_menuaddentry, hMenuOptions, MENU_CTACMTRANGE2, Addr szCTACmntOutsideRange
; Invoke _plugin_menuaddentry, hMenuOptions, MENU_CTACMTJMPDEST2, Addr szCTACmntJmpDest
; Invoke _plugin_menuaddentry, hMenuOptions, MENU_CTACMTCALLDEST2, Addr szCTACmntCallDest
; Invoke _plugin_menuaddseparator, hMenuOptions
; Invoke _plugin_menuaddentry, hMenuOptions, MENU_CTALBLUSEADDRESS2, Addr szCTALblsUseAddress
; Invoke _plugin_menuaddentry, hMenuOptions, MENU_CTALBLUSELABEL2, Addr szCTALblsUseLabel
; Invoke _plugin_menuaddseparator, hMenuOptions
; Invoke _plugin_menuaddentry, hMenuOptions, MENU_COPYTOASM_FMT2, Addr szCopyToAsmFormat
; Invoke _plugin_menuseticon, hMenuOptions, Addr hIconDataOptions
Invoke CTALoadMenuIcon, IMG_COPYTOASM_MAIN, Addr hIconData
.IF rax == TRUE
Invoke _plugin_menuseticon, hMenu, Addr hIconData
Invoke _plugin_menuseticon, hMenuDisasm, Addr hIconData
.ENDIF
Invoke CTALoadMenuIcon, IMG_COPYTOASM_CLPB, Addr hIconData
.IF rax == TRUE
Invoke _plugin_menuentryseticon, pluginHandle, MENU_COPYTOASM_CLPB1, Addr hIconData
Invoke _plugin_menuentryseticon, pluginHandle, MENU_COPYTOASM_CLPB2, Addr hIconData
.ENDIF
Invoke CTALoadMenuIcon, IMG_COPYTOASM_REFV, Addr hIconData
.IF rax == TRUE
Invoke _plugin_menuentryseticon, pluginHandle, MENU_COPYTOASM_REFV1, Addr hIconData
Invoke _plugin_menuentryseticon, pluginHandle, MENU_COPYTOASM_REFV2, Addr hIconData
.ENDIF
Invoke CTALoadMenuIcon, IMG_MENU_OPTIONS, Addr hIconDataOptions
.IF rax == TRUE
Invoke _plugin_menuentryseticon, pluginHandle, MENU_COPYTOASM_OPTIONS1, Addr hIconDataOptions
Invoke _plugin_menuentryseticon, pluginHandle, MENU_COPYTOASM_OPTIONS2, Addr hIconDataOptions
.ENDIF
;Invoke CTALoadMenuIcon, IMG_MENU_CHECK, Addr hImgCheck
;Invoke CTALoadMenuIcon, IMG_MENU_NOCHECK, Addr hImgNoCheck
Invoke IniGetOutsideRangeLabels
mov g_OutsideRangeLabels, rax
; .IF rax == 1
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTARANGELABELS1, Addr hImgCheck
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTARANGELABELS2, Addr hImgCheck
; .ELSE
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTARANGELABELS1, Addr hImgNoCheck
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTARANGELABELS2, Addr hImgNoCheck
; .ENDIF
Invoke IniGetCmntOutsideRange
mov g_CmntOutsideRange, rax
; .IF rax == 1
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTRANGE1, Addr hImgCheck
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTRANGE2, Addr hImgCheck
; .ELSE
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTRANGE1, Addr hImgNoCheck
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTRANGE2, Addr hImgNoCheck
; .ENDIF
Invoke IniGetCmntJumpDest
mov g_CmntJumpDest, rax
; .IF rax == 1
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTJMPDEST1, Addr hImgCheck
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTJMPDEST2, Addr hImgCheck
; .ELSE
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTJMPDEST1, Addr hImgNoCheck
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTJMPDEST2, Addr hImgNoCheck
; .ENDIF
Invoke IniGetCmntCallDest
mov g_CmntCallDest, rax
; .IF rax == 1
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTCALLDEST1, Addr hImgCheck
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTCALLDEST2, Addr hImgCheck
; .ELSE
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTCALLDEST1, Addr hImgNoCheck
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTCALLDEST2, Addr hImgNoCheck
; .ENDIF
Invoke IniGetLblUseAddress
mov g_LblUseAddress, rax
; .IF rax == 1
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSEADDRESS1, Addr hImgCheck
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSEADDRESS2, Addr hImgCheck
; .ELSE
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSEADDRESS1, Addr hImgNoCheck
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSEADDRESS2, Addr hImgNoCheck
; .ENDIF
Invoke IniGetLblUseLabel
mov g_LblUseLabel, rax
; .IF rax == 1
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSELABEL1, Addr hImgCheck
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSELABEL2, Addr hImgCheck
; .ELSE
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSELABEL1, Addr hImgNoCheck
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSELABEL2, Addr hImgNoCheck
; .ENDIF
Invoke IniGetFormatType
mov g_FormatType, rax
; .IF rax == 1
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_COPYTOASM_FMT1, Addr hImgCheck
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_COPYTOASM_FMT2, Addr hImgCheck
; .ELSE
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_COPYTOASM_FMT1, Addr hImgNoCheck
; Invoke _plugin_menuentryseticon, pluginHandle, MENU_COPYTOASM_FMT2, Addr hImgNoCheck
; .ENDIF
Invoke IniGetLblUsex64dbgLabels
mov g_LblUsex64dbgLabels, rax
Invoke _plugin_registercommand, pluginHandle, Addr szCTACLongCommand, Addr cbCTAC, TRUE
Invoke _plugin_registercommand, pluginHandle, Addr szCTACCommand, Addr cbCTAC, TRUE
Invoke _plugin_registercommand, pluginHandle, Addr szCTARLongCommand, Addr cbCTAR, TRUE
Invoke _plugin_registercommand, pluginHandle, Addr szCTARCommand, Addr cbCTAR, TRUE
Invoke GuiAddLogMessage, Addr szCopyToAsmInfo
Invoke GuiGetWindowHandle
mov hwndDlg, rax
ret
plugsetup endp
;=====================================================================================
; CBMENUENTRY - Called by debugger when a menu item is clicked - needs to be EXPORTED
;
; Arguments: cbType
; cbInfo - a pointer to a PLUG_CB_MENUENTRY structure. The hEntry contains
; the resource id of menu item identifiers
;
; Notes: hEntry can be used to determine if the user has clicked on your plugins
; menu item(s) and to do something in response to it.
; Needs to be PROC C type procedure call to be compatible with debugger
;-------------------------------------------------------------------------------------
CBMENUENTRY PROC FRAME USES RBX cbType:QWORD, cbInfo:QWORD
mov rbx, cbInfo
xor rax, rax
mov eax, [rbx].PLUG_CB_MENUENTRY.hEntry
.IF eax == MENU_COPYTOASM_CLPB1 || eax == MENU_COPYTOASM_CLPB2
Invoke DbgIsDebugging
.IF rax == FALSE
Invoke GuiAddStatusBarMessage, Addr szDebuggingRequired
Invoke GuiAddLogMessage, Addr szDebuggingRequired
.ELSE
Invoke DoCopyToAsm, 0 ; clipboard
.ENDIF
.ELSEIF eax == MENU_COPYTOASM_REFV1 || eax == MENU_COPYTOASM_REFV2
Invoke DbgIsDebugging
.IF rax == FALSE
Invoke GuiAddStatusBarMessage, Addr szDebuggingRequired
Invoke GuiAddLogMessage, Addr szDebuggingRequired
.ELSE
Invoke DoCopyToAsm, 1 ; refview
.ENDIF
.ELSEIF eax == MENU_COPYTOASM_FMT1 || eax == MENU_COPYTOASM_FMT2
mov rax, g_FormatType
.IF rax == 1
mov g_FormatType, 0
Invoke IniSetFormatType, 0
Invoke _plugin_menuentryseticon, pluginHandle, MENU_COPYTOASM_FMT1, Addr hImgNoCheck
Invoke _plugin_menuentryseticon, pluginHandle, MENU_COPYTOASM_FMT2, Addr hImgNoCheck
.ELSE
mov g_FormatType, 1
Invoke IniSetFormatType, 1
Invoke _plugin_menuentryseticon, pluginHandle, MENU_COPYTOASM_FMT1, Addr hImgCheck
Invoke _plugin_menuentryseticon, pluginHandle, MENU_COPYTOASM_FMT2, Addr hImgCheck
.ENDIF
.ELSEIF eax == MENU_CTARANGELABELS1 || eax == MENU_CTARANGELABELS2
mov rax, g_OutsideRangeLabels
.IF rax == 1
mov g_OutsideRangeLabels, 0
Invoke IniSetOutsideRangeLabels, 0
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTARANGELABELS1, Addr hImgNoCheck
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTARANGELABELS2, Addr hImgNoCheck
.ELSE
mov g_OutsideRangeLabels, 1
Invoke IniSetOutsideRangeLabels, 1
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTARANGELABELS1, Addr hImgCheck
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTARANGELABELS2, Addr hImgCheck
.ENDIF
.ELSEIF eax == MENU_CTACMTRANGE1 || eax == MENU_CTACMTRANGE2
mov rax, g_CmntOutsideRange
.IF rax == 1
mov g_CmntOutsideRange, 0
Invoke IniSetCmntOutsideRange, 0
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTRANGE1, Addr hImgNoCheck
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTRANGE2, Addr hImgNoCheck
.ELSE
mov g_CmntOutsideRange, 1
Invoke IniSetCmntOutsideRange, 1
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTRANGE1, Addr hImgCheck
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTRANGE2, Addr hImgCheck
.ENDIF
.ELSEIF eax == MENU_CTACMTJMPDEST1 || eax == MENU_CTACMTJMPDEST2
mov rax, g_CmntJumpDest
.IF rax == 1
mov g_CmntJumpDest, 0
Invoke IniSetCmntJumpDest, 0
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTJMPDEST1, Addr hImgNoCheck
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTJMPDEST2, Addr hImgNoCheck
.ELSE
mov g_CmntJumpDest, 1
Invoke IniSetCmntJumpDest, 1
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTJMPDEST1, Addr hImgCheck
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTJMPDEST2, Addr hImgCheck
.ENDIF
.ELSEIF eax == MENU_CTACMTCALLDEST1 || eax == MENU_CTACMTCALLDEST2
mov rax, g_CmntCallDest
.IF rax == 1
mov g_CmntCallDest, 0
Invoke IniSetCmntCallDest, 0
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTCALLDEST1, Addr hImgNoCheck
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTCALLDEST2, Addr hImgNoCheck
.ELSE
mov g_CmntCallDest, 1
Invoke IniSetCmntCallDest, 1
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTCALLDEST1, Addr hImgCheck
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTACMTCALLDEST2, Addr hImgCheck
.ENDIF
.ELSEIF eax == MENU_CTALBLUSEADDRESS1 || eax == MENU_CTALBLUSEADDRESS2
mov rax, g_LblUseAddress
.IF rax == 1
mov g_LblUseAddress, 0
Invoke IniSetLblUseAddress, 0
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSEADDRESS1, Addr hImgNoCheck
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSEADDRESS2, Addr hImgNoCheck
.ELSE
mov g_LblUseAddress, 1
Invoke IniSetLblUseAddress, 1
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSEADDRESS1, Addr hImgCheck
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSEADDRESS2, Addr hImgCheck
.ENDIF
.ELSEIF eax == MENU_CTALBLUSELABEL1 || eax == MENU_CTALBLUSELABEL2
mov rax, g_LblUseLabel
.IF rax == 1
mov g_LblUseLabel, 0
Invoke IniSetLblUseLabel, 0
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSELABEL1, Addr hImgNoCheck
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSELABEL2, Addr hImgNoCheck
.ELSE
mov g_LblUseLabel, 1
Invoke IniSetLblUseLabel, 1
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSELABEL1, Addr hImgCheck
Invoke _plugin_menuentryseticon, pluginHandle, MENU_CTALBLUSELABEL2, Addr hImgCheck
.ENDIF
.ELSEIF eax == MENU_COPYTOASM_OPTIONS1 || eax == MENU_COPYTOASM_OPTIONS2
Invoke DialogBoxParam, hInstance, IDD_OPTIONSDLG, hwndDlg, Addr OptionsDlgProc, NULL
.ENDIF
mov rax, TRUE
ret
CBMENUENTRY endp
;=====================================================================================
; CTALoadMenuIcon - Loads RT_RCDATA png resource and assigns it to ICONDATA
; Returns TRUE in eax if succesful or FALSE otherwise.
;-------------------------------------------------------------------------------------
CTALoadMenuIcon PROC FRAME USES RBX dqImageResourceID:QWORD, lpIconData:QWORD
LOCAL hRes:QWORD
; Load image for our menu item
Invoke FindResource, hInstance, dqImageResourceID, RT_RCDATA ; load png image as raw data
.IF eax != NULL
mov hRes, rax
Invoke SizeofResource, hInstance, hRes
.IF rax != 0
mov rbx, lpIconData
mov [rbx].ICONDATA.size_, rax
Invoke LoadResource, hInstance, hRes
.IF rax != NULL
Invoke LockResource, rax
.IF rax != NULL
mov rbx, lpIconData
mov [rbx].ICONDATA.data, rax
mov rax, TRUE
.ELSE
;PrintText 'Failed to lock resource'
mov rax, FALSE
.ENDIF
.ELSE
;PrintText 'Failed to load resource'
mov rax, FALSE
.ENDIF
.ELSE
;PrintText 'Failed to get resource size'
mov rax, FALSE
.ENDIF
.ELSE
;PrintText 'Failed to find resource'
mov rax, FALSE
.ENDIF
ret
CTALoadMenuIcon ENDP
;-------------------------------------------------------------------------------------
; Copies selected disassembly range to clipboard and formats as masm style code
; fixes jmps and labels relative to each other, removes segments and 0x from instructions
;-------------------------------------------------------------------------------------
DoCopyToAsm PROC FRAME USES RBX RCX qwOutput:QWORD
LOCAL bii:BASIC_INSTRUCTION_INFO ; basic
LOCAL cbii:BASIC_INSTRUCTION_INFO ; call destination
LOCAL sel:SELECTIONDATA
LOCAL sellength:QWORD
LOCAL qwStartAddress:QWORD
LOCAL qwFinishAddress:QWORD
LOCAL qwCurrentAddress:QWORD
LOCAL JmpDestination:QWORD
LOCAL CallDestination:QWORD
LOCAL ptrClipboardData:QWORD
LOCAL LenClipData:QWORD
LOCAL pClipData:QWORD
LOCAL hClipData:QWORD
LOCAL bOutsideRange:QWORD
LOCAL qwCTALIndex:QWORD
Invoke DbgIsDebugging
.IF rax == FALSE
Invoke GuiAddLogMessage, Addr szDebuggingRequired
ret
.ENDIF
Invoke GuiAddStatusBarMessage, Addr szStartCopyToAsm
;----------------------------------
; Get selection information
;----------------------------------
Invoke GuiSelectionGet, GUI_DISASSEMBLY, Addr sel
mov rax, sel.finish
mov qwFinishAddress, rax
mov rbx, sel.start
mov qwStartAddress, rbx
sub rax, rbx
mov sellength, rax
mov qwCTALIndex, 0
;----------------------------------
; Get some info for user
;----------------------------------
Invoke ModNameFromAddr, sel.start, Addr szModuleName, TRUE
Invoke ModNameFromAddr, sel.start, Addr szModuleNameStrip, FALSE
Invoke szCatStr, Addr szModuleNameStrip, Addr szDot
Invoke ModBaseFromAddr, sel.start
mov ModBase, rax
;----------------------------------
; 1st pass build jmp destination array
;----------------------------------
Invoke CTABuildJmpTable, qwStartAddress, qwFinishAddress
.IF rax == FALSE
ret
.ENDIF
;----------------------------------
; 2nd pass build call destination array
;----------------------------------
Invoke CTABuildCallTable, qwStartAddress, qwFinishAddress
.IF rax == FALSE
ret
.ENDIF
.IF qwOutput == 0 ; clipboard
;----------------------------------
; Alloc space for clipboard data
;----------------------------------
.IF CLIPDATASIZE != 0
Invoke szLen, Addr szModuleName
add rax, 64d; "; Source: "+CRLF + CRLF + (base 0x12345678 - 12345678)
add CLIPDATASIZE, rax
Invoke GlobalAlloc, GMEM_FIXED + GMEM_ZEROINIT, CLIPDATASIZE
.IF rax == NULL
Invoke GuiAddStatusBarMessage, Addr szErrorClipboardData
mov rax, FALSE
ret
.ENDIF
mov ptrClipboardData, rax
Invoke OpenClipboard, 0
.IF rax == 0
Invoke GlobalFree, ptrClipboardData
Invoke GuiAddStatusBarMessage, Addr szErrorClipboardData
mov rax, FALSE
ret
.ENDIF
Invoke EmptyClipboard
.ELSE
Invoke GuiAddStatusBarMessage, Addr szErrorClipboardData
.ENDIF
;----------------------------------
; Start : Module Name and Base
;----------------------------------
Invoke szCatStr, ptrClipboardData, Addr szModuleSource
Invoke szCatStr, ptrClipboardData, Addr szModuleName
Invoke qw2hex, ModBase, Addr szValueString
Invoke szCatStr, ptrClipboardData, Addr szModBase
Invoke szCatStr, ptrClipboardData, Addr szValueString
Invoke utoa_ex, ModBase, Addr szValueString, 10, FALSE, TRUE
Invoke szCatStr, ptrClipboardData, Addr szModBaseHex
Invoke szCatStr, ptrClipboardData, Addr szValueString
Invoke szCatStr, ptrClipboardData, Addr szRightBracket
Invoke szCatStr, ptrClipboardData, Addr szCRLF
Invoke szCatStr, ptrClipboardData, Addr szCRLF
.IF g_OutsideRangeLabels == 1
;----------------------------------
; Labels Before
;----------------------------------
Invoke CTAOutputLabelsOutsideRangeBefore, qwStartAddress, ptrClipboardData
Invoke CTAOutputCallLabelsOutsideRangeBefore, qwStartAddress, ptrClipboardData
.ENDIF
;----------------------------------
; Start Information
;----------------------------------
Invoke szCatStr, ptrClipboardData, Addr szCommentSelStart
Invoke qw2hex, qwStartAddress, Addr szValueString
Invoke szCatStr, ptrClipboardData, Addr szHex
Invoke szCatStr, ptrClipboardData, Addr szValueString
;Invoke szCatStr, ptrClipboardData, Addr szOffsetLeftBracket
;Invoke utoa_ex, qwStartAddress, Addr szValueString, 10, FALSE, TRUE
;Invoke szCatStr, ptrClipboardData, Addr szValueString
;Invoke szCatStr, ptrClipboardData, Addr szRightBracket
Invoke szCatStr, ptrClipboardData, Addr szCRLF
.ELSE ; output to reference view
Invoke CTA_AddColumnsToRefView, qwStartAddress, qwFinishAddress
.IF g_OutsideRangeLabels == 1
;----------------------------------
; Labels Before
;----------------------------------
Invoke CTARefViewLabelsOutsideRangeBefore, qwStartAddress, qwCTALIndex
mov qwCTALIndex, rax
Invoke CTARefViewCallLabelsOutsideRangeBefore, qwStartAddress, qwCTALIndex
mov qwCTALIndex, rax
.ENDIF
.ENDIF
Invoke szCopy, Addr szNull, Addr szLastLabelText
;----------------------------------
; Start main loop processing selection
;----------------------------------
mov rax, qwStartAddress
mov qwCurrentAddress, rax
.WHILE rax <= qwFinishAddress
; Use x64dbg label if present?
.IF g_LblUsex64dbgLabels == TRUE
Invoke DbgGetLabelAt, qwCurrentAddress, SEG_DEFAULT, Addr szLabelText
.IF rax == TRUE
Invoke szLen, Addr szLabelText
.IF rax != 0
;PrintString szLabelText
Invoke szCatStr, Addr szLabelText, Addr szColon
.IF qwOutput == 0 ; output to clipboard
Invoke szCatStr, ptrClipboardData, Addr szCRLF
Invoke szCatStr, ptrClipboardData, Addr szLabelText
Invoke szCatStr, ptrClipboardData, Addr szCRLF
.ELSE ; output to reference view
Invoke CTA_AddRowToRefView, qwCTALIndex, Addr szLabelText
inc qwCTALIndex
.ENDIF
.ENDIF
.ENDIF
.ENDIF
; Check instruction is in our jmp table as a destination for a jump, if so insert a label
Invoke CTAAddressInJmpTable, qwCurrentAddress
.IF rax != 0
Invoke CTALabelFromJmpEntry, rax, qwCurrentAddress, Addr szLabelX
.IF qwOutput == 0 ; output to clipboard
Invoke szCatStr, ptrClipboardData, Addr szCRLF
Invoke szCatStr, ptrClipboardData, Addr szLabelX
Invoke szCatStr, ptrClipboardData, Addr szCRLF
.ELSE ; output to reference view
Invoke CTA_AddRowToRefView, qwCTALIndex, Addr szLabelX
inc qwCTALIndex
.ENDIF
.ENDIF
; Check instruction is in our call table as a destination for a call, if so insert a label
Invoke CTAAddressInCallTable, qwCurrentAddress
.IF rax != -1
Invoke CTALabelFromCallEntry, rax, Addr szLabelX
.IF qwOutput == 0 ; output to clipboard
Invoke szCatStr, ptrClipboardData, Addr szCRLF
Invoke szCatStr, ptrClipboardData, Addr szLabelX
Invoke szCatStr, ptrClipboardData, Addr szCRLF
.ELSE ; output to reference view
Invoke CTA_AddRowToRefView, qwCTALIndex, Addr szLabelX
inc qwCTALIndex
.ENDIF
.ENDIF
Invoke RtlZeroMemory, Addr bii, SIZEOF BASIC_INSTRUCTION_INFO
Invoke DbgDisasmFastAt, qwCurrentAddress, Addr bii
movzx rax, byte ptr bii.call_
movzx rbx, byte ptr bii.branch
.IF rax == 1 && rbx == 1 ; we have call statement
Invoke GuiGetDisassembly, qwCurrentAddress, Addr szDisasmText
mov rax, bii.address
mov CallDestination, rax
Invoke RtlZeroMemory, Addr cbii, SIZEOF BASIC_INSTRUCTION_INFO
Invoke DbgDisasmFastAt, CallDestination, Addr cbii
;mov rax, cbii.address
;.IF rax == 0
mov rax, bii.address
;.ENDIF
mov JmpDestination, rax
Invoke Strip_x64dbg_calls, Addr szDisasmText, Addr szCALLFunction
Invoke IsCallApiNameHexOnly, Addr szCALLFunction
.IF rax == FALSE
Invoke szCopy, Addr szCall, Addr szFormattedDisasmText
Invoke szCatStr, Addr szFormattedDisasmText, Addr szCALLFunction
; convert any 'call qword ptr [somehex]' type calls to appropriate hex values
Invoke ConvertHexValues, Addr szFormattedDisasmText, Addr szDisasmText, g_FormatType
Invoke szCopy, Addr szDisasmText, Addr szFormattedDisasmText
.ELSE
Invoke szCopy, Addr szCall, Addr szFormattedDisasmText
Invoke szCatStr, Addr szFormattedDisasmText, Addr szUnderscore
Invoke szCatStr, Addr szFormattedDisasmText, Addr szCALLFunction
.ENDIF
;Invoke szCopy, Addr szCall, Addr szFormattedDisasmText
;Invoke szCatStr, Addr szFormattedDisasmText, Addr szCALLFunction
;mov rax, bii.address
;PrintQWORD rax
;mov rax, cbii.address
;PrintQWORD rax
;movzx eax, byte ptr cbii.call_
;PrintDWORD eax
;movzx eax, byte ptr cbii.branch
;PrintDWORD eax
;movzx eax, byte ptr cbii.branch
mov rax, bii.address
.IF eax == 0 ; external function call
.ELSE ; internal function call
Invoke qw2hex, JmpDestination, Addr szValueString
.IF g_CmntOutsideRange == 1
mov rax, qwStartAddress
mov rbx, qwFinishAddress
.IF JmpDestination < rax || JmpDestination > rbx
Invoke szCatStr, Addr szFormattedDisasmText, Addr szCmnt
Invoke szCatStr, Addr szFormattedDisasmText, Addr szDestJmp
Invoke szCatStr, Addr szFormattedDisasmText, Addr szHex
Invoke szCatStr, Addr szFormattedDisasmText, Addr szValueString
Invoke szCatStr, Addr szFormattedDisasmText, Addr szCommentOutsideRange2
.ELSE
.IF g_CmntCallDest == 1
Invoke szCatStr, Addr szFormattedDisasmText, Addr szCmnt
Invoke szCatStr, Addr szFormattedDisasmText, Addr szDestJmp
Invoke szCatStr, Addr szFormattedDisasmText, Addr szHex
Invoke szCatStr, Addr szFormattedDisasmText, Addr szValueString
.ENDIF
.ENDIF
.ELSE
.IF g_CmntCallDest == 1
Invoke szCatStr, Addr szFormattedDisasmText, Addr szCmnt
Invoke szCatStr, Addr szFormattedDisasmText, Addr szDestJmp
Invoke szCatStr, Addr szFormattedDisasmText, Addr szHex
Invoke szCatStr, Addr szFormattedDisasmText, Addr szValueString
.ENDIF
.ENDIF
.ENDIF
.ELSEIF rax == 0 && rbx == 1 ; jumps
Invoke DbgGetBranchDestination, qwCurrentAddress
mov JmpDestination, rax
mov rax, qwStartAddress
mov rbx, qwFinishAddress
.IF JmpDestination < rax || JmpDestination > rbx
mov bOutsideRange, TRUE
.ELSE
mov bOutsideRange, FALSE
.ENDIF
Invoke GuiGetDisassembly, qwCurrentAddress, Addr szDisasmText
Invoke CTAAddressInJmpTable, JmpDestination
.IF rax != 0
Invoke CTAJmpLabelFromJmpEntry, rax, JmpDestination, bOutsideRange, Addr szDisasmText, Addr szFormattedDisasmText
.ELSE
;PrintText 'jmp destination not in CTAAddressInJmpTable!'
.ENDIF
.ELSE ; normal non jump or call instructions
Invoke GuiGetDisassembly, qwCurrentAddress, Addr szDisasmText
Invoke Strip_x64dbg_segments, Addr szDisasmText, Addr szFormattedDisasmText
Invoke Strip_x64dbg_anglebrackets, Addr szFormattedDisasmText, Addr szDisasmText
Invoke Strip_x64dbg_modulename, Addr szDisasmText, Addr szFormattedDisasmText
Invoke ConvertHexValues, Addr szFormattedDisasmText, Addr szDisasmText, g_FormatType
Invoke szCopy, Addr szDisasmText, Addr szFormattedDisasmText
.ENDIF
.IF qwOutput == 0 ; output to clipboard
Invoke szCatStr, ptrClipboardData, Addr szFormattedDisasmText
Invoke szCatStr, ptrClipboardData, Addr szCRLF
.ELSE ; output to reference view
Invoke CTA_AddRowToRefView, qwCTALIndex, Addr szFormattedDisasmText
.ENDIF
inc qwCTALIndex
mov eax, bii.size_
add qwCurrentAddress, rax
mov rax, qwCurrentAddress
.ENDW
;----------------------------------
; End main loop
;----------------------------------
.IF qwOutput == 0 ; output to clipboard
;----------------------------------
; Finish Information
;----------------------------------
Invoke szCatStr, ptrClipboardData, Addr szCommentSelFinish
Invoke qw2hex, qwFinishAddress, Addr szValueString
Invoke szCatStr, ptrClipboardData, Addr szHex
Invoke szCatStr, ptrClipboardData, Addr szValueString
;Invoke szCatStr, ptrClipboardData, Addr szOffsetLeftBracket
;Invoke utoa_ex, qwFinishAddress, Addr szValueString, 10, FALSE, TRUE
;Invoke szCatStr, ptrClipboardData, Addr szValueString
;Invoke szCatStr, ptrClipboardData, Addr szRightBracket
Invoke szCatStr, ptrClipboardData, Addr szCRLF
;Invoke szCatStr, ptrClipboardData, Addr szCRLF
.IF g_OutsideRangeLabels == 1
;----------------------------------
; Labels After
;----------------------------------
Invoke CTAOutputLabelsOutsideRangeAfter, qwFinishAddress, ptrClipboardData
Invoke CTAOutputCallLabelsOutsideRangeAfter, qwFinishAddress, ptrClipboardData
.ENDIF
.ELSE
.IF g_OutsideRangeLabels == 1
;----------------------------------
; Labels After
;----------------------------------
Invoke CTARefViewLabelsOutsideRangeAfter, qwFinishAddress, qwCTALIndex
mov qwCTALIndex, rax
Invoke CTARefViewCallLabelsOutsideRangeAfter, qwFinishAddress, qwCTALIndex
mov qwCTALIndex, rax
.ENDIF
.ENDIF
Invoke CTAClearJmpTable ; free jmp table
Invoke CTAClearCallTable ; free call table
.IF qwOutput == 0 ; output to clipboard
;----------------------------------
; set clipboard data
;----------------------------------
Invoke szLen, ptrClipboardData
.IF eax != 0
mov LenClipData, rax
inc rax
Invoke GlobalAlloc, GMEM_MOVEABLE, rax
.IF rax == NULL
Invoke GlobalFree, ptrClipboardData
Invoke CloseClipboard
ret
.ENDIF
mov hClipData, rax
Invoke GlobalLock, hClipData
.IF rax == NULL
Invoke GlobalFree, ptrClipboardData
Invoke GlobalFree, hClipData
Invoke CloseClipboard
ret
.ENDIF
mov pClipData, rax
mov rax, LenClipData
Invoke RtlMoveMemory, pClipData, ptrClipboardData, rax
Invoke GlobalUnlock, hClipData
invoke SetClipboardData, CF_TEXT, hClipData
Invoke CloseClipboard
Invoke GlobalFree, ptrClipboardData
.ENDIF
;PrintText 'Finished'
Invoke GuiAddStatusBarMessage, Addr szFinishCopyToAsm
.ELSE
Invoke GuiAddStatusBarMessage, Addr szFinishCopyToAsmRefView
Invoke GuiReferenceSetSingleSelection, 0, TRUE
Invoke GuiReferenceReloadData
.ENDIF
ret
DoCopyToAsm ENDP
;-------------------------------------------------------------------------------------
; 1st pass of selection, build an array of jmp destinations
; estimates size required based on selection size (bytes) / 2 (jmp near = 2 bytes long)
; = no of entries (max safe estimate) * size jmptable_entry struct
; also roughly calcs the size of clipboard data required
;-------------------------------------------------------------------------------------
CTABuildJmpTable PROC FRAME USES RBX qwStartAddress:QWORD, qwFinishAddress:QWORD
LOCAL bii:BASIC_INSTRUCTION_INFO ; basic
LOCAL qwJmpTableSize:QWORD
LOCAL qwCurrentAddress:QWORD
LOCAL JmpDestination:QWORD
LOCAL nJmpEntry:QWORD
LOCAL ptrJmpEntry:QWORD
;PrintText 'CTABuildJmpTable'
mov CLIPDATASIZE, 0
mov rax, qwFinishAddress
mov rbx, qwStartAddress
sub rax, rbx
.IF sqword ptr rax < 0
neg rax
.ENDIF
shr rax, 1 ; div by 2
mov JMPTABLE_ENTRIES_MAX, rax
mov rbx, SIZEOF JMPTABLE_ENTRY
mul rbx
mov qwJmpTableSize, rax
Invoke GlobalAlloc, GMEM_FIXED + GMEM_ZEROINIT, qwJmpTableSize
.IF rax == NULL
Invoke GuiAddStatusBarMessage, Addr szErrorAllocMemJmpTable
mov rax, FALSE
ret