Publish precompiled tp6.c blob (lots of dirty hacks)

This commit is contained in:
mkrsym1 2023-07-05 23:59:27 +03:00
parent 94efee7496
commit df1f611199
6 changed files with 102 additions and 42 deletions

View File

@ -1,12 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
if ! [ "x$1" = "xdo" ]; then
echo "A part of the source code is witheld (game_payload/src/tp6.c) to make abuse more difficult. Please download a binary release"
exit
fi
shift
strip="x86_64-w64-mingw32-strip" strip="x86_64-w64-mingw32-strip"
rm -f jadeite.zip rm -f jadeite.zip

BIN
game_payload/blob/tp6c.obj Normal file

Binary file not shown.

View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
cp "$1" "$2"
cp "$1" "$3"

View File

@ -1,3 +1,7 @@
fs = import('fs')
include_dir = include_directories('include')
# Input files # Input files
sources = [ sources = [
'src/main.c', 'src/main.c',
@ -8,10 +12,7 @@ sources = [
'src/hi3.c', 'src/hi3.c',
'src/hsr.c', 'src/hsr.c',
'src/utils.c', 'src/utils.c',
'src/msg.c', 'src/msg.c'
# File withheld to make abuse more difficult
'src/tp6.c'
] ]
resources = [ resources = [
'res/hi3/glb/allocations.dat', 'res/hi3/glb/allocations.dat',
@ -24,17 +25,53 @@ resources = [
] ]
# Generate resource files for ./res # Generate resource files for ./res
res_files = custom_target( res_header = custom_target(
'resources.[ho]', 'resources.h',
output: [ 'resources.o', 'resources.h' ], output: 'resources.h',
input: resources, input: resources,
command: [ gen_res, meson.current_source_dir(), '@OUTPUT0@', '@OUTPUT1@', '@INPUT@' ] command: [ gen_res, '--header', meson.current_source_dir(), '@OUTPUT0@', '@INPUT@' ]
) )
res_object = custom_target(
'resources.o',
output: 'resources.o',
input: resources,
command: [ gen_res, '--object', meson.current_source_dir(), '@OUTPUT0@', '@INPUT@' ]
)
if fs.exists('src/tp6.c')
# Compile the real file first (dirty hack)
tp6c_fake_exe = executable(
'tp6c.obj',
'src/tp6.c',
res_header,
link_args: [ '-r' ], # Output an object file
include_directories: include_dir
)
# another dirty hack
copy_tp6c = find_program('copy_tp6c.sh')
tp6c = custom_target(
'copy_tp6c',
output: 'tp6c.obj',
input: tp6c_fake_exe.extract_all_objects(recursive: false),
command: [
copy_tp6c,
'@INPUT0@',
'@OUTPUT0@', meson.current_source_dir() / 'blob/tp6c.obj'
]
)
else
message('Using precompiled tp6c blob. Refer to the readme for more details')
tp6c = 'blob/tp6c.obj'
endif
shared_library( shared_library(
'game_payload', 'game_payload',
sources, sources,
res_files, tp6c,
include_directories: 'include', res_header,
res_object,
include_directories: include_dir,
name_prefix: '' name_prefix: ''
) )

View File

@ -1,20 +1,41 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# I hate this.
linker="x86_64-w64-mingw32-ld" linker="x86_64-w64-mingw32-ld"
# Output config (terrible)
if [ "x$1" = "x--header" ]; then
gen_header=1
shift
fi
if [ "x$1" = "x--object" ]; then
gen_object=1
shift
fi
# Read project directory # Read project directory
proj_dir=`realpath "$1"` proj_dir=`realpath "$1"`
shift shift
# Read output file destinations # Read output file destinations
resources_o=`realpath "$1"` if [ "x${gen_object}" = "x1" ]; then
shift resources_o=`realpath "$1"`
resources_h=`realpath "$1"` shift
shift fi
if [ "x${gen_header}" = "x1" ]; then
resources_h=`realpath "$1"`
shift
fi
# Make sure that the header does not exist # Make sure that output files do not exist
rm -f "${resources_h}" if [ "x${gen_header}" = "x1" ]; then
rm -f "${resources_o}" rm -f "${resources_h}"
fi
if [ "x${gen_object}" = "x1" ]; then
rm -f "${resources_o}"
fi
# Recomupte relative paths to parameters # Recomupte relative paths to parameters
idx=0 idx=0
@ -26,16 +47,19 @@ do
idx="$(("${idx}" + 1))" idx="$(("${idx}" + 1))"
done done
# Create the object file if [ "x${gen_object}" = "x1" ]; then
pushd "${proj_dir}" >> /dev/null # Create the object file
$linker -r -b binary -o "${resources_o}" "${resource_files[@]}" pushd "${proj_dir}" >> /dev/null
popd >> /dev/null $linker -r -b binary -o "${resources_o}" "${resource_files[@]}"
popd >> /dev/null
fi
# Include stddef.h in the resources header (for size_t) if [ "x${gen_header}" = "x1" ]; then
echo "#include <stddef.h>" >> "${resources_h}" # Include stddef.h in the resources header (for size_t)
echo "#include <stddef.h>" >> "${resources_h}"
for resource in "${resource_files[@]}" for resource in "${resource_files[@]}"
do do
# Use relative path to the resource as the variable name # Use relative path to the resource as the variable name
var_name="_binary_${resource}" var_name="_binary_${resource}"
@ -46,4 +70,5 @@ do
echo "extern void *${var_name}_start;" >> "${resources_h}" echo "extern void *${var_name}_start;" >> "${resources_h}"
echo "extern void *${var_name}_size;" >> "${resources_h}" echo "extern void *${var_name}_size;" >> "${resources_h}"
echo "" >> "${resources_h}" echo "" >> "${resources_h}"
done done
fi

View File

@ -17,14 +17,14 @@ exe_res_files = custom_target(
'launcher_p.[oh]', 'launcher_p.[oh]',
output: [ 'launcher_p.o', 'launcher_p.h' ], output: [ 'launcher_p.o', 'launcher_p.h' ],
input: [ launcher_payload_bin ], input: [ launcher_payload_bin ],
command: [ gen_res, './injector', '@OUTPUT0@', '@OUTPUT1@', '@INPUT@' ] command: [ gen_res, '--header', '--object', './injector', '@OUTPUT0@', '@OUTPUT1@', '@INPUT@' ]
) )
dll_res_files = custom_target( dll_res_files = custom_target(
'game_p.[oh]', 'game_p.[oh]',
output: [ 'game_p.o', 'game_p.h' ], output: [ 'game_p.o', 'game_p.h' ],
input: [ game_payload_bin ], input: [ game_payload_bin ],
command: [ gen_res, './injector', '@OUTPUT0@', '@OUTPUT1@', '@INPUT@' ] command: [ gen_res, '--header', '--object', './injector', '@OUTPUT0@', '@OUTPUT1@', '@INPUT@' ]
) )
# Main injector exe # Main injector exe