diff options
Diffstat (limited to 'src/dutil/svcutil.cpp')
| -rw-r--r-- | src/dutil/svcutil.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/dutil/svcutil.cpp b/src/dutil/svcutil.cpp new file mode 100644 index 00000000..9da2b5b3 --- /dev/null +++ b/src/dutil/svcutil.cpp | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | #include "precomp.h" | ||
| 4 | |||
| 5 | /******************************************************************** | ||
| 6 | SvcQueryConfig - queries the configuration of a service | ||
| 7 | |||
| 8 | ********************************************************************/ | ||
| 9 | extern "C" HRESULT DAPI SvcQueryConfig( | ||
| 10 | __in SC_HANDLE sch, | ||
| 11 | __out QUERY_SERVICE_CONFIGW** ppConfig | ||
| 12 | ) | ||
| 13 | { | ||
| 14 | HRESULT hr = S_OK; | ||
| 15 | QUERY_SERVICE_CONFIGW* pConfig = NULL; | ||
| 16 | DWORD cbConfig = 0; | ||
| 17 | |||
| 18 | if (!::QueryServiceConfigW(sch, NULL, 0, &cbConfig)) | ||
| 19 | { | ||
| 20 | DWORD er = ::GetLastError(); | ||
| 21 | if (ERROR_INSUFFICIENT_BUFFER == er) | ||
| 22 | { | ||
| 23 | pConfig = static_cast<QUERY_SERVICE_CONFIGW*>(MemAlloc(cbConfig, TRUE)); | ||
| 24 | ExitOnNull(pConfig, hr, E_OUTOFMEMORY, "Failed to allocate memory to get configuration."); | ||
| 25 | |||
| 26 | if (!::QueryServiceConfigW(sch, pConfig, cbConfig, &cbConfig)) | ||
| 27 | { | ||
| 28 | ExitWithLastError(hr, "Failed to read service configuration."); | ||
| 29 | } | ||
| 30 | } | ||
| 31 | else | ||
| 32 | { | ||
| 33 | ExitOnWin32Error(er, hr, "Failed to query service configuration."); | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | *ppConfig = pConfig; | ||
| 38 | pConfig = NULL; | ||
| 39 | |||
| 40 | LExit: | ||
| 41 | ReleaseMem(pConfig); | ||
| 42 | |||
| 43 | return hr; | ||
| 44 | } | ||
