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
July
June
May
April
March
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
October 2014
----- 2025 -----
July 2025
June 2025
May 2025
April 2025
March 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
397 discussions
Start a n
N
ew thread
Sebastian Lackner : kernel32: Implement GetProcessDEPPolicy.
by Alexandre Julliard
21 Oct '14
21 Oct '14
Module: wine Branch: master Commit: d74c9e3ec20dc886ab83f924cd3f5444a52a4c7e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d74c9e3ec20dc886ab83f924c…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Tue Oct 21 07:46:10 2014 +0200 kernel32: Implement GetProcessDEPPolicy. --- dlls/kernel32/process.c | 28 +++++++++++++++++++++++++--- dlls/kernel32/tests/virtual.c | 3 --- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 301c64a..138273b 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -3942,9 +3942,31 @@ BOOL WINAPI GetNumaAvailableMemoryNode(UCHAR node, PULONGLONG available_bytes) */ BOOL WINAPI GetProcessDEPPolicy(HANDLE process, LPDWORD flags, PBOOL permanent) { - FIXME("(%p %p %p): stub\n", process, flags, permanent); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + NTSTATUS status; + ULONG dep_flags; + + TRACE("(%p %p %p)\n", process, flags, permanent); + + status = NtQueryInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, + &dep_flags, sizeof(dep_flags), NULL ); + if (!status) + { + + if (flags) + { + *flags = 0; + if (dep_flags & MEM_EXECUTE_OPTION_DISABLE) + *flags |= PROCESS_DEP_ENABLE; + if (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION) + *flags |= PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION; + } + + if (permanent) + *permanent = (dep_flags & MEM_EXECUTE_OPTION_PERMANENT) != 0; + + } + if (status) SetLastError( RtlNtStatusToDosError(status) ); + return !status; } /********************************************************************** diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 40f45ef..98ef703 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -1995,7 +1995,6 @@ static void test_atl_thunk_emulation( ULONG dep_flags ) ok( success, "VirtualProtect failed %u\n", GetLastError() ); success = get_dep_policy( GetCurrentProcess(), &policy_flags, &policy_permanent ); - todo_wine ok( success, "GetProcessDEPPolicy failed %u\n", GetLastError() ); ret = 0; @@ -2004,9 +2003,7 @@ static void test_atl_thunk_emulation( ULONG dep_flags ) if (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION) ret |= PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION; - todo_wine ok( policy_flags == ret, "expected policy flags %d, got %d\n", ret, policy_flags ); - todo_wine ok( !policy_permanent || broken(policy_permanent == 0x44), "expected policy permanent FALSE, got %d\n", policy_permanent ); }
1
0
0
0
Sebastian Lackner : kernel32/tests: Add test for GetProcessDEPPolicy.
by Alexandre Julliard
21 Oct '14
21 Oct '14
Module: wine Branch: master Commit: 19927ee517977addd56a040dc7549976a3a0439b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=19927ee517977addd56a040dc…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Tue Oct 21 07:43:12 2014 +0200 kernel32/tests: Add test for GetProcessDEPPolicy. --- dlls/kernel32/tests/virtual.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/winbase.h | 3 +++ 2 files changed, 43 insertions(+) diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 1592b87..40f45ef 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -46,6 +46,7 @@ static DWORD (WINAPI *pNtUnmapViewOfSection)(HANDLE, PVOID); static struct _TEB * (WINAPI *pNtCurrentTeb)(void); static PVOID (WINAPI *pRtlAddVectoredExceptionHandler)(ULONG, PVECTORED_EXCEPTION_HANDLER); static ULONG (WINAPI *pRtlRemoveVectoredExceptionHandler)(PVOID); +static BOOL (WINAPI *pGetProcessDEPPolicy)(HANDLE, LPDWORD, PBOOL); /* ############################### */ @@ -1972,6 +1973,44 @@ static void test_atl_thunk_emulation( ULONG dep_flags ) base = VirtualAlloc( 0, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE ); ok( base != NULL, "VirtualAlloc failed %u\n", GetLastError() ); + /* Check result of GetProcessDEPPolicy */ + if (!pGetProcessDEPPolicy) + win_skip( "GetProcessDEPPolicy not supported\n" ); + else + { + BOOL (WINAPI *get_dep_policy)(HANDLE, LPDWORD, PBOOL) = (void *)base; + BOOL policy_permanent = 0xdeadbeef; + DWORD policy_flags = 0xdeadbeef; + + /* GetProcessDEPPolicy crashes on Windows when a NULL pointer is passed. + * Moreover this function has a bug on Windows 8, which has the effect that + * policy_permanent is set to the content of the CL register instead of 0, + * when the policy is not permanent. To detect that we use an assembler + * wrapper to call the function. */ + + memcpy( base, code_atl2, sizeof(code_atl2) ); + *(DWORD *)(base + 6) = (DWORD_PTR)pGetProcessDEPPolicy - (DWORD_PTR)(base + 10); + + success = VirtualProtect( base, size, PAGE_EXECUTE_READWRITE, &old_prot ); + ok( success, "VirtualProtect failed %u\n", GetLastError() ); + + success = get_dep_policy( GetCurrentProcess(), &policy_flags, &policy_permanent ); + todo_wine + ok( success, "GetProcessDEPPolicy failed %u\n", GetLastError() ); + + ret = 0; + if (dep_flags & MEM_EXECUTE_OPTION_DISABLE) + ret |= PROCESS_DEP_ENABLE; + if (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION) + ret |= PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION; + + todo_wine + ok( policy_flags == ret, "expected policy flags %d, got %d\n", ret, policy_flags ); + todo_wine + ok( !policy_permanent || broken(policy_permanent == 0x44), + "expected policy permanent FALSE, got %d\n", policy_permanent ); + } + memcpy( base, code_jmp, sizeof(code_jmp) ); *(DWORD *)(base + 1) = (DWORD_PTR)jmp_test_func - (DWORD_PTR)(base + 5); @@ -3424,6 +3463,7 @@ START_TEST(virtual) pVirtualFreeEx = (void *) GetProcAddress(hkernel32, "VirtualFreeEx"); pGetWriteWatch = (void *) GetProcAddress(hkernel32, "GetWriteWatch"); pResetWriteWatch = (void *) GetProcAddress(hkernel32, "ResetWriteWatch"); + pGetProcessDEPPolicy = (void *)GetProcAddress( hkernel32, "GetProcessDEPPolicy" ); pNtAreMappedFilesTheSame = (void *)GetProcAddress( hntdll, "NtAreMappedFilesTheSame" ); pNtMapViewOfSection = (void *)GetProcAddress( hntdll, "NtMapViewOfSection" ); pNtUnmapViewOfSection = (void *)GetProcAddress( hntdll, "NtUnmapViewOfSection" ); diff --git a/include/winbase.h b/include/winbase.h index edd6ad6..723da26 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -1449,6 +1449,9 @@ typedef enum _DEP_SYSTEM_POLICY_TYPE { OptOut = 3 } DEP_SYSTEM_POLICY_TYPE; +#define PROCESS_DEP_ENABLE 1 +#define PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION 2 + /* Event Logging */ #define EVENTLOG_FULL_INFO 0
1
0
0
0
Sebastian Lackner : ntdll: Add support for ATL thunk 'POP ecx; POP eax; PUSH ecx; JMP 4(%eax)'.
by Alexandre Julliard
21 Oct '14
21 Oct '14
Module: wine Branch: master Commit: 1c1e7ed016c129dacc52e5f6432587270c91f681 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1c1e7ed016c129dacc52e5f64…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Tue Oct 21 06:03:57 2014 +0200 ntdll: Add support for ATL thunk 'POP ecx; POP eax; PUSH ecx; JMP 4(%eax)'. --- dlls/kernel32/tests/virtual.c | 41 +++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/signal_i386.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index ae0ede5..1592b87 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -1889,6 +1889,23 @@ static inline DWORD send_message_excpt( HWND hWnd, UINT uMsg, WPARAM wParam, LPA return ret; } +static inline DWORD call_proc_excpt( DWORD (CALLBACK *code)(void *), void *arg ) +{ + EXCEPTION_REGISTRATION_RECORD frame; + DWORD ret; + + frame.Handler = execute_fault_seh_handler; + frame.Prev = pNtCurrentTeb()->Tib.ExceptionList; + pNtCurrentTeb()->Tib.ExceptionList = &frame; + + num_guard_page_calls = num_execute_fault_calls = 0; + ret = code( arg ); + + pNtCurrentTeb()->Tib.ExceptionList = frame.Prev; + + return ret; +} + static LRESULT CALLBACK jmp_test_func( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { if (uMsg == WM_USER) @@ -1907,6 +1924,11 @@ static LRESULT CALLBACK atl_test_func( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR return 43; } +static DWORD CALLBACK atl5_test_func( void ) +{ + return 44; +} + static void test_atl_thunk_emulation( ULONG dep_flags ) { static const char code_jmp[] = {0xE9, 0x00, 0x00, 0x00, 0x00}; @@ -1914,6 +1936,7 @@ static void test_atl_thunk_emulation( ULONG dep_flags ) static const char code_atl2[] = {0xB9, 0x44, 0x33, 0x22, 0x11, 0xE9, 0x00, 0x00, 0x00, 0x00}; static const char code_atl3[] = {0xBA, 0x44, 0x33, 0x22, 0x11, 0xB9, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xE1}; static const char code_atl4[] = {0xB9, 0x44, 0x33, 0x22, 0x11, 0xB8, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xE0}; + static const char code_atl5[] = {0x59, 0x58, 0x51, 0xFF, 0x60, 0x04}; static const char cls_name[] = "atl_thunk_class"; DWORD ret, size, old_prot; ULONG old_flags = MEM_EXECUTE_OPTION_ENABLE; @@ -2133,6 +2156,24 @@ static void test_atl_thunk_emulation( ULONG dep_flags ) else ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls ); + memcpy( base, code_atl5, sizeof(code_atl5) ); + + success = VirtualProtect( base, size, PAGE_READWRITE, &old_prot ); + ok( success, "VirtualProtect failed %u\n", GetLastError() ); + + ret = (DWORD_PTR)atl5_test_func; + ret = call_proc_excpt( (void *)base, &ret - 1 ); + /* FIXME: We don't check the content of the registers EAX/ECX yet */ + ok( ret == 44, "call returned wrong result, expected 44, got %d\n", ret ); + ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls ); + if ((dep_flags & MEM_EXECUTE_OPTION_DISABLE) && (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION)) + ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls ); + else if (dep_flags & MEM_EXECUTE_OPTION_DISABLE) + ok( num_execute_fault_calls == 0 || broken(num_execute_fault_calls == 1) /* Windows XP */, + "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls ); + else + ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls ); + /* Restore the JMP instruction, set to executable, and then destroy the Window */ memcpy( base, code_jmp, sizeof(code_jmp) ); diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index b315e55..13df4bb 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -1648,6 +1648,14 @@ union atl_thunk DWORD func; WORD jmp; /* jmp eax */ } t4; + struct + { + DWORD inst1; /* pop ecx + * pop eax + * push ecx + * jmp 4(%eax) */ + WORD inst2; + } t5; }; #include "poppack.h" @@ -1708,6 +1716,26 @@ static BOOL check_atl_thunk( EXCEPTION_RECORD *rec, CONTEXT *context ) thunk, context->Eip, context->Eax, context->Ecx ); return TRUE; } + else if (thunk_len >= sizeof(thunk_copy.t5) && thunk_copy.t5.inst1 == 0xff515859 && + thunk_copy.t5.inst2 == 0x0460) + { + DWORD func, stack[2]; + if (virtual_uninterrupted_read_memory( (DWORD *)context->Esp, + stack, sizeof(stack) ) == sizeof(stack) && + virtual_uninterrupted_read_memory( (DWORD *)stack[1] + 1, + &func, sizeof(DWORD) ) == sizeof(DWORD) && + virtual_uninterrupted_write_memory( (DWORD *)context->Esp + 1, + &stack[0], sizeof(stack[0]) ) == sizeof(stack[0])) + { + context->Ecx = stack[0]; + context->Eax = stack[1]; + context->Esp = context->Esp + sizeof(DWORD); + context->Eip = func; + TRACE( "emulating ATL thunk type 5 at %p, func=%08x eax=%08x ecx=%08x esp=%08x\n", + thunk, context->Eip, context->Eax, context->Ecx, context->Esp ); + return TRUE; + } + } return FALSE; }
1
0
0
0
Sebastian Lackner : ntdll: Add support for ATL thunk 'MOV this,ecx; MOV func,eax; JMP eax'.
by Alexandre Julliard
21 Oct '14
21 Oct '14
Module: wine Branch: master Commit: dcd2b0a36695d7b5f17b753f49f1032884677234 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=dcd2b0a36695d7b5f17b753f4…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Tue Oct 21 06:02:02 2014 +0200 ntdll: Add support for ATL thunk 'MOV this,ecx; MOV func,eax; JMP eax'. --- dlls/kernel32/tests/virtual.c | 19 +++++++++++++++++++ dlls/ntdll/signal_i386.c | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index a89f1e3..ae0ede5 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -1913,6 +1913,7 @@ static void test_atl_thunk_emulation( ULONG dep_flags ) static const char code_atl1[] = {0xC7, 0x44, 0x24, 0x04, 0x44, 0x33, 0x22, 0x11, 0xE9, 0x00, 0x00, 0x00, 0x00}; static const char code_atl2[] = {0xB9, 0x44, 0x33, 0x22, 0x11, 0xE9, 0x00, 0x00, 0x00, 0x00}; static const char code_atl3[] = {0xBA, 0x44, 0x33, 0x22, 0x11, 0xB9, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xE1}; + static const char code_atl4[] = {0xB9, 0x44, 0x33, 0x22, 0x11, 0xB8, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xE0}; static const char cls_name[] = "atl_thunk_class"; DWORD ret, size, old_prot; ULONG old_flags = MEM_EXECUTE_OPTION_ENABLE; @@ -2114,6 +2115,24 @@ static void test_atl_thunk_emulation( ULONG dep_flags ) else ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls ); + memcpy( base, code_atl4, sizeof(code_atl4) ); + *(DWORD *)(base + 6) = (DWORD_PTR)atl_test_func; + + success = VirtualProtect( base, size, PAGE_READWRITE, &old_prot ); + ok( success, "VirtualProtect failed %u\n", GetLastError() ); + + ret = send_message_excpt( hWnd, WM_USER + 1, 0, 0 ); + /* FIXME: We don't check the content of the registers EAX/ECX yet */ + ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret ); + ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls ); + if ((dep_flags & MEM_EXECUTE_OPTION_DISABLE) && (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION)) + ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls ); + else if (dep_flags & MEM_EXECUTE_OPTION_DISABLE) + ok( num_execute_fault_calls == 0 || broken(num_execute_fault_calls == 1) /* Windows XP */, + "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls ); + else + ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls ); + /* Restore the JMP instruction, set to executable, and then destroy the Window */ memcpy( base, code_jmp, sizeof(code_jmp) ); diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index e8c6a77..b315e55 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -1640,6 +1640,14 @@ union atl_thunk DWORD func; WORD jmp; /* jmp ecx */ } t3; + struct + { + BYTE movl1; /* movl this,ecx */ + DWORD this; + BYTE movl2; /* movl func,eax */ + DWORD func; + WORD jmp; /* jmp eax */ + } t4; }; #include "poppack.h" @@ -1689,6 +1697,17 @@ static BOOL check_atl_thunk( EXCEPTION_RECORD *rec, CONTEXT *context ) thunk, context->Eip, context->Ecx, context->Edx ); return TRUE; } + else if (thunk_len >= sizeof(thunk_copy.t4) && thunk_copy.t4.movl1 == 0xb9 && + thunk_copy.t4.movl2 == 0xb8 && + thunk_copy.t4.jmp == 0xe0ff) + { + context->Ecx = thunk_copy.t4.this; + context->Eax = thunk_copy.t4.func; + context->Eip = thunk_copy.t4.func; + TRACE( "emulating ATL thunk type 4 at %p, func=%08x eax=%08x ecx=%08x\n", + thunk, context->Eip, context->Eax, context->Ecx ); + return TRUE; + } return FALSE; }
1
0
0
0
Sebastian Lackner : ntdll: Add support for ATL thunk 'MOV this,edx; MOV func,ecx; JMP ecx'.
by Alexandre Julliard
21 Oct '14
21 Oct '14
Module: wine Branch: master Commit: 40472cd3a7e440386a125760a42ea175bed8176e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=40472cd3a7e440386a125760a…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Tue Oct 21 06:00:20 2014 +0200 ntdll: Add support for ATL thunk 'MOV this,edx; MOV func,ecx; JMP ecx'. --- dlls/kernel32/tests/virtual.c | 16 ++++++++++++++++ dlls/ntdll/signal_i386.c | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 5f83ead..a89f1e3 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -1912,6 +1912,7 @@ static void test_atl_thunk_emulation( ULONG dep_flags ) static const char code_jmp[] = {0xE9, 0x00, 0x00, 0x00, 0x00}; static const char code_atl1[] = {0xC7, 0x44, 0x24, 0x04, 0x44, 0x33, 0x22, 0x11, 0xE9, 0x00, 0x00, 0x00, 0x00}; static const char code_atl2[] = {0xB9, 0x44, 0x33, 0x22, 0x11, 0xE9, 0x00, 0x00, 0x00, 0x00}; + static const char code_atl3[] = {0xBA, 0x44, 0x33, 0x22, 0x11, 0xB9, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xE1}; static const char cls_name[] = "atl_thunk_class"; DWORD ret, size, old_prot; ULONG old_flags = MEM_EXECUTE_OPTION_ENABLE; @@ -2098,6 +2099,21 @@ static void test_atl_thunk_emulation( ULONG dep_flags ) else ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls ); + memcpy( base, code_atl3, sizeof(code_atl3) ); + *(DWORD *)(base + 6) = (DWORD_PTR)atl_test_func; + + success = VirtualProtect( base, size, PAGE_READWRITE, &old_prot ); + ok( success, "VirtualProtect failed %u\n", GetLastError() ); + + ret = send_message_excpt( hWnd, WM_USER + 1, 0, 0 ); + /* FIXME: we don't check the content of the registers ECX/EDX yet */ + ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret ); + ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls ); + if ((dep_flags & MEM_EXECUTE_OPTION_DISABLE) && (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION)) + ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls ); + else + ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls ); + /* Restore the JMP instruction, set to executable, and then destroy the Window */ memcpy( base, code_jmp, sizeof(code_jmp) ); diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index dde4e2d..e8c6a77 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -1632,6 +1632,14 @@ union atl_thunk BYTE jmp; /* jmp func */ int func; } t2; + struct + { + BYTE movl1; /* movl this,edx */ + DWORD this; + BYTE movl2; /* movl func,ecx */ + DWORD func; + WORD jmp; /* jmp ecx */ + } t3; }; #include "poppack.h" @@ -1670,6 +1678,17 @@ static BOOL check_atl_thunk( EXCEPTION_RECORD *rec, CONTEXT *context ) thunk, context->Eip, context->Ecx ); return TRUE; } + else if (thunk_len >= sizeof(thunk_copy.t3) && thunk_copy.t3.movl1 == 0xba && + thunk_copy.t3.movl2 == 0xb9 && + thunk_copy.t3.jmp == 0xe1ff) + { + context->Edx = thunk_copy.t3.this; + context->Ecx = thunk_copy.t3.func; + context->Eip = thunk_copy.t3.func; + TRACE( "emulating ATL thunk type 3 at %p, func=%08x ecx=%08x edx=%08x\n", + thunk, context->Eip, context->Ecx, context->Edx ); + return TRUE; + } return FALSE; }
1
0
0
0
Sebastian Lackner : ntdll: Add support for ATL thunk 'MOV this,ecx; JMP func'.
by Alexandre Julliard
21 Oct '14
21 Oct '14
Module: wine Branch: master Commit: aab0d25a49ab2c8d67d05e0c16ab6c02d041fd6b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=aab0d25a49ab2c8d67d05e0c1…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Tue Oct 21 05:55:27 2014 +0200 ntdll: Add support for ATL thunk 'MOV this,ecx; JMP func'. --- dlls/kernel32/tests/virtual.c | 31 +++++++++++++++++++++---- dlls/ntdll/signal_i386.c | 54 +++++++++++++++++++++++++++++-------------- 2 files changed, 63 insertions(+), 22 deletions(-) diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 73b753e..5f83ead 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -1882,7 +1882,7 @@ static inline DWORD send_message_excpt( HWND hWnd, UINT uMsg, WPARAM wParam, LPA pNtCurrentTeb()->Tib.ExceptionList = &frame; num_guard_page_calls = num_execute_fault_calls = 0; - ret = SendMessageA( hWnd, WM_USER, 0, 0 ); + ret = SendMessageA( hWnd, uMsg, wParam, lParam ); pNtCurrentTeb()->Tib.ExceptionList = frame.Prev; @@ -1900,14 +1900,18 @@ static LRESULT CALLBACK jmp_test_func( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR static LRESULT CALLBACK atl_test_func( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { DWORD arg = (DWORD)hWnd; - ok( arg == 0x11223344, "arg is 0x%08x instead of 0x11223344\n", arg ); + if (uMsg == WM_USER) + ok( arg == 0x11223344, "arg is 0x%08x instead of 0x11223344\n", arg ); + else + ok( arg != 0x11223344, "arg is unexpectedly 0x11223344\n" ); return 43; } static void test_atl_thunk_emulation( ULONG dep_flags ) { static const char code_jmp[] = {0xE9, 0x00, 0x00, 0x00, 0x00}; - static const char code_atl[] = {0xC7, 0x44, 0x24, 0x04, 0x44, 0x33, 0x22, 0x11, 0xE9, 0x00, 0x00, 0x00, 0x00}; + static const char code_atl1[] = {0xC7, 0x44, 0x24, 0x04, 0x44, 0x33, 0x22, 0x11, 0xE9, 0x00, 0x00, 0x00, 0x00}; + static const char code_atl2[] = {0xB9, 0x44, 0x33, 0x22, 0x11, 0xE9, 0x00, 0x00, 0x00, 0x00}; static const char cls_name[] = "atl_thunk_class"; DWORD ret, size, old_prot; ULONG old_flags = MEM_EXECUTE_OPTION_ENABLE; @@ -2008,7 +2012,7 @@ static void test_atl_thunk_emulation( ULONG dep_flags ) /* Now test with a proper ATL thunk instruction. */ - memcpy( base, code_atl, sizeof(code_atl) ); + memcpy( base, code_atl1, sizeof(code_atl1) ); *(DWORD *)(base + 9) = (DWORD_PTR)atl_test_func - (DWORD_PTR)(base + 13); success = VirtualProtect( base, size, PAGE_EXECUTE_READWRITE, &old_prot ); @@ -2077,6 +2081,23 @@ static void test_atl_thunk_emulation( ULONG dep_flags ) win_skip( "RtlAddVectoredExceptionHandler or RtlRemoveVectoredExceptionHandler not found\n" ); } + /* Test alternative ATL thunk instructions. */ + + memcpy( base, code_atl2, sizeof(code_atl2) ); + *(DWORD *)(base + 6) = (DWORD_PTR)atl_test_func - (DWORD_PTR)(base + 10); + + success = VirtualProtect( base, size, PAGE_READWRITE, &old_prot ); + ok( success, "VirtualProtect failed %u\n", GetLastError() ); + + ret = send_message_excpt( hWnd, WM_USER + 1, 0, 0 ); + /* FIXME: we don't check the content of the register ECX yet */ + ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret ); + ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls ); + if ((dep_flags & MEM_EXECUTE_OPTION_DISABLE) && (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION)) + ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls ); + else + ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls ); + /* Restore the JMP instruction, set to executable, and then destroy the Window */ memcpy( base, code_jmp, sizeof(code_jmp) ); @@ -2194,7 +2215,7 @@ static void test_atl_thunk_emulation( ULONG dep_flags ) /* Now test with a proper ATL thunk instruction. */ - memcpy( base, code_atl, sizeof(code_atl) ); + memcpy( base, code_atl1, sizeof(code_atl1) ); *(DWORD *)(base + 9) = (DWORD_PTR)atl_test_func - (DWORD_PTR)(base + 13); count = 64; diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index f97799c..dde4e2d 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -1616,12 +1616,22 @@ static inline BOOL check_invalid_gs( CONTEXT *context ) #include "pshpack1.h" -struct atl_thunk +union atl_thunk { - DWORD movl; /* movl this,4(%esp) */ - DWORD this; - BYTE jmp; /* jmp func */ - int func; + struct + { + DWORD movl; /* movl this,4(%esp) */ + DWORD this; + BYTE jmp; /* jmp func */ + int func; + } t1; + struct + { + BYTE movl; /* movl this,ecx */ + DWORD this; + BYTE jmp; /* jmp func */ + int func; + } t2; }; #include "poppack.h" @@ -1632,26 +1642,36 @@ struct atl_thunk */ static BOOL check_atl_thunk( EXCEPTION_RECORD *rec, CONTEXT *context ) { - const struct atl_thunk *thunk = (const struct atl_thunk *)rec->ExceptionInformation[1]; - struct atl_thunk thunk_copy; - BOOL ret = FALSE; + const union atl_thunk *thunk = (const union atl_thunk *)rec->ExceptionInformation[1]; + union atl_thunk thunk_copy; + SIZE_T thunk_len; - if (virtual_uninterrupted_read_memory( thunk, &thunk_copy, sizeof(*thunk) ) != sizeof(*thunk)) - return FALSE; + thunk_len = virtual_uninterrupted_read_memory( thunk, &thunk_copy, sizeof(*thunk) ); + if (!thunk_len) return FALSE; - if (thunk_copy.movl == 0x042444c7 && thunk_copy.jmp == 0xe9) + if (thunk_len >= sizeof(thunk_copy.t1) && thunk_copy.t1.movl == 0x042444c7 && + thunk_copy.t1.jmp == 0xe9) { if (virtual_uninterrupted_write_memory( (DWORD *)context->Esp + 1, - &thunk_copy.this, sizeof(DWORD) ) == sizeof(DWORD)) + &thunk_copy.t1.this, sizeof(DWORD) ) == sizeof(DWORD)) { - context->Eip = (DWORD_PTR)(&thunk->func + 1) + thunk_copy.func; - TRACE( "emulating ATL thunk at %p, func=%08x arg=%08x\n", - thunk, context->Eip, thunk_copy.this ); - ret = TRUE; + context->Eip = (DWORD_PTR)(&thunk->t1.func + 1) + thunk_copy.t1.func; + TRACE( "emulating ATL thunk type 1 at %p, func=%08x arg=%08x\n", + thunk, context->Eip, thunk_copy.t1.this ); + return TRUE; } } + else if (thunk_len >= sizeof(thunk_copy.t2) && thunk_copy.t2.movl == 0xb9 && + thunk_copy.t2.jmp == 0xe9) + { + context->Ecx = thunk_copy.t2.this; + context->Eip = (DWORD_PTR)(&thunk->t2.func + 1) + thunk_copy.t2.func; + TRACE( "emulating ATL thunk type 2 at %p, func=%08x ecx=%08x\n", + thunk, context->Eip, context->Ecx ); + return TRUE; + } - return ret; + return FALSE; }
1
0
0
0
Hans Leidekker : msi: Support more transform validation flags.
by Alexandre Julliard
21 Oct '14
21 Oct '14
Module: wine Branch: master Commit: 1e3f15d88c1e878f5c459e642ff2079b05aa5c41 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1e3f15d88c1e878f5c459e642…
Author: Hans Leidekker <hans(a)codeweavers.com> Date: Tue Oct 21 11:29:08 2014 +0200 msi: Support more transform validation flags. --- dlls/msi/msipriv.h | 1 + dlls/msi/package.c | 2 +- dlls/msi/patch.c | 215 ++++++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 191 insertions(+), 27 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=1e3f15d88c1e878f5c459…
1
0
0
0
Hans Leidekker : secur32/tests: Switch requested protocol from SSL3 to TLS1.
by Alexandre Julliard
21 Oct '14
21 Oct '14
Module: wine Branch: master Commit: 5a6558b854bc320066d8dfbfa4a7a1d21dc88837 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=5a6558b854bc320066d8dfbfa…
Author: Hans Leidekker <hans(a)codeweavers.com> Date: Tue Oct 21 11:28:44 2014 +0200 secur32/tests: Switch requested protocol from SSL3 to TLS1. --- dlls/secur32/tests/schannel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/secur32/tests/schannel.c b/dlls/secur32/tests/schannel.c index e868b13..97fa0bc 100644 --- a/dlls/secur32/tests/schannel.c +++ b/dlls/secur32/tests/schannel.c @@ -533,7 +533,7 @@ static void init_cred(SCHANNEL_CRED *cred) cred->aphMappers = NULL; cred->cSupportedAlgs = 0; cred->palgSupportedAlgs = NULL; - cred->grbitEnabledProtocols = SP_PROT_SSL3_CLIENT; + cred->grbitEnabledProtocols = SP_PROT_TLS1_CLIENT; cred->dwMinimumCipherStrength = 0; cred->dwMaximumCipherStrength = 0; cred->dwSessionLifespan = 0; @@ -685,7 +685,7 @@ static void test_communication(void) ok(status == SEC_E_OK, "AcquireCredentialsHandleA failed: %08x\n", status); if (status != SEC_E_OK) return; - test_supported_protocols(&cred_handle, SP_PROT_SSL3_CLIENT); + test_supported_protocols(&cred_handle, SP_PROT_TLS1_CLIENT); /* Initialize the connection */ init_buffers(&buffers[0], 4, buf_size);
1
0
0
0
Nikolay Sivov : dwrite: Implement GetInformationalStrings().
by Alexandre Julliard
21 Oct '14
21 Oct '14
Module: wine Branch: master Commit: 04a237fe18cb775bf7545472bea88d6a79e5344e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=04a237fe18cb775bf7545472b…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon Oct 20 21:45:57 2014 +0400 dwrite: Implement GetInformationalStrings(). --- dlls/dwrite/dwrite_private.h | 1 + dlls/dwrite/font.c | 45 ++++++++-- dlls/dwrite/opentype.c | 204 +++++++++++++++++++++++++++++++++++++++++++ dlls/dwrite/tests/font.c | 6 +- 4 files changed, 244 insertions(+), 12 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=04a237fe18cb775bf7545…
1
0
0
0
Nikolay Sivov : dwrite: Store registered file loaders in a list.
by Alexandre Julliard
21 Oct '14
21 Oct '14
Module: wine Branch: master Commit: 177f601889dac6e887564011035f93e7499da828 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=177f601889dac6e8875640110…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon Oct 20 12:53:21 2014 +0400 dwrite: Store registered file loaders in a list. --- dlls/dwrite/main.c | 115 ++++++++++++++++++++++++++--------------------------- 1 file changed, 56 insertions(+), 59 deletions(-) diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index cdd27c2..bac0c78 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -398,6 +398,12 @@ struct collectionloader IDWriteFontCollectionLoader *loader; }; +struct fileloader +{ + struct list entry; + IDWriteFontFileLoader *loader; +}; + struct dwritefactory { IDWriteFactory IDWriteFactory_iface; LONG ref; @@ -407,8 +413,7 @@ struct dwritefactory { IDWriteGdiInterop *gdiinterop; struct list collection_loaders; - IDWriteFontFileLoader **file_loaders; - LONG file_loader_count; + struct list file_loaders; }; static inline struct dwritefactory *impl_from_IDWriteFactory(IDWriteFactory *iface) @@ -418,8 +423,8 @@ static inline struct dwritefactory *impl_from_IDWriteFactory(IDWriteFactory *ifa static void release_dwritefactory(struct dwritefactory *factory) { + struct fileloader *fileloader, *fileloader2; struct collectionloader *loader, *loader2; - int i; if (factory->localfontfileloader) IDWriteLocalFontFileLoader_Release(factory->localfontfileloader); @@ -430,10 +435,12 @@ static void release_dwritefactory(struct dwritefactory *factory) heap_free(loader); } - for (i = 0; i < factory->file_loader_count; i++) - if (factory->file_loaders[i]) - IDWriteFontFileLoader_Release(factory->file_loaders[i]); - heap_free(factory->file_loaders); + LIST_FOR_EACH_ENTRY_SAFE(fileloader, fileloader2, &factory->file_loaders, struct fileloader, entry) { + list_remove(&fileloader->entry); + IDWriteFontFileLoader_Release(fileloader->loader); + heap_free(fileloader); + } + if (factory->system_collection) IDWriteFontCollection_Release(factory->system_collection); if (factory->gdiinterop) @@ -449,6 +456,20 @@ static void release_shared_factory(IDWriteFactory *iface) release_dwritefactory(factory); } +static struct fileloader *factory_get_file_loader(struct dwritefactory *factory, IDWriteFontFileLoader *loader) +{ + struct fileloader *entry, *found = NULL; + + LIST_FOR_EACH_ENTRY(entry, &factory->file_loaders, struct fileloader, entry) { + if (entry->loader == loader) { + found = entry; + break; + } + } + + return found; +} + static HRESULT WINAPI dwritefactory_QueryInterface(IDWriteFactory *iface, REFIID riid, void **obj) { struct dwritefactory *This = impl_from_IDWriteFactory(iface); @@ -592,21 +613,14 @@ static HRESULT WINAPI dwritefactory_CreateFontFileReference(IDWriteFactory *ifac static HRESULT WINAPI dwritefactory_CreateCustomFontFileReference(IDWriteFactory *iface, void const *reference_key, UINT32 key_size, IDWriteFontFileLoader *loader, IDWriteFontFile **font_file) { - int i; struct dwritefactory *This = impl_from_IDWriteFactory(iface); - HRESULT hr; TRACE("(%p)->(%p %u %p %p)\n", This, reference_key, key_size, loader, font_file); - if (loader == NULL) + if (!loader || !factory_get_file_loader(This, loader)) return E_INVALIDARG; - for (i = 0; i < This->file_loader_count; i++) - if (This->file_loaders[i] == loader) break; - if (i == This->file_loader_count) - return E_INVALIDARG; - hr = create_font_file(loader, reference_key, key_size, font_file); - return hr; + return create_font_file(loader, reference_key, key_size, font_file); } static HRESULT WINAPI dwritefactory_CreateFontFace(IDWriteFactory *iface, @@ -655,53 +669,47 @@ static HRESULT WINAPI dwritefactory_CreateCustomRenderingParams(IDWriteFactory * static HRESULT WINAPI dwritefactory_RegisterFontFileLoader(IDWriteFactory *iface, IDWriteFontFileLoader *loader) { - int i; struct dwritefactory *This = impl_from_IDWriteFactory(iface); + struct fileloader *entry; + TRACE("(%p)->(%p)\n", This, loader); if (!loader) return E_INVALIDARG; - for (i = 0; i < This->file_loader_count; i++) - if (This->file_loaders[i] == loader) + LIST_FOR_EACH_ENTRY(entry, &This->file_loaders, struct fileloader, entry) { + if (entry->loader == loader) return DWRITE_E_ALREADYREGISTERED; - else if (This->file_loaders[i] == NULL) - break; - - if (i == This->file_loader_count) - { - IDWriteFontFileLoader **new_list = NULL; - int new_count = 0; - - new_count = This->file_loader_count * 2; - new_list = heap_realloc_zero(This->file_loaders, new_count * sizeof(*This->file_loaders)); - - if (!new_list) - return E_OUTOFMEMORY; - else - { - This->file_loader_count = new_count; - This->file_loaders = new_list; - } } + + entry = heap_alloc(sizeof(*entry)); + if (!entry) + return E_OUTOFMEMORY; + + entry->loader = loader; IDWriteFontFileLoader_AddRef(loader); - This->file_loaders[i] = loader; + list_add_tail(&This->file_loaders, &entry->entry); return S_OK; } static HRESULT WINAPI dwritefactory_UnregisterFontFileLoader(IDWriteFactory *iface, IDWriteFontFileLoader *loader) { - int i; struct dwritefactory *This = impl_from_IDWriteFactory(iface); + struct fileloader *found; + TRACE("(%p)->(%p)\n", This, loader); - for (i = 0; i < This->file_loader_count; i++) - if (This->file_loaders[i] == loader) break; - if (i == This->file_loader_count) - return E_INVALIDARG; - IDWriteFontFileLoader_Release(This->file_loaders[i]); - This->file_loaders[i] = NULL; + if (!loader) + return E_INVALIDARG; + + found = factory_get_file_loader(This, loader); + if (!found) + return E_INVALIDARG; + + IDWriteFontFileLoader_Release(found->loader); + list_remove(&found->entry); + heap_free(found); return S_OK; } @@ -875,28 +883,21 @@ static const struct IDWriteFactoryVtbl shareddwritefactoryvtbl = { dwritefactory_CreateGlyphRunAnalysis }; -static HRESULT init_dwritefactory(struct dwritefactory *factory, const struct IDWriteFactoryVtbl *vtbl) +static void init_dwritefactory(struct dwritefactory *factory, const struct IDWriteFactoryVtbl *vtbl) { factory->IDWriteFactory_iface.lpVtbl = vtbl; factory->ref = 1; factory->localfontfileloader = NULL; - factory->file_loader_count = 2; - factory->file_loaders = heap_alloc_zero(sizeof(*factory->file_loaders) * 2); factory->system_collection = NULL; factory->gdiinterop = NULL; list_init(&factory->collection_loaders); - - if (!factory->file_loaders) - return E_OUTOFMEMORY; - - return S_OK; + list_init(&factory->file_loaders); } HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnknown **ret) { struct dwritefactory *factory; - HRESULT hr; TRACE("(%d, %s, %p)\n", type, debugstr_guid(riid), ret); @@ -913,11 +914,7 @@ HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnkno factory = heap_alloc(sizeof(struct dwritefactory)); if (!factory) return E_OUTOFMEMORY; - hr = init_dwritefactory(factory, type == DWRITE_FACTORY_TYPE_SHARED ? &shareddwritefactoryvtbl : &dwritefactoryvtbl); - if (FAILED(hr)) { - heap_free(factory); - return hr; - } + init_dwritefactory(factory, type == DWRITE_FACTORY_TYPE_SHARED ? &shareddwritefactoryvtbl : &dwritefactoryvtbl); if (type == DWRITE_FACTORY_TYPE_SHARED) if (InterlockedCompareExchangePointer((void**)&shared_factory, factory, NULL)) {
1
0
0
0
← Newer
1
...
13
14
15
16
17
18
19
...
40
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
Results per page:
10
25
50
100
200