;This program loads name lists from text files and kills duplicates
;Than saves the duplicate killed list
; LISTBOX KILL DUPES
; FASM SOURCE
; If you want to compile this source code get...
; FlatASM for free at http://flatassembler.net/
format PE GUI 4.0
entry start
include 'C:\Documents and Settings\siu\Desktop\zLouie\ASM1\INCLUDE\win32a.inc'
IDM_ADD = 101 ;Menu Constant
IDM_DK = 102 ;Menu const for the save list
section '.data' data readable writeable
hprocess dd ?
ThrID dd ?
ThrIDs dd ?
lbcnt dd ?
scnt dd ?
dcnt dd ?
_crlf db 0x0d, 0x0a
linebuff rb 000000FFh ;256byte buffer for each line
txtbuff rb 000fffffh ;1000k-ish overyly huge reserved byte buffer for the file text
bwritten dd ?
_SaveName db 'nlist.txt',0
_FileName db 'list.txt',0
_title db 'LBKILLDUPES r22',0
_class db 'LBKILLDUPESr22',0
_edit db 'ListBox',0
bread dd ?
hfile dd ?
hfiles dd ?
hwnd dd ?
hinstance dd ?
edithwnd dd ?
editfont dd ?
msg MSG
wc WNDCLASS
client RECT
section '.code' code readable executable
start:
invoke GetModuleHandle,0
mov [hinstance],eax
invoke LoadIcon,0,17
mov [wc.hIcon],eax
invoke LoadCursor,0,IDC_ARROW
mov [wc.hCursor],eax
mov [wc.style],0
mov [wc.lpfnWndProc],WindowProc
mov [wc.cbClsExtra],0
mov [wc.cbWndExtra],0
mov eax,[hinstance]
mov [wc.hInstance],eax
mov [wc.hbrBackground],COLOR_WINDOW+1
mov [wc.lpszMenuName],0
mov [wc.lpszClassName],_class
invoke RegisterClass,wc
invoke LoadMenu,[hinstance],37
invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,0,0,300,300,0,eax,[hinstance],0
mov [hwnd],eax
invoke GetCurrentProcess
mov [hprocess], eax
msg_loop:
invoke GetMessage,msg,0,0,0
or eax,eax
jz end_loop
invoke TranslateMessage,msg
invoke DispatchMessage,msg
jmp msg_loop
end_loop:
invoke ExitProcess,[msg.wParam]
proc WindowProc, hwnd,wmsg,wparam,lparam
push ebx esi edi
cmp [wmsg],WM_CREATE
je wmcreate
cmp [wmsg],WM_COMMAND
je wmcommand
cmp [wmsg],WM_DESTROY
je wmdestroy
defwndproc:
invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
jmp finish
wmcreate:
invoke GetClientRect,[hwnd],client
invoke CreateWindowEx,WS_EX_CLIENTEDGE,_edit,0,LBS_HASSTRINGS+LBS_NOTIFY+WS_VISIBLE+WS_CHILD+WS_VSCROLL,[client.left],[client.top],[client.right],[client.bottom],[hwnd],0,[hinstance],0
or eax,eax
jz failed
mov [edithwnd],eax
invoke CreateFont,16,0,0,0,0,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_RASTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH+FF_DONTCARE,0
or eax,eax
jz failed
mov [editfont],eax
invoke SendMessage,[edithwnd],WM_SETFONT,eax,FALSE
xor eax,eax
jmp finish
failed:
or eax,-1
jmp finish
wmcommand:
mov eax,[wparam]
and eax,0FFFFh
cmp eax,IDM_ADD
je AddFile
cmp eax,IDM_DK
je SaveKillDupes
jmp defwndproc
AddFile:
invoke CreateThread,0,0,RADDER,0,0,ThrID
invoke CloseHandle,[ThrID]
jmp finish
SaveKillDupes:
invoke CreateThread,0,0,RSAVER,0,0,ThrIDs
invoke CloseHandle,[ThrIDs]
jmp finish
wmdestroy:
invoke DeleteObject,[editfont]
invoke PostQuitMessage,0
xor eax,eax
finish:
pop edi esi ebx
return
endp
proc RADDER
push esp
invoke SetPriorityClass,[hprocess],HIGH_PRIORITY_CLASS
invoke SetThreadPriority,[ThrID],THREAD_PRIORITY_TIME_CRITICAL
invoke CreateFile, _FileName, GENERIC_READ, FILE_SHARE_WRITE, 0, OPEN_ALWAYS, 0, 0
mov [hfile], eax
morefile:
invoke ReadFile, [hfile], txtbuff, 000FFFFFh, bread, 0
cmp eax, -1
je failedsend
cmp [bread], 0
je failedsend
mov [scnt], 00000000h
mov [dcnt], 00000000h
lea esi, [txtbuff]
dec [scnt]
dec [dcnt]
keepadding:
inc [dcnt]
fixerror:
inc [scnt]
mov ecx, [scnt]
mov edx, [dcnt]
mov byte[linebuff+edx], 00h
cmp byte[esi+ecx], 0
je endadd
cmp byte[esi+ecx], 0dh
je skipstore
mov al, byte[esi+ecx]
cmp al, 0ah
je fixerror
mov byte[linebuff+edx], al
jmp keepadding
skipstore:
cmp byte[linebuff+1], 0ah
je nextline
cmp byte[linebuff+1], 0dh
je nextline
cmp byte[linebuff+1], 00h
je nextline
invoke SendMessage, [edithwnd], LB_FINDSTRINGEXACT, 0, linebuff
cmp eax, LB_ERR
jne noadd
invoke SendMessage, [edithwnd], LB_ADDSTRING, 0, linebuff
noadd:
nextline:
mov [dcnt], 00000000h
dec [dcnt]
inc [scnt]
jmp keepadding
endadd:
invoke UpdateWindow,[hwnd]
mov [scnt], 000FFFFFh
cleanbuff:
mov ecx, [scnt]
mov byte[txtbuff+ecx], 00h
dec [scnt]
cmp [scnt], 0
je buffclear
jmp cleanbuff
buffclear:
jmp morefile
invoke CloseHandle, [hfile]
jmp finish
failedsend:
invoke CloseHandle, [hfile]
invoke SetPriorityClass,[hprocess],NORMAL_PRIORITY_CLASS
pop esp
return
endp
proc RSAVER
push esp
invoke SetThreadPriority,[ThrIDs],THREAD_PRIORITY_TIME_CRITICAL
mov [lbcnt], 00000000h
invoke CreateFile, _SaveName, GENERIC_WRITE, FILE_SHARE_WRITE, 0, CREATE_NEW, 0, 0
mov [hfiles], eax
keepsaving:
mov ecx, 000000FFh
lplnbuff:
mov byte[linebuff+ecx],00h
dec ecx
cmp ecx,0
jne lplnbuff
invoke SendMessage, [edithwnd], LB_GETTEXT, [lbcnt], linebuff
cmp eax, LB_ERR
je endsavedk
mov eax, 00000000h
dec eax
looplen:
inc eax
cmp word[linebuff+eax], 0000h
je endlen
jmp looplen
endlen:
cmp byte[linebuff+1], 0ah
je nextindex
cmp byte[linebuff+1], 0dh
je nextindex
cmp byte[linebuff+1], 00h
je nextindex
invoke WriteFile, [hfiles], linebuff, eax, bwritten, 0
invoke WriteFile, [hfiles], _crlf, 2, bwritten, 0
nextindex:
inc [lbcnt]
invoke UpdateWindow,[hwnd]
jmp keepsaving
endsavedk:
invoke CloseHandle, [hfiles]
pop esp
return
endp
section '.idata' import data readable writeable
library kernel,'KERNEL32.DLL',\
user,'USER32.DLL',\
gdi,'GDI32.DLL'
import kernel,\
GetModuleHandle,'GetModuleHandleA',\
CreateFile, 'CreateFileA',\
GetCurrentProcess,'GetCurrentProcess',\
SetPriorityClass,'SetPriorityClass',\
SetThreadPriority,'SetThreadPriority',\
ReadFile, 'ReadFile',\
WriteFile, 'WriteFile',\
CreateThread,'CreateThread',\
CloseHandle, 'CloseHandle',\
ExitProcess,'ExitProcess'
import user,\
FindWindow,'FindWindowA',\
FindWindowEx,'FindWindowExA',\
RegisterClass,'RegisterClassA',\
CreateWindowEx,'CreateWindowExA',\
DefWindowProc,'DefWindowProcA',\
SetWindowLong,'SetWindowLongA',\
RedrawWindow,'RedrawWindow',\
GetMessage,'GetMessageA',\
TranslateMessage,'TranslateMessage',\
DispatchMessage,'DispatchMessageA',\
SendMessage,'SendMessageA',\
LoadCursor,'LoadCursorA',\
LoadIcon,'LoadIconA',\
LoadMenu,'LoadMenuA',\
GetClientRect,'GetClientRect',\
MoveWindow,'MoveWindow',\
SetFocus,'SetFocus',\
MessageBox,'MessageBoxA',\
UpdateWindow,'UpdateWindow',\
PostQuitMessage,'PostQuitMessage'
import gdi,\
CreateFont,'CreateFontA',\
DeleteObject,'DeleteObject'
section '.rsrc' resource data readable
; resource directory
directory RT_MENU,menus,\
RT_ICON,icons,\
RT_GROUP_ICON,group_icons,\
RT_VERSION,versions
; resource subdirectories
resource menus,\
37,LANG_ENGLISH+SUBLANG_DEFAULT,main_menu
resource icons,\
1,LANG_NEUTRAL,icon_data
resource group_icons,\
17,LANG_NEUTRAL,main_icon
resource versions,\
1,LANG_NEUTRAL,version_info
menu main_menu
menuitem '&File',0,MFR_POPUP+MFR_END
menuitem '&SaveList nlist.txt',IDM_DK,0
menuitem '&AddFile list.txt',IDM_ADD,MFR_END
icon main_icon,icon_data,'minipad.ico'
version version_info,VOS__WINDOWS32,VFT_APP,VFT2_UNKNOWN,LANG_ENGLISH+SUBLANG_DEFAULT,0,\
'FileDescription','List Dupe Killer',\
'LegalCopyright','No rights reserved.',\
'FileVersion','1.0',\
'ProductVersion','1.0',\
'OriginalFilename','r22asmdupekiller.exe'