ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
August 2014
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
16 participants
226 discussions
Start a n
N
ew thread
[jgardou] 63997: [REACTOS.DFF] - Add optional GNUTLS DLLs for the curious. They can be grabbed from here: ftp://ftp.gnutls.org/gcrypt/gnutls/w32/gnutls-3.2.16-w32.zip We will provide a MSI package ...
by jgardou@svn.reactos.org
Author: jgardou Date: Sat Aug 30 21:33:42 2014 New Revision: 63997 URL:
http://svn.reactos.org/svn/reactos?rev=63997&view=rev
Log: [REACTOS.DFF] - Add optional GNUTLS DLLs for the curious. They can be grabbed from here:
ftp://ftp.gnutls.org/gcrypt/gnutls/w32/gnutls-3.2.16-w32.zip
We will provide a MSI package soon Modified: trunk/reactos/boot/bootdata/packages/reactos.dff.in Modified: trunk/reactos/boot/bootdata/packages/reactos.dff.in URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/packages/rea…
============================================================================== --- trunk/reactos/boot/bootdata/packages/reactos.dff.in [iso-8859-1] (original) +++ trunk/reactos/boot/bootdata/packages/reactos.dff.in [iso-8859-1] Sat Aug 30 21:33:42 2014 @@ -66,6 +66,7 @@ 50 = security\templates 51 = system32\CatRoot 52 = system32\CatRoot2 +53 = system32\gnutls .InfEnd @@ -100,3 +101,12 @@ "modules/optional/vmx_svga.sys" 2 optional "modules/optional/wine_gecko-2.24-x86.msi" 4 optional "boot/bootdata/bootcdregtest/AHKAppTests.cmd" 7 optional +"modules/optional/gnutls/libgcc_s_sjlj-1.dll" 53 optional +"modules/optional/gnutls/libgmp-10.dll" 53 optional +"modules/optional/gnutls/libgnutls-28.dll" 53 optional +"modules/optional/gnutls/libgnutls-xssl-0.dll" 53 optional +"modules/optional/gnutls/libgnutlsxx-28.dll" 53 optional +"modules/optional/gnutls/libhogweed-2-5.dll" 53 optional +"modules/optional/gnutls/libnettle-4-7.dll" 53 optional +"modules/optional/gnutls/libp11-kit-0.dll" 53 optional +"modules/optional/gnutls/libwinpthread-1.dll" 53 optional
10 years, 3 months
1
0
0
0
[jgardou] 63996: [SCHANNEL] - Import TLS/SSL support on top of GNUTLS from wine Won't work until we ship the gnutls DLLs
by jgardou@svn.reactos.org
Author: jgardou Date: Sat Aug 30 21:33:21 2014 New Revision: 63996 URL:
http://svn.reactos.org/svn/reactos?rev=63996&view=rev
Log: [SCHANNEL] - Import TLS/SSL support on top of GNUTLS from wine Won't work until we ship the gnutls DLLs Added: trunk/reactos/dll/win32/schannel/schannel_gnutls.c (with props) trunk/reactos/dll/win32/schannel/schannel_priv.h (with props) trunk/reactos/dll/win32/schannel/schannel_wine.c (with props) trunk/reactos/dll/win32/schannel/secur32_wine.c (with props) trunk/reactos/dll/win32/schannel/stubs.c (with props) Modified: trunk/reactos/dll/win32/schannel/CMakeLists.txt trunk/reactos/dll/win32/schannel/precomp.h trunk/reactos/dll/win32/schannel/schannel.spec trunk/reactos/dll/win32/schannel/schannel_main.c Modified: trunk/reactos/dll/win32/schannel/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/schannel/CMakeLi…
============================================================================== --- trunk/reactos/dll/win32/schannel/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/dll/win32/schannel/CMakeLists.txt [iso-8859-1] Sat Aug 30 21:33:21 2014 @@ -1,12 +1,20 @@ -include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) -add_definitions(-D__WINESRC__) +include_directories( + ${REACTOS_SOURCE_DIR}/include/reactos/wine + ${REACTOS_SOURCE_DIR}/include/reactos/libs/gnutls) + + +add_definitions(-D__WINESRC__ -D_WINE) spec2def(schannel.dll schannel.spec) list(APPEND SOURCE lsamode.c + schannel_gnutls.c schannel_main.c + schannel_wine.c + secur32_wine.c usermode.c + stubs.c precomp.h ${CMAKE_CURRENT_BINARY_DIR}/schannel_stubs.c) @@ -17,6 +25,6 @@ set_module_type(schannel win32dll) target_link_libraries(schannel wine) -add_importlibs(schannel secur32 msvcrt kernel32 ntdll) +add_importlibs(schannel crypt32 advapi32 msvcrt kernel32 ntdll) add_pch(schannel precomp.h SOURCE) add_cd_file(TARGET schannel DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/dll/win32/schannel/precomp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/schannel/precomp…
============================================================================== --- trunk/reactos/dll/win32/schannel/precomp.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/schannel/precomp.h [iso-8859-1] Sat Aug 30 21:33:21 2014 @@ -10,11 +10,20 @@ #define WIN32_NO_STATUS #include <windef.h> #include <winbase.h> +#include <winnls.h> +#include <winreg.h> #include <sspi.h> #include <ntsecapi.h> #include <ntsecpkg.h> +#include <schannel.h> + +#include <wine/list.h> +#include "schannel_priv.h" + #include <wine/debug.h> +#include <wine/unicode.h> + WINE_DEFAULT_DEBUG_CHANNEL(schannel); #endif /* _SCHANNEL_PCH_ */ Modified: trunk/reactos/dll/win32/schannel/schannel.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/schannel/schanne…
============================================================================== --- trunk/reactos/dll/win32/schannel/schannel.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/schannel/schannel.spec [iso-8859-1] Sat Aug 30 21:33:21 2014 @@ -1,24 +1,24 @@ -@ stdcall AcceptSecurityContext(ptr ptr ptr long long ptr ptr ptr ptr) secur32.AcceptSecurityContext -@ stdcall AcquireCredentialsHandleA(str str long ptr ptr ptr ptr ptr ptr) secur32.AcquireCredentialsHandleA -@ stdcall AcquireCredentialsHandleW(wstr wstr long ptr ptr ptr ptr ptr ptr) secur32.AcquireCredentialsHandleW -@ stdcall ApplyControlToken(ptr ptr) secur32.ApplyControlToken +@ stdcall AcceptSecurityContext(ptr ptr ptr long long ptr ptr ptr ptr) schan_AcceptSecurityContext +@ stdcall AcquireCredentialsHandleA(str str long ptr ptr ptr ptr ptr ptr) schan_AcquireCredentialsHandleA +@ stdcall AcquireCredentialsHandleW(wstr wstr long ptr ptr ptr ptr ptr ptr) schan_AcquireCredentialsHandleW +@ stdcall ApplyControlToken(ptr ptr) schan_ApplyControlToken @ stub CloseSslPerformanceData @ stub CollectSslPerformanceData -@ stdcall CompleteAuthToken(ptr ptr) secur32.CompleteAuthToken -@ stdcall DeleteSecurityContext(ptr) secur32.DeleteSecurityContext -@ stdcall EnumerateSecurityPackagesA(ptr ptr) secur32.EnumerateSecurityPackagesA -@ stdcall EnumerateSecurityPackagesW(ptr ptr) secur32.EnumerateSecurityPackagesW -@ stdcall FreeContextBuffer(ptr) secur32.FreeContextBuffer -@ stdcall FreeCredentialsHandle(ptr) secur32.FreeCredentialsHandle -@ stdcall ImpersonateSecurityContext(ptr) secur32.ImpersonateSecurityContext -@ stdcall InitSecurityInterfaceA() secur32.InitSecurityInterfaceA -@ stdcall InitSecurityInterfaceW() secur32.InitSecurityInterfaceW -@ stdcall InitializeSecurityContextA(ptr ptr str long long long ptr long ptr ptr ptr ptr) secur32.InitializeSecurityContextA -@ stdcall InitializeSecurityContextW(ptr ptr wstr long long long ptr long ptr ptr ptr ptr) secur32.InitializeSecurityContextW +@ stdcall CompleteAuthToken(ptr ptr) schan_CompleteAuthToken +@ stdcall DeleteSecurityContext(ptr) schan_DeleteSecurityContext +@ stdcall EnumerateSecurityPackagesA(ptr ptr) schan_EnumerateSecurityPackagesA +@ stdcall EnumerateSecurityPackagesW(ptr ptr) schan_EnumerateSecurityPackagesW +@ stdcall FreeContextBuffer(ptr) schan_FreeContextBuffer +@ stdcall FreeCredentialsHandle(ptr) schan_FreeCredentialsHandle +@ stdcall ImpersonateSecurityContext(ptr) schan_ImpersonateSecurityContext +@ stdcall InitSecurityInterfaceA() schan_InitSecurityInterfaceA +@ stdcall InitSecurityInterfaceW() schan_InitSecurityInterfaceW +@ stdcall InitializeSecurityContextA(ptr ptr str long long long ptr long ptr ptr ptr ptr) schan_InitializeSecurityContextA +@ stdcall InitializeSecurityContextW(ptr ptr wstr long long long ptr long ptr ptr ptr ptr) schan_InitializeSecurityContextW @ stdcall MakeSignature(ptr long ptr long) secur32.MakeSignature @ stub OpenSslPerformanceData -@ stdcall QueryContextAttributesA(ptr long ptr) secur32.QueryContextAttributesA -@ stdcall QueryContextAttributesW(ptr long ptr) secur32.QueryContextAttributesW +@ stdcall QueryContextAttributesA(ptr long ptr) schan_QueryContextAttributesA +@ stdcall QueryContextAttributesW(ptr long ptr) schan_QueryContextAttributesW @ stdcall QuerySecurityPackageInfoA(str ptr) secur32.QuerySecurityPackageInfoA @ stdcall QuerySecurityPackageInfoW(wstr ptr) secur32.QuerySecurityPackageInfoW @ stdcall RevertSecurityContext(ptr) secur32.RevertSecurityContext Added: trunk/reactos/dll/win32/schannel/schannel_gnutls.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/schannel/schanne…
============================================================================== --- trunk/reactos/dll/win32/schannel/schannel_gnutls.c (added) +++ trunk/reactos/dll/win32/schannel/schannel_gnutls.c [iso-8859-1] Sat Aug 30 21:33:21 2014 @@ -0,0 +1,593 @@ +/* + * GnuTLS-based implementation of the schannel (SSL/TLS) provider. + * + * Copyright 2005 Juan Lang + * Copyright 2008 Henri Verbeet + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "precomp.h" + +#include <wine/config.h> +#include <wine/port.h> +#include <strsafe.h> + +#ifdef SONAME_LIBGNUTLS +#include <gnutls/gnutls.h> +#include <gnutls/crypto.h> +#endif + +#define __wine_dbch_secur32 __wine_dbch_schannel + +#if defined(SONAME_LIBGNUTLS) && !defined(HAVE_SECURITY_SECURITY_H) + +static void *libgnutls_handle; +#define MAKE_FUNCPTR(f) static typeof(f) * p##f +MAKE_FUNCPTR(gnutls_alert_get); +MAKE_FUNCPTR(gnutls_alert_get_name); +MAKE_FUNCPTR(gnutls_certificate_allocate_credentials); +MAKE_FUNCPTR(gnutls_certificate_free_credentials); +MAKE_FUNCPTR(gnutls_certificate_get_peers); +MAKE_FUNCPTR(gnutls_cipher_get); +MAKE_FUNCPTR(gnutls_cipher_get_key_size); +MAKE_FUNCPTR(gnutls_credentials_set); +MAKE_FUNCPTR(gnutls_deinit); +MAKE_FUNCPTR(gnutls_global_deinit); +MAKE_FUNCPTR(gnutls_global_init); +MAKE_FUNCPTR(gnutls_global_set_log_function); +MAKE_FUNCPTR(gnutls_global_set_log_level); +MAKE_FUNCPTR(gnutls_handshake); +MAKE_FUNCPTR(gnutls_init); +MAKE_FUNCPTR(gnutls_kx_get); +MAKE_FUNCPTR(gnutls_mac_get); +MAKE_FUNCPTR(gnutls_mac_get_key_size); +MAKE_FUNCPTR(gnutls_perror); +MAKE_FUNCPTR(gnutls_protocol_get_version); +MAKE_FUNCPTR(gnutls_priority_set_direct); +MAKE_FUNCPTR(gnutls_record_get_max_size); +MAKE_FUNCPTR(gnutls_record_recv); +MAKE_FUNCPTR(gnutls_record_send); +MAKE_FUNCPTR(gnutls_server_name_set); +MAKE_FUNCPTR(gnutls_transport_get_ptr); +MAKE_FUNCPTR(gnutls_transport_set_errno); +MAKE_FUNCPTR(gnutls_transport_set_ptr); +MAKE_FUNCPTR(gnutls_transport_set_pull_function); +MAKE_FUNCPTR(gnutls_transport_set_push_function); +#undef MAKE_FUNCPTR + + + +static ssize_t schan_pull_adapter(gnutls_transport_ptr_t transport, + void *buff, size_t buff_len) +{ + struct schan_transport *t = (struct schan_transport*)transport; + gnutls_session_t s = (gnutls_session_t)schan_session_for_transport(t); + + int ret = schan_pull(transport, buff, &buff_len); + if (ret) + { + pgnutls_transport_set_errno(s, ret); + return -1; + } + + return buff_len; +} + +static ssize_t schan_push_adapter(gnutls_transport_ptr_t transport, + const void *buff, size_t buff_len) +{ + struct schan_transport *t = (struct schan_transport*)transport; + gnutls_session_t s = (gnutls_session_t)schan_session_for_transport(t); + + int ret = schan_push(transport, buff, &buff_len); + if (ret) + { + pgnutls_transport_set_errno(s, ret); + return -1; + } + + return buff_len; +} + +static const struct { + DWORD enable_flag; + const char *gnutls_flag; +} protocol_priority_flags[] = { + {SP_PROT_TLS1_2_CLIENT, "VERS-TLS1.2"}, + {SP_PROT_TLS1_1_CLIENT, "VERS-TLS1.1"}, + {SP_PROT_TLS1_0_CLIENT, "VERS-TLS1.0"}, + {SP_PROT_SSL3_CLIENT, "VERS-SSL3.0"} + /* {SP_PROT_SSL2_CLIENT} is not supported by GnuTLS */ +}; + +DWORD schan_imp_enabled_protocols(void) +{ + /* NOTE: No support for SSL 2.0 */ + return SP_PROT_SSL3_CLIENT | SP_PROT_TLS1_0_CLIENT | SP_PROT_TLS1_1_CLIENT | SP_PROT_TLS1_2_CLIENT; +} + +BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cred) +{ + gnutls_session_t *s = (gnutls_session_t*)session; + char priority[64] = "NORMAL", *p; + unsigned i; + + int err = pgnutls_init(s, cred->credential_use == SECPKG_CRED_INBOUND ? GNUTLS_SERVER : GNUTLS_CLIENT); + if (err != GNUTLS_E_SUCCESS) + { + pgnutls_perror(err); + return FALSE; + } + + p = priority + strlen(priority); + for(i=0; i < sizeof(protocol_priority_flags)/sizeof(*protocol_priority_flags); i++) { + *p++ = ':'; + *p++ = (cred->enabled_protocols & protocol_priority_flags[i].enable_flag) ? '+' : '-'; + strcpy(p, protocol_priority_flags[i].gnutls_flag); + p += strlen(p); + } + + TRACE("Using %s priority\n", debugstr_a(priority)); + err = pgnutls_priority_set_direct(*s, priority, NULL); + if (err != GNUTLS_E_SUCCESS) + { + pgnutls_perror(err); + pgnutls_deinit(*s); + return FALSE; + } + + err = pgnutls_credentials_set(*s, GNUTLS_CRD_CERTIFICATE, + (gnutls_certificate_credentials_t)cred->credentials); + if (err != GNUTLS_E_SUCCESS) + { + pgnutls_perror(err); + pgnutls_deinit(*s); + return FALSE; + } + + pgnutls_transport_set_pull_function(*s, schan_pull_adapter); + pgnutls_transport_set_push_function(*s, schan_push_adapter); + + return TRUE; +} + +void schan_imp_dispose_session(schan_imp_session session) +{ + gnutls_session_t s = (gnutls_session_t)session; + pgnutls_deinit(s); +} + +void schan_imp_set_session_transport(schan_imp_session session, + struct schan_transport *t) +{ + gnutls_session_t s = (gnutls_session_t)session; + pgnutls_transport_set_ptr(s, (gnutls_transport_ptr_t)t); +} + +void schan_imp_set_session_target(schan_imp_session session, const char *target) +{ + gnutls_session_t s = (gnutls_session_t)session; + + pgnutls_server_name_set( s, GNUTLS_NAME_DNS, target, strlen(target) ); +} + +SECURITY_STATUS schan_imp_handshake(schan_imp_session session) +{ + gnutls_session_t s = (gnutls_session_t)session; + int err; + + while(1) { + err = pgnutls_handshake(s); + switch(err) { + case GNUTLS_E_SUCCESS: + TRACE("Handshake completed\n"); + return SEC_E_OK; + + case GNUTLS_E_AGAIN: + TRACE("Continue...\n"); + return SEC_I_CONTINUE_NEEDED; + + case GNUTLS_E_WARNING_ALERT_RECEIVED: + { + gnutls_alert_description_t alert = pgnutls_alert_get(s); + + WARN("WARNING ALERT: %d %s\n", alert, pgnutls_alert_get_name(alert)); + + switch(alert) { + case GNUTLS_A_UNRECOGNIZED_NAME: + TRACE("Ignoring\n"); + continue; + default: + return SEC_E_INTERNAL_ERROR; + } + } + + case GNUTLS_E_FATAL_ALERT_RECEIVED: + { + gnutls_alert_description_t alert = pgnutls_alert_get(s); + WARN("FATAL ALERT: %d %s\n", alert, pgnutls_alert_get_name(alert)); + return SEC_E_INTERNAL_ERROR; + } + + default: + pgnutls_perror(err); + return SEC_E_INTERNAL_ERROR; + } + } + + /* Never reached */ + return SEC_E_OK; +} + +static unsigned int schannel_get_cipher_block_size(gnutls_cipher_algorithm_t cipher) +{ + const struct + { + gnutls_cipher_algorithm_t cipher; + unsigned int block_size; + } + algorithms[] = + { + {GNUTLS_CIPHER_3DES_CBC, 8}, + {GNUTLS_CIPHER_AES_128_CBC, 16}, + {GNUTLS_CIPHER_AES_256_CBC, 16}, + {GNUTLS_CIPHER_ARCFOUR_128, 1}, + {GNUTLS_CIPHER_ARCFOUR_40, 1}, + {GNUTLS_CIPHER_DES_CBC, 8}, + {GNUTLS_CIPHER_NULL, 1}, + {GNUTLS_CIPHER_RC2_40_CBC, 8}, + }; + unsigned int i; + + for (i = 0; i < sizeof(algorithms) / sizeof(*algorithms); ++i) + { + if (algorithms[i].cipher == cipher) + return algorithms[i].block_size; + } + + FIXME("Unknown cipher %#x, returning 1\n", cipher); + + return 1; +} + +static DWORD schannel_get_protocol(gnutls_protocol_t proto) +{ + /* FIXME: currently schannel only implements client connections, but + * there's no reason it couldn't be used for servers as well. The + * context doesn't tell us which it is, so assume client for now. + */ + switch (proto) + { + case GNUTLS_SSL3: return SP_PROT_SSL3_CLIENT; + case GNUTLS_TLS1_0: return SP_PROT_TLS1_0_CLIENT; + case GNUTLS_TLS1_1: return SP_PROT_TLS1_1_CLIENT; + case GNUTLS_TLS1_2: return SP_PROT_TLS1_2_CLIENT; + default: + FIXME("unknown protocol %d\n", proto); + return 0; + } +} + +static ALG_ID schannel_get_cipher_algid(gnutls_cipher_algorithm_t cipher) +{ + switch (cipher) + { + case GNUTLS_CIPHER_UNKNOWN: + case GNUTLS_CIPHER_NULL: return 0; + case GNUTLS_CIPHER_ARCFOUR_40: + case GNUTLS_CIPHER_ARCFOUR_128: return CALG_RC4; + case GNUTLS_CIPHER_DES_CBC: + case GNUTLS_CIPHER_3DES_CBC: return CALG_DES; + case GNUTLS_CIPHER_AES_128_CBC: + case GNUTLS_CIPHER_AES_256_CBC: return CALG_AES; + case GNUTLS_CIPHER_RC2_40_CBC: return CALG_RC2; + default: + FIXME("unknown algorithm %d\n", cipher); + return 0; + } +} + +static ALG_ID schannel_get_mac_algid(gnutls_mac_algorithm_t mac) +{ + switch (mac) + { + case GNUTLS_MAC_UNKNOWN: + case GNUTLS_MAC_NULL: return 0; + case GNUTLS_MAC_MD5: return CALG_MD5; + case GNUTLS_MAC_SHA1: + case GNUTLS_MAC_SHA256: + case GNUTLS_MAC_SHA384: + case GNUTLS_MAC_SHA512: return CALG_SHA; + default: + FIXME("unknown algorithm %d\n", mac); + return 0; + } +} + +static ALG_ID schannel_get_kx_algid(gnutls_kx_algorithm_t kx) +{ + switch (kx) + { + case GNUTLS_KX_RSA: return CALG_RSA_KEYX; + case GNUTLS_KX_DHE_DSS: + case GNUTLS_KX_DHE_RSA: return CALG_DH_EPHEM; + default: + FIXME("unknown algorithm %d\n", kx); + return 0; + } +} + +unsigned int schan_imp_get_session_cipher_block_size(schan_imp_session session) +{ + gnutls_session_t s = (gnutls_session_t)session; + gnutls_cipher_algorithm_t cipher = pgnutls_cipher_get(s); + return schannel_get_cipher_block_size(cipher); +} + +unsigned int schan_imp_get_max_message_size(schan_imp_session session) +{ + return pgnutls_record_get_max_size((gnutls_session_t)session); +} + +SECURITY_STATUS schan_imp_get_connection_info(schan_imp_session session, + SecPkgContext_ConnectionInfo *info) +{ + gnutls_session_t s = (gnutls_session_t)session; + gnutls_protocol_t proto = pgnutls_protocol_get_version(s); + gnutls_cipher_algorithm_t alg = pgnutls_cipher_get(s); + gnutls_mac_algorithm_t mac = pgnutls_mac_get(s); + gnutls_kx_algorithm_t kx = pgnutls_kx_get(s); + + info->dwProtocol = schannel_get_protocol(proto); + info->aiCipher = schannel_get_cipher_algid(alg); + info->dwCipherStrength = pgnutls_cipher_get_key_size(alg) * 8; + info->aiHash = schannel_get_mac_algid(mac); + info->dwHashStrength = pgnutls_mac_get_key_size(mac) * 8; + info->aiExch = schannel_get_kx_algid(kx); + /* FIXME: info->dwExchStrength? */ + info->dwExchStrength = 0; + return SEC_E_OK; +} + +SECURITY_STATUS schan_imp_get_session_peer_certificate(schan_imp_session session, HCERTSTORE store, + PCCERT_CONTEXT *ret) +{ + gnutls_session_t s = (gnutls_session_t)session; + PCCERT_CONTEXT cert = NULL; + const gnutls_datum_t *datum; + unsigned list_size, i; + BOOL res; + + datum = pgnutls_certificate_get_peers(s, &list_size); + if(!datum) + return SEC_E_INTERNAL_ERROR; + + for(i = 0; i < list_size; i++) { + res = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, datum[i].data, datum[i].size, + CERT_STORE_ADD_REPLACE_EXISTING, i ? NULL : &cert); + if(!res) { + if(i) + CertFreeCertificateContext(cert); + return GetLastError(); + } + } + + *ret = cert; + return SEC_E_OK; +} + +SECURITY_STATUS schan_imp_send(schan_imp_session session, const void *buffer, + SIZE_T *length) +{ + gnutls_session_t s = (gnutls_session_t)session; + ssize_t ret; + +again: + ret = pgnutls_record_send(s, buffer, *length); + + if (ret >= 0) + *length = ret; + else if (ret == GNUTLS_E_AGAIN) + { + struct schan_transport *t = (struct schan_transport *)pgnutls_transport_get_ptr(s); + SIZE_T count = 0; + + if (schan_get_buffer(t, &t->out, &count)) + goto again; + + return SEC_I_CONTINUE_NEEDED; + } + else + { + pgnutls_perror(ret); + return SEC_E_INTERNAL_ERROR; + } + + return SEC_E_OK; +} + +SECURITY_STATUS schan_imp_recv(schan_imp_session session, void *buffer, + SIZE_T *length) +{ + gnutls_session_t s = (gnutls_session_t)session; + ssize_t ret; + +again: + ret = pgnutls_record_recv(s, buffer, *length); + + if (ret >= 0) + *length = ret; + else if (ret == GNUTLS_E_AGAIN) + { + struct schan_transport *t = (struct schan_transport *)pgnutls_transport_get_ptr(s); + SIZE_T count = 0; + + if (schan_get_buffer(t, &t->in, &count)) + goto again; + + return SEC_I_CONTINUE_NEEDED; + } + else + { + pgnutls_perror(ret); + return SEC_E_INTERNAL_ERROR; + } + + return SEC_E_OK; +} + +BOOL schan_imp_allocate_certificate_credentials(schan_credentials *c) +{ + int ret = pgnutls_certificate_allocate_credentials((gnutls_certificate_credentials_t*)&c->credentials); + if (ret != GNUTLS_E_SUCCESS) + pgnutls_perror(ret); + return (ret == GNUTLS_E_SUCCESS); +} + +void schan_imp_free_certificate_credentials(schan_credentials *c) +{ + pgnutls_certificate_free_credentials(c->credentials); +} + +static void schan_gnutls_log(int level, const char *msg) +{ + TRACE("<%d> %s", level, msg); +} + +BOOL schan_imp_init(void) +{ + int ret; + +#ifndef __REACTOS__ + libgnutls_handle = wine_dlopen(SONAME_LIBGNUTLS, RTLD_NOW, NULL, 0); + if (!libgnutls_handle) + { + WARN("Failed to load libgnutls.\n"); + return FALSE; + } + +#define LOAD_FUNCPTR(f) \ + if (!(p##f = wine_dlsym(libgnutls_handle, #f, NULL, 0))) \ + { \ + ERR("Failed to load %s\n", #f); \ + goto fail; \ + } +#else +/* + static const WCHAR RosSchannelKey[] = L"Software\\ReactOS\\Schannel"; + static const WCHAR PathValue[] = L"GnuTLSPath"; + WCHAR Path[MAX_PATH]; + DWORD PathSize = sizeof(Path), ValueType; + HKEY Key; + DWORD Error; + + Error = RegOpenKeyW(HKEY_LOCAL_MACHINE, RosSchannelKey, &Key); + if(Error != ERROR_SUCCESS) + return FALSE; + + Error = RegQueryValueExW(Key, PathValue, NULL, &ValueType, (LPBYTE)Path, &PathSize); + RegCloseKey(Key); + if ((Error != ERROR_SUCCESS) || (ValueType != REG_SZ)) + return FALSE; + wcscat(Path, L"\\"); + wcscat(Path, SONAME_LIBGNUTLS); +*/ + static const WCHAR Path[] = L"C:\\Reactos\\system32\\gnutls\\libgnutls-28.dll"; + + libgnutls_handle = LoadLibraryExW(Path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + if (!libgnutls_handle) + { + ERR("Could not load %S.\n", Path); + return FALSE; + } + +#define LOAD_FUNCPTR(f) \ + if (!(p##f = (void*)GetProcAddress(libgnutls_handle, #f))) \ + { \ + ERR("Failed to load %s\n", #f); \ + goto fail; \ + } +#endif // __REACTOS__ + + LOAD_FUNCPTR(gnutls_alert_get) + LOAD_FUNCPTR(gnutls_alert_get_name) + LOAD_FUNCPTR(gnutls_certificate_allocate_credentials) + LOAD_FUNCPTR(gnutls_certificate_free_credentials) + LOAD_FUNCPTR(gnutls_certificate_get_peers) + LOAD_FUNCPTR(gnutls_cipher_get) + LOAD_FUNCPTR(gnutls_cipher_get_key_size) + LOAD_FUNCPTR(gnutls_credentials_set) + LOAD_FUNCPTR(gnutls_deinit) + LOAD_FUNCPTR(gnutls_global_deinit) + LOAD_FUNCPTR(gnutls_global_init) + LOAD_FUNCPTR(gnutls_global_set_log_function) + LOAD_FUNCPTR(gnutls_global_set_log_level) + LOAD_FUNCPTR(gnutls_handshake) + LOAD_FUNCPTR(gnutls_init) + LOAD_FUNCPTR(gnutls_kx_get) + LOAD_FUNCPTR(gnutls_mac_get) + LOAD_FUNCPTR(gnutls_mac_get_key_size) + LOAD_FUNCPTR(gnutls_perror) + LOAD_FUNCPTR(gnutls_protocol_get_version) + LOAD_FUNCPTR(gnutls_priority_set_direct) + LOAD_FUNCPTR(gnutls_record_get_max_size); + LOAD_FUNCPTR(gnutls_record_recv); + LOAD_FUNCPTR(gnutls_record_send); + LOAD_FUNCPTR(gnutls_server_name_set) + LOAD_FUNCPTR(gnutls_transport_get_ptr) + LOAD_FUNCPTR(gnutls_transport_set_errno) + LOAD_FUNCPTR(gnutls_transport_set_ptr) + LOAD_FUNCPTR(gnutls_transport_set_pull_function) + LOAD_FUNCPTR(gnutls_transport_set_push_function) +#undef LOAD_FUNCPTR + + ret = pgnutls_global_init(); + if (ret != GNUTLS_E_SUCCESS) + { + pgnutls_perror(ret); + goto fail; + } + + if (TRACE_ON(secur32)) + { + pgnutls_global_set_log_level(4); + pgnutls_global_set_log_function(schan_gnutls_log); + } + + return TRUE; + +fail: +#ifndef __REACTOS__ + wine_dlclose(libgnutls_handle, NULL, 0); +#else + FreeLibrary(libgnutls_handle); +#endif + libgnutls_handle = NULL; + return FALSE; +} + +void schan_imp_deinit(void) +{ + pgnutls_global_deinit(); +#ifndef __REACTOS__ + wine_dlclose(libgnutls_handle, NULL, 0); +#else + FreeLibrary(libgnutls_handle); +#endif + libgnutls_handle = NULL; +} + +#endif /* SONAME_LIBGNUTLS && !HAVE_SECURITY_SECURITY_H */ Propchange: trunk/reactos/dll/win32/schannel/schannel_gnutls.c ------------------------------------------------------------------------------ charset = UTF-8 Propchange: trunk/reactos/dll/win32/schannel/schannel_gnutls.c ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/reactos/dll/win32/schannel/schannel_gnutls.c ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: trunk/reactos/dll/win32/schannel/schannel_main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/schannel/schanne…
============================================================================== --- trunk/reactos/dll/win32/schannel/schannel_main.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/schannel/schannel_main.c [iso-8859-1] Sat Aug 30 21:33:21 2014 @@ -27,7 +27,10 @@ if (fdwReason == DLL_WINE_PREATTACH) return FALSE; /* prefer native version */ if (fdwReason == DLL_PROCESS_ATTACH) + { DisableThreadLibraryCalls(hinstDLL); + SECUR32_initSchannelSP(); + } return TRUE; } @@ -43,3 +46,19 @@ FIXME("%s %x\n", debugstr_w(target), flags); return TRUE; } + +PSecurityFunctionTableW +WINAPI +schan_InitSecurityInterfaceW(VOID) +{ + TRACE("InitSecurityInterfaceW() called\n"); + return &schanTableW; +} + +PSecurityFunctionTableA +WINAPI +schan_InitSecurityInterfaceA(VOID) +{ + TRACE("InitSecurityInterfaceA() called\n"); + return &schanTableA; +} Added: trunk/reactos/dll/win32/schannel/schannel_priv.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/schannel/schanne…
============================================================================== --- trunk/reactos/dll/win32/schannel/schannel_priv.h (added) +++ trunk/reactos/dll/win32/schannel/schannel_priv.h [iso-8859-1] Sat Aug 30 21:33:21 2014 @@ -0,0 +1,130 @@ +/* + * secur32 private definitions. + * + * Copyright (C) 2004 Juan Lang + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __SCHANNEL_PRIV_H__ +#define __SCHANNEL_PRIV_H__ + +typedef struct _SecureProvider +{ + struct list entry; + BOOL loaded; + PWSTR moduleName; + HMODULE lib; +} SecureProvider; + +typedef struct _SecurePackage +{ + struct list entry; + SecPkgInfoW infoW; + SecureProvider *provider; +} SecurePackage; + +/* Allocates space for and initializes a new provider. If fnTableA or fnTableW + * is non-NULL, assumes the provider is built-in, and if moduleName is non-NULL, + * means must load the LSA/user mode functions tables from external SSP/AP module. + * Otherwise moduleName must not be NULL. + * Returns a pointer to the stored provider entry, for use adding packages. + */ +SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA, + const SecurityFunctionTableW *fnTableW, PCWSTR moduleName) DECLSPEC_HIDDEN; + +/* Allocates space for and adds toAdd packages with the given provider. + * provider must not be NULL, and either infoA or infoW may be NULL, but not + * both. + */ +void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd, + const SecPkgInfoA *infoA, const SecPkgInfoW *infoW) DECLSPEC_HIDDEN; + +/* Initialization functions for built-in providers */ +void SECUR32_initSchannelSP(void) DECLSPEC_HIDDEN; + +/* schannel internal interface */ +typedef struct schan_imp_session_opaque *schan_imp_session; + +typedef struct schan_credentials +{ + ULONG credential_use; + void *credentials; + DWORD enabled_protocols; +} schan_credentials; + +struct schan_transport; + +struct schan_buffers +{ + SIZE_T offset; + SIZE_T limit; + const SecBufferDesc *desc; + int current_buffer_idx; + BOOL allow_buffer_resize; + int (*get_next_buffer)(const struct schan_transport *, struct schan_buffers *); +}; + +struct schan_transport +{ + struct schan_context *ctx; + struct schan_buffers in; + struct schan_buffers out; +}; + +char *schan_get_buffer(const struct schan_transport *t, struct schan_buffers *s, SIZE_T *count) DECLSPEC_HIDDEN; +extern int schan_pull(struct schan_transport *t, void *buff, size_t *buff_len) DECLSPEC_HIDDEN; +extern int schan_push(struct schan_transport *t, const void *buff, size_t *buff_len) DECLSPEC_HIDDEN; + +extern schan_imp_session schan_session_for_transport(struct schan_transport* t) DECLSPEC_HIDDEN; + +/* schannel implementation interface */ +extern BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cred) DECLSPEC_HIDDEN; +extern void schan_imp_dispose_session(schan_imp_session session) DECLSPEC_HIDDEN; +extern void schan_imp_set_session_transport(schan_imp_session session, + struct schan_transport *t) DECLSPEC_HIDDEN; +extern void schan_imp_set_session_target(schan_imp_session session, const char *target) DECLSPEC_HIDDEN; +extern SECURITY_STATUS schan_imp_handshake(schan_imp_session session) DECLSPEC_HIDDEN; +extern unsigned int schan_imp_get_session_cipher_block_size(schan_imp_session session) DECLSPEC_HIDDEN; +extern unsigned int schan_imp_get_max_message_size(schan_imp_session session) DECLSPEC_HIDDEN; +extern SECURITY_STATUS schan_imp_get_connection_info(schan_imp_session session, + SecPkgContext_ConnectionInfo *info) DECLSPEC_HIDDEN; +extern SECURITY_STATUS schan_imp_get_session_peer_certificate(schan_imp_session session, HCERTSTORE, + PCCERT_CONTEXT *cert) DECLSPEC_HIDDEN; +extern SECURITY_STATUS schan_imp_send(schan_imp_session session, const void *buffer, + SIZE_T *length) DECLSPEC_HIDDEN; +extern SECURITY_STATUS schan_imp_recv(schan_imp_session session, void *buffer, + SIZE_T *length) DECLSPEC_HIDDEN; +extern BOOL schan_imp_allocate_certificate_credentials(schan_credentials*) DECLSPEC_HIDDEN; +extern void schan_imp_free_certificate_credentials(schan_credentials*) DECLSPEC_HIDDEN; +extern DWORD schan_imp_enabled_protocols(void) DECLSPEC_HIDDEN; +extern BOOL schan_imp_init(void) DECLSPEC_HIDDEN; +extern void schan_imp_deinit(void) DECLSPEC_HIDDEN; + +SECURITY_STATUS +WINAPI +schan_FreeContextBuffer ( + PVOID pvoid + ); +SECURITY_STATUS WINAPI schan_EnumerateSecurityPackagesA(PULONG pcPackages, + PSecPkgInfoA *ppPackageInfo); +SECURITY_STATUS WINAPI schan_EnumerateSecurityPackagesW(PULONG pcPackages, + PSecPkgInfoW *ppPackageInfo); +extern SecurityFunctionTableA schanTableA; +extern SecurityFunctionTableW schanTableW; + +#endif /* ndef __SCHANNEL_PRIV_H__ */ + + Propchange: trunk/reactos/dll/win32/schannel/schannel_priv.h ------------------------------------------------------------------------------ charset = UTF-8 Propchange: trunk/reactos/dll/win32/schannel/schannel_priv.h ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/reactos/dll/win32/schannel/schannel_priv.h ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: trunk/reactos/dll/win32/schannel/schannel_wine.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/schannel/schanne…
============================================================================== --- trunk/reactos/dll/win32/schannel/schannel_wine.c (added) +++ trunk/reactos/dll/win32/schannel/schannel_wine.c [iso-8859-1] Sat Aug 30 21:33:21 2014 @@ -0,0 +1,1469 @@ +/* Copyright (C) 2005 Juan Lang + * Copyright 2008 Henri Verbeet + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * + * This file implements the schannel provider, or, the SSL/TLS implementations. + */ + +#include "precomp.h" + +#include <wine/config.h> + +#if defined(SONAME_LIBGNUTLS) || defined (HAVE_SECURITY_SECURITY_H) + +#define SCHAN_INVALID_HANDLE ~0UL + +enum schan_handle_type +{ + SCHAN_HANDLE_CRED, + SCHAN_HANDLE_CTX, + SCHAN_HANDLE_FREE +}; + +struct schan_handle +{ + void *object; + enum schan_handle_type type; +}; + +struct schan_context +{ + schan_imp_session session; + ULONG req_ctx_attr; + const CERT_CONTEXT *cert; +}; + +static struct schan_handle *schan_handle_table; +static struct schan_handle *schan_free_handles; +static SIZE_T schan_handle_table_size; +static SIZE_T schan_handle_count; + +/* Protocols enabled, only those may be used for the connection. */ +static DWORD config_enabled_protocols; + +/* Protocols disabled by default. They are enabled for using, but disabled when caller asks for default settings. */ +static DWORD config_default_disabled_protocols; + +static ULONG_PTR schan_alloc_handle(void *object, enum schan_handle_type type) +{ + struct schan_handle *handle; + + if (schan_free_handles) + { + DWORD index = schan_free_handles - schan_handle_table; + /* Use a free handle */ + handle = schan_free_handles; + if (handle->type != SCHAN_HANDLE_FREE) + { + ERR("Handle %d(%p) is in the free list, but has type %#x.\n", index, handle, handle->type); + return SCHAN_INVALID_HANDLE; + } + schan_free_handles = handle->object; + handle->object = object; + handle->type = type; + + return index; + } + if (!(schan_handle_count < schan_handle_table_size)) + { + /* Grow the table */ + SIZE_T new_size = schan_handle_table_size + (schan_handle_table_size >> 1); + struct schan_handle *new_table = HeapReAlloc(GetProcessHeap(), 0, schan_handle_table, new_size * sizeof(*schan_handle_table)); + if (!new_table) + { + ERR("Failed to grow the handle table\n"); + return SCHAN_INVALID_HANDLE; + } + schan_handle_table = new_table; + schan_handle_table_size = new_size; + } + + handle = &schan_handle_table[schan_handle_count++]; + handle->object = object; + handle->type = type; + + return handle - schan_handle_table; +} + +static void *schan_free_handle(ULONG_PTR handle_idx, enum schan_handle_type type) +{ + struct schan_handle *handle; + void *object; + + if (handle_idx == SCHAN_INVALID_HANDLE) return NULL; + if (handle_idx >= schan_handle_count) return NULL; + handle = &schan_handle_table[handle_idx]; + if (handle->type != type) + { + ERR("Handle %ld(%p) is not of type %#x\n", handle_idx, handle, type); + return NULL; + } + + object = handle->object; + handle->object = schan_free_handles; + handle->type = SCHAN_HANDLE_FREE; + schan_free_handles = handle; + + return object; +} + +static void *schan_get_object(ULONG_PTR handle_idx, enum schan_handle_type type) +{ + struct schan_handle *handle; + + if (handle_idx == SCHAN_INVALID_HANDLE) return NULL; + if (handle_idx >= schan_handle_count) return NULL; + handle = &schan_handle_table[handle_idx]; + if (handle->type != type) + { + ERR("Handle %ld(%p) is not of type %#x\n", handle_idx, handle, type); + return NULL; + } + + return handle->object; +} + +static void read_config(void) +{ + DWORD enabled = 0, default_disabled = 0; + HKEY protocols_key, key; + WCHAR subkey_name[64]; + unsigned i; + DWORD res; + + static BOOL config_read = FALSE; + + static const WCHAR protocol_config_key_name[] = { + 'S','Y','S','T','E','M','\\', + 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', + 'C','o','n','t','r','o','l','\\', + 'S','e','c','u','r','i','t','y','P','r','o','v','i','d','e','r','s','\\', + 'S','C','H','A','N','N','E','L','\\', + 'P','r','o','t','o','c','o','l','s',0 }; + + static const WCHAR clientW[] = {'\\','C','l','i','e','n','t',0}; + static const WCHAR enabledW[] = {'e','n','a','b','l','e','d',0}; + static const WCHAR disabledbydefaultW[] = {'D','i','s','a','b','l','e','d','B','y','D','e','f','a','u','l','t',0}; + + static const struct { + WCHAR key_name[20]; + DWORD prot_client_flag; + BOOL enabled; /* If no config is present, enable the protocol */ + BOOL disabled_by_default; /* Disable if caller asks for default protocol set */ + } protocol_config_keys[] = { + {{'S','S','L',' ','2','.','0',0}, SP_PROT_SSL2_CLIENT, FALSE, TRUE}, /* NOTE: TRUE, TRUE on Windows */ + {{'S','S','L',' ','3','.','0',0}, SP_PROT_SSL3_CLIENT, TRUE, FALSE}, + {{'T','L','S',' ','1','.','0',0}, SP_PROT_TLS1_0_CLIENT, TRUE, FALSE}, + {{'T','L','S',' ','1','.','1',0}, SP_PROT_TLS1_1_CLIENT, TRUE, FALSE /* NOTE: not enabled by default on Windows */ }, + {{'T','L','S',' ','1','.','2',0}, SP_PROT_TLS1_2_CLIENT, TRUE, FALSE /* NOTE: not enabled by default on Windows */ } + }; + + /* No need for thread safety */ + if(config_read) + return; + + res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, protocol_config_key_name, 0, KEY_READ, &protocols_key); + if(res == ERROR_SUCCESS) { + DWORD type, size, value; + + for(i=0; i < sizeof(protocol_config_keys)/sizeof(*protocol_config_keys); i++) { + strcpyW(subkey_name, protocol_config_keys[i].key_name); + strcatW(subkey_name, clientW); + res = RegOpenKeyExW(protocols_key, subkey_name, 0, KEY_READ, &key); + if(res != ERROR_SUCCESS) { + if(protocol_config_keys[i].enabled) + enabled |= protocol_config_keys[i].prot_client_flag; + if(protocol_config_keys[i].disabled_by_default) + default_disabled |= protocol_config_keys[i].prot_client_flag; + continue; + } + + size = sizeof(value); + res = RegQueryValueExW(key, enabledW, NULL, &type, (BYTE*)&value, &size); + if(res == ERROR_SUCCESS) { + if(type == REG_DWORD && value) + enabled |= protocol_config_keys[i].prot_client_flag; + }else if(protocol_config_keys[i].enabled) { + enabled |= protocol_config_keys[i].prot_client_flag; + } + + size = sizeof(value); + res = RegQueryValueExW(key, disabledbydefaultW, NULL, &type, (BYTE*)&value, &size); + if(res == ERROR_SUCCESS) { + if(type != REG_DWORD || value) + default_disabled |= protocol_config_keys[i].prot_client_flag; + }else if(protocol_config_keys[i].disabled_by_default) { + default_disabled |= protocol_config_keys[i].prot_client_flag; + } + + RegCloseKey(key); + } + }else { + /* No config, enable all known protocols. */ + for(i=0; i < sizeof(protocol_config_keys)/sizeof(*protocol_config_keys); i++) { + if(protocol_config_keys[i].enabled) + enabled |= protocol_config_keys[i].prot_client_flag; + if(protocol_config_keys[i].disabled_by_default) + default_disabled |= protocol_config_keys[i].prot_client_flag; + } + } + + RegCloseKey(protocols_key); + + config_enabled_protocols = enabled & schan_imp_enabled_protocols(); + config_default_disabled_protocols = default_disabled; + config_read = TRUE; + + TRACE("enabled %x, disabled by default %x\n", config_enabled_protocols, config_default_disabled_protocols); +} + +static SECURITY_STATUS schan_QueryCredentialsAttributes( + PCredHandle phCredential, ULONG ulAttribute, VOID *pBuffer) +{ + struct schan_credentials *cred; + SECURITY_STATUS ret; + + cred = schan_get_object(phCredential->dwLower, SCHAN_HANDLE_CRED); + if(!cred) + return SEC_E_INVALID_HANDLE; + + switch (ulAttribute) + { + case SECPKG_ATTR_SUPPORTED_ALGS: + if (pBuffer) + { + /* FIXME: get from CryptoAPI */ + FIXME("SECPKG_ATTR_SUPPORTED_ALGS: stub\n"); + ret = SEC_E_UNSUPPORTED_FUNCTION; + } + else + ret = SEC_E_INTERNAL_ERROR; + break; + case SECPKG_ATTR_CIPHER_STRENGTHS: + if (pBuffer) + { + SecPkgCred_CipherStrengths *r = pBuffer; + + /* FIXME: get from CryptoAPI */ + FIXME("SECPKG_ATTR_CIPHER_STRENGTHS: semi-stub\n"); + r->dwMinimumCipherStrength = 40; + r->dwMaximumCipherStrength = 168; + ret = SEC_E_OK; + } + else + ret = SEC_E_INTERNAL_ERROR; + break; + case SECPKG_ATTR_SUPPORTED_PROTOCOLS: + if(pBuffer) { + /* Regardless of MSDN documentation, tests show that this attribute takes into account + * what protocols are enabled for given credential. */ + ((SecPkgCred_SupportedProtocols*)pBuffer)->grbitProtocol = cred->enabled_protocols; + ret = SEC_E_OK; + }else { + ret = SEC_E_INTERNAL_ERROR; + } + break; + default: + ret = SEC_E_UNSUPPORTED_FUNCTION; + } + return ret; +} + +static SECURITY_STATUS SEC_ENTRY schan_QueryCredentialsAttributesA( + PCredHandle phCredential, ULONG ulAttribute, PVOID pBuffer) +{ + SECURITY_STATUS ret; + + TRACE("(%p, %d, %p)\n", phCredential, ulAttribute, pBuffer); + + switch (ulAttribute) + { + case SECPKG_CRED_ATTR_NAMES: + FIXME("SECPKG_CRED_ATTR_NAMES: stub\n"); + ret = SEC_E_UNSUPPORTED_FUNCTION; + break; + default: + ret = schan_QueryCredentialsAttributes(phCredential, ulAttribute, + pBuffer); + } + return ret; +} + +SECURITY_STATUS SEC_ENTRY schan_QueryCredentialsAttributesW( + PCredHandle phCredential, ULONG ulAttribute, PVOID pBuffer) +{ + SECURITY_STATUS ret; + + TRACE("(%p, %d, %p)\n", phCredential, ulAttribute, pBuffer); + + switch (ulAttribute) + { + case SECPKG_CRED_ATTR_NAMES: + FIXME("SECPKG_CRED_ATTR_NAMES: stub\n"); + ret = SEC_E_UNSUPPORTED_FUNCTION; + break; + default: + ret = schan_QueryCredentialsAttributes(phCredential, ulAttribute, + pBuffer); + } + return ret; +} + +static SECURITY_STATUS schan_CheckCreds(const SCHANNEL_CRED *schanCred) +{ + SECURITY_STATUS st; + DWORD i; + + TRACE("dwVersion = %d\n", schanCred->dwVersion); + TRACE("cCreds = %d\n", schanCred->cCreds); + TRACE("hRootStore = %p\n", schanCred->hRootStore); + TRACE("cMappers = %d\n", schanCred->cMappers); + TRACE("cSupportedAlgs = %d:\n", schanCred->cSupportedAlgs); + for (i = 0; i < schanCred->cSupportedAlgs; i++) + TRACE("%08x\n", schanCred->palgSupportedAlgs[i]); + TRACE("grbitEnabledProtocols = %08x\n", schanCred->grbitEnabledProtocols); + TRACE("dwMinimumCipherStrength = %d\n", schanCred->dwMinimumCipherStrength); + TRACE("dwMaximumCipherStrength = %d\n", schanCred->dwMaximumCipherStrength); + TRACE("dwSessionLifespan = %d\n", schanCred->dwSessionLifespan); + TRACE("dwFlags = %08x\n", schanCred->dwFlags); + TRACE("dwCredFormat = %d\n", schanCred->dwCredFormat); + + switch (schanCred->dwVersion) + { + case SCH_CRED_V3: + case SCHANNEL_CRED_VERSION: + break; + default: + return SEC_E_INTERNAL_ERROR; + } + + if (schanCred->cCreds == 0) + st = SEC_E_NO_CREDENTIALS; + else if (schanCred->cCreds > 1) + st = SEC_E_UNKNOWN_CREDENTIALS; + else + { + DWORD keySpec; + HCRYPTPROV csp; + BOOL ret, freeCSP; + + ret = CryptAcquireCertificatePrivateKey(schanCred->paCred[0], + 0, /* FIXME: what flags to use? */ NULL, + &csp, &keySpec, &freeCSP); + if (ret) + { + st = SEC_E_OK; + if (freeCSP) + CryptReleaseContext(csp, 0); + } + else + st = SEC_E_UNKNOWN_CREDENTIALS; + } + return st; +} + +static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schanCred, + PCredHandle phCredential, PTimeStamp ptsExpiry) +{ + struct schan_credentials *creds; + unsigned enabled_protocols; + ULONG_PTR handle; + SECURITY_STATUS st = SEC_E_OK; + + TRACE("schanCred %p, phCredential %p, ptsExpiry %p\n", schanCred, phCredential, ptsExpiry); + + if (schanCred) + { + st = schan_CheckCreds(schanCred); + if (st != SEC_E_OK && st != SEC_E_NO_CREDENTIALS) + return st; + + st = SEC_E_OK; + } + + read_config(); + if(schanCred && schanCred->grbitEnabledProtocols) + enabled_protocols = schanCred->grbitEnabledProtocols & config_enabled_protocols; + else + enabled_protocols = config_enabled_protocols & ~config_default_disabled_protocols; + if(!enabled_protocols) { + ERR("Could not find matching protocol\n"); + return SEC_E_NO_AUTHENTICATING_AUTHORITY; + } + + /* For now, the only thing I'm interested in is the direction of the + * connection, so just store it. + */ + creds = HeapAlloc(GetProcessHeap(), 0, sizeof(*creds)); + if (!creds) return SEC_E_INSUFFICIENT_MEMORY; + + handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED); + if (handle == SCHAN_INVALID_HANDLE) goto fail; + + creds->credential_use = SECPKG_CRED_OUTBOUND; + if (!schan_imp_allocate_certificate_credentials(creds)) + { + schan_free_handle(handle, SCHAN_HANDLE_CRED); + goto fail; + } + + creds->enabled_protocols = enabled_protocols; + phCredential->dwLower = handle; + phCredential->dwUpper = 0; + + /* Outbound credentials have no expiry */ + if (ptsExpiry) + { + ptsExpiry->LowPart = 0; + ptsExpiry->HighPart = 0; + } + + return st; + +fail: + HeapFree(GetProcessHeap(), 0, creds); + return SEC_E_INTERNAL_ERROR; +} + +static SECURITY_STATUS schan_AcquireServerCredentials(const SCHANNEL_CRED *schanCred, + PCredHandle phCredential, PTimeStamp ptsExpiry) +{ + SECURITY_STATUS st; + + TRACE("schanCred %p, phCredential %p, ptsExpiry %p\n", schanCred, phCredential, ptsExpiry); + + if (!schanCred) return SEC_E_NO_CREDENTIALS; + + st = schan_CheckCreds(schanCred); + if (st == SEC_E_OK) + { + ULONG_PTR handle; + struct schan_credentials *creds; + + creds = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*creds)); + if (!creds) return SEC_E_INSUFFICIENT_MEMORY; + creds->credential_use = SECPKG_CRED_INBOUND; + + handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED); + if (handle == SCHAN_INVALID_HANDLE) + { + HeapFree(GetProcessHeap(), 0, creds); + return SEC_E_INTERNAL_ERROR; + } + + phCredential->dwLower = handle; + phCredential->dwUpper = 0; + + /* FIXME: get expiry from cert */ + } + return st; +} + +static SECURITY_STATUS schan_AcquireCredentialsHandle(ULONG fCredentialUse, + const SCHANNEL_CRED *schanCred, PCredHandle phCredential, PTimeStamp ptsExpiry) +{ + SECURITY_STATUS ret; + + if (fCredentialUse == SECPKG_CRED_OUTBOUND) + ret = schan_AcquireClientCredentials(schanCred, phCredential, + ptsExpiry); + else + ret = schan_AcquireServerCredentials(schanCred, phCredential, + ptsExpiry); + return ret; +} + +SECURITY_STATUS SEC_ENTRY schan_AcquireCredentialsHandleA( + SEC_CHAR *pszPrincipal, SEC_CHAR *pszPackage, ULONG fCredentialUse, + PLUID pLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, + PVOID pGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry) +{ + TRACE("(%s, %s, 0x%08x, %p, %p, %p, %p, %p, %p)\n", + debugstr_a(pszPrincipal), debugstr_a(pszPackage), fCredentialUse, + pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry); + return schan_AcquireCredentialsHandle(fCredentialUse, + pAuthData, phCredential, ptsExpiry); +} + +SECURITY_STATUS SEC_ENTRY schan_AcquireCredentialsHandleW( + SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialUse, + PLUID pLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, + PVOID pGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry) +{ + TRACE("(%s, %s, 0x%08x, %p, %p, %p, %p, %p, %p)\n", + debugstr_w(pszPrincipal), debugstr_w(pszPackage), fCredentialUse, + pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry); + return schan_AcquireCredentialsHandle(fCredentialUse, + pAuthData, phCredential, ptsExpiry); +} + +SECURITY_STATUS SEC_ENTRY schan_FreeCredentialsHandle( + PCredHandle phCredential) +{ + struct schan_credentials *creds; + + TRACE("phCredential %p\n", phCredential); + + if (!phCredential) return SEC_E_INVALID_HANDLE; + + creds = schan_free_handle(phCredential->dwLower, SCHAN_HANDLE_CRED); + if (!creds) return SEC_E_INVALID_HANDLE; + + if (creds->credential_use == SECPKG_CRED_OUTBOUND) + schan_imp_free_certificate_credentials(creds); + HeapFree(GetProcessHeap(), 0, creds); + + return SEC_E_OK; +} + +static void init_schan_buffers(struct schan_buffers *s, const PSecBufferDesc desc, + int (*get_next_buffer)(const struct schan_transport *, struct schan_buffers *)) +{ + s->offset = 0; + s->limit = ~0UL; + s->desc = desc; + s->current_buffer_idx = -1; + s->allow_buffer_resize = FALSE; + s->get_next_buffer = get_next_buffer; +} + +static int schan_find_sec_buffer_idx(const SecBufferDesc *desc, unsigned int start_idx, ULONG buffer_type) +{ + unsigned int i; + PSecBuffer buffer; + + for (i = start_idx; i < desc->cBuffers; ++i) + { + buffer = &desc->pBuffers[i]; + if (buffer->BufferType == buffer_type) return i; + } + + return -1; +} + +static void schan_resize_current_buffer(const struct schan_buffers *s, SIZE_T min_size) +{ + SecBuffer *b = &s->desc->pBuffers[s->current_buffer_idx]; + SIZE_T new_size = b->cbBuffer ? b->cbBuffer * 2 : 128; + void *new_data; + + if (b->cbBuffer >= min_size || !s->allow_buffer_resize || min_size > UINT_MAX / 2) return; + + while (new_size < min_size) new_size *= 2; + + if (b->pvBuffer) + new_data = HeapReAlloc(GetProcessHeap(), 0, b->pvBuffer, new_size); + else + new_data = HeapAlloc(GetProcessHeap(), 0, new_size); + + if (!new_data) + { + TRACE("Failed to resize %p from %d to %ld\n", b->pvBuffer, b->cbBuffer, new_size); + return; + } + + b->cbBuffer = new_size; + b->pvBuffer = new_data; +} + +char *schan_get_buffer(const struct schan_transport *t, struct schan_buffers *s, SIZE_T *count) +{ + SIZE_T max_count; + PSecBuffer buffer; + + if (!s->desc) + { + TRACE("No desc\n"); + return NULL; + } + + if (s->current_buffer_idx == -1) + { + /* Initial buffer */ + int buffer_idx = s->get_next_buffer(t, s); + if (buffer_idx == -1) + { + TRACE("No next buffer\n"); + return NULL; + } + s->current_buffer_idx = buffer_idx; + } + + buffer = &s->desc->pBuffers[s->current_buffer_idx]; + TRACE("Using buffer %d: cbBuffer %d, BufferType %#x, pvBuffer %p\n", s->current_buffer_idx, buffer->cbBuffer, buffer->BufferType, buffer->pvBuffer); + + schan_resize_current_buffer(s, s->offset + *count); + max_count = buffer->cbBuffer - s->offset; + if (s->limit != ~0UL && s->limit < max_count) + max_count = s->limit; + if (!max_count) + { + int buffer_idx; + + s->allow_buffer_resize = FALSE; + buffer_idx = s->get_next_buffer(t, s); + if (buffer_idx == -1) + { + TRACE("No next buffer\n"); + return NULL; + } + s->current_buffer_idx = buffer_idx; + s->offset = 0; + return schan_get_buffer(t, s, count); + } + + if (*count > max_count) + *count = max_count; + if (s->limit != ~0UL) + s->limit -= *count; + + return (char *)buffer->pvBuffer + s->offset; +} + +/* schan_pull + * Read data from the transport input buffer. + * + * t - The session transport object. + * buff - The buffer into which to store the read data. Must be at least + * *buff_len bytes in length. + * buff_len - On input, *buff_len is the desired length to read. On successful + * return, *buff_len is the number of bytes actually read. + * + * Returns: + * 0 on success, in which case: + * *buff_len == 0 indicates end of file. + * *buff_len > 0 indicates that some data was read. May be less than + * what was requested, in which case the caller should call again if/ + * when they want more. + * EAGAIN when no data could be read without blocking + * another errno-style error value on failure + * + */ +int schan_pull(struct schan_transport *t, void *buff, size_t *buff_len) +{ + char *b; + SIZE_T local_len = *buff_len; + + TRACE("Pull %lu bytes\n", local_len); + + *buff_len = 0; + + b = schan_get_buffer(t, &t->in, &local_len); + if (!b) + return EAGAIN; + + memcpy(buff, b, local_len); + t->in.offset += local_len; + + TRACE("Read %lu bytes\n", local_len); + + *buff_len = local_len; + return 0; +} + +/* schan_push + * Write data to the transport output buffer. + * + * t - The session transport object. + * buff - The buffer of data to write. Must be at least *buff_len bytes in length. + * buff_len - On input, *buff_len is the desired length to write. On successful + * return, *buff_len is the number of bytes actually written. + * + * Returns: + * 0 on success + * *buff_len will be > 0 indicating how much data was written. May be less + * than what was requested, in which case the caller should call again + if/when they want to write more. + * EAGAIN when no data could be written without blocking + * another errno-style error value on failure + * + */ +int schan_push(struct schan_transport *t, const void *buff, size_t *buff_len) +{ + char *b; + SIZE_T local_len = *buff_len; + + TRACE("Push %lu bytes\n", local_len); + + *buff_len = 0; + + b = schan_get_buffer(t, &t->out, &local_len); + if (!b) + return EAGAIN; + + memcpy(b, buff, local_len); + t->out.offset += local_len; + + TRACE("Wrote %lu bytes\n", local_len); + + *buff_len = local_len; + return 0; +} + +schan_imp_session schan_session_for_transport(struct schan_transport* t) +{ + return t->ctx->session; +} + +static int schan_init_sec_ctx_get_next_buffer(const struct schan_transport *t, struct schan_buffers *s) +{ + if (s->current_buffer_idx == -1) + { + int idx = schan_find_sec_buffer_idx(s->desc, 0, SECBUFFER_TOKEN); + if (t->ctx->req_ctx_attr & ISC_REQ_ALLOCATE_MEMORY) + { + if (idx == -1) + { + idx = schan_find_sec_buffer_idx(s->desc, 0, SECBUFFER_EMPTY); + if (idx != -1) s->desc->pBuffers[idx].BufferType = SECBUFFER_TOKEN; + } + if (idx != -1 && !s->desc->pBuffers[idx].pvBuffer) + { + s->desc->pBuffers[idx].cbBuffer = 0; + s->allow_buffer_resize = TRUE; + } + } + return idx; + } + + return -1; +} + +static void dump_buffer_desc(SecBufferDesc *desc) +{ + unsigned int i; + + if (!desc) return; + TRACE("Buffer desc %p:\n", desc); + for (i = 0; i < desc->cBuffers; ++i) + { + SecBuffer *b = &desc->pBuffers[i]; + TRACE("\tbuffer %u: cbBuffer %d, BufferType %#x pvBuffer %p\n", i, b->cbBuffer, b->BufferType, b->pvBuffer); + } +} + +/*********************************************************************** + * InitializeSecurityContextW + */ +SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW( + PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR *pszTargetName, + ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, + PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, + PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry) +{ + struct schan_context *ctx; + struct schan_buffers *out_buffers; + struct schan_credentials *cred; + struct schan_transport transport; + SIZE_T expected_size = ~0UL; + SECURITY_STATUS ret; + + TRACE("%p %p %s 0x%08x %d %d %p %d %p %p %p %p\n", phCredential, phContext, + debugstr_w(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput, + Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry); + + dump_buffer_desc(pInput); + dump_buffer_desc(pOutput); + + if (!phContext) + { + ULONG_PTR handle; + + if (!phCredential) return SEC_E_INVALID_HANDLE; + + cred = schan_get_object(phCredential->dwLower, SCHAN_HANDLE_CRED); + if (!cred) return SEC_E_INVALID_HANDLE; + + if (!(cred->credential_use & SECPKG_CRED_OUTBOUND)) + { + WARN("Invalid credential use %#x\n", cred->credential_use); + return SEC_E_INVALID_HANDLE; + } + + ctx = HeapAlloc(GetProcessHeap(), 0, sizeof(*ctx)); + if (!ctx) return SEC_E_INSUFFICIENT_MEMORY; + + ctx->cert = NULL; + handle = schan_alloc_handle(ctx, SCHAN_HANDLE_CTX); + if (handle == SCHAN_INVALID_HANDLE) + { + HeapFree(GetProcessHeap(), 0, ctx); + return SEC_E_INTERNAL_ERROR; + } + + if (!schan_imp_create_session(&ctx->session, cred)) + { + schan_free_handle(handle, SCHAN_HANDLE_CTX); + HeapFree(GetProcessHeap(), 0, ctx); + return SEC_E_INTERNAL_ERROR; + } + + if (pszTargetName) + { + UINT len = WideCharToMultiByte( CP_UNIXCP, 0, pszTargetName, -1, NULL, 0, NULL, NULL ); + char *target = HeapAlloc( GetProcessHeap(), 0, len ); + + if (target) + { + WideCharToMultiByte( CP_UNIXCP, 0, pszTargetName, -1, target, len, NULL, NULL ); + schan_imp_set_session_target( ctx->session, target ); + HeapFree( GetProcessHeap(), 0, target ); + } + } + phNewContext->dwLower = handle; + phNewContext->dwUpper = 0; + } + else + { + SIZE_T record_size = 0; + unsigned char *ptr; + SecBuffer *buffer; + int idx; + + if (!pInput) + return SEC_E_INCOMPLETE_MESSAGE; + + idx = schan_find_sec_buffer_idx(pInput, 0, SECBUFFER_TOKEN); + if (idx == -1) + return SEC_E_INCOMPLETE_MESSAGE; + + buffer = &pInput->pBuffers[idx]; + ptr = buffer->pvBuffer; + expected_size = 0; + + while (buffer->cbBuffer > expected_size + 5) + { + record_size = 5 + ((ptr[3] << 8) | ptr[4]); + + if (buffer->cbBuffer < expected_size + record_size) + break; + + expected_size += record_size; + ptr += record_size; + } + + if (!expected_size) + { + TRACE("Expected at least %lu bytes, but buffer only contains %u bytes.\n", + max(6, record_size), buffer->cbBuffer); + return SEC_E_INCOMPLETE_MESSAGE; + } + + TRACE("Using expected_size %lu.\n", expected_size); + + ctx = schan_get_object(phContext->dwLower, SCHAN_HANDLE_CTX); + } + + ctx->req_ctx_attr = fContextReq; + + transport.ctx = ctx; + init_schan_buffers(&transport.in, pInput, schan_init_sec_ctx_get_next_buffer); + transport.in.limit = expected_size; + init_schan_buffers(&transport.out, pOutput, schan_init_sec_ctx_get_next_buffer); + schan_imp_set_session_transport(ctx->session, &transport); + + /* Perform the TLS handshake */ + ret = schan_imp_handshake(ctx->session); + + if(transport.in.offset && transport.in.offset != pInput->pBuffers[0].cbBuffer) { + if(pInput->cBuffers<2 || pInput->pBuffers[1].BufferType!=SECBUFFER_EMPTY) + return SEC_E_INVALID_TOKEN; + + pInput->pBuffers[1].BufferType = SECBUFFER_EXTRA; + pInput->pBuffers[1].cbBuffer = pInput->pBuffers[0].cbBuffer-transport.in.offset; + } + + out_buffers = &transport.out; + if (out_buffers->current_buffer_idx != -1) + { + SecBuffer *buffer = &out_buffers->desc->pBuffers[out_buffers->current_buffer_idx]; + buffer->cbBuffer = out_buffers->offset; + } + + *pfContextAttr = 0; + if (ctx->req_ctx_attr & ISC_REQ_ALLOCATE_MEMORY) + *pfContextAttr |= ISC_RET_ALLOCATED_MEMORY; + + return ret; +} + +/*********************************************************************** + * InitializeSecurityContextA + */ +SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextA( + PCredHandle phCredential, PCtxtHandle phContext, SEC_CHAR *pszTargetName, + ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, + PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, + PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry) +{ + SECURITY_STATUS ret; + SEC_WCHAR *target_name = NULL; + + TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext, + debugstr_a(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput, + Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry); + + if (pszTargetName) + { + INT len = MultiByteToWideChar(CP_ACP, 0, pszTargetName, -1, NULL, 0); + target_name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*target_name)); + MultiByteToWideChar(CP_ACP, 0, pszTargetName, -1, target_name, len); + } + + ret = schan_InitializeSecurityContextW(phCredential, phContext, target_name, + fContextReq, Reserved1, TargetDataRep, pInput, Reserved2, + phNewContext, pOutput, pfContextAttr, ptsExpiry); + + HeapFree(GetProcessHeap(), 0, target_name); + + return ret; +} + +SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW( + PCtxtHandle context_handle, ULONG attribute, PVOID buffer) +{ + struct schan_context *ctx; + + TRACE("context_handle %p, attribute %#x, buffer %p\n", + context_handle, attribute, buffer); + + if (!context_handle) return SEC_E_INVALID_HANDLE; + ctx = schan_get_object(context_handle->dwLower, SCHAN_HANDLE_CTX); + + switch(attribute) + { + case SECPKG_ATTR_STREAM_SIZES: + { + SecPkgContext_ConnectionInfo info; + SECURITY_STATUS status = schan_imp_get_connection_info(ctx->session, &info); + if (status == SEC_E_OK) + { + SecPkgContext_StreamSizes *stream_sizes = buffer; + SIZE_T mac_size = info.dwHashStrength; + unsigned int block_size = schan_imp_get_session_cipher_block_size(ctx->session); + unsigned int message_size = schan_imp_get_max_message_size(ctx->session); + + TRACE("Using %lu mac bytes, message size %u, block size %u\n", + mac_size, message_size, block_size); + + /* These are defined by the TLS RFC */ + stream_sizes->cbHeader = 5; + stream_sizes->cbTrailer = mac_size + 256; /* Max 255 bytes padding + 1 for padding size */ + stream_sizes->cbMaximumMessage = message_size; + stream_sizes->cbBuffers = 4; + stream_sizes->cbBlockSize = block_size; + } + + return status; + } + case SECPKG_ATTR_REMOTE_CERT_CONTEXT: + { + PCCERT_CONTEXT *cert = buffer; + + if (!ctx->cert) { + HCERTSTORE cert_store; + SECURITY_STATUS status; + + cert_store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); + if(!cert_store) + return GetLastError(); + + status = schan_imp_get_session_peer_certificate(ctx->session, cert_store, &ctx->cert); + CertCloseStore(cert_store, 0); + if(status != SEC_E_OK) + return status; + } + + *cert = CertDuplicateCertificateContext(ctx->cert); + return SEC_E_OK; + } + case SECPKG_ATTR_CONNECTION_INFO: + { + SecPkgContext_ConnectionInfo *info = buffer; + return schan_imp_get_connection_info(ctx->session, info); + } + + default: + FIXME("Unhandled attribute %#x\n", attribute); + return SEC_E_UNSUPPORTED_FUNCTION; + } +} + +SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesA( + PCtxtHandle context_handle, ULONG attribute, PVOID buffer) +{ + TRACE("context_handle %p, attribute %#x, buffer %p\n", + context_handle, attribute, buffer); + + switch(attribute) + { + case SECPKG_ATTR_STREAM_SIZES: + return schan_QueryContextAttributesW(context_handle, attribute, buffer); + case SECPKG_ATTR_REMOTE_CERT_CONTEXT: + return schan_QueryContextAttributesW(context_handle, attribute, buffer); + case SECPKG_ATTR_CONNECTION_INFO: + return schan_QueryContextAttributesW(context_handle, attribute, buffer); + + default: + FIXME("Unhandled attribute %#x\n", attribute); + return SEC_E_UNSUPPORTED_FUNCTION; + } +} + +static int schan_encrypt_message_get_next_buffer(const struct schan_transport *t, struct schan_buffers *s) +{ + SecBuffer *b; + + if (s->current_buffer_idx == -1) + return schan_find_sec_buffer_idx(s->desc, 0, SECBUFFER_STREAM_HEADER); + + b = &s->desc->pBuffers[s->current_buffer_idx]; + + if (b->BufferType == SECBUFFER_STREAM_HEADER) + return schan_find_sec_buffer_idx(s->desc, 0, SECBUFFER_DATA); + + if (b->BufferType == SECBUFFER_DATA) + return schan_find_sec_buffer_idx(s->desc, 0, SECBUFFER_STREAM_TRAILER); + + return -1; +} + +static int schan_encrypt_message_get_next_buffer_token(const struct schan_transport *t, struct schan_buffers *s) +{ + SecBuffer *b; + + if (s->current_buffer_idx == -1) + return schan_find_sec_buffer_idx(s->desc, 0, SECBUFFER_TOKEN); + + b = &s->desc->pBuffers[s->current_buffer_idx]; + + if (b->BufferType == SECBUFFER_TOKEN) + { + int idx = schan_find_sec_buffer_idx(s->desc, 0, SECBUFFER_TOKEN); + if (idx != s->current_buffer_idx) return -1; + return schan_find_sec_buffer_idx(s->desc, 0, SECBUFFER_DATA); + } + + if (b->BufferType == SECBUFFER_DATA) + { + int idx = schan_find_sec_buffer_idx(s->desc, 0, SECBUFFER_TOKEN); + if (idx != -1) + idx = schan_find_sec_buffer_idx(s->desc, idx + 1, SECBUFFER_TOKEN); + return idx; + } + + return -1; +} + +static SECURITY_STATUS SEC_ENTRY schan_EncryptMessage(PCtxtHandle context_handle, + ULONG quality, PSecBufferDesc message, ULONG message_seq_no) +{ + struct schan_transport transport; + struct schan_context *ctx; + struct schan_buffers *b; + SECURITY_STATUS status; + SecBuffer *buffer; + SIZE_T data_size; + SIZE_T length; + char *data; + int idx; + + TRACE("context_handle %p, quality %d, message %p, message_seq_no %d\n", + context_handle, quality, message, message_seq_no); + + if (!context_handle) return SEC_E_INVALID_HANDLE; + ctx = schan_get_object(context_handle->dwLower, SCHAN_HANDLE_CTX); + + dump_buffer_desc(message); + + idx = schan_find_sec_buffer_idx(message, 0, SECBUFFER_DATA); + if (idx == -1) + { + WARN("No data buffer passed\n"); + return SEC_E_INTERNAL_ERROR; + } + buffer = &message->pBuffers[idx]; + + data_size = buffer->cbBuffer; + data = HeapAlloc(GetProcessHeap(), 0, data_size); + memcpy(data, buffer->pvBuffer, data_size); + + transport.ctx = ctx; + init_schan_buffers(&transport.in, NULL, NULL); + if (schan_find_sec_buffer_idx(message, 0, SECBUFFER_STREAM_HEADER) != -1) + init_schan_buffers(&transport.out, message, schan_encrypt_message_get_next_buffer); + else + init_schan_buffers(&transport.out, message, schan_encrypt_message_get_next_buffer_token); + schan_imp_set_session_transport(ctx->session, &transport); + + length = data_size; + status = schan_imp_send(ctx->session, data, &length); + + TRACE("Sent %ld bytes.\n", length); + + if (length != data_size) + status = SEC_E_INTERNAL_ERROR; + + b = &transport.out; + b->desc->pBuffers[b->current_buffer_idx].cbBuffer = b->offset; + HeapFree(GetProcessHeap(), 0, data); + + TRACE("Returning %#x.\n", status); + + return status; +} + +static int schan_decrypt_message_get_next_buffer(const struct schan_transport *t, struct schan_buffers *s) +{ + if (s->current_buffer_idx == -1) + return schan_find_sec_buffer_idx(s->desc, 0, SECBUFFER_DATA); + + return -1; +} + +static int schan_validate_decrypt_buffer_desc(PSecBufferDesc message) +{ + int data_idx = -1; + unsigned int empty_count = 0; + unsigned int i; + + if (message->cBuffers < 4) + { + WARN("Less than four buffers passed\n"); + return -1; + } + + for (i = 0; i < message->cBuffers; ++i) + { + SecBuffer *b = &message->pBuffers[i]; + if (b->BufferType == SECBUFFER_DATA) + { + if (data_idx != -1) + { + WARN("More than one data buffer passed\n"); + return -1; + } + data_idx = i; + } + else if (b->BufferType == SECBUFFER_EMPTY) + ++empty_count; + } + + if (data_idx == -1) + { + WARN("No data buffer passed\n"); + return -1; + } + + if (empty_count < 3) + { + WARN("Less than three empty buffers passed\n"); + return -1; + } + + return data_idx; +} + +static void schan_decrypt_fill_buffer(PSecBufferDesc message, ULONG buffer_type, void *data, ULONG size) +{ + int idx; + SecBuffer *buffer; + + idx = schan_find_sec_buffer_idx(message, 0, SECBUFFER_EMPTY); + buffer = &message->pBuffers[idx]; + + buffer->BufferType = buffer_type; + buffer->pvBuffer = data; + buffer->cbBuffer = size; +} + +static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle, + PSecBufferDesc message, ULONG message_seq_no, PULONG quality) +{ + struct schan_transport transport; + struct schan_context *ctx; + SecBuffer *buffer; + SIZE_T data_size; + char *data; + unsigned expected_size; + SSIZE_T received = 0; + int idx; + unsigned char *buf_ptr; + + TRACE("context_handle %p, message %p, message_seq_no %d, quality %p\n", + context_handle, message, message_seq_no, quality); + + if (!context_handle) return SEC_E_INVALID_HANDLE; + ctx = schan_get_object(context_handle->dwLower, SCHAN_HANDLE_CTX); + + dump_buffer_desc(message); + + idx = schan_validate_decrypt_buffer_desc(message); + if (idx == -1) + return SEC_E_INVALID_TOKEN; + buffer = &message->pBuffers[idx]; + buf_ptr = buffer->pvBuffer; + + expected_size = 5 + ((buf_ptr[3] << 8) | buf_ptr[4]); + if(buffer->cbBuffer < expected_size) + { + TRACE("Expected %u bytes, but buffer only contains %u bytes\n", expected_size, buffer->cbBuffer); + buffer->BufferType = SECBUFFER_MISSING; + buffer->cbBuffer = expected_size - buffer->cbBuffer; + + /* This is a bit weird, but windows does it too */ + idx = schan_find_sec_buffer_idx(message, 0, SECBUFFER_EMPTY); + buffer = &message->pBuffers[idx]; + buffer->BufferType = SECBUFFER_MISSING; + buffer->cbBuffer = expected_size - buffer->cbBuffer; + + TRACE("Returning SEC_E_INCOMPLETE_MESSAGE\n"); + return SEC_E_INCOMPLETE_MESSAGE; + } + + data_size = expected_size - 5; + data = HeapAlloc(GetProcessHeap(), 0, data_size); + + transport.ctx = ctx; + init_schan_buffers(&transport.in, message, schan_decrypt_message_get_next_buffer); + transport.in.limit = expected_size; + init_schan_buffers(&transport.out, NULL, NULL); + schan_imp_set_session_transport(ctx->session, &transport); + + while (received < data_size) + { + SIZE_T length = data_size - received; + SECURITY_STATUS status = schan_imp_recv(ctx->session, data + received, &length); + + if (status == SEC_I_CONTINUE_NEEDED) + break; + + if (status != SEC_E_OK) + { + HeapFree(GetProcessHeap(), 0, data); + ERR("Returning %x\n", status); + return status; + } + + if (!length) + break; + + received += length; + } + + TRACE("Received %ld bytes\n", received); + + memcpy(buf_ptr + 5, data, received); + HeapFree(GetProcessHeap(), 0, data); + + schan_decrypt_fill_buffer(message, SECBUFFER_DATA, + buf_ptr + 5, received); + + schan_decrypt_fill_buffer(message, SECBUFFER_STREAM_TRAILER, + buf_ptr + 5 + received, buffer->cbBuffer - 5 - received); + + if(buffer->cbBuffer > expected_size) + schan_decrypt_fill_buffer(message, SECBUFFER_EXTRA, + buf_ptr + expected_size, buffer->cbBuffer - expected_size); + + buffer->BufferType = SECBUFFER_STREAM_HEADER; + buffer->cbBuffer = 5; + + return SEC_E_OK; +} + +SECURITY_STATUS SEC_ENTRY schan_DeleteSecurityContext(PCtxtHandle context_handle) +{ + struct schan_context *ctx; + + TRACE("context_handle %p\n", context_handle); + + if (!context_handle) return SEC_E_INVALID_HANDLE; + + ctx = schan_free_handle(context_handle->dwLower, SCHAN_HANDLE_CTX); + if (!ctx) return SEC_E_INVALID_HANDLE; + + if (ctx->cert) + CertFreeCertificateContext(ctx->cert); + schan_imp_dispose_session(ctx->session); + HeapFree(GetProcessHeap(), 0, ctx); + + return SEC_E_OK; +} + +SecurityFunctionTableA schanTableA = { + 1, + schan_EnumerateSecurityPackagesA, + schan_QueryCredentialsAttributesA, + schan_AcquireCredentialsHandleA, + schan_FreeCredentialsHandle, + NULL, /* Reserved2 */ + schan_InitializeSecurityContextA, + NULL, /* AcceptSecurityContext */ + NULL, /* CompleteAuthToken */ + schan_DeleteSecurityContext, + NULL, /* ApplyControlToken */ + schan_QueryContextAttributesA, + NULL, /* ImpersonateSecurityContext */ + NULL, /* RevertSecurityContext */ + NULL, /* MakeSignature */ + NULL, /* VerifySignature */ + schan_FreeContextBuffer, + NULL, /* QuerySecurityPackageInfoA */ + NULL, /* Reserved3 */ + NULL, /* Reserved4 */ + NULL, /* ExportSecurityContext */ + NULL, /* ImportSecurityContextA */ + NULL, /* AddCredentialsA */ + NULL, /* Reserved8 */ + NULL, /* QuerySecurityContextToken */ + schan_EncryptMessage, + schan_DecryptMessage, + NULL, /* SetContextAttributesA */ +}; + +SecurityFunctionTableW schanTableW = { + 1, + schan_EnumerateSecurityPackagesW, + schan_QueryCredentialsAttributesW, + schan_AcquireCredentialsHandleW, + schan_FreeCredentialsHandle, + NULL, /* Reserved2 */ + schan_InitializeSecurityContextW, + NULL, /* AcceptSecurityContext */ + NULL, /* CompleteAuthToken */ + schan_DeleteSecurityContext, + NULL, /* ApplyControlToken */ + schan_QueryContextAttributesW, + NULL, /* ImpersonateSecurityContext */ + NULL, /* RevertSecurityContext */ + NULL, /* MakeSignature */ + NULL, /* VerifySignature */ + schan_FreeContextBuffer, + NULL, /* QuerySecurityPackageInfoW */ + NULL, /* Reserved3 */ + NULL, /* Reserved4 */ + NULL, /* ExportSecurityContext */ + NULL, /* ImportSecurityContextW */ + NULL, /* AddCredentialsW */ + NULL, /* Reserved8 */ + NULL, /* QuerySecurityContextToken */ + schan_EncryptMessage, + schan_DecryptMessage, + NULL, /* SetContextAttributesW */ +}; + +static const WCHAR schannelComment[] = { 'S','c','h','a','n','n','e','l',' ', + 'S','e','c','u','r','i','t','y',' ','P','a','c','k','a','g','e',0 }; +static const WCHAR schannelDllName[] = { 's','c','h','a','n','n','e','l','.','d','l','l',0 }; + +void SECUR32_initSchannelSP(void) +{ + /* This is what Windows reports. This shouldn't break any applications + * even though the functions are missing, because the wrapper will + * return SEC_E_UNSUPPORTED_FUNCTION if our function is NULL. + */ + static const LONG caps = + SECPKG_FLAG_INTEGRITY | + SECPKG_FLAG_PRIVACY | + SECPKG_FLAG_CONNECTION | + SECPKG_FLAG_MULTI_REQUIRED | + SECPKG_FLAG_EXTENDED_ERROR | + SECPKG_FLAG_IMPERSONATION | + SECPKG_FLAG_ACCEPT_WIN32_NAME | + SECPKG_FLAG_STREAM; + static const short version = 1; + static const LONG maxToken = 16384; + SEC_WCHAR *uniSPName = (SEC_WCHAR *)UNISP_NAME_W, + *schannel = (SEC_WCHAR *)SCHANNEL_NAME_W; + const SecPkgInfoW info[] = { + { caps, version, UNISP_RPC_ID, maxToken, uniSPName, uniSPName }, + { caps, version, UNISP_RPC_ID, maxToken, schannel, + (SEC_WCHAR *)schannelComment }, + }; + SecureProvider *provider; + + if (!schan_imp_init()) + return; + + schan_handle_table = HeapAlloc(GetProcessHeap(), 0, 64 * sizeof(*schan_handle_table)); + if (!schan_handle_table) + { + ERR("Failed to allocate schannel handle table.\n"); + goto fail; + } + schan_handle_table_size = 64; + + provider = SECUR32_addProvider(&schanTableA, &schanTableW, schannelDllName); + if (!provider) + { + ERR("Failed to add schannel provider.\n"); + goto fail; + } + + SECUR32_addPackages(provider, sizeof(info) / sizeof(info[0]), NULL, info); + + return; + +fail: + HeapFree(GetProcessHeap(), 0, schan_handle_table); + schan_handle_table = NULL; + schan_imp_deinit(); + return; +} + +void SECUR32_deinitSchannelSP(void) +{ + SIZE_T i = schan_handle_count; + + if (!schan_handle_table) return; + + /* deinitialized sessions first because a pointer to the credentials + * may be stored for the session. */ + while (i--) + { + if (schan_handle_table[i].type == SCHAN_HANDLE_CTX) + { + struct schan_context *ctx = schan_free_handle(i, SCHAN_HANDLE_CTX); + schan_imp_dispose_session(ctx->session); + HeapFree(GetProcessHeap(), 0, ctx); + } + } + i = schan_handle_count; + while (i--) + { + if (schan_handle_table[i].type != SCHAN_HANDLE_FREE) + { + struct schan_credentials *cred; + cred = schan_free_handle(i, SCHAN_HANDLE_CRED); + schan_imp_free_certificate_credentials(cred); + HeapFree(GetProcessHeap(), 0, cred); + } + } + HeapFree(GetProcessHeap(), 0, schan_handle_table); + schan_imp_deinit(); +} + +#else /* SONAME_LIBGNUTLS || HAVE_SECURITY_SECURITY_H */ + +void SECUR32_initSchannelSP(void) +{ + ERR("TLS library not found, SSL connections will fail\n"); +} + +void SECUR32_deinitSchannelSP(void) {} + +#endif /* SONAME_LIBGNUTLS || HAVE_SECURITY_SECURITY_H */ Propchange: trunk/reactos/dll/win32/schannel/schannel_wine.c ------------------------------------------------------------------------------ charset = UTF-8 Propchange: trunk/reactos/dll/win32/schannel/schannel_wine.c ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/reactos/dll/win32/schannel/schannel_wine.c ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: trunk/reactos/dll/win32/schannel/secur32_wine.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/schannel/secur32…
============================================================================== --- trunk/reactos/dll/win32/schannel/secur32_wine.c (added) +++ trunk/reactos/dll/win32/schannel/secur32_wine.c [iso-8859-1] Sat Aug 30 21:33:21 2014 @@ -0,0 +1,399 @@ +/* Copyright (C) 2004 Juan Lang + * + * This file implements loading of SSP DLLs. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "precomp.h" + +#include <assert.h> + +typedef struct _SecurePackageTable +{ + DWORD numPackages; + DWORD numAllocated; + struct list table; +} SecurePackageTable; + +typedef struct _SecureProviderTable +{ + DWORD numProviders; + DWORD numAllocated; + struct list table; +} SecureProviderTable; + +/** + * Globals + */ + +static CRITICAL_SECTION cs; +static CRITICAL_SECTION_DEBUG cs_debug = +{ + 0, 0, &cs, + { &cs_debug.ProcessLocksList, &cs_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": cs") } +}; +static CRITICAL_SECTION cs = { &cs_debug, -1, 0, 0, 0, 0 }; +static SecurePackageTable *packageTable = NULL; +static SecureProviderTable *providerTable = NULL; + +/*********************************************************************** + * EnumerateSecurityPackagesW (SECUR32.@) + */ +SECURITY_STATUS WINAPI schan_EnumerateSecurityPackagesW(PULONG pcPackages, + PSecPkgInfoW *ppPackageInfo) +{ + SECURITY_STATUS ret = SEC_E_OK; + + TRACE("(%p, %p)\n", pcPackages, ppPackageInfo); + + /* windows just crashes if pcPackages or ppPackageInfo is NULL, so will I */ + *pcPackages = 0; + EnterCriticalSection(&cs); + if (packageTable) + { + SecurePackage *package; + size_t bytesNeeded; + + bytesNeeded = packageTable->numPackages * sizeof(SecPkgInfoW); + LIST_FOR_EACH_ENTRY(package, &packageTable->table, SecurePackage, entry) + { + if (package->infoW.Name) + bytesNeeded += (lstrlenW(package->infoW.Name) + 1) * sizeof(WCHAR); + if (package->infoW.Comment) + bytesNeeded += (lstrlenW(package->infoW.Comment) + 1) * sizeof(WCHAR); + } + if (bytesNeeded) + { + *ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded); + if (*ppPackageInfo) + { + ULONG i = 0; + PWSTR nextString; + + *pcPackages = packageTable->numPackages; + nextString = (PWSTR)((PBYTE)*ppPackageInfo + + packageTable->numPackages * sizeof(SecPkgInfoW)); + LIST_FOR_EACH_ENTRY(package, &packageTable->table, SecurePackage, entry) + { + PSecPkgInfoW pkgInfo = *ppPackageInfo + i++; + + *pkgInfo = package->infoW; + if (package->infoW.Name) + { + TRACE("Name[%d] = %S\n", i - 1, package->infoW.Name); + pkgInfo->Name = nextString; + lstrcpyW(nextString, package->infoW.Name); + nextString += lstrlenW(nextString) + 1; + } + else + pkgInfo->Name = NULL; + if (package->infoW.Comment) + { + TRACE("Comment[%d] = %S\n", i - 1, package->infoW.Comment); + pkgInfo->Comment = nextString; + lstrcpyW(nextString, package->infoW.Comment); + nextString += lstrlenW(nextString) + 1; + } + else + pkgInfo->Comment = NULL; + } + } + else + ret = SEC_E_INSUFFICIENT_MEMORY; + } + } + LeaveCriticalSection(&cs); + TRACE("<-- 0x%08x\n", ret); + return ret; +} + +/* Converts info (which is assumed to be an array of cPackages SecPkgInfoW + * structures) into an array of SecPkgInfoA structures, which it returns. + */ +static PSecPkgInfoA thunk_PSecPkgInfoWToA(ULONG cPackages, + const SecPkgInfoW *info) +{ + PSecPkgInfoA ret; + + if (info) + { + size_t bytesNeeded = cPackages * sizeof(SecPkgInfoA); + ULONG i; + + for (i = 0; i < cPackages; i++) + { + if (info[i].Name) + bytesNeeded += WideCharToMultiByte(CP_ACP, 0, info[i].Name, + -1, NULL, 0, NULL, NULL); + if (info[i].Comment) + bytesNeeded += WideCharToMultiByte(CP_ACP, 0, info[i].Comment, + -1, NULL, 0, NULL, NULL); + } + ret = HeapAlloc(GetProcessHeap(), 0, bytesNeeded); + if (ret) + { + PSTR nextString; + + nextString = (PSTR)((PBYTE)ret + cPackages * sizeof(SecPkgInfoA)); + for (i = 0; i < cPackages; i++) + { + PSecPkgInfoA pkgInfo = ret + i; + int bytes; + + memcpy(pkgInfo, &info[i], sizeof(SecPkgInfoA)); + if (info[i].Name) + { + pkgInfo->Name = nextString; + /* just repeat back to WideCharToMultiByte how many bytes + * it requires, since we asked it earlier + */ + bytes = WideCharToMultiByte(CP_ACP, 0, info[i].Name, -1, + NULL, 0, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, info[i].Name, -1, + pkgInfo->Name, bytes, NULL, NULL); + nextString += lstrlenA(nextString) + 1; + } + else + pkgInfo->Name = NULL; + if (info[i].Comment) + { + pkgInfo->Comment = nextString; + /* just repeat back to WideCharToMultiByte how many bytes + * it requires, since we asked it earlier + */ + bytes = WideCharToMultiByte(CP_ACP, 0, info[i].Comment, -1, + NULL, 0, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, info[i].Comment, -1, + pkgInfo->Comment, bytes, NULL, NULL); + nextString += lstrlenA(nextString) + 1; + } + else + pkgInfo->Comment = NULL; + } + } + } + else + ret = NULL; + return ret; +} + +/*********************************************************************** + * EnumerateSecurityPackagesA (SECUR32.@) + */ +SECURITY_STATUS WINAPI schan_EnumerateSecurityPackagesA(PULONG pcPackages, + PSecPkgInfoA *ppPackageInfo) +{ + SECURITY_STATUS ret; + PSecPkgInfoW info; + + ret = schan_EnumerateSecurityPackagesW(pcPackages, &info); + if (ret == SEC_E_OK && *pcPackages && info) + { + *ppPackageInfo = thunk_PSecPkgInfoWToA(*pcPackages, info); + if (*pcPackages && !*ppPackageInfo) + { + *pcPackages = 0; + ret = SEC_E_INSUFFICIENT_MEMORY; + } + schan_FreeContextBuffer(info); + } + return ret; +} + +SECURITY_STATUS +WINAPI +schan_FreeContextBuffer ( + PVOID pvoid + ) +{ + HeapFree(GetProcessHeap(), 0, pvoid); + return SEC_E_OK; +} + + + +static PWSTR SECUR32_strdupW(PCWSTR str) +{ + PWSTR ret; + + if (str) + { + ret = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(str) + 1) * sizeof(WCHAR)); + if (ret) + lstrcpyW(ret, str); + } + else + ret = NULL; + return ret; +} + +PWSTR SECUR32_AllocWideFromMultiByte(PCSTR str) +{ + PWSTR ret; + + if (str) + { + int charsNeeded = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); + + if (charsNeeded) + { + ret = HeapAlloc(GetProcessHeap(), 0, charsNeeded * sizeof(WCHAR)); + if (ret) + MultiByteToWideChar(CP_ACP, 0, str, -1, ret, charsNeeded); + } + else + ret = NULL; + } + else + ret = NULL; + return ret; +} + +PSTR SECUR32_AllocMultiByteFromWide(PCWSTR str) +{ + PSTR ret; + + if (str) + { + int charsNeeded = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, + NULL, NULL); + + if (charsNeeded) + { + ret = HeapAlloc(GetProcessHeap(), 0, charsNeeded); + if (ret) + WideCharToMultiByte(CP_ACP, 0, str, -1, ret, charsNeeded, + NULL, NULL); + } + else + ret = NULL; + } + else + ret = NULL; + return ret; +} + +static void _copyPackageInfo(PSecPkgInfoW info, const SecPkgInfoA *inInfoA, + const SecPkgInfoW *inInfoW) +{ + if (info && (inInfoA || inInfoW)) + { + /* odd, I know, but up until Name and Comment the structures are + * identical + */ + memcpy(info, inInfoW ? inInfoW : (const SecPkgInfoW *)inInfoA, sizeof(*info)); + if (inInfoW) + { + info->Name = SECUR32_strdupW(inInfoW->Name); + info->Comment = SECUR32_strdupW(inInfoW->Comment); + } + else + { + info->Name = SECUR32_AllocWideFromMultiByte(inInfoA->Name); + info->Comment = SECUR32_AllocWideFromMultiByte(inInfoA->Comment); + } + } +} + +SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA, + const SecurityFunctionTableW *fnTableW, PCWSTR moduleName) +{ + SecureProvider *ret; + + EnterCriticalSection(&cs); + + if (!providerTable) + { + providerTable = HeapAlloc(GetProcessHeap(), 0, sizeof(SecureProviderTable)); + if (!providerTable) + { + LeaveCriticalSection(&cs); + return NULL; + } + + list_init(&providerTable->table); + } + + ret = HeapAlloc(GetProcessHeap(), 0, sizeof(SecureProvider)); + if (!ret) + { + LeaveCriticalSection(&cs); + return NULL; + } + + list_add_tail(&providerTable->table, &ret->entry); + ret->lib = NULL; + +#ifndef __REACTOS__ + if (fnTableA || fnTableW) + { + ret->moduleName = moduleName ? SECUR32_strdupW(moduleName) : NULL; + _makeFnTableA(&ret->fnTableA, fnTableA, fnTableW); + _makeFnTableW(&ret->fnTableW, fnTableA, fnTableW); + ret->loaded = !moduleName; + } + else +#endif + { + ret->moduleName = SECUR32_strdupW(moduleName); + ret->loaded = FALSE; + } + + LeaveCriticalSection(&cs); + return ret; +} + +void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd, + const SecPkgInfoA *infoA, const SecPkgInfoW *infoW) +{ + ULONG i; + + assert(provider); + assert(infoA || infoW); + + EnterCriticalSection(&cs); + + if (!packageTable) + { + packageTable = HeapAlloc(GetProcessHeap(), 0, sizeof(SecurePackageTable)); + if (!packageTable) + { + LeaveCriticalSection(&cs); + return; + } + + packageTable->numPackages = 0; + list_init(&packageTable->table); + } + + for (i = 0; i < toAdd; i++) + { + SecurePackage *package = HeapAlloc(GetProcessHeap(), 0, sizeof(SecurePackage)); + if (!package) + continue; + + list_add_tail(&packageTable->table, &package->entry); + + package->provider = provider; + _copyPackageInfo(&package->infoW, + infoA ? &infoA[i] : NULL, + infoW ? &infoW[i] : NULL); + } + packageTable->numPackages += toAdd; + + LeaveCriticalSection(&cs); +} Propchange: trunk/reactos/dll/win32/schannel/secur32_wine.c ------------------------------------------------------------------------------ charset = UTF-8 Propchange: trunk/reactos/dll/win32/schannel/secur32_wine.c ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/reactos/dll/win32/schannel/secur32_wine.c ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: trunk/reactos/dll/win32/schannel/stubs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/schannel/stubs.c…
============================================================================== --- trunk/reactos/dll/win32/schannel/stubs.c (added) +++ trunk/reactos/dll/win32/schannel/stubs.c [iso-8859-1] Sat Aug 30 21:33:21 2014 @@ -0,0 +1,28 @@ + +#include "precomp.h" + +SECURITY_STATUS WINAPI schan_AcceptSecurityContext( + PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput, + ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext, + PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry) +{ + return SEC_E_UNSUPPORTED_FUNCTION; +} + +SECURITY_STATUS WINAPI schan_ApplyControlToken(PCtxtHandle phContext, + PSecBufferDesc pInput) +{ + return SEC_E_UNSUPPORTED_FUNCTION; +} + +SECURITY_STATUS WINAPI schan_CompleteAuthToken(PCtxtHandle phContext, + PSecBufferDesc pToken) +{ + return SEC_E_UNSUPPORTED_FUNCTION; +} + +SECURITY_STATUS WINAPI schan_ImpersonateSecurityContext(PCtxtHandle phContext) +{ + return SEC_E_UNSUPPORTED_FUNCTION; +} + Propchange: trunk/reactos/dll/win32/schannel/stubs.c ------------------------------------------------------------------------------ charset = UTF-8 Propchange: trunk/reactos/dll/win32/schannel/stubs.c ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/reactos/dll/win32/schannel/stubs.c ------------------------------------------------------------------------------ svn:mime-type = text/plain
10 years, 3 months
1
0
0
0
[jgardou] 63995: [INCLUDE] - import GNUTLS headers - define wine's SONAME_LIBGNUTLS to a relevant value
by jgardou@svn.reactos.org
Author: jgardou Date: Sat Aug 30 21:32:52 2014 New Revision: 63995 URL:
http://svn.reactos.org/svn/reactos?rev=63995&view=rev
Log: [INCLUDE] - import GNUTLS headers - define wine's SONAME_LIBGNUTLS to a relevant value Added: trunk/reactos/include/reactos/libs/gnutls/ trunk/reactos/include/reactos/libs/gnutls/gmp.h (with props) trunk/reactos/include/reactos/libs/gnutls/gnutls/ trunk/reactos/include/reactos/libs/gnutls/gnutls/abstract.h (with props) trunk/reactos/include/reactos/libs/gnutls/gnutls/compat.h (with props) trunk/reactos/include/reactos/libs/gnutls/gnutls/crypto.h (with props) trunk/reactos/include/reactos/libs/gnutls/gnutls/dtls.h (with props) trunk/reactos/include/reactos/libs/gnutls/gnutls/gnutls.h (with props) trunk/reactos/include/reactos/libs/gnutls/gnutls/gnutlsxx.h (with props) trunk/reactos/include/reactos/libs/gnutls/gnutls/ocsp.h (with props) trunk/reactos/include/reactos/libs/gnutls/gnutls/openpgp.h (with props) trunk/reactos/include/reactos/libs/gnutls/gnutls/pkcs11.h (with props) trunk/reactos/include/reactos/libs/gnutls/gnutls/pkcs12.h (with props) trunk/reactos/include/reactos/libs/gnutls/gnutls/tpm.h (with props) trunk/reactos/include/reactos/libs/gnutls/gnutls/x509.h (with props) trunk/reactos/include/reactos/libs/gnutls/gnutls/xssl.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/ trunk/reactos/include/reactos/libs/gnutls/nettle/aes.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/arcfour.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/arctwo.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/asn1.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/base16.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/base64.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/bignum.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/blowfish.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/buffer.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/camellia.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/cast128.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/cbc.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/ctr.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/des-compat.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/des.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/dsa.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/ecc-curve.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/ecc.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/ecdsa.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/gcm.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/gosthash94.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/hmac.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/knuth-lfib.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/macros.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/md2.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/md4.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/md5-compat.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/md5.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/memxor.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/nettle-meta.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/nettle-stdint.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/nettle-types.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/pbkdf2.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/pgp.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/pkcs1.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/realloc.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/ripemd160.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/rsa-compat.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/rsa.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/salsa20.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/serpent.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/sexp.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/sha.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/sha1.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/sha2.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/sha3.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/twofish.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/umac.h (with props) trunk/reactos/include/reactos/libs/gnutls/nettle/yarrow.h (with props) trunk/reactos/include/reactos/libs/gnutls/p11-kit/ trunk/reactos/include/reactos/libs/gnutls/p11-kit/deprecated.h (with props) trunk/reactos/include/reactos/libs/gnutls/p11-kit/iter.h (with props) trunk/reactos/include/reactos/libs/gnutls/p11-kit/p11-kit.h (with props) trunk/reactos/include/reactos/libs/gnutls/p11-kit/pin.h (with props) trunk/reactos/include/reactos/libs/gnutls/p11-kit/pkcs11.h (with props) trunk/reactos/include/reactos/libs/gnutls/p11-kit/uri.h (with props) Modified: trunk/reactos/include/reactos/wine/config.h [This mail would be too long, it was shortened to contain the URLs only.] Added: trunk/reactos/include/reactos/libs/gnutls/gmp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/gnutls/abstract.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/gnutls/compat.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/gnutls/crypto.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/gnutls/dtls.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/gnutls/gnutls.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/gnutls/gnutlsxx.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/gnutls/ocsp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/gnutls/openpgp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/gnutls/pkcs11.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/gnutls/pkcs12.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/gnutls/tpm.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/gnutls/x509.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/gnutls/xssl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/aes.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/arcfour.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/arctwo.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/asn1.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/base16.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/base64.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/bignum.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/blowfish.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/buffer.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/camellia.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/cast128.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/cbc.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/ctr.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/des-compat.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/des.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/dsa.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/ecc-curve.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/ecc.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/ecdsa.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/gcm.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/gosthash94.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/hmac.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/knuth-lfib.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/macros.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/md2.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/md4.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/md5-compat.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/md5.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/memxor.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/nettle-meta.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/nettle-stdint.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/nettle-types.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/pbkdf2.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/pgp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/pkcs1.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/realloc.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/ripemd160.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/rsa-compat.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/rsa.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/salsa20.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/serpent.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/sexp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/sha.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/sha1.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/sha2.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/sha3.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/twofish.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/umac.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/nettle/yarrow.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/p11-kit/deprecated.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/p11-kit/iter.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/p11-kit/p11-kit.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/p11-kit/pin.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/p11-kit/pkcs11.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Added: trunk/reactos/include/reactos/libs/gnutls/p11-kit/uri.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/gnutl…
Modified: trunk/reactos/include/reactos/wine/config.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/wine/confi…
10 years, 3 months
1
0
0
0
[jgardou] 63994: [SECUR32] - Import SSPI module loading from wine
by jgardou@svn.reactos.org
Author: jgardou Date: Sat Aug 30 21:31:32 2014 New Revision: 63994 URL:
http://svn.reactos.org/svn/reactos?rev=63994&view=rev
Log: [SECUR32] - Import SSPI module loading from wine Added: trunk/reactos/dll/win32/secur32/secur32_priv.h (with props) trunk/reactos/dll/win32/secur32/thunks.c (with props) trunk/reactos/dll/win32/secur32/thunks.h (with props) trunk/reactos/dll/win32/secur32/wrapper.c (with props) Modified: trunk/reactos/dll/win32/secur32/CMakeLists.txt trunk/reactos/dll/win32/secur32/precomp.h trunk/reactos/dll/win32/secur32/secur32.spec trunk/reactos/dll/win32/secur32/sspi.c [This mail would be too long, it was shortened to contain the URLs only.] Modified: trunk/reactos/dll/win32/secur32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/secur32/CMakeLis…
Modified: trunk/reactos/dll/win32/secur32/precomp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/secur32/precomp.…
Modified: trunk/reactos/dll/win32/secur32/secur32.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/secur32/secur32.…
Added: trunk/reactos/dll/win32/secur32/secur32_priv.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/secur32/secur32_…
Modified: trunk/reactos/dll/win32/secur32/sspi.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/secur32/sspi.c?r…
Added: trunk/reactos/dll/win32/secur32/thunks.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/secur32/thunks.c…
Added: trunk/reactos/dll/win32/secur32/thunks.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/secur32/thunks.h…
Added: trunk/reactos/dll/win32/secur32/wrapper.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/secur32/wrapper.…
10 years, 3 months
1
0
0
0
[tkreuzer] 63993: [HPP] Implement support for variable substitution
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Sat Aug 30 17:18:48 2014 New Revision: 63993 URL:
http://svn.reactos.org/svn/reactos?rev=63993&view=rev
Log: [HPP] Implement support for variable substitution Added: trunk/reactos/tools/hpp/CMakeLists.txt (with props) Modified: trunk/reactos/tools/hpp/hpp.c Added: trunk/reactos/tools/hpp/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/hpp/CMakeLists.txt?r…
============================================================================== --- trunk/reactos/tools/hpp/CMakeLists.txt (added) +++ trunk/reactos/tools/hpp/CMakeLists.txt [iso-8859-1] Sat Aug 30 17:18:48 2014 @@ -0,0 +1 @@ +add_executable(hpp hpp.c) Propchange: trunk/reactos/tools/hpp/CMakeLists.txt ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/tools/hpp/hpp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/hpp/hpp.c?rev=63993&…
============================================================================== --- trunk/reactos/tools/hpp/hpp.c [iso-8859-1] (original) +++ trunk/reactos/tools/hpp/hpp.c [iso-8859-1] Sat Aug 30 17:18:48 2014 @@ -23,9 +23,12 @@ typedef struct _DEFINE { struct _DEFINE *pNext; - int len; int val; - char szName[1]; + char *pszName; + unsigned int cchName; + char *pszValue; + unsigned int cchValue; + char achBuffer[1]; } DEFINE, *PDEFINE; DEFINE *gpDefines = 0; @@ -58,7 +61,7 @@ #endif i++; } - return(newpath); + return newpath; } char* @@ -160,45 +163,87 @@ return len; } - -void -WriteLine(char *pszLine, FILE *fileOut) -{ - char * pszEnd; - - pszEnd = strchr(pszLine, '\n'); - if (pszEnd) - { - int len = pszEnd - pszLine + 1; - fwrite(pszLine, 1, len, fileOut); - } -} - -int -EvaluateConstant(const char *p, char **pNext) +PDEFINE +FindDefine(const char *p, char **pNext) { PDEFINE pDefine; - int len; - - len = strxlen(p); + int cchName; + + cchName = strxlen(p); if (pNext) - *pNext = (char*)p + len; + *pNext = (char*)p + cchName; /* search for the define in the global list */ pDefine = gpDefines; while (pDefine != 0) { - trace("found a define: %s\n", pDefine->szName); - if (pDefine->len == len) - { - if (strncmp(p, pDefine->szName, len) == 0) - { - return pDefine->val; + trace("found a define: %s\n", pDefine->pszName); + if (pDefine->cchName == cchName) + { + if (strncmp(p, pDefine->pszName, cchName) == 0) + { + return pDefine; } } pDefine = pDefine->pNext; } return 0; +} + +void +WriteLine(char *pchLine, FILE *fileOut) +{ + char *pch, *pchLineEnd, *pchVariable; + int len; + PDEFINE pDefine; + + pchLineEnd = strchr(pchLine, '\n'); + if (pchLineEnd == 0) + return; + + len = pchLineEnd - pchLine + 1; + + pch = pchLine; + while (len > 0) + { + /* Check if there is a $ variable in the line */ + pchVariable = strchr(pch, '$'); + if (pchVariable && (pchVariable < pchLineEnd)) + { + fwrite(pch, 1, pchVariable - pch, fileOut); + + pDefine = FindDefine(pchVariable + 1, &pch); + if (pDefine != 0) + { + fwrite(pDefine->pszValue, 1, pDefine->cchValue, fileOut); + } + else + { + len = strxlen(pchVariable + 1) + 1; + error("Could not find variable '%.*s'\n", len, pchVariable); + fwrite(pchVariable, 1, pch - pchVariable, fileOut); + } + + len = pchLineEnd - pch; + } + else + { + fwrite(pch, 1, len, fileOut); + break; + } + } +} + +int +EvaluateConstant(const char *p, char **pNext) +{ + PDEFINE pDefine; + + pDefine = FindDefine(p, pNext); + if (!pDefine) + return 0; + + return pDefine->val; } int @@ -289,7 +334,7 @@ } else { - error("+Parse error: expected '(' or operator in Line %d, got %c\n", + error("+Parse error: expected '(' or operator in Line %d, got %c\n", iLine, pstart[0]); return -1; } @@ -317,7 +362,7 @@ ParseInputFile(const char *pszInFile, FILE *fileOut) { char* pInputData, *pCurrentLine, *p1, *p2; - size_t cbInFileLenth, len; + size_t cbInFileLenth; int iIfLevel, iCopyLevel; trace("parsing input file: %s\n", pszInFile); @@ -393,33 +438,75 @@ if (strncmp(pCurrentLine, "$define", 7) == 0) { PDEFINE pDefine; + char *pchName, *pchValue; + size_t cchName, cchValue; trace("found $define\n"); p1 = GetNextChar(pCurrentLine + 7); if (*p1 != '(') { - error("Parse error: expected '(' at %s:%d\n", + error("Parse error: expected '(' at %s:%d\n", pszInFile, iLine); return -1; } - p1 = GetNextChar(p1 + 1); - len = strxlen(p1); - p2 = p1 + len; - if (*p2 != ')') + + pchName = GetNextChar(p1 + 1); + cchName = strxlen(pchName); + p1 = GetNextChar(pchName + cchName); + + /* Check for assignment */ + if (*p1 == '=') + { + trace("found $define with assignment\n"); + pchValue = GetNextChar(p1 + 1); + cchValue = strxlen(pchValue); + p1 = GetNextChar(pchValue + cchValue); + } + else + { + pchValue = 0; + cchValue = 0; + } + + /* Allocate a DEFINE structure */ + pDefine = malloc(sizeof(DEFINE) + cchName + cchValue + 2); + if (pDefine == 0) + { + error("Failed to allocate %u bytes\n", + sizeof(DEFINE) + cchName + cchValue + 2); + return -1; + } + + pDefine->pszName = pDefine->achBuffer; + strncpy(pDefine->pszName, pchName, cchName); + pDefine->pszName[cchName] = 0; + pDefine->cchName = cchName; + pDefine->val = 1; + + if (pchValue != 0) + { + pDefine->pszValue = &pDefine->achBuffer[cchName + 1]; + strncpy(pDefine->pszValue, pchValue, cchValue); + pDefine->pszValue[cchValue] = 0; + pDefine->cchValue = cchValue; + } + else + { + pDefine->pszValue = 0; + pDefine->cchValue = 0; + } + + /* Insert the new define into the global list */ + pDefine->pNext = gpDefines; + gpDefines = pDefine; + + /* Check for closing ')' */ + if (*p1 != ')') { error("Parse error: expected ')' at %s:%d\n", pszInFile, iLine); return -1; } - - /* Insert the new define into the global list */ - pDefine = malloc(sizeof(DEFINE) + len); - strncpy(pDefine->szName, p1, len); - pDefine->szName[len] = 0; - pDefine->len = len; - pDefine->val = 1; - pDefine->pNext = gpDefines; - gpDefines = pDefine; } /* Check for $if */ @@ -457,7 +544,7 @@ p1 = GetNextChar(pCurrentLine + 8); if (*p1 != '(') { - error("Parse error: expected '(' at %s:%d, found '%c'\n", + error("Parse error: expected '(' at %s:%d, found '%c'\n", pszInFile, iLine, *p1); return -1; } @@ -470,7 +557,7 @@ /* Restore the global file name */ gpszCurFile = pszInFile; - + /* Restore the zeroed character */ *p2 = ')';
10 years, 3 months
1
0
0
0
[hbelusca] 63992: [CONSRV]: Start implementing popup windows (it's what you see when you press e.g. the F7 key in your console, when you run cmd.exe).
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sat Aug 30 16:20:32 2014 New Revision: 63992 URL:
http://svn.reactos.org/svn/reactos?rev=63992&view=rev
Log: [CONSRV]: Start implementing popup windows (it's what you see when you press e.g. the F7 key in your console, when you run cmd.exe). Added: branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.c (with props) branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.h (with props) Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv.cmake branches/condrv_restructure/win32ss/user/winsrv/consrv/console.c branches/condrv_restructure/win32ss/user/winsrv/consrv/include/conio_winsrv.h Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv.cmake URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
============================================================================== --- branches/condrv_restructure/win32ss/user/winsrv/consrv.cmake [iso-8859-1] (original) +++ branches/condrv_restructure/win32ss/user/winsrv/consrv.cmake [iso-8859-1] Sat Aug 30 16:20:32 2014 @@ -14,6 +14,7 @@ consrv/history.c consrv/init.c consrv/lineinput.c + consrv/popup.c consrv/settings.c consrv/subsysreg.c consrv/condrv/coninput.c Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/console.c URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
============================================================================== --- branches/condrv_restructure/win32ss/user/winsrv/consrv/console.c [iso-8859-1] (original) +++ branches/condrv_restructure/win32ss/user/winsrv/consrv/console.c [iso-8859-1] Sat Aug 30 16:20:32 2014 @@ -436,6 +436,9 @@ Console->LineInsertToggle = Console->InsertMode = ConsoleInfo.InsertMode; Console->QuickEdit = ConsoleInfo.QuickEdit; + + /* Popup windows */ + InitializeListHead(&Console->PopupWindows); /* Colour table */ memcpy(Console->Colors, ConsoleInfo.Colors, sizeof(ConsoleInfo.Colors)); Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/include/conio_winsrv.h URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
============================================================================== --- branches/condrv_restructure/win32ss/user/winsrv/consrv/include/conio_winsrv.h [iso-8859-1] (original) +++ branches/condrv_restructure/win32ss/user/winsrv/consrv/include/conio_winsrv.h [iso-8859-1] Sat Aug 30 16:20:32 2014 @@ -168,7 +168,8 @@ HANDLE ErrorHardwareEvent; /****************************** Other properties ******************************/ - COLORREF Colors[16]; /* Colour palette */ + LIST_ENTRY PopupWindows; /*List of popup windows */ + COLORREF Colors[16]; /* Colour palette */ } WINSRV_CONSOLE, *PWINSRV_CONSOLE; Added: branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.c URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
============================================================================== --- branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.c (added) +++ branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.c [iso-8859-1] Sat Aug 30 16:20:32 2014 @@ -0,0 +1,248 @@ +/* + * LICENSE: GPL - See COPYING in the top level directory + * PROJECT: ReactOS Console Server DLL + * FILE: win32ss/user/winsrv/consrv/popup.c + * PURPOSE: Console popup windows + * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) + * + * NOTE: Strongly inspired by the DrawBox function + * from base/setup/usetup/interface/usetup.c, written by: + * Eric Kohl (revision 3753) + * Hervé Poussineau (revision 24718) + * and *UiDisplayMenu from FreeLdr. + */ + +/* INCLUDES *******************************************************************/ + +#include "consrv.h" +#include "popup.h" + +#define NDEBUG +#include <debug.h> + + +/* PRIVATE FUNCTIONS **********************************************************/ + +NTSTATUS NTAPI +ConDrvFillConsoleOutput(IN PCONSOLE Console, + IN PTEXTMODE_SCREEN_BUFFER Buffer, + IN CODE_TYPE CodeType, + IN CODE_ELEMENT Code, + IN ULONG NumCodesToWrite, + IN PCOORD WriteCoord, + OUT PULONG NumCodesWritten OPTIONAL); +NTSTATUS NTAPI +ConDrvReadConsoleOutput(IN PCONSOLE Console, + IN PTEXTMODE_SCREEN_BUFFER Buffer, + IN BOOLEAN Unicode, + OUT PCHAR_INFO CharInfo/*Buffer*/, + IN OUT PSMALL_RECT ReadRegion); +NTSTATUS NTAPI +ConDrvWriteConsoleOutput(IN PCONSOLE Console, + IN PTEXTMODE_SCREEN_BUFFER Buffer, + IN BOOLEAN Unicode, + IN PCHAR_INFO CharInfo/*Buffer*/, + IN OUT PSMALL_RECT WriteRegion); + + +static VOID +DrawBox(PTEXTMODE_SCREEN_BUFFER Buffer, + IN SHORT xLeft, + IN SHORT yTop, + IN SHORT Width, + IN SHORT Height) +{ + COORD coPos; + DWORD Written; + + /* Set screen attributes */ + coPos.X = xLeft; + for (coPos.Y = yTop; coPos.Y < yTop + Height; coPos.Y++) + { + ConDrvFillConsoleOutput(Buffer->Header.Console, + Buffer, + CODE_ATTRIBUTE, + (CODE_ELEMENT)(WORD)Buffer->PopupDefaultAttrib, + Width, + &coPos, + &Written); + } + + /* draw upper left corner */ + coPos.X = xLeft; + coPos.Y = yTop; + ConDrvFillConsoleOutput(Buffer->Header.Console, + Buffer, + CODE_ASCII, + (CODE_ELEMENT)(CHAR)0xDA, // '+', + 1, + &coPos, + &Written); + + /* draw upper edge */ + coPos.X = xLeft + 1; + coPos.Y = yTop; + ConDrvFillConsoleOutput(Buffer->Header.Console, + Buffer, + CODE_ASCII, + (CODE_ELEMENT)(CHAR)0xC4, // '-', + Width - 2, + &coPos, + &Written); + + /* draw upper right corner */ + coPos.X = xLeft + Width - 1; + coPos.Y = yTop; + ConDrvFillConsoleOutput(Buffer->Header.Console, + Buffer, + CODE_ASCII, + (CODE_ELEMENT)(CHAR)0xBF, // '+', + 1, + &coPos, + &Written); + + /* Draw right edge, inner space and left edge */ + for (coPos.Y = yTop + 1; coPos.Y < yTop + Height - 1; coPos.Y++) + { + coPos.X = xLeft; + ConDrvFillConsoleOutput(Buffer->Header.Console, + Buffer, + CODE_ASCII, + (CODE_ELEMENT)(CHAR)0xB3, // '|', + 1, + &coPos, + &Written); + + coPos.X = xLeft + 1; + ConDrvFillConsoleOutput(Buffer->Header.Console, + Buffer, + CODE_ASCII, + (CODE_ELEMENT)(CHAR)' ', + Width - 2, + &coPos, + &Written); + + coPos.X = xLeft + Width - 1; + ConDrvFillConsoleOutput(Buffer->Header.Console, + Buffer, + CODE_ASCII, + (CODE_ELEMENT)(CHAR)0xB3, // '|', + 1, + &coPos, + &Written); + } + + /* draw lower left corner */ + coPos.X = xLeft; + coPos.Y = yTop + Height - 1; + ConDrvFillConsoleOutput(Buffer->Header.Console, + Buffer, + CODE_ASCII, + (CODE_ELEMENT)(CHAR)0xC0, // '+', + 1, + &coPos, + &Written); + + /* draw lower edge */ + coPos.X = xLeft + 1; + coPos.Y = yTop + Height - 1; + ConDrvFillConsoleOutput(Buffer->Header.Console, + Buffer, + CODE_ASCII, + (CODE_ELEMENT)(CHAR)0xC4, // '-', + Width - 2, + &coPos, + &Written); + + /* draw lower right corner */ + coPos.X = xLeft + Width - 1; + coPos.Y = yTop + Height - 1; + ConDrvFillConsoleOutput(Buffer->Header.Console, + Buffer, + CODE_ASCII, + (CODE_ELEMENT)(CHAR)0xD9, // '+', + 1, + &coPos, + &Written); +} + + +/* PUBLIC FUNCTIONS ***********************************************************/ + +PPOPUP_WINDOW +CreatePopupWindow(PTEXTMODE_SCREEN_BUFFER Buffer, + SHORT xLeft, + SHORT yTop, + SHORT Width, + SHORT Height) +{ + PPOPUP_WINDOW Popup; + SMALL_RECT Region; + + /* Create the popup window */ + Popup = ConsoleAllocHeap(HEAP_ZERO_MEMORY, sizeof(*Popup)); + if (Popup == NULL) return NULL; + + Popup->ScreenBuffer = Buffer; + Popup->Origin.X = xLeft; + Popup->Origin.Y = yTop; + Popup->Size.X = Width; + Popup->Size.Y = Height; + + /* Save old contents */ + Popup->OldContents = ConsoleAllocHeap(HEAP_ZERO_MEMORY, + Popup->Size.X * Popup->Size.Y * + sizeof(*Popup->OldContents)); + if (Popup->OldContents == NULL) + { + ConsoleFreeHeap(Popup); + return NULL; + } + Region.Left = Popup->Origin.X; + Region.Top = Popup->Origin.Y; + Region.Right = Popup->Origin.X + Popup->Size.X - 1; + Region.Bottom = Popup->Origin.Y + Popup->Size.Y - 1; + ConDrvReadConsoleOutput(Buffer->Header.Console, + Buffer, + TRUE, + Popup->OldContents, + &Region); + + /* Draw it */ + DrawBox(Buffer, + xLeft, yTop, + Width, Height); + + /* Add it into the list of popups */ + InsertTailList(&Buffer->Header.Console->PopupWindows, &Popup->ListEntry); + + return Popup; +} + +VOID +DestroyPopupWindow(PPOPUP_WINDOW Popup) +{ + SMALL_RECT Region; + + if (Popup == NULL) return; + + /* Remove it from the list of popups */ + RemoveEntryList(&Popup->ListEntry); + + /* Restore the old screen-buffer contents */ + Region.Left = Popup->Origin.X; + Region.Top = Popup->Origin.Y; + Region.Right = Popup->Origin.X + Popup->Size.X - 1; + Region.Bottom = Popup->Origin.Y + Popup->Size.Y - 1; + ConDrvWriteConsoleOutput(Popup->ScreenBuffer->Header.Console, + Popup->ScreenBuffer, + TRUE, + Popup->OldContents, + &Region); + + /* Free memory */ + ConsoleFreeHeap(Popup->OldContents); + ConsoleFreeHeap(Popup); +} + +/* EOF */ Propchange: branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.c ------------------------------------------------------------------------------ svn:eol-style = native Added: branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.h URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
============================================================================== --- branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.h (added) +++ branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.h [iso-8859-1] Sat Aug 30 16:20:32 2014 @@ -0,0 +1,36 @@ +/* + * LICENSE: GPL - See COPYING in the top level directory + * PROJECT: ReactOS Console Server DLL + * FILE: win32ss/user/winsrv/consrv/popup.h + * PURPOSE: Console popup windows + * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) + */ + +#pragma once + +typedef +VOID +(NTAPI *PPOPUP_INPUT_ROUTINE)(VOID); + +typedef struct _POPUP_WINDOW +{ + LIST_ENTRY ListEntry; /* Entry in console's list of popups */ + PTEXTMODE_SCREEN_BUFFER ScreenBuffer; /* Associated screen-buffer */ + + // SMALL_RECT Region; /* The region the popup occupies */ + COORD Origin; /* Origin of the popup window */ + COORD Size; /* Size of the popup window */ + + PCHAR_INFO OldContents; /* The data under the popup window */ + PPOPUP_INPUT_ROUTINE PopupInputRoutine; /* Routine called when input is received */ +} POPUP_WINDOW, *PPOPUP_WINDOW; + + +PPOPUP_WINDOW +CreatePopupWindow(PTEXTMODE_SCREEN_BUFFER Buffer, + SHORT xLeft, + SHORT yTop, + SHORT Width, + SHORT Height); +VOID +DestroyPopupWindow(PPOPUP_WINDOW Popup); Propchange: branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.h ------------------------------------------------------------------------------ svn:eol-style = native
10 years, 3 months
1
0
0
0
[hbelusca] 63991: [CONDRV] - In ConDrvChangeScreenBufferAttributes, change also the popup attributes. - In some functions we need to check validity of Read/WriteCoord parameters, add fixme for now, ...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sat Aug 30 16:18:07 2014 New Revision: 63991 URL:
http://svn.reactos.org/svn/reactos?rev=63991&view=rev
Log: [CONDRV] - In ConDrvChangeScreenBufferAttributes, change also the popup attributes. - In some functions we need to check validity of Read/WriteCoord parameters, add fixme for now, that need to be fixed later on. Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/text.c Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/text.c URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
============================================================================== --- branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/text.c [iso-8859-1] (original) +++ branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/text.c [iso-8859-1] Sat Aug 30 16:18:07 2014 @@ -363,7 +363,7 @@ COORD TopLeft = {0}; ULONG NumCodesToWrite; - USHORT OldScreenAttrib; + USHORT OldScreenAttrib, OldPopupAttrib; if (Console == NULL || Buffer == NULL) { @@ -375,6 +375,7 @@ NumCodesToWrite = Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y; OldScreenAttrib = Buffer->ScreenDefaultAttrib; + OldPopupAttrib = Buffer->PopupDefaultAttrib; X = TopLeft.X; Y = (TopLeft.Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y; @@ -395,10 +396,14 @@ /* Foreground color */ if ((Ptr->Attributes & 0x0F) == (OldScreenAttrib & 0x0F)) Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewScreenAttrib & 0x0F); + if ((Ptr->Attributes & 0x0F) == (OldPopupAttrib & 0x0F)) + Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewPopupAttrib & 0x0F); /* Background color */ if ((Ptr->Attributes & 0xF0) == (OldScreenAttrib & 0xF0)) Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewScreenAttrib & 0xF0); + if ((Ptr->Attributes & 0xF0) == (OldPopupAttrib & 0xF0)) + Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewPopupAttrib & 0xF0); // ++Ptr; @@ -715,6 +720,10 @@ /* Validity checks */ ASSERT(Console == Buffer->Header.Console); ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCodesToRead == 0)); + + // + // FIXME: Make overflow checks on ReadCoord !!!!!! + // if (NumCodesRead) *NumCodesRead = 0; @@ -826,6 +835,10 @@ ASSERT(Console == Buffer->Header.Console); ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCodesToWrite == 0)); + // + // FIXME: Make overflow checks on WriteCoord !!!!!! + // + if (NumCodesWritten) *NumCodesWritten = 0; switch (CodeType) @@ -953,6 +966,10 @@ /* Validity check */ ASSERT(Console == Buffer->Header.Console); + + // + // FIXME: Make overflow checks on WriteCoord !!!!!! + // if (NumCodesWritten) *NumCodesWritten = 0;
10 years, 3 months
1
0
0
0
[hbelusca] 63990: [CONSRV]: Code formatting only.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sat Aug 30 15:59:35 2014 New Revision: 63990 URL:
http://svn.reactos.org/svn/reactos?rev=63990&view=rev
Log: [CONSRV]: Code formatting only. Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/lineinput.c Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/lineinput.c URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
============================================================================== --- branches/condrv_restructure/win32ss/user/winsrv/consrv/lineinput.c [iso-8859-1] (original) +++ branches/condrv_restructure/win32ss/user/winsrv/consrv/lineinput.c [iso-8859-1] Sat Aug 30 15:59:35 2014 @@ -165,7 +165,6 @@ { UINT Pos = Console->LinePos; UNICODE_STRING Entry; - // INT HistPos; /* * First, deal with control keys... @@ -173,159 +172,207 @@ switch (KeyEvent->wVirtualKeyCode) { - case VK_ESCAPE: - /* Clear entire line */ - LineInputSetPos(Console, 0); - LineInputEdit(Console, Console->LineSize, 0, NULL); - return; - case VK_HOME: - /* Move to start of line. With CTRL, erase everything left of cursor */ - LineInputSetPos(Console, 0); - if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) - LineInputEdit(Console, Pos, 0, NULL); - return; - case VK_END: - /* Move to end of line. With CTRL, erase everything right of cursor */ - if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) - LineInputEdit(Console, Console->LineSize - Pos, 0, NULL); - else - LineInputSetPos(Console, Console->LineSize); - return; - case VK_LEFT: - /* Move left. With CTRL, move to beginning of previous word */ - if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) - { - while (Pos > 0 && Console->LineBuffer[Pos - 1] == L' ') Pos--; - while (Pos > 0 && Console->LineBuffer[Pos - 1] != L' ') Pos--; - } - else - { - Pos -= (Pos > 0); - } - LineInputSetPos(Console, Pos); - return; - case VK_RIGHT: - case VK_F1: - /* Move right. With CTRL, move to beginning of next word */ - if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) - { - while (Pos < Console->LineSize && Console->LineBuffer[Pos] != L' ') Pos++; - while (Pos < Console->LineSize && Console->LineBuffer[Pos] == L' ') Pos++; + case VK_ESCAPE: + { + /* Clear entire line */ + LineInputSetPos(Console, 0); + LineInputEdit(Console, Console->LineSize, 0, NULL); + return; + } + + case VK_HOME: + { + /* Move to start of line. With CTRL, erase everything left of cursor */ + LineInputSetPos(Console, 0); + if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) + LineInputEdit(Console, Pos, 0, NULL); + return; + } + + case VK_END: + { + /* Move to end of line. With CTRL, erase everything right of cursor */ + if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) + LineInputEdit(Console, Console->LineSize - Pos, 0, NULL); + else + LineInputSetPos(Console, Console->LineSize); + return; + } + + case VK_LEFT: + { + /* Move left. With CTRL, move to beginning of previous word */ + if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) + { + while (Pos > 0 && Console->LineBuffer[Pos - 1] == L' ') Pos--; + while (Pos > 0 && Console->LineBuffer[Pos - 1] != L' ') Pos--; + } + else + { + Pos -= (Pos > 0); + } LineInputSetPos(Console, Pos); - } - else - { - /* Recall one character (but don't overwrite current line) */ + return; + } + + case VK_RIGHT: + case VK_F1: + { + /* Move right. With CTRL, move to beginning of next word */ + if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) + { + while (Pos < Console->LineSize && Console->LineBuffer[Pos] != L' ') Pos++; + while (Pos < Console->LineSize && Console->LineBuffer[Pos] == L' ') Pos++; + LineInputSetPos(Console, Pos); + } + else + { + /* Recall one character (but don't overwrite current line) */ + HistoryGetCurrentEntry(Console, ExeName, &Entry); + if (Pos < Console->LineSize) + LineInputSetPos(Console, Pos + 1); + else if (Pos * sizeof(WCHAR) < Entry.Length) + LineInputEdit(Console, 0, 1, &Entry.Buffer[Pos]); + } + return; + } + + case VK_INSERT: + { + /* Toggle between insert and overstrike */ + Console->LineInsertToggle = !Console->LineInsertToggle; + TermSetCursorInfo(Console, Console->ActiveBuffer); + return; + } + + case VK_DELETE: + { + /* Remove character to right of cursor */ + if (Pos != Console->LineSize) + LineInputEdit(Console, 1, 0, NULL); + return; + } + + case VK_PRIOR: + { + /* Recall first history entry */ + LineInputRecallHistory(Console, ExeName, -((WORD)-1)); + return; + } + + case VK_NEXT: + { + /* Recall last history entry */ + LineInputRecallHistory(Console, ExeName, +((WORD)-1)); + return; + } + + case VK_UP: + case VK_F5: + { + /* + * Recall previous history entry. On first time, actually recall the + * current (usually last) entry; on subsequent times go back. + */ + LineInputRecallHistory(Console, ExeName, Console->LineUpPressed ? -1 : 0); + Console->LineUpPressed = TRUE; + return; + } + + case VK_DOWN: + { + /* Recall next history entry */ + LineInputRecallHistory(Console, ExeName, +1); + return; + } + + case VK_F3: + { + /* Recall remainder of current history entry */ HistoryGetCurrentEntry(Console, ExeName, &Entry); - if (Pos < Console->LineSize) - LineInputSetPos(Console, Pos + 1); - else if (Pos * sizeof(WCHAR) < Entry.Length) - LineInputEdit(Console, 0, 1, &Entry.Buffer[Pos]); - } - return; - case VK_INSERT: - /* Toggle between insert and overstrike */ - Console->LineInsertToggle = !Console->LineInsertToggle; - TermSetCursorInfo(Console, Console->ActiveBuffer); - return; - case VK_DELETE: - /* Remove character to right of cursor */ - if (Pos != Console->LineSize) - LineInputEdit(Console, 1, 0, NULL); - return; - case VK_PRIOR: - /* Recall first history entry */ - LineInputRecallHistory(Console, ExeName, -((WORD)-1)); - return; - case VK_NEXT: - /* Recall last history entry */ - LineInputRecallHistory(Console, ExeName, +((WORD)-1)); - return; - case VK_UP: - case VK_F5: - /* - * Recall previous history entry. On first time, actually recall the - * current (usually last) entry; on subsequent times go back. - */ - LineInputRecallHistory(Console, ExeName, Console->LineUpPressed ? -1 : 0); - Console->LineUpPressed = TRUE; - return; - case VK_DOWN: - /* Recall next history entry */ - LineInputRecallHistory(Console, ExeName, +1); - return; - case VK_F3: - /* Recall remainder of current history entry */ - HistoryGetCurrentEntry(Console, ExeName, &Entry); - if (Pos * sizeof(WCHAR) < Entry.Length) - { - UINT InsertSize = (Entry.Length / sizeof(WCHAR) - Pos); - UINT DeleteSize = min(Console->LineSize - Pos, InsertSize); - LineInputEdit(Console, DeleteSize, InsertSize, &Entry.Buffer[Pos]); - } - return; - case VK_F6: - /* Insert a ^Z character */ - KeyEvent->uChar.UnicodeChar = 26; - break; - case VK_F7: - if (KeyEvent->dwControlKeyState & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) - HistoryDeleteCurrentBuffer(Console, ExeName); - return; - case VK_F8: - - { - UNICODE_STRING EntryFound; - - Entry.Length = Console->LinePos * sizeof(WCHAR); // == Pos * sizeof(WCHAR) - Entry.Buffer = Console->LineBuffer; - - if (HistoryFindEntryByPrefix(Console, ExeName, &Entry, &EntryFound)) - { - LineInputEdit(Console, Console->LineSize - Pos, - EntryFound.Length / sizeof(WCHAR) - Pos, - &EntryFound.Buffer[Pos]); - /* Cursor stays where it was */ - LineInputSetPos(Console, Pos); - } - } -#if 0 - PHISTORY_BUFFER Hist; - - /* Search for history entries starting with input. */ - Hist = HistoryCurrentBuffer(Console, ExeName); - if (!Hist || Hist->NumEntries == 0) return; - - /* - * Like Up/F5, on first time start from current (usually last) entry, - * but on subsequent times start at previous entry. - */ - if (Console->LineUpPressed) - Hist->Position = (Hist->Position ? Hist->Position : Hist->NumEntries) - 1; - Console->LineUpPressed = TRUE; - - Entry.Length = Console->LinePos * sizeof(WCHAR); // == Pos * sizeof(WCHAR) - Entry.Buffer = Console->LineBuffer; - - /* - * Keep going backwards, even wrapping around to the end, - * until we get back to starting point. - */ - HistPos = Hist->Position; - do - { - if (RtlPrefixUnicodeString(&Entry, &Hist->Entries[HistPos], FALSE)) - { - Hist->Position = HistPos; + if (Pos * sizeof(WCHAR) < Entry.Length) + { + UINT InsertSize = (Entry.Length / sizeof(WCHAR) - Pos); + UINT DeleteSize = min(Console->LineSize - Pos, InsertSize); + LineInputEdit(Console, DeleteSize, InsertSize, &Entry.Buffer[Pos]); + } + return; + } + + case VK_F6: + { + /* Insert a ^Z character */ + KeyEvent->uChar.UnicodeChar = 26; + break; + } + + case VK_F7: + { + if (KeyEvent->dwControlKeyState & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) + HistoryDeleteCurrentBuffer(Console, ExeName); + return; + } + + case VK_F8: + { + UNICODE_STRING EntryFound; + + Entry.Length = Console->LinePos * sizeof(WCHAR); // == Pos * sizeof(WCHAR) + Entry.Buffer = Console->LineBuffer; + + if (HistoryFindEntryByPrefix(Console, ExeName, &Entry, &EntryFound)) + { LineInputEdit(Console, Console->LineSize - Pos, - Hist->Entries[HistPos].Length / sizeof(WCHAR) - Pos, - &Hist->Entries[HistPos].Buffer[Pos]); + EntryFound.Length / sizeof(WCHAR) - Pos, + &EntryFound.Buffer[Pos]); /* Cursor stays where it was */ LineInputSetPos(Console, Pos); - return; - } - if (--HistPos < 0) HistPos += Hist->NumEntries; - } while (HistPos != Hist->Position); + } + + return; + } +#if 0 + { + PHISTORY_BUFFER Hist; + INT HistPos; + + /* Search for history entries starting with input. */ + Hist = HistoryCurrentBuffer(Console, ExeName); + if (!Hist || Hist->NumEntries == 0) return; + + /* + * Like Up/F5, on first time start from current (usually last) entry, + * but on subsequent times start at previous entry. + */ + if (Console->LineUpPressed) + Hist->Position = (Hist->Position ? Hist->Position : Hist->NumEntries) - 1; + Console->LineUpPressed = TRUE; + + Entry.Length = Console->LinePos * sizeof(WCHAR); // == Pos * sizeof(WCHAR) + Entry.Buffer = Console->LineBuffer; + + /* + * Keep going backwards, even wrapping around to the end, + * until we get back to starting point. + */ + HistPos = Hist->Position; + do + { + if (RtlPrefixUnicodeString(&Entry, &Hist->Entries[HistPos], FALSE)) + { + Hist->Position = HistPos; + LineInputEdit(Console, Console->LineSize - Pos, + Hist->Entries[HistPos].Length / sizeof(WCHAR) - Pos, + &Hist->Entries[HistPos].Buffer[Pos]); + /* Cursor stays where it was */ + LineInputSetPos(Console, Pos); + return; + } + if (--HistPos < 0) HistPos += Hist->NumEntries; + } while (HistPos != Hist->Position); + + return; + } #endif return; @@ -333,7 +380,7 @@ /* - * OK, we can continue... + * OK, we deal with normal keys, we can continue... */ if (KeyEvent->uChar.UnicodeChar == L'\b' && Console->InputBuffer.Mode & ENABLE_PROCESSED_INPUT)
10 years, 3 months
1
0
0
0
[akhaldi] 63989: [W32KNAPI_APITEST] * Here's another memset call..
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sat Aug 30 12:05:36 2014 New Revision: 63989 URL:
http://svn.reactos.org/svn/reactos?rev=63989&view=rev
Log: [W32KNAPI_APITEST] * Here's another memset call.. Modified: trunk/rostests/apitests/w32knapi/ntgdi/NtGdiCreateDIBSection.c Modified: trunk/rostests/apitests/w32knapi/ntgdi/NtGdiCreateDIBSection.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/ntgdi/N…
============================================================================== --- trunk/rostests/apitests/w32knapi/ntgdi/NtGdiCreateDIBSection.c [iso-8859-1] (original) +++ trunk/rostests/apitests/w32knapi/ntgdi/NtGdiCreateDIBSection.c [iso-8859-1] Sat Aug 30 12:05:36 2014 @@ -381,7 +381,7 @@ pbV4h->bV4BlueMask = 0; pbV4h->bV4AlphaMask = 0; pbV4h->bV4CSType = 0; - memset(&pbV4h->bV4Endpoints, sizeof(CIEXYZTRIPLE), 0); + memset(&pbV4h->bV4Endpoints, 0, sizeof(CIEXYZTRIPLE)); pbV4h->bV4GammaRed = 0; pbV4h->bV4GammaGreen = 0; pbV4h->bV4GammaBlue = 0;
10 years, 3 months
1
0
0
0
[akhaldi] 63988: [W32KNAPI_APITEST] * Fix a memset call. CID 1223160. CORE-7975
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sat Aug 30 12:03:58 2014 New Revision: 63988 URL:
http://svn.reactos.org/svn/reactos?rev=63988&view=rev
Log: [W32KNAPI_APITEST] * Fix a memset call. CID 1223160. CORE-7975 Modified: trunk/rostests/apitests/w32knapi/ntgdi/NtGdiCreateDIBSection.c Modified: trunk/rostests/apitests/w32knapi/ntgdi/NtGdiCreateDIBSection.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/ntgdi/N…
============================================================================== --- trunk/rostests/apitests/w32knapi/ntgdi/NtGdiCreateDIBSection.c [iso-8859-1] (original) +++ trunk/rostests/apitests/w32knapi/ntgdi/NtGdiCreateDIBSection.c [iso-8859-1] Sat Aug 30 12:03:58 2014 @@ -417,7 +417,7 @@ pbV5h->bV5BlueMask = 0; pbV5h->bV5AlphaMask = 0; pbV5h->bV5CSType = 0; - memset(&pbV5h->bV5Endpoints, sizeof(CIEXYZTRIPLE), 0); + memset(&pbV5h->bV5Endpoints, 0, sizeof(CIEXYZTRIPLE)); pbV5h->bV5GammaRed = 0; pbV5h->bV5GammaGreen = 0; pbV5h->bV5GammaBlue = 0;
10 years, 3 months
1
0
0
0
← Newer
1
2
3
4
5
6
...
23
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
Results per page:
10
25
50
100
200