汇编语言 文件扩展名修改程序资料

文件扩展名

2011年7月24日 星期日

16:08

文件后缀名: 8+3格式,8个字节,文件名,3个字节后缀名

 

文件扩展名

维基百科,自由的百科全书

副檔名(Filename Extension,或作延伸檔名)是早期操作系统(如VMSCP/MDOS等)用来标志文件格式的一种机制。以DOS来说,一个副檔名是跟在主檔名后面的,由一个分隔符号分隔。在一个像“example.txt”的檔名中,example是主檔名,txt为副檔名,表示这个文件是一个純文字文件,“.”就是主檔名与副檔名的分隔符号。

DOS作業系统(包括Windows 3.x)把副檔名限制在3个字符以内。在其他Windows作業系統上,無論是1632 位元Windows 95Windows 98Windows ME還是32位Windows NTWindows 2000Windows XPWindows 2003Windows VistaWindows 7FAT32檔案系统中包含有一个界面水平的修正,使得副檔名的字数可以达到256个英文字符,但是在系统层面,仍然保留3个字母的命名方式,这对很多用户来说都是不可见的。NTFS檔案系统则没有这种限制。(但NTFS不適用於95、98和ME)

檔案的副檔名可以根据外壳(shell)或浏览器的设置表示为显示的或隐藏的。传播电脑病毒蠕虫病毒的恶意用户可能使用类似于LOVE-LETTER-FOR-YOU.TXT.vbsJustForYou.TXT.exe这样看起来像是一个无害的纯文本文件的檔案传播给目标用户,如果檔案副檔名是隐藏的话(通常微软作業系统預设为隐藏的),那么这个VBScript檔案或帶有電腦病毒的執行檔就有可能欺骗到用户。

然而这种命名法有着很大的缺陷,甚至安全的缺陷。所以某些作業系统已经不再遵循副檔名的规范,而是采用更精确的檔案魔術數字(magic number)来确定檔案類型(参见UNIXLinux系统)。不过Windows系列的作業系统即使是最新的Windows 7都依然保持这种命名格式。

文件扩展名更重要的作用是让系统决定当用户想打开这个文件的时候用哪种软件运行,如windows系统中exe文件是可执行文件,doc文件默认用office word打开。

 

源文档 <http://zh.wikipedia.org/wiki/%E6%96%87%E4%BB%B6%E6%89%A9%E5%B1%95%E5%90%8D>

 

  1. 8.3

    维基百科,自由的百科全书

    8.3是一種限制對檔案名稱的長度的方法,這在DOSMicrosoft WindowsWindows 95Windows NT 3.5以的前版本中,在FAT檔案系統中的常用方法。在以前的CP/M及某些的通用資料迪吉多微型電腦作業系統中使用。

    8.3檔案名稱最多只可以含有8個字元,跟著最多3個字元的副檔名,利用『.』號將兩者連接起來。檔案及目錄名稱 是全部使用大寫字母的。

     

    [编辑]對於8.3與長檔名的相容性

    VFAT,是對於FAT系統中的加強版,在Windows 95和Windows NT 3.5加入。VFAT檔案系統可允許比傳統的8.3檔名,支援更長、而且能大小寫混合的長檔名(LFN)。

    要維持對以前的應用程式(例如DOS和Windows 3.1)中的向下兼容性,每一個長檔名便會自動產生一個相應的8.3檔案名稱,可容許檔案可以繼續更名、刪除或開啟。

    由於這對於一個長檔名沒有一個必然的算法建立一個8.3檔名,Windows會使用以下的常規以決定一個8.3檔案名稱是如何產生:

  2. 如果長檔名是8.3大寫字母,在磁碟上不會儲存任何長檔名。
  3. 例如: "TEXTFILE.TXT"
  4. 如果長檔名是8.3大小寫混合字母,那麼長檔名會儲存大小寫混合字母的檔名,在8.3的名稱會儲存它的大寫字母版本。
  5. 例如: "TextFile.Txt" 會轉換成 "TEXTFILE.TXT"。
  6. 長檔名只會保留基本名稱的首6位半形字元,以一個~號連接著,再以一個數字作結尾以作識別,最後以副檔名的首3位字元作結束。從這個結果中再對無法使用的字元再作刪除,像(+)號會轉換成(_)號,另外這也會轉成全大寫字母。
  7. 例如: "TextFile1.Mine.txt" 會轉換成 "TEXTFI~1.TXT";"附屬應用程式" 會轉換成 "附屬應~1"(或如果 "TEXTFI~1.TXT" 已經存在的情況下,會儲存作 "TEXTFI~2.TXT")。 "ver +1.2.text" 會轉換成 "VER_12~1.TEX"。
  8. 從Windows 2000開始,如果最少4個檔案或資料夾的短檔名的首6個字元是相同的話,該長檔名會另行將檔名轉作基本名稱的首2位字元(或如果基本名稱只有1個字元的話,便全取檔案名稱1個字元),再以4位十六進位的檔案名稱的切細值連接上,接著~號,再接著一位的數字及.號,最後以首3位的副檔名作為結尾。結果,相比之中,這檔名是已經分拆及改用全大寫字母。
  9. 例如: "TextFile.Mine.txt" 會轉換成 "TE021F~1.TXT"。

    在Windows NT family中的NTFS檔案系統本身已經對長檔名作出支援,但8.3的名稱仍然會保留,供舊有的應用程式使用。這可以選擇性地關上這個功能以增加效能。

     

    源文档 <http://zh.wikipedia.org/wiki/8.3>

     

  • Function 4Eh - Search for first match

    Action:

    Searches the default or specified drive:directory for the first occurrence of a matching filename.

    On entry:

    AH = 4Eh

    Returns:

    CX = Attribute to use in search

    DS:DX = Segment:offset of ASCIIZ file specification

    Notes:

     

    CX = 0 if successful. The current DTA is filled as follows:

    Bytes

    0-20: Reserved for use by DOS in subsequent calls

    21: Attribute of matched file

    22-23: File time stamp

    24-25: File date stamp

    26-27: least significant word of file size

    28-29: Most significant word of file size

    30-42:: Filenarne.extension in ASCIIZ string form

    Carry set if failed, AX = Error code as follows

    02h path invalid

    12h: no rnatching directory entry

    This call assumes the DTA has heat set up by a successful call to function 1Ah.

    Both wildcards (? and *) are permitted in filenames, but only the first matching name is returned.

    if the attribute in CX is zero only normal files are searched. If the volume label attribute bit is set only volume labels are returned. For all other attribute settings, (i.e, hidden, system or directory) those files and normal files are searched

    Function 4Fh - Search for next match

    Action:

    Searches for the next matching file after a previously successful call to Function 4Eh.

    On entry:

    AH = 4Fh

    Returns:

    Carry clear if successful

    The current DTA is filled as follows:-

    Bytes

    0-20 : reserved for use by DOS in subsequent calls

    21: Attribute of matched file

    22-23: File time stamp

    24-25: File date stamp

    26-27: least significant word of file size

    28-29: Most significant word of file size

    30-42: Filenarne.extension in ASCIIZ string form

    Carry set if failed, AX = Error code

    12h: no matching directory entry

    Notes:

    When used this call requires a DTA containing returned data from a previously successful call to function 4Eh or 4Fh.

    Use of function 4Fh is only relevant when the original file spedacation used in function 4Eh included at least one wildcard.

     

    源文档 <http://bbc.nvg.org/doc/Master%20512%20Technical%20Guide/m512techb_int21.htm>

     

Function 4Eh - Find first matching file

AH = 4Eh

AL = flag used by APPEND

CX = attribute mask

DS:EDX -> ASCIZ file name (may include path and wildcards)

Returns

CF = clear on success (DTA as set with function 1Ah filled)

CF = set on error (AX = error code)

Function 4Fh - Find next matching file

AH = 4Fh

DTA as set with function 1Ah contains information from previous Find First call (function 4Eh)

Returns

CF = clear on success (DTA as set with function 1Ah filled)

CF = set on error (AX = error code)

 

源文档 <http://tippach.business.t-online.de/wdosx/int21api.html#f4e>

 

 

 

.model small, c

.stack

.data
    file_spec db "*.*", 0
    DTA db 128h dup(0)

.code
main proc
    mov ax, @Data
    mov ds, ax
    mov dx,offset DTA
    mov ah,1Ah
    int 21h

    mov dx,offset file_spec
    xor cx, cx
    mov ah,4Eh
    int 21h
    jc  quit

print_name:
    lea si, DTA + 1eh
next_char:
    lodsb
    int 29h
    test al, al
    jnz next_char

    mov al, 13
    int 29h
    mov al, 10
    int 29h

    mov dx, offset file_spec
    xor cx, cx
    mov ah, 4fh
    int 21h
    jnc print_name
quit:  
    mov ax, 4c00h
    int 21h
main endp
    end main

 

源文档 <http://stackoverflow.com/questions/5653624/assembly-interrupt-21-4eh-4fh-problem>

 

 

ds:dx should contain the address of the (null terminated) filename (wildchars allowed). So for example to list all exes in c:\ the filename will be c:\*.exe.

On return, if the carry flag is set to 1 there weren't files, otherwise the DTA is filled in this way:

Offset   Size in bytes   Meaning

0        21              Reserved
21       1               File attributes
22       2               Time last modified
24       2               Date last modified
26       4               Size of file (in bytes)
30       13              File name (ASCIIZ)

You can tell DOS where you want the DTA to be placed with this simple snippet:

mov dx,OFFSET youChoose     ; DS:DX points to DTA
mov ah,1AH               ; function 1Ah - set DTA
int 21h                     ; call DOS service

 

源文档 <http://stackoverflow.com/questions/5653624/assembly-interrupt-21-4eh-4fh-problem>

 

 

 

.model small

.stack

.data

 

FileName db "c:\*.*",0 ;file name

DTA db 128 dup(?) ;buffer to store the DTA 

ErrorMsg db "An Error has occurred - exiting.$"

 

.code

 

mov ax,@data    ; set up ds to be equal to the 

mov ds,ax           ; data segment

mov es,ax           ; also es

 

mov dx,OFFSET DTA ; DS:DX points to DTA 

mov ah,1AH                 ; function 1Ah - set DTA

int 21h                         ; call DOS service

 

mov cx,3Fh                          ; attribute mask - all files

mov dx,OFFSET FileName ; DS:DX points ASCIZ filename

mov ah,4Eh                         ; function 4Eh - find first

int 21h                                 ; call DOS service

 

jc error          ; jump if carry flag is set

 

LoopCycle:

 

mov dx,OFFSET FileName ; DS:DX points to file name

mov ah,4Fh                         ; function 4fh - find next

int 21h                                 ; call DOS service

 

jc exit             ; exit if carry flag is set

 

mov cx,13                         ; length of filename

mov si,OFFSET DTA+30 ; DS:SI points to filename in DTA

xor bh,bh                          ; video page - 0

mov ah,0Eh                      ; function 0Eh - write character

 

NextChar:

 

lodsb            ; AL = next character in string

int 10h          ; call BIOS service

 

loop NextChar

 

mov di,OFFSET DTA+30 ; ES:DI points to DTA

mov cx,13                          ; length of filename

xor al,al                             ; fill with zeros

rep stosb                           ; erase DTA

 

jmp LoopCycle           ; continue searching

 

error: 

 

mov dx,OFFSET ErrorMsg          ; display error message

mov ah,9

int 21h

 

exit:

 

mov ax,4C00h            ; exit to DOS

int 21h

 

end

 

源文档 <http://hi.baidu.com/yanjingtu/blog/item/a3dfb98f55c9f3ecf01f36c5.html>

 

 

 

Cx

bit 0 = 1 read-only file
bit 1 = 1 hidden file
bit 2 = 1 system file
bit 3 = 1 volume (ignored)
bit 4 = 1 reserved (0) - directory
bit 5 = 1 archive bit
bits 6-15 reserved (0)

 

源文档 <http://stackoverflow.com/questions/5653624/assembly-interrupt-21-4eh-4fh-problem>

 

 

 

使用 Microsoft Office OneNote 2007 进行创建
可在一个位置放置所有笔记和信息

原文地址:https://www.cnblogs.com/hustlijian/p/2122387.html