Commit b2b4dfcc authored by Pecio's avatar Pecio Committed by Richard Levitte
Browse files

Enabled OneCore Conf for Console Apps (removed nonUniversal API)

parent fc1d73bb
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -4,7 +4,11 @@
# Mobile[?] Windows editions. It's a set up "umbrella" libraries that
# export subset of Win32 API that are common to all Windows 10 devices.
#
# TODO: drop onecore_downlevel.lib.
# OneCore Configuration temporarly dedicated for console applications 
# due to disabled event logging, which is incompatible with one core.
# Error messages are provided via standard error only.
# TODO: extend error handling to use ETW based eventing
# (Or rework whole error messaging)

my %targets = (
    "VC-WIN32-ONECORE" => {
@@ -13,12 +17,14 @@ my %targets = (
        # hidden reference to kernel32.lib, but we don't actually want
        # it in "onecore" build.
        lflags          => add("/NODEFAULTLIB:kernel32.lib"),
        ex_libs         => "onecore.lib onecore_downlevel.lib",
        defines         => add("OPENSSL_SYS_WIN_CORE"),
        ex_libs         => "onecore.lib",
    },
    "VC-WIN64A-ONECORE" => {
        inherit_from    => [ "VC-WIN64A" ],
        lflags          => add("/NODEFAULTLIB:kernel32.lib"),
        ex_libs         => "onecore.lib onecore_downlevel.lib",
        defines         => add("OPENSSL_SYS_WIN_CORE"),
        ex_libs         => "onecore.lib",
    },

    # Windows on ARM targets. ARM compilers are additional components in
@@ -39,18 +45,20 @@ my %targets = (

    "VC-WIN32-ARM" => {
        inherit_from    => [ "VC-noCE-common" ],
        defines         => add("_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE"),
        defines         => add("_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE",
                               "OPENSSL_SYS_WIN_CORE"),
        bn_ops          => "BN_LLONG RC4_CHAR EXPORT_VAR_AS_FN",
        lflags          => add("/NODEFAULTLIB:kernel32.lib"),
        ex_libs         => "onecore.lib onecore_downlevel.lib",
        ex_libs         => "onecore.lib",
        multilib        => "-arm",
    },
    "VC-WIN64-ARM" => {
        inherit_from    => [ "VC-noCE-common" ],
        defines         => add("_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE"),
        defines         => add("_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE",
                               "OPENSSL_SYS_WIN_CORE"),
        bn_ops          => "SIXTY_FOUR_BIT RC4_CHAR EXPORT_VAR_AS_FN",
        lflags          => add("/NODEFAULTLIB:kernel32.lib"),
        ex_libs         => "onecore.lib onecore_downlevel.lib",
        ex_libs         => "onecore.lib",
        multilib        => "-arm64",
    },
);
+38 −7
Original line number Diff line number Diff line
@@ -120,6 +120,14 @@ void OPENSSL_cpuid_setup(void)
# endif

# if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
#  ifdef OPENSSL_SYS_WIN_CORE

int OPENSSL_isservice(void)
{
    /* OneCore API cannot interact with GUI */
    return 1;
}
#  else
int OPENSSL_isservice(void)
{
    HWINSTA h;
@@ -176,6 +184,7 @@ int OPENSSL_isservice(void)
    else
        return 0;
}
#  endif
# else
int OPENSSL_isservice(void)
{
@@ -272,6 +281,24 @@ void OPENSSL_showfatal(const char *fmta, ...)
    va_end(ap);

# if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
#  ifdef OPENSSL_SYS_WIN_CORE
    /* ONECORE is always NONGUI and NT >= 0x0601 */

    /*
    * TODO: (For non GUI and no std error cases)
    * Add event logging feature here. 
    */
    
#   if !defined(NDEBUG)
        /*
        * We are in a situation where we tried to report a critical
        * error and this failed for some reason. As a last resort,
        * in debug builds, send output to the debugger or any other
        * tool like DebugView which can monitor the output.
        */
        OutputDebugString(buf);
#   endif
#  else
    /* this -------------v--- guards NT-specific calls */
    if (check_winnt() && OPENSSL_isservice() > 0) {
        HANDLE hEventLog = RegisterEventSource(NULL, _T("OpenSSL"));
@@ -281,7 +308,7 @@ void OPENSSL_showfatal(const char *fmta, ...)

            if (!ReportEvent(hEventLog, EVENTLOG_ERROR_TYPE, 0, 0, NULL,
                             1, 0, &pmsg, NULL)) {
#if defined(DEBUG)
#   if !defined(NDEBUG)
                /*
                 * We are in a situation where we tried to report a critical
                 * error and this failed for some reason. As a last resort,
@@ -294,9 +321,13 @@ void OPENSSL_showfatal(const char *fmta, ...)

            (void)DeregisterEventSource(hEventLog);
        }
    } else
    } else {
        MessageBox(NULL, buf, _T("OpenSSL: FATAL"), MB_OK | MB_ICONERROR);
    }
#  endif
# else
    MessageBox(NULL, buf, _T("OpenSSL: FATAL"), MB_OK | MB_ICONERROR);
# endif     
}
#else
void OPENSSL_showfatal(const char *fmta, ...)