crash on wine, we support linux, ucb_unix, svr4

natively ffs. i tested this patch on wine 4.4 on fuckin
Solaris 11 snv_151
This commit is contained in:
Rick V 2019-11-15 13:40:43 -06:00
parent f8c6c1379a
commit cf3469e11a
No known key found for this signature in database
GPG Key ID: C0EDC8723FDC3465
5 changed files with 70 additions and 0 deletions

View File

@ -1,6 +1,7 @@
#include <config/config.hpp> // for ensure_config
#include <constants/version.hpp>
#include <llarp.h>
#include <util/lokinet_init.h>
#include <util/fs.hpp>
#include <util/logging/logger.hpp>
#include <util/logging/ostream_logger.hpp>
@ -83,6 +84,11 @@ run_main_context(std::string conffname, llarp_main_runtime_opts opts)
int
main(int argc, char *argv[])
{
auto result = Lokinet_INIT();
if(result)
{
return result;
}
llarp_main_runtime_opts opts;
const char *singleThreadVar = getenv("LLARP_SHADOW");
if(singleThreadVar && std::string(singleThreadVar) == "1")

View File

@ -25,6 +25,7 @@ set(LIB_UTIL_SRC
util/logging/ostream_logger.cpp
util/logging/syslog_logger.cpp
util/logging/win32_logger.cpp
util/lokinet_init.c
util/mem.cpp
util/meta/memfn_traits.cpp
util/meta/memfn.cpp

View File

@ -11,6 +11,7 @@
#include <util/mem.hpp>
#include <util/meta/memfn.hpp>
#include <util/str.hpp>
#include <util/lokinet_init.h>
#include <absl/strings/strip.h>
@ -468,6 +469,8 @@ namespace llarp
bool
Config::parse(const ConfigParser &parser)
{
if(Lokinet_INIT())
return false;
router = find_section< RouterConfig >(parser, "router");
network = find_section< NetworkConfig >(parser, "network");
connect = find_section< ConnectConfig >(parser, "connect");
@ -509,6 +512,8 @@ extern "C" bool
llarp_ensure_config(const char *fname, const char *basedir, bool overwrite,
bool asRouter)
{
if(Lokinet_INIT())
return false;
std::error_code ec;
if(fs::exists(fname, ec) && !overwrite)
{

34
llarp/util/lokinet_init.c Normal file
View File

@ -0,0 +1,34 @@
#include <util/lokinet_init.h>
#if defined(_WIN32)
#include <windows.h>
#include <winuser.h>
#include <stdio.h>
int
Lokinet_INIT(void)
{
static const char *(CDECL * pwine_get_version)(void);
HMODULE hntdll = GetModuleHandle("ntdll.dll");
if(hntdll)
{
pwine_get_version = (void *)GetProcAddress(hntdll, "wine_get_version");
if(pwine_get_version)
{
static const char *text =
"dont run lokinet in wine like wtf man we support linux and pretty "
"much every flavor of BSD.\nThis Program Will now crash lmao.";
static const char *title = "srsly fam wtf";
MessageBoxA(NULL, text, title, MB_ICONEXCLAMATION | MB_OK);
abort();
}
}
return 0;
}
#else
int
Lokinet_INIT(void)
{
return 0;
}
#endif

24
llarp/util/lokinet_init.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef LLARP_UTIL_LOKINET_INIT_H
#define LLARP_UTIL_LOKINET_INIT_H
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef Lokinet_INIT
#if defined(_WIN32)
#define Lokinet_INIT \
DieInCaseSomehowThisGetsRunInWineButLikeWTFThatShouldNotHappenButJustInCaseHandleItWithAPopupOrSomeShit
#else
#define Lokinet_INIT _lokinet_non_shit_platform_INIT
#endif
#endif
int
Lokinet_INIT(void);
#ifdef __cplusplus
}
#endif
#endif