ChangeServiceConfig

ChangeServiceConfig problem setting logon credentials Ive got this weird problem - Im calling ChangeServiceConfig on a newly installed service (I CreateService it myself) to supply the logon credentials, but while the function succeeds (returns TRUE), 阅读详情

ChangeServiceConfig

The ChangeServiceConfig function changes the configuration parameters of a service.

To change the optional configuration parameters, use the ChangeServiceConfig2 function.

BOOL ChangeServiceConfig(
  SC_HANDLE hService,
  DWORD dwServiceType,
  DWORD dwStartType,
  DWORD dwErrorControl,
  LPCTSTR lpBinaryPathName,
  LPCTSTR lpLoadOrderGroup,
  LPDWORD lpdwTagId,
  LPCTSTR lpDependencies,
  LPCTSTR lpServiceStartName,
  LPCTSTR lpPassword,
  LPCTSTR lpDisplayName
);
Parameters
hService
[in] Handle to the service. This handle is returned by the OpenService or CreateService function and must have the SERVICE_CHANGE_CONFIG access right. For more information, see Service Security and Access Rights.
dwServiceType
[in] Type of service. Specify SERVICE_NO_CHANGE if you are not changing the existing service type; otherwise, specify one of the following service types.
ValueMeaning
SERVICE_FILE_SYSTEM_DRIVER
0x00000002
File system driver service.
SERVICE_KERNEL_DRIVER
0x00000001
Driver service.
SERVICE_WIN32_OWN_PROCESS
0x00000010
Service that runs in its own process.
SERVICE_WIN32_SHARE_PROCESS
0x00000020
Service that shares a process with other services.

If you specify either SERVICE_WIN32_OWN_PROCESS or SERVICE_WIN32_SHARE_PROCESS, and the service is running in the context of the LocalSystem account, you can also specify the following type.

ValueMeaning
SERVICE_INTERACTIVE_PROCESS
0x00000100
The service can interact with the desktop.

For more information, see Interactive Services.

dwStartType
[in] Service start options. Specify SERVICE_NO_CHANGE if you are not changing the existing start type; otherwise, specify one of the following values.
ValueMeaning
SERVICE_AUTO_START
0x00000002
A service started automatically by the service control manager during system startup.
SERVICE_BOOT_START
0x00000000
A device driver started by the system loader. This value is valid only for driver services.
SERVICE_DEMAND_START
0x00000003
A service started by the service control manager when a process calls the StartService function.
SERVICE_DISABLED
0x00000004
A service that cannot be started. Attempts to start the service result in the error code ERROR_SERVICE_DISABLED.
SERVICE_SYSTEM_START
0x00000001
A device driver started by the IoInitSystem function. This value is valid only for driver services.
dwErrorControl
[in] Severity of the error, and action taken, if this service fails to start. Specify SERVICE_NO_CHANGE if you are not changing the existing error control; otherwise, specify one of the following values.
ValueMeaning
SERVICE_ERROR_CRITICAL
0x00000003
The startup program logs the error, if possible. If the last-known-good configuration is being started, the startup operation fails. Otherwise, the system is restarted with the last-known good configuration.
SERVICE_ERROR_IGNORE
0x00000000
The startup program logs the error but continues the startup operation.
SERVICE_ERROR_NORMAL
0x00000001
The startup program logs the error and puts up a message box pop-up but continues the startup operation.
SERVICE_ERROR_SEVERE
0x00000002
The startup program logs the error. If the last-known-good configuration is being started, the startup operation continues. Otherwise, the system is restarted with the last-known-good configuration.
lpBinaryPathName
[in] Pointer to a null-terminated string that contains the fully qualified path to the service binary file. Specify NULL if you are not changing the existing path. If the path contains a space, it must be quoted so that it is correctly interpreted. For example, "d://my share//myservice.exe" should be specified as "/"d://my share//myservice.exe/"".

The path can also include arguments for an auto-start service. For example, "d://myshare//myservice.exe arg1 arg2". These arguments are passed to the service entry point (typically the main function).

lpLoadOrderGroup
[in] Pointer to a null-terminated string that names the load ordering group of which this service is a member. Specify NULL if you are not changing the existing group. Specify an empty string if the service does not belong to a group.

The startup program uses load ordering groups to load groups of services in a specified order with respect to the other groups. The list of load ordering groups is contained in the ServiceGroupOrder value of the following registry key:

HKEY_LOCAL_MACHINE/System/CurrentControlSet/Control

lpdwTagId
[out] Pointer to a variable that receives a tag value that is unique in the group specified in the lpLoadOrderGroup parameter. Specify NULL if you are not changing the existing tag.

You can use a tag for ordering service startup within a load ordering group by specifying a tag order vector in the GroupOrderList value of the following registry key:

HKEY_LOCAL_MACHINE/System/CurrentControlSet/Control

Tags are only evaluated for driver services that have SERVICE_BOOT_START or SERVICE_SYSTEM_START start types.

lpDependencies
[in] Pointer to a double null-terminated array of null-separated names of services or load ordering groups that the system must start before this service can be started. (Dependency on a group means that this service can run if at least one member of the group is running after an attempt to start all members of the group.) Specify NULL if you are not changing the existing dependencies. Specify an empty string if the service has no dependencies.

You must prefix group names with SC_GROUP_IDENTIFIER so that they can be distinguished from a service name, because services and service groups share the same name space.

lpServiceStartName
[in] Pointer to a null-terminated string that specifies the name of the account under which the service should run. Specify NULL if you are not changing the existing account name. If the service type is SERVICE_WIN32_OWN_PROCESS, use an account name in the form DomainName/ UserName. The service process will be logged on as this user. If the account belongs to the built-in domain, you can specify ./ UserName (note that the corresponding C/C++ string is ".// UserName"). For more information, see Service User Accounts and the warning in the Remarks section.
Windows NT:  If the service type is SERVICE_WIN32_SHARE_PROCESS, you must specify the LocalSystem account. On later versions of Windows, a shared process can run as any user.

If the service type is SERVICE_KERNEL_DRIVER or SERVICE_FILE_SYSTEM_DRIVER, the name is the driver object name that the system uses to load the device driver. Specify NULL if the driver is to use a default object name created by the I/O system.

lpPassword
[in] Pointer to a null-terminated string that contains the password to the account name specified by the lpServiceStartName parameter. Specify NULL if you are not changing the existing password. Specify an empty string if the account has no password or if the service runs in the LocalService, NetworkService, or LocalSystem account. For more information, see Service Record List.

Passwords are ignored for driver services.

lpDisplayName
[in] Pointer to a null-terminated string that contains the display name to be used by applications to identify the service for its users. Specify NULL if you are not changing the existing display name; otherwise, this string has a maximum length of 256 characters. The name is case-preserved in the service control manager. Display name comparisons are always case-insensitive.
Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

The following error codes may be set by the service control manager. Other error codes may be set by the registry functions that are called by the service control manager.

Return codeDescription
ERROR_ACCESS_DENIEDThe handle does not have the SERVICE_CHANGE_CONFIG access right.
ERROR_CIRCULAR_DEPENDENCYA circular service dependency was specified.
ERROR_DUPLICATE_SERVICE_NAMEThe display name already exists in the service controller manager database, either as a service name or as another display name.
ERROR_INVALID_HANDLEThe specified handle is invalid.
ERROR_INVALID_PARAMETERA parameter that was specified is invalid.
ERROR_INVALID_SERVICE_ACCOUNTThe account name does not exist, or a service is specified to share the same binary file as an already installed service but with an account name that is not the same as the installed service.
ERROR_SERVICE_MARKED_FOR_DELETEThe service has been marked for deletion.
Remarks

The ChangeServiceConfig function changes the configuration information for the specified service in the service control manager database. You can obtain the current configuration information by using the QueryServiceConfig function.

If the configuration is changed for a service that is running, with the exception of lpDisplayName, the changes do not take effect until the service is stopped. To update the credentials without having to restart the service, use the LsaCallAuthenticationPackage function.

Security Remarks

Setting the lpServiceStartName parameter changes the logon account of the service. This can cause problems. If you have registered a service principal name (SPN), it would now be registered on the wrong account. Similarly, if you have used an ACE to grant access to a service, it would now grant access to the wrong account.

Example Code

For an example, see Changing a Service Configuration.

Requirements
ClientRequires Windows XP, Windows 2000 Professional, or Windows NT Workstation.
ServerRequires Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header

Declared in Winsvc.h; include Windows.h.

Library

Link to Advapi32.lib.

DLLRequires Advapi32.dll.
Unicode

Implemented as ChangeServiceConfigW (Unicode) and ChangeServiceConfigA (ANSI).

SCShell:依靠ChangeServiceConfigA来运行命令的无文件横向移动工具 壳牌 SCShell是无文件横向移动工具,它依赖ChangeServiceConfigA来运行命令。 该工具的优点在于它不会针对SMB执行身份验证。 一切都通过DCERPC执行。 该实用程序可以在不注册服务或创建服务的情况下远程使用。 它也不必删除远程系统上的任何文件*(取决于用于执行的技术) 它是如何工作的 无需创建服务,而只需通过ChangeServiceConfigA API远程打开服务并修改二进制路径名即可。 然后启动服务。 执行完成后,服务二进制路径将还原为原始路径。 原始服务路径是使用QueryServiceConfigA提取的。 一切都通过DCERPC进行,包括身份验证。 用法 当前的版本是用C编写的,但是我将其移植到C#和PowerShell 。 Usage: SCShell.exe target service payload domain username p 立即下载

相关推荐

Computers & Security 投稿实战:从零到一详解避坑指南

本文详细解析了向《Computers & Security》投稿的全流程避坑指南,包括ORCID账号注册、文件格式统一、Editorial Manager®系统操作技巧等关键步骤。特别强调了cover letter撰写、Declaration of Interest Statement准备以及PDF生成后的检查要点,帮助研究者高效完成投稿流程。

weixin_29228203的博客 676

ChangeServiceConfig函数

ChangeServiceConfig函数可以配置更多关于服务的信息,下面列出其原型:BOOL ChangeServiceConfig( SC_HANDLE hService      // 打开服务时返回的句柄 DWORD dwServiceType,    // 服务的类型 DWORD dwStartType,      // 何时启动服务 DWORD dwErrorCon

gaobc的专栏 2170

保姆级教程:用Python+OpenCV实现相移法与格雷码三维重建(从生成条纹到点云生成)

本文详细介绍了使用Python和OpenCV实现相移法与格雷码三维重建的全流程,从条纹生成到点云计算。通过结构光技术,结合相移法和格雷码,实现高精度的三维重建,适用于无纹理物体表面的密集对应点生成。教程包含环境搭建、条纹生成、相位计算、三维点云重建及常见问题排查,适合计算机视觉开发者和研究人员。

weixin_33443333的博客 351

windows创建服务:更新服务信息乱码问题(ChangeServiceConfig)

因为小项目需要创建windows服务,安装微软官方示例一切都挺顺利,代码运行后发现配置的信息在系统里显示乱码。打开注册表发现的确是乱码。这就排除软件读取得问题,而是调用ChangeServiceConfig系统函数写入时就发生了乱码。让我在网上查找了一下午,都没有结果。主要是我是按照官方的示例创建的呀,既然是官方示例,出现bug的可能就极小。没法,静下心来看官方文档吧。功夫不负有心人,终于让我发现了问题。记录一下错误过程:出现问题的地方是windows的很多函数都会用宏预先处理调用函数。

开软古剑楠 821

【AI绘图进阶指南】Latent Diffusion Model核心组件解析——从理论到实践

本文深入解析Latent Diffusion Model(LDM)的核心组件,包括Autoencoder、Denoiser和Conditioning Encoder的工作原理及实践应用。通过理论结合代码示例,揭示LDM如何高效处理图像生成任务,并优化AI绘图流程,为开发者提供从理论到实践的进阶指南。

weixin_42628941的博客 387

PDN设计

作者:AirCity 2020.2.6 Aircity007@sina.com 本文所有权归作者Aircity所有 PDN设计的目的是降低电源纹波水平,减小电压跌落。我们通常要求LDO的文波水平是30mV,DCDC是50mV,超过这个就需要PDN设计。 PDN设计的方法是用不同的容值,合适的总电容量,降低电源平面与地平面之间的交流阻抗,确定容值总量和电容大小的过程,就是PDN设计过程。 为什么需...

AirCity123的博客 4148

ChangeServiceConfig2

ChangeServiceConfig2The ChangeServiceConfig2 function changes the optional configuration parameters of a service.BOOL ChangeServiceConfig2( SC_HANDLE hService, DWORD dwInfoLevel, LPVOID lpInf

小发猫 2863

linux系统下安装nexus做私服仓库

1.下载地址 官网地址:https://www.sonatype.com/download-oss-sonatype选择相应的版本即可 2.示例环境 linux系统:CentOS 7 JDK: 1.8 Nexus:nexus-3.16.2-01-unix.tar.gz 3.环境安装 从官网上下载安装包拷贝到linux环境中并解压; 如上图,进入bin目录中,然后运行./nexu...

chang18829350947的博客 1581

windows的sc 服务配置管理 (services Configuration)

大家用windows系统可能比较熟悉, 但是不是做windwos运维方向的话, 可能对系统的维护管理并不是很了解. 比如服务管理, 下面简单介绍一下windows的服务管理配置, 一般软件安装后会自动注册为系统服务. 可以随系统启动一并启动, 也可以通过系统管理来进行启动停止, 延迟启动等操作. 也是十分方便的. 操作方法: 在cmd命令行下操作 打开cmd窗口或按下win+R 输入cmd打开都可以. 输入sc 命令, 后面如果不输入其他选项的话, 会出现很多的相关参数...

星月情缘的博客 1804

Flowable高级篇 -6.8.0 最全表结构说明-主要表结构字段注释

flowable 28张表 详细

billzhen的博客 1万+

BMS硬件设计核心:安全、精度与EMC的工程平衡

电池管理系统(BMS)是保障锂电安全运行的关键嵌入式子系统,其本质是在高精度模拟测量、实时故障响应与复杂电磁环境适应性之间达成工程平衡。原理上,BMS依赖专用监测芯片(如BQ76920)实现微秒级硬件保护,结合主控MCU(如STM32)完成策略决策与通信管理,形成‘安全协处理器+智能主控’双架构。技术价值体现在对过压/欠压/过流/温度等多维故障的毫秒级闭环处置能力,支撑SOC/SOH估算可信度与系统鲁棒性。典型应用场景涵盖电动工具、轻型电动车及储能模块等中低串数电池组。本文聚焦BMS控制板在时钟布局、电源滤

weixin_30591519的博客 71

Windows服务编写

摘要:几乎所有的操作系统在启动的时候都会启动一些不需要与用户交互的进程,这些进程在Windows中就被称作服务。它由服务程序、服务控制程序(SCP,service control program)和服务控制管理器(SCM,service control manager)三个组件构成。本文针对服务程序与服务控制程序的编写进行综合讲述。    关键词:Windows,服务,VC++•1    

lziog的专栏 1805

10、犹豫双模糊TOPSIS算法:原理与实例解析

本文介绍了犹豫双模糊TOPSIS算法的基本原理与应用步骤,结合中国四家纺织公司的案例,详细解析了从构建犹豫双模糊决策矩阵、归一化处理、专家信息聚合,到确定正负理想解、计算距离与相对贴近度系数的完整决策流程。该方法有效应对决策者在评价过程中的犹豫性,适用于财务评估、项目选择等复杂多属性决策场景,具有较强的实用性和推广价值。

yhn45678901的博客 123

ChangeServiceConfig2设置SERVICE_CONFIG_FAILURE_ACTIONS

SERVICE_FAILURE_ACTIONS sdBuf={0};    BOOL bSuccess=TRUE;  if (argc!=2) {  return 1; }    // Open a handle to the service.  SC_HANDLE sch=OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS); if (sch==NULL)

tianyu的专栏 - Linux site:blog.youkuaiyun.com/wishfly 4554

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

ChangeServiceConfig2 function

ChangeServiceConfig2 function   Changes the optional configuration parameters of a service. Syntax C++   BOOL WINAPI ChangeServiceConfig2( _In_     SC_HANDLE hService, _In_  ...

weixin_33970449的博客 485

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

MS Windows DCE-RPC svcctl ChangeServiceConfig2A() 0day Memory Corruption PoC Exploit

#!/usr/bin/python# MS Windows DCE-RPC svcctl ChangeServiceConfig2A() 0day Memory Corruption PoC Exploit# Bug discovered by Krystian Kloskowski (h07) # Tested on Windows 2000 SP4 Polish (all patches)##

1928

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

API ChangeServiceConfig La bless d1

 Welcome to my blog!La bless you, Masr George! said Aunt Chloe, with earnestness, catching his arm, you wouldnt be for cuttin it wid dat ar great heavy knife! Smash all downspile all de pretty rise of

huihuang1414的专栏 637

java调用windows系统API:一个完整的ChangeServiceConfig例子

[code="java"]#include "C:\Documents and Settings\Joe Chen\桌面\c源文件\sdfds\sdfds\org_hexun_wangchong_admin_dll_Dll.h"; #include #include #include using namespace std ; bool modifyServiceC...

不懂夜的黑 342

C++ 修改 Windows Service【转】

原文:http://msdn.microsoft.com/en-us/library/windows/desktop/ms682006(v=vs.85).aspx // // Purpose: // Disables the service. // // Parameters: // None // // Return value: // None ...

245

Changing a Service Configuration

Changing a Service ConfigurationIn the following example, a service configuration program uses the ChangeServiceConfig and ChangeServiceConfig2 functions to change the configuration parameters of an i

小发猫 1163

修改Win32 Service配置信息(包括SCM描述信息)

修改Win32 Service配置信息(包括SCM描述信息)

生命因你而精彩!明天更美好! 1009

Changing a Service's Configuration

Changing a Service's Configuration   A service configuration program uses the ChangeServiceConfig and ChangeServiceConfig2 functions to change the configuration parameters of an installed service....

weixin_33724570的博客 121
上一篇: Modifying the DACL for a Service
下一篇: ControlService
普通网友
博客等级 码龄22年 1万+粉丝 3156原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值