Skip to content

Commit

Permalink
change the structure of whole project
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriSizuku committed Oct 29, 2023
1 parent 56b8dce commit 8c7d7ce
Show file tree
Hide file tree
Showing 95 changed files with 3,579 additions and 4,263 deletions.
55 changes: 11 additions & 44 deletions .github/workflows/build_wintools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ name: build_tools
on:
push: {tags: ['v*'] } # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
build_libwinhook:
build_winexe_libwinhook:
runs-on: windows-2019 # default batch, powershell
steps:
- name: pull and init
uses: actions/checkout@v3
with: {submodules: true}
- name: add msbuild to path
uses: microsoft/setup-msbuild@v1.1
- name: build dllloader
run: .\tool\libwinhook\build_libwinhook.bat
- name: build winloader
run: .\project\winexe_winloader\release_msvc.bat
- name: create a release
uses: ncipollo/release-action@v1
with:
artifacts: "./tool/libwinhook/release/dllloader32.exe,./tool/libwinhook/x64/release/dllloader64.exe"
artifacts: "./project/winexe_winloader/build/winloader32.exe,./project/winexe_winloader/build/winloader64.exe"
allowUpdates: "true"
token: ${{ secrets.GITHUB_TOKEN }}

build_pytool_nuitkasingle:
build_pyexes:
runs-on: windows-2019 # default batch, powershell
strategy:
matrix:
pytoolname: [bintext, ftextcvt]
pyexe_name: [bintext, ftext]
steps:
- name: pull and init
uses: actions/checkout@v3
Expand All @@ -37,46 +37,13 @@ jobs:
run: |
python -m pip install nuitka zstandard
python -m pip install python-docx
- name: build pytool single
- name: build single pyexe by nuitka
run: |
cmd.exe /c ".\tool\${{ matrix.pytoolname }}\build_${{ matrix.pytoolname }}_nuitkasingle.bat"
move ".\tool\${{ matrix.pytoolname }}\bin\c${{ matrix.pytoolname }}.exe" ".\tool\${{ matrix.pytoolname }}\bin\c${{ matrix.pytoolname }}32.exe"
cmd.exe /c ".\project\pyexe_${{ matrix.pyexe_name }}\build_nuitka.bat"
move ".\project\pyexe_${{ matrix.pyexe_name }}\build\c${{ matrix.pyexe_name }}.exe" ".\project\pyexe_${{ matrix.pyexe_name }}\build\c${{ matrix.pyexe_name }}32.exe"
- name: create a release
uses: ncipollo/release-action@v1
with:
artifacts: "./tool/${{ matrix.pytoolname }}/bin/*.exe"
artifacts: "./project/pyexe_${{ matrix.pyexe_name }}/build/*.exe"
allowUpdates: "true"
token: ${{ secrets.GITHUB_TOKEN }}

build_pytool_nuitkamulti:
runs-on: windows-2019 # default batch, powershell
strategy:
matrix:
pytoolname: [bintext, ftextcvt]
steps:
- name: pull and init
uses: actions/checkout@v3
with: {submodules: true}
- name: set python version
uses: actions/setup-python@v3
with:
python-version: '3.7'
architecture: 'x86'
- name: make python enviroment
run: |
python -m pip install nuitka zstandard
python -m pip install python-docx
- name: build pytool directory
run: |
cmd.exe /c ".\tool\${{ matrix.pytoolname }}\build_${{ matrix.pytoolname }}_nuitkamulti.bat"
- name: pack files
run: |
move ".\tool\${{ matrix.pytoolname }}\bin\multi" ".\tool\${{ matrix.pytoolname }}\bin\c${{ matrix.pytoolname }}32_multi"
7z a -t7z -mx5 c${{ matrix.pytoolname }}32_multi.7z ".\tool\${{ matrix.pytoolname }}\bin\c${{ matrix.pytoolname }}32_multi"
- name: create a release
uses: ncipollo/release-action@v1
with:
artifacts: "*.7z"
allowUpdates: "true"
token: ${{ secrets.GITHUB_TOKEN }}

token: ${{ secrets.GITHUB_TOKEN }}
20 changes: 7 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*.pyc
__pycache__
*.o
*.obj
*.log
Expand All @@ -8,18 +7,13 @@ __pycache__
*.pdb
*.ipdb
*.exp
*.aps
*.ilk
*.vcxproj.filters
*.vcxproj.user

.vs
.vscodes
/tool/**/bin/*
/tool/**/x64/*
/tool/**/Debug/*
/tool/**/Release/*
/tool/**/**/x64/*
/tool/**/**/Release/*
/tool/**/**/Debug/*
/script/tmp/*
/src/**/release/*
/src/**/debug/*
/util/bin/**
/env/*
__pycache__

project/**/build/*
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"winpe.h": "c"
}
}
34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
# ReverseUtil
# ReverseTool

![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/yurisizuku/reverseutil?color=green&label=ReverseUtil)![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/YuriSizuku/ReverseUtil/build_wintools.yml?label=build_wintools)
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/yurisizuku/reversetool?color=green&label=ReverseTool)![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/YuriSizuku/ReverseTool/build_wintools.yml?label=build_wintools)
There are my tools for reversing.
The building example is in `./sln`,
The building example is in `./project`,
as well as `Makefile` for `tcc`, `gcc` and `clang`.

## UTIL scripts and libraries
## Cross scripts and libraries

* `bintext.py`, for text exporting and importing, checking
* `libbintext.py`, for text exporting and importing, checking
* `librawtext.py`, some matching and statistic method for text
* `libfont.py`, for extracting, building tile font, or generating font picture.
* `libtext.py`, some matching and statistic method for text
* `texture.py`, something about texture and picture convert
* `ftextcvt.py`, convert the `ftext` format made by `bintext.py`
* `cpcvt.py`, convert some strings encoding in file
* `listmagic.py`, list the files magic to analyze
* `shellcode.py`, some method for generating shellcode, such as parsing `coff` object file
* `bintext.h`, parser for `ftext` by `bintext.py`
* `libtexture.py`, something about texture and picture convert
* `libshellcode.py`, some method for generating shellcode, such as parsing `coff` object file
* `ftext.py`, convert the `ftext` format made by `bintext.py`
* `codepage.py`, convert some strings encoding in file

## Windows scripts and libraries

* `win_injectdll.py` , pre inject `dll` to a `exe`
* `win_console.js`, Allocate a console for game
* `win_file.js` , view information for both `CreateFile`, `ReadFile`, `WriteFile`, `fopen`,`fread`, `fwrite`
* `win_redirect.js`, redirect font, codepage, and paths in games
* `winhook.h`, single file for dynamic hook functions, such as IAT hook, inline hook
* `winpe.h`, single file for parsing windows PE structure, adjust RELOC, ADDRS, or IAT
* `windllin.py` , pre inject `dll` to a `exe`
* `winconsole.js`, Allocate a console for game
* `winfile.js` , view information for both `CreateFile`, `ReadFile`, `WriteFile`, `fopen`,`fread`, `fwrite`
* `winredirect.js`, redirect font, codepage, and paths in games

## Useful tools
## Windows Useful tools

* `dllloader.c`, a tool to start a exe with a `dll` injected, see [Release](https://github.com/YuriSizuku/ReverseUtil/releases)
* `win.c`, a tool to start a exe with a `dll` injected, see [Release](https://github.com/YuriSizuku/ReverseUtil/releases)
7 changes: 7 additions & 0 deletions project/pyexe_bintext/_env.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
::@echo off
set TARGET_NAME=bintext
set PYENV_NAME=pyenv
set PYENV_DIR=%~dp0build
set PYSRC_PATH=%~dp0..\..\src\py\libbintext.py
set OUT_DIR=%~dp0build
set ICON_PATH=%~dp0..\..\asset\default.ico
4 changes: 4 additions & 0 deletions project/pyexe_bintext/build_nuitka.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:: build single files
call %~dp0_env.bat
python -m pip install nuitka
nuitka --standalone --onefile --full-compat --show-progress "%PYSRC_PATH%" --windows-icon-from-ico="%ICON_PATH%" --output-dir="%OUT_DIR%" -o "c%TARGET_NAME%.exe" --assume-yes-for-downloads
4 changes: 4 additions & 0 deletions project/pyexe_bintext/build_pyinstaller.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:: build by pyinstaller
call %~dp0_env.bat
python -m pip install pyinstaller
pyinstaller -F "%PYSRC_PATH%" --name "%TARGET_NAME%.exe" --distpath="%OUT_DIR%" --workpath="%OUT_DIR%/obj/pyinstaller" --specpath="%OUT_DIR%/obj/pyinstaller" --icon="%ICON_PATH%" --exclude-module=numpy --exclude-module=PIL --console --clean --noupx -y
11 changes: 11 additions & 0 deletions project/pyexe_bintext/build_viapyenv.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
::@echo off
:: use as build_viapyenv.bat path/to/xxx.bat

call %~dp0_env.bat
if not exist "%PYENV_DIR%" mkdir "%PYENV_DIR%"

pushd "%PYENV_DIR%"
python -m venv %PYENV_NAME%
cd %PYENV_NAME%\Scripts
call %1
popd
7 changes: 7 additions & 0 deletions project/pyexe_ftext/_env.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
::@echo off
set TARGET_NAME=ftext
set PYENV_NAME=pyenv
set PYENV_DIR=%~dp0build
set PYSRC_PATH=%~dp0..\..\src\py\ftext.py
set OUT_DIR=%~dp0build
set ICON_PATH=%~dp0..\..\asset\default.ico
4 changes: 4 additions & 0 deletions project/pyexe_ftext/build_nuitka.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:: build single files
call %~dp0_env.bat
python -m pip install nuitka
nuitka --standalone --onefile --full-compat --show-progress "%PYSRC_PATH%" --windows-icon-from-ico="%ICON_PATH%" --output-dir="%OUT_DIR%" -o "c%TARGET_NAME%.exe" --assume-yes-for-downloads
4 changes: 4 additions & 0 deletions project/pyexe_ftext/build_pyinstaller.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:: build by pyinstaller
call %~dp0_env.bat
python -m pip install pyinstaller
pyinstaller -F "%PYSRC_PATH%" --name "%TARGET_NAME%.exe" --distpath="%OUT_DIR%" --workpath="%OUT_DIR%/obj/pyinstaller" --specpath="%OUT_DIR%/obj/pyinstaller" --icon="%ICON_PATH%" --exclude-module=numpy --exclude-module=PIL --console --clean --noupx -y
12 changes: 12 additions & 0 deletions project/pyexe_ftext/build_viapyenv.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
::@echo off
:: use as build_viapyenv.bat path/to/xxx.bat

call %~dp0_env.bat
if not exist "%PYENV_DIR%" mkdir "%PYENV_DIR%"

pushd "%PYENV_DIR%"
python -m venv %PYENV_NAME%
cd %PYENV_NAME%\Scripts
python -m pip install python-docx
call %1
popd
116 changes: 116 additions & 0 deletions project/windll_winhook/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# main config
LIBPREFIX?=./../../
ARCH?=i686
PREFIX?=./build

CC:=clang
INCS:=-I$(LIBPREFIX)src/c/include
LIBDIRS:=
LIBS:=-luser32 -lgdi32 -lpsapi
CFLAGS:=-ffunction-sections\
-fdata-sections -std=c99
LDFLAGS:=

# arch config
ifeq ($(ARCH), x86_64)
ARCH_POSTFIX:=64
LIBDIRS+=-L$(LIBPREFIX)lib64
CFLAGS+=-D_WIN64
ifdef DEBUG
BUILD_POSTFIX:=64d
else
BUILD_POSTFIX:=64
endif
else # x86
ARCH_POSTFIX:=32
LIBDIRS+=-L$(LIBPREFIX)lib32
ifdef DEBUG
BUILD_POSTFIX:=32d
else
BUILD_POSTFIX:=32
endif
endif

# compiler config
ifneq (,$(findstring clang, $(CC)))
CFLAGS+=-target $(ARCH)-pc-windows-msvc \
-D_CRT_SECURE_NO_DEPRECATE
LDFLAGS+= -Wl,/OPT:REF\
-Wl,/DEF:src/libwinhook.def\
-Wno-undefined-inline
else # mingw
CFLAGS+=-m$(ARCH_POSTFIX) \
-fPIC\
-fvisibility=hidden\
-fgnu89-inline\
-DWINPE_NOASM
ifneq (,$(findstring gcc, $(CC)))
LDFLAGS+=-lwinpthread \
-static-libgcc \
-static-libstdc++ \
-Wl,-Bstatic,--whole-archive \
-Wl,--no-whole-archive\
-Wl,--gc-sections\
-Wl,--enable-stdcall-fixup\
-Wl,--kill-at
endif
endif

# optimization config
ifdef DEBUG
CFLAGS+=-g -D_DEBUG
else
CFLAGS+=-Os
endif
LIBDIRS+=-L$(PREFIX)

# system config
ifeq ($(shell echo ${OS}), Windows_NT)
DLL_EXT=.dll
EXE_EXT=.exe
else
DLL_EXT?=.so
EXE_EXT?=
endif

# other config
ifneq (,$(findstring clang, $(CC)))
else
ifneq (,$(findstring gcc, $(CC)))
endif
endif

all: prepare\
libwinhook\
libwinhook_test\
helloexe\
hellodll

clean:
rm -rf $(PREFIX)/*libwinhook*
rm -rf $(PREFIX)/*hello*
rm -rf $(PREFIX)/*test*

prepare:
@if ! [ -d $(PREFIX) ]; then mkdir -p $(PREFIX); fi

libwinhook: src\libwinhook.c
@echo \#\#building $@ ...
$(CC) -shared $< \
-o $(PREFIX)/$@$(BUILD_POSTFIX)$(DLL_EXT) \
$(CFLAGS) $(LDFLAGS) $(INCS) $(LIBS) $(LIBDIRS)

libwinhook_test: src\libwinhook_test.c
$(CC) $< \
-o $(PREFIX)/$@$(BUILD_POSTFIX).exe \
$(CFLAGS) $(LDFLAGS) $(INCS) $(LIBS) $(LIBDIRS)

helloexe: src\helloexe.c
@echo \#\#building $@ ...
$(CC) $< -o $(PREFIX)/hello$(BUILD_POSTFIX).exe $(CFLAGS) -lgdi32 -luser32

hellodll: src\hellodll.c
@echo \#\#building $@ ...
$(CC) -shared $< -o $(PREFIX)/hello$(BUILD_POSTFIX).dll $(CFLAGS) -luser32

.PHONY: all clean prepare libwinhook helloexe hellodll
Loading

0 comments on commit 8c7d7ce

Please sign in to comment.