News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Handy as a pocket

Started by Magnum, December 23, 2012, 01:12:57 PM

Previous topic - Next topic

Magnum

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
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

jj2007

> we are suing boyer moore

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