The MASM Forum

General => The Campus => Topic started by: Magnum on December 23, 2012, 01:12:57 PM

Title: Handy as a pocket
Post by: Magnum on December 23, 2012, 01:12:57 PM
BMBinSearch is  pretty handy depending on the kind of string you are looking for.

Code is short too.

Andy


; mint.asm Code by blabberer
;
.386
.model flat, stdcall
option casemap:none
include \masm32\include\masm32.inc
include \masm32\include\USER32.inc
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\USER32.lib

.data
SourceStr      db "Iczelion's tutorial no.2 instead of this string you can use file open mint77 and use the stream",0
SearchStr      db "mint77",0

.code

start:

;we are suing boyer moore binary search algo available in masm32 just include masm32.inc / masm32.lib and we are go
;for string searching in this example we are searching for mint77 in the source string and display both
;source string as MsgBoxCaption and result as message box text

; BMBinSearch proc startpos:DWORD,
;                  lpSource:DWORD,srcLngth:DWORD,
;                  lpSubStr:DWORD,subLngth:DWORD



invoke BMBinSearch,0,ADDR SourceStr,200,ADDR SearchStr,6
add eax,OFFSET SourceStr 
; result in eax is the offset where pattern was found this can be -1 if no pattern found/blah blah and crash :)

invoke MessageBox, 0,eax,addr SourceStr, 1
      invoke ExitProcess,0

;retn  ;Let's exit correctly

end start
Title: Re: Handy as a pocket
Post by: jj2007 on December 23, 2012, 06:18:20 PM
> we are suing boyer moore

Good luck! Can the authors prove that they have older rights?