diff --git a/Dockerfile b/Dockerfile.build
similarity index 100%
rename from Dockerfile
rename to Dockerfile.build
diff --git a/Dockerfile.dev b/Dockerfile.dev
new file mode 100644
index 00000000..00c51086
--- /dev/null
+++ b/Dockerfile.dev
@@ -0,0 +1,21 @@
+FROM --platform=amd64 debian:11.6-slim@sha256:f7d141c1ec6af549958a7a2543365a7829c2cdc4476308ec2e182f8a7c59b519
+
+LABEL description="Development environment for bemanitools"
+
+# mingw-w64-gcc has 32-bit and 64-bit toolchains
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ mingw-w64 \
+ mingw-w64-common \
+ make \
+ zip \
+ git \
+ clang-format \
+ python3-pip \
+ && rm -rf /var/lib/apt/lists/*
+
+RUN pip3 install mdformat
+
+RUN mkdir /bemanitools
+WORKDIR /bemanitools
+
+ENV SHELL /bin/bash
\ No newline at end of file
diff --git a/GNUmakefile b/GNUmakefile
index be0bd9ba..8d14ac2c 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -13,8 +13,10 @@ BUILDDIR ?= build
builddir_docker := $(BUILDDIR)/docker
-docker_container_name := "bemanitools-build"
-docker_image_name := "bemanitools-build:latest"
+docker_build_container_name := "bemanitools-build"
+docker_build_image_name := "bemanitools-build:latest"
+docker_dev_container_name := "bemanitools-dev"
+docker_dev_image_name := "bemanitools-dev:latest"
depdir := $(BUILDDIR)/dep
objdir := $(BUILDDIR)/obj
@@ -25,7 +27,7 @@ toolchain_64 := x86_64-w64-mingw32-
gitrev := $(shell git rev-parse HEAD)
cppflags := -I src -I src/main -I src/test -DGITREV=$(gitrev)
-cflags := -O2 -pipe -ffunction-sections -fdata-sections \
+cflags := -g -O2 -pipe -ffunction-sections -fdata-sections \
-Wall -std=c99 -DPSAPI_VERSION=1
cflags_release := -Werror
ldflags := -Wl,--gc-sections -static-libgcc
@@ -41,6 +43,7 @@ FORCE:
.PHONY: \
build-docker \
+dev-docker \
clean \
code-format \
print-building \
@@ -83,21 +86,38 @@ version:
$(V)echo "$(gitrev)" > version
build-docker:
- $(V)docker rm -f $(docker_container_name) 2> /dev/null || true
+ $(V)docker rm -f $(docker_build_container_name) 2> /dev/null || true
$(V)docker \
build \
- -t $(docker_image_name) \
- -f Dockerfile \
+ -t $(docker_build_image_name) \
+ -f Dockerfile.build \
.
$(V)docker \
run \
--volume $(shell pwd):/bemanitools \
- --name $(docker_container_name) \
- $(docker_image_name)
+ --name $(docker_build_container_name) \
+ $(docker_build_image_name)
+
+dev-docker:
+ $(V)docker rm -f $(docker_dev_container_name) 2> /dev/null || true
+ $(V)docker \
+ build \
+ -t $(docker_dev_image_name) \
+ -f Dockerfile.dev \
+ .
+ $(V)docker \
+ run \
+ --interactive \
+ --tty \
+ --volume $(shell pwd):/bemanitools \
+ --name $(docker_dev_container_name) \
+ $(docker_dev_image_name)
clean-docker:
- $(V)docker rm -f $(docker_container_name) || true
- $(V)docker image rm -f $(docker_image_name) || true
+ $(V)docker rm -f $(docker_dev_container_name) || true
+ $(V)docker image rm -f $(docker_dev_image_name) || true
+ $(V)docker rm -f $(docker_build_container_name) || true
+ $(V)docker image rm -f $(docker_build_image_name) || true
$(V)rm -rf $(BUILDDIR)
#
@@ -240,7 +260,6 @@ $$(dll_$1_$2_$3) $$(implib_$1_$2_$3): $$(obj_$1_$2_$3) $$(abslib_$1_$2_$3) \
$(V)$$(toolchain_$1)gcc -shared \
-o $$(dll_$1_$2_$3) -Wl,--out-implib,$$(implib_$1_$2_$3) \
-Wl,--start-group $$^ -Wl,--end-group $$(ldflags_$3)
- $(V)$$(toolchain_$1)strip $$(dll_$1_$2_$3)
$(V)$$(toolchain_$1)ranlib $$(implib_$1_$2_$3)
endef
@@ -257,7 +276,6 @@ $$(exe_$1_$2_$3): $$(obj_$1_$2_$3) $$(abslib_$1_$2_$3) $$(absdpl_$1_$2_$3) \
| $$(bindir_$1_$2)
$(V)echo ... $$@
$(V)$$(toolchain_$1)gcc -o $$@ $$^ $$(ldflags_$3)
- $(V)$$(toolchain_$1)strip $$@
endef
diff --git a/Module.mk b/Module.mk
index 4178a424..0719e25f 100644
--- a/Module.mk
+++ b/Module.mk
@@ -80,7 +80,7 @@ cflags += \
# Each AVS-dependent project should consume the earliest AVS import definition
# that is still ABI-compatible with the real build its target links against.
-avsvers_32 := 1700 1603 1601 1508 1403 1304 1101 1002 803 0
+avsvers_32 := 1700 1603 1601 1508 1403 1306 1304 1101 1002 803 0
avsvers_64 := 1700 1603 1601 1509 1508
imps += avs avs-ea3
@@ -91,6 +91,7 @@ include src/main/acioemu/Module.mk
include src/main/aciomgr/Module.mk
include src/main/aciotest/Module.mk
include src/main/asio/Module.mk
+include src/main/avs-util/Module.mk
include src/main/bio2drv/Module.mk
include src/main/bio2emu-iidx/Module.mk
include src/main/bio2emu/Module.mk
@@ -99,6 +100,7 @@ include src/main/bstio/Module.mk
include src/main/camhook/Module.mk
include src/main/cconfig/Module.mk
include src/main/config/Module.mk
+include src/main/core/Module.mk
include src/main/d3d9-util/Module.mk
include src/main/d3d9exhook/Module.mk
include src/main/ddrhook-util/Module.mk
@@ -180,6 +182,8 @@ include src/main/p4ioemu/Module.mk
include src/main/popnhook-util/Module.mk
include src/main/popnhook1/Module.mk
include src/main/popnio/Module.mk
+include src/main/procmon/Module.mk
+include src/main/procmon-lib/Module.mk
include src/main/pcbidgen/Module.mk
include src/main/sdvxhook/Module.mk
include src/main/sdvxhook2-cn/Module.mk
@@ -231,6 +235,7 @@ $(zipdir)/tools.zip: \
build/bin/indep-32/ezusb2-dbg-hook.dll \
build/bin/indep-32/ezusb2-tool.exe \
build/bin/indep-32/ezusb-tool.exe \
+ build/bin/indep-32/procmon.dll \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
@@ -245,6 +250,7 @@ $(zipdir)/tools-x64.zip: \
build/bin/indep-64/iidx-ezusb2-exit-hook.dll \
build/bin/indep-64/jbiotest.exe \
build/bin/indep-64/mempatch-hook.dll \
+ build/bin/indep-64/procmon.dll \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
@@ -257,6 +263,7 @@ $(zipdir)/iidx-09-to-12.zip: \
build/bin/indep-32/iidxio.dll \
build/bin/indep-32/vefxio.dll \
build/bin/indep-32/inject.exe \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/iidx/config.bat \
dist/iidx/gamestart-09.bat \
dist/iidx/gamestart-10.bat \
@@ -282,6 +289,7 @@ $(zipdir)/iidx-13.zip: \
build/bin/indep-32/iidxio.dll \
build/bin/indep-32/vefxio.dll \
build/bin/indep-32/inject.exe \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/iidx/config.bat \
dist/iidx/gamestart-13.bat \
dist/iidx/iidxhook-13.conf \
@@ -298,6 +306,7 @@ $(zipdir)/iidx-14-to-17.zip: \
build/bin/indep-32/iidxio.dll \
build/bin/indep-32/vefxio.dll \
build/bin/indep-32/inject.exe \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/iidx/config.bat \
dist/iidx/gamestart-14.bat \
dist/iidx/gamestart-15.bat \
@@ -323,6 +332,10 @@ $(zipdir)/iidx-18.zip: \
dist/iidx/config.bat \
dist/iidx/gamestart-18.bat \
dist/iidx/iidxhook-18.conf \
+ dist/iidx/launcher-18.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
dist/iidx/vefx.txt \
| $(zipdir)/
$(V)echo ... $@
@@ -335,6 +348,7 @@ $(zipdir)/iidx-18-cn.zip: \
build/bin/indep-32/iidxio.dll \
build/bin/indep-32/vefxio.dll \
build/bin/indep-32/inject.exe \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/iidx/config.bat \
dist/iidx/gamestart-18-cn.bat \
dist/iidx/iidxhook-18-cn.conf \
@@ -351,9 +365,14 @@ $(zipdir)/iidx-19.zip: \
build/bin/indep-32/geninput.dll \
build/bin/indep-32/iidxio.dll \
build/bin/indep-32/vefxio.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/iidx/config.bat \
dist/iidx/gamestart-19.bat \
dist/iidx/iidxhook-19.conf \
+ dist/iidx/launcher-19.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
dist/iidx/vefx.txt \
| $(zipdir)/
$(V)echo ... $@
@@ -367,9 +386,14 @@ $(zipdir)/iidx-20.zip: \
build/bin/indep-32/geninput.dll \
build/bin/indep-32/iidxio.dll \
build/bin/indep-32/vefxio.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/iidx/config.bat \
dist/iidx/gamestart-20.bat \
dist/iidx/iidxhook-20.conf \
+ dist/iidx/launcher-20.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
dist/iidx/vefx.txt \
| $(zipdir)/
$(V)echo ... $@
@@ -382,6 +406,7 @@ $(zipdir)/iidx-20-cn.zip: \
build/bin/indep-32/iidxio.dll \
build/bin/indep-32/vefxio.dll \
build/bin/indep-32/inject.exe \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/iidx/config.bat \
dist/iidx/gamestart-20-cn.bat \
dist/iidx/iidxhook-20-cn.conf \
@@ -398,6 +423,7 @@ $(zipdir)/iidx-21-to-24.zip: \
build/bin/indep-32/geninput.dll \
build/bin/indep-32/iidxio.dll \
build/bin/indep-32/vefxio.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/iidx/config.bat \
dist/iidx/gamestart-21.bat \
dist/iidx/gamestart-22.bat \
@@ -407,6 +433,13 @@ $(zipdir)/iidx-21-to-24.zip: \
dist/iidx/iidxhook-22.conf \
dist/iidx/iidxhook-23.conf \
dist/iidx/iidxhook-24.conf \
+ dist/iidx/launcher-21.xml \
+ dist/iidx/launcher-22.xml \
+ dist/iidx/launcher-23.xml \
+ dist/iidx/launcher-24.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
dist/iidx/vefx.txt \
| $(zipdir)/
$(V)echo ... $@
@@ -420,11 +453,17 @@ $(zipdir)/iidx-25-to-26.zip: \
build/bin/indep-64/geninput.dll \
build/bin/indep-64/iidxio.dll \
build/bin/indep-64/vefxio.dll \
+ dist/dwarfstack/64/dwarfstack.dll \
dist/iidx/config.bat \
dist/iidx/gamestart-25.bat \
dist/iidx/gamestart-26.bat \
dist/iidx/iidxhook-25.conf \
dist/iidx/iidxhook-26.conf \
+ dist/iidx/launcher-25.xml \
+ dist/iidx/launcher-26.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
dist/iidx/vefx.txt \
| $(zipdir)/
$(V)echo ... $@
@@ -438,6 +477,7 @@ $(zipdir)/iidx-27-to-30.zip: \
build/bin/indep-64/geninput.dll \
build/bin/indep-64/iidxio.dll \
build/bin/indep-64/vefxio.dll \
+ dist/dwarfstack/64/dwarfstack.dll \
dist/iidx/config.bat \
dist/iidx/gamestart-27.bat \
dist/iidx/gamestart-28.bat \
@@ -447,6 +487,13 @@ $(zipdir)/iidx-27-to-30.zip: \
dist/iidx/iidxhook-28.conf \
dist/iidx/iidxhook-29.conf \
dist/iidx/iidxhook-30.conf \
+ dist/iidx/launcher-27.xml \
+ dist/iidx/launcher-28.xml \
+ dist/iidx/launcher-29.xml \
+ dist/iidx/launcher-30.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
dist/iidx/vefx.txt \
| $(zipdir)/
$(V)echo ... $@
@@ -485,6 +532,7 @@ $(zipdir)/jb-01.zip: \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
build/bin/indep-32/jbio.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/jb/config.bat \
dist/jb/gamestart-01.bat \
dist/jb/jbhook-01.conf \
@@ -499,6 +547,7 @@ $(zipdir)/jb-02.zip: \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
build/bin/indep-32/jbio.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/jb/config.bat \
dist/jb/gamestart-02.bat \
dist/jb/jbhook-02.conf \
@@ -513,8 +562,13 @@ $(zipdir)/jb-03.zip: \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
build/bin/indep-32/jbio.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/jb/config.bat \
dist/jb/gamestart-03.bat \
+ dist/jb/launcher-03.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
@@ -526,8 +580,13 @@ $(zipdir)/jb-04.zip: \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
build/bin/indep-32/jbio.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/jb/config.bat \
dist/jb/gamestart-03.bat \
+ dist/jb/launcher-03.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
@@ -539,8 +598,13 @@ $(zipdir)/jb-05-to-07.zip: \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
build/bin/indep-32/jbio.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/jb/config.bat \
dist/jb/gamestart-04.bat \
+ dist/jb/launcher-04.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
@@ -552,8 +616,13 @@ $(zipdir)/jb-08.zip: \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
build/bin/indep-32/jbio.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/jb/config.bat \
dist/jb/gamestart-04.bat \
+ dist/jb/launcher-04.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
@@ -576,8 +645,13 @@ $(zipdir)/sdvx-01-to-04.zip: \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
build/bin/indep-32/sdvxio.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/sdvx/config.bat \
dist/sdvx/gamestart.bat \
+ dist/sdvx/launcher.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
@@ -589,9 +663,14 @@ $(zipdir)/sdvx-05-to-06.zip: \
build/bin/indep-64/eamio.dll \
build/bin/indep-64/geninput.dll \
build/bin/indep-64/sdvxio.dll \
+ dist/dwarfstack/64/dwarfstack.dll \
dist/sdvx5/config.bat \
dist/sdvx5/gamestart.bat \
dist/sdvx5/sdvxhook2.conf \
+ dist/sdvx5/launcher.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
@@ -603,9 +682,14 @@ $(zipdir)/sdvx-05-cn.zip: \
build/bin/indep-64/eamio.dll \
build/bin/indep-64/geninput.dll \
build/bin/indep-64/sdvxio.dll \
+ dist/dwarfstack/64/dwarfstack.dll \
dist/sdvx5/config.bat \
dist/sdvx5/gamestart-cn.bat \
dist/sdvx5/sdvxhook2-cn.conf \
+ dist/sdvx5/launcher-cn.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
@@ -659,6 +743,7 @@ $(zipdir)/ddr-12-us.zip: \
build/bin/indep-32/ddrio-smx.dll \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/ddr/config.bat \
dist/ddr/gamestart-12-us.bat \
dist/ddr/gamestart-12-eu.bat \
@@ -678,29 +763,39 @@ $(zipdir)/ddr-12.zip: \
build/bin/indep-32/ddrio-smx.dll \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/ddr/config.bat \
dist/ddr/gamestart-12.bat \
+ dist/ddr/launcher-12.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
$(zipdir)/ddr-13.zip: \
- build/bin/avs2_1304-32/launcher.exe \
- build/bin/avs2_1304-32/ddrhook2.dll \
- build/bin/avs2_1304-32/unicorntail.dll \
+ build/bin/avs2_1306-32/launcher.exe \
+ build/bin/avs2_1306-32/ddrhook2.dll \
+ build/bin/avs2_1306-32/unicorntail.dll \
build/bin/indep-32/config.exe \
build/bin/indep-32/ddrio.dll \
build/bin/indep-32/ddrio-mm.dll \
build/bin/indep-32/ddrio-smx.dll \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/ddr/config.bat \
dist/ddr/gamestart-13.bat \
+ dist/ddr/launcher-13.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
-$(zipdir)/ddr-14-to-16.zip: \
+$(zipdir)/ddr-14-to-18.zip: \
build/bin/avs2_1508-32/launcher.exe \
build/bin/avs2_1508-32/ddrhook2.dll \
build/bin/avs2_1508-32/unicorntail.dll \
@@ -708,15 +803,26 @@ $(zipdir)/ddr-14-to-16.zip: \
build/bin/indep-32/ddrio.dll \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/geninput.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/ddr/config.bat \
dist/ddr/gamestart-14.bat \
dist/ddr/gamestart-15.bat \
dist/ddr/gamestart-16.bat \
+ dist/ddr/gamestart-17.bat \
+ dist/ddr/gamestart-18.bat \
+ dist/ddr/launcher-14.xml \
+ dist/ddr/launcher-15.xml \
+ dist/ddr/launcher-16.xml \
+ dist/ddr/launcher-17.xml \
+ dist/ddr/launcher-18.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
-$(zipdir)/ddr-16-x64.zip: \
+$(zipdir)/ddr-16-to-18-x64.zip: \
build/bin/avs2_1603-64/launcher.exe \
build/bin/avs2_1603-64/ddrhook2.dll \
build/bin/avs2_1603-64/unicorntail.dll \
@@ -724,8 +830,17 @@ $(zipdir)/ddr-16-x64.zip: \
build/bin/indep-64/ddrio.dll \
build/bin/indep-64/eamio.dll \
build/bin/indep-64/geninput.dll \
+ dist/dwarfstack/64/dwarfstack.dll \
dist/ddr/config.bat \
dist/ddr/gamestart-16.bat \
+ dist/ddr/gamestart-17.bat \
+ dist/ddr/gamestart-18.bat \
+ dist/ddr/launcher-16.xml \
+ dist/ddr/launcher-17.xml \
+ dist/ddr/launcher-18.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
@@ -761,9 +876,15 @@ $(zipdir)/bst.zip: \
build/bin/indep-64/config.exe \
build/bin/indep-64/eamio.dll \
build/bin/indep-64/geninput.dll \
+ dist/dwarfstack/64/dwarfstack.dll \
dist/bst/config.bat \
dist/bst/gamestart1.bat \
dist/bst/gamestart2.bat \
+ dist/bst/launcher-01.xml \
+ dist/bst/launcher-02.xml \
+ dist/shared/ea3-ident.xml \
+ dist/shared/ea3-license.xml \
+ dist/shared/ea3-service.xml \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^
@@ -776,6 +897,7 @@ $(zipdir)/popn-15-to-18.zip: \
build/bin/indep-32/eamio.dll \
build/bin/indep-32/popnio.dll \
build/bin/indep-32/ezusb2-popn-shim.dll \
+ dist/dwarfstack/32/dwarfstack.dll \
dist/popn/config.bat \
dist/popn/gamestart-15.bat \
dist/popn/gamestart-16.bat \
@@ -807,6 +929,7 @@ $(BUILDDIR)/tests.zip: \
build/bin/indep-32/iidxhook-util-config-gfx-test.exe \
build/bin/indep-32/iidxhook-util-config-misc-test.exe \
build/bin/indep-32/iidxhook-util-config-sec-test.exe \
+ dist/dwarfstack/32/dwarfstack.dll \
build/bin/indep-32/inject.exe \
build/bin/indep-32/security-id-test.exe \
build/bin/indep-32/security-mcode-test.exe \
@@ -827,8 +950,8 @@ $(BUILDDIR)/bemanitools.zip: \
$(zipdir)/ddr-12.zip \
$(zipdir)/ddr-12-us.zip \
$(zipdir)/ddr-13.zip \
- $(zipdir)/ddr-14-to-16.zip \
- $(zipdir)/ddr-16-x64.zip \
+ $(zipdir)/ddr-14-to-18.zip \
+ $(zipdir)/ddr-16-to-18-x64.zip \
$(zipdir)/ddr-hwio-x86.zip \
$(zipdir)/ddr-hwio-x64.zip \
$(zipdir)/doc.zip \
diff --git a/README.md b/README.md
index d320361e..20ffb2b7 100644
--- a/README.md
+++ b/README.md
@@ -35,9 +35,12 @@ The following games are supported with their corresponding hook-libraries.
* Dance Dance Revolution X (`ddr-11.zip`): [ddrhook1](doc/ddrhook/ddrhook1.md)
* Dance Dance Revolution X2 (US/EU regions) (`ddr-12-us.zip`): [ddrhook1](doc/ddrhook/ddrhook1.md)
* Dance Dance Revolution X2 (JP region) (`ddr-12.zip`): [ddrhook2](doc/ddrhook/ddrhook2.md)
- * Dance Dance Revolution 2013 (`ddr-14-to-16.zip`): [ddrhook2](doc/ddrhook/ddrhook2.md)
- * Dance Dance Revolution 2014 (`ddr-14-to-16.zip`): [ddrhook2](doc/ddrhook/ddrhook2.md)
- * Dance Dance Revolution A (`ddr-14-to-16.zip`): [ddrhook2](doc/ddrhook/ddrhook2.md)
+ * Dance Dance Revolution X3 vs. 2ndMIX (`ddr-13.zip`): [ddrhook2](doc/ddrhook/ddrhook2.md)
+ * Dance Dance Revolution 2013 (`ddr-14-to-18.zip`): [ddrhook2](doc/ddrhook/ddrhook2.md)
+ * Dance Dance Revolution 2014 (`ddr-14-to-18.zip`): [ddrhook2](doc/ddrhook/ddrhook2.md)
+ * Dance Dance Revolution A (`ddr-14-to-18.zip`): [ddrhook2](doc/ddrhook/ddrhook2.md)
+ * Dance Dance Revolution A20 (`ddr-14-to-18.zip`): [ddrhook2](doc/ddrhook/ddrhook2.md)
+ * Dance Dance Revolution A20+ (`ddr-14-to-18.zip`): [ddrhook2](doc/ddrhook/ddrhook2.md)
* [Beatmania IIDX](doc/iidxhook/README.md)
* Beatmania IIDX 9th Style (`iidx-09-to-12.zip`): [iidxhook1](doc/iidxhook/iidxhook1.md)
* Beatmania IIDX 10th Style (`iidx-09-to-12.zip`): [iidxhook1](doc/iidxhook/iidxhook1.md)
@@ -133,21 +136,34 @@ or FAQ. We advice you to read them as your questions and concerns might already
know if there is any information that you consider helpful or important to know and should be added.
### Setup and dependencies
-Most (older generation) games were developed for Windows XP Embedded but should run fine on any
-consumer version of Windows XP. Newer versions of Windows, e.g. Windows 7, 8 and 10, should be fine
-as well. Some hooks also include fixes required to run the games on a more recent version.
-
-Depending on the game, you also need the following dependencies installed:
-
-* The 32-bit (x86) version of
- [Microsoft Visual C++ 2010 Service Pack 1 Redistributable Package MFC Security Update](https://www.microsoft.com/en-sg/download/details.aspx?id=26999)
-* The 32-bit (x86) and 64-bit (x64) versions of
- [Microsoft Visual C++ Redistributable Packages for Visual Studio 2013](https://www.microsoft.com/en-sg/download/details.aspx?id=40784)
-* The [DirectX 9 End-User Runtimes (June 2010)](https://www.microsoft.com/en-us/download/details.aspx?id=8109)
-
-See also
-[bemanitools-supplement](https://www.github.com/djhackersdev/bemanitools-supplement/)
-for files.
+The games bemanitools support span several generations of (embedded) Windows versions:
+XP, 7 and 10 (IoT). With these come different generations of dependencies as requirements.
+
+Simplified, this boils down to the following list of C++ Redistributable (vcredist) packages that are
+recommended to be installed without going into detail which game needs exactly which version.
+Keep in mind the "bitness" (32-bit vs. 64-bit) of each specific game and download the right
+ones accordingly.
+
+You can use a tool like [dependencywalker](https://www.dependencywalker.com/) to figure that
+out if it is relevant to you.
+
+Links/files are also provided by
+[bemanitools-supplement](https://github.com/djhackersdev/bemanitools-supplement/tree/master/misc/win-runtime#windows-runtimes-and-libraries)
+
+#### Visual C++ Redistributable Packages
+* 2010
+ * [32-bit (x86)](http://download.microsoft.com/download/5/B/C/5BC5DBB3-652D-4DCE-B14A-475AB85EEF6E/vcredist_x86.exe)
+ * [64-bit (x64)](http://download.microsoft.com/download/d/2/4/d242c3fb-da5a-4542-ad66-f9661d0a8d19/vcredist_x64.exe)
+* 2013
+ * [32-bit (x86)](http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe)
+ * [64-bit (x64)](http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe)
+* 2015
+ * [32-bit (x86)](https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe)
+ * [64-bit (x64)](https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe)
+
+#### DirectX 9
+Most/nearly all games support to this day use the DirectX 9(ex) API. Make sure to install the
+[DirectX 9 End-User Runtimes (June 2010)](https://www.microsoft.com/en-us/download/details.aspx?id=8109)
## Development
### Building
diff --git a/dist/bst/gamestart1.bat b/dist/bst/gamestart1.bat
index 5a3a9155..5bca8eb1 100644
--- a/dist/bst/gamestart1.bat
+++ b/dist/bst/gamestart1.bat
@@ -1,10 +1,34 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\nvram\coin.xml copy prop\defaults\coin.xml dev\nvram\coin.xml
-if not exist dev\nvram\eacoin.xml copy prop\defaults\eacoin.xml dev\nvram\eacoin.xml
-if not exist dev\raw mkdir dev\raw
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-launcher -K bsthook.dll -E prop/ea3-config-1.xml beatstream1.dll %*
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-01.xml %*
\ No newline at end of file
diff --git a/dist/bst/gamestart2.bat b/dist/bst/gamestart2.bat
index 8b6f53f8..55340c37 100644
--- a/dist/bst/gamestart2.bat
+++ b/dist/bst/gamestart2.bat
@@ -1,10 +1,34 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\nvram\coin.xml copy prop\defaults\coin.xml dev\nvram\coin.xml
-if not exist dev\nvram\eacoin.xml copy prop\defaults\eacoin.xml dev\nvram\eacoin.xml
-if not exist dev\raw mkdir dev\raw
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-launcher -K bsthook.dll -E prop/ea3-config-2.xml beatstream2.dll %*
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-02.xml %*
\ No newline at end of file
diff --git a/dist/bst/launcher-01.xml b/dist/bst/launcher-01.xml
new file mode 100644
index 00000000..b62630ef
--- /dev/null
+++ b/dist/bst/launcher-01.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 16777216
+ 16777216
+ ∂
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ beatstream1.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-server.xml
+
+
+
+ bsthook.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/bst/launcher-02.xml b/dist/bst/launcher-02.xml
new file mode 100644
index 00000000..fdad81d9
--- /dev/null
+++ b/dist/bst/launcher-02.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 16777216
+ 16777216
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ beatstream2.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ bsthook.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/ddr/gamestart-12.bat b/dist/ddr/gamestart-12.bat
index 7df3fa33..03daa9c3 100644
--- a/dist/ddr/gamestart-12.bat
+++ b/dist/ddr/gamestart-12.bat
@@ -1,11 +1,42 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist conf\nvram mkdir conf\nvram
-if not exist conf\raw mkdir conf\raw
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set COM_DIR=%CONTENT_DIR%\com
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Register video codecs, e.g. required for background videos
+regsvr32 /s %COM_DIR%\k-clvsd.dll
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-regsvr32 /s k-clvsd.dll
-regsvr32 /s xactengine2_10.dll
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-13.xml %*
-.\launcher.exe -K .\ddrhook2.dll .\ddr.dll %*
+:: Unregister video codec to avoid conflicts with other/older video codecs crashing different
+:: game versions, e.g. DDR X
+regsvr32 /u /s %COM_DIR%\k-clvsd.dll
\ No newline at end of file
diff --git a/dist/ddr/gamestart-13.bat b/dist/ddr/gamestart-13.bat
index 7df3fa33..03daa9c3 100644
--- a/dist/ddr/gamestart-13.bat
+++ b/dist/ddr/gamestart-13.bat
@@ -1,11 +1,42 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist conf\nvram mkdir conf\nvram
-if not exist conf\raw mkdir conf\raw
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set COM_DIR=%CONTENT_DIR%\com
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Register video codecs, e.g. required for background videos
+regsvr32 /s %COM_DIR%\k-clvsd.dll
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-regsvr32 /s k-clvsd.dll
-regsvr32 /s xactengine2_10.dll
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-13.xml %*
-.\launcher.exe -K .\ddrhook2.dll .\ddr.dll %*
+:: Unregister video codec to avoid conflicts with other/older video codecs crashing different
+:: game versions, e.g. DDR X
+regsvr32 /u /s %COM_DIR%\k-clvsd.dll
\ No newline at end of file
diff --git a/dist/ddr/gamestart-14.bat b/dist/ddr/gamestart-14.bat
index 2ad52121..2364f521 100644
--- a/dist/ddr/gamestart-14.bat
+++ b/dist/ddr/gamestart-14.bat
@@ -1,14 +1,44 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist conf\nvram mkdir conf\nvram
-if not exist conf\nvram\coin.xml copy prop\coin.xml conf\nvram\coin.xml
-if not exist conf\nvram\eacoin.xml copy prop\eacoin.xml conf\nvram\eacoin.xml
-if not exist conf\nvram\share-config.xml copy prop\share-config.xml conf\nvram\share-config.xml
-if not exist conf\raw mkdir conf\raw
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set COM_DIR=%CONTENT_DIR%\com
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Register video codecs, e.g. required for background videos
+regsvr32 /s %COM_DIR%\k-clvsd.dll
+regsvr32 /s %COM_DIR%\xactengine2_10.dll
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-regsvr32 /s k-clvsd.dll
-regsvr32 /s xactengine2_10.dll
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-14.xml %*
-.\launcher.exe -K .\ddrhook2.dll .\mdxja_945.dll %*
+:: Unregister video codec to avoid conflicts with other/older video codecs crashing different
+:: game versions, e.g. DDR X
+regsvr32 /u /s %COM_DIR%\k-clvsd.dll
+regsvr32 /u /s %COM_DIR%\xactengine2_10.dll
\ No newline at end of file
diff --git a/dist/ddr/gamestart-15.bat b/dist/ddr/gamestart-15.bat
index 2ad52121..97301177 100644
--- a/dist/ddr/gamestart-15.bat
+++ b/dist/ddr/gamestart-15.bat
@@ -1,14 +1,44 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist conf\nvram mkdir conf\nvram
-if not exist conf\nvram\coin.xml copy prop\coin.xml conf\nvram\coin.xml
-if not exist conf\nvram\eacoin.xml copy prop\eacoin.xml conf\nvram\eacoin.xml
-if not exist conf\nvram\share-config.xml copy prop\share-config.xml conf\nvram\share-config.xml
-if not exist conf\raw mkdir conf\raw
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set COM_DIR=%CONTENT_DIR%\com
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Register video codecs, e.g. required for background videos
+regsvr32 /s %COM_DIR%\k-clvsd.dll
+regsvr32 /s %COM_DIR%\xactengine2_10.dll
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-regsvr32 /s k-clvsd.dll
-regsvr32 /s xactengine2_10.dll
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-15.xml %*
-.\launcher.exe -K .\ddrhook2.dll .\mdxja_945.dll %*
+:: Unregister video codec to avoid conflicts with other/older video codecs crashing different
+:: game versions, e.g. DDR X
+regsvr32 /u /s %COM_DIR%\k-clvsd.dll
+regsvr32 /u /s %COM_DIR%\xactengine2_10.dll
\ No newline at end of file
diff --git a/dist/ddr/gamestart-16.bat b/dist/ddr/gamestart-16.bat
index d108118b..b176cb3a 100644
--- a/dist/ddr/gamestart-16.bat
+++ b/dist/ddr/gamestart-16.bat
@@ -1,15 +1,44 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist conf\nvram mkdir conf\nvram
-if not exist conf\nvram\ea3-config.xml copy prop\eamuse-config.xml conf\nvram\ea3-config.xml
-if not exist conf\nvram\coin.xml copy prop\coin.xml conf\nvram\coin.xml
-if not exist conf\nvram\eacoin.xml copy prop\eacoin.xml conf\nvram\eacoin.xml
-if not exist conf\nvram\testmode-v.xml copy prop\testmode-v.xml conf\nvram\testmode-v.xml
-if not exist conf\raw mkdir conf\raw
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set COM_DIR=%CONTENT_DIR%\com
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Register video codecs, e.g. required for background videos
+regsvr32 /s %COM_DIR%\k-clvsd.dll
+regsvr32 /s %COM_DIR%\xactengine2_10.dll
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-regsvr32 /s com\k-clvsd.dll
-regsvr32 /s com\xactengine2_10.dll
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-17.xml %*
-.\launcher.exe -H 33554432 -K .\ddrhook2.dll .\arkmdxp3.dll %*
+:: Unregister video codec to avoid conflicts with other/older video codecs crashing different
+:: game versions, e.g. DDR X
+regsvr32 /u /s %COM_DIR%\k-clvsd.dll
+regsvr32 /u /s %COM_DIR%\xactengine2_10.dll
\ No newline at end of file
diff --git a/dist/ddr/gamestart-17.bat b/dist/ddr/gamestart-17.bat
new file mode 100644
index 00000000..b176cb3a
--- /dev/null
+++ b/dist/ddr/gamestart-17.bat
@@ -0,0 +1,44 @@
+@echo off
+
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
+cd /d %~dp0
+
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set COM_DIR=%CONTENT_DIR%\com
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Register video codecs, e.g. required for background videos
+regsvr32 /s %COM_DIR%\k-clvsd.dll
+regsvr32 /s %COM_DIR%\xactengine2_10.dll
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
+
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-17.xml %*
+
+:: Unregister video codec to avoid conflicts with other/older video codecs crashing different
+:: game versions, e.g. DDR X
+regsvr32 /u /s %COM_DIR%\k-clvsd.dll
+regsvr32 /u /s %COM_DIR%\xactengine2_10.dll
\ No newline at end of file
diff --git a/dist/ddr/gamestart-18.bat b/dist/ddr/gamestart-18.bat
new file mode 100644
index 00000000..95a92ed0
--- /dev/null
+++ b/dist/ddr/gamestart-18.bat
@@ -0,0 +1,44 @@
+@echo off
+
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
+cd /d %~dp0
+
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set COM_DIR=%CONTENT_DIR%\com
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Register video codecs, e.g. required for background videos
+regsvr32 /s %COM_DIR%\k-clvsd.dll
+regsvr32 /s %COM_DIR%\xactengine2_10.dll
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
+
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-18.xml %*
+
+:: Unregister video codec to avoid conflicts with other/older video codecs crashing different
+:: game versions, e.g. DDR X
+regsvr32 /u /s %COM_DIR%\k-clvsd.dll
+regsvr32 /u /s %COM_DIR%\xactengine2_10.dll
\ No newline at end of file
diff --git a/dist/ddr/launcher-12.xml b/dist/ddr/launcher-12.xml
new file mode 100644
index 00000000..54c0284b
--- /dev/null
+++ b/dist/ddr/launcher-12.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 31457280
+ 31457280
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ ddr.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ ddrhook2.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/ddr/launcher-13.xml b/dist/ddr/launcher-13.xml
new file mode 100644
index 00000000..54c0284b
--- /dev/null
+++ b/dist/ddr/launcher-13.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 31457280
+ 31457280
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ ddr.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ ddrhook2.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/ddr/launcher-14.xml b/dist/ddr/launcher-14.xml
new file mode 100644
index 00000000..9ae27ac3
--- /dev/null
+++ b/dist/ddr/launcher-14.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 31457280
+ 31457280
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ mdxja_945.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ ddrhook2.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/ddr/launcher-15.xml b/dist/ddr/launcher-15.xml
new file mode 100644
index 00000000..9ae27ac3
--- /dev/null
+++ b/dist/ddr/launcher-15.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 31457280
+ 31457280
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ mdxja_945.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ ddrhook2.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/ddr/launcher-16.xml b/dist/ddr/launcher-16.xml
new file mode 100644
index 00000000..cdf16d55
--- /dev/null
+++ b/dist/ddr/launcher-16.xml
@@ -0,0 +1,76 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 33554432
+ 1048576
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ arkmdxp3.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ ddrhook2.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/ddr/launcher-17.xml b/dist/ddr/launcher-17.xml
new file mode 100644
index 00000000..cdf16d55
--- /dev/null
+++ b/dist/ddr/launcher-17.xml
@@ -0,0 +1,76 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 33554432
+ 1048576
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ arkmdxp3.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ ddrhook2.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/ddr/launcher-18.xml b/dist/ddr/launcher-18.xml
new file mode 100644
index 00000000..cdf16d55
--- /dev/null
+++ b/dist/ddr/launcher-18.xml
@@ -0,0 +1,76 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 33554432
+ 1048576
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ arkmdxp3.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ ddrhook2.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/dwarfstack/32/dwarfstack.dll b/dist/dwarfstack/32/dwarfstack.dll
new file mode 100644
index 00000000..74b9796d
Binary files /dev/null and b/dist/dwarfstack/32/dwarfstack.dll differ
diff --git a/dist/dwarfstack/64/dwarfstack.dll b/dist/dwarfstack/64/dwarfstack.dll
new file mode 100644
index 00000000..8944c726
Binary files /dev/null and b/dist/dwarfstack/64/dwarfstack.dll differ
diff --git a/dist/dwarfstack/readme.md b/dist/dwarfstack/readme.md
new file mode 100644
index 00000000..c8ce1e3c
--- /dev/null
+++ b/dist/dwarfstack/readme.md
@@ -0,0 +1 @@
+Version/release: https://github.com/ssbssa/dwarfstack/releases/tag/2.2
\ No newline at end of file
diff --git a/dist/iidx/ea3-ident.xml b/dist/iidx/ea3-ident.xml
new file mode 100644
index 00000000..e24a9b92
--- /dev/null
+++ b/dist/iidx/ea3-ident.xml
@@ -0,0 +1,10 @@
+
+
+
+ LDJ
+ J
+ A
+ A
+ 2022082400
+
+
\ No newline at end of file
diff --git a/dist/iidx/eamuse-server.xml b/dist/iidx/eamuse-server.xml
new file mode 100644
index 00000000..bc706444
--- /dev/null
+++ b/dist/iidx/eamuse-server.xml
@@ -0,0 +1,6 @@
+
+
+
+ http://localhost
+
+
\ No newline at end of file
diff --git a/dist/iidx/gamestart-18.bat b/dist/iidx/gamestart-18.bat
index cce99b03..4777dd9c 100755
--- a/dist/iidx/gamestart-18.bat
+++ b/dist/iidx/gamestart-18.bat
@@ -1,14 +1,34 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist d mkdir d
-if not exist e mkdir e
-if not exist f mkdir f
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\nvram\coin.xml copy prop\defaults\coin.xml dev\nvram\coin.xml
-if not exist dev\nvram\eacoin.xml copy prop\defaults\eacoin.xml dev\nvram\eacoin.xml
-if not exist dev\raw mkdir dev\raw
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-launcher -K iidxhook4.dll bm2dx.dll --config iidxhook-18.conf %*
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-18.xml --config %BEMANITOOLS_DIR%\iidxhook-18.conf %*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-19.bat b/dist/iidx/gamestart-19.bat
index 8bfd5803..03c22b08 100755
--- a/dist/iidx/gamestart-19.bat
+++ b/dist/iidx/gamestart-19.bat
@@ -1,14 +1,34 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist d mkdir d
-if not exist e mkdir e
-if not exist f mkdir f
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\nvram\coin.xml copy prop\defaults\coin.xml dev\nvram\coin.xml
-if not exist dev\nvram\eacoin.xml copy prop\defaults\eacoin.xml dev\nvram\eacoin.xml
-if not exist dev\raw mkdir dev\raw
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-launcher -K iidxhook5.dll bm2dx.dll --config iidxhook-19.conf %*
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-19.xml --config %BEMANITOOLS_DIR%\iidxhook-19.conf %*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-20.bat b/dist/iidx/gamestart-20.bat
index 2dac80ea..f579f2ef 100755
--- a/dist/iidx/gamestart-20.bat
+++ b/dist/iidx/gamestart-20.bat
@@ -1,10 +1,34 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\nvram\coin.xml copy prop\defaults\coin.xml dev\nvram\coin.xml
-if not exist dev\nvram\eacoin.xml copy prop\defaults\eacoin.xml dev\nvram\eacoin.xml
-if not exist dev\raw mkdir dev\raw
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-launcher -K iidxhook6.dll bm2dx.dll --config iidxhook-20.conf %*
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-20.xml --config %BEMANITOOLS_DIR%\iidxhook-20.conf %*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-21.bat b/dist/iidx/gamestart-21.bat
index b79d6416..9ec039dd 100755
--- a/dist/iidx/gamestart-21.bat
+++ b/dist/iidx/gamestart-21.bat
@@ -1,10 +1,34 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\nvram\coin.xml copy prop\defaults\coin.xml dev\nvram\coin.xml
-if not exist dev\nvram\eacoin.xml copy prop\defaults\eacoin.xml dev\nvram\eacoin.xml
-if not exist dev\raw mkdir dev\raw
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-launcher -K iidxhook7.dll bm2dx.dll --config iidxhook-21.conf %*
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-21.xml --config %BEMANITOOLS_DIR%\iidxhook-21.conf %*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-22.bat b/dist/iidx/gamestart-22.bat
index d10a945a..d2847863 100755
--- a/dist/iidx/gamestart-22.bat
+++ b/dist/iidx/gamestart-22.bat
@@ -1,10 +1,34 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\nvram\coin.xml copy prop\defaults\coin.xml dev\nvram\coin.xml
-if not exist dev\nvram\eacoin.xml copy prop\defaults\eacoin.xml dev\nvram\eacoin.xml
-if not exist dev\raw mkdir dev\raw
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-launcher -K iidxhook7.dll bm2dx.dll --config iidxhook-22.conf %*
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-22.xml --config %BEMANITOOLS_DIR%\iidxhook-22.conf %*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-23.bat b/dist/iidx/gamestart-23.bat
index 656e1fe2..33cceb12 100755
--- a/dist/iidx/gamestart-23.bat
+++ b/dist/iidx/gamestart-23.bat
@@ -1,10 +1,34 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\nvram\coin.xml copy prop\defaults\coin.xml dev\nvram\coin.xml
-if not exist dev\nvram\eacoin.xml copy prop\defaults\eacoin.xml dev\nvram\eacoin.xml
-if not exist dev\raw mkdir dev\raw
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-launcher -K iidxhook7.dll bm2dx.dll --config iidxhook-23.conf %*
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-23.xml --config %BEMANITOOLS_DIR%\iidxhook-23.conf %*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-24.bat b/dist/iidx/gamestart-24.bat
index 283020c4..94fa8b2b 100755
--- a/dist/iidx/gamestart-24.bat
+++ b/dist/iidx/gamestart-24.bat
@@ -1,10 +1,34 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\nvram\coin.xml copy prop\defaults\coin.xml dev\nvram\coin.xml
-if not exist dev\nvram\eacoin.xml copy prop\defaults\eacoin.xml dev\nvram\eacoin.xml
-if not exist dev\raw mkdir dev\raw
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-launcher -K iidxhook7.dll bm2dx.dll --config iidxhook-24.conf %*
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-24.xml --config %BEMANITOOLS_DIR%\iidxhook-24.conf %*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-25.bat b/dist/iidx/gamestart-25.bat
index edff2940..2d6b6c7c 100644
--- a/dist/iidx/gamestart-25.bat
+++ b/dist/iidx/gamestart-25.bat
@@ -1,16 +1,34 @@
@echo off
-cd /d %~dp0
-if not exist dev mkdir dev
-if not exist dev\e mkdir dev\e
-if not exist dev\g mkdir dev\g
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\raw mkdir dev\raw
-if not exist dev\raw\log mkdir dev\raw\log
-if not exist dev\raw\fscache mkdir dev\raw\fscache
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
-for /R prop\defaults %%D in (*.*) do (
- if not exist dev\nvram\%%~nxD copy /y prop\defaults\%%~nxD dev\nvram
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
)
-launcher -H 134217728 -K iidxhook8.dll bm2dx.dll --config iidxhook-25.conf %*
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
+cd /d %~dp0
+
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
+
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-25.xml --config %BEMANITOOLS_DIR%\iidxhook-25.conf %*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-26.bat b/dist/iidx/gamestart-26.bat
index d41b72b3..dc06460f 100644
--- a/dist/iidx/gamestart-26.bat
+++ b/dist/iidx/gamestart-26.bat
@@ -1,16 +1,34 @@
@echo off
-cd /d %~dp0
-if not exist dev mkdir dev
-if not exist dev\e mkdir dev\e
-if not exist dev\g mkdir dev\g
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\raw mkdir dev\raw
-if not exist dev\raw\log mkdir dev\raw\log
-if not exist dev\raw\fscache mkdir dev\raw\fscache
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
-for /R prop\defaults %%D in (*.*) do (
- if not exist dev\nvram\%%~nxD copy /y prop\defaults\%%~nxD dev\nvram
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
)
-launcher -H 134217728 -K iidxhook8.dll bm2dx.dll --config iidxhook-26.conf %*
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
+cd /d %~dp0
+
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
+
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-26.xml --config %BEMANITOOLS_DIR%\iidxhook-26.conf %*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-27.bat b/dist/iidx/gamestart-27.bat
index 04a39091..d034f84f 100644
--- a/dist/iidx/gamestart-27.bat
+++ b/dist/iidx/gamestart-27.bat
@@ -1,16 +1,34 @@
@echo off
-cd /d %~dp0
-if not exist dev mkdir dev
-if not exist dev\e mkdir dev\e
-if not exist dev\g mkdir dev\g
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\raw mkdir dev\raw
-if not exist dev\raw\log mkdir dev\raw\log
-if not exist dev\raw\fscache mkdir dev\raw\fscache
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
-for /R prop\defaults %%D in (*.*) do (
- if not exist dev\nvram\%%~nxD copy /y prop\defaults\%%~nxD dev\nvram
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
)
-launcher -H 134217728 -B iidxhook9.dll bm2dx.dll --config iidxhook-27.conf %*
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
+cd /d %~dp0
+
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
+
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-27.xml --config %BEMANITOOLS_DIR%\iidxhook-27.conf %*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-28.bat b/dist/iidx/gamestart-28.bat
index 1abb520d..cfc18e45 100644
--- a/dist/iidx/gamestart-28.bat
+++ b/dist/iidx/gamestart-28.bat
@@ -1,16 +1,34 @@
@echo off
-cd /d %~dp0
-if not exist dev mkdir dev
-if not exist dev\e mkdir dev\e
-if not exist dev\g mkdir dev\g
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\raw mkdir dev\raw
-if not exist dev\raw\log mkdir dev\raw\log
-if not exist dev\raw\fscache mkdir dev\raw\fscache
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
-for /R prop\defaults %%D in (*.*) do (
- if not exist dev\nvram\%%~nxD copy /y prop\defaults\%%~nxD dev\nvram
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
)
-launcher -H 134217728 -B iidxhook9.dll bm2dx.dll --config iidxhook-28.conf %*
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
+cd /d %~dp0
+
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
+
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-28.xml --config %BEMANITOOLS_DIR%\iidxhook-28.conf %*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-29.bat b/dist/iidx/gamestart-29.bat
index 1029b8c5..64a02a5b 100644
--- a/dist/iidx/gamestart-29.bat
+++ b/dist/iidx/gamestart-29.bat
@@ -1,16 +1,34 @@
@echo off
-cd /d %~dp0
-if not exist dev mkdir dev
-if not exist dev\e mkdir dev\e
-if not exist dev\g mkdir dev\g
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\raw mkdir dev\raw
-if not exist dev\raw\log mkdir dev\raw\log
-if not exist dev\raw\fscache mkdir dev\raw\fscache
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
-for /R prop\defaults %%D in (*.*) do (
- if not exist dev\nvram\%%~nxD copy /y prop\defaults\%%~nxD dev\nvram
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
)
-launcher -H 134217728 -B iidxhook9.dll bm2dx.dll --config iidxhook-29.conf %*
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
+cd /d %~dp0
+
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
+
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-29.xml --config %BEMANITOOLS_DIR%\iidxhook-29.conf %*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-30.bat b/dist/iidx/gamestart-30.bat
index 776d7e84..61f77205 100644
--- a/dist/iidx/gamestart-30.bat
+++ b/dist/iidx/gamestart-30.bat
@@ -1,16 +1,34 @@
@echo off
-cd /d %~dp0
-if not exist dev mkdir dev
-if not exist dev\e mkdir dev\e
-if not exist dev\g mkdir dev\g
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\raw mkdir dev\raw
-if not exist dev\raw\log mkdir dev\raw\log
-if not exist dev\raw\fscache mkdir dev\raw\fscache
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
-for /R prop\defaults %%D in (*.*) do (
- if not exist dev\nvram\%%~nxD copy /y prop\defaults\%%~nxD dev\nvram
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
)
-modules\launcher -H 134217728 -B iidxhook9.dll bm2dx.dll --config iidxhook-30.conf %*
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
+cd /d %~dp0
+
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
+
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-30.xml --config %BEMANITOOLS_DIR%\iidxhook-30.conf %*
\ No newline at end of file
diff --git a/dist/iidx/launcher-18.xml b/dist/iidx/launcher-18.xml
new file mode 100644
index 00000000..74bf35e3
--- /dev/null
+++ b/dist/iidx/launcher-18.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 16777216
+ 16777216
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ bm2dx.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ iidxhook4.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/iidx/launcher-19.xml b/dist/iidx/launcher-19.xml
new file mode 100644
index 00000000..1749cfbd
--- /dev/null
+++ b/dist/iidx/launcher-19.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 16777216
+ 16777216
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ bm2dx.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ iidxhook5.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/iidx/launcher-20.xml b/dist/iidx/launcher-20.xml
new file mode 100644
index 00000000..7af7ce4f
--- /dev/null
+++ b/dist/iidx/launcher-20.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 16777216
+ 16777216
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ bm2dx.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ iidxhook6.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/iidx/launcher-21.xml b/dist/iidx/launcher-21.xml
new file mode 100644
index 00000000..502407b7
--- /dev/null
+++ b/dist/iidx/launcher-21.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 16777216
+ 16777216
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ bm2dx.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ iidxhook7.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/iidx/launcher-22.xml b/dist/iidx/launcher-22.xml
new file mode 100644
index 00000000..502407b7
--- /dev/null
+++ b/dist/iidx/launcher-22.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 16777216
+ 16777216
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ bm2dx.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ iidxhook7.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/iidx/launcher-23.xml b/dist/iidx/launcher-23.xml
new file mode 100644
index 00000000..502407b7
--- /dev/null
+++ b/dist/iidx/launcher-23.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 16777216
+ 16777216
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ bm2dx.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ iidxhook7.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/iidx/launcher-24.xml b/dist/iidx/launcher-24.xml
new file mode 100644
index 00000000..502407b7
--- /dev/null
+++ b/dist/iidx/launcher-24.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 16777216
+ 16777216
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ bm2dx.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ iidxhook7.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/iidx/launcher-25.xml b/dist/iidx/launcher-25.xml
new file mode 100644
index 00000000..733a8807
--- /dev/null
+++ b/dist/iidx/launcher-25.xml
@@ -0,0 +1,74 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 134217728
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ bm2dx.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ iidxhook8.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/iidx/launcher-26.xml b/dist/iidx/launcher-26.xml
new file mode 100644
index 00000000..733a8807
--- /dev/null
+++ b/dist/iidx/launcher-26.xml
@@ -0,0 +1,74 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 134217728
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ bm2dx.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ iidxhook8.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/iidx/launcher-27.xml b/dist/iidx/launcher-27.xml
new file mode 100644
index 00000000..736ee635
--- /dev/null
+++ b/dist/iidx/launcher-27.xml
@@ -0,0 +1,69 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 134217728
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ bm2dx.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+ boot
+
+
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+
+
+ iidxhook9.dll
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/iidx/launcher-28.xml b/dist/iidx/launcher-28.xml
new file mode 100644
index 00000000..736ee635
--- /dev/null
+++ b/dist/iidx/launcher-28.xml
@@ -0,0 +1,69 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 134217728
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ bm2dx.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+ boot
+
+
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+
+
+ iidxhook9.dll
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/iidx/launcher-29.xml b/dist/iidx/launcher-29.xml
new file mode 100644
index 00000000..736ee635
--- /dev/null
+++ b/dist/iidx/launcher-29.xml
@@ -0,0 +1,69 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 134217728
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ bm2dx.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+ boot
+
+
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+
+
+ iidxhook9.dll
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/iidx/launcher-30.xml b/dist/iidx/launcher-30.xml
new file mode 100644
index 00000000..736ee635
--- /dev/null
+++ b/dist/iidx/launcher-30.xml
@@ -0,0 +1,69 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 134217728
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ bm2dx.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+ boot
+
+
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+
+
+ iidxhook9.dll
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/iidx/pcbid.xml b/dist/iidx/pcbid.xml
new file mode 100644
index 00000000..bc50cdee
--- /dev/null
+++ b/dist/iidx/pcbid.xml
@@ -0,0 +1,7 @@
+
+
+
+ 0101020304050607083F
+ 0101020304050607083F
+
+
\ No newline at end of file
diff --git a/dist/jb/ea3-ident.xml b/dist/jb/ea3-ident.xml
new file mode 100644
index 00000000..e24a9b92
--- /dev/null
+++ b/dist/jb/ea3-ident.xml
@@ -0,0 +1,10 @@
+
+
+
+ LDJ
+ J
+ A
+ A
+ 2022082400
+
+
\ No newline at end of file
diff --git a/dist/jb/eamuse-server.xml b/dist/jb/eamuse-server.xml
new file mode 100644
index 00000000..bc706444
--- /dev/null
+++ b/dist/jb/eamuse-server.xml
@@ -0,0 +1,6 @@
+
+
+
+ http://localhost
+
+
\ No newline at end of file
diff --git a/dist/jb/gamestart-03.bat b/dist/jb/gamestart-03.bat
index 76acc782..39e1b8fd 100644
--- a/dist/jb/gamestart-03.bat
+++ b/dist/jb/gamestart-03.bat
@@ -1,11 +1,34 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\nvram\ea3-config.xml copy prop\ea3-config.xml dev\nvram\ea3-config.xml
-if not exist dev\nvram\coin.xml copy prop\defaults\coin.xml dev\nvram\coin.xml
-if not exist dev\nvram\eacoin.xml copy prop\defaults\eacoin.xml dev\nvram\eacoin.xml
-if not exist dev\raw mkdir dev\raw
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-launcher -H 33554432 -K jbhook2.dll jubeat.dll -v
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-03.xml -v %*
\ No newline at end of file
diff --git a/dist/jb/gamestart-04.bat b/dist/jb/gamestart-04.bat
index 245e314d..14d95e78 100644
--- a/dist/jb/gamestart-04.bat
+++ b/dist/jb/gamestart-04.bat
@@ -1,11 +1,34 @@
@echo off
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
cd /d %~dp0
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\nvram\ea3-config.xml copy prop\ea3-config.xml dev\nvram\ea3-config.xml
-if not exist dev\nvram\coin.xml copy prop\defaults\coin.xml dev\nvram\coin.xml
-if not exist dev\nvram\eacoin.xml copy prop\defaults\eacoin.xml dev\nvram\eacoin.xml
-if not exist dev\raw mkdir dev\raw
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
-launcher -H 33554432 -K jbhook3.dll jubeat.dll
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-04.xml %*
\ No newline at end of file
diff --git a/dist/jb/launcher-03.xml b/dist/jb/launcher-03.xml
new file mode 100644
index 00000000..095b2f62
--- /dev/null
+++ b/dist/jb/launcher-03.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 33554432
+ 33554432
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ jubeat.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ jbhook2.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/jb/launcher-04.xml b/dist/jb/launcher-04.xml
new file mode 100644
index 00000000..1c85a3c8
--- /dev/null
+++ b/dist/jb/launcher-04.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 33554432
+ 33554432
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ jubeat.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ jbhook3.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/jb/pcbid.xml b/dist/jb/pcbid.xml
new file mode 100644
index 00000000..bc50cdee
--- /dev/null
+++ b/dist/jb/pcbid.xml
@@ -0,0 +1,7 @@
+
+
+
+ 0101020304050607083F
+ 0101020304050607083F
+
+
\ No newline at end of file
diff --git a/dist/sdvx/ea3-ident.xml b/dist/sdvx/ea3-ident.xml
new file mode 100644
index 00000000..e24a9b92
--- /dev/null
+++ b/dist/sdvx/ea3-ident.xml
@@ -0,0 +1,10 @@
+
+
+
+ LDJ
+ J
+ A
+ A
+ 2022082400
+
+
\ No newline at end of file
diff --git a/dist/sdvx/eamuse-server.xml b/dist/sdvx/eamuse-server.xml
new file mode 100644
index 00000000..bc706444
--- /dev/null
+++ b/dist/sdvx/eamuse-server.xml
@@ -0,0 +1,6 @@
+
+
+
+ http://localhost
+
+
\ No newline at end of file
diff --git a/dist/sdvx/gamestart.bat b/dist/sdvx/gamestart.bat
index a286325c..4e97b924 100644
--- a/dist/sdvx/gamestart.bat
+++ b/dist/sdvx/gamestart.bat
@@ -8,3 +8,38 @@ if not exist dev\nvram\eacoin.xml copy prop\defaults\eacoin.xml dev\nvram\eacoin
if not exist dev\raw mkdir dev\raw
launcher -K sdvxhook.dll soundvoltex.dll %*
+
+@echo off
+
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
+
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
+)
+
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
+cd /d %~dp0
+
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
+
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher.xml %*
\ No newline at end of file
diff --git a/dist/sdvx/launcher.xml b/dist/sdvx/launcher.xml
new file mode 100644
index 00000000..4876ca76
--- /dev/null
+++ b/dist/sdvx/launcher.xml
@@ -0,0 +1,75 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 16777216
+ 16777216
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ soundvoltex.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ sdvxhook.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/sdvx/pcbid.xml b/dist/sdvx/pcbid.xml
new file mode 100644
index 00000000..bc50cdee
--- /dev/null
+++ b/dist/sdvx/pcbid.xml
@@ -0,0 +1,7 @@
+
+
+
+ 0101020304050607083F
+ 0101020304050607083F
+
+
\ No newline at end of file
diff --git a/dist/sdvx5/ea3-ident.xml b/dist/sdvx5/ea3-ident.xml
new file mode 100644
index 00000000..e24a9b92
--- /dev/null
+++ b/dist/sdvx5/ea3-ident.xml
@@ -0,0 +1,10 @@
+
+
+
+ LDJ
+ J
+ A
+ A
+ 2022082400
+
+
\ No newline at end of file
diff --git a/dist/sdvx5/eamuse-server.xml b/dist/sdvx5/eamuse-server.xml
new file mode 100644
index 00000000..bc706444
--- /dev/null
+++ b/dist/sdvx5/eamuse-server.xml
@@ -0,0 +1,6 @@
+
+
+
+ http://localhost
+
+
\ No newline at end of file
diff --git a/dist/sdvx5/gamestart-cn.bat b/dist/sdvx5/gamestart-cn.bat
index 8435bd73..265fce19 100644
--- a/dist/sdvx5/gamestart-cn.bat
+++ b/dist/sdvx5/gamestart-cn.bat
@@ -1,17 +1,34 @@
@echo off
-cd /d %~dp0
-if not exist dev mkdir dev
-if not exist dev\e mkdir dev\e
-if not exist dev\g mkdir dev\g
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\raw mkdir dev\raw
-if not exist dev\raw\c.dest echo $null >> dev\raw\c.dest
-if not exist dev\raw\log mkdir dev\raw\log
-if not exist dev\raw\fscache mkdir dev\raw\fscache
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
-for /R prop\defaults %%D in (*.*) do (
- if not exist dev\nvram\%%~nxD copy /y prop\defaults\%%~nxD dev\nvram
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
)
-launcher -H 268435456 -K sdvxhook2-cn.dll soundvoltex.dll --config sdvxhook2-cn.conf %*
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
+cd /d %~dp0
+
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
+
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher-cn.xml --config %BEMANITOOLS_DIR%\sdvxhook2-cn.conf %*
\ No newline at end of file
diff --git a/dist/sdvx5/gamestart.bat b/dist/sdvx5/gamestart.bat
index c1b41ddd..2db92894 100644
--- a/dist/sdvx5/gamestart.bat
+++ b/dist/sdvx5/gamestart.bat
@@ -1,16 +1,34 @@
@echo off
-cd /d %~dp0
-if not exist dev mkdir dev
-if not exist dev\e mkdir dev\e
-if not exist dev\g mkdir dev\g
-if not exist dev\nvram mkdir dev\nvram
-if not exist dev\raw mkdir dev\raw
-if not exist dev\raw\log mkdir dev\raw\log
-if not exist dev\raw\fscache mkdir dev\raw\fscache
+:: Game doesn't work properly when not run with administrator privileges
+>nul 2>&1 net session
-for /R prop\defaults %%D in (*.*) do (
- if not exist dev\nvram\%%~nxD copy /y prop\defaults\%%~nxD dev\nvram
+if %errorlevel% neq 0 (
+ echo This script requires administrative privileges.
+ echo Please run the script as an administrator.
+ pause
+ exit 1
)
-launcher -H 268435456 -K sdvxhook2.dll soundvoltex.dll --config sdvxhook2.conf %*
+:: Script expects to be located in a subfolder "bemanitools" in the root folder
+:: (contents/) next to the folders modules, data etc.
+cd /d %~dp0
+
+:: Script expects to be located in the root folder (contents/) next to the
+:: folders modules, data etc.
+set CONTENT_DIR=%CD%\..
+set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
+set MODULES_DIR=%CONTENT_DIR%\modules
+
+:: Keep that data vanilla, no need to copy these around anymore
+:: Just add them to the env PATH so launcher can find the libs and game executable
+:: Remark: This also requires admin privileges to propage correctly to launcher
+set PATH=^
+%MODULES_DIR%;^
+%BEMANITOOLS_DIR%;^
+%PATH%
+
+:: Current working dir is the game's root folder
+cd /d %CONTENT_DIR%
+
+%BEMANITOOLS_DIR%\launcher %BEMANITOOLS_DIR%\launcher.xml --config %BEMANITOOLS_DIR%\sdvxhook2.conf %*
\ No newline at end of file
diff --git a/dist/sdvx5/launcher-cn.xml b/dist/sdvx5/launcher-cn.xml
new file mode 100644
index 00000000..4ec2939f
--- /dev/null
+++ b/dist/sdvx5/launcher-cn.xml
@@ -0,0 +1,74 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 268435456
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ soundvoltex.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ sdvxhook2-cn.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/sdvx5/launcher.xml b/dist/sdvx5/launcher.xml
new file mode 100644
index 00000000..3ae97c1e
--- /dev/null
+++ b/dist/sdvx5/launcher.xml
@@ -0,0 +1,74 @@
+
+
+
+ bemanitools_local_fs
+
+
+
+
+
+
+
+
+
+
+ prop/avs-config.xml
+ 268435456
+
+
+ info
+
+
+ /dev/nvram/ea3-config.xml
+
+
+ soundvoltex.dll
+
+
+
+
+
+
+
+
+ bemanitools/ea3-ident.xml
+ bemanitools/ea3-license.xml
+
+
+
+
+
+
+ .
+
+
+ dev/nvram
+ fs
+
+
+
+ dev/raw
+ fs
+
+
+
+
+
+
+
+ bemanitools/ea3-service.xml
+
+
+
+ sdvxhook2.dll
+
+
+
+
+
+
+
+ 0
+ 0
+
+
\ No newline at end of file
diff --git a/dist/sdvx5/pcbid.xml b/dist/sdvx5/pcbid.xml
new file mode 100644
index 00000000..bc50cdee
--- /dev/null
+++ b/dist/sdvx5/pcbid.xml
@@ -0,0 +1,7 @@
+
+
+
+ 0101020304050607083F
+ 0101020304050607083F
+
+
\ No newline at end of file
diff --git a/dist/shared/ea3-ident.xml b/dist/shared/ea3-ident.xml
new file mode 100644
index 00000000..ae4161ef
--- /dev/null
+++ b/dist/shared/ea3-ident.xml
@@ -0,0 +1,11 @@
+
+
+
+
+ 000
+ A
+ A
+ A
+ 1969032100
+
+
\ No newline at end of file
diff --git a/dist/shared/ea3-license.xml b/dist/shared/ea3-license.xml
new file mode 100644
index 00000000..fef35346
--- /dev/null
+++ b/dist/shared/ea3-license.xml
@@ -0,0 +1,8 @@
+
+
+
+
+ 0101020304050607083F
+ 0101020304050607083F
+
+
\ No newline at end of file
diff --git a/dist/shared/ea3-service.xml b/dist/shared/ea3-service.xml
new file mode 100644
index 00000000..ffaaa437
--- /dev/null
+++ b/dist/shared/ea3-service.xml
@@ -0,0 +1,7 @@
+
+
+
+
+ http://localhost
+
+
\ No newline at end of file
diff --git a/doc/ddrhook/ddrhook2.md b/doc/ddrhook/ddrhook2.md
index 38c0f44d..0cfddcbe 100644
--- a/doc/ddrhook/ddrhook2.md
+++ b/doc/ddrhook/ddrhook2.md
@@ -9,6 +9,8 @@ The following games are supported by this hook library:
* Dance Dance Revolution 2013
* Dance Dance Revolution 2014
* Dance Dance Revolution A
+* Dance Dance Revolution A20
+* Dance Dance Revolution A20+
Note that different builds of the same hook library are required to run the
different versions. See different distribution packages, e.g. `ddr-12.zip`,
diff --git a/src/api/log.h b/src/api/log.h
new file mode 100644
index 00000000..638a269a
--- /dev/null
+++ b/src/api/log.h
@@ -0,0 +1,31 @@
+#ifndef BEMANITOOLS_API_THREAD_H
+#define BEMANITOOLS_API_THREAD_H
+
+#include
+
+#ifdef __GNUC__
+/* Bemanitools is compiled with GCC (MinGW, specifically) as of version 5 */
+#define LOG_CHECK_FMT __attribute__((format(printf, 2, 3)))
+#else
+/* Compile it out for MSVC plebs */
+#define LOG_CHECK_FMT
+#endif
+
+/* An AVS-style logger function. Comes in four flavors: misc, info, warning,
+ and fatal, with increasing severity. Fatal loggers do not return, they
+ abort the running process after writing their message to the log.
+
+ "module" is an arbitrary short string identifying the source of the log
+ message. The name of the calling DLL is a good default choice for this
+ string, although you might want to identify a module within your DLL here
+ instead.
+
+ "fmt" is a printf-style format string. Depending on the context in which
+ your DLL is running you might end up calling a logger function exported
+ from libavs, which has its own printf implementation (including a number of
+ proprietary extensions), so don't use any overly exotic formats. */
+
+typedef void (*btapi_log_formatter_t)(const char *module, const char *fmt, ...)
+ LOG_CHECK_FMT;
+
+#endif
diff --git a/src/api/thread.h b/src/api/thread.h
new file mode 100644
index 00000000..0459c9d1
--- /dev/null
+++ b/src/api/thread.h
@@ -0,0 +1,20 @@
+#ifndef BEMANITOOLS_API_THREAD_H
+#define BEMANITOOLS_API_THREAD_H
+
+#include
+
+/* An API for spawning threads. This API is defined by libavs, although
+ Bemanitools itself may supply compatible implementations of these functions
+ to your DLL, depending on the context in which it runs.
+
+ NOTE: You may only use the logging functions from a thread where Bemanitools
+ calls you, or a thread that you create using this API. Failure to observe
+ this restriction will cause the process to crash. This is a limitation of
+ libavs itself, not Bemanitools. */
+
+typedef int (*btapi_thread_create_t)(
+ int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority);
+typedef void (*btapi_thread_join_t)(int thread_id, int *result);
+typedef void (*btapi_thread_destroy_t)(int thread_id);
+
+#endif
diff --git a/src/imports/avs.h b/src/imports/avs.h
index ff48a33e..9dce5beb 100644
--- a/src/imports/avs.h
+++ b/src/imports/avs.h
@@ -4,6 +4,7 @@
#include
#include
#include
+#include
enum property_create_flag {
PROPERTY_FLAG_READ = 0x1,
@@ -26,18 +27,39 @@ enum property_node_traversal {
};
enum property_type {
- PROPERTY_TYPE_VOID = 1,
- PROPERTY_TYPE_S8 = 2,
- PROPERTY_TYPE_U8 = 3,
- PROPERTY_TYPE_S16 = 4,
- PROPERTY_TYPE_U16 = 5,
- PROPERTY_TYPE_S32 = 6,
- PROPERTY_TYPE_U32 = 7,
- PROPERTY_TYPE_S64 = 8,
- PROPERTY_TYPE_U64 = 9,
- PROPERTY_TYPE_BIN = 10,
- PROPERTY_TYPE_STR = 11,
- PROPERTY_TYPE_BOOL = 52
+ PROPERTY_TYPE_VOID = 0x01,
+ PROPERTY_TYPE_S8 = 0x02,
+ PROPERTY_TYPE_U8 = 0x03,
+ PROPERTY_TYPE_S16 = 0x04,
+ PROPERTY_TYPE_U16 = 0x05,
+ PROPERTY_TYPE_S32 = 0x06,
+ PROPERTY_TYPE_U32 = 0x07,
+ PROPERTY_TYPE_S64 = 0x08,
+ PROPERTY_TYPE_U64 = 0x09,
+ PROPERTY_TYPE_BIN = 0x0A,
+ PROPERTY_TYPE_STR = 0x0B,
+ PROPERTY_TYPE_IP4 = 0x0C,
+ PROPERTY_TYPE_TIME = 0x0D,
+ PROPERTY_TYPE_FLOAT = 0x0E,
+ PROPERTY_TYPE_DOUBLE = 0x0F,
+ PROPERTY_TYPE_4U8 = 0x25,
+ PROPERTY_TYPE_ATTR = 0x2E,
+ PROPERTY_TYPE_BOOL = 0x34,
+
+ // Missing __type attribute
+ PROPERTY_TYPE_VOID_WITH_ATTRIBUTES = 0x40 | PROPERTY_TYPE_VOID,
+ PROPERTY_TYPE_ARRAY_S8 = 0x40 | PROPERTY_TYPE_S8,
+ PROPERTY_TYPE_ARRAY_U8 = 0x40 | PROPERTY_TYPE_U8,
+ PROPERTY_TYPE_ARRAY_S16 = 0x40 | PROPERTY_TYPE_S16,
+ PROPERTY_TYPE_ARRAY_U16 = 0x40 | PROPERTY_TYPE_U16,
+ PROPERTY_TYPE_ARRAY_S32 = 0x40 | PROPERTY_TYPE_S32,
+ PROPERTY_TYPE_ARRAY_U32 = 0x40 | PROPERTY_TYPE_U32,
+ PROPERTY_TYPE_ARRAY_S64 = 0x40 | PROPERTY_TYPE_S64,
+ PROPERTY_TYPE_ARRAY_U64 = 0x40 | PROPERTY_TYPE_U64,
+ PROPERTY_TYPE_ARRAY_TIME = 0x40 | PROPERTY_TYPE_TIME,
+ PROPERTY_TYPE_ARRAY_BOOL = 0x40 | PROPERTY_TYPE_BOOL,
+
+ PROPERTY_TYPE_STR_WITH_ATTRIBUTES = 0x40 | PROPERTY_TYPE_STR,
};
struct property;
@@ -66,6 +88,7 @@ enum psmap_type {
PSMAP_TYPE_STR = 10,
PSMAP_TYPE_ATTR = 45,
PSMAP_TYPE_BOOL = 50,
+ PSMAP_TYPE_TERMINATOR = 0xFF,
};
#define PSMAP_FLAG_HAVE_DEFAULT 0x01
@@ -102,7 +125,7 @@ struct property_psmap {
#define PSMAP_END \
{ \
- 0xFF, 0, 0, 0, NULL, 0 \
+ PSMAP_TYPE_TERMINATOR, 0, 0, 0, NULL, 0 \
} \
} \
;
@@ -160,6 +183,11 @@ void avs_boot(
void avs_shutdown(void);
+typedef uint32_t avs_desc;
+typedef int avs_error;
+
+#define AVS_IS_ERROR(x) x < 0
+
void log_body_fatal(const char *module, const char *fmt, ...);
void log_body_info(const char *module, const char *fmt, ...);
void log_body_misc(const char *module, const char *fmt, ...);
@@ -187,10 +215,14 @@ int property_insert_read(
uint32_t context);
int property_mem_write(struct property *prop, void *bytes, int nbytes);
void *property_desc_to_buffer(struct property *prop);
+avs_error property_query_size(struct property *prop);
void property_file_write(struct property *prop, const char *path);
int property_set_flag(struct property *prop, int flags, int mask);
void property_destroy(struct property *prop);
+avs_error property_get_error(struct property *prop);
+struct property *property_clear_error(struct property *prop);
+
int property_psmap_import(
struct property *prop,
struct property_node *root,
@@ -203,8 +235,8 @@ int property_psmap_export(
const struct property_psmap *psmap);
struct property_node *property_node_clone(
- struct property *new_parent,
- int unk0,
+ struct property *parent_prop,
+ struct property_node *parent_node,
struct property_node *src,
bool deep);
struct property_node *property_node_create(
@@ -226,15 +258,73 @@ void property_node_remove(struct property_node *node);
enum property_type property_node_type(struct property_node *node);
struct property_node *property_node_traversal(
struct property_node *node, enum property_node_traversal direction);
-void property_node_datasize(struct property_node *node);
+int property_node_datasize(struct property_node *node);
+avs_error property_node_read(struct property_node *node, enum property_type type, void* data, uint32_t data_size);
+
+static inline void property_remove(struct property *prop, struct property_node *node, const char *path)
+{
+ struct property_node *cur = property_search(prop, node, path);
+ while (cur) {
+ struct property_node *next = property_node_traversal(node, TRAVERSE_NEXT_SEARCH_RESULT);
+ property_node_remove(cur);
+ cur = next;
+ }
+}
bool std_getenv(const char *key, char *val, uint32_t nbytes);
void std_setenv(const char *key, const char *val);
-void* avs_fs_open(const char* path, int mode, int flags);
+struct avs_stat {
+ uint64_t st_atime;
+ uint64_t st_mtime;
+ uint64_t st_ctime;
+ uint32_t unk1;
+ uint32_t filesize;
+ struct stat padding;
+};
+
+#if AVS_VERSION <= 1306
+enum avs_file_mode {
+ AVS_FILE_READ = 0x00,
+ AVS_FILE_WRITE = 0x01,
+ AVS_FILE_READ_WRITE = 0x02,
+ AVS_FILE_CREATE = 0x10,
+ AVS_FILE_TRUNCATE = 0x20,
+ AVS_FILE_EXCLUSIVE = 0x80,
+};
+#else
+enum avs_file_mode {
+ AVS_FILE_READ = 0x01,
+ AVS_FILE_WRITE = 0x02,
+ AVS_FILE_CREATE = 0x10,
+ AVS_FILE_TRUNCATE = 0x20,
+ AVS_FILE_EXCLUSIVE = 0x80,
+};
+#endif
+
+enum avs_file_flag {
+ AVS_FILE_FLAG_SHARE_READ = 0x124,
+ AVS_FILE_FLAG_SHARE_WRITE = 0x92,
+};
+
+enum avs_seek_origin {
+ AVS_SEEK_SET = 0,
+ AVS_SEEK_CUR = 1,
+ AVS_SEEK_END = 2,
+};
+
+avs_desc avs_fs_open(const char *path, uint16_t mode, int flags);
+int avs_fs_close(avs_desc desc);
+size_t avs_fs_read(avs_desc desc, char *buf, uint32_t sz);
+int avs_fs_lseek(avs_desc desc, long pos, int whence);
+int avs_fs_lstat(const char *path, struct avs_stat *st);
+int avs_fs_copy(const char *src, const char *dest);
int avs_fs_addfs(void *filesys_struct);
int avs_fs_mount(
const char *mountpoint, const char *fsroot, const char *fstype, void *data);
+avs_desc avs_fs_opendir(const char *path);
+const char* avs_fs_readdir(avs_desc dir);
+void avs_fs_closedir(avs_desc dir);
bool avs_is_active();
diff --git a/src/imports/dwarfstack.h b/src/imports/dwarfstack.h
new file mode 100644
index 00000000..ba2d23c6
--- /dev/null
+++ b/src/imports/dwarfstack.h
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2013-2019 Hannes Domani
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#ifndef __DWARFSTACK_H__
+#define __DWARFSTACK_H__
+
+#include
+
+
+#if defined(DWST_STATIC)
+#define EXPORT
+#elif defined(DWST_SHARED)
+#define EXPORT __declspec(dllexport)
+#else
+#define EXPORT __declspec(dllimport)
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+// dwstCallback(): callback function
+// addr: stack address
+// filename: source file location
+// lineno: line number
+// funcname: function name
+// context: user-provided pointer (callbackContext)
+// columnno: column number
+typedef void dwstCallback(
+ uint64_t addr,const char *filename,int lineno,const char *funcname,
+ void *context,int columnno );
+
+typedef void dwstCallbackW(
+ uint64_t addr,const wchar_t *filename,int lineno,const char *funcname,
+ void *context,int columnno );
+
+// special values for lineno:
+
+// DWST_BASE_ADDR: inform about the used image base address
+// (important in case it's not the same as the preferred image base address)
+// addr: used image base address
+// filename: executable location
+#define DWST_BASE_ADDR 0
+
+// DWST_NO_DBG_SYM: no debug information available
+// addr: stack address
+// filename: executable location
+#define DWST_NO_DBG_SYM -1
+
+// DWST_NO_SRC_FILE: no source file information available
+// addr: stack address
+// filename: executable location
+#define DWST_NO_SRC_FILE -2
+
+// DWST_NOT_FOUND: no information available (invalid address?)
+// addr: stack address
+// filename: executable location
+#define DWST_NOT_FOUND -3
+
+
+// dwstOfFile(): stack information of file
+// name: executable location
+// imageBase: used image base address
+// addr: stack addresses
+// count: number of addresses
+// callbackFunc: callback function
+// callbackContext: user-provided pointer (context)
+// (for example see examples/addr2line/)
+EXPORT int dwstOfFile(
+ const char *name,uint64_t imageBase,
+ uint64_t *addr,int count,
+ dwstCallback *callbackFunc,void *callbackContext );
+
+EXPORT int dwstOfFileW(
+ const wchar_t *name,uint64_t imageBase,
+ uint64_t *addr,int count,
+ dwstCallbackW *callbackFunc,void *callbackContext );
+
+
+// dwstOfProcess(): stack information of current process
+// addr: stack addresses
+// count: number of addresses
+// callbackFunc: callback function
+// callbackContext: user-provided pointer (context)
+EXPORT int dwstOfProcess(
+ uintptr_t *addr,int count,
+ dwstCallback *callbackFunc,void *callbackContext );
+
+EXPORT int dwstOfProcessW(
+ uintptr_t *addr,int count,
+ dwstCallbackW *callbackFunc,void *callbackContext );
+
+
+// dwstOfLocation(): stack information of current location
+// callbackFunc: callback function
+// callbackContext: user-provided pointer (context)
+// (for example see examples/location/)
+EXPORT int dwstOfLocation(
+ dwstCallback *callbackFunc,void *callbackContext );
+
+EXPORT int dwstOfLocationW(
+ dwstCallbackW *callbackFunc,void *callbackContext );
+
+
+// dwstOfException(): stack information of exception
+// context: ContextRecord of exception
+// callbackFunc: callback function
+// callbackContext: user-provided pointer (context)
+// (for example see examples/exception/)
+EXPORT int dwstOfException(
+ void *context,
+ dwstCallback *callbackFunc,void *callbackContext );
+
+EXPORT int dwstOfExceptionW(
+ void *context,
+ dwstCallbackW *callbackFunc,void *callbackContext );
+
+
+// dwstExceptionDialog(): show dialog on unhandled exception
+// extraInfo: extra information shown in dialog
+// (for example see examples/exception-dialog/)
+EXPORT void dwstExceptionDialog(
+ const char *extraInfo );
+
+EXPORT void dwstExceptionDialogW(
+ const wchar_t *extraInfo );
+
+
+#ifndef DWST_STATIC
+// dwstDemangle(): demangle gcc style c++ symbols
+// mangled: mangled name
+// demangled: demangled name
+// length: size of demangled buffer
+EXPORT size_t dwstDemangle(
+ const char *mangled,
+ char *demangled,size_t length );
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/imports/import_32_0_avs.def b/src/imports/import_32_0_avs.def
index cb2ea9d1..9632ecb4 100644
--- a/src/imports/import_32_0_avs.def
+++ b/src/imports/import_32_0_avs.def
@@ -2,6 +2,12 @@ LIBRARY libavs-win32
EXPORTS
avs_boot
+ avs_fs_close
+ avs_fs_copy
+ avs_fs_lseek
+ avs_fs_lstat
+ avs_fs_open
+ avs_fs_read
avs_net_ctrl
avs_shutdown
avs_thread_create
@@ -19,6 +25,8 @@ EXPORTS
property_destroy
property_file_write
property_insert_read
+ property_clear_error
+ property_get_error
property_mem_write
property_read_query_memsize
property_search
@@ -26,6 +34,7 @@ EXPORTS
property_node_clone
property_node_create
property_node_name
+ property_node_read
property_node_refer
property_node_remove
property_node_type
diff --git a/src/imports/import_32_1002_avs.def b/src/imports/import_32_1002_avs.def
index 6d1fd136..cc4ee29c 100644
--- a/src/imports/import_32_1002_avs.def
+++ b/src/imports/import_32_1002_avs.def
@@ -2,6 +2,15 @@ LIBRARY libavs-win32
EXPORTS
avs_boot
+ avs_fs_close
+ avs_fs_copy
+ avs_fs_lseek
+ avs_fs_lstat
+ avs_fs_open
+ avs_fs_read
+ avs_fs_opendir
+ avs_fs_readdir
+ avs_fs_closedir
avs_net_ctrl
avs_shutdown
avs_thread_create
@@ -19,6 +28,8 @@ EXPORTS
property_destroy
property_file_write
property_insert_read
+ property_clear_error
+ property_get_error
property_mem_write
property_read_query_memsize
property_search
@@ -27,11 +38,13 @@ EXPORTS
property_node_create
property_node_datasize
property_node_name
+ property_node_read
property_node_refer
property_node_remove
property_node_type
property_node_traversal
property_node_refdata
+ property_query_size
property_psmap_export
property_psmap_import
std_getenv
diff --git a/src/imports/import_32_1101_avs.def b/src/imports/import_32_1101_avs.def
index cfc6f9b5..776dc712 100644
--- a/src/imports/import_32_1101_avs.def
+++ b/src/imports/import_32_1101_avs.def
@@ -2,6 +2,15 @@ LIBRARY libavs-win32
EXPORTS
avs_boot @22 NONAME
+ avs_fs_close @60 NONAME
+ avs_fs_copy @63 NONAME
+ avs_fs_lseek @70 NONAME
+ avs_fs_lstat @71 NONAME
+ avs_fs_open @75 NONAME
+ avs_fs_read @77 NONAME
+ avs_fs_opendir @76 NONAME
+ avs_fs_readdir @78 NONAME
+ avs_fs_closedir @61 NONAME
avs_net_ctrl @107 NONAME
avs_shutdown @140 NONAME
avs_thread_create @156 NONAME
@@ -17,10 +26,19 @@ EXPORTS
property_desc_to_buffer @246 NONAME
property_destroy @247 NONAME
property_insert_read @255 NONAME
+ property_clear_error @573 NONAME
+ property_get_error @573 NONAME
property_node_create @266 NONAME
property_node_datasize @267 NONAME
+ property_node_name @274 NONAME
+ property_node_read @276 NONAME
property_node_refer @278 NONAME
property_node_remove @279 NONAME
+ property_node_type @282 NONAME
+ property_node_clone @280 NONAME
+ property_node_traversal @282 NONAME
+ property_node_refdata @277 NONAME
+ property_query_size @290 NONAME
property_psmap_import @288 NONAME
property_psmap_export @287 NONAME
property_read_query_memsize @291 NONAME
diff --git a/src/imports/import_32_1304_avs.def b/src/imports/import_32_1304_avs.def
index 489944a7..18dad23a 100644
--- a/src/imports/import_32_1304_avs.def
+++ b/src/imports/import_32_1304_avs.def
@@ -2,7 +2,15 @@ LIBRARY libavs-win32
EXPORTS
avs_boot @237 NONAME
+ avs_fs_close @276 NONAME
+ avs_fs_copy @283 NONAME
+ avs_fs_lseek @16 NONAME
+ avs_fs_lstat @97 NONAME
avs_fs_open @178 NONAME
+ avs_fs_read @306 NONAME
+ avs_fs_opendir @216 NONAME
+ avs_fs_readdir @130 NONAME
+ avs_fs_closedir @131 NONAME
avs_net_ctrl @15 NONAME
avs_shutdown @333 NONAME
avs_thread_create @183 NONAME
@@ -17,10 +25,19 @@ EXPORTS
property_desc_to_buffer @201 NONAME
property_destroy @264 NONAME
property_insert_read @23 NONAME
+ property_clear_error @573 NONAME
+ property_get_error @573 NONAME
property_node_create @316 NONAME
property_node_datasize @249 NONAME
+ property_node_name @255 NONAME
+ property_node_read @2 NONAME
property_node_refer @268 NONAME
property_node_remove @129 NONAME
+ property_node_type @329 NONAME
+ property_node_clone @130 NONAME
+ property_node_traversal @93 NONAME
+ property_node_refdata @330 NONAME == XC058ba5000151
+ property_query_size @250 NONAME == XC058ba5000101
property_psmap_import @102 NONAME
property_psmap_export @110 NONAME
property_read_query_memsize @100 NONAME
diff --git a/src/imports/import_32_1306_avs-ea3.def b/src/imports/import_32_1306_avs-ea3.def
new file mode 100644
index 00000000..2606209e
--- /dev/null
+++ b/src/imports/import_32_1306_avs-ea3.def
@@ -0,0 +1,5 @@
+LIBRARY libavs-win32-ea3
+
+EXPORTS
+ ea3_boot @94 NONAME
+ ea3_shutdown @97 NONAME
diff --git a/src/imports/import_32_1306_avs.def b/src/imports/import_32_1306_avs.def
new file mode 100644
index 00000000..f6deed72
--- /dev/null
+++ b/src/imports/import_32_1306_avs.def
@@ -0,0 +1,46 @@
+LIBRARY libavs-win32
+
+EXPORTS
+ avs_boot @237 NONAME == XC058ba50000f4
+ avs_fs_close @276 NONAME == XC058ba500011b
+ avs_fs_copy @283 NONAME == XC058ba5000122
+ avs_fs_lseek @16 NONAME == XC058ba500000f
+ avs_fs_lstat @97 NONAME == XC058ba5000063
+ avs_fs_open @178 NONAME == XC058ba50000b6
+ avs_fs_read @306 NONAME == XC058ba5000139
+ avs_fs_opendir @216 NONAME == XC058ba50000dd
+ avs_fs_readdir @130 NONAME == XC058ba5000086
+ avs_fs_closedir @131 NONAME == XC058ba5000087
+ avs_net_ctrl @15 NONAME == XC058ba500000e
+ avs_shutdown @333 NONAME == XC058ba5000154
+ avs_thread_create @183 NONAME == XC058ba50000bb
+ avs_thread_destroy @76 NONAME == XC058ba500004e
+ avs_thread_exit @147 NONAME == XC058ba5000097
+ avs_thread_join @92 NONAME == XC058ba500005e
+ log_body_misc @44 NONAME == XC058ba500002d
+ log_body_info @339 NONAME == XC058ba500015a
+ log_body_warning @219 NONAME == XC058ba50000e1
+ log_body_fatal @128 NONAME == XC058ba5000084
+ property_create @256 NONAME == XC058ba5000107
+ property_desc_to_buffer @201 NONAME == XC058ba50000cd
+ property_destroy @264 NONAME == XC058ba500010f
+ property_insert_read @23 NONAME == XC058ba5000016
+ property_clear_error @573 NONAME
+ property_get_error @573 NONAME
+ property_node_create @316 NONAME == XC058ba5000143
+ property_node_datasize @249 NONAME == XC058ba5000100
+ property_node_name @255 NONAME == XC058ba5000106
+ property_node_read @2 NONAME == XC058ba5000001
+ property_node_refer @268 NONAME == XC058ba5000113
+ property_node_remove @129 NONAME == XC058ba5000085
+ property_node_type @329 NONAME == XC058ba5000150
+ property_node_clone @252 NONAME == XC058ba5000103
+ property_node_traversal @93 NONAME == XC058ba500005f
+ property_node_refdata @330 NONAME == XC058ba5000151
+ property_query_size @250 NONAME == XC058ba5000101
+ property_psmap_import @102 NONAME == XC058ba5000068
+ property_psmap_export @110 NONAME == XC058ba5000071
+ property_read_query_memsize @100 NONAME == XC058ba5000066
+ property_search @244 NONAME == XC058ba50000fb
+ std_getenv @226 NONAME == XC058ba50000e8
+ std_setenv @114 NONAME == XC058ba5000075
diff --git a/src/imports/import_32_1403_avs.def b/src/imports/import_32_1403_avs.def
index 32d68b11..716d0817 100644
--- a/src/imports/import_32_1403_avs.def
+++ b/src/imports/import_32_1403_avs.def
@@ -2,6 +2,15 @@ LIBRARY libavs-win32
EXPORTS
avs_boot @298 NONAME
+ avs_fs_close @573 NONAME == XC0bbe97000119
+ avs_fs_copy @573 NONAME == XC0bbe97000120
+ avs_fs_lseek @573 NONAME ==
+ avs_fs_lstat @573 NONAME == XC0bbe9700005f
+ avs_fs_open @573 NONAME == XC0bbe970000b3
+ avs_fs_read @573 NONAME ==
+ avs_fs_opendir @573 NONAME == XC0bbe970000db
+ avs_fs_readdir @573 NONAME ==
+ avs_fs_closedir @573 NONAME ==
avs_net_ctrl @100 NONAME
avs_shutdown @299 NONAME
avs_thread_create @6 NONAME
@@ -15,7 +24,16 @@ EXPORTS
property_desc_to_buffer @131 NONAME
property_destroy @130 NONAME
property_insert_read @133 NONAME
+ property_clear_error @573 NONAME
+ property_get_error @573 NONAME
+ property_node_name @573 NONAME ==
+ property_node_read @573 NONAME ==
property_node_remove @148 NONAME
+ property_node_type @573 NONAME ==
+ property_node_clone @149 NONAME
+ property_node_traversal @151 NONAME
+ property_node_refdata @573 NONAME ==
+ property_query_size @573 NONAME ==
property_psmap_import @163 NONAME
property_psmap_export @164 NONAME
property_read_query_memsize @161 NONAME
diff --git a/src/imports/import_32_1508_avs.def b/src/imports/import_32_1508_avs.def
index 05419ed7..504a303f 100644
--- a/src/imports/import_32_1508_avs.def
+++ b/src/imports/import_32_1508_avs.def
@@ -5,8 +5,13 @@ EXPORTS
avs_fs_close @65 NONAME
avs_fs_lseek @59 NONAME
avs_fs_lseek64 @60 NONAME
+ avs_fs_lstat @79 NONAME
avs_fs_open @58 NONAME
avs_fs_read @61 NONAME
+ avs_fs_copy @81 NONAME
+ avs_fs_opendir @72 NONAME == XCd229cc0000f0
+ avs_fs_readdir @73 NONAME == XCd229cc0000bb
+ avs_fs_closedir @74 NONAME == XCd229cc0000b8
avs_net_ctrl @98 NONAME
avs_shutdown @286 NONAME
avs_thread_create @6 NONAME
@@ -21,9 +26,19 @@ EXPORTS
property_desc_to_buffer @129 NONAME
property_destroy @128 NONAME
property_insert_read @131 NONAME
+ property_clear_error @573 NONAME
+ property_get_error @573 NONAME
property_node_create @145 NONAME
+ property_node_name @150 NONAME
+ property_node_read @154 NONAME == XCd229cc0000f3
property_node_refer @158 NONAME
property_node_remove @146 NONAME
+ property_node_type @151 NONAME == XCd229cc000071
+ property_node_clone @147 NONAME
+ property_node_traversal @149 NONAME
+ property_node_refdata @148 NONAME == XCd229cc00009f
+ property_node_datasize @153 NONAME == XCd229cc000083
+ property_query_size @142 NONAME == XCd229cc000032
property_psmap_export @162 NONAME
property_psmap_import @161 NONAME
property_read_query_memsize @159 NONAME
diff --git a/src/imports/import_32_1601_avs.def b/src/imports/import_32_1601_avs.def
index e260a8c6..286806bf 100644
--- a/src/imports/import_32_1601_avs.def
+++ b/src/imports/import_32_1601_avs.def
@@ -1,6 +1,15 @@
LIBRARY libavs-win32
EXPORTS
+ avs_fs_close @65 NONAME
+ avs_fs_copy @81 NONAME
+ avs_fs_lseek @59 NONAME
+ avs_fs_lstat @79 NONAME
+ avs_fs_open @58 NONAME
+ avs_fs_read @61 NONAME
+ avs_fs_opendir @72 NONAME == XCnbrep7000047
+ avs_fs_readdir @73 NONAME == XCnbrep7000048
+ avs_fs_closedir @74 NONAME == XCnbrep7000049
avs_thread_create @5 NONAME
avs_thread_destroy @7 NONAME
avs_thread_exit @11 NONAME
@@ -10,9 +19,19 @@ EXPORTS
property_destroy @125 NONAME
property_desc_to_buffer @126 NONAME
property_insert_read @128 NONAME
+ property_clear_error @573 NONAME
+ property_get_error @573 NONAME
property_search @141 NONAME
property_node_create @142 NONAME
+ property_node_name @147 NONAME == XCnbrep7000092
property_node_remove @143 NONAME
+ property_node_type @148 NONAME == XCnbrep7000093
+ property_node_clone @144 NONAME
+ property_node_traversal @146 NONAME
+ property_node_refdata @145 NONAME == XCnbrep7000090
+ property_node_datasize @150 NONAME == XCnbrep7000095
+ property_node_read @151 NONAME == XCnbrep7000096
+ property_query_size @139 NONAME == XCnbrep700008a
property_node_refer @155 NONAME
property_read_query_memsize @156 NONAME
property_psmap_export @159 NONAME
diff --git a/src/imports/import_32_1603_avs.def b/src/imports/import_32_1603_avs.def
index 98f5fe7a..93fd07d2 100644
--- a/src/imports/import_32_1603_avs.def
+++ b/src/imports/import_32_1603_avs.def
@@ -1,6 +1,15 @@
LIBRARY libavs-win32
EXPORTS
+ avs_fs_close @86 NONAME == XCnbrep7000055
+ avs_fs_copy @102 NONAME == XCnbrep7000065
+ avs_fs_lseek @80 NONAME == XCnbrep700004f
+ avs_fs_lstat @100 NONAME == XCnbrep7000063
+ avs_fs_open @79 NONAME == XCnbrep700004e
+ avs_fs_read @82 NONAME == XCnbrep7000051
+ avs_fs_opendir @93 NONAME == XCnbrep700005c
+ avs_fs_readdir @94 NONAME == XCnbrep700005d
+ avs_fs_closedir @95 NONAME == XCnbrep700005e
avs_thread_create @5 NONAME
avs_thread_destroy @7 NONAME
avs_thread_exit @11 NONAME
@@ -10,9 +19,19 @@ EXPORTS
property_destroy @146 NONAME
property_desc_to_buffer @147 NONAME
property_insert_read @149 NONAME
+ property_clear_error @158 NONAME == XCnbrep700009d
+ property_get_error @159 NONAME == XCnbrep700009e
property_search @162 NONAME
property_node_create @163 NONAME
+ property_node_name @168 NONAME == XCnbrep70000a7
property_node_remove @164 NONAME
+ property_node_type @169 NONAME == XCnbrep70000a8
+ property_node_clone @165 NONAME
+ property_node_traversal @167 NONAME
+ property_node_refdata @166 NONAME == XCnbrep70000a5
+ property_node_datasize @171 NONAME == XCnbrep70000aa
+ property_query_size @160 NONAME == XCnbrep700009f
+ property_node_read @172 NONAME == XCnbrep70000ab
property_node_refer @176 NONAME
property_read_query_memsize @177 NONAME
property_psmap_import @179 NONAME
diff --git a/src/imports/import_32_1700_avs.def b/src/imports/import_32_1700_avs.def
index d8944d9b..f01bc391 100644
--- a/src/imports/import_32_1700_avs.def
+++ b/src/imports/import_32_1700_avs.def
@@ -6,15 +6,34 @@ EXPORTS
avs_thread_exit @11 NONAME
avs_thread_join @12 NONAME
avs_fs_addfs @73 NONAME
+ avs_fs_close @86 NONAME == XCgsqzn0000055
+ avs_fs_copy @102 NONAME == XCgsqzn0000065
+ avs_fs_lseek @80 NONAME == XCgsqzn000004f
+ avs_fs_lstat @100 NONAME == XCgsqzn0000063
avs_fs_mount @76 NONAME
+ avs_fs_open @79 NONAME == XCgsqzn000004e
+ avs_fs_read @82 NONAME == XCgsqzn0000051
+ avs_fs_opendir @93 NONAME == XCgsqzn000005c
+ avs_fs_readdir @94 NONAME == XCgsqzn000005d
+ avs_fs_closedir @95 NONAME == XCgsqzn000005e
avs_net_ctrl @119 NONAME
property_create @145 NONAME
property_destroy @146 NONAME
property_desc_to_buffer @147 NONAME
property_insert_read @149 NONAME
+ property_clear_error @158 NONAME == XCgsqzn000009d
+ property_get_error @159 NONAME == XCgsqzn000009e
property_search @162 NONAME
property_node_create @163 NONAME
+ property_node_name @168 NONAME == XCgsqzn00000a7
property_node_remove @164 NONAME
+ property_node_type @169 NONAME == XCgsqzn00000a8
+ property_node_clone @165 NONAME
+ property_node_traversal @167 NONAME
+ property_node_refdata @166 NONAME == XCgsqzn00000a5
+ property_node_datasize @171 NONAME == XCgsqzn00000aa
+ property_node_read @172 NONAME == XCgsqzn00000ab
+ property_query_size @160 NONAME == XCgsqzn000009f
property_node_refer @176 NONAME
property_read_query_memsize @177 NONAME
property_psmap_import @179 NONAME
diff --git a/src/imports/import_32_803_avs.def b/src/imports/import_32_803_avs.def
index a7f59b51..9340dad5 100644
--- a/src/imports/import_32_803_avs.def
+++ b/src/imports/import_32_803_avs.def
@@ -2,6 +2,12 @@ LIBRARY libavs-win32
EXPORTS
avs_boot
+ avs_fs_close
+ avs_fs_copy
+ avs_fs_lseek
+ avs_fs_lstat
+ avs_fs_open
+ avs_fs_read
avs_net_ctrl
avs_shutdown
avs_thread_create
@@ -19,6 +25,8 @@ EXPORTS
property_destroy
property_file_write
property_insert_read
+ property_clear_error
+ property_get_error
property_mem_write
property_read_query_memsize
property_search
@@ -27,6 +35,7 @@ EXPORTS
property_node_create
property_node_datasize
property_node_name
+ property_node_read
property_node_refer
property_node_remove
property_node_type
diff --git a/src/imports/import_32_indep_dwarfstack.def b/src/imports/import_32_indep_dwarfstack.def
new file mode 100644
index 00000000..71f1aaf5
--- /dev/null
+++ b/src/imports/import_32_indep_dwarfstack.def
@@ -0,0 +1,13 @@
+LIBRARY dwarfstack
+
+EXPORTS
+ dwstOfFile @ 441
+ dwstOfFileW @ 443
+ dwstOfProcess @ 446
+ dwstOfProcessW @ 448
+ dwstOfLocation @ 444
+ dwstOfLocationW @ 445
+ dwstOfException @ 438
+ dwstOfExceptionW @ 440
+ dwstExceptionDialog @ 436
+ dwstExceptionDialogW @ 437
\ No newline at end of file
diff --git a/src/imports/import_64_1508_avs.def b/src/imports/import_64_1508_avs.def
index bc9fbf06..1a93e7e5 100644
--- a/src/imports/import_64_1508_avs.def
+++ b/src/imports/import_64_1508_avs.def
@@ -3,10 +3,15 @@ LIBRARY libavs-win64
EXPORTS
avs_boot @285 NONAME
avs_fs_close @65 NONAME
+ avs_fs_copy @81 NONAME
avs_fs_lseek @59 NONAME
avs_fs_lseek64 @60 NONAME
+ avs_fs_lstat @79 NONAME
avs_fs_open @58 NONAME
avs_fs_read @61 NONAME
+ avs_fs_opendir @72 NONAME == XCd229cc0000f0
+ avs_fs_readdir @73 NONAME == XCd229cc0000bb
+ avs_fs_closedir @74 NONAME == XCd229cc0000b8
avs_net_ctrl @98 NONAME
avs_shutdown @286 NONAME
avs_thread_create @6 NONAME
@@ -21,9 +26,19 @@ EXPORTS
property_desc_to_buffer @129 NONAME
property_destroy @128 NONAME
property_insert_read @131 NONAME
+ property_clear_error @573 NONAME
+ property_get_error @573 NONAME
property_node_create @145 NONAME
+ property_node_name @150 NONAME
+ property_node_read @154 NONAME == XCd229cc0000f3
property_node_refer @158 NONAME
property_node_remove @146 NONAME
+ property_node_type @151 NONAME == XCd229cc000071
+ property_node_clone @147 NONAME
+ property_node_traversal @149 NONAME
+ property_node_refdata @148 NONAME == XCd229cc00009f
+ property_node_datasize @153 NONAME == XCd229cc000083
+ property_query_size @142 NONAME == XCd229cc000032
property_psmap_export @162 NONAME
property_psmap_import @161 NONAME
property_read_query_memsize @159 NONAME
diff --git a/src/imports/import_64_1509_avs.def b/src/imports/import_64_1509_avs.def
index ae6110a2..a596513a 100644
--- a/src/imports/import_64_1509_avs.def
+++ b/src/imports/import_64_1509_avs.def
@@ -3,10 +3,15 @@ LIBRARY libavs-win64
EXPORTS
avs_boot @285 NONAME
avs_fs_close @65 NONAME
+ avs_fs_copy @81 NONAME
avs_fs_lseek @59 NONAME
avs_fs_lseek64 @60 NONAME
+ avs_fs_lstat @78 NONAME
avs_fs_open @58 NONAME
avs_fs_read @61 NONAME
+ avs_fs_opendir @573 NONAME ==
+ avs_fs_readdir @573 NONAME ==
+ avs_fs_closedir @573 NONAME ==
avs_net_ctrl @98 NONAME
avs_shutdown @286 NONAME
avs_thread_create @6 NONAME
@@ -21,9 +26,19 @@ EXPORTS
property_desc_to_buffer @129 NONAME
property_destroy @128 NONAME
property_insert_read @131 NONAME
+ property_clear_error @573 NONAME
+ property_get_error @573 NONAME
property_node_create @145 NONAME
+ property_node_name @573 NONAME ==
+ property_node_read @573 NONAME ==
+ property_query_size @573 NONAME ==
property_node_refer @158 NONAME
property_node_remove @146 NONAME
+ property_node_type @573 NONAME ==
+ property_node_clone @147 NONAME
+ property_node_traversal @149 NONAME
+ property_node_refdata @573 NONAME ==
+ property_node_datasize @573 NONAME ==
property_psmap_export @162 NONAME
property_psmap_import @161 NONAME
property_read_query_memsize @159 NONAME
diff --git a/src/imports/import_64_1601_avs.def b/src/imports/import_64_1601_avs.def
index 5bbe4528..960fb947 100644
--- a/src/imports/import_64_1601_avs.def
+++ b/src/imports/import_64_1601_avs.def
@@ -1,6 +1,15 @@
LIBRARY libavs-win64
EXPORTS
+ avs_fs_close @65 NONAME
+ avs_fs_copy @81 NONAME
+ avs_fs_lseek @59 NONAME
+ avs_fs_lstat @79 NONAME
+ avs_fs_open @58 NONAME
+ avs_fs_read @61 NONAME
+ avs_fs_opendir @72 NONAME == XCnbrep7000047
+ avs_fs_readdir @73 NONAME == XCnbrep7000048
+ avs_fs_closedir @74 NONAME == XCnbrep7000049
avs_thread_create @5 NONAME
avs_thread_destroy @7 NONAME
avs_thread_exit @11 NONAME
@@ -10,9 +19,19 @@ EXPORTS
property_destroy @125 NONAME
property_desc_to_buffer @126 NONAME
property_insert_read @128 NONAME
+ property_clear_error @573 NONAME
+ property_get_error @573 NONAME
property_search @141 NONAME
property_node_create @142 NONAME
+ property_node_name @147 NONAME == XCnbrep7000092
property_node_remove @143 NONAME
+ property_node_type @148 NONAME == XCnbrep7000093
+ property_node_clone @144 NONAME
+ property_node_traversal @146 NONAME
+ property_node_refdata @145 NONAME == XCnbrep7000090
+ property_node_datasize @150 NONAME == XCnbrep7000095
+ property_node_read @151 NONAME == XCnbrep7000096
+ property_query_size @139 NONAME == XCnbrep700008a
property_node_refer @155 NONAME
property_read_query_memsize @156 NONAME
property_psmap_export @159 NONAME
diff --git a/src/imports/import_64_1603_avs.def b/src/imports/import_64_1603_avs.def
index 0355922f..14f42b7b 100644
--- a/src/imports/import_64_1603_avs.def
+++ b/src/imports/import_64_1603_avs.def
@@ -1,6 +1,15 @@
LIBRARY libavs-win64
EXPORTS
+ avs_fs_close @86 NONAME == XCnbrep7000055
+ avs_fs_copy @102 NONAME == XCnbrep7000065
+ avs_fs_lseek @80 NONAME == XCnbrep700004f
+ avs_fs_lstat @100 NONAME == XCnbrep7000063
+ avs_fs_open @79 NONAME == XCnbrep700004e
+ avs_fs_read @82 NONAME == XCnbrep7000051
+ avs_fs_opendir @93 NONAME == XCnbrep700005c
+ avs_fs_readdir @94 NONAME == XCnbrep700005d
+ avs_fs_closedir @95 NONAME == XCnbrep700005e
avs_thread_create @5 NONAME
avs_thread_destroy @7 NONAME
avs_thread_exit @11 NONAME
@@ -10,9 +19,19 @@ EXPORTS
property_destroy @146 NONAME
property_desc_to_buffer @147 NONAME
property_insert_read @149 NONAME
+ property_clear_error @158 NONAME == XCnbrep700009d
+ property_get_error @159 NONAME == XCnbrep700009e
property_search @162 NONAME
property_node_create @163 NONAME
+ property_node_name @168 NONAME == XCnbrep70000a7
property_node_remove @164 NONAME
+ property_node_type @169 NONAME == XCnbrep70000a8
+ property_node_clone @165 NONAME == XCnbrep70000a4
+ property_node_traversal @167 NONAME
+ property_node_refdata @166 NONAME == XCnbrep70000a5
+ property_node_datasize @171 NONAME == XCnbrep70000aa
+ property_node_read @172 NONAME == XCnbrep70000ab
+ property_query_size @160 NONAME == XCnbrep700009f
property_node_refer @176 NONAME
property_read_query_memsize @177 NONAME
property_psmap_import @179 NONAME
diff --git a/src/imports/import_64_1700_avs.def b/src/imports/import_64_1700_avs.def
index fe8cc6e6..3e456b50 100644
--- a/src/imports/import_64_1700_avs.def
+++ b/src/imports/import_64_1700_avs.def
@@ -6,15 +6,34 @@ EXPORTS
avs_thread_exit @11 NONAME
avs_thread_join @12 NONAME
avs_fs_addfs @73 NONAME
+ avs_fs_close @86 NONAME == XCgsqzn0000055
+ avs_fs_copy @102 NONAME == XCgsqzn0000065
+ avs_fs_lseek @80 NONAME == XCgsqzn000004f
+ avs_fs_lstat @100 NONAME == XCgsqzn0000063
avs_fs_mount @76 NONAME
+ avs_fs_open @79 NONAME == XCgsqzn000004e
+ avs_fs_read @82 NONAME == XCgsqzn0000051
+ avs_fs_opendir @93 NONAME == XCgsqzn000005c
+ avs_fs_readdir @94 NONAME == XCgsqzn000005d
+ avs_fs_closedir @95 NONAME == XCgsqzn000005e
avs_net_ctrl @119 NONAME
property_create @145 NONAME
property_destroy @146 NONAME
property_desc_to_buffer @147 NONAME
property_insert_read @149 NONAME
+ property_clear_error @158 NONAME == XCgsqzn000009d
+ property_get_error @159 NONAME == XCgsqzn000009e
property_search @162 NONAME
property_node_create @163 NONAME
+ property_node_name @168 NONAME == XCgsqzn00000a7
property_node_remove @164 NONAME
+ property_node_type @169 NONAME == XCgsqzn00000a8
+ property_node_clone @165 NONAME
+ property_node_traversal @167 NONAME
+ property_node_refdata @166 NONAME == XCgsqzn00000a5
+ property_node_datasize @171 NONAME == XCgsqzn00000aa
+ property_node_read @172 NONAME == XCgsqzn00000ab
+ property_query_size @160 NONAME == XCgsqzn000009f
property_node_refer @176 NONAME
property_read_query_memsize @177 NONAME
property_psmap_import @179 NONAME
diff --git a/src/imports/import_64_indep_dwarfstack.def b/src/imports/import_64_indep_dwarfstack.def
new file mode 100644
index 00000000..71f1aaf5
--- /dev/null
+++ b/src/imports/import_64_indep_dwarfstack.def
@@ -0,0 +1,13 @@
+LIBRARY dwarfstack
+
+EXPORTS
+ dwstOfFile @ 441
+ dwstOfFileW @ 443
+ dwstOfProcess @ 446
+ dwstOfProcessW @ 448
+ dwstOfLocation @ 444
+ dwstOfLocationW @ 445
+ dwstOfException @ 438
+ dwstOfExceptionW @ 440
+ dwstExceptionDialog @ 436
+ dwstExceptionDialogW @ 437
\ No newline at end of file
diff --git a/src/main/aciodrv-proc/Module.mk b/src/main/aciodrv-proc/Module.mk
index e347f778..9fa6b381 100644
--- a/src/main/aciodrv-proc/Module.mk
+++ b/src/main/aciodrv-proc/Module.mk
@@ -1,6 +1,7 @@
libs += aciodrv-proc
libs_aciodrv-proc := \
+ core \
src_aciodrv-proc := \
panb.c \
diff --git a/src/main/aciodrv-proc/panb.c b/src/main/aciodrv-proc/panb.c
index c054e21f..3f9d5a4f 100644
--- a/src/main/aciodrv-proc/panb.c
+++ b/src/main/aciodrv-proc/panb.c
@@ -5,8 +5,9 @@
#include "aciodrv/device.h"
#include "aciodrv/panb.h"
-#include "util/log.h"
-#include "util/thread.h"
+#include "core/thread.h"
+
+#include "core/log.h"
static int auto_poll_proc(void *auto_poll_param);
static int auto_poll_threadid;
@@ -50,7 +51,7 @@ bool aciodrv_proc_panb_init(struct aciodrv_device_ctx *device)
InitializeCriticalSection(&keypair_lock);
InitializeCriticalSection(&auto_poll_stop_lock);
auto_poll_threadid =
- thread_create(auto_poll_proc, (void *) device, 0x4000, 0);
+ core_thread_create(auto_poll_proc, (void *) device, 0x4000, 0);
return true;
}
@@ -80,8 +81,8 @@ void aciodrv_proc_panb_fini(struct aciodrv_device_ctx *device)
auto_poll_stop = true;
LeaveCriticalSection(&auto_poll_stop_lock);
- thread_join(auto_poll_threadid, NULL);
- thread_destroy(auto_poll_threadid);
+ core_thread_join(auto_poll_threadid, NULL);
+ core_thread_destroy(auto_poll_threadid);
DeleteCriticalSection(&keypair_lock);
DeleteCriticalSection(&auto_poll_stop_lock);
diff --git a/src/main/aciodrv/device.c b/src/main/aciodrv/device.c
index 39bf8afc..7584968d 100644
--- a/src/main/aciodrv/device.c
+++ b/src/main/aciodrv/device.c
@@ -7,8 +7,9 @@
#include "aciodrv/port.h"
+#include "core/log.h"
+
#include "util/hex.h"
-#include "util/log.h"
#include "util/mem.h"
/* Enable to dump all data to the logger */
diff --git a/src/main/aciodrv/h44b.c b/src/main/aciodrv/h44b.c
index afbab429..19283f64 100644
--- a/src/main/aciodrv/h44b.c
+++ b/src/main/aciodrv/h44b.c
@@ -7,7 +7,7 @@
#include "aciodrv/device.h"
-#include "util/log.h"
+#include "core/log.h"
bool aciodrv_h44b_init(struct aciodrv_device_ctx *device, uint8_t node_id)
{
diff --git a/src/main/aciodrv/icca.c b/src/main/aciodrv/icca.c
index ac56d0ea..7bec0c77 100644
--- a/src/main/aciodrv/icca.c
+++ b/src/main/aciodrv/icca.c
@@ -5,7 +5,7 @@
#include "aciodrv/device.h"
#include "aciodrv/icca.h"
-#include "util/log.h"
+#include "core/log.h"
static bool aciodrv_icca_queue_loop_start(
struct aciodrv_device_ctx *device, uint8_t node_id)
diff --git a/src/main/aciodrv/kfca.c b/src/main/aciodrv/kfca.c
index e21a0b84..88093e4b 100644
--- a/src/main/aciodrv/kfca.c
+++ b/src/main/aciodrv/kfca.c
@@ -5,7 +5,7 @@
#include "aciodrv/device.h"
-#include "util/log.h"
+#include "core/log.h"
static bool
aciodrv_kfca_watchdog_start(struct aciodrv_device_ctx *device, uint8_t node_id)
diff --git a/src/main/aciodrv/panb.c b/src/main/aciodrv/panb.c
index 1412e160..2dbc85ed 100644
--- a/src/main/aciodrv/panb.c
+++ b/src/main/aciodrv/panb.c
@@ -5,8 +5,7 @@
#include "aciodrv/device.h"
#include "aciodrv/panb.h"
-#include "util/log.h"
-#include "util/thread.h"
+#include "core/log.h"
bool aciodrv_panb_start_auto_input(
struct aciodrv_device_ctx *device, uint8_t node_id, uint8_t node_count)
diff --git a/src/main/aciodrv/port.c b/src/main/aciodrv/port.c
index b38ad2a7..c3c9c71f 100644
--- a/src/main/aciodrv/port.c
+++ b/src/main/aciodrv/port.c
@@ -6,7 +6,7 @@
#include
-#include "util/log.h"
+#include "core/log.h"
HANDLE aciodrv_port_open(const char *port_path, int baud)
{
diff --git a/src/main/aciodrv/rvol.c b/src/main/aciodrv/rvol.c
index a9e0c36f..ed7c0360 100644
--- a/src/main/aciodrv/rvol.c
+++ b/src/main/aciodrv/rvol.c
@@ -5,7 +5,7 @@
#include "aciodrv/device.h"
-#include "util/log.h"
+#include "core/log.h"
static bool aciodrv_rvol_change_expand_mode(
struct aciodrv_device_ctx *device, uint8_t node_id, uint8_t mode)
diff --git a/src/main/acioemu/addr.c b/src/main/acioemu/addr.c
index 8d85487e..3f52fbb5 100644
--- a/src/main/acioemu/addr.c
+++ b/src/main/acioemu/addr.c
@@ -5,7 +5,7 @@
#include "acioemu/addr.h"
#include "acioemu/emu.h"
-#include "util/log.h"
+#include "core/log.h"
void ac_io_emu_cmd_assign_addrs(
struct ac_io_emu *emu, const struct ac_io_message *req, uint8_t node_count)
diff --git a/src/main/acioemu/emu.c b/src/main/acioemu/emu.c
index 11cf35a4..57f74e05 100644
--- a/src/main/acioemu/emu.c
+++ b/src/main/acioemu/emu.c
@@ -14,9 +14,10 @@
#include "acioemu/emu.h"
#include "acioemu/pipe.h"
+#include "core/log.h"
+
#include "hook/iohook.h"
-#include "util/log.h"
#include "util/str.h"
static HRESULT ac_io_emu_open(struct ac_io_emu *emu, struct irp *irp);
diff --git a/src/main/acioemu/hdxs.c b/src/main/acioemu/hdxs.c
index 9a38beee..01ec19df 100644
--- a/src/main/acioemu/hdxs.c
+++ b/src/main/acioemu/hdxs.c
@@ -6,7 +6,7 @@
#include "acioemu/emu.h"
#include "acioemu/hdxs.h"
-#include "util/log.h"
+#include "core/log.h"
static void ac_io_emu_hdxs_cmd_send_version(
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req);
diff --git a/src/main/acioemu/icca.c b/src/main/acioemu/icca.c
index 134b14fc..e7713e52 100644
--- a/src/main/acioemu/icca.c
+++ b/src/main/acioemu/icca.c
@@ -511,7 +511,7 @@ static void ac_io_emu_icca_cipher_set_key(
resp.cmd.raw[0] = (reader_key >> 24) & 0xFF;
resp.cmd.raw[1] = (reader_key >> 16) & 0xFF;
resp.cmd.raw[2] = (reader_key >> 8) & 0xFF;
- resp.cmd.raw[3] = (reader_key) &0xFF;
+ resp.cmd.raw[3] = (reader_key) & 0xFF;
// so I looked these constants up, this isn't actually a secure key
// generator it's actually Marsaglia's "KISS" algorithm with different
diff --git a/src/main/acioemu/pipe.h b/src/main/acioemu/pipe.h
index ad442fc2..859c3b6f 100644
--- a/src/main/acioemu/pipe.h
+++ b/src/main/acioemu/pipe.h
@@ -7,9 +7,10 @@
#include "acio/acio.h"
+#include "core/log.h"
+
#include "util/iobuf.h"
#include "util/list.h"
-#include "util/log.h"
/* This uses the USB convention where OUT and IN are from the host's (game's)
perspective. So an OUT transaction comes in to us and vice versa.
diff --git a/src/main/aciomgr/Module.mk b/src/main/aciomgr/Module.mk
index 0a17e8cd..b87f81b6 100644
--- a/src/main/aciomgr/Module.mk
+++ b/src/main/aciomgr/Module.mk
@@ -1,6 +1,7 @@
dlls += aciomgr
libs_aciomgr := \
+ core \
aciodrv \
util \
diff --git a/src/main/aciomgr/manager.c b/src/main/aciomgr/manager.c
index e73b18e2..d7f03787 100644
--- a/src/main/aciomgr/manager.c
+++ b/src/main/aciomgr/manager.c
@@ -5,14 +5,15 @@
#include
#include "aciomgr/manager-init.h"
-
#include "aciomgr/manager.h"
#include "acio/acio.h"
#include "aciodrv/device.h"
+
+#include "core/log.h"
+
#include "util/array.h"
-#include "util/log.h"
#define MAX_PORT_PATH_LENGTH 256
@@ -90,7 +91,7 @@ void aciomgr_set_loggers(
log_formatter_t warning,
log_formatter_t fatal)
{
- log_to_external(misc, info, warning, fatal);
+ core_log_impl_set(misc, warning, info, fatal);
}
struct aciomgr_port_dispatcher *aciomgr_port_init(const char *path, int baud)
diff --git a/src/main/aciotest/Module.mk b/src/main/aciotest/Module.mk
index af04652b..efeb038f 100644
--- a/src/main/aciotest/Module.mk
+++ b/src/main/aciotest/Module.mk
@@ -1,6 +1,7 @@
exes += aciotest
libs_aciotest := \
+ core \
bio2drv \
aciodrv \
aciodrv-proc \
diff --git a/src/main/aciotest/bi2a-iidx.c b/src/main/aciotest/bi2a-iidx.c
index bd391cf8..01315675 100644
--- a/src/main/aciotest/bi2a-iidx.c
+++ b/src/main/aciotest/bi2a-iidx.c
@@ -29,81 +29,79 @@ bool aciotest_bi2a_iidx_handler_update(
return false;
}
-
-
printf(
- "|---------------------------------------|\n"
- "| R Y G B Neons B G Y R |\n"
- "| %d %d %d %d %d %d %d %d %d |\n"
- "|---------------------------------------|\n"
- "| NOW PLAYING: %c%c%c%c%c%c%c%c%c |\n"
- "|---------------------------------------|\n"
- "| Effect %d S1 S2 S3 S4 S5 Test %d|\n"
- "|StartP1 %d %02d %02d %02d %02d %02d StartP2 %d|\n"
- "| VEFX %d Service %d|\n"
- "_________________________________________\n"
- "| __ __ |\n"
- "| / \\ _ / \\ |\n"
- "| | %03d| %d %d %d |%d| %d %d %d | %03d| |\n"
- "| \\___/ %d %d %d %d |_| %d %d %d %d \\___/ |\n"
- "| |\n"
- "|---------------------------------------|\n"
- "|---------------------------------------|\n",
-
- pout.SPOTLIGHT2[0].l_state,
- pout.SPOTLIGHT2[1].l_state,
- pout.SPOTLIGHT2[2].l_state,
- pout.SPOTLIGHT2[3].l_state,
- pout.NEONLAMP.l_state,
- pout.SPOTLIGHT1[0].l_state,
- pout.SPOTLIGHT1[1].l_state,
- pout.SPOTLIGHT1[2].l_state,
- pout.SPOTLIGHT1[3].l_state,
-
- pout.SEG16[0],
- pout.SEG16[1],
- pout.SEG16[2],
- pout.SEG16[3],
- pout.SEG16[4],
- pout.SEG16[5],
- pout.SEG16[6],
- pout.SEG16[7],
- pout.SEG16[8],
-
- pin.PANEL.y_effect,
- pin.SYSTEM.v_test,
-
- pin.PANEL.y_start1,
- pin.SLIDER1.s_val,
- pin.SLIDER2.s_val,
- pin.SLIDER3.s_val,
- pin.SLIDER4.s_val,
- pin.SLIDER5.s_val,
- pin.PANEL.y_start2,
-
- pin.PANEL.y_vefx,
- pin.SYSTEM.v_service,
-
- pin.TURNTABLE1,
- pin.P1SW2.b_val,
- pin.P1SW4.b_val,
- pin.P1SW6.b_val,
- pin.SYSTEM.v_coin,
- pin.P2SW2.b_val,
- pin.P2SW4.b_val,
- pin.P2SW6.b_val,
- pin.TURNTABLE2,
-
- pin.P1SW1.b_val,
- pin.P1SW3.b_val,
- pin.P1SW5.b_val,
- pin.P1SW7.b_val,
- pin.P2SW1.b_val,
- pin.P2SW3.b_val,
- pin.P2SW5.b_val,
- pin.P2SW7.b_val
-
- );
+ "|---------------------------------------|\n"
+ "| R Y G B Neons B G Y R |\n"
+ "| %d %d %d %d %d %d %d %d %d |\n"
+ "|---------------------------------------|\n"
+ "| NOW PLAYING: %c%c%c%c%c%c%c%c%c |\n"
+ "|---------------------------------------|\n"
+ "| Effect %d S1 S2 S3 S4 S5 Test %d|\n"
+ "|StartP1 %d %02d %02d %02d %02d %02d StartP2 %d|\n"
+ "| VEFX %d Service %d|\n"
+ "_________________________________________\n"
+ "| __ __ |\n"
+ "| / \\ _ / \\ |\n"
+ "| | %03d| %d %d %d |%d| %d %d %d | %03d| |\n"
+ "| \\___/ %d %d %d %d |_| %d %d %d %d \\___/ |\n"
+ "| |\n"
+ "|---------------------------------------|\n"
+ "|---------------------------------------|\n",
+
+ pout.SPOTLIGHT2[0].l_state,
+ pout.SPOTLIGHT2[1].l_state,
+ pout.SPOTLIGHT2[2].l_state,
+ pout.SPOTLIGHT2[3].l_state,
+ pout.NEONLAMP.l_state,
+ pout.SPOTLIGHT1[0].l_state,
+ pout.SPOTLIGHT1[1].l_state,
+ pout.SPOTLIGHT1[2].l_state,
+ pout.SPOTLIGHT1[3].l_state,
+
+ pout.SEG16[0],
+ pout.SEG16[1],
+ pout.SEG16[2],
+ pout.SEG16[3],
+ pout.SEG16[4],
+ pout.SEG16[5],
+ pout.SEG16[6],
+ pout.SEG16[7],
+ pout.SEG16[8],
+
+ pin.PANEL.y_effect,
+ pin.SYSTEM.v_test,
+
+ pin.PANEL.y_start1,
+ pin.SLIDER1.s_val,
+ pin.SLIDER2.s_val,
+ pin.SLIDER3.s_val,
+ pin.SLIDER4.s_val,
+ pin.SLIDER5.s_val,
+ pin.PANEL.y_start2,
+
+ pin.PANEL.y_vefx,
+ pin.SYSTEM.v_service,
+
+ pin.TURNTABLE1,
+ pin.P1SW2.b_val,
+ pin.P1SW4.b_val,
+ pin.P1SW6.b_val,
+ pin.SYSTEM.v_coin,
+ pin.P2SW2.b_val,
+ pin.P2SW4.b_val,
+ pin.P2SW6.b_val,
+ pin.TURNTABLE2,
+
+ pin.P1SW1.b_val,
+ pin.P1SW3.b_val,
+ pin.P1SW5.b_val,
+ pin.P1SW7.b_val,
+ pin.P2SW1.b_val,
+ pin.P2SW3.b_val,
+ pin.P2SW5.b_val,
+ pin.P2SW7.b_val
+
+ );
return true;
}
diff --git a/src/main/aciotest/main.c b/src/main/aciotest/main.c
index a0da1391..fdf6df48 100644
--- a/src/main/aciotest/main.c
+++ b/src/main/aciotest/main.c
@@ -1,21 +1,28 @@
#include
#include
-#include
#include
+#include
#include
#include "aciodrv/device.h"
-#include "aciotest/bi2a-sdvx.h"
#include "aciotest/bi2a-iidx.h"
+#include "aciotest/bi2a-sdvx.h"
#include "aciotest/handler.h"
#include "aciotest/icca.h"
#include "aciotest/kfca.h"
#include "aciotest/panb.h"
#include "aciotest/rvol.h"
-#include "util/log.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log.h"
+#include "core/thread-crt-ext.h"
+#include "core/thread-crt.h"
+#include "core/thread.h"
+
+#include "core/log.h"
static uint8_t aciotest_cnt = 0;
static uint8_t bi2a_mode = 255;
@@ -58,25 +65,23 @@ static bool aciotest_assign_handler(
if (bi2a_mode == 255) {
printf(
"Unknown BI2A mode specified, please check your command.\n"
- "Using bi2a-sdvx mode as default, press ENTER to continue\n"
- );
+ "Using bi2a-sdvx mode as default, press ENTER to continue\n");
bi2a_mode = 0;
getchar();
}
- switch (bi2a_mode)
- {
- case 0:
- handler->init = aciotest_bi2a_sdvx_handler_init;
- handler->update = aciotest_bi2a_sdvx_handler_update;
- break;
- case 1:
- handler->init = aciotest_bi2a_iidx_handler_init;
- handler->update = aciotest_bi2a_iidx_handler_update;
- break;
-
- default:
- break;
+ switch (bi2a_mode) {
+ case 0:
+ handler->init = aciotest_bi2a_sdvx_handler_init;
+ handler->update = aciotest_bi2a_sdvx_handler_update;
+ break;
+ case 1:
+ handler->init = aciotest_bi2a_iidx_handler_init;
+ handler->update = aciotest_bi2a_iidx_handler_update;
+ break;
+
+ default:
+ break;
}
return true;
}
@@ -107,14 +112,17 @@ int main(int argc, char **argv)
}
if (argc == 4) {
- if(!strcmp(argv[3],"bi2a-iidx")) {
+ if (!strcmp(argv[3], "bi2a-iidx")) {
bi2a_mode = 1;
- } else if(!strcmp(argv[3],"bi2a-sdvx")) {
+ } else if (!strcmp(argv[3], "bi2a-sdvx")) {
bi2a_mode = 0;
}
}
- log_to_writer(log_writer_stdout, NULL);
+ core_thread_crt_ext_impl_set();
+ core_log_bt_ext_impl_set();
+
+ core_log_bt_ext_init_with_stdout();
struct aciodrv_device_ctx *device =
aciodrv_device_open_path(argv[1], atoi(argv[2]));
diff --git a/src/main/asio/asio-reghook.c b/src/main/asio/asio-reghook.c
index 161b13b1..7e058904 100644
--- a/src/main/asio/asio-reghook.c
+++ b/src/main/asio/asio-reghook.c
@@ -10,13 +10,14 @@
#include
+#include "asio/asio-reghook.h"
+
+#include "core/log.h"
+
#include "hook/com-proxy.h"
#include "hook/table.h"
-#include "asio/asio-reghook.h"
-
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
#include "util/time.h"
diff --git a/src/main/asio/config-asio.c b/src/main/asio/config-asio.c
index b29f99c8..2a8675d1 100644
--- a/src/main/asio/config-asio.c
+++ b/src/main/asio/config-asio.c
@@ -1,8 +1,8 @@
#include "cconfig/cconfig-util.h"
-#include "asio/config-asio.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "asio/config-asio.h"
#define ASIOHOOK_CONFIG_IO_FORCE_ASIO_KEY "asio.force_asio"
#define ASIOHOOK_CONFIG_IO_FORCE_WASAPI_KEY "asio.force_wasapi"
diff --git a/src/main/avs-util/Module.mk b/src/main/avs-util/Module.mk
new file mode 100644
index 00000000..2e59f579
--- /dev/null
+++ b/src/main/avs-util/Module.mk
@@ -0,0 +1,7 @@
+libs += avs-util
+
+libs_avs-util := \
+
+src_avs-util := \
+ core-interop.c \
+ error.c \
diff --git a/src/main/avs-util/core-interop.c b/src/main/avs-util/core-interop.c
new file mode 100644
index 00000000..555930f1
--- /dev/null
+++ b/src/main/avs-util/core-interop.c
@@ -0,0 +1,16 @@
+#include "core/log.h"
+#include "core/thread.h"
+
+#include "imports/avs.h"
+
+void avs_util_core_interop_log_avs_impl_set()
+{
+ core_log_impl_set(
+ log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+}
+
+void avs_util_core_interop_thread_avs_impl_set()
+{
+ core_thread_impl_set(
+ avs_thread_create, avs_thread_join, avs_thread_destroy);
+}
\ No newline at end of file
diff --git a/src/main/avs-util/core-interop.h b/src/main/avs-util/core-interop.h
new file mode 100644
index 00000000..51b1e119
--- /dev/null
+++ b/src/main/avs-util/core-interop.h
@@ -0,0 +1,7 @@
+#ifndef AVS_UTIL_CORE_INTEROP_H
+#define AVS_UTIL_CORE_INTEROP_H
+
+void avs_util_core_interop_log_avs_impl_set();
+void avs_util_core_interop_thread_avs_impl_set();
+
+#endif
\ No newline at end of file
diff --git a/src/main/avs-util/error.c b/src/main/avs-util/error.c
new file mode 100644
index 00000000..d31b2e18
--- /dev/null
+++ b/src/main/avs-util/error.c
@@ -0,0 +1,109 @@
+#include "avs-util/error.h"
+
+#include "util/defs.h"
+
+struct avs_util_avs_error_str {
+ avs_error error;
+ const char *msg;
+};
+
+static const char *avs_util_error_unknown = "unknown error";
+
+// Source: https://github.com/spicetools/spicetools
+static const struct avs_util_avs_error_str AVS_UTIL_ERRORS[] = {
+ {0x80092000, "invalid type"},
+ {0x80092001, "type cannot use as array"},
+ {0x80092002, "invalid"},
+ {0x80092003, "too large data size"},
+ {0x80092004, "too small buffer size"},
+ {0x80092005, "passcode 0 is not allowed"},
+ {0x80092040, "invalid node name"},
+ {0x80092041, "invalid attribute name"},
+ {0x80092042, "reserved attribute name"},
+ {0x80092043, "cannot find node/attribute"},
+ {0x80092080, "cannot allocate node"},
+ {0x80092081, "cannot allocate node value"},
+ {0x80092082, "cannot allocate mdigest for finger-print"},
+ {0x80092083, "cannot allocate nodename"},
+ {0x800920C0, "node type differs"},
+ {0x800920C1, "node type is VOID"},
+ {0x800920C2, "node is array"},
+ {0x800920C3, "node is not array"},
+ {0x80092100, "node is create-disabled"},
+ {0x80092101, "node is read-disabled"},
+ {0x80092102, "node is write-disabled"},
+ {0x80092103, "flag is already locked"},
+ {0x80092104, "passcode differs"},
+ {0x80092105, "insert_read() is applied to attribute"},
+ {0x80092106, "part_write() is applied to attribute"},
+ {0x80092107, "MODE_EXTEND flag differs"},
+ {0x80092140, "root node already exists"},
+ {0x80092141, "attribute cannot have children"},
+ {0x80092142, "node/attribute already exists"},
+ {0x80092143, "number of nodes exceeds 65535"},
+ {0x80092144, "cannot interpret as number"},
+ {0x80092145, "property is empty"},
+ {0x80092180, "I/O error"},
+ {0x80092181, "unexpected EOF"},
+ {0x80092182, "unknown format"},
+ {0x800921C0, "broken magic"},
+ {0x800921C1, "broken metadata"},
+ {0x800921C2, "broken databody"},
+ {0x800921C3, "invalid type"},
+ {0x800921C4, "too large data size"},
+ {0x800921C5, "too long node/attribute name"},
+ {0x800921C6, "attribute name is too long"},
+ {0x800921C7, "node/attribute already exists"},
+ {0x80092200, "invalid encoding"},
+ {0x80092201, "invalid XML token"},
+ {0x80092202, "XML syntax error"},
+ {0x80092203, "start tag / end tag mismatch"},
+ {0x80092204, "too large node data (__size mismatch)"},
+ {0x80092205, "too deep node tree"},
+ {0x80092206, "invalid type"},
+ {0x80092207, "invalid size"},
+ {0x80092208, "invalid count"},
+ {0x80092209, "invalid value"},
+ {0x8009220A, "invalid node name"},
+ {0x8009220B, "invalid attribute name"},
+ {0x8009220C, "reserved attribute name"},
+ {0x8009220D, "node/attribute already exists"},
+ {0x8009220E, "too many elements in node data"},
+ {0x80092240, "JSON syntax error"},
+ {0x80092241, "invalid JSON literal"},
+ {0x80092242, "invalid JSON number"},
+ {0x80092243, "invalid JSON string"},
+ {0x80092244, "invalid JSON object name"},
+ {0x80092245, "object name already exists"},
+ {0x80092246, "too long JSON object name"},
+ {0x80092247, "too deep JSON object/array nesting"},
+ {0x80092248, "cannot convert JSON array to property"},
+ {0x80092249, "cannot convert empty JSON object to property"},
+ {0x8009224A, "root node already exists"},
+ {0x8009224B, "cannot convert root node to TYPE_ARRAY"},
+ {0x8009224C, "name represents reserved attribute"},
+ {0x80092280, "finger-print differs"},
+ {0x800922C0, "operation is not supported"}};
+
+const char *avs_util_error_str(avs_error error)
+{
+ int i;
+
+ for (i = 0; i < lengthof(AVS_UTIL_ERRORS); i++) {
+ if (error == AVS_UTIL_ERRORS[i].error) {
+ return AVS_UTIL_ERRORS[i].msg;
+ }
+ }
+
+ return avs_util_error_unknown;
+}
+
+const char *avs_util_property_error_get_and_clear(struct property *prop)
+{
+ avs_error error;
+
+ error = property_get_error(prop);
+ property_clear_error(prop);
+
+ return avs_util_error_str(error);
+}
\ No newline at end of file
diff --git a/src/main/avs-util/error.h b/src/main/avs-util/error.h
new file mode 100644
index 00000000..bdf415ec
--- /dev/null
+++ b/src/main/avs-util/error.h
@@ -0,0 +1,10 @@
+#ifndef AVS_UTIL_ERROR_H
+#define AVS_UTIL_ERROR_H
+
+#include "imports/avs.h"
+
+const char *avs_util_error_str(avs_error error);
+
+const char *avs_util_property_error_get_and_clear(struct property *prop);
+
+#endif
\ No newline at end of file
diff --git a/src/main/bio2drv/Module.mk b/src/main/bio2drv/Module.mk
index f5bdb568..9e5e92b3 100644
--- a/src/main/bio2drv/Module.mk
+++ b/src/main/bio2drv/Module.mk
@@ -1,10 +1,11 @@
libs += bio2drv
libs_bio2drv := \
- aciodrv
+ core \
+ aciodrv \
src_bio2drv := \
detect.c \
config-bio2.c \
bi2a-iidx.c \
- bi2a-sdvx.c
+ bi2a-sdvx.c \
diff --git a/src/main/bio2drv/bi2a-iidx.c b/src/main/bio2drv/bi2a-iidx.c
index 1119876f..bce8c41e 100644
--- a/src/main/bio2drv/bi2a-iidx.c
+++ b/src/main/bio2drv/bi2a-iidx.c
@@ -7,7 +7,7 @@
#include "aciodrv/device.h"
-#include "util/log.h"
+#include "core/log.h"
// Must be provided on init command. Actual meaning unknown right now.
// Not providing this will not initialize the IO correctly resulting
diff --git a/src/main/bio2drv/bi2a-sdvx.c b/src/main/bio2drv/bi2a-sdvx.c
index 93edf496..14e52395 100644
--- a/src/main/bio2drv/bi2a-sdvx.c
+++ b/src/main/bio2drv/bi2a-sdvx.c
@@ -7,7 +7,7 @@
#include "aciodrv/device.h"
-#include "util/log.h"
+#include "core/log.h"
static const uint8_t _BIO2DR_BI2A_SDVX_INIT_DATA = 0x3B;
diff --git a/src/main/bio2drv/config-bio2.c b/src/main/bio2drv/config-bio2.c
index 492cdefd..c016fa94 100644
--- a/src/main/bio2drv/config-bio2.c
+++ b/src/main/bio2drv/config-bio2.c
@@ -1,8 +1,8 @@
#include "cconfig/cconfig-util.h"
-#include "bio2drv/config-bio2.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "bio2drv/config-bio2.h"
#define BIO2DRV_CONFIG_BIO2_AUTO_KEY "bio2.autodetect"
#define BIO2DRV_CONFIG_BIO2_PORT_KEY "bio2.port"
diff --git a/src/main/bio2drv/detect.c b/src/main/bio2drv/detect.c
index d559175d..dfdf5013 100644
--- a/src/main/bio2drv/detect.c
+++ b/src/main/bio2drv/detect.c
@@ -8,11 +8,11 @@
#include "bio2drv/detect.h"
+#include "core/log.h"
+
#include
#include
-#include "util/log.h"
-
DEFINE_GUID(
GUID_COM_BUS_ENUMERATOR,
0x4D36E978,
@@ -142,7 +142,7 @@ void bio2drv_set_loggers(
log_formatter_t warning,
log_formatter_t fatal)
{
- log_to_external(misc, info, warning, fatal);
+ core_log_impl_set(misc, warning, info, fatal);
}
bool bio2drv_detect(
diff --git a/src/main/bio2emu/emu.c b/src/main/bio2emu/emu.c
index 9fbcb3d8..ea9c7f0d 100644
--- a/src/main/bio2emu/emu.c
+++ b/src/main/bio2emu/emu.c
@@ -14,6 +14,8 @@
#include "acioemu/addr.h"
#include "acioemu/emu.h"
+#include "core/log.h"
+
#include "hook/iohook.h"
#include "hooklib/rs232.h"
@@ -25,7 +27,6 @@
#include "util/array.h"
#include "util/defs.h"
#include "util/iobuf.h"
-#include "util/log.h"
#include "util/str.h"
static struct array bio2_active_ports;
diff --git a/src/main/bio2emu/setupapi.c b/src/main/bio2emu/setupapi.c
index 5dbfffc7..bb2f32c3 100644
--- a/src/main/bio2emu/setupapi.c
+++ b/src/main/bio2emu/setupapi.c
@@ -6,13 +6,14 @@
#include
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "bio2emu/emu.h"
#include "bio2emu/setupapi.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
#include "util/time.h"
diff --git a/src/main/bsthook/Module.mk b/src/main/bsthook/Module.mk
index ef61d283..92ab3b1c 100644
--- a/src/main/bsthook/Module.mk
+++ b/src/main/bsthook/Module.mk
@@ -4,6 +4,8 @@ deplibs_bsthook := \
avs \
libs_bsthook := \
+ avs-util \
+ core \
acioemu \
bstio \
hook \
diff --git a/src/main/bsthook/acio.c b/src/main/bsthook/acio.c
index fe5f8cc1..500d4c5b 100644
--- a/src/main/bsthook/acio.c
+++ b/src/main/bsthook/acio.c
@@ -19,13 +19,14 @@
#include "bsthook/acio.h"
#include "bsthook/kfca.h"
+#include "core/log.h"
+
#include "hook/iohook.h"
#include "imports/avs.h"
#include "util/defs.h"
#include "util/iobuf.h"
-#include "util/log.h"
#include "util/str.h"
static struct ac_io_emu ac_io_emu;
diff --git a/src/main/bsthook/dllmain.c b/src/main/bsthook/dllmain.c
index 57d38e03..e508057c 100644
--- a/src/main/bsthook/dllmain.c
+++ b/src/main/bsthook/dllmain.c
@@ -2,9 +2,14 @@
#include
+#include "avs-util/core-interop.h"
+
#include "bemanitools/bstio.h"
#include "bemanitools/eamio.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "hook/iohook.h"
#include "hooklib/app.h"
@@ -18,7 +23,6 @@
#include "util/cmdline.h"
#include "util/defs.h"
-#include "util/log.h"
static bool my_dll_entry_init(char *sidcode, struct property_node *config);
static bool my_dll_entry_main(void);
@@ -33,19 +37,23 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *config)
log_info("Starting up BeatStream IO backend");
- bst_io_set_loggers(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ core_log_impl_assign(bst_io_set_loggers);
- ok = bst_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
+ ok = bst_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get());
if (!ok) {
goto bst_io_fail;
}
- eam_io_set_loggers(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
- ok = eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
+ ok = eam_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get());
if (!ok) {
goto eam_io_fail;
@@ -91,8 +99,9 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
return TRUE;
}
- log_to_external(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ // Use AVS APIs
+ avs_util_core_interop_thread_avs_impl_set();
+ avs_util_core_interop_log_avs_impl_set();
args_recover(&argc, &argv);
diff --git a/src/main/bsthook/gfx.c b/src/main/bsthook/gfx.c
index 43d88a2d..23d37e0f 100644
--- a/src/main/bsthook/gfx.c
+++ b/src/main/bsthook/gfx.c
@@ -3,6 +3,8 @@
#include
+#include "core/log.h"
+
#include "hook/com-proxy.h"
#include "hook/pe.h"
#include "hook/table.h"
@@ -10,7 +12,6 @@
#include "sdvxhook/gfx.h"
#include "util/defs.h"
-#include "util/log.h"
static HRESULT STDCALL my_CreateDevice(
IDirect3D9 *self,
diff --git a/src/main/bsthook/settings.c b/src/main/bsthook/settings.c
index 8f48ea8e..c9fb10ae 100644
--- a/src/main/bsthook/settings.c
+++ b/src/main/bsthook/settings.c
@@ -7,10 +7,11 @@
#include
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
/* ------------------------------------------------------------------------- */
diff --git a/src/main/camhook/cam.c b/src/main/camhook/cam.c
index 4ce92603..169fd020 100644
--- a/src/main/camhook/cam.c
+++ b/src/main/camhook/cam.c
@@ -15,13 +15,14 @@
#include
+#include "camhook/cam.h"
+
+#include "core/log.h"
+
#include "hook/com-proxy.h"
#include "hook/table.h"
-#include "camhook/cam.h"
-
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
#include "util/time.h"
diff --git a/src/main/camhook/config-cam.c b/src/main/camhook/config-cam.c
index 6a55852e..c6dd1afb 100644
--- a/src/main/camhook/config-cam.c
+++ b/src/main/camhook/config-cam.c
@@ -1,8 +1,8 @@
#include "cconfig/cconfig-util.h"
-#include "camhook/config-cam.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "camhook/config-cam.h"
#define CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY "cam.disable_emu"
#define CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE false
diff --git a/src/main/cconfig/cconfig-main.c b/src/main/cconfig/cconfig-main.c
index 342a9120..342d8dfe 100644
--- a/src/main/cconfig/cconfig-main.c
+++ b/src/main/cconfig/cconfig-main.c
@@ -6,8 +6,9 @@
#include "cconfig/cconfig-main.h"
+#include "core/log.h"
+
#include "util/cmdline.h"
-#include "util/log.h"
bool cconfig_main_config_init(
struct cconfig *config,
@@ -84,7 +85,7 @@ bool cconfig_main_config_init(
}
log_misc("Config state after file loading:");
- cconfig_util_log(config, log_impl_misc);
+ cconfig_util_log(config, core_log_misc_impl_get());
}
log_misc("Parsing override config parameters from cmd");
@@ -96,7 +97,7 @@ bool cconfig_main_config_init(
}
log_misc("Config state after cmd parameter overrides:");
- cconfig_util_log(config, log_impl_misc);
+ cconfig_util_log(config, core_log_misc_impl_get());
goto success;
diff --git a/src/main/cconfig/cconfig-util.c b/src/main/cconfig/cconfig-util.c
index f4ce05f3..35853574 100644
--- a/src/main/cconfig/cconfig-util.c
+++ b/src/main/cconfig/cconfig-util.c
@@ -5,8 +5,9 @@
#include "cconfig/cconfig-util.h"
+#include "core/log.h"
+
#include "util/hex.h"
-#include "util/log.h"
#include "util/mem.h"
bool cconfig_util_get_int(
@@ -220,10 +221,10 @@ void cconfig_util_set_data(
free(str);
}
-void cconfig_util_log(struct cconfig *config, log_formatter_t log_formatter)
+void cconfig_util_log(struct cconfig *config, core_log_message_t log_message)
{
for (uint32_t i = 0; i < config->nentries; i++) {
- log_formatter(
+ log_message(
LOG_MODULE,
"%s=%s",
config->entries[i].key,
diff --git a/src/main/cconfig/cconfig-util.h b/src/main/cconfig/cconfig-util.h
index aa9b5004..8f6a3058 100644
--- a/src/main/cconfig/cconfig-util.h
+++ b/src/main/cconfig/cconfig-util.h
@@ -7,7 +7,7 @@
#include "cconfig/cconfig.h"
-#include "util/log.h"
+#include "core/log.h"
bool cconfig_util_get_int(
struct cconfig *config,
@@ -57,6 +57,6 @@ void cconfig_util_set_data(
size_t len,
const char *desc);
-void cconfig_util_log(struct cconfig *config, log_formatter_t log_formatter);
+void cconfig_util_log(struct cconfig *config, core_log_message_t log_message);
#endif
\ No newline at end of file
diff --git a/src/main/cconfig/cconfig.c b/src/main/cconfig/cconfig.c
index 1cfcbedb..6150f66f 100644
--- a/src/main/cconfig/cconfig.c
+++ b/src/main/cconfig/cconfig.c
@@ -2,7 +2,8 @@
#include "cconfig/cconfig.h"
-#include "util/log.h"
+#include "core/log.h"
+
#include "util/mem.h"
#include "util/str.h"
diff --git a/src/main/cconfig/cmd.c b/src/main/cconfig/cmd.c
index 3d4f32fc..3bb1c247 100644
--- a/src/main/cconfig/cmd.c
+++ b/src/main/cconfig/cmd.c
@@ -7,8 +7,9 @@
#include "cconfig/cmd.h"
+#include "core/log.h"
+
#include "util/hex.h"
-#include "util/log.h"
#include "util/str.h"
static void
diff --git a/src/main/cconfig/conf.c b/src/main/cconfig/conf.c
index de21f8b9..b23e9d47 100644
--- a/src/main/cconfig/conf.c
+++ b/src/main/cconfig/conf.c
@@ -6,8 +6,9 @@
#include "cconfig/conf.h"
+#include "core/log.h"
+
#include "util/fs.h"
-#include "util/log.h"
#include "util/str.h"
enum cconfig_conf_error cconfig_conf_load_from_file(
diff --git a/src/main/config/Module.mk b/src/main/config/Module.mk
index 2f7bac83..fc37a230 100644
--- a/src/main/config/Module.mk
+++ b/src/main/config/Module.mk
@@ -3,6 +3,7 @@ rc_config := config.rc
cppflags_config := -DUNICODE
libs_config := \
+ core \
eamio \
geninput \
util \
diff --git a/src/main/config/analogs.c b/src/main/config/analogs.c
index 48c48817..e7ef0a21 100644
--- a/src/main/config/analogs.c
+++ b/src/main/config/analogs.c
@@ -11,13 +11,14 @@
#include "config/schema.h"
#include "config/usages.h"
+#include "core/log.h"
+
#include "geninput/hid-mgr.h"
#include "geninput/input-config.h"
#include "geninput/mapper.h"
#include "util/array.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"
diff --git a/src/main/config/buttons.c b/src/main/config/buttons.c
index f4a498b8..e083bf3f 100644
--- a/src/main/config/buttons.c
+++ b/src/main/config/buttons.c
@@ -15,11 +15,12 @@
#include "config/schema.h"
#include "config/usages.h"
+#include "core/log.h"
+
#include "geninput/input-config.h"
#include "geninput/mapper.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/mem.h"
#include "util/winres.h"
diff --git a/src/main/config/eam.c b/src/main/config/eam.c
index e9bb76ce..1d665189 100644
--- a/src/main/config/eam.c
+++ b/src/main/config/eam.c
@@ -13,6 +13,8 @@
#include "config/resource.h"
#include "config/schema.h"
+#include "core/log.h"
+
#include "eamio/eam-config.h"
#include "geninput/hid-mgr.h"
@@ -21,7 +23,6 @@
#include "util/array.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"
diff --git a/src/main/config/gametype.c b/src/main/config/gametype.c
index e7e7353b..2ec0ea4b 100644
--- a/src/main/config/gametype.c
+++ b/src/main/config/gametype.c
@@ -6,8 +6,9 @@
#include "config/resource.h"
#include "config/schema.h"
+#include "core/log.h"
+
#include "util/defs.h"
-#include "util/log.h"
static INT_PTR CALLBACK
game_type_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
diff --git a/src/main/config/main.c b/src/main/config/main.c
index ba515554..8be13700 100644
--- a/src/main/config/main.c
+++ b/src/main/config/main.c
@@ -14,14 +14,19 @@
#include "config/spinner.h"
#include "config/usages.h"
+#include "core/log-bt.h"
+#include "core/log-sink-debug.h"
+#include "core/log.h"
+#include "core/thread-crt-ext.h"
+#include "core/thread-crt.h"
+#include "core/thread.h"
+
#include "eamio/eam-config.h"
#include "geninput/input-config.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
-#include "util/thread.h"
#include "util/winres.h"
HPROPSHEETPAGE
@@ -61,11 +66,22 @@ int main(int argc, char **argv)
wchar_t text[1024];
int max_light;
size_t i;
+ struct core_log_sink sink;
inst = GetModuleHandle(NULL);
- log_to_writer(log_writer_debug, NULL);
- log_to_external(log_impl_misc, log_impl_info, log_impl_warning, my_fatal);
+ core_thread_crt_ext_impl_set();
+
+ core_log_impl_set(
+ core_log_bt_log_misc,
+ core_log_bt_log_info,
+ core_log_bt_log_warning,
+ my_fatal);
+
+ core_log_sink_debug_open(&sink);
+
+ core_log_bt_init(&sink);
+ core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
usages_init(inst);
@@ -96,13 +112,17 @@ int main(int argc, char **argv)
}
}
- input_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
- input_init(crt_thread_create, crt_thread_join, crt_thread_destroy);
-
- eam_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
- eam_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy);
+ core_log_impl_assign(input_set_loggers);
+ input_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get());
+
+ core_log_impl_assign(eam_io_set_loggers);
+ eam_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get());
eam_io_config_api = eam_io_get_config_api();
// calculate these and check against the loaded config
diff --git a/src/main/config/snap.c b/src/main/config/snap.c
index 8981c686..6d8547ab 100644
--- a/src/main/config/snap.c
+++ b/src/main/config/snap.c
@@ -6,10 +6,11 @@
#include "config/snap.h"
+#include "core/log.h"
+
#include "geninput/hid-mgr.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/mem.h"
enum snap_control_heuristic { CONTROL_CENTERING_AXIS, CONTROL_MULTISWITCH };
diff --git a/src/main/config/usages.c b/src/main/config/usages.c
index 5e28ad9b..771772cd 100644
--- a/src/main/config/usages.c
+++ b/src/main/config/usages.c
@@ -9,8 +9,9 @@
#include "config/resource.h"
+#include "core/log.h"
+
#include "util/array.h"
-#include "util/log.h"
#include "util/str.h"
#include "util/winres.h"
diff --git a/src/main/core/Module.mk b/src/main/core/Module.mk
new file mode 100644
index 00000000..bd35e6d0
--- /dev/null
+++ b/src/main/core/Module.mk
@@ -0,0 +1,20 @@
+libs += core
+
+libs_core := \
+ util \
+
+src_core := \
+ log-bt-ext.c \
+ log-bt.c \
+ log-sink-async.c \
+ log-sink-debug.c \
+ log-sink-file.c \
+ log-sink-list.c \
+ log-sink-mutex.c \
+ log-sink-null.c \
+ log-sink-std.c \
+ log.c \
+ thread-crt-ext.c \
+ thread-crt.c \
+ thread.c \
+
diff --git a/src/main/core/log-bt-ext.c b/src/main/core/log-bt-ext.c
new file mode 100644
index 00000000..b1aa4f46
--- /dev/null
+++ b/src/main/core/log-bt-ext.c
@@ -0,0 +1,67 @@
+#include
+
+#include "core/log-bt.h"
+#include "core/log-sink-debug.h"
+#include "core/log-sink-file.h"
+#include "core/log-sink-list.h"
+#include "core/log-sink-mutex.h"
+#include "core/log-sink-std.h"
+#include "core/log.h"
+
+void core_log_bt_ext_impl_set()
+{
+ core_log_impl_set(
+ core_log_bt_log_misc,
+ core_log_bt_log_info,
+ core_log_bt_log_warning,
+ core_log_bt_log_fatal);
+}
+
+void core_log_bt_ext_init_with_stdout()
+{
+ struct core_log_sink sink;
+
+ core_log_sink_std_out_open(true, &sink);
+ core_log_bt_init(&sink);
+}
+
+void core_log_bt_ext_init_with_stderr()
+{
+ struct core_log_sink sink;
+
+ core_log_sink_std_err_open(true, &sink);
+ core_log_bt_init(&sink);
+}
+
+void core_log_bt_ext_init_with_debug()
+{
+ struct core_log_sink sink;
+
+ core_log_sink_debug_open(&sink);
+ core_log_bt_init(&sink);
+}
+
+void core_log_bt_ext_init_with_file(
+ const char *path, bool append, bool rotate, uint8_t max_rotations)
+{
+ struct core_log_sink sink;
+
+ core_log_sink_file_open(path, append, rotate, max_rotations, &sink);
+ core_log_bt_init(&sink);
+}
+
+void core_log_bt_ext_init_with_stdout_and_file(
+ const char *path, bool append, bool rotate, uint8_t max_rotations)
+{
+ struct core_log_sink sinks[2];
+ struct core_log_sink sink_composed;
+ struct core_log_sink sink_mutex;
+
+ core_log_sink_std_out_open(true, &sinks[0]);
+ core_log_sink_file_open(path, append, rotate, max_rotations, &sinks[1]);
+ core_log_sink_list_open(sinks, 2, &sink_composed);
+
+ core_log_sink_mutex_open(&sink_composed, &sink_mutex);
+
+ core_log_bt_init(&sink_mutex);
+}
\ No newline at end of file
diff --git a/src/main/core/log-bt-ext.h b/src/main/core/log-bt-ext.h
new file mode 100644
index 00000000..dcb9a9a6
--- /dev/null
+++ b/src/main/core/log-bt-ext.h
@@ -0,0 +1,59 @@
+#ifndef CORE_LOG_BT_EXT_H
+#define CORE_LOG_BT_EXT_H
+
+#include
+#include
+
+/**
+ * Set the current thread API implementation to use the bemanitools log
+ * implementation
+ */
+void core_log_bt_ext_impl_set();
+
+/**
+ * Helper to setup the bemanitools log implementation with a stdout sink.
+ */
+void core_log_bt_ext_init_with_stdout();
+
+/**
+ * Helper to setup the bemanitools log implementation with a stderr sink.
+ */
+void core_log_bt_ext_init_with_stderr();
+
+/**
+ * Helper to setup the bemanitools log implementation with a OutputDebugStr
+ * sink.
+ */
+void core_log_bt_ext_init_with_debug();
+
+/**
+ * Helper to setup the bemanitools log implementation with a file sink
+ *
+ * @param path Path to the log file to write the log output to
+ * @param append If true, then append to an existing file, false to overwrite
+ * any existing file
+ * @param rotate If true, rotates an existing log file and creates a new one
+ * for this session
+ * @param max_rotations Max number of rotations for the log files
+ */
+void core_log_bt_ext_init_with_file(
+ const char *path, bool append, bool rotate, uint8_t max_rotations);
+
+/**
+ * Helper to setup the bemanitools log implementation with a stdout and file
+ * sink
+ *
+ * Important: This combined sink is guarded by a mutex to avoid data races on
+ * logging to two different sinks.
+ *
+ * @param path Path to the log file to write the log output to
+ * @param append If true, then append to an existing file, false to overwrite
+ * any existing file
+ * @param rotate If true, rotates an existing log file and creates a new one
+ * for this session
+ * @param max_rotations Max number of rotations for the log files
+ */
+void core_log_bt_ext_init_with_stdout_and_file(
+ const char *path, bool append, bool rotate, uint8_t max_rotations);
+
+#endif
\ No newline at end of file
diff --git a/src/main/core/log-bt.c b/src/main/core/log-bt.c
new file mode 100644
index 00000000..fd868979
--- /dev/null
+++ b/src/main/core/log-bt.c
@@ -0,0 +1,129 @@
+#include
+#include
+#include
+
+#include "core/log-bt.h"
+#include "core/log-sink.h"
+#include "core/log.h"
+
+#include "util/mem.h"
+#include "util/str.h"
+
+static enum core_log_bt_log_level _core_log_bt_log_level;
+static struct core_log_sink *_core_log_bt_sink;
+
+static void _core_log_bt_vformat_write(
+ enum core_log_bt_log_level level,
+ const char *module,
+ const char *fmt,
+ va_list ap)
+{
+ static const char chars[] = "FFWIM";
+
+ char timestamp[64];
+ /* 64k so we can log data dumps of rs232 without crashing */
+ char msg[65536];
+ char line[65536];
+ int result;
+
+ time_t curtime;
+ struct tm *tm;
+
+ curtime = 0;
+ tm = NULL;
+
+ curtime = time(NULL);
+ tm = localtime(&curtime);
+
+ strftime(timestamp, sizeof(timestamp), "[%Y/%m/%d %H:%M:%S]", tm);
+
+ str_vformat(msg, sizeof(msg), fmt, ap);
+
+ result = str_format(
+ line,
+ sizeof(line),
+ "%s %c:%s: %s\n",
+ timestamp,
+ chars[level],
+ module,
+ msg);
+
+ _core_log_bt_sink->write(_core_log_bt_sink->ctx, line, result);
+}
+
+void core_log_bt_init(const struct core_log_sink *sink)
+{
+ if (sink == NULL) {
+ abort();
+ }
+
+ _core_log_bt_sink = xmalloc(sizeof(struct core_log_sink));
+ memcpy(_core_log_bt_sink, sink, sizeof(struct core_log_sink));
+
+ _core_log_bt_log_level = CORE_LOG_BT_LOG_LEVEL_OFF;
+}
+
+void core_log_bt_level_set(enum core_log_bt_log_level level)
+{
+ _core_log_bt_log_level = level;
+}
+
+void core_log_bt_fini()
+{
+ log_assert(_core_log_bt_sink);
+
+ _core_log_bt_sink->close(_core_log_bt_sink->ctx);
+
+ free(_core_log_bt_sink);
+}
+
+void core_log_bt_log_fatal(const char *module, const char *fmt, ...)
+{
+ va_list ap;
+
+ if (_core_log_bt_log_level >= CORE_LOG_BT_LOG_LEVEL_FATAL) {
+ va_start(ap, fmt);
+ _core_log_bt_vformat_write(
+ CORE_LOG_BT_LOG_LEVEL_FATAL, module, fmt, ap);
+ va_end(ap);
+ }
+}
+
+void core_log_bt_log_warning(const char *module, const char *fmt, ...)
+{
+ va_list ap;
+
+ if (_core_log_bt_log_level >= CORE_LOG_BT_LOG_LEVEL_WARNING) {
+ va_start(ap, fmt);
+ _core_log_bt_vformat_write(
+ CORE_LOG_BT_LOG_LEVEL_WARNING, module, fmt, ap);
+ va_end(ap);
+ }
+}
+
+void core_log_bt_log_info(const char *module, const char *fmt, ...)
+{
+ va_list ap;
+
+ if (_core_log_bt_log_level >= CORE_LOG_BT_LOG_LEVEL_INFO) {
+ va_start(ap, fmt);
+ _core_log_bt_vformat_write(CORE_LOG_BT_LOG_LEVEL_INFO, module, fmt, ap);
+ va_end(ap);
+ }
+}
+
+void core_log_bt_log_misc(const char *module, const char *fmt, ...)
+{
+ va_list ap;
+
+ if (_core_log_bt_log_level >= CORE_LOG_BT_LOG_LEVEL_MISC) {
+ va_start(ap, fmt);
+ _core_log_bt_vformat_write(CORE_LOG_BT_LOG_LEVEL_MISC, module, fmt, ap);
+ va_end(ap);
+ }
+}
+
+void core_log_bt_direct_sink_write(const char *chars, size_t nchars)
+{
+ _core_log_bt_sink->write(_core_log_bt_sink->ctx, chars, nchars);
+}
\ No newline at end of file
diff --git a/src/main/core/log-bt.h b/src/main/core/log-bt.h
new file mode 100644
index 00000000..2a8052f3
--- /dev/null
+++ b/src/main/core/log-bt.h
@@ -0,0 +1,87 @@
+#ifndef CORE_LOG_BT_H
+#define CORE_LOG_BT_H
+
+#include "core/log-sink.h"
+
+/**
+ * Log API implementation for games/applications without AVS
+ */
+
+enum core_log_bt_log_level {
+ CORE_LOG_BT_LOG_LEVEL_OFF = 0,
+ CORE_LOG_BT_LOG_LEVEL_FATAL = 1,
+ CORE_LOG_BT_LOG_LEVEL_WARNING = 2,
+ CORE_LOG_BT_LOG_LEVEL_INFO = 3,
+ CORE_LOG_BT_LOG_LEVEL_MISC = 4,
+};
+
+/**
+ * Initialize the logging backend
+ *
+ * This must be called as early as possible in your application to setup
+ * a logging sink according to your needs. Until this is finished, no
+ * log output is available.
+ *
+ * By default, logging is turned off entirely and must be enabled by setting
+ * a desired logging level explicitly.
+ *
+ * @param sink Pointer to a log sink implementation. The caller owns the memory
+ * of this.
+ */
+void core_log_bt_init(const struct core_log_sink *sink);
+
+/**
+ * Set the current logging level. This can be changed at any given time, e.g.
+ * to increase/decrease verbosity.
+ *
+ * @param level The logging level to set.
+ */
+void core_log_bt_level_set(enum core_log_bt_log_level level);
+
+/**
+ * Cleanup the logging backend.
+ *
+ * Ensure to call this on application exit and cleanup.
+ */
+void core_log_bt_fini();
+
+/**
+ * Implementation of the log API.
+ */
+void core_log_bt_log_fatal(const char *module, const char *fmt, ...);
+
+/**
+ * Implementation of the log API.
+ */
+void core_log_bt_log_warning(const char *module, const char *fmt, ...);
+
+/**
+ * Implementation of the log API.
+ */
+void core_log_bt_log_info(const char *module, const char *fmt, ...);
+
+/**
+ * Implementation of the log API.
+ */
+void core_log_bt_log_misc(const char *module, const char *fmt, ...);
+
+/**
+ * Allow AVS to by-pass the core log API/engine.
+ *
+ * This function must only be called by AVS in an appropriate log callback
+ * function that is passed to avs_boot.
+ *
+ * AVS has it's own logging engine and manages aspects such as async logging,
+ * log levels and decorating log messages.
+ *
+ * Thus, proper interoperability only requires the writer/sink part to be shared
+ * with AVS.
+ *
+ * @param chars Buffer with text data to write to the configured sinks. The
+ * buffer might contain several log messages separated by newline
+ * characters.
+ * @param nchars Number of chars to write to the sink.
+ */
+void core_log_bt_direct_sink_write(const char *chars, size_t nchars);
+
+#endif
\ No newline at end of file
diff --git a/src/main/core/log-sink-async.c b/src/main/core/log-sink-async.c
new file mode 100644
index 00000000..f327aad8
--- /dev/null
+++ b/src/main/core/log-sink-async.c
@@ -0,0 +1,23 @@
+#include
+
+#include "core/log-sink.h"
+
+static void
+_core_log_sink_file_write(void *ctx, const char *chars, size_t nchars)
+{
+ // TODO
+}
+
+static void _core_log_sink_file_close(void *ctx)
+{
+ // TODO
+}
+
+void core_log_sink_async_open(struct core_log_sink *sink)
+{
+ // TODO
+
+ sink->ctx = NULL;
+ sink->write = _core_log_sink_file_write;
+ sink->close = _core_log_sink_file_close;
+}
\ No newline at end of file
diff --git a/src/main/core/log-sink-async.h b/src/main/core/log-sink-async.h
new file mode 100644
index 00000000..47aa49e7
--- /dev/null
+++ b/src/main/core/log-sink-async.h
@@ -0,0 +1,19 @@
+#ifndef CORE_LOG_SINK_ASYNC_H
+#define CORE_LOG_SINK_ASYNC_H
+
+#include
+#include
+
+#include "core/log-sink.h"
+
+/**
+ * Open a async log sink
+ *
+ * The sink passes data to log to a separate thread which executes the actual
+ * logging of the data.
+ *
+ * @param sink Pointer to allocated memory that receives the opened sink
+ */
+void core_log_sink_async_open(struct core_log_sink *sink);
+
+#endif
\ No newline at end of file
diff --git a/src/main/core/log-sink-debug.c b/src/main/core/log-sink-debug.c
new file mode 100644
index 00000000..c1dd7a20
--- /dev/null
+++ b/src/main/core/log-sink-debug.c
@@ -0,0 +1,23 @@
+#include
+
+#include
+
+#include "core/log-sink.h"
+
+static void
+_core_log_sink_debug_write(void *ctx, const char *chars, size_t nchars)
+{
+ OutputDebugStringA(chars);
+}
+
+static void _core_log_sink_debug_close(void *ctx)
+{
+ // noop
+}
+
+void core_log_sink_debug_open(struct core_log_sink *sink)
+{
+ sink->ctx = NULL;
+ sink->write = _core_log_sink_debug_write;
+ sink->close = _core_log_sink_debug_close;
+}
\ No newline at end of file
diff --git a/src/main/core/log-sink-debug.h b/src/main/core/log-sink-debug.h
new file mode 100644
index 00000000..4c21d50c
--- /dev/null
+++ b/src/main/core/log-sink-debug.h
@@ -0,0 +1,15 @@
+#ifndef CORE_LOG_SINK_DEBUG_H
+#define CORE_LOG_SINK_DEBUG_H
+
+#include
+
+#include "core/log-sink.h"
+
+/**
+ * Open a log sink that uses OutputDebugStr
+ *
+ * @param sink Pointer to allocated memory that receives the opened sink
+ */
+void core_log_sink_debug_open(struct core_log_sink *sink);
+
+#endif
\ No newline at end of file
diff --git a/src/main/core/log-sink-file.c b/src/main/core/log-sink-file.c
new file mode 100644
index 00000000..f2ca188e
--- /dev/null
+++ b/src/main/core/log-sink-file.c
@@ -0,0 +1,92 @@
+#include
+
+#include
+#include
+#include
+#include
+
+#include "core/log-sink.h"
+
+#include "util/fs.h"
+#include "util/str.h"
+
+static void _core_log_sink_file_rotate(const char *path, uint8_t max_rotations)
+{
+ uint8_t i;
+ char rotate_file[MAX_PATH];
+ char rotate_file_next[MAX_PATH];
+ char version[8];
+ char version_next[8];
+
+ for (i = max_rotations; i > 0; i++) {
+ str_cpy(rotate_file, sizeof(rotate_file), path);
+ str_cpy(rotate_file_next, sizeof(rotate_file_next), path);
+
+ if (i - 1 != 0) {
+ sprintf(version, ".%d", i);
+ } else {
+ memset(version, 0, sizeof(version));
+ }
+
+ sprintf(version_next, ".%d", i);
+
+ str_cat(rotate_file, sizeof(rotate_file), version);
+ str_cat(rotate_file_next, sizeof(rotate_file_next), version_next);
+
+ if (path_exists(rotate_file)) {
+ CopyFile(rotate_file, rotate_file_next, FALSE);
+ }
+ }
+}
+
+static void
+_core_log_sink_file_write(void *ctx, const char *chars, size_t nchars)
+{
+ FILE *file;
+
+ file = (FILE *) ctx;
+
+ fwrite(chars, 1, nchars, file);
+}
+
+static void _core_log_sink_file_close(void *ctx)
+{
+ FILE *file;
+
+ file = (FILE *) ctx;
+
+ fflush(file);
+ fclose(file);
+}
+
+void core_log_sink_file_open(
+ const char *path,
+ bool append,
+ bool rotate,
+ uint8_t max_rotations,
+ struct core_log_sink *sink)
+{
+ FILE *file;
+
+ if (rotate) {
+ _core_log_sink_file_rotate(path, max_rotations);
+
+ // Appending doesn't matter when file is rotated anyway
+ file = fopen(path, "w+");
+ } else {
+ if (append) {
+ file = fopen(path, "a+");
+ } else {
+ file = fopen(path, "w+");
+ }
+ }
+
+ if (!file) {
+ printf("Cannot open log file: %s", path);
+ abort();
+ }
+
+ sink->ctx = (void *) file;
+ sink->write = _core_log_sink_file_write;
+ sink->close = _core_log_sink_file_close;
+}
\ No newline at end of file
diff --git a/src/main/core/log-sink-file.h b/src/main/core/log-sink-file.h
new file mode 100644
index 00000000..968a1fed
--- /dev/null
+++ b/src/main/core/log-sink-file.h
@@ -0,0 +1,28 @@
+#ifndef CORE_LOG_SINK_FILE_H
+#define CORE_LOG_SINK_FILE_H
+
+#include
+#include
+#include
+
+#include "core/log-sink.h"
+
+/**
+ * Open a log sink writing data to a file
+ *
+ * @param path Path to the log file to write the log output to
+ * @param append If true, then append to an existing file, false to overwrite
+ * any existing file
+ * @param rotate If true, rotates an existing log file and creates a new one
+ * for this session
+ * @param max_rotations Max number of rotations for the log files
+ * @param sink Pointer to allocated memory that receives the opened sink
+ */
+void core_log_sink_file_open(
+ const char *path,
+ bool append,
+ bool rotate,
+ uint8_t max_rotations,
+ struct core_log_sink *sink);
+
+#endif
\ No newline at end of file
diff --git a/src/main/core/log-sink-list.c b/src/main/core/log-sink-list.c
new file mode 100644
index 00000000..38e32112
--- /dev/null
+++ b/src/main/core/log-sink-list.c
@@ -0,0 +1,66 @@
+#include
+#include
+
+#include "core/log-sink-list.h"
+#include "core/log-sink.h"
+
+#include "util/mem.h"
+
+#define MAX_SINKS 8
+
+struct core_log_sink_list {
+ struct core_log_sink entries[MAX_SINKS];
+ uint8_t num;
+};
+
+static void
+_core_log_sink_list_write(void *ctx, const char *chars, size_t nchars)
+{
+ struct core_log_sink_list *sink_list;
+ int i;
+
+ sink_list = (struct core_log_sink_list *) ctx;
+
+ for (i = 0; i < sink_list->num; i++) {
+ sink_list->entries[i].write(sink_list->entries[i].ctx, chars, nchars);
+ }
+}
+
+static void _core_log_sink_list_close(void *ctx)
+{
+ struct core_log_sink_list *sink_list;
+ int i;
+
+ sink_list = (struct core_log_sink_list *) ctx;
+
+ for (i = 0; i < sink_list->num; i++) {
+ sink_list->entries[i].close(sink_list->entries[i].ctx);
+ }
+
+ free(sink_list);
+}
+
+void core_log_sink_list_open(
+ const struct core_log_sink *entry, uint8_t num, struct core_log_sink *sink)
+{
+ struct core_log_sink_list *sink_list;
+ int i;
+
+ if (num > MAX_SINKS) {
+ abort();
+ }
+
+ sink_list = xmalloc(sizeof(struct core_log_sink_list));
+
+ for (i = 0; i < num; i++) {
+ sink_list->entries[i].ctx = entry[i].ctx;
+ sink_list->entries[i].write = entry[i].write;
+ sink_list->entries[i].close = entry[i].close;
+ }
+
+ sink_list->num = num;
+
+ sink->ctx = (void *) sink_list;
+ sink->write = _core_log_sink_list_write;
+ sink->close = _core_log_sink_list_close;
+}
\ No newline at end of file
diff --git a/src/main/core/log-sink-list.h b/src/main/core/log-sink-list.h
new file mode 100644
index 00000000..f1e99f35
--- /dev/null
+++ b/src/main/core/log-sink-list.h
@@ -0,0 +1,24 @@
+#ifndef CORE_LOG_SINK_LIST_H
+#define CORE_LOG_SINK_LIST_H
+
+#include
+#include
+
+#include "core/log-sink.h"
+
+/**
+ * Combine multiple log sinks into a list of sinks.
+ *
+ * Upon invoking a list sink, all sinks contained within the list are
+ * being invoked in the configured order.
+ *
+ * @param entry A pointer to allocated memory with a sequence of opened sinks
+ * that you want to add to the list. Ownership of these sinks
+ * is transferred, i.e. closing the list sink closes its children.
+ * @param num The number of elements in the sequence of opened sinks pointed to.
+ * @param sink Pointer to allocated memory that receives the opened sink
+ */
+void core_log_sink_list_open(
+ const struct core_log_sink *entry, uint8_t num, struct core_log_sink *sink);
+
+#endif
\ No newline at end of file
diff --git a/src/main/core/log-sink-mutex.c b/src/main/core/log-sink-mutex.c
new file mode 100644
index 00000000..13c8b207
--- /dev/null
+++ b/src/main/core/log-sink-mutex.c
@@ -0,0 +1,53 @@
+#include
+
+#include
+
+#include "core/log-sink.h"
+
+#include "util/mem.h"
+
+struct core_log_sink_mutex_ctx {
+ struct core_log_sink *child;
+ HANDLE mutex;
+};
+
+static void
+_core_log_sink_mutex_write(void *ctx_, const char *chars, size_t nchars)
+{
+ struct core_log_sink_mutex_ctx *ctx;
+
+ ctx = (struct core_log_sink_mutex_ctx *) ctx_;
+
+ WaitForSingleObject(ctx->mutex, INFINITE);
+
+ ctx->child->write(ctx->child->ctx, chars, nchars);
+
+ ReleaseMutex(ctx->mutex);
+}
+
+static void _core_log_sink_mutex_close(void *ctx_)
+{
+ struct core_log_sink_mutex_ctx *ctx;
+
+ ctx = (struct core_log_sink_mutex_ctx *) ctx_;
+
+ CloseHandle(ctx->mutex);
+
+ ctx->child->close(ctx->child->ctx);
+ free(ctx);
+}
+
+void core_log_sink_mutex_open(
+ const struct core_log_sink *child_sink, struct core_log_sink *sink)
+{
+ struct core_log_sink_mutex_ctx *ctx;
+
+ ctx = xmalloc(sizeof(struct core_log_sink_mutex_ctx));
+
+ memcpy(ctx->child, child_sink, sizeof(struct core_log_sink));
+ ctx->mutex = CreateMutex(NULL, FALSE, NULL);
+
+ sink->ctx = ctx;
+ sink->write = _core_log_sink_mutex_write;
+ sink->close = _core_log_sink_mutex_close;
+}
\ No newline at end of file
diff --git a/src/main/core/log-sink-mutex.h b/src/main/core/log-sink-mutex.h
new file mode 100644
index 00000000..e30357e4
--- /dev/null
+++ b/src/main/core/log-sink-mutex.h
@@ -0,0 +1,21 @@
+#ifndef CORE_LOG_SINK_MUTEX_H
+#define CORE_LOG_SINK_MUTEX_H
+
+#include
+
+#include "core/log-sink.h"
+
+/**
+ * Create a sink that surrounds another sink with a mutex.
+ *
+ * Use this to make other sink implementations thread-safe.
+ *
+ * @param child_sink Another opened sink to surround with the mutex. Ownership
+ * of the sink is transferred, i.e. closing the mutex sink
+ * also closes the wrapped child sink.
+ * @param sink Pointer to allocated memory that receives the opened sink
+ */
+void core_log_sink_mutex_open(
+ const struct core_log_sink *child_sink, struct core_log_sink *sink);
+
+#endif
\ No newline at end of file
diff --git a/src/main/core/log-sink-null.c b/src/main/core/log-sink-null.c
new file mode 100644
index 00000000..7655a208
--- /dev/null
+++ b/src/main/core/log-sink-null.c
@@ -0,0 +1,21 @@
+#include
+
+#include "core/log-sink.h"
+
+static void
+_core_log_sink_null_write(void *ctx, const char *chars, size_t nchars)
+{
+ // noop
+}
+
+static void _core_log_sink_null_close(void *ctx)
+{
+ // noop
+}
+
+void core_log_sink_null_open(struct core_log_sink *sink)
+{
+ sink->ctx = NULL;
+ sink->write = _core_log_sink_null_write;
+ sink->close = _core_log_sink_null_close;
+}
\ No newline at end of file
diff --git a/src/main/core/log-sink-null.h b/src/main/core/log-sink-null.h
new file mode 100644
index 00000000..ebd2babe
--- /dev/null
+++ b/src/main/core/log-sink-null.h
@@ -0,0 +1,17 @@
+#ifndef CORE_LOG_SINK_NULL_H
+#define CORE_LOG_SINK_NULL_H
+
+#include
+
+#include "core/log-sink.h"
+
+/**
+ * Create a null/dummy sink.
+ *
+ * Use this to disable any logging entirely.
+ *
+ * @param sink Pointer to allocated memory that receives the opened sink
+ */
+void core_log_sink_null_open(struct core_log_sink *sink);
+
+#endif
\ No newline at end of file
diff --git a/src/main/core/log-sink-std.c b/src/main/core/log-sink-std.c
new file mode 100644
index 00000000..197fd12a
--- /dev/null
+++ b/src/main/core/log-sink-std.c
@@ -0,0 +1,193 @@
+#include
+
+#include
+
+#include "core/log-sink.h"
+
+#include "util/mem.h"
+
+struct core_log_sink_std_ctx {
+ HANDLE handle;
+ bool color;
+};
+
+static char _core_log_sink_std_determine_color(const char *str)
+{
+ /* Add some color to make spotting warnings/errors easier.
+ Based on debug output level identifier. */
+
+ /* Avoids colored output on strings like "Windows" */
+ if (str[1] != ':') {
+ return 15;
+ }
+
+ switch (str[0]) {
+ /* green */
+ case 'M':
+ return 10;
+ /* blue */
+ case 'I':
+ return 9;
+ /* yellow */
+ case 'W':
+ return 14;
+ /* red */
+ case 'F':
+ return 12;
+ /* default console color */
+ default:
+ return 15;
+ }
+}
+
+static size_t _core_log_sink_std_msg_coloring_len(const char *str)
+{
+ // Expected format example: "I:boot: my log message"
+
+ const char *ptr;
+ size_t len;
+ int colon_count;
+
+ ptr = str;
+ len = 0;
+ colon_count = 0;
+
+ while (true) {
+ // End of string = invalid log format
+ if (*ptr == '\0') {
+ return 0;
+ }
+
+ if (*ptr == ':') {
+ colon_count++;
+ }
+
+ if (colon_count == 2) {
+ // Skip current colon, next char is a space
+ return len + 1;
+ }
+
+ len++;
+ ptr++;
+ }
+
+ return 0;
+}
+
+static void
+_core_log_sink_std_write(void *ctx_, const char *chars, size_t nchars)
+{
+ static const size_t timestamp_len = strlen("[----/--/-- --:--:--]");
+
+ struct core_log_sink_std_ctx *ctx;
+
+ char color;
+ size_t color_len;
+ size_t msg_len;
+ const char *msg_start;
+ const char *msg_end;
+ DWORD written;
+ DWORD write_pos;
+
+ ctx = (struct core_log_sink_std_ctx *) ctx_;
+
+ if (ctx->color) {
+ write_pos = 0;
+
+ // Support multiple buffered log messages, e.g. from the AVS logging
+ // engine
+ while (write_pos < nchars) {
+ // Expects the AVS timestamp format
+ msg_start = chars + timestamp_len + 1; // +1 is the space
+
+ color_len = _core_log_sink_std_msg_coloring_len(msg_start);
+
+ // Check if we could detect which part to color, otherwise just
+ // write the whole log message without any coloring logic
+ if (color_len > 0) {
+ color = _core_log_sink_std_determine_color(msg_start);
+
+ // Timestamp
+ WriteConsole(
+ ctx->handle, chars, timestamp_len + 1, &written, NULL);
+ write_pos += written;
+ chars += written;
+
+ // Log level + module colored
+ SetConsoleTextAttribute(ctx->handle, color);
+ WriteConsole(ctx->handle, chars, color_len, &written, NULL);
+ write_pos += written;
+ chars += written;
+ SetConsoleTextAttribute(ctx->handle, 15);
+
+ msg_end = strchr(chars, '\n');
+
+ if (msg_end != NULL) {
+ msg_len = msg_end - chars;
+
+ // Write \n as well
+ msg_len++;
+
+ // Write actual message non colored
+ WriteConsole(ctx->handle, chars, msg_len, &written, NULL);
+ write_pos += written;
+ chars += written;
+ } else {
+ WriteConsole(
+ ctx->handle, chars, nchars - write_pos, &written, NULL);
+ write_pos += written;
+ chars += written;
+ }
+ } else {
+ WriteConsole(
+ ctx->handle,
+ chars + write_pos,
+ nchars - write_pos,
+ &written,
+ NULL);
+ write_pos += written;
+ }
+ }
+ } else {
+ WriteConsole(ctx->handle, chars, nchars, &written, NULL);
+ }
+}
+
+static void _core_log_sink_std_close(void *ctx_)
+{
+ struct core_log_sink_std_ctx *ctx;
+
+ ctx = (struct core_log_sink_std_ctx *) ctx_;
+
+ // Remark: Don't close the ctx->handle, see win API docs
+
+ free(ctx);
+}
+
+void core_log_sink_std_out_open(bool color, struct core_log_sink *sink)
+{
+ struct core_log_sink_std_ctx *ctx;
+
+ ctx = xmalloc(sizeof(struct core_log_sink_std_ctx));
+
+ ctx->handle = GetStdHandle(STD_OUTPUT_HANDLE);
+ ctx->color = color;
+
+ sink->ctx = (void *) ctx;
+ sink->write = _core_log_sink_std_write;
+ sink->close = _core_log_sink_std_close;
+}
+
+void core_log_sink_std_err_open(bool color, struct core_log_sink *sink)
+{
+ struct core_log_sink_std_ctx *ctx;
+
+ ctx = xmalloc(sizeof(struct core_log_sink_std_ctx));
+
+ ctx->handle = GetStdHandle(STD_ERROR_HANDLE);
+ ctx->color = color;
+
+ sink->ctx = (void *) ctx;
+ sink->write = _core_log_sink_std_write;
+ sink->close = _core_log_sink_std_close;
+}
\ No newline at end of file
diff --git a/src/main/core/log-sink-std.h b/src/main/core/log-sink-std.h
new file mode 100644
index 00000000..e0e006bf
--- /dev/null
+++ b/src/main/core/log-sink-std.h
@@ -0,0 +1,24 @@
+#ifndef CORE_LOG_SINK_STD_H
+#define CORE_LOG_SINK_STD_H
+
+#include
+
+#include "core/log-sink.h"
+
+/**
+ * Create a sink that writes to stdout.
+ *
+ * @param color If true, messages are colored by log level.
+ * @param sink Pointer to allocated memory that receives the opened sink
+ */
+void core_log_sink_std_out_open(bool color, struct core_log_sink *sink);
+
+/**
+ * Create a sink that writes to stderr.
+ *
+ * @param color If true, messages are colored by log level.
+ * @param sink Pointer to allocated memory that receives the opened sink
+ */
+void core_log_sink_std_err_open(bool color, struct core_log_sink *sink);
+
+#endif
\ No newline at end of file
diff --git a/src/main/core/log-sink.h b/src/main/core/log-sink.h
new file mode 100644
index 00000000..7fdd42fb
--- /dev/null
+++ b/src/main/core/log-sink.h
@@ -0,0 +1,45 @@
+#ifndef CORE_LOG_SINK_H
+#define CORE_LOG_SINK_H
+
+#include
+
+/**
+ * Write function for a log sink implementation.
+ *
+ * Write the given data to your target output destination.
+ *
+ * @param ctx Context defined by the implementation when opening the sink.
+ * @param chars Buffer with text data to log. This can contain partial data of
+ * a single log line, a full log line terminated by a newline
+ * character or multiple log lines (each terminated by a newline
+ * character).
+ * @param nchars Number of characters to write.
+ */
+typedef void (*core_log_sink_write_t)(
+ void *ctx, const char *chars, size_t nchars);
+
+/**
+ * Close your log sink and cleanup resources
+ *
+ * Depending on your implementation, you might want to flush any
+ * outstanding/buffered data.
+ *
+ * @param ctx Context defined by the implementation when opening the sink.
+ */
+typedef void (*core_log_sink_close_t)(void *ctx);
+
+/**
+ * Log sink structure.
+ *
+ * This must be set-up and populated when opening your log sink implementation.
+ * The ctx field contains any arbitrary data that you need for your log sink
+ * to operate, e.g. a file handle, additional buffers etc. Make sure these
+ * resources are cleaned up upon closing the sink.
+ */
+struct core_log_sink {
+ void *ctx;
+ core_log_sink_write_t write;
+ core_log_sink_close_t close;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/main/core/log.c b/src/main/core/log.c
new file mode 100644
index 00000000..9d2d6d76
--- /dev/null
+++ b/src/main/core/log.c
@@ -0,0 +1,74 @@
+#include
+
+#include "core/log.h"
+
+core_log_message_t _core_log_misc_impl;
+core_log_message_t _core_log_info_impl;
+core_log_message_t _core_log_warning_impl;
+core_log_message_t _core_log_fatal_impl;
+
+void core_log_impl_set(
+ core_log_message_t misc,
+ core_log_message_t info,
+ core_log_message_t warning,
+ core_log_message_t fatal)
+{
+ if (misc == NULL || info == NULL || warning == NULL || fatal == NULL) {
+ abort();
+ }
+
+ _core_log_misc_impl = misc;
+ _core_log_info_impl = info;
+ _core_log_warning_impl = warning;
+ _core_log_fatal_impl = fatal;
+}
+
+void core_log_impl_assign(core_log_impl_set_t impl_set)
+{
+ if (_core_log_misc_impl == NULL || _core_log_info_impl == NULL ||
+ _core_log_warning_impl == NULL || _core_log_fatal_impl == NULL) {
+ abort();
+ }
+
+ impl_set(
+ _core_log_misc_impl,
+ _core_log_info_impl,
+ _core_log_warning_impl,
+ _core_log_fatal_impl);
+}
+
+core_log_message_t core_log_misc_impl_get()
+{
+ if (_core_log_misc_impl == NULL) {
+ abort();
+ }
+
+ return _core_log_misc_impl;
+}
+
+core_log_message_t core_log_info_impl_get()
+{
+ if (_core_log_info_impl == NULL) {
+ abort();
+ }
+
+ return _core_log_info_impl;
+}
+
+core_log_message_t core_log_warning_impl_get()
+{
+ if (_core_log_warning_impl == NULL) {
+ abort();
+ }
+
+ return _core_log_warning_impl;
+}
+
+core_log_message_t core_log_fatal_impl_get()
+{
+ if (_core_log_fatal_impl == NULL) {
+ abort();
+ }
+
+ return _core_log_fatal_impl;
+}
\ No newline at end of file
diff --git a/src/main/core/log.h b/src/main/core/log.h
new file mode 100644
index 00000000..5b5cd9da
--- /dev/null
+++ b/src/main/core/log.h
@@ -0,0 +1,197 @@
+#ifndef CORE_LOG_H
+#define CORE_LOG_H
+
+#include
+#include
+
+#include "util/defs.h"
+
+/**
+ * The core log API of bemanitools.
+ *
+ * To a large extent, this reflects the AVS logging API and allows for swapping
+ * out the backends with different implementations. Most games should have some
+ * version of the AVS API available while some (legacy) games do not. These
+ * can use a bemanitools private logging implementation by configuring it
+ * in the bootstrapping process.
+ */
+
+/* BUILD_MODULE is passed in as a command-line #define by the makefile */
+
+#ifndef LOG_MODULE
+#define LOG_MODULE STRINGIFY(BUILD_MODULE)
+#endif
+
+/**
+ * Log a message on misc level
+ *
+ * Always use this interface in your application which hides the currently
+ * configured implementation.
+ *
+ * The macro is required to make things work with varargs.
+ * The log message is only printed if the log level is set to misc
+ *
+ * @param fmt printf format string
+ * @param ... Additional arguments according to the specified arguments in the
+ * printf format string
+ */
+#define log_misc(...) _core_log_misc_impl(LOG_MODULE, __VA_ARGS__)
+
+/**
+ * Log a message on info level
+ *
+ * Always use this interface in your application which hides the currently
+ * configured implementation.
+ *
+ * The macro is required to make things work with varargs.
+ * The log message is only printed if the log level is set to info or lower
+ *
+ * @param fmt printf format string
+ * @param ... Additional arguments according to the specified arguments in the
+ * printf format string
+ */
+#define log_info(...) _core_log_info_impl(LOG_MODULE, __VA_ARGS__)
+
+/**
+ * Log a message on warning level
+ *
+ * Always use this interface in your application which hides the currently
+ * configured implementation.
+ *
+ * The macro is required to make things work with varargs.
+ * The log message is only printed if the log level is set to warning or lower
+ *
+ * @param fmt printf format string
+ * @param ... Additional arguments according to the specified arguments in the
+ * printf format string
+ */
+#define log_warning(...) _core_log_warning_impl(LOG_MODULE, __VA_ARGS__)
+
+/**
+ * Log a message on fatal level
+ *
+ * Always use this interface in your application which hides the currently
+ * configured implementation.
+ *
+ * The macro is required to make things work with varargs.
+ * The log message is only printed if the log level is set to fatal.
+ *
+ * This call will also terminate the application.
+ *
+ * @param fmt printf format string
+ * @param ... Additional arguments according to the specified arguments in the
+ * printf format string
+ */
+#define log_fatal(...) \
+ do { \
+ _core_log_fatal_impl(LOG_MODULE, __VA_ARGS__); \
+ abort(); \
+ } while (0)
+
+/**
+ * Log a message and terminate the application if given condition fails
+ *
+ * Always use this interface in your application which hides the currently
+ * configured implementation.
+ *
+ * The macro is required to make things work with varargs.
+ *
+ * @param x Condition to evaluate. If false, the application terminates
+ */
+#define log_assert(x) \
+ do { \
+ if (!(x)) { \
+ _core_log_fatal_impl( \
+ "assert", \
+ "%s:%d: function `%s'", \
+ __FILE__, \
+ __LINE__, \
+ __FUNCTION__); \
+ abort(); \
+ } \
+ } while (0)
+
+/**
+ * Log a message in an exception handler
+ *
+ * Only use this function in an exception handler, e.g. for stack traces. It
+ * logs the message on fatal level but does not terminate.
+ *
+ * @param fmt printf format string
+ * @param ... Additional arguments according to the specified arguments in the
+ * printf format string
+ */
+#define log_exception_handler(...) \
+ _core_log_fatal_impl("exception", __VA_ARGS__)
+
+typedef void (*core_log_message_t)(const char *module, const char *fmt, ...);
+
+typedef void (*core_log_impl_set_t)(
+ core_log_message_t misc,
+ core_log_message_t info,
+ core_log_message_t warning,
+ core_log_message_t fatal);
+
+/**
+ * Configure the log API implementations
+ *
+ * Advised to do this as early in your application/library module as possible
+ * as calls to the getter functions below will return the currently configured
+ * implementations.
+ *
+ * @param misc Pointer to a function implementing logging on misc level
+ * @param info Pointer to a function implementing logging on info level
+ * @param warning Pointer to a function implementing logging on warning level
+ * @param fatal Pointer to a function implementing logging on fatal level
+ */
+void core_log_impl_set(
+ core_log_message_t misc,
+ core_log_message_t info,
+ core_log_message_t warning,
+ core_log_message_t fatal);
+
+/**
+ * Supporting function to inject/assign the currently set implementation
+ * with the given setter function.
+ *
+ * @param impl_set Setter function to call with the currently configured log
+ * function implementations
+ */
+void core_log_impl_assign(core_log_impl_set_t impl_set);
+
+/**
+ * Get the currently configured implementation of the misc level log function
+ *
+ * @return Pointer to the currently configured implementation of the function
+ */
+core_log_message_t core_log_misc_impl_get();
+
+/**
+ * Get the currently configured implementation of the info level log function
+ *
+ * @return Pointer to the currently configured implementation of the function
+ */
+core_log_message_t core_log_info_impl_get();
+
+/**
+ * Get the currently configured implementation of the warning level log function
+ *
+ * @return Pointer to the currently configured implementation of the function
+ */
+core_log_message_t core_log_warning_impl_get();
+
+/**
+ * Get the currently configured implementation of the fatal level log function
+ *
+ * @return Pointer to the currently configured implementation of the function
+ */
+core_log_message_t core_log_fatal_impl_get();
+
+// Do not use these directly.
+// These are only here to allow usage in the macros above.
+extern core_log_message_t _core_log_misc_impl;
+extern core_log_message_t _core_log_info_impl;
+extern core_log_message_t _core_log_warning_impl;
+extern core_log_message_t _core_log_fatal_impl;
+
+#endif
\ No newline at end of file
diff --git a/src/main/core/thread-crt-ext.c b/src/main/core/thread-crt-ext.c
new file mode 100644
index 00000000..eb403ade
--- /dev/null
+++ b/src/main/core/thread-crt-ext.c
@@ -0,0 +1,8 @@
+#include "core/thread-crt.h"
+#include "core/thread.h"
+
+void core_thread_crt_ext_impl_set()
+{
+ core_thread_impl_set(
+ core_thread_crt_create, core_thread_crt_join, core_thread_crt_destroy);
+}
\ No newline at end of file
diff --git a/src/main/core/thread-crt-ext.h b/src/main/core/thread-crt-ext.h
new file mode 100644
index 00000000..a17b29b6
--- /dev/null
+++ b/src/main/core/thread-crt-ext.h
@@ -0,0 +1,9 @@
+#ifndef CORE_THREAD_CRT_EXT_H
+#define CORE_THREAD_CRT_EXT_H
+
+/**
+ * Set the current thread API implementation to use the C runtime thread API
+ */
+void core_thread_crt_ext_impl_set();
+
+#endif
\ No newline at end of file
diff --git a/src/main/util/thread.c b/src/main/core/thread-crt.c
similarity index 54%
rename from src/main/util/thread.c
rename to src/main/core/thread-crt.c
index daa82677..0251cf12 100644
--- a/src/main/util/thread.c
+++ b/src/main/core/thread-crt.c
@@ -4,8 +4,10 @@
#include
#include
+#include "core/thread-crt.h"
+#include "core/thread.h"
+
#include "util/defs.h"
-#include "util/thread.h"
struct shim_ctx {
HANDLE barrier;
@@ -13,10 +15,6 @@ struct shim_ctx {
void *ctx;
};
-thread_create_t thread_impl_create = crt_thread_create;
-thread_join_t thread_impl_join = crt_thread_join;
-thread_destroy_t thread_impl_destroy = crt_thread_destroy;
-
static unsigned int STDCALL crt_thread_shim(void *outer_ctx)
{
struct shim_ctx *sctx = outer_ctx;
@@ -31,7 +29,7 @@ static unsigned int STDCALL crt_thread_shim(void *outer_ctx)
return proc(inner_ctx);
}
-int crt_thread_create(
+int core_thread_crt_create(
int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority)
{
struct shim_ctx sctx;
@@ -49,12 +47,12 @@ int crt_thread_create(
return (int) thread_id;
}
-void crt_thread_destroy(int thread_id)
+void core_thread_crt_destroy(int thread_id)
{
CloseHandle((HANDLE) (uintptr_t) thread_id);
}
-void crt_thread_join(int thread_id, int *result)
+void core_thread_crt_join(int thread_id, int *result)
{
WaitForSingleObject((HANDLE) (uintptr_t) thread_id, INFINITE);
@@ -62,31 +60,3 @@ void crt_thread_join(int thread_id, int *result)
GetExitCodeThread((HANDLE) (uintptr_t) thread_id, (DWORD *) result);
}
}
-
-void thread_api_init(
- thread_create_t create, thread_join_t join, thread_destroy_t destroy)
-{
- if (create == NULL || join == NULL || destroy == NULL) {
- abort();
- }
-
- thread_impl_create = create;
- thread_impl_join = join;
- thread_impl_destroy = destroy;
-}
-
-int thread_create(
- int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority)
-{
- return thread_impl_create(proc, ctx, stack_sz, priority);
-}
-
-void thread_join(int thread_id, int *result)
-{
- thread_impl_join(thread_id, result);
-}
-
-void thread_destroy(int thread_id)
-{
- thread_impl_destroy(thread_id);
-}
diff --git a/src/main/core/thread-crt.h b/src/main/core/thread-crt.h
new file mode 100644
index 00000000..e9c1e8c0
--- /dev/null
+++ b/src/main/core/thread-crt.h
@@ -0,0 +1,15 @@
+#ifndef CORE_THREAD_CRT_H
+#define CORE_THREAD_CRT_H
+
+#include
+
+/**
+ * Thread API implementation using the C runtime API
+ */
+
+int core_thread_crt_create(
+ int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority);
+void core_thread_crt_join(int thread_id, int *result);
+void core_thread_crt_destroy(int thread_id);
+
+#endif
diff --git a/src/main/core/thread.c b/src/main/core/thread.c
new file mode 100644
index 00000000..f4e5bfeb
--- /dev/null
+++ b/src/main/core/thread.c
@@ -0,0 +1,78 @@
+#include
+
+#include "core/log.h"
+#include "core/thread.h"
+
+core_thread_create_t core_thread_create_impl;
+core_thread_join_t core_thread_join_impl;
+core_thread_destroy_t core_thread_destroy_impl;
+
+int core_thread_create(
+ int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority)
+{
+ log_assert(core_thread_create_impl);
+
+ return core_thread_create_impl(proc, ctx, stack_sz, priority);
+}
+
+void core_thread_join(int thread_id, int *result)
+{
+ log_assert(core_thread_join_impl);
+
+ core_thread_join_impl(thread_id, result);
+}
+
+void core_thread_destroy(int thread_id)
+{
+ log_assert(core_thread_destroy_impl);
+
+ core_thread_destroy_impl(thread_id);
+}
+
+void core_thread_impl_set(
+ core_thread_create_t create,
+ core_thread_join_t join,
+ core_thread_destroy_t destroy)
+{
+ if (create == NULL || join == NULL || destroy == NULL) {
+ abort();
+ }
+
+ core_thread_create_impl = create;
+ core_thread_join_impl = join;
+ core_thread_destroy_impl = destroy;
+}
+
+void core_thread_impl_assign(core_thread_impl_set_t impl_set)
+{
+ if (core_thread_create_impl == NULL || core_thread_join_impl == NULL ||
+ core_thread_destroy_impl == NULL) {
+ abort();
+ }
+
+ impl_set(
+ core_thread_create_impl,
+ core_thread_join_impl,
+ core_thread_destroy_impl);
+}
+
+core_thread_create_t core_thread_create_impl_get()
+{
+ log_assert(core_thread_create_impl);
+
+ return core_thread_create_impl;
+}
+
+core_thread_join_t core_thread_join_impl_get()
+{
+ log_assert(core_thread_join_impl);
+
+ return core_thread_join_impl;
+}
+
+core_thread_destroy_t core_thread_destroy_impl_get()
+{
+ log_assert(core_thread_destroy_impl);
+
+ return core_thread_destroy_impl;
+}
diff --git a/src/main/core/thread.h b/src/main/core/thread.h
new file mode 100644
index 00000000..88115665
--- /dev/null
+++ b/src/main/core/thread.h
@@ -0,0 +1,117 @@
+#ifndef CORE_THREAD_H
+#define CORE_THREAD_H
+
+#include
+
+/**
+ * The core thread API of bemanitools.
+ *
+ * This essentially reflects the AVS threading API and allows for swapping out
+ * the backends with different implementations. Most games should have some
+ * version of the AVS API available while some (legacy) games do not. These
+ * can use a bemanitools private threading implementation by configuring it
+ * in the bootstrapping process.
+ */
+
+/**
+ * Create a thread
+ *
+ * Always use this interface in your application which hides the currently
+ * configured implementation.
+ *
+ * @param proc The function to run in a separate thread
+ * @param ctx Additional data to pass to the function as a parameter
+ * @param stack_sz The stack size to allocate for the thread in bytes
+ * @param priority The thread's priority
+ * @return The ID of the thread once created and started
+ */
+int core_thread_create(
+ int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority);
+
+/**
+ * Wait for a thread to finish
+ *
+ * Always use this interface in your application which hides the currently
+ * configured implementation.
+ *
+ * The caller of this function blocks until the thread has finished executing.
+ *
+ * @param thread_id ID of the thread to wait for
+ * @param result Pointer to a variable to write the return value of the function
+ * the thread executed to
+ */
+void core_thread_join(int thread_id, int *result);
+
+/**
+ * Destroy a thread
+ *
+ * Always use this interface in your application which hides the currently
+ * configured implementation.
+ *
+ * The thread must have finished execution before calling this. It is advised
+ * to make threads terminate their execution flow, join them and destroy.
+ *
+ * @param thread_id The ID of the thread to destroy.
+ */
+void core_thread_destroy(int thread_id);
+
+typedef int (*core_thread_create_t)(
+ int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority);
+typedef void (*core_thread_join_t)(int thread_id, int *result);
+typedef void (*core_thread_destroy_t)(int thread_id);
+
+typedef void (*core_thread_impl_set_t)(
+ core_thread_create_t create,
+ core_thread_join_t join,
+ core_thread_destroy_t destroy);
+
+/**
+ * Configure the thread API implementations
+ *
+ * Advised to do this as early in your application/library module as possible
+ * as calls to the getter functions below will return the currently configured
+ * implementations.
+ *
+ * @param create Pointer to a function implementing thread creation
+ * @param join Pointer to a function implementing joining of a thread
+ * @param destroy Pointer to a function implementing destroying of a thread
+ */
+void core_thread_impl_set(
+ core_thread_create_t create,
+ core_thread_join_t join,
+ core_thread_destroy_t destroy);
+
+/**
+ * Supporting function to inject/assign the currently set implementation
+ * with the given setter function.
+ *
+ * @param impl_set Setter function to call with the currently configured thread
+ * function implementations
+ */
+void core_thread_impl_assign(core_thread_impl_set_t impl_set);
+
+/**
+ * Get the currently configured implementation for thread_create
+ *
+ * @return Pointer to the currently configured implementation of the
+ * thread_create function
+ */
+core_thread_create_t core_thread_create_impl_get();
+
+/**
+ * Get the currently configured implementation for thread_join
+ *
+ * @return Pointer to the currently configured implementation of the thread_join
+ * function
+ */
+core_thread_join_t core_thread_join_impl_get();
+
+/**
+ * Get the currently configured implementation for thread_destroy
+ *
+ * @return Pointer to the currently configured implementation of the
+ * thread_destroy function
+ */
+core_thread_destroy_t core_thread_destroy_impl_get();
+
+#endif
diff --git a/src/main/d3d9exhook/config-gfx.c b/src/main/d3d9exhook/config-gfx.c
index 6cf57af0..b4a51973 100644
--- a/src/main/d3d9exhook/config-gfx.c
+++ b/src/main/d3d9exhook/config-gfx.c
@@ -4,9 +4,9 @@
#include "cconfig/cconfig-util.h"
-#include "d3d9exhook/config-gfx.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "d3d9exhook/config-gfx.h"
#define D3D9EXHOOK_CONFIG_GFX_FRAMED_KEY "gfx.framed"
#define D3D9EXHOOK_CONFIG_GFX_WINDOWED_KEY "gfx.windowed"
diff --git a/src/main/d3d9exhook/d3d9ex.c b/src/main/d3d9exhook/d3d9ex.c
index 88d95b00..80d958c3 100644
--- a/src/main/d3d9exhook/d3d9ex.c
+++ b/src/main/d3d9exhook/d3d9ex.c
@@ -9,13 +9,14 @@
#include
#include
+#include "core/log.h"
+
#include "hook/com-proxy.h"
#include "hook/table.h"
#include "d3d9exhook/d3d9ex.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
#include "util/time.h"
diff --git a/src/main/ddrhook-util/_com4.c b/src/main/ddrhook-util/_com4.c
index 44e01784..4ca08c37 100644
--- a/src/main/ddrhook-util/_com4.c
+++ b/src/main/ddrhook-util/_com4.c
@@ -19,6 +19,8 @@
#include "bemanitools/ddrio.h"
+#include "core/log.h"
+
#include "ddrhook-util/_com4.h"
#include "hook/iohook.h"
@@ -27,7 +29,6 @@
#include "util/defs.h"
#include "util/iobuf.h"
-#include "util/log.h"
static struct ac_io_emu com4_ac_io_emu;
static struct ac_io_emu_hdxs com4_hdxs;
diff --git a/src/main/ddrhook-util/dinput.c b/src/main/ddrhook-util/dinput.c
index b0fdc663..949fb1eb 100644
--- a/src/main/ddrhook-util/dinput.c
+++ b/src/main/ddrhook-util/dinput.c
@@ -5,12 +5,13 @@
#include
+#include "core/log.h"
+
#include "hook/com-proxy.h"
#include "hook/pe.h"
#include "hook/table.h"
#include "util/defs.h"
-#include "util/log.h"
static HRESULT STDCALL my_DirectInput8Create(
HINSTANCE hinst,
diff --git a/src/main/ddrhook-util/extio.c b/src/main/ddrhook-util/extio.c
index cd2dc84b..661b165f 100644
--- a/src/main/ddrhook-util/extio.c
+++ b/src/main/ddrhook-util/extio.c
@@ -14,10 +14,11 @@
#include "bemanitools/ddrio.h"
+#include "core/log.h"
+
#include "hook/iohook.h"
#include "util/iobuf.h"
-#include "util/log.h"
#include "util/str.h"
static HRESULT extio_open(struct irp *irp);
diff --git a/src/main/ddrhook-util/gfx.c b/src/main/ddrhook-util/gfx.c
index 3f5f7736..0bfd0a5c 100644
--- a/src/main/ddrhook-util/gfx.c
+++ b/src/main/ddrhook-util/gfx.c
@@ -11,13 +11,14 @@
#include
#include
+#include "core/log.h"
+
#include "hook/com-proxy.h"
#include "hook/table.h"
#include "ddrhook-util/gfx.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
#include "util/time.h"
diff --git a/src/main/ddrhook-util/misc.c b/src/main/ddrhook-util/misc.c
index b74c8de6..e04390d1 100644
--- a/src/main/ddrhook-util/misc.c
+++ b/src/main/ddrhook-util/misc.c
@@ -2,13 +2,14 @@
#include
+#include "core/log.h"
+
#include "ddrhook-util/gfx.h"
#include "hook/pe.h"
#include "hook/table.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
static LRESULT(STDCALL *real_SendMessageW)(
diff --git a/src/main/ddrhook-util/monitor.c b/src/main/ddrhook-util/monitor.c
index 0dfce07f..cba18ccd 100644
--- a/src/main/ddrhook-util/monitor.c
+++ b/src/main/ddrhook-util/monitor.c
@@ -7,12 +7,13 @@
#include
#include
+#include "core/log.h"
+
#include "ddrhook-util/monitor.h"
#include "hook/table.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
/* Link pointers */
diff --git a/src/main/ddrhook-util/p3io.c b/src/main/ddrhook-util/p3io.c
index 09b8c6f5..af0f1a93 100644
--- a/src/main/ddrhook-util/p3io.c
+++ b/src/main/ddrhook-util/p3io.c
@@ -7,11 +7,11 @@
#include "ddrhook-util/p3io.h"
+#include "core/log.h"
+
#include "p3ioemu/emu.h"
#include "p3ioemu/uart.h"
-#include "util/log.h"
-
extern bool _15khz;
extern bool standard_def;
diff --git a/src/main/ddrhook-util/spike.c b/src/main/ddrhook-util/spike.c
index 0e383d20..37cf8887 100644
--- a/src/main/ddrhook-util/spike.c
+++ b/src/main/ddrhook-util/spike.c
@@ -15,10 +15,11 @@
#include "acioemu/addr.h"
#include "acioemu/emu.h"
+#include "core/log.h"
+
#include "hook/iohook.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
static struct ac_io_emu spike_ac_io_emu;
diff --git a/src/main/ddrhook-util/usbmem.c b/src/main/ddrhook-util/usbmem.c
index f85363f3..c4e12c48 100644
--- a/src/main/ddrhook-util/usbmem.c
+++ b/src/main/ddrhook-util/usbmem.c
@@ -12,12 +12,13 @@
#include
#include
+#include "core/log.h"
+
#include "hook/iohook.h"
#include "util/crc.h"
#include "util/fs.h"
#include "util/iobuf.h"
-#include "util/log.h"
#include "util/str.h"
#define USBMEM_DEVICE_COUNT 2
diff --git a/src/main/ddrhook1/Module.mk b/src/main/ddrhook1/Module.mk
index 83782ae8..1e9dc240 100644
--- a/src/main/ddrhook1/Module.mk
+++ b/src/main/ddrhook1/Module.mk
@@ -7,6 +7,8 @@ deplibs_ddrhook1 := \
avs \
libs_ddrhook1 := \
+ avs-util \
+ core \
acioemu \
cconfig \
ddrhook-util \
diff --git a/src/main/ddrhook1/avs-boot.c b/src/main/ddrhook1/avs-boot.c
index 1b7ad41a..db4445b4 100644
--- a/src/main/ddrhook1/avs-boot.c
+++ b/src/main/ddrhook1/avs-boot.c
@@ -5,6 +5,9 @@
#include
#include
+#include "core/log-bt.h"
+#include "core/log.h"
+
#include "hook/iohook.h"
#include "hook/table.h"
@@ -13,7 +16,6 @@
#include "ddrhook1/avs-boot.h"
#include "ddrhook1/filesystem.h"
-#include "util/log.h"
#include "util/str.h"
static void (*real_avs_boot)(
@@ -50,6 +52,11 @@ static const struct hook_symbol ddrhook1_avs_ea3_hook_syms[] = {
.link = (void **) &real_ea3_boot},
};
+static AVS_LOG_WRITER(_avs_boot_log_writer, chars, nchars, ctx)
+{
+ core_log_bt_direct_sink_write(chars, nchars);
+}
+
static void avs_boot_replace_property_str(
struct property_node *node, const char *name, const char *val)
{
@@ -115,7 +122,7 @@ static void my_avs_boot(
sz_std_heap,
avs_heap,
sz_avs_heap,
- log_writer_debug,
+ _avs_boot_log_writer,
NULL);
}
diff --git a/src/main/ddrhook1/config-ddrhook1.c b/src/main/ddrhook1/config-ddrhook1.c
index 154f3ae3..a5872bf9 100644
--- a/src/main/ddrhook1/config-ddrhook1.c
+++ b/src/main/ddrhook1/config-ddrhook1.c
@@ -2,9 +2,9 @@
#include "cconfig/cconfig-util.h"
-#include "ddrhook1/config-ddrhook1.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "ddrhook1/config-ddrhook1.h"
#define DDRHOOK1_CONFIG_DDRHOOK1_USE_COM4_EMU_KEY "ddrhook1.use_com4_emu"
#define DDRHOOK1_CONFIG_DDRHOOK1_STANDARD_DEF_KEY "ddrhook1.standard_def"
diff --git a/src/main/ddrhook1/config-eamuse.c b/src/main/ddrhook1/config-eamuse.c
index 260791d3..dbe44cde 100644
--- a/src/main/ddrhook1/config-eamuse.c
+++ b/src/main/ddrhook1/config-eamuse.c
@@ -2,9 +2,10 @@
#include "cconfig/cconfig-util.h"
+#include "core/log.h"
+
#include "ddrhook1/config-eamuse.h"
-#include "util/log.h"
#include "util/net.h"
#define DDRHOOK1_CONFIG_EAMUSE_SERVER_KEY "eamuse.server"
diff --git a/src/main/ddrhook1/config-gfx.c b/src/main/ddrhook1/config-gfx.c
index 09ccc0c6..c71e74df 100644
--- a/src/main/ddrhook1/config-gfx.c
+++ b/src/main/ddrhook1/config-gfx.c
@@ -2,9 +2,9 @@
#include "cconfig/cconfig-util.h"
-#include "ddrhook1/config-gfx.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "ddrhook1/config-gfx.h"
#define DDRHOOK1_CONFIG_GFX_WINDOWED_KEY "gfx.windowed"
diff --git a/src/main/ddrhook1/config-security.c b/src/main/ddrhook1/config-security.c
index 9489b0a6..b0b7d2b2 100644
--- a/src/main/ddrhook1/config-security.c
+++ b/src/main/ddrhook1/config-security.c
@@ -2,11 +2,12 @@
#include "cconfig/cconfig-util.h"
+#include "core/log.h"
+
#include "ddrhook1/config-security.h"
#include "security/mcode.h"
-#include "util/log.h"
#include "util/net.h"
#define DDRHOOK1_CONFIG_SECURITY_MCODE_KEY "security.mcode"
diff --git a/src/main/ddrhook1/dllmain.c b/src/main/ddrhook1/dllmain.c
index 3dcc6c94..3cccb3a7 100644
--- a/src/main/ddrhook1/dllmain.c
+++ b/src/main/ddrhook1/dllmain.c
@@ -2,11 +2,20 @@
#include
+#include "avs-util/core-interop.h"
+
#include "bemanitools/ddrio.h"
#include "bemanitools/eamio.h"
#include "cconfig/cconfig-hook.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log-sink-debug.h"
+#include "core/log.h"
+#include "core/thread-crt.h"
+#include "core/thread.h"
+
#include "ddrhook-util/_com4.h"
#include "ddrhook-util/extio.h"
#include "ddrhook-util/p3io.h"
@@ -37,8 +46,6 @@
#include "util/cmdline.h"
#include "util/defs.h"
-#include "util/log.h"
-#include "util/thread.h"
#define DDRHOOK1_INFO_HEADER \
"ddrhook1 for DDR X" \
@@ -68,6 +75,15 @@ static const struct hook_symbol init_hook_syms[] = {
},
};
+static void _ddrhook1_log_init()
+{
+ core_log_bt_ext_impl_set();
+ core_log_bt_ext_init_with_debug();
+
+ // TODO change log level support
+ core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
+}
+
static DWORD STDCALL
my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
{
@@ -155,7 +171,12 @@ my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
log_info("Initializing DDR IO backend");
- ok = ddr_io_init(thread_create, thread_join, thread_destroy);
+ core_log_impl_assign(ddr_io_set_loggers);
+
+ ok = ddr_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get());
if (!ok) {
log_fatal("Couldn't initialize DDR IO backend");
@@ -165,10 +186,12 @@ my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
if (config_ddrhook1.use_com4_emu) {
log_info("Initializing card reader backend");
- eam_io_set_loggers(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
- ok = eam_io_init(thread_create, thread_join, thread_destroy);
+ ok = eam_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get());
if (!ok) {
log_fatal("Couldn't initialize card reader backend");
@@ -185,7 +208,12 @@ my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
{
if (reason == DLL_PROCESS_ATTACH) {
- log_to_writer(log_writer_debug, NULL);
+ // Use AVS APIs
+ avs_util_core_interop_thread_avs_impl_set();
+
+ // TODO init debug logging but with avs available? why not use avs
+ // logging?
+ _ddrhook1_log_init();
hook_table_apply(
NULL, "kernel32.dll", init_hook_syms, lengthof(init_hook_syms));
diff --git a/src/main/ddrhook1/filesystem.c b/src/main/ddrhook1/filesystem.c
index abec921e..9912c4f9 100644
--- a/src/main/ddrhook1/filesystem.c
+++ b/src/main/ddrhook1/filesystem.c
@@ -6,10 +6,11 @@
#include
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"
diff --git a/src/main/ddrhook1/master.c b/src/main/ddrhook1/master.c
index b30836a5..480d56f7 100644
--- a/src/main/ddrhook1/master.c
+++ b/src/main/ddrhook1/master.c
@@ -1,3 +1,5 @@
+#include "core/log.h"
+
#include "ddrhook1/master.h"
#include "ddrhook-util/dinput.h"
@@ -9,7 +11,6 @@
#include "p3ioemu/devmgr.h"
#include "util/defs.h"
-#include "util/log.h"
static HMODULE(STDCALL *real_LoadLibraryA)(const char *name);
static BOOL(STDCALL *real_IsDebuggerPresent)();
diff --git a/src/main/ddrhook2/Module.mk b/src/main/ddrhook2/Module.mk
index 0c9fd365..e0416d66 100644
--- a/src/main/ddrhook2/Module.mk
+++ b/src/main/ddrhook2/Module.mk
@@ -4,6 +4,8 @@ deplibs_ddrhook2 := \
avs \
libs_ddrhook2 := \
+ avs-util \
+ core \
acioemu \
ddrhook-util \
p3ioemu \
diff --git a/src/main/ddrhook2/dllmain.c b/src/main/ddrhook2/dllmain.c
index 90355519..cabbb941 100644
--- a/src/main/ddrhook2/dllmain.c
+++ b/src/main/ddrhook2/dllmain.c
@@ -2,9 +2,14 @@
#include
+#include "avs-util/core-interop.h"
+
#include "bemanitools/ddrio.h"
#include "bemanitools/eamio.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "ddrhook-util/_com4.h"
#include "ddrhook-util/extio.h"
#include "ddrhook-util/gfx.h"
@@ -25,7 +30,6 @@
#include "util/cmdline.h"
#include "util/defs.h"
-#include "util/log.h"
static bool my_dll_entry_init(char *sidcode, struct property_node *param);
static bool my_dll_entry_main(void);
@@ -119,10 +123,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
log_info("Initializing DDR IO backend");
- ddr_io_set_loggers(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ core_log_impl_assign(ddr_io_set_loggers);
- ok = ddr_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
+ ok = ddr_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get());
if (!ok) {
return false;
@@ -131,11 +137,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
if (com4) {
log_info("Initializing card reader backend");
- eam_io_set_loggers(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
- ok =
- eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
+ ok = eam_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get());
if (!ok) {
return false;
@@ -174,8 +181,9 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
goto end;
}
- log_to_external(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ // Use AVS APIs
+ avs_util_core_interop_thread_avs_impl_set();
+ avs_util_core_interop_log_avs_impl_set();
app_hook_init(my_dll_entry_init, my_dll_entry_main);
diff --git a/src/main/ddrhook2/master.c b/src/main/ddrhook2/master.c
index 89f874ff..aba5451d 100644
--- a/src/main/ddrhook2/master.c
+++ b/src/main/ddrhook2/master.c
@@ -1,3 +1,5 @@
+#include "core/log.h"
+
#include "ddrhook2/master.h"
#include "ddrhook-util/dinput.h"
@@ -10,7 +12,6 @@
#include "p3ioemu/devmgr.h"
#include "util/defs.h"
-#include "util/log.h"
static HMODULE(STDCALL *real_LoadLibraryA)(const char *name);
diff --git a/src/main/ddrio-async/Module.mk b/src/main/ddrio-async/Module.mk
index 62006cfe..2eb806dd 100644
--- a/src/main/ddrio-async/Module.mk
+++ b/src/main/ddrio-async/Module.mk
@@ -3,6 +3,7 @@ dlls += ddrio-async
ldflags_ddrio-async:= \
libs_ddrio-async := \
+ core \
util \
src_ddrio-async := \
diff --git a/src/main/ddrio-async/ddrio.c b/src/main/ddrio-async/ddrio.c
index 9b857fd6..998c59a5 100644
--- a/src/main/ddrio-async/ddrio.c
+++ b/src/main/ddrio-async/ddrio.c
@@ -11,8 +11,9 @@
#include "bemanitools/ddrio.h"
-#include "util/log.h"
-#include "util/thread.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "util/time.h"
typedef void (*ddr_io_set_loggers_t)(
@@ -28,7 +29,8 @@ typedef uint32_t (*ddr_io_read_pad_t)(void);
typedef void (*ddr_io_set_lights_extio_t)(uint32_t extio_lights);
typedef void (*ddr_io_set_lights_p3io_t)(uint32_t p3io_lights);
typedef void (*ddr_io_set_lights_hdxs_panel_t)(uint32_t hdxs_lights);
-typedef void (*ddr_io_set_lights_hdxs_rgb_t)(uint8_t idx, uint8_t r, uint8_t g, uint8_t b);
+typedef void (*ddr_io_set_lights_hdxs_rgb_t)(
+ uint8_t idx, uint8_t r, uint8_t g, uint8_t b);
typedef void (*ddr_io_fini_t)(void);
static HMODULE _child_ddr_io_module;
@@ -66,10 +68,7 @@ static int _io_thread_proc(void *ctx)
uint32_t local_tmp;
- atomic_store_explicit(
- &_io_thread_proc_running,
- true,
- memory_order_seq_cst);
+ atomic_store_explicit(&_io_thread_proc_running, true, memory_order_seq_cst);
log_info("IO thread running");
@@ -85,18 +84,16 @@ static int _io_thread_proc(void *ctx)
local_tmp = _child_ddr_io_read_pad();
atomic_store_explicit(
- &_child_ddr_io_data_pad,
- local_tmp,
- memory_order_relaxed);
+ &_child_ddr_io_data_pad, local_tmp, memory_order_relaxed);
- // Only update outputs when they change gives this loop a major performance boost
- // The write calls on a p3io for the outputs are very expensive (~12 ms) as they
- // are executed over the ACIO protocol compared to only the input read
- // calls (~4 ms) which have a dedicated IOCTL call/endpoint
+ // Only update outputs when they change gives this loop a major
+ // performance boost The write calls on a p3io for the outputs are very
+ // expensive (~12 ms) as they are executed over the ACIO protocol
+ // compared to only the input read calls (~4 ms) which have a dedicated
+ // IOCTL call/endpoint
local_tmp = atomic_load_explicit(
- &_child_ddr_io_data_extio_lights,
- memory_order_relaxed);
+ &_child_ddr_io_data_extio_lights, memory_order_relaxed);
if (local_tmp != prev_child_ddr_io_data_extio_lights) {
_child_ddr_io_set_lights_extio(local_tmp);
@@ -104,9 +101,8 @@ static int _io_thread_proc(void *ctx)
}
local_tmp = atomic_load_explicit(
- &_child_ddr_io_data_p3io_lights,
- memory_order_relaxed);
-
+ &_child_ddr_io_data_p3io_lights, memory_order_relaxed);
+
if (local_tmp != prev_child_ddr_io_data_p3io_lights) {
_child_ddr_io_set_lights_p3io(local_tmp);
prev_child_ddr_io_data_p3io_lights = local_tmp;
@@ -121,22 +117,23 @@ static int _io_thread_proc(void *ctx)
time_end = time_get_counter();
total_time = time_get_elapsed_us(time_end - time_start);
- log_info("IO thread performance: total iterations %lld, avg. loop cycle time %f us",
- loop_counter, ((double) total_time) / loop_counter);
+ log_info(
+ "IO thread performance: total iterations %lld, avg. loop cycle time %f "
+ "us",
+ loop_counter,
+ ((double) total_time) / loop_counter);
atomic_store_explicit(
- &_io_thread_proc_running,
- false,
- memory_order_seq_cst);
+ &_io_thread_proc_running, false, memory_order_seq_cst);
log_info("IO thread shut down");
return 0;
}
-static void* _load_function(HMODULE module, const char* name)
+static void *_load_function(HMODULE module, const char *name)
{
- void* ptr;
+ void *ptr;
ptr = GetProcAddress(module, name);
@@ -158,7 +155,7 @@ void ddr_io_set_loggers(
_log_formatter_warning = warning;
_log_formatter_fatal = fatal;
- log_to_external(misc, info, warning, fatal);
+ core_log_impl_set(misc, info, warning, fatal);
}
bool ddr_io_init(
@@ -168,6 +165,8 @@ bool ddr_io_init(
{
log_info("Loading ddrio-async-child.dll as child ddrio library...");
+ core_thread_impl_set(thread_create, thread_join, thread_destroy);
+
_child_ddr_io_module = LoadLibraryA("ddrio-async-child.dll");
if (_child_ddr_io_module == NULL) {
@@ -175,13 +174,19 @@ bool ddr_io_init(
return false;
}
- _child_ddr_io_set_loggers = _load_function(_child_ddr_io_module, "ddr_io_set_loggers");
+ _child_ddr_io_set_loggers =
+ _load_function(_child_ddr_io_module, "ddr_io_set_loggers");
_child_ddr_io_init = _load_function(_child_ddr_io_module, "ddr_io_init");
- _child_ddr_io_read_pad = _load_function(_child_ddr_io_module, "ddr_io_read_pad");
- _child_ddr_io_set_lights_extio = _load_function(_child_ddr_io_module, "ddr_io_set_lights_extio");
- _child_ddr_io_set_lights_p3io = _load_function(_child_ddr_io_module, "ddr_io_set_lights_p3io");
- _child_ddr_io_set_lights_hdxs_panel = _load_function(_child_ddr_io_module, "ddr_io_set_lights_hdxs_panel");
- _child_ddr_io_set_lights_hdxs_rgb = _load_function(_child_ddr_io_module, "ddr_io_set_lights_hdxs_rgb");
+ _child_ddr_io_read_pad =
+ _load_function(_child_ddr_io_module, "ddr_io_read_pad");
+ _child_ddr_io_set_lights_extio =
+ _load_function(_child_ddr_io_module, "ddr_io_set_lights_extio");
+ _child_ddr_io_set_lights_p3io =
+ _load_function(_child_ddr_io_module, "ddr_io_set_lights_p3io");
+ _child_ddr_io_set_lights_hdxs_panel =
+ _load_function(_child_ddr_io_module, "ddr_io_set_lights_hdxs_panel");
+ _child_ddr_io_set_lights_hdxs_rgb =
+ _load_function(_child_ddr_io_module, "ddr_io_set_lights_hdxs_rgb");
_child_ddr_io_fini = _load_function(_child_ddr_io_module, "ddr_io_fini");
_child_ddr_io_set_loggers(
@@ -199,10 +204,7 @@ bool ddr_io_init(
return false;
}
- atomic_store_explicit(
- &_io_thread_proc_loop,
- true,
- memory_order_seq_cst);
+ atomic_store_explicit(&_io_thread_proc_loop, true, memory_order_seq_cst);
if (!thread_create(_io_thread_proc, NULL, 16384, 0)) {
log_warning("Creating IO thread failed");
@@ -224,17 +226,13 @@ uint32_t ddr_io_read_pad(void)
void ddr_io_set_lights_extio(uint32_t extio_lights)
{
atomic_store_explicit(
- &_child_ddr_io_data_extio_lights,
- extio_lights,
- memory_order_relaxed);
+ &_child_ddr_io_data_extio_lights, extio_lights, memory_order_relaxed);
}
void ddr_io_set_lights_p3io(uint32_t p3io_lights)
{
atomic_store_explicit(
- &_child_ddr_io_data_p3io_lights,
- p3io_lights,
- memory_order_relaxed);
+ &_child_ddr_io_data_p3io_lights, p3io_lights, memory_order_relaxed);
}
void ddr_io_set_lights_hdxs_panel(uint32_t lights)
@@ -249,14 +247,12 @@ void ddr_io_set_lights_hdxs_rgb(uint8_t idx, uint8_t r, uint8_t g, uint8_t b)
void ddr_io_fini(void)
{
- atomic_store_explicit(
- &_io_thread_proc_loop,
- false,
- memory_order_seq_cst);
+ atomic_store_explicit(&_io_thread_proc_loop, false, memory_order_seq_cst);
log_info("Shutting down IO thread and waiting for it to finish...");
- while (atomic_load_explicit(&_io_thread_proc_running, memory_order_seq_cst)) {
+ while (
+ atomic_load_explicit(&_io_thread_proc_running, memory_order_seq_cst)) {
Sleep(1);
}
diff --git a/src/main/ddrio-mm/Module.mk b/src/main/ddrio-mm/Module.mk
index 9368a623..16e3ca87 100644
--- a/src/main/ddrio-mm/Module.mk
+++ b/src/main/ddrio-mm/Module.mk
@@ -5,6 +5,7 @@ ldflags_ddrio-mm:= \
-lsetupapi \
libs_ddrio-mm := \
+ core \
mm \
util \
diff --git a/src/main/ddrio-mm/ddrio.c b/src/main/ddrio-mm/ddrio.c
index 08bd1d29..44bdd352 100644
--- a/src/main/ddrio-mm/ddrio.c
+++ b/src/main/ddrio-mm/ddrio.c
@@ -7,11 +7,12 @@
#include "bemanitools/ddrio.h"
+#include "core/log.h"
+
#include "mm/mm.h"
#include "util/cmdline.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/mem.h"
struct ddr_bittrans {
@@ -117,7 +118,7 @@ void ddr_io_set_loggers(
log_formatter_t warning,
log_formatter_t fatal)
{
- log_to_external(misc, info, warning, fatal);
+ core_log_impl_set(misc, info, warning, fatal);
}
bool ddr_io_init(
diff --git a/src/main/ddrio-p3io/Module.mk b/src/main/ddrio-p3io/Module.mk
index 43e0fd06..2824bf0e 100644
--- a/src/main/ddrio-p3io/Module.mk
+++ b/src/main/ddrio-p3io/Module.mk
@@ -4,6 +4,7 @@ ldflags_ddrio-p3io:= \
-lsetupapi \
libs_ddrio-p3io := \
+ core \
cconfig \
extio \
extiodrv \
diff --git a/src/main/ddrio-p3io/config.c b/src/main/ddrio-p3io/config.c
index c45254e1..54591575 100644
--- a/src/main/ddrio-p3io/config.c
+++ b/src/main/ddrio-p3io/config.c
@@ -1,6 +1,6 @@
#include "cconfig/cconfig-util.h"
-#include "util/log.h"
+#include "core/log.h"
#include "config.h"
diff --git a/src/main/ddrio-p3io/ddrio.c b/src/main/ddrio-p3io/ddrio.c
index a38ce09d..6ed7e90c 100644
--- a/src/main/ddrio-p3io/ddrio.c
+++ b/src/main/ddrio-p3io/ddrio.c
@@ -10,15 +10,15 @@
#include "cconfig/cconfig-main.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "extiodrv/device.h"
#include "extiodrv/extio.h"
#include "p3iodrv/ddr.h"
#include "p3iodrv/device.h"
-#include "util/log.h"
-#include "util/thread.h"
-
#include "config.h"
static struct ddrio_p3io_config _ddr_io_p3io_config;
@@ -255,7 +255,7 @@ void ddr_io_set_loggers(
log_formatter_t warning,
log_formatter_t fatal)
{
- log_to_external(misc, info, warning, fatal);
+ core_log_impl_set(misc, info, warning, fatal);
}
static void _ddr_io_config_init(struct ddrio_p3io_config *config_ddrio_p3io)
diff --git a/src/main/ddrio-smx/Module.mk b/src/main/ddrio-smx/Module.mk
index cc0563b2..12fd74de 100644
--- a/src/main/ddrio-smx/Module.mk
+++ b/src/main/ddrio-smx/Module.mk
@@ -5,6 +5,7 @@ deplibs_ddrio-smx := \
SMX \
libs_ddrio-smx := \
+ core \
geninput \
util \
diff --git a/src/main/ddrio-smx/ddrio.c b/src/main/ddrio-smx/ddrio.c
index a7cda337..334ccaca 100644
--- a/src/main/ddrio-smx/ddrio.c
+++ b/src/main/ddrio-smx/ddrio.c
@@ -6,11 +6,12 @@
#include "bemanitools/ddrio.h"
#include "bemanitools/input.h"
+#include "core/log.h"
+
#include "imports/SMX.h"
#include "imports/avs.h"
#include "util/defs.h"
-#include "util/log.h"
struct ddr_io_smx_pad_map {
int pad_no;
@@ -99,7 +100,7 @@ void ddr_io_set_loggers(
log_formatter_t warning,
log_formatter_t fatal)
{
- log_to_external(misc, info, warning, fatal);
+ core_log_impl_set(misc, info, warning, fatal);
input_set_loggers(misc, info, warning, fatal);
/* We would need a log server thread to accept log messages from SMX, since
diff --git a/src/main/ddrio/ddrio.c b/src/main/ddrio/ddrio.c
index 167b7c6e..5da99348 100644
--- a/src/main/ddrio/ddrio.c
+++ b/src/main/ddrio/ddrio.c
@@ -4,7 +4,7 @@
#include "bemanitools/input.h"
-#include "util/log.h"
+#include "core/log.h"
void ddr_io_set_loggers(
log_formatter_t misc,
diff --git a/src/main/ddriotest/Module.mk b/src/main/ddriotest/Module.mk
index 569d9736..b6cba5cb 100644
--- a/src/main/ddriotest/Module.mk
+++ b/src/main/ddriotest/Module.mk
@@ -1,6 +1,7 @@
exes += ddriotest \
libs_ddriotest := \
+ core \
ddrio \
util \
diff --git a/src/main/ddriotest/main.c b/src/main/ddriotest/main.c
index e03bc0c4..40453ce0 100644
--- a/src/main/ddriotest/main.c
+++ b/src/main/ddriotest/main.c
@@ -7,32 +7,41 @@
#include "bemanitools/ddrio.h"
-#include "util/log.h"
-#include "util/thread.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log.h"
+#include "core/thread-crt-ext.h"
+#include "core/thread-crt.h"
+#include "core/thread.h"
int main(int argc, char **argv)
{
- enum log_level log_level;
+ enum core_log_bt_log_level log_level;
- log_level = LOG_LEVEL_FATAL;
+ log_level = CORE_LOG_BT_LOG_LEVEL_FATAL;
for (int i = 0; i < argc; i++) {
if (!strcmp(argv[i], "-v")) {
- log_level = LOG_LEVEL_WARNING;
+ log_level = CORE_LOG_BT_LOG_LEVEL_WARNING;
} else if (!strcmp(argv[i], "-vv")) {
- log_level = LOG_LEVEL_INFO;
+ log_level = CORE_LOG_BT_LOG_LEVEL_INFO;
} else if (!strcmp(argv[i], "-vvv")) {
- log_level = LOG_LEVEL_MISC;
+ log_level = CORE_LOG_BT_LOG_LEVEL_MISC;
}
}
- log_to_writer(log_writer_stderr, NULL);
- log_set_level(log_level);
+ core_thread_crt_ext_impl_set();
+ core_log_bt_ext_impl_set();
- ddr_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_bt_ext_init_with_stderr();
+ core_log_bt_level_set(log_level);
- if (!ddr_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy)) {
+ core_log_impl_assign(ddr_io_set_loggers);
+
+ if (!ddr_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
fprintf(stderr, "Initializing ddrio failed\n");
return -1;
}
diff --git a/src/main/dinput/dinput.c b/src/main/dinput/dinput.c
index 248ead4a..e65928f7 100644
--- a/src/main/dinput/dinput.c
+++ b/src/main/dinput/dinput.c
@@ -8,12 +8,13 @@
#include
+#include "core/log.h"
+
#include "hook/com-proxy.h"
#include "hook/pe.h"
#include "hook/table.h"
#include "util/defs.h"
-#include "util/log.h"
static HRESULT STDCALL my_DirectInput8Create(
HINSTANCE hinst,
diff --git a/src/main/eamio-icca/Module.mk b/src/main/eamio-icca/Module.mk
index 28c388e5..bcd4be83 100644
--- a/src/main/eamio-icca/Module.mk
+++ b/src/main/eamio-icca/Module.mk
@@ -2,6 +2,7 @@ dlls += \
eamio-icca \
libs_eamio-icca := \
+ core \
aciodrv \
aciomgr \
cconfig \
diff --git a/src/main/eamio-icca/config-icc.c b/src/main/eamio-icca/config-icc.c
index 660c0ee1..963f6882 100644
--- a/src/main/eamio-icca/config-icc.c
+++ b/src/main/eamio-icca/config-icc.c
@@ -2,8 +2,6 @@
#include "eamio-icca/config-icc.h"
-#include "util/log.h"
-
#define EAMIO_ICCA_CONFIG_ICC_PORT_KEY "icc.port"
#define EAMIO_ICCA_CONFIG_ICC_BAUD_KEY "icc.baud"
diff --git a/src/main/eamio-icca/eamio-icca.c b/src/main/eamio-icca/eamio-icca.c
index c681610e..db0215a9 100644
--- a/src/main/eamio-icca/eamio-icca.c
+++ b/src/main/eamio-icca/eamio-icca.c
@@ -14,11 +14,11 @@
#include "bemanitools/eamio.h"
+#include "core/log.h"
+
#include "cconfig/cconfig-main.h"
#include "eamio-icca/config-icc.h"
-#include "util/log.h"
-
#define IDLE_RESPONSES_BETWEEN_FELICA_POLLS 5
#define NUMBER_OF_EMULATED_READERS 2
#define INVALID_NODE_ID -1
@@ -60,7 +60,7 @@ void eam_io_set_loggers(
{
aciomgr_set_loggers(misc, info, warning, fatal);
- log_to_external(misc, info, warning, fatal);
+ core_log_impl_set(misc, info, warning, fatal);
}
// all of these are referred to internally as ICCA
diff --git a/src/main/eamio/Module.mk b/src/main/eamio/Module.mk
index f7a7409c..9cf82ed3 100644
--- a/src/main/eamio/Module.mk
+++ b/src/main/eamio/Module.mk
@@ -1,5 +1,5 @@
dlls += eamio
-libs_eamio := geninput util
+libs_eamio := core geninput util
src_eamio := \
eam-api.c \
eam-impl.c \
diff --git a/src/main/eamio/eam-api.c b/src/main/eamio/eam-api.c
index 03203173..9d2857d9 100644
--- a/src/main/eamio/eam-api.c
+++ b/src/main/eamio/eam-api.c
@@ -11,14 +11,15 @@
#include "bemanitools/eamio.h"
#include "bemanitools/input.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "eamio/eam-config.h"
#include "eamio/eam-impl.h"
#include "eamio/eam-s11n.h"
#include "util/fs.h"
-#include "util/log.h"
#include "util/msg-thread.h"
-#include "util/thread.h"
static void eam_handle_hotplug_msg(WPARAM wparam, const DEV_BROADCAST_HDR *hdr);
static FILE *eam_io_config_open(const char *mode);
@@ -108,14 +109,14 @@ void eam_io_set_loggers(
log_formatter_t warning,
log_formatter_t fatal)
{
- log_to_external(misc, info, warning, fatal);
+ core_log_impl_set(misc, info, warning, fatal);
}
bool eam_io_init(
thread_create_t create, thread_join_t join, thread_destroy_t destroy)
{
input_init(create, join, destroy);
- thread_api_init(create, join, destroy);
+ core_thread_impl_set(create, join, destroy);
eam_io_config_load();
msg_thread_init(eam_hinst);
diff --git a/src/main/eamio/eam-impl.c b/src/main/eamio/eam-impl.c
index 0c417094..6aca5898 100644
--- a/src/main/eamio/eam-impl.c
+++ b/src/main/eamio/eam-impl.c
@@ -9,6 +9,8 @@
#include "bemanitools/eamio.h"
+#include "core/log.h"
+
#include "eamio/eam-impl.h"
#include "geninput/hid-mgr.h"
@@ -16,7 +18,6 @@
#include "util/defs.h"
#include "util/fs.h"
#include "util/hex.h"
-#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"
diff --git a/src/main/eamiotest/Module.mk b/src/main/eamiotest/Module.mk
index a54384b7..0b9fd4b9 100644
--- a/src/main/eamiotest/Module.mk
+++ b/src/main/eamiotest/Module.mk
@@ -1,6 +1,7 @@
exes += eamiotest
libs_eamiotest := \
+ core \
eamio \
util \
diff --git a/src/main/eamiotest/main.c b/src/main/eamiotest/main.c
index 9880af4a..a2f410f4 100644
--- a/src/main/eamiotest/main.c
+++ b/src/main/eamiotest/main.c
@@ -7,20 +7,29 @@
#include "bemanitools/eamio.h"
-#include "util/log.h"
-#include "util/thread.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log.h"
+#include "core/thread-crt-ext.h"
+#include "core/thread-crt.h"
+#include "core/thread.h"
/**
* Tool to test your implementations of eamio.
*/
int main(int argc, char **argv)
{
- log_to_writer(log_writer_stdout, NULL);
+ core_thread_crt_ext_impl_set();
+ core_log_bt_ext_impl_set();
- eam_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_bt_ext_init_with_stdout();
- if (!eam_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy)) {
+ core_log_impl_assign(eam_io_set_loggers);
+
+ if (!eam_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
printf("Initializing eamio failed\n");
return -1;
}
diff --git a/src/main/extiodrv/device.c b/src/main/extiodrv/device.c
index ba14fa7f..e6bc788f 100644
--- a/src/main/extiodrv/device.c
+++ b/src/main/extiodrv/device.c
@@ -2,7 +2,7 @@
#include "device.h"
-#include "util/log.h"
+#include "core/log.h"
HRESULT extiodrv_device_open(const char *port, HANDLE *handle)
{
diff --git a/src/main/extiodrv/extio.c b/src/main/extiodrv/extio.c
index 8c50de2f..5b1ae6a4 100644
--- a/src/main/extiodrv/extio.c
+++ b/src/main/extiodrv/extio.c
@@ -2,7 +2,7 @@
#include "extio.h"
-#include "util/log.h"
+#include "core/log.h"
// static uint8_t _extiodrv_extio_sensor_read_mode_map[5] = {
// 1, // all
diff --git a/src/main/extiotest/Module.mk b/src/main/extiotest/Module.mk
index 73ec1b07..3e05ba08 100644
--- a/src/main/extiotest/Module.mk
+++ b/src/main/extiotest/Module.mk
@@ -3,6 +3,7 @@ exes += extiotest \
libs_extiotest := \
extiodrv \
extio \
+ core \
util \
src_extiotest := \
diff --git a/src/main/extiotest/main.c b/src/main/extiotest/main.c
index 3be152b1..c9e48bab 100644
--- a/src/main/extiotest/main.c
+++ b/src/main/extiotest/main.c
@@ -5,12 +5,15 @@
#include
-#include "extiodrv/extio.h"
+#include "core/log-bt.h"
+#include "core/log-sink-std.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "extiodrv/extio.h"
int main(int argc, char **argv)
{
+ struct core_log_sink log_sink;
HRESULT hr;
const char *port;
HANDLE handle;
@@ -22,8 +25,9 @@ int main(int argc, char **argv)
fprintf(stderr, " COM_PORT: For example COM1\n");
}
- log_to_writer(log_writer_stderr, NULL);
- log_set_level(LOG_LEVEL_MISC);
+ core_log_sink_std_err_open(true, &log_sink);
+ core_log_bt_init(&log_sink);
+ core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
port = argv[1];
diff --git a/src/main/ezusb-emu/device.c b/src/main/ezusb-emu/device.c
index 9f1eca82..9cf5c98d 100644
--- a/src/main/ezusb-emu/device.c
+++ b/src/main/ezusb-emu/device.c
@@ -9,6 +9,8 @@
#include
+#include "core/log.h"
+
#include "ezusb/ezusbsys2.h"
#include "ezusb/util.h"
@@ -25,7 +27,6 @@
#include "util/fs.h"
#include "util/hex.h"
#include "util/iobuf.h"
-#include "util/log.h"
#include "util/str.h"
// The max buffer size in iidx's ezusb client library is 4096 for the initial
diff --git a/src/main/ezusb-emu/node-coin.c b/src/main/ezusb-emu/node-coin.c
index 87e75037..6b4aed19 100644
--- a/src/main/ezusb-emu/node-coin.c
+++ b/src/main/ezusb-emu/node-coin.c
@@ -1,11 +1,11 @@
#define LOG_MODULE "ezusb-emu-node-coin"
+#include "core/log.h"
+
#include "ezusb-emu/node-coin.h"
#include "ezusb-iidx/coin-cmd.h"
-#include "util/log.h"
-
static uint8_t ezusb_iidx_emu_node_coin_mode = 0;
uint8_t ezusb_iidx_emu_node_coin_process_cmd(
diff --git a/src/main/ezusb-emu/node-eeprom.c b/src/main/ezusb-emu/node-eeprom.c
index ea6a3fea..f63d866f 100644
--- a/src/main/ezusb-emu/node-eeprom.c
+++ b/src/main/ezusb-emu/node-eeprom.c
@@ -2,12 +2,12 @@
#include
+#include "core/log.h"
+
#include "ezusb-emu/node-eeprom.h"
#include "ezusb-iidx/eeprom-cmd.h"
-#include "util/log.h"
-
/* not verified, but we got calls with 3 pages only so far */
#define EEPROM_NPAGES 3
diff --git a/src/main/ezusb-emu/node-security-mem.c b/src/main/ezusb-emu/node-security-mem.c
index 92422c82..8d11c5ff 100644
--- a/src/main/ezusb-emu/node-security-mem.c
+++ b/src/main/ezusb-emu/node-security-mem.c
@@ -2,11 +2,11 @@
#include
+#include "core/log.h"
+
#include "ezusb-emu/node-security-mem.h"
#include "ezusb-iidx/secmem-cmd.h"
-#include "util/log.h"
-
#define SECURITY2_NPAGES 5
/* Starting GOLD with the new IO2 (C02 is not affected), the game does not
diff --git a/src/main/ezusb-emu/node-security-plug.c b/src/main/ezusb-emu/node-security-plug.c
index 2b05a03a..ed57eed8 100644
--- a/src/main/ezusb-emu/node-security-plug.c
+++ b/src/main/ezusb-emu/node-security-plug.c
@@ -2,6 +2,8 @@
#include
+#include "core/log.h"
+
#include "ezusb-emu/node-eeprom.h"
#include "ezusb-emu/node-security-mem.h"
#include "ezusb-emu/node-security-plug.h"
@@ -11,8 +13,6 @@
#include "security/rp2.h"
#include "security/util.h"
-#include "util/log.h"
-
static struct security_mcode ezusb_iidx_emu_node_security_plug_boot_version;
static uint32_t ezusb_iidx_emu_node_security_plug_boot_seeds[3];
diff --git a/src/main/ezusb-emu/node-sram.c b/src/main/ezusb-emu/node-sram.c
index 200f1caf..dc3846b4 100644
--- a/src/main/ezusb-emu/node-sram.c
+++ b/src/main/ezusb-emu/node-sram.c
@@ -2,12 +2,13 @@
#include
+#include "core/log.h"
+
#include "ezusb-emu/conf.h"
#include "ezusb-emu/node-sram.h"
#include "ezusb-iidx/sram-cmd.h"
#include "util/fs.h"
-#include "util/log.h"
#define SRAM_NPAGES 12
diff --git a/src/main/ezusb-emu/node-wdt.c b/src/main/ezusb-emu/node-wdt.c
index 9185bdde..8c5c5416 100644
--- a/src/main/ezusb-emu/node-wdt.c
+++ b/src/main/ezusb-emu/node-wdt.c
@@ -1,10 +1,10 @@
#define LOG_MODULE "ezusb-emu-node-wdt"
+#include "core/log.h"
+
#include "ezusb-emu/node-wdt.h"
#include "ezusb-iidx/wdt-cmd.h"
-#include "util/log.h"
-
uint8_t ezusb_iidx_emu_node_wdt_process_cmd(
uint8_t cmd_id, uint8_t cmd_data, uint8_t cmd_data2)
{
diff --git a/src/main/ezusb-emu/util.c b/src/main/ezusb-emu/util.c
index 6e2798ae..30edd425 100644
--- a/src/main/ezusb-emu/util.c
+++ b/src/main/ezusb-emu/util.c
@@ -6,10 +6,11 @@
#include
#include
+#include "core/log.h"
+
#include "ezusb-emu/util.h"
#include "util/hex.h"
-#include "util/log.h"
enum ezusb_pipe {
/* This is just the NT driver API. Add 1 to get the actual EP number. */
diff --git a/src/main/ezusb-iidx-16seg-emu/node-16seg.c b/src/main/ezusb-iidx-16seg-emu/node-16seg.c
index 89bc5070..2121235e 100644
--- a/src/main/ezusb-iidx-16seg-emu/node-16seg.c
+++ b/src/main/ezusb-iidx-16seg-emu/node-16seg.c
@@ -6,9 +6,9 @@
#include "bemanitools/iidxio.h"
-#include "ezusb-iidx/seg16-cmd.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "ezusb-iidx/seg16-cmd.h"
uint8_t ezusb_iidx_emu_node_16seg_process_cmd(
uint8_t cmd_id, uint8_t cmd_data, uint8_t cmd_data2)
diff --git a/src/main/ezusb-iidx-emu/Module.mk b/src/main/ezusb-iidx-emu/Module.mk
index d6253631..16f2c1dd 100644
--- a/src/main/ezusb-iidx-emu/Module.mk
+++ b/src/main/ezusb-iidx-emu/Module.mk
@@ -1,6 +1,7 @@
libs += ezusb-iidx-emu
libs_ezusb-iidx-emu := \
+ core \
ezusb-emu \
ezusb-iidx-16seg-emu \
diff --git a/src/main/ezusb-iidx-emu/card-mag.c b/src/main/ezusb-iidx-emu/card-mag.c
index a210fd69..b65414ea 100644
--- a/src/main/ezusb-iidx-emu/card-mag.c
+++ b/src/main/ezusb-iidx-emu/card-mag.c
@@ -2,10 +2,11 @@
#include
+#include "core/log.h"
+
#include "security/mcode.h"
#include "util/crc.h"
-#include "util/log.h"
static const uint16_t ezusb_iidx_emu_card_mag_checksum_table_payload[256] = {
0x0, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
diff --git a/src/main/ezusb-iidx-emu/msg.c b/src/main/ezusb-iidx-emu/msg.c
index bcab6566..76b97423 100644
--- a/src/main/ezusb-iidx-emu/msg.c
+++ b/src/main/ezusb-iidx-emu/msg.c
@@ -6,6 +6,8 @@
#include "bemanitools/iidxio.h"
+#include "core/log.h"
+
#include "hook/iohook.h"
#include "ezusb-emu/msg.h"
@@ -21,7 +23,6 @@
#include "ezusb-iidx-16seg-emu/nodes.h"
#include "util/hex.h"
-#include "util/log.h"
/* ------------------------------------------------------------------------ */
diff --git a/src/main/ezusb-iidx-emu/node-fpga.c b/src/main/ezusb-iidx-emu/node-fpga.c
index d66c440c..6615b43f 100644
--- a/src/main/ezusb-iidx-emu/node-fpga.c
+++ b/src/main/ezusb-iidx-emu/node-fpga.c
@@ -2,12 +2,13 @@
#include
+#include "core/log.h"
+
#include "ezusb-iidx-emu/conf.h"
#include "ezusb-iidx-emu/node-fpga.h"
#include "ezusb-iidx/fpga-cmd.h"
#include "util/fs.h"
-#include "util/log.h"
static uint16_t ezusb_iidx_emu_node_fpga_write_ptr;
static uint16_t ezusb_iidx_emu_node_fpga_prog_size;
diff --git a/src/main/ezusb-iidx-emu/node-serial.c b/src/main/ezusb-iidx-emu/node-serial.c
index 378ab02f..7dc65193 100644
--- a/src/main/ezusb-iidx-emu/node-serial.c
+++ b/src/main/ezusb-iidx-emu/node-serial.c
@@ -4,6 +4,9 @@
#include "bemanitools/eamio.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "ezusb-iidx-emu/card-mag.c"
#include "ezusb-iidx-emu/node-serial.h"
#include "ezusb-iidx/serial-cmd.h"
@@ -11,9 +14,7 @@
#include "security/mcode.h"
#include "util/hex.h"
-#include "util/log.h"
#include "util/mem.h"
-#include "util/thread.h"
#define CARD_ID_LEN 8
@@ -292,7 +293,7 @@ void ezusb_iidx_emu_node_serial_init(void)
&ezusb_iidx_emu_node_serial_emulation_state[i].card_cs);
}
- ezusb_iidx_emu_node_serial_emu_thread = thread_create(
+ ezusb_iidx_emu_node_serial_emu_thread = core_thread_create(
ezusb_iidx_emu_node_serial_emu_thread_proc, NULL, 0x4000, 0);
}
diff --git a/src/main/ezusb-iidx-fpga-flash/Module.mk b/src/main/ezusb-iidx-fpga-flash/Module.mk
index c250b35b..320d6f49 100644
--- a/src/main/ezusb-iidx-fpga-flash/Module.mk
+++ b/src/main/ezusb-iidx-fpga-flash/Module.mk
@@ -4,6 +4,7 @@ ldflags_ezusb-iidx-fpga-flash := \
-lsetupapi \
libs_ezusb-iidx-fpga-flash := \
+ core \
ezusb \
ezusb-iidx \
util \
diff --git a/src/main/ezusb-iidx-fpga-flash/main.c b/src/main/ezusb-iidx-fpga-flash/main.c
index a8fb6816..f8dacdd3 100644
--- a/src/main/ezusb-iidx-fpga-flash/main.c
+++ b/src/main/ezusb-iidx-fpga-flash/main.c
@@ -3,11 +3,14 @@
#include
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log.h"
+
#include "ezusb-iidx/fpga.h"
#include "ezusb/ezusb.h"
#include "util/fs.h"
-#include "util/log.h"
int main(int argc, char **argv)
{
@@ -24,7 +27,8 @@ int main(int argc, char **argv)
return -1;
}
- log_to_writer(log_writer_stderr, NULL);
+ core_log_bt_ext_impl_set();
+ core_log_bt_ext_init_with_stderr();
log_info("Opening ezusb '%s'...", EZUSB_DEVICE_PATH);
diff --git a/src/main/ezusb-iidx-sram-flash/Module.mk b/src/main/ezusb-iidx-sram-flash/Module.mk
index b6e6a73d..a369b060 100644
--- a/src/main/ezusb-iidx-sram-flash/Module.mk
+++ b/src/main/ezusb-iidx-sram-flash/Module.mk
@@ -4,6 +4,7 @@ ldflags_ezusb-iidx-sram-flash := \
-lsetupapi \
libs_ezusb-iidx-sram-flash := \
+ core \
ezusb \
ezusb-iidx \
util \
diff --git a/src/main/ezusb-iidx-sram-flash/main.c b/src/main/ezusb-iidx-sram-flash/main.c
index d22464e0..b4fa94d3 100644
--- a/src/main/ezusb-iidx-sram-flash/main.c
+++ b/src/main/ezusb-iidx-sram-flash/main.c
@@ -3,11 +3,14 @@
#include
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log.h"
+
#include "ezusb-iidx/sram.h"
#include "ezusb/ezusb.h"
#include "util/fs.h"
-#include "util/log.h"
int main(int argc, char **argv)
{
@@ -24,7 +27,8 @@ int main(int argc, char **argv)
return -1;
}
- log_to_writer(log_writer_stdout, NULL);
+ core_log_bt_ext_impl_set();
+ core_log_bt_ext_init_with_stdout();
log_info("Opening ezusb '%s'...", argv[1]);
diff --git a/src/main/ezusb-iidx/ezusb-iidx.c b/src/main/ezusb-iidx/ezusb-iidx.c
index e82e2145..ae035b73 100644
--- a/src/main/ezusb-iidx/ezusb-iidx.c
+++ b/src/main/ezusb-iidx/ezusb-iidx.c
@@ -1,11 +1,12 @@
#define LOG_MODULE "ezusb-iidx"
+#include "core/log.h"
+
#include "ezusb-iidx/ezusb-iidx.h"
#include "ezusb/ezusbsys2.h"
#include "util/hex.h"
-#include "util/log.h"
#include "util/time.h"
#include "msg.h"
diff --git a/src/main/ezusb-iidx/fpga.c b/src/main/ezusb-iidx/fpga.c
index 23d5fd05..b4d25500 100644
--- a/src/main/ezusb-iidx/fpga.c
+++ b/src/main/ezusb-iidx/fpga.c
@@ -4,7 +4,7 @@
#include
-#include "util/log.h"
+#include "core/log.h"
#include "ezusb-iidx.h"
#include "fpga-cmd.h"
diff --git a/src/main/ezusb-iidx/sram.c b/src/main/ezusb-iidx/sram.c
index f816b383..fcce3840 100644
--- a/src/main/ezusb-iidx/sram.c
+++ b/src/main/ezusb-iidx/sram.c
@@ -1,8 +1,8 @@
#define LOG_MODULE "ezusb-iidx-sram"
-#include "ezusb-iidx/sram.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "ezusb-iidx/sram.h"
#include "ezusb-iidx.h"
#include "sram-cmd.h"
diff --git a/src/main/ezusb-tool/Module.mk b/src/main/ezusb-tool/Module.mk
index 349bc089..b5e81588 100644
--- a/src/main/ezusb-tool/Module.mk
+++ b/src/main/ezusb-tool/Module.mk
@@ -4,6 +4,7 @@ ldflags_ezusb-tool := \
-lsetupapi \
libs_ezusb-tool := \
+ core \
ezusb \
util \
diff --git a/src/main/ezusb-tool/main.c b/src/main/ezusb-tool/main.c
index 115f79c5..ca847815 100644
--- a/src/main/ezusb-tool/main.c
+++ b/src/main/ezusb-tool/main.c
@@ -3,11 +3,13 @@
#include
#include
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log.h"
+
#include "ezusb/ezusb.h"
#include "ezusb/util.h"
-#include "util/log.h"
-
static int info()
{
HANDLE handle;
@@ -103,7 +105,8 @@ int main(int argc, char **argv)
arg_pos = 1;
- log_to_writer(log_writer_stderr, NULL);
+ core_log_bt_ext_impl_set();
+ core_log_bt_ext_init_with_stderr();
if (!strcmp(argv[arg_pos], "info")) {
return info();
diff --git a/src/main/ezusb/ezusb.c b/src/main/ezusb/ezusb.c
index ce1b828e..7204589a 100644
--- a/src/main/ezusb/ezusb.c
+++ b/src/main/ezusb/ezusb.c
@@ -4,10 +4,11 @@
#include
// clang-format on
+#include "core/log.h"
+
#include "ezusb/ezusb.h"
#include "ezusb/ezusbsys2.h"
-#include "util/log.h"
#include "util/str.h"
static bool ezusb_reset(HANDLE handle, bool hold)
diff --git a/src/main/ezusb/util.c b/src/main/ezusb/util.c
index efc2cd10..5bf18a45 100644
--- a/src/main/ezusb/util.c
+++ b/src/main/ezusb/util.c
@@ -1,11 +1,12 @@
#include
#include
+#include "core/log.h"
+
#include "ezusb/util.h"
#include "util/crc.h"
#include "util/fs.h"
-#include "util/log.h"
#include "util/mem.h"
struct ezusb_firmware *ezusb_firmware_load(const char *file)
diff --git a/src/main/ezusb2-dbg-hook/Module.mk b/src/main/ezusb2-dbg-hook/Module.mk
index 4290f5cf..579e9bfb 100644
--- a/src/main/ezusb2-dbg-hook/Module.mk
+++ b/src/main/ezusb2-dbg-hook/Module.mk
@@ -1,6 +1,7 @@
dlls += ezusb2-dbg-hook
libs_ezusb2-dbg-hook := \
+ core \
hook \
util \
diff --git a/src/main/ezusb2-dbg-hook/main.c b/src/main/ezusb2-dbg-hook/main.c
index e90d3fb0..e1c1bdbb 100644
--- a/src/main/ezusb2-dbg-hook/main.c
+++ b/src/main/ezusb2-dbg-hook/main.c
@@ -10,13 +10,17 @@
#include
#include
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log-sink-file.h"
+#include "core/log.h"
+
#include "ezusb2/cyioctl.h"
#include "hook/table.h"
#include "util/cmdline.h"
#include "util/hex.h"
-#include "util/log.h"
#include "util/str.h"
static HANDLE STDCALL my_CreateFileW(
@@ -367,14 +371,13 @@ static void ezusb2_dbg_hook_terminate_process()
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
if (reason == DLL_PROCESS_ATTACH) {
- FILE *file;
int argc;
char **argv;
wchar_t *buffer;
uint32_t args_success;
- file = fopen("ezusb2_dbg.log", "w+");
- log_to_writer(log_writer_file, file);
+ core_log_bt_ext_impl_set();
+ core_log_bt_ext_init_with_file("ezusb2_dbg.log", false, false, 0);
hook_table_apply(
NULL,
diff --git a/src/main/ezusb2-emu/device.c b/src/main/ezusb2-emu/device.c
index f4652798..ecba8163 100644
--- a/src/main/ezusb2-emu/device.c
+++ b/src/main/ezusb2-emu/device.c
@@ -9,6 +9,8 @@
#include
+#include "core/log.h"
+
#include "ezusb/util.h"
#include "ezusb2/cyioctl.h"
@@ -27,7 +29,6 @@
#include "util/fs.h"
#include "util/hex.h"
#include "util/iobuf.h"
-#include "util/log.h"
#include "util/str.h"
// The max buffer size in iidx's ezusb client library is 4096 for the initial
diff --git a/src/main/ezusb2-emu/util.c b/src/main/ezusb2-emu/util.c
index 2abd5134..d5b12b92 100644
--- a/src/main/ezusb2-emu/util.c
+++ b/src/main/ezusb2-emu/util.c
@@ -6,13 +6,14 @@
#include
#include
+#include "core/log.h"
+
#include "ezusb2/cyioctl.h"
#include "ezusb2/ezusb2.h"
#include "ezusb-emu/util.h"
#include "util/hex.h"
-#include "util/log.h"
void ezusb2_emu_util_log_usb_msg(const char *prefix, const struct irp *irp)
{
diff --git a/src/main/ezusb2-iidx-emu/msg.c b/src/main/ezusb2-iidx-emu/msg.c
index 1279ea9b..bfc3dce8 100644
--- a/src/main/ezusb2-iidx-emu/msg.c
+++ b/src/main/ezusb2-iidx-emu/msg.c
@@ -6,6 +6,8 @@
#include "bemanitools/iidxio.h"
+#include "core/log.h"
+
#include "hook/iohook.h"
#include "ezusb-emu/msg.h"
@@ -15,7 +17,6 @@
#include "ezusb2-iidx/msg.h"
#include "util/hex.h"
-#include "util/log.h"
/* ------------------------------------------------------------------------ */
diff --git a/src/main/ezusb2-popn-emu/msg.c b/src/main/ezusb2-popn-emu/msg.c
index 6e83f7ac..d696ecc3 100644
--- a/src/main/ezusb2-popn-emu/msg.c
+++ b/src/main/ezusb2-popn-emu/msg.c
@@ -6,6 +6,8 @@
#include "bemanitools/popnio.h"
+#include "core/log.h"
+
#include "hook/iohook.h"
#include "ezusb-emu/msg.h"
@@ -19,7 +21,6 @@
#include "ezusb2-popn/msg.h"
#include "util/hex.h"
-#include "util/log.h"
/* ------------------------------------------------------------------------ */
diff --git a/src/main/ezusb2-popn-shim/Module.mk b/src/main/ezusb2-popn-shim/Module.mk
index aefc2d40..f4536c47 100644
--- a/src/main/ezusb2-popn-shim/Module.mk
+++ b/src/main/ezusb2-popn-shim/Module.mk
@@ -4,6 +4,7 @@ ldflags_ezusb2-popn-shim := \
-lsetupapi \
libs_ezusb2-popn-shim := \
+ core \
ezusb2-emu \
hook \
hooklib \
diff --git a/src/main/ezusb2-popn-shim/dllmain.c b/src/main/ezusb2-popn-shim/dllmain.c
index c8e16fcf..ec7e18f6 100644
--- a/src/main/ezusb2-popn-shim/dllmain.c
+++ b/src/main/ezusb2-popn-shim/dllmain.c
@@ -4,6 +4,8 @@
#include
+#include "core/log.h"
+
#include "ezusb2-emu/desc.h"
#include "ezusb2-emu/device.h"
@@ -13,8 +15,6 @@
#include "ezusb2-popn-shim/proxy.h"
-#include "util/log.h"
-
#define EZUSB_REAL_DLL_FILENAME "ezusb.dll"
static DWORD(STDCALL *real_entrypoint)(HMODULE self, DWORD reason, void *ctx);
diff --git a/src/main/ezusb2-popn-shim/proxy.c b/src/main/ezusb2-popn-shim/proxy.c
index fdf4f9f9..ec47002f 100644
--- a/src/main/ezusb2-popn-shim/proxy.c
+++ b/src/main/ezusb2-popn-shim/proxy.c
@@ -2,7 +2,7 @@
#include
#include
-#include "util/log.h"
+#include "core/log.h"
struct CoinParam;
struct EEP_HISTORY;
diff --git a/src/main/ezusb2-tool/Module.mk b/src/main/ezusb2-tool/Module.mk
index 06115652..87e6dff8 100644
--- a/src/main/ezusb2-tool/Module.mk
+++ b/src/main/ezusb2-tool/Module.mk
@@ -4,6 +4,7 @@ ldflags_ezusb2-tool := \
-lsetupapi \
libs_ezusb2-tool := \
+ core \
ezusb2 \
ezusb \
util \
diff --git a/src/main/ezusb2-tool/main.c b/src/main/ezusb2-tool/main.c
index cdfd179b..0579c077 100644
--- a/src/main/ezusb2-tool/main.c
+++ b/src/main/ezusb2-tool/main.c
@@ -3,11 +3,13 @@
#include
#include
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log.h"
+
#include "ezusb/util.h"
#include "ezusb2/ezusb2.h"
-#include "util/log.h"
-
static int scan()
{
char *path;
@@ -122,7 +124,8 @@ int main(int argc, char **argv)
arg_pos = 1;
- log_to_writer(log_writer_stderr, NULL);
+ core_log_bt_ext_impl_set();
+ core_log_bt_ext_init_with_stderr();
if (!strcmp(argv[arg_pos], "scan")) {
return scan();
diff --git a/src/main/ezusb2/ezusb2.c b/src/main/ezusb2/ezusb2.c
index 61fabd73..2c1b7b97 100644
--- a/src/main/ezusb2/ezusb2.c
+++ b/src/main/ezusb2/ezusb2.c
@@ -4,6 +4,8 @@
#include
// clang-format on
+#include "core/log.h"
+
#include "ezusb/ezusb.h"
#include "ezusb2/cyioctl.h"
@@ -11,7 +13,6 @@
#include "util/crc.h"
#include "util/fs.h"
-#include "util/log.h"
#include "util/str.h"
#define REQ_TYPE_HOST_TO_DEV 0x40
diff --git a/src/main/geninput/Module.mk b/src/main/geninput/Module.mk
index 1521d806..3115edf0 100644
--- a/src/main/geninput/Module.mk
+++ b/src/main/geninput/Module.mk
@@ -5,6 +5,7 @@ ldflags_geninput := \
-lsetupapi \
libs_geninput := \
+ core \
util \
src_geninput := \
diff --git a/src/main/geninput/dev-list.c b/src/main/geninput/dev-list.c
index 2bfcb4e8..ce6d93ac 100644
--- a/src/main/geninput/dev-list.c
+++ b/src/main/geninput/dev-list.c
@@ -9,9 +9,10 @@
#include
#include
+#include "core/log.h"
+
#include "geninput/dev-list.h"
-#include "util/log.h"
#include "util/mem.h"
void dev_list_init(struct dev_list *devs, const GUID *class_guid)
diff --git a/src/main/geninput/hid-generic.c b/src/main/geninput/hid-generic.c
index 41e73828..46c2924b 100644
--- a/src/main/geninput/hid-generic.c
+++ b/src/main/geninput/hid-generic.c
@@ -12,6 +12,8 @@
#include
// clang-format on
+#include "core/log.h"
+
#include "geninput/hid-generic-strings.h"
#include "geninput/hid-generic.h"
#include "geninput/hid-meta-in.h"
@@ -19,7 +21,6 @@
#include "geninput/hid.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"
diff --git a/src/main/geninput/hid-meta-in.c b/src/main/geninput/hid-meta-in.c
index bbaf44f1..3a324947 100644
--- a/src/main/geninput/hid-meta-in.c
+++ b/src/main/geninput/hid-meta-in.c
@@ -11,10 +11,11 @@
#include
#include
+#include "core/log.h"
+
#include "geninput/hid-meta-in.h"
#include "geninput/hid-report-in.h"
-#include "util/log.h"
#include "util/mem.h"
static bool
diff --git a/src/main/geninput/hid-meta-out.c b/src/main/geninput/hid-meta-out.c
index 94402835..19037851 100644
--- a/src/main/geninput/hid-meta-out.c
+++ b/src/main/geninput/hid-meta-out.c
@@ -12,10 +12,11 @@
#include
#include
+#include "core/log.h"
+
#include "geninput/hid-meta-out.h"
#include "geninput/hid-report-out.h"
-#include "util/log.h"
#include "util/mem.h"
static bool
@@ -50,8 +51,9 @@ bool hid_meta_out_init(
caps_fail:
/**
* Still allow the device to be used as input.
- * Useful for devices like the Sony DUALSHOCK 4, where it indicates it can receive outputs
- * but it errors out when trying to initialize an output report.
+ * Useful for devices like the Sony DUALSHOCK 4, where it indicates it can
+ * receive outputs but it errors out when trying to initialize an output
+ * report.
*/
return true;
}
@@ -213,7 +215,7 @@ static bool hid_meta_out_init_arrays(struct hid_meta_out *meta)
meta->nreports = 0;
free(meta->reports);
meta->reports = NULL;
-
+
meta->nlights = 0;
meta->nbuttons = 0;
// Failed out before allocating memory
diff --git a/src/main/geninput/hid-mgr.c b/src/main/geninput/hid-mgr.c
index f22d3a78..2f8a7c13 100644
--- a/src/main/geninput/hid-mgr.c
+++ b/src/main/geninput/hid-mgr.c
@@ -2,9 +2,10 @@
#include
+#include "core/log.h"
+
#include "geninput/hid-mgr.h"
-#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"
diff --git a/src/main/geninput/hid-report-in.c b/src/main/geninput/hid-report-in.c
index 721a721d..aec213de 100644
--- a/src/main/geninput/hid-report-in.c
+++ b/src/main/geninput/hid-report-in.c
@@ -10,9 +10,10 @@
#include
#include
+#include "core/log.h"
+
#include "geninput/hid-report-in.h"
-#include "util/log.h"
#include "util/mem.h"
void hid_report_in_init(
diff --git a/src/main/geninput/hid-report-out.c b/src/main/geninput/hid-report-out.c
index 5469e3a3..892cd13f 100644
--- a/src/main/geninput/hid-report-out.c
+++ b/src/main/geninput/hid-report-out.c
@@ -11,9 +11,10 @@
#include
#include
+#include "core/log.h"
+
#include "geninput/hid-report-out.h"
-#include "util/log.h"
#include "util/mem.h"
bool hid_report_out_init(
diff --git a/src/main/geninput/hid.c b/src/main/geninput/hid.c
index 57685b02..889ee80f 100644
--- a/src/main/geninput/hid.c
+++ b/src/main/geninput/hid.c
@@ -1,10 +1,11 @@
#include
#include
+#include "core/log.h"
+
#include "geninput/dev-list.h"
#include "geninput/hid.h"
-#include "util/log.h"
#include "util/str.h"
wchar_t *hid_ri_init_name(const GUID *class_guid, const char *dev_node)
diff --git a/src/main/geninput/hotplug.c b/src/main/geninput/hotplug.c
index 54dad425..d9954d37 100644
--- a/src/main/geninput/hotplug.c
+++ b/src/main/geninput/hotplug.c
@@ -6,13 +6,13 @@
#include
+#include "core/log.h"
+
#include "geninput/hid.h"
#include "geninput/hotplug.h"
#include "geninput/io-thread.h"
#include "geninput/ri.h"
-#include "util/log.h"
-
static HDEVNOTIFY hotplug_handle;
void hotplug_init(HWND wnd)
diff --git a/src/main/geninput/input.c b/src/main/geninput/input.c
index ef5f4b09..3f21d681 100644
--- a/src/main/geninput/input.c
+++ b/src/main/geninput/input.c
@@ -7,6 +7,9 @@
#include "bemanitools/glue.h"
#include "bemanitools/input.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "geninput/hid-mgr.h"
#include "geninput/hid.h"
#include "geninput/io-thread.h"
@@ -14,10 +17,8 @@
#include "geninput/mapper.h"
#include "util/fs.h"
-#include "util/log.h"
#include "util/msg-thread.h"
#include "util/str.h"
-#include "util/thread.h"
static HINSTANCE input_hinst;
static volatile long input_init_count;
@@ -37,7 +38,7 @@ void input_set_loggers(
log_formatter_t warning,
log_formatter_t fatal)
{
- log_to_external(misc, info, warning, fatal);
+ core_log_impl_set(misc, info, warning, fatal);
}
void input_init(
@@ -53,7 +54,7 @@ void input_init(
mapper_inst = mapper_impl_create();
- thread_api_init(create, join, destroy);
+ core_thread_impl_set(create, join, destroy);
msg_thread_init(input_hinst);
io_thread_init();
}
diff --git a/src/main/geninput/io-thread.c b/src/main/geninput/io-thread.c
index ca663ff3..18f5ccca 100644
--- a/src/main/geninput/io-thread.c
+++ b/src/main/geninput/io-thread.c
@@ -2,6 +2,9 @@
#include
+#include "core/log.h"
+#include "core/thread.h"
+
#include "geninput/dev-list.h"
#include "geninput/hid-generic.h"
#include "geninput/hid-mgr.h"
@@ -10,9 +13,7 @@
#include "geninput/pacdrive.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/mem.h"
-#include "util/thread.h"
enum io_thread_cmd {
IO_THREAD_CMD_STOP,
@@ -172,7 +173,7 @@ void io_thread_init(void)
barrier = CreateEvent(NULL, TRUE, FALSE, NULL);
- io_thread_id = thread_create(io_thread_proc, barrier, 16384, 0);
+ io_thread_id = core_thread_create(io_thread_proc, barrier, 16384, 0);
WaitForSingleObject(barrier, INFINITE);
CloseHandle(barrier);
@@ -200,6 +201,6 @@ void io_thread_fini(void)
PostQueuedCompletionStatus(io_thread_cp, 0, (uintptr_t) &msg, NULL);
- thread_join(io_thread_id, NULL);
- thread_destroy(io_thread_id);
+ core_thread_join(io_thread_id, NULL);
+ core_thread_destroy(io_thread_id);
}
diff --git a/src/main/geninput/kbd.c b/src/main/geninput/kbd.c
index 9ae8e5ed..191890b0 100644
--- a/src/main/geninput/kbd.c
+++ b/src/main/geninput/kbd.c
@@ -11,12 +11,13 @@
#include
#include
+#include "core/log.h"
+
#include "geninput/hid.h"
#include "geninput/kbd-data.h"
#include "geninput/kbd.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"
diff --git a/src/main/geninput/mapper.c b/src/main/geninput/mapper.c
index 96da997e..b6c40f49 100644
--- a/src/main/geninput/mapper.c
+++ b/src/main/geninput/mapper.c
@@ -1,11 +1,12 @@
#include
#include
+#include "core/log.h"
+
#include "geninput/hid-mgr.h"
#include "geninput/mapper.h"
#include "util/array.h"
-#include "util/log.h"
#include "util/mem.h"
struct action_iter {
diff --git a/src/main/geninput/mouse.c b/src/main/geninput/mouse.c
index 2b24d1c8..f1c54bfd 100644
--- a/src/main/geninput/mouse.c
+++ b/src/main/geninput/mouse.c
@@ -12,11 +12,12 @@
#include
#include
+#include "core/log.h"
+
#include "geninput/hid.h"
#include "geninput/mouse.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"
diff --git a/src/main/geninput/msg-thread.c b/src/main/geninput/msg-thread.c
index cc21ae06..7ca47f32 100644
--- a/src/main/geninput/msg-thread.c
+++ b/src/main/geninput/msg-thread.c
@@ -6,10 +6,11 @@
#include
+#include "core/log.h"
+
#include "geninput/hotplug.h"
#include "geninput/ri.h"
-#include "util/log.h"
#include "util/msg-thread.h"
void msg_window_setup(HWND hwnd)
diff --git a/src/main/geninput/pacdrive.c b/src/main/geninput/pacdrive.c
index 2a5ab36f..b388036f 100644
--- a/src/main/geninput/pacdrive.c
+++ b/src/main/geninput/pacdrive.c
@@ -11,12 +11,13 @@
#include
#include
+#include "core/log.h"
+
#include "geninput/hid.h"
#include "geninput/io-thread.h"
#include "geninput/pacdrive.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/mem.h"
/* The PacDrive appears to have a malformed descriptor for its OUT report.
diff --git a/src/main/geninput/ri.c b/src/main/geninput/ri.c
index b3befee9..45b6d65b 100644
--- a/src/main/geninput/ri.c
+++ b/src/main/geninput/ri.c
@@ -1,5 +1,7 @@
#include
+#include "core/log.h"
+
#include "geninput/hid-mgr.h"
#include "geninput/hid.h"
#include "geninput/kbd.h"
@@ -7,7 +9,6 @@
#include "geninput/ri.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/mem.h"
struct ri_handle {
diff --git a/src/main/hook/d3d9.c b/src/main/hook/d3d9.c
index 45e1fd14..0f09ec68 100644
--- a/src/main/hook/d3d9.c
+++ b/src/main/hook/d3d9.c
@@ -1,11 +1,11 @@
#define LOG_MODULE "hook-d3d9"
-#include "hook/d3d9.h"
+#include "core/log.h"
+
#include "hook/com-proxy.h"
+#include "hook/d3d9.h"
#include "hook/table.h"
-#include "util/log.h"
-
/* ------------------------------------------------------------------------------------------------------------------
*/
diff --git a/src/main/hook/table.c b/src/main/hook/table.c
index ed67b3b6..285a43d3 100644
--- a/src/main/hook/table.c
+++ b/src/main/hook/table.c
@@ -15,12 +15,21 @@ static const size_t apiset_prefix_len = sizeof(apiset_prefix) - 1;
static void hook_table_apply_to_all(
const char *depname, const struct hook_symbol *syms, size_t nsyms);
+static void hook_table_revert_to_all(
+ const char *depname, const struct hook_symbol *syms, size_t nsyms);
+
static void hook_table_apply_to_iid(
HMODULE target,
const pe_iid_t *iid,
const struct hook_symbol *syms,
size_t nsyms);
+static void hook_table_revert_to_iid(
+ HMODULE target,
+ const pe_iid_t *iid,
+ const struct hook_symbol *syms,
+ size_t nsyms);
+
static bool hook_table_match_module(
HMODULE target, const char *iid_name, const char *depname);
@@ -44,6 +53,23 @@ static void hook_table_apply_to_all(
}
}
+static void hook_table_revert_to_all(
+ const char *depname, const struct hook_symbol *syms, size_t nsyms)
+{
+ const peb_dll_t *dll;
+ HMODULE pe;
+
+ for (dll = peb_dll_get_first(); dll != NULL; dll = peb_dll_get_next(dll)) {
+ pe = peb_dll_get_base(dll);
+
+ if (pe == NULL) {
+ continue; /* ?? Happens sometimes. */
+ }
+
+ hook_table_revert(pe, depname, syms, nsyms);
+ }
+}
+
void hook_table_apply(
HMODULE target,
const char *depname,
@@ -73,6 +99,35 @@ void hook_table_apply(
}
}
+void hook_table_revert(
+ HMODULE target,
+ const char *depname,
+ const struct hook_symbol *syms,
+ size_t nsyms)
+{
+ const pe_iid_t *iid;
+ const char *iid_name;
+
+ assert(depname != NULL);
+ assert(syms != NULL || nsyms == 0);
+
+ if (target == NULL) {
+ /* Call out, which will then call us back repeatedly. Awkward, but
+ viewed from the outside it's good for usability. */
+
+ hook_table_revert_to_all(depname, syms, nsyms);
+ } else {
+ for (iid = pe_iid_get_first(target); iid != NULL;
+ iid = pe_iid_get_next(target, iid)) {
+ iid_name = pe_iid_get_name(target, iid);
+
+ if (hook_table_match_module(target, iid_name, depname)) {
+ hook_table_revert_to_iid(target, iid, syms, nsyms);
+ }
+ }
+ }
+}
+
static void hook_table_apply_to_iid(
HMODULE target,
const pe_iid_t *iid,
@@ -101,6 +156,34 @@ static void hook_table_apply_to_iid(
}
}
+static void hook_table_revert_to_iid(
+ HMODULE target,
+ const pe_iid_t *iid,
+ const struct hook_symbol *syms,
+ size_t nsyms)
+{
+ struct pe_iat_entry iate;
+ size_t i;
+ size_t j;
+ const struct hook_symbol *sym;
+
+ i = 0;
+
+ while (pe_iid_get_iat_entry(target, iid, i++, &iate) == S_OK) {
+ for (j = 0; j < nsyms; j++) {
+ sym = &syms[j];
+
+ if (hook_table_match_proc(&iate, sym)) {
+ // Only revert-able if the original pointer was stored
+ // previously
+ if (sym->link != NULL && *sym->link != NULL) {
+ pe_patch(iate.ppointer, sym->link, sizeof(*sym->link));
+ }
+ }
+ }
+ }
+}
+
static bool hook_table_match_module(
HMODULE target, const char *iid_name, const char *depname)
{
diff --git a/src/main/hooklib/acp.c b/src/main/hooklib/acp.c
index 52675b2d..81faa738 100644
--- a/src/main/hooklib/acp.c
+++ b/src/main/hooklib/acp.c
@@ -6,13 +6,14 @@
#include
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "hooklib/acp.h"
#include "util/codepage.h"
#include "util/defs.h"
-#include "util/log.h"
static NTSTATUS NTAPI my_RtlMultiByteToUnicodeN(
wchar_t *dest,
diff --git a/src/main/hooklib/adapter.c b/src/main/hooklib/adapter.c
index 0b94c125..8b3b6d9f 100644
--- a/src/main/hooklib/adapter.c
+++ b/src/main/hooklib/adapter.c
@@ -6,13 +6,14 @@
#include
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "hooklib/adapter.h"
#include "util/codepage.h"
#include "util/defs.h"
-#include "util/log.h"
static DWORD WINAPI
my_GetAdaptersInfo(PIP_ADAPTER_INFO adapter_info, PULONG out_buf_len);
diff --git a/src/main/hooklib/app.c b/src/main/hooklib/app.c
index 7ccd441d..11fb8243 100644
--- a/src/main/hooklib/app.c
+++ b/src/main/hooklib/app.c
@@ -1,5 +1,7 @@
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "hooklib/app.h"
@@ -7,7 +9,6 @@
#include "imports/avs.h"
#include "imports/eapki.h"
-#include "util/log.h"
#include "util/str.h"
static dll_entry_init_t hook_dll_entry_init;
diff --git a/src/main/hooklib/config-adapter.c b/src/main/hooklib/config-adapter.c
index 49c24505..0ddb6806 100644
--- a/src/main/hooklib/config-adapter.c
+++ b/src/main/hooklib/config-adapter.c
@@ -1,8 +1,8 @@
#include "cconfig/cconfig-util.h"
-#include "hooklib/config-adapter.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "hooklib/config-adapter.h"
#define HOOKLIB_CONFIG_ADAPTER_OVERRIDE_IP_KEY "adapter.override_ip"
diff --git a/src/main/hooklib/memfile.c b/src/main/hooklib/memfile.c
index 08dbeba1..09c05878 100644
--- a/src/main/hooklib/memfile.c
+++ b/src/main/hooklib/memfile.c
@@ -3,12 +3,13 @@
#include
#include
+#include "core/log.h"
+
#include "hook/hr.h"
#include "hook/iohook.h"
#include "hook/table.h"
#include "util/array.h"
-#include "util/log.h"
#include "util/str.h"
struct file_entry {
diff --git a/src/main/hooklib/rs232.c b/src/main/hooklib/rs232.c
index 8d6d371f..591c98f4 100644
--- a/src/main/hooklib/rs232.c
+++ b/src/main/hooklib/rs232.c
@@ -14,12 +14,13 @@
#include
#include
+#include "core/log.h"
+
#include "hook/hr.h"
#include "hook/iohook.h"
#include "hook/table.h"
#include "util/array.h"
-#include "util/log.h"
/* RS232 API hooks */
diff --git a/src/main/hooklib/setupapi.c b/src/main/hooklib/setupapi.c
index 07dc72cf..5363c52a 100644
--- a/src/main/hooklib/setupapi.c
+++ b/src/main/hooklib/setupapi.c
@@ -4,12 +4,13 @@
#include
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "hooklib/setupapi.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
/* my hooks */
diff --git a/src/main/iidx-bio2-exit-hook/Module.mk b/src/main/iidx-bio2-exit-hook/Module.mk
index dcf7289b..085af3a8 100644
--- a/src/main/iidx-bio2-exit-hook/Module.mk
+++ b/src/main/iidx-bio2-exit-hook/Module.mk
@@ -4,6 +4,7 @@ ldflags_iidx-bio2-exit-hook := \
-lsetupapi \
libs_iidx-bio2-exit-hook := \
+ core \
bio2drv \
hook \
util \
diff --git a/src/main/iidx-bio2-exit-hook/main.c b/src/main/iidx-bio2-exit-hook/main.c
index 13ac8251..2718717c 100644
--- a/src/main/iidx-bio2-exit-hook/main.c
+++ b/src/main/iidx-bio2-exit-hook/main.c
@@ -11,10 +11,13 @@
#include "bio2/bi2a-iidx.h"
#include "bio2drv/detect.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log.h"
+
#include "hook/iobuf.h"
#include "hook/iohook.h"
-#include "util/log.h"
#include "util/mem.h"
#include "util/proc.h"
#include "util/str.h"
@@ -224,7 +227,8 @@ static HRESULT _iohook_handler(struct irp *irp)
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
- log_to_writer(log_writer_stdout, NULL);
+ core_log_bt_ext_impl_set();
+ core_log_bt_ext_init_with_stdout();
if (reason != DLL_PROCESS_ATTACH) {
return TRUE;
diff --git a/src/main/iidx-ezusb-exit-hook/Module.mk b/src/main/iidx-ezusb-exit-hook/Module.mk
index 4050ebe1..500bd156 100644
--- a/src/main/iidx-ezusb-exit-hook/Module.mk
+++ b/src/main/iidx-ezusb-exit-hook/Module.mk
@@ -1,6 +1,7 @@
dlls += iidx-ezusb-exit-hook
libs_iidx-ezusb-exit-hook := \
+ core \
ezusb-iidx \
hook \
util \
diff --git a/src/main/iidx-ezusb2-exit-hook/Module.mk b/src/main/iidx-ezusb2-exit-hook/Module.mk
index 7828a97b..f449f383 100644
--- a/src/main/iidx-ezusb2-exit-hook/Module.mk
+++ b/src/main/iidx-ezusb2-exit-hook/Module.mk
@@ -1,6 +1,7 @@
dlls += iidx-ezusb2-exit-hook
libs_iidx-ezusb2-exit-hook := \
+ core \
hook \
util \
diff --git a/src/main/iidx-irbeat-patch/Module.mk b/src/main/iidx-irbeat-patch/Module.mk
index df42cd3d..d01645fa 100644
--- a/src/main/iidx-irbeat-patch/Module.mk
+++ b/src/main/iidx-irbeat-patch/Module.mk
@@ -2,6 +2,7 @@ exes += iidx-irbeat-patch
libs_iidx-irbeat-patch := \
util \
+ core \
src_iidx-irbeat-patch := \
main.c \
diff --git a/src/main/iidxhook-d3d9/bb-scale-hd.c b/src/main/iidxhook-d3d9/bb-scale-hd.c
index 60dae6be..84afe7c8 100644
--- a/src/main/iidxhook-d3d9/bb-scale-hd.c
+++ b/src/main/iidxhook-d3d9/bb-scale-hd.c
@@ -2,13 +2,13 @@
#include
+#include "core/log.h"
+
#include "d3d9-util/vertex.h"
#include "bb-scale-hd.h"
#include "util.h"
-#include "util/log.h"
-
static bool iidxhook_d3d9_bb_scale_initialized;
static uint16_t iidxhook_d3d9_bb_scale_hd_width;
static uint16_t iidxhook_d3d9_bb_scale_hd_height;
diff --git a/src/main/iidxhook-d3d9/util.h b/src/main/iidxhook-d3d9/util.h
index 3a77e99b..96b489e0 100644
--- a/src/main/iidxhook-d3d9/util.h
+++ b/src/main/iidxhook-d3d9/util.h
@@ -3,9 +3,9 @@
#include
-#include "d3d9-util/dxerr9.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "d3d9-util/dxerr9.h"
inline void
iidxhook_d3d9_util_check_and_handle_failure(HRESULT hr, const char *msg)
diff --git a/src/main/iidxhook-util/Module.mk b/src/main/iidxhook-util/Module.mk
index 92fe44d8..50dd18dc 100644
--- a/src/main/iidxhook-util/Module.mk
+++ b/src/main/iidxhook-util/Module.mk
@@ -1,6 +1,7 @@
libs += iidxhook-util
libs_iidxhook-util := \
+ core \
util \
src_iidxhook-util := \
diff --git a/src/main/iidxhook-util/acio.c b/src/main/iidxhook-util/acio.c
index 62913361..a52fa766 100644
--- a/src/main/iidxhook-util/acio.c
+++ b/src/main/iidxhook-util/acio.c
@@ -15,6 +15,8 @@
#include "acioemu/emu.h"
#include "acioemu/icca.h"
+#include "core/log.h"
+
#include "hook/iohook.h"
#include "hooklib/rs232.h"
@@ -24,7 +26,6 @@
#include "util/defs.h"
#include "util/iobuf.h"
-#include "util/log.h"
#include "util/str.h"
static struct ac_io_emu iidxhook_util_acio_emu;
diff --git a/src/main/iidxhook-util/chart-patch.c b/src/main/iidxhook-util/chart-patch.c
index 4b2970ec..b6cc290d 100644
--- a/src/main/iidxhook-util/chart-patch.c
+++ b/src/main/iidxhook-util/chart-patch.c
@@ -4,12 +4,13 @@
#include
#include
+#include "core/log.h"
+
#include "hook/iohook.h"
#include "util/crc.h"
#include "util/defs.h"
#include "util/fs.h"
-#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"
diff --git a/src/main/iidxhook-util/clock.c b/src/main/iidxhook-util/clock.c
index 8c870fff..dc0e2f2f 100644
--- a/src/main/iidxhook-util/clock.c
+++ b/src/main/iidxhook-util/clock.c
@@ -2,10 +2,11 @@
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "util/defs.h"
-#include "util/log.h"
static BOOL STDCALL my_SetLocalTime(const SYSTEMTIME *lpSystemTime);
static BOOL(STDCALL *real_SetLocalTime)(const SYSTEMTIME *lpSystemTime);
diff --git a/src/main/iidxhook-util/config-eamuse.c b/src/main/iidxhook-util/config-eamuse.c
index f59b03e8..c75bd1a7 100644
--- a/src/main/iidxhook-util/config-eamuse.c
+++ b/src/main/iidxhook-util/config-eamuse.c
@@ -2,12 +2,12 @@
#include "cconfig/cconfig-util.h"
+#include "core/log.h"
+
#include "iidxhook-util/config-eamuse.h"
#include "security/mcode.h"
-#include "util/log.h"
-
#define IIDXHOOK_CONFIG_EAMUSE_CARD_TYPE_KEY "eamuse.card_type"
#define IIDXHOOK_CONFIG_EAMUSE_SERVER_KEY "eamuse.server"
#define IIDXHOOK_CONFIG_EAMUSE_PCBID_KEY "eamuse.pcbid"
diff --git a/src/main/iidxhook-util/config-ezusb.c b/src/main/iidxhook-util/config-ezusb.c
index e860a1d5..14d953d2 100644
--- a/src/main/iidxhook-util/config-ezusb.c
+++ b/src/main/iidxhook-util/config-ezusb.c
@@ -3,9 +3,10 @@
#include "cconfig/cconfig-util.h"
+#include "core/log.h"
+
#include "iidxhook-util/config-ezusb.h"
-#include "util/log.h"
#include "util/mem.h"
#define IIDXHOOK_UTIL_CONFIG_EZUSB_API_CALL_MONITORING_KEY \
diff --git a/src/main/iidxhook-util/config-gfx.c b/src/main/iidxhook-util/config-gfx.c
index e591f480..1be281fe 100644
--- a/src/main/iidxhook-util/config-gfx.c
+++ b/src/main/iidxhook-util/config-gfx.c
@@ -2,9 +2,9 @@
#include "cconfig/cconfig-util.h"
-#include "iidxhook-util/config-gfx.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "iidxhook-util/config-gfx.h"
#define IIDXHOOK_CONFIG_GFX_BGVIDEO_UV_FIX_KEY "gfx.bgvideo_uv_fix"
#define IIDXHOOK_CONFIG_GFX_FRAMED_KEY "gfx.framed"
diff --git a/src/main/iidxhook-util/config-io.c b/src/main/iidxhook-util/config-io.c
index 3055ac6e..13c59f3c 100644
--- a/src/main/iidxhook-util/config-io.c
+++ b/src/main/iidxhook-util/config-io.c
@@ -1,8 +1,8 @@
#include "cconfig/cconfig-util.h"
-#include "iidxhook-util/config-io.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "iidxhook-util/config-io.h"
#define IIDXHOOK_UTIL_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY \
"io.disable_card_reader_emu"
diff --git a/src/main/iidxhook-util/config-misc.c b/src/main/iidxhook-util/config-misc.c
index 7a18499e..fca5ea5a 100644
--- a/src/main/iidxhook-util/config-misc.c
+++ b/src/main/iidxhook-util/config-misc.c
@@ -1,8 +1,8 @@
#include "cconfig/cconfig-util.h"
-#include "iidxhook-util/config-misc.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "iidxhook-util/config-misc.h"
#define IIDXHOOK_CONFIG_MISC_DISABLE_CLOCK_SET_KEY "misc.disable_clock_set"
#define IIDXHOOK_CONFIG_MISC_RTEFFECT_STUB_KEY "misc.rteffect_stub"
diff --git a/src/main/iidxhook-util/config-sec.c b/src/main/iidxhook-util/config-sec.c
index 54cb0eea..a2e9a573 100644
--- a/src/main/iidxhook-util/config-sec.c
+++ b/src/main/iidxhook-util/config-sec.c
@@ -3,12 +3,13 @@
#include "cconfig/cconfig-util.h"
+#include "core/log.h"
+
#include "iidxhook-util/config-sec.h"
#include "security/mcode.h"
#include "security/rp.h"
-#include "util/log.h"
#include "util/mem.h"
#define IIDXHOOK_CONFIG_SEC_BOOT_VERSION_KEY "sec.boot_version"
diff --git a/src/main/iidxhook-util/d3d9.c b/src/main/iidxhook-util/d3d9.c
index 9c877199..eeb5081f 100644
--- a/src/main/iidxhook-util/d3d9.c
+++ b/src/main/iidxhook-util/d3d9.c
@@ -9,6 +9,8 @@
#include
#include
+#include "core/log.h"
+
#include "hook/com-proxy.h"
#include "hook/table.h"
@@ -16,7 +18,6 @@
#include "iidxhook-util/vertex-shader.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
#include "util/time.h"
diff --git a/src/main/iidxhook-util/eamuse.c b/src/main/iidxhook-util/eamuse.c
index 15d77da9..6a127bd3 100644
--- a/src/main/iidxhook-util/eamuse.c
+++ b/src/main/iidxhook-util/eamuse.c
@@ -8,12 +8,13 @@
#include
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "iidxhook-util/eamuse.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
/* ------------------------------------------------------------------------- */
diff --git a/src/main/iidxhook-util/effector.c b/src/main/iidxhook-util/effector.c
index 4f30e279..f313c602 100644
--- a/src/main/iidxhook-util/effector.c
+++ b/src/main/iidxhook-util/effector.c
@@ -2,12 +2,13 @@
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "iidxhook-util/effector.h"
#include "util/defs.h"
-#include "util/log.h"
static BOOL my_EnableEqualizer(int a1);
static BOOL my_GetEqualizerStatus(LPVOID buffer);
diff --git a/src/main/iidxhook-util/log-server.c b/src/main/iidxhook-util/log-server.c
index 1a7f687c..5a2fe3d2 100644
--- a/src/main/iidxhook-util/log-server.c
+++ b/src/main/iidxhook-util/log-server.c
@@ -5,6 +5,9 @@
#include
#include
+#include "core/log.h"
+#include "core/thread.h"
+
#include "hook/table.h"
#include "iidxhook-util/log-server.h"
@@ -12,9 +15,7 @@
#include "imports/avs.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
-#include "util/thread.h"
static int log_thread_proc(void *ctx);
static void
@@ -39,7 +40,7 @@ void log_server_init(void)
log_rv_consumer = CreateSemaphore(NULL, 0, 1, NULL);
ready = CreateEvent(NULL, TRUE, FALSE, NULL);
- log_to_external(
+ core_log_impl_set(
log_post_misc, log_post_info, log_post_warning, log_post_fatal);
log_thread_id = avs_thread_create(log_thread_proc, ready, 16384, 0);
diff --git a/src/main/iidxhook-util/settings.c b/src/main/iidxhook-util/settings.c
index b4f2ce3f..5402f695 100644
--- a/src/main/iidxhook-util/settings.c
+++ b/src/main/iidxhook-util/settings.c
@@ -7,12 +7,13 @@
#include
#include
+#include "core/log.h"
+
#include "hook/iohook.h"
#include "hook/table.h"
#include "util/defs.h"
#include "util/fs.h"
-#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"
diff --git a/src/main/iidxhook1/Module.mk b/src/main/iidxhook1/Module.mk
index fcfad98b..61bb5ff4 100644
--- a/src/main/iidxhook1/Module.mk
+++ b/src/main/iidxhook1/Module.mk
@@ -5,6 +5,7 @@ ldflags_iidxhook1 := \
-liphlpapi \
libs_iidxhook1 := \
+ core \
iidxhook-util \
ezusb-emu \
ezusb-iidx-16seg-emu \
diff --git a/src/main/iidxhook1/config-iidxhook1.c b/src/main/iidxhook1/config-iidxhook1.c
index 5a02c95c..b88d4718 100644
--- a/src/main/iidxhook1/config-iidxhook1.c
+++ b/src/main/iidxhook1/config-iidxhook1.c
@@ -1,8 +1,8 @@
#include "cconfig/cconfig-util.h"
-#include "iidxhook1/config-iidxhook1.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "iidxhook1/config-iidxhook1.h"
#define IIDXHOOK_CONFIG_MISC_HAPPY_SKY_MS_BG_FIX_KEY "misc.happy_sky_ms_bg_fix"
diff --git a/src/main/iidxhook1/dllmain.c b/src/main/iidxhook1/dllmain.c
index a3a4a357..60c61a75 100644
--- a/src/main/iidxhook1/dllmain.c
+++ b/src/main/iidxhook1/dllmain.c
@@ -9,6 +9,14 @@
#include "cconfig/cconfig-hook.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log-sink-debug.h"
+#include "core/log.h"
+#include "core/thread-crt-ext.h"
+#include "core/thread-crt.h"
+#include "core/thread.h"
+
#include "ezusb-emu/desc.h"
#include "ezusb-emu/device.h"
#include "ezusb-emu/node-security-plug.h"
@@ -42,8 +50,6 @@
#include "iidxhook1/log-ezusb.h"
#include "util/defs.h"
-#include "util/log.h"
-#include "util/thread.h"
#define IIDXHOOK1_INFO_HEADER \
"iidxhook for 9th Style, 10th Style, RED and HAPPY SKY" \
@@ -68,6 +74,14 @@ static const struct hook_symbol init_hook_syms[] = {
},
};
+static void _iidxhook1_log_init()
+{
+ core_log_bt_ext_impl_set();
+ core_log_bt_ext_init_with_debug();
+ // TODO change log level support
+ core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
+}
+
static void iidxhook1_setup_d3d9_hooks(
const struct iidxhook_config_gfx *config_gfx,
const struct iidxhook_config_iidxhook1 *config_iidxhook1)
@@ -215,20 +229,24 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
/* Start up IIDXIO.DLL */
log_info("Starting IIDX IO backend");
- iidx_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(iidx_io_set_loggers);
- if (!iidx_io_init(thread_create, thread_join, thread_destroy)) {
+ if (!iidx_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing IIDX IO backend failed");
}
/* Start up EAMIO.DLL */
log_misc("Initializing card reader backend");
- eam_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
- if (!eam_io_init(thread_create, thread_join, thread_destroy)) {
+ if (!eam_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing card reader backend failed");
}
@@ -261,7 +279,9 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
if (reason == DLL_PROCESS_ATTACH) {
- log_to_writer(log_writer_debug, NULL);
+ core_thread_crt_ext_impl_set();
+
+ _iidxhook1_log_init();
/* Bootstrap hook for further init tasks (see above) */
diff --git a/src/main/iidxhook1/ezusb-mon.c b/src/main/iidxhook1/ezusb-mon.c
index b76418a6..11f10f9e 100644
--- a/src/main/iidxhook1/ezusb-mon.c
+++ b/src/main/iidxhook1/ezusb-mon.c
@@ -6,12 +6,13 @@
#include
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "iidxhook1/ezusb-mon.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
/* ------------------------------------------------------------------------- */
diff --git a/src/main/iidxhook1/log-ezusb.c b/src/main/iidxhook1/log-ezusb.c
index ac71907b..28a9c6a1 100644
--- a/src/main/iidxhook1/log-ezusb.c
+++ b/src/main/iidxhook1/log-ezusb.c
@@ -6,12 +6,13 @@
#include
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "iidxhook1/log-ezusb.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
/* ------------------------------------------------------------------------- */
diff --git a/src/main/iidxhook2/Module.mk b/src/main/iidxhook2/Module.mk
index c9fd4389..46124426 100644
--- a/src/main/iidxhook2/Module.mk
+++ b/src/main/iidxhook2/Module.mk
@@ -5,6 +5,7 @@ ldflags_iidxhook2 := \
-liphlpapi \
libs_iidxhook2 := \
+ core \
iidxhook-util \
ezusb-emu \
ezusb-iidx-16seg-emu \
diff --git a/src/main/iidxhook2/config-iidxhook2.c b/src/main/iidxhook2/config-iidxhook2.c
index 6e3ac6bd..0db10f3b 100644
--- a/src/main/iidxhook2/config-iidxhook2.c
+++ b/src/main/iidxhook2/config-iidxhook2.c
@@ -1,8 +1,8 @@
#include "cconfig/cconfig-util.h"
-#include "iidxhook2/config-iidxhook2.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "iidxhook2/config-iidxhook2.h"
#define IIDXHOOK_CONFIG_MISC_DISTORTED_MS_BG_FIX_KEY "misc.distorted_ms_bg_fix"
diff --git a/src/main/iidxhook2/dllmain.c b/src/main/iidxhook2/dllmain.c
index 25a76ed9..de8a9160 100644
--- a/src/main/iidxhook2/dllmain.c
+++ b/src/main/iidxhook2/dllmain.c
@@ -9,6 +9,14 @@
#include "cconfig/cconfig-hook.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log-sink-debug.h"
+#include "core/log.h"
+#include "core/thread-crt-ext.h"
+#include "core/thread-crt.h"
+#include "core/thread.h"
+
#include "ezusb-emu/desc.h"
#include "ezusb-emu/device.h"
#include "ezusb-emu/node-security-plug.h"
@@ -41,9 +49,6 @@
#include "iidxhook2/config-iidxhook2.h"
-#include "util/log.h"
-#include "util/thread.h"
-
#define IIDXHOOK2_INFO_HEADER \
"iidxhook for DistorteD" \
", build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV)
@@ -65,6 +70,14 @@ static const struct hook_symbol init_hook_syms[] = {
.link = (void **) &real_OpenProcess},
};
+static void _iidxhook2_log_init()
+{
+ core_log_bt_ext_impl_set();
+ core_log_bt_ext_init_with_debug();
+ // TODO change log level support
+ core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
+}
+
static void iidxhook2_setup_d3d9_hooks(
const struct iidxhook_config_gfx *config_gfx,
const struct iidxhook_config_iidxhook2 *config_iidxhook2)
@@ -207,20 +220,24 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
/* Start up IIDXIO.DLL */
log_info("Starting IIDX IO backend");
- iidx_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(iidx_io_set_loggers);
- if (!iidx_io_init(thread_create, thread_join, thread_destroy)) {
+ if (!iidx_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing IIDX IO backend failed");
}
/* Start up EAMIO.DLL */
log_misc("Initializing card reader backend");
- eam_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
- if (!eam_io_init(thread_create, thread_join, thread_destroy)) {
+ if (!eam_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing card reader backend failed");
}
@@ -254,7 +271,9 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
if (reason == DLL_PROCESS_ATTACH) {
- log_to_writer(log_writer_debug, NULL);
+ core_thread_crt_ext_impl_set();
+
+ _iidxhook2_log_init();
/* Bootstrap hook for further init tasks (see above) */
diff --git a/src/main/iidxhook3/Module.mk b/src/main/iidxhook3/Module.mk
index e328bec3..6ab9a30f 100644
--- a/src/main/iidxhook3/Module.mk
+++ b/src/main/iidxhook3/Module.mk
@@ -5,6 +5,7 @@ ldflags_iidxhook3 := \
-liphlpapi \
libs_iidxhook3 := \
+ core \
iidxhook-util \
ezusb-emu \
ezusb-iidx-16seg-emu \
diff --git a/src/main/iidxhook3/dllmain.c b/src/main/iidxhook3/dllmain.c
index b2e0e41d..4927fc32 100644
--- a/src/main/iidxhook3/dllmain.c
+++ b/src/main/iidxhook3/dllmain.c
@@ -9,6 +9,14 @@
#include "cconfig/cconfig-hook.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log-sink-debug.h"
+#include "core/log.h"
+#include "core/thread-crt-ext.h"
+#include "core/thread-crt.h"
+#include "core/thread.h"
+
#include "ezusb-emu/node-security-plug.h"
#include "ezusb-iidx-emu/node-serial.h"
#include "ezusb-iidx-emu/nodes.h"
@@ -40,9 +48,7 @@
#include "security/rp-sign-key.h"
-#include "util/log.h"
#include "util/str.h"
-#include "util/thread.h"
#define IIDXHOOK3_INFO_HEADER \
"iidxhook for Gold, DJTroopers, Empress and Sirius" \
@@ -64,6 +70,14 @@ static const struct hook_symbol init_hook_syms[] = {
.link = (void **) &real_OpenProcess},
};
+static void _iidxhook3_log_init()
+{
+ core_log_bt_ext_impl_set();
+ core_log_bt_ext_init_with_debug();
+ // TODO change log level support
+ core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
+}
+
static void
iidxhook3_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
{
@@ -200,20 +214,24 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
/* Start up IIDXIO.DLL */
log_info("Starting IIDX IO backend");
- iidx_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(iidx_io_set_loggers);
- if (!iidx_io_init(thread_create, thread_join, thread_destroy)) {
+ if (!iidx_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing IIDX IO backend failed");
}
/* Start up EAMIO.DLL */
log_misc("Initializing card reader backend");
- eam_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
- if (!eam_io_init(thread_create, thread_join, thread_destroy)) {
+ if (!eam_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing card reader backend failed");
}
@@ -246,7 +264,9 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
if (reason == DLL_PROCESS_ATTACH) {
- log_to_writer(log_writer_debug, NULL);
+ core_thread_crt_ext_impl_set();
+
+ _iidxhook3_log_init();
/* Bootstrap hook for further init tasks (see above) */
diff --git a/src/main/iidxhook4-cn/Module.mk b/src/main/iidxhook4-cn/Module.mk
index 0f7bceea..8cc34cb1 100644
--- a/src/main/iidxhook4-cn/Module.mk
+++ b/src/main/iidxhook4-cn/Module.mk
@@ -8,6 +8,8 @@ deplibs_iidxhook4-cn := \
avs \
libs_iidxhook4-cn := \
+ avs-util \
+ core \
iidxhook-util \
ezusb-emu \
ezusb-iidx-16seg-emu \
diff --git a/src/main/iidxhook4-cn/avs-boot.c b/src/main/iidxhook4-cn/avs-boot.c
index 378d80cf..4c498c95 100644
--- a/src/main/iidxhook4-cn/avs-boot.c
+++ b/src/main/iidxhook4-cn/avs-boot.c
@@ -3,14 +3,15 @@
#include
#include
+#include "core/log-bt.h"
+#include "core/log.h"
+
#include "hook/table.h"
#include "imports/avs.h"
#include "iidxhook4-cn/avs-boot.h"
-#include "util/log.h"
-
static void (*real_avs_boot)(
struct property_node *config,
void *std_heap,
@@ -35,6 +36,11 @@ static const struct hook_symbol iidxhook4_cn_log_hook_syms[] = {
.link = (void **) &real_avs_boot},
};
+static AVS_LOG_WRITER(_avs_boot_log_writer, chars, nchars, ctx)
+{
+ core_log_bt_direct_sink_write(chars, nchars);
+}
+
static void avs_boot_replace_property_uint32(
struct property_node *node, const char *name, uint32_t val)
{
@@ -87,7 +93,7 @@ static void my_avs_boot(
sz_std_heap,
avs_heap,
sz_avs_heap,
- log_writer_debug,
+ _avs_boot_log_writer,
NULL);
}
diff --git a/src/main/iidxhook4-cn/dllmain.c b/src/main/iidxhook4-cn/dllmain.c
index ea2f42ab..9fa61ba3 100644
--- a/src/main/iidxhook4-cn/dllmain.c
+++ b/src/main/iidxhook4-cn/dllmain.c
@@ -5,10 +5,19 @@
#include
#include
+#include "avs-util/core-interop.h"
+
#include "bemanitools/iidxio.h"
#include "cconfig/cconfig-hook.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log-sink-debug.h"
+#include "core/log.h"
+#include "core/thread-crt.h"
+#include "core/thread.h"
+
#include "ezusb-emu/node-security-plug.h"
#include "ezusb2-emu/desc.h"
@@ -37,8 +46,6 @@
#include "imports/avs.h"
-#include "util/log.h"
-
#define IIDXHOOK4_CN_INFO_HEADER \
"iidxhook for Resort Anthem CN" \
", build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV)
@@ -61,6 +68,14 @@ static const struct hook_symbol init_hook_syms[] = {
static struct iidxhook_config_io config_io;
+static void _iidxhook4_cn_log_init()
+{
+ core_log_bt_ext_impl_set();
+ core_log_bt_ext_init_with_debug();
+ // TODO change log level support
+ core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
+}
+
static void
iidxhook4_cn_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
{
@@ -183,11 +198,12 @@ my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
if (!config_io.disable_io_emu) {
log_info("Starting IIDX IO backend");
- iidx_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(iidx_io_set_loggers);
if (!iidx_io_init(
- avs_thread_create, avs_thread_join, avs_thread_destroy)) {
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing IIDX IO backend failed");
}
} else {
@@ -221,7 +237,11 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
return TRUE;
}
- log_to_writer(log_writer_debug, NULL);
+ // Use AVS APIs
+ avs_util_core_interop_thread_avs_impl_set();
+
+ // TODO init debug logging but with avs available? why not use avs logging?
+ _iidxhook4_cn_log_init();
hook_table_apply(
NULL, "kernel32.dll", init_hook_syms, lengthof(init_hook_syms));
diff --git a/src/main/iidxhook4-cn/path.c b/src/main/iidxhook4-cn/path.c
index 4ab6c5a3..5d4ef1dd 100644
--- a/src/main/iidxhook4-cn/path.c
+++ b/src/main/iidxhook4-cn/path.c
@@ -4,11 +4,12 @@
#include
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "iidxhook4-cn/path.h"
-#include "util/log.h"
#include "util/str.h"
#define PATH_A "D:/JDZ-001/contents/"
diff --git a/src/main/iidxhook4/Module.mk b/src/main/iidxhook4/Module.mk
index 40f40b02..6546ac19 100644
--- a/src/main/iidxhook4/Module.mk
+++ b/src/main/iidxhook4/Module.mk
@@ -7,6 +7,8 @@ deplibs_iidxhook4 := \
avs \
libs_iidxhook4 := \
+ avs-util \
+ core \
iidxhook-util \
ezusb-emu \
ezusb-iidx-16seg-emu \
diff --git a/src/main/iidxhook4/dllmain.c b/src/main/iidxhook4/dllmain.c
index d7993dd7..c52336f3 100644
--- a/src/main/iidxhook4/dllmain.c
+++ b/src/main/iidxhook4/dllmain.c
@@ -5,11 +5,16 @@
#include
#include
+#include "avs-util/core-interop.h"
+
#include "bemanitools/eamio.h"
#include "bemanitools/iidxio.h"
#include "cconfig/cconfig-hook.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "ezusb-iidx-emu/nodes.h"
#include "ezusb2-emu/desc.h"
@@ -36,9 +41,7 @@
#include "imports/avs.h"
-#include "util/log.h"
#include "util/str.h"
-#include "util/thread.h"
#define IIDXHOOK4_INFO_HEADER \
"iidxhook for Resort Anthem" \
@@ -142,11 +145,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
if (!config_io.disable_io_emu) {
log_info("Starting IIDX IO backend");
- iidx_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(iidx_io_set_loggers);
if (!iidx_io_init(
- avs_thread_create, avs_thread_join, avs_thread_destroy)) {
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing IIDX IO backend failed");
}
} else {
@@ -156,11 +160,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
if (!config_io.disable_card_reader_emu) {
log_misc("Initializing card reader backend");
- eam_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
if (!eam_io_init(
- avs_thread_create, avs_thread_join, avs_thread_destroy)) {
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing card reader backend failed");
}
} else {
@@ -227,8 +232,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
goto end;
}
- log_to_external(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ // Use AVS APIs
+ avs_util_core_interop_thread_avs_impl_set();
+ avs_util_core_interop_log_avs_impl_set();
app_hook_init(my_dll_entry_init, my_dll_entry_main);
diff --git a/src/main/iidxhook5-cn/Module.mk b/src/main/iidxhook5-cn/Module.mk
index feea3d48..5addce9b 100644
--- a/src/main/iidxhook5-cn/Module.mk
+++ b/src/main/iidxhook5-cn/Module.mk
@@ -8,6 +8,8 @@ deplibs_iidxhook5-cn := \
avs \
libs_iidxhook5-cn := \
+ avs-util \
+ core \
iidxhook-util \
ezusb-emu \
ezusb-iidx-16seg-emu \
diff --git a/src/main/iidxhook5-cn/avs-boot.c b/src/main/iidxhook5-cn/avs-boot.c
index 772832ab..eaa1f459 100644
--- a/src/main/iidxhook5-cn/avs-boot.c
+++ b/src/main/iidxhook5-cn/avs-boot.c
@@ -3,14 +3,15 @@
#include
#include
+#include "core/log-bt.h"
+#include "core/log.h"
+
#include "hook/table.h"
#include "imports/avs.h"
#include "iidxhook5-cn/avs-boot.h"
-#include "util/log.h"
-
static void (*real_avs_boot)(
struct property_node *config,
void *std_heap,
@@ -35,6 +36,11 @@ static const struct hook_symbol iidxhook5_cn_log_hook_syms[] = {
.link = (void **) &real_avs_boot},
};
+static AVS_LOG_WRITER(_avs_boot_log_writer, chars, nchars, ctx)
+{
+ core_log_bt_direct_sink_write(chars, nchars);
+}
+
static void avs_boot_replace_property_uint32(
struct property_node *node, const char *name, uint32_t val)
{
@@ -87,7 +93,7 @@ static void my_avs_boot(
sz_std_heap,
avs_heap,
sz_avs_heap,
- log_writer_debug,
+ _avs_boot_log_writer,
NULL);
}
diff --git a/src/main/iidxhook5-cn/dllmain.c b/src/main/iidxhook5-cn/dllmain.c
index 711c906f..1d327dcf 100644
--- a/src/main/iidxhook5-cn/dllmain.c
+++ b/src/main/iidxhook5-cn/dllmain.c
@@ -5,10 +5,18 @@
#include
#include
+#include "avs-util/core-interop.h"
+
#include "bemanitools/iidxio.h"
#include "cconfig/cconfig-hook.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log-sink-debug.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "ezusb-emu/node-security-plug.h"
#include "ezusb2-emu/desc.h"
@@ -37,8 +45,6 @@
#include "imports/avs.h"
-#include "util/log.h"
-
#define IIDXHOOK5_CN_INFO_HEADER \
"iidxhook for tricoro CN" \
", build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV)
@@ -61,6 +67,14 @@ static const struct hook_symbol init_hook_user32_syms[] = {
static struct iidxhook_config_io config_io;
+static void _iidxhook5_cn_log_init()
+{
+ core_log_bt_ext_impl_set();
+ core_log_bt_ext_init_with_debug();
+ // TODO change log level support
+ core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
+}
+
static void
iidxhook5_cn_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
{
@@ -163,11 +177,12 @@ static ATOM WINAPI my_RegisterClassA(const WNDCLASSA *lpWndClass)
if (!config_io.disable_io_emu) {
log_info("Starting IIDX IO backend");
- iidx_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(iidx_io_set_loggers);
if (!iidx_io_init(
- avs_thread_create, avs_thread_join, avs_thread_destroy)) {
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing IIDX IO backend failed");
}
} else {
@@ -200,7 +215,11 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
return TRUE;
}
- log_to_writer(log_writer_debug, NULL);
+ // Use AVS APIs
+ avs_util_core_interop_thread_avs_impl_set();
+
+ // TODO init debug logging but with avs available? why not use avs logging?
+ _iidxhook5_cn_log_init();
hook_table_apply(
NULL,
diff --git a/src/main/iidxhook5-cn/path.c b/src/main/iidxhook5-cn/path.c
index d45bf227..bb4f81d1 100644
--- a/src/main/iidxhook5-cn/path.c
+++ b/src/main/iidxhook5-cn/path.c
@@ -4,11 +4,12 @@
#include
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "iidxhook5-cn/path.h"
-#include "util/log.h"
#include "util/str.h"
#define PATH_A "D:/JDZ-001/contents/"
diff --git a/src/main/iidxhook5/Module.mk b/src/main/iidxhook5/Module.mk
index 78ea3077..28cb7fe4 100644
--- a/src/main/iidxhook5/Module.mk
+++ b/src/main/iidxhook5/Module.mk
@@ -7,6 +7,8 @@ deplibs_iidxhook5 := \
avs \
libs_iidxhook5 := \
+ avs-util \
+ core \
iidxhook-util \
ezusb-emu \
ezusb-iidx-16seg-emu \
diff --git a/src/main/iidxhook5/dllmain.c b/src/main/iidxhook5/dllmain.c
index 268bf395..0912c381 100644
--- a/src/main/iidxhook5/dllmain.c
+++ b/src/main/iidxhook5/dllmain.c
@@ -5,11 +5,16 @@
#include
#include
+#include "avs-util/core-interop.h"
+
#include "bemanitools/eamio.h"
#include "bemanitools/iidxio.h"
#include "cconfig/cconfig-hook.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "ezusb-iidx-emu/nodes.h"
#include "ezusb2-emu/desc.h"
@@ -36,9 +41,7 @@
#include "imports/avs.h"
-#include "util/log.h"
#include "util/str.h"
-#include "util/thread.h"
#include "ifs-snd-redir.h"
@@ -144,11 +147,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
if (!config_io.disable_io_emu) {
log_info("Starting IIDX IO backend");
- iidx_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(iidx_io_set_loggers);
if (!iidx_io_init(
- avs_thread_create, avs_thread_join, avs_thread_destroy)) {
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing IIDX IO backend failed");
}
} else {
@@ -158,11 +162,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
if (!config_io.disable_card_reader_emu) {
log_misc("Initializing card reader backend");
- eam_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
if (!eam_io_init(
- avs_thread_create, avs_thread_join, avs_thread_destroy)) {
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing card reader backend failed");
}
} else {
@@ -228,8 +233,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
goto end;
}
- log_to_external(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ // Use AVS APIs
+ avs_util_core_interop_thread_avs_impl_set();
+ avs_util_core_interop_log_avs_impl_set();
app_hook_init(my_dll_entry_init, my_dll_entry_main);
diff --git a/src/main/iidxhook5/ifs-snd-redir.c b/src/main/iidxhook5/ifs-snd-redir.c
index e73dd5ca..639d16fd 100644
--- a/src/main/iidxhook5/ifs-snd-redir.c
+++ b/src/main/iidxhook5/ifs-snd-redir.c
@@ -3,13 +3,14 @@
#include
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "imports/avs.h"
#include "iidxhook5/ifs-snd-redir.h"
-#include "util/log.h"
#include "util/str.h"
static void *(*real_avs_fs_open)(const char *path, int mode, int flags);
diff --git a/src/main/iidxhook6/Module.mk b/src/main/iidxhook6/Module.mk
index 7fda87b1..fe7e955e 100644
--- a/src/main/iidxhook6/Module.mk
+++ b/src/main/iidxhook6/Module.mk
@@ -7,6 +7,8 @@ deplibs_iidxhook6 := \
avs \
libs_iidxhook6 := \
+ avs-util \
+ core \
iidxhook-d3d9 \
iidxhook-util \
ezusb-emu \
diff --git a/src/main/iidxhook6/dllmain.c b/src/main/iidxhook6/dllmain.c
index b4ca65aa..4b614a48 100644
--- a/src/main/iidxhook6/dllmain.c
+++ b/src/main/iidxhook6/dllmain.c
@@ -5,11 +5,16 @@
#include
#include
+#include "avs-util/core-interop.h"
+
#include "bemanitools/eamio.h"
#include "bemanitools/iidxio.h"
#include "cconfig/cconfig-hook.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "ezusb-iidx-emu/nodes.h"
#include "ezusb2-emu/desc.h"
@@ -35,9 +40,7 @@
#include "imports/avs.h"
-#include "util/log.h"
#include "util/str.h"
-#include "util/thread.h"
#define IIDXHOOK6_INFO_HEADER \
"iidxhook for Tricoro" \
@@ -121,11 +124,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
if (!config_io.disable_io_emu) {
log_info("Starting IIDX IO backend");
- iidx_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(iidx_io_set_loggers);
if (!iidx_io_init(
- avs_thread_create, avs_thread_join, avs_thread_destroy)) {
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing IIDX IO backend failed");
}
} else {
@@ -135,11 +139,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
if (!config_io.disable_card_reader_emu) {
log_misc("Initializing card reader backend");
- eam_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
if (!eam_io_init(
- avs_thread_create, avs_thread_join, avs_thread_destroy)) {
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing card reader backend failed");
}
} else {
@@ -203,8 +208,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
goto end;
}
- log_to_external(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ // Use AVS APIs
+ avs_util_core_interop_thread_avs_impl_set();
+ avs_util_core_interop_log_avs_impl_set();
app_hook_init(my_dll_entry_init, my_dll_entry_main);
diff --git a/src/main/iidxhook7/Module.mk b/src/main/iidxhook7/Module.mk
index a40366af..b1b6d937 100644
--- a/src/main/iidxhook7/Module.mk
+++ b/src/main/iidxhook7/Module.mk
@@ -8,6 +8,8 @@ deplibs_iidxhook7 := \
avs \
libs_iidxhook7 := \
+ avs-util \
+ core \
iidxhook-d3d9 \
iidxhook-util \
cconfig \
diff --git a/src/main/iidxhook7/dllmain.c b/src/main/iidxhook7/dllmain.c
index af948f61..0823e854 100644
--- a/src/main/iidxhook7/dllmain.c
+++ b/src/main/iidxhook7/dllmain.c
@@ -5,11 +5,16 @@
#include
#include
+#include "avs-util/core-interop.h"
+
#include "bemanitools/eamio.h"
#include "bemanitools/iidxio.h"
#include "cconfig/cconfig-hook.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "ezusb-iidx-emu/nodes.h"
#include "ezusb2-emu/desc.h"
@@ -35,9 +40,7 @@
#include "imports/avs.h"
-#include "util/log.h"
#include "util/str.h"
-#include "util/thread.h"
#define IIDXHOOK7_INFO_HEADER \
"iidxhook for SPADA, PENDUAL, copula and SINOBUZ" \
@@ -121,11 +124,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
if (!config_io.disable_io_emu) {
log_info("Starting IIDX IO backend");
- iidx_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(iidx_io_set_loggers);
if (!iidx_io_init(
- avs_thread_create, avs_thread_join, avs_thread_destroy)) {
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing IIDX IO backend failed");
}
} else {
@@ -135,11 +139,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
if (!config_io.disable_card_reader_emu) {
log_misc("Initializing card reader backend");
- eam_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
if (!eam_io_init(
- avs_thread_create, avs_thread_join, avs_thread_destroy)) {
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing card reader backend failed");
}
} else {
@@ -203,8 +208,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
goto end;
}
- log_to_external(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ // Use AVS APIs
+ avs_util_core_interop_thread_avs_impl_set();
+ avs_util_core_interop_log_avs_impl_set();
app_hook_init(my_dll_entry_init, my_dll_entry_main);
diff --git a/src/main/iidxhook8/Module.mk b/src/main/iidxhook8/Module.mk
index e71c8c25..faebbbb9 100644
--- a/src/main/iidxhook8/Module.mk
+++ b/src/main/iidxhook8/Module.mk
@@ -12,6 +12,8 @@ deplibs_iidxhook8 := \
avs \
libs_iidxhook8 := \
+ avs-util \
+ core \
iidxhook-d3d9 \
iidxhook-util \
acioemu \
diff --git a/src/main/iidxhook8/config-io.c b/src/main/iidxhook8/config-io.c
index 8cbb9b24..9f61e130 100644
--- a/src/main/iidxhook8/config-io.c
+++ b/src/main/iidxhook8/config-io.c
@@ -1,8 +1,8 @@
#include "cconfig/cconfig-util.h"
-#include "iidxhook8/config-io.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "iidxhook8/config-io.h"
#define IIDXHOOK8_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY \
"io.disable_card_reader_emu"
diff --git a/src/main/iidxhook8/dllmain.c b/src/main/iidxhook8/dllmain.c
index 13509be4..bf1f55d9 100644
--- a/src/main/iidxhook8/dllmain.c
+++ b/src/main/iidxhook8/dllmain.c
@@ -5,11 +5,16 @@
#include
#include
+#include "avs-util/core-interop.h"
+
#include "bemanitools/eamio.h"
#include "bemanitools/iidxio.h"
#include "cconfig/cconfig-hook.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "hook/d3d9.h"
#include "hooklib/acp.h"
@@ -34,9 +39,7 @@
#include "imports/avs.h"
-#include "util/log.h"
#include "util/str.h"
-#include "util/thread.h"
#define IIDXHOOK8_INFO_HEADER \
"iidxhook for Cannon Ballers/Rootage" \
@@ -131,11 +134,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
/* Start up IIDXIO.DLL */
if (!iidxhook8_config_io.disable_bio2_emu) {
log_info("Starting IIDX IO backend");
- iidx_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(iidx_io_set_loggers);
if (!iidx_io_init(
- avs_thread_create, avs_thread_join, avs_thread_destroy)) {
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing IIDX IO backend failed");
}
}
@@ -143,11 +147,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
/* Start up EAMIO.DLL */
if (!iidxhook8_config_io.disable_card_reader_emu) {
log_misc("Initializing card reader backend");
- eam_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
if (!eam_io_init(
- avs_thread_create, avs_thread_join, avs_thread_destroy)) {
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing card reader backend failed");
}
}
@@ -217,8 +222,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
goto end;
}
- log_to_external(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ // Use AVS APIs
+ avs_util_core_interop_thread_avs_impl_set();
+ avs_util_core_interop_log_avs_impl_set();
app_hook_init(my_dll_entry_init, my_dll_entry_main);
diff --git a/src/main/iidxhook9/Module.mk b/src/main/iidxhook9/Module.mk
index 30384f11..2328fdc3 100644
--- a/src/main/iidxhook9/Module.mk
+++ b/src/main/iidxhook9/Module.mk
@@ -12,6 +12,8 @@ deplibs_iidxhook9 := \
avs \
libs_iidxhook9 := \
+ avs-util \
+ core \
iidxhook-util \
acioemu \
asio \
diff --git a/src/main/iidxhook9/config-io.c b/src/main/iidxhook9/config-io.c
index ba7ff45a..34deebfb 100644
--- a/src/main/iidxhook9/config-io.c
+++ b/src/main/iidxhook9/config-io.c
@@ -1,8 +1,8 @@
#include "cconfig/cconfig-util.h"
-#include "iidxhook9/config-io.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "iidxhook9/config-io.h"
#define IIDXHOOK9_CONFIG_IO_DISABLE_CARD_READER_EMU_KEY \
"io.disable_card_reader_emu"
diff --git a/src/main/iidxhook9/dllmain.c b/src/main/iidxhook9/dllmain.c
index b7ae85ac..ad9572d5 100644
--- a/src/main/iidxhook9/dllmain.c
+++ b/src/main/iidxhook9/dllmain.c
@@ -5,11 +5,18 @@
#include
#include
+#include "avs-util/core-interop.h"
+
#include "bemanitools/eamio.h"
#include "bemanitools/iidxio.h"
#include "cconfig/cconfig-hook.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "hooklib/acp.h"
#include "hooklib/adapter.h"
#include "hooklib/app.h"
@@ -38,9 +45,7 @@
#include "imports/avs.h"
#include "util/cmdline.h"
-#include "util/log.h"
#include "util/str.h"
-#include "util/thread.h"
#define IIDXHOOK9_INFO_HEADER \
"iidxhook for Heroic Verse" \
@@ -97,6 +102,9 @@ static bool load_configs()
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
{
+ // Use AVS APIs
+ avs_util_core_interop_thread_avs_impl_set();
+
// log_server_init is required due to IO occuring in a non avs_thread
log_server_init();
@@ -124,11 +132,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
/* Start up IIDXIO.DLL */
if (!iidxhook9_config_io.disable_bio2_emu) {
log_info("Starting IIDX IO backend");
- iidx_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(iidx_io_set_loggers);
if (!iidx_io_init(
- avs_thread_create, avs_thread_join, avs_thread_destroy)) {
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing IIDX IO backend failed");
}
}
@@ -136,11 +145,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
/* Start up EAMIO.DLL */
if (!iidxhook9_config_io.disable_card_reader_emu) {
log_misc("Initializing card reader backend");
- eam_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
if (!eam_io_init(
- avs_thread_create, avs_thread_join, avs_thread_destroy)) {
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing card reader backend failed");
}
}
@@ -271,8 +281,8 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
// if AVS is loaded, we're likely too late to be a prehook
// so we warn the user
// and switch the current logging context to AVS so it shows up in logs
- log_to_external(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ avs_util_core_interop_log_avs_impl_set();
+
log_warning("iidxhook9 is designed to be used as a prehook");
log_warning("please ensure that it is being loaded with -B");
log_fatal("cya l8r in the prehook :3");
@@ -280,7 +290,7 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
// we can't log to external in DllMain (AVS) as we're a prehook
// later during my_dll_entry_init, log_server_init is called
// which sets swaps the main log write to that instead
- log_to_writer(log_writer_file, stdout);
+ core_log_bt_ext_impl_set();
}
pre_hook();
diff --git a/src/main/iidxio-bio2/Module.mk b/src/main/iidxio-bio2/Module.mk
index 09632c21..e91d76a1 100644
--- a/src/main/iidxio-bio2/Module.mk
+++ b/src/main/iidxio-bio2/Module.mk
@@ -4,6 +4,7 @@ ldflags_iidxio-bio2 := \
-lsetupapi \
libs_iidxio-bio2 := \
+ core \
aciodrv \
bio2drv \
cconfig \
diff --git a/src/main/iidxio-ezusb/Module.mk b/src/main/iidxio-ezusb/Module.mk
index ce9982c2..cc64914e 100644
--- a/src/main/iidxio-ezusb/Module.mk
+++ b/src/main/iidxio-ezusb/Module.mk
@@ -5,6 +5,7 @@ ldflags_iidxio-ezusb := \
-lsetupapi \
libs_iidxio-ezusb := \
+ core \
ezusb \
ezusb2 \
ezusb-iidx \
diff --git a/src/main/iidxio-ezusb2/Module.mk b/src/main/iidxio-ezusb2/Module.mk
index f1f19631..3371a785 100644
--- a/src/main/iidxio-ezusb2/Module.mk
+++ b/src/main/iidxio-ezusb2/Module.mk
@@ -5,6 +5,7 @@ ldflags_iidxio-ezusb2 := \
-lsetupapi \
libs_iidxio-ezusb2 := \
+ core \
ezusb2 \
ezusb \
ezusb2-iidx \
diff --git a/src/main/iidxiotest/Module.mk b/src/main/iidxiotest/Module.mk
index ce0536cf..94eca380 100644
--- a/src/main/iidxiotest/Module.mk
+++ b/src/main/iidxiotest/Module.mk
@@ -1,6 +1,7 @@
exes += iidxiotest \
libs_iidxiotest := \
+ core \
iidxio \
util \
diff --git a/src/main/iidxiotest/main.c b/src/main/iidxiotest/main.c
index ddd57cf4..a9b7daaa 100644
--- a/src/main/iidxiotest/main.c
+++ b/src/main/iidxiotest/main.c
@@ -7,8 +7,12 @@
#include "bemanitools/iidxio.h"
-#include "util/log.h"
-#include "util/thread.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log.h"
+#include "core/thread-crt-ext.h"
+#include "core/thread-crt.h"
+#include "core/thread.h"
static uint8_t _fix_top_lamps_order(uint8_t top_lamps)
{
@@ -55,12 +59,17 @@ static void _all_lights_off_shutdown()
*/
int main(int argc, char **argv)
{
- log_to_writer(log_writer_stdout, NULL);
+ core_thread_crt_ext_impl_set();
+ core_log_bt_ext_impl_set();
- iidx_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_bt_ext_init_with_stdout();
- if (!iidx_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy)) {
+ core_log_impl_assign(iidx_io_set_loggers);
+
+ if (!iidx_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
printf("Initializing iidxio failed\n");
return -1;
}
diff --git a/src/main/inject/Module.mk b/src/main/inject/Module.mk
index 549f1792..5fb93dc8 100644
--- a/src/main/inject/Module.mk
+++ b/src/main/inject/Module.mk
@@ -1,16 +1,19 @@
exes += inject
+imps += dwarfstack
ldflags_inject := \
-mconsole \
-lpsapi \
+ -ldbghelp \
libs_inject := \
+ core \
util \
+ dwarfstack \
src_inject := \
main.c \
debugger.c \
- logger.c \
options.c \
version.c \
diff --git a/src/main/inject/debugger.c b/src/main/inject/debugger.c
index 724ed9ba..4f10acf5 100644
--- a/src/main/inject/debugger.c
+++ b/src/main/inject/debugger.c
@@ -8,13 +8,14 @@
#include
#include
+#include "core/log-bt.h"
+#include "core/log.h"
+
#include "inject/debugger.h"
-#include "inject/logger.h"
-#include "util/log.h"
+#include "util/debug.h"
#include "util/mem.h"
#include "util/proc.h"
-#include "util/signal.h"
#include "util/str.h"
#define MM_ALLOCATION_GRANULARITY 0x10000
@@ -178,6 +179,7 @@ static bool log_debug_str(HANDLE process, const OUTPUT_DEBUG_STRING_INFO *odsi)
log_assert(odsi);
char *debug_str;
+ size_t debug_str_len;
if (odsi->fUnicode) {
debug_str = read_debug_wstr(process, odsi);
@@ -186,7 +188,9 @@ static bool log_debug_str(HANDLE process, const OUTPUT_DEBUG_STRING_INFO *odsi)
}
if (debug_str) {
- logger_log(debug_str);
+ debug_str_len = strlen(debug_str);
+
+ core_log_bt_direct_sink_write(debug_str, debug_str_len);
free(debug_str);
return true;
@@ -271,7 +275,7 @@ static uint32_t debugger_loop()
"EXCEPTION_DEBUG_EVENT(pid %ld, tid %ld): x%s 0x%p",
de.dwProcessId,
de.dwThreadId,
- signal_exception_code_to_str(
+ debug_exception_code_to_str(
de.u.Exception.ExceptionRecord.ExceptionCode),
de.u.Exception.ExceptionRecord.ExceptionAddress);
diff --git a/src/main/inject/logger.c b/src/main/inject/logger.c
deleted file mode 100644
index 8f63aa9c..00000000
--- a/src/main/inject/logger.c
+++ /dev/null
@@ -1,217 +0,0 @@
-#define LOG_MODULE "inject-logger"
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "inject/logger.h"
-#include "inject/version.h"
-
-#include "util/log.h"
-
-static FILE *log_file;
-static HANDLE log_mutex;
-
-static const char *logger_get_formatted_timestamp(void)
-{
- static char buffer[64];
- time_t cur = 0;
- struct tm *tm = NULL;
-
- cur = time(NULL);
- tm = localtime(&cur);
-
- strftime(buffer, sizeof(buffer), "[%Y/%m/%d %H:%M:%S] ", tm);
-
- return buffer;
-}
-
-static char logger_console_determine_color(const char *str)
-{
- log_assert(str);
-
- /* Add some color to make spotting warnings/errors easier.
- Based on debug output level identifier. */
-
- /* Avoids colored output on strings like "Windows" */
- if (str[1] != ':') {
- return 15;
- }
-
- switch (str[0]) {
- /* green */
- case 'M':
- return 10;
- /* blue */
- case 'I':
- return 9;
- /* yellow */
- case 'W':
- return 14;
- /* red */
- case 'F':
- return 12;
- /* default console color */
- default:
- return 15;
- }
-}
-
-static size_t logger_msg_coloring_len(const char *str)
-{
- // Expected format example: "I:boot: my log message"
-
- const char *ptr;
- size_t len;
- int colon_count;
-
- ptr = str;
- len = 0;
- colon_count = 0;
-
- while (true) {
- // End of string = invalid log format
- if (*ptr == '\0') {
- return 0;
- }
-
- if (*ptr == ':') {
- colon_count++;
- }
-
- if (colon_count == 2) {
- // Skip current colon, next char is a space
- return len + 1;
- }
-
- len++;
- ptr++;
- }
-
- return 0;
-}
-
-static void logger_console(
- void *ctx, const char *chars, size_t nchars, const char *timestamp_str)
-{
- char color;
- size_t color_len;
- // See "util/log.c", has to align
- char buffer[65536];
- char tmp;
-
- color_len = logger_msg_coloring_len(chars);
-
- // Check if we could detect which part to color, otherwise just write the
- // whole log message without any coloring logic
- if (color_len > 0) {
- color = logger_console_determine_color(chars);
-
- strcpy(buffer, chars);
-
- // Mask start of log message for coloring
- tmp = buffer[color_len];
- buffer[color_len] = '\0';
-
- printf("%s", timestamp_str);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
- printf("%s", buffer);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
-
- // Write actual message non colored
- buffer[color_len] = tmp;
- printf("%s", buffer + color_len);
- } else {
- printf("%s", chars);
- }
-}
-
-static void logger_file(
- void *ctx, const char *chars, size_t nchars, const char *timestamp_str)
-{
- if (ctx) {
- fwrite(timestamp_str, 1, strlen(timestamp_str), (FILE *) ctx);
- fwrite(chars, 1, nchars, (FILE *) ctx);
- fflush((FILE *) ctx);
- }
-}
-
-static void logger_writer(void *ctx, const char *chars, size_t nchars)
-{
- const char *timestamp_str;
-
- // Different threads logging the same destination, e.g. debugger thread,
- // main thread
-
- WaitForSingleObject(log_mutex, INFINITE);
-
- timestamp_str = logger_get_formatted_timestamp();
-
- logger_console(ctx, chars, nchars, timestamp_str);
- logger_file(ctx, chars, nchars, timestamp_str);
-
- ReleaseMutex(log_mutex);
-}
-
-static void logger_log_header()
-{
- log_info(
- "\n"
- " _ _ _ \n"
- " (_)_ __ (_) ___ ___| |_ \n"
- " | | '_ \\ | |/ _ \\/ __| __|\n"
- " | | | | || | __/ (__| |_ \n"
- " |_|_| |_|/ |\\___|\\___|\\__|\n"
- " |__/ ");
-
- log_info(
- "Inject build date %s, gitrev %s", inject_build_date, inject_gitrev);
-}
-
-bool logger_init(const char *log_file_path)
-{
- if (log_file_path) {
- log_file = fopen(log_file_path, "w+");
- } else {
- log_file = NULL;
- }
-
- log_to_writer(logger_writer, log_file);
-
- logger_log_header();
-
- if (log_file_path) {
- log_info("Log file: %s", log_file_path);
-
- if (!log_file) {
- log_warning(
- "ERROR: Opening log file %s failed: %s",
- log_file_path,
- strerror(errno));
- return false;
- }
- }
-
- log_mutex = CreateMutex(NULL, FALSE, NULL);
-
- return true;
-}
-
-void logger_log(const char *str)
-{
- logger_writer(log_file, str, strlen(str));
-}
-
-void logger_finit()
-{
- log_misc("Logger finit");
-
- if (log_file) {
- fclose(log_file);
- }
-
- CloseHandle(log_mutex);
-}
\ No newline at end of file
diff --git a/src/main/inject/logger.h b/src/main/inject/logger.h
deleted file mode 100644
index 45a8b770..00000000
--- a/src/main/inject/logger.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#include
-
-/**
- * Initialize inject's logger backend.
- *
- * This takes care of hooking and merging the different log
- * streams, e.g. inject's local logging and inject's debugger
- * receiving remote logging events.
- *
- * @param log_file_path Path to the file to log to or NULL to
- * disable.
- */
-bool logger_init(const char *log_file_path);
-
-/**
- * Write a message to the logging backend.
- *
- * This is used by inject's debugger to redirect log messages
- * recevied from the remote process.
- *
- * @param str String to log
- */
-void logger_log(const char *str);
-
-/**
- * Shutdown and cleanup the logging backend.
- */
-void logger_finit();
\ No newline at end of file
diff --git a/src/main/inject/main.c b/src/main/inject/main.c
index bfb6c1be..a93a326b 100644
--- a/src/main/inject/main.c
+++ b/src/main/inject/main.c
@@ -1,3 +1,5 @@
+#define LOG_MODULE "inject"
+
#include
#include
@@ -10,18 +12,68 @@
#include "cconfig/cconfig-util.h"
#include "cconfig/cmd.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log-sink-file.h"
+#include "core/log-sink-list.h"
+#include "core/log-sink-mutex.h"
+#include "core/log-sink-std.h"
+#include "core/log.h"
+#include "core/thread-crt-ext.h"
+#include "core/thread-crt.h"
+#include "core/thread.h"
+
#include "inject/debugger.h"
-#include "inject/logger.h"
#include "inject/options.h"
#include "inject/version.h"
#include "util/cmdline.h"
-#include "util/log.h"
+#include "util/debug.h"
#include "util/mem.h"
#include "util/os.h"
#include "util/signal.h"
#include "util/str.h"
+static void _inject_log_header()
+{
+ log_info(
+ "\n"
+ " _ _ _ \n"
+ " (_)_ __ (_) ___ ___| |_ \n"
+ " | | '_ \\ | |/ _ \\/ __| __|\n"
+ " | | | | || | __/ (__| |_ \n"
+ " |_|_| |_|/ |\\___|\\___|\\__|\n"
+ " |__/ ");
+
+ log_info(
+ "inject build date %s, gitrev %s", inject_build_date, inject_gitrev);
+}
+
+void _inject_log_init(
+ const char *log_file_path, enum core_log_bt_log_level level)
+{
+ struct core_log_sink sinks[2];
+ struct core_log_sink sink_composed;
+ struct core_log_sink sink_mutex;
+
+ core_log_bt_ext_impl_set();
+
+ if (log_file_path) {
+ core_log_sink_std_out_open(true, &sinks[0]);
+ core_log_sink_file_open(log_file_path, false, true, 10, &sinks[1]);
+ core_log_sink_list_open(sinks, 2, &sink_composed);
+ } else {
+ core_log_sink_std_out_open(true, &sink_composed);
+ }
+
+ // Different threads logging the same destination, e.g. debugger thread,
+ // main thread
+ core_log_sink_mutex_open(&sink_composed, &sink_mutex);
+
+ core_log_bt_init(&sink_mutex);
+ core_log_bt_level_set(level);
+}
+
static bool init_options(int argc, char **argv, struct options *options)
{
options_init(options);
@@ -145,7 +197,7 @@ static bool inject_hook_dlls(uint32_t hooks, char **argv)
static void signal_shutdown_handler()
{
debugger_finit(true);
- logger_finit();
+ core_log_bt_fini();
}
int main(int argc, char **argv)
@@ -160,12 +212,17 @@ int main(int argc, char **argv)
goto init_options_fail;
}
- if (!logger_init(strlen(options.log_file) > 0 ? options.log_file : NULL)) {
- goto init_logger_fail;
- }
+ core_thread_crt_ext_impl_set();
+ // TODO expose log level
+
+ _inject_log_init(
+ strlen(options.log_file) > 0 ? options.log_file : NULL,
+ CORE_LOG_BT_LOG_LEVEL_MISC);
+ _inject_log_header();
os_version_log();
+ debug_init(core_log_fatal_impl_get());
signal_exception_handler_init();
// Cleanup remote process on CTRL+C
signal_register_shutdown_handler(signal_shutdown_handler);
@@ -214,7 +271,7 @@ int main(int argc, char **argv)
debugger_finit(false);
- logger_finit();
+ core_log_bt_fini();
return EXIT_SUCCESS;
@@ -226,9 +283,8 @@ int main(int argc, char **argv)
debugger_init_fail:
verify_2_fail:
verify_fail:
- logger_finit();
+ core_log_bt_fini();
-init_logger_fail:
init_options_fail:
return EXIT_FAILURE;
}
diff --git a/src/main/jbhook-util-p3io/gfx.c b/src/main/jbhook-util-p3io/gfx.c
index 63607fd8..0574b1f0 100644
--- a/src/main/jbhook-util-p3io/gfx.c
+++ b/src/main/jbhook-util-p3io/gfx.c
@@ -9,6 +9,8 @@
#include
#include
+#include "core/log.h"
+
#include "hook/com-proxy.h"
#include "hook/table.h"
@@ -17,7 +19,6 @@
#include "jbhook-util-p3io/gfx.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/str.h"
#include "util/time.h"
diff --git a/src/main/jbhook-util-p3io/mixer.c b/src/main/jbhook-util-p3io/mixer.c
index 30dcace9..ba52a638 100644
--- a/src/main/jbhook-util-p3io/mixer.c
+++ b/src/main/jbhook-util-p3io/mixer.c
@@ -6,10 +6,11 @@
#include
// clang-format on
+#include "core/log.h"
+
#include "hook/table.h"
#include "util/defs.h"
-#include "util/log.h"
MMRESULT STDCALL hook_mixerGetLineControlsA(
HMIXEROBJ hmxobj, LPMIXERLINECONTROLSA pmxlc, DWORD fdwControls);
diff --git a/src/main/jbhook-util-p3io/p3io.c b/src/main/jbhook-util-p3io/p3io.c
index 25b3364f..dd04607a 100644
--- a/src/main/jbhook-util-p3io/p3io.c
+++ b/src/main/jbhook-util-p3io/p3io.c
@@ -5,6 +5,8 @@
#include "bemanitools/jbio.h"
+#include "core/log.h"
+
#include "jbhook-util-p3io/p3io.h"
#include "p3ioemu/emu.h"
@@ -13,8 +15,6 @@
#include "security/rp-sign-key.h"
#include "security/rp3.h"
-#include "util/log.h"
-
static HRESULT jbhook_p3io_read_jamma(void *ctx, uint32_t *state);
static HRESULT jbhook_p3io_get_roundplug(
void *ctx, uint8_t plug_id, uint8_t *rom, uint8_t *eeprom);
diff --git a/src/main/jbhook-util/acio.c b/src/main/jbhook-util/acio.c
index a1f5492e..8a1ed023 100644
--- a/src/main/jbhook-util/acio.c
+++ b/src/main/jbhook-util/acio.c
@@ -16,6 +16,8 @@
#include "acioemu/h44b.h"
#include "acioemu/icca.h"
+#include "core/log.h"
+
#include "hook/iohook.h"
#include "jbhook-util/acio.h"
@@ -25,7 +27,6 @@
#include "util/defs.h"
#include "util/hex.h"
#include "util/iobuf.h"
-#include "util/log.h"
#include "util/str.h"
static struct ac_io_emu ac_io_emu;
diff --git a/src/main/jbhook-util/eamuse.c b/src/main/jbhook-util/eamuse.c
index 0a796259..c9d1d906 100644
--- a/src/main/jbhook-util/eamuse.c
+++ b/src/main/jbhook-util/eamuse.c
@@ -9,10 +9,11 @@
#include
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "util/defs.h"
-#include "util/log.h"
#include "util/net.h"
#include "util/str.h"
diff --git a/src/main/jbhook-util/locale.c b/src/main/jbhook-util/locale.c
index 272bbc64..a6b6d17a 100644
--- a/src/main/jbhook-util/locale.c
+++ b/src/main/jbhook-util/locale.c
@@ -2,10 +2,11 @@
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "util/defs.h"
-#include "util/log.h"
// ANSI/OEM Japanese; Japanese (Shift-JIS)
#define CODEPAGE_SHIFT_JIS 932
diff --git a/src/main/jbhook-util/p4io.c b/src/main/jbhook-util/p4io.c
index ab77d5dc..824ab803 100644
--- a/src/main/jbhook-util/p4io.c
+++ b/src/main/jbhook-util/p4io.c
@@ -4,14 +4,14 @@
#include "bemanitools/jbio.h"
+#include "core/log.h"
+
#include "imports/avs.h"
#include "jbhook-util/p4io.h"
#include "p4io/cmd.h"
-#include "util/log.h"
-
static void jbhook_io_jamma2_read(void *resp, uint32_t nbytes);
static uint32_t jbhook_command_handle(
uint8_t cmd,
diff --git a/src/main/jbhook1/Module.mk b/src/main/jbhook1/Module.mk
index b5e47776..c434f217 100644
--- a/src/main/jbhook1/Module.mk
+++ b/src/main/jbhook1/Module.mk
@@ -11,6 +11,7 @@ ldflags_jbhook1 := \
-lopengl32 \
libs_jbhook1 := \
+ core \
acioemu \
cconfig \
eamio \
diff --git a/src/main/jbhook1/avs-boot.c b/src/main/jbhook1/avs-boot.c
index dccba692..62d67733 100644
--- a/src/main/jbhook1/avs-boot.c
+++ b/src/main/jbhook1/avs-boot.c
@@ -5,14 +5,15 @@
#include
#include
+#include "core/log-bt.h"
+#include "core/log.h"
+
#include "hook/table.h"
#include "imports/avs.h"
#include "jbhook1/avs-boot.h"
-#include "util/log.h"
-
static void (*real_avs_boot)(
struct property_node *config,
void *std_heap,
@@ -52,6 +53,11 @@ static const struct hook_symbol jbhook1_log_gftools_hook_syms2[] = {
.link = (void **) &real_ea3_boot},
};
+static AVS_LOG_WRITER(_avs_boot_log_writer, chars, nchars, ctx)
+{
+ core_log_bt_direct_sink_write(chars, nchars);
+}
+
static void avs_boot_create_property_str(
struct property *config, const char *name, const char *val)
{
@@ -139,7 +145,7 @@ static void my_avs_boot(
sz_std_heap,
avs_heap,
sz_avs_heap,
- log_writer_debug,
+ _avs_boot_log_writer,
NULL);
}
diff --git a/src/main/jbhook1/config-eamuse.c b/src/main/jbhook1/config-eamuse.c
index dba512eb..77170e2c 100644
--- a/src/main/jbhook1/config-eamuse.c
+++ b/src/main/jbhook1/config-eamuse.c
@@ -2,9 +2,10 @@
#include "cconfig/cconfig-util.h"
+#include "core/log.h"
+
#include "jbhook1/config-eamuse.h"
-#include "util/log.h"
#include "util/net.h"
#define JBHOOK1_CONFIG_EAMUSE_SERVER_KEY "eamuse.server"
diff --git a/src/main/jbhook1/config-gfx.c b/src/main/jbhook1/config-gfx.c
index 5215659c..10102fa7 100644
--- a/src/main/jbhook1/config-gfx.c
+++ b/src/main/jbhook1/config-gfx.c
@@ -2,9 +2,9 @@
#include "cconfig/cconfig-util.h"
-#include "jbhook1/config-gfx.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "jbhook1/config-gfx.h"
#define JBHOOK1_CONFIG_GFX_WINDOWED_KEY "gfx.windowed"
#define JBHOOK1_CONFIG_GFX_VERTICAL_KEY "gfx.vertical"
diff --git a/src/main/jbhook1/config-security.c b/src/main/jbhook1/config-security.c
index 565081e4..d6c56b05 100644
--- a/src/main/jbhook1/config-security.c
+++ b/src/main/jbhook1/config-security.c
@@ -2,11 +2,12 @@
#include "cconfig/cconfig-util.h"
+#include "core/log.h"
+
#include "jbhook1/config-security.h"
#include "security/mcode.h"
-#include "util/log.h"
#include "util/net.h"
#define JBHOOK1_CONFIG_SECURITY_MCODE_KEY "security.mcode"
diff --git a/src/main/jbhook1/dllmain.c b/src/main/jbhook1/dllmain.c
index 42f8dc9d..f058d0f3 100644
--- a/src/main/jbhook1/dllmain.c
+++ b/src/main/jbhook1/dllmain.c
@@ -10,6 +10,14 @@
#include "cconfig/cconfig-hook.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log-sink-debug.h"
+#include "core/log.h"
+#include "core/thread-crt-ext.h"
+#include "core/thread-crt.h"
+#include "core/thread.h"
+
#include "hook/table.h"
#include "hooklib/acp.h"
@@ -33,8 +41,6 @@
#include "p3ioemu/emu.h"
#include "util/defs.h"
-#include "util/log.h"
-#include "util/thread.h"
#define JBHOOK1_INFO_HEADER \
"jbhook1 for jubeat" \
@@ -89,6 +95,14 @@ static const struct hook_symbol kernel32_hook_syms[] = {
// so our CreateProcessA hook can check
static bool vertical;
+static void _jbhook1_log_init()
+{
+ core_log_bt_ext_impl_set();
+ core_log_bt_ext_init_with_debug();
+ // TODO change log level support
+ core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
+}
+
/**
* This seems to be a good entry point to intercept before the game calls
* anything important (very close to the start of WinMain).
@@ -153,19 +167,23 @@ static HWND CDECL my_mwindow_create(
log_info("Starting up jubeat IO backend");
- jb_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(jb_io_set_loggers);
- if (!jb_io_init(thread_create, thread_join, thread_destroy)) {
+ if (!jb_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing jb IO backend failed");
}
log_info("Starting up card reader backend");
- eam_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
- if (!eam_io_init(thread_create, thread_join, thread_destroy)) {
+ if (!eam_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
log_fatal("Initializing card reader backend failed");
}
@@ -201,7 +219,12 @@ static HWND CDECL my_mwindow_create(
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
if (reason == DLL_PROCESS_ATTACH) {
- log_to_writer(log_writer_debug, NULL);
+ // TODO why not use AVS threads?
+ core_thread_crt_ext_impl_set();
+
+ // TODO init debug logging but with avs available? why not use avs
+ // logging?
+ _jbhook1_log_init();
/* Bootstrap hook for further init tasks (see above) */
diff --git a/src/main/jbhook1/log-gftools.c b/src/main/jbhook1/log-gftools.c
index 97721736..f0dbf854 100644
--- a/src/main/jbhook1/log-gftools.c
+++ b/src/main/jbhook1/log-gftools.c
@@ -5,9 +5,9 @@
#include
#include
-#include "hook/table.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "hook/table.h"
static int CDECL my_GFReportPuts(
int level,
diff --git a/src/main/jbhook2/Module.mk b/src/main/jbhook2/Module.mk
index 2573867f..7ecebdb9 100644
--- a/src/main/jbhook2/Module.mk
+++ b/src/main/jbhook2/Module.mk
@@ -10,6 +10,8 @@ ldflags_jbhook2 := \
-lopengl32 \
libs_jbhook2 := \
+ avs-util \
+ core \
acioemu \
eamio \
jbio \
diff --git a/src/main/jbhook2/dllmain.c b/src/main/jbhook2/dllmain.c
index a8523ad9..4c06e4dc 100644
--- a/src/main/jbhook2/dllmain.c
+++ b/src/main/jbhook2/dllmain.c
@@ -5,9 +5,14 @@
#include
#include
+#include "avs-util/core-interop.h"
+
#include "bemanitools/eamio.h"
#include "bemanitools/jbio.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "hook/iohook.h"
#include "hook/table.h"
@@ -36,8 +41,6 @@
#include "security/mcode.h"
#include "util/defs.h"
-#include "util/log.h"
-#include "util/thread.h"
static struct options options;
@@ -80,11 +83,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
log_info("Starting up jubeat IO backend");
- jb_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(jb_io_set_loggers);
- jb_io_ok =
- jb_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
+ jb_io_ok = jb_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get());
if (!jb_io_ok) {
goto fail;
@@ -99,11 +103,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
log_info("Starting up card reader backend");
- eam_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
- eam_io_ok =
- eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
+ eam_io_ok = eam_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get());
if (!eam_io_ok) {
goto fail;
@@ -224,8 +229,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
return TRUE;
}
- log_to_external(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ // Use AVS APIs
+ avs_util_core_interop_thread_avs_impl_set();
+ avs_util_core_interop_log_avs_impl_set();
options_init_from_cmdline(&options);
diff --git a/src/main/jbhook2/options.c b/src/main/jbhook2/options.c
index 9e1987e4..63ee6d45 100644
--- a/src/main/jbhook2/options.c
+++ b/src/main/jbhook2/options.c
@@ -9,7 +9,7 @@
#include "util/cmdline.h"
#include "util/defs.h"
#include "util/hex.h"
-#include "util/log.h"
+
#include "util/str.h"
void options_init_from_cmdline(struct options *options)
diff --git a/src/main/jbhook3/Module.mk b/src/main/jbhook3/Module.mk
index a82c4cc9..ca36a439 100644
--- a/src/main/jbhook3/Module.mk
+++ b/src/main/jbhook3/Module.mk
@@ -8,6 +8,8 @@ ldflags_jbhook3 := \
-liphlpapi \
libs_jbhook3 := \
+ avs-util \
+ core \
acioemu \
eamio \
jbio \
diff --git a/src/main/jbhook3/dllmain.c b/src/main/jbhook3/dllmain.c
index b4eada83..30a0eb3d 100644
--- a/src/main/jbhook3/dllmain.c
+++ b/src/main/jbhook3/dllmain.c
@@ -5,9 +5,14 @@
#include
#include
+#include "avs-util/core-interop.h"
+
#include "bemanitools/eamio.h"
#include "bemanitools/jbio.h"
+#include "core/log.h"
+#include "core/thread.h"
+
#include "hook/iohook.h"
#include "hook/table.h"
@@ -31,8 +36,6 @@
#include "security/id.h"
#include "util/defs.h"
-#include "util/log.h"
-#include "util/thread.h"
static struct options options;
@@ -62,11 +65,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
if (!options.disable_p4ioemu) {
log_info("Starting up jubeat IO backend");
- jb_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(jb_io_set_loggers);
- jb_io_ok =
- jb_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
+ jb_io_ok = jb_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get());
if (!jb_io_ok) {
goto fail;
@@ -79,11 +83,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
if (!options.disable_cardemu) {
log_info("Starting up card reader backend");
- eam_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_impl_assign(eam_io_set_loggers);
- eam_io_ok =
- eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
+ eam_io_ok = eam_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get());
if (!eam_io_ok) {
goto fail;
@@ -143,8 +148,9 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
return TRUE;
}
- log_to_external(
- log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+ // Use AVS APIs
+ avs_util_core_interop_thread_avs_impl_set();
+ avs_util_core_interop_log_avs_impl_set();
options_init_from_cmdline(&options);
diff --git a/src/main/jbhook3/gfx.c b/src/main/jbhook3/gfx.c
index ee3b5ff5..827ac55f 100644
--- a/src/main/jbhook3/gfx.c
+++ b/src/main/jbhook3/gfx.c
@@ -5,12 +5,12 @@
#include
#include
+#include "core/log.h"
+
#include "hook/table.h"
#include "jbhook3/options.h"
-#include "util/log.h"
-
static bool jbhook3_gfx_windowed;
static bool jbhook3_gfx_show_cursor;
diff --git a/src/main/jbhook3/options.c b/src/main/jbhook3/options.c
index 59ffc1eb..8bb544b8 100644
--- a/src/main/jbhook3/options.c
+++ b/src/main/jbhook3/options.c
@@ -6,10 +6,11 @@
#include
#include
+#include "core/log.h"
+
#include "util/cmdline.h"
#include "util/defs.h"
#include "util/hex.h"
-#include "util/log.h"
#include "util/str.h"
void options_init_from_cmdline(struct options *options)
diff --git a/src/main/jbio-p4io/Module.mk b/src/main/jbio-p4io/Module.mk
index b31604df..ca9895e3 100644
--- a/src/main/jbio-p4io/Module.mk
+++ b/src/main/jbio-p4io/Module.mk
@@ -9,6 +9,7 @@ src_jbio-p4io := \
jbio.c \
libs_jbio-p4io := \
+ core \
aciodrv \
aciomgr \
cconfig \
diff --git a/src/main/jbio-p4io/config-h44b.c b/src/main/jbio-p4io/config-h44b.c
index 91d37cb8..98a5f4f2 100644
--- a/src/main/jbio-p4io/config-h44b.c
+++ b/src/main/jbio-p4io/config-h44b.c
@@ -1,8 +1,8 @@
#include "cconfig/cconfig-util.h"
-#include "jbio-p4io/config-h44b.h"
+#include "core/log.h"
-#include "util/log.h"
+#include "jbio-p4io/config-h44b.h"
#define JBIO_CONFIG_H44B_PORT_KEY "h44b.port"
#define JBIO_CONFIG_H44B_BAUD_KEY "h44b.baud"
diff --git a/src/main/jbio-p4io/h44b.c b/src/main/jbio-p4io/h44b.c
index 1d9b77a0..f26aa2a1 100644
--- a/src/main/jbio-p4io/h44b.c
+++ b/src/main/jbio-p4io/h44b.c
@@ -10,7 +10,7 @@
#include "aciomgr/manager.h"
-#include "util/log.h"
+#include "core/log.h"
static int16_t h44b_node_id;
diff --git a/src/main/jbio-p4io/jbio.c b/src/main/jbio-p4io/jbio.c
index 202187fe..58f4db9a 100644
--- a/src/main/jbio-p4io/jbio.c
+++ b/src/main/jbio-p4io/jbio.c
@@ -7,17 +7,17 @@
#include "aciomgr/manager.h"
+#include "bemanitools/jbio.h"
+
#include "cconfig/cconfig-main.h"
-#include "bemanitools/jbio.h"
+#include "core/log.h"
#include "jbio-p4io/config-h44b.h"
#include "jbio-p4io/h44b.h"
#include "p4iodrv/device.h"
-#include "util/log.h"
-
static struct p4iodrv_ctx *p4io_ctx;
static uint16_t jb_io_panels;
static uint8_t jb_io_sys_buttons;
@@ -36,7 +36,7 @@ void jb_io_set_loggers(
{
aciomgr_set_loggers(misc, info, warning, fatal);
- log_to_external(misc, info, warning, fatal);
+ core_log_impl_set(misc, info, warning, fatal);
}
bool jb_io_init(
diff --git a/src/main/jbiotest/Module.mk b/src/main/jbiotest/Module.mk
index f2cf618b..eba9c0b1 100644
--- a/src/main/jbiotest/Module.mk
+++ b/src/main/jbiotest/Module.mk
@@ -1,6 +1,7 @@
exes += jbiotest \
libs_jbiotest := \
+ core \
jbio \
util \
diff --git a/src/main/jbiotest/main.c b/src/main/jbiotest/main.c
index 416b3251..0a6270b4 100644
--- a/src/main/jbiotest/main.c
+++ b/src/main/jbiotest/main.c
@@ -7,8 +7,12 @@
#include "bemanitools/jbio.h"
-#include "util/log.h"
-#include "util/thread.h"
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log.h"
+#include "core/thread-crt-ext.h"
+#include "core/thread-crt.h"
+#include "core/thread.h"
typedef struct {
uint8_t r, g, b;
@@ -23,12 +27,17 @@ enum jbio_light_mode { LIGHTS_OFF, LIGHTS_ON, LIGHTS_INPUT };
*/
int main(int argc, char **argv)
{
- log_to_writer(log_writer_stdout, NULL);
+ core_thread_crt_ext_impl_set();
+ core_log_bt_ext_impl_set();
- jb_io_set_loggers(
- log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
+ core_log_bt_ext_init_with_stdout();
- if (!jb_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy)) {
+ core_log_impl_assign(jb_io_set_loggers);
+
+ if (!jb_io_init(
+ core_thread_create_impl_get(),
+ core_thread_join_impl_get(),
+ core_thread_destroy_impl_get())) {
printf("Initializing jbio failed\n");
return -1;
}
diff --git a/src/main/launcher/Module.mk b/src/main/launcher/Module.mk
index c9dfd078..32afa4c0 100644
--- a/src/main/launcher/Module.mk
+++ b/src/main/launcher/Module.mk
@@ -3,22 +3,36 @@ rc_launcher := launcher.rc
ldflags_launcher := \
-mconsole \
+ -ldbghelp \
deplibs_launcher := \
avs \
avs-ea3 \
libs_launcher := \
+ avs-util \
+ core \
hook \
util \
+ dwarfstack \
+ procmon-lib \
src_launcher := \
- avs-context.c \
- ea3-config.c \
+ avs-config.c \
+ avs.c \
+ bootstrap-config.c \
+ bootstrap.c \
+ debug.c \
+ ea3-ident-config.c \
+ eamuse-config.c \
+ eamuse.c \
+ hook.c \
+ launcher-config.c \
+ launcher.c \
main.c \
module.c \
options.c \
- property.c \
+ property-util.c \
stubs.c \
version.c \
diff --git a/src/main/launcher/avs-config.c b/src/main/launcher/avs-config.c
new file mode 100644
index 00000000..8669f3d4
--- /dev/null
+++ b/src/main/launcher/avs-config.c
@@ -0,0 +1,773 @@
+#define LOG_MODULE "avs-config"
+
+#include
+
+#include "avs-util/error.h"
+
+#include "core/log.h"
+
+#include "imports/avs.h"
+
+#include "launcher/avs-config.h"
+#include "launcher/property-util.h"
+
+#include "util/str.h"
+
+#define AVS_CONFIG_ROOT_NODE "/config"
+
+static const char *_avs_config_property_mounttable_path =
+ "/config/fs/mounttable";
+
+static void _avs_config_node_vfs_copy(
+ struct property *parent_property,
+ struct property_node *parent,
+ struct property_node *source)
+{
+ // Use max path size to fit dst and src fs paths
+ char data[MAX_PATH];
+
+ // Remark: Using property_node_clone doesn't work here
+ // Cloning non-deep only clones the vfs node. Cloning deep doesn't seem
+ // to work with arbitrary attributes that don't follow the general
+ // design of a property structure. This seems to require clear typing for
+ // nodes in order to allow property_node_clone to work
+
+ // Ignore errors and default to empty
+ memset(data, 0, sizeof(data));
+ property_node_refer(
+ NULL, source, "name@", PROPERTY_TYPE_ATTR, data, sizeof(data));
+ property_util_node_attribute_replace(
+ parent_property, parent, "name@", data);
+
+ memset(data, 0, sizeof(data));
+ property_node_refer(
+ NULL, source, "fstype@", PROPERTY_TYPE_ATTR, data, sizeof(data));
+ property_util_node_attribute_replace(
+ parent_property, parent, "fstype@", data);
+
+ memset(data, 0, sizeof(data));
+ property_node_refer(
+ NULL, source, "src@", PROPERTY_TYPE_ATTR, data, sizeof(data));
+ property_util_node_attribute_replace(parent_property, parent, "src@", data);
+
+ memset(data, 0, sizeof(data));
+ property_node_refer(
+ NULL, source, "dst@", PROPERTY_TYPE_ATTR, data, sizeof(data));
+ property_util_node_attribute_replace(parent_property, parent, "dst@", data);
+
+ memset(data, 0, sizeof(data));
+ property_node_refer(
+ NULL, source, "opt@", PROPERTY_TYPE_ATTR, data, sizeof(data));
+ property_util_node_attribute_replace(parent_property, parent, "opt@", data);
+}
+
+static bool _avs_config_mounttable_vfs_nodes_merge_strategy_do(
+ struct property *parent_property,
+ struct property_node *parent,
+ struct property_node *source,
+ void *ctx,
+ property_util_node_merge_recursion_do_t node_merge_recursion_do)
+{
+ struct property_node *parent_child;
+ struct property_node *source_child;
+
+ char parent_child_name[PROPERTY_NODE_NAME_SIZE_MAX];
+ char name_parent[PROPERTY_NODE_ATTR_NAME_SIZE_MAX];
+ char dst_parent[PROPERTY_NODE_ATTR_NAME_SIZE_MAX];
+
+ char source_child_name[PROPERTY_NODE_NAME_SIZE_MAX];
+ char name_source[PROPERTY_NODE_ATTR_NAME_SIZE_MAX];
+ char dst_source[PROPERTY_NODE_ATTR_NAME_SIZE_MAX];
+
+ bool node_consumed;
+ bool found_parent;
+
+ source_child = property_node_traversal(source, TRAVERSE_FIRST_CHILD);
+
+ node_consumed = false;
+
+ while (source_child) {
+ property_node_name(
+ source_child, source_child_name, sizeof(source_child_name));
+
+ if (str_eq(source_child_name, "vfs")) {
+ node_consumed = true;
+
+ parent_child =
+ property_node_traversal(parent, TRAVERSE_FIRST_CHILD);
+
+ found_parent = false;
+
+ while (parent_child) {
+ property_node_name(
+ parent_child, parent_child_name, sizeof(parent_child_name));
+
+ if (str_eq(parent_child_name, "vfs")) {
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ source_child,
+ "name@",
+ PROPERTY_TYPE_ATTR,
+ name_source,
+ sizeof(name_source)))) {
+ log_fatal(
+ "Missing 'name' attribute on avs config mounttable "
+ "vfs source node");
+ }
+
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ source_child,
+ "dst@",
+ PROPERTY_TYPE_ATTR,
+ dst_source,
+ sizeof(dst_source)))) {
+ log_fatal(
+ "Missing 'dst' attribute on avs config mounttable "
+ "vfs source node");
+ }
+
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ parent_child,
+ "name@",
+ PROPERTY_TYPE_ATTR,
+ name_parent,
+ sizeof(name_parent)))) {
+ log_fatal(
+ "Missing 'name' attribute on avs config mounttable "
+ "vfs parent node");
+ }
+
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ parent_child,
+ "dst@",
+ PROPERTY_TYPE_ATTR,
+ dst_parent,
+ sizeof(dst_parent)))) {
+ log_fatal(
+ "Missing 'dst' attribute on avs config mounttable "
+ "vfs parent node");
+ }
+
+ // Found existing matching node on parent, replace it
+ if (str_eq(name_source, name_parent) &&
+ str_eq(dst_source, dst_parent)) {
+ _avs_config_node_vfs_copy(
+ parent_property, parent_child, source_child);
+
+ found_parent = true;
+ break;
+ }
+ }
+
+ parent_child = property_node_traversal(
+ parent_child, TRAVERSE_NEXT_SIBLING);
+ }
+
+ // Not found an existing node that got replaced, insert/merge new
+ // data
+ if (!found_parent) {
+ parent_child = property_node_create(
+ parent_property, parent, PROPERTY_TYPE_VOID, "vfs");
+
+ _avs_config_node_vfs_copy(
+ parent_property, parent_child, source_child);
+ }
+ }
+
+ source_child =
+ property_node_traversal(source_child, TRAVERSE_NEXT_SIBLING);
+ }
+
+ return node_consumed;
+}
+
+struct property *avs_config_load(const char *filepath)
+{
+ struct property *property;
+
+ log_assert(filepath);
+
+ log_info("Loading from file path: %s", filepath);
+
+ property = property_util_load(filepath);
+
+ // Check if root node exists, call already errors if not
+ avs_config_root_get(property);
+
+ return property;
+}
+
+struct property_node *avs_config_root_get(struct property *property)
+{
+ struct property_node *node;
+
+ log_assert(property);
+
+ node = property_search(property, 0, AVS_CONFIG_ROOT_NODE);
+
+ if (node == NULL) {
+ log_fatal("Root node " AVS_CONFIG_ROOT_NODE " in AVS config missing");
+ }
+
+ return node;
+}
+
+struct property *
+avs_config_property_merge(struct property *parent, struct property *source)
+{
+ struct property_util_node_merge_strategies strategies;
+
+ log_assert(parent);
+ log_assert(source);
+
+ strategies.num = 2;
+
+ strategies.entry[0].path = _avs_config_property_mounttable_path;
+ strategies.entry[0].merge_strategy_do =
+ _avs_config_mounttable_vfs_nodes_merge_strategy_do;
+
+ strategies.entry[1].path = "";
+ strategies.entry[1].merge_strategy_do =
+ property_util_node_merge_default_strategy_do;
+
+ return property_util_merge_with_strategies(parent, source, &strategies);
+}
+
+void avs_config_fs_root_device_get(
+ struct property_node *node, char *buffer, size_t size)
+{
+ struct property_node *device_node;
+ avs_error error;
+
+ log_assert(node);
+
+ device_node = property_search(NULL, node, "fs/root/device");
+
+ if (device_node == NULL) {
+ log_fatal("Could not find node fs/root/device AVS config");
+ }
+
+ error = property_node_read(device_node, PROPERTY_TYPE_STR, buffer, size);
+
+ if (AVS_IS_ERROR(error)) {
+ log_fatal(
+ "fs/root/device, property read failed: %s",
+ avs_util_error_str(error));
+ }
+}
+
+void avs_config_mode_product_set(struct property_node *node, bool enable)
+{
+ log_assert(node);
+
+#if AVS_VERSION <= 1306
+ property_util_node_u8_replace(NULL, node, "mode/product", enable ? 1 : 0);
+#else
+ property_util_node_bool_replace(NULL, node, "mode/product", enable);
+#endif
+}
+
+void avs_config_net_raw_set(struct property_node *node, bool enable)
+{
+ log_assert(node);
+
+#if AVS_VERSION <= 1306
+ property_util_node_u8_replace(NULL, node, "net/enable_raw", enable ? 1 : 0);
+#else
+ property_util_node_bool_replace(NULL, node, "net/enable_raw", enable);
+#endif
+}
+
+void avs_config_net_eaudp_set(struct property_node *node, bool enable)
+{
+ log_assert(node);
+
+#if AVS_VERSION <= 1306
+ property_util_node_u8_replace(
+ NULL, node, "net/eaudp/enable", enable ? 1 : 0);
+#else
+ property_util_node_bool_replace(NULL, node, "net/eaudp/enable", enable);
+#endif
+}
+
+void avs_config_sntp_ea_set(struct property_node *node, bool on)
+{
+ log_assert(node);
+
+#if AVS_VERSION <= 1306
+ property_util_node_u8_replace(NULL, node, "sntp/ea_on", on ? 1 : 0);
+#else
+ property_util_node_bool_replace(NULL, node, "sntp/ea_on", on);
+#endif
+}
+
+void avs_config_log_level_set(struct property_node *node, const char *level)
+{
+ log_assert(node);
+ log_assert(level);
+
+#if AVS_VERSION <= 1306
+ uint32_t level_value;
+
+ if (str_eq(level, "fatal")) {
+ level_value = 1;
+ } else if (str_eq(level, "warning")) {
+ level_value = 2;
+ } else if (str_eq(level, "info")) {
+ level_value = 3;
+ } else if (str_eq(level, "misc")) {
+ level_value = 4;
+ } else if (str_eq(level, "all")) {
+ level_value = 4;
+ } else if (str_eq(level, "disable")) {
+ level_value = 0;
+ } else if (str_eq(level, "default")) {
+ level_value = 4;
+ } else {
+ log_fatal("Unknown log level string %s", level);
+ }
+
+ property_util_node_u32_replace(NULL, node, "log/level", level_value);
+#else
+ property_util_node_str_replace(NULL, node, "log/level", level);
+#endif
+}
+
+void avs_config_log_name_set(struct property_node *node, const char *name)
+{
+ log_assert(node);
+ log_assert(name);
+
+ property_util_node_str_replace(NULL, node, "log/name", name);
+}
+
+void avs_config_log_file_set(struct property_node *node, const char *file)
+{
+ log_assert(node);
+ log_assert(file);
+
+ property_util_node_str_replace(NULL, node, "log/file", file);
+}
+
+void avs_config_log_buffer_size_set(struct property_node *node, uint32_t size)
+{
+ log_assert(node);
+
+ property_util_node_u32_replace(NULL, node, "log/sz_buf", size);
+}
+
+void avs_config_log_output_delay_set(
+ struct property_node *node, uint16_t delay_ms)
+{
+ log_assert(node);
+
+ property_util_node_u16_replace(NULL, node, "log/output_delay", delay_ms);
+}
+
+void avs_config_log_enable_console_set(struct property_node *node, bool enable)
+{
+ log_assert(node);
+
+#if AVS_VERSION <= 1306
+ property_util_node_u8_replace(
+ NULL, node, "log/enable_console", enable ? 1 : 0);
+#else
+ property_util_node_bool_replace(NULL, node, "log/enable_console", enable);
+#endif
+}
+
+void avs_config_log_enable_sci_set(struct property_node *node, bool enable)
+{
+ log_assert(node);
+
+#if AVS_VERSION <= 1306
+ property_util_node_u8_replace(
+ NULL, node, "log/enable_netsci", enable ? 1 : 0);
+#else
+ property_util_node_bool_replace(NULL, node, "log/enable_netsci", enable);
+#endif
+}
+
+void avs_config_log_enable_net_set(struct property_node *node, bool enable)
+{
+ log_assert(node);
+
+#if AVS_VERSION <= 1306
+ property_util_node_u8_replace(
+ NULL, node, "log/enable_netlog", enable ? 1 : 0);
+#else
+ property_util_node_bool_replace(NULL, node, "log/enable_netlog", enable);
+#endif
+}
+
+void avs_config_log_enable_file_set(struct property_node *node, bool enable)
+{
+ log_assert(node);
+
+#if AVS_VERSION <= 1306
+ property_util_node_u8_replace(
+ NULL, node, "log/enable_file", enable ? 1 : 0);
+#else
+ property_util_node_bool_replace(NULL, node, "log/enable_file", enable);
+#endif
+}
+
+void avs_config_log_rotate_set(struct property_node *node, bool rotate)
+{
+ log_assert(node);
+
+#if AVS_VERSION <= 1306
+ property_util_node_u8_replace(NULL, node, "log/rotate", rotate ? 1 : 0);
+#else
+ property_util_node_bool_replace(NULL, node, "log/rotate", rotate);
+#endif
+}
+
+void avs_config_log_append_set(struct property_node *node, bool append)
+{
+ log_assert(node);
+
+#if AVS_VERSION <= 1306
+ property_util_node_u8_replace(NULL, node, "log/append", append ? 1 : 0);
+#else
+ property_util_node_bool_replace(NULL, node, "log/append", append);
+#endif
+}
+
+void avs_config_log_count_set(struct property_node *node, uint16_t count)
+{
+ log_assert(node);
+
+ property_util_node_u16_replace(NULL, node, "log/gen", count);
+}
+
+void avs_config_set_log_level(
+ struct property_node *node, enum core_log_bt_log_level loglevel)
+{
+ const char *str;
+
+ log_assert(node);
+
+ switch (loglevel) {
+ case CORE_LOG_BT_LOG_LEVEL_OFF:
+ str = "disable";
+ break;
+
+ case CORE_LOG_BT_LOG_LEVEL_FATAL:
+ str = "fatal";
+ break;
+
+ case CORE_LOG_BT_LOG_LEVEL_WARNING:
+ str = "warn";
+ break;
+
+ case CORE_LOG_BT_LOG_LEVEL_INFO:
+ str = "info";
+ break;
+
+ case CORE_LOG_BT_LOG_LEVEL_MISC:
+ str = "misc";
+ break;
+
+ default:
+ log_fatal("Unsupported log level: %d", loglevel);
+ break;
+ }
+
+ avs_config_log_level_set(node, str);
+}
+
+void avs_config_local_fs_path_dev_nvram_and_raw_set(
+ struct property_node *node, const char *dev_nvram_raw_path)
+{
+ char path_dev_raw[MAX_PATH];
+ char path_dev_nvram[MAX_PATH];
+
+ struct property_node *fs_node;
+ struct property_node *mounttable_node;
+ struct property_node *vfs_node;
+
+ log_assert(node);
+ log_assert(dev_nvram_raw_path);
+
+ str_cpy(path_dev_raw, sizeof(path_dev_raw), dev_nvram_raw_path);
+ str_cat(path_dev_raw, sizeof(path_dev_raw), "/dev/raw");
+
+ str_cpy(path_dev_nvram, sizeof(path_dev_nvram), dev_nvram_raw_path);
+ str_cat(path_dev_nvram, sizeof(path_dev_nvram), "/dev/nvram");
+
+ fs_node = property_search(NULL, node, "fs");
+
+ if (!fs_node) {
+ log_fatal("Cannot find 'fs' node in avs config");
+ }
+
+ // Check if "new" mounttable config is used for dev/nvram and dev/raw or
+ // legacy config
+ if (property_search(NULL, fs_node, "mounttable")) {
+ property_remove(NULL, fs_node, "mounttable");
+
+ mounttable_node = property_node_create(
+ NULL, fs_node, PROPERTY_TYPE_VOID, "mounttable");
+
+ vfs_node = property_node_create(
+ NULL, mounttable_node, PROPERTY_TYPE_VOID, "vfs");
+
+ property_node_create(
+ NULL, vfs_node, PROPERTY_TYPE_ATTR, "name", "boot");
+ property_node_create(
+ NULL, vfs_node, PROPERTY_TYPE_ATTR, "fstype", "fs");
+ property_node_create(
+ NULL, vfs_node, PROPERTY_TYPE_ATTR, "src", path_dev_raw);
+ property_node_create(
+ NULL, vfs_node, PROPERTY_TYPE_ATTR, "dest", "/dev/raw");
+ property_node_create(
+ NULL, vfs_node, PROPERTY_TYPE_ATTR, "opt", "vf=1,posix=1");
+
+ vfs_node = property_node_create(
+ NULL, mounttable_node, PROPERTY_TYPE_VOID, "vfs");
+
+ property_node_create(
+ NULL, vfs_node, PROPERTY_TYPE_ATTR, "name", "boot");
+ property_node_create(
+ NULL, vfs_node, PROPERTY_TYPE_ATTR, "fstype", "fs");
+ property_node_create(
+ NULL, vfs_node, PROPERTY_TYPE_ATTR, "src", path_dev_nvram);
+ property_node_create(
+ NULL, vfs_node, PROPERTY_TYPE_ATTR, "dest", "/dev/nvram");
+ property_node_create(
+ NULL, vfs_node, PROPERTY_TYPE_ATTR, "opt", "vf=1,posix=1");
+ } else {
+ property_util_node_str_replace(
+ NULL, fs_node, "nvram/device", path_dev_raw);
+ property_util_node_str_replace(NULL, fs_node, "nvram/fstype", "fs");
+ property_util_node_str_replace(
+ NULL, fs_node, "nvram/option", "vf=1,posix=1");
+
+ property_util_node_str_replace(
+ NULL, fs_node, "raw/device", path_dev_nvram);
+ property_util_node_str_replace(NULL, fs_node, "raw/fstype", "fs");
+ property_util_node_str_replace(
+ NULL, fs_node, "raw/option", "vf=1,posix=1");
+ }
+}
+
+void avs_config_vfs_mounttable_get(
+ struct property_node *node, struct avs_config_vfs_mounttable *mounttable)
+{
+ struct property_node *fs_node;
+ struct property_node *mounttable_node;
+ struct property_node *cur;
+ char mounttable_selector[128];
+ char name[128];
+ uint8_t pos;
+
+ log_assert(node);
+ log_assert(mounttable);
+
+ fs_node = property_search(NULL, node, "fs");
+
+ if (!fs_node) {
+ log_fatal("Cannot find 'fs' node in avs config");
+ }
+
+ // Check if new mounttable config is used for dev/nvram and dev/raw or
+ // legacy config
+ mounttable_node = property_search(NULL, fs_node, "mounttable");
+
+ memset(mounttable, 0, sizeof(*mounttable));
+ pos = 0;
+
+ if (mounttable_node) {
+ cur = property_search(NULL, fs_node, "mounttable_selector");
+
+ if (!cur) {
+ log_fatal("Missing 'mounttable_selector' on mounttable");
+ }
+
+ if (AVS_IS_ERROR(property_node_read(
+ cur,
+ PROPERTY_TYPE_STR,
+ mounttable_selector,
+ sizeof(mounttable_selector)))) {
+ log_fatal("Reading 'mounttable_selector' failed");
+ }
+
+ log_misc("Mounttable selector: %s", mounttable_selector);
+
+ cur = property_node_traversal(mounttable_node, TRAVERSE_FIRST_CHILD);
+
+ while (cur) {
+ property_node_name(cur, name, sizeof(name));
+
+ if (str_eq(name, "vfs")) {
+ if (pos >= AVS_CONFIG_MOUNTTABLE_MAX_ENTRIES) {
+ log_warning(
+ "Exceeding max number of supported mounttable entries "
+ "(%d), ignoring remaining",
+ pos);
+ break;
+ }
+
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ cur,
+ "name@",
+ PROPERTY_TYPE_ATTR,
+ name,
+ sizeof(name)))) {
+ log_fatal("Missing 'name' attribute on vfs node");
+ }
+
+ if (str_eq(name, mounttable_selector)) {
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ cur,
+ "fstype@",
+ PROPERTY_TYPE_ATTR,
+ mounttable->entry[pos].fstype,
+ sizeof(mounttable->entry[pos].fstype)))) {
+ // default
+ str_cpy(
+ mounttable->entry[pos].fstype,
+ sizeof(mounttable->entry[pos].fstype),
+ "fs");
+ }
+
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ cur,
+ "src@",
+ PROPERTY_TYPE_ATTR,
+ mounttable->entry[pos].src,
+ sizeof(mounttable->entry[pos].src)))) {
+ log_fatal(
+ "Missing 'src' attribute on vfs node, name: %s",
+ name);
+ }
+
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ cur,
+ "dst@",
+ PROPERTY_TYPE_ATTR,
+ mounttable->entry[pos].dst,
+ sizeof(mounttable->entry[pos].dst)))) {
+ log_fatal(
+ "Missing 'dst' attribute on vfs node, name: %s",
+ name);
+ }
+
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ cur,
+ "opt@",
+ PROPERTY_TYPE_ATTR,
+ mounttable->entry[pos].opt,
+ sizeof(mounttable->entry[pos].opt)))) {
+ // optional
+ }
+
+ pos++;
+ }
+ }
+
+ cur = property_node_traversal(cur, TRAVERSE_NEXT_SIBLING);
+ }
+ } else {
+ cur = property_search(NULL, fs_node, "nvram");
+
+ if (cur) {
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ cur,
+ "fstype",
+ PROPERTY_TYPE_STR,
+ mounttable->entry[pos].fstype,
+ sizeof(mounttable->entry[pos].fstype)))) {
+ // default
+ str_cpy(
+ mounttable->entry[pos].fstype,
+ sizeof(mounttable->entry[pos].fstype),
+ "fs");
+ }
+
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ cur,
+ "device",
+ PROPERTY_TYPE_STR,
+ mounttable->entry[pos].src,
+ sizeof(mounttable->entry[pos].src)))) {
+ log_fatal("Missing 'device' attribute on nvram node");
+ }
+
+ str_cpy(
+ mounttable->entry[pos].dst,
+ sizeof(mounttable->entry[pos].dst),
+ "/dev/nvram");
+
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ cur,
+ "opt",
+ PROPERTY_TYPE_STR,
+ mounttable->entry[pos].opt,
+ sizeof(mounttable->entry[pos].opt)))) {
+ // optional
+ }
+
+ pos++;
+ }
+
+ cur = property_search(NULL, fs_node, "raw");
+
+ if (cur) {
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ cur,
+ "fstype",
+ PROPERTY_TYPE_STR,
+ mounttable->entry[pos].fstype,
+ sizeof(mounttable->entry[pos].fstype)))) {
+ // default
+ str_cpy(
+ mounttable->entry[pos].fstype,
+ sizeof(mounttable->entry[pos].fstype),
+ "fs");
+ }
+
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ cur,
+ "device",
+ PROPERTY_TYPE_STR,
+ mounttable->entry[pos].src,
+ sizeof(mounttable->entry[pos].src)))) {
+ log_fatal("Missing 'device' attribute on raw node");
+ }
+
+ str_cpy(
+ mounttable->entry[pos].dst,
+ sizeof(mounttable->entry[pos].dst),
+ "/dev/raw");
+
+ if (AVS_IS_ERROR(property_node_refer(
+ NULL,
+ cur,
+ "opt",
+ PROPERTY_TYPE_STR,
+ mounttable->entry[pos].opt,
+ sizeof(mounttable->entry[pos].opt)))) {
+ // optional
+ }
+
+ pos++;
+ }
+ }
+
+ mounttable->num_entries = pos;
+}
\ No newline at end of file
diff --git a/src/main/launcher/avs-config.h b/src/main/launcher/avs-config.h
new file mode 100644
index 00000000..692643d3
--- /dev/null
+++ b/src/main/launcher/avs-config.h
@@ -0,0 +1,57 @@
+#ifndef LAUNCHER_AVS_CONFIG_H
+#define LAUNCHER_AVS_CONFIG_H
+
+#include "core/log-bt.h"
+
+#include "imports/avs.h"
+
+#include "launcher/bootstrap-config.h"
+
+#define AVS_CONFIG_MOUNTTABLE_MAX_ENTRIES 16
+
+struct avs_config_vfs_mounttable {
+ struct {
+ char fstype[64];
+ char src[512];
+ char dst[512];
+ char opt[256];
+ } entry[AVS_CONFIG_MOUNTTABLE_MAX_ENTRIES];
+
+ uint8_t num_entries;
+};
+
+struct property *avs_config_load(const char *filepath);
+struct property_node *avs_config_root_get(struct property *property);
+struct property *
+avs_config_property_merge(struct property *parent, struct property *source);
+
+void avs_config_fs_root_device_get(
+ struct property_node *node, char *buffer, size_t size);
+
+void avs_config_mode_product_set(struct property_node *node, bool enable);
+void avs_config_net_raw_set(struct property_node *node, bool enable);
+void avs_config_net_eaudp_set(struct property_node *node, bool enable);
+void avs_config_sntp_ea_set(struct property_node *node, bool on);
+void avs_config_log_level_set(struct property_node *node, const char *level);
+void avs_config_log_name_set(struct property_node *node, const char *name);
+void avs_config_log_file_set(struct property_node *node, const char *file);
+void avs_config_log_buffer_size_set(struct property_node *node, uint32_t size);
+void avs_config_log_output_delay_set(
+ struct property_node *node, uint16_t delay_ms);
+void avs_config_log_enable_console_set(struct property_node *node, bool enable);
+void avs_config_log_enable_sci_set(struct property_node *node, bool enable);
+void avs_config_log_enable_net_set(struct property_node *node, bool enable);
+void avs_config_log_enable_file_set(struct property_node *node, bool enable);
+void avs_config_log_rotate_set(struct property_node *node, bool rotate);
+void avs_config_log_append_set(struct property_node *node, bool append);
+void avs_config_log_count_set(struct property_node *node, uint16_t count);
+
+void avs_config_set_log_level(
+ struct property_node *node, enum core_log_bt_log_level loglevel);
+void avs_config_local_fs_path_dev_nvram_and_raw_set(
+ struct property_node *node, const char *dev_nvram_raw_path);
+
+void avs_config_vfs_mounttable_get(
+ struct property_node *node, struct avs_config_vfs_mounttable *mounttable);
+
+#endif
\ No newline at end of file
diff --git a/src/main/launcher/avs-context.c b/src/main/launcher/avs-context.c
deleted file mode 100644
index 1e391db1..00000000
--- a/src/main/launcher/avs-context.c
+++ /dev/null
@@ -1,72 +0,0 @@
-#include
-
-#include
-#include
-#include
-
-#include "imports/avs.h"
-
-#include "launcher/avs-context.h"
-
-#include "util/log.h"
-
-static void *avs_heap;
-
-#ifdef AVS_HAS_STD_HEAP
-static void *std_heap;
-#endif
-
-void avs_context_init(
- struct property_node *config,
- uint32_t avs_heap_size,
- uint32_t std_heap_size,
- avs_log_writer_t log_writer,
- void *log_writer_ctx)
-{
- avs_heap = VirtualAlloc(
- NULL, avs_heap_size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
-
- if (avs_heap == NULL) {
- log_fatal(
- "Failed to VirtualAlloc %d byte AVS heap: %08x",
- avs_heap_size,
- (unsigned int) GetLastError());
- }
-
-#ifdef AVS_HAS_STD_HEAP
- std_heap = VirtualAlloc(
- NULL, std_heap_size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
-
- if (std_heap == NULL) {
- log_fatal(
- "Failed to VirtualAlloc %d byte \"std\" heap: %08x",
- std_heap_size,
- (unsigned int) GetLastError());
- }
-#endif
-
-#ifdef AVS_HAS_STD_HEAP
- avs_boot(
- config,
- std_heap,
- std_heap_size,
- avs_heap,
- avs_heap_size,
- log_writer,
- log_writer_ctx);
-#else
- /* AVS v2.16.xx and I suppose onward uses a unified heap */
- avs_boot(config, avs_heap, avs_heap_size, NULL, log_writer, log_writer_ctx);
-#endif
-}
-
-void avs_context_fini(void)
-{
- avs_shutdown();
-
-#ifdef AVS_HAS_STD_HEAP
- VirtualFree(std_heap, 0, MEM_RELEASE);
-#endif
-
- VirtualFree(avs_heap, 0, MEM_RELEASE);
-}
diff --git a/src/main/launcher/avs-context.h b/src/main/launcher/avs-context.h
deleted file mode 100644
index d4532eb4..00000000
--- a/src/main/launcher/avs-context.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef LAUNCHER_AVS_CONTEXT_H
-#define LAUNCHER_AVS_CONTEXT_H
-
-#include
-
-#include "imports/avs.h"
-
-#if AVS_VERSION < 1600
-#define AVS_HAS_STD_HEAP
-#endif
-
-void avs_context_init(
- struct property_node *config,
- uint32_t avs_heap_size,
- uint32_t std_heap_size,
- avs_log_writer_t log_writer,
- void *log_writer_ctx);
-void avs_context_fini(void);
-
-#endif
diff --git a/src/main/launcher/avs.c b/src/main/launcher/avs.c
new file mode 100644
index 00000000..4ff0730a
--- /dev/null
+++ b/src/main/launcher/avs.c
@@ -0,0 +1,270 @@
+#define LOG_MODULE "avs"
+
+#include
+
+#include
+#include
+#include
+
+#include "core/log-bt.h"
+#include "core/log.h"
+
+#include "imports/avs.h"
+
+#include "launcher/avs-config.h"
+#include "launcher/avs.h"
+#include "launcher/property-util.h"
+
+#include "util/codepage.h"
+#include "util/fs.h"
+#include "util/mem.h"
+#include "util/str.h"
+
+#if AVS_VERSION < 1600
+#define AVS_HAS_STD_HEAP
+#endif
+
+static void *avs_heap;
+
+#ifdef AVS_HAS_STD_HEAP
+static void *std_heap;
+#endif
+
+/* Gratuitous API changes orz */
+static AVS_LOG_WRITER(_avs_context_log_writer, chars, nchars, ctx)
+{
+ wchar_t *utf16;
+ char *utf8;
+ int utf16_len;
+ int utf8_len;
+ int result;
+
+ /* Ignore existing NUL terminator */
+
+ nchars--;
+
+ /* Transcode shit_jis to UTF-8 */
+
+ utf16_len = MultiByteToWideChar(CP_SHIFT_JIS, 0, chars, nchars, NULL, 0);
+
+ if (utf16_len == 0) {
+ abort();
+ }
+
+ utf16 = xmalloc(sizeof(*utf16) * utf16_len);
+ result =
+ MultiByteToWideChar(CP_SHIFT_JIS, 0, chars, nchars, utf16, utf16_len);
+
+ if (result == 0) {
+ abort();
+ }
+
+ utf8_len =
+ WideCharToMultiByte(CP_UTF8, 0, utf16, utf16_len, NULL, 0, NULL, NULL);
+
+ if (utf8_len == 0) {
+ abort();
+ }
+
+ utf8 = xmalloc(utf8_len + 3);
+ result = WideCharToMultiByte(
+ CP_UTF8, 0, utf16, utf16_len, utf8, utf8_len, NULL, NULL);
+
+ if (result == 0) {
+ abort();
+ }
+
+#if AVS_VERSION >= 1500
+ utf8[utf8_len + 0] = '\r';
+ utf8[utf8_len + 1] = '\n';
+
+ utf8_len += 2;
+#endif
+
+ // Clean string terminate
+ utf8[utf8_len] = '\0';
+
+ // Write to launcher's dedicated logging backend
+ core_log_bt_direct_sink_write(utf8, utf8_len);
+
+ /* Clean up */
+
+ free(utf8);
+ free(utf16);
+}
+
+static void _avs_switch_log_engine()
+{
+ // Switch the logging backend now that AVS is booted to use a single logging
+ // engine which avoids concurrency issues as AVS runs it's own async logger
+ // thread
+ core_log_impl_set(
+ log_body_misc, log_body_info, log_body_warning, log_body_fatal);
+
+ log_misc("Switched logging engine to AVS");
+}
+
+void avs_fs_assert_root_device_exists(struct property_node *node)
+{
+ char root_device_path[PATH_MAX];
+ char cwd_path[PATH_MAX];
+
+ avs_config_fs_root_device_get(
+ node, root_device_path, sizeof(root_device_path));
+ getcwd(cwd_path, sizeof(cwd_path));
+
+ if (!path_exists(root_device_path)) {
+ log_fatal(
+ "Root device path '%s' does not exist in current working dir '%s'",
+ root_device_path,
+ cwd_path);
+ }
+}
+
+void avs_fs_mountpoints_fs_dirs_create(struct property_node *node)
+{
+ struct avs_config_vfs_mounttable mounttable;
+ uint8_t i;
+
+ avs_config_vfs_mounttable_get(node, &mounttable);
+
+ if (mounttable.num_entries == 0) {
+ log_warning("No mountpoints found in mounttable");
+ }
+
+ for (i = 0; i < mounttable.num_entries; i++) {
+ if (str_eq(mounttable.entry[i].fstype, "fs")) {
+ log_misc(
+ "Creating avs fs directory '%s' for destination/device '%s'...",
+ mounttable.entry[i].src,
+ mounttable.entry[i].dst);
+
+ if (!path_exists(mounttable.entry[i].src)) {
+ if (!path_mkdir(mounttable.entry[i].src)) {
+ log_fatal(
+ "Creating fs directory %s failed",
+ mounttable.entry[i].src);
+ }
+ }
+ }
+ }
+}
+
+void avs_init(
+ struct property_node *node, uint32_t avs_heap_size, uint32_t std_heap_size)
+{
+ log_assert(node);
+ log_assert(avs_heap_size > 0);
+ // Modern games don't have a separate std heap anymore
+ log_assert(std_heap_size >= 0);
+
+ log_info("init");
+
+ log_misc("Allocating avs heap: %d", avs_heap_size);
+
+ avs_heap = VirtualAlloc(
+ NULL, avs_heap_size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
+
+ if (avs_heap == NULL) {
+ log_fatal(
+ "Failed to VirtualAlloc %d byte AVS heap: %08x",
+ avs_heap_size,
+ (unsigned int) GetLastError());
+ }
+
+#ifdef AVS_HAS_STD_HEAP
+ log_misc("Allocating std heap: %d", std_heap_size);
+
+ std_heap = VirtualAlloc(
+ NULL, std_heap_size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
+
+ if (std_heap == NULL) {
+ log_fatal(
+ "Failed to VirtualAlloc %d byte \"std\" heap: %08x",
+ std_heap_size,
+ (unsigned int) GetLastError());
+ }
+#endif
+
+ log_info("Calling avs_boot");
+
+#ifdef AVS_HAS_STD_HEAP
+ avs_boot(
+ node,
+ std_heap,
+ std_heap_size,
+ avs_heap,
+ avs_heap_size,
+ _avs_context_log_writer,
+ NULL);
+#else
+ /* AVS v2.16.xx and I suppose onward uses a unified heap */
+ avs_boot(
+ node, avs_heap, avs_heap_size, NULL, _avs_context_log_writer, NULL);
+#endif
+
+ _avs_switch_log_engine();
+
+ log_misc("init done");
+}
+
+void avs_fs_file_copy(const char *src, const char *dst)
+{
+ struct avs_stat st;
+
+ log_assert(src);
+ log_assert(dst);
+
+ log_misc("Copying %s to %s...", src, dst);
+
+ if (!avs_fs_lstat(src, &st)) {
+ log_fatal("File source %s does not exist or is not accessible", src);
+ }
+
+ if (avs_fs_copy(src, dst) < 0) {
+ log_fatal("Failed copying file %s to %s", src, dst);
+ }
+}
+
+void avs_fs_dir_log(const char *path)
+{
+ const char *name;
+
+ log_assert(path);
+
+ avs_desc dir = avs_fs_opendir(path);
+
+ if (dir < 0) {
+ log_warning(
+ "Opening avs dir %s failed, skipping logging contents", path);
+ }
+
+ log_misc("Contents of %s:", path);
+
+ do {
+ name = avs_fs_readdir(dir);
+
+ if (name == NULL) {
+ break;
+ }
+
+ log_misc("%s", name);
+ } while (name != NULL);
+
+ avs_fs_closedir(dir);
+}
+
+void avs_fini(void)
+{
+ log_info("fini");
+
+ avs_shutdown();
+
+#ifdef AVS_HAS_STD_HEAP
+ VirtualFree(std_heap, 0, MEM_RELEASE);
+#endif
+
+ VirtualFree(avs_heap, 0, MEM_RELEASE);
+
+ log_misc("fini done");
+}
diff --git a/src/main/launcher/avs.h b/src/main/launcher/avs.h
new file mode 100644
index 00000000..ad2233ac
--- /dev/null
+++ b/src/main/launcher/avs.h
@@ -0,0 +1,16 @@
+#ifndef LAUNCHER_AVS_H
+#define LAUNCHER_AVS_H
+
+#include
+
+#include "imports/avs.h"
+
+void avs_fs_assert_root_device_exists(struct property_node *node);
+void avs_fs_mountpoints_fs_dirs_create(struct property_node *node);
+void avs_init(
+ struct property_node *node, uint32_t avs_heap_size, uint32_t std_heap_size);
+void avs_fs_file_copy(const char *src, const char *dst);
+void avs_fs_dir_log(const char *path);
+void avs_fini(void);
+
+#endif
diff --git a/src/main/launcher/bootstrap-config.c b/src/main/launcher/bootstrap-config.c
new file mode 100644
index 00000000..35915c65
--- /dev/null
+++ b/src/main/launcher/bootstrap-config.c
@@ -0,0 +1,548 @@
+#define LOG_MODULE "bootstrap-config"
+
+#include
+
+#include "core/log.h"
+
+#include "imports/avs.h"
+
+#include "launcher/avs-config.h"
+#include "launcher/bootstrap-config.h"
+#include "launcher/property-util.h"
+
+#include "util/defs.h"
+#include "util/hex.h"
+#include "util/str.h"
+
+// clang-format off
+PSMAP_BEGIN(bootstrap_startup_boot_psmap)
+PSMAP_REQUIRED(PSMAP_TYPE_STR, struct bootstrap_boot_config, config_file,
+ "boot/file")
+PSMAP_REQUIRED(PSMAP_TYPE_U32, struct bootstrap_boot_config, avs_heap_size,
+ "boot/heap_avs")
+PSMAP_OPTIONAL(PSMAP_TYPE_U32, struct bootstrap_boot_config, std_heap_size,
+ "boot/heap_std", 0)
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_boot_config, mount_table_selector,
+ "boot/mounttable_selector", "boot")
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_boot_config, watcher_enable,
+ "boot/watcher", 1)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_boot_config, timemachine_enable,
+ "boot/timemachine", 0)
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_boot_config, launch_config_file,
+ "boot/launch_path", "/dev/raw/launch.xml")
+PSMAP_END
+
+PSMAP_BEGIN(bootstrap_startup_log_psmap)
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_log_config, level,
+ "log/level", "all")
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_log_config, name,
+ "log/name", "")
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_log_config, file,
+ "log/file", "")
+PSMAP_OPTIONAL(PSMAP_TYPE_U32, struct bootstrap_log_config, bufsz,
+ "log/sz_buf", 4096)
+PSMAP_OPTIONAL(PSMAP_TYPE_U16, struct bootstrap_log_config, output_delay_ms,
+ "log/output_delay", 10)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_log_config, enable_console,
+ "log/enable_console", 1)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_log_config, enable_sci,
+ "log/enable_netsci", 0)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_log_config, enable_net,
+ "log/enable_netlog", 1)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_log_config, enable_file,
+ "log/enable_file", 1)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_log_config, rotate,
+ "log/rotate", 1)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_log_config, append,
+ "log/append", 0)
+PSMAP_OPTIONAL(PSMAP_TYPE_U16, struct bootstrap_log_config, count,
+ "log/gen", 10)
+PSMAP_END
+
+PSMAP_BEGIN(bootstrap_startup_minidump_psmap)
+PSMAP_OPTIONAL(PSMAP_TYPE_U8, struct bootstrap_minidump_config, count,
+ "minidump/gen", 10)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_minidump_config, continue_,
+ "minidump/cont_debug", 0)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_minidump_config, log,
+ "minidump/echo_log", 1)
+PSMAP_OPTIONAL(PSMAP_TYPE_U8, struct bootstrap_minidump_config, type,
+ "minidump/dump_type", 2)
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_minidump_config, path,
+ "minidump/path", "/dev/raw/minidump")
+PSMAP_OPTIONAL(PSMAP_TYPE_U32, struct bootstrap_minidump_config, symbufsz,
+ "minidump/sz_symbuf", 32768)
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_minidump_config, search_path,
+ "minidump/search", ".")
+PSMAP_END
+
+PSMAP_BEGIN(bootstrap_startup_module_psmap)
+PSMAP_REQUIRED(PSMAP_TYPE_STR, struct bootstrap_module_config, file,
+ "component/file")
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_module_config, load_type,
+ "component/load_type", "MEMORY")
+PSMAP_END
+
+PSMAP_BEGIN(bootstrap_startup_dlm_psmap)
+/* disabled until we implement PSMAP_TYPE_BIN
+ PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_startup_config, ntdll_digest,
+ "dlml/ntdll/hash", "")
+ */
+PSMAP_OPTIONAL(PSMAP_TYPE_U32, struct bootstrap_dlm_config, size,
+ "dlml/ntdll/size", 0)
+PSMAP_OPTIONAL(PSMAP_TYPE_U32, struct bootstrap_dlm_config, ift_table,
+ "dlml/ntdll/ift_table", 0)
+PSMAP_OPTIONAL(PSMAP_TYPE_U32, struct bootstrap_dlm_config, ift_insert,
+ "dlml/ntdll/insert_ift", 0)
+PSMAP_OPTIONAL(PSMAP_TYPE_U32, struct bootstrap_dlm_config, ift_remove,
+ "dlml/ntdll/remove_ift", 0)
+PSMAP_END
+
+PSMAP_BEGIN(bootstrap_startup_shield_psmap)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_shield_config, enable,
+ "shield/enable", 1)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_shield_config, verbose,
+ "shield/verbose", 0)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_shield_config, use_loadlibrary,
+ "shield/use_loadlibrary", 0)
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_shield_config, logger,
+ "shield/logger", "")
+PSMAP_OPTIONAL(PSMAP_TYPE_U32, struct bootstrap_shield_config, sleep_min,
+ "shield/sleepmin", 10)
+PSMAP_OPTIONAL(PSMAP_TYPE_U32, struct bootstrap_shield_config, sleep_blur,
+ "shield/sleepblur", 90)
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_shield_config, whitelist_file,
+ "shield/whitelist", "prop/whitelist.csv")
+PSMAP_OPTIONAL(PSMAP_TYPE_U32, struct bootstrap_shield_config, tick_sleep,
+ "shield/ticksleep", 100)
+PSMAP_OPTIONAL(PSMAP_TYPE_U32, struct bootstrap_shield_config, tick_error,
+ "shield/tickerror", 1000)
+PSMAP_OPTIONAL(PSMAP_TYPE_U8, struct bootstrap_shield_config, overwork_threshold,
+ "shield/overwork_threshold", 50)
+PSMAP_OPTIONAL(PSMAP_TYPE_U32, struct bootstrap_shield_config, overwork_delay,
+ "shield/overwork_delay", 100)
+PSMAP_OPTIONAL(PSMAP_TYPE_U32, struct bootstrap_shield_config, pause_delay,
+ "shield/pause_delay", 1000)
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_shield_config, unlimited_key,
+ "shield/unlimited_key", "")
+PSMAP_OPTIONAL(PSMAP_TYPE_U16, struct bootstrap_shield_config, killer_port,
+ "shield_killer/port", 5001)
+PSMAP_END
+
+PSMAP_BEGIN(bootstrap_startup_dongle_psmap)
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_dongle_config, license_cn,
+ "dongle/license", "")
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_dongle_config, account_cn,
+ "dongle/account", "")
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_dongle_config, driver_dll,
+ "dongle/pkcs11_driver", "eTPKCS11.dll")
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_dongle_config, disable_gc,
+ "dongle/disable_gc", 0)
+PSMAP_END
+
+PSMAP_BEGIN(bootstrap_startup_drm_psmap)
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_drm_config, dll,
+ "drm/dll", "")
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_drm_config, fstype,
+ "drm/fstype", "")
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_drm_config, device,
+ "drm/device", "")
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_drm_config, mount,
+ "drm/dst", "/")
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_drm_config, options,
+ "drm/option", "")
+PSMAP_END
+
+PSMAP_BEGIN(bootstrap_startup_lte_psmap)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_lte_config, enable,
+ "lte/enable", 0)
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_lte_config, config_file,
+ "lte/file", "/dev/nvram/lte-config.xml")
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_lte_config, unlimited_key,
+ "lte/unlimited_key", "")
+PSMAP_END
+
+PSMAP_BEGIN(bootstrap_startup_ssl_psmap)
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_ssl_config, options,
+ "ssl/option", "")
+PSMAP_END
+
+PSMAP_BEGIN(bootstrap_startup_esign_psmap)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_esign_config, enable,
+ "esign/enable", 0)
+PSMAP_END
+
+PSMAP_BEGIN(bootstrap_startup_eamuse_psmap)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_eamuse_config, enable,
+ "eamuse/enable", 1)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_eamuse_config, sync,
+ "eamuse/sync", 1)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_eamuse_config, enable_model,
+ "eamuse/enable_model", 0)
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_eamuse_config, config_file,
+ "eamuse/file", "/dev/nvram/ea3-config.xml")
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct bootstrap_eamuse_config, updatecert_enable,
+ "eamuse/updatecert_enable", 1)
+PSMAP_OPTIONAL(PSMAP_TYPE_U32, struct bootstrap_eamuse_config, updatecert_interval,
+ "eamuse/updatecert_interval", 0)
+PSMAP_END
+
+PSMAP_BEGIN(bootstrap_psmap)
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct bootstrap_config, release_code, "/release_code", "")
+PSMAP_END
+// clang-format on
+
+#define ROOT_NODE "/config"
+#define MODULE_PATH_PREFIX "modules/"
+
+#define NODE_MISSING_FATAL(subnode) \
+ log_fatal("%s/%s: Node missing", ROOT_NODE, subnode);
+#define NODE_STARTUP_MISSING_FATAL(profile) \
+ log_fatal("%s/startup/%s: Node missing", ROOT_NODE, profile);
+#define NODE_PROFILE_MISSING_FATAL(profile, subnode) \
+ log_fatal("%s/%s/%s: Node missing", ROOT_NODE, profile, subnode);
+#define NODE_PROFILE_LOADING_FATAL(profile, subnode) \
+ log_fatal("%s/startup/%s/%s: Node loading", ROOT_NODE, profile, subnode);
+
+#define DEFAULT_HEAP_SIZE 16777216
+
+const char *const inherited_nodes[] = {
+ "develop",
+ "default",
+ "log",
+ "minidump",
+ "boot",
+ "drm",
+ "ssl",
+ "eamuse",
+ "shield",
+ "esign",
+ "dongle",
+ "lte",
+};
+
+static void _bootstrap_config_profile_node_verify(
+ struct property_node *node, const char *profile)
+{
+ struct property_node *profile_node;
+
+ log_assert(node);
+ log_assert(profile);
+
+ profile_node = property_search(NULL, node, profile);
+
+ if (!profile_node) {
+ NODE_STARTUP_MISSING_FATAL(profile);
+ }
+}
+
+static struct property_node *
+_bootstrap_config_root_node_get(struct property *property)
+{
+ struct property_node *root_node;
+
+ log_assert(property);
+
+ root_node = property_search(property, NULL, ROOT_NODE);
+
+ if (!root_node) {
+ NODE_MISSING_FATAL("");
+ }
+
+ return root_node;
+}
+
+static struct property_node *
+_bootstrap_config_startup_node_get(struct property_node *node)
+{
+ struct property_node *startup_node;
+
+ log_assert(node);
+
+ startup_node = property_search(NULL, node, "startup");
+
+ if (!startup_node) {
+ NODE_MISSING_FATAL("startup");
+ }
+
+ return startup_node;
+}
+
+static void _bootstrap_config_inheritance_resolve(
+ struct property_node *startup_node, const char *profile_name)
+{
+ struct property_node *startup_parent_node;
+ struct property_node *startup_profile_node;
+ struct property_node *tmp_node;
+
+ char inherit_name[64];
+ avs_error error;
+ struct property_node *result;
+
+ startup_profile_node = property_search(NULL, startup_node, profile_name);
+
+ if (!startup_profile_node) {
+ log_fatal(ROOT_NODE "/startup/%s: missing", profile_name);
+ }
+
+ startup_parent_node = startup_profile_node;
+
+ for (;;) {
+ error = property_node_refer(
+ NULL,
+ startup_parent_node,
+ "inherit@",
+ PROPERTY_TYPE_ATTR,
+ inherit_name,
+ sizeof(inherit_name));
+
+ if (AVS_IS_ERROR(error)) {
+ break;
+ }
+
+ startup_parent_node = property_search(NULL, startup_node, inherit_name);
+
+ if (!startup_parent_node) {
+ NODE_STARTUP_MISSING_FATAL(inherit_name);
+ }
+
+ for (int i = 0; i < _countof(inherited_nodes); i++) {
+ if (property_search(NULL, startup_node, inherited_nodes[i])) {
+ continue;
+ }
+
+ tmp_node =
+ property_search(NULL, startup_parent_node, inherited_nodes[i]);
+
+ if (tmp_node) {
+ log_misc(
+ ROOT_NODE "/startup/%s: merging %s...",
+ inherit_name,
+ inherited_nodes[i]);
+
+ result = property_node_clone(
+ NULL, startup_profile_node, tmp_node, true);
+
+ if (!result) {
+ log_fatal(
+ "Merging '%s' into '%s' failed",
+ inherited_nodes[i],
+ inherit_name);
+ }
+ }
+ }
+ }
+}
+
+static void _bootstrap_config_load_bootstrap_module_app_config(
+ struct property_node *profile_node, struct bootstrap_module_config *config)
+{
+ struct property_node *app_node;
+
+ log_assert(profile_node);
+ log_assert(config);
+
+ app_node = property_search(NULL, profile_node, "component/param");
+
+ config->app_config = property_util_node_extract(app_node);
+}
+
+static void _bootstrap_config_load_bootstrap_default_files_config(
+ const char *profile_name,
+ struct property_node *profile_node,
+ struct bootstrap_default_file_config *config)
+{
+ int i;
+ int result;
+ struct property_node *child;
+
+ log_assert(profile_node);
+ log_assert(config);
+
+ child = property_search(NULL, profile_node, "default/file");
+ i = 0;
+
+ while (child) {
+ if (i >= DEFAULT_FILE_MAX) {
+ log_warning(
+ "Currently not supporting more than %d default files, skipping "
+ "remaining",
+ i);
+ break;
+ }
+
+ result = property_node_refer(
+ NULL,
+ child,
+ "src@",
+ PROPERTY_TYPE_ATTR,
+ &config->file[i].src,
+ sizeof(config->file[i].src));
+
+ if (result < 0) {
+ log_fatal(
+ "Missing src attribute on default file node of profile %s",
+ profile_name);
+ }
+
+ result = property_node_refer(
+ NULL,
+ child,
+ "dst@",
+ PROPERTY_TYPE_ATTR,
+ &config->file[i].dst,
+ sizeof(config->file[i].dst));
+
+ if (result < 0) {
+ log_fatal(
+ "Missing dst attribute on default file node of profile %s",
+ profile_name);
+ }
+
+ child = property_node_traversal(child, TRAVERSE_NEXT_SEARCH_RESULT);
+ i++;
+ }
+}
+
+static void _bootstrap_config_load_bootstrap(
+ struct property_node *startup_node,
+ const char *profile,
+ struct bootstrap_startup_config *config)
+{
+ struct property_node *profile_node;
+
+ profile_node = property_search(NULL, startup_node, profile);
+
+ if (!profile_node) {
+ NODE_PROFILE_LOADING_FATAL(profile, "");
+ }
+
+ _bootstrap_config_load_bootstrap_default_files_config(
+ profile, profile_node, &config->default_file);
+
+ if (!property_psmap_import(
+ NULL, profile_node, &config->boot, bootstrap_startup_boot_psmap)) {
+ NODE_PROFILE_LOADING_FATAL(profile, "boot");
+ }
+
+ if (!property_psmap_import(
+ NULL, profile_node, &config->log, bootstrap_startup_log_psmap)) {
+ NODE_PROFILE_LOADING_FATAL(profile, "log");
+ }
+
+ if (!property_psmap_import(
+ NULL,
+ profile_node,
+ &config->minidump,
+ bootstrap_startup_minidump_psmap)) {
+ NODE_PROFILE_LOADING_FATAL(profile, "minidump");
+ }
+
+ if (!property_psmap_import(
+ NULL,
+ profile_node,
+ &config->module,
+ bootstrap_startup_module_psmap)) {
+ NODE_PROFILE_LOADING_FATAL(profile, "component");
+ }
+
+ _bootstrap_config_load_bootstrap_module_app_config(
+ profile_node, &config->module);
+
+ if (!property_psmap_import(
+ NULL,
+ profile_node,
+ &config->dlm_ntdll,
+ bootstrap_startup_dlm_psmap)) {
+ NODE_PROFILE_LOADING_FATAL(profile, "dlm/ntdll");
+ }
+
+ if (!property_psmap_import(
+ NULL,
+ profile_node,
+ &config->shield,
+ bootstrap_startup_shield_psmap)) {
+ NODE_PROFILE_LOADING_FATAL(profile, "shield");
+ }
+
+ if (!property_psmap_import(
+ NULL,
+ profile_node,
+ &config->dongle,
+ bootstrap_startup_dongle_psmap)) {
+ NODE_PROFILE_LOADING_FATAL(profile, "dongle");
+ }
+
+ if (!property_psmap_import(
+ NULL, profile_node, &config->drm, bootstrap_startup_drm_psmap)) {
+ NODE_PROFILE_LOADING_FATAL(profile, "drm");
+ }
+
+ if (!property_psmap_import(
+ NULL, profile_node, &config->lte, bootstrap_startup_lte_psmap)) {
+ NODE_PROFILE_LOADING_FATAL(profile, "lte");
+ }
+
+ if (!property_psmap_import(
+ NULL, profile_node, &config->ssl, bootstrap_startup_ssl_psmap)) {
+ NODE_PROFILE_LOADING_FATAL(profile, "ssl");
+ }
+
+ if (!property_psmap_import(
+ NULL,
+ profile_node,
+ &config->esign,
+ bootstrap_startup_esign_psmap)) {
+ NODE_PROFILE_LOADING_FATAL(profile, "esign");
+ }
+
+ if (!property_psmap_import(
+ NULL,
+ profile_node,
+ &config->eamuse,
+ bootstrap_startup_eamuse_psmap)) {
+ NODE_PROFILE_LOADING_FATAL(profile, "eamuse");
+ }
+}
+
+void bootstrap_config_init(struct bootstrap_config *config)
+{
+ log_assert(config);
+
+ memset(config, 0, sizeof(*config));
+}
+
+void bootstrap_config_load(
+ struct property *property,
+ const char *profile,
+ struct bootstrap_config *config)
+{
+ struct property_node *root_node;
+ struct property_node *startup_node;
+
+ log_assert(property);
+ log_assert(profile);
+ log_assert(config);
+
+ log_info(ROOT_NODE ": loading...");
+
+ root_node = _bootstrap_config_root_node_get(property);
+
+ if (!property_psmap_import(NULL, root_node, config, bootstrap_psmap)) {
+ log_fatal(ROOT_NODE ": loading failed");
+ }
+
+ startup_node = _bootstrap_config_startup_node_get(root_node);
+
+ _bootstrap_config_profile_node_verify(startup_node, profile);
+
+ _bootstrap_config_inheritance_resolve(startup_node, profile);
+
+ log_misc(ROOT_NODE "/startup/%s: loading merged result...", profile);
+
+ property_util_node_log(startup_node);
+
+ _bootstrap_config_load_bootstrap(startup_node, profile, &config->startup);
+
+ log_misc("Loading finished");
+}
\ No newline at end of file
diff --git a/src/main/launcher/bootstrap-config.h b/src/main/launcher/bootstrap-config.h
new file mode 100644
index 00000000..596bf93f
--- /dev/null
+++ b/src/main/launcher/bootstrap-config.h
@@ -0,0 +1,139 @@
+#ifndef LAUNCHER_BOOTSTRAP_CONFIG_H
+#define LAUNCHER_BOOTSTRAP_CONFIG_H
+
+#include
+#include
+
+#include "imports/avs.h"
+
+// should be enough for a while
+#define DEFAULT_FILE_MAX 16
+
+struct bootstrap_startup_config {
+ struct bootstrap_default_file_config {
+ struct bootstrap_default_file {
+ char src[64];
+ char dst[64];
+ } file[DEFAULT_FILE_MAX];
+ } default_file;
+
+ struct bootstrap_boot_config {
+ char config_file[64];
+ uint32_t avs_heap_size;
+ uint32_t std_heap_size;
+ char launch_config_file[64];
+ char mount_table_selector[16];
+ bool watcher_enable;
+ bool timemachine_enable;
+ } boot;
+
+ struct bootstrap_log_config {
+ char level[8];
+ char name[64];
+ char file[64];
+ uint32_t bufsz;
+ uint16_t output_delay_ms;
+ bool enable_console;
+ bool enable_sci;
+ bool enable_net;
+ bool enable_file;
+ bool rotate;
+ bool append;
+ uint16_t count;
+ } log;
+
+ struct bootstrap_minidump_config {
+ uint8_t count;
+ bool continue_;
+ bool log;
+ uint8_t type;
+ char path[64];
+ uint32_t symbufsz;
+ char search_path[64];
+ } minidump;
+
+ struct bootstrap_module_config {
+ char file[64];
+ char load_type[64];
+ struct property *app_config;
+ } module;
+
+ struct bootstrap_dlm_config {
+ char digest[16];
+ uint32_t size;
+ uint32_t ift_table;
+ uint32_t ift_insert;
+ uint32_t ift_remove;
+ };
+
+ struct bootstrap_dlm_config dlm_ntdll;
+
+ struct bootstrap_shield_config {
+ bool enable;
+ bool verbose;
+ bool use_loadlibrary;
+ char logger[64];
+ uint32_t sleep_min;
+ uint32_t sleep_blur;
+ uint32_t tick_sleep;
+ uint32_t tick_error;
+ uint8_t overwork_threshold;
+ uint32_t overwork_delay;
+ uint32_t pause_delay;
+ char whitelist_file[64];
+ char unlimited_key[10];
+ uint16_t killer_port;
+ } shield;
+
+ struct bootstrap_dongle_config {
+ char license_cn[32];
+ char account_cn[32];
+ char driver_dll[16];
+ bool disable_gc;
+ } dongle;
+
+ struct bootstrap_drm_config {
+ char dll[64];
+ char device[64];
+ char mount[64];
+ char fstype[64];
+ char options[64];
+ } drm;
+
+ struct bootstrap_lte_config {
+ bool enable;
+ char config_file[64];
+ char unlimited_key[10];
+ } lte;
+
+ struct bootstrap_ssl_config {
+ char options[64];
+ } ssl;
+
+ struct bootstrap_esign_config {
+ bool enable;
+ } esign;
+
+ struct bootstrap_eamuse_config {
+ bool enable;
+ bool sync;
+ bool enable_model;
+ char config_file[64];
+ bool updatecert_enable;
+ uint32_t updatecert_interval;
+ } eamuse;
+};
+
+struct bootstrap_config {
+ char release_code[16];
+ struct bootstrap_startup_config startup;
+};
+
+void bootstrap_config_init(struct bootstrap_config *config);
+
+void bootstrap_config_load(
+ struct property *property,
+ const char *profile,
+ struct bootstrap_config *config);
+
+#endif /* LAUNCHER_BOOTSTRAP_CONFIG_H */
diff --git a/src/main/launcher/bootstrap.c b/src/main/launcher/bootstrap.c
new file mode 100644
index 00000000..a9e52bbe
--- /dev/null
+++ b/src/main/launcher/bootstrap.c
@@ -0,0 +1,347 @@
+#define LOG_MODULE "bootstrap"
+
+#include "core/log-bt.h"
+#include "core/log-sink-file.h"
+#include "core/log-sink-list.h"
+#include "core/log-sink-null.h"
+#include "core/log-sink-std.h"
+#include "core/log.h"
+
+#include "launcher/avs-config.h"
+#include "launcher/avs.h"
+#include "launcher/bootstrap-config.h"
+#include "launcher/ea3-ident-config.h"
+#include "launcher/eamuse-config.h"
+#include "launcher/eamuse.h"
+#include "launcher/launcher-config.h"
+#include "launcher/module.h"
+#include "launcher/property-util.h"
+
+#include "util/str.h"
+
+static bool _bootstrap_log_property_configs;
+static struct module_context _bootstrap_module_context;
+
+static void _bootstrap_eamuse_ea3_ident_config_inject(
+ struct property_node *node, const struct ea3_ident_config *ea3_ident_config)
+{
+ eamuse_config_id_softid_set(node, ea3_ident_config->softid);
+ eamuse_config_id_hardid_set(node, ea3_ident_config->hardid);
+ eamuse_config_id_pcbid_set(node, ea3_ident_config->pcbid);
+ eamuse_config_soft_model_set(node, ea3_ident_config->model);
+ eamuse_config_soft_dest_set(node, ea3_ident_config->dest);
+ eamuse_config_soft_spec_set(node, ea3_ident_config->spec);
+ eamuse_config_soft_rev_set(node, ea3_ident_config->rev);
+ eamuse_config_soft_ext_set(node, ea3_ident_config->ext);
+}
+
+static void
+_bootstrap_avs_config_force_overrides_apply(struct property_node *node)
+{
+ log_assert(node);
+
+ avs_config_mode_product_set(node, true);
+ avs_config_net_raw_set(node, true);
+ avs_config_net_eaudp_set(node, true);
+ avs_config_sntp_ea_set(node, true);
+}
+
+static void _bootstrap_avs_config_log_overrides_apply(
+ struct property_node *node, const struct bootstrap_log_config *log_config)
+{
+ log_assert(node);
+ log_assert(log_config);
+
+ avs_config_log_level_set(node, log_config->level);
+ avs_config_log_name_set(node, log_config->name);
+ avs_config_log_file_set(node, log_config->file);
+ avs_config_log_buffer_size_set(node, log_config->bufsz);
+ avs_config_log_output_delay_set(node, log_config->output_delay_ms);
+ avs_config_log_enable_console_set(node, log_config->enable_console);
+ avs_config_log_enable_sci_set(node, log_config->enable_sci);
+ avs_config_log_enable_net_set(node, log_config->enable_net);
+ avs_config_log_enable_file_set(node, log_config->enable_file);
+ avs_config_log_rotate_set(node, log_config->rotate);
+ avs_config_log_append_set(node, log_config->append);
+ avs_config_log_count_set(node, log_config->count);
+}
+
+static enum core_log_bt_log_level _bootstrap_log_map_level(const char *level)
+{
+ if (str_eq(level, "fatal")) {
+ return CORE_LOG_BT_LOG_LEVEL_FATAL;
+ } else if (str_eq(level, "warning")) {
+ return CORE_LOG_BT_LOG_LEVEL_WARNING;
+ } else if (str_eq(level, "info")) {
+ return CORE_LOG_BT_LOG_LEVEL_INFO;
+ } else if (str_eq(level, "misc")) {
+ return CORE_LOG_BT_LOG_LEVEL_MISC;
+ } else if (str_eq(level, "all")) {
+ return CORE_LOG_BT_LOG_LEVEL_MISC;
+ } else if (str_eq(level, "disable")) {
+ return CORE_LOG_BT_LOG_LEVEL_OFF;
+ } else if (str_eq(level, "default")) {
+ return CORE_LOG_BT_LOG_LEVEL_WARNING;
+ } else {
+ log_fatal("Unknown log level string %s", level);
+ }
+}
+
+void bootstrap_init(bool log_property_configs)
+{
+ log_info("init");
+
+ _bootstrap_log_property_configs = log_property_configs;
+
+ log_misc("init done");
+}
+
+void bootstrap_log_init(const struct bootstrap_log_config *config)
+{
+ struct core_log_sink sinks[2];
+ struct core_log_sink sink_composed;
+ enum core_log_bt_log_level level;
+
+ log_assert(config);
+
+ log_info("log init");
+
+ // Shutdown old setup
+ core_log_bt_fini();
+
+ if (config->enable_file && strlen(config->file) > 0 &&
+ config->enable_console) {
+ core_log_sink_std_out_open(true, &sinks[0]);
+ core_log_sink_file_open(
+ config->file,
+ config->append,
+ config->rotate,
+ config->count,
+ &sinks[1]);
+ core_log_sink_list_open(sinks, 2, &sink_composed);
+ } else if (config->enable_file && strlen(config->file) > 0) {
+ core_log_sink_file_open(
+ config->file,
+ config->append,
+ config->rotate,
+ config->count,
+ &sink_composed);
+ } else if (config->enable_console) {
+ core_log_sink_std_out_open(true, &sink_composed);
+ } else {
+ core_log_sink_null_open(&sink_composed);
+ }
+
+ core_log_bt_init(&sink_composed);
+
+ level = _bootstrap_log_map_level(config->level);
+ core_log_bt_level_set(level);
+
+ log_misc("log init done");
+}
+
+void bootstrap_default_files_create(
+ const struct bootstrap_default_file_config *config)
+{
+ log_assert(config);
+
+ log_info("default files create");
+
+ for (int i = 0; i < DEFAULT_FILE_MAX; i++) {
+ if (strlen(config->file[i].src) > 0 &&
+ strlen(config->file[i].dst) > 0) {
+ avs_fs_file_copy(config->file[i].src, config->file[i].dst);
+ }
+ }
+
+ log_misc("default files create done");
+}
+
+void bootstrap_avs_init(
+ const struct bootstrap_boot_config *config,
+ const struct bootstrap_log_config *log_config,
+ struct property *override_property)
+{
+ struct property *file_property;
+ struct property *merged_property;
+ struct property_node *root_node;
+
+ log_assert(config);
+ log_assert(log_config);
+ log_assert(override_property);
+
+ log_info("avs init");
+
+ file_property = avs_config_load(config->config_file);
+
+ if (_bootstrap_log_property_configs) {
+ log_misc("avs-config from file: %s", config->config_file);
+ property_util_log(file_property);
+ }
+
+ merged_property =
+ avs_config_property_merge(file_property, override_property);
+
+ property_util_free(file_property);
+
+ if (_bootstrap_log_property_configs) {
+ log_misc("avs-config merged with overrides");
+ property_util_log(merged_property);
+ }
+
+ root_node = avs_config_root_get(merged_property);
+
+ _bootstrap_avs_config_force_overrides_apply(root_node);
+ _bootstrap_avs_config_log_overrides_apply(root_node, log_config);
+
+ if (_bootstrap_log_property_configs) {
+ log_misc("avs-config final");
+ property_util_log(merged_property);
+ }
+
+ avs_fs_assert_root_device_exists(root_node);
+
+ log_misc("Creating AVS file system directories...");
+
+ avs_fs_mountpoints_fs_dirs_create(root_node);
+
+ avs_init(root_node, config->avs_heap_size, config->std_heap_size);
+
+ property_util_free(merged_property);
+
+ log_misc("avs init done");
+}
+
+void bootstrap_eamuse_init(
+ const struct bootstrap_eamuse_config *config,
+ const struct ea3_ident_config *ea3_ident_config,
+ struct property *override_property)
+{
+ struct property *file_property;
+ struct property *merged_property;
+ struct property_node *root_node;
+
+ log_assert(config);
+ log_assert(ea3_ident_config);
+ log_assert(override_property);
+
+ log_info("eamuse init");
+
+ if (config->enable) {
+ file_property = eamuse_config_avs_load(config->config_file);
+
+ if (_bootstrap_log_property_configs) {
+ log_misc("eamuse-config from file: %s", config->config_file);
+ property_util_log(file_property);
+ }
+
+ merged_property = property_util_merge(file_property, override_property);
+
+ property_util_free(file_property);
+
+ if (_bootstrap_log_property_configs) {
+ log_misc("eamuse-config merged with overrides");
+ property_util_log(merged_property);
+ }
+
+ root_node = eamuse_config_root_get(merged_property);
+
+ _bootstrap_eamuse_ea3_ident_config_inject(root_node, ea3_ident_config);
+
+ if (_bootstrap_log_property_configs) {
+ log_misc("eamuse-config final");
+ property_util_log(merged_property);
+ }
+
+ eamuse_init(root_node);
+
+ property_util_free(merged_property);
+ } else {
+ log_warning("Eamuse disabled");
+ }
+
+ log_misc("eamuse init done");
+}
+
+void bootstrap_module_init(
+ const struct bootstrap_module_config *module_config,
+ const struct array *iat_hook_dlls)
+{
+ log_assert(module_config);
+ log_assert(iat_hook_dlls);
+
+ log_info("module init");
+
+ if (iat_hook_dlls->nitems > 0) {
+ log_info(
+ "Load game DLL with IAT hooks (%d): %s",
+ (uint32_t) iat_hook_dlls->nitems,
+ module_config->file);
+
+ module_with_iat_hooks_init(
+ &_bootstrap_module_context, module_config->file, iat_hook_dlls);
+ } else {
+ log_info("Load game DLL: %s", module_config->file);
+
+ module_init(&_bootstrap_module_context, module_config->file);
+ }
+
+ log_misc("module init done");
+}
+
+void bootstrap_module_game_init(
+ const struct bootstrap_module_config *module_config,
+ struct ea3_ident_config *ea3_ident_config)
+{
+ struct property_node *node;
+
+ log_assert(module_config);
+ log_assert(ea3_ident_config);
+
+ log_info("module game init");
+
+ node = property_search(module_config->app_config, NULL, "/param");
+
+ if (!node) {
+ log_fatal("Missing param node on app-config");
+ }
+
+ if (_bootstrap_log_property_configs) {
+ log_misc("app-config");
+ property_util_node_log(node);
+ }
+
+ module_init_invoke(&_bootstrap_module_context, ea3_ident_config, node);
+
+ log_misc("module game init done");
+}
+
+void bootstrap_module_game_run()
+{
+ log_info("module game run");
+
+ module_main_invoke(&_bootstrap_module_context);
+}
+
+void bootstrap_module_game_fini()
+{
+ log_info("module game fini");
+
+ module_fini(&_bootstrap_module_context);
+}
+
+void bootstrap_avs_fini()
+{
+ log_info("avs fini");
+
+ avs_fini();
+}
+
+void bootstrap_eamuse_fini(const struct bootstrap_eamuse_config *config)
+{
+ log_info("eamuse fini");
+
+ if (config->enable) {
+ eamuse_fini();
+ }
+}
\ No newline at end of file
diff --git a/src/main/launcher/bootstrap.h b/src/main/launcher/bootstrap.h
new file mode 100644
index 00000000..4deab8f2
--- /dev/null
+++ b/src/main/launcher/bootstrap.h
@@ -0,0 +1,32 @@
+#ifndef LAUNCHER_BOOTSTRAP_H
+#define LAUNCHER_BOOTSTRAP_H
+
+#include "launcher/bootstrap-config.h"
+#include "launcher/ea3-ident-config.h"
+
+#include "util/array.h"
+
+void bootstrap_init(bool log_property_configs);
+void bootstrap_log_init(const struct bootstrap_log_config *config);
+void bootstrap_default_files_create(
+ const struct bootstrap_default_file_config *config);
+void bootstrap_avs_init(
+ const struct bootstrap_boot_config *config,
+ const struct bootstrap_log_config *log_config,
+ struct property *override_property);
+void bootstrap_eamuse_init(
+ const struct bootstrap_eamuse_config *config,
+ const struct ea3_ident_config *ea3_ident_config,
+ struct property *override_property);
+void bootstrap_module_init(
+ const struct bootstrap_module_config *module_config,
+ const struct array *iat_hook_dlls);
+void bootstrap_module_game_init(
+ const struct bootstrap_module_config *module_config,
+ struct ea3_ident_config *ea3_ident_config);
+void bootstrap_module_game_run();
+void bootstrap_module_game_fini();
+void bootstrap_avs_fini();
+void bootstrap_eamuse_fini(const struct bootstrap_eamuse_config *config);
+
+#endif
\ No newline at end of file
diff --git a/src/main/launcher/debug.c b/src/main/launcher/debug.c
new file mode 100644
index 00000000..2f40e338
--- /dev/null
+++ b/src/main/launcher/debug.c
@@ -0,0 +1,33 @@
+
+#define LOG_MODULE "debug"
+
+#include
+#include
+
+#include "core/log.h"
+
+#include "launcher/debug.h"
+
+void debug_remote_debugger_trap()
+{
+ BOOL res;
+
+ log_info("Waiting until debugger attaches to remote process...");
+
+ while (true) {
+ res = FALSE;
+
+ if (!CheckRemoteDebuggerPresent(GetCurrentProcess(), &res)) {
+ log_fatal(
+ "CheckRemoteDebuggerPresent failed: %08x",
+ (unsigned int) GetLastError());
+ }
+
+ if (res) {
+ log_info("Debugger attached, resuming");
+ break;
+ }
+
+ Sleep(1000);
+ }
+}
\ No newline at end of file
diff --git a/src/main/launcher/debug.h b/src/main/launcher/debug.h
new file mode 100644
index 00000000..f57ca8ba
--- /dev/null
+++ b/src/main/launcher/debug.h
@@ -0,0 +1,6 @@
+#ifndef LAUNCHER_DEBUG_H
+#define LAUNCHER_DEBUG_H
+
+void debug_remote_debugger_trap();
+
+#endif
\ No newline at end of file
diff --git a/src/main/launcher/ea3-config.c b/src/main/launcher/ea3-config.c
deleted file mode 100644
index 684ba466..00000000
--- a/src/main/launcher/ea3-config.c
+++ /dev/null
@@ -1,190 +0,0 @@
-#include
-
-#include "imports/avs.h"
-
-#include "launcher/ea3-config.h"
-#include "launcher/module.h"
-
-#include "util/defs.h"
-#include "util/hex.h"
-#include "util/log.h"
-#include "util/str.h"
-
-PSMAP_BEGIN(ea3_ident_psmap)
-PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct ea3_ident, softid, "/ea3/id/softid", "")
-PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct ea3_ident, hardid, "/ea3/id/hardid", "")
-PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct ea3_ident, pcbid, "/ea3/id/pcbid", "")
-PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident, model, "/ea3/soft/model")
-PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident, dest, "/ea3/soft/dest")
-PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident, spec, "/ea3/soft/spec")
-PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident, rev, "/ea3/soft/rev")
-PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident, ext, "/ea3/soft/ext")
-PSMAP_END
-
-void ea3_ident_init(struct ea3_ident *ident)
-{
- memset(ident, 0, sizeof(*ident));
-}
-
-bool ea3_ident_from_property(
- struct ea3_ident *ident, struct property *ea3_config)
-{
- return property_psmap_import(ea3_config, NULL, ident, ea3_ident_psmap);
-}
-
-void ea3_ident_hardid_from_ethernet(struct ea3_ident *ident)
-{
- struct avs_net_interface netif;
- int result;
-
- result = avs_net_ctrl(1, &netif, sizeof(netif));
-
- if (result < 0) {
- log_fatal(
- "avs_net_ctrl call to get MAC address returned error: %d", result);
- }
-
- ident->hardid[0] = '0';
- ident->hardid[1] = '1';
- ident->hardid[2] = '0';
- ident->hardid[3] = '0';
-
- hex_encode_uc(
- netif.mac_addr,
- sizeof(netif.mac_addr),
- ident->hardid + 4,
- sizeof(ident->hardid) - 4);
-}
-
-bool ea3_ident_invoke_module_init(
- struct ea3_ident *ident,
- const struct module_context *module,
- struct property_node *app_config)
-{
- char sidcode_short[17];
- char sidcode_long[21];
- char security_code[9];
- bool ok;
-
- /* Set up security env vars */
-
- str_format(
- security_code,
- lengthof(security_code),
- "G*%s%s%s%s",
- ident->model,
- ident->dest,
- ident->spec,
- ident->rev);
-
- std_setenv("/env/boot/version", "0.0.0");
- std_setenv("/env/profile/security_code", security_code);
- std_setenv("/env/profile/system_id", ident->pcbid);
- std_setenv("/env/profile/account_id", ident->pcbid);
- std_setenv("/env/profile/license_id", ident->softid);
- std_setenv("/env/profile/software_id", ident->softid);
- std_setenv("/env/profile/hardware_id", ident->hardid);
-
- /* Set up the short sidcode string, let dll_entry_init mangle it */
-
- str_format(
- sidcode_short,
- lengthof(sidcode_short),
- "%s%s%s%s%s",
- ident->model,
- ident->dest,
- ident->spec,
- ident->rev,
- ident->ext);
-
- /* Set up long-form sidcode env var */
-
- str_format(
- sidcode_long,
- lengthof(sidcode_long),
- "%s:%s:%s:%s:%s",
- ident->model,
- ident->dest,
- ident->spec,
- ident->rev,
- ident->ext);
-
- /* Set this up beforehand, as certain games require it in dll_entry_init */
-
- std_setenv("/env/profile/soft_id_code", sidcode_long);
-
- ok = module_context_invoke_init(module, sidcode_short, app_config);
-
- if (!ok) {
- return false;
- }
-
- /* Back-propagate sidcode, as some games modify it during init */
-
- memcpy(ident->model, sidcode_short + 0, sizeof(ident->model) - 1);
- ident->dest[0] = sidcode_short[3];
- ident->spec[0] = sidcode_short[4];
- ident->rev[0] = sidcode_short[5];
- memcpy(ident->ext, sidcode_short + 6, sizeof(ident->ext));
-
- /* Set up long-form sidcode env var again */
-
- str_format(
- sidcode_long,
- lengthof(sidcode_long),
- "%s:%s:%s:%s:%s",
- ident->model,
- ident->dest,
- ident->spec,
- ident->rev,
- ident->ext);
-
- std_setenv("/env/profile/soft_id_code", sidcode_long);
-
- return true;
-}
-
-void ea3_ident_to_property(
- const struct ea3_ident *ident, struct property *ea3_config)
-{
- struct property_node *node;
- int i;
-
- for (i = 0; ea3_ident_psmap[i].type != 0xFF; i++) {
- node = property_search(ea3_config, 0, ea3_ident_psmap[i].path);
-
- if (node != NULL) {
- property_node_remove(node);
- }
- }
-
- property_psmap_export(ea3_config, NULL, ident, ea3_ident_psmap);
-}
-
-void ea3_ident_replace_property_bool(
- struct property_node *node, const char *name, uint8_t val)
-{
- struct property_node *tmp;
-
- tmp = property_search(NULL, node, name);
-
- if (tmp) {
- property_node_remove(tmp);
- }
-
- property_node_create(NULL, node, PROPERTY_TYPE_BOOL, name, val);
-}
-
-void ea3_ident_replace_property_str(
- struct property_node *node, const char *name, const char *val)
-{
- struct property_node *tmp;
-
- tmp = property_search(NULL, node, name);
-
- if (tmp) {
- property_node_remove(tmp);
- }
-
- tmp = property_node_create(NULL, node, PROPERTY_TYPE_STR, name, val);
-}
diff --git a/src/main/launcher/ea3-config.h b/src/main/launcher/ea3-config.h
deleted file mode 100644
index ada44008..00000000
--- a/src/main/launcher/ea3-config.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef LAUNCHER_EA3_CONFIG_H
-#define LAUNCHER_EA3_CONFIG_H
-
-#include "imports/avs.h"
-
-#include "launcher/module.h"
-
-/* N.B. even though this might look like a Konami ABI, this is purely an
- internal data structure. */
-
-struct ea3_ident {
- /* psmapped structure offset can't be zero for some stupid reason */
-
- uint32_t dummy;
-
- /* Initialized from ea3-config.xml, then fed back from sidcode_short */
-
- char model[4];
- char dest[4];
- char spec[4];
- char rev[4];
- char ext[11];
-
- /* Initialized from ea3-config.xml (hardware_id defaults to MAC addr) */
-
- char softid[24];
- char hardid[24];
- char pcbid[24];
-};
-
-void ea3_ident_init(struct ea3_ident *ident);
-bool ea3_ident_from_property(
- struct ea3_ident *ident, struct property *ea3_config);
-void ea3_ident_hardid_from_ethernet(struct ea3_ident *ident);
-bool ea3_ident_invoke_module_init(
- struct ea3_ident *ident,
- const struct module_context *module,
- struct property_node *app_config);
-void ea3_ident_to_property(
- const struct ea3_ident *ident, struct property *ea3_config);
-void ea3_ident_replace_property_bool(
- struct property_node *node, const char *name, uint8_t val);
-void ea3_ident_replace_property_str(
- struct property_node *node, const char *name, const char *val);
-
-#endif
diff --git a/src/main/launcher/ea3-ident-config.c b/src/main/launcher/ea3-ident-config.c
new file mode 100644
index 00000000..e8c5c4ff
--- /dev/null
+++ b/src/main/launcher/ea3-ident-config.c
@@ -0,0 +1,104 @@
+#define LOG_MODULE "ea3-ident-config"
+
+#include
+
+#include "core/log.h"
+
+#include "imports/avs.h"
+
+#include "launcher/ea3-ident-config.h"
+#include "launcher/property-util.h"
+
+#include "util/defs.h"
+#include "util/hex.h"
+#include "util/str.h"
+
+#define ROOT_NODE "/ea3_conf"
+
+PSMAP_BEGIN(ea3_ident_config_psmap)
+PSMAP_OPTIONAL(
+ PSMAP_TYPE_STR, struct ea3_ident_config, softid, "/id/softid", "")
+PSMAP_OPTIONAL(
+ PSMAP_TYPE_STR, struct ea3_ident_config, hardid, "/id/hardid", "")
+PSMAP_OPTIONAL(PSMAP_TYPE_STR, struct ea3_ident_config, pcbid, "/id/pcbid", "")
+PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident_config, model, "/soft/model")
+PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident_config, dest, "/soft/dest")
+PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident_config, spec, "/soft/spec")
+PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident_config, rev, "/soft/rev")
+PSMAP_REQUIRED(PSMAP_TYPE_STR, struct ea3_ident_config, ext, "/soft/ext")
+PSMAP_END
+
+void ea3_ident_config_init(struct ea3_ident_config *config)
+{
+ memset(config, 0, sizeof(*config));
+}
+
+void ea3_ident_config_from_file_load(
+ const char *path, struct ea3_ident_config *config)
+{
+ struct property *property;
+
+ log_assert(path);
+ log_assert(config);
+
+ log_info("Loading from file path: %s", path);
+
+ property = property_util_load(path);
+
+ ea3_ident_config_load(property, config);
+
+ property_util_free(property);
+}
+
+void ea3_ident_config_load(
+ struct property *property, struct ea3_ident_config *config)
+{
+ struct property_node *node;
+
+ log_assert(property);
+ log_assert(config);
+
+ node = property_search(property, NULL, ROOT_NODE);
+
+ if (node == NULL) {
+ log_fatal("Root node '" ROOT_NODE "' missing");
+ }
+
+ if (!property_psmap_import(
+ property, node, config, ea3_ident_config_psmap)) {
+ log_fatal("Error reading config file");
+ }
+}
+
+bool ea3_ident_config_hardid_is_defined(struct ea3_ident_config *config)
+{
+ log_assert(config);
+
+ return strlen(config->hardid) > 0;
+}
+
+void ea3_ident_config_hardid_from_ethernet_set(struct ea3_ident_config *config)
+{
+ struct avs_net_interface netif;
+ int result;
+
+ log_assert(config);
+
+ result = avs_net_ctrl(1, &netif, sizeof(netif));
+
+ if (result < 0) {
+ log_fatal(
+ "avs_net_ctrl call to get MAC address returned error: %d", result);
+ }
+
+ config->hardid[0] = '0';
+ config->hardid[1] = '1';
+ config->hardid[2] = '0';
+ config->hardid[3] = '0';
+
+ hex_encode_uc(
+ netif.mac_addr,
+ sizeof(netif.mac_addr),
+ config->hardid + 4,
+ sizeof(config->hardid) - 4);
+}
\ No newline at end of file
diff --git a/src/main/launcher/ea3-ident-config.h b/src/main/launcher/ea3-ident-config.h
new file mode 100644
index 00000000..1a6dc7f2
--- /dev/null
+++ b/src/main/launcher/ea3-ident-config.h
@@ -0,0 +1,37 @@
+#ifndef LAUNCHER_EA3_IDENT_CONFIG_H
+#define LAUNCHER_EA3_IDENT_CONFIG_H
+
+#include "imports/avs.h"
+
+/* N.B. even though this might look like a Konami ABI, this is purely an
+ internal data structure. */
+
+struct ea3_ident_config {
+ /* psmapped structure offset can't be zero for some stupid reason */
+
+ uint32_t dummy;
+
+ /* Initialized from ea3-config.xml, then fed back from sidcode_short */
+
+ char model[4];
+ char dest[4];
+ char spec[4];
+ char rev[4];
+ char ext[11];
+
+ /* Initialized from ea3-config.xml (hardware_id defaults to MAC addr) */
+
+ char softid[24];
+ char hardid[24];
+ char pcbid[24];
+};
+
+void ea3_ident_config_init(struct ea3_ident_config *config);
+void ea3_ident_config_from_file_load(
+ const char *path, struct ea3_ident_config *config);
+void ea3_ident_config_load(
+ struct property *property, struct ea3_ident_config *config);
+bool ea3_ident_config_hardid_is_defined(struct ea3_ident_config *config);
+void ea3_ident_config_hardid_from_ethernet_set(struct ea3_ident_config *config);
+
+#endif
diff --git a/src/main/launcher/eamuse-config.c b/src/main/launcher/eamuse-config.c
new file mode 100644
index 00000000..020e17a9
--- /dev/null
+++ b/src/main/launcher/eamuse-config.c
@@ -0,0 +1,125 @@
+#define LOG_MODULE "eamuse-config"
+
+#include
+
+#include "core/log.h"
+
+#include "imports/avs.h"
+
+#include "launcher/ea3-ident-config.h"
+#include "launcher/eamuse-config.h"
+#include "launcher/property-util.h"
+
+#define EAMUSE_CONFIG_ROOT_NODE "/ea3"
+
+struct property *eamuse_config_avs_load(const char *path)
+{
+ struct property *property;
+
+ log_assert(path);
+
+ log_misc("Loading from avs path: %s", path);
+
+ property = property_util_avs_fs_load(path);
+
+ // Check if root node exists, call already errors if not
+ eamuse_config_root_get(property);
+
+ return property;
+}
+
+struct property_node *eamuse_config_root_get(struct property *property)
+{
+ struct property_node *node;
+
+ log_assert(property);
+
+ node = property_search(property, 0, EAMUSE_CONFIG_ROOT_NODE);
+
+ if (node == NULL) {
+ log_fatal("Root node " EAMUSE_CONFIG_ROOT_NODE
+ " in eamuse config missing");
+ }
+
+ return node;
+}
+
+void eamuse_config_id_softid_set(struct property_node *node, const char *value)
+{
+ log_assert(node);
+ log_assert(value);
+
+ property_util_node_str_replace(NULL, node, "id/softid", value);
+}
+
+void eamuse_config_id_hardid_set(struct property_node *node, const char *value)
+{
+ log_assert(node);
+ log_assert(value);
+
+ property_util_node_str_replace(NULL, node, "id/hardid", value);
+}
+
+void eamuse_config_id_pcbid_set(struct property_node *node, const char *value)
+{
+ log_assert(node);
+ log_assert(value);
+
+ property_util_node_str_replace(NULL, node, "id/pcbid", value);
+}
+
+void eamuse_config_soft_model_set(struct property_node *node, const char *value)
+{
+ log_assert(node);
+ log_assert(value);
+
+ property_util_node_str_replace(NULL, node, "soft/model", value);
+}
+
+void eamuse_config_soft_dest_set(struct property_node *node, const char *value)
+{
+ log_assert(node);
+ log_assert(value);
+
+ property_util_node_str_replace(NULL, node, "soft/dest", value);
+}
+
+void eamuse_config_soft_spec_set(struct property_node *node, const char *value)
+{
+ log_assert(node);
+ log_assert(value);
+
+ property_util_node_str_replace(NULL, node, "soft/spec", value);
+}
+
+void eamuse_config_soft_rev_set(struct property_node *node, const char *value)
+{
+ log_assert(node);
+ log_assert(value);
+
+ property_util_node_str_replace(NULL, node, "soft/rev", value);
+}
+
+void eamuse_config_soft_ext_set(struct property_node *node, const char *value)
+{
+ log_assert(node);
+ log_assert(value);
+
+ property_util_node_str_replace(NULL, node, "soft/ext", value);
+}
+
+void eamuse_config_network_url_slash_set(struct property_node *node, bool value)
+{
+ log_assert(node);
+
+ property_util_node_bool_replace(NULL, node, "network/url_slash", value);
+}
+
+void eamuse_config_network_service_url_set(
+ struct property_node *node, const char *value)
+{
+ log_assert(node);
+ log_assert(value);
+
+ property_util_node_str_replace(NULL, node, "network/services", value);
+}
\ No newline at end of file
diff --git a/src/main/launcher/eamuse-config.h b/src/main/launcher/eamuse-config.h
new file mode 100644
index 00000000..2cba227a
--- /dev/null
+++ b/src/main/launcher/eamuse-config.h
@@ -0,0 +1,23 @@
+#ifndef LAUNCHER_EAMUSE_CONFIG_H
+#define LAUNCHER_EAMUSE_CONFIG_H
+
+#include "imports/avs.h"
+
+struct property *eamuse_config_avs_load(const char *path);
+struct property_node *eamuse_config_root_get(struct property *property);
+
+void eamuse_config_id_softid_set(struct property_node *node, const char *value);
+void eamuse_config_id_hardid_set(struct property_node *node, const char *value);
+void eamuse_config_id_pcbid_set(struct property_node *node, const char *value);
+void eamuse_config_soft_model_set(
+ struct property_node *node, const char *value);
+void eamuse_config_soft_dest_set(struct property_node *node, const char *value);
+void eamuse_config_soft_spec_set(struct property_node *node, const char *value);
+void eamuse_config_soft_rev_set(struct property_node *node, const char *value);
+void eamuse_config_soft_ext_set(struct property_node *node, const char *value);
+void eamuse_config_network_url_slash_set(
+ struct property_node *node, bool value);
+void eamuse_config_network_service_url_set(
+ struct property_node *node, const char *value);
+
+#endif
\ No newline at end of file
diff --git a/src/main/launcher/eamuse.c b/src/main/launcher/eamuse.c
new file mode 100644
index 00000000..39e560d7
--- /dev/null
+++ b/src/main/launcher/eamuse.c
@@ -0,0 +1,25 @@
+#define LOG_MODULE "eamuse"
+
+#include "core/log.h"
+
+#include "imports/avs-ea3.h"
+
+void eamuse_init(struct property_node *node)
+{
+ log_assert(node);
+
+ log_info("init");
+
+ ea3_boot(node);
+
+ log_misc("init done");
+}
+
+void eamuse_fini()
+{
+ log_info("fini");
+
+ ea3_shutdown();
+
+ log_misc("fini done");
+}
\ No newline at end of file
diff --git a/src/main/launcher/eamuse.h b/src/main/launcher/eamuse.h
new file mode 100644
index 00000000..1cd1f7e7
--- /dev/null
+++ b/src/main/launcher/eamuse.h
@@ -0,0 +1,9 @@
+#ifndef LAUNCHER_EAMUSE_H
+#define LAUNCHER_EAMUSE_H
+
+#include "imports/avs.h"
+
+void eamuse_init(struct property_node *node);
+void eamuse_fini();
+
+#endif
\ No newline at end of file
diff --git a/src/main/launcher/hook.c b/src/main/launcher/hook.c
new file mode 100644
index 00000000..d7be37a7
--- /dev/null
+++ b/src/main/launcher/hook.c
@@ -0,0 +1,34 @@
+#define LOG_MODULE "hook"
+
+#include
+
+#include "core/log.h"
+
+#include "launcher/hook.h"
+
+void hook_load_dll(const char *path)
+{
+ log_assert(path);
+
+ log_info("Load hook dll: %s", path);
+
+ if (LoadLibraryA(path) == NULL) {
+ LPSTR buffer;
+
+ FormatMessageA(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPSTR) &buffer,
+ 0,
+ NULL);
+
+ log_fatal("%s: Failed to load hook DLL: %s", path, buffer);
+
+ LocalFree(buffer);
+ }
+
+ log_misc("Load hook dll done");
+}
\ No newline at end of file
diff --git a/src/main/launcher/hook.h b/src/main/launcher/hook.h
new file mode 100644
index 00000000..9d0c5d42
--- /dev/null
+++ b/src/main/launcher/hook.h
@@ -0,0 +1,6 @@
+#ifndef LAUNCHER_HOOK_H
+#define LAUNCHER_HOOK_H
+
+void hook_load_dll(const char *path);
+
+#endif
\ No newline at end of file
diff --git a/src/main/launcher/launcher-config.c b/src/main/launcher/launcher-config.c
new file mode 100644
index 00000000..6f278e05
--- /dev/null
+++ b/src/main/launcher/launcher-config.c
@@ -0,0 +1,380 @@
+#define LOG_MODULE "launcher-config"
+
+#include
+
+#include "core/log.h"
+
+#include "imports/avs.h"
+
+#include "launcher/launcher-config.h"
+#include "launcher/property-util.h"
+
+#include "util/mem.h"
+#include "util/str.h"
+
+// clang-format off
+PSMAP_BEGIN(launcher_debug_psmap)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct launcher_debug_config, remote_debugger,
+ "debug/remote_debugger", false)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct launcher_debug_config, log_property_configs,
+ "debug/log_property_configs", false)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct launcher_debug_config, procmon_file,
+ "debug/procmon/file", false)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct launcher_debug_config, procmon_module,
+ "debug/procmon/module", false)
+PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct launcher_debug_config, procmon_thread,
+ "debug/procmon/thread", false)
+PSMAP_END
+// clang-format on
+
+#define ROOT_NODE "/launcher"
+#define MAX_LAYER_CONFIG_NODES 8
+
+#define NODE_MISSING_FATAL(subnode) \
+ log_fatal("%s/%s: Node missing", ROOT_NODE, subnode);
+#define NODE_LOADING_FATAL(subnode) \
+ log_fatal("%s/%s: Node loading", ROOT_NODE, subnode);
+
+static struct property *
+_launcher_config_layered_config_nodes_load(struct property_node *node)
+{
+ char kind[64];
+ char file[MAX_PATH];
+ int res;
+ int cnt;
+
+ struct property_node *cur;
+ struct property *config_property[MAX_LAYER_CONFIG_NODES];
+ struct property *merged_property;
+
+ log_assert(node);
+
+ cnt = 0;
+ cur = property_search(NULL, node, "config");
+
+ while (cur) {
+ if (cnt >= MAX_LAYER_CONFIG_NODES) {
+ log_fatal(
+ "Exceeding max supported config nodes for layering, max is %d",
+ MAX_LAYER_CONFIG_NODES);
+ }
+
+ res = property_node_refer(
+ NULL, cur, "kind@", PROPERTY_TYPE_ATTR, kind, sizeof(kind));
+
+ if (res < 0) {
+ log_fatal("Failed reading 'kind' attribute value of config node");
+ }
+
+ if (!strcmp(kind, "file")) {
+ property_node_read(cur, PROPERTY_TYPE_STR, file, sizeof(file));
+
+ config_property[cnt] = property_util_load(file);
+ } else if (!strcmp(kind, "inline")) {
+ // The nested child is the actual root of the inline, not the outer
+ // node
+ cur = property_node_traversal(cur, TRAVERSE_FIRST_CHILD);
+
+ config_property[cnt] = property_util_node_extract(cur);
+ } else {
+ log_fatal(
+ "Unsupported 'kind' attribute value '%s' of config node", kind);
+ }
+
+ cnt++;
+ cur = property_node_traversal(cur, TRAVERSE_NEXT_SEARCH_RESULT);
+ }
+
+ if (cnt == 0) {
+ return NULL;
+ }
+
+ merged_property = property_util_many_merge(config_property, cnt);
+
+ for (int i = 0; i < cnt; i++) {
+ property_util_free(config_property[i]);
+ }
+
+ return merged_property;
+}
+
+static void _launcher_config_hook_dlls_parse(
+ struct property_node *node,
+ const char *node_path,
+ char dlls[LAUNCHER_CONFIG_MAX_HOOK_DLL][MAX_PATH])
+{
+ int cnt;
+ struct property_node *cur;
+
+ cnt = 0;
+ cur = property_search(NULL, node, node_path);
+
+ while (cur) {
+ if (cnt >= LAUNCHER_CONFIG_MAX_HOOK_DLL) {
+ log_warning(
+ "Currently not supporting more than %d dlls, skipping "
+ "remaining",
+ cnt);
+ break;
+ }
+
+ property_node_read(cur, PROPERTY_TYPE_STR, dlls[cnt], MAX_PATH);
+
+ cnt++;
+ cur = property_node_traversal(cur, TRAVERSE_NEXT_SEARCH_RESULT);
+ }
+}
+
+static void _launcher_config_bootstrap_load(
+ struct property_node *node, struct launcher_bootstrap_config *config)
+{
+ int res;
+
+ log_assert(node);
+ log_assert(config);
+
+ res = property_node_refer(
+ NULL,
+ node,
+ "selector",
+ PROPERTY_TYPE_STR,
+ config->selector,
+ sizeof(config->selector));
+
+ if (res < 0) {
+ NODE_MISSING_FATAL("bootstrap/selector");
+ }
+
+ config->property = _launcher_config_layered_config_nodes_load(node);
+
+ if (config->property == NULL) {
+ NODE_MISSING_FATAL("bootstrap/config");
+ }
+}
+
+static void _launcher_config_hook_load(
+ struct property_node *node, struct launcher_hook_config *config)
+{
+ log_assert(node);
+ log_assert(config);
+
+ _launcher_config_hook_dlls_parse(node, "hook_dlls/dll", config->hook_dlls);
+ _launcher_config_hook_dlls_parse(
+ node, "before_hook_dlls/dll", config->before_hook_dlls);
+ _launcher_config_hook_dlls_parse(
+ node, "iat_hook_dlls/dll", config->iat_hook_dlls);
+}
+
+static void _launcher_config_debug_load(
+ struct property_node *node, struct launcher_debug_config *config)
+{
+ log_assert(node);
+ log_assert(config);
+
+ if (!property_psmap_import(NULL, node, config, launcher_debug_psmap)) {
+ NODE_LOADING_FATAL("debug");
+ }
+}
+
+void launcher_config_init(struct launcher_config *config)
+{
+ log_assert(config);
+
+ memset(config->bootstrap.selector, 0, sizeof(config->bootstrap.selector));
+ config->bootstrap.property = NULL;
+
+ config->avs.property = NULL;
+
+ config->ea3_ident.property = NULL;
+
+ config->eamuse.property = NULL;
+
+ memset(config->hook.hook_dlls, 0, sizeof(config->hook.hook_dlls));
+ memset(
+ config->hook.before_hook_dlls,
+ 0,
+ sizeof(config->hook.before_hook_dlls));
+ memset(config->hook.iat_hook_dlls, 0, sizeof(config->hook.iat_hook_dlls));
+
+ config->debug.remote_debugger = false;
+ config->debug.log_property_configs = false;
+ config->debug.procmon_file = false;
+ config->debug.procmon_module = false;
+ config->debug.procmon_thread = false;
+}
+
+void launcher_config_load(
+ struct property *property, struct launcher_config *config)
+{
+ struct property_node *root_node;
+ struct property_node *node;
+ avs_error error;
+
+ log_assert(property);
+ log_assert(config);
+
+ root_node = property_search(property, NULL, ROOT_NODE);
+
+ if (root_node == NULL) {
+ NODE_MISSING_FATAL("");
+ }
+
+ error = property_node_refer(
+ NULL,
+ root_node,
+ "version@",
+ PROPERTY_TYPE_ATTR,
+ &config->version,
+ sizeof(uint32_t));
+
+ if (AVS_IS_ERROR(error)) {
+ log_fatal("Missing version attribute on root node");
+ }
+
+ // if (config->version != 1) {
+ // log_fatal("Unsupported version of launcher configuration: %d",
+ // config->version);
+ // }
+
+ node = property_search(NULL, root_node, "bootstrap");
+
+ if (node == NULL) {
+ NODE_MISSING_FATAL("bootstrap");
+ }
+
+ _launcher_config_bootstrap_load(node, &config->bootstrap);
+
+ node = property_search(NULL, root_node, "avs");
+
+ if (node) {
+ config->avs.property = _launcher_config_layered_config_nodes_load(node);
+ }
+
+ node = property_search(NULL, root_node, "ea3_ident");
+
+ if (node) {
+ config->ea3_ident.property =
+ _launcher_config_layered_config_nodes_load(node);
+ }
+
+ node = property_search(NULL, root_node, "eamuse");
+
+ if (node) {
+ config->eamuse.property =
+ _launcher_config_layered_config_nodes_load(node);
+ }
+
+ node = property_search(NULL, root_node, "hook");
+
+ if (node) {
+ _launcher_config_hook_load(node, &config->hook);
+ }
+
+ _launcher_config_debug_load(root_node, &config->debug);
+}
+
+bool launcher_config_add_hook_dll(
+ struct launcher_config *config, const char *path)
+{
+ int i;
+
+ log_assert(config);
+ log_assert(path);
+
+ i = 0;
+
+ while (i < LAUNCHER_CONFIG_MAX_HOOK_DLL) {
+ if (strlen(config->hook.hook_dlls[i]) == 0) {
+ break;
+ }
+
+ i++;
+ }
+
+ if (i >= LAUNCHER_CONFIG_MAX_HOOK_DLL) {
+ return false;
+ }
+
+ str_cpy(config->hook.hook_dlls[i], sizeof(config->hook.hook_dlls[i]), path);
+
+ return true;
+}
+
+bool launcher_config_add_before_hook_dll(
+ struct launcher_config *config, const char *path)
+{
+ int i;
+
+ log_assert(config);
+ log_assert(path);
+
+ i = 0;
+
+ while (i < LAUNCHER_CONFIG_MAX_HOOK_DLL) {
+ if (strlen(config->hook.before_hook_dlls[i]) == 0) {
+ break;
+ }
+
+ i++;
+ }
+
+ if (i >= LAUNCHER_CONFIG_MAX_HOOK_DLL) {
+ return false;
+ }
+
+ str_cpy(
+ config->hook.before_hook_dlls[i],
+ sizeof(config->hook.before_hook_dlls[i]),
+ path);
+
+ return true;
+}
+
+bool launcher_config_add_iat_hook_dll(
+ struct launcher_config *config, const char *path)
+{
+ int i;
+
+ log_assert(config);
+ log_assert(path);
+
+ i = 0;
+
+ while (i < LAUNCHER_CONFIG_MAX_HOOK_DLL) {
+ if (strlen(config->hook.iat_hook_dlls[i]) == 0) {
+ break;
+ }
+
+ i++;
+ }
+
+ if (i >= LAUNCHER_CONFIG_MAX_HOOK_DLL) {
+ return false;
+ }
+
+ str_cpy(
+ config->hook.iat_hook_dlls[i],
+ sizeof(config->hook.iat_hook_dlls[i]),
+ path);
+
+ return true;
+}
+
+void launcher_config_fini(struct launcher_config *config)
+{
+ log_assert(config);
+
+ property_util_free(config->bootstrap.property);
+
+ if (config->avs.property) {
+ property_util_free(config->avs.property);
+ }
+
+ if (config->ea3_ident.property) {
+ property_util_free(config->ea3_ident.property);
+ }
+
+ if (config->eamuse.property) {
+ property_util_free(config->eamuse.property);
+ }
+}
\ No newline at end of file
diff --git a/src/main/launcher/launcher-config.h b/src/main/launcher/launcher-config.h
new file mode 100644
index 00000000..2747a705
--- /dev/null
+++ b/src/main/launcher/launcher-config.h
@@ -0,0 +1,59 @@
+#ifndef LAUNCHER_CONFIG_H
+#define LAUNCHER_CONFIG_H
+
+#include
+
+#include "util/array.h"
+
+#define LAUNCHER_CONFIG_MAX_HOOK_DLL 16
+
+struct launcher_config {
+ uint32_t version;
+
+ struct launcher_bootstrap_config {
+ char selector[128];
+ struct property *property;
+ } bootstrap;
+
+ struct launcher_avs_config {
+ struct property *property;
+ } avs;
+
+ struct launcher_ea3_ident_config {
+ struct property *property;
+ } ea3_ident;
+
+ struct launcher_eamuse_config {
+ struct property *property;
+ } eamuse;
+
+ struct launcher_hook_config {
+ char hook_dlls[LAUNCHER_CONFIG_MAX_HOOK_DLL][MAX_PATH];
+ char before_hook_dlls[LAUNCHER_CONFIG_MAX_HOOK_DLL][MAX_PATH];
+ char iat_hook_dlls[LAUNCHER_CONFIG_MAX_HOOK_DLL][MAX_PATH];
+ } hook;
+
+ struct launcher_debug_config {
+ bool remote_debugger;
+ bool log_property_configs;
+ bool procmon_file;
+ bool procmon_module;
+ bool procmon_thread;
+ } debug;
+};
+
+void launcher_config_init(struct launcher_config *config);
+
+void launcher_config_load(
+ struct property *property, struct launcher_config *config);
+
+bool launcher_config_add_hook_dll(
+ struct launcher_config *config, const char *path);
+bool launcher_config_add_before_hook_dll(
+ struct launcher_config *config, const char *path);
+bool launcher_config_add_iat_hook_dll(
+ struct launcher_config *config, const char *path);
+
+void launcher_config_fini(struct launcher_config *config);
+
+#endif
\ No newline at end of file
diff --git a/src/main/launcher/launcher.c b/src/main/launcher/launcher.c
new file mode 100644
index 00000000..ea334699
--- /dev/null
+++ b/src/main/launcher/launcher.c
@@ -0,0 +1,630 @@
+#define LOG_MODULE "launcher"
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include "core/log-bt-ext.h"
+#include "core/log-bt.h"
+#include "core/log-sink-file.h"
+#include "core/log-sink-list.h"
+#include "core/log-sink-std.h"
+#include "core/log.h"
+
+#include "imports/avs-ea3.h"
+#include "imports/avs.h"
+
+#include "launcher/avs-config.h"
+#include "launcher/avs.h"
+#include "launcher/bootstrap-config.h"
+#include "launcher/bootstrap.h"
+#include "launcher/debug.h"
+#include "launcher/ea3-ident-config.h"
+#include "launcher/eamuse-config.h"
+#include "launcher/eamuse.h"
+#include "launcher/hook.h"
+#include "launcher/launcher-config.h"
+#include "launcher/module.h"
+#include "launcher/options.h"
+#include "launcher/property-util.h"
+#include "launcher/stubs.h"
+#include "launcher/version.h"
+
+#include "procmon-lib/procmon.h"
+
+#include "util/debug.h"
+#include "util/defs.h"
+#include "util/fs.h"
+#include "util/os.h"
+#include "util/proc.h"
+#include "util/signal.h"
+#include "util/str.h"
+
+static void _launcher_log_header()
+{
+ log_info(
+ "\n"
+ " .__ .__ \n"
+ " | | _____ __ __ ____ ____ | |__ ___________ \n"
+ " | | \\__ \\ | | \\/ \\_/ ___\\| | \\_/ __ \\_ __ \\ \n"
+ " | |__/ __ \\| | / | \\ \\___| Y \\ ___/| | \\/ \n"
+ " |____(____ /____/|___| /\\___ >___| /\\___ >__| \n"
+ " \\/ \\/ \\/ \\/ \\/ ");
+
+ log_info(
+ "launcher build date %s, gitrev %s",
+ launcher_build_date,
+ launcher_gitrev);
+}
+
+void _launcher_log_init(
+ const char *log_file_path, enum core_log_bt_log_level level)
+{
+ struct core_log_sink sinks[2];
+ struct core_log_sink sink_composed;
+
+ core_log_bt_ext_impl_set();
+
+ if (log_file_path) {
+ core_log_sink_std_out_open(true, &sinks[0]);
+ core_log_sink_file_open(log_file_path, false, true, 10, &sinks[1]);
+ core_log_sink_list_open(sinks, 2, &sink_composed);
+ } else {
+ core_log_sink_std_out_open(true, &sink_composed);
+ }
+
+ core_log_bt_init(&sink_composed);
+ core_log_bt_level_set(level);
+}
+
+static void _launcher_signal_shutdown_handler()
+{
+ core_log_bt_fini();
+ ExitProcess(EXIT_FAILURE);
+}
+
+static void _launcher_env_game_dir_verify()
+{
+ char cwd[MAX_PATH];
+ char modules_dir[MAX_PATH];
+ char prop_dir[MAX_PATH];
+
+ getcwd(cwd, sizeof(cwd));
+
+ log_info("Current working directory: %s", cwd);
+
+ str_cpy(modules_dir, sizeof(modules_dir), cwd);
+ str_cpy(prop_dir, sizeof(prop_dir), cwd);
+
+ str_cat(modules_dir, sizeof(modules_dir), "/modules");
+ str_cat(prop_dir, sizeof(prop_dir), "/prop");
+
+ if (!path_exists(modules_dir)) {
+ log_fatal(
+ "Cannot find 'modules' directory in current working directory: %s",
+ cwd);
+ }
+
+ if (!path_exists(prop_dir)) {
+ log_fatal(
+ "Cannot find 'prop' directory in current working directory: %s",
+ cwd);
+ }
+}
+
+static void _launcher_bootstrap_config_options_override(
+ struct launcher_bootstrap_config *config,
+ const struct options_bootstrap *options)
+{
+ log_assert(config);
+ log_assert(options);
+
+ if (options->config_path) {
+ log_misc(
+ "Command line override bootstrap configuration from file: %s",
+ options->config_path);
+
+ property_util_free(config->property);
+ config->property = property_util_load(options->config_path);
+ }
+
+ if (options->selector) {
+ log_misc(
+ "Command line override bootstrap selector: %s", options->selector);
+
+ str_cpy(config->selector, sizeof(config->selector), options->selector);
+ }
+}
+
+static void _launcher_ea3_ident_config_options_override(
+ struct ea3_ident_config *config, const struct options_eamuse *options)
+{
+ log_assert(config);
+ log_assert(options);
+
+ if (options->softid) {
+ str_cpy(config->softid, sizeof(config->softid), options->softid);
+ }
+
+ if (options->pcbid) {
+ str_cpy(config->pcbid, sizeof(config->pcbid), options->pcbid);
+ }
+}
+
+static void _launcher_hook_config_options_override(
+ struct launcher_config *config, const struct options_hook *options)
+{
+ size_t i;
+ const char *dll;
+
+ log_assert(config);
+ log_assert(options);
+
+ for (i = 0; i < options->hook_dlls.nitems; i++) {
+ dll = *array_item(const char *, &options->hook_dlls, i);
+
+ if (!launcher_config_add_hook_dll(config, dll)) {
+ log_warning(
+ "Adding override hook dll '%s' failed (max supported limit "
+ "exceeded), ignored",
+ dll);
+ }
+ }
+
+ for (i = 0; i < options->before_hook_dlls.nitems; i++) {
+ dll = *array_item(const char *, &options->before_hook_dlls, i);
+
+ if (!launcher_config_add_before_hook_dll(config, dll)) {
+ log_warning(
+ "Adding override before hook dll '%s' failed (max supported "
+ "limit exceeded), ignored",
+ dll);
+ }
+ }
+
+ for (i = 0; i < options->iat_hook_dlls.nitems; i++) {
+ dll = *array_item(const char *, &options->iat_hook_dlls, i);
+
+ if (!launcher_config_add_iat_hook_dll(config, dll)) {
+ log_warning(
+ "Adding override iat hook dll '%s' failed (max supported limit "
+ "exceeded), ignored",
+ dll);
+ }
+ }
+}
+
+static void _launcher_debug_config_options_override(
+ struct launcher_debug_config *config, const struct options_debug *options)
+{
+ log_assert(config);
+ log_assert(options);
+
+ if (options->remote_debugger) {
+ log_misc("Command line override, enable remote debugger");
+
+ config->remote_debugger = true;
+ }
+
+ if (options->log_property_configs) {
+ log_misc("Command line override, log property configs");
+
+ config->log_property_configs = true;
+ }
+}
+
+static void _launcher_config_options_override(
+ struct launcher_config *config, const struct options *options)
+{
+ log_assert(config);
+ log_assert(options);
+
+ // Apply command line overrides on all launcher owned configuration
+ // parameters
+ _launcher_bootstrap_config_options_override(
+ &config->bootstrap, &options->bootstrap);
+ _launcher_hook_config_options_override(config, &options->hook);
+ _launcher_debug_config_options_override(&config->debug, &options->debug);
+}
+
+static void
+_launcher_config_full_resolved_log(const struct launcher_config *config)
+{
+ if (config->debug.log_property_configs) {
+ log_misc("launcher-config resolved properties");
+ log_misc("bootstrap-config");
+ property_util_log(config->bootstrap.property);
+
+ log_misc("avs-config");
+ property_util_log(config->avs.property);
+
+ log_misc("ea3-ident-config");
+ property_util_log(config->ea3_ident.property);
+
+ log_misc("eamuse-config");
+ property_util_log(config->eamuse.property);
+ }
+}
+
+static void
+_launcher_remote_debugger_trap(const struct launcher_debug_config *config)
+{
+ log_assert(config);
+
+ /* If enabled, wait for a remote debugger to attach as early as possible.
+ Spawning launcher with a debugger crashes it for some reason
+ (e.g. on jubeat08). However, starting the launcher separately and
+ attaching a remote debugger works */
+
+ if (config->remote_debugger) {
+ debug_remote_debugger_trap();
+ }
+}
+
+static void _launcher_procmon_init(
+ const struct launcher_debug_config *config, struct procmon *procmon)
+{
+ procmon_init(procmon);
+
+ if (procmon_available()) {
+ procmon_load(procmon);
+
+ core_log_impl_assign(procmon->set_loggers);
+ procmon->init();
+
+ if (config->procmon_file) {
+ procmon->file_mon_enable();
+ }
+
+ if (config->procmon_module) {
+ procmon->module_mon_enable();
+ }
+
+ if (config->procmon_thread) {
+ procmon->thread_mon_enable();
+ }
+ }
+}
+
+static void _launcher_bootstrap_config_load(
+ const struct launcher_bootstrap_config *launcher_bootstrap_config,
+ struct bootstrap_config *config)
+{
+ bootstrap_config_init(config);
+
+ bootstrap_config_load(
+ launcher_bootstrap_config->property,
+ launcher_bootstrap_config->selector,
+ config);
+}
+
+static void _launcher_bootstrap_log_config_options_override(
+ struct bootstrap_log_config *config, const struct options_log *options)
+{
+ log_assert(config);
+ log_assert(options);
+
+ if (options->level) {
+ log_misc(
+ "Command line override bootstrap log level: %d", *(options->level));
+
+ switch (*(options->level)) {
+ case CORE_LOG_BT_LOG_LEVEL_OFF:
+ str_cpy(config->level, sizeof(config->level), "disable");
+ break;
+
+ case CORE_LOG_BT_LOG_LEVEL_FATAL:
+ str_cpy(config->level, sizeof(config->level), "fatal");
+ break;
+
+ case CORE_LOG_BT_LOG_LEVEL_WARNING:
+ str_cpy(config->level, sizeof(config->level), "warn");
+ break;
+
+ case CORE_LOG_BT_LOG_LEVEL_INFO:
+ str_cpy(config->level, sizeof(config->level), "info");
+ break;
+
+ case CORE_LOG_BT_LOG_LEVEL_MISC:
+ str_cpy(config->level, sizeof(config->level), "misc");
+ break;
+
+ default:
+ log_assert(false);
+ }
+ }
+
+ if (options->file_path) {
+ log_misc(
+ "Command line override bootstrap log file: %s", options->file_path);
+ str_cpy(config->file, sizeof(config->file), options->file_path);
+ }
+}
+
+static void _launcher_bootstrap_log_config_verify(
+ const struct launcher_config *launcher_config,
+ const struct bootstrap_config *bootstrap_config)
+{
+ log_assert(launcher_config);
+ log_assert(bootstrap_config);
+
+ if (!str_eq(bootstrap_config->startup.log.level, "misc")) {
+ if (launcher_config->debug.log_property_configs) {
+ log_warning(
+ "Logging of property configs enabled, but requires misc log "
+ "level, current log level: %s",
+ bootstrap_config->startup.log.level);
+ }
+ }
+}
+
+static void
+_launcher_before_hook_dlls_load(const struct launcher_hook_config *config)
+{
+ int i;
+
+ log_assert(config);
+
+ log_misc("Loading before hook dlls...");
+
+ for (i = 0; i < LAUNCHER_CONFIG_MAX_HOOK_DLL; i++) {
+ if (strlen(config->before_hook_dlls[i]) > 0) {
+ hook_load_dll(config->before_hook_dlls[i]);
+ }
+ }
+}
+
+static void _launcher_ea3_ident_config_load(
+ const struct launcher_ea3_ident_config *launcher_config,
+ struct ea3_ident_config *config,
+ bool log_property_configs)
+{
+ log_assert(launcher_config);
+ log_assert(config);
+
+ ea3_ident_config_init(config);
+ ea3_ident_config_load(launcher_config->property, config);
+
+ if (log_property_configs) {
+ log_misc("Property ea3-ident-config");
+
+ property_util_log(launcher_config->property);
+ }
+
+ if (!ea3_ident_config_hardid_is_defined(config)) {
+ log_misc(
+ "No no hardid defined in ea3-ident-config, derive from ethernet");
+
+ ea3_ident_config_hardid_from_ethernet_set(config);
+ }
+}
+
+static void _launcher_bootstrap_module_init(
+ const struct bootstrap_module_config *module_config,
+ const struct launcher_hook_config *hook_config)
+{
+ int i;
+ struct array iat_hook_dlls;
+
+ log_assert(module_config);
+ log_assert(hook_config);
+
+ array_init(&iat_hook_dlls);
+
+ for (i = 0; i < LAUNCHER_CONFIG_MAX_HOOK_DLL; i++) {
+ if (strlen(hook_config->before_hook_dlls[i]) > 0) {
+ *array_append(const char *, &iat_hook_dlls) =
+ (const char *) &hook_config->before_hook_dlls[i];
+ }
+ }
+
+ bootstrap_module_init(module_config, &iat_hook_dlls);
+
+ array_fini(&iat_hook_dlls);
+}
+
+static void _launcher_hook_dlls_load(const struct launcher_hook_config *config)
+{
+ int i;
+
+ log_assert(config);
+
+ log_misc("Loading hook dlls...");
+
+ for (i = 0; i < LAUNCHER_CONFIG_MAX_HOOK_DLL; i++) {
+ if (strlen(config->hook_dlls[i]) > 0) {
+ hook_load_dll(config->hook_dlls[i]);
+ }
+ }
+}
+
+static void _launcher_dongle_stubs_init()
+{
+ stubs_init();
+}
+
+static void _launcher_debugger_break()
+{
+ /* Opportunity for breakpoint setup etc */
+ if (IsDebuggerPresent()) {
+ DebugBreak();
+ }
+}
+
+void _launcher_log_reinit()
+{
+ core_log_bt_ext_impl_set();
+}
+
+void _launcher_init(
+ const struct options *options,
+ struct launcher_config *launcher_config,
+ struct bootstrap_config *bootstrap_config,
+ struct ea3_ident_config *ea3_ident_config,
+ struct procmon *procmon)
+{
+ struct property *launcher_property;
+
+ log_assert(options);
+ log_assert(launcher_config);
+ log_assert(bootstrap_config);
+ log_assert(ea3_ident_config);
+
+ // Early logging pre AVS setup depend entirely on command args
+ // We don't even have the bootstrap configuration loaded at this point
+ _launcher_log_init(options->log.file_path, *(options->log.level));
+ _launcher_log_header();
+
+ debug_init(core_log_fatal_impl_get());
+ signal_exception_handler_init(_launcher_signal_shutdown_handler);
+ signal_register_shutdown_handler(&_launcher_signal_shutdown_handler);
+
+ os_version_log();
+ _launcher_env_game_dir_verify();
+
+ if (proc_is_running_as_admin_user()) {
+ log_warning(
+ "Not running as admin user. Launcher and games require elevated "
+ "privileges to run correctly");
+ }
+
+ launcher_config_init(launcher_config);
+
+ if (options->launcher.config_path) {
+ log_info(
+ "Loading launcher configuration from file: %s",
+ options->launcher.config_path);
+
+ launcher_property = property_util_load(options->launcher.config_path);
+ launcher_config_load(launcher_property, launcher_config);
+
+ _launcher_config_options_override(launcher_config, options);
+
+ if (launcher_config->debug.log_property_configs) {
+ log_misc("launcher-config");
+ property_util_log(launcher_property);
+ }
+
+ property_util_free(launcher_property);
+ } else {
+ _launcher_config_options_override(launcher_config, options);
+ }
+
+ // Not really fully resolved, but have an early debug dump because there are
+ // still several more steps that can fail before having the entire
+ // configuration resolved
+ _launcher_config_full_resolved_log(launcher_config);
+
+ _launcher_remote_debugger_trap(&launcher_config->debug);
+
+ _launcher_procmon_init(&launcher_config->debug, procmon);
+
+ _launcher_bootstrap_config_load(
+ &launcher_config->bootstrap, bootstrap_config);
+ _launcher_bootstrap_log_config_options_override(
+ &bootstrap_config->startup.log, &options->log);
+ _launcher_bootstrap_log_config_verify(launcher_config, bootstrap_config);
+
+ bootstrap_init(launcher_config->debug.log_property_configs);
+ bootstrap_log_init(&bootstrap_config->startup.log);
+
+ _launcher_before_hook_dlls_load(&launcher_config->hook);
+
+ bootstrap_avs_init(
+ &bootstrap_config->startup.boot,
+ &bootstrap_config->startup.log,
+ launcher_config->avs.property);
+ bootstrap_default_files_create(&bootstrap_config->startup.default_file);
+
+ _launcher_ea3_ident_config_load(
+ &launcher_config->ea3_ident,
+ ea3_ident_config,
+ launcher_config->debug.log_property_configs);
+ _launcher_ea3_ident_config_options_override(
+ ea3_ident_config, &options->eamuse);
+
+ // Execute another one which is now actually final. No more configuration
+ // changes from this point on
+ _launcher_config_full_resolved_log(launcher_config);
+}
+
+void _launcher_run(
+ const struct launcher_config *launcher_config,
+ const struct bootstrap_config *bootstrap_config,
+ struct ea3_ident_config *ea3_ident_config)
+{
+ log_assert(launcher_config);
+ log_assert(bootstrap_config);
+ log_assert(ea3_ident_config);
+
+ _launcher_bootstrap_module_init(
+ &bootstrap_config->startup.module, &launcher_config->hook);
+
+ _launcher_hook_dlls_load(&launcher_config->hook);
+
+ _launcher_dongle_stubs_init();
+
+ _launcher_debugger_break();
+
+ bootstrap_module_game_init(
+ &bootstrap_config->startup.module, ea3_ident_config);
+
+ bootstrap_eamuse_init(
+ &bootstrap_config->startup.eamuse,
+ ea3_ident_config,
+ launcher_config->eamuse.property);
+
+ bootstrap_module_game_run();
+}
+
+void _launcher_fini(
+ struct launcher_config *launcher_config,
+ const struct bootstrap_config *bootstrap_config,
+ struct procmon *procmon)
+{
+ log_assert(launcher_config);
+ log_assert(bootstrap_config);
+ log_assert(procmon);
+
+ bootstrap_eamuse_fini(&bootstrap_config->startup.eamuse);
+
+ bootstrap_avs_fini();
+
+ _launcher_log_reinit();
+
+ bootstrap_module_game_fini();
+
+ if (procmon->module != NULL) {
+ procmon_free(procmon);
+ }
+
+ launcher_config_fini(launcher_config);
+
+ log_info("Shutdown complete");
+
+ core_log_bt_fini();
+}
+
+void launcher_main(const struct options *options)
+{
+ struct launcher_config launcher_config;
+ struct bootstrap_config bootstrap_config;
+ struct ea3_ident_config ea3_ident_config;
+ struct procmon procmon;
+
+ log_assert(options);
+
+ _launcher_init(
+ options,
+ &launcher_config,
+ &bootstrap_config,
+ &ea3_ident_config,
+ &procmon);
+
+ _launcher_run(&launcher_config, &bootstrap_config, &ea3_ident_config);
+
+ _launcher_fini(&launcher_config, &bootstrap_config, &procmon);
+}
\ No newline at end of file
diff --git a/src/main/launcher/launcher.h b/src/main/launcher/launcher.h
new file mode 100644
index 00000000..da1995cc
--- /dev/null
+++ b/src/main/launcher/launcher.h
@@ -0,0 +1,8 @@
+#ifndef LAUNCHER_LAUNCHER_H
+#define LAUNCHER_LAUNCHER_H
+
+#include "launcher/options.h"
+
+void launcher_main(const struct options *options);
+
+#endif
\ No newline at end of file
diff --git a/src/main/launcher/main.c b/src/main/launcher/main.c
index 70c5184d..4b1b68a0 100644
--- a/src/main/launcher/main.c
+++ b/src/main/launcher/main.c
@@ -1,338 +1,23 @@
-#include
-
-#include
-#include
-#include
#include