flat assembler
Message board for the users of flat assembler.
  
       
      Index
      > Windows > Search a string in a text file | 
  
| Author | 
  | 
              
| 
                  
                   mns 06 Aug 2011, 18:39 
                  Can any one tell me Is there a way of search a sring in a text file using windows API? 
 
        or please show me any other way I tried to do as following but failed,(full code attached with this) Code: Textsearch: invoke CreateFile,FileName, GENERIC_READ + GENERIC_WRITE, 0, 0,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 mov [hFile], eax cmp [hFile],INVALID_HANDLE_VALUE je .inValHandle invoke GetFileSize,fileSize,0 mov [fileSize],eax invoke GlobalAlloc,0,fileSize mov [dwBufferSize],eax cmp [dwBufferSize],0 je .fileNtAlloc invoke ReadFile,[hFile],dwBufferSize,fileSize,dwTextLength,0 mov edi,[dwBufferSize] mov ecx,[fileSize] mov esi,stxt mov al, byte[esi] call sloop .inValHandle: invoke MessageBox,[hwnddlg],text2,caption,NULL+MB_OK call endn ;.invalTxtLen: ;invoke MessageBox,[hwnddlg],text5,caption,NULL+MB_OK ;call endn .fileNtAlloc: invoke MessageBox,[hwnddlg],text4,caption,NULL+MB_OK call endn sloop: repnz scasb cmp ecx,0 je .notfound invoke lstrlen,stxt mov [strlenth],eax mov ecx,strlenth repz cmpsb cmp ecx,0 je .success jmp sloop invoke GlobalFree,dwBufferSize invoke CloseHandle,[hFile] call endn .notfound: invoke MessageBox,[hwnddlg],text6,caption,NULL+MB_OK call endn .success: invoke MessageBox,[hwnddlg],text7,caption,NULL+MB_OK call endn endn: retn [Edit by Loco]Added code tags 
  | 
              |||||||||||
                  
  | 
              
| 
                  
                   mns 07 Aug 2011, 05:15 
                  sorry typedef I'm still in a early stages of learning assembly.
 
                can you explain more? or point to a tutorial on that may be thanks  | 
              |||
                  
  | 
              
| 
                  
                   cod3b453 07 Aug 2011, 07:41 
                  The WinAPI provides a strstr function for searching strings - http://msdn.microsoft.com/en-us/library/bb773436(v=vs.85).aspx 
                 | 
              |||
                  
  | 
              
| 
                  
                   mns 13 Aug 2011, 18:09 
                  I tried to use StrStrI function (source attached with this) but no success.
 
        Please someone help me 
 
  | 
              |||||||||||||||||||||
                  
  | 
              
| 
                  
                   mns 13 Aug 2011, 20:09 
                  sorry there was a mistake in added file exp14.asm of previous post now corrected. 
                 | 
              |||
                  
  | 
              
| 
                  
                   mns 15 Aug 2011, 18:51 
                  At last I'v managed to write a code for search a sring in a text file.  
        I'v used old CMPSB.If you interrested please check the attached files(please dwnlod both file to same directory) thanx every one for helping me 
 
  | 
              |||||||||||||||||||||
                  
  | 
              
< Last Thread | Next Thread >  | 
    
Forum Rules: 
  | 
    
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.