Skip to content

Commit

Permalink
remove comctl32 dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed May 31, 2024
1 parent c2f36b3 commit 2bc6564
Showing 1 changed file with 5 additions and 42 deletions.
47 changes: 5 additions & 42 deletions source/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#include "dllmain.h"
#include "exception.hpp"
#include <shellapi.h>
#include <Commctrl.h>
#pragma comment(lib,"Comctl32.lib")
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#include <initguid.h>
#include <filesystem>
#include <safetyhook.hpp>
Expand Down Expand Up @@ -33,18 +29,6 @@ std::vector<std::pair<std::filesystem::path, LARGE_INTEGER>> updateFilenames;
thread_local std::string sCurrentFindFileDirA;
thread_local std::wstring sCurrentFindFileDirW;

HRESULT CALLBACK TaskDialogCallbackProc(HWND hwnd, UINT uNotification, WPARAM wParam, LPARAM lParam, LONG_PTR dwRefData)
{
switch (uNotification)
{
case TDN_HYPERLINK_CLICKED:
ShellExecuteW(hwnd, L"open", (LPCWSTR)lParam, NULL, NULL, SW_SHOW);
break;
}

return S_OK;
}

bool iequals(std::wstring_view s1, std::wstring_view s2)
{
std::wstring str1(std::move(s1));
Expand Down Expand Up @@ -676,40 +660,19 @@ void FindFiles(WIN32_FIND_DATAW* fd)
auto e = GetLastError();
if (e != ERROR_DLL_INIT_FAILED && e != ERROR_BAD_EXE_FORMAT) // in case dllmain returns false or IMAGE_MACHINE is not compatible
{
TASKDIALOGCONFIG tdc = { sizeof(TASKDIALOGCONFIG) };
int nClickedBtn;
BOOL bCheckboxChecked;
LPCWSTR szTitle = L"ASI Loader", szHeader = L"", szContent = L"";
TASKDIALOG_BUTTON aCustomButtons[] = { { 1000, L"Continue" } };

std::wstring msg = L"Unable to load " + std::wstring(fd->cFileName) + L". Error: " + std::to_wstring(e);
szHeader = msg.c_str();

std::wstring msg = L"Unable to load " + std::wstring(fd->cFileName) + L". Error: " + std::to_wstring(e) + L".";
if (e == ERROR_MOD_NOT_FOUND)
{
szContent = L"This ASI file requires a dependency that is missing from your system. To identify the missing dependency, download and run the free, open-source app, " \
L"<a href=\"https://github.com/lucasg/Dependencies/releases/latest\">Dependencies</a>.\n\n" \
L"<a href=\"https://github.com/lucasg/Dependencies\">https://github.com/lucasg/Dependencies</a>";
msg += L" This ASI file requires a dependency that is missing from your system. " \
"To identify the missing dependency, download and run the free, open-source app, " \
"Dependencies at https://github.com/lucasg/Dependencies";
}

tdc.hwndParent = NULL;
tdc.dwFlags = TDF_USE_COMMAND_LINKS | TDF_ENABLE_HYPERLINKS | TDF_SIZE_TO_CONTENT | TDF_CAN_BE_MINIMIZED;
tdc.pButtons = aCustomButtons;
tdc.cButtons = _countof(aCustomButtons);
tdc.pszWindowTitle = szTitle;
tdc.pszMainIcon = TD_ERROR_ICON;
tdc.pszMainInstruction = szHeader;
tdc.pszContent = szContent;
tdc.pfCallback = TaskDialogCallbackProc;
tdc.lpCallbackData = 0;

std::ignore = TaskDialogIndirect(&tdc, &nClickedBtn, NULL, &bCheckboxChecked);
MessageBoxW(0, msg.c_str(), L"ASI Loader", MB_ICONERROR);
}
}
else
{
auto procedure = (void(*)())GetProcAddress(h, "InitializeASI");

if (procedure != NULL)
{
procedure();
Expand Down

0 comments on commit 2bc6564

Please sign in to comment.