New upstream version 26.0.0+dfsg1

This commit is contained in:
Sebastian Ramacher 2020-10-01 22:15:25 +02:00
parent 8e020cdacb
commit 240080891f
837 changed files with 41275 additions and 9196 deletions

View file

@ -14,8 +14,6 @@ include_directories(${LIBLZMA_INCLUDE_DIRS})
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/libobs")
include_directories(${BLAKE2_INCLUDE_DIR})
find_package(ZLIB REQUIRED)
set(updater_HEADERS
../win-update-helpers.hpp
resource.h
@ -51,3 +49,4 @@ target_link_libraries(updater
shell32
winhttp
)
set_target_properties(updater PROPERTIES FOLDER "frontend")

View file

@ -45,6 +45,7 @@ void StringToHash(const wchar_t *in, BYTE *out)
bool CalculateFileHash(const wchar_t *path, BYTE *hash)
{
static BYTE hashBuffer[1048576];
blake2b_state blake2;
if (blake2b_init(&blake2, BLAKE2_HASH_LENGTH) != 0)
return false;
@ -54,19 +55,16 @@ bool CalculateFileHash(const wchar_t *path, BYTE *hash)
if (handle == INVALID_HANDLE_VALUE)
return false;
vector<BYTE> buf;
buf.resize(65536);
for (;;) {
DWORD read = 0;
if (!ReadFile(handle, buf.data(), (DWORD)buf.size(), &read,
if (!ReadFile(handle, hashBuffer, sizeof(hashBuffer), &read,
nullptr))
return false;
if (!read)
break;
if (blake2b_update(&blake2, buf.data(), read) != 0)
if (blake2b_update(&blake2, hashBuffer, read) != 0)
return false;
}

View file

@ -1153,17 +1153,31 @@ static bool Update(wchar_t *cmdLine)
GetCurrentDirectory(_countof(lpAppDataPath), lpAppDataPath);
StringCbCat(lpAppDataPath, sizeof(lpAppDataPath), L"\\config");
} else {
CoTaskMemPtr<wchar_t> pOut;
HRESULT hr = SHGetKnownFolderPath(FOLDERID_RoamingAppData,
KF_FLAG_DEFAULT, nullptr,
&pOut);
if (hr != S_OK) {
DWORD ret;
ret = GetEnvironmentVariable(L"OBS_USER_APPDATA_PATH",
lpAppDataPath,
_countof(lpAppDataPath));
if (ret >= _countof(lpAppDataPath)) {
Status(L"Update failed: Could not determine AppData "
L"location");
return false;
}
StringCbCopy(lpAppDataPath, sizeof(lpAppDataPath), pOut);
if (!ret) {
CoTaskMemPtr<wchar_t> pOut;
HRESULT hr = SHGetKnownFolderPath(
FOLDERID_RoamingAppData, KF_FLAG_DEFAULT,
nullptr, &pOut);
if (hr != S_OK) {
Status(L"Update failed: Could not determine AppData "
L"location");
return false;
}
StringCbCopy(lpAppDataPath, sizeof(lpAppDataPath),
pOut);
}
}
StringCbCat(lpAppDataPath, sizeof(lpAppDataPath), L"\\obs-studio");
@ -1410,6 +1424,40 @@ static bool Update(wchar_t *cmdLine)
}
}
/* ------------------------------------- *
* Install virtual camera */
if (!bIsPortable) {
wchar_t regsvr[MAX_PATH];
wchar_t src[MAX_PATH];
wchar_t tmp[MAX_PATH];
wchar_t tmp2[MAX_PATH];
SHGetFolderPathW(nullptr, CSIDL_SYSTEM, nullptr,
SHGFP_TYPE_CURRENT, regsvr);
StringCbCat(regsvr, sizeof(regsvr), L"\\regsvr32.exe");
GetCurrentDirectoryW(_countof(src), src);
StringCbCat(src, sizeof(src),
L"\\data\\obs-plugins\\win-dshow\\");
StringCbCopy(tmp, sizeof(tmp), L"\"\"");
StringCbCat(tmp, sizeof(tmp), regsvr);
StringCbCat(tmp, sizeof(tmp), L"\" /s \"");
StringCbCat(tmp, sizeof(tmp), src);
StringCbCat(tmp, sizeof(tmp), L"obs-virtualcam-module");
StringCbCopy(tmp2, sizeof(tmp2), tmp);
StringCbCat(tmp2, sizeof(tmp2), L"32.dll\"\"");
_wsystem(tmp2);
if (is_64bit_windows()) {
StringCbCopy(tmp2, sizeof(tmp2), tmp);
StringCbCat(tmp2, sizeof(tmp2), L"64.dll\"\"");
_wsystem(tmp2);
}
}
/* ------------------------------------- *
* Update hook files and vulkan registry */
@ -1563,16 +1611,13 @@ static INT_PTR CALLBACK UpdateDialogProc(HWND hwnd, UINT message, WPARAM wParam,
return false;
}
static void RestartAsAdmin(LPWSTR lpCmdLine)
static int RestartAsAdmin(LPCWSTR lpCmdLine, LPCWSTR cwd)
{
wchar_t myPath[MAX_PATH];
if (!GetModuleFileNameW(nullptr, myPath, _countof(myPath) - 1)) {
return;
return 0;
}
wchar_t cwd[MAX_PATH];
GetCurrentDirectoryW(_countof(cwd) - 1, cwd);
SHELLEXECUTEINFO shExInfo = {0};
shExInfo.cbSize = sizeof(shExInfo);
shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
@ -1588,16 +1633,27 @@ static void RestartAsAdmin(LPWSTR lpCmdLine)
* windows :( */
AllowSetForegroundWindow(ASFW_ANY);
/* if the admin is a different user, save the path to the user's
* appdata so we can load the correct manifest */
CoTaskMemPtr<wchar_t> pOut;
HRESULT hr = SHGetKnownFolderPath(FOLDERID_RoamingAppData,
KF_FLAG_DEFAULT, nullptr, &pOut);
if (hr == S_OK)
SetEnvironmentVariable(L"OBS_USER_APPDATA_PATH", pOut);
if (ShellExecuteEx(&shExInfo)) {
DWORD exitCode;
WaitForSingleObject(shExInfo.hProcess, INFINITE);
if (GetExitCodeProcess(shExInfo.hProcess, &exitCode)) {
if (exitCode == 1) {
LaunchOBS();
return exitCode;
}
}
CloseHandle(shExInfo.hProcess);
}
return 0;
}
static bool HasElevation()
@ -1622,11 +1678,36 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int)
{
INITCOMMONCONTROLSEX icce;
wchar_t cwd[MAX_PATH];
wchar_t newPath[MAX_PATH];
GetCurrentDirectoryW(_countof(cwd) - 1, cwd);
is32bit = wcsstr(cwd, L"bin\\32bit") != nullptr;
if (!HasElevation()) {
WinHandle hMutex = OpenMutex(
SYNCHRONIZE, false, L"OBSUpdaterRunningAsNonAdminUser");
if (hMutex) {
MessageBox(
nullptr, L"Updater Error",
L"OBS Studio Updater must be run as an administrator.",
MB_ICONWARNING);
return 2;
}
HANDLE hLowMutex = CreateMutexW(
nullptr, true, L"OBSUpdaterRunningAsNonAdminUser");
RestartAsAdmin(lpCmdLine);
/* return code 1 = user wanted to launch OBS */
if (RestartAsAdmin(lpCmdLine, cwd) == 1) {
StringCbCat(cwd, sizeof(cwd), L"\\..\\..");
GetFullPathName(cwd, _countof(newPath), newPath,
nullptr);
SetCurrentDirectory(newPath);
LaunchOBS();
}
if (hLowMutex) {
ReleaseMutex(hLowMutex);
@ -1635,18 +1716,9 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int)
return 0;
} else {
{
wchar_t cwd[MAX_PATH];
wchar_t newPath[MAX_PATH];
GetCurrentDirectoryW(_countof(cwd) - 1, cwd);
is32bit = wcsstr(cwd, L"bin\\32bit") != nullptr;
StringCbCat(cwd, sizeof(cwd), L"\\..\\..");
GetFullPathName(cwd, _countof(newPath), newPath,
nullptr);
SetCurrentDirectory(newPath);
}
StringCbCat(cwd, sizeof(cwd), L"\\..\\..");
GetFullPathName(cwd, _countof(newPath), newPath, nullptr);
SetCurrentDirectory(newPath);
hinstMain = hInstance;

View file

@ -274,14 +274,14 @@ static bool VerifyDigitalSignature(uint8_t *buf, size_t len, uint8_t *sig,
if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO,
binaryKey, binaryKeyLen,
CRYPT_ENCODE_ALLOC_FLAG, nullptr, &publicPBLOB,
CRYPT_DECODE_ALLOC_FLAG, nullptr, &publicPBLOB,
&iPBLOBSize))
return false;
if (!CryptDecodeObjectEx(X509_ASN_ENCODING, RSA_CSP_PUBLICKEYBLOB,
publicPBLOB->PublicKey.pbData,
publicPBLOB->PublicKey.cbData,
CRYPT_ENCODE_ALLOC_FLAG, nullptr,
CRYPT_DECODE_ALLOC_FLAG, nullptr,
&rsaPublicBLOB, &rsaPublicBLOBSize))
return false;