Skip to content

Commit 6c24dfa

Browse files
authored
Merge pull request #217 from kylewo/master
Fixing corruption in callbacks introduced by x86 changes
2 parents 7ec9238 + 4c72048 commit 6c24dfa

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

pkg/etw/sample/sample.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"bufio"
88
"fmt"
99
"os"
10+
"runtime"
1011

1112
"github.com/Microsoft/go-winio/pkg/etw"
1213
"github.com/Microsoft/go-winio/pkg/guid"
@@ -18,6 +19,8 @@ func callback(sourceID guid.GUID, state etw.ProviderState, level etw.Level, matc
1819
}
1920

2021
func main() {
22+
fmt.Printf("Running on %s/%s\n", runtime.GOOS, runtime.GOARCH)
23+
2124
group, err := guid.FromString("12341234-abcd-abcd-abcd-123412341234")
2225
if err != nil {
2326
logrus.Error(err)

pkg/etw/wrapper_32.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ func eventSetInformation(
5959
// For x86, the matchAny and matchAll keywords need to be assembled from two
6060
// 32-bit integers, because the max size of an argument is uintptr, but those
6161
// two arguments are actually 64-bit integers.
62-
func providerCallbackAdapter(sourceID *guid.GUID, state uint32, level uint8, matchAnyKeyword_low uint32, matchAnyKeyword_high uint32, matchAllKeyword_low uint32, matchAllKeyword_high uint32, filterData uintptr, i uintptr) uintptr {
63-
matchAnyKeyword := uint64(matchAnyKeyword_high) << 32 | uint64(matchAnyKeyword_low)
64-
matchAllKeyword := uint64(matchAllKeyword_high) << 32 | uint64(matchAllKeyword_low)
62+
func providerCallbackAdapter(sourceID *guid.GUID, state uint32, level uint32, matchAnyKeyword_low uint32, matchAnyKeyword_high uint32, matchAllKeyword_low uint32, matchAllKeyword_high uint32, filterData uintptr, i uintptr) uintptr {
63+
matchAnyKeyword := uint64(matchAnyKeyword_high)<<32 | uint64(matchAnyKeyword_low)
64+
matchAllKeyword := uint64(matchAllKeyword_high)<<32 | uint64(matchAllKeyword_low)
6565
providerCallback(*sourceID, ProviderState(state), Level(level), uint64(matchAnyKeyword), uint64(matchAllKeyword), filterData, i)
6666
return 0
67-
}
67+
}

pkg/etw/wrapper_64.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func eventSetInformation(
4646
// for provider notifications. Because Go has trouble with callback arguments of
4747
// different size, it has only pointer-sized arguments, which are then cast to
4848
// the appropriate types when calling providerCallback.
49-
func providerCallbackAdapter(sourceID *guid.GUID, state uint32, level uint8, matchAnyKeyword uintptr, matchAllKeyword uintptr, filterData uintptr, i uintptr) uintptr {
49+
func providerCallbackAdapter(sourceID *guid.GUID, state uintptr, level uintptr, matchAnyKeyword uintptr, matchAllKeyword uintptr, filterData uintptr, i uintptr) uintptr {
5050
providerCallback(*sourceID, ProviderState(state), Level(level), uint64(matchAnyKeyword), uint64(matchAllKeyword), filterData, i)
5151
return 0
52-
}
52+
}

0 commit comments

Comments
 (0)