首页
社区
课程
招聘
[求助]关于创建服务的疑惑
发表于: 2008-5-19 18:31 3724

[求助]关于创建服务的疑惑

2008-5-19 18:31
3724
我在实现  创建服务  这个功能的时候
写不进服务列表
希望大家帮看看,先谢谢了
以下是 代码(仅仅是写进列表,不要求运行或者别的)

  .386
  .model flat, stdcall
  option casemap :none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 文件定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include  windows.inc
include  user32.inc
includelib user32.lib
include  kernel32.inc
includelib kernel32.lib
include  AdvApi32.inc
includelib AdvApi32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  .data?
@dwReturn dd ?
@hService  dd ?
hSCM         dd        ?
  .const

szServiceName  db 'hihiihhihi',0
szDisplayName db  ' l1dsadfa',0
szServiceFile db  '"d:\\Shot00009.bmp',0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  .code
start:
;local @dwReturn
;local  @hService
invoke OpenSCManager,NULL,NULL,SERVICE_ALL_ACCESS
mov  hSCM,eax
; 创建服务
  
  invoke CreateService,hSCM,addr szServiceName,addr szDisplayName,\
   SERVICE_ALL_ACCESS,SERVICE_WIN32_OWN_PROCESS or SERVICE_INTERACTIVE_PROCESS,\
   SERVICE_AUTO_START,SERVICE_ERROR_NORMAL,addr szServiceFile,\
   NULL,NULL,NULL,NULL,NULL

  .if ! eax                                ;错误处理
   invoke GetLastError
   .if eax == ERROR_DUP_NAME || eax == ERROR_SERVICE_EXISTS
    mov @dwReturn,TRUE

   .else
    mov @dwReturn,FALSE
   .endif
   jmp @F
  .endif
  mov @hService,eax
  mov @dwReturn,TRUE
;****************************************************************
  invoke CloseServiceHandle,@hService
@@:
  mov eax,@dwReturn
  ret
;_InstallService endp
end        start

[课程]Android-CTF解题方法汇总!

收藏
免费 0
支持
分享
最新回复 (4)
雪    币: 209
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
szServiceFile db  '"d:\\Shot00009.bmp',0 --> szServiceFile db  'd:\\Shot00009.bmp',0
2008-5-19 21:22
0
雪    币: 140
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
谢谢楼上的
这个是笔误
改后仍然写不进服务管理器
~~~~~
2008-5-19 21:58
0
雪    币: 321
活跃值: (271)
能力值: ( LV13,RANK:1050 )
在线值:
发帖
回帖
粉丝
4
呵呵,这句错了。
invoke OpenSCManager,NULL,NULL,SERVICE_ALL_ACCESS

应该修改为:
invoke OpenSCManager,NULL,NULL,SC_MANAGER_ALL_ACCESS
2008-5-20 08:58
0
雪    币: 140
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
非常感谢!
问题解决了,原因应该是这个:
SERVICE_ALL_ACCESS (0xF01FF) 和SC_MANAGER_ALL_ACCESS (0xF003F)
的Access right虽然都是:
Includes STANDARD_RIGHTS_REQUIRED, in addition to all access rights in this table.
但是SC_MANAGER_ALL_ACCESS 是 Access Rights for the Service Control Manager
而SERVICE_ALL_ACCESS  是  Access Rights for a Service
却别在于Service Control Manager,因为OpenSCManager作用是Establishes a connection to the service control manager on the specified computer and opens the specified service control manager database.
^ ^
2008-5-20 09:20
0
游客
登录 | 注册 方可回帖
返回
//