├── .editorconfig
├── .github
└── workflows
│ └── build-and-package.yml
├── .gitignore
├── .gitmodules
├── .idea
├── .gitignore
├── KoalaBox.iml
├── cmake.xml
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── misc.xml
├── modules.xml
└── vcs.xml
├── CMakeLists.txt
├── LICENSE.txt
├── README.adoc
├── UNLICENSE.txt
├── build.ps1
├── cmake
└── KoalaBox.cmake
├── include
└── koalabox
│ ├── cache.hpp
│ ├── config.hpp
│ ├── core.hpp
│ ├── crypto.hpp
│ ├── dll_monitor.hpp
│ ├── globals.hpp
│ ├── hook.hpp
│ ├── http_client.hpp
│ ├── io.hpp
│ ├── ipc.hpp
│ ├── loader.hpp
│ ├── logger.hpp
│ ├── patcher.hpp
│ ├── paths.hpp
│ ├── pch.hpp
│ ├── util.hpp
│ └── win_util.hpp
├── res
├── build_config.gen.h
└── version.gen.rc
└── src
├── exports_generator
└── exports_generator.cpp
└── koalabox
├── cache.cpp
├── core.cpp
├── crypto.cpp
├── dll_monitor.cpp
├── globals.cpp
├── hook.cpp
├── http_client.cpp
├── io.cpp
├── ipc.cpp
├── loader.cpp
├── logger.cpp
├── ntapi.hpp
├── patcher.cpp
├── paths.cpp
├── util.cpp
└── win_util.cpp
/.editorconfig:
--------------------------------------------------------------------------------
1 | [*]
2 | charset = utf-8
3 | end_of_line = crlf
4 | indent_size = 4
5 | indent_style = space
6 | insert_final_newline = true
7 | max_line_length = 120
8 | tab_width = 4
9 | ij_continuation_indent_size = 4
10 | ij_formatter_off_tag = @formatter:off
11 | ij_formatter_on_tag = @formatter:on
12 | ij_formatter_tags_enabled = false
13 | ij_smart_tabs = false
14 | ij_visual_guides = none
15 | ij_wrap_on_typing = false
16 |
17 | [.editorconfig]
18 | ij_editorconfig_align_group_field_declarations = false
19 | ij_editorconfig_space_after_colon = false
20 | ij_editorconfig_space_after_comma = true
21 | ij_editorconfig_space_before_colon = false
22 | ij_editorconfig_space_before_comma = false
23 | ij_editorconfig_spaces_around_assignment_operators = true
24 |
25 | [{*.c,*.c++,*.cc,*.cp,*.cpp,*.cu,*.cuh,*.cxx,*.h,*.h++,*.hh,*.hp,*.hpp,*.hxx,*.i,*.icc,*.ii,*.inl,*.ino,*.ipp,*.m,*.mm,*.pch,*.tcc,*.tpp,version.gen.rc}]
26 | ij_c_add_brief_tag = false
27 | ij_c_add_getter_prefix = true
28 | ij_c_add_setter_prefix = true
29 | ij_c_align_dictionary_pair_values = false
30 | ij_c_align_group_field_declarations = false
31 | ij_c_align_init_list_in_columns = true
32 | ij_c_align_multiline_array_initializer_expression = true
33 | ij_c_align_multiline_assignment = true
34 | ij_c_align_multiline_binary_operation = true
35 | ij_c_align_multiline_chained_methods = false
36 | ij_c_align_multiline_for = true
37 | ij_c_align_multiline_ternary_operation = false
38 | ij_c_array_initializer_comma_on_next_line = false
39 | ij_c_array_initializer_new_line_after_left_brace = false
40 | ij_c_array_initializer_right_brace_on_new_line = false
41 | ij_c_array_initializer_wrap = normal
42 | ij_c_assignment_wrap = off
43 | ij_c_binary_operation_sign_on_next_line = false
44 | ij_c_binary_operation_wrap = normal
45 | ij_c_blank_lines_after_class_header = 0
46 | ij_c_blank_lines_after_imports = 1
47 | ij_c_blank_lines_around_class = 1
48 | ij_c_blank_lines_around_field = 0
49 | ij_c_blank_lines_around_field_in_interface = 0
50 | ij_c_blank_lines_around_method = 1
51 | ij_c_blank_lines_around_method_in_interface = 1
52 | ij_c_blank_lines_around_namespace = 0
53 | ij_c_blank_lines_around_properties_in_declaration = 0
54 | ij_c_blank_lines_around_properties_in_interface = 0
55 | ij_c_blank_lines_before_imports = 1
56 | ij_c_blank_lines_before_method_body = 0
57 | ij_c_block_brace_placement = end_of_line
58 | ij_c_block_brace_style = end_of_line
59 | ij_c_block_comment_at_first_column = true
60 | ij_c_catch_on_new_line = false
61 | ij_c_class_brace_style = end_of_line
62 | ij_c_class_constructor_init_list_align_multiline = true
63 | ij_c_class_constructor_init_list_comma_on_next_line = false
64 | ij_c_class_constructor_init_list_new_line_after_colon = never
65 | ij_c_class_constructor_init_list_new_line_before_colon = if_long
66 | ij_c_class_constructor_init_list_wrap = normal
67 | ij_c_copy_is_deep = false
68 | ij_c_create_interface_for_categories = true
69 | ij_c_declare_generated_methods = true
70 | ij_c_description_include_member_names = true
71 | ij_c_discharged_short_ternary_operator = false
72 | ij_c_do_not_add_breaks = false
73 | ij_c_do_while_brace_force = never
74 | ij_c_else_on_new_line = false
75 | ij_c_enum_constants_comma_on_next_line = false
76 | ij_c_enum_constants_wrap = on_every_item
77 | ij_c_for_brace_force = never
78 | ij_c_for_statement_new_line_after_left_paren = false
79 | ij_c_for_statement_right_paren_on_new_line = false
80 | ij_c_for_statement_wrap = off
81 | ij_c_function_brace_placement = end_of_line
82 | ij_c_function_call_arguments_align_multiline = false
83 | ij_c_function_call_arguments_align_multiline_pars = false
84 | ij_c_function_call_arguments_comma_on_next_line = false
85 | ij_c_function_call_arguments_new_line_after_lpar = false
86 | ij_c_function_call_arguments_new_line_before_rpar = false
87 | ij_c_function_call_arguments_wrap = normal
88 | ij_c_function_non_top_after_return_type_wrap = normal
89 | ij_c_function_parameters_align_multiline = true
90 | ij_c_function_parameters_align_multiline_pars = false
91 | ij_c_function_parameters_comma_on_next_line = false
92 | ij_c_function_parameters_new_line_after_lpar = true
93 | ij_c_function_parameters_new_line_before_rpar = true
94 | ij_c_function_parameters_wrap = normal
95 | ij_c_function_top_after_return_type_wrap = normal
96 | ij_c_generate_additional_eq_operators = true
97 | ij_c_generate_additional_rel_operators = true
98 | ij_c_generate_class_constructor = true
99 | ij_c_generate_comparison_operators_use_std_tie = false
100 | ij_c_generate_instance_variables_for_properties = ask
101 | ij_c_generate_operators_as_members = true
102 | ij_c_header_guard_style_pattern = ${PROJECT_NAME}_${FILE_NAME}_${EXT}
103 | ij_c_if_brace_force = never
104 | ij_c_in_line_short_ternary_operator = true
105 | ij_c_indent_block_comment = true
106 | ij_c_indent_c_struct_members = 4
107 | ij_c_indent_case_from_switch = true
108 | ij_c_indent_class_members = 4
109 | ij_c_indent_directive_as_code = false
110 | ij_c_indent_implementation_members = 0
111 | ij_c_indent_inside_code_block = 4
112 | ij_c_indent_interface_members = 0
113 | ij_c_indent_interface_members_except_ivars_block = false
114 | ij_c_indent_namespace_members = 4
115 | ij_c_indent_preprocessor_directive = 0
116 | ij_c_indent_visibility_keywords = 0
117 | ij_c_insert_override = true
118 | ij_c_insert_virtual_with_override = false
119 | ij_c_introduce_auto_vars = false
120 | ij_c_introduce_const_params = false
121 | ij_c_introduce_const_vars = false
122 | ij_c_introduce_generate_property = false
123 | ij_c_introduce_generate_synthesize = true
124 | ij_c_introduce_globals_to_header = true
125 | ij_c_introduce_prop_to_private_category = false
126 | ij_c_introduce_static_consts = true
127 | ij_c_introduce_use_ns_types = false
128 | ij_c_ivars_prefix = _
129 | ij_c_keep_blank_lines_before_end = 1
130 | ij_c_keep_blank_lines_before_right_brace = 1
131 | ij_c_keep_blank_lines_in_code = 1
132 | ij_c_keep_blank_lines_in_declarations = 1
133 | ij_c_keep_case_expressions_in_one_line = false
134 | ij_c_keep_control_statement_in_one_line = true
135 | ij_c_keep_directive_at_first_column = true
136 | ij_c_keep_first_column_comment = true
137 | ij_c_keep_line_breaks = true
138 | ij_c_keep_nested_namespaces_in_one_line = false
139 | ij_c_keep_simple_blocks_in_one_line = true
140 | ij_c_keep_simple_methods_in_one_line = true
141 | ij_c_keep_structures_in_one_line = true
142 | ij_c_lambda_capture_list_align_multiline = false
143 | ij_c_lambda_capture_list_align_multiline_bracket = false
144 | ij_c_lambda_capture_list_comma_on_next_line = false
145 | ij_c_lambda_capture_list_new_line_after_lbracket = false
146 | ij_c_lambda_capture_list_new_line_before_rbracket = false
147 | ij_c_lambda_capture_list_wrap = off
148 | ij_c_line_comment_add_space = false
149 | ij_c_line_comment_at_first_column = true
150 | ij_c_method_brace_placement = end_of_line
151 | ij_c_method_call_arguments_align_by_colons = true
152 | ij_c_method_call_arguments_align_multiline = false
153 | ij_c_method_call_arguments_special_dictionary_pairs_treatment = true
154 | ij_c_method_call_arguments_wrap = off
155 | ij_c_method_call_chain_wrap = off
156 | ij_c_method_parameters_align_by_colons = true
157 | ij_c_method_parameters_align_multiline = false
158 | ij_c_method_parameters_wrap = off
159 | ij_c_namespace_brace_placement = end_of_line
160 | ij_c_parentheses_expression_new_line_after_left_paren = false
161 | ij_c_parentheses_expression_right_paren_on_new_line = false
162 | ij_c_place_assignment_sign_on_next_line = false
163 | ij_c_property_nonatomic = true
164 | ij_c_put_ivars_to_implementation = true
165 | ij_c_refactor_compatibility_aliases_and_classes = true
166 | ij_c_refactor_properties_and_ivars = true
167 | ij_c_release_style = ivar
168 | ij_c_retain_object_parameters_in_constructor = true
169 | ij_c_semicolon_after_method_signature = false
170 | ij_c_shift_operation_align_multiline = true
171 | ij_c_shift_operation_wrap = normal
172 | ij_c_show_non_virtual_functions = false
173 | ij_c_space_after_colon = true
174 | ij_c_space_after_colon_in_foreach = true
175 | ij_c_space_after_colon_in_selector = false
176 | ij_c_space_after_comma = true
177 | ij_c_space_after_cup_in_blocks = false
178 | ij_c_space_after_dictionary_literal_colon = true
179 | ij_c_space_after_for_semicolon = true
180 | ij_c_space_after_init_list_colon = true
181 | ij_c_space_after_method_parameter_type_parentheses = false
182 | ij_c_space_after_method_return_type_parentheses = false
183 | ij_c_space_after_pointer_in_declaration = true
184 | ij_c_space_after_quest = true
185 | ij_c_space_after_reference_in_declaration = true
186 | ij_c_space_after_reference_in_rvalue = false
187 | ij_c_space_after_structures_rbrace = true
188 | ij_c_space_after_superclass_colon = true
189 | ij_c_space_after_type_cast = true
190 | ij_c_space_after_visibility_sign_in_method_declaration = true
191 | ij_c_space_before_autorelease_pool_lbrace = true
192 | ij_c_space_before_catch_keyword = true
193 | ij_c_space_before_catch_left_brace = true
194 | ij_c_space_before_catch_parentheses = true
195 | ij_c_space_before_category_parentheses = true
196 | ij_c_space_before_chained_send_message = true
197 | ij_c_space_before_class_left_brace = true
198 | ij_c_space_before_colon = true
199 | ij_c_space_before_colon_in_foreach = false
200 | ij_c_space_before_comma = false
201 | ij_c_space_before_dictionary_literal_colon = false
202 | ij_c_space_before_do_left_brace = true
203 | ij_c_space_before_else_keyword = true
204 | ij_c_space_before_else_left_brace = true
205 | ij_c_space_before_for_left_brace = true
206 | ij_c_space_before_for_parentheses = true
207 | ij_c_space_before_for_semicolon = false
208 | ij_c_space_before_if_left_brace = true
209 | ij_c_space_before_if_parentheses = true
210 | ij_c_space_before_init_list = false
211 | ij_c_space_before_init_list_colon = true
212 | ij_c_space_before_method_call_parentheses = false
213 | ij_c_space_before_method_left_brace = true
214 | ij_c_space_before_method_parentheses = false
215 | ij_c_space_before_namespace_lbrace = true
216 | ij_c_space_before_pointer_in_declaration = false
217 | ij_c_space_before_property_attributes_parentheses = false
218 | ij_c_space_before_protocols_brackets = true
219 | ij_c_space_before_quest = true
220 | ij_c_space_before_reference_in_declaration = false
221 | ij_c_space_before_superclass_colon = true
222 | ij_c_space_before_switch_left_brace = true
223 | ij_c_space_before_switch_parentheses = true
224 | ij_c_space_before_template_call_lt = false
225 | ij_c_space_before_template_declaration_lt = false
226 | ij_c_space_before_try_left_brace = true
227 | ij_c_space_before_while_keyword = true
228 | ij_c_space_before_while_left_brace = true
229 | ij_c_space_before_while_parentheses = true
230 | ij_c_space_between_adjacent_brackets = false
231 | ij_c_space_between_operator_and_punctuator = false
232 | ij_c_space_within_empty_array_initializer_braces = false
233 | ij_c_spaces_around_additive_operators = true
234 | ij_c_spaces_around_assignment_operators = true
235 | ij_c_spaces_around_bitwise_operators = true
236 | ij_c_spaces_around_equality_operators = true
237 | ij_c_spaces_around_lambda_arrow = true
238 | ij_c_spaces_around_logical_operators = true
239 | ij_c_spaces_around_multiplicative_operators = true
240 | ij_c_spaces_around_pm_operators = false
241 | ij_c_spaces_around_relational_operators = true
242 | ij_c_spaces_around_shift_operators = true
243 | ij_c_spaces_around_unary_operator = false
244 | ij_c_spaces_within_array_initializer_braces = true
245 | ij_c_spaces_within_braces = true
246 | ij_c_spaces_within_brackets = false
247 | ij_c_spaces_within_cast_parentheses = false
248 | ij_c_spaces_within_catch_parentheses = false
249 | ij_c_spaces_within_category_parentheses = false
250 | ij_c_spaces_within_empty_braces = false
251 | ij_c_spaces_within_empty_function_call_parentheses = false
252 | ij_c_spaces_within_empty_function_declaration_parentheses = false
253 | ij_c_spaces_within_empty_lambda_capture_list_bracket = false
254 | ij_c_spaces_within_empty_template_call_ltgt = false
255 | ij_c_spaces_within_empty_template_declaration_ltgt = false
256 | ij_c_spaces_within_for_parentheses = false
257 | ij_c_spaces_within_function_call_parentheses = false
258 | ij_c_spaces_within_function_declaration_parentheses = false
259 | ij_c_spaces_within_if_parentheses = false
260 | ij_c_spaces_within_lambda_capture_list_bracket = false
261 | ij_c_spaces_within_method_parameter_type_parentheses = false
262 | ij_c_spaces_within_method_return_type_parentheses = false
263 | ij_c_spaces_within_parentheses = false
264 | ij_c_spaces_within_property_attributes_parentheses = false
265 | ij_c_spaces_within_protocols_brackets = false
266 | ij_c_spaces_within_send_message_brackets = false
267 | ij_c_spaces_within_switch_parentheses = false
268 | ij_c_spaces_within_template_call_ltgt = false
269 | ij_c_spaces_within_template_declaration_ltgt = false
270 | ij_c_spaces_within_template_double_gt = true
271 | ij_c_spaces_within_while_parentheses = false
272 | ij_c_special_else_if_treatment = true
273 | ij_c_superclass_list_after_colon = never
274 | ij_c_superclass_list_align_multiline = true
275 | ij_c_superclass_list_before_colon = if_long
276 | ij_c_superclass_list_comma_on_next_line = false
277 | ij_c_superclass_list_wrap = on_every_item
278 | ij_c_tag_prefix_of_block_comment = at
279 | ij_c_tag_prefix_of_line_comment = back_slash
280 | ij_c_template_call_arguments_align_multiline = false
281 | ij_c_template_call_arguments_align_multiline_pars = false
282 | ij_c_template_call_arguments_comma_on_next_line = false
283 | ij_c_template_call_arguments_new_line_after_lt = false
284 | ij_c_template_call_arguments_new_line_before_gt = false
285 | ij_c_template_call_arguments_wrap = off
286 | ij_c_template_declaration_function_body_indent = false
287 | ij_c_template_declaration_function_wrap = split_into_lines
288 | ij_c_template_declaration_struct_body_indent = false
289 | ij_c_template_declaration_struct_wrap = split_into_lines
290 | ij_c_template_parameters_align_multiline = false
291 | ij_c_template_parameters_align_multiline_pars = false
292 | ij_c_template_parameters_comma_on_next_line = false
293 | ij_c_template_parameters_new_line_after_lt = false
294 | ij_c_template_parameters_new_line_before_gt = false
295 | ij_c_template_parameters_wrap = off
296 | ij_c_ternary_operation_signs_on_next_line = true
297 | ij_c_ternary_operation_wrap = normal
298 | ij_c_type_qualifiers_placement = before
299 | ij_c_use_modern_casts = true
300 | ij_c_use_setters_in_constructor = true
301 | ij_c_while_brace_force = never
302 | ij_c_while_on_new_line = false
303 | ij_c_wrap_property_declaration = off
304 |
305 | [{*.cmake,CMakeLists.txt}]
306 | ij_continuation_indent_size = 4
307 | ij_cmake_align_multiline_parameters_in_calls = false
308 | ij_cmake_force_commands_case = 2
309 | ij_cmake_keep_blank_lines_in_code = 2
310 | ij_cmake_space_before_for_parentheses = true
311 | ij_cmake_space_before_if_parentheses = true
312 | ij_cmake_space_before_method_call_parentheses = false
313 | ij_cmake_space_before_method_parentheses = false
314 | ij_cmake_space_before_while_parentheses = true
315 | ij_cmake_spaces_within_for_parentheses = false
316 | ij_cmake_spaces_within_if_parentheses = false
317 | ij_cmake_spaces_within_method_call_parentheses = false
318 | ij_cmake_spaces_within_method_parentheses = false
319 | ij_cmake_spaces_within_while_parentheses = false
320 |
321 | [{*.har,*.json,*.jsonc}]
322 | indent_size = 2
323 | ij_json_keep_blank_lines_in_code = 1
324 | ij_json_keep_indents_on_empty_lines = false
325 | ij_json_keep_line_breaks = true
326 | ij_json_space_after_colon = true
327 | ij_json_space_after_comma = true
328 | ij_json_space_before_colon = true
329 | ij_json_space_before_comma = false
330 | ij_json_spaces_within_braces = false
331 | ij_json_spaces_within_brackets = false
332 | ij_json_wrap_long_lines = false
333 |
334 | [{*.apinotes,*.yaml,*.yml,.clang-format,.clang-tidy,_clang-format}]
335 | indent_size = 2
336 |
--------------------------------------------------------------------------------
/.github/workflows/build-and-package.yml:
--------------------------------------------------------------------------------
1 | name: Build and Package
2 | on:
3 | workflow_call:
4 | inputs:
5 | modules:
6 | description: 'Stringified JSON object listing modules to build'
7 | required: true
8 | type: string
9 |
10 | zip_command:
11 | description: 'A shell command for creating a release zip'
12 | required: true
13 | type: string
14 |
15 | config:
16 | description: 'A CMake build config'
17 | required: true
18 | type: string
19 | default: Release
20 |
21 | jobs:
22 | build-project:
23 | name: Build ${{ matrix.module }} for ${{ matrix.arch }}-bit architecture
24 | runs-on: windows-2022
25 | strategy:
26 | matrix:
27 | module: ${{ fromJson(inputs.modules) }}
28 | arch: [ 32, 64 ]
29 | include:
30 | - arch: 32
31 | platform: Win32
32 | term: amd64_x86
33 |
34 | - arch: 64
35 | platform: x64
36 | term: amd64
37 |
38 | env:
39 | BUILD_DIR: ${{ github.workspace }}\build\${{ matrix.arch }}\${{ matrix.module }}
40 |
41 | steps:
42 | - name: Check out repository code
43 | uses: actions/checkout@v3
44 | with:
45 | submodules: recursive
46 |
47 | - name: Install and cache the latest CMake
48 | uses: lukka/get-cmake@latest
49 |
50 | - name: Setup Developer Command Prompt for Microsoft Visual C++.
51 | uses: ilammy/msvc-dev-cmd@v1
52 | with:
53 | arch: ${{ matrix.term }}
54 |
55 | - name: Print build directory tree
56 | run: tree /f ${{ env.BUILD_DIR }}
57 |
58 | - name: Generate build files
59 | run: cmake -G "Visual Studio 17 2022" -A "${{ matrix.platform }}" -B "${{ env.BUILD_DIR }}" -DMODULE=${{ matrix.module }}
60 |
61 | - name: Build the project
62 | run: cmake --build ${{ env.BUILD_DIR }} --config ${{ inputs.config }}
63 |
64 | - name: Upload binaries
65 | uses: actions/upload-artifact@v3
66 | with:
67 | name: ${{ matrix.module }}-${{ matrix.arch }}
68 | path: ${{ env.BUILD_DIR }}\${{ inputs.config }}\*.dll
69 |
70 | package-project:
71 | name: Package the artifacts into a release zip
72 | if: startsWith(github.ref, 'refs/tags/')
73 | runs-on: ubuntu-latest
74 | needs: build-project
75 | permissions:
76 | contents: write
77 | steps:
78 | - name: Setup version tag
79 | run: echo "VERSION_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
80 |
81 | - name: Setup zip name
82 | env:
83 | PROJECT_NAME: ${{ github.event.repository.name }}
84 | run: echo "ZIP_NAME=$PROJECT_NAME-$VERSION_TAG.zip" >> $GITHUB_ENV
85 |
86 | - name: Install required tools
87 | run: |
88 | sudo apt update
89 | sudo apt install zip tree
90 |
91 | - name: Check out repository code
92 | uses: actions/checkout@v3
93 |
94 | - name: Download all workflow run artifacts
95 | uses: actions/download-artifact@v3
96 | with:
97 | path: artifacts
98 |
99 | - name: Print artifact tree
100 | run: tree artifacts
101 |
102 | - name: Make release zip
103 | run: ${{ inputs.zip_command }}
104 |
105 | - name: Create a release draft
106 | uses: softprops/action-gh-release@v1
107 | with:
108 | body: '# 📑 Changelog'
109 | draft: true
110 | prerelease: false
111 | files: ${{ env.ZIP_NAME }}
112 | name: Release ${{ env.VERSION_TAG }}
113 | tag_name: ${{ env.VERSION_TAG }}
114 | fail_on_unmatched_files: true
115 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/acidicoala/KoalaBox/842c83eecfd0b40f572853a36df4dfb24656db4e/.gitmodules
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 |
--------------------------------------------------------------------------------
/.idea/KoalaBox.iml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/.idea/cmake.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.24)
2 |
3 | project(
4 | KoalaBox LANGUAGES CXX
5 | DESCRIPTION "A box of koality tools"
6 | )
7 |
8 | include(cmake/KoalaBox.cmake)
9 |
10 | # Configure variables
11 |
12 | include(GNUInstallDirs)
13 |
14 | set(
15 | KOALABOX_HEADERS
16 | include/koalabox/cache.hpp
17 | include/koalabox/config.hpp
18 | include/koalabox/core.hpp
19 | include/koalabox/crypto.hpp
20 | include/koalabox/dll_monitor.hpp
21 | include/koalabox/globals.hpp
22 | include/koalabox/logger.hpp
23 | include/koalabox/hook.hpp
24 | include/koalabox/http_client.hpp
25 | include/koalabox/io.hpp
26 | include/koalabox/ipc.hpp
27 | include/koalabox/loader.hpp
28 | include/koalabox/patcher.hpp
29 | include/koalabox/paths.hpp
30 | include/koalabox/util.hpp
31 | include/koalabox/win_util.hpp
32 | )
33 |
34 | set(
35 | KOALABOX_SOURCES
36 | src/koalabox/cache.cpp
37 | src/koalabox/core.cpp
38 | src/koalabox/crypto.cpp
39 | src/koalabox/dll_monitor.cpp
40 | src/koalabox/globals.cpp
41 | src/koalabox/logger.cpp
42 | src/koalabox/hook.cpp
43 | src/koalabox/http_client.cpp
44 | src/koalabox/io.cpp
45 | src/koalabox/ipc.cpp
46 | src/koalabox/loader.cpp
47 | src/koalabox/ntapi.hpp
48 | src/koalabox/patcher.cpp
49 | src/koalabox/paths.cpp
50 | src/koalabox/util.cpp
51 | src/koalabox/win_util.cpp
52 | )
53 |
54 | add_library(KoalaBox OBJECT ${KOALABOX_HEADERS} ${KOALABOX_SOURCES})
55 |
56 | # Configure dependencies
57 |
58 | ## Cpr - https://github.com/libcpr/cpr/
59 | fetch_library(cpr libcpr/cpr 1.10.1)
60 |
61 | ## Json - https://github.com/nlohmann/json
62 | fetch_library(nlohmann_json nlohmann/json v3.11.2)
63 |
64 | ## Polyhook2 - https://github.com/stevemk14ebr/PolyHook_2_0
65 | set(POLYHOOK_FEATURE_INLINENTD OFF)
66 | set(POLYHOOK_FEATURE_EXCEPTION OFF)
67 | fetch_library(PolyHook_2 stevemk14ebr/PolyHook_2_0 71d273463a3c4e30ec0a4031c4b477b85ea773fb)
68 |
69 | ## Spdlog - https://github.com/gabime/spdlog
70 | fetch_library(spdlog gabime/spdlog v1.11.0)
71 |
72 | ## Miniz - https://github.com/richgel999/miniz
73 | fetch_library(miniz richgel999/miniz 3.0.2)
74 |
75 | ## WinReg - https://github.com/GiovanniDicanio/WinReg
76 | fetch_library(WinReg acidicoala/WinReg b86786c6845a4a03a2e66a456cd65ec77069a7c4)
77 |
78 | # Setup KoalaBox exports
79 | target_include_directories(
80 | KoalaBox PUBLIC
81 | "$"
82 | "$"
83 | )
84 |
85 | set(PCH_PATH ${CMAKE_CURRENT_SOURCE_DIR}/include/koalabox/pch.hpp)
86 | target_precompile_headers(KoalaBox PUBLIC "$<$:${PCH_PATH}>")
87 |
88 | install(
89 | TARGETS KoalaBox DESTINATION ${LIB_INSTALL_DIR}
90 | INCLUDES ${KOALABOX_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}
91 | )
92 |
93 | # Exports Generator
94 |
95 | add_executable(exports_generator src/exports_generator/exports_generator.cpp)
96 |
97 | target_link_libraries(exports_generator PUBLIC KoalaBox)
98 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | BSD Zero Clause License
2 |
3 | Copyright (c) 2022 by acidicoala
4 |
5 | Permission to use, copy, modify, and/or distribute this software for any
6 | purpose with or without fee is hereby granted.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 | PERFORMANCE OF THIS SOFTWARE.
15 |
--------------------------------------------------------------------------------
/README.adoc:
--------------------------------------------------------------------------------
1 | = 🐨 KoalaBox 🧰
2 |
3 | A collection of C++ utilities that comes in handy when developing koality projects.
4 |
5 | To use this library as a submodule add the following to the CMake file:
6 |
7 | [source,cmake]
8 | ----
9 | add_subdirectory(KoalaBox EXCLUDE_FROM_ALL)
10 | target_link_libraries(MyProject PRIVATE KoalaBox)
11 | ----
12 |
13 | == 📚 Open-Source libraries
14 |
15 | This project makes use of the following libraries:
16 |
17 | * https://github.com/libcpr/cpr[C++ Requests]
18 | * https://github.com/nlohmann/json[nlohmann JSON]
19 | * https://github.com/stevemk14ebr/PolyHook_2_0[PolyHook 2]
20 | * https://github.com/gabime/spdlog[spdlog]
21 | * https://github.com/acidicoala/WinReg[WinReg]
22 |
23 | == 📄 License
24 |
25 | This software is licensed under the https://unlicense.org/[Unlicense], terms of which are available in link:UNLICENSE.txt[UNLICENSE.txt]
26 |
--------------------------------------------------------------------------------
/UNLICENSE.txt:
--------------------------------------------------------------------------------
1 | This is free and unencumbered software released into the public domain.
2 |
3 | Anyone is free to copy, modify, publish, use, compile, sell, or
4 | distribute this software, either in source code form or as a compiled
5 | binary, for any purpose, commercial or non-commercial, and by any
6 | means.
7 |
8 | In jurisdictions that recognize copyright laws, the author or authors
9 | of this software dedicate any and all copyright interest in the
10 | software to the public domain. We make this dedication for the benefit
11 | of the public at large and to the detriment of our heirs and
12 | successors. We intend this dedication to be an overt act of
13 | relinquishment in perpetuity of all present and future rights to this
14 | software under copyright law.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | For more information, please refer to
--------------------------------------------------------------------------------
/build.ps1:
--------------------------------------------------------------------------------
1 | # Usage:
2 | # build.ps1 32 Debug
3 | # build.ps1 32 Release
4 | # build.ps1 64 Debug
5 | # build.ps1 64 Release
6 |
7 | $target = $args[0]
8 |
9 | $arch = $args[1]
10 | if ($arch -notmatch '^(32|64)$')
11 | {
12 | throw "Invalid architecute. Expected: '32' or '64'. Got: '$arch'"
13 | }
14 | $platform = If ($arch -eq '32')
15 | {
16 | 'Win32'
17 | }
18 | Else
19 | {
20 | 'x64'
21 | }
22 |
23 | $config = $args[2]
24 | if ($config -notmatch '^(Debug|Release|RelWithDebInfo)$')
25 | {
26 | throw "Invalid architecute. Expected: 'Debug' or 'Release' or 'RelWithDebInfo'. Got: '$config'"
27 | }
28 |
29 | $Env:BUILD_DIR = "build\$arch"
30 |
31 | function Build-Project {
32 | cmake -G "Visual Studio 17 2022" -A $platform -B "$Env:BUILD_DIR" "$Env:CMAKE_OPTIONS"
33 |
34 | cmake --build "$Env:BUILD_DIR" --target $target --config $config
35 | }
36 |
--------------------------------------------------------------------------------
/cmake/KoalaBox.cmake:
--------------------------------------------------------------------------------
1 | set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use")
2 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
3 | set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" CACHE STRING "MSVC Runtime Library")
4 | set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build DLL instead of static library")
5 |
6 | include(FetchContent)
7 |
8 | function(fetch_library LIB USER_REPO TAG)
9 | FetchContent_Declare(${LIB} GIT_REPOSITORY "https://github.com/${USER_REPO}" GIT_TAG ${TAG})
10 | FetchContent_MakeAvailable(${LIB})
11 | target_link_libraries(${PROJECT_NAME} PUBLIC ${LIB})
12 | endfunction()
13 |
14 | # Sets the variable ${VAR} with val_for_32 on 32-bit build
15 | # and appends 64 to val_for_32 on 64-bit build, unless it an optional argument
16 | # is provided.
17 | function(set_32_and_64 VAR val_for_32)
18 | if (DEFINED ARGV2)
19 | set(val_for_64 ${ARGV2})
20 | else ()
21 | set(val_for_64 "${val_for_32}64")
22 | endif ()
23 |
24 | if (CMAKE_SIZEOF_VOID_P EQUAL 8)
25 | set(${VAR} ${val_for_64} PARENT_SCOPE)
26 | else ()
27 | set(${VAR} ${val_for_32} PARENT_SCOPE)
28 | endif ()
29 | endfunction()
30 |
31 | ## Generate version resource file
32 | function(configure_version_resource FILE_DESC)
33 | set(DLL_VERSION_FILE_DESC ${FILE_DESC})
34 | set(DLL_VERSION_PRODUCT_NAME ${CMAKE_PROJECT_NAME})
35 | set(DLL_VERSION_INTERNAL_NAME ${CMAKE_PROJECT_NAME})
36 |
37 | set(VERSION_RESOURCE "${CMAKE_CURRENT_BINARY_DIR}/version.rc")
38 | set(VERSION_RESOURCE ${VERSION_RESOURCE} PARENT_SCOPE)
39 |
40 | configure_file(KoalaBox/res/version.gen.rc ${VERSION_RESOURCE})
41 | endfunction()
42 |
43 | function(configure_build_config)
44 | set(BUILD_CONFIG_HEADER "${CMAKE_CURRENT_BINARY_DIR}/build_config.h")
45 |
46 | configure_file(KoalaBox/res/build_config.gen.h ${BUILD_CONFIG_HEADER})
47 |
48 | foreach (EXTRA_CONFIG IN LISTS ARGN)
49 | set(GENERATED_EXTRA_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/${EXTRA_CONFIG}.h)
50 |
51 | file(TOUCH ${GENERATED_EXTRA_CONFIG})
52 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/res/${EXTRA_CONFIG}.gen.h ${GENERATED_EXTRA_CONFIG})
53 | file(APPEND ${BUILD_CONFIG_HEADER} "#include <${EXTRA_CONFIG}.h>\n")
54 | endforeach ()
55 | endfunction()
56 |
57 |
58 | function(configure_output_name OUT_NAME)
59 | set_target_properties(
60 | ${CMAKE_PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_NAME "${OUT_NAME}"
61 | )
62 | endfunction()
63 |
64 | function(configure_include_directories)
65 | target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
66 | "${CMAKE_CURRENT_SOURCE_DIR}/src"
67 | "${CMAKE_CURRENT_BINARY_DIR}"
68 | "${ARGN}")
69 | endfunction()
70 |
71 | function(link_to_koalabox)
72 | target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE KoalaBox)
73 | endfunction()
74 |
75 | function(configure_linker_exports)
76 | cmake_parse_arguments(
77 | ARG "UNDECORATE" "FORWARDED_DLL;INPUT_SOURCES_DIR" "INPUT_DLLS;DEP_SOURCES" ${ARGN}
78 | )
79 |
80 | string(JOIN "|" JOINED_INPUT_DLLS ${ARG_INPUT_DLLS})
81 |
82 | set(GENERATED_LINKER_EXPORTS "${CMAKE_CURRENT_BINARY_DIR}/linker_exports.h")
83 | set(GENERATED_LINKER_EXPORTS "${GENERATED_LINKER_EXPORTS}" PARENT_SCOPE)
84 |
85 | # Make the linker_exports header available before build
86 | file(TOUCH ${GENERATED_LINKER_EXPORTS})
87 |
88 | add_custom_command(
89 | OUTPUT ${GENERATED_LINKER_EXPORTS}
90 | COMMAND exports_generator # Executable path
91 | ${ARG_UNDECORATE} # Undecorate boolean
92 | ${ARG_FORWARDED_DLL} # Forwarded DLL path
93 | "\"${JOINED_INPUT_DLLS}\"" # Input DLLs
94 | "${GENERATED_LINKER_EXPORTS}" # Output header
95 | "${ARG_INPUT_SOURCES_DIR}" # Input sources
96 | DEPENDS exports_generator
97 | "${ARG_INPUT_DLLS}"
98 | "${ARG_DEP_SOURCES}"
99 | )
100 | endfunction()
101 |
102 | function(install_python)
103 | # https://www.python.org/downloads/release/python-3112/
104 | set(MY_PYTHON_VERSION 3.11.2)
105 | set_32_and_64(MY_PYTHON_INSTALLER python-${MY_PYTHON_VERSION}.exe python-${MY_PYTHON_VERSION}-amd64.exe)
106 | set_32_and_64(MY_PYTHON_INSTALLER_EXPECTED_MD5 2123016702bbb45688baedc3695852f4 4331ca54d9eacdbe6e97d6ea63526e57)
107 |
108 | set(MY_PYTHON_INSTALLER_PATH "${CMAKE_BINARY_DIR}/python-installer/${MY_PYTHON_INSTALLER}")
109 |
110 | # Download installer if necessary
111 | set(MY_PYTHON_INSTALLER_URL "https://www.python.org/ftp/python/${MY_PYTHON_VERSION}/${MY_PYTHON_INSTALLER}")
112 |
113 | MESSAGE(STATUS "Downloading python installer: ${MY_PYTHON_INSTALLER_URL}")
114 |
115 | file(
116 | DOWNLOAD ${MY_PYTHON_INSTALLER_URL} "${MY_PYTHON_INSTALLER_PATH}"
117 | EXPECTED_HASH MD5=${MY_PYTHON_INSTALLER_EXPECTED_MD5}
118 | SHOW_PROGRESS
119 | )
120 |
121 | MESSAGE(STATUS "Installing python: ${MY_PYTHON_INSTALLER_PATH}")
122 |
123 | cmake_path(CONVERT "${CMAKE_BINARY_DIR}/python" TO_NATIVE_PATH_LIST MY_PYTHON_INSTALL_DIR NORMALIZE)
124 |
125 | # Install python
126 | execute_process(
127 | COMMAND "${MY_PYTHON_INSTALLER_PATH}" /quiet
128 | InstallAllUsers=0
129 | "TargetDir=${MY_PYTHON_INSTALL_DIR}"
130 | AssociateFiles=0
131 | PrependPath=0
132 | AppendPath=0
133 | Shortcuts=0
134 | Include_doc=0
135 | Include_debug=1
136 | Include_dev=1
137 | Include_exe=0
138 | Include_launcher=0
139 | Include_lib=1
140 | Include_pip=1
141 | Include_tcltk=1
142 | Include_test=0
143 | COMMAND_ERROR_IS_FATAL ANY
144 | COMMAND_ECHO STDOUT
145 | )
146 |
147 | set(Python_ROOT_DIR CACHE STRING "${MY_PYTHON_INSTALLER_PATH}")
148 |
149 | find_package(Python REQUIRED COMPONENTS Development)
150 | endfunction()
151 |
--------------------------------------------------------------------------------
/include/koalabox/cache.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | /**
6 | * This namespace contains utility functions for reading from and writing to cache file on disk.
7 | * All functions are intended to be safe to call, i.e. they should not throw exceptions.
8 | */
9 | namespace koalabox::cache {
10 |
11 | KOALABOX_API(Json) get(const String& key, const Json& value = Json());
12 |
13 | KOALABOX_API(bool) put(const String& key, const Json& value) noexcept;
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/include/koalabox/config.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | namespace koalabox::config {
10 |
11 | template
12 | KOALABOX_API(Config) parse(Path config_path) {
13 | if (not exists(config_path)) {
14 | return Config();
15 | }
16 |
17 | try {
18 | const auto config_str = koalabox::io::read_file(config_path);
19 |
20 | const auto config = Json::parse(config_str).get();
21 |
22 | LOG_DEBUG("Parsed config:\n{}", Json(config).dump(2))
23 |
24 | return config;
25 | } catch (const Exception& e) {
26 | util::panic("Error parsing config file: {}", e.what());
27 | }
28 | }
29 |
30 | template
31 | KOALABOX_API(Config) parse() {
32 | return parse(koalabox::paths::get_config_path());
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/include/koalabox/core.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include