The MASM Forum Archive 2004 to 2012
Welcome, Guest. Please login or register.
January 22, 2018, 06:23:19 PM

Login with username, password and session length
Search:     Advanced search
128553 Posts in 15254 Topics by 684 Members
Latest Member: mottt
* Home Help Search Login Register
+  The MASM Forum Archive 2004 to 2012
|-+  Specialised Projects
| |-+  Pelle's Macro Assembler Development (Moderator: Vortex)
| | |-+  Get file extension
« previous next »
Pages: [1] Print
Author Topic: Get file extension  (Read 2831 times)
Vortex
Raider of the lost code
Moderator
Member
*****
Gender: Male
Posts: 3460



Get file extension
« on: April 28, 2012, 10:02:38 AM »

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.

Code:
.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

* GetFileExtension2.zip (3.48 KB - downloaded 315 times.)
Logged

Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP The MASM Forum Archive 2004 to 2012 | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!