@@ -551,6 +551,7 @@ ScControlService(PACTIVE_SERVICE lpService,
551551 PSCM_CONTROL_PACKET ControlPacket )
552552{
553553 DWORD dwError = ERROR_SUCCESS ;
554+ DWORD dwControl ;
554555 DWORD dwEventType = 0 ;
555556 PVOID pEventData = NULL ;
556557
@@ -566,29 +567,39 @@ ScControlService(PACTIVE_SERVICE lpService,
566567 /* Set service tag */
567568 NtCurrentTeb ()-> SubProcessTag = UlongToPtr (lpService -> dwServiceTag );
568569
570+ dwControl = ControlPacket -> dwControl ;
571+
569572 if (lpService -> HandlerFunction )
570573 {
571- _SEH2_TRY
574+ if (((dwControl >= SERVICE_CONTROL_STOP ) && (dwControl <= SERVICE_CONTROL_NETBINDDISABLE )) ||
575+ ((dwControl >= 128 ) && (dwControl <= 255 )))
572576 {
573- (lpService -> HandlerFunction )(ControlPacket -> dwControl );
577+ _SEH2_TRY
578+ {
579+ (lpService -> HandlerFunction )(dwControl );
580+ }
581+ _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER )
582+ {
583+ dwError = ERROR_EXCEPTION_IN_SERVICE ;
584+ }
585+ _SEH2_END ;
574586 }
575- _SEH2_EXCEPT ( EXCEPTION_EXECUTE_HANDLER )
587+ else
576588 {
577- dwError = ERROR_EXCEPTION_IN_SERVICE ;
589+ dwError = ERROR_INVALID_SERVICE_CONTROL ;
578590 }
579- _SEH2_END ;
580591 }
581592 else if (lpService -> HandlerFunctionEx )
582593 {
583- if (ControlPacket -> dwControl == SERVICE_CONTROL_DEVICEEVENT )
594+ if (dwControl == SERVICE_CONTROL_DEVICEEVENT )
584595 {
585596 dwEventType = * (LPDWORD )((ULONG_PTR )ControlPacket + sizeof (SCM_CONTROL_PACKET ));
586597 pEventData = (PVOID )((ULONG_PTR )ControlPacket + sizeof (SCM_CONTROL_PACKET ) + sizeof (DWORD ));
587598 }
588599
589600 _SEH2_TRY
590601 {
591- (lpService -> HandlerFunctionEx )(ControlPacket -> dwControl ,
602+ (lpService -> HandlerFunctionEx )(dwControl ,
592603 dwEventType ,
593604 pEventData ,
594605 lpService -> HandlerContext );
0 commit comments