From b6889370fb1098ed892bd3400d189bb6a3355813 Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Sun, 20 Jan 2019 16:37:32 +1100 Subject: [PATCH] windows/svc: align ctlHandler parameters ctlHandler is passed to RegisterServiceCtrlHandlerEx as a callback function. But all ctlHandler parameters have to be uintptr aligned regardless of their type. Adjust ctlHandler parameters, so they are aligned accordingly. Also uncomment part of TestExample that verifies passing of ChangeRequest.Context. Fixes golang/go#25660 Change-Id: Ie96fa5c78b911ad9df6775f5c49e7f6d56464f6b Reviewed-on: https://go-review.googlesource.com/c/158698 Reviewed-by: Brad Fitzpatrick --- windows/svc/service.go | 4 ++-- windows/svc/svc_test.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/windows/svc/service.go b/windows/svc/service.go index d6ec7e78..58ad4efd 100644 --- a/windows/svc/service.go +++ b/windows/svc/service.go @@ -315,8 +315,8 @@ func Run(name string, handler Handler) error { return err } - ctlHandler := func(ctl uint32, evtype uint32, evdata uintptr, context uintptr) uintptr { - e := ctlEvent{cmd: Cmd(ctl), eventType: evtype, eventData: evdata, context: context} + ctlHandler := func(ctl, evtype, evdata, context uintptr) uintptr { + e := ctlEvent{cmd: Cmd(ctl), eventType: uint32(evtype), eventData: evdata, context: context} // We assume that this callback function is running on // the same thread as Run. Nowhere in MS documentation // I could find statement to guarantee that. So putting diff --git a/windows/svc/svc_test.go b/windows/svc/svc_test.go index 8e59c0de..3a80e480 100644 --- a/windows/svc/svc_test.go +++ b/windows/svc/svc_test.go @@ -127,8 +127,7 @@ func TestExample(t *testing.T) { } want := strings.Join(append([]string{name}, args...), "-") // Test context passing (see servicemain in sys_386.s and sys_amd64.s). - // TODO(brainman): Uncomment next line once issue #25660 is fixed. - //want += "-123456" + want += "-123456" if !strings.Contains(string(out), want) { t.Errorf("%q string does not contain %q", string(out), want) }