silent mode

gui v1.4
qtkite 2 years ago
parent e19797d4d3
commit ef2557c474

@ -1,25 +1,43 @@
// to-do: // to-do:
// make a ui for this // make a ui for this
// argument support -s check
// //
#include "dcontrol.hpp" #include "dcontrol.hpp"
#include "wmic.hpp" #include "wmic.hpp"
#include "trusted.hpp" #include "trusted.hpp"
bool check_silent(int argc, char** argv)
{
for (int i = 0; i < argc; i++)
{
if (!strcmp(argv[i], "-s"))
return true;
}
return false;
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
auto silent = check_silent(argc, argv);
if (!trusted::has_admin()) if (!trusted::has_admin())
{ {
printf("Must run as admin!\n"); printf("Must run as admin!\n");
system("pause");
if (!silent)
system("pause");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
// Because we are a primary token, we can't swap ourselves with an impersonation token. // Because we are a primary token, we can't swap ourselves with an impersonation token.
// There will always be a need to re-create the process with the token as primary. // There will always be a need to re-create the process with the token as primary.
if (!trusted::is_system_group() && argc == 1) // we check for argc == 1, assuming we aren't launching with any parameters
//
if (!trusted::is_system_group()) // && argc == 1
{ {
printf("Restarting with privileges\n"); printf("Restarting with privileges\n");
trusted::create_process(util::get_current_path()); trusted::create_process(util::get_current_path().append(silent ? " -s" : ""));
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -31,8 +49,8 @@ int main(int argc, char** argv)
dcontrol::toggle_tamper(false); dcontrol::toggle_tamper(false);
printf(dcontrol::check_defender() ? printf(dcontrol::check_defender() ?
"Windows defender is ACTIVE\n" : "Windows defender is currently ACTIVE\n" :
"Windows defender is OFF\n"); "Windows defender is currently OFF\n");
#if DEFENDER_CONFIG == DEFENDER_DISABLE #if DEFENDER_CONFIG == DEFENDER_DISABLE
if (dcontrol::disable_defender()) if (dcontrol::disable_defender())
@ -53,6 +71,8 @@ int main(int argc, char** argv)
printf("%s\n", e.what()); printf("%s\n", e.what());
} }
system("pause"); if (!silent)
system("pause");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

@ -12,7 +12,6 @@ namespace reg
DWORD buff_sz = sizeof(DWORD); DWORD buff_sz = sizeof(DWORD);
// https://docs.microsoft.com/en-us/windows/win32/winprog64/accessing-an-alternate-registry-view // https://docs.microsoft.com/en-us/windows/win32/winprog64/accessing-an-alternate-registry-view
//
status = RegOpenKeyExW( status = RegOpenKeyExW(
HKEY_LOCAL_MACHINE, HKEY_LOCAL_MACHINE,
root_name, root_name,
@ -25,7 +24,6 @@ namespace reg
{ {
if (flags & DBG_MSG) if (flags & DBG_MSG)
wprintf(L"Error opening %ls key \n", root_name); wprintf(L"Error opening %ls key \n", root_name);
return -1; return -1;
} }

@ -6,4 +6,4 @@
#define DEFENDER_DISABLE 2 #define DEFENDER_DISABLE 2
#define DEFENDER_GUI 3 #define DEFENDER_GUI 3
#define DEFENDER_CONFIG DEFENDER_DISABLE #define DEFENDER_CONFIG DEFENDER_ENABLE

@ -283,5 +283,4 @@ namespace trusted
return ret; return ret;
} }
} }

@ -140,6 +140,4 @@ namespace wmic
{ {
return last_error; return last_error;
} }
} }

Loading…
Cancel
Save