Skip to content

Commit

Permalink
embed bin files
Browse files Browse the repository at this point in the history
  • Loading branch information
ddkwork committed Jul 3, 2024
1 parent 8f2e26b commit 6bf4fa9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 6 additions & 5 deletions sdk/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand All @@ -20,23 +21,23 @@ 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")
mylog.Check2(GengoLibrary.LoadEmbed(dllData))

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)
}
stream.WriteTruncate(filepath.Join(dir, k), v)
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[:]))
Expand Down
3 changes: 2 additions & 1 deletion sdk/sdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion sdk/util.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 6bf4fa9

Please sign in to comment.