find files of certain type...

Reply

Join Date: Nov 2006
Posts: 11
Reputation: seth0x2b is an unknown quantity at this point 
Solved Threads: 0
seth0x2b seth0x2b is offline Offline
Newbie Poster

find files of certain type...

 
0
  #1
Nov 27th, 2006
Hey guys.
First of all its nice to see an assemly forum that still has visitors..everything I found on the net are old forums unvisited for about 2-3 years.

I started learning win32 assembly ...well..last night .
I do have (some) programming background in Delphi and some c/c++, and also ye old Z80-machine code (those were the days... ).
I kept myself away from ASM because of my contact with Z80 ....since that was a very hard to "master" language (for me anyways...)...in comparison to pascal/delphi.

But looking at a source on some forum last night I was amased to see that win32 assembly is somewhat logical...and this is the reason I'm stickin to it for the time being.

That being said..today I had a little "argument" with my fellow programmer friends. We all used Delphi and passed on to vc++

I anounced my new discovered love for win32 asm and I got a few good laughs.
Now it's my turn .I'd like to prove that win32 asm is (almost) as easy and logical as any c++ code, just a lot faster(I think/guess..).

The "contest" is this:

Search the entire harddrive(all partitions...) for a file of given type, and output the search results to a text file....

I'd apreciate any suggestions/hints/source you guys can provide..
I'm using MASM32

Cheers and thanks in advance

P.S. BTW I'm not in highschool so this is not homework..I know you guys are pretty much against students that want to get away with having someone else doing they're homework fore them...
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,334
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1454
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: find files of certain type...

 
0
  #2
Nov 27th, 2006
1st: there is no such thing as "win32 asm". win32 is an operating system that runs on top of the hardware Intell and Intell-look-alike chips. what you really mean I presume is 80x88 and Pentium assembly code.

Yes it can be done in assembly, afterall all C compilers compile everything down to assembly code. But what you want to do with modern 32-bit programs that run in protected mode is just a lot easier to do with a C or C++ compiler. An assembly program is not allowed to make direct interrupt calls in 32-bit protected-mode programs. You can do that in 16-bit real-mode programs, but the program will not be able to process all the space on today's huge hard drives -- I think they are limited to 2 gig drives/partitions.

As for speed -- just because its hand-writen assembly code doesn't mean it will be faster than the code generated by a good, modern optimizing C/C++ compiler. The speed of todays RAM -- mine is 2.5 Gz -- and new compilers have made hand-writing assembly almost a thing of the past.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,600
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 462
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: find files of certain type...

 
0
  #3
Nov 27th, 2006
Originally Posted by Ancient Dragon View Post
The speed of todays RAM -- mine is 2.5 Gz
Speed of RAM....2.5 GHz ?
I thought it was still in MHz
The latest one is I think 333 MHz. Maybe you wanted to say Processor speed.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 11
Reputation: seth0x2b is an unknown quantity at this point 
Solved Threads: 0
seth0x2b seth0x2b is offline Offline
Newbie Poster

Re: find files of certain type...

 
0
  #4
Nov 27th, 2006
Ok...I got the term wrong...I told you I'm new ...

I got the term from http://win32assembly.online.fr/ and the site seems to be very popular....

I know I could do what I want alot easier/faster in c++, and on my computer the speed difference would probably be un-noticeable

I'm sure there's no real reson for me to start learning about asm when I could simply use c++, but since programming for me is just a hobby, and nothing more, I want to learn asm too...

Still waiting for some info ....

Cheers
Last edited by seth0x2b; Nov 27th, 2006 at 3:40 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,334
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1454
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: find files of certain type...

 
0
  #5
Nov 27th, 2006
Thanks for that link -- seems to have a lot of good information. I'd suggest you work through the tutorials they have and by the time you get done with them you might know how to do the file i/o you are asking about.

My guess is that you will need to call the win32 api functions FindFirstFile() and FindNextFile() to get a list of all the files. I don't know the details about the assembly code they use, but they are more than likely calling some kernel-level functions.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 11
Reputation: seth0x2b is an unknown quantity at this point 
Solved Threads: 0
seth0x2b seth0x2b is offline Offline
Newbie Poster

Re: find files of certain type...

 
0
  #6
Nov 27th, 2006
I'm actually surprised you diidn't know about that page..it's among the first I read when searching for asm tutorials...

BTW..here's what I use in c++ to achieve what I want to do now in asm:


  1.  
  2. CString theLog = "images.txt";
  3. ofstream indexfile;
  4.  
  5.  
  6. int writeLog(CString line)
  7. {
  8. indexfile << line << endl;
  9. return 0;
  10. }
  11.  
  12.  
  13. void find( const std::string& filter, const std::string& directory, bool subfolders = true )
  14. {
  15. WIN32_FIND_DATA find_data;
  16. HANDLE find_handle;
  17.  
  18. find_handle = FindFirstFile( (directory + filter).c_str(), &find_data );
  19.  
  20. if( find_handle != INVALID_HANDLE_VALUE )
  21. {
  22. do
  23. {
  24. CString foundline = ((directory + find_data.cFileName).c_str());
  25. writeLog(foundline); //at this point write the found filename...
  26. }while( FindNextFile( find_handle, &find_data ) );
  27. FindClose( find_handle );
  28. }
  29. if( subfolders )
  30. {
  31. find_handle = FindFirstFile( (directory + "*").c_str(), &find_data );
  32. do
  33. {
  34. if( find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
  35. {
  36. if( strcmp( find_data.cFileName, "." ) != 0 && strcmp( find_data.cFileName, ".." ) != 0 )
  37. find( filter, directory + std::string(find_data.cFileName) + "\\", subfolders );
  38.  
  39. }
  40. }while( FindNextFile( find_handle, &find_data ) );
  41.  
  42. FindClose( find_handle );
  43. }
  44. }
  45.  
  46.  
  47.  
  48. int getFiles()
  49. {
  50.  
  51. CString Drives[26];
  52. CString drive;
  53. int numdrives = 0;
  54. char curletter = 'c';
  55. while(curletter != 'z')
  56. {
  57. drive = "";
  58. drive += curletter;
  59. drive += ":\\";
  60.  
  61. if(GetDriveType(drive) == DRIVE_FIXED)
  62. {
  63. Drives[numdrives] = drive;
  64. numdrives++;
  65. }
  66. curletter++;
  67. }
  68. int c;
  69. for(c=0;c<numdrives;c++){
  70. find( "*.jpg", (LPCSTR)Drives[c],true);
  71. }
  72.  
  73.  
  74. return 0;
  75. }
  76.  
  77. int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
  78. {
  79. indexfile.open (theLog,ios::app);
  80. getFiles();
  81. indexfile.close();
  82. MessageBox(NULL,"Search complete!"," ",NULL);
  83.  
  84. return 0;
  85. }
I do use the "FindFirstFile" API call, and I guess it's the same thing in asm..but I was curious how much harder would be to code this in ASM..


Cheers
Last edited by seth0x2b; Nov 27th, 2006 at 4:15 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,334
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1454
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: find files of certain type...

 
0
  #7
Nov 27th, 2006
>>I'm actually surprised you diidn't know about that page..it's among the first I read when searching for asm tutorials...

I have not written assembly for the past 15 or so years, before a certain politician (no names please) invented the internet.

I do use the "FindFirstFile" API call, and I guess it's the same thing in asm..but I was curious how much harder would be to code this in ASM..
Cheers
Take the number of lines you have in your C code and multiply by 100. :cheesy: Or, more accurately, have your compiler generate assembly listing, then compare the two.
Last edited by Ancient Dragon; Nov 27th, 2006 at 4:48 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 11
Reputation: seth0x2b is an unknown quantity at this point 
Solved Threads: 0
seth0x2b seth0x2b is offline Offline
Newbie Poster

Re: find files of certain type...

 
0
  #8
Nov 27th, 2006
I always thought the internet was "invented" by the american military in the 80's..I think I was wrong

http://www.boutell.com/newfaq/history/inventednet.html
Happy readin'

I really don't think it's 100 times more code in ASM...
I just found a sample that even has a gui to search for every file on a given folder(I supplied c:\ as a folder and it found every file on the primary partition...


Here's the code:
  1.  
  2. ;-search.asm v0.1------------------------------------------------------------
  3. ; x86 - Dos & Win32 - Assembly Language Programming ;
  4. ; ;
  5. ; Written by: John A Lyons (megablast) ;
  6. ; Email : asm@megablast.8k.com ;
  7. ; Page : http://www.asmsource.8k.com/ ;
  8. ; Compiler : Masm32 v6.13 Microsoft Macro Assembler ;
  9. ; Date : 17-Feb-2001 ;
  10. ; Purpose : Program that searches recursively from a particular dir, ;
  11. ; for files of a specific type. ;
  12. ; ;
  13. ; v0.1 : Basic features, including box, buttons and edit boxes ;
  14. ; ;
  15. ;----------------------------------------------------------------------------
  16.  
  17.  
  18. .386
  19. .MODEL FLAT, STDCALL
  20.  
  21. include windows.inc
  22. include user32.inc
  23. include kernel32.inc
  24. include comctl32.inc
  25. include gdi32.inc
  26. includelib kernel32.lib
  27. includelib user32.lib
  28. includelib comctl32.lib
  29. includelib gdi32.lib
  30. include shell32.inc
  31. includelib shell32.lib
  32. include advapi32.inc
  33. includelib advapi32.lib
  34.  
  35. EXTRN wsprintfA:PROC
  36.  
  37. ; ---------- procedures declared later
  38. HyperLinkWndProc PROTO :HWND, :DWORD, :DWORD, :DWORD
  39. regget proto regstring:DWORD
  40. regset proto regstring:DWORD,number:DWORD
  41. dofind proto searchstring:DWORD
  42. WinMain PROTO hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdShow:SDWORD
  43.  
  44.  
  45.  
  46. .CONST
  47.  
  48. IDI_ICON1 equ 5
  49.  
  50. IDC_TAB1 EQU 1011
  51. ;------------------------- buttons
  52. IDC_EXIT equ 3002
  53. ;IDC_HIDE equ 3000
  54. IDC_GO equ 1015
  55.  
  56.  
  57. ;------------------------- menu
  58. IDM_FAST equ 32000
  59. IDM_SLOW equ 32001
  60. IDM_EXIT equ 32003
  61. IDM_ABOUT equ 32002
  62.  
  63. ;------------------------- About
  64. IDC_URL equ 9
  65. IDI_CUR1 equ 101
  66. IDI_BITMAP equ 102
  67.  
  68. ;------------------------- Search
  69.  
  70. IDC_EDIT1 equ 1012
  71. IDC_EDIT2 equ 1013
  72. IDC_LIST equ 1014
  73. IDC_UPDATE equ 1016
  74.  
  75. .DATA
  76.  
  77. wmenu dd ?
  78.  
  79.  
  80. MainDlgName DB "MAINWINDOW",0
  81. aboutdialog DB "ABOUTDIALOG",0
  82.  
  83. count dd 0
  84. num1 db "%%"
  85. num2 db "%lu",0
  86.  
  87. hInstance HINSTANCE ?
  88. CommandLine LPSTR ?
  89. mem1 db "Load %%%lu",0
  90. runcount1 db "RunCount %lu",0
  91. buff db 256 dup(?)
  92. menuhand DWORD ?
  93. first BOOL FALSE
  94.  
  95. ;------------------------- Options
  96. ontop BOOL FALSE
  97. windowmove BOOL TRUE
  98.  
  99. ;------------------------- Popup Menu
  100. IDM_ONTOP equ 2
  101. IDM_UPDATE equ 3
  102. ;IDM_EXIT equ 1
  103. ;IDM_ABOUT equ 4
  104.  
  105. pick1 db "Always On Top",0
  106. pick2 db "Update Title",0
  107. about db "About",0
  108. exit db "Exit",0
  109.  
  110.  
  111. ;------------------------- About
  112. hover BOOL ?
  113. ;first BOOL FALSE
  114. szOpen db "open",0
  115. hwndDlg dd 0
  116. first2 BOOL FALSE
  117.  
  118. hFinger dd ?
  119. orgStatic dd ?
  120.  
  121. tabwin dd ?
  122. newload BOOL TRUE
  123. memoryload dd ?
  124. mainhwnd HANDLE ?
  125.  
  126. ItemStruct TC_ITEM <?>
  127. WhichTabChosen DWORD ?
  128.  
  129.  
  130. ;-------------------------------- Registry
  131. regstring2 db "Run Count",0
  132. regstring1 db "xpos",0
  133. regstring3 db "ypos",0
  134. subkeyname db "Software\search",0
  135. xpos dd NULL
  136. ypos dd NULL
  137.  
  138. IDB_MAIN equ 102
  139.  
  140. ;-------------------------------- Search
  141. hlistview dd ?
  142. szname db "Name",0
  143. szsize db "Size",0
  144. szloc db "Location",0
  145. szadd db "add me",0
  146. icc INITCOMMONCONTROLSEX <sizeof INITCOMMONCONTROLSEX, ICC_LISTVIEW_CLASSES>
  147.  
  148.  
  149. ;-------------------------------- Search
  150. fmem dd ?
  151. mem dd ?
  152. filetype db "*.*",0
  153. dirback db "..",0
  154. filesize db "%lu bytes",0
  155.  
  156. searchfor db 100 dup(0)
  157. currentdir db 128 dup(0)
  158. searchdir db 128 dup(0)
  159.  
  160. .CODE
  161.  
  162. start:
  163.  
  164.  
  165. INVOKE GetModuleHandle, NULL
  166. MOV hInstance,EAX
  167. INVOKE WinMain, hInstance,NULL,SW_SHOWDEFAULT
  168. INVOKE ExitProcess,EAX
  169.  
  170. WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdShow:SDWORD
  171.  
  172. invoke InitCommonControlsEx, ADDR icc
  173. MOV EAX, OFFSET DlgProc
  174. INVOKE DialogBoxParam, hInst, OFFSET MainDlgName,NULL,EAX,NULL
  175. mov eax,hInst
  176. mov hInstance,eax
  177. RET
  178.  
  179. WinMain endp
  180.  
  181. AddCol proc hwndListView:DWORD, iColIndex:DWORD, iColMask:DWORD, iColFormat:DWORD, iColImage:DWORD, iColWidth:DWORD, pszColText:DWORD
  182. LOCAL lcNew:LVCOLUMN
  183.  
  184. mov eax,[iColMask]
  185. mov [lcNew.imask],eax
  186. mov eax,[iColImage]
  187. mov [lcNew.iImage],eax
  188. mov eax,[iColFormat]
  189. mov [lcNew.fmt],eax
  190. mov eax,[iColWidth]
  191. mov [lcNew.lx],eax
  192. mov eax,[iColIndex]
  193. mov [lcNew.iSubItem],eax
  194.  
  195. mov eax, [pszColText]
  196. mov [lcNew.pszText], eax
  197.  
  198. invoke lstrlen, eax
  199. mov [lcNew.cchTextMax], eax
  200. and [lcNew.iOrder], 0
  201.  
  202. invoke SendMessage, [hwndListView], LVM_INSERTCOLUMN, [iColIndex], ADDR lcNew
  203.  
  204. ret
  205. AddCol endp
  206. AddItem proc hwndListView:DWORD, iItemIndex:DWORD, iSubItemIndex:DWORD, iItemMask:DWORD, iItemImage:DWORD, iItemIndent:DWORD, lParam:DWORD, pszItemText:DWORD, lenItemText:DWORD, bAction:BYTE
  207. LOCAL liNew:LV_ITEM
  208.  
  209. ; typedef struct _LV_ITEM {
  210. ; UINT mask;
  211. ; int iItem;
  212. ; int iSubItem;
  213. ; UINT state;
  214. ; UINT stateMask;
  215. ; LPTSTR pszText;
  216. ; int cchTextMax;
  217. ; int iImage; // index of the list view item's icon
  218. ; LPARAM lParam; // 32-bit value to associate with item
  219. ; } LV_ITEM;
  220.  
  221. mov eax, [iItemMask]
  222. mov [liNew.imask],eax
  223.  
  224. mov eax,[iItemIndex]
  225. mov [liNew.iItem],eax
  226.  
  227. mov eax, [iSubItemIndex]
  228. mov [liNew.iSubItem],eax
  229.  
  230. mov eax, [iItemImage]
  231. mov [liNew.iImage],eax
  232.  
  233. mov eax,[lParam]
  234. ; mov [liNew.lParam],eax
  235. mov [liNew.lParam],eax
  236.  
  237. mov edx, [pszItemText]
  238. mov [liNew.pszText], edx
  239.  
  240. mov eax, [lenItemText]
  241. mov [liNew.cchTextMax], eax
  242.  
  243. .if !eax
  244. invoke lstrlen, edx
  245. mov [liNew.cchTextMax], eax
  246. .endif
  247. and [liNew.state], 0
  248. and [liNew.stateMask], 0
  249.  
  250. .if ![bAction]
  251. invoke SendMessage, [hwndListView], LVM_INSERTITEM, 0, ADDR liNew
  252. .else
  253. invoke SendMessage, [hwndListView], LVM_SETITEM, 0, ADDR liNew
  254. .endif
  255. ret
  256. AddItem endp
  257. DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
  258. LOCAL hdc:DWORD
  259. LOCAL rect:RECT
  260. LOCAL Disp :DWORD
  261. LOCAL pKey :DWORD
  262. LOCAL Temp :DWORD
  263.  
  264. mov eax,uMsg
  265.  
  266. .if ax==WM_CLOSE
  267. bigclose:
  268. ; invoke KillTimer,hWnd,ID_TIMER
  269.  
  270. invoke GetWindowRect,hWnd,ADDR rect
  271. mov eax,rect.top
  272. mov eax,rect.left
  273.  
  274. mov eax,[count]
  275. inc eax
  276. invoke regset,ADDR regstring2,eax
  277. mov eax,xpos
  278. invoke regset,ADDR regstring1,eax
  279. mov eax,ypos
  280. invoke regset,ADDR regstring3,eax
  281.  
  282. INVOKE ExitProcess,0
  283. RET
  284.  
  285. .ELSEIF ax==WM_MOVE
  286. call updatepos
  287. ; .ELSEIF eax == WM_CTLCOLORSTATIC
  288. ;invoke SetWindowText,mainhwnd,ADDR num2
  289. ;invoke SendMessage,lParam,uMsg,wParam,lParam
  290. ; ret
  291. .elseif ax==WM_INITDIALOG
  292.  
  293. invoke LoadIcon, hInstance, IDI_ICON1
  294. invoke SendMessage, hWnd, WM_SETICON, 1, eax
  295.  
  296. mov eax,hWnd
  297. mov mainhwnd,eax
  298.  
  299.  
  300. invoke regget,ADDR regstring2
  301. mov [count],eax
  302. invoke regget,ADDR regstring1
  303. mov xpos,eax
  304. invoke regget,ADDR regstring3
  305. mov ypos,eax
  306. invoke SetWindowPos,hWnd,NULL,xpos,ypos,0,0,SWP_NOSIZE+SWP_NOZORDER
  307.  
  308. invoke CreatePopupMenu
  309. mov [wmenu],eax
  310. mov eax,[count]
  311. push eax
  312. push offset runcount1
  313. push offset buff
  314. call wsprintfA
  315. add esp,0ch
  316. invoke AppendMenu,wmenu,MF_STRING,-1,ADDR buff
  317. invoke AppendMenu,wmenu,MF_STRING,IDM_ONTOP,ADDR pick1
  318. invoke AppendMenu,wmenu,MF_STRING,IDM_UPDATE,ADDR pick2
  319. invoke AppendMenu,wmenu,MF_STRING,IDM_ABOUT,ADDR about
  320. invoke AppendMenu,wmenu,MF_STRING,IDM_EXIT,ADDR exit
  321. invoke CheckMenuItem,wmenu,IDM_UPDATE,MF_CHECKED
  322.  
  323. call updatepos
  324.  
  325. invoke GetDlgItem, [hWnd],IDC_LIST
  326. mov [hlistview], eax
  327.  
  328. ; invoke SendMessage, eax, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT
  329.  
  330. invoke AddCol, [hlistview], 0, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 100, ADDR szname
  331. invoke AddCol, [hlistview], 1, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 100, ADDR szsize
  332. invoke AddCol, [hlistview], 2, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 300, ADDR szloc
  333.  
  334. invoke GetCurrentDirectory,128,ADDR buff
  335. invoke SendDlgItemMessage, mainhwnd, IDC_EDIT2,WM_SETTEXT, 0,ADDR buff
  336. invoke SendDlgItemMessage, mainhwnd, IDC_EDIT1,WM_SETTEXT, 0,ADDR filetype
  337.  
  338.  
  339.  
  340. RET
  341.  
  342.  
  343. .ELSEIF ax==WM_COMMAND
  344. mov eax,wParam
  345. .IF lParam==0
  346. .IF ax==IDM_ONTOP
  347. xor ontop,1
  348.  
  349. cmp ontop,TRUE
  350. je setontop
  351.  
  352. invoke SetWindowPos,mainhwnd,HWND_NOTOPMOST,200,200,242,88,SWP_NOMOVE
  353. invoke CheckMenuItem,wmenu,IDM_ONTOP,MF_UNCHECKED
  354. jmp clearontop
  355. setontop:
  356. invoke SetWindowPos,mainhwnd,HWND_TOPMOST,200,200,242,88,SWP_NOMOVE
  357. invoke CheckMenuItem,wmenu,IDM_ONTOP,MF_CHECKED
  358. clearontop:
  359.  
  360. .ELSEIF ax==IDM_UPDATE
  361. xor windowmove,1
  362.  
  363. cmp windowmove,TRUE
  364. je setupdate
  365. invoke CheckMenuItem,wmenu,IDM_UPDATE,MF_UNCHECKED
  366. jmp noupdate1
  367. setupdate:
  368. invoke CheckMenuItem,wmenu,IDM_UPDATE,MF_CHECKED
  369. noupdate1:
  370. .ELSEIF ax==IDM_ABOUT
  371.  
  372. lea eax,AboutDlgProc
  373. invoke CreateDialogParam,hInstance,addr aboutdialog,hWnd,eax,NULL
  374. mov hwndDlg,eax
  375.  
  376.  
  377.  
  378. .ELSEIF ax==IDM_EXIT
  379. jmp bigclose
  380. .endif
  381.  
  382.  
  383. .ENDIF
  384. mov eax,wParam
  385. mov edx,eax
  386. shr edx,16
  387. .IF ax==IDC_GO
  388.  
  389. mov eax,hWnd
  390. mov [mainhwnd],eax
  391. call dosearch
  392.  
  393.  
  394. .ENDIF
  395.  
  396. .elseif ax==WM_PAINT
  397. ;call graph
  398.  
  399. .ELSEIF ax==WM_RBUTTONDOWN
  400. mov ebx,lParam
  401. mov ecx,ebx
  402. and ebx,0ffffh
  403. shr ecx,16
  404. add ebx,xpos
  405. add ecx,ypos
  406. add ecx,20
  407. invoke TrackPopupMenu,wmenu,TPM_CENTERALIGN +TPM_LEFTBUTTON,ebx,ecx,0,hWnd,NULL
  408. .endif
  409.  
  410. xor EAX,EAX
  411. RET
  412.  
  413.  
  414.  
  415.  
  416.  
  417. DlgProc endp
  418.  
  419. updatepos proc
  420. LOCAL rect:RECT
  421. invoke GetWindowRect,mainhwnd,ADDR rect
  422. mov eax,rect.top
  423. mov ypos,eax
  424. mov eax,rect.left
  425. mov xpos,eax
  426.  
  427. ret
  428. updatepos endp
  429.  
  430.  
  431.  
  432. AboutDlgProc PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM
  433. LOCAL hdc:DWORD
  434. LOCAL ps:PAINTSTRUCT
  435. LOCAL rect:RECT
  436.  
  437. .if iMsg==WM_INITDIALOG
  438. invoke GetDlgItem, hWnd, IDC_URL
  439. invoke SetWindowLong, eax, GWL_WNDPROC, ADDR HyperLinkWndProc
  440. mov orgStatic,eax
  441. invoke LoadCursor,hInstance,IDI_CUR1
  442. mov hFinger,eax
  443.  
  444. push count
  445. push offset runcount1
  446. push offset buff
  447. call wsprintfA
  448. add esp,0ch
  449.  
  450. ; invoke SendDlgItemMessage, hWnd, IDD_LOAD, WM_SETTEXT, 0,ADDR buff
  451.  
  452. xor eax,eax
  453. ret
  454.  
  455. .ELSEIF eax == WM_CTLCOLORSTATIC
  456. invoke SendMessage,lParam,iMsg,wParam,lParam
  457. ret
  458. .elseif iMsg==WM_CLOSE
  459. invoke EndDialog,hWnd,NULL
  460. mov hwndDlg,0
  461.  
  462. .elseif iMsg==WM_COMMAND
  463. mov eax,wParam
  464. mov edx,eax
  465. shr edx,16
  466. .if eax==IDC_EXIT
  467. invoke SendMessage,hWnd,WM_CLOSE,NULL,NULL
  468. invoke EndDialog,hWnd,NULL
  469. mov hwndDlg,0
  470. .endif
  471. .else
  472. mov eax,FALSE
  473. ret
  474. .endif
  475. mov eax,TRUE
  476. ret
  477. AboutDlgProc endp
  478. HyperLinkWndProc PROC uses ebx, hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
  479. LOCAL tmpFont :LOGFONT
  480. LOCAL rect:RECT
  481. LOCAL pt:POINT
  482.  
  483.  
  484. .IF uMsg==WM_NCHITTEST
  485. mov eax, 1
  486. ret
  487. .ELSEIF eax == WM_CTLCOLORSTATIC
  488. invoke SendMessage, hWnd, WM_GETFONT, 0, 0
  489. mov edx,eax
  490. invoke GetObject, edx, sizeof LOGFONT, addr tmpFont
  491. mov tmpFont.lfUnderline, TRUE
  492. invoke CreateFontIndirect, addr tmpFont
  493. mov ebx,eax
  494. invoke SelectObject, wParam, ebx
  495.  
  496. .if hover == FALSE
  497. invoke SetTextColor, wParam, Blue
  498. .else
  499. invoke SetTextColor, wParam,Red
  500. .endif
  501.  
  502. invoke GetSysColor, COLOR_MENU
  503. invoke SetBkColor, wParam, eax
  504. invoke DeleteObject,ebx
  505. invoke GetStockObject, HOLLOW_BRUSH
  506. ret
  507.  
  508.  
  509. .ELSEIF uMsg==WM_MOUSEMOVE
  510. invoke SetCursor,hFinger
  511.  
  512. .ELSEIF uMsg==WM_LBUTTONDOWN
  513.  
  514. invoke GetWindowText,hWnd,offset buff,sizeof buff
  515. invoke ShellExecute, NULL, offset szOpen, offset buff, NULL, NULL, SW_MAXIMIZE ;change this to represent your preset url
  516. xor eax,eax
  517. ret
  518. .ENDIF
  519.  
  520. invoke CallWindowProc, orgStatic, hWnd, uMsg, wParam, lParam
  521. ret
  522.  
  523. HyperLinkWndProc endp
  524. regget proc regstring:DWORD
  525. LOCAL number:DWORD
  526. LOCAL Disp :DWORD
  527. LOCAL pKey :DWORD
  528. LOCAL Temp :DWORD
  529.  
  530. mov Temp,4
  531.  
  532. invoke RegCreateKeyEx, HKEY_LOCAL_MACHINE,ADDR subkeyname,
  533. NULL, NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,
  534. NULL,addr pKey, addr Disp
  535.  
  536. cmp eax,ERROR_SUCCESS
  537. jne regok1
  538.  
  539. invoke RegQueryValueEx, pKey, regstring,NULL, ADDR Disp,
  540. ADDR number, ADDR Temp
  541.  
  542. invoke RegCloseKey, pKey
  543. mov eax,number
  544. ret
  545. regok1:
  546. mov eax,NULL
  547. ret
  548. regget endp
  549. regset proc regstring:DWORD,number:DWORD
  550. LOCAL Disp :DWORD
  551. LOCAL pKey :DWORD
  552. LOCAL Temp :DWORD
  553.  
  554. mov Temp,4
  555.  
  556. invoke RegCreateKeyEx, HKEY_LOCAL_MACHINE,ADDR subkeyname, NULL,
  557. NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS, NULL,
  558. addr pKey, addr Disp
  559. cmp eax,ERROR_SUCCESS
  560. jne regok2
  561.  
  562. invoke RegSetValueEx, pKey, regstring,NULL,
  563. REG_DWORD_LITTLE_ENDIAN,ADDR number, Temp
  564.  
  565. invoke RegCloseKey, pKey
  566. regok2:
  567. ret
  568.  
  569. regset endp
  570. dosearch proc
  571.  
  572. invoke GetDlgItemText,mainhwnd,IDC_EDIT2,ADDR searchdir,100
  573. invoke lstrlen,ADDR searchdir
  574. cmp eax,1
  575. jbe notvalid2
  576.  
  577. mov edi,NULL
  578.  
  579. invoke GetCurrentDirectory,128,ADDR currentdir
  580.  
  581. invoke SetCurrentDirectory,ADDR searchdir
  582. cmp eax,FALSE
  583. je notvalid2
  584. lea edi,searchdir
  585.  
  586. notvalid2:
  587.  
  588. nodir22:
  589. push edi
  590.  
  591.  
  592. invoke GetDlgItemText,mainhwnd,IDC_EDIT1,ADDR searchfor,100
  593.  
  594. invoke lstrlen,ADDR searchfor
  595. cmp eax,1
  596. jbe notvalid
  597. lea eax,searchfor
  598. jmp isvalid
  599. notvalid:
  600. lea eax,filetype
  601. isvalid:
  602.  
  603. pop edi
  604. invoke dofind,eax
  605.  
  606.  
  607. invoke SetCurrentDirectory,ADDR currentdir
  608. ret
  609. ;invoke AddItem, [hlistview], 0, 0, LVIF_TEXT OR LVIF_PARAM, 0, 0, [hWnd], ADDR buff, eax, 0
  610. dosearch endp
  611.  
  612. ;--------------------------------------- Find Proc v1
  613. dofind proc searchstring:DWORD
  614. LOCAL fd:WIN32_FIND_DATA
  615. ;typedef struct _WIN32_FIND_DATA { // wfd
  616. ;
  617. ; DWORD dwFileAttributes;
  618. ; FILETIME ftCreationTime;
  619. ; FILETIME ftLastAccessTime;
  620. ; FILETIME ftLastWriteTime;
  621. ; DWORD nFileSizeHigh;
  622. ; DWORD nFileSizeLow;
  623. ; DWORD dwReserved0;
  624. ; DWORD dwReserved1;
  625. ; TCHAR cFileName[ MAX_PATH ];
  626. ; TCHAR cAlternateFileName[ 14 ];
  627. ;} WIN32_FIND_DATA;
  628. LOCAL search:HANDLE
  629. LOCAL fsize:DWORD
  630. LOCAL tmem:DWORD
  631.  
  632. invoke GetCurrentDirectory,128,ADDR searchdir
  633. invoke SendDlgItemMessage, mainhwnd, IDC_UPDATE,WM_SETTEXT, 0,ADDR searchdir
  634.  
  635. ; Do search for files first
  636.  
  637. invoke FindFirstFile,searchstring,ADDR fd
  638. cmp eax,INVALID_HANDLE_VALUE
  639. je noshow
  640. mov [search],eax
  641. rego:
  642. test fd.dwFileAttributes ,FILE_ATTRIBUTE_DIRECTORY
  643. jne isnotafile
  644. isafile: ;--a file
  645.  
  646. invoke AddItem, [hlistview], 0, 0, LVIF_TEXT OR LVIF_PARAM, 0, 0, [mainhwnd], ADDR fd.cFileName, eax, 0
  647.  
  648. mov eax,fd.nFileSizeHigh
  649. shr eax,16
  650. add eax,fd.nFileSizeLow
  651. push eax
  652. push offset filesize
  653. push offset buff
  654. call wsprintfA
  655. add esp,0ch
  656. invoke lstrlen, ADDR buff
  657. invoke AddItem, [hlistview], 0,1, LVIF_TEXT, 0, 0, 0, ADDR buff, eax, 1
  658.  
  659. invoke lstrlen, ADDR searchdir
  660. invoke AddItem, [hlistview], 0,2, LVIF_TEXT, 0, 0, 0, ADDR searchdir, eax, 1
  661.  
  662. isnotafile:
  663. invoke FindNextFile,search,ADDR fd
  664. cmp eax,TRUE
  665. je rego
  666.  
  667. noshow:
  668. ; Lets go into all the dir's
  669.  
  670. invoke FindFirstFile,ADDR filetype,ADDR fd
  671. cmp eax,INVALID_HANDLE_VALUE
  672. je noshow2
  673. mov [search],eax
  674. rego2:
  675. mov eax,fd.dwFileAttributes
  676. test eax,FILE_ATTRIBUTE_DIRECTORY
  677. je isafile2
  678.  
  679. lea esi,fd.cFileName
  680. cmp [esi],byte ptr "."
  681. je isafile2
  682.  
  683. invoke SetCurrentDirectory,ADDR fd.cFileName
  684. cmp eax,TRUE
  685. jne isafile2
  686.  
  687. invoke dofind,searchstring
  688.  
  689. invoke SetCurrentDirectory,ADDR dirback
  690. isafile2:
  691.  
  692. invoke FindNextFile,search,ADDR fd
  693. cmp eax,TRUE
  694. je rego2
  695.  
  696. noshow2:
  697.  
  698. ret
  699. dofind endp
  700.  
  701.  
  702. END start

At least I have starting point now..

Cheers
Last edited by seth0x2b; Nov 27th, 2006 at 6:08 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,334
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1454
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: find files of certain type...

 
0
  #9
Nov 27th, 2006
>>I always thought the internet was "invented" by the american military in the 80's..I think I was wrong

Not according to this :mrgreen:

The code you posted is not a complete, self-sutaining, program. It must be linked with a normal C windows program. It appears the author just used a C program, had the compiler print the assembly code, then twik it to suit himself. It might be fun to do and instructional, but not much practical value to it other than learning how c programs work.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 11
Reputation: seth0x2b is an unknown quantity at this point 
Solved Threads: 0
seth0x2b seth0x2b is offline Offline
Newbie Poster

Re: find files of certain type...

 
0
  #10
Nov 27th, 2006
Originally Posted by Ancient Dragon
Not according to this :mrgreen:
All I can get from that page is that "the politician" helped the internet along..good for him...but that doesn't mean that he invented it..
No one really invented th internet...
the WWW on the other hand does have an inventor http://en.wikipedia.org/wiki/Tim_Berners-Lee


About the code..I just can't believe that I'll need a few thousand lines of ASM code to do a recursive file search...

Anyone..any ideeas?

Cheers
Last edited by seth0x2b; Nov 27th, 2006 at 6:27 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Assembly Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC