Skip to content

Commit

Permalink
Merge branch 'develop' into develop-output-signtools-exception-details
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonYu6 authored Sep 14, 2024
2 parents e4f5945 + 51f5e2c commit 589f835
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/Setup/UpdateRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ void CUpdateRunner::DisplayErrorMessage(CString& errorMessage, wchar_t* logFile)
}
}

HRESULT CUpdateRunner::AreWeInWine()
{
// NB: Behaving differently in Wine is *usually* discouraged
// https://wiki.winehq.org/Developer_FAQ#How_can_I_detect_Wine.3F
HMODULE hntdll = GetModuleHandle(L"ntdll.dll");
if (!hntdll) {
// NB: This can never fail but we'll be pedantic
return E_FAIL;
}

return GetProcAddress(hntdll, "wine_get_version") != NULL ? S_OK : S_FALSE;
}

HRESULT CUpdateRunner::AreWeUACElevated()
{
HANDLE hProcess = GetCurrentProcess();
Expand Down
1 change: 1 addition & 0 deletions src/Setup/UpdateRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class CUpdateRunner

public:
static void DisplayErrorMessage(CString& errorMessage, wchar_t* logFile);
static HRESULT AreWeInWine();
static HRESULT AreWeUACElevated();
static HRESULT ShellExecuteFromExplorer(LPWSTR pszFile, LPWSTR pszParameters);
static bool DirectoryExists(wchar_t* szPath);
Expand Down
3 changes: 2 additions & 1 deletion src/Setup/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,

// If we're UAC-elevated, we shouldn't be because it will give us permissions
// problems later. Just silently rerun ourselves.
if (weAreUACElevated) {
// (Skip this check in Wine, which always reports admin privileges)
if (weAreUACElevated && CUpdateRunner::AreWeInWine() != S_OK) {
wchar_t buf[4096];
HMODULE hMod = GetModuleHandle(NULL);
GetModuleFileNameW(hMod, buf, 4096);
Expand Down
2 changes: 1 addition & 1 deletion src/Squirrel/TrayHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public unsafe void RemoveDeadEntries(List<string> executablesInPackage, string r
var path = item.ExePath.ToLowerInvariant();

// Someone completely unrelated? Keep it!
if (!executablesInPackage.Any(exe => path.Contains(exe))) {
if (!executablesInPackage.Any(exe => path.Contains(exe.ToLowerInvariant()))) {
goto keepItem;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Squirrel/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ static unsafe class UnsafeUtility
public static List<Tuple<string, int>> EnumerateProcesses()
{
int bytesReturned = 0;
var pids = new int[2048];
var pids = new int[16384];

fixed(int* p = pids) {
if (!NativeMethods.EnumProcesses((IntPtr)p, sizeof(int) * pids.Length, out bytesReturned)) {
Expand Down

0 comments on commit 589f835

Please sign in to comment.