ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
September 2016
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
18 participants
342 discussions
Start a n
N
ew thread
[dchapyshev] 72700: [ROSAPPS] Add initial version txt2nls file converter (DBCS codepages not supported yet)
by dchapyshev@svn.reactos.org
Author: dchapyshev Date: Sat Sep 17 01:02:53 2016 New Revision: 72700 URL:
http://svn.reactos.org/svn/reactos?rev=72700&view=rev
Log: [ROSAPPS] Add initial version txt2nls file converter (DBCS codepages not supported yet) Added: trunk/rosapps/applications/devutils/txt2nls/ trunk/rosapps/applications/devutils/txt2nls/CMakeLists.txt (with props) trunk/rosapps/applications/devutils/txt2nls/main.c (with props) trunk/rosapps/applications/devutils/txt2nls/nls.c (with props) trunk/rosapps/applications/devutils/txt2nls/precomp.h (with props) trunk/rosapps/applications/devutils/txt2nls/txt.c (with props) trunk/rosapps/applications/devutils/txt2nls/txt2nls.rc (with props) Modified: trunk/rosapps/applications/devutils/CMakeLists.txt Modified: trunk/rosapps/applications/devutils/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/CMak…
============================================================================== --- trunk/rosapps/applications/devutils/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rosapps/applications/devutils/CMakeLists.txt [iso-8859-1] Sat Sep 17 01:02:53 2016 @@ -7,4 +7,5 @@ add_subdirectory(shimdbg) add_subdirectory(symdump) add_subdirectory(syscalldump) +add_subdirectory(txt2nls) add_subdirectory(vgafontedit) Added: trunk/rosapps/applications/devutils/txt2nls/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/txt2…
============================================================================== --- trunk/rosapps/applications/devutils/txt2nls/CMakeLists.txt (added) +++ trunk/rosapps/applications/devutils/txt2nls/CMakeLists.txt [iso-8859-1] Sat Sep 17 01:02:53 2016 @@ -0,0 +1,12 @@ + +list(APPEND SOURCE + main.c + txt.c + nls.c + precomp.h) + +add_executable(txt2nls ${SOURCE} txt2nls.rc) +add_pch(txt2nls precomp.h SOURCE) +set_module_type(txt2nls win32cui) +add_importlibs(txt2nls msvcrt kernel32) +add_cd_file(TARGET txt2nls DESTINATION reactos/system32 FOR all) Propchange: trunk/rosapps/applications/devutils/txt2nls/CMakeLists.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rosapps/applications/devutils/txt2nls/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/txt2…
============================================================================== --- trunk/rosapps/applications/devutils/txt2nls/main.c (added) +++ trunk/rosapps/applications/devutils/txt2nls/main.c [iso-8859-1] Sat Sep 17 01:02:53 2016 @@ -0,0 +1,19 @@ +/* + * PROJECT: ReactOS TXT to NLS Converter + * LICENSE: GNU General Public License Version 2.0 or any later version + * FILE: devutils/txt2nls/main.c + * COPYRIGHT: Copyright 2016 Dmitry Chapyshev <dmitry(a)reactos.org> + */ + +#include "precomp.h" + +int main(int argc, char* argv[]) +{ + if (argc != 3) + return 1; + + if (!nls_from_txt(argv[1], argv[2])) + return 1; + + return 0; +} Propchange: trunk/rosapps/applications/devutils/txt2nls/main.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rosapps/applications/devutils/txt2nls/nls.c URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/txt2…
============================================================================== --- trunk/rosapps/applications/devutils/txt2nls/nls.c (added) +++ trunk/rosapps/applications/devutils/txt2nls/nls.c [iso-8859-1] Sat Sep 17 01:02:53 2016 @@ -0,0 +1,231 @@ +/* + * PROJECT: ReactOS TXT to NLS Converter + * LICENSE: GNU General Public License Version 2.0 or any later version + * FILE: devutils/txt2nls/nls.c + * COPYRIGHT: Copyright 2016 Dmitry Chapyshev <dmitry(a)reactos.org> + */ + +#include "precomp.h" + +#define _NLS_DEBUG_PRINT + +#ifdef _NLS_DEBUG_PRINT + +static void +nls_print_header(NLS_FILE_HEADER *header) +{ + uint32_t i; + + printf("HEADER:\n"); + printf("CodePage: %u\n", header->CodePage); + printf("Character size: %u\n", header->MaximumCharacterSize); + printf("Default char: 0x%02X\n", header->DefaultChar); + printf("Default unicode char: 0x%04X\n", header->UniDefaultChar); + printf("Trans default char: 0x%02X\n", header->TransUniDefaultChar); + printf("Trans default unicode char: 0x%04X\n", header->TransUniDefaultChar); + + for (i = 0; i < MAXIMUM_LEADBYTES; i++) + { + printf("LeadByte[%u] = 0x%02X\n", i, header->LeadByte[i]); + } + + printf("\n"); +} + +static void +nls_print_mb_table(uint16_t *mb_table, uint16_t uni_default_char) +{ + uint32_t ch; + + printf("MBTABLE:\n"); + + for (ch = 0; ch <= 0xFF; ch++) + { + if (mb_table[ch] != uni_default_char) + { + printf("0x%02X 0x%04X\n", (unsigned int)ch, (unsigned int)mb_table[ch]); + } + } + + printf("\n"); +} + +static void +nls_print_wc_table(uint16_t *wc_table, uint16_t default_char, int is_dbcs) +{ + uint32_t ch; + + printf("WCTABLE:\n"); + + for (ch = 0; ch <= 0xFFFF; ch++) + { + /* DBCS code page */ + if (is_dbcs) + { + uint16_t *table = (uint16_t*)wc_table; + + if (table[ch] != default_char) + printf("0x%04X 0x%04X\n", (unsigned int)ch, (unsigned int)table[ch]); + } + /* SBCS code page */ + else + { + uint8_t *table = (uint8_t*)wc_table; + + if (table[ch] != default_char) + printf("0x%04X 0x%02X\n", (unsigned int)ch, (unsigned int)table[ch]); + } + } + + printf("\n"); +} + +static void +nls_print_glyph_table(uint16_t *glyph_table, uint16_t uni_default_char) +{ + uint32_t ch; + + printf("GLYPHTABLE:\n"); + + for (ch = 0; ch <= 0xFF; ch++) + { + if (glyph_table[ch] != uni_default_char) + { + printf("0x%02X 0x%04X\n", (unsigned int)ch, (unsigned int)glyph_table[ch]); + } + } + + printf("\n"); +} + +#endif /* _NLS_DEBUG_PRINT */ + +int +nls_from_txt(const char *txt_file_path, const char *nls_file_path) +{ + NLS_FILE_HEADER header; + FILE *file = NULL; + uint16_t *mb_table = NULL; + uint16_t *wc_table = NULL; + uint16_t *glyph_table = NULL; + uint16_t number_of_lb_ranges; + uint16_t size; + int is_dbcs; + int res = 0; + + memset(&header, 0, sizeof(header)); + + if (!txt_get_header(txt_file_path, &header)) + goto Cleanup; + + is_dbcs = (header.MaximumCharacterSize == 2) ? 1 : 0; + + mb_table = txt_get_mb_table(txt_file_path, header.UniDefaultChar); + if (!mb_table) + goto Cleanup; + + wc_table = txt_get_wc_table(txt_file_path, header.DefaultChar, is_dbcs); + if (!wc_table) + goto Cleanup; + + /* GLYPHTABLE optionally. We do not leave if it is absent */ + glyph_table = txt_get_glyph_table(txt_file_path, header.UniDefaultChar); + +#ifdef _NLS_DEBUG_PRINT + nls_print_header(&header); + nls_print_mb_table(mb_table, header.UniDefaultChar); + if (glyph_table) + nls_print_glyph_table(glyph_table, header.UniDefaultChar); + nls_print_wc_table(wc_table, header.DefaultChar, is_dbcs); +#endif /* _NLS_DEBUG_PRINT */ + + /* Create binary file with write access */ + file = fopen(nls_file_path, "wb"); + if (!file) + { + printf("Unable to create NLS file.\n"); + goto Cleanup; + } + + /* Write NLS file header */ + if (fwrite(&header, 1, sizeof(header), file) != sizeof(header)) + { + printf("Unable to write NLS file.\n"); + goto Cleanup; + } + + size = (256 * sizeof(uint16_t)) + /* Primary CP to Unicode table */ + sizeof(uint16_t) + /* optional OEM glyph table size in words */ + (glyph_table ? (256 * sizeof(uint16_t)) : 0) + /* OEM glyph table size in words * sizeof(uint16_t) */ + sizeof(uint16_t) + /* Number of DBCS LeadByte ranges */ + 0 + /* offsets of lead byte sub tables */ + 0 + /* LeadByte sub tables */ + sizeof(uint16_t); /* Unknown flag */ + + size /= sizeof(uint16_t); + + if (fwrite(&size, 1, sizeof(size), file) != sizeof(size)) + { + printf("Unable to write NLS file.\n"); + goto Cleanup; + } + + /* Write multibyte table */ + if (fwrite(mb_table, 1, (256 * sizeof(uint16_t)), file) != (256 * sizeof(uint16_t))) + { + printf("Unable to write NLS file.\n"); + goto Cleanup; + } + + /* OEM glyph table size in words */ + size = (glyph_table ? (256 * sizeof(uint16_t)) : 0); + + if (fwrite(&size, 1, sizeof(size), file) != sizeof(size)) + { + printf("Unable to write NLS file.\n"); + goto Cleanup; + } + + if (glyph_table) + { + /* Write OEM glyph table */ + if (fwrite(glyph_table, 1, (256 * sizeof(uint16_t)), file) != (256 * sizeof(uint16_t))) + { + printf("Unable to write NLS file.\n"); + goto Cleanup; + } + } + + /* Number of DBCS LeadByte ranges */ + number_of_lb_ranges = 0; + if (fwrite(&number_of_lb_ranges, 1, sizeof(number_of_lb_ranges), file) != sizeof(number_of_lb_ranges)) + { + printf("Unable to write NLS file.\n"); + goto Cleanup; + } + + /* Unknown flag */ + size = 0; + if (fwrite(&size, 1, sizeof(size), file) != sizeof(size)) + { + printf("Unable to write NLS file.\n"); + goto Cleanup; + } + + /* Write wide char table */ + if (fwrite(wc_table, 1, (65535 * header.MaximumCharacterSize), file) != (65535 * header.MaximumCharacterSize)) + { + printf("Unable to write NLS file.\n"); + goto Cleanup; + } + + res = 1; + +Cleanup: + if (file) fclose(file); + free(mb_table); + free(wc_table); + free(glyph_table); + + return res; +} Propchange: trunk/rosapps/applications/devutils/txt2nls/nls.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rosapps/applications/devutils/txt2nls/precomp.h URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/txt2…
============================================================================== --- trunk/rosapps/applications/devutils/txt2nls/precomp.h (added) +++ trunk/rosapps/applications/devutils/txt2nls/precomp.h [iso-8859-1] Sat Sep 17 01:02:53 2016 @@ -0,0 +1,49 @@ +/* + * PROJECT: ReactOS TXT to NLS Converter + * LICENSE: GNU General Public License Version 2.0 or any later version + * FILE: devutils/txt2nls/precomp.h + * COPYRIGHT: Copyright 2016 Dmitry Chapyshev <dmitry(a)reactos.org> + */ + +#ifndef __PRECOMP_H +#define __PRECOMP_H + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> +#include <ctype.h> +#include <memory.h> + +#define MAXIMUM_LEADBYTES 12 + +typedef struct +{ + uint16_t HeaderSize; + uint16_t CodePage; + uint16_t MaximumCharacterSize; + uint16_t DefaultChar; + uint16_t UniDefaultChar; + uint16_t TransDefaultChar; + uint16_t TransUniDefaultChar; + uint8_t LeadByte[MAXIMUM_LEADBYTES]; +} NLS_FILE_HEADER; + +/* nls.c */ +int +nls_from_txt(const char *txt_file_path, const char *nls_file_path); + +/* bestfit.c */ +int +txt_get_header(const char *file_path, NLS_FILE_HEADER *header); + +uint16_t* +txt_get_mb_table(const char *file_path, uint16_t uni_default_char); + +uint16_t* +txt_get_wc_table(const char *file_path, uint16_t default_char, int is_dbcs); + +uint16_t* +txt_get_glyph_table(const char *file_path, uint16_t uni_default_char); + +#endif Propchange: trunk/rosapps/applications/devutils/txt2nls/precomp.h ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rosapps/applications/devutils/txt2nls/txt.c URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/txt2…
============================================================================== --- trunk/rosapps/applications/devutils/txt2nls/txt.c (added) +++ trunk/rosapps/applications/devutils/txt2nls/txt.c [iso-8859-1] Sat Sep 17 01:02:53 2016 @@ -0,0 +1,495 @@ +/* + * PROJECT: ReactOS TXT to NLS Converter + * LICENSE: GNU General Public License Version 2.0 or any later version + * FILE: devutils/txt2nls/txt.c + * COPYRIGHT: Copyright 2016 Dmitry Chapyshev <dmitry(a)reactos.org> + */ + +#include "precomp.h" + +int +txt_get_header(const char *file_path, NLS_FILE_HEADER *header) +{ + FILE *file; + char *p; + char buf[256]; + uint32_t line = 0; + int res = 0; + int found; + uint32_t val; + + file = fopen(file_path, "r"); + if (!file) + { + printf("Unable to read TXT file.\n"); + return 0; + } + + /* Find CODEPAGE entry */ + found = 0; + while (fgets(buf, sizeof(buf), file)) + { + ++line; + + p = strstr(buf, "CODEPAGE"); + if (p) + { + /* Length of CODEPAGE string is 8 chars */ + p += 8; + + /* Skip all spaces after CODEPAGE */ + while (isspace(*p)) ++p; + + /* Convert string to uint32_t */ + val = strtoul(p, &p, 10); + + /* Validate codepage value */ + if (val > 0xFFFF) + { + printf("Wrong codepage: %u (line: %u)\n", val, line); + goto Cleanup; + } + + header->CodePage = (uint16_t)val; + + found = 1; + break; + } + } + + if (!found) + { + printf("CODEPAGE not found.\n"); + goto Cleanup; + } + + /* Find CPINFO entry */ + found = 0; + while (fgets(buf, sizeof(buf), file)) + { + ++line; + + p = strstr(buf, "CPINFO"); + if (p) + { + /* Length of CPINFO string is 6 chars */ + p += 6; + + /* Skip all spaces after CPINFO */ + while (isspace(*p)) ++p; + + /* Convert string to uint32_t */ + val = strtoul(p, &p, 10); + + /* Validate value */ + if (val != 1 && val != 2) + { + printf("Wrong character size: %u (line: %u)\n", val, line); + goto Cleanup; + } + + header->MaximumCharacterSize = (uint16_t)val; + + /* Skip all spaces after character size */ + while (isspace(*p)) ++p; + + /* Convert string to uint32_t */ + val = strtoul(p, &p, 16); + header->DefaultChar = (uint16_t)val; + header->TransDefaultChar = (uint16_t)val; + + /* Skip all spaces after default char */ + while (isspace(*p)) ++p; + + /* Convert string to uint32_t */ + val = strtoul(p, &p, 16); + header->UniDefaultChar = (uint16_t)val; + header->TransUniDefaultChar = (uint16_t)val; + + found = 1; + break; + } + } + + if (!found) + { + printf("CPINFO not found.\n"); + goto Cleanup; + } + + header->HeaderSize = sizeof(NLS_FILE_HEADER) / sizeof(uint16_t); + + res = 1; + +Cleanup: + fclose(file); + + return res; +} + +uint16_t* +txt_get_mb_table(const char *file_path, uint16_t uni_default_char) +{ + uint16_t *table; + char buf[256]; + char *p; + uint32_t count = 0; + uint32_t index; + uint32_t line = 0; + int found; + int res = 0; + FILE *file; + + table = malloc(0xFF * sizeof(uint16_t)); + if (!table) + { + printf("Memory allocation failure\n"); + return NULL; + } + + /* Set default value for all table items */ + for (index = 0; index <= 0xFF; index++) + table[index] = uni_default_char; + + file = fopen(file_path, "r"); + if (!file) + { + printf("Unable to read TXT file.\n"); + goto Cleanup; + } + + /* Find MBTABLE entry */ + found = 0; + while (fgets(buf, sizeof(buf), file)) + { + ++line; + + p = strstr(buf, "MBTABLE"); + if (p) + { + p += 7; + + /* Skip spaces */ + while (isspace(*p)) ++p; + + count = strtoul(p, &p, 10); + if (count == 0 || count > 256) + { + printf("Wrong MBTABLE size: %u (line: %u)\n", count, line); + goto Cleanup; + } + + found = 1; + break; + } + } + + if (!found) + { + printf("MBTABLE not found.\n"); + goto Cleanup; + } + + /* Parse next line */ + while (fgets(buf, sizeof(buf), file) && count) + { + uint32_t cp_char; + uint32_t uni_char; + + ++line; + + p = buf; + + /* Skip spaces */ + while (isspace(*p)) ++p; + + if (!*p || p[0] == ';') + continue; + + cp_char = strtoul(p, &p, 16); + if (cp_char > 0xFF) + { + printf("Wrong char value: %u (line: %u)\n", cp_char, line); + goto Cleanup; + } + + /* Skip spaces */ + while (isspace(*p)) ++p; + + uni_char = strtoul(p, &p, 16); + if (uni_char > 0xFFFF) + { + printf("Wrong unicode char value: %u (line: %u)\n", uni_char, line); + goto Cleanup; + } + + table[cp_char] = uni_char; + --count; + } + + res = 1; + +Cleanup: + if (!res) + { + free(table); + table = NULL; + } + + fclose(file); + + return table; +} + +uint16_t* +txt_get_wc_table(const char *file_path, uint16_t default_char, int is_dbcs) +{ + char buf[256]; + char *p; + uint16_t *table; + uint32_t index; + uint32_t count = 0; + uint32_t line = 0; + int res = 0; + int found; + FILE *file; + + table = malloc(0xFFFF * (is_dbcs ? sizeof(uint16_t) : sizeof(uint8_t))); + if (!table) + { + printf("Memory allocation failure\n"); + return NULL; + } + + /* Set default value for all table items */ + for (index = 0; index <= 0xFFFF; index++) + { + /* DBCS code page */ + if (is_dbcs) + { + uint16_t *tmp = (uint16_t*)table; + tmp[index] = default_char; + } + /* SBCS code page */ + else + { + uint8_t *tmp = (uint8_t*)table; + tmp[index] = default_char; + } + } + + file = fopen(file_path, "r"); + if (!file) + { + printf("Unable to read TXT file.\n"); + goto Cleanup; + } + + /* Find WCTABLE entry */ + found = 0; + while (fgets(buf, sizeof(buf), file)) + { + ++line; + + p = strstr(buf, "WCTABLE"); + if (p) + { + p += 7; + + /* Skip spaces */ + while (isspace(*p)) ++p; + + count = strtoul(p, &p, 10); + if (count == 0 || count > 65536) + { + printf("Wrong WCTABLE size: %u (line: %u)\n", count, line); + goto Cleanup; + } + + found = 1; + break; + } + } + + if (!found) + { + printf("WCTABLE not found.\n"); + goto Cleanup; + } + + /* Parse next line */ + while (fgets(buf, sizeof(buf), file) && count) + { + uint32_t cp_char; + uint32_t uni_char; + + ++line; + + p = buf; + + /* Skip spaces */ + while (isspace(*p)) ++p; + + if (!*p || p[0] == ';') + continue; + + uni_char = strtoul(p, &p, 16); + if (uni_char > 0xFFFF) + { + printf("Wrong unicode char value: %u (line: %u)\n", uni_char, line); + goto Cleanup; + } + + /* Skip spaces */ + while (isspace(*p)) ++p; + + cp_char = strtoul(p, &p, 16); + if ((is_dbcs && cp_char > 0xFFFF) || (!is_dbcs && cp_char > 0xFF)) + { + printf("Wrong char value: %u (line: %u)\n", cp_char, line); + goto Cleanup; + } + + /* DBCS code page */ + if (is_dbcs) + { + uint16_t *tmp = (uint16_t*)table; + tmp[uni_char] = cp_char; + } + /* SBCS code page */ + else + { + uint8_t *tmp = (uint8_t*)table; + tmp[uni_char] = cp_char; + } + + --count; + } + + res = 1; + +Cleanup: + if (!res) + { + free(table); + table = NULL; + } + + fclose(file); + + return table; +} + +uint16_t* +txt_get_glyph_table(const char *file_path, uint16_t uni_default_char) +{ + uint16_t *table; + char buf[256]; + char *p; + uint32_t count = 0; + uint32_t index; + uint32_t line = 0; + int found; + int res = 0; + FILE *file; + + table = malloc(0xFF * sizeof(uint16_t)); + if (!table) + { + printf("Memory allocation failure\n"); + return NULL; + } + + /* Set default value for all table items */ + for (index = 0; index <= 0xFF; index++) + table[index] = uni_default_char; + + file = fopen(file_path, "r"); + if (!file) + { + printf("Unable to read TXT file.\n"); + goto Cleanup; + } + + /* Find GLYPHTABLE entry */ + found = 0; + while (fgets(buf, sizeof(buf), file)) + { + ++line; + + p = strstr(buf, "GLYPHTABLE"); + if (p) + { + p += 10; + + /* Skip spaces */ + while (isspace(*p)) ++p; + + count = strtoul(p, &p, 10); + if (count == 0 || count > 256) + { + printf("Wrong GLYPHTABLE size: %u (line: %u)\n", count, line); + goto Cleanup; + } + + found = 1; + break; + } + } + + if (!found) + { + printf("GLYPHTABLE not found.\n"); + goto Cleanup; + } + + /* Parse next line */ + while (fgets(buf, sizeof(buf), file) && count) + { + uint32_t cp_char; + uint32_t uni_char; + + ++line; + + p = buf; + + /* Skip spaces */ + while (isspace(*p)) ++p; + + if (!*p || p[0] == ';') + continue; + + cp_char = strtoul(p, &p, 16); + if (cp_char > 0xFF) + { + printf("Wrong char value: %u (line: %u)\n", cp_char, line); + goto Cleanup; + } + + /* Skip spaces */ + while (isspace(*p)) ++p; + + uni_char = strtoul(p, &p, 16); + if (uni_char > 0xFFFF) + { + printf("Wrong unicode char value: %u (line: %u)\n", uni_char, line); + goto Cleanup; + } + + table[cp_char] = uni_char; + --count; + } + + res = 1; + +Cleanup: + if (!res) + { + free(table); + table = NULL; + } + + fclose(file); + + return table; +} Propchange: trunk/rosapps/applications/devutils/txt2nls/txt.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rosapps/applications/devutils/txt2nls/txt2nls.rc URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/txt2…
============================================================================== --- trunk/rosapps/applications/devutils/txt2nls/txt2nls.rc (added) +++ trunk/rosapps/applications/devutils/txt2nls/txt2nls.rc [iso-8859-1] Sat Sep 17 01:02:53 2016 @@ -0,0 +1,18 @@ +/* + * PROJECT: ReactOS TXT to NLS Converter + * LICENSE: GNU General Public License Version 2.0 or any later version + * FILE: devutils/txt2nls/txt2nls.rc + * COPYRIGHT: Copyright 2016 Dmitry Chapyshev <dmitry(a)reactos.org> + */ + +#include <windows.h> +#include <commctrl.h> + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TXT to NLS Converter" +#define REACTOS_STR_INTERNAL_NAME "txt2nls" +#define REACTOS_STR_ORIGINAL_FILENAME "txt2nls.exe" +#include <reactos/version.rc> + +#include <reactos/manifest_exe.rc> Propchange: trunk/rosapps/applications/devutils/txt2nls/txt2nls.rc ------------------------------------------------------------------------------ svn:eol-style = native
8 years, 3 months
1
0
0
0
[jimtabor] 72699: [NtUser] - Use desktop thread list to search for related active desktop threads. See CORE-11983.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Fri Sep 16 23:58:51 2016 New Revision: 72699 URL:
http://svn.reactos.org/svn/reactos?rev=72699&view=rev
Log: [NtUser] - Use desktop thread list to search for related active desktop threads. See CORE-11983. Modified: trunk/reactos/win32ss/user/ntuser/kbdlayout.c Modified: trunk/reactos/win32ss/user/ntuser/kbdlayout.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/kbdlay…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/kbdlayout.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/kbdlayout.c [iso-8859-1] Fri Sep 16 23:58:51 2016 @@ -450,31 +450,37 @@ UserGetKeyboardLayout( DWORD dwThreadId) { - NTSTATUS Status; - PETHREAD pThread; PTHREADINFO pti; + PLIST_ENTRY ListEntry; PKL pKl; - HKL hKl; + + pti = PsGetCurrentThreadWin32Thread(); if (!dwThreadId) { - pti = PsGetCurrentThreadWin32Thread(); pKl = pti->KeyboardLayout; return pKl ? pKl->hkl : NULL; } - Status = PsLookupThreadByThreadId((HANDLE)(DWORD_PTR)dwThreadId, &pThread); - if (!NT_SUCCESS(Status)) - { - EngSetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - pti = PsGetThreadWin32Thread(pThread); - pKl = pti->KeyboardLayout; - hKl = pKl ? pKl->hkl : NULL; - ObDereferenceObject(pThread); - return hKl; + ListEntry = pti->rpdesk->PtiList.Flink; + + // + // Search the Desktop Thread list for related Desktop active Threads. + // + while(ListEntry != &pti->rpdesk->PtiList) + { + pti = CONTAINING_RECORD(ListEntry, THREADINFO, PtiLink); + + if (PsGetThreadId(pti->pEThread) == UlongToHandle(dwThreadId)) + { + pKl = pti->KeyboardLayout; + return pKl ? pKl->hkl : NULL; + } + + ListEntry = ListEntry->Flink; + } + + return NULL; } /*
8 years, 3 months
1
0
0
0
[hbelusca] 72698: [PIFMGR]: Update the 16-colour format of some icons; add new icons. CORE-10253
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Sep 16 23:17:06 2016 New Revision: 72698 URL:
http://svn.reactos.org/svn/reactos?rev=72698&view=rev
Log: [PIFMGR]: Update the 16-colour format of some icons; add new icons. CORE-10253 Added: trunk/reactos/subsystems/mvdm/pifmgr/res/02.ico (with props) trunk/reactos/subsystems/mvdm/pifmgr/res/05.ico (with props) trunk/reactos/subsystems/mvdm/pifmgr/res/12.ico (with props) trunk/reactos/subsystems/mvdm/pifmgr/res/15.ico (with props) trunk/reactos/subsystems/mvdm/pifmgr/res/17.ico (with props) trunk/reactos/subsystems/mvdm/pifmgr/res/18.ico (with props) trunk/reactos/subsystems/mvdm/pifmgr/res/22.ico (with props) Modified: trunk/reactos/subsystems/mvdm/pifmgr/pifmgr.rc trunk/reactos/subsystems/mvdm/pifmgr/res/03.ico trunk/reactos/subsystems/mvdm/pifmgr/res/09.ico trunk/reactos/subsystems/mvdm/pifmgr/res/13.ico trunk/reactos/subsystems/mvdm/pifmgr/res/19.ico trunk/reactos/subsystems/mvdm/pifmgr/res/20.ico trunk/reactos/subsystems/mvdm/pifmgr/res/23.ico Modified: trunk/reactos/subsystems/mvdm/pifmgr/pifmgr.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/pifmgr/pif…
============================================================================== --- trunk/reactos/subsystems/mvdm/pifmgr/pifmgr.rc [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/pifmgr/pifmgr.rc [iso-8859-1] Fri Sep 16 23:17:06 2016 @@ -10,27 +10,27 @@ /* Icons */ 1 ICON "res/01.ico" -2 ICON "res_alt/02.ico" +2 ICON "res/02.ico" 3 ICON "res/03.ico" 4 ICON "res/04.ico" -5 ICON "res/00.ico" +5 ICON "res/05.ico" 6 ICON "res/06.ico" 7 ICON "res/00.ico" 8 ICON "res_alt/08.ico" 9 ICON "res/09.ico" /* No icon 10 */ 11 ICON "res/11.ico" -12 ICON "res/00.ico" +12 ICON "res/12.ico" 13 ICON "res/13.ico" 14 ICON "res/14.ico" -15 ICON "res_alt/15.ico" +15 ICON "res/15.ico" 16 ICON "res_alt/16.ico" -17 ICON "res/00.ico" -18 ICON "res_alt/18.ico" +17 ICON "res/17.ico" +18 ICON "res/18.ico" 19 ICON "res/19.ico" 20 ICON "res/20.ico" 21 ICON "res/00.ico" -22 ICON "res/00.ico" +22 ICON "res/22.ico" 23 ICON "res/23.ico" 24 ICON "res_alt/24.ico" 25 ICON "res_alt/25.ico" Added: trunk/reactos/subsystems/mvdm/pifmgr/res/02.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/pifmgr/res…
============================================================================== Binary file - no diff available. Propchange: trunk/reactos/subsystems/mvdm/pifmgr/res/02.ico ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: trunk/reactos/subsystems/mvdm/pifmgr/res/03.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/pifmgr/res…
============================================================================== Binary files - no diff available. Added: trunk/reactos/subsystems/mvdm/pifmgr/res/05.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/pifmgr/res…
============================================================================== Binary file - no diff available. Propchange: trunk/reactos/subsystems/mvdm/pifmgr/res/05.ico ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: trunk/reactos/subsystems/mvdm/pifmgr/res/09.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/pifmgr/res…
============================================================================== Binary files - no diff available. Added: trunk/reactos/subsystems/mvdm/pifmgr/res/12.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/pifmgr/res…
============================================================================== Binary file - no diff available. Propchange: trunk/reactos/subsystems/mvdm/pifmgr/res/12.ico ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: trunk/reactos/subsystems/mvdm/pifmgr/res/13.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/pifmgr/res…
============================================================================== Binary files - no diff available. Added: trunk/reactos/subsystems/mvdm/pifmgr/res/15.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/pifmgr/res…
============================================================================== Binary file - no diff available. Propchange: trunk/reactos/subsystems/mvdm/pifmgr/res/15.ico ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: trunk/reactos/subsystems/mvdm/pifmgr/res/17.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/pifmgr/res…
============================================================================== Binary file - no diff available. Propchange: trunk/reactos/subsystems/mvdm/pifmgr/res/17.ico ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: trunk/reactos/subsystems/mvdm/pifmgr/res/18.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/pifmgr/res…
============================================================================== Binary file - no diff available. Propchange: trunk/reactos/subsystems/mvdm/pifmgr/res/18.ico ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: trunk/reactos/subsystems/mvdm/pifmgr/res/19.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/pifmgr/res…
============================================================================== Binary files - no diff available. Modified: trunk/reactos/subsystems/mvdm/pifmgr/res/20.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/pifmgr/res…
============================================================================== Binary files - no diff available. Added: trunk/reactos/subsystems/mvdm/pifmgr/res/22.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/pifmgr/res…
============================================================================== Binary file - no diff available. Propchange: trunk/reactos/subsystems/mvdm/pifmgr/res/22.ico ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: trunk/reactos/subsystems/mvdm/pifmgr/res/23.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/pifmgr/res…
============================================================================== Binary files - no diff available.
8 years, 3 months
1
0
0
0
[akhaldi] 72697: [DHCPCSVC] Add registry key for DHCP domain if present in DHCP reply. By Peter Hater. CORE-10440
by akhaldi@svn.reactos.org
Author: akhaldi Date: Fri Sep 16 13:40:21 2016 New Revision: 72697 URL:
http://svn.reactos.org/svn/reactos?rev=72697&view=rev
Log: [DHCPCSVC] Add registry key for DHCP domain if present in DHCP reply. By Peter Hater. CORE-10440 Modified: trunk/reactos/base/services/dhcpcsvc/dhcp/dhclient.c Modified: trunk/reactos/base/services/dhcpcsvc/dhcp/dhclient.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcpcsvc/dhc…
============================================================================== --- trunk/reactos/base/services/dhcpcsvc/dhcp/dhclient.c [iso-8859-1] (original) +++ trunk/reactos/base/services/dhcpcsvc/dhcp/dhclient.c [iso-8859-1] Fri Sep 16 13:40:21 2016 @@ -447,6 +447,56 @@ } +void +set_domain(PDHCP_ADAPTER Adapter, + struct client_lease *new_lease) +{ + CHAR Buffer1[MAX_PATH] = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\"; + CHAR Buffer2[MAX_PATH] = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"; + HKEY RegKey1, RegKey2; + + strcat(Buffer1, Adapter->DhclientInfo.name); + + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, Buffer1, 0, KEY_WRITE, &RegKey1 ) != ERROR_SUCCESS) + { + return; + } + + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, Buffer2, 0, KEY_WRITE, &RegKey2 ) != ERROR_SUCCESS) + { + RegCloseKey(RegKey1); + return; + } + + if (new_lease->options[DHO_DOMAIN_NAME].len) + { + DH_DbgPrint(MID_TRACE, ("Setting DhcpDomain: %s\n", new_lease->options[DHO_DOMAIN_NAME].data)); + + RegSetValueExA(RegKey1, + "DhcpDomain", + 0, + REG_SZ, + (LPBYTE)new_lease->options[DHO_DOMAIN_NAME].data, + new_lease->options[DHO_DOMAIN_NAME].len); + + RegSetValueExA(RegKey2, + "DhcpDomain", + 0, + REG_SZ, + (LPBYTE)new_lease->options[DHO_DOMAIN_NAME].data, + new_lease->options[DHO_DOMAIN_NAME].len); + } + else + { + RegDeleteValueW(RegKey1, L"DhcpDomain"); + RegDeleteValueW(RegKey2, L"DhcpDomain"); + } + + RegCloseKey(RegKey1); + RegCloseKey(RegKey2); + +} + void setup_adapter( PDHCP_ADAPTER Adapter, struct client_lease *new_lease ) { CHAR Buffer[200] = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\"; struct iaddr netmask; @@ -569,6 +619,7 @@ return; } set_name_servers( Adapter, new_lease ); + set_domain( Adapter, new_lease ); } /*
8 years, 3 months
1
0
0
0
[tfaber] 72696: [NTDLL_WINETEST] - Skip exception test on WHS-Testbot... because problems... ROSTESTS-240
by tfaber@svn.reactos.org
Author: tfaber Date: Fri Sep 16 09:33:54 2016 New Revision: 72696 URL:
http://svn.reactos.org/svn/reactos?rev=72696&view=rev
Log: [NTDLL_WINETEST] - Skip exception test on WHS-Testbot... because problems... ROSTESTS-240 Modified: trunk/rostests/winetests/ntdll/exception.c Modified: trunk/rostests/winetests/ntdll/exception.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/ntdll/exception…
============================================================================== --- trunk/rostests/winetests/ntdll/exception.c [iso-8859-1] (original) +++ trunk/rostests/winetests/ntdll/exception.c [iso-8859-1] Fri Sep 16 09:33:54 2016 @@ -1893,7 +1893,14 @@ START_TEST(exception) { HMODULE hntdll = GetModuleHandleA("ntdll.dll"); - +#ifdef __REACTOS__ + if (!winetest_interactive && + !strcmp(winetest_platform, "windows")) + { + skip("ROSTESTS-240: Skipping ntdll_winetest:exception because it hangs on WHS-Testbot. Set winetest_interactive to run it anyway.\n"); + return; + } +#endif code_mem = VirtualAlloc(NULL, 65536, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); if(!code_mem) { trace("VirtualAlloc failed\n");
8 years, 3 months
1
0
0
0
[dchapyshev] 72695: [NLS2TXT] Remove unneeded imports
by dchapyshev@svn.reactos.org
Author: dchapyshev Date: Thu Sep 15 21:47:22 2016 New Revision: 72695 URL:
http://svn.reactos.org/svn/reactos?rev=72695&view=rev
Log: [NLS2TXT] Remove unneeded imports Modified: trunk/rosapps/applications/devutils/nls2txt/CMakeLists.txt trunk/rosapps/applications/devutils/nls2txt/precomp.h Modified: trunk/rosapps/applications/devutils/nls2txt/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/nls2…
============================================================================== --- trunk/rosapps/applications/devutils/nls2txt/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rosapps/applications/devutils/nls2txt/CMakeLists.txt [iso-8859-1] Thu Sep 15 21:47:22 2016 @@ -8,5 +8,5 @@ add_executable(nls2txt ${SOURCE} nls2txt.rc) add_pch(nls2txt precomp.h SOURCE) set_module_type(nls2txt win32cui UNICODE) -add_importlibs(nls2txt user32 gdi32 comdlg32 comctl32 getuname msvcrt kernel32) +add_importlibs(nls2txt getuname msvcrt kernel32) add_cd_file(TARGET nls2txt DESTINATION reactos/system32 FOR all) Modified: trunk/rosapps/applications/devutils/nls2txt/precomp.h URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/nls2…
============================================================================== --- trunk/rosapps/applications/devutils/nls2txt/precomp.h [iso-8859-1] (original) +++ trunk/rosapps/applications/devutils/nls2txt/precomp.h [iso-8859-1] Thu Sep 15 21:47:22 2016 @@ -9,8 +9,6 @@ #define __PRECOMP_H #include <windows.h> -#include <windowsx.h> -#include <commctrl.h> #include <strsafe.h> #define MAX_STR_LEN 256
8 years, 3 months
1
0
0
0
[dchapyshev] 72694: [GETUNAME] Add import library for nls2txt
by dchapyshev@svn.reactos.org
Author: dchapyshev Date: Thu Sep 15 21:17:03 2016 New Revision: 72694 URL:
http://svn.reactos.org/svn/reactos?rev=72694&view=rev
Log: [GETUNAME] Add import library for nls2txt Modified: trunk/reactos/dll/win32/getuname/CMakeLists.txt Modified: trunk/reactos/dll/win32/getuname/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/getuname/CMakeLi…
============================================================================== --- trunk/reactos/dll/win32/getuname/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/dll/win32/getuname/CMakeLists.txt [iso-8859-1] Thu Sep 15 21:17:03 2016 @@ -1,6 +1,6 @@ include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine) -spec2def(getuname.dll getuname.spec) +spec2def(getuname.dll getuname.spec ADD_IMPORTLIB) add_library(getuname SHARED getuname.c
8 years, 3 months
1
0
0
0
[dchapyshev] 72693: [ROSAPPS] Add NLS to TXT file converter
by dchapyshev@svn.reactos.org
Author: dchapyshev Date: Thu Sep 15 21:13:26 2016 New Revision: 72693 URL:
http://svn.reactos.org/svn/reactos?rev=72693&view=rev
Log: [ROSAPPS] Add NLS to TXT file converter Added: trunk/rosapps/applications/devutils/nls2txt/ trunk/rosapps/applications/devutils/nls2txt/CMakeLists.txt (with props) trunk/rosapps/applications/devutils/nls2txt/bestfit.c (with props) trunk/rosapps/applications/devutils/nls2txt/main.c (with props) trunk/rosapps/applications/devutils/nls2txt/nls.c (with props) trunk/rosapps/applications/devutils/nls2txt/nls2txt.rc (with props) trunk/rosapps/applications/devutils/nls2txt/precomp.h (with props) Modified: trunk/rosapps/applications/devutils/CMakeLists.txt Modified: trunk/rosapps/applications/devutils/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/CMak…
============================================================================== --- trunk/rosapps/applications/devutils/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rosapps/applications/devutils/CMakeLists.txt [iso-8859-1] Thu Sep 15 21:13:26 2016 @@ -3,6 +3,7 @@ add_subdirectory(gdb2) add_subdirectory(gdihv) add_subdirectory(genguid) +add_subdirectory(nls2txt) add_subdirectory(shimdbg) add_subdirectory(symdump) add_subdirectory(syscalldump) Added: trunk/rosapps/applications/devutils/nls2txt/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/nls2…
============================================================================== --- trunk/rosapps/applications/devutils/nls2txt/CMakeLists.txt (added) +++ trunk/rosapps/applications/devutils/nls2txt/CMakeLists.txt [iso-8859-1] Thu Sep 15 21:13:26 2016 @@ -0,0 +1,12 @@ + +list(APPEND SOURCE + main.c + nls.c + bestfit.c + precomp.h) + +add_executable(nls2txt ${SOURCE} nls2txt.rc) +add_pch(nls2txt precomp.h SOURCE) +set_module_type(nls2txt win32cui UNICODE) +add_importlibs(nls2txt user32 gdi32 comdlg32 comctl32 getuname msvcrt kernel32) +add_cd_file(TARGET nls2txt DESTINATION reactos/system32 FOR all) Propchange: trunk/rosapps/applications/devutils/nls2txt/CMakeLists.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rosapps/applications/devutils/nls2txt/bestfit.c URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/nls2…
============================================================================== --- trunk/rosapps/applications/devutils/nls2txt/bestfit.c (added) +++ trunk/rosapps/applications/devutils/nls2txt/bestfit.c [iso-8859-1] Thu Sep 15 21:13:26 2016 @@ -0,0 +1,282 @@ +/* + * PROJECT: ReactOS NLS to TXT Converter + * LICENSE: GNU General Public License Version 2.0 or any later version + * FILE: devutils/nls2txt/bestfit.c + * COPYRIGHT: Copyright 2016 Dmitry Chapyshev <dmitry(a)reactos.org> + */ + +#include "precomp.h" + +static HANDLE +BestFit_CreateFile(const WCHAR *pszFile) +{ + DWORD dwBytesWritten; + HANDLE hFile; + + hFile = CreateFileW(pszFile, + GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (hFile != INVALID_HANDLE_VALUE) + { + /* Write UTF-8 BOM */ + WriteFile(hFile, "\xEF\xBB\xBF", 3, &dwBytesWritten, NULL); + } + + return hFile; +} + +static VOID +BestFit_CloseFile(HANDLE hFile) +{ + CloseHandle(hFile); +} + +static CHAR* +UTF8fromUNICODE(const WCHAR *pszInput, PSIZE_T Size) +{ + ULONG Length; + CHAR *pszOutput; + + if (!pszInput || !Size) return NULL; + + Length = WideCharToMultiByte(CP_UTF8, 0, pszInput, -1, NULL, 0, NULL, NULL); + + *Size = Length * sizeof(CHAR); + + pszOutput = (CHAR *) malloc(*Size); + if (pszOutput) + { + WideCharToMultiByte(CP_UTF8, 0, pszInput, -1, pszOutput, Length, NULL, NULL); + } + + return pszOutput; +} + +static VOID +BestFit_Write(HANDLE hFile, const WCHAR *pszFormat, ...) +{ + LARGE_INTEGER FileSize; + LARGE_INTEGER MoveTo; + LARGE_INTEGER NewPos; + DWORD dwBytesWritten; + + if (hFile == INVALID_HANDLE_VALUE) + return; + + MoveTo.QuadPart = 0; + if (!SetFilePointerEx(hFile, MoveTo, &NewPos, FILE_END)) + return; + + if (!GetFileSizeEx(hFile, &FileSize)) + return; + + if (LockFile(hFile, (DWORD_PTR)NewPos.QuadPart, 0, (DWORD_PTR)FileSize.QuadPart, 0)) + { + WCHAR *pszString; + CHAR *pszUtf8; + va_list Args; + SIZE_T Size; + + va_start(Args, pszFormat); + + Size = (_vscwprintf(pszFormat, Args) + 1) * sizeof(WCHAR); + pszString = (WCHAR*) malloc(Size); + + if (!pszString) + { + UnlockFile(hFile, (DWORD_PTR)NewPos.QuadPart, 0, (DWORD_PTR)FileSize.QuadPart, 0); + va_end(Args); + return; + } + + StringCbVPrintfW(pszString, Size, pszFormat, Args); + va_end(Args); + + pszUtf8 = UTF8fromUNICODE(pszString, &Size); + if (pszUtf8) + { + WriteFile(hFile, pszUtf8, Size - sizeof(CHAR), &dwBytesWritten, NULL); + free(pszUtf8); + } + + free(pszString); + + UnlockFile(hFile, (DWORD_PTR)NewPos.QuadPart, 0, (DWORD_PTR)FileSize.QuadPart, 0); + } +} + +BOOL +BestFit_FromNLS(const WCHAR *pszNLSFile, const WCHAR *pszBestFitFile) +{ + CPTABLEINFO CodePageTable; + PUSHORT CodePage; + HANDLE hFile; + USHORT CodePageChar; + ULONG UnicodeChar; + + CodePage = NLS_ReadFile(pszNLSFile, &CodePageTable); + if (CodePage == NULL) + return FALSE; + + hFile = BestFit_CreateFile(pszBestFitFile); + if (hFile == INVALID_HANDLE_VALUE) + { + free(CodePage); + return FALSE; + } + + /* The only field is the decimal windows code page number for this code page. */ + BestFit_Write(hFile, L"CODEPAGE %u\r\n\r\n", CodePageTable.CodePage); + + BestFit_Write(hFile, + L"CPINFO %u 0x%02X 0x%04X\r\n\r\n", + /* "1" for a single byte code page, "2" for a double byte code page */ + CodePageTable.MaximumCharacterSize, + /* Replacement characters for unassigned Unicode code points when + written to this code page */ + CodePageTable.DefaultChar, + /* Replacement characters for illegal or unassigned code page values + when converting to Unicode. */ + CodePageTable.UniDefaultChar); + + /* This field contains the number of following records of code page to Unicode mappings. */ + BestFit_Write(hFile, L"MBTABLE %u\r\n\r\n", NLS_RecordsCountForMBTable(&CodePageTable)); + + for (CodePageChar = 0; CodePageChar <= 0xFF; CodePageChar++) + { + if (!NLS_IsDefaultCharForMB(&CodePageTable, CodePageChar)) + { + WCHAR szCharName[MAX_STR_LEN] = { 0 }; + + GetUName(CodePageTable.MultiByteTable[CodePageChar], szCharName); + + BestFit_Write(hFile, + L"0x%02X 0x%04X ;%s\r\n", + CodePageChar, + CodePageTable.MultiByteTable[CodePageChar], + szCharName); + } + } + + BestFit_Write(hFile, L"\r\n"); + + if (NLS_IsGlyphTablePresent(&CodePageTable)) + { + PUSHORT GlyphTable = CodePageTable.MultiByteTable + 256 + 1; + + BestFit_Write(hFile, L"GLYPHTABLE %u\r\n\r\n", NLS_RecordsCountForGlyphTable(&CodePageTable)); + + for (CodePageChar = 0; CodePageChar <= 0xFF; CodePageChar++) + { + WCHAR szCharName[MAX_STR_LEN] = { 0 }; + + GetUName(GlyphTable[CodePageChar], szCharName); + + BestFit_Write(hFile, + L"0x%02X 0x%04X ;%s\r\n", + CodePageChar, + GlyphTable[CodePageChar], + szCharName); + } + + BestFit_Write(hFile, L"\r\n"); + } + + if (NLS_IsDBCSCodePage(&CodePageTable)) + { + PUSHORT LeadByteRanges = (PUSHORT)&CodePageTable.LeadByte[0]; + USHORT Index; + USHORT LeadByte; + + BestFit_Write(hFile, + L"DBCSRANGE %u ;%u DBCS Lead Byte Ranges\r\n\r\n", + CodePageTable.DBCSRanges[0], + CodePageTable.DBCSRanges[0]); + + for (Index = 0; Index < MAXIMUM_LEADBYTES / 2; Index++) + { + if (!LeadByteRanges[Index]) + continue; + + BestFit_Write(hFile, + L"0x%X 0x%X ;Lead Byte Range %u\r\n\r\n", + LOBYTE(LeadByteRanges[Index]), + HIBYTE(LeadByteRanges[Index]), + Index + 1); + + for (LeadByte = LOBYTE(LeadByteRanges[Index]); + LeadByte <= HIBYTE(LeadByteRanges[Index]); + LeadByte++) + { + PUSHORT LeadByteInfo = CodePageTable.DBCSOffsets; + + BestFit_Write(hFile, + L"DBCSTABLE %u ;Range = %u, LeadByte = 0x%02X\r\n\r\n", + NLS_RecordsCountForDBCSTable(&CodePageTable, LeadByte), + Index + 1, + LeadByte); + + for (CodePageChar = 0; CodePageChar <= 0xFF; CodePageChar++) + { + USHORT Info = LeadByteInfo[LeadByte]; + + if (Info && LeadByteInfo[Info + CodePageChar] != CodePageTable.UniDefaultChar) + { + BestFit_Write(hFile, + L"0x%02X 0x%04X\r\n", + CodePageChar, + LeadByteInfo[Info + CodePageChar]); + } + } + + BestFit_Write(hFile, L"\r\n"); + } + } + } + + /* This field contains the number of records of Unicode to byte mappings. */ + BestFit_Write(hFile, L"WCTABLE %u\r\n\r\n", NLS_RecordsCountForUnicodeTable(&CodePageTable)); + + for (UnicodeChar = 0; UnicodeChar <= 0xFFFF; UnicodeChar++) + { + if (!NLS_IsDefaultCharForUnicode(&CodePageTable, UnicodeChar)) + { + WCHAR szCharName[MAX_STR_LEN] = { 0 }; + + GetUName(UnicodeChar, szCharName); + + if (NLS_IsDBCSCodePage(&CodePageTable)) + { + PUSHORT MultiByteTable = (PUSHORT)CodePageTable.WideCharTable; + + BestFit_Write(hFile, + L"0x%04X 0x%04X ;%s\r\n", + UnicodeChar, + MultiByteTable[UnicodeChar], + szCharName); + } + else + { + PUCHAR SingleByteTable = (PUCHAR)CodePageTable.WideCharTable; + + BestFit_Write(hFile, + L"0x%04X 0x%02X ;%s\r\n", + UnicodeChar, + SingleByteTable[UnicodeChar], + szCharName); + } + } + } + + /* This tag marks the end of the code page data. Anything after this marker is ignored. */ + BestFit_Write(hFile, L"\r\nENDCODEPAGE\r\n"); + + BestFit_CloseFile(hFile); + free(CodePage); + + return TRUE; +} Propchange: trunk/rosapps/applications/devutils/nls2txt/bestfit.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rosapps/applications/devutils/nls2txt/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/nls2…
============================================================================== --- trunk/rosapps/applications/devutils/nls2txt/main.c (added) +++ trunk/rosapps/applications/devutils/nls2txt/main.c [iso-8859-1] Thu Sep 15 21:13:26 2016 @@ -0,0 +1,19 @@ +/* + * PROJECT: ReactOS NLS to TXT Converter + * LICENSE: GNU General Public License Version 2.0 or any later version + * FILE: devutils/nls2txt/main.c + * COPYRIGHT: Copyright 2016 Dmitry Chapyshev <dmitry(a)reactos.org> + */ + +#include "precomp.h" + +INT wmain(INT argc, WCHAR* argv[]) +{ + if (argc != 3) + return 1; + + if (!BestFit_FromNLS(argv[1], argv[2])) + return 1; + + return 0; +} Propchange: trunk/rosapps/applications/devutils/nls2txt/main.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rosapps/applications/devutils/nls2txt/nls.c URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/nls2…
============================================================================== --- trunk/rosapps/applications/devutils/nls2txt/nls.c (added) +++ trunk/rosapps/applications/devutils/nls2txt/nls.c [iso-8859-1] Thu Sep 15 21:13:26 2016 @@ -0,0 +1,203 @@ +/* + * PROJECT: ReactOS NLS to TXT Converter + * LICENSE: GNU General Public License Version 2.0 or any later version + * FILE: devutils/nlsedit/nls.c + * COPYRIGHT: Copyright 2016 Dmitry Chapyshev <dmitry(a)reactos.org> + */ + +#include "precomp.h" + +static VOID +NLS_InitCodePageTable(PUSHORT TableBase, PCPTABLEINFO CodePageTable) +{ + PNLS_FILE_HEADER NlsFileHeader; + + NlsFileHeader = (PNLS_FILE_HEADER)TableBase; + + /* Copy header fields first */ + CodePageTable->CodePage = NlsFileHeader->CodePage; + CodePageTable->MaximumCharacterSize = NlsFileHeader->MaximumCharacterSize; + CodePageTable->DefaultChar = NlsFileHeader->DefaultChar; + CodePageTable->UniDefaultChar = NlsFileHeader->UniDefaultChar; + CodePageTable->TransDefaultChar = NlsFileHeader->TransDefaultChar; + CodePageTable->TransUniDefaultChar = NlsFileHeader->TransUniDefaultChar; + + CopyMemory(&CodePageTable->LeadByte, &NlsFileHeader->LeadByte, MAXIMUM_LEADBYTES); + + /* Offset to wide char table is after the header */ + CodePageTable->WideCharTable = TableBase + NlsFileHeader->HeaderSize + 1 + + TableBase[NlsFileHeader->HeaderSize]; + + /* Then multibyte table (256 wchars) follows */ + CodePageTable->MultiByteTable = TableBase + NlsFileHeader->HeaderSize + 1; + + /* Check the presence of glyph table (256 wchars) */ + if (!CodePageTable->MultiByteTable[256]) + { + CodePageTable->DBCSRanges = CodePageTable->MultiByteTable + 256 + 1; + } + else + { + CodePageTable->DBCSRanges = CodePageTable->MultiByteTable + 256 + 1 + 256; + } + + /* Is this double-byte code page? */ + if (*CodePageTable->DBCSRanges) + { + CodePageTable->DBCSCodePage = 1; + CodePageTable->DBCSOffsets = CodePageTable->DBCSRanges + 1; + } + else + { + CodePageTable->DBCSCodePage = 0; + CodePageTable->DBCSOffsets = NULL; + } +} + +PUSHORT +NLS_ReadFile(const WCHAR *pszFile, PCPTABLEINFO CodePageTable) +{ + HANDLE hFile; + + hFile = CreateFile(pszFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + if (hFile != INVALID_HANDLE_VALUE) + { + PUSHORT pData = NULL; + DWORD dwRead; + DWORD dwFileSize; + + dwFileSize = GetFileSize(hFile, NULL); + pData = malloc(dwFileSize); + if (pData != NULL) + { + if (ReadFile(hFile, pData, dwFileSize, &dwRead, NULL) != FALSE) + { + NLS_InitCodePageTable(pData, CodePageTable); + CloseHandle(hFile); + + return pData; + } + + free(pData); + } + + CloseHandle(hFile); + } + + return NULL; +} + +BOOL +NLS_IsDBCSCodePage(PCPTABLEINFO CodePageTable) +{ + return (BOOL)CodePageTable->DBCSCodePage; +} + +BOOL +NLS_IsGlyphTablePresent(PCPTABLEINFO CodePageTable) +{ + return (CodePageTable->MultiByteTable[256]) ? TRUE : FALSE; +} + +BOOL +NLS_IsDefaultCharForMB(PCPTABLEINFO CodePageTable, UCHAR Char) +{ + if (CodePageTable->MultiByteTable[Char] != CodePageTable->UniDefaultChar) + return FALSE; + + return TRUE; +} + +BOOL +NLS_IsDefaultCharForUnicode(PCPTABLEINFO CodePageTable, USHORT Char) +{ + USHORT CodePageChar; + + if (NLS_IsDBCSCodePage(CodePageTable)) + { + PUSHORT MultiByteTable = (PUSHORT)CodePageTable->WideCharTable; + CodePageChar = MultiByteTable[Char]; + } + else + { + PUCHAR SingleByteTable = (PUCHAR)CodePageTable->WideCharTable; + CodePageChar = SingleByteTable[Char]; + } + + if (CodePageChar != CodePageTable->DefaultChar) + return FALSE; + + return TRUE; +} + +USHORT +NLS_RecordsCountForMBTable(PCPTABLEINFO CodePageTable) +{ + USHORT CodePageChar; + USHORT Count = 0; + + for (CodePageChar = 0; CodePageChar <= 0xFF; CodePageChar++) + { + if (!NLS_IsDefaultCharForMB(CodePageTable, CodePageChar)) + Count++; + } + + return Count; +} + +USHORT +NLS_RecordsCountForUnicodeTable(PCPTABLEINFO CodePageTable) +{ + ULONG UnicodeChar; + USHORT Count = 0; + + for (UnicodeChar = 0; UnicodeChar <= 0xFFFF; UnicodeChar++) + { + if (!NLS_IsDefaultCharForUnicode(CodePageTable, UnicodeChar)) + Count++; + } + + return Count; +} + +USHORT +NLS_RecordsCountForGlyphTable(PCPTABLEINFO CodePageTable) +{ + USHORT Count = 0; + + if (NLS_IsGlyphTablePresent(CodePageTable)) + { + PUSHORT GlyphTable = CodePageTable->MultiByteTable + 256 + 1; + USHORT CodePageChar; + + for (CodePageChar = 0; CodePageChar <= 0xFF; CodePageChar++) + { + USHORT Char = GlyphTable[CodePageChar]; + + if (Char != CodePageTable->UniDefaultChar) + Count++; + } + } + + return Count; +} + +USHORT +NLS_RecordsCountForDBCSTable(PCPTABLEINFO CodePageTable, UCHAR LeadByte) +{ + PUSHORT LeadByteInfo = CodePageTable->DBCSOffsets; + USHORT CodePageChar; + USHORT Count = 0; + + for (CodePageChar = 0; CodePageChar <= 0xFF; CodePageChar++) + { + USHORT Info = LeadByteInfo[LeadByte]; + + if (Info && LeadByteInfo[Info + CodePageChar] != CodePageTable->UniDefaultChar) + { + Count++; + } + } + + return Count; +} Propchange: trunk/rosapps/applications/devutils/nls2txt/nls.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rosapps/applications/devutils/nls2txt/nls2txt.rc URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/nls2…
============================================================================== --- trunk/rosapps/applications/devutils/nls2txt/nls2txt.rc (added) +++ trunk/rosapps/applications/devutils/nls2txt/nls2txt.rc [iso-8859-1] Thu Sep 15 21:13:26 2016 @@ -0,0 +1,18 @@ +/* + * PROJECT: ReactOS NLS to TXT Converter + * LICENSE: GNU General Public License Version 2.0 or any later version + * FILE: devutils/nls2txt/nls2txt.rc + * COPYRIGHT: Copyright 2016 Dmitry Chapyshev <dmitry(a)reactos.org> + */ + +#include <windows.h> +#include <commctrl.h> + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS NLS to TXT Converter" +#define REACTOS_STR_INTERNAL_NAME "nls2txt" +#define REACTOS_STR_ORIGINAL_FILENAME "nls2txt.exe" +#include <reactos/version.rc> + +#include <reactos/manifest_exe.rc> Propchange: trunk/rosapps/applications/devutils/nls2txt/nls2txt.rc ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rosapps/applications/devutils/nls2txt/precomp.h URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/devutils/nls2…
============================================================================== --- trunk/rosapps/applications/devutils/nls2txt/precomp.h (added) +++ trunk/rosapps/applications/devutils/nls2txt/precomp.h [iso-8859-1] Thu Sep 15 21:13:26 2016 @@ -0,0 +1,83 @@ +/* + * PROJECT: ReactOS NLS to TXT Converter + * LICENSE: GNU General Public License Version 2.0 or any later version + * FILE: devutils/nls2txt/precomp.h + * COPYRIGHT: Copyright 2016 Dmitry Chapyshev <dmitry(a)reactos.org> + */ + +#ifndef __PRECOMP_H +#define __PRECOMP_H + +#include <windows.h> +#include <windowsx.h> +#include <commctrl.h> +#include <strsafe.h> + +#define MAX_STR_LEN 256 + +#define MAXIMUM_LEADBYTES 12 + +typedef struct _NLS_FILE_HEADER +{ + USHORT HeaderSize; + USHORT CodePage; + USHORT MaximumCharacterSize; + USHORT DefaultChar; + USHORT UniDefaultChar; + USHORT TransDefaultChar; + USHORT TransUniDefaultChar; + UCHAR LeadByte[MAXIMUM_LEADBYTES]; +} NLS_FILE_HEADER, *PNLS_FILE_HEADER; + +typedef struct _CPTABLEINFO +{ + USHORT CodePage; + USHORT MaximumCharacterSize; /* 1 = SBCS, 2 = DBCS */ + USHORT DefaultChar; /* Default MultiByte Character for the CP->Unicode conversion */ + USHORT UniDefaultChar; /* Default Unicode Character for the CP->Unicode conversion */ + USHORT TransDefaultChar; /* Default MultiByte Character for the Unicode->CP conversion */ + USHORT TransUniDefaultChar; /* Default Unicode Character for the Unicode->CP conversion */ + USHORT DBCSCodePage; + UCHAR LeadByte[MAXIMUM_LEADBYTES]; + PUSHORT MultiByteTable; /* Table for CP->Unicode conversion */ + PVOID WideCharTable; /* Table for Unicode->CP conversion */ + PUSHORT DBCSRanges; + PUSHORT DBCSOffsets; +} CPTABLEINFO, *PCPTABLEINFO; + +int WINAPI +GetUName(IN WORD wCharCode, OUT LPWSTR lpBuf); + +/* nls.c */ +PUSHORT +NLS_ReadFile(const WCHAR *pszFile, PCPTABLEINFO CodePageTable); + +BOOL +NLS_IsDBCSCodePage(PCPTABLEINFO CodePageTable); + +BOOL +NLS_IsGlyphTablePresent(PCPTABLEINFO CodePageTable); + +BOOL +NLS_IsDefaultCharForMB(PCPTABLEINFO CodePageTable, UCHAR Char); + +BOOL +NLS_IsDefaultCharForUnicode(PCPTABLEINFO CodePageTable, USHORT Char); + +USHORT +NLS_RecordsCountForMBTable(PCPTABLEINFO CodePageTable); + +USHORT +NLS_RecordsCountForUnicodeTable(PCPTABLEINFO CodePageTable); + +USHORT +NLS_RecordsCountForGlyphTable(PCPTABLEINFO CodePageTable); + +USHORT +NLS_RecordsCountForDBCSTable(PCPTABLEINFO CodePageTable, UCHAR LeadByte); + +/* bestfit.c */ +BOOL +BestFit_FromNLS(const WCHAR *pszNLSFile, const WCHAR *pszBestFitFile); + +#endif Propchange: trunk/rosapps/applications/devutils/nls2txt/precomp.h ------------------------------------------------------------------------------ svn:eol-style = native
8 years, 3 months
1
0
0
0
[dchapyshev] 72692: [RTL] Add internal RtlpDowncaseUnicodeChar function and use instead RtlDowncaseUnicodeChar internally in RTL. RtlMultiAppendUnicodeStringBuffer parameters are specified (it is d...
by dchapyshev@svn.reactos.org
Author: dchapyshev Date: Thu Sep 15 20:40:29 2016 New Revision: 72692 URL:
http://svn.reactos.org/svn/reactos?rev=72692&view=rev
Log: [RTL] Add internal RtlpDowncaseUnicodeChar function and use instead RtlDowncaseUnicodeChar internally in RTL. RtlMultiAppendUnicodeStringBuffer parameters are specified (it is documented on:
http://undoc.airesoft.co.uk/ntdll.dll/RtlMultiAppendUnicodeStringBuffer.php
) Modified: trunk/reactos/sdk/lib/rtl/nls.c trunk/reactos/sdk/lib/rtl/path.c trunk/reactos/sdk/lib/rtl/rtlp.h trunk/reactos/sdk/lib/rtl/unicode.c Modified: trunk/reactos/sdk/lib/rtl/nls.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/nls.c?rev=7269…
============================================================================== --- trunk/reactos/sdk/lib/rtl/nls.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/rtl/nls.c [iso-8859-1] Thu Sep 15 20:40:29 2016 @@ -86,7 +86,7 @@ * @implemented */ WCHAR NTAPI -RtlDowncaseUnicodeChar(IN WCHAR Source) +RtlpDowncaseUnicodeChar(IN WCHAR Source) { USHORT Offset; @@ -122,6 +122,17 @@ DPRINT("Result: %hx\n", Source + (SHORT)Offset); return Source + (SHORT)Offset; +} + +/* + * @implemented + */ +WCHAR NTAPI +RtlDowncaseUnicodeChar(IN WCHAR Source) +{ + PAGED_CODE_RTL(); + + return RtlpDowncaseUnicodeChar(Source); } /* Modified: trunk/reactos/sdk/lib/rtl/path.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/path.c?rev=726…
============================================================================== --- trunk/reactos/sdk/lib/rtl/path.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/rtl/path.c [iso-8859-1] Thu Sep 15 20:40:29 2016 @@ -163,7 +163,7 @@ { /* Get the next lower case character */ End++; - c = RtlDowncaseUnicodeChar(*End); + c = RtlpDowncaseUnicodeChar(*End); /* Check if it's a DOS device (LPT, COM, PRN, AUX, or NUL) */ if ((End < &PathCopy.Buffer[OriginalLength / sizeof(WCHAR)]) && @@ -189,7 +189,7 @@ } /* Get the next lower case character and check if it's a DOS device */ - c = RtlDowncaseUnicodeChar(*PathCopy.Buffer); + c = RtlpDowncaseUnicodeChar(*PathCopy.Buffer); if ((c != L'l') && (c != L'c') && (c != L'p') && (c != L'a') && (c != L'n')) { /* Not LPT, COM, PRN, AUX, or NUL */ Modified: trunk/reactos/sdk/lib/rtl/rtlp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/rtlp.h?rev=726…
============================================================================== --- trunk/reactos/sdk/lib/rtl/rtlp.h [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/rtl/rtlp.h [iso-8859-1] Thu Sep 15 20:40:29 2016 @@ -235,4 +235,8 @@ NTAPI RtlpUpcaseUnicodeChar(IN WCHAR Source); +WCHAR +NTAPI +RtlpDowncaseUnicodeChar(IN WCHAR Source); + /* EOF */ Modified: trunk/reactos/sdk/lib/rtl/unicode.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/unicode.c?rev=…
============================================================================== --- trunk/reactos/sdk/lib/rtl/unicode.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/rtl/unicode.c [iso-8859-1] Thu Sep 15 20:40:29 2016 @@ -34,9 +34,9 @@ NTSTATUS NTAPI -RtlMultiAppendUnicodeStringBuffer(IN PVOID Unknown, - IN ULONG Unknown2, - IN PVOID Unknown3) +RtlMultiAppendUnicodeStringBuffer(OUT PRTL_UNICODE_STRING_BUFFER StringBuffer, + IN ULONG NumberOfAddends, + IN PCUNICODE_STRING Addends) { UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; @@ -2376,7 +2376,7 @@ } else { - UniDest->Buffer[i] = RtlDowncaseUnicodeChar(UniSource->Buffer[i]); + UniDest->Buffer[i] = RtlpDowncaseUnicodeChar(UniSource->Buffer[i]); } }
8 years, 3 months
1
0
0
0
[dchapyshev] 72691: [RTL] Add internal RtlpUpcaseUnicodeChar function and use instead RtlUpcaseUnicodeChar internally in RTL
by dchapyshev@svn.reactos.org
Author: dchapyshev Date: Thu Sep 15 20:05:26 2016 New Revision: 72691 URL:
http://svn.reactos.org/svn/reactos?rev=72691&view=rev
Log: [RTL] Add internal RtlpUpcaseUnicodeChar function and use instead RtlUpcaseUnicodeChar internally in RTL Modified: trunk/reactos/sdk/lib/rtl/dos8dot3.c trunk/reactos/sdk/lib/rtl/nls.c trunk/reactos/sdk/lib/rtl/path.c trunk/reactos/sdk/lib/rtl/rtlp.h trunk/reactos/sdk/lib/rtl/unicode.c trunk/reactos/sdk/lib/rtl/unicodeprefix.c Modified: trunk/reactos/sdk/lib/rtl/dos8dot3.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/dos8dot3.c?rev…
============================================================================== --- trunk/reactos/sdk/lib/rtl/dos8dot3.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/rtl/dos8dot3.c [iso-8859-1] Thu Sep 15 20:05:26 2016 @@ -113,7 +113,7 @@ if (RtlpIsShortIllegal(Char)) Char = L'_'; else if (Char >= L'a' && Char <= L'z') - Char = RtlUpcaseUnicodeChar(Char); + Char = RtlpUpcaseUnicodeChar(Char); Context->NameBuffer[Context->NameLength] = Char; ++Context->NameLength; @@ -137,7 +137,7 @@ if (RtlpIsShortIllegal(Char)) Char = L'_'; else if (Char >= L'a' && Char <= L'z') - Char = RtlUpcaseUnicodeChar(Char); + Char = RtlpUpcaseUnicodeChar(Char); Context->ExtensionBuffer[Context->ExtensionLength++] = Char; } Modified: trunk/reactos/sdk/lib/rtl/nls.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/nls.c?rev=7269…
============================================================================== --- trunk/reactos/sdk/lib/rtl/nls.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/rtl/nls.c [iso-8859-1] Thu Sep 15 20:05:26 2016 @@ -54,7 +54,7 @@ PAGED_CODE_RTL(); - if (CustomCP->DBCSCodePage == 0) + if (!CustomCP->DBCSCodePage) { /* single-byte code page */ if (CustomSize > (UnicodeSize / sizeof(WCHAR))) @@ -62,7 +62,7 @@ else Size = CustomSize; - if (ResultSize != NULL) + if (ResultSize) *ResultSize = Size * sizeof(WCHAR); for (i = 0; i < Size; i++) @@ -206,7 +206,6 @@ if (AnsiTableBase && OemTableBase && CaseTableBase) { RtlInitCodePageTable(AnsiTableBase, &NlsTable->AnsiTableInfo); - RtlInitCodePageTable(OemTableBase, &NlsTable->OemTableInfo); NlsTable->UpperCaseTable = (PUSHORT)CaseTableBase + 2; @@ -229,7 +228,7 @@ PAGED_CODE_RTL(); - if (NlsMbCodePageTag == FALSE) + if (!NlsMbCodePageTag) { /* single-byte code page */ if (MbSize > (UnicodeSize / sizeof(WCHAR))) @@ -237,7 +236,7 @@ else Size = MbSize; - if (ResultSize != NULL) + if (ResultSize) *ResultSize = Size * sizeof(WCHAR); for (i = 0; i < Size; i++) @@ -274,7 +273,7 @@ *UnicodeString++ = NlsLeadByteInfo[LeadByteInfo + *(PUCHAR)MbString++]; } - if (ResultSize != NULL) + if (ResultSize) *ResultSize = i * sizeof(WCHAR); } @@ -369,7 +368,7 @@ PAGED_CODE_RTL(); - if (NlsMbOemCodePageTag == FALSE) + if (!NlsMbOemCodePageTag) { /* single-byte code page */ if (OemSize > (UnicodeSize / sizeof(WCHAR))) @@ -377,7 +376,7 @@ else Size = OemSize; - if (ResultSize != NULL) + if (ResultSize) *ResultSize = Size * sizeof(WCHAR); for (i = 0; i < Size; i++) @@ -419,7 +418,7 @@ NlsOemLeadByteInfo[OemLeadByteInfo + *(PUCHAR)OemString++]; } - if (ResultSize != NULL) + if (ResultSize) *ResultSize = i * sizeof(WCHAR); } @@ -479,7 +478,7 @@ PAGED_CODE_RTL(); - if (CustomCP->DBCSCodePage == 0) + if (!CustomCP->DBCSCodePage) { /* single-byte code page */ if (UnicodeSize > (CustomSize * sizeof(WCHAR))) @@ -487,7 +486,7 @@ else Size = UnicodeSize / sizeof(WCHAR); - if (ResultSize != NULL) + if (ResultSize) *ResultSize = Size; for (i = 0; i < Size; i++) @@ -522,16 +521,14 @@ PAGED_CODE_RTL(); - if (NlsMbCodePageTag == FALSE) + if (!NlsMbCodePageTag) { /* single-byte code page */ Size = (UnicodeSize > (MbSize * sizeof (WCHAR))) ? MbSize : (UnicodeSize / sizeof (WCHAR)); - if (ResultSize != NULL) - { + if (ResultSize) *ResultSize = Size; - } for (i = 0; i < Size; i++) { @@ -573,7 +570,7 @@ else break; } - if (ResultSize != NULL) + if (ResultSize) *ResultSize = MbSize - i; } @@ -640,7 +637,7 @@ PAGED_CODE_RTL(); - if (NlsMbOemCodePageTag == FALSE) + if (!NlsMbOemCodePageTag) { /* single-byte code page */ if (UnicodeSize > (OemSize * sizeof(WCHAR))) @@ -648,7 +645,7 @@ else Size = UnicodeSize / sizeof(WCHAR); - if (ResultSize != NULL) + if (ResultSize) *ResultSize = Size; for (i = 0; i < Size; i++) @@ -693,11 +690,37 @@ else break; } - if (ResultSize != NULL) + if (ResultSize) *ResultSize = OemSize - i; } return STATUS_SUCCESS; +} + +/* + * @implemented + */ +WCHAR NTAPI +RtlpUpcaseUnicodeChar(IN WCHAR Source) +{ + USHORT Offset; + + if (Source < 'a') + return Source; + + if (Source <= 'z') + return (Source - ('a' - 'A')); + + Offset = ((USHORT)Source >> 8) & 0xFF; + Offset = NlsUnicodeUpcaseTable[Offset]; + + Offset += ((USHORT)Source >> 4) & 0xF; + Offset = NlsUnicodeUpcaseTable[Offset]; + + Offset += ((USHORT)Source & 0xF); + Offset = NlsUnicodeUpcaseTable[Offset]; + + return Source + (SHORT)Offset; } /* @@ -706,26 +729,9 @@ WCHAR NTAPI RtlUpcaseUnicodeChar(IN WCHAR Source) { - USHORT Offset; - - PAGED_CODE_RTL(); - - if (Source < 'a') - return Source; - - if (Source <= 'z') - return (Source - ('a' - 'A')); - - Offset = ((USHORT)Source >> 8) & 0xFF; - Offset = NlsUnicodeUpcaseTable[Offset]; - - Offset += ((USHORT)Source >> 4) & 0xF; - Offset = NlsUnicodeUpcaseTable[Offset]; - - Offset += ((USHORT)Source & 0xF); - Offset = NlsUnicodeUpcaseTable[Offset]; - - return Source + (SHORT)Offset; + PAGED_CODE_RTL(); + + return RtlpUpcaseUnicodeChar(Source); } /* @@ -758,7 +764,7 @@ for (i = 0; i < Size; i++) { - UpcaseChar = RtlUpcaseUnicodeChar(*UnicodeString); + UpcaseChar = RtlpUpcaseUnicodeChar(*UnicodeString); *CustomString = ((PCHAR)CustomCP->WideCharTable)[UpcaseChar]; ++CustomString; ++UnicodeString; @@ -790,7 +796,7 @@ PAGED_CODE_RTL(); - if (NlsMbCodePageTag == FALSE) + if (!NlsMbCodePageTag) { /* single-byte code page */ if (UnicodeSize > (MbSize * sizeof(WCHAR))) @@ -798,12 +804,12 @@ else Size = UnicodeSize / sizeof(WCHAR); - if (ResultSize != NULL) + if (ResultSize) *ResultSize = Size; for (i = 0; i < Size; i++) { - UpcaseChar = RtlUpcaseUnicodeChar(*UnicodeString); + UpcaseChar = RtlpUpcaseUnicodeChar(*UnicodeString); *MbString = NlsUnicodeToAnsiTable[UpcaseChar]; MbString++; UnicodeString++; @@ -837,7 +843,7 @@ ASSERT(NlsUnicodeToOemTable != NULL); - if (NlsMbOemCodePageTag == FALSE) + if (!NlsMbOemCodePageTag) { /* single-byte code page */ if (UnicodeSize > (OemSize * sizeof(WCHAR))) @@ -845,12 +851,12 @@ else Size = UnicodeSize / sizeof(WCHAR); - if (ResultSize != NULL) + if (ResultSize) *ResultSize = Size; for (i = 0; i < Size; i++) { - UpcaseChar = RtlUpcaseUnicodeChar(*UnicodeString); + UpcaseChar = RtlpUpcaseUnicodeChar(*UnicodeString); *OemString = NlsUnicodeToOemTable[UpcaseChar]; OemString++; UnicodeString++; @@ -866,7 +872,7 @@ for (i = OemSize, Size = UnicodeSize / sizeof(WCHAR); i && Size; i--, Size--) { - WideChar = RtlUpcaseUnicodeChar(*UnicodeString++); + WideChar = RtlpUpcaseUnicodeChar(*UnicodeString++); if (WideChar < 0x80) { @@ -891,7 +897,7 @@ else break; } - if (ResultSize != NULL) + if (ResultSize) *ResultSize = OemSize - i; } @@ -926,7 +932,7 @@ } else { - if (NlsMbCodePageTag == FALSE) + if (!NlsMbCodePageTag) { /* single-byte code page */ @@ -934,7 +940,7 @@ Unicode = NlsAnsiToUnicodeTable[(UCHAR)Source]; /* upcase conversion */ - Unicode = RtlUpcaseUnicodeChar (Unicode); + Unicode = RtlpUpcaseUnicodeChar (Unicode); /* unicode -> ansi */ Destination = NlsUnicodeToAnsiTable[(USHORT)Unicode]; Modified: trunk/reactos/sdk/lib/rtl/path.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/path.c?rev=726…
============================================================================== --- trunk/reactos/sdk/lib/rtl/path.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/rtl/path.c [iso-8859-1] Thu Sep 15 20:05:26 2016 @@ -614,7 +614,7 @@ ASSERT(FileNameBuffer[1] == L':'); ASSERT(IS_PATH_SEPARATOR(FileNameBuffer[2])); - // FileNameBuffer[0] = RtlUpcaseUnicodeChar(FileNameBuffer[0]); + // FileNameBuffer[0] = RtlpUpcaseUnicodeChar(FileNameBuffer[0]); Prefix = FileNameBuffer; PrefixLength = 3 * sizeof(WCHAR); Source += 3; @@ -631,8 +631,8 @@ Source += 2; SourceLength -= 2 * sizeof(WCHAR); - CurDrive = RtlUpcaseUnicodeChar(CurDirName->Buffer[0]); - NewDrive = RtlUpcaseUnicodeChar(FileNameBuffer[0]); + CurDrive = RtlpUpcaseUnicodeChar(CurDirName->Buffer[0]); + NewDrive = RtlpUpcaseUnicodeChar(FileNameBuffer[0]); if ((NewDrive != CurDrive) || CurDirName->Buffer[1] != L':') { Modified: trunk/reactos/sdk/lib/rtl/rtlp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/rtlp.h?rev=726…
============================================================================== --- trunk/reactos/sdk/lib/rtl/rtlp.h [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/rtl/rtlp.h [iso-8859-1] Thu Sep 15 20:05:26 2016 @@ -230,4 +230,9 @@ ULONG64 NumberOfBits; } RTL_BITMAP_RUN64, *PRTL_BITMAP_RUN64; +/* nls.c */ +WCHAR +NTAPI +RtlpUpcaseUnicodeChar(IN WCHAR Source); + /* EOF */ Modified: trunk/reactos/sdk/lib/rtl/unicode.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/unicode.c?rev=…
============================================================================== --- trunk/reactos/sdk/lib/rtl/unicode.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/rtl/unicode.c [iso-8859-1] Thu Sep 15 20:05:26 2016 @@ -528,7 +528,7 @@ Offset = NlsOemLeadByteInfo[HIBYTE(OemChar)]; /* Receive Unicode character from the table */ - UnicodeChar = RtlUpcaseUnicodeChar(NlsOemToUnicodeTable[LOBYTE(OemChar) + Offset]); + UnicodeChar = RtlpUpcaseUnicodeChar(NlsOemToUnicodeTable[LOBYTE(OemChar) + Offset]); /* Receive OEM character from the table */ OemChar = NlsUnicodeToMbOemTable[UnicodeChar]; @@ -536,7 +536,7 @@ else { /* Receive Unicode character from the table */ - UnicodeChar = RtlUpcaseUnicodeChar(NlsOemToUnicodeTable[(UCHAR)NlsUnicodeToOemTable[*Char]]); + UnicodeChar = RtlpUpcaseUnicodeChar(NlsOemToUnicodeTable[(UCHAR)NlsUnicodeToOemTable[*Char]]); /* Receive OEM character from the table */ OemChar = NlsUnicodeToOemTable[UnicodeChar]; @@ -742,11 +742,11 @@ } else if (len == length) { - memcpy(str, pos, len); + RtlCopyMemory(str, pos, len); } else { - memcpy(str, pos, len + 1); + RtlCopyMemory(str, pos, len + 1); } return STATUS_SUCCESS; @@ -943,8 +943,8 @@ { while (NumChars--) { - if (RtlUpcaseUnicodeChar(*pc1++) != - RtlUpcaseUnicodeChar(*pc2++)) + if (RtlpUpcaseUnicodeChar(*pc1++) != + RtlpUpcaseUnicodeChar(*pc2++)) return FALSE; } } @@ -1924,7 +1924,7 @@ for (i = 0; i < j; i++) { - UniDest->Buffer[i] = RtlUpcaseUnicodeChar(UniSource->Buffer[i]); + UniDest->Buffer[i] = RtlpUpcaseUnicodeChar(UniSource->Buffer[i]); } UniDest->Length = UniSource->Length; @@ -2196,7 +2196,7 @@ if (CaseInsensitive) { - while (!ret && len--) ret = RtlUpcaseUnicodeChar(*p1++) - RtlUpcaseUnicodeChar(*p2++); + while (!ret && len--) ret = RtlpUpcaseUnicodeChar(*p1++) - RtlpUpcaseUnicodeChar(*p2++); } else { @@ -2586,13 +2586,13 @@ USHORT i; if (CaseInSensitive) - Char = RtlUpcaseUnicodeChar(Char); + Char = RtlpUpcaseUnicodeChar(Char); for (i = 0; i < MatchString->Length / sizeof(WCHAR); i++) { WCHAR OtherChar = MatchString->Buffer[i]; if (CaseInSensitive) - OtherChar = RtlUpcaseUnicodeChar(OtherChar); + OtherChar = RtlpUpcaseUnicodeChar(OtherChar); if (Char == OtherChar) return TRUE; Modified: trunk/reactos/sdk/lib/rtl/unicodeprefix.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/unicodeprefix.…
============================================================================== --- trunk/reactos/sdk/lib/rtl/unicodeprefix.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/rtl/unicodeprefix.c [iso-8859-1] Thu Sep 15 20:05:26 2016 @@ -96,8 +96,8 @@ if (FoundPrefix != FoundString) { /* Upcase the characters */ - FoundPrefix = RtlUpcaseUnicodeChar(FoundPrefix); - FoundString = RtlUpcaseUnicodeChar(FoundString); + FoundPrefix = RtlpUpcaseUnicodeChar(FoundPrefix); + FoundString = RtlpUpcaseUnicodeChar(FoundString); /* Compare them again */ if (FoundPrefix != FoundString) break;
8 years, 3 months
1
0
0
0
← Newer
1
...
15
16
17
18
19
20
21
...
35
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Results per page:
10
25
50
100
200