From 7dfe6edff5f81349fdd4e6670f3857c0211a83b5 Mon Sep 17 00:00:00 2001 From: Olaf Siejka Date: Sat, 26 Mar 2011 23:36:56 +0000 Subject: [PATCH 01/66] [NTDLL] - Fix "entry point not found" harderror parameters. Patch by Thomas Faber See issue #5983 for more details. svn path=/trunk/; revision=51167 --- reactos/dll/ntdll/ldr/utils.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/reactos/dll/ntdll/ldr/utils.c b/reactos/dll/ntdll/ldr/utils.c index c9bb89bbb51..9ce0cbb9feb 100644 --- a/reactos/dll/ntdll/ldr/utils.c +++ b/reactos/dll/ntdll/ldr/utils.c @@ -1350,7 +1350,7 @@ RtlpRaiseImportNotFound(CHAR *FuncName, ULONG Ordinal, PUNICODE_STRING DllName) ULONG ErrorResponse; ULONG_PTR ErrorParameters[2]; ANSI_STRING ProcNameAnsi; - UNICODE_STRING ProcName; + ANSI_STRING DllNameAnsi; CHAR Buffer[8]; if (!FuncName) @@ -1360,16 +1360,16 @@ RtlpRaiseImportNotFound(CHAR *FuncName, ULONG Ordinal, PUNICODE_STRING DllName) } RtlInitAnsiString(&ProcNameAnsi, FuncName); - RtlAnsiStringToUnicodeString(&ProcName, &ProcNameAnsi, TRUE); - ErrorParameters[0] = (ULONG_PTR)&ProcName; - ErrorParameters[1] = (ULONG_PTR)DllName; + RtlUnicodeStringToAnsiString(&DllNameAnsi, DllName, TRUE); + ErrorParameters[0] = (ULONG_PTR)&ProcNameAnsi; + ErrorParameters[1] = (ULONG_PTR)&DllNameAnsi; NtRaiseHardError(STATUS_ENTRYPOINT_NOT_FOUND, 2, 3, ErrorParameters, OptionOk, &ErrorResponse); - RtlFreeUnicodeString(&ProcName); + RtlFreeAnsiString(&DllNameAnsi); } static NTSTATUS From 47d38c298964e7f213b7134fde9ef47b798b1481 Mon Sep 17 00:00:00 2001 From: Olaf Siejka Date: Sat, 26 Mar 2011 23:53:49 +0000 Subject: [PATCH 02/66] [RAPPS] - Add DoubleCommander to app list. Russian and Ukrainian translation by Igorko, Polish translation by me. [CMD] - Fix Russian translation of cmd. Patch by seven_ro. See bugreport no.#6043 svn path=/trunk/; revision=51168 --- .../rapps/rapps/doublecommander.txt | 21 + reactos/base/shell/cmd/lang/ru-RU.rc | 968 +++++++++--------- 2 files changed, 505 insertions(+), 484 deletions(-) create mode 100644 reactos/base/applications/rapps/rapps/doublecommander.txt diff --git a/reactos/base/applications/rapps/rapps/doublecommander.txt b/reactos/base/applications/rapps/rapps/doublecommander.txt new file mode 100644 index 00000000000..12169d2fd90 --- /dev/null +++ b/reactos/base/applications/rapps/rapps/doublecommander.txt @@ -0,0 +1,21 @@ +; UTF-8 + +[Section] +Name = Double Commander +Version = 0.4.5.2 beta +Licence = GPL +Description = Double Commander is an open source file manager with two panels side by side. You need 7-Zip or a similar Utility to extract it. +Size = 6.71MB +Category = 12 +URLSite = http://doublecmd.sourceforge.net/ +URLDownload = http://ignum.dl.sourceforge.net/project/doublecmd/DC%20for%20Windows%2032%20bit/Double%20Commander%200.4.5.2%20beta/doublecmd-0.4.5.2.i386-win32.zip +CDPath = none + +[Section.0415] +Description = Double Commander to menedżer plików, o otwartym źródle, z klasycznym układem dwóch paneli obok siebie. Do rozpakowania archiwum potrzebny jest 7-zip lub podobny program. + +[Section.0419] +Description = Double Commander - это открытый двухпанельный файловый менеджер. Вам нужен 7-Zip или подобная утилита для его распаковки. + +[Section.0422] +Description = Double Commander - це відкритий двопанельний файловий менеджер. Вам потрібен 7-Zip або подібна утиліта щоб розпакувати його. \ No newline at end of file diff --git a/reactos/base/shell/cmd/lang/ru-RU.rc b/reactos/base/shell/cmd/lang/ru-RU.rc index 97b3d4aef5b..c09389263fb 100644 --- a/reactos/base/shell/cmd/lang/ru-RU.rc +++ b/reactos/base/shell/cmd/lang/ru-RU.rc @@ -19,291 +19,291 @@ assoc .ext (print specific association)\n\ assoc .ext= (remove specific association)\n\ assoc .ext=FileType (add new association)\n" -STRING_ATTRIB_HELP, "Âûâîä è èçìåíåíèå àòðèáóòîâ ôàéëîâ.\n\n\ -ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] ôàéë ...\n\ +STRING_ATTRIB_HELP, "Вывод и изменение атрибутов файлов.\n\n\ +ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] файл ...\n\ [/S [/D]]\n\n\ - + Óñòàíîâêà àòðèáóòà.\n\ - - Ñíÿòèå àòðèáóòà.\n\ - R Àòðèáóò ""Òîëüêî ÷òåíèå"".\n\ - A Àòðèáóò ""Àðõèâíûé"".\n\ - S Àòðèáóò ""Ñèñòåìíûé"".\n\ - H Àòðèáóò ""Ñêðûòûé"".\n\ - /S Îáðàáîòêà ôàéëîâ ñ óêàçàííûìè èìåíàìè â òåêóùåé ïàïêå\n\ -è âî âñåõ åå ïîäïàïêàõ.\n\ - /D Îáðàáîòêà è ôàéëîâ, è ïàïîê.\n\n\ -ATTRIB áåç ïàðàìåòðîâ âûâîäèò àòðèáóòû âñåõ ôàéëîâ.\n" + + Установка атрибута.\n\ + - Снятие атрибута.\n\ + R Атрибут ""Только чтение"".\n\ + A Атрибут ""Архивный"".\n\ + S Атрибут ""Системный"".\n\ + H Атрибут ""Скрытый"".\n\ + /S Обработка файлов с указанными именами в текущей папке\n\ +и во всех ее подпапках.\n\ + /D Обработка и файлов, и папок.\n\n\ +ATTRIB без параметров выводит атрибуты всех файлов.\n" -STRING_ALIAS_HELP, "Âûâîä, óñòàíîâêà èëè óäàëåíèå ïñåâäîíèìîâ.\n\n\ -ALIAS [ïñåâäîíèì=[êîìàíäà]]\n\n\ - ïñåâäîíèì Íàèìåíîâàíèå ïñåâäîíèìà.\n\ - êîìàíäà Òåêñò, ïîäñòàâëÿåìûé âìåñòî ïñåâäîíèìà.\n\n\ -Âûâîä ñïèñêà âñåõ ïñåâäîíèìîâ:\n\ +STRING_ALIAS_HELP, "Вывод, установка или удаление псевдонимов.\n\n\ +ALIAS [псевдоним=[команда]]\n\n\ + псевдоним Наименование псевдонима.\n\ + команда Текст, подставляемый вместо псевдонима.\n\n\ +Вывод списка всех псевдонимов:\n\ ALIAS\n\n\ -Óñòàíîâêà èëè èçìåíåíèå ñóùåñòâóþùåãî ïñåâäîíèìà:\n\ +Установка или изменение существующего псевдонима:\n\ ALIAS da=dir a:\n\n\ -Óäàëåíèå ïñåâäîíèìà èç ñïèñêà:\n\ +Удаление псевдонима из списка:\n\ ALIAS da=" -STRING_BEEP_HELP, "Çâóêîâîé ñèãíàë.\n\nBEEP\n" +STRING_BEEP_HELP, "Звуковой сигнал.\n\nBEEP\n" -STRING_CALL_HELP, "Âûçîâ îäíîãî ïàêåòíîãî ôàéëà èç äðóãîãî.\n\n\ -CALL [äèñê:][ïóòü]èìÿ_ôàéëà [ïàðàìåòðû]\n\n\ - ïàðàìåòðû Íàáîð ïàðàìåòðîâ êîìàíäíîé ñòðîêè, íåîáõîäèìûõ\n\ - ïàêåòíîìó ôàéëó." +STRING_CALL_HELP, "Вызов одного пакетного файла из другого.\n\n\ +CALL [диск:][путь]имя_файла [параметры]\n\n\ + параметры Набор параметров командной строки, необходимых\n\ + пакетному файлу." -STRING_CD_HELP, "Âûâîä èìåíè ëèáî ñìåíà òåêóùåãî êàòàëîãà.\n\n\ -CHDIR [/D][äèñê:][ïóòü]\n\ +STRING_CD_HELP, "Вывод имени либо смена текущего каталога.\n\n\ +CHDIR [/D][диск:][путь]\n\ CHDIR[..|.]\n\ -CD [/D][äèñê:][ïóòü]\n\ +CD [/D][диск:][путь]\n\ CD[..|.]\n\n\ - .. îáîçíà÷àåò ðîäèòåëüñêèé êàòàëîã\n\ - . îáîçíà÷àåò òåêóùèé êàòàëîã\n\ - /D Îäíîâðåìåííàÿ ñìåíà òåêóùèõ äèñêà è êàòàëîãà.\n\n\ -Êîìàíäà CD äèñê: îòîáðàæàåò èìÿ òåêóùåãî êàòàëîãà óêàçàííîãî äèñêà.\n\ -Êîìàíäà CD áåç ïàðàìåòðîâ îòîáðàæàåò èìåíà òåêóùèõ äèñêà è êàòàëîãà.\n" + .. обозначает родительский каталог\n\ + . обозначает текущий каталог\n\ + /D Одновременная смена текущих диска и каталога.\n\n\ +Команда CD диск: отображает имя текущего каталога указанного диска.\n\ +Команда CD без параметров отображает имена текущих диска и каталога.\n" -STRING_CHCP_HELP, "Âûâîä èëè ñìåíà òåêóùåãî íîìåðà êîäîâîé ñòðàíèöû.\n\n\ +STRING_CHCP_HELP, "Вывод или смена текущего номера кодовой страницы.\n\n\ CHCP [nnn]\n\n\ - nnn Íîìåð êîäîâîé ñòðàíèöû.\n\n\ -Êîìàíäà CHCP áåç ïàðàìåòðà âûâîäèò òåêóùèé íîìåð êîäîâîé ñòðàíèöû.\n" + nnn Номер кодовой страницы.\n\n\ +Команда CHCP без параметра выводит текущий номер кодовой страницы.\n" -STRING_CHOICE_HELP, "Æäåò, ïîêà ïîëüçîâàòåëü íå âûáåðåò îäèí èç óêàçàííûõ â ñïèñêå ñèìâîëîâ.\n\n\ -CHOICE [/C[:]ñïèñîê_ñèìâîëîâ][/N][/S][/T[:]c,nn][òåêñò]\n\n\ - /C[:]ñïèñîê_ñèìâîëîâ Óêàçûâàåò äîïóñòèìûå ñèìâîëû. Ïî óìîë÷àíèþ ýòî YN.\n\ - /N Íå âûâîäèòü ñïèñîê ñèìâîëîâ è ? ïîñëå ïîäñêàçêè.\n\ - /S Òðàêòîâàòü ñèìâîëû êàê ÷óâñòâèòåëüíûå ê ðåãèñòðó.\n\ - /T[:]c,nn Ïî óìîë÷àíèþ âûáîð c ïî èñòå÷åíèè nn ñåêóíä.\n\ - text Ïîäñêàçêà.\n\n\ -ERRORLEVEL óñòàíàâëèâàåòñÿ ðàâíûì íîìåðó âûáðàííîãî ñèìâîëà.\n" +STRING_CHOICE_HELP, "Ждет, пока пользователь не выберет один из указанных в списке символов.\n\n\ +CHOICE [/C[:]список_символов][/N][/S][/T[:]c,nn][текст]\n\n\ + /C[:]список_символов Указывает допустимые символы. По умолчанию это YN.\n\ + /N Не выводить список символов и ? после подсказки.\n\ + /S Трактовать символы как чувствительные к регистру.\n\ + /T[:]c,nn По умолчанию выбор c по истечении nn секунд.\n\ + text Подсказка.\n\n\ +ERRORLEVEL устанавливается равным номеру выбранного символа.\n" -STRING_CLS_HELP, "Î÷èñòêà ýêðàíà.\n\nCLS\n" +STRING_CLS_HELP, "Очистка экрана.\n\nCLS\n" -STRING_CMD_HELP1, "\nÄîñòóïíûå âíóòðåííèå êîìàíäû:\n" +STRING_CMD_HELP1, "\nДоступные внутренние команды:\n" -STRING_CMD_HELP2, "\nÄîñòóïíûå âîçìîæíîñòè:" +STRING_CMD_HELP2, "\nДоступные возможности:" -STRING_CMD_HELP3," [ïñåâäîíèìû]" +STRING_CMD_HELP3," [псевдонимы]" -STRING_CMD_HELP4," [èñòîðèÿ]" +STRING_CMD_HELP4," [история]" -STRING_CMD_HELP5," [çàâåðøåíèå èìåí ôàéëîâ unix]" +STRING_CMD_HELP5," [завершение имен файлов unix]" -STRING_CMD_HELP6," [ñòåê äèðåêòîðèé]" +STRING_CMD_HELP6," [стек директорий]" -STRING_CMD_HELP7," [ïåðåíàïðàâëåíèå è piping]" +STRING_CMD_HELP7," [перенаправление и piping]" -STRING_CMD_HELP8, "Çàïóñê íîâîé êîïèè èíòåðïðåòàòîðà êîìàíä ReactOS.\n\n\ -CMD [/[C|K] êîìàíäà][/P][/Q][/T:bf]\n\n\ - /C êîìàíäà Âûïîëíåíèå óêàçàííîé êîìàíäû ñ ïîñëåäóþùèì çàâåðøåíèåì.\n\ - /K êîìàíäà Âûïîëíåíèå óêàçàííîé êîìàíäû áåç ïîñëåäóþùåãî çàâåðøåíèÿ.\n\ - /P CMD ñòàíîâèòñÿ ïåðìàíåíòíûì è çàïóñêàåò autoexec.bat\n\ - (ïðîöåññ íåìîæåò áûòü çàâåðøåí).\n\ - /T:öâ Âûáîð öâåòà òåêñòà/ôîíà (áîëåå ïîäðîáíî ñì. COLOR /?).\n" +STRING_CMD_HELP8, "Запуск новой копии интерпретатора команд ReactOS.\n\n\ +CMD [/[C|K] команда][/P][/Q][/T:bf]\n\n\ + /C команда Выполнение указанной команды с последующим завершением.\n\ + /K команда Выполнение указанной команды без последующего завершения.\n\ + /P CMD становится перманентным и запускает autoexec.bat\n\ + (процесс неможет быть завершен).\n\ + /T:цв Выбор цвета текста/фона (более подробно см. COLOR /?).\n" -STRING_COLOR_HELP1, "Óñòàíîâêà öâåòîâ ïî óìîë÷àíèþ äëÿ òåêñòà è ôîíà.\n\n\ -COLOR [öâåòà [/-F]] \n\n\ - öâåòà Àòðèáóòû öâåòîâ äëÿ òåêñòîâûõ îêîí\n\ - /-F Íå çàëèâàòü íåçàïîëíåííûå ìåñòà öâåòîì\n\n\ -Åñòü òðè ñïîñîáà îáîçíà÷àòü öâåòà:\n\ -1) ïî íàçâàíèþ íà àíãëèéñêîì ÿçûêå (òðåáóþòñÿ òîëüêî ïåðâûå òðè áóêâû öâåòà)\n\ -2) â âèäå äåñÿòè÷íûõ ÷èñåë (decimal on decimal)\n\ -3) äâà øåñòíàäöàòåðè÷íûõ ÷èñëà\n\n\ -Òàáëèöà öâåòîâ:\n\ -äåñ. øåñò.íàçâàíèå äåñ. øåñò.íàçâàíèå\n\ - 0 0 = ×åðíûé 8 8 = Ñåðûé\n\ - 1 1 = Ñèíèé 9 9 = Ñâåòëî-ñèíèé\n\ - 2 2 = Çåëåíûé 10 A = Ñâåòëî-çåëåíûé\n\ - 3 3 = Ãîëóáîé 11 B = Ñâåòëî-ãîëóáîé\n\ - 4 4 = Êðàñíûé 12 C = Ñâåòëî-êðàñíûé\n\ - 5 5 = Ëèëîâûé 13 D = Ñâåòëî-ëèëîâûé\n\ - 6 6 = Æåëòûé 14 E = Ñâåòëî-æåëòûé\n\ - 7 7 = Áåëûé 15 F = ßðêî-áåëûé\n" +STRING_COLOR_HELP1, "Установка цветов по умолчанию для текста и фона.\n\n\ +COLOR [цвета [/-F]] \n\n\ + цвета Атрибуты цветов для текстовых окон\n\ + /-F Не заливать незаполненные места цветом\n\n\ +Есть три способа обозначать цвета:\n\ +1) по названию на английском языке (требуются только первые три буквы цвета)\n\ +2) в виде десятичных чисел (decimal on decimal)\n\ +3) два шестнадцатеричных числа\n\n\ +Таблица цветов:\n\ +дес. шест.название дес. шест.название\n\ + 0 0 = Черный 8 8 = Серый\n\ + 1 1 = Синий 9 9 = Светло-синий\n\ + 2 2 = Зеленый 10 A = Светло-зеленый\n\ + 3 3 = Голубой 11 B = Светло-голубой\n\ + 4 4 = Красный 12 C = Светло-красный\n\ + 5 5 = Лиловый 13 D = Светло-лиловый\n\ + 6 6 = Желтый 14 E = Светло-желтый\n\ + 7 7 = Белый 15 F = Ярко-белый\n" -STRING_COPY_HELP1, "Ïåðåçàïèñàòü %s (Yes/No/All)? " +STRING_COPY_HELP1, "Перезаписать %s (Yes/No/All)? " -STRING_COPY_HELP2, "Êîïèðîâàíèå îäíîãî èëè íåñêîëüêèõ ôàéëîâ â äðóãîå ìåñòî.\n\n\ -COPY [/V][/Y|/-Y][/A|/B] èñòî÷íèê [/A|/B]\n\ - [+ èñòî÷íèê [/A|/B] [+ ...]] [ðåçóëüòàò [/A|/B]]\n\n\ - èñòî÷íèê Èìåíà îäíîãî èëè íåñêîëüêèõ êîïèðóåìûõ ôàéëîâ.\n\ - /A Ôàéë ÿâëÿåòñÿ òåêñòîâûì ôàéëîì ASCII.\n\ - /B Ôàéë ÿâëÿåòñÿ äâîè÷íûì ôàéëîì.\n\ - ðåçóëüòàò Êàòàëîã è/èëè èìÿ äëÿ êîíå÷íûõ ôàéëîâ.\n\ - /V Ïðîâåðêà ïðàâèëüíîñòè êîïèðîâàíèÿ ôàéëîâ.\n\ - /Y Ïîäàâëåíèå çàïðîñà ïîäòâåðæäåíèÿ íà ïåðåçàïèñü ñóùåñòâóþùåãî\n\ - ðåçóëüòèðóþùåãî ôàéëà.\n\ - /-Y Îáÿçàòåëüíûé çàïðîñ ïîäòâåðæäåíèÿ íà ïåðåçàïèñü ñóùåñòâóþùåãî\n\ - ðåçóëüòèðóþùåãî ôàéëà.\n\n\ -Êëþ÷ /Y ìîæíî óñòàíîâèòü ÷åðåç ïåðåìåííóþ ñðåäû COPYCMD.\n\ +STRING_COPY_HELP2, "Копирование одного или нескольких файлов в другое место.\n\n\ +COPY [/V][/Y|/-Y][/A|/B] источник [/A|/B]\n\ + [+ источник [/A|/B] [+ ...]] [результат [/A|/B]]\n\n\ + источник Имена одного или нескольких копируемых файлов.\n\ + /A Файл является текстовым файлом ASCII.\n\ + /B Файл является двоичным файлом.\n\ + результат Каталог и/или имя для конечных файлов.\n\ + /V Проверка правильности копирования файлов.\n\ + /Y Подавление запроса подтверждения на перезапись существующего\n\ + результирующего файла.\n\ + /-Y Обязательный запрос подтверждения на перезапись существующего\n\ + результирующего файла.\n\n\ +Ключ /Y можно установить через переменную среды COPYCMD.\n\ ...\n" -STRING_DATE_HELP1, "\nÂâåäèòå íîâóþ äàòó (ìì%cää%cãããã): " +STRING_DATE_HELP1, "\nВведите новую дату (мм%cдд%cгггг): " -STRING_DATE_HELP2, "\nÂâåäèòå íîâóþ äàòó (ää%cìì%cãããã): " +STRING_DATE_HELP2, "\nВведите новую дату (дд%cмм%cгггг): " -STRING_DATE_HELP3, "\nÂâåäèòå íîâóþ äàòó (ãããã%cìì%cää): " +STRING_DATE_HELP3, "\nВведите новую дату (гггг%cмм%cдд): " -STRING_DATE_HELP4, "Âûâîä èëè èçìåíåíèå äàòû.\n\n\ -DATE [/T][äàòà]\n\n\ - /T Íå çàïðàøèâàòü ââîä íîâîé äàòû\n\n\ -Êîìàíäà DATE áåç ïàðàìåòðîâ îòîáðàæàåò òåêóùóþ äàòó è çàïðàøèâàåò ââîä\n\ -íîâîé äàòû. Äëÿ ñîõðàíåíèÿ òåêóùåé äàòû íàæìèòå êëàâèøó ENTER.\n" +STRING_DATE_HELP4, "Вывод или изменение даты.\n\n\ +DATE [/T][дата]\n\n\ + /T Не запрашивать ввод новой даты\n\n\ +Команда DATE без параметров отображает текущую дату и запрашивает ввод\n\ +новой даты. Для сохранения текущей даты нажмите клавишу ENTER.\n" -STRING_DEL_HELP1, "Óäàëåíèå îäíîãî èëè íåñêîëüêèõ ôàéëîâ.\n\n\ -DEL [/N /P /T /Q /S /W /Y /Z /A[[:]àòðèáóòû]] èìåíà_ôàéëîâ ...\n\ -DELETE [/N /P /T /Q /S /W /Y /Z /A[[:]àòðèáóòû]] èìåíà_ôàéëîâ ...\n\ -ERASE [/N /P /T /Q /S /W /Y /Z /A[[:]àòðèáóòû]] èìåíà_ôàéëîâ ...\n\n\ - èìåíà_ôàéëîâ Èìåíà îäíîãî èëè íåñêîëüêèõ ôàéëîâ.\n\n\ - /N Íåâûïîëíÿòü íåïîñðåäñòâåííî îïåðàöèþ óäàëåíèÿ ôàéëà.\n\ - /P Çàïðîñ íà ïîäòâåðæäåíèå ïåðåä óäàëåíèåì êàæäîãî ôàéëà.\n\ - /T Ïîêàçûâàåò êîëè÷åñòâî óäàëåííûõ ôàéëîâ è îñâîáîäèâøåãîñÿ\n\ - äèñêîâîãî ïðîñòðàíñòâà.\n\ - /Q Îòêëþ÷åíèå çàïðîñà íà ïîäòâåðæäåíèå ïðè óäàëåíèè ôàéëîâ.\n\ - /W Ïåðåïèñàòü ôàéë ñëó÷àéíûìè äàííûìè ïåðåä óäàëåíèåì.\n\ - /Y Îòêëþ÷åíèå çàïðîñà íà ïîäòâåðæäåíèå ïðè óäàëåíèè ôàéëîâ\n\ - äàæå äëÿ ìàñêè *.*.\n\ - /F Ïðèíóäèòåëüíîå óäàëåíèå ôàéëîâ, äîñòóïíûõ òîëüêî äëÿ ÷òåíèÿ.\n\ - /S Óäàëÿòü ôàéë èç âñåõ ïîääèðåêòîðèé\n\ - /A Îòáîð ôàéëîâ äëÿ óäàëåíèÿ ïî àòðèáóòàì.\n\ - R Äîñòóïíûé òîëüêî äëÿ ÷òåíèÿ\n\ - S Ñèñòåìíûå ôàéëû\n\ - A Ôàéëû äëÿ àðõèâèðîâàíèÿ\n\ - H Ñêðûòûå ôàéëû\n\ - Ïðåôèêñ ""-"" èìååò çíà÷åíèå ÍÅ\n" +STRING_DEL_HELP1, "Удаление одного или нескольких файлов.\n\n\ +DEL [/N /P /T /Q /S /W /Y /Z /A[[:]атрибуты]] имена_файлов ...\n\ +DELETE [/N /P /T /Q /S /W /Y /Z /A[[:]атрибуты]] имена_файлов ...\n\ +ERASE [/N /P /T /Q /S /W /Y /Z /A[[:]атрибуты]] имена_файлов ...\n\n\ + имена_файлов Имена одного или нескольких файлов.\n\n\ + /N Невыполнять непосредственно операцию удаления файла.\n\ + /P Запрос на подтверждение перед удалением каждого файла.\n\ + /T Показывает количество удаленных файлов и освободившегося\n\ + дискового пространства.\n\ + /Q Отключение запроса на подтверждение при удалении файлов.\n\ + /W Переписать файл случайными данными перед удалением.\n\ + /Y Отключение запроса на подтверждение при удалении файлов\n\ + даже для маски *.*.\n\ + /F Принудительное удаление файлов, доступных только для чтения.\n\ + /S Удалять файл из всех поддиректорий\n\ + /A Отбор файлов для удаления по атрибутам.\n\ + R Доступный только для чтения\n\ + S Системные файлы\n\ + A Файлы для архивирования\n\ + H Скрытые файлы\n\ + Префикс ""-"" имеет значение НЕ\n" -STRING_DEL_HELP2, "Âñå ôàéëû â êàòàëîãå áóäóò óäàëåíû!\nÂû óâåðåíû (Y/N)?" -STRING_DEL_HELP3, " %lu ôàéë óäàëåí\n" -STRING_DEL_HELP4, " %lu ôàéëîâ óäàëåíî\n" +STRING_DEL_HELP2, "Все файлы в каталоге будут удалены!\nВы уверены (Y/N)?" +STRING_DEL_HELP3, " %lu файл удален\n" +STRING_DEL_HELP4, " %lu файлов удалено\n" -STRING_DELAY_HELP, "ïàóçà íà n ñåêóíä èëè ìèëëèñåêóíä\n\ +STRING_DELAY_HELP, "пауза на n секунд или миллисекунд\n\ DELAY [/m]n\n\n\ - /m óêàçûâàåò, ÷òî n îçíà÷àåò êîëè÷åñòâî ìèëëèñåêóíä\n\ - èíà÷å n îçíà÷àåò êîëè÷åñòâî ñåêóíä\n" + /m указывает, что n означает количество миллисекунд\n\ + иначе n означает количество секунд\n" -STRING_DIR_HELP1, "DIR [äèñê:][ïóòü][èìÿ_ôàéëà] [/A[[:]àòðèáóòû]] [/B] [/C] [/D] [/L] [/N]\n\ +STRING_DIR_HELP1, "DIR [диск:][путь][имя_файла] [/A[[:]атрибуты]] [/B] [/C] [/D] [/L] [/N]\n\ [/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]\n\n\ - [äèñê:][ïóòü][èìÿ_ôàéëà]\n\ - Äèñê, êàòàëîã è/èëè ôàéëû, êîòîðûå ñëåäóåò âêëþ÷èòü â ñïèñîê.\n\n\ - /A Âûâîä ôàéëîâ ñ óêàçàííûìè àòðèáóòàìè.\n\ - àòðèáóòû D Êàòàëîãè R Äîñòóïíûå òîëüêî äëÿ ÷òåíèÿ\n\ - H Ñêðûòûå ôàéëû A Ôàéëû äëÿ àðõèâèðîâàíèÿ\n\ - S Ñèñòåìíûå ôàéëû Ïðåôèêñ ""-"" èìååò çíà÷åíèå ÍÅ\n\ - /B Âûâîä òîëüêî èìåí ôàéëîâ.\n\ - /C Ïðèìåíåíèå ðàçäåëèòåëÿ ãðóïï ðàçðÿäîâ äëÿ âûâîäà ðàçìåðîâ ôàéëîâ\n\ - (ïî óìîë÷àíèþ). Äëÿ îòêëþ÷åíèÿ ýòîãî ðåæèìà ñëóæèò êëþ÷ /-C.\n\ - /D Âûâîä ñïèñêà â íåñêîëüêî ñòîëáöîâ ñ ñîðòèðîâêîé ïî ñòîëáöàì.\n\ - /L Èñïîëüçîâàíèå íèæíåãî ðåãèñòðà äëÿ èìåí ôàéëîâ.\n\ - /N Îòîáðàæåíèå èìåí ôàéëîâ â êðàéíåì ïðàâîì ñòîëáöå.\n\ - /O Ñîðòèðîâêà ñïèñêà îòîáðàæàåìûõ ôàéëîâ.\n\ - ïîðÿäîê N Ïî èìåíè (àëôàâèòíàÿ) S Ïî ðàçìåðó (ñïåðâà ìåíüøèå)\n\ - E Ïî ðàñøèðåíèþ (àëôàâèòíàÿ) D Ïî äàòå (ñïåðâà áîëåå ñòàðûå)\n\ - G Íà÷àòü ñïèñîê ñ êàòàëîãîâ Ïðåôèêñ ""-"" îáðàùàåò ïîðÿäîê\n\ - /P Ïàóçà ïîñëå çàïîëíåíèÿ êàæäîãî ýêðàíà.\n\ - /Q Âûâîä ñâåäåíèé î âëàäåëüöå ôàéëà.\n\ - /S Âûâîä ñïèñêà ôàéëîâ èç óêàçàííîãî êàòàëîãà è åãî ïîäêàòàëîãîâ.\n\ - /T Âûáîð ïîëÿ âðåìåíè äëÿ îòîáðàæåíèÿ è ñîðòèðîâêè\n\ - âðåìÿ C Ñîçäàíèå\n\ - A Ïîñëåäíåå èñïîëüçîâàíèå\n\ - W Ïîñëåäíåå èçìåíåíèå\n\ - /W Âûâîä ñïèñêà â íåñêîëüêî ñòîëáöîâ.\n\ - /X Îòîáðàæåíèå êîðîòêèõ èìåí äëÿ ôàéëîâ, ÷üè èìåíà íå ñîîòâåòñòâóþò\n\ - ñòàíäàðòó 8.3. Ôîðìàò àíàëîãè÷åí âûâîäó ñ êëþ÷îì /N, íî êîðîòêèå\n\ - èìåíà ôàéëîâ âûâîäÿòñÿ ñëåâà îò äëèííûõ. Åñëè êîðîòêîãî èìåíè ó\n\ - ôàéëà íåò, âìåñòî íåãî âûâîäÿòñÿ ïðîáåëû.\n\ - /4 Âûâîä íîìåðà ãîäà â ÷åòûðåõçíà÷íîì ôîðìàòå\n" + [диск:][путь][имя_файла]\n\ + Диск, каталог и/или файлы, которые следует включить в список.\n\n\ + /A Вывод файлов с указанными атрибутами.\n\ + атрибуты D Каталоги R Доступные только для чтения\n\ + H Скрытые файлы A Файлы для архивирования\n\ + S Системные файлы Префикс ""-"" имеет значение НЕ\n\ + /B Вывод только имен файлов.\n\ + /C Применение разделителя групп разрядов для вывода размеров файлов\n\ + (по умолчанию). Для отключения этого режима служит ключ /-C.\n\ + /D Вывод списка в несколько столбцов с сортировкой по столбцам.\n\ + /L Использование нижнего регистра для имен файлов.\n\ + /N Отображение имен файлов в крайнем правом столбце.\n\ + /O Сортировка списка отображаемых файлов.\n\ + порядок N По имени (алфавитная) S По размеру (сперва меньшие)\n\ + E По расширению (алфавитная) D По дате (сперва более старые)\n\ + G Начать список с каталогов Префикс ""-"" обращает порядок\n\ + /P Пауза после заполнения каждого экрана.\n\ + /Q Вывод сведений о владельце файла.\n\ + /S Вывод списка файлов из указанного каталога и его подкаталогов.\n\ + /T Выбор поля времени для отображения и сортировки\n\ + время C Создание\n\ + A Последнее использование\n\ + W Последнее изменение\n\ + /W Вывод списка в несколько столбцов.\n\ + /X Отображение коротких имен для файлов, чьи имена не соответствуют\n\ + стандарту 8.3. Формат аналогичен выводу с ключом /N, но короткие\n\ + имена файлов выводятся слева от длинных. Если короткого имени у\n\ + файла нет, вместо него выводятся пробелы.\n\ + /4 Вывод номера года в четырехзначном формате\n" -STRING_DIR_HELP2, " Òîì â óñòðîéñòâå %c èìååò ìåòêó %s\n" -STRING_DIR_HELP3, " Òîì â óñòðîéñòâå %c íå èìååò ìåòêè.\n" -STRING_DIR_HELP4, " Ñåðèéíûé íîìåð òîìà: %04X-%04X\n" -STRING_DIR_HELP5, "\n Âñåãî:\n%16i Ôàéë(îâ)% 14s áàéò\n" -STRING_DIR_HELP6, "%16i Dir(s)% 15s áàéò\n" -STRING_DIR_HELP7, "\n Êàòàëîã of %s\n\n" -STRING_DIR_HELP8, "%16i ôàéë(îâ)% 14s áàéò\n" +STRING_DIR_HELP2, " Том в устройстве %c имеет метку %s\n" +STRING_DIR_HELP3, " Том в устройстве %c не имеет метки.\n" +STRING_DIR_HELP4, " Серийный номер тома: %04X-%04X\n" +STRING_DIR_HELP5, "\n Всего:\n%16i Файл(ов)% 14s байт\n" +STRING_DIR_HELP6, "%16i Dir(s)% 15s байт\n" +STRING_DIR_HELP7, "\n Каталог of %s\n\n" +STRING_DIR_HELP8, "%16i файл(ов)% 14s байт\n" -STRING_DIRSTACK_HELP1, "Ñîõðàíÿåò òåêóùóþ äèðåêòîðèþ äëÿ èñïîëüçîâàíèÿ êîìàíäîé POPD, çàòåì\n\ -èçìåíÿåò åå íà óêàçàííóþ.\n\n\ +STRING_DIRSTACK_HELP1, "Сохраняет текущую директорию для использования командой POPD, затем\n\ +изменяет ее на указанную.\n\n\ PUSHD [path | ..]\n\n\ - path Óêàçûâàåò äèðåêòîðèþ, êîòîðóþ íàäî ñäåëàòü òåêóùåé\n" + path Указывает директорию, которую надо сделать текущей\n" -STRING_DIRSTACK_HELP2, "Èçìåíÿåò òåêóùóþ äèðåêòîðèþ íà òó, êîòîðàÿ ñîõðàíåíà êîìàíäîé PUSHD.\n\nPOPD" +STRING_DIRSTACK_HELP2, "Изменяет текущую директорию на ту, которая сохранена командой PUSHD.\n\nPOPD" -STRING_DIRSTACK_HELP3, "Ïå÷àòàåò ñîäåðæèìîå ñòåêà äèðåêòîðèé.\n\nDIRS" +STRING_DIRSTACK_HELP3, "Печатает содержимое стека директорий.\n\nDIRS" -STRING_DIRSTACK_HELP4, "Ñòåê äèðåêòîðèé ïóñò" +STRING_DIRSTACK_HELP4, "Стек директорий пуст" -STRING_ECHO_HELP1, "Âûäàåò ñîîáùåíèå áåç ïåðåâîäà ñòðîêè.\n\n\ +STRING_ECHO_HELP1, "Выдает сообщение без перевода строки.\n\n\ ECHOS message" -STRING_ECHO_HELP2, "Âûäàåò ñîîáùåíèå â ñòàíäàðòíûé êàíàë âûâîäà îøèáîê.\n\n\ +STRING_ECHO_HELP2, "Выдает сообщение в стандартный канал вывода ошибок.\n\n\ ECHOERR message\n\ - ECHOERR. ïå÷àòàåò ïóñòóþ ñòðîêó" + ECHOERR. печатает пустую строку" -STRING_ECHO_HELP3, "Ïå÷àòàåò ñîîáùåíèå â ñòàíäàðòíûé êàíàë âûâîäà îøèáîê áåç ïåðåâîäà ñòðîêè è âîçâðàòà êàðåòêè.\n\n\ +STRING_ECHO_HELP3, "Печатает сообщение в стандартный канал вывода ошибок без перевода строки и возврата каретки.\n\n\ ECHOSERR message" -STRING_ECHO_HELP4, "Âûâîä ñîîáùåíèé è ïåðåêëþ÷åíèå ðåæèìà îòîáðàæåíèÿ êîìàíä íà ýêðàíå.\n\n\ +STRING_ECHO_HELP4, "Вывод сообщений и переключение режима отображения команд на экране.\n\n\ ECHO [ON | OFF]\n\ - ECHO [ñîîáùåíèå]\n\ - ECHO. âûâîä ïóñòîé ñòðîêè\n\n\ -ECHO áåç ïàðàìåòðà âûâîäèò òåêóùèé ðåæèì îòîáðàæåíèÿ êîìàíä." + ECHO [сообщение]\n\ + ECHO. вывод пустой строки\n\n\ +ECHO без параметра выводит текущий режим отображения команд." STRING_ECHO_HELP5, "ECHO is %s\n" -STRING_EXIT_HELP, "Çàâåðøàåò èíòåðïðåòàòîð êîìàíä.\n\nEXIT\n" +STRING_EXIT_HELP, "Завершает интерпретатор команд.\n\nEXIT\n" -STRING_FOR_HELP1, "Çàïóñêàåò óêàçàííóþ êîìàíäó äëÿ êàæäîãî ôàéëà èç íàáîðà ôàéëîâ\n\n\ -FOR %ïåðåìåííàÿ IN (íàáîð) DO êîìàíäà [ïàðàìåòðû]\n\n\ - %ïåðåìåííàÿ Ïîäñòàâëÿåìûé ïàðàìåòð.\n\ - (íàáîð) Íàáîð èç îäíîãî èëè íåñêîëüêèõ ôàéëîâ.\n\ - Äîïóñêàåòñÿ èñïîëüçîâàíèå ïîäñòàíîâî÷íûõ çíàêîâ.\n\ - êîìàíäà Êîìàíäà, êîòîðóþ ñëåäóåò âûïîëíèòü äëÿ êàæäîãî ôàéëà.\n\ - ïàðàìåòðû Ïàðàìåòðû è êëþ÷è äëÿ óêàçàííîé êîìàíäû.\n\n\ - ïàêåòíûõ ôàéëàõ äëÿ êîìàíäû FOR èñïîëüçóåòñÿ çàïèñü\n\ -%%ïåðåìåííàÿ âìåñòî %ïåðåìåííàÿ.\n" +STRING_FOR_HELP1, "Запускает указанную команду для каждого файла из набора файлов\n\n\ +FOR %переменная IN (набор) DO команда [параметры]\n\n\ + %переменная Подставляемый параметр.\n\ + (набор) Набор из одного или нескольких файлов.\n\ + Допускается использование подстановочных знаков.\n\ + команда Команда, которую следует выполнить для каждого файла.\n\ + параметры Параметры и ключи для указанной команды.\n\n\ +В пакетных файлах для команды FOR используется запись\n\ +%%переменная вместо %переменная.\n" -STRING_FREE_HELP1, "\nÒîì äèñêà %s: %-11s\n\ - Ñåðèéíûé íîìåð: %s\n\ - %16s áàéò îáùåãî äèñêîâîãî ïðîñòðàíñòâà\n\ - %16s áàéò çàíÿòî\n\ - %16s áàéò ñâîáîäíî\n" +STRING_FREE_HELP1, "\nТом диска %s: %-11s\n\ + Серийный номер: %s\n\ + %16s байт общего дискового пространства\n\ + %16s байт занято\n\ + %16s байт свободно\n" -STRING_FREE_HELP2, "Âûâîäèò èíôîðìàöèþ î òîìå.\n\nFREE [drive: ...]\n" +STRING_FREE_HELP2, "Выводит информацию о томе.\n\nFREE [drive: ...]\n" -STRING_IF_HELP1, "Îïåðàòîð óñëîâíîãî âûïîëíåíèÿ êîìàíä â ïàêåòíîì ôàéëå.\n\n\ - IF [NOT] ERRORLEVEL ÷èñëî êîìàíäà\n\ - IF [NOT] ñòðîêà1==ñòðîêà2 êîìàíäà\n\ - IF [NOT] EXIST èìÿ_ôàéëà êîìàíäà\n\ - IF [NOT] DEFINED ïåðåìåííàÿ êîìàíäà\n\n\ - NOT Îáðàùàåò èñòèííîñòü óñëîâèÿ: èñòèííîå óñëîâèå\n\ - ñòàíîâèòñÿ ëîæíûì, à ëîæíîå - èñòèííûì.\n\ - ERRORLEVEL ÷èñëî Óñëîâèå ÿâëÿåòñÿ èñòèííûì, åñëè êîä âîçâðàòà ïîñëåäíåé\n\ - âûïîëíåííîé ïðîãðàììû íå ìåíüøå óêàçàííîãî ÷èñëà.\n\ - ñòðîêà1==ñòðîêà2 Ýòî óñëîâèå ÿâëÿåòñÿ èñòèííûì, åñëè óêàçàííûå ñòðîêè\n\ - ñîâïàäàþò.\n\ - EXIST èìÿ_ôàéëà Ýòî óñëîâèå ÿâëÿåòñÿ èñòèííûì, åñëè ôàéë ñ óêàçàííûì\n\ - èìåíåì ñóùåñòâóåò.\n\ -DEFINED ïåðåìåííàÿ Ýòî óñëîâèå ÿâëÿåòñÿ èñòèííûì, åñëè óêàçàííàÿ ïåðåìåííàÿ\n\ - çàäàíà\n\ - êîìàíäà Çàäàåò êîìàíäó, âûïîëíÿåìóþ ïðè èñòèííîñòè óñëîâèÿ.\n\ - Çà ýòîé êîìàíäîé ìîæåò ñëåäîâàòü êëþ÷åâîå ñëîâî ELSE,\n\ - ñëóæàùåå äëÿ óêàçàíèÿ êîìàíäû, êîòîðàÿ äîëæíà\n\ - âûïîëíÿòüñÿ â òîì ñëó÷àå, åñëè óñëîâèå ëîæíî.\n" +STRING_IF_HELP1, "Оператор условного выполнения команд в пакетном файле.\n\n\ + IF [NOT] ERRORLEVEL число команда\n\ + IF [NOT] строка1==строка2 команда\n\ + IF [NOT] EXIST имя_файла команда\n\ + IF [NOT] DEFINED переменная команда\n\n\ + NOT Обращает истинность условия: истинное условие\n\ + становится ложным, а ложное - истинным.\n\ + ERRORLEVEL число Условие является истинным, если код возврата последней\n\ + выполненной программы не меньше указанного числа.\n\ + строка1==строка2 Это условие является истинным, если указанные строки\n\ + совпадают.\n\ + EXIST имя_файла Это условие является истинным, если файл с указанным\n\ + именем существует.\n\ +DEFINED переменная Это условие является истинным, если указанная переменная\n\ + задана\n\ + команда Задает команду, выполняемую при истинности условия.\n\ + За этой командой может следовать ключевое слово ELSE,\n\ + служащее для указания команды, которая должна\n\ + выполняться в том случае, если условие ложно.\n" -STRING_GOTO_HELP1, "Ïåðåäà÷à óïðàâëåíèÿ ñîäåðæàùåé ìåòêó ñòðîêå ïàêåòíîãî ôàéëà.\n\n\ -GOTO ìåòêà\n\n\ - label Ñòðîêà ïàêåòíîãî ôàéëà, îôîðìëåííàÿ êàê ìåòêà.\n\n\ -Ìåòêà äîëæíà íàõîäèòüñÿ â îòäåëüíîé ñòðîêå è íà÷èíàòüñÿ ñ äâîåòî÷èÿ." +STRING_GOTO_HELP1, "Передача управления содержащей метку строке пакетного файла.\n\n\ +GOTO метка\n\n\ + label Строка пакетного файла, оформленная как метка.\n\n\ +Метка должна находиться в отдельной строке и начинаться с двоеточия." -STRING_LABEL_HELP1, "Ñîçäàíèå, èçìåíåíèå è óäàëåíèå ìåòîê òîìà.\n\nLABEL [äèñê:][ìåòêà]\n" +STRING_LABEL_HELP1, "Создание, изменение и удаление меток тома.\n\nLABEL [диск:][метка]\n" -STRING_LABEL_HELP2, "Òîì â óñòðîéñòâå %c èìååò ìåòêó %s\n" -STRING_LABEL_HELP3, "Òîì â óñòðîéñòâå %c: íå èìååò ìåòêè\n" -STRING_LABEL_HELP4, "Ñåðèéíûé íîìåð òîìà: %04X-%04X\n" -STRING_LABEL_HELP5, "Ìåòêà òîìà (11 áóêâ, ÂÂÎÄ äëÿ ïóñòîé ìåòêè)? " +STRING_LABEL_HELP2, "Том в устройстве %c имеет метку %s\n" +STRING_LABEL_HELP3, "Том в устройстве %c: не имеет метки\n" +STRING_LABEL_HELP4, "Серийный номер тома: %04X-%04X\n" +STRING_LABEL_HELP5, "Метка тома (11 букв, ВВОД для пустой метки)? " -STRING_LOCALE_HELP1, "Òåêóùåå âðåìÿ: " +STRING_LOCALE_HELP1, "Текущее время: " -STRING_MKDIR_HELP, "Ñîçäàíèå êàòàëîãà.\n\n\ -MKDIR [äèñê:]ïóòü\nMD [äèñê:]ïóòü" +STRING_MKDIR_HELP, "Создание каталога.\n\n\ +MKDIR [диск:]путь\nMD [диск:]путь" STRING_MKLINK_HELP, "Creates a filesystem link object.\n\n\ MKLINK [/D | /H | /J] linkname target\n\n\ @@ -312,167 +312,167 @@ MKLINK [/D | /H | /J] linkname target\n\n\ /J Create a directory junction.\n\n\ If neither /H or /J is specified, a symbolic link is created." -STRING_MEMMORY_HELP1, "Âûâîä îáúåìà ñèñòåìíîé ïàìÿòè.\n\nMEMORY" +STRING_MEMMORY_HELP1, "Вывод объема системной памяти.\n\nMEMORY" STRING_MEMMORY_HELP2, "\n %12s%% memory load.\n\n\ - %13s áàéò âñåãî ôèçè÷åñêîé ïàìÿòè.\n\ - %13s áàéò äîñòóïíî ôèçè÷åñêîé ïàìÿòè.\n\n\ - %13s áàéò âñåãî â ôàéëå ïîäêà÷êè.\n\ - %13s áàéò äîñòóïíî â ôàéëå ïîäêà÷êè.\n\n\ - %13s áàéò âñåãî âèðòóàëüíîé ïàìÿòè.\n\ - %13s áàéò äîñòóïíî âèðòóàëüíî ïàìÿòè.\n" + %13s байт всего физической памяти.\n\ + %13s байт доступно физической памяти.\n\n\ + %13s байт всего в файле подкачки.\n\ + %13s байт доступно в файле подкачки.\n\n\ + %13s байт всего виртуальной памяти.\n\ + %13s байт доступно виртуально памяти.\n" -STRING_MISC_HELP1, "Íàæìèòå êëàâèøó äëÿ ïðîäîëæåíèÿ...\n" +STRING_MISC_HELP1, "Нажмите клавишу для продолжения...\n" -STRING_MOVE_HELP1, "Ïåðåïèñàòü %s (Yes/No/All)? " +STRING_MOVE_HELP1, "Переписать %s (Yes/No/All)? " -STRING_MOVE_HELP2, "Ïåðåìåùåíèå ôàéëîâ è ïåðåèìåíîâàíèå ôàéëîâ è êàòàëîãîâ.\n\n\ -Ïåðåìåùåíèå îäíîãî èëè áîëåå ôàéëîâ:\n\ -MOVE [/N][äèñê:][ïóòü]èìÿ_ôàéëà1[,...] íàçíà÷åíèå\n\n\ -Ïåðåèìåíîâàíèå êàòàëîãà:\n\ -MOVE [/N][äèñê:][ïóòü]èìÿ_êàòàëîãà1 èìÿ_êàòàëîãà2\n\n\ - [äèñê:][ïóòü]èìÿ_ôàéëà1 Óêàçûâàåò ìåñòîïîëîæåíèå è èìÿ ôàéëà èëè ôàéëîâ\n\ - êîòîðûå íåîáõîäèìî ïåðåìåñòèòü.\n\ +STRING_MOVE_HELP2, "Перемещение файлов и переименование файлов и каталогов.\n\n\ +Перемещение одного или более файлов:\n\ +MOVE [/N][диск:][путь]имя_файла1[,...] назначение\n\n\ +Переименование каталога:\n\ +MOVE [/N][диск:][путь]имя_каталога1 имя_каталога2\n\n\ + [диск:][путь]имя_файла1 Указывает местоположение и имя файла или файлов\n\ + которые необходимо переместить.\n\ /N Nothing. Do everything but move files or directories.\n\n\ -Òåêóùèå îãðàíè÷åíèÿ:\n\ - - Íåâîçìîæíî ïåðåíîñèòü ôàéëû èëè ïàïêè ìåæäó ðàçíûìè ðàçäåëàìè.\n" +Текущие ограничения:\n\ + - Невозможно переносить файлы или папки между разными разделами.\n" -STRING_MSGBOX_HELP, "Âûâîä îêíà ñ ñîîáùåíèåì è âîçâðàò îòâåòà ïîëüçîâàòåëÿ\n\n\ -MSGBOX òèï ['çàãîëîâîê'] ïîäñêàçêà\n\n\ -òèï âûâîäèìûå êíîïêè\n\ - âîçìîæíûå çíà÷åíèÿ: OK, OKCANCEL,\n\ +STRING_MSGBOX_HELP, "Вывод окна с сообщением и возврат ответа пользователя\n\n\ +MSGBOX тип ['заголовок'] подсказка\n\n\ +тип выводимые кнопки\n\ + возможные значения: OK, OKCANCEL,\n\ YESNO, YESNOCANCEL\n\ -çàãîëîâîê çàãîëîâîê îêíà ñ ñîîáùåíèåì\n\ -ïîäñêàçêà âûâîäèìûé òåêñò ïîäñêàçêè\n\n\n\ -ERRORLEVEL óñòàíàâëèâàåòñÿ â ñîîòâåòñòâèè ñ íàæàòîé êíîïêîé:\n\n\ +заголовок заголовок окна с сообщением\n\ +подсказка выводимый текст подсказки\n\n\n\ +ERRORLEVEL устанавливается в соответствии с нажатой кнопкой:\n\n\ YES : 10 | NO : 11\n\ OK : 10 | CANCEL : 12\n" -STRING_PATH_HELP1, "Âûâîä èëè çàäàíèå ïóòè ïîèñêà èñïîëíÿåìûõ ôàéëîâ.\n\n\ -PATH [[äèñê:]ïóòü[;...]]\nPATH ;\n\n\ -Êîìàíäà PATH ; î÷èùàåò ïóòü ïîèñêà èñïîëüçóåìûõ ôàéëîâ, îãðàíè÷èâ åãî\n\ -òåêóùèì êàòàëîãîì.\n\ -Êîìàíäà PATH áåç ïàðàìåòðîâ îòîáðàæàåò òåêóùèé ïóòü ïîèñêà.\n" +STRING_PATH_HELP1, "Вывод или задание пути поиска исполняемых файлов.\n\n\ +PATH [[диск:]путь[;...]]\nPATH ;\n\n\ +Команда PATH ; очищает путь поиска используемых файлов, ограничив его\n\ +текущим каталогом.\n\ +Команда PATH без параметров отображает текущий путь поиска.\n" -STRING_PROMPT_HELP1, "Èçìåíåíèå ïðèãëàøåíèÿ êîìàíäíîé ñòðîêè.\n\n\ -PROMPT [òåêñò]\n\n\ - òåêñò Íîâîå ïðèãëàøåíèå êîìàíäíîé ñòðîêè.\n\n\ -Ïðèãëàøåíèå ìîæåò âêëþ÷àòü îáû÷íûå ñèìâîëû è ñëåäóþùèå êîäû:\n\n\ - $A & (àìïåðñàíä)\n\ - $B | (âåðòèêàëüíàÿ ÷åðòà)\n\ - $C ( (ëåâàÿ êðóãëàÿ ñêîáêà)\n\ - $D Òåêóùàÿ äàòà\n\ - $E ESC (ñèìâîë ASCII ñ êîäîì 27)\n\ - $F ) (ïðàâàÿ êðóãëàÿ ñêîáêà)\n\ - $G > (çíàê ""áîëüøå"")\n\ - $H BACKSPACE (óäàëåíèå ïðåäûäóùåãî ñèìâîëà)\n\ - $L < (çíàê ""ìåíüøå"")\n\ - $N Òåêóùèé äèñê\n\ - $P Òåêóùèå äèñê è êàòàëîã\n\ - $Q = (çíàê ðàâåíñòâà)\n\ - $T Òåêóùåå âðåìÿ\n\ - $V Íîìåð âåðñèè îïåðàöèîííîé ñèñòåìû\n\ - $_ Ïåðåâîä ñòðîêè\n\ - $$ $ (çíàê äîëëàðà)\n" +STRING_PROMPT_HELP1, "Изменение приглашения командной строки.\n\n\ +PROMPT [текст]\n\n\ + текст Новое приглашение командной строки.\n\n\ +Приглашение может включать обычные символы и следующие коды:\n\n\ + $A & (амперсанд)\n\ + $B | (вертикальная черта)\n\ + $C ( (левая круглая скобка)\n\ + $D Текущая дата\n\ + $E ESC (символ ASCII с кодом 27)\n\ + $F ) (правая круглая скобка)\n\ + $G > (знак ""больше"")\n\ + $H BACKSPACE (удаление предыдущего символа)\n\ + $L < (знак ""меньше"")\n\ + $N Текущий диск\n\ + $P Текущие диск и каталог\n\ + $Q = (знак равенства)\n\ + $T Текущее время\n\ + $V Номер версии операционной системы\n\ + $_ Перевод строки\n\ + $$ $ (знак доллара)\n" -STRING_PAUSE_HELP1, "Ïðèîñòàíîâêà âûïîëíåíèÿ ïàêåòíîãî ôàéëà è âûâîä ñîîáùåíèÿ:\n\ -'Äëÿ ïðîäîëæåíèÿ íàæìèòå ëþáóþ êëàâèøó...' èëè óêàçàííîå ñîîáùåíèå.\n\n\ -PAUSE [ñîîáùåíèå]" +STRING_PAUSE_HELP1, "Приостановка выполнения пакетного файла и вывод сообщения:\n\ +'Для продолжения нажмите любую клавишу...' или указанное сообщение.\n\n\ +PAUSE [сообщение]" STRING_PROMPT_HELP2, " $+ Displays the current depth of the directory stack" -STRING_PROMPT_HELP3, "\nPROMPT áåç ïàðàìåòðîâ óñòàíàâëèâàåò ïðèãëàøåíèå êîìàíäíîé ñòðîêè ïî óìîë÷àíèþ." +STRING_PROMPT_HELP3, "\nPROMPT без параметров устанавливает приглашение командной строки по умолчанию." -STRING_REM_HELP, "Ïîìåùåíèå êîììåíòàðèåâ â ïàêåòíûå ôàéëû.\n\nREM [êîììåíòàðèé]" +STRING_REM_HELP, "Помещение комментариев в пакетные файлы.\n\nREM [комментарий]" -STRING_RMDIR_HELP, "Óäàëåíèå êàòàëîãà.\n\n\ -RMDIR [äèñê:]ïóòü\nRD [äèñê:]ïóòü\n\ -/S Óäàëåíèå äåðåâà êàòàëîãîâ\n\ -/Q Îòêëþ÷åíèå çàïðîñà ïîäòâåðæäåíèÿ\n" -STRING_RMDIR_HELP2, "Êàòàëîã ïóñò!\n" +STRING_RMDIR_HELP, "Удаление каталога.\n\n\ +RMDIR [диск:]путь\nRD [диск:]путь\n\ +/S Удаление дерева каталогов\n\ +/Q Отключение запроса подтверждения\n" +STRING_RMDIR_HELP2, "Каталог пуст!\n" -STRING_REN_HELP1, "Ïåðåèìåíîâàíèå îäíîãî èëè íåñêîëüêèõ ôàéëîâ èëè êàòàëîãîâ.\n\n\ -RENAME [/E /N /P /Q /S /T] ñòàðîå_èìÿ ... íîâîå_èìÿ\n\ -REN [/E /N /P /Q /S /T] ñòàðîå_èìÿ ... íîâîå_èìÿ\n\n\ - /E Íå âûâîäèòü ñîîáùåíèÿ îá îøèáêàõ.\n\ +STRING_REN_HELP1, "Переименование одного или нескольких файлов или каталогов.\n\n\ +RENAME [/E /N /P /Q /S /T] старое_имя ... новое_имя\n\ +REN [/E /N /P /Q /S /T] старое_имя ... новое_имя\n\n\ + /E Не выводить сообщения об ошибках.\n\ /N Nothing.\n\ - /P Çàïðîñ ïîäòâåðæäåíèÿ ïåðåä ïåðåèìåíîâàíèåì.\n\ - (Íå ðåàëèçîâàíî â äàííûé ìîìåíò!)\n\ + /P Запрос подтверждения перед переименованием.\n\ + (Не реализовано в данный момент!)\n\ /Q Quiet.\n\ - /S Ïåðåèìåíîâûâàòü ïîäêàòàëîãè.\n\ - /T Âûâîä êîëè÷åñòâà ïåðåèìåíîâàííûõ ôàéëîâ.\n\n\ -Äëÿ êîíå÷íîãî ôàéëà íåëüçÿ óêàçàòü äðóãîé äèñê èëè êàòàëîã.\n\ -Äëÿ ýòîé öåëè ñëåäóåò èñïîëüçîâàòü êîìàíäó MOVE.\n" + /S Переименовывать подкаталоги.\n\ + /T Вывод количества переименованных файлов.\n\n\ +Для конечного файла нельзя указать другой диск или каталог.\n\ +Для этой цели следует использовать команду MOVE.\n" -STRING_REN_HELP2, " %lu ôàéë ïåðåèìåíîâàí\n" +STRING_REN_HELP2, " %lu файл переименован\n" -STRING_REN_HELP3, " %lu ôàéëîâ ïåðåèìåíîâàíî\n" +STRING_REN_HELP3, " %lu файлов переименовано\n" -STRING_SHIFT_HELP, "Èçìåíåíèå ñîäåðæèìîãî (ñäâèã) ïîäñòàâëÿåìûõ ïàðàìåòðîâ äëÿ ïàêåòíîãî ôàéëà.\n\n\ +STRING_SHIFT_HELP, "Изменение содержимого (сдвиг) подставляемых параметров для пакетного файла.\n\n\ SHIFT [DOWN]" -STRING_SCREEN_HELP, "Ïåðåìåùåíèå êóðñîðà è âûâîä òåêñòà\n\n\ -SCREEN ñòð êîë [òåêñò]\n\n\ - ñòð ñòðîêà, íà êîòîðóþ ñëåäóåò ïåðåìåñòèòü êóðñîð\n\ - êîë êîëîíêà, íà êîòîðóþ ñëåäóåò ïåðåìåñòèòü êóðñîð" +STRING_SCREEN_HELP, "Перемещение курсора и вывод текста\n\n\ +SCREEN стр кол [текст]\n\n\ + стр строка, на которую следует переместить курсор\n\ + кол колонка, на которую следует переместить курсор" -STRING_SET_HELP, "Âûâîä, çàäàíèå è óäàëåíèå ïåðåìåííûõ ñðåäû.\n\n\ -SET [ïåðåìåííàÿ[=][çíà÷åíèå]]\n\n\ - ïåðåìåííàÿ Èìÿ ïåðåìåííîé ñðåäû.\n\ - çíà÷åíèå Ñòðîêà ñèìâîëîâ, ïðèñâàèâàåìàÿ óêàçàííîé ïåðåìåííîé.\n\n\ -SET áåç ïàðàìåòðîâ âûâîäèò òåêóùèå çíà÷åíèÿ ïåðåìåííûõ ñðåäû.\n" +STRING_SET_HELP, "Вывод, задание и удаление переменных среды.\n\n\ +SET [переменная[=][значение]]\n\n\ + переменная Имя переменной среды.\n\ + значение Строка символов, присваиваемая указанной переменной.\n\n\ +SET без параметров выводит текущие значения переменных среды.\n" -STRING_START_HELP1, "Çàïóñê óêàçàííîé ïðîãðàììû èëè êîìàíäû.\n\n\ -START êîìàíäà\n\n\ - êîìàíäà Êîìàíäà èëè ïðîãðàììà äëÿ çàïóñêà.\n\n\ +STRING_START_HELP1, "Запуск указанной программы или команды.\n\n\ +START команда\n\n\ + команда Команда или программа для запуска.\n\n\ At the moment all commands are started asynchronously.\n" -STRING_TITLE_HELP, "Èçìåíåíèå çàãîëîâêà îêíà êîìàíäíîé ñòðîêè.\n\n\ -TITLE [ñòðîêà]\n\n\ -ñòðîêà Áóäóùèé çàãîëîâîê îêíà êîìàíäíîé ñòðîêè.\n" +STRING_TITLE_HELP, "Изменение заголовка окна командной строки.\n\n\ +TITLE [строка]\n\n\ +строка Будущий заголовок окна командной строки.\n" -STRING_TIME_HELP1, "Âûâîä èëè èçìåíåíèå âðåìåíè.\n\n\ -TIME [/T][âðåìÿ]\n\n\ - /T íå èçìåíÿòü âðåìÿ\n\n\ -TIME áåç ïàðàìåòðîâ âûâîäèò òåêóùåå âðåìÿ è çàïðàøèâàåò\n\ -íîâîå âðåìÿ. Íàæàòèå ENTER ñîõðàíèò òåêóùåå âðåìÿ.\n" +STRING_TIME_HELP1, "Вывод или изменение времени.\n\n\ +TIME [/T][время]\n\n\ + /T не изменять время\n\n\ +TIME без параметров выводит текущее время и запрашивает\n\ +новое время. Нажатие ENTER сохранит текущее время.\n" -STRING_TIME_HELP2, "Ââåäèòå íîâîå âðåìÿ: " +STRING_TIME_HELP2, "Введите новое время: " -STRING_TIMER_HELP1, "Ïðîøëî %d ìñåê\n" +STRING_TIMER_HELP1, "Прошло %d мсек\n" -STRING_TIMER_HELP2, "Ïðîøëî %02d%c%02d%c%02d%c%02d\n" +STRING_TIMER_HELP2, "Прошло %02d%c%02d%c%02d%c%02d\n" -STRING_TIMER_HELP3, "Ñåêóíäîìåð.\n\n\ +STRING_TIMER_HELP3, "Секундомер.\n\n\ TIMER [ON|OFF] [/S] [/n] [/Fn]\n\n\ - ON Âêëþ÷èòü ñåêóíäîìåð\n\ - OFF Âûêëþ÷èòü ñåêóíäîìåð\n\ - /S Ðàçíèöà âðåìåíè. Âîçâðàùàåò ðàçíèöó âðåìåíè\n\ - ñåêóíäîìåðà áåç èçìåíåíèÿ åãî çíà÷åíèÿ\n\ - /n Çàäàòü íîìåð ñåêóíäîìåðà.\n\ - Äîñòóïíûå íîìåðà - îò 0 äî 9\n\ - Çíà÷åíèå ïî óìîë÷àíèþ - 1\n\ - /Fn Ôîðìàò âûâîäà\n\ - n îäíî èç:\n\ - 0 ìèëëèñåêóíäû\n\ - 1 ÷÷%cìì%cññ%cää\n\n\ -Åñëè íè îäèí èç ïàðàìåòðîâ íå óêàçàí, êîìàíäà\n\ -ïåðåêëþ÷àåò ñîñòîÿíèå ñåêóíäîìåðà\n\n" + ON Включить секундомер\n\ + OFF Выключить секундомер\n\ + /S Разница времени. Возвращает разницу времени\n\ + секундомера без изменения его значения\n\ + /n Задать номер секундомера.\n\ + Доступные номера - от 0 до 9\n\ + Значение по умолчанию - 1\n\ + /Fn Формат вывода\n\ + n одно из:\n\ + 0 миллисекунды\n\ + 1 чч%cмм%cсс%cдд\n\n\ +Если ни один из параметров не указан, команда\n\ +переключает состояние секундомера\n\n" -STRING_TYPE_HELP1, "Âûâîä ñîäåðæèìîãî îäíîãî èëè íåñêîëüêèõ òåêñòîâûõ ôàéëîâ.\n\nTYPE [äèñê:][ïóòü]èìÿ ôàéëà \n\ - /P Ïîýêðàííûé âûâîä.\n" +STRING_TYPE_HELP1, "Вывод содержимого одного или нескольких текстовых файлов.\n\nTYPE [диск:][путь]имя файла \n\ + /P Поэкранный вывод.\n" STRING_VERIFY_HELP1, "This command is just a dummy!!\n\ -Âêëþ÷åíèå èëè îòêëþ÷åíèå ðåæèìà ïðîâåðêè ïðàâèëüíîñòè çàïèñè ôàéëîâ a\n\ -íà äèñê.\n\n\ +Включение или отключение режима проверки правильности записи файлов a\n\ +на диск.\n\n\ VERIFY [ON | OFF]\n\n\ -VERIFY áåç ïàðàìåòðà âûâîäèò òåêóùåå çíà÷åíèå ýòîé êîìàíäû.\n" +VERIFY без параметра выводит текущее значение этой команды.\n" STRING_VERIFY_HELP2, "VERIFY %s.\n" -STRING_VERIFY_HELP3, "Íåîáõîäèìî óêàçàòü ON èëè OFF." +STRING_VERIFY_HELP3, "Необходимо указать ON или OFF." -STRING_VERSION_HELP1, "Âûâîä âåðñèè\n\n\ +STRING_VERSION_HELP1, "Вывод версии\n\n\ VER [/C][/R][/W]\n\n\ /C Displays credits.\n\ /R Displays redistribution information.\n\ @@ -493,175 +493,175 @@ STRING_VERSION_HELP4, "\n This program is free software; you can redistribute it the Free Software Foundation; either version 2 of the License, or\n\ (at your option) any later version.\n" -STRING_VERSION_HELP5, "\nÏîñûëàéòå îò÷åòû îá îøèáêàõ íà .\n\ -Îáíîâëåíèÿ äîñòóïíû ïî àäðåñó: http://www.reactos.org/" +STRING_VERSION_HELP5, "\nПосылайте отчеты об ошибках на .\n\ +Обновления доступны по адресу: http://www.reactos.org/" -STRING_VERSION_HELP6, "\nFreeDOS-âåðñèÿ íàïèñàíà:\n" +STRING_VERSION_HELP6, "\nFreeDOS-версия написана:\n" -STRING_VERSION_HELP7, "\nReactOS-âåðñèÿ íàïèñàíà:\n" +STRING_VERSION_HELP7, "\nReactOS-версия написана:\n" -STRING_VOL_HELP1, " Òîì â óñòðîéñòâå %c èìååò ìåòêó %s\n" -STRING_VOL_HELP2, " Òîì â óñòðîéñòâå %c íå èìååò ìåòêè\n" -STRING_VOL_HELP3, " Ñåðèéíûé íîìåð òîìà: %04X-%04X\n" -STRING_VOL_HELP4, "Âûâîäèò ìåòêó òîìà è ñåðèéíûé íîìåð.\n\nVOL [äèñê:]" +STRING_VOL_HELP1, " Том в устройстве %c имеет метку %s\n" +STRING_VOL_HELP2, " Том в устройстве %c не имеет метки\n" +STRING_VOL_HELP3, " Серийный номер тома: %04X-%04X\n" +STRING_VOL_HELP4, "Выводит метку тома и серийный номер.\n\nVOL [диск:]" -STRING_WINDOW_HELP1, "Ìåíÿåò âèä îêíà êîíñîëè\n\n\ -WINDOW [/POS[=]left,top,øèðèíà,âûñîòà]\n\ - [MIN|MAX|RESTORE] ['çàãîëîâîê']\n\n\ -/POS óêàçûâàåò ðàçìåð è ïîëîæåíèå îêíà\n\ -MIN ñâîðà÷èâàåò îêíî\n\ -MAX ðàçâîðà÷èâàåò îêíî\n\ -RESTORE âîññòàíàâëèâàåò îêíî\n" +STRING_WINDOW_HELP1, "Меняет вид окна консоли\n\n\ +WINDOW [/POS[=]left,top,ширина,высота]\n\ + [MIN|MAX|RESTORE] ['заголовок']\n\n\ +/POS указывает размер и положение окна\n\ +MIN сворачивает окно\n\ +MAX разворачивает окно\n\ +RESTORE восстанавливает окно\n" -STRING_WINDOW_HELP2, "Ìåíÿåò âèä îêíà êîíñîëè\n\n\ -ACTIVATE 'window' [/POS[=]left,top,øèðèíà,âûñîòà]\n\ - [MIN|MAX|RESTORE] ['çàãîëîâîê']\n\n\ -window çàãîëîâîê îêíà, âèä êîòîðîãî ñëåäóåò ìåíÿòü\n\ -/POS óêàçûâàåò ðàçìåð è ïîëîæåíèå îêíà\n\ -MIN ñâîðà÷èâàåò îêíî\n\ -MAX ðàçâîðà÷èâàåò îêíî\n\ -RESTORE âîññòàíàâëèâàåò îêíî\n\ -çàãîëîâîê íîâûé çàãîëîâîê\n" +STRING_WINDOW_HELP2, "Меняет вид окна консоли\n\n\ +ACTIVATE 'window' [/POS[=]left,top,ширина,высота]\n\ + [MIN|MAX|RESTORE] ['заголовок']\n\n\ +window заголовок окна, вид которого следует менять\n\ +/POS указывает размер и положение окна\n\ +MIN сворачивает окно\n\ +MAX разворачивает окно\n\ +RESTORE восстанавливает окно\n\ +заголовок новый заголовок\n" -STRING_HELP1, "Ñïèñîê âñåõ äîñòóïíûõ êîìàíä ñ êîðîòêèì îïèñàíèåì\n\n\ - êîìàíäà /? Âûâîäèò ïîäðîáíóþ èíôîðìàöèþ î êîìàíäå\n\n\ -? Ñïèñîê âñåõ äîñòóïíûõ êîìàíä áåç îïèñàíèÿ.\n\ -ALIAS Âûâîä, óñòàíîâêà èëè óäàëåíèå ïñåâäîíèìîâ.\n\ -ATTRIB Âûâîä è èçìåíåíèå àòðèáóòîâ ôàéëîâ.\n\ -BEEP Çâóêîâîé ñèãíàë.\n\ -CALL Âûçîâ îäíîãî ïàêåòíîãî ôàéëà èç äðóãîãî.\n\ -CD Âûâîä èìåíè ëèáî ñìåíà òåêóùåãî êàòàëîãà.\n\ -CHCP Âûâîä èëè ñìåíà òåêóùåãî íîìåðà êîäîâîé ñòðàíèöû.\n\ -CHOICE Æäåò, ïîêà ïîëüçîâàòåëü íå âûáåðåò îäèí èç óêàçàííûõ â ñïèñêå ñèìâîëîâ.\n\ -CLS Î÷èñòêà ýêðàíà.\n\ -CMD Çàïóñê íîâîé êîïèè èíòåðïðåòàòîðà êîìàíä.\n\ -COLOR Óñòàíîâêà öâåòîâ ïî óìîë÷àíèþ äëÿ òåêñòà è ôîíà.\n\ -COPY Êîïèðîâàíèå îäíîãî èëè íåñêîëüêèõ ôàéëîâ â äðóãîå ìåñòî.\n\ -DATE Âûâîä èëè èçìåíåíèå äàòû.\n\ -DELETE Óäàëåíèå îäíîãî èëè íåñêîëüêèõ ôàéëîâ.\n\ -DIR Âûâîä ñïèñêà ôàéëîâ è ïîäêàòàëîãîâ êàòàëîãà.\n\ -ECHO Âûâîä ñîîáùåíèé è ïåðåêëþ÷åíèå ðåæèìà îòîáðàæåíèÿ êîìàíä íà ýêðàíå.\n\ -ERASE Óäàëåíèå îäíîãî èëè íåñêîëüêèõ ôàéëîâ.\n\ -EXIT Çàâåðøàåò èíòåðïðåòàòîð êîìàíä.\n\ -FOR Çàïóñêàåò óêàçàííóþ êîìàíäó äëÿ êàæäîãî ôàéëà èç íàáîðà ôàéëîâ.\n\ -FREE (Ñâîáîäíîå) äèñêîâîå ïðîñòðàíñòâî.\n\ -GOTO Ïåðåäà÷à óïðàâëåíèÿ ñîäåðæàùåé ìåòêó ñòðîêå ïàêåòíîãî ôàéëà\n\ -HELP Ïðåäîñòàâëÿåò ñïðàâî÷íóþ èíôîðìàöèþ î êîìàíäàõ ReactOS.\n\ -HISTORY Ñïèñîê çàïóùåííûõ êîìàíä\n\ -IF Îïåðàòîð óñëîâíîãî âûïîëíåíèÿ êîìàíä â ïàêåòíîì ôàéëå.\n\ -LABEL Ñîçäàíèå, èçìåíåíèå è óäàëåíèå ìåòîê òîìà.\n\ -MD Ñîçäàíèå êàòàëîãà.\n\ -MKDIR Ñîçäàíèå êàòàëîãà.\n\ +STRING_HELP1, "Список всех доступных команд с коротким описанием\n\n\ + команда /? Выводит подробную информацию о команде\n\n\ +? Список всех доступных команд без описания.\n\ +ALIAS Вывод, установка или удаление псевдонимов.\n\ +ATTRIB Вывод и изменение атрибутов файлов.\n\ +BEEP Звуковой сигнал.\n\ +CALL Вызов одного пакетного файла из другого.\n\ +CD Вывод имени либо смена текущего каталога.\n\ +CHCP Вывод или смена текущего номера кодовой страницы.\n\ +CHOICE Ждет, пока пользователь не выберет один из указанных в списке символов.\n\ +CLS Очистка экрана.\n\ +CMD Запуск новой копии интерпретатора команд.\n\ +COLOR Установка цветов по умолчанию для текста и фона.\n\ +COPY Копирование одного или нескольких файлов в другое место.\n\ +DATE Вывод или изменение даты.\n\ +DELETE Удаление одного или нескольких файлов.\n\ +DIR Вывод списка файлов и подкаталогов каталога.\n\ +ECHO Вывод сообщений и переключение режима отображения команд на экране.\n\ +ERASE Удаление одного или нескольких файлов.\n\ +EXIT Завершает интерпретатор команд.\n\ +FOR Запускает указанную команду для каждого файла из набора файлов.\n\ +FREE (Свободное) дисковое пространство.\n\ +GOTO Передача управления содержащей метку строке пакетного файла\n\ +HELP Предоставляет справочную информацию о командах ReactOS.\n\ +HISTORY Список запущенных команд\n\ +IF Оператор условного выполнения команд в пакетном файле.\n\ +LABEL Создание, изменение и удаление меток тома.\n\ +MD Создание каталога.\n\ +MKDIR Создание каталога.\n\ MKLINK Creates a filesystem link object.\n\ -MOVE Ïåðåìåùåíèå ôàéëîâ è ïåðåèìåíîâàíèå ôàéëîâ è êàòàëîãîâ\n\ -PATH Âûâîä èëè çàäàíèå ïóòè ïîèñêà èñïîëíÿåìûõ ôàéëîâ.\n\ -PAUSE Ïðèîñòàíîâêà âûïîëíåíèÿ ïàêåòíîãî ôàéëà.\n\ -POPD Âîñòòàíàâëèâàåò ïðåäûäóùåå çíà÷åíèå òåêóùåé äèðåêòîðèè ñîõðàíåííîå êîìàíäîé\n\ +MOVE Перемещение файлов и переименование файлов и каталогов\n\ +PATH Вывод или задание пути поиска исполняемых файлов.\n\ +PAUSE Приостановка выполнения пакетного файла.\n\ +POPD Восттанавливает предыдущее значение текущей директории сохраненное командой\n\ PUSHD.\n\ -PROMPT Èçìåíåíèå ïðèãëàøåíèÿ êîìàíäíîé ñòðîêè.\n\ -PUSHD Ñîõðàíÿåò òåêóùóþ äèðåêòîðèþ, à ïîòîì ìåíÿåò åå.\n\ -RD Óäàëåíèå êàòàëîãà.\n\ -REM Çàïèñûâàåò êîììåíòàðèè (çàìå÷åíèÿ) â ïàêåòíûõ ôàéëàõ.\n\ -REN Ïåðåèìåíîâàíèå îäíîãî èëè íåñêîëüêèõ ôàéëîâ èëè êàòàëîãîâ.\n\ -RENAME Ïåðåèìåíîâàíèå îäíîãî èëè íåñêîëüêèõ ôàéëîâ èëè êàòàëîãîâ.\n\ -RMDIR Óäàëåíèå êàòàëîãà.\n\ -SCREEN Ïåðåìåùåíèå êóðñîðà è âûâîä òåêñòà.\n\ -SET Âûâîä, çàäàíèå è óäàëåíèå ïåðåìåííûõ ñðåäû.\n\ -SHIFT Èçìåíåíèå ñîäåðæèìîãî (ñäâèã) ïîäñòàâëÿåìûõ ïàðàìåòðîâ äëÿ ïàêåòíîãî ôàéëà\n" -STRING_HELP2, "START Îòêðûâàåò îòäåëüíîå îêíî äëÿ çàïóñêà óêàçàííûõ êîìàíä èëè ïðîãðàìì.\n\ - Âûïîëíÿåò êîìàíäó.\n\ -TIME Âûâîä èëè èçìåíåíèå âðåìåíè.\n\ -TIMER Ñåêóíäîìåð.\n\ -TITLE Èçìåíåíèå çàãîëîâêà îêíà êîìàíäíîé ñòðîêè.\n\ -TYPE Âûâîä ñîäåðæèìîãî îäíîãî èëè íåñêîëüêèõ òåêñòîâûõ ôàéëîâ.\n\ -VER Âûâîä âåðñèè ÎÑ.\n\ -VERIFY Âêëþ÷åíèå èëè îòêëþ÷åíèå ðåæèìà ïðîâåðêè ïðàâèëüíîñòè çàïèñè ôàéëîâ\n\ - íà äèñê.\n\ -VOL Âûâîäèò ìåòêó òîìà è ñåðèéíûé íîìåð.\n" +PROMPT Изменение приглашения командной строки.\n\ +PUSHD Сохраняет текущую директорию, а потом меняет ее.\n\ +RD Удаление каталога.\n\ +REM Записывает комментарии (замечения) в пакетных файлах.\n\ +REN Переименование одного или нескольких файлов или каталогов.\n\ +RENAME Переименование одного или нескольких файлов или каталогов.\n\ +RMDIR Удаление каталога.\n\ +SCREEN Перемещение курсора и вывод текста.\n\ +SET Вывод, задание и удаление переменных среды.\n\ +SHIFT Изменение содержимого (сдвиг) подставляемых параметров для пакетного файла\n" +STRING_HELP2, "START Открывает отдельное окно для запуска указанных команд или программ.\n\ + Выполняет команду.\n\ +TIME Вывод или изменение времени.\n\ +TIMER Секундомер.\n\ +TITLE Изменение заголовка окна командной строки.\n\ +TYPE Вывод содержимого одного или нескольких текстовых файлов.\n\ +VER Вывод версии ОС.\n\ +VERIFY Включение или отключение режима проверки правильности записи файлов\n\ + на диск.\n\ +VOL Выводит метку тома и серийный номер.\n" STRING_CHOICE_OPTION, "YN" STRING_COPY_OPTION, "YNA" -STRING_ALIAS_ERROR, "Êîìàíäíàÿ ñòðîêà ñëèøêîì äëèííàÿ ïîñëå ðàçâåðòûâàíèÿ ïñåâäîíèìîâ!\n" +STRING_ALIAS_ERROR, "Командная строка слишком длинная после развертывания псевдонимов!\n" STRING_ASSOC_ERROR, "File association not found for extension %s\n" -STRING_BATCH_ERROR, "Îøèáêà îòêðûòèÿ êîìàíäíîãî ôàéëà\n" -STRING_CHCP_ERROR1, "Òåêóùàÿ êîäîâàÿ ñòðàíèöà: %u\n" -STRING_CHCP_ERROR4, "Îøèáî÷íàÿ êîäîâàÿ ñòðàíèöà\n" -STRING_CHOICE_ERROR, "Îøèáî÷íûé ïàðàìåòð. Îæèäàåòñÿ ôîðìàò: /C[:]ïàðàìåòðû" -STRING_CHOICE_ERROR_TXT, "Îøèáî÷íûé ïàðàìåòð. Îæèäàåòñÿ ôîðìàò: /T[:]c,nn" -STRING_CHOICE_ERROR_OPTION, "Îøèáî÷íûé ïàðàìåòð: %s" -STRING_MD_ERROR, "Ïîäêàòàëîã èëè ôàéë óæå ñóùåñòâóåò.\n" -STRING_MD_ERROR2, "Ïóòü ê íîâîìó êàòàëîãó íå ñóùåñòâóåò.\n" -STRING_CMD_ERROR1, "Íå ìîãó ïåðåíàïðàâèòü ââîä èç ôàéëà %s\n" -STRING_CMD_ERROR2, "Îøèáêà ñîçäàíèÿ âðåìåííîãî ôàéëà äëÿ pipe-äàííûõ\n" -STRING_CMD_ERROR3, "Íå ìîãó ïåðåíàïðàâèòü â ôàéë %s\n" -STRING_CMD_ERROR4, "Çàïóñê %s...\n" -STRING_CMD_ERROR5, "Çàïóñê cmdexit.bat...\n" -STRING_COLOR_ERROR1, "Îäèíàêîâûå öâåòà! (Öâåòà ôîíà è òåêñòà íå ìîãóò áûòü îäèíàêîâûìè)" -STRING_COLOR_ERROR2, "îøèáêà â óêàçàíèè öâåòà" -STRING_COLOR_ERROR3, "Öâåò %x\n" -STRING_COLOR_ERROR4, "Îäèíàêîâûå öâåòà!" -STRING_CONSOLE_ERROR, "Íåèçâåñòíàÿ îøèáêà: %d\n" -STRING_COPY_ERROR1, "Îøèáêà: Íåâîçìîæíî îòêðûòü èñòî÷íèê - %s!\n" -STRING_COPY_ERROR2, "Îøèáêà: Íåâîçìîæíî êîïèðîâàòü â ñåáÿ!\n" -STRING_COPY_ERROR3, "Îøèáêà çàïèñè!\n" -STRING_COPY_ERROR4, "Îøèáêà:  äàííûé ìîìåíò íå ðåàëèçîâàíî!\n" -STRING_DATE_ERROR, "Íåïðàâèëüíàÿ äàòà." -STRING_DEL_ERROR5, "Ôàéë %s áóäåò óäàëåí! " -STRING_DEL_ERROR6, "Âû óâåðåíû (Y/N)?" -STRING_DEL_ERROR7, "Óäàëåíèå: %s\n" -STRING_ERROR_ERROR1, "Íåèçâåñòíàÿ îøèáêà! Êîä îøèáêè: 0x%lx\n" -STRING_ERROR_ERROR2, "Ñèíòàêñè÷åñêàÿ îøèáêà" -STRING_FOR_ERROR1, "'in' îòñóòñòâóåò â êîìàíäå for." -STRING_FOR_ERROR2, "ñêîáîê íåîáíàðóæåíî." -STRING_FOR_ERROR3, "'do' îòñóòñâóåò." -STRING_FOR_ERROR4, "íåò êîìàíäû ïîñëå 'do'." -STRING_FREE_ERROR1, "Íåïðàâèëüíîå èìÿ äèñêà" -STRING_FREE_ERROR2, "íåîòìå÷åíî" -STRING_GOTO_ERROR1, "Íå îïðåäåëåíà ìåòêà äëÿ GOTO" -STRING_GOTO_ERROR2, "Ìåòêà '%s' íå íàéäåíà\n" +STRING_BATCH_ERROR, "Ошибка открытия командного файла\n" +STRING_CHCP_ERROR1, "Текущая кодовая страница: %u\n" +STRING_CHCP_ERROR4, "Ошибочная кодовая страница\n" +STRING_CHOICE_ERROR, "Ошибочный параметр. Ожидается формат: /C[:]параметры" +STRING_CHOICE_ERROR_TXT, "Ошибочный параметр. Ожидается формат: /T[:]c,nn" +STRING_CHOICE_ERROR_OPTION, "Ошибочный параметр: %s" +STRING_MD_ERROR, "Подкаталог или файл уже существует.\n" +STRING_MD_ERROR2, "Путь к новому каталогу не существует.\n" +STRING_CMD_ERROR1, "Не могу перенаправить ввод из файла %s\n" +STRING_CMD_ERROR2, "Ошибка создания временного файла для pipe-данных\n" +STRING_CMD_ERROR3, "Не могу перенаправить в файл %s\n" +STRING_CMD_ERROR4, "Запуск %s...\n" +STRING_CMD_ERROR5, "Запуск cmdexit.bat...\n" +STRING_COLOR_ERROR1, "Одинаковые цвета! (Цвета фона и текста не могут быть одинаковыми)" +STRING_COLOR_ERROR2, "ошибка в указании цвета" +STRING_COLOR_ERROR3, "Цвет %x\n" +STRING_COLOR_ERROR4, "Одинаковые цвета!" +STRING_CONSOLE_ERROR, "Неизвестная ошибка: %d\n" +STRING_COPY_ERROR1, "Ошибка: Невозможно открыть источник - %s!\n" +STRING_COPY_ERROR2, "Ошибка: Невозможно копировать в себя!\n" +STRING_COPY_ERROR3, "Ошибка записи!\n" +STRING_COPY_ERROR4, "Ошибка: В данный момент не реализовано!\n" +STRING_DATE_ERROR, "Неправильная дата." +STRING_DEL_ERROR5, "Файл %s будет удален! " +STRING_DEL_ERROR6, "Вы уверены (Y/N)?" +STRING_DEL_ERROR7, "Удаление: %s\n" +STRING_ERROR_ERROR1, "Неизвестная ошибка! Код ошибки: 0x%lx\n" +STRING_ERROR_ERROR2, "Синтаксическая ошибка" +STRING_FOR_ERROR1, "'in' отсутствует в команде for." +STRING_FOR_ERROR2, "скобок необнаружено." +STRING_FOR_ERROR3, "'do' отсутсвует." +STRING_FOR_ERROR4, "нет команды после 'do'." +STRING_FREE_ERROR1, "Неправильное имя диска" +STRING_FREE_ERROR2, "неотмечено" +STRING_GOTO_ERROR1, "Не определена метка для GOTO" +STRING_GOTO_ERROR2, "Метка '%s' не найдена\n" STRING_MOVE_ERROR1, "[OK]\n" -STRING_MOVE_ERROR2, "[Îøèáêà]\n" +STRING_MOVE_ERROR2, "[Ошибка]\n" -STRING_REN_ERROR1, "Âûïîëíåíèå MoveFile() áûëî íåóñïåøíûì. Îøèáêà: %lu\n" +STRING_REN_ERROR1, "Выполнение MoveFile() было неуспешным. Ошибка: %lu\n" -STRING_START_ERROR1, "Íà äàííûé ìîìåíò íåò ïîääåðæêè ïàêåòíûõ ôàéëîâ!" +STRING_START_ERROR1, "На данный момент нет поддержки пакетных файлов!" -STRING_TIME_ERROR1, "Íåïðàâèëüíîå âðåìÿ." +STRING_TIME_ERROR1, "Неправильное время." -STRING_TYPE_ERROR1, "Íåïðàâèëüíûé ïàðàìåòð '/%s'\n" +STRING_TYPE_ERROR1, "Неправильный параметр '/%s'\n" -STRING_WINDOW_ERROR1, "îêíî íå íàéäåíî" +STRING_WINDOW_ERROR1, "окно не найдено" -STRING_ERROR_PARAMETERF_ERROR, "Íåêîððåêòíûé ôîðìàò ïàðàìåòðà - %c\n" -STRING_ERROR_INVALID_SWITCH, "Íåâåðíûé ïàðàìåòð - /%c\n" -STRING_ERROR_TOO_MANY_PARAMETERS, "Ñëèøêîì ìíîãî ïàðàìåòðîâ - %s\n" -STRING_ERROR_PATH_NOT_FOUND, "Ïóòü íå íàéäåí\n" -STRING_ERROR_FILE_NOT_FOUND, "Ôàéë íå íàéäåí\n" -STRING_ERROR_REQ_PARAM_MISSING, "Îòñóòñòâóåò íåîáõîäèìûé ïàðàìåòð\n" -STRING_ERROR_INVALID_DRIVE, "Îøèáî÷íîå îïðåäåëåíèå äèñêà\n" -STRING_ERROR_INVALID_PARAM_FORMAT, "Îøèáî÷íûé ôîðìàò ïàðàìåòðà - %s\n" -STRING_ERROR_BADCOMMAND, "Íåïðàâèëüíàÿ êîìàíäà èëè íåâåðíîå èìÿ ôàéëà - %s\n" -STRING_ERROR_OUT_OF_MEMORY, "Íåõâàòêà ïàìÿòè.\n" -STRING_ERROR_CANNOTPIPE, "Îøèáêà! Íåâîçìîæíî èñïîëüçîâàòü pipe! Íåâîçìîæíî ñîçäàòü âðåìåííûé ôàéë!\n" -STRING_ERROR_D_PAUSEMSG, "Äëÿ ïðîäîëæåíèÿ íàæìèòå ëþáóþ êëàâèøó . . ." -STRING_ERROR_DRIVER_NOT_READY, "Óñòðîéñòâî íå ãîòîâî" +STRING_ERROR_PARAMETERF_ERROR, "Некорректный формат параметра - %c\n" +STRING_ERROR_INVALID_SWITCH, "Неверный параметр - /%c\n" +STRING_ERROR_TOO_MANY_PARAMETERS, "Слишком много параметров - %s\n" +STRING_ERROR_PATH_NOT_FOUND, "Путь не найден\n" +STRING_ERROR_FILE_NOT_FOUND, "Файл не найден\n" +STRING_ERROR_REQ_PARAM_MISSING, "Отсутствует необходимый параметр\n" +STRING_ERROR_INVALID_DRIVE, "Ошибочное определение диска\n" +STRING_ERROR_INVALID_PARAM_FORMAT, "Ошибочный формат параметра - %s\n" +STRING_ERROR_BADCOMMAND, "Неправильная команда или неверное имя файла - %s\n" +STRING_ERROR_OUT_OF_MEMORY, "Нехватка памяти.\n" +STRING_ERROR_CANNOTPIPE, "Ошибка! Невозможно использовать pipe! Невозможно создать временный файл!\n" +STRING_ERROR_D_PAUSEMSG, "Для продолжения нажмите любую клавишу . . ." +STRING_ERROR_DRIVER_NOT_READY, "Устройство не готово" -STRING_PATH_ERROR, "CMD: Íå â ñðåäå îêðóæåíèÿ '%s'\n" +STRING_PATH_ERROR, "CMD: Не в среде окружения '%s'\n" STRING_REACTOS_VERSION, "ReactOS Operating System [Version %s-%s]\n" -STRING_CMD_SHELLINFO, "\nÈíòåðïðåòàòîð êîìàíäíîé ñòðîêè ReactOS\nVersion %s %s" -STRING_VERSION_RUNVER, " çàïóùåí íà %s" -STRING_COPY_FILE , " %d ôàéë(îâ) ñêîïèðîâàíî\n" +STRING_CMD_SHELLINFO, "\nИнтерпретатор командной строки ReactOS\nVersion %s %s" +STRING_VERSION_RUNVER, " запущен на %s" +STRING_COPY_FILE , " %d файл(ов) скопировано\n" STRING_DELETE_WIPE, "wiped" -STRING_FOR_ERROR, "íåïðàâèëüíîå çàäàíèå ïåðåìåííîé." -STRING_SCREEN_COL, "íåïðàâèëüíîå çíà÷åíèå äëÿ êîë" -STRING_SCREEN_ROW, "íåïðàâèëüíîå çíà÷åíèå äëÿ ñòð" +STRING_FOR_ERROR, "неправильное задание переменной." +STRING_SCREEN_COL, "неправильное значение для кол" +STRING_SCREEN_ROW, "неправильное значение для стр" STRING_TIMER_TIME "Timer %d is %s: " STRING_MKLINK_CREATED_SYMBOLIC, "Symbolic link created for %s <<===>> %s\n" STRING_MKLINK_CREATED_HARD, "Hard link created for %s <<===>> %s\n" @@ -669,9 +669,9 @@ STRING_MKLINK_CREATED_JUNCTION, "Junction created for %s <<===>> %s\n" STRING_MORE, "More? " STRING_CANCEL_BATCH_FILE, "\r\nCtrl-Break pressed. Cancel batch file? (Yes/No/All) " -STRING_INVALID_OPERAND, "Íåâåðíûé îïåðàíä." -STRING_EXPECTED_CLOSE_PAREN, "Îæèäàåòñÿ ')'." -STRING_EXPECTED_NUMBER_OR_VARIABLE,"Îæèäàåòñÿ ÷èñëî èëè íàçâàíèå ïåðåìåííîé." -STRING_SYNTAX_COMMAND_INCORRECT, "Íåâåðíûé ñèíòàêñèñ êîìàíäû." +STRING_INVALID_OPERAND, "Неверный операнд." +STRING_EXPECTED_CLOSE_PAREN, "Ожидается ')'." +STRING_EXPECTED_NUMBER_OR_VARIABLE,"Ожидается число или название переменной." +STRING_SYNTAX_COMMAND_INCORRECT, "Неверный синтаксис команды." END From 8900f7d5d4c5e4d825fe1ec9074a841e6690e44e Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Sun, 27 Mar 2011 01:12:25 +0000 Subject: [PATCH 03/66] [WIN32K] Rename IntResetMonitorSize to IntUpdateMonitorSize Use IntUpdateMonitorSize instead of setting monitor size manually when attaching monitor Change display device name from VIDEOx to DISPLAYx as it is in Windows (fixes user32:monitor winetest) [USER32] Return FALSE in EnumDisplayMonitors if EnumProc returned FALSE (fixes user32:monitor winetest) svn path=/trunk/; revision=51169 --- reactos/dll/win32/user32/misc/display.c | 22 +++++++++------- reactos/subsystems/win32/win32k/eng/device.c | 2 +- .../subsystems/win32/win32k/include/monitor.h | 2 +- .../subsystems/win32/win32k/ntuser/display.c | 2 +- .../subsystems/win32/win32k/ntuser/monitor.c | 26 ++++++------------- 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/reactos/dll/win32/user32/misc/display.c b/reactos/dll/win32/user32/misc/display.c index 196ff76d369..af430b3bbc1 100644 --- a/reactos/dll/win32/user32/misc/display.c +++ b/reactos/dll/win32/user32/misc/display.c @@ -116,6 +116,7 @@ EnumDisplayMonitors( HMONITOR *hMonitorList; LPRECT pRectList; HANDLE hHeap; + BOOL ret = FALSE; /* get list of monitors/rects */ iCount = NtUserEnumDisplayMonitors(hdc, lprcClip, NULL, NULL, 0); @@ -139,18 +140,15 @@ EnumDisplayMonitors( pRectList = HeapAlloc(hHeap, 0, sizeof (RECT) * iCount); if (pRectList == NULL) { - HeapFree(hHeap, 0, hMonitorList); SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; + goto cleanup; } iCount = NtUserEnumDisplayMonitors(hdc, lprcClip, hMonitorList, pRectList, iCount); if (iCount <= 0) { /* FIXME: SetLastError() */ - HeapFree(hHeap, 0, hMonitorList); - HeapFree(hHeap, 0, pRectList); - return FALSE; + goto cleanup; } /* enumerate list */ @@ -167,11 +165,17 @@ EnumDisplayMonitors( } if (!lpfnEnum(hMonitor, hMonitorDC, pMonitorRect, dwData)) - break; + goto cleanup; /* return FALSE */ } - HeapFree(hHeap, 0, hMonitorList); - HeapFree(hHeap, 0, pRectList); - return TRUE; + + ret = TRUE; + +cleanup: + if(hMonitorList) + HeapFree(hHeap, 0, hMonitorList); + if(pRectList) + HeapFree(hHeap, 0, pRectList); + return ret; } diff --git a/reactos/subsystems/win32/win32k/eng/device.c b/reactos/subsystems/win32/win32k/eng/device.c index 802bcf50e4f..b20ad072db2 100644 --- a/reactos/subsystems/win32/win32k/eng/device.c +++ b/reactos/subsystems/win32/win32k/eng/device.c @@ -90,7 +90,7 @@ EngpRegisterGraphicsDevice( pustrDeviceName->Length); /* Create a win device name (FIXME: virtual devices!) */ - swprintf(pGraphicsDevice->szWinDeviceName, L"\\\\.\\VIDEO%d", (int)giDevNum); + swprintf(pGraphicsDevice->szWinDeviceName, L"\\\\.\\DISPLAY%d", (int)giDevNum); /* Allocate a buffer for the strings */ cj = pustrDiplayDrivers->Length + pustrDescription->Length + sizeof(WCHAR); diff --git a/reactos/subsystems/win32/win32k/include/monitor.h b/reactos/subsystems/win32/win32k/include/monitor.h index 280864fb7cb..cc42f0d1edb 100644 --- a/reactos/subsystems/win32/win32k/include/monitor.h +++ b/reactos/subsystems/win32/win32k/include/monitor.h @@ -40,7 +40,7 @@ NTSTATUS CleanupMonitorImpl(VOID); NTSTATUS IntAttachMonitor(PDEVOBJ *pGdiDevice, ULONG DisplayNumber); NTSTATUS IntDetachMonitor(PDEVOBJ *pGdiDevice); -NTSTATUS IntResetMonitorSize(IN PDEVOBJ *pGdiDevice); +NTSTATUS IntUpdateMonitorSize(IN PDEVOBJ *pGdiDevice); PMONITOR FASTCALL UserGetMonitorObject(IN HMONITOR); PMONITOR FASTCALL IntGetPrimaryMonitor(VOID); diff --git a/reactos/subsystems/win32/win32k/ntuser/display.c b/reactos/subsystems/win32/win32k/ntuser/display.c index 98b93d5ddf7..76c0d25f315 100644 --- a/reactos/subsystems/win32/win32k/ntuser/display.c +++ b/reactos/subsystems/win32/win32k/ntuser/display.c @@ -766,7 +766,7 @@ UserChangeDisplaySettings( //IntvGetDeviceCaps(&PrimarySurface, &GdiHandleTable->DevCaps); /* Set new size of the monitor */ - IntResetMonitorSize(ppdev); + IntUpdateMonitorSize(ppdev); /* Remove all cursor clipping */ UserClipCursor(NULL); diff --git a/reactos/subsystems/win32/win32k/ntuser/monitor.c b/reactos/subsystems/win32/win32k/ntuser/monitor.c index 935be89cf12..83ea41a1b9b 100644 --- a/reactos/subsystems/win32/win32k/ntuser/monitor.c +++ b/reactos/subsystems/win32/win32k/ntuser/monitor.c @@ -157,17 +157,8 @@ IntAttachMonitor(IN PDEVOBJ *pGdiDevice, } Monitor->GdiDevice = pGdiDevice; - Monitor->rcMonitor.left = 0; - Monitor->rcMonitor.top = 0; - Monitor->rcMonitor.right = Monitor->rcMonitor.left + pGdiDevice->gdiinfo.ulHorzRes; - Monitor->rcMonitor.bottom = Monitor->rcMonitor.top + pGdiDevice->gdiinfo.ulVertRes; - Monitor->rcWork = Monitor->rcMonitor; Monitor->cWndStack = 0; - Monitor->hrgnMonitor = IntSysCreateRectRgnIndirect( &Monitor->rcMonitor ); - - IntGdiSetRegionOwner(Monitor->hrgnMonitor, GDI_OBJ_HMGR_PUBLIC); - if (gMonitorList == NULL) { DPRINT("Primary monitor is beeing attached\n"); @@ -184,6 +175,8 @@ IntAttachMonitor(IN PDEVOBJ *pGdiDevice, } Monitor->Prev = p; } + + IntUpdateMonitorSize(pGdiDevice); return STATUS_SUCCESS; } @@ -246,7 +239,7 @@ IntDetachMonitor(IN PDEVOBJ *pGdiDevice) return STATUS_SUCCESS; } -/* IntResetMonitorSize +/* IntUpdateMonitorSize * * Reset size of the monitor using atached device * @@ -259,7 +252,7 @@ IntDetachMonitor(IN PDEVOBJ *pGdiDevice) * Returns a NTSTATUS */ NTSTATUS -IntResetMonitorSize(IN PDEVOBJ *pGdiDevice) +IntUpdateMonitorSize(IN PDEVOBJ *pGdiDevice) { PMONITOR Monitor; @@ -701,13 +694,10 @@ NtUserGetMonitorInfo( /* fill device name */ if (MonitorInfo.cbSize == sizeof (MONITORINFOEXW)) { - WCHAR nul = L'\0'; - INT len = Monitor->DeviceName.Length; - if (len >= CCHDEVICENAME * sizeof (WCHAR)) - len = (CCHDEVICENAME - 1) * sizeof (WCHAR); - - memcpy(MonitorInfo.szDevice, Monitor->DeviceName.Buffer, len); - memcpy(MonitorInfo.szDevice + (len / sizeof (WCHAR)), &nul, sizeof (WCHAR)); + RtlStringCbCopyNW(MonitorInfo.szDevice, + sizeof(MonitorInfo.szDevice), + Monitor->DeviceName.Buffer, + Monitor->DeviceName.Length); } /* output data */ From 34bb47605692747a889bc652c87d34d1d1e9fc2d Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sun, 27 Mar 2011 05:40:30 +0000 Subject: [PATCH 04/66] [GDI32] - Finish object attribute support. svn path=/trunk/; revision=51170 --- reactos/dll/win32/gdi32/misc/misc.c | 62 ++++++++++++++++++------- reactos/dll/win32/gdi32/objects/brush.c | 2 + reactos/dll/win32/gdi32/objects/pen.c | 24 +++++++++- 3 files changed, 70 insertions(+), 18 deletions(-) diff --git a/reactos/dll/win32/gdi32/misc/misc.c b/reactos/dll/win32/gdi32/misc/misc.c index 8fedb8fb820..25ff84253de 100644 --- a/reactos/dll/win32/gdi32/misc/misc.c +++ b/reactos/dll/win32/gdi32/misc/misc.c @@ -275,7 +275,7 @@ HGDIOBJ FASTCALL hGetPEBHandle(HANDLECACHETYPE Type, COLORREF cr) { - int Number; + int Number, Count, MaxNum, GdiType; HANDLE Lock; HGDIOBJ Handle = NULL; @@ -287,26 +287,54 @@ hGetPEBHandle(HANDLECACHETYPE Type, COLORREF cr) Number = GdiHandleCache->ulNumHandles[Type]; - if ( Number && Number <= CACHE_REGION_ENTRIES ) + if (Type == hctBrushHandle) { - if ( Type == hctRegionHandle) - { - PRGN_ATTR pRgn_Attr; - HGDIOBJ *hPtr; - hPtr = GdiHandleCache->Handle + CACHE_BRUSH_ENTRIES+CACHE_PEN_ENTRIES; - Handle = hPtr[Number - 1]; + Count = 0; + MaxNum = CACHE_BRUSH_ENTRIES; + GdiType = GDILoObjType_LO_BRUSH_TYPE; + } + else if (Type == hctPenHandle) + { + Count = CACHE_BRUSH_ENTRIES; + MaxNum = CACHE_PEN_ENTRIES; + GdiType = GDILoObjType_LO_PEN_TYPE; + } + else if (Type == hctRegionHandle) + { + Count = CACHE_BRUSH_ENTRIES+CACHE_PEN_ENTRIES; + MaxNum = CACHE_REGION_ENTRIES; + GdiType = GDILoObjType_LO_REGION_TYPE; + } + else // Font is not supported here. + { + return Handle; + } - if (GdiGetHandleUserData( Handle, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr)) - { - if (pRgn_Attr->AttrFlags & ATTR_CACHED) + if ( Number && Number <= MaxNum ) + { + PBRUSH_ATTR pBrush_Attr; + HGDIOBJ *hPtr; + hPtr = GdiHandleCache->Handle + Count; + Handle = hPtr[Number - 1]; + + if (GdiGetHandleUserData( Handle, GdiType, (PVOID) &pBrush_Attr)) + { + if (pBrush_Attr->AttrFlags & ATTR_CACHED) + { + DPRINT("Get Handle! Type %d Count %d PEB 0x%x\n", Type, GdiHandleCache->ulNumHandles[Type], NtCurrentTeb()->ProcessEnvironmentBlock); + pBrush_Attr->AttrFlags &= ~ATTR_CACHED; + hPtr[Number - 1] = NULL; + GdiHandleCache->ulNumHandles[Type]--; + if ( Type == hctBrushHandle ) // Handle only brush. + { + if ( pBrush_Attr->lbColor != cr ) { - DPRINT("Get Handle! Count %d PEB 0x%x\n", GdiHandleCache->ulNumHandles[Type], NtCurrentTeb()->ProcessEnvironmentBlock); - pRgn_Attr->AttrFlags &= ~ATTR_CACHED; - hPtr[Number - 1] = NULL; - GdiHandleCache->ulNumHandles[Type]--; + pBrush_Attr->lbColor = cr ; + pBrush_Attr->AttrFlags |= ATTR_NEW_COLOR; } - } - } + } + } + } } (void)InterlockedExchangePointer((PVOID*)&GdiHandleCache->ulLock, Lock); return Handle; diff --git a/reactos/dll/win32/gdi32/objects/brush.c b/reactos/dll/win32/gdi32/objects/brush.c index 185bed6c3fb..e1b7f2951e5 100644 --- a/reactos/dll/win32/gdi32/objects/brush.c +++ b/reactos/dll/win32/gdi32/objects/brush.c @@ -234,6 +234,8 @@ CreateBrushIndirect( break; case BS_SOLID: +/* hBrush = hGetPEBHandle(hctBrushHandle, LogBrush->lbColor); + if (!hBrush)*/ hBrush = NtGdiCreateSolidBrush(LogBrush->lbColor, 0); break; diff --git a/reactos/dll/win32/gdi32/objects/pen.c b/reactos/dll/win32/gdi32/objects/pen.c index 0a431c20049..dbbe0f2de2b 100644 --- a/reactos/dll/win32/gdi32/objects/pen.c +++ b/reactos/dll/win32/gdi32/objects/pen.c @@ -23,12 +23,34 @@ CreatePen( int nWidth, COLORREF crColor) { - /* FIXME Some part need be done in user mode */ +/* HPEN hPen; + PBRUSH_ATTR Pen_Attr; +*/ + if (nPenStyle < PS_SOLID) nPenStyle = PS_SOLID; if (nPenStyle > PS_DASHDOTDOT) { if (nPenStyle == PS_NULL) return GetStockObject(NULL_PEN); if (nPenStyle != PS_INSIDEFRAME) nPenStyle = PS_SOLID; } +#if 0 + hPen = hGetPEBHandle(hctPenHandle, nPenStyle); + if ( nWidth || nPenStyle || !hPen ) + { + return NtGdiCreatePen(nPenStyle, nWidth, crColor, NULL); + } + + if ((GdiGetHandleUserData( hPen, GDI_OBJECT_TYPE_PEN, (PVOID) &Pen_Attr)) && + ( Pen_Attr != NULL )) + { + if ( Pen_Attr->lbColor != crColor) + { + Pen_Attr->lbColor = crColor; + Pen_Attr->AttrFlags |= ATTR_NEW_COLOR; + } + return hPen; + } + DeleteObject(hPen); +#endif return NtGdiCreatePen(nPenStyle, nWidth, crColor, NULL); } From 828d04705abceafa449057ca35aa2d71332282ae Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sun, 27 Mar 2011 11:32:55 +0000 Subject: [PATCH 05/66] [NTOS/MM] - Return STATUS_IMAGE_NOT_AT_BASE when mapping an image section to a different base address. New ntdll loader depends on this and fails to relocate the image if this status is not returned. svn path=/trunk/; revision=51171 --- reactos/ntoskrnl/mm/section.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index aa092adf41d..83471dd5efc 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -4571,6 +4571,7 @@ MmMapViewOfSection(IN PVOID SectionObject, PMMSUPPORT AddressSpace; ULONG ViewOffset; NTSTATUS Status = STATUS_SUCCESS; + BOOLEAN NotAtBase = FALSE; if ((ULONG_PTR)SectionObject & 1) { @@ -4652,6 +4653,8 @@ MmMapViewOfSection(IN PVOID SectionObject, MmUnlockAddressSpace(AddressSpace); return(STATUS_UNSUCCESSFUL); } + /* Remember that we loaded image at a different base address */ + NotAtBase = TRUE; } for (i = 0; i < NrSegments; i++) @@ -4756,7 +4759,12 @@ MmMapViewOfSection(IN PVOID SectionObject, MmUnlockAddressSpace(AddressSpace); - return(STATUS_SUCCESS); + if (NotAtBase) + Status = STATUS_IMAGE_NOT_AT_BASE; + else + Status = STATUS_SUCCESS; + + return Status; } /* From 4288ba63064d3c8b754146db19bf7ff0855d1d7b Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 27 Mar 2011 13:12:12 +0000 Subject: [PATCH 06/66] [SERVICES] ScmWriteDependencies: - Fixed an off-by-one bug. This bug caused a wrong calculation of the 'DependOnGroup' value data length. Group dependencies were not written properly to the registry. - Write 'DependOnService' and 'DependOnService' values to the registry only if the dependency strings are not empty. Delete a value if the corresponding dependency string is empty. This fixes another winetest. svn path=/trunk/; revision=51172 --- reactos/base/system/services/config.c | 42 ++++++++++++++++++--------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/reactos/base/system/services/config.c b/reactos/base/system/services/config.c index b056af5c86c..bcde1d47198 100644 --- a/reactos/base/system/services/config.c +++ b/reactos/base/system/services/config.c @@ -125,7 +125,7 @@ ScmWriteDependencies(HKEY hServiceKey, lpDst = lpGroupDeps; while (*lpSrc != 0) { - dwLength = wcslen(lpSrc); + dwLength = wcslen(lpSrc) + 1; if (*lpSrc == SC_GROUP_IDENTIFIERW) { lpSrc++; @@ -157,21 +157,37 @@ ScmWriteDependencies(HKEY hServiceKey, *lpDst = 0; dwServiceLength++; - dwError = RegSetValueExW(hServiceKey, - L"DependOnGroup", - 0, - REG_MULTI_SZ, - (LPBYTE)lpGroupDeps, - dwGroupLength * sizeof(WCHAR)); + if (dwGroupLength > 1) + { + dwError = RegSetValueExW(hServiceKey, + L"DependOnGroup", + 0, + REG_MULTI_SZ, + (LPBYTE)lpGroupDeps, + dwGroupLength * sizeof(WCHAR)); + } + else + { + RegDeleteValueW(hServiceKey, + L"DependOnGroup"); + } if (dwError == ERROR_SUCCESS) { - dwError = RegSetValueExW(hServiceKey, - L"DependOnService", - 0, - REG_MULTI_SZ, - (LPBYTE)lpServiceDeps, - dwServiceLength * sizeof(WCHAR)); + if (dwServiceLength > 1) + { + dwError = RegSetValueExW(hServiceKey, + L"DependOnService", + 0, + REG_MULTI_SZ, + (LPBYTE)lpServiceDeps, + dwServiceLength * sizeof(WCHAR)); + } + else + { + RegDeleteValueW(hServiceKey, + L"DependOnService"); + } } HeapFree(GetProcessHeap(), 0, lpGroupDeps); From 29b96f834c0476653c66c63b11bd9217e15618d6 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sun, 27 Mar 2011 16:37:26 +0000 Subject: [PATCH 07/66] - Lay out critical system DLLs so that they don't overlap when loaded properly. svn path=/trunk/; revision=51173 --- reactos/baseaddress.rbuild | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/reactos/baseaddress.rbuild b/reactos/baseaddress.rbuild index 6d5988ca988..489cd673514 100644 --- a/reactos/baseaddress.rbuild +++ b/reactos/baseaddress.rbuild @@ -244,13 +244,13 @@ - - - - - - - + + + + + + + From 91eff339fd8ccd4201568b0a3c3cbe1cc07e61d3 Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Sun, 27 Mar 2011 18:34:22 +0000 Subject: [PATCH 08/66] Update the Applications to the recent Versions. Add the dlls the C,VB etc Runtime Packs will install into the description. Remove goOO from rapps. svn path=/trunk/; revision=51175 --- .../applications/rapps/rapps/comctl32ocx.txt | 2 +- .../applications/rapps/rapps/firefox36.txt | 18 +++++------ .../base/applications/rapps/rapps/go-oo.txt | 27 ---------------- .../applications/rapps/rapps/libreoffice.txt | 6 ++-- .../base/applications/rapps/rapps/mfc40.txt | 2 +- .../applications/rapps/rapps/mirandaim.txt | 4 +-- .../base/applications/rapps/rapps/msxml3.txt | 4 +-- .../base/applications/rapps/rapps/scite.txt | 4 +-- .../applications/rapps/rapps/seamonkey.txt | 14 ++++---- .../base/applications/rapps/rapps/tahoma.txt | 2 +- .../base/applications/rapps/rapps/vb5run.txt | 2 +- .../base/applications/rapps/rapps/vb6run.txt | 2 +- .../applications/rapps/rapps/vc2005run.txt | 32 ------------------- .../applications/rapps/rapps/vc2005sp1run.txt | 2 +- .../applications/rapps/rapps/vc2008run.txt | 32 ------------------- .../applications/rapps/rapps/vc2008sp1run.txt | 2 +- .../base/applications/rapps/rapps/vc6run.txt | 2 +- reactos/base/applications/rapps/rapps/vlc.txt | 6 ++-- 18 files changed, 36 insertions(+), 127 deletions(-) delete mode 100644 reactos/base/applications/rapps/rapps/go-oo.txt delete mode 100644 reactos/base/applications/rapps/rapps/vc2005run.txt delete mode 100644 reactos/base/applications/rapps/rapps/vc2008run.txt diff --git a/reactos/base/applications/rapps/rapps/comctl32ocx.txt b/reactos/base/applications/rapps/rapps/comctl32ocx.txt index b0aac593814..47494f3fb43 100644 --- a/reactos/base/applications/rapps/rapps/comctl32ocx.txt +++ b/reactos/base/applications/rapps/rapps/comctl32ocx.txt @@ -4,7 +4,7 @@ Name = Microsoft Visual Basic 6.0 Common Controls Version = 6.0 Licence = Unknown -Description = File needed by some applications. +Description = File needed by some applications. Contains: comctl32.ocx, mscomctl.ocx, advpack.dll. Size = 914kB Category = 14 URLSite = http://www.microsoft.com/downloads/details.aspx?FamilyID=25437D98-51D0-41C1-BB14-64662F5F62FE&displaylang=en diff --git a/reactos/base/applications/rapps/rapps/firefox36.txt b/reactos/base/applications/rapps/rapps/firefox36.txt index 4f5d3b8c96b..207565f77b1 100644 --- a/reactos/base/applications/rapps/rapps/firefox36.txt +++ b/reactos/base/applications/rapps/rapps/firefox36.txt @@ -2,53 +2,53 @@ [Section] Name = Mozilla Firefox 3.6 -Version = 3.6.15 +Version = 3.6.16 Licence = MPL/GPL/LGPL Description = The most popular and one of the best free Web Browsers out there. Size = 8.2M Category = 5 URLSite = http://www.mozilla.com/en-US/ -URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.15/win32/en-US/Firefox%20Setup%203.6.15.exe +URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.16/win32/en-US/Firefox%20Setup%203.6.16.exe CDPath = none [Section.0407] Description = Der populärste und einer der besten freien Webbrowser. Size = 8.1M URLSite = http://www.mozilla-europe.org/de/ -URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.15/win32/de/Firefox%20Setup%203.6.15.exe +URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.16/win32/de/Firefox%20Setup%203.6.16.exe [Section.040a] Description = El más popular y uno de los mejores navegadores web gratuitos que hay. Size = 8.1M URLSite = http://www.mozilla-europe.org/es/ -URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.15/win32/es-ES/Firefox%20Setup%203.6.15.exe +URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.16/win32/es-ES/Firefox%20Setup%203.6.16.exe [Section.040c] Description = Le navigateur web gratuit le plus populaire et l'un des meilleurs. Size = 8.1M URLSite = http://www.mozilla-europe.org/fr/ -URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.15/win32/fr/Firefox%20Setup%203.6.15.exe +URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.16/win32/fr/Firefox%20Setup%203.6.16.exe [Section.0414] Description = Mest populære og best også gratis nettleserene der ute. Size = 8.1M URLSite = http://www.mozilla-europe.org/no/ -URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.15/win32/nb-NO/Firefox%20Setup%203.6.15.exe +URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.16/win32/nb-NO/Firefox%20Setup%203.6.16.exe [Section.0415] Description = Najpopularniejsza i jedna z najlepszych darmowych przeglądarek internetowych. Size = 8.9M URLSite = http://www.mozilla-europe.org/pl/ -URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.15/win32/pl/Firefox%20Setup%203.6.15.exe +URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.16/win32/pl/Firefox%20Setup%203.6.16.exe [Section.0419] Description = Один из самых популярных и лучших бесплатных браузеров. Size = 8.5M URLSite = http://www.mozilla-europe.org/ru/ -URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.15/win32/ru/Firefox%20Setup%203.6.15.exe +URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.16/win32/ru/Firefox%20Setup%203.6.16.exe [Section.0422] Description = Найпопулярніший та один з кращих безплатних веб-браузерів. Size = 8.5M URLSite = http://www.mozilla-europe.org/uk/ -URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.15/win32/uk/Firefox%20Setup%203.6.15.exe +URLDownload = http://mozilla.cdn.leaseweb.com/firefox/releases/3.6.16/win32/uk/Firefox%20Setup%203.6.16.exe diff --git a/reactos/base/applications/rapps/rapps/go-oo.txt b/reactos/base/applications/rapps/rapps/go-oo.txt deleted file mode 100644 index 28e9fa68f1a..00000000000 --- a/reactos/base/applications/rapps/rapps/go-oo.txt +++ /dev/null @@ -1,27 +0,0 @@ -; UTF-8 - -[Section] -Name = Go-OO -Version = 3.2.1-11 -Licence = LGPL -Description = Open Source Office Suite, based on Open Office, but way better. -Size = 181.0MB -Category = 6 -URLSite = http://www.go-oo.org/ -URLDownload = http://go-oo.mirrorbrain.org/stable/win32/3.2.1/GoOo-3.2.1-11.exe -CDPath = none - -[Section.0407] -Description = Open Source Office Suite, basierend auf Open Office, aber viel besser. - -[Section.040a] -Description = La suite de ofimática de código abierto. - -[Section.040c] -Description = Suite bureautique open source basée sur Open Office, mais bien meilleure. - -[Section.0415] -Description = Otwarty pakiet biurowy, bazujący na Open Office, ale znacznie lepszy. - -[Section.0422] -Description = Відкритий офісний пакет. diff --git a/reactos/base/applications/rapps/rapps/libreoffice.txt b/reactos/base/applications/rapps/rapps/libreoffice.txt index 93805ef8f7d..d609e3f80b4 100644 --- a/reactos/base/applications/rapps/rapps/libreoffice.txt +++ b/reactos/base/applications/rapps/rapps/libreoffice.txt @@ -2,13 +2,13 @@ [Section] Name = LibreOffice -Version = 3.3.1 +Version = 3.3.2 Licence = LGPL Description = Former called OpenOffice. Open Source Office Suite. -Size = 213.4MB +Size = 214.0MB Category = 6 URLSite = http://www.documentfoundation.org/ -URLDownload = http://download.documentfoundation.org/libreoffice/stable/3.3.1/win/x86/LibO_3.3.1_Win_x86_install_multi.exe +URLDownload = http://download.documentfoundation.org/libreoffice/stable/3.3.2/win/x86/LibO_3.3.2_Win_x86_install_multi.exe CDPath = none [Section.0407] diff --git a/reactos/base/applications/rapps/rapps/mfc40.txt b/reactos/base/applications/rapps/rapps/mfc40.txt index 58e1f4ebe02..b732baa385e 100644 --- a/reactos/base/applications/rapps/rapps/mfc40.txt +++ b/reactos/base/applications/rapps/rapps/mfc40.txt @@ -4,7 +4,7 @@ Name = OLE Viewer and Microsoft Foundation Classes version 4 Version = 4.0 Licence = Unknown -Description = MFC 4 is needed by some applications. +Description = MFC 4 is needed by some applications. Contains: mfc40.dll, msvcrt40.dll. Size = 865kB Category = 14 URLSite = http://support.microsoft.com/kb/122244/ diff --git a/reactos/base/applications/rapps/rapps/mirandaim.txt b/reactos/base/applications/rapps/rapps/mirandaim.txt index 68ff3854ab0..9e1198eb888 100644 --- a/reactos/base/applications/rapps/rapps/mirandaim.txt +++ b/reactos/base/applications/rapps/rapps/mirandaim.txt @@ -2,13 +2,13 @@ [Section] Name = Miranda IM -Version = 0.9.17 +Version = 0.9.18 Licence = GPL Description = Open source multiprotocol instant messaging application - May not work completely. Size = 3.0MB Category = 5 URLSite = http://www.miranda-im.org/ -URLDownload = http://miranda.googlecode.com/files/miranda-im-v0.9.17-unicode.exe +URLDownload = http://miranda.googlecode.com/files/miranda-im-v0.9.18-unicode.exe CDPath = none [Section.0407] diff --git a/reactos/base/applications/rapps/rapps/msxml3.txt b/reactos/base/applications/rapps/rapps/msxml3.txt index 788488af34c..d023aa69db9 100644 --- a/reactos/base/applications/rapps/rapps/msxml3.txt +++ b/reactos/base/applications/rapps/rapps/msxml3.txt @@ -4,11 +4,11 @@ Name = Microsoft XML 3 Version = 3.0 Licence = Unknown -Description = MSXML3 is needed for some MSI Installers. +Description = MSXML3 is needed for some MSI Installers. Contains: msxml3.dll, msxml3a.dll, msxml3r.dll. Size = 1.0MB Category = 14 URLSite = http://www.microsoft.com/downloads/details.aspx?FamilyID=28494391-052B-42FF-9674-F752BDCA9582&displaylang=en -URLDownload = http://download.microsoft.com/download/8/8/8/888f34b7-4f54-4f06-8dac-fa29b19f33dd/msxml3.msi +URLDownload = ftp://ftp.uni-rostock.de/pub/tools/microsoft/XML/US/msxml3.msi CDPath = none [Section.0407] diff --git a/reactos/base/applications/rapps/rapps/scite.txt b/reactos/base/applications/rapps/rapps/scite.txt index a323c6d24a1..b9e287e025a 100644 --- a/reactos/base/applications/rapps/rapps/scite.txt +++ b/reactos/base/applications/rapps/rapps/scite.txt @@ -2,13 +2,13 @@ [Section] Name = SciTE -Version = 2.24 +Version = 2.25 Licence = Freeware Description = SciTE is a SCIntilla based Text Editor. Originally built to demonstrate Scintilla, it has grown to be a generally useful editor with facilities for building and running programs. Size = 0.6M Category = 7 URLSite = http://www.scintilla.org/ -URLDownload = http://kent.dl.sourceforge.net/project/scintilla/SciTE/2.24/Sc224.exe +URLDownload = http://kent.dl.sourceforge.net/project/scintilla/SciTE/2.25/Sc225.exe CDPath = none [Section.0407] diff --git a/reactos/base/applications/rapps/rapps/seamonkey.txt b/reactos/base/applications/rapps/rapps/seamonkey.txt index 2564895cac8..48579604d39 100644 --- a/reactos/base/applications/rapps/rapps/seamonkey.txt +++ b/reactos/base/applications/rapps/rapps/seamonkey.txt @@ -2,36 +2,36 @@ [Section] Name = Mozilla SeaMonkey -Version = 2.0.12 +Version = 2.0.13 Licence = MPL/GPL/LGPL Description = Mozilla Suite is alive. This is the one and only Browser, Mail, Chat, and Composer bundle you will ever need. Size = 10.2MB Category = 5 URLSite = http://www.seamonkey-project.org/ -URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.12/win32/en-US/SeaMonkey%20Setup%202.0.12.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.13/win32/en-US/SeaMonkey%20Setup%202.0.13.exe CDPath = none [Section.0407] Description = Mozilla Suite lebt. Dies ist das einzige Browser-, Mail-, Chat- and Composerwerkzeug-Bundle welches Sie benötigen. Size = 10.1MB -URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.12/win32/de/SeaMonkey%20Setup%202.0.12.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.13/win32/de/SeaMonkey%20Setup%202.0.13.exe [Section.040a] Description = La suite de Mozilla está viva. Es el primero y único navegador web, gestor de correo, lector de noticias, Chat y editor HTML que necesitarás. Size = 10.1MB -URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.12/win32/es-ES/SeaMonkey%20Setup%202.0.12.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.13/win32/es-ES/SeaMonkey%20Setup%202.0.13.exe [Section.040c] Description = La suite Mozilla est en vie. Ceci est le seul et l'unique package navigateur, client mail, client chat et composer dont vous aurez besoin. Size = 10.1MB -URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.12/win32/fr/SeaMonkey%20Setup%202.0.12.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.13/win32/fr/SeaMonkey%20Setup%202.0.13.exe [Section.0415] Description = Pakiet Mozilla żyje. W zestawie: przeglądarka, klient poczty, IRC oraz Edytor HTML - wszystko, czego potrzebujesz. Size = 11.0MB -URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.12/win32/pl/SeaMonkey%20Setup%202.0.12.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.13/win32/pl/SeaMonkey%20Setup%202.0.13.exe [Section.0419] Description = Продолжение Mozilla Suite. Включает браузер, почтовый клиент, IRC-клиент и HTML-редактор. Size = 10.5MB -URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.12/win32/ru/SeaMonkey%20Setup%202.0.12.exe +URLDownload = http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/2.0.13/win32/ru/SeaMonkey%20Setup%202.0.13.exe diff --git a/reactos/base/applications/rapps/rapps/tahoma.txt b/reactos/base/applications/rapps/rapps/tahoma.txt index 68181fd4e0e..41addaf0e6a 100644 --- a/reactos/base/applications/rapps/rapps/tahoma.txt +++ b/reactos/base/applications/rapps/rapps/tahoma.txt @@ -4,7 +4,7 @@ Name = Microsoft Tahoma Font Version = 1.0 Licence = Unknown -Description = Tahoma Font pack needed by some apps (Steam). +Description = Tahoma Font pack needed by some apps (Steam). Contains: Tahoma.tff, Tahomabd.ttf. Size = 305kB Category = 14 URLSite = http://support.microsoft.com/ diff --git a/reactos/base/applications/rapps/rapps/vb5run.txt b/reactos/base/applications/rapps/rapps/vb5run.txt index 12fb70ef3e9..a2847618589 100644 --- a/reactos/base/applications/rapps/rapps/vb5run.txt +++ b/reactos/base/applications/rapps/rapps/vb5run.txt @@ -4,7 +4,7 @@ Name = Visual Basic 5 Runtime Version = 5.0 Licence = Unknown -Description = Visual Basic 5 Runtime. +Description = Visual Basic 5 Runtime. Contains: advpack.dll, asycfilt.dll, comcat.dll, msvbvm50.dll, oleaut32.dll, olepro32.dll. Size = 970kB Category = 14 URLSite = http://support.microsoft.com/kb/180071/ diff --git a/reactos/base/applications/rapps/rapps/vb6run.txt b/reactos/base/applications/rapps/rapps/vb6run.txt index 542b977c95d..a7f34a12ed6 100644 --- a/reactos/base/applications/rapps/rapps/vb6run.txt +++ b/reactos/base/applications/rapps/rapps/vb6run.txt @@ -4,7 +4,7 @@ Name = Visual Basic 6 Runtime Version = 6.0 Licence = Unknown -Description = Visual Basic 6 Runtime. +Description = Visual Basic 6 Runtime. Contains: advpack.dll, asycfilt.dll, comcat.dll, msvbvm60.dll, oleaut32.dll, olepro32.dll. Size = 1.0MB Category = 14 URLSite = http://support.microsoft.com/kb/192461/ diff --git a/reactos/base/applications/rapps/rapps/vc2005run.txt b/reactos/base/applications/rapps/rapps/vc2005run.txt deleted file mode 100644 index 50b68787d2c..00000000000 --- a/reactos/base/applications/rapps/rapps/vc2005run.txt +++ /dev/null @@ -1,32 +0,0 @@ -; UTF-8 - -[Section] -Name = Microsoft Visual C++ 2005 Redistributable Package -Version = 7.0 -Licence = Unknown -Description = Visual Studio 2005 Runtime. -Size = 2.6MB -Category = 14 -URLSite = http://www.microsoft.com/Downloads/details.aspx?displaylang=en&FamilyID=32bc1bee-a3f9-4c13-9c99-220b62a191ee -URLDownload = http://download.microsoft.com/download/6/B/B/6BB661D6-A8AE-4819-B79F-236472F6070C/vcredist_x86.exe -CDPath = none - -[Section.0407] -Licence = Unbekannt -Description = Visual Studio 2005 Laufzeitsystem. - -[Section.040a] -Licence = Desconocida -Description = Librerias Visual Studio 2005. - -[Section.040c] -Licence = Inconnue -Description = Bibliothèque Visual Studio 2005. - -[Section.0415] -Licence = Nieznana -Description = Biblioteki uruchomieniowe Visual Studio 2005. - -[Section.0422] -Licence = Невідома -Description = Бібліотеки Visual Studio 2005. diff --git a/reactos/base/applications/rapps/rapps/vc2005sp1run.txt b/reactos/base/applications/rapps/rapps/vc2005sp1run.txt index 40a8a5dee88..b8966eaebc1 100644 --- a/reactos/base/applications/rapps/rapps/vc2005sp1run.txt +++ b/reactos/base/applications/rapps/rapps/vc2005sp1run.txt @@ -4,7 +4,7 @@ Name = Microsoft Visual C++ 2005 SP1 Redistributable Package Version = 7.1 Licence = Unknown -Description = Visual Studio 2005 Runtime SP1. +Description = Visual Studio 2005 Runtime SP1. Contains: atl80.dll, mfc80.dll, mfcm80.dll, mfcm80u.dll, msdia80.dll, msvcm80.dll, msvcp80.dll, msvcr80.dll, vcomp.dll. Size = 2.6MB Category = 14 URLSite = http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647&displaylang=en diff --git a/reactos/base/applications/rapps/rapps/vc2008run.txt b/reactos/base/applications/rapps/rapps/vc2008run.txt deleted file mode 100644 index b6bf3443feb..00000000000 --- a/reactos/base/applications/rapps/rapps/vc2008run.txt +++ /dev/null @@ -1,32 +0,0 @@ -; UTF-8 - -[Section] -Name = Microsoft Visual C++ 2008 Redistributable Package -Version = 8.0 -Licence = Unknown -Description = Visual Studio 2008 Runtime. -Size = 4.3MB -Category = 14 -URLSite = http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en -URLDownload = http://download.microsoft.com/download/9/7/7/977B481A-7BA6-4E30-AC40-ED51EB2028F2/vcredist_x86.exe -CDPath = none - -[Section.0407] -Licence = Unbekannt -Description = Visual Studio 2008 Laufzeitsystem. - -[Section.040a] -Licence = Desconocida -Description = Librerias Visual Studio 2008. - -[Section.040c] -Licence = Inconnue -Description = Bibliothèque Visual Studio 2008. - -[Section.0415] -Licence = Nieznana -Description = Biblioteki uruchomieniowe Visual Studio 2008. - -[Section.0422] -Licence = Невідома -Description = Бібліотеки Visual Studio 2008. diff --git a/reactos/base/applications/rapps/rapps/vc2008sp1run.txt b/reactos/base/applications/rapps/rapps/vc2008sp1run.txt index 0f05a041bc6..2743f24c607 100644 --- a/reactos/base/applications/rapps/rapps/vc2008sp1run.txt +++ b/reactos/base/applications/rapps/rapps/vc2008sp1run.txt @@ -4,7 +4,7 @@ Name = Microsoft Visual C++ 2008 SP1 Redistributable Package Version = 8.0 Licence = Unknown -Description = Visual Studio 2008 SP1 Runtime. +Description = Visual Studio 2008 SP1 Runtime. Contains: atl90.dll, mfc90.dll, mfc90u.dll, mfcm90.dll, mfcm90u.dll, msdia90.dll, msvcm90.dll, msvcp90.dll, msvcr90.dll, vcomp90.dll. Size = 4.0MB Category = 14 URLSite = http://www.microsoft.com/downloads/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2&displaylang=en diff --git a/reactos/base/applications/rapps/rapps/vc6run.txt b/reactos/base/applications/rapps/rapps/vc6run.txt index 9ed5a088034..0f45b98a420 100644 --- a/reactos/base/applications/rapps/rapps/vc6run.txt +++ b/reactos/base/applications/rapps/rapps/vc6run.txt @@ -4,7 +4,7 @@ Name = Microsoft Visual C++ 6 Redistributable Package Version = 6.0 Licence = Unknown -Description = Visual Studio 6 Runtime. +Description = Visual Studio 6 Runtime. Contains: advpack.dll, asycfilt.dll, atla.dll, atlu.dll, comcat.dll, mfc42.dll, mfc42u.dll, msvcirt.dll, msvcp60.dll, msvcrt.dll, oleaut32.dll, olepro32.dll. Size = 1.7MB Category = 14 URLSite = http://support.microsoft.com/kb/259403/ diff --git a/reactos/base/applications/rapps/rapps/vlc.txt b/reactos/base/applications/rapps/rapps/vlc.txt index ae94d897561..0e35475c489 100644 --- a/reactos/base/applications/rapps/rapps/vlc.txt +++ b/reactos/base/applications/rapps/rapps/vlc.txt @@ -2,13 +2,13 @@ [Section] Name = VLC media player -Version = 1.1.7 +Version = 1.1.8 Licence = GPL Description = A media player. -Size = 19.4MB +Size = 19.6MB Category = 1 URLSite = http://www.videolan.org/vlc/ -URLDownload = http://kent.dl.sourceforge.net/project/vlc/1.1.7/win32/vlc-1.1.7-win32.exe +URLDownload = http://kent.dl.sourceforge.net/project/vlc/1.1.8/win32/vlc-1.1.8-win32.exe CDPath = none [Section.0407] From 8174c5cfde298e6e394e9f8053c41678746cd1cb Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Sun, 27 Mar 2011 21:51:41 +0000 Subject: [PATCH 09/66] [SYSSETUP] Set HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate to install date. Patch by Edijs Kolesnikovics slightly modified by me See issue #6044 for more details. svn path=/trunk/; revision=51176 --- reactos/dll/win32/syssetup/wizard.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/reactos/dll/win32/syssetup/wizard.c b/reactos/dll/win32/syssetup/wizard.c index 63d6bc2ed88..7c438ab5ecd 100644 --- a/reactos/dll/win32/syssetup/wizard.c +++ b/reactos/dll/win32/syssetup/wizard.c @@ -1916,11 +1916,30 @@ ProcessPageDlgProc(HWND hwndDlg, static VOID -SetupIsActive( DWORD dw ) +SetInstallationCompleted(VOID) { HKEY hKey = 0; - if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, L"SYSTEM\\Setup", 0, KEY_WRITE, &hKey ) == ERROR_SUCCESS) { - RegSetValueExW( hKey, L"SystemSetupInProgress", 0, REG_DWORD, (CONST BYTE *)&dw, sizeof(dw) ); + DWORD InProgress = 0; + DWORD InstallDate; + + if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, + L"SYSTEM\\Setup", + 0, + KEY_WRITE, + &hKey ) == ERROR_SUCCESS) + { + RegSetValueExW( hKey, L"SystemSetupInProgress", 0, REG_DWORD, (LPBYTE)&InProgress, sizeof(InProgress) ); + RegCloseKey( hKey ); + } + + if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, + L"Software\\Microsoft\\Windows NT\\CurrentVersion", + 0, + KEY_WRITE, + &hKey ) == ERROR_SUCCESS) + { + InstallDate = (DWORD)time(NULL); + RegSetValueExW( hKey, L"InstallDate", 0, REG_DWORD, (LPBYTE)&InstallDate, sizeof(InstallDate) ); RegCloseKey( hKey ); } } @@ -1951,7 +1970,7 @@ FinishDlgProc(HWND hwndDlg, if (SetupData->UnattendSetup) { KillTimer(hwndDlg, 1); - SetupIsActive(0); + SetInstallationCompleted(); PostQuitMessage(0); } } @@ -1959,7 +1978,7 @@ FinishDlgProc(HWND hwndDlg, case WM_DESTROY: { - SetupIsActive(0); + SetInstallationCompleted(); PostQuitMessage(0); return TRUE; } From 54cac2ef9ef3b04d672d2226d0c6a821d22290ef Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Sun, 27 Mar 2011 22:47:59 +0000 Subject: [PATCH 10/66] [PING] Fix crash if option, which needs number is on the end of command line Get rid of GetULONG and GetULONG2 functions. MS doesn't check input so precisely Command line options can be preceded by "/" See issue #6047 for more details. svn path=/trunk/; revision=51177 --- reactos/base/applications/network/ping/ping.c | 113 ++++++++---------- 1 file changed, 47 insertions(+), 66 deletions(-) diff --git a/reactos/base/applications/network/ping/ping.c b/reactos/base/applications/network/ping/ping.c index 6f7935e9159..c0bd93201a1 100644 --- a/reactos/base/applications/network/ping/ping.c +++ b/reactos/base/applications/network/ping/ping.c @@ -59,7 +59,6 @@ typedef struct _ICMP_ECHO_PACKET #pragma pack(1) -BOOL InvalidOption; BOOL NeverStop; BOOL ResolveAddresses; UINT PingCount; @@ -213,84 +212,71 @@ static VOID Reset(VOID) } } -/* Return ULONG in a string */ -static ULONG GetULONG(LPWSTR String) -{ - UINT i, Length; - ULONG Value; - LPWSTR StopString; - i = 0; - Length = (UINT)wcslen(String); - while ((i < Length) && ((String[i] < L'0') || (String[i] > L'9'))) i++; - if ((i >= Length) || ((String[i] < L'0') || (String[i] > L'9'))) - { - InvalidOption = TRUE; - return 0; - } - Value = wcstoul(&String[i], &StopString, 10); - - return Value; -} - -/* Return ULONG in a string. Try next paramter if not successful */ -static ULONG GetULONG2(LPWSTR String1, LPWSTR String2, PINT i) -{ - ULONG Value; - - Value = GetULONG(String1); - if (InvalidOption) - { - InvalidOption = FALSE; - if (String2[0] != L'-') - { - Value = GetULONG(String2); - if (!InvalidOption) - *i += 1; - } - } - - return Value; -} - /* Parse command line parameters */ static BOOL ParseCmdline(int argc, LPWSTR argv[]) { INT i; - BOOL ShowUsage; - BOOL FoundTarget; + BOOL FoundTarget = FALSE, InvalidOption = FALSE; + if (argc < 2) - ShowUsage = TRUE; - else - ShowUsage = FALSE; - FoundTarget = FALSE; - InvalidOption = FALSE; + { + Usage(); + return FALSE; + } for (i = 1; i < argc; i++) { - if (argv[i][0] == L'-') + if (argv[i][0] == L'-' || argv[i][0] == L'/') { switch (argv[i][1]) { case L't': NeverStop = TRUE; break; case L'a': ResolveAddresses = TRUE; break; - case L'n': PingCount = GetULONG2(&argv[i][2], argv[i + 1], &i); break; + case L'n': + if (i + 1 < argc) + PingCount = wcstoul(argv[++i], NULL, 0); + else + InvalidOption = TRUE; + break; case L'l': - DataSize = GetULONG2(&argv[i][2], argv[i + 1], &i); - if (DataSize > ICMP_MAXSIZE - sizeof(ICMP_ECHO_PACKET) - sizeof(IPv4_HEADER)) + if (i + 1 < argc) { - FormatOutput(IDS_BAD_VALUE_OPTION_L, ICMP_MAXSIZE - \ - (int)sizeof(ICMP_ECHO_PACKET) - \ - (int)sizeof(IPv4_HEADER)); - return FALSE; - } + DataSize = wcstoul(argv[++i], NULL, 0); + + if (DataSize > ICMP_MAXSIZE - sizeof(ICMP_ECHO_PACKET) - sizeof(IPv4_HEADER)) + { + FormatOutput(IDS_BAD_VALUE_OPTION_L, ICMP_MAXSIZE - \ + (int)sizeof(ICMP_ECHO_PACKET) - \ + (int)sizeof(IPv4_HEADER)); + return FALSE; + } + } else + InvalidOption = TRUE; break; case L'f': DontFragment = TRUE; break; - case L'i': TTLValue = GetULONG2(&argv[i][2], argv[i + 1], &i); break; - case L'v': TOSValue = GetULONG2(&argv[i][2], argv[i + 1], &i); break; - case L'w': Timeout = GetULONG2(&argv[i][2], argv[i + 1], &i); break; + case L'i': + if (i + 1 < argc) + TTLValue = wcstoul(argv[++i], NULL, 0); + else + InvalidOption = TRUE; + break; + case L'v': + if (i + 1 < argc) + TOSValue = wcstoul(argv[++i], NULL, 0); + else + InvalidOption = TRUE; + break; + case L'w': + if (i + 1 < argc) + Timeout = wcstoul(argv[++i], NULL, 0); + else + InvalidOption = TRUE; + break; + case '?': + Usage(); + return FALSE; default: FormatOutput(IDS_BAD_OPTION, argv[i]); - Usage(); return FALSE; } if (InvalidOption) @@ -314,17 +300,12 @@ static BOOL ParseCmdline(int argc, LPWSTR argv[]) } } - if ((!ShowUsage) && (!FoundTarget)) + if (!FoundTarget) { FormatOutput(IDS_DEST_MUST_BE_SPECIFIED); return FALSE; } - if (ShowUsage) - { - Usage(); - return FALSE; - } return TRUE; } From f21acd6f09d2793470d8e2a8230ea99d1d89e03b Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Sun, 27 Mar 2011 23:19:56 +0000 Subject: [PATCH 11/66] [USER32] Don't fail if FillRect is called without brush. Fixes user32:uitools winetest svn path=/trunk/; revision=51178 --- reactos/dll/win32/user32/windows/draw.c | 29 ++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/reactos/dll/win32/user32/windows/draw.c b/reactos/dll/win32/user32/windows/draw.c index dd50c75b1c3..1d353289c29 100644 --- a/reactos/dll/win32/user32/windows/draw.c +++ b/reactos/dll/win32/user32/windows/draw.c @@ -1565,19 +1565,28 @@ INT WINAPI FillRect(HDC hDC, CONST RECT *lprc, HBRUSH hbr) { HBRUSH prevhbr; + BOOL Ret; - if (hbr <= (HBRUSH)(COLOR_MENUBAR + 1)) + /* Select brush if specified */ + if (hbr) { - hbr = GetSysColorBrush(PtrToUlong(hbr) - 1); + /* Handle system colors */ + if (hbr <= (HBRUSH)(COLOR_MENUBAR + 1)) + hbr = GetSysColorBrush(PtrToUlong(hbr) - 1); + + prevhbr = SelectObject(hDC, hbr); + if (prevhbr == NULL) + return (INT)FALSE; } - if ((prevhbr = SelectObject(hDC, hbr)) == NULL) - { - return FALSE; - } - PatBlt(hDC, lprc->left, lprc->top, lprc->right - lprc->left, - lprc->bottom - lprc->top, PATCOPY); - SelectObject(hDC, prevhbr); - return TRUE; + + Ret = PatBlt(hDC, lprc->left, lprc->top, lprc->right - lprc->left, + lprc->bottom - lprc->top, PATCOPY); + + /* Select old brush */ + if (hbr) + SelectObject(hDC, prevhbr); + + return (INT)Ret; } /* From 4ef3dbc2255f7bd763c6fff4f2bb7b6e402763a6 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Mon, 28 Mar 2011 00:17:21 +0000 Subject: [PATCH 12/66] [GDI32|User32|Win32k] - Fix ScrollDC ApiTest. svn path=/trunk/; revision=51179 --- reactos/dll/win32/gdi32/misc/misc.c | 14 ++++++---- reactos/dll/win32/user32/windows/paint.c | 28 +++++++++---------- .../subsystems/win32/win32k/ntuser/painting.c | 5 ++-- .../subsystems/win32/win32k/objects/region.c | 21 +++++++++++--- 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/reactos/dll/win32/gdi32/misc/misc.c b/reactos/dll/win32/gdi32/misc/misc.c index 25ff84253de..dac9a73a8ff 100644 --- a/reactos/dll/win32/gdi32/misc/misc.c +++ b/reactos/dll/win32/gdi32/misc/misc.c @@ -275,7 +275,7 @@ HGDIOBJ FASTCALL hGetPEBHandle(HANDLECACHETYPE Type, COLORREF cr) { - int Number, Count, MaxNum, GdiType; + int Number, Offset, MaxNum, GdiType; HANDLE Lock; HGDIOBJ Handle = NULL; @@ -289,19 +289,19 @@ hGetPEBHandle(HANDLECACHETYPE Type, COLORREF cr) if (Type == hctBrushHandle) { - Count = 0; + Offset = 0; MaxNum = CACHE_BRUSH_ENTRIES; GdiType = GDILoObjType_LO_BRUSH_TYPE; } else if (Type == hctPenHandle) { - Count = CACHE_BRUSH_ENTRIES; + Offset = CACHE_BRUSH_ENTRIES; MaxNum = CACHE_PEN_ENTRIES; GdiType = GDILoObjType_LO_PEN_TYPE; } else if (Type == hctRegionHandle) { - Count = CACHE_BRUSH_ENTRIES+CACHE_PEN_ENTRIES; + Offset = CACHE_BRUSH_ENTRIES+CACHE_PEN_ENTRIES; MaxNum = CACHE_REGION_ENTRIES; GdiType = GDILoObjType_LO_REGION_TYPE; } @@ -314,7 +314,7 @@ hGetPEBHandle(HANDLECACHETYPE Type, COLORREF cr) { PBRUSH_ATTR pBrush_Attr; HGDIOBJ *hPtr; - hPtr = GdiHandleCache->Handle + Count; + hPtr = GdiHandleCache->Handle + Offset; Handle = hPtr[Number - 1]; if (GdiGetHandleUserData( Handle, GdiType, (PVOID) &pBrush_Attr)) @@ -335,6 +335,10 @@ hGetPEBHandle(HANDLECACHETYPE Type, COLORREF cr) } } } + else + { + Handle = NULL; + } } (void)InterlockedExchangePointer((PVOID*)&GdiHandleCache->ulLock, Lock); return Handle; diff --git a/reactos/dll/win32/user32/windows/paint.c b/reactos/dll/win32/user32/windows/paint.c index 433577eedf5..dff5f98afd3 100644 --- a/reactos/dll/win32/user32/windows/paint.c +++ b/reactos/dll/win32/user32/windows/paint.c @@ -107,19 +107,19 @@ GetUpdateRect( pWnd = ValidateHwnd(Wnd); if (!pWnd) return FALSE; -/* + if ( pWnd->hrgnUpdate || pWnd->state & (WNDS_SENDERASEBACKGROUND|WNDS_SENDNCPAINT|WNDS_UPDATEDIRTY|WNDS_PAINTNOTPROCESSED)) - {*/ + { return NtUserGetUpdateRect(Wnd, Rect, Erase); -/* } + } if (Rect) { // Did the Rgn update? No! Back set and shutup! Rect->left = Rect->right = Rect->top = Rect->bottom = 0; } return FALSE; // msdn: "If there is no update region, the return value is zero." -*/ + } @@ -144,14 +144,14 @@ GetUpdateRgn( pWnd = ValidateHwnd(hWnd); if (!pWnd) return ERROR; -/* + if ( pWnd->hrgnUpdate || pWnd->state & (WNDS_SENDERASEBACKGROUND|WNDS_SENDNCPAINT|WNDS_UPDATEDIRTY|WNDS_PAINTNOTPROCESSED)) - {*/ + { return NtUserGetUpdateRgn(hWnd, hRgn, bErase); -/* } + } SetRectRgn(hRgn, 0, 0, 0, 0); - return NULLREGION;*/ + return NULLREGION; } @@ -239,14 +239,14 @@ UpdateWindow( if (!pWnd) return FALSE; -/* + if ( pWnd->hrgnUpdate || pWnd->state & WNDS_INTERNALPAINT || pWnd->spwndChild ) - {*/ + { return NtUserCallHwndLock(hWnd, HWNDLOCK_ROUTINE_UPDATEWINDOW); -/* } - return TRUE;*/ + } + return TRUE; } /* @@ -286,7 +286,7 @@ GetWindowRgn( if (!Ret) return ERROR; - if (pWnd->fnid != FNID_DESKTOP) + if (hWnd != GetDesktopWindow()) // pWnd->fnid != FNID_DESKTOP) Ret = OffsetRgn(hRgn, -pWnd->rcWindow.left, -pWnd->rcWindow.top); if (pWnd->ExStyle & WS_EX_LAYOUTRTL) @@ -320,7 +320,7 @@ GetWindowRgnBox( if (!Ret) return ERROR; - if (pWnd->fnid != FNID_DESKTOP) + if (hWnd != GetDesktopWindow()) // pWnd->fnid != FNID_DESKTOP) OffsetRect(lprc, -pWnd->rcWindow.left, -pWnd->rcWindow.top); if (pWnd->ExStyle & WS_EX_LAYOUTRTL) diff --git a/reactos/subsystems/win32/win32k/ntuser/painting.c b/reactos/subsystems/win32/win32k/ntuser/painting.c index f2e3850437f..48919098be7 100644 --- a/reactos/subsystems/win32/win32k/ntuser/painting.c +++ b/reactos/subsystems/win32/win32k/ntuser/painting.c @@ -1248,6 +1248,7 @@ UserScrollDC( hrgnOwn = hrgnUpdate; if (!NtGdiSetRectRgn(hrgnOwn, rcDst.left, rcDst.top, rcDst.right, rcDst.bottom)) { + DC_UnlockDc(pDC); return ERROR; } } @@ -1265,8 +1266,8 @@ UserScrollDC( NtGdiOffsetRgn(hrgnTmp, dx, dy); Result = NtGdiCombineRgn(hrgnOwn, hrgnOwn, hrgnTmp, RGN_DIFF); - /* DO NOT Unlock DC while messing with prgnVis! */ - DC_UnlockDc(pDC); + /* DO NOT Unlock DC while messing with prgnVis! */ + DC_UnlockDc(pDC); REGION_FreeRgnByHandle(hrgnTmp); diff --git a/reactos/subsystems/win32/win32k/objects/region.c b/reactos/subsystems/win32/win32k/objects/region.c index d0bd3bafc61..38ad6ae7232 100644 --- a/reactos/subsystems/win32/win32k/objects/region.c +++ b/reactos/subsystems/win32/win32k/objects/region.c @@ -2080,6 +2080,7 @@ REGION_AllocUserRgnWithHandle(INT nRgn) { Entry = GDI_HANDLE_GET_ENTRY(GdiHandleTable, pRgn->BaseObject.hHmgr); Entry->UserData = AllocateObjectAttr(); + RtlZeroMemory(Entry->UserData, sizeof(RGN_ATTR)); } return pRgn; } @@ -2090,6 +2091,7 @@ RGNOBJAPI_Lock(HRGN hRgn, PRGN_ATTR *ppRgn_Attr) { PGDI_TABLE_ENTRY Entry; PRGN_ATTR pRgn_Attr; + BOOL Hit = FALSE; PROSRGNDATA pRgn = NULL; pRgn = REGION_LockRgn(hRgn); @@ -2103,11 +2105,12 @@ RGNOBJAPI_Lock(HRGN hRgn, PRGN_ATTR *ppRgn_Attr) { _SEH2_TRY { - if ( !(pRgn_Attr->AttrFlags & ATTR_CACHED) && - pRgn_Attr->AttrFlags & (ATTR_RGN_VALID|ATTR_RGN_DIRTY) ) + if ( !(pRgn_Attr->AttrFlags & ATTR_CACHED) ) { - switch (pRgn_Attr->Flags) + if ( pRgn_Attr->AttrFlags & (ATTR_RGN_VALID|ATTR_RGN_DIRTY) ) { + switch (pRgn_Attr->Flags) + { case NULLREGION: EMPTY_REGION( pRgn ); break; @@ -2119,8 +2122,13 @@ RGNOBJAPI_Lock(HRGN hRgn, PRGN_ATTR *ppRgn_Attr) pRgn_Attr->Rect.right, pRgn_Attr->Rect.bottom ); break; + } + pRgn_Attr->AttrFlags &= ~ATTR_RGN_DIRTY; } - pRgn_Attr->AttrFlags &= ~ATTR_RGN_DIRTY; + } + else + { // This object is cached an waiting for it's resurrection by the users. + Hit = TRUE; } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) @@ -2128,6 +2136,11 @@ RGNOBJAPI_Lock(HRGN hRgn, PRGN_ATTR *ppRgn_Attr) } _SEH2_END; + if (Hit) + { + REGION_UnlockRgn(pRgn); + return NULL; + } if (ppRgn_Attr) *ppRgn_Attr = pRgn_Attr; } From c5dad4998c9db06200fe3b57995f832b486ea67c Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Mon, 28 Mar 2011 20:52:27 +0000 Subject: [PATCH 13/66] [USER32] Fix a bug causing "Attempted to lock object, wrong reuse counter" messages when CMD was started in LiveCD. Once got desktop HDC was used in different threads. When thread, which created handle terminated, DC handle was removed and next calls to CreateIcon* API was using invalid hDC. svn path=/trunk/; revision=51184 --- reactos/dll/win32/user32/windows/cursoricon.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/reactos/dll/win32/user32/windows/cursoricon.c b/reactos/dll/win32/user32/windows/cursoricon.c index 32b0ffde97a..e3c5ca13b29 100644 --- a/reactos/dll/win32/user32/windows/cursoricon.c +++ b/reactos/dll/win32/user32/windows/cursoricon.c @@ -458,16 +458,10 @@ static BOOL create_icon_bitmaps( const BITMAPINFO *bmi, int width, int height, void *color_bits, *mask_bits; BOOL ret = FALSE; HDC hdc = 0; - static HDC hScreenDC = 0; if (!(info = HeapAlloc( GetProcessHeap(), 0, max( size, FIELD_OFFSET( BITMAPINFO, bmiColors[2] ))))) return FALSE; - if(!hScreenDC) - { - hScreenDC = GetDC(0); - if(!hScreenDC) goto done; - } - if (!(hdc = CreateCompatibleDC(hScreenDC))) goto done; + if (!(hdc = CreateCompatibleDC(NULL))) goto done; memcpy( info, bmi, size ); info->bmiHeader.biHeight /= 2; @@ -491,8 +485,8 @@ static BOOL create_icon_bitmaps( const BITMAPINFO *bmi, int width, int height, else { if (!(*mask = CreateBitmap( width, height, 1, 1, NULL ))) goto done; - if (!(*color = CreateBitmap( width, height, GetDeviceCaps(hScreenDC, PLANES), - GetDeviceCaps(hScreenDC, BITSPIXEL), NULL ))) + if (!(*color = CreateBitmap( width, height, GetDeviceCaps(hdc, PLANES), + GetDeviceCaps(hdc, BITSPIXEL), NULL ))) { DeleteObject( *mask ); goto done; From 9e22fe596258da312518fc2af47837bf6d4fd3ff Mon Sep 17 00:00:00 2001 From: James Tabor Date: Tue, 29 Mar 2011 02:57:48 +0000 Subject: [PATCH 14/66] [Win32k] - Finish object attribute support part 2. - Removed DC from the list, ReactOS handles this in a different way. Comment out Brush and Pen switches until proper handling is implemented. svn path=/trunk/; revision=51185 --- .../subsystems/win32/win32k/objects/gdiobj.c | 45 +++++++++++++------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/reactos/subsystems/win32/win32k/objects/gdiobj.c b/reactos/subsystems/win32/win32k/objects/gdiobj.c index 6bbca8cddd4..45756ae81bf 100644 --- a/reactos/subsystems/win32/win32k/objects/gdiobj.c +++ b/reactos/subsystems/win32/win32k/objects/gdiobj.c @@ -741,16 +741,22 @@ IsObjectDead(HGDIOBJ hObject) } } - +/* + * Process Environment Cached GDI Handles + * + * What types of GDI handle objects that are cached in the GDI handle buffer? + * Brushes set to BS_SOLID, Pens with widths of zero or set to PS_SOLID, and + * Regions that are set to NULLREGION or SIMPLEREGION. + */ BOOL FASTCALL bPEBCacheHandle(HGDIOBJ Handle, int oType, PVOID pAttr) { PGDIHANDLECACHE GdiHandleCache; HGDIOBJ *hPtr; - BOOL Ret = FALSE; - int Offset = 0, Number; HANDLE Lock; + int Number, Offset, MaxNum = CACHE_PEN_ENTRIES; + BOOL Ret = FALSE; GdiHandleCache = (PGDIHANDLECACHE)NtCurrentTeb()->ProcessEnvironmentBlock->GdiHandleBuffer; @@ -758,6 +764,7 @@ bPEBCacheHandle(HGDIOBJ Handle, int oType, PVOID pAttr) { case hctBrushHandle: Offset = 0; + MaxNum = CACHE_BRUSH_ENTRIES; break; case hctPenHandle: @@ -783,10 +790,10 @@ bPEBCacheHandle(HGDIOBJ Handle, int oType, PVOID pAttr) hPtr = GdiHandleCache->Handle + Offset; - if ( pAttr && oType == hctRegionHandle) + if ( pAttr ) { - if ( Number < CACHE_REGION_ENTRIES ) - { + if ( Number < MaxNum ) + { // This object is cached and waiting for it's resurrection by the users. ((PRGN_ATTR)pAttr)->AttrFlags |= ATTR_CACHED; hPtr[Number] = Handle; GdiHandleCache->ulNumHandles[oType]++; @@ -817,6 +824,7 @@ GreDeleteObject(HGDIOBJ hObject) INT Index; PGDI_TABLE_ENTRY Entry; DWORD dwObjectType; + INT ihct; PVOID pAttr = NULL; DPRINT("NtGdiDeleteObject handle 0x%08x\n", hObject); @@ -831,14 +839,27 @@ GreDeleteObject(HGDIOBJ hObject) switch (dwObjectType) { case GDI_OBJECT_TYPE_BRUSH: + ihct = hctBrushHandle; + break; + + case GDI_OBJECT_TYPE_PEN: + ihct = hctPenHandle; break; case GDI_OBJECT_TYPE_REGION: - /* If pAttr NULL, the probability is high for System Region. */ + ihct = hctRegionHandle; + break; + } + + switch (dwObjectType) + { +// case GDI_OBJECT_TYPE_BRUSH: +// case GDI_OBJECT_TYPE_PEN: + case GDI_OBJECT_TYPE_REGION: + /* If pAttr NULL, the probability is high for System GDI handle object. */ if ( pAttr && - bPEBCacheHandle(hObject, hctRegionHandle, pAttr)) - { - /* User space handle only! */ + bPEBCacheHandle(hObject, ihct, pAttr) ) + { /* User space handle only! */ return TRUE; } if (pAttr) @@ -847,10 +868,6 @@ GreDeleteObject(HGDIOBJ hObject) Entry->UserData = NULL; } break; - - case GDI_OBJECT_TYPE_DC: -// DC_FreeDcAttr(hObject); - break; } return NULL != hObject From 827e75cb8914ac0931e3ed6986d37dd8541e338c Mon Sep 17 00:00:00 2001 From: James Tabor Date: Tue, 29 Mar 2011 05:11:02 +0000 Subject: [PATCH 15/66] [User32] - Fix select old brush in FillRect. svn path=/trunk/; revision=51186 --- reactos/dll/win32/user32/windows/draw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/user32/windows/draw.c b/reactos/dll/win32/user32/windows/draw.c index 1d353289c29..5ecf9a53462 100644 --- a/reactos/dll/win32/user32/windows/draw.c +++ b/reactos/dll/win32/user32/windows/draw.c @@ -1564,8 +1564,8 @@ FlashWindow(HWND hWnd, BOOL bInvert) INT WINAPI FillRect(HDC hDC, CONST RECT *lprc, HBRUSH hbr) { - HBRUSH prevhbr; BOOL Ret; + HBRUSH prevhbr = NULL; /* Select brush if specified */ if (hbr) @@ -1583,7 +1583,7 @@ FillRect(HDC hDC, CONST RECT *lprc, HBRUSH hbr) lprc->bottom - lprc->top, PATCOPY); /* Select old brush */ - if (hbr) + if (prevhbr) SelectObject(hDC, prevhbr); return (INT)Ret; From 0bf0c70444b6477e4347e257b5683898dc249352 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Tue, 29 Mar 2011 05:53:34 +0000 Subject: [PATCH 16/66] [User32|Win32k] - Properly implement RealGetWindowClass, fixes the ApiTest. Keeping the Ansi support for now, will use it as a reference. svn path=/trunk/; revision=51187 --- reactos/dll/win32/user32/windows/class.c | 39 +++++++++++-------- reactos/include/reactos/win32k/ntuser.h | 7 ---- .../subsystems/win32/win32k/ntuser/class.c | 23 ++++++++--- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/reactos/dll/win32/user32/windows/class.c b/reactos/dll/win32/user32/windows/class.c index df665d1ce2d..6770b6d6d0b 100644 --- a/reactos/dll/win32/user32/windows/class.c +++ b/reactos/dll/win32/user32/windows/class.c @@ -696,22 +696,20 @@ GetClassNameA( LPSTR lpClassName, int nMaxCount) { - ANSI_STRING ClassName; - int Result; - - ClassName.MaximumLength = nMaxCount; - ClassName.Buffer = lpClassName; - - Result = NtUserGetClassName(hWnd, - (PUNICODE_STRING)&ClassName, - TRUE); + WCHAR tmpbuf[MAX_ATOM_LEN + 1]; + int len; + + if (nMaxCount <= 0) return 0; + if (!GetClassNameW( hWnd, tmpbuf, sizeof(tmpbuf)/sizeof(WCHAR) )) return 0; + RtlUnicodeToMultiByteN( lpClassName, nMaxCount - 1, (PULONG)&len, tmpbuf, strlenW(tmpbuf) * sizeof(WCHAR) ); + lpClassName[len] = 0; TRACE("%p class/atom: %s/%04x %x\n", hWnd, IS_ATOM(lpClassName) ? NULL : lpClassName, IS_ATOM(lpClassName) ? lpClassName : 0, nMaxCount); - return Result; + return len; } @@ -732,8 +730,8 @@ GetClassNameW( ClassName.Buffer = lpClassName; Result = NtUserGetClassName(hWnd, - &ClassName, - FALSE); + FALSE, + &ClassName); TRACE("%p class/atom: %S/%04x %x\n", hWnd, IS_ATOM(lpClassName) ? NULL : lpClassName, @@ -914,8 +912,11 @@ RealGetWindowClassW( LPWSTR pszType, UINT cchType) { - /* FIXME: Implement correct functionality of RealGetWindowClass */ - return GetClassNameW(hwnd,pszType,cchType); + UNICODE_STRING ClassName; + ClassName.MaximumLength = cchType * sizeof(WCHAR); + ClassName.Buffer = (PWSTR)pszType; + + return NtUserGetClassName(hwnd,TRUE,&ClassName); } @@ -929,8 +930,14 @@ RealGetWindowClassA( LPSTR pszType, UINT cchType) { - /* FIXME: Implement correct functionality of RealGetWindowClass */ - return GetClassNameA(hwnd,pszType,cchType); + WCHAR tmpbuf[MAX_ATOM_LEN + 1]; + UINT len; + + if (cchType <= 0) return 0; + if (!RealGetWindowClassW( hwnd, tmpbuf, sizeof(tmpbuf)/sizeof(WCHAR) )) return 0; + RtlUnicodeToMultiByteN( pszType, cchType - 1, (PULONG)&len, tmpbuf, strlenW(tmpbuf) * sizeof(WCHAR) ); + pszType[len] = 0; + return len; } /* diff --git a/reactos/include/reactos/win32k/ntuser.h b/reactos/include/reactos/win32k/ntuser.h index 484a3a4b84c..b6e2d8339ef 100644 --- a/reactos/include/reactos/win32k/ntuser.h +++ b/reactos/include/reactos/win32k/ntuser.h @@ -1761,18 +1761,11 @@ NtUserGetClassInfo(HINSTANCE hInstance, LPWSTR *ppszMenuName, BOOL Ansi); -INT -NTAPI -NtUserGetClassName(HWND hWnd, - PUNICODE_STRING ClassName, - BOOL Ansi); -#if 0 // Real NtUserGetClassName INT NTAPI NtUserGetClassName(HWND hWnd, BOOL Real, // 0 GetClassNameW, 1 RealGetWindowClassA/W PUNICODE_STRING ClassName); -#endif HANDLE NTAPI diff --git a/reactos/subsystems/win32/win32k/ntuser/class.c b/reactos/subsystems/win32/win32k/ntuser/class.c index 81e0076be26..74595eccaa3 100644 --- a/reactos/subsystems/win32/win32k/ntuser/class.c +++ b/reactos/subsystems/win32/win32k/ntuser/class.c @@ -1398,6 +1398,7 @@ UserUnregisterClass(IN PUNICODE_STRING ClassName, INT UserGetClassName(IN PCLS Class, IN OUT PUNICODE_STRING ClassName, + IN RTL_ATOM Atom, IN BOOL Ansi) { NTSTATUS Status = STATUS_SUCCESS; @@ -1451,7 +1452,7 @@ UserGetClassName(IN PCLS Class, /* query the class name */ Status = RtlQueryAtomInAtomTable(gAtomTable, - Class->atomClassName, + Atom ? Atom : Class->atomClassName, NULL, NULL, szTemp, @@ -1485,7 +1486,7 @@ UserGetClassName(IN PCLS Class, /* query the atom name */ Status = RtlQueryAtomInAtomTable(gAtomTable, - Class->atomClassName, + Atom ? Atom : Class->atomClassName, NULL, NULL, ClassName->Buffer, @@ -2376,18 +2377,27 @@ NtUserGetClassInfo( INT APIENTRY NtUserGetClassName (IN HWND hWnd, - OUT PUNICODE_STRING ClassName, - IN BOOL Ansi) + IN BOOL Real, + OUT PUNICODE_STRING ClassName) { PWND Window; UNICODE_STRING CapturedClassName; - INT Ret = 0; + INT iCls, Ret = 0; + RTL_ATOM Atom = 0; UserEnterShared(); Window = UserGetWindowObject(hWnd); if (Window != NULL) { + if (Real && Window->fnid && !(Window->fnid & FNID_DESTROY)) + { + if (LookupFnIdToiCls(Window->fnid, &iCls)) + { + Atom = gpsi->atomSysClass[iCls]; + } + } + _SEH2_TRY { ProbeForWriteUnicodeString(ClassName); @@ -2396,7 +2406,8 @@ NtUserGetClassName (IN HWND hWnd, /* get the class name */ Ret = UserGetClassName(Window->pcls, &CapturedClassName, - Ansi); + Atom, + FALSE); if (Ret != 0) { From 216026918d1bf2b8f533cfbea88cbad8a27af189 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 29 Mar 2011 09:52:39 +0000 Subject: [PATCH 17/66] [WIN32K] Fix parameter check and buffer probing in NtUserSetSysColors svn path=/trunk/; revision=51188 --- .../subsystems/win32/win32k/ntuser/ntstubs.c | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c index 7cdc720cd0a..1ec7f71ca97 100644 --- a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c +++ b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c @@ -539,37 +539,34 @@ NtUserSetSysColors( FLONG Flags) { DWORD Ret = TRUE; - NTSTATUS Status = STATUS_SUCCESS; if (cElements == 0) return TRUE; + if ((ULONG)cElements >= 0x40000000) + return FALSE; + UserEnterExclusive(); + _SEH2_TRY { - ProbeForRead(lpaElements, - sizeof(INT), - 1); - ProbeForRead(lpaRgbValues, - sizeof(COLORREF), - 1); -// Developers: We are thread locked and calling gdi. + ProbeForRead(lpaElements, cElements * sizeof(INT), 1); + ProbeForRead(lpaRgbValues, cElements * sizeof(COLORREF), 1); + IntSetSysColors(cElements, lpaElements, lpaRgbValues); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - Status = _SEH2_GetExceptionCode(); - } - _SEH2_END; - if (!NT_SUCCESS(Status)) - { - SetLastNtError(Status); + SetLastNtError(_SEH2_GetExceptionCode()); Ret = FALSE; } + _SEH2_END; + if (Ret) { UserSendNotifyMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0); } + UserLeave(); return Ret; } From 854e23cc3e137bc8fdfcdc342851125843dce118 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 29 Mar 2011 10:02:38 +0000 Subject: [PATCH 18/66] [WIN32K] Make GdiTableSection a static variable and use it only from gdiobj.c svn path=/trunk/; revision=51189 --- reactos/subsystems/win32/win32k/include/gdiobj.h | 5 ++--- reactos/subsystems/win32/win32k/main/dllmain.c | 6 +++--- reactos/subsystems/win32/win32k/objects/gdiobj.c | 8 ++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/reactos/subsystems/win32/win32k/include/gdiobj.h b/reactos/subsystems/win32/win32k/include/gdiobj.h index e29077c2f42..032acc2c523 100644 --- a/reactos/subsystems/win32/win32k/include/gdiobj.h +++ b/reactos/subsystems/win32/win32k/include/gdiobj.h @@ -47,6 +47,7 @@ typedef struct _BASEOBJECT USHORT cExclusiveLock; USHORT BaseFlags; PTHREADINFO Tid; + EX_PUSH_LOCK pushlock; } BASEOBJECT, *POBJ; typedef struct _CLIENTOBJ @@ -62,8 +63,6 @@ enum BASEFLAGS BASEFLAG_READY_TO_DIE = 0x1000 }; -extern PSECTION_OBJECT GdiTableSection; - BOOL INTERNAL_CALL GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle); BOOL INTERNAL_CALL GDIOBJ_SetOwnership(HGDIOBJ ObjectHandle, PEPROCESS Owner); BOOL INTERNAL_CALL GDIOBJ_CopyOwnership(HGDIOBJ CopyFrom, HGDIOBJ CopyTo); @@ -78,7 +77,7 @@ PGDIOBJ INTERNAL_CALL GDIOBJ_LockObj (HGDIOBJ hObj, DWORD ObjectType); PGDIOBJ INTERNAL_CALL GDIOBJ_ShareLockObj (HGDIOBJ hObj, DWORD ObjectType); VOID INTERNAL_CALL GDIOBJ_LockMultipleObjs(ULONG ulCount, IN HGDIOBJ* ahObj, OUT PGDIOBJ* apObj); -PVOID INTERNAL_CALL GDI_MapHandleTable(PSECTION_OBJECT SectionObject, PEPROCESS Process); +PVOID INTERNAL_CALL GDI_MapHandleTable(PEPROCESS Process); INIT_FUNCTION NTSTATUS diff --git a/reactos/subsystems/win32/win32k/main/dllmain.c b/reactos/subsystems/win32/win32k/main/dllmain.c index 1bff6e3f3b9..ce9f9b585b7 100644 --- a/reactos/subsystems/win32/win32k/main/dllmain.c +++ b/reactos/subsystems/win32/win32k/main/dllmain.c @@ -107,7 +107,7 @@ Win32kProcessCallback(struct _EPROCESS *Process, if(Process->Peb != NULL) { /* map the gdi handle table to user land */ - Process->Peb->GdiSharedHandleTable = GDI_MapHandleTable(GdiTableSection, Process); + Process->Peb->GdiSharedHandleTable = GDI_MapHandleTable(Process); Process->Peb->GdiDCAttributeList = GDI_BATCH_LIMIT; } @@ -264,7 +264,7 @@ Win32kThreadCallback(struct _ETHREAD *Thread, if (Win32Thread->KeyboardLayout) pci->hKL = Win32Thread->KeyboardLayout->hkl; pci->dwTIFlags = Win32Thread->TIF_flags; /* CI may not have been initialized. */ - if (!pci->pDeskInfo && Win32Thread->pDeskInfo) + if (!pci->pDeskInfo && Win32Thread->pDeskInfo) { if (!pci->ulClientDelta) pci->ulClientDelta = DesktopHeapGetUserDelta(); @@ -440,7 +440,7 @@ DriverEntry( /* Register our per-process and per-thread structures. */ PsEstablishWin32Callouts((PWIN32_CALLOUTS_FPNS)&CalloutData); -#if 0 // DBG +#if 1 // DBG /* Register service hook callbacks */ KdSystemDebugControl('CsoR', DbgPreServiceHook, ID_Win32PreServiceHook, 0, 0, 0, 0); KdSystemDebugControl('CsoR', DbgPostServiceHook, ID_Win32PostServiceHook, 0, 0, 0, 0); diff --git a/reactos/subsystems/win32/win32k/objects/gdiobj.c b/reactos/subsystems/win32/win32k/objects/gdiobj.c index 45756ae81bf..55f8a1d9b42 100644 --- a/reactos/subsystems/win32/win32k/objects/gdiobj.c +++ b/reactos/subsystems/win32/win32k/objects/gdiobj.c @@ -70,7 +70,7 @@ OBJ_TYPE_INFO ObjTypeInfo[BASE_OBJTYPE_COUNT] = static LARGE_INTEGER ShortDelay; PGDI_HANDLE_TABLE GdiHandleTable = NULL; -PSECTION_OBJECT GdiTableSection = NULL; +static PSECTION_OBJECT GdiTableSection = NULL; /** INTERNAL FUNCTIONS ********************************************************/ @@ -1663,7 +1663,7 @@ LockHandleFrom: } PVOID INTERNAL_CALL -GDI_MapHandleTable(PSECTION_OBJECT SectionObject, PEPROCESS Process) +GDI_MapHandleTable(PEPROCESS Process) { PVOID MappedView = NULL; NTSTATUS Status; @@ -1672,10 +1672,10 @@ GDI_MapHandleTable(PSECTION_OBJECT SectionObject, PEPROCESS Process) Offset.QuadPart = 0; - ASSERT(SectionObject != NULL); + ASSERT(GdiTableSection != NULL); ASSERT(Process != NULL); - Status = MmMapViewOfSection(SectionObject, + Status = MmMapViewOfSection(GdiTableSection, Process, &MappedView, 0, From e78589d99a0d697c1f72c88cdc22ab3cc34d7ccf Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 29 Mar 2011 10:07:11 +0000 Subject: [PATCH 19/66] [WIN32K] Disable system service hooks, that got accidentally enabled. svn path=/trunk/; revision=51190 --- reactos/subsystems/win32/win32k/main/dllmain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/subsystems/win32/win32k/main/dllmain.c b/reactos/subsystems/win32/win32k/main/dllmain.c index ce9f9b585b7..59853171885 100644 --- a/reactos/subsystems/win32/win32k/main/dllmain.c +++ b/reactos/subsystems/win32/win32k/main/dllmain.c @@ -440,7 +440,7 @@ DriverEntry( /* Register our per-process and per-thread structures. */ PsEstablishWin32Callouts((PWIN32_CALLOUTS_FPNS)&CalloutData); -#if 1 // DBG +#if 0 // DBG /* Register service hook callbacks */ KdSystemDebugControl('CsoR', DbgPreServiceHook, ID_Win32PreServiceHook, 0, 0, 0, 0); KdSystemDebugControl('CsoR', DbgPostServiceHook, ID_Win32PostServiceHook, 0, 0, 0, 0); From d7e597d60ec06d1495e0c3e93bd708be27a0f23f Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 29 Mar 2011 10:25:10 +0000 Subject: [PATCH 20/66] [WIN32K] - Move IntGdiSetBrushOwner to brush.c - Move IntGdiSetDCOwnerEx to dclife.c - Move IntGdiSetRegionOwner to region.c svn path=/trunk/; revision=51191 --- .../subsystems/win32/win32k/objects/brush.c | 49 +++++++ .../subsystems/win32/win32k/objects/dclife.c | 44 ++++++- .../subsystems/win32/win32k/objects/gdiobj.c | 120 ------------------ .../subsystems/win32/win32k/objects/region.c | 28 ++++ 4 files changed, 120 insertions(+), 121 deletions(-) diff --git a/reactos/subsystems/win32/win32k/objects/brush.c b/reactos/subsystems/win32/win32k/objects/brush.c index 5ad5f0764bf..f9d773e2e38 100644 --- a/reactos/subsystems/win32/win32k/objects/brush.c +++ b/reactos/subsystems/win32/win32k/objects/brush.c @@ -573,4 +573,53 @@ NtGdiSetBrushOrg(HDC hDC, INT XOrg, INT YOrg, LPPOINT Point) return TRUE; } +BOOL +FASTCALL +IntGdiSetBrushOwner(PBRUSH pbr, DWORD OwnerMask) +{ + HBRUSH hBR; + PEPROCESS Owner = NULL; + PGDI_TABLE_ENTRY pEntry = NULL; + + if (!pbr) return FALSE; + + hBR = pbr->BaseObject.hHmgr; + + if (!hBR || (GDI_HANDLE_GET_TYPE(hBR) != GDI_OBJECT_TYPE_BRUSH)) + return FALSE; + else + { + INT Index = GDI_HANDLE_GET_INDEX((HGDIOBJ)hBR); + pEntry = &GdiHandleTable->Entries[Index]; + } + + if (pbr->flAttrs & GDIBRUSH_IS_GLOBAL) + { + GDIOBJ_ShareUnlockObjByPtr((POBJ)pbr); + return TRUE; + } + + if ((OwnerMask == GDI_OBJ_HMGR_PUBLIC) || OwnerMask == GDI_OBJ_HMGR_NONE) + { + // Set this Brush to inaccessible mode and to an Owner of NONE. +// if (OwnerMask == GDI_OBJ_HMGR_NONE) Owner = OwnerMask; + + if (!GDIOBJ_SetOwnership((HGDIOBJ) hBR, Owner)) + return FALSE; + + // Deny user access to User Data. + pEntry->UserData = NULL; // This hBR is inaccessible! + } + + if (OwnerMask == GDI_OBJ_HMGR_POWNED) + { + if (!GDIOBJ_SetOwnership((HGDIOBJ) hBR, PsGetCurrentProcess() )) + return FALSE; + + // Allow user access to User Data. + pEntry->UserData = pbr->pBrushAttr; + } + return TRUE; +} + /* EOF */ diff --git a/reactos/subsystems/win32/win32k/objects/dclife.c b/reactos/subsystems/win32/win32k/objects/dclife.c index 7d6d330e708..b83c6f039fd 100644 --- a/reactos/subsystems/win32/win32k/objects/dclife.c +++ b/reactos/subsystems/win32/win32k/objects/dclife.c @@ -836,7 +836,7 @@ IntGdiDeleteDC(HDC hDC, BOOL Force) { DPRINT1("Attempted to Delete 0x%x currently being destroyed!!!\n", hDC); } - + return TRUE; } @@ -973,3 +973,45 @@ IntGdiCreateDisplayDC(HDEV hDev, ULONG DcType, BOOL EmptyDC) return hDC; } +BOOL +FASTCALL +IntGdiSetDCOwnerEx( HDC hDC, DWORD OwnerMask, BOOL NoSetBrush) +{ + PDC pDC; + BOOL Ret = FALSE; + + if (!hDC || (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC)) return FALSE; + + if ((OwnerMask == GDI_OBJ_HMGR_PUBLIC) || OwnerMask == GDI_OBJ_HMGR_NONE) + { + pDC = DC_LockDc ( hDC ); + MmCopyFromCaller(&pDC->dcattr, pDC->pdcattr, sizeof(DC_ATTR)); + DC_vFreeDcAttr(pDC); + DC_UnlockDc( pDC ); + + if (!DC_SetOwnership( hDC, NULL )) // This hDC is inaccessible! + return Ret; + } + + if (OwnerMask == GDI_OBJ_HMGR_POWNED) + { + pDC = DC_LockDc ( hDC ); + ASSERT(pDC->pdcattr == &pDC->dcattr); + DC_UnlockDc( pDC ); + + if (!DC_SetOwnership( hDC, PsGetCurrentProcess() )) return Ret; + + DC_AllocateDcAttr( hDC ); // Allocate new dcattr + + DCU_SynchDcAttrtoUser( hDC ); // Copy data from dc to dcattr + } + + if ((OwnerMask != GDI_OBJ_HMGR_NONE) && !NoSetBrush) + { + pDC = DC_LockDc ( hDC ); + if (IntGdiSetBrushOwner((PBRUSH)pDC->dclevel.pbrFill, OwnerMask)) + IntGdiSetBrushOwner((PBRUSH)pDC->dclevel.pbrLine, OwnerMask); + DC_UnlockDc( pDC ); + } + return TRUE; +} diff --git a/reactos/subsystems/win32/win32k/objects/gdiobj.c b/reactos/subsystems/win32/win32k/objects/gdiobj.c index 55f8a1d9b42..6c6be35895c 100644 --- a/reactos/subsystems/win32/win32k/objects/gdiobj.c +++ b/reactos/subsystems/win32/win32k/objects/gdiobj.c @@ -1726,126 +1726,6 @@ GDIOBJ_LockMultipleObjs(ULONG ulCount, /** PUBLIC FUNCTIONS **********************************************************/ -BOOL -FASTCALL -IntGdiSetRegionOwner(HRGN hRgn, DWORD OwnerMask) -{ - INT Index; - PGDI_TABLE_ENTRY Entry; -/* - System Regions: - These regions do not use attribute sections and when allocated, use gdiobj - level functions. - */ - // FIXME! HAX!!! Remove this once we get everything right! - Index = GDI_HANDLE_GET_INDEX(hRgn); - Entry = &GdiHandleTable->Entries[Index]; - if (Entry->UserData) FreeObjectAttr(Entry->UserData); - Entry->UserData = NULL; - // - if ((OwnerMask == GDI_OBJ_HMGR_PUBLIC) || OwnerMask == GDI_OBJ_HMGR_NONE) - { - return GDIOBJ_SetOwnership(hRgn, NULL); - } - if (OwnerMask == GDI_OBJ_HMGR_POWNED) - { - return GDIOBJ_SetOwnership((HGDIOBJ) hRgn, PsGetCurrentProcess() ); - } - return FALSE; -} - -BOOL -FASTCALL -IntGdiSetBrushOwner(PBRUSH pbr, DWORD OwnerMask) -{ - HBRUSH hBR; - PEPROCESS Owner = NULL; - PGDI_TABLE_ENTRY pEntry = NULL; - - if (!pbr) return FALSE; - - hBR = pbr->BaseObject.hHmgr; - - if (!hBR || (GDI_HANDLE_GET_TYPE(hBR) != GDI_OBJECT_TYPE_BRUSH)) - return FALSE; - else - { - INT Index = GDI_HANDLE_GET_INDEX((HGDIOBJ)hBR); - pEntry = &GdiHandleTable->Entries[Index]; - } - - if (pbr->flAttrs & GDIBRUSH_IS_GLOBAL) - { - GDIOBJ_ShareUnlockObjByPtr((POBJ)pbr); - return TRUE; - } - - if ((OwnerMask == GDI_OBJ_HMGR_PUBLIC) || OwnerMask == GDI_OBJ_HMGR_NONE) - { - // Set this Brush to inaccessible mode and to an Owner of NONE. -// if (OwnerMask == GDI_OBJ_HMGR_NONE) Owner = OwnerMask; - - if (!GDIOBJ_SetOwnership((HGDIOBJ) hBR, Owner)) - return FALSE; - - // Deny user access to User Data. - pEntry->UserData = NULL; // This hBR is inaccessible! - } - - if (OwnerMask == GDI_OBJ_HMGR_POWNED) - { - if (!GDIOBJ_SetOwnership((HGDIOBJ) hBR, PsGetCurrentProcess() )) - return FALSE; - - // Allow user access to User Data. - pEntry->UserData = pbr->pBrushAttr; - } - return TRUE; -} - -BOOL -FASTCALL -IntGdiSetDCOwnerEx( HDC hDC, DWORD OwnerMask, BOOL NoSetBrush) -{ - PDC pDC; - BOOL Ret = FALSE; - - if (!hDC || (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC)) return FALSE; - - if ((OwnerMask == GDI_OBJ_HMGR_PUBLIC) || OwnerMask == GDI_OBJ_HMGR_NONE) - { - pDC = DC_LockDc ( hDC ); - MmCopyFromCaller(&pDC->dcattr, pDC->pdcattr, sizeof(DC_ATTR)); - DC_vFreeDcAttr(pDC); - DC_UnlockDc( pDC ); - - if (!DC_SetOwnership( hDC, NULL )) // This hDC is inaccessible! - return Ret; - } - - if (OwnerMask == GDI_OBJ_HMGR_POWNED) - { - pDC = DC_LockDc ( hDC ); - ASSERT(pDC->pdcattr == &pDC->dcattr); - DC_UnlockDc( pDC ); - - if (!DC_SetOwnership( hDC, PsGetCurrentProcess() )) return Ret; - - DC_AllocateDcAttr( hDC ); // Allocate new dcattr - - DCU_SynchDcAttrtoUser( hDC ); // Copy data from dc to dcattr - } - - if ((OwnerMask != GDI_OBJ_HMGR_NONE) && !NoSetBrush) - { - pDC = DC_LockDc ( hDC ); - if (IntGdiSetBrushOwner((PBRUSH)pDC->dclevel.pbrFill, OwnerMask)) - IntGdiSetBrushOwner((PBRUSH)pDC->dclevel.pbrLine, OwnerMask); - DC_UnlockDc( pDC ); - } - return TRUE; -} - INT FASTCALL GreGetObjectOwner(HGDIOBJ Handle, GDIOBJTYPE ObjType) diff --git a/reactos/subsystems/win32/win32k/objects/region.c b/reactos/subsystems/win32/win32k/objects/region.c index 38ad6ae7232..56b6763148e 100644 --- a/reactos/subsystems/win32/win32k/objects/region.c +++ b/reactos/subsystems/win32/win32k/objects/region.c @@ -3942,4 +3942,32 @@ NtGdiGetRegionData( return size + sizeof(RGNDATAHEADER); } +BOOL +FASTCALL +IntGdiSetRegionOwner(HRGN hRgn, DWORD OwnerMask) +{ + INT Index; + PGDI_TABLE_ENTRY Entry; +/* + System Regions: + These regions do not use attribute sections and when allocated, use gdiobj + level functions. + */ + // FIXME! HAX!!! Remove this once we get everything right! + Index = GDI_HANDLE_GET_INDEX(hRgn); + Entry = &GdiHandleTable->Entries[Index]; + if (Entry->UserData) FreeObjectAttr(Entry->UserData); + Entry->UserData = NULL; + // + if ((OwnerMask == GDI_OBJ_HMGR_PUBLIC) || OwnerMask == GDI_OBJ_HMGR_NONE) + { + return GDIOBJ_SetOwnership(hRgn, NULL); + } + if (OwnerMask == GDI_OBJ_HMGR_POWNED) + { + return GDIOBJ_SetOwnership((HGDIOBJ) hRgn, PsGetCurrentProcess() ); + } + return FALSE; +} + /* EOF */ From fb0b4f31c46ed05474bf33e35614169b841dd2de Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Tue, 29 Mar 2011 10:56:28 +0000 Subject: [PATCH 21/66] [NTOS/MM] - Remove IMG_SCN_TYPE_NOLOAD support which was firstly removed by Alex, then reenabled by Herve. Hopefully it works this time. - Return proper image size after successfully mapping an image section (previously, 0 was always returned). The change above is necessary for returning correct size. svn path=/trunk/; revision=51192 --- reactos/ntoskrnl/mm/section.c | 71 +++++++++++++++-------------------- 1 file changed, 30 insertions(+), 41 deletions(-) diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index 83471dd5efc..7749a03eb05 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -4326,14 +4326,11 @@ MmUnmapViewOfSection(PEPROCESS Process, * and calculate the image base address */ for (i = 0; i < NrSegments; i++) { - if (!(SectionSegments[i].Characteristics & IMAGE_SCN_TYPE_NOLOAD)) - { - if (Segment == &SectionSegments[i]) - { - ImageBaseAddress = (char*)BaseAddress - (ULONG_PTR)SectionSegments[i].VirtualAddress; - break; - } - } + if (Segment == &SectionSegments[i]) + { + ImageBaseAddress = (char*)BaseAddress - (ULONG_PTR)SectionSegments[i].VirtualAddress; + break; + } } if (i >= NrSegments) { @@ -4342,13 +4339,10 @@ MmUnmapViewOfSection(PEPROCESS Process, for (i = 0; i < NrSegments; i++) { - if (!(SectionSegments[i].Characteristics & IMAGE_SCN_TYPE_NOLOAD)) - { - PVOID SBaseAddress = (PVOID) - ((char*)ImageBaseAddress + (ULONG_PTR)SectionSegments[i].VirtualAddress); + PVOID SBaseAddress = (PVOID) + ((char*)ImageBaseAddress + (ULONG_PTR)SectionSegments[i].VirtualAddress); - Status = MmUnmapViewOfSegment(AddressSpace, SBaseAddress); - } + Status = MmUnmapViewOfSegment(AddressSpace, SBaseAddress); } } else @@ -4625,13 +4619,10 @@ MmMapViewOfSection(IN PVOID SectionObject, ImageSize = 0; for (i = 0; i < NrSegments; i++) { - if (!(SectionSegments[i].Characteristics & IMAGE_SCN_TYPE_NOLOAD)) - { - ULONG_PTR MaxExtent; - MaxExtent = (ULONG_PTR)SectionSegments[i].VirtualAddress + - SectionSegments[i].Length; - ImageSize = max(ImageSize, MaxExtent); - } + ULONG_PTR MaxExtent; + MaxExtent = (ULONG_PTR)SectionSegments[i].VirtualAddress + + SectionSegments[i].Length; + ImageSize = max(ImageSize, MaxExtent); } ImageSectionObject->ImageSize = ImageSize; @@ -4659,29 +4650,27 @@ MmMapViewOfSection(IN PVOID SectionObject, for (i = 0; i < NrSegments; i++) { - if (!(SectionSegments[i].Characteristics & IMAGE_SCN_TYPE_NOLOAD)) - { - PVOID SBaseAddress = (PVOID) - ((char*)ImageBase + (ULONG_PTR)SectionSegments[i].VirtualAddress); - MmLockSectionSegment(&SectionSegments[i]); - Status = MmMapViewOfSegment(AddressSpace, - Section, - &SectionSegments[i], - &SBaseAddress, - SectionSegments[i].Length, - SectionSegments[i].Protection, - 0, - 0); - MmUnlockSectionSegment(&SectionSegments[i]); - if (!NT_SUCCESS(Status)) - { - MmUnlockAddressSpace(AddressSpace); - return(Status); - } - } + PVOID SBaseAddress = (PVOID) + ((char*)ImageBase + (ULONG_PTR)SectionSegments[i].VirtualAddress); + MmLockSectionSegment(&SectionSegments[i]); + Status = MmMapViewOfSegment(AddressSpace, + Section, + &SectionSegments[i], + &SBaseAddress, + SectionSegments[i].Length, + SectionSegments[i].Protection, + 0, + 0); + MmUnlockSectionSegment(&SectionSegments[i]); + if (!NT_SUCCESS(Status)) + { + MmUnlockAddressSpace(AddressSpace); + return(Status); + } } *BaseAddress = (PVOID)ImageBase; + *ViewSize = ImageSize; } else { From 6771858659b5485c96c49c6a886f9d1e3180c57b Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Tue, 29 Mar 2011 11:00:34 +0000 Subject: [PATCH 22/66] [RTL] - Turn off LdrVerifyMappedImageMatchesChecksum() verification for now. (should have been part of r51192). svn path=/trunk/; revision=51193 --- reactos/lib/rtl/image.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reactos/lib/rtl/image.c b/reactos/lib/rtl/image.c index 03c402fc20c..ce54a6b4df9 100644 --- a/reactos/lib/rtl/image.c +++ b/reactos/lib/rtl/image.c @@ -46,6 +46,7 @@ LdrVerifyMappedImageMatchesChecksum( IN ULONG ImageSize, IN ULONG FileLength) { +#if 0 PIMAGE_NT_HEADERS Header; PUSHORT Ptr; ULONG Sum; @@ -118,6 +119,9 @@ LdrVerifyMappedImageMatchesChecksum( DPRINT1("Image %p checksum mismatches! 0x%x != 0x%x, ImageSize %x, FileLen %x\n", BaseAddress, CalcSum, HeaderSum, ImageSize, FileLength); return (BOOLEAN)(CalcSum == HeaderSum); +#else + return TRUE; +#endif } /* From 2127ff030c01f57116ea0bcc8125458430bd5b16 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 29 Mar 2011 15:35:10 +0000 Subject: [PATCH 23/66] [WIN32K] Addendum to r51188: set last error, when overflow check fails. Fixes test regression. svn path=/trunk/; revision=51194 --- reactos/subsystems/win32/win32k/ntuser/ntstubs.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c index 1ec7f71ca97..c0834596f81 100644 --- a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c +++ b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c @@ -84,11 +84,11 @@ NtUserBitBltSysBmp( Ret = NtGdiBitBlt( hdc, nXDest, nYDest, - nWidth, - nHeight, + nWidth, + nHeight, hSystemBM, - nXSrc, - nYSrc, + nXSrc, + nYSrc, dwRop, 0, 0); @@ -255,7 +255,7 @@ HBRUSH APIENTRY NtUserGetControlColor( HWND hwndParent, - HWND hwnd, + HWND hwnd, HDC hdc, UINT CtlMsg) // Wine PaintRect: WM_CTLCOLORMSGBOX + hbrush { @@ -380,7 +380,7 @@ NtUserInitializeClientPfnArrays( DPRINT1("Failed reading Client Pfns from user space.\n"); SetLastNtError(Status); } - + UserLeave(); return Status; } @@ -543,8 +543,12 @@ NtUserSetSysColors( if (cElements == 0) return TRUE; + /* We need this check to prevent overflow later */ if ((ULONG)cElements >= 0x40000000) + { + EngSetLastError(ERROR_NOACCESS); return FALSE; + } UserEnterExclusive(); From c98d64bacb25add2325289e1f9d9c9be8f1942b5 Mon Sep 17 00:00:00 2001 From: Olaf Siejka Date: Tue, 29 Mar 2011 21:21:18 +0000 Subject: [PATCH 24/66] [SYSSETUP] - Fix compilation warning. Patch by Edijs Kolesnikovics See issue #6059 for more details. svn path=/trunk/; revision=51195 --- reactos/dll/win32/syssetup/wizard.c | 1 + 1 file changed, 1 insertion(+) diff --git a/reactos/dll/win32/syssetup/wizard.c b/reactos/dll/win32/syssetup/wizard.c index 7c438ab5ecd..de46e556ad5 100644 --- a/reactos/dll/win32/syssetup/wizard.c +++ b/reactos/dll/win32/syssetup/wizard.c @@ -20,6 +20,7 @@ #include #define NTOS_MODE_USER #include +#include #include From ed27eba84377638a4e7e993d56c4881a1228b53d Mon Sep 17 00:00:00 2001 From: Olaf Siejka Date: Tue, 29 Mar 2011 21:41:14 +0000 Subject: [PATCH 25/66] [SHELL32] - Fix compile warning (uninitialized use). Based on patch by Edijs Kolesnikovics slightly modified by Aleksiej See issue #6058 for more details. svn path=/trunk/; revision=51196 --- reactos/dll/win32/shell32/shlfileop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/dll/win32/shell32/shlfileop.c b/reactos/dll/win32/shell32/shlfileop.c index 8fa50417493..ddf6670fe18 100644 --- a/reactos/dll/win32/shell32/shlfileop.c +++ b/reactos/dll/win32/shell32/shlfileop.c @@ -584,7 +584,7 @@ BOOL QueueFile( FILE_OPERATION_CONTEXT * Context) { - FILE_ENTRY * from, *to; + FILE_ENTRY * from, *too = NULL; BOOL bRet = FALSE; if (Context->Index >= Context->from->dwNumFiles) From a77d09adf9393128be3b688c5ad976a5f05cbf0d Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Tue, 29 Mar 2011 21:48:13 +0000 Subject: [PATCH 26/66] [KERNEL32] - Rename global vars to some better names (some of the names seen in Windows 2003 asserts and text messages). - Add BaseDefaultPath initialization, which will be needed but the new kernel32/ldr code, which is in turn required by the new ntdll/ldr code. - Add some beginnings of BasepGetDllPath(), but it returns NULL anyway now so no change in execution. svn path=/trunk/; revision=51197 --- reactos/dll/win32/kernel32/file/curdir.c | 2 + reactos/dll/win32/kernel32/file/dir.c | 38 +++++++++--------- reactos/dll/win32/kernel32/include/kernel32.h | 10 ++++- reactos/dll/win32/kernel32/misc/console.c | 4 +- reactos/dll/win32/kernel32/misc/dllmain.c | 28 +++++++++++-- reactos/dll/win32/kernel32/process/procsup.c | 40 ++++++++++++++++++- 6 files changed, 94 insertions(+), 28 deletions(-) diff --git a/reactos/dll/win32/kernel32/file/curdir.c b/reactos/dll/win32/kernel32/file/curdir.c index 8c74fbe11a1..42ae057f054 100644 --- a/reactos/dll/win32/kernel32/file/curdir.c +++ b/reactos/dll/win32/kernel32/file/curdir.c @@ -28,6 +28,8 @@ DEBUG_CHANNEL(kernel32file); UNICODE_STRING SystemDirectory; UNICODE_STRING WindowsDirectory; +UNICODE_STRING BaseDefaultPathAppend; +UNICODE_STRING BaseDefaultPath; /* FUNCTIONS *****************************************************************/ diff --git a/reactos/dll/win32/kernel32/file/dir.c b/reactos/dll/win32/kernel32/file/dir.c index a364e6a1f46..184403912f3 100644 --- a/reactos/dll/win32/kernel32/file/dir.c +++ b/reactos/dll/win32/kernel32/file/dir.c @@ -20,7 +20,7 @@ #include DEBUG_CHANNEL(kernel32file); -UNICODE_STRING DllDirectory = {0, 0, NULL}; +UNICODE_STRING BaseDllDirectory = {0, 0, NULL}; /* FUNCTIONS *****************************************************************/ @@ -1079,35 +1079,35 @@ SetDllDirectoryW( RtlInitUnicodeString(&PathName, lpPathName); - RtlEnterCriticalSection(&DllLock); + RtlEnterCriticalSection(&BaseDllDirectoryLock); if(PathName.Length > 0) { - if(PathName.Length + sizeof(WCHAR) <= DllDirectory.MaximumLength) + if(PathName.Length + sizeof(WCHAR) <= BaseDllDirectory.MaximumLength) { - RtlCopyUnicodeString(&DllDirectory, &PathName); + RtlCopyUnicodeString(&BaseDllDirectory, &PathName); } else { - RtlFreeUnicodeString(&DllDirectory); - if(!(DllDirectory.Buffer = (PWSTR)RtlAllocateHeap(RtlGetProcessHeap(), - 0, - PathName.Length + sizeof(WCHAR)))) + RtlFreeUnicodeString(&BaseDllDirectory); + if(!(BaseDllDirectory.Buffer = (PWSTR)RtlAllocateHeap(RtlGetProcessHeap(), + 0, + PathName.Length + sizeof(WCHAR)))) { - RtlLeaveCriticalSection(&DllLock); + RtlLeaveCriticalSection(&BaseDllDirectoryLock); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } - DllDirectory.Length = 0; - DllDirectory.MaximumLength = PathName.Length + sizeof(WCHAR); + BaseDllDirectory.Length = 0; + BaseDllDirectory.MaximumLength = PathName.Length + sizeof(WCHAR); - RtlCopyUnicodeString(&DllDirectory, &PathName); + RtlCopyUnicodeString(&BaseDllDirectory, &PathName); } } else { - RtlFreeUnicodeString(&DllDirectory); + RtlFreeUnicodeString(&BaseDllDirectory); } - RtlLeaveCriticalSection(&DllLock); + RtlLeaveCriticalSection(&BaseDllDirectoryLock); return TRUE; } @@ -1144,10 +1144,10 @@ GetDllDirectoryW( { DWORD Ret; - RtlEnterCriticalSection(&DllLock); + RtlEnterCriticalSection(&BaseDllDirectoryLock); if(nBufferLength > 0) { - Ret = DllDirectory.Length / sizeof(WCHAR); + Ret = BaseDllDirectory.Length / sizeof(WCHAR); if(Ret > nBufferLength - 1) { Ret = nBufferLength - 1; @@ -1155,16 +1155,16 @@ GetDllDirectoryW( if(Ret > 0) { - RtlCopyMemory(lpBuffer, DllDirectory.Buffer, Ret * sizeof(WCHAR)); + RtlCopyMemory(lpBuffer, BaseDllDirectory.Buffer, Ret * sizeof(WCHAR)); } lpBuffer[Ret] = L'\0'; } else { /* include termination character, even if the string is empty! */ - Ret = (DllDirectory.Length / sizeof(WCHAR)) + 1; + Ret = (BaseDllDirectory.Length / sizeof(WCHAR)) + 1; } - RtlLeaveCriticalSection(&DllLock); + RtlLeaveCriticalSection(&BaseDllDirectoryLock); return Ret; } diff --git a/reactos/dll/win32/kernel32/include/kernel32.h b/reactos/dll/win32/kernel32/include/kernel32.h index 747c8b1b664..d6361b3bdfe 100755 --- a/reactos/dll/win32/kernel32/include/kernel32.h +++ b/reactos/dll/win32/kernel32/include/kernel32.h @@ -91,9 +91,9 @@ extern HANDLE hProcessHeap; extern HANDLE hBaseDir; extern HMODULE hCurrentModule; -extern RTL_CRITICAL_SECTION DllLock; +extern RTL_CRITICAL_SECTION BaseDllDirectoryLock; -extern UNICODE_STRING DllDirectory; +extern UNICODE_STRING BaseDllDirectory; extern LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter; @@ -211,6 +211,12 @@ BasepMapFile(IN LPCWSTR lpApplicationName, OUT PHANDLE hSection, IN PUNICODE_STRING ApplicationName); +LPWSTR +WINAPI +BasepGetDllPath(LPWSTR FullPath, + PVOID Environment); + + PCODEPAGE_ENTRY FASTCALL IntGetCodePageEntry(UINT CodePage); diff --git a/reactos/dll/win32/kernel32/misc/console.c b/reactos/dll/win32/kernel32/misc/console.c index 2b0d253b23e..2fc95b58d5f 100644 --- a/reactos/dll/win32/kernel32/misc/console.c +++ b/reactos/dll/win32/kernel32/misc/console.c @@ -3524,7 +3524,7 @@ SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, { BOOL Ret; - RtlEnterCriticalSection(&DllLock); + RtlEnterCriticalSection(&BaseDllDirectoryLock); if (Add) { Ret = AddConsoleCtrlHandler(HandlerRoutine); @@ -3534,7 +3534,7 @@ SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, Ret = RemoveConsoleCtrlHandler(HandlerRoutine); } - RtlLeaveCriticalSection(&DllLock); + RtlLeaveCriticalSection(&BaseDllDirectoryLock); return(Ret); } diff --git a/reactos/dll/win32/kernel32/misc/dllmain.c b/reactos/dll/win32/kernel32/misc/dllmain.c index ae0ada2e85c..f43b9b27b69 100644 --- a/reactos/dll/win32/kernel32/misc/dllmain.c +++ b/reactos/dll/win32/kernel32/misc/dllmain.c @@ -5,6 +5,7 @@ * FILE: lib/kernel32/misc/dllmain.c * PURPOSE: Initialization * PROGRAMMER: Ariadne ( ariadne@xs4all.nl) + * Aleksey Bragin (aleksey@reactos.org) * UPDATE HISTORY: * Created 01/11/98 */ @@ -20,6 +21,10 @@ extern UNICODE_STRING SystemDirectory; extern UNICODE_STRING WindowsDirectory; +extern UNICODE_STRING BaseDefaultPath; +extern UNICODE_STRING BaseDefaultPathAppend; + +WCHAR BaseDefaultPathBuffer[6140]; HANDLE hProcessHeap = NULL; HMODULE hCurrentModule = NULL; @@ -36,7 +41,7 @@ DllMain(HANDLE hInst, LPVOID lpReserved); /* Critical section for various kernel32 data structures */ -RTL_CRITICAL_SECTION DllLock; +RTL_CRITICAL_SECTION BaseDllDirectoryLock; RTL_CRITICAL_SECTION ConsoleLock; extern BOOL WINAPI DefaultConsoleCtrlHandler(DWORD Event); @@ -275,6 +280,9 @@ DllMain(HANDLE hDll, /* Don't bother us for each thread */ LdrDisableThreadCalloutsForDll((PVOID)hDll); + /* Initialize default path to NULL */ + RtlInitUnicodeString(&BaseDefaultPath, NULL); + /* Setup the right Object Directory path */ if (!SessionId) { @@ -332,11 +340,25 @@ DllMain(HANDLE hDll, SystemDirectory.MaximumLength); if(SystemDirectory.Buffer == NULL) { + DPRINT1("Failure allocating SystemDirectory buffer\n"); return FALSE; } wcscpy(SystemDirectory.Buffer, WindowsDirectory.Buffer); wcscat(SystemDirectory.Buffer, L"\\System32"); + /* Construct the default path (using the static buffer) */ + _snwprintf(BaseDefaultPathBuffer, sizeof(BaseDefaultPathBuffer) / sizeof(WCHAR), + L".;%wZ;%wZ\\system;%wZ;", &SystemDirectory, &WindowsDirectory, &WindowsDirectory); + + BaseDefaultPath.Buffer = BaseDefaultPathBuffer; + BaseDefaultPath.Length = wcslen(BaseDefaultPathBuffer) * sizeof(WCHAR); + BaseDefaultPath.MaximumLength = sizeof(BaseDefaultPathBuffer); + + /* Use remaining part of the default path buffer for the append path */ + BaseDefaultPathAppend.Buffer = (PWSTR)((ULONG_PTR)BaseDefaultPathBuffer + BaseDefaultPath.Length); + BaseDefaultPathAppend.Length = 0; + BaseDefaultPathAppend.MaximumLength = BaseDefaultPath.MaximumLength - BaseDefaultPath.Length; + /* Initialize command line */ InitCommandLines(); @@ -349,7 +371,7 @@ DllMain(HANDLE hDll, } /* Initialize the DLL critical section */ - RtlInitializeCriticalSection(&DllLock); + RtlInitializeCriticalSection(&BaseDllDirectoryLock); /* Initialize the National Language Support routines */ if (!NlsInit()) @@ -395,7 +417,7 @@ DllMain(HANDLE hDll, ConsoleInitialized = FALSE; RtlDeleteCriticalSection (&ConsoleLock); } - RtlDeleteCriticalSection (&DllLock); + RtlDeleteCriticalSection (&BaseDllDirectoryLock); /* Close object base directory */ NtClose(hBaseDir); diff --git a/reactos/dll/win32/kernel32/process/procsup.c b/reactos/dll/win32/kernel32/process/procsup.c index 33b053d9324..a4d35d786d7 100644 --- a/reactos/dll/win32/kernel32/process/procsup.c +++ b/reactos/dll/win32/kernel32/process/procsup.c @@ -14,6 +14,9 @@ #define NDEBUG #include +UNICODE_STRING BasePathVariableName = RTL_CONSTANT_STRING(L"PATH"); +UNICODE_STRING BaseDefaultPath; + #define CMD_STRING L"cmd /c " extern __declspec(noreturn) @@ -352,13 +355,46 @@ BasepDuplicateAndWriteHandle(IN HANDLE ProcessHandle, } } +LPWSTR +WINAPI +BasepGetProcessPath(DWORD Reserved, + LPWSTR FullPath, + PVOID Environment) +{ + return NULL; +} + LPWSTR WINAPI BasepGetDllPath(LPWSTR FullPath, PVOID Environment) { - /* FIXME: Not yet implemented */ - return NULL; + LPWSTR DllPath = NULL; + + /* Acquire DLL directory lock */ + RtlEnterCriticalSection(&BaseDllDirectoryLock); + + /* Check if we have a base dll directory */ + if (BaseDllDirectory.Buffer) + { + /* Then get process path */ + DllPath = BasepGetProcessPath(0, FullPath, Environment); + + /* Release DLL directory lock */ + RtlLeaveCriticalSection(&BaseDllDirectoryLock); + + /* Return dll path */ + return DllPath; + } + + /* Release DLL directory lock */ + RtlLeaveCriticalSection(&BaseDllDirectoryLock); + + /* There is no base DLL directory */ + UNIMPLEMENTED; + + /* Return dll path */ + return DllPath; } VOID From 615f45bf9a7a544335bd0dfde399e62571c264d5 Mon Sep 17 00:00:00 2001 From: Olaf Siejka Date: Tue, 29 Mar 2011 21:48:30 +0000 Subject: [PATCH 27/66] [SHELL32] - Fix build, borked by copypasta svn path=/trunk/; revision=51198 --- reactos/dll/win32/shell32/shlfileop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/dll/win32/shell32/shlfileop.c b/reactos/dll/win32/shell32/shlfileop.c index ddf6670fe18..2adcbc9adc5 100644 --- a/reactos/dll/win32/shell32/shlfileop.c +++ b/reactos/dll/win32/shell32/shlfileop.c @@ -584,7 +584,7 @@ BOOL QueueFile( FILE_OPERATION_CONTEXT * Context) { - FILE_ENTRY * from, *too = NULL; + FILE_ENTRY * from, *to = NULL; BOOL bRet = FALSE; if (Context->Index >= Context->from->dwNumFiles) From c07f34ceee9d5fde938865270ec0069c36a05fce Mon Sep 17 00:00:00 2001 From: Olaf Siejka Date: Tue, 29 Mar 2011 21:59:57 +0000 Subject: [PATCH 28/66] [SHELL32] - Fix a bug, by Johannes Anderwald svn path=/trunk/; revision=51199 --- reactos/dll/win32/shell32/shlfileop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/dll/win32/shell32/shlfileop.c b/reactos/dll/win32/shell32/shlfileop.c index 2adcbc9adc5..f22b7225a00 100644 --- a/reactos/dll/win32/shell32/shlfileop.c +++ b/reactos/dll/win32/shell32/shlfileop.c @@ -593,7 +593,7 @@ QueueFile( /* get current file */ from = &Context->from->feFiles[Context->Index]; - if (Context->op->req->fFlags != FO_DELETE) + if (Context->op->req->wFunc != FO_DELETE) to = &Context->to->feFiles[Context->Index]; /* update status */ From f42a29cf5cff5ac2f6536513793c8287cc069a4b Mon Sep 17 00:00:00 2001 From: James Tabor Date: Tue, 29 Mar 2011 23:44:22 +0000 Subject: [PATCH 29/66] [Win32k] - Move IntGdiSetBrushOwner and IntGdiSetRegionOwner out of the export section. svn path=/trunk/; revision=51200 --- .../subsystems/win32/win32k/objects/brush.c | 97 +++++++++---------- .../subsystems/win32/win32k/objects/region.c | 56 +++++------ 2 files changed, 76 insertions(+), 77 deletions(-) diff --git a/reactos/subsystems/win32/win32k/objects/brush.c b/reactos/subsystems/win32/win32k/objects/brush.c index f9d773e2e38..72b7fd3864a 100644 --- a/reactos/subsystems/win32/win32k/objects/brush.c +++ b/reactos/subsystems/win32/win32k/objects/brush.c @@ -162,6 +162,54 @@ FreeObjectAttr(PVOID pAttr) return; } +BOOL +FASTCALL +IntGdiSetBrushOwner(PBRUSH pbr, DWORD OwnerMask) +{ + HBRUSH hBR; + PEPROCESS Owner = NULL; + PGDI_TABLE_ENTRY pEntry = NULL; + + if (!pbr) return FALSE; + + hBR = pbr->BaseObject.hHmgr; + + if (!hBR || (GDI_HANDLE_GET_TYPE(hBR) != GDI_OBJECT_TYPE_BRUSH)) + return FALSE; + else + { + INT Index = GDI_HANDLE_GET_INDEX((HGDIOBJ)hBR); + pEntry = &GdiHandleTable->Entries[Index]; + } + + if (pbr->flAttrs & GDIBRUSH_IS_GLOBAL) + { + GDIOBJ_ShareUnlockObjByPtr((POBJ)pbr); + return TRUE; + } + + if ((OwnerMask == GDI_OBJ_HMGR_PUBLIC) || OwnerMask == GDI_OBJ_HMGR_NONE) + { + // Set this Brush to inaccessible mode and to an Owner of NONE. +// if (OwnerMask == GDI_OBJ_HMGR_NONE) Owner = OwnerMask; + + if (!GDIOBJ_SetOwnership((HGDIOBJ) hBR, Owner)) + return FALSE; + + // Deny user access to User Data. + pEntry->UserData = NULL; // This hBR is inaccessible! + } + + if (OwnerMask == GDI_OBJ_HMGR_POWNED) + { + if (!GDIOBJ_SetOwnership((HGDIOBJ) hBR, PsGetCurrentProcess() )) + return FALSE; + + // Allow user access to User Data. + pEntry->UserData = pbr->pBrushAttr; + } + return TRUE; +} BOOL INTERNAL_CALL @@ -573,53 +621,4 @@ NtGdiSetBrushOrg(HDC hDC, INT XOrg, INT YOrg, LPPOINT Point) return TRUE; } -BOOL -FASTCALL -IntGdiSetBrushOwner(PBRUSH pbr, DWORD OwnerMask) -{ - HBRUSH hBR; - PEPROCESS Owner = NULL; - PGDI_TABLE_ENTRY pEntry = NULL; - - if (!pbr) return FALSE; - - hBR = pbr->BaseObject.hHmgr; - - if (!hBR || (GDI_HANDLE_GET_TYPE(hBR) != GDI_OBJECT_TYPE_BRUSH)) - return FALSE; - else - { - INT Index = GDI_HANDLE_GET_INDEX((HGDIOBJ)hBR); - pEntry = &GdiHandleTable->Entries[Index]; - } - - if (pbr->flAttrs & GDIBRUSH_IS_GLOBAL) - { - GDIOBJ_ShareUnlockObjByPtr((POBJ)pbr); - return TRUE; - } - - if ((OwnerMask == GDI_OBJ_HMGR_PUBLIC) || OwnerMask == GDI_OBJ_HMGR_NONE) - { - // Set this Brush to inaccessible mode and to an Owner of NONE. -// if (OwnerMask == GDI_OBJ_HMGR_NONE) Owner = OwnerMask; - - if (!GDIOBJ_SetOwnership((HGDIOBJ) hBR, Owner)) - return FALSE; - - // Deny user access to User Data. - pEntry->UserData = NULL; // This hBR is inaccessible! - } - - if (OwnerMask == GDI_OBJ_HMGR_POWNED) - { - if (!GDIOBJ_SetOwnership((HGDIOBJ) hBR, PsGetCurrentProcess() )) - return FALSE; - - // Allow user access to User Data. - pEntry->UserData = pbr->pBrushAttr; - } - return TRUE; -} - /* EOF */ diff --git a/reactos/subsystems/win32/win32k/objects/region.c b/reactos/subsystems/win32/win32k/objects/region.c index 56b6763148e..9a267493002 100644 --- a/reactos/subsystems/win32/win32k/objects/region.c +++ b/reactos/subsystems/win32/win32k/objects/region.c @@ -2294,6 +2294,34 @@ IntUpdateVisRectRgn(PDC pDC, PROSRGNDATA pRgn) } } +BOOL +FASTCALL +IntGdiSetRegionOwner(HRGN hRgn, DWORD OwnerMask) +{ + INT Index; + PGDI_TABLE_ENTRY Entry; +/* + System Regions: + These regions do not use attribute sections and when allocated, use gdiobj + level functions. + */ + // FIXME! HAX!!! Remove this once we get everything right! + Index = GDI_HANDLE_GET_INDEX(hRgn); + Entry = &GdiHandleTable->Entries[Index]; + if (Entry->UserData) FreeObjectAttr(Entry->UserData); + Entry->UserData = NULL; + // + if ((OwnerMask == GDI_OBJ_HMGR_PUBLIC) || OwnerMask == GDI_OBJ_HMGR_NONE) + { + return GDIOBJ_SetOwnership(hRgn, NULL); + } + if (OwnerMask == GDI_OBJ_HMGR_POWNED) + { + return GDIOBJ_SetOwnership((HGDIOBJ) hRgn, PsGetCurrentProcess() ); + } + return FALSE; +} + INT FASTCALL IntGdiCombineRgn(PROSRGNDATA destRgn, @@ -3942,32 +3970,4 @@ NtGdiGetRegionData( return size + sizeof(RGNDATAHEADER); } -BOOL -FASTCALL -IntGdiSetRegionOwner(HRGN hRgn, DWORD OwnerMask) -{ - INT Index; - PGDI_TABLE_ENTRY Entry; -/* - System Regions: - These regions do not use attribute sections and when allocated, use gdiobj - level functions. - */ - // FIXME! HAX!!! Remove this once we get everything right! - Index = GDI_HANDLE_GET_INDEX(hRgn); - Entry = &GdiHandleTable->Entries[Index]; - if (Entry->UserData) FreeObjectAttr(Entry->UserData); - Entry->UserData = NULL; - // - if ((OwnerMask == GDI_OBJ_HMGR_PUBLIC) || OwnerMask == GDI_OBJ_HMGR_NONE) - { - return GDIOBJ_SetOwnership(hRgn, NULL); - } - if (OwnerMask == GDI_OBJ_HMGR_POWNED) - { - return GDIOBJ_SetOwnership((HGDIOBJ) hRgn, PsGetCurrentProcess() ); - } - return FALSE; -} - /* EOF */ From 0d6b3c7ebd6229a2bd46b04d86cae6ef89cf0d7b Mon Sep 17 00:00:00 2001 From: James Tabor Date: Wed, 30 Mar 2011 01:00:28 +0000 Subject: [PATCH 30/66] [User32|Win32k] - Update NtUser pump functions, based on known values. Move one more function to the right place. svn path=/trunk/; revision=51201 --- reactos/include/reactos/win32k/ntuser.h | 28 ++++---- .../subsystems/win32/win32k/ntuser/ntstubs.c | 28 ++++---- .../subsystems/win32/win32k/ntuser/window.c | 67 ------------------- .../subsystems/win32/win32k/ntuser/winpos.c | 66 ++++++++++++++++++ 4 files changed, 94 insertions(+), 95 deletions(-) diff --git a/reactos/include/reactos/win32k/ntuser.h b/reactos/include/reactos/win32k/ntuser.h index b6e2d8339ef..71ea1772fc6 100644 --- a/reactos/include/reactos/win32k/ntuser.h +++ b/reactos/include/reactos/win32k/ntuser.h @@ -2404,28 +2404,28 @@ NtUserQueryWindow( HWND hWnd, DWORD Index); -DWORD +BOOL NTAPI NtUserRealInternalGetMessage( - DWORD dwUnknown1, - DWORD dwUnknown2, - DWORD dwUnknown3, - DWORD dwUnknown4, - DWORD dwUnknown5, - DWORD dwUnknown6); + LPMSG lpMsg, + HWND hWnd, + UINT wMsgFilterMin, + UINT wMsgFilterMax, + UINT wRemoveMsg, + BOOL bGMSG); -DWORD +HWND NTAPI NtUserRealChildWindowFromPoint( - DWORD Unknown0, - DWORD Unknown1, - DWORD Unknown2); + HWND Parent, + LONG x, + LONG y); -DWORD +BOOL NTAPI NtUserRealWaitMessageEx( - DWORD dwUnknown1, - DWORD dwUnknown2); + DWORD dwWakeMask, + UINT uTimeout); BOOL NTAPI diff --git a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c index c0834596f81..06b84793c87 100644 --- a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c +++ b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c @@ -935,25 +935,25 @@ NtUserQueryInputContext( return 0; } -DWORD +BOOL APIENTRY NtUserRealInternalGetMessage( - DWORD dwUnknown1, - DWORD dwUnknown2, - DWORD dwUnknown3, - DWORD dwUnknown4, - DWORD dwUnknown5, - DWORD dwUnknown6) + LPMSG lpMsg, + HWND hWnd, + UINT wMsgFilterMin, + UINT wMsgFilterMax, + UINT wRemoveMsg, + BOOL bGMSG) { UNIMPLEMENTED; return 0; } -DWORD +BOOL APIENTRY NtUserRealWaitMessageEx( - DWORD dwUnknown1, - DWORD dwUnknown2) + DWORD dwWakeMask, + UINT uTimeout) { UNIMPLEMENTED; return 0; @@ -1252,10 +1252,10 @@ NtUserLockWindowUpdate(HWND hWnd) /* * @unimplemented */ -DWORD APIENTRY -NtUserRealChildWindowFromPoint(DWORD Unknown0, - DWORD Unknown1, - DWORD Unknown2) +HWND APIENTRY +NtUserRealChildWindowFromPoint(HWND Parent, + LONG x, + LONG y) { UNIMPLEMENTED diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index 72d232b5393..acd8a1aa14b 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -1478,73 +1478,6 @@ NtUserBuildHwndList( return STATUS_SUCCESS; } - -/* - * @implemented - */ -HWND APIENTRY -NtUserChildWindowFromPointEx(HWND hwndParent, - LONG x, - LONG y, - UINT uiFlags) -{ - PWND Parent; - POINTL Pt; - HWND Ret; - HWND *List, *phWnd; - - if(!(Parent = UserGetWindowObject(hwndParent))) - { - return NULL; - } - - Pt.x = x; - Pt.y = y; - - if(Parent->head.h != IntGetDesktopWindow()) - { - Pt.x += Parent->rcClient.left; - Pt.y += Parent->rcClient.top; - } - - if(!IntPtInWindow(Parent, Pt.x, Pt.y)) - { - return NULL; - } - - Ret = Parent->head.h; - if((List = IntWinListChildren(Parent))) - { - for(phWnd = List; *phWnd; phWnd++) - { - PWND Child; - if((Child = UserGetWindowObject(*phWnd))) - { - if(!(Child->style & WS_VISIBLE) && (uiFlags & CWP_SKIPINVISIBLE)) - { - continue; - } - if((Child->style & WS_DISABLED) && (uiFlags & CWP_SKIPDISABLED)) - { - continue; - } - if((Child->ExStyle & WS_EX_TRANSPARENT) && (uiFlags & CWP_SKIPTRANSPARENT)) - { - continue; - } - if(IntPtInWindow(Child, Pt.x, Pt.y)) - { - Ret = Child->head.h; - break; - } - } - } - ExFreePool(List); - } - - return Ret; -} - static void IntSendParentNotify( PWND pWindow, UINT msg ) { if ( (pWindow->style & (WS_CHILD | WS_POPUP)) == WS_CHILD && diff --git a/reactos/subsystems/win32/win32k/ntuser/winpos.c b/reactos/subsystems/win32/win32k/ntuser/winpos.c index 3934dcb21b6..7b9a6f6fa44 100644 --- a/reactos/subsystems/win32/win32k/ntuser/winpos.c +++ b/reactos/subsystems/win32/win32k/ntuser/winpos.c @@ -1797,6 +1797,72 @@ BOOL FASTCALL IntEndDeferWindowPosEx( HDWP hdwp ) return res; } +/* + * @implemented + */ +HWND APIENTRY +NtUserChildWindowFromPointEx(HWND hwndParent, + LONG x, + LONG y, + UINT uiFlags) +{ + PWND Parent; + POINTL Pt; + HWND Ret; + HWND *List, *phWnd; + + if(!(Parent = UserGetWindowObject(hwndParent))) + { + return NULL; + } + + Pt.x = x; + Pt.y = y; + + if(Parent->head.h != IntGetDesktopWindow()) + { + Pt.x += Parent->rcClient.left; + Pt.y += Parent->rcClient.top; + } + + if(!IntPtInWindow(Parent, Pt.x, Pt.y)) + { + return NULL; + } + + Ret = Parent->head.h; + if((List = IntWinListChildren(Parent))) + { + for(phWnd = List; *phWnd; phWnd++) + { + PWND Child; + if((Child = UserGetWindowObject(*phWnd))) + { + if(!(Child->style & WS_VISIBLE) && (uiFlags & CWP_SKIPINVISIBLE)) + { + continue; + } + if((Child->style & WS_DISABLED) && (uiFlags & CWP_SKIPDISABLED)) + { + continue; + } + if((Child->ExStyle & WS_EX_TRANSPARENT) && (uiFlags & CWP_SKIPTRANSPARENT)) + { + continue; + } + if(IntPtInWindow(Child, Pt.x, Pt.y)) + { + Ret = Child->head.h; + break; + } + } + } + ExFreePool(List); + } + + return Ret; +} + /* * @implemented */ From 815eb466ba330dd351be34c49b97b87b5ba4f5a7 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Wed, 30 Mar 2011 01:26:54 +0000 Subject: [PATCH 31/66] [User32] - Connect the rest of the pump hooks and start tracking from application testing. svn path=/trunk/; revision=51202 --- reactos/dll/win32/user32/windows/message.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/reactos/dll/win32/user32/windows/message.c b/reactos/dll/win32/user32/windows/message.c index f00e6670a00..5536d835cec 100644 --- a/reactos/dll/win32/user32/windows/message.c +++ b/reactos/dll/win32/user32/windows/message.c @@ -2491,11 +2491,13 @@ BOOL WINAPI SetMessageQueue(int cMessagesMax) } typedef DWORD (WINAPI * RealGetQueueStatusProc)(UINT flags); typedef DWORD (WINAPI * RealMsgWaitForMultipleObjectsExProc)(DWORD nCount, CONST HANDLE *lpHandles, DWORD dwMilliseconds, DWORD dwWakeMask, DWORD dwFlags); +typedef BOOL (WINAPI * RealInternalGetMessageProc)(LPMSG,HWND,UINT,UINT,UINT,BOOL); +typedef BOOL (WINAPI * RealWaitMessageExProc)(DWORD,UINT); typedef struct _USER_MESSAGE_PUMP_ADDRESSES { DWORD cbSize; - //NtUserRealInternalGetMessageProc NtUserRealInternalGetMessage; - //NtUserRealWaitMessageExProc NtUserRealWaitMessageEx; + RealInternalGetMessageProc NtUserRealInternalGetMessage; + RealWaitMessageExProc NtUserRealWaitMessageEx; RealGetQueueStatusProc RealGetQueueStatus; RealMsgWaitForMultipleObjectsExProc RealMsgWaitForMultipleObjectsEx; } USER_MESSAGE_PUMP_ADDRESSES, * PUSER_MESSAGE_PUMP_ADDRESSES; @@ -2515,8 +2517,8 @@ CRITICAL_SECTION gcsMPH; MESSAGEPUMPHOOKPROC gpfnInitMPH; DWORD gcLoadMPH = 0; USER_MESSAGE_PUMP_ADDRESSES gmph = {sizeof(USER_MESSAGE_PUMP_ADDRESSES), - //NtUserRealInternalGetMessage, - //NtUserRealInternalWaitMessageEx, + NtUserRealInternalGetMessage, + NtUserRealWaitMessageEx, RealGetQueueStatus, RealMsgWaitForMultipleObjectsEx }; @@ -2532,8 +2534,8 @@ BOOL WINAPI IsInsideMessagePumpHook() void WINAPI ResetMessagePumpHook(PUSER_MESSAGE_PUMP_ADDRESSES Addresses) { Addresses->cbSize = sizeof(USER_MESSAGE_PUMP_ADDRESSES); - //Addresses->NtUserRealInternalGetMessage = (NtUserRealInternalGetMessageProc)NtUserRealInternalGetMessage; - //Addresses->NtUserRealWaitMessageEx = (NtUserRealWaitMessageExProc)NtUserRealInternalWaitMessageEx; + Addresses->NtUserRealInternalGetMessage = NtUserRealInternalGetMessage; + Addresses->NtUserRealWaitMessageEx = NtUserRealWaitMessageEx; Addresses->RealGetQueueStatus = RealGetQueueStatus; Addresses->RealMsgWaitForMultipleObjectsEx = RealMsgWaitForMultipleObjectsEx; } From 88339aa831161a7e22601814feb20afd7b9ab77c Mon Sep 17 00:00:00 2001 From: James Tabor Date: Wed, 30 Mar 2011 08:19:52 +0000 Subject: [PATCH 32/66] [User32|Win32k] - Move EnableWindow to Win32k. - Fix sign in class function. svn path=/trunk/; revision=51203 --- reactos/dll/win32/user32/windows/class.c | 2 +- reactos/dll/win32/user32/windows/input.c | 37 +--------------- .../subsystems/win32/win32k/include/window.h | 2 + .../win32/win32k/ntuser/simplecall.c | 3 +- .../subsystems/win32/win32k/ntuser/window.c | 44 +++++++++++++++++++ 5 files changed, 49 insertions(+), 39 deletions(-) diff --git a/reactos/dll/win32/user32/windows/class.c b/reactos/dll/win32/user32/windows/class.c index 6770b6d6d0b..0d9ae490b69 100644 --- a/reactos/dll/win32/user32/windows/class.c +++ b/reactos/dll/win32/user32/windows/class.c @@ -933,7 +933,7 @@ RealGetWindowClassA( WCHAR tmpbuf[MAX_ATOM_LEN + 1]; UINT len; - if (cchType <= 0) return 0; + if ((INT)cchType <= 0) return 0; if (!RealGetWindowClassW( hwnd, tmpbuf, sizeof(tmpbuf)/sizeof(WCHAR) )) return 0; RtlUnicodeToMultiByteN( pszType, cchType - 1, (PULONG)&len, tmpbuf, strlenW(tmpbuf) * sizeof(WCHAR) ); pszType[len] = 0; diff --git a/reactos/dll/win32/user32/windows/input.c b/reactos/dll/win32/user32/windows/input.c index 63f266eb492..e9189576963 100644 --- a/reactos/dll/win32/user32/windows/input.c +++ b/reactos/dll/win32/user32/windows/input.c @@ -100,7 +100,6 @@ DragDetect( #endif } - /* * @implemented */ @@ -108,43 +107,9 @@ BOOL WINAPI EnableWindow(HWND hWnd, BOOL bEnable) { - // This will soon be moved to win32k. - BOOL Update; - LONG Style = GetWindowLongPtrW(hWnd, GWL_STYLE); - /* check if updating is needed */ - UINT bIsDisabled = (Style & WS_DISABLED); - Update = bIsDisabled; - - if (bEnable) - { - Style &= ~WS_DISABLED; - } - else - { - Update = !bIsDisabled; - - SendMessageW( hWnd, WM_CANCELMODE, 0, 0); - - /* Remove keyboard focus from that window if it had focus */ - if (hWnd == GetFocus()) - { - SetFocus(NULL); - } - Style |= WS_DISABLED; - } - - NtUserSetWindowLong(hWnd, GWL_STYLE, Style, FALSE); - - if (Update) - { - IntNotifyWinEvent(EVENT_OBJECT_STATECHANGE, hWnd, OBJID_WINDOW, CHILDID_SELF, 0); - SendMessageW(hWnd, WM_ENABLE, (LPARAM)bEnable, 0); - } - // Return nonzero if it was disabled, or zero if it wasn't: - return bIsDisabled; + return NtUserCallTwoParam((DWORD_PTR)hWnd, (DWORD_PTR)bEnable, TWOPARAM_ROUTINE_ENABLEWINDOW); } - /* * @implemented */ diff --git a/reactos/subsystems/win32/win32k/include/window.h b/reactos/subsystems/win32/win32k/include/window.h index 0e2073d3df1..44e6a8c86db 100644 --- a/reactos/subsystems/win32/win32k/include/window.h +++ b/reactos/subsystems/win32/win32k/include/window.h @@ -111,4 +111,6 @@ VOID FASTCALL IntNotifyWinEvent(DWORD, PWND, LONG, LONG, DWORD); PWND FASTCALL co_UserCreateWindowEx(CREATESTRUCTW*, PUNICODE_STRING, PLARGE_STRING); WNDPROC FASTCALL IntGetWindowProc(PWND,BOOL); +BOOL FASTCALL IntEnableWindow(HWND,BOOL); + /* EOF */ diff --git a/reactos/subsystems/win32/win32k/ntuser/simplecall.c b/reactos/subsystems/win32/win32k/ntuser/simplecall.c index d4a1a14f403..21109806fe9 100644 --- a/reactos/subsystems/win32/win32k/ntuser/simplecall.c +++ b/reactos/subsystems/win32/win32k/ntuser/simplecall.c @@ -436,8 +436,7 @@ NtUserCallTwoParam( } case TWOPARAM_ROUTINE_ENABLEWINDOW: - UNIMPLEMENTED - RETURN( 0); + RETURN( IntEnableWindow((HWND)Param1, (BOOL)Param2)); case TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS: { diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index acd8a1aa14b..21aecf32546 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -176,6 +176,50 @@ IntGetParent(PWND Wnd) return NULL; } +BOOL +FASTCALL +IntEnableWindow( HWND hWnd, BOOL bEnable ) +{ + BOOL Update; + PWND pWnd; + UINT bIsDisabled; + + if(!(pWnd = UserGetWindowObject(hWnd))) + { + return FALSE; + } + + /* check if updating is needed */ + bIsDisabled = (pWnd->style & WS_DISABLED); + Update = bIsDisabled; + + if (bEnable) + { + pWnd->style &= ~WS_DISABLED; + } + else + { + Update = !bIsDisabled; + + co_IntSendMessage( hWnd, WM_CANCELMODE, 0, 0); + + /* Remove keyboard focus from that window if it had focus */ + if (hWnd == IntGetThreadFocusWindow()) + { + co_UserSetFocus(NULL); + } + pWnd->style |= WS_DISABLED; + } + + if (Update) + { + IntNotifyWinEvent(EVENT_OBJECT_STATECHANGE, pWnd, OBJID_WINDOW, CHILDID_SELF, 0); + co_IntSendMessage(hWnd, WM_ENABLE, (LPARAM)bEnable, 0); + } + // Return nonzero if it was disabled, or zero if it wasn't: + return bIsDisabled; +} + /* * IntWinListChildren * From 550e976e243ed90dfacb0f97e2264e5b60f9d66f Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 30 Mar 2011 11:05:40 +0000 Subject: [PATCH 33/66] [NTOS/KE] - Clear KernelApcPending flag every time the Kernel APCs queue is not empty. svn path=/trunk/; revision=51204 --- reactos/ntoskrnl/ke/apc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reactos/ntoskrnl/ke/apc.c b/reactos/ntoskrnl/ke/apc.c index 53f19f1a271..c4bab2a4c02 100644 --- a/reactos/ntoskrnl/ke/apc.c +++ b/reactos/ntoskrnl/ke/apc.c @@ -340,6 +340,9 @@ KiDeliverApc(IN KPROCESSOR_MODE DeliveryMode, break; } + /* Kernel APC is not pending anymore */ + Thread->ApcState.KernelApcPending = FALSE; + /* Get the next Entry */ ApcListEntry = Thread->ApcState.ApcListHead[KernelMode].Flink; Apc = CONTAINING_RECORD(ApcListEntry, KAPC, ApcListEntry); From e37934bec0074e234365b1e2e4466eee0bc011bf Mon Sep 17 00:00:00 2001 From: Gabriel Ilardi Date: Wed, 30 Mar 2011 13:02:57 +0000 Subject: [PATCH 34/66] [CMD] Fix a typo in dir that led to omitting the last character in the AM/PM time format. See issue #6061 for more details. svn path=/trunk/; revision=51205 --- reactos/base/shell/cmd/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/base/shell/cmd/dir.c b/reactos/base/shell/cmd/dir.c index ce1e5657771..e648f0cbde4 100644 --- a/reactos/base/shell/cmd/dir.c +++ b/reactos/base/shell/cmd/dir.c @@ -680,10 +680,10 @@ FormatTime(TCHAR *lpTime, LPSYSTEMTIME dt) { case 0: /* 12 hour format */ default: - return _stprintf(lpTime,_T("%02d%c%02u%c"), + return _stprintf(lpTime,_T("%02d%c%02u %cM"), (dt->wHour == 0 ? 12 : (dt->wHour <= 12 ? dt->wHour : dt->wHour - 12)), cTimeSeparator, - dt->wMinute, (dt->wHour <= 11 ? _T('a') : _T('p'))); + dt->wMinute, (dt->wHour <= 11 ? _T('A') : _T('P'))); break; case 1: /* 24 hour format */ From 5882dc90387a8eb351e39f318f797b4c7ea69955 Mon Sep 17 00:00:00 2001 From: Olaf Siejka Date: Wed, 30 Mar 2011 18:49:01 +0000 Subject: [PATCH 35/66] [DESK] - Translation patch by Adam "Saibamen" Stachowicz. See issue #6057 for more details. [EXPLORER] - Translation patch by Adam "Saibamen" Stachowicz. [SERVMAN] - Translation patch by Adam "Saibamen" Stachowicz. [SHELL32] - Translation patch by Adam "Saibamen" Stachowicz. See issue #6060 for more details. svn path=/trunk/; revision=51206 --- .../base/applications/mscutils/servman/lang/pl-PL.rc | 11 ++++++----- reactos/base/shell/explorer/explorer-pl.rc | 4 ++-- reactos/dll/cpl/desk/lang/pl-PL.rc | 11 ++++++----- reactos/dll/win32/shell32/lang/pl-PL.rc | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/reactos/base/applications/mscutils/servman/lang/pl-PL.rc b/reactos/base/applications/mscutils/servman/lang/pl-PL.rc index ea785ed3433..df0759c7e9f 100644 --- a/reactos/base/applications/mscutils/servman/lang/pl-PL.rc +++ b/reactos/base/applications/mscutils/servman/lang/pl-PL.rc @@ -4,6 +4,7 @@ * https://sourceforge.net/projects/reactospl * * updated by Caemyr - Olaf Siejka (Jan, 2008) + * updated by Saibamen - Adam Stachowicz (Mar, 2011) */ LANGUAGE LANG_POLISH, SUBLANG_DEFAULT @@ -46,7 +47,7 @@ BEGIN POPUP "Pomoc" BEGIN MENUITEM "Pomoc", ID_HELP - MENUITEM "Servman - informacje", ID_ABOUT + MENUITEM "O programie", ID_ABOUT END END @@ -72,11 +73,11 @@ BEGIN END IDD_ABOUTBOX DIALOGEX 22,16,190,182 -CAPTION "Service Manager - informacje" +CAPTION "Meneder Usug - informacje" FONT 8, "MS Shell Dlg",0,0 STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME BEGIN - LTEXT "Service Manager v0.5.1\nCopyright (C) 2005-2006\nby Ged Murphy (gedmurphy@gmail.com)", IDC_STATIC, 48, 7, 135, 26 + LTEXT "Meneder Usug v0.5.1\nCopyright (C) 2005-2006\nby Ged Murphy (gedmurphy@gmail.com)", IDC_STATIC, 48, 7, 135, 26 PUSHBUTTON "Zamknij", IDOK, 75, 162, 44, 15 ICON IDI_SM_ICON, IDC_STATIC, 10, 10, 7, 30 EDITTEXT IDC_LICENSE_EDIT, 8, 44, 174, 107, WS_VISIBLE | WS_VSCROLL | WS_TABSTOP | ES_READONLY | ES_MULTILINE @@ -198,8 +199,8 @@ END STRINGTABLE DISCARDABLE BEGIN IDS_NUM_SERVICES "Numer usugi: %d" - IDS_STOP_DEPENDS "When %s stops, these other services will also stop" - IDS_NO_DEPENDS "" + IDS_STOP_DEPENDS "Kiedy %s si zatrzyma, inne usugi rwnie si zatrzymaj" + IDS_NO_DEPENDS "" IDS_LICENSE "Niniejszy program jest wolnym oprogramowaniem; moesz go rozprowadza dalej i/lub modyfikowa na warunkach Powszechnej Licencji Publicznej GNU, wydanej przez Fundacj Wolnego Oprogramowania - wedug wersji 2 tej Licencji lub (wedug Twojego wyboru) ktrej z pniejszych wersji.\r\n\r\nNiniejszy program rozpowszechniany jest z nadziej, i bdzie on uyteczny - jednak BEZ JAKIEJKOLWIEK GWARANCJI, nawet domylnej gwarancji PRZYDATNOCI HANDLOWEJ albo PRZYDATNOCI DO OKRELONYCH ZASTOSOWA. W celu uzyskania bliszych informacji signij do Powszechnej Licencji Publicznej GNU.\r\n\r\nZ pewnoci wraz z niniejszym programem otrzymae te egzemplarz Powszechnej Licencji Publicznej GNU (GNU General Public License); jeli nie - napisz do Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA." END diff --git a/reactos/base/shell/explorer/explorer-pl.rc b/reactos/base/shell/explorer/explorer-pl.rc index 06a142d5ae3..9dad38a8f7a 100644 --- a/reactos/base/shell/explorer/explorer-pl.rc +++ b/reactos/base/shell/explorer/explorer-pl.rc @@ -381,8 +381,8 @@ BEGIN IDS_DESKTOPBAR_SETTINGS "Waciwoci pulpitu" IDS_DESKTOP "Pulpit" IDS_TASKBAR "Pasek zada" - IDS_NAMECOLUMN "Name" - IDS_PATHCOLUMN "Path" + IDS_NAMECOLUMN "Nazwa" + IDS_PATHCOLUMN "cieka" IDS_MENUCOLUMN "Menu path" END diff --git a/reactos/dll/cpl/desk/lang/pl-PL.rc b/reactos/dll/cpl/desk/lang/pl-PL.rc index 80c38df7b7d..50f6ef58b4c 100644 --- a/reactos/dll/cpl/desk/lang/pl-PL.rc +++ b/reactos/dll/cpl/desk/lang/pl-PL.rc @@ -7,6 +7,7 @@ * Use ReactOS forum PM or IRC to contact me * http://www.reactos.org * IRC: irc.freenode.net #reactos-pl; +* update by Saibamen saibamenppl@gmail.com (29.03.2011) */ LANGUAGE LANG_POLISH, SUBLANG_DEFAULT @@ -217,11 +218,11 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_COLOR_4BIT "16 kolorw (4 Bity)" - IDS_COLOR_8BIT "256 kolorw (8 Bitw)" - IDS_COLOR_16BIT "65,536 kolorw (16 Bitw)" - IDS_COLOR_24BIT "16,777,216 kolorw (24 Bitw)" - IDS_COLOR_32BIT "16,777,216 kolorw (32 Bity)" + IDS_COLOR_4BIT "16 kolorw" + IDS_COLOR_8BIT "256 kolorw" + IDS_COLOR_16BIT "High Color (16 Bitw)" + IDS_COLOR_24BIT "True Color (24 Bitw)" + IDS_COLOR_32BIT "True Color (32 Bity)" IDS_PIXEL "%lux%lu pikseli" END diff --git a/reactos/dll/win32/shell32/lang/pl-PL.rc b/reactos/dll/win32/shell32/lang/pl-PL.rc index cb33116bd45..588990e6fe3 100644 --- a/reactos/dll/win32/shell32/lang/pl-PL.rc +++ b/reactos/dll/win32/shell32/lang/pl-PL.rc @@ -223,7 +223,7 @@ BEGIN LTEXT "", 14011, 68, 93, 160, 10 LTEXT "Utworzony:", 14014, 8, 118, 45, 10 LTEXT "", 14015, 68, 118, 160, 10 - AUTOCHECKBOX "&Tylko-do-odczytu", 14021, 45, 150, 67, 10 + AUTOCHECKBOX "&Tylko do odczytu", 14021, 45, 150, 67, 10 AUTOCHECKBOX "&Ukryty", 14022, 126, 150, 50, 10 END From b94139f67f9a2d37033c36cd1c3738cd16563a52 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 30 Mar 2011 20:56:05 +0000 Subject: [PATCH 36/66] [NTDLL] - Add RtlDosApplyFileIsolationRedirection_Ustr() stub. svn path=/trunk/; revision=51207 --- reactos/dll/ntdll/rtl/libsupp.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/reactos/dll/ntdll/rtl/libsupp.c b/reactos/dll/ntdll/rtl/libsupp.c index 4239183c436..f3e685c10af 100644 --- a/reactos/dll/ntdll/rtl/libsupp.c +++ b/reactos/dll/ntdll/rtl/libsupp.c @@ -519,3 +519,22 @@ RtlPcToFileHeader(IN PVOID PcValue, *BaseOfImage = ImageBase; return ImageBase; } + +NTSYSAPI +NTSTATUS +NTAPI +RtlDosApplyFileIsolationRedirection_Ustr( + IN BOOLEAN Unknown, + IN PUNICODE_STRING OriginalName, + IN PUNICODE_STRING Extension, + IN OUT PUNICODE_STRING RedirectedName, + IN OUT PUNICODE_STRING RedirectedName2, + IN OUT PUNICODE_STRING *OriginalName2, + IN PVOID Unknown1, + IN PVOID Unknown2, + IN PVOID Unknown3 +) +{ + return STATUS_SXS_KEY_NOT_FOUND; +} + From b98f8ccd88bace66631c6635c99f223a6b50298e Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 30 Mar 2011 21:21:42 +0000 Subject: [PATCH 37/66] [NTDLL] - Implement LdrEnumerateLoadedModules(). svn path=/trunk/; revision=51208 --- reactos/dll/ntdll/def/ntdll.pspec | 2 +- reactos/dll/ntdll/ldr/ldrapi.c | 62 +++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/reactos/dll/ntdll/def/ntdll.pspec b/reactos/dll/ntdll/def/ntdll.pspec index f9027dda2a1..2c5de04b8d1 100644 --- a/reactos/dll/ntdll/def/ntdll.pspec +++ b/reactos/dll/ntdll/def/ntdll.pspec @@ -77,7 +77,7 @@ //@ stdcall LdrDestroyOutOfProcessImage @ stdcall LdrDisableThreadCalloutsForDll(long) @ stdcall LdrEnumResources(ptr ptr long ptr ptr) -//@ stdcall LdrEnumerateLoadedModules +@ stdcall LdrEnumerateLoadedModules(long ptr long) //@ stdcall LdrFindCreateProcessManifest // 5.1 and 5.2 only @ stdcall LdrFindEntryForAddress(ptr ptr) @ stdcall LdrFindResourceDirectory_U(long ptr long ptr) diff --git a/reactos/dll/ntdll/ldr/ldrapi.c b/reactos/dll/ntdll/ldr/ldrapi.c index 0a19351dab8..ad56964d7ea 100644 --- a/reactos/dll/ntdll/ldr/ldrapi.c +++ b/reactos/dll/ntdll/ldr/ldrapi.c @@ -530,4 +530,66 @@ LdrQueryProcessModuleInformation(IN PRTL_PROCESS_MODULES ModuleInformation, return LdrQueryProcessModuleInformationEx(0, 0, ModuleInformation, Size, ReturnedSize); } +NTSTATUS +NTAPI +LdrEnumerateLoadedModules(BOOLEAN ReservedFlag, PLDR_ENUM_CALLBACK EnumProc, ULONG Context) +{ + PLIST_ENTRY ListHead, ListEntry; + PLDR_DATA_TABLE_ENTRY LdrEntry; + NTSTATUS Status; + ULONG Cookie; + BOOLEAN Stop = FALSE; + + /* Check parameters */ + if (ReservedFlag || !EnumProc) return STATUS_INVALID_PARAMETER; + + /* Acquire the loader lock */ + Status = LdrLockLoaderLock(0, NULL, &Cookie); + if (!NT_SUCCESS(Status)) return Status; + + /* Loop all the modules and call enum proc */ + ListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList; + ListEntry = ListHead->Flink; + while (ListHead != ListEntry) + { + /* Get the entry */ + LdrEntry = CONTAINING_RECORD(ListEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); + + /* Call the enumeration proc inside SEH */ + _SEH2_TRY + { + EnumProc(LdrEntry, Context, &Stop); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + /* Ignoring the exception */ + } _SEH2_END; + + /* Break if we were asked to stop enumeration */ + if (Stop) + { + /* Release loader lock */ + Status = LdrUnlockLoaderLock(0, Cookie); + + /* Reset any successful status to STATUS_SUCCESS, but leave + failure to the caller */ + if (NT_SUCCESS(Status)) + Status = STATUS_SUCCESS; + + /* Return any possible failure status */ + return Status; + } + + /* Advance to the next module */ + ListEntry = ListEntry->Flink; + } + + /* Release loader lock, it must succeed this time */ + Status = LdrUnlockLoaderLock(0, Cookie); + ASSERT(NT_SUCCESS(Status)); + + /* Return success */ + return STATUS_SUCCESS; +} + /* EOF */ From c7b59706ce6c8c907773fcf8559e498af6d22a46 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 30 Mar 2011 21:33:57 +0000 Subject: [PATCH 38/66] - Fix build. svn path=/trunk/; revision=51209 --- reactos/include/ndk/ldrfuncs.h | 8 ++++++++ reactos/include/ndk/ldrtypes.h | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/reactos/include/ndk/ldrfuncs.h b/reactos/include/ndk/ldrfuncs.h index 743d213b87e..8b967fa8e3d 100644 --- a/reactos/include/ndk/ldrfuncs.h +++ b/reactos/include/ndk/ldrfuncs.h @@ -118,4 +118,12 @@ LdrProcessRelocationBlockLongLong( IN LONGLONG Delta ); +NTSTATUS +NTAPI +LdrEnumerateLoadedModules( + IN BOOLEAN ReservedFlag, + IN PLDR_ENUM_CALLBACK EnumProc, + IN ULONG Context +); + #endif diff --git a/reactos/include/ndk/ldrtypes.h b/reactos/include/ndk/ldrtypes.h index d706fec93e3..fbfa381638b 100644 --- a/reactos/include/ndk/ldrtypes.h +++ b/reactos/include/ndk/ldrtypes.h @@ -188,4 +188,10 @@ typedef struct _ALT_RESOURCE_MODULE #endif } ALT_RESOURCE_MODULE, *PALT_RESOURCE_MODULE; +// +// Callback function for LdrEnumerateLoadedModules +// +typedef NTSTATUS (NTAPI LDR_ENUM_CALLBACK)(IN PLDR_DATA_TABLE_ENTRY ModuleInformation, IN ULONG Parameter, OUT BOOLEAN *Stop); +typedef LDR_ENUM_CALLBACK *PLDR_ENUM_CALLBACK; + #endif From 73b6d5b3d6b70d5ae9074b78a727de02b7ce7aaf Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 31 Mar 2011 11:32:57 +0000 Subject: [PATCH 39/66] [NTDLL] - Change Context/Parameter in LdrEnumerateLoadedModules() to PVOID (previous ULONG type was a typo). svn path=/trunk/; revision=51210 --- reactos/dll/ntdll/ldr/ldrapi.c | 2 +- reactos/include/ndk/ldrfuncs.h | 2 +- reactos/include/ndk/ldrtypes.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/reactos/dll/ntdll/ldr/ldrapi.c b/reactos/dll/ntdll/ldr/ldrapi.c index ad56964d7ea..9b697ca9a0e 100644 --- a/reactos/dll/ntdll/ldr/ldrapi.c +++ b/reactos/dll/ntdll/ldr/ldrapi.c @@ -532,7 +532,7 @@ LdrQueryProcessModuleInformation(IN PRTL_PROCESS_MODULES ModuleInformation, NTSTATUS NTAPI -LdrEnumerateLoadedModules(BOOLEAN ReservedFlag, PLDR_ENUM_CALLBACK EnumProc, ULONG Context) +LdrEnumerateLoadedModules(BOOLEAN ReservedFlag, PLDR_ENUM_CALLBACK EnumProc, PVOID Context) { PLIST_ENTRY ListHead, ListEntry; PLDR_DATA_TABLE_ENTRY LdrEntry; diff --git a/reactos/include/ndk/ldrfuncs.h b/reactos/include/ndk/ldrfuncs.h index 8b967fa8e3d..1bf8a83d32c 100644 --- a/reactos/include/ndk/ldrfuncs.h +++ b/reactos/include/ndk/ldrfuncs.h @@ -123,7 +123,7 @@ NTAPI LdrEnumerateLoadedModules( IN BOOLEAN ReservedFlag, IN PLDR_ENUM_CALLBACK EnumProc, - IN ULONG Context + IN PVOID Context ); #endif diff --git a/reactos/include/ndk/ldrtypes.h b/reactos/include/ndk/ldrtypes.h index fbfa381638b..49ebe38cd55 100644 --- a/reactos/include/ndk/ldrtypes.h +++ b/reactos/include/ndk/ldrtypes.h @@ -191,7 +191,7 @@ typedef struct _ALT_RESOURCE_MODULE // // Callback function for LdrEnumerateLoadedModules // -typedef NTSTATUS (NTAPI LDR_ENUM_CALLBACK)(IN PLDR_DATA_TABLE_ENTRY ModuleInformation, IN ULONG Parameter, OUT BOOLEAN *Stop); +typedef NTSTATUS (NTAPI LDR_ENUM_CALLBACK)(IN PLDR_DATA_TABLE_ENTRY ModuleInformation, IN PVOID Parameter, OUT BOOLEAN *Stop); typedef LDR_ENUM_CALLBACK *PLDR_ENUM_CALLBACK; #endif From ddbfebc22a6e69bfe14c2a2f8e11cc035010f94d Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Thu, 31 Mar 2011 15:56:24 +0000 Subject: [PATCH 40/66] [SYSTEMINFO] Convert TABs to spaces Print output to stdout instead of stderr Close opened registry keys Simplify a bit Add System Manufacturer and System Model Add System Up Time (patch by Edijs Kolesnikovics , see issue 6055 for more details) svn path=/trunk/; revision=51212 --- .../sysutils/systeminfo/lang/de-DE.rc | 4 +- .../sysutils/systeminfo/lang/en-US.rc | 4 +- .../sysutils/systeminfo/lang/es-ES.rc | 4 +- .../sysutils/systeminfo/lang/fr-FR.rc | 4 +- .../sysutils/systeminfo/lang/no-NO.rc | 4 +- .../sysutils/systeminfo/lang/pl-PL.rc | 6 +- .../sysutils/systeminfo/lang/sk-SK.rc | 4 +- .../sysutils/systeminfo/lang/uk-UA.rc | 4 +- .../sysutils/systeminfo/resource.h | 14 +- .../sysutils/systeminfo/systeminfo.c | 547 +++++++++--------- 10 files changed, 299 insertions(+), 296 deletions(-) diff --git a/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc b/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc index bcb637853bd..3ee3ac425d7 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc @@ -32,11 +32,11 @@ Beispiele:\n\ SYSTEMINFO /S system /FO CSV /NH\n" IDS_OS_NAME, "OS Name: %s\n" -IDS_OS_VERSION, "OS Version: %d.%d.%d %s" -IDS_OS_BUILD, " Build %s\n" +IDS_OS_VERSION, "OS Version: %u.%u.%u %s Build %u\n" IDS_OS_BUILD_TYPE, "OS Build Typ: %s\n" IDS_REG_OWNER, "Registrierter Benutzer: %s\n" IDS_REG_ORG, "Registrierte Organisation: %s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_PRODUCT_ID, "Produkt ID: %s\n" IDS_INST_DATE, "Installationsdatum: %s, " IDS_INST_TIME, "%s\n" diff --git a/rosapps/applications/sysutils/systeminfo/lang/en-US.rc b/rosapps/applications/sysutils/systeminfo/lang/en-US.rc index 503e6912aa4..005fa713f1b 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/en-US.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/en-US.rc @@ -30,11 +30,11 @@ Examples:\n\ SYSTEMINFO /S system /FO CSV /NH\n" IDS_OS_NAME, "OS Name: %s\n" -IDS_OS_VERSION, "OS Version: %d.%d.%d %s" -IDS_OS_BUILD, " Build %s\n" +IDS_OS_VERSION, "OS Version: %u.%u.%u %s Build %u\n" IDS_OS_BUILD_TYPE, "OS Build Type: %s\n" IDS_REG_OWNER, "Registered Owner: %s\n" IDS_REG_ORG, "Registered Organization: %s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_PRODUCT_ID, "Product ID: %s\n" IDS_INST_DATE, "Install Date: %s, " IDS_INST_TIME, "%s\n" diff --git a/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc b/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc index 13e3589c2fe..eabccc4cc04 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc @@ -35,11 +35,11 @@ Ejemplos:\n\ SYSTEMINFO /S sistema /FO CSV /NH\n" IDS_OS_NAME, "Nombre Sistema Operativo: %s\n" -IDS_OS_VERSION, "Versin Sistema Operativo: %d.%d.%d %s" -IDS_OS_BUILD, " Compilacin %s\n" +IDS_OS_VERSION, "Versin Sistema Operativo: %u.%u.%u %s Compilacin %u\n" IDS_OS_BUILD_TYPE, "Tipo Compilacin: %s\n" IDS_REG_OWNER, "Propietario: %s\n" IDS_REG_ORG, "Organizacin: %s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_PRODUCT_ID, "Identificador de Producto %s\n" IDS_INST_DATE, "Fecha de Instalacin: %s, " IDS_INST_TIME, "%s\n" diff --git a/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc b/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc index fdf0b2cf8ac..aacdbdf80c2 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc @@ -30,11 +30,11 @@ Exemples:\n\ SYSTEMINFO /S systme /FO CSV /NH\n" IDS_OS_NAME, "Nom du systme d'exploitation : %s\n" -IDS_OS_VERSION, "Version du systme d'exploitation : %d.%d.%d %s" -IDS_OS_BUILD, " Compilation %s\n" +IDS_OS_VERSION, "Version du systme d'exploitation : %u.%u.%u %s Compilation %u\n" IDS_OS_BUILD_TYPE, "Type de compilation du systme d'exploitation : %s\n" IDS_REG_OWNER, "Propritaire enregistr : %s\n" IDS_REG_ORG, "Organisation enregistre : %s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_PRODUCT_ID, "ID du produit : %s\n" IDS_INST_DATE, "Date d'installation : %s, " IDS_INST_TIME, "%s\n" diff --git a/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc b/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc index 2f862a3a18f..f541156c496 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc @@ -30,11 +30,11 @@ Eksempler:\n\ SYSTEMINFO /S system /FO CSV /NH\n" IDS_OS_NAME, "OS navn: %s\n" -IDS_OS_VERSION, "OS versjon: %d.%d.%d %s" -IDS_OS_BUILD, " Bygget %s\n" +IDS_OS_VERSION, "OS versjon: %u.%u.%u %s Bygget %u\n" IDS_OS_BUILD_TYPE, "OS bygg type: %s\n" IDS_REG_OWNER, "Registert eier: %s\n" IDS_REG_ORG, "Registerert organisasjon: %s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_PRODUCT_ID, "Produkt ID: %s\n" IDS_INST_DATE, "Installert dato: %s, " IDS_INST_TIME, "%s\n" diff --git a/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc b/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc index 69cd7543400..53a421dcf12 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc @@ -37,11 +37,11 @@ Przyk SYSTEMINFO /S system /FO CSV /NH\n" IDS_OS_NAME, "Nazwa Systemu: %s\n" -IDS_OS_VERSION, "Wersja: %d.%d.%d %s" -IDS_OS_BUILD, " Kompilacja %s\n" +IDS_OS_VERSION, "Wersja: %u.%u.%u %s Kompilacja %u\n" IDS_OS_BUILD_TYPE, "Rodzaj kompilacji: %s\n" IDS_REG_OWNER, "Uytkownik: %s\n" IDS_REG_ORG, "Organizacja: %s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_PRODUCT_ID, "ID produktu: %s\n" IDS_INST_DATE, "Data instalacji: %s, " IDS_INST_TIME, "%s\n" @@ -49,7 +49,7 @@ IDS_SYS_TYPE_UNKNOWN, "Rodzaj systemu: Unknown\n" IDS_SYS_TYPE_X86, "Architektura: X86-based PC\n" IDS_SYS_TYPE_IA64, "Architektura: IA64-based PC\n" IDS_SYS_TYPE_AMD64, "Rodzaj systemu: AMD64-based PC\n" -IDS_PROCESSORS, "Ilo Procesorw: %u .\n" +IDS_PROCESSORS, "Ilo Procesorw: %u.\n" IDS_ROS_DIR, "Katalog ReactOS: %s\n" IDS_SYS_DIR, "Katalog Systemowy: %s\n" IDS_BOOT_DEV, "Urzdzenie rdowe: %s\n" diff --git a/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc b/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc index abdb09d00c2..a4b87232f69 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc @@ -34,11 +34,11 @@ Examples:\n\ SYSTEMINFO /S system /FO CSV /NH\n" IDS_OS_NAME, "Nzov OS: %s\n" -IDS_OS_VERSION, "Verzia OS: %d.%d.%d %s" -IDS_OS_BUILD, " Build %s\n" +IDS_OS_VERSION, "Verzia OS: %u.%u.%u %s Build %u\n" IDS_OS_BUILD_TYPE, "OS Build typ: %s\n" IDS_REG_OWNER, "Registovan vlastnk: %s\n" IDS_REG_ORG, "Registrovan organizcia: %s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_PRODUCT_ID, "ID produktu: %s\n" IDS_INST_DATE, "Dtum intalcie: %s, " IDS_INST_TIME, "%s\n" diff --git a/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc b/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc index 3dc62009d51..e0f96369ad3 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc @@ -38,11 +38,11 @@ IDS_USAGE, "SYSTEMINFO [/S SYSTEMINFO /S /FO CSV /NH\n" IDS_OS_NAME, "' : %s\n" -IDS_OS_VERSION, " : %d.%d.%d %s" -IDS_OS_BUILD, " %s\n" +IDS_OS_VERSION, " : %u.%u.%u %s %u\n" IDS_OS_BUILD_TYPE, " : %s\n" IDS_REG_OWNER, " : %s\n" IDS_REG_ORG, " : %s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_PRODUCT_ID, "ID : %s\n" IDS_INST_DATE, " : %s, " IDS_INST_TIME, "%s\n" diff --git a/rosapps/applications/sysutils/systeminfo/resource.h b/rosapps/applications/sysutils/systeminfo/resource.h index a8499d52eec..4942b4739cc 100644 --- a/rosapps/applications/sysutils/systeminfo/resource.h +++ b/rosapps/applications/sysutils/systeminfo/resource.h @@ -2,13 +2,13 @@ #define IDS_OS_NAME 100 #define IDS_OS_VERSION 101 -#define IDS_OS_BUILD 102 -#define IDS_OS_BUILD_TYPE 103 -#define IDS_REG_OWNER 104 -#define IDS_REG_ORG 105 -#define IDS_PRODUCT_ID 106 -#define IDS_INST_DATE 107 -#define IDS_INST_TIME 108 +#define IDS_OS_BUILD_TYPE 102 +#define IDS_REG_OWNER 103 +#define IDS_REG_ORG 104 +#define IDS_PRODUCT_ID 105 +#define IDS_INST_DATE 106 +#define IDS_INST_TIME 107 +#define IDS_UP_TIME 108 #define IDS_SYS_TYPE_UNKNOWN 109 #define IDS_SYS_TYPE_X86 110 #define IDS_SYS_TYPE_IA64 111 diff --git a/rosapps/applications/sysutils/systeminfo/systeminfo.c b/rosapps/applications/sysutils/systeminfo/systeminfo.c index d641c200da0..3231732a569 100644 --- a/rosapps/applications/sysutils/systeminfo/systeminfo.c +++ b/rosapps/applications/sysutils/systeminfo/systeminfo.c @@ -21,23 +21,26 @@ #include #include #include +#include #include "resource.h" #define BUFFER_SIZE 32767 +#define B_TO_MB(bytes) ((bytes)/(1024*1024)) +#define B_TO_KB(bytes) ((bytes)/1024) /* Load from resource and convert to OEM */ static BOOL GetOemStrings(UINT rcID, LPSTR OutMsg) { - TCHAR Msg[BUFFER_SIZE]; - if (LoadString(GetModuleHandle(NULL), rcID, (LPTSTR)Msg, BUFFER_SIZE)) - { - CharToOem(Msg, OutMsg); - return TRUE; - } - return FALSE; + TCHAR Msg[BUFFER_SIZE]; + if (LoadString(GetModuleHandle(NULL), rcID, (LPTSTR)Msg, BUFFER_SIZE)) + { + CharToOem(Msg, OutMsg); + return TRUE; + } + return FALSE; } /* Load data from registry */ @@ -45,25 +48,25 @@ static BOOL GetRegistryValue(HKEY hKeyName, LPCTSTR SubKey, LPCTSTR ValueName, LPCTSTR Buf) { - DWORD CharCount = BUFFER_SIZE; - HKEY hKey; - LONG lRet; + DWORD CharCount = BUFFER_SIZE; + HKEY hKey; + LONG lRet; - CharCount = BUFFER_SIZE; - lRet = RegOpenKeyEx(hKeyName, - SubKey, - 0, - KEY_QUERY_VALUE, - &hKey); - if (lRet != ERROR_SUCCESS) return FALSE; - lRet = RegQueryValueEx(hKey, - ValueName, - NULL, - NULL, - (LPBYTE)Buf, - &CharCount); - if (lRet != ERROR_SUCCESS) return FALSE; - return TRUE; + lRet = RegOpenKeyEx(hKeyName, + SubKey, + 0, + KEY_QUERY_VALUE, + &hKey); + if (lRet != ERROR_SUCCESS) return FALSE; + lRet = RegQueryValueEx(hKey, + ValueName, + NULL, + NULL, + (LPBYTE)Buf, + &CharCount); + if (lRet != ERROR_SUCCESS) return FALSE; + RegCloseKey(hKey); + return TRUE; } /* Show usage */ @@ -71,298 +74,298 @@ static VOID Usage(VOID) { - TCHAR Buf[BUFFER_SIZE]; - if(GetOemStrings(IDS_USAGE,Buf)) printf("%s",Buf); + TCHAR Buf[BUFFER_SIZE]; + if(GetOemStrings(IDS_USAGE, Buf)) printf("%s",Buf); } /* Print all system information */ VOID AllSysInfo(VOID) { - DWORD CharCount = BUFFER_SIZE; - OSVERSIONINFO VersionInfo; - BOOL bOsVersionInfoEx; - SYSTEM_INFO SysInfo; - TCHAR Buf[BUFFER_SIZE],Tmp[BUFFER_SIZE], Msg[BUFFER_SIZE]; - MEMORYSTATUS memory; - unsigned int DIV = 1024; - TIME_ZONE_INFORMATION TimeZoneInfo; + DWORD dwCharCount = BUFFER_SIZE; + OSVERSIONINFO VersionInfo; + SYSTEM_INFO SysInfo; + TCHAR Buf[BUFFER_SIZE], Tmp[BUFFER_SIZE], Msg[BUFFER_SIZE], szSystemDir[MAX_PATH]; + MEMORYSTATUS MemoryStatus; + unsigned int cSeconds; + TIME_ZONE_INFORMATION TimeZoneInfo; - GetSystemInfo(&SysInfo); + if (!GetSystemDirectory(szSystemDir, sizeof(szSystemDir)/sizeof(szSystemDir[0]))) + printf("Error getting: GetSystemDirectory\n"); + GetSystemInfo(&SysInfo); - // getting computer name - CharCount = BUFFER_SIZE; - if(!GetComputerName(Buf,&CharCount)) printf("Error getting: GetComputerName"); - if(GetOemStrings(IDS_HOST_NAME,Msg)) fprintf(stderr,Msg,Buf); + // getting computer name + dwCharCount = BUFFER_SIZE; + if (!GetComputerName(Buf, &dwCharCount)) + printf("Error getting: GetComputerName"); + if (GetOemStrings(IDS_HOST_NAME, Msg)) + printf(Msg, Buf); - //getting OS Name - GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - TEXT("ProductName"), - Buf); - if(GetOemStrings(IDS_OS_NAME,Msg)) fprintf(stderr,Msg,Buf); + //getting OS Name + GetRegistryValue(HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), + TEXT("ProductName"), + Buf); + if (GetOemStrings(IDS_OS_NAME, Msg)) printf(Msg, Buf); - //getting OS Version - ZeroMemory(&VersionInfo, sizeof(OSVERSIONINFO)); - VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if(!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*)&VersionInfo))) - { - VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (!GetVersionEx((OSVERSIONINFO*)&VersionInfo)) - return; - } - if (VersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) - { - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - TEXT("CSDVersion"), - Buf)) - if(GetOemStrings(IDS_OS_VERSION,Msg)) - fprintf(stderr, Msg, - (int)VersionInfo.dwMajorVersion, - (int)VersionInfo.dwMinorVersion, - (int)VersionInfo.dwBuildNumber, - Buf); - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - TEXT("CurrentBuildNumber"), - Buf)) - if(GetOemStrings(IDS_OS_BUILD,Msg)) fprintf(stderr,Msg,Buf); - } + //getting OS Version + ZeroMemory(&VersionInfo, sizeof(VersionInfo)); + VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo); + GetVersionEx(&VersionInfo); + + if (GetOemStrings(IDS_OS_VERSION, Msg)) + printf(Msg, + (unsigned)VersionInfo.dwMajorVersion, + (unsigned)VersionInfo.dwMinorVersion, + (unsigned)VersionInfo.dwBuildNumber, + VersionInfo.szCSDVersion, + (unsigned)VersionInfo.dwBuildNumber); - //getting OS Manufacturer + //getting OS Manufacturer - //getting OS Configuration + //getting OS Configuration - //getting OS Build Type - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - TEXT("CurrentType"), - Buf)) - if(GetOemStrings(IDS_OS_BUILD_TYPE,Msg)) fprintf(stderr,Msg,Buf); + //getting OS Build Type + if (GetRegistryValue(HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), + TEXT("CurrentType"), + Buf)) + if (GetOemStrings(IDS_OS_BUILD_TYPE, Msg)) printf(Msg, Buf); - //getting Registered Owner - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - TEXT("RegisteredOwner"), - Buf)) - if(GetOemStrings(IDS_REG_OWNER,Msg)) fprintf(stderr,Msg,Buf); + //getting Registered Owner + if (GetRegistryValue(HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), + TEXT("RegisteredOwner"), + Buf)) + if (GetOemStrings(IDS_REG_OWNER, Msg)) printf(Msg, Buf); - //getting Registered Organization - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - TEXT("RegisteredOrganization"), - Buf)) - if(GetOemStrings(IDS_REG_ORG,Msg)) fprintf(stderr,Msg,Buf); + //getting Registered Organization + if (GetRegistryValue(HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), + TEXT("RegisteredOrganization"), + Buf)) + if (GetOemStrings(IDS_REG_ORG, Msg)) printf(Msg, Buf); - //getting Product ID - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - TEXT("ProductId"), - Buf)) - if(GetOemStrings(IDS_PRODUCT_ID,Msg)) fprintf(stderr,Msg,Buf); + //getting Product ID // use SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate + if (GetRegistryValue(HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), + TEXT("ProductId"), + Buf)) + if (GetOemStrings(IDS_PRODUCT_ID, Msg)) printf(Msg, Buf); - //getting Install Date - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\WBEM\\CIMOM"), - TEXT("SetupDate"), - Buf)) - if(GetOemStrings(IDS_INST_DATE,Msg)) fprintf(stderr,Msg,Buf); + //getting Install Date + if (GetRegistryValue(HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\WBEM\\CIMOM"), + TEXT("SetupDate"), + Buf)) + if (GetOemStrings(IDS_INST_DATE, Msg)) printf(Msg, Buf); - //getting Install Time - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\WBEM\\CIMOM"), - TEXT("SetupTime"), - Buf)) - if(GetOemStrings(IDS_INST_TIME,Msg)) fprintf(stderr,Msg,Buf); + //getting Install Time + if (GetRegistryValue(HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\WBEM\\CIMOM"), + TEXT("SetupTime"), + Buf)) + if (GetOemStrings(IDS_INST_TIME, Msg)) printf(Msg, Buf); - //getting System Up Time + //getting System Up Time + cSeconds = GetTickCount() / 1000; + if (GetOemStrings(IDS_UP_TIME, Msg)) + printf(Msg, cSeconds / (60*60*24), (cSeconds / (60*60)) % 24, (cSeconds / 60) % 60, cSeconds % 60); - //getting System Manufacturer + //getting System Manufacturer + sprintf(Tmp, "%s\\oeminfo.ini", szSystemDir); + GetPrivateProfileString(TEXT("General"), + TEXT("Manufacturer"), + TEXT("To Be Filled By O.E.M."), + Buf, + sizeof(Buf)/sizeof(Buf[0]), + Tmp); + printf("System Manufacturer:\t\t%s\n", Buf); - //getting System Model + //getting System Model + GetPrivateProfileString(TEXT("General"), + TEXT("Model"), + TEXT("To Be Filled By O.E.M."), + Buf, + sizeof(Buf)/sizeof(Buf[0]), + Tmp); + printf("System Model:\t\t\t%s\n", Buf); - //getting System type - switch (SysInfo.wProcessorArchitecture) - { - case PROCESSOR_ARCHITECTURE_UNKNOWN: - if(GetOemStrings(IDS_SYS_TYPE_UNKNOWN,Msg)) printf("%s",Msg); - break; - case PROCESSOR_ARCHITECTURE_INTEL: - if(GetOemStrings(IDS_SYS_TYPE_X86,Msg)) printf("%s",Msg); - break; - case PROCESSOR_ARCHITECTURE_IA64: - if(GetOemStrings(IDS_SYS_TYPE_IA64,Msg)) printf("%s",Msg); - break; - case PROCESSOR_ARCHITECTURE_AMD64: - if(GetOemStrings(IDS_SYS_TYPE_AMD64,Msg)) printf("%s",Msg); - break; - } + //getting System type + switch (SysInfo.wProcessorArchitecture) + { + case PROCESSOR_ARCHITECTURE_UNKNOWN: + if (GetOemStrings(IDS_SYS_TYPE_UNKNOWN, Msg)) printf("%s", Msg); + break; + case PROCESSOR_ARCHITECTURE_INTEL: + if (GetOemStrings(IDS_SYS_TYPE_X86, Msg)) printf("%s", Msg); + break; + case PROCESSOR_ARCHITECTURE_IA64: + if (GetOemStrings(IDS_SYS_TYPE_IA64, Msg)) printf("%s", Msg); + break; + case PROCESSOR_ARCHITECTURE_AMD64: + if (GetOemStrings(IDS_SYS_TYPE_AMD64, Msg)) printf("%s", Msg); + break; + } - //getting Processor(s) - if(GetOemStrings(IDS_PROCESSORS,Msg)) - { - unsigned int i; - fprintf(stderr,Msg,(unsigned int)SysInfo.dwNumberOfProcessors); - for(i = 0; i < (unsigned int)SysInfo.dwNumberOfProcessors; i++) - { - sprintf(Tmp,"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u",i); - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - (LPCTSTR)Tmp, - TEXT("Identifier"), - Buf)) - printf(" [0%u]: %s",i+1,Buf); - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - (LPCTSTR)Tmp, - TEXT("VendorIdentifier"), - Buf)) - printf(" %s\n",Buf); - } - } + //getting Processor(s) + if (GetOemStrings(IDS_PROCESSORS, Msg)) + { + unsigned int i; + printf(Msg, (unsigned int)SysInfo.dwNumberOfProcessors); + for(i = 0; i < (unsigned int)SysInfo.dwNumberOfProcessors; i++) + { + sprintf(Tmp,"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u",i); + if (GetRegistryValue(HKEY_LOCAL_MACHINE, + (LPCTSTR)Tmp, + TEXT("Identifier"), + Buf)) + printf(" [0%u]: %s", i+1, Buf); + if (GetRegistryValue(HKEY_LOCAL_MACHINE, + (LPCTSTR)Tmp, + TEXT("VendorIdentifier"), + Buf)) + printf(" %s\n", Buf); + } + } - //getting BIOS Version - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("HARDWARE\\DESCRIPTION\\System"), - TEXT("SystemBiosVersion"), - Buf)) - if(GetOemStrings(IDS_BIOS_VERSION,Msg)) fprintf(stderr,Msg,Buf); + //getting BIOS Version + if (GetRegistryValue(HKEY_LOCAL_MACHINE, + TEXT("HARDWARE\\DESCRIPTION\\System"), + TEXT("SystemBiosVersion"), + Buf)) + if (GetOemStrings(IDS_BIOS_VERSION, Msg)) printf(Msg, Buf); - //gettings BIOS date - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("HARDWARE\\DESCRIPTION\\System"), - TEXT("SystemBiosDate"), - Buf)) - if(GetOemStrings(IDS_BIOS_DATE,Msg)) fprintf(stderr,Msg,Buf); + //gettings BIOS date + if (GetRegistryValue(HKEY_LOCAL_MACHINE, + TEXT("HARDWARE\\DESCRIPTION\\System"), + TEXT("SystemBiosDate"), + Buf)) + if (GetOemStrings(IDS_BIOS_DATE, Msg)) printf(Msg, Buf); - //getting ReactOS Directory - if(!GetWindowsDirectory(Buf,BUFFER_SIZE)) printf("Error getting: GetWindowsDirectory"); - if(GetOemStrings(IDS_ROS_DIR,Msg)) fprintf(stderr,Msg,Buf); + //getting ReactOS Directory + if (!GetWindowsDirectory(Buf, BUFFER_SIZE)) printf("Error getting: GetWindowsDirectory"); + if (GetOemStrings(IDS_ROS_DIR, Msg)) printf(Msg, Buf); - //getting System Directory - if(!GetSystemDirectory(Buf,BUFFER_SIZE)) printf("Error getting: GetSystemDirectory"); - if(GetOemStrings(IDS_SYS_DIR,Msg)) fprintf(stderr,Msg,Buf); + //getting System Directory + if (GetOemStrings(IDS_SYS_DIR, Msg)) printf(Msg, szSystemDir); - //getting Boot Device - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SYSTEM\\Setup"), - TEXT("SystemPartition"), - Buf)) - if(GetOemStrings(IDS_BOOT_DEV,Msg)) fprintf(stderr,Msg,Buf); + //getting Boot Device + if (GetRegistryValue(HKEY_LOCAL_MACHINE, + TEXT("SYSTEM\\Setup"), + TEXT("SystemPartition"), + Buf)) + if (GetOemStrings(IDS_BOOT_DEV, Msg)) printf(Msg, Buf); - //getting System Locale - if (GetRegistryValue(HKEY_CURRENT_USER, - TEXT("Control Panel\\International"), - TEXT("Locale"), - Tmp)) - if (GetRegistryValue(HKEY_CLASSES_ROOT, - TEXT("MIME\\Database\\Rfc1766"), - (LPTSTR)Tmp, - Buf)) - if(GetOemStrings(IDS_SYS_LOCALE,Msg)) fprintf(stderr,Msg,Buf); + //getting System Locale + if (GetRegistryValue(HKEY_CURRENT_USER, + TEXT("Control Panel\\International"), + TEXT("Locale"), + Tmp)) + if (GetRegistryValue(HKEY_CLASSES_ROOT, + TEXT("MIME\\Database\\Rfc1766"), + (LPTSTR)Tmp, + Buf)) + if (GetOemStrings(IDS_SYS_LOCALE, Msg)) printf(Msg, Buf); - //getting Input Locale - if (GetRegistryValue(HKEY_CURRENT_USER, - TEXT("Keyboard Layout\\Preload"), - TEXT("1"), - Buf)) - { - int i,j; - for(j = 0, i = 4; i <= 8; j++, i++) Tmp[j] = Buf[i]; - if (GetRegistryValue(HKEY_CLASSES_ROOT, - TEXT("MIME\\Database\\Rfc1766"), - (LPTSTR)Tmp, - Buf)) - if(GetOemStrings(IDS_INPUT_LOCALE,Msg)) fprintf(stderr,Msg,Buf); - } + //getting Input Locale + if (GetRegistryValue(HKEY_CURRENT_USER, + TEXT("Keyboard Layout\\Preload"), + TEXT("1"), + Buf)) + { + int i,j; + for(j = 0, i = 4; i <= 8; j++, i++) Tmp[j] = Buf[i]; + if (GetRegistryValue(HKEY_CLASSES_ROOT, + TEXT("MIME\\Database\\Rfc1766"), + (LPTSTR)Tmp, + Buf)) + if (GetOemStrings(IDS_INPUT_LOCALE, Msg)) printf(Msg, Buf); + } - //getting Time Zone - GetTimeZoneInformation(&TimeZoneInfo); - sprintf(Tmp,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\%S",TimeZoneInfo.StandardName); - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - (LPCTSTR)Tmp, - TEXT("Display"), - Buf)) - if(GetOemStrings(IDS_TIME_ZONE,Msg)) fprintf(stderr,Msg,Buf); + //getting Time Zone + GetTimeZoneInformation(&TimeZoneInfo); + sprintf(Tmp,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\%S",TimeZoneInfo.StandardName); + if (GetRegistryValue(HKEY_LOCAL_MACHINE, + (LPCTSTR)Tmp, + TEXT("Display"), + Buf)) + if (GetOemStrings(IDS_TIME_ZONE, Msg)) printf(Msg, Buf); - //getting Total Physical Memory - GlobalMemoryStatus(&memory); - if(GetOemStrings(IDS_TOTAL_PHYS_MEM,Msg)) - fprintf(stderr, - Msg, - memory.dwTotalPhys/(DIV*DIV), - memory.dwTotalPhys/DIV); + //getting Total Physical Memory + GlobalMemoryStatus(&MemoryStatus); + if(GetOemStrings(IDS_TOTAL_PHYS_MEM, Msg)) + printf(Msg, + B_TO_MB(MemoryStatus.dwTotalPhys), + B_TO_KB(MemoryStatus.dwTotalPhys)); - //getting Available Physical Memory - if(GetOemStrings(IDS_AVAIL_PHISICAL_MEM,Msg)) - fprintf(stderr, - Msg, - memory.dwAvailPhys/(DIV*DIV), - memory.dwAvailPhys/DIV); + //getting Available Physical Memory + if(GetOemStrings(IDS_AVAIL_PHISICAL_MEM,Msg)) + printf(Msg, + B_TO_MB(MemoryStatus.dwAvailPhys), + B_TO_KB(MemoryStatus.dwAvailPhys)); - //getting Virtual Memory: Max Size - if(GetOemStrings(IDS_VIRT_MEM_MAX,Msg)) - fprintf(stderr, - Msg, - memory.dwTotalVirtual/(DIV*DIV), - memory.dwTotalVirtual/DIV); + //getting Virtual Memory: Max Size + if(GetOemStrings(IDS_VIRT_MEM_MAX, Msg)) + printf(Msg, + B_TO_MB(MemoryStatus.dwTotalVirtual), + B_TO_KB(MemoryStatus.dwTotalVirtual)); - //getting Virtual Memory: Available - if(GetOemStrings(IDS_VIRT_MEM_AVAIL,Msg)) - fprintf(stderr, - Msg, - memory.dwAvailVirtual/(DIV*DIV), - memory.dwAvailVirtual/DIV); + //getting Virtual Memory: Available + if(GetOemStrings(IDS_VIRT_MEM_AVAIL, Msg)) + printf(Msg, + B_TO_MB(MemoryStatus.dwAvailVirtual), + B_TO_KB(MemoryStatus.dwAvailVirtual)); - //getting Virtual Memory: In Use - if(GetOemStrings(IDS_VIRT_MEM_INUSE,Msg)) - fprintf(stderr, - Msg, - (memory.dwTotalVirtual-memory.dwAvailVirtual)/(DIV*DIV), - (memory.dwTotalVirtual-memory.dwAvailVirtual)/DIV); + //getting Virtual Memory: In Use + if(GetOemStrings(IDS_VIRT_MEM_INUSE, Msg)) + printf(Msg, + B_TO_MB(MemoryStatus.dwTotalVirtual-MemoryStatus.dwAvailVirtual), + B_TO_KB(MemoryStatus.dwTotalVirtual-MemoryStatus.dwAvailVirtual)); - //getting Page File Location(s) - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SYSTEM\\ControlSet001\\Control\\Session Manager\\Memory Management"), - TEXT("PagingFiles"), - Buf)) - { - int i; - for(i = 0; i < strlen((char*)Buf); i++) - { - if (Buf[i] == ' ') - { - Buf[i] = '\0'; - break; - } - } - if(GetOemStrings(IDS_PAGEFILE_LOC,Msg)) fprintf(stderr,Msg,Buf); - } + //getting Page File Location(s) + if (GetRegistryValue(HKEY_LOCAL_MACHINE, + TEXT("SYSTEM\\ControlSet001\\Control\\Session Manager\\Memory Management"), + TEXT("PagingFiles"), + Buf)) + { + int i; + for(i = 0; i < strlen((char*)Buf); i++) + { + if (Buf[i] == ' ') + { + Buf[i] = '\0'; + break; + } + } + if(GetOemStrings(IDS_PAGEFILE_LOC, Msg)) printf(Msg, Buf); + } - //getting Domain - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), - TEXT("CachePrimaryDomain"), - Buf)) - if(GetOemStrings(IDS_DOMINE,Msg)) fprintf(stderr,Msg,Buf); + //getting Domain + if (GetRegistryValue(HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), + TEXT("CachePrimaryDomain"), + Buf)) + if(GetOemStrings(IDS_DOMINE, Msg)) printf(Msg, Buf); - //getting Logon Server + //getting Logon Server - //getting NetWork Card(s) - if(GetOemStrings(IDS_NETWORK_CARDS,Msg)) - { + //getting NetWork Card(s) + if(GetOemStrings(IDS_NETWORK_CARDS, Msg)) + { - } + } } /* Main program */ int main(int argc, char *argv[]) { - if (argc > 1 && !strcmp(argv[1], "/?")) - { - Usage(); - return 0; - } - AllSysInfo(); - return 0; + if (argc > 1 && (!strcmp(argv[1], "/?") || !strcmp(argv[1], "-?"))) + { + Usage(); + return 0; + } + AllSysInfo(); + return 0; } From 62d4baba0355e19c17e4dcc76f62093db8dbb499 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Thu, 31 Mar 2011 16:16:10 +0000 Subject: [PATCH 41/66] [PSDK] - More header updates svn path=/trunk/; revision=51213 --- reactos/include/psdk/ksmedia.h | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/reactos/include/psdk/ksmedia.h b/reactos/include/psdk/ksmedia.h index 4873e1dbe64..1cde28039e2 100644 --- a/reactos/include/psdk/ksmedia.h +++ b/reactos/include/psdk/ksmedia.h @@ -348,6 +348,25 @@ typedef struct { WAVEFORMATEX WaveFormatEx; } KSDATAFORMAT_WAVEFORMATEX, *PKSDATAFORMAT_WAVEFORMATEX; +#ifndef _WAVEFORMATEXTENSIBLE_ +#define _WAVEFORMATEXTENSIBLE_ +typedef struct { + WAVEFORMATEX Format; + union + { + WORD wValidBitsPerSample; + WORD wSamplesPerBlock; + WORD wReserved; + }Samples; + DWORD dwChannelMask; + GUID SubFormat; +} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE; +#endif + +#if !defined(WAVE_FORMAT_EXTENSIBLE) +#define WAVE_FORMAT_EXTENSIBLE 0xFFFE +#endif + typedef struct { ULONG Flags; ULONG Control; @@ -734,4 +753,45 @@ typedef struct ULONG ChannelMask; } KSDATARANGE_MUSIC, *PKSDATARANGE_MUSIC; +#define SPEAKER_FRONT_LEFT 0x1 +#define SPEAKER_FRONT_RIGHT 0x2 +#define SPEAKER_FRONT_CENTER 0x4 +#define SPEAKER_LOW_FREQUENCY 0x8 +#define SPEAKER_BACK_LEFT 0x10 +#define SPEAKER_BACK_RIGHT 0x20 +#define SPEAKER_FRONT_LEFT_OF_CENTER 0x40 +#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80 +#define SPEAKER_BACK_CENTER 0x100 +#define SPEAKER_SIDE_LEFT 0x200 +#define SPEAKER_SIDE_RIGHT 0x400 +#define SPEAKER_TOP_CENTER 0x800 +#define SPEAKER_TOP_FRONT_LEFT 0x1000 +#define SPEAKER_TOP_FRONT_CENTER 0x2000 +#define SPEAKER_TOP_FRONT_RIGHT 0x4000 +#define SPEAKER_TOP_BACK_LEFT 0x8000 +#define SPEAKER_TOP_BACK_CENTER 0x10000 +#define SPEAKER_TOP_BACK_RIGHT 0x20000 + +#define SPEAKER_RESERVED 0x7FFC0000 +#define SPEAKER_ALL 0x80000000 + + +#if (NTDDI_VERSION >= NTDDI_WINXP) +#define KSAUDIO_SPEAKER_DIRECTOUT 0 +#endif + +#define KSAUDIO_SPEAKER_MONO (SPEAKER_FRONT_CENTER) +#define KSAUDIO_SPEAKER_STEREO (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT) +#define KSAUDIO_SPEAKER_QUAD (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | \ + SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT) +#define KSAUDIO_SPEAKER_SURROUND (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | \ + SPEAKER_FRONT_CENTER | SPEAKER_BACK_CENTER) +#define KSAUDIO_SPEAKER_5POINT1 (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | \ + SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | \ + SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT) +#define KSAUDIO_SPEAKER_7POINT1 (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | \ + SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | \ + SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | \ + SPEAKER_FRONT_LEFT_OF_CENTER | SPEAKER_FRONT_RIGHT_OF_CENTER) + #endif From 0a3b87a1efdb40cf1b6db33fa8c12c166949ed70 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Thu, 31 Mar 2011 16:21:38 +0000 Subject: [PATCH 42/66] - Fix build attempt #1 svn path=/trunk/; revision=51214 --- reactos/include/psdk/ksmedia.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/reactos/include/psdk/ksmedia.h b/reactos/include/psdk/ksmedia.h index 1cde28039e2..3860e73b33f 100644 --- a/reactos/include/psdk/ksmedia.h +++ b/reactos/include/psdk/ksmedia.h @@ -753,6 +753,10 @@ typedef struct ULONG ChannelMask; } KSDATARANGE_MUSIC, *PKSDATARANGE_MUSIC; +#ifndef _SPEAKER_POSITIONS_ +#define _SPEAKER_POSITIONS_ + + #define SPEAKER_FRONT_LEFT 0x1 #define SPEAKER_FRONT_RIGHT 0x2 #define SPEAKER_FRONT_CENTER 0x4 @@ -775,6 +779,7 @@ typedef struct #define SPEAKER_RESERVED 0x7FFC0000 #define SPEAKER_ALL 0x80000000 +#endif #if (NTDDI_VERSION >= NTDDI_WINXP) #define KSAUDIO_SPEAKER_DIRECTOUT 0 From 04afecea16343398d0755c255378433f286e1575 Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Thu, 31 Mar 2011 16:51:19 +0000 Subject: [PATCH 43/66] [SYSTEMINFO] Add System Manufacturer and System Model to resources Convert TABs to spaces in resources Sort strings in resources a bit svn path=/trunk/; revision=51215 --- .../sysutils/systeminfo/lang/de-DE.rc | 76 ++++++++-------- .../sysutils/systeminfo/lang/en-US.rc | 76 ++++++++-------- .../sysutils/systeminfo/lang/es-ES.rc | 76 ++++++++-------- .../sysutils/systeminfo/lang/fr-FR.rc | 76 ++++++++-------- .../sysutils/systeminfo/lang/no-NO.rc | 88 ++++++++++--------- .../sysutils/systeminfo/lang/pl-PL.rc | 76 ++++++++-------- .../sysutils/systeminfo/lang/sk-SK.rc | 88 ++++++++++--------- .../sysutils/systeminfo/lang/uk-UA.rc | 74 ++++++++-------- .../sysutils/systeminfo/resource.h | 66 +++++++------- .../sysutils/systeminfo/systeminfo.c | 6 +- 10 files changed, 361 insertions(+), 341 deletions(-) diff --git a/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc b/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc index 3ee3ac425d7..18efe35948b 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc @@ -11,16 +11,16 @@ Parameterliste:\n\ /S System Bestimmt das Remotesystem mit dem die Verbindung\n\ hergestellt werden soll.\n\n\ /U [Domne\]Benutzer Bestimmt den Benutzerkontext unter dem\n\ - der Befehl ausgefhrt werden soll.\n\n\ + der Befehl ausgefhrt werden soll.\n\n\ /P [Passwort] Bestimmt das Kennwort fr den zugewiesenen\n\ - Benutzerkontext. Bei Auslassung, wird dieses\n\ + Benutzerkontext. Bei Auslassung, wird dieses\n\ angefordert.\n\n\ /FO Format Bestimmt das Format in dem die Ausgabe\n\ - angezeigt werden soll.\n\ - Gltige Werte: TABLE, LIST, CSV.\n\n\ + angezeigt werden soll.\n\ + Gltige Werte: TABLE, LIST, CSV.\n\n\ /NH Bestimmt, dass der Spalten-Header in der\n\ - Ausgabe nicht angezeigt werden soll.\n\ - Nur fr Formate TABLE und CSV.\n\n\ + Ausgabe nicht angezeigt werden soll.\n\ + Nur fr Formate TABLE und CSV.\n\n\ /? Zeigt die Hilfemeldung an.\n\n\ Beispiele:\n\ SYSTEMINFO\n\ @@ -31,36 +31,38 @@ Beispiele:\n\ SYSTEMINFO /S system /FO LIST\n\ SYSTEMINFO /S system /FO CSV /NH\n" -IDS_OS_NAME, "OS Name: %s\n" -IDS_OS_VERSION, "OS Version: %u.%u.%u %s Build %u\n" -IDS_OS_BUILD_TYPE, "OS Build Typ: %s\n" -IDS_REG_OWNER, "Registrierter Benutzer: %s\n" -IDS_REG_ORG, "Registrierte Organisation: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" -IDS_PRODUCT_ID, "Produkt ID: %s\n" -IDS_INST_DATE, "Installationsdatum: %s, " -IDS_INST_TIME, "%s\n" -IDS_SYS_TYPE_UNKNOWN, "Systemtyp: Unbekannt\n" -IDS_SYS_TYPE_X86, "Systemtyp: X86-based PC\n" -IDS_SYS_TYPE_IA64, "Systemtyp: IA64-based PC\n" -IDS_SYS_TYPE_AMD64, "Systemtyp: AMD64-based PC\n" -IDS_PROCESSORS, "Prozessor(en): %u Prozessor(en) Installiert.\n" -IDS_ROS_DIR, "ReactOS Verzeichnis: %s\n" -IDS_SYS_DIR, "System Verzeichnis: %s\n" -IDS_BOOT_DEV, "Startgert: %s\n" -IDS_SYS_LOCALE, "Systemgebietsschema: %s\n" -IDS_INPUT_LOCALE, "Eingabegebietsschema: %s\n" -IDS_TOTAL_PHYS_MEM, "Gesamter Physikalischer Speicher: %ld MB (%ld KB)\n" -IDS_AVAIL_PHISICAL_MEM, "Verfgbarer Physikalischer Speicher: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_MAX, "Auslagerungsdatei: Max Gre: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_AVAIL, "Auslagerungsdatei: Verfgbar: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_INUSE, "Auslagerungsdatei: In Verwendung: %ld MB (%ld KB)\n" -IDS_HOST_NAME, "Domne: %s\n" -IDS_PAGEFILE_LOC, "Auslagerungsdateipfad(e) %s" -IDS_TIME_ZONE, "Zeitzone: %s\n" -IDS_DOMINE, "Domain: %s\n" -IDS_BIOS_DATE, "BIOS Datum: %s\n" -IDS_BIOS_VERSION, "BIOS Version: %s\n" -IDS_NETWORK_CARDS, "Netzwerkkarte(n) %u Installiert.\n" +IDS_HOST_NAME, "Domne: %s\n" +IDS_OS_NAME, "OS Name: %s\n" +IDS_OS_VERSION, "OS Version: %u.%u.%u %s Build %u\n" +IDS_OS_BUILD_TYPE, "OS Build Typ: %s\n" +IDS_REG_OWNER, "Registrierter Benutzer: %s\n" +IDS_REG_ORG, "Registrierte Organisation: %s\n" +IDS_PRODUCT_ID, "Produkt ID: %s\n" +IDS_INST_DATE, "Installationsdatum: %s, " +IDS_INST_TIME, "%s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" +IDS_SYS_MODEL, "System Model: %s\n" +IDS_SYS_TYPE_UNKNOWN, "Systemtyp: Unbekannt\n" +IDS_SYS_TYPE_X86, "Systemtyp: X86-based PC\n" +IDS_SYS_TYPE_IA64, "Systemtyp: IA64-based PC\n" +IDS_SYS_TYPE_AMD64, "Systemtyp: AMD64-based PC\n" +IDS_PROCESSORS, "Prozessor(en): %u Prozessor(en) Installiert.\n" +IDS_BIOS_DATE, "BIOS Datum: %s\n" +IDS_BIOS_VERSION, "BIOS Version: %s\n" +IDS_ROS_DIR, "ReactOS Verzeichnis: %s\n" +IDS_SYS_DIR, "System Verzeichnis: %s\n" +IDS_BOOT_DEV, "Startgert: %s\n" +IDS_SYS_LOCALE, "Systemgebietsschema: %s\n" +IDS_INPUT_LOCALE, "Eingabegebietsschema: %s\n" +IDS_TOTAL_PHYS_MEM, "Gesamter Physikalischer Speicher: %ld MB (%ld KB)\n" +IDS_AVAIL_PHISICAL_MEM, "Verfgbarer Physikalischer Speicher: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_MAX, "Auslagerungsdatei: Max Gre: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_AVAIL, "Auslagerungsdatei: Verfgbar: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_INUSE, "Auslagerungsdatei: In Verwendung: %ld MB (%ld KB)\n" +IDS_PAGEFILE_LOC, "Auslagerungsdateipfad(e) %s" +IDS_TIME_ZONE, "Zeitzone: %s\n" +IDS_DOMINE, "Domain: %s\n" +IDS_NETWORK_CARDS, "Netzwerkkarte(n) %u Installiert.\n" END diff --git a/rosapps/applications/sysutils/systeminfo/lang/en-US.rc b/rosapps/applications/sysutils/systeminfo/lang/en-US.rc index 005fa713f1b..6c2053f836c 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/en-US.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/en-US.rc @@ -10,15 +10,15 @@ Description:\n\ Parameter List:\n\ /S system Specifies the remote system to connect to.\n\n\ /U [domain\\]user Specifies the user context under which\n\ - the command should execute.\n\n\ + the command should execute.\n\n\ /P [password] Specifies the password for the given\n\ - user context. Prompts for input if omitted.\n\n\ + user context. Prompts for input if omitted.\n\n\ /FO format Specifies the format in which the output\n\ - is to be displayed.\n\ - Valid values: ""TABLE"", ""LIST"", ""CSV"".\n\n\ + is to be displayed.\n\ + Valid values: ""TABLE"", ""LIST"", ""CSV"".\n\n\ /NH Specifies that the ""Column Header"" should\n\ - not be displayed in the output.\n\ - Valid only for ""TABLE"" and ""CSV"" formats.\n\n\ + not be displayed in the output.\n\ + Valid only for ""TABLE"" and ""CSV"" formats.\n\n\ /? Displays this help/usage.\n\n\ Examples:\n\ SYSTEMINFO\n\ @@ -29,36 +29,38 @@ Examples:\n\ SYSTEMINFO /S system /FO LIST\n\ SYSTEMINFO /S system /FO CSV /NH\n" -IDS_OS_NAME, "OS Name: %s\n" -IDS_OS_VERSION, "OS Version: %u.%u.%u %s Build %u\n" -IDS_OS_BUILD_TYPE, "OS Build Type: %s\n" -IDS_REG_OWNER, "Registered Owner: %s\n" -IDS_REG_ORG, "Registered Organization: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" -IDS_PRODUCT_ID, "Product ID: %s\n" -IDS_INST_DATE, "Install Date: %s, " -IDS_INST_TIME, "%s\n" -IDS_SYS_TYPE_UNKNOWN, "System type: Unknown\n" -IDS_SYS_TYPE_X86, "System type: X86-based PC\n" -IDS_SYS_TYPE_IA64, "System type: IA64-based PC\n" -IDS_SYS_TYPE_AMD64, "System type: AMD64-based PC\n" -IDS_PROCESSORS, "Processor(s): %u Processor(s) Installed.\n" -IDS_ROS_DIR, "ReactOS Directory: %s\n" -IDS_SYS_DIR, "System Directory: %s\n" -IDS_BOOT_DEV, "Boot Device: %s\n" -IDS_SYS_LOCALE, "System Locale: %s\n" -IDS_INPUT_LOCALE, "Input Locale: %s\n" -IDS_TOTAL_PHYS_MEM, "Total Physical Memory: %ld MB (%ld KB)\n" -IDS_AVAIL_PHISICAL_MEM, "Available Physical Memory: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_MAX, "Virtual Memory: Max Size: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_AVAIL, "Virtual Memory: Available: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_INUSE, "Virtual Memory: In Use: %ld MB (%ld KB)\n" -IDS_HOST_NAME, "Host Name: %s\n" -IDS_PAGEFILE_LOC, "Page File Location(s) %s\n" -IDS_TIME_ZONE, "Time zone: %s\n" -IDS_DOMINE, "Domain: %s\n" -IDS_BIOS_DATE, "BIOS Date: %s\n" -IDS_BIOS_VERSION, "BIOS Version: %s\n" -IDS_NETWORK_CARDS, "Network Card(s) %u Installed.\n" +IDS_HOST_NAME, "Host Name: %s\n" +IDS_OS_NAME, "OS Name: %s\n" +IDS_OS_VERSION, "OS Version: %u.%u.%u %s Build %u\n" +IDS_OS_BUILD_TYPE, "OS Build Type: %s\n" +IDS_REG_OWNER, "Registered Owner: %s\n" +IDS_REG_ORG, "Registered Organization: %s\n" +IDS_PRODUCT_ID, "Product ID: %s\n" +IDS_INST_DATE, "Install Date: %s, " +IDS_INST_TIME, "%s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" +IDS_SYS_MODEL, "System Model: %s\n" +IDS_SYS_TYPE_UNKNOWN, "System type: Unknown\n" +IDS_SYS_TYPE_X86, "System type: X86-based PC\n" +IDS_SYS_TYPE_IA64, "System type: IA64-based PC\n" +IDS_SYS_TYPE_AMD64, "System type: AMD64-based PC\n" +IDS_PROCESSORS, "Processor(s): %u Processor(s) Installed.\n" +IDS_BIOS_DATE, "BIOS Date: %s\n" +IDS_BIOS_VERSION, "BIOS Version: %s\n" +IDS_ROS_DIR, "ReactOS Directory: %s\n" +IDS_SYS_DIR, "System Directory: %s\n" +IDS_BOOT_DEV, "Boot Device: %s\n" +IDS_SYS_LOCALE, "System Locale: %s\n" +IDS_INPUT_LOCALE, "Input Locale: %s\n" +IDS_TOTAL_PHYS_MEM, "Total Physical Memory: %ld MB (%ld KB)\n" +IDS_AVAIL_PHISICAL_MEM, "Available Physical Memory: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_MAX, "Virtual Memory: Max Size: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_AVAIL, "Virtual Memory: Available: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_INUSE, "Virtual Memory: In Use: %ld MB (%ld KB)\n" +IDS_PAGEFILE_LOC, "Page File Location(s) %s\n" +IDS_TIME_ZONE, "Time zone: %s\n" +IDS_DOMINE, "Domain: %s\n" +IDS_NETWORK_CARDS, "Network Card(s) %u Installed.\n" END diff --git a/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc b/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc index eabccc4cc04..21491ba7075 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc @@ -15,15 +15,15 @@ Description:\n\ Lista de Parametros:\n\ /S sistema Especifica el sistema remoto al cual conectarse.\n\n\ /U [dominio\\]usuario Especifica el usuario bajo el cual el comando\n\ - debe ejecutarse.\n\n\ + debe ejecutarse.\n\n\ /P [contrasea] Especifica la contrasea de usuario.\n\ - Pregunta por ella si es omitida.\n\n\ + Pregunta por ella si es omitida.\n\n\ /FO formato Especifica el formato en el que la salida\n\ - ser mostrada.\n\ - Valores vlidos: ""TABLE"", ""LIST"", ""CSV"".\n\n\ + ser mostrada.\n\ + Valores vlidos: ""TABLE"", ""LIST"", ""CSV"".\n\n\ /NH Especifica que la ""Columna cabezera"" no ser\n\ - mostrada en la salida.\n\ - Vlido slo para formatos ""TABLE"" y ""CSV"" .\n\n\ + mostrada en la salida.\n\ + Vlido slo para formatos ""TABLE"" y ""CSV"" .\n\n\ /? Muestra esta ayuda.\n\n\ Ejemplos:\n\ SYSTEMINFO\n\ @@ -34,36 +34,38 @@ Ejemplos:\n\ SYSTEMINFO /S sistema /FO LIST\n\ SYSTEMINFO /S sistema /FO CSV /NH\n" -IDS_OS_NAME, "Nombre Sistema Operativo: %s\n" -IDS_OS_VERSION, "Versin Sistema Operativo: %u.%u.%u %s Compilacin %u\n" -IDS_OS_BUILD_TYPE, "Tipo Compilacin: %s\n" -IDS_REG_OWNER, "Propietario: %s\n" -IDS_REG_ORG, "Organizacin: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" -IDS_PRODUCT_ID, "Identificador de Producto %s\n" -IDS_INST_DATE, "Fecha de Instalacin: %s, " -IDS_INST_TIME, "%s\n" -IDS_SYS_TYPE_UNKNOWN, "Tipo de sistema: Desconocido\n" -IDS_SYS_TYPE_X86, "Tipo de sistema: PC basado en X86\n" -IDS_SYS_TYPE_IA64, "Tipo de sistema: PC basado en IA64\n" -IDS_SYS_TYPE_AMD64, "Tipo de sistema: PC basado en AMD64\n" -IDS_PROCESSORS, "Procesador(es): %u Procesador(es) Instalados.\n" -IDS_ROS_DIR, "Directorio de ReactOS: %s\n" -IDS_SYS_DIR, "Directorio del Sistema: %s\n" -IDS_BOOT_DEV, "Dispositivo de Inicio: %s\n" -IDS_SYS_LOCALE, "Idioma del sistema: %s\n" -IDS_INPUT_LOCALE, "Idioma de entrada: %s\n" -IDS_TOTAL_PHYS_MEM, "Memoria Fsica Total: %ld MB (%ld KB)\n" -IDS_AVAIL_PHISICAL_MEM, "Memoria Fsica Disponible: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_MAX, "Memoria Virtual: Tamao Mx: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_AVAIL, "Memoria Virtual: Disponible: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_INUSE, "Memoria Virtual: En Uso: %ld MB (%ld KB)\n" -IDS_HOST_NAME, "Nombre del Servidor: %s\n" -IDS_PAGEFILE_LOC, "Ruta(s) Archivo Paginacin %s\n" -IDS_TIME_ZONE, "Zona horario: %s\n" -IDS_DOMINE, "Dominio: %s\n" -IDS_BIOS_DATE, "Fecha BIOS: %s\n" -IDS_BIOS_VERSION, "Versin BIOS: %s\n" -IDS_NETWORK_CARDS, "Tarjeta(s) de Red %u No Instalada.\n" +IDS_HOST_NAME, "Nombre del Servidor: %s\n" +IDS_OS_NAME, "Nombre Sistema Operativo: %s\n" +IDS_OS_VERSION, "Versin Sistema Operativo: %u.%u.%u %s Compilacin %u\n" +IDS_OS_BUILD_TYPE, "Tipo Compilacin: %s\n" +IDS_REG_OWNER, "Propietario: %s\n" +IDS_REG_ORG, "Organizacin: %s\n" +IDS_PRODUCT_ID, "Identificador de Producto %s\n" +IDS_INST_DATE, "Fecha de Instalacin: %s, " +IDS_INST_TIME, "%s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" +IDS_SYS_MODEL, "System Model: %s\n" +IDS_SYS_TYPE_UNKNOWN, "Tipo de sistema: Desconocido\n" +IDS_SYS_TYPE_X86, "Tipo de sistema: PC basado en X86\n" +IDS_SYS_TYPE_IA64, "Tipo de sistema: PC basado en IA64\n" +IDS_SYS_TYPE_AMD64, "Tipo de sistema: PC basado en AMD64\n" +IDS_PROCESSORS, "Procesador(es): %u Procesador(es) Instalados.\n" +IDS_BIOS_DATE, "Fecha BIOS: %s\n" +IDS_BIOS_VERSION, "Versin BIOS: %s\n" +IDS_ROS_DIR, "Directorio de ReactOS: %s\n" +IDS_SYS_DIR, "Directorio del Sistema: %s\n" +IDS_BOOT_DEV, "Dispositivo de Inicio: %s\n" +IDS_SYS_LOCALE, "Idioma del sistema: %s\n" +IDS_INPUT_LOCALE, "Idioma de entrada: %s\n" +IDS_TOTAL_PHYS_MEM, "Memoria Fsica Total: %ld MB (%ld KB)\n" +IDS_AVAIL_PHISICAL_MEM, "Memoria Fsica Disponible: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_MAX, "Memoria Virtual: Tamao Mx: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_AVAIL, "Memoria Virtual: Disponible: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_INUSE, "Memoria Virtual: En Uso: %ld MB (%ld KB)\n" +IDS_PAGEFILE_LOC, "Ruta(s) Archivo Paginacin %s\n" +IDS_TIME_ZONE, "Zona horario: %s\n" +IDS_DOMINE, "Dominio: %s\n" +IDS_NETWORK_CARDS, "Tarjeta(s) de Red %u No Instalada.\n" END diff --git a/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc b/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc index aacdbdf80c2..d99900e1ab1 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc @@ -10,15 +10,15 @@ Description :\n\ Parameter List:\n\ /S systme Spcifie le systme distant auquel se connecter.\n\n\ /U [domain\\]user Spcifie le contexte utilisateur dans lequel\n\ - la commande doit tre excute.\n\n\ + la commande doit tre excute.\n\n\ /P [motdepasse] Spcifie le mot de passe pour le contexte utilisateur\n\ - fourni. Le demande si ommis.\n\n\ + fourni. Le demande si ommis.\n\n\ /FO format Spcifie le format dans lequel la sortie\n\ - doit tre affiche.\n\ - Valeurs valides: ""TABLE"", ""LIST"", ""CSV"".\n\n\ + doit tre affiche.\n\ + Valeurs valides: ""TABLE"", ""LIST"", ""CSV"".\n\n\ /NH Spcifie que ""L'entte de colonne"" ne doit\n\ - pas tre affich dans la sortie.\n\ - Valide uniquement pour les format ""TABLE"" et ""CSV"".\n\n\ + pas tre affich dans la sortie.\n\ + Valide uniquement pour les format ""TABLE"" et ""CSV"".\n\n\ /? Affiche cette aide.\n\n\ Exemples:\n\ SYSTEMINFO\n\ @@ -29,36 +29,38 @@ Exemples:\n\ SYSTEMINFO /S systme /FO LIST\n\ SYSTEMINFO /S systme /FO CSV /NH\n" -IDS_OS_NAME, "Nom du systme d'exploitation : %s\n" -IDS_OS_VERSION, "Version du systme d'exploitation : %u.%u.%u %s Compilation %u\n" -IDS_OS_BUILD_TYPE, "Type de compilation du systme d'exploitation : %s\n" -IDS_REG_OWNER, "Propritaire enregistr : %s\n" -IDS_REG_ORG, "Organisation enregistre : %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" -IDS_PRODUCT_ID, "ID du produit : %s\n" -IDS_INST_DATE, "Date d'installation : %s, " -IDS_INST_TIME, "%s\n" -IDS_SYS_TYPE_UNKNOWN, "Type du systme : Inconnu\n" -IDS_SYS_TYPE_X86, "Type du systme : Bas sur un PC X86\n" -IDS_SYS_TYPE_IA64, "Type du systme : Bas sur un PC IA64\n" -IDS_SYS_TYPE_AMD64, "Type du systme : Bas sur un PC AMD64\n" -IDS_PROCESSORS, "Processeur(s) : %u Processeur(s) install(s).\n" -IDS_ROS_DIR, "Rpertoire ReactOS : %s\n" -IDS_SYS_DIR, "Rpertoire systme : %s\n" -IDS_BOOT_DEV, "Priphrique de dmarrage : %s\n" -IDS_SYS_LOCALE, "Paramtre rgional du systme : %s\n" -IDS_INPUT_LOCALE, "Paramtre rgional de saisie : %s\n" -IDS_TOTAL_PHYS_MEM, "Mmoire physique totale : %ld Mo (%ld Ko)\n" -IDS_AVAIL_PHISICAL_MEM, "Mmoire physique disponible : %ld Mo (%ld Ko)\n" -IDS_VIRT_MEM_MAX, "Mmoire virtuelle: Taille max : %ld Mo (%ld Ko)\n" -IDS_VIRT_MEM_AVAIL, "Mmoire virtuelle: Disponible : %ld Mo (%ld Ko)\n" -IDS_VIRT_MEM_INUSE, "Mmoire virtuelle: Utilise : %ld Mo (%ld Ko)\n" -IDS_HOST_NAME, "Nom d'hte : %s\n" -IDS_PAGEFILE_LOC, "Emplacement(s) des fichiers d'change %s" -IDS_TIME_ZONE, "Fuseau horaire : %s\n" -IDS_DOMINE, "Domaine : %s\n" -IDS_BIOS_DATE, "Date du BIOS : %s\n" -IDS_BIOS_VERSION, "Version du BIOS : %s\n" -IDS_NETWORK_CARDS, "Carte(s) rseau %u installe(s).\n" +IDS_HOST_NAME, "Nom d'hte : %s\n" +IDS_OS_NAME, "Nom du systme d'exploitation : %s\n" +IDS_OS_VERSION, "Version du systme d'exploitation : %u.%u.%u %s Compilation %u\n" +IDS_OS_BUILD_TYPE, "Type de compilation du systme d'exploitation : %s\n" +IDS_REG_OWNER, "Propritaire enregistr : %s\n" +IDS_REG_ORG, "Organisation enregistre : %s\n" +IDS_PRODUCT_ID, "ID du produit : %s\n" +IDS_INST_DATE, "Date d'installation : %s, " +IDS_INST_TIME, "%s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" +IDS_SYS_MODEL, "System Model: %s\n" +IDS_SYS_TYPE_UNKNOWN, "Type du systme : Inconnu\n" +IDS_SYS_TYPE_X86, "Type du systme : Bas sur un PC X86\n" +IDS_SYS_TYPE_IA64, "Type du systme : Bas sur un PC IA64\n" +IDS_SYS_TYPE_AMD64, "Type du systme : Bas sur un PC AMD64\n" +IDS_PROCESSORS, "Processeur(s) : %u Processeur(s) install(s).\n" +IDS_BIOS_DATE, "Date du BIOS : %s\n" +IDS_BIOS_VERSION, "Version du BIOS : %s\n" +IDS_ROS_DIR, "Rpertoire ReactOS : %s\n" +IDS_SYS_DIR, "Rpertoire systme : %s\n" +IDS_BOOT_DEV, "Priphrique de dmarrage : %s\n" +IDS_SYS_LOCALE, "Paramtre rgional du systme : %s\n" +IDS_INPUT_LOCALE, "Paramtre rgional de saisie : %s\n" +IDS_TOTAL_PHYS_MEM, "Mmoire physique totale : %ld Mo (%ld Ko)\n" +IDS_AVAIL_PHISICAL_MEM, "Mmoire physique disponible : %ld Mo (%ld Ko)\n" +IDS_VIRT_MEM_MAX, "Mmoire virtuelle: Taille max : %ld Mo (%ld Ko)\n" +IDS_VIRT_MEM_AVAIL, "Mmoire virtuelle: Disponible : %ld Mo (%ld Ko)\n" +IDS_VIRT_MEM_INUSE, "Mmoire virtuelle: Utilise : %ld Mo (%ld Ko)\n" +IDS_PAGEFILE_LOC, "Emplacement(s) des fichiers d'change %s" +IDS_TIME_ZONE, "Fuseau horaire : %s\n" +IDS_DOMINE, "Domaine : %s\n" +IDS_NETWORK_CARDS, "Carte(s) rseau %u installe(s).\n" END diff --git a/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc b/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc index f541156c496..0beda9afec7 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc @@ -8,18 +8,18 @@ Beskrivelse:\n\ Denne komando linje verktyet gjr det mulig for en administrator sprre om basis\n\ system konfigurasjon informasjon.\n\n\ Parameter liste:\n\ - /S system Spesifisere eksternt system for kunne kobles til.\n\n\ - /U [domene\\]bruker Spesifisere brukeren sammenheng under hvilken\n\ - av kommando som skal kjres.\n\n\ - /P [passord] Spesifisere passord for gitt\n\ - bruker sammenheng. Prompts for input if omitted.\n\n\ - /FO format Spesifisere formatet som i utgende\n\ - som skal vises.\n\ - Gyldige verdier: ""TABLE"", ""LIST"", ""CSV"".\n\n\ - /NH Spesifisere at ""Column Header"" skal\n\ - ikke vises i utgende.\n\ - Gyldig for bare ""TABLE"" og ""CSV"" formater.\n\n\ - /? Vis denne hjelp/bruk meldingen.\n\n\ + /S system Spesifisere eksternt system for kunne kobles til.\n\n\ + /U [domene\\]bruker Spesifisere brukeren sammenheng under hvilken\n\ + av kommando som skal kjres.\n\n\ + /P [passord] Spesifisere passord for gitt\n\ + bruker sammenheng. Prompts for input if omitted.\n\n\ + /FO format Spesifisere formatet som i utgende\n\ + som skal vises.\n\ + Gyldige verdier: ""TABLE"", ""LIST"", ""CSV"".\n\n\ + /NH Spesifisere at ""Column Header"" skal\n\ + ikke vises i utgende.\n\ + Gyldig for bare ""TABLE"" og ""CSV"" formater.\n\n\ + /? Vis denne hjelp/bruk meldingen.\n\n\ Eksempler:\n\ SYSTEMINFO\n\ SYSTEMINFO /?\n\ @@ -29,36 +29,38 @@ Eksempler:\n\ SYSTEMINFO /S system /FO LIST\n\ SYSTEMINFO /S system /FO CSV /NH\n" -IDS_OS_NAME, "OS navn: %s\n" -IDS_OS_VERSION, "OS versjon: %u.%u.%u %s Bygget %u\n" -IDS_OS_BUILD_TYPE, "OS bygg type: %s\n" -IDS_REG_OWNER, "Registert eier: %s\n" -IDS_REG_ORG, "Registerert organisasjon: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" -IDS_PRODUCT_ID, "Produkt ID: %s\n" -IDS_INST_DATE, "Installert dato: %s, " -IDS_INST_TIME, "%s\n" -IDS_SYS_TYPE_UNKNOWN, "Systemtype: Ukjent\n" -IDS_SYS_TYPE_X86, "Systemtype: X86-basert PC\n" -IDS_SYS_TYPE_IA64, "Systemtype: IA64-basert PC\n" -IDS_SYS_TYPE_AMD64, "Systemtype: AMD64-basert PC\n" -IDS_PROCESSORS, "Prosessor(er): %u Prosessor(er) installert.\n" -IDS_ROS_DIR, "ReactOS mappe: %s\n" -IDS_SYS_DIR, "System mappe: %s\n" -IDS_BOOT_DEV, "Oppstartsenhet: %s\n" -IDS_SYS_LOCALE, "System lokal: %s\n" -IDS_INPUT_LOCALE, "Input lokal: %s\n" -IDS_TOTAL_PHYS_MEM, "Total fysisk minne: %ld MB (%ld KB)\n" -IDS_AVAIL_PHISICAL_MEM, "Tilgjengelig fysisk minne: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_MAX, "Virtuelt minne: Maks Strrelse: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_AVAIL, "Virtuelt minne: Tilgjengelig: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_INUSE, "Virtuelt minne: i bruk: %ld MB (%ld KB)\n" -IDS_HOST_NAME, "Datamaskin navn: %s\n" -IDS_PAGEFILE_LOC, "Sidevekslingsfil lokalsjon(er) %s\n" -IDS_TIME_ZONE, "Tidssone: %s\n" -IDS_DOMINE, "Domene: %s\n" -IDS_BIOS_DATE, "BIOS dato: %s\n" -IDS_BIOS_VERSION, "BIOS Versjon: %s\n" -IDS_NETWORK_CARDS, "Nettverkskort(er) %u installert.\n" +IDS_HOST_NAME, "Datamaskin navn: %s\n" +IDS_OS_NAME, "OS navn: %s\n" +IDS_OS_VERSION, "OS versjon: %u.%u.%u %s Bygget %u\n" +IDS_OS_BUILD_TYPE, "OS bygg type: %s\n" +IDS_REG_OWNER, "Registert eier: %s\n" +IDS_REG_ORG, "Registerert organisasjon: %s\n" +IDS_PRODUCT_ID, "Produkt ID: %s\n" +IDS_INST_DATE, "Installert dato: %s, " +IDS_INST_TIME, "%s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" +IDS_SYS_MODEL, "System Model: %s\n" +IDS_SYS_TYPE_UNKNOWN, "Systemtype: Ukjent\n" +IDS_SYS_TYPE_X86, "Systemtype: X86-basert PC\n" +IDS_SYS_TYPE_IA64, "Systemtype: IA64-basert PC\n" +IDS_SYS_TYPE_AMD64, "Systemtype: AMD64-basert PC\n" +IDS_PROCESSORS, "Prosessor(er): %u Prosessor(er) installert.\n" +IDS_BIOS_DATE, "BIOS dato: %s\n" +IDS_BIOS_VERSION, "BIOS Versjon: %s\n" +IDS_ROS_DIR, "ReactOS mappe: %s\n" +IDS_SYS_DIR, "System mappe: %s\n" +IDS_BOOT_DEV, "Oppstartsenhet: %s\n" +IDS_SYS_LOCALE, "System lokal: %s\n" +IDS_INPUT_LOCALE, "Input lokal: %s\n" +IDS_TOTAL_PHYS_MEM, "Total fysisk minne: %ld MB (%ld KB)\n" +IDS_AVAIL_PHISICAL_MEM, "Tilgjengelig fysisk minne: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_MAX, "Virtuelt minne: Maks Strrelse: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_AVAIL, "Virtuelt minne: Tilgjengelig: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_INUSE, "Virtuelt minne: i bruk: %ld MB (%ld KB)\n" +IDS_PAGEFILE_LOC, "Sidevekslingsfil lokalsjon(er) %s\n" +IDS_TIME_ZONE, "Tidssone: %s\n" +IDS_DOMINE, "Domene: %s\n" +IDS_NETWORK_CARDS, "Nettverkskort(er) %u installert.\n" END diff --git a/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc b/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc index 53a421dcf12..6f48d0656ee 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc @@ -17,15 +17,15 @@ Opis:\n\ Lista parametrw:\n\ /S system Wyznacza nazw systemu zdalnego do poczenia.\n\n\ /U [domain\\]user Wyznacza uytkownika (domen) z ktrego konta\n\ - komenda bdzie wywoana.\n\n\ + komenda bdzie wywoana.\n\n\ /P [password] Wyznacza haso do uytego konta uytkownika\n\ - Program sam zapyta o haso, jeli nie jest podane.\n\n\ + Program sam zapyta o haso, jeli nie jest podane.\n\n\ /FO format Wyznacza format w ktrym wywietlone zostan\n\ - informacje o systemie.\n\ - Dostpne formaty: ""TABLE"", ""LIST"", ""CSV"".\n\n\ + informacje o systemie.\n\ + Dostpne formaty: ""TABLE"", ""LIST"", ""CSV"".\n\n\ /NH Blokuje wywietlanie kolumny ""Column Header"" w\n\ - informacjach systemowych.\n\ - Dziaa tylko z formatami ""TABLE"" i ""CSV"".\n\n\ + informacjach systemowych.\n\ + Dziaa tylko z formatami ""TABLE"" i ""CSV"".\n\n\ /? Wywietla niniejszy tekst pomocy.\n\n\ Przykady:\n\ SYSTEMINFO\n\ @@ -36,36 +36,38 @@ Przyk SYSTEMINFO /S system /FO LIST\n\ SYSTEMINFO /S system /FO CSV /NH\n" -IDS_OS_NAME, "Nazwa Systemu: %s\n" -IDS_OS_VERSION, "Wersja: %u.%u.%u %s Kompilacja %u\n" -IDS_OS_BUILD_TYPE, "Rodzaj kompilacji: %s\n" -IDS_REG_OWNER, "Uytkownik: %s\n" -IDS_REG_ORG, "Organizacja: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" -IDS_PRODUCT_ID, "ID produktu: %s\n" -IDS_INST_DATE, "Data instalacji: %s, " -IDS_INST_TIME, "%s\n" -IDS_SYS_TYPE_UNKNOWN, "Rodzaj systemu: Unknown\n" -IDS_SYS_TYPE_X86, "Architektura: X86-based PC\n" -IDS_SYS_TYPE_IA64, "Architektura: IA64-based PC\n" -IDS_SYS_TYPE_AMD64, "Rodzaj systemu: AMD64-based PC\n" -IDS_PROCESSORS, "Ilo Procesorw: %u.\n" -IDS_ROS_DIR, "Katalog ReactOS: %s\n" -IDS_SYS_DIR, "Katalog Systemowy: %s\n" -IDS_BOOT_DEV, "Urzdzenie rdowe: %s\n" -IDS_SYS_LOCALE, "Wersja lokalizacji: %s\n" -IDS_INPUT_LOCALE, "Lokalizacja klawiatury: %s\n" -IDS_TOTAL_PHYS_MEM, "Pamici fizycznej ogem: %ld MB (%ld KB)\n" -IDS_AVAIL_PHISICAL_MEM, "Dostpnej pamici fizycznej: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_MAX, "Pamici wirtualnej: Maksymalnie: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_AVAIL, "Pamici wirtualnej: Dostpne: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_INUSE, "Pamici wirtualnej: W uyciu: %ld MB (%ld KB)\n" -IDS_HOST_NAME, "Nazwa hosta: %s\n" -IDS_PAGEFILE_LOC, "Lokalizacja pliku wymiany %s\n" -IDS_TIME_ZONE, "Strefa czasowa: %s\n" -IDS_DOMINE, "Domena: %s\n" -IDS_BIOS_DATE, "Data BIOSu: %s\n" -IDS_BIOS_VERSION, "Wersja BIOSu: %s\n" -IDS_NETWORK_CARDS, "Liczba kart sieciowych %u.\n" +IDS_HOST_NAME, "Nazwa hosta: %s\n" +IDS_OS_NAME, "Nazwa Systemu: %s\n" +IDS_OS_VERSION, "Wersja: %u.%u.%u %s Kompilacja %u\n" +IDS_OS_BUILD_TYPE, "Rodzaj kompilacji: %s\n" +IDS_REG_OWNER, "Uytkownik: %s\n" +IDS_REG_ORG, "Organizacja: %s\n" +IDS_PRODUCT_ID, "ID produktu: %s\n" +IDS_INST_DATE, "Data instalacji: %s, " +IDS_INST_TIME, "%s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_SYS_MANUFACTURER, "Producent systemu: %s\n" +IDS_SYS_MODEL, "Model systemu: %s\n" +IDS_SYS_TYPE_UNKNOWN, "Rodzaj systemu: Unknown\n" +IDS_SYS_TYPE_X86, "Architektura: X86-based PC\n" +IDS_SYS_TYPE_IA64, "Architektura: IA64-based PC\n" +IDS_SYS_TYPE_AMD64, "Rodzaj systemu: AMD64-based PC\n" +IDS_PROCESSORS, "Ilo Procesorw: %u.\n" +IDS_BIOS_DATE, "Data BIOSu: %s\n" +IDS_BIOS_VERSION, "Wersja BIOSu: %s\n" +IDS_ROS_DIR, "Katalog ReactOS: %s\n" +IDS_SYS_DIR, "Katalog Systemowy: %s\n" +IDS_BOOT_DEV, "Urzdzenie rdowe: %s\n" +IDS_SYS_LOCALE, "Wersja lokalizacji: %s\n" +IDS_INPUT_LOCALE, "Lokalizacja klawiatury: %s\n" +IDS_TOTAL_PHYS_MEM, "Pamici fizycznej ogem: %ld MB (%ld KB)\n" +IDS_AVAIL_PHISICAL_MEM, "Dostpnej pamici fizycznej: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_MAX, "Pamici wirtualnej: Maksymalnie: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_AVAIL, "Pamici wirtualnej: Dostpne: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_INUSE, "Pamici wirtualnej: W uyciu: %ld MB (%ld KB)\n" +IDS_PAGEFILE_LOC, "Lokalizacja pliku wymiany %s\n" +IDS_TIME_ZONE, "Strefa czasowa: %s\n" +IDS_DOMINE, "Domena: %s\n" +IDS_NETWORK_CARDS, "Liczba kart sieciowych %u.\n" END diff --git a/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc b/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc index a4b87232f69..cfe27484ec7 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc @@ -12,18 +12,18 @@ Description:\n\ This command line tool enables an administrator to query for basic\n\ system configuration information.\n\n\ Parameter List:\n\ - /S systm Specifies the remote system to connect to.\n\n\ - /U [domna\\]pouvate Specifies the user context under which\n\ - the command should execute.\n\n\ - /P [heslo] Specifies the password for the given\n\ - user context. Prompts for input if omitted.\n\n\ - /FO formt Specifies the format in which the output\n\ - is to be displayed.\n\ - Valid values: ""TABLE"", ""LIST"", ""CSV"".\n\n\ - /NH Specifies that the ""Column Header"" should\n\ - not be displayed in the output.\n\ - Valid only for ""TABLE"" and ""CSV"" formats.\n\n\ - /? Displays this help/usage.\n\n\ + /S systm Specifies the remote system to connect to.\n\n\ + /U [domna\\]pouvate Specifies the user context under which\n\ + the command should execute.\n\n\ + /P [heslo] Specifies the password for the given\n\ + user context. Prompts for input if omitted.\n\n\ + /FO formt Specifies the format in which the output\n\ + is to be displayed.\n\ + Valid values: ""TABLE"", ""LIST"", ""CSV"".\n\n\ + /NH Specifies that the ""Column Header"" should\n\ + not be displayed in the output.\n\ + Valid only for ""TABLE"" and ""CSV"" formats.\n\n\ + /? Displays this help/usage.\n\n\ Examples:\n\ SYSTEMINFO\n\ SYSTEMINFO /?\n\ @@ -33,36 +33,38 @@ Examples:\n\ SYSTEMINFO /S system /FO LIST\n\ SYSTEMINFO /S system /FO CSV /NH\n" -IDS_OS_NAME, "Nzov OS: %s\n" -IDS_OS_VERSION, "Verzia OS: %u.%u.%u %s Build %u\n" -IDS_OS_BUILD_TYPE, "OS Build typ: %s\n" -IDS_REG_OWNER, "Registovan vlastnk: %s\n" -IDS_REG_ORG, "Registrovan organizcia: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" -IDS_PRODUCT_ID, "ID produktu: %s\n" -IDS_INST_DATE, "Dtum intalcie: %s, " -IDS_INST_TIME, "%s\n" -IDS_SYS_TYPE_UNKNOWN, "Typ systmu: Neznmy\n" -IDS_SYS_TYPE_X86, "Typ systmu: PC zaloen na X86\n" -IDS_SYS_TYPE_IA64, "Typ systmu: PC zaloen na IA64\n" -IDS_SYS_TYPE_AMD64, "Typ systmu: PC zaloen na AMD64\n" -IDS_PROCESSORS, "Procesor(y): %u Procesor(y) naintalovan.\n" -IDS_ROS_DIR, "Adresr ReactOS: %s\n" -IDS_SYS_DIR, "Adresr System: %s\n" -IDS_BOOT_DEV, "Zavdzacie zariadenie: %s\n" -IDS_SYS_LOCALE, "System Locale: %s\n" -IDS_INPUT_LOCALE, "Input Locale: %s\n" -IDS_TOTAL_PHYS_MEM, "Celkov fyzick pam: %ld MB (%ld KB)\n" -IDS_AVAIL_PHISICAL_MEM, "Dostupn fyzick pam: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_MAX, "Virtulna pam: Max Size: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_AVAIL, "Virtulna pam: Available: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_INUSE, "Virtulna pam: In Use: %ld MB (%ld KB)\n" -IDS_HOST_NAME, "Host Name: %s\n" -IDS_PAGEFILE_LOC, "Umiestnenie(a) strnkovacieho sboru: %s\n" -IDS_TIME_ZONE, "asov psmo: %s\n" -IDS_DOMINE, "Domna: %s\n" -IDS_BIOS_DATE, "Dtum BIOSu: %s\n" -IDS_BIOS_VERSION, "Verzia BIOSu: %s\n" -IDS_NETWORK_CARDS, "Sieov karta(y) %u naintalovan.\n" +IDS_HOST_NAME, "Host Name: %s\n" +IDS_OS_NAME, "Nzov OS: %s\n" +IDS_OS_VERSION, "Verzia OS: %u.%u.%u %s Build %u\n" +IDS_OS_BUILD_TYPE, "OS Build typ: %s\n" +IDS_REG_OWNER, "Registovan vlastnk: %s\n" +IDS_REG_ORG, "Registrovan organizcia: %s\n" +IDS_PRODUCT_ID, "ID produktu: %s\n" +IDS_INST_DATE, "Dtum intalcie: %s, " +IDS_INST_TIME, "%s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" +IDS_SYS_MODEL, "System Model: %s\n" +IDS_SYS_TYPE_UNKNOWN, "Typ systmu: Neznmy\n" +IDS_SYS_TYPE_X86, "Typ systmu: PC zaloen na X86\n" +IDS_SYS_TYPE_IA64, "Typ systmu: PC zaloen na IA64\n" +IDS_SYS_TYPE_AMD64, "Typ systmu: PC zaloen na AMD64\n" +IDS_PROCESSORS, "Procesor(y): %u Procesor(y) naintalovan.\n" +IDS_BIOS_DATE, "Dtum BIOSu: %s\n" +IDS_BIOS_VERSION, "Verzia BIOSu: %s\n" +IDS_ROS_DIR, "Adresr ReactOS: %s\n" +IDS_SYS_DIR, "Adresr System: %s\n" +IDS_BOOT_DEV, "Zavdzacie zariadenie: %s\n" +IDS_SYS_LOCALE, "System Locale: %s\n" +IDS_INPUT_LOCALE, "Input Locale: %s\n" +IDS_TOTAL_PHYS_MEM, "Celkov fyzick pam: %ld MB (%ld KB)\n" +IDS_AVAIL_PHISICAL_MEM, "Dostupn fyzick pam: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_MAX, "Virtulna pam: Max Size: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_AVAIL, "Virtulna pam: Available: %ld MB (%ld KB)\n" +IDS_VIRT_MEM_INUSE, "Virtulna pam: In Use: %ld MB (%ld KB)\n" +IDS_PAGEFILE_LOC, "Umiestnenie(a) strnkovacieho sboru: %s\n" +IDS_TIME_ZONE, "asov psmo: %s\n" +IDS_DOMINE, "Domna: %s\n" +IDS_NETWORK_CARDS, "Sieov karta(y) %u naintalovan.\n" END diff --git a/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc b/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc index e0f96369ad3..edc724e7f12 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc @@ -20,13 +20,13 @@ IDS_USAGE, "SYSTEMINFO [/S /U [\\]. , \n\ .\n\n\ /P [] .\n\ - , .\n\n\ + , .\n\n\ /FO , \n\ - .\n\ - : ""TABLE"", ""LIST"", ""CSV"".\n\n\ + .\n\ + : ""TABLE"", ""LIST"", ""CSV"".\n\n\ /NH \n\ - .\n\ - ""TABLE"" and ""CSV"".\n\n\ + .\n\ + ""TABLE"" and ""CSV"".\n\n\ /? .\n\n\ :\n\ SYSTEMINFO\n\ @@ -37,36 +37,38 @@ IDS_USAGE, "SYSTEMINFO [/S SYSTEMINFO /S /FO LIST\n\ SYSTEMINFO /S /FO CSV /NH\n" -IDS_OS_NAME, "' : %s\n" -IDS_OS_VERSION, " : %u.%u.%u %s %u\n" -IDS_OS_BUILD_TYPE, " : %s\n" -IDS_REG_OWNER, " : %s\n" -IDS_REG_ORG, " : %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" -IDS_PRODUCT_ID, "ID : %s\n" -IDS_INST_DATE, " : %s, " -IDS_INST_TIME, "%s\n" -IDS_SYS_TYPE_UNKNOWN, " : \n" -IDS_SYS_TYPE_X86, " : X86-based PC\n" -IDS_SYS_TYPE_IA64, " : IA64-based PC\n" -IDS_SYS_TYPE_AMD64, " : AMD64-based PC\n" -IDS_PROCESSORS, "(): %u (,) .\n" -IDS_ROS_DIR, " ReactOS: %s\n" -IDS_SYS_DIR, " : %s\n" -IDS_BOOT_DEV, " : %s\n" -IDS_SYS_LOCALE, " : %s\n" -IDS_INPUT_LOCALE, " : %s\n" -IDS_TOTAL_PHYS_MEM, " ': %ld (%ld )\n" -IDS_AVAIL_PHISICAL_MEM, " ': %ld (%ld )\n" -IDS_VIRT_MEM_MAX, "³ ': . : %ld (%ld )\n" -IDS_VIRT_MEM_AVAIL, "³ ': : %ld (%ld )\n" -IDS_VIRT_MEM_INUSE, "³ ': .: %ld (%ld )\n" -IDS_HOST_NAME, "' ': %s\n" -IDS_PAGEFILE_LOC, " %s\n" -IDS_TIME_ZONE, " : %s\n" -IDS_DOMINE, ": %s\n" -IDS_BIOS_DATE, " BIOS: %s\n" -IDS_BIOS_VERSION, " BIOS: %s\n" -IDS_NETWORK_CARDS, " () %u Installed.\n" +IDS_HOST_NAME, "' ': %s\n" +IDS_OS_NAME, "' : %s\n" +IDS_OS_VERSION, " : %u.%u.%u %s %u\n" +IDS_OS_BUILD_TYPE, " : %s\n" +IDS_REG_OWNER, " : %s\n" +IDS_REG_ORG, " : %s\n" +IDS_PRODUCT_ID, "ID : %s\n" +IDS_INST_DATE, " : %s, " +IDS_INST_TIME, "%s\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" +IDS_SYS_MODEL, "System Model: %s\n" +IDS_SYS_TYPE_UNKNOWN, " : \n" +IDS_SYS_TYPE_X86, " : X86-based PC\n" +IDS_SYS_TYPE_IA64, " : IA64-based PC\n" +IDS_SYS_TYPE_AMD64, " : AMD64-based PC\n" +IDS_PROCESSORS, "(): %u (,) .\n" +IDS_BIOS_DATE, " BIOS: %s\n" +IDS_BIOS_VERSION, " BIOS: %s\n" +IDS_ROS_DIR, " ReactOS: %s\n" +IDS_SYS_DIR, " : %s\n" +IDS_BOOT_DEV, " : %s\n" +IDS_SYS_LOCALE, " : %s\n" +IDS_INPUT_LOCALE, " : %s\n" +IDS_TOTAL_PHYS_MEM, " ': %ld (%ld )\n" +IDS_AVAIL_PHISICAL_MEM, " ': %ld (%ld )\n" +IDS_VIRT_MEM_MAX, "³ ': . : %ld (%ld )\n" +IDS_VIRT_MEM_AVAIL, "³ ': : %ld (%ld )\n" +IDS_VIRT_MEM_INUSE, "³ ': .: %ld (%ld )\n" +IDS_PAGEFILE_LOC, " %s\n" +IDS_TIME_ZONE, " : %s\n" +IDS_DOMINE, ": %s\n" +IDS_NETWORK_CARDS, " () %u Installed.\n" END diff --git a/rosapps/applications/sysutils/systeminfo/resource.h b/rosapps/applications/sysutils/systeminfo/resource.h index 4942b4739cc..eb28aea10a3 100644 --- a/rosapps/applications/sysutils/systeminfo/resource.h +++ b/rosapps/applications/sysutils/systeminfo/resource.h @@ -1,33 +1,35 @@ -#define IDS_USAGE 1000 +#define IDS_USAGE 1000 -#define IDS_OS_NAME 100 -#define IDS_OS_VERSION 101 -#define IDS_OS_BUILD_TYPE 102 -#define IDS_REG_OWNER 103 -#define IDS_REG_ORG 104 -#define IDS_PRODUCT_ID 105 -#define IDS_INST_DATE 106 -#define IDS_INST_TIME 107 -#define IDS_UP_TIME 108 -#define IDS_SYS_TYPE_UNKNOWN 109 -#define IDS_SYS_TYPE_X86 110 -#define IDS_SYS_TYPE_IA64 111 -#define IDS_SYS_TYPE_AMD64 112 -#define IDS_PROCESSORS 113 -#define IDS_ROS_DIR 114 -#define IDS_SYS_DIR 115 -#define IDS_BOOT_DEV 116 -#define IDS_SYS_LOCALE 117 -#define IDS_INPUT_LOCALE 118 -#define IDS_TOTAL_PHYS_MEM 119 -#define IDS_AVAIL_PHISICAL_MEM 120 -#define IDS_VIRT_MEM_MAX 121 -#define IDS_VIRT_MEM_AVAIL 122 -#define IDS_VIRT_MEM_INUSE 123 -#define IDS_HOST_NAME 124 -#define IDS_PAGEFILE_LOC 125 -#define IDS_TIME_ZONE 126 -#define IDS_DOMINE 127 -#define IDS_BIOS_DATE 128 -#define IDS_BIOS_VERSION 129 -#define IDS_NETWORK_CARDS 130 +#define IDS_HOST_NAME 100 +#define IDS_OS_NAME 101 +#define IDS_OS_VERSION 102 +#define IDS_OS_BUILD_TYPE 103 +#define IDS_REG_OWNER 104 +#define IDS_REG_ORG 105 +#define IDS_PRODUCT_ID 106 +#define IDS_INST_DATE 107 +#define IDS_INST_TIME 108 +#define IDS_UP_TIME 109 +#define IDS_SYS_MANUFACTURER 110 +#define IDS_SYS_MODEL 111 +#define IDS_SYS_TYPE_UNKNOWN 112 +#define IDS_PROCESSORS 113 +#define IDS_BIOS_DATE 114 +#define IDS_BIOS_VERSION 115 +#define IDS_ROS_DIR 116 +#define IDS_SYS_DIR 117 +#define IDS_BOOT_DEV 118 +#define IDS_SYS_LOCALE 119 +#define IDS_INPUT_LOCALE 120 +#define IDS_TOTAL_PHYS_MEM 121 +#define IDS_AVAIL_PHISICAL_MEM 122 +#define IDS_VIRT_MEM_MAX 123 +#define IDS_VIRT_MEM_AVAIL 124 +#define IDS_VIRT_MEM_INUSE 125 +#define IDS_PAGEFILE_LOC 126 +#define IDS_TIME_ZONE 127 +#define IDS_DOMINE 128 +#define IDS_NETWORK_CARDS 130 +#define IDS_SYS_TYPE_X86 140 +#define IDS_SYS_TYPE_IA64 141 +#define IDS_SYS_TYPE_AMD64 142 diff --git a/rosapps/applications/sysutils/systeminfo/systeminfo.c b/rosapps/applications/sysutils/systeminfo/systeminfo.c index 3231732a569..68b32e1ec9d 100644 --- a/rosapps/applications/sysutils/systeminfo/systeminfo.c +++ b/rosapps/applications/sysutils/systeminfo/systeminfo.c @@ -180,7 +180,8 @@ AllSysInfo(VOID) Buf, sizeof(Buf)/sizeof(Buf[0]), Tmp); - printf("System Manufacturer:\t\t%s\n", Buf); + if (GetOemStrings(IDS_SYS_MANUFACTURER, Msg)) + printf(Msg, Buf); //getting System Model GetPrivateProfileString(TEXT("General"), @@ -189,7 +190,8 @@ AllSysInfo(VOID) Buf, sizeof(Buf)/sizeof(Buf[0]), Tmp); - printf("System Model:\t\t\t%s\n", Buf); + if (GetOemStrings(IDS_SYS_MODEL, Msg)) + printf(Msg, Buf); //getting System type switch (SysInfo.wProcessorArchitecture) From 951d604b0c2b77ef5429df0c019e74f1367c4486 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Thu, 31 Mar 2011 21:20:06 +0000 Subject: [PATCH 44/66] [Win32k] - Fix wine post message test, corrected the peek message window selection. - Add a check for dead windows and new message queue flags. - Other miscellaneous fix ups. svn path=/trunk/; revision=51216 --- .../win32/win32k/include/msgqueue.h | 34 ++++++++-- .../subsystems/win32/win32k/ntuser/message.c | 49 +++++++++------ .../subsystems/win32/win32k/ntuser/msgqueue.c | 62 +++++++++++++------ 3 files changed, 103 insertions(+), 42 deletions(-) diff --git a/reactos/subsystems/win32/win32k/include/msgqueue.h b/reactos/subsystems/win32/win32k/include/msgqueue.h index f078a16f23d..5af589ee0a8 100644 --- a/reactos/subsystems/win32/win32k/include/msgqueue.h +++ b/reactos/subsystems/win32/win32k/include/msgqueue.h @@ -78,12 +78,16 @@ typedef struct _USER_MESSAGE_QUEUE HANDLE NewMessagesHandle; /* Last time PeekMessage() was called. */ ULONG LastMsgRead; - /* Current window with focus (ie. receives keyboard input) for this queue. */ - HWND FocusWindow; - /* Current active window for this queue. */ - HWND ActiveWindow; /* Current capture window for this queue. */ HWND CaptureWindow; + PWND spwndCapture; + /* Current window with focus (ie. receives keyboard input) for this queue. */ + HWND FocusWindow; + PWND spwndFocus; + /* Current active window for this queue. */ + HWND ActiveWindow; + PWND spwndActive; + PWND spwndActivePrev; /* Current move/size window for this queue */ HWND MoveSize; /* Current menu owner window for this queue */ @@ -92,6 +96,8 @@ typedef struct _USER_MESSAGE_QUEUE BYTE MenuState; /* Caret information for this queue */ PTHRDCARETINFO CaretInfo; + /* Message Queue Flags */ + DWORD QF_flags; /* queue state tracking */ // Send list QS_SENDMESSAGE @@ -112,8 +118,28 @@ typedef struct _USER_MESSAGE_QUEUE struct _DESKTOP *Desktop; } USER_MESSAGE_QUEUE, *PUSER_MESSAGE_QUEUE; +#define QF_UPDATEKEYSTATE 0x00000001 +#define QF_FMENUSTATUSBREAK 0x00000004 +#define QF_FMENUSTATUS 0x00000008 +#define QF_FF10STATUS 0x00000010 +#define QF_MOUSEMOVED 0x00000020 // See MouseMoved. +#define QF_ACTIVATIONCHANGE 0x00000040 +#define QF_TABSWITCHING 0x00000080 +#define QF_KEYSTATERESET 0x00000100 +#define QF_INDESTROY 0x00000200 +#define QF_LOCKNOREMOVE 0x00000400 +#define QF_FOCUSNULLSINCEACTIVE 0x00000800 +#define QF_DIALOGACTIVE 0x00004000 +#define QF_EVENTDEACTIVATEREMOVED 0x00008000 +#define QF_TRACKMOUSELEAVE 0x00020000 +#define QF_TRACKMOUSEHOVER 0x00040000 +#define QF_TRACKMOUSEFIRING 0x00080000 +#define QF_CAPTURELOCKED 0x00100000 +#define QF_ACTIVEWNDTRACKING 0x00200000 + BOOL FASTCALL MsqIsHung(PUSER_MESSAGE_QUEUE MessageQueue); +VOID CALLBACK HungAppSysTimerProc(HWND,UINT,UINT_PTR,DWORD); NTSTATUS FASTCALL co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 0822009f541..f14ec4745ed 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -1233,6 +1233,7 @@ co_IntSendMessageTimeoutSingle( HWND hWnd, if (uFlags & SMTO_ABORTIFHUNG && MsqIsHung(Window->head.pti->MessageQueue)) { + // FIXME - Set window hung and add to a list. /* FIXME - Set a LastError? */ RETURN( FALSE); } @@ -1258,7 +1259,7 @@ co_IntSendMessageTimeoutSingle( HWND hWnd, } while ((STATUS_TIMEOUT == Status) && (uFlags & SMTO_NOTIMEOUTIFNOTHUNG) && - !MsqIsHung(Window->head.pti->MessageQueue)); + !MsqIsHung(Window->head.pti->MessageQueue)); // FIXME - Set window hung and add to a list. IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, (LRESULT *)uResult); @@ -1348,7 +1349,13 @@ co_IntSendMessageNoWait(HWND hWnd, &Result); return Result; } - +/* MSDN: + If you send a message in the range below WM_USER to the asynchronous message + functions (PostMessage, SendNotifyMessage, and SendMessageCallback), its + message parameters cannot include pointers. Otherwise, the operation will fail. + The functions will return before the receiving thread has had a chance to + process the message and the sender will free the memory before it is used. +*/ LRESULT FASTCALL co_IntSendMessageWithCallBack( HWND hWnd, UINT Msg, @@ -2014,24 +2021,23 @@ NtUserMessageCall( HWND hWnd, UserEnterExclusive(); - /* Validate input */ - if (hWnd && (hWnd != INVALID_HANDLE_VALUE)) - { - Window = UserGetWindowObject(hWnd); - if (!Window) - { - UserLeave(); - return FALSE; - } - } - switch(dwType) { case FNID_DEFWINDOWPROC: - if (Window) UserRefObjectCo(Window, &Ref); + /* Validate input */ + if (hWnd && (hWnd != INVALID_HANDLE_VALUE)) + { + Window = UserGetWindowObject(hWnd); + if (!Window) + { + UserLeave(); + return FALSE; + } + } + UserRefObjectCo(Window, &Ref); lResult = IntDefWindowProc(Window, Msg, wParam, lParam, Ansi); Ret = TRUE; - if (Window) UserDerefObjectCo(Window); + UserDerefObjectCo(Window); break; case FNID_SENDNOTIFYMESSAGE: Ret = UserSendNotifyMessage(hWnd, Msg, wParam, lParam); @@ -2050,7 +2056,6 @@ NtUserMessageCall( HWND hWnd, } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - Ret = FALSE; _SEH2_YIELD(break); } _SEH2_END; @@ -2121,13 +2126,18 @@ NtUserMessageCall( HWND hWnd, } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - Ret = FALSE; _SEH2_YIELD(break); } _SEH2_END; - if (!co_IntSendMessageWithCallBack(hWnd, Msg, wParam, lParam, - CallBackInfo.CallBack, CallBackInfo.Context, &uResult)) + if (is_pointer_message(Msg)) + { + EngSetLastError(ERROR_MESSAGE_SYNC_ONLY ); + break; + } + + if (!(Ret = co_IntSendMessageWithCallBack(hWnd, Msg, wParam, lParam, + CallBackInfo.CallBack, CallBackInfo.Context, &uResult))) { DPRINT1("Callback failure!\n"); } @@ -2165,7 +2175,6 @@ NtUserMessageCall( HWND hWnd, } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - Ret = FALSE; _SEH2_YIELD(break); } _SEH2_END; diff --git a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c index f225950dfd6..9f0706706af 100644 --- a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c +++ b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c @@ -121,7 +121,7 @@ ClearMsgBitsMask(PUSER_MESSAGE_QUEUE Queue, UINT MessageBits) pti = Queue->Thread->Tcb.Win32Thread; if (MessageBits & QS_KEY) - { + { if (--Queue->nCntsQBits[QSRosKey] == 0) ClrMask |= QS_KEY; } if (MessageBits & QS_MOUSEMOVE) // ReactOS hard coded. @@ -244,7 +244,13 @@ co_MsqInsertMouseMessage(MSG* Msg) pwnd != NULL; pwnd = pwnd->spwndNext ) { - if((pwnd->style & WS_VISIBLE) && + if ( pwnd->state2 & WNDS2_INDESTROY || pwnd->state & WNDS_DESTROYED ) + { + DPRINT("The Window is in DESTROY!\n"); + continue; + } + + if((pwnd->style & WS_VISIBLE) && IntPtInWindow(pwnd, Msg->pt.x, Msg->pt.y)) { Msg->hwnd = pwnd->head.h; @@ -623,7 +629,7 @@ co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, UINT uTimeout, BOOL Block, INT HookMessage, ULONG_PTR *uResult) { - PTHREADINFO pti; + PTHREADINFO pti, ptirec; PUSER_SENT_MESSAGE Message; KEVENT CompletionEvent; NTSTATUS WaitStatus; @@ -642,8 +648,10 @@ co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, pti = PsGetCurrentThreadWin32Thread(); ThreadQueue = pti->MessageQueue; + ptirec = MessageQueue->Thread->Tcb.Win32Thread; ASSERT(ThreadQueue != MessageQueue); - + ASSERT(ptirec->pcti); // Send must have a client side to receive it!!!! + Timeout.QuadPart = (LONGLONG) uTimeout * (LONGLONG) -10000; /* FIXME - increase reference counter of sender's message queue here */ @@ -727,7 +735,7 @@ co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, Entry = Entry->Flink; } - DPRINT("MsqSendMessage (blocked) timed out\n"); + DPRINT("MsqSendMessage (blocked) timed out 1\n"); } while (co_MsqDispatchOneSentMessage(ThreadQueue)) ; @@ -787,7 +795,7 @@ co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, Entry = Entry->Flink; } - DPRINT("MsqSendMessage timed out\n"); + DPRINT("MsqSendMessage timed out 2\n"); break; } while (co_MsqDispatchOneSentMessage(ThreadQueue)) @@ -860,7 +868,7 @@ static void MsqSendParentNotify( PWND pwnd, WORD event, WORD idChild, POINT pt ) if (pwndParent == pwndDesktop) break; pt.x += pwnd->rcClient.left - pwndParent->rcClient.left; pt.y += pwnd->rcClient.top - pwndParent->rcClient.top; - + pwnd = pwndParent; co_IntSendMessage( UserHMGetHandle(pwnd), WM_PARENTNOTIFY, MAKEWPARAM( event, idChild ), MAKELPARAM( pt.x, pt.y ) ); @@ -902,7 +910,7 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT } DPRINT("Got mouse message for 0x%x, hittest: 0x%x\n", msg->hwnd, hittest ); - + if (pwndMsg == NULL || pwndMsg->head.pti != pti) { /* Remove and ignore the message */ @@ -972,7 +980,7 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT } } - if (!((first == 0 && last == 0) || (message >= first || message <= last))) + if (!((first == 0 && last == 0) || (message >= first || message <= last))) { DPRINT("Message out of range!!!\n"); RETURN(FALSE); @@ -1095,8 +1103,8 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT if (pwndTop && pwndTop != pwndDesktop) { - LONG ret = co_IntSendMessage( msg->hwnd, - WM_MOUSEACTIVATE, + LONG ret = co_IntSendMessage( msg->hwnd, + WM_MOUSEACTIVATE, (WPARAM)UserHMGetHandle(pwndTop), MAKELONG( hittest, msg->message)); switch(ret) @@ -1250,7 +1258,7 @@ co_MsqPeekHardwareMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry); - do + do { if (IsListEmpty(CurrentEntry)) break; if (!CurrentMessage) break; @@ -1296,7 +1304,7 @@ MsqPeekMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, PLIST_ENTRY CurrentEntry; PUSER_MESSAGE CurrentMessage; PLIST_ENTRY ListHead; - + CurrentEntry = MessageQueue->PostedMessagesListHead.Flink; ListHead = &MessageQueue->PostedMessagesListHead; @@ -1309,8 +1317,15 @@ MsqPeekMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, if (IsListEmpty(CurrentEntry)) break; if (!CurrentMessage) break; CurrentEntry = CurrentEntry->Flink; - - if ( ( !Window || Window == HWND_BOTTOM || Window->head.h == CurrentMessage->Msg.hwnd ) && +/* + MSDN: + 1: any window that belongs to the current thread, and any messages on the current thread's message queue whose hwnd value is NULL. + 2: retrieves only messages on the current thread's message queue whose hwnd value is NULL. + 3: handle to the window whose messages are to be retrieved. + */ + if ( ( !Window || // 1 + ( Window == HWND_BOTTOM && CurrentMessage->Msg.hwnd == NULL ) || // 2 + ( Window != HWND_BOTTOM && Window->head.h == CurrentMessage->Msg.hwnd ) ) && // 3 ( ( ( MsgFilterLow == 0 && MsgFilterHigh == 0 ) && CurrentMessage->QS_Flags & QSflags ) || ( MsgFilterLow <= CurrentMessage->Msg.message && MsgFilterHigh >= CurrentMessage->Msg.message ) ) ) { @@ -1342,7 +1357,7 @@ co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, PWND WndFilter, ret = KeWaitForSingleObject(MessageQueue->NewMessages, Executive, UserMode, - FALSE, + FALSE, NULL); UserEnterCo(); return ret; @@ -1357,6 +1372,15 @@ MsqIsHung(PUSER_MESSAGE_QUEUE MessageQueue) return ((LargeTickCount.u.LowPart - MessageQueue->LastMsgRead) > MSQ_HUNG); } +VOID +CALLBACK +HungAppSysTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +{ + //DoTheScreenSaver(); + DPRINT("HungAppSysTimerProc\n"); + // Process list of windows that are hung and waiting. +} + BOOLEAN FASTCALL MsqInitializeMessageQueue(struct _ETHREAD *Thread, PUSER_MESSAGE_QUEUE MessageQueue) { @@ -1405,7 +1429,7 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue) PUSER_MESSAGE CurrentMessage; PUSER_SENT_MESSAGE CurrentSentMessage; PTHREADINFO pti; - + pti = MessageQueue->Thread->Tcb.Win32Thread; @@ -1428,7 +1452,7 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue) DPRINT("Notify the sender and remove a message from the queue that had not been dispatched\n"); /* remove the message from the dispatching list if needed */ - if ((!(CurrentSentMessage->HookMessage & MSQ_SENTNOWAIT)) + if ((!(CurrentSentMessage->HookMessage & MSQ_SENTNOWAIT)) && (CurrentSentMessage->DispatchingListEntry.Flink != NULL)) { RemoveEntryList(&CurrentSentMessage->DispatchingListEntry); @@ -1555,6 +1579,8 @@ MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue) { PDESKTOP desk; + MessageQueue->QF_flags |= QF_INDESTROY; + /* remove the message queue from any desktops */ if ((desk = InterlockedExchangePointer((PVOID*)&MessageQueue->Desktop, 0))) { From 0ca9a93ca6ccdd8095e0d17e40b5cf8dfb94abd6 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Fri, 1 Apr 2011 10:06:03 +0000 Subject: [PATCH 45/66] [KERNEL32] - Implement a simple version of BasepGetDllPath()/BasepGetProcessPath(). svn path=/trunk/; revision=51217 --- reactos/dll/win32/kernel32/include/kernel32.h | 2 + reactos/dll/win32/kernel32/misc/dllmain.c | 2 - reactos/dll/win32/kernel32/process/procsup.c | 187 ++++++++++++++++++ 3 files changed, 189 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/kernel32/include/kernel32.h b/reactos/dll/win32/kernel32/include/kernel32.h index d6361b3bdfe..ef74e9e69ad 100755 --- a/reactos/dll/win32/kernel32/include/kernel32.h +++ b/reactos/dll/win32/kernel32/include/kernel32.h @@ -94,6 +94,8 @@ extern HMODULE hCurrentModule; extern RTL_CRITICAL_SECTION BaseDllDirectoryLock; extern UNICODE_STRING BaseDllDirectory; +extern UNICODE_STRING BaseDefaultPath; +extern UNICODE_STRING BaseDefaultPathAppend; extern LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter; diff --git a/reactos/dll/win32/kernel32/misc/dllmain.c b/reactos/dll/win32/kernel32/misc/dllmain.c index f43b9b27b69..c29a1828481 100644 --- a/reactos/dll/win32/kernel32/misc/dllmain.c +++ b/reactos/dll/win32/kernel32/misc/dllmain.c @@ -21,8 +21,6 @@ extern UNICODE_STRING SystemDirectory; extern UNICODE_STRING WindowsDirectory; -extern UNICODE_STRING BaseDefaultPath; -extern UNICODE_STRING BaseDefaultPathAppend; WCHAR BaseDefaultPathBuffer[6140]; diff --git a/reactos/dll/win32/kernel32/process/procsup.c b/reactos/dll/win32/kernel32/process/procsup.c index a4d35d786d7..95f415b9a04 100644 --- a/reactos/dll/win32/kernel32/process/procsup.c +++ b/reactos/dll/win32/kernel32/process/procsup.c @@ -16,6 +16,7 @@ UNICODE_STRING BasePathVariableName = RTL_CONSTANT_STRING(L"PATH"); UNICODE_STRING BaseDefaultPath; +PLDR_DATA_TABLE_ENTRY BasepExeLdrEntry; #define CMD_STRING L"cmd /c " @@ -355,12 +356,194 @@ BasepDuplicateAndWriteHandle(IN HANDLE ProcessHandle, } } +VOID +NTAPI +BasepLocateExeLdrEntry(IN PLDR_DATA_TABLE_ENTRY Entry, + IN PVOID Context, + OUT BOOLEAN *StopEnumeration) +{ + /* Make sure we get Entry, Context and valid StopEnumeration pointer */ + ASSERT(Entry); + ASSERT(Context); + ASSERT(StopEnumeration); + + /* If entry is already found - signal to stop */ + if (BasepExeLdrEntry) + { + /* Signal to stop enumeration and return */ + *StopEnumeration = TRUE; + return; + } + + /* We don't have a exe ldr entry, so try to see if this one is ours + by matching base address */ + if (Entry->DllBase == Context) + { + /* It matches, so remember the ldr entry */ + BasepExeLdrEntry = Entry; + + /* And stop enumeration */ + *StopEnumeration = TRUE; + } +} + LPWSTR WINAPI BasepGetProcessPath(DWORD Reserved, LPWSTR FullPath, PVOID Environment) { + NTSTATUS Status; + LPWSTR AllocatedPath = NULL, ch; + ULONG DefaultLength = BaseDefaultPath.Length; + ULONG AppLength = 0; + UNICODE_STRING EnvPath; + LPWSTR NamePtr; + LPWSTR PathBuffer; + BOOLEAN SecondAttempt = FALSE; + PPEB Peb = NtCurrentPeb(); + + if (!Environment) RtlAcquirePebLock(); + + /* Query PATH env var into append path */ + Status = RtlQueryEnvironmentVariable_U(Environment, + &BasePathVariableName, + &BaseDefaultPathAppend); + if (NT_SUCCESS(Status)) + { + /* Add up PATH environment length */ + DefaultLength += BaseDefaultPathAppend.Length; + } + else if (Status == STATUS_BUFFER_TOO_SMALL) + { + /* We have to allocate path dynamically */ + AllocatedPath = RtlAllocateHeap(RtlGetProcessHeap(), 0, BaseDefaultPathAppend.Length + sizeof(UNICODE_NULL)); + + if (AllocatedPath) + { + /* Set up EnvPath */ + EnvPath.Buffer = AllocatedPath; + EnvPath.Length = BaseDefaultPathAppend.Length + sizeof(UNICODE_NULL); + EnvPath.MaximumLength = EnvPath.Length; + + /* Query PATH env var into newly allocated path */ + Status = RtlQueryEnvironmentVariable_U(Environment, + &BasePathVariableName, + &EnvPath); + + if (NT_SUCCESS(Status)) + { + DefaultLength += EnvPath.Length; + } + else + { + /* Free newly allocated path, it didn't work */ + RtlFreeHeap(RtlGetProcessHeap(), 0, AllocatedPath); + AllocatedPath = NULL; + Status = STATUS_NO_MEMORY; + } + } + } + +secondattempt: + if (!FullPath) + { + /* Initialize BasepExeLdrEntry if necessary */ + if (!BasepExeLdrEntry) + LdrEnumerateLoadedModules(0, BasepLocateExeLdrEntry, Peb->ImageBaseAddress); + + DPRINT1("Found BasepExeLdrEntry %wZ\n", &BasepExeLdrEntry->FullDllName); + + /* Set name pointer to the full dll path */ + NamePtr = BasepExeLdrEntry->FullDllName.Buffer; + } + else + { + /* Set name pointer to the provided path */ + NamePtr = FullPath; + } + + /* Determine application path length */ + if (NamePtr) + { + ch = NamePtr; + while (*ch) + { + /* Check if there is a slash */ + if (*ch == L'\\') + { + /* Update app length */ + AppLength = (ULONG_PTR)ch - (ULONG_PTR)NamePtr + sizeof(WCHAR); + } + + ch++; + } + } + + /* Now check, if we found a valid path in the provided full path */ + if (!AppLength && FullPath && !SecondAttempt) + { + /* We were provided with a bad full path, retry again using just this app's path */ + FullPath = NULL; + SecondAttempt = TRUE; + goto secondattempt; + } + + /* Allocate the path buffer */ + PathBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, DefaultLength + AppLength + 2*sizeof(WCHAR)); + if (!PathBuffer) + { + /* Fail */ + if (!Environment) RtlReleasePebLock(); + if (AllocatedPath) RtlFreeHeap(RtlGetProcessHeap(), 0, AllocatedPath); + return NULL; + } + + /* Copy contents there */ + if (AppLength) + { + /* Remove trailing slashes if it's not root dir */ + if (AppLength != 3*sizeof(WCHAR)) + AppLength -= sizeof(WCHAR); + + /* Copy contents */ + RtlMoveMemory(PathBuffer, NamePtr, AppLength); + } + + /* Release the lock */ + if (!Environment) RtlReleasePebLock(); + + /* Finish preparing the path string */ + NamePtr = &PathBuffer[AppLength / sizeof(WCHAR)]; + + /* Put a separating ";" if something was added */ + if (AppLength) + { + *NamePtr = L';'; + NamePtr++; + } + + if (AllocatedPath) + { + /* Dynamically allocated env path, copy from the static buffer, + concatenate with dynamic buffer and free it */ + RtlMoveMemory(NamePtr, BaseDefaultPath.Buffer, BaseDefaultPath.Length); + RtlMoveMemory(&NamePtr[BaseDefaultPath.Length / sizeof(WCHAR)], AllocatedPath, EnvPath.Length); + + /* Free it */ + RtlFreeHeap(RtlGetProcessHeap(), 0, AllocatedPath); + } + else + { + /* Static env path string, copy directly from BaseDefaultPath */ + RtlMoveMemory(NamePtr, BaseDefaultPath.Buffer, DefaultLength); + } + + /* Null terminate the string */ + NamePtr[DefaultLength / sizeof(WCHAR)] = 0; + + DPRINT("Path: %S\n", NamePtr); + return NULL; } @@ -369,6 +552,7 @@ WINAPI BasepGetDllPath(LPWSTR FullPath, PVOID Environment) { +#if 0 LPWSTR DllPath = NULL; /* Acquire DLL directory lock */ @@ -395,6 +579,9 @@ BasepGetDllPath(LPWSTR FullPath, /* Return dll path */ return DllPath; +#else + return BasepGetProcessPath(0, FullPath, Environment); +#endif } VOID From 472df5e17a512918c02e4ab5de59924231a3cc54 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Fri, 1 Apr 2011 12:18:54 +0000 Subject: [PATCH 46/66] - Fix build. Happens. svn path=/trunk/; revision=51218 --- reactos/include/ndk/ldrtypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/include/ndk/ldrtypes.h b/reactos/include/ndk/ldrtypes.h index 49ebe38cd55..aaf790ab6e5 100644 --- a/reactos/include/ndk/ldrtypes.h +++ b/reactos/include/ndk/ldrtypes.h @@ -191,7 +191,7 @@ typedef struct _ALT_RESOURCE_MODULE // // Callback function for LdrEnumerateLoadedModules // -typedef NTSTATUS (NTAPI LDR_ENUM_CALLBACK)(IN PLDR_DATA_TABLE_ENTRY ModuleInformation, IN PVOID Parameter, OUT BOOLEAN *Stop); +typedef VOID (NTAPI LDR_ENUM_CALLBACK)(IN PLDR_DATA_TABLE_ENTRY ModuleInformation, IN PVOID Parameter, OUT BOOLEAN *Stop); typedef LDR_ENUM_CALLBACK *PLDR_ENUM_CALLBACK; #endif From 7c126a9a69cffd5b1c8e8889669aa90998a6fb3a Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Fri, 1 Apr 2011 18:58:12 +0000 Subject: [PATCH 47/66] [SYSTEMINFO] Don't translate System Type Don't mix TCHARs and chars Fix Time Zone for not English systems Use proper registry key for Install Date Format dates using system settings Format numbers svn path=/trunk/; revision=51221 --- .../sysutils/systeminfo/lang/de-DE.rc | 22 +- .../sysutils/systeminfo/lang/en-US.rc | 22 +- .../sysutils/systeminfo/lang/es-ES.rc | 20 +- .../sysutils/systeminfo/lang/fr-FR.rc | 20 +- .../sysutils/systeminfo/lang/no-NO.rc | 22 +- .../sysutils/systeminfo/lang/pl-PL.rc | 22 +- .../sysutils/systeminfo/lang/sk-SK.rc | 20 +- .../sysutils/systeminfo/lang/uk-UA.rc | 22 +- .../sysutils/systeminfo/resource.h | 6 +- .../sysutils/systeminfo/systeminfo.c | 507 +++++++++++------- 10 files changed, 395 insertions(+), 288 deletions(-) diff --git a/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc b/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc index 18efe35948b..f161f72c54c 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc @@ -38,15 +38,11 @@ IDS_OS_BUILD_TYPE, "OS Build Typ: %s\n" IDS_REG_OWNER, "Registrierter Benutzer: %s\n" IDS_REG_ORG, "Registrierte Organisation: %s\n" IDS_PRODUCT_ID, "Produkt ID: %s\n" -IDS_INST_DATE, "Installationsdatum: %s, " -IDS_INST_TIME, "%s\n" +IDS_INST_DATE, "Installationsdatum: %s\n" IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" IDS_SYS_MODEL, "System Model: %s\n" -IDS_SYS_TYPE_UNKNOWN, "Systemtyp: Unbekannt\n" -IDS_SYS_TYPE_X86, "Systemtyp: X86-based PC\n" -IDS_SYS_TYPE_IA64, "Systemtyp: IA64-based PC\n" -IDS_SYS_TYPE_AMD64, "Systemtyp: AMD64-based PC\n" +IDS_SYS_TYPE, "Systemtyp: %s\n" IDS_PROCESSORS, "Prozessor(en): %u Prozessor(en) Installiert.\n" IDS_BIOS_DATE, "BIOS Datum: %s\n" IDS_BIOS_VERSION, "BIOS Version: %s\n" @@ -55,13 +51,13 @@ IDS_SYS_DIR, "System Verzeichnis: %s\n" IDS_BOOT_DEV, "Startgert: %s\n" IDS_SYS_LOCALE, "Systemgebietsschema: %s\n" IDS_INPUT_LOCALE, "Eingabegebietsschema: %s\n" -IDS_TOTAL_PHYS_MEM, "Gesamter Physikalischer Speicher: %ld MB (%ld KB)\n" -IDS_AVAIL_PHISICAL_MEM, "Verfgbarer Physikalischer Speicher: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_MAX, "Auslagerungsdatei: Max Gre: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_AVAIL, "Auslagerungsdatei: Verfgbar: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_INUSE, "Auslagerungsdatei: In Verwendung: %ld MB (%ld KB)\n" -IDS_PAGEFILE_LOC, "Auslagerungsdateipfad(e) %s" -IDS_TIME_ZONE, "Zeitzone: %s\n" +IDS_TIME_ZONE, "Zeitzone: %s\n" +IDS_TOTAL_PHYS_MEM, "Gesamter Physikalischer Speicher: %s MB\n" +IDS_AVAIL_PHISICAL_MEM, "Verfgbarer Physikalischer Speicher: %s MB\n" +IDS_VIRT_MEM_MAX, "Auslagerungsdatei: Max Gre: %s MB\n" +IDS_VIRT_MEM_AVAIL, "Auslagerungsdatei: Verfgbar: %s MB\n" +IDS_VIRT_MEM_INUSE, "Auslagerungsdatei: In Verwendung: %s MB\n" +IDS_PAGEFILE_LOC, "Auslagerungsdateipfad(e): %s" IDS_DOMINE, "Domain: %s\n" IDS_NETWORK_CARDS, "Netzwerkkarte(n) %u Installiert.\n" diff --git a/rosapps/applications/sysutils/systeminfo/lang/en-US.rc b/rosapps/applications/sysutils/systeminfo/lang/en-US.rc index 6c2053f836c..d7731b67229 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/en-US.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/en-US.rc @@ -36,15 +36,11 @@ IDS_OS_BUILD_TYPE, "OS Build Type: %s\n" IDS_REG_OWNER, "Registered Owner: %s\n" IDS_REG_ORG, "Registered Organization: %s\n" IDS_PRODUCT_ID, "Product ID: %s\n" -IDS_INST_DATE, "Install Date: %s, " -IDS_INST_TIME, "%s\n" +IDS_INST_DATE, "Install Date: %s\n" IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" IDS_SYS_MODEL, "System Model: %s\n" -IDS_SYS_TYPE_UNKNOWN, "System type: Unknown\n" -IDS_SYS_TYPE_X86, "System type: X86-based PC\n" -IDS_SYS_TYPE_IA64, "System type: IA64-based PC\n" -IDS_SYS_TYPE_AMD64, "System type: AMD64-based PC\n" +IDS_SYS_TYPE, "System type: %s\n" IDS_PROCESSORS, "Processor(s): %u Processor(s) Installed.\n" IDS_BIOS_DATE, "BIOS Date: %s\n" IDS_BIOS_VERSION, "BIOS Version: %s\n" @@ -53,13 +49,13 @@ IDS_SYS_DIR, "System Directory: %s\n" IDS_BOOT_DEV, "Boot Device: %s\n" IDS_SYS_LOCALE, "System Locale: %s\n" IDS_INPUT_LOCALE, "Input Locale: %s\n" -IDS_TOTAL_PHYS_MEM, "Total Physical Memory: %ld MB (%ld KB)\n" -IDS_AVAIL_PHISICAL_MEM, "Available Physical Memory: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_MAX, "Virtual Memory: Max Size: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_AVAIL, "Virtual Memory: Available: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_INUSE, "Virtual Memory: In Use: %ld MB (%ld KB)\n" -IDS_PAGEFILE_LOC, "Page File Location(s) %s\n" -IDS_TIME_ZONE, "Time zone: %s\n" +IDS_TIME_ZONE, "Time zone: %s\n" +IDS_TOTAL_PHYS_MEM, "Total Physical Memory: %s MB\n" +IDS_AVAIL_PHISICAL_MEM, "Available Physical Memory: %s MB\n" +IDS_VIRT_MEM_MAX, "Virtual Memory: Max Size: %s MB\n" +IDS_VIRT_MEM_AVAIL, "Virtual Memory: Available: %s MB\n" +IDS_VIRT_MEM_INUSE, "Virtual Memory: In Use: %s MB\n" +IDS_PAGEFILE_LOC, "Page File Location(s): %s\n" IDS_DOMINE, "Domain: %s\n" IDS_NETWORK_CARDS, "Network Card(s) %u Installed.\n" diff --git a/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc b/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc index 21491ba7075..423c67d0374 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc @@ -41,15 +41,11 @@ IDS_OS_BUILD_TYPE, "Tipo Compilaci IDS_REG_OWNER, "Propietario: %s\n" IDS_REG_ORG, "Organizacin: %s\n" IDS_PRODUCT_ID, "Identificador de Producto %s\n" -IDS_INST_DATE, "Fecha de Instalacin: %s, " -IDS_INST_TIME, "%s\n" +IDS_INST_DATE, "Fecha de Instalacin: %s\n" IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" IDS_SYS_MODEL, "System Model: %s\n" -IDS_SYS_TYPE_UNKNOWN, "Tipo de sistema: Desconocido\n" -IDS_SYS_TYPE_X86, "Tipo de sistema: PC basado en X86\n" -IDS_SYS_TYPE_IA64, "Tipo de sistema: PC basado en IA64\n" -IDS_SYS_TYPE_AMD64, "Tipo de sistema: PC basado en AMD64\n" +IDS_SYS_TYPE, "Tipo de sistema: %s\n" IDS_PROCESSORS, "Procesador(es): %u Procesador(es) Instalados.\n" IDS_BIOS_DATE, "Fecha BIOS: %s\n" IDS_BIOS_VERSION, "Versin BIOS: %s\n" @@ -58,13 +54,13 @@ IDS_SYS_DIR, "Directorio del Sistema: %s\n" IDS_BOOT_DEV, "Dispositivo de Inicio: %s\n" IDS_SYS_LOCALE, "Idioma del sistema: %s\n" IDS_INPUT_LOCALE, "Idioma de entrada: %s\n" -IDS_TOTAL_PHYS_MEM, "Memoria Fsica Total: %ld MB (%ld KB)\n" -IDS_AVAIL_PHISICAL_MEM, "Memoria Fsica Disponible: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_MAX, "Memoria Virtual: Tamao Mx: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_AVAIL, "Memoria Virtual: Disponible: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_INUSE, "Memoria Virtual: En Uso: %ld MB (%ld KB)\n" -IDS_PAGEFILE_LOC, "Ruta(s) Archivo Paginacin %s\n" IDS_TIME_ZONE, "Zona horario: %s\n" +IDS_TOTAL_PHYS_MEM, "Memoria Fsica Total: %s MB\n" +IDS_AVAIL_PHISICAL_MEM, "Memoria Fsica Disponible: %s MB\n" +IDS_VIRT_MEM_MAX, "Memoria Virtual: Tamao Mx: %s MB\n" +IDS_VIRT_MEM_AVAIL, "Memoria Virtual: Disponible: %s MB\n" +IDS_VIRT_MEM_INUSE, "Memoria Virtual: En Uso: %s MB\n" +IDS_PAGEFILE_LOC, "Ruta(s) Archivo Paginacin: %s\n" IDS_DOMINE, "Dominio: %s\n" IDS_NETWORK_CARDS, "Tarjeta(s) de Red %u No Instalada.\n" diff --git a/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc b/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc index d99900e1ab1..4d9c9a4ae3b 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc @@ -36,15 +36,11 @@ IDS_OS_BUILD_TYPE, "Type de compilation du syst IDS_REG_OWNER, "Propritaire enregistr : %s\n" IDS_REG_ORG, "Organisation enregistre : %s\n" IDS_PRODUCT_ID, "ID du produit : %s\n" -IDS_INST_DATE, "Date d'installation : %s, " -IDS_INST_TIME, "%s\n" +IDS_INST_DATE, "Date d'installation : %s\n" IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" IDS_SYS_MODEL, "System Model: %s\n" -IDS_SYS_TYPE_UNKNOWN, "Type du systme : Inconnu\n" -IDS_SYS_TYPE_X86, "Type du systme : Bas sur un PC X86\n" -IDS_SYS_TYPE_IA64, "Type du systme : Bas sur un PC IA64\n" -IDS_SYS_TYPE_AMD64, "Type du systme : Bas sur un PC AMD64\n" +IDS_SYS_TYPE, "Type du systme : %s\n" IDS_PROCESSORS, "Processeur(s) : %u Processeur(s) install(s).\n" IDS_BIOS_DATE, "Date du BIOS : %s\n" IDS_BIOS_VERSION, "Version du BIOS : %s\n" @@ -53,13 +49,13 @@ IDS_SYS_DIR, "R IDS_BOOT_DEV, "Priphrique de dmarrage : %s\n" IDS_SYS_LOCALE, "Paramtre rgional du systme : %s\n" IDS_INPUT_LOCALE, "Paramtre rgional de saisie : %s\n" -IDS_TOTAL_PHYS_MEM, "Mmoire physique totale : %ld Mo (%ld Ko)\n" -IDS_AVAIL_PHISICAL_MEM, "Mmoire physique disponible : %ld Mo (%ld Ko)\n" -IDS_VIRT_MEM_MAX, "Mmoire virtuelle: Taille max : %ld Mo (%ld Ko)\n" -IDS_VIRT_MEM_AVAIL, "Mmoire virtuelle: Disponible : %ld Mo (%ld Ko)\n" -IDS_VIRT_MEM_INUSE, "Mmoire virtuelle: Utilise : %ld Mo (%ld Ko)\n" -IDS_PAGEFILE_LOC, "Emplacement(s) des fichiers d'change %s" IDS_TIME_ZONE, "Fuseau horaire : %s\n" +IDS_TOTAL_PHYS_MEM, "Mmoire physique totale : %s Mo\n" +IDS_AVAIL_PHISICAL_MEM, "Mmoire physique disponible : %s Mo\n" +IDS_VIRT_MEM_MAX, "Mmoire virtuelle: Taille max : %s Mo\n" +IDS_VIRT_MEM_AVAIL, "Mmoire virtuelle: Disponible : %s Mo\n" +IDS_VIRT_MEM_INUSE, "Mmoire virtuelle: Utilise : %s Mo\n" +IDS_PAGEFILE_LOC, "Emplacement(s) des fichiers d'change : %s" IDS_DOMINE, "Domaine : %s\n" IDS_NETWORK_CARDS, "Carte(s) rseau %u installe(s).\n" diff --git a/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc b/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc index 0beda9afec7..e4e49667182 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc @@ -36,15 +36,11 @@ IDS_OS_BUILD_TYPE, "OS bygg type: %s\n" IDS_REG_OWNER, "Registert eier: %s\n" IDS_REG_ORG, "Registerert organisasjon: %s\n" IDS_PRODUCT_ID, "Produkt ID: %s\n" -IDS_INST_DATE, "Installert dato: %s, " -IDS_INST_TIME, "%s\n" +IDS_INST_DATE, "Installert dato: %s\n" IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" IDS_SYS_MODEL, "System Model: %s\n" -IDS_SYS_TYPE_UNKNOWN, "Systemtype: Ukjent\n" -IDS_SYS_TYPE_X86, "Systemtype: X86-basert PC\n" -IDS_SYS_TYPE_IA64, "Systemtype: IA64-basert PC\n" -IDS_SYS_TYPE_AMD64, "Systemtype: AMD64-basert PC\n" +IDS_SYS_TYPE, "Systemtype: %s\n" IDS_PROCESSORS, "Prosessor(er): %u Prosessor(er) installert.\n" IDS_BIOS_DATE, "BIOS dato: %s\n" IDS_BIOS_VERSION, "BIOS Versjon: %s\n" @@ -53,13 +49,13 @@ IDS_SYS_DIR, "System mappe: %s\n" IDS_BOOT_DEV, "Oppstartsenhet: %s\n" IDS_SYS_LOCALE, "System lokal: %s\n" IDS_INPUT_LOCALE, "Input lokal: %s\n" -IDS_TOTAL_PHYS_MEM, "Total fysisk minne: %ld MB (%ld KB)\n" -IDS_AVAIL_PHISICAL_MEM, "Tilgjengelig fysisk minne: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_MAX, "Virtuelt minne: Maks Strrelse: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_AVAIL, "Virtuelt minne: Tilgjengelig: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_INUSE, "Virtuelt minne: i bruk: %ld MB (%ld KB)\n" -IDS_PAGEFILE_LOC, "Sidevekslingsfil lokalsjon(er) %s\n" -IDS_TIME_ZONE, "Tidssone: %s\n" +IDS_TIME_ZONE, "Tidssone: %s\n" +IDS_TOTAL_PHYS_MEM, "Total fysisk minne: %s MB\n" +IDS_AVAIL_PHISICAL_MEM, "Tilgjengelig fysisk minne: %s MB\n" +IDS_VIRT_MEM_MAX, "Virtuelt minne: Maks Strrelse: %s MB\n" +IDS_VIRT_MEM_AVAIL, "Virtuelt minne: Tilgjengelig: %s MB\n" +IDS_VIRT_MEM_INUSE, "Virtuelt minne: i bruk: %s MB\n" +IDS_PAGEFILE_LOC, "Sidevekslingsfil lokalsjon(er): %s\n" IDS_DOMINE, "Domene: %s\n" IDS_NETWORK_CARDS, "Nettverkskort(er) %u installert.\n" diff --git a/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc b/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc index 6f48d0656ee..749a63fc5d9 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc @@ -43,15 +43,11 @@ IDS_OS_BUILD_TYPE, "Rodzaj kompilacji: %s\n" IDS_REG_OWNER, "Uytkownik: %s\n" IDS_REG_ORG, "Organizacja: %s\n" IDS_PRODUCT_ID, "ID produktu: %s\n" -IDS_INST_DATE, "Data instalacji: %s, " -IDS_INST_TIME, "%s\n" +IDS_INST_DATE, "Data instalacji: %s\n" IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "Producent systemu: %s\n" IDS_SYS_MODEL, "Model systemu: %s\n" -IDS_SYS_TYPE_UNKNOWN, "Rodzaj systemu: Unknown\n" -IDS_SYS_TYPE_X86, "Architektura: X86-based PC\n" -IDS_SYS_TYPE_IA64, "Architektura: IA64-based PC\n" -IDS_SYS_TYPE_AMD64, "Rodzaj systemu: AMD64-based PC\n" +IDS_SYS_TYPE, "Rodzaj systemu: %s\n" IDS_PROCESSORS, "Ilo Procesorw: %u.\n" IDS_BIOS_DATE, "Data BIOSu: %s\n" IDS_BIOS_VERSION, "Wersja BIOSu: %s\n" @@ -60,13 +56,13 @@ IDS_SYS_DIR, "Katalog Systemowy: %s\n" IDS_BOOT_DEV, "Urzdzenie rdowe: %s\n" IDS_SYS_LOCALE, "Wersja lokalizacji: %s\n" IDS_INPUT_LOCALE, "Lokalizacja klawiatury: %s\n" -IDS_TOTAL_PHYS_MEM, "Pamici fizycznej ogem: %ld MB (%ld KB)\n" -IDS_AVAIL_PHISICAL_MEM, "Dostpnej pamici fizycznej: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_MAX, "Pamici wirtualnej: Maksymalnie: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_AVAIL, "Pamici wirtualnej: Dostpne: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_INUSE, "Pamici wirtualnej: W uyciu: %ld MB (%ld KB)\n" -IDS_PAGEFILE_LOC, "Lokalizacja pliku wymiany %s\n" -IDS_TIME_ZONE, "Strefa czasowa: %s\n" +IDS_TIME_ZONE, "Strefa czasowa: %s\n" +IDS_TOTAL_PHYS_MEM, "Pamici fizycznej ogem: %s MB\n" +IDS_AVAIL_PHISICAL_MEM, "Dostpnej pamici fizycznej: %s MB\n" +IDS_VIRT_MEM_MAX, "Pamici wirtualnej: maksymalnie: %s MB\n" +IDS_VIRT_MEM_AVAIL, "Pamici wirtualnej: dostpne: %s MB\n" +IDS_VIRT_MEM_INUSE, "Pamici wirtualnej: w uyciu: %s MB\n" +IDS_PAGEFILE_LOC, "Lokalizacja pliku wymiany: %s\n" IDS_DOMINE, "Domena: %s\n" IDS_NETWORK_CARDS, "Liczba kart sieciowych %u.\n" diff --git a/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc b/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc index cfe27484ec7..f53414670f2 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc @@ -40,15 +40,11 @@ IDS_OS_BUILD_TYPE, "OS Build typ: %s\n" IDS_REG_OWNER, "Registovan vlastnk: %s\n" IDS_REG_ORG, "Registrovan organizcia: %s\n" IDS_PRODUCT_ID, "ID produktu: %s\n" -IDS_INST_DATE, "Dtum intalcie: %s, " -IDS_INST_TIME, "%s\n" +IDS_INST_DATE, "Dtum intalcie: %s\n" IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" IDS_SYS_MODEL, "System Model: %s\n" -IDS_SYS_TYPE_UNKNOWN, "Typ systmu: Neznmy\n" -IDS_SYS_TYPE_X86, "Typ systmu: PC zaloen na X86\n" -IDS_SYS_TYPE_IA64, "Typ systmu: PC zaloen na IA64\n" -IDS_SYS_TYPE_AMD64, "Typ systmu: PC zaloen na AMD64\n" +IDS_SYS_TYPE, "Typ systmu: %s\n" IDS_PROCESSORS, "Procesor(y): %u Procesor(y) naintalovan.\n" IDS_BIOS_DATE, "Dtum BIOSu: %s\n" IDS_BIOS_VERSION, "Verzia BIOSu: %s\n" @@ -57,13 +53,13 @@ IDS_SYS_DIR, "Adres IDS_BOOT_DEV, "Zavdzacie zariadenie: %s\n" IDS_SYS_LOCALE, "System Locale: %s\n" IDS_INPUT_LOCALE, "Input Locale: %s\n" -IDS_TOTAL_PHYS_MEM, "Celkov fyzick pam: %ld MB (%ld KB)\n" -IDS_AVAIL_PHISICAL_MEM, "Dostupn fyzick pam: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_MAX, "Virtulna pam: Max Size: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_AVAIL, "Virtulna pam: Available: %ld MB (%ld KB)\n" -IDS_VIRT_MEM_INUSE, "Virtulna pam: In Use: %ld MB (%ld KB)\n" -IDS_PAGEFILE_LOC, "Umiestnenie(a) strnkovacieho sboru: %s\n" IDS_TIME_ZONE, "asov psmo: %s\n" +IDS_TOTAL_PHYS_MEM, "Celkov fyzick pam: %s MB\n" +IDS_AVAIL_PHISICAL_MEM, "Dostupn fyzick pam: %s MB\n" +IDS_VIRT_MEM_MAX, "Virtulna pam: Max Size: %s MB\n" +IDS_VIRT_MEM_AVAIL, "Virtulna pam: Available: %s MB\n" +IDS_VIRT_MEM_INUSE, "Virtulna pam: In Use: %s MB\n" +IDS_PAGEFILE_LOC, "Umiestnenie(a) strnkovacieho sboru: %s\n" IDS_DOMINE, "Domna: %s\n" IDS_NETWORK_CARDS, "Sieov karta(y) %u naintalovan.\n" diff --git a/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc b/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc index edc724e7f12..eccf833302e 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc @@ -44,15 +44,11 @@ IDS_OS_BUILD_TYPE, " IDS_REG_OWNER, " : %s\n" IDS_REG_ORG, " : %s\n" IDS_PRODUCT_ID, "ID : %s\n" -IDS_INST_DATE, " : %s, " -IDS_INST_TIME, "%s\n" +IDS_INST_DATE, " : %s\n" IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" IDS_SYS_MODEL, "System Model: %s\n" -IDS_SYS_TYPE_UNKNOWN, " : \n" -IDS_SYS_TYPE_X86, " : X86-based PC\n" -IDS_SYS_TYPE_IA64, " : IA64-based PC\n" -IDS_SYS_TYPE_AMD64, " : AMD64-based PC\n" +IDS_SYS_TYPE, " : %s\n" IDS_PROCESSORS, "(): %u (,) .\n" IDS_BIOS_DATE, " BIOS: %s\n" IDS_BIOS_VERSION, " BIOS: %s\n" @@ -61,13 +57,13 @@ IDS_SYS_DIR, " IDS_BOOT_DEV, " : %s\n" IDS_SYS_LOCALE, " : %s\n" IDS_INPUT_LOCALE, " : %s\n" -IDS_TOTAL_PHYS_MEM, " ': %ld (%ld )\n" -IDS_AVAIL_PHISICAL_MEM, " ': %ld (%ld )\n" -IDS_VIRT_MEM_MAX, "³ ': . : %ld (%ld )\n" -IDS_VIRT_MEM_AVAIL, "³ ': : %ld (%ld )\n" -IDS_VIRT_MEM_INUSE, "³ ': .: %ld (%ld )\n" -IDS_PAGEFILE_LOC, " %s\n" -IDS_TIME_ZONE, " : %s\n" +IDS_TIME_ZONE, " : %s\n" +IDS_TOTAL_PHYS_MEM, " ': %s \n" +IDS_AVAIL_PHISICAL_MEM, " ': %s \n" +IDS_VIRT_MEM_MAX, "³ ': . : %s \n" +IDS_VIRT_MEM_AVAIL, "³ ': : %s \n" +IDS_VIRT_MEM_INUSE, "³ ': .: %s \n" +IDS_PAGEFILE_LOC, " : %s\n" IDS_DOMINE, ": %s\n" IDS_NETWORK_CARDS, " () %u Installed.\n" diff --git a/rosapps/applications/sysutils/systeminfo/resource.h b/rosapps/applications/sysutils/systeminfo/resource.h index eb28aea10a3..da4408392a0 100644 --- a/rosapps/applications/sysutils/systeminfo/resource.h +++ b/rosapps/applications/sysutils/systeminfo/resource.h @@ -8,11 +8,10 @@ #define IDS_REG_ORG 105 #define IDS_PRODUCT_ID 106 #define IDS_INST_DATE 107 -#define IDS_INST_TIME 108 #define IDS_UP_TIME 109 #define IDS_SYS_MANUFACTURER 110 #define IDS_SYS_MODEL 111 -#define IDS_SYS_TYPE_UNKNOWN 112 +#define IDS_SYS_TYPE 112 #define IDS_PROCESSORS 113 #define IDS_BIOS_DATE 114 #define IDS_BIOS_VERSION 115 @@ -30,6 +29,3 @@ #define IDS_TIME_ZONE 127 #define IDS_DOMINE 128 #define IDS_NETWORK_CARDS 130 -#define IDS_SYS_TYPE_X86 140 -#define IDS_SYS_TYPE_IA64 141 -#define IDS_SYS_TYPE_AMD64 142 diff --git a/rosapps/applications/sysutils/systeminfo/systeminfo.c b/rosapps/applications/sysutils/systeminfo/systeminfo.c index 68b32e1ec9d..1e911ded3ce 100644 --- a/rosapps/applications/sysutils/systeminfo/systeminfo.c +++ b/rosapps/applications/sysutils/systeminfo/systeminfo.c @@ -14,27 +14,27 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2007, Dmitry Chapyshev */ +/* Copyright (C) 2011, Rafal Harabien */ #include #include #include #include #include -#include #include +#include #include "resource.h" #define BUFFER_SIZE 32767 -#define B_TO_MB(bytes) ((bytes)/(1024*1024)) -#define B_TO_KB(bytes) ((bytes)/1024) /* Load from resource and convert to OEM */ static BOOL -GetOemStrings(UINT rcID, LPSTR OutMsg) +GetOemStrings(UINT rcID, LPTSTR OutMsg) { TCHAR Msg[BUFFER_SIZE]; + if (LoadString(GetModuleHandle(NULL), rcID, (LPTSTR)Msg, BUFFER_SIZE)) { CharToOem(Msg, OutMsg); @@ -46,27 +46,124 @@ GetOemStrings(UINT rcID, LPSTR OutMsg) /* Load data from registry */ static BOOL -GetRegistryValue(HKEY hKeyName, LPCTSTR SubKey, LPCTSTR ValueName, LPCTSTR Buf) +RegGetSZ(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR Buf) { - DWORD CharCount = BUFFER_SIZE; - HKEY hKey; - LONG lRet; + DWORD dwBytes = BUFFER_SIZE*sizeof(TCHAR), dwType; + BOOL bRet = TRUE; + + /* If SubKy is specified open it */ + if (lpSubKey && RegOpenKeyEx(hKey, + lpSubKey, + 0, + KEY_QUERY_VALUE, + &hKey) != ERROR_SUCCESS) + { + //_tprintf("Warning! Cannot open %s. Last error: %lu.\n", lpSubKey, GetLastError()); + return FALSE; + } - lRet = RegOpenKeyEx(hKeyName, - SubKey, - 0, - KEY_QUERY_VALUE, - &hKey); - if (lRet != ERROR_SUCCESS) return FALSE; - lRet = RegQueryValueEx(hKey, - ValueName, - NULL, - NULL, - (LPBYTE)Buf, - &CharCount); - if (lRet != ERROR_SUCCESS) return FALSE; - RegCloseKey(hKey); - return TRUE; + if (RegQueryValueEx(hKey, + lpValueName, + NULL, + &dwType, + (LPBYTE)Buf, + &dwBytes) != ERROR_SUCCESS || (dwType != REG_SZ && dwType != REG_MULTI_SZ)) + { + //_tprintf("Warning! Cannot query %s. Last error: %lu, type: %lu.\n", lpValueName, GetLastError(), dwType); + dwBytes = 0; + bRet = FALSE; + } + + /* Close key if we opened it */ + if (lpSubKey) + RegCloseKey(hKey); + + /* NULL-terminate string */ + Buf[min(BUFFER_SIZE-1, dwBytes/sizeof(TCHAR))] = TEXT('\0'); + + return bRet; +} + +static +BOOL +RegGetDWORD(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPDWORD lpData) +{ + DWORD dwBytes = sizeof(*lpData), dwType; + BOOL bRet = TRUE; + + /* If SubKy is specified open it */ + if (lpSubKey && RegOpenKeyEx(hKey, + lpSubKey, + 0, + KEY_QUERY_VALUE, + &hKey) != ERROR_SUCCESS) + { + return FALSE; + } + + if (RegQueryValueEx(hKey, + lpValueName, + NULL, + &dwType, + (LPBYTE)lpData, + &dwBytes) != ERROR_SUCCESS || dwType != REG_DWORD) + { + //_tprintf("Warning! Cannot query %s. Last err: %lu, type: %lu\n", lpValueName, GetLastError(), dwType); + *lpData = 0; + bRet = FALSE; + } + + /* Close key if we opened it */ + if (lpSubKey) + RegCloseKey(hKey); + + return bRet; +} + +static +void +FormatBytes(LPTSTR Buf, unsigned cBytes) +{ + TCHAR szMB[32], Tmp[BUFFER_SIZE]; + NUMBERFMT fmt; + + itoa(cBytes / (1024*1024), szMB, 10); + + fmt.NumDigits = 0; + fmt.LeadingZero = 0; + fmt.Grouping = 3; + fmt.lpDecimalSep = TEXT(""); + fmt.lpThousandSep = TEXT(" "); + fmt.NegativeOrder = 0; + if(!GetNumberFormat(LOCALE_SYSTEM_DEFAULT, 0, szMB, &fmt, Tmp, BUFFER_SIZE)) + printf("Error! GetNumberFormat failed.\n"); + + CharToOem(Tmp, Buf); +} + +static +void +FormatDateTime(time_t Time, LPTSTR lpBuf) +{ + unsigned cchBuf = BUFFER_SIZE, i; + SYSTEMTIME SysTime; + const struct tm *lpTm; + + lpTm = localtime(&Time); + SysTime.wYear = (WORD)(1900 + lpTm->tm_year); + SysTime.wMonth = (WORD)(1 + lpTm->tm_mon); + SysTime.wDayOfWeek = (WORD)lpTm->tm_wday; + SysTime.wDay = (WORD)lpTm->tm_mday; + SysTime.wHour = (WORD)lpTm->tm_hour; + SysTime.wMinute = (WORD)lpTm->tm_min; + SysTime.wSecond = (WORD)lpTm->tm_sec; + SysTime.wMilliseconds = 0; + + i = GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf, cchBuf); + if (i) + --i; /* don't count NULL character */ + i += _stprintf(lpBuf + i, TEXT(", ")); + GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf + i, cchBuf - i); } /* Show usage */ @@ -75,46 +172,63 @@ VOID Usage(VOID) { TCHAR Buf[BUFFER_SIZE]; - if(GetOemStrings(IDS_USAGE, Buf)) printf("%s",Buf); + + if(GetOemStrings(IDS_USAGE, Buf)) + _tprintf("%s", Buf); } /* Print all system information */ VOID AllSysInfo(VOID) { - DWORD dwCharCount = BUFFER_SIZE; + DWORD dwCharCount = BUFFER_SIZE, dwTimestamp; OSVERSIONINFO VersionInfo; SYSTEM_INFO SysInfo; TCHAR Buf[BUFFER_SIZE], Tmp[BUFFER_SIZE], Msg[BUFFER_SIZE], szSystemDir[MAX_PATH]; + const TCHAR *lpcszSysType; MEMORYSTATUS MemoryStatus; unsigned int cSeconds; TIME_ZONE_INFORMATION TimeZoneInfo; + HKEY hKey; if (!GetSystemDirectory(szSystemDir, sizeof(szSystemDir)/sizeof(szSystemDir[0]))) - printf("Error getting: GetSystemDirectory\n"); + { + _tprintf("Error! GetSystemDirectory failed.\n"); + return; + } + GetSystemInfo(&SysInfo); // getting computer name dwCharCount = BUFFER_SIZE; if (!GetComputerName(Buf, &dwCharCount)) - printf("Error getting: GetComputerName"); - if (GetOemStrings(IDS_HOST_NAME, Msg)) - printf(Msg, Buf); + _tprintf("Error! GetComputerName failed.\n"); + else if (GetOemStrings(IDS_HOST_NAME, Msg)) + _tprintf(Msg, Buf); + + // open CurrentVersion key + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), + 0, + KEY_QUERY_VALUE, + &hKey) != ERROR_SUCCESS) + { + _tprintf("Error! RegOpenKeyEx failed.\n"); + return; + } //getting OS Name - GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - TEXT("ProductName"), - Buf); - if (GetOemStrings(IDS_OS_NAME, Msg)) printf(Msg, Buf); + RegGetSZ(hKey, NULL, TEXT("ProductName"), Buf); + if (GetOemStrings(IDS_OS_NAME, Msg)) + _tprintf(Msg, Buf); //getting OS Version ZeroMemory(&VersionInfo, sizeof(VersionInfo)); VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo); GetVersionEx(&VersionInfo); - + if (GetOemStrings(IDS_OS_VERSION, Msg)) - printf(Msg, + _tprintf(Msg, (unsigned)VersionInfo.dwMajorVersion, (unsigned)VersionInfo.dwMinorVersion, (unsigned)VersionInfo.dwBuildNumber, @@ -126,53 +240,40 @@ AllSysInfo(VOID) //getting OS Configuration //getting OS Build Type - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - TEXT("CurrentType"), - Buf)) - if (GetOemStrings(IDS_OS_BUILD_TYPE, Msg)) printf(Msg, Buf); + RegGetSZ(hKey, NULL, TEXT("CurrentType"), Buf); + if (GetOemStrings(IDS_OS_BUILD_TYPE, Msg)) + _tprintf(Msg, Buf); //getting Registered Owner - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - TEXT("RegisteredOwner"), - Buf)) - if (GetOemStrings(IDS_REG_OWNER, Msg)) printf(Msg, Buf); + RegGetSZ(hKey, NULL, TEXT("RegisteredOwner"), Buf); + if (GetOemStrings(IDS_REG_OWNER, Msg)) + _tprintf(Msg, Buf); //getting Registered Organization - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - TEXT("RegisteredOrganization"), - Buf)) - if (GetOemStrings(IDS_REG_ORG, Msg)) printf(Msg, Buf); + RegGetSZ(hKey, NULL, TEXT("RegisteredOrganization"), Buf); + if (GetOemStrings(IDS_REG_ORG, Msg)) + _tprintf(Msg, Buf); - //getting Product ID // use SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), - TEXT("ProductId"), - Buf)) - if (GetOemStrings(IDS_PRODUCT_ID, Msg)) printf(Msg, Buf); + //getting Product ID + RegGetSZ(hKey, NULL, TEXT("ProductId"), Buf); + if (GetOemStrings(IDS_PRODUCT_ID, Msg)) + _tprintf(Msg, Buf); //getting Install Date - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\WBEM\\CIMOM"), - TEXT("SetupDate"), - Buf)) - if (GetOemStrings(IDS_INST_DATE, Msg)) printf(Msg, Buf); + RegGetDWORD(hKey, NULL, TEXT("InstallDate"), &dwTimestamp); + FormatDateTime((time_t)dwTimestamp, Buf); + if (GetOemStrings(IDS_INST_DATE, Msg)) + _tprintf(Msg, Buf); - //getting Install Time - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\WBEM\\CIMOM"), - TEXT("SetupTime"), - Buf)) - if (GetOemStrings(IDS_INST_TIME, Msg)) printf(Msg, Buf); + // close Current Version key now + RegCloseKey(hKey); //getting System Up Time cSeconds = GetTickCount() / 1000; if (GetOemStrings(IDS_UP_TIME, Msg)) - printf(Msg, cSeconds / (60*60*24), (cSeconds / (60*60)) % 24, (cSeconds / 60) % 60, cSeconds % 60); + _tprintf(Msg, cSeconds / (60*60*24), (cSeconds / (60*60)) % 24, (cSeconds / 60) % 60, cSeconds % 60); - //getting System Manufacturer + //getting System Manufacturer; HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\Manufacturer for Win >= 6.0 sprintf(Tmp, "%s\\oeminfo.ini", szSystemDir); GetPrivateProfileString(TEXT("General"), TEXT("Manufacturer"), @@ -181,9 +282,9 @@ AllSysInfo(VOID) sizeof(Buf)/sizeof(Buf[0]), Tmp); if (GetOemStrings(IDS_SYS_MANUFACTURER, Msg)) - printf(Msg, Buf); + _tprintf(Msg, Buf); - //getting System Model + //getting System Model; HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\Model for Win >= 6.0 GetPrivateProfileString(TEXT("General"), TEXT("Model"), TEXT("To Be Filled By O.E.M."), @@ -191,164 +292,204 @@ AllSysInfo(VOID) sizeof(Buf)/sizeof(Buf[0]), Tmp); if (GetOemStrings(IDS_SYS_MODEL, Msg)) - printf(Msg, Buf); + _tprintf(Msg, Buf); //getting System type switch (SysInfo.wProcessorArchitecture) { - case PROCESSOR_ARCHITECTURE_UNKNOWN: - if (GetOemStrings(IDS_SYS_TYPE_UNKNOWN, Msg)) printf("%s", Msg); - break; case PROCESSOR_ARCHITECTURE_INTEL: - if (GetOemStrings(IDS_SYS_TYPE_X86, Msg)) printf("%s", Msg); + lpcszSysType = TEXT("X86-based PC"); break; case PROCESSOR_ARCHITECTURE_IA64: - if (GetOemStrings(IDS_SYS_TYPE_IA64, Msg)) printf("%s", Msg); + lpcszSysType = TEXT("IA64-based PC"); break; case PROCESSOR_ARCHITECTURE_AMD64: - if (GetOemStrings(IDS_SYS_TYPE_AMD64, Msg)) printf("%s", Msg); + lpcszSysType = TEXT("AMD64-based PC"); + break; + default: + lpcszSysType = TEXT("Unknown"); break; } + if (GetOemStrings(IDS_SYS_TYPE, Msg)) + _tprintf(Msg, lpcszSysType); //getting Processor(s) if (GetOemStrings(IDS_PROCESSORS, Msg)) { unsigned int i; - printf(Msg, (unsigned int)SysInfo.dwNumberOfProcessors); + _tprintf(Msg, (unsigned int)SysInfo.dwNumberOfProcessors); for(i = 0; i < (unsigned int)SysInfo.dwNumberOfProcessors; i++) { - sprintf(Tmp,"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u",i); - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - (LPCTSTR)Tmp, - TEXT("Identifier"), - Buf)) - printf(" [0%u]: %s", i+1, Buf); - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - (LPCTSTR)Tmp, - TEXT("VendorIdentifier"), - Buf)) - printf(" %s\n", Buf); + sprintf(Tmp, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u",i); + + RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, TEXT("Identifier"), Buf); + _tprintf(" [%02u]: %s", i+1, Buf); + + RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, TEXT("VendorIdentifier"), Buf); + _tprintf(" %s\n", Buf); } } //getting BIOS Version - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("HARDWARE\\DESCRIPTION\\System"), - TEXT("SystemBiosVersion"), - Buf)) - if (GetOemStrings(IDS_BIOS_VERSION, Msg)) printf(Msg, Buf); + RegGetSZ(HKEY_LOCAL_MACHINE, + TEXT("HARDWARE\\DESCRIPTION\\System"), + TEXT("SystemBiosVersion"), + Buf); + if (GetOemStrings(IDS_BIOS_VERSION, Msg)) + _tprintf(Msg, Buf); //gettings BIOS date - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("HARDWARE\\DESCRIPTION\\System"), - TEXT("SystemBiosDate"), - Buf)) - if (GetOemStrings(IDS_BIOS_DATE, Msg)) printf(Msg, Buf); + RegGetSZ(HKEY_LOCAL_MACHINE, + TEXT("HARDWARE\\DESCRIPTION\\System"), + TEXT("SystemBiosDate"), + Buf); + if (GetOemStrings(IDS_BIOS_DATE, Msg)) + _tprintf(Msg, Buf); //getting ReactOS Directory - if (!GetWindowsDirectory(Buf, BUFFER_SIZE)) printf("Error getting: GetWindowsDirectory"); - if (GetOemStrings(IDS_ROS_DIR, Msg)) printf(Msg, Buf); + if (!GetWindowsDirectory(Buf, BUFFER_SIZE)) + _tprintf("Error! GetWindowsDirectory failed."); + else if (GetOemStrings(IDS_ROS_DIR, Msg)) + _tprintf(Msg, Buf); //getting System Directory - if (GetOemStrings(IDS_SYS_DIR, Msg)) printf(Msg, szSystemDir); + if (GetOemStrings(IDS_SYS_DIR, Msg)) + _tprintf(Msg, szSystemDir); //getting Boot Device - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SYSTEM\\Setup"), - TEXT("SystemPartition"), - Buf)) - if (GetOemStrings(IDS_BOOT_DEV, Msg)) printf(Msg, Buf); + RegGetSZ(HKEY_LOCAL_MACHINE, + TEXT("SYSTEM\\Setup"), + TEXT("SystemPartition"), + Buf); + if (GetOemStrings(IDS_BOOT_DEV, Msg)) + _tprintf(Msg, Buf); //getting System Locale - if (GetRegistryValue(HKEY_CURRENT_USER, - TEXT("Control Panel\\International"), - TEXT("Locale"), - Tmp)) - if (GetRegistryValue(HKEY_CLASSES_ROOT, - TEXT("MIME\\Database\\Rfc1766"), - (LPTSTR)Tmp, - Buf)) - if (GetOemStrings(IDS_SYS_LOCALE, Msg)) printf(Msg, Buf); + if (RegGetSZ(HKEY_CURRENT_USER, + TEXT("Control Panel\\International"), + TEXT("Locale"), + Tmp)) + if (RegGetSZ(HKEY_CLASSES_ROOT, + TEXT("MIME\\Database\\Rfc1766"), + Tmp, + Buf)) + if (GetOemStrings(IDS_SYS_LOCALE, Msg)) + _tprintf(Msg, Buf); //getting Input Locale - if (GetRegistryValue(HKEY_CURRENT_USER, - TEXT("Keyboard Layout\\Preload"), - TEXT("1"), - Buf)) + if (RegGetSZ(HKEY_CURRENT_USER, + TEXT("Keyboard Layout\\Preload"), + TEXT("1"), + Buf)) { - int i,j; - for(j = 0, i = 4; i <= 8; j++, i++) Tmp[j] = Buf[i]; - if (GetRegistryValue(HKEY_CLASSES_ROOT, - TEXT("MIME\\Database\\Rfc1766"), - (LPTSTR)Tmp, - Buf)) - if (GetOemStrings(IDS_INPUT_LOCALE, Msg)) printf(Msg, Buf); + int i, j; + + for(j = 0, i = 4; i <= 8; j++, i++) + Tmp[j] = Buf[i]; + + if (RegGetSZ(HKEY_CLASSES_ROOT, + TEXT("MIME\\Database\\Rfc1766"), + Tmp, + Buf)) + if (GetOemStrings(IDS_INPUT_LOCALE, Msg)) + _tprintf(Msg, Buf); } //getting Time Zone GetTimeZoneInformation(&TimeZoneInfo); - sprintf(Tmp,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\%S",TimeZoneInfo.StandardName); - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - (LPCTSTR)Tmp, - TEXT("Display"), - Buf)) - if (GetOemStrings(IDS_TIME_ZONE, Msg)) printf(Msg, Buf); - - //getting Total Physical Memory - GlobalMemoryStatus(&MemoryStatus); - if(GetOemStrings(IDS_TOTAL_PHYS_MEM, Msg)) - printf(Msg, - B_TO_MB(MemoryStatus.dwTotalPhys), - B_TO_KB(MemoryStatus.dwTotalPhys)); - - //getting Available Physical Memory - if(GetOemStrings(IDS_AVAIL_PHISICAL_MEM,Msg)) - printf(Msg, - B_TO_MB(MemoryStatus.dwAvailPhys), - B_TO_KB(MemoryStatus.dwAvailPhys)); - - //getting Virtual Memory: Max Size - if(GetOemStrings(IDS_VIRT_MEM_MAX, Msg)) - printf(Msg, - B_TO_MB(MemoryStatus.dwTotalVirtual), - B_TO_KB(MemoryStatus.dwTotalVirtual)); - - //getting Virtual Memory: Available - if(GetOemStrings(IDS_VIRT_MEM_AVAIL, Msg)) - printf(Msg, - B_TO_MB(MemoryStatus.dwAvailVirtual), - B_TO_KB(MemoryStatus.dwAvailVirtual)); - - //getting Virtual Memory: In Use - if(GetOemStrings(IDS_VIRT_MEM_INUSE, Msg)) - printf(Msg, - B_TO_MB(MemoryStatus.dwTotalVirtual-MemoryStatus.dwAvailVirtual), - B_TO_KB(MemoryStatus.dwTotalVirtual-MemoryStatus.dwAvailVirtual)); - - //getting Page File Location(s) - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SYSTEM\\ControlSet001\\Control\\Session Manager\\Memory Management"), - TEXT("PagingFiles"), - Buf)) + + /* Open Time Zones key */ + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"), + 0, + KEY_ENUMERATE_SUB_KEYS|KEY_READ, + &hKey) == ERROR_SUCCESS) { - int i; - for(i = 0; i < strlen((char*)Buf); i++) + unsigned i; + + /* Find current timezone */ + dwCharCount = 256; // Windows seems to have a bug - it doesnt accept BUFFER_SIZE here + for(i = 0; RegEnumKeyEx(hKey, i, Tmp, &dwCharCount, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++i, dwCharCount = 255) { - if (Buf[i] == ' ') +#ifdef _UNICODE + RegGetSZ(hKey, Tmp, TEXT("Std"), Buf); + + if(!wcscmp(wBuf, TimeZoneInfo.StandardName)) +#else + wchar_t wBuf[BUFFER_SIZE]; + + RegGetSZ(hKey, Tmp, TEXT("Std"), Buf); + mbstowcs(wBuf, Buf, BUFFER_SIZE); + + if(!wcscmp(wBuf, TimeZoneInfo.StandardName)) +#endif { - Buf[i] = '\0'; + RegGetSZ(hKey, Tmp, TEXT("Display"), Buf); + + if (GetOemStrings(IDS_TIME_ZONE, Msg)) + _tprintf(Msg, Buf); + break; } } - if(GetOemStrings(IDS_PAGEFILE_LOC, Msg)) printf(Msg, Buf); + RegCloseKey(hKey); + } + + + //getting Total Physical Memory + GlobalMemoryStatus(&MemoryStatus); + FormatBytes(Buf, MemoryStatus.dwTotalPhys); + if (GetOemStrings(IDS_TOTAL_PHYS_MEM, Msg)) + _tprintf(Msg, Buf); + + //getting Available Physical Memory + FormatBytes(Buf, MemoryStatus.dwAvailPhys); + if (GetOemStrings(IDS_AVAIL_PHISICAL_MEM,Msg)) + _tprintf(Msg, Buf); + + //getting Virtual Memory: Max Size + FormatBytes(Buf, MemoryStatus.dwTotalVirtual); + if (GetOemStrings(IDS_VIRT_MEM_MAX, Msg)) + _tprintf(Msg, Buf); + + //getting Virtual Memory: Available + FormatBytes(Buf, MemoryStatus.dwAvailVirtual); + if (GetOemStrings(IDS_VIRT_MEM_AVAIL, Msg)) + _tprintf(Msg, Buf); + + //getting Virtual Memory: In Use + FormatBytes(Buf, MemoryStatus.dwTotalVirtual-MemoryStatus.dwAvailVirtual); + if (GetOemStrings(IDS_VIRT_MEM_INUSE, Msg)) + _tprintf(Msg, Buf); + + //getting Page File Location(s) + if (RegGetSZ(HKEY_LOCAL_MACHINE, + TEXT("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management"), + TEXT("PagingFiles"), + Buf)) + { + int i; + + for(i = 0; i < strlen((char*)Buf); i++) + { + if (Buf[i] == TEXT(' ')) + { + Buf[i] = TEXT('\0'); + break; + } + } + + if(GetOemStrings(IDS_PAGEFILE_LOC, Msg)) + _tprintf(Msg, Buf); } //getting Domain - if (GetRegistryValue(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), - TEXT("CachePrimaryDomain"), - Buf)) - if(GetOemStrings(IDS_DOMINE, Msg)) printf(Msg, Buf); + if (RegGetSZ(HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), + TEXT("CachePrimaryDomain"), + Buf)) + if(GetOemStrings(IDS_DOMINE, Msg)) + _tprintf(Msg, Buf); //getting Logon Server @@ -368,6 +509,8 @@ main(int argc, char *argv[]) Usage(); return 0; } + AllSysInfo(); + return 0; } From f4f2b68256090c04f73cfb777fc6e19eb9e99233 Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Fri, 1 Apr 2011 22:10:52 +0000 Subject: [PATCH 48/66] [ADVAPI32] * Fix bug in RegQueryValueExA, which causes buffer overflow * Fixes systeminfo in ReactOS See issue #6050 for more details. svn path=/trunk/; revision=51222 --- reactos/dll/win32/advapi32/reg/reg.c | 44 +++++++++++++++------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/reactos/dll/win32/advapi32/reg/reg.c b/reactos/dll/win32/advapi32/reg/reg.c index c6af98b5b4f..cfc8ba1ea28 100644 --- a/reactos/dll/win32/advapi32/reg/reg.c +++ b/reactos/dll/win32/advapi32/reg/reg.c @@ -3988,7 +3988,7 @@ RegQueryValueExA(HKEY hKey, LPDWORD lpcbData) { UNICODE_STRING ValueName; - UNICODE_STRING ValueData; + LPWSTR lpValueBuffer; LONG ErrorCode; DWORD Length; DWORD Type; @@ -4003,39 +4003,42 @@ RegQueryValueExA(HKEY hKey, return ERROR_INVALID_PARAMETER; } + Length = (lpcbData == NULL || lpData == NULL) ? 0 : *lpcbData * sizeof(WCHAR); + if (lpData) { - ValueData.Length = 0; - ValueData.MaximumLength = (*lpcbData + 1) * sizeof(WCHAR); - ValueData.Buffer = RtlAllocateHeap(ProcessHeap, - 0, - ValueData.MaximumLength); - if (!ValueData.Buffer) + lpValueBuffer = RtlAllocateHeap(ProcessHeap, + 0, + Length + sizeof(WCHAR)); + if (!lpValueBuffer) { return ERROR_OUTOFMEMORY; } } else { - ValueData.Buffer = NULL; - ValueData.Length = 0; - ValueData.MaximumLength = 0; + lpValueBuffer = NULL; if (lpcbData) *lpcbData = 0; } - RtlCreateUnicodeStringFromAsciiz(&ValueName, - (LPSTR)lpValueName); + if(!RtlCreateUnicodeStringFromAsciiz(&ValueName, + (LPSTR)lpValueName)) + { + ERR("RtlCreateUnicodeStringFromAsciiz failed!\n"); + ErrorCode = ERROR_OUTOFMEMORY; + goto cleanup; + } - Length = (lpcbData == NULL) ? 0 : *lpcbData * sizeof(WCHAR); ErrorCode = RegQueryValueExW(hKey, ValueName.Buffer, lpReserved, &Type, - (lpData == NULL) ? NULL : (LPBYTE)ValueData.Buffer, + (LPBYTE)lpValueBuffer, &Length); TRACE("ErrorCode %lu\n", ErrorCode); + RtlFreeUnicodeString(&ValueName); if (ErrorCode == ERROR_SUCCESS || @@ -4044,9 +4047,9 @@ RegQueryValueExA(HKEY hKey, if (is_string(Type)) { - if (ErrorCode == ERROR_SUCCESS && ValueData.Buffer != NULL) + if (ErrorCode == ERROR_SUCCESS && lpValueBuffer != NULL) { - Status = RtlUnicodeToMultiByteN((PCHAR)lpData, *lpcbData, &Index, (PWCHAR)ValueData.Buffer, Length); + Status = RtlUnicodeToMultiByteN((PCHAR)lpData, *lpcbData, &Index, (PWCHAR)lpValueBuffer, Length); if (NT_SUCCESS(Status)) { PCHAR szData = (PCHAR)lpData; @@ -4063,7 +4066,7 @@ RegQueryValueExA(HKEY hKey, Length = Length / sizeof(WCHAR); } - else if (ErrorCode == ERROR_SUCCESS && ValueData.Buffer != NULL) + else if (ErrorCode == ERROR_SUCCESS && lpValueBuffer != NULL) { if (*lpcbData < Length) { @@ -4071,7 +4074,7 @@ RegQueryValueExA(HKEY hKey, } else { - RtlMoveMemory(lpData, ValueData.Buffer, Length); + RtlMoveMemory(lpData, lpValueBuffer, Length); } } @@ -4086,9 +4089,10 @@ RegQueryValueExA(HKEY hKey, *lpType = Type; } - if (ValueData.Buffer != NULL) +cleanup: + if (lpValueBuffer != NULL) { - RtlFreeHeap(ProcessHeap, 0, ValueData.Buffer); + RtlFreeHeap(ProcessHeap, 0, lpValueBuffer); } return ErrorCode; From 1d045ebeb326c1fbf5bead70d8ca083ce16fe908 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sat, 2 Apr 2011 09:20:16 +0000 Subject: [PATCH 49/66] [NTDLL] - Fix a typo which led to incorrect logic of TLS allocation. This repairs those installers broken by r51051. See issue #6009 for more details. svn path=/trunk/; revision=51223 --- reactos/dll/ntdll/ldr/ldrinit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/dll/ntdll/ldr/ldrinit.c b/reactos/dll/ntdll/ldr/ldrinit.c index cccaa4ee4f3..5913304361a 100644 --- a/reactos/dll/ntdll/ldr/ldrinit.c +++ b/reactos/dll/ntdll/ldr/ldrinit.c @@ -786,8 +786,8 @@ LdrpAllocateTls(VOID) PVOID *TlsVector; /* Check if we have any entries */ - if (LdrpNumberOfTlsEntries) - return 0; + if (!LdrpNumberOfTlsEntries) + return STATUS_SUCCESS; /* Allocate the vector array */ TlsVector = RtlAllocateHeap(RtlGetProcessHeap(), From 0857319218b176097b0126b92b5169a4f0411135 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Sat, 2 Apr 2011 10:12:44 +0000 Subject: [PATCH 50/66] [win32k] - Simplify co_IntWaitMessage - In co_IntGetPeekMessage, call co_MsqWaitForNewMessages instead of co_IntWaitMessage when we need to wait for a new message. co_IntWaitMessage calls co_IntPeekMessage again without removing messages. The problem is that processing some messages produce other messages or hooks even though the message must not be removed. As a result some messages like WM_NCHITTEST were received twice by the application - Should fix bug 3232 svn path=/trunk/; revision=51224 --- .../subsystems/win32/win32k/ntuser/message.c | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index f14ec4745ed..b66f31db35d 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -850,15 +850,15 @@ co_IntWaitMessage( PWND Window, Window, MsgFilterMin, MsgFilterMax); - } - while ( (STATUS_WAIT_0 <= Status && Status <= STATUS_WAIT_63) || - STATUS_TIMEOUT == Status ); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + DPRINT1("Exit co_IntWaitMessage on error!\n"); - if (!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - DPRINT1("Exit co_IntWaitMessage on error!\n"); + return FALSE; + } } + while ( TRUE ); return FALSE; } @@ -874,6 +874,7 @@ co_IntGetPeekMessage( PMSG pMsg, PWND Window; PTHREADINFO pti; BOOL Present = FALSE; + NTSTATUS Status; if ( hWnd == HWND_TOPMOST || hWnd == HWND_BROADCAST ) hWnd = HWND_BOTTOM; @@ -941,7 +942,11 @@ co_IntGetPeekMessage( PMSG pMsg, if ( bGMSG ) { - if ( !co_IntWaitMessage(Window, MsgFilterMin, MsgFilterMax) ) + Status = co_MsqWaitForNewMessages( pti->MessageQueue, + Window, + MsgFilterMin, + MsgFilterMax); + if ( !NT_SUCCESS(Status) ) { Present = -1; break; From 88e51aaa476e74ce7135140895242477ea281e7f Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Sat, 2 Apr 2011 14:54:24 +0000 Subject: [PATCH 51/66] [SYSTEMINFO] * Fix Domain field * Get rid of TCHAR * Translate System Up Time to polish svn path=/trunk/; revision=51225 --- .../sysutils/systeminfo/lang/de-DE.rc | 4 +- .../sysutils/systeminfo/lang/en-US.rc | 4 +- .../sysutils/systeminfo/lang/es-ES.rc | 4 +- .../sysutils/systeminfo/lang/fr-FR.rc | 4 +- .../sysutils/systeminfo/lang/no-NO.rc | 4 +- .../sysutils/systeminfo/lang/pl-PL.rc | 4 +- .../sysutils/systeminfo/lang/sk-SK.rc | 4 +- .../sysutils/systeminfo/lang/uk-UA.rc | 4 +- .../sysutils/systeminfo/resource.h | 2 +- .../sysutils/systeminfo/systeminfo.c | 337 +++++++++--------- .../sysutils/systeminfo/systeminfo.rbuild | 1 + 11 files changed, 184 insertions(+), 188 deletions(-) diff --git a/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc b/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc index f161f72c54c..287217c99b1 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc @@ -39,7 +39,7 @@ IDS_REG_OWNER, "Registrierter Benutzer: %s\n" IDS_REG_ORG, "Registrierte Organisation: %s\n" IDS_PRODUCT_ID, "Produkt ID: %s\n" IDS_INST_DATE, "Installationsdatum: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" IDS_SYS_MODEL, "System Model: %s\n" IDS_SYS_TYPE, "Systemtyp: %s\n" @@ -58,7 +58,7 @@ IDS_VIRT_MEM_MAX, "Auslagerungsdatei: Max Gr IDS_VIRT_MEM_AVAIL, "Auslagerungsdatei: Verfgbar: %s MB\n" IDS_VIRT_MEM_INUSE, "Auslagerungsdatei: In Verwendung: %s MB\n" IDS_PAGEFILE_LOC, "Auslagerungsdateipfad(e): %s" -IDS_DOMINE, "Domain: %s\n" +IDS_DOMAIN, "Domain: %s\n" IDS_NETWORK_CARDS, "Netzwerkkarte(n) %u Installiert.\n" END diff --git a/rosapps/applications/sysutils/systeminfo/lang/en-US.rc b/rosapps/applications/sysutils/systeminfo/lang/en-US.rc index d7731b67229..aa0c7713a08 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/en-US.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/en-US.rc @@ -37,7 +37,7 @@ IDS_REG_OWNER, "Registered Owner: %s\n" IDS_REG_ORG, "Registered Organization: %s\n" IDS_PRODUCT_ID, "Product ID: %s\n" IDS_INST_DATE, "Install Date: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" IDS_SYS_MODEL, "System Model: %s\n" IDS_SYS_TYPE, "System type: %s\n" @@ -56,7 +56,7 @@ IDS_VIRT_MEM_MAX, "Virtual Memory: Max Size: %s MB\n" IDS_VIRT_MEM_AVAIL, "Virtual Memory: Available: %s MB\n" IDS_VIRT_MEM_INUSE, "Virtual Memory: In Use: %s MB\n" IDS_PAGEFILE_LOC, "Page File Location(s): %s\n" -IDS_DOMINE, "Domain: %s\n" +IDS_DOMAIN, "Domain: %s\n" IDS_NETWORK_CARDS, "Network Card(s) %u Installed.\n" END diff --git a/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc b/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc index 423c67d0374..c9ec95f6a78 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc @@ -42,7 +42,7 @@ IDS_REG_OWNER, "Propietario: %s\n" IDS_REG_ORG, "Organizacin: %s\n" IDS_PRODUCT_ID, "Identificador de Producto %s\n" IDS_INST_DATE, "Fecha de Instalacin: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" IDS_SYS_MODEL, "System Model: %s\n" IDS_SYS_TYPE, "Tipo de sistema: %s\n" @@ -61,7 +61,7 @@ IDS_VIRT_MEM_MAX, "Memoria Virtual: Tama IDS_VIRT_MEM_AVAIL, "Memoria Virtual: Disponible: %s MB\n" IDS_VIRT_MEM_INUSE, "Memoria Virtual: En Uso: %s MB\n" IDS_PAGEFILE_LOC, "Ruta(s) Archivo Paginacin: %s\n" -IDS_DOMINE, "Dominio: %s\n" +IDS_DOMAIN, "Dominio: %s\n" IDS_NETWORK_CARDS, "Tarjeta(s) de Red %u No Instalada.\n" END diff --git a/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc b/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc index 4d9c9a4ae3b..82b5a62f84d 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc @@ -37,7 +37,7 @@ IDS_REG_OWNER, "Propri IDS_REG_ORG, "Organisation enregistre : %s\n" IDS_PRODUCT_ID, "ID du produit : %s\n" IDS_INST_DATE, "Date d'installation : %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" IDS_SYS_MODEL, "System Model: %s\n" IDS_SYS_TYPE, "Type du systme : %s\n" @@ -56,7 +56,7 @@ IDS_VIRT_MEM_MAX, "M IDS_VIRT_MEM_AVAIL, "Mmoire virtuelle: Disponible : %s Mo\n" IDS_VIRT_MEM_INUSE, "Mmoire virtuelle: Utilise : %s Mo\n" IDS_PAGEFILE_LOC, "Emplacement(s) des fichiers d'change : %s" -IDS_DOMINE, "Domaine : %s\n" +IDS_DOMAIN, "Domaine : %s\n" IDS_NETWORK_CARDS, "Carte(s) rseau %u installe(s).\n" END diff --git a/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc b/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc index e4e49667182..7f92fe924a3 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc @@ -37,7 +37,7 @@ IDS_REG_OWNER, "Registert eier: %s\n" IDS_REG_ORG, "Registerert organisasjon: %s\n" IDS_PRODUCT_ID, "Produkt ID: %s\n" IDS_INST_DATE, "Installert dato: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" IDS_SYS_MODEL, "System Model: %s\n" IDS_SYS_TYPE, "Systemtype: %s\n" @@ -56,7 +56,7 @@ IDS_VIRT_MEM_MAX, "Virtuelt minne: Maks St IDS_VIRT_MEM_AVAIL, "Virtuelt minne: Tilgjengelig: %s MB\n" IDS_VIRT_MEM_INUSE, "Virtuelt minne: i bruk: %s MB\n" IDS_PAGEFILE_LOC, "Sidevekslingsfil lokalsjon(er): %s\n" -IDS_DOMINE, "Domene: %s\n" +IDS_DOMAIN, "Domene: %s\n" IDS_NETWORK_CARDS, "Nettverkskort(er) %u installert.\n" END diff --git a/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc b/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc index 749a63fc5d9..fc92954bd17 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc @@ -44,7 +44,7 @@ IDS_REG_OWNER, "U IDS_REG_ORG, "Organizacja: %s\n" IDS_PRODUCT_ID, "ID produktu: %s\n" IDS_INST_DATE, "Data instalacji: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_UP_TIME, "Czas pracy systemu: %u dni, %u godzin, %u minut, %u sekund\n" IDS_SYS_MANUFACTURER, "Producent systemu: %s\n" IDS_SYS_MODEL, "Model systemu: %s\n" IDS_SYS_TYPE, "Rodzaj systemu: %s\n" @@ -63,7 +63,7 @@ IDS_VIRT_MEM_MAX, "Pami IDS_VIRT_MEM_AVAIL, "Pamici wirtualnej: dostpne: %s MB\n" IDS_VIRT_MEM_INUSE, "Pamici wirtualnej: w uyciu: %s MB\n" IDS_PAGEFILE_LOC, "Lokalizacja pliku wymiany: %s\n" -IDS_DOMINE, "Domena: %s\n" +IDS_DOMAIN, "Domena: %s\n" IDS_NETWORK_CARDS, "Liczba kart sieciowych %u.\n" END diff --git a/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc b/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc index f53414670f2..474373b7744 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc @@ -41,7 +41,7 @@ IDS_REG_OWNER, "Registovan IDS_REG_ORG, "Registrovan organizcia: %s\n" IDS_PRODUCT_ID, "ID produktu: %s\n" IDS_INST_DATE, "Dtum intalcie: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" IDS_SYS_MODEL, "System Model: %s\n" IDS_SYS_TYPE, "Typ systmu: %s\n" @@ -60,7 +60,7 @@ IDS_VIRT_MEM_MAX, "Virtu IDS_VIRT_MEM_AVAIL, "Virtulna pam: Available: %s MB\n" IDS_VIRT_MEM_INUSE, "Virtulna pam: In Use: %s MB\n" IDS_PAGEFILE_LOC, "Umiestnenie(a) strnkovacieho sboru: %s\n" -IDS_DOMINE, "Domna: %s\n" +IDS_DOMAIN, "Domna: %s\n" IDS_NETWORK_CARDS, "Sieov karta(y) %u naintalovan.\n" END diff --git a/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc b/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc index eccf833302e..a0c8f57674f 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc @@ -45,7 +45,7 @@ IDS_REG_OWNER, " IDS_REG_ORG, " : %s\n" IDS_PRODUCT_ID, "ID : %s\n" IDS_INST_DATE, " : %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u, Minutes, %u Seconds\n" +IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u Minutes, %u Seconds\n" IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" IDS_SYS_MODEL, "System Model: %s\n" IDS_SYS_TYPE, " : %s\n" @@ -64,7 +64,7 @@ IDS_VIRT_MEM_MAX, "³ IDS_VIRT_MEM_AVAIL, "³ ': : %s \n" IDS_VIRT_MEM_INUSE, "³ ': .: %s \n" IDS_PAGEFILE_LOC, " : %s\n" -IDS_DOMINE, ": %s\n" +IDS_DOMAIN, ": %s\n" IDS_NETWORK_CARDS, " () %u Installed.\n" END diff --git a/rosapps/applications/sysutils/systeminfo/resource.h b/rosapps/applications/sysutils/systeminfo/resource.h index da4408392a0..c50f3bd74e8 100644 --- a/rosapps/applications/sysutils/systeminfo/resource.h +++ b/rosapps/applications/sysutils/systeminfo/resource.h @@ -27,5 +27,5 @@ #define IDS_VIRT_MEM_INUSE 125 #define IDS_PAGEFILE_LOC 126 #define IDS_TIME_ZONE 127 -#define IDS_DOMINE 128 +#define IDS_DOMAIN 128 #define IDS_NETWORK_CARDS 130 diff --git a/rosapps/applications/sysutils/systeminfo/systeminfo.c b/rosapps/applications/sysutils/systeminfo/systeminfo.c index 1e911ded3ce..3f8d354f49a 100644 --- a/rosapps/applications/sysutils/systeminfo/systeminfo.c +++ b/rosapps/applications/sysutils/systeminfo/systeminfo.c @@ -16,13 +16,15 @@ /* Copyright (C) 2007, Dmitry Chapyshev */ /* Copyright (C) 2011, Rafal Harabien */ +#include #include #include #include #include #include -#include #include +#include +#include #include "resource.h" @@ -31,68 +33,64 @@ /* Load from resource and convert to OEM */ static BOOL -GetOemStrings(UINT rcID, LPTSTR OutMsg) +GetOemStrings(UINT rcID, LPWSTR OutMsg) { - TCHAR Msg[BUFFER_SIZE]; - - if (LoadString(GetModuleHandle(NULL), rcID, (LPTSTR)Msg, BUFFER_SIZE)) - { - CharToOem(Msg, OutMsg); + if (LoadStringW(GetModuleHandle(NULL), rcID, OutMsg, BUFFER_SIZE)) return TRUE; - } + return FALSE; } /* Load data from registry */ static BOOL -RegGetSZ(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR Buf) +RegGetSZ(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPWSTR Buf) { - DWORD dwBytes = BUFFER_SIZE*sizeof(TCHAR), dwType; + DWORD dwBytes = BUFFER_SIZE*sizeof(WCHAR), dwType; BOOL bRet = TRUE; - + /* If SubKy is specified open it */ - if (lpSubKey && RegOpenKeyEx(hKey, - lpSubKey, - 0, - KEY_QUERY_VALUE, - &hKey) != ERROR_SUCCESS) + if (lpSubKey && RegOpenKeyExW(hKey, + lpSubKey, + 0, + KEY_QUERY_VALUE, + &hKey) != ERROR_SUCCESS) { - //_tprintf("Warning! Cannot open %s. Last error: %lu.\n", lpSubKey, GetLastError()); + //wprintf("Warning! Cannot open %s. Last error: %lu.\n", lpSubKey, GetLastError()); return FALSE; } - if (RegQueryValueEx(hKey, - lpValueName, - NULL, - &dwType, - (LPBYTE)Buf, - &dwBytes) != ERROR_SUCCESS || (dwType != REG_SZ && dwType != REG_MULTI_SZ)) + if (RegQueryValueExW(hKey, + lpValueName, + NULL, + &dwType, + (LPBYTE)Buf, + &dwBytes) != ERROR_SUCCESS || (dwType != REG_SZ && dwType != REG_MULTI_SZ)) { - //_tprintf("Warning! Cannot query %s. Last error: %lu, type: %lu.\n", lpValueName, GetLastError(), dwType); + //wprintf("Warning! Cannot query %s. Last error: %lu, type: %lu.\n", lpValueName, GetLastError(), dwType); dwBytes = 0; bRet = FALSE; } - + /* Close key if we opened it */ if (lpSubKey) RegCloseKey(hKey); - + /* NULL-terminate string */ - Buf[min(BUFFER_SIZE-1, dwBytes/sizeof(TCHAR))] = TEXT('\0'); - + Buf[min(BUFFER_SIZE-1, dwBytes/sizeof(WCHAR))] = L'\0'; + return bRet; } static BOOL -RegGetDWORD(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPDWORD lpData) +RegGetDWORD(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPDWORD lpData) { DWORD dwBytes = sizeof(*lpData), dwType; BOOL bRet = TRUE; /* If SubKy is specified open it */ - if (lpSubKey && RegOpenKeyEx(hKey, + if (lpSubKey && RegOpenKeyExW(hKey, lpSubKey, 0, KEY_QUERY_VALUE, @@ -101,54 +99,53 @@ RegGetDWORD(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPDWORD lpData) return FALSE; } - if (RegQueryValueEx(hKey, - lpValueName, - NULL, - &dwType, - (LPBYTE)lpData, - &dwBytes) != ERROR_SUCCESS || dwType != REG_DWORD) + if (RegQueryValueExW(hKey, + lpValueName, + NULL, + &dwType, + (LPBYTE)lpData, + &dwBytes) != ERROR_SUCCESS || dwType != REG_DWORD) { - //_tprintf("Warning! Cannot query %s. Last err: %lu, type: %lu\n", lpValueName, GetLastError(), dwType); + //wprintf("Warning! Cannot query %s. Last err: %lu, type: %lu\n", lpValueName, GetLastError(), dwType); *lpData = 0; bRet = FALSE; } - + /* Close key if we opened it */ if (lpSubKey) RegCloseKey(hKey); - + return bRet; } static void -FormatBytes(LPTSTR Buf, unsigned cBytes) +FormatBytes(LPWSTR Buf, unsigned cBytes) { - TCHAR szMB[32], Tmp[BUFFER_SIZE]; - NUMBERFMT fmt; - - itoa(cBytes / (1024*1024), szMB, 10); - + WCHAR szMB[32]; + NUMBERFMTW fmt; + + _itow(cBytes / (1024*1024), szMB, 10); + fmt.NumDigits = 0; fmt.LeadingZero = 0; fmt.Grouping = 3; - fmt.lpDecimalSep = TEXT(""); - fmt.lpThousandSep = TEXT(" "); + fmt.lpDecimalSep = L""; + fmt.lpThousandSep = L" "; fmt.NegativeOrder = 0; - if(!GetNumberFormat(LOCALE_SYSTEM_DEFAULT, 0, szMB, &fmt, Tmp, BUFFER_SIZE)) - printf("Error! GetNumberFormat failed.\n"); - - CharToOem(Tmp, Buf); + + if(!GetNumberFormatW(LOCALE_SYSTEM_DEFAULT, 0, szMB, &fmt, Buf, BUFFER_SIZE)) + wprintf(L"Error! GetNumberFormat failed.\n"); } static void -FormatDateTime(time_t Time, LPTSTR lpBuf) +FormatDateTime(time_t Time, LPWSTR lpBuf) { unsigned cchBuf = BUFFER_SIZE, i; SYSTEMTIME SysTime; const struct tm *lpTm; - + lpTm = localtime(&Time); SysTime.wYear = (WORD)(1900 + lpTm->tm_year); SysTime.wMonth = (WORD)(1 + lpTm->tm_mon); @@ -158,12 +155,15 @@ FormatDateTime(time_t Time, LPTSTR lpBuf) SysTime.wMinute = (WORD)lpTm->tm_min; SysTime.wSecond = (WORD)lpTm->tm_sec; SysTime.wMilliseconds = 0; - - i = GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf, cchBuf); + + /* Time first */ + i = GetDateFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf, cchBuf); if (i) --i; /* don't count NULL character */ - i += _stprintf(lpBuf + i, TEXT(", ")); - GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf + i, cchBuf - i); + + /* Time now */ + i += swprintf(lpBuf + i, L", "); + GetTimeFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf + i, cchBuf - i); } /* Show usage */ @@ -171,10 +171,10 @@ static VOID Usage(VOID) { - TCHAR Buf[BUFFER_SIZE]; - + WCHAR Buf[BUFFER_SIZE]; + if(GetOemStrings(IDS_USAGE, Buf)) - _tprintf("%s", Buf); + wprintf(L"%s", Buf); } /* Print all system information */ @@ -182,18 +182,20 @@ VOID AllSysInfo(VOID) { DWORD dwCharCount = BUFFER_SIZE, dwTimestamp; - OSVERSIONINFO VersionInfo; + OSVERSIONINFOW VersionInfo; SYSTEM_INFO SysInfo; - TCHAR Buf[BUFFER_SIZE], Tmp[BUFFER_SIZE], Msg[BUFFER_SIZE], szSystemDir[MAX_PATH]; - const TCHAR *lpcszSysType; + WCHAR Buf[BUFFER_SIZE], Tmp[BUFFER_SIZE], Msg[BUFFER_SIZE], szSystemDir[MAX_PATH]; + const WCHAR *lpcszSysType; + LPWSTR lpNetBuffer; + NETSETUP_JOIN_STATUS NetJoinStatus; MEMORYSTATUS MemoryStatus; unsigned int cSeconds; TIME_ZONE_INFORMATION TimeZoneInfo; HKEY hKey; - if (!GetSystemDirectory(szSystemDir, sizeof(szSystemDir)/sizeof(szSystemDir[0]))) + if (!GetSystemDirectoryW(szSystemDir, sizeof(szSystemDir)/sizeof(szSystemDir[0]))) { - _tprintf("Error! GetSystemDirectory failed.\n"); + wprintf(L"Error! GetSystemDirectory failed.\n"); return; } @@ -201,34 +203,34 @@ AllSysInfo(VOID) // getting computer name dwCharCount = BUFFER_SIZE; - if (!GetComputerName(Buf, &dwCharCount)) - _tprintf("Error! GetComputerName failed.\n"); + if (!GetComputerNameW(Buf, &dwCharCount)) + wprintf(L"Error! GetComputerName failed.\n"); else if (GetOemStrings(IDS_HOST_NAME, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); // open CurrentVersion key - if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), + if(RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) { - _tprintf("Error! RegOpenKeyEx failed.\n"); + wprintf(L"Error! RegOpenKeyEx failed.\n"); return; } //getting OS Name - RegGetSZ(hKey, NULL, TEXT("ProductName"), Buf); + RegGetSZ(hKey, NULL, L"ProductName", Buf); if (GetOemStrings(IDS_OS_NAME, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting OS Version ZeroMemory(&VersionInfo, sizeof(VersionInfo)); VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo); - GetVersionEx(&VersionInfo); + GetVersionExW(&VersionInfo); if (GetOemStrings(IDS_OS_VERSION, Msg)) - _tprintf(Msg, + wprintf(Msg, (unsigned)VersionInfo.dwMajorVersion, (unsigned)VersionInfo.dwMinorVersion, (unsigned)VersionInfo.dwBuildNumber, @@ -240,30 +242,30 @@ AllSysInfo(VOID) //getting OS Configuration //getting OS Build Type - RegGetSZ(hKey, NULL, TEXT("CurrentType"), Buf); + RegGetSZ(hKey, NULL, L"CurrentType", Buf); if (GetOemStrings(IDS_OS_BUILD_TYPE, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting Registered Owner - RegGetSZ(hKey, NULL, TEXT("RegisteredOwner"), Buf); + RegGetSZ(hKey, NULL, L"RegisteredOwner", Buf); if (GetOemStrings(IDS_REG_OWNER, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting Registered Organization - RegGetSZ(hKey, NULL, TEXT("RegisteredOrganization"), Buf); + RegGetSZ(hKey, NULL, L"RegisteredOrganization", Buf); if (GetOemStrings(IDS_REG_ORG, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting Product ID - RegGetSZ(hKey, NULL, TEXT("ProductId"), Buf); + RegGetSZ(hKey, NULL, L"ProductId", Buf); if (GetOemStrings(IDS_PRODUCT_ID, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting Install Date - RegGetDWORD(hKey, NULL, TEXT("InstallDate"), &dwTimestamp); + RegGetDWORD(hKey, NULL, L"InstallDate", &dwTimestamp); FormatDateTime((time_t)dwTimestamp, Buf); if (GetOemStrings(IDS_INST_DATE, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); // close Current Version key now RegCloseKey(hKey); @@ -271,115 +273,115 @@ AllSysInfo(VOID) //getting System Up Time cSeconds = GetTickCount() / 1000; if (GetOemStrings(IDS_UP_TIME, Msg)) - _tprintf(Msg, cSeconds / (60*60*24), (cSeconds / (60*60)) % 24, (cSeconds / 60) % 60, cSeconds % 60); + wprintf(Msg, cSeconds / (60*60*24), (cSeconds / (60*60)) % 24, (cSeconds / 60) % 60, cSeconds % 60); //getting System Manufacturer; HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\Manufacturer for Win >= 6.0 - sprintf(Tmp, "%s\\oeminfo.ini", szSystemDir); - GetPrivateProfileString(TEXT("General"), - TEXT("Manufacturer"), - TEXT("To Be Filled By O.E.M."), - Buf, - sizeof(Buf)/sizeof(Buf[0]), - Tmp); + swprintf(Tmp, L"%s\\oeminfo.ini", szSystemDir); + GetPrivateProfileStringW(L"General", + L"Manufacturer", + L"To Be Filled By O.E.M.", + Buf, + sizeof(Buf)/sizeof(Buf[0]), + Tmp); if (GetOemStrings(IDS_SYS_MANUFACTURER, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting System Model; HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\Model for Win >= 6.0 - GetPrivateProfileString(TEXT("General"), - TEXT("Model"), - TEXT("To Be Filled By O.E.M."), - Buf, - sizeof(Buf)/sizeof(Buf[0]), - Tmp); + GetPrivateProfileStringW(L"General", + L"Model", + L"To Be Filled By O.E.M.", + Buf, + sizeof(Buf)/sizeof(Buf[0]), + Tmp); if (GetOemStrings(IDS_SYS_MODEL, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting System type switch (SysInfo.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_INTEL: - lpcszSysType = TEXT("X86-based PC"); + lpcszSysType = L"X86-based PC"; break; case PROCESSOR_ARCHITECTURE_IA64: - lpcszSysType = TEXT("IA64-based PC"); + lpcszSysType = L"IA64-based PC"; break; case PROCESSOR_ARCHITECTURE_AMD64: - lpcszSysType = TEXT("AMD64-based PC"); + lpcszSysType = L"AMD64-based PC"; break; default: - lpcszSysType = TEXT("Unknown"); + lpcszSysType = L"Unknown"; break; } if (GetOemStrings(IDS_SYS_TYPE, Msg)) - _tprintf(Msg, lpcszSysType); + wprintf(Msg, lpcszSysType); //getting Processor(s) if (GetOemStrings(IDS_PROCESSORS, Msg)) { unsigned int i; - _tprintf(Msg, (unsigned int)SysInfo.dwNumberOfProcessors); + wprintf(Msg, (unsigned int)SysInfo.dwNumberOfProcessors); for(i = 0; i < (unsigned int)SysInfo.dwNumberOfProcessors; i++) { - sprintf(Tmp, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u",i); + swprintf(Tmp, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u", i); - RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, TEXT("Identifier"), Buf); - _tprintf(" [%02u]: %s", i+1, Buf); + RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"Identifier", Buf); + wprintf(L" [%02u]: %s", i+1, Buf); - RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, TEXT("VendorIdentifier"), Buf); - _tprintf(" %s\n", Buf); + RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"VendorIdentifier", Buf); + wprintf(L" %s\n", Buf); } } //getting BIOS Version RegGetSZ(HKEY_LOCAL_MACHINE, - TEXT("HARDWARE\\DESCRIPTION\\System"), - TEXT("SystemBiosVersion"), + L"HARDWARE\\DESCRIPTION\\System", + L"SystemBiosVersion", Buf); if (GetOemStrings(IDS_BIOS_VERSION, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //gettings BIOS date RegGetSZ(HKEY_LOCAL_MACHINE, - TEXT("HARDWARE\\DESCRIPTION\\System"), - TEXT("SystemBiosDate"), + L"HARDWARE\\DESCRIPTION\\System", + L"SystemBiosDate", Buf); if (GetOemStrings(IDS_BIOS_DATE, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting ReactOS Directory - if (!GetWindowsDirectory(Buf, BUFFER_SIZE)) - _tprintf("Error! GetWindowsDirectory failed."); + if (!GetWindowsDirectoryW(Buf, BUFFER_SIZE)) + wprintf(L"Error! GetWindowsDirectory failed."); else if (GetOemStrings(IDS_ROS_DIR, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting System Directory if (GetOemStrings(IDS_SYS_DIR, Msg)) - _tprintf(Msg, szSystemDir); + wprintf(Msg, szSystemDir); //getting Boot Device RegGetSZ(HKEY_LOCAL_MACHINE, - TEXT("SYSTEM\\Setup"), - TEXT("SystemPartition"), + L"SYSTEM\\Setup", + L"SystemPartition", Buf); if (GetOemStrings(IDS_BOOT_DEV, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting System Locale if (RegGetSZ(HKEY_CURRENT_USER, - TEXT("Control Panel\\International"), - TEXT("Locale"), + L"Control Panel\\International", + L"Locale", Tmp)) if (RegGetSZ(HKEY_CLASSES_ROOT, - TEXT("MIME\\Database\\Rfc1766"), + L"MIME\\Database\\Rfc1766", Tmp, Buf)) if (GetOemStrings(IDS_SYS_LOCALE, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting Input Locale if (RegGetSZ(HKEY_CURRENT_USER, - TEXT("Keyboard Layout\\Preload"), - TEXT("1"), + L"Keyboard Layout\\Preload", + L"1", Buf)) { int i, j; @@ -388,84 +390,74 @@ AllSysInfo(VOID) Tmp[j] = Buf[i]; if (RegGetSZ(HKEY_CLASSES_ROOT, - TEXT("MIME\\Database\\Rfc1766"), + L"MIME\\Database\\Rfc1766", Tmp, Buf)) if (GetOemStrings(IDS_INPUT_LOCALE, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); } //getting Time Zone GetTimeZoneInformation(&TimeZoneInfo); - + /* Open Time Zones key */ - if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"), - 0, - KEY_ENUMERATE_SUB_KEYS|KEY_READ, - &hKey) == ERROR_SUCCESS) + if(RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", + 0, + KEY_ENUMERATE_SUB_KEYS|KEY_READ, + &hKey) == ERROR_SUCCESS) { unsigned i; - + /* Find current timezone */ dwCharCount = 256; // Windows seems to have a bug - it doesnt accept BUFFER_SIZE here - for(i = 0; RegEnumKeyEx(hKey, i, Tmp, &dwCharCount, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++i, dwCharCount = 255) + for(i = 0; RegEnumKeyExW(hKey, i, Tmp, &dwCharCount, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++i, dwCharCount = 255) { -#ifdef _UNICODE - RegGetSZ(hKey, Tmp, TEXT("Std"), Buf); - - if(!wcscmp(wBuf, TimeZoneInfo.StandardName)) -#else - wchar_t wBuf[BUFFER_SIZE]; + RegGetSZ(hKey, Tmp, L"Std", Buf); - RegGetSZ(hKey, Tmp, TEXT("Std"), Buf); - mbstowcs(wBuf, Buf, BUFFER_SIZE); - - if(!wcscmp(wBuf, TimeZoneInfo.StandardName)) -#endif + if(!wcscmp(Buf, TimeZoneInfo.StandardName)) { - RegGetSZ(hKey, Tmp, TEXT("Display"), Buf); + RegGetSZ(hKey, Tmp, L"Display", Buf); if (GetOemStrings(IDS_TIME_ZONE, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); break; } } RegCloseKey(hKey); } - - + //getting Total Physical Memory GlobalMemoryStatus(&MemoryStatus); FormatBytes(Buf, MemoryStatus.dwTotalPhys); if (GetOemStrings(IDS_TOTAL_PHYS_MEM, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting Available Physical Memory FormatBytes(Buf, MemoryStatus.dwAvailPhys); if (GetOemStrings(IDS_AVAIL_PHISICAL_MEM,Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting Virtual Memory: Max Size FormatBytes(Buf, MemoryStatus.dwTotalVirtual); if (GetOemStrings(IDS_VIRT_MEM_MAX, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting Virtual Memory: Available FormatBytes(Buf, MemoryStatus.dwAvailVirtual); if (GetOemStrings(IDS_VIRT_MEM_AVAIL, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting Virtual Memory: In Use FormatBytes(Buf, MemoryStatus.dwTotalVirtual-MemoryStatus.dwAvailVirtual); if (GetOemStrings(IDS_VIRT_MEM_INUSE, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); //getting Page File Location(s) if (RegGetSZ(HKEY_LOCAL_MACHINE, - TEXT("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management"), - TEXT("PagingFiles"), + L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management", + L"PagingFiles", Buf)) { int i; @@ -478,18 +470,19 @@ AllSysInfo(VOID) break; } } - + if(GetOemStrings(IDS_PAGEFILE_LOC, Msg)) - _tprintf(Msg, Buf); + wprintf(Msg, Buf); } //getting Domain - if (RegGetSZ(HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), - TEXT("CachePrimaryDomain"), - Buf)) - if(GetOemStrings(IDS_DOMINE, Msg)) - _tprintf(Msg, Buf); + if (NetGetJoinInformation (NULL, &lpNetBuffer, &NetJoinStatus) == NERR_Success) + { + if(GetOemStrings(IDS_DOMAIN, Msg)) + wprintf(Msg, lpNetBuffer); + + NetApiBufferFree(lpNetBuffer); + } //getting Logon Server @@ -504,6 +497,8 @@ AllSysInfo(VOID) int main(int argc, char *argv[]) { + setlocale(LC_ALL, ""); + if (argc > 1 && (!strcmp(argv[1], "/?") || !strcmp(argv[1], "-?"))) { Usage(); diff --git a/rosapps/applications/sysutils/systeminfo/systeminfo.rbuild b/rosapps/applications/sysutils/systeminfo/systeminfo.rbuild index 56a855f263f..5779bd1f911 100644 --- a/rosapps/applications/sysutils/systeminfo/systeminfo.rbuild +++ b/rosapps/applications/sysutils/systeminfo/systeminfo.rbuild @@ -2,6 +2,7 @@ user32 ntdll advapi32 + netapi32 systeminfo.c systeminfo.rc rsrc.rc From 542a951d464e2f20cf2b65b1a768135060121524 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Sat, 2 Apr 2011 15:15:08 +0000 Subject: [PATCH 52/66] [TEE] - TEE should overwrite existing file - Patch by vins8920 hotmail See issue #6022 for more details. svn path=/trunk/; revision=51226 --- rosapps/applications/cmdutils/tee/tee.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosapps/applications/cmdutils/tee/tee.c b/rosapps/applications/cmdutils/tee/tee.c index 0d244fa3038..149f8486d0c 100644 --- a/rosapps/applications/cmdutils/tee/tee.c +++ b/rosapps/applications/cmdutils/tee/tee.c @@ -154,7 +154,7 @@ INT main (int argc,char **p) //l=0; hFile[i] = CreateFile(files[i],GENERIC_WRITE, 0,NULL, - OPEN_ALWAYS, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL); if (hFile[i] == INVALID_HANDLE_VALUE) From 91e657f78287f7faa36440143ef376a21e74a36c Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Sat, 2 Apr 2011 15:22:48 +0000 Subject: [PATCH 53/66] {FULLFAT] - Update FullFat to the latest stable release (1.0.5) - I'm awaiting a reply from James as to when 1.1.0 will be released as it have some nice improvements. svn path=/trunk/; revision=51227 --- .../include/reactos/libs/fullfat/ff_config.h | 15 +- reactos/include/reactos/libs/fullfat/ff_dir.h | 2 +- reactos/include/reactos/libs/fullfat/ff_fat.h | 2 +- .../include/reactos/libs/fullfat/ff_fatdef.h | 90 +++++++++ .../include/reactos/libs/fullfat/ff_ioman.h | 19 +- .../include/reactos/libs/fullfat/ff_memory.h | 118 +++++++++++- .../include/reactos/libs/fullfat/fullfat.h | 8 + reactos/lib/3rdparty/fullfat/ff_dir.c | 1 - reactos/lib/3rdparty/fullfat/ff_dir.h | 2 +- reactos/lib/3rdparty/fullfat/ff_fat.c | 28 ++- reactos/lib/3rdparty/fullfat/ff_file.c | 52 ++++- reactos/lib/3rdparty/fullfat/ff_hash.c | 4 +- reactos/lib/3rdparty/fullfat/ff_ioman.c | 179 ++++++++++++------ reactos/lib/3rdparty/fullfat/ff_memory.c | 106 ++++------- 14 files changed, 456 insertions(+), 170 deletions(-) create mode 100644 reactos/include/reactos/libs/fullfat/ff_fatdef.h diff --git a/reactos/include/reactos/libs/fullfat/ff_config.h b/reactos/include/reactos/libs/fullfat/ff_config.h index f81c79ac7c9..4588ef9c305 100644 --- a/reactos/include/reactos/libs/fullfat/ff_config.h +++ b/reactos/include/reactos/libs/fullfat/ff_config.h @@ -74,13 +74,24 @@ // within the same path. E.g. a copy \dir1\*.* \dir2\*.* command. // This command requires FF_MAX_PATH number of bytes of memory. (Defined below, default 2600). +//---------- BLKDEV USES SEMAPHORE +#define FF_BLKDEV_USES_SEM // When defined, each call to fnReadBlocks and fnWriteBlocks will be done while semaphore is locked + // See also ff_safety.c + // (HT addition) + #define FF_PATH_CACHE_DEPTH 2 // The Number of PATH's to Cache. //---------- DON'T USE MALLOC //#define FF_NO_MALLOC -//---------- DON'T +#define FF_MALLOC(aSize) malloc(aSize) +#define FF_FREE(apPtr) free(apPtr) + +//#define FF_INLINE_MEMORY_ACCESS + +//#define FF_INLINE static __forceinline // Keywords to inline functions (Windows) +#define FF_INLINE static inline // Standard for GCC //---------- Hash Table Support @@ -117,7 +128,7 @@ //---------- AUTOMATIC SETTINGS DO NOT EDIT -- These configure your options from above, and check sanity! #ifdef FF_LFN_SUPPORT -#define FF_MAX_FILENAME 260 +#define FF_MAX_FILENAME (129) #else #define FF_MAX_FILENAME 13 #endif diff --git a/reactos/include/reactos/libs/fullfat/ff_dir.h b/reactos/include/reactos/libs/fullfat/ff_dir.h index 7415eac06e6..41eb7278f8d 100644 --- a/reactos/include/reactos/libs/fullfat/ff_dir.h +++ b/reactos/include/reactos/libs/fullfat/ff_dir.h @@ -43,7 +43,7 @@ #include "ff_ioman.h" #include "ff_blk.h" #include "ff_fat.h" -#include "fat.h" +#include "ff_fatdef.h" #include "ff_memory.h" #include "ff_time.h" #include "ff_hash.h" diff --git a/reactos/include/reactos/libs/fullfat/ff_fat.h b/reactos/include/reactos/libs/fullfat/ff_fat.h index 2e6ff6702b9..8add6d0132e 100644 --- a/reactos/include/reactos/libs/fullfat/ff_fat.h +++ b/reactos/include/reactos/libs/fullfat/ff_fat.h @@ -39,7 +39,7 @@ #define _FF_FAT_H_ #include "ff_config.h" -#include "fat.h" +#include "ff_fatdef.h" #include "ff_ioman.h" #include "ff_blk.h" #include "ff_types.h" diff --git a/reactos/include/reactos/libs/fullfat/ff_fatdef.h b/reactos/include/reactos/libs/fullfat/ff_fatdef.h new file mode 100644 index 00000000000..7fd7c3c5f6f --- /dev/null +++ b/reactos/include/reactos/libs/fullfat/ff_fatdef.h @@ -0,0 +1,90 @@ +/***************************************************************************** + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * + * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + * IMPORTANT NOTICE: * + * ================= * + * Alternative Licensing is available directly from the Copyright holder, * + * (James Walmsley). For more information consult LICENSING.TXT to obtain * + * a Commercial license. * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * Removing the above notice is illegal and will invalidate this license. * + ***************************************************************************** + * See http://worm.me.uk/fullfat for more information. * + * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + *****************************************************************************/ +#ifndef _FF_FATDEF_H_ +#define _FF_FATDEF_H_ + +/* + This file defines offsets to various data for the FAT specification. +*/ + +// MBR / PBR Offsets + +#define FF_FAT_BYTES_PER_SECTOR 0x00B +#define FF_FAT_SECTORS_PER_CLUS 0x00D +#define FF_FAT_RESERVED_SECTORS 0x00E +#define FF_FAT_NUMBER_OF_FATS 0x010 +#define FF_FAT_ROOT_ENTRY_COUNT 0x011 +#define FF_FAT_16_TOTAL_SECTORS 0x013 +#define FF_FAT_32_TOTAL_SECTORS 0x020 +#define FF_FAT_16_SECTORS_PER_FAT 0x016 +#define FF_FAT_32_SECTORS_PER_FAT 0x024 +#define FF_FAT_ROOT_DIR_CLUSTER 0x02C + +#define FF_FAT_16_VOL_LABEL 0x02B +#define FF_FAT_32_VOL_LABEL 0x047 + +#define FF_FAT_PTBL 0x1BE +#define FF_FAT_PTBL_LBA 0x008 +#define FF_FAT_PTBL_ACTIVE 0x000 +#define FF_FAT_PTBL_ID 0x004 + +#define FF_FAT_MBR_SIGNATURE 0x1FE + +#define FF_FAT_DELETED 0xE5 + +// Directory Entry Offsets +#define FF_FAT_DIRENT_SHORTNAME 0x000 +#define FF_FAT_DIRENT_ATTRIB 0x00B +#define FF_FAT_DIRENT_CREATE_TIME 0x00E ///< Creation Time. +#define FF_FAT_DIRENT_CREATE_DATE 0x010 ///< Creation Date. +#define FF_FAT_DIRENT_LASTACC_DATE 0x012 ///< Date of Last Access. +#define FF_FAT_DIRENT_CLUS_HIGH 0x014 +#define FF_FAT_DIRENT_LASTMOD_TIME 0x016 ///< Time of Last modification. +#define FF_FAT_DIRENT_LASTMOD_DATE 0x018 ///< Date of Last modification. +#define FF_FAT_DIRENT_CLUS_LOW 0x01A +#define FF_FAT_DIRENT_FILESIZE 0x01C +#define FF_FAT_LFN_ORD 0x000 +#define FF_FAT_LFN_NAME_1 0x001 +#define FF_FAT_LFN_CHECKSUM 0x00D +#define FF_FAT_LFN_NAME_2 0x00E +#define FF_FAT_LFN_NAME_3 0x01C + +// Dirent Attributes +#define FF_FAT_ATTR_READONLY 0x01 +#define FF_FAT_ATTR_HIDDEN 0x02 +#define FF_FAT_ATTR_SYSTEM 0x04 +#define FF_FAT_ATTR_VOLID 0x08 +#define FF_FAT_ATTR_DIR 0x10 +#define FF_FAT_ATTR_ARCHIVE 0x20 +#define FF_FAT_ATTR_LFN 0x0F + +#endif + diff --git a/reactos/include/reactos/libs/fullfat/ff_ioman.h b/reactos/include/reactos/libs/fullfat/ff_ioman.h index 187ffa347f9..d59c10593cd 100644 --- a/reactos/include/reactos/libs/fullfat/ff_ioman.h +++ b/reactos/include/reactos/libs/fullfat/ff_ioman.h @@ -100,10 +100,10 @@ typedef struct { **/ typedef struct { FF_T_UINT32 Sector; ///< The LBA of the Cached sector. - FF_T_UINT8 Mode; ///< Read or Write mode. + FF_T_UINT32 LRU; ///< For the Least Recently Used algorithm. FF_T_UINT16 NumHandles; ///< Number of objects using this buffer. FF_T_UINT16 Persistance; ///< For the persistance algorithm. - FF_T_UINT32 LRU; ///< For the Least Recently Used algorithm. + FF_T_UINT8 Mode; ///< Read or Write mode. FF_T_BOOL Modified; ///< If the sector was modified since read. FF_T_BOOL Valid; ///< Initially FALSE. FF_T_UINT8 *pBuffer; ///< Pointer to the cache block. @@ -129,7 +129,7 @@ typedef struct { FF_T_UINT16 BlkSize; ///< Size of a Sector Block in bytes. FF_T_UINT8 BlkFactor; ///< Scale Factor for blocksizes above 512! //FF_T_INT8 Name[FF_MAX_PARTITION_NAME]; ///< Partition Identifier e.g. c: sd0: etc. - //FF_T_INT8 VolLabel[12]; ///< Volume Label of the partition. + FF_T_INT8 VolLabel[12]; ///< Volume Label of the partition. FF_T_UINT32 BeginLBA; ///< LBA start address of the partition. FF_T_UINT32 PartSize; ///< Size of Partition in number of sectors. FF_T_UINT32 FatBeginLBA; ///< LBA of the FAT tables. @@ -182,14 +182,15 @@ typedef struct { FF_BLK_DEVICE *pBlkDevice; ///< Pointer to a Block device description. FF_PARTITION *pPartition; ///< Pointer to a partition description. FF_BUFFER *pBuffers; ///< Pointer to the first buffer description. - FF_T_UINT32 LastReplaced; ///< Marks which sector was last replaced in the cache. - FF_T_UINT16 BlkSize; ///< The Block size that IOMAN is configured to. - FF_T_UINT8 *pCacheMem; ///< Pointer to a block of memory for the cache. - FF_T_UINT16 CacheSize; ///< Size of the cache in number of Sectors. - FF_T_UINT8 MemAllocation; ///< Bit-Mask identifying allocated pointers. - FF_T_UINT8 Locks; ///< Lock Flag for FAT & DIR Locking etc (This must be accessed via a semaphore). void *pSemaphore; ///< Pointer to a Semaphore object. (For buffer description modifications only!). void *FirstFile; ///< Pointer to the first File object. + FF_T_UINT8 *pCacheMem; ///< Pointer to a block of memory for the cache. + FF_T_UINT32 LastReplaced; ///< Marks which sector was last replaced in the cache. + FF_T_UINT16 BlkSize; ///< The Block size that IOMAN is configured to. + FF_T_UINT16 CacheSize; ///< Size of the cache in number of Sectors. + FF_T_UINT8 PreventFlush; ///< Flushing to disk only allowed when 0 + FF_T_UINT8 MemAllocation; ///< Bit-Mask identifying allocated pointers. + FF_T_UINT8 Locks; ///< Lock Flag for FAT & DIR Locking etc (This must be accessed via a semaphore). } FF_IOMAN; // Bit-Masks for Memory Allocation testing. diff --git a/reactos/include/reactos/libs/fullfat/ff_memory.h b/reactos/include/reactos/libs/fullfat/ff_memory.h index 1d4507c4a85..555a829210a 100644 --- a/reactos/include/reactos/libs/fullfat/ff_memory.h +++ b/reactos/include/reactos/libs/fullfat/ff_memory.h @@ -41,19 +41,119 @@ #include "ff_config.h" #include "ff_types.h" - +/* + HT changed type of aOffset to u32 +*/ //---------- PROTOTYPES -FF_T_UINT8 FF_getChar (FF_T_UINT8 *pBuffer, FF_T_UINT16 offset); -FF_T_UINT16 FF_getShort (FF_T_UINT8 *pBuffer, FF_T_UINT16 offset); -FF_T_UINT32 FF_getLong (FF_T_UINT8 *pBuffer, FF_T_UINT16 offset); +#if defined(FF_LITTLE_ENDIAN) -void FF_putChar (FF_T_UINT8 *pBuffer, FF_T_UINT16 offset, FF_T_UINT8 Value); -void FF_putShort (FF_T_UINT8 *pBuffer, FF_T_UINT16 offset, FF_T_UINT16 Value); -void FF_putLong (FF_T_UINT8 *pBuffer, FF_T_UINT16 offset, FF_T_UINT32 Value); +typedef struct { + FF_T_UINT8 u8_0; + FF_T_UINT8 u8_1; +} FF_T_SHORT; -void *FF_Malloc(FF_T_UINT32 allocSize); -void FF_Free(void *pBuffer); +typedef struct { + FF_T_UINT8 u8_0; + FF_T_UINT8 u8_1; + FF_T_UINT8 u8_2; + FF_T_UINT8 u8_3; +} FF_T_LONG; + +#elif defined(FF_BIG_ENDIAN) + +typedef struct { + FF_T_UINT8 u8_1; + FF_T_UINT8 u8_0; +} FF_T_SHORT; + +typedef struct { + FF_T_UINT8 u8_3; + FF_T_UINT8 u8_2; + FF_T_UINT8 u8_1; + FF_T_UINT8 u8_0; +} FF_T_LONG; + +#else + +#error Little or Big Endian? + +#endif + +//! 16-bit union. +typedef union { + FF_T_UINT16 u16; + FF_T_SHORT bytes; +} FF_T_UN16; + +//! 32-bit union. +typedef union { + FF_T_UINT32 u32; + FF_T_LONG bytes; +} FF_T_UN32; + +/* HT inlined these functions: + */ + +#ifdef FF_INLINE_MEMORY_ACCESS + +FF_INLINE FF_T_UINT8 FF_getChar(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset) +{ + return (FF_T_UINT8) (pBuffer[aOffset]); +} + +FF_INLINE FF_T_UINT16 FF_getShort(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset) +{ + FF_T_UN16 u16; + pBuffer += aOffset; + u16.bytes.u8_1 = pBuffer[1]; + u16.bytes.u8_0 = pBuffer[0]; + return u16.u16; +} + +FF_INLINE FF_T_UINT32 FF_getLong(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset) { + FF_T_UN32 u32; + pBuffer += aOffset; + u32.bytes.u8_3 = pBuffer[3]; + u32.bytes.u8_2 = pBuffer[2]; + u32.bytes.u8_1 = pBuffer[1]; + u32.bytes.u8_0 = pBuffer[0]; + return u32.u32; +} + +FF_INLINE void FF_putChar(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset, FF_T_UINT8 Value) { + pBuffer[aOffset] = Value; +} + +FF_INLINE void FF_putShort(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset, FF_T_UINT16 Value) { + FF_T_UN16 u16; + u16.u16 = Value; + pBuffer += aOffset; + pBuffer[0] = u16.bytes.u8_0; + pBuffer[1] = u16.bytes.u8_1; +} + +FF_INLINE void FF_putLong(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset, FF_T_UINT32 Value) { + FF_T_UN32 u32; + u32.u32 = Value; + pBuffer += aOffset; + pBuffer[0] = u32.bytes.u8_0; + pBuffer[1] = u32.bytes.u8_1; + pBuffer[2] = u32.bytes.u8_2; + pBuffer[3] = u32.bytes.u8_3; +} + +#else + +FF_T_UINT8 FF_getChar(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset); +FF_T_UINT16 FF_getShort(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset); +FF_T_UINT32 FF_getLong(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset); +void FF_putChar(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset, FF_T_UINT8 Value); +void FF_putShort(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset, FF_T_UINT16 Value); +void FF_putLong(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset, FF_T_UINT32 Value); + + +#endif #endif diff --git a/reactos/include/reactos/libs/fullfat/fullfat.h b/reactos/include/reactos/libs/fullfat/fullfat.h index dd8da071cf5..e4e8363e432 100644 --- a/reactos/include/reactos/libs/fullfat/fullfat.h +++ b/reactos/include/reactos/libs/fullfat/fullfat.h @@ -32,6 +32,10 @@ #ifndef _FULLFAT_H_ #define _FULLFAT_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "ff_config.h" #include "ff_ioman.h" #include "ff_fat.h" @@ -41,6 +45,10 @@ #include "ff_crc.h" #include "ff_hash.h" #include "ff_string.h" +//#include "ff_format.h" +#ifdef __cplusplus +} // extern "C" +#endif #endif diff --git a/reactos/lib/3rdparty/fullfat/ff_dir.c b/reactos/lib/3rdparty/fullfat/ff_dir.c index 6bba0b79020..f35d91c02e6 100644 --- a/reactos/lib/3rdparty/fullfat/ff_dir.c +++ b/reactos/lib/3rdparty/fullfat/ff_dir.c @@ -1769,4 +1769,3 @@ void FF_RmLFNs(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 DirEntry) { }while(FF_getChar(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_ATTRIB)) == FF_FAT_ATTR_LFN); } - diff --git a/reactos/lib/3rdparty/fullfat/ff_dir.h b/reactos/lib/3rdparty/fullfat/ff_dir.h index 7415eac06e6..41eb7278f8d 100644 --- a/reactos/lib/3rdparty/fullfat/ff_dir.h +++ b/reactos/lib/3rdparty/fullfat/ff_dir.h @@ -43,7 +43,7 @@ #include "ff_ioman.h" #include "ff_blk.h" #include "ff_fat.h" -#include "fat.h" +#include "ff_fatdef.h" #include "ff_memory.h" #include "ff_time.h" #include "ff_hash.h" diff --git a/reactos/lib/3rdparty/fullfat/ff_fat.c b/reactos/lib/3rdparty/fullfat/ff_fat.c index 1cbd420ffad..66769e56af7 100644 --- a/reactos/lib/3rdparty/fullfat/ff_fat.c +++ b/reactos/lib/3rdparty/fullfat/ff_fat.c @@ -136,13 +136,13 @@ FF_T_SINT32 FF_getFatEntry(FF_IOMAN *pIoman, FF_T_UINT32 nCluster) { FatSectorEntry = FatOffset % pIoman->pPartition->BlkSize; LBAadjust = (FF_T_UINT8) (FatSectorEntry / pIoman->BlkSize); - relClusterEntry = (FF_T_UINT16) (FatSectorEntry % pIoman->BlkSize); + relClusterEntry = (FF_T_UINT32) (FatSectorEntry % pIoman->BlkSize); FatSector = FF_getRealLBA(pIoman, FatSector); #ifdef FF_FAT12_SUPPORT if(pIoman->pPartition->Type == FF_T_FAT12) { - if(relClusterEntry == (pIoman->BlkSize - 1)) { + if(relClusterEntry == (FF_T_UINT32)(pIoman->BlkSize - 1)) { // Fat Entry SPANS a Sector! // First Buffer get the last Byte in buffer (first byte of our address)! pBuffer = FF_GetBuffer(pIoman, FatSector + LBAadjust, FF_MODE_READ); @@ -333,7 +333,7 @@ FF_T_SINT8 FF_putFatEntry(FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_T_UINT32 Va FF_T_UINT32 FatSectorEntry; FF_T_UINT32 FatEntry; FF_T_UINT8 LBAadjust; - FF_T_UINT16 relClusterEntry; + FF_T_UINT32 relClusterEntry; #ifdef FF_FAT12_SUPPORT FF_T_UINT8 F12short[2]; // For FAT12 FAT Table Across sector boundary traversal. #endif @@ -350,13 +350,13 @@ FF_T_SINT8 FF_putFatEntry(FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_T_UINT32 Va FatSectorEntry = FatOffset % pIoman->pPartition->BlkSize; LBAadjust = (FF_T_UINT8) (FatSectorEntry / pIoman->BlkSize); - relClusterEntry = (FF_T_UINT16)(FatSectorEntry % pIoman->BlkSize); + relClusterEntry = (FF_T_UINT32)(FatSectorEntry % pIoman->BlkSize); FatSector = FF_getRealLBA(pIoman, FatSector); #ifdef FF_FAT12_SUPPORT if(pIoman->pPartition->Type == FF_T_FAT12) { - if(relClusterEntry == (FF_T_UINT16) (pIoman->BlkSize - 1)) { + if(relClusterEntry == (FF_T_UINT32)(pIoman->BlkSize - 1)) { // Fat Entry SPANS a Sector! // First Buffer get the last Byte in buffer (first byte of our address)! pBuffer = FF_GetBuffer(pIoman, FatSector + LBAadjust, FF_MODE_READ); @@ -497,6 +497,11 @@ FF_T_UINT32 FF_FindFreeCluster(FF_IOMAN *pIoman) { for(i = FatSector; i < pIoman->pPartition->SectorsPerFAT; i++) { pBuffer = FF_GetBuffer(pIoman, pIoman->pPartition->FatBeginLBA + i, FF_MODE_READ); { + // HT addition: don't use non-existing clusters + if (nCluster >= pIoman->pPartition->NumClusters) { + FF_ReleaseBuffer(pIoman, pBuffer); + return 0; + } for(x = nCluster % EntriesPerSector; x < EntriesPerSector; x++) { if(pIoman->pPartition->Type == FF_T_FAT32) { FatOffset = x * 4; @@ -612,6 +617,7 @@ FF_T_SINT8 FF_UnlinkClusterChain(FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_ FF_T_UINT32 fatEntry; FF_T_UINT32 currentCluster, chainLength = 0; FF_T_UINT32 iLen = 0; + FF_T_UINT32 lastFree = StartCluster; /* HT addition : reset LastFreeCluster */ fatEntry = StartCluster; @@ -622,9 +628,15 @@ FF_T_SINT8 FF_UnlinkClusterChain(FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_ do { fatEntry = FF_getFatEntry(pIoman, fatEntry); FF_putFatEntry(pIoman, currentCluster, 0x00000000); + if (lastFree > currentCluster) { + lastFree = currentCluster; + } currentCluster = fatEntry; iLen ++; }while(!FF_isEndOfChain(pIoman, fatEntry)); + if (pIoman->pPartition->LastFreeCluster > lastFree) { + pIoman->pPartition->LastFreeCluster = lastFree; + } FF_IncreaseFreeClusters(pIoman, iLen); } else { // Truncation - This is quite hard, because we can only do it backwards. @@ -694,7 +706,7 @@ FF_T_UINT32 FF_CountFreeClusters(FF_IOMAN *pIoman) { } else { FatOffset = x * 2; FatSectorEntry = FatOffset % pIoman->pPartition->BlkSize; - FatEntry = (FF_T_UINT32) FF_getShort(pBuffer->pBuffer, (FF_T_UINT16)FatSectorEntry); + FatEntry = (FF_T_UINT32) FF_getShort(pBuffer->pBuffer, FatSectorEntry); } if(FatEntry == 0x00000000) { FreeClusters += 1; @@ -706,7 +718,7 @@ FF_T_UINT32 FF_CountFreeClusters(FF_IOMAN *pIoman) { FF_ReleaseBuffer(pIoman, pBuffer); } - return FreeClusters; + return FreeClusters <= pIoman->pPartition->NumClusters ? FreeClusters : pIoman->pPartition->NumClusters; } #ifdef FF_64_NUM_SUPPORT @@ -747,4 +759,4 @@ FF_T_UINT32 FF_GetFreeSize(FF_IOMAN *pIoman) { } return 0; } -#endif +#endif \ No newline at end of file diff --git a/reactos/lib/3rdparty/fullfat/ff_file.c b/reactos/lib/3rdparty/fullfat/ff_file.c index 7f982dc90d4..cd29e31562b 100644 --- a/reactos/lib/3rdparty/fullfat/ff_file.c +++ b/reactos/lib/3rdparty/fullfat/ff_file.c @@ -163,7 +163,7 @@ FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ER } return (FF_FILE *)NULL; } - pFile = FF_Malloc(sizeof(FF_FILE)); + pFile = FF_MALLOC(sizeof(FF_FILE)); if(!pFile) { if(pError) { *pError = FF_ERR_NOT_ENOUGH_MEMORY; @@ -222,7 +222,7 @@ FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ER if(Object.Attrib == FF_FAT_ATTR_DIR) { if(!(pFile->Mode & FF_MODE_DIR)) { // Not the object, File Not Found! - FF_Free(pFile); + FF_FREE(pFile); if(pError) { *pError = FF_ERR_FILE_OBJECT_IS_A_DIR; } @@ -233,7 +233,7 @@ FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ER //---------- Ensure Read-Only files don't get opened for Writing. if((pFile->Mode & FF_MODE_WRITE) || (pFile->Mode & FF_MODE_APPEND)) { if((Object.Attrib & FF_FAT_ATTR_READONLY)) { - FF_Free(pFile); + FF_FREE(pFile); if(pError) { *pError = FF_ERR_FILE_IS_READ_ONLY; } @@ -276,7 +276,7 @@ FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ER if(pFileChain->ObjectCluster == pFile->ObjectCluster) { // File is already open! DON'T ALLOW IT! FF_ReleaseSemaphore(pIoman->pSemaphore); - FF_Free(pFile); + FF_FREE(pFile); if(pError) { *pError = FF_ERR_FILE_ALREADY_OPEN; } @@ -294,7 +294,7 @@ FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ER return pFile; }else { - FF_Free(pFile); + FF_FREE(pFile); if(pError) { *pError = FF_ERR_FILE_NOT_FOUND; } @@ -305,7 +305,7 @@ FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ER *pError = FF_ERR_FILE_INVALID_PATH; } - FF_Free(pFile); + FF_FREE(pFile); return (FF_FILE *)NULL; } @@ -600,7 +600,14 @@ static FF_T_SINT32 FF_ReadClusters(FF_FILE *pFile, FF_T_UINT32 Count, FF_T_UINT8 do { if(pFile->pIoman->pBlkDevice->fnReadBlocks) { +#ifdef FF_BLKDEV_USES_SEM + FF_PendSemaphore(pFile->pIoman->pSemaphore); +#endif + // Called from FF_Read, sem not claimed RetVal = pFile->pIoman->pBlkDevice->fnReadBlocks(buffer, nItemLBA, Sectors, pFile->pIoman->pBlkDevice->pParam); +#ifdef FF_BLKDEV_USES_SEM + FF_ReleaseSemaphore(pFile->pIoman->pSemaphore); +#endif if(RetVal == FF_ERR_DRIVER_BUSY) { FF_Yield(); FF_Sleep(FF_DRIVER_BUSY_SLEEP); @@ -703,7 +710,14 @@ static FF_T_SINT32 FF_WriteClusters(FF_FILE *pFile, FF_T_UINT32 Count, FF_T_UINT do { if(pFile->pIoman->pBlkDevice->fnWriteBlocks) { +#ifdef FF_BLKDEV_USES_SEM + FF_PendSemaphore(pFile->pIoman->pSemaphore); +#endif + // Called from FF_Write, sem not claimed RetVal = pFile->pIoman->pBlkDevice->fnWriteBlocks(buffer, nItemLBA, Sectors, pFile->pIoman->pBlkDevice->pParam); +#ifdef FF_BLKDEV_USES_SEM + FF_ReleaseSemaphore(pFile->pIoman->pSemaphore); +#endif if(RetVal == FF_ERR_DRIVER_BUSY) { FF_Yield(); FF_Sleep(FF_DRIVER_BUSY_SLEEP); @@ -832,7 +846,13 @@ FF_T_SINT32 FF_Read(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, do { if(pIoman->pBlkDevice->fnReadBlocks) { +#ifdef FF_BLKDEV_USES_SEM + FF_PendSemaphore(pFile->pIoman->pSemaphore); +#endif RetVal = pFile->pIoman->pBlkDevice->fnReadBlocks(buffer, nItemLBA, sSectors, pIoman->pBlkDevice->pParam); +#ifdef FF_BLKDEV_USES_SEM + FF_ReleaseSemaphore(pFile->pIoman->pSemaphore); +#endif } if(RetVal == FF_ERR_DRIVER_BUSY) { FF_Yield(); @@ -887,7 +907,13 @@ FF_T_SINT32 FF_Read(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, do { if(pIoman->pBlkDevice->fnReadBlocks) { +#ifdef FF_BLKDEV_USES_SEM + FF_PendSemaphore(pFile->pIoman->pSemaphore); +#endif RetVal = pFile->pIoman->pBlkDevice->fnReadBlocks(buffer, nItemLBA, sSectors, pIoman->pBlkDevice->pParam); +#ifdef FF_BLKDEV_USES_SEM + FF_ReleaseSemaphore(pFile->pIoman->pSemaphore); +#endif } if(RetVal == FF_ERR_DRIVER_BUSY) { FF_Yield(); @@ -1116,7 +1142,13 @@ FF_T_SINT32 FF_Write(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, do { if(pIoman->pBlkDevice->fnWriteBlocks) { +#ifdef FF_BLKDEV_USES_SEM + FF_PendSemaphore(pFile->pIoman->pSemaphore); +#endif RetVal = pFile->pIoman->pBlkDevice->fnWriteBlocks(buffer, nItemLBA, sSectors, pIoman->pBlkDevice->pParam); +#ifdef FF_BLKDEV_USES_SEM + FF_ReleaseSemaphore(pFile->pIoman->pSemaphore); +#endif } if(RetVal == FF_ERR_DRIVER_BUSY) { FF_Yield(); @@ -1174,7 +1206,13 @@ FF_T_SINT32 FF_Write(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, do { if(pIoman->pBlkDevice->fnWriteBlocks) { +#ifdef FF_BLKDEV_USES_SEM + FF_PendSemaphore(pFile->pIoman->pSemaphore); +#endif RetVal = pFile->pIoman->pBlkDevice->fnWriteBlocks(buffer, nItemLBA, sSectors, pIoman->pBlkDevice->pParam); +#ifdef FF_BLKDEV_USES_SEM + FF_ReleaseSemaphore(pFile->pIoman->pSemaphore); +#endif } if(RetVal == FF_ERR_DRIVER_BUSY) { FF_Yield(); @@ -1405,7 +1443,7 @@ FF_ERROR FF_Close(FF_FILE *pFile) { FF_ReleaseSemaphore(pFile->pIoman->pSemaphore); // If file written, flush to disk - FF_Free(pFile); + FF_FREE(pFile); // Simply free the pointer! return FF_ERR_NONE; } diff --git a/reactos/lib/3rdparty/fullfat/ff_hash.c b/reactos/lib/3rdparty/fullfat/ff_hash.c index 5bcaf4c66d2..4a07c81d37e 100644 --- a/reactos/lib/3rdparty/fullfat/ff_hash.c +++ b/reactos/lib/3rdparty/fullfat/ff_hash.c @@ -53,7 +53,7 @@ struct _FF_HASH_TABLE { * **/ FF_HASH_TABLE FF_CreateHashTable() { - FF_HASH_TABLE pHash = (FF_HASH_TABLE) FF_Malloc(sizeof(struct _FF_HASH_TABLE)); + FF_HASH_TABLE pHash = (FF_HASH_TABLE) FF_MALLOC(sizeof(struct _FF_HASH_TABLE)); if(pHash) { FF_ClearHashTable(pHash); @@ -110,7 +110,7 @@ FF_T_BOOL FF_isHashSet(FF_HASH_TABLE pHash, FF_T_UINT32 nHash) { FF_ERROR FF_DestroyHashTable(FF_HASH_TABLE pHash) { if(pHash) { - free(pHash); + FF_FREE(pHash); return FF_ERR_NONE; } return FF_ERR_NULL_POINTER; diff --git a/reactos/lib/3rdparty/fullfat/ff_ioman.c b/reactos/lib/3rdparty/fullfat/ff_ioman.c index c30126d3f28..60871f831a0 100644 --- a/reactos/lib/3rdparty/fullfat/ff_ioman.c +++ b/reactos/lib/3rdparty/fullfat/ff_ioman.c @@ -42,8 +42,10 @@ * Destroying a FullFAT IO object. **/ +#include + #include "ff_ioman.h" // Includes ff_types.h, ff_safety.h, -#include "fat.h" +#include "ff_fatdef.h" extern FF_T_UINT32 FF_FindFreeCluster (FF_IOMAN *pIoman); extern FF_T_UINT32 FF_CountFreeClusters (FF_IOMAN *pIoman); @@ -89,7 +91,7 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl return NULL; // Memory Size not a multiple of BlkSize > 0 } - pIoman = (FF_IOMAN *) FF_Malloc(sizeof(FF_IOMAN)); + pIoman = (FF_IOMAN *) FF_MALLOC(sizeof(FF_IOMAN)); if(!pIoman) { // Ensure malloc() succeeded. if(pError) { @@ -98,62 +100,68 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl return NULL; } + memset (pIoman, '\0', sizeof(FF_IOMAN)); + // This is just a bit-mask, to use a byte to keep track of memory. // pIoman->MemAllocation = 0x00; // Unset all allocation identifiers. - pIoman->pBlkDevice = NULL; - pIoman->pBuffers = NULL; - pIoman->pCacheMem = NULL; - pIoman->pPartition = NULL; - pIoman->pSemaphore = NULL; - - pIoman->pPartition = (FF_PARTITION *) FF_Malloc(sizeof(FF_PARTITION)); - if(pIoman->pPartition) { // If succeeded, flag that allocation. - pIoman->MemAllocation |= FF_IOMAN_ALLOC_PART; - pIoman->pPartition->LastFreeCluster = 0; - pIoman->pPartition->PartitionMounted = FF_FALSE; // This should be checked by FF_Open(); -#ifdef FF_PATH_CACHE - pIoman->pPartition->PCIndex = 0; - for(i = 0; i < FF_PATH_CACHE_DEPTH; i++) { - pIoman->pPartition->PathCache[i].DirCluster = 0; - pIoman->pPartition->PathCache[i].Path[0] = '\0'; -#ifdef FF_HASH_TABLE_SUPPORT - pIoman->pPartition->PathCache[i].pHashTable = FF_CreateHashTable(); - pIoman->pPartition->PathCache[i].bHashed = FF_FALSE; -#endif + pIoman->pPartition = (FF_PARTITION *) FF_MALLOC(sizeof(FF_PARTITION)); + if(!pIoman->pPartition) { + if(pError) { + *pError = FF_ERR_NOT_ENOUGH_MEMORY; } + FF_DestroyIOMAN(pIoman); + return NULL; + } + memset (pIoman->pPartition, '\0', sizeof(FF_PARTITION)); + + pIoman->MemAllocation |= FF_IOMAN_ALLOC_PART; // If succeeded, flag that allocation. + pIoman->pPartition->LastFreeCluster = 0; + pIoman->pPartition->PartitionMounted = FF_FALSE; // This should be checked by FF_Open(); +#ifdef FF_PATH_CACHE + pIoman->pPartition->PCIndex = 0; + for(i = 0; i < FF_PATH_CACHE_DEPTH; i++) { + pIoman->pPartition->PathCache[i].DirCluster = 0; + pIoman->pPartition->PathCache[i].Path[0] = '\0'; +#ifdef FF_HASH_TABLE_SUPPORT + pIoman->pPartition->PathCache[i].pHashTable = FF_CreateHashTable(); + pIoman->pPartition->PathCache[i].bHashed = FF_FALSE; #endif - } else { + } +#endif + + pIoman->pBlkDevice = (FF_BLK_DEVICE *) FF_MALLOC(sizeof(FF_BLK_DEVICE)); + if(!pIoman->pBlkDevice) { // If succeeded, flag that allocation. + if(pError) { + *pError = FF_ERR_NOT_ENOUGH_MEMORY; + } FF_DestroyIOMAN(pIoman); return NULL; } + memset (pIoman->pBlkDevice, '\0', sizeof(FF_BLK_DEVICE)); + pIoman->MemAllocation |= FF_IOMAN_ALLOC_BLKDEV; - pIoman->pBlkDevice = (FF_BLK_DEVICE *) FF_Malloc(sizeof(FF_BLK_DEVICE)); - if(pIoman->pBlkDevice) { // If succeeded, flag that allocation. - pIoman->MemAllocation |= FF_IOMAN_ALLOC_BLKDEV; - - // Make sure all pointers are NULL - pIoman->pBlkDevice->fnReadBlocks = NULL; - pIoman->pBlkDevice->fnWriteBlocks = NULL; - pIoman->pBlkDevice->pParam = NULL; - - } else { - FF_DestroyIOMAN(pIoman); - return NULL; - } + // Make sure all pointers are NULL + pIoman->pBlkDevice->fnReadBlocks = NULL; + pIoman->pBlkDevice->fnWriteBlocks = NULL; + pIoman->pBlkDevice->pParam = NULL; // Organise the memory provided, or create our own! if(pCacheMem) { pIoman->pCacheMem = pCacheMem; }else { // No-Cache buffer provided (malloc) - pLong = (FF_T_UINT32 *) FF_Malloc(Size); + pLong = (FF_T_UINT32 *) FF_MALLOC(Size); pIoman->pCacheMem = (FF_T_UINT8 *) pLong; if(!pIoman->pCacheMem) { - pIoman->MemAllocation |= FF_IOMAN_ALLOC_BUFFERS; + if(pError) { + *pError = FF_ERR_NOT_ENOUGH_MEMORY; + } FF_DestroyIOMAN(pIoman); return NULL; } + pIoman->MemAllocation |= FF_IOMAN_ALLOC_BUFFERS; } + memset (pIoman->pCacheMem, '\0', Size); pIoman->BlkSize = BlkSize; pIoman->CacheSize = (FF_T_UINT16) (Size / BlkSize); @@ -163,14 +171,19 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl /* Malloc() memory for buffer objects. (FullFAT never refers to a buffer directly but uses buffer objects instead. Allows us to provide thread safety. */ - pIoman->pBuffers = (FF_BUFFER *) FF_Malloc(sizeof(FF_BUFFER) * pIoman->CacheSize); + pIoman->pBuffers = (FF_BUFFER *) FF_MALLOC(sizeof(FF_BUFFER) * pIoman->CacheSize); - if(pIoman->pBuffers) { - pIoman->MemAllocation |= FF_IOMAN_ALLOC_BUFDESCR; - FF_IOMAN_InitBufferDescriptors(pIoman); - } else { + if(!pIoman->pBuffers) { + if(pError) { + *pError = FF_ERR_NOT_ENOUGH_MEMORY; + } FF_DestroyIOMAN(pIoman); + return NULL; // HT added } + memset (pIoman->pBuffers, '\0', sizeof(FF_BUFFER) * pIoman->CacheSize); + + pIoman->MemAllocation |= FF_IOMAN_ALLOC_BUFDESCR; + FF_IOMAN_InitBufferDescriptors(pIoman); // Finally create a Semaphore for Buffer Description modifications. pIoman->pSemaphore = FF_CreateSemaphore(); @@ -196,22 +209,22 @@ FF_ERROR FF_DestroyIOMAN(FF_IOMAN *pIoman) { // Ensure pPartition pointer was allocated. if((pIoman->MemAllocation & FF_IOMAN_ALLOC_PART)) { - FF_Free(pIoman->pPartition); + FF_FREE(pIoman->pPartition); } // Ensure pBlkDevice pointer was allocated. if((pIoman->MemAllocation & FF_IOMAN_ALLOC_BLKDEV)) { - FF_Free(pIoman->pBlkDevice); + FF_FREE(pIoman->pBlkDevice); } // Ensure pBuffers pointer was allocated. if((pIoman->MemAllocation & FF_IOMAN_ALLOC_BUFDESCR)) { - FF_Free(pIoman->pBuffers); + FF_FREE(pIoman->pBuffers); } // Ensure pCacheMem pointer was allocated. if((pIoman->MemAllocation & FF_IOMAN_ALLOC_BUFFERS)) { - FF_Free(pIoman->pCacheMem); + FF_FREE(pIoman->pCacheMem); } // Destroy any Semaphore that was created. @@ -220,7 +233,7 @@ FF_ERROR FF_DestroyIOMAN(FF_IOMAN *pIoman) { } // Finally free the FF_IOMAN object. - FF_Free(pIoman); + FF_FREE(pIoman); return FF_ERR_NONE; } @@ -236,15 +249,9 @@ static void FF_IOMAN_InitBufferDescriptors(FF_IOMAN *pIoman) { FF_T_UINT16 i; FF_BUFFER *pBuffer = pIoman->pBuffers; pIoman->LastReplaced = 0; + // HT : it is assmued that pBuffer was cleared by memset () for(i = 0; i < pIoman->CacheSize; i++) { - pBuffer->Mode = 0; - pBuffer->NumHandles = 0; - pBuffer->Persistance = 0; - pBuffer->LRU = 0; - pBuffer->Sector = 0; pBuffer->pBuffer = (FF_T_UINT8 *)((pIoman->pCacheMem) + (pIoman->BlkSize * i)); - pBuffer->Modified = FF_FALSE; - pBuffer->Valid = FF_FALSE; pBuffer++; } } @@ -273,12 +280,15 @@ static void FF_IOMAN_InitBufferDescriptors(FF_IOMAN *pIoman) { * @param Sector LBA address of the sector to fetch. * @param pBuffer Pointer to a byte-wise buffer to store the fetched data. * + * HT Note: will be called while semaphore claimed (by FF_GetBuffer) + * * @return FF_TRUE when valid, else FF_FALSE. **/ static FF_ERROR FF_IOMAN_FillBuffer(FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_UINT8 *pBuffer) { FF_T_SINT32 retVal = 0; if(pIoman->pBlkDevice->fnReadBlocks) { // Make sure we don't execute a NULL. do{ + // Called from FF_GetBuffer with semaphore claimed retVal = pIoman->pBlkDevice->fnReadBlocks(pBuffer, Sector, 1, pIoman->pBlkDevice->pParam); if(retVal == FF_ERR_DRIVER_BUSY) { FF_Sleep(FF_DRIVER_BUSY_SLEEP); @@ -306,9 +316,13 @@ static FF_ERROR FF_IOMAN_FillBuffer(FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_U * @param Sector LBA address of the sector to fetch. * @param pBuffer Pointer to a byte-wise buffer to store the fetched data. * + * + * HT made it a globally accesible function to be used by new module ff_format.c + * Note that this function is called when semaphore is already locked + * * @return FF_TRUE when valid, else FF_FALSE. **/ -static FF_ERROR FF_IOMAN_FlushBuffer(FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_UINT8 *pBuffer) { +/* static */ FF_ERROR FF_IOMAN_FlushBuffer(FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_UINT8 *pBuffer) { FF_T_SINT32 retVal = 0; if(pIoman->pBlkDevice->fnWriteBlocks) { // Make sure we don't execute a NULL. do{ @@ -481,7 +495,7 @@ FF_BUFFER *FF_GetBuffer(FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_UINT8 Mode) { } } FF_ReleaseSemaphore(pIoman->pSemaphore); - FF_Yield(); + FF_Yield(); // Better to go asleep to give low-priority task a chance to release buffer(s) } return pBufMatch; // Return the Matched Buffer! @@ -500,7 +514,11 @@ void FF_ReleaseBuffer(FF_IOMAN *pIoman, FF_BUFFER *pBuffer) { // Protect description changes with a semaphore. FF_PendSemaphore(pIoman->pSemaphore); { - pBuffer->NumHandles--; + if (pBuffer->NumHandles) { + pBuffer->NumHandles--; + } else { + //printf ("FF_ReleaseBuffer: buffer not claimed\n"); + } } FF_ReleaseSemaphore(pIoman->pSemaphore); } @@ -630,6 +648,34 @@ static FF_ERROR FF_DetermineFatType(FF_IOMAN *pIoman) { return FF_ERR_IOMAN_NOT_FAT_FORMATTED; } + +static FF_T_SINT8 FF_PartitionCount (FF_T_UINT8 *pBuffer) +{ + FF_T_SINT8 count = 0; + FF_T_SINT8 part; + // Check PBR or MBR signature + if (FF_getChar(pBuffer, FF_FAT_MBR_SIGNATURE) != 0x55 && + FF_getChar(pBuffer, FF_FAT_MBR_SIGNATURE) != 0xAA ) { + // No MBR, but is it a PBR ? + if (FF_getChar(pBuffer, 0) == 0xEB && // PBR Byte 0 + FF_getChar(pBuffer, 2) == 0x90 && // PBR Byte 2 + (FF_getChar(pBuffer, 21) & 0xF0) == 0xF0) {// PBR Byte 21 : Media byte + return 1; // No MBR but PBR exist then only one partition + } + return 0; // No MBR and no PBR then no partition found + } + for (part = 0; part < 4; part++) { + FF_T_UINT8 active = FF_getChar(pBuffer, FF_FAT_PTBL + FF_FAT_PTBL_ACTIVE + (16 * part)); + FF_T_UINT8 part_id = FF_getChar(pBuffer, FF_FAT_PTBL + FF_FAT_PTBL_ID + (16 * part)); + // The first sector must be a MBR, then check the partition entry in the MBR + if (active != 0x80 && (active != 0 || part_id == 0)) { + break; + } + count++; + } + return count; +} + /** * @public * @brief Mounts the Specified partition, the volume specified by the FF_IOMAN object provided. @@ -651,6 +697,7 @@ static FF_ERROR FF_DetermineFatType(FF_IOMAN *pIoman) { FF_ERROR FF_MountPartition(FF_IOMAN *pIoman, FF_T_UINT8 PartitionNumber) { FF_PARTITION *pPart; FF_BUFFER *pBuffer = 0; + int partCount; if(!pIoman) { return FF_ERR_NULL_POINTER; @@ -662,18 +709,27 @@ FF_ERROR FF_MountPartition(FF_IOMAN *pIoman, FF_T_UINT8 PartitionNumber) { pPart = pIoman->pPartition; + memset (pIoman->pBuffers, '\0', sizeof(FF_BUFFER) * pIoman->CacheSize); + memset (pIoman->pCacheMem, '\0', pIoman->BlkSize * pIoman->CacheSize); + + FF_IOMAN_InitBufferDescriptors(pIoman); + pIoman->FirstFile = 0; + pBuffer = FF_GetBuffer(pIoman, 0, FF_MODE_READ); if(!pBuffer) { return FF_ERR_DEVICE_DRIVER_FAILED; } + + partCount = FF_PartitionCount (pBuffer->pBuffer); + pPart->BlkSize = FF_getShort(pBuffer->pBuffer, FF_FAT_BYTES_PER_SECTOR); - if((pPart->BlkSize % 512) == 0 && pPart->BlkSize > 0) { + if (partCount == 0) { //(pPart->BlkSize % 512) == 0 && pPart->BlkSize > 0) { // Volume is not partitioned (MBR Found) pPart->BeginLBA = 0; } else { // Primary Partitions to deal with! - pPart->BeginLBA = FF_getLong(pBuffer->pBuffer, (FF_T_UINT16)(FF_FAT_PTBL + FF_FAT_PTBL_LBA + (16 * PartitionNumber))); + pPart->BeginLBA = FF_getLong(pBuffer->pBuffer, FF_FAT_PTBL + FF_FAT_PTBL_LBA + (16 * PartitionNumber)); FF_ReleaseBuffer(pIoman, pBuffer); if(!pPart->BeginLBA) { @@ -690,6 +746,7 @@ FF_ERROR FF_MountPartition(FF_IOMAN *pIoman, FF_T_UINT8 PartitionNumber) { return FF_ERR_IOMAN_INVALID_FORMAT; } } + // Assume FAT16, then we'll adjust if its FAT32 pPart->ReservedSectors = FF_getShort(pBuffer->pBuffer, FF_FAT_RESERVED_SECTORS); pPart->FatBeginLBA = pPart->BeginLBA + pPart->ReservedSectors; @@ -709,6 +766,7 @@ FF_ERROR FF_MountPartition(FF_IOMAN *pIoman, FF_T_UINT8 PartitionNumber) { if(pPart->TotalSectors == 0) { pPart->TotalSectors = FF_getLong(pBuffer->pBuffer, FF_FAT_32_TOTAL_SECTORS); } + memcpy (pPart->VolLabel, pBuffer->pBuffer + FF_FAT_32_VOL_LABEL, sizeof pPart->VolLabel); } else { // FAT16 pPart->ClusterBeginLBA = pPart->BeginLBA + pPart->ReservedSectors + (pPart->NumFATS * pPart->SectorsPerFAT); pPart->TotalSectors = (FF_T_UINT32) FF_getShort(pBuffer->pBuffer, FF_FAT_16_TOTAL_SECTORS); @@ -716,6 +774,7 @@ FF_ERROR FF_MountPartition(FF_IOMAN *pIoman, FF_T_UINT8 PartitionNumber) { if(pPart->TotalSectors == 0) { pPart->TotalSectors = FF_getLong(pBuffer->pBuffer, FF_FAT_32_TOTAL_SECTORS); } + memcpy (pPart->VolLabel, pBuffer->pBuffer + FF_FAT_16_VOL_LABEL, sizeof pPart->VolLabel); } FF_ReleaseBuffer(pIoman, pBuffer); // Release the buffer finally! diff --git a/reactos/lib/3rdparty/fullfat/ff_memory.c b/reactos/lib/3rdparty/fullfat/ff_memory.c index cdbb2acf02d..2d6913d64d7 100644 --- a/reactos/lib/3rdparty/fullfat/ff_memory.c +++ b/reactos/lib/3rdparty/fullfat/ff_memory.c @@ -48,87 +48,55 @@ #include "ff_memory.h" #include "ff_config.h" -#ifdef FF_LITTLE_ENDIAN - -/** - * @public - * @brief 8 bit memory access routines. - **/ /* - These functions swap the byte-orders of shorts and longs. A getChar function is provided - incase there is a system that doesn't have byte-wise access to all memory. + * HT inlined these functions + * + * Not much left for the C-module + */ - These functions can be replaced with your own platform specific byte-order swapping routines - for more efficiency. - The provided functions should work on almost all platforms. -*/ -FF_T_UINT8 FF_getChar(FF_T_UINT8 *pBuffer, FF_T_UINT16 offset) { - return (FF_T_UINT8) (pBuffer[offset]); +#ifndef FF_INLINE_MEMORY_ACCESS +FF_T_UINT8 FF_getChar(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset) { + return (FF_T_UINT8) (pBuffer[aOffset]); } -FF_T_UINT16 FF_getShort(FF_T_UINT8 *pBuffer, FF_T_UINT16 offset) { - return (FF_T_UINT16) (pBuffer[offset] & 0x00FF) | ((FF_T_UINT16) (pBuffer[offset+1] << 8) & 0xFF00); +FF_T_UINT16 FF_getShort(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset) { + FF_T_UN16 u16; + pBuffer += aOffset; + u16.bytes.u8_1 = pBuffer[1]; + u16.bytes.u8_0 = pBuffer[0]; + return u16.u16; } -FF_T_UINT32 FF_getLong(FF_T_UINT8 *pBuffer, FF_T_UINT16 offset) { - return (FF_T_UINT32) (pBuffer[offset] & 0x000000FF) | ((FF_T_UINT32) (pBuffer[offset+1] << 8) & 0x0000FF00) | ((FF_T_UINT32) (pBuffer[offset+2] << 16) & 0x00FF0000) | ((FF_T_UINT32) (pBuffer[offset+3] << 24) & 0xFF000000); +FF_T_UINT32 FF_getLong(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset) { + FF_T_UN32 u32; + pBuffer += aOffset; + u32.bytes.u8_3 = pBuffer[3]; + u32.bytes.u8_2 = pBuffer[2]; + u32.bytes.u8_1 = pBuffer[1]; + u32.bytes.u8_0 = pBuffer[0]; + return u32.u32; } -void FF_putChar(FF_T_UINT8 *pBuffer, FF_T_UINT16 offset, FF_T_UINT8 Value) { - pBuffer[offset] = Value; +void FF_putChar(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset, FF_T_UINT8 Value) { + pBuffer[aOffset] = Value; } -void FF_putShort(FF_T_UINT8 *pBuffer, FF_T_UINT16 offset, FF_T_UINT16 Value) { - FF_T_UINT8 *Val = (FF_T_UINT8 *) &Value; - pBuffer[offset] = Val[0]; - pBuffer[offset + 1] = Val[1]; +void FF_putShort(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset, FF_T_UINT16 Value) { + FF_T_UN16 u16; + u16.u16 = Value; + pBuffer += aOffset; + pBuffer[0] = u16.bytes.u8_0; + pBuffer[1] = u16.bytes.u8_1; } -void FF_putLong(FF_T_UINT8 *pBuffer, FF_T_UINT16 offset, FF_T_UINT32 Value) { - FF_T_UINT8 *Val = (FF_T_UINT8 *) &Value; - pBuffer[offset] = Val[0]; - pBuffer[offset + 1] = Val[1]; - pBuffer[offset + 2] = Val[2]; - pBuffer[offset + 3] = Val[3]; -} - -#endif - -#ifdef FF_BIG_ENDIAN -/* - These haven't been tested or checked. They should work in theory :) - Please contact james@worm.me.uk if they don't work, and also any fix. -*/ -FF_T_UINT8 FF_getChar(FF_T_UINT8 *pBuffer, FF_T_UINT16 offset) { - return (FF_T_UINT8) (pBuffer[offset]); -} - -FF_T_UINT16 FF_getShort(FF_T_UINT8 *pBuffer, FF_T_UINT16 offset) { - return (FF_T_UINT16) ((pBuffer[offset] & 0xFF00) << 8) | ((FF_T_UINT16) (pBuffer[offset+1]) & 0x00FF); -} - -FF_T_UINT32 FF_getLong(FF_T_UINT8 *pBuffer, FF_T_UINT16 offset) { - return (FF_T_UINT32) ((pBuffer[offset] << 24) & 0xFF0000) | ((FF_T_UINT32) (pBuffer[offset+1] << 16) & 0x00FF0000) | ((FF_T_UINT32) (pBuffer[offset+2] << 8) & 0x0000FF00) | ((FF_T_UINT32) (pBuffer[offset+3]) & 0x000000FF); -} - -void FF_putChar(FF_T_UINT8 *pBuffer, FF_T_UINT16 offset, FF_T_UINT8 Value) { - pBuffer[offset] = Value; -} - -void FF_putShort(FF_T_UINT8 *pBuffer, FF_T_UINT16 offset, FF_T_UINT16 Value) { - FF_T_UINT8 *Val = (FF_T_UINT8 *) &Value; - pBuffer[offset] = Val[1]; - pBuffer[offset + 1] = Val[0]; -} - -void FF_putLong(FF_T_UINT8 *pBuffer, FF_T_UINT16 offset, FF_T_UINT32 Value) { - FF_T_UINT8 *Val = (FF_T_UINT8 *) &Value; - pBuffer[offset] = Val[3]; - pBuffer[offset + 1] = Val[2]; - pBuffer[offset + 2] = Val[1]; - pBuffer[offset + 3] = Val[0]; +void FF_putLong(FF_T_UINT8 *pBuffer, FF_T_UINT32 aOffset, FF_T_UINT32 Value) { + FF_T_UN32 u32; + u32.u32 = Value; + pBuffer += aOffset; + pBuffer[0] = u32.bytes.u8_0; + pBuffer[1] = u32.bytes.u8_1; + pBuffer[2] = u32.bytes.u8_2; + pBuffer[3] = u32.bytes.u8_3; } #endif - - From 888f3912cb212baf778c727d83389b17121d48d4 Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Sat, 2 Apr 2011 15:50:45 +0000 Subject: [PATCH 54/66] [SYSTEMINFO] * Fix System Locale field * Fix Input Locale field svn path=/trunk/; revision=51228 --- .../sysutils/systeminfo/systeminfo.c | 50 ++++++++++--------- .../sysutils/systeminfo/systeminfo.rbuild | 1 + 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/rosapps/applications/sysutils/systeminfo/systeminfo.c b/rosapps/applications/sysutils/systeminfo/systeminfo.c index 3f8d354f49a..49503679c2b 100644 --- a/rosapps/applications/sysutils/systeminfo/systeminfo.c +++ b/rosapps/applications/sysutils/systeminfo/systeminfo.c @@ -18,13 +18,12 @@ #include #include -#include #include -#include #include #include #include #include +#include #include "resource.h" @@ -56,7 +55,7 @@ RegGetSZ(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPWSTR Buf) KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) { - //wprintf("Warning! Cannot open %s. Last error: %lu.\n", lpSubKey, GetLastError()); + wprintf(L"Warning! Cannot open %s. Last error: %lu.\n", lpSubKey, GetLastError()); return FALSE; } @@ -67,7 +66,7 @@ RegGetSZ(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPWSTR Buf) (LPBYTE)Buf, &dwBytes) != ERROR_SUCCESS || (dwType != REG_SZ && dwType != REG_MULTI_SZ)) { - //wprintf("Warning! Cannot query %s. Last error: %lu, type: %lu.\n", lpValueName, GetLastError(), dwType); + wprintf(L"Warning! Cannot query %s. Last error: %lu, type: %lu.\n", lpValueName, GetLastError(), dwType); dwBytes = 0; bRet = FALSE; } @@ -96,6 +95,7 @@ RegGetDWORD(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPDWORD lpData) KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) { + wprintf(L"Warning! Cannot open %s. Last error: %lu.\n", lpSubKey, GetLastError()); return FALSE; } @@ -106,7 +106,7 @@ RegGetDWORD(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPDWORD lpData) (LPBYTE)lpData, &dwBytes) != ERROR_SUCCESS || dwType != REG_DWORD) { - //wprintf("Warning! Cannot query %s. Last err: %lu, type: %lu\n", lpValueName, GetLastError(), dwType); + wprintf(L"Warning! Cannot query %s. Last err: %lu, type: %lu\n", lpValueName, GetLastError(), dwType); *lpData = 0; bRet = FALSE; } @@ -186,7 +186,7 @@ AllSysInfo(VOID) SYSTEM_INFO SysInfo; WCHAR Buf[BUFFER_SIZE], Tmp[BUFFER_SIZE], Msg[BUFFER_SIZE], szSystemDir[MAX_PATH]; const WCHAR *lpcszSysType; - LPWSTR lpNetBuffer; + LPWSTR lpBuffer; NETSETUP_JOIN_STATUS NetJoinStatus; MEMORYSTATUS MemoryStatus; unsigned int cSeconds; @@ -325,7 +325,7 @@ AllSysInfo(VOID) swprintf(Tmp, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u", i); RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"Identifier", Buf); - wprintf(L" [%02u]: %s", i+1, Buf); + wprintf(L" [%02u]: %s", i+1, Buf); RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"VendorIdentifier", Buf); wprintf(L" %s\n", Buf); @@ -367,35 +367,39 @@ AllSysInfo(VOID) wprintf(Msg, Buf); //getting System Locale - if (RegGetSZ(HKEY_CURRENT_USER, - L"Control Panel\\International", - L"Locale", - Tmp)) + if (GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, Tmp, BUFFER_SIZE)) if (RegGetSZ(HKEY_CLASSES_ROOT, L"MIME\\Database\\Rfc1766", Tmp, Buf)) + { + /* get rid of @filename,resource */ + lpBuffer = wcschr(Buf, L';'); + if (lpBuffer) + SHLoadIndirectString(lpBuffer+1, lpBuffer+1, BUFFER_SIZE - (lpBuffer-Buf) - 1, NULL); + if (GetOemStrings(IDS_SYS_LOCALE, Msg)) wprintf(Msg, Buf); + } //getting Input Locale if (RegGetSZ(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", L"1", - Buf)) - { - int i, j; - - for(j = 0, i = 4; i <= 8; j++, i++) - Tmp[j] = Buf[i]; - + Tmp) && wcslen(Tmp) > 4) if (RegGetSZ(HKEY_CLASSES_ROOT, L"MIME\\Database\\Rfc1766", - Tmp, + Tmp + 4, Buf)) + { + /* get rid of @filename,resource */ + lpBuffer = wcschr(Buf, L';'); + if (lpBuffer) + SHLoadIndirectString(lpBuffer+1, lpBuffer+1, BUFFER_SIZE - (lpBuffer-Buf) - 1, NULL); + if (GetOemStrings(IDS_INPUT_LOCALE, Msg)) wprintf(Msg, Buf); - } + } //getting Time Zone GetTimeZoneInformation(&TimeZoneInfo); @@ -476,12 +480,12 @@ AllSysInfo(VOID) } //getting Domain - if (NetGetJoinInformation (NULL, &lpNetBuffer, &NetJoinStatus) == NERR_Success) + if (NetGetJoinInformation (NULL, &lpBuffer, &NetJoinStatus) == NERR_Success) { if(GetOemStrings(IDS_DOMAIN, Msg)) - wprintf(Msg, lpNetBuffer); + wprintf(Msg, lpBuffer); - NetApiBufferFree(lpNetBuffer); + NetApiBufferFree(lpBuffer); } //getting Logon Server diff --git a/rosapps/applications/sysutils/systeminfo/systeminfo.rbuild b/rosapps/applications/sysutils/systeminfo/systeminfo.rbuild index 5779bd1f911..fc3ef6dd2c3 100644 --- a/rosapps/applications/sysutils/systeminfo/systeminfo.rbuild +++ b/rosapps/applications/sysutils/systeminfo/systeminfo.rbuild @@ -3,6 +3,7 @@ ntdll advapi32 netapi32 + shlwapi systeminfo.c systeminfo.rc rsrc.rc From 271454653dc352ee752e5743c4ae4182639eceeb Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Sat, 2 Apr 2011 16:31:43 +0000 Subject: [PATCH 55/66] [FULLFAT] - Update FullFat to the latest SVN code on James' recommendation. - This release has many advantages over the previous, including full UTF-8 and UTF-16 support and the ability to modify attributes and timestamps. All of which are important for ros. - It currently has a few warnings (in both gcc and msc), so I've had to turn allow warnings on. svn path=/trunk/; revision=51229 --- .../include/reactos/libs/fullfat/ff_config.h | 194 +- reactos/include/reactos/libs/fullfat/ff_crc.h | 1 + reactos/include/reactos/libs/fullfat/ff_dir.h | 134 +- .../include/reactos/libs/fullfat/ff_error.h | 130 +- reactos/include/reactos/libs/fullfat/ff_fat.h | 25 +- .../include/reactos/libs/fullfat/ff_fatdef.h | 15 + .../include/reactos/libs/fullfat/ff_file.h | 20 +- .../include/reactos/libs/fullfat/ff_format.h | 47 + .../include/reactos/libs/fullfat/ff_ioman.h | 29 +- .../include/reactos/libs/fullfat/ff_memory.h | 2 +- .../include/reactos/libs/fullfat/ff_string.h | 36 +- .../include/reactos/libs/fullfat/ff_types.h | 9 + .../include/reactos/libs/fullfat/ff_unicode.h | 60 + .../include/reactos/libs/fullfat/fullfat.h | 1 + reactos/lib/3rdparty/fullfat/ff_crc.c | 73 +- reactos/lib/3rdparty/fullfat/ff_dir.c | 2460 +++++++++++------ reactos/lib/3rdparty/fullfat/ff_dir.h | 134 +- reactos/lib/3rdparty/fullfat/ff_error.c | 6 +- reactos/lib/3rdparty/fullfat/ff_fat.c | 168 +- reactos/lib/3rdparty/fullfat/ff_file.c | 716 +++-- reactos/lib/3rdparty/fullfat/ff_format.c | 132 + reactos/lib/3rdparty/fullfat/ff_hash.c | 4 +- reactos/lib/3rdparty/fullfat/ff_ioman.c | 462 ++-- reactos/lib/3rdparty/fullfat/ff_string.c | 274 +- reactos/lib/3rdparty/fullfat/ff_unicode.c | 294 ++ reactos/lib/3rdparty/fullfat/fullfat.rbuild | 4 +- 26 files changed, 3972 insertions(+), 1458 deletions(-) create mode 100644 reactos/include/reactos/libs/fullfat/ff_format.h create mode 100644 reactos/include/reactos/libs/fullfat/ff_unicode.h create mode 100644 reactos/lib/3rdparty/fullfat/ff_format.c create mode 100644 reactos/lib/3rdparty/fullfat/ff_unicode.c diff --git a/reactos/include/reactos/libs/fullfat/ff_config.h b/reactos/include/reactos/libs/fullfat/ff_config.h index 4588ef9c305..0c8e3f37db2 100644 --- a/reactos/include/reactos/libs/fullfat/ff_config.h +++ b/reactos/include/reactos/libs/fullfat/ff_config.h @@ -34,108 +34,138 @@ Here you can change the configuration of FullFAT as appropriate to your platform. */ - //---------- ENDIANESS -#define FF_LITTLE_ENDIAN // Choosing the Byte-order of your system is important. -//#define FF_BIG_ENDIAN // You may be able to provide better Byte-order swapping routines to FullFAT. - // See ff_memory.c for more information. +#define FF_LITTLE_ENDIAN // Choosing the Byte-order of your system is important. +//#define FF_BIG_ENDIAN // You may be able to provide better Byte-order swapping routines to FullFAT. + // See ff_memory.c for more information. + //---------- LFN (Long File-name) SUPPORT -#define FF_LFN_SUPPORT // Comment this out if you don't want to worry about Patent Issues. - // FullFAT works great with LFNs and without. You choose, its your project! +#define FF_LFN_SUPPORT // Comment this out if you don't want to worry about Patent Issues. + // FullFAT works great with LFNs and without. You choose, its your project! -//---------- LEGAL LFNS -//#define FF_LEGAL_LFNS // Enabling this define causes FullFAT to not infringe on any of Microsoft's patents when making LFN names. - // To do this, it will only create LFNs and no shortnames. Microsofts patents are only relevent when mapping - // a shortname to a long name. This is the same way that Linux gets around the FAT legal issues: - // see http://lkml.org/lkml/2009/6/26/314 - // - // Enabling this may break compatibility with devices that cannot read LFN filenames. - // Enabling this option causes no compatibility issues when reading any media. - -//---------- TIME SUPPORT -#define FF_TIME_SUPPORT // Should FullFAT use time stamping. Only if you have provided the relevant time drivers in ff_time.c - // Note, by default ff_time.c is set-up for the Windows Demonstration. Please see ff_time.c to disable. - -//---------- FILE SPACE ALLOCATION PERFORMANCE - // Uncomment the prefered method. (Can only choose a single method). -#define FF_ALLOC_DEFAULT // Only allocate as much as is needed. (Provides good performance, without wasting space). -//#define FF_ALLOC_DOUBLE // Doubles the size of a file each time allocation is required. (When high-performance writing is required). - -//---------- Use Native STDIO.h -//#define FF_USE_NATIVE_STDIO // Makes FullFAT conform to values provided by your native STDIO.h file. - -//---------- FREE SPACE CALCULATION -//#define FF_MOUNT_FIND_FREE // Uncomment this option to check for Freespace on a volume mount. (Performance Penalty while mounting). - // If not done in the mount, it will be done on the first call to FF_GetFreeSize() function. - -//---------- PATH CACHE -#define FF_PATH_CACHE // Enables a simply Path Caching mechanism that increases performance of repeated operations - // within the same path. E.g. a copy \dir1\*.* \dir2\*.* command. - // This command requires FF_MAX_PATH number of bytes of memory. (Defined below, default 2600). - -//---------- BLKDEV USES SEMAPHORE -#define FF_BLKDEV_USES_SEM // When defined, each call to fnReadBlocks and fnWriteBlocks will be done while semaphore is locked - // See also ff_safety.c - // (HT addition) +//#define FF_INCLUDE_SHORT_NAME // HT addition, in 'FF_DIRENT', beside FileName, ShortName will be filled as well + // Useful for debugging, but also some situations its useful to know both. +//---------- SHORTNAMES CAN USE THE CASE BITS +#define FF_SHORTNAME_CASE // Works for XP+ e.g. short.TXT or SHORT.txt. -#define FF_PATH_CACHE_DEPTH 2 // The Number of PATH's to Cache. +//---------- UNICODE SUPPORT +//#define FF_UNICODE_SUPPORT // If this is defined, then all of FullFAT's API's will expect to receive UTF-16 formatted strings. + // FF_FindFirst() and FF_FindNext() will also return Filenames in UTF-16 format. + // NOTE: This option may cause FullFAT to not "Clean-compile" when using GCC. This is because + // pedantically GCC refuses to accept C99 library functions, unless the -std=c99 flag is used. + // To use UNICODE (UTF-16, or UTF-32 depending on the size of wchar_t) you must have a C99 compliant + // compiler and library. -//---------- DON'T USE MALLOC -//#define FF_NO_MALLOC +//#define FF_UNICODE_UTF8_SUPPORT // If this is defined, then all of FullFAT's API's will expect to receive UTF-8 formatted strings. + // FF_FindFirst() and FF_FindNext() will also return Filenames in UTF-8 format. -#define FF_MALLOC(aSize) malloc(aSize) -#define FF_FREE(apPtr) free(apPtr) - -//#define FF_INLINE_MEMORY_ACCESS - -//#define FF_INLINE static __forceinline // Keywords to inline functions (Windows) -#define FF_INLINE static inline // Standard for GCC - - -//---------- Hash Table Support -//#define FF_HASH_TABLE_SUPPORT // Enable HASH to speed up file creation. -#ifdef FF_HASH_TABLE_SUPPORT -#define FF_HASH_FUNCTION CRC16 -//#define FF_HASH_FUNCTION CRC8 -#endif + // Note the 2 UNICODE options are mutually exclusive. Only one can be enabled. + // Ensure that dirents are big enough to hold the maximum UTF-8 sequence. //---------- FAT12 SUPPORT -#define FF_FAT12_SUPPORT // Enable FAT12 Suppport. You can reduce the code-size by commenting this out. - // If you don't need FAT12 support, why have it. FAT12 is more complex to process, - // therefore savings can be made by not having it. +#define FF_FAT12_SUPPORT // Enable FAT12 Suppport. You can reduce the code-size by commenting this out. + // If you don't need FAT12 support, why have it. FAT12 is more complex to process, + // therefore savings can be made by not having it. + + +//---------- TIME SUPPORT +#define FF_TIME_SUPPORT // Should FullFAT use time stamping. Only if you have provided the relevant time drivers in ff_time.c + // Note, by default ff_time.c is set-up for the Windows Demonstration. Please see ff_time.c to disable. + + +//---------- FILE SPACE ALLOCATION PERFORMANCE + // Uncomment the prefered method. (Can only choose a single method). +#define FF_ALLOC_DEFAULT // Only allocate as much as is needed. (Provides good performance, without wasting space). +//#define FF_ALLOC_DOUBLE // Doubles the size of a file each time allocation is required. (When high-performance writing is required). + + +//---------- Use Native STDIO.h +//#define FF_USE_NATIVE_STDIO // Makes FullFAT conform to values provided by your native STDIO.h file. + + +//---------- FREE SPACE CALCULATION +//#define FF_MOUNT_FIND_FREE // Uncomment this option to check for Freespace on a volume mount. (Performance Penalty while mounting). + // If not done in the mount, it will be done on the first call to FF_GetFreeSize() function. + + +//---------- FIND API WILD-CARD SUPPORT +#define FF_FINDAPI_ALLOW_WILDCARDS // Defined to enable Wild-cards in the API. Disabling this, makes the API consistent with 1.0.x series. + +#define FF_WILDCARD_CASE_INSENSITIVE // Alter the case insensitivity of the Wild-card checking behaviour. + + +//---------- PATH CACHE ---------- +#define FF_PATH_CACHE // Enables a simply Path Caching mechanism that increases performance of repeated operations + // within the same path. E.g. a copy \dir1\*.* \dir2\*.* command. + // This command requires FF_MAX_PATH number of bytes of memory. (Defined below, default 2600). + +#define FF_PATH_CACHE_DEPTH 5 // The Number of PATH's to Cache. (Memory Requirement ~= FF_PATH_CACHE_DEPTH * FF_MAX_PATH). + + +//---------- HASH CACHE // Speed up File-creation with a HASH table. Provides up to 20x performance boost. +//#define FF_HASH_CACHE // Enable HASH to speed up file creation. +#define FF_HASH_CACHE_DEPTH 10 // Number of Directories to be Hashed. (For CRC16 memory is 8KB * DEPTH) +#define FF_HASH_FUNCTION CRC16 // Choose a 16-bit hash. +//#define FF_HASH_FUNCTION CRC8 // Choose an 8-bit hash. + + +//---------- BLKDEV USES SEMAPHORE +#define FF_BLKDEV_USES_SEM // When defined, each call to fnReadBlocks and fnWriteBlocks will be done while semaphore is locked + // See also ff_safety.c + // (HT addition) - Thanks to Hein Tibosch + + +//---------- MALLOC + // These should map on to platform specific memory allocators. +#define FF_MALLOC(aSize) malloc(aSize) +#define FF_FREE(apPtr) free(apPtr) + + +//---------- IN-LINE FUNCTIONS +//---------- INLINE KeyWord // Define FF_INLINE as your compiler's inline keyword. This is placed before the type qualifier. +#define FF_INLINE static __forceinline // Keywords to inline functions (Windows) +//#define FF_INLINE static inline // Standard for GCC + +//---------- Inline Memory Independence Routines for better performance, but bigger codesize. +//#define FF_INLINE_MEMORY_ACCESS +//---------- Inline Block Calculation Routines for slightly better performance in critical sections. +//#define FF_INLINE_BLOCK_CALCULATIONS + //---------- 64-Bit Number Support -#define FF_64_NUM_SUPPORT // This helps to give information about the FreeSpace and VolumeSize of a partition or volume. - // If you cannot support 64-bit integers, then FullFAT still works, its just that the functions: - // FF_GetFreeSize() and FF_GetVolumeSize() don't make sense when reporting sizes > 4GB. +#define FF_64_NUM_SUPPORT // This helps to give information about the FreeSpace and VolumeSize of a partition or volume. + // If you cannot support 64-bit integers, then FullFAT still works, its just that the functions: + // FF_GetFreeSize() and FF_GetVolumeSize() don't make sense when reporting sizes > 4GB. -//---------- Driver Sleep Time // How long FullFAT should sleep the thread for in ms, if FF_ERR_DRIVER_BUSY is recieved. -#define FF_DRIVER_BUSY_SLEEP 20 -//---------- Debugging Features -#define FF_DEBUG // Enable the Error Code string functions. const FF_T_INT8 *FF_GetErrMessage( FF_T_SINT32 iErrorCode); - // Uncommenting this just stops FullFAT error strings being compiled. +//---------- Driver Sleep Time +#define FF_DRIVER_BUSY_SLEEP 20 // How long FullFAT should sleep the thread for in ms, if FF_ERR_DRIVER_BUSY is recieved. -//---------- Actively Determine if partition is FAT -#define FF_FAT_CHECK // This is experimental, so if FullFAT won't mount your volume, comment this out - // Also report the problem to james@worm.me.uk + +//---------- DEBUGGING FEATURES (HELPFUL ERROR MESSAGES) +#define FF_DEBUG // Enable the Error Code string functions. const FF_T_INT8 *FF_GetErrMessage( FF_T_SINT32 iErrorCode); + // Uncommenting this just stops FullFAT error strings being compiled. + // Further calls to FF_GetErrMessage() are safe, and simply returns a pointer to a NULL string. (""). + // This should be disabled to reduce code-size dramatically. //---------- AUTOMATIC SETTINGS DO NOT EDIT -- These configure your options from above, and check sanity! #ifdef FF_LFN_SUPPORT -#define FF_MAX_FILENAME (129) +#define FF_MAX_FILENAME (260) #else -#define FF_MAX_FILENAME 13 +#define FF_MAX_FILENAME (13) #endif #ifdef FF_USE_NATIVE_STDIO #ifdef MAX_PATH #define FF_MAX_PATH MAX_PATH +#elif PATH_MAX +#define FF_MAX_PATH PATH_MAX #else #define FF_MAX_PATH 2600 #endif @@ -155,6 +185,16 @@ #endif #endif +#ifdef FF_UNICODE_SUPPORT +#ifdef FF_UNICODE_UTF8_SUPPORT +#error FullFAT Invalid ff_config.h file: Must choose a single UNICODE support option. FF_UNICODE_SUPPORT for UTF-16, FF_UNICODE_UTF8_SUPPORT for UTF-8. +#endif +#endif + +#ifndef FF_FAT_CHECK // FF_FAT_CHECK is now forced. +#define FF_FAT_CHECK +#endif + #ifndef FF_LITTLE_ENDIAN #ifndef FF_BIG_ENDIAN #error FullFAT Invalid ff_config.h file: An ENDIANESS must be defined for your platform. See ff_config.h file. @@ -167,16 +207,18 @@ #endif #endif -#ifdef FF_HASH_TABLE_SUPPORT +#ifdef FF_HASH_CACHE #if FF_HASH_FUNCTION == CRC16 #define FF_HASH_TABLE_SIZE 8192 #elif FF_HASH_FUNCTION == CRC8 #define FF_HASH_TABLE_SIZE 32 #else -#error Invalid Hashing function selected. CRC16 or CRC8! +#error FullFAT Invalid ff_config.h file: Invalid Hashing function selected. CRC16 or CRC8! #endif #endif #endif + +//---------- END-OF-CONFIGURATION diff --git a/reactos/include/reactos/libs/fullfat/ff_crc.h b/reactos/include/reactos/libs/fullfat/ff_crc.h index 7349269d836..51b658dc1f3 100644 --- a/reactos/include/reactos/libs/fullfat/ff_crc.h +++ b/reactos/include/reactos/libs/fullfat/ff_crc.h @@ -44,6 +44,7 @@ FF_T_UINT8 FF_GetCRC8 (FF_T_UINT8 *pbyData, FF_T_UINT32 stLength); FF_T_UINT16 FF_GetCRC16 (FF_T_UINT8 *pbyData, FF_T_UINT32 stLength); +FF_T_UINT32 FF_GetCRC32 (FF_T_UINT8 *pbyData, FF_T_UINT32 stLength); #endif diff --git a/reactos/include/reactos/libs/fullfat/ff_dir.h b/reactos/include/reactos/libs/fullfat/ff_dir.h index 41eb7278f8d..6c99b7279c5 100644 --- a/reactos/include/reactos/libs/fullfat/ff_dir.h +++ b/reactos/include/reactos/libs/fullfat/ff_dir.h @@ -52,54 +52,118 @@ #include typedef struct { - FF_T_INT8 FileName[FF_MAX_FILENAME]; - FF_T_UINT8 Attrib; + FF_T_UINT32 ulChainLength; + FF_T_UINT32 ulDirCluster; + FF_T_UINT32 ulCurrentClusterLCN; + FF_T_UINT32 ulCurrentClusterNum; + FF_T_UINT32 ulCurrentEntry; + FF_BUFFER *pBuffer; +} FF_FETCH_CONTEXT; + +typedef struct { FF_T_UINT32 Filesize; FF_T_UINT32 ObjectCluster; - + + // Book Keeping + FF_T_UINT32 CurrentCluster; + FF_T_UINT32 AddrCurrentCluster; + FF_T_UINT32 DirCluster; + FF_T_UINT16 CurrentItem; + // End Book Keeping + #ifdef FF_TIME_SUPPORT FF_SYSTEMTIME CreateTime; ///< Date and Time Created. FF_SYSTEMTIME ModifiedTime; ///< Date and Time Modified. FF_SYSTEMTIME AccessedTime; ///< Date of Last Access. #endif - //---- Book Keeping for FF_Find Functions - FF_T_UINT16 CurrentItem; - FF_T_UINT32 DirCluster; - FF_T_UINT32 CurrentCluster; - FF_T_UINT32 AddrCurrentCluster; - //FF_T_UINT8 NumLFNs; +#ifdef FF_FINDAPI_ALLOW_WILDCARDS +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR szWildCard[FF_MAX_FILENAME]; +#else + FF_T_INT8 szWildCard[FF_MAX_FILENAME]; +#endif +#endif + +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR FileName[FF_MAX_FILENAME]; +#else + FF_T_INT8 FileName[FF_MAX_FILENAME]; +#endif + +#if defined(FF_LFN_SUPPORT) && defined(FF_INCLUDE_SHORT_NAME) + FF_T_INT8 ShortName[13]; +#endif + FF_T_UINT8 Attrib; + FF_FETCH_CONTEXT FetchContext; } FF_DIRENT; - FF_ERROR FF_GetEntry (FF_IOMAN *pIoman, FF_T_UINT16 nEntry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); - FF_T_SINT8 FF_PutEntry (FF_IOMAN *pIoman, FF_T_UINT16 Entry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); - FF_T_SINT8 FF_FindEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *Name, FF_DIRENT *pDirent, FF_T_BOOL LFNs); - FF_ERROR FF_FindFirst (FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_INT8 *path); - FF_ERROR FF_FindNext (FF_IOMAN *pIoman, FF_DIRENT *pDirent); - void FF_PopulateShortDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT8 *EntryBuffer); - FF_T_SINT8 FF_PopulateLongDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry); - FF_T_SINT8 FF_FetchEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer); - FF_T_SINT8 FF_PushEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer); - FF_T_BOOL FF_isEndOfDir (FF_T_UINT8 *EntryBuffer); - FF_T_SINT8 FF_FindNextInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); - FF_T_UINT32 FF_FindEntryInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent); - FF_T_SINT8 FF_CreateShortName(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *ShortName, FF_T_INT8 *LongName); - -void FF_lockDIR (FF_IOMAN *pIoman); -void FF_unlockDIR (FF_IOMAN *pIoman); -FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *FileName, FF_DIRENT *pDirent); -FF_ERROR FF_MkDir(FF_IOMAN *pIoman, const FF_T_INT8 *Path); -FF_T_SINT8 FF_CreateDirent(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); -FF_T_SINT8 FF_ExtendDirectory(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster); -FF_T_UINT32 FF_FindDir(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 pathLen); -FF_T_BOOL FF_CheckDirentHash(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash); -FF_T_BOOL FF_DirHashed(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster); -FF_ERROR FF_AddDirentHash(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash); -void FF_SetDirHashed(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster); +// PUBLIC API +#ifdef FF_UNICODE_SUPPORT +FF_ERROR FF_FindFirst (FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_WCHAR *path); +FF_ERROR FF_MkDir (FF_IOMAN *pIoman, const FF_T_WCHAR *Path); +#else +FF_ERROR FF_FindFirst (FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_INT8 *path); +FF_ERROR FF_MkDir (FF_IOMAN *pIoman, const FF_T_INT8 *Path); +#endif -void FF_RmLFNs(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 DirEntry); +FF_ERROR FF_FindNext (FF_IOMAN *pIoman, FF_DIRENT *pDirent); + + +// INTERNAL API +FF_ERROR FF_GetEntry (FF_IOMAN *pIoman, FF_T_UINT16 nEntry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); +FF_ERROR FF_PutEntry (FF_IOMAN *pIoman, FF_T_UINT16 Entry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); +FF_T_SINT8 FF_FindEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *Name, FF_DIRENT *pDirent, FF_T_BOOL LFNs); + +void FF_PopulateShortDirent (FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT8 *EntryBuffer); +FF_ERROR FF_PopulateLongDirent (FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT16 nEntry, FF_FETCH_CONTEXT *pFetchContext); + +FF_ERROR FF_InitEntryFetch (FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster, FF_FETCH_CONTEXT *pContext); +FF_ERROR FF_FetchEntryWithContext (FF_IOMAN *pIoman, FF_T_UINT32 ulEntry, FF_FETCH_CONTEXT *pContext, FF_T_UINT8 *pEntryBuffer); +FF_ERROR FF_PushEntryWithContext (FF_IOMAN *pIoman, FF_T_UINT32 ulEntry, FF_FETCH_CONTEXT *pContext, FF_T_UINT8 *pEntryBuffer); +void FF_CleanupEntryFetch (FF_IOMAN *pIoman, FF_FETCH_CONTEXT *pContext); + +FF_T_SINT8 FF_PushEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer, void *pParam); +FF_T_BOOL FF_isEndOfDir (FF_T_UINT8 *EntryBuffer); +FF_ERROR FF_FindNextInDir (FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_FETCH_CONTEXT *pFetchContext); + +#ifdef FF_UNICODE_SUPPORT +FF_T_UINT32 FF_FindEntryInDir (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, const FF_T_WCHAR *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent, FF_ERROR *pError); +FF_T_SINT8 FF_CreateShortName (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_WCHAR *ShortName, FF_T_WCHAR *LongName); +#else +FF_T_UINT32 FF_FindEntryInDir (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, const FF_T_INT8 *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent, FF_ERROR *pError); +FF_T_SINT8 FF_CreateShortName (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *ShortName, FF_T_INT8 *LongName); +#endif + + +void FF_lockDIR (FF_IOMAN *pIoman); +void FF_unlockDIR (FF_IOMAN *pIoman); + +#ifdef FF_UNICODE_SUPPORT +FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_WCHAR *FileName, FF_DIRENT *pDirent, FF_ERROR *pError); +#else +FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *FileName, FF_DIRENT *pDirent, FF_ERROR *pError); +#endif + +FF_ERROR FF_CreateDirent (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); +FF_ERROR FF_ExtendDirectory (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster); + +#ifdef FF_UNICODE_SUPPORT +FF_T_UINT32 FF_FindDir (FF_IOMAN *pIoman, const FF_T_WCHAR *path, FF_T_UINT16 pathLen, FF_ERROR *pError); +#else +FF_T_UINT32 FF_FindDir (FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 pathLen, FF_ERROR *pError); +#endif + +#ifdef FF_HASH_CACHE +FF_T_BOOL FF_CheckDirentHash (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash); +FF_T_BOOL FF_DirHashed (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster); +FF_ERROR FF_AddDirentHash (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash); +FF_ERROR FF_HashDir (FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster); +#endif + +FF_ERROR FF_RmLFNs(FF_IOMAN *pIoman, FF_T_UINT16 usDirEntry, FF_FETCH_CONTEXT *pContext); #endif diff --git a/reactos/include/reactos/libs/fullfat/ff_error.h b/reactos/include/reactos/libs/fullfat/ff_error.h index 8a48c8f1cce..c6b39dcd018 100644 --- a/reactos/include/reactos/libs/fullfat/ff_error.h +++ b/reactos/include/reactos/libs/fullfat/ff_error.h @@ -40,53 +40,111 @@ #include "ff_config.h" #include "ff_types.h" +/** + Error codes are 32-bit numbers, and consist of three items: + 8Bits 8bits 16bits + ........ ........ ........ ........ + [ModuleID][FunctionID][-- ERROR CODE --] + +**/ + +#define FF_GETERROR(x) (x & 0x0000FFFF) + +#define FF_MODULE_SHIFT 24 +#define FF_FUNCTION_SHIFT 16 + +//----- FullFAT Module Identifiers +#define FF_MODULE_IOMAN (1 << FF_MODULE_SHIFT) +#define FF_MODULE_DIR (2 << FF_MODULE_SHIFT) +#define FF_MODULE_FILE (3 << FF_MODULE_SHIFT) +#define FF_MODULE_FAT (4 << FF_MODULE_SHIFT) +#define FF_MODULE_CRC (5 << FF_MODULE_SHIFT) +#define FF_MODULE_FORMAT (6 << FF_MODULE_SHIFT) +#define FF_MODULE_HASH (7 << FF_MODULE_SHIFT) +#define FF_MODULE_MEMORY (8 << FF_MODULE_SHIFT) +#define FF_MODULE_STRING (9 << FF_MODULE_SHIFT) +#define FF_MODULE_UNICODE (10 << FF_MODULE_SHIFT) +#define FF_MODULE_SAFETY (11 << FF_MODULE_SHIFT) +#define FF_MODULE_TIME (12 << FF_MODULE_SHIFT) +#define FF_MODULE_DRIVER (13 << FF_MODULE_SHIFT) // We can mark underlying platform error codes with this. + +//----- FullFAT Function Identifiers (In Modular Order) +//----- FF_IOMAN - The FullFAT I/O Manager. +#define FF_CREATEIOMAN (1 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN +#define FF_DESTROYIOMAN (2 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN +#define FF_REGISTERBLKDEVICE (3 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN +#define FF_UNREGISTERBLKDEVICE (4 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN +#define FF_MOUNTPARTITION (5 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN +#define FF_UNMOUNTPARTITION (6 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN +#define FF_FLUSHCACHE (7 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN +#define FF_GETPARTITIONBLOCKSIZE (8 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN +#define FF_BLOCKREAD (9 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN +#define FF_BLOCKWRITE (10 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN + +//----- FF_DIR - The FullFAT directory handling routines. +// -- COMPLETE THESE ERROR CODES TOMORROW :P + + /* FullFAT defines different Error-Code spaces for each module. This ensures that all error codes remain unique, and their meaning can be quickly identified. */ // Global Error Codes -#define FF_ERR_NONE 0 ///< No Error -#define FF_ERR_NULL_POINTER -2 ///< pIoman was NULL. -#define FF_ERR_NOT_ENOUGH_MEMORY -3 ///< malloc() failed! - Could not allocate handle memory. -#define FF_ERR_DEVICE_DRIVER_FAILED -4 ///< The Block Device driver reported a FATAL error, cannot continue. +#define FF_ERR_NONE 0 ///< No Error +//#define FF_ERR_GENERIC 1 ///< BAD NEVER USE THIS! +#define FF_ERR_NULL_POINTER 2 ///< pIoman was NULL. +#define FF_ERR_NOT_ENOUGH_MEMORY 3 ///< malloc() failed! - Could not allocate handle memory. +#define FF_ERR_DEVICE_DRIVER_FAILED 4 ///< The Block Device driver reported a FATAL error, cannot continue. // IOMAN Error Codes -#define FF_ERR_IOMAN_BAD_BLKSIZE -11 ///< The provided blocksize was not a multiple of 512. -#define FF_ERR_IOMAN_BAD_MEMSIZE -12 ///< The memory size was not a multiple of the blocksize. -#define FF_ERR_IOMAN_DEV_ALREADY_REGD -13 ///< Device was already registered. Use FF_UnRegister() to re-use this IOMAN with another device. -#define FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION -14 ///< A mountable partition could not be found on the device. -#define FF_ERR_IOMAN_INVALID_FORMAT -15 ///< The -#define FF_ERR_IOMAN_INVALID_PARTITION_NUM -16 ///< The partition number provided was out of range. -#define FF_ERR_IOMAN_NOT_FAT_FORMATTED -17 ///< The partition did not look like a FAT partition. -#define FF_ERR_IOMAN_DEV_INVALID_BLKSIZE -18 ///< IOMAN object BlkSize is not compatible with the blocksize of this device driver. -#define FF_ERR_IOMAN_PARTITION_MOUNTED -19 ///< Device is in use by an actively mounted partition. Unmount the partition first. -#define FF_ERR_IOMAN_ACTIVE_HANDLES -20 ///< The partition cannot be unmounted until all active file handles are closed. (There may also be active handles on the cache). +#define FF_ERR_IOMAN_BAD_BLKSIZE 11 ///< The provided blocksize was not a multiple of 512. +#define FF_ERR_IOMAN_BAD_MEMSIZE 12 ///< The memory size was not a multiple of the blocksize. +#define FF_ERR_IOMAN_DEV_ALREADY_REGD 13 ///< Device was already registered. Use FF_UnRegister() to re-use this IOMAN with another device. +#define FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION 14 ///< A mountable partition could not be found on the device. +#define FF_ERR_IOMAN_INVALID_FORMAT 15 ///< The +#define FF_ERR_IOMAN_INVALID_PARTITION_NUM 16 ///< The partition number provided was out of range. +#define FF_ERR_IOMAN_NOT_FAT_FORMATTED 17 ///< The partition did not look like a FAT partition. +#define FF_ERR_IOMAN_DEV_INVALID_BLKSIZE 18 ///< IOMAN object BlkSize is not compatible with the blocksize of this device driver. +#define FF_ERR_IOMAN_PARTITION_MOUNTED 19 ///< Device is in use by an actively mounted partition. Unmount the partition first. +#define FF_ERR_IOMAN_ACTIVE_HANDLES 20 ///< The partition cannot be unmounted until all active file handles are closed. (There may also be active handles on the cache). +#define FF_ERR_IOMAN_GPT_HEADER_CORRUPT 21 ///< The GPT partition table appears to be corrupt, refusing to mount. +#define FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE 22 +#define FF_ERR_IOMAN_OUT_OF_BOUNDS_READ 23 +#define FF_ERR_IOMAN_OUT_OF_BOUNDS_WRITE 24 -// File Error Codes -30 + -#define FF_ERR_FILE_ALREADY_OPEN -30 ///< File is in use. -#define FF_ERR_FILE_NOT_FOUND -31 ///< File was not found. -#define FF_ERR_FILE_OBJECT_IS_A_DIR -32 ///< Tried to FF_Open() a Directory. -#define FF_ERR_FILE_IS_READ_ONLY -33 ///< Tried to FF_Open() a file marked read only. -#define FF_ERR_FILE_INVALID_PATH -34 ///< The path of the file was not found. -#define FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE -35 -#define FF_ERR_FILE_NOT_OPENED_IN_READ_MODE -36 -#define FF_ERR_FILE_EXTEND_FAILED -37 ///< Could not extend the file. -#define FF_ERR_FILE_DESTINATION_EXISTS -38 -#define FF_ERR_FILE_SOURCE_NOT_FOUND -39 -#define FF_ERR_FILE_DIR_NOT_FOUND -40 -#define FF_ERR_FILE_COULD_NOT_CREATE_DIRENT -41 +// File Error Codes 30 + +#define FF_ERR_FILE_ALREADY_OPEN 30 ///< File is in use. +#define FF_ERR_FILE_NOT_FOUND 31 ///< File was not found. +#define FF_ERR_FILE_OBJECT_IS_A_DIR 32 ///< Tried to FF_Open() a Directory. +#define FF_ERR_FILE_IS_READ_ONLY 33 ///< Tried to FF_Open() a file marked read only. +#define FF_ERR_FILE_INVALID_PATH 34 ///< The path of the file was not found. +#define FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE 35 +#define FF_ERR_FILE_NOT_OPENED_IN_READ_MODE 36 +#define FF_ERR_FILE_EXTEND_FAILED 37 ///< Could not extend the file. +#define FF_ERR_FILE_DESTINATION_EXISTS 38 +#define FF_ERR_FILE_SOURCE_NOT_FOUND 39 +#define FF_ERR_FILE_DIR_NOT_FOUND 40 +#define FF_ERR_FILE_COULD_NOT_CREATE_DIRENT 41 -// Directory Error Codes -50 + -#define FF_ERR_DIR_OBJECT_EXISTS -50 ///< A file or folder of the same name already exists in the current directory. -#define FF_ERR_DIR_DIRECTORY_FULL -51 ///< No more items could be added to the directory. -#define FF_ERR_DIR_END_OF_DIR -52 /// -#define FF_ERR_DIR_NOT_EMPTY -53 ///< Cannot delete a directory that contains files or folders. -#define FF_ERR_DIR_INVALID_PATH -54 ///< Could not find the directory specified by the path. -#define FF_ERR_DIR_CANT_EXTEND_ROOT_DIR -55 ///< Can't extend the root dir. +// Directory Error Codes 50 + +#define FF_ERR_DIR_OBJECT_EXISTS 50 ///< A file or folder of the same name already exists in the current directory. +#define FF_ERR_DIR_DIRECTORY_FULL 51 ///< No more items could be added to the directory. +#define FF_ERR_DIR_END_OF_DIR 52 /// +#define FF_ERR_DIR_NOT_EMPTY 53 ///< Cannot delete a directory that contains files or folders. +#define FF_ERR_DIR_INVALID_PATH 54 ///< Could not find the directory specified by the path. +#define FF_ERR_DIR_CANT_EXTEND_ROOT_DIR 55 ///< Can't extend the root dir. +#define FF_ERR_DIR_EXTEND_FAILED 56 ///< Not enough space to extend the directory. +#define FF_ERR_DIR_NAME_TOO_LONG 57 ///< Name exceeds the number of allowed charachters for a filename. -// Fat Error Codes -70 + -#define FF_ERR_FAT_NO_FREE_CLUSTERS -70 ///< No more free space is available on the disk. +// Fat Error Codes 70 + +#define FF_ERR_FAT_NO_FREE_CLUSTERS 70 ///< No more free space is available on the disk. + +// UNICODE Error Codes 100 + +#define FF_ERR_UNICODE_INVALID_CODE 100 ///< An invalid Unicode charachter was provided! +#define FF_ERR_UNICODE_DEST_TOO_SMALL 101 ///< Not enough space in the UTF-16 buffer to encode the entire sequence as UTF-16. +#define FF_ERR_UNICODE_INVALID_SEQUENCE 102 ///< An invalid UTF-16 sequence was encountered. +#define FF_ERR_UNICODE_CONVERSION_EXCEEDED 103 ///< Filename exceeds MAX long-filename length when converted to UTF-16. #ifdef FF_DEBUG const FF_T_INT8 *FF_GetErrMessage(FF_ERROR iErrorCode); diff --git a/reactos/include/reactos/libs/fullfat/ff_fat.h b/reactos/include/reactos/libs/fullfat/ff_fat.h index 8add6d0132e..0ff784590ab 100644 --- a/reactos/include/reactos/libs/fullfat/ff_fat.h +++ b/reactos/include/reactos/libs/fullfat/ff_fat.h @@ -52,24 +52,23 @@ FF_T_UINT32 FF_getRealLBA (FF_IOMAN *pIoman, FF_T_UINT32 LBA); FF_T_UINT32 FF_Cluster2LBA (FF_IOMAN *pIoman, FF_T_UINT32 Cluster); FF_T_UINT32 FF_LBA2Cluster (FF_IOMAN *pIoman, FF_T_UINT32 Address); - FF_T_SINT32 FF_getFatEntry (FF_IOMAN *pIoman, FF_T_UINT32 nCluster); + FF_T_UINT32 FF_getFatEntry (FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_ERROR *pError); + FF_ERROR FF_putFatEntry (FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_T_UINT32 Value); FF_T_BOOL FF_isEndOfChain (FF_IOMAN *pIoman, FF_T_UINT32 fatEntry); - FF_T_SINT8 FF_putFatEntry (FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_T_UINT32 Value); - FF_T_UINT32 FF_FindFreeCluster (FF_IOMAN *pIoman); + FF_T_UINT32 FF_FindFreeCluster (FF_IOMAN *pIoman, FF_ERROR *pError); FF_T_UINT32 FF_ExtendClusterChain (FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_T_UINT32 Count); - FF_T_SINT8 FF_UnlinkClusterChain (FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_T_UINT16 Count); - FF_T_UINT32 FF_TraverseFAT (FF_IOMAN *pIoman, FF_T_UINT32 Start, FF_T_UINT32 Count); - FF_T_UINT32 FF_CreateClusterChain (FF_IOMAN *pIoman); - FF_T_UINT32 FF_GetChainLength (FF_IOMAN *pIoman, FF_T_UINT32 pa_nStartCluster, FF_T_UINT32 *piEndOfChain); - FF_T_UINT32 FF_FindEndOfChain (FF_IOMAN *pIoman, FF_T_UINT32 Start); - FF_T_SINT8 FF_ClearCluster (FF_IOMAN *pIoman, FF_T_UINT32 nCluster); + FF_ERROR FF_UnlinkClusterChain (FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_T_UINT16 Count); + FF_T_UINT32 FF_TraverseFAT (FF_IOMAN *pIoman, FF_T_UINT32 Start, FF_T_UINT32 Count, FF_ERROR *pError); + FF_T_UINT32 FF_CreateClusterChain (FF_IOMAN *pIoman, FF_ERROR *pError); + FF_T_UINT32 FF_GetChainLength (FF_IOMAN *pIoman, FF_T_UINT32 pa_nStartCluster, FF_T_UINT32 *piEndOfChain, FF_ERROR *pError); + FF_T_UINT32 FF_FindEndOfChain (FF_IOMAN *pIoman, FF_T_UINT32 Start, FF_ERROR *pError); + FF_ERROR FF_ClearCluster (FF_IOMAN *pIoman, FF_T_UINT32 nCluster); #ifdef FF_64_NUM_SUPPORT - FF_T_UINT64 FF_GetFreeSize (FF_IOMAN *pIoman); + FF_T_UINT64 FF_GetFreeSize (FF_IOMAN *pIoman, FF_ERROR *pError); #else - FF_T_UINT32 FF_GetFreeSize (FF_IOMAN *pIoman); + FF_T_UINT32 FF_GetFreeSize (FF_IOMAN *pIoman, FF_ERROR *pError); #endif - FF_T_UINT32 FF_FindFreeCluster (FF_IOMAN *pIoman); - FF_T_UINT32 FF_CountFreeClusters (FF_IOMAN *pIoman); + FF_T_UINT32 FF_CountFreeClusters (FF_IOMAN *pIoman, FF_ERROR *pError); // WARNING: If this protoype changes, it must be updated in ff_ioman.c also! void FF_lockFAT (FF_IOMAN *pIoman); void FF_unlockFAT (FF_IOMAN *pIoman); diff --git a/reactos/include/reactos/libs/fullfat/ff_fatdef.h b/reactos/include/reactos/libs/fullfat/ff_fatdef.h index 7fd7c3c5f6f..8e86d138a6d 100644 --- a/reactos/include/reactos/libs/fullfat/ff_fatdef.h +++ b/reactos/include/reactos/libs/fullfat/ff_fatdef.h @@ -86,5 +86,20 @@ #define FF_FAT_ATTR_ARCHIVE 0x20 #define FF_FAT_ATTR_LFN 0x0F +/** + * -- Hein_Tibosch additions for mixed case in shortnames -- + * + * Specifically, bit 4 means lowercase extension and bit 3 lowercase basename, + * which allows for combinations such as "example.TXT" or "HELLO.txt" but not "Mixed.txt" + */ + +#define FF_FAT_CASE_OFFS 0x0C ///< After NT/XP : 2 case bits +#define FF_FAT_CASE_ATTR_BASE 0x08 +#define FF_FAT_CASE_ATTR_EXT 0x10 + +#if defined(FF_LFN_SUPPORT) && defined(FF_INCLUDE_SHORT_NAME) +#define FF_FAT_ATTR_IS_LFN 0x40 ///< artificial attribute, for debugging only +#endif + #endif diff --git a/reactos/include/reactos/libs/fullfat/ff_file.h b/reactos/include/reactos/libs/fullfat/ff_file.h index e74d4a6a6ed..ac5528e38c7 100644 --- a/reactos/include/reactos/libs/fullfat/ff_file.h +++ b/reactos/include/reactos/libs/fullfat/ff_file.h @@ -75,19 +75,29 @@ typedef struct _FF_FILE { //---------- PROTOTYPES // PUBLIC (Interfaces): -FF_FILE *FF_Open (FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ERROR *pError); +#ifdef FF_UNICODE_SUPPORT +FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_WCHAR *path, FF_T_UINT8 Mode, FF_ERROR *pError); +FF_T_BOOL FF_isDirEmpty (FF_IOMAN *pIoman, const FF_T_WCHAR *Path); +FF_ERROR FF_RmFile (FF_IOMAN *pIoman, const FF_T_WCHAR *path); +FF_ERROR FF_RmDir (FF_IOMAN *pIoman, const FF_T_WCHAR *path); +FF_ERROR FF_Move (FF_IOMAN *pIoman, const FF_T_WCHAR *szSourceFile, const FF_T_WCHAR *szDestinationFile); +#else +FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ERROR *pError); +FF_T_BOOL FF_isDirEmpty (FF_IOMAN *pIoman, const FF_T_INT8 *Path); +FF_ERROR FF_RmFile (FF_IOMAN *pIoman, const FF_T_INT8 *path); +FF_ERROR FF_RmDir (FF_IOMAN *pIoman, const FF_T_INT8 *path); +FF_ERROR FF_Move (FF_IOMAN *pIoman, const FF_T_INT8 *szSourceFile, const FF_T_INT8 *szDestinationFile); +#endif FF_ERROR FF_Close (FF_FILE *pFile); FF_T_SINT32 FF_GetC (FF_FILE *pFile); +FF_T_SINT32 FF_GetLine (FF_FILE *pFile, FF_T_INT8 *szLine, FF_T_UINT32 ulLimit); FF_T_SINT32 FF_Read (FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, FF_T_UINT8 *buffer); FF_T_SINT32 FF_Write (FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, FF_T_UINT8 *buffer); FF_T_BOOL FF_isEOF (FF_FILE *pFile); FF_ERROR FF_Seek (FF_FILE *pFile, FF_T_SINT32 Offset, FF_T_INT8 Origin); FF_T_SINT32 FF_PutC (FF_FILE *pFile, FF_T_UINT8 Value); FF_T_UINT32 FF_Tell (FF_FILE *pFile); -FF_ERROR FF_RmFile (FF_IOMAN *pIoman, const FF_T_INT8 *path); -FF_ERROR FF_RmDir (FF_IOMAN *pIoman, const FF_T_INT8 *path); -FF_T_BOOL FF_isDirEmpty (FF_IOMAN *pIoman, const FF_T_INT8 *Path); -FF_ERROR FF_Move (FF_IOMAN *pIoman, const FF_T_INT8 *szSourceFile, const FF_T_INT8 *szDestinationFile); + FF_T_UINT8 FF_GetModeBits (FF_T_INT8 *Mode); // Private : diff --git a/reactos/include/reactos/libs/fullfat/ff_format.h b/reactos/include/reactos/libs/fullfat/ff_format.h new file mode 100644 index 00000000000..d7c53e58a9f --- /dev/null +++ b/reactos/include/reactos/libs/fullfat/ff_format.h @@ -0,0 +1,47 @@ +/***************************************************************************** + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * + * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + * IMPORTANT NOTICE: * + * ================= * + * Alternative Licensing is available directly from the Copyright holder, * + * (James Walmsley). For more information consult LICENSING.TXT to obtain * + * a Commercial license. * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * Removing the above notice is illegal and will invalidate this license. * + ***************************************************************************** + * See http://worm.me.uk/fullfat for more information. * + * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + *****************************************************************************/ + +/** + * @file ff_format.c + * @author James Walmsley + * @ingroup FORMAT + * + **/ + + +#ifndef _FF_FORMAT_H_ +#define _FF_FORMAT_H_ + + + + + +#endif diff --git a/reactos/include/reactos/libs/fullfat/ff_ioman.h b/reactos/include/reactos/libs/fullfat/ff_ioman.h index d59c10593cd..92d62ebd85d 100644 --- a/reactos/include/reactos/libs/fullfat/ff_ioman.h +++ b/reactos/include/reactos/libs/fullfat/ff_ioman.h @@ -87,8 +87,8 @@ typedef FF_T_SINT32 (*FF_READ_BLOCKS) (FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAd * @brief Describes the block device driver interface to FullFAT. **/ typedef struct { - FF_WRITE_BLOCKS fnWriteBlocks; ///< Function Pointer, to write a block(s) from a block device. - FF_READ_BLOCKS fnReadBlocks; ///< Function Pointer, to read a block(s) from a block device. + FF_WRITE_BLOCKS fnpWriteBlocks; ///< Function Pointer, to write a block(s) from a block device. + FF_READ_BLOCKS fnpReadBlocks; ///< Function Pointer, to read a block(s) from a block device. FF_T_UINT16 devBlkSize; ///< Block size that the driver deals with. void *pParam; ///< Pointer to some parameters e.g. for a Low-Level Driver Handle } FF_BLK_DEVICE; @@ -110,14 +110,23 @@ typedef struct { } FF_BUFFER; typedef struct { +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR Path[FF_MAX_PATH]; +#else FF_T_INT8 Path[FF_MAX_PATH]; - FF_T_UINT32 DirCluster; -#ifdef FF_HASH_TABLE_SUPPORT - FF_HASH_TABLE pHashTable; - FF_T_BOOL bHashed; #endif + FF_T_UINT32 DirCluster; } FF_PATHCACHE; +#ifdef FF_HASH_CACHE +typedef struct { + FF_T_UINT32 ulDirCluster; ///< The Starting Cluster of the dir that the hash represents. + FF_HASH_TABLE pHashTable; ///< Pointer to the Hash Table object. + FF_T_UINT32 ulNumHandles; ///< Number of active Handles using this hash table. + FF_T_UINT32 ulMisses; ///< Number of times this Hash Table was missed, (i.e. how redundant it is). +} FF_HASHCACHE; +#endif + /** * @private * @brief FullFAT identifies a partition with the following data. @@ -183,6 +192,9 @@ typedef struct { FF_PARTITION *pPartition; ///< Pointer to a partition description. FF_BUFFER *pBuffers; ///< Pointer to the first buffer description. void *pSemaphore; ///< Pointer to a Semaphore object. (For buffer description modifications only!). +#ifdef FF_BLKDEV_USES_SEM + void *pBlkDevSemaphore; ///< Semaphore to guarantee Atomic access to the underlying block device, if required. +#endif void *FirstFile; ///< Pointer to the first File object. FF_T_UINT8 *pCacheMem; ///< Pointer to a block of memory for the cache. FF_T_UINT32 LastReplaced; ///< Marks which sector was last replaced in the cache. @@ -191,6 +203,9 @@ typedef struct { FF_T_UINT8 PreventFlush; ///< Flushing to disk only allowed when 0 FF_T_UINT8 MemAllocation; ///< Bit-Mask identifying allocated pointers. FF_T_UINT8 Locks; ///< Lock Flag for FAT & DIR Locking etc (This must be accessed via a semaphore). +#ifdef FF_HASH_CACHE + FF_HASHCACHE HashCache[FF_HASH_CACHE_DEPTH]; +#endif } FF_IOMAN; // Bit-Masks for Memory Allocation testing. @@ -220,6 +235,8 @@ FF_T_UINT32 FF_GetVolumeSize(FF_IOMAN *pIoman); #endif // PUBLIC (To FullFAT Only): +FF_T_SINT32 FF_BlockRead (FF_IOMAN *pIoman, FF_T_UINT32 ulSectorLBA, FF_T_UINT32 ulNumSectors, void *pBuffer); +FF_T_SINT32 FF_BlockWrite (FF_IOMAN *pIoman, FF_T_UINT32 ulSectorLBA, FF_T_UINT32 ulNumSectors, void *pBuffer); FF_ERROR FF_IncreaseFreeClusters (FF_IOMAN *pIoman, FF_T_UINT32 Count); FF_ERROR FF_DecreaseFreeClusters (FF_IOMAN *pIoman, FF_T_UINT32 Count); FF_BUFFER *FF_GetBuffer (FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_UINT8 Mode); diff --git a/reactos/include/reactos/libs/fullfat/ff_memory.h b/reactos/include/reactos/libs/fullfat/ff_memory.h index 555a829210a..03ae55a77a3 100644 --- a/reactos/include/reactos/libs/fullfat/ff_memory.h +++ b/reactos/include/reactos/libs/fullfat/ff_memory.h @@ -76,7 +76,7 @@ typedef struct { #else -#error Little or Big Endian? +#error Little or Big Endian? - Please set an endianess in ff_config.h #endif diff --git a/reactos/include/reactos/libs/fullfat/ff_string.h b/reactos/include/reactos/libs/fullfat/ff_string.h index e3789102e4b..a5e85955da4 100644 --- a/reactos/include/reactos/libs/fullfat/ff_string.h +++ b/reactos/include/reactos/libs/fullfat/ff_string.h @@ -44,11 +44,37 @@ #define _FF_STRING_H_ #include "ff_types.h" +#include "ff_config.h" +#include -void FF_tolower (FF_T_INT8 *string, FF_T_UINT32 strLen); -void FF_toupper (FF_T_INT8 *string, FF_T_UINT32 strLen); -FF_T_BOOL FF_strmatch (const FF_T_INT8 *str1, const FF_T_INT8 *str2, FF_T_UINT16 len); -FF_T_INT8 *FF_strtok (const FF_T_INT8 *string, FF_T_INT8 *token, FF_T_UINT16 *tokenNumber, FF_T_BOOL *last, FF_T_UINT16 Length); -FF_T_BOOL FF_wildcompare(const FF_T_INT8 *pszWildCard, const FF_T_INT8 *pszString); +#ifdef WIN32 +#define stricmp stricmp +#define FF_stricmp stricmp +#else +#define strcasecmp strcasecmp +#define FF_stricmp strcasecmp +#endif + +#ifdef FF_UNICODE_SUPPORT +void FF_tolower (FF_T_WCHAR *string, FF_T_UINT32 strLen); +void FF_toupper (FF_T_WCHAR *string, FF_T_UINT32 strLen); +FF_T_BOOL FF_strmatch (const FF_T_WCHAR *str1, const FF_T_WCHAR *str2, FF_T_UINT16 len); +FF_T_WCHAR *FF_strtok (const FF_T_WCHAR *string, FF_T_WCHAR *token, FF_T_UINT16 *tokenNumber, FF_T_BOOL *last, FF_T_UINT16 Length); +FF_T_BOOL FF_wildcompare (const FF_T_WCHAR *pszWildCard, const FF_T_WCHAR *pszString); + +// ASCII to UTF16 and UTF16 to ASCII routines. -- These are lossy routines, and are only for converting ASCII to UTF-16 +// and the equivalent back to ASCII. Do not use them for international text. +void FF_cstrtowcs(FF_T_WCHAR *wcsDest, const FF_T_INT8 *szpSource); +void FF_wcstocstr(FF_T_INT8 *szpDest, const FF_T_WCHAR *wcsSource); +void FF_cstrntowcs(FF_T_WCHAR *wcsDest, const FF_T_INT8 *szpSource, FF_T_UINT32 len); +void FF_wcsntocstr(FF_T_INT8 *szpDest, const FF_T_WCHAR *wcsSource, FF_T_UINT32 len); + +#else +void FF_tolower (FF_T_INT8 *string, FF_T_UINT32 strLen); +void FF_toupper (FF_T_INT8 *string, FF_T_UINT32 strLen); +FF_T_BOOL FF_strmatch (const FF_T_INT8 *str1, const FF_T_INT8 *str2, FF_T_UINT16 len); +FF_T_INT8 *FF_strtok (const FF_T_INT8 *string, FF_T_INT8 *token, FF_T_UINT16 *tokenNumber, FF_T_BOOL *last, FF_T_UINT16 Length); +FF_T_BOOL FF_wildcompare (const FF_T_INT8 *pszWildCard, const FF_T_INT8 *pszString); +#endif #endif diff --git a/reactos/include/reactos/libs/fullfat/ff_types.h b/reactos/include/reactos/libs/fullfat/ff_types.h index 59a599670a3..0a3d5c280f1 100644 --- a/reactos/include/reactos/libs/fullfat/ff_types.h +++ b/reactos/include/reactos/libs/fullfat/ff_types.h @@ -61,6 +61,11 @@ typedef long FF_T_INT32; ///< 32 bit default integer. typedef unsigned long FF_T_UINT32; ///< 32 bit unsigned integer. typedef signed long FF_T_SINT32; ///< 32 bit signed integer. +//---------------- Platform Integer Sizes +typedef int FF_T_INT; +typedef unsigned int FF_T_UINT; +typedef signed int FF_T_SINT; + #ifdef FF_64_NUM_SUPPORT //---------------- 64 BIT INTEGERS // If you cannot define these, then make sure you see ff_config.h typedef long long FF_T_INT64; // about 64-bit number support. @@ -70,5 +75,9 @@ typedef signed long long FF_T_SINT64; // > 4GB in bytes if you cannot support 64 #endif typedef FF_T_SINT32 FF_ERROR; ///< A special error code type to ease some inconsistencies in Error reporting. +#ifdef FF_UNICODE_SUPPORT +#include +typedef wchar_t FF_T_WCHAR; ///< Unicode UTF-16 Charachter type, for FullFAT when UNICODE is enabled. +#endif #endif // end of include guard diff --git a/reactos/include/reactos/libs/fullfat/ff_unicode.h b/reactos/include/reactos/libs/fullfat/ff_unicode.h new file mode 100644 index 00000000000..9f0cbecb4cd --- /dev/null +++ b/reactos/include/reactos/libs/fullfat/ff_unicode.h @@ -0,0 +1,60 @@ +/***************************************************************************** + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * + * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + * IMPORTANT NOTICE: * + * ================= * + * Alternative Licensing is available directly from the Copyright holder, * + * (James Walmsley). For more information consult LICENSING.TXT to obtain * + * a Commercial license. * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * Removing the above notice is illegal and will invalidate this license. * + ***************************************************************************** + * See http://worm.me.uk/fullfat for more information. * + * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + *****************************************************************************/ + +/** + * @file ff_unicode.c + * @author James Walmsley + * @ingroup UNICODE + * + **/ + +#ifndef _FF_UNICODE_H_ +#define _FF_UNICODE_H_ + +#include "ff_config.h" +#include "ff_types.h" +#include "ff_error.h" + +// UTF8 / UTF16 Transformation Functions + +FF_T_UINT FF_GetUtf16SequenceLen (FF_T_UINT16 usLeadChar); +FF_T_SINT32 FF_Utf8ctoUtf16c (FF_T_UINT16 *utf16Dest, const FF_T_UINT8 *utf8Source, FF_T_UINT32 ulSize); +FF_T_SINT32 FF_Utf16ctoUtf8c (FF_T_UINT8 *utf8Dest, const FF_T_UINT16 *utf16Source, FF_T_UINT32 ulSize); + +// UTF16 / UTF32 Transformation Functions + +FF_T_SINT32 FF_Utf16ctoUtf32c(FF_T_UINT32 *utf32Dest, const FF_T_UINT16 *utf16Source); +FF_T_SINT32 FF_Utf32ctoUtf16c(FF_T_UINT16 *utf16Dest, FF_T_UINT32 utf32char, FF_T_UINT32 ulSize); + +// String transformations +FF_T_SINT32 FF_Utf32stoUtf8s(FF_T_UINT8 *Utf8String, FF_T_UINT32 *Utf32String); + +#endif diff --git a/reactos/include/reactos/libs/fullfat/fullfat.h b/reactos/include/reactos/libs/fullfat/fullfat.h index e4e8363e432..18aa2bb2549 100644 --- a/reactos/include/reactos/libs/fullfat/fullfat.h +++ b/reactos/include/reactos/libs/fullfat/fullfat.h @@ -45,6 +45,7 @@ extern "C" { #include "ff_crc.h" #include "ff_hash.h" #include "ff_string.h" +#include "ff_unicode.h" //#include "ff_format.h" #ifdef __cplusplus diff --git a/reactos/lib/3rdparty/fullfat/ff_crc.c b/reactos/lib/3rdparty/fullfat/ff_crc.c index 9c6ea469334..2b6f76ba5a2 100644 --- a/reactos/lib/3rdparty/fullfat/ff_crc.c +++ b/reactos/lib/3rdparty/fullfat/ff_crc.c @@ -41,7 +41,68 @@ #include "ff_crc.h" -static const FF_T_UINT8 CRC16_Low[256] = + +static const FF_T_UINT32 crc32_table[256] = { + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, + 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, + 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, + 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, + 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, + 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, + 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, + 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, + 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, + 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, + 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, + 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, + 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, + 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, + 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, + 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, + 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, + 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, + 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, + 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, + 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, + 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D +}; + +FF_T_UINT32 FF_GetCRC32(FF_T_UINT8 *pbyData, FF_T_UINT32 stLength) { + + register FF_T_UINT32 crc = 0xFFFFFFFF; + + while(stLength--) { + crc = ((crc >> 8) & 0x00FFFFFF) ^ crc32_table[(crc^*pbyData++) & 0x000000FF]; + } + + return (crc ^ 0xFFFFFFFF); +} + + + + +static const FF_T_UINT8 crc16_table_low[256] = { 0x000, 0x0c1, 0x081, 0x040, 0x001, 0x0c0, 0x080, 0x041, 0x001, 0x0c0, 0x080, 0x041, 0x000, 0x0c1, 0x081, 0x040, @@ -77,7 +138,7 @@ static const FF_T_UINT8 CRC16_Low[256] = 0x001, 0x0c0, 0x080, 0x041, 0x000, 0x0c1, 0x081, 0x040, }; -static const FF_T_UINT8 CRC16_High[256] = +static const FF_T_UINT8 crc16_table_high[256] = { 0x000, 0x0c0, 0x0c1, 0x001, 0x0c3, 0x003, 0x002, 0x0c2, 0x0c6, 0x006, 0x007, 0x0c7, 0x005, 0x0c5, 0x0c4, 0x004, @@ -130,15 +191,15 @@ FF_T_UINT16 FF_GetCRC16(FF_T_UINT8 *pbyData, FF_T_UINT32 stLength) { while (stLength--) { bTableValue = (FF_T_UINT8)((wCRC & 0x00FF) ^ *pbyData++); - wCRC = (FF_T_UINT16)(((CRC16_High[bTableValue]) << 8) - + (CRC16_Low[bTableValue] ^ ((wCRC >> 8) & 0x00FF))); + wCRC = (FF_T_UINT16)(((crc16_table_high[bTableValue]) << 8) + + (crc16_table_low[bTableValue] ^ ((wCRC >> 8) & 0x00FF))); } return wCRC; } -static const FF_T_UINT8 byCRCLookUpTable[256] = +static const FF_T_UINT8 crc8_table[256] = { 0, 94, 188, 226, 97, 63, 221, 131, 194, 156, 126, 32, 163, 253, 31, 65, @@ -188,7 +249,7 @@ FF_T_UINT8 FF_GetCRC8(FF_T_UINT8 *pbyData, FF_T_UINT32 stLength) { FF_T_UINT8 byCRC = 0, byData; while (stLength--) { byData = *pbyData++; - byCRC = byCRCLookUpTable[(byCRC ^ byData)]; + byCRC = crc8_table[(byCRC ^ byData)]; } return byCRC; } diff --git a/reactos/lib/3rdparty/fullfat/ff_dir.c b/reactos/lib/3rdparty/fullfat/ff_dir.c index f35d91c02e6..f34c18ecbab 100644 --- a/reactos/lib/3rdparty/fullfat/ff_dir.c +++ b/reactos/lib/3rdparty/fullfat/ff_dir.c @@ -42,16 +42,44 @@ #include "ff_dir.h" #include "ff_string.h" +#include "ff_unicode.h" #include + +#ifdef FF_UNICODE_SUPPORT +#include +#endif + +#ifdef WIN32 +#else +#include // tolower() +int strcasecmp(const char *s1, const char *s2) +{ + unsigned char c1,c2; + do { + c1 = *s1++; + c2 = *s2++; + c1 = (unsigned char) tolower( (unsigned char) c1); + c2 = (unsigned char) tolower( (unsigned char) c2); + } + while((c1 == c2) && (c1 != '\0')); + return (int) c1-c2; +} +#endif + + +#ifdef FF_UNICODE_SUPPORT +static void FF_ProcessShortName(FF_T_WCHAR *name); +#else static void FF_ProcessShortName(FF_T_INT8 *name); +#endif void FF_lockDIR(FF_IOMAN *pIoman) { - FF_PendSemaphore(pIoman->pSemaphore); // Use Semaphore to protect FAT modifications. + FF_PendSemaphore(pIoman->pSemaphore); // Use Semaphore to protect DIR modifications. { while((pIoman->Locks & FF_DIR_LOCK)) { FF_ReleaseSemaphore(pIoman->pSemaphore); - FF_Yield(); // Keep Releasing and Yielding until we have the Fat protector. + FF_Yield(); // Keep Releasing and Yielding until we have the DIR protector. FF_PendSemaphore(pIoman->pSemaphore); } pIoman->Locks |= FF_DIR_LOCK; @@ -77,24 +105,28 @@ static FF_T_UINT8 FF_CreateChkSum(const FF_T_UINT8 *pa_pShortName) { return ChkSum; } -FF_T_SINT8 FF_FindNextInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent) { + +FF_ERROR FF_FindNextInDir(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_FETCH_CONTEXT *pFetchContext) { - FF_T_UINT8 numLFNs; - FF_T_UINT8 EntryBuffer[32]; + FF_T_UINT8 numLFNs; + FF_T_UINT8 EntryBuffer[32]; + FF_ERROR Error; if(!pIoman) { return FF_ERR_NULL_POINTER; } - //pDirent->NumLFNs = 0; - for(; pDirent->CurrentItem < 0xFFFF; pDirent->CurrentItem += 1) { - if(FF_FetchEntry(pIoman, DirCluster, pDirent->CurrentItem, EntryBuffer)) { - return -2; + + Error = FF_FetchEntryWithContext(pIoman, pDirent->CurrentItem, pFetchContext, EntryBuffer); + + if(Error) { + return Error; } + if(EntryBuffer[0] != 0xE5) { if(FF_isEndOfDir(EntryBuffer)){ - return -2; + return FF_ERR_DIR_END_OF_DIR; } pDirent->Attrib = FF_getChar(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_ATTRIB)); if((pDirent->Attrib & FF_FAT_ATTR_LFN) == FF_FAT_ATTR_LFN) { @@ -102,8 +134,11 @@ FF_T_SINT8 FF_FindNextInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT numLFNs = (FF_T_UINT8)(EntryBuffer[0] & ~0x40); //pDirent->NumLFNs = numLFNs; #ifdef FF_LFN_SUPPORT - FF_PopulateLongDirent(pIoman, pDirent, DirCluster, pDirent->CurrentItem); - return 0; + Error = FF_PopulateLongDirent(pIoman, pDirent, pDirent->CurrentItem, pFetchContext); + if(Error) { + return Error; + } + return FF_ERR_NONE; #else pDirent->CurrentItem += (numLFNs - 1); #endif @@ -113,421 +148,307 @@ FF_T_SINT8 FF_FindNextInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT } else { FF_PopulateShortDirent(pIoman, pDirent, EntryBuffer); pDirent->CurrentItem += 1; - return 0; + return FF_ERR_NONE; } } } - return -1; + return FF_ERR_DIR_END_OF_DIR; } -/* -FF_T_BOOL FF_ShortNameExists(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *name) { - FF_DIRENT MyDir; +#ifdef FF_UNICODE_SUPPORT +static FF_T_BOOL FF_ShortNameExists(FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster, FF_T_WCHAR *szShortName, FF_ERROR *pError) { +#else +static FF_T_BOOL FF_ShortNameExists(FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster, FF_T_INT8 *szShortName, FF_ERROR *pError) { +#endif - if(FF_FindEntry(pIoman, DirCluster, name, &MyDir, FF_FALSE)) { - return FF_FALSE; - } + FF_T_UINT16 i; + FF_T_UINT8 EntryBuffer[32]; + FF_T_UINT8 Attrib; + FF_FETCH_CONTEXT FetchContext; + +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR UTF16EntryBuffer[32]; +#endif - return FF_TRUE; -}*/ +#ifdef FF_HASH_CACHE + FF_T_UINT32 ulHash; +#endif -FF_T_BOOL FF_ShortNameExists(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *name) { + *pError = FF_ERR_NONE; - FF_T_UINT16 i; - FF_T_UINT8 EntryBuffer[32]; - FF_T_UINT8 Attrib; -#ifdef FF_HASH_TABLE_SUPPORT - - if(!FF_DirHashed(pIoman, DirCluster)) { - for(i = 0; i < 0xFFFF; i++) { - if(FF_FetchEntry(pIoman, DirCluster, i, EntryBuffer)) { - FF_SetDirHashed(pIoman, DirCluster); - break; - } - Attrib = FF_getChar(EntryBuffer, FF_FAT_DIRENT_ATTRIB); - if(FF_getChar(EntryBuffer, 0x00) != 0xE5) { - if(Attrib != FF_FAT_ATTR_LFN) { - if(FF_isEndOfDir(EntryBuffer)) { - FF_SetDirHashed(pIoman, DirCluster); - break; - } - FF_ProcessShortName((FF_T_INT8 *)EntryBuffer); - FF_AddDirentHash(pIoman, DirCluster, FF_GetCRC16((FF_T_UINT8 *) EntryBuffer, strlen(EntryBuffer))); - } - } - } - } +#ifdef FF_HASH_CACHE + if(!FF_DirHashed(pIoman, ulDirCluster)) { + // Hash the directory + FF_HashDir(pIoman, ulDirCluster); + } #if FF_HASH_FUNCTION == CRC16 - if(FF_CheckDirentHash(pIoman, DirCluster, (FF_T_UINT32)FF_GetCRC16((FF_T_UINT8 *) name, strlen(name)))) { + ulHash = (FF_T_UINT32) FF_GetCRC16((FF_T_UINT8 *) szShortName, strlen(szShortName)); #elif FF_HASH_FUNCTION == CRC8 - if(FF_CheckDirentHash(pIoman, DirCluster, (FF_T_UINT32)FF_GetCRC8((FF_T_UINT8 *) name, strlen(name)))) { + ulHash = (FF_T_UINT32) FF_GetCRC8((FF_T_UINT8 *) szShortName, strlen(szShortName)); +#endif + + if(!FF_CheckDirentHash(pIoman, ulDirCluster, ulHash)) { + return FF_FALSE; + } + +#endif + + *pError = FF_InitEntryFetch(pIoman, ulDirCluster, &FetchContext); + if(*pError) { + return FF_FALSE; + } + + for(i = 0; i < 0xFFFF; i++) { + *pError = FF_FetchEntryWithContext(pIoman, i, &FetchContext, EntryBuffer); + if(*pError) { + FF_CleanupEntryFetch(pIoman, &FetchContext); + return FF_FALSE; + } + Attrib = FF_getChar(EntryBuffer, FF_FAT_DIRENT_ATTRIB); + if(FF_getChar(EntryBuffer, 0x00) != 0xE5) { + if(Attrib != FF_FAT_ATTR_LFN) { +#ifdef FF_UNICODE_SUPPORT + // Convert Entry Buffer into UTF16 + FF_cstrntowcs(UTF16EntryBuffer, (FF_T_INT8 *) EntryBuffer, 32); + FF_ProcessShortName(UTF16EntryBuffer); #else - { + FF_ProcessShortName((FF_T_INT8 *)EntryBuffer); #endif + if(FF_isEndOfDir(EntryBuffer)) { + FF_CleanupEntryFetch(pIoman, &FetchContext); + return FF_FALSE; + } +#ifdef FF_UNICODE_SUPPORT + if(wcscmp(szShortName, UTF16EntryBuffer) == 0) { +#else + if(strcmp(szShortName, (FF_T_INT8 *)EntryBuffer) == 0) { #endif - - for(i = 0; i < 0xFFFF; i++) { - FF_FetchEntry(pIoman, DirCluster, i, EntryBuffer); - Attrib = FF_getChar(EntryBuffer, FF_FAT_DIRENT_ATTRIB); - if(FF_getChar(EntryBuffer, 0x00) != 0xE5) { - if(Attrib != FF_FAT_ATTR_LFN) { - FF_ProcessShortName((FF_T_INT8 *)EntryBuffer); - if(FF_isEndOfDir(EntryBuffer)) { - return FF_FALSE; - } - if(strcmp(name, (FF_T_INT8 *)EntryBuffer) == 0) { - return FF_TRUE; - } - } + FF_CleanupEntryFetch(pIoman, &FetchContext); + return FF_TRUE; } } -#ifdef FF_HASH_TABLE_SUPPORT } -#endif - - return FF_FALSE; + } + + FF_CleanupEntryFetch(pIoman, &FetchContext); + return FF_FALSE; } -FF_T_UINT32 FF_FindEntryInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent) { - FF_T_UINT16 fnameLen; - FF_T_UINT16 compareLength; - FF_T_UINT16 nameLen; - FF_T_INT8 Filename[FF_MAX_FILENAME]; - FF_T_INT8 MyFname[FF_MAX_FILENAME]; - FF_T_BOOL bBreak = FF_FALSE; - - pDirent->CurrentItem = 0; - nameLen = (FF_T_UINT16) strlen(name); +#ifdef FF_UNICODE_SUPPORT +FF_T_UINT32 FF_FindEntryInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, const FF_T_WCHAR *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent, FF_ERROR *pError) { +#else +FF_T_UINT32 FF_FindEntryInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, const FF_T_INT8 *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent, FF_ERROR *pError) { +#endif - while(!bBreak) { - if(FF_FindNextInDir(pIoman, DirCluster, pDirent)) { - break; // end of dir, file not found! - } - - if((pDirent->Attrib & pa_Attrib) == pa_Attrib){ - strcpy(Filename, pDirent->FileName); - fnameLen = (FF_T_UINT16) strlen(Filename); - FF_tolower(Filename, (FF_T_UINT32) fnameLen); - if(nameLen < FF_MAX_FILENAME) { - memcpy(MyFname, name, nameLen + 1); - } else { - memcpy(MyFname, name, FF_MAX_FILENAME); - MyFname[FF_MAX_FILENAME - 1] = '\0'; - } - FF_tolower(MyFname, (FF_T_UINT32) nameLen); - if(nameLen > fnameLen) { - compareLength = nameLen; - } else { - compareLength = fnameLen; - } - if(strncmp(MyFname, Filename, (FF_T_UINT32) compareLength) == 0) { - // Object found! - return pDirent->ObjectCluster; // Return the cluster number - } - } - } - - return 0; -} - -/* -#define FF_DIR_LFN_TRAVERSED 0x01 -#define FF_DIR_LFN_DELETED 0x02 - -FF_T_SINT8 FF_PopulateLongBufEntry(FF_IOMAN *pIoman, FF_BUFFER **ppBuffer, FF_DIRENT *pDirent) { - // Relative positions! - FF_T_UINT32 RelBlockNum; - FF_T_UINT32 RelBlockPos = FF_getMinorBlockEntry(pIoman, pDirent->CurrentItem, 32); - FF_T_UINT32 iItemLBA; - FF_T_INT8 *DirBuffer = ((*ppBuffer)->pBuffer + (RelBlockPos * 32)); - FF_T_UINT8 numLFNs = (FF_getChar(DirBuffer, (FF_T_UINT16) 0) & ~0x40); - FF_T_UINT16 x,i,y,myShort, lenlfn = 0; - FF_T_UINT32 CurrentCluster; - FF_T_SINT8 RetVal = FF_ERR_NONE; - FF_T_INT8 ShortName[13]; - FF_T_UINT8 CheckSum = FF_getChar(DirBuffer, FF_FAT_LFN_CHECKSUM); - - while(numLFNs > 0) { - - for(i = 0, y = 0; i < 5; i++, y += 2) { - pDirent->FileName[i + ((numLFNs - 1) * 13)] = DirBuffer[FF_FAT_LFN_NAME_1 + y]; - lenlfn++; - } - - for(i = 0, y = 0; i < 6; i++, y += 2) { - pDirent->FileName[i + ((numLFNs - 1) * 13) + 5] = DirBuffer[FF_FAT_LFN_NAME_2 + y]; - lenlfn++; - } - - for(i = 0, y = 0; i < 2; i++, y += 2) { - pDirent->FileName[i + ((numLFNs - 1) * 13) + 11] = DirBuffer[FF_FAT_LFN_NAME_3 + y]; - lenlfn++; - } - numLFNs--; - pDirent->CurrentItem += 1; - - CurrentCluster = FF_getClusterChainNumber(pIoman, pDirent->CurrentItem, 32); - RelBlockNum = FF_getMajorBlockNumber(pIoman, pDirent->CurrentItem, 32); - RelBlockPos = FF_getMinorBlockEntry(pIoman, pDirent->CurrentItem, 32); - iItemLBA = FF_Cluster2LBA(pIoman, pDirent->AddrCurrentCluster) + RelBlockNum; - - if(CurrentCluster > pDirent->CurrentCluster) { - pDirent->AddrCurrentCluster = FF_TraverseFAT(pIoman, pDirent->AddrCurrentCluster, 1); - pDirent->CurrentCluster += 1; - iItemLBA = FF_Cluster2LBA(pIoman, pDirent->AddrCurrentCluster) + RelBlockNum; - FF_ReleaseBuffer(pIoman, *ppBuffer); - *ppBuffer = FF_GetBuffer(pIoman, iItemLBA, FF_MODE_READ); - RetVal |= FF_DIR_LFN_TRAVERSED; - } else if(iItemLBA > ((*ppBuffer)->Sector)) { - FF_ReleaseBuffer(pIoman, *ppBuffer); - *ppBuffer = FF_GetBuffer(pIoman, iItemLBA, FF_MODE_READ); - RetVal |= FF_DIR_LFN_TRAVERSED; - } - - DirBuffer = ((*ppBuffer)->pBuffer + (RelBlockPos * 32)); - } - - if(FF_getChar(DirBuffer, (FF_T_UINT16) 0) == FF_FAT_DELETED) { - RetVal |= FF_DIR_LFN_DELETED; - return RetVal; - } - - pDirent->FileName[lenlfn] = '\0'; - - // Process the ShortName Entry - memcpy(ShortName, DirBuffer, 11); - if(CheckSum != FF_CreateChkSum(ShortName)) { - FF_ProcessShortName(ShortName); - strcpy(pDirent->FileName, ShortName); - } else { - FF_ProcessShortName(ShortName); - } - - myShort = FF_getShort(DirBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_CLUS_HIGH)); - pDirent->ObjectCluster = (FF_T_UINT32) (myShort << 16); - myShort = FF_getShort(DirBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_CLUS_LOW)); - pDirent->ObjectCluster |= myShort; - - // Get the filesize. - pDirent->Filesize = FF_getLong(DirBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_FILESIZE)); - // Get the attribute. - pDirent->Attrib = FF_getChar(DirBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_ATTRIB)); - - return RetVal; -}*/ - -/* -FF_T_SINT8 FF_FindEntry(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *Name, FF_DIRENT *pDirent, FF_T_BOOL LFNs) { - - FF_T_UINT32 iItemLBA; - FF_BUFFER *pBuffer; - FF_T_INT8 *DirBuffer; - FF_T_UINT32 fatEntry = DirCluster; - FF_T_UINT32 i,x; - FF_T_UINT32 numLFNs; - FF_T_UINT16 NameLen, DirentNameLen; - FF_T_BOOL Compare = FF_FALSE; - FF_T_SINT8 RetVal = 0; - FF_T_UINT16 RelEntry; + FF_FETCH_CONTEXT FetchContext; + FF_T_UINT8 *src; // Pointer to read from pBuffer + FF_T_UINT8 *lastSrc; +#ifdef FF_UNICODE_UTF8_SUPPORT + FF_T_SINT32 utf8Error; + FF_T_UINT8 bSurrogate = FF_FALSE; +#endif +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR *ptr; // Pointer to store a LFN +#else + FF_T_INT8 *ptr; // Pointer to store a LFN +#endif +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR *lastPtr = pDirent->FileName + sizeof(pDirent->FileName); +#else + FF_T_INT8 *lastPtr = pDirent->FileName + sizeof(pDirent->FileName); +#endif + FF_T_UINT8 CheckSum; + FF_T_UINT8 lastAttrib; + FF_T_INT8 totalLFNs = 0; + FF_T_INT8 numLFNs = 0; + FF_T_INT32 i; + FF_T_UINT16 lfnItem = 0; pDirent->CurrentItem = 0; - pDirent->AddrCurrentCluster = DirCluster; - pDirent->CurrentCluster = 0; - pDirent->DirCluster = DirCluster; + pDirent->Attrib = 0; - do { - - pDirent->AddrCurrentCluster = fatEntry; - iItemLBA = FF_Cluster2LBA(pIoman, pDirent->AddrCurrentCluster); + FF_InitEntryFetch(pIoman, DirCluster, &FetchContext); - for(i = 0; i < pIoman->pPartition->SectorsPerCluster; i++) { - - if(FF_getClusterChainNumber(pIoman, pDirent->CurrentItem, 32) > pDirent->CurrentCluster) { - break; - } - - pBuffer = FF_GetBuffer(pIoman, iItemLBA + i, FF_MODE_READ); - { - if(!pBuffer) { - return FF_ERR_DEVICE_DRIVER_FAILED; - } - pBuffer->Persistance = 1; - RelEntry = FF_getMinorBlockEntry(pIoman, pDirent->CurrentItem, 32); - for(x = RelEntry; x < (pIoman->BlkSize / 32); x++) { - if(FF_getMajorBlockNumber(pIoman, pDirent->CurrentItem, 32) > i) { - break; - } - if(FF_getClusterChainNumber(pIoman, pDirent->CurrentItem, 32) > pDirent->CurrentCluster) { - break; - } - RelEntry = FF_getMinorBlockEntry(pIoman, pDirent->CurrentItem, 32); - x = RelEntry; - if(x >= (pIoman->BlkSize / 32)) { - break; - } - DirBuffer = (pBuffer->pBuffer + (32 * x)); - // Process each entry and Compare to Name! - if(FF_getChar(DirBuffer, (FF_T_UINT16) 0) != FF_FAT_DELETED) { - if(DirBuffer[0] == 0x00) { - FF_ReleaseBuffer(pIoman, pBuffer); - return FF_ERR_DIR_END_OF_DIR; - } - pDirent->Attrib = FF_getChar(DirBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_ATTRIB)); - if((pDirent->Attrib & FF_FAT_ATTR_LFN) == FF_FAT_ATTR_LFN) { - numLFNs = (FF_T_UINT8)(DirBuffer[0] & ~0x40); - if(LFNs) { - RetVal = FF_PopulateLongBufEntry(pIoman, &pBuffer, pDirent); - if((RetVal & FF_DIR_LFN_DELETED)) { - Compare = FF_FALSE; - RetVal &= ~FF_DIR_LFN_DELETED; - } else { - Compare = FF_TRUE; - } - - pDirent->CurrentItem += 1; - } else { - pDirent->CurrentItem += numLFNs; - } - - } else { - FF_PopulateShortDirent(pDirent, DirBuffer); - Compare = FF_TRUE; - pDirent->CurrentItem += 1; - } - - if(Compare) { - // Compare the Items - NameLen = strlen(Name); - DirentNameLen = strlen(pDirent->FileName); - - if(NameLen == DirentNameLen) { // Names are same length, possible match. - if(FF_StrMatch(Name, pDirent->FileName, NameLen)) { - FF_ReleaseBuffer(pIoman, pBuffer); - return FF_ERR_NONE; // Success Item found! - } - } - Compare = FF_FALSE; - } - - if((RetVal & FF_DIR_LFN_TRAVERSED)) { - break; - } - - } else { - pDirent->CurrentItem += 1; - } - } - } - FF_ReleaseBuffer(pIoman, pBuffer); - if((RetVal & FF_DIR_LFN_TRAVERSED)) { - break; - } - } - - // Traverse! - - if((RetVal & FF_DIR_LFN_TRAVERSED)) { - RetVal = FF_ERR_NONE; - fatEntry = pDirent->AddrCurrentCluster; - } else { - if(FF_getClusterChainNumber(pIoman, pDirent->CurrentItem, 32) > pDirent->CurrentCluster) { - fatEntry = FF_getFatEntry(pIoman, pDirent->AddrCurrentCluster); - pDirent->AddrCurrentCluster = FF_TraverseFAT(pIoman, pDirent->AddrCurrentCluster, 1); - pDirent->CurrentCluster += 1; - } - } - } while(!FF_isEndOfChain(pIoman, fatEntry)); - - return FF_ERR_DIR_END_OF_DIR; -}*/ - - -/** - * @private - **/ -/*FF_T_UINT32 FF_FindEntry(FF_IOMAN *pIoman, FF_T_SINT8 *path, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent) { - - FF_T_INT32 retVal; - FF_T_INT8 name[FF_MAX_FILENAME]; - FF_T_INT8 Filename[FF_MAX_FILENAME]; - FF_T_UINT16 fnameLen; - FF_T_UINT16 compareLength; - FF_T_UINT16 nameLen; - FF_T_UINT16 i = strlen(path); - - - while(i != 0) { - if(path[i] == '\\' || path[i] == '/') { + while(pDirent->CurrentItem < 0xFFFF) { + if (FF_FetchEntryWithContext(pIoman, pDirent->CurrentItem, &FetchContext, NULL)) { break; } - i--; - } - - if(i == 0) { - i = 1; - } - - nameLen = strlen((path + i)); - strncpy(name, (path + i), nameLen); - name[nameLen] = '\0'; - - - if(FF_FindFirst(pIoman, pDirent, path)) { - return 0; // file not found. - } - - if((pDirent->Attrib & pa_Attrib) == pa_Attrib){ - strcpy(Filename, pDirent->FileName); - fnameLen = (FF_T_UINT16) strlen(Filename); - FF_tolower(Filename, (FF_T_UINT32) fnameLen); - FF_tolower(name, (FF_T_UINT32) nameLen); - if(nameLen > fnameLen) { - compareLength = nameLen; - } else { - compareLength = fnameLen; - } - if(strncmp(name, Filename, (FF_T_UINT32) compareLength) == 0) { - // Object found!! - return pDirent->ObjectCluster; // Return the cluster number - } - } - - while(1) { - if(FF_FindNext(pIoman, pDirent)) { - return 0; // end of dir, file not found! - } - - if((pDirent->Attrib & pa_Attrib) == pa_Attrib){ - strcpy(Filename, pDirent->FileName); - fnameLen = (FF_T_UINT16) strlen(Filename); - FF_tolower(Filename, (FF_T_UINT32) fnameLen); - FF_tolower(name, (FF_T_UINT32) nameLen); - if(nameLen > fnameLen) { - compareLength = nameLen; - } else { - compareLength = fnameLen; + lastSrc = FetchContext.pBuffer->pBuffer + pIoman->BlkSize; + for (src = FetchContext.pBuffer->pBuffer; src < lastSrc; src += 32, pDirent->CurrentItem++) { + if (FF_isEndOfDir(src)) { // 0x00: end-of-dir + FF_CleanupEntryFetch(pIoman, &FetchContext); + return 0; } - if(strncmp(name, Filename, (FF_T_UINT32) compareLength) == 0) { - // Object found! - return pDirent->ObjectCluster; // Return the cluster number + if (src[0] == 0xE5) { // Entry not used + pDirent->Attrib = 0; + continue; } + lastAttrib = pDirent->Attrib; + pDirent->Attrib = FF_getChar(src, FF_FAT_DIRENT_ATTRIB); + if((pDirent->Attrib & FF_FAT_ATTR_LFN) == FF_FAT_ATTR_LFN) { + // LFN Processing +#ifdef FF_LFN_SUPPORT + if (numLFNs == 0 || (lastAttrib & FF_FAT_ATTR_LFN) != FF_FAT_ATTR_LFN) { + totalLFNs = numLFNs = (FF_T_UINT8)(src[0] & ~0x40); + lfnItem = pDirent->CurrentItem; + CheckSum = FF_getChar(src, FF_FAT_LFN_CHECKSUM); + lastPtr[-1] = '\0'; + } + if (numLFNs) { + numLFNs--; + ptr = pDirent->FileName + (numLFNs * 13); + + /* + This section needs to extract the name and do the comparison + dependent on UNICODE settings in the ff_config.h file. + */ +#ifdef FF_UNICODE_SUPPORT + // Add UTF-16 Routine here + memcpy(ptr, &src[FF_FAT_LFN_NAME_1], 10); // Copy first 5 UTF-16 chars (10 bytes). + ptr += 5; // Increment Filename pointer 5 utf16 chars. + + memcpy(ptr, &src[FF_FAT_LFN_NAME_2], 12); //Copy next 6 chars (12 bytes). + ptr += 6; + + memcpy(ptr, &src[FF_FAT_LFN_NAME_3], 4); // You're getting the idea by now! + ptr += 2; + +#endif +#ifdef FF_UNICODE_UTF8_SUPPORT + // UTF-8 Routine here + for(i = 0; i < 5 && ptr < lastPtr; i++) { + // Was there a surrogate sequence? -- Add handling here. + utf8Error = FF_Utf16ctoUtf8c((FF_T_UINT8 *) ptr, (FF_T_UINT16 *) &src[FF_FAT_LFN_NAME_1 + (2*i)], lastPtr - ptr); + if(utf8Error > 0) { + ptr += utf8Error; + + } else { + if(utf8Error == FF_ERR_UNICODE_INVALID_SEQUENCE) { + // Handle potential surrogate sequence across entries. + + } + } + } + + for(i = 0; i < 6 && ptr < lastPtr; i++) { + // Was there a surrogate sequence? -- To add handling here. + utf8Error = FF_Utf16ctoUtf8c((FF_T_UINT8 *) ptr, (FF_T_UINT16 *) &src[FF_FAT_LFN_NAME_2 + (2*i)], lastPtr - ptr); + if(utf8Error > 0) { + ptr += utf8Error; + } else { + if(utf8Error == FF_ERR_UNICODE_INVALID_SEQUENCE) { + // Handle potential surrogate sequence across entries. + } + } + } + + for(i = 0; i < 2 && ptr < lastPtr; i++) { + // Was there a surrogate sequence? -- To add handling here. + utf8Error = FF_Utf16ctoUtf8c((FF_T_UINT8 *) ptr, (FF_T_UINT16 *) &src[FF_FAT_LFN_NAME_3 + (2*i)], lastPtr - ptr); + if(utf8Error > 0) { + ptr += utf8Error; + } else { + if(utf8Error == FF_ERR_UNICODE_INVALID_SEQUENCE) { + // Handle potential surrogate sequence across entries. + } + } + } + +#endif +#ifndef FF_UNICODE_SUPPORT +#ifndef FF_UNICODE_UTF8_SUPPORT + for(i = 0; i < 10 && ptr < lastPtr; i += 2) + *(ptr++) = src[FF_FAT_LFN_NAME_1 + i]; + + for(i = 0; i < 12 && ptr < lastPtr; i += 2) + *(ptr++) = src[FF_FAT_LFN_NAME_2 + i]; + + for(i = 0; i < 4 && ptr < lastPtr; i += 2) + *(ptr++) = src[FF_FAT_LFN_NAME_3 + i]; + + if (numLFNs == totalLFNs-1 && ptr < lastPtr) + *ptr = '\0'; // Important when name len is multiple of 13 +#endif +#endif + if (numLFNs == totalLFNs-1 && ptr < lastPtr) + *ptr = '\0'; // Important when name len is multiple of 13 + + } +#endif + continue; + } + if ((pDirent->Attrib & FF_FAT_ATTR_VOLID) == FF_FAT_ATTR_VOLID) { + totalLFNs = 0; + continue; + } +#ifdef FF_LFN_SUPPORT + if(!totalLFNs || CheckSum != FF_CreateChkSum(src)) +#endif + { +#ifdef FF_UNICODE_SUPPORT + for(i = 0; i < 11; i++) { + pDirent->FileName[i] = (FF_T_WCHAR) src[i]; + } + FF_ProcessShortName(pDirent->FileName); +#else + memcpy(pDirent->FileName, src, 11); + FF_ProcessShortName(pDirent->FileName); +#endif + totalLFNs = 0; + } + + if((pDirent->Attrib & pa_Attrib) == pa_Attrib){ +#ifdef FF_UNICODE_SUPPORT + if(!wcsicmp(name, pDirent->FileName)) { +#else + if (!FF_stricmp(name, pDirent->FileName)) { +#endif + // Finally get the complete information +#ifdef FF_LFN_SUPPORT + if (totalLFNs) { + FF_PopulateLongDirent(pIoman, pDirent, lfnItem, &FetchContext); + } else +#endif + { + FF_PopulateShortDirent(pIoman, pDirent, src); + } + // Object found! + FF_CleanupEntryFetch(pIoman, &FetchContext); + return pDirent->ObjectCluster; // Return the cluster number + } + } + totalLFNs = 0; } - } + } // for (src = FetchContext.pBuffer->pBuffer; src < lastSrc; src += 32, pDirent->CurrentItem++) + + FF_CleanupEntryFetch(pIoman, &FetchContext); + return 0; -}*/ +} + + /** * @private **/ - -FF_T_UINT32 FF_FindDir(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 pathLen) { +#ifdef FF_UNICODE_SUPPORT +FF_T_UINT32 FF_FindDir(FF_IOMAN *pIoman, const FF_T_WCHAR *path, FF_T_UINT16 pathLen, FF_ERROR *pError) { +#else +FF_T_UINT32 FF_FindDir(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 pathLen, FF_ERROR *pError) { +#endif FF_T_UINT32 dirCluster = pIoman->pPartition->RootDirCluster; - FF_T_INT8 mytoken[FF_MAX_FILENAME]; - FF_T_INT8 *token; +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR mytoken[FF_MAX_FILENAME]; + FF_T_WCHAR *token; +#else + FF_T_INT8 mytoken[FF_MAX_FILENAME]; + FF_T_INT8 *token; +#endif + FF_T_UINT16 it = 0; // Re-entrancy Variables for FF_strtok() FF_T_BOOL last = FF_FALSE; FF_DIRENT MyDir; @@ -535,7 +456,9 @@ FF_T_UINT32 FF_FindDir(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 path FF_T_UINT32 i; #endif - if(pathLen == 1) { // Must be the root dir! (/ or \) + *pError = FF_ERR_NONE; + + if(pathLen <= 1) { // Must be the root dir! (/ or \) return pIoman->pPartition->RootDirCluster; } @@ -547,8 +470,14 @@ FF_T_UINT32 FF_FindDir(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 path FF_PendSemaphore(pIoman->pSemaphore); // Thread safety on shared object! { for(i = 0; i < FF_PATH_CACHE_DEPTH; i++) { +#ifdef FF_UNICODE_SUPPORT + if(wcslen(pIoman->pPartition->PathCache[i].Path) == pathLen) { + if(FF_strmatch(pIoman->pPartition->PathCache[i].Path, path, pathLen)) { +#else if(strlen(pIoman->pPartition->PathCache[i].Path) == pathLen) { if(FF_strmatch(pIoman->pPartition->PathCache[i].Path, path, pathLen)) { +#endif + FF_ReleaseSemaphore(pIoman->pSemaphore); return pIoman->pPartition->PathCache[i].DirCluster; } @@ -561,9 +490,13 @@ FF_T_UINT32 FF_FindDir(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 path token = FF_strtok(path, mytoken, &it, &last, pathLen); do{ - //lastDirCluster = dirCluster; MyDir.CurrentItem = 0; - dirCluster = FF_FindEntryInDir(pIoman, dirCluster, token, FF_FAT_ATTR_DIR, &MyDir); + dirCluster = FF_FindEntryInDir(pIoman, dirCluster, token, FF_FAT_ATTR_DIR, &MyDir, pError); + + if(*pError) { + return 0; + } + /*if(dirCluster == 0 && MyDir.CurrentItem == 2 && MyDir.FileName[0] == '.') { // .. Dir Entry pointing to root dir. dirCluster = pIoman->pPartition->RootDirCluster; }*/ @@ -575,7 +508,11 @@ FF_T_UINT32 FF_FindDir(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 path FF_PendSemaphore(pIoman->pSemaphore); { if(pathLen < FF_MAX_PATH) { // Ensure the PATH won't cause a buffer overrun. +#ifdef FF_UNICODE_SUPPORT + memcpy(pIoman->pPartition->PathCache[pIoman->pPartition->PCIndex].Path, path, pathLen * sizeof(FF_T_WCHAR)); +#else memcpy(pIoman->pPartition->PathCache[pIoman->pPartition->PCIndex].Path, path, pathLen); +#endif pIoman->pPartition->PathCache[pIoman->pPartition->PCIndex].Path[pathLen] = '\0'; pIoman->pPartition->PathCache[pIoman->pPartition->PCIndex].DirCluster = dirCluster; #ifdef FF_HASH_TABLE_SUPPORT @@ -594,132 +531,81 @@ FF_T_UINT32 FF_FindDir(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 path return dirCluster; } -/* -FF_T_UINT32 FF_FindDir(FF_IOMAN *pIoman, FF_T_INT8 *path, FF_T_UINT16 pathLen) { - FF_T_UINT32 dirCluster = pIoman->pPartition->RootDirCluster; - FF_T_INT8 mytoken[FF_MAX_FILENAME]; - FF_T_INT8 *token; - FF_T_UINT16 it = 0; // Re-entrancy Variables for FF_strtok() - FF_T_BOOL last = FF_FALSE; - FF_DIRENT MyDir; - if(pathLen == 1) { // Must be the root dir! (/ or \) - return pIoman->pPartition->RootDirCluster; - } - - if(path[pathLen-1] == '\\' || path[pathLen-1] == '/') { - pathLen--; - } - - token = FF_strtok(path, mytoken, &it, &last, pathLen); - - do{ - //lastDirCluster = dirCluster; - MyDir.CurrentItem = 0; - if(FF_FindEntry(pIoman, dirCluster, token, &MyDir, FF_TRUE)) { - return 0; - } else { - dirCluster = MyDir.ObjectCluster; - } - if(MyDir.Attrib != FF_FAT_ATTR_DIR) { - return 0; - } - if(dirCluster == 0 && MyDir.CurrentItem == 2 && MyDir.FileName[0] == '.') { // .. Dir Entry pointing to root dir. - dirCluster = pIoman->pPartition->RootDirCluster; - } - token = FF_strtok(path, mytoken, &it, &last, pathLen); - }while(token != NULL); - - return dirCluster; -} -*/ - -#ifdef FF_LFN_SUPPORT +#if defined(FF_SHORTNAME_CASE) /** * @private - **//* -FF_T_SINT8 FF_getLFN(FF_IOMAN *pIoman, FF_BUFFER *pBuffer, FF_DIRENT *pDirent, FF_T_INT8 *filename) { - - FF_T_UINT8 numLFNs; - FF_T_UINT16 lenlfn = 0; - FF_T_UINT8 tester; - FF_T_UINT16 i,y; - FF_T_UINT32 CurrentCluster; - FF_T_UINT32 fatEntry; - FF_T_UINT8 *buffer = pBuffer->pBuffer; - FF_T_UINT32 Sector = pBuffer->Sector; - FF_T_UINT32 Entry = FF_getMinorBlockEntry(pIoman, pDirent->CurrentItem, 32); - - tester = FF_getChar(pBuffer->pBuffer, (FF_T_UINT16)(Entry * 32)); - numLFNs = (FF_T_UINT8) (tester & ~0x40); - - while(numLFNs > 0) { - if(FF_getClusterChainNumber(pIoman, pDirent->CurrentItem, 32) > pDirent->CurrentCluster) { - FF_ReleaseBuffer(pIoman, pBuffer); - fatEntry = FF_getFatEntry(pIoman, pDirent->DirCluster); - if(fatEntry == (FF_T_UINT32) FF_ERR_DEVICE_DRIVER_FAILED) { - return FF_ERR_DEVICE_DRIVER_FAILED; - } - - if(FF_isEndOfChain(pIoman, fatEntry)) { - CurrentCluster = pDirent->DirCluster; - // ERROR THIS SHOULD NOT OCCUR! - } else { - CurrentCluster = fatEntry; - } - - pBuffer = FF_GetBuffer(pIoman, FF_getRealLBA(pIoman, FF_Cluster2LBA(pIoman, CurrentCluster)), FF_MODE_READ); - if(!pBuffer) { - return FF_ERR_DEVICE_DRIVER_FAILED; - } - Entry = 0; + * For short-name entries, NT/XP etc store case information in byte 0x0c + * Use this to show proper case of "README.txt" or "source.H" + **/ +#ifdef FF_UNICODE_SUPPORT +static void FF_CaseShortName(FF_T_WCHAR *name, FF_T_UINT8 attrib) { +#else +static void FF_CaseShortName(FF_T_INT8 *name, FF_T_UINT8 attrib) { +#endif + FF_T_UINT8 testAttrib = FF_FAT_CASE_ATTR_BASE; + for (; *name; name++) { + if (*name == '.') { + testAttrib = FF_FAT_CASE_ATTR_EXT; + } else if ((attrib & testAttrib)) { + if (*name >= 'A' && *name <= 'Z') + *name += 0x20; + } else if (*name >= 'a' && *name <= 'z') { + *name -= 0x20; } - - if(Entry > 15) { - FF_ReleaseBuffer(pIoman, pBuffer); - Sector += 1; - pBuffer = FF_GetBuffer(pIoman, Sector, FF_MODE_READ); - if(!pBuffer) { - return FF_ERR_DEVICE_DRIVER_FAILED; - } - buffer = pBuffer->pBuffer; - Entry = 0; - } - - for(i = 0, y = 0; i < 5; i++, y += 2) { - filename[i + ((numLFNs - 1) * 13)] = buffer[(Entry * 32) + FF_FAT_LFN_NAME_1 + y]; - lenlfn++; - } - - for(i = 0, y = 0; i < 6; i++, y += 2) { - filename[i + ((numLFNs - 1) * 13) + 5] = buffer[(Entry * 32) + FF_FAT_LFN_NAME_2 + y]; - lenlfn++; - } - - for(i = 0, y = 0; i < 2; i++, y += 2) { - filename[i + ((numLFNs - 1) * 13) + 11] = buffer[(Entry * 32) + FF_FAT_LFN_NAME_3 + y]; - lenlfn++; - } - - numLFNs--; - - Entry++; - pDirent->CurrentItem += 1; } - - filename[lenlfn] = '\0'; - - return 0; -}*/ +} #endif /** * @private **/ + +#ifdef FF_UNICODE_SUPPORT +static void FF_ProcessShortName(FF_T_WCHAR *name) { + FF_T_WCHAR shortName[13]; + FF_T_WCHAR *ptr = name; +#else static void FF_ProcessShortName(FF_T_INT8 *name) { FF_T_INT8 shortName[13]; + FF_T_INT8 *ptr = name; +#endif FF_T_UINT8 i; +#ifdef FF_UNICODE_SUPPORT + memcpy(shortName, name, 11 * sizeof(FF_T_WCHAR)); +#else memcpy(shortName, name, 11); +#endif + + for(i = 0; i < 11; i++) { + if(shortName[i] == 0x20) { + if (i >= 8) + break; + i = 7; + } else { + if (i == 8) + *(ptr++) = '.'; + *(ptr++) = shortName[i]; + } + } + *ptr = '\0'; +} + +/* +#ifdef FF_UNICODE_SUPPORT +static void FF_ProcessShortName(FF_T_WCHAR *name) { + FF_T_WCHAR shortName[13]; +#else +static void FF_ProcessShortName(FF_T_INT8 *name) { + FF_T_INT8 shortName[13]; +#endif + + FF_T_UINT8 i; +#ifdef FF_UNICODE_SUPPORT + memcpy(shortName, name, 11 * sizeof(FF_T_WCHAR)); +#else + memcpy(shortName, name, 11); +#endif for(i = 0; i < 8; i++) { if(shortName[i] == 0x20) { @@ -745,7 +631,7 @@ static void FF_ProcessShortName(FF_T_INT8 *name) { name[i] = '\0'; } -} +}*/ #ifdef FF_TIME_SUPPORT static void FF_PlaceTime(FF_T_UINT8 *EntryBuffer, FF_T_UINT32 Offset) { @@ -790,28 +676,40 @@ static void FF_GetDate(FF_SYSTEMTIME *pTime, FF_T_UINT8 *EntryBuffer, FF_T_UINT3 pTime->Month = (((myShort & 0x01E0) >> 5) & 0x000F); pTime->Day = myShort & 0x01F; } - - - #endif void FF_PopulateShortDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT8 *EntryBuffer) { FF_T_UINT16 myShort; - +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR UTF16EntryBuffer[12]; + FF_cstrntowcs(UTF16EntryBuffer, (FF_T_INT8 *) EntryBuffer, 11); + memcpy(pDirent->FileName, UTF16EntryBuffer, 11 * sizeof(FF_T_WCHAR)); +#else memcpy(pDirent->FileName, EntryBuffer, 11); // Copy the filename into the Dirent object. +#endif +#if defined(FF_LFN_SUPPORT) && defined(FF_INCLUDE_SHORT_NAME) + memcpy(pDirent->ShortName, EntryBuffer, 11); + pDirent->ShortName[11] = '\0'; + FF_ProcessShortName(pDirent->ShortName); // Format the shortname, for pleasant viewing. + +#endif FF_ProcessShortName(pDirent->FileName); // Format the shortname, for pleasant viewing. #ifdef FF_HASH_TABLE_SUPPORT -#if FF_HASH_FUNCTION == CRC16 +/*#if FF_HASH_FUNCTION == CRC16 FF_AddDirentHash(pIoman, pDirent->DirCluster, (FF_T_UINT32)FF_GetCRC16((FF_T_UINT8 *) pDirent->FileName, strlen(pDirent->FileName))); #elif FF_HASH_FUNCTION == CRC8 FF_AddDirentHash(pIoman, pDirent->DirCluster, (FF_T_UINT32)FF_GetCRC8((FF_T_UINT8 *) pDirent->FileName, strlen(pDirent->FileName))); -#endif +#endif*/ #else - pIoman = NULL; + pIoman = NULL; // Silence a compiler warning, about not referencing pIoman. #endif +#ifdef FF_UNICODE_SUPPORT + FF_tolower(pDirent->FileName, (FF_T_UINT32)wcslen(pDirent->FileName)); +#else FF_tolower(pDirent->FileName, (FF_T_UINT32)strlen(pDirent->FileName)); +#endif // Get the item's Cluster address. myShort = FF_getShort(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_CLUS_HIGH)); @@ -837,68 +735,167 @@ void FF_PopulateShortDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT8 *En pDirent->Attrib = FF_getChar(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_ATTRIB)); } -FF_T_SINT8 FF_FetchEntry(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer) { - FF_BUFFER *pBuffer; - FF_T_UINT32 itemLBA; - FF_T_UINT32 chainLength = FF_GetChainLength(pIoman, DirCluster, NULL); // BottleNeck - FF_T_UINT32 clusterNum = FF_getClusterChainNumber (pIoman, nEntry, (FF_T_UINT16)32); - FF_T_UINT32 relItem = FF_getMinorBlockEntry (pIoman, nEntry, (FF_T_UINT16)32); - FF_T_UINT32 clusterAddress = FF_TraverseFAT(pIoman, DirCluster, clusterNum); // BottleNeck +/* + Initialises a context object for FF_FetchEntryWithContext() +*/ +FF_ERROR FF_InitEntryFetch(FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster, FF_FETCH_CONTEXT *pContext) { + + FF_ERROR Error; + + memset(pContext, 0, sizeof(FF_FETCH_CONTEXT)); + + pContext->ulChainLength = FF_GetChainLength(pIoman, ulDirCluster, NULL, &Error); // Get the total length of the chain. + if(Error) { + return Error; + } + pContext->ulDirCluster = ulDirCluster; + pContext->ulCurrentClusterLCN = ulDirCluster; + pContext->ulCurrentClusterNum = 0; + pContext->ulCurrentEntry = 0; if(pIoman->pPartition->Type != FF_T_FAT32) { - if(DirCluster == pIoman->pPartition->RootDirCluster) { - chainLength = pIoman->pPartition->RootDirSectors / pIoman->pPartition->SectorsPerCluster; - if(!chainLength) { // Some media has RootDirSectors < SectorsPerCluster. This is wrong, as it should be atleast 1 cluster! - chainLength = 1; + // Handle Root Dirs that don't have cluster chains! + if(pContext->ulDirCluster == pIoman->pPartition->RootDirCluster) { + // This is a RootDIR, special consideration needs to be made, because it doesn't have a Cluster chain! + pContext->ulChainLength = pIoman->pPartition->RootDirSectors / pIoman->pPartition->SectorsPerCluster; + if(!pContext->ulChainLength) { // Some media has RootDirSectors < SectorsPerCluster. This is wrong, as it should be atleast 1 cluster! + pContext->ulChainLength = 1; } - clusterAddress = DirCluster; - clusterNum = 0; - if(nEntry > ((pIoman->pPartition->RootDirSectors * pIoman->pPartition->BlkSize) / 32)) { + } + } + + return FF_ERR_NONE; +} + +void FF_CleanupEntryFetch(FF_IOMAN *pIoman, FF_FETCH_CONTEXT *pContext) { + if(pContext->pBuffer) { + FF_ReleaseBuffer(pIoman, pContext->pBuffer); + pContext->pBuffer = NULL; + } +} + +FF_ERROR FF_FetchEntryWithContext(FF_IOMAN *pIoman, FF_T_UINT32 ulEntry, FF_FETCH_CONTEXT *pContext, FF_T_UINT8 *pEntryBuffer) { + + FF_T_UINT32 ulItemLBA; + FF_T_UINT32 ulRelItem; + FF_T_UINT32 ulClusterNum; + FF_ERROR Error; + + ulClusterNum = FF_getClusterChainNumber(pIoman, ulEntry, (FF_T_UINT16)32); + ulRelItem = FF_getMinorBlockEntry (pIoman, ulEntry, (FF_T_UINT16)32); + + if(ulClusterNum != pContext->ulCurrentClusterNum) { + // Traverse the fat gently! + if(ulClusterNum > pContext->ulCurrentClusterNum) { + pContext->ulCurrentClusterLCN = FF_TraverseFAT(pIoman, pContext->ulCurrentClusterLCN, (ulClusterNum - pContext->ulCurrentClusterNum), &Error); + if(Error) { + return Error; + } + } else { + pContext->ulCurrentClusterLCN = FF_TraverseFAT(pIoman, pContext->ulDirCluster, ulClusterNum, &Error); + if(Error) { + return Error; + } + } + pContext->ulCurrentClusterNum = ulClusterNum; + } + + if(pIoman->pPartition->Type != FF_T_FAT32) { + // Handle Root Dirs that don't have cluster chains! + if(pContext->ulDirCluster == pIoman->pPartition->RootDirCluster) { + // This is a RootDIR, special consideration needs to be made, because it doesn't have a Cluster chain! + pContext->ulCurrentClusterLCN = pContext->ulDirCluster; + ulClusterNum = 0; + if(ulEntry > ((pIoman->pPartition->RootDirSectors * pIoman->pPartition->BlkSize) / 32)) { return FF_ERR_DIR_END_OF_DIR; } } } - - if((clusterNum + 1) > chainLength) { + + if((ulClusterNum + 1) > pContext->ulChainLength) { return FF_ERR_DIR_END_OF_DIR; // End of Dir was reached! } - itemLBA = FF_Cluster2LBA(pIoman, clusterAddress) + FF_getMajorBlockNumber(pIoman, nEntry, (FF_T_UINT16)32); - itemLBA = FF_getRealLBA (pIoman, itemLBA) + FF_getMinorBlockNumber(pIoman, relItem, (FF_T_UINT16)32); - - pBuffer = FF_GetBuffer(pIoman, itemLBA, FF_MODE_READ); - { - memcpy(buffer, (pBuffer->pBuffer + (relItem*32)), 32); - pBuffer->Persistance = 1; + ulItemLBA = FF_Cluster2LBA (pIoman, pContext->ulCurrentClusterLCN) + FF_getMajorBlockNumber(pIoman, ulEntry, (FF_T_UINT16)32); + ulItemLBA = FF_getRealLBA (pIoman, ulItemLBA) + FF_getMinorBlockNumber(pIoman, ulRelItem, (FF_T_UINT16)32); + + if(!pContext->pBuffer || (pContext->pBuffer->Sector != ulItemLBA)) { + if(pContext->pBuffer) { + FF_ReleaseBuffer(pIoman, pContext->pBuffer); + } + pContext->pBuffer = FF_GetBuffer(pIoman, ulItemLBA, FF_MODE_READ); + if(!pContext->pBuffer) { + return FF_ERR_DEVICE_DRIVER_FAILED; + } } - FF_ReleaseBuffer(pIoman, pBuffer); - + + if (pEntryBuffer) { // HT Because it might be called with NULL + memcpy(pEntryBuffer, (pContext->pBuffer->pBuffer + (ulRelItem*32)), 32); + } + return FF_ERR_NONE; } -FF_T_SINT8 FF_PushEntry(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer) { - FF_BUFFER *pBuffer; - FF_T_UINT32 itemLBA; - FF_T_UINT32 chainLength = FF_GetChainLength(pIoman, DirCluster, NULL); // BottleNeck - FF_T_UINT32 clusterNum = FF_getClusterChainNumber (pIoman, nEntry, (FF_T_UINT16)32); - FF_T_UINT32 relItem = FF_getMinorBlockEntry (pIoman, nEntry, (FF_T_UINT16)32); - FF_T_UINT32 clusterAddress = FF_TraverseFAT(pIoman, DirCluster, clusterNum); // BottleNeck - - if((clusterNum + 1) > chainLength) { +FF_ERROR FF_PushEntryWithContext(FF_IOMAN *pIoman, FF_T_UINT32 ulEntry, FF_FETCH_CONTEXT *pContext, FF_T_UINT8 *pEntryBuffer) { + FF_T_UINT32 ulItemLBA; + FF_T_UINT32 ulRelItem; + FF_T_UINT32 ulClusterNum; + FF_ERROR Error; + + ulClusterNum = FF_getClusterChainNumber(pIoman, ulEntry, (FF_T_UINT16)32); + ulRelItem = FF_getMinorBlockEntry (pIoman, ulEntry, (FF_T_UINT16)32); + + if(ulClusterNum != pContext->ulCurrentClusterNum) { + // Traverse the fat gently! + if(ulClusterNum > pContext->ulCurrentClusterNum) { + pContext->ulCurrentClusterLCN = FF_TraverseFAT(pIoman, pContext->ulCurrentClusterLCN, (ulClusterNum - pContext->ulCurrentClusterNum), &Error); + if(Error) { + return Error; + } + } else { + pContext->ulCurrentClusterLCN = FF_TraverseFAT(pIoman, pContext->ulDirCluster, ulClusterNum, &Error); + if(Error) { + return Error; + } + } + pContext->ulCurrentClusterNum = ulClusterNum; + } + + if(pIoman->pPartition->Type != FF_T_FAT32) { + // Handle Root Dirs that don't have cluster chains! + if(pContext->ulDirCluster == pIoman->pPartition->RootDirCluster) { + // This is a RootDIR, special consideration needs to be made, because it doesn't have a Cluster chain! + pContext->ulCurrentClusterLCN = pContext->ulDirCluster; + ulClusterNum = 0; + if(ulEntry > ((pIoman->pPartition->RootDirSectors * pIoman->pPartition->BlkSize) / 32)) { + return FF_ERR_DIR_END_OF_DIR; + } + } + } + + if((ulClusterNum + 1) > pContext->ulChainLength) { return FF_ERR_DIR_END_OF_DIR; // End of Dir was reached! } - itemLBA = FF_Cluster2LBA(pIoman, clusterAddress) + FF_getMajorBlockNumber(pIoman, nEntry, (FF_T_UINT16)32); - itemLBA = FF_getRealLBA (pIoman, itemLBA) + FF_getMinorBlockNumber(pIoman, relItem, (FF_T_UINT16)32); - - pBuffer = FF_GetBuffer(pIoman, itemLBA, FF_MODE_WRITE); - { - memcpy((pBuffer->pBuffer + (relItem*32)), buffer, 32); + ulItemLBA = FF_Cluster2LBA (pIoman, pContext->ulCurrentClusterLCN) + FF_getMajorBlockNumber(pIoman, ulEntry, (FF_T_UINT16)32); + ulItemLBA = FF_getRealLBA (pIoman, ulItemLBA) + FF_getMinorBlockNumber(pIoman, ulRelItem, (FF_T_UINT16)32); + + if(!pContext->pBuffer || (pContext->pBuffer->Sector != ulItemLBA)) { + if(pContext->pBuffer) { + FF_ReleaseBuffer(pIoman, pContext->pBuffer); + } + pContext->pBuffer = FF_GetBuffer(pIoman, ulItemLBA, FF_MODE_READ); + if(!pContext->pBuffer) { + return FF_ERR_DEVICE_DRIVER_FAILED; + } } - FF_ReleaseBuffer(pIoman, pBuffer); - - return 0; + + memcpy((pContext->pBuffer->pBuffer + (ulRelItem*32)), pEntryBuffer, 32); + pContext->pBuffer->Mode = FF_MODE_WRITE; + pContext->pBuffer->Modified = FF_TRUE; + + return FF_ERR_NONE; } @@ -906,14 +903,24 @@ FF_T_SINT8 FF_PushEntry(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nE * @private **/ FF_ERROR FF_GetEntry(FF_IOMAN *pIoman, FF_T_UINT16 nEntry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent) { - FF_T_UINT8 EntryBuffer[32]; - FF_T_UINT8 numLFNs; + FF_T_UINT8 EntryBuffer[32]; + FF_T_UINT8 numLFNs; + FF_FETCH_CONTEXT FetchContext; + FF_ERROR Error; + + Error = FF_InitEntryFetch(pIoman, DirCluster, &FetchContext); + if(Error) { + return Error; + } - if(FF_FetchEntry(pIoman, DirCluster, nEntry, EntryBuffer)) { - return FF_ERR_DIR_END_OF_DIR; + Error = FF_FetchEntryWithContext(pIoman, nEntry, &FetchContext, EntryBuffer); + if(Error) { + FF_CleanupEntryFetch(pIoman, &FetchContext); + return Error; } if(EntryBuffer[0] != 0xE5) { if(FF_isEndOfDir(EntryBuffer)){ + FF_CleanupEntryFetch(pIoman, &FetchContext); return FF_ERR_DIR_END_OF_DIR; } @@ -923,8 +930,12 @@ FF_ERROR FF_GetEntry(FF_IOMAN *pIoman, FF_T_UINT16 nEntry, FF_T_UINT32 DirCluste // LFN Processing numLFNs = (FF_T_UINT8)(EntryBuffer[0] & ~0x40); #ifdef FF_LFN_SUPPORT - FF_PopulateLongDirent(pIoman, pDirent, DirCluster, nEntry); - return 0; + Error = FF_PopulateLongDirent(pIoman, pDirent, nEntry, &FetchContext); + FF_CleanupEntryFetch(pIoman, &FetchContext); + if(Error) { + return Error; + } + return FF_ERR_NONE; #else pDirent->CurrentItem += (numLFNs - 1); #endif @@ -934,9 +945,12 @@ FF_ERROR FF_GetEntry(FF_IOMAN *pIoman, FF_T_UINT16 nEntry, FF_T_UINT32 DirCluste } else { FF_PopulateShortDirent(pIoman, pDirent, EntryBuffer); pDirent->CurrentItem += 1; + FF_CleanupEntryFetch(pIoman, &FetchContext); return 0; } } + + FF_CleanupEntryFetch(pIoman, &FetchContext); return FF_ERR_NONE; } @@ -947,55 +961,123 @@ FF_T_BOOL FF_isEndOfDir(FF_T_UINT8 *EntryBuffer) { return FF_FALSE; } -#ifdef FF_HASH_TABLE_SUPPORT -FF_ERROR FF_AddDirentHash(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash) { +#ifdef FF_HASH_CACHE +FF_ERROR FF_AddDirentHash(FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster, FF_T_UINT32 ulHash) { FF_T_UINT32 i; FF_HASH_TABLE pHash = NULL; - for(i = 0; i < FF_PATH_CACHE_DEPTH; i++) { - if(pIoman->pPartition->PathCache[i].DirCluster == DirCluster) { - pHash = pIoman->pPartition->PathCache[i].pHashTable; + for(i = 0; i < FF_HASH_CACHE_DEPTH; i++) { + if(pIoman->HashCache[i].ulDirCluster == ulDirCluster) { + pHash = pIoman->HashCache[i].pHashTable; break; } } if(pHash) { - FF_SetHash(pHash, nHash); + FF_SetHash(pHash, ulHash); } return FF_ERR_NONE; } -FF_T_BOOL FF_CheckDirentHash(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash) { +FF_T_BOOL FF_CheckDirentHash(FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster, FF_T_UINT32 ulHash) { FF_T_UINT32 i; FF_HASH_TABLE pHash = NULL; - for(i = 0; i < FF_PATH_CACHE_DEPTH; i++) { - if(pIoman->pPartition->PathCache[i].DirCluster == DirCluster) { - pHash = pIoman->pPartition->PathCache[i].pHashTable; + for(i = 0; i < FF_HASH_CACHE_DEPTH; i++) { + if(pIoman->HashCache[i].ulDirCluster == ulDirCluster) { + pHash = pIoman->HashCache[i].pHashTable; break; } } if(pHash) { - return FF_isHashSet(pHash, nHash); + return FF_isHashSet(pHash, ulHash); } return FF_FALSE; } -FF_T_BOOL FF_DirHashed(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster) { +FF_T_BOOL FF_DirHashed(FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster) { FF_T_UINT32 i; - for(i = 0; i < FF_PATH_CACHE_DEPTH; i++) { - if(pIoman->pPartition->PathCache[i].DirCluster == DirCluster) { - if(pIoman->pPartition->PathCache[i].bHashed) { - return FF_TRUE; - } + for(i = 0; i < FF_HASH_CACHE_DEPTH; i++) { + if(pIoman->HashCache[i].ulDirCluster == ulDirCluster) { + return FF_TRUE; } } return FF_FALSE; } -void FF_SetDirHashed(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster) { +FF_ERROR FF_HashDir(FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster) { + // Find most suitable Hash Table to replace! + FF_T_UINT32 i; + FF_HASHCACHE *pHashCache = NULL; + FF_FETCH_CONTEXT FetchContext; + FF_T_UINT8 EntryBuffer[32], ucAttrib; + FF_T_UINT32 ulHash; + + if(FF_DirHashed(pIoman, ulDirCluster)) { + return FF_ERR_NONE; // Don't wastefully re-hash a dir! + } + + //printf("----- Hashing Directory\n"); + + for(i = 0; i < FF_HASH_CACHE_DEPTH; i++) { + if(!pIoman->HashCache[i].ulNumHandles) { + if(!pHashCache) { + pHashCache = &pIoman->HashCache[i]; + } else { + if((pIoman->HashCache[i].ulMisses > pHashCache->ulMisses)) { + pHashCache = &pIoman->HashCache[i]; + } + } + } + } + + if(pHashCache) { + // Clear the hash table! + FF_ClearHashTable(pHashCache->pHashTable); + pHashCache->ulDirCluster = ulDirCluster; + pHashCache->ulMisses = 0; + + // Hash the directory! + + FF_InitEntryFetch(pIoman, ulDirCluster, &FetchContext); + + for(i = 0; i < 0xFFFF; i++) { + if(FF_FetchEntryWithContext(pIoman, i, &FetchContext, EntryBuffer)) { + break; // HT addition + } + ucAttrib = FF_getChar(EntryBuffer, FF_FAT_DIRENT_ATTRIB); + if(FF_getChar(EntryBuffer, 0x00) != 0xE5) { + if(ucAttrib != FF_FAT_ATTR_LFN) { + FF_ProcessShortName((FF_T_INT8 *)EntryBuffer); + if(FF_isEndOfDir(EntryBuffer)) { + // HT uncommented + FF_CleanupEntryFetch(pIoman, &FetchContext); + return FF_ERR_NONE; + } + + // Generate the Hash +#if FF_HASH_FUNCTION == CRC16 + ulHash = FF_GetCRC16(EntryBuffer, strlen((const FF_T_INT8 *) EntryBuffer)); +#elif FF_HASH_FUNCTION == CRC8 + ulHash = FF_GetCRC8(EntryBuffer, strlen((const FF_T_INT8 *) EntryBuffer)); +#endif + FF_SetHash(pHashCache->pHashTable, ulHash); + + } + } + } + + FF_CleanupEntryFetch(pIoman, &FetchContext); + + return FF_ERR_NONE; + } + + return -1; +} + +/*void FF_SetDirHashed(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster) { int i; for(i = 0; i < FF_PATH_CACHE_DEPTH; i++) { if(pIoman->pPartition->PathCache[i].DirCluster == DirCluster) { @@ -1003,27 +1085,273 @@ void FF_SetDirHashed(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster) { return; } } -} +}*/ #endif +FF_ERROR FF_PopulateLongDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT16 nEntry, FF_FETCH_CONTEXT *pFetchContext) { + // First get the entire name as UTF-16 from the LFN's. + // Then transform into the API's native string format. + + FF_ERROR Error; + FF_T_UINT uiNumLFNs; + FF_T_UINT uiLfnLength = 0; + FF_T_UINT i,y; +#ifdef FF_UNICODE_UTF8_SUPPORT +// FF_T_SINT32 slRetVal; + FF_T_UINT16 nLfnBegin; + FF_T_UINT16 usUtf8Len = 0; +#endif + FF_T_UINT16 myShort; + FF_T_UINT8 ucCheckSum; -FF_T_SINT8 FF_PopulateLongDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry) { FF_T_UINT8 EntryBuffer[32]; + //FF_T_UINT16 UTF16Name[FF_MAX_FILENAME]; + +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR WCEntryBuffer[32]; + FF_T_WCHAR ShortName[13]; +#else FF_T_INT8 ShortName[13]; +#endif + + Error = FF_FetchEntryWithContext(pIoman, nEntry++, pFetchContext, EntryBuffer); + if(Error) { + return Error; + } + + uiNumLFNs = (FF_T_UINT)(EntryBuffer[0] & ~0x40); + ucCheckSum = FF_getChar(EntryBuffer, FF_FAT_LFN_CHECKSUM); + +#ifdef FF_UNICODE_SUPPORT // UTF-16 Can simply get segments of the UTF-16 sequence going forward + // in the dirents. (I.e. reversed order). + + while(uiNumLFNs) { // Avoid stack intensive use of a UTF-16 buffer. Stream direct to FileName dirent field in correct format. + + // memcopy direct!-UTF-16 support + memcpy(pDirent->FileName + ((uiNumLFNs - 1) * 13) + 0, &EntryBuffer[FF_FAT_LFN_NAME_1], 10); + memcpy(pDirent->FileName + ((uiNumLFNs - 1) * 13) + 5, &EntryBuffer[FF_FAT_LFN_NAME_2], 12); + memcpy(pDirent->FileName + ((uiNumLFNs - 1) * 13) + 11, &EntryBuffer[FF_FAT_LFN_NAME_3], 4); + + + uiLfnLength += 13; + + Error = FF_FetchEntryWithContext(pIoman, nEntry++, pFetchContext, EntryBuffer); + if(Error) { + return Error; + } + uiNumLFNs--; + } + + pDirent->FileName[uiLfnLength] = '\0'; +#endif + +#ifdef FF_UNICODE_UTF8_SUPPORT + // UTF-8 Sequence, we can only convert this from the beginning, must receive entries in reverse. + nLfnBegin = nEntry - 1; + + for(i = 0; i < uiNumLFNs; i++) { + Error = FF_FetchEntryWithContext(pIoman, (nLfnBegin + (uiNumLFNs - 1) - i), pFetchContext, EntryBuffer); + if(Error) { + return Error; + } + + // Now have the first part of the UTF-16 sequence. Stream into a UTF-8 sequence. + for(y = 0; y < 5; y++) { + Error = FF_Utf16ctoUtf8c((FF_T_UINT8 *) &pDirent->FileName[usUtf8Len], (FF_T_UINT16 *) &EntryBuffer[FF_FAT_LFN_NAME_1 + (y*2)], sizeof(pDirent->FileName) - usUtf8Len); + if(Error > 0) { + usUtf8Len += (FF_T_UINT16) Error; + } + } + + for(y = 0; y < 6; y++) { + Error = FF_Utf16ctoUtf8c((FF_T_UINT8 *) &pDirent->FileName[usUtf8Len], (FF_T_UINT16 *) &EntryBuffer[FF_FAT_LFN_NAME_2 + (y*2)], sizeof(pDirent->FileName) - usUtf8Len); + if(Error > 0) { + usUtf8Len += (FF_T_UINT16) Error; + } + } + + for(y = 0; y < 2; y++) { + Error = FF_Utf16ctoUtf8c((FF_T_UINT8 *) &pDirent->FileName[usUtf8Len], (FF_T_UINT16 *) &EntryBuffer[FF_FAT_LFN_NAME_3 + (y*2)], sizeof(pDirent->FileName) - usUtf8Len); + if(Error > 0) { + usUtf8Len += (FF_T_UINT16) Error; + } + } + nEntry++; + } + + pDirent->FileName[usUtf8Len] = '\0'; + + // Put Entry context to correct position. + Error = FF_FetchEntryWithContext(pIoman, nEntry-1, pFetchContext, EntryBuffer); + if(Error) { + return Error; + } + +#endif + +#ifndef FF_UNICODE_SUPPORT +#ifndef FF_UNICODE_UTF8_SUPPORT // No Unicode, simple ASCII. + while(uiNumLFNs) { // Avoid stack intensive use of a UTF-16 buffer. Stream direct to FileName dirent field in correct format. + + for(i = 0; i < 5; i++) { + pDirent->FileName[((uiNumLFNs - 1) * 13) + i] = EntryBuffer[FF_FAT_LFN_NAME_1 + (i*2)]; + } + + for(i = 0; i < 6; i++) { + pDirent->FileName[((uiNumLFNs - 1) * 13) + i + 5] = EntryBuffer[FF_FAT_LFN_NAME_2 + (i*2)]; + } + + for(i = 0; i < 2; i++) { + pDirent->FileName[((uiNumLFNs - 1) * 13) + i + 11] = EntryBuffer[FF_FAT_LFN_NAME_3 + (i*2)]; + } + + uiLfnLength += 13; + + Error = FF_FetchEntryWithContext(pIoman, nEntry++, pFetchContext, EntryBuffer); + if(Error) { + return Error; + } + uiNumLFNs--; + } + + pDirent->FileName[uiLfnLength] = '\0'; + + +#endif +#endif + // Process the Shortname. -- LFN Transformation is now complete. + // Process the ShortName Entry + + // if SHORTNAMES must be included, simple byte copy into shortname buffer. +#if defined(FF_LFN_SUPPORT) && defined(FF_INCLUDE_SHORT_NAME) + memcpy(pDirent->ShortName, EntryBuffer, 11); + pDirent->ShortName[11] = '\0'; + FF_ProcessShortName(pDirent->ShortName); +#endif + +#ifdef FF_UNICODE_SUPPORT + FF_cstrntowcs(WCEntryBuffer, (FF_T_INT8 *) EntryBuffer, 32); + memcpy(ShortName, WCEntryBuffer, 11 * sizeof(FF_T_WCHAR)); +#else + memcpy(ShortName, EntryBuffer, 11); +#endif + FF_ProcessShortName(ShortName); + if(ucCheckSum != FF_CreateChkSum(EntryBuffer)) { +#ifdef FF_UNICODE_SUPPORT + wcscpy(pDirent->FileName, ShortName); +#else + strcpy(pDirent->FileName, ShortName); +#endif + } + + // Finally fill in the other details + myShort = FF_getShort(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_CLUS_HIGH)); + pDirent->ObjectCluster = (FF_T_UINT32) (myShort << 16); + myShort = FF_getShort(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_CLUS_LOW)); + pDirent->ObjectCluster |= myShort; + +#ifdef FF_TIME_SUPPORT + // Get the creation Time & Date + FF_GetTime(&pDirent->CreateTime, EntryBuffer, FF_FAT_DIRENT_CREATE_TIME); + FF_GetDate(&pDirent->CreateTime, EntryBuffer, FF_FAT_DIRENT_CREATE_DATE); + // Get the modified Time & Date + FF_GetTime(&pDirent->CreateTime, EntryBuffer, FF_FAT_DIRENT_LASTMOD_TIME); + FF_GetDate(&pDirent->CreateTime, EntryBuffer, FF_FAT_DIRENT_LASTMOD_DATE); + // Get the last accessed Date. + FF_GetDate(&pDirent->AccessedTime, EntryBuffer, FF_FAT_DIRENT_LASTACC_DATE); + pDirent->AccessedTime.Hour = 0; + pDirent->AccessedTime.Minute = 0; + pDirent->AccessedTime.Second = 0; +#endif + + // Get the filesize. + pDirent->Filesize = FF_getLong(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_FILESIZE)); + // Get the attribute. + pDirent->Attrib = FF_getChar(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_ATTRIB)); + + pDirent->CurrentItem = nEntry; + //return x; + return FF_ERR_NONE; +} + +/* +FF_ERROR FF_PopulateLongDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT16 nEntry, FF_FETCH_CONTEXT *pFetchContext) { + FF_T_UINT8 EntryBuffer[32]; +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR UTF16EntryBuffer[32]; + FF_T_WCHAR ShortName[13]; +#if WCHAR_MAX > 0xFFFF + FF_T_UINT16 i,y; +#endif +#else + FF_T_INT8 ShortName[13]; +#ifdef FF_UNICODE_UTF8_SUPPORT + FF_T_SINT32 i, y; +#else + FF_T_UINT16 i, y; +#endif +#endif + +#ifdef FF_UNICODE_UTF8_SUPPORT + FF_T_UINT16 UTF16Name[FF_MAX_FILENAME]; // Read in the entire UTF-16 name into this buffer. + FF_T_UINT16 *UTF16cptr; +#endif FF_T_UINT8 numLFNs; FF_T_UINT8 x; FF_T_UINT8 CheckSum = 0; - FF_T_UINT16 i,y; + FF_T_UINT16 lenlfn = 0; FF_T_UINT16 myShort; + FF_ERROR Error; - FF_FetchEntry(pIoman, DirCluster, nEntry++, EntryBuffer); + Error = FF_FetchEntryWithContext(pIoman, nEntry++, pFetchContext, EntryBuffer); + if(Error) { + return Error; + } + numLFNs = (FF_T_UINT8)(EntryBuffer[0] & ~0x40); // Handle the name CheckSum = FF_getChar(EntryBuffer, FF_FAT_LFN_CHECKSUM); x = numLFNs; while(numLFNs) { + if(numLFNs > 1) { + numLFNs = numLFNs; + } + +#ifdef FF_UNICODE_SUPPORT + // Simply fill the FileName buffer with UTF-16 Filename! +#if WCHAR_MAX <= 0xFFFF // System works in UTF-16 so we can trust it if we just copy the UTF-16 strings directly. + memcpy(pDirent->FileName + ((numLFNs - 1) * 13) + 0, &EntryBuffer[FF_FAT_LFN_NAME_1], (5 * 2)); + memcpy(pDirent->FileName + ((numLFNs - 1) * 13) + 5, &EntryBuffer[FF_FAT_LFN_NAME_2], (6 * 2)); + memcpy(pDirent->FileName + ((numLFNs - 1) * 13) + 11, &EntryBuffer[FF_FAT_LFN_NAME_3], (2 * 2)); + lenlfn += 13; +#else + for(i = 0, y = 0; i < 5; i++, y += 2) { + FF_Utf16ctoUtf32c((FF_T_UINT32 *)&pDirent->FileName[i + ((numLFNs - 1) * 13)], (FF_T_UINT16 *) &EntryBuffer[FF_FAT_LFN_NAME_1 + y]); + //pDirent->FileName[i + ((numLFNs - 1) * 13)] = (FF_T_WCHAR) ((FF_T_WCHAR) EntryBuffer[FF_FAT_LFN_NAME_1 + y] | ((FF_T_WCHAR) EntryBuffer[FF_FAT_LFN_NAME_1 + y + 1] >> 8)); + lenlfn++; + } + for(i = 0, y = 0; i < 6; i++, y += 2) { + FF_Utf16ctoUtf32c((FF_T_UINT32 *)&pDirent->FileName[i + ((numLFNs - 1) * 13) + 5], (FF_T_UINT16 *) &EntryBuffer[FF_FAT_LFN_NAME_2 + y]); + //pDirent->FileName[i + ((numLFNs - 1) * 13) + 5] = (FF_T_WCHAR) ((FF_T_WCHAR) EntryBuffer[FF_FAT_LFN_NAME_2 + y] | ((FF_T_WCHAR) EntryBuffer[FF_FAT_LFN_NAME_2 + y + 1] >> 8)); + lenlfn++; + } + for(i = 0, y = 0; i < 2; i++, y += 2) { + FF_Utf16ctoUtf32c((FF_T_UINT32 *)&pDirent->FileName[i + ((numLFNs - 1) * 13) + 11], (FF_T_UINT16 *) &EntryBuffer[FF_FAT_LFN_NAME_3 + y]); + //pDirent->FileName[i + ((numLFNs - 1) * 13) + 11] = (FF_T_WCHAR) ((FF_T_WCHAR) EntryBuffer[FF_FAT_LFN_NAME_3 + y] | ((FF_T_WCHAR)EntryBuffer[FF_FAT_LFN_NAME_3 + y + 1] >> 8)); + lenlfn++; + } +#endif + // Copy each part of the LFNS +#else +#ifdef FF_UNICODE_UTF8_SUPPORT + memcpy(UTF16Name + ((numLFNs - 1) * 13) + 0, &EntryBuffer[FF_FAT_LFN_NAME_1], (5 * 2)); + memcpy(UTF16Name + ((numLFNs - 1) * 13) + 5, &EntryBuffer[FF_FAT_LFN_NAME_2], (6 * 2)); + memcpy(UTF16Name + ((numLFNs - 1) * 13) + 11, &EntryBuffer[FF_FAT_LFN_NAME_3], (2 * 2)); + lenlfn += 13; +#else + // Attempts to pull ASCII from UTF-8 encoding. for(i = 0, y = 0; i < 5; i++, y += 2) { pDirent->FileName[i + ((numLFNs - 1) * 13)] = EntryBuffer[FF_FAT_LFN_NAME_1 + y]; lenlfn++; @@ -1038,28 +1366,56 @@ FF_T_SINT8 FF_PopulateLongDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT pDirent->FileName[i + ((numLFNs - 1) * 13) + 11] = EntryBuffer[FF_FAT_LFN_NAME_3 + y]; lenlfn++; } +#endif +#endif - FF_FetchEntry(pIoman, DirCluster, nEntry++, EntryBuffer); + Error = FF_FetchEntryWithContext(pIoman, nEntry++, pFetchContext, EntryBuffer); + if(Error) { + return Error; + } numLFNs--; } +#ifdef FF_UNICODE_UTF8_SUPPORT + UTF16cptr = UTF16Name; + UTF16Name[lenlfn] = '\0'; + i = 0; // Keep tabs of the current char position in the UTF-8 sequence. + while(*UTF16cptr) { + y = FF_Utf16ctoUtf8c((FF_T_UINT8 *)&pDirent->FileName[i], UTF16cptr, (FF_MAX_FILENAME - i)); + i += y; + if(FF_GetUtf16SequenceLen(*UTF16cptr++) == 2) { // IF this is a surrogate, then bump the UTF16 Pointer. + UTF16cptr++; + } + } + pDirent->FileName[i] = '\0'; +#else pDirent->FileName[lenlfn] = '\0'; +#endif // Process the ShortName Entry +#ifdef FF_UNICODE_SUPPORT + FF_cstrntowcs(UTF16EntryBuffer, (FF_T_INT8 *) EntryBuffer, 32); + memcpy(ShortName, UTF16EntryBuffer, 11 * sizeof(FF_T_WCHAR)); +#else memcpy(ShortName, EntryBuffer, 11); +#endif if(CheckSum != FF_CreateChkSum(EntryBuffer)) { FF_ProcessShortName(ShortName); +#ifdef FF_UNICODE_SUPPORT + wcscpy(pDirent->FileName, ShortName); +#else strcpy(pDirent->FileName, ShortName); +#endif } else { FF_ProcessShortName(ShortName); } -#ifdef FF_HASH_TABLE_SUPPORT -#if FF_HASH_FUNCTION == CRC16 - FF_AddDirentHash(pIoman, DirCluster, (FF_T_UINT32)FF_GetCRC16((FF_T_UINT8 *) ShortName, strlen(ShortName))); +#ifdef FF_HASH_TABLE_SUPPORT*/ +/*#if FF_HASH_FUNCTION == CRC16 + FF_AddDirentHash(pIoman, pFetchContext->ulDirCluster, (FF_T_UINT32)FF_GetCRC16((FF_T_UINT8 *) ShortName, strlen(ShortName))); #elif FF_HASH_FUNCTION == CRC8 FF_AddDirentHash(pIoman, DirCluster, (FF_T_UINT32)FF_GetCRC8((FF_T_UINT8 *) ShortName, strlen(ShortName))); -#endif +#endif*//* #endif myShort = FF_getShort(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_CLUS_HIGH)); @@ -1087,9 +1443,10 @@ FF_T_SINT8 FF_PopulateLongDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT pDirent->Attrib = FF_getChar(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_ATTRIB)); pDirent->CurrentItem = nEntry; - return x; + //return x; + return FF_ERR_NONE; } - +*/ /** * @public * @brief Find's the first directory entry for the provided path. @@ -1097,6 +1454,22 @@ FF_T_SINT8 FF_PopulateLongDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT * All values recorded in pDirent must be preserved to and between calls to * FF_FindNext(). * + * If FF_FINDAPI_ALLOW_WILDCARDS is defined, then path will have the following behaviour: + * + * path = "\" - Open the root dir, and iterate through all items. + * path = "\*.c" - Open the root dir, showing only files matching *.c wildcard. + * path = "\sub1\newdir" - Get the DIRENT for the newdir directory in /sub1/ if one exists. + * path = "\sub1\newdir\" - Open the directory /sub1/newdir/ and iterate through all items. + * path = "\sub1\newdir\*.c" - Open the directory /sub1/newdir/ and iterate through all items matching the *.c wildcard. + * + * It is important to distinguish the differences in behaviour between opening a Find operation + * on a path like /sub1 and /sub1/. (/sub1 gets the sub1 dirent from the / dir, whereas /sub/ opens the sub1 dir). + * + * Note, as compatible with other similar APIs, FullFAT also accepts \sub1\* for the same behaviour as + * /sub1/. + * + * For more up-to-date information please see the FullFAT wiki pages. + * * @param pIoman FF_IOMAN object that was created by FF_CreateIOMAN(). * @param pDirent FF_DIRENT object to store the entry information. * @param path String to of the path to the Dir being listed. @@ -1106,60 +1479,78 @@ FF_T_SINT8 FF_PopulateLongDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT * @return -2 if Dir was not found. * **/ +#ifdef FF_UNICODE_SUPPORT +FF_ERROR FF_FindFirst(FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_WCHAR *path) { +#else FF_ERROR FF_FindFirst(FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_INT8 *path) { - FF_T_UINT8 numLFNs; - FF_T_UINT8 EntryBuffer[32]; +#endif +#ifdef FF_UNICODE_SUPPORT + FF_T_UINT16 PathLen = (FF_T_UINT16) wcslen(path); +#else FF_T_UINT16 PathLen = (FF_T_UINT16) strlen(path); +#endif + FF_ERROR Error; + +#ifdef FF_FINDAPI_ALLOW_WILDCARDS + FF_T_UINT16 i = 0; +#ifdef FF_UNICODE_SUPPORT + const FF_T_WCHAR *szWildCard; // Check for a Wild-card. +#else + const FF_T_INT8 *szWildCard; // Check for a Wild-card. +#endif +#endif if(!pIoman) { return FF_ERR_NULL_POINTER; } + // Detect a Wild-Card on the End, or Filename, as apposed to a complete path. +#ifndef FF_FINDAPI_ALLOW_WILDCARDS pDirent->DirCluster = FF_FindDir(pIoman, path, PathLen); // Get the directory cluster, if it exists. +#endif + +#ifdef FF_FINDAPI_ALLOW_WILDCARDS + pDirent->szWildCard[0] = '\0'; // WildCard blank if its not a wildCard. + + szWildCard = &path[PathLen - 1]; + + if(PathLen) { + while(*szWildCard != '\\' && *szWildCard != '/') { // Open the dir of the last token. + i++; + szWildCard--; + if(!(PathLen - i)) { + break; + } + } + } + + pDirent->DirCluster = FF_FindDir(pIoman, path, PathLen - i, &Error); + if(Error) { + return Error; + } + if(pDirent->DirCluster) { + // Valid Dir found, copy the wildCard to filename! +#ifdef FF_UNICODE_SUPPORT + wcsncpy(pDirent->szWildCard, ++szWildCard, FF_MAX_FILENAME); +#else + strncpy(pDirent->szWildCard, ++szWildCard, FF_MAX_FILENAME); +#endif + } +#endif if(pDirent->DirCluster == 0) { return FF_ERR_DIR_INVALID_PATH; } - - for(pDirent->CurrentItem = 0; pDirent->CurrentItem < 0xFFFF; pDirent->CurrentItem += 1) { - if(FF_FetchEntry(pIoman, pDirent->DirCluster, pDirent->CurrentItem, EntryBuffer)) { - return FF_ERR_DIR_END_OF_DIR; - } - if(EntryBuffer[0] != FF_FAT_DELETED) { - if(FF_isEndOfDir(EntryBuffer)){ - return FF_ERR_DIR_END_OF_DIR; - } - pDirent->Attrib = FF_getChar(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_ATTRIB)); - if((pDirent->Attrib & FF_FAT_ATTR_LFN) == FF_FAT_ATTR_LFN) { - // LFN Processing - numLFNs = (FF_T_UINT8)(EntryBuffer[0] & ~0x40); - // Get the shortname and check if it is marked deleted. -#ifdef FF_LFN_SUPPORT - // Fetch the shortname, and get it's checksum, or for a deleted item with - // orphaned LFN entries. - if(FF_FetchEntry(pIoman, pDirent->DirCluster, (pDirent->CurrentItem + numLFNs), EntryBuffer)) { - return FF_ERR_DIR_END_OF_DIR; - } - - if(EntryBuffer[0] != FF_FAT_DELETED) { - FF_PopulateLongDirent(pIoman, pDirent, pDirent->DirCluster, pDirent->CurrentItem); - return FF_ERR_NONE; - } -#else - pDirent->CurrentItem += (numLFNs - 1); -#endif - } else if((pDirent->Attrib & FF_FAT_ATTR_VOLID) == FF_FAT_ATTR_VOLID) { - // Do Nothing - - } else { - FF_PopulateShortDirent(pIoman, pDirent, EntryBuffer); - pDirent->CurrentItem += 1; - return FF_ERR_NONE; - } - } - } - return FF_ERR_DIR_END_OF_DIR; + // Initialise the Fetch Context + Error = FF_InitEntryFetch(pIoman, pDirent->DirCluster, &pDirent->FetchContext); + if(Error) { + return Error; + } + + pDirent->CurrentItem = 0; + + return FF_FindNext(pIoman, pDirent); } /** @@ -1167,16 +1558,17 @@ FF_ERROR FF_FindFirst(FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_INT8 *pat * @brief Get's the next Entry based on the data recorded in the FF_DIRENT object. * * All values recorded in pDirent must be preserved to and between calls to - * FF_FindNext(). + * FF_FindNext(). Please see @see FF_FindFirst() for find initialisation. * * @param pIoman FF_IOMAN object that was created by FF_CreateIOMAN(). - * @param pDirent FF_DIRENT object to store the entry information. + * @param pDirent FF_DIRENT object to store the entry information. (As initialised by FF_FindFirst()). * * @return FF_ERR_DEVICE_DRIVER_FAILED is device access failed. * **/ FF_ERROR FF_FindNext(FF_IOMAN *pIoman, FF_DIRENT *pDirent) { + FF_ERROR Error; FF_T_UINT8 numLFNs; FF_T_UINT8 EntryBuffer[32]; @@ -1185,11 +1577,14 @@ FF_ERROR FF_FindNext(FF_IOMAN *pIoman, FF_DIRENT *pDirent) { } for(; pDirent->CurrentItem < 0xFFFF; pDirent->CurrentItem += 1) { - if(FF_FetchEntry(pIoman, pDirent->DirCluster, pDirent->CurrentItem, EntryBuffer)) { - return FF_ERR_DIR_END_OF_DIR; + Error = FF_FetchEntryWithContext(pIoman, pDirent->CurrentItem, &pDirent->FetchContext, EntryBuffer); + if(Error) { + FF_CleanupEntryFetch(pIoman, &pDirent->FetchContext); + return Error; } if(EntryBuffer[0] != FF_FAT_DELETED) { if(FF_isEndOfDir(EntryBuffer)){ + FF_CleanupEntryFetch(pIoman, &pDirent->FetchContext); return FF_ERR_DIR_END_OF_DIR; } pDirent->Attrib = FF_getChar(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_ATTRIB)); @@ -1200,13 +1595,41 @@ FF_ERROR FF_FindNext(FF_IOMAN *pIoman, FF_DIRENT *pDirent) { #ifdef FF_LFN_SUPPORT // Fetch the shortname, and get it's checksum, or for a deleted item with // orphaned LFN entries. - if(FF_FetchEntry(pIoman, pDirent->DirCluster, (pDirent->CurrentItem + numLFNs), EntryBuffer)) { - return FF_ERR_DIR_END_OF_DIR; + Error = FF_FetchEntryWithContext(pIoman, (pDirent->CurrentItem + numLFNs), &pDirent->FetchContext, EntryBuffer); + if(Error) { + FF_CleanupEntryFetch(pIoman, &pDirent->FetchContext); + return Error; } if(EntryBuffer[0] != FF_FAT_DELETED) { - FF_PopulateLongDirent(pIoman, pDirent, pDirent->DirCluster, pDirent->CurrentItem); + Error = FF_PopulateLongDirent(pIoman, pDirent, pDirent->CurrentItem, &pDirent->FetchContext); + if(Error) { + FF_CleanupEntryFetch(pIoman, &pDirent->FetchContext); + return Error; + } +#ifdef FF_INCLUDE_SHORT_NAME + pDirent->Attrib |= FF_FAT_ATTR_IS_LFN; +#endif + +#ifdef FF_FINDAPI_ALLOW_WILDCARDS +#ifdef FF_UNICODE_SUPPORT + if(wcscmp(pDirent->szWildCard, L"")) { +#else + if(strcmp(pDirent->szWildCard, "")) { +#endif + if(FF_wildcompare(pDirent->szWildCard, pDirent->FileName)) { + FF_CleanupEntryFetch(pIoman, &pDirent->FetchContext); + return FF_ERR_NONE; + } + pDirent->CurrentItem -= 1; + } else { + FF_CleanupEntryFetch(pIoman, &pDirent->FetchContext); + return FF_ERR_NONE; + } +#else + FF_CleanupEntryFetch(pIoman, &pDirent->FetchContext); return FF_ERR_NONE; +#endif } #else pDirent->CurrentItem += (numLFNs - 1); @@ -1216,11 +1639,37 @@ FF_ERROR FF_FindNext(FF_IOMAN *pIoman, FF_DIRENT *pDirent) { } else { FF_PopulateShortDirent(pIoman, pDirent, EntryBuffer); +#if defined(FF_SHORTNAME_CASE) + // Apply NT/XP+ bits to get correct case + FF_CaseShortName(pDirent->FileName, FF_getChar(EntryBuffer, FF_FAT_CASE_OFFS)); +#endif +#ifdef FF_FINDAPI_ALLOW_WILDCARDS +#ifdef FF_UNICODE_SUPPORT + if(wcscmp(pDirent->szWildCard, L"")) { +#else + if(strcmp(pDirent->szWildCard, "")) { +#endif + if(FF_wildcompare(pDirent->szWildCard, pDirent->FileName)) { + FF_CleanupEntryFetch(pIoman, &pDirent->FetchContext); + pDirent->CurrentItem += 1; + return FF_ERR_NONE; + } + } else { + FF_CleanupEntryFetch(pIoman, &pDirent->FetchContext); + pDirent->CurrentItem += 1; + return FF_ERR_NONE; + } +#else + + FF_CleanupEntryFetch(pIoman, &pDirent->FetchContext); pDirent->CurrentItem += 1; return FF_ERR_NONE; +#endif } } } + + FF_CleanupEntryFetch(pIoman, &pDirent->FetchContext); return FF_ERR_DIR_END_OF_DIR; } @@ -1234,30 +1683,55 @@ FF_T_SINT8 FF_RewindFind(FF_IOMAN *pIoman, FF_DIRENT *pDirent) { return 0; } +/* + Returns >= 0 for a free dirent entry. + Returns < 0 with and Error code if anything goes wrong. +*/ +static FF_T_SINT32 FF_FindFreeDirent(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 Sequential) { -FF_T_SINT32 FF_FindFreeDirent(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 Sequential) { + FF_T_UINT8 EntryBuffer[32]; + FF_T_UINT16 i = 0; + FF_T_UINT16 nEntry; + FF_ERROR Error; + FF_T_UINT32 DirLength; + FF_FETCH_CONTEXT FetchContext; - FF_T_UINT8 EntryBuffer[32]; - FF_T_UINT16 i = 0; - FF_T_UINT16 nEntry; - FF_T_SINT8 RetVal; - FF_T_UINT32 DirLength; - FF_T_UINT32 iEndOfChain; + Error = FF_InitEntryFetch(pIoman, DirCluster, &FetchContext); + if(Error) { + return Error; + } for(nEntry = 0; nEntry < 0xFFFF; nEntry++) { - if(FF_FetchEntry(pIoman, DirCluster, nEntry, EntryBuffer) == FF_ERR_DIR_END_OF_DIR) { - RetVal = FF_ExtendDirectory(pIoman, DirCluster); - if(RetVal != FF_ERR_NONE) { - return RetVal; + Error = FF_FetchEntryWithContext(pIoman, nEntry, &FetchContext, EntryBuffer); + if(Error == FF_ERR_DIR_END_OF_DIR) { + + Error = FF_ExtendDirectory(pIoman, DirCluster); + FF_CleanupEntryFetch(pIoman, &FetchContext); + + if(Error) { + return Error; } + return nEntry; + } else { + if(Error) { + FF_CleanupEntryFetch(pIoman, &FetchContext); + return Error; + } } if(FF_isEndOfDir(EntryBuffer)) { // If its the end of the Dir, then FreeDirents from here. // Check Dir is long enough! - DirLength = FF_GetChainLength(pIoman, DirCluster, &iEndOfChain); + DirLength = FetchContext.ulChainLength;//FF_GetChainLength(pIoman, DirCluster, &iEndOfChain); if((nEntry + Sequential) > (FF_T_UINT16)(((pIoman->pPartition->SectorsPerCluster * pIoman->pPartition->BlkSize) * DirLength) / 32)) { - FF_ExtendDirectory(pIoman, DirCluster); + Error = FF_ExtendDirectory(pIoman, DirCluster); } + + FF_CleanupEntryFetch(pIoman, &FetchContext); + + if(Error) { + return Error; + } + return nEntry; } if(EntryBuffer[0] == 0xE5) { @@ -1267,36 +1741,48 @@ FF_T_SINT32 FF_FindFreeDirent(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UIN } if(i == Sequential) { + FF_CleanupEntryFetch(pIoman, &FetchContext); return (nEntry - (Sequential - 1));// Return the beginning entry in the sequential sequence. } } - return FF_ERR_DIR_DIRECTORY_FULL; + FF_CleanupEntryFetch(pIoman, &FetchContext); + + return FF_ERR_DIR_DIRECTORY_FULL; } -FF_T_SINT8 FF_PutEntry(FF_IOMAN *pIoman, FF_T_UINT16 Entry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent) { +FF_ERROR FF_PutEntry(FF_IOMAN *pIoman, FF_T_UINT16 Entry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent) { FF_BUFFER *pBuffer; + FF_ERROR Error; FF_T_UINT32 itemLBA; FF_T_UINT32 clusterNum = FF_getClusterChainNumber (pIoman, Entry, (FF_T_UINT16)32); FF_T_UINT32 relItem = FF_getMinorBlockEntry (pIoman, Entry, (FF_T_UINT16)32); - FF_T_UINT32 clusterAddress = FF_TraverseFAT(pIoman, DirCluster, clusterNum); + FF_T_UINT32 clusterAddress = FF_TraverseFAT(pIoman, DirCluster, clusterNum, &Error); + + if(Error) { + return Error; + } itemLBA = FF_Cluster2LBA(pIoman, clusterAddress) + FF_getMajorBlockNumber(pIoman, Entry, (FF_T_UINT16)32); itemLBA = FF_getRealLBA (pIoman, itemLBA) + FF_getMinorBlockNumber(pIoman, relItem, (FF_T_UINT16)32); pBuffer = FF_GetBuffer(pIoman, itemLBA, FF_MODE_WRITE); { + if(!pBuffer) { + return FF_ERR_DEVICE_DRIVER_FAILED; + } // Modify the Entry! //memcpy((pBuffer->pBuffer + (32*relItem)), pDirent->FileName, 11); - FF_putChar(pBuffer->pBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_ATTRIB + (32 * relItem)), pDirent->Attrib); - FF_putShort(pBuffer->pBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_CLUS_HIGH + (32 * relItem)), (FF_T_UINT16)(pDirent->ObjectCluster >> 16)); - FF_putShort(pBuffer->pBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_CLUS_LOW + (32 * relItem)), (FF_T_UINT16)(pDirent->ObjectCluster)); - FF_putLong(pBuffer->pBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_FILESIZE + (32 * relItem)), pDirent->Filesize); + relItem *= 32; + FF_putChar(pBuffer->pBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_ATTRIB + relItem), pDirent->Attrib); + FF_putShort(pBuffer->pBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_CLUS_HIGH + relItem), (FF_T_UINT16)(pDirent->ObjectCluster >> 16)); + FF_putShort(pBuffer->pBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_CLUS_LOW + relItem), (FF_T_UINT16)(pDirent->ObjectCluster)); + FF_putLong(pBuffer->pBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_FILESIZE + relItem), pDirent->Filesize); #ifdef FF_TIME_SUPPORT - FF_PlaceDate((pBuffer->pBuffer + (32 * relItem)), FF_FAT_DIRENT_LASTACC_DATE); // Last accessed date. + FF_PlaceDate((pBuffer->pBuffer + relItem), FF_FAT_DIRENT_LASTACC_DATE); // Last accessed date. #endif } FF_ReleaseBuffer(pIoman, pBuffer); @@ -1304,143 +1790,200 @@ FF_T_SINT8 FF_PutEntry(FF_IOMAN *pIoman, FF_T_UINT16 Entry, FF_T_UINT32 DirClust return 0; } +FF_T_BOOL FF_ValidShortChar (FF_T_INT8 Chr) +{ + return (Chr >= 'A' && Chr <= 'Z') || +#if defined(FF_SHORTNAME_CASE) + (Chr >= 'a' && Chr <= 'z') || // lower-case can be stored using NT/XP attribute +#endif + (Chr >= '0' && Chr <= '9') || + strchr ("$%-_@~`!(){}^#&", Chr) != NULL; +} -/*static FF_T_BOOL FF_isShortName(const FF_T_UINT8 *Name, FF_T_UINT16 StrLen) { - FF_T_UINT16 i; - for(i = 0; i < StrLen; i++) { - if(Name[i] == '.') { - i--; - } - } - if(i < 11) { - return FF_TRUE; - } - return FF_FALSE; -}*/ +FF_T_BOOL FF_ValidLongChar (FF_T_INT8 Chr) +{ + return Chr >= 0x20 && strchr ("/\\:*?\"<>|", Chr) == NULL; +} +#ifdef FF_UNICODE_SUPPORT +FF_T_SINT8 FF_CreateShortName(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_WCHAR *ShortName, FF_T_WCHAR *LongName) { +#else FF_T_SINT8 FF_CreateShortName(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *ShortName, FF_T_INT8 *LongName) { - FF_T_UINT16 i,x,y; - FF_T_INT8 TempName[FF_MAX_FILENAME]; +#endif + FF_T_UINT8 caseAttrib = 0; +#if defined(FF_SHORTNAME_CASE) + FF_T_UINT8 testAttrib = FF_FAT_CASE_ATTR_BASE; +#endif + + FF_T_UINT16 i,x,y,last_dot; + FF_T_UINT16 first_tilde = 6; +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR MyShortName[13]; +#else FF_T_INT8 MyShortName[13]; - FF_T_UINT16 NameLen; - FF_T_BOOL FitsShort = FF_FALSE; +#endif + FF_T_UINT16 NameLen; + FF_T_BOOL FitsShort = FF_TRUE; FF_DIRENT MyDir; + FF_T_BOOL found; //FF_T_SINT8 RetVal = 0; FF_T_INT8 NumberBuf[6]; - // Create a Short Name - strncpy(TempName, LongName, FF_MAX_FILENAME); - NameLen = (FF_T_UINT16) strlen(TempName); - FF_toupper(TempName, NameLen); + FF_ERROR Error; - // Initialise Shortname - - for(i = 0; i < 11; i++) { - ShortName[i] = 0x20; - } +#ifdef FF_UNICODE_SUPPORT + NameLen = (FF_T_UINT16) wcslen(LongName); +#else + NameLen = (FF_T_UINT16) strlen(LongName); +#endif // Does LongName fit a shortname? - for(i = 0, x = 0; i < NameLen; i++) { - if(TempName[i] != '.') { + for(i = 0, x = 0, last_dot = NameLen; i < NameLen; i++) { + if(LongName[i] != '.') { x++; - } - } - - if(x <= 11) { - //FitsShort = FF_TRUE; - } - - // Main part of the name - for(i = 0, x = 0; i < 8; i++, x++) { - if(i == 0 && TempName[x] == '.') { - i--; } else { - if(TempName[x] == '.') { - break; - } else if(TempName[x] == ' ') { - i--; - } else { - ShortName[i] = TempName[x]; - if(ShortName[i] == 0x00) { - ShortName[i] = 0x20; - } - } - } - } - - for(i = NameLen; i > x; i--) { - if(TempName[i] == '.') { - break; + last_dot = i; } } - if(TempName[i] == '.') { - x = i + 1; - for(i = 0; i < 3; i++) { - if(x < NameLen) { - ShortName[8 + i] = TempName[x++]; + if (NameLen > 12 || NameLen-x > 1 || NameLen-last_dot > 4 || last_dot > 8) { + FitsShort = FF_FALSE; + } + + for(i = 0, x = 0; i < 11; x++) { + FF_T_INT8 ch = (FF_T_INT8) LongName[x]; + if (!ch) + break; + if (x == last_dot) { + while (i < 8) + ShortName[i++] = 0x20; +#if defined(FF_SHORTNAME_CASE) + testAttrib = FF_FAT_CASE_ATTR_EXT; +#endif + } else { + if (i == 8) { + x = last_dot; + ch = (FF_T_INT8) LongName[x]; + if (ch) + ch = (FF_T_INT8) LongName[++x]; +#if defined(FF_SHORTNAME_CASE) + testAttrib = FF_FAT_CASE_ATTR_EXT; +#endif } + if (!FF_ValidShortChar (ch)) { + FitsShort = FF_FALSE; + continue; + } + if (ch >= 'a' && ch <= 'z') { + ch -= 0x20; +#if defined(FF_SHORTNAME_CASE) + if (testAttrib) + caseAttrib |= testAttrib; + else + FitsShort = FF_FALSE; // We had capital: does not fit + } else if (ch >= 'A' && ch <= 'Z') { + if (caseAttrib & testAttrib) + FitsShort = FF_FALSE; // We had lower-case: does not fit + testAttrib = 0; +#endif + } + ShortName[i++] = ch; } } + while (i < 11) + ShortName[i++] = 0x20; + if (last_dot < first_tilde) + first_tilde = last_dot; + if (NameLen < first_tilde) // Names like "Abc" will become "~Abc" + first_tilde = NameLen; // Tail : memcpy(MyShortName, ShortName, 11); FF_ProcessShortName(MyShortName); - - if(!FF_FindEntryInDir(pIoman, DirCluster, MyShortName, 0x00, &MyDir) && FitsShort) { - return 0; - } else { - if(FitsShort) { - return FF_ERR_DIR_OBJECT_EXISTS; - } - for(i = 1; i < 0x0000FFFF; i++) { // Max Number of Entries in a DIR! - sprintf(NumberBuf, "%d", i); - NameLen = (FF_T_UINT16) strlen(NumberBuf); - x = 7 - NameLen; - ShortName[x++] = '~'; - for(y = 0; y < NameLen; y++) { - ShortName[x+y] = NumberBuf[y]; - } - memcpy(MyShortName, ShortName, 11); - FF_ProcessShortName(MyShortName); - if(!FF_ShortNameExists(pIoman, DirCluster, MyShortName)) { - return 0; - } - } - // Add a tail and special number until we're happy :D + found = (FF_T_BOOL) FF_FindEntryInDir(pIoman, DirCluster, MyShortName, 0x00, &MyDir, &Error); +#ifdef Hein_Tibosch + if (verboseLevel >= 1) logPrintf ("Long Name: %-14.14s Short '%s' (%s) Fit '%d' Found %d\n", LongName, ShortName, MyShortName, FitsShort, found); +#endif + if(FitsShort && !found) { + return caseAttrib | 0x01; } + if(FitsShort) { + return FF_ERR_DIR_OBJECT_EXISTS; + } + for(i = 1; i < 0x0000FFFF; i++) { // Max Number of Entries in a DIR! + sprintf(NumberBuf, "%d", i); + NameLen = (FF_T_UINT16) strlen(NumberBuf); + x = 7 - NameLen; + if (x > first_tilde) + x = first_tilde; + ShortName[x++] = '~'; + for(y = 0; y < NameLen; y++) { + ShortName[x+y] = NumberBuf[y]; + } + memcpy(MyShortName, ShortName, 11); + FF_ProcessShortName(MyShortName); + found = FF_ShortNameExists(pIoman, DirCluster, MyShortName, &Error); +#ifdef Hein_Tibosch + if (verboseLevel >= 1) logPrintf ("Long Name: %-14.14s Short '%s' (%s) Fit '%d' Found %d\n", LongName, ShortName, MyShortName, FitsShort, found); +#endif + if(!found) { +#ifdef FF_HASH_CACHE +#if FF_HASH_FUNCTION == CRC16 + FF_AddDirentHash(pIoman, DirCluster, (FF_T_UINT32) FF_GetCRC16((FF_T_UINT8*)MyShortName, strlen(MyShortName))); +#elif FF_HASH_FUNCTION == CRC8 + FF_AddDirentHash(pIoman, DirCluster, (FF_T_UINT32) FF_GetCRC8((FF_T_UINT8*)MyShortName, strlen(MyShortName))); +#endif +#endif + return 0; + } + } + // Add a tail and special number until we're happy :D return FF_ERR_DIR_DIRECTORY_FULL; } + + #ifdef FF_LFN_SUPPORT -static FF_T_SINT8 FF_CreateLFNEntry(FF_T_UINT8 *EntryBuffer, FF_T_INT8 *Name, FF_T_UINT8 NameLen, FF_T_UINT8 nLFN, FF_T_UINT8 CheckSum) { +static FF_T_SINT8 FF_CreateLFNEntry(FF_T_UINT8 *EntryBuffer, FF_T_UINT16 *Name, FF_T_UINT uiNameLen, FF_T_UINT uiLFN, FF_T_UINT8 CheckSum) { - FF_T_UINT8 i, x; + FF_T_UINT i, x; memset(EntryBuffer, 0, 32); - FF_putChar(EntryBuffer, FF_FAT_LFN_ORD, (FF_T_UINT8) ((nLFN & ~0x40))); + FF_putChar(EntryBuffer, FF_FAT_LFN_ORD, (FF_T_UINT8) ((uiLFN & ~0x40))); FF_putChar(EntryBuffer, FF_FAT_DIRENT_ATTRIB, (FF_T_UINT8) FF_FAT_ATTR_LFN); FF_putChar(EntryBuffer, FF_FAT_LFN_CHECKSUM, (FF_T_UINT8) CheckSum); // Name_1 for(i = 0, x = 0; i < 5; i++, x += 2) { - if(i < NameLen) { - EntryBuffer[FF_FAT_LFN_NAME_1 + x] = Name[i]; - } else if (i == NameLen) { - EntryBuffer[FF_FAT_LFN_NAME_1 + x] = '\0'; - }else { - EntryBuffer[FF_FAT_LFN_NAME_1 + x] = 0xFF; - EntryBuffer[FF_FAT_LFN_NAME_1 + x + 1] = 0xFF; + if(i < uiNameLen) + { + memcpy(&EntryBuffer[FF_FAT_LFN_NAME_1 + x], &Name[i], sizeof(FF_T_UINT16)); + //bobtntfullfat *((FF_T_UINT16 *) &EntryBuffer[FF_FAT_LFN_NAME_1 + x]) = Name[i]; } + else + if (i == uiNameLen) + { + EntryBuffer[FF_FAT_LFN_NAME_1 + x] = '\0'; + EntryBuffer[FF_FAT_LFN_NAME_1 + x + 1] = '\0'; + } + else + { + EntryBuffer[FF_FAT_LFN_NAME_1 + x] = 0xFF; + EntryBuffer[FF_FAT_LFN_NAME_1 + x + 1] = 0xFF; + } } // Name_2 for(i = 0, x = 0; i < 6; i++, x += 2) { - if((i + 5) < NameLen) { - EntryBuffer[FF_FAT_LFN_NAME_2 + x] = Name[i+5]; - } else if ((i + 5) == NameLen) { - EntryBuffer[FF_FAT_LFN_NAME_2 + x] = '\0'; + if((i + 5) < uiNameLen) + { + memcpy(&EntryBuffer[FF_FAT_LFN_NAME_2 + x], &Name[i+5], sizeof(FF_T_UINT16)); + //EntryBuffer[FF_FAT_LFN_NAME_2 + x] = Name[i+5]; + //bobtntfullfat *((FF_T_UINT16 *) &EntryBuffer[FF_FAT_LFN_NAME_2 + x]) = Name[i+5]; + } else if ((i + 5) == uiNameLen) { + EntryBuffer[FF_FAT_LFN_NAME_2 + x] = '\0'; + EntryBuffer[FF_FAT_LFN_NAME_2 + x + 1] = '\0'; }else { EntryBuffer[FF_FAT_LFN_NAME_2 + x] = 0xFF; EntryBuffer[FF_FAT_LFN_NAME_2 + x + 1] = 0xFF; @@ -1449,10 +1992,14 @@ static FF_T_SINT8 FF_CreateLFNEntry(FF_T_UINT8 *EntryBuffer, FF_T_INT8 *Name, FF // Name_3 for(i = 0, x = 0; i < 2; i++, x += 2) { - if((i + 11) < NameLen) { - EntryBuffer[FF_FAT_LFN_NAME_3 + x] = Name[i+11]; - } else if ((i + 11) == NameLen) { - EntryBuffer[FF_FAT_LFN_NAME_3 + x] = '\0'; + if((i + 11) < uiNameLen) + { + memcpy(&EntryBuffer[FF_FAT_LFN_NAME_3 + x], &Name[i+11], sizeof(FF_T_UINT16)); + //EntryBuffer[FF_FAT_LFN_NAME_3 + x] = Name[i+11]; + //bobtntfullfat *((FF_T_UINT16 *) &EntryBuffer[FF_FAT_LFN_NAME_3 + x]) = Name[i+11]; + } else if ((i + 11) == uiNameLen) { + EntryBuffer[FF_FAT_LFN_NAME_3 + x] = '\0'; + EntryBuffer[FF_FAT_LFN_NAME_3 + x + 1] = '\0'; }else { EntryBuffer[FF_FAT_LFN_NAME_3 + x] = 0xFF; EntryBuffer[FF_FAT_LFN_NAME_3 + x + 1] = 0xFF; @@ -1461,13 +2008,26 @@ static FF_T_SINT8 FF_CreateLFNEntry(FF_T_UINT8 *EntryBuffer, FF_T_INT8 *Name, FF return FF_ERR_NONE; } +#endif -static FF_T_SINT8 FF_CreateLFNs(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *Name, FF_T_UINT8 CheckSum, FF_T_UINT16 nEntry) { +/* +#ifdef FF_UNICODE_SUPPORT +static FF_ERROR FF_CreateLFNs(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_WCHAR *Name, FF_T_UINT8 CheckSum, FF_T_UINT16 nEntry) { +#else +static FF_ERROR FF_CreateLFNs(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *Name, FF_T_UINT8 CheckSum, FF_T_UINT16 nEntry) { +#endif FF_T_UINT8 EntryBuffer[32]; +#ifdef FF_UNICODE_SUPPORT + FF_T_UINT16 NameLen = (FF_T_UINT16) wcslen(Name); +#else FF_T_UINT16 NameLen = (FF_T_UINT16) strlen(Name); +#endif FF_T_UINT8 NumLFNs = (FF_T_UINT8) (NameLen / 13); FF_T_UINT8 i; FF_T_UINT8 EndPos = (NameLen % 13); + FF_ERROR Error; + + FF_FETCH_CONTEXT FetchContext; if(EndPos) { NumLFNs ++; @@ -1475,6 +2035,11 @@ static FF_T_SINT8 FF_CreateLFNs(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_I EndPos = 13; } + Error = FF_InitEntryFetch(pIoman, DirCluster, &FetchContext); + if(Error) { + return Error; + } + for(i = NumLFNs; i > 0; i--) { if(i == NumLFNs) { FF_CreateLFNEntry(EntryBuffer, (Name + (13 * (i - 1))), EndPos, i, CheckSum); @@ -1482,16 +2047,143 @@ static FF_T_SINT8 FF_CreateLFNs(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_I } else { FF_CreateLFNEntry(EntryBuffer, (Name + (13 * (i - 1))), 13, i, CheckSum); } - FF_PushEntry(pIoman, DirCluster, nEntry + (NumLFNs - i), EntryBuffer); + + Error = FF_PushEntryWithContext(pIoman, nEntry + (NumLFNs - i), &FetchContext, EntryBuffer); + if(Error) { + FF_CleanupEntryFetch(pIoman, &FetchContext); + return Error; + } } + FF_CleanupEntryFetch(pIoman, &FetchContext); + return FF_ERR_NONE; } #endif +*/ -FF_T_SINT8 FF_ExtendDirectory(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster) { + +#ifdef FF_UNICODE_SUPPORT +static FF_ERROR FF_CreateLFNs(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_WCHAR *Name, FF_T_UINT8 CheckSum, FF_T_UINT16 nEntry) { +#else +static FF_ERROR FF_CreateLFNs(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *Name, FF_T_UINT8 CheckSum, FF_T_UINT16 nEntry) { +#endif + FF_ERROR Error; + FF_T_UINT uiNumLFNs; + FF_T_UINT uiEndPos; + FF_T_UINT i,y; + +#ifdef FF_UNICODE_UTF8_SUPPORT + FF_T_SINT32 slRetVal; +#endif + +#ifndef FF_UNICODE_SUPPORT +#ifndef FF_UNICODE_UTF8_SUPPORT + FF_T_UINT16 *pUtf16; +#endif +#endif + + FF_FETCH_CONTEXT FetchContext; + + FF_T_UINT8 EntryBuffer[32]; + FF_T_UINT16 usUtf16Name[FF_MAX_FILENAME + 1]; + + +#ifdef FF_UNICODE_SUPPORT +#if WCHAR_MAX <= 0xFFFF + y = wcslen(Name); + if(y > FF_MAX_FILENAME) { + return FF_ERR_DIR_NAME_TOO_LONG; + } + wcsncpy(usUtf16Name, Name, FF_MAX_FILENAME); +#else + i = 0; + y = 0; + while(Name[i]) { + FF_Utf32ctoUtf16c(&usUtf16Name[y], (FF_T_UINT32) Name[i], FF_MAX_FILENAME - i); + y += FF_GetUtf16SequenceLen(usUtf16Name[y]); + i++; + if(y > FF_MAX_FILENAME) { + return FF_ERR_DIR_NAME_TOO_LONG; + } + } +#endif +#endif + + // Convert the name into UTF-16 format. +#ifdef FF_UNICODE_UTF8_SUPPORT + // Simply convert the UTF8 to UTF16 and be done with it. + i = 0; + y = 0; + while(Name[i]) { + slRetVal = FF_Utf8ctoUtf16c(&usUtf16Name[y], (FF_T_UINT8 *)&Name[i], FF_MAX_FILENAME - i); + if(slRetVal > 0) { + i += slRetVal; + } else { + break; // No more space in the UTF-16 buffer, simply truncate for safety. + } + y += FF_GetUtf16SequenceLen(usUtf16Name[y]); + if(y > FF_MAX_FILENAME) { + return FF_ERR_DIR_NAME_TOO_LONG; + } + } +#else +#ifndef FF_UNICODE_SUPPORT + i = 0; + y = strlen(Name); + if(y > FF_MAX_FILENAME) { + return FF_ERR_DIR_NAME_TOO_LONG; + } + pUtf16 = usUtf16Name; + while(Name[i]) { + usUtf16Name[i] = (FF_T_UINT16) Name[i]; + i++; + } +#endif +#endif + + // Whole name is now in a valid UTF-16 format. Lets go make thos LFN's. + // i should at this point be the length of the name. + + uiNumLFNs = y / 13; // Number of LFNs is the total number of UTF-16 units, divided by 13 (13 units per LFN). + uiEndPos = y % 13; // The ending position in an LFN, of the last LFN UTF-16 charachter. + + if(uiEndPos) { + uiNumLFNs++; + } else { + uiEndPos = 13; + } + + Error = FF_InitEntryFetch(pIoman, DirCluster, &FetchContext); + if(Error) { + return Error; + } + + // After this point, i is no longer the length of the Filename in UTF-16 units. + for(i = uiNumLFNs; i > 0; i--) { + if(i == uiNumLFNs) { + FF_CreateLFNEntry(EntryBuffer, (usUtf16Name + (13 * (i - 1))), uiEndPos, i, CheckSum); + EntryBuffer[0] |= 0x40; + } else { + FF_CreateLFNEntry(EntryBuffer, (usUtf16Name + (13 * (i - 1))), 13, i, CheckSum); + } + + Error = FF_PushEntryWithContext(pIoman, nEntry + (uiNumLFNs - i), &FetchContext, EntryBuffer); + if(Error) { + FF_CleanupEntryFetch(pIoman, &FetchContext); + return Error; + } + } + + FF_CleanupEntryFetch(pIoman, &FetchContext); + + return FF_ERR_NONE; +} + +FF_ERROR FF_ExtendDirectory(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster) { FF_T_UINT32 CurrentCluster; FF_T_UINT32 NextCluster; + FF_ERROR Error; if(pIoman->pPartition->Type != FF_T_FAT32) { if(DirCluster == pIoman->pPartition->RootDirCluster) { @@ -1500,7 +2192,10 @@ FF_T_SINT8 FF_ExtendDirectory(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster) { } if(!pIoman->pPartition->FreeClusterCount) { - pIoman->pPartition->FreeClusterCount = FF_CountFreeClusters(pIoman); + pIoman->pPartition->FreeClusterCount = FF_CountFreeClusters(pIoman, &Error); + if(Error) { + return Error; + } if(pIoman->pPartition->FreeClusterCount == 0) { return FF_ERR_FAT_NO_FREE_CLUSTERS; } @@ -1508,20 +2203,52 @@ FF_T_SINT8 FF_ExtendDirectory(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster) { FF_lockFAT(pIoman); { - CurrentCluster = FF_FindEndOfChain(pIoman, DirCluster); - NextCluster = FF_FindFreeCluster(pIoman); - FF_putFatEntry(pIoman, CurrentCluster, NextCluster); - FF_putFatEntry(pIoman, NextCluster, 0xFFFFFFFF); + CurrentCluster = FF_FindEndOfChain(pIoman, DirCluster, &Error); + if(Error) { + FF_unlockFAT(pIoman); + return Error; + } + + NextCluster = FF_FindFreeCluster(pIoman, &Error); + if(Error) { + FF_unlockFAT(pIoman); + return Error; + } + + Error = FF_putFatEntry(pIoman, CurrentCluster, NextCluster); + if(Error) { + FF_unlockFAT(pIoman); + return Error; + } + + Error = FF_putFatEntry(pIoman, NextCluster, 0xFFFFFFFF); + if(Error) { + FF_unlockFAT(pIoman); + return Error; + } } FF_unlockFAT(pIoman); - FF_ClearCluster(pIoman, NextCluster); - FF_DecreaseFreeClusters(pIoman, 1); + Error = FF_ClearCluster(pIoman, NextCluster); + if(Error) { + FF_unlockFAT(pIoman); + return Error; + } + + Error = FF_DecreaseFreeClusters(pIoman, 1); + if(Error) { + FF_unlockFAT(pIoman); + return Error; + } return FF_ERR_NONE; } -static void FF_MakeNameCompliant(FF_T_INT8 *Name) { +#ifdef FF_UNICODE_SUPPORT +static void FF_MakeNameCompliant(FF_T_WCHAR *Name) { +#else +static void FF_MakeNameCompliant(FF_T_UINT8 *Name) { +#endif if((FF_T_UINT8) Name[0] == 0xE5) { // Support Japanese KANJI symbol. Name[0] = 0x05; @@ -1531,7 +2258,7 @@ static void FF_MakeNameCompliant(FF_T_INT8 *Name) { if(*Name < 0x20 || *Name == 0x7F || *Name == 0x22 || *Name == 0x7C) { // Leave all extended chars as they are. *Name = '_'; } - if(*Name >= 0x2A && *Name <= 0x2F && *Name != 0x2B && *Name != 0x2E) { + if(*Name >= 0x2A && *Name <= 0x2F && *Name != 0x2B && *Name != 0x2E && *Name != 0x2D) { *Name = '_'; } if(*Name >= 0x3A && *Name <= 0x3F) { @@ -1544,23 +2271,43 @@ static void FF_MakeNameCompliant(FF_T_INT8 *Name) { } } -FF_T_SINT8 FF_CreateDirent(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent) { +FF_ERROR FF_CreateDirent(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent) { FF_T_UINT8 EntryBuffer[32]; +#ifdef FF_UNICODE_SUPPORT + FF_T_UINT16 NameLen = (FF_T_UINT16) wcslen(pDirent->FileName); +#else FF_T_UINT16 NameLen = (FF_T_UINT16) strlen(pDirent->FileName); +#endif FF_T_UINT8 numLFNs = (FF_T_UINT8) (NameLen / 13); FF_T_SINT32 FreeEntry; - FF_T_SINT8 RetVal = 0; + FF_ERROR RetVal = FF_ERR_NONE; FF_T_UINT8 Entries; + + FF_FETCH_CONTEXT FetchContext; + #ifdef FF_LFN_SUPPORT FF_T_UINT8 CheckSum; #endif +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR UTF16EntryBuffer[32]; +#if WCHAR_MAX > 0xFFFF + // Check that the filename won't exceed the max LFN length if converted to UTF-16. + /*if(FF_Utf32GetUtf16Len((FF_T_UINT32 *) pDirent->FileName) > FF_MAX_FILENAME) { + return FF_ERR_UNICODE_CONVERSION_EXCEEDED; + }*/ +#endif + +#endif + +#ifdef FF_UNICODE_SUPPORT FF_MakeNameCompliant(pDirent->FileName); // Ensure we don't break the Dir tables. +#else + FF_MakeNameCompliant((FF_T_UINT8 *)pDirent->FileName); // Ensure we don't break the Dir tables. +#endif memset(EntryBuffer, 0, 32); - - if(NameLen % 13) { numLFNs ++; } @@ -1576,10 +2323,18 @@ FF_T_SINT8 FF_CreateDirent(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT * FF_lockDIR(pIoman); { if((FreeEntry = FF_FindFreeDirent(pIoman, DirCluster, Entries)) >= 0) { +#ifdef FF_UNICODE_SUPPORT + //FF_cstrntowcs(UTF16EntryBuffer, (FF_T_INT8 *) EntryBuffer, 32); + RetVal = FF_CreateShortName(pIoman, DirCluster, UTF16EntryBuffer, pDirent->FileName); +#else RetVal = FF_CreateShortName(pIoman, DirCluster, (FF_T_INT8 *) EntryBuffer, pDirent->FileName); +#endif - if(!RetVal) { + //if(!RetVal) { #ifdef FF_LFN_SUPPORT +#ifdef FF_UNICODE_SUPPORT + FF_wcsntocstr((FF_T_INT8 *) EntryBuffer, UTF16EntryBuffer, 11); +#endif CheckSum = FF_CreateChkSum(EntryBuffer); FF_CreateLFNs(pIoman, DirCluster, pDirent->FileName, CheckSum, (FF_T_UINT16) FreeEntry); #else @@ -1598,10 +2353,24 @@ FF_T_SINT8 FF_CreateDirent(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT * FF_putShort(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_CLUS_LOW), (FF_T_UINT16)(pDirent->ObjectCluster)); FF_putLong(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_FILESIZE), pDirent->Filesize); - FF_PushEntry(pIoman, DirCluster, (FF_T_UINT16) (FreeEntry + numLFNs), EntryBuffer); - } + RetVal = FF_InitEntryFetch(pIoman, DirCluster, &FetchContext); + if(RetVal) { + FF_unlockDIR(pIoman); + return RetVal; + } + RetVal = FF_PushEntryWithContext(pIoman, (FF_T_UINT16) (FreeEntry + numLFNs), &FetchContext, EntryBuffer); + FF_CleanupEntryFetch(pIoman, &FetchContext); + if(RetVal) { + FF_unlockDIR(pIoman); + return RetVal; + } + /*} else { + FF_unlockDIR(pIoman); + return RetVal; + }*/ }else { - RetVal = (FF_T_SINT8) FreeEntry; + FF_unlockDIR(pIoman); + return FreeEntry; } } FF_unlockDIR(pIoman); @@ -1614,19 +2383,36 @@ FF_T_SINT8 FF_CreateDirent(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT * pDirent->CurrentItem = (FF_T_UINT16) (FreeEntry + numLFNs); } - return 0; + return FF_ERR_NONE; } -FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *FileName, FF_DIRENT *pDirent) { - FF_DIRENT MyFile; + +#ifdef FF_UNICODE_SUPPORT +FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_WCHAR *FileName, FF_DIRENT *pDirent, FF_ERROR *pError) { +#else +FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *FileName, FF_DIRENT *pDirent, FF_ERROR *pError) { +#endif + FF_DIRENT MyFile; + *pError = FF_ERR_NONE; +#ifdef FF_UNICODE_SUPPORT + wcsncpy(MyFile.FileName, FileName, FF_MAX_FILENAME); +#else strncpy(MyFile.FileName, FileName, FF_MAX_FILENAME); +#endif MyFile.Attrib = 0x00; MyFile.Filesize = 0; - MyFile.ObjectCluster = FF_CreateClusterChain(pIoman); + MyFile.ObjectCluster = FF_CreateClusterChain(pIoman, pError); + if(*pError) { + FF_UnlinkClusterChain(pIoman, MyFile.ObjectCluster, 0); + FF_FlushCache(pIoman); + return 0; + } MyFile.CurrentItem = 0; - if(FF_CreateDirent(pIoman, DirCluster, &MyFile)) { + *pError = FF_CreateDirent(pIoman, DirCluster, &MyFile); + + if(*pError) { FF_UnlinkClusterChain(pIoman, MyFile.ObjectCluster, 0); FF_FlushCache(pIoman); return 0; @@ -1653,20 +2439,34 @@ FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *F * @return FF_ERR_DIR_INVALID_PATH * @return FF_ERR_NONE on success. **/ +#ifdef FF_UNICODE_SUPPORT +FF_ERROR FF_MkDir(FF_IOMAN *pIoman, const FF_T_WCHAR *Path) { +#else FF_ERROR FF_MkDir(FF_IOMAN *pIoman, const FF_T_INT8 *Path) { +#endif FF_DIRENT MyDir; FF_T_UINT32 DirCluster; +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR DirName[FF_MAX_FILENAME]; +#else FF_T_INT8 DirName[FF_MAX_FILENAME]; +#endif FF_T_UINT8 EntryBuffer[32]; FF_T_UINT32 DotDotCluster; FF_T_UINT16 i; - FF_T_SINT8 RetVal = 0; + FF_ERROR Error = FF_ERR_NONE; + + FF_FETCH_CONTEXT FetchContext; if(!pIoman) { return FF_ERR_NULL_POINTER; } +#ifdef FF_UNICODE_SUPPORT + i = (FF_T_UINT16) wcslen(Path); +#else i = (FF_T_UINT16) strlen(Path); +#endif while(i != 0) { if(Path[i] == '\\' || Path[i] == '/') { @@ -1675,35 +2475,60 @@ FF_ERROR FF_MkDir(FF_IOMAN *pIoman, const FF_T_INT8 *Path) { i--; } +#ifdef FF_UNICODE_SUPPORT + wcsncpy(DirName, (Path + i + 1), FF_MAX_FILENAME); +#else strncpy(DirName, (Path + i + 1), FF_MAX_FILENAME); +#endif if(i == 0) { i = 1; } - DirCluster = FF_FindDir(pIoman, Path, i); + DirCluster = FF_FindDir(pIoman, Path, i, &Error); + + if(Error) { + return Error; + } if(DirCluster) { - - /*if(!FF_FindEntry(pIoman, DirCluster, DirName, &MyDir, FF_TRUE)) { - return FF_ERR_DIR_OBJECT_EXISTS; - }*/ - if(FF_FindEntryInDir(pIoman, DirCluster, DirName, 0x00, &MyDir)) { + if(FF_FindEntryInDir(pIoman, DirCluster, DirName, 0x00, &MyDir, &Error)) { return FF_ERR_DIR_OBJECT_EXISTS; } + if(Error && Error != FF_ERR_DIR_END_OF_DIR) { + return Error; + } + +#ifdef FF_UNICODE_SUPPORT + wcsncpy(MyDir.FileName, DirName, FF_MAX_FILENAME); +#else strncpy(MyDir.FileName, DirName, FF_MAX_FILENAME); +#endif MyDir.Filesize = 0; MyDir.Attrib = FF_FAT_ATTR_DIR; - MyDir.ObjectCluster = FF_CreateClusterChain(pIoman); - FF_ClearCluster(pIoman, MyDir.ObjectCluster); + MyDir.ObjectCluster = FF_CreateClusterChain(pIoman, &Error); + if(Error) { + return Error; + } + if(MyDir.ObjectCluster) { + Error = FF_ClearCluster(pIoman, MyDir.ObjectCluster); + if(Error) { + FF_UnlinkClusterChain(pIoman, MyDir.ObjectCluster, 0); + FF_FlushCache(pIoman); + return Error; + } + } else { + // Couldn't allocate any space for the dir! + return FF_ERR_DIR_EXTEND_FAILED; + } - RetVal = FF_CreateDirent(pIoman, DirCluster, &MyDir); + Error = FF_CreateDirent(pIoman, DirCluster, &MyDir); - if(RetVal) { + if(Error) { FF_UnlinkClusterChain(pIoman, MyDir.ObjectCluster, 0); FF_FlushCache(pIoman); - return RetVal; + return Error; } memset(EntryBuffer, 0, 32); @@ -1716,7 +2541,20 @@ FF_ERROR FF_MkDir(FF_IOMAN *pIoman, const FF_T_INT8 *Path) { FF_putShort(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_CLUS_LOW), (FF_T_UINT16) MyDir.ObjectCluster); FF_putLong(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_FILESIZE), 0); - FF_PushEntry(pIoman, MyDir.ObjectCluster, 0, EntryBuffer); + Error = FF_InitEntryFetch(pIoman, MyDir.ObjectCluster, &FetchContext); + if(Error) { + FF_UnlinkClusterChain(pIoman, MyDir.ObjectCluster, 0); + FF_FlushCache(pIoman); + return Error; + } + + Error = FF_PushEntryWithContext(pIoman, 0, &FetchContext, EntryBuffer); + if(Error) { + FF_UnlinkClusterChain(pIoman, MyDir.ObjectCluster, 0); + FF_FlushCache(pIoman); + FF_CleanupEntryFetch(pIoman, &FetchContext); + return Error; + } memset(EntryBuffer, 0, 32); EntryBuffer[0] = '.'; @@ -1736,8 +2574,16 @@ FF_ERROR FF_MkDir(FF_IOMAN *pIoman, const FF_T_INT8 *Path) { FF_putShort(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_CLUS_LOW), (FF_T_UINT16) DotDotCluster); FF_putLong(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_FILESIZE), 0); - FF_PushEntry(pIoman, MyDir.ObjectCluster, 1, EntryBuffer); - + //FF_PushEntry(pIoman, MyDir.ObjectCluster, 1, EntryBuffer); + Error = FF_PushEntryWithContext(pIoman, 1, &FetchContext, EntryBuffer); + if(Error) { + FF_UnlinkClusterChain(pIoman, MyDir.ObjectCluster, 0); + FF_FlushCache(pIoman); + FF_CleanupEntryFetch(pIoman, &FetchContext); + return Error; + } + FF_CleanupEntryFetch(pIoman, &FetchContext); + FF_FlushCache(pIoman); // Ensure dir was flushed to the disk! return FF_ERR_NONE; @@ -1748,24 +2594,32 @@ FF_ERROR FF_MkDir(FF_IOMAN *pIoman, const FF_T_INT8 *Path) { -void FF_RmLFNs(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 DirEntry) { +FF_ERROR FF_RmLFNs(FF_IOMAN *pIoman, FF_T_UINT16 usDirEntry, FF_FETCH_CONTEXT *pContext) { + FF_ERROR Error; FF_T_UINT8 EntryBuffer[32]; - DirEntry--; + usDirEntry--; do { - FF_FetchEntry(pIoman, DirCluster, DirEntry, EntryBuffer); + Error = FF_FetchEntryWithContext(pIoman, usDirEntry, pContext, EntryBuffer); + if(Error) { + return Error; + } if(FF_getChar(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_ATTRIB)) == FF_FAT_ATTR_LFN) { FF_putChar(EntryBuffer, (FF_T_UINT16) 0, (FF_T_UINT8) 0xE5); - FF_PushEntry(pIoman, DirCluster, DirEntry, EntryBuffer); + Error = FF_PushEntryWithContext(pIoman, usDirEntry, pContext, EntryBuffer); + if(Error) { + return Error; + } } - if(DirEntry == 0) { + if(usDirEntry == 0) { break; } - DirEntry--; + usDirEntry--; }while(FF_getChar(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_ATTRIB)) == FF_FAT_ATTR_LFN); + return FF_ERR_NONE; } diff --git a/reactos/lib/3rdparty/fullfat/ff_dir.h b/reactos/lib/3rdparty/fullfat/ff_dir.h index 41eb7278f8d..6c99b7279c5 100644 --- a/reactos/lib/3rdparty/fullfat/ff_dir.h +++ b/reactos/lib/3rdparty/fullfat/ff_dir.h @@ -52,54 +52,118 @@ #include typedef struct { - FF_T_INT8 FileName[FF_MAX_FILENAME]; - FF_T_UINT8 Attrib; + FF_T_UINT32 ulChainLength; + FF_T_UINT32 ulDirCluster; + FF_T_UINT32 ulCurrentClusterLCN; + FF_T_UINT32 ulCurrentClusterNum; + FF_T_UINT32 ulCurrentEntry; + FF_BUFFER *pBuffer; +} FF_FETCH_CONTEXT; + +typedef struct { FF_T_UINT32 Filesize; FF_T_UINT32 ObjectCluster; - + + // Book Keeping + FF_T_UINT32 CurrentCluster; + FF_T_UINT32 AddrCurrentCluster; + FF_T_UINT32 DirCluster; + FF_T_UINT16 CurrentItem; + // End Book Keeping + #ifdef FF_TIME_SUPPORT FF_SYSTEMTIME CreateTime; ///< Date and Time Created. FF_SYSTEMTIME ModifiedTime; ///< Date and Time Modified. FF_SYSTEMTIME AccessedTime; ///< Date of Last Access. #endif - //---- Book Keeping for FF_Find Functions - FF_T_UINT16 CurrentItem; - FF_T_UINT32 DirCluster; - FF_T_UINT32 CurrentCluster; - FF_T_UINT32 AddrCurrentCluster; - //FF_T_UINT8 NumLFNs; +#ifdef FF_FINDAPI_ALLOW_WILDCARDS +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR szWildCard[FF_MAX_FILENAME]; +#else + FF_T_INT8 szWildCard[FF_MAX_FILENAME]; +#endif +#endif + +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR FileName[FF_MAX_FILENAME]; +#else + FF_T_INT8 FileName[FF_MAX_FILENAME]; +#endif + +#if defined(FF_LFN_SUPPORT) && defined(FF_INCLUDE_SHORT_NAME) + FF_T_INT8 ShortName[13]; +#endif + FF_T_UINT8 Attrib; + FF_FETCH_CONTEXT FetchContext; } FF_DIRENT; - FF_ERROR FF_GetEntry (FF_IOMAN *pIoman, FF_T_UINT16 nEntry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); - FF_T_SINT8 FF_PutEntry (FF_IOMAN *pIoman, FF_T_UINT16 Entry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); - FF_T_SINT8 FF_FindEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *Name, FF_DIRENT *pDirent, FF_T_BOOL LFNs); - FF_ERROR FF_FindFirst (FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_INT8 *path); - FF_ERROR FF_FindNext (FF_IOMAN *pIoman, FF_DIRENT *pDirent); - void FF_PopulateShortDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT8 *EntryBuffer); - FF_T_SINT8 FF_PopulateLongDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry); - FF_T_SINT8 FF_FetchEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer); - FF_T_SINT8 FF_PushEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer); - FF_T_BOOL FF_isEndOfDir (FF_T_UINT8 *EntryBuffer); - FF_T_SINT8 FF_FindNextInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); - FF_T_UINT32 FF_FindEntryInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent); - FF_T_SINT8 FF_CreateShortName(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *ShortName, FF_T_INT8 *LongName); - -void FF_lockDIR (FF_IOMAN *pIoman); -void FF_unlockDIR (FF_IOMAN *pIoman); -FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *FileName, FF_DIRENT *pDirent); -FF_ERROR FF_MkDir(FF_IOMAN *pIoman, const FF_T_INT8 *Path); -FF_T_SINT8 FF_CreateDirent(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); -FF_T_SINT8 FF_ExtendDirectory(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster); -FF_T_UINT32 FF_FindDir(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 pathLen); -FF_T_BOOL FF_CheckDirentHash(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash); -FF_T_BOOL FF_DirHashed(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster); -FF_ERROR FF_AddDirentHash(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash); -void FF_SetDirHashed(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster); +// PUBLIC API +#ifdef FF_UNICODE_SUPPORT +FF_ERROR FF_FindFirst (FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_WCHAR *path); +FF_ERROR FF_MkDir (FF_IOMAN *pIoman, const FF_T_WCHAR *Path); +#else +FF_ERROR FF_FindFirst (FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_INT8 *path); +FF_ERROR FF_MkDir (FF_IOMAN *pIoman, const FF_T_INT8 *Path); +#endif -void FF_RmLFNs(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 DirEntry); +FF_ERROR FF_FindNext (FF_IOMAN *pIoman, FF_DIRENT *pDirent); + + +// INTERNAL API +FF_ERROR FF_GetEntry (FF_IOMAN *pIoman, FF_T_UINT16 nEntry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); +FF_ERROR FF_PutEntry (FF_IOMAN *pIoman, FF_T_UINT16 Entry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); +FF_T_SINT8 FF_FindEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *Name, FF_DIRENT *pDirent, FF_T_BOOL LFNs); + +void FF_PopulateShortDirent (FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT8 *EntryBuffer); +FF_ERROR FF_PopulateLongDirent (FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT16 nEntry, FF_FETCH_CONTEXT *pFetchContext); + +FF_ERROR FF_InitEntryFetch (FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster, FF_FETCH_CONTEXT *pContext); +FF_ERROR FF_FetchEntryWithContext (FF_IOMAN *pIoman, FF_T_UINT32 ulEntry, FF_FETCH_CONTEXT *pContext, FF_T_UINT8 *pEntryBuffer); +FF_ERROR FF_PushEntryWithContext (FF_IOMAN *pIoman, FF_T_UINT32 ulEntry, FF_FETCH_CONTEXT *pContext, FF_T_UINT8 *pEntryBuffer); +void FF_CleanupEntryFetch (FF_IOMAN *pIoman, FF_FETCH_CONTEXT *pContext); + +FF_T_SINT8 FF_PushEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer, void *pParam); +FF_T_BOOL FF_isEndOfDir (FF_T_UINT8 *EntryBuffer); +FF_ERROR FF_FindNextInDir (FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_FETCH_CONTEXT *pFetchContext); + +#ifdef FF_UNICODE_SUPPORT +FF_T_UINT32 FF_FindEntryInDir (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, const FF_T_WCHAR *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent, FF_ERROR *pError); +FF_T_SINT8 FF_CreateShortName (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_WCHAR *ShortName, FF_T_WCHAR *LongName); +#else +FF_T_UINT32 FF_FindEntryInDir (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, const FF_T_INT8 *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent, FF_ERROR *pError); +FF_T_SINT8 FF_CreateShortName (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *ShortName, FF_T_INT8 *LongName); +#endif + + +void FF_lockDIR (FF_IOMAN *pIoman); +void FF_unlockDIR (FF_IOMAN *pIoman); + +#ifdef FF_UNICODE_SUPPORT +FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_WCHAR *FileName, FF_DIRENT *pDirent, FF_ERROR *pError); +#else +FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *FileName, FF_DIRENT *pDirent, FF_ERROR *pError); +#endif + +FF_ERROR FF_CreateDirent (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); +FF_ERROR FF_ExtendDirectory (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster); + +#ifdef FF_UNICODE_SUPPORT +FF_T_UINT32 FF_FindDir (FF_IOMAN *pIoman, const FF_T_WCHAR *path, FF_T_UINT16 pathLen, FF_ERROR *pError); +#else +FF_T_UINT32 FF_FindDir (FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 pathLen, FF_ERROR *pError); +#endif + +#ifdef FF_HASH_CACHE +FF_T_BOOL FF_CheckDirentHash (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash); +FF_T_BOOL FF_DirHashed (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster); +FF_ERROR FF_AddDirentHash (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash); +FF_ERROR FF_HashDir (FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster); +#endif + +FF_ERROR FF_RmLFNs(FF_IOMAN *pIoman, FF_T_UINT16 usDirEntry, FF_FETCH_CONTEXT *pContext); #endif diff --git a/reactos/lib/3rdparty/fullfat/ff_error.c b/reactos/lib/3rdparty/fullfat/ff_error.c index 483bf964ce3..787c8769aaa 100644 --- a/reactos/lib/3rdparty/fullfat/ff_error.c +++ b/reactos/lib/3rdparty/fullfat/ff_error.c @@ -56,7 +56,7 @@ const struct _FFERRTAB {"Not enough memory (malloc() returned NULL).", FF_ERR_NOT_ENOUGH_MEMORY}, {"Device Driver returned a FATAL error!.", FF_ERR_DEVICE_DRIVER_FAILED}, {"The blocksize is not 512 multiple.", FF_ERR_IOMAN_BAD_BLKSIZE}, - {"The provided memory size, is not a multiple of the blocksize.", FF_ERR_IOMAN_BAD_MEMSIZE}, + {"The memory size, is not a multiple of the blocksize. (Atleast 2 Blocks).", FF_ERR_IOMAN_BAD_MEMSIZE}, {"Device is already registered, use FF_UnregisterBlkDevice() first.", FF_ERR_IOMAN_DEV_ALREADY_REGD}, {"No mountable partition was found on the specified device.", FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION}, {"The format of the MBR was unrecognised.", FF_ERR_IOMAN_INVALID_FORMAT}, @@ -65,6 +65,7 @@ const struct _FFERRTAB {"Cannot register device. (BlkSize not a multiple of 512).", FF_ERR_IOMAN_DEV_INVALID_BLKSIZE}, {"Cannot unregister device, a partition is still mounted.", FF_ERR_IOMAN_PARTITION_MOUNTED}, {"Cannot unmount the partition while there are active FILE handles.", FF_ERR_IOMAN_ACTIVE_HANDLES}, + {"The GPT partition header appears to be corrupt, refusing to mount.", FF_ERR_IOMAN_GPT_HEADER_CORRUPT}, {"Cannot open the file, file already in use.", FF_ERR_FILE_ALREADY_OPEN}, {"The specified file could not be found.", FF_ERR_FILE_NOT_FOUND}, {"Cannot open a Directory.", FF_ERR_FILE_OBJECT_IS_A_DIR}, @@ -84,6 +85,9 @@ const struct _FFERRTAB {"Source file was not found.", FF_ERR_FILE_SOURCE_NOT_FOUND}, {"Destination path (dir) was not found.", FF_ERR_FILE_DIR_NOT_FOUND}, {"Failed to create the directory Entry.", FF_ERR_FILE_COULD_NOT_CREATE_DIRENT}, + {"Not enough free disk space to complete the disk transaction.", FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE}, + {"Attempted to Read a sector out of bounds.", FF_ERR_IOMAN_OUT_OF_BOUNDS_READ}, + {"Attempted to Write a sector out of bounds.", FF_ERR_IOMAN_OUT_OF_BOUNDS_WRITE}, }; /** diff --git a/reactos/lib/3rdparty/fullfat/ff_fat.c b/reactos/lib/3rdparty/fullfat/ff_fat.c index 66769e56af7..fb5ac824033 100644 --- a/reactos/lib/3rdparty/fullfat/ff_fat.c +++ b/reactos/lib/3rdparty/fullfat/ff_fat.c @@ -110,7 +110,7 @@ FF_T_UINT32 FF_LBA2Cluster(FF_IOMAN *pIoman, FF_T_UINT32 Address) { /** * @private **/ -FF_T_SINT32 FF_getFatEntry(FF_IOMAN *pIoman, FF_T_UINT32 nCluster) { +FF_T_UINT32 FF_getFatEntry(FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_ERROR *pError) { FF_BUFFER *pBuffer; FF_T_UINT32 FatOffset; @@ -148,7 +148,8 @@ FF_T_SINT32 FF_getFatEntry(FF_IOMAN *pIoman, FF_T_UINT32 nCluster) { pBuffer = FF_GetBuffer(pIoman, FatSector + LBAadjust, FF_MODE_READ); { if(!pBuffer) { - return FF_ERR_DEVICE_DRIVER_FAILED; + *pError = FF_ERR_DEVICE_DRIVER_FAILED; + return 0; } F12short[0] = FF_getChar(pBuffer->pBuffer, (FF_T_UINT16)(pIoman->BlkSize - 1)); } @@ -157,7 +158,8 @@ FF_T_SINT32 FF_getFatEntry(FF_IOMAN *pIoman, FF_T_UINT32 nCluster) { pBuffer = FF_GetBuffer(pIoman, FatSector + LBAadjust + 1, FF_MODE_READ); { if(!pBuffer) { - return FF_ERR_DEVICE_DRIVER_FAILED; + *pError = FF_ERR_DEVICE_DRIVER_FAILED; + return 0; } F12short[1] = FF_getChar(pBuffer->pBuffer, 0); } @@ -176,7 +178,8 @@ FF_T_SINT32 FF_getFatEntry(FF_IOMAN *pIoman, FF_T_UINT32 nCluster) { pBuffer = FF_GetBuffer(pIoman, FatSector + LBAadjust, FF_MODE_READ); { if(!pBuffer) { - return FF_ERR_DEVICE_DRIVER_FAILED; + *pError = FF_ERR_DEVICE_DRIVER_FAILED; + return 0; } switch(pIoman->pPartition->Type) { @@ -208,11 +211,10 @@ FF_T_SINT32 FF_getFatEntry(FF_IOMAN *pIoman, FF_T_UINT32 nCluster) { return (FF_T_SINT32) FatEntry; } -FF_T_SINT8 FF_ClearCluster(FF_IOMAN *pIoman, FF_T_UINT32 nCluster) { +FF_ERROR FF_ClearCluster(FF_IOMAN *pIoman, FF_T_UINT32 nCluster) { FF_BUFFER *pBuffer; FF_T_UINT16 i; FF_T_UINT32 BaseLBA; - FF_T_SINT8 RetVal = 0; BaseLBA = FF_Cluster2LBA(pIoman, nCluster); BaseLBA = FF_getRealLBA(pIoman, BaseLBA); @@ -220,16 +222,15 @@ FF_T_SINT8 FF_ClearCluster(FF_IOMAN *pIoman, FF_T_UINT32 nCluster) { for(i = 0; i < pIoman->pPartition->SectorsPerCluster; i++) { pBuffer = FF_GetBuffer(pIoman, BaseLBA++, FF_MODE_WRITE); { - if(pBuffer) { - memset(pBuffer->pBuffer, 0x00, 512); - } else { - RetVal = FF_ERR_DEVICE_DRIVER_FAILED; + if(!pBuffer) { + return FF_ERR_DEVICE_DRIVER_FAILED; } + memset(pBuffer->pBuffer, 0x00, 512); } FF_ReleaseBuffer(pIoman, pBuffer); } - return RetVal; + return FF_ERR_NONE; } /** @@ -240,17 +241,19 @@ FF_T_SINT8 FF_ClearCluster(FF_IOMAN *pIoman, FF_T_UINT32 nCluster) { * @param Start Cluster address of the first cluster in the chain. * @param Count Number of Cluster in the chain, * - * @return FF_TRUE if it is an end of chain, otherwise FF_FALSE. + * * **/ -FF_T_UINT32 FF_TraverseFAT(FF_IOMAN *pIoman, FF_T_UINT32 Start, FF_T_UINT32 Count) { +FF_T_UINT32 FF_TraverseFAT(FF_IOMAN *pIoman, FF_T_UINT32 Start, FF_T_UINT32 Count, FF_ERROR *pError) { FF_T_UINT32 i; FF_T_UINT32 fatEntry = Start, currentCluster = Start; + *pError = FF_ERR_NONE; + for(i = 0; i < Count; i++) { - fatEntry = FF_getFatEntry(pIoman, currentCluster); - if(fatEntry == (FF_T_UINT32) FF_ERR_DEVICE_DRIVER_FAILED) { + fatEntry = FF_getFatEntry(pIoman, currentCluster, pError); + if(*pError) { return 0; } @@ -264,13 +267,14 @@ FF_T_UINT32 FF_TraverseFAT(FF_IOMAN *pIoman, FF_T_UINT32 Start, FF_T_UINT32 Coun return fatEntry; } -FF_T_UINT32 FF_FindEndOfChain(FF_IOMAN *pIoman, FF_T_UINT32 Start) { +FF_T_UINT32 FF_FindEndOfChain(FF_IOMAN *pIoman, FF_T_UINT32 Start, FF_ERROR *pError) { FF_T_UINT32 fatEntry = Start, currentCluster = Start; + *pError = FF_ERR_NONE; while(!FF_isEndOfChain(pIoman, fatEntry)) { - fatEntry = FF_getFatEntry(pIoman, currentCluster); - if(fatEntry == (FF_T_UINT32) FF_ERR_DEVICE_DRIVER_FAILED) { + fatEntry = FF_getFatEntry(pIoman, currentCluster, pError); + if(*pError) { return 0; } @@ -325,7 +329,7 @@ FF_T_BOOL FF_isEndOfChain(FF_IOMAN *pIoman, FF_T_UINT32 fatEntry) { * @param nCluster Cluster Number to be modified. * @param Value The Value to store. **/ -FF_T_SINT8 FF_putFatEntry(FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_T_UINT32 Value) { +FF_ERROR FF_putFatEntry(FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_T_UINT32 Value) { FF_BUFFER *pBuffer; FF_T_UINT32 FatOffset; @@ -439,7 +443,7 @@ FF_T_SINT8 FF_putFatEntry(FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_T_UINT32 Va } FF_ReleaseBuffer(pIoman, pBuffer); - return 0; + return FF_ERR_NONE; } @@ -454,12 +458,17 @@ FF_T_SINT8 FF_putFatEntry(FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_T_UINT32 Va * @return 0 on error. **/ #ifdef FF_FAT12_SUPPORT -FF_T_UINT32 FF_FindFreeClusterOLD(FF_IOMAN *pIoman) { +static FF_T_UINT32 FF_FindFreeClusterOLD(FF_IOMAN *pIoman, FF_ERROR *pError) { FF_T_UINT32 nCluster; FF_T_UINT32 fatEntry; + *pError = FF_ERR_NONE; + for(nCluster = pIoman->pPartition->LastFreeCluster; nCluster < pIoman->pPartition->NumClusters; nCluster++) { - fatEntry = FF_getFatEntry(pIoman, nCluster); + fatEntry = FF_getFatEntry(pIoman, nCluster, pError); + if(*pError) { + return 0; + } if(fatEntry == 0x00000000) { pIoman->pPartition->LastFreeCluster = nCluster; return nCluster; @@ -469,7 +478,7 @@ FF_T_UINT32 FF_FindFreeClusterOLD(FF_IOMAN *pIoman) { } #endif -FF_T_UINT32 FF_FindFreeCluster(FF_IOMAN *pIoman) { +FF_T_UINT32 FF_FindFreeCluster(FF_IOMAN *pIoman, FF_ERROR *pError) { FF_BUFFER *pBuffer; FF_T_UINT32 i, x, nCluster = pIoman->pPartition->LastFreeCluster; FF_T_UINT32 FatOffset; @@ -478,9 +487,11 @@ FF_T_UINT32 FF_FindFreeCluster(FF_IOMAN *pIoman) { FF_T_UINT32 EntriesPerSector; FF_T_UINT32 FatEntry = 1; + *pError = FF_ERR_NONE; + #ifdef FF_FAT12_SUPPORT if(pIoman->pPartition->Type == FF_T_FAT12) { // FAT12 tables are too small to optimise, and would make it very complicated! - return FF_FindFreeClusterOLD(pIoman); + return FF_FindFreeClusterOLD(pIoman, pError); } #endif @@ -491,15 +502,20 @@ FF_T_UINT32 FF_FindFreeCluster(FF_IOMAN *pIoman) { EntriesPerSector = pIoman->BlkSize / 2; FatOffset = nCluster * 2; } + + // HT addition: don't use non-existing clusters + if (nCluster >= pIoman->pPartition->NumClusters) { + *pError = FF_ERR_FAT_NO_FREE_CLUSTERS; + return 0; + } FatSector = (FatOffset / pIoman->pPartition->BlkSize); for(i = FatSector; i < pIoman->pPartition->SectorsPerFAT; i++) { pBuffer = FF_GetBuffer(pIoman, pIoman->pPartition->FatBeginLBA + i, FF_MODE_READ); { - // HT addition: don't use non-existing clusters - if (nCluster >= pIoman->pPartition->NumClusters) { - FF_ReleaseBuffer(pIoman, pBuffer); + if(!pBuffer) { + *pError = FF_ERR_DEVICE_DRIVER_FAILED; return 0; } for(x = nCluster % EntriesPerSector; x < EntriesPerSector; x++) { @@ -533,24 +549,54 @@ FF_T_UINT32 FF_FindFreeCluster(FF_IOMAN *pIoman) { * @private * @brief Create's a Cluster Chain **/ -FF_T_UINT32 FF_CreateClusterChain(FF_IOMAN *pIoman) { +FF_T_UINT32 FF_CreateClusterChain(FF_IOMAN *pIoman, FF_ERROR *pError) { FF_T_UINT32 iStartCluster; + FF_ERROR Error; + *pError = FF_ERR_NONE; + FF_lockFAT(pIoman); { - iStartCluster = FF_FindFreeCluster(pIoman); - FF_putFatEntry(pIoman, iStartCluster, 0xFFFFFFFF); // Mark the cluster as EOC + iStartCluster = FF_FindFreeCluster(pIoman, &Error); + if(Error) { + *pError = Error; + FF_unlockFAT(pIoman); + return 0; + } + + if(iStartCluster) { + Error = FF_putFatEntry(pIoman, iStartCluster, 0xFFFFFFFF); // Mark the cluster as End-Of-Chain + if(Error) { + *pError = Error; + FF_unlockFAT(pIoman); + return 0; + } + } } FF_unlockFAT(pIoman); + + if(iStartCluster) { + Error = FF_DecreaseFreeClusters(pIoman, 1); + if(Error) { + *pError = Error; + return 0; + } + } + return iStartCluster; } -FF_T_UINT32 FF_GetChainLength(FF_IOMAN *pIoman, FF_T_UINT32 pa_nStartCluster, FF_T_UINT32 *piEndOfChain) { +FF_T_UINT32 FF_GetChainLength(FF_IOMAN *pIoman, FF_T_UINT32 pa_nStartCluster, FF_T_UINT32 *piEndOfChain, FF_ERROR *pError) { FF_T_UINT32 iLength = 0; + + *pError = FF_ERR_NONE; FF_lockFAT(pIoman); { while(!FF_isEndOfChain(pIoman, pa_nStartCluster)) { - pa_nStartCluster = FF_getFatEntry(pIoman, pa_nStartCluster); + pa_nStartCluster = FF_getFatEntry(pIoman, pa_nStartCluster, pError); + if(*pError) { + return 0; + } iLength++; } if(piEndOfChain) { @@ -612,12 +658,13 @@ FF_T_UINT32 FF_ExtendClusterChain(FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF * @return -1 If the device driver failed to provide access. * **/ -FF_T_SINT8 FF_UnlinkClusterChain(FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_T_UINT16 Count) { +FF_ERROR FF_UnlinkClusterChain(FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_T_UINT16 Count) { FF_T_UINT32 fatEntry; FF_T_UINT32 currentCluster, chainLength = 0; FF_T_UINT32 iLen = 0; FF_T_UINT32 lastFree = StartCluster; /* HT addition : reset LastFreeCluster */ + FF_ERROR Error; fatEntry = StartCluster; @@ -626,8 +673,15 @@ FF_T_SINT8 FF_UnlinkClusterChain(FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_ currentCluster = StartCluster; fatEntry = currentCluster; do { - fatEntry = FF_getFatEntry(pIoman, fatEntry); - FF_putFatEntry(pIoman, currentCluster, 0x00000000); + fatEntry = FF_getFatEntry(pIoman, fatEntry, &Error); + if(Error) { + return Error; + } + Error = FF_putFatEntry(pIoman, currentCluster, 0x00000000); + if(Error) { + return Error; + } + if (lastFree > currentCluster) { lastFree = currentCluster; } @@ -637,11 +691,17 @@ FF_T_SINT8 FF_UnlinkClusterChain(FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_ if (pIoman->pPartition->LastFreeCluster > lastFree) { pIoman->pPartition->LastFreeCluster = lastFree; } - FF_IncreaseFreeClusters(pIoman, iLen); + Error = FF_IncreaseFreeClusters(pIoman, iLen); + if(Error) { + return Error; + } } else { // Truncation - This is quite hard, because we can only do it backwards. do { - fatEntry = FF_getFatEntry(pIoman, fatEntry); + fatEntry = FF_getFatEntry(pIoman, fatEntry, &Error); + if(Error) { + return Error; + } chainLength++; }while(!FF_isEndOfChain(pIoman, fatEntry)); } @@ -650,14 +710,19 @@ FF_T_SINT8 FF_UnlinkClusterChain(FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_ } #ifdef FF_FAT12_SUPPORT -FF_T_UINT32 FF_CountFreeClustersOLD(FF_IOMAN *pIoman) { +FF_T_UINT32 FF_CountFreeClustersOLD(FF_IOMAN *pIoman, FF_ERROR *pError) { FF_T_UINT32 i; FF_T_UINT32 TotalClusters = pIoman->pPartition->DataSectors / pIoman->pPartition->SectorsPerCluster; FF_T_UINT32 FatEntry; FF_T_UINT32 FreeClusters = 0; + *pError = FF_ERR_NONE; + for(i = 0; i < TotalClusters; i++) { - FatEntry = FF_getFatEntry(pIoman, i); + FatEntry = FF_getFatEntry(pIoman, i, pError); + if(*pError) { + return 0; + } if(!FatEntry) { FreeClusters++; } @@ -668,7 +733,7 @@ FF_T_UINT32 FF_CountFreeClustersOLD(FF_IOMAN *pIoman) { #endif -FF_T_UINT32 FF_CountFreeClusters(FF_IOMAN *pIoman) { +FF_T_UINT32 FF_CountFreeClusters(FF_IOMAN *pIoman, FF_ERROR *pError) { FF_BUFFER *pBuffer; FF_T_UINT32 i, x, nCluster = 0; FF_T_UINT32 FatOffset; @@ -678,9 +743,14 @@ FF_T_UINT32 FF_CountFreeClusters(FF_IOMAN *pIoman) { FF_T_UINT32 FatEntry = 1; FF_T_UINT32 FreeClusters = 0; + *pError = FF_ERR_NONE; + #ifdef FF_FAT12_SUPPORT if(pIoman->pPartition->Type == FF_T_FAT12) { // FAT12 tables are too small to optimise, and would make it very complicated! - return FF_CountFreeClustersOLD(pIoman); + FreeClusters = FF_CountFreeClustersOLD(pIoman, pError); + if(*pError) { + return 0; + } } #endif @@ -697,6 +767,10 @@ FF_T_UINT32 FF_CountFreeClusters(FF_IOMAN *pIoman) { for(i = 0; i < pIoman->pPartition->SectorsPerFAT; i++) { pBuffer = FF_GetBuffer(pIoman, pIoman->pPartition->FatBeginLBA + i, FF_MODE_READ); { + if(!pBuffer) { + *pError = FF_ERR_DEVICE_DRIVER_FAILED; + return 0; + } for(x = nCluster % EntriesPerSector; x < EntriesPerSector; x++) { if(pIoman->pPartition->Type == FF_T_FAT32) { FatOffset = x * 4; @@ -722,15 +796,23 @@ FF_T_UINT32 FF_CountFreeClusters(FF_IOMAN *pIoman) { } #ifdef FF_64_NUM_SUPPORT -FF_T_UINT64 FF_GetFreeSize(FF_IOMAN *pIoman) { +FF_T_UINT64 FF_GetFreeSize(FF_IOMAN *pIoman, FF_ERROR *pError) { FF_T_UINT32 FreeClusters; FF_T_UINT64 FreeSize; + FF_ERROR Error; if(pIoman) { FF_lockFAT(pIoman); { if(!pIoman->pPartition->FreeClusterCount) { - pIoman->pPartition->FreeClusterCount = FF_CountFreeClusters(pIoman); + pIoman->pPartition->FreeClusterCount = FF_CountFreeClusters(pIoman, &Error); + if(Error) { + if(pError) { + *pError = Error; + } + FF_unlockFAT(pIoman); + return 0; + } } FreeClusters = pIoman->pPartition->FreeClusterCount; } diff --git a/reactos/lib/3rdparty/fullfat/ff_file.c b/reactos/lib/3rdparty/fullfat/ff_file.c index cd29e31562b..716467a7833 100644 --- a/reactos/lib/3rdparty/fullfat/ff_file.c +++ b/reactos/lib/3rdparty/fullfat/ff_file.c @@ -42,6 +42,11 @@ #include "ff_file.h" #include "ff_string.h" +#include "ff_config.h" + +#ifdef FF_UNICODE_SUPPORT +#include +#endif /** * @public @@ -143,13 +148,22 @@ FF_T_UINT8 FF_GetModeBits(FF_T_INT8 *Mode) { * @return NULL pointer on Error, in which case pError should be checked for more information. * @return pError can be: **/ +#ifdef FF_UNICODE_SUPPORT +FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_WCHAR *path, FF_T_UINT8 Mode, FF_ERROR *pError) { +#else FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ERROR *pError) { +#endif FF_FILE *pFile; FF_FILE *pFileChain; FF_DIRENT Object; FF_T_UINT32 DirCluster, FileCluster; FF_T_UINT32 nBytesPerCluster; +#ifdef FF_UNICODE_SUPPORT + FF_T_WCHAR filename[FF_MAX_FILENAME]; +#else FF_T_INT8 filename[FF_MAX_FILENAME]; +#endif + FF_ERROR Error; FF_T_UINT16 i; @@ -174,7 +188,11 @@ FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ER // Get the Mode Bits. pFile->Mode = Mode; +#ifdef FF_UNICODE_SUPPORT + i = (FF_T_UINT16) wcslen(path); +#else i = (FF_T_UINT16) strlen(path); +#endif while(i != 0) { if(path[i] == '\\' || path[i] == '/') { @@ -182,29 +200,45 @@ FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ER } i--; } - +#ifdef FF_UNICODE_SUPPORT + wcsncpy(filename, (path + i + 1), FF_MAX_FILENAME); +#else strncpy(filename, (path + i + 1), FF_MAX_FILENAME); +#endif if(i == 0) { i = 1; } - DirCluster = FF_FindDir(pIoman, path, i); + DirCluster = FF_FindDir(pIoman, path, i, &Error); + if(Error) { + if(pError) { + *pError = Error; + } + FF_FREE(pFile); + return (FF_FILE *) NULL; + } if(DirCluster) { - //RetVal = //FF_FindEntry(pIoman, DirCluster, filename, &Object, FF_TRUE); - //if(RetVal >= 0) { - //FileCluster = Object.ObjectCluster;//FF_FindEntryInDir(pIoman, DirCluster, filename, 0x00, &Object); - //} else { - // FileCluster = 0; - //} - FileCluster = FF_FindEntryInDir(pIoman, DirCluster, filename, 0x00, &Object); + FileCluster = FF_FindEntryInDir(pIoman, DirCluster, filename, 0x00, &Object, &Error); + if(Error) { + if(pError) { + *pError = Error; + } + FF_FREE(pFile); + return (FF_FILE *) NULL; + } if(!FileCluster) { // If 0 was returned, it might be because the file has no allocated cluster +#ifdef FF_UNICODE_SUPPORT + if(wcslen(filename) == wcslen(Object.FileName)) { + if(Object.Filesize == 0 && FF_strmatch(filename, Object.FileName, (FF_T_UINT16) wcslen(filename)) == FF_TRUE) { +#else if(strlen(filename) == strlen(Object.FileName)) { if(Object.Filesize == 0 && FF_strmatch(filename, Object.FileName, (FF_T_UINT16) strlen(filename)) == FF_TRUE) { +#endif // The file really was found! FileCluster = 1; } @@ -213,7 +247,14 @@ FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ER if(!FileCluster) { if((pFile->Mode & FF_MODE_CREATE)) { - FileCluster = FF_CreateFile(pIoman, DirCluster, filename, &Object); + FileCluster = FF_CreateFile(pIoman, DirCluster, filename, &Object, &Error); + if(Error) { + if(pError) { + *pError = Error; + } + FF_FREE(pFile); + return (FF_FILE *) NULL; + } Object.CurrentItem += 1; } } @@ -318,7 +359,11 @@ FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ER * @param pIoman FF_IOMAN object returned from the FF_CreateIOMAN() function. * **/ +#ifdef FF_UNICODE_SUPPORT +FF_T_BOOL FF_isDirEmpty(FF_IOMAN *pIoman, const FF_T_WCHAR *Path) { +#else FF_T_BOOL FF_isDirEmpty(FF_IOMAN *pIoman, const FF_T_INT8 *Path) { +#endif FF_DIRENT MyDir; FF_ERROR RetVal = FF_ERR_NONE; @@ -340,11 +385,16 @@ FF_T_BOOL FF_isDirEmpty(FF_IOMAN *pIoman, const FF_T_INT8 *Path) { return FF_TRUE; } +#ifdef FF_UNICODE_SUPPORT +FF_ERROR FF_RmDir(FF_IOMAN *pIoman, const FF_T_WCHAR *path) { +#else FF_ERROR FF_RmDir(FF_IOMAN *pIoman, const FF_T_INT8 *path) { - FF_FILE *pFile; - FF_ERROR Error = FF_ERR_NONE; - FF_T_UINT8 EntryBuffer[32]; - FF_T_SINT8 RetVal = FF_ERR_NONE; +#endif + FF_FILE *pFile; + FF_ERROR Error = FF_ERR_NONE; + FF_T_UINT8 EntryBuffer[32]; + FF_FETCH_CONTEXT FetchContext; + FF_T_SINT8 RetVal = FF_ERR_NONE; #ifdef FF_PATH_CACHE FF_T_UINT32 i; #endif @@ -366,20 +416,57 @@ FF_ERROR FF_RmDir(FF_IOMAN *pIoman, const FF_T_INT8 *path) { if(FF_isDirEmpty(pIoman, path)) { FF_lockFAT(pIoman); { - FF_UnlinkClusterChain(pIoman, pFile->ObjectCluster, 0); // 0 to delete the entire chain! + Error = FF_UnlinkClusterChain(pIoman, pFile->ObjectCluster, 0); // 0 to delete the entire chain! } FF_unlockFAT(pIoman); + + if(Error) { + FF_unlockDIR(pIoman); + FF_Close(pFile); + return Error; + } + + // Initialise the dirent Fetch Context object for faster removal of dirents. + + Error = FF_InitEntryFetch(pIoman, pFile->DirCluster, &FetchContext); + if(Error) { + FF_unlockDIR(pIoman); + FF_Close(pFile); + return Error; + } // Edit the Directory Entry! (So it appears as deleted); - FF_RmLFNs(pIoman, pFile->DirCluster, pFile->DirEntry); - FF_FetchEntry(pIoman, pFile->DirCluster, pFile->DirEntry, EntryBuffer); + Error = FF_RmLFNs(pIoman, pFile->DirEntry, &FetchContext); + if(Error) { + FF_CleanupEntryFetch(pIoman, &FetchContext); + FF_unlockDIR(pIoman); + FF_Close(pFile); + return Error; + } + Error = FF_FetchEntryWithContext(pIoman, pFile->DirEntry, &FetchContext, EntryBuffer); + if(Error) { + FF_CleanupEntryFetch(pIoman, &FetchContext); + FF_unlockDIR(pIoman); + FF_Close(pFile); + return Error; + } EntryBuffer[0] = 0xE5; - FF_PushEntry(pIoman, pFile->DirCluster, pFile->DirEntry, EntryBuffer); + Error = FF_PushEntryWithContext(pIoman, pFile->DirEntry, &FetchContext, EntryBuffer); + if(Error) { + FF_CleanupEntryFetch(pIoman, &FetchContext); + FF_unlockDIR(pIoman); + FF_Close(pFile); + return Error; + } #ifdef FF_PATH_CACHE FF_PendSemaphore(pIoman->pSemaphore); // Thread safety on shared object! { for(i = 0; i < FF_PATH_CACHE_DEPTH; i++) { +#ifdef FF_UNICODE_SUPPORT + if(FF_strmatch(pIoman->pPartition->PathCache[i].Path, path, (FF_T_UINT16)wcslen(path))) { +#else if(FF_strmatch(pIoman->pPartition->PathCache[i].Path, path, (FF_T_UINT16)strlen(path))) { +#endif pIoman->pPartition->PathCache[i].Path[0] = '\0'; pIoman->pPartition->PathCache[i].DirCluster = 0; FF_ReleaseSemaphore(pIoman->pSemaphore); @@ -389,24 +476,46 @@ FF_ERROR FF_RmDir(FF_IOMAN *pIoman, const FF_T_INT8 *path) { FF_ReleaseSemaphore(pIoman->pSemaphore); #endif - FF_IncreaseFreeClusters(pIoman, pFile->iChainLength); + Error = FF_IncreaseFreeClusters(pIoman, pFile->iChainLength); + if(Error) { + FF_CleanupEntryFetch(pIoman, &FetchContext); + FF_unlockDIR(pIoman); + FF_Close(pFile); + return Error; + } - FF_FlushCache(pIoman); + FF_CleanupEntryFetch(pIoman, &FetchContext); + + Error = FF_FlushCache(pIoman); + if(Error) { + FF_unlockDIR(pIoman); + FF_Close(pFile); + return Error; + } } else { RetVal = FF_ERR_DIR_NOT_EMPTY; } } FF_unlockDIR(pIoman); - - FF_Close(pFile); // Free the file pointer resources + Error = FF_Close(pFile); // Free the file pointer resources + + if(Error) { + return Error; + } + // File is now lost! return RetVal; } +#ifdef FF_UNICODE_SUPPORT +FF_ERROR FF_RmFile(FF_IOMAN *pIoman, const FF_T_WCHAR *path) { +#else FF_ERROR FF_RmFile(FF_IOMAN *pIoman, const FF_T_INT8 *path) { +#endif FF_FILE *pFile; - FF_ERROR Error = 0; + FF_ERROR Error = FF_ERR_NONE; FF_T_UINT8 EntryBuffer[32]; + FF_FETCH_CONTEXT FetchContext; pFile = FF_Open(pIoman, path, FF_MODE_READ, &Error); @@ -416,26 +525,64 @@ FF_ERROR FF_RmFile(FF_IOMAN *pIoman, const FF_T_INT8 *path) { pFile->FileDeleted = FF_TRUE; - FF_lockFAT(pIoman); // Lock the FAT so its thread-safe. - { - FF_UnlinkClusterChain(pIoman, pFile->ObjectCluster, 0); // 0 to delete the entire chain! + if(pFile->ObjectCluster) { // Ensure there is actually a cluster chain to delete! + FF_lockFAT(pIoman); // Lock the FAT so its thread-safe. + { + Error = FF_UnlinkClusterChain(pIoman, pFile->ObjectCluster, 0); // 0 to delete the entire chain! + } + FF_unlockFAT(pIoman); + + if(Error) { + FF_Close(pFile); + return Error; + } } - FF_unlockFAT(pIoman); // Edit the Directory Entry! (So it appears as deleted); FF_lockDIR(pIoman); { - FF_RmLFNs(pIoman, pFile->DirCluster, pFile->DirEntry); - FF_FetchEntry(pIoman, pFile->DirCluster, pFile->DirEntry, EntryBuffer); + Error = FF_InitEntryFetch(pIoman, pFile->DirCluster, &FetchContext); + if(Error) { + FF_unlockDIR(pIoman); + FF_Close(pFile); + return Error; + } + Error = FF_RmLFNs(pIoman, pFile->DirEntry, &FetchContext); + if(Error) { + FF_CleanupEntryFetch(pIoman, &FetchContext); + FF_unlockDIR(pIoman); + FF_Close(pFile); + return Error; + } + Error = FF_FetchEntryWithContext(pIoman, pFile->DirEntry, &FetchContext, EntryBuffer); + if(Error) { + FF_CleanupEntryFetch(pIoman, &FetchContext); + FF_unlockDIR(pIoman); + FF_Close(pFile); + return Error; + } EntryBuffer[0] = 0xE5; - FF_PushEntry(pIoman, pFile->DirCluster, pFile->DirEntry, EntryBuffer); + + Error = FF_PushEntryWithContext(pIoman, pFile->DirEntry, &FetchContext, EntryBuffer); + if(Error) { + FF_CleanupEntryFetch(pIoman, &FetchContext); + FF_unlockDIR(pIoman); + FF_Close(pFile); + return Error; + } + + FF_CleanupEntryFetch(pIoman, &FetchContext); } FF_unlockDIR(pIoman); - FF_FlushCache(pIoman); + Error = FF_FlushCache(pIoman); + if(Error) { + FF_Close(pFile); + return Error; + } - FF_Close(pFile); // Free the file pointer resources - return 0; + Error = FF_Close(pFile); // Free the file pointer resources + return Error; } /** @@ -453,13 +600,18 @@ FF_ERROR FF_RmFile(FF_IOMAN *pIoman, const FF_T_INT8 *path) { * @return FF_ERR_FILE_SOURCE_NOT_FOUND if the source file was not found. * **/ +#ifdef FF_UNICODE_SUPPORT +FF_ERROR FF_Move(FF_IOMAN *pIoman, const FF_T_WCHAR *szSourceFile, const FF_T_WCHAR *szDestinationFile) { +#else FF_ERROR FF_Move(FF_IOMAN *pIoman, const FF_T_INT8 *szSourceFile, const FF_T_INT8 *szDestinationFile) { +#endif FF_ERROR Error; FF_FILE *pSrcFile, *pDestFile; FF_DIRENT MyFile; FF_T_UINT8 EntryBuffer[32]; FF_T_UINT16 i; FF_T_UINT32 DirCluster; + FF_FETCH_CONTEXT FetchContext; if(!pIoman) { return FF_ERR_NULL_POINTER; @@ -480,16 +632,34 @@ FF_ERROR FF_Move(FF_IOMAN *pIoman, const FF_T_INT8 *szSourceFile, const FF_T_INT pSrcFile = FF_Open(pIoman, szSourceFile, FF_MODE_DIR, &Error); } - if(pSrcFile) { + if(!pSrcFile) { + return Error; + } + if(pSrcFile) { // Create the new dirent. - FF_FetchEntry(pIoman, pSrcFile->DirCluster, pSrcFile->DirEntry, EntryBuffer); + Error = FF_InitEntryFetch(pIoman, pSrcFile->DirCluster, &FetchContext); + if(Error) { + FF_Close(pSrcFile); + return Error; + } + Error = FF_FetchEntryWithContext(pIoman, pSrcFile->DirEntry, &FetchContext, EntryBuffer); + if(Error) { + FF_Close(pSrcFile); + FF_CleanupEntryFetch(pIoman, &FetchContext); + return Error; + } + //FF_FetchEntry(pIoman, pSrcFile->DirCluster, pSrcFile->DirEntry, EntryBuffer); MyFile.Attrib = FF_getChar(EntryBuffer, (FF_T_UINT16)(FF_FAT_DIRENT_ATTRIB)); MyFile.Filesize = pSrcFile->Filesize; MyFile.ObjectCluster = pSrcFile->ObjectCluster; MyFile.CurrentItem = 0; +#ifdef FF_UNICODE_SUPPORT + i = (FF_T_UINT16) wcslen(szDestinationFile); +#else i = (FF_T_UINT16) strlen(szDestinationFile); +#endif while(i != 0) { if(szDestinationFile[i] == '\\' || szDestinationFile[i] == '/') { @@ -498,30 +668,62 @@ FF_ERROR FF_Move(FF_IOMAN *pIoman, const FF_T_INT8 *szSourceFile, const FF_T_INT i--; } +#ifdef FF_UNICODE_SUPPORT + wcsncpy(MyFile.FileName, (szDestinationFile + i + 1), FF_MAX_FILENAME); +#else strncpy(MyFile.FileName, (szDestinationFile + i + 1), FF_MAX_FILENAME); +#endif if(i == 0) { i = 1; } - DirCluster = FF_FindDir(pIoman, szDestinationFile, i); + DirCluster = FF_FindDir(pIoman, szDestinationFile, i, &Error); + if(Error) { + FF_Close(pSrcFile); + FF_CleanupEntryFetch(pIoman, &FetchContext); + return Error; + } if(DirCluster) { // Destination Dir was found, we can now create the new entry. - if(FF_CreateDirent(pIoman, DirCluster, &MyFile)) { + Error = FF_CreateDirent(pIoman, DirCluster, &MyFile); + if(Error) { FF_Close(pSrcFile); - return FF_ERR_FILE_COULD_NOT_CREATE_DIRENT; // FAILED + FF_CleanupEntryFetch(pIoman, &FetchContext); + return Error; // FAILED } // Edit the Directory Entry! (So it appears as deleted); FF_lockDIR(pIoman); { - FF_RmLFNs(pIoman, pSrcFile->DirCluster, pSrcFile->DirEntry); - FF_FetchEntry(pIoman, pSrcFile->DirCluster, pSrcFile->DirEntry, EntryBuffer); + + Error = FF_RmLFNs(pIoman, pSrcFile->DirEntry, &FetchContext); + if(Error) { + FF_unlockDIR(pIoman); + FF_Close(pSrcFile); + FF_CleanupEntryFetch(pIoman, &FetchContext); + return Error; + } + Error = FF_FetchEntryWithContext(pIoman, pSrcFile->DirEntry, &FetchContext, EntryBuffer); + if(Error) { + FF_unlockDIR(pIoman); + FF_Close(pSrcFile); + FF_CleanupEntryFetch(pIoman, &FetchContext); + return Error; + } EntryBuffer[0] = 0xE5; - FF_PushEntry(pIoman, pSrcFile->DirCluster, pSrcFile->DirEntry, EntryBuffer); + //FF_PushEntry(pIoman, pSrcFile->DirCluster, pSrcFile->DirEntry, EntryBuffer); + Error = FF_PushEntryWithContext(pIoman, pSrcFile->DirEntry, &FetchContext, EntryBuffer); + if(Error) { + FF_unlockDIR(pIoman); + FF_Close(pSrcFile); + FF_CleanupEntryFetch(pIoman, &FetchContext); + return Error; + } + FF_CleanupEntryFetch(pIoman, &FetchContext); } FF_unlockDIR(pIoman); FF_Close(pSrcFile); @@ -560,14 +762,19 @@ FF_T_BOOL FF_isEOF(FF_FILE *pFile) { } } -static FF_T_UINT32 FF_GetSequentialClusters(FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_T_UINT32 Limit) { +static FF_T_UINT32 FF_GetSequentialClusters(FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_T_UINT32 Limit, FF_ERROR *pError) { FF_T_UINT32 CurrentCluster; FF_T_UINT32 NextCluster = StartCluster; FF_T_UINT32 i = 0; + *pError = FF_ERR_NONE; + do { CurrentCluster = NextCluster; - NextCluster = FF_getFatEntry(pIoman, CurrentCluster); + NextCluster = FF_getFatEntry(pIoman, CurrentCluster, pError); + if(*pError) { + return 0; + } if(NextCluster == (CurrentCluster + 1)) { i++; } else { @@ -584,48 +791,40 @@ static FF_T_UINT32 FF_GetSequentialClusters(FF_IOMAN *pIoman, FF_T_UINT32 StartC return i; } -static FF_T_SINT32 FF_ReadClusters(FF_FILE *pFile, FF_T_UINT32 Count, FF_T_UINT8 *buffer) { - FF_T_UINT32 Sectors; +static FF_ERROR FF_ReadClusters(FF_FILE *pFile, FF_T_UINT32 Count, FF_T_UINT8 *buffer) { + FF_T_UINT32 ulSectors; FF_T_UINT32 SequentialClusters = 0; FF_T_UINT32 nItemLBA; - FF_T_SINT32 RetVal; + FF_T_SINT32 slRetVal; + FF_ERROR Error; while(Count != 0) { if((Count - 1) > 0) { - SequentialClusters = FF_GetSequentialClusters(pFile->pIoman, pFile->AddrCurrentCluster, (Count - 1)); + SequentialClusters = FF_GetSequentialClusters(pFile->pIoman, pFile->AddrCurrentCluster, (Count - 1), &Error); + if(Error) { + return Error; + } } - Sectors = (SequentialClusters + 1) * pFile->pIoman->pPartition->SectorsPerCluster; + ulSectors = (SequentialClusters + 1) * pFile->pIoman->pPartition->SectorsPerCluster; nItemLBA = FF_Cluster2LBA(pFile->pIoman, pFile->AddrCurrentCluster); nItemLBA = FF_getRealLBA(pFile->pIoman, nItemLBA); - do { - if(pFile->pIoman->pBlkDevice->fnReadBlocks) { -#ifdef FF_BLKDEV_USES_SEM - FF_PendSemaphore(pFile->pIoman->pSemaphore); -#endif - // Called from FF_Read, sem not claimed - RetVal = pFile->pIoman->pBlkDevice->fnReadBlocks(buffer, nItemLBA, Sectors, pFile->pIoman->pBlkDevice->pParam); -#ifdef FF_BLKDEV_USES_SEM - FF_ReleaseSemaphore(pFile->pIoman->pSemaphore); -#endif - if(RetVal == FF_ERR_DRIVER_BUSY) { - FF_Yield(); - FF_Sleep(FF_DRIVER_BUSY_SLEEP); - } - } else { - RetVal = FF_ERR_DEVICE_DRIVER_FAILED; - } - - }while(RetVal == FF_ERR_DRIVER_BUSY); + slRetVal = FF_BlockRead(pFile->pIoman, nItemLBA, ulSectors, buffer); + if(slRetVal < 0) { + return slRetVal; + } Count -= (SequentialClusters + 1); - pFile->AddrCurrentCluster = FF_TraverseFAT(pFile->pIoman, pFile->AddrCurrentCluster, (SequentialClusters + 1)); + pFile->AddrCurrentCluster = FF_TraverseFAT(pFile->pIoman, pFile->AddrCurrentCluster, (SequentialClusters + 1), &Error); + if(Error) { + return Error; + } pFile->CurrentCluster += (SequentialClusters + 1); - buffer += Sectors * pFile->pIoman->BlkSize; + buffer += ulSectors * pFile->pIoman->BlkSize; SequentialClusters = 0; } - return 0; + return FF_ERR_NONE; } @@ -637,6 +836,7 @@ static FF_ERROR FF_ExtendFile(FF_FILE *pFile, FF_T_UINT32 Size) { FF_T_UINT32 CurrentCluster, NextCluster; FF_T_UINT32 i; FF_DIRENT OriginalEntry; + FF_ERROR Error; if((pFile->Mode & FF_MODE_WRITE) != FF_MODE_WRITE) { return FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE; @@ -644,13 +844,25 @@ static FF_ERROR FF_ExtendFile(FF_FILE *pFile, FF_T_UINT32 Size) { if(pFile->Filesize == 0 && pFile->ObjectCluster == 0) { // No Allocated clusters. // Create a Cluster chain! - pFile->AddrCurrentCluster = FF_CreateClusterChain(pFile->pIoman); - if(!FF_GetEntry(pIoman, pFile->DirEntry, pFile->DirCluster, &OriginalEntry)) { - OriginalEntry.ObjectCluster = pFile->AddrCurrentCluster; - FF_PutEntry(pIoman, pFile->DirEntry, pFile->DirCluster, &OriginalEntry); - } else { - return FF_ERR_FILE_EXTEND_FAILED; + pFile->AddrCurrentCluster = FF_CreateClusterChain(pFile->pIoman, &Error); + + if(Error) { + return Error; } + + Error = FF_GetEntry(pIoman, pFile->DirEntry, pFile->DirCluster, &OriginalEntry); + + if(!Error) { + OriginalEntry.ObjectCluster = pFile->AddrCurrentCluster; + Error = FF_PutEntry(pIoman, pFile->DirEntry, pFile->DirCluster, &OriginalEntry); + } else { + return Error; + } + + if(Error) { + return Error; + } + pFile->ObjectCluster = pFile->AddrCurrentCluster; pFile->iChainLength = 1; pFile->CurrentCluster = 0; @@ -662,7 +874,10 @@ static FF_ERROR FF_ExtendFile(FF_FILE *pFile, FF_T_UINT32 Size) { } if(pFile->iChainLength == 0) { // First extension requiring the chain length, - pFile->iChainLength = FF_GetChainLength(pIoman, pFile->ObjectCluster, &pFile->iEndOfChain); + pFile->iChainLength = FF_GetChainLength(pIoman, pFile->ObjectCluster, &pFile->iEndOfChain, &Error); + if(Error) { + return Error; + } } nClusterToExtend = (nTotalClustersNeeded - pFile->iChainLength); @@ -673,65 +888,88 @@ static FF_ERROR FF_ExtendFile(FF_FILE *pFile, FF_T_UINT32 Size) { FF_lockFAT(pIoman); { for(i = 0; i <= nClusterToExtend; i++) { - CurrentCluster = FF_FindEndOfChain(pIoman, NextCluster); - NextCluster = FF_FindFreeCluster(pIoman); + CurrentCluster = FF_FindEndOfChain(pIoman, NextCluster, &Error); + if(Error) { + FF_unlockFAT(pIoman); + FF_DecreaseFreeClusters(pIoman, i); + return Error; + } + NextCluster = FF_FindFreeCluster(pIoman, &Error); + if(Error) { + FF_unlockFAT(pIoman); + FF_DecreaseFreeClusters(pIoman, i); + return Error; + } if(!NextCluster) { FF_unlockFAT(pIoman); + FF_DecreaseFreeClusters(pIoman, i); return FF_ERR_FAT_NO_FREE_CLUSTERS; } - FF_putFatEntry(pIoman, CurrentCluster, NextCluster); - FF_putFatEntry(pIoman, NextCluster, 0xFFFFFFFF); + + Error = FF_putFatEntry(pIoman, CurrentCluster, NextCluster); + if(Error) { + FF_unlockFAT(pIoman); + FF_DecreaseFreeClusters(pIoman, i); + return Error; + } + Error = FF_putFatEntry(pIoman, NextCluster, 0xFFFFFFFF); + if(Error) { + FF_unlockFAT(pIoman); + FF_DecreaseFreeClusters(pIoman, i); + return Error; + } } - pFile->iEndOfChain = FF_FindEndOfChain(pIoman, NextCluster); + pFile->iEndOfChain = FF_FindEndOfChain(pIoman, NextCluster, &Error); + if(Error) { + FF_unlockFAT(pIoman); + FF_DecreaseFreeClusters(pIoman, i); + return Error; + } } FF_unlockFAT(pIoman); pFile->iChainLength += i; - FF_DecreaseFreeClusters(pIoman, i); // Keep Tab of Numbers for fast FreeSize() + Error = FF_DecreaseFreeClusters(pIoman, i); // Keep Tab of Numbers for fast FreeSize() + if(Error) { + return Error; + } } return FF_ERR_NONE; } -static FF_T_SINT32 FF_WriteClusters(FF_FILE *pFile, FF_T_UINT32 Count, FF_T_UINT8 *buffer) { - FF_T_UINT32 Sectors; +static FF_ERROR FF_WriteClusters(FF_FILE *pFile, FF_T_UINT32 Count, FF_T_UINT8 *buffer) { + FF_T_UINT32 ulSectors; FF_T_UINT32 SequentialClusters = 0; FF_T_UINT32 nItemLBA; - FF_T_SINT32 RetVal; + FF_T_SINT32 slRetVal; + FF_ERROR Error; while(Count != 0) { if((Count - 1) > 0) { - SequentialClusters = FF_GetSequentialClusters(pFile->pIoman, pFile->AddrCurrentCluster, (Count - 1)); + SequentialClusters = FF_GetSequentialClusters(pFile->pIoman, pFile->AddrCurrentCluster, (Count - 1), &Error); + if(Error) { + return Error; + } } - Sectors = (SequentialClusters + 1) * pFile->pIoman->pPartition->SectorsPerCluster; + ulSectors = (SequentialClusters + 1) * pFile->pIoman->pPartition->SectorsPerCluster; nItemLBA = FF_Cluster2LBA(pFile->pIoman, pFile->AddrCurrentCluster); nItemLBA = FF_getRealLBA(pFile->pIoman, nItemLBA); - do { - if(pFile->pIoman->pBlkDevice->fnWriteBlocks) { -#ifdef FF_BLKDEV_USES_SEM - FF_PendSemaphore(pFile->pIoman->pSemaphore); -#endif - // Called from FF_Write, sem not claimed - RetVal = pFile->pIoman->pBlkDevice->fnWriteBlocks(buffer, nItemLBA, Sectors, pFile->pIoman->pBlkDevice->pParam); -#ifdef FF_BLKDEV_USES_SEM - FF_ReleaseSemaphore(pFile->pIoman->pSemaphore); -#endif - if(RetVal == FF_ERR_DRIVER_BUSY) { - FF_Yield(); - FF_Sleep(FF_DRIVER_BUSY_SLEEP); - } - } else { - RetVal = FF_ERR_DEVICE_DRIVER_FAILED; - } - - }while(RetVal == FF_ERR_DRIVER_BUSY); + slRetVal = FF_BlockWrite(pFile->pIoman, nItemLBA, ulSectors, buffer); + + if(slRetVal < 0) { + return slRetVal; + } Count -= (SequentialClusters + 1); - pFile->AddrCurrentCluster = FF_TraverseFAT(pFile->pIoman, pFile->AddrCurrentCluster, (SequentialClusters + 1)); + pFile->AddrCurrentCluster = FF_TraverseFAT(pFile->pIoman, pFile->AddrCurrentCluster, (SequentialClusters + 1), &Error); + if(Error) { + return Error; + } pFile->CurrentCluster += (SequentialClusters + 1); - buffer += Sectors * pFile->pIoman->BlkSize; + buffer += ulSectors * pFile->pIoman->BlkSize; SequentialClusters = 0; } @@ -763,6 +1001,7 @@ FF_T_SINT32 FF_Read(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, FF_T_UINT32 nRelClusterPos; FF_T_UINT32 nBytesPerCluster; FF_T_UINT32 nClusterDiff; + FF_ERROR Error; if(!pFile) { return FF_ERR_NULL_POINTER; @@ -785,7 +1024,10 @@ FF_T_SINT32 FF_Read(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nClusterDiff = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1) - pFile->CurrentCluster; if(nClusterDiff) { if(pFile->CurrentCluster < FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1)) { - pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff); + pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff, &Error); + if(Error) { + return Error; + } pFile->CurrentCluster += nClusterDiff; } } @@ -798,6 +1040,9 @@ FF_T_SINT32 FF_Read(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, if((nRelBlockPos + nBytes) < pIoman->BlkSize) { // Bytes to read are within a block and less than a block size. pBuffer = FF_GetBuffer(pIoman, nItemLBA, FF_MODE_READ); { + if(!pBuffer) { + return FF_ERR_DEVICE_DRIVER_FAILED; + } memcpy(buffer, (pBuffer->pBuffer + nRelBlockPos), nBytes); } FF_ReleaseBuffer(pIoman, pBuffer); @@ -813,6 +1058,9 @@ FF_T_SINT32 FF_Read(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nBytesToRead = pIoman->BlkSize - nRelBlockPos; pBuffer = FF_GetBuffer(pIoman, nItemLBA, FF_MODE_READ); { + if(!pBuffer) { + return FF_ERR_DEVICE_DRIVER_FAILED; + } // Here we copy to the sector boudary. memcpy(buffer, (pBuffer->pBuffer + nRelBlockPos), nBytesToRead); } @@ -834,7 +1082,10 @@ FF_T_SINT32 FF_Read(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nClusterDiff = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1) - pFile->CurrentCluster; if(nClusterDiff) { if(pFile->CurrentCluster < FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1)) { - pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff); + pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff, &Error); + if(Error) { + return Error; + } pFile->CurrentCluster += nClusterDiff; } } @@ -844,21 +1095,7 @@ FF_T_SINT32 FF_Read(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, sSectors = (FF_T_UINT16) (pIoman->pPartition->SectorsPerCluster - (nRelClusterPos / pIoman->BlkSize)); - do { - if(pIoman->pBlkDevice->fnReadBlocks) { -#ifdef FF_BLKDEV_USES_SEM - FF_PendSemaphore(pFile->pIoman->pSemaphore); -#endif - RetVal = pFile->pIoman->pBlkDevice->fnReadBlocks(buffer, nItemLBA, sSectors, pIoman->pBlkDevice->pParam); -#ifdef FF_BLKDEV_USES_SEM - FF_ReleaseSemaphore(pFile->pIoman->pSemaphore); -#endif - } - if(RetVal == FF_ERR_DRIVER_BUSY) { - FF_Yield(); - FF_Sleep(FF_DRIVER_BUSY_SLEEP); - } - }while(RetVal == FF_ERR_DRIVER_BUSY); + RetVal = FF_BlockRead(pIoman, nItemLBA, (FF_T_UINT32) sSectors, buffer); nBytesToRead = sSectors * pIoman->BlkSize; nBytes -= nBytesToRead; @@ -874,13 +1111,19 @@ FF_T_SINT32 FF_Read(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nClusterDiff = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1) - pFile->CurrentCluster; if(nClusterDiff) { if(pFile->CurrentCluster < FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1)) { - pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff); + pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff, &Error); + if(Error) { + return Error; + } pFile->CurrentCluster += nClusterDiff; } } //----- End of Contributor fix. - FF_ReadClusters(pFile, (nBytes / nBytesPerCluster), buffer); + RetVal = FF_ReadClusters(pFile, (nBytes / nBytesPerCluster), buffer); + if(RetVal < 0) { + return RetVal; + } nBytesToRead = (nBytesPerCluster * (nBytes / nBytesPerCluster)); pFile->FilePointer += nBytesToRead; @@ -897,29 +1140,22 @@ FF_T_SINT32 FF_Read(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nClusterDiff = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1) - pFile->CurrentCluster; if(nClusterDiff) { if(pFile->CurrentCluster < FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1)) { - pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff); + pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff, &Error); + if(Error) { + return Error; + } pFile->CurrentCluster += nClusterDiff; } } nItemLBA = FF_Cluster2LBA(pIoman, pFile->AddrCurrentCluster); nItemLBA = FF_getRealLBA(pIoman, nItemLBA + FF_getMajorBlockNumber(pIoman, pFile->FilePointer, 1)) + FF_getMinorBlockNumber(pIoman, pFile->FilePointer, 1); - - do { - if(pIoman->pBlkDevice->fnReadBlocks) { -#ifdef FF_BLKDEV_USES_SEM - FF_PendSemaphore(pFile->pIoman->pSemaphore); -#endif - RetVal = pFile->pIoman->pBlkDevice->fnReadBlocks(buffer, nItemLBA, sSectors, pIoman->pBlkDevice->pParam); -#ifdef FF_BLKDEV_USES_SEM - FF_ReleaseSemaphore(pFile->pIoman->pSemaphore); -#endif - } - if(RetVal == FF_ERR_DRIVER_BUSY) { - FF_Yield(); - FF_Sleep(FF_DRIVER_BUSY_SLEEP); - } - }while(RetVal == FF_ERR_DRIVER_BUSY); + + RetVal = FF_BlockRead(pIoman, nItemLBA, (FF_T_UINT32) sSectors, buffer); + + if(RetVal < 0) { + return RetVal; + } nBytesToRead = sSectors * pIoman->BlkSize; pFile->FilePointer += nBytesToRead; @@ -934,7 +1170,10 @@ FF_T_SINT32 FF_Read(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nClusterDiff = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1) - pFile->CurrentCluster; if(nClusterDiff) { if(pFile->CurrentCluster < FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1)) { - pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff); + pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff, &Error); + if(Error) { + return Error; + } pFile->CurrentCluster += nClusterDiff; } } @@ -943,6 +1182,9 @@ FF_T_SINT32 FF_Read(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nItemLBA = FF_getRealLBA(pIoman, nItemLBA + FF_getMajorBlockNumber(pIoman, pFile->FilePointer, 1)) + FF_getMinorBlockNumber(pIoman, pFile->FilePointer, 1); pBuffer = FF_GetBuffer(pIoman, nItemLBA, FF_MODE_READ); { + if(!pBuffer) { + return FF_ERR_DEVICE_DRIVER_FAILED; + } memcpy(buffer, pBuffer->pBuffer, nBytes); } FF_ReleaseBuffer(pIoman, pBuffer); @@ -980,6 +1222,7 @@ FF_T_SINT32 FF_GetC(FF_FILE *pFile) { FF_T_UINT32 relMinorBlockPos; FF_T_UINT32 clusterNum; FF_T_UINT32 nClusterDiff; + FF_ERROR Error; if(!pFile) { @@ -1000,7 +1243,10 @@ FF_T_SINT32 FF_GetC(FF_FILE *pFile) { nClusterDiff = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1) - pFile->CurrentCluster; if(nClusterDiff) { if(pFile->CurrentCluster < FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1)) { - pFile->AddrCurrentCluster = FF_TraverseFAT(pFile->pIoman, pFile->AddrCurrentCluster, nClusterDiff); + pFile->AddrCurrentCluster = FF_TraverseFAT(pFile->pIoman, pFile->AddrCurrentCluster, nClusterDiff, &Error); + if(Error) { + return Error; + } pFile->CurrentCluster += nClusterDiff; } } @@ -1012,7 +1258,7 @@ FF_T_SINT32 FF_GetC(FF_FILE *pFile) { pBuffer = FF_GetBuffer(pFile->pIoman, fileLBA, FF_MODE_READ); { if(!pBuffer) { - return -3; + return FF_ERR_DEVICE_DRIVER_FAILED; } retChar = pBuffer->pBuffer[relMinorBlockPos]; } @@ -1023,6 +1269,45 @@ FF_T_SINT32 FF_GetC(FF_FILE *pFile) { return (FF_T_INT32) retChar; } + +/** + * @public + * @brief Gets a Line from a Text File, but no more than ulLimit charachters. The line will be NULL terminated. + * + * The behaviour of this function is undefined when called on a binary file. + * It should just read in ulLimit bytes of binary, and ZERO terminate the line. + * + * This function works for both UNIX line feeds, and Windows CRLF type files. + * + * @param pFile The FF_FILE object pointer. + * @param szLine The charachter buffer where the line should be stored. + * @param ulLimit This should be the max number of charachters that szLine can hold. + * + * @return The number of charachters read from the line, on success. + * @return 0 when no more lines are available, or when ulLimit is 0. + * @return FF_ERR_NULL_POINTER if pFile or szLine are NULL; + * + **/ +FF_T_SINT32 FF_GetLine(FF_FILE *pFile, FF_T_INT8 *szLine, FF_T_UINT32 ulLimit) { + FF_T_SINT32 c; + FF_T_UINT32 i; + + if(!pFile || !szLine) { + return FF_ERR_NULL_POINTER; + } + + for(i = 0; i < (ulLimit - 1) && (c=FF_GetC(pFile)) >= 0 && c != '\n'; ++i) { + if(c == '\r') { + i--; + } else { + szLine[i] = (FF_T_INT8) c; + } + } + + szLine[i] = '\0'; + return i; +} + FF_T_UINT32 FF_Tell(FF_FILE *pFile) { return pFile->FilePointer; } @@ -1047,7 +1332,7 @@ FF_T_SINT32 FF_Write(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, FF_BUFFER *pBuffer; FF_T_UINT32 nRelBlockPos; FF_T_UINT32 nItemLBA; - FF_T_SINT32 RetVal = 0; + FF_T_SINT32 slRetVal = 0; FF_T_UINT16 sSectors; FF_T_UINT32 nRelClusterPos; FF_T_UINT32 nBytesPerCluster, nClusterDiff, nClusters; @@ -1085,7 +1370,10 @@ FF_T_SINT32 FF_Write(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nClusterDiff = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1) - pFile->CurrentCluster; if(nClusterDiff) { if(pFile->CurrentCluster != FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1)) { - pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff); + pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff, &Error); + if(Error) { + return Error; + } pFile->CurrentCluster += nClusterDiff; } } @@ -1096,6 +1384,9 @@ FF_T_SINT32 FF_Write(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, if((nRelBlockPos + nBytes) < pIoman->BlkSize) { // Bytes to read are within a block and less than a block size. pBuffer = FF_GetBuffer(pIoman, nItemLBA, FF_MODE_WRITE); { + if(!pBuffer) { + return FF_ERR_DEVICE_DRIVER_FAILED; + } memcpy((pBuffer->pBuffer + nRelBlockPos), buffer, nBytes); } FF_ReleaseBuffer(pIoman, pBuffer); @@ -1111,6 +1402,9 @@ FF_T_SINT32 FF_Write(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nBytesToWrite = pIoman->BlkSize - nRelBlockPos; pBuffer = FF_GetBuffer(pIoman, nItemLBA, FF_MODE_WRITE); { + if(!pBuffer) { + return FF_ERR_DEVICE_DRIVER_FAILED; + } // Here we copy to the sector boudary. memcpy((pBuffer->pBuffer + nRelBlockPos), buffer, nBytesToWrite); } @@ -1130,7 +1424,10 @@ FF_T_SINT32 FF_Write(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nClusterDiff = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1) - pFile->CurrentCluster; if(nClusterDiff) { if(pFile->CurrentCluster < FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1)) { - pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff); + pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff, &Error); + if(Error) { + return Error; + } pFile->CurrentCluster += nClusterDiff; } } @@ -1139,22 +1436,11 @@ FF_T_SINT32 FF_Write(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nItemLBA = FF_getRealLBA(pIoman, nItemLBA + FF_getMajorBlockNumber(pIoman, pFile->FilePointer, 1)) + FF_getMinorBlockNumber(pIoman, pFile->FilePointer, 1); sSectors = (FF_T_UINT16) (pIoman->pPartition->SectorsPerCluster - (nRelClusterPos / pIoman->BlkSize)); - - do { - if(pIoman->pBlkDevice->fnWriteBlocks) { -#ifdef FF_BLKDEV_USES_SEM - FF_PendSemaphore(pFile->pIoman->pSemaphore); -#endif - RetVal = pFile->pIoman->pBlkDevice->fnWriteBlocks(buffer, nItemLBA, sSectors, pIoman->pBlkDevice->pParam); -#ifdef FF_BLKDEV_USES_SEM - FF_ReleaseSemaphore(pFile->pIoman->pSemaphore); -#endif - } - if(RetVal == FF_ERR_DRIVER_BUSY) { - FF_Yield(); - FF_Sleep(FF_DRIVER_BUSY_SLEEP); - } - }while(RetVal == FF_ERR_DRIVER_BUSY); + + slRetVal = FF_BlockWrite(pFile->pIoman, nItemLBA, sSectors, buffer); + if(slRetVal < 0) { + return slRetVal; + } nBytesToWrite = sSectors * pIoman->BlkSize; nBytes -= nBytesToWrite; @@ -1170,7 +1456,10 @@ FF_T_SINT32 FF_Write(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nClusterDiff = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1) - pFile->CurrentCluster; if(nClusterDiff) { if(pFile->CurrentCluster < FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1)) { - pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff); + pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff, &Error); + if(Error) { + return Error; + } pFile->CurrentCluster += nClusterDiff; } } @@ -1178,7 +1467,10 @@ FF_T_SINT32 FF_Write(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nClusters = (nBytes / nBytesPerCluster); - FF_WriteClusters(pFile, nClusters, buffer); + slRetVal = FF_WriteClusters(pFile, nClusters, buffer); + if(slRetVal < 0) { + return slRetVal; + } nBytesToWrite = (nBytesPerCluster * nClusters); @@ -1196,7 +1488,10 @@ FF_T_SINT32 FF_Write(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nClusterDiff = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1) - pFile->CurrentCluster; if(nClusterDiff) { if(pFile->CurrentCluster < FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1)) { - pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff); + pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff, &Error); + if(Error) { + return Error; + } pFile->CurrentCluster += nClusterDiff; } } @@ -1204,28 +1499,16 @@ FF_T_SINT32 FF_Write(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nItemLBA = FF_Cluster2LBA(pIoman, pFile->AddrCurrentCluster); nItemLBA = FF_getRealLBA(pIoman, nItemLBA + FF_getMajorBlockNumber(pIoman, pFile->FilePointer, 1)) + FF_getMinorBlockNumber(pIoman, pFile->FilePointer, 1); - do { - if(pIoman->pBlkDevice->fnWriteBlocks) { -#ifdef FF_BLKDEV_USES_SEM - FF_PendSemaphore(pFile->pIoman->pSemaphore); -#endif - RetVal = pFile->pIoman->pBlkDevice->fnWriteBlocks(buffer, nItemLBA, sSectors, pIoman->pBlkDevice->pParam); -#ifdef FF_BLKDEV_USES_SEM - FF_ReleaseSemaphore(pFile->pIoman->pSemaphore); -#endif - } - if(RetVal == FF_ERR_DRIVER_BUSY) { - FF_Yield(); - FF_Sleep(FF_DRIVER_BUSY_SLEEP); - } - }while(RetVal == FF_ERR_DRIVER_BUSY); + slRetVal = FF_BlockWrite(pFile->pIoman, nItemLBA, sSectors, buffer); + if(slRetVal < 0) { + return slRetVal; + } nBytesToWrite = sSectors * pIoman->BlkSize; pFile->FilePointer += nBytesToWrite; nBytes -= nBytesToWrite; buffer += nBytesToWrite; nBytesWritten += nBytesToWrite; - } //---------- Write (memcpy) Remaining Bytes @@ -1234,7 +1517,10 @@ FF_T_SINT32 FF_Write(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nClusterDiff = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1) - pFile->CurrentCluster; if(nClusterDiff) { if(pFile->CurrentCluster < FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1)) { - pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff); + pFile->AddrCurrentCluster = FF_TraverseFAT(pIoman, pFile->AddrCurrentCluster, nClusterDiff, &Error); + if(Error) { + return Error; + } pFile->CurrentCluster += nClusterDiff; } } @@ -1243,6 +1529,9 @@ FF_T_SINT32 FF_Write(FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, nItemLBA = FF_getRealLBA(pIoman, nItemLBA + FF_getMajorBlockNumber(pIoman, pFile->FilePointer, 1)) + FF_getMinorBlockNumber(pIoman, pFile->FilePointer, 1); pBuffer = FF_GetBuffer(pIoman, nItemLBA, FF_MODE_WRITE); { + if(!pBuffer) { + return FF_ERR_DEVICE_DRIVER_FAILED; + } memcpy(pBuffer->pBuffer, buffer, nBytes); } FF_ReleaseBuffer(pIoman, pBuffer); @@ -1279,6 +1568,7 @@ FF_T_SINT32 FF_PutC(FF_FILE *pFile, FF_T_UINT8 pa_cValue) { FF_T_UINT32 iItemLBA; FF_T_UINT32 iRelPos; FF_T_UINT32 nClusterDiff; + FF_ERROR Error; if(!pFile) { // Ensure we don't have a Null file pointer on a Public interface. return FF_ERR_NULL_POINTER; @@ -1298,18 +1588,24 @@ FF_T_SINT32 FF_PutC(FF_FILE *pFile, FF_T_UINT8 pa_cValue) { iRelPos = FF_getMinorBlockEntry(pFile->pIoman, pFile->FilePointer, 1); // Handle File Space Allocation. - FF_ExtendFile(pFile, pFile->FilePointer + 1); + Error = FF_ExtendFile(pFile, pFile->FilePointer + 1); + if(Error) { + return Error; + } nClusterDiff = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1) - pFile->CurrentCluster; if(nClusterDiff) { if(pFile->CurrentCluster < FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1)) { - pFile->AddrCurrentCluster = FF_TraverseFAT(pFile->pIoman, pFile->AddrCurrentCluster, nClusterDiff); + pFile->AddrCurrentCluster = FF_TraverseFAT(pFile->pIoman, pFile->AddrCurrentCluster, nClusterDiff, &Error); + if(Error) { + return Error; + } pFile->CurrentCluster += nClusterDiff; } } iItemLBA = FF_Cluster2LBA(pFile->pIoman, pFile->AddrCurrentCluster) + FF_getMajorBlockNumber(pFile->pIoman, pFile->FilePointer, (FF_T_UINT16) 1); - iItemLBA = FF_getRealLBA (pFile->pIoman, iItemLBA) + FF_getMinorBlockNumber(pFile->pIoman, pFile->FilePointer, (FF_T_UINT16) 1); + iItemLBA = FF_getRealLBA (pFile->pIoman, iItemLBA) + FF_getMinorBlockNumber(pFile->pIoman, pFile->FilePointer, (FF_T_UINT16) 1); pBuffer = FF_GetBuffer(pFile->pIoman, iItemLBA, FF_MODE_WRITE); { @@ -1339,22 +1635,32 @@ FF_T_SINT32 FF_PutC(FF_FILE *pFile, FF_T_UINT8 pa_cValue) { * * @return 0 on Sucess, * @return -2 if offset results in an invalid position in the file. - * @return -1 if a FF_FILE pointer was not recieved. + * @return FF_ERR_NULL_POINTER if a FF_FILE pointer was not recieved. * @return -3 if an invalid origin was provided. * **/ FF_ERROR FF_Seek(FF_FILE *pFile, FF_T_SINT32 Offset, FF_T_INT8 Origin) { + FF_ERROR Error; + if(!pFile) { return FF_ERR_NULL_POINTER; } + Error = FF_FlushCache(pFile->pIoman); + if(Error) { + return Error; + } + switch(Origin) { case FF_SEEK_SET: if((FF_T_UINT32) Offset <= pFile->Filesize && Offset >= 0) { pFile->FilePointer = Offset; pFile->CurrentCluster = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1); - pFile->AddrCurrentCluster = FF_TraverseFAT(pFile->pIoman, pFile->ObjectCluster, pFile->CurrentCluster); + pFile->AddrCurrentCluster = FF_TraverseFAT(pFile->pIoman, pFile->ObjectCluster, pFile->CurrentCluster, &Error); + if(Error) { + return Error; + } } else { return -2; } @@ -1364,7 +1670,10 @@ FF_ERROR FF_Seek(FF_FILE *pFile, FF_T_SINT32 Offset, FF_T_INT8 Origin) { if((Offset + pFile->FilePointer) <= pFile->Filesize && (Offset + (FF_T_SINT32) pFile->FilePointer) >= 0) { pFile->FilePointer = Offset + pFile->FilePointer; pFile->CurrentCluster = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1); - pFile->AddrCurrentCluster = FF_TraverseFAT(pFile->pIoman, pFile->ObjectCluster, pFile->CurrentCluster); + pFile->AddrCurrentCluster = FF_TraverseFAT(pFile->pIoman, pFile->ObjectCluster, pFile->CurrentCluster, &Error); + if(Error) { + return Error; + } } else { return -2; } @@ -1374,7 +1683,10 @@ FF_ERROR FF_Seek(FF_FILE *pFile, FF_T_SINT32 Offset, FF_T_INT8 Origin) { if((Offset + (FF_T_SINT32) pFile->Filesize) >= 0 && (Offset + pFile->Filesize) <= pFile->Filesize) { pFile->FilePointer = Offset + pFile->Filesize; pFile->CurrentCluster = FF_getClusterChainNumber(pFile->pIoman, pFile->FilePointer, 1); - pFile->AddrCurrentCluster = FF_TraverseFAT(pFile->pIoman, pFile->ObjectCluster, pFile->CurrentCluster); + pFile->AddrCurrentCluster = FF_TraverseFAT(pFile->pIoman, pFile->ObjectCluster, pFile->CurrentCluster, &Error); + if(Error) { + return Error; + } } else { return -2; } @@ -1419,14 +1731,15 @@ FF_ERROR FF_Close(FF_FILE *pFile) { if(!pFile->FileDeleted) { if(pFile->Filesize != OriginalEntry.Filesize) { OriginalEntry.Filesize = pFile->Filesize; - FF_PutEntry(pFile->pIoman, pFile->DirEntry, pFile->DirCluster, &OriginalEntry); + Error = FF_PutEntry(pFile->pIoman, pFile->DirEntry, pFile->DirCluster, &OriginalEntry); + if(Error) { + return Error; + } } } - //if(pFile->Mode == FF_MODE_WRITE) { - FF_FlushCache(pFile->pIoman); // Ensure all modfied blocks are flushed to disk! - //} - + Error = FF_FlushCache(pFile->pIoman); // Ensure all modfied blocks are flushed to disk! + // Handle Linked list! FF_PendSemaphore(pFile->pIoman->pSemaphore); { // Semaphore is required, or linked list could become corrupted. @@ -1444,6 +1757,11 @@ FF_ERROR FF_Close(FF_FILE *pFile) { // If file written, flush to disk FF_FREE(pFile); + + if(Error) { + return Error; + } + // Simply free the pointer! return FF_ERR_NONE; } diff --git a/reactos/lib/3rdparty/fullfat/ff_format.c b/reactos/lib/3rdparty/fullfat/ff_format.c new file mode 100644 index 00000000000..8799f9a204e --- /dev/null +++ b/reactos/lib/3rdparty/fullfat/ff_format.c @@ -0,0 +1,132 @@ +/***************************************************************************** + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * + * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + * IMPORTANT NOTICE: * + * ================= * + * Alternative Licensing is available directly from the Copyright holder, * + * (James Walmsley). For more information consult LICENSING.TXT to obtain * + * a Commercial license. * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * Removing the above notice is illegal and will invalidate this license. * + ***************************************************************************** + * See http://worm.me.uk/fullfat for more information. * + * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + *****************************************************************************/ + +/** + * @file ff_format.c + * @author James Walmsley + * @ingroup FORMAT + * + * @defgroup FORMAT Independent FAT Formatter + * @brief Provides an interface to format a partition with FAT. + * + * + * + **/ + + +#include "ff_format.h" +#include "ff_types.h" +#include "ff_ioman.h" +#include "ff_fatdef.h" + +static FF_T_SINT8 FF_PartitionCount (FF_T_UINT8 *pBuffer) +{ + FF_T_SINT8 count = 0; + FF_T_SINT8 part; + // Check PBR or MBR signature + if (FF_getChar(pBuffer, FF_FAT_MBR_SIGNATURE) != 0x55 && + FF_getChar(pBuffer, FF_FAT_MBR_SIGNATURE) != 0xAA ) { + // No MBR, but is it a PBR ? + if (FF_getChar(pBuffer, 0) == 0xEB && // PBR Byte 0 + FF_getChar(pBuffer, 2) == 0x90 && // PBR Byte 2 + (FF_getChar(pBuffer, 21) & 0xF0) == 0xF0) {// PBR Byte 21 : Media byte + return 1; // No MBR but PBR exist then only one partition + } + return 0; // No MBR and no PBR then no partition found + } + for (part = 0; part < 4; part++) { + FF_T_UINT8 active = FF_getChar(pBuffer, FF_FAT_PTBL + FF_FAT_PTBL_ACTIVE + (16 * part)); + FF_T_UINT8 part_id = FF_getChar(pBuffer, FF_FAT_PTBL + FF_FAT_PTBL_ID + (16 * part)); + // The first sector must be a MBR, then check the partition entry in the MBR + if (active != 0x80 && (active != 0 || part_id == 0)) { + break; + } + count++; + } + return count; +} + +FF_ERROR FF_FormatPartition(FF_IOMAN *pIoman, FF_T_UINT32 ulPartitionNumber, FF_T_UINT32 ulClusterSize) { + + FF_BUFFER *pBuffer; + FF_T_UINT8 ucPartitionType; + FF_T_SINT8 scPartitionCount; + + FF_T_UINT32 /*ulPartitionBeginLBA, ulPartitionLength,*/ ulPnum; + + FF_ERROR Error = FF_ERR_NONE; + + ulClusterSize = 0; + + // Get Partition Metrics, and pass on to FF_Format() function + + pBuffer = FF_GetBuffer(pIoman, 0, FF_MODE_READ); + { + if(!pBuffer) { + return FF_ERR_DEVICE_DRIVER_FAILED; + } + + scPartitionCount = FF_PartitionCount(pBuffer->pBuffer); + + ucPartitionType = FF_getChar(pBuffer->pBuffer, FF_FAT_PTBL + FF_FAT_PTBL_ID); + + if(ucPartitionType == 0xEE) { + // Handle Extended Partitions + ulPnum = 0; + } else { + if(ulPartitionNumber > (FF_T_UINT32) scPartitionCount) { + FF_ReleaseBuffer(pIoman, pBuffer); + return FF_ERR_IOMAN_INVALID_PARTITION_NUM; + } + ulPnum = ulPartitionNumber; + } + + } + FF_ReleaseBuffer(pIoman, pBuffer); + + + + return Error; + +} + +FF_ERROR FF_Format(FF_IOMAN *pIoman, FF_T_UINT32 ulStartLBA, FF_T_UINT32 ulEndLBA, FF_T_UINT32 ulClusterSize) { + FF_T_UINT32 ulTotalSectors; + FF_T_UINT32 ulTotalClusters; + + ulTotalSectors = ulEndLBA - ulStartLBA; + ulTotalClusters = ulTotalSectors / (ulClusterSize / pIoman->BlkSize); + + + return -1; + + +} \ No newline at end of file diff --git a/reactos/lib/3rdparty/fullfat/ff_hash.c b/reactos/lib/3rdparty/fullfat/ff_hash.c index 4a07c81d37e..6357987b313 100644 --- a/reactos/lib/3rdparty/fullfat/ff_hash.c +++ b/reactos/lib/3rdparty/fullfat/ff_hash.c @@ -43,9 +43,9 @@ #include #include -#ifdef FF_HASH_TABLE_SUPPORT +#ifdef FF_HASH_CACHE struct _FF_HASH_TABLE { - FF_T_UINT8 bitTable[FF_HASH_TABLE_SIZE]; + FF_T_UINT8 bitTable[FF_HASH_TABLE_SIZE]; }; /** diff --git a/reactos/lib/3rdparty/fullfat/ff_ioman.c b/reactos/lib/3rdparty/fullfat/ff_ioman.c index 60871f831a0..8e8fc32d418 100644 --- a/reactos/lib/3rdparty/fullfat/ff_ioman.c +++ b/reactos/lib/3rdparty/fullfat/ff_ioman.c @@ -46,9 +46,10 @@ #include "ff_ioman.h" // Includes ff_types.h, ff_safety.h, #include "ff_fatdef.h" +#include "ff_crc.h" -extern FF_T_UINT32 FF_FindFreeCluster (FF_IOMAN *pIoman); -extern FF_T_UINT32 FF_CountFreeClusters (FF_IOMAN *pIoman); +//extern FF_T_UINT32 FF_FindFreeCluster (FF_IOMAN *pIoman); +extern FF_T_UINT32 FF_CountFreeClusters (FF_IOMAN *pIoman, FF_ERROR *pError); static void FF_IOMAN_InitBufferDescriptors(FF_IOMAN *pIoman); @@ -57,7 +58,7 @@ static void FF_IOMAN_InitBufferDescriptors(FF_IOMAN *pIoman); * @brief Creates an FF_IOMAN object, to initialise FullFAT * * @param pCacheMem Pointer to a buffer for the cache. (NULL if ok to Malloc). - * @param Size The size of the provided buffer, or size of the cache to be created. + * @param Size The size of the provided buffer, or size of the cache to be created. (Must be atleast 2 * BlkSize). Always a multiple of BlkSize. * @param BlkSize The block size of devices to be attached. If in doubt use 512. * @param pError Pointer to a signed byte for error checking. Can be NULL if not required. * @param pError To be checked when a NULL pointer is returned. @@ -77,16 +78,16 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl *pError = FF_ERR_NONE; } - if((BlkSize % 512) != 0 || Size == 0) { + if((BlkSize % 512) != 0 || BlkSize == 0) { if(pError) { - *pError = FF_ERR_IOMAN_BAD_BLKSIZE; + *pError = FF_ERR_IOMAN_BAD_BLKSIZE | FF_CREATEIOMAN; } return NULL; // BlkSize Size not a multiple of 512 > 0 } - if((Size % BlkSize) != 0 || Size == 0) { + if((Size % BlkSize) != 0 || Size == 0 || Size == BlkSize) { // Size must now be atleast 2 * BlkSize (or a deadlock will occur). if(pError) { - *pError = FF_ERR_IOMAN_BAD_MEMSIZE; + *pError = FF_ERR_IOMAN_BAD_MEMSIZE | FF_CREATEIOMAN; } return NULL; // Memory Size not a multiple of BlkSize > 0 } @@ -95,7 +96,7 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl if(!pIoman) { // Ensure malloc() succeeded. if(pError) { - *pError = FF_ERR_NOT_ENOUGH_MEMORY; + *pError = FF_ERR_NOT_ENOUGH_MEMORY | FF_CREATEIOMAN; } return NULL; } @@ -107,7 +108,7 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl pIoman->pPartition = (FF_PARTITION *) FF_MALLOC(sizeof(FF_PARTITION)); if(!pIoman->pPartition) { if(pError) { - *pError = FF_ERR_NOT_ENOUGH_MEMORY; + *pError = FF_ERR_NOT_ENOUGH_MEMORY | FF_CREATEIOMAN; } FF_DestroyIOMAN(pIoman); return NULL; @@ -122,17 +123,25 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl for(i = 0; i < FF_PATH_CACHE_DEPTH; i++) { pIoman->pPartition->PathCache[i].DirCluster = 0; pIoman->pPartition->PathCache[i].Path[0] = '\0'; -#ifdef FF_HASH_TABLE_SUPPORT +/*#ifdef FF_HASH_TABLE_SUPPORT pIoman->pPartition->PathCache[i].pHashTable = FF_CreateHashTable(); pIoman->pPartition->PathCache[i].bHashed = FF_FALSE; +#endif*/ + } #endif + +#ifdef FF_HASH_CACHE + for(i = 0; i < FF_HASH_CACHE_DEPTH; i++) { + pIoman->HashCache[i].pHashTable = FF_CreateHashTable(); + pIoman->HashCache[i].ulDirCluster = 0; + pIoman->HashCache[i].ulMisses = 100; } #endif pIoman->pBlkDevice = (FF_BLK_DEVICE *) FF_MALLOC(sizeof(FF_BLK_DEVICE)); if(!pIoman->pBlkDevice) { // If succeeded, flag that allocation. if(pError) { - *pError = FF_ERR_NOT_ENOUGH_MEMORY; + *pError = FF_ERR_NOT_ENOUGH_MEMORY | FF_CREATEIOMAN; } FF_DestroyIOMAN(pIoman); return NULL; @@ -141,8 +150,8 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl pIoman->MemAllocation |= FF_IOMAN_ALLOC_BLKDEV; // Make sure all pointers are NULL - pIoman->pBlkDevice->fnReadBlocks = NULL; - pIoman->pBlkDevice->fnWriteBlocks = NULL; + pIoman->pBlkDevice->fnpReadBlocks = NULL; + pIoman->pBlkDevice->fnpWriteBlocks = NULL; pIoman->pBlkDevice->pParam = NULL; // Organise the memory provided, or create our own! @@ -153,7 +162,7 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl pIoman->pCacheMem = (FF_T_UINT8 *) pLong; if(!pIoman->pCacheMem) { if(pError) { - *pError = FF_ERR_NOT_ENOUGH_MEMORY; + *pError = FF_ERR_NOT_ENOUGH_MEMORY | FF_CREATEIOMAN; } FF_DestroyIOMAN(pIoman); return NULL; @@ -175,7 +184,7 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl if(!pIoman->pBuffers) { if(pError) { - *pError = FF_ERR_NOT_ENOUGH_MEMORY; + *pError = FF_ERR_NOT_ENOUGH_MEMORY | FF_CREATEIOMAN; } FF_DestroyIOMAN(pIoman); return NULL; // HT added @@ -188,6 +197,10 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl // Finally create a Semaphore for Buffer Description modifications. pIoman->pSemaphore = FF_CreateSemaphore(); +#ifdef FF_BLKDEV_USES_SEM + pIoman->pBlkDevSemaphore = FF_CreateSemaphore(); +#endif + return pIoman; // Sucess, return the created object. } @@ -202,9 +215,13 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl **/ FF_ERROR FF_DestroyIOMAN(FF_IOMAN *pIoman) { +#ifdef FF_HASH_CACHE + FF_T_UINT32 i; +#endif + // Ensure no NULL pointer was provided. if(!pIoman) { - return FF_ERR_NULL_POINTER; + return FF_ERR_NULL_POINTER | FF_DESTROYIOMAN; } // Ensure pPartition pointer was allocated. @@ -231,6 +248,18 @@ FF_ERROR FF_DestroyIOMAN(FF_IOMAN *pIoman) { if(pIoman->pSemaphore) { FF_DestroySemaphore(pIoman->pSemaphore); } +#ifdef FF_BLKDEV_USES_SEM + if(pIoman->pBlkDevSemaphore) { + FF_DestroySemaphore(pIoman->pBlkDevSemaphore); + } +#endif + + // Destroy HashCache +#ifdef FF_HASH_CACHE + for(i = 0; i < FF_HASH_CACHE_DEPTH; i++) { + FF_DestroyHashTable(pIoman->HashCache[i].pHashTable); + } +#endif // Finally free the FF_IOMAN object. FF_FREE(pIoman); @@ -256,94 +285,6 @@ static void FF_IOMAN_InitBufferDescriptors(FF_IOMAN *pIoman) { } } -/** - * @private - * @brief Tests the Mode for validity. - * - * @param Mode Mode of buffer to check. - * - * @return FF_TRUE when valid, else FF_FALSE. - **/ -/*static FF_T_BOOL FF_IOMAN_ModeValid(FF_T_UINT8 Mode) { - if(Mode == FF_MODE_READ || Mode == FF_MODE_WRITE) { - return FF_TRUE; - } - return FF_FALSE; -}*/ - - -/** - * @private - * @brief Fills a buffer with the appropriate sector via the device driver. - * - * @param pIoman FF_IOMAN object. - * @param Sector LBA address of the sector to fetch. - * @param pBuffer Pointer to a byte-wise buffer to store the fetched data. - * - * HT Note: will be called while semaphore claimed (by FF_GetBuffer) - * - * @return FF_TRUE when valid, else FF_FALSE. - **/ -static FF_ERROR FF_IOMAN_FillBuffer(FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_UINT8 *pBuffer) { - FF_T_SINT32 retVal = 0; - if(pIoman->pBlkDevice->fnReadBlocks) { // Make sure we don't execute a NULL. - do{ - // Called from FF_GetBuffer with semaphore claimed - retVal = pIoman->pBlkDevice->fnReadBlocks(pBuffer, Sector, 1, pIoman->pBlkDevice->pParam); - if(retVal == FF_ERR_DRIVER_BUSY) { - FF_Sleep(FF_DRIVER_BUSY_SLEEP); - } - } while(retVal == FF_ERR_DRIVER_BUSY); - if(retVal < 0) { - return -1; // FF_ERR_DRIVER_FATAL_ERROR was returned Fail! - } else { - if(retVal == 1) { - return 0; // 1 Block was sucessfully read. - } else { - return -1; // 0 Blocks we're read, Error! - } - } - } - return -1; // error no device diver registered. -} - - -/** - * @private - * @brief Flushes a buffer to the device driver. - * - * @param pIoman FF_IOMAN object. - * @param Sector LBA address of the sector to fetch. - * @param pBuffer Pointer to a byte-wise buffer to store the fetched data. - * - * - * HT made it a globally accesible function to be used by new module ff_format.c - * Note that this function is called when semaphore is already locked - * - * @return FF_TRUE when valid, else FF_FALSE. - **/ -/* static */ FF_ERROR FF_IOMAN_FlushBuffer(FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_UINT8 *pBuffer) { - FF_T_SINT32 retVal = 0; - if(pIoman->pBlkDevice->fnWriteBlocks) { // Make sure we don't execute a NULL. - do{ - retVal = pIoman->pBlkDevice->fnWriteBlocks(pBuffer, Sector, 1, pIoman->pBlkDevice->pParam); - if(retVal == FF_ERR_DRIVER_BUSY) { - FF_Sleep(FF_DRIVER_BUSY_SLEEP); - } - } while(retVal == FF_ERR_DRIVER_BUSY); - if(retVal < 0) { - return -1; // FF_ERR_DRIVER_FATAL_ERROR was returned Fail! - } else { - if(retVal == 1) { - return FF_ERR_NONE; // 1 Block was sucessfully written. - } else { - return -1; // 0 Blocks we're written, Error! - } - } - } - return -1; // error no device diver registered. -} - /** * @private @@ -358,7 +299,7 @@ FF_ERROR FF_FlushCache(FF_IOMAN *pIoman) { FF_T_UINT16 i,x; if(!pIoman) { - return FF_ERR_NULL_POINTER; + return FF_ERR_NULL_POINTER | FF_FLUSHCACHE; } FF_PendSemaphore(pIoman->pSemaphore); @@ -366,7 +307,7 @@ FF_ERROR FF_FlushCache(FF_IOMAN *pIoman) { for(i = 0; i < pIoman->CacheSize; i++) { if((pIoman->pBuffers + i)->NumHandles == 0 && (pIoman->pBuffers + i)->Modified == FF_TRUE) { - FF_IOMAN_FlushBuffer(pIoman, (pIoman->pBuffers + i)->Sector, (pIoman->pBuffers + i)->pBuffer); + FF_BlockWrite(pIoman, (pIoman->pBuffers + i)->Sector, 1, (pIoman->pBuffers + i)->pBuffer); // Buffer has now been flushed, mark it as a read buffer and unmodified. (pIoman->pBuffers + i)->Mode = FF_MODE_READ; @@ -389,13 +330,6 @@ FF_ERROR FF_FlushCache(FF_IOMAN *pIoman) { return FF_ERR_NONE; } -/*static FF_T_BOOL FF_isFATSector(FF_IOMAN *pIoman, FF_T_UINT32 Sector) { - if(Sector >= pIoman->pPartition->FatBeginLBA && Sector < (pIoman->pPartition->FatBeginLBA + pIoman->pPartition->ReservedSectors)) { - return FF_TRUE; - } - return FF_FALSE; -}*/ - FF_BUFFER *FF_GetBuffer(FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_UINT8 Mode) { FF_BUFFER *pBuffer; FF_BUFFER *pBufLRU = NULL; @@ -407,35 +341,13 @@ FF_BUFFER *FF_GetBuffer(FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_UINT8 Mode) { while(!pBufMatch) { FF_PendSemaphore(pIoman->pSemaphore); { - for(i = 0; i < pIoman->CacheSize; i++) { + pBuffer = pIoman->pBuffers; + // HT if a perfect match has priority, find that first + for(i = 0; i < pIoman->CacheSize; i++, pBuffer++) { pBuffer = (pIoman->pBuffers + i); if(pBuffer->Sector == Sector && pBuffer->Valid == FF_TRUE) { pBufMatch = pBuffer; - } else { - if(pBuffer->NumHandles == 0) { - pBuffer->LRU += 1; - - if(!pBufLRU) { - pBufLRU = pBuffer; - } - if(!pBufLHITS) { - pBufLHITS = pBuffer; - } - - if(pBuffer->LRU >= pBufLRU->LRU) { - if(pBuffer->LRU == pBufLRU->LRU) { - if(pBuffer->Persistance > pBufLRU->Persistance) { - pBufLRU = pBuffer; - } - } else { - pBufLRU = pBuffer; - } - } - - if(pBuffer->Persistance < pBufLHITS->Persistance) { - pBufLHITS = pBuffer; - } - } + break; // Why look further if you found a perfect match? } } @@ -468,11 +380,38 @@ FF_BUFFER *FF_GetBuffer(FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_UINT8 Mode) { pBufMatch = NULL; // Sector is already in use, keep yielding until its available! } else { - // Choose a suitable buffer! + pBuffer = pIoman->pBuffers; + for(i = 0; i < pIoman->CacheSize; i++, pBuffer++) { + if(pBuffer->NumHandles == 0) { + pBuffer->LRU += 1; + + if(!pBufLRU) { + pBufLRU = pBuffer; + } + if(!pBufLHITS) { + pBufLHITS = pBuffer; + } + + if(pBuffer->LRU >= pBufLRU->LRU) { + if(pBuffer->LRU == pBufLRU->LRU) { + if(pBuffer->Persistance > pBufLRU->Persistance) { + pBufLRU = pBuffer; + } + } else { + pBufLRU = pBuffer; + } + } + + if(pBuffer->Persistance < pBufLHITS->Persistance) { + pBufLHITS = pBuffer; + } + } + } + if(pBufLRU) { // Process the suitable candidate. if(pBufLRU->Modified == FF_TRUE) { - FF_IOMAN_FlushBuffer(pIoman, pBufLRU->Sector, pBufLRU->pBuffer); + FF_BlockWrite(pIoman, pBufLRU->Sector, 1, pBufLRU->pBuffer); } pBufLRU->Mode = Mode; pBufLRU->Persistance = 1; @@ -486,7 +425,7 @@ FF_BUFFER *FF_GetBuffer(FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_UINT8 Mode) { pBufLRU->Modified = FF_FALSE; } - FF_IOMAN_FillBuffer(pIoman, Sector, pBufLRU->pBuffer); + FF_BlockRead(pIoman, Sector, 1, pBufLRU->pBuffer); pBufLRU->Valid = FF_TRUE; FF_ReleaseSemaphore(pIoman->pSemaphore); return pBufLRU; @@ -540,39 +479,94 @@ void FF_ReleaseBuffer(FF_IOMAN *pIoman, FF_BUFFER *pBuffer) { **/ FF_ERROR FF_RegisterBlkDevice(FF_IOMAN *pIoman, FF_T_UINT16 BlkSize, FF_WRITE_BLOCKS fnWriteBlocks, FF_READ_BLOCKS fnReadBlocks, void *pParam) { if(!pIoman) { // We can't do anything without an IOMAN object. - return FF_ERR_NULL_POINTER; + return FF_ERR_NULL_POINTER | FF_REGISTERBLKDEVICE; } if((BlkSize % 512) != 0 || BlkSize == 0) { - return FF_ERR_IOMAN_DEV_INVALID_BLKSIZE; // BlkSize Size not a multiple of IOMAN's Expected BlockSize > 0 + return FF_ERR_IOMAN_DEV_INVALID_BLKSIZE | FF_REGISTERBLKDEVICE; // BlkSize Size not a multiple of IOMAN's Expected BlockSize > 0 } if((BlkSize % pIoman->BlkSize) != 0 || BlkSize == 0) { - return FF_ERR_IOMAN_DEV_INVALID_BLKSIZE; // BlkSize Size not a multiple of IOMAN's Expected BlockSize > 0 + return FF_ERR_IOMAN_DEV_INVALID_BLKSIZE | FF_REGISTERBLKDEVICE; // BlkSize Size not a multiple of IOMAN's Expected BlockSize > 0 } // Ensure that a device cannot be re-registered "mid-flight" // Doing so would corrupt the context of FullFAT - if(pIoman->pBlkDevice->fnReadBlocks) { - return FF_ERR_IOMAN_DEV_ALREADY_REGD; + if(pIoman->pBlkDevice->fnpReadBlocks) { + return FF_ERR_IOMAN_DEV_ALREADY_REGD | FF_REGISTERBLKDEVICE; } - if(pIoman->pBlkDevice->fnWriteBlocks) { - return FF_ERR_IOMAN_DEV_ALREADY_REGD; + if(pIoman->pBlkDevice->fnpWriteBlocks) { + return FF_ERR_IOMAN_DEV_ALREADY_REGD | FF_REGISTERBLKDEVICE; } if(pIoman->pBlkDevice->pParam) { - return FF_ERR_IOMAN_DEV_ALREADY_REGD; + return FF_ERR_IOMAN_DEV_ALREADY_REGD | FF_REGISTERBLKDEVICE; } // Here we shall just set the values. // FullFAT checks before using any of these values. pIoman->pBlkDevice->devBlkSize = BlkSize; - pIoman->pBlkDevice->fnReadBlocks = fnReadBlocks; - pIoman->pBlkDevice->fnWriteBlocks = fnWriteBlocks; + pIoman->pBlkDevice->fnpReadBlocks = fnReadBlocks; + pIoman->pBlkDevice->fnpWriteBlocks = fnWriteBlocks; pIoman->pBlkDevice->pParam = pParam; return FF_ERR_NONE; // Success } +/* + New Interface for FullFAT to read blocks. +*/ + +FF_T_SINT32 FF_BlockRead(FF_IOMAN *pIoman, FF_T_UINT32 ulSectorLBA, FF_T_UINT32 ulNumSectors, void *pBuffer) { + FF_T_SINT32 slRetVal = 0; + + if(pIoman->pPartition->TotalSectors) { + if((ulSectorLBA + ulNumSectors) > (pIoman->pPartition->TotalSectors + pIoman->pPartition->BeginLBA)) { + return -(FF_ERR_IOMAN_OUT_OF_BOUNDS_READ | FF_BLOCKREAD); + } + } + + if(pIoman->pBlkDevice->fnpReadBlocks) { // Make sure we don't execute a NULL. +#ifdef FF_BLKDEV_USES_SEM + FF_PendSemaphore(pIoman->pBlkDevSemaphore); +#endif + slRetVal = pIoman->pBlkDevice->fnpReadBlocks(pBuffer, ulSectorLBA, ulNumSectors, pIoman->pBlkDevice->pParam); +#ifdef FF_BLKDEV_USES_SEM + FF_ReleaseSemaphore(pIoman->pBlkDevSemaphore); +#endif + if(FF_GETERROR(slRetVal) == FF_ERR_DRIVER_BUSY) { + FF_Sleep(FF_DRIVER_BUSY_SLEEP); + } + } while(FF_GETERROR(slRetVal) == FF_ERR_DRIVER_BUSY); + + return slRetVal; +} + +FF_T_SINT32 FF_BlockWrite(FF_IOMAN *pIoman, FF_T_UINT32 ulSectorLBA, FF_T_UINT32 ulNumSectors, void *pBuffer) { + FF_T_SINT32 slRetVal = 0; + + if(pIoman->pPartition->TotalSectors) { + if((ulSectorLBA + ulNumSectors) > (pIoman->pPartition->TotalSectors + pIoman->pPartition->BeginLBA)) { + return -(FF_ERR_IOMAN_OUT_OF_BOUNDS_WRITE | FF_BLOCKWRITE); + } + } + + if(pIoman->pBlkDevice->fnpWriteBlocks) { // Make sure we don't execute a NULL. +#ifdef FF_BLKDEV_USES_SEM + FF_PendSemaphore(pIoman->pBlkDevSemaphore); +#endif + slRetVal = pIoman->pBlkDevice->fnpWriteBlocks(pBuffer, ulSectorLBA, ulNumSectors, pIoman->pBlkDevice->pParam); +#ifdef FF_BLKDEV_USES_SEM + FF_ReleaseSemaphore(pIoman->pBlkDevSemaphore); +#endif + if(FF_GETERROR(slRetVal) == FF_ERR_DRIVER_BUSY) { + FF_Sleep(FF_DRIVER_BUSY_SLEEP); + } + } while(FF_GETERROR(slRetVal) == FF_ERR_DRIVER_BUSY); + + return slRetVal; +} + + /** * @private **/ @@ -638,7 +632,7 @@ static FF_ERROR FF_DetermineFatType(FF_IOMAN *pIoman) { testLong = FF_getLong(pBuffer->pBuffer, 0x0000); } FF_ReleaseBuffer(pIoman, pBuffer); - if((testLong & 0x0FFFFFF8) != 0x0FFFFFF8) { + if((testLong & 0x0FFFFFF8) != 0x0FFFFFF8 && (testLong & 0x0FFFFFF8) != 0x0FFFFFF0) { return FF_ERR_IOMAN_NOT_FAT_FORMATTED; } #endif @@ -676,6 +670,91 @@ static FF_T_SINT8 FF_PartitionCount (FF_T_UINT8 *pBuffer) return count; } +/* + Mount GPT Partition Tables +*/ + +#define FF_GPT_HEAD_ENTRY_SIZE 0x54 +#define FF_GPT_HEAD_TOTAL_ENTRIES 0x50 +#define FF_GPT_HEAD_PART_ENTRY_LBA 0x48 +#define FF_GPT_ENTRY_FIRST_SECTOR_LBA 0x20 +#define FF_GPT_HEAD_CRC 0x10 +#define FF_GPT_HEAD_LENGTH 0x0C + +static FF_ERROR FF_GetEfiPartitionEntry(FF_IOMAN *pIoman, FF_T_UINT32 ulPartitionNumber) { + // Continuing on from FF_MountPartition() pPartition->BeginLBA should be the sector of the GPT Header + FF_BUFFER *pBuffer; + FF_PARTITION *pPart = pIoman->pPartition; + + FF_T_UINT32 ulBeginGPT; + FF_T_UINT32 ulEntrySector; + FF_T_UINT32 ulSectorOffset; + FF_T_UINT32 ulTotalPartitionEntries; + FF_T_UINT32 ulPartitionEntrySize; + FF_T_UINT32 ulGPTHeadCRC, ulGPTCrcCheck, ulGPTHeadLength; + + if(ulPartitionNumber >= 128) { + return FF_ERR_IOMAN_INVALID_PARTITION_NUM; + } + + pBuffer = FF_GetBuffer(pIoman, pPart->BeginLBA, FF_MODE_READ); + { + if(!pBuffer) { + return FF_ERR_DEVICE_DRIVER_FAILED; + } + + // Verify this is an EFI header + if(memcmp(pBuffer->pBuffer, "EFI PART", 8) != 0) { + FF_ReleaseBuffer(pIoman, pBuffer); + return FF_ERR_IOMAN_INVALID_FORMAT; + } + + ulBeginGPT = FF_getLong(pBuffer->pBuffer, FF_GPT_HEAD_PART_ENTRY_LBA); + ulTotalPartitionEntries = FF_getLong(pBuffer->pBuffer, FF_GPT_HEAD_TOTAL_ENTRIES); + ulPartitionEntrySize = FF_getLong(pBuffer->pBuffer, FF_GPT_HEAD_ENTRY_SIZE); + ulGPTHeadCRC = FF_getLong(pBuffer->pBuffer, FF_GPT_HEAD_CRC); + ulGPTHeadLength = FF_getLong(pBuffer->pBuffer, FF_GPT_HEAD_LENGTH); + + // Calculate Head CRC + + // Blank CRC field + FF_putLong(pBuffer->pBuffer, FF_GPT_HEAD_CRC, 0x00000000); + + // Calculate CRC + ulGPTCrcCheck = FF_GetCRC32(pBuffer->pBuffer, ulGPTHeadLength); + + // Restore The CRC field + FF_putLong(pBuffer->pBuffer, FF_GPT_HEAD_CRC, ulGPTHeadCRC); + } + FF_ReleaseBuffer(pIoman, pBuffer); + + // Check CRC + if(ulGPTHeadCRC != ulGPTCrcCheck) { + return FF_ERR_IOMAN_GPT_HEADER_CORRUPT; + } + + // Calculate Sector Containing the Partition Entry we want to use. + + ulEntrySector = ((ulPartitionNumber * ulPartitionEntrySize) / pIoman->BlkSize) + ulBeginGPT; + ulSectorOffset = (ulPartitionNumber % (pIoman->BlkSize / ulPartitionEntrySize)) * ulPartitionEntrySize; + + pBuffer = FF_GetBuffer(pIoman, ulEntrySector, FF_MODE_READ); + { + if(!pBuffer) { + return FF_ERR_DEVICE_DRIVER_FAILED; + } + + pPart->BeginLBA = FF_getLong(pBuffer->pBuffer, ulSectorOffset + FF_GPT_ENTRY_FIRST_SECTOR_LBA); + } + FF_ReleaseBuffer(pIoman, pBuffer); + + if(!pPart->BeginLBA) { + return FF_ERR_IOMAN_INVALID_PARTITION_NUM; + } + + return FF_ERR_NONE; +} + /** * @public * @brief Mounts the Specified partition, the volume specified by the FF_IOMAN object provided. @@ -697,15 +776,19 @@ static FF_T_SINT8 FF_PartitionCount (FF_T_UINT8 *pBuffer) FF_ERROR FF_MountPartition(FF_IOMAN *pIoman, FF_T_UINT8 PartitionNumber) { FF_PARTITION *pPart; FF_BUFFER *pBuffer = 0; + FF_ERROR Error; + + FF_T_UINT8 ucPartitionType; + int partCount; if(!pIoman) { return FF_ERR_NULL_POINTER; } - if(PartitionNumber > 3) { + /*if(PartitionNumber > 3) { return FF_ERR_IOMAN_INVALID_PARTITION_NUM; - } + }*/ pPart = pIoman->pPartition; @@ -728,10 +811,32 @@ FF_ERROR FF_MountPartition(FF_IOMAN *pIoman, FF_T_UINT8 PartitionNumber) { // Volume is not partitioned (MBR Found) pPart->BeginLBA = 0; } else { - // Primary Partitions to deal with! - pPart->BeginLBA = FF_getLong(pBuffer->pBuffer, FF_FAT_PTBL + FF_FAT_PTBL_LBA + (16 * PartitionNumber)); + + ucPartitionType = FF_getChar(pBuffer->pBuffer, FF_FAT_PTBL + FF_FAT_PTBL_ID); // Ensure its not an EFI partition! + + if(ucPartitionType != 0xEE) { + + if(PartitionNumber > 3) { + FF_ReleaseBuffer(pIoman, pBuffer); + return FF_ERR_IOMAN_INVALID_PARTITION_NUM; + } + + // Primary Partitions to deal with! + pPart->BeginLBA = FF_getLong(pBuffer->pBuffer, FF_FAT_PTBL + FF_FAT_PTBL_LBA + (16 * PartitionNumber)); + } + FF_ReleaseBuffer(pIoman, pBuffer); + if(ucPartitionType == 0xEE) { + + pPart->BeginLBA = FF_getLong(pBuffer->pBuffer, FF_FAT_PTBL + FF_FAT_PTBL_LBA); + Error = FF_GetEfiPartitionEntry(pIoman, PartitionNumber); + + if(Error) { + return Error; + } + } + if(!pPart->BeginLBA) { return FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION; } @@ -778,13 +883,25 @@ FF_ERROR FF_MountPartition(FF_IOMAN *pIoman, FF_T_UINT8 PartitionNumber) { } FF_ReleaseBuffer(pIoman, pBuffer); // Release the buffer finally! + + if(!pPart->BlkSize) { + return FF_ERR_IOMAN_INVALID_FORMAT; + } + pPart->RootDirSectors = ((FF_getShort(pBuffer->pBuffer, FF_FAT_ROOT_ENTRY_COUNT) * 32) + pPart->BlkSize - 1) / pPart->BlkSize; pPart->FirstDataSector = pPart->ClusterBeginLBA + pPart->RootDirSectors; pPart->DataSectors = pPart->TotalSectors - (pPart->ReservedSectors + (pPart->NumFATS * pPart->SectorsPerFAT) + pPart->RootDirSectors); + + if(!pPart->SectorsPerCluster) { + return FF_ERR_IOMAN_INVALID_FORMAT; + } + pPart->NumClusters = pPart->DataSectors / pPart->SectorsPerCluster; - if(FF_DetermineFatType(pIoman)) { - return FF_ERR_IOMAN_NOT_FAT_FORMATTED; + Error = FF_DetermineFatType(pIoman); + + if(Error) { + return Error; } #ifdef FF_MOUNT_FIND_FREE @@ -820,8 +937,8 @@ FF_ERROR FF_UnregisterBlkDevice(FF_IOMAN *pIoman) { { if(pIoman->pPartition->PartitionMounted == FF_FALSE) { pIoman->pBlkDevice->devBlkSize = 0; - pIoman->pBlkDevice->fnReadBlocks = NULL; - pIoman->pBlkDevice->fnWriteBlocks = NULL; + pIoman->pBlkDevice->fnpReadBlocks = NULL; + pIoman->pBlkDevice->fnpWriteBlocks = NULL; pIoman->pBlkDevice->pParam = NULL; } else { RetVal = FF_ERR_IOMAN_PARTITION_MOUNTED; @@ -876,7 +993,11 @@ FF_ERROR FF_UnmountPartition(FF_IOMAN *pIoman) { { if(!FF_ActiveHandles(pIoman)) { if(pIoman->FirstFile == NULL) { + // Release Semaphore to call this function! + FF_ReleaseSemaphore(pIoman->pSemaphore); FF_FlushCache(pIoman); // Flush any unwritten sectors to disk. + // Reclaim Semaphore + FF_PendSemaphore(pIoman->pSemaphore); pIoman->pPartition->PartitionMounted = FF_FALSE; } else { RetVal = FF_ERR_IOMAN_ACTIVE_HANDLES; @@ -893,12 +1014,17 @@ FF_ERROR FF_UnmountPartition(FF_IOMAN *pIoman) { FF_ERROR FF_IncreaseFreeClusters(FF_IOMAN *pIoman, FF_T_UINT32 Count) { + FF_ERROR Error; //FF_PendSemaphore(pIoman->pSemaphore); //{ if(!pIoman->pPartition->FreeClusterCount) { - pIoman->pPartition->FreeClusterCount = FF_CountFreeClusters(pIoman); + pIoman->pPartition->FreeClusterCount = FF_CountFreeClusters(pIoman, &Error); + if(Error) { + return Error; + } + } else { + pIoman->pPartition->FreeClusterCount += Count; } - pIoman->pPartition->FreeClusterCount += Count; //} //FF_ReleaseSemaphore(pIoman->pSemaphore); @@ -907,12 +1033,18 @@ FF_ERROR FF_IncreaseFreeClusters(FF_IOMAN *pIoman, FF_T_UINT32 Count) { FF_ERROR FF_DecreaseFreeClusters(FF_IOMAN *pIoman, FF_T_UINT32 Count) { + FF_ERROR Error; + //FF_lockFAT(pIoman); //{ if(!pIoman->pPartition->FreeClusterCount) { - pIoman->pPartition->FreeClusterCount = FF_CountFreeClusters(pIoman); + pIoman->pPartition->FreeClusterCount = FF_CountFreeClusters(pIoman, &Error); + if(Error) { + return Error; + } + } else { + pIoman->pPartition->FreeClusterCount -= Count; } - pIoman->pPartition->FreeClusterCount -= Count; //} //FF_unlockFAT(pIoman); diff --git a/reactos/lib/3rdparty/fullfat/ff_string.c b/reactos/lib/3rdparty/fullfat/ff_string.c index 6913ee7082f..b6c06790ea9 100644 --- a/reactos/lib/3rdparty/fullfat/ff_string.c +++ b/reactos/lib/3rdparty/fullfat/ff_string.c @@ -42,27 +42,57 @@ #include #include +#include #include "ff_string.h" +#include "ff_error.h" + +#ifdef FF_UNICODE_SUPPORT +#include +#include +#endif /* * These will eventually be moved into a platform independent string * library. Which will be optional. (To allow the use of system specific versions). */ +#ifdef FF_UNICODE_SUPPORT + +void FF_cstrntowcs(FF_T_WCHAR *wcsDest, const FF_T_INT8 *szpSource, FF_T_UINT32 len) { + while(*szpSource && len--) { + *wcsDest++ = *szpSource++; + } + *wcsDest = '\0'; +} + +void FF_cstrtowcs(FF_T_WCHAR *wcsDest, const FF_T_INT8 *szpSource) { + while(*szpSource) { + *wcsDest++ = (FF_T_WCHAR) *szpSource++; + } + *wcsDest = '\0'; +} + +void FF_wcstocstr(FF_T_INT8 *szpDest, const FF_T_WCHAR *wcsSource) { + while(*wcsSource) { + *szpDest++ = (FF_T_INT8) *wcsSource++; + } + *szpDest = '\0'; +} + +void FF_wcsntocstr(FF_T_INT8 *szpDest, const FF_T_WCHAR *wcsSource, FF_T_UINT32 len) { + while(*wcsSource && len--) { + *szpDest++ = (FF_T_INT8) *wcsSource++; + } + *szpDest = '\0'; +} + +#endif + /** * @private * @brief Converts an ASCII string to lowercase. **/ -void FF_tolower(FF_T_INT8 *string, FF_T_UINT32 strLen) { - FF_T_UINT32 i; - for(i = 0; i < strLen; i++) { - if(string[i] >= 'A' && string[i] <= 'Z') - string[i] += 32; - if(string[i] == '\0') - break; - } -} - +#ifndef FF_UNICODE_SUPPORT /** * @private * @brief Converts an ASCII string to uppercase. @@ -76,6 +106,32 @@ void FF_toupper(FF_T_INT8 *string, FF_T_UINT32 strLen) { break; } } +void FF_tolower(FF_T_INT8 *string, FF_T_UINT32 strLen) { + FF_T_UINT32 i; + for(i = 0; i < strLen; i++) { + if(string[i] >= 'A' && string[i] <= 'Z') + string[i] += 32; + if(string[i] == '\0') + break; + } +} + +#else +void FF_toupper(FF_T_WCHAR *string, FF_T_UINT32 strLen) { + FF_T_UINT32 i; + for(i = 0; i < strLen; i++) { + string[i] = towupper(string[i]); + } +} +void FF_tolower(FF_T_WCHAR *string, FF_T_UINT32 strLen) { + FF_T_UINT32 i; + for(i = 0; i < strLen; i++) { + string[i] = towlower(string[i]); + } +} +#endif + + /** @@ -84,6 +140,8 @@ void FF_toupper(FF_T_INT8 *string, FF_T_UINT32 strLen) { * otherwise FF_FALSE is returned. * **/ + +#ifndef FF_UNICODE_SUPPORT FF_T_BOOL FF_strmatch(const FF_T_INT8 *str1, const FF_T_INT8 *str2, FF_T_UINT16 len) { register FF_T_UINT16 i; register FF_T_INT8 char1, char2; @@ -112,12 +170,38 @@ FF_T_BOOL FF_strmatch(const FF_T_INT8 *str1, const FF_T_INT8 *str2, FF_T_UINT16 return FF_TRUE; } +#else + +FF_T_BOOL FF_strmatch(const FF_T_WCHAR *str1, const FF_T_WCHAR *str2, FF_T_UINT16 len) { + register FF_T_UINT16 i; + register FF_T_WCHAR char1, char2; + + if(!len) { + if(wcslen(str1) != wcslen(str2)) { + return FF_FALSE; + } + len = (FF_T_UINT16) wcslen(str1); + } + + for(i = 0; i < len; i++) { + char1 = towlower(str1[i]); + char2 = towlower(str2[i]); + if(char1 != char2) { + return FF_FALSE; + } + } + + return FF_TRUE; +} +#endif /** * @private * @brief A re-entrant Strtok function. No documentation is provided :P * Use at your own risk. (This is for FullFAT's use only). **/ + +#ifndef FF_UNICODE_SUPPORT FF_T_INT8 *FF_strtok(const FF_T_INT8 *string, FF_T_INT8 *token, FF_T_UINT16 *tokenNumber, FF_T_BOOL *last, FF_T_UINT16 Length) { FF_T_UINT16 strLen = Length; FF_T_UINT16 i,y, tokenStart, tokenEnd = 0; @@ -153,20 +237,80 @@ FF_T_INT8 *FF_strtok(const FF_T_INT8 *string, FF_T_INT8 *token, FF_T_UINT16 *tok } tokenEnd = i; } - - memcpy(token, (string + tokenStart), (FF_T_UINT32)(tokenEnd - tokenStart)); - token[tokenEnd - tokenStart] = '\0'; + if((tokenEnd - tokenStart) < FF_MAX_FILENAME) { + memcpy(token, (string + tokenStart), (FF_T_UINT32)(tokenEnd - tokenStart)); + token[tokenEnd - tokenStart] = '\0'; + } else { + memcpy(token, (string + tokenStart), (FF_T_UINT32)(FF_MAX_FILENAME)); + token[FF_MAX_FILENAME-1] = '\0'; + } + //token[tokenEnd - tokenStart] = '\0'; *tokenNumber += 1; return token; } +#else +FF_T_WCHAR *FF_strtok(const FF_T_WCHAR *string, FF_T_WCHAR *token, FF_T_UINT16 *tokenNumber, FF_T_BOOL *last, FF_T_UINT16 Length) { + FF_T_UINT16 strLen = Length; + FF_T_UINT16 i,y, tokenStart, tokenEnd = 0; -FF_T_BOOL FF_wildcompare(const FF_T_INT8 *pszWildCard, const FF_T_INT8 *pszString) { - /* Check to see if the string contains the wild card */ + i = 0; + y = 0; + + if(string[i] == '\\' || string[i] == '/') { + i++; + } + + tokenStart = i; + + while(i < strLen) { + if(string[i] == '\\' || string[i] == '/') { + y++; + if(y == *tokenNumber) { + tokenStart = (FF_T_UINT16)(i + 1); + } + if(y == (*tokenNumber + 1)) { + tokenEnd = i; + break; + } + } + i++; + } + + if(!tokenEnd) { + if(*last == FF_TRUE) { + return NULL; + } else { + *last = FF_TRUE; + } + tokenEnd = i; + } + if((tokenEnd - tokenStart) < FF_MAX_FILENAME) { + memcpy(token, (string + tokenStart), (FF_T_UINT32)(tokenEnd - tokenStart) * sizeof(FF_T_WCHAR)); + token[tokenEnd - tokenStart] = '\0'; + } else { + memcpy(token, (string + tokenStart), (FF_T_UINT32)(FF_MAX_FILENAME) * sizeof(FF_T_WCHAR)); + token[FF_MAX_FILENAME-1] = '\0'; + } + //token[tokenEnd - tokenStart] = '\0'; + *tokenNumber += 1; + + return token; +} +#endif + +/* + A Wild-Card Comparator Library function, Provided by Adam Fullerton. + This can be extended or altered to improve or advance wildCard matching + of the FF_FindFirst() and FF_FindNext() API's. +*/ +#ifdef FF_FINDAPI_ALLOW_WILDCARDS +/*FF_T_BOOL FF_wildcompare(const FF_T_INT8 *pszWildCard, const FF_T_INT8 *pszString) { + // Check to see if the string contains the wild card if (!memchr(pszWildCard, '*', strlen(pszWildCard))) { - /* if it does not then do a straight string compare */ + // if it does not then do a straight string compare if (strcmp(pszWildCard, pszString)) { return FF_FALSE; @@ -177,20 +321,20 @@ FF_T_BOOL FF_wildcompare(const FF_T_INT8 *pszWildCard, const FF_T_INT8 *pszStrin while ((*pszWildCard) && (*pszString)) { - /* Test for the wild card */ + // Test for the wild card if (*pszWildCard == '*') { - /* Eat more than one */ + // Eat more than one while (*pszWildCard == '*') { pszWildCard++; } - /* If there are more chars in the string */ + // If there are more chars in the string if (*pszWildCard) { - /* Search for the next char */ + // Search for the next char pszString = memchr(pszString, (int)*pszWildCard, strlen(pszString)); - /* if it does not exist then the strings don't match */ + // if it does not exist then the strings don't match if (!pszString) { return FF_FALSE; @@ -201,7 +345,7 @@ FF_T_BOOL FF_wildcompare(const FF_T_INT8 *pszWildCard, const FF_T_INT8 *pszStrin { if (*pszWildCard) { - /* continue */ + // continue break; } else @@ -212,17 +356,17 @@ FF_T_BOOL FF_wildcompare(const FF_T_INT8 *pszWildCard, const FF_T_INT8 *pszStrin } else { - /* Fail if they don't match */ + // Fail if they don't match if (*pszWildCard != *pszString) { return FF_FALSE; } } - /* Bump both pointers */ + // Bump both pointers pszWildCard++; pszString++; } - /* fail if different lengths */ + // fail if different lengths if (*pszWildCard != *pszString) { return FF_FALSE; @@ -230,5 +374,83 @@ FF_T_BOOL FF_wildcompare(const FF_T_INT8 *pszWildCard, const FF_T_INT8 *pszStrin } return FF_TRUE; -} +}*/ +/* + This is a better Wild-card compare function, that works perfectly, and is much more efficient. + This function was contributed by one of our commercial customers. +*/ +#ifdef FF_UNICODE_SUPPORT +FF_T_BOOL FF_wildcompare(const FF_T_WCHAR *pszWildCard, const FF_T_WCHAR *pszString) { + register const FF_T_WCHAR *pszWc = NULL; + register const FF_T_WCHAR *pszStr = NULL; // Encourage the string pointers to be placed in memory. + do { + if ( *pszWildCard == '*' ) { + while(*(1 + pszWildCard++) == '*'); // Eat up multiple '*''s + pszWc = (pszWildCard - 1); + pszStr = pszString; + } + if (*pszWildCard == '?' && !*pszString) { + return FF_FALSE; // False when the string is ended, yet a ? charachter is demanded. + } +#ifdef FF_WILDCARD_CASE_INSENSITIVE + if (*pszWildCard != '?' && tolower(*pszWildCard) != tolower(*pszString)) { +#else + if (*pszWildCard != '?' && *pszWildCard != *pszString) { +#endif + if (pszWc == NULL) { + return FF_FALSE; + } + pszWildCard = pszWc; + pszString = pszStr++; + } + } while ( *pszWildCard++ && *pszString++ ); + while(*pszWildCard == '*') { + pszWildCard++; + } + + if(!*(pszWildCard - 1)) { // WildCard is at the end. (Terminated) + return FF_TRUE; // Therefore this must be a match. + } + + return FF_FALSE; // If not, then return FF_FALSE! +} +#else +FF_T_BOOL FF_wildcompare(const FF_T_INT8 *pszWildCard, const FF_T_INT8 *pszString) { + register const FF_T_INT8 *pszWc = NULL; + register const FF_T_INT8 *pszStr = NULL; // Encourage the string pointers to be placed in memory. + do { + if ( *pszWildCard == '*' ) { + while(*(1 + pszWildCard++) == '*'); // Eat up multiple '*''s + pszWc = (pszWildCard - 1); + pszStr = pszString; + } + if (*pszWildCard == '?' && !*pszString) { + return FF_FALSE; // False when the string is ended, yet a ? charachter is demanded. + } +#ifdef FF_WILDCARD_CASE_INSENSITIVE + if (*pszWildCard != '?' && tolower(*pszWildCard) != tolower(*pszString)) { +#else + if (*pszWildCard != '?' && *pszWildCard != *pszString) { +#endif + if (pszWc == NULL) { + return FF_FALSE; + } + pszWildCard = pszWc; + pszString = pszStr++; + } + } while ( *pszWildCard++ && *pszString++ ); + + while(*pszWildCard == '*') { + pszWildCard++; + } + + if(!*(pszWildCard - 1)) { // WildCard is at the end. (Terminated) + return FF_TRUE; // Therefore this must be a match. + } + + return FF_FALSE; // If not, then return FF_FALSE! +} +#endif + +#endif diff --git a/reactos/lib/3rdparty/fullfat/ff_unicode.c b/reactos/lib/3rdparty/fullfat/ff_unicode.c new file mode 100644 index 00000000000..24fffd420d4 --- /dev/null +++ b/reactos/lib/3rdparty/fullfat/ff_unicode.c @@ -0,0 +1,294 @@ +/***************************************************************************** + * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * + * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + * * + * IMPORTANT NOTICE: * + * ================= * + * Alternative Licensing is available directly from the Copyright holder, * + * (James Walmsley). For more information consult LICENSING.TXT to obtain * + * a Commercial license. * + * * + * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * + * * + * Removing the above notice is illegal and will invalidate this license. * + ***************************************************************************** + * See http://worm.me.uk/fullfat for more information. * + * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * + *****************************************************************************/ + +/** + * @file ff_unicode.c + * @author James Walmsley + * @ingroup UNICODE + * + * @defgroup UNICODE FullFAT UNICODE Library + * @brief Portable UNICODE Transformation Library for FullFAT + * + **/ + +#include "ff_unicode.h" +#include "string.h" + +// UTF-8 Routines + +/* + UCS-4 range (hex.) UTF-8 octet sequence (binary) + 0000 0000-0000 007F 0xxxxxxx + 0000 0080-0000 07FF 110xxxxx 10xxxxxx + 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx + + 0001 0000-001F FFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + 0020 0000-03FF FFFF 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx -- We don't encode these because we won't receive them. (Invalid UNICODE). + 0400 0000-7FFF FFFF 1111110x 10xxxxxx ... 10xxxxxx -- We don't encode these because we won't receive them. (Invalid UNICODE). +*/ + +FF_T_UINT FF_GetUtf16SequenceLen(FF_T_UINT16 usLeadChar) { + if((usLeadChar & 0xFC00) == 0xD800) { + return 2; + } + return 1; +} + +/* + Returns the number of UTF-8 units read. + Will not exceed ulSize UTF-16 units. (ulSize * 2 bytes). +*/ +/* + UCS-4 range (hex.) UTF-8 octet sequence (binary) + 0000 0000-0000 007F 0xxxxxxx + 0000 0080-0000 07FF 110xxxxx 10xxxxxx + 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx + + 0001 0000-001F FFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + 0020 0000-03FF FFFF 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx -- We don't encode these because we won't receive them. (Invalid UNICODE). + 0400 0000-7FFF FFFF 1111110x 10xxxxxx ... 10xxxxxx -- We don't encode these because we won't receive them. (Invalid UNICODE). +*/ +FF_T_SINT32 FF_Utf8ctoUtf16c(FF_T_UINT16 *utf16Dest, const FF_T_UINT8 *utf8Source, FF_T_UINT32 ulSize) { + FF_T_UINT32 ulUtf32char; + FF_T_UINT16 utf16Source = 0; + register FF_T_INT uiSequenceNumber = 0; + + while((*utf8Source & (0x80 >> (uiSequenceNumber)))) { // Count number of set bits before a zero. + uiSequenceNumber++; + } + + if(!uiSequenceNumber) { + uiSequenceNumber++; + } + + if(!ulSize) { + return FF_ERR_UNICODE_DEST_TOO_SMALL; + } + + switch(uiSequenceNumber) { + case 1: + utf16Source = (FF_T_UINT16) *utf8Source; + memcpy(utf16Dest,&utf16Source,sizeof(FF_T_UINT16)); + //bobtntfullfat *utf16Dest = (FF_T_UINT16) *utf8Source; + break; + + case 2: + utf16Source =(FF_T_UINT16) ((*utf8Source & 0x1F) << 6) | ((*(utf8Source + 1) & 0x3F)); + memcpy(utf16Dest,&utf16Source,sizeof(FF_T_UINT16)); + //bobtntfullfat *utf16Dest = (FF_T_UINT16) ((*utf8Source & 0x1F) << 6) | ((*(utf8Source + 1) & 0x3F)); + break; + + case 3: + utf16Source =(FF_T_UINT16) ((*utf8Source & 0x0F) << 12) | ((*(utf8Source + 1) & 0x3F) << 6) | ((*(utf8Source + 2) & 0x3F)); + memcpy(utf16Dest,&utf16Source,sizeof(FF_T_UINT16)); + //bobtntfullfat *utf16Dest = (FF_T_UINT16) ((*utf8Source & 0x0F) << 12) | ((*(utf8Source + 1) & 0x3F) << 6) | ((*(utf8Source + 2) & 0x3F)); + break; + + case 4: + // Convert to UTF-32 and then into UTF-16 + if(ulSize < 2) { + return FF_ERR_UNICODE_DEST_TOO_SMALL; + } + ulUtf32char = (FF_T_UINT16) ((*utf8Source & 0x0F) << 18) | ((*(utf8Source + 1) & 0x3F) << 12) | ((*(utf8Source + 2) & 0x3F) << 6) | ((*(utf8Source + 3) & 0x3F)); + + utf16Source = (FF_T_UINT16) (((ulUtf32char - 0x10000) & 0xFFC00) >> 10) | 0xD800; + memcpy(utf16Dest,&utf16Source,sizeof(FF_T_UINT16)); + utf16Source = (FF_T_UINT16) (((ulUtf32char - 0x10000) & 0x003FF) >> 00) | 0xDC00; + memcpy(utf16Dest+1,&utf16Source,sizeof(FF_T_UINT16)); + //bobtntfullfat *(utf16Dest + 0) = (FF_T_UINT16) (((ulUtf32char - 0x10000) & 0xFFC00) >> 10) | 0xD800; + //bobtntfullfat *(utf16Dest + 1) = (FF_T_UINT16) (((ulUtf32char - 0x10000) & 0x003FF) >> 00) | 0xDC00; + break; + + default: + break; + } + + return uiSequenceNumber; +} + + +/* + Returns the number of UTF-8 units required to encode the UTF-16 sequence. + Will not exceed ulSize UTF-8 units. (ulSize * 1 bytes). +*/ +FF_T_SINT32 FF_Utf16ctoUtf8c(FF_T_UINT8 *utf8Dest, const FF_T_UINT16 *utf16Source, FF_T_UINT32 ulSize) { + FF_T_UINT32 ulUtf32char; + FF_T_UINT16 ulUtf16char; + + if(!ulSize) { + return FF_ERR_UNICODE_DEST_TOO_SMALL; + } + + memcpy(&ulUtf16char, utf16Source, sizeof(FF_T_UINT16)); + if((/*bobtntfullfat *utf16Source*/ulUtf16char & 0xF800) == 0xD800) { // A surrogate sequence was encountered. Must transform to UTF32 first. + ulUtf32char = ((FF_T_UINT32) (ulUtf16char & 0x003FF) << 10) + 0x10000; + //bobtntfullfat ulUtf32char = ((FF_T_UINT32) (*(utf16Source + 0) & 0x003FF) << 10) + 0x10000; + + memcpy(&ulUtf16char, utf16Source + 1, sizeof(FF_T_UINT16)); + if((/*bobtntfullfat *(utf16Source + 1)*/ulUtf16char & 0xFC00) != 0xDC00) { + return FF_ERR_UNICODE_INVALID_SEQUENCE; // Invalid UTF-16 sequence. + } + ulUtf32char |= ((FF_T_UINT32) (/*bobtntfullfat *(utf16Source + 1)*/ulUtf16char & 0x003FF)); + + } else { + ulUtf32char = (FF_T_UINT32) /*bobtntfullfat *utf16Source*/ulUtf16char; + } + + // Now convert to the UTF-8 sequence. + if(ulUtf32char < 0x00000080) { // Single byte UTF-8 sequence. + *(utf8Dest + 0) = (FF_T_UINT8) ulUtf32char; + return 1; + } + + if(ulUtf32char < 0x00000800) { // Double byte UTF-8 sequence. + if(ulSize < 2) { + return FF_ERR_UNICODE_DEST_TOO_SMALL; + } + *(utf8Dest + 0) = (FF_T_UINT8) (0xC0 | ((ulUtf32char >> 6) & 0x1F)); + *(utf8Dest + 1) = (FF_T_UINT8) (0x80 | ((ulUtf32char >> 0) & 0x3F)); + return 2; + } + + if(ulUtf32char < 0x00010000) { // Triple byte UTF-8 sequence. + if(ulSize < 3) { + return FF_ERR_UNICODE_DEST_TOO_SMALL; + } + *(utf8Dest + 0) = (FF_T_UINT8) (0xE0 | ((ulUtf32char >> 12) & 0x0F)); + *(utf8Dest + 1) = (FF_T_UINT8) (0x80 | ((ulUtf32char >> 6 ) & 0x3F)); + *(utf8Dest + 2) = (FF_T_UINT8) (0x80 | ((ulUtf32char >> 0 ) & 0x3F)); + return 3; + } + + if(ulUtf32char < 0x00200000) { // Quadruple byte UTF-8 sequence. + if(ulSize < 4) { + return FF_ERR_UNICODE_DEST_TOO_SMALL; + } + *(utf8Dest + 0) = (FF_T_UINT8) (0xF0 | ((ulUtf32char >> 18) & 0x07)); + *(utf8Dest + 1) = (FF_T_UINT8) (0x80 | ((ulUtf32char >> 12) & 0x3F)); + *(utf8Dest + 2) = (FF_T_UINT8) (0x80 | ((ulUtf32char >> 6 ) & 0x3F)); + *(utf8Dest + 3) = (FF_T_UINT8) (0x80 | ((ulUtf32char >> 0 ) & 0x3F)); + return 4; + } + + return FF_ERR_UNICODE_INVALID_CODE; // Invalid Charachter +} + + +// UTF-16 Support Functions + +// Converts a UTF-32 Charachter into its equivalent UTF-16 sequence. +FF_T_SINT32 FF_Utf32ctoUtf16c(FF_T_UINT16 *utf16Dest, FF_T_UINT32 utf32char, FF_T_UINT32 ulSize) { + + // Check that its a valid UTF-32 wide-char! + + if(utf32char >= 0xD800 && utf32char <= 0xDFFF) { // This range is not a valid Unicode code point. + return FF_ERR_UNICODE_INVALID_CODE; // Invalid charachter. + } + + if(utf32char < 0x10000) { + *utf16Dest = (FF_T_UINT16) utf32char; // Simple conversion! Char comes within UTF-16 space (without surrogates). + return 1; + } + + if(ulSize < 2) { + return FF_ERR_UNICODE_DEST_TOO_SMALL; // Not enough UTF-16 units to record this charachter. + } + + if(utf32char < 0x00200000) { + // Conversion to a UTF-16 Surrogate pair! + //valueImage = utf32char - 0x10000; + + *(utf16Dest + 0) = (FF_T_UINT16) (((utf32char - 0x10000) & 0xFFC00) >> 10) | 0xD800; + *(utf16Dest + 1) = (FF_T_UINT16) (((utf32char - 0x10000) & 0x003FF) >> 00) | 0xDC00; + + return 2; // Surrogate pair encoded value. + } + + return FF_ERR_UNICODE_INVALID_CODE; // Invalid Charachter +} + +// Converts a UTF-16 sequence into its equivalent UTF-32 code point. +FF_T_SINT32 FF_Utf16ctoUtf32c(FF_T_UINT32 *utf32Dest, const FF_T_UINT16 *utf16Source) { + + if((*utf16Source & 0xFC00) != 0xD800) { // Not a surrogate sequence. + *utf32Dest = (FF_T_UINT32) *utf16Source; + return 1; // A single UTF-16 item was used to represent the charachter. + } + + *utf32Dest = ((FF_T_UINT32) (*(utf16Source + 0) & 0x003FF) << 10) + 0x10000; + + if((*(utf16Source + 1) & 0xFC00) != 0xDC00) { + return FF_ERR_UNICODE_INVALID_SEQUENCE; // Invalid UTF-16 sequence. + } + *utf32Dest |= ((FF_T_UINT32) (*(utf16Source + 1) & 0x003FF)); + return 2; // 2 utf-16 units make up the Unicode code-point. +} + + +/* + Returns the total number of UTF-16 items required to represent + the provided UTF-32 string in UTF-16 form. +*/ +/* +FF_T_UINT FF_Utf32GetUtf16Len(const FF_T_UINT32 *utf32String) { + FF_T_UINT utf16len = 0; + + while(*utf32String) { + if(*utf32String++ <= 0xFFFF) { + utf16len++; + } else { + utf16len += 2; + } + } + + return utf16len; +}*/ + + +// String conversions + +FF_T_SINT32 FF_Utf32stoUtf8s(FF_T_UINT8 *Utf8String, FF_T_UINT32 *Utf32String) { + int i = 0,y = 0; + + FF_T_UINT16 utf16buffer[2]; + + while(Utf32String[i]) { + // Convert to a UTF16 char. + FF_Utf32ctoUtf16c(utf16buffer, Utf32String[i], 2); + // Now convert the UTF16 to UTF8 sequence. + y += FF_Utf16ctoUtf8c(&Utf8String[y], utf16buffer, 4); + i++; + } + + Utf8String[y] = '\0'; + + return 0; +} diff --git a/reactos/lib/3rdparty/fullfat/fullfat.rbuild b/reactos/lib/3rdparty/fullfat/fullfat.rbuild index df4d3580b01..754502d6d57 100644 --- a/reactos/lib/3rdparty/fullfat/fullfat.rbuild +++ b/reactos/lib/3rdparty/fullfat/fullfat.rbuild @@ -1,6 +1,6 @@ - + include/reactos/libs/fullfat @@ -10,10 +10,12 @@ ff_error.c ff_fat.c ff_file.c + ff_format.c ff_hash.c ff_ioman.c ff_memory.c ff_safety.c ff_string.c ff_time.c + ff_unicode.c From 50fd13ae9c673275c156002c50ee8e9e6d2fbd4a Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Sat, 2 Apr 2011 16:37:25 +0000 Subject: [PATCH 56/66] [FULLFAT] - Switch UTF-16 support on throughout the library. svn path=/trunk/; revision=51230 --- reactos/include/reactos/libs/fullfat/ff_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/include/reactos/libs/fullfat/ff_config.h b/reactos/include/reactos/libs/fullfat/ff_config.h index 0c8e3f37db2..d8de409f1c6 100644 --- a/reactos/include/reactos/libs/fullfat/ff_config.h +++ b/reactos/include/reactos/libs/fullfat/ff_config.h @@ -51,7 +51,7 @@ //---------- UNICODE SUPPORT -//#define FF_UNICODE_SUPPORT // If this is defined, then all of FullFAT's API's will expect to receive UTF-16 formatted strings. +#define FF_UNICODE_SUPPORT // If this is defined, then all of FullFAT's API's will expect to receive UTF-16 formatted strings. // FF_FindFirst() and FF_FindNext() will also return Filenames in UTF-16 format. // NOTE: This option may cause FullFAT to not "Clean-compile" when using GCC. This is because // pedantically GCC refuses to accept C99 library functions, unless the -std=c99 flag is used. From a27aa839046b19e4177141ffcc8877da3a581fe8 Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Sat, 2 Apr 2011 17:51:09 +0000 Subject: [PATCH 57/66] [SYSTEMINFO] Clean it up a bit Prepare for CSV format support svn path=/trunk/; revision=51233 --- .../sysutils/systeminfo/lang/de-DE.rc | 60 +++-- .../sysutils/systeminfo/lang/en-US.rc | 62 +++-- .../sysutils/systeminfo/lang/es-ES.rc | 62 +++-- .../sysutils/systeminfo/lang/fr-FR.rc | 62 +++-- .../sysutils/systeminfo/lang/no-NO.rc | 62 +++-- .../sysutils/systeminfo/lang/pl-PL.rc | 62 +++-- .../sysutils/systeminfo/lang/sk-SK.rc | 62 +++-- .../sysutils/systeminfo/lang/uk-UA.rc | 62 +++-- .../sysutils/systeminfo/resource.h | 54 ++-- .../sysutils/systeminfo/systeminfo.c | 247 ++++++++++-------- 10 files changed, 429 insertions(+), 366 deletions(-) diff --git a/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc b/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc index 287217c99b1..f7a0e476016 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/de-DE.rc @@ -31,34 +31,38 @@ Beispiele:\n\ SYSTEMINFO /S system /FO LIST\n\ SYSTEMINFO /S system /FO CSV /NH\n" -IDS_HOST_NAME, "Domne: %s\n" -IDS_OS_NAME, "OS Name: %s\n" -IDS_OS_VERSION, "OS Version: %u.%u.%u %s Build %u\n" -IDS_OS_BUILD_TYPE, "OS Build Typ: %s\n" -IDS_REG_OWNER, "Registrierter Benutzer: %s\n" -IDS_REG_ORG, "Registrierte Organisation: %s\n" -IDS_PRODUCT_ID, "Produkt ID: %s\n" -IDS_INST_DATE, "Installationsdatum: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u Minutes, %u Seconds\n" -IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" -IDS_SYS_MODEL, "System Model: %s\n" -IDS_SYS_TYPE, "Systemtyp: %s\n" -IDS_PROCESSORS, "Prozessor(en): %u Prozessor(en) Installiert.\n" -IDS_BIOS_DATE, "BIOS Datum: %s\n" -IDS_BIOS_VERSION, "BIOS Version: %s\n" -IDS_ROS_DIR, "ReactOS Verzeichnis: %s\n" -IDS_SYS_DIR, "System Verzeichnis: %s\n" -IDS_BOOT_DEV, "Startgert: %s\n" -IDS_SYS_LOCALE, "Systemgebietsschema: %s\n" -IDS_INPUT_LOCALE, "Eingabegebietsschema: %s\n" -IDS_TIME_ZONE, "Zeitzone: %s\n" -IDS_TOTAL_PHYS_MEM, "Gesamter Physikalischer Speicher: %s MB\n" -IDS_AVAIL_PHISICAL_MEM, "Verfgbarer Physikalischer Speicher: %s MB\n" -IDS_VIRT_MEM_MAX, "Auslagerungsdatei: Max Gre: %s MB\n" -IDS_VIRT_MEM_AVAIL, "Auslagerungsdatei: Verfgbar: %s MB\n" -IDS_VIRT_MEM_INUSE, "Auslagerungsdatei: In Verwendung: %s MB\n" +IDS_HOST_NAME, "Domne" +IDS_OS_NAME, "OS Name" +IDS_OS_VERSION, "OS Version: Build %u" +IDS_BUILD, "Build" +IDS_OS_BUILD_TYPE, "OS Build Typ" +IDS_REG_OWNER, "Registrierter Benutzer" +IDS_REG_ORG, "Registrierte Organisation" +IDS_PRODUCT_ID, "Produkt ID" +IDS_INST_DATE, "Installationsdatum" +IDS_UP_TIME, "System Up Time" +IDS_UP_TIME_FORMAT "%u Days, %u Hours, %u Minutes, %u Seconds" +IDS_SYS_MANUFACTURER, "System Manufacturer" +IDS_SYS_MODEL, "System Model" +IDS_SYS_TYPE, "Systemtyp" +IDS_PROCESSORS, "Prozessor(en)" +IDS_PROCESSORS_FORMAT, "%u Prozessor(en) Installiert." +IDS_BIOS_DATE, "BIOS Datum" +IDS_BIOS_VERSION, "BIOS Version" +IDS_ROS_DIR, "ReactOS Verzeichnis" +IDS_SYS_DIR, "System Verzeichnis" +IDS_BOOT_DEV, "Startgert" +IDS_SYS_LOCALE, "Systemgebietsschema" +IDS_INPUT_LOCALE, "Eingabegebietsschema" +IDS_TIME_ZONE, "Zeitzone" +IDS_TOTAL_PHYS_MEM, "Gesamter Physikalischer Speicher" +IDS_AVAIL_PHISICAL_MEM, "Verfgbarer Physikalischer Speicher" +IDS_VIRT_MEM_MAX, "Auslagerungsdatei: Max Gre" +IDS_VIRT_MEM_AVAIL, "Auslagerungsdatei: Verfgbar" +IDS_VIRT_MEM_INUSE, "Auslagerungsdatei: In Verwendung" IDS_PAGEFILE_LOC, "Auslagerungsdateipfad(e): %s" -IDS_DOMAIN, "Domain: %s\n" -IDS_NETWORK_CARDS, "Netzwerkkarte(n) %u Installiert.\n" +IDS_DOMAIN, "Domain" +IDS_NETWORK_CARDS, "Netzwerkkarte(n)" +IDS_NETWORK_CARDS_FORMAT, "%u Installiert." END diff --git a/rosapps/applications/sysutils/systeminfo/lang/en-US.rc b/rosapps/applications/sysutils/systeminfo/lang/en-US.rc index aa0c7713a08..05bdb9dac96 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/en-US.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/en-US.rc @@ -29,34 +29,38 @@ Examples:\n\ SYSTEMINFO /S system /FO LIST\n\ SYSTEMINFO /S system /FO CSV /NH\n" -IDS_HOST_NAME, "Host Name: %s\n" -IDS_OS_NAME, "OS Name: %s\n" -IDS_OS_VERSION, "OS Version: %u.%u.%u %s Build %u\n" -IDS_OS_BUILD_TYPE, "OS Build Type: %s\n" -IDS_REG_OWNER, "Registered Owner: %s\n" -IDS_REG_ORG, "Registered Organization: %s\n" -IDS_PRODUCT_ID, "Product ID: %s\n" -IDS_INST_DATE, "Install Date: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u Minutes, %u Seconds\n" -IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" -IDS_SYS_MODEL, "System Model: %s\n" -IDS_SYS_TYPE, "System type: %s\n" -IDS_PROCESSORS, "Processor(s): %u Processor(s) Installed.\n" -IDS_BIOS_DATE, "BIOS Date: %s\n" -IDS_BIOS_VERSION, "BIOS Version: %s\n" -IDS_ROS_DIR, "ReactOS Directory: %s\n" -IDS_SYS_DIR, "System Directory: %s\n" -IDS_BOOT_DEV, "Boot Device: %s\n" -IDS_SYS_LOCALE, "System Locale: %s\n" -IDS_INPUT_LOCALE, "Input Locale: %s\n" -IDS_TIME_ZONE, "Time zone: %s\n" -IDS_TOTAL_PHYS_MEM, "Total Physical Memory: %s MB\n" -IDS_AVAIL_PHISICAL_MEM, "Available Physical Memory: %s MB\n" -IDS_VIRT_MEM_MAX, "Virtual Memory: Max Size: %s MB\n" -IDS_VIRT_MEM_AVAIL, "Virtual Memory: Available: %s MB\n" -IDS_VIRT_MEM_INUSE, "Virtual Memory: In Use: %s MB\n" -IDS_PAGEFILE_LOC, "Page File Location(s): %s\n" -IDS_DOMAIN, "Domain: %s\n" -IDS_NETWORK_CARDS, "Network Card(s) %u Installed.\n" +IDS_HOST_NAME, "Host Name" +IDS_OS_NAME, "OS Name" +IDS_OS_VERSION, "OS Version" +IDS_BUILD, "Build" +IDS_OS_BUILD_TYPE, "OS Build Type" +IDS_REG_OWNER, "Registered Owner" +IDS_REG_ORG, "Registered Organization" +IDS_PRODUCT_ID, "Product ID" +IDS_INST_DATE, "Install Date" +IDS_UP_TIME, "System Up Time" +IDS_UP_TIME_FORMAT "%u Days, %u Hours, %u Minutes, %u Seconds" +IDS_SYS_MANUFACTURER, "System Manufacturer" +IDS_SYS_MODEL, "System Model" +IDS_SYS_TYPE, "System type" +IDS_PROCESSORS, "Processor(s)" +IDS_PROCESSORS_FORMAT, "%u Processor(s) Installed." +IDS_BIOS_DATE, "BIOS Date" +IDS_BIOS_VERSION, "BIOS Version" +IDS_ROS_DIR, "ReactOS Directory" +IDS_SYS_DIR, "System Directory" +IDS_BOOT_DEV, "Boot Device" +IDS_SYS_LOCALE, "System Locale" +IDS_INPUT_LOCALE, "Input Locale" +IDS_TIME_ZONE, "Time zone" +IDS_TOTAL_PHYS_MEM, "Total Physical Memory" +IDS_AVAIL_PHISICAL_MEM, "Available Physical Memory" +IDS_VIRT_MEM_MAX, "Virtual Memory: Max Size" +IDS_VIRT_MEM_AVAIL, "Virtual Memory: Available" +IDS_VIRT_MEM_INUSE, "Virtual Memory: In Use" +IDS_PAGEFILE_LOC, "Page File Location(s)" +IDS_DOMAIN, "Domain" +IDS_NETWORK_CARDS, "Network Card(s)" +IDS_NETWORK_CARDS_FORMAT, "%u Installed." END diff --git a/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc b/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc index c9ec95f6a78..b57be05cf12 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/es-ES.rc @@ -34,34 +34,38 @@ Ejemplos:\n\ SYSTEMINFO /S sistema /FO LIST\n\ SYSTEMINFO /S sistema /FO CSV /NH\n" -IDS_HOST_NAME, "Nombre del Servidor: %s\n" -IDS_OS_NAME, "Nombre Sistema Operativo: %s\n" -IDS_OS_VERSION, "Versin Sistema Operativo: %u.%u.%u %s Compilacin %u\n" -IDS_OS_BUILD_TYPE, "Tipo Compilacin: %s\n" -IDS_REG_OWNER, "Propietario: %s\n" -IDS_REG_ORG, "Organizacin: %s\n" -IDS_PRODUCT_ID, "Identificador de Producto %s\n" -IDS_INST_DATE, "Fecha de Instalacin: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u Minutes, %u Seconds\n" -IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" -IDS_SYS_MODEL, "System Model: %s\n" -IDS_SYS_TYPE, "Tipo de sistema: %s\n" -IDS_PROCESSORS, "Procesador(es): %u Procesador(es) Instalados.\n" -IDS_BIOS_DATE, "Fecha BIOS: %s\n" -IDS_BIOS_VERSION, "Versin BIOS: %s\n" -IDS_ROS_DIR, "Directorio de ReactOS: %s\n" -IDS_SYS_DIR, "Directorio del Sistema: %s\n" -IDS_BOOT_DEV, "Dispositivo de Inicio: %s\n" -IDS_SYS_LOCALE, "Idioma del sistema: %s\n" -IDS_INPUT_LOCALE, "Idioma de entrada: %s\n" -IDS_TIME_ZONE, "Zona horario: %s\n" -IDS_TOTAL_PHYS_MEM, "Memoria Fsica Total: %s MB\n" -IDS_AVAIL_PHISICAL_MEM, "Memoria Fsica Disponible: %s MB\n" -IDS_VIRT_MEM_MAX, "Memoria Virtual: Tamao Mx: %s MB\n" -IDS_VIRT_MEM_AVAIL, "Memoria Virtual: Disponible: %s MB\n" -IDS_VIRT_MEM_INUSE, "Memoria Virtual: En Uso: %s MB\n" -IDS_PAGEFILE_LOC, "Ruta(s) Archivo Paginacin: %s\n" -IDS_DOMAIN, "Dominio: %s\n" -IDS_NETWORK_CARDS, "Tarjeta(s) de Red %u No Instalada.\n" +IDS_HOST_NAME, "Nombre del Servidor" +IDS_OS_NAME, "Nombre Sistema Operativo" +IDS_OS_VERSION, "Versin Sistema Operativo" +IDS_BUILD, "Compilacin" +IDS_OS_BUILD_TYPE, "Tipo Compilacin" +IDS_REG_OWNER, "Propietario" +IDS_REG_ORG, "Organizacin" +IDS_PRODUCT_ID, "Identificador de Producto" +IDS_INST_DATE, "Fecha de Instalacin" +IDS_UP_TIME, "System Up Time" +IDS_UP_TIME_FORMAT "%u Days, %u Hours, %u Minutes, %u Seconds" +IDS_SYS_MANUFACTURER, "System Manufacturer" +IDS_SYS_MODEL, "System Model" +IDS_SYS_TYPE, "Tipo de sistema" +IDS_PROCESSORS, "Procesador(es)" +IDS_PROCESSORS_FORMAT, "%u Procesador(es) Instalados." +IDS_BIOS_DATE, "Fecha BIOS" +IDS_BIOS_VERSION, "Versin BIOS" +IDS_ROS_DIR, "Directorio de ReactOS" +IDS_SYS_DIR, "Directorio del Sistema" +IDS_BOOT_DEV, "Dispositivo de Inicio" +IDS_SYS_LOCALE, "Idioma del sistema" +IDS_INPUT_LOCALE, "Idioma de entrada" +IDS_TIME_ZONE, "Zona horario" +IDS_TOTAL_PHYS_MEM, "Memoria Fsica Total" +IDS_AVAIL_PHISICAL_MEM, "Memoria Fsica Disponible" +IDS_VIRT_MEM_MAX, "Memoria Virtual: Tamao Mx" +IDS_VIRT_MEM_AVAIL, "Memoria Virtual: Disponible" +IDS_VIRT_MEM_INUSE, "Memoria Virtual: En Uso" +IDS_PAGEFILE_LOC, "Ruta(s) Archivo Paginacin" +IDS_DOMAIN, "Dominio" +IDS_NETWORK_CARDS, "Tarjeta(s) de Red" +IDS_NETWORK_CARDS_FORMAT, "%u No Instalada." END diff --git a/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc b/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc index 82b5a62f84d..88eb9c06d4c 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/fr-FR.rc @@ -29,34 +29,38 @@ Exemples:\n\ SYSTEMINFO /S systme /FO LIST\n\ SYSTEMINFO /S systme /FO CSV /NH\n" -IDS_HOST_NAME, "Nom d'hte : %s\n" -IDS_OS_NAME, "Nom du systme d'exploitation : %s\n" -IDS_OS_VERSION, "Version du systme d'exploitation : %u.%u.%u %s Compilation %u\n" -IDS_OS_BUILD_TYPE, "Type de compilation du systme d'exploitation : %s\n" -IDS_REG_OWNER, "Propritaire enregistr : %s\n" -IDS_REG_ORG, "Organisation enregistre : %s\n" -IDS_PRODUCT_ID, "ID du produit : %s\n" -IDS_INST_DATE, "Date d'installation : %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u Minutes, %u Seconds\n" -IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" -IDS_SYS_MODEL, "System Model: %s\n" -IDS_SYS_TYPE, "Type du systme : %s\n" -IDS_PROCESSORS, "Processeur(s) : %u Processeur(s) install(s).\n" -IDS_BIOS_DATE, "Date du BIOS : %s\n" -IDS_BIOS_VERSION, "Version du BIOS : %s\n" -IDS_ROS_DIR, "Rpertoire ReactOS : %s\n" -IDS_SYS_DIR, "Rpertoire systme : %s\n" -IDS_BOOT_DEV, "Priphrique de dmarrage : %s\n" -IDS_SYS_LOCALE, "Paramtre rgional du systme : %s\n" -IDS_INPUT_LOCALE, "Paramtre rgional de saisie : %s\n" -IDS_TIME_ZONE, "Fuseau horaire : %s\n" -IDS_TOTAL_PHYS_MEM, "Mmoire physique totale : %s Mo\n" -IDS_AVAIL_PHISICAL_MEM, "Mmoire physique disponible : %s Mo\n" -IDS_VIRT_MEM_MAX, "Mmoire virtuelle: Taille max : %s Mo\n" -IDS_VIRT_MEM_AVAIL, "Mmoire virtuelle: Disponible : %s Mo\n" -IDS_VIRT_MEM_INUSE, "Mmoire virtuelle: Utilise : %s Mo\n" -IDS_PAGEFILE_LOC, "Emplacement(s) des fichiers d'change : %s" -IDS_DOMAIN, "Domaine : %s\n" -IDS_NETWORK_CARDS, "Carte(s) rseau %u installe(s).\n" +IDS_HOST_NAME, "Nom d'hte" +IDS_OS_NAME, "Nom du systme d'exploitation" +IDS_OS_VERSION, "Version du systme d'exploitation" +IDS_BUILD, "Compilation" +IDS_OS_BUILD_TYPE, "Type de compilation du systme d'exploitation" +IDS_REG_OWNER, "Propritaire enregistr" +IDS_REG_ORG, "Organisation enregistre" +IDS_PRODUCT_ID, "ID du produit" +IDS_INST_DATE, "Date d'installation" +IDS_UP_TIME, "System Up Time" +IDS_UP_TIME_FORMAT "%u Days, %u Hours, %u Minutes, %u Seconds" +IDS_SYS_MANUFACTURER, "System Manufacturer" +IDS_SYS_MODEL, "System Model" +IDS_SYS_TYPE, "Type du systme" +IDS_PROCESSORS, "Processeur(s)" +IDS_PROCESSORS_FORMAT, "%u Processeur(s) install(s)." +IDS_BIOS_DATE, "Date du BIOS" +IDS_BIOS_VERSION, "Version du BIOS" +IDS_ROS_DIR, "Rpertoire ReactOS" +IDS_SYS_DIR, "Rpertoire systme" +IDS_BOOT_DEV, "Priphrique de dmarrage" +IDS_SYS_LOCALE, "Paramtre rgional du systme" +IDS_INPUT_LOCALE, "Paramtre rgional de saisie" +IDS_TIME_ZONE, "Fuseau horaire" +IDS_TOTAL_PHYS_MEM, "Mmoire physique totale" +IDS_AVAIL_PHISICAL_MEM, "Mmoire physique disponible" +IDS_VIRT_MEM_MAX, "Mmoire virtuelle: Taille max" +IDS_VIRT_MEM_AVAIL, "Mmoire virtuelle: Disponible" +IDS_VIRT_MEM_INUSE, "Mmoire virtuelle: Utilise" +IDS_PAGEFILE_LOC, "Emplacement(s) des fichiers d'change" +IDS_DOMAIN, "Domaine" +IDS_NETWORK_CARDS, "Carte(s) rseau" +IDS_NETWORK_CARDS_FORMAT, "%u installe(s)." END diff --git a/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc b/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc index 7f92fe924a3..af655d38478 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/no-NO.rc @@ -29,34 +29,38 @@ Eksempler:\n\ SYSTEMINFO /S system /FO LIST\n\ SYSTEMINFO /S system /FO CSV /NH\n" -IDS_HOST_NAME, "Datamaskin navn: %s\n" -IDS_OS_NAME, "OS navn: %s\n" -IDS_OS_VERSION, "OS versjon: %u.%u.%u %s Bygget %u\n" -IDS_OS_BUILD_TYPE, "OS bygg type: %s\n" -IDS_REG_OWNER, "Registert eier: %s\n" -IDS_REG_ORG, "Registerert organisasjon: %s\n" -IDS_PRODUCT_ID, "Produkt ID: %s\n" -IDS_INST_DATE, "Installert dato: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u Minutes, %u Seconds\n" -IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" -IDS_SYS_MODEL, "System Model: %s\n" -IDS_SYS_TYPE, "Systemtype: %s\n" -IDS_PROCESSORS, "Prosessor(er): %u Prosessor(er) installert.\n" -IDS_BIOS_DATE, "BIOS dato: %s\n" -IDS_BIOS_VERSION, "BIOS Versjon: %s\n" -IDS_ROS_DIR, "ReactOS mappe: %s\n" -IDS_SYS_DIR, "System mappe: %s\n" -IDS_BOOT_DEV, "Oppstartsenhet: %s\n" -IDS_SYS_LOCALE, "System lokal: %s\n" -IDS_INPUT_LOCALE, "Input lokal: %s\n" -IDS_TIME_ZONE, "Tidssone: %s\n" -IDS_TOTAL_PHYS_MEM, "Total fysisk minne: %s MB\n" -IDS_AVAIL_PHISICAL_MEM, "Tilgjengelig fysisk minne: %s MB\n" -IDS_VIRT_MEM_MAX, "Virtuelt minne: Maks Strrelse: %s MB\n" -IDS_VIRT_MEM_AVAIL, "Virtuelt minne: Tilgjengelig: %s MB\n" -IDS_VIRT_MEM_INUSE, "Virtuelt minne: i bruk: %s MB\n" -IDS_PAGEFILE_LOC, "Sidevekslingsfil lokalsjon(er): %s\n" -IDS_DOMAIN, "Domene: %s\n" -IDS_NETWORK_CARDS, "Nettverkskort(er) %u installert.\n" +IDS_HOST_NAME, "Datamaskin navn" +IDS_OS_NAME, "OS navn" +IDS_OS_VERSION, "OS versjon" +IDS_BUILD, "Bygget" +IDS_OS_BUILD_TYPE, "OS bygg type" +IDS_REG_OWNER, "Registert eier" +IDS_REG_ORG, "Registerert organisasjon" +IDS_PRODUCT_ID, "Produkt ID" +IDS_INST_DATE, "Installert dato" +IDS_UP_TIME, "System Up Time" +IDS_UP_TIME_FORMAT "%u Days, %u Hours, %u Minutes, %u Seconds" +IDS_SYS_MANUFACTURER, "System Manufacturer" +IDS_SYS_MODEL, "System Model" +IDS_SYS_TYPE, "Systemtype" +IDS_PROCESSORS, "Prosessor(er)" +IDS_PROCESSORS_FORMAT, "%u Prosessor(er) installert." +IDS_BIOS_DATE, "BIOS dato" +IDS_BIOS_VERSION, "BIOS Versjon" +IDS_ROS_DIR, "ReactOS mappe" +IDS_SYS_DIR, "System mappe" +IDS_BOOT_DEV, "Oppstartsenhet" +IDS_SYS_LOCALE, "System lokal" +IDS_INPUT_LOCALE, "Input lokal" +IDS_TIME_ZONE, "Tidssone" +IDS_TOTAL_PHYS_MEM, "Total fysisk minne" +IDS_AVAIL_PHISICAL_MEM, "Tilgjengelig fysisk minne" +IDS_VIRT_MEM_MAX, "Virtuelt minne: Maks Strrelse" +IDS_VIRT_MEM_AVAIL, "Virtuelt minne: Tilgjengelig" +IDS_VIRT_MEM_INUSE, "Virtuelt minne: i bruk" +IDS_PAGEFILE_LOC, "Sidevekslingsfil lokalsjon(er)" +IDS_DOMAIN, "Domene" +IDS_NETWORK_CARDS, "Nettverkskort(er)" +IDS_NETWORK_CARDS_FORMAT, "%u installert." END diff --git a/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc b/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc index fc92954bd17..c18a60935c2 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/pl-PL.rc @@ -36,34 +36,38 @@ Przyk SYSTEMINFO /S system /FO LIST\n\ SYSTEMINFO /S system /FO CSV /NH\n" -IDS_HOST_NAME, "Nazwa hosta: %s\n" -IDS_OS_NAME, "Nazwa Systemu: %s\n" -IDS_OS_VERSION, "Wersja: %u.%u.%u %s Kompilacja %u\n" -IDS_OS_BUILD_TYPE, "Rodzaj kompilacji: %s\n" -IDS_REG_OWNER, "Uytkownik: %s\n" -IDS_REG_ORG, "Organizacja: %s\n" -IDS_PRODUCT_ID, "ID produktu: %s\n" -IDS_INST_DATE, "Data instalacji: %s\n" -IDS_UP_TIME, "Czas pracy systemu: %u dni, %u godzin, %u minut, %u sekund\n" -IDS_SYS_MANUFACTURER, "Producent systemu: %s\n" -IDS_SYS_MODEL, "Model systemu: %s\n" -IDS_SYS_TYPE, "Rodzaj systemu: %s\n" -IDS_PROCESSORS, "Ilo Procesorw: %u.\n" -IDS_BIOS_DATE, "Data BIOSu: %s\n" -IDS_BIOS_VERSION, "Wersja BIOSu: %s\n" -IDS_ROS_DIR, "Katalog ReactOS: %s\n" -IDS_SYS_DIR, "Katalog Systemowy: %s\n" -IDS_BOOT_DEV, "Urzdzenie rdowe: %s\n" -IDS_SYS_LOCALE, "Wersja lokalizacji: %s\n" -IDS_INPUT_LOCALE, "Lokalizacja klawiatury: %s\n" -IDS_TIME_ZONE, "Strefa czasowa: %s\n" -IDS_TOTAL_PHYS_MEM, "Pamici fizycznej ogem: %s MB\n" -IDS_AVAIL_PHISICAL_MEM, "Dostpnej pamici fizycznej: %s MB\n" -IDS_VIRT_MEM_MAX, "Pamici wirtualnej: maksymalnie: %s MB\n" -IDS_VIRT_MEM_AVAIL, "Pamici wirtualnej: dostpne: %s MB\n" -IDS_VIRT_MEM_INUSE, "Pamici wirtualnej: w uyciu: %s MB\n" -IDS_PAGEFILE_LOC, "Lokalizacja pliku wymiany: %s\n" -IDS_DOMAIN, "Domena: %s\n" -IDS_NETWORK_CARDS, "Liczba kart sieciowych %u.\n" +IDS_HOST_NAME, "Nazwa hosta" +IDS_OS_NAME, "Nazwa systemu" +IDS_OS_VERSION, "Wersja systemu" +IDS_BUILD, "Kompilacja" +IDS_OS_BUILD_TYPE, "Rodzaj kompilacji" +IDS_REG_OWNER, "Uytkownik" +IDS_REG_ORG, "Organizacja" +IDS_PRODUCT_ID, "ID produktu" +IDS_INST_DATE, "Data instalacji" +IDS_UP_TIME, "Czas pracy systemu" +IDS_UP_TIME_FORMAT "%u dni, %u godzin, %u minut, %u sekund" +IDS_SYS_MANUFACTURER, "Producent systemu" +IDS_SYS_MODEL, "Model systemu" +IDS_SYS_TYPE, "Rodzaj systemu" +IDS_PROCESSORS, "Procesory" +IDS_PROCESSORS_FORMAT, "Zainstalowane procesory: %u." +IDS_BIOS_DATE, "Data BIOSu" +IDS_BIOS_VERSION, "Wersja BIOSu" +IDS_ROS_DIR, "Katalog ReactOS" +IDS_SYS_DIR, "Katalog Systemowy" +IDS_BOOT_DEV, "Urzdzenie rdowe" +IDS_SYS_LOCALE, "Wersja lokalizacji" +IDS_INPUT_LOCALE, "Lokalizacja klawiatury" +IDS_TIME_ZONE, "Strefa czasowa" +IDS_TOTAL_PHYS_MEM, "Pamici fizycznej ogem" +IDS_AVAIL_PHISICAL_MEM, "Dostpnej pamici fizycznej" +IDS_VIRT_MEM_MAX, "Pamici wirtualnej: maksymalnie" +IDS_VIRT_MEM_AVAIL, "Pamici wirtualnej: dostpne" +IDS_VIRT_MEM_INUSE, "Pamici wirtualnej: w uyciu" +IDS_PAGEFILE_LOC, "Lokalizacja pliku wymiany" +IDS_DOMAIN, "Domena" +IDS_NETWORK_CARDS, "Karty sieciowe" +IDS_NETWORK_CARDS_FORMAT, "Zainstalowane karty NIC: %u." END diff --git a/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc b/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc index 474373b7744..7da44551e49 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/sk-SK.rc @@ -33,34 +33,38 @@ Examples:\n\ SYSTEMINFO /S system /FO LIST\n\ SYSTEMINFO /S system /FO CSV /NH\n" -IDS_HOST_NAME, "Host Name: %s\n" -IDS_OS_NAME, "Nzov OS: %s\n" -IDS_OS_VERSION, "Verzia OS: %u.%u.%u %s Build %u\n" -IDS_OS_BUILD_TYPE, "OS Build typ: %s\n" -IDS_REG_OWNER, "Registovan vlastnk: %s\n" -IDS_REG_ORG, "Registrovan organizcia: %s\n" -IDS_PRODUCT_ID, "ID produktu: %s\n" -IDS_INST_DATE, "Dtum intalcie: %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u Minutes, %u Seconds\n" -IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" -IDS_SYS_MODEL, "System Model: %s\n" -IDS_SYS_TYPE, "Typ systmu: %s\n" -IDS_PROCESSORS, "Procesor(y): %u Procesor(y) naintalovan.\n" -IDS_BIOS_DATE, "Dtum BIOSu: %s\n" -IDS_BIOS_VERSION, "Verzia BIOSu: %s\n" -IDS_ROS_DIR, "Adresr ReactOS: %s\n" -IDS_SYS_DIR, "Adresr System: %s\n" -IDS_BOOT_DEV, "Zavdzacie zariadenie: %s\n" -IDS_SYS_LOCALE, "System Locale: %s\n" -IDS_INPUT_LOCALE, "Input Locale: %s\n" -IDS_TIME_ZONE, "asov psmo: %s\n" -IDS_TOTAL_PHYS_MEM, "Celkov fyzick pam: %s MB\n" -IDS_AVAIL_PHISICAL_MEM, "Dostupn fyzick pam: %s MB\n" -IDS_VIRT_MEM_MAX, "Virtulna pam: Max Size: %s MB\n" -IDS_VIRT_MEM_AVAIL, "Virtulna pam: Available: %s MB\n" -IDS_VIRT_MEM_INUSE, "Virtulna pam: In Use: %s MB\n" -IDS_PAGEFILE_LOC, "Umiestnenie(a) strnkovacieho sboru: %s\n" -IDS_DOMAIN, "Domna: %s\n" -IDS_NETWORK_CARDS, "Sieov karta(y) %u naintalovan.\n" +IDS_HOST_NAME, "Host Name" +IDS_OS_NAME, "Nzov OS" +IDS_OS_VERSION, "Verzia OS" +IDS_BUILD, "Build" +IDS_OS_BUILD_TYPE, "OS Build typ" +IDS_REG_OWNER, "Registovan vlastnk" +IDS_REG_ORG, "Registrovan organizcia" +IDS_PRODUCT_ID, "ID produktu" +IDS_INST_DATE, "Dtum intalcie" +IDS_UP_TIME, "System Up Time" +IDS_UP_TIME_FORMAT "%u Days, %u Hours, %u Minutes, %u Seconds" +IDS_SYS_MANUFACTURER, "System Manufacturer" +IDS_SYS_MODEL, "System Model" +IDS_SYS_TYPE, "Typ systmu" +IDS_PROCESSORS, "Procesor(y)" +IDS_PROCESSORS_FORMAT, "%u Procesor(y) naintalovan." +IDS_BIOS_DATE, "Dtum BIOSu" +IDS_BIOS_VERSION, "Verzia BIOSu" +IDS_ROS_DIR, "Adresr ReactOS" +IDS_SYS_DIR, "Adresr System" +IDS_BOOT_DEV, "Zavdzacie zariadenie" +IDS_SYS_LOCALE, "System Locale" +IDS_INPUT_LOCALE, "Input Locale" +IDS_TIME_ZONE, "asov psmo" +IDS_TOTAL_PHYS_MEM, "Celkov fyzick pam" +IDS_AVAIL_PHISICAL_MEM, "Dostupn fyzick pam" +IDS_VIRT_MEM_MAX, "Virtulna pam: Max Size" +IDS_VIRT_MEM_AVAIL, "Virtulna pam: Available" +IDS_VIRT_MEM_INUSE, "Virtulna pam: In Use" +IDS_PAGEFILE_LOC, "Umiestnenie(a) strnkovacieho sboru" +IDS_DOMAIN, "Domna" +IDS_NETWORK_CARDS, "Sieov karta(y)" +IDS_NETWORK_CARDS_FORMAT, "%u naintalovan." END diff --git a/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc b/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc index a0c8f57674f..08e575c3fb8 100644 --- a/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc +++ b/rosapps/applications/sysutils/systeminfo/lang/uk-UA.rc @@ -37,34 +37,38 @@ IDS_USAGE, "SYSTEMINFO [/S SYSTEMINFO /S /FO LIST\n\ SYSTEMINFO /S /FO CSV /NH\n" -IDS_HOST_NAME, "' ': %s\n" -IDS_OS_NAME, "' : %s\n" -IDS_OS_VERSION, " : %u.%u.%u %s %u\n" -IDS_OS_BUILD_TYPE, " : %s\n" -IDS_REG_OWNER, " : %s\n" -IDS_REG_ORG, " : %s\n" -IDS_PRODUCT_ID, "ID : %s\n" -IDS_INST_DATE, " : %s\n" -IDS_UP_TIME, "System Up Time: %u Days, %u Hours, %u Minutes, %u Seconds\n" -IDS_SYS_MANUFACTURER, "System Manufacturer: %s\n" -IDS_SYS_MODEL, "System Model: %s\n" -IDS_SYS_TYPE, " : %s\n" -IDS_PROCESSORS, "(): %u (,) .\n" -IDS_BIOS_DATE, " BIOS: %s\n" -IDS_BIOS_VERSION, " BIOS: %s\n" -IDS_ROS_DIR, " ReactOS: %s\n" -IDS_SYS_DIR, " : %s\n" -IDS_BOOT_DEV, " : %s\n" -IDS_SYS_LOCALE, " : %s\n" -IDS_INPUT_LOCALE, " : %s\n" -IDS_TIME_ZONE, " : %s\n" -IDS_TOTAL_PHYS_MEM, " ': %s \n" -IDS_AVAIL_PHISICAL_MEM, " ': %s \n" -IDS_VIRT_MEM_MAX, "³ ': . : %s \n" -IDS_VIRT_MEM_AVAIL, "³ ': : %s \n" -IDS_VIRT_MEM_INUSE, "³ ': .: %s \n" -IDS_PAGEFILE_LOC, " : %s\n" -IDS_DOMAIN, ": %s\n" -IDS_NETWORK_CARDS, " () %u Installed.\n" +IDS_HOST_NAME, "' '" +IDS_OS_NAME, "' " +IDS_OS_VERSION, " " +IDS_BUILD, "" +IDS_OS_BUILD_TYPE, " " +IDS_REG_OWNER, " " +IDS_REG_ORG, " " +IDS_PRODUCT_ID, "ID " +IDS_INST_DATE, " " +IDS_UP_TIME, "System Up Time" +IDS_UP_TIME_FORMAT "%u Days, %u Hours, %u Minutes, %u Seconds" +IDS_SYS_MANUFACTURER, "System Manufacturer" +IDS_SYS_MODEL, "System Model" +IDS_SYS_TYPE, " " +IDS_PROCESSORS, "()" +IDS_PROCESSORS_FORMAT, "%u (,) ." +IDS_BIOS_DATE, " BIOS" +IDS_BIOS_VERSION, " BIOS" +IDS_ROS_DIR, " ReactOS" +IDS_SYS_DIR, " " +IDS_BOOT_DEV, " " +IDS_SYS_LOCALE, " " +IDS_INPUT_LOCALE, " " +IDS_TIME_ZONE, " " +IDS_TOTAL_PHYS_MEM, " '" +IDS_AVAIL_PHISICAL_MEM, " '" +IDS_VIRT_MEM_MAX, "³ ': . " +IDS_VIRT_MEM_AVAIL, "³ ': " +IDS_VIRT_MEM_INUSE, "³ ': ." +IDS_PAGEFILE_LOC, " " +IDS_DOMAIN, "" +IDS_NETWORK_CARDS, " ()" +IDS_NETWORK_CARDS_FORMAT, "%u Installed." END diff --git a/rosapps/applications/sysutils/systeminfo/resource.h b/rosapps/applications/sysutils/systeminfo/resource.h index c50f3bd74e8..c69f6f5a20d 100644 --- a/rosapps/applications/sysutils/systeminfo/resource.h +++ b/rosapps/applications/sysutils/systeminfo/resource.h @@ -3,29 +3,33 @@ #define IDS_HOST_NAME 100 #define IDS_OS_NAME 101 #define IDS_OS_VERSION 102 -#define IDS_OS_BUILD_TYPE 103 -#define IDS_REG_OWNER 104 -#define IDS_REG_ORG 105 -#define IDS_PRODUCT_ID 106 -#define IDS_INST_DATE 107 +#define IDS_BUILD 103 +#define IDS_OS_BUILD_TYPE 104 +#define IDS_REG_OWNER 105 +#define IDS_REG_ORG 106 +#define IDS_PRODUCT_ID 107 +#define IDS_INST_DATE 108 #define IDS_UP_TIME 109 -#define IDS_SYS_MANUFACTURER 110 -#define IDS_SYS_MODEL 111 -#define IDS_SYS_TYPE 112 -#define IDS_PROCESSORS 113 -#define IDS_BIOS_DATE 114 -#define IDS_BIOS_VERSION 115 -#define IDS_ROS_DIR 116 -#define IDS_SYS_DIR 117 -#define IDS_BOOT_DEV 118 -#define IDS_SYS_LOCALE 119 -#define IDS_INPUT_LOCALE 120 -#define IDS_TOTAL_PHYS_MEM 121 -#define IDS_AVAIL_PHISICAL_MEM 122 -#define IDS_VIRT_MEM_MAX 123 -#define IDS_VIRT_MEM_AVAIL 124 -#define IDS_VIRT_MEM_INUSE 125 -#define IDS_PAGEFILE_LOC 126 -#define IDS_TIME_ZONE 127 -#define IDS_DOMAIN 128 -#define IDS_NETWORK_CARDS 130 +#define IDS_UP_TIME_FORMAT 110 +#define IDS_SYS_MANUFACTURER 111 +#define IDS_SYS_MODEL 112 +#define IDS_SYS_TYPE 113 +#define IDS_PROCESSORS 114 +#define IDS_PROCESSORS_FORMAT 115 +#define IDS_BIOS_DATE 116 +#define IDS_BIOS_VERSION 117 +#define IDS_ROS_DIR 118 +#define IDS_SYS_DIR 119 +#define IDS_BOOT_DEV 120 +#define IDS_SYS_LOCALE 121 +#define IDS_INPUT_LOCALE 122 +#define IDS_TOTAL_PHYS_MEM 123 +#define IDS_AVAIL_PHISICAL_MEM 124 +#define IDS_VIRT_MEM_MAX 125 +#define IDS_VIRT_MEM_AVAIL 126 +#define IDS_VIRT_MEM_INUSE 127 +#define IDS_PAGEFILE_LOC 128 +#define IDS_TIME_ZONE 129 +#define IDS_DOMAIN 130 +#define IDS_NETWORK_CARDS 131 +#define IDS_NETWORK_CARDS_FORMAT 132 diff --git a/rosapps/applications/sysutils/systeminfo/systeminfo.c b/rosapps/applications/sysutils/systeminfo/systeminfo.c index 49503679c2b..d9ebe2a6e62 100644 --- a/rosapps/applications/sysutils/systeminfo/systeminfo.c +++ b/rosapps/applications/sysutils/systeminfo/systeminfo.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -42,11 +43,11 @@ GetOemStrings(UINT rcID, LPWSTR OutMsg) /* Load data from registry */ static -BOOL -RegGetSZ(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPWSTR Buf) +unsigned +RegGetSZ(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPWSTR lpBuf, DWORD cchBuf) { - DWORD dwBytes = BUFFER_SIZE*sizeof(WCHAR), dwType; - BOOL bRet = TRUE; + DWORD dwBytes = cchBuf*sizeof(WCHAR), dwType; + unsigned cChars; /* If SubKy is specified open it */ if (lpSubKey && RegOpenKeyExW(hKey, @@ -56,29 +57,34 @@ RegGetSZ(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPWSTR Buf) &hKey) != ERROR_SUCCESS) { wprintf(L"Warning! Cannot open %s. Last error: %lu.\n", lpSubKey, GetLastError()); - return FALSE; + return 0; } if (RegQueryValueExW(hKey, lpValueName, NULL, &dwType, - (LPBYTE)Buf, + (LPBYTE)lpBuf, &dwBytes) != ERROR_SUCCESS || (dwType != REG_SZ && dwType != REG_MULTI_SZ)) { wprintf(L"Warning! Cannot query %s. Last error: %lu, type: %lu.\n", lpValueName, GetLastError(), dwType); dwBytes = 0; - bRet = FALSE; } /* Close key if we opened it */ if (lpSubKey) RegCloseKey(hKey); - /* NULL-terminate string */ - Buf[min(BUFFER_SIZE-1, dwBytes/sizeof(WCHAR))] = L'\0'; + cChars = dwBytes/sizeof(WCHAR); - return bRet; + /* NULL-terminate string */ + lpBuf[min(cchBuf-1, cChars)] = L'\0'; + + /* Don't count NULL characters */ + while(cChars && !lpBuf[cChars-1]) + --cChars; + + return cChars; } static @@ -119,11 +125,12 @@ RegGetDWORD(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPDWORD lpData) } static -void -FormatBytes(LPWSTR Buf, unsigned cBytes) +VOID +FormatBytes(LPWSTR lpBuf, unsigned cBytes) { WCHAR szMB[32]; NUMBERFMTW fmt; + unsigned i; _itow(cBytes / (1024*1024), szMB, 10); @@ -134,15 +141,17 @@ FormatBytes(LPWSTR Buf, unsigned cBytes) fmt.lpThousandSep = L" "; fmt.NegativeOrder = 0; - if(!GetNumberFormatW(LOCALE_SYSTEM_DEFAULT, 0, szMB, &fmt, Buf, BUFFER_SIZE)) - wprintf(L"Error! GetNumberFormat failed.\n"); + i = GetNumberFormatW(LOCALE_SYSTEM_DEFAULT, 0, szMB, &fmt, lpBuf, BUFFER_SIZE - 3); + if (i) + --i; /* don't count NULL character */ + wcscpy(lpBuf + i, L" MB"); } static -void +VOID FormatDateTime(time_t Time, LPWSTR lpBuf) { - unsigned cchBuf = BUFFER_SIZE, i; + unsigned i; SYSTEMTIME SysTime; const struct tm *lpTm; @@ -156,14 +165,15 @@ FormatDateTime(time_t Time, LPWSTR lpBuf) SysTime.wSecond = (WORD)lpTm->tm_sec; SysTime.wMilliseconds = 0; - /* Time first */ - i = GetDateFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf, cchBuf); + /* Copy date first */ + i = GetDateFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf, BUFFER_SIZE - 2); if (i) --i; /* don't count NULL character */ - /* Time now */ + /* Copy time now */ i += swprintf(lpBuf + i, L", "); - GetTimeFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf + i, cchBuf - i); + i += 2; + GetTimeFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf + i, BUFFER_SIZE - i); } /* Show usage */ @@ -177,6 +187,32 @@ Usage(VOID) wprintf(L"%s", Buf); } +static +VOID +PrintRow(UINT nTitleID, unsigned cxOffset, LPWSTR lpFormat, ...) +{ + WCHAR Buf[BUFFER_SIZE]; + va_list Args; + unsigned c; + + if (nTitleID) + { + c = LoadStringW(GetModuleHandle(NULL), nTitleID, Buf, BUFFER_SIZE); + if (!c) + return; + + wcscpy(Buf + c, L":"); + } else + Buf[0] = L'\0'; + wprintf(L"%-32s ", Buf); + + va_start(Args, lpFormat); + vwprintf(lpFormat, Args); + va_end(Args); + + wprintf(L"\n"); +} + /* Print all system information */ VOID AllSysInfo(VOID) @@ -189,7 +225,7 @@ AllSysInfo(VOID) LPWSTR lpBuffer; NETSETUP_JOIN_STATUS NetJoinStatus; MEMORYSTATUS MemoryStatus; - unsigned int cSeconds; + unsigned int cSeconds, i, j; TIME_ZONE_INFORMATION TimeZoneInfo; HKEY hKey; @@ -205,8 +241,8 @@ AllSysInfo(VOID) dwCharCount = BUFFER_SIZE; if (!GetComputerNameW(Buf, &dwCharCount)) wprintf(L"Error! GetComputerName failed.\n"); - else if (GetOemStrings(IDS_HOST_NAME, Msg)) - wprintf(Msg, Buf); + else + PrintRow(IDS_HOST_NAME, 0, L"%s", Buf); // open CurrentVersion key if(RegOpenKeyExW(HKEY_LOCAL_MACHINE, @@ -220,60 +256,60 @@ AllSysInfo(VOID) } //getting OS Name - RegGetSZ(hKey, NULL, L"ProductName", Buf); - if (GetOemStrings(IDS_OS_NAME, Msg)) - wprintf(Msg, Buf); + RegGetSZ(hKey, NULL, L"ProductName", Buf, BUFFER_SIZE); + PrintRow(IDS_OS_NAME, 0, L"%s", Buf); //getting OS Version ZeroMemory(&VersionInfo, sizeof(VersionInfo)); VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo); GetVersionExW(&VersionInfo); - if (GetOemStrings(IDS_OS_VERSION, Msg)) - wprintf(Msg, - (unsigned)VersionInfo.dwMajorVersion, - (unsigned)VersionInfo.dwMinorVersion, - (unsigned)VersionInfo.dwBuildNumber, - VersionInfo.szCSDVersion, - (unsigned)VersionInfo.dwBuildNumber); + if (!LoadStringW(GetModuleHandle(NULL), IDS_BUILD, Tmp, BUFFER_SIZE)) + Tmp[0] = L'\0'; + PrintRow(IDS_OS_VERSION, + 0, + L"%u.%u.%u %s %s %u", + (unsigned)VersionInfo.dwMajorVersion, + (unsigned)VersionInfo.dwMinorVersion, + (unsigned)VersionInfo.dwBuildNumber, + VersionInfo.szCSDVersion, + Tmp, + (unsigned)VersionInfo.dwBuildNumber); //getting OS Manufacturer //getting OS Configuration //getting OS Build Type - RegGetSZ(hKey, NULL, L"CurrentType", Buf); - if (GetOemStrings(IDS_OS_BUILD_TYPE, Msg)) - wprintf(Msg, Buf); + RegGetSZ(hKey, NULL, L"CurrentType", Buf, BUFFER_SIZE); + PrintRow(IDS_OS_BUILD_TYPE, 0, L"%s", Buf); //getting Registered Owner - RegGetSZ(hKey, NULL, L"RegisteredOwner", Buf); - if (GetOemStrings(IDS_REG_OWNER, Msg)) - wprintf(Msg, Buf); + RegGetSZ(hKey, NULL, L"RegisteredOwner", Buf, BUFFER_SIZE); + PrintRow(IDS_REG_OWNER, 0, L"%s", Buf); //getting Registered Organization - RegGetSZ(hKey, NULL, L"RegisteredOrganization", Buf); - if (GetOemStrings(IDS_REG_ORG, Msg)) - wprintf(Msg, Buf); + RegGetSZ(hKey, NULL, L"RegisteredOrganization", Buf, BUFFER_SIZE); + PrintRow(IDS_REG_ORG, 0, L"%s", Buf); //getting Product ID - RegGetSZ(hKey, NULL, L"ProductId", Buf); - if (GetOemStrings(IDS_PRODUCT_ID, Msg)) - wprintf(Msg, Buf); + RegGetSZ(hKey, NULL, L"ProductId", Buf, BUFFER_SIZE); + PrintRow(IDS_PRODUCT_ID, 0, L"%s", Buf); //getting Install Date RegGetDWORD(hKey, NULL, L"InstallDate", &dwTimestamp); FormatDateTime((time_t)dwTimestamp, Buf); - if (GetOemStrings(IDS_INST_DATE, Msg)) - wprintf(Msg, Buf); + PrintRow(IDS_INST_DATE, 0, L"%s", Buf); // close Current Version key now RegCloseKey(hKey); //getting System Up Time cSeconds = GetTickCount() / 1000; - if (GetOemStrings(IDS_UP_TIME, Msg)) - wprintf(Msg, cSeconds / (60*60*24), (cSeconds / (60*60)) % 24, (cSeconds / 60) % 60, cSeconds % 60); + if (!LoadStringW(GetModuleHandle(NULL), IDS_UP_TIME_FORMAT, Tmp, BUFFER_SIZE)) + Tmp[0] = L'\0'; + swprintf(Buf, Tmp, cSeconds / (60*60*24), (cSeconds / (60*60)) % 24, (cSeconds / 60) % 60, cSeconds % 60); + PrintRow(IDS_UP_TIME, 0, L"%s", Buf); //getting System Manufacturer; HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\Manufacturer for Win >= 6.0 swprintf(Tmp, L"%s\\oeminfo.ini", szSystemDir); @@ -283,8 +319,7 @@ AllSysInfo(VOID) Buf, sizeof(Buf)/sizeof(Buf[0]), Tmp); - if (GetOemStrings(IDS_SYS_MANUFACTURER, Msg)) - wprintf(Msg, Buf); + PrintRow(IDS_SYS_MANUFACTURER, 0, L"%s", Buf); //getting System Model; HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\Model for Win >= 6.0 GetPrivateProfileStringW(L"General", @@ -293,8 +328,7 @@ AllSysInfo(VOID) Buf, sizeof(Buf)/sizeof(Buf[0]), Tmp); - if (GetOemStrings(IDS_SYS_MODEL, Msg)) - wprintf(Msg, Buf); + PrintRow(IDS_SYS_MODEL, 0, L"%s", Buf); //getting System type switch (SysInfo.wProcessorArchitecture) @@ -312,93 +346,93 @@ AllSysInfo(VOID) lpcszSysType = L"Unknown"; break; } - if (GetOemStrings(IDS_SYS_TYPE, Msg)) - wprintf(Msg, lpcszSysType); + PrintRow(IDS_SYS_TYPE, 0, L"%s", lpcszSysType); //getting Processor(s) - if (GetOemStrings(IDS_PROCESSORS, Msg)) + if (!LoadStringW(GetModuleHandle(NULL), IDS_PROCESSORS_FORMAT, Tmp, BUFFER_SIZE)) + Tmp[0] = L'\0'; + swprintf(Buf, Tmp, (unsigned)SysInfo.dwNumberOfProcessors); + PrintRow(IDS_PROCESSORS, 0, L"%s", Buf); + for(i = 0; i < (unsigned int)SysInfo.dwNumberOfProcessors; i++) { - unsigned int i; - wprintf(Msg, (unsigned int)SysInfo.dwNumberOfProcessors); - for(i = 0; i < (unsigned int)SysInfo.dwNumberOfProcessors; i++) - { - swprintf(Tmp, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u", i); - - RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"Identifier", Buf); - wprintf(L" [%02u]: %s", i+1, Buf); - - RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"VendorIdentifier", Buf); - wprintf(L" %s\n", Buf); - } + swprintf(Tmp, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u", i); + j = swprintf(Buf, L"[%02u]: ", i + 1); + + j += RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"Identifier", Buf + j, BUFFER_SIZE - j); + if(j + 1 < BUFFER_SIZE) + Buf[j++] = L' '; + RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"VendorIdentifier", Buf + j, BUFFER_SIZE - j); + + PrintRow(0, 0, L"%s", Buf); } //getting BIOS Version RegGetSZ(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System", L"SystemBiosVersion", - Buf); - if (GetOemStrings(IDS_BIOS_VERSION, Msg)) - wprintf(Msg, Buf); + Buf, + BUFFER_SIZE); + PrintRow(IDS_BIOS_VERSION, 0, L"%s", Buf); //gettings BIOS date RegGetSZ(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System", L"SystemBiosDate", - Buf); - if (GetOemStrings(IDS_BIOS_DATE, Msg)) - wprintf(Msg, Buf); + Buf, + BUFFER_SIZE); + PrintRow(IDS_BIOS_DATE, 0, L"%s", Buf); //getting ReactOS Directory if (!GetWindowsDirectoryW(Buf, BUFFER_SIZE)) wprintf(L"Error! GetWindowsDirectory failed."); - else if (GetOemStrings(IDS_ROS_DIR, Msg)) - wprintf(Msg, Buf); + else + PrintRow(IDS_ROS_DIR, 0, L"%s", Buf); //getting System Directory - if (GetOemStrings(IDS_SYS_DIR, Msg)) - wprintf(Msg, szSystemDir); + PrintRow(IDS_SYS_DIR, 0, L"%s", szSystemDir); //getting Boot Device RegGetSZ(HKEY_LOCAL_MACHINE, L"SYSTEM\\Setup", L"SystemPartition", - Buf); - if (GetOemStrings(IDS_BOOT_DEV, Msg)) - wprintf(Msg, Buf); + Buf, + BUFFER_SIZE); + PrintRow(IDS_BOOT_DEV, 0, L"%s", Buf); //getting System Locale if (GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, Tmp, BUFFER_SIZE)) if (RegGetSZ(HKEY_CLASSES_ROOT, L"MIME\\Database\\Rfc1766", Tmp, - Buf)) + Buf, + BUFFER_SIZE)) { /* get rid of @filename,resource */ lpBuffer = wcschr(Buf, L';'); if (lpBuffer) SHLoadIndirectString(lpBuffer+1, lpBuffer+1, BUFFER_SIZE - (lpBuffer-Buf) - 1, NULL); - if (GetOemStrings(IDS_SYS_LOCALE, Msg)) - wprintf(Msg, Buf); + PrintRow(IDS_SYS_LOCALE, 0, L"%s", Buf); } //getting Input Locale if (RegGetSZ(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", L"1", - Tmp) && wcslen(Tmp) > 4) + Tmp, + BUFFER_SIZE) && wcslen(Tmp) > 4) if (RegGetSZ(HKEY_CLASSES_ROOT, L"MIME\\Database\\Rfc1766", Tmp + 4, - Buf)) + Buf, + BUFFER_SIZE)) { /* get rid of @filename,resource */ lpBuffer = wcschr(Buf, L';'); if (lpBuffer) SHLoadIndirectString(lpBuffer+1, lpBuffer+1, BUFFER_SIZE - (lpBuffer-Buf) - 1, NULL); - if (GetOemStrings(IDS_INPUT_LOCALE, Msg)) - wprintf(Msg, Buf); + PrintRow(IDS_INPUT_LOCALE, 0, L"%s", Buf); } //getting Time Zone @@ -417,14 +451,13 @@ AllSysInfo(VOID) dwCharCount = 256; // Windows seems to have a bug - it doesnt accept BUFFER_SIZE here for(i = 0; RegEnumKeyExW(hKey, i, Tmp, &dwCharCount, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++i, dwCharCount = 255) { - RegGetSZ(hKey, Tmp, L"Std", Buf); + RegGetSZ(hKey, Tmp, L"Std", Buf, BUFFER_SIZE); if(!wcscmp(Buf, TimeZoneInfo.StandardName)) { - RegGetSZ(hKey, Tmp, L"Display", Buf); + RegGetSZ(hKey, Tmp, L"Display", Buf, BUFFER_SIZE); - if (GetOemStrings(IDS_TIME_ZONE, Msg)) - wprintf(Msg, Buf); + PrintRow(IDS_TIME_ZONE, 0, L"%s", Buf); break; } @@ -435,55 +468,49 @@ AllSysInfo(VOID) //getting Total Physical Memory GlobalMemoryStatus(&MemoryStatus); FormatBytes(Buf, MemoryStatus.dwTotalPhys); - if (GetOemStrings(IDS_TOTAL_PHYS_MEM, Msg)) - wprintf(Msg, Buf); + PrintRow(IDS_TOTAL_PHYS_MEM, 0, L"%s", Buf); //getting Available Physical Memory FormatBytes(Buf, MemoryStatus.dwAvailPhys); - if (GetOemStrings(IDS_AVAIL_PHISICAL_MEM,Msg)) - wprintf(Msg, Buf); + PrintRow(IDS_AVAIL_PHISICAL_MEM, 0, L"%s", Buf); //getting Virtual Memory: Max Size FormatBytes(Buf, MemoryStatus.dwTotalVirtual); - if (GetOemStrings(IDS_VIRT_MEM_MAX, Msg)) - wprintf(Msg, Buf); + PrintRow(IDS_VIRT_MEM_MAX, 0, L"%s", Buf); //getting Virtual Memory: Available FormatBytes(Buf, MemoryStatus.dwAvailVirtual); - if (GetOemStrings(IDS_VIRT_MEM_AVAIL, Msg)) - wprintf(Msg, Buf); + PrintRow(IDS_VIRT_MEM_AVAIL, 0, L"%s", Buf); //getting Virtual Memory: In Use FormatBytes(Buf, MemoryStatus.dwTotalVirtual-MemoryStatus.dwAvailVirtual); - if (GetOemStrings(IDS_VIRT_MEM_INUSE, Msg)) - wprintf(Msg, Buf); + PrintRow(IDS_VIRT_MEM_INUSE, 0, L"%s", Buf); //getting Page File Location(s) if (RegGetSZ(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management", L"PagingFiles", - Buf)) + Buf, + BUFFER_SIZE)) { int i; - for(i = 0; i < strlen((char*)Buf); i++) + for(i = 0; Buf[i]; i++) { - if (Buf[i] == TEXT(' ')) + if (Buf[i] == L' ') { - Buf[i] = TEXT('\0'); + Buf[i] = L'\0'; break; } } - if(GetOemStrings(IDS_PAGEFILE_LOC, Msg)) - wprintf(Msg, Buf); + PrintRow(IDS_PAGEFILE_LOC, 0, L"%s", Buf); } //getting Domain if (NetGetJoinInformation (NULL, &lpBuffer, &NetJoinStatus) == NERR_Success) { - if(GetOemStrings(IDS_DOMAIN, Msg)) - wprintf(Msg, lpBuffer); + PrintRow(IDS_DOMAIN, 0, L"%s", lpBuffer); NetApiBufferFree(lpBuffer); } From d7899fc4747e43848fbcad124488500e13d033af Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Sat, 2 Apr 2011 18:12:31 +0000 Subject: [PATCH 58/66] [FULLFAT] - Fix warnings for both msc and rbuild - These fixes will be applied to the FullFat source too, so I've not bothered with a local ros.diff svn path=/trunk/; revision=51234 --- .../include/reactos/libs/fullfat/ff_string.h | 2 - reactos/lib/3rdparty/fullfat/ff_dir.c | 6 +- reactos/lib/3rdparty/fullfat/ff_dir.h | 169 ------------------ reactos/lib/3rdparty/fullfat/fullfat.rbuild | 2 +- 4 files changed, 5 insertions(+), 174 deletions(-) delete mode 100644 reactos/lib/3rdparty/fullfat/ff_dir.h diff --git a/reactos/include/reactos/libs/fullfat/ff_string.h b/reactos/include/reactos/libs/fullfat/ff_string.h index a5e85955da4..0820391f56c 100644 --- a/reactos/include/reactos/libs/fullfat/ff_string.h +++ b/reactos/include/reactos/libs/fullfat/ff_string.h @@ -48,10 +48,8 @@ #include #ifdef WIN32 -#define stricmp stricmp #define FF_stricmp stricmp #else -#define strcasecmp strcasecmp #define FF_stricmp strcasecmp #endif diff --git a/reactos/lib/3rdparty/fullfat/ff_dir.c b/reactos/lib/3rdparty/fullfat/ff_dir.c index f34c18ecbab..b9767352b8e 100644 --- a/reactos/lib/3rdparty/fullfat/ff_dir.c +++ b/reactos/lib/3rdparty/fullfat/ff_dir.c @@ -261,13 +261,15 @@ FF_T_UINT32 FF_FindEntryInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, const FF #else FF_T_INT8 *lastPtr = pDirent->FileName + sizeof(pDirent->FileName); #endif - FF_T_UINT8 CheckSum; + FF_T_UINT8 CheckSum = 0; FF_T_UINT8 lastAttrib; FF_T_INT8 totalLFNs = 0; FF_T_INT8 numLFNs = 0; FF_T_INT32 i; FF_T_UINT16 lfnItem = 0; + pError = NULL; + pDirent->CurrentItem = 0; pDirent->Attrib = 0; @@ -1095,8 +1097,8 @@ FF_ERROR FF_PopulateLongDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT16 FF_ERROR Error; FF_T_UINT uiNumLFNs; FF_T_UINT uiLfnLength = 0; - FF_T_UINT i,y; #ifdef FF_UNICODE_UTF8_SUPPORT + FF_T_UINT i,y; // FF_T_SINT32 slRetVal; FF_T_UINT16 nLfnBegin; FF_T_UINT16 usUtf8Len = 0; diff --git a/reactos/lib/3rdparty/fullfat/ff_dir.h b/reactos/lib/3rdparty/fullfat/ff_dir.h deleted file mode 100644 index 6c99b7279c5..00000000000 --- a/reactos/lib/3rdparty/fullfat/ff_dir.h +++ /dev/null @@ -1,169 +0,0 @@ -/***************************************************************************** - * FullFAT - High Performance, Thread-Safe Embedded FAT File-System * - * Copyright (C) 2009 James Walmsley (james@worm.me.uk) * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - * * - * IMPORTANT NOTICE: * - * ================= * - * Alternative Licensing is available directly from the Copyright holder, * - * (James Walmsley). For more information consult LICENSING.TXT to obtain * - * a Commercial license. * - * * - * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. * - * * - * Removing the above notice is illegal and will invalidate this license. * - ***************************************************************************** - * See http://worm.me.uk/fullfat for more information. * - * Or http://fullfat.googlecode.com/ for latest releases and the wiki. * - *****************************************************************************/ - -/** - * @file ff_dir.h - * @author James Walmsley - * @ingroup DIR - **/ -#ifndef _FF_DIR_H_ -#define _FF_DIR_H_ - -#include "ff_types.h" -#include "ff_config.h" -#include "ff_error.h" -#include "ff_ioman.h" -#include "ff_blk.h" -#include "ff_fat.h" -#include "ff_fatdef.h" -#include "ff_memory.h" -#include "ff_time.h" -#include "ff_hash.h" -#include "ff_crc.h" -#include "ff_file.h" -#include - -typedef struct { - FF_T_UINT32 ulChainLength; - FF_T_UINT32 ulDirCluster; - FF_T_UINT32 ulCurrentClusterLCN; - FF_T_UINT32 ulCurrentClusterNum; - FF_T_UINT32 ulCurrentEntry; - FF_BUFFER *pBuffer; -} FF_FETCH_CONTEXT; - -typedef struct { - FF_T_UINT32 Filesize; - FF_T_UINT32 ObjectCluster; - - // Book Keeping - FF_T_UINT32 CurrentCluster; - FF_T_UINT32 AddrCurrentCluster; - FF_T_UINT32 DirCluster; - FF_T_UINT16 CurrentItem; - // End Book Keeping - -#ifdef FF_TIME_SUPPORT - FF_SYSTEMTIME CreateTime; ///< Date and Time Created. - FF_SYSTEMTIME ModifiedTime; ///< Date and Time Modified. - FF_SYSTEMTIME AccessedTime; ///< Date of Last Access. -#endif - -#ifdef FF_FINDAPI_ALLOW_WILDCARDS -#ifdef FF_UNICODE_SUPPORT - FF_T_WCHAR szWildCard[FF_MAX_FILENAME]; -#else - FF_T_INT8 szWildCard[FF_MAX_FILENAME]; -#endif -#endif - -#ifdef FF_UNICODE_SUPPORT - FF_T_WCHAR FileName[FF_MAX_FILENAME]; -#else - FF_T_INT8 FileName[FF_MAX_FILENAME]; -#endif - -#if defined(FF_LFN_SUPPORT) && defined(FF_INCLUDE_SHORT_NAME) - FF_T_INT8 ShortName[13]; -#endif - FF_T_UINT8 Attrib; - FF_FETCH_CONTEXT FetchContext; -} FF_DIRENT; - - - -// PUBLIC API -#ifdef FF_UNICODE_SUPPORT -FF_ERROR FF_FindFirst (FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_WCHAR *path); -FF_ERROR FF_MkDir (FF_IOMAN *pIoman, const FF_T_WCHAR *Path); -#else -FF_ERROR FF_FindFirst (FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_INT8 *path); -FF_ERROR FF_MkDir (FF_IOMAN *pIoman, const FF_T_INT8 *Path); -#endif - -FF_ERROR FF_FindNext (FF_IOMAN *pIoman, FF_DIRENT *pDirent); - - -// INTERNAL API -FF_ERROR FF_GetEntry (FF_IOMAN *pIoman, FF_T_UINT16 nEntry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); -FF_ERROR FF_PutEntry (FF_IOMAN *pIoman, FF_T_UINT16 Entry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); -FF_T_SINT8 FF_FindEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *Name, FF_DIRENT *pDirent, FF_T_BOOL LFNs); - -void FF_PopulateShortDirent (FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT8 *EntryBuffer); -FF_ERROR FF_PopulateLongDirent (FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT16 nEntry, FF_FETCH_CONTEXT *pFetchContext); - -FF_ERROR FF_InitEntryFetch (FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster, FF_FETCH_CONTEXT *pContext); -FF_ERROR FF_FetchEntryWithContext (FF_IOMAN *pIoman, FF_T_UINT32 ulEntry, FF_FETCH_CONTEXT *pContext, FF_T_UINT8 *pEntryBuffer); -FF_ERROR FF_PushEntryWithContext (FF_IOMAN *pIoman, FF_T_UINT32 ulEntry, FF_FETCH_CONTEXT *pContext, FF_T_UINT8 *pEntryBuffer); -void FF_CleanupEntryFetch (FF_IOMAN *pIoman, FF_FETCH_CONTEXT *pContext); - -FF_T_SINT8 FF_PushEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer, void *pParam); -FF_T_BOOL FF_isEndOfDir (FF_T_UINT8 *EntryBuffer); -FF_ERROR FF_FindNextInDir (FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_FETCH_CONTEXT *pFetchContext); - -#ifdef FF_UNICODE_SUPPORT -FF_T_UINT32 FF_FindEntryInDir (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, const FF_T_WCHAR *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent, FF_ERROR *pError); -FF_T_SINT8 FF_CreateShortName (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_WCHAR *ShortName, FF_T_WCHAR *LongName); -#else -FF_T_UINT32 FF_FindEntryInDir (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, const FF_T_INT8 *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent, FF_ERROR *pError); -FF_T_SINT8 FF_CreateShortName (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *ShortName, FF_T_INT8 *LongName); -#endif - - -void FF_lockDIR (FF_IOMAN *pIoman); -void FF_unlockDIR (FF_IOMAN *pIoman); - -#ifdef FF_UNICODE_SUPPORT -FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_WCHAR *FileName, FF_DIRENT *pDirent, FF_ERROR *pError); -#else -FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *FileName, FF_DIRENT *pDirent, FF_ERROR *pError); -#endif - -FF_ERROR FF_CreateDirent (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent); -FF_ERROR FF_ExtendDirectory (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster); - -#ifdef FF_UNICODE_SUPPORT -FF_T_UINT32 FF_FindDir (FF_IOMAN *pIoman, const FF_T_WCHAR *path, FF_T_UINT16 pathLen, FF_ERROR *pError); -#else -FF_T_UINT32 FF_FindDir (FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 pathLen, FF_ERROR *pError); -#endif - -#ifdef FF_HASH_CACHE -FF_T_BOOL FF_CheckDirentHash (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash); -FF_T_BOOL FF_DirHashed (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster); -FF_ERROR FF_AddDirentHash (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash); -FF_ERROR FF_HashDir (FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster); -#endif - -FF_ERROR FF_RmLFNs(FF_IOMAN *pIoman, FF_T_UINT16 usDirEntry, FF_FETCH_CONTEXT *pContext); - -#endif - diff --git a/reactos/lib/3rdparty/fullfat/fullfat.rbuild b/reactos/lib/3rdparty/fullfat/fullfat.rbuild index 754502d6d57..4e18e3b3c18 100644 --- a/reactos/lib/3rdparty/fullfat/fullfat.rbuild +++ b/reactos/lib/3rdparty/fullfat/fullfat.rbuild @@ -1,6 +1,6 @@ - + include/reactos/libs/fullfat From 901b5f0d914046aba2b862044fc3673e09e07fb7 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sat, 2 Apr 2011 18:32:04 +0000 Subject: [PATCH 59/66] [NDK] - Add RTL_PERTHREAD_CURDIR structure definition. - Fix RTL_DRIVE_LETTER_CURDIR type vs. structure definition typo (adding more underscores is a truly universal fix!). svn path=/trunk/; revision=51235 --- reactos/include/ndk/rtltypes.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/reactos/include/ndk/rtltypes.h b/reactos/include/ndk/rtltypes.h index c211ccada3c..3b932372ca9 100644 --- a/reactos/include/ndk/rtltypes.h +++ b/reactos/include/ndk/rtltypes.h @@ -1012,7 +1012,7 @@ typedef struct _CURDIR HANDLE Handle; } CURDIR, *PCURDIR; -typedef struct RTL_DRIVE_LETTER_CURDIR +typedef struct _RTL_DRIVE_LETTER_CURDIR { USHORT Flags; USHORT Length; @@ -1020,6 +1020,13 @@ typedef struct RTL_DRIVE_LETTER_CURDIR UNICODE_STRING DosPath; } RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR; +typedef struct _RTL_PERTHREAD_CURDIR +{ + PRTL_DRIVE_LETTER_CURDIR CurrentDirectories; + PUNICODE_STRING ImageName; + PVOID Environment; +} RTL_PERTHREAD_CURDIR, *PRTL_PERTHREAD_CURDIR; + // // Private State structure for RtlAcquirePrivilege/RtlReleasePrivilege // From f6c92d8d84d727926a448a4f8f49ccc26887e46a Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Sat, 2 Apr 2011 18:51:41 +0000 Subject: [PATCH 60/66] [FULLFAT] - Map the memory functions onto kernel APIs svn path=/trunk/; revision=51236 --- reactos/include/reactos/libs/fullfat/ff_config.h | 4 ++-- reactos/include/reactos/libs/fullfat/ff_memory.h | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/reactos/include/reactos/libs/fullfat/ff_config.h b/reactos/include/reactos/libs/fullfat/ff_config.h index d8de409f1c6..09383e336af 100644 --- a/reactos/include/reactos/libs/fullfat/ff_config.h +++ b/reactos/include/reactos/libs/fullfat/ff_config.h @@ -121,8 +121,8 @@ //---------- MALLOC // These should map on to platform specific memory allocators. -#define FF_MALLOC(aSize) malloc(aSize) -#define FF_FREE(apPtr) free(apPtr) +#define FF_MALLOC(aSize) FF_Malloc(aSize) +#define FF_FREE(apPtr) FF_Free(apPtr) //---------- IN-LINE FUNCTIONS diff --git a/reactos/include/reactos/libs/fullfat/ff_memory.h b/reactos/include/reactos/libs/fullfat/ff_memory.h index 03ae55a77a3..5064c2776d2 100644 --- a/reactos/include/reactos/libs/fullfat/ff_memory.h +++ b/reactos/include/reactos/libs/fullfat/ff_memory.h @@ -41,6 +41,12 @@ #include "ff_config.h" #include "ff_types.h" +#ifdef __REACTOS__ +// defined in fullfat.c +void *FF_Malloc(FF_T_UINT32 allocSize); +void FF_Free(void *pBuffer); +#endif + /* HT changed type of aOffset to u32 */ From 6f4a96d594e03e84ee8bd7a1fd1161e03066a821 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sun, 3 Apr 2011 02:14:14 +0000 Subject: [PATCH 61/66] [Win32k] - Fix the return checks for co_MsqWaitForNewMessages, now the wait_idle test no longer randomly crash, also tested the testkbd check from bug 3212. Setup co_MsqWaitForNewMessages to act like get message, checking QS bits and dispatching send messages if queued. - Added desktop hit test data point, now the new track mouse timer code works. Not yet committed. svn path=/trunk/; revision=51237 --- .../subsystems/win32/win32k/ntuser/message.c | 8 ++++++- .../subsystems/win32/win32k/ntuser/msgqueue.c | 21 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index b66f31db35d..53e2b432a4f 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -857,6 +857,10 @@ co_IntWaitMessage( PWND Window, return FALSE; } + if (Status == STATUS_USER_APC || Status == STATUS_TIMEOUT) + { + return FALSE; + } } while ( TRUE ); @@ -946,7 +950,9 @@ co_IntGetPeekMessage( PMSG pMsg, Window, MsgFilterMin, MsgFilterMax); - if ( !NT_SUCCESS(Status) ) + if ( !NT_SUCCESS(Status) || + Status == STATUS_USER_APC || + Status == STATUS_TIMEOUT ) { Present = -1; break; diff --git a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c index 9f0706706af..db8ca7c97b8 100644 --- a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c +++ b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c @@ -193,6 +193,7 @@ co_MsqInsertMouseMessage(MSG* Msg) { LARGE_INTEGER LargeTickCount; MSLLHOOKSTRUCT MouseHookData; + PDESKTOP pDesk; PWND pwnd, pwndDesktop; KeQueryTickCount(&LargeTickCount); @@ -254,6 +255,9 @@ co_MsqInsertMouseMessage(MSG* Msg) IntPtInWindow(pwnd, Msg->pt.x, Msg->pt.y)) { Msg->hwnd = pwnd->head.h; + pDesk = pwnd->head.rpdesk; + pDesk->htEx = HTCLIENT; + pDesk->spwndTrack = pwnd; break; } } @@ -1031,8 +1035,6 @@ BOOL co_IntProcessMouseMessage(MSG* msg, BOOL* RemoveMessages, UINT first, UINT /* message is accepted now (but may still get dropped) */ - pti->rpdesk->htEx = hittest; /* Now set the capture hit. */ - event.message = msg->message; event.time = msg->time; event.hwnd = msg->hwnd; @@ -1351,8 +1353,20 @@ NTSTATUS FASTCALL co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, PWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax) { - NTSTATUS ret; + PTHREADINFO pti; + NTSTATUS ret = STATUS_SUCCESS; + + pti = MessageQueue->Thread->Tcb.Win32Thread; + while ( co_MsqDispatchOneSentMessage(MessageQueue) ); + + if (pti->pcti->fsWakeBits & pti->pcti->fsChangeBits ) + { + return ret; + } + + pti->pClientInfo->cSpins = 0; + IdlePing(); UserLeaveCo(); ret = KeWaitForSingleObject(MessageQueue->NewMessages, Executive, @@ -1360,6 +1374,7 @@ co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, PWND WndFilter, FALSE, NULL); UserEnterCo(); + IdlePong(); return ret; } From 629be1865d28398e1f980efa827e48d2650965af Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sun, 3 Apr 2011 09:42:08 +0000 Subject: [PATCH 62/66] [KERNEL32] - Rewrite large part of ldr.c code, including FreeLibrary, FreeLibraryAndExitThread, GetModuleFileNameA/W, GetModuleHandleA/W, ExA/W. Now they properly validate parameters, common code for getting module handles is factored into a standalone function which is reused for all 4 APIs instead of duplicating almost the same code four times. GetModuleFileNameA became a typical A->W wrapper around GetModuleFileNameW so duplication is also removed there. - Getting module handle also became a correct implementation because now it takes process's dll path into account instead of always assuming a "default" one (which is incompatible with a new ntdll loader). - Fixed a typo in BasepGetProcessPath which led to incorrect value being returned. Downgrade two debugprints. svn path=/trunk/; revision=51238 --- reactos/dll/win32/kernel32/misc/ldr.c | 634 ++++++++++++------- reactos/dll/win32/kernel32/process/procsup.c | 6 +- 2 files changed, 406 insertions(+), 234 deletions(-) diff --git a/reactos/dll/win32/kernel32/misc/ldr.c b/reactos/dll/win32/kernel32/misc/ldr.c index decc300fbab..50fdcc31049 100644 --- a/reactos/dll/win32/kernel32/misc/ldr.c +++ b/reactos/dll/win32/kernel32/misc/ldr.c @@ -1,10 +1,10 @@ -/* $Id$ - * +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT : ReactOS user mode libraries * MODULE : kernel32.dll - * FILE : reactos/lib/kernel32/misc/ldr.c - * AUTHOR : Ariadne + * FILE : reactos/dll/win32/kernel32/misc/ldr.c + * AUTHOR : Aleksey Bragin + * Ariadne */ #include @@ -22,8 +22,53 @@ typedef struct tagLOADPARMS32 { extern BOOLEAN InWindows; extern WaitForInputIdleType lpfnGlobalRegisterWaitForInputIdle; +#define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_FAIL 1 +#define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_SUCCESS 2 +#define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_CONTINUE 3 + /* FUNCTIONS ****************************************************************/ +DWORD +WINAPI +BasepGetModuleHandleExParameterValidation(DWORD dwFlags, + LPCWSTR lpwModuleName, + HMODULE *phModule) +{ + /* Set phModule to 0 if it's not a NULL pointer */ + if (phModule) *phModule = 0; + + /* Check for invalid flags combination */ + if (dwFlags & ~(GET_MODULE_HANDLE_EX_FLAG_PIN | + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT | + GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS) || + (dwFlags & GET_MODULE_HANDLE_EX_FLAG_PIN && + dwFlags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT) || + (!lpwModuleName && (dwFlags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS)) + ) + { + BaseSetLastNTError(STATUS_INVALID_PARAMETER_1); + return BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_FAIL; + } + + /* Check 2nd parameter */ + if (!phModule) + { + BaseSetLastNTError(STATUS_INVALID_PARAMETER_2); + return BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_FAIL; + } + + /* Return what we have according to the module name */ + if (lpwModuleName) + { + return BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_CONTINUE; + } + + /* No name given, so put ImageBaseAddress there */ + *phModule = (HMODULE)NtCurrentPeb()->ImageBaseAddress; + + return BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_SUCCESS; +} + /** * @name GetDllLoadPath * @@ -220,7 +265,7 @@ LoadLibraryExW ( HINSTANCE hInst; NTSTATUS Status; PWSTR SearchPath; - ULONG DllCharacteristics; + ULONG DllCharacteristics = 0; BOOL FreeString = FALSE; (void)hFile; @@ -350,26 +395,37 @@ BOOL WINAPI FreeLibrary(HINSTANCE hLibModule) { NTSTATUS Status; - if (!hLibModule) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - if ((ULONG_PTR)hLibModule & 1) { - /* this is a LOAD_LIBRARY_AS_DATAFILE module */ - char *ptr = (char *)hLibModule - 1; - return UnmapViewOfFile(ptr); + /* This is a LOAD_LIBRARY_AS_DATAFILE module */ + if (RtlImageNtHeader((PVOID)((ULONG_PTR)hLibModule & ~1))) + { + /* Unmap view */ + Status = NtUnmapViewOfSection(NtCurrentProcess(), (PVOID)((ULONG_PTR)hLibModule & ~1)); + + /* Unload alternate resource module */ + LdrUnloadAlternateResourceModule(hLibModule); + } + else + Status = STATUS_INVALID_IMAGE_FORMAT; + } + else + { + /* Just unload it */ + Status = LdrUnloadDll((PVOID)hLibModule); } - Status = LdrUnloadDll(hLibModule); + /* Check what kind of status we got */ if (!NT_SUCCESS(Status)) { - SetLastErrorByStatus(Status); + /* Set last error */ + BaseSetLastNTError(Status); + + /* Return failure */ return FALSE; } + /* Return success */ return TRUE; } @@ -379,12 +435,30 @@ BOOL WINAPI FreeLibrary(HINSTANCE hLibModule) */ VOID WINAPI -FreeLibraryAndExitThread ( - HMODULE hLibModule, - DWORD dwExitCode - ) +FreeLibraryAndExitThread(HMODULE hLibModule, + DWORD dwExitCode) { - FreeLibrary(hLibModule); + NTSTATUS Status; + + if ((ULONG_PTR)hLibModule & 1) + { + /* This is a LOAD_LIBRARY_AS_DATAFILE module */ + if (RtlImageNtHeader((PVOID)((ULONG_PTR)hLibModule & ~1))) + { + /* Unmap view */ + Status = NtUnmapViewOfSection(NtCurrentProcess(), (PVOID)((ULONG_PTR)hLibModule & ~1)); + + /* Unload alternate resource module */ + LdrUnloadAlternateResourceModule(hLibModule); + } + } + else + { + /* Just unload it */ + Status = LdrUnloadDll((PVOID)hLibModule); + } + + /* Exit thread */ ExitThread(dwExitCode); } @@ -394,123 +468,287 @@ FreeLibraryAndExitThread ( */ DWORD WINAPI -GetModuleFileNameA ( - HINSTANCE hModule, - LPSTR lpFilename, - DWORD nSize - ) +GetModuleFileNameA(HINSTANCE hModule, + LPSTR lpFilename, + DWORD nSize) { - ANSI_STRING FileName; - PLIST_ENTRY ModuleListHead; - PLIST_ENTRY Entry; - PLDR_DATA_TABLE_ENTRY Module; - PPEB Peb; - ULONG Length = 0; + UNICODE_STRING filenameW; + ANSI_STRING FilenameA; + NTSTATUS Status; + DWORD Length = 0; - Peb = NtCurrentPeb (); - RtlEnterCriticalSection (Peb->LoaderLock); + /* Allocate a unicode buffer */ + filenameW.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, nSize * sizeof(WCHAR)); + if (!filenameW.Buffer) + { + BaseSetLastNTError(STATUS_NO_MEMORY); + return 0; + } - if (hModule == NULL) - hModule = Peb->ImageBaseAddress; + /* Call unicode API */ + filenameW.Length = GetModuleFileNameW(hModule, filenameW.Buffer, nSize) * sizeof(WCHAR); + filenameW.MaximumLength = filenameW.Length + sizeof(WCHAR); - ModuleListHead = &Peb->Ldr->InLoadOrderModuleList; - Entry = ModuleListHead->Flink; + if (filenameW.Length) + { + /* Convert to ansi string */ + Status = BasepUnicodeStringTo8BitString(&FilenameA, &filenameW, TRUE); + if (!NT_SUCCESS(Status)) + { + /* Set last error, free string and retun failure */ + BaseSetLastNTError(Status); + RtlFreeUnicodeString(&filenameW); + return 0; + } - while (Entry != ModuleListHead) - { - Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - if (Module->DllBase == (PVOID)hModule) - { - Length = min(nSize, Module->FullDllName.Length / sizeof(WCHAR)); - FileName.Length = 0; - FileName.MaximumLength = (USHORT)Length * sizeof(WCHAR); - FileName.Buffer = lpFilename; + /* Calculate size to copy */ + Length = min(nSize, FilenameA.Length); - /* convert unicode string to ansi (or oem) */ - if (bIsFileApiAnsi) - RtlUnicodeStringToAnsiString (&FileName, - &Module->FullDllName, - FALSE); - else - RtlUnicodeStringToOemString (&FileName, - &Module->FullDllName, - FALSE); - - if (Length < nSize) - lpFilename[Length] = '\0'; - else - SetLastErrorByStatus (STATUS_BUFFER_TOO_SMALL); + /* Remove terminating zero */ + if (Length == FilenameA.Length) + Length--; - RtlLeaveCriticalSection (Peb->LoaderLock); - return Length; - } + /* Now copy back to the caller amount he asked */ + RtlMoveMemory(lpFilename, FilenameA.Buffer, Length); - Entry = Entry->Flink; - } + /* Free ansi filename */ + RtlFreeAnsiString(&FilenameA); + } - SetLastErrorByStatus (STATUS_DLL_NOT_FOUND); - RtlLeaveCriticalSection (Peb->LoaderLock); + /* Free unicode filename */ + RtlFreeHeap(RtlGetProcessHeap(), 0, filenameW.Buffer); - return 0; + /* Return length copied */ + return Length; } - /* * @implemented */ DWORD WINAPI -GetModuleFileNameW ( - HINSTANCE hModule, - LPWSTR lpFilename, - DWORD nSize - ) +GetModuleFileNameW(HINSTANCE hModule, + LPWSTR lpFilename, + DWORD nSize) { - UNICODE_STRING FileName; - PLIST_ENTRY ModuleListHead; - PLIST_ENTRY Entry; - PLDR_DATA_TABLE_ENTRY Module; - PPEB Peb; - ULONG Length = 0; + PLIST_ENTRY ModuleListHead, Entry; + PLDR_DATA_TABLE_ENTRY Module; + ULONG Length = 0; + ULONG Cookie; + PPEB Peb; - Peb = NtCurrentPeb (); - RtlEnterCriticalSection (Peb->LoaderLock); + /* Upscale nSize from chars to bytes */ + nSize *= sizeof(WCHAR); - if (hModule == NULL) - hModule = Peb->ImageBaseAddress; + _SEH2_TRY + { + /* We don't use per-thread cur dir now */ + //PRTL_PERTHREAD_CURDIR PerThreadCurdir = (PRTL_PERTHREAD_CURDIR)teb->NtTib.SubSystemTib; - ModuleListHead = &Peb->Ldr->InLoadOrderModuleList; - Entry = ModuleListHead->Flink; - while (Entry != ModuleListHead) - { - Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); + Peb = NtCurrentPeb (); - if (Module->DllBase == (PVOID)hModule) - { - Length = min(nSize, Module->FullDllName.Length / sizeof(WCHAR)); - FileName.Length = 0; - FileName.MaximumLength = (USHORT) Length * sizeof(WCHAR); - FileName.Buffer = lpFilename; + /* Acquire a loader lock */ + LdrLockLoaderLock(LDR_LOCK_LOADER_LOCK_FLAG_RAISE_STATUS, NULL, &Cookie); - RtlCopyUnicodeString (&FileName, - &Module->FullDllName); - if (Length < nSize) - lpFilename[Length] = L'\0'; - else - SetLastErrorByStatus (STATUS_BUFFER_TOO_SMALL); + /* Traverse the module list */ + ModuleListHead = &Peb->Ldr->InLoadOrderModuleList; + Entry = ModuleListHead->Flink; + while (Entry != ModuleListHead) + { + Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - RtlLeaveCriticalSection (Peb->LoaderLock); + /* Check if this is the requested module */ + if (Module->DllBase == (PVOID)hModule) + { + /* Calculate size to copy */ + Length = min(nSize, Module->FullDllName.MaximumLength); - return Length; - } + /* Copy contents */ + RtlMoveMemory(lpFilename, Module->FullDllName.Buffer, Length); - Entry = Entry->Flink; - } + /* Subtract a terminating zero */ + if (Length == Module->FullDllName.MaximumLength) + Length -= sizeof(WCHAR); - SetLastErrorByStatus (STATUS_DLL_NOT_FOUND); - RtlLeaveCriticalSection (Peb->LoaderLock); + /* Break out of the loop */ + break; + } - return 0; + /* Advance to the next entry */ + Entry = Entry->Flink; + } + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + BaseSetLastNTError(_SEH2_GetExceptionCode()); + Length = 0; + } _SEH2_END + + /* Release the loader lock */ + LdrUnlockLoaderLock(LDR_LOCK_LOADER_LOCK_FLAG_RAISE_STATUS, Cookie); + + return Length; +} + +HMODULE +WINAPI +GetModuleHandleForUnicodeString(PUNICODE_STRING ModuleName) +{ + NTSTATUS Status; + PVOID Module; + LPWSTR DllPath; + + /* Try to get a handle with a magic value of 1 for DllPath */ + Status = LdrGetDllHandle((LPWSTR)1, NULL, ModuleName, &Module); + + /* If that succeeded - we're done */ + if (NT_SUCCESS(Status)) return Module; + + /* If not, then the path should be computed */ + DllPath = BasepGetDllPath(NULL, 0); + + /* Call LdrGetHandle() again providing the computed DllPath + and wrapped into SEH */ + _SEH2_TRY + { + Status = LdrGetDllHandle(DllPath, NULL, ModuleName, &Module); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + /* Fail with the SEH error */ + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; + + /* Free the DllPath */ + RtlFreeHeap(RtlGetProcessHeap(), 0, DllPath); + + /* In case of error set last win32 error and return NULL */ + if (!NT_SUCCESS(Status)) + { + DPRINT("Failure acquiring DLL module '%wZ' handle, Status 0x%08X\n", ModuleName, Status); + SetLastErrorByStatus(Status); + Module = 0; + } + + /* Return module */ + return (HMODULE)Module; +} + +BOOLEAN +WINAPI +BasepGetModuleHandleExW(BOOLEAN NoLock, DWORD dwPublicFlags, LPCWSTR lpwModuleName, HMODULE *phModule) +{ + DWORD Cookie; + NTSTATUS Status = STATUS_SUCCESS, Status2; + HANDLE hModule = 0; + UNICODE_STRING ModuleNameU; + DWORD dwValid; + BOOLEAN Redirected = FALSE; // FIXME + + /* Validate parameters */ + dwValid = BasepGetModuleHandleExParameterValidation(dwPublicFlags, lpwModuleName, phModule); + ASSERT(dwValid == BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_CONTINUE); + + /* Acquire lock if necessary */ + if (!NoLock) + { + Status = LdrLockLoaderLock(0, NULL, &Cookie); + if (!NT_SUCCESS(Status)) + { + /* Fail */ + SetLastErrorByStatus(Status); + if (phModule) *phModule = 0; + return Status; + } + } + + if (!(dwPublicFlags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS)) + { + /* Create a unicode string out of module name */ + RtlInitUnicodeString(&ModuleNameU, lpwModuleName); + + // FIXME: Do some redirected DLL stuff? + if (Redirected) + { + UNIMPLEMENTED; + } + + if (!hModule) + { + hModule = GetModuleHandleForUnicodeString(&ModuleNameU); + if (!hModule) + { + // FIXME: Status?! + goto quickie; + } + } + } + else + { + /* Perform Pc to file header to get module instance */ + hModule = (HMODULE)RtlPcToFileHeader((PVOID)lpwModuleName, + (PVOID*)&hModule); + + /* Check if it succeeded */ + if (!hModule) + { + /* Set "dll not found" status and quit */ + Status = STATUS_DLL_NOT_FOUND; + goto quickie; + } + } + + /* Check if changing reference is not forbidden */ + if (!(dwPublicFlags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT)) + { + /* Add reference to this DLL */ + Status = LdrAddRefDll((dwPublicFlags & GET_MODULE_HANDLE_EX_FLAG_PIN) ? LDR_PIN_MODULE : 0, + hModule); + } + +quickie: + /* Unlock loader lock if it was acquired */ + if (!NoLock) + { + Status2 = LdrUnlockLoaderLock(0, Cookie); + ASSERT(NT_SUCCESS(Status2)); + } + + /* Set last error in case of failure */ + if (!NT_SUCCESS(Status)) + SetLastErrorByStatus(Status); + + /* Set the module handle to the caller */ + if (phModule) *phModule = hModule; + + /* Return TRUE on success and FALSE otherwise */ + return NT_SUCCESS(Status); +} + +/* + * @implemented + */ +HMODULE +WINAPI +GetModuleHandleA(LPCSTR lpModuleName) +{ + PUNICODE_STRING ModuleNameW; + PTEB pTeb = NtCurrentTeb(); + + /* Check if we have no name to convert */ + if (!lpModuleName) + return ((HMODULE)pTeb->ProcessEnvironmentBlock->ImageBaseAddress); + + /* Convert module name to unicode */ + ModuleNameW = Basep8BitStringToStaticUnicodeString(lpModuleName); + + /* Call W version if conversion was successful */ + if (ModuleNameW) + return GetModuleHandleW(ModuleNameW->Buffer); + + /* Return failure */ + return 0; } @@ -519,61 +757,26 @@ GetModuleFileNameW ( */ HMODULE WINAPI -GetModuleHandleA ( LPCSTR lpModuleName ) +GetModuleHandleW(LPCWSTR lpModuleName) { - ANSI_STRING ModuleName; - NTSTATUS Status; - PTEB pTeb = NtCurrentTeb(); + HMODULE hModule; + NTSTATUS Status; - if (lpModuleName == NULL) - { - return ((HMODULE)pTeb->ProcessEnvironmentBlock->ImageBaseAddress); - } + /* If current module is requested - return it right away */ + if (!lpModuleName) + return ((HMODULE)NtCurrentPeb()->ImageBaseAddress); - RtlInitAnsiString(&ModuleName, lpModuleName); + /* Use common helper routine */ + Status = BasepGetModuleHandleExW(TRUE, + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + lpModuleName, + &hModule); - Status = RtlAnsiStringToUnicodeString(&pTeb->StaticUnicodeString, - &ModuleName, - FALSE); + /* If it wasn't successful - return 0 */ + if (!NT_SUCCESS(Status)) hModule = 0; - if (NT_SUCCESS(Status)) - { - return GetModuleHandleW(pTeb->StaticUnicodeString.Buffer); - } - - SetLastErrorByStatus(Status); - return FALSE; -} - - -/* - * @implemented - */ -HMODULE -WINAPI -GetModuleHandleW (LPCWSTR lpModuleName) -{ - UNICODE_STRING ModuleName; - PVOID BaseAddress; - NTSTATUS Status; - - if (lpModuleName == NULL) - return ((HMODULE)NtCurrentPeb()->ImageBaseAddress); - - RtlInitUnicodeString (&ModuleName, - (LPWSTR)lpModuleName); - - Status = LdrGetDllHandle (0, - 0, - &ModuleName, - &BaseAddress); - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus (Status); - return NULL; - } - - return ((HMODULE)BaseAddress); + /* Return the handle */ + return hModule; } @@ -583,64 +786,31 @@ GetModuleHandleW (LPCWSTR lpModuleName) BOOL WINAPI GetModuleHandleExW(IN DWORD dwFlags, - IN LPCWSTR lpModuleName OPTIONAL, + IN LPCWSTR lpwModuleName OPTIONAL, OUT HMODULE* phModule) { - HMODULE hModule; NTSTATUS Status; + DWORD dwValid; BOOL Ret = FALSE; - if (phModule == NULL || - ((dwFlags & (GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT)) == - (GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT))) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } + /* Validate parameters */ + dwValid = BasepGetModuleHandleExParameterValidation(dwFlags, lpwModuleName, phModule); - if (lpModuleName == NULL) - { - hModule = NtCurrentPeb()->ImageBaseAddress; - } - else - { - if (dwFlags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS) - { - hModule = (HMODULE)RtlPcToFileHeader((PVOID)lpModuleName, - (PVOID*)&hModule); - if (hModule == NULL) - { - SetLastErrorByStatus(STATUS_DLL_NOT_FOUND); - } - } - else - { - hModule = GetModuleHandleW(lpModuleName); - } - } + /* If result is invalid parameter - return failure */ + if (dwValid == BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_FAIL) return FALSE; - if (hModule != NULL) - { - if (!(dwFlags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT)) - { - Status = LdrAddRefDll((dwFlags & GET_MODULE_HANDLE_EX_FLAG_PIN) ? LDR_PIN_MODULE : 0, - hModule); + /* If result is 2, there is no need to do anything - return success. */ + if (dwValid == BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_SUCCESS) return TRUE; - if (NT_SUCCESS(Status)) - { - Ret = TRUE; - } - else - { - SetLastErrorByStatus(Status); - hModule = NULL; - } - } - else - Ret = TRUE; - } + /* Use common helper routine */ + Status = BasepGetModuleHandleExW(FALSE, + dwFlags, + lpwModuleName, + phModule); + + /* Return TRUE in case of success */ + if (NT_SUCCESS(Status)) Ret = TRUE; - *phModule = hModule; return Ret; } @@ -650,41 +820,45 @@ GetModuleHandleExW(IN DWORD dwFlags, BOOL WINAPI GetModuleHandleExA(IN DWORD dwFlags, - IN LPCSTR lpModuleName OPTIONAL, + IN LPCSTR lpModuleName OPTIONAL, OUT HMODULE* phModule) { - ANSI_STRING ModuleName; - LPCWSTR lpModuleNameW; - NTSTATUS Status; + PUNICODE_STRING lpModuleNameW; + DWORD dwValid; BOOL Ret; - PTEB pTeb = NtCurrentTeb(); + /* Validate parameters */ + dwValid = BasepGetModuleHandleExParameterValidation(dwFlags, (LPCWSTR)lpModuleName, phModule); + /* If result is invalid parameter - return failure */ + if (dwValid == BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_FAIL) return FALSE; + + /* If result is 2, there is no need to do anything - return success. */ + if (dwValid == BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_SUCCESS) return TRUE; + + /* Check if we don't need to convert the name */ if (dwFlags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS) { - lpModuleNameW = (LPCWSTR)lpModuleName; + /* Call the W version of the API without conversion */ + Ret = GetModuleHandleExW(dwFlags, + (LPCWSTR)lpModuleName, + phModule); } else { - RtlInitAnsiString(&ModuleName, lpModuleName); + /* Convert module name to unicode */ + lpModuleNameW = Basep8BitStringToStaticUnicodeString(lpModuleName); - Status = RtlAnsiStringToUnicodeString(&pTeb->StaticUnicodeString, - &ModuleName, - FALSE); + /* Return FALSE if conversion failed */ + if (!lpModuleNameW) return FALSE; - if (!NT_SUCCESS(Status)) - { - SetLastErrorByStatus(Status); - return FALSE; - } - - lpModuleNameW = pTeb->StaticUnicodeString.Buffer; + /* Call the W version of the API */ + Ret = GetModuleHandleExW(dwFlags, + lpModuleNameW->Buffer, + phModule); } - Ret = GetModuleHandleExW(dwFlags, - lpModuleNameW, - phModule); - + /* Return result */ return Ret; } diff --git a/reactos/dll/win32/kernel32/process/procsup.c b/reactos/dll/win32/kernel32/process/procsup.c index 95f415b9a04..39f700714d3 100644 --- a/reactos/dll/win32/kernel32/process/procsup.c +++ b/reactos/dll/win32/kernel32/process/procsup.c @@ -452,7 +452,7 @@ secondattempt: if (!BasepExeLdrEntry) LdrEnumerateLoadedModules(0, BasepLocateExeLdrEntry, Peb->ImageBaseAddress); - DPRINT1("Found BasepExeLdrEntry %wZ\n", &BasepExeLdrEntry->FullDllName); + DPRINT("Found BasepExeLdrEntry %wZ\n", &BasepExeLdrEntry->FullDllName); /* Set name pointer to the full dll path */ NamePtr = BasepExeLdrEntry->FullDllName.Buffer; @@ -542,9 +542,7 @@ secondattempt: /* Null terminate the string */ NamePtr[DefaultLength / sizeof(WCHAR)] = 0; - DPRINT("Path: %S\n", NamePtr); - - return NULL; + return PathBuffer; } LPWSTR From f66194544b40541bf3a8028dc095cb20672babd7 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sun, 3 Apr 2011 12:22:00 +0000 Subject: [PATCH 63/66] [Win32k] - Fix DDE test crash. it's a band-aide. - Fix the last two post quite message test, all pass now. svn path=/trunk/; revision=51239 --- .../subsystems/win32/win32k/ntuser/message.c | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 53e2b432a4f..e13b30352a3 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -320,6 +320,7 @@ PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Non { PMSGMEMORY MsgMemoryEntry; PVOID PackedData; + SIZE_T size; MsgMemoryEntry = FindMsgMemory(Msg); @@ -328,7 +329,13 @@ PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Non /* Keep previous behavior */ return STATUS_SUCCESS; } - PackedData = ExAllocatePoolWithTag(NonPagedPool, MsgMemorySize(MsgMemoryEntry, wParam, lParam), TAG_MSG); + size = MsgMemorySize(MsgMemoryEntry, wParam, lParam); + if (!size) + { + DPRINT1("No size for lParamPacked\n"); + return STATUS_SUCCESS; + } + PackedData = ExAllocatePoolWithTag(NonPagedPool, size, TAG_MSG); RtlCopyMemory(PackedData, (PVOID)lParam, MsgMemorySize(MsgMemoryEntry, wParam, lParam)); *lParamPacked = (LPARAM)PackedData; } @@ -937,11 +944,7 @@ co_IntGetPeekMessage( PMSG pMsg, co_HOOK_CallHooks( WH_GETMESSAGE, HC_ACTION, RemoveMsg & PM_REMOVE, (LPARAM)pMsg); - if ( bGMSG ) - { - Present = (WM_QUIT != pMsg->message); - break; - } + if ( bGMSG ) break; } if ( bGMSG ) @@ -1044,7 +1047,6 @@ UserPostMessage( HWND Wnd, PTHREADINFO pti; MSG Message, KernelModeMsg; LARGE_INTEGER LargeTickCount; - PMSGMEMORY MsgMemoryEntry; Message.hwnd = Wnd; Message.message = Msg; @@ -1054,11 +1056,18 @@ UserPostMessage( HWND Wnd, KeQueryTickCount(&LargeTickCount); Message.time = MsqCalculateMessageTime(&LargeTickCount); - MsgMemoryEntry = FindMsgMemory(Message.message); + if (is_pointer_message(Message.message)) + { + EngSetLastError(ERROR_MESSAGE_SYNC_ONLY ); + return FALSE; + } if( Msg >= WM_DDE_FIRST && Msg <= WM_DDE_LAST ) { NTSTATUS Status; + PMSGMEMORY MsgMemoryEntry; + + MsgMemoryEntry = FindMsgMemory(Message.message); Status = CopyMsgToKernelMem(&KernelModeMsg, &Message, MsgMemoryEntry); if (! NT_SUCCESS(Status)) @@ -1077,12 +1086,6 @@ UserPostMessage( HWND Wnd, return TRUE; } - if (is_pointer_message(Message.message)) - { - EngSetLastError(ERROR_MESSAGE_SYNC_ONLY ); - return FALSE; - } - if (!Wnd) { return UserPostThreadMessage( PtrToInt(PsGetCurrentThreadId()), @@ -1276,8 +1279,8 @@ co_IntSendMessageTimeoutSingle( HWND hWnd, if (STATUS_TIMEOUT == Status) { - /* -MSDN says: +/* + MSDN says: Microsoft Windows 2000: If GetLastError returns zero, then the function timed out. XP+ : If the function fails or times out, the return value is zero. @@ -1873,7 +1876,7 @@ NtUserGetMessage(PMSG pMsg, _SEH2_END; } - return Ret; + return Ret ? (WM_QUIT != pMsg->message) : FALSE; } BOOL APIENTRY From 8907f384ebaeaf223713a6fe896be6007f63481c Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 3 Apr 2011 14:51:18 +0000 Subject: [PATCH 64/66] [LSASRV] Fix typos in lsa.idl (LsarLookupNames2, LsarLookupNames3 and LsarLookupNames4) and fix resulting errors in lsasrv.dll. svn path=/trunk/; revision=51240 --- reactos/dll/win32/lsasrv/lsarpc.c | 6 +++--- reactos/include/reactos/idl/lsa.idl | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/reactos/dll/win32/lsasrv/lsarpc.c b/reactos/dll/win32/lsasrv/lsarpc.c index 9055bf608e0..7887a7d5abf 100644 --- a/reactos/dll/win32/lsasrv/lsarpc.c +++ b/reactos/dll/win32/lsasrv/lsarpc.c @@ -1185,7 +1185,7 @@ NTSTATUS WINAPI LsarLookupNames2( DWORD Count, PRPC_UNICODE_STRING Names, PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains, - PLSAPR_TRANSLATED_SID_EX TranslatedSids, + PLSAPR_TRANSLATED_SIDS_EX TranslatedSids, LSAP_LOOKUP_LEVEL LookupLevel, DWORD *MappedCount, DWORD LookupOptions, @@ -1287,7 +1287,7 @@ NTSTATUS WINAPI LsarLookupNames3( DWORD Count, PRPC_UNICODE_STRING Names, PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains, - PLSAPR_TRANSLATED_SID_EX2 TranslatedSids, + PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids, LSAP_LOOKUP_LEVEL LookupLevel, DWORD *MappedCount, DWORD LookupOptions, @@ -1391,7 +1391,7 @@ NTSTATUS WINAPI LsarLookupNames4( DWORD Count, PRPC_UNICODE_STRING Names, PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains, - PLSAPR_TRANSLATED_SID_EX2 TranslatedSids, + PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids, LSAP_LOOKUP_LEVEL LookupLevel, DWORD *MappedCount, DWORD LookupOptions, diff --git a/reactos/include/reactos/idl/lsa.idl b/reactos/include/reactos/idl/lsa.idl index 00949cf4779..2a9aba6e8cb 100644 --- a/reactos/include/reactos/idl/lsa.idl +++ b/reactos/include/reactos/idl/lsa.idl @@ -975,7 +975,7 @@ cpp_quote("#if _WIN32_WINNT >= 0x0500") [in] DWORD Count, [in, size_is(Count)] PRPC_UNICODE_STRING Names, [out] PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains, - [in, out] PLSAPR_TRANSLATED_SID_EX TranslatedSids, + [in, out] PLSAPR_TRANSLATED_SIDS_EX TranslatedSids, [in] LSAP_LOOKUP_LEVEL LookupLevel, [in, out] DWORD *MappedCount, [in] DWORD LookupOptions, @@ -1029,7 +1029,7 @@ cpp_quote("#if _WIN32_WINNT >= 0x0501") [in] DWORD Count, [in, size_is(Count)] PRPC_UNICODE_STRING Names, [out] PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains, - [in, out] PLSAPR_TRANSLATED_SID_EX2 TranslatedSids, + [in, out] PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids, [in] LSAP_LOOKUP_LEVEL LookupLevel, [in, out] DWORD *MappedCount, [in] DWORD LookupOptions, @@ -1088,7 +1088,7 @@ cpp_quote("#if _WIN32_WINNT >= 0x0501") [in] DWORD Count, [in, size_is(Count)] PRPC_UNICODE_STRING Names, [out] PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains, - [in, out] PLSAPR_TRANSLATED_SID_EX2 TranslatedSids, + [in, out] PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids, [in] LSAP_LOOKUP_LEVEL LookupLevel, [in, out] DWORD *MappedCount, [in] DWORD LookupOptions, From 4c2b7d67a104524c877704716d41ef285a4509bf Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Sun, 3 Apr 2011 16:22:15 +0000 Subject: [PATCH 65/66] [FULLFAT] - Add the kernel APIs required by the library svn path=/trunk/; revision=51241 --- reactos/lib/3rdparty/fullfat/ff_safety.c | 107 ++++++++++++++++++----- 1 file changed, 85 insertions(+), 22 deletions(-) diff --git a/reactos/lib/3rdparty/fullfat/ff_safety.c b/reactos/lib/3rdparty/fullfat/ff_safety.c index 9659f5a57eb..685185c07b8 100644 --- a/reactos/lib/3rdparty/fullfat/ff_safety.c +++ b/reactos/lib/3rdparty/fullfat/ff_safety.c @@ -55,50 +55,113 @@ **/ #include "ff_safety.h" // ncludes ff_types.h +#include +#define TAG_FULLFAT 'FLUF' + +// Call your OS's CreateSemaphore function +// void *FF_CreateSemaphore(void) { - // Call your OS's CreateSemaphore function - // + PKSEMAPHORE ProcessSemaphore; - // return pointer to semaphore - return NULL; // Comment this out for your implementation. + /* Allocate some memory to store the semaphore */ + ProcessSemaphore = ExAllocatePoolWithTag(NonPagedPool, + sizeof(KSEMAPHORE), + TAG_FULLFAT); + if (ProcessSemaphore) + { + /* Initialize it */ + KeInitializeSemaphore(ProcessSemaphore, + 0, + MAXLONG); + } + + return ProcessSemaphore; } +// Call your OS's PendSemaphore with the provided pSemaphore pointer. +// +// This should block indefinitely until the Semaphore +// becomes available. (No timeout!) +// If your OS doesn't do it for you, you should sleep +// this thread until the Semaphore is available. void FF_PendSemaphore(void *pSemaphore) { - // Call your OS's PendSemaphore with the provided pSemaphore pointer. - // - // This should block indefinitely until the Semaphore - // becomes available. (No timeout!) - // If your OS doesn't do it for you, you should sleep - // this thread until the Semaphore is available. - pSemaphore = 0; + NTSTATUS Status; + + /* Sanity check */ + if (pSemaphore) + { + /* Wait for the sempaphore to become signaled */ + Status = KeWaitForSingleObject(pSemaphore, + Executive, + KernelMode, + FALSE, + NULL); + if (NT_SUCCESS(Status)) + { + if (Status != STATUS_SUCCESS) + { + // log an error? + } + } + else + { + // log an error? + } + } } +// Call your OS's ReleaseSemaphore with the provided pSemaphore pointer. +// void FF_ReleaseSemaphore(void *pSemaphore) { - // Call your OS's ReleaseSemaphore with the provided pSemaphore pointer. - // - // - pSemaphore = 0; + /* Sanity check */ + if (pSemaphore) + { + /* Increment the semaphore */ + KeReleaseSemaphore(pSemaphore, + 0, + 1, + FALSE); + } } +// Call your OS's DestroySemaphore with the provided pSemaphore pointer. +// void FF_DestroySemaphore(void *pSemaphore) { - // Call your OS's DestroySemaphore with the provided pSemaphore pointer. - // - // - pSemaphore = 0; + /* Sanity check */ + if (pSemaphore) + { + /* Free the semaphore memory */ + ExFreePoolWithTag(pSemaphore, + TAG_FULLFAT); + } } +// FIXME: what do we do with this? void FF_Yield(void) { // Call your OS's thread Yield function. // If this doesn't work, then a deadlock will occur } +// Call your OS's thread sleep function, +// Sleep for TimeMs milliseconds void FF_Sleep(FF_T_UINT32 TimeMs) { - // Call your OS's thread sleep function, - // Sleep for TimeMs milliseconds - TimeMs = 0; + LARGE_INTEGER Interval; + NTSTATUS Status; + + /* Calculate the interval */ + Interval.QuadPart = -((LONGLONG)TimeMs * 10000); + + /* Do the wait */ + Status = KeDelayExecutionThread(KernelMode, + FALSE, + &Interval); + if (!NT_SUCCESS(Status)) + { + // log an error? + } } From 9d955773ac73d1c7053e0e19d44c77b9970fc949 Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Sun, 3 Apr 2011 20:26:57 +0000 Subject: [PATCH 66/66] [CONSOLE] Fix french resource file name. Dedicated to HeisSpiter & JanusMagnus. svn path=/trunk/; revision=51243 --- reactos/dll/cpl/console/lang/{fr-Fr.rc => fr-FR.rc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename reactos/dll/cpl/console/lang/{fr-Fr.rc => fr-FR.rc} (100%) diff --git a/reactos/dll/cpl/console/lang/fr-Fr.rc b/reactos/dll/cpl/console/lang/fr-FR.rc similarity index 100% rename from reactos/dll/cpl/console/lang/fr-Fr.rc rename to reactos/dll/cpl/console/lang/fr-FR.rc