Rev 91 | Rev 171 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 91 | Rev 131 | ||
---|---|---|---|
Line 1786... | Line 1786... | ||
1786 | mov ebx, edx |
1786 | mov ebx, edx |
1787 | pop edi edi ecx edx |
1787 | pop edi edi ecx edx |
1788 | sub ebx, edx |
1788 | sub ebx, edx |
1789 | mov [edi+28], ebx |
1789 | mov [edi+28], ebx |
1790 | add esp, 20 |
1790 | add esp, 20 |
- | 1791 | mov [esp+16], ebx |
|
1791 | popad |
1792 | popad |
1792 | xor eax, eax |
1793 | xor eax, eax |
1793 | ret |
1794 | ret |
1794 | .disk_full2: |
1795 | .disk_full2: |
1795 | mov ebx, edx |
1796 | mov ebx, edx |
1796 | pop edi edi ecx edx |
1797 | pop edi edi ecx edx |
1797 | sub ebx, edx |
1798 | sub ebx, edx |
1798 | mov [edi+28], ebx |
1799 | mov [edi+28], ebx |
1799 | add esp, 20 |
1800 | add esp, 20 |
- | 1801 | mov [esp+16], ebx |
|
1800 | popad |
1802 | popad |
1801 | push ERROR_DISK_FULL |
1803 | push ERROR_DISK_FULL |
1802 | pop eax |
1804 | pop eax |
1803 | ret |
1805 | ret |
Line 1818... | Line 1820... | ||
1818 | call .read_symbol |
1820 | call .read_symbol |
1819 | stosw |
1821 | stosw |
1820 | loop .read_symbols |
1822 | loop .read_symbols |
1821 | ret |
1823 | ret |
Line -... | Line 1824... | ||
- | 1824 | ||
- | 1825 | ;---------------------------------------------------------------- |
|
- | 1826 | ; |
|
- | 1827 | ; fs_RamdiskWrite - LFN variant for writing to sys floppy |
|
- | 1828 | ; |
|
- | 1829 | ; esi points to filename |
|
- | 1830 | ; ebx pointer to 64-bit number = first wanted byte, 0+ |
|
- | 1831 | ; may be ebx=0 - start from first byte |
|
- | 1832 | ; ecx number of bytes to write, 0+ |
|
- | 1833 | ; edx mem location to data |
|
- | 1834 | ; |
|
- | 1835 | ; ret ebx = bytes written (maybe 0) |
|
- | 1836 | ; eax = 0 ok write or other = errormsg |
|
- | 1837 | ; |
|
- | 1838 | ;-------------------------------------------------------------- |
|
- | 1839 | @@: |
|
- | 1840 | push ERROR_ACCESS_DENIED |
|
- | 1841 | fs_RamdiskWrite.ret0: |
|
- | 1842 | pop eax |
|
- | 1843 | xor ebx, ebx |
|
- | 1844 | ret |
|
- | 1845 | ||
- | 1846 | fs_RamdiskWrite: |
|
- | 1847 | cmp byte [esi], 0 |
|
- | 1848 | jz @b |
|
- | 1849 | pushad |
|
- | 1850 | call rd_find_lfn |
|
- | 1851 | jnc .found |
|
- | 1852 | popad |
|
- | 1853 | push ERROR_FILE_NOT_FOUND |
|
- | 1854 | jmp .ret0 |
|
- | 1855 | .found: |
|
- | 1856 | ; must not be directory |
|
- | 1857 | test byte [edi+11], 10h |
|
- | 1858 | jz @f |
|
- | 1859 | popad |
|
- | 1860 | push ERROR_ACCESS_DENIED |
|
- | 1861 | jmp .ret0 |
|
- | 1862 | @@: |
|
- | 1863 | ; FAT does not support files larger than 4GB |
|
- | 1864 | test ebx, ebx |
|
- | 1865 | jz .l1 |
|
- | 1866 | cmp dword [ebx+4], 0 |
|
- | 1867 | jz @f |
|
- | 1868 | .eof: |
|
- | 1869 | popad |
|
- | 1870 | push ERROR_END_OF_FILE |
|
- | 1871 | jmp .ret0 |
|
- | 1872 | @@: |
|
- | 1873 | mov ebx, [ebx] |
|
- | 1874 | .l1: |
|
- | 1875 | ; now edi points to direntry, ebx=start byte to write, |
|
- | 1876 | ; ecx=number of bytes to write, edx=data pointer |
|
- | 1877 | call get_time_for_file |
|
- | 1878 | mov [edi+22], ax ; last write time |
|
- | 1879 | call get_date_for_file |
|
- | 1880 | mov [edi+24], ax ; last write date |
|
- | 1881 | mov [edi+18], ax ; last access date |
|
- | 1882 | ||
- | 1883 | ; extend file if needed |
|
- | 1884 | add ecx, ebx |
|
- | 1885 | jc .eof ; FAT does not support files larger than 4GB |
|
- | 1886 | push 0 ; return value=0 |
|
- | 1887 | cmp ecx, [edi+28] |
|
- | 1888 | jbe .length_ok |
|
- | 1889 | cmp ecx, ebx |
|
- | 1890 | jz .length_ok |
|
- | 1891 | call ramdisk_extend_file |
|
- | 1892 | jnc .length_ok |
|
- | 1893 | ; ramdisk_extend_file can return two error codes: FAT table error or disk full. |
|
- | 1894 | ; First case is fatal error, in second case we may write some data |
|
- | 1895 | mov [esp], eax |
|
- | 1896 | cmp al, ERROR_DISK_FULL |
|
- | 1897 | jz .disk_full |
|
- | 1898 | pop eax |
|
- | 1899 | mov [esp+28], eax |
|
- | 1900 | popad |
|
- | 1901 | xor ebx, ebx |
|
- | 1902 | ret |
|
- | 1903 | .disk_full: |
|
- | 1904 | ; correct number of bytes to write |
|
- | 1905 | mov ecx, [edi+28] |
|
- | 1906 | cmp ecx, ebx |
|
- | 1907 | ja .length_ok |
|
- | 1908 | .ret: |
|
- | 1909 | pop eax |
|
- | 1910 | mov [esp+28], eax ; eax=return value |
|
- | 1911 | sub edx, [esp+20] |
|
- | 1912 | mov [esp+16], edx ; ebx=number of written bytes |
|
- | 1913 | popad |
|
- | 1914 | ret |
|
- | 1915 | .length_ok: |
|
- | 1916 | ; now ebx=start pos, ecx=end pos, both lie inside file |
|
- | 1917 | sub ecx, ebx |
|
- | 1918 | jz .ret |
|
- | 1919 | movzx edi, word [edi+26] ; starting cluster |
|
- | 1920 | .write_loop: |
|
- | 1921 | sub ebx, 0x200 |
|
- | 1922 | jae .next_cluster |
|
- | 1923 | push ecx |
|
- | 1924 | neg ebx |
|
- | 1925 | cmp ecx, ebx |
|
- | 1926 | jbe @f |
|
- | 1927 | mov ecx, ebx |
|
- | 1928 | @@: |
|
- | 1929 | mov eax, edi |
|
- | 1930 | shl eax, 9 |
|
- | 1931 | add eax, 0x100000+31*512+0x200 |
|
- | 1932 | sub eax, ebx |
|
- | 1933 | mov ebx, eax |
|
- | 1934 | mov eax, edx |
|
- | 1935 | call memmove |
|
- | 1936 | xor ebx, ebx |
|
- | 1937 | add edx, ecx |
|
- | 1938 | sub [esp], ecx |
|
- | 1939 | pop ecx |
|
- | 1940 | jz .ret |
|
- | 1941 | .next_cluster: |
|
- | 1942 | movzx edi, word [edi*2+0x280000] |
|
- | 1943 | jmp .write_loop |
|
- | 1944 | ||
- | 1945 | ramdisk_extend_file.zero_size: |
|
- | 1946 | xor eax, eax |
|
- | 1947 | jmp ramdisk_extend_file.start_extend |
|
- | 1948 | ||
- | 1949 | ; extends file on ramdisk to given size, new data area is filled by 0 |
|
- | 1950 | ; in: edi->direntry, ecx=new size |
|
- | 1951 | ; out: CF=0 => OK, eax destroyed |
|
- | 1952 | ; CF=1 => error, eax=code (ERROR_FAT_TABLE or ERROR_DISK_FULL) |
|
- | 1953 | ramdisk_extend_file: |
|
- | 1954 | push ecx |
|
- | 1955 | ; find the last cluster of file |
|
- | 1956 | movzx eax, word [edi+26] ; first cluster |
|
- | 1957 | mov ecx, [edi+28] |
|
- | 1958 | jecxz .zero_size |
|
- | 1959 | @@: |
|
- | 1960 | sub ecx, 0x200 |
|
- | 1961 | jbe @f |
|
- | 1962 | mov eax, [eax*2+0x280000] |
|
- | 1963 | and eax, 0xFFF |
|
- | 1964 | jz .fat_err |
|
- | 1965 | cmp eax, 0xFF8 |
|
- | 1966 | jb @b |
|
- | 1967 | .fat_err: |
|
- | 1968 | pop ecx |
|
- | 1969 | push ERROR_FAT_TABLE |
|
- | 1970 | pop eax |
|
- | 1971 | stc |
|
- | 1972 | ret |
|
- | 1973 | @@: |
|
- | 1974 | push eax |
|
- | 1975 | mov eax, [eax*2+0x280000] |
|
- | 1976 | and eax, 0xFFF |
|
- | 1977 | cmp eax, 0xFF8 |
|
- | 1978 | pop eax |
|
- | 1979 | jb .fat_err |
|
- | 1980 | ; set length to full number of sectors and make sure that last sector is zero-padded |
|
- | 1981 | sub [edi+28], ecx |
|
- | 1982 | push eax edi |
|
- | 1983 | mov edi, eax |
|
- | 1984 | shl edi, 9 |
|
- | 1985 | lea edi, [edi+0x100000+31*512+0x200+ecx] |
|
- | 1986 | neg ecx |
|
- | 1987 | xor eax, eax |
|
- | 1988 | rep stosb |
|
- | 1989 | pop edi eax |
|
- | 1990 | .start_extend: |
|
- | 1991 | pop ecx |
|
- | 1992 | ; now do extend |
|
- | 1993 | push edx esi |
|
- | 1994 | mov esi, 0x280000+2*2 ; start scan from cluster 2 |
|
- | 1995 | mov edx, 2847 ; number of clusters to scan |
|
- | 1996 | .extend_loop: |
|
- | 1997 | cmp [edi+28], ecx |
|
- | 1998 | jae .extend_done |
|
- | 1999 | ; add new sector |
|
- | 2000 | push ecx |
|
- | 2001 | mov ecx, edx |
|
- | 2002 | push edi |
|
- | 2003 | mov edi, esi |
|
- | 2004 | jecxz .disk_full |
|
- | 2005 | push eax |
|
- | 2006 | xor eax, eax |
|
- | 2007 | repnz scasw |
|
- | 2008 | pop eax |
|
- | 2009 | jnz .disk_full |
|
- | 2010 | mov word [edi-2], 0xFFF |
|
- | 2011 | mov esi, edi |
|
- | 2012 | mov edx, ecx |
|
- | 2013 | sub edi, 0x280000 |
|
- | 2014 | shr edi, 1 |
|
- | 2015 | dec edi ; now edi=new cluster |
|
- | 2016 | test eax, eax |
|
- | 2017 | jz .first_cluster |
|
- | 2018 | mov [0x280000+eax*2], di |
|
- | 2019 | jmp @f |
|
- | 2020 | .first_cluster: |
|
- | 2021 | pop eax ; eax->direntry |
|
- | 2022 | push eax |
|
- | 2023 | mov [eax+26], di |
|
- | 2024 | @@: |
|
- | 2025 | push edi |
|
- | 2026 | shl edi, 9 |
|
- | 2027 | add edi, 0x100000+31*512 |
|
- | 2028 | xor eax, eax |
|
- | 2029 | mov ecx, 512/4 |
|
- | 2030 | rep stosd |
|
- | 2031 | pop eax ; eax=new cluster |
|
- | 2032 | pop edi ; edi->direntry |
|
- | 2033 | pop ecx ; ecx=required size |
|
- | 2034 | add dword [edi+28], 0x200 |
|
- | 2035 | jmp .extend_loop |
|
- | 2036 | .extend_done: |
|
- | 2037 | mov [edi+28], ecx |
|
- | 2038 | pop esi edx |
|
- | 2039 | clc |
|
- | 2040 | ret |
|
- | 2041 | .disk_full: |
|
- | 2042 | pop edi ecx |
|
- | 2043 | pop esi edx |
|
- | 2044 | stc |
|
- | 2045 | push ERROR_DISK_FULL |
|
- | 2046 | pop eax |
|
- | 2047 | ret |
|
1822 | 2048 | ||
1823 | fs_RamdiskGetFileInfo: |
2049 | fs_RamdiskGetFileInfo: |
1824 | cmp byte [esi], 0 |
2050 | cmp byte [esi], 0 |
1825 | jnz @f |
2051 | jnz @f |
1826 | mov eax, 2 ; unsupported |
2052 | mov eax, 2 ; unsupported |