Skip to content

Commit 8de4685

Browse files
committed
Add injciv6-gui
Signed-off-by: xaxys <[email protected]>
1 parent 49679a7 commit 8de4685

38 files changed

+2459
-12
lines changed

.gitignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
*.o
2+
*.syso
3+
*.dll
4+
*.exe
25
bin/*
36
!bin/Readme.txt
47
mingw32/*
58
mingw64/*
69
!mingw32/.keep
710
!mingw64/.keep
8-
.vscode
11+
temp/*
12+
.vscode/*
13+
**/.assets/*

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
subdir = hookdll injector injciv6
1+
subdir = hookdll injector injciv6 injciv6-gui
22
cleandir = $(addprefix _clean_, $(subdir))
33

44
all: $(subdir)

env.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
setlocal
33
set MINGW32=%~dp0mingw32
44
set MINGW64=%~dp0mingw64
5-
set PATH=%PATH%;%MINGW32%\bin;%MINGW64%\bin
5+
set PATH=%MINGW64%\bin;%MINGW32%\bin;%PATH%
66
echo Environment variables set. Entering bash...
77
cmd
88
endlocal

hookdll/hookdll.cpp

+23-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
#include <windows.h>
2+
#include <mutex>
23
#include "inlinehook.h"
34
#include "fkhook.h"
45

6+
HANDLE hMutex = NULL;
7+
58
BOOL APIENTRY DllMain(HINSTANCE hinstdll, DWORD reason, LPVOID reserved)
69
{
7-
if (reason == DLL_PROCESS_ATTACH) {
8-
hook();
9-
}
10-
else if (reason == DLL_PROCESS_DETACH) {
11-
unhook();
10+
switch (reason) {
11+
case DLL_PROCESS_ATTACH:
12+
{
13+
hMutex = CreateMutexA(NULL, FALSE, "fkhook");
14+
if (GetLastError() == ERROR_ALREADY_EXISTS) {
15+
CloseHandle(hMutex);
16+
return TRUE;
17+
}
18+
hook();
19+
break;
20+
}
21+
case DLL_PROCESS_DETACH:
22+
{
23+
if (hMutex != NULL) {
24+
CloseHandle(hMutex);
25+
hMutex = NULL;
26+
}
27+
unhook();
28+
break;
29+
}
1230
}
1331
return TRUE;
1432
}

inc/inject.h

+9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
#pragma once
2+
#include <stdbool.h>
23
#include <windows.h>
34

5+
#ifdef __cplusplus
6+
extern "C" {
7+
#endif
8+
49
bool inject_dll(DWORD pid, const char *dll_path);
510
DWORD find_pid_by_name(const char *name);
611
HMODULE find_module_handle_from_pid(DWORD pid, const char *module_name);
712
bool remove_module(DWORD pid, HMODULE module_handle);
13+
14+
#ifdef __cplusplus
15+
}
16+
#endif

inc/inlinehook.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
#define HOOK_JUMP_LEN 5
66

7-
class InlineHook
7+
// [[deprecated]] 自版本 v0.3.0 起,不再使用 InlineHook,改用 MinHook 库
8+
class [[deprecated]] InlineHook
89
{
910
private:
1011
void *old_entry; // 存放原来的代码和跳转回去的代码

injciv6-gui/Makefile

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright (C) 2023 xaxys. All rights reserved.
2+
PACKAGE_NAME := injciv6-gui
3+
4+
GO ?= go.exe
5+
PWD := ${CURDIR}
6+
TARGET := $(PACKAGE_NAME).exe
7+
BUILD_TAGS := $(shell git describe --tags --always --dirty="-dev")
8+
BUILD_TIME := $(shell echo %date% %time%)
9+
GIT_COMMIT := $(shell git rev-parse --short HEAD)
10+
GO_VERSION := $(subst go version ,,$(shell go version))
11+
BIN_DIR := $(PWD)/../bin
12+
13+
CXX64PREFIX := x86_64-w64-mingw32-
14+
CC := $(CXX64PREFIX)gcc
15+
CXX := $(CXX64PREFIX)g++
16+
17+
ICONS := $(PWD)/assets/inject.ico,$(PWD)/assets/host.ico,$(PWD)/assets/remote.ico,$(PWD)/assets/tool.ico,$(PWD)/assets/about.ico
18+
19+
all: gen build
20+
21+
setup:
22+
@$(GO) install github.com/tc-hib/go-winres@latest
23+
24+
gen: setup
25+
@echo Generating resources...
26+
@go-winres make
27+
28+
build:
29+
@echo Building $(PACKAGE_NAME) ...
30+
@$(GO) env -w CGO_ENABLED=1 CC="$(CC)" CXX="$(CXX)"
31+
@$(GO) build \
32+
-tags walk_use_cgo \
33+
-ldflags="-H windowsgui -X 'injciv6-gui/components.BuildTags=$(BUILD_TAGS)' -X 'injciv6-gui/components.BuildTime=$(BUILD_TIME)' -X 'injciv6-gui/components.GitCommit=$(GIT_COMMIT)' -X 'injciv6-gui/components.GoVersion=$(GO_VERSION)'" \
34+
-o $(BIN_DIR)/$(TARGET)
35+
36+
run: build
37+
@echo Running $(PACKAGE_NAME) ...
38+
@$(BIN_DIR)/$(TARGET)
39+
40+
clean:
41+
@$(GO) clean -cache
42+
@del *.syso
43+
44+
.PHONY: all gen setup build run cleans

injciv6-gui/components/about_page.go

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package components
2+
3+
import (
4+
"fmt"
5+
"os/exec"
6+
7+
"github.com/lxn/walk"
8+
. "github.com/lxn/walk/declarative"
9+
)
10+
11+
var (
12+
BuildTags = "unknown"
13+
BuildTime = "unknown"
14+
GitCommit = "unknown"
15+
GoVersion = "unknown"
16+
)
17+
18+
type AboutPage struct {
19+
*walk.Composite
20+
}
21+
22+
func NewAboutPage(parent walk.Container) (Page, error) {
23+
p := &AboutPage{}
24+
25+
if err := (Composite{
26+
AssignTo: &p.Composite,
27+
Name: "关于",
28+
Layout: VBox{},
29+
Children: []Widget{
30+
Composite{
31+
Layout: HBox{},
32+
Children: []Widget{
33+
Label{
34+
Font: Font{PointSize: 10},
35+
TextAlignment: AlignNear,
36+
Text: "injciv6-gui",
37+
},
38+
HSpacer{},
39+
Label{
40+
Font: Font{PointSize: 10},
41+
TextAlignment: AlignNear,
42+
Text: "作者: xaxys",
43+
},
44+
},
45+
Alignment: AlignHNearVCenter,
46+
},
47+
VSeparator{},
48+
Composite{
49+
Layout: VBox{MarginsZero: true},
50+
Children: []Widget{
51+
Label{
52+
Font: Font{PointSize: 10},
53+
TextAlignment: AlignNear,
54+
Text: "版本: " + BuildTags,
55+
},
56+
Label{
57+
Font: Font{PointSize: 10},
58+
TextAlignment: AlignNear,
59+
Text: "编译时间: " + BuildTime,
60+
},
61+
Label{
62+
Font: Font{PointSize: 10},
63+
TextAlignment: AlignNear,
64+
Text: "Commit: " + GitCommit,
65+
},
66+
Label{
67+
Font: Font{PointSize: 10},
68+
TextAlignment: AlignNear,
69+
Text: "Go 版本: " + GoVersion,
70+
},
71+
Label{
72+
Font: Font{PointSize: 10},
73+
TextAlignment: AlignNear,
74+
Text: "GitHub: github.com/xaxys/injciv6",
75+
},
76+
},
77+
Alignment: AlignHCenterVCenter,
78+
},
79+
VSpacer{},
80+
},
81+
}).Create(NewBuilder(parent)); err != nil {
82+
return nil, err
83+
}
84+
85+
if err := walk.InitWrapperWindow(p); err != nil {
86+
return nil, err
87+
}
88+
89+
return p, nil
90+
}
91+
92+
func (p *AboutPage) OpenRepo(link *walk.LinkLabelLink) {
93+
url := "https://github.com/xaxys/injciv6"
94+
err := exec.Command("cmd", "/c", "start", url).Start()
95+
if err != nil {
96+
fmt.Println(err)
97+
}
98+
}
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package components
2+
3+
import "injciv6-gui/service"
4+
5+
type AppMainWindow struct {
6+
AppName string
7+
*MultiPageMainWindow
8+
}
9+
10+
func NewAppMainWindow(appName string, cfg *MultiPageMainWindowConfig) (*AppMainWindow, error) {
11+
amw := &AppMainWindow{
12+
AppName: appName,
13+
}
14+
cfg.OnCurrentPageChanged = amw.OnCurrentPageChanged
15+
cfg.OnCurrentPageToChange = amw.OnCurrentPageToChange
16+
17+
mpmw, err := NewMultiPageMainWindow(cfg)
18+
if err != nil {
19+
return nil, err
20+
}
21+
22+
amw.MultiPageMainWindow = mpmw
23+
return amw, nil
24+
}
25+
26+
func (mw *AppMainWindow) OnCurrentPageToChange() {
27+
service.Game.Listener().UnregisterAll()
28+
service.Inject.Listener().UnregisterAll()
29+
service.IPv6.Listener().UnregisterAll()
30+
service.IPv6.ErrorListener().UnregisterAll()
31+
}
32+
33+
func (mw *AppMainWindow) OnCurrentPageChanged() {
34+
mw.RefreshTitle()
35+
}
36+
37+
func (mw *AppMainWindow) RefreshTitle() {
38+
mw.updateTitle(mw.CurrentPageTitle())
39+
}
40+
41+
func (mw *AppMainWindow) updateTitle(prefix string) {
42+
title := ""
43+
if prefix != "" {
44+
title = prefix + " - "
45+
}
46+
title += mw.AppName
47+
mw.SetTitle(title)
48+
}

0 commit comments

Comments
 (0)