forked from AgileEhsan/winasm-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Misc.asm
5455 lines (4643 loc) · 140 KB
/
Misc.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
InvalidateAllDockWindows PROTO
SetItemText PROTO :HWND, :DWORD, :DWORD, :DWORD
GetTreeItemParameter PROTO :HWND, :DWORD
SetProperties PROTO :DWORD
EnumProjectItems PROTO :DWORD
EnumOpenedExternalFiles PROTO :DWORD
TVM_SETBKCOLOR EQU TV_FIRST + 29
TVM_SETTEXTCOLOR EQU TV_FIRST + 30
TVM_SETLINECOLOR EQU TV_FIRST + 40
TVM_SETINSERTMARKCOLOR EQU TV_FIRST + 37
LANGANDCODEPAGE STRUCT
wLanguage WORD ?
wCodepage WORD ?
LANGANDCODEPAGE ENDS
CODEPAGECHARSET STRUCT
wCodepage WORD ?
byteCharset BYTE ?
CODEPAGECHARSET ENDS
.DATA
CodePageCharset CODEPAGECHARSET <932,128> ;Japanese
CODEPAGECHARSET <936,134> ;Simplified Chinese
CODEPAGECHARSET <949,129> ;Korean
CODEPAGECHARSET <950,136> ;Traditional Chinese-Taiwan (GB5)
CODEPAGECHARSET <1250,238> ;Eastern Europe
CODEPAGECHARSET <1251,204> ;Russian
CODEPAGECHARSET <1252,0> ;Western European Languages
CODEPAGECHARSET <1253,161> ;Greek
CODEPAGECHARSET <1254,162> ;Turkish
CODEPAGECHARSET <1255,177> ;Hebrew
CODEPAGECHARSET <1256,178> ;Arabic
CODEPAGECHARSET <1257,186> ;Baltic
DW 0
.CODE
GetFirstNextChild Proc hItem:DWORD,fNextItem:DWORD
Local tvi:TVITEM
XOR EAX,EAX
.If hItem!=0
Invoke SendMessage,WinAsmHandles.hProjTree,TVM_GETNEXTITEM,fNextItem,hItem
.If EAX
MOV tvi._mask,TVIF_PARAM
MOV tvi.hItem,EAX
Invoke SendMessage,WinAsmHandles.hProjTree,TVM_GETITEM,0,ADDR tvi
;tvi.lParam holds the handle of Child Window
MOV EAX, tvi.lParam
.EndIf
;EAX==0
;.Else
; MOV EAX,0
.EndIf
RET
GetFirstNextChild EndP
GetProjectBinName Proc Uses EDI lpBuffer:DWORD, lpExtension:DWORD
.If ProjectType!=6
.If ActiveBuild==0 ;i.e. Release build
MOV EDI, Offset szReleaseOutCommand
.Else
MOV EDI, Offset szDebugOutCommand
.EndIf
.If BYTE PTR [EDI]==0
Invoke lstrcpy, lpBuffer,Offset FullProjectName
Invoke RemoveFileExt,lpBuffer
Invoke lstrcat,lpBuffer,lpExtension
.Else
Invoke GetFilePath,EDI,lpBuffer
MOV EDX,lpBuffer
.If BYTE PTR [EDX]==0 ;i.e. if no path specified->add project path
Invoke lstrcpy, lpBuffer,Offset ProjectPath
Invoke lstrcat, lpBuffer, EDI;Offset szReleaseOutCommand
.Else
Invoke lstrcpy,lpBuffer,EDI
.EndIf
.EndIf
.Else
Invoke GetFirstNextChild, hASMFilesItem,TVGN_CHILD
Invoke GetWindowLong,EAX,0
Invoke lstrcpy,lpBuffer,ADDR [EAX].CHILDWINDOWDATA.szFileName
Invoke RemoveFileExt,lpBuffer
Invoke lstrcat,lpBuffer,lpExtension
.EndIf
RET
GetProjectBinName EndP
DoEvents Proc
Local Msg:MSG
.While TRUE
Invoke PeekMessage,ADDR Msg,NULL,0,0,PM_REMOVE
.Break .If (!EAX)
Invoke TranslateMessage, ADDR Msg
Invoke DispatchMessage, ADDR Msg
.EndW
RET
DoEvents EndP
;ExecuteThread Proc lParam:DWORD
;
; RET
;ExecuteThread EndP
EnableDisableMakeOptions Proc Uses EBX
Local NoCommand:BOOLEAN
MOV NoCommand,TRUE
Invoke GetFirstNextChild, hResourceFilesItem,TVGN_CHILD
.If EAX
Invoke EnableMenuItem,hMenu,IDM_MAKE_COMPILERESOURCE,MF_ENABLED
MOV NoCommand,FALSE
.If RCToObj[0]!=0
Invoke EnableMenuItem,hMenu,IDM_MAKE_RCTOOBJ,MF_ENABLED
.Else
Invoke EnableMenuItem,hMenu,IDM_MAKE_RCTOOBJ,MF_GRAYED
.EndIf
.Else
Invoke EnableMenuItem,hMenu,IDM_MAKE_COMPILERESOURCE,MF_GRAYED
Invoke EnableMenuItem,hMenu,IDM_MAKE_RCTOOBJ,MF_GRAYED
.EndIf
Invoke GetFirstNextChild, hASMFilesItem,TVGN_CHILD
.If !EAX
Invoke GetFirstNextChild, hModulesItem,TVGN_CHILD
.If !EAX
MOV EDX,MF_GRAYED
MOV EBX,0
JMP EnDisableAssemble
.EndIf
.EndIf
MOV NoCommand,FALSE
MOV EDX,MF_ENABLED
MOV EBX,TBSTATE_ENABLED
EnDisableAssemble:
;-----------------
Invoke EnableMenuItem,hMenu,IDM_MAKE_ASSEMBLE,EDX
Invoke SendMessage,hMakeTB,TB_SETSTATE,IDM_MAKE_ASSEMBLE,EBX
.If NoCommand==FALSE
Invoke EnableMenuItem,WinAsmHandles.PopUpMenus.hMakeMenu,IDM_MAKE_CLEAN,MF_ENABLED
Invoke EnableMenuItem,hMenu,IDM_MAKE_LINK,MF_ENABLED
Invoke SendMessage,hMakeTB,TB_SETSTATE,IDM_MAKE_LINK,TBSTATE_ENABLED
Invoke EnableMenuItem,hMenu,IDM_MAKE_GO,MF_ENABLED
Invoke SendMessage,hMakeTB,TB_SETSTATE,IDM_MAKE_GO,TBSTATE_ENABLED
.If ProjectType==0 || ProjectType==2 || ProjectType==4 || ProjectType==6
Invoke EnableMenuItem,hMenu,IDM_MAKE_EXECUTE,MF_ENABLED
Invoke SendMessage,hMakeTB,TB_SETSTATE,IDM_MAKE_EXECUTE,TBSTATE_ENABLED
Invoke EnableMenuItem,hMenu,IDM_MAKE_DEBUG,MF_ENABLED
.Else
Invoke EnableMenuItem,hMenu,IDM_MAKE_EXECUTE,MF_GRAYED
Invoke SendMessage,hMakeTB,TB_SETSTATE,IDM_MAKE_EXECUTE,0
Invoke EnableMenuItem,hMenu,IDM_MAKE_DEBUG,MF_GRAYED
.EndIf
;Let's enable 'Set Active Make PopUp menu'
Invoke EnableMenuItem,WinAsmHandles.PopUpMenus.hMakeMenu,IDM_MAKEACTIVERELEASEVERSION,MF_ENABLED
Invoke EnableMenuItem,WinAsmHandles.PopUpMenus.hMakeMenu,IDM_MAKEACTIVEDEBUGVERSION,MF_ENABLED
;Invoke GetPrivateProfileInt, Offset szMAKE, Offset szActiveMake, 0, Offset FullProjectName
.If ActiveBuild==0
Invoke CheckMenuItem,WinAsmHandles.PopUpMenus.hMakeMenu,IDM_MAKEACTIVERELEASEVERSION,MF_CHECKED
Invoke CheckMenuItem,WinAsmHandles.PopUpMenus.hMakeMenu,IDM_MAKEACTIVEDEBUGVERSION,MF_UNCHECKED
.Else
Invoke CheckMenuItem,WinAsmHandles.PopUpMenus.hMakeMenu,IDM_MAKEACTIVERELEASEVERSION,MF_UNCHECKED
Invoke CheckMenuItem,WinAsmHandles.PopUpMenus.hMakeMenu,IDM_MAKEACTIVEDEBUGVERSION,MF_CHECKED
.EndIf
.Else
Invoke EnableMenuItem,WinAsmHandles.PopUpMenus.hMakeMenu,IDM_MAKE_CLEAN,MF_GRAYED
Invoke EnableMenuItem,hMenu,IDM_MAKE_LINK,MF_GRAYED
Invoke SendMessage,hMakeTB,TB_SETSTATE,IDM_MAKE_LINK,0
Invoke EnableMenuItem,hMenu,IDM_MAKE_GO,MF_GRAYED
Invoke SendMessage,hMakeTB,TB_SETSTATE,IDM_MAKE_GO,0
Invoke EnableMenuItem,hMenu,IDM_MAKE_EXECUTE,MF_GRAYED
Invoke SendMessage,hMakeTB,TB_SETSTATE,IDM_MAKE_EXECUTE,0
Invoke EnableMenuItem,hMenu,IDM_MAKE_DEBUG,MF_GRAYED
;Let's disable 'Set Active Make PopUp menu'
;Invoke EnableMenuItem,hMakeMenu,0,MF_BYPOSITION or MF_GRAYED
Invoke CheckMenuItem,WinAsmHandles.PopUpMenus.hMakeMenu,IDM_MAKEACTIVERELEASEVERSION,MF_UNCHECKED
Invoke CheckMenuItem,WinAsmHandles.PopUpMenus.hMakeMenu,IDM_MAKEACTIVEDEBUGVERSION,MF_UNCHECKED
Invoke EnableMenuItem,WinAsmHandles.PopUpMenus.hMakeMenu,IDM_MAKEACTIVERELEASEVERSION,MF_GRAYED
Invoke EnableMenuItem,WinAsmHandles.PopUpMenus.hMakeMenu,IDM_MAKEACTIVEDEBUGVERSION,MF_GRAYED
.EndIf
RET
EnableDisableMakeOptions EndP
Execute Proc
Local startinfo :STARTUPINFO
Local ExitCode :DWORD
Local Buffer[512] :BYTE
PUSH EDI
PUSH ESI
Invoke RtlZeroMemory,ADDR startinfo,SizeOf STARTUPINFO
MOV startinfo.cb, SizeOf STARTUPINFO
.If ActiveBuild==0 ;i.e. Release build
MOV ESI,Offset szReleaseCommandLine
.Else
MOV ESI,Offset szDebugCommandLine
.EndIf
LEA EDI,Buffer
MOV BYTE PTR [EDI],'"'
INC EDI
Invoke GetProjectBinName,EDI,Offset szExtExe
Invoke lstrcat,EDI,Offset szQuote
CALL CreateTheProcess
.If !EAX
.If ProjectType==6
Invoke GetProjectBinName,EDI,Offset szExtCom
Invoke lstrcat,EDI,Offset szQuote
CALL CreateTheProcess
.If EAX
JMP Success
.EndIf
.EndIf
CALL ExecutionFailed
JMP Ex
.EndIf
Success:
;------
Invoke EnableMenuItem,hMenu,IDM_NEWPROJECT,MF_GRAYED
Invoke SendMessage,hMainTB,TB_SETSTATE,IDM_NEWPROJECT,0
Invoke EnableMenuItem,hMenu,IDM_OPENPROJECT,MF_GRAYED
Invoke SendMessage,hMainTB,TB_SETSTATE,IDM_OPENPROJECT,0
Invoke EnableMenuItem,hMenu,IDM_CLOSEPROJECT,MF_GRAYED
Invoke EnableMenuItem,hMenu,IDM_MAKE_EXECUTE,MF_GRAYED
Invoke SendMessage,hMakeTB,TB_SETSTATE,IDM_MAKE_EXECUTE,0
Invoke EnableMenuItem,hMenu,IDM_MAKE_STOP,MF_ENABLED
Invoke SendMessage,hMakeTB,TB_SETSTATE,IDM_MAKE_STOP,TBSTATE_ENABLED
Invoke SetTimer,WinAsmHandles.hMain,400,200,0
Ex:
POP ESI
POP EDI
RET
;****************************************************************************
CreateTheProcess:
;Invoke CreateProcess,EDI,ESI,NULL,NULL,FALSE, NORMAL_PRIORITY_CLASS,NULL,NULL,ADDR startinfo,ADDR proc_info
.If BYTE PTR [ESI]
Invoke lstrcat,EDI,Offset szSpc
Invoke lstrcat,EDI,ESI
.EndIf
MOV EDX,EDI
DEC EDX
Invoke CreateProcess,NULL,EDX,NULL,NULL,FALSE, NORMAL_PRIORITY_CLASS,NULL,NULL,ADDR startinfo,ADDR proc_info
RETN
;****************************************************************************
ExecutionFailed:
Invoke MessageBox,WinAsmHandles.hMain,Offset szExecutionError, Offset szAppName,MB_OK+MB_TASKMODAL
RETN
Execute EndP
;ExecuteThread Proc lParam:DWORD
;Local startinfo :STARTUPINFO
;Local ExitCode :DWORD
;Local Buffer[288] :BYTE
;
; Invoke RtlZeroMemory,ADDR startinfo,SizeOf STARTUPINFO
; MOV startinfo.cb, SizeOf STARTUPINFO
; .If ActiveBuild==0 ;i.e. Release build
; MOV EDI,Offset szReleaseCommandLine
; .Else
; MOV EDI,Offset szDebugCommandLine
; .EndIf
;
; .If BYTE PTR [EDI] ;i.e. if there is command line
; MOV ESI, Offset tmpBuffer
; Invoke lstrcpy,ESI,Offset szQuote
; Invoke lstrcat,ESI,EDI
; Invoke lstrcat,ESI,Offset szQuote
; .Else
; MOV ESI, NULL
; .EndIf
;
; LEA EDI,Buffer
; Invoke GetProjectBinName,EDI,Offset szExtExe
;
; ;Invoke ShellExecute,NULL,Offset szopen,EDI,ESI,NULL,SW_SHOWDEFAULT
; CALL CreateTheProcess
;
; .If !EAX;<=32
; .If ProjectType!=6
; CALL ExecutionFailed
;
; .Else
; Invoke GetProjectBinName,EDI,Offset szExtCom
;
; ;Invoke ShellExecute,NULL,Offset szopen,EDI,ESI,NULL,SW_SHOWDEFAULT
; CALL CreateTheProcess
; .If !EAX;<=32
; CALL ExecutionFailed
; .EndIf
; .EndIf
; .EndIf
;
; ;Invoke ExitThread,0
;
;; Invoke EnableMenuItem,hMenu,IDM_MAKE_LINK,MF_ENABLED
;; Invoke SendMessage,hMakeTB,TB_SETSTATE,IDM_MAKE_LINK,TBSTATE_ENABLED
;;
;; Invoke EnableMenuItem,hMenu,IDM_MAKE_GO,MF_ENABLED
;; Invoke SendMessage,hMakeTB,TB_SETSTATE,IDM_MAKE_GO,TBSTATE_ENABLED
;;
;; Invoke EnableMenuItem,hMenu,IDM_MAKE_EXECUTE,MF_ENABLED
;
;
; Invoke SendMessage,hMakeTB,TB_SETCMDID,4,IDM_MAKE_EXECUTE
; Invoke SendMessage,hMakeTB,TB_CHANGEBITMAP,IDM_MAKE_EXECUTE,23
; Invoke InvalidateRect,hMakeTB,NULL,TRUE
;
; Invoke EnableDisableMakeOptions
;
; MOV proc_info.hProcess,0
;
; RET
;
; ;****************************************************************************
; CreateTheProcess:
; Invoke CreateProcess,EDI,ESI,NULL,NULL,FALSE, NORMAL_PRIORITY_CLASS,NULL,NULL,ADDR startinfo, ADDR proc_info
; .If EAX
; Invoke GetCurrentThread
; Invoke SetThreadPriority,EAX,THREAD_PRIORITY_LOWEST
; ;The process has been successfully created
;
; Invoke EnableMenuItem,hMenu,IDM_MAKE_LINK,MF_GRAYED
; Invoke SendMessage,hMakeTB,TB_SETSTATE,IDM_MAKE_LINK,0
;
; Invoke EnableMenuItem,hMenu,IDM_MAKE_GO,MF_GRAYED
; Invoke SendMessage,hMakeTB,TB_SETSTATE,IDM_MAKE_GO,0
;
; Invoke EnableMenuItem,hMenu,IDM_MAKE_EXECUTE,MF_GRAYED
;
; Invoke SendMessage,hMakeTB,TB_SETCMDID,4,IDM_MAKE_STOP
; Invoke SendMessage,hMakeTB,TB_CHANGEBITMAP,IDM_MAKE_STOP,25
; Invoke InvalidateRect,hMakeTB,NULL,TRUE
;
; Invoke WaitForInputIdle,proc_info.hProcess,INFINITE
; ;Process is waiting for user input with no input pending
;
; ;No let's wait till it ends...
; @@:
; Invoke GetExitCodeProcess, proc_info.hProcess, ADDR ExitCode
; .If EAX
; .If ExitCode==STILL_ACTIVE
; JMP @B
; .Else
; Invoke CloseHandle,proc_info.hThread
; Invoke CloseHandle,proc_info.hProcess
; ;PrintText "Terminated1"
; .EndIf
; .Else
; ;Invoke TerminateProcess,proc_info.hProcess,0
; Invoke CloseHandle,proc_info.hThread
; Invoke CloseHandle,proc_info.hProcess
; ;PrintText "Terminated2"
; .EndIf
;
; MOV EAX,TRUE
; .EndIf
; RETN
;
; ;****************************************************************************
; ExecutionFailed:
; Invoke MessageBox,WinAsmHandles.hMain,Offset szExecutionError, Offset szAppName,MB_OK+MB_TASKMODAL
; RETN
;
;ExecuteThread EndP
BrowseForFile Proc hOwner:HWND,lpBrowseForWhatFiles:DWORD, hTextBox:DWORD, lpBuffer:DWORD
Local ofn:OPENFILENAME
Local Buffer[MAX_PATH]:BYTE
;Zero out the ofn struct
Invoke RtlZeroMemory,ADDR ofn,SizeOf ofn
;Setup the ofn struct
MOV ofn.lStructSize,SizeOf ofn
PUSH hOwner
POP ofn.hwndOwner
PUSH hInstance
POP ofn.hInstance
M2M ofn.lpstrFilter, lpBrowseForWhatFiles
MOV Buffer[0],0
LEA EAX,Buffer
MOV ofn.lpstrFile,EAX
MOV ofn.nMaxFile,SizeOf Buffer
MOV ofn.lpstrDefExt,NULL
MOV ofn.lpstrTitle,Offset szBrowseDialogTitle ;"Browse"
MOV ofn.Flags,OFN_EXPLORER OR OFN_FILEMUSTEXIST OR OFN_HIDEREADONLY OR OFN_PATHMUSTEXIST;OFN_ENABLEHOOK OR
;Show the Open dialog
Invoke GetOpenFileName,ADDR ofn
.If EAX
.If hTextBox
Invoke SendMessage,hTextBox,WM_SETTEXT,NULL,ADDR Buffer
.Else
Invoke lstrcpy,lpBuffer,ADDR Buffer
.EndIf
MOV EAX,TRUE
;Return Filter index as well
MOV ECX,ofn.nFilterIndex
.Else
XOR EAX,EAX
.EndIf
RET
BrowseForFile EndP
BinaryFilesDialogProc Proc Uses EBX EDI hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
Local hBinaryFilesList :HWND
Local lvc :LV_COLUMN
Local Rect :RECT
Local lvi :LVITEM
Local Buffer[MAX_PATH+1] :BYTE
Local szCounter[12] :BYTE
.If uMsg==WM_INITDIALOG
Invoke GetDlgItem,hWnd,222 ;Get List's handle
MOV hBinaryFilesList,EAX
MOV lvc.imask, LVCF_FMT
MOV lvc.fmt,LVCFMT_LEFT
Invoke SendMessage, hBinaryFilesList, LVM_INSERTCOLUMN, 0, ADDR lvc
Invoke SendMessage, hBinaryFilesList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT OR LVS_EX_LABELTIP
MOV lvi.imask,LVIF_TEXT
MOV lvi.cchTextMax,256
MOV lvi.iSubItem, 0
LEA EAX,Buffer
MOV lvi.pszText,EAX
XOR EBX,EBX
@@:
MOV lvi.iItem,EBX
INC EBX
Invoke BinToDec,EBX,ADDR Buffer
Invoke GetPrivateProfileString, Offset szBINFILES, ADDR Buffer, ADDR szNULL, ADDR Buffer, MAX_PATH, Offset FullProjectName
.If EAX!=0
Invoke SendMessage,hBinaryFilesList,LVM_INSERTITEM,0,ADDR lvi
JMP @B
.EndIf
.If EBX==1 ;i.e. no binary files
Invoke GetDlgItem,hWnd,227 ;Remove
Invoke EnableWindow,EAX,FALSE
.EndIf
MOV lvi.iItem,0
MOV lvi.iSubItem,0
MOV lvi.imask,LVIF_STATE
MOV lvi.stateMask,LVIS_SELECTED
MOV lvi.state,LVIS_SELECTED
Invoke SendMessage,hBinaryFilesList,LVM_SETITEM,0,ADDR lvi
Invoke GetWindowRect,hBinaryFilesList,ADDR Rect
Invoke GetSystemMetrics,SM_CXBORDER
MOV EBX,EAX
SHL EBX,1 ;Twice
Invoke GetWindowLong,hBinaryFilesList,GWL_STYLE
AND EAX,WS_VSCROLL
.If EAX ;i.e. If VSCROLL is present, take its width into account
Invoke GetSystemMetrics,SM_CXVSCROLL
.Else
XOR EAX,EAX
.EndIf
ADD EBX,EAX
ADD EBX,2 ;Emperical
MOV ECX,Rect.right
SUB ECX,Rect.left
SUB ECX,EBX
Invoke SendMessage, hBinaryFilesList, LVM_SETCOLUMNWIDTH, 0, ECX
.ElseIf uMsg==WM_COMMAND
MOV EAX,wParam
MOV EDX,EAX
SHR EDX,16
AND EAX,0FFFFh
.If EDX==BN_CLICKED
.If EAX==226 ;Add
LEA EDI,Buffer
Invoke BrowseForFile,hWnd,Offset BinaryFilesFilter,0,EDI
.If EAX
Invoke GetDlgItem,hWnd,222 ;Get List's handle
MOV hBinaryFilesList,EAX
MOV lvi.imask,LVIF_TEXT Or LVIF_STATE
MOV lvi.cchTextMax,256
MOV lvi.iSubItem, 0
MOV lvi.stateMask,LVIS_SELECTED
MOV lvi.state,LVIS_SELECTED
Invoke lstrlen,Offset ProjectPath
.If EAX
MOV EBX,EAX
;ESI is the pointer to the filename
ADD EBX,EDI
MOV CL,BYTE PTR [EBX]
PUSH ECX
MOV BYTE PTR [EBX],0
Invoke lstrcmpi,Offset ProjectPath,EDI
.If !EAX ;i.e. equal
INC EBX ;since BYTE PTR [EBX]=0 now
Invoke ReplaceBackSlashWithSlash,EBX
DEC EBX
MOV EDI,EBX
.EndIf
POP ECX
MOV BYTE PTR [EBX],CL
.EndIf
MOV lvi.pszText,EDI
Invoke SendMessage,hBinaryFilesList,LVM_GETITEMCOUNT,0,0
MOV lvi.iItem,EAX
Invoke SendMessage,hBinaryFilesList,LVM_INSERTITEM,0,ADDR lvi
Invoke GetDlgItem,hWnd,227 ;Remove
Invoke EnableWindow,EAX,TRUE
.EndIf
.ElseIf EAX==227 ;Remove
Invoke GetDlgItem,hWnd,222 ;Get List's handle
MOV hBinaryFilesList,EAX
Invoke SendMessage,hBinaryFilesList,LVM_GETNEXTITEM,-1, LVNI_ALL OR LVNI_SELECTED
.If EAX!=-1
PUSH EAX
Invoke SendMessage,hBinaryFilesList,LVM_DELETEITEM,EAX,0
Invoke SendMessage,hBinaryFilesList,LVM_GETITEMCOUNT,0,0
DEC EAX
POP ECX
.If ECX>EAX
MOV ECX,EAX
.EndIf
MOV lvi.iItem,ECX
MOV lvi.iSubItem,0
MOV lvi.imask,LVIF_STATE
MOV lvi.stateMask,LVIS_SELECTED
MOV lvi.state,LVIS_SELECTED
Invoke SendMessage,hBinaryFilesList,LVM_SETITEM,0,ADDR lvi
.EndIf
Invoke SendMessage,hBinaryFilesList,LVM_GETITEMCOUNT,0,0
.If !EAX
Invoke GetDlgItem,hWnd,227 ;Remove
Invoke EnableWindow,EAX,FALSE
.EndIf
.ElseIf EAX==224 ;OK
Invoke EndDialog,hWnd,FALSE ;Return Cancel
Invoke GetDlgItem,hWnd,222 ;Get List's handle
MOV hBinaryFilesList,EAX
Invoke WritePrivateProfileStruct,Offset szBINFILES,NULL,NULL,NULL,Offset FullProjectName
MOV lvi.imask,LVIF_TEXT
MOV lvi.cchTextMax,256
MOV lvi.iSubItem, 0
LEA EDX,Buffer
MOV lvi.pszText,EDX
Invoke SendMessage,hBinaryFilesList,LVM_GETITEMCOUNT,0,0
.If EAX
MOV EBX,EAX
XOR EDI,EDI
.While EDI<EBX
MOV lvi.iItem,EDI
INC EDI
Invoke SendMessage,hBinaryFilesList,LVM_GETITEM,0,ADDR lvi
Invoke BinToDec,EDI,ADDR szCounter
Invoke WritePrivateProfileString, Offset szBINFILES, ADDR szCounter, ADDR Buffer, Offset FullProjectName
.EndW
.EndIf
.Else;If EAX==225 ;Cancel
Invoke EndDialog,hWnd,FALSE ;Return Cancel
.EndIf
.EndIf
.ElseIf uMsg==WM_CLOSE
Invoke EndDialog,hWnd,FALSE
.Else
MOV EAX,FALSE
RET
.EndIf
MOV EAX,TRUE
RET
BinaryFilesDialogProc EndP
RefreshMenuItems Proc Uses EBX EDI
Local mii:MENUITEMINFO
;SetMenuBarItemsCaptions
XOR EBX,EBX
Invoke GetMenuItemCount,WinAsmHandles.hMenu
.If EAX!=11 ;i.e. Active MDI Child is MAXIMIZED
INC EBX
.EndIf
MOV mii.cbSize,SizeOf MENUITEMINFO
MOV mii.fMask,MIIM_TYPE
MOV mii.fType,MFT_STRING
MOV mii.cch,31
MOV EDI,WinAsmHandles.hMenu
MOV mii.dwTypeData,Offset szFileMenu
CALL SetMenuBarItem
MOV mii.dwTypeData,Offset szEditMenu
INC EBX
CALL SetMenuBarItem
MOV mii.dwTypeData,Offset szViewMenu
INC EBX
CALL SetMenuBarItem
MOV mii.dwTypeData,Offset szProjectMenu
INC EBX
CALL SetMenuBarItem
MOV mii.dwTypeData,Offset szFormatMenu
INC EBX
CALL SetMenuBarItem
MOV mii.dwTypeData,Offset szResourcesMenu
INC EBX
CALL SetMenuBarItem
MOV mii.dwTypeData,Offset szMakeMenu
INC EBX
CALL SetMenuBarItem
MOV mii.dwTypeData,Offset szToolsMenu
INC EBX
CALL SetMenuBarItem
MOV mii.dwTypeData,Offset szAddInsMenu
INC EBX
CALL SetMenuBarItem
MOV mii.dwTypeData,Offset szWindowMenu
INC EBX
CALL SetMenuBarItem
MOV mii.dwTypeData,Offset szHelpMenu
INC EBX
CALL SetMenuBarItem
;------------------------------------------------------------
;ForceMeasureItem for ALL Items
MOV mii.fMask,MIIM_TYPE or MIIM_DATA OR MIIM_ID OR MIIM_STATE or MIIM_SUBMENU
MOV EDI,WinAsmHandles.PopUpMenus.hFileMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hEditMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hViewMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hProjectMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hFormatMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hResourcesMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hMakeMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hSetActiveBuildMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hToolsMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hAddInsMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hWindowMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hHelpMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hNewFileMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hConvertMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hControlsMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hDialogMenu
CALL ForceMeasureItem
MOV EDI,WinAsmHandles.PopUpMenus.hInterfacePacks
CALL ForceMeasureItem
;------------------------------------------------------------
;TrayPopMenuItemCaptions
MOV mii.fMask,MIIM_TYPE
MOV mii.fType,MFT_STRING
MOV mii.cch,31
MOV mii.dwTypeData,Offset szRestore
Invoke SetMenuItemInfo,hTrayPopupMenu,0,TRUE,ADDR mii
MOV mii.dwTypeData,Offset szExit
Invoke SetMenuItemInfo,hTrayPopupMenu,2,TRUE,ADDR mii
;Out Window Context menu
MOV mii.dwTypeData,Offset szCopySelection
Invoke SetMenuItemInfo,hOutPopUpMenu,0,TRUE,ADDR mii
MOV mii.dwTypeData,Offset szCopyAllText
Invoke SetMenuItemInfo,hOutPopUpMenu,1,TRUE,ADDR mii
MOV mii.dwTypeData,Offset szSaveOutText
Invoke SetMenuItemInfo,hOutPopUpMenu,3,TRUE,ADDR mii
;------------------------------------------------------------
RET
SetMenuBarItem:
Invoke SetMenuItemInfo,EDI,EBX,TRUE,ADDR mii
RETN
ForceMeasureItem:
Invoke GetMenuItemCount,EDI
MOV EBX,EAX
.While EBX
DEC EBX
Invoke GetMenuItemInfo,EDI,EBX,TRUE,ADDR mii
.If mii.fType==MFT_OWNERDRAW ;ignore separators!!!!
;Switch to MF_STRING
Invoke ModifyMenu,EDI,EBX,MF_BYPOSITION,0,NULL
;Switch back to MF_OWNERDRAW so that WM_MEASUEITEM is sent!!!
Invoke SetMenuItemInfo,EDI,EBX,TRUE,ADDR mii
.EndIf
.EndW
RETN
RefreshMenuItems EndP
RefreshComboBoxes Proc hChild:DWORD
Invoke GetWindowLong,hChild,0
MOV ECX,[EAX].CHILDWINDOWDATA.dwTypeOfFile
.If ECX==1 || ECX==2 || ECX==51 || ECX==101 || ECX==102
PUSH EBX
MOV EBX,EAX
;Invoke GetStockObject,ANSI_FIXED_FONT
Invoke SendMessage,[EBX].CHILDWINDOWDATA.hCombo,WM_SETFONT,hFontTahoma,TRUE
Invoke SendMessage,[EBX].CHILDWINDOWDATA.hCombo,CB_GETCURSEL,0,0
PUSH EAX
Invoke SendMessage,[EBX].CHILDWINDOWDATA.hCombo,CB_DELETESTRING,0,0
Invoke SendMessage,[EBX].CHILDWINDOWDATA.hCombo,CB_INSERTSTRING,0,Offset szSelectProcedureOrGoToTop
POP EDX
Invoke SendMessage,[EBX].CHILDWINDOWDATA.hCombo,CB_SETCURSEL,EDX,0
POP EBX
.EndIf
RET
RefreshComboBoxes EndP
RefreshTahomaFont Proc
Invoke SendMessage,WinAsmHandles.hBlocksList,WM_SETFONT,hFontTahoma,FALSE
Invoke SendMessage,WinAsmHandles.hProjTab,WM_SETFONT,hFontTahoma,FALSE
Invoke SendMessage,WinAsmHandles.hProjTree,WM_SETFONT,hFontTahoma,FALSE
Invoke SendMessage,hResourcesTab,WM_SETFONT,hFontTahoma,FALSE
Invoke SendMessage,hDialogsTree,WM_SETFONT,hFontTahoma,FALSE
Invoke SendMessage,hOthersTree,WM_SETFONT,hFontTahoma,FALSE
Invoke SendMessage,hPropertiesList,WM_SETFONT,hFontTahoma,FALSE
Invoke SendMessage,hEditProperties,WM_SETFONT,hFontTahoma,FALSE
Invoke SendMessage,hSelectComboList,WM_SETFONT,hFontTahoma,FALSE
Invoke SendMessage,hStatus,WM_SETFONT,hFontTahoma,FALSE
; Invoke SendMessage,hListProcedures,WM_SETFONT,hFontTahoma,FALSE
; Invoke SendMessage,hListStructures,WM_SETFONT,hFontTahoma,FALSE
; Invoke SendMessage,hListConstants,WM_SETFONT,hFontTahoma,FALSE
; Invoke SendMessage,hListStructureMembers,WM_SETFONT,hFontTahoma,FALSE
; Invoke SendMessage,hListVariables,WM_SETFONT,hFontTahoma,FALSE
; Invoke SendMessage,hListIncludes,WM_SETFONT,hFontTahoma,FALSE
RET
RefreshTahomaFont EndP
RefreshTheRest Proc
Local tci:TCITEM
Local tvi:TVITEM
Invoke SetWindowText,WinAsmHandles.hProjExplorer,Offset szExplorer
Invoke SetWindowText,WinAsmHandles.hOutParent,Offset szOutput
Invoke SetWindowText,hToolBox,Offset szToolBox
Invoke SetWindowText,hRCOptions,Offset Offset szDialogDW
Invoke InvalidateAllDockWindows
MOV tci.imask,LVIF_TEXT
MOV tci.pszText,Offset szProject
Invoke SendMessage,WinAsmHandles.hProjTab,TCM_SETITEM,0,ADDR tci
MOV tci.pszText,Offset szBlocks
Invoke SendMessage,WinAsmHandles.hProjTab,TCM_SETITEM,1,ADDR tci
MOV tci.pszText,Offset szResources
Invoke SendMessage,WinAsmHandles.hProjTab,TCM_SETITEM,2,ADDR tci
MOV tci.pszText,Offset szDialogs
Invoke SendMessage,hResourcesTab,TCM_SETITEM,0,ADDR tci
MOV tci.pszText,Offset szOthers
Invoke SendMessage,hResourcesTab,TCM_SETITEM,1,ADDR tci
;------------------------------------------------------
;Refresh Others Tree Items
MOV tvi._mask,TVIF_TEXT
MOV tvi.cchTextMax,31
MOV tvi.pszText,Offset szOthers
MOV EAX,hOthersParentItem
MOV tvi.hItem,EAX
Invoke SendMessage,hOthersTree,TVM_SETITEM,0,ADDR tvi
MOV tvi.pszText,Offset szResources
MOV EAX,hResourcesParentItem
MOV tvi.hItem,EAX
Invoke SendMessage,hOthersTree,TVM_SETITEM,0,ADDR tvi
MOV tvi.pszText,Offset szStringTable
MOV EAX,hStringTableParentItem
MOV tvi.hItem,EAX
Invoke SendMessage,hOthersTree,TVM_SETITEM,0,ADDR tvi
MOV tvi.pszText,Offset szMenus
MOV EAX,hMenusParentItem
MOV tvi.hItem,EAX
Invoke SendMessage,hOthersTree,TVM_SETITEM,0,ADDR tvi
MOV tvi.pszText,Offset szIncFiles
MOV EAX,hIncludesParentItem
MOV tvi.hItem,EAX
Invoke SendMessage,hOthersTree,TVM_SETITEM,0,ADDR tvi
MOV tvi.pszText,Offset szAcceleratorTables
MOV EAX,hAccelTablesParentItem
MOV tvi.hItem,EAX
Invoke SendMessage,hOthersTree,TVM_SETITEM,0,ADDR tvi
MOV tvi.pszText,Offset szVersionInfo
MOV EAX,hVersionInfosParentItem
MOV tvi.hItem,EAX
Invoke SendMessage,hOthersTree,TVM_SETITEM,0,ADDR tvi
;------------------------------------------------------
;Refresh Project Tree Items
MOV tvi.pszText,Offset szASMFiles
MOV EAX,hASMFilesItem
CALL SetProjectTreeItem
MOV tvi.pszText,Offset szModules
MOV EAX,hModulesItem
CALL SetProjectTreeItem
MOV tvi.pszText,Offset szIncludeFiles
MOV EAX,hIncludeFilesItem
CALL SetProjectTreeItem
MOV tvi.pszText,Offset szResourceFiles
MOV EAX,hResourceFilesItem
CALL SetProjectTreeItem
MOV tvi.pszText,Offset szTextFiles
MOV EAX,hTextFilesItem
CALL SetProjectTreeItem
MOV tvi.pszText,Offset szBatchFiles
MOV EAX,hBatchFilesItem
CALL SetProjectTreeItem
MOV tvi.pszText,Offset szDefinitionFiles
MOV EAX,hDefFilesItem
CALL SetProjectTreeItem
MOV tvi.pszText,Offset szOtherFiles
MOV EAX,hOtherFilesItem
CALL SetProjectTreeItem
;Properties List
Invoke SendMessage, hDialogsTree, TVM_GETNEXTITEM,TVGN_CARET,NULL
.If EAX ;Handle to the selected Item
Invoke GetTreeItemParameter,hDialogsTree,EAX
Invoke SetProperties,EAX
.EndIf
Invoke EnumProjectItems,Offset RefreshComboBoxes
Invoke EnumOpenedExternalFiles,Offset RefreshComboBoxes
Invoke RefreshTahomaFont
RET
;-----------------------------------------------------
SetProperty:
Invoke SetItemText,hPropertiesList,ECX,0,EDX
RETN
;-----------------------------------------------------
SetProjectTreeItem:
MOV tvi.hItem,EAX
Invoke SendMessage,WinAsmHandles.hProjTree,TVM_SETITEM,0,ADDR tvi
RETN
RefreshTheRest EndP
CreateTahomaFont Proc
Local lf:LOGFONT
Local Buffer[MAX_PATH] :BYTE
Local dwDummy :DWORD
Local lpData :DWORD
Local lpVersionInfo :DWORD
Local puLen :DWORD
.If hFontTahoma
Invoke DeleteObject,hFontTahoma
.EndIf
Invoke RtlZeroMemory,ADDR lf,SizeOf LOGFONT
Invoke lstrcpy,ADDR lf.lfFaceName, Offset szTahomaFontName
.If ObjectsFont
MOV EAX,-12
.Else
MOV EAX,-11
.EndIf
MOV lf.lfHeight,EAX
MOV lf.lfItalic,FALSE
MOV lf.lfWeight,400
;Let's retrieve codePage of DLL
;------------------------------------------------------------------------------
Invoke GetModuleFileName,hUILib,ADDR Buffer,MAX_PATH
Invoke GetFileVersionInfoSize,ADDR Buffer,ADDR dwDummy
.If EAX
PUSH EAX
Invoke LocalAlloc,LPTR,EAX
MOV lpData,EAX
POP EDX
Invoke GetFileVersionInfo,ADDR Buffer,NULL,EDX,lpData
.If EAX