adding support for self check and db updat ewith zip files

This commit is contained in:
jakani24
2024-03-29 10:11:39 +01:00
parent 3b450984b8
commit aa0bc23f50
53 changed files with 786 additions and 146 deletions

View File

@@ -6,6 +6,10 @@
"AbsoluteMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\ma_installer.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|solutionrelative:ma_installer.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\download.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|solutionrelative:download.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\well_known.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|solutionrelative:well_known.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
@@ -13,10 +17,6 @@
{
"AbsoluteMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\download.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|solutionrelative:download.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\download.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{AAE7A550-D2C0-45AC-8C26-ED57DF20BFC3}|ma_installer.vcxproj|solutionrelative:download.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
}
],
"DocumentGroupContainers": [
@@ -30,7 +30,7 @@
"Children": [
{
"$type": "Document",
"DocumentIndex": 1,
"DocumentIndex": 2,
"Title": "well_known.h",
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\well_known.h",
"RelativeDocumentMoniker": "well_known.h",
@@ -42,7 +42,7 @@
},
{
"$type": "Document",
"DocumentIndex": 2,
"DocumentIndex": 3,
"Title": "download.cpp",
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\download.cpp",
"RelativeDocumentMoniker": "download.cpp",
@@ -54,7 +54,7 @@
},
{
"$type": "Document",
"DocumentIndex": 3,
"DocumentIndex": 1,
"Title": "download.h",
"DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\download.h",
"RelativeDocumentMoniker": "download.h",
@@ -72,7 +72,7 @@
"RelativeDocumentMoniker": "ma_installer.cpp",
"ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_installer\\ma_installer.cpp",
"RelativeToolTip": "ma_installer.cpp",
"ViewState": "AQIAAPoAAAAAAAAAAAAAACcDAAAnAAAA",
"ViewState": "AQIAAGgDAAAAAAAAAAAAAIQDAAAIAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
"WhenOpened": "2023-12-22T18:52:51.74Z",
"EditorCaption": ""

View File

@@ -8,7 +8,15 @@
#include <stdio.h>
#include "download.h"
#include "well_known.h"
#pragma comment(lib, "advapi32.lib")
#include <iostream>
#include <windows.h>
#include <objbase.h> // For CoInitialize and CoUninitialize
#include <objidl.h> // For IPersistFile
#include <propvarutil.h> // For InitPropVariantFromString
#include <shobjidl.h> // For IShellLink
#include <shlobj.h>
#include <propkey.h> // For PKEY_AppUserModel_ID
/*
Tasks to do:
- launch as admin
@@ -646,7 +654,99 @@ int copy(const char* source_path, const char* destination_path) {
return 0;
}
HRESULT create_shortcut(const wchar_t* targetPath, const wchar_t* shortcutPath, const wchar_t* iconPath) {
// Initialize the COM library
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr)) {
return hr;
}
// Create an instance of the ShellLink interface
IShellLink* pShellLink = NULL;
hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&pShellLink);
if (FAILED(hr)) {
CoUninitialize();
return hr;
}
// Set the path of the target file
pShellLink->SetPath(targetPath);
// Query the IPropertyStore interface
IPropertyStore* pPropertyStore = NULL;
hr = pShellLink->QueryInterface(IID_IPropertyStore, (void**)&pPropertyStore);
if (FAILED(hr)) {
pShellLink->Release();
CoUninitialize();
return hr;
}
// Load the icon file and set the System.Icon property
PROPVARIANT propvar;
hr = InitPropVariantFromString(iconPath, &propvar);
if (SUCCEEDED(hr)) {
hr = pPropertyStore->SetValue(PKEY_AppUserModel_ID, propvar);
if (SUCCEEDED(hr)) {
hr = pPropertyStore->Commit();
if (FAILED(hr)) {
CoUninitialize();
pPropertyStore->Release();
pShellLink->Release();
return hr;
}
}
else {
CoUninitialize();
pPropertyStore->Release();
pShellLink->Release();
return hr;
}
PropVariantClear(&propvar); // Free memory allocated by InitPropVariantFromString
}
else {
CoUninitialize();
pPropertyStore->Release();
pShellLink->Release();
return hr;
}
// Release the IPropertyStore interface
pPropertyStore->Release();
// Query the IPersistFile interface
IPersistFile* pPersistFile = NULL;
hr = pShellLink->QueryInterface(IID_IPersistFile, (void**)&pPersistFile);
if (FAILED(hr)) {
pShellLink->Release();
CoUninitialize();
return hr;
}
// Save the shortcut to disk
hr = pPersistFile->Save(shortcutPath, TRUE);
if (FAILED(hr)) {
pPersistFile->Release();
pShellLink->Release();
CoUninitialize();
return hr;
}
// Release COM interfaces
pPersistFile->Release();
pShellLink->Release();
// Uninitialize the COM library
CoUninitialize();
return S_OK; // Success
}
int main()
{
printf("Welcome to the Cyberhex installer!\n");
@@ -797,6 +897,17 @@ int main()
std::cerr << "Task creation failed!" << std::endl;
error=5;
}
//create the shortcut
if (error == 0) {
printf("Creating shortcut\n");
HRESULT hr = create_shortcut(L"C:\\Program Files\\cyberhex\\app\\cyberhex_desktop.exe", L"C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\cyberhex.lnk", L"C:\\Program Files\\cyberhex\\app\\icon.ico");
if (FAILED(hr))
{
std::cerr << "Shortcut creation failed!" << std::endl;
error = 6;
}
}
}
switch (error) {

View File

@@ -1,3 +1,4 @@
 ma_installer.cpp
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\ma_installer.cpp(704,15): warning C4101: "fp": Unreferenzierte lokale Variable
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\ma_installer.cpp(804,15): warning C4101: "fp": Unreferenzierte lokale Variable
ma_installer.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\x64\Debug\ma_installer.exe
C:\vcpkg\vcpkg-2023.08.09\scripts\buildsystems\msbuild\vcpkg.targets(228,5): warning : [vcpkg] Failed to gather app local DLL dependencies, program may not run. Set VcpkgApplocalDeps to false in your project file to suppress this warning. PowerShell arguments: -ExecutionPolicy Bypass -noprofile -File "C:\vcpkg\vcpkg-2023.08.09\scripts\buildsystems\msbuild\applocal.ps1" "C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\x64\Debug\ma_installer.exe" "C:\vcpkg\vcpkg-2023.08.09\installed\x64-windows\debug\bin" "ma_installer\x64\Debug\ma_installer.tlog\ma_installer.write.1u.tlog" "ma_installer\x64\Debug\vcpkg.applocal.log"

View File

@@ -1,3 +0,0 @@
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\x64\Debug\libcurl-d.dll
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\x64\Debug\zlibd1.dll
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_installer\ma_installer\x64\Debug\ma_insta.BC7E6B48.Up2Date