Skip to content
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

Everything needed to run simple Rust programs #40

Merged
merged 3 commits into from
Sep 10, 2023

Conversation

encounter
Copy link
Member

Various improvements to support running sjiswrap for mwcceppc.exe.

Of note:

  • Reworked library system to better support LoadLibraryA, GetModuleHandleA, GetProcAddress, etc.
  • Started using Windows defines for API functions.
  • Adds .clang-format and .clang-tidy for editors.

NtAllocateVirtualMemory and NtProtectVirtualMemory are fun, they're for sjiswrap to map the sub-subprocess and execute it. Wrapper inception!


using random_bytes_engine = std::independent_bits_engine<std::default_random_engine, CHAR_BIT, unsigned char>;

NTSTATUS WIN_FUNC BCryptGenRandom(BCRYPT_ALG_HANDLE hAlgorithm, PUCHAR pbBuffer, ULONG cbBuffer, ULONG dwFlags) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

password hashing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust's HashMap uses random bytes as a seed. It's not actually using a BCrypt hash, but the BCryptGenRandom function is a good place to get random bytes, apparently.

files.h Outdated Show resolved Hide resolved
files.h Outdated Show resolved Hide resolved
dll/version.cpp Outdated Show resolved Hide resolved
dll/crt.cpp Outdated Show resolved Hide resolved
if (nSize < len) {
return len;
}
const uint16_t *wideValue = stringToWideString(value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memory leak; should we maybe add a version of stringToWideString that returns a vector<uint16_t>?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, or maybe std::wstring? Added a free() for now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wstring is UTF-32 on Linux, alas

dll/kernel32.cpp Outdated Show resolved Hide resolved
dll/kernel32.cpp Outdated Show resolved Hide resolved
dll/kernel32.cpp Outdated Show resolved Hide resolved
dll/kernel32.cpp Outdated Show resolved Hide resolved
@ethteck ethteck merged commit 94b44fd into decompals:main Sep 10, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants