flat assembler
Message board for the users of flat assembler.

Index > Windows > lodsw Error Control

Author
Thread Post new topic Reply to topic
Torrey



Joined: 12 Oct 2003
Posts: 78
Torrey
Is there any error control that is possible when using lodsw? Or any of the lodsx instructions?

Code:
        mov esi,0x00400000
Another:
        mov edx,esi
        lodsw
        cmp eax,'hi'
        je Continue
        jmp Another
    


That's a really crappy example there, but eventually that will reach a part of memory that will not contain anything, what I'd like it to do is use some form of error control if any to skip over that part of memory or jump to an error handler within my program. If you wonder why I had the "mov edx,esi" in there it's to watch where esi's current location is as I watch in the debugger. Any ideas?

Thanks for the help
~Torrey
Post 04 Mar 2004, 09:28
View user's profile Send private message Visit poster's website Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv
Try repnz(or repz) scasw depending on your needs.
Post 04 Mar 2004, 12:43
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
If you are looking for a word and you know it will be aligned, you can scan two by two bytes, but if not, you better go byte by byte or scan possibilities of having second byte or first byte. i.e

Code:
         ; 1 2 3 4 5 6 7 8 9 0 1 2 3 4
         ; ..  ..  ..  ..  ..  ..  ..
stuff1 db 'this is some stuff, ok?',0,0
stuff2 db 'this is new stuff, ok?',0,0

Start:
  mov   esi,stuff1
Another1:
  lodsw
  cmp   ax,'ok'
  jne   Another1 ; you will find it
ok_found:
  mov   esi,stuff2
Another2:
  lodsw
  cmp   ax,'ok'
  jne   Another2 ; you won't find it.
          ; It may run forever, depending on memory
          ; after stuff2
Another3:
  lodsw
  or    ax,ax
  je    not_found
  cmp   ax,'ok'
  jne   Another2 ; here it stops in a zero word
    
Post 04 Mar 2004, 19:34
View user's profile Send private message Yahoo Messenger Reply with quote
Torrey



Joined: 12 Oct 2003
Posts: 78
Torrey
@pelaillo & roticv

Originally the idea was to scan through a process' memory space for a specific byte pattern, using error control if possible to skip over parts of memory space that esi=??? (nothing) and just do a cmp with esi's current address so it stops at a certain point. As it seems there might not be error control for lodsx. Some colleagues told me to check out SEH for what I wanted. SEH will most likely be the last thing I test out. The first will be checking more into roticv's idea of using repnz or repz scasw. I'm expecting an access violation bomb out, but really hoping for the best.
Post 05 Mar 2004, 00:05
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
Torrey wrote:
I'm expecting an access violation bomb out, but really hoping for the best.


Don't. You probably will get access violation. You need SEH. It is not exactly assembly related stuff, but Windows related. You have to read some tutorials about SEH - in generally it is not so complex.

Regards.
Post 05 Mar 2004, 01:45
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Torrey



Joined: 12 Oct 2003
Posts: 78
Torrey
Honestly I skipped over the scasw stuff earlier and went straight for SEH. Worked perfectly! The hardest part about it all as most of you know...the debugger can't use the new error handler when one is set.
Post 05 Mar 2004, 02:26
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.