Fix windows route
This commit is contained in:
parent
6bad0c2380
commit
a93592a9b5
9 changed files with 662 additions and 26 deletions
46
internal/winsys/helper.go
Normal file
46
internal/winsys/helper.go
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
//go:build windows
|
||||
|
||||
package winsys
|
||||
|
||||
import (
|
||||
"os"
|
||||
"unsafe"
|
||||
|
||||
"github.com/sagernet/sing/common"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
func CreateDisplayData(name, description string) FWPM_DISPLAY_DATA0 {
|
||||
namePtr, err := windows.UTF16PtrFromString(name)
|
||||
common.Must(err)
|
||||
|
||||
descriptionPtr, err := windows.UTF16PtrFromString(description)
|
||||
common.Must(err)
|
||||
|
||||
return FWPM_DISPLAY_DATA0{
|
||||
Name: namePtr,
|
||||
Description: descriptionPtr,
|
||||
}
|
||||
}
|
||||
|
||||
func GetCurrentProcessAppID() (*FWP_BYTE_BLOB, error) {
|
||||
currentFile, err := os.Executable()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
curFilePtr, err := windows.UTF16PtrFromString(currentFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
windows.GetCurrentProcessId()
|
||||
|
||||
var appID *FWP_BYTE_BLOB
|
||||
err = FwpmGetAppIdFromFileName0(curFilePtr, unsafe.Pointer(&appID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return appID, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue