https://git.reactos.org/?p=reactos.git;a=commitdiff;h=db60cd219c6c6f4443d9f…
commit db60cd219c6c6f4443d9f7cb4c708f690662a2f0
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Wed May 2 23:24:26 2018 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Wed May 2 23:24:26 2018 +0200
[ADVAPI32] SEH-protext the calls to service control handlers
ScControlService:
- SEH-protext the calls to service control handlers.
- Return ERROR_EXCEPTION_IN_SERVICE if a service control handler throws an exception.
- Return ERROR_SERVICE_CANNOT_ACCEPT_CTRL if no service control handler has been
registered for the service.
---
dll/win32/advapi32/service/sctrl.c | 34 ++++++++++++++++++++++++++--------
1 file changed, 26 insertions(+), 8 deletions(-)
diff --git a/dll/win32/advapi32/service/sctrl.c b/dll/win32/advapi32/service/sctrl.c
index 4b53a74c0c..9b9c3487ff 100644
--- a/dll/win32/advapi32/service/sctrl.c
+++ b/dll/win32/advapi32/service/sctrl.c
@@ -517,7 +517,7 @@ static DWORD
ScControlService(PACTIVE_SERVICE lpService,
PSCM_CONTROL_PACKET ControlPacket)
{
- DWORD dwError;
+ DWORD dwError = ERROR_SUCCESS;
TRACE("ScControlService(%p %p)\n",
lpService, ControlPacket);
@@ -530,16 +530,34 @@ ScControlService(PACTIVE_SERVICE lpService,
if (lpService->HandlerFunction)
{
- (lpService->HandlerFunction)(ControlPacket->dwControl);
- dwError = ERROR_SUCCESS;
+ _SEH2_TRY
+ {
+ (lpService->HandlerFunction)(ControlPacket->dwControl);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ dwError = ERROR_EXCEPTION_IN_SERVICE;
+ }
+ _SEH2_END;
}
else if (lpService->HandlerFunctionEx)
{
- /* FIXME: Send correct 2nd and 3rd parameters */
- (lpService->HandlerFunctionEx)(ControlPacket->dwControl,
- 0, NULL,
- lpService->HandlerContext);
- dwError = ERROR_SUCCESS;
+ _SEH2_TRY
+ {
+ /* FIXME: Send correct 2nd and 3rd parameters */
+ (lpService->HandlerFunctionEx)(ControlPacket->dwControl,
+ 0, NULL,
+ lpService->HandlerContext);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ dwError = ERROR_EXCEPTION_IN_SERVICE;
+ }
+ _SEH2_END;
+ }
+ else
+ {
+ dwError = ERROR_SERVICE_CANNOT_ACCEPT_CTRL;
}
TRACE("ScControlService() done (Error %lu)\n", dwError);