Skip to content

fix(windows): add missing service UUIDs in scan results#427

Open
acouvreur wants to merge 2 commits intotinygo-org:devfrom
acouvreur:add-windows-scan-result-advertisement-data
Open

fix(windows): add missing service UUIDs in scan results#427
acouvreur wants to merge 2 commits intotinygo-org:devfrom
acouvreur:add-windows-scan-result-advertisement-data

Conversation

@acouvreur
Copy link
Copy Markdown
Contributor

@acouvreur acouvreur commented Mar 20, 2026

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.

@deadprogram
Copy link
Copy Markdown
Member

Any update on this PR @acouvreur @jagobagascon 😸

@acouvreur
Copy link
Copy Markdown
Contributor Author

acouvreur commented Apr 10, 2026

Any update on this PR @acouvreur @jagobagascon 😸

In my opinion, this is mergeable. We can improve it on another PR

gap_windows.go Outdated
Comment on lines +256 to +266
// 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)),
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't use vector.GetAt(i) here? We are doing it above to extract the manufacturer data.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I was a bit confused, and didnt really get the difference. Hence my comment, I will update this with GetAt

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants