News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Get file extension

Started by Vortex, April 28, 2012, 10:02:38 AM

Previous topic - Next topic

Vortex

GetFileExtension finds the address of a file name. It returns the address of the string if there is no file extension.

EndOfStr, a modified version of the StrLen function determines the end of a NULL terminated string.


.386
.model flat,stdcall
option casemap:none

EndOfStr PROTO :DWORD

.code

GetFileExtension PROC USES esi edi pFileName:DWORD

    mov     esi,pFileName
    mov     edi,1
    invoke  EndOfStr,esi
    movzx   ecx,BYTE PTR [esi]
    mov     BYTE PTR [esi],'.'
@@:
    sub     eax,edi
    cmp     BYTE PTR [eax],'.'
    jne     @b
   
    mov     BYTE PTR [esi],cl
    ret

GetFileExtension ENDP

END