From 6bf4fa9eeedb8a6b8af3751e8312d14598d84d7c Mon Sep 17 00:00:00 2001 From: Admin <2762713521@qq.com> Date: Wed, 3 Jul 2024 23:21:05 +0800 Subject: [PATCH] embed bin files --- main_test.go | 2 +- sdk/init.go | 11 ++++++----- sdk/sdk.go | 3 ++- sdk/util.go | 3 ++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/main_test.go b/main_test.go index ac7e8558..16f14d80 100644 --- a/main_test.go +++ b/main_test.go @@ -27,7 +27,7 @@ func TestClear(t *testing.T) { mylog.Check(os.RemoveAll("sdk/Libraries")) stream.CopyDir("bin/debug/SDK/Libraries", "sdk/Libraries") stream.WriteTruncate("sdk/Libraries/hyperkd.sys", stream.NewBuffer("bin/debug/hyperkd.sys")) - mylog.Check(os.RemoveAll("bin")) + // mylog.Check(os.RemoveAll("bin")) } func TestClearTemp(t *testing.T) { diff --git a/sdk/init.go b/sdk/init.go index 26d99fd5..0ba5d38b 100644 --- a/sdk/init.go +++ b/sdk/init.go @@ -3,11 +3,12 @@ package sdk import ( "embed" _ "embed" + "os" + "path/filepath" + "github.com/ddkwork/golibrary/mylog" "github.com/ddkwork/golibrary/stream" "golang.org/x/sys/windows" - "os" - "path/filepath" ) //go:embed Libraries/* @@ -20,7 +21,7 @@ func init() { dir := mylog.Check2(os.UserCacheDir()) dir = filepath.Join(dir, "hyperdbg", "cache") - mylog.CheckIgnore(os.RemoveAll(dir)) //todo test + mylog.CheckIgnore(os.RemoveAll(dir)) // todo test mylog.Check(os.MkdirAll(dir, 0755)) dllData := m.Get("libhyperdbg.dll") @@ -28,7 +29,7 @@ func init() { SetCustomDriverPath(stringToBytePointer(dir), stringToBytePointer(stream.BaseName(dir))) - m.Range(func(k string, v []byte) bool { //copy sys files to cache dir + m.Range(func(k string, v []byte) bool { // copy sys files to cache dir if k == "hyperkd.sys" { sysPath = filepath.Join(dir, k) } @@ -36,7 +37,7 @@ func init() { return true }) - mylog.Check(windows.SetDllDirectory(dir)) //todo what another dep dll names ? + mylog.Check(windows.SetDllDirectory(dir)) // todo what another dep dll names ? //sha := sha256.Sum256(dllData) //dllName := fmt.Sprintf("libhyperdbg-%s.dll", base64.RawURLEncoding.EncodeToString(sha[:])) diff --git a/sdk/sdk.go b/sdk/sdk.go index bd5bee89..ec591130 100644 --- a/sdk/sdk.go +++ b/sdk/sdk.go @@ -2,8 +2,9 @@ package sdk import ( - "github.com/ddkwork/app/bindgen/bindlib" "unsafe" + + "github.com/ddkwork/app/bindgen/bindlib" ) const GengoLibraryName = "libhyperdbg" diff --git a/sdk/util.go b/sdk/util.go index fcf5559f..682fee61 100644 --- a/sdk/util.go +++ b/sdk/util.go @@ -1,13 +1,14 @@ package sdk import ( - "github.com/stretchr/testify/assert" "os" "path/filepath" "strings" "syscall" "testing" + "github.com/stretchr/testify/assert" + "github.com/ddkwork/app/ms/hardwareIndo" "github.com/ddkwork/golibrary/mylog" "github.com/ddkwork/golibrary/stream/bitfield"