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
March 2013
----- 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
14 participants
249 discussions
Start a n
N
ew thread
[ekohl] 58451: [LSASRV] - Move LsapLookupAuthenticationPackage, LsapCallAuthenticationPackage and LsapLogonUser from authport.c to authpackage.c. - Make LsapCallAuthenticationPackage and LsapLogonU...
by ekohl@svn.reactos.org
Author: ekohl Date: Sat Mar 9 15:54:45 2013 New Revision: 58451 URL:
http://svn.reactos.org/svn/reactos?rev=58451&view=rev
Log: [LSASRV] - Move LsapLookupAuthenticationPackage, LsapCallAuthenticationPackage and LsapLogonUser from authport.c to authpackage.c. - Make LsapCallAuthenticationPackage and LsapLogonUser call the matching authentication package functions. Modified: trunk/reactos/dll/win32/lsasrv/authpackage.c trunk/reactos/dll/win32/lsasrv/authport.c trunk/reactos/dll/win32/lsasrv/lsasrv.h Modified: trunk/reactos/dll/win32/lsasrv/authpackage.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/authpacka…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/authpackage.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/authpackage.c [iso-8859-1] Sat Mar 9 15:54:45 2013 @@ -12,9 +12,18 @@ WINE_DEFAULT_DEBUG_CHANNEL(lsasrv); +typedef enum _LSA_TOKEN_INFORMATION_TYPE +{ + LsaTokenInformationNull, + LsaTokenInformationV1 +} LSA_TOKEN_INFORMATION_TYPE, *PLSA_TOKEN_INFORMATION_TYPE; + +typedef PVOID PLSA_CLIENT_REQUEST; typedef PVOID (NTAPI *PLSA_ALLOCATE_LSA_HEAP)(ULONG); typedef VOID (NTAPI *PLSA_FREE_LSA_HEAP)(PVOID); +typedef NTSTATUS (NTAPI *PLSA_ALLOCATE_CLIENT_BUFFER)(PLSA_CLIENT_REQUEST, ULONG, PVOID*); +typedef NTSTATUS (NTAPI *PLSA_FREE_CLIENT_BUFFER)(PLSA_CLIENT_REQUEST, PVOID); typedef struct LSA_DISPATCH_TABLE { @@ -25,8 +34,8 @@ PVOID /*PLSA_DELETE_CREDENTIAL */ DeleteCredential; PLSA_ALLOCATE_LSA_HEAP AllocateLsaHeap; PLSA_FREE_LSA_HEAP FreeLsaHeap; - PVOID /*PLSA_ALLOCATE_CLIENT_BUFFER */ AllocateClientBuffer; - PVOID /*PLSA_FREE_CLIENT_BUFFER */ FreeClientBuffer; + PLSA_ALLOCATE_CLIENT_BUFFER AllocateClientBuffer; + PLSA_FREE_CLIENT_BUFFER FreeClientBuffer; PVOID /*PLSA_COPY_TO_CLIENT_BUFFER */ CopyToClientBuffer; PVOID /*PLSA_COPY_FROM_CLIENT_BUFFER */ CopyFromClientBuffer; } LSA_DISPATCH_TABLE, *PLSA_DISPATCH_TABLE; @@ -34,23 +43,25 @@ typedef NTSTATUS (NTAPI *PLSA_AP_INITIALIZE_PACKAGE)(ULONG, PLSA_DISPATCH_TABLE, PLSA_STRING, PLSA_STRING, PLSA_STRING *); -typedef NTSTATUS (NTAPI *PLSA_AP_CALL_PACKAGE)(PUNICODE_STRING, PVOID, ULONG, - PVOID *, PULONG, PNTSTATUS); -typedef NTSTATUS (NTAPI *PLSA_AP_CALL_PACKAGE_PASSTHROUGH)(PUNICODE_STRING, +typedef NTSTATUS (NTAPI *PLSA_AP_CALL_PACKAGE_INTERNAL)(PLSA_CLIENT_REQUEST, PVOID, PVOID, + ULONG, PVOID *, PULONG, PNTSTATUS); +typedef NTSTATUS (NTAPI *PLSA_AP_CALL_PACKAGE_PASSTHROUGH)(PLSA_CLIENT_REQUEST, PVOID, PVOID, ULONG, PVOID *, PULONG, PNTSTATUS); -typedef NTSTATUS (NTAPI *PLSA_AP_CALL_PACKAGE_UNTRUSTED)(PVOID/*PLSA_CLIENT_REQUEST*/, +typedef NTSTATUS (NTAPI *PLSA_AP_CALL_PACKAGE_UNTRUSTED)(PLSA_CLIENT_REQUEST, PVOID, PVOID, ULONG, PVOID *, PULONG, PNTSTATUS); typedef VOID (NTAPI *PLSA_AP_LOGON_TERMINATED)(PLUID); -typedef NTSTATUS (NTAPI *PLSA_AP_LOGON_USER_EX2)(PVOID /*PLSA_CLIENT_REQUEST*/, +typedef NTSTATUS (NTAPI *PLSA_AP_LOGON_USER_EX2)(PLSA_CLIENT_REQUEST, SECURITY_LOGON_TYPE, PVOID, PVOID, ULONG, PVOID *, PULONG, PLUID, PNTSTATUS, - PVOID /*PLSA_TOKEN_INFORMATION_TYPE*/, PVOID *, PUNICODE_STRING *, PUNICODE_STRING *, + PLSA_TOKEN_INFORMATION_TYPE, PVOID *, PUNICODE_STRING *, PUNICODE_STRING *, PUNICODE_STRING *, PVOID /*PSECPKG_PRIMARY_CRED*/, PVOID /*PSECPKG_SUPPLEMENTAL_CRED_ARRAY **/); -typedef NTSTATUS (NTAPI *PLSA_AP_LOGON_USER_EX)(PVOID /*PLSA_CLIENT_REQUEST*/, +typedef NTSTATUS (NTAPI *PLSA_AP_LOGON_USER_EX)(PLSA_CLIENT_REQUEST, SECURITY_LOGON_TYPE, PVOID, PVOID, ULONG, PVOID *, PULONG, PLUID, PNTSTATUS, - PVOID /*PLSA_TOKEN_INFORMATION_TYPE*/, PVOID *, PUNICODE_STRING *, PUNICODE_STRING *, + PLSA_TOKEN_INFORMATION_TYPE, PVOID *, PUNICODE_STRING *, PUNICODE_STRING *, PUNICODE_STRING *); -typedef NTSTATUS (NTAPI *PLSA_AP_LOGON_USER)(LPWSTR, LPWSTR, LPWSTR, LPWSTR, - DWORD, DWORD, PHANDLE); + +typedef NTSTATUS (NTAPI *PLSA_AP_LOGON_USER_INTERNAL)(PLSA_CLIENT_REQUEST, SECURITY_LOGON_TYPE, + PVOID, PVOID, ULONG, PVOID *, PULONG, PLUID, PNTSTATUS, PLSA_TOKEN_INFORMATION_TYPE, + PVOID *, PUNICODE_STRING *, PUNICODE_STRING *); typedef struct _AUTH_PACKAGE { @@ -60,20 +71,22 @@ PVOID ModuleHandle; PLSA_AP_INITIALIZE_PACKAGE LsaApInitializePackage; - PLSA_AP_CALL_PACKAGE LsaApCallPackage; + PLSA_AP_CALL_PACKAGE_INTERNAL LsaApCallPackage; PLSA_AP_CALL_PACKAGE_PASSTHROUGH LsaApCallPackagePassthrough; PLSA_AP_CALL_PACKAGE_UNTRUSTED LsaApCallPackageUntrusted; PLSA_AP_LOGON_TERMINATED LsaApLogonTerminated; PLSA_AP_LOGON_USER_EX2 LsaApLogonUserEx2; PLSA_AP_LOGON_USER_EX LsaApLogonUserEx; - PLSA_AP_LOGON_USER LsaApLogonUser; + PLSA_AP_LOGON_USER_INTERNAL LsaApLogonUser; } AUTH_PACKAGE, *PAUTH_PACKAGE; + /* GLOBALS *****************************************************************/ static LIST_ENTRY PackageListHead; static ULONG PackageId; static LSA_DISPATCH_TABLE DispatchTable; + /* FUNCTIONS ***************************************************************/ @@ -243,19 +256,71 @@ static +PAUTH_PACKAGE +LsapGetAuthenticationPackage(IN ULONG PackageId) +{ + PLIST_ENTRY ListEntry; + PAUTH_PACKAGE Package; + + ListEntry = PackageListHead.Flink; + while (ListEntry != &PackageListHead) + { + Package = CONTAINING_RECORD(ListEntry, AUTH_PACKAGE, Entry); + + if (Package->Id == PackageId) + { + return Package; + } + + ListEntry = ListEntry->Flink; + } + + return NULL; +} + + +static PVOID NTAPI -LsapAllocateHeap(ULONG Size) -{ - return RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, Size); -} +LsapAllocateHeap(IN ULONG Length) +{ + return RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + Length); +} + static VOID NTAPI -LsapFreeHeap(PVOID Ptr) -{ - RtlFreeHeap(RtlGetProcessHeap(), 0, Ptr); +LsapFreeHeap(IN PVOID Base) +{ + RtlFreeHeap(RtlGetProcessHeap(), + 0, + Base); +} + + +static +NTSTATUS +NTAPI +LsapAllocateClientBuffer(IN PLSA_CLIENT_REQUEST ClientRequest, + IN ULONG LengthRequired, + OUT PVOID *ClientBaseAddress) +{ + FIXME("() stub\n"); + return STATUS_NOT_IMPLEMENTED; +} + + +static +NTSTATUS +NTAPI +LsapFreeClientBuffer(IN PLSA_CLIENT_REQUEST ClientRequest, + IN PVOID ClientBaseAddress) +{ + FIXME("() stub\n"); + return STATUS_NOT_IMPLEMENTED; } @@ -279,8 +344,8 @@ DispatchTable.DeleteCredential = NULL; DispatchTable.AllocateLsaHeap = &LsapAllocateHeap; DispatchTable.FreeLsaHeap = &LsapFreeHeap; - DispatchTable.AllocateClientBuffer = NULL; - DispatchTable.FreeClientBuffer = NULL; + DispatchTable.AllocateClientBuffer = &LsapAllocateClientBuffer; + DispatchTable.FreeClientBuffer = &LsapFreeClientBuffer; DispatchTable.CopyToClientBuffer = NULL; DispatchTable.CopyFromClientBuffer = NULL; @@ -297,21 +362,30 @@ NTSTATUS -LsapLookupAuthenticationPackageByName(IN PSTRING PackageName, - OUT PULONG PackageId) +LsapLookupAuthenticationPackage(PLSA_API_MSG RequestMsg, + PLSAP_LOGON_CONTEXT LogonContext) { PLIST_ENTRY ListEntry; PAUTH_PACKAGE Package; + ULONG PackageNameLength; + PCHAR PackageName; + + TRACE("(%p %p)\n", RequestMsg, LogonContext); + + PackageNameLength = RequestMsg->LookupAuthenticationPackage.Request.PackageNameLength; + PackageName = RequestMsg->LookupAuthenticationPackage.Request.PackageName; + + TRACE("PackageName: %s\n", PackageName); ListEntry = PackageListHead.Flink; while (ListEntry != &PackageListHead) { Package = CONTAINING_RECORD(ListEntry, AUTH_PACKAGE, Entry); - if ((PackageName->Length == Package->Name->Length) && - (_strnicmp(PackageName->Buffer, Package->Name->Buffer, Package->Name->Length) == 0)) + if ((PackageNameLength == Package->Name->Length) && + (_strnicmp(PackageName, Package->Name->Buffer, Package->Name->Length) == 0)) { - *PackageId = Package->Id; + RequestMsg->LookupAuthenticationPackage.Reply.Package = Package->Id; return STATUS_SUCCESS; } @@ -321,4 +395,143 @@ return STATUS_NO_SUCH_PACKAGE; } + +NTSTATUS +LsapCallAuthenticationPackage(PLSA_API_MSG RequestMsg, + PLSAP_LOGON_CONTEXT LogonContext) +{ + PAUTH_PACKAGE Package; + ULONG PackageId; + + NTSTATUS Status; + + TRACE("(%p %p)\n", RequestMsg, LogonContext); + + PackageId = RequestMsg->CallAuthenticationPackage.Request.AuthenticationPackage; + + Package = LsapGetAuthenticationPackage(PackageId); + if (Package == NULL) + { + TRACE("LsapGetAuthenticationPackage() failed to find a package\n"); + return STATUS_NO_SUCH_PACKAGE; + } + + Status = Package->LsaApCallPackage(NULL, /* FIXME: PLSA_CLIENT_REQUEST ClientRequest */ + RequestMsg->CallAuthenticationPackage.Request.ProtocolSubmitBuffer, + NULL, /* FIXME: PVOID ClientBufferBase */ + RequestMsg->CallAuthenticationPackage.Request.SubmitBufferLength, + &RequestMsg->CallAuthenticationPackage.Reply.ProtocolReturnBuffer, + &RequestMsg->CallAuthenticationPackage.Reply.ReturnBufferLength, + &RequestMsg->CallAuthenticationPackage.Reply.ProtocolStatus); + if (!NT_SUCCESS(Status)) + { + TRACE("Package->LsaApCallPackage() failed (Status 0x%08lx)\n", Status); + } + + return Status; +} + + +NTSTATUS +LsapLogonUser(PLSA_API_MSG RequestMsg, + PLSAP_LOGON_CONTEXT LogonContext) +{ + PAUTH_PACKAGE Package; + ULONG PackageId; + NTSTATUS Status; + + LSA_TOKEN_INFORMATION_TYPE TokenInformationType; + PVOID TokenInformation = NULL; + PUNICODE_STRING AccountName = NULL; + PUNICODE_STRING AuthenticatingAuthority = NULL; + PUNICODE_STRING MachineName = NULL; + + TRACE("(%p %p)\n", RequestMsg, LogonContext); + + PackageId = RequestMsg->LogonUser.Request.AuthenticationPackage; + + Package = LsapGetAuthenticationPackage(PackageId); + if (Package == NULL) + { + TRACE("LsapGetAuthenticationPackage() failed to find a package\n"); + return STATUS_NO_SUCH_PACKAGE; + } + + if (Package->LsaApLogonUserEx2 != NULL) + { + Status = Package->LsaApLogonUserEx2(NULL, /* FIXME: PLSA_CLIENT_REQUEST ClientRequest */ + RequestMsg->LogonUser.Request.LogonType, + RequestMsg->LogonUser.Request.AuthenticationInformation, + NULL, /* FIXME: PVOID ClientBufferBase*/ + RequestMsg->LogonUser.Request.AuthenticationInformationLength, + &RequestMsg->LogonUser.Reply.ProfileBuffer, + &RequestMsg->LogonUser.Reply.ProfileBufferLength, + &RequestMsg->LogonUser.Reply.LogonId, + &RequestMsg->LogonUser.Reply.SubStatus, + &TokenInformationType, + &TokenInformation, + &AccountName, + &AuthenticatingAuthority, + &MachineName, + NULL, /* FIXME: PSECPKG_PRIMARY_CRED PrimaryCredentials */ + NULL); /* FIXME: PSECPKG_SUPPLEMENTAL_CRED_ARRAY *SupplementalCredentials */ + } + else if (Package->LsaApLogonUserEx != NULL) + { + Status = Package->LsaApLogonUserEx(NULL, /* FIXME: PLSA_CLIENT_REQUEST ClientRequest */ + RequestMsg->LogonUser.Request.LogonType, + RequestMsg->LogonUser.Request.AuthenticationInformation, + NULL, /* FIXME: PVOID ClientBufferBase*/ + RequestMsg->LogonUser.Request.AuthenticationInformationLength, + &RequestMsg->LogonUser.Reply.ProfileBuffer, + &RequestMsg->LogonUser.Reply.ProfileBufferLength, + &RequestMsg->LogonUser.Reply.LogonId, + &RequestMsg->LogonUser.Reply.SubStatus, + &TokenInformationType, + &TokenInformation, + &AccountName, + &AuthenticatingAuthority, + &MachineName); + } + else + { + Status = Package->LsaApLogonUser(NULL, /* FIXME: PLSA_CLIENT_REQUEST ClientRequest */ + RequestMsg->LogonUser.Request.LogonType, + RequestMsg->LogonUser.Request.AuthenticationInformation, + NULL, /* FIXME: PVOID ClientBufferBase*/ + RequestMsg->LogonUser.Request.AuthenticationInformationLength, + &RequestMsg->LogonUser.Reply.ProfileBuffer, + &RequestMsg->LogonUser.Reply.ProfileBufferLength, + &RequestMsg->LogonUser.Reply.LogonId, + &RequestMsg->LogonUser.Reply.SubStatus, + &TokenInformationType, + &TokenInformation, + &AccountName, + &AuthenticatingAuthority); + } + + + if (TokenInformation != NULL) + { + + } + + if (AuthenticatingAuthority != NULL) + { + + } + + if (AccountName != NULL) + { + + } + + if (MachineName != NULL) + { + + } + + return Status; +} + /* EOF */ Modified: trunk/reactos/dll/win32/lsasrv/authport.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/authport.…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/authport.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/authport.c [iso-8859-1] Sat Mar 9 15:54:45 2013 @@ -14,14 +14,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(lsasrv); -typedef struct _LSAP_LOGON_CONTEXT -{ - LIST_ENTRY Entry; - HANDLE ClientProcessHandle; - HANDLE ConnectionHandle; -} LSAP_LOGON_CONTEXT, *PLSAP_LOGON_CONTEXT; - - static LIST_ENTRY LsapLogonContextList; static HANDLE PortThreadHandle = NULL; @@ -29,16 +21,6 @@ /* FUNCTIONS ***************************************************************/ - -static NTSTATUS -LsapCallAuthenticationPackage(PLSA_API_MSG RequestMsg, - PLSAP_LOGON_CONTEXT LogonContext) -{ - TRACE("(%p %p)\n", RequestMsg, LogonContext); - - return STATUS_SUCCESS; -} - static NTSTATUS LsapDeregisterLogonProcess(PLSA_API_MSG RequestMsg, @@ -54,106 +36,6 @@ RtlFreeHeap(RtlGetProcessHeap(), 0, LogonContext); return STATUS_SUCCESS; -} - - -static NTSTATUS -LsapLogonUser(PLSA_API_MSG RequestMsg, - PLSAP_LOGON_CONTEXT LogonContext) -{ - PVOID LocalAuthInfo = NULL; - NTSTATUS Status = STATUS_SUCCESS; - - TRACE("(%p %p)\n", RequestMsg, LogonContext); - - TRACE("LogonType: %lu\n", RequestMsg->LogonUser.Request.LogonType); - TRACE("AuthenticationPackage: 0x%08lx\n", RequestMsg->LogonUser.Request.AuthenticationPackage); - TRACE("AuthenticationInformation: %p\n", RequestMsg->LogonUser.Request.AuthenticationInformation); - TRACE("AuthenticationInformationLength: %lu\n", RequestMsg->LogonUser.Request.AuthenticationInformationLength); - - LocalAuthInfo = RtlAllocateHeap(RtlGetProcessHeap(), - HEAP_ZERO_MEMORY, - RequestMsg->LogonUser.Request.AuthenticationInformationLength); - if (LocalAuthInfo == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - goto done; - } - - /* Read the authentication info from the callers adress space */ - Status = NtReadVirtualMemory(LogonContext->ClientProcessHandle, - RequestMsg->LogonUser.Request.AuthenticationInformation, - LocalAuthInfo, - RequestMsg->LogonUser.Request.AuthenticationInformationLength, - NULL); - if (!NT_SUCCESS(Status)) - goto done; - - if (RequestMsg->LogonUser.Request.LogonType == Interactive || - RequestMsg->LogonUser.Request.LogonType == Batch || - RequestMsg->LogonUser.Request.LogonType == Service) - { - PMSV1_0_INTERACTIVE_LOGON LogonInfo; - ULONG_PTR PtrOffset; - - LogonInfo = (PMSV1_0_INTERACTIVE_LOGON)LocalAuthInfo; - - /* Fix-up pointers in the authentication info */ - PtrOffset = (ULONG_PTR)LocalAuthInfo - (ULONG_PTR)RequestMsg->LogonUser.Request.AuthenticationInformation; - - LogonInfo->LogonDomainName.Buffer = (PWSTR)((ULONG_PTR)LogonInfo->LogonDomainName.Buffer + PtrOffset); - LogonInfo->UserName.Buffer = (PWSTR)((ULONG_PTR)LogonInfo->UserName.Buffer + PtrOffset); - LogonInfo->Password.Buffer = (PWSTR)((ULONG_PTR)LogonInfo->Password.Buffer + PtrOffset); - - TRACE("Domain: %S\n", LogonInfo->LogonDomainName.Buffer); - TRACE("User: %S\n", LogonInfo->UserName.Buffer); - TRACE("Password: %S\n", LogonInfo->Password.Buffer); - } - else - { - FIXME("LogonType %lu is not supported yet!\n", RequestMsg->LogonUser.Request.LogonType); - } - - - - RequestMsg->LogonUser.Reply.ProfileBuffer = NULL; - RequestMsg->LogonUser.Reply.ProfileBufferLength = 0; -// LUID LogonId; - RequestMsg->LogonUser.Reply.Token = NULL; -// QUOTA_LIMITS Quotas; - RequestMsg->LogonUser.Reply.SubStatus = STATUS_SUCCESS; - -done: - if (LocalAuthInfo != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, LocalAuthInfo); - - return Status; -} - - -static NTSTATUS -LsapLookupAuthenticationPackage(PLSA_API_MSG RequestMsg, - PLSAP_LOGON_CONTEXT LogonContext) -{ - STRING PackageName; - ULONG PackageId; - NTSTATUS Status; - - TRACE("(%p %p)\n", RequestMsg, LogonContext); - TRACE("PackageName: %s\n", RequestMsg->LookupAuthenticationPackage.Request.PackageName); - - PackageName.Length = RequestMsg->LookupAuthenticationPackage.Request.PackageNameLength; - PackageName.MaximumLength = LSASS_MAX_PACKAGE_NAME_LENGTH + 1; - PackageName.Buffer = RequestMsg->LookupAuthenticationPackage.Request.PackageName; - - Status = LsapLookupAuthenticationPackageByName(&PackageName, - &PackageId); - if (NT_SUCCESS(Status)) - { - RequestMsg->LookupAuthenticationPackage.Reply.Package = PackageId; - } - - return Status; } Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.h?…
============================================================================== --- trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] Sat Mar 9 15:54:45 2013 @@ -69,6 +69,12 @@ DWORD AuditEvents[0]; } LSAP_POLICY_AUDIT_EVENTS_DATA, *PLSAP_POLICY_AUDIT_EVENTS_DATA; +typedef struct _LSAP_LOGON_CONTEXT +{ + LIST_ENTRY Entry; + HANDLE ClientProcessHandle; + HANDLE ConnectionHandle; +} LSAP_LOGON_CONTEXT, *PLSAP_LOGON_CONTEXT; extern SID_IDENTIFIER_AUTHORITY NullSidAuthority; extern SID_IDENTIFIER_AUTHORITY WorldSidAuthority; @@ -86,8 +92,16 @@ LsapInitAuthPackages(VOID); NTSTATUS -LsapLookupAuthenticationPackageByName(IN PSTRING PackageName, - OUT PULONG PackageId); +LsapLookupAuthenticationPackage(PLSA_API_MSG RequestMsg, + PLSAP_LOGON_CONTEXT LogonContext); + +NTSTATUS +LsapCallAuthenticationPackage(PLSA_API_MSG RequestMsg, + PLSAP_LOGON_CONTEXT LogonContext); + +NTSTATUS +LsapLogonUser(PLSA_API_MSG RequestMsg, + PLSAP_LOGON_CONTEXT LogonContext); /* authport.c */ NTSTATUS
11 years, 9 months
1
0
0
0
[spetreolle] 58450: [BOOTDATA] CurrentVersion, CSDVersion and CurrentBuildNumber are REG_SZ strings, not REG_EXPAND_SZ.
by spetreolle@svn.reactos.org
Author: spetreolle Date: Sat Mar 9 15:06:50 2013 New Revision: 58450 URL:
http://svn.reactos.org/svn/reactos?rev=58450&view=rev
Log: [BOOTDATA] CurrentVersion, CSDVersion and CurrentBuildNumber are REG_SZ strings, not REG_EXPAND_SZ. Modified: trunk/reactos/boot/bootdata/hivesft.inf Modified: trunk/reactos/boot/bootdata/hivesft.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesft.inf?…
============================================================================== --- trunk/reactos/boot/bootdata/hivesft.inf [iso-8859-1] (original) +++ trunk/reactos/boot/bootdata/hivesft.inf [iso-8859-1] Sat Mar 9 15:06:50 2013 @@ -121,9 +121,9 @@ HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",,0x00000012 ; Version Information -HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","CurrentVersion",0x00020000,"5.2" -HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","CSDVersion",0x00020000,"Service Pack 2" -HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","CurrentBuildNumber",0x00020000,"3790" +HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","CurrentVersion",0x00000000,"5.2" +HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","CSDVersion",0x00000000,"Service Pack 2" +HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","CurrentBuildNumber",0x00000000,"3790" HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","InstallDate",0x00010003,0 HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","ProductName",2,"ReactOS" HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","RegDone",0x00000002,""
11 years, 9 months
1
0
0
0
[hbelusca] 58449: [KERNEL32] Further correct 4 console winetests.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sat Mar 9 14:18:10 2013 New Revision: 58449 URL:
http://svn.reactos.org/svn/reactos?rev=58449&view=rev
Log: [KERNEL32] Further correct 4 console winetests. Modified: branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c Modified: branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1] Sat Mar 9 14:18:10 2013 @@ -501,12 +501,6 @@ PCSR_CAPTURE_BUFFER CaptureBuffer; DWORD Size; - if (lpBuffer == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - Size = nLength * sizeof(INPUT_RECORD); DPRINT("IntWriteConsoleInput: %lx %p\n", Size, lpNumberOfEventsWritten); @@ -583,6 +577,13 @@ SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } + /* + if (lpWriteRegion == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + */ Size = dwBufferSize.Y * dwBufferSize.X * sizeof(CHAR_INFO);
11 years, 9 months
1
0
0
0
[hbelusca] 58448: [CONSRV] Fix the initialization of screen buffers (concerning the cursor size). [KERNEL32] Fix almost all of the console winetests. Only 26 tests remain to be fixed, concerning pr...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sat Mar 9 01:39:49 2013 New Revision: 58448 URL:
http://svn.reactos.org/svn/reactos?rev=58448&view=rev
Log: [CONSRV] Fix the initialization of screen buffers (concerning the cursor size). [KERNEL32] Fix almost all of the console winetests. Only 26 tests remain to be fixed, concerning principally WriteConsoleInputA/W and GetNumberOfConsoleInputEvents. Modified: branches/ros-csrss/dll/win32/kernel32/client/console/console.c branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c branches/ros-csrss/win32ss/user/consrv/coninput.c branches/ros-csrss/win32ss/user/consrv/conio.h branches/ros-csrss/win32ss/user/consrv/conoutput.c branches/ros-csrss/win32ss/user/consrv/console.c branches/ros-csrss/win32ss/user/consrv/guiconsole.c branches/ros-csrss/win32ss/user/consrv/settings.c Modified: branches/ros-csrss/dll/win32/kernel32/client/console/console.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/console.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/console/console.c [iso-8859-1] Sat Mar 9 01:39:49 2013 @@ -776,7 +776,7 @@ return Ppb->StandardError; } - SetLastError(ERROR_INVALID_PARAMETER); + SetLastError(ERROR_INVALID_HANDLE); return INVALID_HANDLE_VALUE; } @@ -1050,14 +1050,10 @@ { NTSTATUS Status; CONSOLE_API_MESSAGE ApiMessage; - - if (lpNumberOfEvents == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - ApiMessage.Data.GetNumInputEventsRequest.InputHandle = hConsoleInput; + PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest = &ApiMessage.Data.GetNumInputEventsRequest; + + GetNumInputEventsRequest->InputHandle = hConsoleInput; + GetNumInputEventsRequest->NumInputEvents = 0; Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, NULL, @@ -1069,7 +1065,13 @@ return FALSE; } - *lpNumberOfEvents = ApiMessage.Data.GetNumInputEventsRequest.NumInputEvents; + if (lpNumberOfEvents == NULL) + { + SetLastError(ERROR_INVALID_ACCESS); + return FALSE; + } + + *lpNumberOfEvents = GetNumInputEventsRequest->NumInputEvents; return TRUE; } Modified: branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1] Sat Mar 9 01:39:49 2013 @@ -264,7 +264,7 @@ sizeof(CONSOLE_READOUTPUT)); DPRINT("Server returned: %x\n", ApiMessage.Status); - /* Check for success*/ + /* Check for success */ if (NT_SUCCESS(ApiMessage.Status)) { /* Copy into the buffer */ @@ -305,6 +305,7 @@ LPDWORD lpNumberOfCodesRead) { NTSTATUS Status; + BOOL bRet = TRUE; CONSOLE_API_MESSAGE ApiMessage; PCONSOLE_READOUTPUTCODE ReadOutputCodeRequest = &ApiMessage.Data.ReadOutputCodeRequest; PCSR_CAPTURE_BUFFER CaptureBuffer; @@ -353,28 +354,38 @@ ReadOutputCodeRequest->NumCodesToRead = nLength; + /* Call the server */ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepReadConsoleOutputString), sizeof(CONSOLE_READOUTPUTCODE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) - { - BaseSetLastNTError(Status); - CsrFreeCaptureBuffer(CaptureBuffer); - return FALSE; - } - - BytesRead = ReadOutputCodeRequest->CodesRead * CodeSize; - memcpy(pCode, ReadOutputCodeRequest->pCode.pCode, BytesRead); - - ReadOutputCodeRequest->ReadCoord = ReadOutputCodeRequest->EndCoord; - - if (lpNumberOfCodesRead != NULL) - *lpNumberOfCodesRead = ReadOutputCodeRequest->CodesRead; + + /* Check for success */ + if (NT_SUCCESS(Status) || NT_SUCCESS(Status = ApiMessage.Status)) + { + BytesRead = ReadOutputCodeRequest->CodesRead * CodeSize; + memcpy(pCode, ReadOutputCodeRequest->pCode.pCode, BytesRead); + + // ReadOutputCodeRequest->ReadCoord = ReadOutputCodeRequest->EndCoord; + + if (lpNumberOfCodesRead != NULL) + *lpNumberOfCodesRead = ReadOutputCodeRequest->CodesRead; + + bRet = TRUE; + } + else + { + if (lpNumberOfCodesRead != NULL) + *lpNumberOfCodesRead = 0; + + /* Error out */ + BaseSetLastNTError(Status /* ApiMessage.Status */); + bRet = FALSE; + } CsrFreeCaptureBuffer(CaptureBuffer); - return TRUE; + return bRet; } @@ -392,6 +403,7 @@ BOOL bUnicode) { NTSTATUS Status; + BOOL bRet = TRUE; CONSOLE_API_MESSAGE ApiMessage; PCONSOLE_WRITECONSOLE WriteConsoleRequest = &ApiMessage.Data.WriteConsoleRequest; PCSR_CAPTURE_BUFFER CaptureBuffer; @@ -423,48 +435,56 @@ WriteConsoleRequest->OutputHandle = hConsoleOutput; WriteConsoleRequest->Unicode = bUnicode; - // while (nNumberOfCharsToWrite > 0) - { - //// nChars = (USHORT)min(nNumberOfCharsToWrite, CSRSS_MAX_WRITE_CONSOLE / CharSize); - // nChars = nNumberOfCharsToWrite; - // WriteConsoleRequest->NrCharactersToWrite = nChars; - - // SizeBytes = nChars * CharSize; - - // memcpy(WriteConsoleRequest->Buffer, lpBuffer, SizeBytes); - - Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, - CaptureBuffer, - CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepWriteConsole), - sizeof(CONSOLE_WRITECONSOLE)); + // while (nNumberOfCharsToWrite > 0) { + //// nChars = (USHORT)min(nNumberOfCharsToWrite, CSRSS_MAX_WRITE_CONSOLE / CharSize); + // nChars = nNumberOfCharsToWrite; + // WriteConsoleRequest->NrCharactersToWrite = nChars; + + // SizeBytes = nChars * CharSize; + + // memcpy(WriteConsoleRequest->Buffer, lpBuffer, SizeBytes); + + /* Call the server */ + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepWriteConsole), + sizeof(CONSOLE_WRITECONSOLE)); /** FIXME: Added in 47359 for pausing - if (Status == STATUS_PENDING) - { - WaitForSingleObject(WriteConsoleRequest->UnpauseEvent, INFINITE); - CloseHandle(WriteConsoleRequest->UnpauseEvent); - continue; - } + if (Status == STATUS_PENDING) + { + WaitForSingleObject(WriteConsoleRequest->UnpauseEvent, INFINITE); + CloseHandle(WriteConsoleRequest->UnpauseEvent); + continue; + } **/ - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) - { - CsrFreeCaptureBuffer(CaptureBuffer); - BaseSetLastNTError(Status); - return FALSE; - } - + /* Check for success */ + if (NT_SUCCESS(Status) || NT_SUCCESS(Status = ApiMessage.Status)) + { // nNumberOfCharsToWrite -= nChars; // lpBuffer = (PVOID)((ULONG_PTR)lpBuffer + (ULONG_PTR)SizeBytes); // Written += WriteConsoleRequest->NrCharactersWritten; - } - - if (lpNumberOfCharsWritten != NULL) - // *lpNumberOfCharsWritten = Written; - *lpNumberOfCharsWritten = WriteConsoleRequest->NrCharactersWritten; + // } + + if (lpNumberOfCharsWritten != NULL) + // *lpNumberOfCharsWritten = Written; + *lpNumberOfCharsWritten = WriteConsoleRequest->NrCharactersWritten; + + bRet = TRUE; + } + else + { + if (lpNumberOfCharsWritten != NULL) + *lpNumberOfCharsWritten = 0; + + /* Error out */ + BaseSetLastNTError(Status /* ApiMessage.Status */); + bRet = FALSE; + } CsrFreeCaptureBuffer(CaptureBuffer); - return TRUE; + return bRet; } @@ -518,7 +538,7 @@ sizeof(CONSOLE_WRITEINPUT)); DPRINT("Server returned: %x\n", ApiMessage.Status); - /* Check for success*/ + /* Check for success */ if (NT_SUCCESS(ApiMessage.Status)) { /* Return the number of events read */ @@ -597,7 +617,7 @@ sizeof(CONSOLE_WRITEOUTPUT)); DPRINT("Server returned: %x\n", ApiMessage.Status); - /* Check for success*/ + /* Check for success */ if (!NT_SUCCESS(ApiMessage.Status)) { /* Error out */ @@ -626,6 +646,7 @@ LPDWORD lpNumberOfCodesWritten) { NTSTATUS Status; + BOOL bRet = TRUE; CONSOLE_API_MESSAGE ApiMessage; PCONSOLE_WRITEOUTPUTCODE WriteOutputCodeRequest = &ApiMessage.Data.WriteOutputCodeRequest; PCSR_CAPTURE_BUFFER CaptureBuffer; @@ -685,44 +706,46 @@ WriteOutputCodeRequest->CodeType = CodeType; WriteOutputCodeRequest->Coord = dwWriteCoord; - /** - ** TODO: HACK: Surely it has to go into CONSRV !! - **/ - // while (nLength > 0) - { - // DWORD BytesWrite; - - WriteOutputCodeRequest->Length = nLength; // (WORD)min(nLength, nChars); - // BytesWrite = WriteOutputCodeRequest->Length * CodeSize; - - // memcpy(WriteOutputCodeRequest->pCode.pCode, pCode, BytesWrite); - - Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, - CaptureBuffer, - CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepWriteConsoleOutputString), - sizeof(CONSOLE_WRITEOUTPUTCODE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) - { - CsrFreeCaptureBuffer(CaptureBuffer); - BaseSetLastNTError(Status); - return FALSE; - } - + WriteOutputCodeRequest->Length = nLength; // (WORD)min(nLength, nChars); + // BytesWrite = WriteOutputCodeRequest->Length * CodeSize; + + // memcpy(WriteOutputCodeRequest->pCode.pCode, pCode, BytesWrite); + + /* Call the server */ + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepWriteConsoleOutputString), + sizeof(CONSOLE_WRITEOUTPUTCODE)); + + /* Check for success */ + if (NT_SUCCESS(Status) || NT_SUCCESS(Status = ApiMessage.Status)) + { // nLength -= WriteOutputCodeRequest->NrCharactersWritten; // pCode = (PVOID)((ULONG_PTR)pCode + /*(ULONG_PTR)(*/WriteOutputCodeRequest->NrCharactersWritten * CodeSize/*)*/); // Written += WriteOutputCodeRequest->NrCharactersWritten; - WriteOutputCodeRequest->Coord = WriteOutputCodeRequest->EndCoord; - } - - if (lpNumberOfCodesWritten != NULL) - // *lpNumberOfCodesWritten = Written; - // *lpNumberOfCodesWritten = WriteOutputCodeRequest->NrCharactersWritten; - *lpNumberOfCodesWritten = WriteOutputCodeRequest->Length; + // WriteOutputCodeRequest->Coord = WriteOutputCodeRequest->EndCoord; + + if (lpNumberOfCodesWritten != NULL) + // *lpNumberOfCodesWritten = Written; + // *lpNumberOfCodesWritten = WriteOutputCodeRequest->NrCharactersWritten; + *lpNumberOfCodesWritten = WriteOutputCodeRequest->Length; + + bRet = TRUE; + } + else + { + if (lpNumberOfCodesWritten != NULL) + *lpNumberOfCodesWritten = 0; + + /* Error out */ + BaseSetLastNTError(Status /* ApiMessage.Status */); + bRet = FALSE; + } CsrFreeCaptureBuffer(CaptureBuffer); - return TRUE; + return bRet; } @@ -761,24 +784,33 @@ return FALSE; } + /* Set up the data to send to the Console Server */ FillOutputRequest->Coord = dwWriteCoord; FillOutputRequest->Length = nLength; + /* Call the server */ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, NULL, CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepFillConsoleOutput), sizeof(CONSOLE_FILLOUTPUTCODE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) - { + + /* Check for success */ + if (NT_SUCCESS(ApiMessage.Status)) + { + if (lpNumberOfCodesWritten != NULL) + *lpNumberOfCodesWritten = FillOutputRequest->Length; + // *lpNumberOfCodesWritten = Request.Data.FillOutputRequest.NrCharactersWritten; + + return TRUE; + } + else + { + if (lpNumberOfCodesWritten != NULL) + *lpNumberOfCodesWritten = 0; + BaseSetLastNTError(Status); return FALSE; } - - if (lpNumberOfCodesWritten) - *lpNumberOfCodesWritten = FillOutputRequest->Length; - // *lpNumberOfCodesWritten = Request.Data.FillOutputRequest.NrCharactersWritten; - - return TRUE; } Modified: branches/ros-csrss/win32ss/user/consrv/coninput.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/coninput.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/coninput.c [iso-8859-1] Sat Mar 9 01:39:49 2013 @@ -857,7 +857,7 @@ if (!NT_SUCCESS(Status)) return Status; CurrentInput = InputBuffer->InputEvents.Flink; - NumEvents = 0; + /* GetNumInputEventsRequest->NumInputEvents = */ NumEvents = 0; /* If there are any events ... */ while (CurrentInput != &InputBuffer->InputEvents) Modified: branches/ros-csrss/win32ss/user/consrv/conio.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/conio.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/conio.h [iso-8859-1] Sat Mar 9 01:39:49 2013 @@ -275,7 +275,9 @@ OUT PCONSOLE_SCREEN_BUFFER* Buffer, IN COORD ScreenBufferSize, IN USHORT ScreenAttrib, - IN USHORT PopupAttrib); + IN USHORT PopupAttrib, + IN BOOLEAN IsCursorVisible, + IN ULONG CursorSize); VOID WINAPI ConioDeleteScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer); DWORD FASTCALL ConioEffectiveCursorSize(PCONSOLE Console, DWORD Scale); Modified: branches/ros-csrss/win32ss/user/consrv/conoutput.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] Sat Mar 9 01:39:49 2013 @@ -64,7 +64,9 @@ OUT PCONSOLE_SCREEN_BUFFER* Buffer, IN COORD ScreenBufferSize, IN USHORT ScreenAttrib, - IN USHORT PopupAttrib) + IN USHORT PopupAttrib, + IN BOOLEAN IsCursorVisible, + IN ULONG CursorSize) { if (Console == NULL || Buffer == NULL) return STATUS_INVALID_PARAMETER; @@ -91,9 +93,8 @@ (*Buffer)->ShowY = 0; (*Buffer)->VirtualY = 0; - // FIXME: !! - (*Buffer)->CursorInfo.bVisible = TRUE; - // (*Buffer)->CursorInfo.dwSize = ConsoleInfo->CursorSize; + (*Buffer)->CursorInfo.bVisible = (IsCursorVisible && (CursorSize > 0)); + (*Buffer)->CursorInfo.dwSize = min(max(CursorSize, 1), 100); (*Buffer)->ScreenDefaultAttrib = ScreenAttrib; (*Buffer)->PopupDefaultAttrib = PopupAttrib; @@ -1035,8 +1036,8 @@ ConioDrawRegion(Console, &UpdateRect); } - WriteOutputCodeRequest->EndCoord.X = X; - WriteOutputCodeRequest->EndCoord.Y = (Y + Buff->ScreenBufferSize.Y - Buff->VirtualY) % Buff->ScreenBufferSize.Y; + // WriteOutputCodeRequest->EndCoord.X = X; + // WriteOutputCodeRequest->EndCoord.Y = (Y + Buff->ScreenBufferSize.Y - Buff->VirtualY) % Buff->ScreenBufferSize.Y; } if (tmpString) @@ -1269,9 +1270,11 @@ PCONSOLE Console; PCONSOLE_SCREEN_BUFFER Buff; - COORD ScreenBufferSize = (COORD){80, 25}; - USHORT ScreenAttrib = DEFAULT_SCREEN_ATTRIB; - USHORT PopupAttrib = DEFAULT_POPUP_ATTRIB; + COORD ScreenBufferSize = (COORD){80, 25}; + USHORT ScreenAttrib = DEFAULT_SCREEN_ATTRIB; + USHORT PopupAttrib = DEFAULT_POPUP_ATTRIB; + BOOLEAN IsCursorVisible = TRUE; + ULONG CursorSize = CSR_DEFAULT_CURSOR_SIZE; DPRINT("SrvCreateConsoleScreenBuffer\n"); @@ -1292,20 +1295,18 @@ ScreenAttrib = Console->ActiveBuffer->ScreenDefaultAttrib; PopupAttrib = Console->ActiveBuffer->PopupDefaultAttrib; - // Buff->CursorInfo.bVisible = Console->ActiveBuffer->CursorInfo.bVisible; - // Buff->CursorInfo.dwSize = Console->ActiveBuffer->CursorInfo.dwSize; - } - // else - // { - // Buff->CursorInfo.bVisible = TRUE; - // Buff->CursorInfo.dwSize = CSR_DEFAULT_CURSOR_SIZE; - // } + + IsCursorVisible = Console->ActiveBuffer->CursorInfo.bVisible; + CursorSize = Console->ActiveBuffer->CursorInfo.dwSize; + } Status = ConSrvCreateScreenBuffer(Console, &Buff, ScreenBufferSize, ScreenAttrib, - PopupAttrib); + PopupAttrib, + IsCursorVisible, + CursorSize); if (NT_SUCCESS(Status)) { Status = ConSrvInsertObject(ProcessData, Modified: branches/ros-csrss/win32ss/user/consrv/console.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/console.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/console.c [iso-8859-1] Sat Mar 9 01:39:49 2013 @@ -365,7 +365,9 @@ &NewBuffer, ConsoleInfo.ScreenBufferSize, ConsoleInfo.ScreenAttrib, - ConsoleInfo.PopupAttrib); + ConsoleInfo.PopupAttrib, + TRUE, + ConsoleInfo.CursorSize); if (!NT_SUCCESS(Status)) { DPRINT1("ConSrvCreateScreenBuffer: failed, Status = 0x%08lx\n", Status); Modified: branches/ros-csrss/win32ss/user/consrv/guiconsole.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/g…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/guiconsole.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/guiconsole.c [iso-8859-1] Sat Mar 9 01:39:49 2013 @@ -464,7 +464,8 @@ memcpy(Console->Colors, pConInfo->ci.Colors, sizeof(s_Colors)); // FIXME: Possible buffer overflow if s_colors is bigger than pConInfo->Colors. /* Apply cursor size */ - ActiveBuffer->CursorInfo.dwSize = min(max(pConInfo->ci.CursorSize, 1), 100); + ActiveBuffer->CursorInfo.bVisible = (pConInfo->ci.CursorSize > 0); + ActiveBuffer->CursorInfo.dwSize = min(max(pConInfo->ci.CursorSize, 1), 100); if (pConInfo->ci.ConsoleSize.X != Console->Size.X || pConInfo->ci.ConsoleSize.Y != Console->Size.Y) Modified: branches/ros-csrss/win32ss/user/consrv/settings.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/s…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/settings.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/settings.c [iso-8859-1] Sat Mar 9 01:39:49 2013 @@ -446,7 +446,7 @@ ConsoleInfo->CursorBlinkOn; ConsoleInfo->ForceCursorOff; - ConsoleInfo->CursorSize = CSR_DEFAULT_CURSOR_SIZE; // 0; #define SMALL_SIZE 25 // large enough to be one pixel on a six pixel font + ConsoleInfo->CursorSize = CSR_DEFAULT_CURSOR_SIZE; // #define SMALL_SIZE 25 ConsoleInfo->ScreenAttrib = DEFAULT_SCREEN_ATTRIB; ConsoleInfo->PopupAttrib = DEFAULT_POPUP_ATTRIB; @@ -473,13 +473,6 @@ ConsoleInfo->u.GuiInfo.AutoPosition = TRUE; ConsoleInfo->u.GuiInfo.WindowOrigin = (POINT){0, 0}; - // if (Console->ActiveBuffer) - // { - // Console->ActiveBuffer->ScreenBufferSize.X = 80; - // Console->ActiveBuffer->ScreenBufferSize.Y = 300; - // Console->ActiveBuffer->CursorInfo.bVisible = TRUE; - // } - /* * 2. Overwrite them with the ones stored in HKCU\Console. * If the HKCU\Console key doesn't exist, create it
11 years, 9 months
1
0
0
0
[hbelusca] 58447: [CONSRV] - Start to sort out things that depends only of the internals of a console, and things which are only related to "terminal emulators". Do it especially for (what I will c...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Mar 8 23:37:11 2013 New Revision: 58447 URL:
http://svn.reactos.org/svn/reactos?rev=58447&view=rev
Log: [CONSRV] - Start to sort out things that depends only of the internals of a console, and things which are only related to "terminal emulators". Do it especially for (what I will call starting from now) the "GUI terminal emulator". - Temporarily deactivate starting "TUI terminals". - Temporarily break report that the terminal window is held by the current running console application in it (see r58107). This will be fixed later on. Modified: branches/ros-csrss/win32ss/user/consrv/conio.h branches/ros-csrss/win32ss/user/consrv/conoutput.c branches/ros-csrss/win32ss/user/consrv/console.c branches/ros-csrss/win32ss/user/consrv/guiconsole.c branches/ros-csrss/win32ss/user/consrv/guiconsole.h branches/ros-csrss/win32ss/user/consrv/handle.c branches/ros-csrss/win32ss/user/consrv/settings.h branches/ros-csrss/win32ss/user/consrv/tuiconsole.c branches/ros-csrss/win32ss/user/consrv/tuiconsole.h Modified: branches/ros-csrss/win32ss/user/consrv/conio.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/conio.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/conio.h [iso-8859-1] Fri Mar 8 23:37:11 2013 @@ -15,14 +15,6 @@ #define DEFAULT_SCREEN_ATTRIB (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED) #define DEFAULT_POPUP_ATTRIB (FOREGROUND_BLUE | FOREGROUND_RED | \ BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY) - -#ifndef WM_APP -#define WM_APP 0x8000 -#endif -#define PM_CREATE_CONSOLE (WM_APP + 1) -#define PM_DESTROY_CONSOLE (WM_APP + 2) -#define PM_CONSOLE_BEEP (WM_APP + 3) -#define PM_CONSOLE_SET_TITLE (WM_APP + 4) /************************************************************************ @@ -82,16 +74,81 @@ INPUT_RECORD InputEvent; } ConsoleInput; +typedef struct _TERMINAL_VTBL +{ + /* + * Internal interface (functions called by the console server only) + */ + VOID (WINAPI *CleanupConsole)(struct _CONSOLE* Console); + VOID (WINAPI *WriteStream)(struct _CONSOLE* Console, + SMALL_RECT* Block, + LONG CursorStartX, + LONG CursorStartY, + UINT ScrolledLines, + CHAR *Buffer, + UINT Length); + VOID (WINAPI *DrawRegion)(struct _CONSOLE* Console, + SMALL_RECT* Region); + BOOL (WINAPI *SetCursorInfo)(struct _CONSOLE* Console, + PCONSOLE_SCREEN_BUFFER ScreenBuffer); + BOOL (WINAPI *SetScreenInfo)(struct _CONSOLE* Console, + PCONSOLE_SCREEN_BUFFER ScreenBuffer, + UINT OldCursorX, + UINT OldCursorY); + BOOL (WINAPI *UpdateScreenInfo)(struct _CONSOLE* Console, + PCONSOLE_SCREEN_BUFFER ScreenBuffer); + NTSTATUS (WINAPI *ResizeBuffer)(struct _CONSOLE* Console, + PCONSOLE_SCREEN_BUFFER ScreenBuffer, + COORD Size); + BOOL (WINAPI *ProcessKeyCallback)(struct _CONSOLE* Console, + MSG* msg, + BYTE KeyStateMenu, + DWORD ShiftState, + UINT VirtualKeyCode, + BOOL Down); + + /* + * External interface (functions corresponding to the Console API) + */ + VOID (WINAPI *ChangeTitle)(struct _CONSOLE* Console); + BOOL (WINAPI *ChangeIcon)(struct _CONSOLE* Console, + HICON hWindowIcon); + HWND (WINAPI *GetConsoleWindowHandle)(struct _CONSOLE* Console); + +} TERMINAL_VTBL, *PTERMINAL_VTBL; + +#define ConioDrawRegion(Console, Region) (Console)->TermIFace.Vtbl->DrawRegion((Console), (Region)) +#define ConioWriteStream(Console, Block, CurStartX, CurStartY, ScrolledLines, Buffer, Length) \ + (Console)->TermIFace.Vtbl->WriteStream((Console), (Block), (CurStartX), (CurStartY), \ + (ScrolledLines), (Buffer), (Length)) +#define ConioSetCursorInfo(Console, Buff) (Console)->TermIFace.Vtbl->SetCursorInfo((Console), (Buff)) +#define ConioSetScreenInfo(Console, Buff, OldCursorX, OldCursorY) \ + (Console)->TermIFace.Vtbl->SetScreenInfo((Console), (Buff), (OldCursorX), (OldCursorY)) +#define ConioUpdateScreenInfo(Console, Buff) \ + (Console)->TermIFace.Vtbl->UpdateScreenInfo((Console), (Buff)) +#define ConioChangeTitle(Console) (Console)->TermIFace.Vtbl->ChangeTitle(Console) +#define ConioCleanupConsole(Console) (Console)->TermIFace.Vtbl->CleanupConsole(Console) +#define ConioChangeIcon(Console, hWindowIcon) (Console)->TermIFace.Vtbl->ChangeIcon((Console), (hWindowIcon)) +#define ConioResizeBuffer(Console, Buff, Size) (Console)->TermIFace.Vtbl->ResizeBuffer((Console), (Buff), (Size)) +#define ConioProcessKeyCallback(Console, Msg, KeyStateMenu, ShiftState, VirtualKeyCode, Down) \ + (Console)->TermIFace.Vtbl->ProcessKeyCallback((Console), (Msg), (KeyStateMenu), (ShiftState), (VirtualKeyCode), (Down)) + +typedef struct _TERMINAL_IFACE +{ + PTERMINAL_VTBL Vtbl; /* Virtual table */ + PVOID Data; /* Private data */ + PVOID OldData; /* Reserved */ +} TERMINAL_IFACE, *PTERMINAL_IFACE; + typedef struct _CONSOLE { LONG ReferenceCount; /* Is incremented each time a handle to a screen-buffer or the input buffer of this console gets referenced, or the console gets locked */ CRITICAL_SECTION Lock; struct _CONSOLE *Prev, *Next; /* Next and Prev consoles in console wheel */ - struct _CONSOLE_VTBL *Vtbl; /* Using CUI or GUI consoles */ - - CLIENT_ID ConsoleLeaderCID; /* Contains the Console Leader Process CID for this console. TODO: Is it possible to compute it via the contents of the ProcessList list ?? */ - LIST_ENTRY ProcessList; + LIST_ENTRY ProcessList; /* List of processes owning the console. The first one is the so-called "Console Leader Process" */ + + TERMINAL_IFACE TermIFace; /* Terminal-specific interface */ /**************************** Input buffer and data ***************************/ CONSOLE_INPUT_BUFFER InputBuffer; /* Input buffer of the console */ @@ -129,18 +186,12 @@ ULONG NumberOfHistoryBuffers; /* Maximum number of history buffers allowed */ BOOLEAN HistoryNoDup; /* Remove old duplicate history entries */ -/******************************* Common UI data *******************************/ - UNICODE_STRING OriginalTitle; /* Original title of console, the one when the console leader is launched. It is always NULL-terminated */ - UNICODE_STRING Title; /* Title of console. It is always NULL-terminated */ +/****************************** Other properties ******************************/ + UNICODE_STRING OriginalTitle; /* Original title of console, the one when the console leader is launched. Always NULL-terminated */ + UNICODE_STRING Title; /* Title of console. Always NULL-terminated */ COORD Size; /* Size of the console (different of the size of the screen buffer */ COLORREF Colors[16]; /* Colour palette */ - -/****************************** GUI-related data ******************************/ - HWND hWindow; /* Handle to the console's window */ - HICON hIcon; /* Handle to its icon (used when freeing) */ - HICON hIconSm; - PVOID GuiData; /* PGUI_CONSOLE_DATA */ } CONSOLE, *PCONSOLE; @@ -150,28 +201,18 @@ #define GWLP_CONSOLE_LEADER_PID 0 #define GWLP_CONSOLE_LEADER_TID 4 -#define SetConsoleWndConsoleLeaderCID(Console) \ -do { \ - SetWindowLongPtrW((Console)->hWindow, GWLP_CONSOLE_LEADER_PID, (LONG_PTR)((Console)->ConsoleLeaderCID.UniqueProcess)); \ - SetWindowLongPtrW((Console)->hWindow, GWLP_CONSOLE_LEADER_TID, (LONG_PTR)((Console)->ConsoleLeaderCID.UniqueThread )); \ +#define SetConsoleWndConsoleLeaderCID(GuiData) \ +do { \ + PCONSOLE_PROCESS_DATA ProcessData; \ + CLIENT_ID ConsoleLeaderCID; \ + ProcessData = CONTAINING_RECORD((GuiData)->Console->ProcessList.Blink, \ + CONSOLE_PROCESS_DATA, \ + ConsoleLink); \ + ConsoleLeaderCID = ProcessData->Process->ClientId; \ + SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_PID, (LONG_PTR)(ConsoleLeaderCID.UniqueProcess)); \ + SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_TID, (LONG_PTR)(ConsoleLeaderCID.UniqueThread )); \ } while(0) /**************************************************************/ - -typedef struct _CONSOLE_VTBL -{ - VOID (WINAPI *WriteStream)(PCONSOLE Console, SMALL_RECT* Block, LONG CursorStartX, LONG CursorStartY, - UINT ScrolledLines, CHAR *Buffer, UINT Length); - VOID (WINAPI *DrawRegion)(PCONSOLE Console, SMALL_RECT* Region); - BOOL (WINAPI *SetCursorInfo)(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer); - BOOL (WINAPI *SetScreenInfo)(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer, - UINT OldCursorX, UINT OldCursorY); - BOOL (WINAPI *UpdateScreenInfo)(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer); - VOID (WINAPI *ChangeTitle)(PCONSOLE Console); - VOID (WINAPI *CleanupConsole)(PCONSOLE Console); - BOOL (WINAPI *ChangeIcon)(PCONSOLE Console, HICON hWindowIcon); - NTSTATUS (WINAPI *ResizeBuffer)(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer, COORD Size); - BOOL (WINAPI *ProcessKeyCallback)(PCONSOLE Console, MSG* msg, BYTE KeyStateMenu, DWORD ShiftState, UINT VirtualKeyCode, BOOL Down); -} CONSOLE_VTBL, *PCONSOLE_VTBL; /* CONSOLE_SELECTION_INFO dwFlags values */ #define CONSOLE_NO_SELECTION 0x0 @@ -179,6 +220,7 @@ #define CONSOLE_SELECTION_NOT_EMPTY 0x2 #define CONSOLE_MOUSE_SELECTION 0x4 #define CONSOLE_MOUSE_DOWN 0x8 + /* HistoryFlags values */ #define HISTORY_NO_DUP_FLAG 0x1 @@ -186,21 +228,6 @@ #define PAUSED_FROM_KEYBOARD 0x1 #define PAUSED_FROM_SCROLLBAR 0x2 #define PAUSED_FROM_SELECTION 0x4 - -#define ConioDrawRegion(Console, Region) (Console)->Vtbl->DrawRegion((Console), (Region)) -#define ConioWriteStream(Console, Block, CurStartX, CurStartY, ScrolledLines, Buffer, Length) \ - (Console)->Vtbl->WriteStream((Console), (Block), (CurStartX), (CurStartY), \ - (ScrolledLines), (Buffer), (Length)) -#define ConioSetCursorInfo(Console, Buff) (Console)->Vtbl->SetCursorInfo((Console), (Buff)) -#define ConioSetScreenInfo(Console, Buff, OldCursorX, OldCursorY) \ - (Console)->Vtbl->SetScreenInfo((Console), (Buff), (OldCursorX), (OldCursorY)) -#define ConioUpdateScreenInfo(Console, Buff) \ - (Console)->Vtbl->UpdateScreenInfo((Console), (Buff)) -#define ConioChangeTitle(Console) (Console)->Vtbl->ChangeTitle(Console) -#define ConioCleanupConsole(Console) (Console)->Vtbl->CleanupConsole(Console) -#define ConioChangeIcon(Console, hWindowIcon) (Console)->Vtbl->ChangeIcon((Console), (hWindowIcon)) -#define ConioResizeBuffer(Console, Buff, Size) (Console)->Vtbl->ResizeBuffer((Console), (Buff), (Size)) -#define ConioProcessKeyCallback(Console, Msg, KeyStateMenu, ShiftState, VirtualKeyCode, Down) (Console)->Vtbl->ProcessKeyCallback((Console), (Msg), (KeyStateMenu), (ShiftState), (VirtualKeyCode), (Down)) /* console.c */ VOID WINAPI ConSrvDeleteConsole(PCONSOLE Console); Modified: branches/ros-csrss/win32ss/user/consrv/conoutput.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] Fri Mar 8 23:37:11 2013 @@ -231,8 +231,9 @@ /* --- BEL ---*/ else if (Buffer[i] == '\a') { + // FIXME: This MUST BE moved to the terminal emulator!! DPRINT1("Bell\n"); - SendNotifyMessage(Console->hWindow, PM_CONSOLE_BEEP, 0, 0); + // SendNotifyMessage(Console->hWindow, PM_CONSOLE_BEEP, 0, 0); continue; } } Modified: branches/ros-csrss/win32ss/user/consrv/console.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/console.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/console.c [iso-8859-1] Fri Mar 8 23:37:11 2013 @@ -14,7 +14,10 @@ #include "consrv.h" #include "settings.h" #include "guiconsole.h" -#include "tuiconsole.h" + +#ifdef TUI_CONSOLE + #include "tuiconsole.h" +#endif #include <shlwapi.h> #include <shlobj.h> @@ -324,7 +327,6 @@ */ InitializeCriticalSection(&Console->Lock); Console->ReferenceCount = 0; - Console->ConsoleLeaderCID = ConsoleLeaderProcess->ClientId; InitializeListHead(&Console->ProcessList); memcpy(Console->Colors, ConsoleInfo.Colors, sizeof(ConsoleInfo.Colors)); Console->Size = ConsoleInfo.ConsoleSize; @@ -385,10 +387,6 @@ Console->NumberOfHistoryBuffers = ConsoleInfo.NumberOfHistoryBuffers; Console->HistoryNoDup = ConsoleInfo.HistoryNoDup; - /* Finish initialization */ - Console->GuiData = NULL; - Console->hIcon = Console->hIconSm = NULL; - /* Initialize the console title */ RtlCreateUnicodeString(&Console->OriginalTitle, ConsoleStartInfo->ConsoleTitle); if (ConsoleStartInfo->ConsoleTitle[0] == L'\0') @@ -408,35 +406,41 @@ } /* - * If we are not in GUI-mode, start the text-mode console. - * If we fail, try to start the GUI-mode console. + * If we are not in GUI-mode, start the text-mode terminal emulator. + * If we fail, try to start the GUI-mode terminal emulator. */ +#ifdef TUI_CONSOLE GuiMode = DtbgIsDesktopVisible(); - +#else + GuiMode = TRUE; +#endif + +#ifdef TUI_CONSOLE if (!GuiMode) { - DPRINT1("CONSRV: Opening text-mode console\n"); + DPRINT1("CONSRV: Opening text-mode terminal emulator\n"); Status = TuiInitConsole(Console, &ConsoleInfo); if (!NT_SUCCESS(Status)) { - DPRINT1("Failed to open text-mode console, switching to gui-mode, Status = 0x%08lx\n", Status); + DPRINT1("Failed to open text-mode terminal emulator, switching to gui-mode, Status = 0x%08lx\n", Status); GuiMode = TRUE; } } +#endif /* - * Try to open the GUI-mode console. Two cases are possible: + * Try to open the GUI-mode terminal emulator. Two cases are possible: * - We are in GUI-mode, therefore GuiMode == TRUE, the previous test-case - * failed and we start GUI-mode console. + * failed and we start GUI-mode terminal emulator. * - We are in text-mode, therefore GuiMode == FALSE, the previous test-case - * succeeded BUT we failed at starting text-mode console. Then GuiMode - * was switched to TRUE in order to try to open the console in GUI-mode - * (win32k will automatically switch to graphical mode, therefore - * no additional code is needed). + * succeeded BUT we failed at starting text-mode terminal emulator. + * Then GuiMode was switched to TRUE in order to try to open the GUI-mode + * terminal emulator (win32k will automatically switch to graphical mode, + * therefore no additional code is needed). */ if (GuiMode) { - DPRINT1("CONSRV: Opening GUI-mode console\n"); + DPRINT1("CONSRV: Opening GUI-mode terminal emulator\n"); Status = GuiInitConsole(Console, AppPath, &ConsoleInfo, @@ -1023,7 +1027,7 @@ Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE); if (!NT_SUCCESS(Status)) return Status; - GetWindowRequest->WindowHandle = Console->hWindow; + GetWindowRequest->WindowHandle = Console->TermIFace.Vtbl->GetConsoleWindowHandle(Console); ConSrvReleaseConsole(Console, TRUE); return STATUS_SUCCESS; Modified: branches/ros-csrss/win32ss/user/consrv/guiconsole.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/g…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/guiconsole.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/guiconsole.c [iso-8859-1] Fri Mar 8 23:37:11 2013 @@ -2,7 +2,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Console Server DLL * FILE: win32ss/user/consrv/guiconsole.c - * PURPOSE: Implementation of GUI-mode consoles + * PURPOSE: GUI terminal emulator * PROGRAMMERS: */ @@ -23,6 +23,14 @@ /* GUI Console Window Class name */ #define GUI_CONSOLE_WINDOW_CLASS L"ConsoleWindowClass" + +#ifndef WM_APP + #define WM_APP 0x8000 +#endif +#define PM_CREATE_CONSOLE (WM_APP + 1) +#define PM_DESTROY_CONSOLE (WM_APP + 2) +#define PM_CONSOLE_BEEP (WM_APP + 3) +#define PM_CONSOLE_SET_TITLE (WM_APP + 4) /* Not defined in any header file */ @@ -44,15 +52,17 @@ BOOL WindowSizeLock; POINT OldCursor; - // HWND hWindow; - // HICON hIcon; - // HICON hIconSm; + HWND hWindow; /* Handle to the console's window */ + HICON hIcon; /* Handle to the console's icon (big) */ + HICON hIconSm; /* Handle to the console's icon (small) */ + // COLORREF Colors[16]; HFONT Font; UINT CharWidth; UINT CharHeight; - GUI_CONSOLE_INFO GuiInfo; + PCONSOLE Console; /* Pointer to the owned console */ + GUI_CONSOLE_INFO GuiInfo; /* GUI terminal settings */ } GUI_CONSOLE_DATA, *PGUI_CONSOLE_DATA; static BOOL ConsInitialized = FALSE; @@ -171,38 +181,38 @@ } static VOID -GuiConsoleCreateSysMenu(PCONSOLE Console) +GuiConsoleCreateSysMenu(HWND hWnd) { HMENU hMenu; - hMenu = GetSystemMenu(Console->hWindow, - FALSE); + hMenu = GetSystemMenu(hWnd, FALSE); if (hMenu != NULL) { - GuiConsoleAppendMenuItems(hMenu, - GuiConsoleMainMenuItems); - DrawMenuBar(Console->hWindow); - } -} - - -static VOID -GuiConsoleCopy(HWND hWnd, PCONSOLE Console); -static VOID -GuiConsolePaste(HWND hWnd, PCONSOLE Console); + GuiConsoleAppendMenuItems(hMenu, GuiConsoleMainMenuItems); + DrawMenuBar(hWnd); + } +} + + +static VOID +GuiConsoleCopy(PGUI_CONSOLE_DATA GuiData); +static VOID +GuiConsolePaste(PGUI_CONSOLE_DATA GuiData); static VOID GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord); static VOID -GuiConsoleShowConsoleProperties(PCONSOLE Console, - HWND hWnd, - BOOL Defaults); +GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData, BOOL Defaults); +static VOID WINAPI +GuiDrawRegion(PCONSOLE Console, SMALL_RECT* Region); +static NTSTATUS WINAPI +GuiResizeBuffer(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer, COORD Size); +VOID FASTCALL +GuiConsoleInitScrollbar(PGUI_CONSOLE_DATA GuiData); + static LRESULT -GuiConsoleHandleSysMenuCommand(PCONSOLE Console, - HWND hWnd, - WPARAM wParam, LPARAM lParam) +GuiConsoleHandleSysMenuCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam) { LRESULT Ret = TRUE; - COORD bottomRight = { 0, 0 }; switch (wParam) { @@ -211,18 +221,23 @@ break; case ID_SYSTEM_EDIT_COPY: - GuiConsoleCopy(hWnd, Console); + GuiConsoleCopy(GuiData); break; case ID_SYSTEM_EDIT_PASTE: - GuiConsolePaste(hWnd, Console); + GuiConsolePaste(GuiData); break; case ID_SYSTEM_EDIT_SELECTALL: + { + PCONSOLE Console = GuiData->Console; + COORD bottomRight = { 0, 0 }; + bottomRight.X = Console->Size.X - 1; bottomRight.Y = Console->Size.Y - 1; GuiConsoleUpdateSelection(Console, &bottomRight); break; + } case ID_SYSTEM_EDIT_SCROLL: DPRINT1("Scrolling is not handled yet\n"); @@ -233,27 +248,25 @@ break; case ID_SYSTEM_DEFAULTS: - GuiConsoleShowConsoleProperties(Console, hWnd, TRUE); + GuiConsoleShowConsoleProperties(GuiData, TRUE); break; case ID_SYSTEM_PROPERTIES: - GuiConsoleShowConsoleProperties(Console, hWnd, FALSE); + GuiConsoleShowConsoleProperties(GuiData, FALSE); break; default: - Ret = DefWindowProcW(hWnd, WM_SYSCOMMAND, wParam, lParam); + Ret = DefWindowProcW(GuiData->hWindow, WM_SYSCOMMAND, wParam, lParam); break; } return Ret; } static VOID -GuiConsoleShowConsoleProperties(PCONSOLE Console, - HWND hWnd, - BOOL Defaults) +GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData, BOOL Defaults) { NTSTATUS Status; - PGUI_CONSOLE_DATA GuiData = Console->GuiData; + PCONSOLE Console = GuiData->Console; PCONSOLE_PROCESS_DATA ProcessData; HANDLE hSection = NULL, hClientSection = NULL; LARGE_INTEGER SectionSize; @@ -262,8 +275,6 @@ PCONSOLE_PROPS pSharedInfo = NULL; DPRINT("GuiConsoleShowConsoleProperties entered\n"); - - if (GuiData == NULL) return; /* Create a memory section to share with the applet, and map it */ SectionSize.QuadPart = sizeof(CONSOLE_PROPS); @@ -301,7 +312,7 @@ * Setup the shared console properties structure. */ /* Header */ - pSharedInfo->hConsoleWindow = hWnd; // Console->hWindow; + pSharedInfo->hConsoleWindow = GuiData->hWindow; pSharedInfo->ShowDefaultParams = Defaults; /* Console information */ pSharedInfo->ci.HistoryBufferSize = Console->HistoryBufferSize; @@ -380,18 +391,13 @@ return; } - -static NTSTATUS WINAPI -GuiResizeBuffer(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer, COORD Size); -VOID FASTCALL -GuiConsoleInitScrollbar(PCONSOLE Console, HWND hwnd); - -static VOID -GuiApplyUserSettings(PCONSOLE Console, +static VOID +GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData, HANDLE hClientSection, BOOL SaveSettings) { NTSTATUS Status; + PCONSOLE Console = GuiData->Console; PCONSOLE_PROCESS_DATA ProcessData; HANDLE hSection = NULL; ULONG ViewSize = 0; @@ -446,6 +452,8 @@ return; } + // TODO: Check that GuiData->hWindow == pConInfo->hConsoleWindow + /* * Apply foreground and background colors for both screen and popup. * Copy the new palette. @@ -475,13 +483,9 @@ if (SizeChanged) { - PGUI_CONSOLE_DATA GuiData = Console->GuiData; - if (GuiData) - { - GuiData->WindowSizeLock = TRUE; - GuiConsoleInitScrollbar(Console, pConInfo->hConsoleWindow); - GuiData->WindowSizeLock = FALSE; - } + GuiData->WindowSizeLock = TRUE; + GuiConsoleInitScrollbar(GuiData); + GuiData->WindowSizeLock = FALSE; } /// LOCK /// LeaveCriticalSection(&Console->Lock); @@ -500,18 +504,19 @@ NtClose(hSection); } -static PCONSOLE -GuiGetWindowConsole(HWND hWnd) -{ - return (PCONSOLE)GetWindowLongPtrW(hWnd, GWLP_USERDATA); +static PGUI_CONSOLE_DATA +GuiGetGuiData(HWND hWnd) +{ + PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)GetWindowLongPtrW(hWnd, GWLP_USERDATA); + return ( ((GuiData == NULL) || (GuiData->hWindow == hWnd && GuiData->Console != NULL)) ? GuiData : NULL ); } VOID FASTCALL -GuiConsoleInitScrollbar(PCONSOLE Console, HWND hwnd) -{ +GuiConsoleInitScrollbar(PGUI_CONSOLE_DATA GuiData) +{ + PCONSOLE Console = GuiData->Console; SCROLLINFO sInfo; - PGUI_CONSOLE_DATA GuiData = Console->GuiData; DWORD Width = Console->Size.X * GuiData->CharWidth + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE)); DWORD Height = Console->Size.Y * GuiData->CharHeight + 2 * (GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYEDGE)) + GetSystemMetrics(SM_CYCAPTION); @@ -525,13 +530,13 @@ sInfo.nMax = Console->ActiveBuffer->ScreenBufferSize.Y - 1; sInfo.nPage = Console->Size.Y; sInfo.nPos = Console->ActiveBuffer->ShowY; - SetScrollInfo(hwnd, SB_VERT, &sInfo, TRUE); + SetScrollInfo(GuiData->hWindow, SB_VERT, &sInfo, TRUE); Width += GetSystemMetrics(SM_CXVSCROLL); - ShowScrollBar(hwnd, SB_VERT, TRUE); + ShowScrollBar(GuiData->hWindow, SB_VERT, TRUE); } else { - ShowScrollBar(hwnd, SB_VERT, FALSE); + ShowScrollBar(GuiData->hWindow, SB_VERT, FALSE); } if (Console->ActiveBuffer->ScreenBufferSize.X > Console->Size.X) @@ -539,31 +544,31 @@ sInfo.nMax = Console->ActiveBuffer->ScreenBufferSize.X - 1; sInfo.nPage = Console->Size.X; sInfo.nPos = Console->ActiveBuffer->ShowX; - SetScrollInfo(hwnd, SB_HORZ, &sInfo, TRUE); + SetScrollInfo(GuiData->hWindow, SB_HORZ, &sInfo, TRUE); Height += GetSystemMetrics(SM_CYHSCROLL); - ShowScrollBar(hwnd, SB_HORZ, TRUE); + ShowScrollBar(GuiData->hWindow, SB_HORZ, TRUE); } else { - ShowScrollBar(hwnd, SB_HORZ, FALSE); - } - - SetWindowPos(hwnd, NULL, 0, 0, Width, Height, + ShowScrollBar(GuiData->hWindow, SB_HORZ, FALSE); + } + + SetWindowPos(GuiData->hWindow, NULL, 0, 0, Width, Height, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); } static BOOL GuiConsoleHandleNcCreate(HWND hWnd, LPCREATESTRUCTW Create) { - PCONSOLE Console = (PCONSOLE)Create->lpCreateParams; - PGUI_CONSOLE_DATA GuiData = Console->GuiData; + PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)Create->lpCreateParams; + PCONSOLE Console = GuiData->Console; HDC Dc; HFONT OldFont; TEXTMETRICW Metrics; SIZE CharSize; - Console->hWindow = hWnd; + GuiData->hWindow = hWnd; if (NULL == GuiData) { @@ -594,7 +599,7 @@ RtlFreeHeap(ConSrvHeap, 0, GuiData); return FALSE; } - Dc = GetDC(hWnd); + Dc = GetDC(GuiData->hWindow); if (NULL == Dc) { DPRINT1("GuiConsoleNcCreate: GetDC failed\n"); @@ -607,7 +612,7 @@ if (NULL == OldFont) { DPRINT1("GuiConsoleNcCreate: SelectObject failed\n"); - ReleaseDC(hWnd, Dc); + ReleaseDC(GuiData->hWindow, Dc); DeleteObject(GuiData->Font); DeleteCriticalSection(&GuiData->Lock); RtlFreeHeap(ConSrvHeap, 0, GuiData); @@ -617,7 +622,7 @@ { DPRINT1("GuiConsoleNcCreate: GetTextMetrics failed\n"); SelectObject(Dc, OldFont); - ReleaseDC(hWnd, Dc); + ReleaseDC(GuiData->hWindow, Dc); DeleteObject(GuiData->Font); DeleteCriticalSection(&GuiData->Lock); RtlFreeHeap(ConSrvHeap, 0, GuiData); @@ -632,7 +637,7 @@ SelectObject(Dc, OldFont); - ReleaseDC(hWnd, Dc); + ReleaseDC(GuiData->hWindow, Dc); // FIXME: Keep these instructions here ? /////////////////////////////////// Console->ActiveBuffer->CursorBlinkOn = TRUE; @@ -640,25 +645,26 @@ //////////////////////////////////////////////////////////////////////////// DPRINT("Console %p GuiData %p\n", Console, GuiData); - SetWindowLongPtrW(hWnd, GWLP_USERDATA, (DWORD_PTR)Console); - - SetTimer(hWnd, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL); - GuiConsoleCreateSysMenu(Console); + SetWindowLongPtrW(GuiData->hWindow, GWLP_USERDATA, (DWORD_PTR)GuiData); + + SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL); + GuiConsoleCreateSysMenu(GuiData->hWindow); GuiData->WindowSizeLock = TRUE; - GuiConsoleInitScrollbar(Console, hWnd); + GuiConsoleInitScrollbar(GuiData); GuiData->WindowSizeLock = FALSE; SetEvent(GuiData->hGuiInitEvent); - return (BOOL)DefWindowProcW(hWnd, WM_NCCREATE, 0, (LPARAM)Create); -} - -static VOID -SmallRectToRect(PCONSOLE Console, PRECT Rect, PSMALL_RECT SmallRect) -{ + return (BOOL)DefWindowProcW(GuiData->hWindow, WM_NCCREATE, 0, (LPARAM)Create); +} + +static VOID +SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect) +{ + PCONSOLE Console = GuiData->Console; PCONSOLE_SCREEN_BUFFER Buffer = Console->ActiveBuffer; - PGUI_CONSOLE_DATA GuiData = Console->GuiData; + Rect->left = (SmallRect->Left - Buffer->ShowX) * GuiData->CharWidth; Rect->top = (SmallRect->Top - Buffer->ShowY) * GuiData->CharHeight; Rect->right = (SmallRect->Right + 1 - Buffer->ShowX) * GuiData->CharWidth; @@ -668,10 +674,10 @@ static VOID GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord) { + PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data; RECT oldRect, newRect; - HWND hWnd = Console->hWindow; - - SmallRectToRect(Console, &oldRect, &Console->Selection.srSelection); + + SmallRectToRect(GuiData, &oldRect, &Console->Selection.srSelection); if(coord != NULL) { @@ -682,7 +688,7 @@ rc.Right = max(Console->Selection.dwSelectionAnchor.X, coord->X); rc.Bottom = max(Console->Selection.dwSelectionAnchor.Y, coord->Y); - SmallRectToRect(Console, &newRect, &rc); + SmallRectToRect(GuiData, &newRect, &rc); if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY) { @@ -697,7 +703,7 @@ { if(CombineRgn(rgn1, rgn2, rgn1, RGN_XOR) != ERROR) { - InvalidateRgn(hWnd, rgn1, FALSE); + InvalidateRgn(GuiData->hWindow, rgn1, FALSE); } DeleteObject(rgn2); @@ -708,7 +714,7 @@ } else { - InvalidateRect(hWnd, &newRect, FALSE); + InvalidateRect(GuiData->hWindow, &newRect, FALSE); } Console->Selection.dwFlags |= CONSOLE_SELECTION_NOT_EMPTY; Console->Selection.srSelection = rc; @@ -719,7 +725,7 @@ /* clear the selection */ if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY) { - InvalidateRect(hWnd, &oldRect, FALSE); + InvalidateRect(GuiData->hWindow, &oldRect, FALSE); } Console->Selection.dwFlags = CONSOLE_NO_SELECTION; ConioUnpause(Console, PAUSED_FROM_SELECTION); @@ -758,8 +764,7 @@ if (BottomLine >= Buff->ScreenBufferSize.Y) BottomLine = Buff->ScreenBufferSize.Y - 1; if (RightChar >= Buff->ScreenBufferSize.X) RightChar = Buff->ScreenBufferSize.X - 1; - OldFont = SelectObject(hDC, - GuiData->Font); + OldFont = SelectObject(hDC, GuiData->Font); for (Line = TopLine; Line <= BottomLine; Line++) { @@ -825,39 +830,33 @@ CursorBrush = CreateSolidBrush(RGBFromAttrib(Console, Buff->ScreenDefaultAttrib)); } - OldBrush = SelectObject(hDC, - CursorBrush); + OldBrush = SelectObject(hDC, CursorBrush); PatBlt(hDC, (CursorX - Buff->ShowX) * GuiData->CharWidth, (CursorY - Buff->ShowY) * GuiData->CharHeight + (GuiData->CharHeight - CursorHeight), GuiData->CharWidth, CursorHeight, PATCOPY); - SelectObject(hDC, - OldBrush); + SelectObject(hDC, OldBrush); DeleteObject(CursorBrush); } } /// LOCK /// LeaveCriticalSection(&Buff->Header.Console->Lock); - SelectObject(hDC, - OldFont); -} - -static VOID -GuiConsoleHandlePaint(PCONSOLE Console, - HWND hWnd, - HDC hDCPaint) -{ - PGUI_CONSOLE_DATA GuiData = Console->GuiData; + SelectObject(hDC, OldFont); +} + +static VOID +GuiConsoleHandlePaint(PGUI_CONSOLE_DATA GuiData, HDC hDCPaint) +{ + PCONSOLE Console = GuiData->Console; HDC hDC; PAINTSTRUCT ps; - if (GuiData == NULL) return; if (Console->ActiveBuffer == NULL) return; - hDC = BeginPaint(hWnd, &ps); + hDC = BeginPaint(GuiData->hWindow, &ps); if (hDC != NULL && ps.rcPaint.left < ps.rcPaint.right && ps.rcPaint.top < ps.rcPaint.bottom) @@ -874,7 +873,7 @@ if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY) { RECT rc; - SmallRectToRect(Console, &rc, &Console->Selection.srSelection); + SmallRectToRect(GuiData, &rc, &Console->Selection.srSelection); /* invert the selection */ if (IntersectRect(&rc, @@ -893,16 +892,16 @@ LeaveCriticalSection(&GuiData->Lock); } } - EndPaint(hWnd, &ps); -} - -static VOID -GuiConsoleHandleKey(PCONSOLE Console, HWND hWnd, - UINT msg, WPARAM wParam, LPARAM lParam) -{ + EndPaint(GuiData->hWindow, &ps); +} + +static VOID +GuiConsoleHandleKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam) +{ + PCONSOLE Console = GuiData->Console; MSG Message; - Message.hwnd = hWnd; + Message.hwnd = GuiData->hWindow; Message.message = msg; Message.wParam = wParam; Message.lParam = lParam; @@ -916,27 +915,6 @@ ConioProcessKey(Console, &Message); } -static BOOL WINAPI -GuiProcessKeyCallback(PCONSOLE Console, MSG* msg, BYTE KeyStateMenu, DWORD ShiftState, UINT VirtualKeyCode, BOOL Down) -{ - if ((ShiftState & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED) || KeyStateMenu & 0x80) && - (VirtualKeyCode == VK_ESCAPE || VirtualKeyCode == VK_TAB || VirtualKeyCode == VK_SPACE)) - { - DefWindowProcW(msg->hwnd, msg->message, msg->wParam, msg->lParam); - return TRUE; - } - - return FALSE; -} - -static VOID WINAPI -GuiDrawRegion(PCONSOLE Console, SMALL_RECT* Region) -{ - RECT RegionRect; - SmallRectToRect(Console, &RegionRect, Region); - InvalidateRect(Console->hWindow, &RegionRect, FALSE); -} - static VOID GuiInvalidateCell(PCONSOLE Console, UINT x, UINT y) { @@ -944,100 +922,13 @@ GuiDrawRegion(Console, &CellRect); } -static VOID WINAPI -GuiWriteStream(PCONSOLE Console, SMALL_RECT* Region, LONG CursorStartX, LONG CursorStartY, - UINT ScrolledLines, CHAR *Buffer, UINT Length) -{ - PGUI_CONSOLE_DATA GuiData = Console->GuiData; - PCONSOLE_SCREEN_BUFFER Buff = Console->ActiveBuffer; - LONG CursorEndX, CursorEndY; - RECT ScrollRect; - - if (NULL == Console->hWindow || NULL == GuiData) - { - return; - } - - if (0 != ScrolledLines) - { - ScrollRect.left = 0; - ScrollRect.top = 0; - ScrollRect.right = Console->Size.X * GuiData->CharWidth; - ScrollRect.bottom = Region->Top * GuiData->CharHeight; - - ScrollWindowEx(Console->hWindow, - 0, - -(ScrolledLines * GuiData->CharHeight), - &ScrollRect, - NULL, - NULL, - NULL, - SW_INVALIDATE); - } - - GuiDrawRegion(Console, Region); - - if (CursorStartX < Region->Left || Region->Right < CursorStartX - || CursorStartY < Region->Top || Region->Bottom < CursorStartY) - { - GuiInvalidateCell(Console, CursorStartX, CursorStartY); - } - - CursorEndX = Buff->CursorPosition.X; - CursorEndY = Buff->CursorPosition.Y; - if ((CursorEndX < Region->Left || Region->Right < CursorEndX - || CursorEndY < Region->Top || Region->Bottom < CursorEndY) - && (CursorEndX != CursorStartX || CursorEndY != CursorStartY)) - { - GuiInvalidateCell(Console, CursorEndX, CursorEndY); - } - - // Set up the update timer (very short interval) - this is a "hack" for getting the OS to - // repaint the window without having it just freeze up and stay on the screen permanently. - Buff->CursorBlinkOn = TRUE; - SetTimer(Console->hWindow, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL); -} - -static BOOL WINAPI -GuiSetCursorInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff) -{ - if (Console->ActiveBuffer == Buff) - { - GuiInvalidateCell(Console, Buff->CursorPosition.X, Buff->CursorPosition.Y); - } - - return TRUE; -} - -static BOOL WINAPI -GuiSetScreenInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff, UINT OldCursorX, UINT OldCursorY) -{ - if (Console->ActiveBuffer == Buff) - { - /* Redraw char at old position (removes cursor) */ - GuiInvalidateCell(Console, OldCursorX, OldCursorY); - /* Redraw char at new position (shows cursor) */ - GuiInvalidateCell(Console, Buff->CursorPosition.X, Buff->CursorPosition.Y); - } - - return TRUE; -} - -static BOOL WINAPI -GuiUpdateScreenInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff) -{ - return TRUE; -} - -static VOID -GuiConsoleHandleTimer(PCONSOLE Console, HWND hWnd) -{ - PGUI_CONSOLE_DATA GuiData = Console->GuiData; +static VOID +GuiConsoleHandleTimer(PGUI_CONSOLE_DATA GuiData) +{ + PCONSOLE Console = GuiData->Console; PCONSOLE_SCREEN_BUFFER Buff; - if (GuiData == NULL) return; - - SetTimer(hWnd, CONGUI_UPDATE_TIMER, CURSOR_BLINK_TIME, NULL); + SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CURSOR_BLINK_TIME, NULL); Buff = Console->ActiveBuffer; GuiInvalidateCell(Console, Buff->CursorPosition.X, Buff->CursorPosition.Y); @@ -1052,8 +943,8 @@ xScroll.cbSize = sizeof(SCROLLINFO); xScroll.fMask = SIF_POS; // Capture the original position of the scroll bars and save them. - if(GetScrollInfo(hWnd, SB_HORZ, &xScroll))OldScrollX = xScroll.nPos; - if(GetScrollInfo(hWnd, SB_VERT, &xScroll))OldScrollY = xScroll.nPos; + if(GetScrollInfo(GuiData->hWindow, SB_HORZ, &xScroll))OldScrollX = xScroll.nPos; + if(GetScrollInfo(GuiData->hWindow, SB_VERT, &xScroll))OldScrollY = xScroll.nPos; // If we successfully got the info for the horizontal scrollbar if(OldScrollX >= 0) @@ -1092,7 +983,7 @@ { Buff->ShowX = NewScrollX; Buff->ShowY = NewScrollY; - ScrollWindowEx(hWnd, + ScrollWindowEx(GuiData->hWindow, (OldScrollX - NewScrollX) * GuiData->CharWidth, (OldScrollY - NewScrollY) * GuiData->CharHeight, NULL, @@ -1103,14 +994,14 @@ if(NewScrollX >= 0) { xScroll.nPos = NewScrollX; - SetScrollInfo(hWnd, SB_HORZ, &xScroll, TRUE); + SetScrollInfo(GuiData->hWindow, SB_HORZ, &xScroll, TRUE); } if(NewScrollY >= 0) { xScroll.nPos = NewScrollY; - SetScrollInfo(hWnd, SB_VERT, &xScroll, TRUE); + SetScrollInfo(GuiData->hWindow, SB_VERT, &xScroll, TRUE); } - UpdateWindow(hWnd); + UpdateWindow(GuiData->hWindow); GuiData->OldCursor.x = Buff->CursorPosition.X; GuiData->OldCursor.y = Buff->CursorPosition.Y; } @@ -1118,8 +1009,9 @@ } static VOID -GuiConsoleHandleClose(PCONSOLE Console, HWND hWnd) -{ +GuiConsoleHandleClose(PGUI_CONSOLE_DATA GuiData) +{ + PCONSOLE Console = GuiData->Console; PLIST_ENTRY current_entry; PCONSOLE_PROCESS_DATA current; @@ -1148,12 +1040,12 @@ } static VOID -GuiConsoleHandleNcDestroy(PCONSOLE Console, HWND hWnd) -{ - PGUI_CONSOLE_DATA GuiData = Console->GuiData; +GuiConsoleHandleNcDestroy(PGUI_CONSOLE_DATA GuiData, HWND hWnd) +{ + PCONSOLE Console = GuiData->Console; KillTimer(hWnd, 1); - Console->GuiData = NULL; + Console->TermIFace.Data = NULL; DeleteCriticalSection(&GuiData->Lock); GetSystemMenu(hWnd, TRUE); @@ -1161,9 +1053,9 @@ } static COORD -PointToCoord(PCONSOLE Console, LPARAM lParam) -{ - PGUI_CONSOLE_DATA GuiData = Console->GuiData; +PointToCoord(PGUI_CONSOLE_DATA GuiData, LPARAM lParam) +{ + PCONSOLE Console = GuiData->Console; PCONSOLE_SCREEN_BUFFER Buffer = Console->ActiveBuffer; COORD Coord; @@ -1185,54 +1077,50 @@ } static VOID -GuiConsoleLeftMouseDown(PCONSOLE Console, HWND hWnd, - LPARAM lParam) -{ - Console->Selection.dwSelectionAnchor = PointToCoord(Console, lParam); - - SetCapture(hWnd); - +GuiConsoleLeftMouseDown(PGUI_CONSOLE_DATA GuiData, LPARAM lParam) +{ + PCONSOLE Console = GuiData->Console; + + Console->Selection.dwSelectionAnchor = PointToCoord(GuiData, lParam); + SetCapture(GuiData->hWindow); Console->Selection.dwFlags |= CONSOLE_SELECTION_IN_PROGRESS | CONSOLE_MOUSE_SELECTION | CONSOLE_MOUSE_DOWN; - GuiConsoleUpdateSelection(Console, &Console->Selection.dwSelectionAnchor); } static VOID -GuiConsoleLeftMouseUp(PCONSOLE Console, HWND hWnd, - LPARAM lParam) -{ +GuiConsoleLeftMouseUp(PGUI_CONSOLE_DATA GuiData, LPARAM lParam) +{ + PCONSOLE Console = GuiData->Console; COORD c; if (!(Console->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) return; - c = PointToCoord(Console, lParam); - + c = PointToCoord(GuiData, lParam); Console->Selection.dwFlags &= ~CONSOLE_MOUSE_DOWN; - GuiConsoleUpdateSelection(Console, &c); - ReleaseCapture(); } static VOID -GuiConsoleMouseMove(PCONSOLE Console, HWND hWnd, - WPARAM wParam, LPARAM lParam) -{ +GuiConsoleMouseMove(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam) +{ + PCONSOLE Console = GuiData->Console; COORD c; if (!(wParam & MK_LBUTTON)) return; if (!(Console->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) return; - c = PointToCoord(Console, lParam); /* TODO: Scroll buffer to bring c into view */ - + c = PointToCoord(GuiData, lParam); /* TODO: Scroll buffer to bring c into view */ GuiConsoleUpdateSelection(Console, &c); } static VOID -GuiConsoleCopy(HWND hWnd, PCONSOLE Console) -{ - if (OpenClipboard(hWnd) == TRUE) +GuiConsoleCopy(PGUI_CONSOLE_DATA GuiData) +{ + PCONSOLE Console = GuiData->Console; + + if (OpenClipboard(GuiData->hWindow) == TRUE) { HANDLE hData; PBYTE ptr; @@ -1301,9 +1189,11 @@ } static VOID -GuiConsolePaste(HWND hWnd, PCONSOLE Console) -{ - if (OpenClipboard(hWnd) == TRUE) +GuiConsolePaste(PGUI_CONSOLE_DATA GuiData) +{ + PCONSOLE Console = GuiData->Console; + + if (OpenClipboard(GuiData->hWindow) == TRUE) { HANDLE hData; LPSTR str; @@ -1334,15 +1224,17 @@ } static VOID -GuiConsoleRightMouseDown(PCONSOLE Console, HWND hWnd) -{ +GuiConsoleRightMouseDown(PGUI_CONSOLE_DATA GuiData) +{ + PCONSOLE Console = GuiData->Console; + if (!(Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)) { - GuiConsolePaste(hWnd, Console); + GuiConsolePaste(GuiData); } else { - GuiConsoleCopy(hWnd, Console); + GuiConsoleCopy(GuiData); /* Clear the selection */ GuiConsoleUpdateSelection(Console, NULL); @@ -1350,14 +1242,10 @@ } static VOID -GuiConsoleGetMinMaxInfo(PCONSOLE Console, - HWND hWnd, - PMINMAXINFO minMaxInfo) -{ - PGUI_CONSOLE_DATA GuiData = Console->GuiData; +GuiConsoleGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo) +{ + PCONSOLE Console = GuiData->Console; DWORD windx, windy; - - if (GuiData == NULL) return; windx = CONGUI_MIN_WIDTH * GuiData->CharWidth + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE)); windy = CONGUI_MIN_HEIGHT * GuiData->CharHeight + 2 * (GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYEDGE)) + GetSystemMetrics(SM_CYCAPTION); @@ -1376,13 +1264,9 @@ } static VOID -GuiConsoleResize(PCONSOLE Console, - HWND hWnd, - WPARAM wParam, LPARAM lParam) -{ - PGUI_CONSOLE_DATA GuiData = Console->GuiData; - - if (GuiData == NULL) return; +GuiConsoleResize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam) +{ + PCONSOLE Console = GuiData->Console; if ((GuiData->WindowSizeLock == FALSE) && (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED || wParam == SIZE_MINIMIZED)) { @@ -1423,16 +1307,19 @@ Console->Size.Y = (chary <= Buff->ScreenBufferSize.Y) ? chary : Buff->ScreenBufferSize.Y; } - GuiConsoleInitScrollbar(Console, hWnd); + GuiConsoleInitScrollbar(GuiData); // Adjust the start of the visible area if we are attempting to show nonexistent areas if((Buff->ScreenBufferSize.X - Buff->ShowX) < Console->Size.X) Buff->ShowX = Buff->ScreenBufferSize.X - Console->Size.X; if((Buff->ScreenBufferSize.Y - Buff->ShowY) < Console->Size.Y) Buff->ShowY = Buff->ScreenBufferSize.Y - Console->Size.Y; - InvalidateRect(hWnd, NULL, TRUE); + InvalidateRect(GuiData->hWindow, NULL, TRUE); GuiData->WindowSizeLock = FALSE; } } + +/* +// HACK: This functionality is standard for general scrollbars. Don't add it by hand. VOID FASTCALL @@ -1446,6 +1333,7 @@ DPRINT("CreatePopupMenu failed\n"); return; } + //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLHERE); //InsertItem(hMenu, MFT_SEPARATOR, MIIM_FTYPE, 0, NULL, -1); //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLTOP); @@ -1456,110 +1344,14 @@ //InsertItem(hMenu, MFT_SEPARATOR, MIIM_FTYPE, 0, NULL, -1); //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLUP); //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLDOWN); - -} - -static NTSTATUS WINAPI -GuiResizeBuffer(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer, COORD Size) -{ - BYTE * Buffer; - DWORD Offset = 0; - BYTE * OldPtr; - USHORT CurrentY; - BYTE * OldBuffer; -#ifdef HAVE_WMEMSET - USHORT value = MAKEWORD(' ', ScreenBuffer->ScreenDefaultAttrib); -#else - DWORD i; -#endif - DWORD diff; - - /* Buffer size is not allowed to be smaller than window size */ - if (Size.X < Console->Size.X || Size.Y < Console->Size.Y) - return STATUS_INVALID_PARAMETER; - - if (Size.X == ScreenBuffer->ScreenBufferSize.X && Size.Y == ScreenBuffer->ScreenBufferSize.Y) - return STATUS_SUCCESS; - - Buffer = RtlAllocateHeap(ConSrvHeap, 0, Size.X * Size.Y * 2); - if (!Buffer) - return STATUS_NO_MEMORY; - - DPRINT1("Resizing (%d,%d) to (%d,%d)\n", ScreenBuffer->ScreenBufferSize.X, ScreenBuffer->ScreenBufferSize.Y, Size.X, Size.Y); - OldBuffer = ScreenBuffer->Buffer; - - for (CurrentY = 0; CurrentY < ScreenBuffer->ScreenBufferSize.Y && CurrentY < Size.Y; CurrentY++) - { - OldPtr = ConioCoordToPointer(ScreenBuffer, 0, CurrentY); - if (Size.X <= ScreenBuffer->ScreenBufferSize.X) - { - /* reduce size */ - RtlCopyMemory(&Buffer[Offset], OldPtr, Size.X * 2); - Offset += (Size.X * 2); - } - else - { - /* enlarge size */ - RtlCopyMemory(&Buffer[Offset], OldPtr, ScreenBuffer->ScreenBufferSize.X * 2); - Offset += (ScreenBuffer->ScreenBufferSize.X * 2); - - diff = Size.X - ScreenBuffer->ScreenBufferSize.X; - /* zero new part of it */ -#ifdef HAVE_WMEMSET - wmemset((PWCHAR)&Buffer[Offset], value, diff); -#else - for (i = 0; i < diff; i++) - { - Buffer[Offset++] = ' '; - Buffer[Offset++] = ScreenBuffer->ScreenDefaultAttrib; - } -#endif - } - } - - if (Size.Y > ScreenBuffer->ScreenBufferSize.Y) - { - diff = Size.X * (Size.Y - ScreenBuffer->ScreenBufferSize.Y); -#ifdef HAVE_WMEMSET - wmemset((PWCHAR)&Buffer[Offset], value, diff); -#else - for (i = 0; i < diff; i++) - { - Buffer[Offset++] = ' '; - Buffer[Offset++] = ScreenBuffer->ScreenDefaultAttrib; - } -#endif - } - - (void)InterlockedExchangePointer((PVOID volatile*)&ScreenBuffer->Buffer, Buffer); - RtlFreeHeap(ConSrvHeap, 0, OldBuffer); - ScreenBuffer->ScreenBufferSize = Size; - ScreenBuffer->VirtualY = 0; - - /* Ensure cursor and window are within buffer */ - if (ScreenBuffer->CursorPosition.X >= Size.X) - ScreenBuffer->CursorPosition.X = Size.X - 1; - if (ScreenBuffer->CursorPosition.Y >= Size.Y) - ScreenBuffer->CursorPosition.Y = Size.Y - 1; - if (ScreenBuffer->ShowX > Size.X - Console->Size.X) - ScreenBuffer->ShowX = Size.X - Console->Size.X; - if (ScreenBuffer->ShowY > Size.Y - Console->Size.Y) - ScreenBuffer->ShowY = Size.Y - Console->Size.Y; - - /* TODO: Should update scrollbar, but can't use anything that - * calls SendMessage or it could cause deadlock --> Use PostMessage */ - - return STATUS_SUCCESS; -} +} +*/ static LRESULT -GuiConsoleHandleScroll(PCONSOLE Console, - HWND hWnd, - UINT uMsg, - WPARAM wParam) -{ - PGUI_CONSOLE_DATA GuiData = Console->GuiData; +GuiConsoleHandleScroll(PGUI_CONSOLE_DATA GuiData, UINT uMsg, WPARAM wParam) +{ + PCONSOLE Console = GuiData->Console; PCONSOLE_SCREEN_BUFFER Buff; SCROLLINFO sInfo; int fnBar; @@ -1587,7 +1379,7 @@ sInfo.cbSize = sizeof(SCROLLINFO); sInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE | SIF_TRACKPOS; - if (!GetScrollInfo(hWnd, fnBar, &sInfo)) + if (!GetScrollInfo(GuiData->hWindow, fnBar, &sInfo)) { return FALSE; } @@ -1642,7 +1434,7 @@ USHORT OldY = Buff->ShowY; *pShowXY = sInfo.nPos; - ScrollWindowEx(hWnd, + ScrollWindowEx(GuiData->hWindow, (OldX - Buff->ShowX) * GuiData->CharWidth, (OldY - Buff->ShowY) * GuiData->CharHeight, NULL, @@ -1652,9 +1444,9 @@ SW_INVALIDATE); sInfo.fMask = SIF_POS; - SetScrollInfo(hWnd, fnBar, &sInfo, TRUE); - - UpdateWindow(hWnd); + SetScrollInfo(GuiData->hWindow, fnBar, &sInfo, TRUE); + + UpdateWindow(GuiData->hWindow); } return 0; @@ -1664,11 +1456,11 @@ GuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { LRESULT Result = 0; - PCONSOLE Console = NULL; + PGUI_CONSOLE_DATA GuiData = NULL; /* * If it's the first time we create a window - * for the console, just initialize it. + * for the terminal, just initialize it. */ if (msg == WM_NCCREATE) { @@ -1676,31 +1468,31 @@ } /* - * Now the console window is initialized. - * Get the console owned by the window. - * If there is no console, just go away. + * Now the terminal window is initialized. + * Get the terminal data via the window's data. + * If there is no data, just go away. */ - Console = GuiGetWindowConsole(hWnd); - if (Console == NULL) return 0; + GuiData = GuiGetGuiData(hWnd); + if (GuiData == NULL) return 0; // TODO: If the console is about to be destroyed, leave the loop. /* Lock the console */ - EnterCriticalSection(&Console->Lock); + EnterCriticalSection(&GuiData->Console->Lock); /* We have a console, start message dispatching. */ switch (msg) { case WM_CLOSE: - GuiConsoleHandleClose(Console, hWnd); + GuiConsoleHandleClose(GuiData); break; case WM_NCDESTROY: - GuiConsoleHandleNcDestroy(Console, hWnd); + GuiConsoleHandleNcDestroy(GuiData, hWnd); break; case WM_PAINT: - GuiConsoleHandlePaint(Console, hWnd, (HDC)wParam); + GuiConsoleHandlePaint(GuiData, (HDC)wParam); break; case WM_KEYDOWN: @@ -1708,48 +1500,48 @@ case WM_SYSKEYDOWN: case WM_SYSKEYUP: case WM_CHAR: - GuiConsoleHandleKey(Console, hWnd, msg, wParam, lParam); + GuiConsoleHandleKey(GuiData, msg, wParam, lParam); break; case WM_TIMER: - GuiConsoleHandleTimer(Console, hWnd); + GuiConsoleHandleTimer(GuiData); break; case WM_LBUTTONDOWN: - GuiConsoleLeftMouseDown(Console, hWnd, lParam); + GuiConsoleLeftMouseDown(GuiData, lParam); break; case WM_LBUTTONUP: - GuiConsoleLeftMouseUp(Console, hWnd, lParam); + GuiConsoleLeftMouseUp(GuiData, lParam); break; case WM_RBUTTONDOWN: - GuiConsoleRightMouseDown(Console, hWnd); + GuiConsoleRightMouseDown(GuiData); break; case WM_MOUSEMOVE: - GuiConsoleMouseMove(Console, hWnd, wParam, lParam); + GuiConsoleMouseMove(GuiData, wParam, lParam); break; case WM_SYSCOMMAND: - Result = GuiConsoleHandleSysMenuCommand(Console, hWnd, wParam, lParam); + Result = GuiConsoleHandleSysMenuCommand(GuiData, wParam, lParam); break; case WM_HSCROLL: case WM_VSCROLL: - Result = GuiConsoleHandleScroll(Console, hWnd, msg, wParam); + Result = GuiConsoleHandleScroll(GuiData, msg, wParam); break; case WM_GETMINMAXINFO: - GuiConsoleGetMinMaxInfo(Console, hWnd, (PMINMAXINFO)lParam); + GuiConsoleGetMinMaxInfo(GuiData, (PMINMAXINFO)lParam); break; case WM_SIZE: - GuiConsoleResize(Console, hWnd, wParam, lParam); + GuiConsoleResize(GuiData, wParam, lParam); break; case PM_APPLY_CONSOLE_INFO: - GuiApplyUserSettings(Console, (HANDLE)wParam, (BOOL)lParam); + GuiApplyUserSettings(GuiData, (HANDLE)wParam, (BOOL)lParam); break; case PM_CONSOLE_BEEP: @@ -1758,19 +1550,25 @@ break; case PM_CONSOLE_SET_TITLE: - SetWindowText(hWnd, Console->Title.Buffer); + SetWindowText(GuiData->hWindow, GuiData->Console->Title.Buffer); break; default: - Result = DefWindowProcW(hWnd, msg, wParam, lParam); + Result = DefWindowProcW(GuiData->hWindow, msg, wParam, lParam); break; } /* Unlock the console */ - LeaveCriticalSection(&Console->Lock); + LeaveCriticalSection(&GuiData->Console->Lock); return Result; } + + + +/****************************************************************************** + * GUI Terminal Initialization * + ******************************************************************************/ static LRESULT CALLBACK GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -1778,14 +1576,19 @@ HWND NewWindow; LONG WindowCount; MSG Msg; - PCONSOLE Console = (PCONSOLE)lParam; + PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)lParam; + PCONSOLE Console = GuiData->Console; switch (msg) { case WM_CREATE: + { SetWindowLongW(hWnd, GWL_USERDATA, 0); return 0; + } + case PM_CREATE_CONSOLE: + { NewWindow = CreateWindowExW(WS_EX_CLIENTEDGE, GUI_CONSOLE_WINDOW_CLASS, Console->Title.Buffer, @@ -1797,40 +1600,50 @@ NULL, NULL, ConSrvDllInstance, - (PVOID)Console); + (PVOID)GuiData); if (NULL != NewWindow) { - SetConsoleWndConsoleLeaderCID(Console); - SetWindowLongW(hWnd, GWL_USERDATA, GetWindowLongW(hWnd, GWL_USERDATA) + 1); + WindowCount = GetWindowLongW(hWnd, GWL_USERDATA); + WindowCount++; + SetWindowLongW(hWnd, GWL_USERDATA, WindowCount); + + // SetConsoleWndConsoleLeaderCID(Console); DPRINT1("Set icons via PM_CREATE_CONSOLE\n"); - if (Console->hIcon == NULL) + if (GuiData->hIcon == NULL) { - DPRINT1("Not really...\n"); - Console->hIcon = ghDefaultIcon; - Console->hIconSm = ghDefaultIconSm; + DPRINT1("Not really /o\\...\n"); + GuiData->hIcon = ghDefaultIcon; + GuiData->hIconSm = ghDefaultIconSm; } - else if (Console->hIcon != ghDefaultIcon) + else if (GuiData->hIcon != ghDefaultIcon) { - DPRINT1("Yes !\n"); - SendMessageW(Console->hWindow, WM_SETICON, ICON_BIG, (LPARAM)Console->hIcon); - SendMessageW(Console->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)Console->hIconSm); + DPRINT1("Yes \\o/\n"); + SendMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG, (LPARAM)GuiData->hIcon); + SendMessageW(GuiData->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)GuiData->hIconSm); } ShowWindow(NewWindow, (int)wParam); } + return (LRESULT)NewWindow; + } + case PM_DESTROY_CONSOLE: - /* Window creation is done using a PostMessage(), so it's possible that the - * window that we want to destroy doesn't exist yet. So first empty the message - * queue */ + { + /* + * Window creation is done using a PostMessage(), so it's possible + * that the window that we want to destroy doesn't exist yet. + * So first empty the message queue. + */ while(PeekMessageW(&Msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&Msg); DispatchMessageW(&Msg); } - DestroyWindow(Console->hWindow); - Console->hWindow = NULL; + DestroyWindow(GuiData->hWindow); + GuiData->hWindow = NULL; + WindowCount = GetWindowLongW(hWnd, GWL_USERDATA); WindowCount--; SetWindowLongW(hWnd, GWL_USERDATA, WindowCount); @@ -1838,10 +1651,13 @@ { NotifyWnd = NULL; DestroyWindow(hWnd); - PrivateCsrssManualGuiCheck(-1); + DPRINT1("CONSRV: Going to quit the Gui Thread!!\n"); PostQuitMessage(0); } + return 0; + } + default: return DefWindowProcW(hWnd, msg, wParam, lParam); } @@ -1851,7 +1667,14 @@ GuiConsoleGuiThread(PVOID Data) { MSG msg; - PHANDLE GraphicsStartupEvent = (PHANDLE) Data; + PHANDLE GraphicsStartupEvent = (PHANDLE)Data; + + /* + * This thread dispatches all the console notifications to the notify window. + * It is common for all the console windows. + */ + + PrivateCsrssManualGuiCheck(+1); NotifyWnd = CreateWindowW(L"ConSrvCreateNotify", L"", @@ -1879,6 +1702,9 @@ DispatchMessageW(&msg); } + DPRINT1("CONSRV: Quit the Gui Thread!!\n"); + PrivateCsrssManualGuiCheck(-1); + return 1; } @@ -1888,180 +1714,78 @@ WNDCLASSEXW wc; ATOM ConsoleClassAtom; + /* Exit if we were already initialized */ + // if (ConsInitialized) return TRUE; + + /* + * Initialize and register the different window classes, if needed. + */ + if (!ConsInitialized) + { + /* Initialize the notification window class */ + wc.cbSize = sizeof(WNDCLASSEXW); + wc.lpszClassName = L"ConSrvCreateNotify"; + wc.lpfnWndProc = GuiConsoleNotifyWndProc; + wc.style = 0; + wc.hInstance = ConSrvDllInstance; + wc.hIcon = NULL; + wc.hIconSm = NULL; + wc.hCursor = NULL; + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + if (RegisterClassExW(&wc) == 0) + { + DPRINT1("Failed to register GUI notify wndproc\n"); + return FALSE; + } + + /* Initialize the console window class */ + ghDefaultIcon = LoadImageW(ConSrvDllInstance, MAKEINTRESOURCEW(IDI_CONSOLE), IMAGE_ICON, + GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), + LR_SHARED); + ghDefaultIconSm = LoadImageW(ConSrvDllInstance, MAKEINTRESOURCEW(IDI_CONSOLE), IMAGE_ICON, + GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), + LR_SHARED); + ghDefaultCursor = LoadCursorW(NULL, IDC_ARROW); + wc.cbSize = sizeof(WNDCLASSEXW); + wc.lpszClassName = GUI_CONSOLE_WINDOW_CLASS; + wc.lpfnWndProc = GuiConsoleWndProc; + wc.style = 0; + wc.hInstance = ConSrvDllInstance; + wc.hIcon = ghDefaultIcon; + wc.hIconSm = ghDefaultIconSm; + wc.hCursor = ghDefaultCursor; + wc.hbrBackground = CreateSolidBrush(RGB(0,0,0)); // FIXME: Use defaults from registry. + wc.lpszMenuName = NULL; + wc.cbClsExtra = 0; + wc.cbWndExtra = GWLP_CONSOLEWND_ALLOC; + + ConsoleClassAtom = RegisterClassExW(&wc); + if (ConsoleClassAtom == 0) + { + DPRINT1("Failed to register GUI console wndproc\n"); + return FALSE; + } + else + { + NtUserConsoleControl(GuiConsoleWndClassAtom, &ConsoleClassAtom, sizeof(ATOM)); + } + + ConsInitialized = TRUE; + } + + /* + * Set-up the notification window + */ if (NULL == NotifyWnd) { - PrivateCsrssManualGuiCheck(+1); - } - - /* Initialize the notification window class */ - wc.cbSize = sizeof(WNDCLASSEXW); - wc.lpszClassName = L"ConSrvCreateNotify"; - wc.lpfnWndProc = GuiConsoleNotifyWndProc; - wc.style = 0; - wc.hInstance = ConSrvDllInstance; - wc.hIcon = NULL; - wc.hIconSm = NULL; - wc.hCursor = NULL; - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - if (RegisterClassExW(&wc) == 0) - { - DPRINT1("Failed to register GUI notify wndproc\n"); - return FALSE; - } - - /* Initialize the console window class */ - ghDefaultIcon = LoadImageW(ConSrvDllInstance, MAKEINTRESOURCEW(IDI_CONSOLE), IMAGE_ICON, - GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), - LR_SHARED); - ghDefaultIconSm = LoadImageW(ConSrvDllInstance, MAKEINTRESOURCEW(IDI_CONSOLE), IMAGE_ICON, - GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), - LR_SHARED); - ghDefaultCursor = LoadCursorW(NULL, IDC_ARROW); - wc.cbSize = sizeof(WNDCLASSEXW); - wc.lpszClassName = GUI_CONSOLE_WINDOW_CLASS; - wc.lpfnWndProc = GuiConsoleWndProc; - wc.style = 0; - wc.hInstance = ConSrvDllInstance; - wc.hIcon = ghDefaultIcon; - wc.hIconSm = ghDefaultIconSm; - wc.hCursor = ghDefaultCursor; - wc.hbrBackground = CreateSolidBrush(RGB(0,0,0)); // FIXME: Use defaults from registry. - wc.lpszMenuName = NULL; - wc.cbClsExtra = 0; - wc.cbWndExtra = GWLP_CONSOLEWND_ALLOC; - - ConsoleClassAtom = RegisterClassExW(&wc); - if (ConsoleClassAtom == 0) - { - DPRINT1("Failed to register GUI console wndproc\n"); - return FALSE; - } - else - { - NtUserConsoleControl(GuiConsoleWndClassAtom, &ConsoleClassAtom, sizeof(ATOM)); - } - - return TRUE; -} - -static VOID WINAPI -GuiChangeTitle(PCONSOLE Console) -{ - PostMessageW(Console->hWindow, PM_CONSOLE_SET_TITLE, 0, 0); -} - -static BOOL WINAPI -GuiChangeIcon(PCONSOLE Console, HICON hWindowIcon) -{ - HICON hIcon, hIconSm; - - if (hWindowIcon == NULL) - { - hIcon = ghDefaultIcon; - hIconSm = ghDefaultIconSm; - } - else - { - hIcon = CopyIcon(hWindowIcon); - hIconSm = CopyIcon(hWindowIcon); - } - - if (hIcon == NULL) - { - return FALSE; - } - - if (hIcon != Console->hIcon) - { - if (Console->hIcon != NULL && Console->hIcon != ghDefaultIcon) - { - DestroyIcon(Console->hIcon); - } - if (Console->hIconSm != NULL && Console->hIconSm != ghDefaultIconSm) - { - DestroyIcon(Console->hIconSm); - } - - Console->hIcon = hIcon; - Console->hIconSm = hIconSm; - - DPRINT1("Set icons in GuiChangeIcon\n"); - PostMessageW(Console->hWindow, WM_SETICON, ICON_BIG, (LPARAM)Console->hIcon); - PostMessageW(Console->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)Console->hIconSm); - } - - return TRUE; -} - -static VOID WINAPI -GuiCleanupConsole(PCONSOLE Console) -{ - SendMessageW(NotifyWnd, PM_DESTROY_CONSOLE, 0, (LPARAM)Console); - - DPRINT1("Destroying icons !! - Console->hIcon = 0x%p ; ghDefaultIcon = 0x%p ; Console->hIconSm = 0x%p ; ghDefaultIconSm = 0x%p\n", - Console->hIcon, ghDefaultIcon, Console->hIconSm, ghDefaultIconSm); - if (Console->hIcon != NULL && Console->hIcon != ghDefaultIcon) - { - DPRINT1("Destroy hIcon\n"); - DestroyIcon(Console->hIcon); - } - if (Console->hIconSm != NULL && Console->hIconSm != ghDefaultIconSm) - { - DPRINT1("Destroy hIconSm\n"); - DestroyIcon(Console->hIconSm); - } -} - -static CONSOLE_VTBL GuiVtbl = -{ - GuiWriteStream, - GuiDrawRegion, - GuiSetCursorInfo, - GuiSetScreenInfo, - GuiUpdateScreenInfo, - GuiChangeTitle, - GuiCleanupConsole, - GuiChangeIcon, - GuiResizeBuffer, - GuiProcessKeyCallback -}; - -NTSTATUS FASTCALL -GuiInitConsole(PCONSOLE Console, - LPCWSTR AppPath, - PCONSOLE_INFO ConsoleInfo, - LPCWSTR IconPath, - INT IconIndex) -{ - HANDLE GraphicsStartupEvent; - HANDLE ThreadHandle; - PGUI_CONSOLE_DATA GuiData; - - /* Initialize the GUI */ - if (!ConsInitialized) - { - ConsInitialized = TRUE; - if (!GuiInit()) - { - ConsInitialized = FALSE; - return STATUS_UNSUCCESSFUL; - } - } - - /* Finish to initialize the console */ - Console->Vtbl = &GuiVtbl; - Console->hWindow = NULL; - - if (NULL == NotifyWnd) - { + HANDLE ThreadHandle; + HANDLE GraphicsStartupEvent; + GraphicsStartupEvent = CreateEventW(NULL, FALSE, FALSE, NULL); - if (NULL == GraphicsStartupEvent) - { - return STATUS_UNSUCCESSFUL; - } + if (NULL == GraphicsStartupEvent) return FALSE; ThreadHandle = CreateThread(NULL, 0, @@ -2073,7 +1797,7 @@ { CloseHandle(GraphicsStartupEvent); DPRINT1("CONSRV: Failed to create graphics console thread. Expect problems\n"); - return STATUS_UNSUCCESSFUL; + return FALSE; } SetThreadPriority(ThreadHandle, THREAD_PRIORITY_HIGHEST); CloseHandle(ThreadHandle); @@ -2084,9 +1808,334 @@ if (NULL == NotifyWnd) { DPRINT1("CONSRV: Failed to create notification window.\n"); - return STATUS_UNSUCCESSFUL; - } - } + return FALSE; + } + } + + // ConsInitialized = TRUE; + + return TRUE; +} + + + +/****************************************************************************** + * GUI Console Driver * + ******************************************************************************/ + +static VOID WINAPI +GuiCleanupConsole(PCONSOLE Console) +{ + PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data; + + SendMessageW(NotifyWnd, PM_DESTROY_CONSOLE, 0, (LPARAM)GuiData); + + DPRINT1("Destroying icons !! - GuiData->hIcon = 0x%p ; ghDefaultIcon = 0x%p ; GuiData->hIconSm = 0x%p ; ghDefaultIconSm = 0x%p\n", + GuiData->hIcon, ghDefaultIcon, GuiData->hIconSm, ghDefaultIconSm); + if (GuiData->hIcon != NULL && GuiData->hIcon != ghDefaultIcon) + { + DPRINT1("Destroy hIcon\n"); + DestroyIcon(GuiData->hIcon); + } + if (GuiData->hIconSm != NULL && GuiData->hIconSm != ghDefaultIconSm) + { + DPRINT1("Destroy hIconSm\n"); + DestroyIcon(GuiData->hIconSm); + } +} + +static VOID WINAPI +GuiWriteStream(PCONSOLE Console, SMALL_RECT* Region, LONG CursorStartX, LONG CursorStartY, + UINT ScrolledLines, CHAR *Buffer, UINT Length) +{ + PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data; + PCONSOLE_SCREEN_BUFFER Buff = Console->ActiveBuffer; + LONG CursorEndX, CursorEndY; + RECT ScrollRect; + + if (NULL == GuiData || NULL == GuiData->hWindow) + { + return; + } + + if (0 != ScrolledLines) + { + ScrollRect.left = 0; + ScrollRect.top = 0; + ScrollRect.right = Console->Size.X * GuiData->CharWidth; + ScrollRect.bottom = Region->Top * GuiData->CharHeight; + + ScrollWindowEx(GuiData->hWindow, + 0, + -(ScrolledLines * GuiData->CharHeight), + &ScrollRect, + NULL, + NULL, + NULL, + SW_INVALIDATE); + } + + GuiDrawRegion(Console, Region); + + if (CursorStartX < Region->Left || Region->Right < CursorStartX + || CursorStartY < Region->Top || Region->Bottom < CursorStartY) + { + GuiInvalidateCell(Console, CursorStartX, CursorStartY); + } + + CursorEndX = Buff->CursorPosition.X; + CursorEndY = Buff->CursorPosition.Y; + if ((CursorEndX < Region->Left || Region->Right < CursorEndX + || CursorEndY < Region->Top || Region->Bottom < CursorEndY) + && (CursorEndX != CursorStartX || CursorEndY != CursorStartY)) + { + GuiInvalidateCell(Console, CursorEndX, CursorEndY); + } + + // Set up the update timer (very short interval) - this is a "hack" for getting the OS to + // repaint the window without having it just freeze up and stay on the screen permanently. + Buff->CursorBlinkOn = TRUE; + SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL); +} + +static VOID WINAPI +GuiDrawRegion(PCONSOLE Console, SMALL_RECT* Region) +{ + PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data; + RECT RegionRect; + + SmallRectToRect(GuiData, &RegionRect, Region); + InvalidateRect(GuiData->hWindow, &RegionRect, FALSE); +} + +static BOOL WINAPI +GuiSetCursorInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff) +{ + if (Console->ActiveBuffer == Buff) + { + GuiInvalidateCell(Console, Buff->CursorPosition.X, Buff->CursorPosition.Y); + } + + return TRUE; +} + +static BOOL WINAPI +GuiSetScreenInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff, UINT OldCursorX, UINT OldCursorY) +{ + if (Console->ActiveBuffer == Buff) + { + /* Redraw char at old position (removes cursor) */ + GuiInvalidateCell(Console, OldCursorX, OldCursorY); + /* Redraw char at new position (shows cursor) */ + GuiInvalidateCell(Console, Buff->CursorPosition.X, Buff->CursorPosition.Y); + } + + return TRUE; +} + +static BOOL WINAPI +GuiUpdateScreenInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff) +{ + return TRUE; +} + +static NTSTATUS WINAPI +GuiResizeBuffer(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer, COORD Size) +{ + BYTE * Buffer; + DWORD Offset = 0; + BYTE * OldPtr; + USHORT CurrentY; + BYTE * OldBuffer; +#ifdef HAVE_WMEMSET + USHORT value = MAKEWORD(' ', ScreenBuffer->ScreenDefaultAttrib); +#else + DWORD i; +#endif + DWORD diff; + + /* Buffer size is not allowed to be smaller than window size */ + if (Size.X < Console->Size.X || Size.Y < Console->Size.Y) + return STATUS_INVALID_PARAMETER; + + if (Size.X == ScreenBuffer->ScreenBufferSize.X && Size.Y == ScreenBuffer->ScreenBufferSize.Y) + return STATUS_SUCCESS; + + Buffer = RtlAllocateHeap(ConSrvHeap, 0, Size.X * Size.Y * 2); + if (!Buffer) + return STATUS_NO_MEMORY; + + DPRINT1("Resizing (%d,%d) to (%d,%d)\n", ScreenBuffer->ScreenBufferSize.X, ScreenBuffer->ScreenBufferSize.Y, Size.X, Size.Y); + OldBuffer = ScreenBuffer->Buffer; + + for (CurrentY = 0; CurrentY < ScreenBuffer->ScreenBufferSize.Y && CurrentY < Size.Y; CurrentY++) + { + OldPtr = ConioCoordToPointer(ScreenBuffer, 0, CurrentY); + if (Size.X <= ScreenBuffer->ScreenBufferSize.X) + { + /* reduce size */ + RtlCopyMemory(&Buffer[Offset], OldPtr, Size.X * 2); + Offset += (Size.X * 2); + } + else + { + /* enlarge size */ + RtlCopyMemory(&Buffer[Offset], OldPtr, ScreenBuffer->ScreenBufferSize.X * 2); + Offset += (ScreenBuffer->ScreenBufferSize.X * 2); + + diff = Size.X - ScreenBuffer->ScreenBufferSize.X; + /* zero new part of it */ +#ifdef HAVE_WMEMSET + wmemset((PWCHAR)&Buffer[Offset], value, diff); +#else + for (i = 0; i < diff; i++) + { + Buffer[Offset++] = ' '; + Buffer[Offset++] = ScreenBuffer->ScreenDefaultAttrib; + } +#endif + } + } + + if (Size.Y > ScreenBuffer->ScreenBufferSize.Y) + { + diff = Size.X * (Size.Y - ScreenBuffer->ScreenBufferSize.Y); +#ifdef HAVE_WMEMSET + wmemset((PWCHAR)&Buffer[Offset], value, diff); +#else + for (i = 0; i < diff; i++) + { + Buffer[Offset++] = ' '; + Buffer[Offset++] = ScreenBuffer->ScreenDefaultAttrib; + } +#endif + } + + (void)InterlockedExchangePointer((PVOID volatile*)&ScreenBuffer->Buffer, Buffer); + RtlFreeHeap(ConSrvHeap, 0, OldBuffer); + ScreenBuffer->ScreenBufferSize = Size; + ScreenBuffer->VirtualY = 0; + + /* Ensure cursor and window are within buffer */ + if (ScreenBuffer->CursorPosition.X >= Size.X) + ScreenBuffer->CursorPosition.X = Size.X - 1; + if (ScreenBuffer->CursorPosition.Y >= Size.Y) + ScreenBuffer->CursorPosition.Y = Size.Y - 1; + if (ScreenBuffer->ShowX > Size.X - Console->Size.X) + ScreenBuffer->ShowX = Size.X - Console->Size.X; + if (ScreenBuffer->ShowY > Size.Y - Console->Size.Y) + ScreenBuffer->ShowY = Size.Y - Console->Size.Y; + + /* TODO: Should update scrollbar, but can't use anything that + * calls SendMessage or it could cause deadlock --> Use PostMessage */ + // TODO: Tell the terminal to resize its scrollbars. + + return STATUS_SUCCESS; +} + +static BOOL WINAPI +GuiProcessKeyCallback(PCONSOLE Console, MSG* msg, BYTE KeyStateMenu, DWORD ShiftState, UINT VirtualKeyCode, BOOL Down) +{ + if ((ShiftState & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED) || KeyStateMenu & 0x80) && + (VirtualKeyCode == VK_ESCAPE || VirtualKeyCode == VK_TAB || VirtualKeyCode == VK_SPACE)) + { + DefWindowProcW(msg->hwnd, msg->message, msg->wParam, msg->lParam); + return TRUE; + } + + return FALSE; +} + +static VOID WINAPI +GuiChangeTitle(PCONSOLE Console) +{ + PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data; + PostMessageW(GuiData->hWindow, PM_CONSOLE_SET_TITLE, 0, 0); +} + +static BOOL WINAPI +GuiChangeIcon(PCONSOLE Console, HICON hWindowIcon) +{ + PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data; + HICON hIcon, hIconSm; + + if (hWindowIcon == NULL) + { + hIcon = ghDefaultIcon; + hIconSm = ghDefaultIconSm; + } + else + { + hIcon = CopyIcon(hWindowIcon); + hIconSm = CopyIcon(hWindowIcon); + } + + if (hIcon == NULL) + { + return FALSE; + } + + if (hIcon != GuiData->hIcon) + { + if (GuiData->hIcon != NULL && GuiData->hIcon != ghDefaultIcon) + { + DestroyIcon(GuiData->hIcon); + } + if (GuiData->hIconSm != NULL && GuiData->hIconSm != ghDefaultIconSm) + { + DestroyIcon(GuiData->hIconSm); + } + + GuiData->hIcon = hIcon; + GuiData->hIconSm = hIconSm; + + DPRINT1("Set icons in GuiChangeIcon\n"); + PostMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG, (LPARAM)GuiData->hIcon); + PostMessageW(GuiData->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)GuiData->hIconSm); + } + + return TRUE; +} + +static HWND WINAPI +GuiGetConsoleWindowHandle(PCONSOLE Console) +{ + PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data; + return GuiData->hWindow; +} + +static TERMINAL_VTBL GuiVtbl = +{ + GuiCleanupConsole, + GuiWriteStream, + GuiDrawRegion, + GuiSetCursorInfo, + GuiSetScreenInfo, + GuiUpdateScreenInfo, + GuiResizeBuffer, + GuiProcessKeyCallback, + GuiChangeTitle, + GuiChangeIcon, + GuiGetConsoleWindowHandle +}; + +NTSTATUS FASTCALL +GuiInitConsole(PCONSOLE Console, + LPCWSTR AppPath, + PCONSOLE_INFO ConsoleInfo, + LPCWSTR IconPath, + INT IconIndex) +{ + PGUI_CONSOLE_DATA GuiData; + + if (Console == NULL || ConsoleInfo == NULL) + return STATUS_INVALID_PARAMETER; + + /* Initialize the GUI terminal emulator */ + if (!GuiInit()) return STATUS_UNSUCCESSFUL; + + /* Initialize the console */ + Console->TermIFace.Vtbl = &GuiVtbl; GuiData = RtlAllocateHeap(ConSrvHeap, HEAP_ZERO_MEMORY, sizeof(GUI_CONSOLE_DATA)); @@ -2095,30 +2144,23 @@ DPRINT1("CONSRV: Failed to create GUI_CONSOLE_DATA\n"); return STATUS_UNSUCCESSFUL; } - Console->GuiData = (PVOID)GuiData; - - if (ConsoleInfo) - { - wcsncpy(GuiData->GuiInfo.FaceName, ConsoleInfo->u.GuiInfo.FaceName, LF_FACESIZE); - GuiData->GuiInfo.FontFamily = ConsoleInfo->u.GuiInfo.FontFamily; - GuiData->GuiInfo.FontSize = ConsoleInfo->u.GuiInfo.FontSize; - GuiData->GuiInfo.FontWeight = ConsoleInfo->u.GuiInfo.FontWeight; - GuiData->GuiInfo.UseRasterFonts = ConsoleInfo->u.GuiInfo.UseRasterFonts; - - GuiData->GuiInfo.ShowWindow = ConsoleInfo->u.GuiInfo.ShowWindow; - GuiData->GuiInfo.AutoPosition = ConsoleInfo->u.GuiInfo.AutoPosition; - GuiData->GuiInfo.WindowOrigin = ConsoleInfo->u.GuiInfo.WindowOrigin; - } - /* - else - { - // TODO: What could be the defaults ? - } - */ + Console->TermIFace.Data = (PVOID)GuiData; + GuiData->Console = Console; + GuiData->hWindow = NULL; + + /* Set up the GUI data */ + wcsncpy(GuiData->GuiInfo.FaceName, ConsoleInfo->u.GuiInfo.FaceName, LF_FACESIZE); + GuiData->GuiInfo.FontFamily = ConsoleInfo->u.GuiInfo.FontFamily; + GuiData->GuiInfo.FontSize = ConsoleInfo->u.GuiInfo.FontSize; + GuiData->GuiInfo.FontWeight = ConsoleInfo->u.GuiInfo.FontWeight; + GuiData->GuiInfo.UseRasterFonts = ConsoleInfo->u.GuiInfo.UseRasterFonts; + GuiData->GuiInfo.ShowWindow = ConsoleInfo->u.GuiInfo.ShowWindow; + GuiData->GuiInfo.AutoPosition = ConsoleInfo->u.GuiInfo.AutoPosition; + GuiData->GuiInfo.WindowOrigin = ConsoleInfo->u.GuiInfo.WindowOrigin; /* Initialize the icon handles to their default values */ - Console->hIcon = ghDefaultIcon; - Console->hIconSm = ghDefaultIconSm; + GuiData->hIcon = ghDefaultIcon; + GuiData->hIconSm = ghDefaultIconSm; /* Get the associated icon, if any */ if (IconPath == NULL || *IconPath == L'\0') @@ -2139,8 +2181,8 @@ if (hIcon != NULL) { DPRINT1("Effectively set the icons\n"); - Console->hIcon = hIcon; - Console->hIconSm = hIconSm; + GuiData->hIcon = hIcon; + GuiData->hIconSm = hIconSm; } } @@ -2153,11 +2195,11 @@ GuiData->hGuiInitEvent = CreateEventW(NULL, FALSE, FALSE, NULL); /* Create the GUI console */ - PostMessageW(NotifyWnd, PM_CREATE_CONSOLE, GuiData->GuiInfo.ShowWindow, (LPARAM)Console); + PostMessageW(NotifyWnd, PM_CREATE_CONSOLE, GuiData->GuiInfo.ShowWindow, (LPARAM)GuiData); /* Wait until initialization has finished */ WaitForSingleObject(GuiData->hGuiInitEvent, INFINITE); - DPRINT("Received event Console %p GuiData %p X %d Y %d\n", Console, Console->GuiData, Console->Size.X, Console->Size.Y); + DPRINT1("Received event Console %p GuiData %p X %d Y %d\n", Console, GuiData, Console->Size.X, Console->Size.Y); CloseHandle(GuiData->hGuiInitEvent); GuiData->hGuiInitEvent = NULL; Modified: branches/ros-csrss/win32ss/user/consrv/guiconsole.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/g…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/guiconsole.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/guiconsole.h [iso-8859-1] Fri Mar 8 23:37:11 2013 @@ -2,7 +2,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Console Server DLL * FILE: win32ss/user/consrv/guiconsole.h - * PURPOSE: Interface to GUI-mode consoles + * PURPOSE: GUI terminal emulator * PROGRAMMERS: */ Modified: branches/ros-csrss/win32ss/user/consrv/handle.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/h…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/handle.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/handle.c [iso-8859-1] Fri Mar 8 23:37:11 2013 @@ -373,7 +373,7 @@ (HandleEntry->Access & Access) == 0 || (Type != 0 && ObjectEntry->Type != Type) ) { - DPRINT1("CsrGetObject returning invalid handle (%x) of type %lu with access %lu\n", Handle, Type, Access); + DPRINT1("ConSrvGetObject returning invalid handle (%x) of type %lu with access %lu\n", Handle, Type, Access); RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return STATUS_INVALID_HANDLE; } @@ -511,7 +511,6 @@ ConSrvRemoveConsole(PCONSOLE_PROCESS_DATA ProcessData) { PCONSOLE Console; - PCONSOLE_PROCESS_DATA NewProcessData; DPRINT1("ConSrvRemoveConsole\n"); @@ -532,11 +531,7 @@ RemoveEntryList(&ProcessData->ConsoleLink); /* Update the console leader process */ - NewProcessData = CONTAINING_RECORD(Console->ProcessList.Blink, - CONSOLE_PROCESS_DATA, - ConsoleLink); - Console->ConsoleLeaderCID = NewProcessData->Process->ClientId; - SetConsoleWndConsoleLeaderCID(Console); + // SetConsoleWndConsoleLeaderCID(Console); /* Release the console */ ConSrvReleaseConsole(Console, TRUE); @@ -799,7 +794,7 @@ Index >= ProcessData->HandleTableSize || ProcessData->HandleTable[Index].Object == NULL) { - DPRINT("CsrVerifyObject failed\n"); + DPRINT("SrvVerifyConsoleIoHandle failed\n"); Status = STATUS_INVALID_HANDLE; } Modified: branches/ros-csrss/win32ss/user/consrv/settings.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/s…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/settings.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/settings.h [iso-8859-1] Fri Mar 8 23:37:11 2013 @@ -8,6 +8,9 @@ * NOTE: Adapted from existing code. */ +#ifndef WM_APP + #define WM_APP 0x8000 +#endif #define PM_APPLY_CONSOLE_INFO (WM_APP + 100) /* STRUCTURES *****************************************************************/ @@ -54,6 +57,7 @@ WCHAR ConsoleTitle[MAX_PATH + 1]; + // PVOID TerminalInfo; /* Terminal-specific parameters */ union { GUI_CONSOLE_INFO GuiInfo; Modified: branches/ros-csrss/win32ss/user/consrv/tuiconsole.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/t…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/tuiconsole.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/tuiconsole.c [iso-8859-1] Fri Mar 8 23:37:11 2013 @@ -2,9 +2,11 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Console Server DLL * FILE: win32ss/user/consrv/tuiconsole.c - * PURPOSE: Interface to text-mode consoles + * PURPOSE: TUI terminal emulator * PROGRAMMERS: */ + +#ifdef TUI_CONSOLE #include "consrv.h" #include "settings.h" @@ -15,9 +17,21 @@ #include <debug.h> +/* GLOBALS ********************************************************************/ + /* TUI Console Window Class name */ #define TUI_CONSOLE_WINDOW_CLASS L"TuiConsoleWindowClass" +typedef struct _TUI_CONSOLE_DATA +{ + CRITICAL_SECTION Lock; + // HANDLE hTuiInitEvent; + + HWND hWindow; + + PCONSOLE Console; + // TUI_CONSOLE_INFO TuiInfo; +} TUI_CONSOLE_DATA, *PTUI_CONSOLE_DATA; CRITICAL_SECTION ActiveConsoleLock; static COORD PhysicalConsoleSize; @@ -164,7 +178,7 @@ /* alt-tab, swap consoles */ /* move SwapConsole to next console, and print its title */ EnterCriticalSection(&ActiveConsoleLock); - if (! SwapConsole) + if (!SwapConsole) { SwapConsole = ActiveConsole; } @@ -480,6 +494,12 @@ return TRUE; } +static HWND WINAPI +TuiGetConsoleWindowHandle(PCONSOLE Console) +{ + return Console->hWindow; +} + static NTSTATUS WINAPI TuiResizeBuffer(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer, COORD Size) { @@ -507,7 +527,6 @@ return 1; } Console->hWindow = NewWindow; - SetConsoleWndConsoleLeaderCID(Console); SetForegroundWindow(Console->hWindow); @@ -528,16 +547,17 @@ return 0; } -static CONSOLE_VTBL TuiVtbl = -{ +static TERMINAL_VTBL TuiVtbl = +{ + TuiCleanupConsole, TuiWriteStream, TuiDrawRegion, TuiSetCursorInfo, TuiSetScreenInfo, TuiUpdateScreenInfo, TuiChangeTitle, - TuiCleanupConsole, TuiChangeIcon, + TuiGetConsoleWindowHandle, TuiResizeBuffer, TuiProcessKeyCallback }; @@ -558,7 +578,7 @@ } } - Console->Vtbl = &TuiVtbl; + Console->TermIFace.Vtbl = &TuiVtbl; Console->hWindow = NULL; Console->Size = PhysicalConsoleSize; Console->ActiveBuffer->ScreenBufferSize = PhysicalConsoleSize; @@ -601,4 +621,6 @@ return ActiveConsole; } +#endif + /* EOF */ Modified: branches/ros-csrss/win32ss/user/consrv/tuiconsole.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/t…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/tuiconsole.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/tuiconsole.h [iso-8859-1] Fri Mar 8 23:37:11 2013 @@ -2,7 +2,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Console Server DLL * FILE: win32ss/user/consrv/tuiconsole.h - * PURPOSE: Interface to text-mode consoles + * PURPOSE: TUI terminal emulator * PROGRAMMERS: */
11 years, 9 months
1
0
0
0
[hbelusca] 58446: [SERVICES-ADVAPI32] - Check for possible null pointers (invalid address) before dereferencing them. - Correct some DPRINT formatting.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Mar 8 22:40:38 2013 New Revision: 58446 URL:
http://svn.reactos.org/svn/reactos?rev=58446&view=rev
Log: [SERVICES-ADVAPI32] - Check for possible null pointers (invalid address) before dereferencing them. - Correct some DPRINT formatting. Modified: trunk/reactos/base/system/services/rpcserver.c trunk/reactos/base/system/services/services.c trunk/reactos/dll/win32/advapi32/service/scm.c Modified: trunk/reactos/base/system/services/rpcserver.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcse…
============================================================================== --- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Fri Mar 8 22:40:38 2013 @@ -2764,7 +2764,7 @@ lpStr += (wcslen(lpStr) + 1); /* Append the group name */ - if (lpService->lpGroup != NULL) + if ((lpService->lpGroup != NULL) && (lpService->lpGroup->lpGroupName != NULL)) { wcscpy(lpStr, lpService->lpGroup->lpGroupName); } @@ -3733,6 +3733,11 @@ DPRINT("REnumServicesStatusA() called\n"); + if (pcbBytesNeeded == NULL || lpServicesReturned == NULL) + { + return ERROR_INVALID_ADDRESS; + } + if ((dwBufSize > 0) && (lpBuffer)) { lpStatusPtrW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwBufSize); @@ -4496,6 +4501,11 @@ { DPRINT1("Invalid service manager handle!\n"); return ERROR_INVALID_HANDLE; + } + + if (pcbBytesNeeded == NULL || lpServicesReturned == NULL) + { + return ERROR_INVALID_ADDRESS; } *pcbBytesNeeded = 0; @@ -5750,6 +5760,11 @@ DPRINT("REnumServicesStatusExA() called\n"); + if (pcbBytesNeeded == NULL || lpServicesReturned == NULL) + { + return ERROR_INVALID_ADDRESS; + } + if (pszGroupName) { pszGroupNameW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (strlen(pszGroupName) + 1) * sizeof(WCHAR)); @@ -5893,6 +5908,11 @@ { DPRINT1("Invalid service manager handle!\n"); return ERROR_INVALID_HANDLE; + } + + if (pcbBytesNeeded == NULL || lpServicesReturned == NULL) + { + return ERROR_INVALID_ADDRESS; } *pcbBytesNeeded = 0; Modified: trunk/reactos/base/system/services/services.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
============================================================================== --- trunk/reactos/base/system/services/services.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/services.c [iso-8859-1] Fri Mar 8 22:40:38 2013 @@ -173,7 +173,7 @@ hPipe = (HANDLE)Context; - DPRINT("ScmNamedPipeThread(%lu) - Accepting SCM commands through named pipe\n", hPipe); + DPRINT("ScmNamedPipeThread(%p) - Accepting SCM commands through named pipe\n", hPipe); for (;;) { @@ -201,13 +201,13 @@ } } - DPRINT("ScmNamedPipeThread(%lu) - Disconnecting named pipe connection\n", hPipe); + DPRINT("ScmNamedPipeThread(%p) - Disconnecting named pipe connection\n", hPipe); FlushFileBuffers(hPipe); DisconnectNamedPipe(hPipe); CloseHandle(hPipe); - DPRINT("ScmNamedPipeThread(%lu) - Done.\n", hPipe); + DPRINT("ScmNamedPipeThread(%p) - Done.\n", hPipe); return ERROR_SUCCESS; } @@ -237,7 +237,7 @@ return FALSE; } - DPRINT("CreateNamedPipe() - calling ConnectNamedPipe(%x)\n", hPipe); + DPRINT("CreateNamedPipe() - calling ConnectNamedPipe(%p)\n", hPipe); bConnected = ConnectNamedPipe(hPipe, NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED); DPRINT("CreateNamedPipe() - ConnectNamedPipe() returned %d\n", bConnected); Modified: trunk/reactos/dll/win32/advapi32/service/scm.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service…
============================================================================== --- trunk/reactos/dll/win32/advapi32/service/scm.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/service/scm.c [iso-8859-1] Fri Mar 8 22:40:38 2013 @@ -165,6 +165,8 @@ TRACE("ChangeServiceConfig2A() called\n"); + if (lpInfo == NULL) return TRUE; + /* Fill relevent field of the Info structure */ Info.dwInfoLevel = dwInfoLevel; switch (dwInfoLevel) @@ -184,9 +186,6 @@ return FALSE; } - if (lpInfo == NULL) - return TRUE; - RpcTryExcept { dwError = RChangeServiceConfig2A((SC_RPC_HANDLE)hService, @@ -223,6 +222,8 @@ DWORD dwError; TRACE("ChangeServiceConfig2W() called\n"); + + if (lpInfo == NULL) return TRUE; /* Fill relevent field of the Info structure */ Info.dwInfoLevel = dwInfoLevel; @@ -241,9 +242,6 @@ SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } - - if (lpInfo == NULL) - return TRUE; RpcTryExcept { @@ -923,6 +921,12 @@ if (!hSCManager) { SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + if (pcbBytesNeeded == NULL || lpServicesReturned == NULL) + { + SetLastError(ERROR_INVALID_ADDRESS); return FALSE; } @@ -1027,6 +1031,12 @@ return FALSE; } + if (pcbBytesNeeded == NULL || lpServicesReturned == NULL) + { + SetLastError(ERROR_INVALID_ADDRESS); + return FALSE; + } + if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUSA)) { lpStatusPtr = &ServiceStatus; @@ -1110,6 +1120,12 @@ if (!hSCManager) { SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + if (pcbBytesNeeded == NULL || lpServicesReturned == NULL) + { + SetLastError(ERROR_INVALID_ADDRESS); return FALSE; } @@ -1207,8 +1223,13 @@ return FALSE; } - if (lpServices == NULL || - cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSA)) + if (pcbBytesNeeded == NULL || lpServicesReturned == NULL) + { + SetLastError(ERROR_INVALID_ADDRESS); + return FALSE; + } + + if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSA)) { lpStatusPtr = &ServiceStatus; dwBufferSize = sizeof(ENUM_SERVICE_STATUS_PROCESSA); @@ -1307,8 +1328,13 @@ return FALSE; } - if (lpServices == NULL || - cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSW)) + if (pcbBytesNeeded == NULL || lpServicesReturned == NULL) + { + SetLastError(ERROR_INVALID_ADDRESS); + return FALSE; + } + + if (lpServices == NULL || cbBufSize < sizeof(ENUM_SERVICE_STATUS_PROCESSW)) { lpStatusPtr = &ServiceStatus; dwBufferSize = sizeof(ENUM_SERVICE_STATUS_PROCESSW);
11 years, 9 months
1
0
0
0
[hbelusca] 58445: The 'i' variable being only used for displaying the array of parameters (when debug output is enabled), disable it also to avoid "error: unused variable 'i'".
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Mar 8 21:22:05 2013 New Revision: 58445 URL:
http://svn.reactos.org/svn/reactos?rev=58445&view=rev
Log: The 'i' variable being only used for displaying the array of parameters (when debug output is enabled), disable it also to avoid "error: unused variable 'i'". Modified: trunk/reactos/base/system/services/rpcserver.c Modified: trunk/reactos/base/system/services/rpcserver.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcse…
============================================================================== --- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Fri Mar 8 21:22:05 2013 @@ -2896,9 +2896,10 @@ PSERVICE_HANDLE hSvc; PSERVICE lpService = NULL; SC_RPC_LOCK Lock = NULL; + +#ifndef NDEBUG DWORD i; -#ifndef NDEBUG DPRINT("RStartServiceW(%p %lu %p) called\n", hService, argc, argv); DPRINT(" argc: %lu\n", argc); if (argv != NULL)
11 years, 9 months
1
0
0
0
[hbelusca] 58444: [SERVICES] - Disable an unuseful DPRINT. - Remove a redundant variable lpConfig.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Mar 8 21:19:12 2013 New Revision: 58444 URL:
http://svn.reactos.org/svn/reactos?rev=58444&view=rev
Log: [SERVICES] - Disable an unuseful DPRINT. - Remove a redundant variable lpConfig. Modified: trunk/reactos/base/system/services/rpcserver.c Modified: trunk/reactos/base/system/services/rpcserver.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcse…
============================================================================== --- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Fri Mar 8 21:19:12 2013 @@ -2655,7 +2655,6 @@ LPWSTR lpDependencies = NULL; DWORD dwDependenciesLength = 0; DWORD dwRequiredSize; - LPQUERY_SERVICE_CONFIGW lpConfig = NULL; WCHAR lpEmptyString[] = {0,0}; LPWSTR lpStr; @@ -2718,7 +2717,7 @@ else dwRequiredSize += 2 * sizeof(WCHAR); - if (lpService->lpGroup != NULL) + if ((lpService->lpGroup != NULL) && (lpService->lpGroup->lpGroupName != NULL)) dwRequiredSize += (DWORD)((wcslen(lpService->lpGroup->lpGroupName) + 1) * sizeof(WCHAR)); else dwRequiredSize += 2 * sizeof(WCHAR); @@ -2744,13 +2743,12 @@ } else { - lpConfig = (LPQUERY_SERVICE_CONFIGW)lpServiceConfig; - lpConfig->dwServiceType = lpService->Status.dwServiceType; - lpConfig->dwStartType = lpService->dwStartType; - lpConfig->dwErrorControl = lpService->dwErrorControl; - lpConfig->dwTagId = lpService->dwTag; - - lpStr = (LPWSTR)(lpConfig + 1); + lpServiceConfig->dwServiceType = lpService->Status.dwServiceType; + lpServiceConfig->dwStartType = lpService->dwStartType; + lpServiceConfig->dwErrorControl = lpService->dwErrorControl; + lpServiceConfig->dwTagId = lpService->dwTag; + + lpStr = (LPWSTR)(lpServiceConfig + 1); /* Append the image path */ if (lpImagePath != NULL) @@ -2762,7 +2760,7 @@ wcscpy(lpStr, lpEmptyString); } - lpConfig->lpBinaryPathName = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpConfig); + lpServiceConfig->lpBinaryPathName = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig); lpStr += (wcslen(lpStr) + 1); /* Append the group name */ @@ -2775,7 +2773,7 @@ wcscpy(lpStr, lpEmptyString); } - lpConfig->lpLoadOrderGroup = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpConfig); + lpServiceConfig->lpLoadOrderGroup = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig); lpStr += (wcslen(lpStr) + 1); /* Append Dependencies */ @@ -2790,7 +2788,7 @@ wcscpy(lpStr, lpEmptyString); } - lpConfig->lpDependencies = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpConfig); + lpServiceConfig->lpDependencies = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig); if (lpDependencies != NULL) lpStr += dwDependenciesLength; else @@ -2806,7 +2804,7 @@ wcscpy(lpStr, lpEmptyString); } - lpConfig->lpServiceStartName = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpConfig); + lpServiceConfig->lpServiceStartName = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig); lpStr += (wcslen(lpStr) + 1); /* Append the display name */ @@ -2819,7 +2817,7 @@ wcscpy(lpStr, lpEmptyString); } - lpConfig->lpDisplayName = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpConfig); + lpServiceConfig->lpDisplayName = (LPWSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig); } if (pcbBytesNeeded != NULL) @@ -2900,15 +2898,17 @@ SC_RPC_LOCK Lock = NULL; DWORD i; +#ifndef NDEBUG DPRINT("RStartServiceW(%p %lu %p) called\n", hService, argc, argv); DPRINT(" argc: %lu\n", argc); if (argv != NULL) { for (i = 0; i < argc; i++) { - DPRINT(" argv[%lu]: %S\n", i, argv[i]); - } - } + DPRINT(" argv[%lu]: %S\n", i, argv[i].StringPtr); + } + } +#endif if (ScmShutdown) return ERROR_SHUTDOWN_IN_PROGRESS; @@ -3892,7 +3892,6 @@ LPWSTR lpDependencies = NULL; DWORD dwDependenciesLength = 0; DWORD dwRequiredSize; - LPQUERY_SERVICE_CONFIGA lpConfig = NULL; CHAR lpEmptyString[]={0,0}; LPSTR lpStr; @@ -3982,11 +3981,10 @@ } else { - lpConfig = (LPQUERY_SERVICE_CONFIGA)lpServiceConfig; - lpConfig->dwServiceType = lpService->Status.dwServiceType; - lpConfig->dwStartType = lpService->dwStartType; - lpConfig->dwErrorControl = lpService->dwErrorControl; - lpConfig->dwTagId = lpService->dwTag; + lpServiceConfig->dwServiceType = lpService->Status.dwServiceType; + lpServiceConfig->dwStartType = lpService->dwStartType; + lpServiceConfig->dwErrorControl = lpService->dwErrorControl; + lpServiceConfig->dwTagId = lpService->dwTag; lpStr = (LPSTR)(lpServiceConfig + 1); @@ -4009,7 +4007,7 @@ strcpy(lpStr, lpEmptyString); } - lpConfig->lpBinaryPathName = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpConfig); + lpServiceConfig->lpBinaryPathName = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig); lpStr += (strlen((LPSTR)lpStr) + 1); if (lpService->lpGroup && lpService->lpGroup->lpGroupName) @@ -4028,7 +4026,7 @@ strcpy(lpStr, lpEmptyString); } - lpConfig->lpLoadOrderGroup = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpConfig); + lpServiceConfig->lpLoadOrderGroup = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig); lpStr += (strlen(lpStr) + 1); /* Append Dependencies */ @@ -4048,7 +4046,7 @@ strcpy(lpStr, lpEmptyString); } - lpConfig->lpDependencies = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpConfig); + lpServiceConfig->lpDependencies = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig); if (lpDependencies) lpStr += dwDependenciesLength; else @@ -4070,7 +4068,7 @@ strcpy(lpStr, lpEmptyString); } - lpConfig->lpServiceStartName = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpConfig); + lpServiceConfig->lpServiceStartName = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig); lpStr += (strlen(lpStr) + 1); if (lpService->lpDisplayName) @@ -4089,7 +4087,7 @@ strcpy(lpStr, lpEmptyString); } - lpConfig->lpDisplayName = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpConfig); + lpServiceConfig->lpDisplayName = (LPSTR)((ULONG_PTR)lpStr - (ULONG_PTR)lpServiceConfig); } if (pcbBytesNeeded != NULL)
11 years, 9 months
1
0
0
0
[hbelusca] 58443: [SERVICES] * Fix some format specifiers (part 2 of r58442). Thanks Amine :) * Remane two "global" static variables to avoid name collision warnings.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Mar 8 20:56:18 2013 New Revision: 58443 URL:
http://svn.reactos.org/svn/reactos?rev=58443&view=rev
Log: [SERVICES] * Fix some format specifiers (part 2 of r58442). Thanks Amine :) * Remane two "global" static variables to avoid name collision warnings. Modified: trunk/reactos/base/system/services/database.c trunk/reactos/base/system/services/services.c Modified: trunk/reactos/base/system/services/database.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/datab…
============================================================================== --- trunk/reactos/base/system/services/database.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/database.c [iso-8859-1] Fri Mar 8 20:56:18 2013 @@ -36,10 +36,10 @@ LIST_ENTRY ServiceListHead; static RTL_RESOURCE DatabaseLock; -static DWORD dwResumeCount = 1; +static DWORD ResumeCount = 1; static CRITICAL_SECTION ControlServiceCriticalSection; -static DWORD dwPipeTimeout = 30000; /* 30 Seconds */ +static DWORD PipeTimeout = 30000; /* 30 Seconds */ /* FUNCTIONS *****************************************************************/ @@ -110,7 +110,7 @@ 100, 8000, 4, - dwPipeTimeout, + PipeTimeout, NULL); DPRINT("CreateNamedPipeW(%S) done\n", szControlPipeName); if (pServiceImage->hControlPipe == INVALID_HANDLE_VALUE) @@ -380,7 +380,7 @@ lpService->lpDisplayName = lpService->lpServiceName; /* Set the resume count */ - lpService->dwResumeCount = dwResumeCount++; + lpService->dwResumeCount = ResumeCount++; /* Append service record */ InsertTailList(&ServiceListHead, @@ -941,7 +941,7 @@ DPRINT1("dwError: ERROR_IO_PENDING\n"); dwError = WaitForSingleObject(Service->lpImage->hControlPipe, - dwPipeTimeout); + PipeTimeout); DPRINT1("WaitForSingleObject() returned %lu\n", dwError); if (dwError == WAIT_TIMEOUT) @@ -995,7 +995,7 @@ DPRINT1("dwError: ERROR_IO_PENDING\n"); dwError = WaitForSingleObject(Service->lpImage->hControlPipe, - dwPipeTimeout); + PipeTimeout); DPRINT1("WaitForSingleObject() returned %lu\n", dwError); if (dwError == WAIT_TIMEOUT) @@ -1192,7 +1192,7 @@ DPRINT1("dwError: ERROR_IO_PENDING\n"); dwError = WaitForSingleObject(Service->lpImage->hControlPipe, - dwPipeTimeout); + PipeTimeout); DPRINT1("WaitForSingleObject() returned %lu\n", dwError); if (dwError == WAIT_TIMEOUT) @@ -1246,7 +1246,7 @@ DPRINT1("dwError: ERROR_IO_PENDING\n"); dwError = WaitForSingleObject(Service->lpImage->hControlPipe, - dwPipeTimeout); + PipeTimeout); DPRINT1("WaitForSingleObject() returned %lu\n", dwError); if (dwError == WAIT_TIMEOUT) @@ -1354,7 +1354,7 @@ DPRINT("dwError: ERROR_IO_PENDING\n"); dwError = WaitForSingleObject(Service->lpImage->hControlPipe, - dwPipeTimeout); + PipeTimeout); DPRINT("WaitForSingleObject() returned %lu\n", dwError); if (dwError == WAIT_TIMEOUT) @@ -1411,7 +1411,7 @@ DPRINT("dwError: ERROR_IO_PENDING\n"); dwError = WaitForSingleObject(Service->lpImage->hControlPipe, - dwPipeTimeout); + PipeTimeout); if (dwError == WAIT_TIMEOUT) { DPRINT("WaitForSingleObject() returned WAIT_TIMEOUT\n"); @@ -1927,7 +1927,7 @@ L"ServicesPipeTimeout", 0, NULL, - (LPBYTE)&dwPipeTimeout, + (LPBYTE)&PipeTimeout, &dwKeySize); RegCloseKey(hKey); Modified: trunk/reactos/base/system/services/services.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
============================================================================== --- trunk/reactos/base/system/services/services.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/services.c [iso-8859-1] Fri Mar 8 20:56:18 2013 @@ -153,7 +153,7 @@ PVOID Reply, LPDWORD ReplySize) { - DbgPrint("SCM READ: %s\n", Request); + DbgPrint("SCM READ: %p\n", Request); *ReplySize = 0; return FALSE; @@ -173,7 +173,7 @@ hPipe = (HANDLE)Context; - DPRINT("ScmNamedPipeThread(%x) - Accepting SCM commands through named pipe\n", hPipe); + DPRINT("ScmNamedPipeThread(%lu) - Accepting SCM commands through named pipe\n", hPipe); for (;;) { @@ -201,13 +201,13 @@ } } - DPRINT("ScmNamedPipeThread(%x) - Disconnecting named pipe connection\n", hPipe); + DPRINT("ScmNamedPipeThread(%lu) - Disconnecting named pipe connection\n", hPipe); FlushFileBuffers(hPipe); DisconnectNamedPipe(hPipe); CloseHandle(hPipe); - DPRINT("ScmNamedPipeThread(%x) - Done.\n", hPipe); + DPRINT("ScmNamedPipeThread(%lu) - Done.\n", hPipe); return ERROR_SUCCESS; } @@ -278,7 +278,7 @@ ScmNamedPipeListenerThread(LPVOID Context) { // HANDLE hPipe; - DPRINT("ScmNamedPipeListenerThread(%x) - aka SCM.\n", Context); + DPRINT("ScmNamedPipeListenerThread(%p) - aka SCM.\n", Context); // hPipe = (HANDLE)Context; for (;;) @@ -294,7 +294,7 @@ DPRINT("\nSCM: named pipe session created.\n"); Sleep(10); } - DPRINT("\n\nWARNING: ScmNamedPipeListenerThread(%x) - Aborted.\n\n", Context); + DPRINT("\n\nWARNING: ScmNamedPipeListenerThread(%p) - Aborted.\n\n", Context); return ERROR_SUCCESS; }
11 years, 9 months
1
0
0
0
[akhaldi] 58442: [SERVICES] * Fix some format specifiers.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Fri Mar 8 20:49:03 2013 New Revision: 58442 URL:
http://svn.reactos.org/svn/reactos?rev=58442&view=rev
Log: [SERVICES] * Fix some format specifiers. Modified: trunk/reactos/base/system/services/groupdb.c trunk/reactos/base/system/services/rpcserver.c trunk/reactos/base/system/services/services.c Modified: trunk/reactos/base/system/services/groupdb.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/group…
============================================================================== --- trunk/reactos/base/system/services/groupdb.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/groupdb.c [iso-8859-1] Fri Mar 8 20:49:03 2013 @@ -96,7 +96,7 @@ { PSERVICE_GROUP Group; - DPRINT("CreateGroupOrderListRoutine(%S, %x, %x, %x, %x, %x)\n", + DPRINT("CreateGroupOrderListRoutine(%S, %x, %p, %x, %p, %p)\n", ValueName, ValueType, ValueData, ValueLength, Context, EntryContext); if (ValueType == REG_BINARY && @@ -172,7 +172,7 @@ QueryTable, (PVOID)Group, NULL); - DPRINT("%x %d %S\n", Status, Group->TagCount, (PWSTR)ValueData); + DPRINT("%x %lu %S\n", Status, Group->TagCount, (PWSTR)ValueData); InsertTailList(&GroupListHead, &Group->GroupListEntry); Modified: trunk/reactos/base/system/services/rpcserver.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcse…
============================================================================== --- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Fri Mar 8 20:49:03 2013 @@ -1619,7 +1619,7 @@ WCHAR szErrorBuffer[32]; DPRINT("RSetServiceStatus() called\n"); - DPRINT("hServiceStatus = %p\n", hServiceStatus); + DPRINT("hServiceStatus = %lu\n", hServiceStatus); DPRINT("dwServiceType = %lu\n", lpServiceStatus->dwServiceType); DPRINT("dwCurrentState = %lu\n", lpServiceStatus->dwCurrentState); DPRINT("dwControlsAccepted = %lu\n", lpServiceStatus->dwControlsAccepted); Modified: trunk/reactos/base/system/services/services.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
============================================================================== --- trunk/reactos/base/system/services/services.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/services.c [iso-8859-1] Fri Mar 8 20:49:03 2013 @@ -55,7 +55,7 @@ L"Service Control Manager"); if (hLog == NULL) { - DPRINT1("ScmLogEvent: RegisterEventSourceW failed %d\n", GetLastError()); + DPRINT1("ScmLogEvent: RegisterEventSourceW failed %lu\n", GetLastError()); return; } @@ -69,7 +69,7 @@ lpStrings, NULL)) { - DPRINT1("ScmLogEvent: ReportEventW failed %d\n", GetLastError()); + DPRINT1("ScmLogEvent: ReportEventW failed %lu\n", GetLastError()); } DeregisterEventSource(hLog); @@ -233,7 +233,7 @@ NULL); if (hPipe == INVALID_HANDLE_VALUE) { - DPRINT("CreateNamedPipe() failed (%d)\n", GetLastError()); + DPRINT("CreateNamedPipe() failed (%lu)\n", GetLastError()); return FALSE; } @@ -253,7 +253,7 @@ &dwThreadId); if (!hThread) { - DPRINT("Could not create thread (%d)\n", GetLastError()); + DPRINT("Could not create thread (%lu)\n", GetLastError()); DisconnectNamedPipe(hPipe); CloseHandle(hPipe); DPRINT("CreateNamedPipe() - returning FALSE\n");
11 years, 9 months
1
0
0
0
← Newer
1
...
16
17
18
19
20
21
22
...
25
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Results per page:
10
25
50
100
200