Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store original path to registry to deliver promocode to installer #5

Merged
merged 1 commit into from Oct 12, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -633,6 +633,49 @@ HRESULT HandleError(HRESULT result) {
return result;
}

HRESULT StorePathToRegForPromoCode(LPSTR lpCmdLine) {
// This stub installer can be executed twice by internally when user allowed
// to run installer in admin mode. In this case, copied with changed filename
// |kOmahaMetainstallerFileName| at tempdir is used.
// In that case, command line is not empty.
// So, we can only get original file name when this run is user initiated.
if (!CString(lpCmdLine).IsEmpty())
return S_OK;

TCHAR module_file_name[MAX_PATH] = {};
DWORD len = ::GetModuleFileName(NULL,
module_file_name,
arraysize(module_file_name));
if (len == 0 || len >= arraysize(module_file_name)) {
_ASSERTE(false);
return NULL;
}

HKEY key;
DWORD dw;;
if (RegCreateKeyEx(HKEY_CURRENT_USER,
_T("Software\\BraveSoftware\\Promo"),
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_WRITE,
NULL, &key, &dw) != S_OK) {
return S_OK;
}

if (RegSetValueEx(key,
_T("StubInstallerPath"),
NULL,
REG_SZ,
reinterpret_cast<const byte *>(module_file_name),
(lstrlen(module_file_name) + 1) * sizeof(TCHAR)) != S_OK) {
return S_OK;
}

RegCloseKey(key);
return S_OK;
}

} // namespace

} // namespace omaha
@@ -651,6 +694,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int) {
return omaha::HandleError(hr);
}

omaha::StorePathToRegForPromoCode(lpCmdLine);

omaha::MetaInstaller mi(hInstance, lpCmdLine);
int result = mi.ExtractAndRun();
return result;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.