Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张紫娃
miscellaneous
提交
8e128ce6
M
miscellaneous
项目概览
张紫娃
/
miscellaneous
与 Fork 源项目一致
Fork自
Peacoor Zomboss / miscellaneous
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
miscellaneous
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
8e128ce6
编写于
2月 22, 2023
作者:
Peacoor Zomboss
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add injector for civ6
上级
12453f06
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
105 addition
and
1 deletion
+105
-1
230130-hookgamesendto/Makefile
230130-hookgamesendto/Makefile
+1
-1
230130-hookgamesendto/injciv6/Makefile
230130-hookgamesendto/injciv6/Makefile
+25
-0
230130-hookgamesendto/injciv6/injciv6.cpp
230130-hookgamesendto/injciv6/injciv6.cpp
+79
-0
未找到文件。
230130-hookgamesendto/Makefile
浏览文件 @
8e128ce6
subdir
=
hookdll injector
subdir
=
hookdll injector
injciv6
cleandir
=
$(
addprefix
_clean_,
$(subdir)
)
all
:
$(subdir)
...
...
230130-hookgamesendto/injciv6/Makefile
0 → 100644
浏览文件 @
8e128ce6
vpath
%.cpp
../src
cxx
=
g++
cxxflags
=
-c
-O1
-I
../inc
cxx64prefix
=
x86_64-w64-mingw32-
objdir
=
./obj/
bindir
=
../bin/
src
=
injciv6.cpp inject.cpp
obj
=
$(
patsubst
%.cpp,
$(objdir)
%.o,
$(src)
)
target
=
$(bindir)
injciv6.exe
all
:
check $(target)
$(target)
:
$(obj)
$(cxx64prefix)$(cxx)
-o
$@
$^
-static
-mwindows
$(objdir)%.o
:
%.cpp
$(cxx64prefix)$(cxx)
$(cxxflags)
-o
$@
$<
.PHONY
:
check clean
check
:
@
if
not exist obj md obj
clean
:
@
if
exist obj del obj
\*
.o
230130-hookgamesendto/injciv6/injciv6.cpp
0 → 100644
浏览文件 @
8e128ce6
#include <stdio.h>
#include <shlobj.h>
#include <shellapi.h>
#include "inject.h"
bool
runas_admin
(
const
char
*
exename
)
{
SHELLEXECUTEINFOA
sei
;
memset
(
&
sei
,
0
,
sizeof
(
sei
));
sei
.
cbSize
=
sizeof
(
sei
);
sei
.
fMask
=
SEE_MASK_FLAG_DDEWAIT
|
SEE_MASK_FLAG_NO_UI
;
// 设置等待+不显示错误框
sei
.
lpVerb
=
"runas"
;
sei
.
lpFile
=
exename
;
sei
.
nShow
=
SW_SHOWNORMAL
;
return
ShellExecuteExA
(
&
sei
);
}
static
DWORD
get_civ6_proc
()
{
DWORD
pid
=
find_pid_by_name
(
"CivilizationVI.exe"
);
if
(
pid
==
0
)
pid
=
find_pid_by_name
(
"CivilizationVI_DX12.exe"
);
return
pid
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
char
dll_path
[
MAX_PATH
];
strcpy
(
dll_path
,
argv
[
0
]);
int
pos
=
strlen
(
dll_path
)
-
1
;
while
(
pos
>
0
)
{
if
(
dll_path
[
pos
]
==
'\\'
)
break
;
pos
--
;
}
dll_path
[
pos
+
1
]
=
'\0'
;
strcat
(
dll_path
,
"hookdll64.dll"
);
FILE
*
fp
=
fopen
(
dll_path
,
"rb"
);
if
(
fp
==
NULL
)
{
MessageBoxW
(
0
,
L"找不到hookdll64.dll"
,
L"错误"
,
MB_ICONERROR
);
return
0
;
}
fclose
(
fp
);
int
msgres
=
0
;
bool
isadmin
=
IsUserAnAdmin
();
// 检测当前是否有管理员权限,需要shlobj.h
DWORD
civ6pid
=
0
;
while
(
1
)
{
civ6pid
=
get_civ6_proc
();
if
(
civ6pid
!=
0
)
break
;
msgres
=
MessageBoxW
(
0
,
L"请先运行游戏,然后点击重试"
,
L"错误"
,
MB_RETRYCANCEL
|
MB_ICONERROR
);
if
(
msgres
!=
IDRETRY
)
return
0
;
}
retry_inject:
// 尝试注入
if
(
inject_dll
(
civ6pid
,
""
))
{
MessageBoxW
(
0
,
L"注入成功!"
,
L"成功"
,
MB_OK
);
return
0
;
}
// 如果管理员权限也失败了,那就不知道什么情况了
if
(
isadmin
)
{
// 一般情况下是走不到这里来的
msgres
=
MessageBoxW
(
0
,
L"注入失败"
,
L"错误"
,
MB_RETRYCANCEL
|
MB_ICONERROR
);
if
(
msgres
==
IDRETRY
)
goto
retry_inject
;
return
0
;
}
// 有的时候比如steam运行游戏可能是带管理员权限的,这个时候要注入程序也要有管理员权限
msgres
=
MessageBoxW
(
0
,
L"注入失败,是否以管理员权限重试?"
,
L"错误"
,
MB_ICONERROR
|
MB_RETRYCANCEL
);
if
(
msgres
==
IDRETRY
)
{
retry_runas:
if
(
runas_admin
(
argv
[
0
]))
// 成功运行就退出自己
return
0
;
msgres
=
MessageBoxW
(
0
,
L"请在弹出的窗口中点击“是”"
,
L"错误"
,
MB_ICONERROR
|
MB_RETRYCANCEL
);
if
(
msgres
==
IDRETRY
)
goto
retry_runas
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录