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
December 2016
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
10 participants
83 discussions
Start a n
N
ew thread
[ekohl] 73433: [SERVICES] Create a new environment block when a service process is started. Patch by Hermès BÉLUSCA - MAÏTO. CORE-12414
by ekohl@svn.reactos.org
Author: ekohl Date: Tue Dec 6 17:29:30 2016 New Revision: 73433 URL:
http://svn.reactos.org/svn/reactos?rev=73433&view=rev
Log: [SERVICES] Create a new environment block when a service process is started. Patch by Hermès BÉLUSCA - MAÏTO. CORE-12414 Modified: trunk/reactos/base/system/services/CMakeLists.txt trunk/reactos/base/system/services/database.c Modified: trunk/reactos/base/system/services/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/CMake…
============================================================================== --- trunk/reactos/base/system/services/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/system/services/CMakeLists.txt [iso-8859-1] Tue Dec 6 17:29:30 2016 @@ -26,6 +26,6 @@ endif() set_module_type(services win32gui UNICODE) -add_importlibs(services user32 advapi32 rpcrt4 msvcrt kernel32 ntdll) +add_importlibs(services userenv user32 advapi32 rpcrt4 msvcrt kernel32 ntdll) add_pch(services services.h SOURCE) add_cd_file(TARGET services DESTINATION reactos/system32 FOR all) 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] Tue Dec 6 17:29:30 2016 @@ -14,7 +14,7 @@ #include "services.h" -#include <winuser.h> +#include <userenv.h> #define NDEBUG #include <debug.h> @@ -1681,6 +1681,7 @@ { PROCESS_INFORMATION ProcessInformation; STARTUPINFOW StartupInfo; + LPVOID lpEnvironment; BOOL Result; DWORD dwError = ERROR_SUCCESS; @@ -1698,17 +1699,73 @@ StartupInfo.cb = sizeof(StartupInfo); ZeroMemory(&ProcessInformation, sizeof(ProcessInformation)); - Result = CreateProcessAsUserW(Service->lpImage->hToken, - NULL, - Service->lpImage->pszImagePath, - NULL, - NULL, - FALSE, - DETACHED_PROCESS | CREATE_SUSPENDED, - NULL, - NULL, - &StartupInfo, - &ProcessInformation); + /* Use the interactive desktop if the service is interactive */ + if (Service->Status.dwServiceType & SERVICE_INTERACTIVE_PROCESS) + StartupInfo.lpDesktop = L"winsta0\\default"; + + if (Service->lpImage->hToken) + { + /* User token: Run the service under the user account */ + + if (!CreateEnvironmentBlock(&lpEnvironment, Service->lpImage->hToken, FALSE)) + { + /* We failed, run the service with the current environment */ + DPRINT1("CreateEnvironmentBlock() failed with error %d, service '%S' will run with the current environment.\n", + Service->lpServiceName, GetLastError()); + lpEnvironment = NULL; + } + + /* Impersonate the new user */ + if (!ImpersonateLoggedOnUser(Service->lpImage->hToken)) + { + dwError = GetLastError(); + DPRINT1("ImpersonateLoggedOnUser() failed with error %d\n", GetLastError()); + return dwError; + } + + /* Launch the process in the user's logon session */ + Result = CreateProcessAsUserW(Service->lpImage->hToken, + NULL, + Service->lpImage->pszImagePath, + NULL, + NULL, + FALSE, + CREATE_UNICODE_ENVIRONMENT | DETACHED_PROCESS | CREATE_SUSPENDED, + lpEnvironment, + NULL, + &StartupInfo, + &ProcessInformation); + + /* Revert the impersonation */ + RevertToSelf(); + } + else + { + /* No user token: Run the service under the LocalSystem account */ + + if (!CreateEnvironmentBlock(&lpEnvironment, NULL, TRUE)) + { + /* We failed, run the service with the current environment */ + DPRINT1("CreateEnvironmentBlock() failed with error %d, service '%S' will run with the current environment.\n", + Service->lpServiceName, GetLastError()); + lpEnvironment = NULL; + } + + Result = CreateProcessW(NULL, + Service->lpImage->pszImagePath, + NULL, + NULL, + FALSE, + CREATE_UNICODE_ENVIRONMENT | DETACHED_PROCESS | CREATE_SUSPENDED, + lpEnvironment, + NULL, + &StartupInfo, + &ProcessInformation); + } + + if (lpEnvironment) + DestroyEnvironmentBlock(lpEnvironment); + if (!Result) { dwError = GetLastError();
8 years
1
0
0
0
[hbelusca] 73432: Fix for source code file header, sorry for commit noise.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon Dec 5 16:38:11 2016 New Revision: 73432 URL:
http://svn.reactos.org/svn/reactos?rev=73432&view=rev
Log: Fix for source code file header, sorry for commit noise. Modified: trunk/rostests/apitests/advapi32/ServiceEnv.c Modified: trunk/rostests/apitests/advapi32/ServiceEnv.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/Service…
============================================================================== --- trunk/rostests/apitests/advapi32/ServiceEnv.c [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/ServiceEnv.c [iso-8859-1] Mon Dec 5 16:38:11 2016 @@ -1,8 +1,8 @@ /* * PROJECT: ReactOS api tests * LICENSE: GPLv2+ - See COPYING in the top level directory - * PURPOSE: Test for StartService functionality - * PROGRAMMER: Hermès BÃLUSCA - MAÃTO + * PURPOSE: Test for service process environment block + * PROGRAMMER: Hermes Belusca-Maito */ #include <apitest.h>
8 years
1
0
0
0
[hbelusca] 73431: [ADVAPI32_APITEST]: Test for a (correctly initialized) service process environment block, that should contain both ALLUSERSPROFILE and USERPROFILE environment variables. CORE-12414
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon Dec 5 16:36:06 2016 New Revision: 73431 URL:
http://svn.reactos.org/svn/reactos?rev=73431&view=rev
Log: [ADVAPI32_APITEST]: Test for a (correctly initialized) service process environment block, that should contain both ALLUSERSPROFILE and USERPROFILE environment variables. CORE-12414 Added: trunk/rostests/apitests/advapi32/ServiceEnv.c (with props) Modified: trunk/rostests/apitests/advapi32/CMakeLists.txt trunk/rostests/apitests/advapi32/testlist.c Modified: trunk/rostests/apitests/advapi32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/CMakeLi…
============================================================================== --- trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] Mon Dec 5 16:36:06 2016 @@ -14,6 +14,7 @@ RtlEncryptMemory.c SaferIdentifyLevel.c ServiceArgs.c + ServiceEnv.c svchlp.c testlist.c) Added: trunk/rostests/apitests/advapi32/ServiceEnv.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/Service…
============================================================================== --- trunk/rostests/apitests/advapi32/ServiceEnv.c (added) +++ trunk/rostests/apitests/advapi32/ServiceEnv.c [iso-8859-1] Mon Dec 5 16:36:06 2016 @@ -0,0 +1,259 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Test for StartService functionality + * PROGRAMMER: Hermès BÃLUSCA - MAÃTO + */ + +#include <apitest.h> +#include <winsvc.h> +#include "svchlp.h" + + +/*** Service part of the test ***/ + +static SERVICE_STATUS_HANDLE status_handle; + +static void +report_service_status(DWORD dwCurrentState, + DWORD dwWin32ExitCode, + DWORD dwWaitHint) +{ + BOOL res; + SERVICE_STATUS status; + + status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + status.dwCurrentState = dwCurrentState; + status.dwWin32ExitCode = dwWin32ExitCode; + status.dwWaitHint = dwWaitHint; + + status.dwServiceSpecificExitCode = 0; + status.dwCheckPoint = 0; + + if ( (dwCurrentState == SERVICE_START_PENDING) || + (dwCurrentState == SERVICE_STOP_PENDING) || + (dwCurrentState == SERVICE_STOPPED) ) + { + status.dwControlsAccepted = 0; + } + else + { + status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; + } + +#if 0 + if ( (dwCurrentState == SERVICE_RUNNING) || (dwCurrentState == SERVICE_STOPPED) ) + status.dwCheckPoint = 0; + else + status.dwCheckPoint = dwCheckPoint++; +#endif + + res = SetServiceStatus(status_handle, &status); + service_ok(res, "SetServiceStatus(%d) failed: %lu\n", dwCurrentState, GetLastError()); +} + +static VOID WINAPI service_handler(DWORD ctrl) +{ + switch(ctrl) + { + case SERVICE_CONTROL_STOP: + case SERVICE_CONTROL_SHUTDOWN: + report_service_status(SERVICE_STOP_PENDING, NO_ERROR, 0); + default: + report_service_status(SERVICE_RUNNING, NO_ERROR, 0); + } +} + +static void WINAPI +service_main(DWORD dwArgc, LPWSTR* lpszArgv) +{ + // SERVICE_STATUS_HANDLE status_handle; + LPWSTR lpEnvironment, lpEnvStr; + DWORD dwSize; + + UNREFERENCED_PARAMETER(dwArgc); + UNREFERENCED_PARAMETER(lpszArgv); + + /* Register our service for control (lpszArgv[0] holds the service name) */ + status_handle = RegisterServiceCtrlHandlerW(lpszArgv[0], service_handler); + service_ok(status_handle != NULL, "RegisterServiceCtrlHandler failed: %lu\n", GetLastError()); + if (!status_handle) + return; + + /* Report SERVICE_RUNNING status */ + report_service_status(SERVICE_RUNNING, NO_ERROR, 4000); + + /* Display our current environment for informative purposes */ + lpEnvironment = GetEnvironmentStringsW(); + lpEnvStr = lpEnvironment; + while (*lpEnvStr) + { + service_trace("%S\n", lpEnvStr); + lpEnvStr += wcslen(lpEnvStr) + 1; + } + FreeEnvironmentStringsW(lpEnvironment); + + /* Check the presence of the user-related environment variables */ + dwSize = GetEnvironmentVariableW(L"ALLUSERSPROFILE", NULL, 0); + service_ok(dwSize != 0, "ALLUSERSPROFILE envvar not found, or GetEnvironmentVariableW failed: %lu\n", GetLastError()); + dwSize = GetEnvironmentVariableW(L"USERPROFILE", NULL, 0); + service_ok(dwSize != 0, "USERPROFILE envvar not found, or GetEnvironmentVariableW failed: %lu\n", GetLastError()); +#if 0 // May not always exist + dwSize = GetEnvironmentVariableW(L"USERNAME", NULL, 0); + service_ok(dwSize != 0, "USERNAME envvar not found, or GetEnvironmentVariableW failed: %lu\n", GetLastError()); +#endif + + /* Work is done */ + report_service_status(SERVICE_STOPPED, NO_ERROR, 0); +} + +static BOOL start_service(PCSTR service_nameA, PCWSTR service_nameW) +{ + BOOL res; + + SERVICE_TABLE_ENTRYW servtbl[] = + { + { (PWSTR)service_nameW, service_main }, + { NULL, NULL } + }; + + res = StartServiceCtrlDispatcherW(servtbl); + service_ok(res, "StartServiceCtrlDispatcherW failed: %lu\n", GetLastError()); + return res; +} + + +/*** Tester part of the test ***/ + +static void +my_test_server(PCSTR service_nameA, + PCWSTR service_nameW, + void *param) +{ + BOOL res; + SC_HANDLE hSC = NULL; + SC_HANDLE hService = NULL; + SERVICE_STATUS ServiceStatus; + + /* Open the SCM */ + hSC = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS); + if (!hSC) + { + skip("OpenSCManagerW failed with error %lu!\n", GetLastError()); + return; + } + + /* First create ourselves as a service running in the default LocalSystem account */ + hService = register_service_exW(hSC, L"ServiceEnv", service_nameW, NULL, + SERVICE_ALL_ACCESS, + SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, + SERVICE_DEMAND_START, + SERVICE_ERROR_IGNORE, + NULL, NULL, NULL, + NULL, NULL); + if (!hService) + { + skip("CreateServiceW failed with error %lu!\n", GetLastError()); + goto Cleanup; + } + + /* Start it */ + if (!StartServiceW(hService, 0, NULL)) + { + skip("StartServiceW failed with error %lu!\n", GetLastError()); + goto Cleanup; + } + + /* Wait for the service to stop by itself */ + do + { + Sleep(100); + ZeroMemory(&ServiceStatus, sizeof(ServiceStatus)); + res = QueryServiceStatus(hService, &ServiceStatus); + } while (res && ServiceStatus.dwCurrentState != SERVICE_STOPPED); + ok(res, "QueryServiceStatus failed: %lu\n", GetLastError()); + ok(ServiceStatus.dwCurrentState == SERVICE_STOPPED, "ServiceStatus.dwCurrentState = %lx\n", ServiceStatus.dwCurrentState); + + /* Be sure the service is really stopped */ + res = ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus); + if (!res && ServiceStatus.dwCurrentState != SERVICE_STOPPED && + ServiceStatus.dwCurrentState != SERVICE_STOP_PENDING && + GetLastError() != ERROR_SERVICE_NOT_ACTIVE) + { + skip("ControlService failed with error %lu!\n", GetLastError()); + goto Cleanup; + } + +#if 0 + trace("Service stopped. Going to restart it...\n"); + + /* Now change the service configuration to make it start under the NetworkService account */ + if (!ChangeServiceConfigW(hService, + SERVICE_NO_CHANGE, + SERVICE_NO_CHANGE, + SERVICE_NO_CHANGE, + NULL, NULL, NULL, NULL, + L"NT AUTHORITY\\NetworkService", L"", + NULL)) + { + skip("ChangeServiceConfigW failed with error %lu!\n", GetLastError()); + goto Cleanup; + } + + /* Start it */ + if (!StartServiceW(hService, 0, NULL)) + { + skip("StartServiceW failed with error %lu!\n", GetLastError()); + goto Cleanup; + } + + /* Wait for the service to stop by itself */ + do + { + Sleep(100); + ZeroMemory(&ServiceStatus, sizeof(ServiceStatus)); + res = QueryServiceStatus(hService, &ServiceStatus); + } while (res && ServiceStatus.dwCurrentState != SERVICE_STOPPED); + ok(res, "QueryServiceStatus failed: %lu\n", GetLastError()); + ok(ServiceStatus.dwCurrentState == SERVICE_STOPPED, "ServiceStatus.dwCurrentState = %lx\n", ServiceStatus.dwCurrentState); + + /* Be sure the service is really stopped */ + res = ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus); + if (!res && ServiceStatus.dwCurrentState != SERVICE_STOPPED && + ServiceStatus.dwCurrentState != SERVICE_STOP_PENDING && + GetLastError() != ERROR_SERVICE_NOT_ACTIVE) + { + skip("ControlService failed with error %lu!\n", GetLastError()); + goto Cleanup; + } +#endif + +Cleanup: + if (hService) + { + res = DeleteService(hService); + ok(res, "DeleteService failed: %lu\n", GetLastError()); + CloseServiceHandle(hService); + } + + if (hSC) + CloseServiceHandle(hSC); +} + +START_TEST(ServiceEnv) +{ + int argc; + char** argv; + + /* Check whether this test is started as a separated service process */ + argc = winetest_get_mainargs(&argv); + if (argc >= 3) + { + service_process(start_service, argc, argv); + return; + } + + /* We are started as the real test */ + test_runner(my_test_server, NULL); + // trace("Returned from test_runner\n"); +} Propchange: trunk/rostests/apitests/advapi32/ServiceEnv.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/rostests/apitests/advapi32/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/testlis…
============================================================================== --- trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] Mon Dec 5 16:36:06 2016 @@ -17,6 +17,7 @@ extern void func_RtlEncryptMemory(void); extern void func_SaferIdentifyLevel(void); extern void func_ServiceArgs(void); +extern void func_ServiceEnv(void); const struct test winetest_testlist[] = { @@ -34,6 +35,7 @@ { "RtlEncryptMemory", func_RtlEncryptMemory }, { "SaferIdentifyLevel", func_SaferIdentifyLevel }, { "ServiceArgs", func_ServiceArgs }, + { "ServiceEnv", func_ServiceEnv }, { 0, 0 } };
8 years
1
0
0
0
[hbelusca] 73430: [ADVAPI32_APITEST]: Add a small helper lib 'svchlp' for common routines for test-services embedded in api tests. Taken & heavily adapted from Jacek Caban's services_service test a...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon Dec 5 16:22:30 2016 New Revision: 73430 URL:
http://svn.reactos.org/svn/reactos?rev=73430&view=rev
Log: [ADVAPI32_APITEST]: Add a small helper lib 'svchlp' for common routines for test-services embedded in api tests. Taken & heavily adapted from Jacek Caban's services_service test and Thomas Faber's ServiceArgs.c (the latter will be able to use 'svchlp' when it'll be ready). CORE-12414 Added: trunk/rostests/apitests/advapi32/svchlp.c - copied, changed from r73429, trunk/rostests/apitests/advapi32/ServiceArgs.c trunk/rostests/apitests/advapi32/svchlp.h (with props) Modified: trunk/rostests/apitests/advapi32/CMakeLists.txt Modified: trunk/rostests/apitests/advapi32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/CMakeLi…
============================================================================== --- trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] Mon Dec 5 16:22:30 2016 @@ -14,6 +14,7 @@ RtlEncryptMemory.c SaferIdentifyLevel.c ServiceArgs.c + svchlp.c testlist.c) add_executable(advapi32_apitest ${SOURCE}) Copied: trunk/rostests/apitests/advapi32/svchlp.c (from r73429, trunk/rostests/apitests/advapi32/ServiceArgs.c) URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/svchlp.…
============================================================================== --- trunk/rostests/apitests/advapi32/ServiceArgs.c [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/svchlp.c [iso-8859-1] Mon Dec 5 16:22:30 2016 @@ -1,9 +1,16 @@ /* * PROJECT: ReactOS api tests * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory - * PURPOSE: Test for service arguments - * PROGRAMMER: Jacek Caban for CodeWeavers + * PURPOSE: Support helpers for embedded services inside api tests. + * PROGRAMMERS: Jacek Caban for CodeWeavers * Thomas Faber <thomas.faber(a)reactos.org> + * Hermes Belusca-Maito + * + * NOTE: Room for improvements: + * - One test_runner managing 1 pipe for 1 service process that is shared + * by multiple services of type SERVICE_WIN32_SHARE_PROCESS. + * - Find a way to elegantly determine the registered service name inside + * the service process, without really passing it */ #include <apitest.h> @@ -11,28 +18,25 @@ #include <winsvc.h> #include <strsafe.h> -static char **argv; -static int argc; - -static HANDLE pipe_handle = INVALID_HANDLE_VALUE; -static char service_nameA[100]; +static HANDLE hClientPipe = INVALID_HANDLE_VALUE; +static WCHAR named_pipe_name[100]; // Shared: FIXME! + +static CHAR service_nameA[100]; static WCHAR service_nameW[100]; -static WCHAR named_pipe_name[100]; - -/* Test process global variables */ -static SC_HANDLE scm_handle; -static SERVICE_STATUS_HANDLE service_handle; - -static void send_msg(const char *type, const char *msg) + + +/********** S E R V I C E ( C L I E N T ) M O D U L E S I D E *********/ + +void send_msg(const char *type, const char *msg) { DWORD written = 0; char buf[512]; StringCbPrintfA(buf, sizeof(buf), "%s:%s", type, msg); - WriteFile(pipe_handle, buf, strlen(buf)+1, &written, NULL); -} - -static inline void service_trace(const char *msg, ...) + WriteFile(hClientPipe, buf, strlen(buf)+1, &written, NULL); +} + +void service_trace(const char *msg, ...) { va_list valist; char buf[512]; @@ -44,10 +48,10 @@ send_msg("TRACE", buf); } -static void service_ok(int cnd, const char *msg, ...) -{ - va_list valist; - char buf[512]; +void service_ok(int cnd, const char *msg, ...) +{ + va_list valist; + char buf[512]; va_start(valist, msg); StringCbVPrintfA(buf, sizeof(buf), msg, valist); @@ -56,193 +60,81 @@ send_msg(cnd ? "OK" : "FAIL", buf); } -static VOID WINAPI service_handler(DWORD ctrl) -{ - SERVICE_STATUS status; - - status.dwServiceType = SERVICE_WIN32; - status.dwControlsAccepted = SERVICE_ACCEPT_STOP; - status.dwWin32ExitCode = 0; - status.dwServiceSpecificExitCode = 0; - status.dwCheckPoint = 0; - status.dwWaitHint = 0; - - switch(ctrl) - { - case SERVICE_CONTROL_STOP: - status.dwCurrentState = SERVICE_STOP_PENDING; - status.dwControlsAccepted = 0; - SetServiceStatus(service_handle, &status); - default: - status.dwCurrentState = SERVICE_RUNNING; - SetServiceStatus(service_handle, &status); - } -} - -static void service_main_common(void) -{ - SERVICE_STATUS status; +void service_process(BOOL (*start_service)(PCSTR, PCWSTR), int argc, char** argv) +{ BOOL res; - service_handle = RegisterServiceCtrlHandlerW(service_nameW, service_handler); - service_ok(service_handle != NULL, "RegisterServiceCtrlHandler failed: %lu\n", GetLastError()); - if (!service_handle) - return; - - status.dwServiceType = SERVICE_WIN32; - status.dwCurrentState = SERVICE_RUNNING; - status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; - status.dwWin32ExitCode = 0; - status.dwServiceSpecificExitCode = 0; - status.dwCheckPoint = 0; - status.dwWaitHint = 10000; - res = SetServiceStatus(service_handle, &status); - service_ok(res, "SetServiceStatus(SERVICE_RUNNING) failed: %lu", GetLastError()); - - Sleep(100); - - status.dwCurrentState = SERVICE_STOPPED; - status.dwControlsAccepted = 0; - res = SetServiceStatus(service_handle, &status); - service_ok(res, "SetServiceStatus(SERVICE_STOPPED) failed: %lu", GetLastError()); -} - -/* - * A/W argument layout XP/2003: - * [argv array of pointers][parameter 1][parameter 2]...[service name] - * - * A/W argument layout Vista: - * [argv array of pointers][align to 8 bytes][parameter 1][parameter 2]...[service name] - * - * A/W argument layout Win7/8: - * [argv array of pointers][service name] - * [parameter 1][align to 4 bytes][parameter 2][align to 4 bytes]... - * - * Space for parameters and service name is always enough to store - * the WCHAR version including null terminator. - */ - -static void WINAPI service_mainA(DWORD service_argc, char **service_argv) -{ - int i; - char *next_arg; - char *next_arg_aligned; - - service_ok(service_argc == argc - 3, "service_argc = %d, expected %d", service_argc, argc - 3); - if (service_argc == argc - 3) - { - service_ok(!strcmp(service_argv[0], service_nameA), "service_argv[0] = %s, expected %s", service_argv[0], service_nameA); - service_ok(service_argv[0] == (char *)&service_argv[service_argc] || - service_argv[1] == (char *)&service_argv[service_argc] || - service_argv[1] == (char *)(((ULONG_PTR)&service_argv[service_argc] + 7) & ~7), "service_argv[0] = %p, [1] = %p, expected one of them to be %p", service_argv[0], service_argv[1], &service_argv[service_argc]); - //service_trace("service_argv[0] = %p", service_argv[0]); - next_arg_aligned = next_arg = NULL; - for (i = 1; i < service_argc; i++) - { - //service_trace("service_argv[%d] = %p", i, service_argv[i]); - service_ok(!strcmp(service_argv[i], argv[i + 3]), "service_argv[%d] = %s, expected %s", i, service_argv[i], argv[i + 3]); - service_ok(next_arg == NULL || - service_argv[i] == next_arg || - service_argv[i] == next_arg_aligned, "service_argv[%d] = %p, expected %p or %p", i, service_argv[i], next_arg, next_arg_aligned); - next_arg = service_argv[i]; - next_arg += 2 * (strlen(next_arg) + 1); - next_arg_aligned = (char *)(((ULONG_PTR)next_arg + 3) & ~3); - } - } - - service_main_common(); -} - -static void WINAPI service_mainW(DWORD service_argc, WCHAR **service_argv) -{ - int i; - WCHAR argW[32]; - WCHAR *next_arg; - WCHAR *next_arg_aligned; - - service_ok(service_argc == argc - 3, "service_argc = %d, expected %d", service_argc, argc - 3); - if (service_argc == argc - 3) - { - service_ok(!wcscmp(service_argv[0], service_nameW), "service_argv[0] = %ls, expected %ls", service_argv[0], service_nameW); - service_ok(service_argv[0] == (WCHAR *)&service_argv[service_argc] || - service_argv[1] == (WCHAR *)&service_argv[service_argc] || - service_argv[1] == (WCHAR *)(((ULONG_PTR)&service_argv[service_argc] + 7) & ~7), "service_argv[0] = %p, [1] = %p, expected one of them to be %p", service_argv[0], service_argv[1], &service_argv[service_argc]); - //service_trace("service_argv[0] = %p", service_argv[0]); - next_arg_aligned = next_arg = NULL; - for (i = 1; i < service_argc; i++) - { - //service_trace("service_argv[%d] = %p", i, service_argv[i]); - MultiByteToWideChar(CP_ACP, 0, argv[i + 3], -1, argW, _countof(argW)); - service_ok(!wcscmp(service_argv[i], argW), "service_argv[%d] = %ls, expected %ls", i, service_argv[i], argW); - service_ok(next_arg == NULL || - service_argv[i] == next_arg || - service_argv[i] == next_arg_aligned, "service_argv[%d] = %p, expected %p or %p", i, service_argv[i], next_arg, next_arg_aligned); - next_arg = service_argv[i]; - next_arg += wcslen(next_arg) + 1; - next_arg_aligned = (WCHAR *)(((ULONG_PTR)next_arg + 3) & ~3); - } - } - - service_main_common(); -} - -static void service_process(BOOLEAN unicode) -{ - BOOL res; - - SERVICE_TABLE_ENTRYA servtblA[] = - { - { service_nameA, service_mainA }, - { NULL, NULL } - }; - SERVICE_TABLE_ENTRYW servtblW[] = - { - { service_nameW, service_mainW }, - { NULL, NULL } - }; + StringCbCopyA(service_nameA, sizeof(service_nameA), argv[2]); + MultiByteToWideChar(CP_ACP, 0, service_nameA, -1, service_nameW, _countof(service_nameW)); + StringCbPrintfW(named_pipe_name, sizeof(named_pipe_name), L"\\\\.\\pipe\\%ls_pipe", service_nameW); res = WaitNamedPipeW(named_pipe_name, NMPWAIT_USE_DEFAULT_WAIT); if (!res) return; - pipe_handle = CreateFileW(named_pipe_name, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (pipe_handle == INVALID_HANDLE_VALUE) + hClientPipe = CreateFileW(named_pipe_name, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hClientPipe == INVALID_HANDLE_VALUE) return; - //service_trace("Starting..."); - if (unicode) - { - res = StartServiceCtrlDispatcherW(servtblW); - service_ok(res, "StartServiceCtrlDispatcherW failed: %lu\n", GetLastError()); - } - else - { - res = StartServiceCtrlDispatcherA(servtblA); - service_ok(res, "StartServiceCtrlDispatcherA failed: %lu\n", GetLastError()); - } - - CloseHandle(pipe_handle); -} - -static SC_HANDLE register_service(PCWSTR extra_args) -{ - WCHAR service_cmd[MAX_PATH+150]; + service_trace("Service process starting...\n"); + res = start_service(service_nameA, service_nameW); + service_trace("Service process stopped.\n"); + + CloseHandle(hClientPipe); +} + + +/*********** T E S T E R ( S E R V E R ) M O D U L E S I D E **********/ + +SC_HANDLE register_service_exA( + SC_HANDLE scm_handle, + PCSTR test_name, + PCSTR service_name, // LPCSTR lpServiceName, + PCSTR extra_args OPTIONAL, + DWORD dwDesiredAccess, + DWORD dwServiceType, + DWORD dwStartType, + DWORD dwErrorControl, + LPCSTR lpLoadOrderGroup OPTIONAL, + LPDWORD lpdwTagId OPTIONAL, + LPCSTR lpDependencies OPTIONAL, + LPCSTR lpServiceStartName OPTIONAL, + LPCSTR lpPassword OPTIONAL) +{ SC_HANDLE service; - - GetModuleFileNameW(NULL, service_cmd, MAX_PATH); - - StringCbCatW(service_cmd, sizeof(service_cmd), L" ServiceArgs "); - StringCbCatW(service_cmd, sizeof(service_cmd), service_nameW); - StringCbCatW(service_cmd, sizeof(service_cmd), extra_args); - - trace("service_cmd \"%ls\"\n", service_cmd); - - service = CreateServiceW(scm_handle, service_nameW, service_nameW, GENERIC_ALL, - SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START, SERVICE_ERROR_IGNORE, - service_cmd, NULL, NULL, NULL, NULL, NULL); + CHAR service_cmd[MAX_PATH+150]; + + /* Retrieve our full path */ + if (!GetModuleFileNameA(NULL, service_cmd, MAX_PATH)) + { + skip("GetModuleFileNameW failed with error %lu!\n", GetLastError()); + return NULL; + } + + /* + * Build up our custom command line. The first parameter is the test name, + * the second parameter is the flag used to decide whether we should start + * as a service. + */ + StringCbCatA(service_cmd, sizeof(service_cmd), " "); + StringCbCatA(service_cmd, sizeof(service_cmd), test_name); + StringCbCatA(service_cmd, sizeof(service_cmd), " "); + StringCbCatA(service_cmd, sizeof(service_cmd), service_name); + if (extra_args) + { + StringCbCatA(service_cmd, sizeof(service_cmd), " "); + StringCbCatA(service_cmd, sizeof(service_cmd), extra_args); + } + + trace("service_cmd \"%s\"\n", service_cmd); + + service = CreateServiceA(scm_handle, service_name, service_name, + dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl, + service_cmd, lpLoadOrderGroup, lpdwTagId, lpDependencies, + lpServiceStartName, lpPassword); if (!service && GetLastError() == ERROR_ACCESS_DENIED) { - skip("Not enough access right to create service\n"); + skip("Not enough access right to create service.\n"); return NULL; } @@ -250,36 +142,124 @@ return service; } -static DWORD WINAPI pipe_thread(void *arg) -{ - char buf[512]; +SC_HANDLE register_service_exW( + SC_HANDLE scm_handle, + PCWSTR test_name, + PCWSTR service_name, // LPCWSTR lpServiceName, + PCWSTR extra_args OPTIONAL, + DWORD dwDesiredAccess, + DWORD dwServiceType, + DWORD dwStartType, + DWORD dwErrorControl, + LPCWSTR lpLoadOrderGroup OPTIONAL, + LPDWORD lpdwTagId OPTIONAL, + LPCWSTR lpDependencies OPTIONAL, + LPCWSTR lpServiceStartName OPTIONAL, + LPCWSTR lpPassword OPTIONAL) +{ + SC_HANDLE service; + WCHAR service_cmd[MAX_PATH+150]; + + /* Retrieve our full path */ + if (!GetModuleFileNameW(NULL, service_cmd, MAX_PATH)) + { + skip("GetModuleFileNameW failed with error %lu!\n", GetLastError()); + return NULL; + } + + /* + * Build up our custom command line. The first parameter is the test name, + * the second parameter is the flag used to decide whether we should start + * as a service. + */ + StringCbCatW(service_cmd, sizeof(service_cmd), L" "); + StringCbCatW(service_cmd, sizeof(service_cmd), test_name); + StringCbCatW(service_cmd, sizeof(service_cmd), L" "); + StringCbCatW(service_cmd, sizeof(service_cmd), service_name); + if (extra_args) + { + StringCbCatW(service_cmd, sizeof(service_cmd), L" "); + StringCbCatW(service_cmd, sizeof(service_cmd), extra_args); + } + + trace("service_cmd \"%ls\"\n", service_cmd); + + service = CreateServiceW(scm_handle, service_name, service_name, + dwDesiredAccess, dwServiceType, dwStartType, dwErrorControl, + service_cmd, lpLoadOrderGroup, lpdwTagId, lpDependencies, + lpServiceStartName, lpPassword); + if (!service && GetLastError() == ERROR_ACCESS_DENIED) + { + skip("Not enough access right to create service.\n"); + return NULL; + } + + ok(service != NULL, "CreateService failed: %lu\n", GetLastError()); + return service; +} + +SC_HANDLE register_serviceA( + SC_HANDLE scm_handle, + PCSTR test_name, + PCSTR service_name, + PCSTR extra_args OPTIONAL) +{ + return register_service_exA(scm_handle, test_name, service_name, extra_args, + SERVICE_ALL_ACCESS, + SERVICE_WIN32_OWN_PROCESS, + SERVICE_DEMAND_START, + SERVICE_ERROR_IGNORE, + NULL, NULL, NULL, NULL, NULL); +} + +SC_HANDLE register_serviceW( + SC_HANDLE scm_handle, + PCWSTR test_name, + PCWSTR service_name, + PCWSTR extra_args OPTIONAL) +{ + return register_service_exW(scm_handle, test_name, service_name, extra_args, + SERVICE_ALL_ACCESS, + SERVICE_WIN32_OWN_PROCESS, + SERVICE_DEMAND_START, + SERVICE_ERROR_IGNORE, + NULL, NULL, NULL, NULL, NULL); +} + +static DWORD WINAPI pipe_thread(void *param) +{ + HANDLE hServerPipe = (HANDLE)param; DWORD read; BOOL res; - - res = ConnectNamedPipe(pipe_handle, NULL); + char buf[512]; + + // printf("pipe_thread -- ConnectNamedPipe...\n"); + res = ConnectNamedPipe(hServerPipe, NULL); ok(res || GetLastError() == ERROR_PIPE_CONNECTED, "ConnectNamedPipe failed: %lu\n", GetLastError()); + // printf("pipe_thread -- ConnectNamedPipe ok\n"); while (1) { - res = ReadFile(pipe_handle, buf, sizeof(buf), &read, NULL); + res = ReadFile(hServerPipe, buf, sizeof(buf), &read, NULL); if (!res) { ok(GetLastError() == ERROR_BROKEN_PIPE || GetLastError() == ERROR_INVALID_HANDLE, "ReadFile failed: %lu\n", GetLastError()); + // printf("pipe_thread -- break loop\n"); break; } if (!strncmp(buf, "TRACE:", 6)) { - trace("service trace: %s\n", buf+6); + trace("service trace: %s", buf+6); } else if (!strncmp(buf, "OK:", 3)) { - ok(1, "service: %s\n", buf+3); + ok(1, "service: %s", buf+3); } else if (!strncmp(buf, "FAIL:", 5)) { - ok(0, "service: %s\n", buf+5); + ok(0, "service: %s", buf+5); } else { @@ -287,189 +267,52 @@ } } - DisconnectNamedPipe(pipe_handle); - //trace("pipe disconnected\n"); + // printf("pipe_thread -- DisconnectNamedPipe\n"); + + /* + * Flush the pipe to allow the client to read + * the pipe's contents before disconnecting. + */ + FlushFileBuffers(hServerPipe); + + DisconnectNamedPipe(hServerPipe); + trace("pipe disconnected\n"); return 0; } -static void test_startA(SC_HANDLE service_handle, int service_argc, const char **service_argv) -{ - SERVICE_STATUS status; - BOOL res; - - res = StartServiceA(service_handle, service_argc, service_argv); - ok(res, "StartService failed: %lu\n", GetLastError()); - if (!res) - return; - - do - { - Sleep(100); - ZeroMemory(&status, sizeof(status)); - res = QueryServiceStatus(service_handle, &status); - } while (res && status.dwCurrentState != SERVICE_STOPPED); - ok(res, "QueryServiceStatus failed: %lu\n", GetLastError()); - ok(status.dwCurrentState == SERVICE_STOPPED, "status.dwCurrentState = %lx\n", status.dwCurrentState); -} - -static void test_startW(SC_HANDLE service_handle, int service_argc, const WCHAR **service_argv) -{ - SERVICE_STATUS status; - BOOL res; - - res = StartServiceW(service_handle, service_argc, service_argv); - ok(res, "StartService failed: %lu\n", GetLastError()); - if (!res) - return; - - do - { - Sleep(100); - ZeroMemory(&status, sizeof(status)); - res = QueryServiceStatus(service_handle, &status); - } while (res && status.dwCurrentState != SERVICE_STOPPED); - ok(res, "QueryServiceStatus failed: %lu\n", GetLastError()); - ok(status.dwCurrentState == SERVICE_STOPPED, "status.dwCurrentState = %lx\n", status.dwCurrentState); -} - -static void test_runner(BOOLEAN unicode, PCWSTR extra_args, int service_argc, void *service_argv) -{ - HANDLE thread; - SC_HANDLE service_handle; - BOOL res; +void test_runner(void (*run_test)(PCSTR, PCWSTR, void*), void *param) +{ + HANDLE hServerPipe = INVALID_HANDLE_VALUE; + HANDLE hThread; StringCbPrintfW(service_nameW, sizeof(service_nameW), L"WineTestService%lu", GetTickCount()); WideCharToMultiByte(CP_ACP, 0, service_nameW, -1, service_nameA, _countof(service_nameA), NULL, NULL); //trace("service_name: %ls\n", service_nameW); StringCbPrintfW(named_pipe_name, sizeof(named_pipe_name), L"\\\\.\\pipe\\%ls_pipe", service_nameW); - pipe_handle = CreateNamedPipeW(named_pipe_name, PIPE_ACCESS_INBOUND, + hServerPipe = CreateNamedPipeW(named_pipe_name, PIPE_ACCESS_INBOUND, PIPE_TYPE_MESSAGE|PIPE_READMODE_MESSAGE|PIPE_WAIT, 10, 2048, 2048, 10000, NULL); - ok(pipe_handle != INVALID_HANDLE_VALUE, "CreateNamedPipe failed: %lu\n", GetLastError()); - if (pipe_handle == INVALID_HANDLE_VALUE) + ok(hServerPipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed: %lu\n", GetLastError()); + if (hServerPipe == INVALID_HANDLE_VALUE) return; - thread = CreateThread(NULL, 0, pipe_thread, NULL, 0, NULL); - ok(thread != NULL, "CreateThread failed: %lu\n", GetLastError()); - if (!thread) - return; - - service_handle = register_service(extra_args); - if (!service_handle) - return; - - //trace("starting...\n"); - - if (unicode) - test_startW(service_handle, service_argc, service_argv); - else - test_startA(service_handle, service_argc, service_argv); - - res = DeleteService(service_handle); - ok(res, "DeleteService failed: %lu\n", GetLastError()); - - CloseServiceHandle(service_handle); - - ok(WaitForSingleObject(thread, 10000) == WAIT_OBJECT_0, "Timeout waiting for thread\n"); - CloseHandle(thread); - CloseHandle(pipe_handle); -} - -START_TEST(ServiceArgs) -{ - argc = winetest_get_mainargs(&argv); - - scm_handle = OpenSCManagerW(NULL, NULL, GENERIC_ALL); - ok(scm_handle != NULL, "OpenSCManager failed: %lu\n", GetLastError()); - if (!scm_handle) - { - skip("Failed to open service control manager. Skipping test\n"); - return; - } - - if (argc < 3) - { - char *service_argvA[10]; - WCHAR *service_argvW[10]; - - test_runner(FALSE, L" A", 0, NULL); - test_runner(FALSE, L" W", 0, NULL); - test_runner(TRUE, L" A", 0, NULL); - test_runner(TRUE, L" W", 0, NULL); - - service_argvA[0] = "x"; - service_argvW[0] = L"x"; - test_runner(FALSE, L" A x", 1, service_argvA); - test_runner(FALSE, L" W x", 1, service_argvA); - test_runner(TRUE, L" A x", 1, service_argvW); - test_runner(TRUE, L" W x", 1, service_argvW); - - service_argvA[1] = "y"; - service_argvW[1] = L"y"; - test_runner(FALSE, L" A x y", 2, service_argvA); - test_runner(FALSE, L" W x y", 2, service_argvA); - test_runner(TRUE, L" A x y", 2, service_argvW); - test_runner(TRUE, L" W x y", 2, service_argvW); - - service_argvA[0] = "ab"; - service_argvW[0] = L"ab"; - test_runner(FALSE, L" A ab y", 2, service_argvA); - test_runner(FALSE, L" W ab y", 2, service_argvA); - test_runner(TRUE, L" A ab y", 2, service_argvW); - test_runner(TRUE, L" W ab y", 2, service_argvW); - - service_argvA[0] = "abc"; - service_argvW[0] = L"abc"; - test_runner(FALSE, L" A abc y", 2, service_argvA); - test_runner(FALSE, L" W abc y", 2, service_argvA); - test_runner(TRUE, L" A abc y", 2, service_argvW); - test_runner(TRUE, L" W abc y", 2, service_argvW); - - service_argvA[0] = "abcd"; - service_argvW[0] = L"abcd"; - test_runner(FALSE, L" A abcd y", 2, service_argvA); - test_runner(FALSE, L" W abcd y", 2, service_argvA); - test_runner(TRUE, L" A abcd y", 2, service_argvW); - test_runner(TRUE, L" W abcd y", 2, service_argvW); - - service_argvA[0] = "abcde"; - service_argvW[0] = L"abcde"; - test_runner(FALSE, L" A abcde y", 2, service_argvA); - test_runner(FALSE, L" W abcde y", 2, service_argvA); - test_runner(TRUE, L" A abcde y", 2, service_argvW); - test_runner(TRUE, L" W abcde y", 2, service_argvW); - - service_argvA[0] = "abcdef"; - service_argvW[0] = L"abcdef"; - test_runner(FALSE, L" A abcdef y", 2, service_argvA); - test_runner(FALSE, L" W abcdef y", 2, service_argvA); - test_runner(TRUE, L" A abcdef y", 2, service_argvW); - test_runner(TRUE, L" W abcdef y", 2, service_argvW); - - service_argvA[0] = "abcdefg"; - service_argvW[0] = L"abcdefg"; - test_runner(FALSE, L" A abcdefg y", 2, service_argvA); - test_runner(FALSE, L" W abcdefg y", 2, service_argvA); - test_runner(TRUE, L" A abcdefg y", 2, service_argvW); - test_runner(TRUE, L" W abcdefg y", 2, service_argvW); - - service_argvA[0] = ""; - service_argvW[0] = L""; - test_runner(FALSE, L" A \"\" y", 2, service_argvA); - test_runner(FALSE, L" W \"\" y", 2, service_argvA); - test_runner(TRUE, L" A \"\" y", 2, service_argvW); - test_runner(TRUE, L" W \"\" y", 2, service_argvW); - } - else - { - strcpy(service_nameA, argv[2]); - MultiByteToWideChar(CP_ACP, 0, service_nameA, -1, service_nameW, _countof(service_nameW)); - StringCbPrintfW(named_pipe_name, sizeof(named_pipe_name), L"\\\\.\\pipe\\%ls_pipe", service_nameW); - if (!strcmp(argv[3], "A")) - service_process(FALSE); - else - service_process(TRUE); - } - - CloseServiceHandle(scm_handle); -} + hThread = CreateThread(NULL, 0, pipe_thread, (LPVOID)hServerPipe, 0, NULL); + ok(hThread != NULL, "CreateThread failed: %lu\n", GetLastError()); + if (!hThread) + goto Quit; + + run_test(service_nameA, service_nameW, param); + + ok(WaitForSingleObject(hThread, 10000) == WAIT_OBJECT_0, "Timeout waiting for thread\n"); + +Quit: + if (hThread) + { + /* Be sure to kill the thread if it did not already terminate */ + TerminateThread(hThread, 0); + CloseHandle(hThread); + } + + if (hServerPipe != INVALID_HANDLE_VALUE) + CloseHandle(hServerPipe); +} Added: trunk/rostests/apitests/advapi32/svchlp.h URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/svchlp.…
============================================================================== --- trunk/rostests/apitests/advapi32/svchlp.h (added) +++ trunk/rostests/apitests/advapi32/svchlp.h [iso-8859-1] Mon Dec 5 16:22:30 2016 @@ -0,0 +1,73 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory + * PURPOSE: Support helpers for embedded services inside api tests. + * PROGRAMMERS: Jacek Caban for CodeWeavers + * Thomas Faber <thomas.faber(a)reactos.org> + * Hermes Belusca-Maito + */ + +// #include <apitest.h> + + +/********** S E R V I C E ( C L I E N T ) M O D U L E S I D E *********/ + +void send_msg(const char *type, const char *msg); +void service_trace(const char *msg, ...); +void service_ok(int cnd, const char *msg, ...); +void service_process(BOOL (*start_service)(PCSTR, PCWSTR), int argc, char** argv); + + +/*********** T E S T E R ( S E R V E R ) M O D U L E S I D E **********/ + +SC_HANDLE register_service_exA( + SC_HANDLE scm_handle, + PCSTR test_name, + PCSTR service_name, // LPCSTR lpServiceName, + PCSTR extra_args OPTIONAL, + DWORD dwDesiredAccess, + DWORD dwServiceType, + DWORD dwStartType, + DWORD dwErrorControl, + LPCSTR lpLoadOrderGroup OPTIONAL, + LPDWORD lpdwTagId OPTIONAL, + LPCSTR lpDependencies OPTIONAL, + LPCSTR lpServiceStartName OPTIONAL, + LPCSTR lpPassword OPTIONAL); + +SC_HANDLE register_service_exW( + SC_HANDLE scm_handle, + PCWSTR test_name, + PCWSTR service_name, // LPCWSTR lpServiceName, + PCWSTR extra_args OPTIONAL, + DWORD dwDesiredAccess, + DWORD dwServiceType, + DWORD dwStartType, + DWORD dwErrorControl, + LPCWSTR lpLoadOrderGroup OPTIONAL, + LPDWORD lpdwTagId OPTIONAL, + LPCWSTR lpDependencies OPTIONAL, + LPCWSTR lpServiceStartName OPTIONAL, + LPCWSTR lpPassword OPTIONAL); + +SC_HANDLE register_serviceA( + SC_HANDLE scm_handle, + PCSTR test_name, + PCSTR service_name, + PCSTR extra_args OPTIONAL); + +SC_HANDLE register_serviceW( + SC_HANDLE scm_handle, + PCWSTR test_name, + PCWSTR service_name, + PCWSTR extra_args OPTIONAL); + +#ifdef UNICODE +#define register_service_ex register_service_exW +#define register_service register_serviceW +#else +#define register_service_ex register_service_exA +#define register_service register_serviceA +#endif + +void test_runner(void (*run_test)(PCSTR, PCWSTR, void*), void *param); Propchange: trunk/rostests/apitests/advapi32/svchlp.h ------------------------------------------------------------------------------ svn:eol-style = native
8 years
1
0
0
0
[spetreolle] 73429: [BROWSEUI] Fix CShellBrowser window class name, shown by shell32:progman_dde and AHK_Diablo_1.0:1.install
by spetreolle@svn.reactos.org
Author: spetreolle Date: Sun Dec 4 23:33:19 2016 New Revision: 73429 URL:
http://svn.reactos.org/svn/reactos?rev=73429&view=rev
Log: [BROWSEUI] Fix CShellBrowser window class name, shown by shell32:progman_dde and AHK_Diablo_1.0:1.install Modified: trunk/reactos/dll/win32/browseui/shellbrowser.cpp Modified: trunk/reactos/dll/win32/browseui/shellbrowser.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/browseui/shellbr…
============================================================================== --- trunk/reactos/dll/win32/browseui/shellbrowser.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/browseui/shellbrowser.cpp [iso-8859-1] Sun Dec 4 23:33:19 2016 @@ -166,8 +166,8 @@ return desktop->BindToObject (path, NULL, IID_PPV_ARG(IShellFolder, newFolder)); } -static const TCHAR szCabinetWndClass[] = TEXT("CabinetWClassX"); -static const TCHAR szExploreWndClass[] = TEXT("ExploreWClassX"); +static const TCHAR szCabinetWndClass[] = TEXT("CabinetWClass"); +static const TCHAR szExploreWndClass[] = TEXT("ExploreWClass"); class CDockManager; class CShellBrowser;
8 years
1
0
0
0
[hbelusca] 73428: [NTDLL]: Export _wcstoui64 (as done in Win2k3). Prototype from msvcrt. CORE-12534
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sun Dec 4 22:52:03 2016 New Revision: 73428 URL:
http://svn.reactos.org/svn/reactos?rev=73428&view=rev
Log: [NTDLL]: Export _wcstoui64 (as done in Win2k3). Prototype from msvcrt. CORE-12534 Modified: trunk/reactos/dll/ntdll/def/ntdll.spec Modified: trunk/reactos/dll/ntdll/def/ntdll.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/def/ntdll.spec?r…
============================================================================== --- trunk/reactos/dll/ntdll/def/ntdll.spec [iso-8859-1] (original) +++ trunk/reactos/dll/ntdll/def/ntdll.spec [iso-8859-1] Sun Dec 4 22:52:03 2016 @@ -1325,7 +1325,7 @@ 1312 cdecl _wcsicmp(wstr wstr) 1313 cdecl _wcslwr(wstr) 1314 cdecl _wcsnicmp(wstr wstr long) -# _wcstoui64 +1315 cdecl _wcstoui64(wstr ptr long) 1316 cdecl _wcsupr(wstr) 1317 cdecl _wtoi(wstr) 1318 cdecl _wtoi64(wstr)
8 years
1
0
0
0
[hbelusca] 73427: [NTDLL]: Add proper stubs for EtwpGetTraceBuffer and EtwpSetHWConfigFunction, needed for CORE-12534. [NTDLL][ADVAPI32]: Improve the prototypes for EtwReceiveNotificationsA/WmiRece...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sun Dec 4 22:44:37 2016 New Revision: 73427 URL:
http://svn.reactos.org/svn/reactos?rev=73427&view=rev
Log: [NTDLL]: Add proper stubs for EtwpGetTraceBuffer and EtwpSetHWConfigFunction, needed for CORE-12534. [NTDLL][ADVAPI32]: Improve the prototypes for EtwReceiveNotificationsA/WmiReceiveNotificationsA and EtwReceiveNotificationsW/WmiReceiveNotificationsW. Modified: trunk/reactos/dll/ntdll/def/ntdll.spec trunk/reactos/dll/win32/advapi32/advapi32.spec Modified: trunk/reactos/dll/ntdll/def/ntdll.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/def/ntdll.spec?r…
============================================================================== --- trunk/reactos/dll/ntdll/def/ntdll.spec [iso-8859-1] (original) +++ trunk/reactos/dll/ntdll/def/ntdll.spec [iso-8859-1] Sun Dec 4 22:44:37 2016 @@ -59,8 +59,8 @@ 59 stdcall EtwQueryAllTracesW(ptr long ptr) 60 stdcall -stub EtwQueryTraceA(double str ptr) 61 stdcall -stub EtwQueryTraceW(double wstr ptr) -62 stdcall -stub EtwReceiveNotificationsA() # FIXME prototype -63 stdcall -stub EtwReceiveNotificationsW() # FIXME prototype +62 stdcall -stub EtwReceiveNotificationsA(long long long long) +63 stdcall -stub EtwReceiveNotificationsW(long long long long) 64 stdcall EtwRegisterTraceGuidsA(ptr ptr ptr long ptr str str ptr) 65 stdcall EtwRegisterTraceGuidsW(ptr ptr ptr long ptr wstr wstr ptr) 66 stdcall EtwStartTraceA(ptr str ptr) @@ -74,8 +74,8 @@ 74 stdcall EtwUnregisterTraceGuids(double) 75 stdcall -stub EtwUpdateTraceA(double str ptr) 76 stdcall -stub EtwUpdateTraceW(double wstr ptr) -# EtwpGetTraceBuffer -# EtwpSetHWConfigFunction +77 stdcall -stub EtwpGetTraceBuffer(long long long long) +78 stdcall -stub EtwpSetHWConfigFunction(ptr long) 79 stdcall -arch=i386 KiFastSystemCall() 80 stdcall -arch=i386 KiFastSystemCallRet() 81 stdcall -arch=i386 KiIntSystemCall() Modified: trunk/reactos/dll/win32/advapi32/advapi32.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/advapi3…
============================================================================== --- trunk/reactos/dll/win32/advapi32/advapi32.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/advapi32.spec [iso-8859-1] Sun Dec 4 22:44:37 2016 @@ -674,8 +674,8 @@ 674 stub WmiQuerySingleInstanceMultipleA 675 stub WmiQuerySingleInstanceMultipleW 676 stub WmiQuerySingleInstanceW -677 stdcall WmiReceiveNotificationsA() ntdll.EtwReceiveNotificationsA # FIXME prototype -678 stdcall WmiReceiveNotificationsW() ntdll.EtwReceiveNotificationsW # FIXME prototype +677 stdcall WmiReceiveNotificationsA(long long long long) ntdll.EtwReceiveNotificationsA +678 stdcall WmiReceiveNotificationsW(long long long long) ntdll.EtwReceiveNotificationsW 679 stub WmiSetSingleInstanceA 680 stub WmiSetSingleInstanceW 681 stub WmiSetSingleItemA
8 years
1
0
0
0
[hbelusca] 73426: [ADVAPI32_APITEST]: Rename the 'LockDatabase' test to 'LockServiceDatabase' to better match the name of the API.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sun Dec 4 18:41:46 2016 New Revision: 73426 URL:
http://svn.reactos.org/svn/reactos?rev=73426&view=rev
Log: [ADVAPI32_APITEST]: Rename the 'LockDatabase' test to 'LockServiceDatabase' to better match the name of the API. Added: trunk/rostests/apitests/advapi32/LockServiceDatabase.c - copied, changed from r73425, trunk/rostests/apitests/advapi32/LockDatabase.c Removed: trunk/rostests/apitests/advapi32/LockDatabase.c Modified: trunk/rostests/apitests/advapi32/CMakeLists.txt trunk/rostests/apitests/advapi32/testlist.c Modified: trunk/rostests/apitests/advapi32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/CMakeLi…
============================================================================== --- trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] Sun Dec 4 18:41:46 2016 @@ -5,7 +5,7 @@ eventlog.c HKEY_CLASSES_ROOT.c IsTextUnicode.c - LockDatabase.c + LockServiceDatabase.c QueryServiceConfig2.c RegEnumKey.c RegEnumValueW.c Removed: trunk/rostests/apitests/advapi32/LockDatabase.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/LockDat…
============================================================================== --- trunk/rostests/apitests/advapi32/LockDatabase.c [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/LockDatabase.c (removed) @@ -1,761 +0,0 @@ -/* - * PROJECT: ReactOS api tests - * LICENSE: GPLv2+ - See COPYING in the top level directory - * PURPOSE: Tests for Lock/UnlockServiceDatabase and QueryServiceLockStatusA/W - * PROGRAMMER: Hermès BÃLUSCA - MAÃTO - */ - -#include <apitest.h> - -#include <winsvc.h> -#include <strsafe.h> - -#define TESTING_SERVICE L"Spooler" - -static void Test_LockUnlockServiceDatabase(void) -{ - BOOL bError = FALSE; - - SC_HANDLE hScm = NULL; - SC_LOCK hLock = NULL; - - /* First of all, try to lock / unlock the services database with invalid handles */ - SetLastError(0xdeadbeef); - hScm = NULL; - hLock = LockServiceDatabase(hScm); - ok(hLock == NULL, "hLock = 0x%p, expected 0\n", hLock); - ok_err(ERROR_INVALID_HANDLE); - - SetLastError(0xdeadbeef); - hScm = (SC_HANDLE)0xdeadbeef; - hLock = LockServiceDatabase(hScm); - ok(hLock == NULL, "hLock = 0x%p, expected 0\n", hLock); - ok_err(ERROR_INVALID_HANDLE); - -/** This test seems to make this application crash on Windows 7... I do not know why... **/ - SetLastError(0xdeadbeef); - hLock = NULL; - bError = UnlockServiceDatabase(hLock); - ok(bError == FALSE, "bError = %u, expected FALSE\n", bError); - ok_err(ERROR_INVALID_SERVICE_LOCK); -/*****************************************************************************************/ - - SetLastError(0xdeadbeef); - hLock = (SC_LOCK)0xdeadbeef; - bError = UnlockServiceDatabase(hLock); - ok(bError == FALSE, "bError = %u, expected FALSE\n", bError); - ok_err(ERROR_INVALID_SERVICE_LOCK); - - - /* Then, try to lock the services database without having rights */ - SetLastError(0xdeadbeef); - hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT); - ok(hScm != NULL, "Failed to open service manager, error=0x%08lx\n", GetLastError()); - if (!hScm) - { - skip("No service control manager; cannot proceed with LockUnlockServiceDatabase test\n"); - goto cleanup; - } - ok_err(ERROR_SUCCESS); - - SetLastError(0xdeadbeef); - hLock = LockServiceDatabase(hScm); - ok(hLock == NULL, "hLock = 0x%p, expected 0\n", hLock); - ok_err(ERROR_ACCESS_DENIED); - - if (hLock) - UnlockServiceDatabase(hLock); - CloseServiceHandle(hScm); - - /* Try to lock the services database with good rights */ - SetLastError(0xdeadbeef); - hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_LOCK); - ok(hScm != NULL, "Failed to open service manager, error=0x%08lx\n", GetLastError()); - if (!hScm) - { - skip("No service control manager; cannot proceed with LockUnlockServiceDatabase test\n"); - goto cleanup; - } - ok_err(ERROR_SUCCESS); - - SetLastError(0xdeadbeef); - hLock = LockServiceDatabase(hScm); - ok(hLock != NULL, "hLock = 0x%p, expected non-zero\n", hLock); - ok_err(ERROR_SUCCESS); - - /* Now unlock it */ - if (hLock) - { - SetLastError(0xdeadbeef); - bError = UnlockServiceDatabase(hLock); - ok(bError == TRUE, "bError = %u, expected TRUE\n", bError); - ok_err(ERROR_SUCCESS); - } - - -cleanup: - if (hScm) - CloseServiceHandle(hScm); - - return; -} - -static void Test_LockUnlockServiceDatabaseWithServiceStart(void) -{ - BOOL bError = FALSE; - - SC_HANDLE hScm = NULL; - SC_HANDLE hSvc = NULL; - SC_LOCK hLock = NULL; - - LPQUERY_SERVICE_CONFIGW lpConfig = NULL; - DWORD dwRequiredSize = 0; - SERVICE_STATUS status; - BOOL bWasRunning = FALSE; - DWORD dwOldStartType = 0; - - /* Open the services database */ - SetLastError(0xdeadbeef); - hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_LOCK); - ok(hScm != NULL, "Failed to open service manager, error=0x%08lx\n", GetLastError()); - if (!hScm) - { - skip("No service control manager; cannot proceed with LockUnlockServiceDatabaseWithServiceStart test\n"); - goto cleanup; - } - ok_err(ERROR_SUCCESS); - - /* Grab a handle to the testing service */ - SetLastError(0xdeadbeef); - hSvc = OpenServiceW(hScm, TESTING_SERVICE, SERVICE_START | SERVICE_STOP | SERVICE_CHANGE_CONFIG | SERVICE_QUERY_CONFIG | SERVICE_QUERY_STATUS); - ok(hSvc != NULL, "hSvc = 0x%p, expected non-null, error=0x%08lx\n", hSvc, GetLastError()); - if (!hSvc) - { - skip("Cannot open a handle to service %S; cannot proceed with LockUnlockServiceDatabaseWithServiceStart test\n", TESTING_SERVICE); - goto cleanup; - } - ok_err(ERROR_SUCCESS); - - /* Lock the services database */ - SetLastError(0xdeadbeef); - hLock = LockServiceDatabase(hScm); - ok(hLock != NULL, "hLock = 0x%p, expected non-zero, error=0x%08lx\n", hLock, GetLastError()); - if (!hLock) - { - skip("Cannot lock the services database; cannot proceed with LockUnlockServiceDatabaseWithServiceStart test\n"); - goto cleanup; - } - ok_err(ERROR_SUCCESS); - - /* To proceed further, firstly attempt to stop the testing service */ - QueryServiceConfigW(hSvc, NULL, 0, &dwRequiredSize); - lpConfig = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwRequiredSize); - QueryServiceConfigW(hSvc, lpConfig, dwRequiredSize, &dwRequiredSize); - dwOldStartType = lpConfig->dwStartType; - HeapFree(GetProcessHeap(), 0, lpConfig); - if (dwOldStartType == SERVICE_DISABLED) - { - ChangeServiceConfigW(hSvc, - SERVICE_NO_CHANGE, - SERVICE_DEMAND_START, - SERVICE_NO_CHANGE, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL); - } - QueryServiceStatus(hSvc, &status); - bWasRunning = (status.dwCurrentState != SERVICE_STOPPED); - if (bWasRunning) - { - ControlService(hSvc, SERVICE_CONTROL_STOP, &status); - Sleep(1000); /* Wait 1 second for the service to stop */ - } - - /* Now try to start it (this test won't work under Windows Vista / 7 / 8) */ - SetLastError(0xdeadbeef); - bError = StartServiceW(hSvc, 0, NULL); - ok(bError == FALSE, "bError = %u, expected FALSE\n", bError); - ok_err(ERROR_SERVICE_DATABASE_LOCKED); - Sleep(1000); /* Wait 1 second for the service to start */ - - /* Stop the testing service */ - ControlService(hSvc, SERVICE_CONTROL_STOP, &status); - Sleep(1000); /* Wait 1 second for the service to stop */ - - /* Now unlock the services database */ - SetLastError(0xdeadbeef); - bError = UnlockServiceDatabase(hLock); - ok(bError == TRUE, "bError = %u, expected TRUE\n", bError); - ok_err(ERROR_SUCCESS); - - /* Try to start again the service, this time the database unlocked */ - SetLastError(0xdeadbeef); - bError = StartServiceW(hSvc, 0, NULL); - ok(bError == TRUE, "bError = %u, expected TRUE\n", bError); - ok_err(ERROR_SUCCESS); - Sleep(1000); /* Wait 1 second for the service to start */ - - /* Stop the testing service */ - ControlService(hSvc, SERVICE_CONTROL_STOP, &status); - Sleep(1000); /* Wait 1 second for the service to stop */ - - /* Restore its original state */ - if (bWasRunning) - { - StartServiceW(hSvc, 0, NULL); - } - - if (dwOldStartType == SERVICE_DISABLED) - { - ChangeServiceConfigW(hSvc, - SERVICE_NO_CHANGE, - SERVICE_DISABLED, - SERVICE_NO_CHANGE, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL); - } - - -cleanup: - if (hSvc) - CloseServiceHandle(hSvc); - - if (hScm) - CloseServiceHandle(hScm); - - return; -} - -static void Test_QueryLockStatusW(void) -{ - BOOL bError = FALSE; - - SC_HANDLE hScm = NULL; - SC_LOCK hLock = NULL; - LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus = NULL; - DWORD dwRequiredSize = 0; - - /* Firstly try to get lock status with invalid handles */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusW(hScm, - NULL, - 0, - &dwRequiredSize); - ok(bError == FALSE && GetLastError() == ERROR_INVALID_HANDLE, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_INVALID_HANDLE); - ok(dwRequiredSize == 0, "dwRequiredSize is non-zero, expected zero\n"); - - /* Open the services database without having rights */ - SetLastError(0xdeadbeef); - hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT); - ok(hScm != NULL, "Failed to open service manager, error=0x%08lx\n", GetLastError()); - if (!hScm) - { - skip("No service control manager; cannot proceed with QueryLockStatusW test\n"); - goto cleanup; - } - ok_err(ERROR_SUCCESS); - - /* Try to get lock status */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusW(hScm, - NULL, - 0, - &dwRequiredSize); - ok(bError == FALSE && GetLastError() == ERROR_ACCESS_DENIED, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_ACCESS_DENIED); - ok(dwRequiredSize == 0, "dwRequiredSize is non-zero, expected zero\n"); - - CloseServiceHandle(hScm); - - - /* - * Query only the lock status. - */ - - SetLastError(0xdeadbeef); - hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_QUERY_LOCK_STATUS); - ok(hScm != NULL, "Failed to open service manager, error=0x%08lx\n", GetLastError()); - if (!hScm) - { - skip("No service control manager; cannot proceed with QueryLockStatusW test\n"); - goto cleanup; - } - ok_err(ERROR_SUCCESS); - - /* Get the needed size */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusW(hScm, - NULL, - 0, - &dwRequiredSize); - ok(bError == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_INSUFFICIENT_BUFFER); - ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n"); - if (dwRequiredSize == 0) - { - skip("Required size is null; cannot proceed with QueryLockStatusW test\n"); - goto cleanup; - } - - /* Allocate memory */ - lpLockStatus = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwRequiredSize); - if (lpLockStatus == NULL) - { - skip("Cannot allocate %lu bytes of memory\n", dwRequiredSize); - goto cleanup; - } - - /* Get the actual value */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusW(hScm, - lpLockStatus, - dwRequiredSize, - &dwRequiredSize); - ok(bError, "bError = %u, expected TRUE\n", bError); - - /* These conditions must be verified iff the services database wasn't previously locked */ - ok(lpLockStatus->fIsLocked == 0, "lpLockStatus->fIsLocked = %lu, expected 0\n", lpLockStatus->fIsLocked); - ok(lpLockStatus->lpLockOwner != NULL, "lpLockStatus->lpLockOwner is null, expected non-null\n"); - ok(lpLockStatus->lpLockOwner && *lpLockStatus->lpLockOwner == 0, "*lpLockStatus->lpLockOwner != \"\\0\", expected \"\\0\"\n"); - ok(lpLockStatus->dwLockDuration == 0, "lpLockStatus->dwLockDuration = %lu, expected 0\n", lpLockStatus->dwLockDuration); - - HeapFree(GetProcessHeap(), 0, lpLockStatus); - - CloseServiceHandle(hScm); - - - /* - * Now, try to lock the database and check its lock status. - */ - - SetLastError(0xdeadbeef); - hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_LOCK | SC_MANAGER_QUERY_LOCK_STATUS); - ok(hScm != NULL, "Failed to open service manager, error=0x%08lx\n", GetLastError()); - if (!hScm) - { - skip("No service control manager; cannot proceed with QueryLockStatusW test\n"); - goto cleanup; - } - ok_err(ERROR_SUCCESS); - - /* Get the needed size */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusW(hScm, - NULL, - 0, - &dwRequiredSize); - ok(bError == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_INSUFFICIENT_BUFFER); - ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n"); - if (dwRequiredSize == 0) - { - skip("Required size is null; cannot proceed with QueryLockStatusW test\n"); - goto cleanup; - } - - /* Allocate memory */ - lpLockStatus = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwRequiredSize); - if (lpLockStatus == NULL) - { - skip("Cannot allocate %lu bytes of memory\n", dwRequiredSize); - goto cleanup; - } - - /* Get the actual value */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusW(hScm, - lpLockStatus, - dwRequiredSize, - &dwRequiredSize); - ok(bError, "bError = %u, expected TRUE\n", bError); - - /* These conditions must be verified iff the services database wasn't previously locked */ - ok(lpLockStatus->fIsLocked == 0, "lpLockStatus->fIsLocked = %lu, expected 0\n", lpLockStatus->fIsLocked); - ok(lpLockStatus->lpLockOwner != NULL, "lpLockStatus->lpLockOwner is null, expected non-null\n"); - ok(lpLockStatus->lpLockOwner && *lpLockStatus->lpLockOwner == 0, "*lpLockStatus->lpLockOwner != \"\\0\", expected \"\\0\"\n"); - ok(lpLockStatus->dwLockDuration == 0, "lpLockStatus->dwLockDuration = %lu, expected 0\n", lpLockStatus->dwLockDuration); - - HeapFree(GetProcessHeap(), 0, lpLockStatus); - - - /* - * Try again, this time with the database locked. - */ - - SetLastError(0xdeadbeef); - hLock = LockServiceDatabase(hScm); - ok(hLock != NULL, "hLock = 0x%p, expected non-zero\n", hLock); - ok_err(ERROR_SUCCESS); - - Sleep(1000); /* Wait 1 second to let lpLockStatus->dwLockDuration increment */ - - /* Get the needed size */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusW(hScm, - NULL, - 0, - &dwRequiredSize); - ok(bError == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_INSUFFICIENT_BUFFER); - ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n"); - if (dwRequiredSize == 0) - { - skip("Required size is null; cannot proceed with QueryLockStatusW test\n"); - goto cleanup; - } - - /* Allocate memory */ - lpLockStatus = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwRequiredSize); - if (lpLockStatus == NULL) - { - skip("Cannot allocate %lu bytes of memory\n", dwRequiredSize); - goto cleanup; - } - - /* Get the actual value */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusW(hScm, - lpLockStatus, - dwRequiredSize, - &dwRequiredSize); - ok(bError, "bError = %u, expected TRUE\n", bError); - - /* These conditions must be verified iff the services database is locked */ - ok(lpLockStatus->fIsLocked != 0, "lpLockStatus->fIsLocked = %lu, expected non-zero\n", lpLockStatus->fIsLocked); - ok(lpLockStatus->lpLockOwner != NULL, "lpLockStatus->lpLockOwner is null, expected non-null\n"); - ok(lpLockStatus->lpLockOwner && *lpLockStatus->lpLockOwner != 0, "*lpLockStatus->lpLockOwner = \"\\0\", expected non-zero\n"); - ok(lpLockStatus->dwLockDuration != 0, "lpLockStatus->dwLockDuration = %lu, expected non-zero\n", lpLockStatus->dwLockDuration); - - HeapFree(GetProcessHeap(), 0, lpLockStatus); - - - /* - * Last try, with the database again unlocked. - */ - - SetLastError(0xdeadbeef); - bError = UnlockServiceDatabase(hLock); - ok(bError == TRUE, "bError = %u, expected TRUE\n", bError); - ok_err(ERROR_SUCCESS); - hLock = NULL; - - /* Get the needed size */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusW(hScm, - NULL, - 0, - &dwRequiredSize); - ok(bError == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_INSUFFICIENT_BUFFER); - ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n"); - if (dwRequiredSize == 0) - { - skip("Required size is null; cannot proceed with QueryLockStatusW test\n"); - goto cleanup; - } - - /* Allocate memory */ - lpLockStatus = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwRequiredSize); - if (lpLockStatus == NULL) - { - skip("Cannot allocate %lu bytes of memory\n", dwRequiredSize); - goto cleanup; - } - - /* Get the actual value */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusW(hScm, - lpLockStatus, - dwRequiredSize, - &dwRequiredSize); - ok(bError, "bError = %u, expected TRUE\n", bError); - - /* These conditions must be verified iff the services database is unlocked */ - ok(lpLockStatus->fIsLocked == 0, "lpLockStatus->fIsLocked = %lu, expected 0\n", lpLockStatus->fIsLocked); - ok(lpLockStatus->lpLockOwner != NULL, "lpLockStatus->lpLockOwner is null, expected non-null\n"); - ok(lpLockStatus->lpLockOwner && *lpLockStatus->lpLockOwner == 0, "*lpLockStatus->lpLockOwner != \"\\0\", expected \"\\0\"\n"); - ok(lpLockStatus->dwLockDuration == 0, "lpLockStatus->dwLockDuration = %lu, expected 0\n", lpLockStatus->dwLockDuration); - - HeapFree(GetProcessHeap(), 0, lpLockStatus); - - -cleanup: - if (hLock) - UnlockServiceDatabase(hLock); - - if (hScm) - CloseServiceHandle(hScm); - - return; -} - -static void Test_QueryLockStatusA(void) -{ - BOOL bError = FALSE; - - SC_HANDLE hScm = NULL; - SC_LOCK hLock = NULL; - LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus = NULL; - DWORD dwRequiredSize = 0; - - /* Firstly try to get lock status with invalid handles */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusA(hScm, - NULL, - 0, - &dwRequiredSize); - ok(bError == FALSE && GetLastError() == ERROR_INVALID_HANDLE, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_INVALID_HANDLE); - ok(dwRequiredSize == 0, "dwRequiredSize is non-zero, expected zero\n"); - - /* Open the services database without having rights */ - SetLastError(0xdeadbeef); - hScm = OpenSCManagerA(NULL, NULL, SC_MANAGER_CONNECT); - ok(hScm != NULL, "Failed to open service manager, error=0x%08lx\n", GetLastError()); - if (!hScm) - { - skip("No service control manager; cannot proceed with QueryLockStatusA test\n"); - goto cleanup; - } - ok_err(ERROR_SUCCESS); - - /* Try to get lock status */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusA(hScm, - NULL, - 0, - &dwRequiredSize); - ok(bError == FALSE && GetLastError() == ERROR_ACCESS_DENIED, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_ACCESS_DENIED); - ok(dwRequiredSize == 0, "dwRequiredSize is non-zero, expected zero\n"); - - CloseServiceHandle(hScm); - - - /* - * Query only the lock status. - */ - - SetLastError(0xdeadbeef); - hScm = OpenSCManagerA(NULL, NULL, SC_MANAGER_QUERY_LOCK_STATUS); - ok(hScm != NULL, "Failed to open service manager, error=0x%08lx\n", GetLastError()); - if (!hScm) - { - skip("No service control manager; cannot proceed with QueryLockStatusA test\n"); - goto cleanup; - } - ok_err(ERROR_SUCCESS); - - /* Get the needed size */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusA(hScm, - NULL, - 0, - &dwRequiredSize); - ok(bError == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_INSUFFICIENT_BUFFER); - ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n"); - if (dwRequiredSize == 0) - { - skip("Required size is null; cannot proceed with QueryLockStatusA test\n"); - goto cleanup; - } - - /* Allocate memory */ - lpLockStatus = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwRequiredSize); - if (lpLockStatus == NULL) - { - skip("Cannot allocate %lu bytes of memory\n", dwRequiredSize); - goto cleanup; - } - - /* Get the actual value */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusA(hScm, - lpLockStatus, - dwRequiredSize, - &dwRequiredSize); - ok(bError, "bError = %u, expected TRUE\n", bError); - - /* These conditions must be verified iff the services database wasn't previously locked */ - ok(lpLockStatus->fIsLocked == 0, "lpLockStatus->fIsLocked = %lu, expected 0\n", lpLockStatus->fIsLocked); - ok(lpLockStatus->lpLockOwner != NULL, "lpLockStatus->lpLockOwner is null, expected non-null\n"); - ok(lpLockStatus->lpLockOwner && *lpLockStatus->lpLockOwner == 0, "*lpLockStatus->lpLockOwner != \"\\0\", expected \"\\0\"\n"); - ok(lpLockStatus->dwLockDuration == 0, "lpLockStatus->dwLockDuration = %lu, expected 0\n", lpLockStatus->dwLockDuration); - - HeapFree(GetProcessHeap(), 0, lpLockStatus); - - CloseServiceHandle(hScm); - - - /* - * Now, try to lock the database and check its lock status. - */ - - SetLastError(0xdeadbeef); - hScm = OpenSCManagerA(NULL, NULL, SC_MANAGER_LOCK | SC_MANAGER_QUERY_LOCK_STATUS); - ok(hScm != NULL, "Failed to open service manager, error=0x%08lx\n", GetLastError()); - if (!hScm) - { - skip("No service control manager; cannot proceed with QueryLockStatusA test\n"); - goto cleanup; - } - ok_err(ERROR_SUCCESS); - - /* Get the needed size */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusA(hScm, - NULL, - 0, - &dwRequiredSize); - ok(bError == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_INSUFFICIENT_BUFFER); - ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n"); - if (dwRequiredSize == 0) - { - skip("Required size is null; cannot proceed with QueryLockStatusA test\n"); - goto cleanup; - } - - /* Allocate memory */ - lpLockStatus = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwRequiredSize); - if (lpLockStatus == NULL) - { - skip("Cannot allocate %lu bytes of memory\n", dwRequiredSize); - goto cleanup; - } - - /* Get the actual value */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusA(hScm, - lpLockStatus, - dwRequiredSize, - &dwRequiredSize); - ok(bError, "bError = %u, expected TRUE\n", bError); - - /* These conditions must be verified iff the services database wasn't previously locked */ - ok(lpLockStatus->fIsLocked == 0, "lpLockStatus->fIsLocked = %lu, expected 0\n", lpLockStatus->fIsLocked); - ok(lpLockStatus->lpLockOwner != NULL, "lpLockStatus->lpLockOwner is null, expected non-null\n"); - ok(lpLockStatus->lpLockOwner && *lpLockStatus->lpLockOwner == 0, "*lpLockStatus->lpLockOwner != \"\\0\", expected \"\\0\"\n"); - ok(lpLockStatus->dwLockDuration == 0, "lpLockStatus->dwLockDuration = %lu, expected 0\n", lpLockStatus->dwLockDuration); - - HeapFree(GetProcessHeap(), 0, lpLockStatus); - - - /* - * Try again, this time with the database locked. - */ - - SetLastError(0xdeadbeef); - hLock = LockServiceDatabase(hScm); - ok(hLock != NULL, "hLock = 0x%p, expected non-zero\n", hLock); - ok_err(ERROR_SUCCESS); - - Sleep(1000); /* Wait 1 second to let lpLockStatus->dwLockDuration increment */ - - /* Get the needed size */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusA(hScm, - NULL, - 0, - &dwRequiredSize); - ok(bError == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_INSUFFICIENT_BUFFER); - ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n"); - if (dwRequiredSize == 0) - { - skip("Required size is null; cannot proceed with QueryLockStatusA test\n"); - goto cleanup; - } - - /* Allocate memory */ - lpLockStatus = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwRequiredSize); - if (lpLockStatus == NULL) - { - skip("Cannot allocate %lu bytes of memory\n", dwRequiredSize); - goto cleanup; - } - - /* Get the actual value */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusA(hScm, - lpLockStatus, - dwRequiredSize, - &dwRequiredSize); - ok(bError, "bError = %u, expected TRUE\n", bError); - - /* These conditions must be verified iff the services database is locked */ - ok(lpLockStatus->fIsLocked != 0, "lpLockStatus->fIsLocked = %lu, expected non-zero\n", lpLockStatus->fIsLocked); - ok(lpLockStatus->lpLockOwner != NULL, "lpLockStatus->lpLockOwner is null, expected non-null\n"); - ok(lpLockStatus->lpLockOwner && *lpLockStatus->lpLockOwner != 0, "*lpLockStatus->lpLockOwner = \"\\0\", expected non-zero\n"); - ok(lpLockStatus->dwLockDuration != 0, "lpLockStatus->dwLockDuration = %lu, expected non-zero\n", lpLockStatus->dwLockDuration); - - HeapFree(GetProcessHeap(), 0, lpLockStatus); - - - /* - * Last try, with the database again unlocked. - */ - - SetLastError(0xdeadbeef); - bError = UnlockServiceDatabase(hLock); - ok(bError == TRUE, "bError = %u, expected TRUE\n", bError); - ok_err(ERROR_SUCCESS); - hLock = NULL; - - /* Get the needed size */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusA(hScm, - NULL, - 0, - &dwRequiredSize); - ok(bError == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_INSUFFICIENT_BUFFER); - ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n"); - if (dwRequiredSize == 0) - { - skip("Required size is null; cannot proceed with QueryLockStatusA test\n"); - goto cleanup; - } - - /* Allocate memory */ - lpLockStatus = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwRequiredSize); - if (lpLockStatus == NULL) - { - skip("Cannot allocate %lu bytes of memory\n", dwRequiredSize); - goto cleanup; - } - - /* Get the actual value */ - SetLastError(0xdeadbeef); - bError = QueryServiceLockStatusA(hScm, - lpLockStatus, - dwRequiredSize, - &dwRequiredSize); - ok(bError, "bError = %u, expected TRUE\n", bError); - - /* These conditions must be verified iff the services database is unlocked */ - ok(lpLockStatus->fIsLocked == 0, "lpLockStatus->fIsLocked = %lu, expected 0\n", lpLockStatus->fIsLocked); - ok(lpLockStatus->lpLockOwner != NULL, "lpLockStatus->lpLockOwner is null, expected non-null\n"); - ok(lpLockStatus->lpLockOwner && *lpLockStatus->lpLockOwner == 0, "*lpLockStatus->lpLockOwner != \"\\0\", expected \"\\0\"\n"); - ok(lpLockStatus->dwLockDuration == 0, "lpLockStatus->dwLockDuration = %lu, expected 0\n", lpLockStatus->dwLockDuration); - - HeapFree(GetProcessHeap(), 0, lpLockStatus); - - -cleanup: - if (hLock) - UnlockServiceDatabase(hLock); - - if (hScm) - CloseServiceHandle(hScm); - - return; -} - - -START_TEST(LockDatabase) -{ - Test_LockUnlockServiceDatabase(); - Test_LockUnlockServiceDatabaseWithServiceStart(); - Test_QueryLockStatusW(); - Test_QueryLockStatusA(); -} Copied: trunk/rostests/apitests/advapi32/LockServiceDatabase.c (from r73425, trunk/rostests/apitests/advapi32/LockDatabase.c) URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/LockSer…
============================================================================== --- trunk/rostests/apitests/advapi32/LockDatabase.c [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/LockServiceDatabase.c [iso-8859-1] Sun Dec 4 18:41:46 2016 @@ -752,7 +752,7 @@ } -START_TEST(LockDatabase) +START_TEST(LockServiceDatabase) { Test_LockUnlockServiceDatabase(); Test_LockUnlockServiceDatabaseWithServiceStart(); Modified: trunk/rostests/apitests/advapi32/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/testlis…
============================================================================== --- trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] Sun Dec 4 18:41:46 2016 @@ -8,7 +8,7 @@ extern void func_eventlog(void); extern void func_HKEY_CLASSES_ROOT(void); extern void func_IsTextUnicode(void); -extern void func_LockDatabase(void); +extern void func_LockServiceDatabase(void); extern void func_QueryServiceConfig2(void); extern void func_RegEnumKey(void); extern void func_RegEnumValueW(void); @@ -25,7 +25,7 @@ { "eventlog_supp", func_eventlog }, { "HKEY_CLASSES_ROOT", func_HKEY_CLASSES_ROOT }, { "IsTextUnicode" , func_IsTextUnicode }, - { "LockDatabase" , func_LockDatabase }, + { "LockServiceDatabase" , func_LockServiceDatabase }, { "QueryServiceConfig2", func_QueryServiceConfig2 }, { "RegEnumKey", func_RegEnumKey }, { "RegEnumValueW", func_RegEnumValueW },
8 years
1
0
0
0
[hbelusca] 73425: [USERENV]: Use ARRAYSIZE instead of hardcoding the sizes of the static buffers.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sun Dec 4 18:28:33 2016 New Revision: 73425 URL:
http://svn.reactos.org/svn/reactos?rev=73425&view=rev
Log: [USERENV]: Use ARRAYSIZE instead of hardcoding the sizes of the static buffers. Modified: trunk/reactos/dll/win32/userenv/profile.c trunk/reactos/dll/win32/userenv/setup.c Modified: trunk/reactos/dll/win32/userenv/profile.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/profile.…
============================================================================== --- trunk/reactos/dll/win32/userenv/profile.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/profile.c [iso-8859-1] Sun Dec 4 18:28:33 2016 @@ -44,7 +44,7 @@ /* Build profile name postfix */ if (!ExpandEnvironmentStringsW(L"%SystemRoot%", szSystemRoot, - MAX_PATH)) + ARRAYSIZE(szSystemRoot))) { DPRINT1("Error: %lu\n", GetLastError()); return FALSE; @@ -180,7 +180,7 @@ } /* Get profiles path */ - dwLength = MAX_PATH * sizeof(WCHAR); + dwLength = sizeof(szRawProfilesPath); Error = RegQueryValueExW(hKey, L"ProfilesDirectory", NULL, @@ -198,7 +198,7 @@ /* Expand it */ if (!ExpandEnvironmentStringsW(szRawProfilesPath, szProfilesPath, - MAX_PATH)) + ARRAYSIZE(szProfilesPath))) { DPRINT1("Error: %lu\n", GetLastError()); RegCloseKey(hKey); @@ -216,7 +216,7 @@ } /* Get default user path */ - dwLength = MAX_PATH * sizeof(WCHAR); + dwLength = sizeof(szBuffer); Error = RegQueryValueExW(hKey, L"DefaultUserProfile", NULL, @@ -318,7 +318,7 @@ 0, REG_EXPAND_SZ, (LPBYTE)szBuffer, - (wcslen (szBuffer) + 1) * sizeof(WCHAR)); + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); if (Error != ERROR_SUCCESS) { DPRINT1("Error: %lu\n", Error); @@ -766,13 +766,13 @@ /* Expand it */ if (!ExpandEnvironmentStringsW(szBuffer, szProfilesPath, - MAX_PATH)) + ARRAYSIZE(szProfilesPath))) { DPRINT1("Error: %lu\n", GetLastError()); return FALSE; } - dwLength = wcslen (szProfilesPath) + 1; + dwLength = wcslen(szProfilesPath) + 1; if (lpProfilesDir != NULL) { if (*lpcchSize < dwLength) @@ -915,7 +915,7 @@ /* Expand it */ if (!ExpandEnvironmentStringsW(szRawImagePath, szImagePath, - MAX_PATH)) + ARRAYSIZE(szImagePath))) { DPRINT1 ("Error: %lu\n", GetLastError()); return FALSE; @@ -995,7 +995,7 @@ } /* Convert the structure to UNICODE... */ - ProfileInfoW.dwSize = sizeof(PROFILEINFOW); + ProfileInfoW.dwSize = sizeof(ProfileInfoW); ProfileInfoW.dwFlags = lpProfileInfo->dwFlags; if (lpProfileInfo->lpUserName) Modified: trunk/reactos/dll/win32/userenv/setup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/userenv/setup.c?…
============================================================================== --- trunk/reactos/dll/win32/userenv/setup.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/userenv/setup.c [iso-8859-1] Sun Dec 4 18:28:33 2016 @@ -122,7 +122,7 @@ if (!LoadStringW(hInstance, IDS_PROFILEPATH, szBuffer, - MAX_PATH)) + ARRAYSIZE(szBuffer))) { DPRINT1("Error: %lu\n", GetLastError()); return FALSE; @@ -143,7 +143,7 @@ /* Expand it */ if (!ExpandEnvironmentStringsW(szBuffer, szProfilesPath, - MAX_PATH)) + ARRAYSIZE(szProfilesPath))) { DPRINT1("Error: %lu\n", GetLastError()); RegCloseKey(hKey); @@ -162,7 +162,7 @@ } /* Store the profiles directory path in the registry */ - dwLength = (wcslen (szBuffer) + 1) * sizeof(WCHAR); + dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR); Error = RegSetValueExW(hKey, L"ProfilesDirectory", 0, @@ -186,7 +186,7 @@ wcscat(szProfilePath, szBuffer); /* Attempt default user directory creation */ - if (!CreateDirectoryW (szProfilePath, NULL)) + if (!CreateDirectoryW(szProfilePath, NULL)) { if (GetLastError() != ERROR_ALREADY_EXISTS) { @@ -196,7 +196,7 @@ } /* Directory existed, let's try to append the postfix */ - if (!AppendSystemPostfix(szBuffer, MAX_PATH)) + if (!AppendSystemPostfix(szBuffer, ARRAYSIZE(szBuffer))) { DPRINT1("AppendSystemPostfix() failed\n", GetLastError()); RegCloseKey(hKey); @@ -221,7 +221,7 @@ } /* Store the default user profile path in the registry */ - dwLength = (wcslen (szBuffer) + 1) * sizeof(WCHAR); + dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR); Error = RegSetValueExW(hKey, L"DefaultUserProfile", 0, @@ -254,7 +254,7 @@ if (!LoadStringW(hInstance, lpFolderData->uId, &szBuffer[dwLength], - MAX_PATH - dwLength)) + ARRAYSIZE(szBuffer) - dwLength)) { /* Use the default name instead */ wcscat(szBuffer, lpFolderData->lpPath); @@ -304,7 +304,7 @@ if (!LoadStringW(hInstance, lpFolderData->uId, &szBuffer[dwLength], - MAX_PATH - dwLength)) + ARRAYSIZE(szBuffer) - dwLength)) { /* Use the default name instead */ wcscat(szBuffer, lpFolderData->lpPath); @@ -330,7 +330,7 @@ } /* Set 'Fonts' folder path */ - GetWindowsDirectoryW(szBuffer, MAX_PATH); + GetWindowsDirectoryW(szBuffer, ARRAYSIZE(szBuffer)); wcscat(szBuffer, L"\\Fonts"); dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR); @@ -375,7 +375,7 @@ if (!LoadStringW(hInstance, lpFolderData->uId, &szBuffer[dwLength], - MAX_PATH - dwLength)) + ARRAYSIZE(szBuffer) - dwLength)) { /* Use the default name instead */ wcscat(szBuffer, lpFolderData->lpPath); @@ -411,7 +411,7 @@ wcscat(szProfilePath, szBuffer); /* Attempt 'All Users' directory creation */ - if (!CreateDirectoryW (szProfilePath, NULL)) + if (!CreateDirectoryW(szProfilePath, NULL)) { if (GetLastError() != ERROR_ALREADY_EXISTS) { @@ -420,7 +420,7 @@ } /* Directory existed, let's try to append the postfix */ - if (!AppendSystemPostfix(szBuffer, MAX_PATH)) + if (!AppendSystemPostfix(szBuffer, ARRAYSIZE(szBuffer))) { DPRINT1("AppendSystemPostfix() failed\n", GetLastError()); return FALSE; @@ -486,7 +486,7 @@ if (!LoadStringW(hInstance, lpFolderData->uId, &szBuffer[dwLength], - MAX_PATH - dwLength)) + ARRAYSIZE(szBuffer) - dwLength)) { /* Use the default name instead */ wcscat(szBuffer, lpFolderData->lpPath); @@ -536,7 +536,7 @@ if (!LoadStringW(hInstance, lpFolderData->uId, &szBuffer[dwLength], - MAX_PATH - dwLength)) + ARRAYSIZE(szBuffer) - dwLength)) { /* Use the default name instead */ wcscat(szBuffer, lpFolderData->lpPath); @@ -588,7 +588,7 @@ if (!LoadStringW(hInstance, lpFolderData->uId, &szBuffer[dwLength], - MAX_PATH - dwLength)) + ARRAYSIZE(szBuffer) - dwLength)) { /* Use the default name instead */ wcscat(szBuffer, lpFolderData->lpPath); @@ -619,7 +619,7 @@ if (!LoadStringW(hInstance, IDS_PROGRAMFILES, szBuffer, - MAX_PATH)) + ARRAYSIZE(szBuffer))) { DPRINT1("Error: %lu\n", GetLastError()); return FALSE; @@ -628,7 +628,7 @@ if (!LoadStringW(hInstance, IDS_COMMONFILES, szCommonFilesDirPath, - MAX_PATH)) + ARRAYSIZE(szCommonFilesDirPath))) { DPRINT1("Warning: %lu\n", GetLastError()); } @@ -636,7 +636,7 @@ /* Expand it */ if (!ExpandEnvironmentStringsW(szBuffer, szProfilesPath, - MAX_PATH)) + ARRAYSIZE(szProfilesPath))) { DPRINT1("Error: %lu\n", GetLastError()); return FALSE; @@ -647,8 +647,8 @@ wcscat(szBuffer, szCommonFilesDirPath); if (!ExpandEnvironmentStringsW(szBuffer, - szCommonFilesDirPath, - MAX_PATH)) + szCommonFilesDirPath, + ARRAYSIZE(szCommonFilesDirPath))) { DPRINT1("Warning: %lu\n", GetLastError()); } @@ -666,7 +666,7 @@ return FALSE; } - dwLength = (wcslen (szProfilesPath) + 1) * sizeof(WCHAR); + dwLength = (wcslen(szProfilesPath) + 1) * sizeof(WCHAR); Error = RegSetValueExW(hKey, L"ProgramFilesDir", 0, @@ -693,12 +693,12 @@ DPRINT1("Warning: %lu\n", Error); } - RegCloseKey (hKey); + RegCloseKey(hKey); /* Create directory */ if (!CreateDirectoryW(szProfilesPath, NULL)) { - if (GetLastError () != ERROR_ALREADY_EXISTS) + if (GetLastError() != ERROR_ALREADY_EXISTS) { DPRINT1("Error: %lu\n", GetLastError()); return FALSE; @@ -708,7 +708,7 @@ /* Create directory */ if (!CreateDirectoryW(szCommonFilesDirPath, NULL)) { - if (GetLastError () != ERROR_ALREADY_EXISTS) + if (GetLastError() != ERROR_ALREADY_EXISTS) { DPRINT1("Warning: %lu\n", GetLastError()); } @@ -759,7 +759,7 @@ if (!LoadStringW(hInstance, lpFolderData->uId, &szBuffer[dwLength], - MAX_PATH - dwLength)) + ARRAYSIZE(szBuffer) - dwLength)) { /* Use the default name instead */ wcscat(szBuffer, lpFolderData->lpPath);
8 years
1
0
0
0
[mjansen] 73424: [DESK] Fix theme preview for Win7. Patch by Carlo Bramini. CORE-10076 #resolve #comment Thanks!
by mjansen@svn.reactos.org
Author: mjansen Date: Sun Dec 4 16:52:22 2016 New Revision: 73424 URL:
http://svn.reactos.org/svn/reactos?rev=73424&view=rev
Log: [DESK] Fix theme preview for Win7. Patch by Carlo Bramini. CORE-10076 #resolve #comment Thanks! Modified: trunk/reactos/dll/cpl/desk/theme.c Modified: trunk/reactos/dll/cpl/desk/theme.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/theme.c?rev=7…
============================================================================== --- trunk/reactos/dll/cpl/desk/theme.c [iso-8859-1] (original) +++ trunk/reactos/dll/cpl/desk/theme.c [iso-8859-1] Sun Dec 4 16:52:22 2016 @@ -124,6 +124,9 @@ INT i, Result; HKEY hKey; BOOL ret; +#if (WINVER >= 0x0600) + OSVERSIONINFO osvi; +#endif /* Load colors */ for (i = 0; i < NUM_COLORS; i++) @@ -133,6 +136,20 @@ /* Load non client metrics */ scheme->ncMetrics.cbSize = sizeof(NONCLIENTMETRICSW); + +#if (WINVER >= 0x0600) + /* Size of NONCLIENTMETRICSA/W depends on current version of the OS. + * see: + *
https://msdn.microsoft.com/en-us/library/windows/desktop/ff729175%28v=vs.85…
+ */ + if (GetVersionEx(&osvi)) + { + /* Windows XP and earlier */ + if (osvi.dwMajorVersion <= 5) + scheme->ncMetrics.cbSize -= sizeof(scheme->ncMetrics.iPaddedBorderWidth); + } +#endif + ret = SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &scheme->ncMetrics,
8 years
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
9
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
Results per page:
10
25
50
100
200