Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS (WIN) Common - Global.c
    »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
    »Version«   4.51 / »GUID« A9981407-3EC9-42AF-8B6F-8BE6DD919615                                                                                                        */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/*  Copyright: © 2002-2017, Andrew Aye.  All Rights Reserved.
    This software is free for non-commercial use.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
    following conditions are met:
    Redistribution of source code must retain this copyright notice, this list of conditions and the following disclaimers.
    Redistribution in binary form must reproduce this copyright notice, this list of conditions and the following disclaimers in the documentation and other materials
    provided with the distribution.
    The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
    The intellectual property rights of the algorithms used reside with Andrew Aye.
    You may not use this software, in whole or in part, in support of any commercial product without the express written consent of the author.
    There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/* == Common ============================================================================================================================================================ */

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Data                                                                                                                                                           */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

TgMS_HINSTANCE                              g_hInstance = nullptr;
TgMS_HWND                                   g_hWnd = nullptr;

/* API Set: api-ms-win-core-synch-l1-2-0 */
P_TgVOID                                    (__stdcall *g_pfnCreateEventEx)( TgMS_LPSECURITY_ATTRIBUTES, CP_TgCHAR, DWORD, DWORD ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnSetEvent)( P_TgVOID ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnResetEvent)( P_TgVOID ) = nullptr;
P_TgVOID                                    (__stdcall *g_pfnCreateSemaphoreEx)( TgMS_LPSECURITY_ATTRIBUTES, LONG, LONG, CP_TgCHAR, DWORD, DWORD )=nullptr;
TgSINT32                                    (__stdcall *g_pfnReleaseSemaphore)( P_TgVOID, LONG, LPLONG ) = nullptr;
P_TgVOID                                    (__stdcall *g_pfnCreateMutexEx)( TgMS_LPSECURITY_ATTRIBUTES, CP_TgCHAR, DWORD, DWORD ) = nullptr;
TgSINT32                                    (__stdcall *g_pfnReleaseMutex)( P_TgVOID ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnInitializeCriticalSectionEx)( TgMS_LPCRITICAL_SECTION, DWORD, DWORD ) = nullptr;
TgVOID                                      (__stdcall *g_pfnEnterCriticalSection)( TgMS_LPCRITICAL_SECTION ) = nullptr;
TgVOID                                      (__stdcall *g_pfnLeaveCriticalSection)( TgMS_LPCRITICAL_SECTION ) = nullptr;
TgSINT32                                    (__stdcall *g_pfnTryEnterCriticalSection)( TgMS_LPCRITICAL_SECTION ) = nullptr;
TgVOID                                      (__stdcall *g_pfnDeleteCriticalSection)( TgMS_LPCRITICAL_SECTION ) = nullptr;
DWORD                                       (__stdcall *g_pfnWaitForSingleObjectEx)( P_TgVOID, DWORD, C_TgBOOL ) = nullptr;
TgVOID                                      (__stdcall *g_pfnSleep)( DWORD ) = nullptr;

/* API Set: api-ms-win-core-processthreads-l1-1-2 */
P_TgVOID                                    (__stdcall *g_pfnGetCurrentProcess)( TgVOID ) = nullptr;
DWORD                                       (__stdcall *g_pfnGetCurrentProcessId)( TgVOID ) = nullptr;
P_TgVOID                                    (__stdcall *g_pfnCreateThread)( TgMS_LPSECURITY_ATTRIBUTES, TgSIZE, LPTHREAD_START_ROUTINE, P_TgVOID, DWORD, P_TgUINT32 ) = nullptr;
P_TgVOID                                    (__stdcall *g_pfnGetCurrentThread)( TgVOID ) = nullptr;
DWORD                                       (__stdcall *g_pfnGetCurrentThreadId)( TgVOID ) = nullptr;
DWORD                                       (__stdcall *g_pfnGetThreadId)( P_TgVOID ) = nullptr;
TgVOID                                      (__stdcall *g_pfnExitThread)( DWORD ) = nullptr;
BOOL                                        (__stdcall *g_pfnTerminateThread)( P_TgVOID, DWORD ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnSetThreadPriority)( P_TgVOID, TgSINT32 ) = nullptr;
TgSINT32                                    (__stdcall *g_pfnSwitchToThread)( TgVOID ) = nullptr;
TgSINT32                                    (__stdcall *g_pfnIsProcessorFeaturePresent)( DWORD ) = nullptr;

/* API Set: api-ms-win-core-handle-l1-1-0 */
TgSINT32                                    (__stdcall *g_pfnCloseHandle)( P_TgVOID ) = nullptr;
TgSINT32                                    (__stdcall *g_pfnDuplicateHandle )(P_TgVOID, P_TgVOID, P_TgVOID, PP_TgVOID, DWORD, BOOL, DWORD) = nullptr;

/* API Set: api-ms-win-core-errorhandling-l1-1-1 */
TgVOID                                      (__stdcall *g_pfnRaiseException)( DWORD, DWORD, DWORD, CP_TgUINT64 ) = nullptr;
DWORD                                       (__stdcall *g_pfnGetLastError)( TgVOID ) = nullptr;

/* API Set: api-ms-win-core-debug-l1-1-1 */
TgVOID                                      (__stdcall *g_pfnOutputDebugString)( CP_TgCHAR ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnIsDebuggerPresent)( TgVOID ) = nullptr;

/* API Set: api-ms-win-core-com-l1-1-1 */
HRESULT                                     (__stdcall *g_pfnCoInitializeEx)( P_TgVOID, DWORD ) = nullptr;
TgVOID                                      (__stdcall *g_pfnCoUninitialize)( TgVOID ) = nullptr;

/* API Set: api-ms-win-core-sysinfo-l1-2-1 */
TgVOID                                      (__stdcall *g_pfnGetSystemInfo)( TgMS_LPSYSTEM_INFO ) = nullptr;
TgUINT64                                    (__stdcall *g_pfnGetTickCount64)( TgVOID ) = nullptr;
#if !defined(TgCOMPILE_PLATFORM_UWP)
TgBOOL                                      (__stdcall *g_pfnGetComputerNameEx)( TgSINT32, P_TgCHAR, P_TgUINT32 ) = nullptr;
TgUINT32                                    (__stdcall *g_pfnGetSystemDirectory)( P_TgCHAR, TgUINT32 ) = nullptr;
TgUINT32                                    (__stdcall *g_pfnGetWindowsDirectory)( P_TgCHAR, TgUINT32 ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnGlobalMemoryStatusEx)( P_TgVOID ) = nullptr;
/*# !defined(TgCOMPILE_PLATFORM_UWP) */
#endif

/* API Set: api-ms-win-core-processenvironment-l1-2-0 */
DWORD                                       (__stdcall *g_pfnGetCurrentDirectory)( DWORD, P_TgCHAR ) = nullptr;
P_TgCHAR                                    (__stdcall *g_pfnGetCommandLine)( TgVOID ) = nullptr;

/* API Set: api-ms-win-core-profile-l1-1-0 */
TgBOOL                                      (__stdcall *g_pfnQueryPerformanceFrequency)( PLARGE_INTEGER ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnQueryPerformanceCounter)( PLARGE_INTEGER ) = nullptr;

/* API Set: api-ms-win-core-file-l1-2-1 */
TgBOOL                                      (__stdcall *g_pfnGetFileAttributesEx)( CP_TgCHAR, TgSINT32, P_TgVOID ) = nullptr;
P_TgVOID                                    (__stdcall *g_pfnCreateFile2)( CP_TgWIDECHAR, DWORD, DWORD, DWORD, TgMS_LPCREATEFILE2_EXTENDED_PARAMETERS ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnSetFilePointerEx)( P_TgVOID, LARGE_INTEGER, PLARGE_INTEGER, DWORD ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnReadFile)( P_TgVOID, P_TgVOID, DWORD, LPDWORD, TgMS_LPOVERLAPPED ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnWriteFile)( P_TgVOID, CP_TgVOID, DWORD, LPDWORD, TgMS_LPOVERLAPPED ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnFlushFileBuffers)( P_TgVOID ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnCreateDirectory)( CP_TgCHAR, TgMS_LPSECURITY_ATTRIBUTES ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnRemoveDirectory)( CP_TgCHAR ) = nullptr;
DWORD                                       (__stdcall *g_pfnGetTempPath)( DWORD, P_TgCHAR ) = nullptr;
P_TgVOID                                    (__stdcall *g_pfnFindFirstFile)( CP_TgCHAR, P_TgVOID ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnFindNextFile)( P_TgVOID, P_TgVOID ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnFindClose)( P_TgVOID ) = nullptr;
#if !defined(TgCOMPILE_PLATFORM_UWP)
P_TgVOID                                    (__stdcall *g_pfnCreateFile)( CP_TgCHAR, DWORD, DWORD, P_TgVOID, DWORD, DWORD, P_TgVOID ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnDeleteFile)( CP_TgCHAR ) = nullptr;
/*# !defined(TgCOMPILE_PLATFORM_UWP) */
#endif

/* API Set: api-ms-win-core-file-l2-1-1 */
LONG                                        (__stdcall *g_pfnCopyFile2)( CP_TgWIDECHAR, CP_TgWIDECHAR, TgMS_LPCOPYFILE2_EXTENDED_PARAMETERS ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnGetFileInformationByHandleEx )( P_TgVOID, TgSINT32, P_TgVOID, DWORD ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnMoveFileEx)( CP_TgCHAR, CP_TgCHAR, DWORD ) = nullptr;

/* API Set: api-ms-win-core-libraryloader-l1-2-0 */
DWORD                                       (__stdcall *g_pfnGetModuleFileName)( TgMS_HMODULE, P_TgCHAR, DWORD ) = nullptr;

/* API Set: api-ms-win-core-localization-l1-2-1 */
DWORD                                       (__stdcall *g_pfnFormatMessage)( DWORD, CP_TgVOID, DWORD, DWORD, P_TgCHAR, DWORD, va_list* ) = nullptr;
#if !defined(TgCOMPILE_PLATFORM_UWP)
TgSINT32                                    (__stdcall *g_pfnGetLocaleInfo)( DWORD, DWORD, P_TgCHAR, TgSINT32 ) = nullptr;
TgUINT32                                    (__stdcall *g_pfnGetACP)( TgVOID ) = nullptr;
/*# !defined(TgCOMPILE_PLATFORM_UWP) */
#endif

/* API Set: api-ms-win-core-heap-l1-2-0 */
P_TgVOID                                    (__stdcall *g_pfnGetProcessHeap)( TgVOID ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnHeapFree)( P_TgVOID, DWORD, P_TgVOID ) = nullptr;

/* API Set: api-ms-win-core-memory-l1-1-2 */
TgSINT32                                    (__stdcall *g_pfnVirtualFree)( P_TgVOID, TgUINT64, DWORD ) = nullptr;

#if defined(TgCOMPILE_PLATFORM_UWP)
/* API Set: api-ms-win-core-memory-l1-1-3 */
P_TgVOID                                    (__stdcall *g_pfnVirtualAllocFromApp)(P_TgVOID, TgUINT64, DWORD, DWORD) = nullptr;
/*# defined(TgCOMPILE_PLATFORM_UWP) */
#endif

#if !defined(TgCOMPILE_PLATFORM_UWP)
/* API Set: api-ms-win-core-realtime-l1-1-0 */
TgBOOL                                      (__stdcall *g_pfnQueryProcessCycleTime)( P_TgVOID, P_TgUINT64 ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnQueryThreadCycleTime)( P_TgVOID, P_TgUINT64 ) = nullptr;
/*# !defined(TgCOMPILE_PLATFORM_UWP) */
#endif

#if !defined(TgCOMPILE_PLATFORM_UWP)
/* kernel32 */
P_TgVOID                                    (__stdcall *g_pfnVirtualAlloc)(P_TgVOID, TgUINT64, DWORD, DWORD) = nullptr;
TgBOOL                                      (__stdcall *g_pfnCopyFile)( CP_TgCHAR, CP_TgCHAR, TgBOOL ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnVerifyVersionInfo)( P_TgVOID, DWORD, TgUINT64 ) = nullptr;
P_TgVOID                                    (__stdcall *g_pfnCreateToolhelp32Snapshot)( DWORD, DWORD ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnThread32First)( P_TgVOID, P_TgVOID ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnThread32Next)( P_TgVOID, P_TgVOID ) = nullptr;
P_TgVOID                                    (__stdcall *g_pfnLocalFree)( P_TgVOID ) = nullptr;

/* user32 */
TgSINT32                                    (__stdcall *g_pfnGetSystemMetrics)( TgSINT32 ) = nullptr;
TgSINT32                                    (__stdcall *g_pfnSystemParametersInfo)( TgUINT32, TgUINT32, P_TgVOID, TgUINT32 ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnGetMonitorInfo)( TgMS_HMONITOR, P_TgVOID ) = nullptr;
TgMS_HMONITOR                               (__stdcall *g_pfnMonitorFromRect)( CP_TgVOID, DWORD ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnEnumDisplayMonitors)( TgMS_HDC, CP_TgVOID, TgMS_MONITORENUMPROC, TgSINT64 ) = nullptr;

/* Advapi32 */
TgBOOL                                      (__stdcall *g_pfnGetUserName)( P_TgCHAR, P_TgUINT32 ) = nullptr;
TgBOOL                                      (__stdcall *g_pfnGetCurrentHwProfile)( P_TgVOID ) = nullptr;

/* Psapi */
TgBOOL                                      (__stdcall *g_pfnEnumProcessModulesEx)( P_TgVOID, TgMS_HINSTANCE*, DWORD, P_TgUINT32, DWORD ) = nullptr;
DWORD                                       (__stdcall *g_pfnGetModuleFileNameEx)( P_TgVOID, P_TgVOID, P_TgCHAR, DWORD ) = nullptr;

TgSINT32                                    (__stdcall *g_pfnNtDelayExecution)( TgBOOL, P_TgVOID ) = nullptr;
/*# !defined(TgCOMPILE_PLATFORM_UWP) */
#endif




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  File Local Data                                                                                                                                                       */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

#if !defined(TgCOMPILE_PLATFORM_UWP)
static TgMS_HINSTANCE                       s_hDLL_OLE32;
static TgMS_HINSTANCE                       s_hDLL_User32;
static TgMS_HINSTANCE                       s_hDLL_GDI32;
static TgMS_HINSTANCE                       s_hDLL_Kernel32;
static TgMS_HINSTANCE                       s_hDLL_AdvAPI32;
static TgMS_HINSTANCE                       s_hDLL_PSAPI;
static TgMS_HINSTANCE                       s_hDLL_NTDLL;

static TgMS_HINSTANCE                       s_hDLL_Core_COM;
static TgMS_HINSTANCE                       s_hDLL_Core_Sync1;
static TgMS_HINSTANCE                       s_hDLL_Core_Sync2;
static TgMS_HINSTANCE                       s_hDLL_Core_ProcessThread;
static TgMS_HINSTANCE                       s_hDLL_Core_Handle;
static TgMS_HINSTANCE                       s_hDLL_Core_SysInfo;
static TgMS_HINSTANCE                       s_hDLL_Core_ProcessEnvironment;
static TgMS_HINSTANCE                       s_hDLL_Core_Profile;
static TgMS_HINSTANCE                       s_hDLL_Core_File1;
static TgMS_HINSTANCE                       s_hDLL_Core_File2;
static TgMS_HINSTANCE                       s_hDLL_Core_Error;
static TgMS_HINSTANCE                       s_hDLL_Core_Debugger;
static TgMS_HINSTANCE                       s_hDLL_Core_LibLoad;
static TgMS_HINSTANCE                       s_hDLL_Core_Local;
static TgMS_HINSTANCE                       s_hDLL_Core_Heap;
static TgMS_HINSTANCE                       s_hDLL_Core_Mem1;
static TgMS_HINSTANCE                       s_hDLL_Core_Mem2;
static TgMS_HINSTANCE                       s_hDLL_Core_RealTime;
/*# !defined(TgCOMPILE_PLATFORM_UWP) */
#endif




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Local File Functions                                                                                                                                                  */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

#if !defined(TgCOMPILE_PLATFORM_UWP)
static TgRESULT                             GB_Init__Validate_CPU_ID( TgVOID );
static TgRESULT                             GB_Init__Delay_Loaded_DLL( TgVOID );
#else
TgVOID                                      GB_Init__Implicit_DLL( TgVOID );
/*# !defined(TgCOMPILE_PLATFORM_UWP) */
#endif




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Functions                                                                                                                                                      */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

#if TgCOMPILE_CONSOLE_DEBUG_OUTPUT

/* ---- tgPM_DBG_ERR_Write_Byte ----------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgSIZE tgPM_DBG_ERR_Write_Byte( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, C_TgUINT08 UNUSED_PARAM ptbUnused )
{
    return 0;
}


/* ---- tgPM_DBG_ERR_Write ---------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgSIZE tgPM_DBG_ERR_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID pszText, C_TgSIZE _nuiText )
{
    TgSIZE                              nuiText = _nuiText;
    TgCHAR                              szBuffer[1024];

    if (nullptr == g_pfnOutputDebugString)
        return (0);

    while (0 != nuiText)
    {
        tgSZ_CopyN( szBuffer, 1024, (CP_TgCHAR)pszText, nuiText % 1024 );
        nuiText -= nuiText % 1024;
        g_pfnOutputDebugString( szBuffer );
    };

    return (0);
}


/* ---- tgPM_DBG_OUT_Write_Byte ----------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgSIZE tgPM_DBG_OUT_Write_Byte( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, C_TgUINT08 UNUSED_PARAM ptbUnused )
{
    return 0;
}


/* ---- tgPM_DBG_OUT_Write ---------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgSIZE tgPM_DBG_OUT_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID pszText, C_TgSIZE _nuiText )
{
    TgSIZE                              nuiText = _nuiText;
    TgCHAR                              szBuffer[1024];

    if (nullptr == g_pfnOutputDebugString)
        return (0);

    while (0 != nuiText)
    {
        tgSZ_CopyN( szBuffer, 1024, (CP_TgCHAR)pszText, nuiText % 1024 );
        nuiText -= nuiText % 1024;
        g_pfnOutputDebugString( szBuffer );
    };

    return (0);
}


/*# TgCOMPILE_CONSOLE_DEBUG_OUTPUT */
#else

/* ---- tgPM_DBG_ERR_Write_Byte ----------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgSIZE tgPM_DBG_ERR_Write_Byte( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, C_TgUINT08 UNUSED_PARAM ptbUnused )
{
    return 0;
}


/* ---- tgPM_DBG_ERR_Write ---------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgSIZE tgPM_DBG_ERR_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CPC_TgVOID UNUSED_PARAM pszText, C_TgSIZE UNUSED_PARAM _niText )
{
    return 0;
}


/* ---- tgPM_DBG_OUT_Write_Byte ----------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgSIZE tgPM_DBG_OUT_Write_Byte( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, C_TgUINT08 UNUSED_PARAM ptbUnused )
{
    return 0;
}


/* ---- tgPM_DBG_OUT_Write ---------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgSIZE tgPM_DBG_OUT_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CPC_TgVOID UNUSED_PARAM pszText, C_TgSIZE UNUSED_PARAM _niText )
{
    return 0;
}


/*# TgCOMPILE_CONSOLE_DEBUG_OUTPUT */
#endif




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Internal Functions                                                                                                                                                    */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- tgGB_Init_OS ---------------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgRESULT tgGB_Init_OS( TgVOID )
{
    P_TgCHAR                            szCmdLN;

#if !defined(TgCOMPILE_PLATFORM_UWP)
    /* Validate the CPU info */
    if (TgFAILED( GB_Init__Validate_CPU_ID() ))
    {
        return (KTgE_FAIL);
    };

    /* Load DLL | Modules for function pointers */
    if (TgFAILED( GB_Init__Delay_Loaded_DLL() ))
    {
        tgGB_Free_OS();
        return (KTgE_FAIL);
    };
#else
    GB_Init__Implicit_DLL();
/*# !defined(TgCOMPILE_PLATFORM_UWP) */
#endif

    /* Get the command line from the application execution */
    if (0 != (szCmdLN = g_pfnGetCommandLine()))
    {
        tgGB_CMD_Set_Command_Line( szCmdLN );
    };


    /* Initialize the system information */
    tgSI_Init();

    tgTR_Register_Main_Thread( TgT("CM Main Thread") );

    return (KTgS_OK);
}


/* ---- tgGB_Boot_OS ---------------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgRESULT tgGB_Boot_OS( TgVOID )
{
    tgSI_Boot();
    return (KTgS_OK);
}


/* ---- tgGB_Stop_OS ---------------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID tgGB_Stop_OS( TgVOID )
{
    tgSI_Stop();
}


/* ---- tgGB_Free_OS ---------------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID tgGB_Free_OS( TgVOID )
{
    tgSI_Free();

#if !defined(TgCOMPILE_PLATFORM_UWP)
    tgGB_Free_Lib( &s_hDLL_Core_COM );
    tgGB_Free_Lib( &s_hDLL_Core_Sync1 );
    tgGB_Free_Lib( &s_hDLL_Core_Sync2 );
    tgGB_Free_Lib( &s_hDLL_Core_ProcessThread );
    tgGB_Free_Lib( &s_hDLL_Core_Handle );
    tgGB_Free_Lib( &s_hDLL_Core_SysInfo );
    tgGB_Free_Lib( &s_hDLL_Core_ProcessEnvironment );
    tgGB_Free_Lib( &s_hDLL_Core_Profile );
    tgGB_Free_Lib( &s_hDLL_Core_File1 );
    tgGB_Free_Lib( &s_hDLL_Core_File2 );
    tgGB_Free_Lib( &s_hDLL_Core_Error );
    tgGB_Free_Lib( &s_hDLL_Core_Debugger );
    tgGB_Free_Lib( &s_hDLL_Core_LibLoad );
    tgGB_Free_Lib( &s_hDLL_Core_Local );
    tgGB_Free_Lib( &s_hDLL_Core_Heap );
    tgGB_Free_Lib( &s_hDLL_Core_Mem1 );
    tgGB_Free_Lib( &s_hDLL_Core_Mem2 );
    tgGB_Free_Lib( &s_hDLL_Core_RealTime );

    tgGB_Free_Lib( &s_hDLL_PSAPI );
    tgGB_Free_Lib( &s_hDLL_AdvAPI32 );
    tgGB_Free_Lib( &s_hDLL_Kernel32 );
    tgGB_Free_Lib( &s_hDLL_GDI32 );
    tgGB_Free_Lib( &s_hDLL_User32 );
    tgGB_Free_Lib( &s_hDLL_OLE32 );
/*# !defined(TgCOMPILE_PLATFORM_UWP) */
#endif
}




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Local File Functions                                                                                                                                                  */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

#if !defined(TgCOMPILE_PLATFORM_UWP)
/* ---- GB_Init__Validate_CPU_ID ---------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
static TgRESULT GB_Init__Validate_CPU_ID( TgVOID )
{
#if defined(TgCOMPILER_MSVC_MSVC)
    TgSINT32                              aiCPUInfo[4] = { -1 };

    TgEXTN void __cpuid( int a[4], int b );
    __cpuid( aiCPUInfo, 1 );
    TgERROR(0 != (aiCPUInfo[2] & (1 << 13)));
#endif

    return (KTgS_OK);
}
/*# !defined(TgCOMPILE_PLATFORM_UWP) */
#endif


#if !defined(TgCOMPILE_PLATFORM_UWP)
/* ---- GB_Init__Delay_Loaded_DLL --------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
static TgRESULT GB_Init__Delay_Loaded_DLL( TgVOID )
{
    STg2_Output                         sOutCon;

    sOutCon.m_pfnWrite = tgPM_DBG_ERR_Write;
    sOutCon.m_pfnClose = nullptr;

    /* API Set: api-ms-win-core-com-l1-1-1 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_COM, TgT("api-ms-win-core-com-l1-1-1") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load API set api-ms-win-core-com-l1-1-1\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnCoInitializeEx, s_hDLL_Core_COM, "CoInitializeEx" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnCoUninitialize, s_hDLL_Core_COM, "CoUninitialize" )
    )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-com-l1-1-1\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };


#if !defined(TgCOMPILE_WIDE_CHAR)
    /* API Set: api-ms-win-core-synch-l1-2-0 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_Sync1, TgT("api-ms-win-core-synch-ansi-l1-1-0") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-synch-ansi-l1-1-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnCreateSemaphoreEx, s_hDLL_Core_Sync1, "CreateSemaphoreExA" )
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-synch-ansi-l1-1-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };
/*# !defined(TgCOMPILE_WIDE_CHAR) */
#endif

    /* API Set: api-ms-win-core-synch-l1-2-0 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_Sync2, TgT("api-ms-win-core-synch-l1-2-0") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-synch-l1-2-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnCreateEventEx, s_hDLL_Core_Sync2, TFCN( CreateEventEx ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnSetEvent, s_hDLL_Core_Sync2, "SetEvent" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnResetEvent, s_hDLL_Core_Sync2, "ResetEvent" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnReleaseSemaphore, s_hDLL_Core_Sync2, "ReleaseSemaphore" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnCreateMutexEx, s_hDLL_Core_Sync2, TFCN( CreateMutexEx ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnReleaseMutex, s_hDLL_Core_Sync2, "ReleaseMutex" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnInitializeCriticalSectionEx, s_hDLL_Core_Sync2, "InitializeCriticalSectionEx" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnEnterCriticalSection, s_hDLL_Core_Sync2, "EnterCriticalSection" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnLeaveCriticalSection, s_hDLL_Core_Sync2, "LeaveCriticalSection" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnTryEnterCriticalSection, s_hDLL_Core_Sync2, "TryEnterCriticalSection" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnDeleteCriticalSection, s_hDLL_Core_Sync2, "DeleteCriticalSection" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnWaitForSingleObjectEx, s_hDLL_Core_Sync2, "WaitForSingleObjectEx" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnSleep, s_hDLL_Core_Sync2, "Sleep" )
    #if defined(TgCOMPILE_WIDE_CHAR)
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnCreateSemaphoreEx, s_hDLL_Core_Sync2, "CreateSemaphoreExW" )
    #endif
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-synch-l1-2-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* API Set: api-ms-win-core-processthreads-l1-1-2 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_ProcessThread, TgT("api-ms-win-core-processthreads-l1-1-2") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-processthreads-l1-1-2\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetCurrentProcess, s_hDLL_Core_ProcessThread, "GetCurrentProcess" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetCurrentProcessId, s_hDLL_Core_ProcessThread, "GetCurrentProcessId" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnCreateThread, s_hDLL_Core_ProcessThread, "CreateThread" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetCurrentThread, s_hDLL_Core_ProcessThread, "GetCurrentThread" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetCurrentThreadId, s_hDLL_Core_ProcessThread, "GetCurrentThreadId" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetThreadId, s_hDLL_Core_ProcessThread, "GetThreadId" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnExitThread, s_hDLL_Core_ProcessThread, "ExitThread" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnTerminateThread, s_hDLL_Core_ProcessThread, "TerminateThread" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnSetThreadPriority, s_hDLL_Core_ProcessThread, "SetThreadPriority" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnSwitchToThread, s_hDLL_Core_ProcessThread, "SwitchToThread" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnIsProcessorFeaturePresent, s_hDLL_Core_ProcessThread, "IsProcessorFeaturePresent" )
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-processthreads-l1-1-2\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* API Set: api-ms-win-core-handle-l1-1-0 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_Handle, TgT("api-ms-win-core-handle-l1-1-0") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-handle-l1-1-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnCloseHandle, s_hDLL_Core_Handle, "CloseHandle" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnDuplicateHandle, s_hDLL_Core_Handle, "DuplicateHandle" )
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-handle-l1-1-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* API Set: api-ms-win-core-sysinfo-l1-2-1 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_SysInfo, TgT("api-ms-win-core-sysinfo-l1-2-1") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-sysinfo-l1-2-1\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetSystemInfo, s_hDLL_Core_SysInfo, "GetNativeSystemInfo" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetTickCount64, s_hDLL_Core_SysInfo, "GetTickCount64" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetComputerNameEx, s_hDLL_Core_SysInfo, TFCN( GetComputerNameEx ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetSystemDirectory, s_hDLL_Core_SysInfo, TFCN( GetSystemDirectory ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetWindowsDirectory, s_hDLL_Core_SysInfo, TFCN( GetWindowsDirectory ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGlobalMemoryStatusEx, s_hDLL_Core_SysInfo, "GlobalMemoryStatusEx" )
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-sysinfo-l1-2-1\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* API Set: api-ms-win-core-processenvironment-l1-2-0 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_ProcessEnvironment, TgT("api-ms-win-core-processenvironment-l1-2-0") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-processenvironment-l1-2-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetCurrentDirectory, s_hDLL_Core_ProcessEnvironment, TFCN( GetCurrentDirectory ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetCommandLine, s_hDLL_Core_ProcessEnvironment, TFCN( GetCommandLine ) )
        )
    {
        tgIO_PrintF(
            &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-processenvironment-l1-2-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* API Set: api-ms-win-core-profile-l1-1-0 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_Profile, TgT("api-ms-win-core-profile-l1-1-0") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-profile-l1-1-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnQueryPerformanceFrequency, s_hDLL_Core_Profile, "QueryPerformanceFrequency" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnQueryPerformanceCounter, s_hDLL_Core_Profile, "QueryPerformanceCounter" )
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-profile-l1-1-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* API Set: api-ms-win-core-file-l1-2-1 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_File1, TgT("api-ms-win-core-file-l1-2-1") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-file-l1-2-1\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnCreateFile2, s_hDLL_Core_File1, "CreateFile2" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetFileAttributesEx, s_hDLL_Core_File1, TFCN( GetFileAttributesEx ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnSetFilePointerEx, s_hDLL_Core_File1, "SetFilePointerEx" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnFlushFileBuffers, s_hDLL_Core_File1, "FlushFileBuffers" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnReadFile, s_hDLL_Core_File1, "ReadFile" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnWriteFile, s_hDLL_Core_File1, "WriteFile" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnCreateDirectory, s_hDLL_Core_File1, TFCN( CreateDirectory ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnRemoveDirectory, s_hDLL_Core_File1, TFCN( RemoveDirectory ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetTempPath, s_hDLL_Core_File1, TFCN( GetTempPath ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnFindFirstFile, s_hDLL_Core_File1, TFCN( FindFirstFile ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnFindNextFile, s_hDLL_Core_File1, TFCN( FindNextFile ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnFindClose, s_hDLL_Core_File1, "FindClose" )
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-file-l1-2-1\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* API Set: api-ms-win-core-file-l2-1-1 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_File2, TgT("api-ms-win-core-file-l2-1-1") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-file-l2-1-1\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnCopyFile2, s_hDLL_Core_File2, "CopyFile2" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetFileInformationByHandleEx, s_hDLL_Core_File2, "GetFileInformationByHandleEx" )
#if defined(TgCOMPILE_WIDE_CHAR)
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnMoveFileEx, s_hDLL_Core_File2, "MoveFileExW" )
#endif
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-file-l2-1-1\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* API Set: api-ms-win-core-errorhandling-l1-1-1 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_Error, TgT("api-ms-win-core-errorhandling-l1-1-1") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-errorhandling-l1-1-1\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnRaiseException, s_hDLL_Core_Error, "RaiseException" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetLastError, s_hDLL_Core_Error, "GetLastError" )
        )
    {
        tgIO_PrintF(
            &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-errorhandling-l1-1-1\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* API Set: api-ms-win-core-debug-l1-1-1 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_Debugger, TgT("api-ms-win-core-debug-l1-1-1") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-debug-l1-1-1\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnOutputDebugString, s_hDLL_Core_Debugger, TFCN( OutputDebugString ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnIsDebuggerPresent, s_hDLL_Core_Debugger, "IsDebuggerPresent" )
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-debug-l1-1-1\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* API Set: api-ms-win-core-libraryloader-l1-2-0 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_LibLoad, TgT("api-ms-win-core-libraryloader-l1-2-0") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-libraryloader-l1-2-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetModuleFileName, s_hDLL_Core_LibLoad, TFCN( GetModuleFileName ) )
        )
    {
        tgIO_PrintF(
            &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-libraryloader-l1-2-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* API Set: api-ms-win-core-localization-l1-2-1 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_Local, TgT("api-ms-win-core-localization-l1-2-1") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-localization-l1-2-1\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnFormatMessage, s_hDLL_Core_Local, TFCN( FormatMessage ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetLocaleInfo, s_hDLL_Core_Local, TFCN( GetLocaleInfo ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetACP, s_hDLL_Core_Local, "GetACP" )
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-localization-l1-2-1\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* API Set: api-ms-win-core-heap-l1-2-0 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_Heap, TgT("api-ms-win-core-heap-l1-2-0") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-heap-l1-2-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetProcessHeap, s_hDLL_Core_Heap, "GetProcessHeap" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnHeapFree, s_hDLL_Core_Heap, "HeapFree" )
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-heap-l1-2-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* API Set: api-ms-win-core-memory-l1-1-2 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_Mem1, TgT("api-ms-win-core-memory-l1-1-2") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-memory-l1-1-2\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnVirtualFree, s_hDLL_Core_Mem1, "VirtualFree" )
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-memory-l1-1-2\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* API Set: api-ms-win-core-realtime-l1-1-0 */
    if (!tgGB_Load_Lib( &s_hDLL_Core_RealTime, TgT("api-ms-win-core-realtime-l1-1-0") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load api-ms-win-core-realtime-l1-1-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnQueryProcessCycleTime, s_hDLL_Core_RealTime, "QueryProcessCycleTime" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnQueryThreadCycleTime, s_hDLL_Core_RealTime, "QueryThreadCycleTime" )
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in api-ms-win-core-realtime-l1-1-0\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* Kernel32 */
    if (!tgGB_Load_Lib( &s_hDLL_Kernel32, TgT("kernel32") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load kernel32\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnCreateToolhelp32Snapshot, s_hDLL_Kernel32, "CreateToolhelp32Snapshot" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnThread32First, s_hDLL_Kernel32, "Thread32First" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnThread32Next, s_hDLL_Kernel32, "Thread32Next" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnVerifyVersionInfo, s_hDLL_Kernel32, TFCN( VerifyVersionInfo ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnQueryProcessCycleTime, s_hDLL_Kernel32, "QueryProcessCycleTime" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnQueryThreadCycleTime, s_hDLL_Kernel32, "QueryThreadCycleTime" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnCreateFile, s_hDLL_Kernel32, TFCN( CreateFile ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnDeleteFile, s_hDLL_Kernel32, TFCN( DeleteFile ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnCopyFile, s_hDLL_Kernel32, TFCN( CopyFile ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnVirtualAlloc, s_hDLL_Kernel32, "VirtualAlloc" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnLocalFree, s_hDLL_Kernel32, "LocalFree" )
#if !defined(TgCOMPILE_WIDE_CHAR)
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnMoveFileEx, s_hDLL_Kernel32, "MoveFileExA" )
#endif
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in kernel32\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* Load the AdvAPI32 functions from the DLL */
    if (!tgGB_Load_Lib( &s_hDLL_AdvAPI32, TgT("advapi32.dll") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load AdvAPI32 DLL.\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetUserName, s_hDLL_AdvAPI32, TFCN( GetUserName ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetCurrentHwProfile, s_hDLL_AdvAPI32, TFCN( GetCurrentHwProfile ) )
    )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in AdvAPI32 DLL.\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* Load the PSAPI functions from the DLL */
    if (!tgGB_Load_Lib( &s_hDLL_PSAPI, TgT("psapi.dll") ))
    {
        TgCRITICAL_MSGF( 0, TgT("%-16.16s(%-32.32s): Unable to load PSAPI DLL.\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnEnumProcessModulesEx, s_hDLL_PSAPI, "EnumProcessModulesEx" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetModuleFileNameEx, s_hDLL_PSAPI, TFCN( GetModuleFileNameEx ) )
    )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in PSAPI DLL.\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* Load the User functions from the DLL */
    if (!tgGB_Load_Lib( &s_hDLL_User32, TgT("user32.dll") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load User32 DLL.\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetSystemMetrics, s_hDLL_User32, "GetSystemMetrics" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnSystemParametersInfo, s_hDLL_User32, TFCN( SystemParametersInfo ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnGetMonitorInfo, s_hDLL_User32, TFCN( GetMonitorInfo ) )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnMonitorFromRect, s_hDLL_User32, "MonitorFromRect" )
        || TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnEnumDisplayMonitors, s_hDLL_User32, "EnumDisplayMonitors" )
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in User32 DLL.\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    /* Load the User functions from the DLL */
    if (!tgGB_Load_Lib( &s_hDLL_NTDLL, TgT("ntdll.dll") ))
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to load NTDLL DLL.\n"), TgT("Global"), TgT("Platform") );
        tgPM_Break(); return (KTgE_FAIL);
    };

    if (
           TgTRUE != tgGB_Get_Func_Address( (TgMS_FARPROC*)&g_pfnNtDelayExecution, s_hDLL_NTDLL, "NtDelayExecution" )
        )
    {
        tgIO_PrintF( &sOutCon, TgT("%-16.16s(%-32.32s): Unable to find function in NTDLL DLL.\n"), TgT("Global"), TgT("Platform") );
        return (KTgE_FAIL);
    };

    return (KTgS_OK);
}
/*# !defined(TgCOMPILE_PLATFORM_UWP) */
#endif