2007-12-23 20:29:52 +00:00
|
|
|
/*
|
|
|
|
* ReactOS kernel
|
|
|
|
* Copyright (C) 2008 ReactOS Team
|
|
|
|
*
|
|
|
|
* 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 2 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS text-mode setup
|
|
|
|
* FILE: subsys/system/usetup/mui.c
|
|
|
|
* PURPOSE: Text-mode setup
|
2008-02-08 04:14:09 +00:00
|
|
|
* PROGRAMMER:
|
2007-12-23 20:29:52 +00:00
|
|
|
*/
|
|
|
|
|
2007-12-12 00:05:00 +00:00
|
|
|
#include "usetup.h"
|
2008-03-19 04:43:40 +00:00
|
|
|
#include "interface/consup.h"
|
2007-12-15 14:24:02 +00:00
|
|
|
#include "errorcode.h"
|
2007-12-12 00:05:00 +00:00
|
|
|
#include "mui.h"
|
|
|
|
|
2008-01-07 14:51:42 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2008-01-12 10:20:26 +00:00
|
|
|
#include "lang/bg-BG.h"
|
2008-04-10 10:27:56 +00:00
|
|
|
#include "lang/cs-CZ.h"
|
2007-12-12 00:05:00 +00:00
|
|
|
#include "lang/en-US.h"
|
2007-12-15 11:25:03 +00:00
|
|
|
#include "lang/de-DE.h"
|
2007-12-19 11:37:35 +00:00
|
|
|
#include "lang/el-GR.h"
|
2007-12-15 16:52:40 +00:00
|
|
|
#include "lang/es-ES.h"
|
|
|
|
#include "lang/fr-FR.h"
|
2007-12-19 11:02:56 +00:00
|
|
|
#include "lang/it-IT.h"
|
2008-01-02 18:54:54 +00:00
|
|
|
#include "lang/pl-PL.h"
|
2007-12-15 12:48:07 +00:00
|
|
|
#include "lang/ru-RU.h"
|
2008-01-30 17:59:13 +00:00
|
|
|
#include "lang/sk-SK.h"
|
2007-12-15 16:25:42 +00:00
|
|
|
#include "lang/sv-SE.h"
|
|
|
|
#include "lang/uk-UA.h"
|
2008-01-18 15:55:02 +00:00
|
|
|
#include "lang/lt-LT.h"
|
2007-12-15 16:52:40 +00:00
|
|
|
|
2008-01-09 09:40:47 +00:00
|
|
|
static const MUI_LANGUAGE LanguageList[] =
|
2007-12-12 00:05:00 +00:00
|
|
|
{
|
2008-05-14 14:40:17 +00:00
|
|
|
/* Lang ID, DefKbdLayout, SecKbLayout, ANSI CP, OEM CP, MAC CP, Language Name, page strgs,error strings, other strings */
|
|
|
|
{L"00000409", L"00000409", NULL, L"1252", L"437", L"10000", L"English", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000041C", L"0000041C", L"00000409", L"1250", L"852", L"10029", L"Albanian", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000401", L"00000401", L"00000409", L"1256", L"720", L"10004", L"Arabic", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000042B", L"0000042B", L"00000409", L"0", L"1", L"2", L"Armenian Eastern", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000082C", L"0000082C", L"00000409", L"1251", L"866", L"10007", L"Azeri Cyrillic", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000042C", L"0000042C", L"00000409", L"1254", L"857", L"10081", L"Azeri Latin", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000423", L"00000423", L"00000409", L"1251", L"866", L"10007", L"Belarusian", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000813", L"00000813", L"00000409", L"1252", L"850", L"10000", L"Belgian (Dutch)", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000080C", L"0000080C", L"00000409", L"1252", L"850", L"10000", L"Belgian (French)", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000416", L"00010416", L"00000409", L"1252", L"850", L"10000", L"Brazilian", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000402", L"00000402", L"00000409", L"1251", L"866", L"10007", L"Bulgarian", bgBGPages, bgBGErrorEntries, bgBGStrings },
|
|
|
|
{L"00000455", L"00000455", L"00000409", L"0", L"1", L"2", L"Burmese", enUSPages, enUSErrorEntries, enUSStrings },// Unicode only
|
|
|
|
{L"00000C0C", L"00000C0C", L"00000409", L"1252", L"850", L"10000", L"Canadian (French)", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000403", L"0000040A", L"00000409", L"1252", L"850", L"10000", L"Catalan", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000804", L"00000804", L"00000409", L"936", L"936", L"10008", L"Chinese (PRC)", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000405", L"00000405", L"00000409", L"1250", L"852", L"10029", L"Czech", csCZPages, csCZErrorEntries, csCZStrings },
|
|
|
|
{L"00000406", L"00000406", L"00000409", L"1252", L"850", L"10000", L"Danish", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000407", L"00000407", L"00000409", L"1252", L"850", L"10000", L"Deutsch", deDEPages, deDEErrorEntries, deDEStrings },
|
|
|
|
{L"00000413", L"00000813", L"00000409", L"1252", L"850", L"10000", L"Dutch", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000425", L"00000425", L"00000409", L"1257", L"775", L"10029", L"Estonian", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000040B", L"0000040B", L"00000409", L"1252", L"850", L"10000", L"Finnish", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000040C", L"0000040C", L"00000409", L"1252", L"850", L"10000", L"French", frFRPages, frFRErrorEntries, frFRStrings },
|
|
|
|
{L"00000437", L"00000437", L"00000409", L"0", L"1", L"2", L"Georgian", enUSPages, enUSErrorEntries, enUSStrings },// Unicode only
|
|
|
|
{L"00000408", L"00000408", L"00000409", L"1253", L"737", L"10006", L"Greek", elGRPages, elGRErrorEntries, elGRStrings },
|
|
|
|
{L"0000040D", L"0000040D", L"00000409", L"1255", L"862", L"10005", L"Hebrew", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000040E", L"0000040E", L"00000409", L"1250", L"852", L"10029", L"Hungarian", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000040F", L"0000040F", L"00000409", L"1252", L"850", L"10079", L"Icelandic", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000410", L"00000410", L"00000409", L"1252", L"850", L"10000", L"Italian", itITPages, itITErrorEntries, itITStrings },
|
|
|
|
{L"00000411", L"00000411", L"00000409", L"932", L"932", L"10001", L"Japanese", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000043F", L"0000043F", L"00000409", L"1251", L"866", L"10007", L"Kazakh", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000412", L"00000412", L"00000409", L"949", L"949", L"10003", L"Korean", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000426", L"00000426", L"00000409", L"1257", L"775", L"10029", L"Latvian", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000427", L"00000427", L"00000409", L"1257", L"775", L"10029", L"Lithuanian", ltLTPages, ltLTErrorEntries, ltLTStrings },
|
|
|
|
{L"0000042F", L"0000042F", L"00000409", L"1251", L"866", L"10007", L"Macedonian", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000414", L"00000414", L"00000409", L"1252", L"850", L"10000", L"Norwegian", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000418", L"00000418", L"00000409", L"1250", L"852", L"10029", L"Romanian", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000419", L"00000419", L"00000409", L"1251", L"866", L"10007", L"Russkij", ruRUPages, ruRUErrorEntries, ruRUStrings },
|
|
|
|
{L"00000415", L"00000415", L"00000409", L"1250", L"852", L"10029", L"Polski", plPLPages, plPLErrorEntries, plPLStrings },
|
|
|
|
{L"00000816", L"00000816", L"00000409", L"1252", L"850", L"10000", L"Portuguese", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000C1A", L"00000C1A", L"00000409", L"1251", L"855", L"10007", L"Serbian (Cyrillic)",enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000081A", L"0000081A", L"00000409", L"1250", L"852", L"10029", L"Serbian (Latin)", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000041B", L"0000041B", L"00000409", L"1250", L"852", L"10029", L"Slovak", skSKPages, skSKErrorEntries, skSKStrings },
|
|
|
|
{L"0000040A", L"0000040A", L"00000409", L"1252", L"850", L"10000", L"Spanish", esESPages, esESErrorEntries, esESStrings },
|
|
|
|
{L"00000807", L"00000807", L"00000409", L"1252", L"850", L"10000", L"Swiss (German)", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000041D", L"0000041D", L"00000409", L"1252", L"850", L"10000", L"Swedish", svSEPages, svSEErrorEntries, svSEStrings },
|
|
|
|
{L"00000444", L"00000444", L"00000409", L"1251", L"866", L"10007", L"Tatar", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000041E", L"0000041E", L"00000409", L"874", L"874", L"10021", L"Thai", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000041F", L"0000041F", L"00000409", L"1254", L"857", L"10081", L"Turkish", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000422", L"00000422", L"00000409", L"1251", L"866", L"10017", L"Ukrainian", ukUAPages, ukUAErrorEntries, ukUAStrings },
|
|
|
|
{L"00000809", L"00000809", L"00000409", L"1252", L"850", L"10000", L"United Kingdom", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"00000843", L"00000843", L"00000409", L"1251", L"866", L"10007", L"Uzbek", enUSPages, enUSErrorEntries, enUSStrings },
|
|
|
|
{L"0000042A", L"0000042A", L"00000409", L"1258", L"1258",L"10000", L"Vietnamese", enUSPages, enUSErrorEntries, enUSStrings },
|
2008-04-28 14:04:22 +00:00
|
|
|
{NULL, NULL, NULL, NULL, NULL, NULL}
|
2007-12-12 00:05:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern
|
|
|
|
VOID
|
2008-01-09 09:40:47 +00:00
|
|
|
PopupError(IN PCCH Text,
|
|
|
|
IN PCCH Status,
|
|
|
|
IN PINPUT_RECORD Ir,
|
|
|
|
IN ULONG WaitEvent);
|
2007-12-12 00:05:00 +00:00
|
|
|
|
2008-02-12 14:52:36 +00:00
|
|
|
static
|
|
|
|
ULONG
|
|
|
|
FindLanguageIndex()
|
|
|
|
{
|
|
|
|
ULONG lngIndex = 0;
|
|
|
|
|
|
|
|
if (SelectedLanguageId == NULL)
|
|
|
|
{
|
2008-02-29 14:27:32 +00:00
|
|
|
/* default to english */
|
|
|
|
return 0;
|
2008-02-12 14:52:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
|
|
|
|
{
|
|
|
|
return lngIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
lngIndex++;
|
|
|
|
}while (LanguageList[lngIndex].MuiPages != NULL);
|
|
|
|
|
2008-02-29 14:27:32 +00:00
|
|
|
return 0;
|
2008-02-12 14:52:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 00:05:00 +00:00
|
|
|
static
|
2008-01-09 09:40:47 +00:00
|
|
|
const MUI_ENTRY *
|
|
|
|
FindMUIEntriesOfPage(IN ULONG PageNumber)
|
2007-12-12 00:05:00 +00:00
|
|
|
{
|
2007-12-23 20:29:52 +00:00
|
|
|
ULONG muiIndex = 0;
|
2008-02-29 14:27:32 +00:00
|
|
|
ULONG lngIndex;
|
2008-01-09 09:40:47 +00:00
|
|
|
const MUI_PAGE * Pages = NULL;
|
2007-12-23 20:29:52 +00:00
|
|
|
|
2008-02-29 14:27:32 +00:00
|
|
|
lngIndex = max(FindLanguageIndex(), 0);
|
|
|
|
Pages = LanguageList[lngIndex].MuiPages;
|
|
|
|
|
2007-12-12 00:05:00 +00:00
|
|
|
do
|
|
|
|
{
|
2008-02-29 14:27:32 +00:00
|
|
|
if (Pages[muiIndex].Number == PageNumber)
|
|
|
|
return Pages[muiIndex].MuiEntry;
|
2007-12-23 20:29:52 +00:00
|
|
|
|
2008-02-29 14:27:32 +00:00
|
|
|
muiIndex++;
|
|
|
|
}while (Pages[muiIndex].MuiEntry != NULL);
|
2007-12-23 20:29:52 +00:00
|
|
|
|
2007-12-12 00:05:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-01-02 14:34:51 +00:00
|
|
|
static
|
2008-01-09 09:40:47 +00:00
|
|
|
const MUI_ERROR *
|
|
|
|
FindMUIErrorEntries(VOID)
|
2008-01-02 14:34:51 +00:00
|
|
|
{
|
2008-02-29 14:27:32 +00:00
|
|
|
ULONG lngIndex = max(FindLanguageIndex(), 0);
|
|
|
|
return LanguageList[lngIndex].MuiErrors;
|
2008-01-02 14:34:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 04:14:09 +00:00
|
|
|
static
|
|
|
|
const MUI_STRING *
|
|
|
|
FindMUIStringEntries(VOID)
|
|
|
|
{
|
2008-02-29 14:27:32 +00:00
|
|
|
ULONG lngIndex = max(FindLanguageIndex(), 0);
|
|
|
|
return LanguageList[lngIndex].MuiStrings;
|
2008-02-08 04:14:09 +00:00
|
|
|
}
|
|
|
|
|
2008-01-09 09:40:47 +00:00
|
|
|
LPCWSTR
|
|
|
|
MUIDefaultKeyboardLayout(VOID)
|
2008-01-06 23:36:01 +00:00
|
|
|
{
|
2008-02-29 14:27:32 +00:00
|
|
|
ULONG lngIndex = max(FindLanguageIndex(), 0);
|
|
|
|
return LanguageList[lngIndex].LanguageKeyboardLayoutID;
|
2008-01-06 23:36:01 +00:00
|
|
|
}
|
|
|
|
|
2007-12-13 16:15:43 +00:00
|
|
|
VOID
|
2008-01-09 09:40:47 +00:00
|
|
|
MUIDisplayPage(IN ULONG page)
|
2007-12-12 00:05:00 +00:00
|
|
|
{
|
2008-01-09 09:40:47 +00:00
|
|
|
const MUI_ENTRY * entry;
|
2007-12-12 00:05:00 +00:00
|
|
|
int index;
|
|
|
|
|
2008-01-09 09:40:47 +00:00
|
|
|
entry = FindMUIEntriesOfPage(page);
|
2007-12-12 00:05:00 +00:00
|
|
|
if (!entry)
|
|
|
|
{
|
|
|
|
PopupError("Error: Failed to find translated page",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
POPUP_WAIT_NONE);
|
2007-12-15 16:30:15 +00:00
|
|
|
return;
|
2007-12-12 00:05:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
do
|
|
|
|
{
|
2008-03-19 04:43:40 +00:00
|
|
|
CONSOLE_SetStyledText (
|
|
|
|
entry[index].X,
|
|
|
|
entry[index].Y,
|
|
|
|
entry[index].Flags,
|
|
|
|
entry[index].Buffer);
|
|
|
|
|
2007-12-12 00:05:00 +00:00
|
|
|
index++;
|
2007-12-23 20:29:52 +00:00
|
|
|
}
|
|
|
|
while (entry[index].Buffer != NULL);
|
2007-12-12 00:05:00 +00:00
|
|
|
}
|
2007-12-15 14:24:02 +00:00
|
|
|
|
|
|
|
VOID
|
2008-01-09 09:40:47 +00:00
|
|
|
MUIDisplayError(IN ULONG ErrorNum, OUT PINPUT_RECORD Ir, IN ULONG WaitEvent)
|
2007-12-15 14:24:02 +00:00
|
|
|
{
|
2008-01-09 09:40:47 +00:00
|
|
|
const MUI_ERROR * entry;
|
2008-01-02 14:34:51 +00:00
|
|
|
|
2007-12-15 14:24:02 +00:00
|
|
|
if (ErrorNum >= ERROR_LAST_ERROR_CODE)
|
|
|
|
{
|
2008-01-09 09:40:47 +00:00
|
|
|
PopupError("Invalid error number provided",
|
2008-01-02 14:34:51 +00:00
|
|
|
"Press ENTER to continue",
|
|
|
|
Ir,
|
|
|
|
POPUP_WAIT_ENTER);
|
2007-12-15 14:24:02 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2007-12-15 16:30:15 +00:00
|
|
|
|
2008-01-09 09:40:47 +00:00
|
|
|
entry = FindMUIErrorEntries();
|
2008-01-02 14:34:51 +00:00
|
|
|
if (!entry)
|
|
|
|
{
|
|
|
|
PopupError("Error: Failed to find translated error message",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
POPUP_WAIT_NONE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PopupError(entry[ErrorNum].ErrorText,
|
|
|
|
entry[ErrorNum].ErrorStatus,
|
2007-12-15 14:24:02 +00:00
|
|
|
Ir,
|
|
|
|
WaitEvent);
|
|
|
|
}
|
2007-12-23 20:29:52 +00:00
|
|
|
|
2008-02-08 04:14:09 +00:00
|
|
|
LPSTR
|
|
|
|
MUIGetString(ULONG Number)
|
|
|
|
{
|
|
|
|
ULONG i;
|
|
|
|
const MUI_STRING * entry;
|
2008-02-12 14:52:36 +00:00
|
|
|
CHAR szErr[100];
|
2008-02-08 04:14:09 +00:00
|
|
|
|
|
|
|
entry = FindMUIStringEntries();
|
|
|
|
if (entry)
|
|
|
|
{
|
|
|
|
for (i = 0; entry[i].Number != 0; i++)
|
|
|
|
{
|
|
|
|
if (entry[i].Number == Number)
|
|
|
|
{
|
|
|
|
return entry[i].String;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-12 14:52:36 +00:00
|
|
|
sprintf(szErr, "Error: failed find string id %lu for language index %lu\n", Number, FindLanguageIndex());
|
|
|
|
|
|
|
|
PopupError(szErr,
|
2008-02-08 04:14:09 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
POPUP_WAIT_NONE);
|
|
|
|
|
|
|
|
return "<nostring>";
|
|
|
|
}
|
|
|
|
|
2008-04-28 14:04:22 +00:00
|
|
|
static BOOLEAN
|
|
|
|
AddKbLayoutsToRegistry(IN LPCWSTR DefKbLayout, IN LPCWSTR SecKbLayout)
|
|
|
|
{
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
UNICODE_STRING KeyName;
|
|
|
|
UNICODE_STRING ValueName;
|
|
|
|
HANDLE KeyHandle;
|
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG Disposition;
|
|
|
|
WCHAR szKeyName[48] = L"\\Registry\\User\\.DEFAULT\\Keyboard Layout";
|
|
|
|
|
|
|
|
// Open the keyboard layout key
|
|
|
|
RtlInitUnicodeString(&KeyName,
|
|
|
|
szKeyName);
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&KeyName,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
Status = NtCreateKey(&KeyHandle,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
&ObjectAttributes,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
&Disposition);
|
|
|
|
|
|
|
|
if(NT_SUCCESS(Status))
|
|
|
|
NtClose(KeyHandle);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DPRINT1("NtCreateKey() failed (Status %lx)\n", Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyName.MaximumLength = sizeof(szKeyName);
|
|
|
|
Status = RtlAppendUnicodeToString(&KeyName, L"\\Preload");
|
|
|
|
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("RtlAppend failed! (%lx)\n", Status);
|
|
|
|
DPRINT1("String is %wZ\n", &KeyName);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&KeyName,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
Status = NtCreateKey(&KeyHandle,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
&ObjectAttributes,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
&Disposition);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("NtCreateKey() failed (Status %lx)\n", Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set def keyboard layout */
|
|
|
|
RtlInitUnicodeString(&ValueName,
|
|
|
|
L"1");
|
|
|
|
|
|
|
|
Status = NtSetValueKey(KeyHandle,
|
|
|
|
&ValueName,
|
|
|
|
0,
|
|
|
|
REG_SZ,
|
|
|
|
(PVOID)DefKbLayout,
|
|
|
|
(8 + 1) * sizeof(WCHAR));
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
|
|
|
|
NtClose(KeyHandle);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SecKbLayout != NULL)
|
|
|
|
{
|
|
|
|
/* Set second keyboard layout */
|
|
|
|
RtlInitUnicodeString(&ValueName,
|
|
|
|
L"2");
|
|
|
|
|
|
|
|
Status = NtSetValueKey(KeyHandle,
|
|
|
|
&ValueName,
|
|
|
|
0,
|
|
|
|
REG_SZ,
|
|
|
|
(PVOID)SecKbLayout,
|
|
|
|
(8 + 1) * sizeof(WCHAR));
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
|
|
|
|
NtClose(KeyHandle);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NtClose(KeyHandle);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
AddKeyboardLayouts(VOID)
|
|
|
|
{
|
|
|
|
ULONG lngIndex = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
|
|
|
|
{
|
|
|
|
return AddKbLayoutsToRegistry(LanguageList[lngIndex].LanguageKeyboardLayoutID,
|
|
|
|
LanguageList[lngIndex].SecondLangKbLayoutID);
|
|
|
|
}
|
|
|
|
|
|
|
|
lngIndex++;
|
|
|
|
}
|
|
|
|
while (LanguageList[lngIndex].MuiPages != NULL);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-01-07 14:51:42 +00:00
|
|
|
static BOOLEAN
|
2008-01-09 09:40:47 +00:00
|
|
|
AddCodepageToRegistry(IN LPCWSTR ACPage, IN LPCWSTR OEMCPage, IN LPCWSTR MACCPage)
|
2008-01-07 14:51:42 +00:00
|
|
|
{
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
UNICODE_STRING KeyName;
|
|
|
|
UNICODE_STRING ValueName;
|
|
|
|
HANDLE KeyHandle;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
// Open the nls codepage key
|
|
|
|
RtlInitUnicodeString(&KeyName,
|
2008-01-09 09:40:47 +00:00
|
|
|
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage");
|
2008-01-07 14:51:42 +00:00
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
2008-01-09 09:40:47 +00:00
|
|
|
&KeyName,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2008-01-07 14:51:42 +00:00
|
|
|
Status = NtOpenKey(&KeyHandle,
|
2008-01-09 09:40:47 +00:00
|
|
|
KEY_WRITE,
|
|
|
|
&ObjectAttributes);
|
2008-01-07 14:51:42 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set ANSI codepage
|
|
|
|
RtlInitUnicodeString(&ValueName, L"ACP");
|
|
|
|
Status = NtSetValueKey(KeyHandle,
|
2008-01-09 09:40:47 +00:00
|
|
|
&ValueName,
|
|
|
|
0,
|
|
|
|
REG_SZ,
|
|
|
|
(PVOID)ACPage,
|
|
|
|
wcslen(ACPage) * sizeof(PWCHAR));
|
2008-01-07 14:51:42 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
|
|
|
|
NtClose(KeyHandle);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set OEM codepage
|
|
|
|
RtlInitUnicodeString(&ValueName, L"OEMCP");
|
|
|
|
Status = NtSetValueKey(KeyHandle,
|
2008-01-09 09:40:47 +00:00
|
|
|
&ValueName,
|
|
|
|
0,
|
|
|
|
REG_SZ,
|
|
|
|
(PVOID)OEMCPage,
|
|
|
|
wcslen(OEMCPage) * sizeof(PWCHAR));
|
2008-01-07 14:51:42 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
|
|
|
|
NtClose(KeyHandle);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set MAC codepage
|
|
|
|
RtlInitUnicodeString(&ValueName, L"MACCP");
|
|
|
|
Status = NtSetValueKey(KeyHandle,
|
2008-01-09 09:40:47 +00:00
|
|
|
&ValueName,
|
|
|
|
0,
|
|
|
|
REG_SZ,
|
|
|
|
(PVOID)MACCPage,
|
|
|
|
wcslen(MACCPage) * sizeof(PWCHAR));
|
2008-01-07 14:51:42 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
|
|
|
|
NtClose(KeyHandle);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NtClose(KeyHandle);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
AddCodePage(VOID)
|
|
|
|
{
|
|
|
|
ULONG lngIndex = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
|
|
|
|
{
|
|
|
|
return AddCodepageToRegistry(LanguageList[lngIndex].ACPage,
|
|
|
|
LanguageList[lngIndex].OEMCPage,
|
|
|
|
LanguageList[lngIndex].MACCPage);
|
|
|
|
}
|
|
|
|
|
|
|
|
lngIndex++;
|
|
|
|
}
|
|
|
|
while (LanguageList[lngIndex].MuiPages != NULL);
|
2008-01-09 09:40:47 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2008-01-07 14:51:42 +00:00
|
|
|
}
|
|
|
|
|
2008-01-21 13:33:52 +00:00
|
|
|
VOID
|
|
|
|
SetConsoleCodePage(VOID)
|
|
|
|
{
|
|
|
|
ULONG lngIndex = 0;
|
|
|
|
UINT wCodePage;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
|
|
|
|
{
|
|
|
|
wCodePage = (UINT) wcstoul(LanguageList[lngIndex].OEMCPage, NULL, 10);
|
|
|
|
SetConsoleOutputCP(wCodePage);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
lngIndex++;
|
|
|
|
}
|
|
|
|
while (LanguageList[lngIndex].MuiPages != NULL);
|
|
|
|
}
|
|
|
|
|
2007-12-23 20:29:52 +00:00
|
|
|
/* EOF */
|