Changeset 2343


Ignore:
Timestamp:
Jan 6, 2000, 9:05:00 PM (25 years ago)
Author:
sandervl
Message:

Security api updates

Location:
trunk/src/advapi32
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/advapi32/ADVAPI32.CPP

    r2172 r2343  
    1 /* $Id: ADVAPI32.CPP,v 1.12 1999-12-21 00:35:28 sandervl Exp $ */
     1/* $Id: ADVAPI32.CPP,v 1.13 2000-01-06 20:04:59 sandervl Exp $ */
    22
    33/*
     
    955955}
    956956
    957 
    958 
    959 /*****************************************************************************
    960  * Name      : InitializeAcl
    961  * Purpose   : The InitializeAcl function creates a new ACL structure.
    962  *             An ACL is an access-control list.
    963  * Parameters: PACL  pAcl          address of access-control list
    964  *             DWORD nAclLength    size of access-control list
    965  *             DWORD dwAclRevision revision level of access-control list
    966  * Variables :
    967  * Result    :
    968  * Remark    :
    969  * Status    : UNTESTED STUB
    970  *
    971  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
    972  *****************************************************************************/
    973 
    974 BOOL WIN32API InitializeAcl(PACL  pAcl,
    975                                DWORD nAclLength,
    976                                DWORD dwAclRevision)
    977 {
    978   dprintf(("ADVAPI32: InitializeAcl(%08xh,%08xh,%08xh) not implemented.\n",
    979            pAcl,
    980            nAclLength,
    981            dwAclRevision));
    982 
    983   return (FALSE); /* signal failure */
    984 }
    985 
    986 
    987 
    988957/*****************************************************************************
    989958 * Name      : InitiateSystemShutdownA
     
    18431812}
    18441813
    1845 
    1846 
    1847 
    1848 /*****************************************************************************
    1849  * Name      : RegisterServiceCtrlHandlerA
    1850  * Purpose   : The RegisterServiceCtrlHandler function registers a function to
    1851  *             handle service control requests for a service.
    1852  * Parameters: LPCSTR            lpszServiceName address of name of service
    1853  *             LPHANDLER_FUNCTION lpHandlerProc   address of handler function
    1854  * Variables :
    1855  * Result    :
    1856  * Remark    :
    1857  * Status    : UNTESTED STUB
    1858  *
    1859  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
    1860  *****************************************************************************/
    1861 
    1862 #define SERVICE_STATUS_HANDLE DWORD
    1863 #define LPHANDLER_FUNCTION    LPVOID
    1864 SERVICE_STATUS_HANDLE WIN32API RegisterServiceCtrlHandlerA(LPCSTR            lpszServiceName,
    1865                                                               LPHANDLER_FUNCTION lpHandlerProc)
    1866 {
    1867   dprintf(("ADVAPI32: RegisterServiceCtrlHandlerA(%s,%08xh) not implemented.\n",
    1868            lpszServiceName,
    1869            lpHandlerProc));
    1870 
    1871   return (0); /* signal failure */
    1872 }
    1873 
    1874 
    1875 /*****************************************************************************
    1876  * Name      : RegisterServiceCtrlHandlerW
    1877  * Purpose   : The RegisterServiceCtrlHandler function registers a function to
    1878  *             handle service control requests for a service.
    1879  * Parameters: LPCWSTR            lpszServiceName address of name of service
    1880  *             LPHANDLER_FUNCTION lpHandlerProc   address of handler function
    1881  * Variables :
    1882  * Result    :
    1883  * Remark    :
    1884  * Status    : UNTESTED STUB
    1885  *
    1886  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
    1887  *****************************************************************************/
    1888 
    1889 SERVICE_STATUS_HANDLE WIN32API RegisterServiceCtrlHandlerW(LPCWSTR            lpszServiceName,
    1890                                                               LPHANDLER_FUNCTION lpHandlerProc)
    1891 {
    1892   dprintf(("ADVAPI32: RegisterServiceCtrlHandlerW(%s,%08xh) not implemented.\n",
    1893            lpszServiceName,
    1894            lpHandlerProc));
    1895 
    1896   return (0); /* signal failure */
    1897 }
    1898 
    1899 
    1900 
    19011814/*****************************************************************************
    19021815 * Name      : SetAclInformation
     
    19931906
    19941907
    1995 /*****************************************************************************
    1996  * Name      : SetServiceBits
    1997  * Purpose   : The SetServiceBits function registers a service's service type
    1998  *             with the Service Control Manager and the Server service. The
    1999  *             Server service can then announce the registered service type
    2000  *             as one it currently supports. The LAN Manager functions
    2001  *             NetServerGetInfo and NetServerEnum obtain a specified machine's
    2002  *             supported service types.
    2003  *             A service type is represented as a set of bit flags; the
    2004  *             SetServiceBits function sets or clears combinations of those bit flags.
    2005  * Parameters: SERVICE_STATUS_HANDLE hServiceStatus     service status handle
    2006  *             DWORD                 dwServiceBits      service type bits to set or clear
    2007  *             BOOL                  bSetBitsOn         flag to set or clear the service type bits
    2008  *             BOOL                  bUpdateImmediately flag to announce server type immediately
    2009  * Variables :
    2010  * Result    :
    2011  * Remark    :
    2012  * Status    : UNTESTED STUB
    2013  *
    2014  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
    2015  *****************************************************************************/
    2016 
    2017 BOOL WIN32API SetServiceBits(SERVICE_STATUS_HANDLE hServiceStatus,
    2018                                 DWORD                 dwServiceBits,
    2019                                 BOOL                  bSetBitsOn,
    2020                                 BOOL                  bUpdateImmediately)
    2021 {
    2022   dprintf(("ADVAPI32: SetServiceBits(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
    2023            hServiceStatus,
    2024            dwServiceBits,
    2025            bSetBitsOn,
    2026            bUpdateImmediately));
    2027 
    2028   return (FALSE); /* signal failure */
    2029 }
    2030 
    2031 
    2032 
    2033 
     1908
     1909
     1910
  • TabularUnified trunk/src/advapi32/ADVAPI32.DEF

    r2215 r2343  
    1 ; $Id: ADVAPI32.DEF,v 1.10 1999-12-27 18:44:32 sandervl Exp $
     1; $Id: ADVAPI32.DEF,v 1.11 2000-01-06 20:05:00 sandervl Exp $
    22
    33;
     
    77DESCRIPTION 'Odin ADVAPI32.DLL'
    88DATA MULTIPLE NONSHARED
    9 
    10 IMPORTS
    11     _O32_RegCloseKey     = PMWINX.541
    12     _O32_RegCreateKey    = PMWINX.542
    13     _O32_RegCreateKeyEx  = PMWINX.543
    14     _O32_RegDeleteKey    = PMWINX.544
    15     _O32_RegDeleteValue  = PMWINX.545
    16     _O32_RegEnumKey      = PMWINX.546
    17     _O32_RegEnumKeyEx    = PMWINX.547
    18     _O32_RegEnumValue    = PMWINX.548
    19     _O32_RegOpenKey      = PMWINX.549
    20     _O32_RegOpenKeyEx    = PMWINX.550
    21     _O32_RegQueryInfoKey = PMWINX.551
    22     _O32_RegQueryValue   = PMWINX.552
    23     _O32_RegQueryValueEx = PMWINX.553
    24     _O32_RegSetValue     = PMWINX.554
    25     _O32_RegSetValueEx   = PMWINX.555
    269
    2710EXPORTS
  • TabularUnified trunk/src/advapi32/advapi32.h

    r1382 r2343  
    1 /* $Id: advapi32.h,v 1.6 1999-10-20 17:18:17 phaller Exp $ */
     1/* $Id: advapi32.h,v 1.7 2000-01-06 20:05:00 sandervl Exp $ */
    22
    33/*
     
    8888LONG      ODIN_INTERNAL ODIN_RegCreateKeyExW(HKEY,LPCWSTR,DWORD,LPWSTR,DWORD,REGSAM,LPSECURITY_ATTRIBUTES,PHKEY,LPDWORD);
    8989
     90#ifdef USE_ODIN_REGISTRY_APIS
     91#define RegConnectRegistryA ODIN_RegConnectRegistryA
     92#define RegConnectRegistryW ODIN_RegConnectRegistryW
     93#define RegEnumKeyExA ODIN_RegEnumKeyExA
     94#define RegEnumKeyExW ODIN_RegEnumKeyExW
     95#define RegGetKeySecurity ODIN_RegGetKeySecurity
     96#define RegLoadKeyA ODIN_RegLoadKeyA
     97#define RegLoadKeyW ODIN_RegLoadKeyW
     98#define RegNotifyChangeKeyValue ODIN_RegNotifyChangeKeyValue
     99#define RegOpenKeyExW ODIN_RegOpenKeyExW
     100#define RegOpenKeyExA ODIN_RegOpenKeyExA
     101#define RegQueryInfoKeyW ODIN_RegQueryInfoKeyW
     102#define RegQueryInfoKeyA ODIN_RegQueryInfoKeyA
     103#define RegReplaceKeyA ODIN_RegReplaceKeyA
     104#define RegReplaceKeyW ODIN_RegReplaceKeyW
     105#define RegRestoreKeyA ODIN_RegRestoreKeyA
     106#define RegRestoreKeyW ODIN_RegRestoreKeyW
     107#define RegUnLoadKeyA ODIN_RegUnLoadKeyA
     108#define RegUnLoadKeyW ODIN_RegUnLoadKeyW
     109#define RegCloseKey ODIN_RegCloseKey
     110#define RegFlushKey ODIN_RegFlushKey
     111#define RegCreateKeyA ODIN_RegCreateKeyA
     112#define RegCreateKeyW ODIN_RegCreateKeyW
     113#define RegDeleteKeyA ODIN_RegDeleteKeyA
     114#define RegDeleteKeyW ODIN_RegDeleteKeyW
     115#define RegDeleteValueA ODIN_RegDeleteValueA
     116#define RegDeleteValueW ODIN_RegDeleteValueW
     117#define RegEnumKeyA ODIN_RegEnumKeyA
     118#define RegEnumKeyW ODIN_RegEnumKeyW
     119#define RegEnumValueA ODIN_RegEnumValueA
     120#define RegEnumValueW ODIN_RegEnumValueW
     121#define RegOpenKeyA ODIN_RegOpenKeyA
     122#define RegOpenKeyW ODIN_RegOpenKeyW
     123#define RegQueryValueA ODIN_RegQueryValueA
     124#define RegQueryValueW ODIN_RegQueryValueW
     125#define RegQueryValueExA ODIN_RegQueryValueExA
     126#define RegQueryValueExW ODIN_RegQueryValueExW
     127#define RegSetValueA ODIN_RegSetValueA
     128#define RegSetValueW ODIN_RegSetValueW
     129#define RegSetValueExA ODIN_RegSetValueExA
     130#define RegSetValueExW ODIN_RegSetValueExW
     131#define RegCreateKeyExA ODIN_RegCreateKeyExA
     132#define RegCreateKeyExW ODIN_RegCreateKeyExW
     133#endif
    90134
    91135#endif
  • TabularUnified trunk/src/advapi32/makefile

    r2216 r2343  
    1 # $Id: makefile,v 1.17 1999-12-27 18:44:33 sandervl Exp $
     1# $Id: makefile,v 1.18 2000-01-06 20:05:00 sandervl Exp $
    22
    33#
     
    3030        $(LD) $(LDFLAGS) -Fm -Fe$@ $(OBJS) $(TARGET).def \
    3131              $(PDWIN32_LIB)/kernel32.lib $(PDWIN32_LIB)/ntdll.lib \
    32               $(PDWIN32_LIB)/odincrt.lib OS2386.LIB $(RTLLIB_O)
     32              $(PDWIN32_LIB)/odincrt.lib $(PDWIN32_LIB)/pmwinx.lib OS2386.LIB $(RTLLIB_O)
    3333        $(CP) $@ $(PDWIN32_BIN)
    3434
  • TabularUnified trunk/src/advapi32/security.cpp

    r2133 r2343  
    1 /* $Id: security.cpp,v 1.2 1999-12-19 12:24:52 sandervl Exp $ */
     1/* $Id: security.cpp,v 1.3 2000-01-06 20:05:00 sandervl Exp $ */
    22/*
    33 * Win32 security API functions for OS/2
     
    102102}
    103103
     104/*************************************************************************
     105 * SetThreadToken [ADVAPI32.231]
     106 *
     107 * Assigns an "impersonation token" to a thread so it can assume the
     108 * security privledges of another thread or process.  Can also remove
     109 * a previously assigned token.  Only supported on NT - it's a stub
     110 * exactly like this one on Win9X.
     111 *
     112 */
     113
     114BOOL WINAPI SetThreadToken(PHANDLE thread, HANDLE token)
     115{
     116    FIXME(__FUNCTION__"(%p, %x): stub\n", thread, token);
     117
     118    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
     119
     120    return FALSE;
     121}
     122
    104123/******************************************************************************
    105124 * AdjustTokenPrivileges [ADVAPI32.10]
     
    346365                    PSECURITY_DESCRIPTOR lpselfsecdesc, LPDWORD lpbuflen )
    347366{
    348         FIXME_(advapi)("(%p,%p,%p),stub!\n",lpabssecdesc,lpselfsecdesc,lpbuflen);
     367        FIXME(__FUNCTION__"(%p,%p,%p),stub!\n",lpabssecdesc,lpselfsecdesc,lpbuflen);
    349368        return TRUE;
    350369}
     
    356375BOOL WINAPI GetSecurityDescriptorControl ( PSECURITY_DESCRIPTOR  pSecurityDescriptor,
    357376                 PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision)
    358 {       FIXME_(advapi)("(%p,%p,%p),stub!\n",pSecurityDescriptor,pControl,lpdwRevision);
     377{       FIXME(__FUNCTION__"(%p,%p,%p),stub!\n",pSecurityDescriptor,pControl,lpdwRevision);
    359378        return 1;
    360379}               
     
    382401LookupPrivilegeValueW( LPCWSTR lpSystemName, LPCWSTR lpName, LPVOID lpLuid )
    383402{
    384     FIXME_(advapi)("(%s,%s,%p): stub\n",debugstr_w(lpSystemName),
     403    FIXME(__FUNCTION__"(%s,%s,%p): stub\n",debugstr_w(lpSystemName),
    385404                  debugstr_w(lpName), lpLuid);
    386405    return TRUE;
     
    414433                    DWORD nLength, LPDWORD lpnLengthNeeded )
    415434{
    416   FIXME_(advapi)("(%s) : stub\n", debugstr_a(lpFileName));
     435  FIXME(__FUNCTION__"(%s) : stub\n", debugstr_a(lpFileName));
    417436  return TRUE;
    418437}
     
    438457                    DWORD nLength, LPDWORD lpnLengthNeeded )
    439458{
    440   FIXME_(advapi)("(%s) : stub\n", debugstr_w(lpFileName) );
     459  FIXME(__FUNCTION__"(%s) : stub\n", debugstr_w(lpFileName) );
    441460  return TRUE;
    442461}
    443462
     463/******************************************************************************
     464 * SetFileSecurity32A [ADVAPI32.182]
     465 * Sets the security of a file or directory
     466 */
     467BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
     468                                SECURITY_INFORMATION RequestedInformation,
     469                                PSECURITY_DESCRIPTOR pSecurityDescriptor)
     470{
     471  FIXME(__FUNCTION__"(%s) : stub\n", debugstr_a(lpFileName));
     472  return TRUE;
     473}
     474
     475/******************************************************************************
     476 * SetFileSecurity32W [ADVAPI32.183]
     477 * Sets the security of a file or directory
     478 *
     479 * PARAMS
     480 *   lpFileName           []
     481 *   RequestedInformation []
     482 *   pSecurityDescriptor  []
     483 */
     484BOOL WINAPI
     485SetFileSecurityW( LPCWSTR lpFileName,
     486                    SECURITY_INFORMATION RequestedInformation,
     487                    PSECURITY_DESCRIPTOR pSecurityDescriptor )
     488{
     489  FIXME(__FUNCTION__"(%s) : stub\n", debugstr_w(lpFileName) );
     490  return TRUE;
     491}
    444492
    445493/******************************************************************************
     
    451499                     PSID_NAME_USE name_use )
    452500{
    453         FIXME_(security)("(%s,%p,%p,%p,%p,%p,%p): stub\n",
     501        FIXME(__FUNCTION__"(%s,%p,%p,%p,%p,%p,%p): stub\n",
    454502              system,sid,account,accountSize,domain,domainSize,name_use);
    455503        SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
     
    474522                     PSID_NAME_USE name_use )
    475523{
    476         FIXME_(security)("(%p,%p,%p,%p,%p,%p,%p): stub\n",
     524        FIXME(__FUNCTION__"(%p,%p,%p,%p,%p,%p,%p): stub\n",
    477525              system,sid,account,accountSize,domain,domainSize,name_use);
    478526        SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
     
    481529
    482530/******************************************************************************
    483  * SetFileSecurity32A [ADVAPI32.182]
    484  * Sets the security of a file or directory
    485  */
    486 BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
    487                                 SECURITY_INFORMATION RequestedInformation,
    488                                 PSECURITY_DESCRIPTOR pSecurityDescriptor)
    489 {
    490   FIXME_(advapi)("(%s) : stub\n", debugstr_a(lpFileName));
    491   return TRUE;
    492 }
    493 
    494 /******************************************************************************
    495  * SetFileSecurity32W [ADVAPI32.183]
    496  * Sets the security of a file or directory
    497  *
    498  * PARAMS
    499  *   lpFileName           []
    500  *   RequestedInformation []
    501  *   pSecurityDescriptor  []
    502  */
    503 BOOL WINAPI
    504 SetFileSecurityW( LPCWSTR lpFileName,
    505                     SECURITY_INFORMATION RequestedInformation,
    506                     PSECURITY_DESCRIPTOR pSecurityDescriptor )
    507 {
    508   FIXME_(advapi)("(%s) : stub\n", debugstr_w(lpFileName) );
    509   return TRUE;
    510 }
    511 
    512 /******************************************************************************
    513531 * QueryWindows31FilesMigration [ADVAPI32.266]
    514532 *
     
    519537QueryWindows31FilesMigration( DWORD x1 )
    520538{
    521         FIXME_(advapi)("(%ld):stub\n",x1);
     539        FIXME(__FUNCTION__"(%ld):stub\n",x1);
    522540        return TRUE;
    523541}
     
    536554                                               DWORD x4 )
    537555{
    538         FIXME_(advapi)("(0x%08lx,0x%08lx,0x%08lx,0x%08lx):stub\n",x1,x2,x3,x4);
     556        FIXME(__FUNCTION__"(0x%08lx,0x%08lx,0x%08lx,0x%08lx):stub\n",x1,x2,x3,x4);
    539557        return TRUE;
    540558}
     
    555573              PLSA_HANDLE PolicyHandle)
    556574{
    557         FIXME_(advapi)("(%p,%p,0x%08lx,%p):stub\n",
     575        FIXME(__FUNCTION__"(%p,%p,0x%08lx,%p):stub\n",
    558576                       SystemName, ObjectAttributes,
    559577                       DesiredAccess, PolicyHandle);
     
    570588NotifyBootConfigStatus( DWORD x1 )
    571589{
    572         FIXME_(advapi)("(0x%08lx):stub\n",x1);
     590        FIXME(__FUNCTION__"(0x%08lx):stub\n",x1);
    573591        return 1;
    574592}
     
    583601RevertToSelf( void )
    584602{
    585         FIXME_(advapi)("(), stub\n");
     603        FIXME(__FUNCTION__"(), stub\n");
    586604        return TRUE;
    587605}
     
    593611ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
    594612{
    595     FIXME_(advapi)("(%08x), stub\n", ImpersonationLevel);
     613    FIXME(__FUNCTION__"(%08x), stub\n", ImpersonationLevel);
    596614    return TRUE;
    597615}
     
    605623            LPDWORD PrivilegeSetLength, LPDWORD GrantedAccess, LPBOOL AccessStatus)
    606624{
    607     FIXME_(advapi)("(%p, %04x, %08lx, %p, %p, %p, %p, %p), stub\n",
     625    FIXME(__FUNCTION__"(%p, %04x, %08lx, %p, %p, %p, %p, %p), stub\n",
    608626                   pSecurityDescriptor, ClientToken, DesiredAccess, GenericMapping,
    609627                   PrivilegeSet, PrivilegeSetLength, GrantedAccess, AccessStatus);
     
    612630}
    613631
    614 /*************************************************************************
    615  * SetThreadToken [ADVAPI32.231]
    616  *
    617  * Assigns an "impersonation token" to a thread so it can assume the
    618  * security privledges of another thread or process.  Can also remove
    619  * a previously assigned token.  Only supported on NT - it's a stub
    620  * exactly like this one on Win9X.
    621  *
    622  */
    623 
    624 BOOL WINAPI SetThreadToken(PHANDLE thread, HANDLE token)
    625 {
    626     FIXME_(advapi)("(%p, %x): stub\n", thread, token);
    627 
    628     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
    629 
    630     return FALSE;
    631 }
    632 
    633 
    634 
    635 
     632/*****************************************************************************
     633 * Name      : InitializeAcl
     634 * Purpose   : The InitializeAcl function creates a new ACL structure.
     635 *             An ACL is an access-control list.
     636 * Parameters: PACL  pAcl          address of access-control list
     637 *             DWORD nAclLength    size of access-control list
     638 *             DWORD dwAclRevision revision level of access-control list
     639 * Variables :
     640 * Result    :
     641 * Remark    :
     642 * Status    : UNTESTED STUB
     643 *
     644 * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     645 *****************************************************************************/
     646
     647BOOL WIN32API InitializeAcl(PACL  pAcl,
     648                            DWORD nAclLength,
     649                            DWORD dwAclRevision)
     650{
     651  dprintf(("ADVAPI32: InitializeAcl(%08xh,%08xh,%08xh)",
     652           pAcl,
     653           nAclLength,
     654           dwAclRevision));
     655
     656  CallWin32ToNt (RtlCreateAcl(pAcl, nAclLength, dwAclRevision));
     657}
  • TabularUnified trunk/src/advapi32/service.cpp

    r2173 r2343  
    1 /* $Id: service.cpp,v 1.4 1999-12-21 00:35:28 sandervl Exp $ */
     1/* $Id: service.cpp,v 1.5 2000-01-06 20:05:00 sandervl Exp $ */
    22
    33/*
     
    99 * Copyright 1998 Patrick Haller
    1010 *
     11 *
     12 * TODO: Not done; starting services; control handlers and many other things
     13 * TODO: Service status handles are the same as service handles
    1114 *
    1215 * NOTE: Uses registry key for service as handle
     
    2225#include <odinwrap.h>
    2326#include <misc.h>
    24 #include "advapi32.h"
    2527#include <unicode.h>
    2628#include <win\winreg.h>
    2729#include <win\winsvc.h>
    2830#include <heapstring.h>
     31#define USE_ODIN_REGISTRY_APIS
     32#include "advapi32.h"
    2933
    3034ODINDEBUGCHANNEL(ADVAPI32-SERVICE)
     
    4650#define REG_SERVICE_TAG                 "Tag"
    4751#define REG_SERVICE_TAG_W               (LPWSTR)L"Tag"
     52
    4853//Odin key
     54#define REG_SERVICE_BITS                "ServiceBits"
     55#define REG_SERVICE_CONTROLS_ACCEPTED   "ServiceControlsAccepted"
     56#define REG_SERVICE_CHECKPOINT          "dwCheckPoint"
     57#define REG_SERVICE_WAITHINT            "dwWaitHint"
     58#define REG_SERVICE_EXITCODE            "dwWin32ExitCode"
     59#define REG_SERVICE_SPECIFIC_EXITCODE   "dwServiceSpecificExitCode"
    4960#define REG_SERVICE_STATUS              "ServiceStatus"
    5061#define REG_SERVICE_STATUS_W            (LPWSTR)L"ServiceStatus"
    5162//This key exists if DeleteService has been called for a specific service
    5263#define REG_SERVICE_DELETEPENDING       "DeletePending"
     64
     65//Win32 service can call StartServiceCtrlDispatcherA/W only once
     66static BOOL fServiceCtrlDispatcherStarted = FALSE;
    5367
    5468//*****************************************************************************
     
    96110                return 0;
    97111        }
     112        SetLastError(0);
    98113        return keyServices;
    99114  }
     
    183198        return 0;
    184199  }
     200  SetLastError(0);
    185201  return keyThisService;
    186202}
     
    377393
    378394  return (FALSE); /* signal failure */
    379 }
    380 
    381 
    382 /*****************************************************************************
    383  * Name      : SetServiceStatus
    384  * Purpose   : The SetServiceStatus function updates the service control
    385  *             manager's status information for the calling service.
    386  * Parameters: SERVICE_STATUS_HANDLE sshServiceStatus  service status handle
    387  *             LPSERVICE_STATUS      lpssServiceStatus address of status structure
    388  * Variables :
    389  * Result    :
    390  * Remark    :
    391  * Status    : UNTESTED STUB
    392  *
    393  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
    394  *****************************************************************************/
    395 
    396 BOOL WIN32API SetServiceStatus(SERVICE_STATUS_HANDLE sshServiceStatus,
    397                                LPSERVICE_STATUS      lpssServiceStatus)
    398 {
    399   dprintf(("ADVAPI32: SetServiceStatus(%08xh,%08xh) not implemented.\n",
    400            sshServiceStatus,
    401            lpssServiceStatus));
    402 
    403   if(CheckServiceHandle(sshServiceStatus) == FALSE) {
    404         SetLastError(ERROR_INVALID_PARAMETER);
    405         return FALSE;
    406   }
    407 
    408   return (FALSE); /* signal failure */
    409 }
    410 
    411 /*****************************************************************************
    412  * Name      : QueryServiceStatus
    413  * Purpose   : The QueryServiceStatus function retrieves the current status of
    414  *             the specified service.
    415  * Parameters: SC_HANDLE         schService        handle of service
    416  *             LPSERVICE_STATUS  lpssServiceStatus address of service status structure
    417  * Variables :
    418  * Result    :
    419  * Remark    :
    420  * Status    : UNTESTED STUB
    421  *
    422  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
    423  *****************************************************************************/
    424 
    425 BOOL WIN32API QueryServiceStatus(SC_HANDLE         schService,
    426                                  LPSERVICE_STATUS  lpssServiceStatus)
    427 {
    428  DWORD size, keytype;
    429 
    430   dprintf(("ADVAPI32: QueryServiceStatus(%08xh,%08xh) not correctly implemented.\n",
    431            schService,
    432            lpssServiceStatus));
    433 
    434   if(CheckServiceHandle(schService) == FALSE) {
    435         SetLastError(ERROR_INVALID_PARAMETER);
    436         return FALSE;
    437   }
    438 
    439   memset(lpssServiceStatus, 0, sizeof(SERVICE_STATUS));
    440 
    441   size = sizeof(DWORD);
    442   keytype = REG_DWORD;
    443   RegQueryValueExA((HKEY)schService, REG_SERVICE_TYPE, 0, &keytype, (LPBYTE)&lpssServiceStatus->dwServiceType, &size);
    444 
    445   size = sizeof(DWORD);
    446   keytype = REG_DWORD;
    447   RegQueryValueExA((HKEY)schService, REG_SERVICE_STATUS, 0, &keytype, (LPBYTE)&lpssServiceStatus->dwCurrentState, &size);
    448 
    449   //TODO: Should this be set by the service once it has started?
    450   lpssServiceStatus->dwControlsAccepted = SERVICE_ACCEPT_STOP|SERVICE_ACCEPT_PAUSE_CONTINUE|SERVICE_ACCEPT_SHUTDOWN;
    451   return TRUE;
    452395}
    453396
     
    497440 * Result    :
    498441 * Remark    :
    499  * Status    : UNTESTED STUB
    500  *
    501  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     442 * Status    :
     443 *
     444 * Author    : SvL
    502445 *****************************************************************************/
    503446
     
    549492 * Result    :
    550493 * Remark    :
    551  * Status    : UNTESTED STUB
    552  *
    553  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     494 * Status    :
     495 *
     496 * Author    : SvL
    554497 *****************************************************************************/
    555498
     
    566509                                      LPCWSTR   lpDisplayName)
    567510{
     511 LPSTR lpDisplayNameA = NULL, lpBinaryPathNameA = NULL;
     512 LPSTR lpDependenciesA = NULL, lpServiceStartNameA = NULL, lpPasswordA = NULL;
     513 LPSTR lpLoadOrderGroupA = NULL;
     514 BOOL  fRc;
     515
    568516  dprintf(("ADVAPI32: ChangeServiceConfigW(%08xh,%08xh,%08xh,%08xh,%s,%s,%08xh,%s,%s,%s,%s) not implemented.\n",
    569517           hService,
     
    579527           lpDisplayName));
    580528
    581   return (FALSE); /* signal failure */
     529  if(lpDisplayName)
     530        lpDisplayNameA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpDisplayName);
     531  if(lpBinaryPathName)
     532        lpBinaryPathNameA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpBinaryPathName);
     533  if(lpDependencies)
     534        lpDependenciesA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpDependencies);
     535  if(lpServiceStartName)
     536        lpServiceStartNameA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpServiceStartName);
     537  if(lpPassword)
     538        lpPasswordA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpPassword);
     539  if(lpDisplayName)
     540        lpDisplayNameA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpDisplayName);
     541  if(lpLoadOrderGroup)
     542        lpLoadOrderGroupA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpLoadOrderGroup);
     543
     544  fRc = ChangeServiceConfigA(hService,dwServiceType, dwStartType, dwErrorControl,
     545                             lpBinaryPathNameA,
     546                             lpLoadOrderGroupA,
     547                             lpdwTagId,
     548                             lpDependenciesA,
     549                             lpServiceStartNameA,
     550                             lpPasswordA,
     551                             lpDisplayNameA);
     552
     553  if(lpDisplayNameA)            HeapFree(GetProcessHeap(), 0, lpDisplayNameA);
     554  if(lpBinaryPathNameA)         HeapFree(GetProcessHeap(), 0, lpBinaryPathNameA);
     555  if(lpDependenciesA)           HeapFree(GetProcessHeap(), 0, lpDependenciesA);
     556  if(lpServiceStartNameA)       HeapFree(GetProcessHeap(), 0, lpServiceStartNameA);
     557  if(lpPasswordA)               HeapFree(GetProcessHeap(), 0, lpPasswordA);
     558  if(lpLoadOrderGroupA)         HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupA);
     559
     560  return fRc;
    582561}
    583562
     
    593572 * Result    :
    594573 * Remark    :
    595  * Status    : UNTESTED STUB
    596  *
    597  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     574 * Status    :
     575 *
     576 * Author    : SvL
    598577 *****************************************************************************/
    599578
     
    629608
    630609  RegCloseKey((HKEY)hSCObject);
     610  SetLastError(0);
    631611  return TRUE;
    632612}
     
    641621 * Result    :
    642622 * Remark    :
    643  * Status    : UNTESTED STUB
    644  *
    645  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     623 * Status    :
     624 *
     625 * Author    : SvL
    646626 *****************************************************************************/
    647627
     
    660640        return FALSE;
    661641  }
     642  SetLastError(0);
    662643  return TRUE;
    663644}
     
    684665 * Result    :
    685666 * Remark    :
    686  * Status    : UNTESTED STUB
    687  *
    688  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     667 * Status    :
     668 *
     669 * Author    : SvL
    689670 *****************************************************************************/
    690671
     
    766747
    767748  RegCloseKey(keyServices);
     749  SetLastError(0);
    768750  return keyThisService;
    769751}
     
    790772 * Result    :
    791773 * Remark    :
    792  * Status    : UNTESTED STUB
    793  *
    794  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     774 * Status    :
     775 *
     776 * Author    : SvL
    795777 *****************************************************************************/
    796778
     
    872854 * Result    :
    873855 * Remark    :
    874  * Status    : UNTESTED STUB
    875  *
    876  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     856 * Status    :
     857 *
     858 * Author    : SvL
    877859 *****************************************************************************/
    878860
     
    893875  DWORD state = SERVICE_RUNNING;
    894876  if(!RegSetValueExA((HKEY)schService, REG_SERVICE_STATUS, 0, REG_DWORD, (LPBYTE)&state, sizeof(DWORD))) {
     877        SetLastError(0);
    895878        return TRUE;
    896879  }
    897880
     881  //TODO: Really start service
    898882  return (FALSE); /* signal failure */
    899883}
     
    908892 * Result    :
    909893 * Remark    :
    910  * Status    : UNTESTED STUB
    911  *
    912  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     894 * Status    :
     895 *
     896 * Author    : SvL
    913897 *****************************************************************************/
    914898
     
    929913  DWORD state = SERVICE_RUNNING;
    930914  if(!RegSetValueExW((HKEY)schService, REG_SERVICE_STATUS_W, 0, REG_DWORD, (LPBYTE)&state, sizeof(DWORD))) {
     915        SetLastError(0);
    931916        return TRUE;
    932917  }
     918  //TODO: Really start service
    933919  return (FALSE); /* signal failure */
    934920}
     
    942928 * Result    :
    943929 * Remark    :
    944  * Status    : UNTESTED STUB
    945  *
    946  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     930 * Status    :
     931 *
     932 * Author    : SvL
    947933 *****************************************************************************/
    948934
     
    957943  DWORD deletepending = 1;
    958944  if(!RegSetValueExA((HKEY)hService, REG_SERVICE_DELETEPENDING, 0, REG_DWORD, (LPBYTE)&deletepending, sizeof(DWORD))) {
     945        SetLastError(0);
    959946        return TRUE;
    960947  }
     
    974961 * Result    :
    975962 * Remark    :
    976  * Status    : UNTESTED STUB
    977  *
    978  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     963 * Status    :
     964 *
     965 * Author    : SvL
    979966 *****************************************************************************/
    980967
     
    10161003  *lpcchBuffer = size;
    10171004  RegCloseKey(keyThisService);
     1005  SetLastError(0);
    10181006  return TRUE;
    10191007}
     
    10321020 * Result    :
    10331021 * Remark    :
    1034  * Status    : UNTESTED STUB
    1035  *
    1036  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     1022 * Status    :
     1023 *
     1024 * Author    : SvL
    10371025 *****************************************************************************/
    10381026
     
    10741062  *lpcchBuffer = size;
    10751063  RegCloseKey(keyThisService);
     1064  SetLastError(0);
    10761065  return TRUE;
    10771066}
     
    13451334}
    13461335
    1347 
    1348 
     1336//******************************************************************************
     1337//Helper for StartServiceCtrlDispatcherA/W; counts nr or arguments in cmd line
     1338//******************************************************************************
     1339ULONG CountNrArgs(char *cmdline)
     1340{
     1341 char *cmd = cmdline;
     1342 ULONG nrargs = 0;
     1343
     1344  while(*cmd == ' ') cmd++; //skip leading spaces
     1345  while(*cmd != 0) {
     1346        while(*cmd != ' ' && *cmd != 0) cmd++; //skip non-space chars
     1347        while(*cmd == ' ' && *cmd != 0) cmd++; //skip spaces
     1348        nrargs++;       
     1349  }
     1350  return nrargs;
     1351}
    13491352
    13501353/*****************************************************************************
     
    13571360 * Result    :
    13581361 * Remark    :
    1359  * Status    : UNTESTED STUB
    1360  *
    1361  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     1362 * Status    :
     1363 *
     1364 * Author    : SvL
    13621365 *****************************************************************************/
    13631366
    13641367BOOL WIN32API StartServiceCtrlDispatcherW(LPSERVICE_TABLE_ENTRYW lpsteServiceTable)
    13651368{
    1366   dprintf(("ADVAPI32: StartServiceCtrlDispatcherW(%08xh) not implemented.\n",
    1367            lpsteServiceTable));
    1368 
    1369   return (FALSE); /* signal failure */
    1370 }
    1371 
     1369 ULONG nrArgs = 0;
     1370 LPWSTR cmdline;
     1371
     1372  dprintf(("ADVAPI32: StartServiceCtrlDispatcherW(%x)", lpsteServiceTable));
     1373
     1374  if(fServiceCtrlDispatcherStarted == TRUE) {
     1375        SetLastError(ERROR_SERVICE_ALREADY_RUNNING);
     1376        return FALSE;
     1377  }
     1378  fServiceCtrlDispatcherStarted = TRUE;
     1379  if(lpsteServiceTable->lpServiceProc == NULL) {
     1380        SetLastError(ERROR_INVALID_DATA); //or invalid parameter?
     1381        return FALSE;
     1382  }
     1383  while(lpsteServiceTable->lpServiceProc) {
     1384        cmdline = (LPWSTR)GetCommandLineW();
     1385        nrArgs  = CountNrArgs((LPSTR)GetCommandLineA());
     1386        lpsteServiceTable->lpServiceProc(nrArgs, cmdline);
     1387        lpsteServiceTable++; //next service entrypoint
     1388  }
     1389  SetLastError(0);
     1390  return TRUE;
     1391}
    13721392
    13731393/*****************************************************************************
     
    13801400 * Result    :
    13811401 * Remark    :
    1382  * Status    : UNTESTED STUB
    1383  *
    1384  * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     1402 * Status    :
     1403 *
     1404 * Author    : SvL
    13851405 *****************************************************************************/
    13861406
    13871407BOOL WIN32API StartServiceCtrlDispatcherA(LPSERVICE_TABLE_ENTRYA lpsteServiceTable)
    13881408{
    1389   dprintf(("ADVAPI32: StartServiceCtrlDispatcherA(%08xh) not implemented.\n",
    1390            lpsteServiceTable));
    1391 
     1409 ULONG nrArgs = 0;
     1410 LPSTR cmdline;
     1411
     1412  dprintf(("ADVAPI32: StartServiceCtrlDispatcherA(%08xh)", lpsteServiceTable));
     1413
     1414  if(fServiceCtrlDispatcherStarted == TRUE) {
     1415        SetLastError(ERROR_SERVICE_ALREADY_RUNNING);
     1416        return FALSE;
     1417  }
     1418  fServiceCtrlDispatcherStarted = TRUE;
     1419  if(lpsteServiceTable->lpServiceProc == NULL) {
     1420        SetLastError(ERROR_INVALID_DATA); //or invalid parameter?
     1421        return FALSE;
     1422  }
     1423  while(lpsteServiceTable->lpServiceProc) {
     1424        cmdline = (LPSTR)GetCommandLineA();
     1425        nrArgs  = CountNrArgs(cmdline);
     1426        lpsteServiceTable->lpServiceProc(nrArgs, cmdline);
     1427        lpsteServiceTable++; //next service entrypoint
     1428  }
     1429  SetLastError(0);
     1430  return TRUE;
     1431}
     1432
     1433/*****************************************************************************
     1434 * Name      : RegisterServiceCtrlHandlerA
     1435 * Purpose   : The RegisterServiceCtrlHandler function registers a function to
     1436 *             handle service control requests for a service.
     1437 * Parameters: LPCSTR            lpszServiceName address of name of service
     1438 *             LPHANDLER_FUNCTION lpHandlerProc   address of handler function
     1439 * Variables :
     1440 * Result    :
     1441 * Remark    :
     1442 * Status    :
     1443 *
     1444 * Author    : SvL
     1445 *****************************************************************************/
     1446
     1447SERVICE_STATUS_HANDLE WIN32API RegisterServiceCtrlHandlerA(LPCSTR            lpszServiceName,
     1448                                                           LPHANDLER_FUNCTION lpHandlerProc)
     1449{
     1450 SC_HANDLE hSCMgr, hService;
     1451
     1452  dprintf(("ADVAPI32: RegisterServiceCtrlHandlerA(%s,%08xh) not implemented (FAKED)",
     1453           lpszServiceName,
     1454           lpHandlerProc));
     1455
     1456  //Doesn't work for services of type
     1457  if(lpszServiceName == NULL) {
     1458        SetLastError(ERROR_INVALID_NAME);
     1459        return 0;
     1460  }
     1461  hSCMgr = OpenSCManagerA(NULL, NULL, SC_MANAGER_ALL_ACCESS);
     1462  hService = OpenServiceA(hSCMgr, lpszServiceName, SERVICE_ALL_ACCESS);
     1463  if(hService == 0) {
     1464        SetLastError(ERROR_INVALID_NAME);
     1465        return 0;
     1466  }
     1467  CloseServiceHandle(hSCMgr);
     1468  //TODO: Start thread with ctrl handler
     1469  SetLastError(0);
     1470  return hService;
     1471}
     1472
     1473
     1474/*****************************************************************************
     1475 * Name      : RegisterServiceCtrlHandlerW
     1476 * Purpose   : The RegisterServiceCtrlHandler function registers a function to
     1477 *             handle service control requests for a service.
     1478 * Parameters: LPCWSTR            lpszServiceName address of name of service
     1479 *             LPHANDLER_FUNCTION lpHandlerProc   address of handler function
     1480 * Variables :
     1481 * Result    :
     1482 * Remark    :
     1483 * Status    :
     1484 *
     1485 * Author    : SvL
     1486 *****************************************************************************/
     1487
     1488SERVICE_STATUS_HANDLE WIN32API RegisterServiceCtrlHandlerW(LPCWSTR            lpszServiceName,
     1489                                                           LPHANDLER_FUNCTION lpHandlerProc)
     1490{
     1491 SC_HANDLE hSCMgr, hService;
     1492 
     1493  dprintf(("ADVAPI32: RegisterServiceCtrlHandlerW(%s,%08xh) not implemented (FAKED)",
     1494           lpszServiceName,
     1495           lpHandlerProc));
     1496
     1497  //Doesn't work for services of type
     1498  if(lpszServiceName == NULL) {
     1499        SetLastError(ERROR_INVALID_NAME);
     1500        return 0;
     1501  }
     1502  hSCMgr = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
     1503  hService = OpenServiceW(hSCMgr, lpszServiceName, SERVICE_ALL_ACCESS);
     1504  if(hService == 0) {
     1505        SetLastError(ERROR_INVALID_NAME);
     1506        return 0;
     1507  }
     1508  CloseServiceHandle(hSCMgr);
     1509  //TODO: Start thread with ctrl handler
     1510  SetLastError(0);
     1511  return hService;
     1512}
     1513
     1514/*****************************************************************************
     1515 * Name      : SetServiceBits
     1516 * Purpose   : The SetServiceBits function registers a service's service type
     1517 *             with the Service Control Manager and the Server service. The
     1518 *             Server service can then announce the registered service type
     1519 *             as one it currently supports. The LAN Manager functions
     1520 *             NetServerGetInfo and NetServerEnum obtain a specified machine's
     1521 *             supported service types.
     1522 *             A service type is represented as a set of bit flags; the
     1523 *             SetServiceBits function sets or clears combinations of those bit flags.
     1524 * Parameters: SERVICE_STATUS_HANDLE hServiceStatus     service status handle
     1525 *             DWORD                 dwServiceBits      service type bits to set or clear
     1526 *             BOOL                  bSetBitsOn         flag to set or clear the service type bits
     1527 *             BOOL                  bUpdateImmediately flag to announce server type immediately
     1528 * Variables :
     1529 * Result    :
     1530 * Remark    :
     1531 * Status    :
     1532 *
     1533 * Author    : SvL
     1534 *****************************************************************************/
     1535
     1536BOOL WIN32API SetServiceBits(SERVICE_STATUS_HANDLE hServiceStatus,
     1537                             DWORD              dwServiceBits,
     1538                             BOOL               bSetBitsOn,
     1539                             BOOL               bUpdateImmediately)
     1540{
     1541 ULONG size, keytype, servicebits;
     1542
     1543  dprintf(("ADVAPI32: SetServiceBits(%08xh,%08xh,%08xh,%08xh) not correctly implemented",
     1544           hServiceStatus,
     1545           dwServiceBits,
     1546           bSetBitsOn,
     1547           bUpdateImmediately));
     1548
     1549  if(CheckServiceHandle(hServiceStatus) == FALSE) {
     1550        SetLastError(ERROR_INVALID_PARAMETER);
     1551        return FALSE;
     1552  }
     1553  //According to the Platform SDK these bits are reserved by MS and we should return
     1554  //ERROR_INVALID_DATA
     1555  if(dwServiceBits & 0xC00F3F7B) {
     1556        SetLastError(ERROR_INVALID_DATA);
     1557        return FALSE;
     1558  }
     1559
     1560  size = sizeof(DWORD);
     1561  keytype = REG_DWORD;
     1562  if(RegQueryValueExA((HKEY)hServiceStatus, REG_SERVICE_BITS, 0, &keytype, (LPBYTE)&servicebits, &size)) {
     1563        servicebits = 0;
     1564  }
     1565  if(bSetBitsOn) {
     1566        servicebits |= dwServiceBits;
     1567  }
     1568  else  servicebits &= (~dwServiceBits);
     1569
     1570  if(!RegSetValueExA((HKEY)hServiceStatus, REG_SERVICE_BITS, 0, REG_DWORD, (LPBYTE)&servicebits, sizeof(DWORD))) {
     1571        SetLastError(0);
     1572        return TRUE;
     1573  }
    13921574  return (FALSE); /* signal failure */
    13931575}
    13941576
    1395 
     1577/*****************************************************************************
     1578 * Name      : SetServiceStatus
     1579 * Purpose   : The SetServiceStatus function updates the service control
     1580 *             manager's status information for the calling service.
     1581 * Parameters: SERVICE_STATUS_HANDLE sshServiceStatus  service status handle
     1582 *             LPSERVICE_STATUS      lpssServiceStatus address of status structure
     1583 * Variables :
     1584 * Result    :
     1585 * Remark    : Called from ServiceMain function (registered with RegisterServiceCtrlHandler)
     1586 * Status    :
     1587 *
     1588 * Author    : SvL
     1589 *****************************************************************************/
     1590
     1591BOOL WIN32API SetServiceStatus(SERVICE_STATUS_HANDLE sshServiceStatus,
     1592                               LPSERVICE_STATUS      lpssServiceStatus)
     1593{
     1594  dprintf(("ADVAPI32: SetServiceStatus(%08xh,%08xh) not implemented correctly.\n",
     1595           sshServiceStatus,
     1596           lpssServiceStatus));
     1597
     1598  if(CheckServiceHandle(sshServiceStatus) == FALSE) {
     1599        SetLastError(ERROR_INVALID_PARAMETER);
     1600        return FALSE;
     1601  }
     1602
     1603  RegSetValueExA((HKEY)sshServiceStatus, REG_SERVICE_TYPE, 0, REG_DWORD, (LPBYTE)&lpssServiceStatus->dwServiceType, sizeof(DWORD));
     1604  RegSetValueExA((HKEY)sshServiceStatus, REG_SERVICE_STATUS, 0, REG_DWORD, (LPBYTE)&lpssServiceStatus->dwCurrentState, sizeof(DWORD));
     1605  RegSetValueExA((HKEY)sshServiceStatus, REG_SERVICE_CONTROLS_ACCEPTED, 0, REG_DWORD, (LPBYTE)&lpssServiceStatus->dwControlsAccepted, sizeof(DWORD));
     1606
     1607  RegSetValueExA((HKEY)sshServiceStatus, REG_SERVICE_EXITCODE, 0, REG_DWORD, (LPBYTE)&lpssServiceStatus->dwWin32ExitCode, sizeof(DWORD));
     1608  RegSetValueExA((HKEY)sshServiceStatus, REG_SERVICE_SPECIFIC_EXITCODE, 0, REG_DWORD, (LPBYTE)&lpssServiceStatus->dwServiceSpecificExitCode, sizeof(DWORD));
     1609
     1610  RegSetValueExA((HKEY)sshServiceStatus, REG_SERVICE_CHECKPOINT, 0, REG_DWORD, (LPBYTE)&lpssServiceStatus->dwCheckPoint, sizeof(DWORD));
     1611  RegSetValueExA((HKEY)sshServiceStatus, REG_SERVICE_WAITHINT, 0, REG_DWORD, (LPBYTE)&lpssServiceStatus->dwWaitHint, sizeof(DWORD));
     1612
     1613  SetLastError(0);
     1614  return TRUE;
     1615}
     1616
     1617/*****************************************************************************
     1618 * Name      : QueryServiceStatus
     1619 * Purpose   : The QueryServiceStatus function retrieves the current status of
     1620 *             the specified service.
     1621 * Parameters: SC_HANDLE         schService        handle of service
     1622 *             LPSERVICE_STATUS  lpssServiceStatus address of service status structure
     1623 * Variables :
     1624 * Result    :
     1625 * Remark    :
     1626 * Status    :
     1627 *
     1628 * Author    : SvL
     1629 *****************************************************************************/
     1630
     1631BOOL WIN32API QueryServiceStatus(SC_HANDLE         schService,
     1632                                 LPSERVICE_STATUS  lpssServiceStatus)
     1633{
     1634 DWORD size, keytype;
     1635
     1636  dprintf(("ADVAPI32: QueryServiceStatus(%08xh,%08xh) not correctly implemented.\n",
     1637           schService,
     1638           lpssServiceStatus));
     1639
     1640  if(CheckServiceHandle(schService) == FALSE) {
     1641        SetLastError(ERROR_INVALID_PARAMETER);
     1642        return FALSE;
     1643  }
     1644
     1645  memset(lpssServiceStatus, 0, sizeof(SERVICE_STATUS));
     1646
     1647  size = sizeof(DWORD);
     1648  keytype = REG_DWORD;
     1649  RegQueryValueExA((HKEY)schService, REG_SERVICE_TYPE, 0, &keytype, (LPBYTE)&lpssServiceStatus->dwServiceType, &size);
     1650
     1651  size = sizeof(DWORD);
     1652  keytype = REG_DWORD;
     1653  RegQueryValueExA((HKEY)schService, REG_SERVICE_STATUS, 0, &keytype, (LPBYTE)&lpssServiceStatus->dwCurrentState, &size);
     1654
     1655  size = sizeof(DWORD);
     1656  keytype = REG_DWORD;
     1657  RegQueryValueExA((HKEY)schService, REG_SERVICE_CONTROLS_ACCEPTED, 0, &keytype, (LPBYTE)&lpssServiceStatus->dwControlsAccepted, &size);
     1658
     1659  size = sizeof(DWORD);
     1660  keytype = REG_DWORD;
     1661  RegQueryValueExA((HKEY)schService, REG_SERVICE_EXITCODE, 0, &keytype, (LPBYTE)&lpssServiceStatus->dwWin32ExitCode, &size);
     1662
     1663  size = sizeof(DWORD);
     1664  keytype = REG_DWORD;
     1665  RegQueryValueExA((HKEY)schService, REG_SERVICE_SPECIFIC_EXITCODE, 0, &keytype, (LPBYTE)&lpssServiceStatus->dwServiceSpecificExitCode, &size);
     1666
     1667  size = sizeof(DWORD);
     1668  keytype = REG_DWORD;
     1669  RegQueryValueExA((HKEY)schService, REG_SERVICE_CHECKPOINT, 0, &keytype, (LPBYTE)&lpssServiceStatus->dwCheckPoint, &size);
     1670
     1671  size = sizeof(DWORD);
     1672  keytype = REG_DWORD;
     1673  RegQueryValueExA((HKEY)schService, REG_SERVICE_WAITHINT, 0, &keytype, (LPBYTE)&lpssServiceStatus->dwWaitHint, &size);
     1674 
     1675  SetLastError(0);
     1676  return TRUE;
     1677}
Note: See TracChangeset for help on using the changeset viewer.