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 立即下载

相关推荐

GD32F103VBT6串口OTA升级保姆级教程:当硬件没留Boot0引脚时,我是如何用Keil和Ymodem搞定的

本文详细介绍了GD32F103VBT6在无Boot0引脚情况下的串口OTA升级方案,通过Keil工程改造和Ymodem协议实现可靠固件更新。文章涵盖Bootloader配置、APP工程调整、Ymodem传输优化等关键步骤,为嵌入式开发者提供了一套完整的解决方案,特别适用于封闭式设备的远程更新需求。

weixin_28744613的博客 187

ChangeServiceConfig函数

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

gaobc的专栏 2170

微生物测序分析LEfSe

LEfse分析定义 LEfse分析即LDA Effect Size分析,可以实现多个分组之间的比较,还进行分组比较的内部进行亚组比较分析,从而找到组间在丰度上有显著差异的物种(即biomaker);

宁生信 5万+

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

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

开软古剑楠 821

Haystack框架实战:从零构建企业级智能问答系统

自然语言处理(NLP)技术通过让计算机理解和生成人类语言,正在深刻改变信息检索与交互方式。其核心原理在于将文本转化为机器可处理的向量表示,并通过语义相似度计算实现精准匹配。这一技术价值在于能够从海量非结构化数据中快速提取精准信息,大幅提升知识获取效率。在工程实践中,检索增强生成(RAG)架构结合了密集向量检索与大语言模型生成能力,成为构建智能问答、知识库助手等应用的主流方案。该架构通过将用户查询与文档库进行语义匹配,并为大语言模型提供精准上下文,有效提升了回答的准确性与可追溯性。本文以Haystack这一生

weixin_42521032的博客 580

Qt5.15.2安卓开发环境配置保姆级教程(含JDK8、SDK33、NDK21.4及Gradle国内镜像避坑指南)

本文提供Qt5.15.2安卓开发环境配置的完整教程,涵盖JDK8、SDK33、NDK21.4及Gradle国内镜像设置,帮助开发者快速搭建开发环境并避免常见问题。通过详细步骤和实战技巧,解决依赖冲突、网络超时等难题,提升开发效率。

weixin_28730353的博客 208

ChangeServiceConfig2

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

小发猫 2865

【数字IC设计】芯片设计中的RDC

在芯片设计中,RDC是的缩写,类似于CDC(clock domain crossing),由于现在SOC芯片是有很多ECUs组成,为了使整个系统能够快速从复位中恢复, 用户希望SOC里面每个ECU模块都可以有自己独立的异步复位信号,这样可以在出问题的时候只复位有错误逻辑的模块,而使其它模块保持正常工作。

qq_40268672的博客 2203

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

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

星月情缘的博客 1805

3步!Spring Boot+OCR引擎秒提身份证/营业执照?手把手教你从零实现!

OCR技术革新文档识别效率 本文演示了如何利用Spring Boot+Tesseract OCR+OpenCV构建自动化文档识别系统。相比传统人工录入,OCR技术可实现: 5秒极速提取身份证/营业执照关键信息 精准识别中文文本(准确率90%+) 正则过滤自动匹配结构化数据 技术要点: OpenCV图像预处理(灰度化+二值化) Tesseract多语言OCR识别 正则表达式精准提取证件号码 效率提升达100倍,错误率降低90%,适用于金融、政务等需要批量处理证件的场景。

java专栏 907

卫星轨道坐标转换:轨道六根数到经纬高(经STK验证)

a:半长轴(km)e:偏心率i:轨道倾角(度)Ω:升交点赤经(度)ω:近地点幅角(度)ν:真近点角(度)

weixin_52370774的博客 175

Windows服务编写

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

lziog的专栏 1807

【JTAG】1500协议详解

随着集成电路的规模不断扩大,1149.1的板级测试无法满足要求越来越高的芯片测试需求。芯片规模变大后,测试需求不在是一次测试整片芯片,而是芯片分为好几个区域去测试,而1500协议正是对1149.1在该方面的一个补充即1149.1主要测试板级间的互连,而1500用来测试芯片内不同core之间的互连。IEEEStd1500已经为包含不同模块的集成电路(ICs)开发了一种可测试性设计标准方法。............

xuhe0206的博客 7056

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.csdn.net/wishfly 4554

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

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

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

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

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

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的专栏 638

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

小发猫 1166

修改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的博客 122
上一篇: 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、付费专栏及课程。

余额充值
⌂ 换网址