winehq.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
2025
February
January
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
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
January 2011
----- 2025 -----
February 2025
January 2025
----- 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
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
879 discussions
Start a n
N
ew thread
Alexandre Julliard : winedump: Print the machine field from the PDB symbol table.
by Alexandre Julliard
11 Jan '11
11 Jan '11
Module: wine Branch: master Commit: ce6779c9b1c77d5502b97023d3be4ded26b2aa5e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ce6779c9b1c77d5502b97023d…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jan 11 16:17:27 2011 +0100 winedump: Print the machine field from the PDB symbol table. --- include/wine/mscvpdb.h | 5 ++++- tools/winedump/pdb.c | 40 +++++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/include/wine/mscvpdb.h b/include/wine/mscvpdb.h index 59ce8a5..637ed0f 100644 --- a/include/wine/mscvpdb.h +++ b/include/wine/mscvpdb.h @@ -1914,7 +1914,10 @@ typedef struct _PDB_SYMBOLS DWORD hash_size; DWORD srcmodule_size; DWORD pdbimport_size; - DWORD resvd[5]; + DWORD resvd[3]; + WORD resvd3; + WORD machine; + DWORD resvd4; } PDB_SYMBOLS, *PPDB_SYMBOLS; typedef struct _PDB_FPO_DATA diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c index 4568d29..5720c40 100644 --- a/tools/winedump/pdb.c +++ b/tools/winedump/pdb.c @@ -178,23 +178,24 @@ static void pdb_dump_symbols(struct pdb_reader* reader) printf("-Unknown symbol info version %d\n", symbols->version); } printf("Symbols:\n" - "\tsignature: %08x\n" - "\tversion: %u\n" - "\tunknown: %08x\n" - "\thash1_file: %08x\n" - "\thash2_file: %08x\n" - "\tgsym_file: %04x\n" - "\tunknown1: %04x\n" - "\tmodule_size: %08x\n" - "\toffset_size: %08x\n" - "\thash_size: %08x\n" - "\tsrc_module_size %08x\n" - "\tpdbimport_size %08x\n" - "\tresvd[0] %08x\n" - "\tresvd[1] %08x\n" - "\tresvd[2] %08x\n" - "\tresvd[3] %08x\n" - "\tresvd[4] %08x\n", + "\tsignature: %08x\n" + "\tversion: %u\n" + "\tunknown: %08x\n" + "\thash1_file: %08x\n" + "\thash2_file: %08x\n" + "\tgsym_file: %04x\n" + "\tunknown1: %04x\n" + "\tmodule_size: %08x\n" + "\toffset_size: %08x\n" + "\thash_size: %08x\n" + "\tsrc_module_size: %08x\n" + "\tpdbimport_size: %08x\n" + "\tresvd[0] %08x\n" + "\tresvd[1] %08x\n" + "\tresvd[2] %08x\n" + "\tresvd[3] %04x\n" + "\tmachine: %s\n" + "\tresvd[4] %08x\n", symbols->signature, symbols->version, symbols->unknown, @@ -210,8 +211,9 @@ static void pdb_dump_symbols(struct pdb_reader* reader) symbols->resvd[0], symbols->resvd[1], symbols->resvd[2], - symbols->resvd[3], - symbols->resvd[4]); + symbols->resvd3, + get_machine_str( symbols->machine ), + symbols->resvd4); if (symbols->offset_size) {
1
0
0
0
Alexandre Julliard : winedump: Fix printing of module sources in PDB files.
by Alexandre Julliard
11 Jan '11
11 Jan '11
Module: wine Branch: master Commit: 51dd5c2ebbafb0f6c5bce0df5a3b693f533f1014 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=51dd5c2ebbafb0f6c5bce0df5…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jan 11 14:18:35 2011 +0100 winedump: Fix printing of module sources in PDB files. --- tools/winedump/pdb.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c index 89146d5..3cc8882 100644 --- a/tools/winedump/pdb.c +++ b/tools/winedump/pdb.c @@ -273,13 +273,13 @@ static void pdb_dump_symbols(struct pdb_reader* reader) for (i = cfile = 0; i < src->nModules; i++) { printf("\t\tModule[%2d]:\n", i); - for (j = 0; j < indx[i]; j++, cfile++) + cfile = src->table[i]; + for (j = cfile; j < src->nSrcFiles && j < cfile + indx[i]; j++) { /* FIXME: in some cases, it's a p_string but WHEN ? */ - if (src->table[cfile] < src->nSrcFiles && - cstr + offset[src->table[cfile]] >= (const char*)start_cstr /* wrap around */ && - cstr + offset[src->table[cfile]] < (const char*)src + symbols->srcmodule_size) - printf("\t\t\tSource file: %s\n", cstr + offset[src->table[cfile]]); + if (cstr + offset[j] >= (const char*)start_cstr /* wrap around */ && + cstr + offset[j] < (const char*)src + symbols->srcmodule_size) + printf("\t\t\tSource file: %s\n", cstr + offset[j]); else printf("\t\t\tSource file: <<out of bounds>>\n"); }
1
0
0
0
Greg Geldorp : gdi32/tests: Skip tests on unexpected font code page.
by Alexandre Julliard
11 Jan '11
11 Jan '11
Module: wine Branch: master Commit: 3658b8450911028413d1c8b6c36c71be43eee23c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=3658b8450911028413d1c8b6c…
Author: Greg Geldorp <ggeldorp(a)vmware.com> Date: Tue Jan 11 13:07:03 2011 +0100 gdi32/tests: Skip tests on unexpected font code page. --- dlls/gdi32/tests/font.c | 23 ++++++++++++++++++----- 1 files changed, 18 insertions(+), 5 deletions(-) diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index bd4d97d..28bdcc2 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -1558,6 +1558,7 @@ static BOOL get_glyph_indices(INT charset, UINT code_page, WORD *idx, UINT count INT cs; DWORD i, ret; char name[64]; + DWORD (WINAPI *pGdiGetCodePage)(HDC); assert(count <= 128); @@ -1599,6 +1600,16 @@ static BOOL get_glyph_indices(INT charset, UINT code_page, WORD *idx, UINT count } ok(csi.ciACP == code_page, "expected %d, got %d\n", code_page, csi.ciACP); + pGdiGetCodePage = (void *) GetProcAddress(GetModuleHandleA("gdi32.dll"), + "GdiGetCodePage"); + if (pGdiGetCodePage != NULL && pGdiGetCodePage(hdc) != code_page) + { + skip("Font code page %d, looking for code page %d\n", + pGdiGetCodePage(hdc), code_page); + ReleaseDC(0, hdc); + return FALSE; + } + if (unicode) { char ansi_buf[128]; @@ -1610,7 +1621,8 @@ static BOOL get_glyph_indices(INT charset, UINT code_page, WORD *idx, UINT count SetLastError(0xdeadbeef); ret = pGetGlyphIndicesW(hdc, unicode_buf, count, idx, 0); - ok(ret == count, "GetGlyphIndicesW error %u\n", GetLastError()); + ok(ret == count, "GetGlyphIndicesW expected %d got %d, error %u\n", + count, ret, GetLastError()); } else { @@ -1620,7 +1632,8 @@ static BOOL get_glyph_indices(INT charset, UINT code_page, WORD *idx, UINT count SetLastError(0xdeadbeef); ret = pGetGlyphIndicesA(hdc, ansi_buf, count, idx, 0); - ok(ret == count, "GetGlyphIndicesA error %u\n", GetLastError()); + ok(ret == count, "GetGlyphIndicesA expected %d got %d, error %u\n", + count, ret, GetLastError()); } SelectObject(hdc, hfont_old); @@ -1668,9 +1681,9 @@ static void test_font_charset(void) break; } } - get_glyph_indices(cd[i].charset, cd[i].code_page, cd[i].font_idxA, 128, FALSE); - get_glyph_indices(cd[i].charset, cd[i].code_page, cd[i].font_idxW, 128, TRUE); - ok(!memcmp(cd[i].font_idxA, cd[i].font_idxW, 128*sizeof(WORD)), "%d: indices don't match\n", i); + if (get_glyph_indices(cd[i].charset, cd[i].code_page, cd[i].font_idxA, 128, FALSE) && + get_glyph_indices(cd[i].charset, cd[i].code_page, cd[i].font_idxW, 128, TRUE)) + ok(!memcmp(cd[i].font_idxA, cd[i].font_idxW, 128*sizeof(WORD)), "%d: indices don't match\n", i); } ok(memcmp(cd[0].font_idxW, cd[1].font_idxW, 128*sizeof(WORD)), "0 vs 1: indices shouldn't match\n");
1
0
0
0
Andrew Nguyen : wineconsole: Pass an output parameter when calling ReadConsoleOutputCharacterW.
by Alexandre Julliard
11 Jan '11
11 Jan '11
Module: wine Branch: master Commit: 2e5c0a3acb0ca62dec67c30b9d734f68ab3b7a3e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=2e5c0a3acb0ca62dec67c30b9…
Author: Andrew Nguyen <anguyen(a)codeweavers.com> Date: Tue Jan 11 05:11:48 2011 -0600 wineconsole: Pass an output parameter when calling ReadConsoleOutputCharacterW. --- programs/wineconsole/user.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/programs/wineconsole/user.c b/programs/wineconsole/user.c index dc60ffd..bc70a6b 100644 --- a/programs/wineconsole/user.c +++ b/programs/wineconsole/user.c @@ -690,7 +690,9 @@ static void WCUSER_CopySelectionToClipboard(const struct inner_data* data) for (y = 0; y < h; y++, c.Y++) { LPWSTR end; - ReadConsoleOutputCharacterW(data->hConOut, p, w - 1, c, NULL); + DWORD count; + + ReadConsoleOutputCharacterW(data->hConOut, p, w - 1, c, &count); /* strip spaces from the end of the line */ end = p + w - 1;
1
0
0
0
Andrew Nguyen : kernel32: Pass an output parameter when calling WriteConsoleOutputCharacterW and FillConsoleOutputAttribute .
by Alexandre Julliard
11 Jan '11
11 Jan '11
Module: wine Branch: master Commit: ee84a9df12440c4def17941c49710079bf2daf96 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ee84a9df12440c4def17941c4…
Author: Andrew Nguyen <anguyen(a)codeweavers.com> Date: Tue Jan 11 05:11:44 2011 -0600 kernel32: Pass an output parameter when calling WriteConsoleOutputCharacterW and FillConsoleOutputAttribute. --- dlls/kernel32/editline.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dlls/kernel32/editline.c b/dlls/kernel32/editline.c index b33798b..dd93696 100644 --- a/dlls/kernel32/editline.c +++ b/dlls/kernel32/editline.c @@ -186,6 +186,7 @@ static inline void WCEL_WriteNChars(WCEL_Context* ctx, char ch, int count) static inline void WCEL_Update(WCEL_Context* ctx, int beg, int len) { int i, last; + DWORD count; WCHAR tmp[2]; /* bare console case is handled in CONSOLE_ReadLine (we always reprint the whole string) */ @@ -198,25 +199,25 @@ static inline void WCEL_Update(WCEL_Context* ctx, int beg, int len) if (last != i) { WriteConsoleOutputCharacterW(ctx->hConOut, &ctx->line[last], i - last, - WCEL_GetCoord(ctx, last), NULL); + WCEL_GetCoord(ctx, last), &count); FillConsoleOutputAttribute(ctx->hConOut, ctx->csbi.wAttributes, i - last, - WCEL_GetCoord(ctx, last), NULL); + WCEL_GetCoord(ctx, last), &count); } tmp[0] = '^'; tmp[1] = '@' + ctx->line[i]; WriteConsoleOutputCharacterW(ctx->hConOut, tmp, 2, - WCEL_GetCoord(ctx, i), NULL); + WCEL_GetCoord(ctx, i), &count); FillConsoleOutputAttribute(ctx->hConOut, ctx->csbi.wAttributes, 2, - WCEL_GetCoord(ctx, i), NULL); + WCEL_GetCoord(ctx, i), &count); last = i + 1; } } if (last != beg + len) { WriteConsoleOutputCharacterW(ctx->hConOut, &ctx->line[last], i - last, - WCEL_GetCoord(ctx, last), NULL); + WCEL_GetCoord(ctx, last), &count); FillConsoleOutputAttribute(ctx->hConOut, ctx->csbi.wAttributes, i - last, - WCEL_GetCoord(ctx, last), NULL); + WCEL_GetCoord(ctx, last), &count); } }
1
0
0
0
Andrew Nguyen : kernel32/tests: Demonstrate an input event handling peculiarity with WriteConsoleInputA.
by Alexandre Julliard
11 Jan '11
11 Jan '11
Module: wine Branch: master Commit: df18e3fdd404b9561433788aa1eb8c2e96cc6f8d URL:
http://source.winehq.org/git/wine.git/?a=commit;h=df18e3fdd404b9561433788aa…
Author: Andrew Nguyen <anguyen(a)codeweavers.com> Date: Tue Jan 11 05:11:40 2011 -0600 kernel32/tests: Demonstrate an input event handling peculiarity with WriteConsoleInputA. --- dlls/kernel32/tests/console.c | 165 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 159 insertions(+), 6 deletions(-) diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index d761afa..15bb838 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -1223,9 +1223,11 @@ static void test_GetNumberOfConsoleInputEvents(HANDLE input_handle) static void test_WriteConsoleInputA(HANDLE input_handle) { - INPUT_RECORD event, temp; + INPUT_RECORD event; + INPUT_RECORD event_list[5]; MOUSE_EVENT_RECORD mouse_event = { {0, 0}, 0, 0, MOUSE_MOVED }; - DWORD count; + KEY_EVENT_RECORD key_event; + DWORD count, console_mode; BOOL ret; int i; @@ -1263,6 +1265,27 @@ static void test_WriteConsoleInputA(HANDLE input_handle) {input_handle, &event, 1, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, }; + /* Suppress external sources of input events for the duration of the test. */ + ret = GetConsoleMode(input_handle, &console_mode); + ok(ret == TRUE, "Expected GetConsoleMode to return TRUE, got %d\n", ret); + if (!ret) + { + skip("GetConsoleMode failed with last error %u\n", GetLastError()); + return; + } + + ret = SetConsoleMode(input_handle, console_mode & ~(ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT)); + ok(ret == TRUE, "Expected SetConsoleMode to return TRUE, got %d\n", ret); + if (!ret) + { + skip("SetConsoleMode failed with last error %u\n", GetLastError()); + return; + } + + /* Discard any events queued before the tests. */ + ret = FlushConsoleInputBuffer(input_handle); + ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret); + event.EventType = MOUSE_EVENT; event.Event.MouseEvent = mouse_event; @@ -1304,11 +1327,141 @@ static void test_WriteConsoleInputA(HANDLE input_handle) ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret); ok(count == 1, "Expected count to be 1, got %u\n", count); - /* Discard the queued input event by reading it. */ - count = 0xdeadbeef; - ret = ReadConsoleInputA(input_handle, &temp, 1, &count); - ok(ret == TRUE, "Expected ReadConsoleInputA to return TRUE, got %d\n", ret); + ret = FlushConsoleInputBuffer(input_handle); + ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret); + + /* Writing a single mouse event doesn't seem to affect the count if an adjacent mouse event is already queued. */ + event.EventType = MOUSE_EVENT; + event.Event.MouseEvent = mouse_event; + + ret = WriteConsoleInputA(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = WriteConsoleInputA(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + todo_wine + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = FlushConsoleInputBuffer(input_handle); + ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret); + + for (i = 0; i < sizeof(event_list)/sizeof(event_list[0]); i++) + { + event_list[i].EventType = MOUSE_EVENT; + event_list[i].Event.MouseEvent = mouse_event; + } + + /* Writing consecutive chunks of mouse events appears to work. */ + ret = WriteConsoleInputA(input_handle, event_list, sizeof(event_list)/sizeof(event_list[0]), &count); + ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret); + ok(count == sizeof(event_list)/sizeof(event_list[0]), + "Expected count to be event list length, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == sizeof(event_list)/sizeof(event_list[0]), + "Expected count to be event list length, got %u\n", count); + + ret = WriteConsoleInputA(input_handle, event_list, sizeof(event_list)/sizeof(event_list[0]), &count); + ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret); + ok(count == sizeof(event_list)/sizeof(event_list[0]), + "Expected count to be event list length, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == 2*sizeof(event_list)/sizeof(event_list[0]), + "Expected count to be twice event list length, got %u\n", count); + + /* Again, writing a single mouse event with adjacent mouse events queued doesn't appear to affect the count. */ + ret = WriteConsoleInputA(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + todo_wine + ok(count == 2*sizeof(event_list)/sizeof(event_list[0]), + "Expected count to be twice event list length, got %u\n", count); + + ret = FlushConsoleInputBuffer(input_handle); + ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret); + + key_event.bKeyDown = FALSE; + key_event.wRepeatCount = 0; + key_event.wVirtualKeyCode = VK_SPACE; + key_event.wVirtualScanCode = VK_SPACE; + key_event.uChar.AsciiChar = ' '; + key_event.dwControlKeyState = 0; + + event.EventType = KEY_EVENT; + event.Event.KeyEvent = key_event; + + /* Key events don't exhibit the same behavior as mouse events. */ + ret = WriteConsoleInputA(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = WriteConsoleInputA(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == 2, "Expected count to be 2, got %u\n", count); + + ret = FlushConsoleInputBuffer(input_handle); + ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret); + + /* Try interleaving mouse and key events. */ + event.EventType = MOUSE_EVENT; + event.Event.MouseEvent = mouse_event; + + ret = WriteConsoleInputA(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + event.EventType = KEY_EVENT; + event.Event.KeyEvent = key_event; + + ret = WriteConsoleInputA(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == 2, "Expected count to be 2, got %u\n", count); + + event.EventType = MOUSE_EVENT; + event.Event.MouseEvent = mouse_event; + + ret = WriteConsoleInputA(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == 3, "Expected count to be 3, got %u\n", count); + + /* Restore the old console mode. */ + ret = SetConsoleMode(input_handle, console_mode); + ok(ret == TRUE, "Expected SetConsoleMode to return TRUE, got %d\n", ret); } static void test_WriteConsoleInputW(HANDLE input_handle)
1
0
0
0
Andrew Nguyen : kernel32/tests: Demonstrate an input event handling peculiarity with WriteConsoleInputW.
by Alexandre Julliard
11 Jan '11
11 Jan '11
Module: wine Branch: master Commit: e2e9141918114085513a7fb48d8f48d808464023 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=e2e9141918114085513a7fb48…
Author: Andrew Nguyen <anguyen(a)codeweavers.com> Date: Tue Jan 11 05:11:37 2011 -0600 kernel32/tests: Demonstrate an input event handling peculiarity with WriteConsoleInputW. --- dlls/kernel32/tests/console.c | 165 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 159 insertions(+), 6 deletions(-) diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index f417199..d761afa 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -1313,9 +1313,11 @@ static void test_WriteConsoleInputA(HANDLE input_handle) static void test_WriteConsoleInputW(HANDLE input_handle) { - INPUT_RECORD event, temp; + INPUT_RECORD event; + INPUT_RECORD event_list[5]; MOUSE_EVENT_RECORD mouse_event = { {0, 0}, 0, 0, MOUSE_MOVED }; - DWORD count; + KEY_EVENT_RECORD key_event; + DWORD count, console_mode; BOOL ret; int i; @@ -1353,6 +1355,27 @@ static void test_WriteConsoleInputW(HANDLE input_handle) {input_handle, &event, 1, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, }; + /* Suppress external sources of input events for the duration of the test. */ + ret = GetConsoleMode(input_handle, &console_mode); + ok(ret == TRUE, "Expected GetConsoleMode to return TRUE, got %d\n", ret); + if (!ret) + { + skip("GetConsoleMode failed with last error %u\n", GetLastError()); + return; + } + + ret = SetConsoleMode(input_handle, console_mode & ~(ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT)); + ok(ret == TRUE, "Expected SetConsoleMode to return TRUE, got %d\n", ret); + if (!ret) + { + skip("SetConsoleMode failed with last error %u\n", GetLastError()); + return; + } + + /* Discard any events queued before the tests. */ + ret = FlushConsoleInputBuffer(input_handle); + ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret); + event.EventType = MOUSE_EVENT; event.Event.MouseEvent = mouse_event; @@ -1394,11 +1417,141 @@ static void test_WriteConsoleInputW(HANDLE input_handle) ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret); ok(count == 1, "Expected count to be 1, got %u\n", count); - /* Discard the queued input event by reading it. */ - count = 0xdeadbeef; - ret = ReadConsoleInputW(input_handle, &temp, 1, &count); - ok(ret == TRUE, "Expected ReadConsoleInputW to return TRUE, got %d\n", ret); + ret = FlushConsoleInputBuffer(input_handle); + ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret); + + /* Writing a single mouse event doesn't seem to affect the count if an adjacent mouse event is already queued. */ + event.EventType = MOUSE_EVENT; + event.Event.MouseEvent = mouse_event; + + ret = WriteConsoleInputW(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = WriteConsoleInputW(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + todo_wine + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = FlushConsoleInputBuffer(input_handle); + ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret); + + for (i = 0; i < sizeof(event_list)/sizeof(event_list[0]); i++) + { + event_list[i].EventType = MOUSE_EVENT; + event_list[i].Event.MouseEvent = mouse_event; + } + + /* Writing consecutive chunks of mouse events appears to work. */ + ret = WriteConsoleInputW(input_handle, event_list, sizeof(event_list)/sizeof(event_list[0]), &count); + ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret); + ok(count == sizeof(event_list)/sizeof(event_list[0]), + "Expected count to be event list length, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == sizeof(event_list)/sizeof(event_list[0]), + "Expected count to be event list length, got %u\n", count); + + ret = WriteConsoleInputW(input_handle, event_list, sizeof(event_list)/sizeof(event_list[0]), &count); + ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret); + ok(count == sizeof(event_list)/sizeof(event_list[0]), + "Expected count to be event list length, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == 2*sizeof(event_list)/sizeof(event_list[0]), + "Expected count to be twice event list length, got %u\n", count); + + /* Again, writing a single mouse event with adjacent mouse events queued doesn't appear to affect the count. */ + ret = WriteConsoleInputW(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret); ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + todo_wine + ok(count == 2*sizeof(event_list)/sizeof(event_list[0]), + "Expected count to be twice event list length, got %u\n", count); + + ret = FlushConsoleInputBuffer(input_handle); + ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret); + + key_event.bKeyDown = FALSE; + key_event.wRepeatCount = 0; + key_event.wVirtualKeyCode = VK_SPACE; + key_event.wVirtualScanCode = VK_SPACE; + key_event.uChar.UnicodeChar = ' '; + key_event.dwControlKeyState = 0; + + event.EventType = KEY_EVENT; + event.Event.KeyEvent = key_event; + + /* Key events don't exhibit the same behavior as mouse events. */ + ret = WriteConsoleInputW(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = WriteConsoleInputW(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == 2, "Expected count to be 2, got %u\n", count); + + ret = FlushConsoleInputBuffer(input_handle); + ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret); + + /* Try interleaving mouse and key events. */ + event.EventType = MOUSE_EVENT; + event.Event.MouseEvent = mouse_event; + + ret = WriteConsoleInputW(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + event.EventType = KEY_EVENT; + event.Event.KeyEvent = key_event; + + ret = WriteConsoleInputW(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == 2, "Expected count to be 2, got %u\n", count); + + event.EventType = MOUSE_EVENT; + event.Event.MouseEvent = mouse_event; + + ret = WriteConsoleInputW(input_handle, &event, 1, &count); + ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); + + ret = GetNumberOfConsoleInputEvents(input_handle, &count); + ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret); + ok(count == 3, "Expected count to be 3, got %u\n", count); + + /* Restore the old console mode. */ + ret = SetConsoleMode(input_handle, console_mode); + ok(ret == TRUE, "Expected SetConsoleMode to return TRUE, got %d\n", ret); } static void test_WriteConsoleOutputCharacterA(HANDLE output_handle)
1
0
0
0
Andrew Nguyen : kernel32: Improve parameter validation for ReadConsoleOutputAttribute.
by Alexandre Julliard
11 Jan '11
11 Jan '11
Module: wine Branch: master Commit: b158d23c8803f48c7f7d19ad608c2ca86c8cb469 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=b158d23c8803f48c7f7d19ad6…
Author: Andrew Nguyen <anguyen(a)codeweavers.com> Date: Tue Jan 11 05:11:34 2011 -0600 kernel32: Improve parameter validation for ReadConsoleOutputAttribute. --- dlls/kernel32/console.c | 12 ++++- dlls/kernel32/tests/console.c | 84 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 3 deletions(-) diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index 1762ee4..f1bc3bc 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -908,6 +908,14 @@ BOOL WINAPI ReadConsoleOutputAttribute(HANDLE hConsoleOutput, LPWORD lpAttribute TRACE("(%p,%p,%d,%dx%d,%p)\n", hConsoleOutput, lpAttribute, length, coord.X, coord.Y, read_count); + if (!read_count) + { + SetLastError(ERROR_INVALID_ACCESS); + return FALSE; + } + + *read_count = 0; + SERVER_START_REQ( read_console_output ) { req->handle = console_handle_unmap(hConsoleOutput); @@ -917,9 +925,7 @@ BOOL WINAPI ReadConsoleOutputAttribute(HANDLE hConsoleOutput, LPWORD lpAttribute req->wrap = TRUE; wine_server_set_reply( req, lpAttribute, length * sizeof(WORD) ); if ((ret = !wine_server_call_err( req ))) - { - if (read_count) *read_count = wine_server_reply_size(reply) / sizeof(WORD); - } + *read_count = wine_server_reply_size(reply) / sizeof(WORD); } SERVER_END_REQ; return ret; diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 9b53f48..f417199 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -2023,6 +2023,89 @@ static void test_ReadConsoleOutputCharacterW(HANDLE output_handle) ok(count == 1, "Expected count to be 1, got %u\n", count); } +static void test_ReadConsoleOutputAttribute(HANDLE output_handle) +{ + WORD attr; + COORD origin = {0, 0}; + DWORD count; + BOOL ret; + int i; + + const struct + { + HANDLE hConsoleOutput; + LPWORD lpAttribute; + DWORD length; + COORD coord; + LPDWORD read_count; + DWORD expected_count; + DWORD last_error; + int win7_crash; + } invalid_table[] = + { + {NULL, NULL, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {NULL, NULL, 0, origin, &count, 0, ERROR_INVALID_HANDLE}, + {NULL, NULL, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {NULL, NULL, 1, origin, &count, 0, ERROR_INVALID_HANDLE, 1}, + {NULL, &attr, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {NULL, &attr, 0, origin, &count, 0, ERROR_INVALID_HANDLE}, + {NULL, &attr, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {NULL, &attr, 1, origin, &count, 0, ERROR_INVALID_HANDLE}, + {INVALID_HANDLE_VALUE, NULL, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {INVALID_HANDLE_VALUE, NULL, 0, origin, &count, 0, ERROR_INVALID_HANDLE}, + {INVALID_HANDLE_VALUE, NULL, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {INVALID_HANDLE_VALUE, NULL, 1, origin, &count, 0, ERROR_INVALID_HANDLE, 1}, + {INVALID_HANDLE_VALUE, &attr, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {INVALID_HANDLE_VALUE, &attr, 0, origin, &count, 0, ERROR_INVALID_HANDLE}, + {INVALID_HANDLE_VALUE, &attr, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {INVALID_HANDLE_VALUE, &attr, 1, origin, &count, 0, ERROR_INVALID_HANDLE}, + {output_handle, NULL, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {output_handle, NULL, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {output_handle, NULL, 1, origin, &count, 1, ERROR_INVALID_ACCESS, 1}, + {output_handle, &attr, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {output_handle, &attr, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + }; + + for (i = 0; i < sizeof(invalid_table)/sizeof(invalid_table[0]); i++) + { + if (invalid_table[i].win7_crash) + continue; + + SetLastError(0xdeadbeef); + if (invalid_table[i].read_count) count = 0xdeadbeef; + ret = ReadConsoleOutputAttribute(invalid_table[i].hConsoleOutput, + invalid_table[i].lpAttribute, + invalid_table[i].length, + invalid_table[i].coord, + invalid_table[i].read_count); + ok(!ret, "[%d] Expected ReadConsoleOutputAttribute to return FALSE, got %d\n", i, ret); + if (invalid_table[i].read_count) + { + ok(count == invalid_table[i].expected_count, + "[%d] Expected count to be %u, got %u\n", + i, invalid_table[i].expected_count, count); + } + ok(GetLastError() == invalid_table[i].last_error, + "[%d] Expected last error to be %u, got %u\n", + i, invalid_table[i].last_error, GetLastError()); + } + + count = 0xdeadbeef; + ret = ReadConsoleOutputAttribute(output_handle, NULL, 0, origin, &count); + ok(ret == TRUE, "Expected ReadConsoleOutputAttribute to return TRUE, got %d\n", ret); + ok(count == 0, "Expected count to be 0, got %u\n", count); + + count = 0xdeadbeef; + ret = ReadConsoleOutputAttribute(output_handle, &attr, 0, origin, &count); + ok(ret == TRUE, "Expected ReadConsoleOutputAttribute to return TRUE, got %d\n", ret); + ok(count == 0, "Expected count to be 0, got %u\n", count); + + count = 0xdeadbeef; + ret = ReadConsoleOutputAttribute(output_handle, &attr, 1, origin, &count); + ok(ret == TRUE, "Expected ReadConsoleOutputAttribute to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); +} + START_TEST(console) { static const char font_name[] = "Lucida Console"; @@ -2139,4 +2222,5 @@ START_TEST(console) test_FillConsoleOutputAttribute(hConOut); test_ReadConsoleOutputCharacterA(hConOut); test_ReadConsoleOutputCharacterW(hConOut); + test_ReadConsoleOutputAttribute(hConOut); }
1
0
0
0
Andrew Nguyen : kernel32: Improve parameter validation for ReadConsoleOutputCharacterA.
by Alexandre Julliard
11 Jan '11
11 Jan '11
Module: wine Branch: master Commit: 66b42c86d1a65f45d3548d620cac4574f36bdce1 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=66b42c86d1a65f45d3548d620…
Author: Andrew Nguyen <anguyen(a)codeweavers.com> Date: Tue Jan 11 05:11:30 2011 -0600 kernel32: Improve parameter validation for ReadConsoleOutputCharacterA. --- dlls/kernel32/console.c | 19 +++++++-- dlls/kernel32/tests/console.c | 85 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 4 deletions(-) diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index 8ad0a39..1762ee4 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -836,15 +836,26 @@ BOOL WINAPI ReadConsoleOutputCharacterA(HANDLE hConsoleOutput, LPSTR lpstr, DWOR { DWORD read; BOOL ret; - LPWSTR wptr = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR)); + LPWSTR wptr; - if (read_count) *read_count = 0; - if (!wptr) return FALSE; + if (!read_count) + { + SetLastError(ERROR_INVALID_ACCESS); + return FALSE; + } + + *read_count = 0; + + if (!(wptr = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR)))) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } if ((ret = ReadConsoleOutputCharacterW( hConsoleOutput, wptr, count, coord, &read ))) { read = WideCharToMultiByte( GetConsoleOutputCP(), 0, wptr, read, lpstr, count, NULL, NULL); - if (read_count) *read_count = read; + *read_count = read; } HeapFree( GetProcessHeap(), 0, wptr ); return ret; diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index aa193b1..9b53f48 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -1855,6 +1855,90 @@ static void test_FillConsoleOutputAttribute(HANDLE output_handle) ok(count == 1, "Expected count to be 1, got %u\n", count); } +static void test_ReadConsoleOutputCharacterA(HANDLE output_handle) +{ + CHAR read; + COORD origin = {0, 0}; + DWORD count; + BOOL ret; + int i; + + const struct + { + HANDLE hConsoleOutput; + LPSTR lpstr; + DWORD length; + COORD coord; + LPDWORD read_count; + DWORD expected_count; + DWORD last_error; + int win7_crash; + } invalid_table[] = + { + {NULL, NULL, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {NULL, NULL, 0, origin, &count, 0, ERROR_INVALID_HANDLE}, + {NULL, NULL, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {NULL, NULL, 1, origin, &count, 0, ERROR_INVALID_HANDLE, 1}, + {NULL, &read, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {NULL, &read, 0, origin, &count, 0, ERROR_INVALID_HANDLE}, + {NULL, &read, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {NULL, &read, 1, origin, &count, 0, ERROR_INVALID_HANDLE}, + {INVALID_HANDLE_VALUE, NULL, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {INVALID_HANDLE_VALUE, NULL, 0, origin, &count, 0, ERROR_INVALID_HANDLE}, + {INVALID_HANDLE_VALUE, NULL, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {INVALID_HANDLE_VALUE, NULL, 1, origin, &count, 0, ERROR_INVALID_HANDLE, 1}, + {INVALID_HANDLE_VALUE, &read, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {INVALID_HANDLE_VALUE, &read, 0, origin, &count, 0, ERROR_INVALID_HANDLE}, + {INVALID_HANDLE_VALUE, &read, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {INVALID_HANDLE_VALUE, &read, 1, origin, &count, 0, ERROR_INVALID_HANDLE}, + {output_handle, NULL, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {output_handle, NULL, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {output_handle, NULL, 1, origin, &count, 1, ERROR_INVALID_ACCESS, 1}, + {output_handle, NULL, 10, origin, &count, 10, ERROR_INVALID_ACCESS, 1}, + {output_handle, &read, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {output_handle, &read, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + }; + + for (i = 0; i < sizeof(invalid_table)/sizeof(invalid_table[0]); i++) + { + if (invalid_table[i].win7_crash) + continue; + + SetLastError(0xdeadbeef); + if (invalid_table[i].read_count) count = 0xdeadbeef; + ret = ReadConsoleOutputCharacterA(invalid_table[i].hConsoleOutput, + invalid_table[i].lpstr, + invalid_table[i].length, + invalid_table[i].coord, + invalid_table[i].read_count); + ok(!ret, "[%d] Expected ReadConsoleOutputCharacterA to return FALSE, got %d\n", i, ret); + if (invalid_table[i].read_count) + { + ok(count == invalid_table[i].expected_count, + "[%d] Expected count to be %u, got %u\n", + i, invalid_table[i].expected_count, count); + } + ok(GetLastError() == invalid_table[i].last_error, + "[%d] Expected last error to be %u, got %u\n", + i, invalid_table[i].last_error, GetLastError()); + } + + count = 0xdeadbeef; + ret = ReadConsoleOutputCharacterA(output_handle, NULL, 0, origin, &count); + ok(ret == TRUE, "Expected ReadConsoleOutputCharacterA to return TRUE, got %d\n", ret); + ok(count == 0, "Expected count to be 0, got %u\n", count); + + count = 0xdeadbeef; + ret = ReadConsoleOutputCharacterA(output_handle, &read, 0, origin, &count); + ok(ret == TRUE, "Expected ReadConsoleOutputCharacterA to return TRUE, got %d\n", ret); + ok(count == 0, "Expected count to be 0, got %u\n", count); + + count = 0xdeadbeef; + ret = ReadConsoleOutputCharacterA(output_handle, &read, 1, origin, &count); + ok(ret == TRUE, "Expected ReadConsoleOutputCharacterA to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); +} + static void test_ReadConsoleOutputCharacterW(HANDLE output_handle) { WCHAR read; @@ -2053,5 +2137,6 @@ START_TEST(console) test_FillConsoleOutputCharacterA(hConOut); test_FillConsoleOutputCharacterW(hConOut); test_FillConsoleOutputAttribute(hConOut); + test_ReadConsoleOutputCharacterA(hConOut); test_ReadConsoleOutputCharacterW(hConOut); }
1
0
0
0
Andrew Nguyen : kernel32: Improve parameter validation for ReadConsoleOutputCharacterW.
by Alexandre Julliard
11 Jan '11
11 Jan '11
Module: wine Branch: master Commit: c905b7e705edac861dd3bd3b01ce894060f9e8de URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c905b7e705edac861dd3bd3b0…
Author: Andrew Nguyen <anguyen(a)codeweavers.com> Date: Tue Jan 11 05:11:16 2011 -0600 kernel32: Improve parameter validation for ReadConsoleOutputCharacterW. --- dlls/kernel32/console.c | 12 ++++- dlls/kernel32/tests/console.c | 85 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 3 deletions(-) diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index 9589cfc..8ad0a39 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -862,6 +862,14 @@ BOOL WINAPI ReadConsoleOutputCharacterW( HANDLE hConsoleOutput, LPWSTR buffer, D TRACE( "(%p,%p,%d,%dx%d,%p)\n", hConsoleOutput, buffer, count, coord.X, coord.Y, read_count ); + if (!read_count) + { + SetLastError(ERROR_INVALID_ACCESS); + return FALSE; + } + + *read_count = 0; + SERVER_START_REQ( read_console_output ) { req->handle = console_handle_unmap(hConsoleOutput); @@ -871,9 +879,7 @@ BOOL WINAPI ReadConsoleOutputCharacterW( HANDLE hConsoleOutput, LPWSTR buffer, D req->wrap = TRUE; wine_server_set_reply( req, buffer, count * sizeof(WCHAR) ); if ((ret = !wine_server_call_err( req ))) - { - if (read_count) *read_count = wine_server_reply_size(reply) / sizeof(WCHAR); - } + *read_count = wine_server_reply_size(reply) / sizeof(WCHAR); } SERVER_END_REQ; return ret; diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index fa26136..aa193b1 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -1855,6 +1855,90 @@ static void test_FillConsoleOutputAttribute(HANDLE output_handle) ok(count == 1, "Expected count to be 1, got %u\n", count); } +static void test_ReadConsoleOutputCharacterW(HANDLE output_handle) +{ + WCHAR read; + COORD origin = {0, 0}; + DWORD count; + BOOL ret; + int i; + + const struct + { + HANDLE hConsoleOutput; + LPWSTR buffer; + DWORD length; + COORD coord; + LPDWORD read_count; + DWORD expected_count; + DWORD last_error; + int win7_crash; + } invalid_table[] = + { + {NULL, NULL, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {NULL, NULL, 0, origin, &count, 0, ERROR_INVALID_HANDLE}, + {NULL, NULL, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {NULL, NULL, 1, origin, &count, 0, ERROR_INVALID_HANDLE, 1}, + {NULL, &read, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {NULL, &read, 0, origin, &count, 0, ERROR_INVALID_HANDLE}, + {NULL, &read, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {NULL, &read, 1, origin, &count, 0, ERROR_INVALID_HANDLE}, + {INVALID_HANDLE_VALUE, NULL, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {INVALID_HANDLE_VALUE, NULL, 0, origin, &count, 0, ERROR_INVALID_HANDLE}, + {INVALID_HANDLE_VALUE, NULL, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {INVALID_HANDLE_VALUE, NULL, 1, origin, &count, 0, ERROR_INVALID_HANDLE, 1}, + {INVALID_HANDLE_VALUE, &read, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {INVALID_HANDLE_VALUE, &read, 0, origin, &count, 0, ERROR_INVALID_HANDLE}, + {INVALID_HANDLE_VALUE, &read, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {INVALID_HANDLE_VALUE, &read, 1, origin, &count, 0, ERROR_INVALID_HANDLE}, + {output_handle, NULL, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {output_handle, NULL, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {output_handle, NULL, 1, origin, &count, 1, ERROR_INVALID_ACCESS, 1}, + {output_handle, NULL, 10, origin, &count, 10, ERROR_INVALID_ACCESS, 1}, + {output_handle, &read, 0, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + {output_handle, &read, 1, origin, NULL, 0xdeadbeef, ERROR_INVALID_ACCESS, 1}, + }; + + for (i = 0; i < sizeof(invalid_table)/sizeof(invalid_table[0]); i++) + { + if (invalid_table[i].win7_crash) + continue; + + SetLastError(0xdeadbeef); + if (invalid_table[i].read_count) count = 0xdeadbeef; + ret = ReadConsoleOutputCharacterW(invalid_table[i].hConsoleOutput, + invalid_table[i].buffer, + invalid_table[i].length, + invalid_table[i].coord, + invalid_table[i].read_count); + ok(!ret, "[%d] Expected ReadConsoleOutputCharacterW to return FALSE, got %d\n", i, ret); + if (invalid_table[i].read_count) + { + ok(count == invalid_table[i].expected_count, + "[%d] Expected count to be %u, got %u\n", + i, invalid_table[i].expected_count, count); + } + ok(GetLastError() == invalid_table[i].last_error, + "[%d] Expected last error to be %u, got %u\n", + i, invalid_table[i].last_error, GetLastError()); + } + + count = 0xdeadbeef; + ret = ReadConsoleOutputCharacterW(output_handle, NULL, 0, origin, &count); + ok(ret == TRUE, "Expected ReadConsoleOutputCharacterW to return TRUE, got %d\n", ret); + ok(count == 0, "Expected count to be 0, got %u\n", count); + + count = 0xdeadbeef; + ret = ReadConsoleOutputCharacterW(output_handle, &read, 0, origin, &count); + ok(ret == TRUE, "Expected ReadConsoleOutputCharacterW to return TRUE, got %d\n", ret); + ok(count == 0, "Expected count to be 0, got %u\n", count); + + count = 0xdeadbeef; + ret = ReadConsoleOutputCharacterW(output_handle, &read, 1, origin, &count); + ok(ret == TRUE, "Expected ReadConsoleOutputCharacterW to return TRUE, got %d\n", ret); + ok(count == 1, "Expected count to be 1, got %u\n", count); +} + START_TEST(console) { static const char font_name[] = "Lucida Console"; @@ -1969,4 +2053,5 @@ START_TEST(console) test_FillConsoleOutputCharacterA(hConOut); test_FillConsoleOutputCharacterW(hConOut); test_FillConsoleOutputAttribute(hConOut); + test_ReadConsoleOutputCharacterW(hConOut); }
1
0
0
0
← Newer
1
...
53
54
55
56
57
58
59
...
88
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Results per page:
10
25
50
100
200