New upstream version 24.0.1+dfsg1

This commit is contained in:
Sebastian Ramacher 2019-09-22 23:19:10 +02:00
parent b14f9eae6d
commit 5a730d6ec3
842 changed files with 42245 additions and 33385 deletions

View file

@ -2,10 +2,9 @@
#include "obs-app.hpp"
OBSUpdate::OBSUpdate(QWidget *parent, bool manualUpdate, const QString &text)
: QDialog (parent, Qt::WindowSystemMenuHint |
Qt::WindowTitleHint |
Qt::WindowCloseButtonHint),
ui (new Ui_OBSUpdate)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint |
Qt::WindowCloseButtonHint),
ui(new Ui_OBSUpdate)
{
ui->setupUi(this);
ui->text->setHtml(text);

View file

@ -9,11 +9,7 @@ class OBSUpdate : public QDialog {
Q_OBJECT
public:
enum ReturnVal {
No,
Yes,
Skip
};
enum ReturnVal { No, Yes, Skip };
OBSUpdate(QWidget *parent, bool manualUpdate, const QString &text);

View file

@ -26,7 +26,7 @@ void HashToString(const uint8_t *in, wchar_t *out)
const wchar_t alphabet[] = L"0123456789abcdef";
for (int i = 0; i != BLAKE2_HASH_LENGTH; ++i) {
out[2 * i] = alphabet[in[i] / 16];
out[2 * i] = alphabet[in[i] / 16];
out[2 * i + 1] = alphabet[in[i] % 16];
}
@ -35,7 +35,7 @@ void HashToString(const uint8_t *in, wchar_t *out)
void StringToHash(const wchar_t *in, BYTE *out)
{
int temp;
unsigned int temp;
for (int i = 0; i < BLAKE2_HASH_LENGTH; i++) {
swscanf_s(in + i * 2, L"%02x", &temp);
@ -50,7 +50,7 @@ bool CalculateFileHash(const wchar_t *path, BYTE *hash)
return false;
WinHandle handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ,
nullptr, OPEN_EXISTING, 0, nullptr);
nullptr, OPEN_EXISTING, 0, nullptr);
if (handle == INVALID_HANDLE_VALUE)
return false;
@ -60,7 +60,7 @@ bool CalculateFileHash(const wchar_t *path, BYTE *hash)
for (;;) {
DWORD read = 0;
if (!ReadFile(handle, buf.data(), (DWORD)buf.size(), &read,
nullptr))
nullptr))
return false;
if (!read)

View file

@ -20,7 +20,7 @@
using namespace std;
#define MAX_BUF_SIZE 262144
#define MAX_BUF_SIZE 262144
#define READ_BUF_SIZE 32768
/* ------------------------------------------------------------------------ */
@ -36,8 +36,8 @@ public:
inflateEnd(&strm);
}
inline operator z_stream*() {return &strm;}
inline z_stream *operator->() {return &strm;}
inline operator z_stream *() { return &strm; }
inline z_stream *operator->() { return &strm; }
inline bool inflate()
{
@ -50,14 +50,15 @@ public:
/* ------------------------------------------------------------------------ */
static bool ReadZippedHTTPData(string &responseBuf, z_stream *strm,
string &zipBuf, const uint8_t *buffer, DWORD outSize)
string &zipBuf, const uint8_t *buffer,
DWORD outSize)
{
strm->avail_in = outSize;
strm->next_in = buffer;
strm->next_in = buffer;
do {
strm->avail_out = (uInt)zipBuf.size();
strm->next_out = (Bytef *)zipBuf.data();
strm->next_out = (Bytef *)zipBuf.data();
int zret = inflate(strm, Z_NO_FLUSH);
if (zret != Z_STREAM_END && zret != Z_OK)
@ -65,7 +66,7 @@ static bool ReadZippedHTTPData(string &responseBuf, z_stream *strm,
try {
responseBuf.append(zipBuf.data(),
zipBuf.size() - strm->avail_out);
zipBuf.size() - strm->avail_out);
} catch (...) {
return false;
}
@ -75,7 +76,7 @@ static bool ReadZippedHTTPData(string &responseBuf, z_stream *strm,
}
static bool ReadHTTPData(string &responseBuf, const uint8_t *buffer,
DWORD outSize)
DWORD outSize)
{
try {
responseBuf.append((const char *)buffer, outSize);
@ -85,19 +86,16 @@ static bool ReadHTTPData(string &responseBuf, const uint8_t *buffer,
return true;
}
bool HTTPPostData(const wchar_t *url,
const BYTE * data,
int dataLen,
const wchar_t *extraHeaders,
int * responseCode,
string & responseBuf)
bool HTTPPostData(const wchar_t *url, const BYTE *data, int dataLen,
const wchar_t *extraHeaders, int *responseCode,
string &responseBuf)
{
HttpHandle hSession;
HttpHandle hConnect;
HttpHandle hRequest;
string zipBuf;
HttpHandle hSession;
HttpHandle hConnect;
HttpHandle hRequest;
string zipBuf;
URL_COMPONENTS urlComponents = {};
bool secure = false;
bool secure = false;
wchar_t hostName[256];
wchar_t path[1024];
@ -113,10 +111,10 @@ bool HTTPPostData(const wchar_t *url,
urlComponents.dwStructSize = sizeof(urlComponents);
urlComponents.lpszHostName = hostName;
urlComponents.lpszHostName = hostName;
urlComponents.dwHostNameLength = _countof(hostName);
urlComponents.lpszUrlPath = path;
urlComponents.lpszUrlPath = path;
urlComponents.dwUrlPathLength = _countof(path);
WinHttpCrackUrl(url, 0, 0, &urlComponents);
@ -128,22 +126,21 @@ bool HTTPPostData(const wchar_t *url,
* connect to server */
hSession = WinHttpOpen(L"OBS Studio Updater/2.1",
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS,
0);
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS,
0);
if (!hSession) {
*responseCode = -1;
return false;
}
WinHttpSetOption(hSession, WINHTTP_OPTION_SECURE_PROTOCOLS,
(LPVOID)&tlsProtocols, sizeof(tlsProtocols));
(LPVOID)&tlsProtocols, sizeof(tlsProtocols));
hConnect = WinHttpConnect(hSession, hostName,
secure
? INTERNET_DEFAULT_HTTPS_PORT
: INTERNET_DEFAULT_HTTP_PORT, 0);
secure ? INTERNET_DEFAULT_HTTPS_PORT
: INTERNET_DEFAULT_HTTP_PORT,
0);
if (!hConnect) {
*responseCode = -2;
return false;
@ -152,24 +149,19 @@ bool HTTPPostData(const wchar_t *url,
/* -------------------------------------- *
* request data */
hRequest = WinHttpOpenRequest(hConnect,
L"POST",
path,
nullptr,
WINHTTP_NO_REFERER,
acceptTypes,
secure
? WINHTTP_FLAG_SECURE |
WINHTTP_FLAG_REFRESH
: WINHTTP_FLAG_REFRESH);
hRequest = WinHttpOpenRequest(hConnect, L"POST", path, nullptr,
WINHTTP_NO_REFERER, acceptTypes,
secure ? WINHTTP_FLAG_SECURE |
WINHTTP_FLAG_REFRESH
: WINHTTP_FLAG_REFRESH);
if (!hRequest) {
*responseCode = -3;
return false;
}
bool bResults = !!WinHttpSendRequest(hRequest, extraHeaders,
extraHeaders ? -1 : 0,
(void *)data, dataLen, dataLen, 0);
extraHeaders ? -1 : 0,
(void *)data, dataLen, dataLen, 0);
/* -------------------------------------- *
* end request */
@ -185,18 +177,15 @@ bool HTTPPostData(const wchar_t *url,
* get headers */
wchar_t encoding[64];
DWORD encodingLen;
DWORD encodingLen;
wchar_t statusCode[8];
DWORD statusCodeLen;
DWORD statusCodeLen;
statusCodeLen = sizeof(statusCode);
if (!WinHttpQueryHeaders(hRequest,
WINHTTP_QUERY_STATUS_CODE,
WINHTTP_HEADER_NAME_BY_INDEX,
&statusCode,
&statusCodeLen,
WINHTTP_NO_HEADER_INDEX)) {
if (!WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE,
WINHTTP_HEADER_NAME_BY_INDEX, &statusCode,
&statusCodeLen, WINHTTP_NO_HEADER_INDEX)) {
*responseCode = -4;
return false;
} else {
@ -204,12 +193,9 @@ bool HTTPPostData(const wchar_t *url,
}
encodingLen = sizeof(encoding);
if (!WinHttpQueryHeaders(hRequest,
WINHTTP_QUERY_CONTENT_ENCODING,
WINHTTP_HEADER_NAME_BY_INDEX,
encoding,
&encodingLen,
WINHTTP_NO_HEADER_INDEX)) {
if (!WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_CONTENT_ENCODING,
WINHTTP_HEADER_NAME_BY_INDEX, encoding,
&encodingLen, WINHTTP_NO_HEADER_INDEX)) {
encoding[0] = 0;
if (GetLastError() != ERROR_WINHTTP_HEADER_NOT_FOUND) {
*responseCode = -5;
@ -238,11 +224,11 @@ bool HTTPPostData(const wchar_t *url,
bool gzip = wcscmp(encoding, L"gzip") == 0;
if (gzip) {
strm->zalloc = Z_NULL;
strm->zfree = Z_NULL;
strm->opaque = Z_NULL;
strm->zalloc = Z_NULL;
strm->zfree = Z_NULL;
strm->opaque = Z_NULL;
strm->avail_in = 0;
strm->next_in = Z_NULL;
strm->next_in = Z_NULL;
if (!strm.inflate())
return false;
@ -278,7 +264,7 @@ bool HTTPPostData(const wchar_t *url,
dwSize = std::min(dwSize, (DWORD)sizeof(buffer));
if (!WinHttpReadData(hRequest, (void *)buffer, dwSize,
&outSize)) {
&outSize)) {
*responseCode = -9;
return false;
}
@ -311,25 +297,23 @@ bool HTTPPostData(const wchar_t *url,
/* ------------------------------------------------------------------------ */
static bool ReadHTTPZippedFile(z_stream *strm, HANDLE updateFile,
string &zipBuf, const uint8_t *buffer, DWORD outSize,
int *responseCode)
string &zipBuf, const uint8_t *buffer,
DWORD outSize, int *responseCode)
{
strm->avail_in = outSize;
strm->next_in = buffer;
strm->next_in = buffer;
do {
strm->avail_out = (uInt)zipBuf.size();
strm->next_out = (Bytef *)zipBuf.data();
strm->next_out = (Bytef *)zipBuf.data();
int zret = inflate(strm, Z_NO_FLUSH);
if (zret != Z_STREAM_END && zret != Z_OK)
return false;
DWORD written;
if (!WriteFile(updateFile,
zipBuf.data(),
MAX_BUF_SIZE - strm->avail_out,
&written,
if (!WriteFile(updateFile, zipBuf.data(),
MAX_BUF_SIZE - strm->avail_out, &written,
nullptr)) {
*responseCode = -10;
return false;
@ -346,7 +330,7 @@ static bool ReadHTTPZippedFile(z_stream *strm, HANDLE updateFile,
}
static bool ReadHTTPFile(HANDLE updateFile, const uint8_t *buffer,
DWORD outSize, int *responseCode)
DWORD outSize, int *responseCode)
{
DWORD written;
if (!WriteFile(updateFile, buffer, outSize, &written, nullptr)) {
@ -363,20 +347,18 @@ static bool ReadHTTPFile(HANDLE updateFile, const uint8_t *buffer,
return true;
}
bool HTTPGetFile(HINTERNET hConnect,
const wchar_t *url,
const wchar_t *outputPath,
const wchar_t *extraHeaders,
int * responseCode)
bool HTTPGetFile(HINTERNET hConnect, const wchar_t *url,
const wchar_t *outputPath, const wchar_t *extraHeaders,
int *responseCode)
{
HttpHandle hRequest;
const wchar_t *acceptTypes[] = {L"*/*", nullptr};
URL_COMPONENTS urlComponents = {};
bool secure = false;
bool secure = false;
string zipBuf;
string zipBuf;
wchar_t hostName[256];
wchar_t path[1024];
@ -385,10 +367,10 @@ bool HTTPGetFile(HINTERNET hConnect,
urlComponents.dwStructSize = sizeof(urlComponents);
urlComponents.lpszHostName = hostName;
urlComponents.lpszHostName = hostName;
urlComponents.dwHostNameLength = _countof(hostName);
urlComponents.lpszUrlPath = path;
urlComponents.lpszUrlPath = path;
urlComponents.dwUrlPathLength = _countof(path);
WinHttpCrackUrl(url, 0, 0, &urlComponents);
@ -399,23 +381,19 @@ bool HTTPGetFile(HINTERNET hConnect,
/* -------------------------------------- *
* request data */
hRequest = WinHttpOpenRequest(hConnect,
L"GET",
path,
nullptr,
WINHTTP_NO_REFERER,
acceptTypes,
secure
? WINHTTP_FLAG_SECURE |
WINHTTP_FLAG_REFRESH
: WINHTTP_FLAG_REFRESH);
hRequest = WinHttpOpenRequest(hConnect, L"GET", path, nullptr,
WINHTTP_NO_REFERER, acceptTypes,
secure ? WINHTTP_FLAG_SECURE |
WINHTTP_FLAG_REFRESH
: WINHTTP_FLAG_REFRESH);
if (!hRequest) {
*responseCode = -3;
return false;
}
bool bResults = !!WinHttpSendRequest(hRequest, extraHeaders,
extraHeaders ? -1 : 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0);
extraHeaders ? -1 : 0,
WINHTTP_NO_REQUEST_DATA, 0, 0, 0);
/* -------------------------------------- *
* end request */
@ -431,18 +409,15 @@ bool HTTPGetFile(HINTERNET hConnect,
* get headers */
wchar_t encoding[64];
DWORD encodingLen;
DWORD encodingLen;
wchar_t statusCode[8];
DWORD statusCodeLen;
DWORD statusCodeLen;
statusCodeLen = sizeof(statusCode);
if (!WinHttpQueryHeaders(hRequest,
WINHTTP_QUERY_STATUS_CODE,
WINHTTP_HEADER_NAME_BY_INDEX,
&statusCode,
&statusCodeLen,
WINHTTP_NO_HEADER_INDEX)) {
if (!WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE,
WINHTTP_HEADER_NAME_BY_INDEX, &statusCode,
&statusCodeLen, WINHTTP_NO_HEADER_INDEX)) {
*responseCode = -4;
return false;
} else {
@ -450,12 +425,9 @@ bool HTTPGetFile(HINTERNET hConnect,
}
encodingLen = sizeof(encoding);
if (!WinHttpQueryHeaders(hRequest,
WINHTTP_QUERY_CONTENT_ENCODING,
WINHTTP_HEADER_NAME_BY_INDEX,
encoding,
&encodingLen,
WINHTTP_NO_HEADER_INDEX)) {
if (!WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_CONTENT_ENCODING,
WINHTTP_HEADER_NAME_BY_INDEX, encoding,
&encodingLen, WINHTTP_NO_HEADER_INDEX)) {
encoding[0] = 0;
if (GetLastError() != ERROR_WINHTTP_HEADER_NOT_FOUND) {
*responseCode = -5;
@ -472,11 +444,11 @@ bool HTTPGetFile(HINTERNET hConnect,
bool gzip = wcscmp(encoding, L"gzip") == 0;
if (gzip) {
strm->zalloc = Z_NULL;
strm->zfree = Z_NULL;
strm->opaque = Z_NULL;
strm->zalloc = Z_NULL;
strm->zfree = Z_NULL;
strm->opaque = Z_NULL;
strm->avail_in = 0;
strm->next_in = Z_NULL;
strm->next_in = Z_NULL;
if (!strm.inflate())
return false;
@ -498,12 +470,12 @@ bool HTTPGetFile(HINTERNET hConnect,
if (!bResults || *responseCode != 200)
return true;
BYTE buffer[READ_BUF_SIZE];
BYTE buffer[READ_BUF_SIZE];
DWORD dwSize, outSize;
int lastPosition = 0;
int lastPosition = 0;
WinHandle updateFile = CreateFile(outputPath, GENERIC_WRITE, 0,
nullptr, CREATE_ALWAYS, 0, nullptr);
WinHandle updateFile = CreateFile(outputPath, GENERIC_WRITE, 0, nullptr,
CREATE_ALWAYS, 0, nullptr);
if (!updateFile.Valid()) {
*responseCode = -7;
return false;
@ -520,7 +492,7 @@ bool HTTPGetFile(HINTERNET hConnect,
dwSize = std::min(dwSize, (DWORD)sizeof(buffer));
if (!WinHttpReadData(hRequest, (void *)buffer, dwSize,
&outSize)) {
&outSize)) {
*responseCode = -9;
return false;
} else {
@ -529,21 +501,22 @@ bool HTTPGetFile(HINTERNET hConnect,
if (gzip) {
if (!ReadHTTPZippedFile(strm, updateFile,
zipBuf, buffer,
outSize, responseCode))
zipBuf, buffer, outSize,
responseCode))
return false;
} else {
if (!ReadHTTPFile(updateFile, buffer,
outSize, responseCode))
if (!ReadHTTPFile(updateFile, buffer, outSize,
responseCode))
return false;
}
int position = (int)(((float)completedFileSize /
(float)totalFileSize) * 100.0f);
(float)totalFileSize) *
100.0f);
if (position > lastPosition) {
lastPosition = position;
SendDlgItemMessage(hwndMain, IDC_PROGRESS,
PBM_SETPOS, position, 0);
PBM_SETPOS, position, 0);
}
}

View file

@ -20,16 +20,16 @@
#include <vector>
#ifdef _MSC_VER
# define restrict __restrict
# include <lzma.h>
# undef restrict
#define restrict __restrict
#include <lzma.h>
#undef restrict
#else
# include <lzma.h>
#include <lzma.h>
#endif
using namespace std;
#define MAX_BUF_SIZE 262144
#define MAX_BUF_SIZE 262144
#define READ_BUF_SIZE 32768
/* ------------------------------------------------------------------------ */
@ -48,10 +48,7 @@ public:
inline bool init_decoder()
{
lzma_ret ret = lzma_stream_decoder(
&strm,
200 * 1024 * 1024,
0);
lzma_ret ret = lzma_stream_decoder(&strm, 200 * 1024 * 1024, 0);
initialized = (ret == LZMA_OK);
return initialized;
}
@ -82,7 +79,7 @@ public:
struct bspatch_stream {
void *opaque;
int (*read)(const struct bspatch_stream *stream, void *buffer,
int length);
int length);
};
/* ------------------------------------------------------------------------ */
@ -116,7 +113,7 @@ static int64_t offtin(const uint8_t *buf)
/* ------------------------------------------------------------------------ */
static int bspatch(const uint8_t *old, int64_t oldsize, uint8_t *newp,
int64_t newsize, struct bspatch_stream *stream)
int64_t newsize, struct bspatch_stream *stream)
{
uint8_t buf[8];
int64_t oldpos, newpos;
@ -169,9 +166,9 @@ static int bspatch(const uint8_t *old, int64_t oldsize, uint8_t *newp,
/* ------------------------------------------------------------------------ */
struct patch_data {
HANDLE h;
lzma_stream *strm;
uint8_t buf[READ_BUF_SIZE];
HANDLE h;
lzma_stream *strm;
uint8_t buf[READ_BUF_SIZE];
};
static int read_lzma(const struct bspatch_stream *stream, void *buffer, int len)
@ -179,24 +176,24 @@ static int read_lzma(const struct bspatch_stream *stream, void *buffer, int len)
if (!len)
return 0;
patch_data *data = (patch_data*)stream->opaque;
HANDLE h = data->h;
lzma_stream *strm = data->strm;
patch_data *data = (patch_data *)stream->opaque;
HANDLE h = data->h;
lzma_stream *strm = data->strm;
strm->avail_out = (size_t)len;
strm->next_out = (uint8_t *)buffer;
strm->next_out = (uint8_t *)buffer;
for (;;) {
if (strm->avail_in == 0) {
DWORD read_size;
if (!ReadFile(h, data->buf, READ_BUF_SIZE, &read_size,
nullptr))
nullptr))
return -1;
if (read_size == 0)
return -1;
strm->avail_in = (size_t)read_size;
strm->next_in = data->buf;
strm->next_in = data->buf;
}
lzma_ret ret = lzma_code(strm, LZMA_RUN);
@ -213,25 +210,25 @@ static int read_lzma(const struct bspatch_stream *stream, void *buffer, int len)
int ApplyPatch(const wchar_t *patchFile, const wchar_t *targetFile)
try {
uint8_t header[24];
int64_t newsize;
uint8_t header[24];
int64_t newsize;
struct bspatch_stream stream;
bool success;
bool success;
WinHandle hPatch;
WinHandle hTarget;
WinHandle hPatch;
WinHandle hTarget;
LZMAStream strm;
/* --------------------------------- *
* open patch and file to patch */
hPatch = CreateFile(patchFile, GENERIC_READ, 0, nullptr,
OPEN_EXISTING, 0, nullptr);
hPatch = CreateFile(patchFile, GENERIC_READ, 0, nullptr, OPEN_EXISTING,
0, nullptr);
if (!hPatch.Valid())
throw int(GetLastError());
hTarget = CreateFile(targetFile, GENERIC_READ, 0, nullptr,
OPEN_EXISTING, 0, nullptr);
OPEN_EXISTING, 0, nullptr);
if (!hTarget.Valid())
throw int(GetLastError());
@ -289,14 +286,14 @@ try {
throw int(-10);
patch_data data;
data.h = hPatch;
data.h = hPatch;
data.strm = strm.get();
stream.read = read_lzma;
stream.read = read_lzma;
stream.opaque = &data;
int ret = bspatch(oldData.data(), oldData.size(), newData.data(),
newData.size(), &stream);
newData.size(), &stream);
if (ret != 0)
throw int(-9);
@ -305,14 +302,14 @@ try {
hTarget = nullptr;
hTarget = CreateFile(targetFile, GENERIC_WRITE, 0, nullptr,
CREATE_ALWAYS, 0, nullptr);
CREATE_ALWAYS, 0, nullptr);
if (!hTarget.Valid())
throw int(GetLastError());
DWORD written;
success = !!WriteFile(hTarget, newData.data(), (DWORD)newsize,
&written, nullptr);
success = !!WriteFile(hTarget, newData.data(), (DWORD)newsize, &written,
nullptr);
if (!success || written != newsize)
throw int(GetLastError());

View file

@ -2,20 +2,20 @@
// Microsoft Visual C++ generated include file.
// Used by updater.rc
//
#define IDD_UPDATEDIALOG 101
#define IDI_ICON1 103
#define IDC_PROGRESS 1001
#define IDC_STATUS 1002
#define IDCBUTTON 1004
#define IDC_BUTTON 1004
#define IDD_UPDATEDIALOG 101
#define IDI_ICON1 103
#define IDC_PROGRESS 1001
#define IDC_STATUS 1002
#define IDCBUTTON 1004
#define IDC_BUTTON 1004
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1005
#define _APS_NEXT_SYMED_VALUE 101
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1005
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

File diff suppressed because it is too large Load diff

View file

@ -45,53 +45,44 @@
#define BLAKE2_HASH_STR_LENGTH ((BLAKE2_HASH_LENGTH * 2) + 1)
#if defined _M_IX86
#pragma comment(linker, \
"/manifestdependency:\"type='win32' " \
"name='Microsoft.Windows.Common-Controls' " \
"version='6.0.0.0' " \
"processorArchitecture='x86' " \
"publicKeyToken='6595b64144ccf1df' " \
"language='*'\"")
#pragma comment(linker, "/manifestdependency:\"type='win32' " \
"name='Microsoft.Windows.Common-Controls' " \
"version='6.0.0.0' " \
"processorArchitecture='x86' " \
"publicKeyToken='6595b64144ccf1df' " \
"language='*'\"")
#elif defined _M_IA64
#pragma comment(linker, \
"/manifestdependency:\"type='win32' " \
"name='Microsoft.Windows.Common-Controls' " \
"version='6.0.0.0' " \
"processorArchitecture='ia64' " \
"publicKeyToken='6595b64144ccf1df' " \
"language='*'\"")
#pragma comment(linker, "/manifestdependency:\"type='win32' " \
"name='Microsoft.Windows.Common-Controls' " \
"version='6.0.0.0' " \
"processorArchitecture='ia64' " \
"publicKeyToken='6595b64144ccf1df' " \
"language='*'\"")
#elif defined _M_X64
#pragma comment(linker, \
"/manifestdependency:\"type='win32' " \
"name='Microsoft.Windows.Common-Controls' " \
"version='6.0.0.0' " \
"processorArchitecture='amd64' " \
"publicKeyToken='6595b64144ccf1df' " \
"language='*'\"")
#pragma comment(linker, "/manifestdependency:\"type='win32' " \
"name='Microsoft.Windows.Common-Controls' " \
"version='6.0.0.0' " \
"processorArchitecture='amd64' " \
"publicKeyToken='6595b64144ccf1df' " \
"language='*'\"")
#else
#pragma comment(linker, \
"/manifestdependency:\"type='win32' " \
"name='Microsoft.Windows.Common-Controls' " \
"version='6.0.0.0' processorArchitecture='*' " \
"publicKeyToken='6595b64144ccf1df' " \
"language='*'\"")
#pragma comment(linker, "/manifestdependency:\"type='win32' " \
"name='Microsoft.Windows.Common-Controls' " \
"version='6.0.0.0' processorArchitecture='*' " \
"publicKeyToken='6595b64144ccf1df' " \
"language='*'\"")
#endif
#include <util/windows/WinHandle.hpp>
#include <jansson.h>
#include "resource.h"
bool HTTPGetFile(HINTERNET hConnect,
const wchar_t *url,
const wchar_t *outputPath,
const wchar_t *extraHeaders,
int * responseCode);
bool HTTPPostData(const wchar_t *url,
const BYTE * data,
int dataLen,
const wchar_t *extraHeaders,
int * responseCode,
std::string & response);
bool HTTPGetFile(HINTERNET hConnect, const wchar_t *url,
const wchar_t *outputPath, const wchar_t *extraHeaders,
int *responseCode);
bool HTTPPostData(const wchar_t *url, const BYTE *data, int dataLen,
const wchar_t *extraHeaders, int *responseCode,
std::string &response);
void HashToString(const BYTE *in, wchar_t *out);
void StringToHash(const wchar_t *in, BYTE *out);
@ -100,17 +91,17 @@ bool CalculateFileHash(const wchar_t *path, BYTE *hash);
int ApplyPatch(LPCTSTR patchFile, LPCTSTR targetFile);
extern HWND hwndMain;
extern HWND hwndMain;
extern HCRYPTPROV hProvider;
extern int totalFileSize;
extern int completedFileSize;
extern HANDLE cancelRequested;
extern int totalFileSize;
extern int completedFileSize;
extern HANDLE cancelRequested;
#pragma pack(push, r1, 1)
typedef struct {
BLOBHEADER blobheader;
RSAPUBKEY rsapubkey;
RSAPUBKEY rsapubkey;
} PUBLICKEYHEADER;
#pragma pack(pop, r1)

View file

@ -23,9 +23,9 @@ public:
freefunc(handle);
}
inline T *operator&() {return &handle;}
inline operator T() const {return handle;}
inline T get() const {return handle;}
inline T *operator&() { return &handle; }
inline operator T() const { return handle; }
inline T get() const { return handle; }
inline CustomHandle<T, freefunc> &operator=(T in)
{
@ -35,7 +35,7 @@ public:
return *this;
}
inline bool operator!() const {return !handle;}
inline bool operator!() const { return !handle; }
};
void FreeProvider(HCRYPTPROV prov);
@ -43,8 +43,8 @@ void FreeHash(HCRYPTHASH hash);
void FreeKey(HCRYPTKEY key);
using CryptProvider = CustomHandle<HCRYPTPROV, FreeProvider>;
using CryptHash = CustomHandle<HCRYPTHASH, FreeHash>;
using CryptKey = CustomHandle<HCRYPTKEY, FreeKey>;
using CryptHash = CustomHandle<HCRYPTHASH, FreeHash>;
using CryptKey = CustomHandle<HCRYPTKEY, FreeKey>;
/* ------------------------------------------------------------------------ */
@ -58,13 +58,13 @@ public:
LocalFree(ptr);
}
inline T **operator&() {return &ptr;}
inline operator T() const {return ptr;}
inline T *get() const {return ptr;}
inline T **operator&() { return &ptr; }
inline operator T() const { return ptr; }
inline T *get() const { return ptr; }
inline bool operator!() const {return !ptr;}
inline bool operator!() const { return !ptr; }
inline T *operator->() {return ptr;}
inline T *operator->() { return ptr; }
};
/* ------------------------------------------------------------------------ */
@ -76,9 +76,10 @@ public:
inline Json() : json(nullptr) {}
explicit inline Json(json_t *json_) : json(json_) {}
inline Json(const Json &from) : json(json_incref(from.json)) {}
inline Json(Json &&from) : json(from.json) {from.json = nullptr;}
inline Json(Json &&from) : json(from.json) { from.json = nullptr; }
inline ~Json() {
inline ~Json()
{
if (json)
json_decref(json);
}
@ -106,12 +107,12 @@ public:
return *this;
}
inline operator json_t *() const {return json;}
inline operator json_t *() const { return json; }
inline bool operator!() const {return !json;}
inline bool operator!() const { return !json; }
inline const char *GetString(const char *name,
const char *def = nullptr) const
const char *def = nullptr) const
{
json_t *obj(json_object_get(json, name));
if (!obj)
@ -130,7 +131,7 @@ public:
return json_object_get(json, name);
}
inline json_t *get() const {return json;}
inline json_t *get() const { return json; }
};
/* ------------------------------------------------------------------------ */

View file

@ -42,7 +42,7 @@ static __declspec(thread) HCRYPTPROV provider = 0;
typedef struct {
BLOBHEADER blobheader;
RSAPUBKEY rsapubkey;
RSAPUBKEY rsapubkey;
} PUBLICKEYHEADER;
#pragma pack(pop, r1)
@ -120,8 +120,7 @@ static const unsigned char obs_pub[] = {
0x42, 0x61, 0x35, 0x66, 0x37, 0x4c, 0x6f, 0x4b, 0x38, 0x43, 0x41, 0x77,
0x45, 0x41, 0x41, 0x51, 0x3d, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x45, 0x4e, 0x44, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x4b,
0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a
};
0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a};
static const unsigned int obs_pub_len = 800;
/* ------------------------------------------------------------------------ */
@ -132,27 +131,22 @@ try {
if (os_utf8_to_wcs_ptr(file, 0, &w_file) == 0)
return false;
WinHandle handle = CreateFileW(
w_file,
GENERIC_WRITE,
0,
nullptr,
CREATE_ALWAYS,
FILE_FLAG_WRITE_THROUGH,
nullptr);
WinHandle handle = CreateFileW(w_file, GENERIC_WRITE, 0, nullptr,
CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH,
nullptr);
if (handle == INVALID_HANDLE_VALUE)
throw strprintf("Failed to open file '%s': %lu",
file, GetLastError());
throw strprintf("Failed to open file '%s': %lu", file,
GetLastError());
DWORD written;
if (!WriteFile(handle, data, (DWORD)size, &written, nullptr))
throw strprintf("Failed to write file '%s': %lu",
file, GetLastError());
throw strprintf("Failed to write file '%s': %lu", file,
GetLastError());
return true;
} catch (string text) {
} catch (string &text) {
blog(LOG_WARNING, "%s: %s", __FUNCTION__, text.c_str());
return false;
}
@ -163,30 +157,24 @@ try {
if (os_utf8_to_wcs_ptr(file, 0, &w_file) == 0)
return false;
WinHandle handle = CreateFileW(
w_file,
GENERIC_READ,
FILE_SHARE_READ,
nullptr,
OPEN_EXISTING,
0,
nullptr);
WinHandle handle = CreateFileW(w_file, GENERIC_READ, FILE_SHARE_READ,
nullptr, OPEN_EXISTING, 0, nullptr);
if (handle == INVALID_HANDLE_VALUE)
throw strprintf("Failed to open file '%s': %lu",
file, GetLastError());
throw strprintf("Failed to open file '%s': %lu", file,
GetLastError());
DWORD size = GetFileSize(handle, nullptr);
data.resize(size);
DWORD read;
if (!ReadFile(handle, &data[0], size, &read, nullptr))
throw strprintf("Failed to write file '%s': %lu",
file, GetLastError());
throw strprintf("Failed to write file '%s': %lu", file,
GetLastError());
return true;
} catch (string text) {
} catch (string &text) {
blog(LOG_WARNING, "%s: %s", __FUNCTION__, text.c_str());
return false;
}
@ -196,7 +184,7 @@ static void HashToString(const uint8_t *in, char *out)
const char alphabet[] = "0123456789abcdef";
for (int i = 0; i != BLAKE2_HASH_LENGTH; ++i) {
out[2 * i] = alphabet[in[i] / 16];
out[2 * i] = alphabet[in[i] / 16];
out[2 * i + 1] = alphabet[in[i] % 16];
}
@ -214,10 +202,10 @@ try {
return false;
WinHandle handle = CreateFileW(w_path, GENERIC_READ, FILE_SHARE_READ,
nullptr, OPEN_EXISTING, 0, nullptr);
nullptr, OPEN_EXISTING, 0, nullptr);
if (handle == INVALID_HANDLE_VALUE)
throw strprintf("Failed to open file '%s': %lu",
path, GetLastError());
throw strprintf("Failed to open file '%s': %lu", path,
GetLastError());
vector<BYTE> buf;
buf.resize(65536);
@ -225,9 +213,9 @@ try {
for (;;) {
DWORD read = 0;
if (!ReadFile(handle, buf.data(), (DWORD)buf.size(), &read,
nullptr))
throw strprintf("Failed to read file '%s': %lu",
path, GetLastError());
nullptr))
throw strprintf("Failed to read file '%s': %lu", path,
GetLastError());
if (!read)
break;
@ -241,7 +229,7 @@ try {
return true;
} catch (string text) {
} catch (string &text) {
blog(LOG_DEBUG, "%s: %s", __FUNCTION__, text.c_str());
return false;
}
@ -249,19 +237,19 @@ try {
/* ------------------------------------------------------------------------ */
static bool VerifyDigitalSignature(uint8_t *buf, size_t len, uint8_t *sig,
size_t sigLen)
size_t sigLen)
{
/* ASN of PEM public key */
BYTE binaryKey[1024];
BYTE binaryKey[1024];
DWORD binaryKeyLen = sizeof(binaryKey);
/* Windows X509 public key info from ASN */
LocalPtr<CERT_PUBLIC_KEY_INFO> publicPBLOB;
DWORD iPBLOBSize;
DWORD iPBLOBSize;
/* RSA BLOB info from X509 public key */
LocalPtr<PUBLICKEYHEADER> rsaPublicBLOB;
DWORD rsaPublicBLOBSize;
DWORD rsaPublicBLOBSize;
/* Handle to public key */
CryptKey keyOut;
@ -272,41 +260,26 @@ static bool VerifyDigitalSignature(uint8_t *buf, size_t len, uint8_t *sig,
/* Signature in little-endian format */
vector<BYTE> reversedSig;
if (!CryptStringToBinaryA((LPCSTR)obs_pub,
obs_pub_len,
CRYPT_STRING_BASE64HEADER,
binaryKey,
&binaryKeyLen,
nullptr,
nullptr))
if (!CryptStringToBinaryA((LPCSTR)obs_pub, obs_pub_len,
CRYPT_STRING_BASE64HEADER, binaryKey,
&binaryKeyLen, nullptr, nullptr))
return false;
if (!CryptDecodeObjectEx(X509_ASN_ENCODING,
X509_PUBLIC_KEY_INFO,
binaryKey,
binaryKeyLen,
CRYPT_ENCODE_ALLOC_FLAG,
nullptr,
&publicPBLOB,
&iPBLOBSize))
if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO,
binaryKey, binaryKeyLen,
CRYPT_ENCODE_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,
&rsaPublicBLOB,
&rsaPublicBLOBSize))
if (!CryptDecodeObjectEx(X509_ASN_ENCODING, RSA_CSP_PUBLICKEYBLOB,
publicPBLOB->PublicKey.pbData,
publicPBLOB->PublicKey.cbData,
CRYPT_ENCODE_ALLOC_FLAG, nullptr,
&rsaPublicBLOB, &rsaPublicBLOBSize))
return false;
if (!CryptImportKey(provider,
(const BYTE *)rsaPublicBLOB.get(),
rsaPublicBLOBSize,
0,
0,
&keyOut))
if (!CryptImportKey(provider, (const BYTE *)rsaPublicBLOB.get(),
rsaPublicBLOBSize, 0, 0, &keyOut))
return false;
if (!CryptCreateHash(provider, CALG_SHA_512, 0, 0, &hash))
@ -321,19 +294,15 @@ static bool VerifyDigitalSignature(uint8_t *buf, size_t len, uint8_t *sig,
for (size_t i = 0; i < sigLen; i++)
reversedSig[i] = sig[sigLen - i - 1];
if (!CryptVerifySignature(hash,
reversedSig.data(),
(DWORD)sigLen,
keyOut,
nullptr,
0))
if (!CryptVerifySignature(hash, reversedSig.data(), (DWORD)sigLen,
keyOut, nullptr, 0))
return false;
return true;
}
static inline void HexToByteArray(const char *hexStr, size_t hexLen,
vector<uint8_t> &out)
vector<uint8_t> &out)
{
char ptr[3];
@ -347,7 +316,7 @@ static inline void HexToByteArray(const char *hexStr, size_t hexLen,
}
static bool CheckDataSignature(const string &data, const char *name,
const char *hexSig, size_t sigLen)
const char *hexSig, size_t sigLen)
try {
if (sigLen == 0 || sigLen > 0xFFFF || (sigLen & 1) != 0)
throw strprintf("Missing or invalid signature for %s", name);
@ -357,15 +326,13 @@ try {
signature.reserve(sigLen);
HexToByteArray(hexSig, sigLen, signature);
if (!VerifyDigitalSignature((uint8_t*)data.data(),
data.size(),
signature.data(),
signature.size()))
if (!VerifyDigitalSignature((uint8_t *)data.data(), data.size(),
signature.data(), signature.size()))
throw strprintf("Signature check failed for %s", name);
return true;
} catch (string text) {
} catch (string &text) {
blog(LOG_WARNING, "%s: %s", __FUNCTION__, text.c_str());
return false;
}
@ -374,12 +341,12 @@ try {
static bool FetchUpdaterModule(const char *url)
try {
long responseCode;
uint8_t updateFileHash[BLAKE2_HASH_LENGTH];
long responseCode;
uint8_t updateFileHash[BLAKE2_HASH_LENGTH];
vector<string> extraHeaders;
BPtr<char> updateFilePath = GetConfigPathPtr(
"obs-studio\\updates\\updater.exe");
BPtr<char> updateFilePath =
GetConfigPathPtr("obs-studio\\updates\\updater.exe");
if (CalculateFileHash(updateFilePath, updateFileHash)) {
char hashString[BLAKE2_HASH_STR_LENGTH];
@ -394,8 +361,8 @@ try {
string error;
string data;
bool success = GetRemoteFile(url, data, error, &responseCode,
nullptr, nullptr, extraHeaders, &signature);
bool success = GetRemoteFile(url, data, error, &responseCode, nullptr,
nullptr, extraHeaders, &signature);
if (!success || (responseCode != 200 && responseCode != 304)) {
if (responseCode == 404)
@ -407,7 +374,7 @@ try {
/* A new file must be digitally signed */
if (responseCode == 200) {
bool valid = CheckDataSignature(data, url, signature.data(),
signature.size());
signature.size());
if (!valid)
throw string("Invalid updater module signature");
@ -417,7 +384,7 @@ try {
return true;
} catch (string text) {
} catch (string &text) {
blog(LOG_WARNING, "%s: %s", __FUNCTION__, text.c_str());
return false;
}
@ -425,7 +392,7 @@ try {
/* ------------------------------------------------------------------------ */
static bool ParseUpdateManifest(const char *manifest, bool *updatesAvailable,
string &notes_str, int &updateVer)
string &notes_str, int &updateVer)
try {
json_error_t error;
@ -442,10 +409,8 @@ try {
int patch = root.GetInt("version_patch");
if (major == 0)
throw strprintf("Invalid version number: %d.%d.%d",
major,
minor,
patch);
throw strprintf("Invalid version number: %d.%d.%d", major,
minor, patch);
json_t *notes = json_object_get(root, "notes");
if (!json_is_string(notes))
@ -465,7 +430,7 @@ try {
return true;
} catch (string text) {
} catch (string &text) {
blog(LOG_WARNING, "%s: %s", __FUNCTION__, text.c_str());
return false;
}
@ -491,8 +456,8 @@ string GetProgramGUID()
/* NOTE: this is an arbitrary random number that we use to count the
* number of unique OBS installations and is not associated with any
* kind of identifiable information */
const char *pguid = config_get_string(GetGlobalConfig(),
"General", "InstallGUID");
const char *pguid =
config_get_string(GetGlobalConfig(), "General", "InstallGUID");
string guid;
if (pguid)
guid = pguid;
@ -501,9 +466,8 @@ string GetProgramGUID()
GenerateGUID(guid);
if (!guid.empty())
config_set_string(GetGlobalConfig(),
"General", "InstallGUID",
guid.c_str());
config_set_string(GetGlobalConfig(), "General",
"InstallGUID", guid.c_str());
}
return guid;
@ -516,13 +480,12 @@ void AutoUpdateThread::infoMsg(const QString &title, const QString &text)
void AutoUpdateThread::info(const QString &title, const QString &text)
{
QMetaObject::invokeMethod(this, "infoMsg",
Qt::BlockingQueuedConnection,
Q_ARG(QString, title),
Q_ARG(QString, text));
QMetaObject::invokeMethod(this, "infoMsg", Qt::BlockingQueuedConnection,
Q_ARG(QString, title), Q_ARG(QString, text));
}
int AutoUpdateThread::queryUpdateSlot(bool localManualUpdate, const QString &text)
int AutoUpdateThread::queryUpdateSlot(bool localManualUpdate,
const QString &text)
{
OBSUpdate updateDlg(App()->GetMainWindow(), localManualUpdate, text);
return updateDlg.exec();
@ -533,17 +496,17 @@ int AutoUpdateThread::queryUpdate(bool localManualUpdate, const char *text_utf8)
int ret = OBSUpdate::No;
QString text = text_utf8;
QMetaObject::invokeMethod(this, "queryUpdateSlot",
Qt::BlockingQueuedConnection,
Q_RETURN_ARG(int, ret),
Q_ARG(bool, localManualUpdate),
Q_ARG(QString, text));
Qt::BlockingQueuedConnection,
Q_RETURN_ARG(int, ret),
Q_ARG(bool, localManualUpdate),
Q_ARG(QString, text));
return ret;
}
static bool IsFileInUse(const wstring &file)
{
WinHandle f = CreateFile(file.c_str(), GENERIC_WRITE, 0, nullptr,
OPEN_EXISTING, 0, nullptr);
OPEN_EXISTING, 0, nullptr);
if (!f.Valid()) {
int err = GetLastError();
if (err == ERROR_SHARING_VIOLATION ||
@ -557,35 +520,33 @@ static bool IsFileInUse(const wstring &file)
static bool IsGameCaptureInUse()
{
wstring path = L"..\\..\\data\\obs-plugins\\win-capture\\graphics-hook";
return IsFileInUse(path + L"32.dll") ||
IsFileInUse(path + L"64.dll");
return IsFileInUse(path + L"32.dll") || IsFileInUse(path + L"64.dll");
}
void AutoUpdateThread::run()
try {
long responseCode;
long responseCode;
vector<string> extraHeaders;
string text;
string error;
string signature;
CryptProvider localProvider;
BYTE manifestHash[BLAKE2_HASH_LENGTH];
bool updatesAvailable = false;
bool success;
string text;
string error;
string signature;
CryptProvider localProvider;
BYTE manifestHash[BLAKE2_HASH_LENGTH];
bool updatesAvailable = false;
bool success;
struct FinishedTrigger {
inline ~FinishedTrigger()
{
QMetaObject::invokeMethod(App()->GetMainWindow(),
"updateCheckFinished");
"updateCheckFinished");
}
} finishedTrigger;
BPtr<char> manifestPath = GetConfigPathPtr(
"obs-studio\\updates\\manifest.json");
BPtr<char> manifestPath =
GetConfigPathPtr("obs-studio\\updates\\manifest.json");
auto ActiveOrGameCaptureLocked = [this] ()
{
auto ActiveOrGameCaptureLocked = [this]() {
if (obs_video_active()) {
if (manualUpdate)
info(QTStr("Updater.Running.Title"),
@ -611,11 +572,8 @@ try {
/* ----------------------------------- *
* create signature provider */
if (!CryptAcquireContext(&localProvider,
nullptr,
MS_ENH_RSA_AES_PROV,
PROV_RSA_AES,
CRYPT_VERIFYCONTEXT))
if (!CryptAcquireContext(&localProvider, nullptr, MS_ENH_RSA_AES_PROV,
PROV_RSA_AES, CRYPT_VERIFYCONTEXT))
throw strprintf("CryptAcquireContext failed: %lu",
GetLastError());
@ -647,13 +605,14 @@ try {
* get manifest from server */
success = GetRemoteFile(WIN_MANIFEST_URL, text, error, &responseCode,
nullptr, nullptr, extraHeaders, &signature);
nullptr, nullptr, extraHeaders, &signature);
if (!success || (responseCode != 200 && responseCode != 304)) {
if (responseCode == 404)
return;
throw strprintf("Failed to fetch manifest file: %s", error.c_str());
throw strprintf("Failed to fetch manifest file: %s",
error.c_str());
}
/* ----------------------------------- *
@ -661,8 +620,8 @@ try {
/* a new file must be digitally signed */
if (responseCode == 200) {
success = CheckDataSignature(text, "manifest",
signature.data(), signature.size());
success = CheckDataSignature(text, "manifest", signature.data(),
signature.size());
if (!success)
throw string("Invalid manifest signature");
}
@ -687,7 +646,7 @@ try {
int updateVer = 0;
success = ParseUpdateManifest(text.c_str(), &updatesAvailable, notes,
updateVer);
updateVer);
if (!success)
throw string("Failed to parse manifest");
@ -702,7 +661,7 @@ try {
* skip this version if set to skip */
int skipUpdateVer = config_get_int(GetGlobalConfig(), "General",
"SkipUpdateVersion");
"SkipUpdateVersion");
if (!manualUpdate && updateVer == skipUpdateVer)
return;
@ -727,13 +686,13 @@ try {
if (!manualUpdate) {
long long t = (long long)time(nullptr);
config_set_int(GetGlobalConfig(), "General",
"LastUpdateCheck", t);
"LastUpdateCheck", t);
}
return;
} else if (queryResult == OBSUpdate::Skip) {
config_set_int(GetGlobalConfig(), "General",
"SkipUpdateVersion", updateVer);
"SkipUpdateVersion", updateVer);
return;
}
@ -749,8 +708,8 @@ try {
/* ----------------------------------- *
* execute updater */
BPtr<char> updateFilePath = GetConfigPathPtr(
"obs-studio\\updates\\updater.exe");
BPtr<char> updateFilePath =
GetConfigPathPtr("obs-studio\\updates\\updater.exe");
BPtr<wchar_t> wUpdateFilePath;
size_t size = os_utf8_to_wcs_ptr(updateFilePath, 0, &wUpdateFilePath);
@ -773,7 +732,7 @@ try {
execInfo.lpParameters = UPDATE_ARG_SUFFIX;
execInfo.lpDirectory = cwd;
execInfo.nShow = SW_SHOWNORMAL;
execInfo.nShow = SW_SHOWNORMAL;
if (!ShellExecuteEx(&execInfo)) {
QString msg = QTStr("Updater.FailedToLaunch");
@ -787,11 +746,11 @@ try {
config_set_int(GetGlobalConfig(), "General", "LastUpdateCheck", 0);
config_set_int(GetGlobalConfig(), "General", "SkipUpdateVersion", 0);
config_set_string(GetGlobalConfig(), "General", "InstallGUID",
guid.c_str());
guid.c_str());
QMetaObject::invokeMethod(App()->GetMainWindow(), "close");
} catch (string text) {
} catch (string &text) {
blog(LOG_WARNING, "%s: %s", __FUNCTION__, text.c_str());
}
@ -799,26 +758,23 @@ try {
void WhatsNewInfoThread::run()
try {
long responseCode;
long responseCode;
vector<string> extraHeaders;
string text;
string error;
string signature;
CryptProvider localProvider;
BYTE whatsnewHash[BLAKE2_HASH_LENGTH];
bool success;
string text;
string error;
string signature;
CryptProvider localProvider;
BYTE whatsnewHash[BLAKE2_HASH_LENGTH];
bool success;
BPtr<char> whatsnewPath = GetConfigPathPtr(
"obs-studio\\updates\\whatsnew.json");
BPtr<char> whatsnewPath =
GetConfigPathPtr("obs-studio\\updates\\whatsnew.json");
/* ----------------------------------- *
* create signature provider */
if (!CryptAcquireContext(&localProvider,
nullptr,
MS_ENH_RSA_AES_PROV,
PROV_RSA_AES,
CRYPT_VERIFYCONTEXT))
if (!CryptAcquireContext(&localProvider, nullptr, MS_ENH_RSA_AES_PROV,
PROV_RSA_AES, CRYPT_VERIFYCONTEXT))
throw strprintf("CryptAcquireContext failed: %lu",
GetLastError());
@ -851,7 +807,7 @@ try {
* get json from server */
success = GetRemoteFile(WIN_WHATSNEW_URL, text, error, &responseCode,
nullptr, nullptr, extraHeaders, &signature);
nullptr, nullptr, extraHeaders, &signature);
if (!success || (responseCode != 200 && responseCode != 304)) {
if (responseCode == 404)
@ -865,8 +821,8 @@ try {
* verify file signature */
if (responseCode == 200) {
success = CheckDataSignature(text, "whatsnew",
signature.data(), signature.size());
success = CheckDataSignature(text, "whatsnew", signature.data(),
signature.size());
if (!success)
throw string("Invalid whatsnew signature");
}
@ -889,6 +845,6 @@ try {
emit Result(QString::fromUtf8(text.c_str()));
} catch (string text) {
} catch (string &text) {
blog(LOG_WARNING, "%s: %s", __FUNCTION__, text.c_str());
}