Better method to detect process elevation. This hopefully prevents that the process from being detected as "elevated" on Vista+ systems that have UAC disabled.

This commit is contained in:
LoRd_MuldeR 2011-01-03 22:24:58 +01:00
parent 3b598fbdf9
commit fe7a8064c7
6 changed files with 74 additions and 47 deletions

View File

@ -386,20 +386,23 @@
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<widget class="QFrame" name="frame_2">
<property name="maximumSize">
<size>
<width>20</width>
<height>3</height>
<width>16777215</width>
<height>2</height>
</size>
</property>
</spacer>
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
@ -1160,7 +1163,7 @@
</property>
<property name="icon">
<iconset resource="../res/Icons.qrc">
<normaloff>:/icons/door_out.png</normaloff>:/icons/door_out.png</iconset>
<normaloff>:/icons/door_in.png</normaloff>:/icons/door_in.png</iconset>
</property>
</widget>
</item>
@ -1466,7 +1469,7 @@
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../res/Flags.qrc">
<iconset>
<normaloff>:/flags/gb.png</normaloff>:/flags/gb.png</iconset>
</property>
<property name="text">
@ -1482,6 +1485,10 @@
<include location="../res/Images.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Images.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Images.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Images.qrc"/>
</resources>
<connections>
<connection>

View File

@ -35,6 +35,7 @@
<file>icons/delete.png</file>
<file>icons/disk.png</file>
<file>icons/door_out.png</file>
<file>icons/door_in.png</file>
<file>icons/drive_cd.png</file>
<file>icons/exclamation.png</file>
<file>icons/error.png</file>

View File

@ -25,7 +25,7 @@
#define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 0
#define VER_LAMEXP_BUILD 213
#define VER_LAMEXP_BUILD 215
#define VER_LAMEXP_SUFFIX TechPreview
/*

View File

@ -247,7 +247,7 @@ void AboutDialog::showMoreAbout(void)
moreAboutText += LINK("http://www.ac3filter.net/projects/tools");
moreAboutText += "<div style=\"font-size:1pt\"><br></div>";
moreAboutText += VSTR(QString("<li><b>%1 (%2)</b><br>").arg(tr("MediaInfo - Media File Analysis Tool")), "mediainfo_i386.exe", "v?.?.?");
moreAboutText += VSTR(QString("<li><b>%1 (%2)</b><br>").arg(tr("MediaInfo - Media File Analysis Tool")), "mediainfo_i386.exe", "v?.?.??");
moreAboutText += QString("<nobr>%1</nobr><br>").arg(tr("Released under the terms of the GNU Leser General Public License."));
moreAboutText += LINK("http://mediainfo.sourceforge.net/");
moreAboutText += "<div style=\"font-size:1pt\"><br></div>";

View File

@ -74,14 +74,14 @@
#define TEMP_HIDE_DROPBOX(CMD) { bool __dropBoxVisible = m_dropBox->isVisible(); if(__dropBoxVisible) m_dropBox->hide(); CMD; if(__dropBoxVisible) m_dropBox->show(); }
//Helper class
class Index: public QObjectUserData
{
public:
Index(int index) { m_index = index; }
int value(void) { return m_index; }
private:
int m_index;
};
//class Index: public QObjectUserData
//{
//public:
// Index(int index) { m_index = index; }
// int value(void) { return m_index; }
//private:
// int m_index;
//};
////////////////////////////////////////////////////////////
// Constructor
@ -222,11 +222,11 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
m_tabActionGroup->addAction(actionCompression);
m_tabActionGroup->addAction(actionMetaData);
m_tabActionGroup->addAction(actionAdvancedOptions);
actionSourceFiles->setUserData(0, new Index(0));
actionOutputDirectory->setUserData(0, new Index(1));
actionMetaData->setUserData(0, new Index(2));
actionCompression->setUserData(0, new Index(3));
actionAdvancedOptions->setUserData(0, new Index(4));
actionSourceFiles->setData(0);
actionOutputDirectory->setData(1);
actionMetaData->setData(2);
actionCompression->setData(3);
actionAdvancedOptions->setData(4);
actionSourceFiles->setChecked(true);
connect(m_tabActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(tabActionActivated(QAction*)));
@ -237,11 +237,11 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S
m_styleActionGroup->addAction(actionStyleWindowsVista);
m_styleActionGroup->addAction(actionStyleWindowsXP);
m_styleActionGroup->addAction(actionStyleWindowsClassic);
actionStylePlastique->setUserData(0, new Index(0));
actionStyleCleanlooks->setUserData(0, new Index(1));
actionStyleWindowsVista->setUserData(0, new Index(2));
actionStyleWindowsXP->setUserData(0, new Index(3));
actionStyleWindowsClassic->setUserData(0, new Index(4));
actionStylePlastique->setData(0);
actionStyleCleanlooks->setData(1);
actionStyleWindowsVista->setData(2);
actionStyleWindowsXP->setData(3);
actionStyleWindowsClassic->setData(4);
actionStylePlastique->setChecked(true);
actionStyleWindowsXP->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_XP && lamexp_themes_enabled());
actionStyleWindowsVista->setEnabled((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_VISTA && lamexp_themes_enabled());
@ -728,7 +728,7 @@ void MainWindow::encodeButtonClicked(void)
if(m_fileListModel->rowCount() < 1)
{
QMessageBox::warning(this, tr("LameXP"), tr("You must add at least one file to the list before proceeding!"));
QMessageBox::warning(this, tr("LameXP"), QString("<nobr>%1</nobr>").arg(tr("You must add at least one file to the list before proceeding!")));
tabWidget->setCurrentIndex(0);
return;
}
@ -958,7 +958,9 @@ void MainWindow::tabPageChanged(int idx)
QList<QAction*> actions = m_tabActionGroup->actions();
for(int i = 0; i < actions.count(); i++)
{
if(actions.at(i)->userData(0) && dynamic_cast<Index*>(actions.at(i)->userData(0))->value() == idx)
bool ok = false;
int actionIndex = actions.at(i)->data().toInt(&ok);
if(ok && actionIndex == idx)
{
actions.at(i)->setChecked(true);
}
@ -970,10 +972,14 @@ void MainWindow::tabPageChanged(int idx)
*/
void MainWindow::tabActionActivated(QAction *action)
{
if(action && action->userData(0))
if(action && action->data().isValid())
{
int index = dynamic_cast<Index*>(action->userData(0))->value();
tabWidget->setCurrentIndex(index);
bool ok = false;
int index = action->data().toInt(&ok);
if(ok)
{
tabWidget->setCurrentIndex(index);
}
}
}
@ -982,9 +988,11 @@ void MainWindow::tabActionActivated(QAction *action)
*/
void MainWindow::styleActionActivated(QAction *action)
{
if(action && action->userData(0))
if(action && action->data().isValid())
{
m_settings->interfaceStyle(dynamic_cast<Index*>(action->userData(0))->value());
bool ok = false;
int actionIndex = action->data().toInt(&ok);
m_settings->interfaceStyle(actionIndex);
}
switch(m_settings->interfaceStyle())

View File

@ -422,22 +422,33 @@ static bool lamexp_check_compatibility_mode(const char *exportName)
*/
static bool lamexp_check_elevation(void)
{
typedef enum { lamexp_token_elevation_class = 20 };
typedef struct { DWORD TokenIsElevated; } LAMEXP_TOKEN_ELEVATION;
typedef enum { lamexp_token_elevationType_class = 18, lamexp_token_elevation_class = 20 } LAMEXP_TOKEN_INFORMATION_CLASS;
typedef enum { lamexp_elevationType_default = 1, lamexp_elevationType_full, lamexp_elevationType_limited } LAMEXP_TOKEN_ELEVATION_TYPE;
HANDLE hToken = NULL;
bool bIsProcessElevated = false;
if(OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
{
LAMEXP_TOKEN_ELEVATION tokenElevation;
LAMEXP_TOKEN_ELEVATION_TYPE tokenElevationType;
DWORD returnLength;
if(GetTokenInformation(hToken, (TOKEN_INFORMATION_CLASS) lamexp_token_elevation_class, &tokenElevation, sizeof(LAMEXP_TOKEN_ELEVATION), &returnLength))
if(GetTokenInformation(hToken, (TOKEN_INFORMATION_CLASS) lamexp_token_elevationType_class, &tokenElevationType, sizeof(LAMEXP_TOKEN_ELEVATION_TYPE), &returnLength))
{
if(returnLength == sizeof(LAMEXP_TOKEN_ELEVATION) && tokenElevation.TokenIsElevated != 0)
if(returnLength == sizeof(LAMEXP_TOKEN_ELEVATION_TYPE))
{
qWarning("Process token is elevated -> potential security risk!\n");
bIsProcessElevated = true;
switch(tokenElevationType)
{
case lamexp_elevationType_default:
qDebug("Process token elevation type: Default -> UAC is disabled.\n");
break;
case lamexp_elevationType_full:
qWarning("Process token elevation type: Full -> potential security risk!\n");
bIsProcessElevated = true;
break;
case lamexp_elevationType_limited:
qDebug("Process token elevation type: Limited -> not elevated.\n");
break;
}
}
}
CloseHandle(hToken);