DBG+BRIDGE+GUI: put in the title whether x64dbg is elevated or not
This commit is contained in:
parent
223ea586bb
commit
85e96353cb
|
@ -251,6 +251,21 @@ BRIDGE_IMPEXP int BridgeGetDbgVersion()
|
|||
return DBG_VERSION;
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP bool BridgeIsProcessElevated()
|
||||
{
|
||||
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
|
||||
PSID SecurityIdentifier;
|
||||
if(!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &SecurityIdentifier))
|
||||
return 0;
|
||||
|
||||
BOOL IsAdminMember;
|
||||
if(!CheckTokenMembership(NULL, SecurityIdentifier, &IsAdminMember))
|
||||
IsAdminMember = FALSE;
|
||||
|
||||
FreeSid(SecurityIdentifier);
|
||||
return !!IsAdminMember;
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP bool DbgMemRead(duint va, void* dest, duint size)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
|
|
@ -121,6 +121,12 @@ BRIDGE_IMPEXP bool BridgeSettingRead(int* errorLine);
|
|||
/// <returns>25</returns>
|
||||
BRIDGE_IMPEXP int BridgeGetDbgVersion();
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the current process is elevated.
|
||||
/// </summary>
|
||||
/// <returns>true if the process is elevated, false otherwise.</returns>
|
||||
BRIDGE_IMPEXP bool BridgeIsProcessElevated();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -446,7 +446,7 @@ void dbgfunctionsinit()
|
|||
_dbgfunctions.GetPageRights = MemGetPageRights;
|
||||
_dbgfunctions.SetPageRights = MemSetPageRights;
|
||||
_dbgfunctions.PageRightsToString = MemPageRightsToString;
|
||||
_dbgfunctions.IsProcessElevated = IsProcessElevated;
|
||||
_dbgfunctions.IsProcessElevated = BridgeIsProcessElevated;
|
||||
_dbgfunctions.GetCmdline = _getcmdline;
|
||||
_dbgfunctions.SetCmdline = _setcmdline;
|
||||
_dbgfunctions.FileOffsetToVa = valfileoffsettova;
|
||||
|
|
|
@ -306,7 +306,7 @@ bool cbDebugSetJIT(int argc, char* argv[])
|
|||
char* jit_debugger_cmd = "";
|
||||
Memory<char*> oldjit(MAX_SETTING_SIZE + 1);
|
||||
char path[JIT_ENTRY_DEF_SIZE];
|
||||
if(!IsProcessElevated())
|
||||
if(!BridgeIsProcessElevated())
|
||||
{
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "Error run the debugger as Admin to setjit\n"));
|
||||
return false;
|
||||
|
@ -539,7 +539,7 @@ bool cbDebugSetJITAuto(int argc, char* argv[])
|
|||
{
|
||||
arch actual_arch;
|
||||
bool set_jit_auto;
|
||||
if(!IsProcessElevated())
|
||||
if(!BridgeIsProcessElevated())
|
||||
{
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "Error run the debugger as Admin to setjitauto\n"));
|
||||
return false;
|
||||
|
|
|
@ -2588,7 +2588,7 @@ static void debugLoopFunction(void* lpParameter, bool attach)
|
|||
if(!fdProcessInfo)
|
||||
{
|
||||
auto lastError = GetLastError();
|
||||
auto isElevated = IsProcessElevated();
|
||||
auto isElevated = BridgeIsProcessElevated();
|
||||
String error = stringformatinline(StringUtils::sprintf("{winerror@%d}", lastError));
|
||||
if(lastError == ERROR_ELEVATION_REQUIRED && !isElevated)
|
||||
{
|
||||
|
|
|
@ -1,20 +1,5 @@
|
|||
#include "jit.h"
|
||||
|
||||
bool IsProcessElevated()
|
||||
{
|
||||
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
|
||||
PSID SecurityIdentifier;
|
||||
if(!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &SecurityIdentifier))
|
||||
return 0;
|
||||
|
||||
BOOL IsAdminMember;
|
||||
if(!CheckTokenMembership(NULL, SecurityIdentifier, &IsAdminMember))
|
||||
IsAdminMember = FALSE;
|
||||
|
||||
FreeSid(SecurityIdentifier);
|
||||
return !!IsAdminMember;
|
||||
}
|
||||
|
||||
static bool readwritejitkey(wchar_t* jit_key_value, DWORD* jit_key_vale_size, char* key, arch arch_in, arch* arch_out, readwritejitkey_error_t* error, bool write)
|
||||
{
|
||||
DWORD key_flags;
|
||||
|
@ -27,7 +12,7 @@ static bool readwritejitkey(wchar_t* jit_key_value, DWORD* jit_key_vale_size, ch
|
|||
|
||||
if(write)
|
||||
{
|
||||
if(!IsProcessElevated())
|
||||
if(!BridgeIsProcessElevated())
|
||||
{
|
||||
if(error != NULL)
|
||||
*error = ERROR_RW_NOTADMIN;
|
||||
|
|
|
@ -24,7 +24,6 @@ enum arch
|
|||
x64,
|
||||
};
|
||||
|
||||
bool IsProcessElevated();
|
||||
bool dbggetjit(char jit_entry[JIT_ENTRY_MAX_SIZE], arch arch_in, arch* arch_out, readwritejitkey_error_t* rw_error_out);
|
||||
bool dbgsetjit(char* jit_cmd, arch arch_in, arch* arch_out, readwritejitkey_error_t* rw_error_out);
|
||||
bool dbggetjitauto(bool* auto_on, arch arch_in, arch* arch_out, readwritejitkey_error_t* rw_error_out);
|
||||
|
|
|
@ -98,7 +98,13 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
addMenuToList(this, ui->menuPlugins, GUI_PLUGIN_MENU);
|
||||
|
||||
// Set window title
|
||||
mWindowMainTitle = QCoreApplication::applicationName();
|
||||
if(BridgeIsProcessElevated())
|
||||
{
|
||||
mWindowMainTitle = tr("%1 [Elevated]").arg(QCoreApplication::applicationName());
|
||||
ui->actionRestartAdmin->setEnabled(false);
|
||||
}
|
||||
else
|
||||
mWindowMainTitle = QCoreApplication::applicationName();
|
||||
setWindowTitle(QString(mWindowMainTitle));
|
||||
|
||||
// Load application icon
|
||||
|
|
|
@ -289,7 +289,7 @@ void SettingsDialog::LoadSettings()
|
|||
|
||||
ui->chkConfirmBeforeAtt->setCheckState(bool2check(settings.miscSetJITAuto));
|
||||
|
||||
if(!DbgFunctions()->IsProcessElevated())
|
||||
if(!BridgeIsProcessElevated())
|
||||
{
|
||||
ui->chkSetJIT->setDisabled(true);
|
||||
ui->chkConfirmBeforeAtt->setDisabled(true);
|
||||
|
|
Loading…
Reference in New Issue