Skip to content

Commit 5f502be

Browse files
committed
base project
0 parents  commit 5f502be

5 files changed

Lines changed: 145 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
builds/

CMakeLists.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
cmake_minimum_required (VERSION 3.14)
2+
project(BORASUBPROCESS CXX)
3+
set(CMAKE_CXX_STANDARD 20)
4+
5+
file(GLOB_RECURSE SOURCES src/*.cpp src/*.h src/*.hpp)
6+
file(GLOB_RECURSE CONTRIB_TOOLS ../../global/cpp/contribs/tools/*)
7+
8+
if(MSVC)
9+
add_compile_definitions(UNICODE _UNICODE)
10+
add_compile_options(/utf-8)
11+
else()
12+
add_compile_options(-finput-charset=UTF-8 -fexec-charset=UTF-8)
13+
endif()
14+
15+
if(WIN32)
16+
add_executable(BORASUBPROCESS WIN32 ${SOURCES}
17+
../../global/cpp/contribs/tools/DynamicLibrary.cpp
18+
src/win32Resource.rc
19+
)
20+
endif ()
21+
22+
target_include_directories(BORASUBPROCESS PUBLIC
23+
../../global/cpp/contribs
24+
)
25+
26+
target_compile_definitions(BORASUBPROCESS PRIVATE
27+
NOMINMAX
28+
)
29+
30+
target_compile_options(BORASUBPROCESS PRIVATE
31+
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-include${CMAKE_CURRENT_SOURCE_DIR}/../../global/cpp/contribs/TypeDefinitions.h>
32+
$<$<CXX_COMPILER_ID:GNU>:-include${CMAKE_CURRENT_SOURCE_DIR}/../../global/cpp/contribs/TypeDefinitions.h>
33+
$<$<CXX_COMPILER_ID:MSVC>:/FI${CMAKE_CURRENT_SOURCE_DIR}/../../global/cpp/contribs/TypeDefinitions.h>
34+
)
35+

assets/borat.ico

89.8 KB
Binary file not shown.

src/main.cpp

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Apart of the BORA Source which uses the TAOSU License
2+
// Check LICENSE.md for more information regarding the BORA license.
3+
#include <windows.h>
4+
#include <iostream>
5+
#include <shobjidl.h>
6+
#include "tools/Env.h"
7+
#include "tools/DynamicLibrary.h"
8+
#include <filesystem>
9+
#include <shellapi.h>
10+
#include <commctrl.h>
11+
12+
#if defined _WIN64
13+
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
14+
#else
15+
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
16+
#endif
17+
18+
#pragma comment (lib, "Shlwapi.lib")
19+
#pragma comment (lib, "Comctl32.lib")
20+
21+
22+
using MainFuncSymbol = int(*)(int, char * b[]);
23+
24+
int WINAPI WinMain(
25+
HINSTANCE hInstance, // handle to the current instance of the application
26+
HINSTANCE hPrevInstance, // always NULL in Win32 apps
27+
LPSTR lpCmdLine, // command line as ANSI string
28+
int nCmdShow // how the window is to be shown
29+
){
30+
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
31+
32+
auto bPath = std::filesystem::path(Environment::getEnvVar("BORA_RT_PATH") + "/compatibility/latest.dll");
33+
DynamicLibrary latest(bPath.c_str());
34+
if (latest.hasOpened()) {
35+
// todo: implement winmain commands as arguments for DLL
36+
auto main = MainFuncSymbol(latest.getProcAddress("main"));
37+
main(__argc, __argv);
38+
latest.close();
39+
} else {
40+
// Task Dialog configuration
41+
TASKDIALOGCONFIG config = { 0 };
42+
config.cbSize = sizeof(config);
43+
config.hwndParent = nullptr;
44+
config.dwFlags = TDF_USE_COMMAND_LINKS | TDF_POSITION_RELATIVE_TO_WINDOW;
45+
config.dwCommonButtons = TDCBF_CLOSE_BUTTON;
46+
config.pszWindowTitle = L"BORA needs to be reinstalled";
47+
config.pszMainIcon = TD_ERROR_ICON;
48+
config.pszMainInstruction = L"Critical files that BORA requires to run are missing.";
49+
config.pszContent = L"To fix this problem, please visit the downloads website and reinstall BORA.";
50+
51+
// Buttons
52+
TASKDIALOG_BUTTON buttons[] =
53+
{
54+
{ 100, L"Open Download Page" },
55+
};
56+
config.cButtons = ARRAYSIZE(buttons);
57+
config.pButtons = buttons;
58+
config.nDefaultButton = 100;
59+
60+
int pressedButton = 0;
61+
TaskDialogIndirect(&config, &pressedButton, nullptr, nullptr);
62+
63+
// Handle result
64+
if (pressedButton == 100)
65+
{
66+
SHELLEXECUTEINFOW sei = { sizeof(sei) };
67+
sei.fMask = SEE_MASK_FLAG_DDEWAIT;
68+
sei.lpVerb = L"open";
69+
sei.lpFile = L"https://bor.ad/downloads";
70+
sei.nShow = SW_SHOWNORMAL;
71+
72+
if (!ShellExecuteExW(&sei))
73+
{
74+
// Fallback if needed
75+
ShellExecuteW(nullptr, L"open", L"https://bor.ad/downloads", nullptr, nullptr, SW_SHOWNORMAL);
76+
}
77+
78+
// Try to bring the browser window forward
79+
AllowSetForegroundWindow(ASFW_ANY);
80+
}
81+
}
82+
83+
}

src/win32Resource.rc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <windows.h>
2+
3+
VS_VERSION_INFO VERSIONINFO
4+
FILEVERSION 0,0,1
5+
PRODUCTVERSION 1,0,0,0
6+
FILEFLAGSMASK 0x3fL
7+
FILEFLAGS 0x0L
8+
FILEOS 0x40004L
9+
FILETYPE 0x1L
10+
{
11+
BLOCK "StringFileInfo"
12+
{
13+
BLOCK "040904b0" // language + codepage
14+
{
15+
VALUE "FileDescription", "Bora Plain SubProcessor"
16+
VALUE "ProductName", "Your future BORA Name"
17+
VALUE "CompanyName", "Your developer name"
18+
VALUE "ProductVersion", "Application version or 1.0.0.0"
19+
}
20+
}
21+
BLOCK "VarFileInfo"
22+
{
23+
VALUE "Translation", 0x0409, 1200
24+
}
25+
}

0 commit comments

Comments
 (0)