fix(windows): add missing service UUIDs in scan results#427
fix(windows): add missing service UUIDs in scan results#427acouvreur wants to merge 2 commits intotinygo-org:devfrom
Conversation
|
Any update on this PR @acouvreur @jagobagascon 😸 |
In my opinion, this is mergeable. We can improve it on another PR |
gap_windows.go
Outdated
| // Maybe we can use | ||
| // element, _ := vector.GetAt(i) | ||
| // serviceGUID := (*syscall.GUID)(element) | ||
| // ? | ||
| var outGuid syscall.GUID | ||
| hr, _, _ := syscall.SyscallN( | ||
| vector.VTable().GetAt, | ||
| uintptr(unsafe.Pointer(vector)), | ||
| uintptr(i), | ||
| uintptr(unsafe.Pointer(&outGuid)), | ||
| ) |
There was a problem hiding this comment.
Why don't use vector.GetAt(i) here? We are doing it above to extract the manufacturer data.
There was a problem hiding this comment.
I think I was a bit confused, and didnt really get the difference. Hence my comment, I will update this with GetAt
There was a problem hiding this comment.
The problem here is that this is a vector of GUID structs (not pointers). So you will need to convert the unsafe.Pointer to syscall.GUID (without the asterisk).
I found that this works:
for i := uint32(0); i < size; i++ {
element, _ := vector.GetAt(i)
// element is not a pointer, but a GUID struct. But we cannot convert
// unsafe.Pointer to a non-pointer type, so instead we are doing this:
serviceGUID := (*syscall.GUID)(unsafe.Pointer(&element))
uuid := GUIDToUUID(*serviceGUID)
serviceUUIDs = append(serviceUUIDs, uuid)
}There was a problem hiding this comment.
I have just applied your changes @jagobagascon
However I am currently unable to test the Windows version, so I will have to trust your suggestion :D
Closes #362
Closes #390
@jagobagascon can you check my code comment ?
I know that the current version work, but I think I can directly cast the element to a GUID pointer ?
I don't have a windows machine with me to test it right now.