Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
felikcat committed Nov 25, 2024
1 parent df4b846 commit c2e6f72
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 76 deletions.
4 changes: 2 additions & 2 deletions W11Boost.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Global
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{308A159C-0751-4B0C-BAEC-595E13473FDF}.Debug|x64.ActiveCfg = Debug|x64
{308A159C-0751-4B0C-BAEC-595E13473FDF}.Debug|x64.Build.0 = Debug|x64
{308A159C-0751-4B0C-BAEC-595E13473FDF}.Debug|x64.ActiveCfg = Release|x64
{308A159C-0751-4B0C-BAEC-595E13473FDF}.Debug|x64.Build.0 = Release|x64
{308A159C-0751-4B0C-BAEC-595E13473FDF}.Release|x64.ActiveCfg = Release|x64
{308A159C-0751-4B0C-BAEC-595E13473FDF}.Release|x64.Build.0 = Release|x64
EndGlobalSection
Expand Down
49 changes: 24 additions & 25 deletions W11Boost/Common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ auto get_log_directory() -> wchar_t* {
wchar_t currentPath[MAX_PATH_DOUBLE_NULL];
GetModuleFileNameW(NULL, currentPath, MAX_PATH);

wchar_t *removeExe = wcsrchr(currentPath, L'\\');
wchar_t* removeExe = wcsrchr(currentPath, L'\\');
if (removeExe != NULL) {
*removeExe = L'\0';
}

const wchar_t *dirName = L"W11Boost Logs";
wchar_t *fullPath = static_cast<wchar_t*>(malloc(MAX_PATH_DOUBLE_NULL * sizeof(wchar_t)));
const wchar_t* dirName = L"W11Boost Logs";
wchar_t* fullPath = static_cast<wchar_t *>(malloc(MAX_PATH_DOUBLE_NULL * sizeof(wchar_t)));

if (fullPath != NULL) {
swprintf_s(fullPath, MAX_PATH, L"%s\\%s", currentPath, dirName);
Expand Down Expand Up @@ -52,7 +52,7 @@ auto wide_string_to_utf8(const wchar_t* wide_string) -> utf8_result {
}

auto log_registry(const wchar_t* subKey, const wchar_t* valueName, const char* typeName) -> int {
wchar_t *currentDir = get_log_directory();
wchar_t* currentDir = get_log_directory();
wchar_t logLocation[MAX_PATH_DOUBLE_NULL];

if (currentDir == NULL)
Expand All @@ -63,7 +63,7 @@ auto log_registry(const wchar_t* subKey, const wchar_t* valueName, const char* t
if (currentDir == NULL)
return EXIT_FAILURE;

FILE *logFile = NULL;
FILE* logFile = NULL;
errno_t err = _wfopen_s(&logFile, logLocation, L"a");
if (err != 0 || logFile == NULL) {
free(currentDir);
Expand Down Expand Up @@ -113,68 +113,67 @@ auto delete_directory_and_subfolders(LPCWSTR directory) -> long {
return SHFileOperationW(&fos);
}

auto set_dword(HKEY hKey, const wchar_t* subKey, const wchar_t* valueName, const DWORD value) -> LSTATUS {
auto set_dword(HKEY hKey, const wchar_t *subKey, const wchar_t *valueName, const DWORD value) -> LSTATUS {
HKEY hSubKey;
long_result = RegCreateKeyExW(hKey, subKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hSubKey, NULL);

if (long_result == ERROR_SUCCESS)
long_result =
RegSetValueExW(hSubKey, valueName, 0, REG_DWORD, std::bit_cast<const BYTE *>(&value), sizeof(DWORD));
long_result = RegSetValueExW(hSubKey, valueName, 0, REG_DWORD, std::bit_cast<const BYTE *>(&value), sizeof(DWORD));

const char *typeName = " - DWORD: ";
const char* typeName = " - DWORD: ";
log_registry(subKey, valueName, typeName);

long_result = RegCloseKey(hSubKey);
return long_result;
}

auto set_string(HKEY hKey, const wchar_t* subKey, const wchar_t* valueName, const wchar_t* value) -> LSTATUS {
auto set_string(HKEY hKey, const wchar_t *subKey, const wchar_t *valueName, const wchar_t *value) -> LSTATUS {
HKEY hSubKey;
if ((long_result = RegCreateKeyExW(hKey, subKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hSubKey,
NULL)) !=
ERROR_SUCCESS ||
(long_result = RegSetValueExW(hSubKey, valueName, 0, REG_SZ, (const BYTE *)value,
(DWORD)wcslen(value) * sizeof(wchar_t))) != ERROR_SUCCESS ||
(long_result = RegSetValueExW(hSubKey, valueName, 0, REG_SZ, std::bit_cast<const BYTE *>(value),
static_cast<DWORD>(wcslen(value) * sizeof(wchar_t)))) != ERROR_SUCCESS ||
(long_result = RegCloseKey(hSubKey)) != ERROR_SUCCESS)
return EXCEPTION_EXECUTE_HANDLER;
{
const char *typeName = " - SZ: ";
const char* typeName = " - SZ: ";
log_registry(subKey, valueName, typeName);
}
return long_result;
}

auto set_environment(HKEY hKey, const wchar_t *valueName, const wchar_t *value) -> LSTATUS {
auto set_environment(HKEY hKey, const wchar_t* valueName, const wchar_t* value) -> LSTATUS {
HKEY hSubKey;
const wchar_t *subKey = L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
const wchar_t* subKey = L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
long_result = RegOpenKeyExW(hKey, subKey, 0, KEY_ALL_ACCESS, &hSubKey);

if (long_result == ERROR_SUCCESS)
long_result = RegSetValueExW(hSubKey, valueName, 0, REG_EXPAND_SZ, (const BYTE *)value,
(DWORD)(wcslen(value) * sizeof(wchar_t)));
long_result = RegSetValueExW(hSubKey, valueName, 0, REG_EXPAND_SZ, std::bit_cast<const BYTE *>(value),
static_cast<DWORD>(wcslen(value) * sizeof(wchar_t)));

const char *typeName = " - EXPAND_SZ: ";
const char* typeName = " - EXPAND_SZ: ";
log_registry(subKey, valueName, typeName);

long_result = RegCloseKey(hSubKey);
return long_result;
}

auto remove_subkey(HKEY hKey, const wchar_t *subKey, const wchar_t *valueName) -> LSTATUS {
auto remove_subkey(HKEY hKey, const wchar_t* subKey, const wchar_t* valueName) -> LSTATUS {
HKEY hSubKey;
long_result = RegOpenKeyExW(hKey, subKey, 0, KEY_WRITE, &hSubKey);

if (long_result == ERROR_SUCCESS)
long_result = RegDeleteValueW(hSubKey, valueName);

const char *typeName = " - Removed subkey: ";
const char* typeName = " - Removed subkey: ";
log_registry(subKey, valueName, typeName);

long_result = RegCloseKey(hSubKey);
return long_result;
}

auto start_command_and_wait(wchar_t *cmdLine) -> int {
auto start_command_and_wait(wchar_t* cmdLine) -> int {
STARTUPINFOW si{};
PROCESS_INFORMATION pi{};

Expand All @@ -192,7 +191,7 @@ auto start_command_and_wait(wchar_t *cmdLine) -> int {
return EXIT_SUCCESS;
}

auto append_wchar_t(const wchar_t *original, const wchar_t *append, wchar_t *_result) -> bool {
auto append_wchar_t(const wchar_t* original, const wchar_t* append, wchar_t* _result) -> bool {
wcscpy_s(_result, MAX_PATH, original);
if ((PathAppendW(_result, append)) == TRUE)
return true;
Expand All @@ -202,13 +201,13 @@ auto append_wchar_t(const wchar_t *original, const wchar_t *append, wchar_t *_re

// This is for cURL
// "char *ptr" contains the contents
auto write_callback(char *ptr, size_t size, size_t nmemb, void *userdata) -> size_t {
FILE *stream = (FILE *)userdata;
auto write_callback(char* ptr, size_t size, size_t nmemb, void* userdata) -> size_t {
FILE* stream = static_cast<FILE *>(userdata);
return fwrite(ptr, size, nmemb, stream);
}

auto get_windows_path(const GUID folderID) -> std::wstring {
wchar_t *path = NULL;
wchar_t* path = NULL;
HRESULT hr = SHGetKnownFolderPath(folderID, 0, NULL, &path);

if (FAILED(hr))
Expand Down
1 change: 1 addition & 0 deletions W11Boost/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <AccCtrl.h>
#include <AclAPI.h>
#include <SrRestorePtApi.h>
#include <bit>

inline LONG long_result;

Expand Down
4 changes: 2 additions & 2 deletions W11Boost/Edits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ auto main_registry_edits() -> int {
//---- Disables "Fast startup".
set_dword(hKey, L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power", L"HiberbootEnabled", 0);

const wchar_t *filePath = L"C:\\Windows\\System32\\SleepStudy\\UserNotPresentSession.etl";
const wchar_t* filePath = L"C:\\Windows\\System32\\SleepStudy\\UserNotPresentSession.etl";

// File can't be read-only, otherwise DeleteFileW will fail
DWORD attributes = FILE_ATTRIBUTE_NORMAL;
Expand All @@ -56,7 +56,7 @@ auto main_registry_edits() -> int {
if (!del)
return EXIT_FAILURE;

FILE *file = NULL;
FILE* file = NULL;
errno_t err = _wfopen_s(&file, filePath, L"a");
if (err != 0 || file == NULL)
return EXIT_FAILURE;
Expand Down
3 changes: 2 additions & 1 deletion W11Boost/RestorePoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ auto restorepoint_prep() -> void {

if (long_result == ERROR_SUCCESS) {
unsigned long value = 0;
RegSetValueExW(hSubKey, L"SystemRestorePointCreationFrequency", 0, REG_DWORD, (const BYTE *)&value, sizeof(value));
RegSetValueExW(hSubKey, L"SystemRestorePointCreationFrequency", 0, REG_DWORD, std::bit_cast<const BYTE *>(&value),
sizeof(value));
}

long_result = RegCreateKeyExW(hKey, L"SOFTWARE\\Policies\\Microsoft\\Windows NT\\SystemRestore", 0, NULL,
Expand Down
Binary file modified W11Boost/W11Boost.aps
Binary file not shown.
Loading

0 comments on commit c2e6f72

Please sign in to comment.