mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 19:56:51 +08:00
[test] embed_windows
This commit is contained in:
parent
35cf39e415
commit
828ff82ff2
|
@ -10,6 +10,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"sync/atomic"
|
||||
"time"
|
||||
_ "unsafe"
|
||||
|
@ -31,7 +32,7 @@ type rateJuggler struct {
|
|||
changing int32
|
||||
}
|
||||
|
||||
var WintunTunnelType = "Clash"
|
||||
var WintunTunnelType = "Clash.Meta"
|
||||
var WintunStaticRequestedGUID *windows.GUID
|
||||
|
||||
//go:linkname procyield runtime.procyield
|
||||
|
@ -67,6 +68,7 @@ func (tun *tunWindows) ForceMTU(mtu int) {
|
|||
|
||||
func (tun *tunWindows) Read0(buff []byte, offset int) (int, error) {
|
||||
tun.running.Add(1)
|
||||
|
||||
defer tun.running.Done()
|
||||
retry:
|
||||
if atomic.LoadInt32(&tun.close) == 1 {
|
||||
|
|
21
listener/tun/dev/wintun/dll_embed_windows_386.go
Normal file
21
listener/tun/dev/wintun/dll_embed_windows_386.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package wintun
|
||||
|
||||
// Copyright 2020 MeshStep Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed static/386/wintun.dll
|
||||
var ddlContent []byte
|
21
listener/tun/dev/wintun/dll_embed_windows_amd64.go
Normal file
21
listener/tun/dev/wintun/dll_embed_windows_amd64.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package wintun
|
||||
|
||||
// Copyright 2020 MeshStep Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed static/amd64/wintun.dll
|
||||
var ddlContent []byte
|
21
listener/tun/dev/wintun/dll_embed_windows_arm.go
Normal file
21
listener/tun/dev/wintun/dll_embed_windows_arm.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package wintun
|
||||
|
||||
// Copyright 2020 MeshStep Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed static/arm/wintun.dll
|
||||
var ddlContent []byte
|
21
listener/tun/dev/wintun/dll_embed_windows_arm64.go
Normal file
21
listener/tun/dev/wintun/dll_embed_windows_arm64.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package wintun
|
||||
|
||||
// Copyright 2020 MeshStep Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed static/arm64/wintun.dll
|
||||
var ddlContent []byte
|
|
@ -7,6 +7,7 @@ package wintun
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"golang.zx2c4.com/wireguard/windows/driver/memmod"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
|
@ -78,12 +79,7 @@ func (d *lazyDLL) Load() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
//const (
|
||||
// LOAD_LIBRARY_SEARCH_APPLICATION_DIR = 0x00000200
|
||||
// LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800
|
||||
//)
|
||||
//module, err := windows.LoadLibraryEx(d.Name, 0, LOAD_LIBRARY_SEARCH_APPLICATION_DIR|LOAD_LIBRARY_SEARCH_SYSTEM32)
|
||||
module, err := windows.LoadLibraryEx(C.Path.GetAssetLocation(d.Name), 0, windows.LOAD_WITH_ALTERED_SEARCH_PATH)
|
||||
module, err := memmod.LoadLibrary(ddlContent)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to load library: %w", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user