Skip to content

Commit

Permalink
Merge pull request #97 from ddkwork/main
Browse files Browse the repository at this point in the history
generated function
  • Loading branch information
ddkwork authored Jun 18, 2024
2 parents 597d8ba + 92d80fc commit de3b16d
Show file tree
Hide file tree
Showing 126 changed files with 59 additions and 94 deletions.
81 changes: 0 additions & 81 deletions control/control.go

This file was deleted.

24 changes: 12 additions & 12 deletions control/control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func TestRemoveComment(t *testing.T) {
// t.Skip("do not run this test")
t.Skip("do not run this test")
filepath.Walk("hprdbgctrl", func(path string, info fs.FileInfo, err error) error {
ext := filepath.Ext(path)
switch ext {
Expand All @@ -27,12 +27,12 @@ func TestRemoveComment(t *testing.T) {

func removeCommentsFromFile(filename string) {
b := stream.NewBuffer(filename)
re := regexp.MustCompile(`/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/|//.*`)
re := regexp.MustCompile(`/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/|//.*`) //seems has a little bug
processedContent := re.ReplaceAllString(b.String(), "")
lines := stream.NewBuffer(processedContent).ToLines()
f := stream.NewBuffer("")
src := stream.NewBuffer("")
src.WriteStringLn("package control")
cppBody := stream.NewBuffer("")
goBody := stream.NewBuffer("")
goBody.WriteStringLn("package control")
for i, line := range lines {
switch strings.TrimSpace(line) {
case "":
Expand All @@ -47,7 +47,7 @@ func removeCommentsFromFile(filename string) {
// VOID PrintBits(const UINT32 Size, const void * Ptr){
before, _, found := strings.Cut(line, "(")
if found {
index := strings.LastIndex(before, " ") // todo get return type
index := strings.LastIndex(before, " ")
if index != -1 {

returnType := getReturnType(before[:index])
Expand All @@ -60,23 +60,23 @@ func removeCommentsFromFile(filename string) {
signature += "\n"
signature += "}"
mylog.Success("", signature)
src.WriteStringLn(signature)
goBody.WriteStringLn(signature)
}
}
}
f.WriteStringLn(line)
cppBody.WriteStringLn(line)
}
for _, returnType := range returnTypes {
f.ReplaceAll(returnType+"\n", returnType+" ")
cppBody.ReplaceAll(returnType+"\n", returnType+" ")
}
f.ReplaceAll("\n{", "{")
stream.WriteTruncate(filename, f.String())
cppBody.ReplaceAll("\n{", "{")
stream.WriteTruncate(filename, cppBody.String())

if filepath.Ext(filename) == ".cpp" {
all := strings.ReplaceAll(filename, ".cpp", ".go")
join := filepath.Join("tmp", all)
// mylog.Warning(all)
stream.WriteGoFile(join, src)
stream.WriteGoFile(join, goBody)
}
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion control/hprdbgctrl/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ typedef RFLAGS * PRFLAGS;
#endif
#define USE__NATIVE_PHNT_HEADERS
#if defined(USE__NATIVE_PHNT_HEADERS)
typedef con*LPCWCHAR, *PCWCHAR;
typedef const wchar_t *LPCWCHAR, *PCWCHAR;

# define PHNT_MODE PHNT_MODE_USER
# define PHNT_VERSION PHNT_WIN11
# define PHNT_PATCH_FOR_HYPERDBG TRUE
Expand Down
7 changes: 7 additions & 0 deletions demo/cpp/library.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "library.hpp"

#include <iostream>

void hello() {
std::cout << "Hello, World!" << std::endl;
}
6 changes: 6 additions & 0 deletions demo/cpp/library.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef UNTITLED_LIBRARY_H
#define UNTITLED_LIBRARY_H

__declspec(dllexport) void hello();

#endif //UNTITLED_LIBRARY_H
Binary file added demo/demo.dll
Binary file not shown.
25 changes: 25 additions & 0 deletions demo/demo.go

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

7 changes: 7 additions & 0 deletions demo/demo_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package demo

import "testing"

func TestHello(t *testing.T) {
Hello()
}

0 comments on commit de3b16d

Please sign in to comment.