I written a NT Service according a MSDN sample, and installed it with instsrv.exe in win2000 resource development kit.(instsrv.exe "Test Service" C:\srv.exe)
When I start it in Service Control Manager(SCM), a alert shows:
Could not start the Test Service service on local Computer.
Error 1053: The service did not respond the start or control request in a timely fashion.

Please help me to resolve the question!
thank you a million!

;*************************Source Code********************************************************
.586
.model flat , stdcall
option casemap : none

include WinService.inc

.data
serviceStatus SERVICE_STATUS<>
hServiceStatus dd ?
szServiceName db "Test Service",0

;SERVICE_CONTROL_CONTINUE equ 00000003h
.code
;**********************************************************
; Initialize Service
;**********************************************************
InitializeService proc argc , argv , specificError


ret

InitializeService endp

;**********************************************************
; Control Service Status
;**********************************************************
ServiceCtrlHandler proc opCode
LOCAL @stStatus : DWORD

pushad
.if (opCode == SERVICE_CONTROL_STOP)
mov serviceStatus.dwCurrentState,SERVICE_STOPPED
mov serviceStatus.dwWin32ExitCode,0
mov serviceStatus.dwServiceSpecificExitCode,0
mov serviceStatus.dwCheckPoint,0
mov serviceStatus.dwWaitHint,0

.elseif (opCode == SERVICE_CONTROL_PAUSE)
mov serviceStatus.dwCurrentState,SERVICE_PAUSED
.elseif (opCode == SERVICE_CONTROL_CONTINUE)
mov serviceStatus.dwCurrentState,SERVICE_RUNNING
.endif

invoke SetServiceStatus,hServiceStatus,addr serviceStatus

popad

ret
ServiceCtrlHandler endp

ServiceStart proc argc,argv
LOCAL @stStatus : DWORD
LOCAL @stSpecificError : DWORD

pushad

mov serviceStatus.dwServiceType,SERVICE_WIN32
mov serviceStatus.dwCurrentState,SERVICE_START_PENDING
mov serviceStatus.dwControlsAccepted,SERVICE_ACCEPT_STOP or SERVICE_ACCEPT_PAUSE_CONTINUE
mov serviceStatus.dwWin32ExitCode,NULL
mov serviceStatus.dwServiceSpecificExitCode,NULL
mov serviceStatus.dwCheckPoint,NULL
mov serviceStatus.dwWaitHint,NULL

invoke RegisterServiceCtrlHandler,offset szServiceName,offset ServiceCtrlHandler
invoke InitializeService,argc,argv,addr @stSpecificError
mov @stStatus , eax

.if (@stStatus != NO_ERROR)
mov serviceStatus.dwCurrentState,SERVICE_STOPPED
mov serviceStatus.dwCheckPoint,0
mov serviceStatus.dwWaitHint,0
push @stStatus
pop serviceStatus.dwWin32ExitCode
push @stSpecificError
pop serviceStatus.dwServiceSpecificExitCode
; Set current service to stop
invoke SetServiceStatus,hServiceStatus,addr serviceStatus
ret
.endif

mov serviceStatus.dwCurrentState,SERVICE_RUNNING
mov serviceStatus.dwCheckPoint,0
mov serviceStatus.dwWaitHint,0

invoke SetServiceStatus,hServiceStatus,addr serviceStatus

popad
ret

ServiceStart endp

WinMain proc
LOCAL @stDispatchTable[2] :SERVICE_TABLE_ENTRY

invoke RtlZeroMemory,addr @stDispatchTable,sizeof @stDispatchTable

mov @stDispatchTable[0].lpServiceName,offset szServiceName
mov @stDispatchTable[0].lpServiceProc,offset ServiceStart
mov @stDispatchTable[1].lpServiceName,offset szServiceName
mov @stDispatchTable[1].lpServiceProc,offset ServiceStart

invoke StartServiceCtrlDispatcher,addr @stDispatchTable
ret

WinMain endp
Start:
call WinMain
invoke ExitProcess,NULL
end Start
Posted on 2005-11-05 23:56:33 by czg1997
I've read your message...

Me too I am writing a little tutorial  (as simple as I could write) about DRIVERS...
because I have the intention to buid some in 64 bits...

All I can tell you is API (in adavapi.dll) is same than in the following tutorial...in almost all Windows platform...
http://www.freewebs.com/four-f/KmdTut/kmd02.html

Here is the generic source....http://www.freewebs.com/four-f/....

Then try to have a look to this good tutorial...It seems to me better than this of Iczelion...

The link about freewebs was already been given in this Forum...(it is here I found the link)...

Good Enjoy...
---
Gerard





Posted on 2005-11-06 01:17:53 by gerard
Thanks?but i want to find out the reasons.
thanks for you answer! : )
Posted on 2005-11-06 03:23:39 by czg1997
Start Here with a working example from hitchhikr:
http://perso.wanadoo.fr/franck.charlet/

From what I can tell, you do not have enough of it written yet.

I'm personally involved in writing one as well.

Regards,  P1  8)
Posted on 2005-11-21 12:44:09 by P1