mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
sys: Embed resources into rodata
This commit is contained in:
@@ -56,6 +56,8 @@ set(LIBIMHEX_SOURCES
|
||||
source/providers/provider.cpp
|
||||
|
||||
source/views/view.cpp
|
||||
|
||||
source/resources.cpp
|
||||
)
|
||||
|
||||
if (APPLE)
|
||||
|
||||
16
plugins/libimhex/include/hex/resources.hpp
Normal file
16
plugins/libimhex/include/hex/resources.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#define RESOURCE_EXPORT(name) \
|
||||
extern "C" unsigned char name[]; \
|
||||
extern "C" int name##_size;
|
||||
|
||||
|
||||
|
||||
RESOURCE_EXPORT(splash);
|
||||
RESOURCE_EXPORT(banner_light);
|
||||
RESOURCE_EXPORT(banner_dark);
|
||||
RESOURCE_EXPORT(cacert);
|
||||
|
||||
|
||||
|
||||
#undef RESOURCE_EXPORT
|
||||
@@ -4,6 +4,11 @@
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include <mbedtls/x509.h>
|
||||
#include <mbedtls/x509_crt.h>
|
||||
|
||||
#include <hex/resources.hpp>
|
||||
|
||||
namespace hex {
|
||||
|
||||
Net::Net() {
|
||||
@@ -45,10 +50,16 @@ namespace hex {
|
||||
curl_easy_setopt(ctx, CURLOPT_WRITEFUNCTION, writeToString);
|
||||
curl_easy_setopt(ctx, CURLOPT_SSL_VERIFYPEER, 1L);
|
||||
curl_easy_setopt(ctx, CURLOPT_SSL_VERIFYHOST, 1L);
|
||||
for (const auto &resourceDir : hex::getPath(hex::ImHexPath::Resources)) {
|
||||
if (std::filesystem::exists(resourceDir + "/cacert.pem"))
|
||||
curl_easy_setopt(ctx, CURLOPT_CAPATH, resourceDir.c_str());
|
||||
}
|
||||
curl_easy_setopt(ctx, CURLOPT_CAINFO, nullptr);
|
||||
curl_easy_setopt(ctx, CURLOPT_CAPATH, nullptr);
|
||||
curl_easy_setopt(ctx, CURLOPT_SSL_CTX_DATA, [](CURL *ctx, void *sslctx, void *userdata) -> CURLcode {
|
||||
auto* mbedtlsCert = static_cast<mbedtls_x509_crt*>(sslctx);
|
||||
mbedtls_x509_crt_init(mbedtlsCert);
|
||||
|
||||
mbedtls_x509_crt_parse(mbedtlsCert, cacert, cacert_size);
|
||||
|
||||
return CURLE_OK;
|
||||
});
|
||||
curl_easy_setopt(ctx, CURLOPT_WRITEDATA, &response);
|
||||
curl_easy_setopt(ctx, CURLOPT_TIMEOUT_MS, 2000L);
|
||||
curl_easy_setopt(ctx, CURLOPT_CONNECTTIMEOUT_MS, 2000L);
|
||||
|
||||
18
plugins/libimhex/source/resources.cpp
Normal file
18
plugins/libimhex/source/resources.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#define RESOURCE(name, path) __asm__ ( \
|
||||
".section .rodata\n" \
|
||||
".global " #name "\n" \
|
||||
".global " #name "_size\n" \
|
||||
#name ":\n" \
|
||||
".incbin \"" path "\"\n" \
|
||||
".type " #name ", @object\n" \
|
||||
".size " #name "_size, 1\n" \
|
||||
#name "_size:\n" \
|
||||
".int " #name "_size - " #name "\n" \
|
||||
".align 8\n" \
|
||||
)
|
||||
|
||||
RESOURCE(banner_light, "../../../res/resources/banner_light.png");
|
||||
RESOURCE(banner_dark, "../../../res/resources/banner_dark.png");
|
||||
RESOURCE(splash, "../../../res/resources/splash.png");
|
||||
|
||||
RESOURCE(cacert, "../../../res/resources/cacert.pem");
|
||||
Reference in New Issue
Block a user