/*
 * Service Control Manager (SCM) interface definition
 */

//#include <windef.h>
//#include <winsvc.h>
#include "include/reactos/idl/wtypes.idl"

#define SC_HANDLE unsigned int
#define SC_LOCK unsigned int
#define SERVICE_STATUS_HANDLE unsigned long
#define SC_STATUS_TYPE unsigned long
#define SC_ENUM_TYPE unsigned long

#define R(fn) Scmr ## fn

[
  uuid(367abb81-9844-35f1-ad32-98f038001003),
  version(2.0),
  pointer_default(unique),
  explicit_handle
]
interface svcctl
{
cpp_quote("#if 0")
  typedef struct _SERVICE_STATUS
  {
    DWORD dwServiceType;
    DWORD dwCurrentState;
    DWORD dwControlsAccepted;
    DWORD dwWin32ExitCode;
    DWORD dwServiceSpecificExitCode;
    DWORD dwCheckPoint;
    DWORD dwWaitHint;
  } SERVICE_STATUS, *LPSERVICE_STATUS;
cpp_quote("#endif")

  /* Function 0 */
  DWORD R(CloseServiceHandle) ([in] handle_t BindingHandle,
                               [in] SC_HANDLE hSCObject);

  /* Function 1 */
  DWORD R(ControlService) ([in] handle_t BindingHandle,
                           [in] SC_HANDLE hService,
                           [in] DWORD dwControl,
                           [out] SERVICE_STATUS *lpServiceStatus);
/*                           [out] LPSERVICE_STATUS lpServiceStatus); */

  /* Function 2 */
  DWORD R(DeleteService) ([in] handle_t BindingHandle,
                          [in] SC_HANDLE hService);

  /* Function 3 */
  DWORD R(LockServiceDatabase) ([in] handle_t BindingHandle,
                                [in] SC_HANDLE hSCManager,
                                [out] SC_LOCK *hLock);

  /* Function 4 */
  DWORD R(QueryServiceObjectSecurity) ([in] handle_t BindingHandle,
                                       [in] SC_HANDLE hService,
                                       [in] DWORD dwSecurityInformation,
                                       [out, size_is(dwSecuityDescriptorSize)] unsigned char *lpSecurityDescriptor,
                                       [in] DWORD dwSecuityDescriptorSize,
                                       [out] LPDWORD pcbBytesNeeded);

  /* Function 5 */
  DWORD R(SetServiceObjectSecurity) ([in] handle_t BindingHandle,
                                     [in] SC_HANDLE hService,
                                     [in] DWORD dwSecurityInformation,
                                     [in, size_is(dwSecuityDescriptorSize)] unsigned char *lpSecurityDescriptor,
                                     [in] DWORD dwSecuityDescriptorSize);

  /* Function 6 */
  DWORD R(QueryServiceStatus) ([in] handle_t BindingHandle,
                               [in] SC_HANDLE hSCManager,
                               [out] SERVICE_STATUS *lpServiceStatus);
/*                               [out] LPSERVICE_STATUS lpServiceStatus); */

  /* Function 7 */
  DWORD R(SetServiceStatus) ([in] handle_t BindingHandle,
                             [in] SERVICE_STATUS_HANDLE hServiceStatus,
                             [in] SERVICE_STATUS *lpServiceStatus);

  /* Function 8 */
  DWORD R(UnlockServiceDatabase) ([in] handle_t BindingHandle,
                                  [in] SC_LOCK hLock);

  /* Function 9 */
  DWORD R(NotifyBootConfigStatus) ([in] handle_t BindingHandle,
                                   [in] BOOL BootAcceptable);

  /* Function 10 */
  DWORD R(SetServiceBitsW) ([in] handle_t BindingHandle,
                            [in] SERVICE_STATUS_HANDLE hServiceStatus,
                            [in] DWORD dwServiceBits,
                            [in] BOOL bSetBitsOn,
                            [in] BOOL bUpdateImmediately,
                            [in, string, unique] LPWSTR lpString);

  /* Function 11 */
  DWORD R(ChangeServiceConfigW) ([in] handle_t BindingHandle,
                                 [in] SC_HANDLE hSCManager,
                                 [in] DWORD dwServiceType,
                                 [in] DWORD dwStartType,
                                 [in] DWORD dwErrorControl,
                                 [in, string, unique] LPCWSTR lpBinaryPathName,
                                 [in, string, unique] LPCWSTR lpLoadOrderGroup,
                                 [in, out, unique] LPDWORD lpdwTagId,
                                 [in, size_is(dwDependenciesLength), unique] LPCWSTR lpDependencies,
                                 [in] DWORD dwDependenciesLength,
                                 [in, string, unique] LPCWSTR lpServiceStartName,
                                 [in, size_is(dwPasswordLength), unique] LPCWSTR lpPassword,
                                 [in] DWORD dwPasswordLength,
                                 [in, string, unique] LPCWSTR lpDisplayName);

  /* Function 12 */
  DWORD R(CreateServiceW) ([in] handle_t BindingHandle,
                           [in] SC_HANDLE hSCManager,
                           [in, string, ref] LPCWSTR lpServiceName,
                           [in, string, unique] LPCWSTR lpDisplayName,
                           [in] DWORD dwDesiredAccess,
                           [in] DWORD dwServiceType,
                           [in] DWORD dwStartType,
                           [in] DWORD dwErrorControl,
                           [in, string, ref] LPCWSTR lpBinaryPathName,
                           [in, string, unique] LPCWSTR lpLoadOrderGroup,
                           [in, out, unique] LPDWORD lpdwTagId,
                           [in, size_is(dwDependenciesLength), unique] LPCWSTR lpDependencies,
                           [in] DWORD dwDependenciesLength,
                           [in, string, unique] LPCWSTR lpServiceStartName,
                           [in, size_is(dwPasswordLength), unique] LPCWSTR lpPassword,
                           [in] DWORD dwPasswordLength,
                           [out] SC_HANDLE *hService);

  /* Function 13 */
  DWORD R(EnumDependentServicesW) ([in] handle_t BindingHandle,
                                   [in] SC_HANDLE hService,
                                   [in] DWORD dwServiceState,
                                   [out, unique, size_is(cbBufSize)] LPBYTE lpServices,
                                   [in] DWORD cbBufSize,
                                   [out] LPDWORD pcbBytesNeeded,
                                   [out] LPDWORD lpServicesReturned);

  /* Function 14 */
  DWORD R(EnumServicesStatusW) ([in] handle_t BindingHandle,
                                [in] SC_HANDLE hSCManager,
                                [in] DWORD dwServiceType,
                                [in] DWORD dwServiceState,
                                [out, unique, size_is(dwBufSize)] LPBYTE lpServices,
                                [in] DWORD dwBufSize,
                                [out] LPDWORD pcbBytesNeeded,
                                [out] LPDWORD lpServicesReturned,
                                [in, out, unique] LPDWORD lpResumeHandle);

  /* Function 15 */
  DWORD R(OpenSCManagerW) ([in] handle_t BindingHandle,
                           [in, string, unique] LPCWSTR lpMachineName,
                           [in, string, unique] LPCWSTR lpDatabaseName,
                           [in] DWORD dwDesiredAccess,
                           [out] SC_HANDLE *hScm);

  /* Function 16 */
  DWORD R(OpenServiceW) ([in] handle_t BindingHandle,
                         [in] SC_HANDLE hSCManager,
                         [in, string] LPCWSTR lpServiceName,
                         [in] DWORD dwDesiredAccess,
                         [out] SC_HANDLE *hScm);

  /* Function 17 */
  DWORD R(QueryServiceConfigW) ([in] handle_t BindingHandle,
                                [in] SC_HANDLE hService,
                                [out, unique, size_is(cbBufSize)] LPBYTE lpServiceConfig,
                                [in] DWORD cbBufSize,
                                [out] LPDWORD pcbBytesNeeded);

  /* Function 18 */
  DWORD R(QueryServiceLockStatusW) ([in] handle_t BindingHandle,
                                    [in] SC_HANDLE hSCManager,
                                    [out, unique, size_is(cbBufSize)] LPBYTE lpLockStatus,
                                    [in] DWORD cbBufSize,
                                    [out] LPDWORD pcbBytesNeeded);

  /* Function 19 */
  DWORD R(StartServiceW) ([in] handle_t BindingHandle,
                          [in] SC_HANDLE hService,
                          [in] DWORD dwNumServiceArgs,
                          [in, size_is(cbBufSize)] LPBYTE lpServiceArgBuffer,
                          [in] DWORD cbBufSize);

  /* FIXME: This is the correct interface but WIDL doesn't support it yet! */
//  DWORD R(StartServiceW) ([in] handle_t BindingHandle,
//                          [in] SC_HANDLE hService,
//                          [in] DWORD dwNumServiceArgs,
//                          [in, string, size_is(dwNumServiceArgs, ), unique] LPWSTR *lpServiceArgVectors);

  /* Function 20 */
  DWORD R(GetServiceDisplayNameW) ([in] handle_t BindingHandle,
                                   [in] SC_HANDLE hSCManager,
                                   [in, string, ref] LPCWSTR lpServiceName,
                                   [out, size_is(*lpcchBuffer), unique] LPWSTR lpDisplayName,
                                   [in, out, ref] LPDWORD lpcchBuffer);

  /* Function 21 */
  DWORD R(GetServiceKeyNameW) ([in] handle_t BindingHandle,
                               [in] SC_HANDLE hSCManager,
                               [in, string, ref] LPCWSTR lpDisplayName,
                               [out, size_is(*lpcchBuffer), unique] LPWSTR lpServiceName,
                               [in, out, ref] LPDWORD lpcchBuffer);

  /* Function 22 */
  DWORD R(SetServiceBitsA) ([in] handle_t BindingHandle,
                            [in] SERVICE_STATUS_HANDLE hServiceStatus,
                            [in] DWORD dwServiceBits,
                            [in] BOOL bSetBitsOn,
                            [in] BOOL bUpdateImmediately,
                            [in, string, unique] LPSTR lpString);

  /* Function 23 */
  DWORD R(ChangeServiceConfigA) ([in] handle_t BindingHandle,
                                 [in] SC_HANDLE hSCManager,
                                 [in] DWORD dwServiceType,
                                 [in] DWORD dwStartType,
                                 [in] DWORD dwErrorControl,
                                 [in, string, unique] LPCSTR lpBinaryPathName,
                                 [in, string, unique] LPCSTR lpLoadOrderGroup,
                                 [in, out, unique] LPDWORD lpdwTagId,
                                 [in, size_is(dwDependenciesLength), unique] LPCSTR lpDependencies,
                                 [in] DWORD dwDependenciesLength,
                                 [in, string, unique] LPCSTR lpServiceStartName,
                                 [in, size_is(dwPasswordLength), unique] LPCSTR lpPassword,
                                 [in] DWORD dwPasswordLength,
                                 [in, string, unique] LPCSTR lpDisplayName);

  /* Function 24 */
  DWORD R(CreateServiceA) ([in] handle_t BindingHandle,
                           [in] SC_HANDLE hSCManager,
                           [in, string, ref] LPCSTR lpServiceName,
                           [in, string, unique] LPCSTR lpDisplayName,
                           [in] DWORD dwDesiredAccess,
                           [in] DWORD dwServiceType,
                           [in] DWORD dwStartType,
                           [in] DWORD dwErrorControl,
                           [in, string, ref] LPCSTR lpBinaryPathName,
                           [in, string, unique] LPCSTR lpLoadOrderGroup,
                           [in, out, unique] LPDWORD lpdwTagId,
                           [in, size_is(dwDependenciesLength), unique] LPCSTR lpDependencies,
                           [in] DWORD dwDependenciesLength,
                           [in, string, unique] LPCSTR lpServiceStartName,
                           [in, size_is(dwPasswordLength), unique] LPCSTR lpPassword,
                           [in] DWORD dwPasswordLength,
                           [out] SC_HANDLE *hService);

  /* Function 25 */
  DWORD R(EnumDependentServicesA) ([in] handle_t BindingHandle,
                                   [in] SC_HANDLE hService,
                                   [in] DWORD dwServiceState,
                                   [out, unique, size_is(cbBufSize)] LPBYTE lpServices,
                                   [in] DWORD cbBufSize,
                                   [out] LPDWORD pcbBytesNeeded,
                                   [out] LPDWORD lpServicesReturned);

  /* Function 26 */
  DWORD R(EnumServicesStatusA) ([in] handle_t BindingHandle,
                                [in] SC_HANDLE hSCManager,
                                [in] DWORD dwServiceType,
                                [in] DWORD dwServiceState,
                                [out, unique, size_is(dwBufSize)] LPBYTE lpServices,
                                [in] DWORD dwBufSize,
                                [out] LPDWORD pcbBytesNeeded,
                                [out] LPDWORD lpServicesReturned,
                                [in, out, unique] LPDWORD lpResumeHandle);

  /* Function 27 */
  DWORD R(OpenSCManagerA) ([in] handle_t BindingHandle,
                           [in, string, unique] LPCSTR lpMachineName,
                           [in, string, unique] LPCSTR lpDatabaseName,
                           [in] DWORD dwDesiredAccess,
                           [out] SC_HANDLE *hScm);

  /* Function 28 */
  SC_HANDLE R(OpenServiceA) ([in] handle_t BindingHandle,
                             [in] SC_HANDLE hSCManager,
                             [in, string] LPCSTR lpServiceName,
                             [in] DWORD dwDesiredAccess,
                             [out] SC_HANDLE *hScm);

  /* Function 29 */
  DWORD R(QueryServiceConfigA) ([in] handle_t BindingHandle,
                                [in] SC_HANDLE hService,
                                [out, unique, size_is(cbBufSize)] LPBYTE lpServiceConfig,
                                [in] DWORD cbBufSize,
                                [out] LPDWORD pcbBytesNeeded);

  /* Function 30 */
  DWORD R(QueryServiceLockStatusA) ([in] handle_t BindingHandle,
                                    [in] SC_HANDLE hSCManager,
                                    [out, unique, size_is(cbBufSize)] LPBYTE lpLockStatus,
                                    [in] DWORD cbBufSize,
                                    [out] LPDWORD pcbBytesNeeded);

  /* Function 31 */
  DWORD R(StartServiceA) ([in] handle_t BindingHandle,
                          [in] SC_HANDLE hService,
                          [in] DWORD dwNumServiceArgs,
                          [in, size_is(cbBufSize)] LPBYTE lpServiceArgBuffer,
                          [in] DWORD cbBufSize);

  /* FIXME: This is the correct interface but WIDL doesn't support it yet! */
//  DWORD R(StartServiceA) ([in] handle_t BindingHandle,
//                          [in] SC_HANDLE hService,
//                          [in] DWORD dwNumServiceArgs,
//                          [in, unique, string, size_is(dwNumServiceArgs, )] LPSTR *lpServiceArgVectors);

  /* Function 32 */
  DWORD R(GetServiceDisplayNameA) ([in] handle_t BindingHandle,
                                   [in] SC_HANDLE hSCManager,
                                   [in, string, ref] LPCSTR lpServiceName,
                                   [out, unique, size_is(*lpcchBuffer)] LPSTR lpDisplayName,
                                   [in, out, ref] LPDWORD lpcchBuffer);

  /* Function 33 */
  DWORD R(GetServiceKeyNameA) ([in] handle_t BindingHandle,
                               [in] SC_HANDLE hSCManager,
                               [in, string, ref] LPCSTR lpDisplayName,
                               [out, unique, size_is(*lpcchBuffer)] LPSTR lpServiceName,
                               [in, out, ref] LPDWORD lpcchBuffer);

  /* Function 34 */
  DWORD R(GetCurrentGroupStateW) ([in] handle_t BindingHandle); /* FIXME */

  /* Function 35 */
  DWORD R(EnumServiceGroupW) ([in] handle_t BindingHandle); /* FIXME */

  /* Function 36 */
  DWORD R(ChangeServiceConfig2A) ([in] handle_t BindingHandle,
                                  [in] SC_HANDLE hService,
                                  [in] DWORD dwInfoLevel,
                                  [in, size_is(dwInfoSize)] LPBYTE lpInfo,
                                  [in] DWORD dwInfoSize);

  /* Function 37 */
  DWORD R(ChangeServiceConfig2W) ([in] handle_t BindingHandle,
                                  [in] SC_HANDLE hService,
                                  [in] DWORD dwInfoLevel,
                                  [in, size_is(dwInfoSize)] LPBYTE lpInfo,
                                  [in] DWORD dwInfoSize);

  /* Function 38 */
  DWORD R(QueryServiceConfig2A) ([in] handle_t BindingHandle,
                                 [in] SC_HANDLE hService,
                                 [in] DWORD dwInfoLevel,
                                 [out, unique, size_is(cbBufSize)] LPBYTE lpBuffer,
                                 [in] DWORD cbBufSize,
                                 [out] LPDWORD pcbBytesNeeded);

  /* Function 39 */
  DWORD R(QueryServiceConfig2W) ([in] handle_t BindingHandle,
                                 [in] SC_HANDLE hService,
                                 [in] DWORD dwInfoLevel,
                                 [out, unique, size_is(cbBufSize)] LPBYTE lpBuffer,
                                 [in] DWORD cbBufSize,
                                 [out] LPDWORD pcbBytesNeeded);

  /* Function 40 */
  DWORD R(QueryServiceStatusEx) ([in] handle_t BindingHandle,
                                 [in] SC_HANDLE hService,
                                 [in] SC_STATUS_TYPE InfoLevel,
                                 [out, unique, size_is(cbBufSize)] LPBYTE lpBuffer,
                                 [in] DWORD cbBufSize,
                                 [out] LPDWORD pcbBytesNeeded);

  /* Function 41 */
  DWORD R(EnumServicesStatusExA) ([in] handle_t BindingHandle,
                                  [in] SC_HANDLE hService,
                                  [in] SC_ENUM_TYPE InfoLevel,
                                  [in] DWORD dwServiceType,
                                  [in] DWORD dwServiceState,
                                  [out, unique, size_is(cbBufSize)] LPBYTE lpServices,
                                  [in] DWORD cbBufSize,
                                  [out] LPDWORD pcbBytesNeeded,
                                  [out] LPDWORD lpServicesReturned,
                                  [in, out, unique] LPDWORD lpResumeHandle,
                                  [in, string, unique] LPCSTR pszGroupName);

  /* Function 42 */
  DWORD R(EnumServicesStatusExW) ([in] handle_t BindingHandle,
                                  [in] SC_HANDLE hService,
                                  [in] SC_ENUM_TYPE InfoLevel,
                                  [in] DWORD dwServiceType,
                                  [in] DWORD dwServiceState,
                                  [out, unique, size_is(cbBufSize)] LPBYTE lpServices,
                                  [in] DWORD cbBufSize,
                                  [out] LPDWORD pcbBytesNeeded,
                                  [out] LPDWORD lpServicesReturned,
                                  [in, out, unique] LPDWORD lpResumeHandle,
                                  [in, string, unique] LPCWSTR pszGroupName);

  /* Function 43 */
  /* R(SendTSMessage) */
}
