Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ddkwork committed Feb 21, 2025
1 parent 8df7cef commit 054674e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 25 deletions.
5 changes: 1 addition & 4 deletions plugin/hookApiMgr/hookApiMgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ type (
func New() *object { return &object{} }

func (o *object) DecodeStack(api, stack string, argsInput ...string) (argList []ArgList, ok bool) {
lines := stream.NewBuffer(stack).ToLines()

argList = make([]ArgList, 0)

fnCut := func(orig string) (list []string) {
list = make([]string, 0)
orig = strings.TrimSpace(orig)
Expand All @@ -85,7 +82,7 @@ func (o *object) DecodeStack(api, stack string, argsInput ...string) (argList []
return
}

for _, line := range lines {
for line := range strings.Lines(stack) {
if line == "" {
continue
}
Expand Down
10 changes: 0 additions & 10 deletions plugin/symbol/symbol.go
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
package symbol

type (
Interface interface {
// Fn() (ok bool)
}
object struct{}
Ntoskrnl interface{}
)

func New() Interface { return &object{} }
5 changes: 2 additions & 3 deletions plugin/symbol/symbol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import (
)

func TestName(t *testing.T) {
lines := stream.ReadFileToLines(`ssdtTable.txt`)
ntdll := make([]string, 0)
win32u := make([]string, 0)
for i, line := range lines {
for line := range stream.ReadFileToLines(`ssdtTable.txt`) {
if strings.Contains(line, "win32u") {
win32u = append(win32u, lines[i:]...)
win32u = append(win32u, line) //todo test
break
}
ntdll = append(ntdll, line)
Expand Down
2 changes: 1 addition & 1 deletion sdk/bindgen/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestName(t *testing.T) {

func TestBindMacros(t *testing.T) {
headerFile := "merged_headers.h"
macros := extractMacros(stream.NewBuffer(headerFile).ToLines())
macros := extractMacros(stream.ReadFileToLines(headerFile))
// println(macros.GoString())
// return
mylog.Trace("number of macros", macros.Len())
Expand Down
11 changes: 6 additions & 5 deletions sdk/bindgen/constants/constants_gen_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package constants

import (
"github.com/ddkwork/golibrary/safemap"
"path/filepath"
"strconv"
"strings"
Expand All @@ -20,11 +21,11 @@ func TestGenConstants(t *testing.T) {
}

func genConstants(fileName string) {
m := safemap.NewOrdered[string, string]()
for i, s := range stream.NewBuffer(fileName).ToLines() {
if i == 4 {
// break // test
}
m := new(safemap.M[string, string])
for s := range stream.ReadFileToLines(fileName) {
//if i == 4 {
// // break // test
//}
split := strings.Split(s, " ")
v := split[1]
if fileName == "ioctl.txt" {
Expand Down
5 changes: 3 additions & 2 deletions sdk/bindgen/macros_decode.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package bindgen

import (
"iter"
"strings"

"github.com/ddkwork/golibrary/safemap"
)

func extractMacros(lines []string) *safemap.M[string, string] {
func extractMacros(lines iter.Seq[string]) *safemap.M[string, string] {
macros := new(safemap.M[string, string])
macros.Set("PAGE_SIZE", "4096")
var macroName string
var macroValue strings.Builder
inMacro := false

for _, line := range lines {
for line := range lines {
if strings.HasPrefix(line, "#define") {
if inMacro {
// Finish the previous macro
Expand Down

0 comments on commit 054674e

Please sign in to comment.