diff --git a/kernel/trunk/core/memory.inc b/kernel/trunk/core/memory.inc index 9b456e0f76..f2d87cc7e4 100644 --- a/kernel/trunk/core/memory.inc +++ b/kernel/trunk/core/memory.inc @@ -1103,7 +1103,7 @@ f68: jbe sys_sheduler cmp ebx, 11 jb undefined_syscall - cmp ebx, 27 + cmp ebx, 28 ja undefined_syscall xor eax, eax jmp dword [f68call+ebx*4-11*4] @@ -1138,6 +1138,8 @@ f68: call srv_handlerEx ;ecx mov [esp+SYSCALL_STACK._eax], eax ret +.18: + mov eax, edx .19: cmp ecx, OS_BASE jae .fail @@ -1199,6 +1201,24 @@ f68: mov [esp+SYSCALL_STACK._edx], edx mov [esp+SYSCALL_STACK._eax], eax ret +.28: + cmp ecx, OS_BASE + jae .fail + push ecx edx + stdcall kernel_alloc, maxPathLength + mov edi, eax + pop eax esi + push edi + call getFullPath + pop ebp + test eax, eax + jz @f + stdcall load_file_umode, ebp + mov [esp+SYSCALL_STACK._edx], edx +@@: + mov [esp+SYSCALL_STACK._eax], eax + stdcall kernel_free, ebp + ret .fail: mov [esp+SYSCALL_STACK._eax], eax @@ -1214,7 +1234,7 @@ f68call: ; keep this table closer to main code dd f68.fail ; moved to f68.24 dd f68.16 ; get_service dd f68.17 ; call_service - dd f68.fail ; moved to f68.25 + dd f68.18 ; loadLibUnicode dd f68.19 ; load_dll dd f68.20 ; user_realloc dd f68.21 ; load_driver @@ -1224,7 +1244,7 @@ f68call: ; keep this table closer to main code dd f68.25 ; unmask exception dd f68.26 ; user_unmap dd f68.27 ; load_file_umode - + dd f68.28 ; loadFileUnicode align 4 proc load_pe_driver stdcall, file:dword, cmdline:dword diff --git a/kernel/trunk/core/syscall.inc b/kernel/trunk/core/syscall.inc index 7ff76dd9e1..015f1015b9 100644 --- a/kernel/trunk/core/syscall.inc +++ b/kernel/trunk/core/syscall.inc @@ -176,6 +176,9 @@ iglobal dd sys_socket ; 75-reserved for new stack dd sys_protocols ; 76-reserved for new stack dd sys_synchronization ; 77 + dd undefined_syscall ; 78-free + dd undefined_syscall ; 79-free + dd fileSystemUnicode ; 80-File system interface for different encodings times 255 - ( ($-servetable2) /4 ) dd undefined_syscall dd sys_end ; -1-end application diff --git a/kernel/trunk/docs/sysfuncr.txt b/kernel/trunk/docs/sysfuncr.txt index 0aae441373..371a1062a2 100644 --- a/kernel/trunk/docs/sysfuncr.txt +++ b/kernel/trunk/docs/sysfuncr.txt @@ -1695,7 +1695,6 @@ Remarks: ====================================================================== ================ Функция 30 - работа с текущей папкой. =============== ====================================================================== - -------- Подфункция 1 - установить текущую папку для потока. --------- Параметры: * eax = 30 - номер функции @@ -1704,7 +1703,7 @@ Remarks: правила формирования строки указаны в описании функции 70. Возвращаемое значение: * функция не возвращает значения - +---------------------------------------------------------------------- --------- Подфункция 2 - получить текущую папку для потока. ---------- Параметры: * eax = 30 - номер функции @@ -1712,27 +1711,21 @@ Remarks: * ecx = указатель на буфер * edx = размер буфера Возвращаемое значение: - * eax = длина имени текущей папки (включая завершающий 0) + * eax = длина строки (включая завершающий 0) Замечания: - * Если размера буфера недостаточно для копирования всего имени, - копируются только первые (edx-1) байт и в конце ставится - завершающий 0. + * Если размера буфера недостаточно для копирования всего пути, + копируются только часть строки и в конце ставится завершающий 0. * По умолчанию, текущая папка для потока - "/rd/1". * При создании процесса/потока текущая папка наследуется от родителя. - +---------------------------------------------------------------------- ---- Подфункция 3 - установить доп. системную директорию для ядра ---- Параметры: * eax = 30 - номер функции * ebx = 3 - номер подфункции * ecx = указатель на блок данных: - для кодировки cp866: key rb 64 path rb 64 - для кодировки UTF-16LE: -key rb 64 - dw 2 -path rw 31 Пример: align 64 key db 'kolibrios',0 ; ключ должен быть в нижнем регистре @@ -1743,20 +1736,29 @@ path db 'HD0/1',0 * функция не возвращает значения Замечания: * Функция может быть вызвана только 1 раз за 1 сессию работы ОС. - * Кодировка не влияет на символьный ключ. - ------ Подфункция 4 - получить текущую папку в кодировке UTF-16LE ----- + * При вводе пути символьный ключ не зависит от кодировки. +---------------------------------------------------------------------- +--- Подфункция 4 - установить текущую папку с указанием кодировки. --- Параметры: * eax = 30 - номер функции * ebx = 4 - номер подфункции + * ecx = указатель на строку с путём к новой текущей папке + * edx = кодировка строки, подробности указаны в описании функции 80. +Возвращаемое значение: + * функция не возвращает значения +---------------------------------------------------------------------- +---- Подфункция 5 - получить текущую папку с указанием кодировки. ---- +Параметры: + * eax = 30 - номер функции + * ebx = 5 - номер подфункции * ecx = указатель на буфер * edx = размер буфера + * esi = кодировка строки Возвращаемое значение: - * eax = количество символов в строке (включая завершающий 0) + * eax = длина строки в байтах (включая завершающий 0) Замечания: - * Если размера буфера недостаточно для копирования всего имени, - копируются только первые (edx-2) байт и в конце ставится - завершающий 0. + * Если размера буфера недостаточно для копирования всего пути, + копируются только часть строки и в конце ставится завершающий 0. * По умолчанию, текущая папка для потока - "/rd/1". * При создании процесса/потока текущая папка наследуется от родителя. @@ -3380,6 +3382,22 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); eax - SF_SYS_MISC (68) ebx - SSF_CONTROL_DRIVER (17) ====================================================================== +== Функция 68, подфункция 18 - загрузить DLL с указанием кодировки. == +====================================================================== +Параметры: + * eax = 68 - номер функции + * ebx = 18 - номер подфункции + * ecx = указатель на строку с путём к DLL + * edx = кодировка строки, подробности указаны в описании функции 80. +Возвращаемое значение: + * eax = 0 - неудача + * иначе eax = указатель на таблицу экспорта DLL +Замечания: + * Таблица экспорта представляет собой массив структур по 2 dword'а, + заканчивающийся нулём. Первый dword в структуре является + указателем на имя функции, второй содержит адрес функции. + +====================================================================== ============= Функция 68, подфункция 19 - загрузить DLL. ============= ====================================================================== Параметры: @@ -3390,10 +3408,6 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); Возвращаемое значение: * eax = 0 - неудача * иначе eax = указатель на таблицу экспорта DLL -Замечания: - * Таблица экспорта представляет собой массив структур по 2 dword'а, - заканчивающийся нулём. Первый dword в структуре является - указателем на имя функции, второй содержит адрес функции. ---------------------- Константы для регистров: ---------------------- eax - SF_SYS_MISC (68) @@ -3557,7 +3571,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); eax - SF_SYS_MISC (68) ebx - SSF_SET_EXCEPTION_STATE (25) ====================================================================== -= Функция 68, подфункция 26 - освободить страницы памяти ============ +======= Функция 68, подфункция 26 - освободить страницы памяти ======= ====================================================================== Параметры: * eax = 68 - номер функции @@ -3573,7 +3587,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); eax - SF_SYS_MISC (68) ebx - SSF_MEM_FREE_EXT (26) ====================================================================== -= Функция 68, подфункция 27 - загрузить файл =================== +============= Функция 68, подфункция 27 - загрузить файл ============= ====================================================================== Параметры: * eax = 68 - номер функции @@ -3590,6 +3604,20 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); eax - SF_SYS_MISC (68) ebx - SSF_LOAD_FILE (27) ====================================================================== +== Функция 68, подфункция 28 - загрузить файл с указанием кодировки == +====================================================================== +Параметры: + * eax = 68 - номер функции + * ebx = 28 - номер подфункции + * ecx = указатель на строку с путём к файлу + * edx = кодировка строки, подробности указаны в описании функции 80. +Возвращаемое значение: + * eax = указатель на загруженный файл или 0 + * edx = размер загруженного файла или 0 +Примечания: + * функция загружает и, при необходимости, распаковывает файл (kunpack) + +====================================================================== ======================== Функция 69 - отладка. ======================= ====================================================================== Процесс может загрузить другой процесс как отлаживаемый установкой @@ -3891,9 +3919,9 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); в других регистрах Общий формат информационной структуры: * +0: dword: номер подфункции - * +4: dword: смещение в файле - * +8: dword: старший dword смещения (должен быть 0) или поле флагов - * +12 = +0xC: dword: размер + * +4: dword: смещение в файле или папке + * +8: dword: старшая часть смещения или поле флагов + * +12 = +0xC: dword: размер данных * +16 = +0x10: dword: указатель на данные * +20 = +0x14: ?: текстовая строка - путь к файлу, заканчивается нулём или @@ -3902,13 +3930,14 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); Чувствительность к регистру букв зависит от файловой системы. Если путь начинается не с '/', то он считается относительным. Получить или установить текущую папку можно с помощью сисфункции 30. -'../' в начале пути означает подъём на одну папку относительно текущей. +'../' в пути означает подъём на одну папку относительно текущей. Можно указать кодировку строки, поместив в её начале байт со значениями: * 1 = cp866 * 2 = UTF-16LE * 3 = UTF-8 иначе будет использоваться кодировка cp866. В абсолютном пути можно поместить этот байт после '/' или добавить дополнительный '/' перед ним. +Также, можно использовать сисфункцию 80. Формат абсолютного пути: /base/number/dir1/dir2/.../dirn/file, где base/number идентифицирует устройство, на котором ищется файл: @@ -3992,11 +4021,12 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); * +0: dword: 1 = номер подфункции * +4: dword: индекс начального блока (считая с 0) * +8: dword: в какой кодировке возвращать имена: - 0 = cp866 -> байт на символ - 1 = UTF-16LE -> 2 байта на символ + 0 = по умолчанию + 1 = cp866 + 2 = UTF-16LE + 3 = UTF-8 * +12 = +0xC: dword: сколько блоков читать - * +16 = +0x10: dword: указатель на буфер, куда будут записаны - данные, размер буфера должен быть не меньше 32+n(40+256*enc+8) байт + * +16 = +0x10: dword: указатель на буфер, куда будут записаны данные. * +20 = +0x14: путь, правила формирования имён указаны в общем описании Возвращаемое значение: * eax = 0 - успешно, иначе код ошибки файловой системы @@ -4029,9 +4059,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); это может быть полезно для автоматического создания backup-архивов, ибо при записи бит обычно устанавливается (не в Kolibri, правда) - * +4: dword: кодировка имени: - * 0 = cp866 -> байт на символ - * 1 = UTF-16LE -> 2 байта на символ + * +4: dword: кодировка имени, соответствует полю +8 информационной структуры * +8: 4*byte: время создания файла * +12 = +0xC: 4*byte: дата создания файла * +16 = +0x10: 4*byte: время последнего доступа (чтение или запись) @@ -4039,7 +4067,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); * +24 = +0x18: 4*byte: время последней модификации * +28 = +0x1C: 4*byte: дата последней модификации * +32 = +0x20: qword: размер файла в байтах (до 16777216 Тб) - * +40 = +0x28: (256*enc+8)*byte: имя + * +40 = +0x28: имя, размер в cp866 составляет 264 байта, иначе - 520 байт. Формат времени: * +0: byte: секунды * +1: byte: минуты @@ -4052,9 +4080,8 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); * +2: word: год * например, 25.11.1979 записывается как (в hex) 19 0B BB 07 Замечания: - * Если в БДВК присутствует имя в cp866, то длина БДВК составляет - 304 байта, если в UTF-16LE - 560 байт. Значение длины выравнено - на целое кратное 16 байт для ускорения обработки в кэш-памяти CPU. + * Если БДВК содержит имя в cp866, то длина БДВК составляет + 304 байта, иначе - 560 байт. * Строка имени заканчивается нулём, дальнейшие данные содержат мусор. * Если файлы в папке кончились раньше, чем было прочитано запрошенное количество, то функция прочитает, сколько сможет, @@ -4343,7 +4370,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); B - блит на фоновую поферхность T - блит с прозрачностью CR - относительно клиентской области окна - + * ecx = указатель на параметры функции смещение цели и отсечение +0 signed dword: смещение по X окна, для целевого прямоугольника @@ -4834,6 +4861,31 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); ---------------------- Константы для регистров: ---------------------- eax - SF_TERMINATE_PROCESS (-1) +====================================================================== +=== Функция 80 - работа с файловой системой с указанием кодировки. === +====================================================================== +Параметры: + * eax = 80 + * ebx = указатель на информационную структуру +Возвращаемое значение: + * eax = 0 - успешно; иначе код ошибки файловой системы + * в зависимости от подфункции может возвращаться значение и + в других регистрах +Общий формат информационной структуры: + * +0: dword: номер подфункции + * +4: dword: смещение в файле или папке + * +8: dword: старшая часть смещения или поле флагов + * +12 = +0xC: dword: размер данных + * +16 = +0x10: dword: указатель на данные + * +20 = +0x14: dword: кодировка строки: + 1 = cp866 + 2 = UTF-16LE + 3 = UTF-8 + 0 = по умолчанию (поддерживает байт кодировки в начале строки) + * +24 = +0x18: dword: указатель на строку пути (заканчивается нулём) + +В остальном полностью соответствует функции 70. + ====================================================================== =========================== Список событий =========================== ====================================================================== diff --git a/kernel/trunk/docs/sysfuncs.txt b/kernel/trunk/docs/sysfuncs.txt index 43366d0a83..a297529b2f 100644 --- a/kernel/trunk/docs/sysfuncs.txt +++ b/kernel/trunk/docs/sysfuncs.txt @@ -1677,7 +1677,6 @@ Remarks: ====================================================================== ============= Function 30 - work with the current folder. ============ ====================================================================== - --------- Subfunction 1 - set current folder for the thread. --------- Parameters: * eax = 30 - function number @@ -1686,7 +1685,7 @@ Parameters: rules of path forming can be found in function 70 description. Returned value: * function does not return value - +---------------------------------------------------------------------- --------- Subfunction 2 - get current folder for the thread. --------- Parameters: * eax = 30 - function number @@ -1694,26 +1693,21 @@ Parameters: * ecx = pointer to buffer * edx = size of buffer Returned value: - * eax = size of the current folder's name (including terminating 0) + * eax = size of the string (including terminating 0) Remarks: - * If the buffer is too small to hold all data, only first (edx-1) - bytes are copied and than terminating 0 is inserted. + * If the buffer is too small to hold all path, only part of the string + will be copied and terminated with 0. * By default, current folder for the thread is "/rd/1". * At process/thread creation the current folder will be inherited from the parent. - +---------------------------------------------------------------------- --- Subfunction 3 - install the add.system directory for the kernel -- Parameters: * eax = 30 - function number * ebx = 3 - subfunction number * ecx = pointer to a block of data: - for cp866 encoding: key rb 64 path rb 64 - for UTF-16LE encoding: -key rb 64 - dw 2 -path rw 31 Example: align 64 key db 'kolibrios',0 ; key must be in lower case @@ -1724,19 +1718,29 @@ Returned value: * function does not return value Remarks: * The function can be called only 1 time for 1 session of the OS. - * The key is not affected by encoding. - ------- Subfunction 4 - get current folder in UTF-16LE encoding. ------ + * On input the symbolic key is not changing by encoding. +---------------------------------------------------------------------- +---- Subfunction 4 - set current folder, specifying the encoding. ---- Parameters: * eax = 30 - function number * ebx = 4 - subfunction number + * ecx = pointer to string with the path to new current folder + * edx = string encoding, details can be found in function 80 description. +Returned value: + * function does not return value +---------------------------------------------------------------------- +---- Subfunction 5 - get current folder, specifying the encoding. ---- +Parameters: + * eax = 30 - function number + * ebx = 5 - subfunction number * ecx = pointer to buffer * edx = size of buffer + * esi = string encoding Returned value: - * eax = number of chars in the buffer (including terminating 0) + * eax = size of the string in bytes (including terminating 0) Remarks: - * If the buffer is too small to hold all data, only first (edx-2) - bytes are copied and than terminating 0 is inserted. + * If the buffer is too small to hold all path, only part of the string + will be copied and terminated with 0. * By default, current folder for the thread is "/rd/1". * At process/thread creation the current folder will be inherited from the parent. @@ -3343,6 +3347,22 @@ Remarks: eax - SF_SYS_MISC (68) ebx - SSF_CONTROL_DRIVER (17) ====================================================================== +== Function 68, subfunction 18 - load DLL, specifying the encoding. == +====================================================================== +Parameters: + * eax = 68 - function number + * ebx = 18 - subfunction number + * ecx = pointer to the string with path to DLL + * edx = string encoding, details can be found in function 80 description. +Returned value: + * eax = 0 - failed + * otherwise eax = pointer to DLL export table +Remarks: + * Export table is an array of structures of 2 dword's, terminated + by zero. The first dword in structure points to function name, + the second dword contains address of function. + +====================================================================== =============== Function 68, subfunction 19 - load DLL. ============== ====================================================================== Parameters: @@ -3353,10 +3373,6 @@ Parameters: Returned value: * eax = 0 - failed * otherwise eax = pointer to DLL export table -Remarks: - * Export table is an array of structures of 2 dword's, terminated - by zero. The first dword in structure points to function name, - the second dword contains address of function. ---------------------- Constants for registers: ---------------------- eax - SF_SYS_MISC (68) @@ -3552,6 +3568,20 @@ Remarks: eax - SF_SYS_MISC (68) ebx - SSF_LOAD_FILE (27) ====================================================================== +== Function 68, subfunction 28 - load file, specifying the encoding == +====================================================================== +Parameters: + * eax = 68 - function number + * ebx = 28 - subfunction number + * ecx = pointer to the string with path to file + * edx = string encoding, details can be found in function 80 description. +Returned value: + * eax = pointer to the loaded file, or zero + * edx = size of the loaded file, or zero +Remarks: + * function loads file and unpacks, if necessary + +====================================================================== ====================== Function 69 - debugging. ====================== ====================================================================== A process can load other process as debugged by set of corresponding @@ -3847,9 +3877,9 @@ Returned value: * some subfunctions return value in other registers too General format of the information structure: * +0: dword: subfunction number - * +4: dword: file offset - * +8: dword: high dword of offset (must be 0) or flags field - * +12 = +0xC: dword: size + * +4: dword: offset in file or folder + * +8: dword: higher part of offset or flags + * +12 = +0xC: dword: size of data * +16 = +0x10: dword: pointer to data * +20 = +0x14: ?: path - zero terminated string or @@ -3857,14 +3887,15 @@ General format of the information structure: * +21 = +0x15: dword: pointer to string Case sensitivity depends on filesystem. If a path not begins with '/', it is considered a relative. -To get or set the current folder, use the function 30. -'../' in the beginning means a lift by one folder relatively current folder. +To get or set the current folder, use the sysfunction 30. +'../' in the path means a lift by one folder relatively current folder. To set the encoding, put at the start of the string a byte with next values: * 1 = cp866 * 2 = UTF-16LE * 3 = UTF-8 otherwise will be used cp866. In an absolute path you may put this byte after the '/' or put an additional '/' before it. + Also, you may use the sysfunction 80. Format of an absolute path: /base/number/dir1/dir2/.../dirn/file, where base/number identifies device, on which file is located: @@ -3945,12 +3976,13 @@ Parameters: Format of the information structure: * +0: dword: 1 = subfunction number * +4: dword: index of starting block (beginning from 0) - * +8: dword: encoding: - * 0 = cp866 -> byte per char - * 1 = UTF-16LE -> word per char + * +8: dword: names encoding: + 0 = default + 1 = cp866 + 2 = UTF-16LE + 3 = UTF-8 * +12 = +0xC: dword: number of blocks to read - * +16 = +0x10: dword: pointer to buffer for data, buffer size - must be not less than 32+n(40+256*enc+8) bytes + * +16 = +0x10: dword: pointer to buffer for data * +20 = +0x14: path, general rules of names forming Returned value: * eax = 0 - success, otherwise file system error code @@ -3982,9 +4014,7 @@ Structure of block of data for folder entry (BDFE): and after archiving this bit is cleared - it can be useful for automatically creating of backup-archives as at writing this bit is usually set - * +4: dword: encoding: - * 0 = cp866 -> byte per char - * 1 = UTF-16LE -> word per char + * +4: dword: encoding, equals to field +8 in the information structure * +8: 4*byte: time of file creation * +12 = +0xC: 4*byte: date of file creation * +16 = +0x10: 4*byte: time of last access (read or write) @@ -3992,7 +4022,7 @@ Structure of block of data for folder entry (BDFE): * +24 = +0x18: 4*byte: time of last modification * +28 = +0x1C: 4*byte: date of last modification * +32 = +0x20: qword: file size in bytes (up to 16777216 Tb) - * +40 = +0x28: (256*enc+8)*byte: name + * +40 = +0x28: name, 264 bytes in cp866, otherwise - 520 bytes. Time format: * +0: byte: seconds * +1: byte: minutes @@ -4006,8 +4036,7 @@ Date format: * for example, 25.11.1979 is written as (in hex) 19 0B BB 07 Remarks: * If BDFE contains cp866 name, the length of BDFE is 304 bytes, - if UTF-16LE name - 560 bytes. Value of length is aligned - on 16-byte bound to accelerate processing in CPU cache. + otherwise - 560 bytes. * Name string is zero terminated, further data contain garbage. * If files in folder were ended before requested number was read, the function will read as many as it can, and after that return @@ -5046,6 +5075,30 @@ Remarks: ---------------------- Constants for registers: ---------------------- eax - SF_FUTEX (77) ebx - SSF_WAKE (3) +====================================================================== +=== Function 80 - file system interface with parameter of encoding === +====================================================================== +Parameters: + * eax = 80 + * ebx = pointer to the information structure +Returned value: + * eax = 0 - success; otherwise file system error code + * some subfunctions return value in other registers too +General format of the information structure: + * +0: dword: subfunction number + * +4: dword: offset in file or folder + * +8: dword: higher part of offset or flags + * +12 = +0xC: dword: size of data + * +16 = +0x10: dword: pointer to data + * +20 = +0x14: dword: string encoding: + 1 = cp866 + 2 = UTF-16LE + 3 = UTF-8 + 0 = default (supports encoding byte at the start of the string) + * +24 = +0x18: dword: pointer to zero terminated string with path + +The rest is similar to sysfunction 70. + ====================================================================== =============== Function -1 - terminate thread/process =============== ====================================================================== diff --git a/kernel/trunk/fs/ext.inc b/kernel/trunk/fs/ext.inc index a1f7a33ca6..3e5a32acb6 100644 --- a/kernel/trunk/fs/ext.inc +++ b/kernel/trunk/fs/ext.inc @@ -1900,13 +1900,15 @@ ext_ReadFolder: mov esi, [esp+12] movzx ecx, [esi+DIRENTRY.nameLength] lea esi, [esi+DIRENTRY.name] - add ecx, esi cmp byte [esi], '.' jnz @f or byte [edx], KOS_HIDDEN @@: lea edi, [edx+40] - cmp byte [edx+4], 1 + cmp byte [edx+4], 3 + jz .utf8 + add ecx, esi + cmp byte [edx+4], 2 jz .utf16 @@: call utf8to16 @@ -1932,6 +1934,12 @@ ext_ReadFolder: push .wanted_start jmp .end_block +.utf8: + rep movsb + mov byte [edi], 0 + add edx, 40+520 + jmp @b + .utf16: call utf8to16 stosw diff --git a/kernel/trunk/fs/fat.inc b/kernel/trunk/fs/fat.inc index 0c12e547b1..674aeb1b34 100644 --- a/kernel/trunk/fs/fat.inc +++ b/kernel/trunk/fs/fat.inc @@ -1410,26 +1410,36 @@ fat_entry_to_bdfe2: push edi esi mov edi, esi mov esi, ebp - test byte [ebp-4], 1 - jz .ansi -.uni: - lodsw - stosw - test eax, eax - jnz .uni - pop esi edi - add esi, 520 -.ret: - ret - -.ansi: + cmp byte [ebp-4], 2 + jz .utf16 + cmp byte [ebp-4], 3 + jz .utf8 +@@: lodsw call uni2ansi_char stosb test al, al - jnz .ansi + jnz @b pop esi edi add esi, 264 +.ret: + ret + +.utf8: + push ecx + mov ecx, 519 + call UTF16to8_string + pop ecx + jmp @f + +.utf16: + lodsw + stosw + test eax, eax + jnz .utf16 +@@: + pop esi edi + add esi, 520 ret bdfe_to_fat_entry: diff --git a/kernel/trunk/fs/fs_lfn.inc b/kernel/trunk/fs/fs_lfn.inc index d6a81bf0d1..81f0608e18 100644 --- a/kernel/trunk/fs/fs_lfn.inc +++ b/kernel/trunk/fs/fs_lfn.inc @@ -38,31 +38,30 @@ file_system_lfn_protected: mov [image_of_ebx], ebx ret +fileSystemUnicode: +; in: ebx -> f.80 parameter structure + mov edi, [ebx+20] + mov esi, [ebx+24] + jmp @f + file_system_lfn: -; in: ebx -> parameter structure - lea ebp, [ebx+20] - cmp byte [ebp], 0 +; in: ebx -> f.70 parameter structure + xor edi, edi + lea esi, [ebx+20] + cmp byte [esi], 0 jnz @f - mov ebp, [ebx+21] + mov esi, [ebx+21] @@: - cmp word [ebp], '/' - jz .rootdir - cmp byte [ebp], 4 - jnc @f - cmp byte [ebp], 0 - jz @f - cmp word [ebp+1], '/' + cmp word [esi], '/' jnz @f - cmp byte [ebp], 2 + cmp edi, 2 jnz .rootdir - cmp word [ebp+3], 0 + cmp dword[esi], '/' jz .rootdir @@: stdcall kernel_alloc, maxPathLength push eax ebx xchg eax, edi - mov esi, ebp - xor eax, eax call getFullPath pop ebx ebp test eax, eax @@ -367,9 +366,11 @@ process_replace_file_name: lodsb test al, al jz .cont - or al, 20h scasb jz @b + or al, 20h + cmp [edi-1], al + jz @b .cont: pop edi esi inc edi @@ -397,14 +398,19 @@ endg sys_current_directory: ; sysfunction 30 mov eax, [current_slot] mov edi, [eax+APPDATA.cur_dir] + xor eax, eax dec ebx jz .set dec ebx jz .get dec ebx jz .mount_additional_directory + mov eax, edx dec ebx - jz .get16 + jz .set + mov eax, esi + dec ebx + jz .get @@: ret @@ -416,26 +422,17 @@ sys_current_directory: ; sysfunction 30 jnz @b mov esi, ecx mov edi, sysdir_name1 - mov ecx, 63 + mov ecx, 64 rep movsb ; copying fake directory name - inc esi - xor eax, eax - stosb ; terminator of name, in case if we get the inlet trash + mov byte [edi-1], 0 mov cl, 63 - cmp word [esi], 2 - jz .utf16 call cp866toUTF8_string -@@: mov byte [edi], 0 mov [full_file_name_table.size], 2 ret -.utf16: - add esi, 2 - call UTF16to8_string - jmp @b - -.get: ; in: ecx -> buffer, edx = length +.get: +; in: ecx -> buffer, edx = length, eax = encoding mov esi, edi inc esi mov edi, ecx @@ -444,6 +441,11 @@ sys_current_directory: ; sysfunction 30 mov edx, maxPathLength @@: mov ecx, edx + jecxz .ret + cmp eax, 2 + jz .get16 + cmp eax, 3 + jz .get8 @@: dec ecx js @f @@ -453,21 +455,26 @@ sys_current_directory: ; sysfunction 30 test al, al jnz @b sub edx, ecx - mov ecx, edx @@: - mov [esp+32], ecx + mov byte [edi-1], 0 +.ret: + mov [esp+32], edx ret -.get16: - mov esi, edi - inc esi - mov edi, ecx - cmp edx, maxPathLength - jc @f - mov edx, maxPathLength -@@: - shr edx, 1 +.get8: + push edi + mov edi, esi + xor eax, eax + repnz scasb + sub edx, ecx mov ecx, edx + pop edi + rep movsb + jmp @b + +.get16: + shr ecx, 1 + shr edx, 1 @@: dec ecx js @f @@ -476,14 +483,13 @@ sys_current_directory: ; sysfunction 30 test ax, ax jnz @b sub edx, ecx - mov ecx, edx @@: - mov [esp+32], ecx - ret + shl edx, 1 + mov word [edi-2], 0 + jmp .ret .set: mov esi, ecx - xor eax, eax getFullPath: ; in: esi -> file path, eax = string encoding, edi -> destination ; out: UTF-8 string (with marker), eax = length, 0 -> error diff --git a/kernel/trunk/fs/iso9660.inc b/kernel/trunk/fs/iso9660.inc index 696bf5cf0b..5576594491 100644 --- a/kernel/trunk/fs/iso9660.inc +++ b/kernel/trunk/fs/iso9660.inc @@ -297,34 +297,44 @@ fs_CdReadFolder: push edi call cd_find_lfn jnc .found - pop edi cmp [DevErrorCode], 0 jne .noaccess_1 - or ebx, -1 mov eax, ERROR_FILE_NOT_FOUND ret -;-------------------------------------- + .found: mov edi, [cd_current_pointer_of_input] test byte [edi+25], 10b ; do not allow read directories jnz .found_dir - pop edi -;-------------------------------------- .noaccess_1: or ebx, -1 mov eax, ERROR_ACCESS_DENIED ret -;-------------------------------------- + +.end_buffer: + pop edx eax + sub eax, 2048 ; directory is over? + ja .read_to_buffer + mov eax, [cd_counter_block] + mov [edx+8], eax + mov eax, [ebx] + sub [edx+4], eax + xor eax, eax + dec ecx + js @f + mov al, ERROR_END_OF_FILE +@@: + pop ecx edi + mov ebx, [edx+4] + ret + .found_dir: mov eax, [edi+2] ; eax=cluster mov [CDSectorAddress], eax mov eax, [edi+10] ; directory size -;-------------------------------------- -.doit: -; init header push eax ecx mov edi, edx mov ecx, 32/4 @@ -334,153 +344,115 @@ fs_CdReadFolder: mov byte [edx], 1 ; version mov [cd_mem_location], edx add [cd_mem_location], 32 -;.mainloop: mov [cd_counter_block], dword 0 dec dword [CDSectorAddress] push ecx -;-------------------------------------- .read_to_buffer: inc dword [CDSectorAddress] mov [CDDataBuf_pointer], CDDataBuf - call ReadCDWRetr ; read sector of directory + call ReadCDWRetr ; read sector of directory cmp [DevErrorCode], 0 jne .noaccess_1 - - call .get_names_from_buffer - sub eax, 2048 -; directory is over? - ja .read_to_buffer - - mov edi, [cd_counter_block] - mov [edx+8], edi - mov edi, [ebx] - sub [edx+4], edi - xor eax, eax - dec ecx - js @f - - mov al, ERROR_END_OF_FILE -;-------------------------------------- -@@: - pop ecx edi - mov ebx, [edx+4] - ret -;-------------------------------------- -.get_names_from_buffer: mov [cd_current_pointer_of_input_2], CDDataBuf - push eax esi edi edx -;-------------------------------------- -.get_names_from_buffer_1: + push eax edx +.get_names_from_buffer: call cd_get_name jc .end_buffer - inc dword [cd_counter_block] mov eax, [cd_counter_block] cmp [ebx], eax - jae .get_names_from_buffer_1 - + jae .get_names_from_buffer test ecx, ecx - jz .get_names_from_buffer_1 - + jz .get_names_from_buffer mov edi, [cd_counter_block] mov [edx+4], edi dec ecx mov esi, ebp - mov edi, [cd_mem_location] + call cd_get_parameters_of_file add edi, 40 - test dword [ebx+4], 1; 0=ANSI, 1=UNICODE - jnz .unicode -;-------------------------------------- -.ansi: + mov ax, '.' + cmp dword[ebx+4], 2 + jz .utf16 + cmp dword[ebx+4], 3 + jz .utf8 cmp [cd_counter_block], 2 - jbe .ansi_parent_directory - - cld + jbe .parentDirectory +@@: lodsw xchg ah, al call uni2ansi_char - cld stosb -; check end of file - mov ax, [esi] - cmp ax, word 3B00h ; separator end of file ';' - je .cd_get_parameters_of_file_1 -; check for files not ending with separator - movzx eax, byte [ebp-33] - add eax, ebp - sub eax, 34 - cmp esi, eax - je .cd_get_parameters_of_file_1 -; check the end of the directory - movzx eax, byte [ebp-1] - add eax, ebp - cmp esi, eax - jb .ansi -;-------------------------------------- -.cd_get_parameters_of_file_1: + call .checkForEnd + jc @b +@@: mov [edi], byte 0 - call cd_get_parameters_of_file add [cd_mem_location], 304 - jmp .get_names_from_buffer_1 -;-------------------------------------- -.ansi_parent_directory: - cmp [cd_counter_block], 2 - je @f + jmp .get_names_from_buffer - mov [edi], byte '.' - inc edi - jmp .cd_get_parameters_of_file_1 -;-------------------------------------- +.parentDirectory: + stosb + cmp [cd_counter_block], 2 + jnz @b + stosb + jmp @b + +.utf8: + add [cd_mem_location], 256 + cmp [cd_counter_block], 2 + jbe .parentDirectory + push ecx + mov ecx, 519 @@: - mov [edi], word '..' - add edi, 2 - jmp .cd_get_parameters_of_file_1 -;-------------------------------------- -.unicode: - cmp [cd_counter_block], 2 - jbe .unicode_parent_directory + lodsw + xchg ah, al + call UTF16to8 + js @f + call .checkForEnd + jc @b +@@: + pop ecx + mov [edi], byte 0 + add [cd_mem_location], 304 + jmp .get_names_from_buffer - cld - movsw -; check end of file +.checkForEnd: mov ax, [esi] - cmp ax, word 3B00h; separator end of file ';' - je .cd_get_parameters_of_file_2 + cmp ax, 3B00h ; ';' + jz @f ; check for files not ending with separator movzx eax, byte [ebp-33] add eax, ebp sub eax, 34 cmp esi, eax - je .cd_get_parameters_of_file_2 + jz @f ; check the end of the directory movzx eax, byte [ebp-1] add eax, ebp cmp esi, eax - jb .unicode -;-------------------------------------- -.cd_get_parameters_of_file_2: - mov [edi], word 0 - call cd_get_parameters_of_file - add [cd_mem_location], 560 - jmp .get_names_from_buffer_1 -;-------------------------------------- -.unicode_parent_directory: - cmp [cd_counter_block], 2 - je @f - - mov [edi], word 2E00h; '.' - add edi, 2 - jmp .cd_get_parameters_of_file_2 -;-------------------------------------- @@: - mov [edi], dword 2E002E00h; '..' - add edi, 4 - jmp .cd_get_parameters_of_file_2 -;-------------------------------------- -.end_buffer: - pop edx edi esi eax ret -;----------------------------------------------------------------------------- + +.utf16: + cmp [cd_counter_block], 2 + jbe .utf16ParentDirectory +@@: + lodsw + xchg ah, al + stosw + call .checkForEnd + jc @b +@@: + mov [edi], word 0 + add [cd_mem_location], 560 + jmp .get_names_from_buffer + +.utf16ParentDirectory: + stosw + cmp [cd_counter_block], 2 + jnz @b + stosw + jmp @b + cd_get_parameters_of_file: mov edi, [cd_mem_location] cd_get_parameters_of_file_1: @@ -492,9 +464,7 @@ cd_get_parameters_of_file_1: ; is a directory? test [ebp-8], byte 2 jz .file - inc eax -;-------------------------------------- .file: ; not as a volume label in the FAT, in this form not available ; file is not a system @@ -502,14 +472,14 @@ cd_get_parameters_of_file_1: ; file is hidden? (attribute of existence) test [ebp-8], byte 1 jz .hidden - inc eax -;-------------------------------------- .hidden: shl eax, 1 ; file is always read-only, as this CD inc eax mov [edi], eax + mov eax, [ebx+4] + mov [edi+4], eax ; get the time to file ; hour movzx eax, byte [ebp-12] @@ -541,19 +511,6 @@ cd_get_parameters_of_file_1: mov [edi+20], eax ; last write date mov [edi+28], eax -; get the data type of name - xor eax, eax - test dword [ebx+4], 1; 0=ANSI, 1=UNICODE - jnz .unicode_1 - - mov [edi+4], eax - jmp @f -;-------------------------------------- -.unicode_1: - inc eax - mov [edi+4], eax -;-------------------------------------- -@@: ; get the file size in bytes xor eax, eax mov [edi+32+4], eax diff --git a/kernel/trunk/fs/ntfs.inc b/kernel/trunk/fs/ntfs.inc index 5dc3b0b419..95cfb31fc9 100644 --- a/kernel/trunk/fs/ntfs.inc +++ b/kernel/trunk/fs/ntfs.inc @@ -1676,23 +1676,22 @@ ntfs_ReadFolder: mov al, '.' push edi ecx lea ecx, [esi+1] - test byte [edi-0x24], 1 + cmp dword[edi-36], 2 + jz .utf16sp + rep stosb + mov byte [edi], 0 + pop ecx edi + cmp dword[edi-36], 3 jz @f - rep stosw - pop ecx - xor eax, eax - stosw - pop edi - add edi, 520 + add edi, 264 ret +.utf16sp: + rep stosw + mov word [edi], 0 + pop ecx edi @@: - rep stosb - pop ecx - xor eax, eax - stosb - pop edi - add edi, 264 + add edi, 520 .ret: ret @@ -1701,9 +1700,10 @@ ntfs_ReadFolder: cmp byte [esi+namespace], 2 jz .ret ; do not return system files -; ... note that there will be no bad effects if system files also were reported ... - cmp dword [esi+fileRecordReference], 0x10 + cmp dword[esi+fileRecordReference], 16 jb .ret + cmp byte [esi+fileNameLength], 0 + jz .ret mov eax, [edx] inc dword [eax+8] ; new file found dec ebx @@ -1716,33 +1716,42 @@ ntfs_ReadFolder: push ecx esi edi movzx ecx, byte [esi+fileNameLength] add esi, fileName - test byte [edi-0x24], 1 - jz .ansi - shr ecx, 1 - rep movsd - adc ecx, ecx - rep movsw - and word [edi], 0 - pop edi - add edi, 520 - pop esi ecx - ret - -.ansi: - jecxz .skip + cmp dword[edi-36], 2 + jz .utf16 + cmp dword[edi-36], 3 + jz .utf8 @@: lodsw call uni2ansi_char stosb loop @b -.skip: - xor al, al - stosb - pop edi + mov byte [edi], 0 + pop edi esi ecx add edi, 264 - pop esi ecx ret +.utf8: + push ecx + mov cx, 519 +@@: + lodsw + call UTF16to8 + js @f + dec dword[esp] + jnz @b +@@: + mov byte [edi], 0 + pop edi +@@: + pop edi esi ecx + add edi, 520 + ret + +.utf16: + rep movsw + mov word [edi], 0 + jmp @b + ntfs_direntry_to_bdfe: mov [edi+4], eax ; ANSI/UNICODE name mov eax, [esi+fileFlags]