Вопрос

I'm a new in assembly and trying to write something like file searcher. This snippet I using for compare with 4-letter mask (FASM):

  lea    eax,[fd.cFileName]
  push   eax
  call   [lstrlen]
  cmp    dword [fd.cFileName+eax-4],'.txt'         ; extension comparing
  je .finded

How to change this snippet for work with 5-letter extensions, like '.docx'? Thank you.

Это было полезно?

Решение

It could be a little bit more complex if you want to search case insensitive, but something like this:

        lea    eax,[fd.cFileName]
        push   eax
        call   [lstrlen]
        cmp    eax, 5
        jbe    .not_found   ; at least 6 characters name.
        cmp    dword [fd.cFileName+eax-5],'.doc'         ; extension comparing
        jne    .not_found
        cmp    byte [fd.cFileName+eax-1], 'x'
        jne    .not_found

.found: 
; some code


.not_found:
; some other code...
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top