-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Source2Gen is an executable + Linux support #47
base: main
Are you sure you want to change the base?
Conversation
FindDeclareClass doesn't use return value optimization on unix
a cross-platform dlfcn/libloaderapi interface
should work on windows and linux now
- ends_with() removed in favor of std::string_view::ends_with() - generated sdk files no longer contain the ".so" extension on linux
required transition from clang++ to g++ for std::expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, good job. I took a quick look at the changes, and here are some notes.
Not really a big fan of macros since we are coding in C++ and not C. We were trying to remove our macros a while ago, and now we are getting some new ones :)
This definitely needs lots of refactoring, but good job nonetheless
@@ -0,0 +1,38 @@ | |||
// Copyright (C) 2024 neverlosecc | |||
// See end of file for extended copyright information. | |||
#define WINDOWS 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo we should rather use an approach like this https://github.com/es3n1n/obfuscator/blob/dev/src/lib/util/platform.hpp but it's up to you to decide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got inspired by Rust's #[cfg(target_os = "linux")]
. I've never used this approach in C++ before and don't know how well it plays out.
I have no preference for one or the other. I can change it to PLATFORM_IS_*
if you like it better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I am not too sure either, #if PLATFORM == WINDOWS
looks more verbose than mine, although it's pretty much the same thing. I guess you can keep it like this, if you like this one.
Perhaps it would make our thing 🚀 blazing fast, since It was inspired by rust 🙃
`-Wno-unknown-attributes` is `-Wno-attributes` on GNU
Thanks for the quick review and your attention to C++! I'm with you on avoiding macros as much as we can. I had to un-constexpr the |
Never even heard of it, lol
There should definitely be a way to do that. I will try to come up with an implementation, but I am a bit busy with some other projects, so this probably could take some time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise looks like a good pr
Providing a path for the dumper to the game is convenient if you only use the dumper on the server, but if you use it yourself, you'll get a little tired of it after a while. So on windows we'll most likely have to use Registry and from there take SteamLibrary path and hardcode the folder name for each game. Which sounds a little bit bad, but I don't know any other way. If path was provided then we'll work with it otherwise using registry + hardcoded names of folders for each game. |
What's wrong with just placing generated SDKs in the same folder as the binary itself tho? We'll provide an optional path where to place the generated SDKs, and if it wasn't provided, we'll just drop it to the current directory |
We are talkin about game DLL's. Path is being used to get them and load them in to memory. I'm aint against dumping in current executable folder sdk, I thinkin that if I will pass path to dota 2 each time when I want to dump -- I'll break my monitor in week. |
I've had thoughts in a similar direction. Source2Gen could generate the two paths itself, given a path to the game installation directory. I've added a script ( You have suggested to use the registry on Windows, should we note that idea in the linked issue so whoever restores Windows compatibility has an easier time implementing it? * source2gen can't set |
Sorry for the delays in my response(and sorry for my previous response; I was sleep-deprived, T_T). I was a bit busy with some other projects, but now I am more or less free from them, so you can expect faster replies from me.
Yes, please. Most likely this person would be me anyway.
Yes, indeed. they might've changed compiler options, but since we are no valve employees we cannot know this for sure, this is why this is called a version, this variable would be used in the future if source 2 developers introduce any more changes to the compiler options/functions/anything else. This is just more convenient. I am OK with having this comment; just add there What are the current merge blockers for this PR? Apart from the windows support. |
It might be worth to consider adding automatic tests (Separate issue) now that source2gen is faster and doesn't need the games to be running. Even if the tests can only run on a developer machine, they'll make it safer to work on source2gen and could reduce the effort required to review pull requests. |
Okie, I will let him know.
Yeah, I will try to check it out today.
Sure I guess, users will complain if something won't work anyway
Yeah, we will test it only on Windows. As for the required modules, we previously had an array that worked for all the source 2 games. I am too lazy to check, but if you didn't change the checked modules themselves, then we should probably be good.
Ah yes, I've been dreaming about it for a long time, adding something like GTest for tests would make the further work much easier. But that is a different story and will be implemented later. -- Once cpz approves all the changes, I guess I will start on adding Windows support back and will most likely refactor other parts as well. This would probably need your help at some point, but we are too far from that as of now. |
The target game doesn't need to run anymore for source2gen to work. If the game doesn't load its libraries, someone else has to. That someone is source2gen. The |
1. Update m_szValue to 8 size in CSchemaNetworkValue 2. m_unSize was renamed to m_unSizeOf since how Valve calls it 3. Fixed static_asserts for windows 4. Provide __attribute__ ((packed)) for CSchemaType to linux only 5. Minor naming changes in SchemaClassInfoData_t 6. Update loader: find_module_symbol, because it works different in each os 8. Update loader_windows: minor changes 9. Update premake5 to compile as *.exe 10. Wait char, so console wont close automatically after dump (So, we can see how it went and etc) 11. Minor changes to IMemAlloc 12. Support UTF8 and etc console message (GetLastError and FormatMessage will print based on user os language, so it'll be readable) 7.
1. Minor changes in codegen, main reason to visit it was "enum_item", we'll print hex value if sizeof(T) >= 2 instead of >= 4 2. Update Metadata parser for classes\members
- add missing includes - don't reference packed data members - `static_assert`s for struct sizes
- `LoadModuleError` -> `ModuleLookupError` - guard access to `createinterface_symbol` and `g_ppMemAlloc_wrap`
See issue #48 for details and status
Thanks for
.clang-format
, cmake, and for using assertions! It made working on this project much easier than some other projects.