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 :D .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...

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.

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.

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

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.

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:

CString theLog = "images.txt";
ofstream indexfile;


int writeLog(CString line)
{
indexfile << line << endl;
return 0;
}


void find( const std::string& filter, const std::string& directory, bool subfolders = true )
{
  WIN32_FIND_DATA find_data;
  HANDLE find_handle;

  find_handle = FindFirstFile( (directory + filter).c_str(), &find_data );

  if( find_handle != INVALID_HANDLE_VALUE )
  {
    do
    {
    CString foundline = ((directory + find_data.cFileName).c_str());
    writeLog(foundline); //at this point write the found filename...
    }while( FindNextFile( find_handle, &find_data ) );
    FindClose( find_handle );
  }
  if( subfolders )
  {
    find_handle = FindFirstFile( (directory + "*").c_str(), &find_data );
    do
    {
      if( find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
      {
        if( strcmp( find_data.cFileName, "." ) != 0 && strcmp( find_data.cFileName, ".." ) != 0 )
          find( filter, directory + std::string(find_data.cFileName) + "\\", subfolders );
                
      }
    }while( FindNextFile( find_handle, &find_data ) );

    FindClose( find_handle );
  }
}



int getFiles()
{

CString Drives[26];
CString drive;
int numdrives = 0;
char curletter = 'c';
while(curletter != 'z')
{
drive = "";
drive += curletter;
drive += ":\\";

if(GetDriveType(drive) == DRIVE_FIXED)
{
Drives[numdrives] = drive;
numdrives++;
}
curletter++;
}
int c;
for(c=0;c<numdrives;c++){
    find( "*.jpg",  (LPCSTR)Drives[c],true);
}


return 0;
}

int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR    lpCmdLine, int nCmdShow)
{
    indexfile.open (theLog,ios::app);
    getFiles();
    indexfile.close();
    MessageBox(NULL,"Search complete!"," ",NULL);
    
return 0;
}

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

>>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.

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:

;-search.asm v0.1------------------------------------------------------------
;          x86 - Dos & Win32 - Assembly Language Programming                ;
;                                                                           ;
; Written by: John A Lyons (megablast)                                      ;
; Email     : asm@megablast.8k.com                                          ;
; Page      : http://www.asmsource.8k.com/                                  ;
; Compiler  : Masm32 v6.13 Microsoft Macro Assembler                        ;
; Date      : 17-Feb-2001                                                   ;
; Purpose   : Program that searches recursively from a particular dir,      ;
;             for files of a specific type.                                 ;
;                                                                           ;
;  v0.1     : Basic features, including box, buttons and edit boxes         ;
;                                                                           ;
;----------------------------------------------------------------------------


.386            
.MODEL    FLAT, STDCALL

include windows.inc
include user32.inc
include kernel32.inc
include comctl32.inc
include gdi32.inc
includelib kernel32.lib
includelib user32.lib
includelib comctl32.lib
includelib gdi32.lib
include shell32.inc
includelib shell32.lib
include advapi32.inc
includelib advapi32.lib

EXTRN wsprintfA:PROC

;                              ---------- procedures declared later
HyperLinkWndProc PROTO :HWND, :DWORD, :DWORD, :DWORD
regget           proto regstring:DWORD
regset           proto regstring:DWORD,number:DWORD
dofind           proto searchstring:DWORD
WinMain          PROTO hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdShow:SDWORD



.CONST

IDI_ICON1       equ 5

IDC_TAB1  EQU  1011
;------------------------- buttons
IDC_EXIT        equ 3002
;IDC_HIDE        equ 3000
IDC_GO          equ 1015


;------------------------- menu
IDM_FAST        equ 32000
IDM_SLOW        equ 32001
IDM_EXIT        equ 32003
IDM_ABOUT       equ 32002

;------------------------- About
IDC_URL         equ 9
IDI_CUR1        equ 101
IDI_BITMAP      equ 102

;------------------------- Search

IDC_EDIT1       equ 1012
IDC_EDIT2       equ 1013
IDC_LIST        equ 1014
IDC_UPDATE      equ 1016

.DATA

wmenu   dd ?


MainDlgName     DB "MAINWINDOW",0
aboutdialog     DB "ABOUTDIALOG",0

count dd 0
num1            db "%%"
num2            db "%lu",0

hInstance       HINSTANCE ?
CommandLine     LPSTR ?
mem1            db "Load %%%lu",0
runcount1       db "RunCount %lu",0
buff            db 256 dup(?)
menuhand        DWORD ?
first           BOOL FALSE

;------------------------- Options
ontop           BOOL FALSE
windowmove      BOOL TRUE

;------------------------- Popup Menu
IDM_ONTOP       equ 2
IDM_UPDATE       equ 3
;IDM_EXIT        equ 1
;IDM_ABOUT       equ 4

pick1           db "Always On Top",0
pick2           db "Update Title",0
about           db "About",0
exit            db "Exit",0


;------------------------- About
hover           BOOL ?
;first           BOOL FALSE
szOpen          db "open",0
hwndDlg         dd 0
first2           BOOL FALSE

hFinger   dd ?
orgStatic dd ?

tabwin          dd ?
newload         BOOL TRUE
memoryload      dd ?
mainhwnd        HANDLE ?

ItemStruct      TC_ITEM                 <?>
WhichTabChosen  DWORD                   ?


;-------------------------------- Registry
regstring2      db "Run Count",0
regstring1      db "xpos",0
regstring3      db "ypos",0
subkeyname      db "Software\search",0
xpos dd NULL
ypos dd NULL

IDB_MAIN        equ 102

;-------------------------------- Search
hlistview       dd ?
szname          db "Name",0
szsize          db "Size",0
szloc           db "Location",0
szadd           db "add me",0
icc             INITCOMMONCONTROLSEX <sizeof INITCOMMONCONTROLSEX, ICC_LISTVIEW_CLASSES>


;-------------------------------- Search
fmem dd ?
mem  dd ?
filetype db "*.*",0
dirback  db "..",0
filesize db "%lu bytes",0

searchfor       db 100 dup(0)
currentdir      db 128 dup(0)
searchdir       db 128 dup(0)

.CODE

start:


    INVOKE GetModuleHandle, NULL
    MOV    hInstance,EAX
    INVOKE WinMain, hInstance,NULL,SW_SHOWDEFAULT
    INVOKE ExitProcess,EAX

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdShow:SDWORD

        invoke  InitCommonControlsEx, ADDR icc
        MOV EAX, OFFSET DlgProc
        INVOKE DialogBoxParam, hInst, OFFSET MainDlgName,NULL,EAX,NULL
        mov eax,hInst
        mov hInstance,eax
    RET

WinMain endp

AddCol proc hwndListView:DWORD, iColIndex:DWORD, iColMask:DWORD, iColFormat:DWORD, iColImage:DWORD, iColWidth:DWORD, pszColText:DWORD
        LOCAL lcNew:LVCOLUMN

        mov eax,[iColMask]
        mov [lcNew.imask],eax
        mov eax,[iColImage]
        mov [lcNew.iImage],eax
        mov eax,[iColFormat]
        mov [lcNew.fmt],eax
        mov eax,[iColWidth]
        mov [lcNew.lx],eax
        mov eax,[iColIndex]
        mov [lcNew.iSubItem],eax

    mov    eax, [pszColText]
    mov    [lcNew.pszText], eax

    invoke    lstrlen, eax
    mov    [lcNew.cchTextMax], eax
    and    [lcNew.iOrder], 0

    invoke    SendMessage, [hwndListView], LVM_INSERTCOLUMN, [iColIndex], ADDR lcNew

    ret    
AddCol endp
AddItem proc hwndListView:DWORD, iItemIndex:DWORD, iSubItemIndex:DWORD, iItemMask:DWORD, iItemImage:DWORD, iItemIndent:DWORD, lParam:DWORD, pszItemText:DWORD, lenItemText:DWORD, bAction:BYTE
        LOCAL liNew:LV_ITEM

;        typedef struct _LV_ITEM {
;            UINT   mask;
;            int    iItem;
;            int    iSubItem;
;            UINT   state;
;            UINT   stateMask;
;            LPTSTR  pszText;
;            int    cchTextMax;
;            int    iImage;       // index of the list view item's icon
;            LPARAM lParam;       // 32-bit value to associate with item
;        } LV_ITEM;

        mov eax, [iItemMask]
        mov [liNew.imask],eax

        mov eax,[iItemIndex]
        mov [liNew.iItem],eax

        mov eax, [iSubItemIndex]
        mov [liNew.iSubItem],eax

        mov eax, [iItemImage]
        mov [liNew.iImage],eax

        mov eax,[lParam]
;        mov [liNew.lParam],eax
        mov [liNew.lParam],eax

    mov    edx, [pszItemText]
    mov    [liNew.pszText], edx

    mov    eax, [lenItemText]
    mov    [liNew.cchTextMax], eax

    .if !eax
        invoke    lstrlen, edx
        mov    [liNew.cchTextMax], eax
    .endif
    and    [liNew.state], 0
    and    [liNew.stateMask], 0

    .if ![bAction]
        invoke    SendMessage, [hwndListView], LVM_INSERTITEM, 0, ADDR liNew
    .else
        invoke    SendMessage, [hwndListView], LVM_SETITEM, 0, ADDR liNew
    .endif
    ret
AddItem endp
DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
        LOCAL hdc:DWORD
        LOCAL rect:RECT
        LOCAL Disp  :DWORD
        LOCAL pKey  :DWORD
        LOCAL Temp  :DWORD

        mov eax,uMsg

        .if ax==WM_CLOSE
bigclose:
;                invoke KillTimer,hWnd,ID_TIMER

                invoke GetWindowRect,hWnd,ADDR rect
                mov eax,rect.top
                mov eax,rect.left

                mov eax,[count]
                inc eax
                invoke regset,ADDR regstring2,eax
                mov eax,xpos
                invoke regset,ADDR regstring1,eax
                mov eax,ypos
                invoke regset,ADDR regstring3,eax

                INVOKE ExitProcess,0
                RET

        .ELSEIF ax==WM_MOVE
                call updatepos
;        .ELSEIF eax == WM_CTLCOLORSTATIC
                ;invoke SetWindowText,mainhwnd,ADDR num2
                ;invoke SendMessage,lParam,uMsg,wParam,lParam
;                ret
        .elseif ax==WM_INITDIALOG

                invoke LoadIcon, hInstance, IDI_ICON1
                invoke SendMessage, hWnd, WM_SETICON, 1, eax

                mov eax,hWnd
                mov mainhwnd,eax


                invoke regget,ADDR regstring2
                mov [count],eax
                invoke regget,ADDR regstring1
                mov xpos,eax
                invoke regget,ADDR regstring3
                mov ypos,eax
                invoke SetWindowPos,hWnd,NULL,xpos,ypos,0,0,SWP_NOSIZE+SWP_NOZORDER

                invoke CreatePopupMenu
                mov [wmenu],eax
                mov eax,[count]
                push eax
                push offset runcount1
                push offset buff
                call wsprintfA
                add esp,0ch
                invoke AppendMenu,wmenu,MF_STRING,-1,ADDR buff
                invoke AppendMenu,wmenu,MF_STRING,IDM_ONTOP,ADDR pick1
                invoke AppendMenu,wmenu,MF_STRING,IDM_UPDATE,ADDR pick2
                invoke AppendMenu,wmenu,MF_STRING,IDM_ABOUT,ADDR about
                invoke AppendMenu,wmenu,MF_STRING,IDM_EXIT,ADDR exit
                invoke CheckMenuItem,wmenu,IDM_UPDATE,MF_CHECKED

                call updatepos

                invoke  GetDlgItem, [hWnd],IDC_LIST
                mov     [hlistview], eax

;                invoke  SendMessage, eax, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT

                invoke  AddCol, [hlistview], 0, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 100, ADDR szname
                invoke  AddCol, [hlistview], 1, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 100, ADDR szsize
                invoke  AddCol, [hlistview], 2, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 300, ADDR szloc

                invoke GetCurrentDirectory,128,ADDR buff
                invoke SendDlgItemMessage, mainhwnd, IDC_EDIT2,WM_SETTEXT, 0,ADDR buff
                invoke SendDlgItemMessage, mainhwnd, IDC_EDIT1,WM_SETTEXT, 0,ADDR filetype



                RET

     
        .ELSEIF ax==WM_COMMAND
                mov eax,wParam
                .IF lParam==0
                   .IF ax==IDM_ONTOP
                           xor ontop,1

                           cmp ontop,TRUE
                           je setontop

                           invoke SetWindowPos,mainhwnd,HWND_NOTOPMOST,200,200,242,88,SWP_NOMOVE
                           invoke CheckMenuItem,wmenu,IDM_ONTOP,MF_UNCHECKED
                           jmp clearontop
setontop:
                           invoke SetWindowPos,mainhwnd,HWND_TOPMOST,200,200,242,88,SWP_NOMOVE
                           invoke CheckMenuItem,wmenu,IDM_ONTOP,MF_CHECKED
clearontop:

                   .ELSEIF ax==IDM_UPDATE
                           xor windowmove,1

                           cmp windowmove,TRUE
                           je setupdate
                           invoke CheckMenuItem,wmenu,IDM_UPDATE,MF_UNCHECKED
                           jmp noupdate1
setupdate:
                           invoke CheckMenuItem,wmenu,IDM_UPDATE,MF_CHECKED
noupdate1:
                   .ELSEIF ax==IDM_ABOUT

                           lea eax,AboutDlgProc
                           invoke CreateDialogParam,hInstance,addr aboutdialog,hWnd,eax,NULL
                           mov hwndDlg,eax



                   .ELSEIF ax==IDM_EXIT
                           jmp bigclose
                   .endif


                .ENDIF
        mov eax,wParam
        mov edx,eax
        shr edx,16
                .IF ax==IDC_GO

                        mov eax,hWnd
                        mov [mainhwnd],eax
                        call dosearch


                .ENDIF
  
        .elseif ax==WM_PAINT
                ;call graph

        .ELSEIF ax==WM_RBUTTONDOWN
                mov ebx,lParam
                mov ecx,ebx
                and ebx,0ffffh
                shr ecx,16
                add ebx,xpos
                add ecx,ypos
                add ecx,20
                invoke TrackPopupMenu,wmenu,TPM_CENTERALIGN +TPM_LEFTBUTTON,ebx,ecx,0,hWnd,NULL
        .endif

        xor EAX,EAX
        RET


        


DlgProc endp

updatepos proc
          LOCAL rect:RECT
          invoke GetWindowRect,mainhwnd,ADDR rect
          mov eax,rect.top
          mov ypos,eax
          mov eax,rect.left
          mov xpos,eax

          ret
updatepos endp



AboutDlgProc PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM
         LOCAL hdc:DWORD
         LOCAL ps:PAINTSTRUCT
         LOCAL rect:RECT

        .if iMsg==WM_INITDIALOG
                invoke GetDlgItem, hWnd, IDC_URL
                invoke SetWindowLong, eax, GWL_WNDPROC, ADDR HyperLinkWndProc
                mov orgStatic,eax
                invoke LoadCursor,hInstance,IDI_CUR1
                mov hFinger,eax

                push count
                push offset runcount1
                push offset buff
                call wsprintfA
                add esp,0ch

;                invoke SendDlgItemMessage, hWnd, IDD_LOAD, WM_SETTEXT, 0,ADDR buff

                xor eax,eax
                ret

        .ELSEIF eax == WM_CTLCOLORSTATIC
                invoke SendMessage,lParam,iMsg,wParam,lParam
                ret
        .elseif iMsg==WM_CLOSE
        invoke EndDialog,hWnd,NULL
        mov hwndDlg,0

        .elseif iMsg==WM_COMMAND
        mov eax,wParam
        mov edx,eax
        shr edx,16
                .if eax==IDC_EXIT
                      invoke SendMessage,hWnd,WM_CLOSE,NULL,NULL
                      invoke EndDialog,hWnd,NULL
                      mov hwndDlg,0
                .endif
        .else
        mov eax,FALSE
        ret
        .endif
        mov  eax,TRUE
        ret
AboutDlgProc endp
HyperLinkWndProc PROC uses ebx, hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
LOCAL tmpFont  :LOGFONT 
LOCAL rect:RECT
LOCAL pt:POINT


    .IF uMsg==WM_NCHITTEST
        mov eax, 1
            ret
    .ELSEIF eax == WM_CTLCOLORSTATIC
                invoke SendMessage, hWnd, WM_GETFONT, 0, 0
                mov edx,eax
                invoke GetObject, edx, sizeof LOGFONT, addr tmpFont
                mov tmpFont.lfUnderline, TRUE
                invoke CreateFontIndirect, addr tmpFont
                mov ebx,eax
                invoke SelectObject, wParam, ebx

                .if hover == FALSE
                     invoke SetTextColor, wParam, Blue
                .else
                     invoke SetTextColor, wParam,Red
                .endif

                invoke GetSysColor, COLOR_MENU
                invoke SetBkColor, wParam, eax
                invoke DeleteObject,ebx
                invoke GetStockObject, HOLLOW_BRUSH
                ret


    .ELSEIF uMsg==WM_MOUSEMOVE
        invoke SetCursor,hFinger

    .ELSEIF uMsg==WM_LBUTTONDOWN

            invoke GetWindowText,hWnd,offset buff,sizeof buff
            invoke ShellExecute, NULL, offset szOpen, offset buff, NULL, NULL, SW_MAXIMIZE ;change this to represent your preset url
            xor eax,eax
            ret
    .ENDIF

    invoke CallWindowProc, orgStatic, hWnd, uMsg, wParam, lParam
    ret

HyperLinkWndProc endp
regget proc regstring:DWORD
        LOCAL number:DWORD
        LOCAL Disp  :DWORD
        LOCAL pKey  :DWORD
        LOCAL Temp  :DWORD

                mov Temp,4

                invoke RegCreateKeyEx, HKEY_LOCAL_MACHINE,ADDR subkeyname,
                        NULL, NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,
                        NULL,addr pKey, addr Disp

                cmp eax,ERROR_SUCCESS
                jne regok1

                invoke RegQueryValueEx, pKey, regstring,NULL, ADDR Disp,
                                ADDR number, ADDR Temp

                invoke RegCloseKey, pKey
                mov eax,number
                ret
regok1:
                mov eax,NULL
                ret
regget endp
regset proc regstring:DWORD,number:DWORD
        LOCAL Disp  :DWORD
        LOCAL pKey  :DWORD
        LOCAL Temp  :DWORD

                mov Temp,4

                invoke RegCreateKeyEx, HKEY_LOCAL_MACHINE,ADDR subkeyname, NULL,
                        NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS, NULL,
                        addr pKey, addr Disp
                cmp eax,ERROR_SUCCESS
                jne regok2

                invoke RegSetValueEx, pKey, regstring,NULL,
                        REG_DWORD_LITTLE_ENDIAN,ADDR number, Temp

                invoke RegCloseKey, pKey
regok2:
                ret

regset endp
dosearch        proc

                invoke GetDlgItemText,mainhwnd,IDC_EDIT2,ADDR searchdir,100
                invoke lstrlen,ADDR searchdir
                cmp eax,1
                jbe notvalid2

                mov edi,NULL

                invoke GetCurrentDirectory,128,ADDR currentdir

                invoke SetCurrentDirectory,ADDR searchdir
                cmp eax,FALSE
                je notvalid2
                lea edi,searchdir

notvalid2:

nodir22:
                push edi


                invoke GetDlgItemText,mainhwnd,IDC_EDIT1,ADDR searchfor,100

                invoke lstrlen,ADDR searchfor
                cmp eax,1
                jbe notvalid
                lea eax,searchfor
                jmp isvalid
notvalid:
                lea eax,filetype
isvalid:

                pop edi
                invoke dofind,eax


                invoke SetCurrentDirectory,ADDR currentdir
                ret
                        ;invoke  AddItem, [hlistview], 0, 0, LVIF_TEXT OR LVIF_PARAM, 0, 0, [hWnd], ADDR buff, eax, 0
dosearch        endp

;--------------------------------------- Find Proc v1
dofind  proc searchstring:DWORD
        LOCAL fd:WIN32_FIND_DATA
                        ;typedef struct _WIN32_FIND_DATA { // wfd
                        ;
                        ;    DWORD dwFileAttributes;
                        ;    FILETIME ftCreationTime;
                        ;    FILETIME ftLastAccessTime;
                        ;    FILETIME ftLastWriteTime;
                        ;    DWORD    nFileSizeHigh;
                        ;    DWORD    nFileSizeLow;
                        ;    DWORD    dwReserved0;
                        ;    DWORD    dwReserved1;
                        ;    TCHAR    cFileName[ MAX_PATH ];
                        ;    TCHAR    cAlternateFileName[ 14 ];
                        ;} WIN32_FIND_DATA;
        LOCAL search:HANDLE
        LOCAL fsize:DWORD
        LOCAL tmem:DWORD

                invoke GetCurrentDirectory,128,ADDR searchdir
                invoke SendDlgItemMessage, mainhwnd, IDC_UPDATE,WM_SETTEXT, 0,ADDR searchdir

                                        ; Do search for files first

                invoke FindFirstFile,searchstring,ADDR fd
                cmp eax,INVALID_HANDLE_VALUE
                je noshow
                mov [search],eax
rego:
                test fd.dwFileAttributes ,FILE_ATTRIBUTE_DIRECTORY
                jne isnotafile
isafile:                                                  ;--a file

                invoke  AddItem, [hlistview], 0, 0, LVIF_TEXT OR LVIF_PARAM, 0, 0, [mainhwnd], ADDR fd.cFileName, eax, 0

                mov eax,fd.nFileSizeHigh
                shr eax,16
                add eax,fd.nFileSizeLow
                push eax
                push offset filesize
                push offset buff
                call wsprintfA
                add esp,0ch
                invoke  lstrlen, ADDR buff
                invoke  AddItem, [hlistview], 0,1, LVIF_TEXT, 0, 0, 0, ADDR buff, eax, 1

                invoke  lstrlen, ADDR searchdir
                invoke  AddItem, [hlistview], 0,2, LVIF_TEXT, 0, 0, 0, ADDR searchdir, eax, 1

isnotafile:
                invoke FindNextFile,search,ADDR fd
                cmp eax,TRUE
                je rego

noshow:
                                        ; Lets go into all the dir's

                invoke FindFirstFile,ADDR filetype,ADDR fd
                cmp eax,INVALID_HANDLE_VALUE
                je noshow2
                mov [search],eax
rego2:
                mov eax,fd.dwFileAttributes
                test eax,FILE_ATTRIBUTE_DIRECTORY
                je isafile2

                lea esi,fd.cFileName
                cmp [esi],byte ptr "."
                je isafile2

                invoke SetCurrentDirectory,ADDR fd.cFileName
                cmp eax,TRUE
                jne isafile2

                invoke dofind,searchstring

                invoke SetCurrentDirectory,ADDR dirback
isafile2:

                invoke FindNextFile,search,ADDR fd
                cmp eax,TRUE
                je rego2

noshow2:

        ret
dofind  endp


END start

At least I have starting point now..

Cheers

>>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.

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

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...

You are apparently not an American. That was all just a big joke here a few years ago. Al Gore didn't really mean it -- it was a slip of the tounge and everyone laughed at him about it.


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

You probably won't need quite that much code. I already mentioned you convert a C program to assembly. I have already posted two such code snippets

You are apparently not an American. That was all just a big joke here a few years ago. Al Gore didn't really mean it -- it was a slip of the tounge and everyone laughed at him about it.

Is my english all that good? :P No..I'm not American..I'm Romanian (Europe... :) )

I've loked at your code and it's definatly cleaner than mine...
But I already know how to search in c++...My post wast not about the search algoritm itself, it was about how to do it in ASM.

I've already agreed with you on the fact that It's a masochist's wish to do this in asm when I have C++, but I just want to learn stuff like this in asm because..as I said..programming is one of my hobbies and I really enjoy learning new stuff.

Cheers and thanks

>>Is my english all that good? :P No..I'm not American..I'm Romanian
yes -- your English is excellent.

>>My post wast not about the search algoritm itself, it was about how to do it in ASM.
you start out by just doing it. do you already know 80x88 assembly ? If you do then writing that program should be a piece of cake. Sorry, but I'm not gonig to write an asm version of the program.

do you already know 80x88 assembly ? If you do then writing that program should be a piece of cake. Sorry, but I'm not gonig to write an asm version of the program.

The only "assembly" I did was machine code(2 different things i think...) on Z80 spectrums about 10-12 years ago.That can't really help me with what I want to do now..

I was not asking for a complete source ..but some snippets would have been appreciated (asm...not cpp)...
Thanks for your patience..maybe someone else has something..if not..oh well..I'll learn the hard way.. :)


Cheers

that link you posted has a lot of tutorials. Just do them and learn.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.