-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.asm
3844 lines (2887 loc) · 83.8 KB
/
app.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
;----------------T---------------T--------------------------------------------------T------------------------------------------------------
; description: x64 asm source for "commander style" windows file manager - main application class
; note: copyright © by digital performance 1997 - 2014, author S. Deutsch, A. Voelskow
; license:
;
; This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
;
; assembler: Visual Studio 2013
; last update: 2013-02-20 - Deutsch - make x64
;
; general register usage:
; r12 .. holds main app object
; r14 .. holds local structures
; r15 .. holds local object
;
;------------------------------------------------------------------------------------------------------------------------------------------
include windows.inc
include commctrl.inc
include app.inc
include button.inc
include command.inc
include config.inc
include edit.inc
include list.inc
include resource.inc
;------------------------------------------------------------------------------------------------------------------------------------------
; code segment
;------------------------------------------------------------------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------------------------------------------------------------------
; does: create new application object
; last update: 2013-02-20 - Deutsch - make x64
; parameters: pxApp appNew ()
; returns: new object or zero for error
;------------------------------------------------------------------------------------------------------------------------------------------
appNew PROC FRAME
push rbp
.pushreg rbp
mov rbp, rsp
.setframe rbp, 0
sub rsp, 32
.allocstack 32
.endprolog
; -- allocate object --
call GetProcessHeap
test rax, rax
jz appExit
mov r8, sizeof CLASS_APP
mov edx, HEAP_ZERO_MEMORY
mov rcx, rax
call HeapAlloc
test rax, rax
jz appExit
; -- prepare vtable --
lea rcx, [rax.CLASS_APP.xInterface]
mov [rax.CLASS_APP.vtableThis], rcx
lea rdx, appInit
mov [rcx.CLASS_APP_IFACE.pfnInit], rdx
lea rdx, appRun
mov [rcx.CLASS_APP_IFACE.pfnRun], rdx
lea rdx, appRelease
mov [rcx.CLASS_APP_IFACE.pfnRelease], rdx
lea rdx, appInitLogo
mov [rcx.CLASS_APP_IFACE.pfnInitLogo], rdx
lea rdx, appInitButtons
mov [rcx.CLASS_APP_IFACE.pfnInitButtons], rdx
lea rdx, appFindButton
mov [rcx.CLASS_APP_IFACE.pfnFindButton], rdx
lea rdx, appMatchShortcut
mov [rcx.CLASS_APP_IFACE.pfnMatchShortcut], rdx
lea rdx, appLoadString
mov [rcx.CLASS_APP_IFACE.pfnLoadString], rdx
lea rdx, appGetConfigPath
mov [rcx.CLASS_APP_IFACE.pfnGetConfigPath], rdx
lea rdx, appLoadConfig
mov [rcx.CLASS_APP_IFACE.pfnLoadConfig], rdx
lea rdx, appSaveConfig
mov [rcx.CLASS_APP_IFACE.pfnSaveConfig], rdx
lea rdx, appSaveWinConfig
mov [rcx.CLASS_APP_IFACE.pfnSaveWinConfig], rdx
lea rdx, appCreateViewFont
mov [rcx.CLASS_APP_IFACE.pfnCreateViewFont], rdx
lea rdx, appSetPath
mov [rcx.CLASS_APP_IFACE.pfnSetPath], rdx
lea rdx, appSetStatus
mov [rcx.CLASS_APP_IFACE.pfnSetStatus], rdx
lea rdx, appSetActive
mov [rcx.CLASS_APP_IFACE.pfnSetActive], rdx
lea rdx, appProcessActive
mov [rcx.CLASS_APP_IFACE.pfnProcessActive], rdx
lea rdx, appToggleMenu
mov [rcx.CLASS_APP_IFACE.pfnToggleMenu], rdx
lea rdx, appSetMenuState
mov [rcx.CLASS_APP_IFACE.pfnSetMenuState], rdx
lea rdx, appSetStatusCmd
mov [rcx.CLASS_APP_IFACE.pfnSetStatusCmd], rdx
lea rdx, appHandleEvent
mov [rcx.CLASS_APP_IFACE.pfnHandleEvent], rdx
lea rdx, appResize
mov [rcx.CLASS_APP_IFACE.pfnResize], rdx
lea rdx, appFillList
mov [rcx.CLASS_APP_IFACE.pfnFillList], rdx
lea rdx, appConfirmClose
mov [rcx.CLASS_APP_IFACE.pfnConfirmClose], rdx
appExit: add rsp, 32
pop rbp
ret 0
align 4
appNew ENDP
;------------------------------------------------------------------------------------------------------------------------------------------
; does: init application - user interface, threading, child windows
; last update: 2013-02-18 - Deutsch - make x64
; parameters: unError appInit ()
; returns: zero for ok, else error code
;------------------------------------------------------------------------------------------------------------------------------------------
appInit PROC FRAME
LOCAL xClass:WNDCLASSEX ; class info
LOCAL rcApp:RECT ; main window position
LOCAL txClass [64]:WORD ; class name
LOCAL txTitle [64]:WORD ; window title mask
LOCAL txVerMask [64]:WORD
LOCAL unCount:QWORD ; written bytes
LOCAL xPlacement:WINDOWPLACEMENT
push rbp
.pushreg rbp
push r12
.pushreg r12
push r14
.pushreg r14
mov rbp, rsp
.setframe rbp, 0
sub rsp, 1 * 8 + 2 * 64 + 2 * 64 + 2 * 64 + sizeof WNDCLASSEX + sizeof RECT + sizeof WINDOWPLACEMENT + 4 + 8
sub rsp, 128
.allocstack 128 + 1 * 8 + 2 * 64 + 2 * 64 + 2 * 64 + sizeof WNDCLASSEX + sizeof RECT + sizeof WINDOWPLACEMENT + 4 + 8
.endprolog
; -- get parameter --
mov r12, rcx
; -- show logo --
mov rcx, 0
call GetModuleHandle
mov [r12.CLASS_APP.hinstApp], rax
mov [r12.CLASS_APP.unLang], SUBLANG_DEFAULT SHL 10 OR LANG_GERMAN
mov rdx, 1000
mov rcx, r12
mov rax, [rcx.CLASS_APP.vtableThis]
call [rax.CLASS_APP_IFACE.pfnInitLogo]
test rax, rax
jnz appExit
; -- init main members --
lea r14, xClass
mov edx, sizeof WNDCLASSEX
mov rcx, r14
call RtlZeroMemory
mov rax, [r12.CLASS_APP.hinstApp]
mov [r14.WNDCLASSEX.hInstance], rax
; -- init window class --
mov rdx, IDI_APP
mov rcx, [r12.CLASS_APP.hinstApp]
call LoadIcon
mov [r12.CLASS_APP.hiconApp], rax
mov [r14.WNDCLASSEX.hIcon], rax
mov [r14.WNDCLASSEX.hIconSm], rax
mov rdx, IDC_ARROW
mov rcx, 0
call LoadCursor
mov [r14.WNDCLASSEX.hCursor], rax
lea r9, txClass
mov r8, SUBLANG_NEUTRAL SHL 10 OR LANG_NEUTRAL
mov rdx, IDS_APPWINCLASS
mov rcx, r12
mov rax, [rcx.CLASS_APP.vtableThis]
call [rax.CLASS_APP_IFACE.pfnLoadString]
; -- prepare class --
lea rax, txClass
lea rcx, wndprcApp
mov [r14.WNDCLASSEX.cbSize], sizeof WNDCLASSEX
mov [r14.WNDCLASSEX.style], CS_HREDRAW OR CS_VREDRAW
mov [r14.WNDCLASSEX.lpfnWndProc], rcx
mov [r14.WNDCLASSEX.lpszClassName], rax
mov [r14.WNDCLASSEX.hbrBackground], COLOR_BTNFACE + 1
mov rcx, r14
call RegisterClassEx
; -- check and create default config --
call configNew
mov [r12.CLASS_APP.pxConfig], rax
mov rdx, r12
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnInit]
lea r9, [r12.CLASS_APP.txSection]
mov r8, SUBLANG_NEUTRAL SHL 10 OR LANG_NEUTRAL
mov rdx, IDS_CFG_PARAM
mov rcx, r12
mov rax, [rcx.CLASS_APP.vtableThis]
call [rax.CLASS_APP_IFACE.pfnLoadString]
; -- init main app window --
lea r9, txTitle
mov r8, SUBLANG_NEUTRAL SHL 10 OR LANG_NEUTRAL
mov rdx, IDS_APPTITLE
mov rcx, r12
mov rax, [rcx.CLASS_APP.vtableThis]
call [rax.CLASS_APP_IFACE.pfnLoadString]
lea r9, txVerMask
mov r8, SUBLANG_NEUTRAL SHL 10 OR LANG_NEUTRAL
mov rdx, IDS_VERMASK
mov rcx, r12
mov rax, [rcx.CLASS_APP.vtableThis]
call [rax.CLASS_APP_IFACE.pfnLoadString]
lea rcx, txTitle
call lstrlen
mov unCount, rax
; -- get exe version --
mov r8, RT_VERSION
mov rdx, IDV_VERSION
mov rcx, [r12.CLASS_APP.hinstApp]
call FindResource
mov rdx, rax
mov rcx, [r12.CLASS_APP.hinstApp]
call LoadResource
mov rcx, rax
call LockResource
add rax, 6 + 30 + 4 + 8
movzx r9d, word ptr [rax]
movzx r8d, word ptr [rax + 2]
; -- append version to title --
mov rax, unCount
lea rcx, txTitle
lea rcx, [rcx + 2 * rax]
lea rdx, txVerMask
call wsprintf
; -- get application configuration --
mov rcx, r12
mov rax, [r12.CLASS_APP.vtableThis]
call [rax.CLASS_APP_IFACE.pfnLoadConfig]
test rax, rax
jnz appExit
; -- load buttons --
mov rcx, r12
mov rax, [r12.CLASS_APP.vtableThis]
call [rax.CLASS_APP_IFACE.pfnInitButtons]
test rax, rax
jnz appExit
; -- load main menu --
mov edx, IDM_APP
mov rcx, [r12.CLASS_APP.hinstApp]
call LoadMenu
mov [r12.CLASS_APP.hmenuApp], rax
; -- create main window --
mov qword ptr [rsp + 88], 0
mov rax, [r12.CLASS_APP.hinstApp]
mov [rsp + 80], rax
mov rax, [r12.CLASS_APP.hmenuApp]
mov [rsp + 72], rax
mov qword ptr [rsp + 64], 0
mov eax, [r12.CLASS_APP.rcMain.RECT.bottom]
cmp eax, CW_USEDEFAULT
je appDefWin1
sub eax, [r12.CLASS_APP.rcMain.RECT.top]
appDefWin1: mov [rsp + 56], eax
mov eax, [r12.CLASS_APP.rcMain.RECT.right]
cmp eax, CW_USEDEFAULT
je appDefWin2
sub eax, [r12.CLASS_APP.rcMain.RECT.left]
appDefWin2: mov [rsp + 48], eax
mov eax, [r12.CLASS_APP.rcMain.RECT.top]
mov [rsp + 40], eax
mov eax, [r12.CLASS_APP.rcMain.RECT.left]
mov [rsp + 32], eax
mov r9d, WS_OVERLAPPEDWINDOW OR WS_CLIPCHILDREN
lea r8, txTitle
lea rdx, txClass
mov ecx, 0
call CreateWindowEx
test rax, rax
jz appFail
mov [r12.CLASS_APP.hwndApp], rax
mov r8, r12
mov edx, GWLP_USERDATA
mov rcx, [r12.CLASS_APP.hwndApp]
call SetWindowLongPtr
; -- create list objects --
call listNew
mov [r12.CLASS_APP.pxLeftList], rax
call listNew
mov [r12.CLASS_APP.pxRightList], rax
; -- initialize lists --
mov r9, r12
lea r8, [r12.CLASS_APP.txLeft]
mov rdx, IDC_LEFT
mov rcx, [r12.CLASS_APP.pxLeftList]
mov rax, [rcx.CLASS_LIST.vtableThis]
call [rax.CLASS_LIST_IFACE.pfnInit]
test rax, rax
jnz appExit
mov r9, r12
lea r8, [r12.CLASS_APP.txRight]
mov rdx, IDC_RIGHT
mov rcx, [r12.CLASS_APP.pxRightList]
mov rax, [rcx.CLASS_LIST.vtableThis]
call [rax.CLASS_LIST_IFACE.pfnInit]
test rax, rax
jnz appExit
; -- create edit fields --
call pathNew
mov [r12.CLASS_APP.pxLeftPath], rax
call pathNew
mov [r12.CLASS_APP.pxRightPath], rax
mov r8, r12
mov rdx, IDC_LEFTPATH
mov rcx, [r12.CLASS_APP.pxLeftPath]
mov rax, [rcx.CLASS_PATH.vtableThis]
call [rax.CLASS_PATH_IFACE.pfnInit]
test rax, rax
jnz appExit
mov r8, r12
mov rdx, IDC_RIGHTPATH
mov rcx, [r12.CLASS_APP.pxRightPath]
mov rax, [rcx.CLASS_PATH.vtableThis]
call [rax.CLASS_PATH_IFACE.pfnInit]
test rax, rax
jnz appExit
; -- create status bar --
mov r9d, IDC_STATUS
mov r8, [r12.CLASS_APP.hwndApp]
mov rdx, 0
mov rcx, WS_CHILD OR WS_VISIBLE
call CreateStatusWindow
mov [r12.CLASS_APP.hwndStatus], rax
lea rdx, rcApp
mov rcx, rax
call GetWindowRect
xor rax, rax
lea rcx, rcApp
mov eax, [rcx.RECT.bottom]
sub eax, [rcx.RECT.top]
mov [r12.CLASS_APP.unStHeight], rax
; -- create brushes and fonts --
mov rcx, [r12.CLASS_APP.unCurCol]
call CreateSolidBrush
mov [r12.CLASS_APP.hbrCurPath], rax
mov rcx, [r12.CLASS_APP.unOthCol]
call CreateSolidBrush
mov [r12.CLASS_APP.hbrOthPath], rax
; -- create processing events --
mov r9, 0
mov r8d, 0
mov edx, TRUE
mov rcx, 0
call CreateEvent
mov [r12.CLASS_APP.hevStop], rax
; -- store current and other --
mov rax, [r12.CLASS_APP.pxLeftList]
mov rcx, [r12.CLASS_APP.pxRightList]
mov [r12.CLASS_APP.pxActive], rax
mov [r12.CLASS_APP.pxInactive], rcx
; -- all init done, show window --
mov eax, [r12.CLASS_APP.rcMain.RECT.left]
cmp eax, CW_USEDEFAULT
je appFirstShow
lea rdx, xPlacement
mov [rdx.WINDOWPLACEMENT.len], sizeof WINDOWPLACEMENT
mov [rdx.WINDOWPLACEMENT.flags], 0
mov [rdx.WINDOWPLACEMENT.ptMinPosition.POINT.x], 0
mov [rdx.WINDOWPLACEMENT.ptMinPosition.POINT.y], 0
mov [rdx.WINDOWPLACEMENT.ptMaxPosition.POINT.x], 0
mov [rdx.WINDOWPLACEMENT.ptMaxPosition.POINT.y], 0
mov rax, [r12.CLASS_APP.unShowMode]
mov [rdx.WINDOWPLACEMENT.showCmd], eax
mov eax, [r12.CLASS_APP.rcMain.RECT.left]
mov [rdx.WINDOWPLACEMENT.rcNormalPosition.RECT.left], eax
mov eax, [r12.CLASS_APP.rcMain.RECT.top]
mov [rdx.WINDOWPLACEMENT.rcNormalPosition.RECT.top], eax
mov eax, [r12.CLASS_APP.rcMain.RECT.right]
mov [rdx.WINDOWPLACEMENT.rcNormalPosition.RECT.right], eax
mov eax, [r12.CLASS_APP.rcMain.RECT.bottom]
mov [rdx.WINDOWPLACEMENT.rcNormalPosition.RECT.bottom], eax
mov rcx, [r12.CLASS_APP.hwndApp]
call SetWindowPlacement
jmp appDone
appFirstShow: mov rdx, [r12.CLASS_APP.unShowMode]
mov rcx, [r12.CLASS_APP.hwndApp]
call ShowWindow
; -- end cases --
appFail: call GetLastError
jmp appExit
appDone: xor rax, rax
appExit: add rsp, 128
add rsp, 1 * 8 + 2 * 64 + 2 * 64 + 2 * 64 + sizeof WNDCLASSEX + sizeof RECT + sizeof WINDOWPLACEMENT + 4 + 8
pop r14
pop r12
pop rbp
ret 0
align 4
appInit ENDP
;------------------------------------------------------------------------------------------------------------------------------------------
; does: run main application, main message loop handling
; last update: 2013-02-18 - Deutsch - make x64
; parameters: unError appRun ()
; returns: zero for ok, else error code
;------------------------------------------------------------------------------------------------------------------------------------------
appRun PROC FRAME
LOCAL xMessage:MSG ; message info
push rbp
.pushreg rbp
push r12
.pushreg r12
mov rbp, rsp
.setframe rbp, 0
sub rsp, sizeof MSG + 8
sub rsp, 32
.allocstack 32 + sizeof MSG + 8
.endprolog
; -- get parameter --
mov r12, rcx
; -- create main command object --
call commandNew
mov [r12.CLASS_APP.pxCommand], rax
mov rdx, r12
mov rcx, [r12.CLASS_APP.pxCommand]
mov rax, [rcx.CLASS_COMMAND.vtableThis]
call [rax.CLASS_COMMAND_IFACE.pfnInit]
test rax, rax
jnz appDone
; -- start list fill threads --
mov rdx, LIST_ACTUAL
mov rcx, r12
mov rax, [r12.CLASS_APP.vtableThis]
call [rax.CLASS_APP_IFACE.pfnFillList]
mov rdx, LIST_OTHER
mov rcx, r12
mov rax, [r12.CLASS_APP.vtableThis]
call [rax.CLASS_APP_IFACE.pfnFillList]
; -- show new status --
mov rdx, IDS_STATUS_READY
mov rcx, r12
mov rax, [r12.CLASS_APP.vtableThis]
call [rax.CLASS_APP_IFACE.pfnSetStatus]
; -- message loop --
appLoop: mov dword ptr [rsp + 32], PM_REMOVE
mov r9d, 0
mov r8d, 0
mov rdx, 0
lea rcx, xMessage
call PeekMessage
test eax, eax
jz appWait
lea rcx, xMessage
call TranslateMessage
lea rcx, xMessage
call DispatchMessage
jmp appLoop
appWait: mov dword ptr [rsp + 32], QS_ALLINPUT
mov r9d, INFINITE
mov r8d, FALSE
lea rdx, [r12.CLASS_APP.hevStop]
mov ecx, 1
call MsgWaitForMultipleObjects
cmp eax, WAIT_OBJECT_0 + 1
je appLoop
; -- end program --
mov rcx, r12
mov rax, [r12.CLASS_APP.vtableThis]
call [rax.CLASS_APP_IFACE.pfnSaveWinConfig]
; -- release application --
mov rcx, r12
mov rax, [r12.CLASS_APP.vtableThis]
call [rax.CLASS_APP_IFACE.pfnRelease]
; -- message loop exit --
appDone: xor rax, rax
add rsp, 32
add rsp, sizeof MSG + 8
pop r12
pop rbp
ret 0
align 4
appRun ENDP
;------------------------------------------------------------------------------------------------------------------------------------------
; does: release application
; last update: 2013-02-18 - Deutsch - make x64
; parameters: unError appRelease ()
; returns: zero for ok, else error code
;------------------------------------------------------------------------------------------------------------------------------------------
appRelease PROC FRAME
push rbp
.pushreg rbp
push r12
.pushreg r12
mov rbp, rsp
.setframe rbp, 0
sub rsp, 8
sub rsp, 32
.allocstack 32 + 8
.endprolog
; -- get parameter --
mov r12, rcx
; -- store last used paths --
lea r9, [r12.CLASS_APP.txLeft]
mov r8, IDS_CFG_LEFTPATH
lea rdx, [r12.CLASS_APP.txSection]
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnSetConfigText]
lea r9, [r12.CLASS_APP.txRight]
mov r8, IDS_CFG_RIGHTPATH
lea rdx, [r12.CLASS_APP.txSection]
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnSetConfigText]
; -- release childs --
mov rcx, [r12.CLASS_APP.pxCommand]
mov rax, [rcx.CLASS_COMMAND.vtableThis]
call [rax.CLASS_COMMAND_IFACE.pfnRelease]
mov [r12.CLASS_APP.pxCommand], 0
mov rcx, [r12.CLASS_APP.pxLeftPath]
mov rax, [rcx.CLASS_PATH.vtableThis]
call [rax.CLASS_PATH_IFACE.pfnRelease]
mov [r12.CLASS_APP.pxLeftPath], 0
mov rcx, [r12.CLASS_APP.pxRightPath]
mov rax, [rcx.CLASS_PATH.vtableThis]
call [rax.CLASS_PATH_IFACE.pfnRelease]
mov [r12.CLASS_APP.pxRightPath], 0
mov rcx, [r12.CLASS_APP.pxLeftList]
mov rax, [rcx.CLASS_LIST.vtableThis]
call [rax.CLASS_LIST_IFACE.pfnRelease]
mov [r12.CLASS_APP.pxLeftList], 0
mov rcx, [r12.CLASS_APP.pxRightList]
mov rax, [rcx.CLASS_LIST.vtableThis]
call [rax.CLASS_LIST_IFACE.pfnRelease]
mov [r12.CLASS_APP.pxRightList], 0
; -- release allocated resources --
mov rcx, [r12.CLASS_APP.hevStop]
call CloseHandle
mov rcx, [r12.CLASS_APP.hbrCurPath]
call DeleteObject
mov rcx, [r12.CLASS_APP.hbrOthPath]
call DeleteObject
mov rcx, [r12.CLASS_APP.hiconApp]
call DestroyIcon
mov rcx, [r12.CLASS_APP.hmenuApp]
call DestroyMenu
mov rcx, [r12.CLASS_APP.hwndApp]
call DestroyWindow
; -- end process --
xor rax, rax
add rsp, 32
add rsp, 8
pop r12
pop rbp
ret 0
align 4
appRelease ENDP
;------------------------------------------------------------------------------------------------------------------------------------------
; does: create button array
; last update: 2013-02-20 - Deutsch - make x64
; parameters: unError appInitButtons ()
; returns: zero for ok, or error code
;------------------------------------------------------------------------------------------------------------------------------------------
appInitButtons PROC FRAME
LOCAL unHLoop:QWORD ; loop counter horizontal
LOCAL unVLoop:QWORD ; loop counter vertical
push rbp
.pushreg rbp
push r12
.pushreg r12
push r15
.pushreg r15
mov rbp, rsp
.setframe rbp, 0
sub rsp, 2 * 8
sub rsp, 32
.allocstack 32 + 2 * 8
.endprolog
; -- get parameter --
mov r12, rcx
; -- get size for button data --
call GetProcessHeap
test rax, rax
jz appExit
mov r8, sizeof QWORD
imul r8, [r12.CLASS_APP.unBtnCols]
imul r8, [r12.CLASS_APP.unBtnRows]
mov edx, HEAP_ZERO_MEMORY
mov rcx, rax
call HeapAlloc
test rax, rax
jz appExit
mov [r12.CLASS_APP.pxButtons], rax
mov r15, rax
; -- load button config --
mov unVLoop, 0
; -- loop rows --
appLines: mov unHLoop, 0
; -- loop buttons --
appLoop: call buttonNew
mov [r15], rax
; -- init button --
mov r9, r12
mov r8, unVLoop
mov rdx, unHLoop
mov rcx, rax
mov rax, [rcx.CLASS_BUTTON.vtableThis]
call [rax.CLASS_BUTTON_IFACE.pfnInit]
add r15, sizeof QWORD
inc unHLoop
mov rax, [r12.CLASS_APP.unBtnCols]
cmp unHLoop, rax
jl appLoop
inc unVLoop
mov rax, [r12.CLASS_APP.unBtnRows]
cmp unVLoop, rax
jl appLines
; -- return result --
xor rax, rax
appExit: add rsp, 32
add rsp, 2 * 8
pop r15
pop r12
pop rbp
ret 0
align 4
appInitButtons ENDP
;------------------------------------------------------------------------------------------------------------------------------------------
; does: load application configuration from config file
; last update: 2013-02-20 - Deutsch - make x64
; parameters: unError appLoadConfig ()
; returns: zero for ok, or error code
;------------------------------------------------------------------------------------------------------------------------------------------
appLoadConfig PROC FRAME
LOCAL unValue:QWORD ; misc value
LOCAL txDefPath [128]:WORD ; default path
push rbp
.pushreg rbp
push r12
.pushreg r12
mov rbp, rsp
.setframe rbp, 0
sub rsp, 1 * 8 + 2 * 128
sub rsp, 128
.allocstack 128 + 1 * 8 + 2 * 128
.endprolog
; -- get parameter --
mov r12, rcx
; -- get button rows --
lea rax, [r12.CLASS_APP.unBtnRows]
mov [rsp + 32], rax
mov r9, DEF_BUTTON_ROWS
mov r8, IDS_CFG_BUTTONROWS
lea rdx, [r12.CLASS_APP.txSection]
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnGetConfigNumber]
; -- get button columns --
lea rax, [r12.CLASS_APP.unBtnCols]
mov [rsp + 32], rax
mov r9, DEF_BUTTON_COLS
mov r8, IDS_CFG_BUTTONCOLS
lea rdx, [r12.CLASS_APP.txSection]
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnGetConfigNumber]
; -- get delete confirm --
lea rax, [r12.CLASS_APP.fDelConf]
mov [rsp + 32], rax
mov r9, TRUE
mov r8, IDS_CFG_DELCONFIRM
lea rdx, [r12.CLASS_APP.txSection]
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnGetConfigNumber]
; -- get last window rect --
lea rax, unValue
mov [rsp + 32], rax
mov r9, CW_USEDEFAULT
mov r8, IDS_CFG_WINLEFT
lea rdx, [r12.CLASS_APP.txSection]
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnGetConfigNumber]
mov rax, unValue
mov [r12.CLASS_APP.rcMain.RECT.left], eax
lea rax, unValue
mov [rsp + 32], rax
mov r9, CW_USEDEFAULT
mov r8, IDS_CFG_WINTOP
lea rdx, [r12.CLASS_APP.txSection]
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnGetConfigNumber]
mov rax, unValue
mov [r12.CLASS_APP.rcMain.RECT.top], eax
lea rax, unValue
mov [rsp + 32], rax
mov r9, CW_USEDEFAULT
mov r8, IDS_CFG_WINRIGHT
lea rdx, [r12.CLASS_APP.txSection]
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnGetConfigNumber]
mov rax, unValue
mov [r12.CLASS_APP.rcMain.RECT.right], eax
lea rax, unValue
mov [rsp + 32], rax
mov r9, CW_USEDEFAULT
mov r8, IDS_CFG_WINBOTTOM
lea rdx, [r12.CLASS_APP.txSection]
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnGetConfigNumber]
mov rax, unValue
mov [r12.CLASS_APP.rcMain.RECT.bottom], eax
; -- load selection colors --
lea rax, [r12.CLASS_APP.unCurCol]
mov [rsp + 32], rax
mov r9, DEF_CURCOLOR
mov r8, IDS_CFG_SELECTCUR
lea rdx, [r12.CLASS_APP.txSection]
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnGetConfigNumber]
lea rax, [r12.CLASS_APP.unOthCol]
mov [rsp + 32], rax
mov r9, DEF_OTHCOLOR
mov r8, IDS_CFG_SELECTOTH
lea rdx, [r12.CLASS_APP.txSection]
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnGetConfigNumber]
; -- get last used paths --
lea r9, txDefPath
mov r8, SUBLANG_NEUTRAL SHL 10 OR LANG_NEUTRAL
mov rdx, IDS_DEFPATH
mov rcx, r12
mov rax, [rcx.CLASS_APP.vtableThis]
call [rax.CLASS_APP_IFACE.pfnLoadString]
lea rax, [r12.CLASS_APP.txLeft]
mov [rsp + 32], rax
lea r9, txDefPath
mov r8, IDS_CFG_LEFTPATH
lea rdx, [r12.CLASS_APP.txSection]
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnGetConfigText]
lea rax, [r12.CLASS_APP.txRight]
mov [rsp + 32], rax
lea r9, txDefPath
mov r8, IDS_CFG_RIGHTPATH
lea rdx, [r12.CLASS_APP.txSection]
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnGetConfigText]
; -- get last used show mode --
lea rax, [r12.CLASS_APP.unShowMode]
mov [rsp + 32], rax
mov r9, SW_SHOWNORMAL
mov r8, IDS_CFG_SHOWMODE
lea rdx, [r12.CLASS_APP.txSection]
mov rcx, [r12.CLASS_APP.pxConfig]
mov rax, [rcx.CLASS_CONFIG.vtableThis]
call [rax.CLASS_CONFIG_IFACE.pfnGetConfigNumber]
xor rax, rax
add rsp, 128
add rsp, 1 * 8 + 2 * 128
pop r12
pop rbp
ret 0
align 4
appLoadConfig ENDP