-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunctions.asm
1244 lines (972 loc) · 27.6 KB
/
Functions.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
UNICODE=0
MAKELONG MACRO wLow,wHigh
xor eax,eax
mov ax,wHigh
shl eax,16
mov ax,wLow
ENDM
if UNICODE
TCHAR typedef WORD
ELSE
TCHAR typedef BYTE
ENDIF
.const
song_Index TCHAR '%d. %s',0
invalid_song TCHAR '无效 %s',0
filterstr byte '音乐文件(mp3、wma、wav、APE、FLAC、MIDI、OGG、AAC)',0
byte '*.mp3;*.wma;*.wav;*.APE;*.FLAC;*.mid;*.OGG;*.m4a',0
byte '所有文件(*.*)',0
byte '*.*',0
byte 'mp3、wma\0*.mp3;*.wma',0
byte 'APE、FLAC、MIDI、OGG、AAC',0
byte '*.ape;*.flac;*.mid;*.ogg;*.m4a',0,0
lpstrDefExt byte '*.mp3',0
xiegang TCHAR '\',0
search byte '\*',0
mid byte '.mid',0
mp3 byte '.mp3',0
wma byte '.wma',0
wav byte '.wav',0
ogg byte '.OGG',0
m4a byte '.m4a',0
flac byte '.flac',0
ape byte '.ape',0
chooseFolder byte '请选择要添加的文件夹',0
szDll byte 'Player_Core.dll',0
szSpecifyMusicFileA byte 'SpecifyMusicFileA',0
szPlay_Music byte 'Play_Music',0
szPause_Music byte 'Pause_Music',0
szStop_Music byte 'Stop_Music',0
szSetMusicRate byte 'SetMusicRate',0
szSetPlayerBalance byte 'SetPlayerBalance',0
szSetPlayerVolume byte 'SetPlayerVolume',0
szGetPlayerVolume byte 'GetPlayerVolume',0
szGetPlayerCurrentPosition byte 'GetPlayerCurrentPosition',0
szSetPlayerPosition byte 'SetPlayerPosition',0
szGetCurrentState byte 'GetCurrentState',0
szGet_Length byte 'Get_Length',0
szGetCurrentAndRemainA byte 'GetCurrentAndRemainA',0
szGet_Length_StringA byte 'Get_Length_StringA',0
szError byte '无法找到Player_Core.dll,程序将退出',0
szTip byte '音乐播放器V2.001',0
szszInfoTitle byte '嘻嘻……',0
szCRTDll byte 'msvcrt.dll',0
sztime byte 'time',0
szsrand byte 'srand',0
szrand byte 'rand',0
plstname byte 5CH,'PlayList.PLST',0
.code
include strsafe.asm
AddFilesNameToPlayList PROTO nfiles:DWORD
;>>>>>>>>>>>>>>>获取控件句柄>>>>>>>>
Initiate_PlayCore proc hwnd:HWND
invoke LoadLibrary,offset szDll
.if eax
mov hinst_PlayCore,eax
invoke GetProcAddress,eax,offset szSpecifyMusicFileA
mov lpSpecifyMusicFileA,eax
invoke GetProcAddress,hinst_PlayCore,offset szPlay_Music
mov lpPlay_Music,eax
invoke GetProcAddress,hinst_PlayCore,offset szPause_Music
mov lpPause_Music,eax
invoke GetProcAddress,hinst_PlayCore,offset szStop_Music
mov lpStop_Music,eax
invoke GetProcAddress,hinst_PlayCore,offset szSetMusicRate
mov lpSetMusicRate,eax
invoke GetProcAddress,hinst_PlayCore,offset szSetPlayerBalance
mov lpSetPlayerBalance,eax
invoke GetProcAddress,hinst_PlayCore,offset szSetPlayerVolume
mov lpSetPlayerVolume,eax
invoke GetProcAddress,hinst_PlayCore,offset szGetPlayerVolume
mov lpGetPlayerVolume,eax
invoke GetProcAddress,hinst_PlayCore,offset szGetPlayerCurrentPosition
mov lpGetPlayerCurrentPosition,eax
invoke GetProcAddress,hinst_PlayCore,offset szSetPlayerPosition
mov lpSetPlayerPosition,eax
invoke GetProcAddress,hinst_PlayCore,offset szGetCurrentState
mov lpGetCurrentState,eax
invoke GetProcAddress,hinst_PlayCore,offset szGet_Length
mov lpGet_Length,eax
invoke GetProcAddress,hinst_PlayCore,offset szGetCurrentAndRemainA
mov lpGetCurrentAndRemainA,eax
invoke GetProcAddress,hinst_PlayCore,offset szGet_Length_StringA
mov lpGet_Length_StringA,eax
.else
invoke MessageBox,hwnd,offset szError,offset szError,MB_OK
invoke ExitProcess,1
.endif
ret
Initiate_PlayCore endp
Initiate_CRT proc
push ebp
mov ebp,esp
invoke LoadLibrary,offset szCRTDll
.if eax
push eax
invoke GetProcAddress,eax,offset sztime
mov lptime,eax
pop eax
push eax
invoke GetProcAddress,eax,offset szsrand
mov lpsrand,eax
pop eax
push eax
invoke GetProcAddress,eax,offset szrand
mov lprand,eax
.endif
leave
ret
Initiate_CRT endp
GetControlsHandle PROC hDlg:HWND
invoke GetDlgItem,hDlg,IDC_BTN_ABOVE
mov g_hCtl.hBTN_ABOVE,eax
invoke GetDlgItem,hDlg,IDC_BTN_NEXT
mov g_hCtl.hBTN_NEXT,eax
invoke GetDlgItem,hDlg,IDC_BTN_PLAY_PAUSE
mov g_hCtl.hBTN_PLAY_PAUSE,eax
invoke GetDlgItem,hDlg,IDC_BTN_STOP
mov g_hCtl.hBTN_STOP,eax
invoke GetDlgItem,hDlg,IDC_CHK_MUTE
mov g_hCtl.hCHK_MUTE,eax
invoke GetDlgItem,hDlg,IDC_LST_PLAYLIST
mov g_hCtl.hLST_PLAYLIST,eax
invoke GetDlgItem,hDlg,IDC_STC_CURRENT
mov g_hCtl.hSTC_CURRENT,eax
invoke GetDlgItem,hDlg,IDC_STC_REMAIN
mov g_hCtl.hSTC_REMAIN,eax
invoke GetDlgItem,hDlg,IDC_TRB_PROGRESS
mov g_hCtl.hTRB_PROGRESS,eax
invoke GetDlgItem,hDlg,IDC_TRB_SETBALANCE
mov g_hCtl.hTRB_SETBALANCE,eax
invoke GetDlgItem,hDlg,IDC_TRB_SETVOLUME
mov g_hCtl.hTRB_SETVOLUME,eax
invoke GetDlgItem,hDlg,IDC_UDN1
mov g_hCtl.hIDC_UDN1,eax
xor eax,eax
ret
GetControlsHandle ENDP
InitiateControls PROC
; 设置声道平衡控件
;相当于MAKELONG(0,200)
MAKELONG 0,200
invoke SendMessage,g_hCtl.hTRB_SETBALANCE,TBM_SETRANGE,TRUE,eax
;设置声道平衡控件默认位置
invoke SendMessage,g_hCtl.hTRB_SETBALANCE,TBM_SETPOS,TRUE,100
invoke SendMessage,g_hCtl.hTRB_SETBALANCE,TBM_SETTICFREQ,10,0
invoke SendMessage,g_hCtl.hTRB_SETBALANCE,TBM_SETLINESIZE,0,10
invoke SendMessage,g_hCtl.hTRB_SETBALANCE,TBM_SETPAGESIZE,0,10
;设置播放列表行高度
invoke SendMessage,g_hCtl.hLST_PLAYLIST,LB_SETITEMHEIGHT,0,17
;设置音量控件
MAKELONG 0,1000
invoke SendMessage,g_hCtl.hTRB_SETVOLUME,TBM_SETRANGE,TRUE,eax
invoke SendMessage,g_hCtl.hTRB_SETVOLUME,TBM_SETLINESIZE,0,50
invoke SendMessage,g_hCtl.hTRB_SETVOLUME,TBM_SETPAGESIZE,0,50
invoke SendMessage,g_hCtl.hTRB_SETVOLUME,TBM_SETTICFREQ,50,0
xor eax,eax
ret
InitiateControls endp
AddFiles PROC hDlg:HWND
LOCAL szfiledata:dword,hHeap:dword
LOCAL ofn:OPENFILENAME
LOCAL szFilesPath[MAX_PATH]:TCHAR
LOCAL fileNamePointer:DWORD,nlen:DWORD,nAddFilesCount:DWORD
invoke GetProcessHeap
.if eax !=NULL
mov hHeap,eax ; 保存进程堆的句柄
invoke HeapAlloc,eax,HEAP_ZERO_MEMORY,256*MAX_PATH ; 分配堆空间
.if eax !=NULL
mov szfiledata,eax ; 保存所分配的堆的指针
invoke RtlZeroMemory,addr ofn,sizeof OPENFILENAME
mov ofn.lStructSize,sizeof OPENFILENAME
mov eax,hDlg
mov ofn.hwndOwner,eax
mov ofn.lpstrFilter,offset filterstr
mov ofn.lpstrCustomFilter,NULL
mov ofn.nFilterIndex,1
mov ofn.nMaxFile,256*MAX_PATH
mov eax,szfiledata
mov ofn.lpstrFile,eax
mov byte ptr [eax],0
mov ofn.lpstrFileTitle,NULL
mov ofn.nMaxFileTitle,0
mov ofn.lpstrTitle,NULL
mov ofn.Flags,81A04H ;OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_EXPLORER|OFN_ALLOWMULTISELECT
invoke GetOpenFileName,addr ofn
.IF eax !=0
invoke RtlZeroMemory,addr szFilesPath,MAX_PATH ; szFilesPath清零
mov fileNamePointer,NULL
mov nlen,0
mov nAddFilesCount,0
movzx eax,word ptr [ebp-1Ch] ; ofn.nFileOffset入栈
push eax
push dword ptr [szfiledata] ; szfiledata入栈
push 104h ; MAX_PATH入栈
lea eax,szFilesPath
push eax ;szFilesPath 入栈
call StringCchCopyN ; 将路径复制到szFilesPath中,不包括'\'
invoke StringCchCat,addr szFilesPath,MAX_PATH,offset xiegang
movzx eax,ofn.nFileOffset
mov ebx,szfiledata
add ebx,eax
mov fileNamePointer,ebx
mov ecx,fileNamePointer
.while byte ptr [ecx] !=0
mov ebx,offset filesinfo.szFilePath ; filesinfo->szFilePath[lpfilesinfo->iCountOfFiles]
mov eax,filesinfo.iCountOfFiles
mov ecx,MAX_PATH
mul ecx
add ebx,eax
push ebx ; 保存filesinfo->szFilePath[lpfilesinfo->iCountOfFiles]的地址
invoke StringCchCopy,ebx,MAX_PATH,addr szFilesPath
pop ebx
invoke StringCchCat,ebx,MAX_PATH,fileNamePointer
invoke StringCchLength,fileNamePointer,MAX_PATH,addr nlen
inc nlen
mov eax,nlen
add fileNamePointer,eax
inc filesinfo.iCountOfFiles
inc nAddFilesCount
mov ecx,fileNamePointer
.endw
invoke AddFilesNameToPlayList,nAddFilesCount
.ENDIF ; end
invoke HeapFree,hHeap,HEAP_NO_SERIALIZE,szfiledata ; 释放所分配的堆
.endif
.endif
xor eax,eax
ret
AddFiles ENDP
AddFilesNameToPlayList PROC nfiles:DWORD
LOCAL looptime:DWORD
LOCAL szAddMark[MAX_PATH]:TCHAR,szTempstring[MAX_PATH]:TCHAR,szTempstring2[MAX_PATH]:TCHAR
mov eax,filesinfo.iCountOfFiles
sub eax,nfiles
mov looptime,eax
; for repeat begain
cmp filesinfo.iCountOfFiles,0
je end_for
cmp filesinfo.iCountOfFiles,256
jae end_for
jmp for_cmp
for_3th:inc DWORD PTR looptime
dec DWORD PTR nfiles
for_cmp:cmp nfiles,0
je end_for
mov ebx,offset filesinfo.szFilePath ; filesinfo->szFilePath[loop]
mov eax,looptime
mov ecx,MAX_PATH
mul ecx
add ebx,eax
push ebx ; 保存filesinfo->szFilePath[loop]的地址
invoke StringCchCopy,addr szAddMark,MAX_PATH,ebx
invoke PathRemoveExtension,addr szAddMark
invoke PathFindFileName,addr szAddMark
push eax ;StringCchPrintf倒数第一个参数
mov ecx,looptime
inc ecx
push ecx ;StringCchPrintf倒数第二个参数
push offset song_Index ;StringCchPrintf倒数第三个参数
push MAX_PATH ;StringCchPrintf倒数第四个参数
lea eax, szTempstring
push eax ;StringCchPrintf倒数第五个参数
call StringCchPrintf
add esp,20 ; 处理堆栈
invoke StringCchCopy,addr szTempstring2,MAX_PATH,addr szTempstring
pop ebx
invoke PathFileExists,ebx
cmp eax,TRUE
je sendmsg
invoke StringCchPrintf,addr szTempstring2,MAX_PATH,offset invalid_song,addr szTempstring
sendmsg:
invoke SendMessage,g_hCtl.hLST_PLAYLIST,LB_ADDSTRING,0,addr szTempstring2
jmp for_3th
end_for:xor eax,eax
ret
AddFilesNameToPlayList endp
DisableControls proc
invoke EnableMenuItem,g_hPlayList_Menu,IDM_PlayCurrentSelect,3 ; 3= MF_DISABLED|MF_GRAYED
invoke EnableMenuItem,g_hPlayList_Menu,IDM_DELETE,3
invoke EnableMenuItem,g_hPlayList_Menu,IDM_CLEAR,3
invoke EnableWindow,g_hCtl.hBTN_STOP,FALSE
invoke EnableWindow,g_hCtl.hBTN_ABOVE,FALSE
invoke EnableWindow,g_hCtl.hBTN_PLAY_PAUSE,FALSE
invoke EnableWindow,g_hCtl.hBTN_NEXT,FALSE
invoke EnableWindow,g_hCtl.hTRB_PROGRESS,FALSE
invoke EnableWindow,g_hCtl.hIDC_UDN1,FALSE
ret
DisableControls endp
EnableControls proc
invoke EnableMenuItem,g_hPlayList_Menu,IDM_PlayCurrentSelect,MF_ENABLED
invoke EnableMenuItem,g_hPlayList_Menu,IDM_DELETE,MF_ENABLED
invoke EnableMenuItem,g_hPlayList_Menu,IDM_CLEAR,MF_ENABLED
invoke EnableWindow,g_hCtl.hBTN_STOP,TRUE
invoke EnableWindow,g_hCtl.hBTN_ABOVE,TRUE
invoke EnableWindow,g_hCtl.hBTN_PLAY_PAUSE,TRUE
invoke EnableWindow,g_hCtl.hBTN_NEXT,TRUE
invoke EnableWindow,g_hCtl.hTRB_PROGRESS,TRUE
invoke EnableWindow,g_hCtl.hIDC_UDN1,TRUE
ret
EnableControls endp
CompareExtension proto lpExt:dword
AddDropFilesToList proc hDropFiles:DWORD,hdlg:DWORD
LOCAL szFilename[MAX_PATH]:byte
LOCAL nFileCount:DWORD,i:DWORD
mov nFileCount,0
mov i,0
invoke DragQueryFile,hDropFiles,0ffffffffh,NULL, 0
mov nFileCount,eax
.if (eax>0)
;begin for
jmp for_begin
for_add:inc i
for_begin:
mov eax,i
cmp eax,nFileCount
jge for_end
invoke DragQueryFile,hDropFiles,i,addr szFilename,MAX_PATH
invoke CompareExtension,addr szFilename
.if eax
mov ebx,offset filesinfo.szFilePath ; lpsfi->szFilePath[lpsfi->iCountOfFiles]
mov eax,filesinfo.iCountOfFiles;
mov ecx,MAX_PATH
mul ecx
add ebx,eax
invoke StringCchCopy,ebx,MAX_PATH,addr szFilename
inc filesinfo.iCountOfFiles
.endif
jmp for_add
.endif
for_end:
invoke DragFinish,hDropFiles
invoke SendMessage,g_hCtl.hLST_PLAYLIST,LB_RESETCONTENT,0,0
invoke AddFilesNameToPlayList,filesinfo.iCountOfFiles
ret
AddDropFilesToList endp
CompareExtension proc lpExt:dword
LOCAL bequal:dword
mov bequal,TRUE
invoke CompareString,LOCALE_USER_DEFAULT,5h,lpExt,-1,offset mid,-1
.if eax != 2;CSTR_EQUAL
invoke CompareString,LOCALE_USER_DEFAULT,5h,lpExt,-1,offset mp3,-1
.if eax !=2
invoke CompareString,LOCALE_USER_DEFAULT,5h,lpExt,-1,offset wma,-1
.if eax !=2
invoke CompareString,LOCALE_USER_DEFAULT,5h,lpExt,-1,offset wav,-1
.if eax !=2
invoke CompareString,LOCALE_USER_DEFAULT,5h,lpExt,-1,offset ogg,-1
.if eax !=2
invoke CompareString,LOCALE_USER_DEFAULT,5h,lpExt,-1,offset m4a,-1
.if eax !=2
invoke CompareString,LOCALE_USER_DEFAULT,5h,lpExt,-1,offset flac,-1
.if eax !=2
invoke CompareString,LOCALE_USER_DEFAULT,5h,lpExt,-1,offset ape,-1
.if eax !=2
mov bequal,FALSE
.endif
.endif
.endif
.endif
.endif
.endif
.endif
.endif
ret
CompareExtension endp
SearchFilesCondition proc lpSearchPath:DWORD,lpFileExtension:DWORD
LOCAL szTempPath[2*MAX_PATH]:byte,hFindFile:HANDLE,sfd:WIN32_FIND_DATA
LOCAL nCountOfFiles:DWORD
invoke RtlZeroMemory,addr szTempPath,2*MAX_PATH
invoke StringCchCat,addr szTempPath,2*MAX_PATH,lpSearchPath
invoke StringCchCat,addr szTempPath,2*MAX_PATH,offset search
invoke StringCchCat,addr szTempPath,2*MAX_PATH,lpFileExtension
invoke FindFirstFile,addr szTempPath,addr sfd
.if eax != INVALID_HANDLE_VALUE
mov hFindFile,eax
mov nCountOfFiles,0
do:
.if sfd.cFileName ==2eH ; '.'=2eH
jmp do_while
.endif
mov ebx,offset filesinfo.szFilePath ; lpsfi->szFilePath[lpsfi->iCountOfFiles]
mov eax,filesinfo.iCountOfFiles;
mov ecx,MAX_PATH
mul ecx
add ebx,eax
push ebx ; 保存lpsfi->szFilePath[lpsfi->iCountOfFiles]
invoke StringCchCopy,ebx,MAX_PATH,lpSearchPath
pop ebx
push ebx
invoke StringCchCat,ebx,MAX_PATH,offset xiegang
pop ebx
invoke StringCchCat,ebx,MAX_PATH,addr sfd.cFileName
inc nCountOfFiles
inc filesinfo.iCountOfFiles
do_while:
invoke FindNextFile,hFindFile,addr sfd
cmp eax,TRUE
je do
invoke AddFilesNameToPlayList,nCountOfFiles
.endif
ret
SearchFilesCondition endp
AddFolder proc hdlg:HWND
LOCAL sBrowseInfo:BROWSEINFO,lpitem:DWORD
LOCAL szBuffer_Directory[2*MAX_PATH]:byte
invoke RtlZeroMemory,addr sBrowseInfo,sizeof sBrowseInfo
mov eax,hdlg
mov sBrowseInfo.hwndOwner,eax
mov sBrowseInfo.lpszTitle,offset chooseFolder
mov sBrowseInfo.ulFlags,1001H ; 1001=BIF_RETURNONLYFSDIRS|BIF_BROWSEFORCOMPUTER
invoke SHBrowseForFolder,addr sBrowseInfo
.if eax
mov lpitem,eax
invoke RtlZeroMemory,addr szBuffer_Directory,2*MAX_PATH
invoke SHGetPathFromIDList,lpitem,addr szBuffer_Directory
invoke SearchFilesCondition,addr szBuffer_Directory,offset mp3
invoke SearchFilesCondition,addr szBuffer_Directory,offset wma
invoke SearchFilesCondition,addr szBuffer_Directory,offset wav
invoke SearchFilesCondition,addr szBuffer_Directory,offset ape
invoke SearchFilesCondition,addr szBuffer_Directory,offset flac
invoke SearchFilesCondition,addr szBuffer_Directory,offset mid
invoke SearchFilesCondition,addr szBuffer_Directory,offset m4a
invoke SearchFilesCondition,addr szBuffer_Directory,offset ogg
.endif
ret
AddFolder endp
GetNextPlayIndex proc nPlayMode:UINT,nCurrentPlayIndex:DWORD
.if nPlayMode==IDM_Random
mov eax,rNums.nNumsCount
.if (eax<filesinfo.iCountOfFiles)
lea ebx,rNums.arrayNums
add ebx,eax
movzx eax,byte ptr [ebx]
inc rNums.nNumsCount
ret
.else
mov eax,-1
ret
.endif
.elseif nPlayMode==IDM_Sortorder
inc nCurrentPlayIndex
mov eax,nCurrentPlayIndex
.if eax<filesinfo.iCountOfFiles
ret
.else
mov eax,0
ret
.endif
.elseif ((nPlayMode==IDM_SingleLoop)||(nPlayMode==IDM_Loop))
inc nCurrentPlayIndex
mov eax,nCurrentPlayIndex
mov ecx,filesinfo.iCountOfFiles
div ecx
mov eax,edx
ret
.endif
mov eax,-1
ret
GetNextPlayIndex endp
AddNodifyIcon proc hWnd:HWND
mov AppNodifyIcon.cbSize,sizeof NOTIFYICONDATA
mov eax,hWnd
mov AppNodifyIcon.hwnd,eax
mov AppNodifyIcon.uID,IDC_NODIFYICON
mov AppNodifyIcon.uFlags,17H; NIF_ICON|NIF_MESSAGE|NIF_TIP|NIF_INFO
mov AppNodifyIcon.uCallbackMessage,WM_COMMAND
invoke GetWindowLong,hWnd,GWL_HINSTANCE
invoke LoadIcon,eax,IDC_NODIFYICON
mov AppNodifyIcon.hIcon,eax
invoke StringCchCopy,addr AppNodifyIcon.szTip,64,offset szTip
invoke StringCchCopy,addr AppNodifyIcon.szInfo,256,offset szTip
invoke StringCchCopy,addr AppNodifyIcon.szInfoTitle,64,offset szszInfoTitle
mov AppNodifyIcon.dwInfoFlags,11H ;NIIF_INFO|NIIF_NOSOUND
mov AppNodifyIcon.dwStateMask,1h ; NIS_HIDDEN
mov AppNodifyIcon.dwState,1h
invoke Shell_NotifyIcon,NIM_ADD,addr AppNodifyIcon
mov eax,TRUE
ret
AddNodifyIcon endp
GetAbovePlayIndex proc nPlayMode:UINT,nCurrentPlayIndex:DWORD
.if nPlayMode==IDM_Random
mov eax,rNums.nNumsCount
.if ( eax >=0 )
lea ebx,rNums.arrayNums
add ebx,eax
movzx eax,byte ptr [ebx]
dec rNums.nNumsCount
ret
.else
mov eax,-1
ret
.endif
.elseif nPlayMode==IDM_Sortorder
dec nCurrentPlayIndex
mov eax,nCurrentPlayIndex
cmp eax,0
jl _else
.if eax>=0
ret
_else:
mov eax,filesinfo.iCountOfFiles
dec eax
ret
.endif
.elseif ((nPlayMode==IDM_SingleLoop)||(nPlayMode==IDM_Loop))
mov eax,nCurrentPlayIndex
.if (eax!=0)
dec eax
ret
.else
mov eax,filesinfo.iCountOfFiles
dec eax
ret
.endif
.endif
mov eax,-1
ret
GetAbovePlayIndex endp
DeleteItem proc nBeDeleted:DWORD
LOCAL sfsiTemp:DWORD,nLoops:DWORD,hHeap:DWORD
mov nLoops,0
invoke GetProcessHeap
.if eax !=NULL
mov hHeap,eax ; 保存进程堆的句柄
invoke HeapAlloc,eax,HEAP_ZERO_MEMORY,sizeof FILESINFO ; 分配堆空间
.if eax !=NULL
mov sfsiTemp,eax ; 保存所分配的堆的指针
invoke RtlZeroMemory,sfsiTemp,sizeof FILESINFO
mov eax,nLoops
.while (eax<filesinfo.iCountOfFiles)
.if eax==nBeDeleted
inc nLoops
inc eax
.continue
.endif
lea esi,filesinfo.szFilePath
mov ecx,MAX_PATH
mov eax,nLoops
mul ecx
add esi,eax
push esi
push MAX_PATH
mov ebx,sfsiTemp;sfsiTemp.szFilePath
mov eax,DWORD PTR [ebx+256*MAX_PATH]; sfsiTemp.iCountOfFiles
mov ecx,MAX_PATH
mul ecx
add ebx,eax
push ebx
call StringCchCopy
mov ebx,sfsiTemp;sfsiTemp
inc DWORD PTR [ebx+256*MAX_PATH]
inc nLoops
mov eax,nLoops
.endw
lea edi,filesinfo
mov esi,sfsiTemp
mov ecx,4101H; sizeof FILESINFO/4
rep movsd
invoke HeapFree,hHeap,HEAP_NO_SERIALIZE,sfsiTemp ; 释放所分配的堆
.endif
.endif
invoke SendMessage,g_hCtl.hLST_PLAYLIST,LB_RESETCONTENT,0,0
invoke AddFilesNameToPlayList,filesinfo.iCountOfFiles
ret
DeleteItem endp
Main_AboutProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.if uMsg==WM_COMMAND
mov eax,wParam
.if ax==IDC_BTN
invoke EndDialog,hWnd,0
.endif
.endif
mov eax,FALSE
ret
Main_AboutProc endp
GetrandomNumbers proc
LOCAL i,ncheck,randnum
push NULL
call lptime
add esp,4
push eax
call lpsrand
add esp,4
.if filesinfo.iCountOfFiles==0
mov byte ptr rNums,0
mov rNums.nNumsCount,0
ret
.elseif filesinfo.iCountOfFiles==1
mov byte ptr rNums,0
mov rNums.nNumsCount,1
ret
.endif
call lprand
mov ecx,filesinfo.iCountOfFiles
div ecx
mov rNums.arrayNums,dl
mov rNums.nNumsCount,1
mov i,1
jmp for_loop_cmp
for_loop:
inc i
for_loop_cmp:
mov eax,i
cmp filesinfo.iCountOfFiles,eax
jbe for_loop_end
call lprand ;rand()
mov ecx,filesinfo.iCountOfFiles
div ecx
mov randnum,edx ; rand()%filesinfo.iCountOfFiles
mov ncheck,0
jmp for_check_cmp
for_check:
inc ncheck
for_check_cmp:
mov eax,ncheck
cmp rNums.nNumsCount,eax
jbe for_check_end
lea ebx,rNums.arrayNums
mov ecx,ncheck
movzx eax,byte ptr [ebx+ecx]
.if randnum==eax
call lprand
mov ecx,filesinfo.iCountOfFiles
div ecx
mov randnum,edx
mov ncheck,-1
.endif
jmp for_check
for_check_end:
lea ebx,rNums.arrayNums
mov ecx,i
mov eax,randnum
mov byte ptr [ebx+ecx],al
inc rNums.nNumsCount
jmp for_loop
for_loop_end:
mov rNums.nNumsCount,0
ret
GetrandomNumbers endp
RefillFilesInfo proc nNoNeedToCopy:DWORD
LOCAL nHaveLooped:DWORD,lpsfi:DWORD,hHeap
invoke GetProcessHeap
.if eax !=NULL
mov hHeap,eax ; 保存进程堆的句柄
invoke HeapAlloc,eax,HEAP_ZERO_MEMORY,sizeof FILESINFO ; 分配堆空间
.if eax !=NULL
mov lpsfi,eax ; 保存所分配的堆的指针
invoke RtlZeroMemory,lpsfi,sizeof FILESINFO
mov ebx,lpsfi
mov eax,256*MAX_PATH
mov edx,filesinfo.iCountOfFiles
mov dword ptr [ebx+eax],edx
.if nNoNeedToCopy==0
mov nHaveLooped,1
mov eax,nHaveLooped
.while eax<filesinfo.iCountOfFiles
lea esi,filesinfo.szFilePath
mov ecx,nHaveLooped
mov eax,MAX_PATH
mul ecx
add esi,eax
mov edi,lpsfi
mov eax,MAX_PATH
dec ecx
mul ecx
add edi,eax
invoke StringCchCopy,edi,MAX_PATH,esi
inc nHaveLooped
mov eax,nHaveLooped
.endw
mov edi,lpsfi ;sfi.szFilePath[nHaveLooped-1]
mov eax,MAX_PATH
mov ecx,nHaveLooped
dec ecx
mul ecx
add edi,eax
lea esi,filesinfo.szFilePath
invoke StringCchCopy,edi,MAX_PATH,esi
.else
mov nHaveLooped,0
mov edi,lpsfi
lea esi,filesinfo.szFilePath
mov ecx,MAX_PATH
mov eax,filesinfo.iCountOfFiles
dec eax
mul ecx
add esi,eax
invoke StringCchCopy,edi,MAX_PATH,esi
mov eax,nHaveLooped
mov ecx,filesinfo.iCountOfFiles
dec ecx
.while eax<ecx
lea esi,filesinfo.szFilePath
mov ecx,MAX_PATH
mul ecx
add esi,eax
mov edi,lpsfi
mov eax,nHaveLooped
inc eax
mov ecx,MAX_PATH
mul ecx
add edi,eax
invoke StringCchCopy,edi,MAX_PATH,esi
inc nHaveLooped
mov eax,nHaveLooped
mov ecx,filesinfo.iCountOfFiles
dec ecx
.endw
.endif
lea edi,filesinfo
mov esi,lpsfi
mov ecx,4101H; sizeof FILESINFO/4
rep movsd
invoke HeapFree,hHeap,HEAP_NO_SERIALIZE,lpsfi ; 释放所分配的堆
.endif
.endif
ret
RefillFilesInfo endp
MoveUp proc ;lpnCurrentPlay:DWORD,hdlg:DWORD
LOCAL szTemp[MAX_PATH]:byte,nIndexDest,nIndexSrc
invoke SendMessage,g_hCtl.hLST_PLAYLIST,LB_GETCURSEL,0,0
mov nIndexSrc,eax
.if (eax!=0)
mov eax,nIndexSrc
dec eax
mov nIndexDest,eax
lea esi,filesinfo.szFilePath
mov eax,MAX_PATH
mov ecx,nIndexDest
mul ecx
add esi,eax
push esi ;保存lpfsi->szFilePath[nIndexDest]
lea edi,szTemp
invoke StringCchCopy,edi,MAX_PATH,esi
lea esi,filesinfo.szFilePath
mov eax,MAX_PATH
mov ecx,nIndexSrc
mul ecx
add esi,eax
pop edi
push esi ; 保存lpfsi->szFilePath[nIndexSrc]
invoke StringCchCopy,edi,MAX_PATH,esi
pop edi
invoke StringCchCopy,edi,MAX_PATH,addr szTemp
.else
invoke RefillFilesInfo,0
mov eax,filesinfo.iCountOfFiles
dec eax
mov nIndexDest,eax
.endif
invoke SendMessage,g_hCtl.hLST_PLAYLIST,LB_RESETCONTENT,0,0
invoke AddFilesNameToPlayList,filesinfo.iCountOfFiles
invoke SendMessage,g_hCtl.hLST_PLAYLIST,LB_SETCURSEL,nIndexDest,0
mov eax,nIndexDest
mov g_currentPlayIndex,eax
ret
MoveUp endp
MoveDown proc
LOCAL szTemp[MAX_PATH]:byte,nIndexDest,nIndexSrc
invoke SendMessage,g_hCtl.hLST_PLAYLIST,LB_GETCURSEL,0,0
mov nIndexSrc,eax
mov eax,filesinfo.iCountOfFiles
dec eax
.if eax!=nIndexSrc
mov eax,nIndexSrc
inc eax
mov nIndexDest,eax
lea edi,szTemp
lea esi,filesinfo.szFilePath
mov ecx,MAX_PATH
mul ecx
add esi,eax
push esi ; 保存filesinfo.szFilePath[nIndexDest]
invoke StringCchCopy,edi,MAX_PATH,esi