94 Commits
Author SHA1 Message Date
alice 64c1ab0120 update readme [skip ci] 2026-07-26 02:41:07 +02:00
alice ad466e020b update deps 2026-07-26 02:34:41 +02:00
alice 5b4b06cb03 Update build.yml 2026-07-26 02:33:28 +02:00
alice 04871f2a3d update readme [skip ci] 2026-07-26 02:26:05 +02:00
alice 0fedd81e1f httpget fix 2026-07-26 02:22:26 +02:00
alice a1d52b9472 Delete gsc-tool 2026-07-26 02:09:23 +02:00
alice 50438cef27 fixes 2026-07-26 02:06:25 +02:00
alice b2bd1e0835 Update build.yml 2025-12-03 05:49:19 +01:00
alice e2a5d96e10 update 2 2025-12-03 05:47:55 +01:00
alice 8d4fa65e3b update 2025-12-03 05:45:25 +01:00
alice 54226a0e56 Update gsc-tool 2025-12-03 04:26:17 +01:00
fedandGitHub 1061c08829 Merge pull request #92 from fedddddd/dependabot/submodules/deps/GSL-b39e7e4
Bump deps/GSL from `f1a494c` to `b39e7e4`
2024-03-07 21:40:03 +01:00
dependabot[bot]andGitHub c75cf561f7 Bump deps/GSL from f1a494c to b39e7e4
Bumps [deps/GSL](https://github.com/microsoft/GSL) from `f1a494c` to `b39e7e4`.
- [Release notes](https://github.com/microsoft/GSL/releases)
- [Commits](https://github.com/microsoft/GSL/compare/f1a494cfd2ce55fe88b5134eab985f5852667b8d...b39e7e4b0987859f5b19ff7686b149c916588658)

---
updated-dependencies:
- dependency-name: deps/GSL
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2024-02-27 14:30:40 +00:00
fedandGitHub 3ea6050498 Merge pull request #89 from fedddddd/dependabot/submodules/deps/zlib-5c42a23
Bump deps/zlib from `e342bb3` to `5c42a23`
2024-02-12 17:19:02 +01:00
dependabot[bot]andGitHub 1551d7f1fd Bump deps/zlib from e342bb3 to 5c42a23
Bumps [deps/zlib](https://github.com/madler/zlib) from `e342bb3` to `5c42a23`.
- [Release notes](https://github.com/madler/zlib/releases)
- [Commits](https://github.com/madler/zlib/compare/e342bb3daef3f6d89dd1d39a3059355db5a64c49...5c42a230b7b468dff011f444161c0145b5efae59)

---
updated-dependencies:
- dependency-name: deps/zlib
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2024-02-12 14:10:29 +00:00
fedandGitHub bf1d649bc1 Merge pull request #83 from fedddddd/dependabot/submodules/deps/GSL-f1a494c
Bump deps/GSL from `e64c97f` to `f1a494c`
2024-02-07 18:55:06 +01:00
fedandGitHub 71727a5197 Merge pull request #82 from fedddddd/dependabot/submodules/deps/json-0457de2
Bump deps/json from `3780b41` to `0457de2`
2024-02-07 18:54:58 +01:00
fedandGitHub 530cd10466 Merge pull request #85 from fedddddd/dependabot/submodules/deps/zlib-e342bb3
Bump deps/zlib from `643e17b` to `e342bb3`
2024-02-07 18:54:52 +01:00
fed 978e251df8 Fixes for update 2024-02-07 18:52:23 +01:00
dependabot[bot]andGitHub cb96052638 Bump deps/zlib from 643e17b to e342bb3
Bumps [deps/zlib](https://github.com/madler/zlib) from `643e17b` to `e342bb3`.
- [Release notes](https://github.com/madler/zlib/releases)
- [Commits](https://github.com/madler/zlib/compare/643e17b7498d12ab8d15565662880579692f769d...e342bb3daef3f6d89dd1d39a3059355db5a64c49)

---
updated-dependencies:
- dependency-name: deps/zlib
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2024-02-07 14:11:12 +00:00
dependabot[bot]andGitHub 9b217b20e3 Bump deps/GSL from e64c97f to f1a494c
Bumps [deps/GSL](https://github.com/microsoft/GSL) from `e64c97f` to `f1a494c`.
- [Release notes](https://github.com/microsoft/GSL/releases)
- [Commits](https://github.com/microsoft/GSL/compare/e64c97fc2cfc11992098bb38eda932de275e3f4d...f1a494cfd2ce55fe88b5134eab985f5852667b8d)

---
updated-dependencies:
- dependency-name: deps/GSL
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2024-01-30 15:02:59 +00:00
dependabot[bot]andGitHub 136a723187 Bump deps/json from 3780b41 to 0457de2
Bumps [deps/json](https://github.com/nlohmann/json) from `3780b41` to `0457de2`.
- [Release notes](https://github.com/nlohmann/json/releases)
- [Commits](https://github.com/nlohmann/json/compare/3780b41dd070436f3f55327b0a88f27a52e2dfa8...0457de21cffb298c22b629e538036bfeb96130b7)

---
updated-dependencies:
- dependency-name: deps/json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2024-01-30 15:02:56 +00:00
fedandGitHub ad27dcb098 Merge pull request #73 from fedddddd/dependabot/submodules/deps/zlib-643e17b
Bump deps/zlib from `79a0e44` to `643e17b`
2024-01-29 19:33:48 +01:00
fedandGitHub 96acf0718e Merge pull request #79 from fedddddd/dependabot/submodules/deps/json-3780b41
Bump deps/json from `da92c0e` to `3780b41`
2024-01-29 19:33:42 +01:00
fedandGitHub 72f936e82a Merge pull request #74 from fedddddd/dependabot/submodules/deps/minhook-f5485b8
Bump deps/minhook from `0f25a24` to `f5485b8`
2024-01-29 19:33:35 +01:00
fedandGitHub 9a11ac82b3 Merge pull request #67 from fedddddd/dependabot/submodules/deps/GSL-e64c97f
Bump deps/GSL from `52212c2` to `e64c97f`
2024-01-29 19:33:30 +01:00
fed 8f36c271fd Fix for update 2024-01-29 19:33:03 +01:00
dependabot[bot]andGitHub e952b8a0f7 Bump deps/json from da92c0e to 3780b41
Bumps [deps/json](https://github.com/nlohmann/json) from `da92c0e` to `3780b41`.
- [Release notes](https://github.com/nlohmann/json/releases)
- [Commits](https://github.com/nlohmann/json/compare/da92c0e3e72d6a42106b5d829f5ff2d57fb16f77...3780b41dd070436f3f55327b0a88f27a52e2dfa8)

---
updated-dependencies:
- dependency-name: deps/json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-12-07 14:58:09 +00:00
dependabot[bot]andGitHub f6d78fd815 Bump deps/minhook from 0f25a24 to f5485b8
Bumps [deps/minhook](https://github.com/TsudaKageyu/minhook) from `0f25a24` to `f5485b8`.
- [Release notes](https://github.com/TsudaKageyu/minhook/releases)
- [Commits](https://github.com/TsudaKageyu/minhook/compare/0f25a2449b3cf878bcbdbf91b693c38149ecf029...f5485b8454544c2f034c78f8f127c1d03dea3636)

---
updated-dependencies:
- dependency-name: deps/minhook
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-11-27 15:05:13 +00:00
dependabot[bot]andGitHub cadcca22f9 Bump deps/zlib from 79a0e44 to 643e17b
Bumps [deps/zlib](https://github.com/madler/zlib) from `79a0e44` to `643e17b`.
- [Release notes](https://github.com/madler/zlib/releases)
- [Commits](https://github.com/madler/zlib/compare/79a0e447a0dfa32979420cb21cfb96d684b2c9d5...643e17b7498d12ab8d15565662880579692f769d)

---
updated-dependencies:
- dependency-name: deps/zlib
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-11-15 14:14:08 +00:00
dependabot[bot]andGitHub c04a0a0d8c Bump deps/GSL from 52212c2 to e64c97f
Bumps [deps/GSL](https://github.com/microsoft/GSL) from `52212c2` to `e64c97f`.
- [Release notes](https://github.com/microsoft/GSL/releases)
- [Commits](https://github.com/microsoft/GSL/compare/52212c2d7600c816ec9b0438d3fbd2a95c190c2f...e64c97fc2cfc11992098bb38eda932de275e3f4d)

---
updated-dependencies:
- dependency-name: deps/GSL
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-10-19 14:37:17 +00:00
fedandGitHub 61706336ce Merge pull request #50 from fedddddd/dependabot/submodules/deps/zlib-79a0e44
Bump deps/zlib from `04f42ce` to `79a0e44`
2023-09-13 17:44:09 +02:00
fedandGitHub eb08109392 Merge pull request #57 from fedddddd/dependabot/submodules/deps/json-da92c0e
Bump deps/json from `5d27543` to `da92c0e`
2023-09-13 17:43:49 +02:00
fedandGitHub b23cb2014b Merge pull request #58 from fedddddd/dependabot/submodules/deps/GSL-52212c2
Bump deps/GSL from `4300304` to `52212c2`
2023-09-13 17:43:40 +02:00
fed 4d979bf659 Fix for update 2023-09-13 17:43:18 +02:00
dependabot[bot]andGitHub 206d06dc7d Bump deps/GSL from 4300304 to 52212c2
Bumps [deps/GSL](https://github.com/microsoft/GSL) from `4300304` to `52212c2`.
- [Release notes](https://github.com/microsoft/GSL/releases)
- [Commits](https://github.com/microsoft/GSL/compare/4300304ef24c247b3db0255763f46b9f95c3a83d...52212c2d7600c816ec9b0438d3fbd2a95c190c2f)

---
updated-dependencies:
- dependency-name: deps/GSL
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-09-12 14:12:10 +00:00
dependabot[bot]andGitHub 4d8af4bd45 Bump deps/json from 5d27543 to da92c0e
Bumps [deps/json](https://github.com/nlohmann/json) from `5d27543` to `da92c0e`.
- [Release notes](https://github.com/nlohmann/json/releases)
- [Commits](https://github.com/nlohmann/json/compare/5d2754306d67d1e654a1a34e1d2e74439a9d53b3...da92c0e3e72d6a42106b5d829f5ff2d57fb16f77)

---
updated-dependencies:
- dependency-name: deps/json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-09-11 14:56:53 +00:00
dependabot[bot]andGitHub 46ab288488 Bump deps/zlib from 04f42ce to 79a0e44
Bumps [deps/zlib](https://github.com/madler/zlib) from `04f42ce` to `79a0e44`.
- [Release notes](https://github.com/madler/zlib/releases)
- [Commits](https://github.com/madler/zlib/compare/04f42ceca40f73e2978b50e93806c2a18c1281fc...79a0e447a0dfa32979420cb21cfb96d684b2c9d5)

---
updated-dependencies:
- dependency-name: deps/zlib
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-08-21 14:47:09 +00:00
fed dd8c1ff71e Update signatures.cpp 2023-08-10 01:55:12 +02:00
fedandGitHub ed1ac62153 Merge pull request #36 from fedddddd/dependabot/submodules/deps/json-5d27543
Bump deps/json from `c71ecde` to `5d27543`
2023-08-08 16:23:45 +02:00
fedandGitHub 7f7fd016cf Merge pull request #44 from fedddddd/dependabot/submodules/deps/GSL-4300304
Bump deps/GSL from `303d964` to `4300304`
2023-08-08 16:23:38 +02:00
fedandGitHub 6c093888b5 Merge pull request #45 from fedddddd/dependabot/submodules/deps/gsc-tool-d7365e4
Bump deps/gsc-tool from `f026487` to `d7365e4`
2023-08-08 16:23:31 +02:00
dependabot[bot]andGitHub 1440760aa5 Bump deps/gsc-tool from f026487 to d7365e4
Bumps [deps/gsc-tool](https://github.com/xensik/gsc-tool) from `f026487` to `d7365e4`.
- [Release notes](https://github.com/xensik/gsc-tool/releases)
- [Commits](https://github.com/xensik/gsc-tool/compare/f0264876dffeef28a3fc98f9612c53554df35724...d7365e471a05a7a6ac5b60b48f6a11a5947f10f1)

---
updated-dependencies:
- dependency-name: deps/gsc-tool
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-07-28 14:35:53 +00:00
dependabot[bot]andGitHub 105c11a8b2 Bump deps/GSL from 303d964 to 4300304
Bumps [deps/GSL](https://github.com/microsoft/GSL) from `303d964` to `4300304`.
- [Release notes](https://github.com/microsoft/GSL/releases)
- [Commits](https://github.com/microsoft/GSL/compare/303d964a241cb2f2a058fe0baa14013eb9afa116...4300304ef24c247b3db0255763f46b9f95c3a83d)

---
updated-dependencies:
- dependency-name: deps/GSL
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-07-27 14:35:38 +00:00
dependabot[bot]andGitHub 795f8ac162 Bump deps/json from c71ecde to 5d27543
Bumps [deps/json](https://github.com/nlohmann/json) from `c71ecde` to `5d27543`.
- [Release notes](https://github.com/nlohmann/json/releases)
- [Commits](https://github.com/nlohmann/json/compare/c71ecde505ebf236048a731c81ae8ecaf2b260a8...5d2754306d67d1e654a1a34e1d2e74439a9d53b3)

---
updated-dependencies:
- dependency-name: deps/json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-06-14 15:06:14 +00:00
fedandGitHub 6dd4d2651a Merge pull request #34 from fedddddd/dependabot/submodules/deps/json-c71ecde
Bump deps/json from `a0c1318` to `c71ecde`
2023-06-13 04:33:01 +02:00
dependabot[bot]andGitHub b2f030f349 Bump deps/json from a0c1318 to c71ecde
Bumps [deps/json](https://github.com/nlohmann/json) from `a0c1318` to `c71ecde`.
- [Release notes](https://github.com/nlohmann/json/releases)
- [Commits](https://github.com/nlohmann/json/compare/a0c1318830519eac027a31edec1a99ce1ae5670e...c71ecde505ebf236048a731c81ae8ecaf2b260a8)

---
updated-dependencies:
- dependency-name: deps/json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-06-12 14:14:45 +00:00
fedandGitHub 2690eeeece Merge pull request #28 from fedddddd/dependabot/submodules/deps/gsc-tool-f026487
Bump deps/gsc-tool from `a8a62c2` to `f026487`
2023-05-24 00:28:18 +02:00
fedandGitHub 098bd21008 Merge pull request #29 from fedddddd/dependabot/submodules/deps/json-a0c1318
Bump deps/json from `6af826d` to `a0c1318`
2023-05-24 00:28:11 +02:00
fedandGitHub 2f474e979f Merge pull request #30 from fedddddd/dependabot/submodules/deps/GSL-303d964
Bump deps/GSL from `afaaa71` to `303d964`
2023-05-24 00:28:05 +02:00
dependabot[bot]andGitHub 2ab4da0ad9 Bump deps/GSL from afaaa71 to 303d964
Bumps [deps/GSL](https://github.com/microsoft/GSL) from `afaaa71` to `303d964`.
- [Release notes](https://github.com/microsoft/GSL/releases)
- [Commits](https://github.com/microsoft/GSL/compare/afaaa71bcee45d9c90c21f8bd3ba2b12902242e9...303d964a241cb2f2a058fe0baa14013eb9afa116)

---
updated-dependencies:
- dependency-name: deps/GSL
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-05-23 15:04:36 +00:00
dependabot[bot]andGitHub 28c5594094 Bump deps/json from 6af826d to a0c1318
Bumps [deps/json](https://github.com/nlohmann/json) from `6af826d` to `a0c1318`.
- [Release notes](https://github.com/nlohmann/json/releases)
- [Commits](https://github.com/nlohmann/json/compare/6af826d0bdb55e4b69e3ad817576745335f243ca...a0c1318830519eac027a31edec1a99ce1ae5670e)

---
updated-dependencies:
- dependency-name: deps/json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-05-22 15:10:24 +00:00
dependabot[bot]andGitHub 6525bbb8bf Bump deps/gsc-tool from a8a62c2 to f026487
Bumps [deps/gsc-tool](https://github.com/xensik/gsc-tool) from `a8a62c2` to `f026487`.
- [Release notes](https://github.com/xensik/gsc-tool/releases)
- [Commits](https://github.com/xensik/gsc-tool/compare/a8a62c2667ca1c2643798a6c88e39a9e5a30df86...f0264876dffeef28a3fc98f9612c53554df35724)

---
updated-dependencies:
- dependency-name: deps/gsc-tool
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-05-19 15:04:33 +00:00
fedandGitHub 1a9e3dfb15 Merge pull request #24 from fedddddd/dependabot/submodules/deps/minhook-0f25a24
Bump deps/minhook from `98b74f1` to `0f25a24`
2023-05-19 11:00:56 +02:00
fed c62f1995e7 Update generate.bat 2023-05-19 10:49:37 +02:00
dependabot[bot]andGitHub 883e38ae58 Bump deps/minhook from 98b74f1 to 0f25a24
Bumps [deps/minhook](https://github.com/TsudaKageyu/minhook) from `98b74f1` to `0f25a24`.
- [Release notes](https://github.com/TsudaKageyu/minhook/releases)
- [Commits](https://github.com/TsudaKageyu/minhook/compare/98b74f1fc12d00313d91f10450e5b3e0036175e3...0f25a2449b3cf878bcbdbf91b693c38149ecf029)

---
updated-dependencies:
- dependency-name: deps/minhook
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-05-15 15:08:38 +00:00
dependabot[bot]andGitHub 1b2d4dbc46 Merge pull request #20 from fedddddd/dependabot/submodules/deps/json-6af826d 2023-05-13 18:05:49 +00:00
dependabot[bot]andGitHub 7dfb35233e Merge pull request #22 from fedddddd/dependabot/submodules/deps/minhook-98b74f1 2023-05-13 18:04:33 +00:00
dependabot[bot]andGitHub d842022056 Merge pull request #21 from fedddddd/dependabot/submodules/deps/GSL-afaaa71 2023-05-13 18:03:36 +00:00
dependabot[bot]andGitHub 0a8ebc3058 Bump deps/json from e4643d1 to 6af826d
Bumps [deps/json](https://github.com/nlohmann/json) from `e4643d1` to `6af826d`.
- [Release notes](https://github.com/nlohmann/json/releases)
- [Commits](https://github.com/nlohmann/json/compare/e4643d1f1b03fc7a1d7b65f17e012ca93680cad8...6af826d0bdb55e4b69e3ad817576745335f243ca)

---
updated-dependencies:
- dependency-name: deps/json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-05-13 17:58:53 +00:00
dependabot[bot]andGitHub 8ccae5ddec Bump deps/GSL from c31a9ad to afaaa71
Bumps [deps/GSL](https://github.com/microsoft/GSL) from `c31a9ad` to `afaaa71`.
- [Release notes](https://github.com/microsoft/GSL/releases)
- [Commits](https://github.com/microsoft/GSL/compare/c31a9ad5e8e99da8567237a7ba51a7d8f419e5bf...afaaa71bcee45d9c90c21f8bd3ba2b12902242e9)

---
updated-dependencies:
- dependency-name: deps/GSL
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-05-13 17:58:43 +00:00
dependabot[bot]andGitHub cfb143f0fd Bump deps/minhook from 423d1e4 to 98b74f1
Bumps [deps/minhook](https://github.com/TsudaKageyu/minhook) from `423d1e4` to `98b74f1`.
- [Release notes](https://github.com/TsudaKageyu/minhook/releases)
- [Commits](https://github.com/TsudaKageyu/minhook/compare/423d1e45af2ed2719a5c31e990e935ef301ed9c3...98b74f1fc12d00313d91f10450e5b3e0036175e3)

---
updated-dependencies:
- dependency-name: deps/minhook
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-05-13 17:58:38 +00:00
fed 0281b5bef6 Update premake5 2023-05-13 19:53:55 +02:00
fed 70a91b271d Add workflows 2023-05-13 19:51:36 +02:00
fed a7576ea765 Fix for pluto update 2023-05-13 19:50:00 +02:00
fed 3a492f51d9 Update functions.cpp 2023-02-27 01:24:02 +01:00
fed d4ba37cde5 Remove this 2023-02-27 01:20:58 +01:00
fed 2ded4c6a2a Small fix 2023-02-27 01:20:08 +01:00
fed 24b3a9369e Fixes for pluto update 2023-02-27 01:18:50 +01:00
fed 1d94fdd88d Small fix 2022-12-28 01:07:53 +01:00
Federico Cecchetto 0af6b1cb13 Fix for update 2022-07-12 22:12:53 +02:00
Federico Cecchetto d72c6f7057 Fix #16 2022-03-27 23:42:47 +02:00
Federico Cecchetto 39b9e7e352 Small change 2022-03-26 20:03:42 +01:00
Federico Cecchetto 36fefa6bb5 Remove this 2022-03-26 20:01:21 +01:00
Federico Cecchetto 4ffdb331b4 Use signature utils 2022-03-26 19:51:51 +01:00
Federico Cecchetto 7b995b3348 Add some string functions 2022-03-26 00:05:02 +01:00
Federico Cecchetto 14d0f401fb vs2022 build 2022-03-18 01:17:28 +01:00
Federico Cecchetto df23604b1e Update pointers 2022-03-17 19:23:52 +01:00
fedandGitHub e2960bc895 Merge pull request #14 from diamante0018/main
Update Premake5, fix git modules.
2022-02-26 12:13:25 +01:00
Future db90d361a9 tabs 2022-02-26 11:12:55 +00:00
Future 6ec0c5e23c .git 2022-02-26 11:00:11 +00:00
Future c84d681a3a Re add unfricked json 2022-02-26 10:58:51 +00:00
Future 62d1c8671b Re add unfricked json 2022-02-26 10:58:41 +00:00
Future 877adfa4b6 Fix json 2022-02-26 10:54:43 +00:00
Future 12fd44d0da New gsc func + premake5 update 2022-02-26 10:51:20 +00:00
fedandGitHub 12562eb8fd Merge pull request #13 from diamante0018/main
Clean up gsc functions with additional checks
2022-02-25 12:04:16 +01:00
Future 286481cbcd Clean up gsc functions with additional checks 2022-02-24 19:25:58 +00:00
Federico Cecchetto e9a877bd74 Update dllmain.cpp 2022-02-11 19:35:46 +01:00
Federico Cecchetto 3060df1f05 Update pointers 2022-02-07 02:00:15 +01:00
fedandGitHub aa1ae8c574 Merge pull request #12 from diamante0018/main 2022-02-02 15:25:52 +01:00
Future ccd8176c25 Remove assert 2022-02-02 15:24:20 +01:00
Future c230a1d916 Remove incorrect offset comments 2022-02-02 12:47:46 +01:00
Future 2785a60dc0 Add function drop all bots 2022-02-02 12:45:07 +01:00
Federico Cecchetto 1b65bda323 Update pointers 2022-01-29 16:37:04 +01:00
51 changed files with 796 additions and 8667 deletions
+7
View File
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: gitsubmodule
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
+80
View File
@@ -0,0 +1,80 @@
name: Build
on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: false
jobs:
build:
name: Build binaries
runs-on: windows-2022
strategy:
matrix:
configuration:
- Debug
- Release
steps:
- name: Check out files
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
lfs: false
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Generate project files
run: tools/premake5 vs2022
- name: Set up problem matching
uses: ammaraskar/msvc-problem-matcher@master
- name: Build ${{matrix.configuration}} binaries
run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:PlatformTarget=x86 build/iw5-gsc-utils.sln
- name: Upload ${{matrix.configuration}} binaries
uses: actions/upload-artifact@v4
with:
name: ${{matrix.configuration}} binaries
path: |
build/bin/${{matrix.configuration}}/iw5-gsc-utils.dll
deploy:
name: Deploy artifacts
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main')
steps:
- name: Setup main environment
if: github.ref == 'refs/heads/main'
run: echo "ALICE_MASTER_PATH=${{ secrets.ALICE_MASTER_SSH_PATH }}" >> $GITHUB_ENV
- name: Download Release binaries
uses: actions/download-artifact@v4
with:
name: Release binaries
- name: Install SSH key
uses: shimataro/[email protected]
with:
key: ${{ secrets.ALICE_MASTER_SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
- name: Add known hosts
run: ssh-keyscan -H ${{ secrets.ALICE_MASTER_SSH_ADDRESS }} >> ~/.ssh/known_hosts
- name: Remove old data files
run: ssh ${{ secrets.ALICE_MASTER_SSH_USER }}@${{ secrets.ALICE_MASTER_SSH_ADDRESS }} rm -rf ${{ env.ALICE_MASTER_PATH }}/iw5-gsc-utils/*
- name: Upload binary
run: rsync -avz iw5-gsc-utils.dll ${{ secrets.ALICE_MASTER_SSH_USER }}@${{ secrets.ALICE_MASTER_SSH_ADDRESS }}:${{ env.ALICE_MASTER_PATH }}/iw5-gsc-utils/
- name: Publish changes
run: ssh ${{ secrets.ALICE_MASTER_SSH_USER }}@${{ secrets.ALICE_MASTER_SSH_ADDRESS }} ${{ secrets.ALICE_MASTER_SSH_CHANGE_PUBLISH_COMMAND }}
+10 -6
View File
@@ -4,12 +4,16 @@
[submodule "deps/GSL"]
path = deps/GSL
url = https://github.com/microsoft/GSL.git
[submodule "deps/sol2"]
path = deps/sol2
url = https://github.com/ThePhD/sol2.git
[submodule "deps/lua"]
path = deps/lua
url = https://github.com/lua/lua.git
[submodule "deps/json"]
path = deps/json
url = https://github.com/nlohmann/json.git
branch = develop
[submodule "deps/gsc-tool"]
path = deps/gsc-tool
url = https://github.com/xensik/gsc-tool.git
[submodule "deps/zlib"]
path = deps/zlib
url = https://github.com/madler/zlib.git
[submodule "deps/plutonium-sdk"]
path = deps/plutonium-sdk
url = https://github.com/plutoniummod/plutonium-sdk.git
+18 -38
View File
@@ -2,22 +2,13 @@
This plugin adds some useful functions/methods to IW5's GSC VM
# Installation
* Download the latest version [iw5-gsc-utils.dll](https://github.alicent.cat/iw5-gsc-utils/iw5-gsc-utils.dll)
* Copy it to `Plutonium/plugins/`
# Misc
* `executeCommand(command)`: Executes a console command.
* `replaceFunc(what, with)`: Replaces a function with another:
```c
init()
{
replaceFunc(maps\mp\gametypes\_damage::Callback_PlayerDamage, ::callbackPlayerDamage);
}
callbackPlayerDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset)
{
}
```
* `addCommand(name, callback)`: Adds a console command (gets removed after a map restart):
```c
@@ -44,9 +35,6 @@ This plugin adds some useful functions/methods to IW5's GSC VM
}
```
# Player
* `say(message)`: Prints a message to all players' chat.
* `self tell(message)`: Prints a message to the player's chat.
* `self setName(name)`: Sets a player's name.
* `self resetName(name)`: Resets a player's name to its original.
* `self setClantag(name)`: Sets a player's clantag.
@@ -54,28 +42,7 @@ This plugin adds some useful functions/methods to IW5's GSC VM
* `self removeClantag(name)`: Removes a player's clantag.
# IO
The basepath for all IO functions is `Plutonium/storage/iw5`
* `fopen(path, mode)`: Opens a file of given name with given mode, returns a file stream.
* `fwrite(stream, text)`: Writes a string to a stream.
* `fread(stream)`: Reads entire file.
* `fclose(stream)`: Closes a file stream.
* `fremove(path)`: Deletes a file.
```c
init()
{
basePath = getDvar("fs_basegame") + "/";
file = fopen(basePath + "test.txt", "w");
fwrite(file, "test");
fclose(file);
file = fopen(basePath + "test.txt", "r");
print(fread(file));
fclose(file);
}
```
The basepath for all IO functions is `Plutonium/storage/iw5`.
* `fileExists(path)`: Returns true if the file exists.
* `writeFile(path, data[, append])`: Creates a file if it doesn't exist and writes/appends text to it.
* `readFile(path)`: Reads a file.
@@ -86,6 +53,19 @@ The basepath for all IO functions is `Plutonium/storage/iw5`
* `listFiles(path)`: Returns the list of files in the directory as an array.
* `copyFolder(source, target)`: Copies a folder.
# HTTP
* `httpGet(url)`: creates an HTTP request.
```c
init()
{
req = httpget("http://example.com");
req waittill("done", data);
print(data);
}
```
# JSON
* `jsonSerialize(variable[, indent])`: Converts GSC variables (such as arrays) into JSON:
Vendored
+1 -1
Submodule deps/GSL updated: c31a9ad5e8...b39e7e4b09
Vendored
+1 -1
Submodule deps/json updated: e10a3fac8a...d0d29039da
+1 -1
Vendored Submodule
+1
Submodule deps/plutonium-sdk added at 17e9a0a4d5
+18
View File
@@ -0,0 +1,18 @@
plutonium_sdk = {
source = path.join(dependencies.basePath, "plutonium-sdk"),
}
function plutonium_sdk.import()
plutonium_sdk.includes()
end
function plutonium_sdk.includes()
includedirs {
plutonium_sdk.source,
}
end
function plutonium_sdk.project()
end
table.insert(dependencies, plutonium_sdk)
+2 -1
View File
@@ -1,2 +1,3 @@
@echo off
tools\windows\premake5.exe vs2019
call git submodule update --init --recursive
tools\premake5.exe vs2022
+12 -9
View File
@@ -36,32 +36,35 @@ workspace "iw5-gsc-utils"
targetdir "%{wks.location}/bin/%{cfg.buildcfg}"
targetname "%{prj.name}"
configurations { "Debug", "Release", }
language "C++"
cppdialect "C++20"
architecture "x86"
buildoptions "/std:c++latest"
systemversion "latest"
symbols "On"
staticruntime "On"
editandcontinue "Off"
warnings "Extra"
characterset "ASCII"
flags
{
"NoIncrementalLink",
"MultiProcessorCompile",
}
configurations { "Debug", "Release", }
symbols "On"
configuration "Release"
filter "configurations:Release"
optimize "Full"
defines { "NDEBUG" }
configuration{}
filter {}
configuration "Debug"
filter "configurations:Debug"
optimize "Debug"
defines { "DEBUG", "_DEBUG" }
configuration {}
filter {}
startproject "iw5-gsc-utils"
+11 -8
View File
@@ -8,6 +8,8 @@
namespace command
{
std::unordered_map<std::string, std::function<void(params&)>> handlers;
std::vector<std::string> script_commands;
utils::memory::allocator allocator;
void main_handler()
{
@@ -46,9 +48,14 @@ namespace command
for (auto i = index; i < this->size(); i++)
{
if (i > index) result.append(" ");
if (i > index)
{
result.append(" ");
}
result.append(this->get(i));
}
return result;
}
@@ -69,14 +76,11 @@ namespace command
handlers[command] = callback;
}
std::vector<std::string> script_commands;
utils::memory::allocator allocator;
void add_script_command(const std::string& name, const std::function<void(const params&)>& callback)
{
script_commands.push_back(name);
const auto _name = allocator.duplicate_string(name);
add(_name, callback);
const auto name_str = allocator.duplicate_string(name);
add(name_str, callback);
}
void clear_script_commands()
@@ -94,9 +98,8 @@ namespace command
class component final : public component_interface
{
public:
void post_unpack() override
void on_startup([[maybe_unused]] plugin::plugin* plugin) override
{
}
};
}
+1 -1
View File
@@ -25,4 +25,4 @@ namespace command
void add_script_command(const std::string& name, const std::function<void(const params&)>& callback);
void clear_script_commands();
}
}
+101 -163
View File
@@ -14,47 +14,12 @@
namespace gsc
{
std::unordered_map<unsigned, script_function> functions;
std::unordered_map<unsigned, script_method> methods;
namespace
{
std::string method_name(unsigned int id)
{
const auto map = *game::plutonium::method_map_rev;
for (const auto& function : map)
{
if (function.second == id)
{
return function.first;
}
}
return {};
}
std::string function_name(unsigned int id)
{
const auto map = *game::plutonium::function_map_rev;
for (const auto& function : map)
{
if (function.second == id)
{
return function.first;
}
}
return {};
}
function_args get_arguments()
{
std::vector<scripting::script_value> args;
const auto top = game::scr_VmPub->top;
for (auto i = 0; i < game::scr_VmPub->outparamcount; i++)
{
const auto value = game::scr_VmPub->top[-i];
@@ -74,9 +39,6 @@ namespace gsc
scripting::push_value(value);
}
auto function_map_start = 0x200;
auto method_map_start = 0x8400;
auto token_map_start = 0x8000;
auto field_offset_start = 0xA000;
struct entity_field
@@ -89,16 +51,11 @@ namespace gsc
std::vector<std::function<void()>> post_load_callbacks;
std::unordered_map<unsigned int, std::unordered_map<unsigned int, entity_field>> custom_fields;
void call_function(unsigned int id)
void call_function(const script_function* function, const char* name)
{
if (id < 0x200)
{
return reinterpret_cast<builtin_function*>(game::plutonium::function_table.get())[id]();
}
try
{
const auto result = functions[id](get_arguments());
const auto result = function->operator()(get_arguments());
const auto type = result.get_raw().type;
if (type)
@@ -108,23 +65,18 @@ namespace gsc
}
catch (const std::exception& e)
{
printf("************** Script execution error **************\n");
printf("Error executing function %s:\n", function_name(id).data());
printf(" %s\n", e.what());
printf("****************************************************\n");
printf("************** Script execution error **************");
printf("Error executing function %s:", name);
printf(" %s", e.what());
printf("****************************************************");
}
}
void call_method(game::scr_entref_t ent, unsigned int id)
void call_method(const script_method* method, const char* name, game::scr_entref_t ent)
{
if (id < 0x8400)
{
return reinterpret_cast<builtin_method*>(game::plutonium::method_table.get())[id - 0x8000](ent);
}
try
{
const auto result = methods[id](ent, get_arguments());
const auto result = method->operator()(ent, get_arguments());
const auto type = result.get_raw().type;
if (type)
@@ -134,55 +86,10 @@ namespace gsc
}
catch (const std::exception& e)
{
printf("************** Script execution error **************\n");
printf("Error executing method %s:\n", method_name(id).data());
printf(" %s\n", e.what());
printf("****************************************************\n");
}
}
__declspec(naked) void call_builtin_stub()
{
__asm
{
push eax
mov eax, 0x20B4A5C
mov [eax], esi
mov eax, 0x20B4A90
mov [eax], edx
pop eax
pushad
push eax
call call_function
pop eax
popad
push 0x56C900
retn
}
}
__declspec(naked) void call_builtin_method_stub()
{
__asm
{
pushad
push ecx
push ebx
call call_method
pop ebx
pop ecx
popad
push ebx
add esp, 0xC
push 0x56CBE9
retn
printf("************** Script execution error **************");
printf("Error executing method %s:", name);
printf(" %s", e.what());
printf("****************************************************");
}
}
@@ -194,7 +101,7 @@ namespace gsc
return scr_get_object_field_hook.invoke<void>(classnum, entnum, offset);
}
const auto field = custom_fields[classnum][offset];
const auto& field = custom_fields[classnum][offset];
try
{
@@ -203,10 +110,10 @@ namespace gsc
}
catch (const std::exception& e)
{
printf("************** Script execution error **************\n");
printf("Error getting field %s:\n", field.name.data());
printf(" %s\n", e.what());
printf("****************************************************\n");
printf("************** Script execution error **************");
printf("Error getting field %s:", field.name.data());
printf(" %s", e.what());
printf("****************************************************");
}
}
@@ -219,7 +126,7 @@ namespace gsc
}
const auto args = get_arguments();
const auto field = custom_fields[classnum][offset];
const auto& field = custom_fields[classnum][offset];
try
{
@@ -227,10 +134,10 @@ namespace gsc
}
catch (const std::exception& e)
{
printf("************** Script execution error **************\n");
printf("Error setting field %s:\n", field.name.data());
printf(" %s\n", e.what());
printf("****************************************************\n");
printf("************** Script execution error **************");
printf("Error setting field %s:", field.name.data());
printf(" %s", e.what());
printf("****************************************************");
}
}
@@ -246,26 +153,51 @@ namespace gsc
}
}
namespace function
void* make_function_thunk(const char* name, const script_function* func)
{
void add(const std::string& name, const script_function& func)
static std::uint8_t bytes[] =
{
const auto index = function_map_start++;
0x68, 0x44, 0x33, 0x22, 0x11, // push
0x68, 0x44, 0x33, 0x22, 0x11, // push
0x00, 0x00, 0x00, 0x00, 0x00, // call
0x83, 0xC4, 0x08, // add esp, 8
0xC3 // ret
};
functions[index] = func;
(*game::plutonium::function_map_rev)[name] = index;
}
const auto stub = utils::memory::allocate_array<std::uint8_t>(sizeof(bytes));
std::memcpy(stub, bytes, sizeof(bytes));
utils::hook::unprotect(stub, sizeof(bytes));
*reinterpret_cast<std::size_t*>(stub + 1) = reinterpret_cast<size_t>(name);
*reinterpret_cast<std::size_t*>(stub + 6) = reinterpret_cast<size_t>(func);
utils::hook::call(stub + 10, call_function);
return stub;
}
namespace method
void* make_method_thunk(const char* name, const script_method* func)
{
void add(const std::string& name, const script_method& func)
static std::uint8_t bytes[] =
{
const auto index = method_map_start++;
0xFF, 0x74, 0x24, 0x04, // push [esp+4]
0x68, 0x44, 0x33, 0x22, 0x11, // push
0x68, 0x44, 0x33, 0x22, 0x11, // push
0x00, 0x00, 0x00, 0x00, 0x00, // call
0x83, 0xC4, 0x0C, // add esp, 8
0xC3 // ret
};
methods[index] = func;
(*game::plutonium::method_map_rev)[name] = index;
}
const auto stub = utils::memory::allocate_array<std::uint8_t>(sizeof(bytes));
std::memcpy(stub, bytes, sizeof(bytes));
utils::hook::unprotect(stub, sizeof(bytes));
*reinterpret_cast<std::size_t*>(stub + 5) = reinterpret_cast<size_t>(name);
*reinterpret_cast<std::size_t*>(stub + 10) = reinterpret_cast<size_t>(func);
utils::hook::call(stub + 14, call_method);
return stub;
}
namespace field
@@ -274,16 +206,13 @@ namespace gsc
const std::function<scripting::script_value(unsigned int entnum)>& getter,
const std::function<void(unsigned int entnum, const scripting::script_value&)>& setter)
{
const auto token_id = token_map_start++;
const auto offset = field_offset_start++;
custom_fields[classnum][offset] = {name, getter, setter};
(*game::plutonium::token_map_rev)[name] = token_id;
post_load_callbacks.push_back([classnum, name, token_id, offset]()
post_load_callbacks.push_back([=]()
{
const auto name_str = game::SL_GetString(name.data(), 0);
game::Scr_AddClassField(classnum, name_str, token_id, offset);
game::Scr_AddClassField(classnum, name_str, game::SL_GetCanonicalString(name.data()), offset);
});
}
}
@@ -316,13 +245,13 @@ namespace gsc
class component final : public component_interface
{
public:
void post_unpack() override
void on_startup([[maybe_unused]] plugin::plugin* plugin) override
{
scr_get_object_field_hook.create(0x52BDB0, scr_get_object_field_stub);
scr_set_object_field_hook.create(0x52BCC0, scr_set_object_field_stub);
scr_post_load_scripts_hook.create(0x628B50, scr_post_load_scripts_stub);
field::add(classid::entity, "flags",
field::add(classid::entity, "entityflags",
[](unsigned int entnum) -> scripting::script_value
{
const auto entity = &game::g_entities[entnum];
@@ -372,26 +301,17 @@ namespace gsc
return {};
});
function::add("say", [](const function_args& args) -> scripting::script_value
function::add("dropallbots", [](const function_args&) -> scripting::script_value
{
const auto message = args[0].as<std::string>();
game::SV_GameSendServerCommand(-1, 0, utils::string::va("%c \"%s\"", 84, message.data()));
return {};
});
method::add("tell", [](const game::scr_entref_t ent, const function_args& args) -> scripting::script_value
{
if (ent.classnum != 0)
for (auto i = 0; i < *game::svs_clientCount; i++)
{
throw std::runtime_error("Invalid entity");
if (game::svs_clients[i].header.state != game::CS_FREE
&& game::svs_clients[i].header.netchan.remoteAddress.type == game::NA_BOT)
{
game::SV_GameDropClient(i, "GAME_GET_TO_COVER");
}
}
const auto client = ent.entnum;
const auto message = args[0].as<std::string>();
game::SV_GameSendServerCommand(client, 0, utils::string::va("%c \"%s\"", 84, message.data()));
return {};
});
@@ -399,41 +319,59 @@ namespace gsc
{
if (ent.classnum != 0)
{
throw std::runtime_error("Invalid entity");
throw std::runtime_error("invalid entity");
}
const auto client = ent.entnum;
if (game::g_entities[client].client == nullptr)
{
throw std::runtime_error("not a player entity");
}
const auto num = ent.entnum;
const auto toggle = args[0].as<int>();
auto flags = game::g_entities[client].client->ps.perks[0];
auto g_client = game::g_entities[num].client;
auto playerState = &g_client->ps;
auto flags = playerState->perks[0];
playerState->perks[0] = toggle
? flags | 0x4000u
game::g_entities[client].client->ps.perks[0] = toggle
? flags | 0x4000u
: flags & ~0x4000u;
return {};
});
method::add("isbot", [](const game::scr_entref_t ent, const function_args& args) -> scripting::script_value
method::add("isbot", [](const game::scr_entref_t ent, const function_args&) -> scripting::script_value
{
if (ent.classnum != 0)
{
throw std::runtime_error("Invalid entity");
throw std::runtime_error("invalid entity");
}
const auto client = ent.entnum;
if (game::g_entities[client].client == nullptr)
{
throw std::runtime_error("entity is not a player");
throw std::runtime_error("not a player entity");
}
return game::svs_clients[client].bIsTestClient;
});
utils::hook::jump(0x56C8EB, call_builtin_stub);
utils::hook::jump(0x56CBDC, call_builtin_method_stub);
method::add("arecontrolsfrozen", [](const game::scr_entref_t ent, const function_args&) -> scripting::script_value
{
if (ent.classnum != 0)
{
throw std::runtime_error("invalid entity");
}
const auto client = ent.entnum;
if (game::g_entities[client].client == nullptr)
{
throw std::runtime_error("not a player entity");
}
return {(game::g_entities[client].client->flags & 4) != 0};
});
}
};
}
+21 -2
View File
@@ -36,14 +36,33 @@ namespace gsc
using script_function = std::function<scripting::script_value(const function_args&)>;
using script_method = std::function<scripting::script_value(const game::scr_entref_t, const function_args&)>;
void* make_function_thunk(const char* name, const script_function* func);
void* make_method_thunk(const char* name, const script_method* meth);
namespace function
{
void add(const std::string& name, const script_function& func);
template <typename F>
void add(const std::string& name, F&& f)
{
const auto name_str = utils::memory::duplicate_string(name);
const auto func = new script_function(std::forward<F>(f));
const auto thunk = reinterpret_cast<
plutonium::sdk::interfaces::gsc::function_callback>(make_function_thunk(name_str, func));
plugin::get()->get_interface()->gsc()->register_function(name, thunk);
}
}
namespace method
{
void add(const std::string& name, const script_method& func);
template <typename F>
void add(const std::string& name, F&& f)
{
const auto name_str = utils::memory::duplicate_string(name);
const auto func = new script_method(std::forward<F>(f));
const auto thunk = reinterpret_cast<
plutonium::sdk::interfaces::gsc::method_callback>(make_method_thunk(name_str, func));
plugin::get()->get_interface()->gsc()->register_method(name, thunk);
}
}
namespace field
+94 -71
View File
@@ -4,85 +4,118 @@
#include "scheduler.hpp"
#include "gsc.hpp"
#include "json.hpp"
#include "scripting.hpp"
namespace io
{
namespace
{
struct http_request_t
{
std::string url;
bool completed;
std::string result;
scripting::entity handle;
};
utils::concurrency::container<std::vector<http_request_t>> requests;
void run_requests()
{
requests.access([&](std::vector<http_request_t>& r)
{
for (auto& request : r)
{
const auto data = utils::http::get_data(request.url.data());
if (data.has_value())
{
request.result = data->substr(0, 0x5000);
}
else
{
request.result = "";
}
request.completed = true;
}
});
}
void check_requests()
{
requests.access([&](std::vector<http_request_t>& r)
{
for (auto i = r.begin(); i != r.end(); )
{
if (!i->completed)
{
++i;
continue;
}
else
{
scripting::notify(i->handle, "done", {i->result});
i = r.erase(i);
}
}
});
}
void add_request(const std::string& url, const scripting::entity& handle)
{
requests.access([&](std::vector<http_request_t>& r)
{
http_request_t request{};
request.handle = handle;
request.url = url;
request.completed = false;
r.emplace_back(request);
});
}
}
class component final : public component_interface
{
public:
void post_unpack() override
void on_after_dvar_init([[maybe_unused]] plugin::plugin* plugin) override
{
const auto path = game::Dvar_FindVar("fs_basegame")->current.string;
std::filesystem::current_path(path);
const auto fs_basegame = game::Dvar_FindVar("fs_basegame");
if (fs_basegame == nullptr)
{
return;
}
printf("working directory: %s", fs_basegame->current.string);
std::filesystem::current_path(fs_basegame->current.string);
}
void on_startup([[maybe_unused]] plugin::plugin* plugin) override
{
scheduler::loop(run_requests, scheduler::async);
scheduler::loop(check_requests, scheduler::server);
scripting::on_shutdown([]()
{
requests.access([&](std::vector<http_request_t>& r)
{
r.clear();
});
});
gsc::function::add("jsonprint", [](const gsc::function_args& args) -> scripting::script_value
{
std::string buffer;
for (const auto arg : args.get_raw())
for (const auto& arg : args.get_raw())
{
buffer.append(json::gsc_to_string(arg));
buffer.append("\t");
}
printf("%s\n", buffer.data());
printf("%s", buffer.data());
return {};
});
gsc::function::add("fremove", [](const gsc::function_args& args)
{
const auto path = args[0].as<const char*>();
return std::remove(path);
});
gsc::function::add("fopen", [](const gsc::function_args& args)
{
const auto* path = args[0].as<const char*>();
const auto* mode = args[1].as<const char*>();
const auto handle = fopen(path, mode);
if (!handle)
{
printf("fopen: Invalid path\n");
}
return handle;
});
gsc::function::add("fclose", [](const gsc::function_args& args)
{
const auto handle = args[0].as_ptr<FILE>();
return fclose(handle);
});
gsc::function::add("fwrite", [](const gsc::function_args& args)
{
const auto handle = args[0].as_ptr<FILE>();
const auto text = args[1].as<const char*>();
return fprintf(handle, text);
});
gsc::function::add("fread", [](const gsc::function_args& args)
{
const auto handle = args[0].as_ptr<FILE>();
fseek(handle, 0, SEEK_END);
const auto length = ftell(handle);
fseek(handle, 0, SEEK_SET);
char* buffer = (char*)calloc(length, sizeof(char));
fread(buffer, sizeof(char), length, handle);
const std::string result = buffer;
free(buffer);
return result;
});
gsc::function::add("fileexists", [](const gsc::function_args& args)
{
const auto path = args[0].as<std::string>();
@@ -161,17 +194,7 @@ namespace io
const auto url = args[0].as<std::string>();
const auto object = scripting::entity(scripting::make_object());
scheduler::once([object, url]()
{
const auto result = utils::http::get_data(url.data());
scheduler::once([object, result]()
{
const auto value = result.has_value()
? result.value().substr(0, 0x5000)
: "";
scripting::notify(object, "done", {value});
});
}, scheduler::pipeline::async);
add_request(url, object);
return object;
});
@@ -179,4 +202,4 @@ namespace io
};
}
REGISTER_COMPONENT(io::component)
REGISTER_COMPONENT(io::component)
+2 -2
View File
@@ -144,7 +144,7 @@ namespace json
class component final : public component_interface
{
public:
void post_unpack() override
void on_startup([[maybe_unused]] plugin::plugin* plugin) override
{
gsc::function::add("array", [](const gsc::function_args& args)
{
@@ -194,4 +194,4 @@ namespace json
};
}
REGISTER_COMPONENT(json::component)
REGISTER_COMPONENT(json::component)
-68
View File
@@ -1,68 +0,0 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "scheduler.hpp"
#include "gsc.hpp"
#include "scripting.hpp"
namespace notifies
{
namespace
{
std::vector<scripting::function> say_callbacks;
utils::hook::detour client_command_hook;
void client_command_stub(int clientNum)
{
char cmd[1024] = { 0 };
game::SV_Cmd_ArgvBuffer(0, cmd, 1024);
auto hidden = false;
if (cmd == "say"s || cmd == "say_team"s)
{
std::string message = game::ConcatArgs(1);
message.erase(0, 1);
for (const auto& callback : say_callbacks)
{
const auto entity_id = game::Scr_GetEntityId(clientNum, 0);
const auto result = callback(entity_id, {message, cmd == "say_team"s});
if (result.is<int>() && !hidden)
{
hidden = result.as<int>() == 0;
}
}
}
if (!hidden)
{
client_command_hook.invoke<void>(clientNum);
}
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
client_command_hook.create(0x502CB0, client_command_stub);
scripting::on_shutdown([]()
{
say_callbacks.clear();
});
gsc::function::add("onplayersay", [](const gsc::function_args& args) -> scripting::script_value
{
const auto function = args[0].as<scripting::function>();
say_callbacks.push_back(function);
return {};
});
}
};
}
REGISTER_COMPONENT(notifies::component)
+13 -2
View File
@@ -77,6 +77,7 @@ namespace scheduler
};
std::thread thread;
std::atomic_bool killed;
task_pipeline pipelines[pipeline::count];
void execute(const pipeline type)
@@ -128,11 +129,11 @@ namespace scheduler
class component final : public component_interface
{
public:
void post_unpack() override
void on_startup([[maybe_unused]] plugin::plugin* plugin) override
{
thread = std::thread([]()
{
while (true)
while (!killed)
{
execute(pipeline::async);
std::this_thread::sleep_for(10ms);
@@ -141,6 +142,16 @@ namespace scheduler
utils::hook::call(0x50CEDC, server_frame_stub);
}
void on_shutdown([[maybe_unused]] plugin::plugin* plugin) override
{
killed = true;
if (thread.joinable())
{
thread.join();
}
}
};
}
+2 -90
View File
@@ -13,68 +13,12 @@
namespace scripting
{
std::unordered_map<int, std::unordered_map<std::string, int>> fields_table;
std::unordered_map<std::string, std::unordered_map<std::string, const char*>> script_function_table;
namespace
{
utils::hook::detour vm_notify_hook;
utils::hook::detour scr_add_class_field_hook;
utils::hook::detour scr_load_level_hook;
utils::hook::detour g_shutdown_game_hook;
utils::hook::detour scr_set_thread_position_hook;
utils::hook::detour process_script_hook;
std::string current_file;
std::vector<std::function<void()>> shutdown_callbacks;
void vm_notify_stub(const unsigned int notify_list_owner_id, const unsigned int string_value,
game::VariableValue* top)
{
const auto* name = game::SL_ConvertToString(string_value);
if (name)
{
event e;
e.name = name;
e.entity = notify_list_owner_id;
for (auto* value = top; value->type != game::SCRIPT_END; --value)
{
e.arguments.emplace_back(*value);
}
if (e.name == "connected")
{
const auto player = e.arguments[0].as<scripting::entity>();
const auto client = player.call("getentitynumber").as<int>();
userinfo::clear_client_overrides(client);
}
}
vm_notify_hook.invoke<void>(notify_list_owner_id, string_value, top);
}
void scr_add_class_field_stub(unsigned int classnum, unsigned int _name, unsigned int canonicalString, unsigned int offset)
{
const auto name = game::SL_ConvertToString(_name);
if (fields_table[classnum].find(name) == fields_table[classnum].end())
{
fields_table[classnum][name] = offset;
}
scr_add_class_field_hook.invoke<void>(classnum, _name, canonicalString, offset);
}
void scr_load_level_stub()
{
scr_load_level_hook.invoke<void>();
}
void g_shutdown_game_stub(const int free_scripts)
{
userinfo::clear_overrides();
@@ -87,31 +31,6 @@ namespace scripting
g_shutdown_game_hook.invoke<void>(free_scripts);
}
void process_script_stub(const char* filename)
{
current_file = filename;
const auto file_id = atoi(filename);
if (file_id)
{
current_file = scripting::file_list[file_id];
}
process_script_hook.invoke<void>(filename);
}
void scr_set_thread_position_stub(unsigned int threadName, const char* codePos)
{
const auto function_name = scripting::find_token(threadName);
if (!function_name.empty())
{
script_function_table[current_file][function_name] = codePos;
}
scr_set_thread_position_hook.invoke<void>(threadName, codePos);
}
}
void on_shutdown(const std::function<void()>& callback)
@@ -122,18 +41,11 @@ namespace scripting
class component final : public component_interface
{
public:
void post_unpack() override
void on_startup([[maybe_unused]] plugin::plugin* plugin) override
{
scr_load_level_hook.create(0x527AF0, scr_load_level_stub);
g_shutdown_game_hook.create(0x50C100, g_shutdown_game_stub);
scr_add_class_field_hook.create(0x567CD0, scr_add_class_field_stub);
vm_notify_hook.create(0x569720, vm_notify_stub);
scr_set_thread_position_hook.create(0x5616D0, scr_set_thread_position_stub);
process_script_hook.create(0x56B130, process_script_stub);
}
};
}
REGISTER_COMPONENT(scripting::component)
REGISTER_COMPONENT(scripting::component)
-3
View File
@@ -2,8 +2,5 @@
namespace scripting
{
extern std::unordered_map<int, std::unordered_map<std::string, int>> fields_table;
extern std::unordered_map<std::string, std::unordered_map<std::string, const char*>> script_function_table;
void on_shutdown(const std::function<void()>& callback);
}
+41
View File
@@ -0,0 +1,41 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "gsc.hpp"
#include <utils/string.hpp>
namespace string
{
class component final : public component_interface
{
public:
void on_startup([[maybe_unused]] plugin::plugin* plugin) override
{
gsc::function::add("getchar", [](const gsc::function_args& args)
{
auto index = 0;
if (args.size() > 1)
{
index = args[1].as<int>();
}
const auto string = args[0].as<std::string>();
if (index >= static_cast<int>(string.size()))
{
throw std::runtime_error("char index out of bounds");
}
return static_cast<int>(string[index]);
});
gsc::function::add("chartostring", [](const gsc::function_args& args)
{
const auto char_ = static_cast<char>(args[0].as<int>());
return std::string(1, char_);
});
}
};
}
REGISTER_COMPONENT(string::component)
+51 -23
View File
@@ -71,11 +71,11 @@ namespace userinfo
const auto userinfo = map_to_userinfo(map);
strcpy_s(buffer, 1024, userinfo.data());
}
}
void clear_client_overrides(int client)
{
userinfo_overrides[client].clear();
void clear_client_overrides(unsigned int client)
{
userinfo_overrides[client].clear();
}
}
void clear_overrides()
@@ -86,30 +86,43 @@ namespace userinfo
class component final : public component_interface
{
public:
void post_unpack() override
void on_startup([[maybe_unused]] plugin::plugin* plugin) override
{
sv_getuserinfo_hook.create(0x573E00, sv_getuserinfo_stub);
plugin->get_interface()->callbacks()->on_player_connect(clear_client_overrides);
plugin->get_interface()->callbacks()->on_player_disconnect(clear_client_overrides);
gsc::method::add("setname", [](const game::scr_entref_t ent, const gsc::function_args& args) -> scripting::script_value
{
const auto name = args[0].as<std::string>();
if (ent.classnum != 0 || ent.entnum > 17)
if (ent.classnum != 0)
{
throw std::runtime_error("Invalid entity");
throw std::runtime_error("invalid entity");
}
if (game::g_entities[ent.entnum].client == nullptr)
{
throw std::runtime_error("not a player entity");
}
const auto name = args[0].as<std::string>();
userinfo_overrides[ent.entnum]["name"] = name;
game::ClientUserinfoChanged(ent.entnum);
return {};
});
gsc::method::add("resetname", [](const game::scr_entref_t ent, const gsc::function_args& args) -> scripting::script_value
gsc::method::add("resetname", [](const game::scr_entref_t ent, const gsc::function_args&) -> scripting::script_value
{
if (ent.classnum != 0 || ent.entnum > 17)
if (ent.classnum != 0)
{
throw std::runtime_error("Invalid entity");
throw std::runtime_error("invalid entity");
}
if (game::g_entities[ent.entnum].client == nullptr)
{
throw std::runtime_error("not a player entity");
}
userinfo_overrides[ent.entnum].erase("name");
@@ -120,13 +133,18 @@ namespace userinfo
gsc::method::add("setclantag", [](const game::scr_entref_t ent, const gsc::function_args& args) -> scripting::script_value
{
const auto name = args[0].as<std::string>();
if (ent.classnum != 0 || ent.entnum > 17)
if (ent.classnum != 0)
{
throw std::runtime_error("Invalid entity");
throw std::runtime_error("invalid entity");
}
if (game::g_entities[ent.entnum].client == nullptr)
{
throw std::runtime_error("not a player entity");
}
const auto name = args[0].as<std::string>();
userinfo_overrides[ent.entnum]["clantag"] = name;
userinfo_overrides[ent.entnum]["ec_TagText"] = name;
userinfo_overrides[ent.entnum]["ec_usingTag"] = "1";
@@ -135,11 +153,16 @@ namespace userinfo
return {};
});
gsc::method::add("resetclantag", [](const game::scr_entref_t ent, const gsc::function_args& args) -> scripting::script_value
gsc::method::add("resetclantag", [](const game::scr_entref_t ent, const gsc::function_args&) -> scripting::script_value
{
if (ent.classnum != 0 || ent.entnum > 17)
if (ent.classnum != 0)
{
throw std::runtime_error("Invalid entity");
throw std::runtime_error("invalid entity");
}
if (game::g_entities[ent.entnum].client == nullptr)
{
throw std::runtime_error("not a player entity");
}
userinfo_overrides[ent.entnum].erase("clantag");
@@ -150,11 +173,16 @@ namespace userinfo
return {};
});
gsc::method::add("removeclantag", [](const game::scr_entref_t ent, const gsc::function_args& args) -> scripting::script_value
gsc::method::add("removeclantag", [](const game::scr_entref_t ent, const gsc::function_args&) -> scripting::script_value
{
if (ent.classnum != 0 || ent.entnum > 17)
if (ent.classnum != 0)
{
throw std::runtime_error("Invalid entity");
throw std::runtime_error("invalid entity");
}
if (game::g_entities[ent.entnum].client == nullptr)
{
throw std::runtime_error("not a player entity");
}
userinfo_overrides[ent.entnum]["clantag"] = "";
@@ -168,4 +196,4 @@ namespace userinfo
};
}
REGISTER_COMPONENT(userinfo::component)
REGISTER_COMPONENT(userinfo::component)
+14 -14
View File
@@ -1,24 +1,24 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
#include "plugin.hpp"
PLUTONIUM_API plutonium::sdk::plugin* PLUTONIUM_CALLBACK on_initialize()
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
return plugin::get();
}
BOOL APIENTRY DllMain(HMODULE /*module*/, DWORD reason, LPVOID /*reserved*/)
{
if (reason == DLL_PROCESS_ATTACH)
{
const auto value = *reinterpret_cast<DWORD*>(0x21000000);
if (value != 0x7AC6)
{
MessageBoxA(NULL,
"This version of iw5-gsc-utils is outdated.\n" \
"Download the latest dll from here: https://github.com/fedddddd/iw5-gsc-utils/releases" \
, "ERROR", MB_ICONERROR);
return FALSE;
}
}
utils::hook::jump(reinterpret_cast<uintptr_t>(&printf), game::plutonium::printf);
component_loader::post_unpack();
if (reason == DLL_PROCESS_DETACH)
{
component_loader::on_shutdown();
}
return TRUE;
}
}
+7 -1
View File
@@ -2,5 +2,11 @@
namespace game
{
void SV_GameDropClient(int clientNum, const char* reason)
{
if (clientNum >= 0 && clientNum < sv_maxclients->current.integer)
{
SV_DropClient(&svs_clients[clientNum], reason, true);
}
}
}
+7
View File
@@ -16,6 +16,11 @@ namespace game
return dedi_;
}
void set(const size_t dedi)
{
this->dedi_ = reinterpret_cast<T*>(dedi);
}
operator T* () const
{
return this->get();
@@ -29,6 +34,8 @@ namespace game
private:
T* dedi_;
};
void SV_GameDropClient(int clientNum, const char* reason);
}
#include "symbols.hpp"
+4 -8
View File
@@ -212,8 +212,6 @@ namespace scripting
{
return this->get(key.as<std::string>());
}
return {};
}
script_value array::get(const std::string& key) const
@@ -263,11 +261,9 @@ namespace scripting
}
}
void array::set(const std::string& key, const script_value& _value) const
void array::set(const std::string& key, const script_value& value_) const
{
const auto value = _value.get_raw();
const auto string_value = game::SL_GetString(key.data(), 0);
const auto value = value_.get_raw();
const auto variable_id = this->get_value_id(key);
if (!variable_id)
@@ -284,9 +280,9 @@ namespace scripting
variable->u.u = value.u;
}
void array::set(const unsigned int index, const script_value& _value) const
void array::set(const unsigned int index, const script_value& value_) const
{
const auto value = _value.get_raw();
const auto value = value_.get_raw();
const auto variable_id = this->get_value_id(index);
if (!variable_id)
-16
View File
@@ -96,20 +96,4 @@ namespace scripting
game::RemoveRefToValue(game::SCRIPT_OBJECT, {static_cast<int>(this->entity_id_)});
}
}
void entity::set(const std::string& field, const script_value& value) const
{
set_entity_field(*this, field, value);
}
template <>
script_value entity::get<script_value>(const std::string& field) const
{
return get_entity_field(*this, field);
}
script_value entity::call(const std::string& name, const std::vector<script_value>& arguments) const
{
return call_function(name, *this, arguments);
}
}
-16
View File
@@ -18,13 +18,6 @@ namespace scripting
entity& operator=(const entity& other);
entity& operator=(entity&& other) noexcept;
void set(const std::string& field, const script_value& value) const;
template <typename T = script_value>
T get(const std::string& field) const;
script_value call(const std::string& name, const std::vector<script_value>& arguments = {}) const;
unsigned int get_entity_id() const;
game::scr_entref_t get_entity_reference() const;
@@ -37,13 +30,4 @@ namespace scripting
void add() const;
void release() const;
};
template <>
script_value entity::get(const std::string& field) const;
template <typename T>
T entity::get(const std::string& field) const
{
return this->get<script_value>(field).as<T>();
}
}
-170
View File
@@ -1,6 +1,5 @@
#include <stdinc.hpp>
#include "execution.hpp"
#include "safe_execution.hpp"
#include "stack_isolation.hpp"
#include "event.hpp"
@@ -32,16 +31,6 @@ namespace scripting
return script_value(game::scr_VmPub->top[1 - game::scr_VmPub->outparamcount]);
}
int get_field_id(const int classnum, const std::string& field)
{
if (scripting::fields_table[classnum].find(field) != scripting::fields_table[classnum].end())
{
return scripting::fields_table[classnum][field];
}
return -1;
}
void scr_notify_id(int id, unsigned int stringValue, unsigned int paramcount)
{
if (game::scr_VmPub->outparamcount)
@@ -95,47 +84,6 @@ namespace scripting
scr_notify_id(entity.get_entity_id(), event_id, game::scr_VmPub->inparamcount);
}
script_value call_function(const std::string& name, const entity& entity,
const std::vector<script_value>& arguments)
{
const auto entref = entity.get_entity_reference();
const auto is_method_call = *reinterpret_cast<const int*>(&entref) != -1;
const auto function = find_function(name, !is_method_call);
if (!function)
{
throw std::runtime_error("Unknown function '" + name + "'");
}
stack_isolation _;
for (auto i = arguments.rbegin(); i != arguments.rend(); ++i)
{
push_value(*i);
}
game::scr_VmPub->outparamcount = game::scr_VmPub->inparamcount;
game::scr_VmPub->inparamcount = 0;
if (!safe_execution::call(function, entref))
{
throw std::runtime_error("Error executing function '" + name + "'");
}
return get_return_value();
}
script_value call_function(const std::string& name, const std::vector<script_value>& arguments)
{
return call_function(name, entity(), arguments);
}
template <>
script_value call(const std::string& name, const std::vector<script_value>& arguments)
{
return call_function(name, arguments);
}
script_value exec_ent_thread(const entity& entity, const char* pos, const std::vector<script_value>& arguments)
{
const auto id = entity.get_entity_id();
@@ -155,124 +103,6 @@ namespace scripting
return get_return_value();
}
const char* get_function_pos(const std::string& filename, const std::string& function)
{
if (scripting::script_function_table.find(filename) == scripting::script_function_table.end())
{
throw std::runtime_error("File '" + filename + "' not found");
};
const auto functions = scripting::script_function_table[filename];
if (functions.find(function) == functions.end())
{
throw std::runtime_error("Function '" + function + "' in file '" + filename + "' not found");
}
return functions.at(function);
}
script_value call_script_function(const entity& entity, const std::string& filename,
const std::string& function, const std::vector<script_value>& arguments)
{
const auto pos = get_function_pos(filename, function);
return exec_ent_thread(entity, pos, arguments);
}
static std::unordered_map<unsigned int, std::unordered_map<std::string, script_value>> custom_fields;
script_value get_custom_field(const entity& entity, const std::string& field)
{
auto fields = custom_fields[entity.get_entity_id()];
const auto _field = fields.find(field);
if (_field != fields.end())
{
return _field->second;
}
return {};
}
void set_custom_field(const entity& entity, const std::string& field, const script_value& value)
{
const auto id = entity.get_entity_id();
if (custom_fields[id].find(field) != custom_fields[id].end())
{
custom_fields[id][field] = value;
return;
}
custom_fields[id].insert(std::make_pair(field, value));
}
void clear_entity_fields(const entity& entity)
{
const auto id = entity.get_entity_id();
if (custom_fields.find(id) != custom_fields.end())
{
custom_fields[id].clear();
}
}
void clear_custom_fields()
{
custom_fields.clear();
}
void set_entity_field(const entity& entity, const std::string& field, const script_value& value)
{
const auto entref = entity.get_entity_reference();
const int id = get_field_id(entref.classnum, field);
if (id != -1)
{
stack_isolation _;
push_value(value);
game::scr_VmPub->outparamcount = game::scr_VmPub->inparamcount;
game::scr_VmPub->inparamcount = 0;
if (!safe_execution::set_entity_field(entref, id))
{
throw std::runtime_error("Failed to set value for field '" + field + "'");
}
}
else
{
set_custom_field(entity, field, value);
}
}
script_value get_entity_field(const entity& entity, const std::string& field)
{
const auto entref = entity.get_entity_reference();
const auto id = get_field_id(entref.classnum, field);
if (id != -1)
{
stack_isolation _;
game::VariableValue value{};
if (!safe_execution::get_entity_field(entref, id, &value))
{
throw std::runtime_error("Failed to get value for field '" + field + "'");
}
const auto __ = gsl::finally([value]()
{
game::RemoveRefToValue(value.type, value.u);
});
return value;
}
else
{
return get_custom_field(entity, field);
}
return {};
}
unsigned int make_array()
{
unsigned int index = 0;
-12
View File
@@ -9,10 +9,6 @@ namespace scripting
{
void push_value(const script_value& value);
script_value call_function(const std::string& name, const std::vector<script_value>& arguments);
script_value call_function(const std::string& name, const entity& entity,
const std::vector<script_value>& arguments);
template <typename T = script_value>
T call(const std::string& name, const std::vector<script_value>& arguments = {});
@@ -26,14 +22,6 @@ namespace scripting
}
script_value exec_ent_thread(const entity& entity, const char* pos, const std::vector<script_value>& arguments);
script_value call_script_function(const entity& entity, const std::string& filename,
const std::string& function, const std::vector<script_value>& arguments);
void clear_entity_fields(const entity& entity);
void clear_custom_fields();
void set_entity_field(const entity& entity, const std::string& field, const script_value& value);
script_value get_entity_field(const entity& entity, const std::string& field);
void notify(const entity& entity, const std::string& event, const std::vector<script_value>& arguments);
File diff suppressed because it is too large Load Diff
-97
View File
@@ -5,102 +5,5 @@
namespace scripting
{
namespace
{
std::unordered_map<std::string, unsigned> lowercase_map(
const std::unordered_map<std::string, unsigned>& old_map)
{
std::unordered_map<std::string, unsigned> new_map{};
for (auto& entry : old_map)
{
new_map[utils::string::to_lower(entry.first)] = entry.second;
}
return new_map;
}
const std::unordered_map<std::string, unsigned>& get_methods()
{
static auto methods = lowercase_map(method_map);
return methods;
}
const std::unordered_map<std::string, unsigned>& get_functions()
{
static auto function = lowercase_map(function_map);
return function;
}
int find_function_index(const std::string& name, const bool prefer_global)
{
const auto target = utils::string::to_lower(name);
const auto& primary_map = prefer_global
? get_functions()
: get_methods();
const auto& secondary_map = !prefer_global
? get_functions()
: get_methods();
auto function_entry = primary_map.find(target);
if (function_entry != primary_map.end())
{
return function_entry->second;
}
function_entry = secondary_map.find(target);
if (function_entry != secondary_map.end())
{
return function_entry->second;
}
return -1;
}
script_function get_function_by_index(const unsigned index)
{
static const auto function_table = game::plutonium::function_table.get();
static const auto method_table = game::plutonium::method_table.get();
if (index < 0x1C7)
{
return reinterpret_cast<script_function*>(function_table)[index];
}
return reinterpret_cast<script_function*>(method_table)[index - 0x8000];
}
}
std::string find_token(unsigned int id)
{
for (const auto& token : token_map)
{
if (token.second == id)
{
return token.first;
}
}
return {};
}
int find_token_id(const std::string& name)
{
const auto result = token_map.find(name);
if (result != token_map.end())
{
return result->second;
}
return -1;
}
script_function find_function(const std::string& name, const bool prefer_global)
{
const auto index = find_function_index(name, prefer_global);
if (index < 0) return nullptr;
return get_function_by_index(index);
}
}
-9
View File
@@ -3,14 +3,5 @@
namespace scripting
{
extern std::unordered_map<std::string, unsigned> method_map;
extern std::unordered_map<std::string, unsigned> function_map;
extern std::unordered_map<std::string, unsigned> token_map;
extern std::unordered_map<unsigned, std::string> file_list;
using script_function = void(*)(game::scr_entref_t);
script_function find_function(const std::string& name, const bool prefer_global);
int find_token_id(const std::string& name);
std::string find_token(unsigned int id);
}
-74
View File
@@ -1,74 +0,0 @@
#include <stdinc.hpp>
#include "safe_execution.hpp"
#pragma warning(push)
#pragma warning(disable: 4611)
namespace scripting::safe_execution
{
namespace
{
bool execute_with_seh(const script_function function, const game::scr_entref_t& entref)
{
__try
{
function(entref);
return true;
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
return false;
}
}
}
bool call(const script_function function, const game::scr_entref_t& entref)
{
*game::g_script_error_level += 1;
if (game::_setjmp(&game::g_script_error[*game::g_script_error_level], 0, 0, 0))
{
*game::g_script_error_level -= 1;
return false;
}
const auto result = execute_with_seh(function, entref);
*game::g_script_error_level -= 1;
return result;
}
bool set_entity_field(const game::scr_entref_t& entref, const int offset)
{
*game::g_script_error_level += 1;
if (game::_setjmp(&game::g_script_error[*game::g_script_error_level], 0, 0, 0))
{
*game::g_script_error_level -= 1;
return false;
}
game::Scr_SetObjectField(entref.classnum, entref.entnum, offset);
*game::g_script_error_level -= 1;
return true;
}
bool get_entity_field(const game::scr_entref_t& entref, const int offset, game::VariableValue* value)
{
*game::g_script_error_level += 1;
if (game::_setjmp(&game::g_script_error[*game::g_script_error_level], 0, 0, 0))
{
value->type = game::SCRIPT_NONE;
value->u.intValue = 0;
*game::g_script_error_level -= 1;
return false;
}
const auto _value = game::GetEntityFieldValue(entref.classnum, entref.entnum, offset);
value->type = _value.type;
value->u = _value.u;
*game::g_script_error_level -= 1;
return true;
}
}
#pragma warning(pop)
-10
View File
@@ -1,10 +0,0 @@
#pragma once
#include "functions.hpp"
namespace scripting::safe_execution
{
bool call(script_function function, const game::scr_entref_t& entref);
bool set_entity_field(const game::scr_entref_t& entref, int offset);
bool get_entity_field(const game::scr_entref_t& entref, int offset, game::VariableValue* value);
}
+91 -3
View File
@@ -26,20 +26,35 @@ namespace game
const char** argv[8];
};
enum netsrc_t
{
NS_CLIENT1 = 0x0,
NS_CLIENT2 = 0x1,
NS_CLIENT3 = 0x2,
NS_CLIENT4 = 0x3,
NS_MAXCLIENTS = 0x4,
NS_SERVER = 0x4,
NS_PACKET = 0x5,
NS_INVALID_NETSRC = 0x6
};
struct msg_t
{
int overflowed;
int readOnly;
char* data;
char* splitData;
unsigned char* data;
unsigned char* splitData;
int maxsize;
int cursize;
int splitSize;
int readcount;
int bit;
int lastEntityRef;
netsrc_t targetLocalNetID;
};
static_assert(sizeof(msg_t) == 0x2C);
struct XZoneInfo
{
const char* name;
@@ -328,9 +343,82 @@ namespace game
char __pad2[0xEC];
};
enum netadrtype_t
{
NA_BOT = 0x0,
NA_BAD = 0x1,
NA_LOOPBACK = 0x2,
NA_BROADCAST = 0x3,
NA_IP = 0x4
};
struct netadr_s
{
netadrtype_t type;
unsigned char ip[4];
unsigned __int16 port;
unsigned char ipx[10];
unsigned int addrHandleIndex;
};
static_assert(sizeof(netadr_s) == 24);
struct netchan_t
{
int outgoingSequence;
netsrc_t sock;
int dropped;
int incomingSequence;
netadr_s remoteAddress;
int qport;
int fragmentSequence;
int fragmentLength;
unsigned char* fragmentBuffer;
int fragmentBufferSize;
int unsentFragments;
int unsentFragmentStart;
int unsentLength;
unsigned char* unsentBuffer;
int unsentBufferSize;
unsigned char __pad0[0x5E0];
};
static_assert(sizeof(netchan_t) == 0x630);
enum clientState_t
{
CS_FREE = 0,
CS_ZOMBIE = 1,
CS_RECONNECTING = 2,
CS_CONNECTED = 3,
CS_CLIENTLOADING = 4,
CS_ACTIVE = 5
};
struct clientHeader_t
{
clientState_t state; // 0
int sendAsActive; // 4
int deltaMessage; // 8
int rateDealyed; // 12
int hasAckedBaselineData; // 16
int hugeSnapshotSent; // 20
netchan_t netchan; // 24
vec3_t predictedOrigin;
int predictedOriginServerTime;
int migrationState;
vec3_t predictedVehicleOrigin;
int predictedVehicleServerTime;
};
static_assert(sizeof(clientHeader_t) == 0x66C);
struct client_s
{
char __pad0[0x41CB2];
clientHeader_t header;
const char* dropReason;
char userinfo[1024];
char __pad0[0x41242];
unsigned __int16 scriptId; // 269490
int bIsTestClient; // 269492
int serverId; // 269496
+4 -13
View File
@@ -25,8 +25,6 @@ namespace game
WEAK symbol<const dvar_t*(const char*)> Dvar_FindVar{0x5BDCC0};
WEAK symbol<char*(const char*)> I_CleanStr{0x0};
WEAK symbol<VariableValue(unsigned int classnum, int entnum, int offset)> GetEntityFieldValue{0x56AF20};
WEAK symbol<unsigned int(unsigned int parentId, unsigned int name)> FindVariable{0x5651F0};
WEAK symbol<unsigned int(unsigned int parentId, unsigned int name)> FindObject{0x565BD0};
@@ -57,6 +55,7 @@ namespace game
WEAK symbol<void(int clientNum, int type, const char* command)> SV_GameSendServerCommand{0x573220};
WEAK symbol<void(int arg, char* buffer, int bufferLength)> SV_Cmd_ArgvBuffer{0x5459F0};
WEAK symbol<void(client_s* drop, const char* reason, bool tellThem)> SV_DropClient{0x570980};
WEAK symbol<void(unsigned int notifyListOwnerId, unsigned int stringValue, VariableValue* top)> VM_Notify{0x569720};
WEAK symbol<unsigned int(unsigned int localId, const char* pos, unsigned int paramcount)> VM_Execute{0x56DFE0};
@@ -79,15 +78,7 @@ namespace game
WEAK symbol<gentity_s> g_entities{0x1A66E28};
WEAK symbol<unsigned int> levelEntityId{0x208E1A4};
WEAK symbol<dvar_t> sv_maxclients{0x1BA0E4C};
WEAK symbol<int> svs_clientCount{0x4B5CF8C};
WEAK symbol<client_s> svs_clients{0x4B5CF90};
namespace plutonium
{
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> function_map_rev{0x206964D0};
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> method_map_rev{0x206964F0};
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> token_map_rev{0x20696530};
WEAK symbol<int(const char* fmt, ...)> printf{0x20887840};
WEAK symbol<void*> function_table{0x2068F210};
WEAK symbol<void*> method_table{0x2068F9E0};
}
}
}
+6 -6
View File
@@ -1,4 +1,5 @@
#pragma once
#include "../plugin.hpp"
class component_interface
{
@@ -7,25 +8,24 @@ public:
{
}
virtual void post_start()
virtual void on_startup([[maybe_unused]] plugin::plugin* plugin)
{
}
virtual void post_load()
virtual void on_dvar_init([[maybe_unused]] plugin::plugin* plugin)
{
}
virtual void pre_destroy()
virtual void on_after_dvar_init([[maybe_unused]] plugin::plugin* plugin)
{
}
virtual void post_unpack()
virtual void on_game_init([[maybe_unused]] plugin::plugin* plugin)
{
}
virtual void* load_import([[maybe_unused]] const std::string& library, [[maybe_unused]] const std::string& function)
virtual void on_shutdown([[maybe_unused]] plugin::plugin* plugin)
{
return nullptr;
}
virtual bool is_supported()
+34 -89
View File
@@ -1,87 +1,48 @@
#include <stdinc.hpp>
#include "component_loader.hpp"
void component_loader::register_component(std::unique_ptr<component_interface>&& component_)
void component_loader::register_component(const std::string& name, std::unique_ptr<component_interface>&& component_)
{
get_components().push_back(std::move(component_));
get_components().push_back(std::make_pair(name, std::move(component_)));
}
bool component_loader::post_start()
{
static auto handled = false;
if (handled) return true;
handled = true;
#define ON_CALLBACK(__name__) \
void component_loader::__name__() \
{ \
static auto handled = false; \
if (handled) \
{ \
return; \
} \
\
handled = true; \
\
for (const auto& component_ : get_components()) \
{ \
try \
{ \
component_.second->__name__(plugin::get()); \
} \
catch (const std::exception& e) \
{ \
printf("error executing component \"%s\" callback \"%s\": %s\n", component_.first.data(), #__name__, e.what()); \
} \
} \
} \
try
{
for (const auto& component_ : get_components())
{
component_->post_start();
}
}
catch (premature_shutdown_trigger&)
{
return false;
}
return true;
}
bool component_loader::post_load()
{
static auto handled = false;
if (handled) return true;
handled = true;
clean();
try
{
for (const auto& component_ : get_components())
{
component_->post_load();
}
}
catch (premature_shutdown_trigger&)
{
return false;
}
return true;
}
void component_loader::post_unpack()
{
static auto handled = false;
if (handled) return;
handled = true;
for (const auto& component_ : get_components())
{
component_->post_unpack();
}
}
void component_loader::pre_destroy()
{
static auto handled = false;
if (handled) return;
handled = true;
for (const auto& component_ : get_components())
{
component_->pre_destroy();
}
}
ON_CALLBACK(on_startup);
ON_CALLBACK(on_dvar_init);
ON_CALLBACK(on_after_dvar_init);
ON_CALLBACK(on_shutdown);
void component_loader::clean()
{
auto& components = get_components();
for (auto i = components.begin(); i != components.end();)
{
if (!(*i)->is_supported())
if (!(*i).second->is_supported())
{
(*i)->pre_destroy();
(*i).second->on_shutdown(plugin::get());
i = components.erase(i);
}
else
@@ -91,35 +52,19 @@ void component_loader::clean()
}
}
void* component_loader::load_import(const std::string& library, const std::string& function)
{
void* function_ptr = nullptr;
for (const auto& component_ : get_components())
{
auto* const component_function_ptr = component_->load_import(library, function);
if (component_function_ptr)
{
function_ptr = component_function_ptr;
}
}
return function_ptr;
}
void component_loader::trigger_premature_shutdown()
{
throw premature_shutdown_trigger();
}
std::vector<std::unique_ptr<component_interface>>& component_loader::get_components()
std::vector<std::pair<std::string, std::unique_ptr<component_interface>>>& component_loader::get_components()
{
using component_vector = std::vector<std::unique_ptr<component_interface>>;
using component_vector = std::vector<std::pair<std::string, std::unique_ptr<component_interface>>>;
using component_vector_container = std::unique_ptr<component_vector, std::function<void(component_vector*)>>;
static component_vector_container components(new component_vector, [](component_vector* component_vector)
{
pre_destroy();
on_shutdown();
delete component_vector;
});
+10 -10
View File
@@ -18,9 +18,9 @@ public:
static_assert(std::is_base_of<component_interface, T>::value, "component has invalid base class");
public:
installer()
installer(const std::string& name)
{
register_component(std::make_unique<T>());
register_component(name, std::make_unique<T>());
}
};
@@ -38,12 +38,12 @@ public:
return nullptr;
}
static void register_component(std::unique_ptr<component_interface>&& component);
static void register_component(const std::string& name, std::unique_ptr<component_interface>&& component);
static bool post_start();
static bool post_load();
static void post_unpack();
static void pre_destroy();
static void on_startup();
static void on_dvar_init();
static void on_after_dvar_init();
static void on_shutdown();
static void clean();
static void* load_import(const std::string& library, const std::string& function);
@@ -51,11 +51,11 @@ public:
static void trigger_premature_shutdown();
private:
static std::vector<std::unique_ptr<component_interface>>& get_components();
static std::vector<std::pair<std::string, std::unique_ptr<component_interface>>>& get_components();
};
#define REGISTER_COMPONENT(name) \
#define REGISTER_COMPONENT(name) \
namespace \
{ \
static component_loader::installer<name> __component; \
static component_loader::installer<name> __component(#name); \
}
+74
View File
@@ -0,0 +1,74 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "plugin.hpp"
#include <utils/hook.hpp>
#include <utils/string.hpp>
namespace plugin
{
namespace
{
void printf_stub(const char* fmt, ...)
{
char buffer[0x2000] = {};
va_list ap;
va_start(ap, fmt);
vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, fmt, ap);
va_end(ap);
get()->get_interface()->logging()->info(buffer);
}
}
std::uint32_t plugin::plugin_version()
{
return 1;
}
const char* plugin::plugin_name()
{
return "iw5-gsc-utils";
}
bool plugin::is_game_supported([[maybe_unused]] plutonium::sdk::game game)
{
return game == plutonium::sdk::game::iw5;
}
void plugin::on_startup(plutonium::sdk::iinterface* interface_ptr, plutonium::sdk::game game)
{
this->interface_ = interface_ptr;
this->game_ = game;
utils::hook::jump(reinterpret_cast<uintptr_t>(&printf), printf_stub);
component_loader::on_startup();
interface_ptr->callbacks()->on_dvar_init(component_loader::on_dvar_init);
interface_ptr->callbacks()->on_after_dvar_init(component_loader::on_after_dvar_init);
}
void plugin::on_shutdown()
{
component_loader::on_shutdown();
}
plutonium::sdk::iinterface* plugin::get_interface()
{
return this->interface_;
}
plutonium::sdk::game plugin::get_game()
{
return this->game_;
}
plugin* get()
{
static plugin instance;
return &instance;
}
}
+30
View File
@@ -0,0 +1,30 @@
#pragma once
#include <plutonium_sdk.hpp>
namespace plugin
{
class plugin : public plutonium::sdk::plugin
{
public:
~plugin() = default;
std::uint32_t plugin_version() override;
const char* plugin_name() override;
bool is_game_supported([[maybe_unused]] plutonium::sdk::game game) override;
void on_startup(plutonium::sdk::iinterface* interface_ptr, plutonium::sdk::game game) override;
void on_shutdown() override;
plutonium::sdk::iinterface* get_interface();
plutonium::sdk::game get_game();
private:
plutonium::sdk::iinterface* interface_{};
plutonium::sdk::game game_{};
};
plugin* get();
}
+4 -2
View File
@@ -28,21 +28,23 @@
#include <map>
#include <csetjmp>
#include <atlcomcli.h>
#include <Psapi.h>
#pragma comment(lib, "urlmon.lib")
using namespace std::literals;
#define __has_warning(...) 0
#include <gsl/gsl>
#include <MinHook.h>
#include "utils/memory.hpp"
#include "utils/string.hpp"
#include "utils/hook.hpp"
#include "utils/concurrent_list.hpp"
#include "utils/io.hpp"
#include "utils/concurrency.hpp"
#include "utils/http.hpp"
#include "game/structs.hpp"
#include "game/game.hpp"
#include "game/game.hpp"
-144
View File
@@ -1,144 +0,0 @@
#pragma once
#include <mutex>
#include <memory>
// This class is trash. Need to get rid of it.
namespace utils
{
template <typename T>
class concurrent_list final
{
public:
class element final
{
public:
explicit element(std::recursive_mutex* mutex, std::shared_ptr<T> entry = {},
std::shared_ptr<element> next = {}) :
mutex_(mutex),
entry_(std::move(entry)),
next_(std::move(next))
{
}
void remove(const std::shared_ptr<T>& element)
{
std::lock_guard<std::recursive_mutex> _(*this->mutex_);
if (!this->next_) return;
if (this->next_->entry_.get() == element.get())
{
this->next_ = this->next_->next_;
}
else
{
this->next_->remove(element);
}
}
[[nodiscard]] std::shared_ptr<element> get_next() const
{
std::lock_guard<std::recursive_mutex> _(*this->mutex_);
return this->next_;
}
std::shared_ptr<T> operator*() const
{
std::lock_guard<std::recursive_mutex> _(*this->mutex_);
return this->entry_;
}
element& operator++()
{
std::lock_guard<std::recursive_mutex> _(*this->mutex_);
*this = this->next_ ? *this->next_ : element(this->mutex_);
return *this;
}
element operator++(int)
{
std::lock_guard<std::recursive_mutex> _(*this->mutex_);
auto result = *this;
this->operator++();
return result;
}
bool operator==(const element& other)
{
std::lock_guard<std::recursive_mutex> _(*this->mutex_);
return this->entry_.get() == other.entry_.get();
}
bool operator!=(const element& other)
{
std::lock_guard<std::recursive_mutex> _(*this->mutex_);
return !(*this == other);
}
private:
std::recursive_mutex* mutex_;
std::shared_ptr<T> entry_;
std::shared_ptr<element> next_;
};
element begin()
{
std::lock_guard<std::recursive_mutex> _(this->mutex_);
return this->entry_ ? *this->entry_ : this->end();
}
element end()
{
std::lock_guard<std::recursive_mutex> _(this->mutex_);
return element(&this->mutex_);
}
void remove(const element& entry)
{
std::lock_guard<std::recursive_mutex> _(this->mutex_);
this->remove(*entry);
}
void remove(const std::shared_ptr<T>& element)
{
std::lock_guard<std::recursive_mutex> _(this->mutex_);
if (!this->entry_) return;
if ((**this->entry_).get() == element.get())
{
this->entry_ = this->entry_->get_next();
}
else
{
this->entry_->remove(element);
}
}
void add(const T& object)
{
std::lock_guard<std::recursive_mutex> _(this->mutex_);
const auto object_ptr = std::make_shared<T>(object);
this->entry_ = std::make_shared<element>(&this->mutex_, object_ptr, this->entry_);
}
void add(T&& object)
{
std::lock_guard<std::recursive_mutex> _(this->mutex_);
const auto object_ptr = std::make_shared<T>(std::move(object));
this->entry_ = std::make_shared<element>(&this->mutex_, object_ptr, this->entry_);
}
void clear()
{
std::lock_guard<std::recursive_mutex> _(this->mutex_);
this->entry_ = {};
}
private:
std::recursive_mutex mutex_;
std::shared_ptr<element> entry_;
};
}
+13
View File
@@ -177,4 +177,17 @@ namespace utils::hook
delete[] bytes;
}
DWORD unprotect(void* place, const size_t size)
{
DWORD old_protect{};
VirtualProtect(place, size, PAGE_EXECUTE_READWRITE, &old_protect);
return old_protect;
}
void protect(void* place, const size_t size, DWORD old_protect)
{
VirtualProtect(place, size, old_protect, &old_protect);
FlushInstructionCache(GetCurrentProcess(), place, size);
}
}
+3
View File
@@ -113,4 +113,7 @@ namespace utils::hook
{
return static_cast<T(*)(Args ...)>(func)(args...);
}
DWORD unprotect(void* place, const size_t size);
void protect(void* place, const size_t size, DWORD old_protect);
}
+6
View File
@@ -1,8 +1,14 @@
#include <stdinc.hpp>
#include <fstream>
#include "io.hpp"
namespace utils::io
{
bool remove_file(const std::string& file)
{
return DeleteFileA(file.data()) == TRUE;
}
bool file_exists(const std::string& file)
{
return std::ifstream(file).good();
+1
View File
@@ -6,6 +6,7 @@
namespace utils::io
{
bool remove_file(const std::string& file);
bool file_exists(const std::string& file);
bool write_file(const std::string& file, const std::string& data, bool append = false);
bool read_file(const std::string& file, std::string* data);
Binary file not shown.
Binary file not shown.