diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e457e9e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,11 @@ +[submodule "externals/alure"] + path = externals/alure + url = https://github.com/LAGonauta/alure + branch = hasLoopPoints +[submodule "externals/metahook"] + path = externals/metahook + url = https://github.com/LAGonauta/metahook + branch = cmake +[submodule "externals/openal-soft"] + path = externals/openal-soft + url = https://github.com/kcat/openal-soft diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..706bad5 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,59 @@ +cmake_minimum_required(VERSION 3.9) + +if(NOT CMAKE_BUILD_TYPE STREQUAL Debug) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) +endif() + +set(CMAKE_CXX_STANDARD 17) + +project(MetaAudio) + +set(SOURCES + src/exportfuncs.cpp + src/plugins.cpp + src/snd_dma.cpp + src/snd_fx.cpp + src/snd_hook.cpp + src/snd_loader.cpp + src/snd_mem.cpp + src/snd_voice.cpp + src/snd_vox.cpp + src/snd_wav.cpp + src/zone.cpp + src/interface.cpp +) + +add_library(MetaAudio SHARED ${SOURCES}) +target_compile_definitions(MetaAudio PRIVATE AUDIO_EXPORTS) + +target_include_directories(MetaAudio + PRIVATE + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_SOURCE_DIR}/externals/alure/include/AL + ${PROJECT_SOURCE_DIR}/externals/openal-soft/include/AL + ${PROJECT_SOURCE_DIR}/externals/metahook/include + ${PROJECT_SOURCE_DIR}/externals/metahook/include/interface + ${PROJECT_SOURCE_DIR}/externals/metahook/HLSDK/common + ${PROJECT_SOURCE_DIR}/externals/metahook/HLSDK/cl_dll + ${PROJECT_SOURCE_DIR}/externals/metahook/HLSDK/engine + ${PROJECT_SOURCE_DIR}/externals/metahook/HLSDK/public + ${PROJECT_SOURCE_DIR}/externals/metahook/HLSDK/pm_shared +) + +set(ALSOFT_EXAMPLES OFF) +set(ALSOFT_TESTS OFF) +set(ALSOFT_UTILS OFF) +add_subdirectory(externals/openal-soft) + +set(OPENAL_INCLUDE_DIR "../openal-soft/include/AL") +set(ALURE_INSTALL OFF) +set(ALURE_BUILD_STATIC OFF) +set(ALURE_ENABLE_WAVE OFF) +set(ALURE_ENABLE_VORBIS OFF) +set(ALURE_ENABLE_FLAC OFF) +set(ALURE_BUILD_EXAMPLES OFF) +add_subdirectory(externals/alure) + +add_subdirectory(externals/metahook) + +target_link_libraries(MetaAudio PRIVATE OpenAL alure2) diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 0000000..0c5fac5 --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,30 @@ +{ + "configurations": [ + { + "name": "x86-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "inheritEnvironments": [ + "msvc_x86" + ], + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\MetaAudio\\${workspaceHash}\\build\\${name}", + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\MetaAudio\\${workspaceHash}\\install\\${name}", + "cmakeCommandArgs": "-DOPENAL_LIBRARY=${env.USERPROFILE}\\CMakeBuilds\\MetaAudio\\${workspaceHash}\\build\\${name}\\externals\\openal-soft\\OpenAL32.lib", + "buildCommandArgs": "-v", + "ctestCommandArgs": "" + }, + { + "name": "x86-Release", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ + "msvc_x86" + ], + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\MetaAudio\\${workspaceHash}\\build\\${name}", + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\MetaAudio\\${workspaceHash}\\install\\${name}", + "cmakeCommandArgs": "-DOPENAL_LIBRARY=${env.USERPROFILE}\\CMakeBuilds\\MetaAudio\\${workspaceHash}\\build\\${name}\\externals\\openal-soft\\OpenAL32.lib", + "buildCommandArgs": "-v", + "ctestCommandArgs": "" + } + ] +} \ No newline at end of file diff --git a/Detours/detours.cpp b/Detours/detours.cpp deleted file mode 100644 index 67f1499..0000000 --- a/Detours/detours.cpp +++ /dev/null @@ -1,1873 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Core Detours Functionality (detours.cpp of detours.lib) -// -// Microsoft Research Detours Package, Version 3.0 Build_316. -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -#include - -#if (_MSC_VER < 1299) -#pragma warning(disable: 4710) -#endif - -//#define DETOUR_DEBUG 1 -#define DETOURS_INTERNAL - -#include "detours.h" - -#if defined(DETOURS_X86) -#elif defined(DETOURS_X64) -#elif defined(DETOURS_IA64) -#elif defined(DETOURS_ARM) -#else -#error Must define one of DETOURS_X86, DETOURS_X64, DETOURS_IA64, or DETOURS_ARM -#endif - -#if !defined(DETOURS_32BIT) && !defined(DETOURS_64BIT) -#error Must define one of DETOURS_32BIT or DETOURS_64BIT -#endif - -////////////////////////////////////////////////////////////////////////////// -// -struct _DETOUR_ALIGN -{ - BYTE obTarget : 3; - BYTE obTrampoline : 5; -}; - -C_ASSERT(sizeof(_DETOUR_ALIGN) == 1); - -////////////////////////////////////////////////////////////////////////////// -// -static bool detour_is_imported(PBYTE pbCode, PBYTE pbAddress) -{ - MEMORY_BASIC_INFORMATION mbi; - VirtualQuery((PVOID)pbCode, &mbi, sizeof(mbi)); - /*__try*/ { - PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)mbi.AllocationBase; - if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) { - return false; - } - - PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)((PBYTE)pDosHeader + - pDosHeader->e_lfanew); - if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) { - return false; - } - - if (pbAddress >= ((PBYTE)pDosHeader + - pNtHeader->OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress) && - pbAddress < ((PBYTE)pDosHeader + - pNtHeader->OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress + - pNtHeader->OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].Size)) { - return true; - } - return false; - } - /*__except(EXCEPTION_EXECUTE_HANDLER) { - return false; - }*/ -} - -///////////////////////////////////////////////////////////////////////// X86. -// -#ifdef DETOURS_X86 - -struct _DETOUR_TRAMPOLINE -{ - BYTE rbCode[30]; // target code + jmp to pbRemain - BYTE cbCode; // size of moved target code. - BYTE cbCodeBreak; // padding to make debugging easier. - BYTE rbRestore[22]; // original target code. - BYTE cbRestore; // size of original target code. - BYTE cbRestoreBreak; // padding to make debugging easier. - _DETOUR_ALIGN rAlign[8]; // instruction alignment array. - PBYTE pbRemain; // first instruction after moved code. [free list] - PBYTE pbDetour; // first instruction of detour function. -}; - -C_ASSERT(sizeof(_DETOUR_TRAMPOLINE) == 72); - -enum { - SIZE_OF_JMP = 5 -}; - -inline PBYTE detour_gen_jmp_immediate(PBYTE pbCode, PBYTE pbJmpVal) -{ - PBYTE pbJmpSrc = pbCode + 5; - *pbCode++ = 0xE9; // jmp +imm32 - *((INT32*&)pbCode)++ = (INT32)(pbJmpVal - pbJmpSrc); - return pbCode; -} - -inline PBYTE detour_gen_jmp_indirect(PBYTE pbCode, PBYTE *ppbJmpVal) -{ - PBYTE pbJmpSrc = pbCode + 6; - *pbCode++ = 0xff; // jmp [+imm32] - *pbCode++ = 0x25; - *((INT32*&)pbCode)++ = (INT32)((PBYTE)ppbJmpVal - pbJmpSrc); - return pbCode; -} - -inline PBYTE detour_gen_brk(PBYTE pbCode, PBYTE pbLimit) -{ - while (pbCode < pbLimit) { - *pbCode++ = 0xcc; // brk; - } - return pbCode; -} - -inline PBYTE detour_skip_jmp(PBYTE pbCode, PVOID *ppGlobals) -{ - if (pbCode == NULL) { - return NULL; - } - if (ppGlobals != NULL) { - *ppGlobals = NULL; - } - - // First, skip over the import vector if there is one. - if (pbCode[0] == 0xff && pbCode[1] == 0x25) { // jmp [imm32] - // Looks like an import alias jump, then get the code it points to. - PBYTE pbTarget = *(PBYTE *)&pbCode[2]; - if (detour_is_imported(pbCode, pbTarget)) { - PBYTE pbNew = *(PBYTE *)pbTarget; - DETOUR_TRACE(("%p->%p: skipped over import table.\n", pbCode, pbNew)); - pbCode = pbNew; - } - } - - // Then, skip over a patch jump - if (pbCode[0] == 0xeb) { // jmp +imm8 - PBYTE pbNew = pbCode + 2 + *(CHAR *)&pbCode[1]; - DETOUR_TRACE(("%p->%p: skipped over short jump.\n", pbCode, pbNew)); - pbCode = pbNew; - - // First, skip over the import vector if there is one. - if (pbCode[0] == 0xff && pbCode[1] == 0x25) { // jmp [imm32] - // Looks like an import alias jump, then get the code it points to. - PBYTE pbTarget = *(PBYTE *)&pbCode[2]; - if (detour_is_imported(pbCode, pbTarget)) { - PBYTE pbNew = *(PBYTE *)pbTarget; - DETOUR_TRACE(("%p->%p: skipped over import table.\n", pbCode, pbNew)); - pbCode = pbNew; - } - } - // Finally, skip over a long jump if it is the target of the patch jump. - else if (pbCode[0] == 0xe9) { // jmp +imm32 - PBYTE pbNew = pbCode + 5 + *(INT32 *)&pbCode[1]; - DETOUR_TRACE(("%p->%p: skipped over long jump.\n", pbCode, pbNew)); - pbCode = pbNew; - } - } - return pbCode; -} - -inline BOOL detour_does_code_end_function(PBYTE pbCode) -{ - if (pbCode[0] == 0xeb || // jmp +imm8 - pbCode[0] == 0xe9 || // jmp +imm32 - pbCode[0] == 0xe0 || // jmp eax - pbCode[0] == 0xc2 || // ret +imm8 - pbCode[0] == 0xc3 || // ret - pbCode[0] == 0xcc) { // brk - return TRUE; - } - else if (pbCode[0] == 0xff && pbCode[1] == 0x25) { // jmp [+imm32] - return TRUE; - } - else if ((pbCode[0] == 0x26 || // jmp es: - pbCode[0] == 0x2e || // jmp cs: - pbCode[0] == 0x36 || // jmp ss: - pbCode[0] == 0xe3 || // jmp ds: - pbCode[0] == 0x64 || // jmp fs: - pbCode[0] == 0x65) && // jmp gs: - pbCode[1] == 0xff && // jmp [+imm32] - pbCode[2] == 0x25) { - return TRUE; - } - return FALSE; -} - -inline ULONG detour_is_code_filler(PBYTE pbCode) -{ - if (pbCode[0] == 0x90) { // nop - return 1; - } - return 0; -} - -#endif // DETOURS_X86 - -///////////////////////////////////////////////////////////////////////// X64. -// -#ifdef DETOURS_X64 -#error Feature not supported in this release. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#endif // DETOURS_X64 - -//////////////////////////////////////////////////////////////////////// IA64. -// -#ifdef DETOURS_IA64 -#error Feature not supported in this release. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#endif // DETOURS_IA64 - -#ifdef DETOURS_ARM -#error Feature not supported in this release. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#endif // DETOURS_ARM - -//////////////////////////////////////////////// Trampoline Memory Management. -// -struct DETOUR_REGION -{ - ULONG dwSignature; - DETOUR_REGION * pNext; // Next region in list of regions. - DETOUR_TRAMPOLINE * pFree; // List of free trampolines in this region. -}; -typedef DETOUR_REGION * PDETOUR_REGION; - -const ULONG DETOUR_REGION_SIGNATURE = 'Rrtd'; -const ULONG DETOUR_REGION_SIZE = 0x10000; -const ULONG DETOUR_TRAMPOLINES_PER_REGION = (DETOUR_REGION_SIZE - / sizeof(DETOUR_TRAMPOLINE)) - 1; -static PDETOUR_REGION s_pRegions = NULL; // List of all regions. -static PDETOUR_REGION s_pRegion = NULL; // Default region. - -static void detour_writable_trampoline_regions() -{ - // Mark all of the regions as writable. - for (PDETOUR_REGION pRegion = s_pRegions; pRegion != NULL; pRegion = pRegion->pNext) { - DWORD dwOld; - VirtualProtect(pRegion, DETOUR_REGION_SIZE, PAGE_EXECUTE_READWRITE, &dwOld); - } -} - -static void detour_runnable_trampoline_regions() -{ - HANDLE hProcess = GetCurrentProcess(); - - // Mark all of the regions as executable. - for (PDETOUR_REGION pRegion = s_pRegions; pRegion != NULL; pRegion = pRegion->pNext) { - DWORD dwOld; - VirtualProtect(pRegion, DETOUR_REGION_SIZE, PAGE_EXECUTE_READ, &dwOld); - FlushInstructionCache(hProcess, pRegion, DETOUR_REGION_SIZE); - } -} - -static PBYTE detour_alloc_round_down_to_region(PBYTE pbTry) -{ - // WinXP64 returns free areas that aren't REGION aligned to 32-bit applications. - ULONG_PTR extra = ((ULONG_PTR)pbTry) & (DETOUR_REGION_SIZE - 1); - if (extra != 0) { - pbTry -= extra; - } - return pbTry; -} - -static PBYTE detour_alloc_round_up_to_region(PBYTE pbTry) -{ - // WinXP64 returns free areas that aren't REGION aligned to 32-bit applications. - ULONG_PTR extra = ((ULONG_PTR)pbTry) & (DETOUR_REGION_SIZE - 1); - if (extra != 0) { - ULONG_PTR adjust = DETOUR_REGION_SIZE - extra; - pbTry += adjust; - } - return pbTry; -} - -// Starting at pbLo, try to allocate a memory region, continue until pbHi. - -static PVOID detour_alloc_region_from_lo(PBYTE pbLo, PBYTE pbHi) -{ - PBYTE pbTry = detour_alloc_round_up_to_region(pbLo); - - DETOUR_TRACE((" Looking for free region in %p..%p from %p:\n", pbLo, pbHi, pbTry)); - - for (; pbTry < pbHi;) { - MEMORY_BASIC_INFORMATION mbi; - - if (pbTry >= (PBYTE)(ULONG_PTR)0x50000000 && - pbTry <= (PBYTE)(ULONG_PTR)0x80000000) { - // Skip region reserved for system DLLs. - pbTry = (PBYTE)(ULONG_PTR)(0x80000000 + DETOUR_REGION_SIZE); - continue; - } - - ZeroMemory(&mbi, sizeof(mbi)); - if (!VirtualQuery(pbTry, &mbi, sizeof(mbi))) { - break; - } - - DETOUR_TRACE((" Try %p => %p..%p %6x\n", - pbTry, - mbi.BaseAddress, - (PBYTE)mbi.BaseAddress + mbi.RegionSize - 1, - mbi.State)); - - if (mbi.State == MEM_FREE && mbi.RegionSize >= DETOUR_REGION_SIZE) { - - PVOID pv = VirtualAlloc(pbTry, - DETOUR_REGION_SIZE, - MEM_COMMIT | MEM_RESERVE, - PAGE_EXECUTE_READWRITE); - if (pv != NULL) { - return pv; - } - pbTry += DETOUR_REGION_SIZE; - } - else { - pbTry = detour_alloc_round_up_to_region((PBYTE)mbi.BaseAddress + mbi.RegionSize); - } - } - return NULL; -} - -// Starting at pbHi, try to allocate a memory region, continue until pbLo. - -static PVOID detour_alloc_region_from_hi(PBYTE pbLo, PBYTE pbHi) -{ - PBYTE pbTry = detour_alloc_round_down_to_region(pbHi - DETOUR_REGION_SIZE); - - DETOUR_TRACE((" Looking for free region in %p..%p from %p:\n", pbLo, pbHi, pbTry)); - - for (; pbTry > pbLo;) { - MEMORY_BASIC_INFORMATION mbi; - - DETOUR_TRACE((" Try %p\n", pbTry)); - if (pbTry >= (PBYTE)(ULONG_PTR)0x50000000 && - pbTry <= (PBYTE)(ULONG_PTR)0x80000000) { - // Skip region reserved for system DLLs. - pbTry = (PBYTE)(ULONG_PTR)(0x50000000 - DETOUR_REGION_SIZE); - continue; - } - - ZeroMemory(&mbi, sizeof(mbi)); - if (!VirtualQuery(pbTry, &mbi, sizeof(mbi))) { - break; - } - - DETOUR_TRACE((" Try %p => %p..%p %6x\n", - pbTry, - mbi.BaseAddress, - (PBYTE)mbi.BaseAddress + mbi.RegionSize - 1, - mbi.State)); - - if (mbi.State == MEM_FREE && mbi.RegionSize >= DETOUR_REGION_SIZE) { - - PVOID pv = VirtualAlloc(pbTry, - DETOUR_REGION_SIZE, - MEM_COMMIT | MEM_RESERVE, - PAGE_EXECUTE_READWRITE); - if (pv != NULL) { - return pv; - } - pbTry -= DETOUR_REGION_SIZE; - } - else { - pbTry = detour_alloc_round_down_to_region((PBYTE)mbi.AllocationBase - - DETOUR_REGION_SIZE); - } - } - return NULL; -} - -static PDETOUR_TRAMPOLINE detour_alloc_trampoline(PBYTE pbTarget) -{ - // We have to place trampolines within +/- 2GB of target. - - PDETOUR_TRAMPOLINE pLo = (PDETOUR_TRAMPOLINE) - ((pbTarget > (PBYTE)0x7ff80000) - ? pbTarget - 0x7ff80000 : (PBYTE)(ULONG_PTR)DETOUR_REGION_SIZE); - PDETOUR_TRAMPOLINE pHi = (PDETOUR_TRAMPOLINE) - ((pbTarget < (PBYTE)0xffffffff80000000) - ? pbTarget + 0x7ff80000 : (PBYTE)0xfffffffffff80000); - DETOUR_TRACE(("[%p..%p..%p]\n", pLo, pbTarget, pHi)); - - PDETOUR_TRAMPOLINE pTrampoline = NULL; - - // Insure that there is a default region. - if (s_pRegion == NULL && s_pRegions != NULL) { - s_pRegion = s_pRegions; - } - - // First check the default region for an valid free block. - if (s_pRegion != NULL && s_pRegion->pFree != NULL && - s_pRegion->pFree >= pLo && s_pRegion->pFree <= pHi) { - - found_region: - pTrampoline = s_pRegion->pFree; - // do a last sanity check on region. - if (pTrampoline < pLo || pTrampoline > pHi) { - return NULL; - } - s_pRegion->pFree = (PDETOUR_TRAMPOLINE)pTrampoline->pbRemain; - memset(pTrampoline, 0xcc, sizeof(*pTrampoline)); - return pTrampoline; - } - - // Then check the existing regions for a valid free block. - for (s_pRegion = s_pRegions; s_pRegion != NULL; s_pRegion = s_pRegion->pNext) { - if (s_pRegion != NULL && s_pRegion->pFree != NULL && - s_pRegion->pFree >= pLo && s_pRegion->pFree <= pHi) { - goto found_region; - } - } - - // We need to allocate a new region. - - // Round pbTarget down to 64KB block. - pbTarget = pbTarget - (PtrToUlong(pbTarget) & 0xffff); - - PVOID pbTry = NULL; - - // Try looking 1GB below or lower. - if (pbTry == NULL && pbTarget > (PBYTE)0x40000000) { - pbTry = detour_alloc_region_from_hi((PBYTE)pLo, pbTarget - 0x40000000); - } - // Try looking 1GB above or higher. - if (pbTry == NULL && pbTarget < (PBYTE)0xffffffff40000000) { - pbTry = detour_alloc_region_from_lo(pbTarget + 0x40000000, (PBYTE)pHi); - } - // Try looking 1GB below or higher. - if (pbTry == NULL && pbTarget > (PBYTE)0x40000000) { - pbTry = detour_alloc_region_from_lo(pbTarget - 0x40000000, pbTarget); - } - // Try looking 1GB above or lower. - if (pbTry == NULL && pbTarget < (PBYTE)0xffffffff40000000) { - pbTry = detour_alloc_region_from_hi(pbTarget, pbTarget + 0x40000000); - } - // Try anything below. - if (pbTry == NULL) { - pbTry = detour_alloc_region_from_hi((PBYTE)pLo, pbTarget); - } - // try anything above. - if (pbTry == NULL) { - pbTry = detour_alloc_region_from_lo(pbTarget, (PBYTE)pHi); - } - - if (pbTry != NULL) { - s_pRegion = (DETOUR_REGION*)pbTry; - s_pRegion->dwSignature = DETOUR_REGION_SIGNATURE; - s_pRegion->pFree = NULL; - s_pRegion->pNext = s_pRegions; - s_pRegions = s_pRegion; - DETOUR_TRACE((" Allocated region %p..%p\n\n", - s_pRegion, ((PBYTE)s_pRegion) + DETOUR_REGION_SIZE - 1)); - - // Put everything but the first trampoline on the free list. - PBYTE pFree = NULL; - pTrampoline = ((PDETOUR_TRAMPOLINE)s_pRegion) + 1; - for (int i = DETOUR_TRAMPOLINES_PER_REGION - 1; i > 1; i--) { - pTrampoline[i].pbRemain = pFree; - pFree = (PBYTE)&pTrampoline[i]; - } - s_pRegion->pFree = (PDETOUR_TRAMPOLINE)pFree; - goto found_region; - } - - DETOUR_TRACE(("Couldn't find available memory region!\n")); - return NULL; -} - -static void detour_free_trampoline(PDETOUR_TRAMPOLINE pTrampoline) -{ - PDETOUR_REGION pRegion = (PDETOUR_REGION) - ((ULONG_PTR)pTrampoline & ~(ULONG_PTR)0xffff); - - memset(pTrampoline, 0, sizeof(*pTrampoline)); - pTrampoline->pbRemain = (PBYTE)pRegion->pFree; - pRegion->pFree = pTrampoline; -} - -static BOOL detour_is_region_empty(PDETOUR_REGION pRegion) -{ - // Stop if the region isn't a region (this would be bad). - if (pRegion->dwSignature != DETOUR_REGION_SIGNATURE) { - return FALSE; - } - - PBYTE pbRegionBeg = (PBYTE)pRegion; - PBYTE pbRegionLim = pbRegionBeg + DETOUR_REGION_SIZE; - - // Stop if any of the trampolines aren't free. - PDETOUR_TRAMPOLINE pTrampoline = ((PDETOUR_TRAMPOLINE)pRegion) + 1; - for (int i = 0; i < DETOUR_TRAMPOLINES_PER_REGION; i++) { - if (pTrampoline[i].pbRemain != NULL && - (pTrampoline[i].pbRemain < pbRegionBeg || - pTrampoline[i].pbRemain >= pbRegionLim)) { - return FALSE; - } - } - - // OK, the region is empty. - return TRUE; -} - -static void detour_free_unused_trampoline_regions() -{ - PDETOUR_REGION *ppRegionBase = &s_pRegions; - PDETOUR_REGION pRegion = s_pRegions; - - while (pRegion != NULL) { - if (detour_is_region_empty(pRegion)) { - *ppRegionBase = pRegion->pNext; - - VirtualFree(pRegion, 0, MEM_RELEASE); - s_pRegion = NULL; - } - else { - ppRegionBase = &pRegion->pNext; - } - pRegion = *ppRegionBase; - } -} - -///////////////////////////////////////////////////////// Transaction Structs. -// -struct DetourThread -{ - DetourThread * pNext; - HANDLE hThread; -}; - -struct DetourOperation -{ - DetourOperation * pNext; - BOOL fIsRemove; - PBYTE * ppbPointer; - PBYTE pbTarget; - PDETOUR_TRAMPOLINE pTrampoline; - ULONG dwPerm; -}; - -static BOOL s_fIgnoreTooSmall = FALSE; -static BOOL s_fRetainRegions = FALSE; - -static LONG s_nPendingThreadId = 0; // Thread owning pending transaction. -static LONG s_nPendingError = NO_ERROR; -static PVOID * s_ppPendingError = NULL; -static DetourThread * s_pPendingThreads = NULL; -static DetourOperation * s_pPendingOperations = NULL; - -////////////////////////////////////////////////////////////////////////////// -// -PVOID WINAPI DetourCodeFromPointer(PVOID pPointer, PVOID *ppGlobals) -{ - return detour_skip_jmp((PBYTE)pPointer, ppGlobals); -} - -//////////////////////////////////////////////////////////// Transaction APIs. -// -BOOL WINAPI DetourSetIgnoreTooSmall(BOOL fIgnore) -{ - BOOL fPrevious = s_fIgnoreTooSmall; - s_fIgnoreTooSmall = fIgnore; - return fPrevious; -} - -BOOL WINAPI DetourSetRetainRegions(BOOL fRetain) -{ - BOOL fPrevious = s_fRetainRegions; - s_fRetainRegions = fRetain; - return fPrevious; -} - -LONG WINAPI DetourTransactionBegin() -{ - // Only one transaction is allowed at a time. - if (s_nPendingThreadId != 0) { - return ERROR_INVALID_OPERATION; - } - // Make sure only one thread can start a transaction. - if (InterlockedCompareExchange(&s_nPendingThreadId, (LONG)GetCurrentThreadId(), 0) != 0) { - return ERROR_INVALID_OPERATION; - } - - s_pPendingOperations = NULL; - s_pPendingThreads = NULL; - s_nPendingError = NO_ERROR; - s_ppPendingError = NULL; - - // Make sure the trampoline pages are writable. - detour_writable_trampoline_regions(); - - return NO_ERROR; -} - -LONG WINAPI DetourTransactionAbort() -{ - if (s_nPendingThreadId != (LONG)GetCurrentThreadId()) { - return ERROR_INVALID_OPERATION; - } - - // Restore all of the page permissions. - for (DetourOperation *o = s_pPendingOperations; o != NULL;) { - // We don't care if this fails, because the code is still accessible. - DWORD dwOld; - VirtualProtect(o->pbTarget, o->pTrampoline->cbRestore, - o->dwPerm, &dwOld); - - if (!o->fIsRemove) { - if (o->pTrampoline) { - detour_free_trampoline(o->pTrampoline); - o->pTrampoline = NULL; - } - } - - DetourOperation *n = o->pNext; - delete o; - o = n; - } - s_pPendingOperations = NULL; - - // Make sure the trampoline pages are no longer writable. - detour_runnable_trampoline_regions(); - - // Resume any suspended threads. - for (DetourThread *t = s_pPendingThreads; t != NULL;) { - // There is nothing we can do if this fails. - ResumeThread(t->hThread); - - DetourThread *n = t->pNext; - delete t; - t = n; - } - s_pPendingThreads = NULL; - s_nPendingThreadId = 0; - - return NO_ERROR; -} - -LONG WINAPI DetourTransactionCommit() -{ - return DetourTransactionCommitEx(NULL); -} - -static BYTE detour_align_from_trampoline(PDETOUR_TRAMPOLINE pTrampoline, BYTE obTrampoline) -{ - for (LONG n = 0; n < ARRAYSIZE(pTrampoline->rAlign); n++) { - if (pTrampoline->rAlign[n].obTrampoline == obTrampoline) { - return pTrampoline->rAlign[n].obTarget; - } - } - return 0; -} - -static LONG detour_align_from_target(PDETOUR_TRAMPOLINE pTrampoline, LONG obTarget) -{ - for (LONG n = 0; n < ARRAYSIZE(pTrampoline->rAlign); n++) { - if (pTrampoline->rAlign[n].obTarget == obTarget) { - return pTrampoline->rAlign[n].obTrampoline; - } - } - return 0; -} - -LONG WINAPI DetourTransactionCommitEx(PVOID **pppFailedPointer) -{ - if (pppFailedPointer != NULL) { - // Used to get the last error. - *pppFailedPointer = s_ppPendingError; - } - if (s_nPendingThreadId != (LONG)GetCurrentThreadId()) { - return ERROR_INVALID_OPERATION; - } - - // If any of the pending operations failed, then we abort the whole transaction. - if (s_nPendingError != NO_ERROR) { - DETOUR_BREAK(); - DetourTransactionAbort(); - return s_nPendingError; - } - - // Common variables. - DetourOperation *o; - DetourThread *t; - BOOL freed = FALSE; - - // Insert or remove each of the detours. - for (o = s_pPendingOperations; o != NULL; o = o->pNext) { - if (o->fIsRemove) { - CopyMemory(o->pbTarget, - o->pTrampoline->rbRestore, - o->pTrampoline->cbRestore); -#ifdef DETOURS_IA64 -#error Feature not supported in this release. -#endif // DETOURS_IA64 - -#ifdef DETOURS_X86 - *o->ppbPointer = o->pbTarget; -#endif // DETOURS_X86 - -#ifdef DETOURS_X64 -#error Feature not supported in this release. -#endif // DETOURS_X64 - -#ifdef DETOURS_ARM -#error Feature not supported in this release. -#endif // DETOURS_ARM - } - else { - DETOUR_TRACE(("detours: pbTramp =%p, pbRemain=%p, pbDetour=%p, cbRestore=%d\n", - o->pTrampoline, - o->pTrampoline->pbRemain, - o->pTrampoline->pbDetour, - o->pTrampoline->cbRestore)); - - DETOUR_TRACE(("detours: pbTarget=%p: " - "%02x %02x %02x %02x " - "%02x %02x %02x %02x " - "%02x %02x %02x %02x [before]\n", - o->pbTarget, - o->pbTarget[0], o->pbTarget[1], o->pbTarget[2], o->pbTarget[3], - o->pbTarget[4], o->pbTarget[5], o->pbTarget[6], o->pbTarget[7], - o->pbTarget[8], o->pbTarget[9], o->pbTarget[10], o->pbTarget[11])); - -#ifdef DETOURS_IA64 -#error Feature not supported in this release. - - -#endif // DETOURS_IA64 - -#ifdef DETOURS_X64 -#error Feature not supported in this release. - - - -#endif // DETOURS_X64 - -#ifdef DETOURS_X86 - PBYTE pbCode = detour_gen_jmp_immediate(o->pbTarget, o->pTrampoline->pbDetour); - pbCode = detour_gen_brk(pbCode, o->pTrampoline->pbRemain); - *o->ppbPointer = o->pTrampoline->rbCode; -#endif // DETOURS_X86 - -#ifdef DETOURS_ARM -#error Feature not supported in this release. - - -#endif // DETOURS_ARM - - DETOUR_TRACE(("detours: pbTarget=%p: " - "%02x %02x %02x %02x " - "%02x %02x %02x %02x " - "%02x %02x %02x %02x [after]\n", - o->pbTarget, - o->pbTarget[0], o->pbTarget[1], o->pbTarget[2], o->pbTarget[3], - o->pbTarget[4], o->pbTarget[5], o->pbTarget[6], o->pbTarget[7], - o->pbTarget[8], o->pbTarget[9], o->pbTarget[10], o->pbTarget[11])); - - DETOUR_TRACE(("detours: pbTramp =%p: " - "%02x %02x %02x %02x " - "%02x %02x %02x %02x " - "%02x %02x %02x %02x\n", - o->pTrampoline, - o->pTrampoline->rbCode[0], o->pTrampoline->rbCode[1], - o->pTrampoline->rbCode[2], o->pTrampoline->rbCode[3], - o->pTrampoline->rbCode[4], o->pTrampoline->rbCode[5], - o->pTrampoline->rbCode[6], o->pTrampoline->rbCode[7], - o->pTrampoline->rbCode[8], o->pTrampoline->rbCode[9], - o->pTrampoline->rbCode[10], o->pTrampoline->rbCode[11])); - -#ifdef DETOURS_IA64 -#error Feature not supported in this release. - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#endif // DETOURS_IA64 - } - } - - // Update any suspended threads. - for (t = s_pPendingThreads; t != NULL; t = t->pNext) { - CONTEXT cxt; - cxt.ContextFlags = CONTEXT_CONTROL; - -#undef DETOURS_EIP -#undef DETOURS_EIP_TYPE - -#ifdef DETOURS_X86 -#define DETOURS_EIP Eip -#define DETOURS_EIP_TYPE DWORD -#endif // DETOURS_X86 - -#ifdef DETOURS_X64 -#error Feature not supported in this release. - -#endif // DETOURS_X64 - -#ifdef DETOURS_IA64 -#error Feature not supported in this release. - -#endif // DETOURS_IA64 - -#ifdef DETOURS_ARM -#error Feature not supported in this release. - -#endif // DETOURS_ARM - - if (GetThreadContext(t->hThread, &cxt)) { - for (DetourOperation *o = s_pPendingOperations; o != NULL; o = o->pNext) { - if (o->fIsRemove) { - if (cxt.DETOURS_EIP >= (DETOURS_EIP_TYPE)(ULONG_PTR)o->pTrampoline && - cxt.DETOURS_EIP < (DETOURS_EIP_TYPE)((ULONG_PTR)o->pTrampoline - + sizeof(o->pTrampoline)) - ) { - - cxt.DETOURS_EIP = (DETOURS_EIP_TYPE) - ((ULONG_PTR)o->pbTarget - + detour_align_from_trampoline(o->pTrampoline, - (BYTE)(cxt.DETOURS_EIP - - (DETOURS_EIP_TYPE)(ULONG_PTR) - o->pTrampoline))); - - SetThreadContext(t->hThread, &cxt); - } - } - else { - if (cxt.DETOURS_EIP >= (DETOURS_EIP_TYPE)(ULONG_PTR)o->pbTarget && - cxt.DETOURS_EIP < (DETOURS_EIP_TYPE)((ULONG_PTR)o->pbTarget - + o->pTrampoline->cbRestore) - ) { - - cxt.DETOURS_EIP = (DETOURS_EIP_TYPE) - ((ULONG_PTR)o->pTrampoline - + detour_align_from_target(o->pTrampoline, - (BYTE)(cxt.DETOURS_EIP - - (DETOURS_EIP_TYPE)(ULONG_PTR) - o->pbTarget))); - - SetThreadContext(t->hThread, &cxt); - } - } - } - } -#undef DETOURS_EIP - } - - // Restore all of the page permissions and flush the icache. - HANDLE hProcess = GetCurrentProcess(); - for (o = s_pPendingOperations; o != NULL;) { - // We don't care if this fails, because the code is still accessible. - DWORD dwOld; - VirtualProtect(o->pbTarget, o->pTrampoline->cbRestore, o->dwPerm, &dwOld); - FlushInstructionCache(hProcess, o->pbTarget, o->pTrampoline->cbRestore); - - if (o->fIsRemove && o->pTrampoline) { - detour_free_trampoline(o->pTrampoline); - o->pTrampoline = NULL; - freed = true; - } - - DetourOperation *n = o->pNext; - delete o; - o = n; - } - s_pPendingOperations = NULL; - - // Free any trampoline regions that are now unused. - if (freed && !s_fRetainRegions) { - detour_free_unused_trampoline_regions(); - } - - // Make sure the trampoline pages are no longer writable. - detour_runnable_trampoline_regions(); - - // Resume any suspended threads. - for (t = s_pPendingThreads; t != NULL;) { - // There is nothing we can do if this fails. - ResumeThread(t->hThread); - - DetourThread *n = t->pNext; - delete t; - t = n; - } - s_pPendingThreads = NULL; - s_nPendingThreadId = 0; - - if (pppFailedPointer != NULL) { - *pppFailedPointer = s_ppPendingError; - } - - return s_nPendingError; -} - -LONG WINAPI DetourUpdateThread(HANDLE hThread) -{ - LONG error; - - // If any of the pending operations failed, then we don't need to do this. - if (s_nPendingError != NO_ERROR) { - return s_nPendingError; - } - - // Silently (and safely) drop any attempt to suspend our own thread. - if (hThread == GetCurrentThread()) { - return NO_ERROR; - } - - DetourThread *t = new DetourThread; - if (t == NULL) { - error = ERROR_NOT_ENOUGH_MEMORY; - fail: - if (t != NULL) { - delete t; - t = NULL; - } - s_nPendingError = error; - s_ppPendingError = NULL; - DETOUR_BREAK(); - return error; - } - - if (SuspendThread(hThread) == (DWORD)-1) { - error = GetLastError(); - DETOUR_BREAK(); - goto fail; - } - - t->hThread = hThread; - t->pNext = s_pPendingThreads; - s_pPendingThreads = t; - - return NO_ERROR; -} - -///////////////////////////////////////////////////////////// Transacted APIs. -// -LONG WINAPI DetourAttach(PVOID *ppPointer, - PVOID pDetour) -{ - return DetourAttachEx(ppPointer, pDetour, NULL, NULL, NULL); -} - -LONG WINAPI DetourAttachEx(PVOID *ppPointer, - PVOID pDetour, - PDETOUR_TRAMPOLINE *ppRealTrampoline, - PVOID *ppRealTarget, - PVOID *ppRealDetour) -{ - LONG error = NO_ERROR; - - if (ppRealTrampoline != NULL) { - *ppRealTrampoline = NULL; - } - if (ppRealTarget != NULL) { - *ppRealTarget = NULL; - } - if (ppRealDetour != NULL) { - *ppRealDetour = NULL; - } - - if (s_nPendingThreadId != (LONG)GetCurrentThreadId()) { - DETOUR_TRACE(("transaction conflict with thread id=%d\n", s_nPendingThreadId)); - return ERROR_INVALID_OPERATION; - } - - // If any of the pending operations failed, then we don't need to do this. - if (s_nPendingError != NO_ERROR) { - DETOUR_TRACE(("pending transaction error=%d\n", s_nPendingError)); - return s_nPendingError; - } - - if (ppPointer == NULL) { - DETOUR_TRACE(("ppPointer is null\n")); - return ERROR_INVALID_HANDLE; - } - if (*ppPointer == NULL) { - error = ERROR_INVALID_HANDLE; - s_nPendingError = error; - s_ppPendingError = ppPointer; - DETOUR_TRACE(("*ppPointer is null (ppPointer=%p)\n", ppPointer)); - DETOUR_BREAK(); - return error; - } - - PBYTE pbTarget = (PBYTE)*ppPointer; - PDETOUR_TRAMPOLINE pTrampoline = NULL; - DetourOperation *o = NULL; - -#ifdef DETOURS_IA64 -#error Feature not supported in this release. - - - - - - - - - - -#else // DETOURS_IA64 - pbTarget = (PBYTE)DetourCodeFromPointer(pbTarget, NULL); - pDetour = DetourCodeFromPointer(pDetour, NULL); -#endif // !DETOURS_IA64 - - // Don't follow a jump if its destination is the target function. - // This happens when the detour does nothing other than call the target. - if (pDetour == (PVOID)pbTarget) { - if (s_fIgnoreTooSmall) { - goto stop; - } - else { - DETOUR_BREAK(); - goto fail; - } - } - - if (ppRealTarget != NULL) { - *ppRealTarget = pbTarget; - } - if (ppRealDetour != NULL) { - *ppRealDetour = pDetour; - } - - o = new DetourOperation; - if (o == NULL) { - error = ERROR_NOT_ENOUGH_MEMORY; - fail: - s_nPendingError = error; - DETOUR_BREAK(); - stop: - if (pTrampoline != NULL) { - detour_free_trampoline(pTrampoline); - pTrampoline = NULL; - if (ppRealTrampoline != NULL) { - *ppRealTrampoline = NULL; - } - } - if (o != NULL) { - delete o; - o = NULL; - } - s_ppPendingError = ppPointer; - return error; - } - - pTrampoline = detour_alloc_trampoline(pbTarget); - if (pTrampoline == NULL) { - error = ERROR_NOT_ENOUGH_MEMORY; - DETOUR_BREAK(); - goto fail; - } - - if (ppRealTrampoline != NULL) { - *ppRealTrampoline = pTrampoline; - } - - DETOUR_TRACE(("detours: pbTramp=%p, pDetour=%p\n", pTrampoline, pDetour)); - - memset(pTrampoline->rAlign, 0, sizeof(pTrampoline->rAlign)); - - // Determine the number of movable target instructions. - PBYTE pbSrc = pbTarget; - PBYTE pbTrampoline = pTrampoline->rbCode; - PBYTE pbPool = pbTrampoline + sizeof(pTrampoline->rbCode); - ULONG cbTarget = 0; - ULONG cbJump = SIZE_OF_JMP; - ULONG nAlign = 0; - -#ifdef DETOURS_ARM -#error Feature not supported in this release. - - - - - - - - - - - - - - - - - - - - - - - - - - -#endif - - while (cbTarget < cbJump) { - PBYTE pbOp = pbSrc; - LONG lExtra = 0; - - DETOUR_TRACE((" DetourCopyInstruction(%p,%p)\n", - pbTrampoline, pbSrc)); - pbSrc = (PBYTE) - DetourCopyInstruction(pbTrampoline, (PVOID*)&pbPool, pbSrc, NULL, &lExtra); - DETOUR_TRACE((" DetourCopyInstruction() = %p (%d bytes)\n", - pbSrc, (int)(pbSrc - pbOp))); - pbTrampoline += (pbSrc - pbOp) + lExtra; - cbTarget = (LONG)(pbSrc - pbTarget); - pTrampoline->rAlign[nAlign].obTarget = cbTarget; - pTrampoline->rAlign[nAlign].obTrampoline = pbTrampoline - pTrampoline->rbCode; - - if (detour_does_code_end_function(pbOp)) { - break; - } - } - - // Consume, but don't duplicate padding if it is needed and available. - while (cbTarget < cbJump) { - LONG cFiller = detour_is_code_filler(pbSrc); - if (cFiller == 0) { - break; - } - - pbSrc += cFiller; - cbTarget = (LONG)(pbSrc - pbTarget); - } - -#if DETOUR_DEBUG - { - DETOUR_TRACE((" detours: rAlign [")); - LONG n = 0; - for (n = 0; n < ARRAYSIZE(pTrampoline->rAlign); n++) { - if (pTrampoline->rAlign[n].obTarget == 0 && - pTrampoline->rAlign[n].obTrampoline == 0) { - break; - } - DETOUR_TRACE((" %d/%d", - pTrampoline->rAlign[n].obTarget, - pTrampoline->rAlign[n].obTrampoline - )); - - } - DETOUR_TRACE((" ]\n")); - } -#endif - - if (cbTarget < cbJump || nAlign > ARRAYSIZE(pTrampoline->rAlign)) { - // Too few instructions. - - error = ERROR_INVALID_BLOCK; - if (s_fIgnoreTooSmall) { - goto stop; - } - else { - DETOUR_BREAK(); - goto fail; - } - } - - if (pbTrampoline > pbPool) { - __debugbreak(); - } - -#if 0 // [GalenH] - if (cbTarget < pbTrampoline - pTrampoline->rbCode) { - __debugbreak(); - } -#endif - - pTrampoline->cbCode = (BYTE)(pbTrampoline - pTrampoline->rbCode); - pTrampoline->cbRestore = (BYTE)cbTarget; - CopyMemory(pTrampoline->rbRestore, pbTarget, cbTarget); - -#if !defined(DETOURS_IA64) - if (cbTarget > sizeof(pTrampoline->rbCode) - cbJump) { - // Too many instructions. - error = ERROR_INVALID_HANDLE; - DETOUR_BREAK(); - goto fail; - } -#endif // !DETOURS_IA64 - - pTrampoline->pbRemain = pbTarget + cbTarget; - pTrampoline->pbDetour = (PBYTE)pDetour; - -#ifdef DETOURS_IA64 -#error Feature not supported in this release. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#endif // DETOURS_IA64 - - pbTrampoline = pTrampoline->rbCode + pTrampoline->cbCode; -#ifdef DETOURS_X64 -#error Feature not supported in this release. - -#endif // DETOURS_X64 - -#ifdef DETOURS_X86 - pbTrampoline = detour_gen_jmp_immediate(pbTrampoline, pTrampoline->pbRemain); - pbTrampoline = detour_gen_brk(pbTrampoline, pbPool); -#endif // DETOURS_X86 - -#ifdef DETOURS_ARM -#error Feature not supported in this release. - -#endif // DETOURS_ARM - - DWORD dwOld = 0; - if (!VirtualProtect(pbTarget, cbTarget, PAGE_EXECUTE_READWRITE, &dwOld)) { - error = GetLastError(); - DETOUR_BREAK(); - goto fail; - } - - DETOUR_TRACE(("detours: pbTarget=%p: " - "%02x %02x %02x %02x " - "%02x %02x %02x %02x " - "%02x %02x %02x %02x\n", - pbTarget, - pbTarget[0], pbTarget[1], pbTarget[2], pbTarget[3], - pbTarget[4], pbTarget[5], pbTarget[6], pbTarget[7], - pbTarget[8], pbTarget[9], pbTarget[10], pbTarget[11])); - DETOUR_TRACE(("detours: pbTramp =%p: " - "%02x %02x %02x %02x " - "%02x %02x %02x %02x " - "%02x %02x %02x %02x\n", - pTrampoline, - pTrampoline->rbCode[0], pTrampoline->rbCode[1], - pTrampoline->rbCode[2], pTrampoline->rbCode[3], - pTrampoline->rbCode[4], pTrampoline->rbCode[5], - pTrampoline->rbCode[6], pTrampoline->rbCode[7], - pTrampoline->rbCode[8], pTrampoline->rbCode[9], - pTrampoline->rbCode[10], pTrampoline->rbCode[11])); - - o->fIsRemove = FALSE; - o->ppbPointer = (PBYTE*)ppPointer; - o->pTrampoline = pTrampoline; - o->pbTarget = pbTarget; - o->dwPerm = dwOld; - o->pNext = s_pPendingOperations; - s_pPendingOperations = o; - - return NO_ERROR; -} - -LONG WINAPI DetourDetach(PVOID *ppPointer, - PVOID pDetour) -{ - LONG error = NO_ERROR; - - if (s_nPendingThreadId != (LONG)GetCurrentThreadId()) { - return ERROR_INVALID_OPERATION; - } - - // If any of the pending operations failed, then we don't need to do this. - if (s_nPendingError != NO_ERROR) { - return s_nPendingError; - } - - if (ppPointer == NULL) { - return ERROR_INVALID_HANDLE; - } - if (*ppPointer == NULL) { - error = ERROR_INVALID_HANDLE; - s_nPendingError = error; - s_ppPendingError = ppPointer; - DETOUR_BREAK(); - return error; - } - - DetourOperation *o = new DetourOperation; - if (o == NULL) { - error = ERROR_NOT_ENOUGH_MEMORY; - fail: - s_nPendingError = error; - DETOUR_BREAK(); - stop: - if (o != NULL) { - delete o; - o = NULL; - } - s_ppPendingError = ppPointer; - return error; - } - - -#ifdef DETOURS_IA64 -#error Feature not supported in this release. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#else // !DETOURS_IA64 - PDETOUR_TRAMPOLINE pTrampoline = - (PDETOUR_TRAMPOLINE)DetourCodeFromPointer(*ppPointer, NULL); - pDetour = DetourCodeFromPointer(pDetour, NULL); -#endif // !DETOURS_IA64 - - ////////////////////////////////////// Verify that Trampoline is in place. - // - LONG cbTarget = pTrampoline->cbRestore; - PBYTE pbTarget = pTrampoline->pbRemain - cbTarget; - if (cbTarget == 0 || cbTarget > sizeof(pTrampoline->rbCode)) { - error = ERROR_INVALID_BLOCK; - if (s_fIgnoreTooSmall) { - goto stop; - } - else { - DETOUR_BREAK(); - goto fail; - } - } - - if (pTrampoline->pbDetour != pDetour) { - error = ERROR_INVALID_BLOCK; - if (s_fIgnoreTooSmall) { - goto stop; - } - else { - DETOUR_BREAK(); - goto fail; - } - } - - DWORD dwOld = 0; - if (!VirtualProtect(pbTarget, cbTarget, - PAGE_EXECUTE_READWRITE, &dwOld)) { - error = GetLastError(); - DETOUR_BREAK(); - goto fail; - } - - o->fIsRemove = TRUE; - o->ppbPointer = (PBYTE*)ppPointer; - o->pTrampoline = pTrampoline; - o->pbTarget = pbTarget; - o->dwPerm = dwOld; - o->pNext = s_pPendingOperations; - s_pPendingOperations = o; - - return NO_ERROR; -} - -// End of File diff --git a/Detours/detours.h b/Detours/detours.h deleted file mode 100644 index b7c7bde..0000000 --- a/Detours/detours.h +++ /dev/null @@ -1,629 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Core Detours Functionality (detours.h of detours.lib) -// -// Microsoft Research Detours Package, Version 3.0 Build_316. -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// - -#pragma once -#ifndef _DETOURS_H_ -#define _DETOURS_H_ - -#define DETOURS_X86 -#define DETOURS_32BIT - -#define DETOURS_VERSION 30000 // 3.00.00 - -////////////////////////////////////////////////////////////////////////////// -// - -#if (_MSC_VER < 1299) -typedef LONG LONG_PTR; -typedef ULONG ULONG_PTR; -#endif - -#ifndef __in_z -#define __in_z -#endif - -////////////////////////////////////////////////////////////////////////////// -// -#ifndef GUID_DEFINED -#define GUID_DEFINED -typedef struct _GUID -{ - DWORD Data1; - WORD Data2; - WORD Data3; - BYTE Data4[8]; -} GUID; - -#ifdef INITGUID -#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - const GUID name \ - = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } -#else -#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - const GUID name -#endif // INITGUID -#endif // !GUID_DEFINED - -#if defined(__cplusplus) -#ifndef _REFGUID_DEFINED -#define _REFGUID_DEFINED -#define REFGUID const GUID & -#endif // !_REFGUID_DEFINED -#else // !__cplusplus -#ifndef _REFGUID_DEFINED -#define _REFGUID_DEFINED -#define REFGUID const GUID * const -#endif // !_REFGUID_DEFINED -#endif // !__cplusplus - -// -////////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - - /////////////////////////////////////////////////// Instruction Target Macros. - // -#define DETOUR_INSTRUCTION_TARGET_NONE ((PVOID)0) -#define DETOUR_INSTRUCTION_TARGET_DYNAMIC ((PVOID)(LONG_PTR)-1) -#define DETOUR_SECTION_HEADER_SIGNATURE 0x00727444 // "Dtr\0" - - extern const GUID DETOUR_EXE_RESTORE_GUID; - extern const GUID DETOUR_EXE_HELPER_GUID; - -#define DETOUR_TRAMPOLINE_SIGNATURE 0x21727444 // Dtr! - typedef struct _DETOUR_TRAMPOLINE DETOUR_TRAMPOLINE, *PDETOUR_TRAMPOLINE; - - /////////////////////////////////////////////////////////// Binary Structures. - // -#pragma pack(push, 8) - typedef struct _DETOUR_SECTION_HEADER - { - DWORD cbHeaderSize; - DWORD nSignature; - DWORD nDataOffset; - DWORD cbDataSize; - - DWORD nOriginalImportVirtualAddress; - DWORD nOriginalImportSize; - DWORD nOriginalBoundImportVirtualAddress; - DWORD nOriginalBoundImportSize; - - DWORD nOriginalIatVirtualAddress; - DWORD nOriginalIatSize; - DWORD nOriginalSizeOfImage; - DWORD cbPrePE; - - DWORD nOriginalClrFlags; - DWORD reserved1; - DWORD reserved2; - DWORD reserved3; - - // Followed by cbPrePE bytes of data. - } DETOUR_SECTION_HEADER, *PDETOUR_SECTION_HEADER; - - typedef struct _DETOUR_SECTION_RECORD - { - DWORD cbBytes; - DWORD nReserved; - GUID guid; - } DETOUR_SECTION_RECORD, *PDETOUR_SECTION_RECORD; - - typedef struct _DETOUR_CLR_HEADER - { - // Header versioning - ULONG cb; - USHORT MajorRuntimeVersion; - USHORT MinorRuntimeVersion; - - // Symbol table and startup information - IMAGE_DATA_DIRECTORY MetaData; - ULONG Flags; - - // Followed by the rest of the IMAGE_COR20_HEADER - } DETOUR_CLR_HEADER, *PDETOUR_CLR_HEADER; - - typedef struct _DETOUR_EXE_RESTORE - { - DWORD cb; - DWORD cbidh; - DWORD cbinh; - DWORD cbclr; - - PBYTE pidh; - PBYTE pinh; - PBYTE pclr; - - IMAGE_DOS_HEADER idh; - union { - IMAGE_NT_HEADERS inh; - IMAGE_NT_HEADERS32 inh32; - IMAGE_NT_HEADERS64 inh64; - BYTE raw[sizeof(IMAGE_NT_HEADERS64) + - sizeof(IMAGE_SECTION_HEADER) * 32]; - }; - DETOUR_CLR_HEADER clr; - - } DETOUR_EXE_RESTORE, *PDETOUR_EXE_RESTORE; - - typedef struct _DETOUR_EXE_HELPER - { - DWORD cb; - DWORD pid; - CHAR DllName[MAX_PATH]; - - } DETOUR_EXE_HELPER, *PDETOUR_EXE_HELPER; - -#pragma pack(pop) - -#define DETOUR_SECTION_HEADER_DECLARE(cbSectionSize) \ -{ \ - sizeof(DETOUR_SECTION_HEADER),\ - DETOUR_SECTION_HEADER_SIGNATURE,\ - sizeof(DETOUR_SECTION_HEADER),\ - (cbSectionSize),\ - \ - 0,\ - 0,\ - 0,\ - 0,\ - \ - 0,\ - 0,\ - 0,\ - 0,\ -} - - /////////////////////////////////////////////////////////////// Helper Macros. - // -#define DETOURS_STRINGIFY(x) DETOURS_STRINGIFY_(x) -#define DETOURS_STRINGIFY_(x) #x - -///////////////////////////////////////////////////////////// Binary Typedefs. -// - typedef BOOL(CALLBACK *PF_DETOUR_BINARY_BYWAY_CALLBACK)(PVOID pContext, - PCHAR pszFile, - PCHAR *ppszOutFile); - - typedef BOOL(CALLBACK *PF_DETOUR_BINARY_FILE_CALLBACK)(PVOID pContext, - PCHAR pszOrigFile, - PCHAR pszFile, - PCHAR *ppszOutFile); - - typedef BOOL(CALLBACK *PF_DETOUR_BINARY_SYMBOL_CALLBACK)(PVOID pContext, - ULONG nOrigOrdinal, - ULONG nOrdinal, - ULONG *pnOutOrdinal, - PCHAR pszOrigSymbol, - PCHAR pszSymbol, - PCHAR *ppszOutSymbol); - - typedef BOOL(CALLBACK *PF_DETOUR_BINARY_COMMIT_CALLBACK)(PVOID pContext); - - typedef BOOL(CALLBACK *PF_DETOUR_ENUMERATE_EXPORT_CALLBACK)(PVOID pContext, - ULONG nOrdinal, - PCHAR pszName, - PVOID pCode); - - typedef BOOL(CALLBACK *PF_DETOUR_IMPORT_FILE_CALLBACK)(PVOID pContext, - HMODULE hModule, - PCSTR pszFile); - - typedef BOOL(CALLBACK *PF_DETOUR_IMPORT_FUNC_CALLBACK)(PVOID pContext, - DWORD nOrdinal, - PCSTR pszFunc, - PVOID pvFunc); - - typedef VOID * PDETOUR_BINARY; - typedef VOID * PDETOUR_LOADED_BINARY; - - //////////////////////////////////////////////////////////// Transaction APIs. - // - LONG WINAPI DetourTransactionBegin(VOID); - LONG WINAPI DetourTransactionAbort(VOID); - LONG WINAPI DetourTransactionCommit(VOID); - LONG WINAPI DetourTransactionCommitEx(PVOID **pppFailedPointer); - - LONG WINAPI DetourUpdateThread(HANDLE hThread); - - LONG WINAPI DetourAttach(PVOID *ppPointer, - PVOID pDetour); - - LONG WINAPI DetourAttachEx(PVOID *ppPointer, - PVOID pDetour, - PDETOUR_TRAMPOLINE *ppRealTrampoline, - PVOID *ppRealTarget, - PVOID *ppRealDetour); - - LONG WINAPI DetourDetach(PVOID *ppPointer, - PVOID pDetour); - - BOOL WINAPI DetourSetIgnoreTooSmall(BOOL fIgnore); - BOOL WINAPI DetourSetRetainRegions(BOOL fRetain); - - ////////////////////////////////////////////////////////////// Code Functions. - // - PVOID WINAPI DetourFindFunction(PCSTR pszModule, PCSTR pszFunction); - PVOID WINAPI DetourCodeFromPointer(PVOID pPointer, PVOID *ppGlobals); - PVOID WINAPI DetourCopyInstruction(PVOID pDst, - PVOID *pDstPool, - PVOID pSrc, - PVOID *ppTarget, - LONG *plExtra); - - ///////////////////////////////////////////////////// Loaded Binary Functions. - // - HMODULE WINAPI DetourGetContainingModule(PVOID pvAddr); - HMODULE WINAPI DetourEnumerateModules(HMODULE hModuleLast); - PVOID WINAPI DetourGetEntryPoint(HMODULE hModule); - ULONG WINAPI DetourGetModuleSize(HMODULE hModule); - BOOL WINAPI DetourEnumerateExports(HMODULE hModule, - PVOID pContext, - PF_DETOUR_ENUMERATE_EXPORT_CALLBACK pfExport); - BOOL WINAPI DetourEnumerateImports(HMODULE hModule, - PVOID pContext, - PF_DETOUR_IMPORT_FILE_CALLBACK pfImportFile, - PF_DETOUR_IMPORT_FUNC_CALLBACK pfImportFunc); - - PVOID WINAPI DetourFindPayload(HMODULE hModule, REFGUID rguid, DWORD *pcbData); - PVOID WINAPI DetourFindPayloadEx(REFGUID rguid, DWORD * pcbData); - DWORD WINAPI DetourGetSizeOfPayloads(HMODULE hModule); - - ///////////////////////////////////////////////// Persistent Binary Functions. - // - - PDETOUR_BINARY WINAPI DetourBinaryOpen(HANDLE hFile); - PVOID WINAPI DetourBinaryEnumeratePayloads(PDETOUR_BINARY pBinary, - GUID *pGuid, - DWORD *pcbData, - DWORD *pnIterator); - PVOID WINAPI DetourBinaryFindPayload(PDETOUR_BINARY pBinary, - REFGUID rguid, - DWORD *pcbData); - PVOID WINAPI DetourBinarySetPayload(PDETOUR_BINARY pBinary, - REFGUID rguid, - PVOID pData, - DWORD cbData); - BOOL WINAPI DetourBinaryDeletePayload(PDETOUR_BINARY pBinary, REFGUID rguid); - BOOL WINAPI DetourBinaryPurgePayloads(PDETOUR_BINARY pBinary); - BOOL WINAPI DetourBinaryResetImports(PDETOUR_BINARY pBinary); - BOOL WINAPI DetourBinaryEditImports(PDETOUR_BINARY pBinary, - PVOID pContext, - PF_DETOUR_BINARY_BYWAY_CALLBACK pfByway, - PF_DETOUR_BINARY_FILE_CALLBACK pfFile, - PF_DETOUR_BINARY_SYMBOL_CALLBACK pfSymbol, - PF_DETOUR_BINARY_COMMIT_CALLBACK pfCommit); - BOOL WINAPI DetourBinaryWrite(PDETOUR_BINARY pBinary, HANDLE hFile); - BOOL WINAPI DetourBinaryClose(PDETOUR_BINARY pBinary); - - /////////////////////////////////////////////////// Create Process & Load Dll. - // - typedef BOOL(WINAPI *PDETOUR_CREATE_PROCESS_ROUTINEA) - (LPCSTR lpApplicationName, - LPSTR lpCommandLine, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, - DWORD dwCreationFlags, - LPVOID lpEnvironment, - LPCSTR lpCurrentDirectory, - LPSTARTUPINFOA lpStartupInfo, - LPPROCESS_INFORMATION lpProcessInformation); - - typedef BOOL(WINAPI *PDETOUR_CREATE_PROCESS_ROUTINEW) - (LPCWSTR lpApplicationName, - LPWSTR lpCommandLine, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, - DWORD dwCreationFlags, - LPVOID lpEnvironment, - LPCWSTR lpCurrentDirectory, - LPSTARTUPINFOW lpStartupInfo, - LPPROCESS_INFORMATION lpProcessInformation); - - BOOL WINAPI DetourCreateProcessWithDllA(LPCSTR lpApplicationName, - __in_z LPSTR lpCommandLine, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, - DWORD dwCreationFlags, - LPVOID lpEnvironment, - LPCSTR lpCurrentDirectory, - LPSTARTUPINFOA lpStartupInfo, - LPPROCESS_INFORMATION lpProcessInformation, - LPCSTR lpDllName, - PDETOUR_CREATE_PROCESS_ROUTINEA - pfCreateProcessA); - - BOOL WINAPI DetourCreateProcessWithDllW(LPCWSTR lpApplicationName, - __in_z LPWSTR lpCommandLine, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, - DWORD dwCreationFlags, - LPVOID lpEnvironment, - LPCWSTR lpCurrentDirectory, - LPSTARTUPINFOW lpStartupInfo, - LPPROCESS_INFORMATION lpProcessInformation, - LPCSTR lpDllName, - PDETOUR_CREATE_PROCESS_ROUTINEW - pfCreateProcessW); - -#ifdef UNICODE -#define DetourCreateProcessWithDll DetourCreateProcessWithDllW -#define PDETOUR_CREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINEW -#else -#define DetourCreateProcessWithDll DetourCreateProcessWithDllA -#define PDETOUR_CREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINEA -#endif // !UNICODE - - BOOL WINAPI DetourCreateProcessWithDllExA(LPCSTR lpApplicationName, - __in_z LPSTR lpCommandLine, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, - DWORD dwCreationFlags, - LPVOID lpEnvironment, - LPCSTR lpCurrentDirectory, - LPSTARTUPINFOA lpStartupInfo, - LPPROCESS_INFORMATION lpProcessInformation, - LPCSTR lpDllName, - PDETOUR_CREATE_PROCESS_ROUTINEA - pfCreateProcessA); - - BOOL WINAPI DetourCreateProcessWithDllExW(LPCWSTR lpApplicationName, - __in_z LPWSTR lpCommandLine, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, - DWORD dwCreationFlags, - LPVOID lpEnvironment, - LPCWSTR lpCurrentDirectory, - LPSTARTUPINFOW lpStartupInfo, - LPPROCESS_INFORMATION lpProcessInformation, - LPCSTR lpDllName, - PDETOUR_CREATE_PROCESS_ROUTINEW - pfCreateProcessW); - -#ifdef UNICODE -#define DetourCreateProcessWithDllEx DetourCreateProcessWithDllExW -#define PDETOUR_CREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINEW -#else -#define DetourCreateProcessWithDllEx DetourCreateProcessWithDllExA -#define PDETOUR_CREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINEA -#endif // !UNICODE - - BOOL WINAPI DetourProcessViaHelperA(DWORD dwTargetPid, - LPCSTR lpDllName, - PDETOUR_CREATE_PROCESS_ROUTINEA pfCreateProcessA); - - BOOL WINAPI DetourProcessViaHelperW(DWORD dwTargetPid, - LPCSTR lpDllName, - PDETOUR_CREATE_PROCESS_ROUTINEW pfCreateProcessW); - -#ifdef UNICODE -#define DetourProcessViaHelper DetourProcessViaHelperW -#else -#define DetourProcessViaHelper DetourProcessViaHelperA -#endif // !UNICODE - - BOOL WINAPI DetourUpdateProcessWithDll(HANDLE hProcess, - LPCSTR *plpDlls, - DWORD nDlls); - - BOOL WINAPI DetourCopyPayloadToProcess(HANDLE hProcess, - REFGUID rguid, - PVOID pvData, - DWORD cbData); - BOOL WINAPI DetourRestoreAfterWith(VOID); - BOOL WINAPI DetourRestoreAfterWithEx(PVOID pvData, DWORD cbData); - BOOL WINAPI DetourIsHelperProcess(VOID); - VOID CALLBACK DetourFinishHelperProcess(HWND, HINSTANCE, LPSTR, INT); - - // - ////////////////////////////////////////////////////////////////////////////// -#ifdef __cplusplus -} -#endif // __cplusplus - -//////////////////////////////////////////////// Detours Internal Definitions. -// -#ifdef __cplusplus -#ifdef DETOURS_INTERNAL - -#ifndef __deref_out -#define __deref_out -#endif - -#ifndef __deref -#define __deref -#endif - -////////////////////////////////////////////////////////////////////////////// -// -#if (_MSC_VER < 1299) -#include -typedef IMAGEHLP_MODULE IMAGEHLP_MODULE64; -typedef PIMAGEHLP_MODULE PIMAGEHLP_MODULE64; -typedef IMAGEHLP_SYMBOL SYMBOL_INFO; -typedef PIMAGEHLP_SYMBOL PSYMBOL_INFO; - -static inline -LONG InterlockedCompareExchange(LONG *ptr, LONG nval, LONG oval) -{ - return (LONG)::InterlockedCompareExchange((PVOID*)ptr, (PVOID)nval, (PVOID)oval); -} -#else -#include -#endif - -#ifdef IMAGEAPI // defined by DBGHELP.H -typedef LPAPI_VERSION(NTAPI *PF_ImagehlpApiVersionEx)(LPAPI_VERSION AppVersion); - -typedef BOOL(NTAPI *PF_SymInitialize)(IN HANDLE hProcess, - IN LPCSTR UserSearchPath, - IN BOOL fInvadeProcess); -typedef DWORD(NTAPI *PF_SymSetOptions)(IN DWORD SymOptions); -typedef DWORD(NTAPI *PF_SymGetOptions)(VOID); -typedef DWORD64(NTAPI *PF_SymLoadModule64)(IN HANDLE hProcess, - IN HANDLE hFile, - IN PSTR ImageName, - IN PSTR ModuleName, - IN DWORD64 BaseOfDll, - IN DWORD SizeOfDll); -typedef BOOL(NTAPI *PF_SymGetModuleInfo64)(IN HANDLE hProcess, - IN DWORD64 qwAddr, - OUT PIMAGEHLP_MODULE64 ModuleInfo); -typedef BOOL(NTAPI *PF_SymFromName)(IN HANDLE hProcess, - IN LPSTR Name, - OUT PSYMBOL_INFO Symbol); - -typedef struct _DETOUR_SYM_INFO -{ - HANDLE hProcess; - HMODULE hDbgHelp; - PF_ImagehlpApiVersionEx pfImagehlpApiVersionEx; - PF_SymInitialize pfSymInitialize; - PF_SymSetOptions pfSymSetOptions; - PF_SymGetOptions pfSymGetOptions; - PF_SymLoadModule64 pfSymLoadModule64; - PF_SymGetModuleInfo64 pfSymGetModuleInfo64; - PF_SymFromName pfSymFromName; -} DETOUR_SYM_INFO, *PDETOUR_SYM_INFO; - -PDETOUR_SYM_INFO DetourLoadDbgHelp(VOID); - -#endif // IMAGEAPI - -#ifndef DETOUR_TRACE -#if DETOUR_DEBUG -#define DETOUR_TRACE(x) printf x -#define DETOUR_BREAK() __debugbreak() -#include -#include -#else -#define DETOUR_TRACE(x) -#define DETOUR_BREAK() -#endif -#endif - -#ifdef DETOURS_IA64 -#error Feature not supported in this release. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#endif // DETOURS_IA64 - -#ifdef DETOURS_ARM -#error Feature not supported in this release. - - - -#endif // DETOURS_ARM - -////////////////////////////////////////////////////////////////////////////// - -#endif // DETOURS_INTERNAL -#endif // __cplusplus - -#endif // _DETOURS_H_ -// -//////////////////////////////////////////////////////////////// End of File. diff --git a/Detours/detver.h b/Detours/detver.h deleted file mode 100644 index bf4a52d..0000000 --- a/Detours/detver.h +++ /dev/null @@ -1,21 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Common version parameters. -// -// Microsoft Research Detours Package, Version 3.0 Build_316. -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// - -#ifndef DETOURS_STRINGIFY -#define DETOURS_STRINGIFY(x) DETOURS_STRINGIFY_(x) -#define DETOURS_STRINGIFY_(x) #x -#endif - -#define VER_FILEFLAGSMASK 0x3fL -#define VER_FILEFLAGS 0x0L -#define VER_FILEOS 0x00040004L -#define VER_FILETYPE 0x00000002L -#define VER_FILESUBTYPE 0x00000000L - -#define VER_DETOURS_BITS DETOUR_STRINGIFY(DETOURS_BITS) diff --git a/Detours/disasm.cpp b/Detours/disasm.cpp deleted file mode 100644 index f3db9fa..0000000 --- a/Detours/disasm.cpp +++ /dev/null @@ -1,2902 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Detours Disassembler (disasm.cpp of detours.lib) -// -// Microsoft Research Detours Package, Version 3.0 Build_316. -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// - -#include -#include - -// #define DETOUR_DEBUG 1 -#define DETOURS_INTERNAL - -#include "detours.h" - -#if defined(DETOURS_X86) -#elif defined(DETOURS_X64) -#elif defined(DETOURS_IA64) -#elif defined(DETOURS_ARM) -#else -#error Must define one of DETOURS_X86, DETOURS_X64, DETOURS_IA64, or DETOURS_ARM -#endif - -#undef ASSERT -#define ASSERT(x) - -////////////////////////////////////////////////////////////////////////////// -// -// Function: -// DetourCopyInstruction(PVOID pDst, -// PVOID *ppDstPool -// PVOID pSrc, -// PVOID *ppTarget, -// LONG *plExtra) -// Purpose: -// Copy a single instruction from pSrc to pDst. -// -// Arguments: -// pDst: -// Destination address for the instruction. May be NULL in which -// case DetourCopyInstruction is used to measure an instruction. -// If not NULL then the source instruction is copied to the -// destination instruction and any relative arguments are adjusted. -// ppDstPool: -// Destination address for the end of the constant pool. The -// constant pool works backwards toward pDst. All memory between -// pDst and *ppDstPool must be available for use by this function. -// ppDstPool may be NULL if pDst is NULL. -// pSrc: -// Source address of the instruction. -// ppTarget: -// Out parameter for any target instruction address pointed to by -// the instruction. For example, a branch or a jump insruction has -// a target, but a load or store instruction doesn't. A target is -// another instruction that may be executed as a result of this -// instruction. ppTarget may be NULL. -// plExtra: -// Out parameter for the number of extra bytes needed by the -// instruction to reach the target. For example, lExtra = 3 if the -// instruction had an 8-bit relative offset, but needs a 32-bit -// relative offset. -// -// Returns: -// Returns the address of the next instruction (following in the source) -// instruction. By subtracting pSrc from the return value, the caller -// can determinte the size of the instruction copied. -// -// Comments: -// By following the pTarget, the caller can follow alternate -// instruction streams. However, it is not always possible to determine -// the target based on static analysis. For example, the destination of -// a jump relative to a register cannot be determined from just the -// instruction stream. The output value, pTarget, can have any of the -// following outputs: -// DETOUR_INSTRUCTION_TARGET_NONE: -// The instruction has no targets. -// DETOUR_INSTRUCTION_TARGET_DYNAMIC: -// The instruction has a non-deterministic (dynamic) target. -// (i.e. the jump is to an address held in a register.) -// Address: The instruction has the specified target. -// -// When copying instructions, DetourCopyInstruction insures that any -// targets remain constant. It does so by adjusting any IP relative -// offsets. -// - -//////////////////////////////////////////////////// X86 and X64 Disassembler. -// -// Includes full support for all x86 chips prior to the Pentium III. -// -#if defined(DETOURS_X64) || defined(DETOURS_X86) - -class CDetourDis -{ -public: - CDetourDis(PBYTE *ppbTarget, LONG *plExtra); - - PBYTE CopyInstruction(PBYTE pbDst, PBYTE pbSrc); - static BOOL SanityCheckSystem(); - -public: - struct COPYENTRY; - typedef const COPYENTRY * REFCOPYENTRY; - - typedef PBYTE(CDetourDis::* COPYFUNC)(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc); - - enum { - DYNAMIC = 0x1u, - ADDRESS = 0x2u, - NOENLARGE = 0x4u, - RAX = 0x8u, - - SIB = 0x10u, - RIP = 0x20u, - NOTSIB = 0x0fu, - }; - struct COPYENTRY - { - ULONG nOpcode : 8; // Opcode - ULONG nFixedSize : 4; // Fixed size of opcode - ULONG nFixedSize16 : 4; // Fixed size when 16 bit operand - ULONG nModOffset : 4; // Offset to mod/rm byte (0=none) - LONG nRelOffset : 4; // Offset to relative target. - LONG nTargetBack : 4; // Offset back to absolute or rip target - ULONG nFlagBits : 4; // Flags for DYNAMIC, etc. - COPYFUNC pfCopy; // Function pointer. - }; - -protected: - // These macros define common uses of nFixedSize..pfCopy. -#define ENTRY_CopyBytes1 1, 1, 0, 0, 0, 0, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes1Dynamic 1, 1, 0, 0, 0, DYNAMIC, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes2 2, 2, 0, 0, 0, 0, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes2Jump 2, 2, 0, 1, 0, 0, &CDetourDis::CopyBytesJump -#define ENTRY_CopyBytes2CantJump 2, 2, 0, 1, 0, NOENLARGE, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes2Dynamic 2, 2, 0, 0, 0, DYNAMIC, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes3 3, 3, 0, 0, 0, 0, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes3Dynamic 3, 3, 0, 0, 0, DYNAMIC, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes3Or5 5, 3, 0, 0, 0, 0, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes3Or5Rax 5, 3, 0, 0, 0, RAX, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes3Or5Target 5, 3, 0, 1, 0, 0, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes5Or7Dynamic 7, 5, 0, 0, 0, DYNAMIC, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes3Or5Address 5, 3, 0, 0, 0, ADDRESS, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes4 4, 4, 0, 0, 0, 0, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes5 5, 5, 0, 0, 0, 0, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes7 7, 7, 0, 0, 0, 0, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes2Mod 2, 2, 1, 0, 0, 0, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes2Mod1 3, 3, 1, 0, 1, 0, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes2ModOperand 6, 4, 1, 0, 4, 0, &CDetourDis::CopyBytes -#define ENTRY_CopyBytes3Mod 3, 3, 2, 0, 0, 0, &CDetourDis::CopyBytes -#define ENTRY_CopyBytesPrefix 1, 1, 0, 0, 0, 0, &CDetourDis::CopyBytesPrefix -#define ENTRY_CopyBytesRax 1, 1, 0, 0, 0, 0, &CDetourDis::CopyBytesRax -#define ENTRY_Copy0F 1, 1, 0, 0, 0, 0, &CDetourDis::Copy0F -#define ENTRY_Copy66 1, 1, 0, 0, 0, 0, &CDetourDis::Copy66 -#define ENTRY_Copy67 1, 1, 0, 0, 0, 0, &CDetourDis::Copy67 -#define ENTRY_CopyF6 0, 0, 0, 0, 0, 0, &CDetourDis::CopyF6 -#define ENTRY_CopyF7 0, 0, 0, 0, 0, 0, &CDetourDis::CopyF7 -#define ENTRY_CopyFF 0, 0, 0, 0, 0, 0, &CDetourDis::CopyFF -#define ENTRY_Invalid 1, 1, 0, 0, 0, 0, &CDetourDis::Invalid -#define ENTRY_End 0, 0, 0, 0, 0, 0, NULL - - PBYTE CopyBytes(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc); - PBYTE CopyBytesPrefix(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc); - PBYTE CopyBytesRax(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc); - PBYTE CopyBytesJump(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc); - - PBYTE Invalid(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc); - - PBYTE AdjustTarget(PBYTE pbDst, PBYTE pbSrc, LONG cbOp, - LONG cbTargetOffset, LONG cbTargetSize); - -protected: - PBYTE Copy0F(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc); - PBYTE Copy66(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc); - PBYTE Copy67(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc); - PBYTE CopyF6(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc); - PBYTE CopyF7(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc); - PBYTE CopyFF(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc); - -protected: - static const COPYENTRY s_rceCopyTable[257]; - static const COPYENTRY s_rceCopyTable0F[257]; - static const BYTE s_rbModRm[256]; - -protected: - BOOL m_bOperandOverride; - BOOL m_bAddressOverride; - BOOL m_bRaxOverride; - - PBYTE * m_ppbTarget; - LONG * m_plExtra; - - LONG m_lScratchExtra; - PBYTE m_pbScratchTarget; - BYTE m_rbScratchDst[64]; -}; - -PVOID WINAPI DetourCopyInstruction(PVOID pDst, - PVOID *ppDstPool, - PVOID pSrc, - PVOID *ppTarget, - LONG *plExtra) -{ - (void)ppDstPool; // x86 & x64 don't use a constant pool. - CDetourDis oDetourDisasm((PBYTE*)ppTarget, plExtra); - return oDetourDisasm.CopyInstruction((PBYTE)pDst, (PBYTE)pSrc); -} - -/////////////////////////////////////////////////////////// Disassembler Code. -// -CDetourDis::CDetourDis(PBYTE *ppbTarget, LONG *plExtra) -{ - m_bOperandOverride = FALSE; - m_bAddressOverride = FALSE; - m_bRaxOverride = FALSE; - - m_ppbTarget = ppbTarget ? ppbTarget : &m_pbScratchTarget; - m_plExtra = plExtra ? plExtra : &m_lScratchExtra; - - *m_ppbTarget = (PBYTE)DETOUR_INSTRUCTION_TARGET_NONE; - *m_plExtra = 0; -} - -PBYTE CDetourDis::CopyInstruction(PBYTE pbDst, PBYTE pbSrc) -{ - // Configure scratch areas if real areas are not available. - if (NULL == pbDst) { - pbDst = m_rbScratchDst; - } - if (NULL == pbSrc) { - // We can't copy a non-existent instruction. - SetLastError(ERROR_INVALID_DATA); - return NULL; - } - - // Figure out how big the instruction is, do the appropriate copy, - // and figure out what the target of the instruction is if any. - // - REFCOPYENTRY pEntry = &s_rceCopyTable[pbSrc[0]]; - return (this->*pEntry->pfCopy)(pEntry, pbDst, pbSrc); -} - -PBYTE CDetourDis::CopyBytes(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc) -{ -#ifdef DETOURS_X64 -#error Feature not supported in this release. - - - - -#else - LONG nBytesFixed = (pEntry->nFlagBits & ADDRESS) - ? (m_bAddressOverride ? pEntry->nFixedSize16 : pEntry->nFixedSize) - : (m_bOperandOverride ? pEntry->nFixedSize16 : pEntry->nFixedSize); -#endif - - LONG nBytes = nBytesFixed; - LONG nRelOffset = pEntry->nRelOffset; - LONG cbTarget = nBytes - nRelOffset; - if (pEntry->nModOffset > 0) { - BYTE bModRm = pbSrc[pEntry->nModOffset]; - BYTE bFlags = s_rbModRm[bModRm]; - - nBytes += bFlags & NOTSIB; - - if (bFlags & SIB) { - BYTE bSib = pbSrc[pEntry->nModOffset + 1]; - - if ((bSib & 0x07) == 0x05) { - if ((bModRm & 0xc0) == 0x00) { - nBytes += 4; - } - else if ((bModRm & 0xc0) == 0x40) { - nBytes += 1; - } - else if ((bModRm & 0xc0) == 0x80) { - nBytes += 4; - } - } - cbTarget = nBytes - nRelOffset; - } - else if (bFlags & RIP) { -#ifdef DETOURS_X64 -#error Feature not supported in this release. - - -#endif - } - } - CopyMemory(pbDst, pbSrc, nBytes); - - if (nRelOffset) { - *m_ppbTarget = AdjustTarget(pbDst, pbSrc, nBytesFixed, nRelOffset, cbTarget); -#ifdef DETOURS_X64 -#error Feature not supported in this release. - - - -#endif - } - if (pEntry->nFlagBits & NOENLARGE) { - *m_plExtra = -*m_plExtra; - } - if (pEntry->nFlagBits & DYNAMIC) { - *m_ppbTarget = (PBYTE)DETOUR_INSTRUCTION_TARGET_DYNAMIC; - } - return pbSrc + nBytes; -} - -PBYTE CDetourDis::CopyBytesPrefix(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc) -{ - CopyBytes(pEntry, pbDst, pbSrc); - - pEntry = &s_rceCopyTable[pbSrc[1]]; - return (this->*pEntry->pfCopy)(pEntry, pbDst + 1, pbSrc + 1); -} - -PBYTE CDetourDis::CopyBytesRax(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc) -{ - CopyBytes(pEntry, pbDst, pbSrc); - - if (*pbSrc & 0x8) { - m_bRaxOverride = TRUE; - } - - pEntry = &s_rceCopyTable[pbSrc[1]]; - return (this->*pEntry->pfCopy)(pEntry, pbDst + 1, pbSrc + 1); -} - -PBYTE CDetourDis::CopyBytesJump(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc) -{ - (void)pEntry; - - PVOID pvSrcAddr = &pbSrc[1]; - PVOID pvDstAddr = NULL; - LONG_PTR nOldOffset = (LONG_PTR)*(CHAR*&)pvSrcAddr; - LONG_PTR nNewOffset = 0; - - *m_ppbTarget = pbSrc + 2 + nOldOffset; - - if (pbSrc[0] == 0xeb) { - pbDst[0] = 0xe9; - pvDstAddr = &pbDst[1]; - nNewOffset = nOldOffset - ((pbDst - pbSrc) + 3); - *(LONG*&)pvDstAddr = (LONG)nNewOffset; - - *m_plExtra = 3; - return pbSrc + 2; - } - - ASSERT(pbSrc[0] >= 0x70 && pbSrc[0] <= 0x7f); - - pbDst[0] = 0x0f; - pbDst[1] = 0x80 | (pbSrc[0] & 0xf); - pvDstAddr = &pbDst[2]; - nNewOffset = nOldOffset - ((pbDst - pbSrc) + 4); - *(LONG*&)pvDstAddr = (LONG)nNewOffset; - - *m_plExtra = 4; - return pbSrc + 2; -} - -PBYTE CDetourDis::AdjustTarget(PBYTE pbDst, PBYTE pbSrc, LONG cbOp, - LONG cbTargetOffset, LONG cbTargetSize) -{ - PBYTE pbTarget = NULL; - PVOID pvTargetAddr = &pbDst[cbTargetOffset]; - LONG_PTR nOldOffset = 0; - - switch (cbTargetSize) { - case 1: - nOldOffset = (LONG_PTR)*(CHAR*&)pvTargetAddr; - break; - case 2: - nOldOffset = (LONG_PTR)*(SHORT*&)pvTargetAddr; - break; - case 4: - nOldOffset = (LONG_PTR)*(LONG*&)pvTargetAddr; - break; - case 8: - nOldOffset = (LONG_PTR)*(LONG_PTR*&)pvTargetAddr; - break; - default: - ASSERT(!"cbTargetSize is invalid."); - break; - } - - pbTarget = pbSrc + cbOp + nOldOffset; - LONG_PTR nNewOffset = nOldOffset - (pbDst - pbSrc); - - switch (cbTargetSize) { - case 1: - *(CHAR*&)pvTargetAddr = (CHAR)nNewOffset; - if (nNewOffset < SCHAR_MIN || nNewOffset > SCHAR_MAX) { - *m_plExtra = sizeof(ULONG) - 1; - } - break; - case 2: - *(SHORT*&)pvTargetAddr = (SHORT)nNewOffset; - if (nNewOffset < SHRT_MIN || nNewOffset > SHRT_MAX) { - *m_plExtra = sizeof(ULONG) - 2; - } - break; - case 4: - *(LONG*&)pvTargetAddr = (LONG)nNewOffset; - if (nNewOffset < LONG_MIN || nNewOffset > LONG_MAX) { - *m_plExtra = sizeof(ULONG) - 4; - } - break; - case 8: - *(LONG_PTR*&)pvTargetAddr = (LONG_PTR)nNewOffset; - break; - } - ASSERT(pbDst + cbOp + nNewOffset == pbTarget); - return pbTarget; -} - -PBYTE CDetourDis::Invalid(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc) -{ - (void)pbDst; - (void)pEntry; - ASSERT(!"Invalid Instruction"); - return pbSrc + 1; -} - -////////////////////////////////////////////////////// Individual Bytes Codes. -// -PBYTE CDetourDis::Copy0F(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc) -{ - CopyBytes(pEntry, pbDst, pbSrc); - - pEntry = &s_rceCopyTable0F[pbSrc[1]]; - return (this->*pEntry->pfCopy)(pEntry, pbDst + 1, pbSrc + 1); -} - -PBYTE CDetourDis::Copy66(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc) -{ // Operand-size override prefix - m_bOperandOverride = TRUE; - return CopyBytesPrefix(pEntry, pbDst, pbSrc); -} - -PBYTE CDetourDis::Copy67(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc) -{ // Address size override prefix - m_bAddressOverride = TRUE; - return CopyBytesPrefix(pEntry, pbDst, pbSrc); -} - -PBYTE CDetourDis::CopyF6(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc) -{ - (void)pEntry; - - // TEST BYTE /0 - if (0x00 == (0x38 & pbSrc[1])) { // reg(bits 543) of ModR/M == 0 - const COPYENTRY ce = { 0xf6, ENTRY_CopyBytes2Mod1 }; - return (this->*ce.pfCopy)(&ce, pbDst, pbSrc); - } - // DIV /6 - // IDIV /7 - // IMUL /5 - // MUL /4 - // NEG /3 - // NOT /2 - - const COPYENTRY ce = { 0xf6, ENTRY_CopyBytes2Mod }; - return (this->*ce.pfCopy)(&ce, pbDst, pbSrc); -} - -PBYTE CDetourDis::CopyF7(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc) -{ - (void)pEntry; - - // TEST WORD /0 - if (0x00 == (0x38 & pbSrc[1])) { // reg(bits 543) of ModR/M == 0 - const COPYENTRY ce = { 0xf7, ENTRY_CopyBytes2ModOperand }; - return (this->*ce.pfCopy)(&ce, pbDst, pbSrc); - } - - // DIV /6 - // IDIV /7 - // IMUL /5 - // MUL /4 - // NEG /3 - // NOT /2 - const COPYENTRY ce = { 0xf7, ENTRY_CopyBytes2Mod }; - return (this->*ce.pfCopy)(&ce, pbDst, pbSrc); -} - -PBYTE CDetourDis::CopyFF(REFCOPYENTRY pEntry, PBYTE pbDst, PBYTE pbSrc) -{ // CALL /2 - // CALL /3 - // INC /0 - // JMP /4 - // JMP /5 - // PUSH /6 - (void)pEntry; - - if (0x15 == pbSrc[1] || 0x25 == pbSrc[1]) { // CALL [], JMP [] -#ifdef DETOURS_X64 -#error Feature not supported in this release. - - -#else - PBYTE *ppbTarget = *(PBYTE**)&pbSrc[2]; - *m_ppbTarget = *ppbTarget; -#endif - } - else if (0x10 == (0x38 & pbSrc[1]) || // CALL /2 --> reg(bits 543) of ModR/M == 010 - 0x18 == (0x38 & pbSrc[1]) || // CALL /3 --> reg(bits 543) of ModR/M == 011 - 0x20 == (0x38 & pbSrc[1]) || // JMP /4 --> reg(bits 543) of ModR/M == 100 - 0x28 == (0x38 & pbSrc[1]) // JMP /5 --> reg(bits 543) of ModR/M == 101 - ) { - *m_ppbTarget = (PBYTE)DETOUR_INSTRUCTION_TARGET_DYNAMIC; - } - const COPYENTRY ce = { 0xff, ENTRY_CopyBytes2Mod }; - return (this->*ce.pfCopy)(&ce, pbDst, pbSrc); -} - -///////////////////////////////////////////////////////// Disassembler Tables. -// -const BYTE CDetourDis::s_rbModRm[256] = { - 0,0,0,0, SIB | 1,RIP | 4,0,0, 0,0,0,0, SIB | 1,RIP | 4,0,0, // 0x - 0,0,0,0, SIB | 1,RIP | 4,0,0, 0,0,0,0, SIB | 1,RIP | 4,0,0, // 1x - 0,0,0,0, SIB | 1,RIP | 4,0,0, 0,0,0,0, SIB | 1,RIP | 4,0,0, // 2x - 0,0,0,0, SIB | 1,RIP | 4,0,0, 0,0,0,0, SIB | 1,RIP | 4,0,0, // 3x - 1,1,1,1, 2,1,1,1, 1,1,1,1, 2,1,1,1, // 4x - 1,1,1,1, 2,1,1,1, 1,1,1,1, 2,1,1,1, // 5x - 1,1,1,1, 2,1,1,1, 1,1,1,1, 2,1,1,1, // 6x - 1,1,1,1, 2,1,1,1, 1,1,1,1, 2,1,1,1, // 7x - 4,4,4,4, 5,4,4,4, 4,4,4,4, 5,4,4,4, // 8x - 4,4,4,4, 5,4,4,4, 4,4,4,4, 5,4,4,4, // 9x - 4,4,4,4, 5,4,4,4, 4,4,4,4, 5,4,4,4, // Ax - 4,4,4,4, 5,4,4,4, 4,4,4,4, 5,4,4,4, // Bx - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // Cx - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // Dx - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // Ex - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 // Fx -}; - -const CDetourDis::COPYENTRY CDetourDis::s_rceCopyTable[257] = -{ - { 0x00, ENTRY_CopyBytes2Mod }, // ADD /r - { 0x01, ENTRY_CopyBytes2Mod }, // ADD /r - { 0x02, ENTRY_CopyBytes2Mod }, // ADD /r - { 0x03, ENTRY_CopyBytes2Mod }, // ADD /r - { 0x04, ENTRY_CopyBytes2 }, // ADD ib - { 0x05, ENTRY_CopyBytes3Or5 }, // ADD iw - { 0x06, ENTRY_CopyBytes1 }, // PUSH - { 0x07, ENTRY_CopyBytes1 }, // POP - { 0x08, ENTRY_CopyBytes2Mod }, // OR /r - { 0x09, ENTRY_CopyBytes2Mod }, // OR /r - { 0x0A, ENTRY_CopyBytes2Mod }, // OR /r - { 0x0B, ENTRY_CopyBytes2Mod }, // OR /r - { 0x0C, ENTRY_CopyBytes2 }, // OR ib - { 0x0D, ENTRY_CopyBytes3Or5 }, // OR iw - { 0x0E, ENTRY_CopyBytes1 }, // PUSH - { 0x0F, ENTRY_Copy0F }, // Extension Ops - { 0x10, ENTRY_CopyBytes2Mod }, // ADC /r - { 0x11, ENTRY_CopyBytes2Mod }, // ADC /r - { 0x12, ENTRY_CopyBytes2Mod }, // ADC /r - { 0x13, ENTRY_CopyBytes2Mod }, // ADC /r - { 0x14, ENTRY_CopyBytes2 }, // ADC ib - { 0x15, ENTRY_CopyBytes3Or5 }, // ADC id - { 0x16, ENTRY_CopyBytes1 }, // PUSH - { 0x17, ENTRY_CopyBytes1 }, // POP - { 0x18, ENTRY_CopyBytes2Mod }, // SBB /r - { 0x19, ENTRY_CopyBytes2Mod }, // SBB /r - { 0x1A, ENTRY_CopyBytes2Mod }, // SBB /r - { 0x1B, ENTRY_CopyBytes2Mod }, // SBB /r - { 0x1C, ENTRY_CopyBytes2 }, // SBB ib - { 0x1D, ENTRY_CopyBytes3Or5 }, // SBB id - { 0x1E, ENTRY_CopyBytes1 }, // PUSH - { 0x1F, ENTRY_CopyBytes1 }, // POP - { 0x20, ENTRY_CopyBytes2Mod }, // AND /r - { 0x21, ENTRY_CopyBytes2Mod }, // AND /r - { 0x22, ENTRY_CopyBytes2Mod }, // AND /r - { 0x23, ENTRY_CopyBytes2Mod }, // AND /r - { 0x24, ENTRY_CopyBytes2 }, // AND ib - { 0x25, ENTRY_CopyBytes3Or5 }, // AND id - { 0x26, ENTRY_CopyBytesPrefix }, // ES prefix - { 0x27, ENTRY_CopyBytes1 }, // DAA - { 0x28, ENTRY_CopyBytes2Mod }, // SUB /r - { 0x29, ENTRY_CopyBytes2Mod }, // SUB /r - { 0x2A, ENTRY_CopyBytes2Mod }, // SUB /r - { 0x2B, ENTRY_CopyBytes2Mod }, // SUB /r - { 0x2C, ENTRY_CopyBytes2 }, // SUB ib - { 0x2D, ENTRY_CopyBytes3Or5 }, // SUB id - { 0x2E, ENTRY_CopyBytesPrefix }, // CS prefix - { 0x2F, ENTRY_CopyBytes1 }, // DAS - { 0x30, ENTRY_CopyBytes2Mod }, // XOR /r - { 0x31, ENTRY_CopyBytes2Mod }, // XOR /r - { 0x32, ENTRY_CopyBytes2Mod }, // XOR /r - { 0x33, ENTRY_CopyBytes2Mod }, // XOR /r - { 0x34, ENTRY_CopyBytes2 }, // XOR ib - { 0x35, ENTRY_CopyBytes3Or5 }, // XOR id - { 0x36, ENTRY_CopyBytesPrefix }, // SS prefix - { 0x37, ENTRY_CopyBytes1 }, // AAA - { 0x38, ENTRY_CopyBytes2Mod }, // CMP /r - { 0x39, ENTRY_CopyBytes2Mod }, // CMP /r - { 0x3A, ENTRY_CopyBytes2Mod }, // CMP /r - { 0x3B, ENTRY_CopyBytes2Mod }, // CMP /r - { 0x3C, ENTRY_CopyBytes2 }, // CMP ib - { 0x3D, ENTRY_CopyBytes3Or5 }, // CMP id - { 0x3E, ENTRY_CopyBytesPrefix }, // DS prefix - { 0x3F, ENTRY_CopyBytes1 }, // AAS -#ifdef DETOURS_X64 // For Rax Prefix -#error Feature not supported in this release. - - - - - - - - - - - - - - - -#else - { 0x40, ENTRY_CopyBytes1 }, // INC - { 0x41, ENTRY_CopyBytes1 }, // INC - { 0x42, ENTRY_CopyBytes1 }, // INC - { 0x43, ENTRY_CopyBytes1 }, // INC - { 0x44, ENTRY_CopyBytes1 }, // INC - { 0x45, ENTRY_CopyBytes1 }, // INC - { 0x46, ENTRY_CopyBytes1 }, // INC - { 0x47, ENTRY_CopyBytes1 }, // INC - { 0x48, ENTRY_CopyBytes1 }, // DEC - { 0x49, ENTRY_CopyBytes1 }, // DEC - { 0x4A, ENTRY_CopyBytes1 }, // DEC - { 0x4B, ENTRY_CopyBytes1 }, // DEC - { 0x4C, ENTRY_CopyBytes1 }, // DEC - { 0x4D, ENTRY_CopyBytes1 }, // DEC - { 0x4E, ENTRY_CopyBytes1 }, // DEC - { 0x4F, ENTRY_CopyBytes1 }, // DEC -#endif - { 0x50, ENTRY_CopyBytes1 }, // PUSH - { 0x51, ENTRY_CopyBytes1 }, // PUSH - { 0x52, ENTRY_CopyBytes1 }, // PUSH - { 0x53, ENTRY_CopyBytes1 }, // PUSH - { 0x54, ENTRY_CopyBytes1 }, // PUSH - { 0x55, ENTRY_CopyBytes1 }, // PUSH - { 0x56, ENTRY_CopyBytes1 }, // PUSH - { 0x57, ENTRY_CopyBytes1 }, // PUSH - { 0x58, ENTRY_CopyBytes1 }, // POP - { 0x59, ENTRY_CopyBytes1 }, // POP - { 0x5A, ENTRY_CopyBytes1 }, // POP - { 0x5B, ENTRY_CopyBytes1 }, // POP - { 0x5C, ENTRY_CopyBytes1 }, // POP - { 0x5D, ENTRY_CopyBytes1 }, // POP - { 0x5E, ENTRY_CopyBytes1 }, // POP - { 0x5F, ENTRY_CopyBytes1 }, // POP - { 0x60, ENTRY_CopyBytes1 }, // PUSHAD - { 0x61, ENTRY_CopyBytes1 }, // POPAD - { 0x62, ENTRY_CopyBytes2Mod }, // BOUND /r - { 0x63, ENTRY_CopyBytes2Mod }, // ARPL /r - { 0x64, ENTRY_CopyBytesPrefix }, // FS prefix - { 0x65, ENTRY_CopyBytesPrefix }, // GS prefix - { 0x66, ENTRY_Copy66 }, // Operand Prefix - { 0x67, ENTRY_Copy67 }, // Address Prefix - { 0x68, ENTRY_CopyBytes3Or5 }, // PUSH - { 0x69, ENTRY_CopyBytes2ModOperand }, // - { 0x6A, ENTRY_CopyBytes2 }, // PUSH - { 0x6B, ENTRY_CopyBytes2Mod1 }, // IMUL /r ib - { 0x6C, ENTRY_CopyBytes1 }, // INS - { 0x6D, ENTRY_CopyBytes1 }, // INS - { 0x6E, ENTRY_CopyBytes1 }, // OUTS/OUTSB - { 0x6F, ENTRY_CopyBytes1 }, // OUTS/OUTSW - { 0x70, ENTRY_CopyBytes2Jump }, // JO // 0f80 - { 0x71, ENTRY_CopyBytes2Jump }, // JNO // 0f81 - { 0x72, ENTRY_CopyBytes2Jump }, // JB/JC/JNAE // 0f82 - { 0x73, ENTRY_CopyBytes2Jump }, // JAE/JNB/JNC // 0f83 - { 0x74, ENTRY_CopyBytes2Jump }, // JE/JZ // 0f84 - { 0x75, ENTRY_CopyBytes2Jump }, // JNE/JNZ // 0f85 - { 0x76, ENTRY_CopyBytes2Jump }, // JBE/JNA // 0f86 - { 0x77, ENTRY_CopyBytes2Jump }, // JA/JNBE // 0f87 - { 0x78, ENTRY_CopyBytes2Jump }, // JS // 0f88 - { 0x79, ENTRY_CopyBytes2Jump }, // JNS // 0f89 - { 0x7A, ENTRY_CopyBytes2Jump }, // JP/JPE // 0f8a - { 0x7B, ENTRY_CopyBytes2Jump }, // JNP/JPO // 0f8b - { 0x7C, ENTRY_CopyBytes2Jump }, // JL/JNGE // 0f8c - { 0x7D, ENTRY_CopyBytes2Jump }, // JGE/JNL // 0f8d - { 0x7E, ENTRY_CopyBytes2Jump }, // JLE/JNG // 0f8e - { 0x7F, ENTRY_CopyBytes2Jump }, // JG/JNLE // 0f8f - { 0x80, ENTRY_CopyBytes2Mod1 }, // ADC/2 ib, etc.s - { 0x81, ENTRY_CopyBytes2ModOperand }, // - { 0x82, ENTRY_CopyBytes2 }, // MOV al,x - { 0x83, ENTRY_CopyBytes2Mod1 }, // ADC/2 ib, etc. - { 0x84, ENTRY_CopyBytes2Mod }, // TEST /r - { 0x85, ENTRY_CopyBytes2Mod }, // TEST /r - { 0x86, ENTRY_CopyBytes2Mod }, // XCHG /r @todo - { 0x87, ENTRY_CopyBytes2Mod }, // XCHG /r @todo - { 0x88, ENTRY_CopyBytes2Mod }, // MOV /r - { 0x89, ENTRY_CopyBytes2Mod }, // MOV /r - { 0x8A, ENTRY_CopyBytes2Mod }, // MOV /r - { 0x8B, ENTRY_CopyBytes2Mod }, // MOV /r - { 0x8C, ENTRY_CopyBytes2Mod }, // MOV /r - { 0x8D, ENTRY_CopyBytes2Mod }, // LEA /r - { 0x8E, ENTRY_CopyBytes2Mod }, // MOV /r - { 0x8F, ENTRY_CopyBytes2Mod }, // POP /0 - { 0x90, ENTRY_CopyBytes1 }, // NOP - { 0x91, ENTRY_CopyBytes1 }, // XCHG - { 0x92, ENTRY_CopyBytes1 }, // XCHG - { 0x93, ENTRY_CopyBytes1 }, // XCHG - { 0x94, ENTRY_CopyBytes1 }, // XCHG - { 0x95, ENTRY_CopyBytes1 }, // XCHG - { 0x96, ENTRY_CopyBytes1 }, // XCHG - { 0x97, ENTRY_CopyBytes1 }, // XCHG - { 0x98, ENTRY_CopyBytes1 }, // CWDE - { 0x99, ENTRY_CopyBytes1 }, // CDQ - { 0x9A, ENTRY_CopyBytes5Or7Dynamic }, // CALL cp - { 0x9B, ENTRY_CopyBytes1 }, // WAIT/FWAIT - { 0x9C, ENTRY_CopyBytes1 }, // PUSHFD - { 0x9D, ENTRY_CopyBytes1 }, // POPFD - { 0x9E, ENTRY_CopyBytes1 }, // SAHF - { 0x9F, ENTRY_CopyBytes1 }, // LAHF - { 0xA0, ENTRY_CopyBytes3Or5Address }, // MOV - { 0xA1, ENTRY_CopyBytes3Or5Address }, // MOV - { 0xA2, ENTRY_CopyBytes3Or5Address }, // MOV - { 0xA3, ENTRY_CopyBytes3Or5Address }, // MOV - { 0xA4, ENTRY_CopyBytes1 }, // MOVS - { 0xA5, ENTRY_CopyBytes1 }, // MOVS/MOVSD - { 0xA6, ENTRY_CopyBytes1 }, // CMPS/CMPSB - { 0xA7, ENTRY_CopyBytes1 }, // CMPS/CMPSW - { 0xA8, ENTRY_CopyBytes2 }, // TEST - { 0xA9, ENTRY_CopyBytes3Or5 }, // TEST - { 0xAA, ENTRY_CopyBytes1 }, // STOS/STOSB - { 0xAB, ENTRY_CopyBytes1 }, // STOS/STOSW - { 0xAC, ENTRY_CopyBytes1 }, // LODS/LODSB - { 0xAD, ENTRY_CopyBytes1 }, // LODS/LODSW - { 0xAE, ENTRY_CopyBytes1 }, // SCAS/SCASB - { 0xAF, ENTRY_CopyBytes1 }, // SCAS/SCASD - { 0xB0, ENTRY_CopyBytes2 }, // MOV B0+rb - { 0xB1, ENTRY_CopyBytes2 }, // MOV B0+rb - { 0xB2, ENTRY_CopyBytes2 }, // MOV B0+rb - { 0xB3, ENTRY_CopyBytes2 }, // MOV B0+rb - { 0xB4, ENTRY_CopyBytes2 }, // MOV B0+rb - { 0xB5, ENTRY_CopyBytes2 }, // MOV B0+rb - { 0xB6, ENTRY_CopyBytes2 }, // MOV B0+rb - { 0xB7, ENTRY_CopyBytes2 }, // MOV B0+rb - { 0xB8, ENTRY_CopyBytes3Or5Rax }, // MOV B8+rb - { 0xB9, ENTRY_CopyBytes3Or5 }, // MOV B8+rb - { 0xBA, ENTRY_CopyBytes3Or5 }, // MOV B8+rb - { 0xBB, ENTRY_CopyBytes3Or5 }, // MOV B8+rb - { 0xBC, ENTRY_CopyBytes3Or5 }, // MOV B8+rb - { 0xBD, ENTRY_CopyBytes3Or5 }, // MOV B8+rb - { 0xBE, ENTRY_CopyBytes3Or5 }, // MOV B8+rb - { 0xBF, ENTRY_CopyBytes3Or5 }, // MOV B8+rb - { 0xC0, ENTRY_CopyBytes2Mod1 }, // RCL/2 ib, etc. - { 0xC1, ENTRY_CopyBytes2Mod1 }, // RCL/2 ib, etc. - { 0xC2, ENTRY_CopyBytes3 }, // RET - { 0xC3, ENTRY_CopyBytes1 }, // RET - { 0xC4, ENTRY_CopyBytes2Mod }, // LES - { 0xC5, ENTRY_CopyBytes2Mod }, // LDS - { 0xC6, ENTRY_CopyBytes2Mod1 }, // MOV - { 0xC7, ENTRY_CopyBytes2ModOperand }, // MOV - { 0xC8, ENTRY_CopyBytes4 }, // ENTER - { 0xC9, ENTRY_CopyBytes1 }, // LEAVE - { 0xCA, ENTRY_CopyBytes3Dynamic }, // RET - { 0xCB, ENTRY_CopyBytes1Dynamic }, // RET - { 0xCC, ENTRY_CopyBytes1Dynamic }, // INT 3 - { 0xCD, ENTRY_CopyBytes2Dynamic }, // INT ib - { 0xCE, ENTRY_CopyBytes1Dynamic }, // INTO - { 0xCF, ENTRY_CopyBytes1Dynamic }, // IRET - { 0xD0, ENTRY_CopyBytes2Mod }, // RCL/2, etc. - { 0xD1, ENTRY_CopyBytes2Mod }, // RCL/2, etc. - { 0xD2, ENTRY_CopyBytes2Mod }, // RCL/2, etc. - { 0xD3, ENTRY_CopyBytes2Mod }, // RCL/2, etc. - { 0xD4, ENTRY_CopyBytes2 }, // AAM - { 0xD5, ENTRY_CopyBytes2 }, // AAD - { 0xD6, ENTRY_Invalid }, // - { 0xD7, ENTRY_CopyBytes1 }, // XLAT/XLATB - { 0xD8, ENTRY_CopyBytes2Mod }, // FADD, etc. - { 0xD9, ENTRY_CopyBytes2Mod }, // F2XM1, etc. - { 0xDA, ENTRY_CopyBytes2Mod }, // FLADD, etc. - { 0xDB, ENTRY_CopyBytes2Mod }, // FCLEX, etc. - { 0xDC, ENTRY_CopyBytes2Mod }, // FADD/0, etc. - { 0xDD, ENTRY_CopyBytes2Mod }, // FFREE, etc. - { 0xDE, ENTRY_CopyBytes2Mod }, // FADDP, etc. - { 0xDF, ENTRY_CopyBytes2Mod }, // FBLD/4, etc. - { 0xE0, ENTRY_CopyBytes2CantJump }, // LOOPNE cb - { 0xE1, ENTRY_CopyBytes2CantJump }, // LOOPE cb - { 0xE2, ENTRY_CopyBytes2CantJump }, // LOOP cb - { 0xE3, ENTRY_CopyBytes2Jump }, // JCXZ/JECXZ - { 0xE4, ENTRY_CopyBytes2 }, // IN ib - { 0xE5, ENTRY_CopyBytes2 }, // IN id - { 0xE6, ENTRY_CopyBytes2 }, // OUT ib - { 0xE7, ENTRY_CopyBytes2 }, // OUT ib - { 0xE8, ENTRY_CopyBytes3Or5Target }, // CALL cd - { 0xE9, ENTRY_CopyBytes3Or5Target }, // JMP cd - { 0xEA, ENTRY_CopyBytes5Or7Dynamic }, // JMP cp - { 0xEB, ENTRY_CopyBytes2Jump }, // JMP cb - { 0xEC, ENTRY_CopyBytes1 }, // IN ib - { 0xED, ENTRY_CopyBytes1 }, // IN id - { 0xEE, ENTRY_CopyBytes1 }, // OUT - { 0xEF, ENTRY_CopyBytes1 }, // OUT - { 0xF0, ENTRY_CopyBytesPrefix }, // LOCK prefix - { 0xF1, ENTRY_Invalid }, // - { 0xF2, ENTRY_CopyBytesPrefix }, // REPNE prefix - { 0xF3, ENTRY_CopyBytesPrefix }, // REPE prefix - { 0xF4, ENTRY_CopyBytes1 }, // HLT - { 0xF5, ENTRY_CopyBytes1 }, // CMC - { 0xF6, ENTRY_CopyF6 }, // TEST/0, DIV/6 - { 0xF7, ENTRY_CopyF7 }, // TEST/0, DIV/6 - { 0xF8, ENTRY_CopyBytes1 }, // CLC - { 0xF9, ENTRY_CopyBytes1 }, // STC - { 0xFA, ENTRY_CopyBytes1 }, // CLI - { 0xFB, ENTRY_CopyBytes1 }, // STI - { 0xFC, ENTRY_CopyBytes1 }, // CLD - { 0xFD, ENTRY_CopyBytes1 }, // STD - { 0xFE, ENTRY_CopyBytes2Mod }, // DEC/1,INC/0 - { 0xFF, ENTRY_CopyFF }, // CALL/2 - { 0, ENTRY_End }, -}; - -const CDetourDis::COPYENTRY CDetourDis::s_rceCopyTable0F[257] = -{ - { 0x00, ENTRY_CopyBytes2Mod }, // LLDT/2, etc. - { 0x01, ENTRY_CopyBytes2Mod }, // INVLPG/7, etc. - { 0x02, ENTRY_CopyBytes2Mod }, // LAR/r - { 0x03, ENTRY_CopyBytes2Mod }, // LSL/r - { 0x04, ENTRY_Invalid }, // _04 - { 0x05, ENTRY_Invalid }, // _05 - { 0x06, ENTRY_CopyBytes2 }, // CLTS - { 0x07, ENTRY_Invalid }, // _07 - { 0x08, ENTRY_CopyBytes2 }, // INVD - { 0x09, ENTRY_CopyBytes2 }, // WBINVD - { 0x0A, ENTRY_Invalid }, // _0A - { 0x0B, ENTRY_CopyBytes2 }, // UD2 - { 0x0C, ENTRY_Invalid }, // _0C - { 0x0D, ENTRY_CopyBytes2Mod }, // PREFETCH - { 0x0E, ENTRY_CopyBytes2 }, // FEMMS - { 0x0F, ENTRY_CopyBytes3Mod }, // 3DNow Opcodes - { 0x10, ENTRY_CopyBytes2Mod }, // MOVSS MOVUPD MOVSD - { 0x11, ENTRY_CopyBytes2Mod }, // MOVSS MOVUPD MOVSD - { 0x12, ENTRY_CopyBytes2Mod }, // MOVLPD - { 0x13, ENTRY_CopyBytes2Mod }, // MOVLPD - { 0x14, ENTRY_CopyBytes2Mod }, // UNPCKLPD - { 0x15, ENTRY_CopyBytes2Mod }, // UNPCKHPD - { 0x16, ENTRY_CopyBytes2Mod }, // MOVHPD - { 0x17, ENTRY_CopyBytes2Mod }, // MOVHPD - { 0x18, ENTRY_CopyBytes2Mod }, // PREFETCHINTA... - { 0x19, ENTRY_Invalid }, // _19 - { 0x1A, ENTRY_Invalid }, // _1A - { 0x1B, ENTRY_Invalid }, // _1B - { 0x1C, ENTRY_Invalid }, // _1C - { 0x1D, ENTRY_Invalid }, // _1D - { 0x1E, ENTRY_Invalid }, // _1E - { 0x1F, ENTRY_CopyBytes2Mod }, // NOP/r - { 0x20, ENTRY_CopyBytes2Mod }, // MOV/r - { 0x21, ENTRY_CopyBytes2Mod }, // MOV/r - { 0x22, ENTRY_CopyBytes2Mod }, // MOV/r - { 0x23, ENTRY_CopyBytes2Mod }, // MOV/r - { 0x24, ENTRY_Invalid }, // _24 - { 0x25, ENTRY_Invalid }, // _25 - { 0x26, ENTRY_Invalid }, // _26 - { 0x27, ENTRY_Invalid }, // _27 - { 0x28, ENTRY_CopyBytes2Mod }, // MOVAPS MOVAPD - { 0x29, ENTRY_CopyBytes2Mod }, // MOVAPS MOVAPD - { 0x2A, ENTRY_CopyBytes2Mod }, // CVPI2PS & - { 0x2B, ENTRY_CopyBytes2Mod }, // MOVNTPS MOVNTPD - { 0x2C, ENTRY_CopyBytes2Mod }, // CVTTPS2PI & - { 0x2D, ENTRY_CopyBytes2Mod }, // CVTPS2PI & - { 0x2E, ENTRY_CopyBytes2Mod }, // UCOMISS UCOMISD - { 0x2F, ENTRY_CopyBytes2Mod }, // COMISS COMISD - { 0x30, ENTRY_CopyBytes2 }, // WRMSR - { 0x31, ENTRY_CopyBytes2 }, // RDTSC - { 0x32, ENTRY_CopyBytes2 }, // RDMSR - { 0x33, ENTRY_CopyBytes2 }, // RDPMC - { 0x34, ENTRY_CopyBytes2 }, // SYSENTER - { 0x35, ENTRY_CopyBytes2 }, // SYSEXIT - { 0x36, ENTRY_Invalid }, // _36 - { 0x37, ENTRY_Invalid }, // _37 - { 0x38, ENTRY_Invalid }, // _38 - { 0x39, ENTRY_Invalid }, // _39 - { 0x3A, ENTRY_Invalid }, // _3A - { 0x3B, ENTRY_Invalid }, // _3B - { 0x3C, ENTRY_Invalid }, // _3C - { 0x3D, ENTRY_Invalid }, // _3D - { 0x3E, ENTRY_Invalid }, // _3E - { 0x3F, ENTRY_Invalid }, // _3F - { 0x40, ENTRY_CopyBytes2Mod }, // CMOVO (0F 40) - { 0x41, ENTRY_CopyBytes2Mod }, // CMOVNO (0F 41) - { 0x42, ENTRY_CopyBytes2Mod }, // CMOVB & CMOVNE (0F 42) - { 0x43, ENTRY_CopyBytes2Mod }, // CMOVAE & CMOVNB (0F 43) - { 0x44, ENTRY_CopyBytes2Mod }, // CMOVE & CMOVZ (0F 44) - { 0x45, ENTRY_CopyBytes2Mod }, // CMOVNE & CMOVNZ (0F 45) - { 0x46, ENTRY_CopyBytes2Mod }, // CMOVBE & CMOVNA (0F 46) - { 0x47, ENTRY_CopyBytes2Mod }, // CMOVA & CMOVNBE (0F 47) - { 0x48, ENTRY_CopyBytes2Mod }, // CMOVS (0F 48) - { 0x49, ENTRY_CopyBytes2Mod }, // CMOVNS (0F 49) - { 0x4A, ENTRY_CopyBytes2Mod }, // CMOVP & CMOVPE (0F 4A) - { 0x4B, ENTRY_CopyBytes2Mod }, // CMOVNP & CMOVPO (0F 4B) - { 0x4C, ENTRY_CopyBytes2Mod }, // CMOVL & CMOVNGE (0F 4C) - { 0x4D, ENTRY_CopyBytes2Mod }, // CMOVGE & CMOVNL (0F 4D) - { 0x4E, ENTRY_CopyBytes2Mod }, // CMOVLE & CMOVNG (0F 4E) - { 0x4F, ENTRY_CopyBytes2Mod }, // CMOVG & CMOVNLE (0F 4F) - { 0x50, ENTRY_CopyBytes2Mod }, // MOVMSKPD MOVMSKPD - { 0x51, ENTRY_CopyBytes2Mod }, // SQRTPS & - { 0x52, ENTRY_CopyBytes2Mod }, // RSQRTTS RSQRTPS - { 0x53, ENTRY_CopyBytes2Mod }, // RCPPS RCPSS - { 0x54, ENTRY_CopyBytes2Mod }, // ANDPS ANDPD - { 0x55, ENTRY_CopyBytes2Mod }, // ANDNPS ANDNPD - { 0x56, ENTRY_CopyBytes2Mod }, // ORPS ORPD - { 0x57, ENTRY_CopyBytes2Mod }, // XORPS XORPD - { 0x58, ENTRY_CopyBytes2Mod }, // ADDPS & - { 0x59, ENTRY_CopyBytes2Mod }, // MULPS & - { 0x5A, ENTRY_CopyBytes2Mod }, // CVTPS2PD & - { 0x5B, ENTRY_CopyBytes2Mod }, // CVTDQ2PS & - { 0x5C, ENTRY_CopyBytes2Mod }, // SUBPS & - { 0x5D, ENTRY_CopyBytes2Mod }, // MINPS & - { 0x5E, ENTRY_CopyBytes2Mod }, // DIVPS & - { 0x5F, ENTRY_CopyBytes2Mod }, // MASPS & - { 0x60, ENTRY_CopyBytes2Mod }, // PUNPCKLBW/r - { 0x61, ENTRY_CopyBytes2Mod }, // PUNPCKLWD/r - { 0x62, ENTRY_CopyBytes2Mod }, // PUNPCKLWD/r - { 0x63, ENTRY_CopyBytes2Mod }, // PACKSSWB/r - { 0x64, ENTRY_CopyBytes2Mod }, // PCMPGTB/r - { 0x65, ENTRY_CopyBytes2Mod }, // PCMPGTW/r - { 0x66, ENTRY_CopyBytes2Mod }, // PCMPGTD/r - { 0x67, ENTRY_CopyBytes2Mod }, // PACKUSWB/r - { 0x68, ENTRY_CopyBytes2Mod }, // PUNPCKHBW/r - { 0x69, ENTRY_CopyBytes2Mod }, // PUNPCKHWD/r - { 0x6A, ENTRY_CopyBytes2Mod }, // PUNPCKHDQ/r - { 0x6B, ENTRY_CopyBytes2Mod }, // PACKSSDW/r - { 0x6C, ENTRY_CopyBytes2Mod }, // PUNPCKLQDQ - { 0x6D, ENTRY_CopyBytes2Mod }, // PUNPCKHQDQ - { 0x6E, ENTRY_CopyBytes2Mod }, // MOVD/r - { 0x6F, ENTRY_CopyBytes2Mod }, // MOV/r - { 0x70, ENTRY_CopyBytes2Mod1 }, // PSHUFW/r ib - { 0x71, ENTRY_CopyBytes2Mod1 }, // PSLLW/6 ib,PSRAW/4 ib,PSRLW/2 ib - { 0x72, ENTRY_CopyBytes2Mod1 }, // PSLLD/6 ib,PSRAD/4 ib,PSRLD/2 ib - { 0x73, ENTRY_CopyBytes2Mod1 }, // PSLLQ/6 ib,PSRLQ/2 ib - { 0x74, ENTRY_CopyBytes2Mod }, // PCMPEQB/r - { 0x75, ENTRY_CopyBytes2Mod }, // PCMPEQW/r - { 0x76, ENTRY_CopyBytes2Mod }, // PCMPEQD/r - { 0x77, ENTRY_CopyBytes2 }, // EMMS - { 0x78, ENTRY_Invalid }, // _78 - { 0x79, ENTRY_Invalid }, // _79 - { 0x7A, ENTRY_Invalid }, // _7A - { 0x7B, ENTRY_Invalid }, // _7B - { 0x7C, ENTRY_Invalid }, // _7C - { 0x7D, ENTRY_Invalid }, // _7D - { 0x7E, ENTRY_CopyBytes2Mod }, // MOVD/r - { 0x7F, ENTRY_CopyBytes2Mod }, // MOV/r - { 0x80, ENTRY_CopyBytes3Or5Target }, // JO - { 0x81, ENTRY_CopyBytes3Or5Target }, // JNO - { 0x82, ENTRY_CopyBytes3Or5Target }, // JB,JC,JNAE - { 0x83, ENTRY_CopyBytes3Or5Target }, // JAE,JNB,JNC - { 0x84, ENTRY_CopyBytes3Or5Target }, // JE,JZ,JZ - { 0x85, ENTRY_CopyBytes3Or5Target }, // JNE,JNZ - { 0x86, ENTRY_CopyBytes3Or5Target }, // JBE,JNA - { 0x87, ENTRY_CopyBytes3Or5Target }, // JA,JNBE - { 0x88, ENTRY_CopyBytes3Or5Target }, // JS - { 0x89, ENTRY_CopyBytes3Or5Target }, // JNS - { 0x8A, ENTRY_CopyBytes3Or5Target }, // JP,JPE - { 0x8B, ENTRY_CopyBytes3Or5Target }, // JNP,JPO - { 0x8C, ENTRY_CopyBytes3Or5Target }, // JL,NGE - { 0x8D, ENTRY_CopyBytes3Or5Target }, // JGE,JNL - { 0x8E, ENTRY_CopyBytes3Or5Target }, // JLE,JNG - { 0x8F, ENTRY_CopyBytes3Or5Target }, // JG,JNLE - { 0x90, ENTRY_CopyBytes2Mod }, // CMOVO (0F 40) - { 0x91, ENTRY_CopyBytes2Mod }, // CMOVNO (0F 41) - { 0x92, ENTRY_CopyBytes2Mod }, // CMOVB & CMOVC & CMOVNAE (0F 42) - { 0x93, ENTRY_CopyBytes2Mod }, // CMOVAE & CMOVNB & CMOVNC (0F 43) - { 0x94, ENTRY_CopyBytes2Mod }, // CMOVE & CMOVZ (0F 44) - { 0x95, ENTRY_CopyBytes2Mod }, // CMOVNE & CMOVNZ (0F 45) - { 0x96, ENTRY_CopyBytes2Mod }, // CMOVBE & CMOVNA (0F 46) - { 0x97, ENTRY_CopyBytes2Mod }, // CMOVA & CMOVNBE (0F 47) - { 0x98, ENTRY_CopyBytes2Mod }, // CMOVS (0F 48) - { 0x99, ENTRY_CopyBytes2Mod }, // CMOVNS (0F 49) - { 0x9A, ENTRY_CopyBytes2Mod }, // CMOVP & CMOVPE (0F 4A) - { 0x9B, ENTRY_CopyBytes2Mod }, // CMOVNP & CMOVPO (0F 4B) - { 0x9C, ENTRY_CopyBytes2Mod }, // CMOVL & CMOVNGE (0F 4C) - { 0x9D, ENTRY_CopyBytes2Mod }, // CMOVGE & CMOVNL (0F 4D) - { 0x9E, ENTRY_CopyBytes2Mod }, // CMOVLE & CMOVNG (0F 4E) - { 0x9F, ENTRY_CopyBytes2Mod }, // CMOVG & CMOVNLE (0F 4F) - { 0xA0, ENTRY_CopyBytes2 }, // PUSH - { 0xA1, ENTRY_CopyBytes2 }, // POP - { 0xA2, ENTRY_CopyBytes2 }, // CPUID - { 0xA3, ENTRY_CopyBytes2Mod }, // BT (0F A3) - { 0xA4, ENTRY_CopyBytes2Mod1 }, // SHLD - { 0xA5, ENTRY_CopyBytes2Mod }, // SHLD - { 0xA6, ENTRY_Invalid }, // _A6 - { 0xA7, ENTRY_Invalid }, // _A7 - { 0xA8, ENTRY_CopyBytes2 }, // PUSH - { 0xA9, ENTRY_CopyBytes2 }, // POP - { 0xAA, ENTRY_CopyBytes2 }, // RSM - { 0xAB, ENTRY_CopyBytes2Mod }, // BTS (0F AB) - { 0xAC, ENTRY_CopyBytes2Mod1 }, // SHRD - { 0xAD, ENTRY_CopyBytes2Mod }, // SHRD - { 0xAE, ENTRY_CopyBytes2Mod }, // FXRSTOR/1,FXSAVE/0 - { 0xAF, ENTRY_CopyBytes2Mod }, // IMUL (0F AF) - { 0xB0, ENTRY_CopyBytes2Mod }, // CMPXCHG (0F B0) - { 0xB1, ENTRY_CopyBytes2Mod }, // CMPXCHG (0F B1) - { 0xB2, ENTRY_CopyBytes2Mod }, // LSS/r - { 0xB3, ENTRY_CopyBytes2Mod }, // BTR (0F B3) - { 0xB4, ENTRY_CopyBytes2Mod }, // LFS/r - { 0xB5, ENTRY_CopyBytes2Mod }, // LGS/r - { 0xB6, ENTRY_CopyBytes2Mod }, // MOVZX/r - { 0xB7, ENTRY_CopyBytes2Mod }, // MOVZX/r - { 0xB8, ENTRY_Invalid }, // _B8 - { 0xB9, ENTRY_Invalid }, // _B9 - { 0xBA, ENTRY_CopyBytes2Mod1 }, // BT & BTC & BTR & BTS (0F BA) - { 0xBB, ENTRY_CopyBytes2Mod }, // BTC (0F BB) - { 0xBC, ENTRY_CopyBytes2Mod }, // BSF (0F BC) - { 0xBD, ENTRY_CopyBytes2Mod }, // BSR (0F BD) - { 0xBE, ENTRY_CopyBytes2Mod }, // MOVSX/r - { 0xBF, ENTRY_CopyBytes2Mod }, // MOVSX/r - { 0xC0, ENTRY_CopyBytes2Mod }, // XADD/r - { 0xC1, ENTRY_CopyBytes2Mod }, // XADD/r - { 0xC2, ENTRY_CopyBytes2Mod }, // CMPPS & - { 0xC3, ENTRY_CopyBytes2Mod }, // MOVNTI - { 0xC4, ENTRY_CopyBytes2Mod1 }, // PINSRW /r ib - { 0xC5, ENTRY_CopyBytes2Mod1 }, // PEXTRW /r ib - { 0xC6, ENTRY_CopyBytes2Mod1 }, // SHUFPS & SHUFPD - { 0xC7, ENTRY_CopyBytes2Mod }, // CMPXCHG8B (0F C7) - { 0xC8, ENTRY_CopyBytes2 }, // BSWAP 0F C8 + rd - { 0xC9, ENTRY_CopyBytes2 }, // BSWAP 0F C8 + rd - { 0xCA, ENTRY_CopyBytes2 }, // BSWAP 0F C8 + rd - { 0xCB, ENTRY_CopyBytes2 }, //CVTPD2PI BSWAP 0F C8 + rd - { 0xCC, ENTRY_CopyBytes2 }, // BSWAP 0F C8 + rd - { 0xCD, ENTRY_CopyBytes2 }, // BSWAP 0F C8 + rd - { 0xCE, ENTRY_CopyBytes2 }, // BSWAP 0F C8 + rd - { 0xCF, ENTRY_CopyBytes2 }, // BSWAP 0F C8 + rd - { 0xD0, ENTRY_Invalid }, // _D0 - { 0xD1, ENTRY_CopyBytes2Mod }, // PSRLW/r - { 0xD2, ENTRY_CopyBytes2Mod }, // PSRLD/r - { 0xD3, ENTRY_CopyBytes2Mod }, // PSRLQ/r - { 0xD4, ENTRY_CopyBytes2Mod }, // PADDQ - { 0xD5, ENTRY_CopyBytes2Mod }, // PMULLW/r - { 0xD6, ENTRY_CopyBytes2Mod }, // MOVDQ2Q / MOVQ2DQ - { 0xD7, ENTRY_CopyBytes2Mod }, // PMOVMSKB/r - { 0xD8, ENTRY_CopyBytes2Mod }, // PSUBUSB/r - { 0xD9, ENTRY_CopyBytes2Mod }, // PSUBUSW/r - { 0xDA, ENTRY_CopyBytes2Mod }, // PMINUB/r - { 0xDB, ENTRY_CopyBytes2Mod }, // PAND/r - { 0xDC, ENTRY_CopyBytes2Mod }, // PADDUSB/r - { 0xDD, ENTRY_CopyBytes2Mod }, // PADDUSW/r - { 0xDE, ENTRY_CopyBytes2Mod }, // PMAXUB/r - { 0xDF, ENTRY_CopyBytes2Mod }, // PANDN/r - { 0xE0, ENTRY_CopyBytes2Mod }, // PAVGB - { 0xE1, ENTRY_CopyBytes2Mod }, // PSRAW/r - { 0xE2, ENTRY_CopyBytes2Mod }, // PSRAD/r - { 0xE3, ENTRY_CopyBytes2Mod }, // PAVGW - { 0xE4, ENTRY_CopyBytes2Mod }, // PMULHUW/r - { 0xE5, ENTRY_CopyBytes2Mod }, // PMULHW/r - { 0xE6, ENTRY_CopyBytes2Mod }, // CTDQ2PD & - { 0xE7, ENTRY_CopyBytes2Mod }, // MOVNTQ - { 0xE8, ENTRY_CopyBytes2Mod }, // PSUBB/r - { 0xE9, ENTRY_CopyBytes2Mod }, // PSUBW/r - { 0xEA, ENTRY_CopyBytes2Mod }, // PMINSW/r - { 0xEB, ENTRY_CopyBytes2Mod }, // POR/r - { 0xEC, ENTRY_CopyBytes2Mod }, // PADDSB/r - { 0xED, ENTRY_CopyBytes2Mod }, // PADDSW/r - { 0xEE, ENTRY_CopyBytes2Mod }, // PMAXSW /r - { 0xEF, ENTRY_CopyBytes2Mod }, // PXOR/r - { 0xF0, ENTRY_Invalid }, // _F0 - { 0xF1, ENTRY_CopyBytes2Mod }, // PSLLW/r - { 0xF2, ENTRY_CopyBytes2Mod }, // PSLLD/r - { 0xF3, ENTRY_CopyBytes2Mod }, // PSLLQ/r - { 0xF4, ENTRY_CopyBytes2Mod }, // PMULUDQ/r - { 0xF5, ENTRY_CopyBytes2Mod }, // PMADDWD/r - { 0xF6, ENTRY_CopyBytes2Mod }, // PSADBW/r - { 0xF7, ENTRY_CopyBytes2Mod }, // MASKMOVQ - { 0xF8, ENTRY_CopyBytes2Mod }, // PSUBB/r - { 0xF9, ENTRY_CopyBytes2Mod }, // PSUBW/r - { 0xFA, ENTRY_CopyBytes2Mod }, // PSUBD/r - { 0xFB, ENTRY_CopyBytes2Mod }, // FSUBQ/r - { 0xFC, ENTRY_CopyBytes2Mod }, // PADDB/r - { 0xFD, ENTRY_CopyBytes2Mod }, // PADDW/r - { 0xFE, ENTRY_CopyBytes2Mod }, // PADDD/r - { 0xFF, ENTRY_Invalid }, // _FF - { 0, ENTRY_End }, -}; - -BOOL CDetourDis::SanityCheckSystem() -{ - ULONG n = 0; - for (; n < 256; n++) { - REFCOPYENTRY pEntry = &s_rceCopyTable[n]; - - if (n != pEntry->nOpcode) { - ASSERT(n == pEntry->nOpcode); - return FALSE; - } - } - if (s_rceCopyTable[256].pfCopy != NULL) { - ASSERT(!"Missing end marker."); - return FALSE; - } - - for (n = 0; n < 256; n++) { - REFCOPYENTRY pEntry = &s_rceCopyTable0F[n]; - - if (n != pEntry->nOpcode) { - ASSERT(n == pEntry->nOpcode); - return FALSE; - } - } - if (s_rceCopyTable0F[256].pfCopy != NULL) { - ASSERT(!"Missing end marker."); - return FALSE; - } - - return TRUE; -} -#endif // defined(DETOURS_X64) || defined(DETOURS_X86) - -/////////////////////////////////////////////////////////// IA64 Disassembler. -// -#ifdef DETOURS_IA64 -#error Feature not supported in this release. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#endif // DETOURS_IA64 - -#ifdef DETOURS_ARM -#error Feature not supported in this release. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#endif // DETOURS_ARM - -// -///////////////////////////////////////////////////////////////// End of File. diff --git a/Detours/image.cpp b/Detours/image.cpp deleted file mode 100644 index b139c3d..0000000 --- a/Detours/image.cpp +++ /dev/null @@ -1,2192 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Image manipulation functions (image.cpp of detours.lib) -// -// Microsoft Research Detours Package, Version 3.0 Build_316. -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// Used for for payloads, byways, and imports. -// - -#include -#if (_MSC_VER < 1310) -#else -#include -#endif - -#if (_MSC_VER < 1299) -#pragma warning(disable: 4710) -#else -#endif - -//#define DETOUR_DEBUG 1 -#define DETOURS_INTERNAL - -#include "detours.h" - -namespace Detour -{ - ////////////////////////////////////////////////////////////////////////////// - // -#ifndef _STRSAFE_H_INCLUDED_ - static inline HRESULT StringCchLengthA(const char* psz, size_t cchMax, size_t* pcch) - { - HRESULT hr = S_OK; - size_t cchMaxPrev = cchMax; - - if (cchMax > 2147483647) - { - return ERROR_INVALID_PARAMETER; - } - - while (cchMax && (*psz != '\0')) - { - psz++; - cchMax--; - } - - if (cchMax == 0) - { - // the string is longer than cchMax - hr = ERROR_INVALID_PARAMETER; - } - - if (SUCCEEDED(hr) && pcch) - { - *pcch = cchMaxPrev - cchMax; - } - - return hr; - } - - - static inline HRESULT StringCchCopyA(char* pszDest, size_t cchDest, const char* pszSrc) - { - HRESULT hr = S_OK; - - if (cchDest == 0) - { - // can not null terminate a zero-byte dest buffer - hr = ERROR_INVALID_PARAMETER; - } - else - { - while (cchDest && (*pszSrc != '\0')) - { - *pszDest++ = *pszSrc++; - cchDest--; - } - - if (cchDest == 0) - { - // we are going to truncate pszDest - pszDest--; - hr = ERROR_INVALID_PARAMETER; - } - - *pszDest = '\0'; - } - - return hr; - } - - static inline HRESULT StringCchCatA(char* pszDest, size_t cchDest, const char* pszSrc) - { - HRESULT hr; - size_t cchDestCurrent; - - if (cchDest > 2147483647) - { - return ERROR_INVALID_PARAMETER; - } - - hr = StringCchLengthA(pszDest, cchDest, &cchDestCurrent); - - if (SUCCEEDED(hr)) - { - hr = StringCchCopyA(pszDest + cchDestCurrent, - cchDest - cchDestCurrent, - pszSrc); - } - - return hr; - } - -#endif - - /////////////////////////////////////////////////////////////////////////////// - // - class CImageData - { - friend class CImage; - - public: - CImageData(PBYTE pbData, DWORD cbData); - ~CImageData(); - - PBYTE Enumerate(GUID *pGuid, DWORD *pcbData, DWORD *pnIterator); - PBYTE Find(REFGUID rguid, DWORD *pcbData); - PBYTE Set(REFGUID rguid, PBYTE pbData, DWORD cbData); - - BOOL Delete(REFGUID rguid); - BOOL Purge(); - - BOOL IsEmpty() { return m_cbData == 0; } - BOOL IsValid(); - - protected: - BOOL SizeTo(DWORD cbData); - - protected: - PBYTE m_pbData; - DWORD m_cbData; - DWORD m_cbAlloc; - }; - - class CImageImportFile - { - friend class CImage; - friend class CImageImportName; - - public: - CImageImportFile(); - ~CImageImportFile(); - - public: - CImageImportFile * m_pNextFile; - BOOL m_fByway; - - CImageImportName * m_pImportNames; - DWORD m_nImportNames; - - DWORD m_rvaOriginalFirstThunk; - DWORD m_rvaFirstThunk; - - DWORD m_nForwarderChain; - PCHAR m_pszOrig; - PCHAR m_pszName; - }; - - class CImageImportName - { - friend class CImage; - friend class CImageImportFile; - - public: - CImageImportName(); - ~CImageImportName(); - - public: - WORD m_nHint; - ULONG m_nOrig; - ULONG m_nOrdinal; - PCHAR m_pszOrig; - PCHAR m_pszName; - }; - - class CImage - { - friend class CImageThunks; - friend class CImageChars; - friend class CImageImportFile; - friend class CImageImportName; - - public: - CImage(); - ~CImage(); - - static CImage * IsValid(PDETOUR_BINARY pBinary); - - public: // File Functions - BOOL Read(HANDLE hFile); - BOOL Write(HANDLE hFile); - BOOL Close(); - - public: // Manipulation Functions - PBYTE DataEnum(GUID *pGuid, DWORD *pcbData, DWORD *pnIterator); - PBYTE DataFind(REFGUID rguid, DWORD *pcbData); - PBYTE DataSet(REFGUID rguid, PBYTE pbData, DWORD cbData); - BOOL DataDelete(REFGUID rguid); - BOOL DataPurge(); - - BOOL EditImports(PVOID pContext, - PF_DETOUR_BINARY_BYWAY_CALLBACK pfBywayCallback, - PF_DETOUR_BINARY_FILE_CALLBACK pfFileCallback, - PF_DETOUR_BINARY_SYMBOL_CALLBACK pfSymbolCallback, - PF_DETOUR_BINARY_COMMIT_CALLBACK pfCommitCallback); - - protected: - BOOL WriteFile(HANDLE hFile, - LPCVOID lpBuffer, - DWORD nNumberOfBytesToWrite, - LPDWORD lpNumberOfBytesWritten); - BOOL CopyFileData(HANDLE hFile, DWORD nOldPos, DWORD cbData); - BOOL ZeroFileData(HANDLE hFile, DWORD cbData); - BOOL AlignFileData(HANDLE hFile); - - BOOL SizeOutputBuffer(DWORD cbData); - PBYTE AllocateOutput(DWORD cbData, DWORD *pnVirtAddr); - - PVOID RvaToVa(ULONG_PTR nRva); - DWORD RvaToFileOffset(DWORD nRva); - - DWORD FileAlign(DWORD nAddr); - DWORD SectionAlign(DWORD nAddr); - - BOOL CheckImportsNeeded(DWORD *pnTables, - DWORD *pnThunks, - DWORD *pnChars); - - CImageImportFile * NewByway(__in_z PCHAR pszName); - - private: - DWORD m_dwValidSignature; - CImageData * m_pImageData; // Read & Write - - HANDLE m_hMap; // Read & Write - PBYTE m_pMap; // Read & Write - - DWORD m_nNextFileAddr; // Write - DWORD m_nNextVirtAddr; // Write - - IMAGE_DOS_HEADER m_DosHeader; // Read & Write - IMAGE_NT_HEADERS m_NtHeader; // Read & Write - IMAGE_SECTION_HEADER m_SectionHeaders[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; - - DWORD m_nPrePE; - DWORD m_cbPrePE; - DWORD m_cbPostPE; - - DWORD m_nPeOffset; - DWORD m_nSectionsOffset; - DWORD m_nExtraOffset; - DWORD m_nFileSize; - - DWORD m_nOutputVirtAddr; - DWORD m_nOutputVirtSize; - DWORD m_nOutputFileAddr; - - PBYTE m_pbOutputBuffer; - DWORD m_cbOutputBuffer; - - CImageImportFile * m_pImportFiles; - DWORD m_nImportFiles; - - BOOL m_fHadDetourSection; - - private: - enum { - DETOUR_IMAGE_VALID_SIGNATURE = 0xfedcba01, // "Dtr\0" - }; - }; - - ////////////////////////////////////////////////////////////////////////////// - // - static BYTE s_rbDosCode[0x10] = { - 0x0E,0x1F,0xBA,0x0E,0x00,0xB4,0x09,0xCD, - 0x21,0xB8,0x01,0x4C,0xCD,0x21,'*','*' - }; - - static inline DWORD Max(DWORD a, DWORD b) - { - return a > b ? a : b; - } - - static inline DWORD Align(DWORD a, DWORD size) - { - size--; - return (a + size) & ~size; - } - - static inline DWORD QuadAlign(DWORD a) - { - return Align(a, 8); - } - - static PCHAR DuplicateString(__in_z PCHAR pszIn) - { - if (pszIn) { - UINT nIn = (UINT)strlen(pszIn); - PCHAR pszOut = new CHAR[nIn + 1]; - if (pszOut == NULL) { - SetLastError(ERROR_OUTOFMEMORY); - } - else { - CopyMemory(pszOut, pszIn, nIn + 1); - } - return pszOut; - } - return NULL; - } - - static PCHAR ReplaceString(__deref_out PCHAR *ppsz, __in_z PCHAR pszIn) - { - if (ppsz == NULL) { - return NULL; - } - - UINT nIn; - if (*ppsz != NULL) { - if (strcmp(*ppsz, pszIn) == 0) { - return *ppsz; - } - nIn = (UINT)strlen(pszIn); - - if (strlen(*ppsz) == nIn) { - CopyMemory(*ppsz, pszIn, nIn + 1); - return *ppsz; - } - else { - delete[] * ppsz; - *ppsz = NULL; - } - } - else { - nIn = (UINT)strlen(pszIn); - } - - *ppsz = new CHAR[nIn + 1]; - if (*ppsz == NULL) { - SetLastError(ERROR_OUTOFMEMORY); - } - else { - CopyMemory(*ppsz, pszIn, nIn + 1); - } - return *ppsz; - } - - ////////////////////////////////////////////////////////////////////////////// - // - CImageImportFile::CImageImportFile() - { - m_pNextFile = NULL; - m_fByway = FALSE; - - m_pImportNames = NULL; - m_nImportNames = 0; - - m_rvaOriginalFirstThunk = 0; - m_rvaFirstThunk = 0; - - m_nForwarderChain = (UINT)0; - m_pszName = NULL; - m_pszOrig = NULL; - } - - CImageImportFile::~CImageImportFile() - { - if (m_pNextFile) { - delete m_pNextFile; - m_pNextFile = NULL; - } - if (m_pImportNames) { - delete[] m_pImportNames; - m_pImportNames = NULL; - m_nImportNames = 0; - } - if (m_pszName) { - delete[] m_pszName; - m_pszName = NULL; - } - if (m_pszOrig) { - delete[] m_pszOrig; - m_pszOrig = NULL; - } - } - - CImageImportName::CImageImportName() - { - m_nOrig = 0; - m_nOrdinal = 0; - m_nHint = 0; - m_pszName = NULL; - m_pszOrig = NULL; - } - - CImageImportName::~CImageImportName() - { - if (m_pszName) { - delete[] m_pszName; - m_pszName = NULL; - } - if (m_pszOrig) { - delete[] m_pszOrig; - m_pszOrig = NULL; - } - } - - ////////////////////////////////////////////////////////////////////////////// - // - CImageData::CImageData(PBYTE pbData, DWORD cbData) - { - m_pbData = pbData; - m_cbData = cbData; - m_cbAlloc = 0; - } - - CImageData::~CImageData() - { - IsValid(); - - if (m_cbAlloc == 0) { - m_pbData = NULL; - } - if (m_pbData) { - delete[] m_pbData; - m_pbData = NULL; - } - m_cbData = 0; - m_cbAlloc = 0; - } - - BOOL CImageData::SizeTo(DWORD cbData) - { - IsValid(); - - if (cbData <= m_cbAlloc) { - return TRUE; - } - - PBYTE pbNew = new BYTE[cbData]; - if (pbNew == NULL) { - SetLastError(ERROR_OUTOFMEMORY); - return FALSE; - } - - if (m_pbData) { - CopyMemory(pbNew, m_pbData, m_cbData); - if (m_cbAlloc > 0) { - delete[] m_pbData; - } - m_pbData = NULL; - } - m_pbData = pbNew; - m_cbAlloc = cbData; - - IsValid(); - - return TRUE; - } - - BOOL CImageData::Purge() - { - m_cbData = 0; - - IsValid(); - - return TRUE; - } - - BOOL CImageData::IsValid() - { - if (m_pbData == NULL) { - return TRUE; - } - - PBYTE pbBeg = m_pbData; - PBYTE pbEnd = m_pbData + m_cbData; - - for (PBYTE pbIter = pbBeg; pbIter < pbEnd;) { - PDETOUR_SECTION_RECORD pRecord = (PDETOUR_SECTION_RECORD)pbIter; - - if (pRecord->cbBytes < sizeof(DETOUR_SECTION_RECORD)) { - return FALSE; - } - if (pRecord->nReserved != 0) { - return FALSE; - } - - pbIter += pRecord->cbBytes; - } - return TRUE; - } - - PBYTE CImageData::Enumerate(GUID *pGuid, DWORD *pcbData, DWORD *pnIterator) - { - IsValid(); - - if (pnIterator == NULL || - m_cbData < *pnIterator + sizeof(DETOUR_SECTION_RECORD)) { - - if (pcbData) { - *pcbData = 0; - } - if (pGuid) { - ZeroMemory(pGuid, sizeof(*pGuid)); - } - return NULL; - } - - PDETOUR_SECTION_RECORD pRecord = (PDETOUR_SECTION_RECORD)(m_pbData + *pnIterator); - - if (pGuid) { - *pGuid = pRecord->guid; - } - if (pcbData) { - *pcbData = pRecord->cbBytes - sizeof(DETOUR_SECTION_RECORD); - } - *pnIterator = (LONG)(((PBYTE)pRecord - m_pbData) + pRecord->cbBytes); - - return (PBYTE)(pRecord + 1); - } - - PBYTE CImageData::Find(REFGUID rguid, DWORD *pcbData) - { - IsValid(); - - DWORD cbBytes = sizeof(DETOUR_SECTION_RECORD); - for (DWORD nOffset = 0; nOffset < m_cbData; nOffset += cbBytes) { - PDETOUR_SECTION_RECORD pRecord = (PDETOUR_SECTION_RECORD)(m_pbData + nOffset); - - cbBytes = pRecord->cbBytes; - if (cbBytes > m_cbData) { - break; - } - if (cbBytes < sizeof(DETOUR_SECTION_RECORD)) { - continue; - } - - if (pRecord->guid.Data1 == rguid.Data1 && - pRecord->guid.Data2 == rguid.Data2 && - pRecord->guid.Data3 == rguid.Data3 && - pRecord->guid.Data4[0] == rguid.Data4[0] && - pRecord->guid.Data4[1] == rguid.Data4[1] && - pRecord->guid.Data4[2] == rguid.Data4[2] && - pRecord->guid.Data4[3] == rguid.Data4[3] && - pRecord->guid.Data4[4] == rguid.Data4[4] && - pRecord->guid.Data4[5] == rguid.Data4[5] && - pRecord->guid.Data4[6] == rguid.Data4[6] && - pRecord->guid.Data4[7] == rguid.Data4[7]) { - - *pcbData = cbBytes - sizeof(DETOUR_SECTION_RECORD); - return (PBYTE)(pRecord + 1); - } - } - - if (pcbData) { - *pcbData = 0; - } - return NULL; - } - - BOOL CImageData::Delete(REFGUID rguid) - { - IsValid(); - - PBYTE pbFound = NULL; - DWORD cbFound = 0; - - pbFound = Find(rguid, &cbFound); - if (pbFound == NULL) { - SetLastError(ERROR_MOD_NOT_FOUND); - return FALSE; - } - - pbFound -= sizeof(DETOUR_SECTION_RECORD); - cbFound += sizeof(DETOUR_SECTION_RECORD); - - PBYTE pbRestData = pbFound + cbFound; - DWORD cbRestData = m_cbData - (LONG)(pbRestData - m_pbData); - - if (cbRestData) { - MoveMemory(pbFound, pbRestData, cbRestData); - } - m_cbData -= cbFound; - - IsValid(); - return TRUE; - } - - PBYTE CImageData::Set(REFGUID rguid, PBYTE pbData, DWORD cbData) - { - IsValid(); - Delete(rguid); - - DWORD cbAlloc = QuadAlign(cbData); - - if (!SizeTo(m_cbData + cbAlloc + sizeof(DETOUR_SECTION_RECORD))) { - return NULL; - } - - PDETOUR_SECTION_RECORD pRecord = (PDETOUR_SECTION_RECORD)(m_pbData + m_cbData); - pRecord->cbBytes = cbAlloc + sizeof(DETOUR_SECTION_RECORD); - pRecord->nReserved = 0; - pRecord->guid = rguid; - - PBYTE pbDest = (PBYTE)(pRecord + 1); - if (pbData) { - CopyMemory(pbDest, pbData, cbData); - if (cbData < cbAlloc) { - ZeroMemory(pbDest + cbData, cbAlloc - cbData); - } - } - else { - if (cbAlloc > 0) { - ZeroMemory(pbDest, cbAlloc); - } - } - - m_cbData += cbAlloc + sizeof(DETOUR_SECTION_RECORD); - - IsValid(); - return pbDest; - } - - ////////////////////////////////////////////////////////////////////////////// - // - class CImageThunks - { - private: - CImage * m_pImage; - PIMAGE_THUNK_DATA m_pThunks; - DWORD m_nThunks; - DWORD m_nThunksMax; - DWORD m_nThunkVirtAddr; - - public: - CImageThunks(CImage *pImage, DWORD nThunksMax, DWORD *pnAddr) - { - m_pImage = pImage; - m_nThunks = 0; - m_nThunksMax = nThunksMax; - m_pThunks = (PIMAGE_THUNK_DATA) - m_pImage->AllocateOutput(sizeof(IMAGE_THUNK_DATA) * nThunksMax, - &m_nThunkVirtAddr); - *pnAddr = m_nThunkVirtAddr; - } - - PIMAGE_THUNK_DATA Current(DWORD *pnVirtAddr) - { - if (m_nThunksMax > 1) { - *pnVirtAddr = m_nThunkVirtAddr; - return m_pThunks; - } - *pnVirtAddr = 0; - return NULL; - } - - PIMAGE_THUNK_DATA Allocate(ULONG_PTR nData, DWORD *pnVirtAddr) - { - if (m_nThunks < m_nThunksMax) { - *pnVirtAddr = m_nThunkVirtAddr; - - m_nThunks++; - m_nThunkVirtAddr += sizeof(IMAGE_THUNK_DATA); - m_pThunks->u1.Ordinal = (DWORD)nData; - return m_pThunks++; - } - *pnVirtAddr = 0; - return NULL; - } - - DWORD Size() - { - return m_nThunksMax * sizeof(IMAGE_THUNK_DATA); - } - }; - - ////////////////////////////////////////////////////////////////////////////// - // - class CImageChars - { - private: - CImage * m_pImage; - PCHAR m_pChars; - DWORD m_nChars; - DWORD m_nCharsMax; - DWORD m_nCharVirtAddr; - - public: - CImageChars(CImage *pImage, DWORD nCharsMax, DWORD *pnAddr) - { - m_pImage = pImage; - m_nChars = 0; - m_nCharsMax = nCharsMax; - m_pChars = (PCHAR)m_pImage->AllocateOutput(nCharsMax, &m_nCharVirtAddr); - *pnAddr = m_nCharVirtAddr; - } - - PCHAR Allocate(__in_z PCHAR pszString, DWORD *pnVirtAddr) - { - DWORD nLen = (DWORD)strlen(pszString) + 1; - nLen += (nLen & 1); - - if (m_nChars + nLen > m_nCharsMax) { - *pnVirtAddr = 0; - return NULL; - } - - *pnVirtAddr = m_nCharVirtAddr; - HRESULT hrRet = StringCchCopyA(m_pChars, m_nCharsMax, pszString); - - if (FAILED(hrRet)) { - return NULL; - } - - pszString = m_pChars; - - m_pChars += nLen; - m_nChars += nLen; - m_nCharVirtAddr += nLen; - - return pszString; - } - - PCHAR Allocate(PCHAR pszString, DWORD nHint, DWORD *pnVirtAddr) - { - DWORD nLen = (DWORD)strlen(pszString) + 1 + sizeof(USHORT); - nLen += (nLen & 1); - - if (m_nChars + nLen > m_nCharsMax) { - *pnVirtAddr = 0; - return NULL; - } - - *pnVirtAddr = m_nCharVirtAddr; - *(USHORT *)m_pChars = (USHORT)nHint; - - HRESULT hrRet = StringCchCopyA(m_pChars + sizeof(USHORT), m_nCharsMax, pszString); - if (FAILED(hrRet)) { - return NULL; - } - - pszString = m_pChars + sizeof(USHORT); - - m_pChars += nLen; - m_nChars += nLen; - m_nCharVirtAddr += nLen; - - return pszString; - } - - DWORD Size() - { - return m_nChars; - } - }; - - ////////////////////////////////////////////////////////////////////////////// - // - CImage * CImage::IsValid(PDETOUR_BINARY pBinary) - { - if (pBinary) { - CImage *pImage = (CImage *)pBinary; - - if (pImage->m_dwValidSignature == DETOUR_IMAGE_VALID_SIGNATURE) { - return pImage; - } - } - SetLastError(ERROR_INVALID_HANDLE); - return NULL; - } - - CImage::CImage() - { - m_dwValidSignature = (DWORD)DETOUR_IMAGE_VALID_SIGNATURE; - - m_hMap = NULL; - m_pMap = NULL; - - m_nPeOffset = 0; - m_nSectionsOffset = 0; - - m_pbOutputBuffer = NULL; - m_cbOutputBuffer = 0; - - m_pImageData = NULL; - - m_pImportFiles = NULL; - m_nImportFiles = 0; - - m_fHadDetourSection = FALSE; - } - - CImage::~CImage() - { - Close(); - m_dwValidSignature = 0; - } - - BOOL CImage::Close() - { - if (m_pImportFiles) { - delete m_pImportFiles; - m_pImportFiles = NULL; - m_nImportFiles = 0; - } - - if (m_pImageData) { - delete m_pImageData; - m_pImageData = NULL; - } - - if (m_pMap != NULL) { - UnmapViewOfFile(m_pMap); - m_pMap = NULL; - } - - if (m_hMap) { - CloseHandle(m_hMap); - m_hMap = NULL; - } - - if (m_pbOutputBuffer) { - delete[] m_pbOutputBuffer; - m_pbOutputBuffer = NULL; - m_cbOutputBuffer = 0; - } - return TRUE; - } - - ////////////////////////////////////////////////////////////////////////////// - // - PBYTE CImage::DataEnum(GUID *pGuid, DWORD *pcbData, DWORD *pnIterator) - { - if (m_pImageData == NULL) { - return NULL; - } - return m_pImageData->Enumerate(pGuid, pcbData, pnIterator); - } - - PBYTE CImage::DataFind(REFGUID rguid, DWORD *pcbData) - { - if (m_pImageData == NULL) { - return NULL; - } - return m_pImageData->Find(rguid, pcbData); - } - - PBYTE CImage::DataSet(REFGUID rguid, PBYTE pbData, DWORD cbData) - { - if (m_pImageData == NULL) { - return NULL; - } - return m_pImageData->Set(rguid, pbData, cbData); - } - - BOOL CImage::DataDelete(REFGUID rguid) - { - if (m_pImageData == NULL) { - return FALSE; - } - return m_pImageData->Delete(rguid); - } - - BOOL CImage::DataPurge() - { - if (m_pImageData == NULL) { - return TRUE; - } - return m_pImageData->Purge(); - } - - ////////////////////////////////////////////////////////////////////////////// - // - BOOL CImage::SizeOutputBuffer(DWORD cbData) - { - if (m_cbOutputBuffer < cbData) { - if (cbData < 1024) {//65536 - cbData = 1024; - } - cbData = FileAlign(cbData); - - PBYTE pOutput = new BYTE[cbData]; - if (pOutput == NULL) { - SetLastError(ERROR_OUTOFMEMORY); - return FALSE; - } - - if (m_pbOutputBuffer) { - CopyMemory(pOutput, m_pbOutputBuffer, m_cbOutputBuffer); - - delete[] m_pbOutputBuffer; - m_pbOutputBuffer = NULL; - } - - ZeroMemory(pOutput + m_cbOutputBuffer, cbData - m_cbOutputBuffer), - - m_pbOutputBuffer = pOutput; - m_cbOutputBuffer = cbData; - } - return TRUE; - } - - PBYTE CImage::AllocateOutput(DWORD cbData, DWORD *pnVirtAddr) - { - cbData = QuadAlign(cbData); - - PBYTE pbData = m_pbOutputBuffer + m_nOutputVirtSize; - - *pnVirtAddr = m_nOutputVirtAddr + m_nOutputVirtSize; - m_nOutputVirtSize += cbData; - - if (m_nOutputVirtSize > m_cbOutputBuffer) { - SetLastError(ERROR_OUTOFMEMORY); - return NULL; - } - - ZeroMemory(pbData, cbData); - - return pbData; - } - - ////////////////////////////////////////////////////////////////////////////// - // - DWORD CImage::FileAlign(DWORD nAddr) - { - return Align(nAddr, m_NtHeader.OptionalHeader.FileAlignment); - } - - DWORD CImage::SectionAlign(DWORD nAddr) - { - return Align(nAddr, m_NtHeader.OptionalHeader.SectionAlignment); - } - - ////////////////////////////////////////////////////////////////////////////// - // - PVOID CImage::RvaToVa(ULONG_PTR nRva) - { - if (nRva == 0) { - return NULL; - } - - for (DWORD n = 0; n < m_NtHeader.FileHeader.NumberOfSections; n++) { - DWORD vaStart = m_SectionHeaders[n].VirtualAddress; - DWORD vaEnd = vaStart + m_SectionHeaders[n].SizeOfRawData; - - if (nRva >= vaStart && nRva < vaEnd) { - return (PBYTE)m_pMap - + m_SectionHeaders[n].PointerToRawData - + nRva - m_SectionHeaders[n].VirtualAddress; - } - } - return NULL; - } - - DWORD CImage::RvaToFileOffset(DWORD nRva) - { - DWORD n; - for (n = 0; n < m_NtHeader.FileHeader.NumberOfSections; n++) { - DWORD vaStart = m_SectionHeaders[n].VirtualAddress; - DWORD vaEnd = vaStart + m_SectionHeaders[n].SizeOfRawData; - - if (nRva >= vaStart && nRva < vaEnd) { - return m_SectionHeaders[n].PointerToRawData - + nRva - m_SectionHeaders[n].VirtualAddress; - } - } - return 0; - } - - ////////////////////////////////////////////////////////////////////////////// - // - BOOL CImage::WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, - LPDWORD lpNumberOfBytesWritten) - { - return ::WriteFile(hFile, - lpBuffer, - nNumberOfBytesToWrite, - lpNumberOfBytesWritten, - NULL); - } - - - BOOL CImage::CopyFileData(HANDLE hFile, DWORD nOldPos, DWORD cbData) - { - DWORD cbDone = 0; - return WriteFile(hFile, m_pMap + nOldPos, cbData, &cbDone); - } - - BOOL CImage::ZeroFileData(HANDLE hFile, DWORD cbData) - { - if (!SizeOutputBuffer(4096)) { - return FALSE; - } - - ZeroMemory(m_pbOutputBuffer, 4096); - - for (DWORD cbLeft = cbData; cbLeft > 0;) { - DWORD cbStep = cbLeft > sizeof(m_pbOutputBuffer) - ? sizeof(m_pbOutputBuffer) : cbLeft; - DWORD cbDone = 0; - - if (!WriteFile(hFile, m_pbOutputBuffer, cbStep, &cbDone)) { - return FALSE; - } - if (cbDone == 0) { - break; - } - - cbLeft -= cbDone; - } - return TRUE; - } - - BOOL CImage::AlignFileData(HANDLE hFile) - { - DWORD nLastFileAddr = m_nNextFileAddr; - - m_nNextFileAddr = FileAlign(m_nNextFileAddr); - m_nNextVirtAddr = SectionAlign(m_nNextVirtAddr); - - if (hFile != INVALID_HANDLE_VALUE) { - if (m_nNextFileAddr > nLastFileAddr) { - if (SetFilePointer(hFile, nLastFileAddr, NULL, FILE_BEGIN) == ~0u) { - return FALSE; - } - return ZeroFileData(hFile, m_nNextFileAddr - nLastFileAddr); - } - } - return TRUE; - } - - BOOL CImage::Read(HANDLE hFile) - { - DWORD n; - PBYTE pbData = NULL; - DWORD cbData = 0; - - if (hFile == INVALID_HANDLE_VALUE) { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - - ///////////////////////////////////////////////////////// Create mapping. - // - m_nFileSize = GetFileSize(hFile, NULL); - if (m_nFileSize == (DWORD)-1) { - return FALSE; - } - - m_hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL); - if (m_hMap == NULL) { - return FALSE; - } - - m_pMap = (PBYTE)MapViewOfFileEx(m_hMap, FILE_MAP_READ, 0, 0, 0, NULL); - if (m_pMap == NULL) { - return FALSE; - } - - ////////////////////////////////////////////////////// Process DOS Header. - // - PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)m_pMap; - if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) { - SetLastError(ERROR_BAD_EXE_FORMAT); - return FALSE; - } - m_nPeOffset = pDosHeader->e_lfanew; - m_nPrePE = 0; - m_cbPrePE = QuadAlign(pDosHeader->e_lfanew); - - CopyMemory(&m_DosHeader, m_pMap + m_nPrePE, sizeof(m_DosHeader)); - - /////////////////////////////////////////////////////// Process PE Header. - // - CopyMemory(&m_NtHeader, m_pMap + m_nPeOffset, sizeof(m_NtHeader)); - if (m_NtHeader.Signature != IMAGE_NT_SIGNATURE) { - SetLastError(ERROR_INVALID_EXE_SIGNATURE); - return FALSE; - } - if (m_NtHeader.FileHeader.SizeOfOptionalHeader == 0) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return FALSE; - } - m_nSectionsOffset = m_nPeOffset - + sizeof(m_NtHeader.Signature) - + sizeof(m_NtHeader.FileHeader) - + m_NtHeader.FileHeader.SizeOfOptionalHeader; - - ///////////////////////////////////////////////// Process Section Headers. - // - if (m_NtHeader.FileHeader.NumberOfSections > (sizeof(m_SectionHeaders) / - sizeof(m_SectionHeaders[0]))) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return FALSE; - } - CopyMemory(&m_SectionHeaders, - m_pMap + m_nSectionsOffset, - sizeof(m_SectionHeaders[0]) * m_NtHeader.FileHeader.NumberOfSections); - - /////////////////////////////////////////////////// Parse .detour Section. - // - DWORD rvaOriginalImageDirectory = 0; - DWORD rvaDetourBeg = 0; - DWORD rvaDetourEnd = 0; - - for (n = 0; n < m_NtHeader.FileHeader.NumberOfSections; n++) { - if (strcmp((PCHAR)m_SectionHeaders[n].Name, ".detour") == 0) { - DETOUR_SECTION_HEADER dh; - CopyMemory(&dh, - m_pMap + m_SectionHeaders[n].PointerToRawData, - sizeof(dh)); - - rvaOriginalImageDirectory = dh.nOriginalImportVirtualAddress; - if (dh.cbPrePE != 0) { - m_nPrePE = m_SectionHeaders[n].PointerToRawData + sizeof(dh); - m_cbPrePE = dh.cbPrePE; - } - rvaDetourBeg = m_SectionHeaders[n].VirtualAddress; - rvaDetourEnd = rvaDetourBeg + m_SectionHeaders[n].SizeOfRawData; - } - } - - //////////////////////////////////////////////////////// Get Import Table. - // - DWORD rvaImageDirectory = m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress; - PIMAGE_IMPORT_DESCRIPTOR iidp - = (PIMAGE_IMPORT_DESCRIPTOR)RvaToVa(rvaImageDirectory); - PIMAGE_IMPORT_DESCRIPTOR oidp - = (PIMAGE_IMPORT_DESCRIPTOR)RvaToVa(rvaOriginalImageDirectory); - - if (oidp == NULL) { - oidp = iidp; - } - if (iidp == NULL || oidp == NULL) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return FALSE; - } - - DWORD nFiles = 0; - for (; iidp[nFiles].OriginalFirstThunk != 0 || iidp[nFiles].FirstThunk != 0; nFiles++) { - } - - CImageImportFile **ppLastFile = &m_pImportFiles; - m_pImportFiles = NULL; - - for (n = 0; n < nFiles; n++, iidp++) { - ULONG_PTR rvaName = iidp->Name; - PCHAR pszName = (PCHAR)RvaToVa(rvaName); - if (pszName == NULL) { - SetLastError(ERROR_EXE_MARKED_INVALID); - goto fail; - } - - CImageImportFile *pImportFile = new CImageImportFile; - if (pImportFile == NULL) { - SetLastError(ERROR_OUTOFMEMORY); - goto fail; - } - - *ppLastFile = pImportFile; - ppLastFile = &pImportFile->m_pNextFile; - m_nImportFiles++; - - pImportFile->m_pszName = DuplicateString(pszName); - if (pImportFile->m_pszName == NULL) { - goto fail; - } - - pImportFile->m_rvaOriginalFirstThunk = iidp->OriginalFirstThunk; - pImportFile->m_rvaFirstThunk = iidp->FirstThunk; - pImportFile->m_nForwarderChain = iidp->ForwarderChain; - pImportFile->m_pImportNames = NULL; - pImportFile->m_nImportNames = 0; - pImportFile->m_fByway = FALSE; - - if ((ULONG)iidp->FirstThunk >= rvaDetourBeg && - (ULONG)iidp->FirstThunk < rvaDetourEnd) { - - pImportFile->m_pszOrig = NULL; - pImportFile->m_fByway = TRUE; - continue; - } - - rvaName = oidp->Name; - pszName = (PCHAR)RvaToVa(rvaName); - if (pszName == NULL) { - SetLastError(ERROR_EXE_MARKED_INVALID); - goto fail; - } - pImportFile->m_pszOrig = DuplicateString(pszName); - if (pImportFile->m_pszOrig == NULL) { - goto fail; - } - - DWORD rvaThunk = iidp->OriginalFirstThunk; - if (!rvaThunk) { - rvaThunk = iidp->FirstThunk; - } - PIMAGE_THUNK_DATA pAddrThunk = (PIMAGE_THUNK_DATA)RvaToVa(rvaThunk); - rvaThunk = oidp->OriginalFirstThunk; - if (!rvaThunk) { - rvaThunk = oidp->FirstThunk; - } - PIMAGE_THUNK_DATA pLookThunk = (PIMAGE_THUNK_DATA)RvaToVa(rvaThunk); - - DWORD nNames = 0; - if (pAddrThunk) { - for (; pAddrThunk[nNames].u1.Ordinal; nNames++) { - } - } - - if (pAddrThunk && nNames) { - pImportFile->m_nImportNames = nNames; - pImportFile->m_pImportNames = new CImageImportName[nNames]; - if (pImportFile->m_pImportNames == NULL) { - SetLastError(ERROR_OUTOFMEMORY); - goto fail; - } - - CImageImportName *pImportName = &pImportFile->m_pImportNames[0]; - - for (DWORD f = 0; f < nNames; f++, pImportName++) { - pImportName->m_nOrig = 0; - pImportName->m_nOrdinal = 0; - pImportName->m_nHint = 0; - pImportName->m_pszName = NULL; - pImportName->m_pszOrig = NULL; - - rvaName = pAddrThunk[f].u1.Ordinal; - if (rvaName & IMAGE_ORDINAL_FLAG) { - pImportName->m_nOrig = (ULONG)IMAGE_ORDINAL(rvaName); - pImportName->m_nOrdinal = pImportName->m_nOrig; - } - else { - PIMAGE_IMPORT_BY_NAME pName - = (PIMAGE_IMPORT_BY_NAME)RvaToVa(rvaName); - if (pName) { - pImportName->m_nHint = pName->Hint; - pImportName->m_pszName = DuplicateString((PCHAR)pName->Name); - if (pImportName->m_pszName == NULL) { - goto fail; - } - } - - rvaName = pLookThunk[f].u1.Ordinal; - if (rvaName & IMAGE_ORDINAL_FLAG) { - pImportName->m_nOrig = (ULONG)IMAGE_ORDINAL(rvaName); - pImportName->m_nOrdinal = (ULONG)IMAGE_ORDINAL(rvaName); - } - else { - pName = (PIMAGE_IMPORT_BY_NAME)RvaToVa(rvaName); - if (pName) { - pImportName->m_pszOrig - = DuplicateString((PCHAR)pName->Name); - if (pImportName->m_pszOrig == NULL) { - goto fail; - } - } - } - } - } - } - oidp++; - } - - ////////////////////////////////////////////////////////// Parse Sections. - // - m_nExtraOffset = 0; - for (n = 0; n < m_NtHeader.FileHeader.NumberOfSections; n++) { - m_nExtraOffset = Max(m_SectionHeaders[n].PointerToRawData + - m_SectionHeaders[n].SizeOfRawData, - m_nExtraOffset); - - if (strcmp((PCHAR)m_SectionHeaders[n].Name, ".detour") == 0) { - DETOUR_SECTION_HEADER dh; - CopyMemory(&dh, - m_pMap + m_SectionHeaders[n].PointerToRawData, - sizeof(dh)); - - if (dh.nDataOffset == 0) { - dh.nDataOffset = dh.cbHeaderSize; - } - - cbData = dh.cbDataSize - dh.nDataOffset; - pbData = (m_pMap + - m_SectionHeaders[n].PointerToRawData + - dh.nDataOffset); - - m_nExtraOffset = Max(m_SectionHeaders[n].PointerToRawData + - m_SectionHeaders[n].SizeOfRawData, - m_nExtraOffset); - - m_NtHeader.FileHeader.NumberOfSections--; - - m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress - = dh.nOriginalImportVirtualAddress; - m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size - = dh.nOriginalImportSize; - - m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].VirtualAddress - = dh.nOriginalBoundImportVirtualAddress; - m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].Size - = dh.nOriginalBoundImportSize; - - m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress - = dh.nOriginalIatVirtualAddress; - m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].Size - = dh.nOriginalIatSize; - - m_NtHeader.OptionalHeader.CheckSum = 0; - m_NtHeader.OptionalHeader.SizeOfImage - = dh.nOriginalSizeOfImage; - - m_fHadDetourSection = TRUE; - } - } - - m_pImageData = new CImageData(pbData, cbData); - if (m_pImageData == NULL) { - SetLastError(ERROR_OUTOFMEMORY); - } - return TRUE; - - fail: - return FALSE; - } - - static inline BOOL strneq(__in_z PCHAR pszOne, __in_z PCHAR pszTwo) - { - if (pszOne == pszTwo) { - return FALSE; - } - if (!pszOne || !pszTwo) { - return TRUE; - } - return (strcmp(pszOne, pszTwo) != 0); - } - - BOOL CImage::CheckImportsNeeded(DWORD *pnTables, DWORD *pnThunks, DWORD *pnChars) - { - DWORD nTables = 0; - DWORD nThunks = 0; - DWORD nChars = 0; - BOOL fNeedDetourSection = FALSE; - - for (CImageImportFile *pImportFile = m_pImportFiles; - pImportFile != NULL; pImportFile = pImportFile->m_pNextFile) { - - nChars += (int)strlen(pImportFile->m_pszName) + 1; - nChars += nChars & 1; - - if (pImportFile->m_fByway) { - fNeedDetourSection = TRUE; - nThunks++; - } - else { - if (!fNeedDetourSection && - strneq(pImportFile->m_pszName, pImportFile->m_pszOrig)) { - - fNeedDetourSection = TRUE; - } - for (DWORD n = 0; n < pImportFile->m_nImportNames; n++) { - CImageImportName *pImportName = &pImportFile->m_pImportNames[n]; - - if (!fNeedDetourSection && - strneq(pImportName->m_pszName, pImportName->m_pszOrig)) { - - fNeedDetourSection = TRUE; - } - - if (pImportName->m_pszName) { - nChars += sizeof(WORD); // Hint - nChars += (int)strlen(pImportName->m_pszName) + 1; - nChars += nChars & 1; - } - nThunks++; - } - } - nThunks++; - nTables++; - } - nTables++; - - *pnTables = nTables; - *pnThunks = nThunks; - *pnChars = nChars; - - return fNeedDetourSection; - } - - ////////////////////////////////////////////////////////////////////////////// - // - CImageImportFile * CImage::NewByway(__in_z PCHAR pszName) - { - CImageImportFile *pImportFile = new CImageImportFile; - if (pImportFile == NULL) { - SetLastError(ERROR_OUTOFMEMORY); - goto fail; - } - - pImportFile->m_pNextFile = NULL; - pImportFile->m_fByway = TRUE; - - pImportFile->m_pszName = DuplicateString(pszName); - if (pImportFile->m_pszName == NULL) { - goto fail; - } - - pImportFile->m_rvaOriginalFirstThunk = 0; - pImportFile->m_rvaFirstThunk = 0; - pImportFile->m_nForwarderChain = (UINT)0; - pImportFile->m_pImportNames = NULL; - pImportFile->m_nImportNames = 0; - - m_nImportFiles++; - return pImportFile; - - fail: - if (pImportFile) { - delete pImportFile; - pImportFile = NULL; - } - return NULL; - } - - BOOL CImage::EditImports(PVOID pContext, - PF_DETOUR_BINARY_BYWAY_CALLBACK pfBywayCallback, - PF_DETOUR_BINARY_FILE_CALLBACK pfFileCallback, - PF_DETOUR_BINARY_SYMBOL_CALLBACK pfSymbolCallback, - PF_DETOUR_BINARY_COMMIT_CALLBACK pfCommitCallback) - { - CImageImportFile *pImportFile = NULL; - CImageImportFile **ppLastFile = &m_pImportFiles; - - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - - while ((pImportFile = *ppLastFile) != NULL) { - - if (pfBywayCallback) { - PCHAR pszFile = NULL; - if (!(*pfBywayCallback)(pContext, pszFile, &pszFile)) { - goto fail; - } - - if (pszFile) { - // Insert a new Byway. - CImageImportFile *pByway = NewByway(pszFile); - if (pByway == NULL) { - return FALSE; - } - - pByway->m_pNextFile = pImportFile; - *ppLastFile = pByway; - ppLastFile = &pByway->m_pNextFile; - continue; // Retry after Byway. - } - } - - if (pImportFile->m_fByway) { - if (pfBywayCallback) { - PCHAR pszFile = pImportFile->m_pszName; - - if (!(*pfBywayCallback)(pContext, pszFile, &pszFile)) { - goto fail; - } - - if (pszFile) { // Replace? Byway - if (ReplaceString(&pImportFile->m_pszName, pszFile) == NULL) { - goto fail; - } - } - else { // Delete Byway - *ppLastFile = pImportFile->m_pNextFile; - pImportFile->m_pNextFile = NULL; - delete pImportFile; - pImportFile = *ppLastFile; - m_nImportFiles--; - continue; // Retry after delete. - } - } - } - else { - if (pfFileCallback) { - PCHAR pszFile = pImportFile->m_pszName; - - if (!(*pfFileCallback)(pContext, pImportFile->m_pszOrig, - pszFile, &pszFile)) { - goto fail; - } - - if (pszFile != NULL) { - if (ReplaceString(&pImportFile->m_pszName, pszFile) == NULL) { - goto fail; - } - } - } - - if (pfSymbolCallback) { - for (DWORD n = 0; n < pImportFile->m_nImportNames; n++) { - CImageImportName *pImportName = &pImportFile->m_pImportNames[n]; - - PCHAR pszName = pImportName->m_pszName; - ULONG nOrdinal = pImportName->m_nOrdinal; - if (!(*pfSymbolCallback)(pContext, - pImportName->m_nOrig, - nOrdinal, - &nOrdinal, - pImportName->m_pszOrig, - pszName, - &pszName)) { - goto fail; - } - - if (pszName != NULL) { - pImportName->m_nOrdinal = 0; - if (ReplaceString(&pImportName->m_pszName, pszName) == NULL) { - goto fail; - } - } - else if (nOrdinal != 0) { - pImportName->m_nOrdinal = nOrdinal; - - if (pImportName->m_pszName != NULL) { - delete[] pImportName->m_pszName; - pImportName->m_pszName = NULL; - } - } - } - } - } - - ppLastFile = &pImportFile->m_pNextFile; - pImportFile = pImportFile->m_pNextFile; - } - - for (;;) { - if (pfBywayCallback) { - PCHAR pszFile = NULL; - if (!(*pfBywayCallback)(pContext, NULL, &pszFile)) { - goto fail; - } - if (pszFile) { - // Insert a new Byway. - CImageImportFile *pByway = NewByway(pszFile); - if (pByway == NULL) { - return FALSE; - } - - pByway->m_pNextFile = pImportFile; - *ppLastFile = pByway; - ppLastFile = &pByway->m_pNextFile; - continue; // Retry after Byway. - } - } - break; - } - - if (pfCommitCallback) { - if (!(*pfCommitCallback)(pContext)) { - goto fail; - } - } - - SetLastError(NO_ERROR); - return TRUE; - - fail: - return FALSE; - } - - BOOL CImage::Write(HANDLE hFile) - { - DWORD cbDone; - - if (hFile == INVALID_HANDLE_VALUE) { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - - m_nNextFileAddr = 0; - m_nNextVirtAddr = 0; - - DWORD nTables = 0; - DWORD nThunks = 0; - DWORD nChars = 0; - BOOL fNeedDetourSection = CheckImportsNeeded(&nTables, &nThunks, &nChars); - - //////////////////////////////////////////////////////////// Copy Headers. - // - if (SetFilePointer(hFile, 0, NULL, FILE_BEGIN) == ~0u) { - return FALSE; - } - if (!CopyFileData(hFile, 0, m_NtHeader.OptionalHeader.SizeOfHeaders)) { - return FALSE; - } - - if (fNeedDetourSection || !m_pImageData->IsEmpty()) { - // Replace the file's DOS header with our own. - m_nPeOffset = sizeof(m_DosHeader) + sizeof(s_rbDosCode); - m_nSectionsOffset = m_nPeOffset - + sizeof(m_NtHeader.Signature) - + sizeof(m_NtHeader.FileHeader) - + m_NtHeader.FileHeader.SizeOfOptionalHeader; - m_DosHeader.e_lfanew = m_nPeOffset; - - if (SetFilePointer(hFile, 0, NULL, FILE_BEGIN) == ~0u) { - return FALSE; - } - if (!WriteFile(hFile, &m_DosHeader, sizeof(m_DosHeader), &cbDone)) { - return FALSE; - } - if (!WriteFile(hFile, &s_rbDosCode, sizeof(s_rbDosCode), &cbDone)) { - return FALSE; - } - } - else { - // Restore the file's original DOS header. - if (m_nPrePE != 0) { - m_nPeOffset = m_cbPrePE; - m_nSectionsOffset = m_nPeOffset - + sizeof(m_NtHeader.Signature) - + sizeof(m_NtHeader.FileHeader) - + m_NtHeader.FileHeader.SizeOfOptionalHeader; - m_DosHeader.e_lfanew = m_nPeOffset; - - - if (SetFilePointer(hFile, 0, NULL, FILE_BEGIN) == ~0u) { - return FALSE; - } - if (!CopyFileData(hFile, m_nPrePE, m_cbPrePE)) { - return FALSE; - } - } - } - - m_nNextFileAddr = m_NtHeader.OptionalHeader.SizeOfHeaders; - m_nNextVirtAddr = 0; - if (!AlignFileData(hFile)) { - return FALSE; - } - - /////////////////////////////////////////////////////////// Copy Sections. - // - DWORD n = 0; - for (; n < m_NtHeader.FileHeader.NumberOfSections; n++) { - if (m_SectionHeaders[n].SizeOfRawData) { - if (SetFilePointer(hFile, - m_SectionHeaders[n].PointerToRawData, - NULL, FILE_BEGIN) == ~0u) { - return FALSE; - } - if (!CopyFileData(hFile, - m_SectionHeaders[n].PointerToRawData, - m_SectionHeaders[n].SizeOfRawData)) { - return FALSE; - } - } - m_nNextFileAddr = Max(m_SectionHeaders[n].PointerToRawData + - m_SectionHeaders[n].SizeOfRawData, - m_nNextFileAddr); - m_nNextVirtAddr = Max(m_SectionHeaders[n].VirtualAddress + - m_SectionHeaders[n].Misc.VirtualSize, - m_nNextVirtAddr); - m_nExtraOffset = Max(m_nNextFileAddr, m_nExtraOffset); - - if (!AlignFileData(hFile)) { - return FALSE; - } - } - - if (fNeedDetourSection || !m_pImageData->IsEmpty()) { - ////////////////////////////////////////////// Insert .detour Section. - // - DWORD nSection = m_NtHeader.FileHeader.NumberOfSections++; - DETOUR_SECTION_HEADER dh; - - ZeroMemory(&dh, sizeof(dh)); - ZeroMemory(&m_SectionHeaders[nSection], sizeof(m_SectionHeaders[nSection])); - - dh.cbHeaderSize = sizeof(DETOUR_SECTION_HEADER); - dh.nSignature = DETOUR_SECTION_HEADER_SIGNATURE; - - dh.nOriginalImportVirtualAddress = m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress; - dh.nOriginalImportSize = m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size; - - dh.nOriginalBoundImportVirtualAddress - = m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].VirtualAddress; - dh.nOriginalBoundImportSize = m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].Size; - - dh.nOriginalIatVirtualAddress = m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress; - dh.nOriginalIatSize = m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].Size; - - dh.nOriginalSizeOfImage = m_NtHeader.OptionalHeader.SizeOfImage; - - DWORD clrAddr = m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress; - DWORD clrSize = m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size; - if (clrAddr && clrSize) { - PDETOUR_CLR_HEADER pHdr = (PDETOUR_CLR_HEADER)RvaToVa(clrAddr); - if (pHdr != NULL) { - DETOUR_CLR_HEADER hdr; - hdr = *pHdr; - - dh.nOriginalClrFlags = hdr.Flags; - } - } - - HRESULT hrRet = StringCchCopyA((PCHAR)m_SectionHeaders[nSection].Name, IMAGE_SIZEOF_SHORT_NAME, ".detour"); - if (FAILED(hrRet)) - return FALSE; - - m_SectionHeaders[nSection].Characteristics - = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE; - - m_nOutputVirtAddr = m_nNextVirtAddr; - m_nOutputVirtSize = 0; - m_nOutputFileAddr = m_nNextFileAddr; - - dh.nDataOffset = 0; // pbData - dh.cbDataSize = m_pImageData->m_cbData; - dh.cbPrePE = m_cbPrePE; - - ////////////////////////////////////////////////////////////////////////// - // - - DWORD rvaImportTable = 0; - DWORD rvaLookupTable = 0; - DWORD rvaBoundTable = 0; - DWORD rvaNameTable = 0; - DWORD nImportTableSize = nTables * sizeof(IMAGE_IMPORT_DESCRIPTOR); - - if (!SizeOutputBuffer(QuadAlign(sizeof(dh)) - + m_cbPrePE - + QuadAlign(m_pImageData->m_cbData) - + QuadAlign(sizeof(IMAGE_THUNK_DATA) * nThunks) - + QuadAlign(sizeof(IMAGE_THUNK_DATA) * nThunks) - + QuadAlign(nChars) - + QuadAlign(nImportTableSize))) { - return FALSE; - } - - DWORD vaHead = 0; - PBYTE pbHead = NULL; - DWORD vaPrePE = 0; - PBYTE pbPrePE = NULL; - DWORD vaData = 0; - PBYTE pbData = NULL; - - if ((pbHead = AllocateOutput(sizeof(dh), &vaHead)) == NULL) { - return FALSE; - } - - if ((pbPrePE = AllocateOutput(m_cbPrePE, &vaPrePE)) == NULL) { - return FALSE; - } - - CImageThunks lookupTable(this, nThunks, &rvaLookupTable); - CImageThunks boundTable(this, nThunks, &rvaBoundTable); - CImageChars nameTable(this, nChars, &rvaNameTable); - - if ((pbData = AllocateOutput(m_pImageData->m_cbData, &vaData)) == NULL) { - return FALSE; - } - - dh.nDataOffset = vaData - vaHead; - dh.cbDataSize = dh.nDataOffset + m_pImageData->m_cbData; - CopyMemory(pbHead, &dh, sizeof(dh)); - CopyMemory(pbPrePE, m_pMap + m_nPrePE, m_cbPrePE); - CopyMemory(pbData, m_pImageData->m_pbData, m_pImageData->m_cbData); - - PIMAGE_IMPORT_DESCRIPTOR piidDst = (PIMAGE_IMPORT_DESCRIPTOR) - AllocateOutput(nImportTableSize, &rvaImportTable); - if (piidDst == NULL) { - return FALSE; - } - - //////////////////////////////////////////////// Step Through Imports. - // - for (CImageImportFile *pImportFile = m_pImportFiles; - pImportFile != NULL; pImportFile = pImportFile->m_pNextFile) { - - ZeroMemory(piidDst, sizeof(piidDst)); - nameTable.Allocate(pImportFile->m_pszName, (DWORD *)&piidDst->Name); - piidDst->TimeDateStamp = 0; - piidDst->ForwarderChain = pImportFile->m_nForwarderChain; - - if (pImportFile->m_fByway) { - ULONG rvaIgnored; - - lookupTable.Allocate(IMAGE_ORDINAL_FLAG + 1, - (DWORD *)&piidDst->OriginalFirstThunk); - boundTable.Allocate(IMAGE_ORDINAL_FLAG + 1, - (DWORD *)&piidDst->FirstThunk); - - lookupTable.Allocate(0, &rvaIgnored); - boundTable.Allocate(0, &rvaIgnored); - } - else { - ULONG rvaIgnored; - - piidDst->FirstThunk = (ULONG)pImportFile->m_rvaFirstThunk; - lookupTable.Current((DWORD *)&piidDst->OriginalFirstThunk); - - for (n = 0; n < pImportFile->m_nImportNames; n++) { - CImageImportName *pImportName = &pImportFile->m_pImportNames[n]; - - if (pImportName->m_pszName) { - ULONG nDstName = 0; - - nameTable.Allocate(pImportName->m_pszName, - pImportName->m_nHint, - &nDstName); - lookupTable.Allocate(nDstName, &rvaIgnored); - } - else { - lookupTable.Allocate(IMAGE_ORDINAL_FLAG + pImportName->m_nOrdinal, - &rvaIgnored); - } - } - lookupTable.Allocate(0, &rvaIgnored); - } - piidDst++; - } - ZeroMemory(piidDst, sizeof(piidDst)); - - ////////////////////////////////////////////////////////////////////////// - // - m_nNextVirtAddr += m_nOutputVirtSize; - m_nNextFileAddr += FileAlign(m_nOutputVirtSize); - - if (!AlignFileData(hFile)) { - return FALSE; - } - - ////////////////////////////////////////////////////////////////////////// - // - m_SectionHeaders[nSection].VirtualAddress = m_nOutputVirtAddr; - m_SectionHeaders[nSection].Misc.VirtualSize = m_nOutputVirtSize; - m_SectionHeaders[nSection].PointerToRawData = m_nOutputFileAddr; - m_SectionHeaders[nSection].SizeOfRawData = FileAlign(m_nOutputVirtSize); - - m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress - = rvaImportTable; - m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size - = nImportTableSize; - - m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].VirtualAddress = 0; - m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].Size = 0; - - ////////////////////////////////////////////////////////////////////////// - // - if (SetFilePointer(hFile, m_SectionHeaders[nSection].PointerToRawData, - NULL, FILE_BEGIN) == ~0u) { - return FALSE; - } - if (!WriteFile(hFile, m_pbOutputBuffer, m_SectionHeaders[nSection].SizeOfRawData, - &cbDone)) { - return FALSE; - } - } - - ///////////////////////////////////////////////////// Adjust Extra Data. - // - LONG nExtraAdjust = m_nNextFileAddr - m_nExtraOffset; - for (n = 0; n < m_NtHeader.FileHeader.NumberOfSections; n++) { - if (m_SectionHeaders[n].PointerToRawData > m_nExtraOffset) { - m_SectionHeaders[n].PointerToRawData += nExtraAdjust; - } - if (m_SectionHeaders[n].PointerToRelocations > m_nExtraOffset) { - m_SectionHeaders[n].PointerToRelocations += nExtraAdjust; - } - if (m_SectionHeaders[n].PointerToLinenumbers > m_nExtraOffset) { - m_SectionHeaders[n].PointerToLinenumbers += nExtraAdjust; - } - } - if (m_NtHeader.FileHeader.PointerToSymbolTable > m_nExtraOffset) { - m_NtHeader.FileHeader.PointerToSymbolTable += nExtraAdjust; - } - - m_NtHeader.OptionalHeader.CheckSum = 0; - m_NtHeader.OptionalHeader.SizeOfImage = m_nNextVirtAddr; - - ////////////////////////////////////////////////// Adjust Debug Directory. - // - DWORD debugAddr = m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress; - DWORD debugSize = m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].Size; - if (debugAddr && debugSize) { - DWORD nFileOffset = RvaToFileOffset(debugAddr); - if (SetFilePointer(hFile, nFileOffset, NULL, FILE_BEGIN) == ~0u) { - return FALSE; - } - - PIMAGE_DEBUG_DIRECTORY pDir = (PIMAGE_DEBUG_DIRECTORY)RvaToVa(debugAddr); - if (pDir == NULL) { - return FALSE; - } - - DWORD nEntries = debugSize / sizeof(*pDir); - for (n = 0; n < nEntries; n++) { - IMAGE_DEBUG_DIRECTORY dir = pDir[n]; - - if (dir.PointerToRawData > m_nExtraOffset) { - dir.PointerToRawData += nExtraAdjust; - } - if (!WriteFile(hFile, &dir, sizeof(dir), &cbDone)) { - return FALSE; - } - } - } - - /////////////////////////////////////////////////////// Adjust CLR Header. - // - DWORD clrAddr = m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress; - DWORD clrSize = m_NtHeader.OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size; - if (clrAddr && clrSize && fNeedDetourSection) { - DWORD nFileOffset = RvaToFileOffset(clrAddr); - if (SetFilePointer(hFile, nFileOffset, NULL, FILE_BEGIN) == ~0u) { - return FALSE; - } - - PDETOUR_CLR_HEADER pHdr = (PDETOUR_CLR_HEADER)RvaToVa(clrAddr); - if (pHdr == NULL) { - return FALSE; - } - - DETOUR_CLR_HEADER hdr; - hdr = *pHdr; - hdr.Flags &= 0xfffffffe; // Clear the IL_ONLY flag. - - if (!WriteFile(hFile, &hdr, sizeof(hdr), &cbDone)) { - return FALSE; - } - } - - ///////////////////////////////////////////////// Copy Left-over Data. - // - if (m_nFileSize > m_nExtraOffset) { - if (SetFilePointer(hFile, m_nNextFileAddr, NULL, FILE_BEGIN) == ~0u) { - return FALSE; - } - if (!CopyFileData(hFile, m_nExtraOffset, m_nFileSize - m_nExtraOffset)) { - return FALSE; - } - } - - - //////////////////////////////////////////////////// Finalize Headers. - // - - if (SetFilePointer(hFile, m_nPeOffset, NULL, FILE_BEGIN) == ~0u) { - return FALSE; - } - if (!WriteFile(hFile, &m_NtHeader, sizeof(m_NtHeader), &cbDone)) { - return FALSE; - } - - if (SetFilePointer(hFile, m_nSectionsOffset, NULL, FILE_BEGIN) == ~0u) { - return FALSE; - } - if (!WriteFile(hFile, &m_SectionHeaders, - sizeof(m_SectionHeaders[0]) - * m_NtHeader.FileHeader.NumberOfSections, - &cbDone)) { - return FALSE; - } - - m_cbPostPE = SetFilePointer(hFile, 0, NULL, FILE_CURRENT); - if (m_cbPostPE == ~0u) { - return FALSE; - } - m_cbPostPE = m_NtHeader.OptionalHeader.SizeOfHeaders - m_cbPostPE; - - return TRUE; - } - -}; // namespace Detour - - -////////////////////////////////////////////////////////////////////////////// -// -PDETOUR_BINARY WINAPI DetourBinaryOpen(HANDLE hFile) -{ - Detour::CImage *pImage = new Detour::CImage; - if (pImage == NULL) { - SetLastError(ERROR_OUTOFMEMORY); - return FALSE; - } - - if (!pImage->Read(hFile)) { - delete pImage; - return FALSE; - } - - return (PDETOUR_BINARY)pImage; -} - -BOOL WINAPI DetourBinaryWrite(PDETOUR_BINARY pdi, HANDLE hFile) -{ - Detour::CImage *pImage = Detour::CImage::IsValid(pdi); - if (pImage == NULL) { - return FALSE; - } - - return pImage->Write(hFile); -} - -PVOID WINAPI DetourBinaryEnumeratePayloads(PDETOUR_BINARY pdi, - GUID *pGuid, - DWORD *pcbData, - DWORD *pnIterator) -{ - Detour::CImage *pImage = Detour::CImage::IsValid(pdi); - if (pImage == NULL) { - return FALSE; - } - - return pImage->DataEnum(pGuid, pcbData, pnIterator); -} - -PVOID WINAPI DetourBinaryFindPayload(PDETOUR_BINARY pdi, - REFGUID rguid, - DWORD *pcbData) -{ - Detour::CImage *pImage = Detour::CImage::IsValid(pdi); - if (pImage == NULL) { - return FALSE; - } - - return pImage->DataFind(rguid, pcbData); -} - -PVOID WINAPI DetourBinarySetPayload(PDETOUR_BINARY pdi, - REFGUID rguid, - PVOID pvData, - DWORD cbData) -{ - Detour::CImage *pImage = Detour::CImage::IsValid(pdi); - if (pImage == NULL) { - return FALSE; - } - - return pImage->DataSet(rguid, (PBYTE)pvData, cbData); -} - -BOOL WINAPI DetourBinaryDeletePayload(PDETOUR_BINARY pdi, - REFGUID rguid) -{ - Detour::CImage *pImage = Detour::CImage::IsValid(pdi); - if (pImage == NULL) { - return FALSE; - } - - return pImage->DataDelete(rguid); -} - -BOOL WINAPI DetourBinaryPurgePayloads(PDETOUR_BINARY pdi) -{ - Detour::CImage *pImage = Detour::CImage::IsValid(pdi); - if (pImage == NULL) { - return FALSE; - } - - return pImage->DataPurge(); -} - -////////////////////////////////////////////////////////////////////////////// -// -static BOOL CALLBACK ResetBywayCallback(PVOID pContext, - __in_z PCHAR pszFile, - __deref PCHAR *ppszOutFile) -{ - (void)pContext; - (void)pszFile; - - *ppszOutFile = NULL; - return TRUE; -} - -static BOOL CALLBACK ResetFileCallback(PVOID pContext, - __in_z PCHAR pszOrigFile, - __in_z PCHAR pszFile, - __deref PCHAR *ppszOutFile) -{ - (void)pContext; - (void)pszFile; - - *ppszOutFile = pszOrigFile; - return TRUE; -} - -static BOOL CALLBACK ResetSymbolCallback(PVOID pContext, - ULONG nOrigOrdinal, - ULONG nOrdinal, - ULONG *pnOutOrdinal, - __in_z PCHAR pszOrigSymbol, - __in_z PCHAR pszSymbol, - __deref PCHAR *ppszOutSymbol) -{ - (void)pContext; - (void)nOrdinal; - (void)pszSymbol; - - *pnOutOrdinal = nOrigOrdinal; - *ppszOutSymbol = pszOrigSymbol; - return TRUE; -} - -BOOL WINAPI DetourBinaryResetImports(PDETOUR_BINARY pdi) -{ - Detour::CImage *pImage = Detour::CImage::IsValid(pdi); - if (pImage == NULL) { - return FALSE; - } - - return pImage->EditImports(NULL, - ResetBywayCallback, - ResetFileCallback, - ResetSymbolCallback, - NULL); -} - -////////////////////////////////////////////////////////////////////////////// -// -BOOL WINAPI DetourBinaryEditImports(PDETOUR_BINARY pdi, - PVOID pContext, - PF_DETOUR_BINARY_BYWAY_CALLBACK pfBywayCallback, - PF_DETOUR_BINARY_FILE_CALLBACK pfFileCallback, - PF_DETOUR_BINARY_SYMBOL_CALLBACK pfSymbolCallback, - PF_DETOUR_BINARY_COMMIT_CALLBACK pfCommitCallback) -{ - Detour::CImage *pImage = Detour::CImage::IsValid(pdi); - if (pImage == NULL) { - return FALSE; - } - - return pImage->EditImports(pContext, - pfBywayCallback, - pfFileCallback, - pfSymbolCallback, - pfCommitCallback); -} - -BOOL WINAPI DetourBinaryClose(PDETOUR_BINARY pdi) -{ - Detour::CImage *pImage = Detour::CImage::IsValid(pdi); - if (pImage == NULL) { - return FALSE; - } - - BOOL bSuccess = pImage->Close(); - delete pImage; - pImage = NULL; - - return bSuccess; -} - -// -///////////////////////////////////////////////////////////////// End of File. diff --git a/Detours/modules.cpp b/Detours/modules.cpp deleted file mode 100644 index b2de917..0000000 --- a/Detours/modules.cpp +++ /dev/null @@ -1,928 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Module Enumeration Functions (modules.cpp of detours.lib) -// -// Microsoft Research Detours Package, Version 3.0 Build_316. -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// Module enumeration functions. -// - -#include -#if (_MSC_VER < 1310) -#else -#include -#endif - -//#define DETOUR_DEBUG 1 -#define DETOURS_INTERNAL -#include "detours.h" - -#define CLR_DIRECTORY OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR] -#define IAT_DIRECTORY OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT] - -////////////////////////////////////////////////////////////////////////////// -// -#ifndef _STRSAFE_H_INCLUDED_ -static inline HRESULT StringCchLengthA(const char* psz, size_t cchMax, size_t* pcch) -{ - HRESULT hr = S_OK; - size_t cchMaxPrev = cchMax; - - if (cchMax > 2147483647) - { - return ERROR_INVALID_PARAMETER; - } - - while (cchMax && (*psz != '\0')) - { - psz++; - cchMax--; - } - - if (cchMax == 0) - { - // the string is longer than cchMax - hr = ERROR_INVALID_PARAMETER; - } - - if (SUCCEEDED(hr) && pcch) - { - *pcch = cchMaxPrev - cchMax; - } - - return hr; -} - - -static inline HRESULT StringCchCopyA(char* pszDest, size_t cchDest, const char* pszSrc) -{ - HRESULT hr = S_OK; - - if (cchDest == 0) - { - // can not null terminate a zero-byte dest buffer - hr = ERROR_INVALID_PARAMETER; - } - else - { - while (cchDest && (*pszSrc != '\0')) - { - *pszDest++ = *pszSrc++; - cchDest--; - } - - if (cchDest == 0) - { - // we are going to truncate pszDest - pszDest--; - hr = ERROR_INVALID_PARAMETER; - } - - *pszDest = '\0'; - } - - return hr; -} - -static inline HRESULT StringCchCatA(char* pszDest, size_t cchDest, const char* pszSrc) -{ - HRESULT hr; - size_t cchDestCurrent; - - if (cchDest > 2147483647) - { - return ERROR_INVALID_PARAMETER; - } - - hr = StringCchLengthA(pszDest, cchDest, &cchDestCurrent); - - if (SUCCEEDED(hr)) - { - hr = StringCchCopyA(pszDest + cchDestCurrent, - cchDest - cchDestCurrent, - pszSrc); - } - - return hr; -} - -#endif - -////////////////////////////////////////////////////////////////////////////// -// -const GUID DETOUR_EXE_RESTORE_GUID = { - 0x2ed7a3ff, 0x3339, 0x4a8d, - { 0x80, 0x5c, 0xd4, 0x98, 0x15, 0x3f, 0xc2, 0x8f } }; - -const GUID DETOUR_EXE_HELPER_GUID = { /* ea0251b9-5cde-41b5-98d0-2af4a26b0fee */ - 0xea0251b9, 0x5cde, 0x41b5, - { 0x98, 0xd0, 0x2a, 0xf4, 0xa2, 0x6b, 0x0f, 0xee } }; - -////////////////////////////////////////////////////////////////////////////// -// -PDETOUR_SYM_INFO DetourLoadImageHlp(VOID) -{ - static DETOUR_SYM_INFO symInfo; - static PDETOUR_SYM_INFO pSymInfo = NULL; - static BOOL failed = false; - - if (failed) { - return NULL; - } - if (pSymInfo != NULL) { - return pSymInfo; - } - - ZeroMemory(&symInfo, sizeof(symInfo)); - // Create a real handle to the process. -#if 0 - DuplicateHandle(GetCurrentProcess(), - GetCurrentProcess(), - GetCurrentProcess(), - &symInfo.hProcess, - 0, - FALSE, - DUPLICATE_SAME_ACCESS); -#else - symInfo.hProcess = GetCurrentProcess(); -#endif - - symInfo.hDbgHelp = LoadLibraryExW(L"dbghelp.dll", NULL, 0); - if (symInfo.hDbgHelp == NULL) { - abort: - failed = true; - if (symInfo.hDbgHelp != NULL) { - FreeLibrary(symInfo.hDbgHelp); - } - symInfo.pfImagehlpApiVersionEx = NULL; - symInfo.pfSymInitialize = NULL; - symInfo.pfSymSetOptions = NULL; - symInfo.pfSymGetOptions = NULL; - symInfo.pfSymLoadModule64 = NULL; - symInfo.pfSymGetModuleInfo64 = NULL; - symInfo.pfSymFromName = NULL; - return NULL; - } - - symInfo.pfImagehlpApiVersionEx - = (PF_ImagehlpApiVersionEx)GetProcAddress(symInfo.hDbgHelp, - "ImagehlpApiVersionEx"); - symInfo.pfSymInitialize - = (PF_SymInitialize)GetProcAddress(symInfo.hDbgHelp, "SymInitialize"); - symInfo.pfSymSetOptions - = (PF_SymSetOptions)GetProcAddress(symInfo.hDbgHelp, "SymSetOptions"); - symInfo.pfSymGetOptions - = (PF_SymGetOptions)GetProcAddress(symInfo.hDbgHelp, "SymGetOptions"); - symInfo.pfSymLoadModule64 - = (PF_SymLoadModule64)GetProcAddress(symInfo.hDbgHelp, "SymLoadModule64"); - symInfo.pfSymGetModuleInfo64 - = (PF_SymGetModuleInfo64)GetProcAddress(symInfo.hDbgHelp, "SymGetModuleInfo64"); - symInfo.pfSymFromName - = (PF_SymFromName)GetProcAddress(symInfo.hDbgHelp, "SymFromName"); - - API_VERSION av; - ZeroMemory(&av, sizeof(av)); - av.MajorVersion = API_VERSION_NUMBER; - - if (symInfo.pfImagehlpApiVersionEx == NULL || - symInfo.pfSymInitialize == NULL || - symInfo.pfSymLoadModule64 == NULL || - symInfo.pfSymGetModuleInfo64 == NULL || - symInfo.pfSymFromName == NULL) { - goto abort; - } - - symInfo.pfImagehlpApiVersionEx(&av); - if (av.MajorVersion < API_VERSION_NUMBER) { - goto abort; - } - - if (!symInfo.pfSymInitialize(symInfo.hProcess, NULL, FALSE)) { - // We won't retry the initialize if it fails. - goto abort; - } - - if (symInfo.pfSymGetOptions != NULL && symInfo.pfSymSetOptions != NULL) { - DWORD dw = symInfo.pfSymGetOptions(); - - dw &= ~(SYMOPT_CASE_INSENSITIVE | - SYMOPT_UNDNAME | - SYMOPT_DEFERRED_LOADS | - 0); - dw |= ( -#if defined(SYMOPT_EXACT_SYMBOLS) - SYMOPT_EXACT_SYMBOLS | -#endif -#if defined(SYMOPT_NO_UNQUALIFIED_LOADS) - SYMOPT_NO_UNQUALIFIED_LOADS | -#endif - SYMOPT_DEFERRED_LOADS | -#if defined(SYMOPT_FAIL_CRITICAL_ERRORS) - SYMOPT_FAIL_CRITICAL_ERRORS | -#endif -#if defined(SYMOPT_INCLUDE_32BIT_MODULES) - SYMOPT_INCLUDE_32BIT_MODULES | -#endif - 0); - symInfo.pfSymSetOptions(dw); - } - - pSymInfo = &symInfo; - return pSymInfo; -} - -PVOID WINAPI DetourFindFunction(PCSTR pszModule, PCSTR pszFunction) -{ - /////////////////////////////////////////////// First, try GetProcAddress. - // - HMODULE hModule = LoadLibraryExA(pszModule, NULL, 0); - if (hModule == NULL) { - return NULL; - } - - PBYTE pbCode = (PBYTE)GetProcAddress(hModule, pszFunction); - if (pbCode) { - return pbCode; - } - - ////////////////////////////////////////////////////// Then try ImageHelp. - // - DETOUR_TRACE(("DetourFindFunction(%s, %s)\n", pszModule, pszFunction)); - PDETOUR_SYM_INFO pSymInfo = DetourLoadImageHlp(); - if (pSymInfo == NULL) { - DETOUR_TRACE(("DetourLoadImageHlp failed: %d\n", - GetLastError())); - return NULL; - } - - if (pSymInfo->pfSymLoadModule64(pSymInfo->hProcess, NULL, - (PCHAR)pszModule, NULL, - (DWORD64)hModule, 0) == 0) { - if (ERROR_SUCCESS != GetLastError()) { - DETOUR_TRACE(("SymLoadModule64(%p) failed: %d\n", - pSymInfo->hProcess, GetLastError())); - return NULL; - } - } - - HRESULT hrRet; - CHAR szFullName[512]; - IMAGEHLP_MODULE64 modinfo; - ZeroMemory(&modinfo, sizeof(modinfo)); - modinfo.SizeOfStruct = sizeof(modinfo); - if (!pSymInfo->pfSymGetModuleInfo64(pSymInfo->hProcess, (DWORD64)hModule, &modinfo)) { - DETOUR_TRACE(("SymGetModuleInfo64(%p, %p) failed: %d\n", - pSymInfo->hProcess, hModule, GetLastError())); - return NULL; - } - - hrRet = StringCchCopyA(szFullName, sizeof(szFullName) / sizeof(CHAR), modinfo.ModuleName); - if (FAILED(hrRet)) { - DETOUR_TRACE(("StringCchCopyA failed: %08x\n", hrRet)); - return NULL; - } - hrRet = StringCchCatA(szFullName, sizeof(szFullName) / sizeof(CHAR), "!"); - if (FAILED(hrRet)) { - DETOUR_TRACE(("StringCchCatA failed: %08x\n", hrRet)); - return NULL; - } - hrRet = StringCchCatA(szFullName, sizeof(szFullName) / sizeof(CHAR), pszFunction); - if (FAILED(hrRet)) { - DETOUR_TRACE(("StringCchCatA failed: %08x\n", hrRet)); - return NULL; - } - - struct CFullSymbol : SYMBOL_INFO { - CHAR szRestOfName[512]; - } symbol; - ZeroMemory(&symbol, sizeof(symbol)); - //symbol.ModBase = (ULONG64)hModule; - symbol.SizeOfStruct = sizeof(SYMBOL_INFO); -#ifdef DBHLPAPI - symbol.MaxNameLen = sizeof(symbol.szRestOfName) / sizeof(symbol.szRestOfName[0]); -#else - symbol.MaxNameLength = sizeof(symbol.szRestOfName) / sizeof(symbol.szRestOfName[0]); -#endif - - if (!pSymInfo->pfSymFromName(pSymInfo->hProcess, szFullName, &symbol)) { - DETOUR_TRACE(("SymFromName(%s) failed: %d\n", szFullName, GetLastError())); - return NULL; - } - -#if defined(DETOURS_IA64) - // On the IA64, we get a raw code pointer from the symbol engine - // and have to convert it to a wrapped [code pointer, global pointer]. - // - PPLABEL_DESCRIPTOR pldEntry = (PPLABEL_DESCRIPTOR)DetourGetEntryPoint(hModule); - PPLABEL_DESCRIPTOR pldSymbol = new PLABEL_DESCRIPTOR; - - pldSymbol->EntryPoint = symbol.Address; - pldSymbol->GlobalPointer = pldEntry->GlobalPointer; - return (PBYTE)pldSymbol; -#elif defined(DETOURS_ARM) - // On the ARM, we get a raw code pointer, which we must convert into a - // valied Thumb2 function pointer. - return DETOURS_PBYTE_TO_PFUNC(symbol.Address); -#else - return (PBYTE)symbol.Address; -#endif -} - -//////////////////////////////////////////////////// Module Image Functions. -// -HMODULE WINAPI DetourEnumerateModules(HMODULE hModuleLast) -{ - PBYTE pbLast; - - if (hModuleLast == NULL) { - pbLast = (PBYTE)0x10000; - } - else { - pbLast = (PBYTE)hModuleLast + 0x10000; - } - - MEMORY_BASIC_INFORMATION mbi; - ZeroMemory(&mbi, sizeof(mbi)); - - // Find the next memory region that contains a mapped PE image. - // - for (;; pbLast = (PBYTE)mbi.BaseAddress + mbi.RegionSize) { - if (VirtualQuery((PVOID)pbLast, &mbi, sizeof(mbi)) <= 0) { - break; - } - - // Skip uncommitted regions and guard pages. - // - if ((mbi.State != MEM_COMMIT) || - ((mbi.Protect & 0xff) == PAGE_NOACCESS) || - (mbi.Protect & PAGE_GUARD)) { - continue; - } - - __try { - PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)pbLast; - if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE || - (DWORD)pDosHeader->e_lfanew > mbi.RegionSize || - (DWORD)pDosHeader->e_lfanew < sizeof(*pDosHeader)) { - continue; - } - - PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)((PBYTE)pDosHeader + - pDosHeader->e_lfanew); - if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) { - continue; - } - - return (HMODULE)pDosHeader; - } - __except (EXCEPTION_EXECUTE_HANDLER) { - continue; - } - } - return NULL; -} - -PVOID WINAPI DetourGetEntryPoint(HMODULE hModule) -{ - PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)hModule; - if (hModule == NULL) { - pDosHeader = (PIMAGE_DOS_HEADER)GetModuleHandleW(NULL); - } - - __try { - if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) { - SetLastError(ERROR_BAD_EXE_FORMAT); - return NULL; - } - - PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)((PBYTE)pDosHeader + - pDosHeader->e_lfanew); - if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) { - SetLastError(ERROR_INVALID_EXE_SIGNATURE); - return NULL; - } - if (pNtHeader->FileHeader.SizeOfOptionalHeader == 0) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return NULL; - } - - PDETOUR_CLR_HEADER pClrHeader = NULL; - if (pNtHeader->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) { - if (((PIMAGE_NT_HEADERS32)pNtHeader)->CLR_DIRECTORY.VirtualAddress != 0 && - ((PIMAGE_NT_HEADERS32)pNtHeader)->CLR_DIRECTORY.Size != 0) { - pClrHeader = (PDETOUR_CLR_HEADER) - (((PBYTE)pDosHeader) - + ((PIMAGE_NT_HEADERS32)pNtHeader)->CLR_DIRECTORY.VirtualAddress); - } - } - else if (pNtHeader->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) { - if (((PIMAGE_NT_HEADERS64)pNtHeader)->CLR_DIRECTORY.VirtualAddress != 0 && - ((PIMAGE_NT_HEADERS64)pNtHeader)->CLR_DIRECTORY.Size != 0) { - pClrHeader = (PDETOUR_CLR_HEADER) - (((PBYTE)pDosHeader) - + ((PIMAGE_NT_HEADERS64)pNtHeader)->CLR_DIRECTORY.VirtualAddress); - } - } - - if (pClrHeader != NULL) { - // For MSIL assemblies, we want to use the _Cor entry points. - - HMODULE hClr = GetModuleHandleW(L"MSCOREE.DLL"); - if (hClr == NULL) { - return NULL; - } - - SetLastError(NO_ERROR); - return GetProcAddress(hClr, "_CorExeMain"); - } - - SetLastError(NO_ERROR); - return ((PBYTE)pDosHeader) + - pNtHeader->OptionalHeader.AddressOfEntryPoint; - } - __except (EXCEPTION_EXECUTE_HANDLER) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return NULL; - } -} - -ULONG WINAPI DetourGetModuleSize(HMODULE hModule) -{ - PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)hModule; - if (hModule == NULL) { - pDosHeader = (PIMAGE_DOS_HEADER)GetModuleHandleW(NULL); - } - - __try { - if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) { - SetLastError(ERROR_BAD_EXE_FORMAT); - return NULL; - } - - PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)((PBYTE)pDosHeader + - pDosHeader->e_lfanew); - if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) { - SetLastError(ERROR_INVALID_EXE_SIGNATURE); - return NULL; - } - if (pNtHeader->FileHeader.SizeOfOptionalHeader == 0) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return NULL; - } - SetLastError(NO_ERROR); - - return (pNtHeader->OptionalHeader.SizeOfImage); - } - __except (EXCEPTION_EXECUTE_HANDLER) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return NULL; - } -} - -HMODULE WINAPI DetourGetContainingModule(PVOID pvAddr) -{ - MEMORY_BASIC_INFORMATION mbi; - ZeroMemory(&mbi, sizeof(mbi)); - - __try { - if (VirtualQuery(pvAddr, &mbi, sizeof(mbi)) <= 0) { - SetLastError(ERROR_BAD_EXE_FORMAT); - return NULL; - } - - // Skip uncommitted regions and guard pages. - // - if ((mbi.State != MEM_COMMIT) || - ((mbi.Protect & 0xff) == PAGE_NOACCESS) || - (mbi.Protect & PAGE_GUARD)) { - SetLastError(ERROR_BAD_EXE_FORMAT); - return NULL; - } - - PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)mbi.AllocationBase; - if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) { - SetLastError(ERROR_BAD_EXE_FORMAT); - return NULL; - } - - PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)((PBYTE)pDosHeader + - pDosHeader->e_lfanew); - if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) { - SetLastError(ERROR_INVALID_EXE_SIGNATURE); - return NULL; - } - if (pNtHeader->FileHeader.SizeOfOptionalHeader == 0) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return NULL; - } - SetLastError(NO_ERROR); - - return (HMODULE)pDosHeader; - } - __except (EXCEPTION_EXECUTE_HANDLER) { - SetLastError(ERROR_INVALID_EXE_SIGNATURE); - return NULL; - } -} - - -static inline PBYTE RvaAdjust(PIMAGE_DOS_HEADER pDosHeader, DWORD raddr) -{ - if (raddr != NULL) { - return ((PBYTE)pDosHeader) + raddr; - } - return NULL; -} - -BOOL WINAPI DetourEnumerateExports(HMODULE hModule, - PVOID pContext, - PF_DETOUR_ENUMERATE_EXPORT_CALLBACK pfExport) -{ - PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)hModule; - if (hModule == NULL) { - pDosHeader = (PIMAGE_DOS_HEADER)GetModuleHandleW(NULL); - } - - __try { - if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) { - SetLastError(ERROR_BAD_EXE_FORMAT); - return NULL; - } - - PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)((PBYTE)pDosHeader + - pDosHeader->e_lfanew); - if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) { - SetLastError(ERROR_INVALID_EXE_SIGNATURE); - return FALSE; - } - if (pNtHeader->FileHeader.SizeOfOptionalHeader == 0) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return FALSE; - } - - PIMAGE_EXPORT_DIRECTORY pExportDir - = (PIMAGE_EXPORT_DIRECTORY) - RvaAdjust(pDosHeader, - pNtHeader->OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress); - - if (pExportDir == NULL) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return FALSE; - } - - PDWORD pdwFunctions = (PDWORD)RvaAdjust(pDosHeader, pExportDir->AddressOfFunctions); - PDWORD pdwNames = (PDWORD)RvaAdjust(pDosHeader, pExportDir->AddressOfNames); - PWORD pwOrdinals = (PWORD)RvaAdjust(pDosHeader, pExportDir->AddressOfNameOrdinals); - - for (DWORD nFunc = 0; nFunc < pExportDir->NumberOfFunctions; nFunc++) { - PBYTE pbCode = (pdwFunctions != NULL) - ? (PBYTE)RvaAdjust(pDosHeader, pdwFunctions[nFunc]) : NULL; - PCHAR pszName = NULL; - for (DWORD n = 0; n < pExportDir->NumberOfNames; n++) { - if (pwOrdinals[n] == nFunc) { - pszName = (pdwNames != NULL) - ? (PCHAR)RvaAdjust(pDosHeader, pdwNames[n]) : NULL; - break; - } - } - ULONG nOrdinal = pExportDir->Base + nFunc; - - if (!pfExport(pContext, nOrdinal, pszName, pbCode)) { - break; - } - } - SetLastError(NO_ERROR); - return TRUE; - } - __except (EXCEPTION_EXECUTE_HANDLER) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return NULL; - } -} - -BOOL WINAPI DetourEnumerateImports(HMODULE hModule, - PVOID pContext, - PF_DETOUR_IMPORT_FILE_CALLBACK pfImportFile, - PF_DETOUR_IMPORT_FUNC_CALLBACK pfImportFunc) -{ - PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)hModule; - if (hModule == NULL) { - pDosHeader = (PIMAGE_DOS_HEADER)GetModuleHandleW(NULL); - } - - __try { - if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) { - SetLastError(ERROR_BAD_EXE_FORMAT); - return FALSE; - } - - PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)((PBYTE)pDosHeader + - pDosHeader->e_lfanew); - if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) { - SetLastError(ERROR_INVALID_EXE_SIGNATURE); - return FALSE; - } - if (pNtHeader->FileHeader.SizeOfOptionalHeader == 0) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return FALSE; - } - - PIMAGE_IMPORT_DESCRIPTOR iidp - = (PIMAGE_IMPORT_DESCRIPTOR) - RvaAdjust(pDosHeader, - pNtHeader->OptionalHeader - .DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress); - - if (iidp == NULL) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return FALSE; - } - - for (; iidp->OriginalFirstThunk != 0; iidp++) { - - PCSTR pszName = (PCHAR)RvaAdjust(pDosHeader, iidp->Name); - if (pszName == NULL) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return FALSE; - } - - PIMAGE_THUNK_DATA pThunks = (PIMAGE_THUNK_DATA) - RvaAdjust(pDosHeader, iidp->OriginalFirstThunk); - PVOID * pAddrs = (PVOID *) - RvaAdjust(pDosHeader, iidp->FirstThunk); - - HMODULE hFile = DetourGetContainingModule(pAddrs[0]); - - if (pfImportFile != NULL) { - if (!pfImportFile(pContext, hFile, pszName)) { - break; - } - } - - DWORD nNames = 0; - if (pThunks) { - for (; pThunks[nNames].u1.Ordinal; nNames++) { - DWORD nOrdinal = 0; - PCSTR pszFunc = NULL; - - if (IMAGE_SNAP_BY_ORDINAL(pThunks[nNames].u1.Ordinal)) { - nOrdinal = (DWORD)IMAGE_ORDINAL(pThunks[nNames].u1.Ordinal); - } - else { - pszFunc = (PCSTR)RvaAdjust(pDosHeader, - (DWORD)pThunks[nNames].u1.AddressOfData + 2); - } - - if (pfImportFunc != NULL) { - if (!pfImportFunc(pContext, - nOrdinal, - pszFunc, - pAddrs[nNames])) { - break; - } - } - } - if (pfImportFunc != NULL) { - pfImportFunc(pContext, 0, NULL, NULL); - } - } - } - if (pfImportFile != NULL) { - pfImportFile(pContext, NULL, NULL); - } - SetLastError(NO_ERROR); - return TRUE; - } - __except (EXCEPTION_EXECUTE_HANDLER) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return FALSE; - } -} - -static PDETOUR_LOADED_BINARY WINAPI GetPayloadSectionFromModule(HMODULE hModule) -{ - PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)hModule; - if (hModule == NULL) { - pDosHeader = (PIMAGE_DOS_HEADER)GetModuleHandleW(NULL); - } - - __try { - if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) { - SetLastError(ERROR_BAD_EXE_FORMAT); - return NULL; - } - - PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)((PBYTE)pDosHeader + - pDosHeader->e_lfanew); - if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) { - SetLastError(ERROR_INVALID_EXE_SIGNATURE); - return NULL; - } - if (pNtHeader->FileHeader.SizeOfOptionalHeader == 0) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return NULL; - } - - PIMAGE_SECTION_HEADER pSectionHeaders - = (PIMAGE_SECTION_HEADER)((PBYTE)pNtHeader - + sizeof(pNtHeader->Signature) - + sizeof(pNtHeader->FileHeader) - + pNtHeader->FileHeader.SizeOfOptionalHeader); - - for (DWORD n = 0; n < pNtHeader->FileHeader.NumberOfSections; n++) { - if (strcmp((PCHAR)pSectionHeaders[n].Name, ".detour") == 0) { - if (pSectionHeaders[n].VirtualAddress == 0 || - pSectionHeaders[n].SizeOfRawData == 0) { - - break; - } - - PBYTE pbData = (PBYTE)pDosHeader + pSectionHeaders[n].VirtualAddress; - DETOUR_SECTION_HEADER *pHeader = (DETOUR_SECTION_HEADER *)pbData; - if (pHeader->cbHeaderSize < sizeof(DETOUR_SECTION_HEADER) || - pHeader->nSignature != DETOUR_SECTION_HEADER_SIGNATURE) { - - break; - } - - if (pHeader->nDataOffset == 0) { - pHeader->nDataOffset = pHeader->cbHeaderSize; - } - SetLastError(NO_ERROR); - return (PBYTE)pHeader; - } - } - SetLastError(ERROR_EXE_MARKED_INVALID); - return NULL; - } - __except (EXCEPTION_EXECUTE_HANDLER) { - SetLastError(ERROR_EXE_MARKED_INVALID); - return NULL; - } -} - -DWORD WINAPI DetourGetSizeOfPayloads(HMODULE hModule) -{ - PDETOUR_LOADED_BINARY pBinary = GetPayloadSectionFromModule(hModule); - if (pBinary == NULL) { - // Error set by GetPayloadSectionFromModule. - return 0; - } - - __try { - DETOUR_SECTION_HEADER *pHeader = (DETOUR_SECTION_HEADER *)pBinary; - if (pHeader->cbHeaderSize < sizeof(DETOUR_SECTION_HEADER) || - pHeader->nSignature != DETOUR_SECTION_HEADER_SIGNATURE) { - - SetLastError(ERROR_INVALID_HANDLE); - return 0; - } - SetLastError(NO_ERROR); - return pHeader->cbDataSize; - } - __except (EXCEPTION_EXECUTE_HANDLER) { - SetLastError(ERROR_INVALID_HANDLE); - return 0; - } -} - -PVOID WINAPI DetourFindPayload(HMODULE hModule, REFGUID rguid, DWORD * pcbData) -{ - PBYTE pbData = NULL; - if (pcbData) { - *pcbData = 0; - } - - PDETOUR_LOADED_BINARY pBinary = GetPayloadSectionFromModule(hModule); - if (pBinary == NULL) { - // Error set by GetPayloadSectionFromModule. - return NULL; - } - - __try { - DETOUR_SECTION_HEADER *pHeader = (DETOUR_SECTION_HEADER *)pBinary; - if (pHeader->cbHeaderSize < sizeof(DETOUR_SECTION_HEADER) || - pHeader->nSignature != DETOUR_SECTION_HEADER_SIGNATURE) { - - SetLastError(ERROR_INVALID_EXE_SIGNATURE); - return NULL; - } - - PBYTE pbBeg = ((PBYTE)pHeader) + pHeader->nDataOffset; - PBYTE pbEnd = ((PBYTE)pHeader) + pHeader->cbDataSize; - - for (pbData = pbBeg; pbData < pbEnd;) { - DETOUR_SECTION_RECORD *pSection = (DETOUR_SECTION_RECORD *)pbData; - - if (pSection->guid.Data1 == rguid.Data1 && - pSection->guid.Data2 == rguid.Data2 && - pSection->guid.Data3 == rguid.Data3 && - pSection->guid.Data4[0] == rguid.Data4[0] && - pSection->guid.Data4[1] == rguid.Data4[1] && - pSection->guid.Data4[2] == rguid.Data4[2] && - pSection->guid.Data4[3] == rguid.Data4[3] && - pSection->guid.Data4[4] == rguid.Data4[4] && - pSection->guid.Data4[5] == rguid.Data4[5] && - pSection->guid.Data4[6] == rguid.Data4[6] && - pSection->guid.Data4[7] == rguid.Data4[7]) { - - if (pcbData) { - *pcbData = pSection->cbBytes - sizeof(*pSection); - SetLastError(NO_ERROR); - return (PBYTE)(pSection + 1); - } - } - - pbData = (PBYTE)pSection + pSection->cbBytes; - } - SetLastError(ERROR_INVALID_HANDLE); - return NULL; - } - __except (EXCEPTION_EXECUTE_HANDLER) { - SetLastError(ERROR_INVALID_HANDLE); - return NULL; - } -} - -PVOID WINAPI DetourFindPayloadEx(REFGUID rguid, DWORD * pcbData) -{ - for (HMODULE hMod = NULL; (hMod = DetourEnumerateModules(hMod)) != NULL;) { - PVOID pvData; - - pvData = DetourFindPayload(hMod, rguid, pcbData); - if (pvData != NULL) { - return pvData; - } - } - SetLastError(ERROR_MOD_NOT_FOUND); - return NULL; -} - -BOOL WINAPI DetourRestoreAfterWithEx(PVOID pvData, DWORD cbData) -{ - PDETOUR_EXE_RESTORE pder = (PDETOUR_EXE_RESTORE)pvData; - - if (pder->cb != sizeof(*pder) || pder->cb > cbData) { - SetLastError(ERROR_BAD_EXE_FORMAT); - return FALSE; - } - - DWORD dwPermIdh = ~0u; - DWORD dwPermInh = ~0u; - DWORD dwPermClr = ~0u; - DWORD dwIgnore; - BOOL fSucceeded = FALSE; - -#if 0 - if (pder->pclr != NULL && pder->clr.Flags != ((PDETOUR_CLR_HEADER)pder->pclr)->Flags) { - // If we had to promote the 32/64-bit agnostic IL to 64-bit, we don't want - // to restore its IAT. - __debugbreak(); - return TRUE; - } -#endif - - if (VirtualProtect(pder->pidh, pder->cbidh, - PAGE_EXECUTE_READWRITE, &dwPermIdh)) { - if (VirtualProtect(pder->pinh, pder->cbinh, - PAGE_EXECUTE_READWRITE, &dwPermInh)) { - - CopyMemory(pder->pidh, &pder->idh, pder->cbidh); - CopyMemory(pder->pinh, &pder->inh, pder->cbinh); - - if (pder->pclr != NULL) { - if (VirtualProtect(pder->pclr, pder->cbclr, - PAGE_EXECUTE_READWRITE, &dwPermClr)) { - CopyMemory(pder->pclr, &pder->clr, pder->cbclr); - VirtualProtect(pder->pclr, pder->cbclr, dwPermClr, &dwIgnore); - fSucceeded = TRUE; - } - } - else { - fSucceeded = TRUE; - } - VirtualProtect(pder->pinh, pder->cbinh, dwPermInh, &dwIgnore); - } - VirtualProtect(pder->pidh, pder->cbidh, dwPermIdh, &dwIgnore); - } - return fSucceeded; -} - -BOOL WINAPI DetourRestoreAfterWith() -{ - PVOID pvData; - DWORD cbData; - - pvData = DetourFindPayloadEx(DETOUR_EXE_RESTORE_GUID, &cbData); - - if (pvData != NULL && cbData != 0) { - return DetourRestoreAfterWithEx(pvData, cbData); - } - SetLastError(ERROR_MOD_NOT_FOUND); - return FALSE; -} - -// End of File diff --git a/ExceptHandle.h b/ExceptHandle.h deleted file mode 100644 index ffe5dc1..0000000 --- a/ExceptHandle.h +++ /dev/null @@ -1,22 +0,0 @@ -struct EXCEPTION_REGISTRATION -{ - EXCEPTION_REGISTRATION *prev; - FARPROC handler; -}; - -extern "C" int _except_handler3(PEXCEPTION_RECORD, EXCEPTION_REGISTRATION *, PCONTEXT, PEXCEPTION_RECORD); -extern "C" int _except_handler4(PEXCEPTION_RECORD, EXCEPTION_REGISTRATION *, CONTEXT *, void *); - -#define SetupExceptHandler3() \ - DWORD handler = (DWORD)_except_handler3; \ -\ - __asm push handler \ - __asm push FS:[0] \ - __asm mov FS:[0], ESP - -#define SetupExceptHandler4() \ - DWORD handler = (DWORD)_except_handler4; \ -\ - __asm push handler \ - __asm push FS:[0] \ - __asm mov FS:[0], ESP diff --git a/Plugins/Audio/HL1-REVERB.ods b/HL1-REVERB.ods similarity index 100% rename from Plugins/Audio/HL1-REVERB.ods rename to HL1-REVERB.ods diff --git a/HLSDK/cl_dll/parsemsg.cpp b/HLSDK/cl_dll/parsemsg.cpp deleted file mode 100644 index bdfa413..0000000 --- a/HLSDK/cl_dll/parsemsg.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// -// parsemsg.cpp -// -typedef unsigned char byte; -#define true 1 - -static byte *gpBuf; -static int giSize; -static int giRead; -static int giBadRead; - -void BEGIN_READ( void *buf, int size ) -{ - giRead = 0; - giBadRead = 0; - giSize = size; - gpBuf = (byte*)buf; -} - - -int READ_CHAR( void ) -{ - int c; - - if (giRead + 1 > giSize) - { - giBadRead = true; - return -1; - } - - c = (signed char)gpBuf[giRead]; - giRead++; - - return c; -} - -int READ_BYTE( void ) -{ - int c; - - if (giRead+1 > giSize) - { - giBadRead = true; - return -1; - } - - c = (unsigned char)gpBuf[giRead]; - giRead++; - - return c; -} - -int READ_SHORT( void ) -{ - int c; - - if (giRead+2 > giSize) - { - giBadRead = true; - return -1; - } - - c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) ); - - giRead += 2; - - return c; -} - -int READ_WORD( void ) -{ - return READ_SHORT(); -} - - -int READ_LONG( void ) -{ - int c; - - if (giRead+4 > giSize) - { - giBadRead = true; - return -1; - } - - c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24); - - giRead += 4; - - return c; -} - -float READ_FLOAT( void ) -{ - union - { - byte b[4]; - float f; - int l; - } dat; - - dat.b[0] = gpBuf[giRead]; - dat.b[1] = gpBuf[giRead+1]; - dat.b[2] = gpBuf[giRead+2]; - dat.b[3] = gpBuf[giRead+3]; - giRead += 4; - -// dat.l = LittleLong (dat.l); - - return dat.f; -} - -char* READ_STRING( void ) -{ - static char string[2048]; - int l,c; - - string[0] = 0; - - l = 0; - do - { - if ( giRead+1 > giSize ) - break; // no more characters - - c = READ_CHAR(); - if (c == -1 || c == 0) - break; - string[l] = c; - l++; - } while (l < sizeof(string)-1); - - string[l] = 0; - - return string; -} - -float READ_COORD( void ) -{ - return (float)(READ_SHORT() * (1.0/8)); -} - -float READ_ANGLE( void ) -{ - return (float)(READ_CHAR() * (360.0/256)); -} - -float READ_HIRESANGLE( void ) -{ - return (float)(READ_SHORT() * (360.0/65536)); -} - diff --git a/HLSDK/cl_dll/parsemsg.h b/HLSDK/cl_dll/parsemsg.h deleted file mode 100644 index ab8ff15..0000000 --- a/HLSDK/cl_dll/parsemsg.h +++ /dev/null @@ -1,40 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// -// parsemsg.h -// - -#define ASSERT( x ) - -void BEGIN_READ( void *buf, int size ); -int READ_CHAR( void ); -int READ_BYTE( void ); -int READ_SHORT( void ); -int READ_WORD( void ); -int READ_LONG( void ); -float READ_FLOAT( void ); -char* READ_STRING( void ); -float READ_COORD( void ); -float READ_ANGLE( void ); -float READ_HIRESANGLE( void ); - - - - - - - - - diff --git a/HLSDK/cl_dll/util_vector.h b/HLSDK/cl_dll/util_vector.h deleted file mode 100644 index 2a63537..0000000 --- a/HLSDK/cl_dll/util_vector.h +++ /dev/null @@ -1,125 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// Vector.h -// A subset of the extdll.h in the project HL Entity DLL -// - -// Misc C-runtime library headers -#include "stdio.h" -#include "stdlib.h" -#include "math.h" - -// Header file containing definition of globalvars_t and entvars_t -typedef unsigned int func_t; // -typedef unsigned int string_t; // from engine's pr_comp.h; -typedef float vec_t; // needed before including progdefs.h - -//========================================================= -// 2DVector - used for many pathfinding and many other -// operations that are treated as planar rather than 3d. -//========================================================= -class Vector2D -{ -public: - inline Vector2D(void) { } - inline Vector2D(float X, float Y) { x = X; y = Y; } - inline Vector2D operator+(const Vector2D& v) const { return Vector2D(x+v.x, y+v.y); } - inline Vector2D operator-(const Vector2D& v) const { return Vector2D(x-v.x, y-v.y); } - inline Vector2D operator*(float fl) const { return Vector2D(x*fl, y*fl); } - inline Vector2D operator/(float fl) const { return Vector2D(x/fl, y/fl); } - - inline float Length(void) const { return (float)sqrt(x*x + y*y ); } - - inline Vector2D Normalize ( void ) const - { - Vector2D vec2; - - float flLen = Length(); - if ( flLen == 0 ) - { - return Vector2D( (float)0, (float)0 ); - } - else - { - flLen = 1 / flLen; - return Vector2D( x * flLen, y * flLen ); - } - } - - vec_t x, y; -}; - -#undef DotProduct -inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y ); } -inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; } - -//========================================================= -// 3D Vector -//========================================================= -class Vector // same data-layout as engine's vec3_t, -{ // which is a vec_t[3] -public: - // Construction/destruction - inline Vector(void) { } - inline Vector(float X, float Y, float Z) { x = X; y = Y; z = Z; } - inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; } - inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z; } - inline Vector(const Vector& v) { x = v.x; y = v.y; z = v.z; } - inline Vector(float rgfl[3]) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } - - // Operators - inline Vector operator-(void) const { return Vector(-x,-y,-z); } - inline int operator==(const Vector& v) const { return x==v.x && y==v.y && z==v.z; } - inline int operator!=(const Vector& v) const { return !(*this==v); } - inline Vector operator+(const Vector& v) const { return Vector(x+v.x, y+v.y, z+v.z); } - inline Vector operator-(const Vector& v) const { return Vector(x-v.x, y-v.y, z-v.z); } - inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); } - inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); } - - // Methods - inline void CopyToArray(float* rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; } - inline float Length(void) const { return (float)sqrt(x*x + y*y + z*z); } - operator float *() { return &x; } // Vectors will now automatically convert to float * when needed - operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed - inline Vector Normalize(void) const - { - float flLen = Length(); - if (flLen == 0) return Vector(0,0,1); // ???? - flLen = 1 / flLen; - return Vector(x * flLen, y * flLen, z * flLen); - } - - inline Vector2D Make2D ( void ) const - { - Vector2D Vec2; - - Vec2.x = x; - Vec2.y = y; - - return Vec2; - } - inline float Length2D(void) const { return (float)sqrt(x*x + y*y); } - - // Members - vec_t x, y, z; -}; -inline Vector operator*(float fl, const Vector& v) { return v * fl; } -inline float DotProduct(const Vector& a, const Vector& b) { return(a.x*b.x+a.y*b.y+a.z*b.z); } -inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); } - -#ifndef DID_VEC3_T_DEFINE -#define DID_VEC3_T_DEFINE -#define vec3_t Vector -#endif diff --git a/HLSDK/cl_dll/wrect.h b/HLSDK/cl_dll/wrect.h deleted file mode 100644 index 620b816..0000000 --- a/HLSDK/cl_dll/wrect.h +++ /dev/null @@ -1,16 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#if !defined( WRECTH ) -#define WRECTH - -typedef struct rect_s -{ - int left, right, top, bottom; -} wrect_t; - -#endif \ No newline at end of file diff --git a/HLSDK/common/Sequence.h b/HLSDK/common/Sequence.h deleted file mode 100644 index 8df553d..0000000 --- a/HLSDK/common/Sequence.h +++ /dev/null @@ -1,201 +0,0 @@ -//--------------------------------------------------------------------------- -// -// S c r i p t e d S e q u e n c e s -// -//--------------------------------------------------------------------------- -#ifndef _INCLUDE_SEQUENCE_H_ -#define _INCLUDE_SEQUENCE_H_ - - -#ifndef _DEF_BYTE_ -typedef unsigned char byte; -#endif - -//--------------------------------------------------------------------------- -// client_textmessage_t -//--------------------------------------------------------------------------- -typedef struct client_textmessage_s -{ - int effect; - byte r1, g1, b1, a1; // 2 colors for effects - byte r2, g2, b2, a2; - float x; - float y; - float fadein; - float fadeout; - float holdtime; - float fxtime; - const char *pName; - const char *pMessage; -} client_textmessage_t; - - -//-------------------------------------------------------------------------- -// sequenceDefaultBits_e -// -// Enumerated list of possible modifiers for a command. This enumeration -// is used in a bitarray controlling what modifiers are specified for a command. -//--------------------------------------------------------------------------- -enum sequenceModifierBits -{ - SEQUENCE_MODIFIER_EFFECT_BIT = (1 << 1), - SEQUENCE_MODIFIER_POSITION_BIT = (1 << 2), - SEQUENCE_MODIFIER_COLOR_BIT = (1 << 3), - SEQUENCE_MODIFIER_COLOR2_BIT = (1 << 4), - SEQUENCE_MODIFIER_FADEIN_BIT = (1 << 5), - SEQUENCE_MODIFIER_FADEOUT_BIT = (1 << 6), - SEQUENCE_MODIFIER_HOLDTIME_BIT = (1 << 7), - SEQUENCE_MODIFIER_FXTIME_BIT = (1 << 8), - SEQUENCE_MODIFIER_SPEAKER_BIT = (1 << 9), - SEQUENCE_MODIFIER_LISTENER_BIT = (1 << 10), - SEQUENCE_MODIFIER_TEXTCHANNEL_BIT = (1 << 11), -}; -typedef enum sequenceModifierBits sequenceModifierBits_e ; - - -//--------------------------------------------------------------------------- -// sequenceCommandEnum_e -// -// Enumerated sequence command types. -//--------------------------------------------------------------------------- -enum sequenceCommandEnum_ -{ - SEQUENCE_COMMAND_ERROR = -1, - SEQUENCE_COMMAND_PAUSE = 0, - SEQUENCE_COMMAND_FIRETARGETS, - SEQUENCE_COMMAND_KILLTARGETS, - SEQUENCE_COMMAND_TEXT, - SEQUENCE_COMMAND_SOUND, - SEQUENCE_COMMAND_GOSUB, - SEQUENCE_COMMAND_SENTENCE, - SEQUENCE_COMMAND_REPEAT, - SEQUENCE_COMMAND_SETDEFAULTS, - SEQUENCE_COMMAND_MODIFIER, - SEQUENCE_COMMAND_POSTMODIFIER, - SEQUENCE_COMMAND_NOOP, - - SEQUENCE_MODIFIER_EFFECT, - SEQUENCE_MODIFIER_POSITION, - SEQUENCE_MODIFIER_COLOR, - SEQUENCE_MODIFIER_COLOR2, - SEQUENCE_MODIFIER_FADEIN, - SEQUENCE_MODIFIER_FADEOUT, - SEQUENCE_MODIFIER_HOLDTIME, - SEQUENCE_MODIFIER_FXTIME, - SEQUENCE_MODIFIER_SPEAKER, - SEQUENCE_MODIFIER_LISTENER, - SEQUENCE_MODIFIER_TEXTCHANNEL, -}; -typedef enum sequenceCommandEnum_ sequenceCommandEnum_e; - - -//--------------------------------------------------------------------------- -// sequenceCommandType_e -// -// Typeerated sequence command types. -//--------------------------------------------------------------------------- -enum sequenceCommandType_ -{ - SEQUENCE_TYPE_COMMAND, - SEQUENCE_TYPE_MODIFIER, -}; -typedef enum sequenceCommandType_ sequenceCommandType_e; - - -//--------------------------------------------------------------------------- -// sequenceCommandMapping_s -// -// A mapping of a command enumerated-value to its name. -//--------------------------------------------------------------------------- -typedef struct sequenceCommandMapping_ sequenceCommandMapping_s; -struct sequenceCommandMapping_ -{ - sequenceCommandEnum_e commandEnum; - const char* commandName; - sequenceCommandType_e commandType; -}; - - -//--------------------------------------------------------------------------- -// sequenceCommandLine_s -// -// Structure representing a single command (usually 1 line) from a -// .SEQ file entry. -//--------------------------------------------------------------------------- -typedef struct sequenceCommandLine_ sequenceCommandLine_s; -struct sequenceCommandLine_ -{ - int commandType; // Specifies the type of command - client_textmessage_t clientMessage; // Text HUD message struct - char* speakerName; // Targetname of speaking entity - char* listenerName; // Targetname of entity being spoken to - char* soundFileName; // Name of sound file to play - char* sentenceName; // Name of sentences.txt to play - char* fireTargetNames; // List of targetnames to fire - char* killTargetNames; // List of targetnames to remove - float delay; // Seconds 'till next command - int repeatCount; // If nonzero, reset execution pointer to top of block (N times, -1 = infinite) - int textChannel; // Display channel on which text message is sent - int modifierBitField; // Bit field to specify what clientmessage fields are valid - sequenceCommandLine_s* nextCommandLine; // Next command (linked list) -}; - - -//--------------------------------------------------------------------------- -// sequenceEntry_s -// -// Structure representing a single command (usually 1 line) from a -// .SEQ file entry. -//--------------------------------------------------------------------------- -typedef struct sequenceEntry_ sequenceEntry_s; -struct sequenceEntry_ -{ - char* fileName; // Name of sequence file without .SEQ extension - char* entryName; // Name of entry label in file - sequenceCommandLine_s* firstCommand; // Linked list of commands in entry - sequenceEntry_s* nextEntry; // Next loaded entry - qboolean isGlobal; // Is entry retained over level transitions? -}; - - - -//--------------------------------------------------------------------------- -// sentenceEntry_s -// Structure representing a single sentence of a group from a .SEQ -// file entry. Sentences are identical to entries in sentences.txt, but -// can be unique per level and are loaded/unloaded with the level. -//--------------------------------------------------------------------------- -typedef struct sentenceEntry_ sentenceEntry_s; -struct sentenceEntry_ -{ - char* data; // sentence data (ie "We have hostiles" ) - sentenceEntry_s* nextEntry; // Next loaded entry - qboolean isGlobal; // Is entry retained over level transitions? - unsigned int index; // this entry's position in the file. -}; - -//-------------------------------------------------------------------------- -// sentenceGroupEntry_s -// Structure representing a group of sentences found in a .SEQ file. -// A sentence group is defined by all sentences with the same name, ignoring -// the number at the end of the sentence name. Groups enable a sentence -// to be picked at random across a group. -//-------------------------------------------------------------------------- -typedef struct sentenceGroupEntry_ sentenceGroupEntry_s; -struct sentenceGroupEntry_ -{ - char* groupName; // name of the group (ie CT_ALERT ) - unsigned int numSentences; // number of sentences in group - sentenceEntry_s* firstSentence; // head of linked list of sentences in group - sentenceGroupEntry_s* nextEntry; // next loaded group -}; - -//--------------------------------------------------------------------------- -// Function declarations -//--------------------------------------------------------------------------- -sequenceEntry_s* SequenceGet( const char* fileName, const char* entryName ); -void Sequence_ParseFile( const char* fileName, qboolean isGlobal ); -void Sequence_OnLevelLoad( const char* mapName ); -sentenceEntry_s* SequencePickSentence( const char *groupName, int pickMethod, int *picked ); - -#endif // _INCLUDE_SEQUENCE_H_ diff --git a/HLSDK/common/beamdef.h b/HLSDK/common/beamdef.h deleted file mode 100644 index fd77a76..0000000 --- a/HLSDK/common/beamdef.h +++ /dev/null @@ -1,62 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( BEAMDEFH ) -#define BEAMDEFH -#ifdef _WIN32 -#pragma once -#endif - -#define FBEAM_STARTENTITY 0x00000001 -#define FBEAM_ENDENTITY 0x00000002 -#define FBEAM_FADEIN 0x00000004 -#define FBEAM_FADEOUT 0x00000008 -#define FBEAM_SINENOISE 0x00000010 -#define FBEAM_SOLID 0x00000020 -#define FBEAM_SHADEIN 0x00000040 -#define FBEAM_SHADEOUT 0x00000080 -#define FBEAM_STARTVISIBLE 0x10000000 // Has this client actually seen this beam's start entity yet? -#define FBEAM_ENDVISIBLE 0x20000000 // Has this client actually seen this beam's end entity yet? -#define FBEAM_ISACTIVE 0x40000000 -#define FBEAM_FOREVER 0x80000000 - -typedef struct beam_s BEAM; -struct beam_s -{ - BEAM *next; - int type; - int flags; - vec3_t source; - vec3_t target; - vec3_t delta; - float t; // 0 .. 1 over lifetime of beam - float freq; - float die; - float width; - float amplitude; - float r, g, b; - float brightness; - float speed; - float frameRate; - float frame; - int segments; - int startEntity; - int endEntity; - int modelIndex; - int frameCount; - struct model_s *pFollowModel; - struct particle_s *particles; -}; - -#endif diff --git a/HLSDK/common/cl_entity.h b/HLSDK/common/cl_entity.h deleted file mode 100644 index a7cd472..0000000 --- a/HLSDK/common/cl_entity.h +++ /dev/null @@ -1,115 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// cl_entity.h -#if !defined( CL_ENTITYH ) -#define CL_ENTITYH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct efrag_s -{ - struct mleaf_s *leaf; - struct efrag_s *leafnext; - struct cl_entity_s *entity; - struct efrag_s *entnext; -} efrag_t; - -typedef struct -{ - byte mouthopen; // 0 = mouth closed, 255 = mouth agape - byte sndcount; // counter for running average - int sndavg; // running average -} mouth_t; - -typedef struct -{ - float prevanimtime; - float sequencetime; - byte prevseqblending[2]; - vec3_t prevorigin; - vec3_t prevangles; - - int prevsequence; - float prevframe; - - byte prevcontroller[4]; - byte prevblending[2]; -} latchedvars_t; - -typedef struct -{ - // Time stamp for this movement - float animtime; - - vec3_t origin; - vec3_t angles; -} position_history_t; - -typedef struct cl_entity_s cl_entity_t; - -#define HISTORY_MAX 64 // Must be power of 2 -#define HISTORY_MASK ( HISTORY_MAX - 1 ) - - -#if !defined( ENTITY_STATEH ) -#include "entity_state.h" -#endif - -#if !defined( PROGS_H ) -#include "progs.h" -#endif - -struct cl_entity_s -{ - int index; // Index into cl_entities ( should match actual slot, but not necessarily ) - - qboolean player; // True if this entity is a "player" - - entity_state_t baseline; // The original state from which to delta during an uncompressed message - entity_state_t prevstate; // The state information from the penultimate message received from the server - entity_state_t curstate; // The state information from the last message received from server - - int current_position; // Last received history update index - position_history_t ph[ HISTORY_MAX ]; // History of position and angle updates for this player - - mouth_t mouth; // For synchronizing mouth movements. - - latchedvars_t latched; // Variables used by studio model rendering routines - - // Information based on interplocation, extrapolation, prediction, or just copied from last msg received. - // - float lastmove; - - // Actual render position and angles - vec3_t origin; - vec3_t angles; - - // Attachment points - vec3_t attachment[4]; - - // Other entity local information - int trivial_accept; - - struct model_s *model; // cl.model_precache[ curstate.modelindes ]; all visible entities have a model - struct efrag_s *efrag; // linked list of efrags - struct mnode_s *topnode; // for bmodels, first world node that splits bmodel, or NULL if not split - - float syncbase; // for client-side animations -- used by obsolete alias animation system, remove? - int visframe; // last frame this entity was found in an active leaf - colorVec cvFloorColor; -}; - -#endif // !CL_ENTITYH diff --git a/HLSDK/common/com_model.h b/HLSDK/common/com_model.h deleted file mode 100644 index c014a39..0000000 --- a/HLSDK/common/com_model.h +++ /dev/null @@ -1,351 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// com_model.h -#if !defined( COM_MODEL_H ) -#define COM_MODEL_H -#if defined( _WIN32 ) -#pragma once -#endif - -#define STUDIO_RENDER 1 -#define STUDIO_EVENTS 2 - -#define MAX_CLIENTS 32 -#define MAX_EDICTS 900 - -#define MAX_MODEL_NAME 64 -#define MAX_MAP_HULLS 4 -#define MIPLEVELS 4 -#define NUM_AMBIENTS 4 // automatic ambient sounds -#define MAXLIGHTMAPS 4 -#define PLANE_ANYZ 5 - -#define ALIAS_Z_CLIP_PLANE 5 - -// flags in finalvert_t.flags -#define ALIAS_LEFT_CLIP 0x0001 -#define ALIAS_TOP_CLIP 0x0002 -#define ALIAS_RIGHT_CLIP 0x0004 -#define ALIAS_BOTTOM_CLIP 0x0008 -#define ALIAS_Z_CLIP 0x0010 -#define ALIAS_ONSEAM 0x0020 -#define ALIAS_XY_CLIP_MASK 0x000F - -#define ZISCALE ((float)0x8000) - -#define CACHE_SIZE 32 // used to align key data structures - -typedef enum -{ - mod_brush, - mod_sprite, - mod_alias, - mod_studio -} modtype_t; - -// must match definition in modelgen.h -#ifndef SYNCTYPE_T -#define SYNCTYPE_T - -typedef enum -{ - ST_SYNC=0, - ST_RAND -} synctype_t; - -#endif - -typedef struct -{ - float mins[3], maxs[3]; - float origin[3]; - int headnode[MAX_MAP_HULLS]; - int visleafs; // not including the solid leaf 0 - int firstface, numfaces; -} dmodel_t; - -// plane_t structure -typedef struct mplane_s -{ - vec3_t normal; // surface normal - float dist; // closest appoach to origin - byte type; // for texture axis selection and fast side tests - byte signbits; // signx + signy<<1 + signz<<1 - byte pad[2]; -} mplane_t; - -typedef struct -{ - vec3_t position; -} mvertex_t; - -typedef struct -{ - unsigned short v[2]; - unsigned int cachededgeoffset; -} medge_t; - -typedef struct texture_s -{ - char name[16]; - unsigned width, height; - int anim_total; // total tenths in sequence ( 0 = no) - int anim_min, anim_max; // time for this frame min <=time< max - struct texture_s *anim_next; // in the animation sequence - struct texture_s *alternate_anims; // bmodels in frame 1 use these - unsigned offsets[MIPLEVELS]; // four mip maps stored - unsigned paloffset; -} texture_t; - -typedef struct -{ - float vecs[2][4]; // [s/t] unit vectors in world space. - // [i][3] is the s/t offset relative to the origin. - // s or t = dot(3Dpoint,vecs[i])+vecs[i][3] - float mipadjust; // ?? mipmap limits for very small surfaces - texture_t *texture; - int flags; // sky or slime, no lightmap or 256 subdivision -} mtexinfo_t; - -typedef struct mnode_s -{ -// common with leaf - int contents; // 0, to differentiate from leafs - int visframe; // node needs to be traversed if current - - short minmaxs[6]; // for bounding box culling - - struct mnode_s *parent; - -// node specific - mplane_t *plane; - struct mnode_s *children[2]; - - unsigned short firstsurface; - unsigned short numsurfaces; -} mnode_t; - -typedef struct msurface_s msurface_t; -typedef struct decal_s decal_t; - -// JAY: Compress this as much as possible -struct decal_s -{ - decal_t *pnext; // linked list for each surface - msurface_t *psurface; // Surface id for persistence / unlinking - short dx; // Offsets into surface texture (in texture coordinates, so we don't need floats) - short dy; - short texture; // Decal texture - byte scale; // Pixel scale - byte flags; // Decal flags - - short entityIndex; // Entity this is attached to -}; - -typedef struct mleaf_s -{ -// common with node - int contents; // wil be a negative contents number - int visframe; // node needs to be traversed if current - - short minmaxs[6]; // for bounding box culling - - struct mnode_s *parent; - -// leaf specific - byte *compressed_vis; - struct efrag_s *efrags; - - msurface_t **firstmarksurface; - int nummarksurfaces; - int key; // BSP sequence number for leaf's contents - byte ambient_sound_level[NUM_AMBIENTS]; -} mleaf_t; - -struct msurface_s -{ - int visframe; // should be drawn when node is crossed - - int dlightframe; // last frame the surface was checked by an animated light - int dlightbits; // dynamically generated. Indicates if the surface illumination - // is modified by an animated light. - - mplane_t *plane; // pointer to shared plane - int flags; // see SURF_ #defines - - int firstedge; // look up in model->surfedges[], negative numbers - int numedges; // are backwards edges - -// surface generation data - struct surfcache_s *cachespots[MIPLEVELS]; - - short texturemins[2]; // smallest s/t position on the surface. - short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces - - mtexinfo_t *texinfo; - -// lighting info - byte styles[MAXLIGHTMAPS]; // index into d_lightstylevalue[] for animated lights - // no one surface can be effected by more than 4 - // animated lights. - color24 *samples; - - decal_t *pdecals; -}; - -typedef struct -{ - int planenum; - short children[2]; // negative numbers are contents -} dclipnode_t; - -typedef struct hull_s -{ - dclipnode_t *clipnodes; - mplane_t *planes; - int firstclipnode; - int lastclipnode; - vec3_t clip_mins; - vec3_t clip_maxs; -} hull_t; - -#if !defined( CACHE_USER ) && !defined( QUAKEDEF_H ) -#define CACHE_USER -typedef struct cache_user_s -{ - void *data; -} cache_user_t; -#endif - -typedef struct model_s -{ - char name[ MAX_MODEL_NAME ]; - qboolean needload; // bmodels and sprites don't cache normally - - modtype_t type; - int numframes; - synctype_t synctype; - - int flags; - -// -// volume occupied by the model -// - vec3_t mins, maxs; - float radius; - -// -// brush model -// - int firstmodelsurface, nummodelsurfaces; - - int numsubmodels; - dmodel_t *submodels; - - int numplanes; - mplane_t *planes; - - int numleafs; // number of visible leafs, not counting 0 - struct mleaf_s *leafs; - - int numvertexes; - mvertex_t *vertexes; - - int numedges; - medge_t *edges; - - int numnodes; - mnode_t *nodes; - - int numtexinfo; - mtexinfo_t *texinfo; - - int numsurfaces; - msurface_t *surfaces; - - int numsurfedges; - int *surfedges; - - int numclipnodes; - dclipnode_t *clipnodes; - - int nummarksurfaces; - msurface_t **marksurfaces; - - hull_t hulls[MAX_MAP_HULLS]; - - int numtextures; - texture_t **textures; - - byte *visdata; - - color24 *lightdata; - - char *entities; - -// -// additional model data -// - cache_user_t cache; // only access through Mod_Extradata - -} model_t; - -typedef vec_t vec4_t[4]; - -typedef struct alight_s -{ - int ambientlight; // clip at 128 - int shadelight; // clip at 192 - ambientlight - vec3_t color; - float *plightvec; -} alight_t; - -typedef struct auxvert_s -{ - float fv[3]; // viewspace x, y -} auxvert_t; - -#include "custom.h" - -#define MAX_INFO_STRING 256 -#define MAX_SCOREBOARDNAME 32 -typedef struct player_info_s -{ - // User id on server - int userid; - - // User info string - char userinfo[ MAX_INFO_STRING ]; - - // Name - char name[ MAX_SCOREBOARDNAME ]; - - // Spectator or not, unused - int spectator; - - int ping; - int packet_loss; - - // skin information - char model[MAX_QPATH]; - int topcolor; - int bottomcolor; - - // last frame rendered - int renderframe; - - // Gait frame estimation - int gaitsequence; - float gaitframe; - float gaityaw; - vec3_t prevgaitorigin; - - customization_t customdata; -} player_info_t; - -#endif // #define COM_MODEL_H diff --git a/HLSDK/common/con_nprint.h b/HLSDK/common/con_nprint.h deleted file mode 100644 index 64f5dac..0000000 --- a/HLSDK/common/con_nprint.h +++ /dev/null @@ -1,38 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( CON_NPRINTH ) -#define CON_NPRINTH -#ifdef _WIN32 -#pragma once -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct con_nprint_s -{ - int index; // Row # - float time_to_live; // # of seconds before it dissappears - float color[ 3 ]; // RGB colors ( 0.0 -> 1.0 scale ) -} con_nprint_t; - -void Con_NPrintf( int idx, char *fmt, ... ); -void Con_NXPrintf( struct con_nprint_s *info, char *fmt, ... ); -#ifdef __cplusplus -} -#endif - -#endif diff --git a/HLSDK/common/const.h b/HLSDK/common/const.h deleted file mode 100644 index 6c5f35b..0000000 --- a/HLSDK/common/const.h +++ /dev/null @@ -1,783 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef CONST_H -#define CONST_H -// -// Constants shared by the engine and dlls -// This header file included by engine files and DLL files. -// Most came from server.h - -// edict->flags -#define FL_FLY (1<<0) // Changes the SV_Movestep() behavior to not need to be on ground -#define FL_SWIM (1<<1) // Changes the SV_Movestep() behavior to not need to be on ground (but stay in water) -#define FL_CONVEYOR (1<<2) -#define FL_CLIENT (1<<3) -#define FL_INWATER (1<<4) -#define FL_MONSTER (1<<5) -#define FL_GODMODE (1<<6) -#define FL_NOTARGET (1<<7) -#define FL_SKIPLOCALHOST (1<<8) // Don't send entity to local host, it's predicting this entity itself -#define FL_ONGROUND (1<<9) // At rest / on the ground -#define FL_PARTIALGROUND (1<<10) // not all corners are valid -#define FL_WATERJUMP (1<<11) // player jumping out of water -#define FL_FROZEN (1<<12) // Player is frozen for 3rd person camera -#define FL_FAKECLIENT (1<<13) // JAC: fake client, simulated server side; don't send network messages to them -#define FL_DUCKING (1<<14) // Player flag -- Player is fully crouched -#define FL_FLOAT (1<<15) // Apply floating force to this entity when in water -#define FL_GRAPHED (1<<16) // worldgraph has this ent listed as something that blocks a connection - -// UNDONE: Do we need these? -#define FL_IMMUNE_WATER (1<<17) -#define FL_IMMUNE_SLIME (1<<18) -#define FL_IMMUNE_LAVA (1<<19) - -#define FL_PROXY (1<<20) // This is a spectator proxy -#define FL_ALWAYSTHINK (1<<21) // Brush model flag -- call think every frame regardless of nextthink - ltime (for constantly changing velocity/path) -#define FL_BASEVELOCITY (1<<22) // Base velocity has been applied this frame (used to convert base velocity into momentum) -#define FL_MONSTERCLIP (1<<23) // Only collide in with monsters who have FL_MONSTERCLIP set -#define FL_ONTRAIN (1<<24) // Player is _controlling_ a train, so movement commands should be ignored on client during prediction. -#define FL_WORLDBRUSH (1<<25) // Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something) -#define FL_SPECTATOR (1<<26) // This client is a spectator, don't run touch functions, etc. -#define FL_CUSTOMENTITY (1<<29) // This is a custom entity -#define FL_KILLME (1<<30) // This entity is marked for death -- This allows the engine to kill ents at the appropriate time -#define FL_DORMANT (1<<31) // Entity is dormant, no updates to client - - -// Goes into globalvars_t.trace_flags -#define FTRACE_SIMPLEBOX (1<<0) // Traceline with a simple box - - -// walkmove modes -#define WALKMOVE_NORMAL 0 // normal walkmove -#define WALKMOVE_WORLDONLY 1 // doesn't hit ANY entities, no matter what the solid type -#define WALKMOVE_CHECKONLY 2 // move, but don't touch triggers - -// edict->movetype values -#define MOVETYPE_NONE 0 // never moves -//#define MOVETYPE_ANGLENOCLIP 1 -//#define MOVETYPE_ANGLECLIP 2 -#define MOVETYPE_WALK 3 // Player only - moving on the ground -#define MOVETYPE_STEP 4 // gravity, special edge handling -- monsters use this -#define MOVETYPE_FLY 5 // No gravity, but still collides with stuff -#define MOVETYPE_TOSS 6 // gravity/collisions -#define MOVETYPE_PUSH 7 // no clip to world, push and crush -#define MOVETYPE_NOCLIP 8 // No gravity, no collisions, still do velocity/avelocity -#define MOVETYPE_FLYMISSILE 9 // extra size to monsters -#define MOVETYPE_BOUNCE 10 // Just like Toss, but reflect velocity when contacting surfaces -#define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity -#define MOVETYPE_FOLLOW 12 // track movement of aiment -#define MOVETYPE_PUSHSTEP 13 // BSP model that needs physics/world collisions (uses nearest hull for world collision) - -// edict->solid values -// NOTE: Some movetypes will cause collisions independent of SOLID_NOT/SOLID_TRIGGER when the entity moves -// SOLID only effects OTHER entities colliding with this one when they move - UGH! -#define SOLID_NOT 0 // no interaction with other objects -#define SOLID_TRIGGER 1 // touch on edge, but not blocking -#define SOLID_BBOX 2 // touch on edge, block -#define SOLID_SLIDEBOX 3 // touch on edge, but not an onground -#define SOLID_BSP 4 // bsp clip, touch on edge, block - -// edict->deadflag values -#define DEAD_NO 0 // alive -#define DEAD_DYING 1 // playing death animation or still falling off of a ledge waiting to hit ground -#define DEAD_DEAD 2 // dead. lying still. -#define DEAD_RESPAWNABLE 3 -#define DEAD_DISCARDBODY 4 - -#define DAMAGE_NO 0 -#define DAMAGE_YES 1 -#define DAMAGE_AIM 2 - -// entity effects -#define EF_BRIGHTFIELD 1 // swirling cloud of particles -#define EF_MUZZLEFLASH 2 // single frame ELIGHT on entity attachment 0 -#define EF_BRIGHTLIGHT 4 // DLIGHT centered at entity origin -#define EF_DIMLIGHT 8 // player flashlight -#define EF_INVLIGHT 16 // get lighting from ceiling -#define EF_NOINTERP 32 // don't interpolate the next frame -#define EF_LIGHT 64 // rocket flare glow sprite -#define EF_NODRAW 128 // don't draw entity -#define EF_NIGHTVISION 256 // player nightvision -#define EF_SNIPERLASER 512 // sniper laser effect -#define EF_FIBERCAMERA 1024// fiber camera - - -// entity flags -#define EFLAG_SLERP 1 // do studio interpolation of this entity - -// -// temp entity events -// -#define TE_BEAMPOINTS 0 // beam effect between two points -// coord coord coord (start position) -// coord coord coord (end position) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_BEAMENTPOINT 1 // beam effect between point and entity -// short (start entity) -// coord coord coord (end position) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_GUNSHOT 2 // particle effect plus ricochet sound -// coord coord coord (position) - -#define TE_EXPLOSION 3 // additive sprite, 2 dynamic lights, flickering particles, explosion sound, move vertically 8 pps -// coord coord coord (position) -// short (sprite index) -// byte (scale in 0.1's) -// byte (framerate) -// byte (flags) -// -// The Explosion effect has some flags to control performance/aesthetic features: -#define TE_EXPLFLAG_NONE 0 // all flags clear makes default Half-Life explosion -#define TE_EXPLFLAG_NOADDITIVE 1 // sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite) -#define TE_EXPLFLAG_NODLIGHTS 2 // do not render dynamic lights -#define TE_EXPLFLAG_NOSOUND 4 // do not play client explosion sound -#define TE_EXPLFLAG_NOPARTICLES 8 // do not draw particles - - -#define TE_TAREXPLOSION 4 // Quake1 "tarbaby" explosion with sound -// coord coord coord (position) - -#define TE_SMOKE 5 // alphablend sprite, move vertically 30 pps -// coord coord coord (position) -// short (sprite index) -// byte (scale in 0.1's) -// byte (framerate) - -#define TE_TRACER 6 // tracer effect from point to point -// coord, coord, coord (start) -// coord, coord, coord (end) - -#define TE_LIGHTNING 7 // TE_BEAMPOINTS with simplified parameters -// coord, coord, coord (start) -// coord, coord, coord (end) -// byte (life in 0.1's) -// byte (width in 0.1's) -// byte (amplitude in 0.01's) -// short (sprite model index) - -#define TE_BEAMENTS 8 -// short (start entity) -// short (end entity) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_SPARKS 9 // 8 random tracers with gravity, ricochet sprite -// coord coord coord (position) - -#define TE_LAVASPLASH 10 // Quake1 lava splash -// coord coord coord (position) - -#define TE_TELEPORT 11 // Quake1 teleport splash -// coord coord coord (position) - -#define TE_EXPLOSION2 12 // Quake1 colormaped (base palette) particle explosion with sound -// coord coord coord (position) -// byte (starting color) -// byte (num colors) - -#define TE_BSPDECAL 13 // Decal from the .BSP file -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// short (texture index of precached decal texture name) -// short (entity index) -// [optional - only included if previous short is non-zero (not the world)] short (index of model of above entity) - -#define TE_IMPLOSION 14 // tracers moving toward a point -// coord, coord, coord (position) -// byte (radius) -// byte (count) -// byte (life in 0.1's) - -#define TE_SPRITETRAIL 15 // line of moving glow sprites with gravity, fadeout, and collisions -// coord, coord, coord (start) -// coord, coord, coord (end) -// short (sprite index) -// byte (count) -// byte (life in 0.1's) -// byte (scale in 0.1's) -// byte (velocity along vector in 10's) -// byte (randomness of velocity in 10's) - -#define TE_BEAM 16 // obsolete - -#define TE_SPRITE 17 // additive sprite, plays 1 cycle -// coord, coord, coord (position) -// short (sprite index) -// byte (scale in 0.1's) -// byte (brightness) - -#define TE_BEAMSPRITE 18 // A beam with a sprite at the end -// coord, coord, coord (start position) -// coord, coord, coord (end position) -// short (beam sprite index) -// short (end sprite index) - -#define TE_BEAMTORUS 19 // screen aligned beam ring, expands to max radius over lifetime -// coord coord coord (center position) -// coord coord coord (axis and radius) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_BEAMDISK 20 // disk that expands to max radius over lifetime -// coord coord coord (center position) -// coord coord coord (axis and radius) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_BEAMCYLINDER 21 // cylinder that expands to max radius over lifetime -// coord coord coord (center position) -// coord coord coord (axis and radius) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_BEAMFOLLOW 22 // create a line of decaying beam segments until entity stops moving -// short (entity:attachment to follow) -// short (sprite index) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte,byte,byte (color) -// byte (brightness) - -#define TE_GLOWSPRITE 23 -// coord, coord, coord (pos) short (model index) byte (scale / 10) - -#define TE_BEAMRING 24 // connect a beam ring to two entities -// short (start entity) -// short (end entity) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_STREAK_SPLASH 25 // oriented shower of tracers -// coord coord coord (start position) -// coord coord coord (direction vector) -// byte (color) -// short (count) -// short (base speed) -// short (ramdon velocity) - -#define TE_BEAMHOSE 26 // obsolete - -#define TE_DLIGHT 27 // dynamic light, effect world, minor entity effect -// coord, coord, coord (pos) -// byte (radius in 10's) -// byte byte byte (color) -// byte (brightness) -// byte (life in 10's) -// byte (decay rate in 10's) - -#define TE_ELIGHT 28 // point entity light, no world effect -// short (entity:attachment to follow) -// coord coord coord (initial position) -// coord (radius) -// byte byte byte (color) -// byte (life in 0.1's) -// coord (decay rate) - -#define TE_TEXTMESSAGE 29 -// short 1.2.13 x (-1 = center) -// short 1.2.13 y (-1 = center) -// byte Effect 0 = fade in/fade out - // 1 is flickery credits - // 2 is write out (training room) - -// 4 bytes r,g,b,a color1 (text color) -// 4 bytes r,g,b,a color2 (effect color) -// ushort 8.8 fadein time -// ushort 8.8 fadeout time -// ushort 8.8 hold time -// optional ushort 8.8 fxtime (time the highlight lags behing the leading text in effect 2) -// string text message (512 chars max sz string) -#define TE_LINE 30 -// coord, coord, coord startpos -// coord, coord, coord endpos -// short life in 0.1 s -// 3 bytes r, g, b - -#define TE_BOX 31 -// coord, coord, coord boxmins -// coord, coord, coord boxmaxs -// short life in 0.1 s -// 3 bytes r, g, b - -#define TE_KILLBEAM 99 // kill all beams attached to entity -// short (entity) - -#define TE_LARGEFUNNEL 100 -// coord coord coord (funnel position) -// short (sprite index) -// short (flags) - -#define TE_BLOODSTREAM 101 // particle spray -// coord coord coord (start position) -// coord coord coord (spray vector) -// byte (color) -// byte (speed) - -#define TE_SHOWLINE 102 // line of particles every 5 units, dies in 30 seconds -// coord coord coord (start position) -// coord coord coord (end position) - -#define TE_BLOOD 103 // particle spray -// coord coord coord (start position) -// coord coord coord (spray vector) -// byte (color) -// byte (speed) - -#define TE_DECAL 104 // Decal applied to a brush entity (not the world) -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name) -// short (entity index) - -#define TE_FIZZ 105 // create alpha sprites inside of entity, float upwards -// short (entity) -// short (sprite index) -// byte (density) - -#define TE_MODEL 106 // create a moving model that bounces and makes a sound when it hits -// coord, coord, coord (position) -// coord, coord, coord (velocity) -// angle (initial yaw) -// short (model index) -// byte (bounce sound type) -// byte (life in 0.1's) - -#define TE_EXPLODEMODEL 107 // spherical shower of models, picks from set -// coord, coord, coord (origin) -// coord (velocity) -// short (model index) -// short (count) -// byte (life in 0.1's) - -#define TE_BREAKMODEL 108 // box of models or sprites -// coord, coord, coord (position) -// coord, coord, coord (size) -// coord, coord, coord (velocity) -// byte (random velocity in 10's) -// short (sprite or model index) -// byte (count) -// byte (life in 0.1 secs) -// byte (flags) - -#define TE_GUNSHOTDECAL 109 // decal and ricochet sound -// coord, coord, coord (position) -// short (entity index???) -// byte (decal???) - -#define TE_SPRITE_SPRAY 110 // spay of alpha sprites -// coord, coord, coord (position) -// coord, coord, coord (velocity) -// short (sprite index) -// byte (count) -// byte (speed) -// byte (noise) - -#define TE_ARMOR_RICOCHET 111 // quick spark sprite, client ricochet sound. -// coord, coord, coord (position) -// byte (scale in 0.1's) - -#define TE_PLAYERDECAL 112 // ??? -// byte (playerindex) -// coord, coord, coord (position) -// short (entity???) -// byte (decal number???) -// [optional] short (model index???) - -#define TE_BUBBLES 113 // create alpha sprites inside of box, float upwards -// coord, coord, coord (min start position) -// coord, coord, coord (max start position) -// coord (float height) -// short (model index) -// byte (count) -// coord (speed) - -#define TE_BUBBLETRAIL 114 // create alpha sprites along a line, float upwards -// coord, coord, coord (min start position) -// coord, coord, coord (max start position) -// coord (float height) -// short (model index) -// byte (count) -// coord (speed) - -#define TE_BLOODSPRITE 115 // spray of opaque sprite1's that fall, single sprite2 for 1..2 secs (this is a high-priority tent) -// coord, coord, coord (position) -// short (sprite1 index) -// short (sprite2 index) -// byte (color) -// byte (scale) - -#define TE_WORLDDECAL 116 // Decal applied to the world brush -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name) - -#define TE_WORLDDECALHIGH 117 // Decal (with texture index > 256) applied to world brush -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name - 256) - -#define TE_DECALHIGH 118 // Same as TE_DECAL, but the texture index was greater than 256 -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name - 256) -// short (entity index) - -#define TE_PROJECTILE 119 // Makes a projectile (like a nail) (this is a high-priority tent) -// coord, coord, coord (position) -// coord, coord, coord (velocity) -// short (modelindex) -// byte (life) -// byte (owner) projectile won't collide with owner (if owner == 0, projectile will hit any client). - -#define TE_SPRAY 120 // Throws a shower of sprites or models -// coord, coord, coord (position) -// coord, coord, coord (direction) -// short (modelindex) -// byte (count) -// byte (speed) -// byte (noise) -// byte (rendermode) - -#define TE_PLAYERSPRITES 121 // sprites emit from a player's bounding box (ONLY use for players!) -// byte (playernum) -// short (sprite modelindex) -// byte (count) -// byte (variance) (0 = no variance in size) (10 = 10% variance in size) - -#define TE_PARTICLEBURST 122 // very similar to lavasplash. -// coord (origin) -// short (radius) -// byte (particle color) -// byte (duration * 10) (will be randomized a bit) - -#define TE_FIREFIELD 123 // makes a field of fire. -// coord (origin) -// short (radius) (fire is made in a square around origin. -radius, -radius to radius, radius) -// short (modelindex) -// byte (count) -// byte (flags) -// byte (duration (in seconds) * 10) (will be randomized a bit) -// -// to keep network traffic low, this message has associated flags that fit into a byte: -#define TEFIRE_FLAG_ALLFLOAT 1 // all sprites will drift upwards as they animate -#define TEFIRE_FLAG_SOMEFLOAT 2 // some of the sprites will drift upwards. (50% chance) -#define TEFIRE_FLAG_LOOP 4 // if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration. -#define TEFIRE_FLAG_ALPHA 8 // if set, sprite is rendered alpha blended at 50% else, opaque -#define TEFIRE_FLAG_PLANAR 16 // if set, all fire sprites have same initial Z instead of randomly filling a cube. -#define TEFIRE_FLAG_ADDITIVE 32 // if set, sprite is rendered non-opaque with additive - -#define TE_PLAYERATTACHMENT 124 // attaches a TENT to a player (this is a high-priority tent) -// byte (entity index of player) -// coord (vertical offset) ( attachment origin.z = player origin.z + vertical offset ) -// short (model index) -// short (life * 10 ); - -#define TE_KILLPLAYERATTACHMENTS 125 // will expire all TENTS attached to a player. -// byte (entity index of player) - -#define TE_MULTIGUNSHOT 126 // much more compact shotgun message -// This message is used to make a client approximate a 'spray' of gunfire. -// Any weapon that fires more than one bullet per frame and fires in a bit of a spread is -// a good candidate for MULTIGUNSHOT use. (shotguns) -// -// NOTE: This effect makes the client do traces for each bullet, these client traces ignore -// entities that have studio models.Traces are 4096 long. -// -// coord (origin) -// coord (origin) -// coord (origin) -// coord (direction) -// coord (direction) -// coord (direction) -// coord (x noise * 100) -// coord (y noise * 100) -// byte (count) -// byte (bullethole decal texture index) - -#define TE_USERTRACER 127 // larger message than the standard tracer, but allows some customization. -// coord (origin) -// coord (origin) -// coord (origin) -// coord (velocity) -// coord (velocity) -// coord (velocity) -// byte ( life * 10 ) -// byte ( color ) this is an index into an array of color vectors in the engine. (0 - ) -// byte ( length * 10 ) - - - -#define MSG_BROADCAST 0 // unreliable to all -#define MSG_ONE 1 // reliable to one (msg_entity) -#define MSG_ALL 2 // reliable to all -#define MSG_INIT 3 // write to the init string -#define MSG_PVS 4 // Ents in PVS of org -#define MSG_PAS 5 // Ents in PAS of org -#define MSG_PVS_R 6 // Reliable to PVS -#define MSG_PAS_R 7 // Reliable to PAS -#define MSG_ONE_UNRELIABLE 8 // Send to one client, but don't put in reliable stream, put in unreliable datagram ( could be dropped ) -#define MSG_SPEC 9 // Sends to all spectator proxies - -// contents of a spot in the world -#define CONTENTS_EMPTY -1 -#define CONTENTS_SOLID -2 -#define CONTENTS_WATER -3 -#define CONTENTS_SLIME -4 -#define CONTENTS_LAVA -5 -#define CONTENTS_SKY -6 -/* These additional contents constants are defined in bspfile.h -#define CONTENTS_ORIGIN -7 // removed at csg time -#define CONTENTS_CLIP -8 // changed to contents_solid -#define CONTENTS_CURRENT_0 -9 -#define CONTENTS_CURRENT_90 -10 -#define CONTENTS_CURRENT_180 -11 -#define CONTENTS_CURRENT_270 -12 -#define CONTENTS_CURRENT_UP -13 -#define CONTENTS_CURRENT_DOWN -14 - -#define CONTENTS_TRANSLUCENT -15 -*/ -#define CONTENTS_LADDER -16 - -#define CONTENT_FLYFIELD -17 -#define CONTENT_GRAVITY_FLYFIELD -18 -#define CONTENT_FOG -19 - -#define CONTENT_EMPTY -1 -#define CONTENT_SOLID -2 -#define CONTENT_WATER -3 -#define CONTENT_SLIME -4 -#define CONTENT_LAVA -5 -#define CONTENT_SKY -6 - -// channels -#define CHAN_AUTO 0 -#define CHAN_WEAPON 1 -#define CHAN_VOICE 2 -#define CHAN_ITEM 3 -#define CHAN_BODY 4 -#define CHAN_STREAM 5 // allocate stream channel from the static or dynamic area -#define CHAN_STATIC 6 // allocate channel from the static area -#define CHAN_NETWORKVOICE_BASE 7 // voice data coming across the network -#define CHAN_NETWORKVOICE_END 500 // network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END). -#define CHAN_BOT 501 // channel used for bot chatter. - -// attenuation values -#define ATTN_NONE 0 -#define ATTN_NORM (float)0.8 -#define ATTN_IDLE (float)2 -#define ATTN_STATIC (float)1.25 - -// pitch values -#define PITCH_NORM 100 // non-pitch shifted -#define PITCH_LOW 95 // other values are possible - 0-255, where 255 is very high -#define PITCH_HIGH 120 - -// volume values -#define VOL_NORM 1.0 - -// plats -#define PLAT_LOW_TRIGGER 1 - -// Trains -#define SF_TRAIN_WAIT_RETRIGGER 1 -#define SF_TRAIN_START_ON 4 // Train is initially moving -#define SF_TRAIN_PASSABLE 8 // Train is not solid -- used to make water trains - -// buttons -#ifndef IN_BUTTONS_H -#include "in_buttons.h" -#endif - -// Break Model Defines - -#define BREAK_TYPEMASK 0x4F -#define BREAK_GLASS 0x01 -#define BREAK_METAL 0x02 -#define BREAK_FLESH 0x04 -#define BREAK_WOOD 0x08 - -#define BREAK_SMOKE 0x10 -#define BREAK_TRANS 0x20 -#define BREAK_CONCRETE 0x40 -#define BREAK_2 0x80 - -// Colliding temp entity sounds - -#define BOUNCE_GLASS BREAK_GLASS -#define BOUNCE_METAL BREAK_METAL -#define BOUNCE_FLESH BREAK_FLESH -#define BOUNCE_WOOD BREAK_WOOD -#define BOUNCE_SHRAP 0x10 -#define BOUNCE_SHELL 0x20 -#define BOUNCE_CONCRETE BREAK_CONCRETE -#define BOUNCE_SHOTSHELL 0x80 - -// Temp entity bounce sound types -#define TE_BOUNCE_NULL 0 -#define TE_BOUNCE_SHELL 1 -#define TE_BOUNCE_SHOTSHELL 2 - -// Rendering constants -enum -{ - kRenderNormal, // src - kRenderTransColor, // c*a+dest*(1-a) - kRenderTransTexture, // src*a+dest*(1-a) - kRenderGlow, // src*a+dest -- No Z buffer checks - kRenderTransAlpha, // src*srca+dest*(1-srca) - kRenderTransAdd, // src*a+dest -}; - -enum -{ - kRenderFxNone = 0, - kRenderFxPulseSlow, - kRenderFxPulseFast, - kRenderFxPulseSlowWide, - kRenderFxPulseFastWide, - kRenderFxFadeSlow, - kRenderFxFadeFast, - kRenderFxSolidSlow, - kRenderFxSolidFast, - kRenderFxStrobeSlow, - kRenderFxStrobeFast, - kRenderFxStrobeFaster, - kRenderFxFlickerSlow, - kRenderFxFlickerFast, - kRenderFxNoDissipation, - kRenderFxDistort, // Distort/scale/translate flicker - kRenderFxHologram, // kRenderFxDistort + distance fade - kRenderFxDeadPlayer, // kRenderAmt is the player index - kRenderFxExplode, // Scale up really big! - kRenderFxGlowShell, // Glowing Shell - kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!) - kRenderFxLightMultiplier, //CTM !!!CZERO added to tell the studiorender that the value in iuser2 is a lightmultiplier -}; - - -typedef unsigned int func_t; -typedef unsigned int string_t; - -typedef unsigned char byte; -typedef unsigned short word; -#define _DEF_BYTE_ - -#undef true -#undef false - -#ifndef __cplusplus -typedef enum {false, true} qboolean; -#else -typedef int qboolean; -#endif - -typedef struct -{ - byte r, g, b; -} color24; - -typedef struct -{ - unsigned r, g, b, a; -} colorVec; - -#ifdef _WIN32 -#pragma pack(push,2) -#endif - -typedef struct -{ - unsigned short r, g, b, a; -} PackedColorVec; - -#ifdef _WIN32 -#pragma pack(pop) -#endif -typedef struct link_s -{ - struct link_s *prev, *next; -} link_t; - -typedef struct edict_s edict_t; - -typedef struct -{ - vec3_t normal; - float dist; -} plane_t; - -typedef struct -{ - qboolean allsolid; // if true, plane is not valid - qboolean startsolid; // if true, the initial point was in a solid area - qboolean inopen, inwater; - float fraction; // time completed, 1.0 = didn't hit anything - vec3_t endpos; // final position - plane_t plane; // surface normal at impact - edict_t *ent; // entity the surface is on - int hitgroup; // 0 == generic, non zero is specific body part -} trace_t; - -#endif - diff --git a/HLSDK/common/crc.h b/HLSDK/common/crc.h deleted file mode 100644 index eba4ab8..0000000 --- a/HLSDK/common/crc.h +++ /dev/null @@ -1,65 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -/* crc.h */ -#ifndef CRC_H -#define CRC_H -#ifdef _WIN32 -#pragma once -#endif - -#include "archtypes.h" // DAL - -// MD5 Hash -typedef struct -{ - unsigned int buf[4]; - unsigned int bits[2]; - unsigned char in[64]; -} MD5Context_t; - - -#ifdef _WIN32 -typedef uint32 CRC32_t; -#else -typedef uint32 CRC32_t; -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif -void CRC32_Init(CRC32_t *pulCRC); -CRC32_t CRC32_Final(CRC32_t pulCRC); -void CRC32_ProcessBuffer(CRC32_t *pulCRC, void *p, int len); -void CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch); -int CRC_File(CRC32_t *crcvalue, char *pszFileName); -#ifdef __cplusplus -} -#endif -unsigned char COM_BlockSequenceCRCByte (unsigned char *base, int length, int sequence); - -void MD5Init(MD5Context_t *context); -void MD5Update(MD5Context_t *context, unsigned char const *buf, - unsigned int len); -void MD5Final(unsigned char digest[16], MD5Context_t *context); -void Transform(unsigned int buf[4], unsigned int const in[16]); - -int MD5_Hash_File(unsigned char digest[16], char *pszFileName, int bUsefopen, int bSeed, unsigned int seed[4]); -char *MD5_Print(unsigned char hash[16]); -int MD5_Hash_CachedFile(unsigned char digest[16], unsigned char *pCache, int nFileSize, int bSeed, unsigned int seed[4]); - -int CRC_MapFile(CRC32_t *crcvalue, char *pszFileName); - -#endif diff --git a/HLSDK/common/cvardef.h b/HLSDK/common/cvardef.h deleted file mode 100644 index 16044ab..0000000 --- a/HLSDK/common/cvardef.h +++ /dev/null @@ -1,37 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef CVARDEF_H -#define CVARDEF_H - -#define FCVAR_ARCHIVE (1<<0) // set to cause it to be saved to vars.rc -#define FCVAR_USERINFO (1<<1) // changes the client's info string -#define FCVAR_SERVER (1<<2) // notifies players when changed -#define FCVAR_EXTDLL (1<<3) // defined by external DLL -#define FCVAR_CLIENTDLL (1<<4) // defined by the client dll -#define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value -#define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server. -#define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). -#define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log -#define FCVAR_NOEXTRAWHITEPACE (1<<9) // strip trailing/leading white space from this cvar - -typedef struct cvar_s -{ - char *name; - char *string; - int flags; - float value; - struct cvar_s *next; -} cvar_t; -#endif diff --git a/HLSDK/common/demo_api.h b/HLSDK/common/demo_api.h deleted file mode 100644 index 8284a81..0000000 --- a/HLSDK/common/demo_api.h +++ /dev/null @@ -1,31 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( DEMO_APIH ) -#define DEMO_APIH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct demo_api_s -{ - int ( *IsRecording ) ( void ); - int ( *IsPlayingback ) ( void ); - int ( *IsTimeDemo ) ( void ); - void ( *WriteBuffer ) ( int size, unsigned char *buffer ); -} demo_api_t; - -extern demo_api_t demoapi; - -#endif diff --git a/HLSDK/common/director_cmds.h b/HLSDK/common/director_cmds.h deleted file mode 100644 index 4c8fdd5..0000000 --- a/HLSDK/common/director_cmds.h +++ /dev/null @@ -1,38 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// director_cmds.h -// sub commands for svc_director - -#define DRC_ACTIVE 0 // tells client that he's an spectator and will get director command -#define DRC_STATUS 1 // send status infos about proxy -#define DRC_CAMERA 2 // set the actual director camera position -#define DRC_EVENT 3 // informs the dircetor about ann important game event - - -#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important) -#define DRC_FLAG_SIDE (1<<4) -#define DRC_FLAG_DRAMATIC (1<<5) - - - -// commands of the director API function CallDirectorProc(...) - -#define DRCAPI_NOP 0 // no operation -#define DRCAPI_ACTIVE 1 // de/acivates director mode in engine -#define DRCAPI_STATUS 2 // request proxy information -#define DRCAPI_SETCAM 3 // set camera n to given position and angle -#define DRCAPI_GETCAM 4 // request camera n position and angle -#define DRCAPI_DIRPLAY 5 // set director time and play with normal speed -#define DRCAPI_DIRFREEZE 6 // freeze directo at this time -#define DRCAPI_SETVIEWMODE 7 // overview or 4 cameras -#define DRCAPI_SETOVERVIEWPARAMS 8 // sets parameter for overview mode -#define DRCAPI_SETFOCUS 9 // set the camera which has the input focus -#define DRCAPI_GETTARGETS 10 // queries engine for player list -#define DRCAPI_SETVIEWPOINTS 11 // gives engine all waypoints - - diff --git a/HLSDK/common/dlight.h b/HLSDK/common/dlight.h deleted file mode 100644 index f869c98..0000000 --- a/HLSDK/common/dlight.h +++ /dev/null @@ -1,33 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( DLIGHTH ) -#define DLIGHTH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct dlight_s -{ - vec3_t origin; - float radius; - color24 color; - float die; // stop lighting after this time - float decay; // drop this each second - float minlight; // don't add when contributing less - int key; - qboolean dark; // subtracts light instead of adding -} dlight_t; - -#endif diff --git a/HLSDK/common/dll_state.h b/HLSDK/common/dll_state.h deleted file mode 100644 index 4065162..0000000 --- a/HLSDK/common/dll_state.h +++ /dev/null @@ -1,23 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -//DLL State Flags - -#define DLL_INACTIVE 0 // no dll -#define DLL_ACTIVE 1 // dll is running -#define DLL_PAUSED 2 // dll is paused -#define DLL_CLOSE 3 // closing down dll -#define DLL_TRANS 4 // Level Transition - -// DLL Pause reasons - -#define DLL_NORMAL 0 // User hit Esc or something. -#define DLL_QUIT 4 // Quit now -#define DLL_RESTART 6 // Switch to launcher for linux, does a quit but returns 1 - -// DLL Substate info ( not relevant ) -#define ENG_NORMAL (1<<0) diff --git a/HLSDK/common/entity_state.h b/HLSDK/common/entity_state.h deleted file mode 100644 index 3d2d44a..0000000 --- a/HLSDK/common/entity_state.h +++ /dev/null @@ -1,193 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( ENTITY_STATEH ) -#define ENTITY_STATEH -#ifdef _WIN32 -#pragma once -#endif - -// For entityType below -#define ENTITY_NORMAL (1<<0) -#define ENTITY_BEAM (1<<1) - -// Entity state is used for the baseline and for delta compression of a packet of -// entities that is sent to a client. -typedef struct entity_state_s entity_state_t; - -struct entity_state_s -{ -// Fields which are filled in by routines outside of delta compression - int entityType; - // Index into cl_entities array for this entity. - int number; - float msg_time; - - // Message number last time the player/entity state was updated. - int messagenum; - - // Fields which can be transitted and reconstructed over the network stream - vec3_t origin; - vec3_t angles; - - int modelindex; - int sequence; - float frame; - int colormap; - short skin; - short solid; - int effects; - float scale; - - byte eflags; - - // Render information - int rendermode; - int renderamt; - color24 rendercolor; - int renderfx; - - int movetype; - float animtime; - float framerate; - int body; - byte controller[4]; - byte blending[4]; - vec3_t velocity; - - // Send bbox down to client for use during prediction. - vec3_t mins; - vec3_t maxs; - - int aiment; - // If owned by a player, the index of that player ( for projectiles ). - int owner; - - // Friction, for prediction. - float friction; - // Gravity multiplier - float gravity; - -// PLAYER SPECIFIC - int team; - int playerclass; - int health; - qboolean spectator; - int weaponmodel; - int gaitsequence; - // If standing on conveyor, e.g. - vec3_t basevelocity; - // Use the crouched hull, or the regular player hull. - int usehull; - // Latched buttons last time state updated. - int oldbuttons; - // -1 = in air, else pmove entity number - int onground; - int iStepLeft; - // How fast we are falling - float flFallVelocity; - - float fov; - int weaponanim; - - // Parametric movement overrides - vec3_t startpos; - vec3_t endpos; - float impacttime; - float starttime; - - // For mods - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; -}; - -#include "pm_info.h" - -typedef struct clientdata_s -{ - vec3_t origin; - vec3_t velocity; - - int viewmodel; - vec3_t punchangle; - int flags; - int waterlevel; - int watertype; - vec3_t view_ofs; - float health; - - int bInDuck; - - int weapons; // remove? - - int flTimeStepSound; - int flDuckTime; - int flSwimTime; - int waterjumptime; - - float maxspeed; - - float fov; - int weaponanim; - - int m_iId; - int ammo_shells; - int ammo_nails; - int ammo_cells; - int ammo_rockets; - float m_flNextAttack; - - int tfstate; - - int pushmsec; - - int deadflag; - - char physinfo[ MAX_PHYSINFO_STRING ]; - - // For mods - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; -} clientdata_t; - -#include "weaponinfo.h" - -typedef struct local_state_s -{ - entity_state_t playerstate; - clientdata_t client; - weapon_data_t weapondata[ 64 ]; -} local_state_t; - -#endif // !ENTITY_STATEH diff --git a/HLSDK/common/entity_types.h b/HLSDK/common/entity_types.h deleted file mode 100644 index ff783df..0000000 --- a/HLSDK/common/entity_types.h +++ /dev/null @@ -1,26 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// entity_types.h -#if !defined( ENTITY_TYPESH ) -#define ENTITY_TYPESH - -#define ET_NORMAL 0 -#define ET_PLAYER 1 -#define ET_TEMPENTITY 2 -#define ET_BEAM 3 -// BMODEL or SPRITE that was split across BSP nodes -#define ET_FRAGMENTED 4 - -#endif // !ENTITY_TYPESH diff --git a/HLSDK/common/enums.h b/HLSDK/common/enums.h deleted file mode 100644 index 1590191..0000000 --- a/HLSDK/common/enums.h +++ /dev/null @@ -1,27 +0,0 @@ -/*** - * - * Copyright (c) 2009, Valve LLC. All rights reserved. - * - * This product contains software technology licensed from Id - * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. - * All Rights Reserved. - * - * Use, distribution, and modification of this source code and/or resulting - * object code is restricted to non-commercial enhancements to products from - * Valve LLC. All other use, distribution, or modification is prohibited - * without written permission from Valve LLC. - * - ****/ - -#ifndef ENUMS_H -#define ENUMS_H - -typedef enum netsrc_s - { - NS_CLIENT, - NS_SERVER, - NS_MULTICAST // xxxMO - } netsrc_t; - -#endif - diff --git a/HLSDK/common/event_api.h b/HLSDK/common/event_api.h deleted file mode 100644 index 722dfe2..0000000 --- a/HLSDK/common/event_api.h +++ /dev/null @@ -1,51 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( EVENT_APIH ) -#define EVENT_APIH -#ifdef _WIN32 -#pragma once -#endif - -#define EVENT_API_VERSION 1 - -typedef struct event_api_s -{ - int version; - void ( *EV_PlaySound ) ( int ent, float *origin, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch ); - void ( *EV_StopSound ) ( int ent, int channel, const char *sample ); - int ( *EV_FindModelIndex )( const char *pmodel ); - int ( *EV_IsLocal ) ( int playernum ); - int ( *EV_LocalPlayerDucking ) ( void ); - void ( *EV_LocalPlayerViewheight ) ( float * ); - void ( *EV_LocalPlayerBounds ) ( int hull, float *mins, float *maxs ); - int ( *EV_IndexFromTrace) ( struct pmtrace_s *pTrace ); - struct physent_s *( *EV_GetPhysent ) ( int idx ); - void ( *EV_SetUpPlayerPrediction ) ( int dopred, int bIncludeLocalClient ); - void ( *EV_PushPMStates ) ( void ); - void ( *EV_PopPMStates ) ( void ); - void ( *EV_SetSolidPlayers ) (int playernum); - void ( *EV_SetTraceHull ) ( int hull ); - void ( *EV_PlayerTrace ) ( float *start, float *end, int traceFlags, int ignore_pe, struct pmtrace_s *tr ); - void ( *EV_WeaponAnimation ) ( int sequence, int body ); - unsigned short ( *EV_PrecacheEvent ) ( int type, const char* psz ); - void ( *EV_PlaybackEvent ) ( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); - const char *( *EV_TraceTexture ) ( int ground, float *vstart, float *vend ); - void ( *EV_StopAllSounds ) ( int entnum, int entchannel ); - void ( *EV_KillEvents ) ( int entnum, const char *eventname ); -} event_api_t; - -extern event_api_t eventapi; - -#endif diff --git a/HLSDK/common/event_args.h b/HLSDK/common/event_args.h deleted file mode 100644 index 99dd49a..0000000 --- a/HLSDK/common/event_args.h +++ /dev/null @@ -1,50 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( EVENT_ARGSH ) -#define EVENT_ARGSH -#ifdef _WIN32 -#pragma once -#endif - -// Event was invoked with stated origin -#define FEVENT_ORIGIN ( 1<<0 ) - -// Event was invoked with stated angles -#define FEVENT_ANGLES ( 1<<1 ) - -typedef struct event_args_s -{ - int flags; - - // Transmitted - int entindex; - - float origin[3]; - float angles[3]; - float velocity[3]; - - int ducking; - - float fparam1; - float fparam2; - - int iparam1; - int iparam2; - - int bparam1; - int bparam2; -} event_args_t; - -#endif diff --git a/HLSDK/common/event_flags.h b/HLSDK/common/event_flags.h deleted file mode 100644 index 43f804f..0000000 --- a/HLSDK/common/event_flags.h +++ /dev/null @@ -1,47 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( EVENT_FLAGSH ) -#define EVENT_FLAGSH -#ifdef _WIN32 -#pragma once -#endif - -// Skip local host for event send. -#define FEV_NOTHOST (1<<0) - -// Send the event reliably. You must specify the origin and angles and use -// PLAYBACK_EVENT_FULL for this to work correctly on the server for anything -// that depends on the event origin/angles. I.e., the origin/angles are not -// taken from the invoking edict for reliable events. -#define FEV_RELIABLE (1<<1) - -// Don't restrict to PAS/PVS, send this event to _everybody_ on the server ( useful for stopping CHAN_STATIC -// sounds started by client event when client is not in PVS anymore ( hwguy in TFC e.g. ). -#define FEV_GLOBAL (1<<2) - -// If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate -// -#define FEV_UPDATE (1<<3) - -// Only send to entity specified as the invoker -#define FEV_HOSTONLY (1<<4) - -// Only send if the event was created on the server. -#define FEV_SERVER (1<<5) - -// Only issue event client side ( from shared code ) -#define FEV_CLIENT (1<<6) - -#endif diff --git a/HLSDK/common/hltv.h b/HLSDK/common/hltv.h deleted file mode 100644 index ab7184c..0000000 --- a/HLSDK/common/hltv.h +++ /dev/null @@ -1,54 +0,0 @@ -// hltv.h -// all shared consts between server, clients and proxy - -#ifndef HLTV_H -#define HLTV_H - -#define TYPE_CLIENT 0 // client is a normal HL client (default) -#define TYPE_PROXY 1 // client is another proxy -#define TYPE_COMMENTATOR 3 // client is a commentator -#define TYPE_DEMO 4 // client is a demo file - -// sub commands of svc_hltv: -#define HLTV_ACTIVE 0 // tells client that he's an spectator and will get director commands -#define HLTV_STATUS 1 // send status infos about proxy -#define HLTV_LISTEN 2 // tell client to listen to a multicast stream - -// director command types: -#define DRC_CMD_NONE 0 // NULL director command -#define DRC_CMD_START 1 // start director mode -#define DRC_CMD_EVENT 2 // informs about director command -#define DRC_CMD_MODE 3 // switches camera modes -#define DRC_CMD_CAMERA 4 // set fixed camera -#define DRC_CMD_TIMESCALE 5 // sets time scale -#define DRC_CMD_MESSAGE 6 // send HUD centerprint -#define DRC_CMD_SOUND 7 // plays a particular sound -#define DRC_CMD_STATUS 8 // HLTV broadcast status -#define DRC_CMD_BANNER 9 // set GUI banner -#define DRC_CMD_STUFFTEXT 10 // like the normal svc_stufftext but as director command -#define DRC_CMD_CHASE 11 // chase a certain player -#define DRC_CMD_INEYE 12 // view player through own eyes -#define DRC_CMD_MAP 13 // show overview map -#define DRC_CMD_CAMPATH 14 // define camera waypoint -#define DRC_CMD_WAYPOINTS 15 // start moving camera, inetranl message - -#define DRC_CMD_LAST 15 - - -// DRC_CMD_EVENT event flags -#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important) -#define DRC_FLAG_SIDE (1<<4) // -#define DRC_FLAG_DRAMATIC (1<<5) // is a dramatic scene -#define DRC_FLAG_SLOWMOTION (1<<6) // would look good in SloMo -#define DRC_FLAG_FACEPLAYER (1<<7) // player is doning something (reload/defuse bomb etc) -#define DRC_FLAG_INTRO (1<<8) // is a introduction scene -#define DRC_FLAG_FINAL (1<<9) // is a final scene -#define DRC_FLAG_NO_RANDOM (1<<10) // don't randomize event data - - -// DRC_CMD_WAYPOINT flags -#define DRC_FLAG_STARTPATH 1 // end with speed 0.0 -#define DRC_FLAG_SLOWSTART 2 // start with speed 0.0 -#define DRC_FLAG_SLOWEND 4 // end with speed 0.0 - -#endif // HLTV_H diff --git a/HLSDK/common/in_buttons.h b/HLSDK/common/in_buttons.h deleted file mode 100644 index 4196a2d..0000000 --- a/HLSDK/common/in_buttons.h +++ /dev/null @@ -1,38 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef IN_BUTTONS_H -#define IN_BUTTONS_H -#ifdef _WIN32 -#pragma once -#endif - -#define IN_ATTACK (1 << 0) -#define IN_JUMP (1 << 1) -#define IN_DUCK (1 << 2) -#define IN_FORWARD (1 << 3) -#define IN_BACK (1 << 4) -#define IN_USE (1 << 5) -#define IN_CANCEL (1 << 6) -#define IN_LEFT (1 << 7) -#define IN_RIGHT (1 << 8) -#define IN_MOVELEFT (1 << 9) -#define IN_MOVERIGHT (1 << 10) -#define IN_ATTACK2 (1 << 11) -#define IN_RUN (1 << 12) -#define IN_RELOAD (1 << 13) -#define IN_ALT1 (1 << 14) -#define IN_SCORE (1 << 15) // Used by client.dll for when scoreboard is held down - -#endif // IN_BUTTONS_H diff --git a/HLSDK/common/interface.cpp b/HLSDK/common/interface.cpp deleted file mode 100644 index 4b2f391..0000000 --- a/HLSDK/common/interface.cpp +++ /dev/null @@ -1,109 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#include -#include -#include "interface.h" - -#ifndef _WIN32 // LINUX -#include -#include -#endif - -// ------------------------------------------------------------------------------------ // -// InterfaceReg. -// ------------------------------------------------------------------------------------ // -InterfaceReg *InterfaceReg::s_pInterfaceRegs = NULL; - -InterfaceReg::InterfaceReg(InstantiateInterfaceFn fn, const char *pName) : - m_pName(pName) -{ - m_CreateFn = fn; - m_pNext = s_pInterfaceRegs; - s_pInterfaceRegs = this; -} - -// ------------------------------------------------------------------------------------ // -// CreateInterface. -// ------------------------------------------------------------------------------------ // -EXPORT_FUNCTION IBaseInterface *CreateInterface(const char *pName, int *pReturnCode) -{ - InterfaceReg *pCur; - - for (pCur = InterfaceReg::s_pInterfaceRegs; pCur; pCur = pCur->m_pNext) - { - if (strcmp(pCur->m_pName, pName) == 0) - { - if (pReturnCode) - { - *pReturnCode = IFACE_OK; - } - return pCur->m_CreateFn(); - } - } - - if (pReturnCode) - { - *pReturnCode = IFACE_FAILED; - } - return NULL; -} - -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include "windows.h" -#endif - -HINTERFACEMODULE Sys_LoadModule(const char *pModuleName) -{ -#ifdef _WIN32 - return (HINTERFACEMODULE)LoadLibrary(pModuleName); -#else // LINUX - // Linux dlopen() doesn't look in the current directory for libraries. - // We tell it to, so people don't have to 'install' libraries as root. - std::string library_path = std::filesystem::current_path().string() + "/" + pModuleName; - - return (HINTERFACEMODULE)dlopen(library_path.c_str(), RTLD_NOW); -#endif -} - -void Sys_FreeModule(HINTERFACEMODULE hModule) -{ - if (!hModule) - return; -#ifdef _WIN32 - FreeLibrary((HMODULE)hModule); -#else // LINUX - dlclose((void *)hModule); -#endif -} - -//----------------------------------------------------------------------------- -// Purpose: returns the instance of this module -// Output : interface_instance_t -//----------------------------------------------------------------------------- -CreateInterfaceFn Sys_GetFactoryThis(void) -{ - return CreateInterface; -} - -//----------------------------------------------------------------------------- -// Purpose: returns the instance of the named module -// Input : *pModuleName - name of the module -// Output : interface_instance_t - instance of that module -//----------------------------------------------------------------------------- - -CreateInterfaceFn Sys_GetFactory(HINTERFACEMODULE hModule) -{ - if (!hModule) - return nullptr; -#ifdef _WIN32 - return (CreateInterfaceFn)GetProcAddress((HMODULE)hModule, CREATEINTERFACE_PROCNAME); -#else // LINUX - return (CreateInterfaceFn)dlsym((void *)hModule, CREATEINTERFACE_PROCNAME); -#endif -} \ No newline at end of file diff --git a/HLSDK/common/ivoicetweak.h b/HLSDK/common/ivoicetweak.h deleted file mode 100644 index d5e6b3e..0000000 --- a/HLSDK/common/ivoicetweak.h +++ /dev/null @@ -1,38 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef IVOICETWEAK_H -#define IVOICETWEAK_H -#ifdef _WIN32 -#pragma once -#endif - -// These provide access to the voice controls. -typedef enum -{ - MicrophoneVolume=0, // values 0-1. - OtherSpeakerScale, // values 0-1. Scales how loud other players are. - MicBoost, // 20 db gain to voice input -} VoiceTweakControl; - - -typedef struct IVoiceTweak_s -{ - // These turn voice tweak mode on and off. While in voice tweak mode, the user's voice is echoed back - // without sending to the server. - int (*StartVoiceTweakMode)(); // Returns 0 on error. - void (*EndVoiceTweakMode)(); - - // Get/set control values. - void (*SetControlFloat)(VoiceTweakControl iControl, float value); - float (*GetControlFloat)(VoiceTweakControl iControl); - - int (*GetSpeakingVolume)(); -} IVoiceTweak; - - -#endif // IVOICETWEAK_H diff --git a/HLSDK/common/mathlib.h b/HLSDK/common/mathlib.h deleted file mode 100644 index f5a0c37..0000000 --- a/HLSDK/common/mathlib.h +++ /dev/null @@ -1,158 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// mathlib.h - -typedef float vec_t; -#ifndef DID_VEC3_T_DEFINE -#define DID_VEC3_T_DEFINE -typedef vec_t vec3_t[3]; -#endif -typedef vec_t vec4_t[4]; // x,y,z,w -typedef vec_t vec5_t[5]; - -typedef short vec_s_t; -typedef vec_s_t vec3s_t[3]; -typedef vec_s_t vec4s_t[4]; // x,y,z,w -typedef vec_s_t vec5s_t[5]; - -typedef int fixed4_t; -typedef int fixed8_t; -typedef int fixed16_t; -#ifndef M_PI -#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h -#endif - -struct mplane_s; - -extern vec3_t vec3_origin; -extern int nanmask; - -#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask) - -#ifndef VECTOR_H - #define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) -#endif - -#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];} -#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];} -#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];} -#define VectorClear(a) {(a)[0]=0.0;(a)[1]=0.0;(a)[2]=0.0;} - -void VectorMA (const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc); - -vec_t _DotProduct (vec3_t v1, vec3_t v2); -void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out); -void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out); -void _VectorCopy (vec3_t in, vec3_t out); - -int VectorCompare (const vec3_t v1, const vec3_t v2); -float Length (const vec3_t v); -void CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross); -float VectorNormalize (vec3_t v); // returns vector length -void VectorInverse (vec3_t v); -void VectorScale (const vec3_t in, vec_t scale, vec3_t out); -int Q_log2(int val); - -void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]); -void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]); - -// Here are some "manual" INLINE routines for doing floating point to integer conversions -extern short new_cw, old_cw; - -typedef union DLONG { - int i[2]; - double d; - float f; - } DLONG; - -extern DLONG dlong; - -#ifdef _WIN32 -void __inline set_fpu_cw(void) -{ -_asm - { wait - fnstcw old_cw - wait - mov ax, word ptr old_cw - or ah, 0xc - mov word ptr new_cw,ax - fldcw new_cw - } -} - -int __inline quick_ftol(float f) -{ - _asm { - // Assumes that we are already in chop mode, and only need a 32-bit int - fld DWORD PTR f - fistp DWORD PTR dlong - } - return dlong.i[0]; -} - -void __inline restore_fpu_cw(void) -{ - _asm fldcw old_cw -} -#else -#define set_fpu_cw() /* */ -#define quick_ftol(f) ftol(f) -#define restore_fpu_cw() /* */ -#endif - -void FloorDivMod (double numer, double denom, int *quotient, - int *rem); -fixed16_t Invert24To16(fixed16_t val); -int GreatestCommonDivisor (int i1, int i2); - -void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); -void AngleVectorsTranspose (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); -#define AngleIVectors AngleVectorsTranspose - -void AngleMatrix (const vec3_t angles, float (*matrix)[4] ); -void AngleIMatrix (const vec3_t angles, float (*matrix)[4] ); -void VectorTransform (const vec3_t in1, float in2[3][4], vec3_t out); - -void NormalizeAngles( vec3_t angles ); -void InterpolateAngles( vec3_t start, vec3_t end, vec3_t output, float frac ); -float AngleBetweenVectors( const vec3_t v1, const vec3_t v2 ); - - -void VectorMatrix( vec3_t forward, vec3_t right, vec3_t up); -void VectorAngles( const vec3_t forward, vec3_t angles ); - -int InvertMatrix( const float * m, float *out ); - -int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane); -float anglemod(float a); - - - -#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \ - (((p)->type < 3)? \ - ( \ - ((p)->dist <= (emins)[(p)->type])? \ - 1 \ - : \ - ( \ - ((p)->dist >= (emaxs)[(p)->type])?\ - 2 \ - : \ - 3 \ - ) \ - ) \ - : \ - BoxOnPlaneSide( (emins), (emaxs), (p))) diff --git a/HLSDK/common/net_api.h b/HLSDK/common/net_api.h deleted file mode 100644 index 49c39e7..0000000 --- a/HLSDK/common/net_api.h +++ /dev/null @@ -1,99 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#if !defined( NET_APIH ) -#define NET_APIH -#ifdef _WIN32 -#pragma once -#endif - -#if !defined ( NETADRH ) -#include "netadr.h" -#endif - -#define NETAPI_REQUEST_SERVERLIST ( 0 ) // Doesn't need a remote address -#define NETAPI_REQUEST_PING ( 1 ) -#define NETAPI_REQUEST_RULES ( 2 ) -#define NETAPI_REQUEST_PLAYERS ( 3 ) -#define NETAPI_REQUEST_DETAILS ( 4 ) - -// Set this flag for things like broadcast requests, etc. where the engine should not -// kill the request hook after receiving the first response -#define FNETAPI_MULTIPLE_RESPONSE ( 1<<0 ) - -typedef void ( *net_api_response_func_t ) ( struct net_response_s *response ); - -#define NET_SUCCESS ( 0 ) -#define NET_ERROR_TIMEOUT ( 1<<0 ) -#define NET_ERROR_PROTO_UNSUPPORTED ( 1<<1 ) -#define NET_ERROR_UNDEFINED ( 1<<2 ) - -typedef struct net_adrlist_s -{ - struct net_adrlist_s *next; - netadr_t remote_address; -} net_adrlist_t; - -typedef struct net_response_s -{ - // NET_SUCCESS or an error code - int error; - - // Context ID - int context; - // Type - int type; - - // Server that is responding to the request - netadr_t remote_address; - - // Response RTT ping time - double ping; - // Key/Value pair string ( separated by backlash \ characters ) - // WARNING: You must copy this buffer in the callback function, because it is freed - // by the engine right after the call!!!! - // ALSO: For NETAPI_REQUEST_SERVERLIST requests, this will be a pointer to a linked list of net_adrlist_t's - void *response; -} net_response_t; - -typedef struct net_status_s -{ - // Connected to remote server? 1 == yes, 0 otherwise - int connected; - // Client's IP address - netadr_t local_address; - // Address of remote server - netadr_t remote_address; - // Packet Loss ( as a percentage ) - int packet_loss; - // Latency, in seconds ( multiply by 1000.0 to get milliseconds ) - double latency; - // Connection time, in seconds - double connection_time; - // Rate setting ( for incoming data ) - double rate; -} net_status_t; - -typedef struct net_api_s -{ - // APIs - void ( *InitNetworking )( void ); - void ( *Status ) ( struct net_status_s *status ); - void ( *SendRequest) ( int context, int request, int flags, double timeout, struct netadr_s *remote_address, net_api_response_func_t response ); - void ( *CancelRequest ) ( int context ); - void ( *CancelAllRequests ) ( void ); - char *( *AdrToString ) ( struct netadr_s *a ); - int ( *CompareAdr ) ( struct netadr_s *a, struct netadr_s *b ); - int ( *StringToAdr ) ( char *s, struct netadr_s *a ); - const char *( *ValueForKey ) ( const char *s, const char *key ); - void ( *RemoveKey ) ( char *s, const char *key ); - void ( *SetValueForKey ) (char *s, const char *key, const char *value, int maxsize ); -} net_api_t; - -extern net_api_t netapi; - -#endif // NET_APIH \ No newline at end of file diff --git a/HLSDK/common/netadr.h b/HLSDK/common/netadr.h deleted file mode 100644 index 304073c..0000000 --- a/HLSDK/common/netadr.h +++ /dev/null @@ -1,40 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// netadr.h -#ifndef NETADR_H -#define NETADR_H -#ifdef _WIN32 -#pragma once -#endif - -typedef enum -{ - NA_UNUSED, - NA_LOOPBACK, - NA_BROADCAST, - NA_IP, - NA_IPX, - NA_BROADCAST_IPX, -} netadrtype_t; - -typedef struct netadr_s -{ - netadrtype_t type; - unsigned char ip[4]; - unsigned char ipx[10]; - unsigned short port; -} netadr_t; - -#endif // NETADR_H diff --git a/HLSDK/common/nowin.h b/HLSDK/common/nowin.h deleted file mode 100644 index cecd2c1..0000000 --- a/HLSDK/common/nowin.h +++ /dev/null @@ -1,16 +0,0 @@ -//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef INC_NOWIN_H -#define INC_NOWIN_H -#ifndef _WIN32 - -#include -#include - -#endif //!_WIN32 -#endif //INC_NOWIN_H diff --git a/HLSDK/common/parsemsg.cpp b/HLSDK/common/parsemsg.cpp deleted file mode 100644 index 6742db2..0000000 --- a/HLSDK/common/parsemsg.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/*** -* -* Copyright (c) 1999, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// -// parsemsg.cpp -// -//-------------------------------------------------------------------------------------------------------------- -#include "parsemsg.h" -#include - -typedef unsigned char byte; -#define true 1 - -static byte *gpBuf; -static int giSize; -static int giRead; -static int giBadRead; - -int READ_OK( void ) -{ - return !giBadRead; -} - -void BEGIN_READ( void *buf, int size ) -{ - giRead = 0; - giBadRead = 0; - giSize = size; - gpBuf = (byte*)buf; -} - - -int READ_CHAR( void ) -{ - int c; - - if (giRead + 1 > giSize) - { - giBadRead = true; - return -1; - } - - c = (signed char)gpBuf[giRead]; - giRead++; - - return c; -} - -int READ_BYTE( void ) -{ - int c; - - if (giRead+1 > giSize) - { - giBadRead = true; - return -1; - } - - c = (unsigned char)gpBuf[giRead]; - giRead++; - - return c; -} - -int READ_SHORT( void ) -{ - int c; - - if (giRead+2 > giSize) - { - giBadRead = true; - return -1; - } - - c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) ); - - giRead += 2; - - return c; -} - -int READ_WORD( void ) -{ - return READ_SHORT(); -} - - -int READ_LONG( void ) -{ - int c; - - if (giRead+4 > giSize) - { - giBadRead = true; - return -1; - } - - c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24); - - giRead += 4; - - return c; -} - -float READ_FLOAT( void ) -{ - union - { - byte b[4]; - float f; - int l; - } dat; - - dat.b[0] = gpBuf[giRead]; - dat.b[1] = gpBuf[giRead+1]; - dat.b[2] = gpBuf[giRead+2]; - dat.b[3] = gpBuf[giRead+3]; - giRead += 4; - -// dat.l = LittleLong (dat.l); - - return dat.f; -} - -char* READ_STRING( void ) -{ - static char string[2048]; - int l,c; - - string[0] = 0; - - l = 0; - do - { - if ( giRead+1 > giSize ) - break; // no more characters - - c = READ_CHAR(); - if (c == -1 || c == 0) - break; - string[l] = c; - l++; - } while (l < sizeof(string)-1); - - string[l] = 0; - - return string; -} - -float READ_COORD( void ) -{ - return (float)(READ_SHORT() * (1.0/8)); -} - -float READ_ANGLE( void ) -{ - return (float)(READ_CHAR() * (360.0/256)); -} - -float READ_HIRESANGLE( void ) -{ - return (float)(READ_SHORT() * (360.0/65536)); -} - -//-------------------------------------------------------------------------------------------------------------- -BufferWriter::BufferWriter() -{ - Init( NULL, 0 ); -} - -//-------------------------------------------------------------------------------------------------------------- -BufferWriter::BufferWriter( unsigned char *buffer, int bufferLen ) -{ - Init( buffer, bufferLen ); -} - -//-------------------------------------------------------------------------------------------------------------- -void BufferWriter::Init( unsigned char *buffer, int bufferLen ) -{ - m_overflow = false; - m_buffer = buffer; - m_remaining = bufferLen; - m_overallLength = bufferLen; -} - -//-------------------------------------------------------------------------------------------------------------- -void BufferWriter::WriteByte( unsigned char data ) -{ - if (!m_buffer || !m_remaining) - { - m_overflow = true; - return; - } - - *m_buffer = data; - ++m_buffer; - --m_remaining; -} - -//-------------------------------------------------------------------------------------------------------------- -void BufferWriter::WriteLong( int data ) -{ - if (!m_buffer || m_remaining < 4) - { - m_overflow = true; - return; - } - - m_buffer[0] = data&0xff; - m_buffer[1] = (data>>8)&0xff; - m_buffer[2] = (data>>16)&0xff; - m_buffer[3] = data>>24; - m_buffer += 4; - m_remaining -= 4; -} - -//-------------------------------------------------------------------------------------------------------------- -void BufferWriter::WriteString( const char *str ) -{ - if (!m_buffer || !m_remaining) - { - m_overflow = true; - return; - } - - if (!str) - str = ""; - - int len = strlen(str)+1; - if ( len > m_remaining ) - { - m_overflow = true; - str = ""; - len = 1; - } - - strcpy((char *)m_buffer, str); - m_remaining -= len; - m_buffer += len; -} - -//-------------------------------------------------------------------------------------------------------------- -int BufferWriter::GetSpaceUsed() -{ - return m_overallLength - m_remaining; -} - -//-------------------------------------------------------------------------------------------------------------- diff --git a/HLSDK/common/parsemsg.h b/HLSDK/common/parsemsg.h deleted file mode 100644 index be7affc..0000000 --- a/HLSDK/common/parsemsg.h +++ /dev/null @@ -1,66 +0,0 @@ -/*** -* -* Copyright (c) 1999, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// -// parsemsg.h -// MDC - copying from cstrike\cl_dll so career-mode stuff can catch messages -// in this dll. (and C++ifying it) -// - -#ifndef PARSEMSG_H -#define PARSEMSG_H - -#define ASSERT( x ) -//-------------------------------------------------------------------------------------------------------------- -void BEGIN_READ( void *buf, int size ); -int READ_CHAR( void ); -int READ_BYTE( void ); -int READ_SHORT( void ); -int READ_WORD( void ); -int READ_LONG( void ); -float READ_FLOAT( void ); -char* READ_STRING( void ); -float READ_COORD( void ); -float READ_ANGLE( void ); -float READ_HIRESANGLE( void ); -int READ_OK( void ); - -//-------------------------------------------------------------------------------------------------------------- -class BufferWriter -{ -public: - BufferWriter(); - BufferWriter( unsigned char *buffer, int bufferLen ); - void Init( unsigned char *buffer, int bufferLen ); - - void WriteByte( unsigned char data ); - void WriteLong( int data ); - void WriteString( const char *str ); - - bool HasOverflowed(); - int GetSpaceUsed(); - -protected: - unsigned char *m_buffer; - int m_remaining; - bool m_overflow; - int m_overallLength; -}; - -//-------------------------------------------------------------------------------------------------------------- - -#endif // PARSEMSG_H - - - diff --git a/HLSDK/common/particledef.h b/HLSDK/common/particledef.h deleted file mode 100644 index 7e4043a..0000000 --- a/HLSDK/common/particledef.h +++ /dev/null @@ -1,57 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( PARTICLEDEFH ) -#define PARTICLEDEFH -#ifdef _WIN32 -#pragma once -#endif - -typedef enum { - pt_static, - pt_grav, - pt_slowgrav, - pt_fire, - pt_explode, - pt_explode2, - pt_blob, - pt_blob2, - pt_vox_slowgrav, - pt_vox_grav, - pt_clientcustom // Must have callback function specified -} ptype_t; - -// !!! if this is changed, it must be changed in d_ifacea.h too !!! -typedef struct particle_s -{ -// driver-usable fields - vec3_t org; - short color; - short packedColor; -// drivers never touch the following fields - struct particle_s *next; - vec3_t vel; - float ramp; - float die; - ptype_t type; - void (*deathfunc)( struct particle_s *particle ); - - // for pt_clientcusttom, we'll call this function each frame - void (*callback)( struct particle_s *particle, float frametime ); - - // For deathfunc, etc. - unsigned char context; -} particle_t; - -#endif diff --git a/HLSDK/common/pmtrace.h b/HLSDK/common/pmtrace.h deleted file mode 100644 index 1784e9c..0000000 --- a/HLSDK/common/pmtrace.h +++ /dev/null @@ -1,43 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( PMTRACEH ) -#define PMTRACEH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct -{ - vec3_t normal; - float dist; -} pmplane_t; - -typedef struct pmtrace_s pmtrace_t; - -struct pmtrace_s -{ - qboolean allsolid; // if true, plane is not valid - qboolean startsolid; // if true, the initial point was in a solid area - qboolean inopen, inwater; // End point is in empty space or in water - float fraction; // time completed, 1.0 = didn't hit anything - vec3_t endpos; // final position - pmplane_t plane; // surface normal at impact - int ent; // entity at impact - vec3_t deltavelocity; // Change in player's velocity caused by impact. - // Only run on server. - int hitgroup; -}; - -#endif diff --git a/HLSDK/common/port.h b/HLSDK/common/port.h deleted file mode 100644 index f449e15..0000000 --- a/HLSDK/common/port.h +++ /dev/null @@ -1,124 +0,0 @@ -// port.h: portability helper -// -////////////////////////////////////////////////////////////////////// - -#if !defined PORT_H -#define PORT_H - -#include "archtypes.h" // DAL - -#ifdef _WIN32 - -// Insert your headers here -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#define WIN32_EXTRA_LEAN - -#include "winsani_in.h" -#include -#include "winsani_out.h" - -#include -#include -#include - -#define snprintf _snprintf -#define vsnprintf _vsnprintf - -#else // _WIN32 - -#include -#include -#include // exit() -#include // strncpy() -#include // tolower() -#include -#include -#include -#include - -typedef unsigned char BYTE; -typedef short int WORD; -typedef unsigned int DWORD; -typedef int32 LONG; -//typedef uint32 ULONG; -#ifndef ARCHTYPES_H -typedef uint32 ULONG; -#endif -typedef void *HANDLE; -#ifndef HMODULE -typedef void *HMODULE; -#endif -typedef char * LPSTR; - -#define __cdecl - - -//const int MAX_PATH = PATH_MAX; -#define MAX_PATH PATH_MAX - -#ifdef LINUX -typedef struct POINT_s -{ - int x; - int y; -} POINT; -typedef void *HINSTANCE; -typedef void *HWND; -typedef void *HDC; -typedef void *HGLRC; - -typedef struct RECT_s -{ - int left; - int right; - int top; - int bottom; -} RECT; -#endif - - -#ifdef __cplusplus - -//#undef FALSE -//#undef TRUE - -#ifdef OSX -//#else -//const bool FALSE = false; -//const bool TRUE = true; -#endif -#endif - -#ifndef NULL - #ifdef __cplusplus - #define NULL 0 - #else - #define NULL ((void *)0) - #endif -#endif - -#ifdef __cplusplus -inline int ioctlsocket( int d, int cmd, uint32 *argp ) { return ioctl( d, cmd, argp ); } -inline int closesocket( int fd ) { return close( fd ); } -inline char * GetCurrentDirectory( size_t size, char * buf ) { return getcwd( buf, size ); } -inline int WSAGetLastError() { return errno; } - -inline void DebugBreak( void ) { exit( 1 ); } -#endif - -extern char g_szEXEName[ 4096 ]; - -#define _snprintf snprintf - -#if defined(OSX) -#define SO_ARCH_SUFFIX ".dylib" -#else -#if defined ( __x86_64__ ) -#define SO_ARCH_SUFFIX "_amd64.so" -#else -#define SO_ARCH_SUFFIX ".so" -#endif -#endif -#endif - -#endif // PORT_H diff --git a/HLSDK/common/qfont.h b/HLSDK/common/qfont.h deleted file mode 100644 index 2fc8129..0000000 --- a/HLSDK/common/qfont.h +++ /dev/null @@ -1,41 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( QFONTH ) -#define QFONTH -#ifdef _WIN32 -#pragma once -#endif - -// Font stuff - -#define NUM_GLYPHS 256 -// does not exist: // #include "basetypes.h" - -typedef struct -{ - short startoffset; - short charwidth; -} charinfo; - -typedef struct qfont_s -{ - int width, height; - int rowcount; - int rowheight; - charinfo fontinfo[ NUM_GLYPHS ]; - unsigned char data[4]; -} qfont_t; - -#endif // qfont.h diff --git a/HLSDK/common/r_efx.h b/HLSDK/common/r_efx.h deleted file mode 100644 index e57a70c..0000000 --- a/HLSDK/common/r_efx.h +++ /dev/null @@ -1,197 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( R_EFXH ) -#define R_EFXH -#ifdef _WIN32 -#pragma once -#endif - -// particle_t -#if !defined( PARTICLEDEFH ) -#include "particledef.h" -#endif - -// BEAM -#if !defined( BEAMDEFH ) -#include "beamdef.h" -#endif - -// dlight_t -#if !defined ( DLIGHTH ) -#include "dlight.h" -#endif - -// cl_entity_t -#if !defined( CL_ENTITYH ) -#include "cl_entity.h" -#endif - -/* -// FOR REFERENCE, These are the built-in tracer colors. Note, color 4 is the one -// that uses the tracerred/tracergreen/tracerblue and traceralpha cvar settings -color24 gTracerColors[] = -{ - { 255, 255, 255 }, // White - { 255, 0, 0 }, // Red - { 0, 255, 0 }, // Green - { 0, 0, 255 }, // Blue - { 0, 0, 0 }, // Tracer default, filled in from cvars, etc. - { 255, 167, 17 }, // Yellow-orange sparks - { 255, 130, 90 }, // Yellowish streaks (garg) - { 55, 60, 144 }, // Blue egon streak - { 255, 130, 90 }, // More Yellowish streaks (garg) - { 255, 140, 90 }, // More Yellowish streaks (garg) - { 200, 130, 90 }, // More red streaks (garg) - { 255, 120, 70 }, // Darker red streaks (garg) -}; -*/ - -// Temporary entity array -#define TENTPRIORITY_LOW 0 -#define TENTPRIORITY_HIGH 1 - -// TEMPENTITY flags -#define FTENT_NONE 0x00000000 -#define FTENT_SINEWAVE 0x00000001 -#define FTENT_GRAVITY 0x00000002 -#define FTENT_ROTATE 0x00000004 -#define FTENT_SLOWGRAVITY 0x00000008 -#define FTENT_SMOKETRAIL 0x00000010 -#define FTENT_COLLIDEWORLD 0x00000020 -#define FTENT_FLICKER 0x00000040 -#define FTENT_FADEOUT 0x00000080 -#define FTENT_SPRANIMATE 0x00000100 -#define FTENT_HITSOUND 0x00000200 -#define FTENT_SPIRAL 0x00000400 -#define FTENT_SPRCYCLE 0x00000800 -#define FTENT_COLLIDEALL 0x00001000 // will collide with world and slideboxes -#define FTENT_PERSIST 0x00002000 // tent is not removed when unable to draw -#define FTENT_COLLIDEKILL 0x00004000 // tent is removed upon collision with anything -#define FTENT_PLYRATTACHMENT 0x00008000 // tent is attached to a player (owner) -#define FTENT_SPRANIMATELOOP 0x00010000 // animating sprite doesn't die when last frame is displayed -#define FTENT_SPARKSHOWER 0x00020000 -#define FTENT_NOMODEL 0x00040000 // Doesn't have a model, never try to draw ( it just triggers other things ) -#define FTENT_CLIENTCUSTOM 0x00080000 // Must specify callback. Callback function is responsible for killing tempent and updating fields ( unless other flags specify how to do things ) - -typedef struct tempent_s -{ - int flags; - float die; - float frameMax; - float x; - float y; - float z; - float fadeSpeed; - float bounceFactor; - int hitSound; - void ( *hitcallback ) ( struct tempent_s *ent, struct pmtrace_s *ptr ); - void ( *callback ) ( struct tempent_s *ent, float frametime, float currenttime ); - struct tempent_s *next; - int priority; - short clientIndex; // if attached, this is the index of the client to stick to - // if COLLIDEALL, this is the index of the client to ignore - // TENTS with FTENT_PLYRATTACHMENT MUST set the clientindex! - - vec3_t tentOffset; // if attached, client origin + tentOffset = tent origin. - cl_entity_t entity; - - // baseline.origin - velocity - // baseline.renderamt - starting fadeout intensity - // baseline.angles - angle velocity -} TEMPENTITY; - -typedef struct efx_api_s efx_api_t; - -struct efx_api_s -{ - particle_t *( *R_AllocParticle ) ( void ( *callback ) ( struct particle_s *particle, float frametime ) ); - void ( *R_BlobExplosion ) ( float * org ); - void ( *R_Blood ) ( float * org, float * dir, int pcolor, int speed ); - void ( *R_BloodSprite ) ( float * org, int colorindex, int modelIndex, int modelIndex2, float size ); - void ( *R_BloodStream ) ( float * org, float * dir, int pcolor, int speed ); - void ( *R_BreakModel ) ( float *pos, float *size, float *dir, float random, float life, int count, int modelIndex, char flags ); - void ( *R_Bubbles ) ( float * mins, float * maxs, float height, int modelIndex, int count, float speed ); - void ( *R_BubbleTrail ) ( float * start, float * end, float height, int modelIndex, int count, float speed ); - void ( *R_BulletImpactParticles ) ( float * pos ); - void ( *R_EntityParticles ) ( struct cl_entity_s *ent ); - void ( *R_Explosion ) ( float *pos, int model, float scale, float framerate, int flags ); - void ( *R_FizzEffect ) ( struct cl_entity_s *pent, int modelIndex, int density ); - void ( *R_FireField ) ( float * org, int radius, int modelIndex, int count, int flags, float life ); - void ( *R_FlickerParticles ) ( float * org ); - void ( *R_FunnelSprite ) ( float *org, int modelIndex, int reverse ); - void ( *R_Implosion ) ( float * end, float radius, int count, float life ); - void ( *R_LargeFunnel ) ( float * org, int reverse ); - void ( *R_LavaSplash ) ( float * org ); - void ( *R_MultiGunshot ) ( float * org, float * dir, float * noise, int count, int decalCount, int *decalIndices ); - void ( *R_MuzzleFlash ) ( float *pos1, int type ); - void ( *R_ParticleBox ) ( float *mins, float *maxs, unsigned char r, unsigned char g, unsigned char b, float life ); - void ( *R_ParticleBurst ) ( float * pos, int size, int color, float life ); - void ( *R_ParticleExplosion ) ( float * org ); - void ( *R_ParticleExplosion2 ) ( float * org, int colorStart, int colorLength ); - void ( *R_ParticleLine ) ( float * start, float *end, unsigned char r, unsigned char g, unsigned char b, float life ); - void ( *R_PlayerSprites ) ( int client, int modelIndex, int count, int size ); - void ( *R_Projectile ) ( float * origin, float * velocity, int modelIndex, int life, int owner, void (*hitcallback)( struct tempent_s *ent, struct pmtrace_s *ptr ) ); - void ( *R_RicochetSound ) ( float * pos ); - void ( *R_RicochetSprite ) ( float *pos, struct model_s *pmodel, float duration, float scale ); - void ( *R_RocketFlare ) ( float *pos ); - void ( *R_RocketTrail ) ( float * start, float * end, int type ); - void ( *R_RunParticleEffect ) ( float * org, float * dir, int color, int count ); - void ( *R_ShowLine ) ( float * start, float * end ); - void ( *R_SparkEffect ) ( float *pos, int count, int velocityMin, int velocityMax ); - void ( *R_SparkShower ) ( float *pos ); - void ( *R_SparkStreaks ) ( float * pos, int count, int velocityMin, int velocityMax ); - void ( *R_Spray ) ( float * pos, float * dir, int modelIndex, int count, int speed, int spread, int rendermode ); - void ( *R_Sprite_Explode ) ( TEMPENTITY *pTemp, float scale, int flags ); - void ( *R_Sprite_Smoke ) ( TEMPENTITY *pTemp, float scale ); - void ( *R_Sprite_Spray ) ( float * pos, float * dir, int modelIndex, int count, int speed, int iRand ); - void ( *R_Sprite_Trail ) ( int type, float * start, float * end, int modelIndex, int count, float life, float size, float amplitude, int renderamt, float speed ); - void ( *R_Sprite_WallPuff ) ( TEMPENTITY *pTemp, float scale ); - void ( *R_StreakSplash ) ( float * pos, float * dir, int color, int count, float speed, int velocityMin, int velocityMax ); - void ( *R_TracerEffect ) ( float * start, float * end ); - void ( *R_UserTracerParticle ) ( float * org, float * vel, float life, int colorIndex, float length, unsigned char deathcontext, void ( *deathfunc)( struct particle_s *particle ) ); - particle_t *( *R_TracerParticles ) ( float * org, float * vel, float life ); - void ( *R_TeleportSplash ) ( float * org ); - void ( *R_TempSphereModel ) ( float *pos, float speed, float life, int count, int modelIndex ); - TEMPENTITY *( *R_TempModel ) ( float *pos, float *dir, float *angles, float life, int modelIndex, int soundtype ); - TEMPENTITY *( *R_DefaultSprite ) ( float *pos, int spriteIndex, float framerate ); - TEMPENTITY *( *R_TempSprite ) ( float *pos, float *dir, float scale, int modelIndex, int rendermode, int renderfx, float a, float life, int flags ); - int ( *Draw_DecalIndex ) ( int id ); - int ( *Draw_DecalIndexFromName ) ( char *name ); - void ( *R_DecalShoot ) ( int textureIndex, int entity, int modelIndex, float * position, int flags ); - void ( *R_AttachTentToPlayer ) ( int client, int modelIndex, float zoffset, float life ); - void ( *R_KillAttachedTents ) ( int client ); - BEAM *( *R_BeamCirclePoints ) ( int type, float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - BEAM *( *R_BeamEntPoint ) ( int startEnt, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - BEAM *( *R_BeamEnts ) ( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - BEAM *( *R_BeamFollow ) ( int startEnt, int modelIndex, float life, float width, float r, float g, float b, float brightness ); - void ( *R_BeamKill ) ( int deadEntity ); - BEAM *( *R_BeamLightning ) ( float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed ); - BEAM *( *R_BeamPoints ) ( float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - BEAM *( *R_BeamRing ) ( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - dlight_t *( *CL_AllocDlight ) ( int key ); - dlight_t *( *CL_AllocElight ) ( int key ); - TEMPENTITY *( *CL_TempEntAlloc ) ( float * org, struct model_s *model ); - TEMPENTITY *( *CL_TempEntAllocNoModel ) ( float * org ); - TEMPENTITY *( *CL_TempEntAllocHigh ) ( float * org, struct model_s *model ); - TEMPENTITY *( *CL_TentEntAllocCustom ) ( float *origin, struct model_s *model, int high, void ( *callback ) ( struct tempent_s *ent, float frametime, float currenttime ) ); - void ( *R_GetPackedColor ) ( short *packed, short color ); - short ( *R_LookupColor ) ( unsigned char r, unsigned char g, unsigned char b ); - void ( *R_DecalRemoveAll ) ( int textureIndex ); //textureIndex points to the decal index in the array, not the actual texture index. - void ( *R_FireCustomDecal ) ( int textureIndex, int entity, int modelIndex, float * position, int flags, float scale ); -}; - -extern efx_api_t efx; - -#endif diff --git a/HLSDK/common/r_studioint.h b/HLSDK/common/r_studioint.h deleted file mode 100644 index 3570993..0000000 --- a/HLSDK/common/r_studioint.h +++ /dev/null @@ -1,144 +0,0 @@ -#if !defined( R_STUDIOINT_H ) -#define R_STUDIOINT_H -#if defined( _WIN32 ) -#pragma once -#endif - -#define STUDIO_INTERFACE_VERSION 1 - -typedef struct engine_studio_api_s -{ - // Allocate number*size bytes and zero it - void *( *Mem_Calloc ) ( int number, size_t size ); - // Check to see if pointer is in the cache - void *( *Cache_Check ) ( struct cache_user_s *c ); - // Load file into cache ( can be swapped out on demand ) - void ( *LoadCacheFile ) ( char *path, struct cache_user_s *cu ); - // Retrieve model pointer for the named model - struct model_s *( *Mod_ForName ) ( const char *name, int crash_if_missing ); - // Retrieve pointer to studio model data block from a model - void *( *Mod_Extradata ) ( struct model_s *mod ); - // Retrieve indexed model from client side model precache list - struct model_s *( *GetModelByIndex ) ( int index ); - // Get entity that is set for rendering - struct cl_entity_s * ( *GetCurrentEntity ) ( void ); - // Get referenced player_info_t - struct player_info_s *( *PlayerInfo ) ( int index ); - // Get most recently received player state data from network system - struct entity_state_s *( *GetPlayerState ) ( int index ); - // Get viewentity - struct cl_entity_s * ( *GetViewEntity ) ( void ); - // Get current frame count, and last two timestampes on client - void ( *GetTimes ) ( int *framecount, double *current, double *old ); - // Get a pointer to a cvar by name - struct cvar_s *( *GetCvar ) ( const char *name ); - // Get current render origin and view vectors ( up, right and vpn ) - void ( *GetViewInfo ) ( float *origin, float *upv, float *rightv, float *vpnv ); - // Get sprite model used for applying chrome effect - struct model_s *( *GetChromeSprite ) ( void ); - // Get model counters so we can incement instrumentation - void ( *GetModelCounters ) ( int **s, int **a ); - // Get software scaling coefficients - void ( *GetAliasScale ) ( float *x, float *y ); - - // Get bone, light, alias, and rotation matrices - float ****( *StudioGetBoneTransform ) ( void ); - float ****( *StudioGetLightTransform )( void ); - float ***( *StudioGetAliasTransform ) ( void ); - float ***( *StudioGetRotationMatrix ) ( void ); - - // Set up body part, and get submodel pointers - void ( *StudioSetupModel ) ( int bodypart, void **ppbodypart, void **ppsubmodel ); - // Check if entity's bbox is in the view frustum - int ( *StudioCheckBBox ) ( void ); - // Apply lighting effects to model - void ( *StudioDynamicLight ) ( struct cl_entity_s *ent, struct alight_s *plight ); - void ( *StudioEntityLight ) ( struct alight_s *plight ); - void ( *StudioSetupLighting ) ( struct alight_s *plighting ); - - // Draw mesh vertices - void ( *StudioDrawPoints ) ( void ); - - // Draw hulls around bones - void ( *StudioDrawHulls ) ( void ); - // Draw bbox around studio models - void ( *StudioDrawAbsBBox ) ( void ); - // Draws bones - void ( *StudioDrawBones ) ( void ); - // Loads in appropriate texture for model - void ( *StudioSetupSkin ) ( void *ptexturehdr, int index ); - // Sets up for remapped colors - void ( *StudioSetRemapColors ) ( int top, int bottom ); - // Set's player model and returns model pointer - struct model_s *( *SetupPlayerModel ) ( int index ); - // Fires any events embedded in animation - void ( *StudioClientEvents ) ( void ); - // Retrieve/set forced render effects flags - int ( *GetForceFaceFlags ) ( void ); - void ( *SetForceFaceFlags ) ( int flags ); - // Tell engine the value of the studio model header - void ( *StudioSetHeader ) ( void *header ); - // Tell engine which model_t * is being renderered - void ( *SetRenderModel ) ( struct model_s *model ); - - // Final state setup and restore for rendering - void ( *SetupRenderer ) ( int rendermode ); - void ( *RestoreRenderer ) ( void ); - - // Set render origin for applying chrome effect - void ( *SetChromeOrigin ) ( void ); - - // True if using D3D/OpenGL - int ( *IsHardware ) ( void ); - - // Only called by hardware interface - void ( *GL_StudioDrawShadow ) ( void ); - void ( *GL_SetRenderMode ) ( int mode ); - - void ( *StudioSetRenderamt ) (int iRenderamt); //!!!CZERO added for rendering glass on viewmodels - void ( *StudioSetCullState ) ( int iCull ); - void ( *StudioRenderShadow ) ( int iSprite, float *p1, float *p2, float *p3, float *p4 ); -} engine_studio_api_t; - -typedef struct server_studio_api_s -{ - // Allocate number*size bytes and zero it - void *( *Mem_Calloc ) ( int number, size_t size ); - // Check to see if pointer is in the cache - void *( *Cache_Check ) ( struct cache_user_s *c ); - // Load file into cache ( can be swapped out on demand ) - void ( *LoadCacheFile ) ( char *path, struct cache_user_s *cu ); - // Retrieve pointer to studio model data block from a model - void *( *Mod_Extradata ) ( struct model_s *mod ); -} server_studio_api_t; - - -// client blending -typedef struct r_studio_interface_s -{ - int version; - int ( *StudioDrawModel ) ( int flags ); - int ( *StudioDrawPlayer ) ( int flags, struct entity_state_s *pplayer ); -} r_studio_interface_t; - -extern r_studio_interface_t *pStudioAPI; - -// server blending -#define SV_BLENDING_INTERFACE_VERSION 1 - -typedef struct sv_blending_interface_s -{ - int version; - - void ( *SV_StudioSetupBones ) ( struct model_s *pModel, - float frame, - int sequence, - const vec3_t angles, - const vec3_t origin, - const byte *pcontroller, - const byte *pblending, - int iBone, - const edict_t *pEdict ); -} sv_blending_interface_t; - -#endif // R_STUDIOINT_H diff --git a/HLSDK/common/ref_params.h b/HLSDK/common/ref_params.h deleted file mode 100644 index 90eb03f..0000000 --- a/HLSDK/common/ref_params.h +++ /dev/null @@ -1,75 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( REF_PARAMSH ) -#define REF_PARAMSH - -typedef struct ref_params_s -{ - // Output - float vieworg[3]; - float viewangles[3]; - - float forward[3]; - float right[3]; - float up[3]; - - // Client frametime; - float frametime; - // Client time - float time; - - // Misc - int intermission; - int paused; - int spectator; - int onground; - int waterlevel; - - float simvel[3]; - float simorg[3]; - - float viewheight[3]; - float idealpitch; - - float cl_viewangles[3]; - - int health; - float crosshairangle[3]; - float viewsize; - - float punchangle[3]; - int maxclients; - int viewentity; - int playernum; - int max_entities; - int demoplayback; - int hardware; - - int smoothing; - - // Last issued usercmd - struct usercmd_s *cmd; - - // Movevars - struct movevars_s *movevars; - - int viewport[4]; // the viewport coordinates x ,y , width, height - - int nextView; // the renderer calls ClientDLL_CalcRefdef() and Renderview - // so long in cycles until this value is 0 (multiple views) - int onlyClientDraw; // if !=0 nothing is drawn by the engine except clientDraw functions -} ref_params_t; - -#endif // !REF_PARAMSH diff --git a/HLSDK/common/screenfade.h b/HLSDK/common/screenfade.h deleted file mode 100644 index 62c0d25..0000000 --- a/HLSDK/common/screenfade.h +++ /dev/null @@ -1,24 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#if !defined( SCREENFADEH ) -#define SCREENFADEH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct screenfade_s -{ - float fadeSpeed; // How fast to fade (tics / second) (+ fade in, - fade out) - float fadeEnd; // When the fading hits maximum - float fadeTotalEnd; // Total End Time of the fade (used for FFADE_OUT) - float fadeReset; // When to reset to not fading (for fadeout and hold) - byte fader, fadeg, fadeb, fadealpha; // Fade color - int fadeFlags; // Fading flags -} screenfade_t; - -#endif // !SCREENFADEH diff --git a/HLSDK/common/studio_event.h b/HLSDK/common/studio_event.h deleted file mode 100644 index c79c210..0000000 --- a/HLSDK/common/studio_event.h +++ /dev/null @@ -1,29 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( STUDIO_EVENTH ) -#define STUDIO_EVENTH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct mstudioevent_s -{ - int frame; - int event; - int type; - char options[64]; -} mstudioevent_t; - -#endif // STUDIO_EVENTH diff --git a/HLSDK/common/triangleapi.h b/HLSDK/common/triangleapi.h deleted file mode 100644 index 069a4d6..0000000 --- a/HLSDK/common/triangleapi.h +++ /dev/null @@ -1,64 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( TRIANGLEAPIH ) -#define TRIANGLEAPIH -#ifdef _WIN32 -#pragma once -#endif - -typedef enum -{ - TRI_FRONT = 0, - TRI_NONE = 1, -} TRICULLSTYLE; - -#define TRI_API_VERSION 1 - -#define TRI_TRIANGLES 0 -#define TRI_TRIANGLE_FAN 1 -#define TRI_QUADS 2 -#define TRI_POLYGON 3 -#define TRI_LINES 4 -#define TRI_TRIANGLE_STRIP 5 -#define TRI_QUAD_STRIP 6 - -typedef struct triangleapi_s -{ - int version; - - void ( *RenderMode )( int mode ); - void ( *Begin )( int primitiveCode ); - void ( *End ) ( void ); - - void ( *Color4f ) ( float r, float g, float b, float a ); - void ( *Color4ub ) ( unsigned char r, unsigned char g, unsigned char b, unsigned char a ); - void ( *TexCoord2f ) ( float u, float v ); - void ( *Vertex3fv ) ( float *worldPnt ); - void ( *Vertex3f ) ( float x, float y, float z ); - void ( *Brightness ) ( float brightness ); - void ( *CullFace ) ( TRICULLSTYLE style ); - int ( *SpriteTexture ) ( struct model_s *pSpriteModel, int frame ); - int ( *WorldToScreen ) ( float *world, float *screen ); // Returns 1 if it's z clipped - void ( *Fog ) ( float flFogColor[3], float flStart, float flEnd, int bOn ); // Works just like GL_FOG, flFogColor is r/g/b. - void ( *ScreenToWorld ) ( float *screen, float *world ); - void ( *GetMatrix ) ( const int pname, float *matrix ); - int ( *BoxInPVS ) ( float *mins, float *maxs ); - void ( *LightAtPoint ) ( float *pos, float *value ); - void ( *Color4fRendermode ) ( float r, float g, float b, float a, int rendermode ); - void ( *FogParams ) ( float flDensity, int iFogSkybox ); // Used with Fog()...sets fog density and whether the fog should be applied to the skybox - -} triangleapi_t; - -#endif // !TRIANGLEAPIH diff --git a/HLSDK/common/usercmd.h b/HLSDK/common/usercmd.h deleted file mode 100644 index 7cdcfe2..0000000 --- a/HLSDK/common/usercmd.h +++ /dev/null @@ -1,41 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef USERCMD_H -#define USERCMD_H -#ifdef _WIN32 -#pragma once -#endif - -typedef struct usercmd_s -{ - short lerp_msec; // Interpolation time on client - byte msec; // Duration in ms of command - vec3_t viewangles; // Command view angles. - -// intended velocities - float forwardmove; // Forward velocity. - float sidemove; // Sideways velocity. - float upmove; // Upward velocity. - byte lightlevel; // Light level at spot where we are standing. - unsigned short buttons; // Attack buttons - byte impulse; // Impulse command issued. - byte weaponselect; // Current weapon id - -// Experimental player impact stuff. - int impact_index; - vec3_t impact_position; -} usercmd_t; - -#endif // USERCMD_H diff --git a/HLSDK/common/weaponinfo.h b/HLSDK/common/weaponinfo.h deleted file mode 100644 index b648652..0000000 --- a/HLSDK/common/weaponinfo.h +++ /dev/null @@ -1,52 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( WEAPONINFOH ) -#define WEAPONINFOH -#ifdef _WIN32 -#pragma once -#endif - -// Info about weapons player might have in his/her possession -typedef struct weapon_data_s -{ - int m_iId; - int m_iClip; - - float m_flNextPrimaryAttack; - float m_flNextSecondaryAttack; - float m_flTimeWeaponIdle; - - int m_fInReload; - int m_fInSpecialReload; - float m_flNextReload; - float m_flPumpTime; - float m_fReloadTime; - - float m_fAimedDamage; - float m_fNextAimBonus; - int m_fInZoom; - int m_iWeaponState; - - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; -} weapon_data_t; - -#endif diff --git a/HLSDK/common/winsani_in.h b/HLSDK/common/winsani_in.h deleted file mode 100644 index d8c8527..0000000 --- a/HLSDK/common/winsani_in.h +++ /dev/null @@ -1,7 +0,0 @@ -#if _MSC_VER >= 1500 // MSVC++ 9.0 (Visual Studio 2008) -#pragma push_macro("ARRAYSIZE") -#ifdef ARRAYSIZE -#undef ARRAYSIZE -#endif -#define HSPRITE WINDOWS_HSPRITE -#endif diff --git a/HLSDK/common/winsani_out.h b/HLSDK/common/winsani_out.h deleted file mode 100644 index 2726950..0000000 --- a/HLSDK/common/winsani_out.h +++ /dev/null @@ -1,4 +0,0 @@ -#if _MSC_VER >= 1500 // MSVC++ 9.0 (Visual Studio 2008) -#undef HSPRITE -#pragma pop_macro("ARRAYSIZE") -#endif diff --git a/HLSDK/dlls/vector.h b/HLSDK/dlls/vector.h deleted file mode 100644 index 2ca0c15..0000000 --- a/HLSDK/dlls/vector.h +++ /dev/null @@ -1,112 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef VECTOR_H -#define VECTOR_H - -//========================================================= -// 2DVector - used for many pathfinding and many other -// operations that are treated as planar rather than 3d. -//========================================================= -class Vector2D -{ -public: - inline Vector2D(void): x(0.0), y(0.0) { } - inline Vector2D(float X, float Y): x(0.0), y(0.0) { x = X; y = Y; } - inline Vector2D operator+(const Vector2D& v) const { return Vector2D(x+v.x, y+v.y); } - inline Vector2D operator-(const Vector2D& v) const { return Vector2D(x-v.x, y-v.y); } - inline Vector2D operator*(float fl) const { return Vector2D(x*fl, y*fl); } - inline Vector2D operator/(float fl) const { return Vector2D(x/fl, y/fl); } - - inline float Length(void) const { return sqrt(x*x + y*y ); } - - inline Vector2D Normalize ( void ) const - { - // Vector2D vec2; - - float flLen = Length(); - if ( flLen == 0 ) - { - return Vector2D( 0, 0 ); - } - else - { - flLen = 1 / flLen; - return Vector2D( x * flLen, y * flLen ); - } - } - - vec_t x, y; -}; - -inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y ); } -inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; } - -//========================================================= -// 3D Vector -//========================================================= -class Vector // same data-layout as engine's vec3_t, -{ // which is a vec_t[3] -public: - // Construction/destruction - inline Vector(void): x(0.0), y(0.0), z(0.0) { } - inline Vector(float X, float Y, float Z): x(0.0), y(0.0), z(0.0) { x = X; y = Y; z = Z; } - //inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; } - //inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z; } - inline Vector(const Vector& v): x(0.0), y(0.0), z(0.0) { x = v.x; y = v.y; z = v.z; } - inline Vector(float rgfl[3]): x(0.0), y(0.0), z(0.0) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } - - // Operators - inline Vector operator-(void) const { return Vector(-x,-y,-z); } - inline int operator==(const Vector& v) const { return x==v.x && y==v.y && z==v.z; } - inline int operator!=(const Vector& v) const { return !(*this==v); } - inline Vector operator+(const Vector& v) const { return Vector(x+v.x, y+v.y, z+v.z); } - inline Vector operator-(const Vector& v) const { return Vector(x-v.x, y-v.y, z-v.z); } - inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); } - inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); } - - // Methods - inline void CopyToArray(float* rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; } - inline float Length(void) const { return sqrt(x*x + y*y + z*z); } - operator float *() { return &x; } // Vectors will now automatically convert to float * when needed - operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed - inline Vector Normalize(void) const - { - float flLen = Length(); - if (flLen == 0) return Vector(0,0,1); // ???? - flLen = 1 / flLen; - return Vector(x * flLen, y * flLen, z * flLen); - } - - inline Vector2D Make2D ( void ) const - { - Vector2D Vec2; - - Vec2.x = x; - Vec2.y = y; - - return Vec2; - } - inline float Length2D(void) const { return sqrt(x*x + y*y); } - - // Members - vec_t x, y, z; -}; -inline Vector operator*(float fl, const Vector& v) { return v * fl; } -inline float DotProduct(const Vector& a, const Vector& b) { return(a.x*b.x+a.y*b.y+a.z*b.z); } -inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); } - - - -#endif diff --git a/HLSDK/engine/APIProxy.h b/HLSDK/engine/APIProxy.h deleted file mode 100644 index b4a07f8..0000000 --- a/HLSDK/engine/APIProxy.h +++ /dev/null @@ -1,939 +0,0 @@ -#ifndef __APIPROXY__ -#define __APIPROXY__ - -#include "archtypes.h" // DAL -#include "netadr.h" -#include "Sequence.h" - -#ifndef _WIN32 -#include "enums.h" -#endif - -#define MAX_ALIAS_NAME 32 - -typedef struct cmdalias_s -{ - struct cmdalias_s *next; - char name[MAX_ALIAS_NAME]; - char *value; -} cmdalias_t; - - -// ******************************************************** -// Functions exported by the client .dll -// ******************************************************** - -// Function type declarations for client exports -typedef int (*INITIALIZE_FUNC) ( struct cl_enginefuncs_s*, int ); -typedef void (*HUD_INIT_FUNC) ( void ); -typedef int (*HUD_VIDINIT_FUNC) ( void ); -typedef int (*HUD_REDRAW_FUNC) ( float, int ); -typedef int (*HUD_UPDATECLIENTDATA_FUNC) ( struct client_data_s*, float ); -typedef void (*HUD_RESET_FUNC) ( void ); -typedef void (*HUD_CLIENTMOVE_FUNC)( struct playermove_s *ppmove, qboolean server ); -typedef void (*HUD_CLIENTMOVEINIT_FUNC)( struct playermove_s *ppmove ); -typedef char (*HUD_TEXTURETYPE_FUNC)( char *name ); -typedef void (*HUD_IN_ACTIVATEMOUSE_FUNC) ( void ); -typedef void (*HUD_IN_DEACTIVATEMOUSE_FUNC) ( void ); -typedef void (*HUD_IN_MOUSEEVENT_FUNC) ( int mstate ); -typedef void (*HUD_IN_CLEARSTATES_FUNC) ( void ); -typedef void (*HUD_IN_ACCUMULATE_FUNC ) ( void ); -typedef void (*HUD_CL_CREATEMOVE_FUNC) ( float frametime, struct usercmd_s *cmd, int active ); -typedef int (*HUD_CL_ISTHIRDPERSON_FUNC) ( void ); -typedef void (*HUD_CL_GETCAMERAOFFSETS_FUNC )( float *ofs ); -typedef struct kbutton_s * (*HUD_KB_FIND_FUNC) ( const char *name ); -typedef void ( *HUD_CAMTHINK_FUNC )( void ); -typedef void ( *HUD_CALCREF_FUNC ) ( struct ref_params_s *pparams ); -typedef int ( *HUD_ADDENTITY_FUNC ) ( int type, struct cl_entity_s *ent, const char *modelname ); -typedef void ( *HUD_CREATEENTITIES_FUNC ) ( void ); -typedef void ( *HUD_DRAWNORMALTRIS_FUNC ) ( void ); -typedef void ( *HUD_DRAWTRANSTRIS_FUNC ) ( void ); -typedef void ( *HUD_STUDIOEVENT_FUNC ) ( const struct mstudioevent_s *event, const struct cl_entity_s *entity ); -typedef void ( *HUD_POSTRUNCMD_FUNC ) ( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed ); -typedef void ( *HUD_SHUTDOWN_FUNC ) ( void ); -typedef void ( *HUD_TXFERLOCALOVERRIDES_FUNC )( struct entity_state_s *state, const struct clientdata_s *client ); -typedef void ( *HUD_PROCESSPLAYERSTATE_FUNC )( struct entity_state_s *dst, const struct entity_state_s *src ); -typedef void ( *HUD_TXFERPREDICTIONDATA_FUNC ) ( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd ); -typedef void ( *HUD_DEMOREAD_FUNC ) ( int size, unsigned char *buffer ); -typedef int ( *HUD_CONNECTIONLESS_FUNC )( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); -typedef int ( *HUD_GETHULLBOUNDS_FUNC ) ( int hullnumber, float *mins, float *maxs ); -typedef void (*HUD_FRAME_FUNC) ( double ); -typedef int (*HUD_KEY_EVENT_FUNC ) ( int eventcode, int keynum, const char *pszCurrentBinding ); -typedef void (*HUD_TEMPENTUPDATE_FUNC) ( double frametime, double client_time, double cl_gravity, struct tempent_s **ppTempEntFree, struct tempent_s **ppTempEntActive, int ( *Callback_AddVisibleEntity )( struct cl_entity_s *pEntity ), void ( *Callback_TempEntPlaySound )( struct tempent_s *pTemp, float damp ) ); -typedef struct cl_entity_s *(*HUD_GETUSERENTITY_FUNC ) ( int index ); -typedef void (*HUD_VOICESTATUS_FUNC)(int entindex, qboolean bTalking); -typedef void (*HUD_DIRECTORMESSAGE_FUNC)( int iSize, void *pbuf ); -typedef int ( *HUD_STUDIO_INTERFACE_FUNC )( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio ); -typedef void (*HUD_CHATINPUTPOSITION_FUNC)( int *x, int *y ); -typedef int (*HUD_GETPLAYERTEAM)(int iplayer); -typedef void *(*CLIENTFACTORY)(); // this should be CreateInterfaceFn but that means including interface.h - // which is a C++ file and some of the client files a C only... - // so we return a void * which we then do a typecast on later. - - -// Pointers to the exported client functions themselves -typedef struct -{ - INITIALIZE_FUNC pInitFunc; - HUD_INIT_FUNC pHudInitFunc; - HUD_VIDINIT_FUNC pHudVidInitFunc; - HUD_REDRAW_FUNC pHudRedrawFunc; - HUD_UPDATECLIENTDATA_FUNC pHudUpdateClientDataFunc; - HUD_RESET_FUNC pHudResetFunc; - HUD_CLIENTMOVE_FUNC pClientMove; - HUD_CLIENTMOVEINIT_FUNC pClientMoveInit; - HUD_TEXTURETYPE_FUNC pClientTextureType; - HUD_IN_ACTIVATEMOUSE_FUNC pIN_ActivateMouse; - HUD_IN_DEACTIVATEMOUSE_FUNC pIN_DeactivateMouse; - HUD_IN_MOUSEEVENT_FUNC pIN_MouseEvent; - HUD_IN_CLEARSTATES_FUNC pIN_ClearStates; - HUD_IN_ACCUMULATE_FUNC pIN_Accumulate; - HUD_CL_CREATEMOVE_FUNC pCL_CreateMove; - HUD_CL_ISTHIRDPERSON_FUNC pCL_IsThirdPerson; - HUD_CL_GETCAMERAOFFSETS_FUNC pCL_GetCameraOffsets; - HUD_KB_FIND_FUNC pFindKey; - HUD_CAMTHINK_FUNC pCamThink; - HUD_CALCREF_FUNC pCalcRefdef; - HUD_ADDENTITY_FUNC pAddEntity; - HUD_CREATEENTITIES_FUNC pCreateEntities; - HUD_DRAWNORMALTRIS_FUNC pDrawNormalTriangles; - HUD_DRAWTRANSTRIS_FUNC pDrawTransparentTriangles; - HUD_STUDIOEVENT_FUNC pStudioEvent; - HUD_POSTRUNCMD_FUNC pPostRunCmd; - HUD_SHUTDOWN_FUNC pShutdown; - HUD_TXFERLOCALOVERRIDES_FUNC pTxferLocalOverrides; - HUD_PROCESSPLAYERSTATE_FUNC pProcessPlayerState; - HUD_TXFERPREDICTIONDATA_FUNC pTxferPredictionData; - HUD_DEMOREAD_FUNC pReadDemoBuffer; - HUD_CONNECTIONLESS_FUNC pConnectionlessPacket; - HUD_GETHULLBOUNDS_FUNC pGetHullBounds; - HUD_FRAME_FUNC pHudFrame; - HUD_KEY_EVENT_FUNC pKeyEvent; - HUD_TEMPENTUPDATE_FUNC pTempEntUpdate; - HUD_GETUSERENTITY_FUNC pGetUserEntity; - HUD_VOICESTATUS_FUNC pVoiceStatus; // Possibly null on old client dlls. - HUD_DIRECTORMESSAGE_FUNC pDirectorMessage; // Possibly null on old client dlls. - HUD_STUDIO_INTERFACE_FUNC pStudioInterface; // Not used by all clients - HUD_CHATINPUTPOSITION_FUNC pChatInputPosition; // Not used by all clients - HUD_GETPLAYERTEAM pGetPlayerTeam; // Not used by all clients - CLIENTFACTORY pClientFactory; -} cldll_func_t; - -// Function type declarations for client destination functions -typedef void (*DST_INITIALIZE_FUNC) ( struct cl_enginefuncs_s**, int *); -typedef void (*DST_HUD_INIT_FUNC) ( void ); -typedef void (*DST_HUD_VIDINIT_FUNC) ( void ); -typedef void (*DST_HUD_REDRAW_FUNC) ( float*, int* ); -typedef void (*DST_HUD_UPDATECLIENTDATA_FUNC) ( struct client_data_s**, float* ); -typedef void (*DST_HUD_RESET_FUNC) ( void ); -typedef void (*DST_HUD_CLIENTMOVE_FUNC)( struct playermove_s **, qboolean * ); -typedef void (*DST_HUD_CLIENTMOVEINIT_FUNC)( struct playermove_s ** ); -typedef void (*DST_HUD_TEXTURETYPE_FUNC)( char ** ); -typedef void (*DST_HUD_IN_ACTIVATEMOUSE_FUNC) ( void ); -typedef void (*DST_HUD_IN_DEACTIVATEMOUSE_FUNC) ( void ); -typedef void (*DST_HUD_IN_MOUSEEVENT_FUNC) ( int * ); -typedef void (*DST_HUD_IN_CLEARSTATES_FUNC) ( void ); -typedef void (*DST_HUD_IN_ACCUMULATE_FUNC ) ( void ); -typedef void (*DST_HUD_CL_CREATEMOVE_FUNC) ( float *, struct usercmd_s **, int * ); -typedef void (*DST_HUD_CL_ISTHIRDPERSON_FUNC) ( void ); -typedef void (*DST_HUD_CL_GETCAMERAOFFSETS_FUNC )( float ** ); -typedef void (*DST_HUD_KB_FIND_FUNC) ( const char ** ); -typedef void (*DST_HUD_CAMTHINK_FUNC )( void ); -typedef void (*DST_HUD_CALCREF_FUNC ) ( struct ref_params_s ** ); -typedef void (*DST_HUD_ADDENTITY_FUNC ) ( int *, struct cl_entity_s **, const char ** ); -typedef void (*DST_HUD_CREATEENTITIES_FUNC ) ( void ); -typedef void (*DST_HUD_DRAWNORMALTRIS_FUNC ) ( void ); -typedef void (*DST_HUD_DRAWTRANSTRIS_FUNC ) ( void ); -typedef void (*DST_HUD_STUDIOEVENT_FUNC ) ( const struct mstudioevent_s **, const struct cl_entity_s ** ); -typedef void (*DST_HUD_POSTRUNCMD_FUNC ) ( struct local_state_s **, struct local_state_s **, struct usercmd_s **, int *, double *, unsigned int * ); -typedef void (*DST_HUD_SHUTDOWN_FUNC ) ( void ); -typedef void (*DST_HUD_TXFERLOCALOVERRIDES_FUNC )( struct entity_state_s **, const struct clientdata_s ** ); -typedef void (*DST_HUD_PROCESSPLAYERSTATE_FUNC )( struct entity_state_s **, const struct entity_state_s ** ); -typedef void (*DST_HUD_TXFERPREDICTIONDATA_FUNC ) ( struct entity_state_s **, const struct entity_state_s **, struct clientdata_s **, const struct clientdata_s **, struct weapon_data_s **, const struct weapon_data_s ** ); -typedef void (*DST_HUD_DEMOREAD_FUNC ) ( int *, unsigned char ** ); -typedef void (*DST_HUD_CONNECTIONLESS_FUNC )( const struct netadr_s **, const char **, char **, int ** ); -typedef void (*DST_HUD_GETHULLBOUNDS_FUNC ) ( int *, float **, float ** ); -typedef void (*DST_HUD_FRAME_FUNC) ( double * ); -typedef void (*DST_HUD_KEY_EVENT_FUNC ) ( int *, int *, const char ** ); -typedef void (*DST_HUD_TEMPENTUPDATE_FUNC) ( double *, double *, double *, struct tempent_s ***, struct tempent_s ***, int ( **Callback_AddVisibleEntity )( struct cl_entity_s *pEntity ), void ( **Callback_TempEntPlaySound )( struct tempent_s *pTemp, float damp ) ); -typedef void (*DST_HUD_GETUSERENTITY_FUNC ) ( int * ); -typedef void (*DST_HUD_VOICESTATUS_FUNC)(int *, qboolean *); -typedef void (*DST_HUD_DIRECTORMESSAGE_FUNC)( int *, void ** ); -typedef void (*DST_HUD_STUDIO_INTERFACE_FUNC ) ( int *, struct r_studio_interface_s ***, struct engine_studio_api_s ** ); -typedef void (*DST_HUD_CHATINPUTPOSITION_FUNC)( int **, int ** ); -typedef void (*DST_HUD_GETPLAYERTEAM)(int); - -// Pointers to the client destination functions -typedef struct -{ - DST_INITIALIZE_FUNC pInitFunc; - DST_HUD_INIT_FUNC pHudInitFunc; - DST_HUD_VIDINIT_FUNC pHudVidInitFunc; - DST_HUD_REDRAW_FUNC pHudRedrawFunc; - DST_HUD_UPDATECLIENTDATA_FUNC pHudUpdateClientDataFunc; - DST_HUD_RESET_FUNC pHudResetFunc; - DST_HUD_CLIENTMOVE_FUNC pClientMove; - DST_HUD_CLIENTMOVEINIT_FUNC pClientMoveInit; - DST_HUD_TEXTURETYPE_FUNC pClientTextureType; - DST_HUD_IN_ACTIVATEMOUSE_FUNC pIN_ActivateMouse; - DST_HUD_IN_DEACTIVATEMOUSE_FUNC pIN_DeactivateMouse; - DST_HUD_IN_MOUSEEVENT_FUNC pIN_MouseEvent; - DST_HUD_IN_CLEARSTATES_FUNC pIN_ClearStates; - DST_HUD_IN_ACCUMULATE_FUNC pIN_Accumulate; - DST_HUD_CL_CREATEMOVE_FUNC pCL_CreateMove; - DST_HUD_CL_ISTHIRDPERSON_FUNC pCL_IsThirdPerson; - DST_HUD_CL_GETCAMERAOFFSETS_FUNC pCL_GetCameraOffsets; - DST_HUD_KB_FIND_FUNC pFindKey; - DST_HUD_CAMTHINK_FUNC pCamThink; - DST_HUD_CALCREF_FUNC pCalcRefdef; - DST_HUD_ADDENTITY_FUNC pAddEntity; - DST_HUD_CREATEENTITIES_FUNC pCreateEntities; - DST_HUD_DRAWNORMALTRIS_FUNC pDrawNormalTriangles; - DST_HUD_DRAWTRANSTRIS_FUNC pDrawTransparentTriangles; - DST_HUD_STUDIOEVENT_FUNC pStudioEvent; - DST_HUD_POSTRUNCMD_FUNC pPostRunCmd; - DST_HUD_SHUTDOWN_FUNC pShutdown; - DST_HUD_TXFERLOCALOVERRIDES_FUNC pTxferLocalOverrides; - DST_HUD_PROCESSPLAYERSTATE_FUNC pProcessPlayerState; - DST_HUD_TXFERPREDICTIONDATA_FUNC pTxferPredictionData; - DST_HUD_DEMOREAD_FUNC pReadDemoBuffer; - DST_HUD_CONNECTIONLESS_FUNC pConnectionlessPacket; - DST_HUD_GETHULLBOUNDS_FUNC pGetHullBounds; - DST_HUD_FRAME_FUNC pHudFrame; - DST_HUD_KEY_EVENT_FUNC pKeyEvent; - DST_HUD_TEMPENTUPDATE_FUNC pTempEntUpdate; - DST_HUD_GETUSERENTITY_FUNC pGetUserEntity; - DST_HUD_VOICESTATUS_FUNC pVoiceStatus; // Possibly null on old client dlls. - DST_HUD_DIRECTORMESSAGE_FUNC pDirectorMessage; // Possibly null on old client dlls. - DST_HUD_STUDIO_INTERFACE_FUNC pStudioInterface; // Not used by all clients - DST_HUD_CHATINPUTPOSITION_FUNC pChatInputPosition; // Not used by all clients - DST_HUD_GETPLAYERTEAM pGetPlayerTeam; // Not used by all clients -} cldll_func_dst_t; - - - - -// ******************************************************** -// Functions exported by the engine -// ******************************************************** - -// Function type declarations for engine exports -typedef HSPRITE (*pfnEngSrc_pfnSPR_Load_t ) ( const char *szPicName ); -typedef int (*pfnEngSrc_pfnSPR_Frames_t ) ( HSPRITE hPic ); -typedef int (*pfnEngSrc_pfnSPR_Height_t ) ( HSPRITE hPic, int frame ); -typedef int (*pfnEngSrc_pfnSPR_Width_t ) ( HSPRITE hPic, int frame ); -typedef void (*pfnEngSrc_pfnSPR_Set_t ) ( HSPRITE hPic, int r, int g, int b ); -typedef void (*pfnEngSrc_pfnSPR_Draw_t ) ( int frame, int x, int y, const struct rect_s *prc ); -typedef void (*pfnEngSrc_pfnSPR_DrawHoles_t ) ( int frame, int x, int y, const struct rect_s *prc ); -typedef void (*pfnEngSrc_pfnSPR_DrawAdditive_t ) ( int frame, int x, int y, const struct rect_s *prc ); -typedef void (*pfnEngSrc_pfnSPR_EnableScissor_t ) ( int x, int y, int width, int height ); -typedef void (*pfnEngSrc_pfnSPR_DisableScissor_t ) ( void ); -typedef struct client_sprite_s * (*pfnEngSrc_pfnSPR_GetList_t ) ( char *psz, int *piCount ); -typedef void (*pfnEngSrc_pfnFillRGBA_t ) ( int x, int y, int width, int height, int r, int g, int b, int a ); -typedef int (*pfnEngSrc_pfnGetScreenInfo_t ) ( struct SCREENINFO_s *pscrinfo ); -typedef void (*pfnEngSrc_pfnSetCrosshair_t ) ( HSPRITE hspr, wrect_t rc, int r, int g, int b ); -typedef struct cvar_s * (*pfnEngSrc_pfnRegisterVariable_t ) ( char *szName, char *szValue, int flags ); -typedef float (*pfnEngSrc_pfnGetCvarFloat_t ) ( char *szName ); -typedef char* (*pfnEngSrc_pfnGetCvarString_t ) ( char *szName ); -typedef int (*pfnEngSrc_pfnAddCommand_t ) ( char *cmd_name, void (*pfnEngSrc_function)(void) ); -typedef int (*pfnEngSrc_pfnHookUserMsg_t ) ( char *szMsgName, pfnUserMsgHook pfn ); -typedef int (*pfnEngSrc_pfnServerCmd_t ) ( char *szCmdString ); -typedef int (*pfnEngSrc_pfnClientCmd_t ) ( char *szCmdString ); -typedef void (*pfnEngSrc_pfnPrimeMusicStream_t ) ( char *szFilename, int looping ); -typedef void (*pfnEngSrc_pfnGetPlayerInfo_t ) ( int ent_num, struct hud_player_info_s *pinfo ); -typedef void (*pfnEngSrc_pfnPlaySoundByName_t ) ( char *szSound, float volume ); -typedef void (*pfnEngSrc_pfnPlaySoundByNameAtPitch_t ) ( char *szSound, float volume, int pitch ); -typedef void (*pfnEngSrc_pfnPlaySoundVoiceByName_t ) ( char *szSound, float volume, int pitch ); -typedef void (*pfnEngSrc_pfnPlaySoundByIndex_t ) ( int iSound, float volume ); -typedef void (*pfnEngSrc_pfnAngleVectors_t ) ( const float * vecAngles, float * forward, float * right, float * up ); -typedef struct client_textmessage_s*(*pfnEngSrc_pfnTextMessageGet_t ) ( const char *pName ); -typedef int (*pfnEngSrc_pfnDrawCharacter_t ) ( int x, int y, int number, int r, int g, int b ); -typedef int (*pfnEngSrc_pfnDrawConsoleString_t ) ( int x, int y, char *string ); -typedef void (*pfnEngSrc_pfnDrawSetTextColor_t ) ( float r, float g, float b ); -typedef void (*pfnEngSrc_pfnDrawConsoleStringLen_t )( const char *string, int *length, int *height ); -typedef void (*pfnEngSrc_pfnConsolePrint_t ) ( const char *string ); -typedef void (*pfnEngSrc_pfnCenterPrint_t ) ( const char *string ); -typedef int (*pfnEngSrc_GetWindowCenterX_t ) ( void ); -typedef int (*pfnEngSrc_GetWindowCenterY_t ) ( void ); -typedef void (*pfnEngSrc_GetViewAngles_t ) ( float * ); -typedef void (*pfnEngSrc_SetViewAngles_t ) ( float * ); -typedef int (*pfnEngSrc_GetMaxClients_t ) ( void ); -typedef void (*pfnEngSrc_Cvar_SetValue_t ) ( char *cvar, float value ); -typedef int (*pfnEngSrc_Cmd_Argc_t) (void); -typedef char * (*pfnEngSrc_Cmd_Argv_t ) ( int arg ); -typedef void (*pfnEngSrc_Con_Printf_t ) ( char *fmt, ... ); -typedef void (*pfnEngSrc_Con_DPrintf_t ) ( char *fmt, ... ); -typedef void (*pfnEngSrc_Con_NPrintf_t ) ( int pos, char *fmt, ... ); -typedef void (*pfnEngSrc_Con_NXPrintf_t ) ( struct con_nprint_s *info, char *fmt, ... ); -typedef const char * (*pfnEngSrc_PhysInfo_ValueForKey_t ) ( const char *key ); -typedef const char * (*pfnEngSrc_ServerInfo_ValueForKey_t )( const char *key ); -typedef float (*pfnEngSrc_GetClientMaxspeed_t ) ( void ); -typedef int (*pfnEngSrc_CheckParm_t ) ( char *parm, char **ppnext ); -typedef void (*pfnEngSrc_Key_Event_t ) ( int key, int down ); -typedef void (*pfnEngSrc_GetMousePosition_t ) ( int *mx, int *my ); -typedef int (*pfnEngSrc_IsNoClipping_t ) ( void ); -typedef struct cl_entity_s * (*pfnEngSrc_GetLocalPlayer_t ) ( void ); -typedef struct cl_entity_s * (*pfnEngSrc_GetViewModel_t ) ( void ); -typedef struct cl_entity_s * (*pfnEngSrc_GetEntityByIndex_t ) ( int idx ); -typedef float (*pfnEngSrc_GetClientTime_t ) ( void ); -typedef void (*pfnEngSrc_V_CalcShake_t ) ( void ); -typedef void (*pfnEngSrc_V_ApplyShake_t ) ( float *origin, float *angles, float factor ); -typedef int (*pfnEngSrc_PM_PointContents_t ) ( float *point, int *truecontents ); -typedef int (*pfnEngSrc_PM_WaterEntity_t ) ( float *p ); -typedef struct pmtrace_s * (*pfnEngSrc_PM_TraceLine_t ) ( float *start, float *end, int flags, int usehull, int ignore_pe ); -typedef struct model_s * (*pfnEngSrc_CL_LoadModel_t ) ( const char *modelname, int *index ); -typedef int (*pfnEngSrc_CL_CreateVisibleEntity_t ) ( int type, struct cl_entity_s *ent ); -typedef const struct model_s * (*pfnEngSrc_GetSpritePointer_t ) ( HSPRITE hSprite ); -typedef void (*pfnEngSrc_pfnPlaySoundByNameAtLocation_t ) ( char *szSound, float volume, float *origin ); -typedef unsigned short (*pfnEngSrc_pfnPrecacheEvent_t ) ( int type, const char* psz ); -typedef void (*pfnEngSrc_pfnPlaybackEvent_t ) ( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); -typedef void (*pfnEngSrc_pfnWeaponAnim_t ) ( int iAnim, int body ); -typedef float (*pfnEngSrc_pfnRandomFloat_t ) ( float flLow, float flHigh ); -typedef int32 (*pfnEngSrc_pfnRandomLong_t ) ( int32 lLow, int32 lHigh ); -typedef void (*pfnEngSrc_pfnHookEvent_t ) ( char *name, void ( *pfnEvent )( struct event_args_s *args ) ); -typedef int (*pfnEngSrc_Con_IsVisible_t) (); -typedef const char * (*pfnEngSrc_pfnGetGameDirectory_t ) ( void ); -typedef struct cvar_s * (*pfnEngSrc_pfnGetCvarPointer_t ) ( const char *szName ); -typedef const char * (*pfnEngSrc_Key_LookupBinding_t ) ( const char *pBinding ); -typedef const char * (*pfnEngSrc_pfnGetLevelName_t ) ( void ); -typedef void (*pfnEngSrc_pfnGetScreenFade_t ) ( struct screenfade_s *fade ); -typedef void (*pfnEngSrc_pfnSetScreenFade_t ) ( struct screenfade_s *fade ); -typedef void * (*pfnEngSrc_VGui_GetPanel_t ) ( ); -typedef void (*pfnEngSrc_VGui_ViewportPaintBackground_t ) (int extents[4]); -typedef byte* (*pfnEngSrc_COM_LoadFile_t ) ( char *path, int usehunk, int *pLength ); -typedef char* (*pfnEngSrc_COM_ParseFile_t ) ( char *data, char *token ); -typedef void (*pfnEngSrc_COM_FreeFile_t) ( void *buffer ); -typedef struct triangleapi_s * pTriAPI; -typedef struct efx_api_s * pEfxAPI; -typedef struct event_api_s * pEventAPI; -typedef struct demo_api_s * pDemoAPI; -typedef struct net_api_s * pNetAPI; -typedef struct IVoiceTweak_s * pVoiceTweak; -typedef int (*pfnEngSrc_IsSpectateOnly_t ) ( void ); -typedef struct model_s * (*pfnEngSrc_LoadMapSprite_t ) ( const char *filename ); -typedef void (*pfnEngSrc_COM_AddAppDirectoryToSearchPath_t ) ( const char *pszBaseDir, const char *appName ); -typedef int (*pfnEngSrc_COM_ExpandFilename_t) ( const char *fileName, char *nameOutBuffer, int nameOutBufferSize ); -typedef const char * (*pfnEngSrc_PlayerInfo_ValueForKey_t )( int playerNum, const char *key ); -typedef void (*pfnEngSrc_PlayerInfo_SetValueForKey_t )( const char *key, const char *value ); -typedef qboolean (*pfnEngSrc_GetPlayerUniqueID_t)(int iPlayer, char playerID[16]); -typedef int (*pfnEngSrc_GetTrackerIDForPlayer_t)(int playerSlot); -typedef int (*pfnEngSrc_GetPlayerForTrackerID_t)(int trackerID); -typedef int (*pfnEngSrc_pfnServerCmdUnreliable_t )( char *szCmdString ); -typedef void (*pfnEngSrc_GetMousePos_t )(struct tagPOINT *ppt); -typedef void (*pfnEngSrc_SetMousePos_t )(int x, int y); -typedef void (*pfnEngSrc_SetMouseEnable_t)(qboolean fEnable); -typedef struct cvar_s * (*pfnEngSrc_GetFirstCVarPtr_t)(); -typedef unsigned int (*pfnEngSrc_GetFirstCmdFunctionHandle_t)(); -typedef unsigned int (*pfnEngSrc_GetNextCmdFunctionHandle_t)(unsigned int cmdhandle); -typedef const char * (*pfnEngSrc_GetCmdFunctionName_t)(unsigned int cmdhandle); -typedef float (*pfnEngSrc_GetClientOldTime_t)(); -typedef float (*pfnEngSrc_GetServerGravityValue_t)(); -typedef struct model_s * (*pfnEngSrc_GetModelByIndex_t)( int index ); -typedef void (*pfnEngSrc_pfnSetFilterMode_t )( int mode ); -typedef void (*pfnEngSrc_pfnSetFilterColor_t )( float r, float g, float b ); -typedef void (*pfnEngSrc_pfnSetFilterBrightness_t )( float brightness ); -typedef sequenceEntry_s* (*pfnEngSrc_pfnSequenceGet_t )( const char *fileName, const char* entryName ); -typedef void (*pfnEngSrc_pfnSPR_DrawGeneric_t )( int frame, int x, int y, const struct rect_s *prc, int src, int dest, int w, int h ); -typedef sentenceEntry_s* (*pfnEngSrc_pfnSequencePickSentence_t )( const char *sentenceName, int pickMethod, int* entryPicked ); -// draw a complete string -typedef int (*pfnEngSrc_pfnDrawString_t ) ( int x, int y, const char *str, int r, int g, int b ); -typedef int (*pfnEngSrc_pfnDrawStringReverse_t ) ( int x, int y, const char *str, int r, int g, int b ); -typedef const char * (*pfnEngSrc_LocalPlayerInfo_ValueForKey_t )( const char *key ); -typedef int (*pfnEngSrc_pfnVGUI2DrawCharacter_t ) ( int x, int y, int ch, unsigned int font ); -typedef int (*pfnEngSrc_pfnVGUI2DrawCharacterAdd_t ) ( int x, int y, int ch, int r, int g, int b, unsigned int font); -typedef unsigned int (*pfnEngSrc_COM_GetApproxWavePlayLength ) ( const char * filename); -typedef void * (*pfnEngSrc_pfnGetCareerUI_t)(); -typedef void (*pfnEngSrc_Cvar_Set_t ) ( char *cvar, char *value ); -typedef int (*pfnEngSrc_pfnIsPlayingCareerMatch_t)(); -typedef double (*pfnEngSrc_GetAbsoluteTime_t) ( void ); -typedef void (*pfnEngSrc_pfnProcessTutorMessageDecayBuffer_t)(int *buffer, int bufferLength); -typedef void (*pfnEngSrc_pfnConstructTutorMessageDecayBuffer_t)(int *buffer, int bufferLength); -typedef void (*pfnEngSrc_pfnResetTutorMessageDecayData_t)(); -typedef void (*pfnEngSrc_pfnFillRGBABlend_t ) ( int x, int y, int width, int height, int r, int g, int b, int a ); -typedef int (*pfnEngSrc_pfnGetAppID_t) ( void ); -typedef cmdalias_t* (*pfnEngSrc_pfnGetAliases_t) ( void ); -typedef void (*pfnEngSrc_pfnVguiWrap2_GetMouseDelta_t) ( int *x, int *y ); - -// Pointers to the exported engine functions themselves -typedef struct cl_enginefuncs_s -{ - pfnEngSrc_pfnSPR_Load_t pfnSPR_Load; - pfnEngSrc_pfnSPR_Frames_t pfnSPR_Frames; - pfnEngSrc_pfnSPR_Height_t pfnSPR_Height; - pfnEngSrc_pfnSPR_Width_t pfnSPR_Width; - pfnEngSrc_pfnSPR_Set_t pfnSPR_Set; - pfnEngSrc_pfnSPR_Draw_t pfnSPR_Draw; - pfnEngSrc_pfnSPR_DrawHoles_t pfnSPR_DrawHoles; - pfnEngSrc_pfnSPR_DrawAdditive_t pfnSPR_DrawAdditive; - pfnEngSrc_pfnSPR_EnableScissor_t pfnSPR_EnableScissor; - pfnEngSrc_pfnSPR_DisableScissor_t pfnSPR_DisableScissor; - pfnEngSrc_pfnSPR_GetList_t pfnSPR_GetList; - pfnEngSrc_pfnFillRGBA_t pfnFillRGBA; - pfnEngSrc_pfnGetScreenInfo_t pfnGetScreenInfo; - pfnEngSrc_pfnSetCrosshair_t pfnSetCrosshair; - pfnEngSrc_pfnRegisterVariable_t pfnRegisterVariable; - pfnEngSrc_pfnGetCvarFloat_t pfnGetCvarFloat; - pfnEngSrc_pfnGetCvarString_t pfnGetCvarString; - pfnEngSrc_pfnAddCommand_t pfnAddCommand; - pfnEngSrc_pfnHookUserMsg_t pfnHookUserMsg; - pfnEngSrc_pfnServerCmd_t pfnServerCmd; - pfnEngSrc_pfnClientCmd_t pfnClientCmd; - pfnEngSrc_pfnGetPlayerInfo_t pfnGetPlayerInfo; - pfnEngSrc_pfnPlaySoundByName_t pfnPlaySoundByName; - pfnEngSrc_pfnPlaySoundByIndex_t pfnPlaySoundByIndex; - pfnEngSrc_pfnAngleVectors_t pfnAngleVectors; - pfnEngSrc_pfnTextMessageGet_t pfnTextMessageGet; - pfnEngSrc_pfnDrawCharacter_t pfnDrawCharacter; - pfnEngSrc_pfnDrawConsoleString_t pfnDrawConsoleString; - pfnEngSrc_pfnDrawSetTextColor_t pfnDrawSetTextColor; - pfnEngSrc_pfnDrawConsoleStringLen_t pfnDrawConsoleStringLen; - pfnEngSrc_pfnConsolePrint_t pfnConsolePrint; - pfnEngSrc_pfnCenterPrint_t pfnCenterPrint; - pfnEngSrc_GetWindowCenterX_t GetWindowCenterX; - pfnEngSrc_GetWindowCenterY_t GetWindowCenterY; - pfnEngSrc_GetViewAngles_t GetViewAngles; - pfnEngSrc_SetViewAngles_t SetViewAngles; - pfnEngSrc_GetMaxClients_t GetMaxClients; - pfnEngSrc_Cvar_SetValue_t Cvar_SetValue; - pfnEngSrc_Cmd_Argc_t Cmd_Argc; - pfnEngSrc_Cmd_Argv_t Cmd_Argv; - pfnEngSrc_Con_Printf_t Con_Printf; - pfnEngSrc_Con_DPrintf_t Con_DPrintf; - pfnEngSrc_Con_NPrintf_t Con_NPrintf; - pfnEngSrc_Con_NXPrintf_t Con_NXPrintf; - pfnEngSrc_PhysInfo_ValueForKey_t PhysInfo_ValueForKey; - pfnEngSrc_ServerInfo_ValueForKey_t ServerInfo_ValueForKey; - pfnEngSrc_GetClientMaxspeed_t GetClientMaxspeed; - pfnEngSrc_CheckParm_t CheckParm; - pfnEngSrc_Key_Event_t Key_Event; - pfnEngSrc_GetMousePosition_t GetMousePosition; - pfnEngSrc_IsNoClipping_t IsNoClipping; - pfnEngSrc_GetLocalPlayer_t GetLocalPlayer; - pfnEngSrc_GetViewModel_t GetViewModel; - pfnEngSrc_GetEntityByIndex_t GetEntityByIndex; - pfnEngSrc_GetClientTime_t GetClientTime; - pfnEngSrc_V_CalcShake_t V_CalcShake; - pfnEngSrc_V_ApplyShake_t V_ApplyShake; - pfnEngSrc_PM_PointContents_t PM_PointContents; - pfnEngSrc_PM_WaterEntity_t PM_WaterEntity; - pfnEngSrc_PM_TraceLine_t PM_TraceLine; - pfnEngSrc_CL_LoadModel_t CL_LoadModel; - pfnEngSrc_CL_CreateVisibleEntity_t CL_CreateVisibleEntity; - pfnEngSrc_GetSpritePointer_t GetSpritePointer; - pfnEngSrc_pfnPlaySoundByNameAtLocation_t pfnPlaySoundByNameAtLocation; - pfnEngSrc_pfnPrecacheEvent_t pfnPrecacheEvent; - pfnEngSrc_pfnPlaybackEvent_t pfnPlaybackEvent; - pfnEngSrc_pfnWeaponAnim_t pfnWeaponAnim; - pfnEngSrc_pfnRandomFloat_t pfnRandomFloat; - pfnEngSrc_pfnRandomLong_t pfnRandomLong; - pfnEngSrc_pfnHookEvent_t pfnHookEvent; - pfnEngSrc_Con_IsVisible_t Con_IsVisible; - pfnEngSrc_pfnGetGameDirectory_t pfnGetGameDirectory; - pfnEngSrc_pfnGetCvarPointer_t pfnGetCvarPointer; - pfnEngSrc_Key_LookupBinding_t Key_LookupBinding; - pfnEngSrc_pfnGetLevelName_t pfnGetLevelName; - pfnEngSrc_pfnGetScreenFade_t pfnGetScreenFade; - pfnEngSrc_pfnSetScreenFade_t pfnSetScreenFade; - pfnEngSrc_VGui_GetPanel_t VGui_GetPanel; - pfnEngSrc_VGui_ViewportPaintBackground_t VGui_ViewportPaintBackground; - pfnEngSrc_COM_LoadFile_t COM_LoadFile; - pfnEngSrc_COM_ParseFile_t COM_ParseFile; - pfnEngSrc_COM_FreeFile_t COM_FreeFile; - struct triangleapi_s *pTriAPI; - struct efx_api_s *pEfxAPI; - struct event_api_s *pEventAPI; - struct demo_api_s *pDemoAPI; - struct net_api_s *pNetAPI; - struct IVoiceTweak_s *pVoiceTweak; - pfnEngSrc_IsSpectateOnly_t IsSpectateOnly; - pfnEngSrc_LoadMapSprite_t LoadMapSprite; - pfnEngSrc_COM_AddAppDirectoryToSearchPath_t COM_AddAppDirectoryToSearchPath; - pfnEngSrc_COM_ExpandFilename_t COM_ExpandFilename; - pfnEngSrc_PlayerInfo_ValueForKey_t PlayerInfo_ValueForKey; - pfnEngSrc_PlayerInfo_SetValueForKey_t PlayerInfo_SetValueForKey; - pfnEngSrc_GetPlayerUniqueID_t GetPlayerUniqueID; - pfnEngSrc_GetTrackerIDForPlayer_t GetTrackerIDForPlayer; - pfnEngSrc_GetPlayerForTrackerID_t GetPlayerForTrackerID; - pfnEngSrc_pfnServerCmdUnreliable_t pfnServerCmdUnreliable; - pfnEngSrc_GetMousePos_t pfnGetMousePos; - pfnEngSrc_SetMousePos_t pfnSetMousePos; - pfnEngSrc_SetMouseEnable_t pfnSetMouseEnable; - pfnEngSrc_GetFirstCVarPtr_t GetFirstCvarPtr; - pfnEngSrc_GetFirstCmdFunctionHandle_t GetFirstCmdFunctionHandle; - pfnEngSrc_GetNextCmdFunctionHandle_t GetNextCmdFunctionHandle; - pfnEngSrc_GetCmdFunctionName_t GetCmdFunctionName; - pfnEngSrc_GetClientOldTime_t hudGetClientOldTime; - pfnEngSrc_GetServerGravityValue_t hudGetServerGravityValue; - pfnEngSrc_GetModelByIndex_t hudGetModelByIndex; - pfnEngSrc_pfnSetFilterMode_t pfnSetFilterMode; - pfnEngSrc_pfnSetFilterColor_t pfnSetFilterColor; - pfnEngSrc_pfnSetFilterBrightness_t pfnSetFilterBrightness; - pfnEngSrc_pfnSequenceGet_t pfnSequenceGet; - pfnEngSrc_pfnSPR_DrawGeneric_t pfnSPR_DrawGeneric; - pfnEngSrc_pfnSequencePickSentence_t pfnSequencePickSentence; - pfnEngSrc_pfnDrawString_t pfnDrawString; - pfnEngSrc_pfnDrawStringReverse_t pfnDrawStringReverse; - pfnEngSrc_LocalPlayerInfo_ValueForKey_t LocalPlayerInfo_ValueForKey; - pfnEngSrc_pfnVGUI2DrawCharacter_t pfnVGUI2DrawCharacter; - pfnEngSrc_pfnVGUI2DrawCharacterAdd_t pfnVGUI2DrawCharacterAdd; - pfnEngSrc_COM_GetApproxWavePlayLength COM_GetApproxWavePlayLength; - pfnEngSrc_pfnGetCareerUI_t pfnGetCareerUI; - pfnEngSrc_Cvar_Set_t Cvar_Set; - pfnEngSrc_pfnIsPlayingCareerMatch_t pfnIsCareerMatch; - pfnEngSrc_pfnPlaySoundVoiceByName_t pfnPlaySoundVoiceByName; - pfnEngSrc_pfnPrimeMusicStream_t pfnPrimeMusicStream; - pfnEngSrc_GetAbsoluteTime_t GetAbsoluteTime; - pfnEngSrc_pfnProcessTutorMessageDecayBuffer_t pfnProcessTutorMessageDecayBuffer; - pfnEngSrc_pfnConstructTutorMessageDecayBuffer_t pfnConstructTutorMessageDecayBuffer; - pfnEngSrc_pfnResetTutorMessageDecayData_t pfnResetTutorMessageDecayData; - pfnEngSrc_pfnPlaySoundByNameAtPitch_t pfnPlaySoundByNameAtPitch; - pfnEngSrc_pfnFillRGBABlend_t pfnFillRGBABlend; - pfnEngSrc_pfnGetAppID_t pfnGetAppID; - pfnEngSrc_pfnGetAliases_t pfnGetAliasList; - pfnEngSrc_pfnVguiWrap2_GetMouseDelta_t pfnVguiWrap2_GetMouseDelta; -} cl_enginefunc_t; - -// Function type declarations for engine destination functions -typedef void (*pfnEngDst_pfnSPR_Load_t ) ( const char ** ); -typedef void (*pfnEngDst_pfnSPR_Frames_t ) ( HSPRITE * ); -typedef void (*pfnEngDst_pfnSPR_Height_t ) ( HSPRITE *, int * ); -typedef void (*pfnEngDst_pfnSPR_Width_t ) ( HSPRITE *, int * ); -typedef void (*pfnEngDst_pfnSPR_Set_t ) ( HSPRITE *, int *, int *, int * ); -typedef void (*pfnEngDst_pfnSPR_Draw_t ) ( int *, int *, int *, const struct rect_s ** ); -typedef void (*pfnEngDst_pfnSPR_DrawHoles_t ) ( int *, int *, int *, const struct rect_s ** ); -typedef void (*pfnEngDst_pfnSPR_DrawAdditive_t ) ( int *, int *, int *, const struct rect_s ** ); -typedef void (*pfnEngDst_pfnSPR_EnableScissor_t ) ( int *, int *, int *, int * ); -typedef void (*pfnEngDst_pfnSPR_DisableScissor_t ) ( void ); -typedef void (*pfnEngDst_pfnSPR_GetList_t ) ( char **, int ** ); -typedef void (*pfnEngDst_pfnFillRGBA_t ) ( int *, int *, int *, int *, int *, int *, int *, int * ); -typedef void (*pfnEngDst_pfnGetScreenInfo_t ) ( struct SCREENINFO_s ** ); -typedef void (*pfnEngDst_pfnSetCrosshair_t ) ( HSPRITE *, struct rect_s *, int *, int *, int * ); -typedef void (*pfnEngDst_pfnRegisterVariable_t ) ( char **, char **, int * ); -typedef void (*pfnEngDst_pfnGetCvarFloat_t ) ( char ** ); -typedef void (*pfnEngDst_pfnGetCvarString_t ) ( char ** ); -typedef void (*pfnEngDst_pfnAddCommand_t ) ( char **, void (**pfnEngDst_function)(void) ); -typedef void (*pfnEngDst_pfnHookUserMsg_t ) ( char **, pfnUserMsgHook * ); -typedef void (*pfnEngDst_pfnServerCmd_t ) ( char ** ); -typedef void (*pfnEngDst_pfnClientCmd_t ) ( char ** ); -typedef void (*pfnEngDst_pfnPrimeMusicStream_t ) ( char **, int *); -typedef void (*pfnEngDst_pfnGetPlayerInfo_t ) ( int *, struct hud_player_info_s ** ); -typedef void (*pfnEngDst_pfnPlaySoundByName_t ) ( char **, float * ); -typedef void (*pfnEngDst_pfnPlaySoundByNameAtPitch_t ) ( char **, float *, int * ); -typedef void (*pfnEngDst_pfnPlaySoundVoiceByName_t ) (char **, float * ); -typedef void (*pfnEngDst_pfnPlaySoundByIndex_t ) ( int *, float * ); -typedef void (*pfnEngDst_pfnAngleVectors_t ) ( const float * *, float * *, float * *, float * * ); -typedef void (*pfnEngDst_pfnTextMessageGet_t ) ( const char ** ); -typedef void (*pfnEngDst_pfnDrawCharacter_t ) ( int *, int *, int *, int *, int *, int * ); -typedef void (*pfnEngDst_pfnDrawConsoleString_t ) ( int *, int *, char ** ); -typedef void (*pfnEngDst_pfnDrawSetTextColor_t ) ( float *, float *, float * ); -typedef void (*pfnEngDst_pfnDrawConsoleStringLen_t ) ( const char **, int **, int ** ); -typedef void (*pfnEngDst_pfnConsolePrint_t ) ( const char ** ); -typedef void (*pfnEngDst_pfnCenterPrint_t ) ( const char ** ); -typedef void (*pfnEngDst_GetWindowCenterX_t ) ( void ); -typedef void (*pfnEngDst_GetWindowCenterY_t ) ( void ); -typedef void (*pfnEngDst_GetViewAngles_t ) ( float ** ); -typedef void (*pfnEngDst_SetViewAngles_t ) ( float ** ); -typedef void (*pfnEngDst_GetMaxClients_t ) ( void ); -typedef void (*pfnEngDst_Cvar_SetValue_t ) ( char **, float * ); -typedef void (*pfnEngDst_Cmd_Argc_t) (void); -typedef void (*pfnEngDst_Cmd_Argv_t ) ( int * ); -typedef void (*pfnEngDst_Con_Printf_t ) ( char **); -typedef void (*pfnEngDst_Con_DPrintf_t ) ( char **); -typedef void (*pfnEngDst_Con_NPrintf_t ) ( int *, char ** ); -typedef void (*pfnEngDst_Con_NXPrintf_t ) ( struct con_nprint_s **, char **); -typedef void (*pfnEngDst_PhysInfo_ValueForKey_t ) ( const char ** ); -typedef void (*pfnEngDst_ServerInfo_ValueForKey_t ) ( const char ** ); -typedef void (*pfnEngDst_GetClientMaxspeed_t ) ( void ); -typedef void (*pfnEngDst_CheckParm_t ) ( char **, char *** ); -typedef void (*pfnEngDst_Key_Event_t ) ( int *, int * ); -typedef void (*pfnEngDst_GetMousePosition_t ) ( int **, int ** ); -typedef void (*pfnEngDst_IsNoClipping_t ) ( void ); -typedef void (*pfnEngDst_GetLocalPlayer_t ) ( void ); -typedef void (*pfnEngDst_GetViewModel_t ) ( void ); -typedef void (*pfnEngDst_GetEntityByIndex_t ) ( int * ); -typedef void (*pfnEngDst_GetClientTime_t ) ( void ); -typedef void (*pfnEngDst_V_CalcShake_t ) ( void ); -typedef void (*pfnEngDst_V_ApplyShake_t ) ( float **, float **, float * ); -typedef void (*pfnEngDst_PM_PointContents_t ) ( float **, int ** ); -typedef void (*pfnEngDst_PM_WaterEntity_t ) ( float ** ); -typedef void (*pfnEngDst_PM_TraceLine_t ) ( float **, float **, int *, int *, int * ); -typedef void (*pfnEngDst_CL_LoadModel_t ) ( const char **, int ** ); -typedef void (*pfnEngDst_CL_CreateVisibleEntity_t ) ( int *, struct cl_entity_s ** ); -typedef void (*pfnEngDst_GetSpritePointer_t ) ( HSPRITE * ); -typedef void (*pfnEngDst_pfnPlaySoundByNameAtLocation_t ) ( char **, float *, float ** ); -typedef void (*pfnEngDst_pfnPrecacheEvent_t ) ( int *, const char* * ); -typedef void (*pfnEngDst_pfnPlaybackEvent_t ) ( int *, const struct edict_s **, unsigned short *, float *, float **, float **, float *, float *, int *, int *, int *, int * ); -typedef void (*pfnEngDst_pfnWeaponAnim_t ) ( int *, int * ); -typedef void (*pfnEngDst_pfnRandomFloat_t ) ( float *, float * ); -typedef void (*pfnEngDst_pfnRandomLong_t ) ( int32 *, int32 * ); -typedef void (*pfnEngDst_pfnHookEvent_t ) ( char **, void ( **pfnEvent )( struct event_args_s *args ) ); -typedef void (*pfnEngDst_Con_IsVisible_t) (); -typedef void (*pfnEngDst_pfnGetGameDirectory_t ) ( void ); -typedef void (*pfnEngDst_pfnGetCvarPointer_t ) ( const char ** ); -typedef void (*pfnEngDst_Key_LookupBinding_t ) ( const char ** ); -typedef void (*pfnEngDst_pfnGetLevelName_t ) ( void ); -typedef void (*pfnEngDst_pfnGetScreenFade_t ) ( struct screenfade_s ** ); -typedef void (*pfnEngDst_pfnSetScreenFade_t ) ( struct screenfade_s ** ); -typedef void (*pfnEngDst_VGui_GetPanel_t ) ( ); -typedef void (*pfnEngDst_VGui_ViewportPaintBackground_t ) (int **); -typedef void (*pfnEngDst_COM_LoadFile_t ) ( char **, int *, int ** ); -typedef void (*pfnEngDst_COM_ParseFile_t ) ( char **, char ** ); -typedef void (*pfnEngDst_COM_FreeFile_t) ( void ** ); -typedef void (*pfnEngDst_IsSpectateOnly_t ) ( void ); -typedef void (*pfnEngDst_LoadMapSprite_t ) ( const char ** ); -typedef void (*pfnEngDst_COM_AddAppDirectoryToSearchPath_t ) ( const char **, const char ** ); -typedef void (*pfnEngDst_COM_ExpandFilename_t) ( const char **, char **, int * ); -typedef void (*pfnEngDst_PlayerInfo_ValueForKey_t ) ( int *, const char ** ); -typedef void (*pfnEngDst_PlayerInfo_SetValueForKey_t )( const char **, const char ** ); -typedef void (*pfnEngDst_GetPlayerUniqueID_t) (int *, char **); -typedef void (*pfnEngDst_GetTrackerIDForPlayer_t) (int *); -typedef void (*pfnEngDst_GetPlayerForTrackerID_t) (int *); -typedef void (*pfnEngDst_pfnServerCmdUnreliable_t ) ( char ** ); -typedef void (*pfnEngDst_GetMousePos_t ) (struct tagPOINT **); -typedef void (*pfnEngDst_SetMousePos_t ) (int *, int *); -typedef void (*pfnEngDst_SetMouseEnable_t ) (qboolean *); -typedef void (*pfnEngDst_pfnSetFilterMode_t) ( int * ); -typedef void (*pfnEngDst_pfnSetFilterColor_t) ( float *, float *, float * ); -typedef void (*pfnEngDst_pfnSetFilterBrightness_t) ( float * ); -typedef void (*pfnEngDst_pfnSequenceGet_t ) ( const char**, const char** ); -typedef void (*pfnEngDst_pfnSPR_DrawGeneric_t ) ( int *, int *, int *, const struct rect_s **, int *, int *, int *, int * ); -typedef void (*pfnEngDst_pfnSequencePickSentence_t ) ( const char**, int *, int ** ); -typedef void (*pfnEngDst_pfnDrawString_t ) ( int *, int *, const char *, int *, int *, int * ); -typedef void (*pfnEngDst_pfnDrawStringReverse_t ) ( int *, int *, const char *, int *, int *, int * ); -typedef void (*pfnEngDst_LocalPlayerInfo_ValueForKey_t )( const char **); -typedef void (*pfnEngDst_pfnVGUI2DrawCharacter_t ) ( int *, int *, int *, unsigned int * ); -typedef void (*pfnEngDst_pfnVGUI2DrawCharacterAdd_t ) ( int *, int *, int *, int *, int *, int *, unsigned int *); -typedef void (*pfnEngDst_pfnProcessTutorMessageDecayBuffer_t )(int **, int *); -typedef void (*pfnEngDst_pfnConstructTutorMessageDecayBuffer_t )(int **, int *); -typedef void (*pfnEngDst_pfnResetTutorMessageDecayData_t)(); -typedef void (*pfnEngDst_pfnFillRGBABlend_t ) ( int *, int *, int *, int *, int *, int *, int *, int * ); -typedef void (*pfnEngDst_pfnGetAppID_t ) ( void ); -typedef void (*pfnEngDst_pfnGetAliases_t ) ( void ); -typedef void (*pfnEngDst_pfnVguiWrap2_GetMouseDelta_t) ( int *x, int *y ); - - -// Pointers to the engine destination functions -typedef struct -{ - pfnEngDst_pfnSPR_Load_t pfnSPR_Load; - pfnEngDst_pfnSPR_Frames_t pfnSPR_Frames; - pfnEngDst_pfnSPR_Height_t pfnSPR_Height; - pfnEngDst_pfnSPR_Width_t pfnSPR_Width; - pfnEngDst_pfnSPR_Set_t pfnSPR_Set; - pfnEngDst_pfnSPR_Draw_t pfnSPR_Draw; - pfnEngDst_pfnSPR_DrawHoles_t pfnSPR_DrawHoles; - pfnEngDst_pfnSPR_DrawAdditive_t pfnSPR_DrawAdditive; - pfnEngDst_pfnSPR_EnableScissor_t pfnSPR_EnableScissor; - pfnEngDst_pfnSPR_DisableScissor_t pfnSPR_DisableScissor; - pfnEngDst_pfnSPR_GetList_t pfnSPR_GetList; - pfnEngDst_pfnFillRGBA_t pfnFillRGBA; - pfnEngDst_pfnGetScreenInfo_t pfnGetScreenInfo; - pfnEngDst_pfnSetCrosshair_t pfnSetCrosshair; - pfnEngDst_pfnRegisterVariable_t pfnRegisterVariable; - pfnEngDst_pfnGetCvarFloat_t pfnGetCvarFloat; - pfnEngDst_pfnGetCvarString_t pfnGetCvarString; - pfnEngDst_pfnAddCommand_t pfnAddCommand; - pfnEngDst_pfnHookUserMsg_t pfnHookUserMsg; - pfnEngDst_pfnServerCmd_t pfnServerCmd; - pfnEngDst_pfnClientCmd_t pfnClientCmd; - pfnEngDst_pfnGetPlayerInfo_t pfnGetPlayerInfo; - pfnEngDst_pfnPlaySoundByName_t pfnPlaySoundByName; - pfnEngDst_pfnPlaySoundByIndex_t pfnPlaySoundByIndex; - pfnEngDst_pfnAngleVectors_t pfnAngleVectors; - pfnEngDst_pfnTextMessageGet_t pfnTextMessageGet; - pfnEngDst_pfnDrawCharacter_t pfnDrawCharacter; - pfnEngDst_pfnDrawConsoleString_t pfnDrawConsoleString; - pfnEngDst_pfnDrawSetTextColor_t pfnDrawSetTextColor; - pfnEngDst_pfnDrawConsoleStringLen_t pfnDrawConsoleStringLen; - pfnEngDst_pfnConsolePrint_t pfnConsolePrint; - pfnEngDst_pfnCenterPrint_t pfnCenterPrint; - pfnEngDst_GetWindowCenterX_t GetWindowCenterX; - pfnEngDst_GetWindowCenterY_t GetWindowCenterY; - pfnEngDst_GetViewAngles_t GetViewAngles; - pfnEngDst_SetViewAngles_t SetViewAngles; - pfnEngDst_GetMaxClients_t GetMaxClients; - pfnEngDst_Cvar_SetValue_t Cvar_SetValue; - pfnEngDst_Cmd_Argc_t Cmd_Argc; - pfnEngDst_Cmd_Argv_t Cmd_Argv; - pfnEngDst_Con_Printf_t Con_Printf; - pfnEngDst_Con_DPrintf_t Con_DPrintf; - pfnEngDst_Con_NPrintf_t Con_NPrintf; - pfnEngDst_Con_NXPrintf_t Con_NXPrintf; - pfnEngDst_PhysInfo_ValueForKey_t PhysInfo_ValueForKey; - pfnEngDst_ServerInfo_ValueForKey_t ServerInfo_ValueForKey; - pfnEngDst_GetClientMaxspeed_t GetClientMaxspeed; - pfnEngDst_CheckParm_t CheckParm; - pfnEngDst_Key_Event_t Key_Event; - pfnEngDst_GetMousePosition_t GetMousePosition; - pfnEngDst_IsNoClipping_t IsNoClipping; - pfnEngDst_GetLocalPlayer_t GetLocalPlayer; - pfnEngDst_GetViewModel_t GetViewModel; - pfnEngDst_GetEntityByIndex_t GetEntityByIndex; - pfnEngDst_GetClientTime_t GetClientTime; - pfnEngDst_V_CalcShake_t V_CalcShake; - pfnEngDst_V_ApplyShake_t V_ApplyShake; - pfnEngDst_PM_PointContents_t PM_PointContents; - pfnEngDst_PM_WaterEntity_t PM_WaterEntity; - pfnEngDst_PM_TraceLine_t PM_TraceLine; - pfnEngDst_CL_LoadModel_t CL_LoadModel; - pfnEngDst_CL_CreateVisibleEntity_t CL_CreateVisibleEntity; - pfnEngDst_GetSpritePointer_t GetSpritePointer; - pfnEngDst_pfnPlaySoundByNameAtLocation_t pfnPlaySoundByNameAtLocation; - pfnEngDst_pfnPrecacheEvent_t pfnPrecacheEvent; - pfnEngDst_pfnPlaybackEvent_t pfnPlaybackEvent; - pfnEngDst_pfnWeaponAnim_t pfnWeaponAnim; - pfnEngDst_pfnRandomFloat_t pfnRandomFloat; - pfnEngDst_pfnRandomLong_t pfnRandomLong; - pfnEngDst_pfnHookEvent_t pfnHookEvent; - pfnEngDst_Con_IsVisible_t Con_IsVisible; - pfnEngDst_pfnGetGameDirectory_t pfnGetGameDirectory; - pfnEngDst_pfnGetCvarPointer_t pfnGetCvarPointer; - pfnEngDst_Key_LookupBinding_t Key_LookupBinding; - pfnEngDst_pfnGetLevelName_t pfnGetLevelName; - pfnEngDst_pfnGetScreenFade_t pfnGetScreenFade; - pfnEngDst_pfnSetScreenFade_t pfnSetScreenFade; - pfnEngDst_VGui_GetPanel_t VGui_GetPanel; - pfnEngDst_VGui_ViewportPaintBackground_t VGui_ViewportPaintBackground; - pfnEngDst_COM_LoadFile_t COM_LoadFile; - pfnEngDst_COM_ParseFile_t COM_ParseFile; - pfnEngDst_COM_FreeFile_t COM_FreeFile; - struct triangleapi_s *pTriAPI; - struct efx_api_s *pEfxAPI; - struct event_api_s *pEventAPI; - struct demo_api_s *pDemoAPI; - struct net_api_s *pNetAPI; - struct IVoiceTweak_s *pVoiceTweak; - pfnEngDst_IsSpectateOnly_t IsSpectateOnly; - pfnEngDst_LoadMapSprite_t LoadMapSprite; - pfnEngDst_COM_AddAppDirectoryToSearchPath_t COM_AddAppDirectoryToSearchPath; - pfnEngDst_COM_ExpandFilename_t COM_ExpandFilename; - pfnEngDst_PlayerInfo_ValueForKey_t PlayerInfo_ValueForKey; - pfnEngDst_PlayerInfo_SetValueForKey_t PlayerInfo_SetValueForKey; - pfnEngDst_GetPlayerUniqueID_t GetPlayerUniqueID; - pfnEngDst_GetTrackerIDForPlayer_t GetTrackerIDForPlayer; - pfnEngDst_GetPlayerForTrackerID_t GetPlayerForTrackerID; - pfnEngDst_pfnServerCmdUnreliable_t pfnServerCmdUnreliable; - pfnEngDst_GetMousePos_t pfnGetMousePos; - pfnEngDst_SetMousePos_t pfnSetMousePos; - pfnEngDst_SetMouseEnable_t pfnSetMouseEnable; - pfnEngDst_pfnSetFilterMode_t pfnSetFilterMode ; - pfnEngDst_pfnSetFilterColor_t pfnSetFilterColor ; - pfnEngDst_pfnSetFilterBrightness_t pfnSetFilterBrightness ; - pfnEngDst_pfnSequenceGet_t pfnSequenceGet; - pfnEngDst_pfnSPR_DrawGeneric_t pfnSPR_DrawGeneric; - pfnEngDst_pfnSequencePickSentence_t pfnSequencePickSentence; - pfnEngDst_pfnDrawString_t pfnDrawString; - pfnEngDst_pfnDrawString_t pfnDrawStringReverse; - pfnEngDst_LocalPlayerInfo_ValueForKey_t LocalPlayerInfo_ValueForKey; - pfnEngDst_pfnVGUI2DrawCharacter_t pfnVGUI2DrawCharacter; - pfnEngDst_pfnVGUI2DrawCharacterAdd_t pfnVGUI2DrawCharacterAdd; - pfnEngDst_pfnPlaySoundVoiceByName_t pfnPlaySoundVoiceByName; - pfnEngDst_pfnPrimeMusicStream_t pfnPrimeMusicStream; - pfnEngDst_pfnProcessTutorMessageDecayBuffer_t pfnProcessTutorMessageDecayBuffer; - pfnEngDst_pfnConstructTutorMessageDecayBuffer_t pfnConstructTutorMessageDecayBuffer; - pfnEngDst_pfnResetTutorMessageDecayData_t pfnResetTutorMessageDecayData; - pfnEngDst_pfnPlaySoundByNameAtPitch_t pfnPlaySoundByNameAtPitch; - pfnEngDst_pfnFillRGBABlend_t pfnFillRGBABlend; - pfnEngDst_pfnGetAppID_t pfnGetAppID; - pfnEngDst_pfnGetAliases_t pfnGetAliasList; - pfnEngDst_pfnVguiWrap2_GetMouseDelta_t pfnVguiWrap2_GetMouseDelta; -} cl_enginefunc_dst_t; - - -// ******************************************************** -// Functions exposed by the engine to the module -// ******************************************************** - -// Functions for ModuleS -typedef void (*PFN_KICKPLAYER)(int nPlayerSlot, int nReason); - -typedef struct modshelpers_s -{ - PFN_KICKPLAYER m_pfnKickPlayer; - - // reserved for future expansion - int m_nVoid1; - int m_nVoid2; - int m_nVoid3; - int m_nVoid4; - int m_nVoid5; - int m_nVoid6; - int m_nVoid7; - int m_nVoid8; - int m_nVoid9; -} modshelpers_t; - -// Functions for moduleC -typedef struct modchelpers_s -{ - // reserved for future expansion - int m_nVoid0; - int m_nVoid1; - int m_nVoid2; - int m_nVoid3; - int m_nVoid4; - int m_nVoid5; - int m_nVoid6; - int m_nVoid7; - int m_nVoid8; - int m_nVoid9; -} modchelpers_t; - - -// ******************************************************** -// Information about the engine -// ******************************************************** -typedef struct engdata_s -{ - cl_enginefunc_t *pcl_enginefuncs; // functions exported by the engine - cl_enginefunc_dst_t *pg_engdstAddrs; // destination handlers for engine exports - cldll_func_t *pcl_funcs; // client exports - cldll_func_dst_t *pg_cldstAddrs; // client export destination handlers - struct modfuncs_s *pg_modfuncs; // engine's pointer to module functions - struct cmd_function_s **pcmd_functions; // list of all registered commands - void *pkeybindings; // all key bindings (not really a void *, but easier this way) - void (*pfnConPrintf)(char *, ...); // dump to console - struct cvar_s **pcvar_vars; // pointer to head of cvar list - struct glwstate_t *pglwstate; // OpenGl information - void *(*pfnSZ_GetSpace)(struct sizebuf_s *, int); // pointer to SZ_GetSpace - struct modfuncs_s *pmodfuncs; // &g_modfuncs - void *pfnGetProcAddress; // &GetProcAddress - void *pfnGetModuleHandle; // &GetModuleHandle - struct server_static_s *psvs; // &svs - struct client_static_s *pcls; // &cls - void (*pfnSV_DropClient)(struct client_s *, qboolean, char *, ...); // pointer to SV_DropClient - void (*pfnNetchan_Transmit)(struct netchan_s *, int, byte *); // pointer to Netchan_Transmit - void (*pfnNET_SendPacket)(enum netsrc_s sock, int length, void *data, netadr_t to); // &NET_SendPacket - struct cvar_s *(*pfnCvarFindVar)(const char *pchName); // pointer to Cvar_FindVar - int *phinstOpenGlEarly; // &g_hinstOpenGlEarly - - // Reserved for future expansion - void *pVoid0; // reserved for future expan - void *pVoid1; // reserved for future expan - void *pVoid2; // reserved for future expan - void *pVoid3; // reserved for future expan - void *pVoid4; // reserved for future expan - void *pVoid5; // reserved for future expan - void *pVoid6; // reserved for future expan - void *pVoid7; // reserved for future expan - void *pVoid8; // reserved for future expan - void *pVoid9; // reserved for future expan -} engdata_t; - - -// ******************************************************** -// Functions exposed by the security module -// ******************************************************** -typedef void (*PFN_LOADMOD)(char *pchModule); -typedef void (*PFN_CLOSEMOD)(void); -typedef int (*PFN_NCALL)(int ijump, int cnArg, ...); - -typedef void (*PFN_GETCLDSTADDRS)(cldll_func_dst_t *pcldstAddrs); -typedef void (*PFN_GETENGDSTADDRS)(cl_enginefunc_dst_t *pengdstAddrs); -typedef void (*PFN_MODULELOADED)(void); - -typedef void (*PFN_PROCESSOUTGOINGNET)(struct netchan_s *pchan, struct sizebuf_s *psizebuf); -typedef qboolean (*PFN_PROCESSINCOMINGNET)(struct netchan_s *pchan, struct sizebuf_s *psizebuf); - -typedef void (*PFN_TEXTURELOAD)(char *pszName, int dxWidth, int dyHeight, char *pbData); -typedef void (*PFN_MODELLOAD)(struct model_s *pmodel, void *pvBuf); - -typedef void (*PFN_FRAMEBEGIN)(void); -typedef void (*PFN_FRAMERENDER1)(void); -typedef void (*PFN_FRAMERENDER2)(void); - -typedef void (*PFN_SETMODSHELPERS)(modshelpers_t *pmodshelpers); -typedef void (*PFN_SETMODCHELPERS)(modchelpers_t *pmodchelpers); -typedef void (*PFN_SETENGDATA)(engdata_t *pengdata); - -typedef void (*PFN_CONNECTCLIENT)(int iPlayer); -typedef void (*PFN_RECORDIP)(unsigned int pnIP); -typedef void (*PFN_PLAYERSTATUS)(unsigned char *pbData, int cbData); - -typedef void (*PFN_SETENGINEVERSION)(int nVersion); - -// typedef class CMachine *(*PFN_PCMACHINE)(void); -typedef int (*PFN_PCMACHINE)(void); -typedef void (*PFN_SETIP)(int ijump); -typedef void (*PFN_EXECUTE)(void); - -typedef struct modfuncs_s -{ - // Functions for the pcode interpreter - PFN_LOADMOD m_pfnLoadMod; - PFN_CLOSEMOD m_pfnCloseMod; - PFN_NCALL m_pfnNCall; - - // API destination functions - PFN_GETCLDSTADDRS m_pfnGetClDstAddrs; - PFN_GETENGDSTADDRS m_pfnGetEngDstAddrs; - - // Miscellaneous functions - PFN_MODULELOADED m_pfnModuleLoaded; // Called right after the module is loaded - - // Functions for processing network traffic - PFN_PROCESSOUTGOINGNET m_pfnProcessOutgoingNet; // Every outgoing packet gets run through this - PFN_PROCESSINCOMINGNET m_pfnProcessIncomingNet; // Every incoming packet gets run through this - - // Resource functions - PFN_TEXTURELOAD m_pfnTextureLoad; // Called as each texture is loaded - PFN_MODELLOAD m_pfnModelLoad; // Called as each model is loaded - - // Functions called every frame - PFN_FRAMEBEGIN m_pfnFrameBegin; // Called at the beginning of each frame cycle - PFN_FRAMERENDER1 m_pfnFrameRender1; // Called at the beginning of the render loop - PFN_FRAMERENDER2 m_pfnFrameRender2; // Called at the end of the render loop - - // Module helper transfer - PFN_SETMODSHELPERS m_pfnSetModSHelpers; - PFN_SETMODCHELPERS m_pfnSetModCHelpers; - PFN_SETENGDATA m_pfnSetEngData; - - // Which version of the module is this? - int m_nVersion; - - // Miscellaneous game stuff - PFN_CONNECTCLIENT m_pfnConnectClient; // Called whenever a new client connects - PFN_RECORDIP m_pfnRecordIP; // Secure master has reported a new IP for us - PFN_PLAYERSTATUS m_pfnPlayerStatus; // Called whenever we receive a PlayerStatus packet - - // Recent additions - PFN_SETENGINEVERSION m_pfnSetEngineVersion; // 1 = patched engine - - // reserved for future expansion - int m_nVoid2; - int m_nVoid3; - int m_nVoid4; - int m_nVoid5; - int m_nVoid6; - int m_nVoid7; - int m_nVoid8; - int m_nVoid9; -} modfuncs_t; - - -#define k_nEngineVersion15Base 0 -#define k_nEngineVersion15Patch 1 -#define k_nEngineVersion16Base 2 -#define k_nEngineVersion16Validated 3 // 1.6 engine with built-in validation - - -typedef struct validator_s -{ - int m_nRandomizer; // Random number to be XOR'd into all subsequent fields - int m_nSignature1; // First signature that identifies this structure - int m_nSignature2; // Second signature - int m_pbCode; // Beginning of the code block - int m_cbCode; // Size of the code block - int m_nChecksum; // Checksum of the code block - int m_nSpecial; // For engine, 1 if hw.dll, 0 if sw.dll. For client, pclfuncs checksum - int m_nCompensator; // Keeps the checksum correct -} validator_t; - - -#define k_nChecksumCompensator 0x36a8f09c // Don't change this value: it's hardcorded in cdll_int.cpp, - -#define k_nModuleVersionCur 0x43210004 - - -#endif // __APIPROXY__ diff --git a/HLSDK/engine/Sequence.h b/HLSDK/engine/Sequence.h deleted file mode 100644 index eaea2c7..0000000 --- a/HLSDK/engine/Sequence.h +++ /dev/null @@ -1,204 +0,0 @@ -//--------------------------------------------------------------------------- -// -// S c r i p t e d S e q u e n c e s -// -//--------------------------------------------------------------------------- -#ifndef _INCLUDE_SEQUENCE_H_ -#define _INCLUDE_SEQUENCE_H_ - - -#ifndef _DEF_BYTE_ -typedef unsigned char byte; -#endif - -//--------------------------------------------------------------------------- -// client_textmessage_t -//--------------------------------------------------------------------------- -#ifndef _CLIENT_TEXTMSG_DEFINED_ -#define _CLIENT_TEXTMSG_DEFINED_ -typedef struct client_textmessage_s -{ - int effect; - byte r1, g1, b1, a1; // 2 colors for effects - byte r2, g2, b2, a2; - float x; - float y; - float fadein; - float fadeout; - float holdtime; - float fxtime; - const char *pName; - const char *pMessage; -} client_textmessage_t; -#endif - - -//-------------------------------------------------------------------------- -// sequenceDefaultBits_e -// -// Enumerated list of possible modifiers for a command. This enumeration -// is used in a bitarray controlling what modifiers are specified for a command. -//--------------------------------------------------------------------------- -enum sequenceModifierBits -{ - SEQUENCE_MODIFIER_EFFECT_BIT = (1 << 1), - SEQUENCE_MODIFIER_POSITION_BIT = (1 << 2), - SEQUENCE_MODIFIER_COLOR_BIT = (1 << 3), - SEQUENCE_MODIFIER_COLOR2_BIT = (1 << 4), - SEQUENCE_MODIFIER_FADEIN_BIT = (1 << 5), - SEQUENCE_MODIFIER_FADEOUT_BIT = (1 << 6), - SEQUENCE_MODIFIER_HOLDTIME_BIT = (1 << 7), - SEQUENCE_MODIFIER_FXTIME_BIT = (1 << 8), - SEQUENCE_MODIFIER_SPEAKER_BIT = (1 << 9), - SEQUENCE_MODIFIER_LISTENER_BIT = (1 << 10), - SEQUENCE_MODIFIER_TEXTCHANNEL_BIT = (1 << 11), -}; -typedef enum sequenceModifierBits sequenceModifierBits_e ; - - -//--------------------------------------------------------------------------- -// sequenceCommandEnum_e -// -// Enumerated sequence command types. -//--------------------------------------------------------------------------- -enum sequenceCommandEnum_ -{ - SEQUENCE_COMMAND_ERROR = -1, - SEQUENCE_COMMAND_PAUSE = 0, - SEQUENCE_COMMAND_FIRETARGETS, - SEQUENCE_COMMAND_KILLTARGETS, - SEQUENCE_COMMAND_TEXT, - SEQUENCE_COMMAND_SOUND, - SEQUENCE_COMMAND_GOSUB, - SEQUENCE_COMMAND_SENTENCE, - SEQUENCE_COMMAND_REPEAT, - SEQUENCE_COMMAND_SETDEFAULTS, - SEQUENCE_COMMAND_MODIFIER, - SEQUENCE_COMMAND_POSTMODIFIER, - SEQUENCE_COMMAND_NOOP, - - SEQUENCE_MODIFIER_EFFECT, - SEQUENCE_MODIFIER_POSITION, - SEQUENCE_MODIFIER_COLOR, - SEQUENCE_MODIFIER_COLOR2, - SEQUENCE_MODIFIER_FADEIN, - SEQUENCE_MODIFIER_FADEOUT, - SEQUENCE_MODIFIER_HOLDTIME, - SEQUENCE_MODIFIER_FXTIME, - SEQUENCE_MODIFIER_SPEAKER, - SEQUENCE_MODIFIER_LISTENER, - SEQUENCE_MODIFIER_TEXTCHANNEL, -}; -typedef enum sequenceCommandEnum_ sequenceCommandEnum_e; - - -//--------------------------------------------------------------------------- -// sequenceCommandType_e -// -// Typeerated sequence command types. -//--------------------------------------------------------------------------- -enum sequenceCommandType_ -{ - SEQUENCE_TYPE_COMMAND, - SEQUENCE_TYPE_MODIFIER, -}; -typedef enum sequenceCommandType_ sequenceCommandType_e; - - -//--------------------------------------------------------------------------- -// sequenceCommandMapping_s -// -// A mapping of a command enumerated-value to its name. -//--------------------------------------------------------------------------- -typedef struct sequenceCommandMapping_ sequenceCommandMapping_s; -struct sequenceCommandMapping_ -{ - sequenceCommandEnum_e commandEnum; - const char* commandName; - sequenceCommandType_e commandType; -}; - - -//--------------------------------------------------------------------------- -// sequenceCommandLine_s -// -// Structure representing a single command (usually 1 line) from a -// .SEQ file entry. -//--------------------------------------------------------------------------- -typedef struct sequenceCommandLine_ sequenceCommandLine_s; -struct sequenceCommandLine_ -{ - int commandType; // Specifies the type of command - client_textmessage_t clientMessage; // Text HUD message struct - char* speakerName; // Targetname of speaking entity - char* listenerName; // Targetname of entity being spoken to - char* soundFileName; // Name of sound file to play - char* sentenceName; // Name of sentences.txt to play - char* fireTargetNames; // List of targetnames to fire - char* killTargetNames; // List of targetnames to remove - float delay; // Seconds 'till next command - int repeatCount; // If nonzero, reset execution pointer to top of block (N times, -1 = infinite) - int textChannel; // Display channel on which text message is sent - int modifierBitField; // Bit field to specify what clientmessage fields are valid - sequenceCommandLine_s* nextCommandLine; // Next command (linked list) -}; - - -//--------------------------------------------------------------------------- -// sequenceEntry_s -// -// Structure representing a single command (usually 1 line) from a -// .SEQ file entry. -//--------------------------------------------------------------------------- -typedef struct sequenceEntry_ sequenceEntry_s; -struct sequenceEntry_ -{ - char* fileName; // Name of sequence file without .SEQ extension - char* entryName; // Name of entry label in file - sequenceCommandLine_s* firstCommand; // Linked list of commands in entry - sequenceEntry_s* nextEntry; // Next loaded entry - qboolean isGlobal; // Is entry retained over level transitions? -}; - - - -//--------------------------------------------------------------------------- -// sentenceEntry_s -// Structure representing a single sentence of a group from a .SEQ -// file entry. Sentences are identical to entries in sentences.txt, but -// can be unique per level and are loaded/unloaded with the level. -//--------------------------------------------------------------------------- -typedef struct sentenceEntry_ sentenceEntry_s; -struct sentenceEntry_ -{ - char* data; // sentence data (ie "We have hostiles" ) - sentenceEntry_s* nextEntry; // Next loaded entry - qboolean isGlobal; // Is entry retained over level transitions? - unsigned int index; // this entry's position in the file. -}; - -//-------------------------------------------------------------------------- -// sentenceGroupEntry_s -// Structure representing a group of sentences found in a .SEQ file. -// A sentence group is defined by all sentences with the same name, ignoring -// the number at the end of the sentence name. Groups enable a sentence -// to be picked at random across a group. -//-------------------------------------------------------------------------- -typedef struct sentenceGroupEntry_ sentenceGroupEntry_s; -struct sentenceGroupEntry_ -{ - char* groupName; // name of the group (ie CT_ALERT ) - unsigned int numSentences; // number of sentences in group - sentenceEntry_s* firstSentence; // head of linked list of sentences in group - sentenceGroupEntry_s* nextEntry; // next loaded group -}; - -//--------------------------------------------------------------------------- -// Function declarations -//--------------------------------------------------------------------------- -sequenceEntry_s* SequenceGet( const char* fileName, const char* entryName ); -void Sequence_ParseFile( const char* fileName, qboolean isGlobal ); -void Sequence_OnLevelLoad( const char* mapName ); -sentenceEntry_s* SequencePickSentence( const char *groupName, int pickMethod, int *picked ); - -#endif /* _INCLUDE_SEQUENCE_H_ */ diff --git a/HLSDK/engine/anorms.h b/HLSDK/engine/anorms.h deleted file mode 100644 index c90f8d6..0000000 --- a/HLSDK/engine/anorms.h +++ /dev/null @@ -1,177 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -{-0.525731, 0.000000, 0.850651}, -{-0.442863, 0.238856, 0.864188}, -{-0.295242, 0.000000, 0.955423}, -{-0.309017, 0.500000, 0.809017}, -{-0.162460, 0.262866, 0.951056}, -{0.000000, 0.000000, 1.000000}, -{0.000000, 0.850651, 0.525731}, -{-0.147621, 0.716567, 0.681718}, -{0.147621, 0.716567, 0.681718}, -{0.000000, 0.525731, 0.850651}, -{0.309017, 0.500000, 0.809017}, -{0.525731, 0.000000, 0.850651}, -{0.295242, 0.000000, 0.955423}, -{0.442863, 0.238856, 0.864188}, -{0.162460, 0.262866, 0.951056}, -{-0.681718, 0.147621, 0.716567}, -{-0.809017, 0.309017, 0.500000}, -{-0.587785, 0.425325, 0.688191}, -{-0.850651, 0.525731, 0.000000}, -{-0.864188, 0.442863, 0.238856}, -{-0.716567, 0.681718, 0.147621}, -{-0.688191, 0.587785, 0.425325}, -{-0.500000, 0.809017, 0.309017}, -{-0.238856, 0.864188, 0.442863}, -{-0.425325, 0.688191, 0.587785}, -{-0.716567, 0.681718, -0.147621}, -{-0.500000, 0.809017, -0.309017}, -{-0.525731, 0.850651, 0.000000}, -{0.000000, 0.850651, -0.525731}, -{-0.238856, 0.864188, -0.442863}, -{0.000000, 0.955423, -0.295242}, -{-0.262866, 0.951056, -0.162460}, -{0.000000, 1.000000, 0.000000}, -{0.000000, 0.955423, 0.295242}, -{-0.262866, 0.951056, 0.162460}, -{0.238856, 0.864188, 0.442863}, -{0.262866, 0.951056, 0.162460}, -{0.500000, 0.809017, 0.309017}, -{0.238856, 0.864188, -0.442863}, -{0.262866, 0.951056, -0.162460}, -{0.500000, 0.809017, -0.309017}, -{0.850651, 0.525731, 0.000000}, -{0.716567, 0.681718, 0.147621}, -{0.716567, 0.681718, -0.147621}, -{0.525731, 0.850651, 0.000000}, -{0.425325, 0.688191, 0.587785}, -{0.864188, 0.442863, 0.238856}, -{0.688191, 0.587785, 0.425325}, -{0.809017, 0.309017, 0.500000}, -{0.681718, 0.147621, 0.716567}, -{0.587785, 0.425325, 0.688191}, -{0.955423, 0.295242, 0.000000}, -{1.000000, 0.000000, 0.000000}, -{0.951056, 0.162460, 0.262866}, -{0.850651, -0.525731, 0.000000}, -{0.955423, -0.295242, 0.000000}, -{0.864188, -0.442863, 0.238856}, -{0.951056, -0.162460, 0.262866}, -{0.809017, -0.309017, 0.500000}, -{0.681718, -0.147621, 0.716567}, -{0.850651, 0.000000, 0.525731}, -{0.864188, 0.442863, -0.238856}, -{0.809017, 0.309017, -0.500000}, -{0.951056, 0.162460, -0.262866}, -{0.525731, 0.000000, -0.850651}, -{0.681718, 0.147621, -0.716567}, -{0.681718, -0.147621, -0.716567}, -{0.850651, 0.000000, -0.525731}, -{0.809017, -0.309017, -0.500000}, -{0.864188, -0.442863, -0.238856}, -{0.951056, -0.162460, -0.262866}, -{0.147621, 0.716567, -0.681718}, -{0.309017, 0.500000, -0.809017}, -{0.425325, 0.688191, -0.587785}, -{0.442863, 0.238856, -0.864188}, -{0.587785, 0.425325, -0.688191}, -{0.688191, 0.587785, -0.425325}, -{-0.147621, 0.716567, -0.681718}, -{-0.309017, 0.500000, -0.809017}, -{0.000000, 0.525731, -0.850651}, -{-0.525731, 0.000000, -0.850651}, -{-0.442863, 0.238856, -0.864188}, -{-0.295242, 0.000000, -0.955423}, -{-0.162460, 0.262866, -0.951056}, -{0.000000, 0.000000, -1.000000}, -{0.295242, 0.000000, -0.955423}, -{0.162460, 0.262866, -0.951056}, -{-0.442863, -0.238856, -0.864188}, -{-0.309017, -0.500000, -0.809017}, -{-0.162460, -0.262866, -0.951056}, -{0.000000, -0.850651, -0.525731}, -{-0.147621, -0.716567, -0.681718}, -{0.147621, -0.716567, -0.681718}, -{0.000000, -0.525731, -0.850651}, -{0.309017, -0.500000, -0.809017}, -{0.442863, -0.238856, -0.864188}, -{0.162460, -0.262866, -0.951056}, -{0.238856, -0.864188, -0.442863}, -{0.500000, -0.809017, -0.309017}, -{0.425325, -0.688191, -0.587785}, -{0.716567, -0.681718, -0.147621}, -{0.688191, -0.587785, -0.425325}, -{0.587785, -0.425325, -0.688191}, -{0.000000, -0.955423, -0.295242}, -{0.000000, -1.000000, 0.000000}, -{0.262866, -0.951056, -0.162460}, -{0.000000, -0.850651, 0.525731}, -{0.000000, -0.955423, 0.295242}, -{0.238856, -0.864188, 0.442863}, -{0.262866, -0.951056, 0.162460}, -{0.500000, -0.809017, 0.309017}, -{0.716567, -0.681718, 0.147621}, -{0.525731, -0.850651, 0.000000}, -{-0.238856, -0.864188, -0.442863}, -{-0.500000, -0.809017, -0.309017}, -{-0.262866, -0.951056, -0.162460}, -{-0.850651, -0.525731, 0.000000}, -{-0.716567, -0.681718, -0.147621}, -{-0.716567, -0.681718, 0.147621}, -{-0.525731, -0.850651, 0.000000}, -{-0.500000, -0.809017, 0.309017}, -{-0.238856, -0.864188, 0.442863}, -{-0.262866, -0.951056, 0.162460}, -{-0.864188, -0.442863, 0.238856}, -{-0.809017, -0.309017, 0.500000}, -{-0.688191, -0.587785, 0.425325}, -{-0.681718, -0.147621, 0.716567}, -{-0.442863, -0.238856, 0.864188}, -{-0.587785, -0.425325, 0.688191}, -{-0.309017, -0.500000, 0.809017}, -{-0.147621, -0.716567, 0.681718}, -{-0.425325, -0.688191, 0.587785}, -{-0.162460, -0.262866, 0.951056}, -{0.442863, -0.238856, 0.864188}, -{0.162460, -0.262866, 0.951056}, -{0.309017, -0.500000, 0.809017}, -{0.147621, -0.716567, 0.681718}, -{0.000000, -0.525731, 0.850651}, -{0.425325, -0.688191, 0.587785}, -{0.587785, -0.425325, 0.688191}, -{0.688191, -0.587785, 0.425325}, -{-0.955423, 0.295242, 0.000000}, -{-0.951056, 0.162460, 0.262866}, -{-1.000000, 0.000000, 0.000000}, -{-0.850651, 0.000000, 0.525731}, -{-0.955423, -0.295242, 0.000000}, -{-0.951056, -0.162460, 0.262866}, -{-0.864188, 0.442863, -0.238856}, -{-0.951056, 0.162460, -0.262866}, -{-0.809017, 0.309017, -0.500000}, -{-0.864188, -0.442863, -0.238856}, -{-0.951056, -0.162460, -0.262866}, -{-0.809017, -0.309017, -0.500000}, -{-0.681718, 0.147621, -0.716567}, -{-0.681718, -0.147621, -0.716567}, -{-0.850651, 0.000000, -0.525731}, -{-0.688191, 0.587785, -0.425325}, -{-0.587785, 0.425325, -0.688191}, -{-0.425325, 0.688191, -0.587785}, -{-0.425325, -0.688191, -0.587785}, -{-0.587785, -0.425325, -0.688191}, -{-0.688191, -0.587785, -0.425325}, diff --git a/HLSDK/engine/archtypes.h b/HLSDK/engine/archtypes.h deleted file mode 100644 index 3315135..0000000 --- a/HLSDK/engine/archtypes.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// Word size dependent definitions -// DAL 1/03 -// -#ifndef ARCHTYPES_H -#define ARCHTYPES_H - -#ifdef __x86_64__ -#define X64BITS -#endif - -#if defined( _WIN32 ) && (! defined( __MINGW32__ )) - -typedef __int16 int16; -typedef unsigned __int16 uint16; -typedef __int32 int32; -typedef unsigned __int32 uint32; -typedef __int64 int64; -typedef unsigned __int64 uint64; -typedef __int32 intp; // intp is an integer that can accomodate a pointer -typedef unsigned __int32 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *) - -#else /* _WIN32 */ - -typedef short int16; -typedef unsigned short uint16; -typedef int int32; -typedef unsigned int uint32; -typedef long long int64; -typedef unsigned long long uint64; -#ifdef X64BITS -typedef long long intp; -typedef unsigned long long uintp; -#else -typedef int intp; -typedef unsigned int uintp; -#endif - -#endif /* else _WIN32 */ - -#endif /* ARCHTYPES_H */ diff --git a/HLSDK/engine/cdll_int.h b/HLSDK/engine/cdll_int.h deleted file mode 100644 index 555800f..0000000 --- a/HLSDK/engine/cdll_int.h +++ /dev/null @@ -1,467 +0,0 @@ -/*** -* -* Copyright (c) 1999, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// -// cdll_int.h -// -// 4-23-98 -// JOHN: client dll interface declarations -// - -#ifndef CDLL_INT_H -#define CDLL_INT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "const.h" -#include "steam/steamtypes.h" -#include "ref_params.h" -#include "r_efx.h" -#include "studio_event.h" - -// this file is included by both the engine and the client-dll, -// so make sure engine declarations aren't done twice - -typedef int HSPRITE; // handle to a graphic - -#define SCRINFO_SCREENFLASH 1 -#define SCRINFO_STRETCHED 2 - -typedef struct SCREENINFO_s -{ - int iSize; - int iWidth; - int iHeight; - int iFlags; - int iCharHeight; - short charWidths[256]; -} SCREENINFO; - - -typedef struct client_data_s -{ - // fields that cannot be modified (ie. have no effect if changed) - vec3_t origin; - - // fields that can be changed by the cldll - vec3_t viewangles; - int iWeaponBits; -// int iAccessoryBits; - float fov; // field of view -} client_data_t; - -typedef struct client_sprite_s -{ - char szName[64]; - char szSprite[64]; - int hspr; - int iRes; - wrect_t rc; -} client_sprite_t; - - - -typedef struct hud_player_info_s -{ - char *name; - short ping; - byte thisplayer; // TRUE if this is the calling player - - byte spectator; - byte packetloss; - - char *model; - short topcolor; - short bottomcolor; - - uint64 m_nSteamID; -} hud_player_info_t; - - - -typedef struct module_s -{ - unsigned char ucMD5Hash[16]; // hash over code - qboolean fLoaded; // true if successfully loaded -} module_t; - - - - - - -#ifndef IN_BUTTONS_H -#include "in_buttons.h" -#endif - -#define CLDLL_INTERFACE_VERSION 7 - -extern void LoadSecurityModuleFromDisk(char * pszDllName); -extern void LoadSecurityModuleFromMemory( unsigned char * pCode, int nSize ); -extern void CloseSecurityModule(); - - -extern void ClientDLL_Init( void ); // from cdll_int.c -extern void ClientDLL_Shutdown( void ); -extern void ClientDLL_HudInit( void ); -extern void ClientDLL_HudVidInit( void ); -extern void ClientDLL_UpdateClientData( void ); -extern void ClientDLL_Frame( double time ); -extern void ClientDLL_HudRedraw( int intermission ); -extern void ClientDLL_MoveClient( struct playermove_s *ppmove ); -extern void ClientDLL_ClientMoveInit( struct playermove_s *ppmove ); -extern char ClientDLL_ClientTextureType( char *name ); - -extern void ClientDLL_CreateMove( float frametime, struct usercmd_s *cmd, int active ); -extern void ClientDLL_ActivateMouse( void ); -extern void ClientDLL_DeactivateMouse( void ); -extern void ClientDLL_MouseEvent( int mstate ); -extern void ClientDLL_ClearStates( void ); -extern int ClientDLL_IsThirdPerson( void ); -extern void ClientDLL_GetCameraOffsets( float *ofs ); -extern int ClientDLL_GraphKeyDown( void ); -extern struct kbutton_s *ClientDLL_FindKey( const char *name ); -extern void ClientDLL_CAM_Think( void ); -extern void ClientDLL_IN_Accumulate( void ); -extern void ClientDLL_CalcRefdef( struct ref_params_s *pparams ); -extern int ClientDLL_AddEntity( int type, struct cl_entity_s *ent ); -extern void ClientDLL_CreateEntities( void ); - -extern void ClientDLL_DrawNormalTriangles( void ); -extern void ClientDLL_DrawTransparentTriangles( void ); -extern void ClientDLL_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *entity ); -extern void ClientDLL_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed ); -extern void ClientDLL_TxferLocalOverrides( struct entity_state_s *state, const struct clientdata_s *client ); -extern void ClientDLL_ProcessPlayerState( struct entity_state_s *dst, const struct entity_state_s *src ); -extern void ClientDLL_TxferPredictionData ( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd ); -extern void ClientDLL_ReadDemoBuffer( int size, unsigned char *buffer ); -extern int ClientDLL_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); -extern int ClientDLL_GetHullBounds( int hullnumber, float *mins, float *maxs ); - -extern void ClientDLL_VGui_ConsolePrint(const char* text); - -extern int ClientDLL_Key_Event( int down, int keynum, const char *pszCurrentBinding ); -extern void ClientDLL_TempEntUpdate( double ft, double ct, double grav, struct tempent_s **ppFreeTE, struct tempent_s **ppActiveTE, int ( *addTEntity )( struct cl_entity_s *pEntity ), void ( *playTESound )( struct tempent_s *pTemp, float damp ) ); -extern struct cl_entity_s *ClientDLL_GetUserEntity( int index ); -extern void ClientDLL_VoiceStatus(int entindex, qboolean bTalking); -extern void ClientDLL_DirectorMessage( int iSize, void *pbuf ); -extern void ClientDLL_ChatInputPosition( int *x, int *y ); - -//#include "server.h" // server_static_t define for apiproxy -#include "APIProxy.h" - -extern cldll_func_t cl_funcs; -extern cl_enginefunc_t cl_engsrcProxies; -extern cl_enginefunc_dst_t g_engdstAddrs; - -// Module exports -extern modfuncs_t g_modfuncs; -extern module_t g_module; - -// Macros for exported engine funcs -#define RecEngSPR_Load(a) (g_engdstAddrs.pfnSPR_Load(&a)) -#define RecEngSPR_Frames(a) (g_engdstAddrs.pfnSPR_Frames(&a)) -#define RecEngSPR_Height(a, b) (g_engdstAddrs.pfnSPR_Height(&a, &b)) -#define RecEngSPR_Width(a, b) (g_engdstAddrs.pfnSPR_Width(&a, &b)) -#define RecEngSPR_Set(a, b, c, d) (g_engdstAddrs.pfnSPR_Set(&a, &b, &c, &d)) -#define RecEngSPR_Draw(a, b, c, d) (g_engdstAddrs.pfnSPR_Draw(&a, &b, &c, &d)) -#define RecEngSPR_DrawHoles(a, b, c, d) (g_engdstAddrs.pfnSPR_DrawHoles(&a, &b, &c, &d)) -#define RecEngSPR_DrawAdditive(a, b, c, d) (g_engdstAddrs.pfnSPR_DrawAdditive(&a, &b, &c, &d)) -#define RecEngSPR_EnableScissor(a, b, c, d) (g_engdstAddrs.pfnSPR_EnableScissor(&a, &b, &c, &d)) -#define RecEngSPR_DisableScissor() (g_engdstAddrs.pfnSPR_DisableScissor()) -#define RecEngSPR_GetList(a, b) (g_engdstAddrs.pfnSPR_GetList(&a, &b)) -#define RecEngDraw_FillRGBA(a, b, c, d, e, f, g, h) (g_engdstAddrs.pfnFillRGBA(&a, &b, &c, &d, &e, &f, &g, &h)) -#define RecEnghudGetScreenInfo(a) (g_engdstAddrs.pfnGetScreenInfo(&a)) -#define RecEngSetCrosshair(a, b, c, d, e) (g_engdstAddrs.pfnSetCrosshair(&a, &b, &c, &d, &e)) -#define RecEnghudRegisterVariable(a, b, c) (g_engdstAddrs.pfnRegisterVariable(&a, &b, &c)) -#define RecEnghudGetCvarFloat(a) (g_engdstAddrs.pfnGetCvarFloat(&a)) -#define RecEnghudGetCvarString(a) (g_engdstAddrs.pfnGetCvarString(&a)) -#define RecEnghudAddCommand(a, b) (g_engdstAddrs.pfnAddCommand(&a, &b)) -#define RecEnghudHookUserMsg(a, b) (g_engdstAddrs.pfnHookUserMsg(&a, &b)) -#define RecEnghudServerCmd(a) (g_engdstAddrs.pfnServerCmd(&a)) -#define RecEnghudClientCmd(a) (g_engdstAddrs.pfnClientCmd(&a)) -#define RecEngPrimeMusicStream(a, b) (g_engdstAddrs.pfnPrimeMusicStream(&a, &b)) -#define RecEnghudGetPlayerInfo(a, b) (g_engdstAddrs.pfnGetPlayerInfo(&a, &b)) -#define RecEnghudPlaySoundByName(a, b) (g_engdstAddrs.pfnPlaySoundByName(&a, &b)) -#define RecEnghudPlaySoundByNameAtPitch(a, b, c) (g_engdstAddrs.pfnPlaySoundByNameAtPitch(&a, &b, &c)) -#define RecEnghudPlaySoundVoiceByName(a, b) (g_engdstAddrs.pfnPlaySoundVoiceByName(&a, &b)) -#define RecEnghudPlaySoundByIndex(a, b) (g_engdstAddrs.pfnPlaySoundByIndex(&a, &b)) -#define RecEngAngleVectors(a, b, c, d) (g_engdstAddrs.pfnAngleVectors(&a, &b, &c, &d)) -#define RecEngTextMessageGet(a) (g_engdstAddrs.pfnTextMessageGet(&a)) -#define RecEngTextMessageDrawCharacter(a, b, c, d, e, f) (g_engdstAddrs.pfnDrawCharacter(&a, &b, &c, &d, &e, &f)) -#define RecEngDrawConsoleString(a, b, c) (g_engdstAddrs.pfnDrawConsoleString(&a, &b, &c)) -#define RecEngDrawSetTextColor(a, b, c) (g_engdstAddrs.pfnDrawSetTextColor(&a, &b, &c)) -#define RecEnghudDrawConsoleStringLen(a, b, c) (g_engdstAddrs.pfnDrawConsoleStringLen(&a, &b, &c)) -#define RecEnghudConsolePrint(a) (g_engdstAddrs.pfnConsolePrint(&a)) -#define RecEnghudCenterPrint(a) (g_engdstAddrs.pfnCenterPrint(&a)) -#define RecEnghudCenterX() (g_engdstAddrs.GetWindowCenterX()) -#define RecEnghudCenterY() (g_engdstAddrs.GetWindowCenterY()) -#define RecEnghudGetViewAngles(a) (g_engdstAddrs.GetViewAngles(&a)) -#define RecEnghudSetViewAngles(a) (g_engdstAddrs.SetViewAngles(&a)) -#define RecEnghudGetMaxClients() (g_engdstAddrs.GetMaxClients()) -#define RecEngCvar_SetValue(a, b) (g_engdstAddrs.Cvar_SetValue(&a, &b)) -#define RecEngCmd_Argc() (g_engdstAddrs.Cmd_Argc()) -#define RecEngCmd_Argv(a) (g_engdstAddrs.Cmd_Argv(&a)) -#define RecEngCon_Printf(a) (g_engdstAddrs.Con_Printf(&a)) -#define RecEngCon_DPrintf(a) (g_engdstAddrs.Con_DPrintf(&a)) -#define RecEngCon_NPrintf(a, b) (g_engdstAddrs.Con_NPrintf(&a, &b)) -#define RecEngCon_NXPrintf(a, b) (g_engdstAddrs.Con_NXPrintf(&a, &b)) -#define RecEnghudPhysInfo_ValueForKey(a) (g_engdstAddrs.PhysInfo_ValueForKey(&a)) -#define RecEnghudServerInfo_ValueForKey(a) (g_engdstAddrs.ServerInfo_ValueForKey(&a)) -#define RecEnghudGetClientMaxspeed() (g_engdstAddrs.GetClientMaxspeed()) -#define RecEnghudCheckParm(a, b) (g_engdstAddrs.CheckParm(&a, &b)) -#define RecEngKey_Event(a, b) (g_engdstAddrs.Key_Event(&a, &b)) -#define RecEnghudGetMousePosition(a, b) (g_engdstAddrs.GetMousePosition(&a, &b)) -#define RecEnghudIsNoClipping() (g_engdstAddrs.IsNoClipping()) -#define RecEnghudGetLocalPlayer() (g_engdstAddrs.GetLocalPlayer()) -#define RecEnghudGetViewModel() (g_engdstAddrs.GetViewModel()) -#define RecEnghudGetEntityByIndex(a) (g_engdstAddrs.GetEntityByIndex(&a)) -#define RecEnghudGetClientTime() (g_engdstAddrs.GetClientTime()) -#define RecEngV_CalcShake() (g_engdstAddrs.V_CalcShake()) -#define RecEngV_ApplyShake(a, b, c) (g_engdstAddrs.V_ApplyShake(&a, &b, &c)) -#define RecEngPM_PointContents(a, b) (g_engdstAddrs.PM_PointContents(&a, &b)) -#define RecEngPM_WaterEntity(a) (g_engdstAddrs.PM_WaterEntity(&a)) -#define RecEngPM_TraceLine(a, b, c, d, e) (g_engdstAddrs.PM_TraceLine(&a, &b, &c, &d, &e)) -#define RecEngCL_LoadModel(a, b) (g_engdstAddrs.CL_LoadModel(&a, &b)) -#define RecEngCL_CreateVisibleEntity(a, b) (g_engdstAddrs.CL_CreateVisibleEntity(&a, &b)) -#define RecEnghudGetSpritePointer(a) (g_engdstAddrs.GetSpritePointer(&a)) -#define RecEnghudPlaySoundByNameAtLocation(a, b, c) (g_engdstAddrs.pfnPlaySoundByNameAtLocation(&a, &b, &c)) -#define RecEnghudPrecacheEvent(a, b) (g_engdstAddrs.pfnPrecacheEvent(&a, &b)) -#define RecEnghudPlaybackEvent(a, b, c, d, e, f, g, h, i, j, k, l) (g_engdstAddrs.pfnPlaybackEvent(&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l)) -#define RecEnghudWeaponAnim(a, b) (g_engdstAddrs.pfnWeaponAnim(&a, &b)) -#define RecEngRandomFloat(a, b) (g_engdstAddrs.pfnRandomFloat(&a, &b)) -#define RecEngRandomLong(a, b) (g_engdstAddrs.pfnRandomLong(&a, &b)) -#define RecEngCL_HookEvent(a, b) (g_engdstAddrs.pfnHookEvent(&a, &b)) -#define RecEngCon_IsVisible() (g_engdstAddrs.Con_IsVisible()) -#define RecEnghudGetGameDir() (g_engdstAddrs.pfnGetGameDirectory()) -#define RecEngCvar_FindVar(a) (g_engdstAddrs.pfnGetCvarPointer(&a)) -#define RecEngKey_NameForBinding(a) (g_engdstAddrs.Key_LookupBinding(&a)) -#define RecEnghudGetLevelName() (g_engdstAddrs.pfnGetLevelName()) -#define RecEnghudGetScreenFade(a) (g_engdstAddrs.pfnGetScreenFade(&a)) -#define RecEnghudSetScreenFade(a) (g_engdstAddrs.pfnSetScreenFade(&a)) -#define RecEngVGuiWrap_GetPanel() (g_engdstAddrs.VGui_GetPanel()) -#define RecEngVGui_ViewportPaintBackground(a) (g_engdstAddrs.VGui_ViewportPaintBackground(&a)) -#define RecEngCOM_LoadFile(a, b, c) (g_engdstAddrs.COM_LoadFile(&a, &b, &c)) -#define RecEngCOM_ParseFile(a, b) (g_engdstAddrs.COM_ParseFile(&a, &b)) -#define RecEngCOM_FreeFile(a) (g_engdstAddrs.COM_FreeFile(&a)) -#define RecEngCL_IsSpectateOnly() (g_engdstAddrs.IsSpectateOnly()) -#define RecEngR_LoadMapSprite(a) (g_engdstAddrs.LoadMapSprite(&a)) -#define RecEngCOM_AddAppDirectoryToSearchPath(a, b) (g_engdstAddrs.COM_AddAppDirectoryToSearchPath(&a, &b)) -#define RecEngClientDLL_ExpandFileName(a, b, c) (g_engdstAddrs.COM_ExpandFilename(&a, &b, &c)) -#define RecEngPlayerInfo_ValueForKey(a, b) (g_engdstAddrs.PlayerInfo_ValueForKey(&a, &b)) -#define RecEngPlayerInfo_SetValueForKey(a, b) (g_engdstAddrs.PlayerInfo_SetValueForKey(&a, &b)) -#define RecEngGetPlayerUniqueID(a, b) (g_engdstAddrs.GetPlayerUniqueID(&a, &b)) -#define RecEngGetTrackerIDForPlayer(a) (g_engdstAddrs.GetTrackerIDForPlayer(&a)) -#define RecEngGetPlayerForTrackerID(a) (g_engdstAddrs.GetPlayerForTrackerID(&a)) -#define RecEnghudServerCmdUnreliable(a) (g_engdstAddrs.pfnServerCmdUnreliable(&a)) -#define RecEngGetMousePos(a) (g_engdstAddrs.pfnGetMousePos(&a)) -#define RecEngSetMousePos(a, b) (g_engdstAddrs.pfnSetMousePos(&a, &b)) -#define RecEngSetMouseEnable(a) (g_engdstAddrs.pfnSetMouseEnable(&a)) -#define RecEngSetFilterMode(a) (g_engdstAddrs.pfnSetFilterMode(&a)) -#define RecEngSetFilterColor(a,b,c) (g_engdstAddrs.pfnSetFilterColor(&a,&b,&c)) -#define RecEngSetFilterBrightness(a) (g_engdstAddrs.pfnSetFilterBrightness(&a)) -#define RecEngSequenceGet(a,b) (g_engdstAddrs.pfnSequenceGet(&a,&b)) -#define RecEngSPR_DrawGeneric(a,b,c,d,e,f,g,h) (g_engdstAddrs.pfnSPR_DrawGeneric(&a, &b, &c, &d, &e, &f, &g, &h)) -#define RecEngSequencePickSentence(a,b,c) (g_engdstAddrs.pfnSequencePickSentence(&a, &b, &c)) -#define RecEngLocalPlayerInfo_ValueForKey(a) (g_engdstAddrs.LocalPlayerInfo_ValueForKey(&a)) -#define RecEngProcessTutorMessageDecayBuffer(a, b) (g_engdstAddrs.pfnProcessTutorMessageDecayBuffer(&a, &b)) -#define RecEngConstructTutorMessageDecayBuffer(a, b) (g_engdstAddrs.pfnConstructTutorMessageDecayBuffer(&a, &b)) -#define RecEngResetTutorMessageDecayBuffer() (g_engdstAddrs.pfnResetTutorMessageDecayBuffer()) -#define RecEngDraw_FillRGBABlend(a, b, c, d, e, f, g, h) (g_engdstAddrs.pfnFillRGBABlend(&a, &b, &c, &d, &e, &f, &g, &h)) - -// Dummy destination function for use when there's no security module -extern void NullDst(void); - -// Use this to init an engdst structure to point to NullDst -#define k_engdstNull \ -{ \ - (pfnEngDst_pfnSPR_Load_t) NullDst, \ - (pfnEngDst_pfnSPR_Frames_t) NullDst, \ - (pfnEngDst_pfnSPR_Height_t) NullDst, \ - (pfnEngDst_pfnSPR_Width_t) NullDst, \ - (pfnEngDst_pfnSPR_Set_t) NullDst, \ - (pfnEngDst_pfnSPR_Draw_t) NullDst, \ - (pfnEngDst_pfnSPR_DrawHoles_t) NullDst, \ - (pfnEngDst_pfnSPR_DrawAdditive_t) NullDst, \ - (pfnEngDst_pfnSPR_EnableScissor_t) NullDst, \ - (pfnEngDst_pfnSPR_DisableScissor_t) NullDst, \ - (pfnEngDst_pfnSPR_GetList_t) NullDst, \ - (pfnEngDst_pfnFillRGBA_t) NullDst, \ - (pfnEngDst_pfnGetScreenInfo_t) NullDst, \ - (pfnEngDst_pfnSetCrosshair_t) NullDst, \ - (pfnEngDst_pfnRegisterVariable_t) NullDst, \ - (pfnEngDst_pfnGetCvarFloat_t) NullDst, \ - (pfnEngDst_pfnGetCvarString_t) NullDst, \ - (pfnEngDst_pfnAddCommand_t) NullDst, \ - (pfnEngDst_pfnHookUserMsg_t) NullDst, \ - (pfnEngDst_pfnServerCmd_t) NullDst, \ - (pfnEngDst_pfnClientCmd_t) NullDst, \ - (pfnEngDst_pfnGetPlayerInfo_t) NullDst, \ - (pfnEngDst_pfnPlaySoundByName_t) NullDst, \ - (pfnEngDst_pfnPlaySoundByIndex_t) NullDst, \ - (pfnEngDst_pfnAngleVectors_t) NullDst, \ - (pfnEngDst_pfnTextMessageGet_t) NullDst, \ - (pfnEngDst_pfnDrawCharacter_t) NullDst, \ - (pfnEngDst_pfnDrawConsoleString_t) NullDst, \ - (pfnEngDst_pfnDrawSetTextColor_t) NullDst, \ - (pfnEngDst_pfnDrawConsoleStringLen_t) NullDst, \ - (pfnEngDst_pfnConsolePrint_t) NullDst, \ - (pfnEngDst_pfnCenterPrint_t) NullDst, \ - (pfnEngDst_GetWindowCenterX_t) NullDst, \ - (pfnEngDst_GetWindowCenterY_t) NullDst, \ - (pfnEngDst_GetViewAngles_t) NullDst, \ - (pfnEngDst_SetViewAngles_t) NullDst, \ - (pfnEngDst_GetMaxClients_t) NullDst, \ - (pfnEngDst_Cvar_SetValue_t) NullDst, \ - (pfnEngDst_Cmd_Argc_t) NullDst, \ - (pfnEngDst_Cmd_Argv_t) NullDst, \ - (pfnEngDst_Con_Printf_t) NullDst, \ - (pfnEngDst_Con_DPrintf_t) NullDst, \ - (pfnEngDst_Con_NPrintf_t) NullDst, \ - (pfnEngDst_Con_NXPrintf_t) NullDst, \ - (pfnEngDst_PhysInfo_ValueForKey_t) NullDst, \ - (pfnEngDst_ServerInfo_ValueForKey_t) NullDst, \ - (pfnEngDst_GetClientMaxspeed_t) NullDst, \ - (pfnEngDst_CheckParm_t) NullDst, \ - (pfnEngDst_Key_Event_t) NullDst, \ - (pfnEngDst_GetMousePosition_t) NullDst, \ - (pfnEngDst_IsNoClipping_t) NullDst, \ - (pfnEngDst_GetLocalPlayer_t) NullDst, \ - (pfnEngDst_GetViewModel_t) NullDst, \ - (pfnEngDst_GetEntityByIndex_t) NullDst, \ - (pfnEngDst_GetClientTime_t) NullDst, \ - (pfnEngDst_V_CalcShake_t) NullDst, \ - (pfnEngDst_V_ApplyShake_t) NullDst, \ - (pfnEngDst_PM_PointContents_t) NullDst, \ - (pfnEngDst_PM_WaterEntity_t) NullDst, \ - (pfnEngDst_PM_TraceLine_t) NullDst, \ - (pfnEngDst_CL_LoadModel_t) NullDst, \ - (pfnEngDst_CL_CreateVisibleEntity_t) NullDst, \ - (pfnEngDst_GetSpritePointer_t) NullDst, \ - (pfnEngDst_pfnPlaySoundByNameAtLocation_t) NullDst, \ - (pfnEngDst_pfnPrecacheEvent_t) NullDst, \ - (pfnEngDst_pfnPlaybackEvent_t) NullDst, \ - (pfnEngDst_pfnWeaponAnim_t) NullDst, \ - (pfnEngDst_pfnRandomFloat_t) NullDst, \ - (pfnEngDst_pfnRandomLong_t) NullDst, \ - (pfnEngDst_pfnHookEvent_t) NullDst, \ - (pfnEngDst_Con_IsVisible_t) NullDst, \ - (pfnEngDst_pfnGetGameDirectory_t) NullDst, \ - (pfnEngDst_pfnGetCvarPointer_t) NullDst, \ - (pfnEngDst_Key_LookupBinding_t) NullDst, \ - (pfnEngDst_pfnGetLevelName_t) NullDst, \ - (pfnEngDst_pfnGetScreenFade_t) NullDst, \ - (pfnEngDst_pfnSetScreenFade_t) NullDst, \ - (pfnEngDst_VGui_GetPanel_t) NullDst, \ - (pfnEngDst_VGui_ViewportPaintBackground_t) NullDst, \ - (pfnEngDst_COM_LoadFile_t) NullDst, \ - (pfnEngDst_COM_ParseFile_t) NullDst, \ - (pfnEngDst_COM_FreeFile_t) NullDst, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - NULL, \ - (pfnEngDst_IsSpectateOnly_t) NullDst, \ - (pfnEngDst_LoadMapSprite_t) NullDst, \ - (pfnEngDst_COM_AddAppDirectoryToSearchPath_t) NullDst, \ - (pfnEngDst_COM_ExpandFilename_t) NullDst, \ - (pfnEngDst_PlayerInfo_ValueForKey_t) NullDst, \ - (pfnEngDst_PlayerInfo_SetValueForKey_t) NullDst, \ - (pfnEngDst_GetPlayerUniqueID_t) NullDst, \ - (pfnEngDst_GetTrackerIDForPlayer_t) NullDst, \ - (pfnEngDst_GetPlayerForTrackerID_t) NullDst, \ - (pfnEngDst_pfnServerCmdUnreliable_t) NullDst, \ - (pfnEngDst_GetMousePos_t) NullDst, \ - (pfnEngDst_SetMousePos_t) NullDst, \ - (pfnEngDst_SetMouseEnable_t) NullDst, \ - (pfnEngDst_pfnSetFilterMode_t) NullDst, \ - (pfnEngDst_pfnSetFilterColor_t) NullDst, \ - (pfnEngDst_pfnSetFilterBrightness_t) NullDst, \ - (pfnEngDst_pfnSequenceGet_t) NullDst, \ - (pfnEngDst_pfnSPR_DrawGeneric_t) NullDst, \ - (pfnEngDst_pfnSequencePickSentence_t) NullDst, \ - (pfnEngDst_pfnDrawString_t) NullDst, \ - (pfnEngDst_pfnDrawStringReverse_t) NullDst, \ - (pfnEngDst_LocalPlayerInfo_ValueForKey_t) NullDst, \ - (pfnEngDst_pfnVGUI2DrawCharacter_t) NullDst, \ - (pfnEngDst_pfnVGUI2DrawCharacterAdd_t) NullDst, \ - (pfnEngDst_pfnPlaySoundVoiceByName_t) NullDst, \ - (pfnEngDst_pfnPrimeMusicStream_t) NullDst, \ - (pfnEngDst_pfnProcessTutorMessageDecayBuffer_t) NullDst, \ - (pfnEngDst_pfnConstructTutorMessageDecayBuffer_t) NullDst, \ - (pfnEngDst_pfnResetTutorMessageDecayData_t) NullDst, \ - (pfnEngDst_pfnPlaySoundByNameAtPitch_t) NullDst, \ - (pfnEngDst_pfnFillRGBABlend_t) NullDst, \ - (pfnEngDst_pfnGetAppID_t) NullDst, \ - (pfnEngDst_pfnGetAliases_t) NullDst, \ - (pfnEngDst_pfnVguiWrap2_GetMouseDelta_t) NullDst, \ -}; - -// Use this to init a cldll_func_dst structure to point to NullDst -#define k_cldstNull \ -{ \ - (DST_INITIALIZE_FUNC) NullDst, \ - (DST_HUD_INIT_FUNC) NullDst, \ - (DST_HUD_VIDINIT_FUNC) NullDst, \ - (DST_HUD_REDRAW_FUNC) NullDst, \ - (DST_HUD_UPDATECLIENTDATA_FUNC) NullDst, \ - (DST_HUD_RESET_FUNC) NullDst, \ - (DST_HUD_CLIENTMOVE_FUNC) NullDst, \ - (DST_HUD_CLIENTMOVEINIT_FUNC) NullDst, \ - (DST_HUD_TEXTURETYPE_FUNC) NullDst, \ - (DST_HUD_IN_ACTIVATEMOUSE_FUNC) NullDst, \ - (DST_HUD_IN_DEACTIVATEMOUSE_FUNC) NullDst, \ - (DST_HUD_IN_MOUSEEVENT_FUNC) NullDst, \ - (DST_HUD_IN_CLEARSTATES_FUNC) NullDst, \ - (DST_HUD_IN_ACCUMULATE_FUNC) NullDst, \ - (DST_HUD_CL_CREATEMOVE_FUNC) NullDst, \ - (DST_HUD_CL_ISTHIRDPERSON_FUNC) NullDst, \ - (DST_HUD_CL_GETCAMERAOFFSETS_FUNC) NullDst, \ - (DST_HUD_KB_FIND_FUNC) NullDst, \ - (DST_HUD_CAMTHINK_FUNC) NullDst, \ - (DST_HUD_CALCREF_FUNC) NullDst, \ - (DST_HUD_ADDENTITY_FUNC) NullDst, \ - (DST_HUD_CREATEENTITIES_FUNC) NullDst, \ - (DST_HUD_DRAWNORMALTRIS_FUNC) NullDst, \ - (DST_HUD_DRAWTRANSTRIS_FUNC) NullDst, \ - (DST_HUD_STUDIOEVENT_FUNC) NullDst, \ - (DST_HUD_POSTRUNCMD_FUNC) NullDst, \ - (DST_HUD_SHUTDOWN_FUNC) NullDst, \ - (DST_HUD_TXFERLOCALOVERRIDES_FUNC) NullDst, \ - (DST_HUD_PROCESSPLAYERSTATE_FUNC) NullDst, \ - (DST_HUD_TXFERPREDICTIONDATA_FUNC) NullDst, \ - (DST_HUD_DEMOREAD_FUNC) NullDst, \ - (DST_HUD_CONNECTIONLESS_FUNC) NullDst, \ - (DST_HUD_GETHULLBOUNDS_FUNC) NullDst, \ - (DST_HUD_FRAME_FUNC) NullDst, \ - (DST_HUD_KEY_EVENT_FUNC) NullDst, \ - (DST_HUD_TEMPENTUPDATE_FUNC) NullDst, \ - (DST_HUD_GETUSERENTITY_FUNC) NullDst, \ - (DST_HUD_VOICESTATUS_FUNC) NullDst, \ - (DST_HUD_DIRECTORMESSAGE_FUNC) NullDst, \ - (DST_HUD_STUDIO_INTERFACE_FUNC) NullDst, \ - (DST_HUD_CHATINPUTPOSITION_FUNC) NullDst, \ - (DST_HUD_GETPLAYERTEAM) NullDst, \ -} - -#ifdef __cplusplus -} -#endif - -#endif // CDLL_INT_H - \ No newline at end of file diff --git a/HLSDK/engine/custom.h b/HLSDK/engine/custom.h deleted file mode 100644 index a5a8da9..0000000 --- a/HLSDK/engine/custom.h +++ /dev/null @@ -1,101 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// Customization.h - -#ifndef CUSTOM_H -#define CUSTOM_H -#ifdef _WIN32 -#pragma once -#endif - -#include "const.h" - -#define MAX_QPATH 64 // Must match value in quakedefs.h - -///////////////// -// Customization -// passed to pfnPlayerCustomization -// For automatic downloading. -typedef enum -{ - t_sound = 0, - t_skin, - t_model, - t_decal, - t_generic, - t_eventscript, - t_world, // Fake type for world, is really t_model -} resourcetype_t; - - -typedef struct -{ - int size; -} _resourceinfo_t; - -typedef struct resourceinfo_s -{ - _resourceinfo_t info[ 8 ]; -} resourceinfo_t; - -#define RES_FATALIFMISSING (1<<0) // Disconnect if we can't get this file. -#define RES_WASMISSING (1<<1) // Do we have the file locally, did we get it ok? -#define RES_CUSTOM (1<<2) // Is this resource one that corresponds to another player's customization - // or is it a server startup resource. -#define RES_REQUESTED (1<<3) // Already requested a download of this one -#define RES_PRECACHED (1<<4) // Already precached - -#include "crc.h" - -typedef struct resource_s -{ - char szFileName[MAX_QPATH]; // File name to download/precache. - resourcetype_t type; // t_sound, t_skin, t_model, t_decal. - int nIndex; // For t_decals - int nDownloadSize; // Size in Bytes if this must be downloaded. - unsigned char ucFlags; - -// For handling client to client resource propagation - unsigned char rgucMD5_hash[16]; // To determine if we already have it. - unsigned char playernum; // Which player index this resource is associated with, if it's a custom resource. - - unsigned char rguc_reserved[ 32 ]; // For future expansion - struct resource_s *pNext; // Next in chain. - struct resource_s *pPrev; -} resource_t; - -typedef struct customization_s -{ - qboolean bInUse; // Is this customization in use; - resource_t resource; // The resource_t for this customization - qboolean bTranslated; // Has the raw data been translated into a useable format? - // (e.g., raw decal .wad make into texture_t *) - int nUserData1; // Customization specific data - int nUserData2; // Customization specific data - void *pInfo; // Buffer that holds the data structure that references the data (e.g., the cachewad_t) - void *pBuffer; // Buffer that holds the data for the customization (the raw .wad data) - struct customization_s *pNext; // Next in chain -} customization_t; - -#define FCUST_FROMHPAK ( 1<<0 ) -#define FCUST_WIPEDATA ( 1<<1 ) -#define FCUST_IGNOREINIT ( 1<<2 ) - -void COM_ClearCustomizationList( struct customization_s *pHead, qboolean bCleanDecals); -qboolean COM_CreateCustomization( struct customization_s *pListHead, struct resource_s *pResource, int playernumber, int flags, - struct customization_s **pCustomization, int *nLumps ); -int COM_SizeofResourceList ( struct resource_s *pList, struct resourceinfo_s *ri ); - -#endif // CUSTOM_H diff --git a/HLSDK/engine/customentity.h b/HLSDK/engine/customentity.h deleted file mode 100644 index 2c4eb5e..0000000 --- a/HLSDK/engine/customentity.h +++ /dev/null @@ -1,38 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef CUSTOMENTITY_H -#define CUSTOMENTITY_H - -// Custom Entities - -// Start/End Entity is encoded as 12 bits of entity index, and 4 bits of attachment (4:12) -#define BEAMENT_ENTITY(x) ((x)&0xFFF) -#define BEAMENT_ATTACHMENT(x) (((x)>>12)&0xF) - -// Beam types, encoded as a byte -enum -{ - BEAM_POINTS = 0, - BEAM_ENTPOINT, - BEAM_ENTS, - BEAM_HOSE, -}; - -#define BEAM_FSINE 0x10 -#define BEAM_FSOLID 0x20 -#define BEAM_FSHADEIN 0x40 -#define BEAM_FSHADEOUT 0x80 - -#endif //CUSTOMENTITY_H diff --git a/HLSDK/engine/edict.h b/HLSDK/engine/edict.h deleted file mode 100644 index 6bb109d..0000000 --- a/HLSDK/engine/edict.h +++ /dev/null @@ -1,36 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#if !defined EDICT_H -#define EDICT_H -#ifdef _WIN32 -#pragma once -#endif -#define MAX_ENT_LEAFS 48 - -#include "progdefs.h" - -struct edict_s -{ - qboolean free; - int serialnumber; - link_t area; // linked to a division node or leaf - - int headnode; // -1 to use normal leaf check - int num_leafs; - short leafnums[MAX_ENT_LEAFS]; - - float freetime; // sv.time when the object was freed - - void* pvPrivateData; // Alloced and freed by engine, used by DLLs - - entvars_t v; // C exported fields from progs - - // other fields from progs come immediately after -}; - -#endif diff --git a/HLSDK/engine/eiface.h b/HLSDK/engine/eiface.h deleted file mode 100644 index 7297e03..0000000 --- a/HLSDK/engine/eiface.h +++ /dev/null @@ -1,530 +0,0 @@ -/*** -* -* Copyright (c) 1999, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef EIFACE_H -#define EIFACE_H - -#include "archtypes.h" // DAL - -#ifdef HLDEMO_BUILD -#define INTERFACE_VERSION 001 -#else // !HLDEMO_BUILD, i.e., regular version of HL -#define INTERFACE_VERSION 140 -#endif // !HLDEMO_BUILD - -#include -#include "custom.h" -#include "cvardef.h" -#include "Sequence.h" -// -// Defines entity interface between engine and DLLs. -// This header file included by engine files and DLL files. -// -// Before including this header, DLLs must: -// include progdefs.h -// This is conveniently done for them in extdll.h -// - -#ifdef _WIN32 -#define DLLEXPORT __stdcall -#else -#define DLLEXPORT /* */ -#endif - -typedef enum - { - at_notice, - at_console, // same as at_notice, but forces a ConPrintf, not a message box - at_aiconsole, // same as at_console, but only shown if developer level is 2! - at_warning, - at_error, - at_logged // Server print to console ( only in multiplayer games ). - } ALERT_TYPE; - -// 4-22-98 JOHN: added for use in pfnClientPrintf -typedef enum - { - print_console, - print_center, - print_chat, - } PRINT_TYPE; - -// For integrity checking of content on clients -typedef enum -{ - force_exactfile, // File on client must exactly match server's file - force_model_samebounds, // For model files only, the geometry must fit in the same bbox - force_model_specifybounds, // For model files only, the geometry must fit in the specified bbox - force_model_specifybounds_if_avail, // For Steam model files only, the geometry must fit in the specified bbox (if the file is available) -} FORCE_TYPE; - -// Returned by TraceLine -typedef struct - { - int fAllSolid; // if true, plane is not valid - int fStartSolid; // if true, the initial point was in a solid area - int fInOpen; - int fInWater; - float flFraction; // time completed, 1.0 = didn't hit anything - vec3_t vecEndPos; // final position - float flPlaneDist; - vec3_t vecPlaneNormal; // surface normal at impact - edict_t *pHit; // entity the surface is on - int iHitgroup; // 0 == generic, non zero is specific body part - } TraceResult; - -// CD audio status -typedef struct -{ - int fPlaying;// is sound playing right now? - int fWasPlaying;// if not, CD is paused if WasPlaying is true. - int fInitialized; - int fEnabled; - int fPlayLooping; - float cdvolume; - //BYTE remap[100]; - int fCDRom; - int fPlayTrack; -} CDStatus; - -#include "../common/crc.h" - - -// Engine hands this to DLLs for functionality callbacks -typedef struct enginefuncs_s -{ - int (*pfnPrecacheModel) (char* s); - int (*pfnPrecacheSound) (char* s); - void (*pfnSetModel) (edict_t *e, const char *m); - int (*pfnModelIndex) (const char *m); - int (*pfnModelFrames) (int modelIndex); - void (*pfnSetSize) (edict_t *e, const float *rgflMin, const float *rgflMax); - void (*pfnChangeLevel) (char* s1, char* s2); - void (*pfnGetSpawnParms) (edict_t *ent); - void (*pfnSaveSpawnParms) (edict_t *ent); - float (*pfnVecToYaw) (const float *rgflVector); - void (*pfnVecToAngles) (const float *rgflVectorIn, float *rgflVectorOut); - void (*pfnMoveToOrigin) (edict_t *ent, const float *pflGoal, float dist, int iMoveType); - void (*pfnChangeYaw) (edict_t* ent); - void (*pfnChangePitch) (edict_t* ent); - edict_t* (*pfnFindEntityByString) (edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); - int (*pfnGetEntityIllum) (edict_t* pEnt); - edict_t* (*pfnFindEntityInSphere) (edict_t *pEdictStartSearchAfter, const float *org, float rad); - edict_t* (*pfnFindClientInPVS) (edict_t *pEdict); - edict_t* (*pfnEntitiesInPVS) (edict_t *pplayer); - void (*pfnMakeVectors) (const float *rgflVector); - void (*pfnAngleVectors) (const float *rgflVector, float *forward, float *right, float *up); - edict_t* (*pfnCreateEntity) (void); - void (*pfnRemoveEntity) (edict_t* e); - edict_t* (*pfnCreateNamedEntity) (int className); - void (*pfnMakeStatic) (edict_t *ent); - int (*pfnEntIsOnFloor) (edict_t *e); - int (*pfnDropToFloor) (edict_t* e); - int (*pfnWalkMove) (edict_t *ent, float yaw, float dist, int iMode); - void (*pfnSetOrigin) (edict_t *e, const float *rgflOrigin); - void (*pfnEmitSound) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); - void (*pfnEmitAmbientSound) (edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); - void (*pfnTraceLine) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); - void (*pfnTraceToss) (edict_t* pent, edict_t* pentToIgnore, TraceResult *ptr); - int (*pfnTraceMonsterHull) (edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); - void (*pfnTraceHull) (const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); - void (*pfnTraceModel) (const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); - const char *(*pfnTraceTexture) (edict_t *pTextureEntity, const float *v1, const float *v2 ); - void (*pfnTraceSphere) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); - void (*pfnGetAimVector) (edict_t* ent, float speed, float *rgflReturn); - void (*pfnServerCommand) (char* str); - void (*pfnServerExecute) (void); - void (*pfnClientCommand) (edict_t* pEdict, char* szFmt, ...); - void (*pfnParticleEffect) (const float *org, const float *dir, float color, float count); - void (*pfnLightStyle) (int style, char* val); - int (*pfnDecalIndex) (const char *name); - int (*pfnPointContents) (const float *rgflVector); - void (*pfnMessageBegin) (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); - void (*pfnMessageEnd) (void); - void (*pfnWriteByte) (int iValue); - void (*pfnWriteChar) (int iValue); - void (*pfnWriteShort) (int iValue); - void (*pfnWriteLong) (int iValue); - void (*pfnWriteAngle) (float flValue); - void (*pfnWriteCoord) (float flValue); - void (*pfnWriteString) (const char *sz); - void (*pfnWriteEntity) (int iValue); - void (*pfnCVarRegister) (cvar_t *pCvar); - float (*pfnCVarGetFloat) (const char *szVarName); - const char* (*pfnCVarGetString) (const char *szVarName); - void (*pfnCVarSetFloat) (const char *szVarName, float flValue); - void (*pfnCVarSetString) (const char *szVarName, const char *szValue); - void (*pfnAlertMessage) (ALERT_TYPE atype, char *szFmt, ...); - void (*pfnEngineFprintf) (void *pfile, char *szFmt, ...); - void* (*pfnPvAllocEntPrivateData) (edict_t *pEdict, int32 cb); - void* (*pfnPvEntPrivateData) (edict_t *pEdict); - void (*pfnFreeEntPrivateData) (edict_t *pEdict); - const char* (*pfnSzFromIndex) (int iString); - int (*pfnAllocString) (const char *szValue); - struct entvars_s* (*pfnGetVarsOfEnt) (edict_t *pEdict); - edict_t* (*pfnPEntityOfEntOffset) (int iEntOffset); - int (*pfnEntOffsetOfPEntity) (const edict_t *pEdict); - int (*pfnIndexOfEdict) (const edict_t *pEdict); - edict_t* (*pfnPEntityOfEntIndex) (int iEntIndex); - edict_t* (*pfnFindEntityByVars) (struct entvars_s* pvars); - void* (*pfnGetModelPtr) (edict_t* pEdict); - int (*pfnRegUserMsg) (const char *pszName, int iSize); - void (*pfnAnimationAutomove) (const edict_t* pEdict, float flTime); - void (*pfnGetBonePosition) (const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); - uint32 (*pfnFunctionFromName) ( const char *pName ); - const char *(*pfnNameForFunction) ( uint32 function ); - void (*pfnClientPrintf) ( edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg ); // JOHN: engine callbacks so game DLL can print messages to individual clients - void (*pfnServerPrint) ( const char *szMsg ); - const char *(*pfnCmd_Args) ( void ); // these 3 added - const char *(*pfnCmd_Argv) ( int argc ); // so game DLL can easily - int (*pfnCmd_Argc) ( void ); // access client 'cmd' strings - void (*pfnGetAttachment) (const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); - void (*pfnCRC32_Init) (CRC32_t *pulCRC); - void (*pfnCRC32_ProcessBuffer) (CRC32_t *pulCRC, void *p, int len); - void (*pfnCRC32_ProcessByte) (CRC32_t *pulCRC, unsigned char ch); - CRC32_t (*pfnCRC32_Final) (CRC32_t pulCRC); - int32 (*pfnRandomLong) (int32 lLow, int32 lHigh); - float (*pfnRandomFloat) (float flLow, float flHigh); - void (*pfnSetView) (const edict_t *pClient, const edict_t *pViewent ); - float (*pfnTime) ( void ); - void (*pfnCrosshairAngle) (const edict_t *pClient, float pitch, float yaw); - byte * (*pfnLoadFileForMe) (char *filename, int *pLength); - void (*pfnFreeFile) (void *buffer); - void (*pfnEndSection) (const char *pszSectionName); // trigger_endsection - int (*pfnCompareFileTime) (char *filename1, char *filename2, int *iCompare); - void (*pfnGetGameDir) (char *szGetGameDir); - void (*pfnCvar_RegisterVariable) (cvar_t *variable); - void (*pfnFadeClientVolume) (const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); - void (*pfnSetClientMaxspeed) (const edict_t *pEdict, float fNewMaxspeed); - edict_t * (*pfnCreateFakeClient) (const char *netname); // returns NULL if fake client can't be created - void (*pfnRunPlayerMove) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); - int (*pfnNumberOfEntities) (void); - char* (*pfnGetInfoKeyBuffer) (edict_t *e); // passing in NULL gets the serverinfo - char* (*pfnInfoKeyValue) (char *infobuffer, char *key); - void (*pfnSetKeyValue) (char *infobuffer, char *key, char *value); - void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, char *key, char *value); - int (*pfnIsMapValid) (char *filename); - void (*pfnStaticDecal) ( const float *origin, int decalIndex, int entityIndex, int modelIndex ); - int (*pfnPrecacheGeneric) (char* s); - int (*pfnGetPlayerUserId) (edict_t *e ); // returns the server assigned userid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients - void (*pfnBuildSoundMsg) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); - int (*pfnIsDedicatedServer) (void);// is this a dedicated server? - cvar_t *(*pfnCVarGetPointer) (const char *szVarName); - unsigned int (*pfnGetPlayerWONId) (edict_t *e); // returns the server assigned WONid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients - - // YWB 8/1/99 TFF Physics additions - void (*pfnInfo_RemoveKey) ( char *s, const char *key ); - const char *(*pfnGetPhysicsKeyValue) ( const edict_t *pClient, const char *key ); - void (*pfnSetPhysicsKeyValue) ( const edict_t *pClient, const char *key, const char *value ); - const char *(*pfnGetPhysicsInfoString) ( const edict_t *pClient ); - unsigned short (*pfnPrecacheEvent) ( int type, const char*psz ); - void (*pfnPlaybackEvent) ( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); - - unsigned char *(*pfnSetFatPVS) ( float *org ); - unsigned char *(*pfnSetFatPAS) ( float *org ); - - int (*pfnCheckVisibility ) ( const edict_t *entity, unsigned char *pset ); - - void (*pfnDeltaSetField) ( struct delta_s *pFields, const char *fieldname ); - void (*pfnDeltaUnsetField) ( struct delta_s *pFields, const char *fieldname ); - void (*pfnDeltaAddEncoder) ( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); - int (*pfnGetCurrentPlayer) ( void ); - int (*pfnCanSkipPlayer) ( const edict_t *player ); - int (*pfnDeltaFindField) ( struct delta_s *pFields, const char *fieldname ); - void (*pfnDeltaSetFieldByIndex) ( struct delta_s *pFields, int fieldNumber ); - void (*pfnDeltaUnsetFieldByIndex)( struct delta_s *pFields, int fieldNumber ); - - void (*pfnSetGroupMask) ( int mask, int op ); - - int (*pfnCreateInstancedBaseline) ( int classname, struct entity_state_s *baseline ); - void (*pfnCvar_DirectSet) ( struct cvar_s *var, char *value ); - - // Forces the client and server to be running with the same version of the specified file - // ( e.g., a player model ). - // Calling this has no effect in single player - void (*pfnForceUnmodified) ( FORCE_TYPE type, float *mins, float *maxs, const char *filename ); - - void (*pfnGetPlayerStats) ( const edict_t *pClient, int *ping, int *packet_loss ); - - void (*pfnAddServerCommand) ( char *cmd_name, void (*function) (void) ); - - // For voice communications, set which clients hear eachother. - // NOTE: these functions take player entity indices (starting at 1). - qboolean (*pfnVoice_GetClientListening)(int iReceiver, int iSender); - qboolean (*pfnVoice_SetClientListening)(int iReceiver, int iSender, qboolean bListen); - - const char *(*pfnGetPlayerAuthId) ( edict_t *e ); - - // PSV: Added for CZ training map -// const char *(*pfnKeyNameForBinding) ( const char* pBinding ); - - sequenceEntry_s* (*pfnSequenceGet) ( const char* fileName, const char* entryName ); - sentenceEntry_s* (*pfnSequencePickSentence) ( const char* groupName, int pickMethod, int *picked ); - - // LH: Give access to filesize via filesystem - int (*pfnGetFileSize) ( char *filename ); - - unsigned int (*pfnGetApproxWavePlayLen) (const char *filepath); - // MDC: Added for CZ career-mode - int (*pfnIsCareerMatch) ( void ); - - // BGC: return the number of characters of the localized string referenced by using "label" - int (*pfnGetLocalizedStringLength) (const char *label); - - // BGC: added to facilitate persistent storage of tutor message decay values for - // different career game profiles. Also needs to persist regardless of mp.dll being - // destroyed and recreated. - void (*pfnRegisterTutorMessageShown) (int mid); - int (*pfnGetTimesTutorMessageShown) (int mid); - void (*pfnProcessTutorMessageDecayBuffer) (int *buffer, int bufferLength); - void (*pfnConstructTutorMessageDecayBuffer) (int *buffer, int bufferLength); - void (*pfnResetTutorMessageDecayData) ( void ); - void (*pfnQueryClientCvarValue) ( const edict_t *player, const char *cvarName ); - void (*pfnQueryClientCvarValue2) ( const edict_t *player, const char *cvarName, int requestID ); -} enginefuncs_t; - - -// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 138 - -// Passed to pfnKeyValue -typedef struct KeyValueData_s -{ - char *szClassName; // in: entity classname - char *szKeyName; // in: name of key - char *szValue; // in: value of key - int32 fHandled; // out: DLL sets to true if key-value pair was understood -} KeyValueData; - - -typedef struct -{ - char mapName[ 32 ]; - char landmarkName[ 32 ]; - edict_t *pentLandmark; - vec3_t vecLandmarkOrigin; -} LEVELLIST; -#define MAX_LEVEL_CONNECTIONS 16 // These are encoded in the lower 16bits of ENTITYTABLE->flags - -typedef struct -{ - int id; // Ordinal ID of this entity (used for entity <--> pointer conversions) - edict_t *pent; // Pointer to the in-game entity - - int location; // Offset from the base data of this entity - int size; // Byte size of this entity's data - int flags; // This could be a short -- bit mask of transitions that this entity is in the PVS of - string_t classname; // entity class name - -} ENTITYTABLE; - -#define FENTTABLE_PLAYER 0x80000000 -#define FENTTABLE_REMOVED 0x40000000 -#define FENTTABLE_MOVEABLE 0x20000000 -#define FENTTABLE_GLOBAL 0x10000000 - -typedef struct saverestore_s SAVERESTOREDATA; - -#ifdef _WIN32 -typedef -#endif -struct saverestore_s -{ - char *pBaseData; // Start of all entity save data - char *pCurrentData; // Current buffer pointer for sequential access - int size; // Current data size - int bufferSize; // Total space for data - int tokenSize; // Size of the linear list of tokens - int tokenCount; // Number of elements in the pTokens table - char **pTokens; // Hash table of entity strings (sparse) - int currentIndex; // Holds a global entity table ID - int tableCount; // Number of elements in the entity table - int connectionCount;// Number of elements in the levelList[] - ENTITYTABLE *pTable; // Array of ENTITYTABLE elements (1 for each entity) - LEVELLIST levelList[ MAX_LEVEL_CONNECTIONS ]; // List of connections from this level - - // smooth transition - int fUseLandmark; - char szLandmarkName[20];// landmark we'll spawn near in next level - vec3_t vecLandmarkOffset;// for landmark transitions - float time; - char szCurrentMapName[32]; // To check global entities - -} -#ifdef _WIN32 -SAVERESTOREDATA -#endif -; - -typedef enum _fieldtypes -{ - FIELD_FLOAT = 0, // Any floating point value - FIELD_STRING, // A string ID (return from ALLOC_STRING) - FIELD_ENTITY, // An entity offset (EOFFSET) - FIELD_CLASSPTR, // CBaseEntity * - FIELD_EHANDLE, // Entity handle - FIELD_EVARS, // EVARS * - FIELD_EDICT, // edict_t *, or edict_t * (same thing) - FIELD_VECTOR, // Any vector - FIELD_POSITION_VECTOR, // A world coordinate (these are fixed up across level transitions automagically) - FIELD_POINTER, // Arbitrary data pointer... to be removed, use an array of FIELD_CHARACTER - FIELD_INTEGER, // Any integer or enum - FIELD_FUNCTION, // A class function pointer (Think, Use, etc) - FIELD_BOOLEAN, // boolean, implemented as an int, I may use this as a hint for compression - FIELD_SHORT, // 2 byte integer - FIELD_CHARACTER, // a byte - FIELD_TIME, // a floating point time (these are fixed up automatically too!) - FIELD_MODELNAME, // Engine string that is a model name (needs precache) - FIELD_SOUNDNAME, // Engine string that is a sound name (needs precache) - - FIELD_TYPECOUNT, // MUST BE LAST -} FIELDTYPE; - -#ifndef offsetof -#define offsetof(s,m) (size_t)&(((s *)0)->m) -#endif - -#define _FIELD(type,name,fieldtype,count,flags) { fieldtype, #name, offsetof(type, name), count, flags } -#define DEFINE_FIELD(type,name,fieldtype) _FIELD(type, name, fieldtype, 1, 0) -#define DEFINE_ARRAY(type,name,fieldtype,count) _FIELD(type, name, fieldtype, count, 0) -#define DEFINE_ENTITY_FIELD(name,fieldtype) _FIELD(entvars_t, name, fieldtype, 1, 0 ) -#define DEFINE_ENTITY_GLOBAL_FIELD(name,fieldtype) _FIELD(entvars_t, name, fieldtype, 1, FTYPEDESC_GLOBAL ) -#define DEFINE_GLOBAL_FIELD(type,name,fieldtype) _FIELD(type, name, fieldtype, 1, FTYPEDESC_GLOBAL ) - - -#define FTYPEDESC_GLOBAL 0x0001 // This field is masked for global entity save/restore - -typedef struct -{ - FIELDTYPE fieldType; - char *fieldName; - int fieldOffset; - short fieldSize; - short flags; -} TYPEDESCRIPTION; - -// Fix warning in MSVC8 -#undef ARRAYSIZE -#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) - -typedef struct -{ - // Initialize/shutdown the game (one-time call after loading of game .dll ) - void (*pfnGameInit) ( void ); - int (*pfnSpawn) ( edict_t *pent ); - void (*pfnThink) ( edict_t *pent ); - void (*pfnUse) ( edict_t *pentUsed, edict_t *pentOther ); - void (*pfnTouch) ( edict_t *pentTouched, edict_t *pentOther ); - void (*pfnBlocked) ( edict_t *pentBlocked, edict_t *pentOther ); - void (*pfnKeyValue) ( edict_t *pentKeyvalue, KeyValueData *pkvd ); - void (*pfnSave) ( edict_t *pent, SAVERESTOREDATA *pSaveData ); - int (*pfnRestore) ( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); - void (*pfnSetAbsBox) ( edict_t *pent ); - - void (*pfnSaveWriteFields) ( SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int ); - void (*pfnSaveReadFields) ( SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int ); - - void (*pfnSaveGlobalState) ( SAVERESTOREDATA * ); - void (*pfnRestoreGlobalState) ( SAVERESTOREDATA * ); - void (*pfnResetGlobalState) ( void ); - - qboolean (*pfnClientConnect) ( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); - - void (*pfnClientDisconnect) ( edict_t *pEntity ); - void (*pfnClientKill) ( edict_t *pEntity ); - void (*pfnClientPutInServer) ( edict_t *pEntity ); - void (*pfnClientCommand) ( edict_t *pEntity ); - void (*pfnClientUserInfoChanged)( edict_t *pEntity, char *infobuffer ); - - void (*pfnServerActivate) ( edict_t *pEdictList, int edictCount, int clientMax ); - void (*pfnServerDeactivate) ( void ); - - void (*pfnPlayerPreThink) ( edict_t *pEntity ); - void (*pfnPlayerPostThink) ( edict_t *pEntity ); - - void (*pfnStartFrame) ( void ); - void (*pfnParmsNewLevel) ( void ); - void (*pfnParmsChangeLevel) ( void ); - - // Returns string describing current .dll. E.g., TeamFotrress 2, Half-Life - const char *(*pfnGetGameDescription)( void ); - - // Notify dll about a player customization. - void (*pfnPlayerCustomization) ( edict_t *pEntity, customization_t *pCustom ); - - // Spectator funcs - void (*pfnSpectatorConnect) ( edict_t *pEntity ); - void (*pfnSpectatorDisconnect) ( edict_t *pEntity ); - void (*pfnSpectatorThink) ( edict_t *pEntity ); - - // Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. - void (*pfnSys_Error) ( const char *error_string ); - - void (*pfnPM_Move) ( struct playermove_s *ppmove, qboolean server ); - void (*pfnPM_Init) ( struct playermove_s *ppmove ); - char (*pfnPM_FindTextureType)( char *name ); - void (*pfnSetupVisibility)( struct edict_s *pViewEntity, struct edict_s *pClient, unsigned char **pvs, unsigned char **pas ); - void (*pfnUpdateClientData) ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); - int (*pfnAddToFullPack)( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); - void (*pfnCreateBaseline) ( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); - void (*pfnRegisterEncoders) ( void ); - int (*pfnGetWeaponData) ( struct edict_s *player, struct weapon_data_s *info ); - - void (*pfnCmdStart) ( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); - void (*pfnCmdEnd) ( const edict_t *player ); - - // Return 1 if the packet is valid. Set response_buffer_size if you want to send a response packet. Incoming, it holds the max - // size of the response_buffer, so you must zero it out if you choose not to respond. - int (*pfnConnectionlessPacket ) ( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); - - // Enumerates player hulls. Returns 0 if the hull number doesn't exist, 1 otherwise - int (*pfnGetHullBounds) ( int hullnumber, float *mins, float *maxs ); - - // Create baselines for certain "unplaced" items. - void (*pfnCreateInstancedBaselines) ( void ); - - // One of the pfnForceUnmodified files failed the consistency check for the specified player - // Return 0 to allow the client to continue, 1 to force immediate disconnection ( with an optional disconnect message of up to 256 characters ) - int (*pfnInconsistentFile)( const struct edict_s *player, const char *filename, char *disconnect_message ); - - // The game .dll should return 1 if lag compensation should be allowed ( could also just set - // the sv_unlag cvar. - // Most games right now should return 0, until client-side weapon prediction code is written - // and tested for them. - int (*pfnAllowLagCompensation)( void ); -} DLL_FUNCTIONS; - -extern DLL_FUNCTIONS gEntityInterface; - -// Current version. -#define NEW_DLL_FUNCTIONS_VERSION 1 - -typedef struct -{ - // Called right before the object's memory is freed. - // Calls its destructor. - void (*pfnOnFreeEntPrivateData)(edict_t *pEnt); - void (*pfnGameShutdown)(void); - int (*pfnShouldCollide)( edict_t *pentTouched, edict_t *pentOther ); - void (*pfnCvarValue)( const edict_t *pEnt, const char *value ); - void (*pfnCvarValue2)( const edict_t *pEnt, int requestID, const char *cvarName, const char *value ); -} NEW_DLL_FUNCTIONS; -typedef int (*NEW_DLL_FUNCTIONS_FN)( NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ); - -// Pointers will be null if the game DLL doesn't support this API. -extern NEW_DLL_FUNCTIONS gNewDLLFunctions; - -typedef int (*APIFUNCTION)( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion ); -typedef int (*APIFUNCTION2)( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ); - -#endif /* EIFACE_H */ diff --git a/HLSDK/engine/keydefs.h b/HLSDK/engine/keydefs.h deleted file mode 100644 index aca2c09..0000000 --- a/HLSDK/engine/keydefs.h +++ /dev/null @@ -1,129 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// keydefs.h -#ifndef KEYDEFS_H -#define KEYDEFS_H -#ifdef _WIN32 -#pragma once -#endif - -// -// these are the key numbers that should be passed to Key_Event -// -#define K_TAB 9 -#define K_ENTER 13 -#define K_ESCAPE 27 -#define K_SPACE 32 - -// normal keys should be passed as lowercased ascii - -#define K_BACKSPACE 127 -#define K_UPARROW 128 -#define K_DOWNARROW 129 -#define K_LEFTARROW 130 -#define K_RIGHTARROW 131 - -#define K_ALT 132 -#define K_CTRL 133 -#define K_SHIFT 134 -#define K_F1 135 -#define K_F2 136 -#define K_F3 137 -#define K_F4 138 -#define K_F5 139 -#define K_F6 140 -#define K_F7 141 -#define K_F8 142 -#define K_F9 143 -#define K_F10 144 -#define K_F11 145 -#define K_F12 146 -#define K_INS 147 -#define K_DEL 148 -#define K_PGDN 149 -#define K_PGUP 150 -#define K_HOME 151 -#define K_END 152 - -#define K_KP_HOME 160 -#define K_KP_UPARROW 161 -#define K_KP_PGUP 162 -#define K_KP_LEFTARROW 163 -#define K_KP_5 164 -#define K_KP_RIGHTARROW 165 -#define K_KP_END 166 -#define K_KP_DOWNARROW 167 -#define K_KP_PGDN 168 -#define K_KP_ENTER 169 -#define K_KP_INS 170 -#define K_KP_DEL 171 -#define K_KP_SLASH 172 -#define K_KP_MINUS 173 -#define K_KP_PLUS 174 -#define K_CAPSLOCK 175 - - -// -// joystick buttons -// -#define K_JOY1 203 -#define K_JOY2 204 -#define K_JOY3 205 -#define K_JOY4 206 - -// -// aux keys are for multi-buttoned joysticks to generate so they can use -// the normal binding process -// -#define K_AUX1 207 -#define K_AUX2 208 -#define K_AUX3 209 -#define K_AUX4 210 -#define K_AUX5 211 -#define K_AUX6 212 -#define K_AUX7 213 -#define K_AUX8 214 -#define K_AUX9 215 -#define K_AUX10 216 -#define K_AUX11 217 -#define K_AUX12 218 -#define K_AUX13 219 -#define K_AUX14 220 -#define K_AUX15 221 -#define K_AUX16 222 -#define K_AUX17 223 -#define K_AUX18 224 -#define K_AUX19 225 -#define K_AUX20 226 -#define K_AUX21 227 -#define K_AUX22 228 -#define K_AUX23 229 -#define K_AUX24 230 -#define K_AUX25 231 -#define K_AUX26 232 -#define K_AUX27 233 -#define K_AUX28 234 -#define K_AUX29 235 -#define K_AUX30 236 -#define K_AUX31 237 -#define K_AUX32 238 -#define K_MWHEELDOWN 239 -#define K_MWHEELUP 240 - -#define K_PAUSE 255 - -// -// mouse buttons generate virtual keys -// -#define K_MOUSE1 241 -#define K_MOUSE2 242 -#define K_MOUSE3 243 -#define K_MOUSE4 244 -#define K_MOUSE5 245 - -#endif // KEYDEFS_H diff --git a/HLSDK/engine/progdefs.h b/HLSDK/engine/progdefs.h deleted file mode 100644 index b8c58ad..0000000 --- a/HLSDK/engine/progdefs.h +++ /dev/null @@ -1,224 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef PROGDEFS_H -#define PROGDEFS_H -#ifdef _WIN32 -#pragma once -#endif - -typedef struct -{ - float time; - float frametime; - float force_retouch; - string_t mapname; - string_t startspot; - float deathmatch; - float coop; - float teamplay; - float serverflags; - float found_secrets; - vec3_t v_forward; - vec3_t v_up; - vec3_t v_right; - float trace_allsolid; - float trace_startsolid; - float trace_fraction; - vec3_t trace_endpos; - vec3_t trace_plane_normal; - float trace_plane_dist; - edict_t *trace_ent; - float trace_inopen; - float trace_inwater; - int trace_hitgroup; - int trace_flags; - int msg_entity; - int cdAudioTrack; - int maxClients; - int maxEntities; - const char *pStringBase; - - void *pSaveData; - vec3_t vecLandmarkOffset; -} globalvars_t; - - -typedef struct entvars_s -{ - string_t classname; - string_t globalname; - - vec3_t origin; - vec3_t oldorigin; - vec3_t velocity; - vec3_t basevelocity; - vec3_t clbasevelocity; // Base velocity that was passed in to server physics so - // client can predict conveyors correctly. Server zeroes it, so we need to store here, too. - vec3_t movedir; - - vec3_t angles; // Model angles - vec3_t avelocity; // angle velocity (degrees per second) - vec3_t punchangle; // auto-decaying view angle adjustment - vec3_t v_angle; // Viewing angle (player only) - - // For parametric entities - vec3_t endpos; - vec3_t startpos; - float impacttime; - float starttime; - - int fixangle; // 0:nothing, 1:force view angles, 2:add avelocity - float idealpitch; - float pitch_speed; - float ideal_yaw; - float yaw_speed; - - int modelindex; - string_t model; - - int viewmodel; // player's viewmodel - int weaponmodel; // what other players see - - vec3_t absmin; // BB max translated to world coord - vec3_t absmax; // BB max translated to world coord - vec3_t mins; // local BB min - vec3_t maxs; // local BB max - vec3_t size; // maxs - mins - - float ltime; - float nextthink; - - int movetype; - int solid; - - int skin; - int body; // sub-model selection for studiomodels - int effects; - - float gravity; // % of "normal" gravity - float friction; // inverse elasticity of MOVETYPE_BOUNCE - - int light_level; - - int sequence; // animation sequence - int gaitsequence; // movement animation sequence for player (0 for none) - float frame; // % playback position in animation sequences (0..255) - float animtime; // world time when frame was set - float framerate; // animation playback rate (-8x to 8x) - byte controller[4]; // bone controller setting (0..255) - byte blending[2]; // blending amount between sub-sequences (0..255) - - float scale; // sprite rendering scale (0..255) - - int rendermode; - float renderamt; - vec3_t rendercolor; - int renderfx; - - float health; - float frags; - int weapons; // bit mask for available weapons - float takedamage; - - int deadflag; - vec3_t view_ofs; // eye position - - int button; - int impulse; - - edict_t *chain; // Entity pointer when linked into a linked list - edict_t *dmg_inflictor; - edict_t *enemy; - edict_t *aiment; // entity pointer when MOVETYPE_FOLLOW - edict_t *owner; - edict_t *groundentity; - - int spawnflags; - int flags; - - int colormap; // lowbyte topcolor, highbyte bottomcolor - int team; - - float max_health; - float teleport_time; - float armortype; - float armorvalue; - int waterlevel; - int watertype; - - string_t target; - string_t targetname; - string_t netname; - string_t message; - - float dmg_take; - float dmg_save; - float dmg; - float dmgtime; - - string_t noise; - string_t noise1; - string_t noise2; - string_t noise3; - - float speed; - float air_finished; - float pain_finished; - float radsuit_finished; - - edict_t *pContainingEntity; - - int playerclass; - float maxspeed; - - float fov; - int weaponanim; - - int pushmsec; - - int bInDuck; - int flTimeStepSound; - int flSwimTime; - int flDuckTime; - int iStepLeft; - float flFallVelocity; - - int gamestate; - - int oldbuttons; - - int groupinfo; - - // For mods - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; - edict_t *euser1; - edict_t *euser2; - edict_t *euser3; - edict_t *euser4; -} entvars_t; - - -#endif // PROGDEFS_H \ No newline at end of file diff --git a/HLSDK/engine/progs.h b/HLSDK/engine/progs.h deleted file mode 100644 index 6115fcb..0000000 --- a/HLSDK/engine/progs.h +++ /dev/null @@ -1,82 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef PROGS_H -#define PROGS_H - -#include "progdefs.h" - -// 16 simultaneous events, max -#define MAX_EVENT_QUEUE 64 - -#define DEFAULT_EVENT_RESENDS 1 - -#include "event_flags.h" - -typedef struct event_info_s event_info_t; - -#include "event_args.h" - -struct event_info_s -{ - unsigned short index; // 0 implies not in use - - short packet_index; // Use data from state info for entity in delta_packet . -1 implies separate info based on event - // parameter signature - short entity_index; // The edict this event is associated with - - float fire_time; // if non-zero, the time when the event should be fired ( fixed up on the client ) - - event_args_t args; - -// CLIENT ONLY - int flags; // Reliable or not, etc. - -}; - -typedef struct event_state_s event_state_t; - -struct event_state_s -{ - struct event_info_s ei[ MAX_EVENT_QUEUE ]; -}; - -#if !defined( ENTITY_STATEH ) -#include "entity_state.h" -#endif - -#if !defined( EDICT_H ) -#include "edict.h" -#endif - -#define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m))) -#define EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area) - -//============================================================================ - -extern char *pr_strings; -extern globalvars_t gGlobalVariables; - -//============================================================================ - -edict_t *ED_Alloc (void); -void ED_Free (edict_t *ed); -void ED_LoadFromFile (char *data); - -edict_t *EDICT_NUM(int n); -int NUM_FOR_EDICT(const edict_t *e); - -#define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e)) - -#endif // PROGS_H \ No newline at end of file diff --git a/HLSDK/engine/shake.h b/HLSDK/engine/shake.h deleted file mode 100644 index 8e405db..0000000 --- a/HLSDK/engine/shake.h +++ /dev/null @@ -1,55 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef SHAKE_H -#define SHAKE_H - -// Screen / View effects - -// screen shake -extern int gmsgShake; - -// This structure is sent over the net to describe a screen shake event -typedef struct -{ - unsigned short amplitude; // FIXED 4.12 amount of shake - unsigned short duration; // FIXED 4.12 seconds duration - unsigned short frequency; // FIXED 8.8 noise frequency (low frequency is a jerk,high frequency is a rumble) -} ScreenShake; - -extern void V_ApplyShake( float *origin, float *angles, float factor ); -extern void V_CalcShake( void ); -extern int V_ScreenShake( const char *pszName, int iSize, void *pbuf ); -extern int V_ScreenFade( const char *pszName, int iSize, void *pbuf ); - - -// Fade in/out -extern int gmsgFade; - -#define FFADE_IN 0x0000 // Just here so we don't pass 0 into the function -#define FFADE_OUT 0x0001 // Fade out (not in) -#define FFADE_MODULATE 0x0002 // Modulate (don't blend) -#define FFADE_STAYOUT 0x0004 // ignores the duration, stays faded out until new ScreenFade message received - -// This structure is sent over the net to describe a screen fade event -typedef struct -{ - unsigned short duration; // FIXED 4.12 seconds duration - unsigned short holdTime; // FIXED 4.12 seconds duration until reset (fade & hold) - short fadeFlags; // flags - byte r, g, b, a; // fade to color ( max alpha ) -} ScreenFade; - -#endif // SHAKE_H - diff --git a/HLSDK/engine/studio.h b/HLSDK/engine/studio.h deleted file mode 100644 index 62d4a98..0000000 --- a/HLSDK/engine/studio.h +++ /dev/null @@ -1,362 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - - - - -#ifndef _STUDIO_H_ -#define _STUDIO_H_ - -/* -============================================================================== - -STUDIO MODELS - -Studio models are position independent, so the cache manager can move them. -============================================================================== -*/ - - -#define MAXSTUDIOTRIANGLES 20000 // TODO: tune this -#define MAXSTUDIOVERTS 2048 // TODO: tune this -#define MAXSTUDIOSEQUENCES 256 // total animation sequences -#define MAXSTUDIOSKINS 100 // total textures -#define MAXSTUDIOSRCBONES 512 // bones allowed at source movement -#define MAXSTUDIOBONES 128 // total bones actually used -#define MAXSTUDIOMODELS 32 // sub-models per model -#define MAXSTUDIOBODYPARTS 32 -#define MAXSTUDIOGROUPS 16 -#define MAXSTUDIOANIMATIONS 512 // per sequence -#define MAXSTUDIOMESHES 256 -#define MAXSTUDIOEVENTS 1024 -#define MAXSTUDIOPIVOTS 256 -#define MAXSTUDIOCONTROLLERS 8 - -typedef struct -{ - int id; - int version; - - char name[64]; - int length; - - vec3_t eyeposition; // ideal eye position - vec3_t min; // ideal movement hull size - vec3_t max; - - vec3_t bbmin; // clipping bounding box - vec3_t bbmax; - - int flags; - - int numbones; // bones - int boneindex; - - int numbonecontrollers; // bone controllers - int bonecontrollerindex; - - int numhitboxes; // complex bounding boxes - int hitboxindex; - - int numseq; // animation sequences - int seqindex; - - int numseqgroups; // demand loaded sequences - int seqgroupindex; - - int numtextures; // raw textures - int textureindex; - int texturedataindex; - - int numskinref; // replaceable textures - int numskinfamilies; - int skinindex; - - int numbodyparts; - int bodypartindex; - - int numattachments; // queryable attachable points - int attachmentindex; - - int soundtable; - int soundindex; - int soundgroups; - int soundgroupindex; - - int numtransitions; // animation node to animation node transition graph - int transitionindex; -} studiohdr_t; - -// header for demand loaded sequence group data -typedef struct -{ - int id; - int version; - - char name[64]; - int length; -} studioseqhdr_t; - -// bones -typedef struct -{ - char name[32]; // bone name for symbolic links - int parent; // parent bone - int flags; // ?? - int bonecontroller[6]; // bone controller index, -1 == none - float value[6]; // default DoF values - float scale[6]; // scale for delta DoF values -} mstudiobone_t; - - -// bone controllers -typedef struct -{ - int bone; // -1 == 0 - int type; // X, Y, Z, XR, YR, ZR, M - float start; - float end; - int rest; // byte index value at rest - int index; // 0-3 user set controller, 4 mouth -} mstudiobonecontroller_t; - -// intersection boxes -typedef struct -{ - int bone; - int group; // intersection group - vec3_t bbmin; // bounding box - vec3_t bbmax; -} mstudiobbox_t; - -#if !defined( CACHE_USER ) && !defined( QUAKEDEF_H ) -#define CACHE_USER -typedef struct cache_user_s -{ - void *data; -} cache_user_t; -#endif - -// demand loaded sequence groups -typedef struct -{ - char label[32]; // textual name - char name[64]; // file name - cache_user_t cache; // cache index pointer - int data; // hack for group 0 -} mstudioseqgroup_t; - -// sequence descriptions -typedef struct -{ - char label[32]; // sequence label - - float fps; // frames per second - int flags; // looping/non-looping flags - - int activity; - int actweight; - - int numevents; - int eventindex; - - int numframes; // number of frames per sequence - - int numpivots; // number of foot pivots - int pivotindex; - - int motiontype; - int motionbone; - vec3_t linearmovement; - int automoveposindex; - int automoveangleindex; - - vec3_t bbmin; // per sequence bounding box - vec3_t bbmax; - - int numblends; - int animindex; // mstudioanim_t pointer relative to start of sequence group data - // [blend][bone][X, Y, Z, XR, YR, ZR] - - int blendtype[2]; // X, Y, Z, XR, YR, ZR - float blendstart[2]; // starting value - float blendend[2]; // ending value - int blendparent; - - int seqgroup; // sequence group for demand loading - - int entrynode; // transition node at entry - int exitnode; // transition node at exit - int nodeflags; // transition rules - - int nextseq; // auto advancing sequences -} mstudioseqdesc_t; - -// events -#include "studio_event.h" -/* -typedef struct -{ - int frame; - int event; - int type; - char options[64]; -} mstudioevent_t; -*/ - -// pivots -typedef struct -{ - vec3_t org; // pivot point - int start; - int end; -} mstudiopivot_t; - -// attachment -typedef struct -{ - char name[32]; - int type; - int bone; - vec3_t org; // attachment point - vec3_t vectors[3]; -} mstudioattachment_t; - -typedef struct -{ - unsigned short offset[6]; -} mstudioanim_t; - -// animation frames -typedef union -{ - struct { - byte valid; - byte total; - } num; - short value; -} mstudioanimvalue_t; - - - -// body part index -typedef struct -{ - char name[64]; - int nummodels; - int base; - int modelindex; // index into models array -} mstudiobodyparts_t; - - - -// skin info -typedef struct -{ - char name[64]; - int flags; - int width; - int height; - int index; -} mstudiotexture_t; - - -// skin families -// short index[skinfamilies][skinref] - -// studio models -typedef struct -{ - char name[64]; - - int type; - - float boundingradius; - - int nummesh; - int meshindex; - - int numverts; // number of unique vertices - int vertinfoindex; // vertex bone info - int vertindex; // vertex vec3_t - int numnorms; // number of unique surface normals - int norminfoindex; // normal bone info - int normindex; // normal vec3_t - - int numgroups; // deformation groups - int groupindex; -} mstudiomodel_t; - - -// vec3_t boundingbox[model][bone][2]; // complex intersection info - - -// meshes -typedef struct -{ - int numtris; - int triindex; - int skinref; - int numnorms; // per mesh normals - int normindex; // normal vec3_t -} mstudiomesh_t; - -// triangles -#if 0 -typedef struct -{ - short vertindex; // index into vertex array - short normindex; // index into normal array - short s,t; // s,t position on skin -} mstudiotrivert_t; -#endif - -// lighting options -#define STUDIO_NF_FLATSHADE 0x0001 -#define STUDIO_NF_CHROME 0x0002 -#define STUDIO_NF_FULLBRIGHT 0x0004 - -// motion flags -#define STUDIO_X 0x0001 -#define STUDIO_Y 0x0002 -#define STUDIO_Z 0x0004 -#define STUDIO_XR 0x0008 -#define STUDIO_YR 0x0010 -#define STUDIO_ZR 0x0020 -#define STUDIO_LX 0x0040 -#define STUDIO_LY 0x0080 -#define STUDIO_LZ 0x0100 -#define STUDIO_AX 0x0200 -#define STUDIO_AY 0x0400 -#define STUDIO_AZ 0x0800 -#define STUDIO_AXR 0x1000 -#define STUDIO_AYR 0x2000 -#define STUDIO_AZR 0x4000 -#define STUDIO_TYPES 0x7FFF -#define STUDIO_RLOOP 0x8000 // controller that wraps shortest distance - -// sequence flags -#define STUDIO_LOOPING 0x0001 - -// bone flags -#define STUDIO_HAS_NORMALS 0x0001 -#define STUDIO_HAS_VERTICES 0x0002 -#define STUDIO_HAS_BBOX 0x0004 -#define STUDIO_HAS_CHROME 0x0008 // if any of the textures have chrome on them - -#define RAD_TO_STUDIO (32768.0/M_PI) -#define STUDIO_TO_RAD (M_PI/32768.0) - -#endif diff --git a/HLSDK/pm_shared/pm_debug.h b/HLSDK/pm_shared/pm_debug.h deleted file mode 100644 index a506d37..0000000 --- a/HLSDK/pm_shared/pm_debug.h +++ /dev/null @@ -1,28 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef PM_DEBUG_H -#define PM_DEBUG_H -#ifdef _WIN32 -#ifndef __MINGW32__ -#pragma once -#endif /* not __MINGW32__ */ -#endif - -void PM_ViewEntity( void ); -void PM_DrawBBox(vec3_t mins, vec3_t maxs, vec3_t origin, int pcolor, float life); -void PM_ParticleLine(vec3_t start, vec3_t end, int pcolor, float life, float vert); -void PM_ShowClipBox( void ); - -#endif // PMOVEDBG_H diff --git a/HLSDK/pm_shared/pm_defs.h b/HLSDK/pm_shared/pm_defs.h deleted file mode 100644 index a41d706..0000000 --- a/HLSDK/pm_shared/pm_defs.h +++ /dev/null @@ -1,226 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// pm_defs.h -#if !defined( PM_DEFSH ) -#define PM_DEFSH -#ifdef _WIN32 -#ifndef __MINGW32__ -#pragma once -#endif /* not __MINGW32__ */ -#endif - -#define MAX_PHYSENTS 600 // Must have room for all entities in the world. -#define MAX_MOVEENTS 64 -#define MAX_CLIP_PLANES 5 - -#define PM_NORMAL 0x00000000 -#define PM_STUDIO_IGNORE 0x00000001 // Skip studio models -#define PM_STUDIO_BOX 0x00000002 // Use boxes for non-complex studio models (even in traceline) -#define PM_GLASS_IGNORE 0x00000004 // Ignore entities with non-normal rendermode -#define PM_WORLD_ONLY 0x00000008 // Only trace against the world - -// Values for flags parameter of PM_TraceLine -#define PM_TRACELINE_PHYSENTSONLY 0 -#define PM_TRACELINE_ANYVISIBLE 1 - - -#include "pm_info.h" - -// PM_PlayerTrace results. -#include "pmtrace.h" - -#if !defined ( USERCMD_H ) -#include "usercmd.h" -#endif - -// physent_t -typedef struct physent_s -{ - char name[32]; // Name of model, or "player" or "world". - int player; - vec3_t origin; // Model's origin in world coordinates. - struct model_s *model; // only for bsp models - struct model_s *studiomodel; // SOLID_BBOX, but studio clip intersections. - vec3_t mins, maxs; // only for non-bsp models - int info; // For client or server to use to identify (index into edicts or cl_entities) - vec3_t angles; // rotated entities need this info for hull testing to work. - - int solid; // Triggers and func_door type WATER brushes are SOLID_NOT - int skin; // BSP Contents for such things like fun_door water brushes. - int rendermode; // So we can ignore glass - - // Complex collision detection. - float frame; - int sequence; - byte controller[4]; - byte blending[2]; - - int movetype; - int takedamage; - int blooddecal; - int team; - int classnumber; - - // For mods - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; -} physent_t; - - -typedef struct playermove_s -{ - int player_index; // So we don't try to run the PM_CheckStuck nudging too quickly. - qboolean server; // For debugging, are we running physics code on server side? - - qboolean multiplayer; // 1 == multiplayer server - float time; // realtime on host, for reckoning duck timing - float frametime; // Duration of this frame - - vec3_t forward, right, up; // Vectors for angles - // player state - vec3_t origin; // Movement origin. - vec3_t angles; // Movement view angles. - vec3_t oldangles; // Angles before movement view angles were looked at. - vec3_t velocity; // Current movement direction. - vec3_t movedir; // For waterjumping, a forced forward velocity so we can fly over lip of ledge. - vec3_t basevelocity; // Velocity of the conveyor we are standing, e.g. - - // For ducking/dead - vec3_t view_ofs; // Our eye position. - float flDuckTime; // Time we started duck - qboolean bInDuck; // In process of ducking or ducked already? - - // For walking/falling - int flTimeStepSound; // Next time we can play a step sound - int iStepLeft; - - float flFallVelocity; - vec3_t punchangle; - - float flSwimTime; - - float flNextPrimaryAttack; - - int effects; // MUZZLE FLASH, e.g. - - int flags; // FL_ONGROUND, FL_DUCKING, etc. - int usehull; // 0 = regular player hull, 1 = ducked player hull, 2 = point hull - float gravity; // Our current gravity and friction. - float friction; - int oldbuttons; // Buttons last usercmd - float waterjumptime; // Amount of time left in jumping out of water cycle. - qboolean dead; // Are we a dead player? - int deadflag; - int spectator; // Should we use spectator physics model? - int movetype; // Our movement type, NOCLIP, WALK, FLY - - int onground; - int waterlevel; - int watertype; - int oldwaterlevel; - - char sztexturename[256]; - char chtexturetype; - - float maxspeed; - float clientmaxspeed; // Player specific maxspeed - - // For mods - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; - // world state - // Number of entities to clip against. - int numphysent; - physent_t physents[MAX_PHYSENTS]; - // Number of momvement entities (ladders) - int nummoveent; - // just a list of ladders - physent_t moveents[MAX_MOVEENTS]; - - // All things being rendered, for tracing against things you don't actually collide with - int numvisent; - physent_t visents[ MAX_PHYSENTS ]; - - // input to run through physics. - usercmd_t cmd; - - // Trace results for objects we collided with. - int numtouch; - pmtrace_t touchindex[MAX_PHYSENTS]; - - char physinfo[ MAX_PHYSINFO_STRING ]; // Physics info string - - struct movevars_s *movevars; - vec3_t player_mins[ 4 ]; - vec3_t player_maxs[ 4 ]; - - // Common functions - const char *(*PM_Info_ValueForKey) ( const char *s, const char *key ); - void (*PM_Particle)( float *origin, int color, float life, int zpos, int zvel); - int (*PM_TestPlayerPosition) (float *pos, pmtrace_t *ptrace ); - void (*Con_NPrintf)( int idx, char *fmt, ... ); - void (*Con_DPrintf)( char *fmt, ... ); - void (*Con_Printf)( char *fmt, ... ); - double (*Sys_FloatTime)( void ); - void (*PM_StuckTouch)( int hitent, pmtrace_t *ptraceresult ); - int (*PM_PointContents) (float *p, int *truecontents /*filled in if this is non-null*/ ); - int (*PM_TruePointContents) (float *p); - int (*PM_HullPointContents) ( struct hull_s *hull, int num, float *p); - pmtrace_t (*PM_PlayerTrace) (float *start, float *end, int traceFlags, int ignore_pe ); - struct pmtrace_s *(*PM_TraceLine)( float *start, float *end, int flags, int usehulll, int ignore_pe ); - long (*RandomLong)( long lLow, long lHigh ); - float (*RandomFloat)( float flLow, float flHigh ); - int (*PM_GetModelType)( struct model_s *mod ); - void (*PM_GetModelBounds)( struct model_s *mod, float *mins, float *maxs ); - void *(*PM_HullForBsp)( physent_t *pe, float *offset ); - float (*PM_TraceModel)( physent_t *pEnt, float *start, float *end, trace_t *trace ); - int (*COM_FileSize)(char *filename); - byte *(*COM_LoadFile) (char *path, int usehunk, int *pLength); - void (*COM_FreeFile) ( void *buffer ); - char *(*memfgets)( byte *pMemFile, int fileSize, int *pFilePos, char *pBuffer, int bufferSize ); - - // Functions - // Run functions for this frame? - qboolean runfuncs; - void (*PM_PlaySound) ( int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch ); - const char *(*PM_TraceTexture) ( int ground, float *vstart, float *vend ); - void (*PM_PlaybackEventFull) ( int flags, int clientindex, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); - - pmtrace_t (*PM_PlayerTraceEx) (float *start, float *end, int traceFlags, int (*pfnIgnore)( physent_t *pe ) ); - int (*PM_TestPlayerPositionEx) (float *pos, pmtrace_t *ptrace, int (*pfnIgnore)( physent_t *pe ) ); - struct pmtrace_s *(*PM_TraceLineEx)( float *start, float *end, int flags, int usehulll, int (*pfnIgnore)( physent_t *pe ) ); -} playermove_t; - -#endif diff --git a/HLSDK/pm_shared/pm_info.h b/HLSDK/pm_shared/pm_info.h deleted file mode 100644 index fa3cc19..0000000 --- a/HLSDK/pm_shared/pm_info.h +++ /dev/null @@ -1,26 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// Physics info string definition -#if !defined( PM_INFOH ) -#define PM_INFOH -#ifdef _WIN32 -#ifndef __MINGW32__ -#pragma once -#endif /* not __MINGW32__ */ -#endif - -#define MAX_PHYSINFO_STRING 256 - -#endif // PM_INFOH diff --git a/HLSDK/pm_shared/pm_materials.h b/HLSDK/pm_shared/pm_materials.h deleted file mode 100644 index 4140781..0000000 --- a/HLSDK/pm_shared/pm_materials.h +++ /dev/null @@ -1,37 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( PM_MATERIALSH ) -#define PM_MATERIALSH -#ifdef _WIN32 -#ifndef __MINGW32__ -#pragma once -#endif /* not __MINGW32__ */ -#endif - -#define CBTEXTURENAMEMAX 13 // only load first n chars of name - -#define CHAR_TEX_CONCRETE 'C' // texture types -#define CHAR_TEX_METAL 'M' -#define CHAR_TEX_DIRT 'D' -#define CHAR_TEX_VENT 'V' -#define CHAR_TEX_GRATE 'G' -#define CHAR_TEX_TILE 'T' -#define CHAR_TEX_SLOSH 'S' -#define CHAR_TEX_WOOD 'W' -#define CHAR_TEX_COMPUTER 'P' -#define CHAR_TEX_GLASS 'Y' -#define CHAR_TEX_FLESH 'F' - -#endif // !PM_MATERIALSH diff --git a/HLSDK/pm_shared/pm_math.c b/HLSDK/pm_shared/pm_math.c deleted file mode 100644 index 91a0844..0000000 --- a/HLSDK/pm_shared/pm_math.c +++ /dev/null @@ -1,424 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// pm_math.c -- math primitives - -#include "mathlib.h" -#include "const.h" -#include - -// up / down -#define PITCH 0 -// left / right -#define YAW 1 -// fall over -#define ROLL 2 - -#ifdef _MSC_VER -#pragma warning(disable : 4244) -#endif - -vec3_t vec3_origin = {0,0,0}; -int nanmask = 255<<23; - -float anglemod(float a) -{ - a = (360.0/65536) * ((int)(a*(65536/360.0)) & 65535); - return a; -} - -void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) -{ - float angle; - float sr, sp, sy, cr, cp, cy; - - angle = angles[YAW] * (M_PI*2 / 360); - sy = sin(angle); - cy = cos(angle); - angle = angles[PITCH] * (M_PI*2 / 360); - sp = sin(angle); - cp = cos(angle); - angle = angles[ROLL] * (M_PI*2 / 360); - sr = sin(angle); - cr = cos(angle); - - if (forward) - { - forward[0] = cp*cy; - forward[1] = cp*sy; - forward[2] = -sp; - } - if (right) - { - right[0] = (-1*sr*sp*cy+-1*cr*-sy); - right[1] = (-1*sr*sp*sy+-1*cr*cy); - right[2] = -1*sr*cp; - } - if (up) - { - up[0] = (cr*sp*cy+-sr*-sy); - up[1] = (cr*sp*sy+-sr*cy); - up[2] = cr*cp; - } -} - -void AngleVectorsTranspose (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) -{ - float angle; - float sr, sp, sy, cr, cp, cy; - - angle = angles[YAW] * (M_PI*2 / 360); - sy = sin(angle); - cy = cos(angle); - angle = angles[PITCH] * (M_PI*2 / 360); - sp = sin(angle); - cp = cos(angle); - angle = angles[ROLL] * (M_PI*2 / 360); - sr = sin(angle); - cr = cos(angle); - - if (forward) - { - forward[0] = cp*cy; - forward[1] = (sr*sp*cy+cr*-sy); - forward[2] = (cr*sp*cy+-sr*-sy); - } - if (right) - { - right[0] = cp*sy; - right[1] = (sr*sp*sy+cr*cy); - right[2] = (cr*sp*sy+-sr*cy); - } - if (up) - { - up[0] = -sp; - up[1] = sr*cp; - up[2] = cr*cp; - } -} - - -void AngleMatrix (const vec3_t angles, float (*matrix)[4] ) -{ - float angle; - float sr, sp, sy, cr, cp, cy; - - angle = angles[YAW] * (M_PI*2 / 360); - sy = sin(angle); - cy = cos(angle); - angle = angles[PITCH] * (M_PI*2 / 360); - sp = sin(angle); - cp = cos(angle); - angle = angles[ROLL] * (M_PI*2 / 360); - sr = sin(angle); - cr = cos(angle); - - // matrix = (YAW * PITCH) * ROLL - matrix[0][0] = cp*cy; - matrix[1][0] = cp*sy; - matrix[2][0] = -sp; - matrix[0][1] = sr*sp*cy+cr*-sy; - matrix[1][1] = sr*sp*sy+cr*cy; - matrix[2][1] = sr*cp; - matrix[0][2] = (cr*sp*cy+-sr*-sy); - matrix[1][2] = (cr*sp*sy+-sr*cy); - matrix[2][2] = cr*cp; - matrix[0][3] = 0.0; - matrix[1][3] = 0.0; - matrix[2][3] = 0.0; -} - -void AngleIMatrix (const vec3_t angles, float matrix[3][4] ) -{ - float angle; - float sr, sp, sy, cr, cp, cy; - - angle = angles[YAW] * (M_PI*2 / 360); - sy = sin(angle); - cy = cos(angle); - angle = angles[PITCH] * (M_PI*2 / 360); - sp = sin(angle); - cp = cos(angle); - angle = angles[ROLL] * (M_PI*2 / 360); - sr = sin(angle); - cr = cos(angle); - - // matrix = (YAW * PITCH) * ROLL - matrix[0][0] = cp*cy; - matrix[0][1] = cp*sy; - matrix[0][2] = -sp; - matrix[1][0] = sr*sp*cy+cr*-sy; - matrix[1][1] = sr*sp*sy+cr*cy; - matrix[1][2] = sr*cp; - matrix[2][0] = (cr*sp*cy+-sr*-sy); - matrix[2][1] = (cr*sp*sy+-sr*cy); - matrix[2][2] = cr*cp; - matrix[0][3] = 0.0; - matrix[1][3] = 0.0; - matrix[2][3] = 0.0; -} - -void NormalizeAngles( float *angles ) -{ - int i; - // Normalize angles - for ( i = 0; i < 3; i++ ) - { - if ( angles[i] > 180.0 ) - { - angles[i] -= 360.0; - } - else if ( angles[i] < -180.0 ) - { - angles[i] += 360.0; - } - } -} - -/* -=================== -InterpolateAngles - -Interpolate Euler angles. -FIXME: Use Quaternions to avoid discontinuities -Frac is 0.0 to 1.0 ( i.e., should probably be clamped, but doesn't have to be ) -=================== -*/ -void InterpolateAngles( float *start, float *end, float *output, float frac ) -{ - int i; - float ang1, ang2; - float d; - - NormalizeAngles( start ); - NormalizeAngles( end ); - - for ( i = 0 ; i < 3 ; i++ ) - { - ang1 = start[i]; - ang2 = end[i]; - - d = ang2 - ang1; - if ( d > 180 ) - { - d -= 360; - } - else if ( d < -180 ) - { - d += 360; - } - - output[i] = ang1 + d * frac; - } - - NormalizeAngles( output ); -} - - -/* -=================== -AngleBetweenVectors - -=================== -*/ -float AngleBetweenVectors( const vec3_t v1, const vec3_t v2 ) -{ - float angle; - float l1 = Length( v1 ); - float l2 = Length( v2 ); - - if ( !l1 || !l2 ) - return 0.0f; - - angle = acos( DotProduct( v1, v2 ) ) / (l1*l2); - angle = ( angle * 180.0f ) / M_PI; - - return angle; -} - - -void VectorTransform (const vec3_t in1, float in2[3][4], vec3_t out) -{ - out[0] = DotProduct(in1, in2[0]) + in2[0][3]; - out[1] = DotProduct(in1, in2[1]) + in2[1][3]; - out[2] = DotProduct(in1, in2[2]) + in2[2][3]; -} - - -int VectorCompare (const vec3_t v1, const vec3_t v2) -{ - int i; - - for (i=0 ; i<3 ; i++) - if (v1[i] != v2[i]) - return 0; - - return 1; -} - -void VectorMA (const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc) -{ - vecc[0] = veca[0] + scale*vecb[0]; - vecc[1] = veca[1] + scale*vecb[1]; - vecc[2] = veca[2] + scale*vecb[2]; -} - - -vec_t _DotProduct (vec3_t v1, vec3_t v2) -{ - return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]; -} - -void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out) -{ - out[0] = veca[0]-vecb[0]; - out[1] = veca[1]-vecb[1]; - out[2] = veca[2]-vecb[2]; -} - -void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out) -{ - out[0] = veca[0]+vecb[0]; - out[1] = veca[1]+vecb[1]; - out[2] = veca[2]+vecb[2]; -} - -void _VectorCopy (vec3_t in, vec3_t out) -{ - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; -} - -void CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross) -{ - cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; - cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; - cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; -} - -double sqrt(double x); - -float Length(const vec3_t v) -{ - int i; - float length = 0.0f; - - for (i=0 ; i< 3 ; i++) - length += v[i]*v[i]; - length = sqrt (length); // FIXME - - return length; -} - -float Distance(const vec3_t v1, const vec3_t v2) -{ - vec3_t d; - VectorSubtract(v2,v1,d); - return Length(d); -} - -float VectorNormalize (vec3_t v) -{ - float length, ilength; - - length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; - length = sqrt (length); // FIXME - - if (length) - { - ilength = 1/length; - v[0] *= ilength; - v[1] *= ilength; - v[2] *= ilength; - } - - return length; - -} - -void VectorInverse (vec3_t v) -{ - v[0] = -v[0]; - v[1] = -v[1]; - v[2] = -v[2]; -} - -void VectorScale (const vec3_t in, vec_t scale, vec3_t out) -{ - out[0] = in[0]*scale; - out[1] = in[1]*scale; - out[2] = in[2]*scale; -} - - -int Q_log2(int val) -{ - int answer=0; - while (val>>=1) - answer++; - return answer; -} - -void VectorMatrix( vec3_t forward, vec3_t right, vec3_t up) -{ - vec3_t tmp; - - if (forward[0] == 0 && forward[1] == 0) - { - right[0] = 1; - right[1] = 0; - right[2] = 0; - up[0] = -forward[2]; - up[1] = 0; - up[2] = 0; - return; - } - - tmp[0] = 0; tmp[1] = 0; tmp[2] = 1.0; - CrossProduct( forward, tmp, right ); - VectorNormalize( right ); - CrossProduct( right, forward, up ); - VectorNormalize( up ); -} - - -void VectorAngles( const vec3_t forward, vec3_t angles ) -{ - float tmp, yaw, pitch; - - if (forward[1] == 0 && forward[0] == 0) - { - yaw = 0; - if (forward[2] > 0) - pitch = 90; - else - pitch = 270; - } - else - { - yaw = (atan2(forward[1], forward[0]) * 180 / M_PI); - if (yaw < 0) - yaw += 360; - - tmp = sqrt (forward[0]*forward[0] + forward[1]*forward[1]); - pitch = (atan2(forward[2], tmp) * 180 / M_PI); - if (pitch < 0) - pitch += 360; - } - - angles[0] = pitch; - angles[1] = yaw; - angles[2] = 0; -} diff --git a/HLSDK/pm_shared/pm_movevars.h b/HLSDK/pm_shared/pm_movevars.h deleted file mode 100644 index 66c99ee..0000000 --- a/HLSDK/pm_shared/pm_movevars.h +++ /dev/null @@ -1,47 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// pm_movevars.h -#if !defined( PM_MOVEVARSH ) -#define PM_MOVEVARSH - -// movevars_t // Physics variables. -typedef struct movevars_s movevars_t; - -struct movevars_s -{ - float gravity; // Gravity for map - float stopspeed; // Deceleration when not moving - float maxspeed; // Max allowed speed - float spectatormaxspeed; - float accelerate; // Acceleration factor - float airaccelerate; // Same for when in open air - float wateraccelerate; // Same for when in water - float friction; - float edgefriction; // Extra friction near dropofs - float waterfriction; // Less in water - float entgravity; // 1.0 - float bounce; // Wall bounce value. 1.0 - float stepsize; // sv_stepsize; - float maxvelocity; // maximum server velocity. - float zmax; // Max z-buffer range (for GL) - float waveHeight; // Water wave height (for GL) - qboolean footsteps; // Play footstep sounds - char skyName[32]; // Name of the sky map - float rollangle; - float rollspeed; - float skycolor_r; // Sky color - float skycolor_g; // - float skycolor_b; // - float skyvec_x; // Sky vector - float skyvec_y; // - float skyvec_z; // -}; - -extern movevars_t movevars; - -#endif diff --git a/HLSDK/pm_shared/pm_shared.h b/HLSDK/pm_shared/pm_shared.h deleted file mode 100644 index 153c539..0000000 --- a/HLSDK/pm_shared/pm_shared.h +++ /dev/null @@ -1,40 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -// -// pm_shared.h -// -#if !defined( PM_SHAREDH ) -#define PM_SHAREDH -#ifdef _WIN32 -#ifndef __MINGW32__ -#pragma once -#endif /* not __MINGW32__ */ -#endif - -void PM_Init( struct playermove_s *ppmove ); -void PM_Move ( struct playermove_s *ppmove, int server ); -char PM_FindTextureType( char *name ); - -// Spectator Movement modes (stored in pev->iuser1, so the physics code can get at them) -#define OBS_NONE 0 -#define OBS_CHASE_LOCKED 1 -#define OBS_CHASE_FREE 2 -#define OBS_ROAMING 3 -#define OBS_IN_EYE 4 -#define OBS_MAP_FREE 5 -#define OBS_MAP_CHASE 6 - -#endif diff --git a/HLSDK/public/steam/steamtypes.h b/HLSDK/public/steam/steamtypes.h deleted file mode 100644 index 1606616..0000000 --- a/HLSDK/public/steam/steamtypes.h +++ /dev/null @@ -1,177 +0,0 @@ -//========= Copyright � 1996-2008, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -//============================================================================= - -#ifndef STEAMTYPES_H -#define STEAMTYPES_H -#ifdef _WIN32 -#pragma once -#endif - -// Steam-specific types. Defined here so this header file can be included in other code bases. -#if defined( __GNUC__ ) && !defined(POSIX) - #if __GNUC__ < 4 - #error "Steamworks requires GCC 4.X (4.2 or 4.4 have been tested)" - #endif - #define POSIX 1 -#endif - -#if defined(__x86_64__) || defined(_WIN64) -#define X64BITS -#endif - -// Make sure VALVE_BIG_ENDIAN gets set on PS3, may already be set previously in Valve internal code. -#if !defined(VALVE_BIG_ENDIAN) && defined(_PS3) -#define VALVE_BIG_ENDIAN -#endif - -typedef unsigned char uint8; -typedef signed char int8; - -#if defined( _WIN32 ) - -typedef __int16 int16; -typedef unsigned __int16 uint16; -typedef __int32 int32; -typedef unsigned __int32 uint32; -typedef __int64 int64; -typedef unsigned __int64 uint64; - -#ifdef X64BITS -typedef __int64 intp; // intp is an integer that can accomodate a pointer -typedef unsigned __int64 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *) -#else -typedef __int32 intp; -typedef unsigned __int32 uintp; -#endif - -#else // _WIN32 - -typedef short int16; -typedef unsigned short uint16; -typedef int int32; -typedef unsigned int uint32; -typedef long long int64; -typedef unsigned long long uint64; -#ifdef X64BITS -typedef long long intp; -typedef unsigned long long uintp; -#else -typedef int intp; -typedef unsigned int uintp; -#endif - -#endif // else _WIN32 - -#ifdef __cplusplus -const int k_cubSaltSize = 8; -#else -#define k_cubSaltSize 8 -#endif - -typedef uint8 Salt_t[ k_cubSaltSize ]; - -//----------------------------------------------------------------------------- -// GID (GlobalID) stuff -// This is a globally unique identifier. It's guaranteed to be unique across all -// racks and servers for as long as a given universe persists. -//----------------------------------------------------------------------------- -// NOTE: for GID parsing/rendering and other utils, see gid.h -typedef uint64 GID_t; - -#ifdef __cplusplus -const GID_t k_GIDNil = 0xfffffffffffffffful; -#else -#define k_GIDNil 0xffffffffffffffffull; -#endif - -// For convenience, we define a number of types that are just new names for GIDs -typedef GID_t JobID_t; // Each Job has a unique ID -typedef GID_t TxnID_t; // Each financial transaction has a unique ID - -#ifdef __cplusplus -const GID_t k_TxnIDNil = k_GIDNil; -const GID_t k_TxnIDUnknown = 0; -#else -#define k_TxnIDNil k_GIDNil; -#define k_TxnIDUnknown 0; -#endif - -// this is baked into client messages and interfaces as an int, -// make sure we never break this. -typedef uint32 PackageId_t; -#ifdef __cplusplus -const PackageId_t k_uPackageIdFreeSub = 0x0; -const PackageId_t k_uPackageIdInvalid = 0xFFFFFFFF; -#else -#define k_uPackageIdFreeSub 0x0; -#define k_uPackageIdInvalid 0xFFFFFFFF; -#endif - -// this is baked into client messages and interfaces as an int, -// make sure we never break this. -typedef uint32 AppId_t; -#ifdef __cplusplus -const AppId_t k_uAppIdInvalid = 0x0; -#else -#define k_uAppIdInvalid 0x0; -#endif - -typedef uint64 AssetClassId_t; -#ifdef __cplusplus -const AssetClassId_t k_ulAssetClassIdInvalid = 0x0; -#else -#define k_ulAssetClassIdInvalid 0x0; -#endif - -typedef uint32 PhysicalItemId_t; -#ifdef __cplusplus -const PhysicalItemId_t k_uPhysicalItemIdInvalid = 0x0; -#else -#define k_uPhysicalItemIdInvalid 0x0; -#endif - - -// this is baked into client messages and interfaces as an int, -// make sure we never break this. AppIds and DepotIDs also presently -// share the same namespace, but since we'd like to change that in the future -// I've defined it seperately here. -typedef uint32 DepotId_t; -#ifdef __cplusplus -const DepotId_t k_uDepotIdInvalid = 0x0; -#else -#define k_uDepotIdInvalid 0x0; -#endif - -// RTime32 -// We use this 32 bit time representing real world time. -// It offers 1 second resolution beginning on January 1, 1970 (Unix time) -typedef uint32 RTime32; - -typedef uint32 CellID_t; -#ifdef __cplusplus -const CellID_t k_uCellIDInvalid = 0xFFFFFFFF; -#else -#define k_uCellIDInvalid 0x0; -#endif - -// handle to a Steam API call -typedef uint64 SteamAPICall_t; -#ifdef __cplusplus -const SteamAPICall_t k_uAPICallInvalid = 0x0; -#else -#define k_uAPICallInvalid 0x0; -#endif - -typedef uint32 AccountID_t; - -typedef uint32 PartnerId_t; -#ifdef __cplusplus -const PartnerId_t k_uPartnerIdInvalid = 0; -#else -#define k_uPartnerIdInvalid 0x0; -#endif - -#endif // STEAMTYPES_H diff --git a/Interface/IAudio.h b/Interface/IAudio.h deleted file mode 100644 index b891fd5..0000000 --- a/Interface/IAudio.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef IAUDIO_H -#define IAUDIO_H - -#ifdef _WIN32 -#pragma once -#endif - -#ifndef AUDIO_EXPORTS -#include "aud_int.h" -#else -#include "aud_int_internal.h" -#endif - -class IAudio : public IBaseInterface -{ -public: - virtual void GetInterface(aud_export_t *pAudExports, const char *version); -}; - -#define AUDIO_API_VERSION "AUDIO_API_VERSION001" - -extern IAudio *g_pAudio; - -#endif \ No newline at end of file diff --git a/Interface/ICommandLine.h b/Interface/ICommandLine.h deleted file mode 100644 index 1b02032..0000000 --- a/Interface/ICommandLine.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef ICOMMANDLINE_H -#define ICOMMANDLINE_H - -#ifdef _WIN32 -#pragma once -#endif - -class ICommandLine -{ -public: - virtual void CreateCmdLine(const char *commandline) = 0; - virtual const char *GetCmdLine(void) const = 0; - virtual const char *CheckParm(const char *psz, const char **ppszValue = 0) const = 0; - virtual void RemoveParm(const char *parm) = 0; - virtual void AppendParm(const char *pszParm, const char *pszValues) = 0; - virtual void SetParm(const char *pszParm, const char *pszValues) = 0; - virtual void SetParm(const char *pszParm, int iValue) = 0; -}; - -ICommandLine *CommandLine(void); - -#endif \ No newline at end of file diff --git a/Interface/IEngine.h b/Interface/IEngine.h deleted file mode 100644 index 2e479a7..0000000 --- a/Interface/IEngine.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef IENGINE_H -#define IENGINE_H - -#ifdef _WIN32 -#pragma once -#endif - -enum -{ - ENGINE_RESULT_NONE, - ENGINE_RESULT_RESTART, - ENGINE_RESULT_UNSUPPORTEDVIDEO -}; - -class IEngine : public IBaseInterface -{ -public: - virtual int Run(HINSTANCE instance, char *basedir, const char *cmdline, char *szCommand, CreateInterfaceFn launcherFactory, CreateInterfaceFn filesystemFactory); -}; - -#define VENGINE_LAUNCHER_API_VERSION "VENGINE_LAUNCHER_API_VERSION002" - -#endif \ No newline at end of file diff --git a/Interface/IFileSystem.h b/Interface/IFileSystem.h deleted file mode 100644 index fa79bbd..0000000 --- a/Interface/IFileSystem.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef IFILESYSTEM_H -#define IFILESYSTEM_H - -#ifdef _WIN32 -#pragma once -#endif - -typedef void *FileHandle_t; -typedef int FileFindHandle_t; -typedef int WaitForResourcesHandle_t; - -enum FileSystemSeek_t -{ - FILESYSTEM_SEEK_HEAD = 0, - FILESYSTEM_SEEK_CURRENT, - FILESYSTEM_SEEK_TAIL, -}; - -enum -{ - FILESYSTEM_INVALID_FIND_HANDLE = -1 -}; - -enum FileWarningLevel_t -{ - FILESYSTEM_WARNING = -1, - FILESYSTEM_WARNING_QUIET = 0, - FILESYSTEM_WARNING_REPORTUNCLOSED, - FILESYSTEM_WARNING_REPORTUSAGE, - FILESYSTEM_WARNING_REPORTALLACCESSES, - FILESYSTEM_WARNING_REPORTALLACCESSES_READ, - FILESYSTEM_WARNING_REPORTALLACCESSES_READWRITE, - FILESYSTEM_WARNING_REPORTALLACCESSES_ASYNC, -}; - -#define FILESYSTEM_INVALID_HANDLE (FileHandle_t)NULL - -class IFileSystem : public IBaseInterface -{ -public: - virtual void Mount(void) = 0; - virtual void Unmount(void) = 0; - virtual void RemoveAllSearchPaths(void) = 0; - virtual void AddSearchPath(const char *pPath, const char *pathID = 0) = 0; - virtual bool RemoveSearchPath(const char *pPath) = 0; - virtual void RemoveFile(const char *pRelativePath, const char *pathID = 0) = 0; - virtual void CreateDirHierarchy(const char *path, const char *pathID = 0) = 0; - virtual bool FileExists(const char *pFileName) = 0; - virtual bool IsDirectory(const char *pFileName) = 0; - virtual FileHandle_t Open(const char *pFileName, const char *pOptions, const char *pathID = 0) = 0; - virtual void Close(FileHandle_t file) = 0; - virtual void Seek(FileHandle_t file, int pos, FileSystemSeek_t seekType) = 0; - virtual unsigned Tell(FileHandle_t file) = 0; - virtual unsigned Size(FileHandle_t file) = 0; - virtual unsigned Size(const char *pFileName) = 0; - virtual long GetFileTime(const char *pFileName) = 0; - virtual void FileTimeToString(char *pStrip, int maxCharsIncludingTerminator, long fileTime) = 0; - virtual bool IsOk(FileHandle_t file) = 0; - virtual void Flush(FileHandle_t file) = 0; - virtual bool EndOfFile(FileHandle_t file) = 0; - virtual int Read(void *pOutput, int size, FileHandle_t file) = 0; - virtual int Write(void const *pInput, int size, FileHandle_t file) = 0; - virtual char *ReadLine(char *pOutput, int maxChars, FileHandle_t file) = 0; - virtual int FPrintf(FileHandle_t file, char *pFormat, ...) = 0; - virtual char *GetReadBuffer(FileHandle_t file, char *pBuffer) = 0; - virtual void ReleaseReadBuffer(FileHandle_t file, char *pBuffer) = 0; - virtual const char *FindFirst(const char *pWildCard, FileFindHandle_t *pHandle, const char *pathID = 0) = 0; - virtual const char *FindNext(FileFindHandle_t handle) = 0; - virtual bool FindIsDirectory(FileFindHandle_t handle) = 0; - virtual void FindClose(FileFindHandle_t handle) = 0; - virtual void GetLocalCopy(const char *pFileName) = 0; - virtual const char *GetLocalPath(const char *pFileName, char *pLocalPath, int maxlen) = 0; - virtual char *ParseFile(char *data, char *token, bool *wasquoted) = 0; - virtual bool FullPathToRelativePath(const char *pFullpath, char *pRelative) = 0; - virtual bool GetCurrentDirectory(char *pDirectory, int maxlen) = 0; - virtual void PrintOpenedFiles(void) = 0; - virtual void SetWarningFunc(void(*pfnWarning)(const char *fmt, ...)) = 0; - virtual void SetWarningLevel(FileWarningLevel_t level) = 0; - virtual void LogLevelLoadStarted(const char *name) = 0; - virtual void LogLevelLoadFinished(const char *name) = 0; - virtual int HintResourceNeed(const char *hintlist, int forgetEverything) = 0; - virtual int PauseResourcePreloading(void) = 0; - virtual int ResumeResourcePreloading(void) = 0; - virtual int SetVBuf(FileHandle_t stream, char *buffer, int mode, long size) = 0; - virtual void GetInterfaceVersion(char *p, int maxlen) = 0; - virtual bool IsFileImmediatelyAvailable(const char *path) = 0; - virtual void *WaitForResources(const char *pFileName) = 0; - virtual bool GetWaitForResourcesProgress(WaitForResourcesHandle_t handle, float *progress, bool *complete) = 0; - virtual void CancelWaitForResources(WaitForResourcesHandle_t handle) = 0; - virtual bool IsAppReadyForOfflinePlay(void) = 0; - virtual void AddPackFile(const char *pPath, const char *pathID = 0) = 0; - virtual void *OpenFromCacheForRead(const char *pFileName, const char *pOptions, const char *pathID = 0) = 0; -}; - -#define FILESYSTEM_INTERFACE_VERSION "VFileSystem009" - -#endif \ No newline at end of file diff --git a/Interface/IPlugins.h b/Interface/IPlugins.h deleted file mode 100644 index b7b70a8..0000000 --- a/Interface/IPlugins.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef IPLUGINS_H -#define IPLUGINS_H - -#ifdef _WIN32 -#pragma once -#endif - -class IPlugins : public IBaseInterface -{ -public: - virtual void Init(metahook_api_t *pAPI, mh_interface_t *pInterface, mh_enginesave_t *pSave); - virtual void Shutdown(void); - virtual void LoadEngine(void); - virtual void LoadClient(cl_exportfuncs_t *pExportFunc); - virtual void ExitGame(int iResult); -}; - -#define METAHOOK_PLUGIN_API_VERSION "METAHOOK_PLUGIN_API_VERSION002" - -#endif \ No newline at end of file diff --git a/Interface/IPluginsV1.h b/Interface/IPluginsV1.h deleted file mode 100644 index f40f1d3..0000000 --- a/Interface/IPluginsV1.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef IPLUGINS_V1_H -#define IPLUGINS_V1_H - -#ifdef _WIN32 -#pragma once -#endif - -class IPluginsV1 : public IBaseInterface -{ -public: - virtual void Init(struct cl_exportfuncs_s *pExportfuncs); - virtual void Shutdown(int restart); -}; - -#define METAHOOK_PLUGIN_API_VERSION_V1 "METAHOOK_PLUGIN_API_VERSION001" - -#endif \ No newline at end of file diff --git a/Interface/IRegistry.h b/Interface/IRegistry.h deleted file mode 100644 index cb6b46d..0000000 --- a/Interface/IRegistry.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef IREGISTRY_H -#define IREGISTRY_H - -#ifdef _WIN32 -#pragma once -#endif - -class IRegistry -{ -public: - virtual void Init(void) = 0; - virtual void Shutdown(void) = 0; - virtual int ReadInt(const char *key, int defaultValue = 0) = 0; - virtual void WriteInt(const char *key, int value) = 0; - virtual const char *ReadString(const char *key, const char *defaultValue = NULL) = 0; - virtual void WriteString(const char *key, const char *value) = 0; -}; - -extern IRegistry *registry; - -#endif \ No newline at end of file diff --git a/Launcher.ico b/Launcher.ico deleted file mode 100644 index a3daea3..0000000 Binary files a/Launcher.ico and /dev/null differ diff --git a/Launcher.rc b/Launcher.rc deleted file mode 100644 index 7ed562b..0000000 --- a/Launcher.rc +++ /dev/null @@ -1,36 +0,0 @@ -#include - -101 ICON "Launcher.ico" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,4,0,0 - PRODUCTVERSION 0,4,0,0 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - - BEGIN - BLOCK "000004b0" - - BEGIN - VALUE "FileDescription", "MetaHook Plus" - VALUE "FileVersion", "0.4.0.0" - VALUE "InternalName", "MetaHook" - VALUE "OriginalFilename", "MetaHook.exe" - END - END - - BLOCK "VarFileInfo" - - BEGIN - VALUE "Translation", 0x0, 1200 - END -END \ No newline at end of file diff --git a/LoadBlob.cpp b/LoadBlob.cpp deleted file mode 100644 index 370c06d..0000000 --- a/LoadBlob.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include -#include "LoadBlob.h" -#include -#include "IFileSystem.h" - -extern IFileSystem *g_pFileSystem; - -#ifndef _USRDLL -#pragma data_seg(".data") -BYTE g_pBlobBuffer[0x2000000]; -#endif - -BlobHeader_t g_BlobHeader; - -BlobHeader_t *GetBlobHeader(void) -{ - return &g_BlobHeader; -} - -BOOL FIsBlob(const char *pstFileName) -{ - FileHandle_t file = g_pFileSystem->Open(pstFileName, "rb"); - - if (file == FILESYSTEM_INVALID_HANDLE) - return FALSE; - - BlobInfo_t info; - g_pFileSystem->Read(&info, sizeof(BlobInfo_t), file); - g_pFileSystem->Close(file); - - if (info.m_dwAlgorithm != BLOB_ALGORITHM) - return FALSE; - - return TRUE; -} - -DWORD NLoadBlobFile(const char *pstFileName, BlobFootprint_t *pblobfootprint, void **pv) -{ - FileHandle_t file = g_pFileSystem->Open(pstFileName, "rb"); - - DWORD dwSize; - BYTE *pBuffer; - DWORD dwAddress; - - g_pFileSystem->Seek(file, 0, FILESYSTEM_SEEK_TAIL); - dwSize = g_pFileSystem->Tell(file); - g_pFileSystem->Seek(file, 0, FILESYSTEM_SEEK_HEAD); - - pBuffer = (BYTE *)malloc(dwSize); - g_pFileSystem->Read(pBuffer, dwSize, file); - - dwAddress = LoadBlobFile(pBuffer, pblobfootprint, pv, dwSize); - free(pBuffer); - g_pFileSystem->Close(file); - return dwAddress; -} - -DWORD LoadBlobFile(BYTE *pBuffer, BlobFootprint_t *pblobfootprint, void **pv, DWORD dwSize) -{ - BYTE bXor = 0x57; - BlobHeader_t *pHeader; - BlobSection_t *pSection; - DWORD dwAddress = 0; - - for (size_t i = sizeof(BlobInfo_t); i < dwSize; i++) - { - pBuffer[i] ^= bXor; - bXor += pBuffer[i] + 0x57; - } - - pHeader = (BlobHeader_t *)(pBuffer + sizeof(BlobInfo_t)); - pHeader->m_dwExportPoint ^= 0x7A32BC85; - pHeader->m_dwImageBase ^= 0x49C042D1; - pHeader->m_dwEntryPoint -= 12; - pHeader->m_dwImportTable ^= 0x872C3D47; - pSection = (BlobSection_t *)(pBuffer + sizeof(BlobInfo_t) + sizeof(BlobHeader_t)); - - memcpy(&g_BlobHeader, pHeader, sizeof(BlobHeader_t)); - - for (WORD j = 0; j <= pHeader->m_wSectionCount; j++) - { - if (pSection[j].m_bIsSpecial) - dwAddress = pSection[j].m_dwDataAddress; - - if (pSection[j].m_dwVirtualSize > pSection[j].m_dwDataSize) - memset((BYTE *)(pSection[j].m_dwVirtualAddress + pSection[j].m_dwDataSize), NULL, pSection[j].m_dwVirtualSize - pSection[j].m_dwDataSize); - - memcpy((BYTE *)pSection[j].m_dwVirtualAddress, pBuffer + pSection[j].m_dwDataAddress, pSection[j].m_dwDataSize); - } - - PIMAGE_IMPORT_DESCRIPTOR pImport = (PIMAGE_IMPORT_DESCRIPTOR)pHeader->m_dwImportTable; - - while (pImport->Name) - { - HMODULE hPorcDll = LoadLibrary((char *)(pHeader->m_dwImageBase + pImport->Name)); - PIMAGE_THUNK_DATA pThunk = (PIMAGE_THUNK_DATA)(pHeader->m_dwImageBase + pImport++->FirstThunk); - - while (pThunk->u1.Function) - { - const char *pszProcName = IMAGE_SNAP_BY_ORDINAL(pThunk->u1.Ordinal) ? (char *)((LONG)pThunk->u1.Ordinal & IMAGE_ORDINAL_FLAG32 - 1) : (char *)(pHeader->m_dwImageBase + ((IMAGE_IMPORT_BY_NAME *)((LONG)pThunk->u1.Ordinal & IMAGE_ORDINAL_FLAG32 - 1))->Name); - pThunk++->u1.AddressOfData = (DWORD)GetProcAddress(hPorcDll, pszProcName); - } - } - - ((BOOL(WINAPI *)(HINSTANCE, DWORD, void *))(pHeader->m_dwEntryPoint))(0, DLL_PROCESS_ATTACH, 0); - ((void(*)(void **))(pHeader->m_dwExportPoint))(pv); - return dwAddress; -} - -void FreeBlob(BlobFootprint_t *pblobfootprint) -{ - FreeLibrary(pblobfootprint->m_hDll); -} \ No newline at end of file diff --git a/LoadBlob.h b/LoadBlob.h deleted file mode 100644 index cdea0fc..0000000 --- a/LoadBlob.h +++ /dev/null @@ -1,43 +0,0 @@ -#define BLOB_ALGORITHM 0x12345678 - -typedef struct BlobInfo_s -{ - char m_szPath[10]; - char m_szDescribe[32]; - char m_szCompany[22]; - DWORD m_dwAlgorithm; -} -BlobInfo_t; - -typedef struct BlobHeader_s -{ - DWORD m_dwCheckSum; - WORD m_wSectionCount; - DWORD m_dwExportPoint; - DWORD m_dwImageBase; - DWORD m_dwEntryPoint; - DWORD m_dwImportTable; -} -BlobHeader_t; - -typedef struct BlobSection_s -{ - DWORD m_dwVirtualAddress; - DWORD m_dwVirtualSize; - DWORD m_dwDataSize; - DWORD m_dwDataAddress; - BOOL m_bIsSpecial; -} -BlobSection_t; - -typedef struct BlobFootprint_s -{ - HMODULE m_hDll; -} -BlobFootprint_t; - -BlobHeader_t *GetBlobHeader(void); -BOOL FIsBlob(const char *pstFileName); -DWORD NLoadBlobFile(const char *pstFileName, BlobFootprint_t *pblobfootprint, void **pv); -DWORD LoadBlobFile(BYTE *pBuffer, BlobFootprint_t *pblobfootprint, void **pv, DWORD dwSize); -void FreeBlob(BlobFootprint_t *pblobfootprint); \ No newline at end of file diff --git a/MetaHook.sln b/MetaHook.sln deleted file mode 100644 index 6153b37..0000000 --- a/MetaHook.sln +++ /dev/null @@ -1,37 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2026 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MetaHook", "MetaHook.vcxproj", "{0931F284-681C-41F1-AF30-97D1DCE2283C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Audio", "Plugins\Audio\Audio.vcxproj", "{076D2FBC-CAB6-4E26-931A-E5E8E9A4EBA7}" - ProjectSection(ProjectDependencies) = postProject - {0931F284-681C-41F1-AF30-97D1DCE2283C} = {0931F284-681C-41F1-AF30-97D1DCE2283C} - EndProjectSection -EndProject -Global - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0931F284-681C-41F1-AF30-97D1DCE2283C}.Debug|Win32.ActiveCfg = Debug|Win32 - {0931F284-681C-41F1-AF30-97D1DCE2283C}.Debug|Win32.Build.0 = Debug|Win32 - {0931F284-681C-41F1-AF30-97D1DCE2283C}.Release|Win32.ActiveCfg = Release|Win32 - {0931F284-681C-41F1-AF30-97D1DCE2283C}.Release|Win32.Build.0 = Release|Win32 - {076D2FBC-CAB6-4E26-931A-E5E8E9A4EBA7}.Debug|Win32.ActiveCfg = Debug|Win32 - {076D2FBC-CAB6-4E26-931A-E5E8E9A4EBA7}.Debug|Win32.Build.0 = Debug|Win32 - {076D2FBC-CAB6-4E26-931A-E5E8E9A4EBA7}.Release|Win32.ActiveCfg = Release|Win32 - {076D2FBC-CAB6-4E26-931A-E5E8E9A4EBA7}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F5BD051D-7539-49C9-ADF1-A3B6602D18D0} - EndGlobalSection -EndGlobal diff --git a/MetaHook.vcxproj b/MetaHook.vcxproj deleted file mode 100644 index b3ec909..0000000 --- a/MetaHook.vcxproj +++ /dev/null @@ -1,150 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {0931F284-681C-41F1-AF30-97D1DCE2283C} - MetaHook - Win32Proj - - - - Application - v141 - MultiByte - true - - - Application - v141 - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>15.0.27625.0 - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - MinimumRecommendedRules.ruleset - - - false - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - false - MinimumRecommendedRules.ruleset - - - false - - - - /MP %(AdditionalOptions) - Disabled - .\;..\;HLSDK\common;HLSDK\cl_dll;HLSDK\engine;HLSDK\pm_shared;HLSDK\public;Interface;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - - - EnableFastChecks - MultiThreadedDebug - - TurnOffAllWarnings - EditAndContinue - stdcpp17 - - - true - Windows - 0x1400000 - MachineX86 - false - - - copy "$(OutDir)$(ProjectName).exe" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\metahook.exe" - - - - - /MP %(AdditionalOptions) - .\;..\;HLSDK\common;HLSDK\cl_dll;HLSDK\engine;HLSDK\pm_shared;HLSDK\public;Interface;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - Level3 - ProgramDatabase - 4311;4312;4819;4996;%(DisableSpecificWarnings) - stdcpp17 - Speed - true - MaxSpeed - - - false - Windows - true - true - 0x1400000 - MachineX86 - - - copy "$(OutDir)$(ProjectName).exe" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\metahook.exe" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/MetaHook.vcxproj.filters b/MetaHook.vcxproj.filters deleted file mode 100644 index d6726a9..0000000 --- a/MetaHook.vcxproj.filters +++ /dev/null @@ -1,104 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {a122a8d6-81fc-40c7-998d-69c99bdf7a88} - - - {3ca19d0e-0039-4342-8da2-cb589e829d01} - - - - - Source - - - Source - - - Source - - - Source - - - Source - - - Source - - - Source - - - Detours - - - Detours - - - Detours - - - Detours - - - - - Header - - - Header - - - Header - - - Header - - - Header - - - Interface - - - Interface - - - Interface - - - Interface - - - Interface - - - Interface - - - Detours - - - Detours - - - - - Resource - - - \ No newline at end of file diff --git a/MetaHook_DLL.sln b/MetaHook_DLL.sln deleted file mode 100644 index 39201ba..0000000 --- a/MetaHook_DLL.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2042 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MetaHook", "MetaHook_DLL.vcxproj", "{0931F284-681C-41F1-AF30-97D1DCE2283C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0931F284-681C-41F1-AF30-97D1DCE2283C}.Debug|Win32.ActiveCfg = Debug|Win32 - {0931F284-681C-41F1-AF30-97D1DCE2283C}.Debug|Win32.Build.0 = Debug|Win32 - {0931F284-681C-41F1-AF30-97D1DCE2283C}.Release|Win32.ActiveCfg = Release|Win32 - {0931F284-681C-41F1-AF30-97D1DCE2283C}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7110187D-97C9-48A1-BCC0-8F451CF338F4} - EndGlobalSection -EndGlobal diff --git a/MetaHook_DLL.vcxproj b/MetaHook_DLL.vcxproj deleted file mode 100644 index 3975f76..0000000 --- a/MetaHook_DLL.vcxproj +++ /dev/null @@ -1,142 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - MetaHook - {0931F284-681C-41F1-AF30-97D1DCE2283C} - MetaHook - Win32Proj - - - - DynamicLibrary - v141 - MultiByte - true - - - DynamicLibrary - v141 - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>15.0.27625.0 - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - true - MinimumRecommendedRules.ruleset - - - - - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - MinimumRecommendedRules.ruleset - - - - - - /MP %(AdditionalOptions) - Disabled - .\;..\;HLSDK\common;HLSDK\cl_dll;HLSDK\engine;HLSDK\pm_shared;HLSDK\public;Interface;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - TurnOffAllWarnings - EditAndContinue - - - true - Windows - - MachineX86 - - - - - - - - /MP %(AdditionalOptions) - .\;..\;HLSDK\common;HLSDK\cl_dll;HLSDK\engine;HLSDK\pm_shared;HLSDK\public;Interface;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - MultiThreadedDLL - false - - Level3 - ProgramDatabase - 4311;4312;4819;4996;%(DisableSpecificWarnings) - - - true - Windows - true - true - - MachineX86 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/MetaHook_DLL.vcxproj.filters b/MetaHook_DLL.vcxproj.filters deleted file mode 100644 index bae6f90..0000000 --- a/MetaHook_DLL.vcxproj.filters +++ /dev/null @@ -1,107 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {14e6b1ed-752f-430e-8a1b-2ce8ac55f090} - - - {09d4e063-c83f-4287-bc9f-186dc7042bf3} - - - - - Source - - - Source - - - Source - - - Source - - - Source - - - Source - - - Source - - - Source - - - Detours - - - Detours - - - Detours - - - Detours - - - - - Header - - - Header - - - Header - - - Header - - - Header - - - Interface - - - Interface - - - Interface - - - Interface - - - Interface - - - Interface - - - Detours - - - Detours - - - - - Resource - - - \ No newline at end of file diff --git a/OEPHook.cpp b/OEPHook.cpp deleted file mode 100644 index fddb244..0000000 --- a/OEPHook.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include "Detours\detours.h" - -typedef int (CALLBACK *fnWinMain)(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow); - -void HookOEP(void) -{ - HMODULE hGameModule = GetModuleHandle(NULL); - PBYTE PEHead = (PBYTE)hGameModule; - PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)hGameModule; - PIMAGE_NT_HEADERS pNTHeader = (PIMAGE_NT_HEADERS)&PEHead[pDosHeader->e_lfanew]; - fnWinMain pWinMain = (fnWinMain)&PEHead[pNTHeader->OptionalHeader.AddressOfEntryPoint]; - - DetourTransactionBegin(); - DetourUpdateThread(GetCurrentThread()); - DetourAttach((void**)&pWinMain, WinMain); - DetourTransactionCommit(); -} - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - switch (fdwReason) - { - case DLL_PROCESS_ATTACH: - { - HookOEP(); - } - } - - return TRUE; -} \ No newline at end of file diff --git a/Plugins/Audio/Audio.sln b/Plugins/Audio/Audio.sln deleted file mode 100644 index 42272d0..0000000 --- a/Plugins/Audio/Audio.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2042 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Audio", "Audio.vcxproj", "{076D2FBC-CAB6-4E26-931A-E5E8E9A4EBA7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {076D2FBC-CAB6-4E26-931A-E5E8E9A4EBA7}.Debug|Win32.ActiveCfg = Debug|Win32 - {076D2FBC-CAB6-4E26-931A-E5E8E9A4EBA7}.Debug|Win32.Build.0 = Debug|Win32 - {076D2FBC-CAB6-4E26-931A-E5E8E9A4EBA7}.Release|Win32.ActiveCfg = Release|Win32 - {076D2FBC-CAB6-4E26-931A-E5E8E9A4EBA7}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {8D47BD2B-5593-401D-91D7-A84C616A6F0B} - EndGlobalSection -EndGlobal diff --git a/Plugins/Audio/Audio.vcxproj b/Plugins/Audio/Audio.vcxproj deleted file mode 100644 index 3cbc4e6..0000000 --- a/Plugins/Audio/Audio.vcxproj +++ /dev/null @@ -1,172 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {076D2FBC-CAB6-4E26-931A-E5E8E9A4EBA7} - Audio - Win32Proj - - - - DynamicLibrary - v141 - MultiByte - true - - - DynamicLibrary - v141 - MultiByte - - - - - - - - - - - - - <_ProjectFileVersion>15.0.27625.0 - - - $(Configuration)\ - $(Configuration)\ - true - MinimumRecommendedRules.ruleset - - - false - - - $(Configuration)\ - $(Configuration)\ - false - MinimumRecommendedRules.ruleset - - - false - - - - /MP %(AdditionalOptions) - Disabled - ..\..;..\..\Interface;..\..\HLSDK\cl_dll;..\..\HLSDK\common;..\..\HLSDK\engine;..\..\HLSDK\pm_shared;..\..\HLSDK\public;..\..\common;.\;..\..\src\Interface;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;AUDIO_EXPORTS;%(PreprocessorDefinitions) - - - EnableFastChecks - MultiThreadedDebug - StreamingSIMDExtensions2 - - Level3 - EditAndContinue - 4311;4312;4819;4996;%(DisableSpecificWarnings) - stdcpp17 - - - - - - true - Windows - MachineX86 - alure\alure2.lib;%(AdditionalDependencies) - false - - - copy "$(OutDir)$(ProjectName).dll" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\valve\metahook\plugins\audio.dll" -copy "$(OutDir)$(ProjectName).dll" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\ns\metahook\plugins\audio.dll" -copy "$(OutDir)$(ProjectName).dll" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\cstrike\metahook\plugins\audio.dll" -copy "$(OutDir)$(ProjectName).dll" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\czero\metahook\plugins\audio.dll" -copy "$(OutDir)$(ProjectName).dll" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\bshift\metahook\plugins\audio.dll" -copy "$(OutDir)$(ProjectName).dll" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\gearbox\metahook\plugins\audio.dll" -copy "$(OutDir)$(ProjectName).dll" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\asheep\metahook\plugins\audio.dll" - - - - - /MP %(AdditionalOptions) - MaxSpeed - Speed - false - ..\..;..\..\Interface;..\..\HLSDK\cl_dll;..\..\HLSDK\common;..\..\HLSDK\engine;..\..\HLSDK\pm_shared;..\..\HLSDK\public;..\..\common;.\;..\..\src\Interface;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;AUDIO_EXPORTS;%(PreprocessorDefinitions) - MultiThreadedDLL - StreamingSIMDExtensions2 - - Level3 - None - %(DisableSpecificWarnings) - stdcpp17 - true - true - Fast - - - - false - false - Windows - true - true - MachineX86 - false - alure\alure2.lib;%(AdditionalDependencies) - UseLinkTimeCodeGeneration - - - copy "$(OutDir)$(ProjectName).dll" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\valve\metahook\plugins\audio.dll" -copy "$(OutDir)$(ProjectName).dll" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\ns\metahook\plugins\audio.dll" -copy "$(OutDir)$(ProjectName).dll" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\cstrike\metahook\plugins\audio.dll" -copy "$(OutDir)$(ProjectName).dll" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\czero\metahook\plugins\audio.dll" -copy "$(OutDir)$(ProjectName).dll" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\bshift\metahook\plugins\audio.dll" -copy "$(OutDir)$(ProjectName).dll" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\gearbox\metahook\plugins\audio.dll" -copy "$(OutDir)$(ProjectName).dll" "D:\Program Files (x86)\Steam\steamapps\common\Half-Life\asheep\metahook\plugins\audio.dll" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plugins/Audio/Audio.vcxproj.filters b/Plugins/Audio/Audio.vcxproj.filters deleted file mode 100644 index 20a1ddd..0000000 --- a/Plugins/Audio/Audio.vcxproj.filters +++ /dev/null @@ -1,101 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {73ab30be-01bd-4a7f-9b91-255f36b3e3a5} - - - {a2b708ad-5d54-450a-b5ec-c93282dbee7d} - - - - - Source - - - Source - - - Source - - - Source - - - Source - - - Source - - - Source - - - Source - - - Source - - - Source - - - Source - - - Source - - - - - Header - - - Header - - - Header - - - Header - - - Header - - - Header - - - Interface - - - Interface - - - Header - - - Header - - - Header - - - Header - - - Header - - - Header - - - \ No newline at end of file diff --git a/Plugins/Audio/alure/AL/alure2-alext.h b/Plugins/Audio/alure/AL/alure2-alext.h deleted file mode 100644 index dc9ca88..0000000 --- a/Plugins/Audio/alure/AL/alure2-alext.h +++ /dev/null @@ -1,466 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2008 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#ifndef AL_ALEXT_H -#define AL_ALEXT_H - -#include -/* Define int64_t and uint64_t types */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include -#elif defined(_WIN32) && defined(__GNUC__) -#include -#elif defined(_WIN32) -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -/* Fallback if nothing above works */ -#include -#endif - -#include "../alc.h" -#include "../al.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef AL_LOKI_IMA_ADPCM_format -#define AL_LOKI_IMA_ADPCM_format 1 -#define AL_FORMAT_IMA_ADPCM_MONO16_EXT 0x10000 -#define AL_FORMAT_IMA_ADPCM_STEREO16_EXT 0x10001 -#endif - -#ifndef AL_LOKI_WAVE_format -#define AL_LOKI_WAVE_format 1 -#define AL_FORMAT_WAVE_EXT 0x10002 -#endif - -#ifndef AL_EXT_vorbis -#define AL_EXT_vorbis 1 -#define AL_FORMAT_VORBIS_EXT 0x10003 -#endif - -#ifndef AL_LOKI_quadriphonic -#define AL_LOKI_quadriphonic 1 -#define AL_FORMAT_QUAD8_LOKI 0x10004 -#define AL_FORMAT_QUAD16_LOKI 0x10005 -#endif - -#ifndef AL_EXT_float32 -#define AL_EXT_float32 1 -#define AL_FORMAT_MONO_FLOAT32 0x10010 -#define AL_FORMAT_STEREO_FLOAT32 0x10011 -#endif - -#ifndef AL_EXT_double -#define AL_EXT_double 1 -#define AL_FORMAT_MONO_DOUBLE_EXT 0x10012 -#define AL_FORMAT_STEREO_DOUBLE_EXT 0x10013 -#endif - -#ifndef AL_EXT_MULAW -#define AL_EXT_MULAW 1 -#define AL_FORMAT_MONO_MULAW_EXT 0x10014 -#define AL_FORMAT_STEREO_MULAW_EXT 0x10015 -#endif - -#ifndef AL_EXT_ALAW -#define AL_EXT_ALAW 1 -#define AL_FORMAT_MONO_ALAW_EXT 0x10016 -#define AL_FORMAT_STEREO_ALAW_EXT 0x10017 -#endif - -#ifndef ALC_LOKI_audio_channel -#define ALC_LOKI_audio_channel 1 -#define ALC_CHAN_MAIN_LOKI 0x500001 -#define ALC_CHAN_PCM_LOKI 0x500002 -#define ALC_CHAN_CD_LOKI 0x500003 -#endif - -#ifndef AL_EXT_MCFORMATS -#define AL_EXT_MCFORMATS 1 -#define AL_FORMAT_QUAD8 0x1204 -#define AL_FORMAT_QUAD16 0x1205 -#define AL_FORMAT_QUAD32 0x1206 -#define AL_FORMAT_REAR8 0x1207 -#define AL_FORMAT_REAR16 0x1208 -#define AL_FORMAT_REAR32 0x1209 -#define AL_FORMAT_51CHN8 0x120A -#define AL_FORMAT_51CHN16 0x120B -#define AL_FORMAT_51CHN32 0x120C -#define AL_FORMAT_61CHN8 0x120D -#define AL_FORMAT_61CHN16 0x120E -#define AL_FORMAT_61CHN32 0x120F -#define AL_FORMAT_71CHN8 0x1210 -#define AL_FORMAT_71CHN16 0x1211 -#define AL_FORMAT_71CHN32 0x1212 -#endif - -#ifndef AL_EXT_MULAW_MCFORMATS -#define AL_EXT_MULAW_MCFORMATS 1 -#define AL_FORMAT_MONO_MULAW 0x10014 -#define AL_FORMAT_STEREO_MULAW 0x10015 -#define AL_FORMAT_QUAD_MULAW 0x10021 -#define AL_FORMAT_REAR_MULAW 0x10022 -#define AL_FORMAT_51CHN_MULAW 0x10023 -#define AL_FORMAT_61CHN_MULAW 0x10024 -#define AL_FORMAT_71CHN_MULAW 0x10025 -#endif - -#ifndef AL_EXT_IMA4 -#define AL_EXT_IMA4 1 -#define AL_FORMAT_MONO_IMA4 0x1300 -#define AL_FORMAT_STEREO_IMA4 0x1301 -#endif - -#ifndef AL_EXT_STATIC_BUFFER -#define AL_EXT_STATIC_BUFFER 1 -typedef ALvoid (AL_APIENTRY*PFNALBUFFERDATASTATICPROC)(const ALint,ALenum,ALvoid*,ALsizei,ALsizei); -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alBufferDataStatic(const ALint buffer, ALenum format, ALvoid *data, ALsizei len, ALsizei freq); -#endif -#endif - -#ifndef ALC_EXT_EFX -#define ALC_EXT_EFX 1 -#include "efx.h" -#endif - -#ifndef ALC_EXT_disconnect -#define ALC_EXT_disconnect 1 -#define ALC_CONNECTED 0x313 -#endif - -#ifndef ALC_EXT_thread_local_context -#define ALC_EXT_thread_local_context 1 -typedef ALCboolean (ALC_APIENTRY*PFNALCSETTHREADCONTEXTPROC)(ALCcontext *context); -typedef ALCcontext* (ALC_APIENTRY*PFNALCGETTHREADCONTEXTPROC)(void); -#ifdef AL_ALEXT_PROTOTYPES -ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context); -ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void); -#endif -#endif - -#ifndef AL_EXT_source_distance_model -#define AL_EXT_source_distance_model 1 -#define AL_SOURCE_DISTANCE_MODEL 0x200 -#endif - -#ifndef AL_SOFT_buffer_sub_data -#define AL_SOFT_buffer_sub_data 1 -#define AL_BYTE_RW_OFFSETS_SOFT 0x1031 -#define AL_SAMPLE_RW_OFFSETS_SOFT 0x1032 -typedef ALvoid (AL_APIENTRY*PFNALBUFFERSUBDATASOFTPROC)(ALuint,ALenum,const ALvoid*,ALsizei,ALsizei); -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length); -#endif -#endif - -#ifndef AL_SOFT_loop_points -#define AL_SOFT_loop_points 1 -#define AL_LOOP_POINTS_SOFT 0x2015 -#endif - -#ifndef AL_EXT_FOLDBACK -#define AL_EXT_FOLDBACK 1 -#define AL_EXT_FOLDBACK_NAME "AL_EXT_FOLDBACK" -#define AL_FOLDBACK_EVENT_BLOCK 0x4112 -#define AL_FOLDBACK_EVENT_START 0x4111 -#define AL_FOLDBACK_EVENT_STOP 0x4113 -#define AL_FOLDBACK_MODE_MONO 0x4101 -#define AL_FOLDBACK_MODE_STEREO 0x4102 -typedef void (AL_APIENTRY*LPALFOLDBACKCALLBACK)(ALenum,ALsizei); -typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTART)(ALenum,ALsizei,ALsizei,ALfloat*,LPALFOLDBACKCALLBACK); -typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTOP)(void); -#ifdef AL_ALEXT_PROTOTYPES -AL_API void AL_APIENTRY alRequestFoldbackStart(ALenum mode,ALsizei count,ALsizei length,ALfloat *mem,LPALFOLDBACKCALLBACK callback); -AL_API void AL_APIENTRY alRequestFoldbackStop(void); -#endif -#endif - -#ifndef ALC_EXT_DEDICATED -#define ALC_EXT_DEDICATED 1 -#define AL_DEDICATED_GAIN 0x0001 -#define AL_EFFECT_DEDICATED_DIALOGUE 0x9001 -#define AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT 0x9000 -#endif - -#ifndef AL_SOFT_buffer_samples -#define AL_SOFT_buffer_samples 1 -/* Channel configurations */ -#define AL_MONO_SOFT 0x1500 -#define AL_STEREO_SOFT 0x1501 -#define AL_REAR_SOFT 0x1502 -#define AL_QUAD_SOFT 0x1503 -#define AL_5POINT1_SOFT 0x1504 -#define AL_6POINT1_SOFT 0x1505 -#define AL_7POINT1_SOFT 0x1506 - -/* Sample types */ -#define AL_BYTE_SOFT 0x1400 -#define AL_UNSIGNED_BYTE_SOFT 0x1401 -#define AL_SHORT_SOFT 0x1402 -#define AL_UNSIGNED_SHORT_SOFT 0x1403 -#define AL_INT_SOFT 0x1404 -#define AL_UNSIGNED_INT_SOFT 0x1405 -#define AL_FLOAT_SOFT 0x1406 -#define AL_DOUBLE_SOFT 0x1407 -#define AL_BYTE3_SOFT 0x1408 -#define AL_UNSIGNED_BYTE3_SOFT 0x1409 - -/* Storage formats */ -#define AL_MONO8_SOFT 0x1100 -#define AL_MONO16_SOFT 0x1101 -#define AL_MONO32F_SOFT 0x10010 -#define AL_STEREO8_SOFT 0x1102 -#define AL_STEREO16_SOFT 0x1103 -#define AL_STEREO32F_SOFT 0x10011 -#define AL_QUAD8_SOFT 0x1204 -#define AL_QUAD16_SOFT 0x1205 -#define AL_QUAD32F_SOFT 0x1206 -#define AL_REAR8_SOFT 0x1207 -#define AL_REAR16_SOFT 0x1208 -#define AL_REAR32F_SOFT 0x1209 -#define AL_5POINT1_8_SOFT 0x120A -#define AL_5POINT1_16_SOFT 0x120B -#define AL_5POINT1_32F_SOFT 0x120C -#define AL_6POINT1_8_SOFT 0x120D -#define AL_6POINT1_16_SOFT 0x120E -#define AL_6POINT1_32F_SOFT 0x120F -#define AL_7POINT1_8_SOFT 0x1210 -#define AL_7POINT1_16_SOFT 0x1211 -#define AL_7POINT1_32F_SOFT 0x1212 - -/* Buffer attributes */ -#define AL_INTERNAL_FORMAT_SOFT 0x2008 -#define AL_BYTE_LENGTH_SOFT 0x2009 -#define AL_SAMPLE_LENGTH_SOFT 0x200A -#define AL_SEC_LENGTH_SOFT 0x200B - -typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*); -typedef void (AL_APIENTRY*LPALBUFFERSUBSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*); -typedef void (AL_APIENTRY*LPALGETBUFFERSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*); -typedef ALboolean (AL_APIENTRY*LPALISBUFFERFORMATSUPPORTEDSOFT)(ALenum); -#ifdef AL_ALEXT_PROTOTYPES -AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, ALuint samplerate, ALenum internalformat, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data); -AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data); -AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, ALvoid *data); -AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format); -#endif -#endif - -#ifndef AL_SOFT_direct_channels -#define AL_SOFT_direct_channels 1 -#define AL_DIRECT_CHANNELS_SOFT 0x1033 -#endif - -#ifndef ALC_SOFT_loopback -#define ALC_SOFT_loopback 1 -#define ALC_FORMAT_CHANNELS_SOFT 0x1990 -#define ALC_FORMAT_TYPE_SOFT 0x1991 - -/* Sample types */ -#define ALC_BYTE_SOFT 0x1400 -#define ALC_UNSIGNED_BYTE_SOFT 0x1401 -#define ALC_SHORT_SOFT 0x1402 -#define ALC_UNSIGNED_SHORT_SOFT 0x1403 -#define ALC_INT_SOFT 0x1404 -#define ALC_UNSIGNED_INT_SOFT 0x1405 -#define ALC_FLOAT_SOFT 0x1406 - -/* Channel configurations */ -#define ALC_MONO_SOFT 0x1500 -#define ALC_STEREO_SOFT 0x1501 -#define ALC_QUAD_SOFT 0x1503 -#define ALC_5POINT1_SOFT 0x1504 -#define ALC_6POINT1_SOFT 0x1505 -#define ALC_7POINT1_SOFT 0x1506 - -typedef ALCdevice* (ALC_APIENTRY*LPALCLOOPBACKOPENDEVICESOFT)(const ALCchar*); -typedef ALCboolean (ALC_APIENTRY*LPALCISRENDERFORMATSUPPORTEDSOFT)(ALCdevice*,ALCsizei,ALCenum,ALCenum); -typedef void (ALC_APIENTRY*LPALCRENDERSAMPLESSOFT)(ALCdevice*,ALCvoid*,ALCsizei); -#ifdef AL_ALEXT_PROTOTYPES -ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceName); -ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type); -ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); -#endif -#endif - -#ifndef AL_EXT_STEREO_ANGLES -#define AL_EXT_STEREO_ANGLES 1 -#define AL_STEREO_ANGLES 0x1030 -#endif - -#ifndef AL_EXT_SOURCE_RADIUS -#define AL_EXT_SOURCE_RADIUS 1 -#define AL_SOURCE_RADIUS 0x1031 -#endif - -#ifndef AL_SOFT_source_latency -#define AL_SOFT_source_latency 1 -#define AL_SAMPLE_OFFSET_LATENCY_SOFT 0x1200 -#define AL_SEC_OFFSET_LATENCY_SOFT 0x1201 -typedef int64_t ALint64SOFT; -typedef uint64_t ALuint64SOFT; -typedef void (AL_APIENTRY*LPALSOURCEDSOFT)(ALuint,ALenum,ALdouble); -typedef void (AL_APIENTRY*LPALSOURCE3DSOFT)(ALuint,ALenum,ALdouble,ALdouble,ALdouble); -typedef void (AL_APIENTRY*LPALSOURCEDVSOFT)(ALuint,ALenum,const ALdouble*); -typedef void (AL_APIENTRY*LPALGETSOURCEDSOFT)(ALuint,ALenum,ALdouble*); -typedef void (AL_APIENTRY*LPALGETSOURCE3DSOFT)(ALuint,ALenum,ALdouble*,ALdouble*,ALdouble*); -typedef void (AL_APIENTRY*LPALGETSOURCEDVSOFT)(ALuint,ALenum,ALdouble*); -typedef void (AL_APIENTRY*LPALSOURCEI64SOFT)(ALuint,ALenum,ALint64SOFT); -typedef void (AL_APIENTRY*LPALSOURCE3I64SOFT)(ALuint,ALenum,ALint64SOFT,ALint64SOFT,ALint64SOFT); -typedef void (AL_APIENTRY*LPALSOURCEI64VSOFT)(ALuint,ALenum,const ALint64SOFT*); -typedef void (AL_APIENTRY*LPALGETSOURCEI64SOFT)(ALuint,ALenum,ALint64SOFT*); -typedef void (AL_APIENTRY*LPALGETSOURCE3I64SOFT)(ALuint,ALenum,ALint64SOFT*,ALint64SOFT*,ALint64SOFT*); -typedef void (AL_APIENTRY*LPALGETSOURCEI64VSOFT)(ALuint,ALenum,ALint64SOFT*); -#ifdef AL_ALEXT_PROTOTYPES -AL_API void AL_APIENTRY alSourcedSOFT(ALuint source, ALenum param, ALdouble value); -AL_API void AL_APIENTRY alSource3dSOFT(ALuint source, ALenum param, ALdouble value1, ALdouble value2, ALdouble value3); -AL_API void AL_APIENTRY alSourcedvSOFT(ALuint source, ALenum param, const ALdouble *values); -AL_API void AL_APIENTRY alGetSourcedSOFT(ALuint source, ALenum param, ALdouble *value); -AL_API void AL_APIENTRY alGetSource3dSOFT(ALuint source, ALenum param, ALdouble *value1, ALdouble *value2, ALdouble *value3); -AL_API void AL_APIENTRY alGetSourcedvSOFT(ALuint source, ALenum param, ALdouble *values); -AL_API void AL_APIENTRY alSourcei64SOFT(ALuint source, ALenum param, ALint64SOFT value); -AL_API void AL_APIENTRY alSource3i64SOFT(ALuint source, ALenum param, ALint64SOFT value1, ALint64SOFT value2, ALint64SOFT value3); -AL_API void AL_APIENTRY alSourcei64vSOFT(ALuint source, ALenum param, const ALint64SOFT *values); -AL_API void AL_APIENTRY alGetSourcei64SOFT(ALuint source, ALenum param, ALint64SOFT *value); -AL_API void AL_APIENTRY alGetSource3i64SOFT(ALuint source, ALenum param, ALint64SOFT *value1, ALint64SOFT *value2, ALint64SOFT *value3); -AL_API void AL_APIENTRY alGetSourcei64vSOFT(ALuint source, ALenum param, ALint64SOFT *values); -#endif -#endif - -#ifndef ALC_EXT_DEFAULT_FILTER_ORDER -#define ALC_EXT_DEFAULT_FILTER_ORDER 1 -#define ALC_DEFAULT_FILTER_ORDER 0x1100 -#endif - -#ifndef AL_SOFT_deferred_updates -#define AL_SOFT_deferred_updates 1 -#define AL_DEFERRED_UPDATES_SOFT 0xC002 -typedef ALvoid (AL_APIENTRY*LPALDEFERUPDATESSOFT)(void); -typedef ALvoid (AL_APIENTRY*LPALPROCESSUPDATESSOFT)(void); -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void); -AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void); -#endif -#endif - -#ifndef AL_SOFT_block_alignment -#define AL_SOFT_block_alignment 1 -#define AL_UNPACK_BLOCK_ALIGNMENT_SOFT 0x200C -#define AL_PACK_BLOCK_ALIGNMENT_SOFT 0x200D -#endif - -#ifndef AL_SOFT_MSADPCM -#define AL_SOFT_MSADPCM 1 -#define AL_FORMAT_MONO_MSADPCM_SOFT 0x1302 -#define AL_FORMAT_STEREO_MSADPCM_SOFT 0x1303 -#endif - -#ifndef AL_SOFT_source_length -#define AL_SOFT_source_length 1 -/*#define AL_BYTE_LENGTH_SOFT 0x2009*/ -/*#define AL_SAMPLE_LENGTH_SOFT 0x200A*/ -/*#define AL_SEC_LENGTH_SOFT 0x200B*/ -#endif - -#ifndef ALC_SOFT_pause_device -#define ALC_SOFT_pause_device 1 -typedef void (ALC_APIENTRY*LPALCDEVICEPAUSESOFT)(ALCdevice *device); -typedef void (ALC_APIENTRY*LPALCDEVICERESUMESOFT)(ALCdevice *device); -#ifdef AL_ALEXT_PROTOTYPES -ALC_API void ALC_APIENTRY alcDevicePauseSOFT(ALCdevice *device); -ALC_API void ALC_APIENTRY alcDeviceResumeSOFT(ALCdevice *device); -#endif -#endif - -#ifndef AL_EXT_BFORMAT -#define AL_EXT_BFORMAT 1 -#define AL_FORMAT_BFORMAT2D_8 0x20021 -#define AL_FORMAT_BFORMAT2D_16 0x20022 -#define AL_FORMAT_BFORMAT2D_FLOAT32 0x20023 -#define AL_FORMAT_BFORMAT3D_8 0x20031 -#define AL_FORMAT_BFORMAT3D_16 0x20032 -#define AL_FORMAT_BFORMAT3D_FLOAT32 0x20033 -#endif - -#ifndef AL_EXT_MULAW_BFORMAT -#define AL_EXT_MULAW_BFORMAT 1 -#define AL_FORMAT_BFORMAT2D_MULAW 0x10031 -#define AL_FORMAT_BFORMAT3D_MULAW 0x10032 -#endif - -#ifndef ALC_SOFT_HRTF -#define ALC_SOFT_HRTF 1 -#define ALC_HRTF_SOFT 0x1992 -#define ALC_DONT_CARE_SOFT 0x0002 -#define ALC_HRTF_STATUS_SOFT 0x1993 -#define ALC_HRTF_DISABLED_SOFT 0x0000 -#define ALC_HRTF_ENABLED_SOFT 0x0001 -#define ALC_HRTF_DENIED_SOFT 0x0002 -#define ALC_HRTF_REQUIRED_SOFT 0x0003 -#define ALC_HRTF_HEADPHONES_DETECTED_SOFT 0x0004 -#define ALC_HRTF_UNSUPPORTED_FORMAT_SOFT 0x0005 -#define ALC_NUM_HRTF_SPECIFIERS_SOFT 0x1994 -#define ALC_HRTF_SPECIFIER_SOFT 0x1995 -#define ALC_HRTF_ID_SOFT 0x1996 -typedef const ALCchar* (ALC_APIENTRY*LPALCGETSTRINGISOFT)(ALCdevice *device, ALCenum paramName, ALCsizei index); -typedef ALCboolean (ALC_APIENTRY*LPALCRESETDEVICESOFT)(ALCdevice *device, const ALCint *attribs); -#ifdef AL_ALEXT_PROTOTYPES -ALC_API const ALCchar* ALC_APIENTRY alcGetStringiSOFT(ALCdevice *device, ALCenum paramName, ALCsizei index); -ALC_API ALCboolean ALC_APIENTRY alcResetDeviceSOFT(ALCdevice *device, const ALCint *attribs); -#endif -#endif - -#ifndef AL_SOFT_gain_clamp_ex -#define AL_SOFT_gain_clamp_ex 1 -#define AL_GAIN_LIMIT_SOFT 0x200E -#endif - -#ifndef AL_SOFT_source_resampler -#define AL_SOFT_source_resampler -#define AL_NUM_RESAMPLERS_SOFT 0x1210 -#define AL_DEFAULT_RESAMPLER_SOFT 0x1211 -#define AL_SOURCE_RESAMPLER_SOFT 0x1212 -#define AL_RESAMPLER_NAME_SOFT 0x1213 -typedef const ALchar* (AL_APIENTRY*LPALGETSTRINGISOFT)(ALenum pname, ALsizei index); -#ifdef AL_ALEXT_PROTOTYPES -AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index); -#endif -#endif - -#ifndef AL_SOFT_source_spatialize -#define AL_SOFT_source_spatialize -#define AL_SOURCE_SPATIALIZE_SOFT 0x1214 -#define AL_AUTO_SOFT 0x0002 -#endif - -#ifndef ALC_SOFT_output_limiter -#define ALC_SOFT_output_limiter -#define ALC_OUTPUT_LIMITER_SOFT 0x199A -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Plugins/Audio/alure/AL/alure2-aliases.h b/Plugins/Audio/alure/AL/alure2-aliases.h deleted file mode 100644 index c21b897..0000000 --- a/Plugins/Audio/alure/AL/alure2-aliases.h +++ /dev/null @@ -1,85 +0,0 @@ -/********* - * Defines aliases for relevant STL containers. Be aware that even though these - * can be modified to use custom types, the library expects them to have - * standard APIs and semantics. Changing these aliases will also break ABI, so - * they should be left alone for shared builds unless all users are also - * rebuilt. - */ - -#ifndef AL_ALURE2_ALIASES_H -#define AL_ALURE2_ALIASES_H - -#include -#include -#include -#include -#include -#include - -namespace alure { - -// Convenience aliases -template using RemoveRefT = typename std::remove_reference::type; -template using EnableIfT = typename std::enable_if::type; - - -// NOTE: Need to define this as a macro since we can't use the aliased type -// names for explicit template instantiation, and the whole purpose of these -// aliases is to avoid respecifying the desired implementation. -#define ALURE_SHARED_PTR_TYPE std::shared_ptr - - -// Duration in seconds, using double precision -using Seconds = std::chrono::duration; - -// A SharedPtr implementation, defaults to C++11's std::shared_ptr. -template using SharedPtr = ALURE_SHARED_PTR_TYPE; -template -inline SharedPtr MakeShared(Args&&... args) -{ return std::make_shared(std::forward(args)...); } - -// A WeakPtr implementation, defaults to C++11's std::weak_ptr. -template using WeakPtr = std::weak_ptr; - -// A UniquePtr implementation, defaults to C++11's std::unique_ptr. -template using UniquePtr = std::unique_ptr; -// Implement MakeUnique for single objects and arrays. -namespace _details { - template - struct MakeUniq { using object = UniquePtr; }; - template - struct MakeUniq { using array = UniquePtr; }; - template - struct MakeUniq { struct invalid_type { }; }; -} // namespace _details -// MakeUnique for a single object. -template -inline typename _details::MakeUniq::object MakeUnique(Args&&... args) -{ return UniquePtr(new T(std::forward(args)...)); } -// MakeUnique for an array. -template -inline typename _details::MakeUniq::array MakeUnique(std::size_t num) -{ return UniquePtr(new typename std::remove_extent::type[num]()); } -// Disable MakeUnique for an array of declared size. -template -inline typename _details::MakeUniq::invalid_type MakeUnique(Args&&...) = delete; - -// A Promise/Future (+SharedFuture) implementation, defaults to C++11's -// std::promise, std::future, and std::shared_future. -template using Promise = std::promise; -template using Future = std::future; -template using SharedFuture = std::shared_future; - -// A Vector implementation, defaults to C++'s std::vector. -template using Vector = std::vector; - -// A static-sized Array implementation, defaults to C++11's std::array. -template using Array = std::array; - -// A String implementation, default's to C++'s std::string. -template using BasicString = std::basic_string; -using String = BasicString; - -} // namespace alure - -#endif /* AL_ALURE2_ALIASES_H */ diff --git a/Plugins/Audio/alure/AL/alure2-typeviews.h b/Plugins/Audio/alure/AL/alure2-typeviews.h deleted file mode 100644 index dd7373c..0000000 --- a/Plugins/Audio/alure/AL/alure2-typeviews.h +++ /dev/null @@ -1,248 +0,0 @@ -/********* - * Implements the classes alure::ArrayView (non-owning, read-only access to a - * contiguous array of elements), and alure::StringView (non-owning, read-only - * access to an array of chars). These help pass around contiguous arrays and - * strings from various sources without copying. - */ - -#ifndef AL_ALURE2_TYPEVIEWS_H -#define AL_ALURE2_TYPEVIEWS_H - -#include -#include -#include - -#include "alure2-aliases.h" - -namespace alure { - -// Tag specific containers that guarantee contiguous storage. The standard -// provides no such mechanism, so we have to manually specify which are -// acceptable. -template struct IsContiguousTag : std::false_type {}; -template struct IsContiguousTag> : std::true_type {}; -template struct IsContiguousTag> : std::true_type {}; -template struct IsContiguousTag> : std::true_type {}; - -// A rather simple ArrayView container. This allows accepting various array -// types (Array, Vector, a static-sized array, a dynamic array + size) without -// copying its elements. -template -class ArrayView { -public: - using value_type = T; - - using iterator = const value_type*; - using const_iterator = const value_type*; - - using reverse_iterator = std::reverse_iterator; - using const_reverse_iterator = std::reverse_iterator; - - using size_type = size_t; - - static constexpr size_type npos = static_cast(-1); - -private: - const value_type *mStart; - const value_type *mEnd; - -public: - ArrayView() noexcept : mStart(nullptr), mEnd(nullptr) { } - ArrayView(const ArrayView&) noexcept = default; - ArrayView(ArrayView&&) noexcept = default; - ArrayView(const value_type *elems, size_type num_elems) noexcept - : mStart(elems), mEnd(elems+num_elems) { } - // TODO: Allow this? As a function parameter, making a view to a temporary - // is fine since the temporary will exist for the duration of the call. - // It's just a problem when done as a local variable. - template ArrayView(RemoveRefT&&) = delete; - template>::value>> - ArrayView(const OtherT &rhs) noexcept : mStart(rhs.data()), mEnd(rhs.data()+rhs.size()) { } - template - ArrayView(const value_type (&elems)[N]) noexcept : mStart(elems), mEnd(elems+N) { } - - ArrayView& operator=(const ArrayView&) noexcept = default; - - const value_type *data() const noexcept { return mStart; } - - size_type size() const noexcept { return mEnd - mStart; } - bool empty() const noexcept { return mStart == mEnd; } - - const value_type& operator[](size_t i) const noexcept { return mStart[i]; } - - const value_type& front() const noexcept { return *mStart; } - const value_type& back() const noexcept { return *(mEnd - 1); } - - const value_type& at(size_t i) const - { - if(i >= size()) - throw std::out_of_range("alure::ArrayView::at: element out of range"); - return mStart[i]; - } - - const_iterator begin() const noexcept { return mStart; } - const_iterator cbegin() const noexcept { return mStart; } - - const_iterator end() const noexcept { return mEnd; } - const_iterator cend() const noexcept { return mEnd; } - - const_reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } - const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(cend()); } - - const_reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } - const_reverse_iterator crend() const noexcept { return const_reverse_iterator(cbegin()); } - - ArrayView slice(size_type pos, size_type len = npos) const - { - if(pos > size()) - throw std::out_of_range("alure::ArrayView::slice: pos out of range"); - if(size()-pos < len) return ArrayView(data()+pos, size()-pos); - return ArrayView(data()+pos, len); - } - - template - ArrayView reinterpret_as() const - { - // Make sure the current view is properly aligned to be interpreted as - // the new type. - if((reinterpret_cast(mStart) & (alignof(U)-1)) != 0) - throw std::runtime_error( - "alure::ArrayView::reinterpret_as: invalid alignment for type"); - - size_t new_length = - (reinterpret_cast(mEnd) - reinterpret_cast(mStart)) / - sizeof(U); - return ArrayView(reinterpret_cast(mStart), new_length); - } -}; - -template> -class BasicStringView : public ArrayView { -public: - using char_type = T; - using traits_type = Tr; - using size_type = size_t; - - static constexpr size_type npos = static_cast(-1); - - BasicStringView() noexcept = default; - BasicStringView(const BasicStringView&) noexcept = default; - BasicStringView(const char_type *elems, size_type num_elems) noexcept - : ArrayView(elems, num_elems) { } - BasicStringView(const char_type *elems) : ArrayView(elems, traits_type::length(elems)) { } - template - BasicStringView(BasicString&&) = delete; - template - BasicStringView(const BasicString &rhs) noexcept : ArrayView(rhs) { } -#if __cplusplus >= 201703L - BasicStringView(const std::basic_string_view &rhs) noexcept - : ArrayView(rhs.data(), rhs.length()) { } -#endif - - BasicStringView& operator=(const BasicStringView&) noexcept = default; - - size_type length() const noexcept { return this->size(); } - - template - explicit operator BasicString() const - { return BasicString(this->data(), length()); } -#if __cplusplus >= 201703L - operator std::basic_string_view() const noexcept - { return std::basic_string_view(this->data(), length()); } -#endif - - template - BasicString operator+(const BasicString &rhs) const - { - BasicString ret = BasicString(*this); - ret += rhs; - return ret; - } - - int compare(BasicStringView other) const noexcept - { - int ret = traits_type::compare( - this->data(), other.data(), std::min(length(), other.length()) - ); - if(ret == 0) - { - if(length() > other.length()) return 1; - if(length() < other.length()) return -1; - return 0; - } - return ret; - } - bool operator==(BasicStringView rhs) const noexcept { return compare(rhs) == 0; } - bool operator!=(BasicStringView rhs) const noexcept { return compare(rhs) != 0; } - bool operator<=(BasicStringView rhs) const noexcept { return compare(rhs) <= 0; } - bool operator>=(BasicStringView rhs) const noexcept { return compare(rhs) >= 0; } - bool operator<(BasicStringView rhs) const noexcept { return compare(rhs) < 0; } - bool operator>(BasicStringView rhs) const noexcept { return compare(rhs) > 0; } - - BasicStringView substr(size_type pos, size_type len = npos) const - { - if(pos > length()) - throw std::out_of_range("alure::BasicStringView::substr: pos out of range"); - if(length()-pos < len) return BasicStringView(this->data()+pos, length()-pos); - return BasicStringView(this->data()+pos, len); - } - - size_type find_first_of(char_type ch, size_type pos = 0) const noexcept - { - if(pos >= length()) return npos; - const char_type *chpos = traits_type::find(this->data()+pos, length()-pos, ch); - if(chpos) return chpos - this->data(); - return npos; - } - size_type find_first_of(BasicStringView other, size_type pos = 0) const noexcept - { - size_type ret = npos; - for(auto ch : other) - ret = std::min(ret, find_first_of(ch, pos)); - return ret; - } -}; -using StringView = BasicStringView; - -// Inline operators to concat Strings with StringViews. -template -inline BasicString operator+(const BasicString &lhs, BasicStringView rhs) -{ return BasicString(lhs).append(rhs.data(), rhs.size()); } -template -inline BasicString operator+(BasicString&& lhs, BasicStringView rhs) -{ return std::move(lhs.append(rhs.data(), rhs.size())); } -template -inline BasicString& operator+=(BasicString &lhs, BasicStringView rhs) -{ return lhs.append(rhs.data(), rhs.size()); } - -// Inline operators to compare String and C-style strings with StringViews. -#define ALURE_DECL_STROP(op) \ -template \ -inline bool operator op(const BasicString &lhs, \ - BasicStringView rhs) noexcept \ -{ return BasicStringView(lhs) op rhs; } \ -template \ -inline bool operator op(const typename BasicStringView::value_type *lhs, \ - BasicStringView rhs) \ -{ return BasicStringView(lhs) op rhs; } -ALURE_DECL_STROP(==) -ALURE_DECL_STROP(!=) -ALURE_DECL_STROP(<=) -ALURE_DECL_STROP(>=) -ALURE_DECL_STROP(<) -ALURE_DECL_STROP(>) -#undef ALURE_DECL_STROP - -// Inline operator to write out a StringView to an ostream -template -inline std::basic_ostream& operator<<(std::basic_ostream &lhs, BasicStringView rhs) -{ - for(auto ch : rhs) - lhs << ch; - return lhs; -} - -} // namespace alure - -#endif /* AL_ALURE2_TYPEVIEWS_H */ diff --git a/Plugins/Audio/alure/AL/alure2.h b/Plugins/Audio/alure/AL/alure2.h deleted file mode 100644 index f274b1d..0000000 --- a/Plugins/Audio/alure/AL/alure2.h +++ /dev/null @@ -1,1622 +0,0 @@ -#ifndef AL_ALURE2_H -#define AL_ALURE2_H - -#include -#include -#include -#include - -#include "../alc.h" -#include "../al.h" -#include "alure2-alext.h" - -#include "alure2-aliases.h" -#include "alure2-typeviews.h" - -#ifndef ALURE_API - #ifndef ALURE_STATIC_LIB - #if defined(_WIN32) - #define ALURE_API __declspec(dllimport) - #elif defined(__has_attribute) - #if __has_attribute(visibility) - #define ALURE_API __attribute__((visibility("default"))) - #endif - #elif defined(__GNUC__) - #define ALURE_API __attribute__((visibility("default"))) - #endif - #endif - #ifndef ALURE_API - #define ALURE_API - #endif -#endif /* ALURE_API */ -#ifndef ALURE_TEMPLATE - #ifndef ALURE_STATIC_LIB - #define ALURE_TEMPLATE extern template - #else - #define ALURE_TEMPLATE template - #endif -#endif /* ALURE_TEMPLATE */ - -#ifndef EFXEAXREVERBPROPERTIES_DEFINED -#define EFXEAXREVERBPROPERTIES_DEFINED -typedef struct { - float flDensity; - float flDiffusion; - float flGain; - float flGainHF; - float flGainLF; - float flDecayTime; - float flDecayHFRatio; - float flDecayLFRatio; - float flReflectionsGain; - float flReflectionsDelay; - float flReflectionsPan[3]; - float flLateReverbGain; - float flLateReverbDelay; - float flLateReverbPan[3]; - float flEchoTime; - float flEchoDepth; - float flModulationTime; - float flModulationDepth; - float flAirAbsorptionGainHF; - float flHFReference; - float flLFReference; - float flRoomRolloffFactor; - int iDecayHFLimit; -} EFXEAXREVERBPROPERTIES, *LPEFXEAXREVERBPROPERTIES; -#endif - -#ifndef EFXCHORUSPROPERTIES_DEFINED -#define EFXCHORUSPROPERTIES_DEFINED -typedef struct { - int iWaveform; - int iPhase; - float flRate; - float flDepth; - float flFeedback; - float flDelay; -} EFXCHORUSPROPERTIES, *LPEFXCHORUSPROPERTIES; -#endif - -namespace alure { - -// Available class interfaces. -class DeviceManager; -class Device; -class Context; -class Listener; -class Buffer; -class Source; -class SourceGroup; -class AuxiliaryEffectSlot; -class Effect; -class Decoder; -class DecoderFactory; -class FileIOFactory; -class MessageHandler; - -// Opaque class implementations. -class DeviceManagerImpl; -class DeviceImpl; -class ContextImpl; -class ListenerImpl; -class BufferImpl; -class SourceImpl; -class SourceGroupImpl; -class AuxiliaryEffectSlotImpl; -class EffectImpl; - -} - -#ifndef ALURE_STATIC_LIB -/****** Explicitly instantiate templates used by the lib ******/ -ALURE_TEMPLATE class ALURE_API ALURE_SHARED_PTR_TYPE; -/******/ -#endif - -namespace alure { - -/** Convert a value from decibels to linear gain. */ -inline float dBToLinear(float value) { return std::pow(10.0f, value / 20.0f); } -inline double dBToLinear(double value) { return std::pow(10.0, value / 20.0); } -inline double dBToLinear(int value) { return dBToLinear(double(value)); } - -/** Convert a value from linear gain to decibels. */ -inline float LinearTodB(float value) { return std::log10(value) * 20.0f; } -inline double LinearTodB(double value) { return std::log10(value) * 20.0; } - -/** - * An attribute pair, for passing attributes to Device::createContext and - * Device::reset. - */ -struct AttributePair { - ALCint mAttribute; - ALCint mValue; -}; -static_assert(sizeof(AttributePair) == sizeof(ALCint[2]), "Bad AttributePair size"); -inline AttributePair AttributesEnd() noexcept { return AttributePair{0, 0}; } - - -struct FilterParams { - ALfloat mGain; - ALfloat mGainHF; // For low-pass and band-pass filters - ALfloat mGainLF; // For high-pass and band-pass filters -}; - - -class Vector3 { - Array mValue; - -public: - constexpr Vector3() noexcept - : mValue{{0.0f, 0.0f, 0.0f}} - { } - constexpr Vector3(const Vector3 &rhs) noexcept - : mValue{{rhs.mValue[0], rhs.mValue[1], rhs.mValue[2]}} - { } - constexpr Vector3(ALfloat val) noexcept - : mValue{{val, val, val}} - { } - constexpr Vector3(ALfloat x, ALfloat y, ALfloat z) noexcept - : mValue{{x, y, z}} - { } - Vector3(const ALfloat *vec) noexcept - : mValue{{vec[0], vec[1], vec[2]}} - { } - - const ALfloat *getPtr() const noexcept - { return mValue.data(); } - - ALfloat& operator[](size_t i) noexcept - { return mValue[i]; } - constexpr const ALfloat& operator[](size_t i) const noexcept - { return mValue[i]; } - -#define ALURE_DECL_OP(op) \ - constexpr Vector3 operator op(const Vector3 &rhs) const noexcept \ - { \ - return Vector3(mValue[0] op rhs.mValue[0], \ - mValue[1] op rhs.mValue[1], \ - mValue[2] op rhs.mValue[2]); \ - } - ALURE_DECL_OP(+) - ALURE_DECL_OP(-) - ALURE_DECL_OP(*) - ALURE_DECL_OP(/) -#undef ALURE_DECL_OP -#define ALURE_DECL_OP(op) \ - Vector3& operator op(const Vector3 &rhs) noexcept \ - { \ - mValue[0] op rhs.mValue[0]; \ - mValue[1] op rhs.mValue[1]; \ - mValue[2] op rhs.mValue[2]; \ - return *this; \ - } - ALURE_DECL_OP(+=) - ALURE_DECL_OP(-=) - ALURE_DECL_OP(*=) - ALURE_DECL_OP(/=) - -#undef ALURE_DECL_OP -#define ALURE_DECL_OP(op) \ - constexpr Vector3 operator op(ALfloat scale) const noexcept \ - { \ - return Vector3(mValue[0] op scale, \ - mValue[1] op scale, \ - mValue[2] op scale); \ - } - ALURE_DECL_OP(*) - ALURE_DECL_OP(/) -#undef ALURE_DECL_OP -#define ALURE_DECL_OP(op) \ - Vector3& operator op(ALfloat scale) noexcept \ - { \ - mValue[0] op scale; \ - mValue[1] op scale; \ - mValue[2] op scale; \ - return *this; \ - } - ALURE_DECL_OP(*=) - ALURE_DECL_OP(/=) -#undef ALURE_DECL_OP - - constexpr ALfloat getLengthSquared() const noexcept - { return mValue[0]*mValue[0] + mValue[1]*mValue[1] + mValue[2]*mValue[2]; } - ALfloat getLength() const noexcept - { return std::sqrt(getLengthSquared()); } - - constexpr ALfloat getDistanceSquared(const Vector3 &pos) const noexcept - { return (pos - *this).getLengthSquared(); } - ALfloat getDistance(const Vector3 &pos) const noexcept - { return (pos - *this).getLength(); } -}; -static_assert(sizeof(Vector3) == sizeof(ALfloat[3]), "Bad Vector3 size"); - - -enum class SampleType { - UInt8, - Int16, - Float32, - Mulaw -}; -ALURE_API const char *GetSampleTypeName(SampleType type); - -enum class ChannelConfig { - /** 1-channel mono sound. */ - Mono, - /** 2-channel stereo sound. */ - Stereo, - /** 2-channel rear sound (back-left and back-right). */ - Rear, - /** 4-channel surround sound. */ - Quad, - /** 5.1 surround sound. */ - X51, - /** 6.1 surround sound. */ - X61, - /** 7.1 surround sound. */ - X71, - /** 3-channel B-Format, using FuMa channel ordering and scaling. */ - BFormat2D, - /** 4-channel B-Format, using FuMa channel ordering and scaling. */ - BFormat3D -}; -ALURE_API const char *GetChannelConfigName(ChannelConfig cfg); - -ALURE_API ALuint FramesToBytes(ALuint frames, ChannelConfig chans, SampleType type); -ALURE_API ALuint BytesToFrames(ALuint bytes, ChannelConfig chans, SampleType type) noexcept; - - -/** Class for storing a major.minor version number. */ -class Version { - ALuint mMajor : 16; - ALuint mMinor : 16; - -public: - constexpr Version() noexcept : mMajor(0), mMinor(0) { } - constexpr Version(ALuint _maj, ALuint _min) noexcept : mMajor(_maj), mMinor(_min) { } - constexpr Version(const Version&) noexcept = default; - - constexpr ALuint getMajor() const noexcept { return mMajor; } - constexpr ALuint getMinor() const noexcept { return mMinor; } - - constexpr bool operator==(const Version &rhs) const noexcept - { return mMajor == rhs.mMajor && mMinor == rhs.mMinor; } - constexpr bool operator!=(const Version &rhs) const noexcept - { return !(*this == rhs); } - constexpr bool operator<=(const Version &rhs) const noexcept - { return mMajor < rhs.mMajor || (mMajor == rhs.mMajor && mMinor <= rhs.mMinor); } - constexpr bool operator>=(const Version &rhs) const noexcept - { return mMajor > rhs.mMajor || (mMajor == rhs.mMajor && mMinor >= rhs.mMinor); } - constexpr bool operator<(const Version &rhs) const noexcept - { return mMajor < rhs.mMajor || (mMajor == rhs.mMajor && mMinor < rhs.mMinor); } - constexpr bool operator>(const Version &rhs) const noexcept - { return mMajor > rhs.mMajor || (mMajor == rhs.mMajor && mMinor > rhs.mMinor); } - - constexpr bool isZero() const noexcept { return *this == Version{0,0}; } -}; - - -// Tag type to disctate which types are allowed in AutoObj. -template struct IsAutoable : std::false_type { }; -template<> struct IsAutoable : std::true_type { }; -template<> struct IsAutoable : std::true_type { }; -template<> struct IsAutoable : std::true_type { }; -template<> struct IsAutoable : std::true_type { }; -template<> struct IsAutoable : std::true_type { }; -template<> struct IsAutoable : std::true_type { }; - -/** - * A local storage container to manage objects in a non-copyable, movable, and - * auto-destructed manner. Any contained object will have its destroy() method - * invoked prior to being overwritten or when going out of scope. The purpose - * of this is to optionally provide RAII semantics to Alure's resources, such - * as contexts, sources, and effects. - * - * Be aware that destruction order is important, as contexts ultimately "own" - * the resources created from them. Said resources automatically become invalid - * when their owning context is destroyed. Any AutoObjs containing sources, - * effects, etc, should already be destroyed or cleared prior to the context - * being destroyed. - * - * Also, it is possible for resource destruction to fail if the destroy() - * method is called incorrectly (e.g. destroying a source when a different - * context is current). This normally results in an exception, but because - * destructors aren't allowed to let exceptions leave the function body, - * std::terminate will be called as a fatal error instead. - */ -template -class AutoObj { - static_assert(IsAutoable::value, "Invalid type for AutoObj"); - - T mObj; - - template - EnableIfT::value,AutoObj&> do_reset(const U &obj={}) - { - if(mObj) mObj.destroy(); - mObj = obj; - return *this; - } - template - EnableIfT::value,AutoObj&> do_reset(const U &obj={}) - { - if(mObj) mObj.close(); - mObj = obj; - return *this; - } - -public: - using element_type = T; - - AutoObj() noexcept = default; - AutoObj(const AutoObj&) = delete; - AutoObj(AutoObj &&rhs) noexcept : mObj(rhs.mObj) { rhs.mObj = nullptr; } - AutoObj(std::nullptr_t) noexcept : mObj(nullptr) { } - explicit AutoObj(const element_type &rhs) noexcept : mObj(rhs) { } - ~AutoObj() { do_reset(); } - - AutoObj& operator=(const AutoObj&) = delete; - AutoObj& operator=(AutoObj &&rhs) - { - do_reset(rhs.mObj); - rhs.mObj = nullptr; - return *this; - } - - AutoObj& reset(const element_type &obj) { return do_reset(obj); } - - element_type release() noexcept - { - element_type ret = mObj; - mObj = nullptr; - return ret; - } - - element_type& get() noexcept { return mObj; } - - element_type& operator*() noexcept { return mObj; } - element_type* operator->() noexcept { return &mObj; } - - operator bool() const noexcept { return static_cast(mObj); } -}; - -/** Creates an AutoObj for the given input object type. */ -template -inline AutoObj MakeAuto(const T &obj) { return AutoObj(obj); } - - -enum class DeviceEnumeration { - Basic = ALC_DEVICE_SPECIFIER, - Full = ALC_ALL_DEVICES_SPECIFIER, - Capture = ALC_CAPTURE_DEVICE_SPECIFIER -}; - -enum class DefaultDeviceType { - Basic = ALC_DEFAULT_DEVICE_SPECIFIER, - Full = ALC_DEFAULT_ALL_DEVICES_SPECIFIER, - Capture = ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER -}; - -/** - * A class managing Device objects and other related functionality. This class - * is a singleton, only one instance will exist in a process at a time. - */ -class ALURE_API DeviceManager { - SharedPtr pImpl; - - DeviceManager(SharedPtr&& impl) noexcept; - -public: - /** - * Retrieves a reference-counted DeviceManager instance. When the last - * reference goes out of scope, the DeviceManager and any remaining managed - * resources are automatically cleaned up. Multiple calls will return the - * same instance as long as there is still a pre-existing reference to the - * instance, or else a new instance will be created. - */ - static DeviceManager getInstance(); - - DeviceManager() noexcept = default; - DeviceManager(const DeviceManager&) noexcept = default; - DeviceManager(DeviceManager&& rhs) noexcept = default; - ~DeviceManager(); - - DeviceManager& operator=(const DeviceManager&) noexcept = default; - DeviceManager& operator=(DeviceManager&&) noexcept = default; - DeviceManager& operator=(std::nullptr_t) noexcept { pImpl = nullptr; return *this; }; - - operator bool() const noexcept { return pImpl != nullptr; } - - /** Queries the existence of a non-device-specific ALC extension. */ - bool queryExtension(const String &name) const; - bool queryExtension(const char *name) const; - - /** Enumerates available device names of the given type. */ - Vector enumerate(DeviceEnumeration type) const; - /** Retrieves the default device of the given type. */ - String defaultDeviceName(DefaultDeviceType type) const; - - /** - * Opens the playback device given by name, or the default if blank. Throws - * an exception on error. - */ - Device openPlayback(const String &name={}); - Device openPlayback(const char *name); - - /** - * Opens the playback device given by name, or the default if blank. - * Returns an empty Device on error. - */ - Device openPlayback(const String &name, const std::nothrow_t&) noexcept; - Device openPlayback(const char *name, const std::nothrow_t&) noexcept; - - /** Opens the default playback device. Returns an empty Device on error. */ - Device openPlayback(const std::nothrow_t&) noexcept; -}; - - -#define MAKE_PIMPL(BaseT, ImplT) \ -private: \ - ImplT *pImpl; \ - \ -public: \ - using handle_type = ImplT*; \ - \ - BaseT() noexcept : pImpl(nullptr) { } \ - BaseT(ImplT *impl) noexcept : pImpl(impl) { } \ - BaseT(const BaseT&) noexcept = default; \ - BaseT(BaseT&& rhs) noexcept : pImpl(rhs.pImpl) { rhs.pImpl = nullptr; } \ - \ - BaseT& operator=(const BaseT&) noexcept = default; \ - BaseT& operator=(BaseT&& rhs) noexcept \ - { \ - pImpl = rhs.pImpl; rhs.pImpl = nullptr; \ - return *this; \ - } \ - \ - bool operator==(const BaseT &rhs) const noexcept \ - { return pImpl == rhs.pImpl; } \ - bool operator!=(const BaseT &rhs) const noexcept \ - { return pImpl != rhs.pImpl; } \ - bool operator<=(const BaseT &rhs) const noexcept \ - { return pImpl <= rhs.pImpl; } \ - bool operator>=(const BaseT &rhs) const noexcept \ - { return pImpl >= rhs.pImpl; } \ - bool operator<(const BaseT &rhs) const noexcept \ - { return pImpl < rhs.pImpl; } \ - bool operator>(const BaseT &rhs) const noexcept \ - { return pImpl > rhs.pImpl; } \ - \ - operator bool() const noexcept { return !!pImpl; } \ - \ - handle_type getHandle() const noexcept { return pImpl; } - -enum class PlaybackName { - Basic = ALC_DEVICE_SPECIFIER, - Full = ALC_ALL_DEVICES_SPECIFIER -}; - -class ALURE_API Device { - MAKE_PIMPL(Device, DeviceImpl) - -public: - /** Retrieves the device name as given by type. */ - String getName(PlaybackName type=PlaybackName::Full) const; - /** Queries the existence of an ALC extension on this device. */ - bool queryExtension(const String &name) const; - bool queryExtension(const char *name) const; - - /** Retrieves the ALC version supported by this device. */ - Version getALCVersion() const; - - /** - * Retrieves the EFX version supported by this device. If the ALC_EXT_EFX - * extension is unsupported, this will be 0.0. - */ - Version getEFXVersion() const; - - /** Retrieves the device's playback frequency, in hz. */ - ALCuint getFrequency() const; - - /** - * Retrieves the maximum number of auxiliary source sends. If ALC_EXT_EFX - * is unsupported, this will be 0. - */ - ALCuint getMaxAuxiliarySends() const; - - /** - * Enumerates available HRTF names. The names are sorted as OpenAL gives - * them, such that the index of a given name is the ID to use with - * ALC_HRTF_ID_SOFT. - * - * If the ALC_SOFT_HRTF extension is unavailable, this will return an empty - * vector. - */ - Vector enumerateHRTFNames() const; - - /** - * Retrieves whether HRTF is enabled on the device or not. - * - * If the ALC_SOFT_HRTF extension is unavailable, this will return false - * although there could still be HRTF applied at a lower hardware level. - */ - bool isHRTFEnabled() const; - - /** - * Retrieves the name of the HRTF currently being used by this device. - * - * If HRTF is not currently enabled, this will be empty. - */ - String getCurrentHRTF() const; - - /** - * Resets the device, using the specified attributes. - * - * If the ALC_SOFT_HRTF extension is unavailable, this will be a no-op. - */ - void reset(ArrayView attributes); - - /** - * Creates a new Context on this device, using the specified attributes. - * Throws an exception if context creation fails. - */ - Context createContext(ArrayView attributes={}); - /** - * Creates a new Context on this device, using the specified attributes. - * Returns an empty Context if context creation fails. - */ - Context createContext(ArrayView attributes, const std::nothrow_t&) noexcept; - Context createContext(const std::nothrow_t&) noexcept; - - /** - * Pauses device processing, stopping updates for its contexts. Multiple - * calls are allowed but it is not reference counted, so the device will - * resume after one resumeDSP call. - * - * Requires the ALC_SOFT_pause_device extension. - */ - void pauseDSP(); - - /** - * Resumes device processing, restarting updates for its contexts. Multiple - * calls are allowed and will no-op. - */ - void resumeDSP(); - - /** - * Retrieves the current clock time for the device. This starts relative to - * the device being opened, and does not increment while there are no - * contexts nor while processing is paused. This is currently based on - * std::chrono::steady_clock, and so may not exactly match the rate that - * sources play at. In the future it may utilize an OpenAL extension to - * retrieve the audio device's real clock which may tic at a subtly - * different rate than the main clock(s). - */ - std::chrono::nanoseconds getClockTime(); - - /** - * Closes and frees the device. All previously-created contexts must first - * be destroyed. - */ - void close(); -}; - - -enum class DistanceModel { - InverseClamped = AL_INVERSE_DISTANCE_CLAMPED, - LinearClamped = AL_LINEAR_DISTANCE_CLAMPED, - ExponentClamped = AL_EXPONENT_DISTANCE_CLAMPED, - Inverse = AL_INVERSE_DISTANCE, - Linear = AL_LINEAR_DISTANCE, - Exponent = AL_EXPONENT_DISTANCE, - None = AL_NONE, -}; - -class ALURE_API Context { - MAKE_PIMPL(Context, ContextImpl) - -public: - /** Makes the specified context current for OpenAL operations. */ - static void MakeCurrent(Context context); - /** Retrieves the current context used for OpenAL operations. */ - static Context GetCurrent(); - - /** - * Makes the specified context current for OpenAL operations on the calling - * thread only. Requires the ALC_EXT_thread_local_context extension on both - * the context's device and the DeviceManager. - */ - static void MakeThreadCurrent(Context context); - /** Retrieves the thread-specific context used for OpenAL operations. */ - static Context GetThreadCurrent(); - - /** - * Destroys the context. The context must not be current when this is - * called. - */ - void destroy(); - - /** Retrieves the Device this context was created from. */ - Device getDevice(); - - void startBatch(); - void endBatch(); - - /** - * Retrieves a Listener instance for this context. Each context will only - * have one listener, which is automatically destroyed with the context. - */ - Listener getListener(); - - /** - * Sets a MessageHandler instance which will be used to provide certain - * messages back to the application. Only one handler may be set for a - * context at a time. The previously set handler will be returned. - */ - SharedPtr setMessageHandler(SharedPtr handler); - - /** Gets the currently-set message handler. */ - SharedPtr getMessageHandler() const; - - /** - * Specifies the desired interval that the background thread will be woken - * up to process tasks, e.g. keeping streaming sources filled. An interval - * of 0 means the background thread will only be woken up manually with - * calls to update. The default is 0. - */ - void setAsyncWakeInterval(std::chrono::milliseconds interval); - - /** - * Retrieves the current interval used for waking up the background thread. - */ - std::chrono::milliseconds getAsyncWakeInterval() const; - - // Functions below require the context to be current - - /** - * Creates a Decoder instance for the given audio file or resource name. - */ - SharedPtr createDecoder(StringView name); - - /** - * Queries if the channel configuration and sample type are supported by - * the context. - */ - bool isSupported(ChannelConfig channels, SampleType type) const; - - /** - * Queries the list of resamplers supported by the context. If the - * AL_SOFT_source_resampler extension is unsupported this will be an empty - * array, otherwise there will be at least one entry. - */ - ArrayView getAvailableResamplers(); - /** - * Queries the context's default resampler index. Be aware, if the - * AL_SOFT_source_resampler extension is unsupported the resampler list - * will be empty and this will resturn 0. If you try to access the - * resampler list with this index without the extension, undefined behavior - * will occur (accessing an out of bounds array index). - */ - ALsizei getDefaultResamplerIndex() const; - - /** - * Creates and caches a Buffer for the given audio file or resource name. - * Multiple calls with the same name will return the same Buffer object. - * Cached buffers must be freed using removeBuffer before destroying the - * context. If the buffer can't be loaded it will throw an exception. - */ - Buffer getBuffer(StringView name); - - /** - * Asynchronously prepares a cached Buffer for the given audio file or - * resource name. Multiple calls with the same name will return multiple - * SharedFutures for the same Buffer object. Once called, the buffer must - * be freed using removeBuffer before destroying the context, even if you - * never get the Buffer from the SharedFuture. - * - * The Buffer will be scheduled to load asynchronously, and the caller gets - * back a SharedFuture that can be checked later (or waited on) to get the - * actual Buffer when it's ready. The application must take care to handle - * exceptions from the SharedFuture in case an unrecoverable error ocurred - * during the load. - * - * If the Buffer is already fully loaded and cached, a SharedFuture is - * returned in a ready state containing it. - */ - SharedFuture getBufferAsync(StringView name); - - /** - * Asynchronously prepares cached Buffers for the given audio file or - * resource names. Duplicate names and buffers already cached are ignored. - * Cached buffers must be freed using removeBuffer before destroying the - * context. - * - * The Buffer objects will be scheduled for loading asynchronously, and - * should be retrieved later when needed using getBufferAsync or getBuffer. - * Buffers that cannot be loaded, for example due to an unsupported format, - * will be ignored and a later call to getBuffer or getBufferAsync will - * throw an exception. - */ - void precacheBuffersAsync(ArrayView names); - - /** - * Creates and caches a Buffer using the given name by reading the given - * decoder. The name may alias an audio file, but it must not currently - * exist in the buffer cache. - */ - Buffer createBufferFrom(StringView name, SharedPtr decoder); - - /** - * Asynchronously prepares a cached Buffer using the given name by reading - * the given decoder. The name may alias an audio file, but it must not - * currently exist in the buffer cache. Once called, the buffer must be - * freed using removeBuffer before destroying the context, even if you - * never get the Buffer from the SharedFuture. - * - * The Buffer will be scheduled to load asynchronously, and the caller gets - * back a SharedFuture that can be checked later (or waited on) to get the - * actual Buffer when it's ready. The application must take care to handle - * exceptions from the SharedFuture in case an unrecoverable error ocurred - * during the load. The decoder must not have its read or seek methods - * called while the buffer is not ready. - */ - SharedFuture createBufferAsyncFrom(StringView name, SharedPtr decoder); - - /** - * Looks for a cached buffer using the given name and returns it. If the - * given name does not exist in the cache, a null buffer is returned. - */ - Buffer findBuffer(StringView name); - - /** - * Looks for an asynchronously-loading buffer using the given name and - * returns a SharedFuture for it. If the given name does not exist in the - * cache, an invalid SharedFuture is returned (check with a call to - * \c SharedFuture::valid). - * - * If the Buffer is already fully loaded and cached, a SharedFuture is - * returned in a ready state containing it. - */ - SharedFuture findBufferAsync(StringView name); - - /** - * Deletes the cached Buffer object for the given audio file or resource - * name, invalidating all Buffer objects with this name. If a source is - * currently playing the buffer, it will be stopped first. - */ - void removeBuffer(StringView name); - /** - * Deletes the given cached buffer, invalidating all other Buffer objects - * with the same name. Equivalent to calling - * removeBuffer(buffer.getName()). - */ - void removeBuffer(Buffer buffer); - - /** - * Creates a new Source for playing audio. There is no practical limit to - * the number of sources you may create. You must call Source::destroy when - * the source is no longer needed. - */ - Source createSource(); - - AuxiliaryEffectSlot createAuxiliaryEffectSlot(); - - Effect createEffect(); - - SourceGroup createSourceGroup(); - - /** Sets the doppler factor to apply to all source doppler calculations. */ - void setDopplerFactor(ALfloat factor); - - /** - * Sets the speed of sound propagation, in units per second, to calculate - * the doppler effect along with other distance-related time effects. The - * default is 343.3 units per second (a realistic speed assuming 1 meter - * per unit). If this is adjusted for a different unit scale, - * Listener::setMetersPerUnit should also be adjusted. - */ - void setSpeedOfSound(ALfloat speed); - - /** - * Sets the distance model used to attenuate sources given their distance - * from the listener. The default, InverseClamped, provides a realistic 1/r - * reduction in volume (that is, every doubling of distance causes the gain - * to reduce by half). - * - * The Clamped distance models restrict the source distance for the purpose - * of distance attenuation, so a source won't sound closer than its - * reference distance or farther than its max distance. - */ - void setDistanceModel(DistanceModel model); - - /** Updates the context and all sources belonging to this context. */ - void update(); -}; - -class ALURE_API Listener { - MAKE_PIMPL(Listener, ListenerImpl) - -public: - /** Sets the "master" gain for all context output. */ - void setGain(ALfloat gain); - - /** - * Specifies the listener's 3D position, velocity, and orientation - * together (see: setPosition, setVelocity, and setOrientation). - */ - void set3DParameters(const Vector3 &position, const Vector3 &velocity, const std::pair &orientation); - - /** Specifies the listener's 3D position. */ - void setPosition(const Vector3 &position); - void setPosition(const ALfloat *pos); - - /** - * Specifies the listener's 3D velocity, in units per second. As with - * OpenAL, this does not actually alter the listener's position, and - * instead just alters the pitch as determined by the doppler effect. - */ - void setVelocity(const Vector3 &velocity); - void setVelocity(const ALfloat *vel); - - /** - * Specifies the listener's 3D orientation, using position-relative 'at' - * and 'up' direction vectors. - */ - void setOrientation(const std::pair &orientation); - void setOrientation(const ALfloat *at, const ALfloat *up); - void setOrientation(const ALfloat *ori); - - /** - * Sets the number of meters per unit, used for various effects that rely - * on the distance in meters including air absorption and initial reverb - * decay. If this is changed, it's strongly recommended to also set the - * speed of sound (e.g. context.setSpeedOfSound(343.3 / m_u) to maintain a - * realistic 343.3m/s for sound propagation). - */ - void setMetersPerUnit(ALfloat m_u); -}; - - -class ALURE_API Buffer { - MAKE_PIMPL(Buffer, BufferImpl) - -public: - /** Retrieves the length of the buffer in sample frames. */ - ALuint getLength() const; - - /** Retrieves the buffer's frequency in hz. */ - ALuint getFrequency() const; - - /** Retrieves the buffer's sample configuration. */ - ChannelConfig getChannelConfig() const; - - /** Retrieves the buffer's sample type. */ - SampleType getSampleType() const; - - /** - * Retrieves the storage size used by the buffer, in bytes. Note that the - * size in bytes may not be what you expect from the length, as it may take - * more space internally than the ChannelConfig and SampleType suggest to - * be more efficient. - */ - ALuint getSize() const; - - /** - * Sets the buffer's loop points, used for looping sources. If the current - * context does not support the AL_SOFT_loop_points extension, start and - * end must be 0 and getLength() respectively. Otherwise, start must be - * less than end, and end must be less than or equal to getLength(). - * - * The buffer must not be in use when this method is called. - * - * \param start The starting point, in sample frames (inclusive). - * \param end The ending point, in sample frames (exclusive). - */ - void setLoopPoints(ALuint start, ALuint end); - - /** Retrieves the current loop points as a [start,end) pair. */ - std::pair getLoopPoints() const; - - /** Retrieves the Source objects currently playing the buffer. */ - Vector getSources() const; - - /** Retrieves the name the buffer was created with. */ - StringView getName() const; - - /** - * Queries the number of sources currently using the buffer. Be aware that - * you need to call \c Context::update to reliably ensure the count is kept - * updated for when sources reach their end. This is equivalent to calling - * getSources().size(). - */ - size_t getSourceCount() const; -}; - - -enum class Spatialize { - Off = AL_FALSE, - On = AL_TRUE, - Auto = 0x0002 /* AL_AUTO_SOFT */ -}; - -class ALURE_API Source { - MAKE_PIMPL(Source, SourceImpl) - -public: - /** - * Plays the source using a buffer. The same buffer may be played from - * multiple sources simultaneously. - */ - void play(Buffer buffer); - /** - * Plays the source by asynchronously streaming audio from a decoder. The - * given decoder must *NOT* have its read or seek methods called from - * elsewhere while in use. - * - * \param decoder The decoder object to play audio from. - * \param chunk_len The number of sample frames to read for each chunk - * update. Smaller values will require more frequent updates and - * larger values will handle more data with each chunk. - * \param queue_size The number of chunks to keep queued during playback. - * Smaller values use less memory while larger values improve - * protection against underruns. - */ - void play(SharedPtr decoder, ALsizei chunk_len, ALsizei queue_size); - - /** - * Prepares to play a source using a future buffer. The method will return - * right away and the source will begin playing once the future buffer - * becomes ready. If the future buffer is already ready, it begins playing - * immediately as if you called play(future_buffer.get()). - * - * The future buffer is checked during calls to \c Context::update and the - * source will start playback once the future buffer reports it's ready. - * Use the isPending method to check if the source is still waiting for the - * future buffer. - */ - void play(SharedFuture future_buffer); - - /** - * Stops playback, releasing the buffer or decoder reference. Any pending - * playback from a future buffer is canceled. - */ - void stop(); - - /** - * Fades the source to the specified gain over the given duration, at which - * point playback will stop. This gain is in addition to the base gain, and - * must be greater than 0 and less than 1. The duration must also be - * greater than 0. - * - * The fading is logarithmic. As a result, the initial drop-off may happen - * faster than expected but the fading is more perceptually consistant over - * the given duration. It will take just as much time to go from -6dB to - * -12dB as it will to go from -40dB to -46dB, for example. - * - * Pending playback from a future buffer is not immediately canceled, but - * the fade timer starts with this call. If the future buffer then becomes - * ready, it will start mid-fade. Pending playback will be canceled if the - * fade out completes before the future buffer becomes ready. - * - * Fading is updated during calls to \c Context::update, which should be - * called regularly (30 to 50 times per second) for the fading to be - * smooth. - */ - void fadeOutToStop(ALfloat gain, std::chrono::milliseconds duration); - - /** Pauses the source if it is playing. */ - void pause(); - - /** Resumes the source if it is paused. */ - void resume(); - - /** Specifies if the source is waiting to play a future buffer. */ - bool isPending() const; - - /** Specifies if the source is currently playing. */ - bool isPlaying() const; - - /** Specifies if the source is currently paused. */ - bool isPaused() const; - - /** - * Specifies if the source is currently playing or waiting to play a future - * buffer. - */ - bool isPlayingOrPending() const; - - /** - * Sets this source as a child of the given source group. The given source - * group's parameters will influence this and all other sources that belong - * to it. A source can only be the child of one source group at a time, - * although that source group may belong to another source group. - * - * Passing in a null group removes it from its current source group. - */ - void setGroup(SourceGroup group); - - /** Retrieves the source group this source belongs to. */ - SourceGroup getGroup() const; - - /** - * Specifies the source's playback priority. The lowest priority sources - * will be forcefully stopped when no more mixing sources are available and - * higher priority sources are played. - */ - void setPriority(ALuint priority); - /** Retrieves the source's priority. */ - ALuint getPriority() const; - - /** - * Sets the source's offset, in sample frames. If the source is playing or - * paused, it will go to that offset immediately, otherwise the source will - * start at the specified offset the next time it's played. - */ - void setOffset(uint64_t offset); - /** - * Retrieves the source offset in sample frames and its latency in nano- - * seconds. For streaming sources this will be the offset based on the - * decoder's read position. - * - * If the AL_SOFT_source_latency extension is unsupported, the latency will - * be 0. - */ - std::pair getSampleOffsetLatency() const; - uint64_t getSampleOffset() const { return std::get<0>(getSampleOffsetLatency()); } - /** - * Retrieves the source offset and latency in seconds. For streaming - * sources this will be the offset based on the decoder's read position. - * - * If the AL_SOFT_source_latency extension is unsupported, the latency will - * be 0. - */ - std::pair getSecOffsetLatency() const; - Seconds getSecOffset() const { return std::get<0>(getSecOffsetLatency()); } - - /** - * Specifies if the source should loop on the Buffer or Decoder object's - * loop points. - */ - void setLooping(bool looping); - bool getLooping() const; - - /** - * Specifies a linear pitch shift base. A value of 1.0 is the default - * normal speed. - */ - void setPitch(ALfloat pitch); - ALfloat getPitch() const; - - /** - * Specifies the base linear gain. A value of 1.0 is the default normal - * volume. - */ - void setGain(ALfloat gain); - ALfloat getGain() const; - - /** - * Specifies the minimum and maximum gain. The source's gain is clamped to - * this range after distance attenuation and cone attenuation are applied - * to the gain base, although before the filter gain adjustements. - */ - void setGainRange(ALfloat mingain, ALfloat maxgain); - std::pair getGainRange() const; - ALfloat getMinGain() const { return std::get<0>(getGainRange()); } - ALfloat getMaxGain() const { return std::get<1>(getGainRange()); } - - /** - * Specifies the reference distance and maximum distance the source will - * use for the current distance model. For Clamped distance models, the - * source's calculated distance is clamped to the specified range before - * applying distance-related attenuation. - * - * For all distance models, the reference distance is the distance at which - * the source's volume will not have any extra attenuation (an effective - * gain multiplier of 1). - */ - void setDistanceRange(ALfloat refdist, ALfloat maxdist); - std::pair getDistanceRange() const; - ALfloat getReferenceDistance() const { return std::get<0>(getDistanceRange()); } - ALfloat getMaxDistance() const { return std::get<1>(getDistanceRange()); } - - /** - * Specifies the source's 3D position, velocity, and direction together - * (see: setPosition, setVelocity, and setDirection). - */ - void set3DParameters(const Vector3 &position, const Vector3 &velocity, const Vector3 &direction); - - /** - * Specifies the source's 3D position, velocity, and orientation together - * (see: setPosition, setVelocity, and setOrientation). - */ - void set3DParameters(const Vector3 &position, const Vector3 &velocity, const std::pair &orientation); - - /** Specifies the source's 3D position. */ - void setPosition(const Vector3 &position); - void setPosition(const ALfloat *pos); - Vector3 getPosition() const; - - /** - * Specifies the source's 3D velocity, in units per second. As with OpenAL, - * this does not actually alter the source's position, and instead just - * alters the pitch as determined by the doppler effect. - */ - void setVelocity(const Vector3 &velocity); - void setVelocity(const ALfloat *vel); - Vector3 getVelocity() const; - - /** - * Specifies the source's 3D facing direction. Deprecated in favor of - * setOrientation. - */ - void setDirection(const Vector3 &direction); - void setDirection(const ALfloat *dir); - Vector3 getDirection() const; - - /** - * Specifies the source's 3D orientation, using position-relative 'at' and - * 'up' direction vectors. Note: unlike the AL_EXT_BFORMAT extension this - * property comes from, this also affects the facing direction, superceding - * setDirection. - */ - void setOrientation(const std::pair &orientation); - void setOrientation(const ALfloat *at, const ALfloat *up); - void setOrientation(const ALfloat *ori); - std::pair getOrientation() const; - - /** - * Specifies the source's cone angles, in degrees. The inner angle is the - * area within which the listener will hear the source with no extra - * attenuation, while the listener being outside of the outer angle will - * hear the source attenuated according to the outer cone gains. The area - * follows the facing direction, so for example an inner angle of 180 means - * the entire front face of the source is in the inner cone. - */ - void setConeAngles(ALfloat inner, ALfloat outer); - std::pair getConeAngles() const; - ALfloat getInnerConeAngle() const { return std::get<0>(getConeAngles()); } - ALfloat getOuterConeAngle() const { return std::get<1>(getConeAngles()); } - - /** - * Specifies the linear gain multiplier when the listener is outside of the - * source's outer cone area. The specified gain applies to all frequencies, - * while gainhf applies extra attenuation to high frequencies creating a - * low-pass effect. - * - * \param gainhf has no effect without the ALC_EXT_EFX extension. - */ - void setOuterConeGains(ALfloat gain, ALfloat gainhf=1.0f); - std::pair getOuterConeGains() const; - ALfloat getOuterConeGain() const { return std::get<0>(getOuterConeGains()); } - ALfloat getOuterConeGainHF() const { return std::get<1>(getOuterConeGains()); } - - /** - * Specifies the rolloff factors for the direct and send paths. This is - * effectively a distance scaling relative to the reference distance. Note: - * the room rolloff factor is 0 by default, disabling distance attenuation - * for send paths. This is because the reverb engine will, by default, - * apply a more realistic room decay based on the reverb decay time and - * distance. - */ - void setRolloffFactors(ALfloat factor, ALfloat roomfactor=0.0f); - std::pair getRolloffFactors() const; - ALfloat getRolloffFactor() const { return std::get<0>(getRolloffFactors()); } - ALfloat getRoomRolloffFactor() const { return std::get<1>(getRolloffFactors()); } - - /** - * Specifies the doppler factor for the doppler effect's pitch shift. This - * effectively scales the source and listener velocities for the doppler - * calculation. - */ - void setDopplerFactor(ALfloat factor); - ALfloat getDopplerFactor() const; - - /** - * Specifies if the source's position, velocity, and direction/orientation - * are relative to the listener. - */ - void setRelative(bool relative); - bool getRelative() const; - - /** - * Specifies the source's radius. This causes the source to behave as if - * every point within the spherical area emits sound. - * - * Has no effect without the AL_EXT_SOURCE_RADIUS extension. - */ - void setRadius(ALfloat radius); - ALfloat getRadius() const; - - /** - * Specifies the left and right channel angles, in radians, when playing a - * stereo buffer or stream. The angles go counter-clockwise, with 0 being - * in front and positive values going left. - * - * Has no effect without the AL_EXT_STEREO_ANGLES extension. - */ - void setStereoAngles(ALfloat leftAngle, ALfloat rightAngle); - std::pair getStereoAngles() const; - - /** - * Specifies if the source always has 3D spatialization features (On), - * never has 3D spatialization features (Off), or if spatialization is - * enabled based on playing a mono sound or not (Auto, default). - * - * Has no effect without the AL_SOFT_source_spatialize extension. - */ - void set3DSpatialize(Spatialize spatialize); - Spatialize get3DSpatialize() const; - - /** - * Specifies the index of the resampler to use for this source. The index - * is from the resamplers returned by \c Context::getAvailableResamplers, - * and must be 0 or greater. - * - * Has no effect without the AL_SOFT_source_resampler extension. - */ - void setResamplerIndex(ALsizei index); - ALsizei getResamplerIndex() const; - - /** - * Specifies a multiplier for the amount of atmospheric high-frequency - * absorption, ranging from 0 to 10. A factor of 1 results in a nominal - * -0.05dB per meter, with higher values simulating foggy air and lower - * values simulating dryer air. The default is 0. - */ - void setAirAbsorptionFactor(ALfloat factor); - ALfloat getAirAbsorptionFactor() const; - - /** - * Specifies to automatically apply adjustments to the direct path's high- - * frequency gain, and the send paths' gain and high-frequency gain. The - * default is true for all. - */ - void setGainAuto(bool directhf, bool send, bool sendhf); - std::tuple getGainAuto() const; - bool getDirectGainHFAuto() const { return std::get<0>(getGainAuto()); } - bool getSendGainAuto() const { return std::get<1>(getGainAuto()); } - bool getSendGainHFAuto() const { return std::get<2>(getGainAuto()); } - - /** Sets the filter properties on the direct path signal. */ - void setDirectFilter(const FilterParams &filter); - /** - * Sets the filter properties on the given send path signal. Any auxiliary - * effect slot on the send path remains in place. - */ - void setSendFilter(ALuint send, const FilterParams &filter); - /** - * Connects the effect slot to the given send path. Any filter properties - * on the send path remain as they were. - */ - void setAuxiliarySend(AuxiliaryEffectSlot slot, ALuint send); - /** - * Connects the effect slot to the given send path, using the filter - * properties. - */ - void setAuxiliarySendFilter(AuxiliaryEffectSlot slot, ALuint send, const FilterParams &filter); - - /** Destroys the source, stopping playback and releasing resources. */ - void destroy(); -}; - - -class ALURE_API SourceGroup { - MAKE_PIMPL(SourceGroup, SourceGroupImpl) - -public: - /** - * Adds this source group as a subgroup of the specified source group. This - * method will throw an exception if this group is being added to a group - * it has as a sub-group (i.e. it would create a circular sub-group chain). - */ - void setParentGroup(SourceGroup group); - - /** Retrieves the source group this source group is a child of. */ - SourceGroup getParentGroup() const; - - /** Returns the list of sources currently in the group. */ - Vector getSources() const; - - /** Returns the list of subgroups currently in the group. */ - Vector getSubGroups() const; - - /** - * Sets the source group gain, which accumulates with its sources' and - * sub-groups' gain. - */ - void setGain(ALfloat gain); - /** Gets the source group gain. */ - ALfloat getGain() const; - - /** - * Sets the source group pitch, which accumulates with its sources' and - * sub-groups' pitch. - */ - void setPitch(ALfloat pitch); - /** Gets the source group pitch. */ - ALfloat getPitch() const; - - /** - * Pauses all currently-playing sources that are under this group, - * including sub-groups. - */ - void pauseAll() const; - /** - * Resumes all paused sources that are under this group, including - * sub-groups. - */ - void resumeAll() const; - - /** Stops all sources that are under this group, including sub-groups. */ - void stopAll() const; - - /** - * Destroys the source group, removing all sources from it before being - * freed. - */ - void destroy(); -}; - - -struct SourceSend { - Source mSource; - ALuint mSend; -}; - -class ALURE_API AuxiliaryEffectSlot { - MAKE_PIMPL(AuxiliaryEffectSlot, AuxiliaryEffectSlotImpl) - -public: - void setGain(ALfloat gain); - /** - * If set to true, the reverb effect will automatically apply adjustments - * to the source's send slot gains based on the effect properties. - * - * Has no effect when using non-reverb effects. Default is true. - */ - void setSendAuto(bool sendauto); - - /** - * Updates the effect slot with a new effect. The given effect object may - * be altered or destroyed without affecting the effect slot. - */ - void applyEffect(Effect effect); - - /** - * Destroys the effect slot, returning it to the system. If the effect slot - * is currently set on a source send, it will be removed first. - */ - void destroy(); - - /** - * Retrieves each Source object and its pairing send this effect slot is - * set on. - */ - Vector getSourceSends() const; - - /** - * Queries the number of source sends the effect slot is used by. This is - * equivalent to calling getSourceSends().size(). - */ - size_t getUseCount() const; -}; - - -class ALURE_API Effect { - MAKE_PIMPL(Effect, EffectImpl) - -public: - /** - * Updates the effect with the specified reverb properties. If the - * EAXReverb effect is not supported, it will automatically attempt to - * downgrade to the Standard Reverb effect. - */ - void setReverbProperties(const EFXEAXREVERBPROPERTIES &props); - - /** - * Updates the effect with the specified chorus properties. If the chorus - * effect is not supported, an exception will be thrown. - */ - void setChorusProperties(const EFXCHORUSPROPERTIES &props); - - void destroy(); -}; - - -/** - * Audio decoder interface. Applications may derive from this, implementing the - * necessary methods, and use it in places the API wants a Decoder object. - */ -class ALURE_API Decoder { -public: - virtual ~Decoder(); - - /** Retrieves the sample frequency, in hz, of the audio being decoded. */ - virtual ALuint getFrequency() const noexcept = 0; - /** Retrieves the channel configuration of the audio being decoded. */ - virtual ChannelConfig getChannelConfig() const noexcept = 0; - /** Retrieves the sample type of the audio being decoded. */ - virtual SampleType getSampleType() const noexcept = 0; - - /** - * Retrieves the total length of the audio, in sample frames. If unknown, - * returns 0. Note that if the returned length is 0, the decoder may not be - * used to load a Buffer. - */ - virtual uint64_t getLength() const noexcept = 0; - /** - * Seek to pos, specified in sample frames. Returns true if the seek was - * successful. - */ - virtual bool seek(uint64_t pos) noexcept = 0; - - /** - * Retrieves if the audio file has any loop point embedded. - */ - virtual bool hasLoopPoints() const noexcept = 0; - - /** - * Retrieves the loop points, in sample frames, as a [start,end) pair. If - * start >= end, all available samples are included in the loop. - */ - virtual std::pair getLoopPoints() const noexcept = 0; - - /** - * Decodes count sample frames, writing them to ptr, and returns the number - * of sample frames written. Returning less than the requested count - * indicates the end of the audio. - */ - virtual ALuint read(ALvoid *ptr, ALuint count) noexcept = 0; -}; - -/** - * Audio decoder factory interface. Applications may derive from this, - * implementing the necessary methods, and use it in places the API wants a - * DecoderFactory object. - */ -class ALURE_API DecoderFactory { -public: - virtual ~DecoderFactory(); - - /** - * Creates and returns a Decoder instance for the given resource file. If - * the decoder needs to retain the file handle for reading as-needed, it - * should move the UniquePtr to internal storage. - * - * \return nullptr if a decoder can't be created from the file. - */ - virtual SharedPtr createDecoder(UniquePtr &file) noexcept = 0; -}; - -/** - * Registers a decoder factory for decoding audio. Registered factories are - * used in lexicographical order, e.g. if Factory1 is registered with name1 and - * Factory2 is registered with name2, Factory1 will be used before Factory2 if - * name1 < name2. Internal decoder factories are always used after registered - * ones. - * - * Alure retains a reference to the DecoderFactory instance and will release it - * (destructing the object) when the library unloads. - * - * \param name A unique name identifying this decoder factory. - * \param factory A DecoderFactory instance used to create Decoder instances. - */ -ALURE_API void RegisterDecoder(StringView name, UniquePtr factory); - -/** - * Unregisters a decoder factory by name. Alure returns the instance back to - * the application. - * - * \param name The unique name identifying a previously-registered decoder - * factory. - * - * \return The unregistered decoder factory instance, or 0 (nullptr) if a - * decoder factory with the given name doesn't exist. - */ -ALURE_API UniquePtr UnregisterDecoder(StringView name) noexcept; - - -/** - * A file I/O factory interface. Applications may derive from this and set an - * instance to be used by the audio decoders. By default, the library uses - * standard I/O. - */ -class ALURE_API FileIOFactory { -public: - /** - * Sets the factory instance to be used by the audio decoders. If a - * previous factory was set, it's returned to the application. Passing in a - * nullptr reverts to the default. - */ - static UniquePtr set(UniquePtr factory) noexcept; - - /** - * Gets the current FileIOFactory instance being used by the audio - * decoders. - */ - static FileIOFactory &get() noexcept; - - virtual ~FileIOFactory(); - - /** Opens a read-only binary file for the given name. */ - virtual UniquePtr openFile(const String &name) noexcept = 0; -}; - - -/** - * A message handler interface. Applications may derive from this and set an - * instance on a context to receive messages. The base methods are no-ops, so - * derived classes only need to implement methods for relevant messages. - * - * It's recommended that applications mark their handler methods using the - * override keyword, to ensure they're properly overriding the base methods in - * case they change. - */ -class ALURE_API MessageHandler { -public: - virtual ~MessageHandler(); - - /** - * Called when the given device has been disconnected and is no longer - * usable for output. As per the ALC_EXT_disconnect specification, - * disconnected devices remain valid, however all playing sources are - * automatically stopped, any sources that are attempted to play will - * immediately stop, and new contexts may not be created on the device. - * - * Note that connection status is checked during Context::update calls, so - * that method must be called regularly to be notified when a device is - * disconnected. This method may not be called if the device lacks support - * for the ALC_EXT_disconnect extension. - */ - virtual void deviceDisconnected(Device device) noexcept; - - /** - * Called when the given source reaches the end of the buffer or stream. - * - * Sources that stopped automatically will be detected upon a call to - * Context::update. - */ - virtual void sourceStopped(Source source) noexcept; - - /** - * Called when the given source was forced to stop. This can be because - * either there were no more mixing sources and a higher-priority source - * preempted it, it's part of a SourceGroup (or sub-group thereof) that had - * its SourceGroup::stopAll method called, or it was playing a buffer - * that's getting removed. - */ - virtual void sourceForceStopped(Source source) noexcept; - - /** - * Called when a new buffer is about to be created and loaded. May be - * called asynchronously for buffers being loaded asynchronously. - * - * \param name The resource name, as passed to Context::getBuffer. - * \param channels Channel configuration of the given audio data. - * \param type Sample type of the given audio data. - * \param samplerate Sample rate of the given audio data. - * \param data The audio data that is about to be fed to the OpenAL buffer. - */ - virtual void bufferLoading(StringView name, ChannelConfig channels, SampleType type, ALuint samplerate, ArrayView data) noexcept; - - /** - * Called when a resource isn't found, allowing the app to substitute in a - * different resource. For buffers being cached, the original name will - * still be used for the cache entry so the app doesn't have to keep track - * of substituted resource names. - * - * This will be called again if the new name also isn't found. - * - * \param name The resource name that was not found. - * \return The replacement resource name to use instead. Returning an empty - * string means to stop trying. - */ - virtual String resourceNotFound(StringView name) noexcept; -}; - -#undef MAKE_PIMPL - -} // namespace alure - -#endif /* AL_ALURE2_H */ diff --git a/Plugins/Audio/alure/AL/efx-presets.h b/Plugins/Audio/alure/AL/efx-presets.h deleted file mode 100644 index 8539fd5..0000000 --- a/Plugins/Audio/alure/AL/efx-presets.h +++ /dev/null @@ -1,402 +0,0 @@ -/* Reverb presets for EFX */ - -#ifndef EFX_PRESETS_H -#define EFX_PRESETS_H - -#ifndef EFXEAXREVERBPROPERTIES_DEFINED -#define EFXEAXREVERBPROPERTIES_DEFINED -typedef struct { - float flDensity; - float flDiffusion; - float flGain; - float flGainHF; - float flGainLF; - float flDecayTime; - float flDecayHFRatio; - float flDecayLFRatio; - float flReflectionsGain; - float flReflectionsDelay; - float flReflectionsPan[3]; - float flLateReverbGain; - float flLateReverbDelay; - float flLateReverbPan[3]; - float flEchoTime; - float flEchoDepth; - float flModulationTime; - float flModulationDepth; - float flAirAbsorptionGainHF; - float flHFReference; - float flLFReference; - float flRoomRolloffFactor; - int iDecayHFLimit; -} EFXEAXREVERBPROPERTIES, *LPEFXEAXREVERBPROPERTIES; -#endif - -/* Default Presets */ - -#define EFX_REVERB_PRESET_GENERIC \ - { 1.0000f, 1.0000f, 0.3162f, 0.8913f, 1.0000f, 1.4900f, 0.8300f, 1.0000f, 0.0500f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PADDEDCELL \ - { 0.1715f, 1.0000f, 0.3162f, 0.0010f, 1.0000f, 0.1700f, 0.1000f, 1.0000f, 0.2500f, 0.0010f, { 0.0000f, 0.0000f, 0.0000f }, 1.2691f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ROOM \ - { 0.4287f, 1.0000f, 0.3162f, 0.5929f, 1.0000f, 0.4000f, 0.8300f, 1.0000f, 0.1503f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 1.0629f, 0.0030f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_BATHROOM \ - { 0.1715f, 1.0000f, 0.3162f, 0.2512f, 1.0000f, 1.4900f, 0.5400f, 1.0000f, 0.6531f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 3.2734f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_LIVINGROOM \ - { 0.9766f, 1.0000f, 0.3162f, 0.0010f, 1.0000f, 0.5000f, 0.1000f, 1.0000f, 0.2051f, 0.0030f, { 0.0000f, 0.0000f, 0.0000f }, 0.2805f, 0.0040f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_STONEROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.7079f, 1.0000f, 2.3100f, 0.6400f, 1.0000f, 0.4411f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1003f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_AUDITORIUM \ - { 1.0000f, 1.0000f, 0.3162f, 0.5781f, 1.0000f, 4.3200f, 0.5900f, 1.0000f, 0.4032f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.7170f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CONCERTHALL \ - { 1.0000f, 1.0000f, 0.3162f, 0.5623f, 1.0000f, 3.9200f, 0.7000f, 1.0000f, 0.2427f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.9977f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CAVE \ - { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 1.0000f, 2.9100f, 1.3000f, 1.0000f, 0.5000f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.7063f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_ARENA \ - { 1.0000f, 1.0000f, 0.3162f, 0.4477f, 1.0000f, 7.2400f, 0.3300f, 1.0000f, 0.2612f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.0186f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_HANGAR \ - { 1.0000f, 1.0000f, 0.3162f, 0.3162f, 1.0000f, 10.0500f, 0.2300f, 1.0000f, 0.5000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2560f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CARPETEDHALLWAY \ - { 0.4287f, 1.0000f, 0.3162f, 0.0100f, 1.0000f, 0.3000f, 0.1000f, 1.0000f, 0.1215f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 0.1531f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_HALLWAY \ - { 0.3645f, 1.0000f, 0.3162f, 0.7079f, 1.0000f, 1.4900f, 0.5900f, 1.0000f, 0.2458f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.6615f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_STONECORRIDOR \ - { 1.0000f, 1.0000f, 0.3162f, 0.7612f, 1.0000f, 2.7000f, 0.7900f, 1.0000f, 0.2472f, 0.0130f, { 0.0000f, 0.0000f, 0.0000f }, 1.5758f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ALLEY \ - { 1.0000f, 0.3000f, 0.3162f, 0.7328f, 1.0000f, 1.4900f, 0.8600f, 1.0000f, 0.2500f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.9954f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.9500f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FOREST \ - { 1.0000f, 0.3000f, 0.3162f, 0.0224f, 1.0000f, 1.4900f, 0.5400f, 1.0000f, 0.0525f, 0.1620f, { 0.0000f, 0.0000f, 0.0000f }, 0.7682f, 0.0880f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY \ - { 1.0000f, 0.5000f, 0.3162f, 0.3981f, 1.0000f, 1.4900f, 0.6700f, 1.0000f, 0.0730f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.1427f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_MOUNTAINS \ - { 1.0000f, 0.2700f, 0.3162f, 0.0562f, 1.0000f, 1.4900f, 0.2100f, 1.0000f, 0.0407f, 0.3000f, { 0.0000f, 0.0000f, 0.0000f }, 0.1919f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_QUARRY \ - { 1.0000f, 1.0000f, 0.3162f, 0.3162f, 1.0000f, 1.4900f, 0.8300f, 1.0000f, 0.0000f, 0.0610f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0250f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.7000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PLAIN \ - { 1.0000f, 0.2100f, 0.3162f, 0.1000f, 1.0000f, 1.4900f, 0.5000f, 1.0000f, 0.0585f, 0.1790f, { 0.0000f, 0.0000f, 0.0000f }, 0.1089f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PARKINGLOT \ - { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 1.0000f, 1.6500f, 1.5000f, 1.0000f, 0.2082f, 0.0080f, { 0.0000f, 0.0000f, 0.0000f }, 0.2652f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_SEWERPIPE \ - { 0.3071f, 0.8000f, 0.3162f, 0.3162f, 1.0000f, 2.8100f, 0.1400f, 1.0000f, 1.6387f, 0.0140f, { 0.0000f, 0.0000f, 0.0000f }, 3.2471f, 0.0210f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_UNDERWATER \ - { 0.3645f, 1.0000f, 0.3162f, 0.0100f, 1.0000f, 1.4900f, 0.1000f, 1.0000f, 0.5963f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 7.0795f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 1.1800f, 0.3480f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRUGGED \ - { 0.4287f, 0.5000f, 0.3162f, 1.0000f, 1.0000f, 8.3900f, 1.3900f, 1.0000f, 0.8760f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 3.1081f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 1.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DIZZY \ - { 0.3645f, 0.6000f, 0.3162f, 0.6310f, 1.0000f, 17.2300f, 0.5600f, 1.0000f, 0.1392f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.4937f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.8100f, 0.3100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PSYCHOTIC \ - { 0.0625f, 0.5000f, 0.3162f, 0.8404f, 1.0000f, 7.5600f, 0.9100f, 1.0000f, 0.4864f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 2.4378f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 4.0000f, 1.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -/* Castle Presets */ - -#define EFX_REVERB_PRESET_CASTLE_SMALLROOM \ - { 1.0000f, 0.8900f, 0.3162f, 0.3981f, 0.1000f, 1.2200f, 0.8300f, 0.3100f, 0.8913f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_SHORTPASSAGE \ - { 1.0000f, 0.8900f, 0.3162f, 0.3162f, 0.1000f, 2.3200f, 0.8300f, 0.3100f, 0.8913f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_MEDIUMROOM \ - { 1.0000f, 0.9300f, 0.3162f, 0.2818f, 0.1000f, 2.0400f, 0.8300f, 0.4600f, 0.6310f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1550f, 0.0300f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_LARGEROOM \ - { 1.0000f, 0.8200f, 0.3162f, 0.2818f, 0.1259f, 2.5300f, 0.8300f, 0.5000f, 0.4467f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1850f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_LONGPASSAGE \ - { 1.0000f, 0.8900f, 0.3162f, 0.3981f, 0.1000f, 3.4200f, 0.8300f, 0.3100f, 0.8913f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_HALL \ - { 1.0000f, 0.8100f, 0.3162f, 0.2818f, 0.1778f, 3.1400f, 0.7900f, 0.6200f, 0.1778f, 0.0560f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_CUPBOARD \ - { 1.0000f, 0.8900f, 0.3162f, 0.2818f, 0.1000f, 0.6700f, 0.8700f, 0.3100f, 1.4125f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 3.5481f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_COURTYARD \ - { 1.0000f, 0.4200f, 0.3162f, 0.4467f, 0.1995f, 2.1300f, 0.6100f, 0.2300f, 0.2239f, 0.1600f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0360f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.3700f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_CASTLE_ALCOVE \ - { 1.0000f, 0.8900f, 0.3162f, 0.5012f, 0.1000f, 1.6400f, 0.8700f, 0.3100f, 1.0000f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -/* Factory Presets */ - -#define EFX_REVERB_PRESET_FACTORY_SMALLROOM \ - { 0.3645f, 0.8200f, 0.3162f, 0.7943f, 0.5012f, 1.7200f, 0.6500f, 1.3100f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.1190f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_SHORTPASSAGE \ - { 0.3645f, 0.6400f, 0.2512f, 0.7943f, 0.5012f, 2.5300f, 0.6500f, 1.3100f, 1.0000f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.1350f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_MEDIUMROOM \ - { 0.4287f, 0.8200f, 0.2512f, 0.7943f, 0.5012f, 2.7600f, 0.6500f, 1.3100f, 0.2818f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1740f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_LARGEROOM \ - { 0.4287f, 0.7500f, 0.2512f, 0.7079f, 0.6310f, 4.2400f, 0.5100f, 1.3100f, 0.1778f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.2310f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_LONGPASSAGE \ - { 0.3645f, 0.6400f, 0.2512f, 0.7943f, 0.5012f, 4.0600f, 0.6500f, 1.3100f, 1.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0370f, { 0.0000f, 0.0000f, 0.0000f }, 0.1350f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_HALL \ - { 0.4287f, 0.7500f, 0.3162f, 0.7079f, 0.6310f, 7.4300f, 0.5100f, 1.3100f, 0.0631f, 0.0730f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_CUPBOARD \ - { 0.3071f, 0.6300f, 0.2512f, 0.7943f, 0.5012f, 0.4900f, 0.6500f, 1.3100f, 1.2589f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.1070f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_COURTYARD \ - { 0.3071f, 0.5700f, 0.3162f, 0.3162f, 0.6310f, 2.3200f, 0.2900f, 0.5600f, 0.2239f, 0.1400f, { 0.0000f, 0.0000f, 0.0000f }, 0.3981f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2900f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_ALCOVE \ - { 0.3645f, 0.5900f, 0.2512f, 0.7943f, 0.5012f, 3.1400f, 0.6500f, 1.3100f, 1.4125f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.1140f, 0.1000f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -/* Ice Palace Presets */ - -#define EFX_REVERB_PRESET_ICEPALACE_SMALLROOM \ - { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 0.2818f, 1.5100f, 1.5300f, 0.2700f, 0.8913f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1640f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_SHORTPASSAGE \ - { 1.0000f, 0.7500f, 0.3162f, 0.5623f, 0.2818f, 1.7900f, 1.4600f, 0.2800f, 0.5012f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.1770f, 0.0900f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_MEDIUMROOM \ - { 1.0000f, 0.8700f, 0.3162f, 0.5623f, 0.4467f, 2.2200f, 1.5300f, 0.3200f, 0.3981f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.1860f, 0.1200f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_LARGEROOM \ - { 1.0000f, 0.8100f, 0.3162f, 0.5623f, 0.4467f, 3.1400f, 1.5300f, 0.3200f, 0.2512f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.2140f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_LONGPASSAGE \ - { 1.0000f, 0.7700f, 0.3162f, 0.5623f, 0.3981f, 3.0100f, 1.4600f, 0.2800f, 0.7943f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0250f, { 0.0000f, 0.0000f, 0.0000f }, 0.1860f, 0.0400f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_HALL \ - { 1.0000f, 0.7600f, 0.3162f, 0.4467f, 0.5623f, 5.4900f, 1.5300f, 0.3800f, 0.1122f, 0.0540f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0520f, { 0.0000f, 0.0000f, 0.0000f }, 0.2260f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_CUPBOARD \ - { 1.0000f, 0.8300f, 0.3162f, 0.5012f, 0.2239f, 0.7600f, 1.5300f, 0.2600f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1430f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_COURTYARD \ - { 1.0000f, 0.5900f, 0.3162f, 0.2818f, 0.3162f, 2.0400f, 1.2000f, 0.3800f, 0.3162f, 0.1730f, { 0.0000f, 0.0000f, 0.0000f }, 0.3162f, 0.0430f, { 0.0000f, 0.0000f, 0.0000f }, 0.2350f, 0.4800f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_ALCOVE \ - { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 0.2818f, 2.7600f, 1.4600f, 0.2800f, 1.1220f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1610f, 0.0900f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -/* Space Station Presets */ - -#define EFX_REVERB_PRESET_SPACESTATION_SMALLROOM \ - { 0.2109f, 0.7000f, 0.3162f, 0.7079f, 0.8913f, 1.7200f, 0.8200f, 0.5500f, 0.7943f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0130f, { 0.0000f, 0.0000f, 0.0000f }, 0.1880f, 0.2600f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_SHORTPASSAGE \ - { 0.2109f, 0.8700f, 0.3162f, 0.6310f, 0.8913f, 3.5700f, 0.5000f, 0.5500f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1720f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_MEDIUMROOM \ - { 0.2109f, 0.7500f, 0.3162f, 0.6310f, 0.8913f, 3.0100f, 0.5000f, 0.5500f, 0.3981f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0350f, { 0.0000f, 0.0000f, 0.0000f }, 0.2090f, 0.3100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_LARGEROOM \ - { 0.3645f, 0.8100f, 0.3162f, 0.6310f, 0.8913f, 3.8900f, 0.3800f, 0.6100f, 0.3162f, 0.0560f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0350f, { 0.0000f, 0.0000f, 0.0000f }, 0.2330f, 0.2800f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_LONGPASSAGE \ - { 0.4287f, 0.8200f, 0.3162f, 0.6310f, 0.8913f, 4.6200f, 0.6200f, 0.5500f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0310f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_HALL \ - { 0.4287f, 0.8700f, 0.3162f, 0.6310f, 0.8913f, 7.1100f, 0.3800f, 0.6100f, 0.1778f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0470f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2500f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_CUPBOARD \ - { 0.1715f, 0.5600f, 0.3162f, 0.7079f, 0.8913f, 0.7900f, 0.8100f, 0.5500f, 1.4125f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0180f, { 0.0000f, 0.0000f, 0.0000f }, 0.1810f, 0.3100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_ALCOVE \ - { 0.2109f, 0.7800f, 0.3162f, 0.7079f, 0.8913f, 1.1600f, 0.8100f, 0.5500f, 1.4125f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0180f, { 0.0000f, 0.0000f, 0.0000f }, 0.1920f, 0.2100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -/* Wooden Galleon Presets */ - -#define EFX_REVERB_PRESET_WOODEN_SMALLROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.1122f, 0.3162f, 0.7900f, 0.3200f, 0.8700f, 1.0000f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_SHORTPASSAGE \ - { 1.0000f, 1.0000f, 0.3162f, 0.1259f, 0.3162f, 1.7500f, 0.5000f, 0.8700f, 0.8913f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_MEDIUMROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.1000f, 0.2818f, 1.4700f, 0.4200f, 0.8200f, 0.8913f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_LARGEROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.0891f, 0.2818f, 2.6500f, 0.3300f, 0.8200f, 0.8913f, 0.0660f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_LONGPASSAGE \ - { 1.0000f, 1.0000f, 0.3162f, 0.1000f, 0.3162f, 1.9900f, 0.4000f, 0.7900f, 1.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.4467f, 0.0360f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_HALL \ - { 1.0000f, 1.0000f, 0.3162f, 0.0794f, 0.2818f, 3.4500f, 0.3000f, 0.8200f, 0.8913f, 0.0880f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0630f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_CUPBOARD \ - { 1.0000f, 1.0000f, 0.3162f, 0.1413f, 0.3162f, 0.5600f, 0.4600f, 0.9100f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_COURTYARD \ - { 1.0000f, 0.6500f, 0.3162f, 0.0794f, 0.3162f, 1.7900f, 0.3500f, 0.7900f, 0.5623f, 0.1230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1000f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_ALCOVE \ - { 1.0000f, 1.0000f, 0.3162f, 0.1259f, 0.3162f, 1.2200f, 0.6200f, 0.9100f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -/* Sports Presets */ - -#define EFX_REVERB_PRESET_SPORT_EMPTYSTADIUM \ - { 1.0000f, 1.0000f, 0.3162f, 0.4467f, 0.7943f, 6.2600f, 0.5100f, 1.1000f, 0.0631f, 0.1830f, { 0.0000f, 0.0000f, 0.0000f }, 0.3981f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_SQUASHCOURT \ - { 1.0000f, 0.7500f, 0.3162f, 0.3162f, 0.7943f, 2.2200f, 0.9100f, 1.1600f, 0.4467f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1260f, 0.1900f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_SMALLSWIMMINGPOOL \ - { 1.0000f, 0.7000f, 0.3162f, 0.7943f, 0.8913f, 2.7600f, 1.2500f, 1.1400f, 0.6310f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1790f, 0.1500f, 0.8950f, 0.1900f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_SPORT_LARGESWIMMINGPOOL \ - { 1.0000f, 0.8200f, 0.3162f, 0.7943f, 1.0000f, 5.4900f, 1.3100f, 1.1400f, 0.4467f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 0.5012f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2220f, 0.5500f, 1.1590f, 0.2100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_SPORT_GYMNASIUM \ - { 1.0000f, 0.8100f, 0.3162f, 0.4467f, 0.8913f, 3.1400f, 1.0600f, 1.3500f, 0.3981f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.5623f, 0.0450f, { 0.0000f, 0.0000f, 0.0000f }, 0.1460f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_FULLSTADIUM \ - { 1.0000f, 1.0000f, 0.3162f, 0.0708f, 0.7943f, 5.2500f, 0.1700f, 0.8000f, 0.1000f, 0.1880f, { 0.0000f, 0.0000f, 0.0000f }, 0.2818f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_STADIUMTANNOY \ - { 1.0000f, 0.7800f, 0.3162f, 0.5623f, 0.5012f, 2.5300f, 0.8800f, 0.6800f, 0.2818f, 0.2300f, { 0.0000f, 0.0000f, 0.0000f }, 0.5012f, 0.0630f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -/* Prefab Presets */ - -#define EFX_REVERB_PRESET_PREFAB_WORKSHOP \ - { 0.4287f, 1.0000f, 0.3162f, 0.1413f, 0.3981f, 0.7600f, 1.0000f, 1.0000f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PREFAB_SCHOOLROOM \ - { 0.4022f, 0.6900f, 0.3162f, 0.6310f, 0.5012f, 0.9800f, 0.4500f, 0.1800f, 1.4125f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.0950f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PREFAB_PRACTISEROOM \ - { 0.4022f, 0.8700f, 0.3162f, 0.3981f, 0.5012f, 1.1200f, 0.5600f, 0.1800f, 1.2589f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.0950f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PREFAB_OUTHOUSE \ - { 1.0000f, 0.8200f, 0.3162f, 0.1122f, 0.1585f, 1.3800f, 0.3800f, 0.3500f, 0.8913f, 0.0240f, { 0.0000f, 0.0000f, -0.0000f }, 0.6310f, 0.0440f, { 0.0000f, 0.0000f, 0.0000f }, 0.1210f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PREFAB_CARAVAN \ - { 1.0000f, 1.0000f, 0.3162f, 0.0891f, 0.1259f, 0.4300f, 1.5000f, 1.0000f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -/* Dome and Pipe Presets */ - -#define EFX_REVERB_PRESET_DOME_TOMB \ - { 1.0000f, 0.7900f, 0.3162f, 0.3548f, 0.2239f, 4.1800f, 0.2100f, 0.1000f, 0.3868f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 1.6788f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.1770f, 0.1900f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PIPE_SMALL \ - { 1.0000f, 1.0000f, 0.3162f, 0.3548f, 0.2239f, 5.0400f, 0.1000f, 0.1000f, 0.5012f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 2.5119f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DOME_SAINTPAULS \ - { 1.0000f, 0.8700f, 0.3162f, 0.3548f, 0.2239f, 10.4800f, 0.1900f, 0.1000f, 0.1778f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0420f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1200f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PIPE_LONGTHIN \ - { 0.2560f, 0.9100f, 0.3162f, 0.4467f, 0.2818f, 9.2100f, 0.1800f, 0.1000f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PIPE_LARGE \ - { 1.0000f, 1.0000f, 0.3162f, 0.3548f, 0.2239f, 8.4500f, 0.1000f, 0.1000f, 0.3981f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PIPE_RESONANT \ - { 0.1373f, 0.9100f, 0.3162f, 0.4467f, 0.2818f, 6.8100f, 0.1800f, 0.1000f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } - -/* Outdoors Presets */ - -#define EFX_REVERB_PRESET_OUTDOORS_BACKYARD \ - { 1.0000f, 0.4500f, 0.3162f, 0.2512f, 0.5012f, 1.1200f, 0.3400f, 0.4600f, 0.4467f, 0.0690f, { 0.0000f, 0.0000f, -0.0000f }, 0.7079f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.2180f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_ROLLINGPLAINS \ - { 1.0000f, 0.0000f, 0.3162f, 0.0112f, 0.6310f, 2.1300f, 0.2100f, 0.4600f, 0.1778f, 0.3000f, { 0.0000f, 0.0000f, -0.0000f }, 0.4467f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_DEEPCANYON \ - { 1.0000f, 0.7400f, 0.3162f, 0.1778f, 0.6310f, 3.8900f, 0.2100f, 0.4600f, 0.3162f, 0.2230f, { 0.0000f, 0.0000f, -0.0000f }, 0.3548f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_CREEK \ - { 1.0000f, 0.3500f, 0.3162f, 0.1778f, 0.5012f, 2.1300f, 0.2100f, 0.4600f, 0.3981f, 0.1150f, { 0.0000f, 0.0000f, -0.0000f }, 0.1995f, 0.0310f, { 0.0000f, 0.0000f, 0.0000f }, 0.2180f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_VALLEY \ - { 1.0000f, 0.2800f, 0.3162f, 0.0282f, 0.1585f, 2.8800f, 0.2600f, 0.3500f, 0.1413f, 0.2630f, { 0.0000f, 0.0000f, -0.0000f }, 0.3981f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -/* Mood Presets */ - -#define EFX_REVERB_PRESET_MOOD_HEAVEN \ - { 1.0000f, 0.9400f, 0.3162f, 0.7943f, 0.4467f, 5.0400f, 1.1200f, 0.5600f, 0.2427f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0800f, 2.7420f, 0.0500f, 0.9977f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_MOOD_HELL \ - { 1.0000f, 0.5700f, 0.3162f, 0.3548f, 0.4467f, 3.5700f, 0.4900f, 2.0000f, 0.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1100f, 0.0400f, 2.1090f, 0.5200f, 0.9943f, 5000.0000f, 139.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_MOOD_MEMORY \ - { 1.0000f, 0.8500f, 0.3162f, 0.6310f, 0.3548f, 4.0600f, 0.8200f, 0.5600f, 0.0398f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.4740f, 0.4500f, 0.9886f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -/* Driving Presets */ - -#define EFX_REVERB_PRESET_DRIVING_COMMENTATOR \ - { 1.0000f, 0.0000f, 0.3162f, 0.5623f, 0.5012f, 2.4200f, 0.8800f, 0.6800f, 0.1995f, 0.0930f, { 0.0000f, 0.0000f, 0.0000f }, 0.2512f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9886f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_PITGARAGE \ - { 0.4287f, 0.5900f, 0.3162f, 0.7079f, 0.5623f, 1.7200f, 0.9300f, 0.8700f, 0.5623f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DRIVING_INCAR_RACER \ - { 0.0832f, 0.8000f, 0.3162f, 1.0000f, 0.7943f, 0.1700f, 2.0000f, 0.4100f, 1.7783f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_INCAR_SPORTS \ - { 0.0832f, 0.8000f, 0.3162f, 0.6310f, 1.0000f, 0.1700f, 0.7500f, 0.4100f, 1.0000f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.5623f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_INCAR_LUXURY \ - { 0.2560f, 1.0000f, 0.3162f, 0.1000f, 0.5012f, 0.1300f, 0.4100f, 0.4600f, 0.7943f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_FULLGRANDSTAND \ - { 1.0000f, 1.0000f, 0.3162f, 0.2818f, 0.6310f, 3.0100f, 1.3700f, 1.2800f, 0.3548f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 0.1778f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10420.2002f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DRIVING_EMPTYGRANDSTAND \ - { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 0.7943f, 4.6200f, 1.7500f, 1.4000f, 0.2082f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 0.2512f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10420.2002f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DRIVING_TUNNEL \ - { 1.0000f, 0.8100f, 0.3162f, 0.3981f, 0.8913f, 3.4200f, 0.9400f, 1.3100f, 0.7079f, 0.0510f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0470f, { 0.0000f, 0.0000f, 0.0000f }, 0.2140f, 0.0500f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 155.3000f, 0.0000f, 0x1 } - -/* City Presets */ - -#define EFX_REVERB_PRESET_CITY_STREETS \ - { 1.0000f, 0.7800f, 0.3162f, 0.7079f, 0.8913f, 1.7900f, 1.1200f, 0.9100f, 0.2818f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 0.1995f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY_SUBWAY \ - { 1.0000f, 0.7400f, 0.3162f, 0.7079f, 0.8913f, 3.0100f, 1.2300f, 0.9100f, 0.7079f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.2100f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY_MUSEUM \ - { 1.0000f, 0.8200f, 0.3162f, 0.1778f, 0.1778f, 3.2800f, 1.4000f, 0.5700f, 0.2512f, 0.0390f, { 0.0000f, 0.0000f, -0.0000f }, 0.8913f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 0.1300f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_CITY_LIBRARY \ - { 1.0000f, 0.8200f, 0.3162f, 0.2818f, 0.0891f, 2.7600f, 0.8900f, 0.4100f, 0.3548f, 0.0290f, { 0.0000f, 0.0000f, -0.0000f }, 0.8913f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.1300f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_CITY_UNDERPASS \ - { 1.0000f, 0.8200f, 0.3162f, 0.4467f, 0.8913f, 3.5700f, 1.1200f, 0.9100f, 0.3981f, 0.0590f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0370f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1400f, 0.2500f, 0.0000f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY_ABANDONED \ - { 1.0000f, 0.6900f, 0.3162f, 0.7943f, 0.8913f, 3.2800f, 1.1700f, 0.9100f, 0.4467f, 0.0440f, { 0.0000f, 0.0000f, 0.0000f }, 0.2818f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9966f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -/* Misc. Presets */ - -#define EFX_REVERB_PRESET_DUSTYROOM \ - { 0.3645f, 0.5600f, 0.3162f, 0.7943f, 0.7079f, 1.7900f, 0.3800f, 0.2100f, 0.5012f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0060f, { 0.0000f, 0.0000f, 0.0000f }, 0.2020f, 0.0500f, 0.2500f, 0.0000f, 0.9886f, 13046.0000f, 163.3000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CHAPEL \ - { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 1.0000f, 4.6200f, 0.6400f, 1.2300f, 0.4467f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.1100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SMALLWATERROOM \ - { 1.0000f, 0.7000f, 0.3162f, 0.4477f, 1.0000f, 1.5100f, 1.2500f, 1.1400f, 0.8913f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1790f, 0.1500f, 0.8950f, 0.1900f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#endif /* EFX_PRESETS_H */ diff --git a/Plugins/Audio/alure/AL/efx.h b/Plugins/Audio/alure/AL/efx.h deleted file mode 100644 index dff3102..0000000 --- a/Plugins/Audio/alure/AL/efx.h +++ /dev/null @@ -1,761 +0,0 @@ -#ifndef AL_EFX_H -#define AL_EFX_H - - -#include "../alc.h" -#include "../al.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ALC_EXT_EFX_NAME "ALC_EXT_EFX" - -#define ALC_EFX_MAJOR_VERSION 0x20001 -#define ALC_EFX_MINOR_VERSION 0x20002 -#define ALC_MAX_AUXILIARY_SENDS 0x20003 - - -/* Listener properties. */ -#define AL_METERS_PER_UNIT 0x20004 - -/* Source properties. */ -#define AL_DIRECT_FILTER 0x20005 -#define AL_AUXILIARY_SEND_FILTER 0x20006 -#define AL_AIR_ABSORPTION_FACTOR 0x20007 -#define AL_ROOM_ROLLOFF_FACTOR 0x20008 -#define AL_CONE_OUTER_GAINHF 0x20009 -#define AL_DIRECT_FILTER_GAINHF_AUTO 0x2000A -#define AL_AUXILIARY_SEND_FILTER_GAIN_AUTO 0x2000B -#define AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO 0x2000C - - -/* Effect properties. */ - -/* Reverb effect parameters */ -#define AL_REVERB_DENSITY 0x0001 -#define AL_REVERB_DIFFUSION 0x0002 -#define AL_REVERB_GAIN 0x0003 -#define AL_REVERB_GAINHF 0x0004 -#define AL_REVERB_DECAY_TIME 0x0005 -#define AL_REVERB_DECAY_HFRATIO 0x0006 -#define AL_REVERB_REFLECTIONS_GAIN 0x0007 -#define AL_REVERB_REFLECTIONS_DELAY 0x0008 -#define AL_REVERB_LATE_REVERB_GAIN 0x0009 -#define AL_REVERB_LATE_REVERB_DELAY 0x000A -#define AL_REVERB_AIR_ABSORPTION_GAINHF 0x000B -#define AL_REVERB_ROOM_ROLLOFF_FACTOR 0x000C -#define AL_REVERB_DECAY_HFLIMIT 0x000D - -/* EAX Reverb effect parameters */ -#define AL_EAXREVERB_DENSITY 0x0001 -#define AL_EAXREVERB_DIFFUSION 0x0002 -#define AL_EAXREVERB_GAIN 0x0003 -#define AL_EAXREVERB_GAINHF 0x0004 -#define AL_EAXREVERB_GAINLF 0x0005 -#define AL_EAXREVERB_DECAY_TIME 0x0006 -#define AL_EAXREVERB_DECAY_HFRATIO 0x0007 -#define AL_EAXREVERB_DECAY_LFRATIO 0x0008 -#define AL_EAXREVERB_REFLECTIONS_GAIN 0x0009 -#define AL_EAXREVERB_REFLECTIONS_DELAY 0x000A -#define AL_EAXREVERB_REFLECTIONS_PAN 0x000B -#define AL_EAXREVERB_LATE_REVERB_GAIN 0x000C -#define AL_EAXREVERB_LATE_REVERB_DELAY 0x000D -#define AL_EAXREVERB_LATE_REVERB_PAN 0x000E -#define AL_EAXREVERB_ECHO_TIME 0x000F -#define AL_EAXREVERB_ECHO_DEPTH 0x0010 -#define AL_EAXREVERB_MODULATION_TIME 0x0011 -#define AL_EAXREVERB_MODULATION_DEPTH 0x0012 -#define AL_EAXREVERB_AIR_ABSORPTION_GAINHF 0x0013 -#define AL_EAXREVERB_HFREFERENCE 0x0014 -#define AL_EAXREVERB_LFREFERENCE 0x0015 -#define AL_EAXREVERB_ROOM_ROLLOFF_FACTOR 0x0016 -#define AL_EAXREVERB_DECAY_HFLIMIT 0x0017 - -/* Chorus effect parameters */ -#define AL_CHORUS_WAVEFORM 0x0001 -#define AL_CHORUS_PHASE 0x0002 -#define AL_CHORUS_RATE 0x0003 -#define AL_CHORUS_DEPTH 0x0004 -#define AL_CHORUS_FEEDBACK 0x0005 -#define AL_CHORUS_DELAY 0x0006 - -/* Distortion effect parameters */ -#define AL_DISTORTION_EDGE 0x0001 -#define AL_DISTORTION_GAIN 0x0002 -#define AL_DISTORTION_LOWPASS_CUTOFF 0x0003 -#define AL_DISTORTION_EQCENTER 0x0004 -#define AL_DISTORTION_EQBANDWIDTH 0x0005 - -/* Echo effect parameters */ -#define AL_ECHO_DELAY 0x0001 -#define AL_ECHO_LRDELAY 0x0002 -#define AL_ECHO_DAMPING 0x0003 -#define AL_ECHO_FEEDBACK 0x0004 -#define AL_ECHO_SPREAD 0x0005 - -/* Flanger effect parameters */ -#define AL_FLANGER_WAVEFORM 0x0001 -#define AL_FLANGER_PHASE 0x0002 -#define AL_FLANGER_RATE 0x0003 -#define AL_FLANGER_DEPTH 0x0004 -#define AL_FLANGER_FEEDBACK 0x0005 -#define AL_FLANGER_DELAY 0x0006 - -/* Frequency shifter effect parameters */ -#define AL_FREQUENCY_SHIFTER_FREQUENCY 0x0001 -#define AL_FREQUENCY_SHIFTER_LEFT_DIRECTION 0x0002 -#define AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION 0x0003 - -/* Vocal morpher effect parameters */ -#define AL_VOCAL_MORPHER_PHONEMEA 0x0001 -#define AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING 0x0002 -#define AL_VOCAL_MORPHER_PHONEMEB 0x0003 -#define AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING 0x0004 -#define AL_VOCAL_MORPHER_WAVEFORM 0x0005 -#define AL_VOCAL_MORPHER_RATE 0x0006 - -/* Pitchshifter effect parameters */ -#define AL_PITCH_SHIFTER_COARSE_TUNE 0x0001 -#define AL_PITCH_SHIFTER_FINE_TUNE 0x0002 - -/* Ringmodulator effect parameters */ -#define AL_RING_MODULATOR_FREQUENCY 0x0001 -#define AL_RING_MODULATOR_HIGHPASS_CUTOFF 0x0002 -#define AL_RING_MODULATOR_WAVEFORM 0x0003 - -/* Autowah effect parameters */ -#define AL_AUTOWAH_ATTACK_TIME 0x0001 -#define AL_AUTOWAH_RELEASE_TIME 0x0002 -#define AL_AUTOWAH_RESONANCE 0x0003 -#define AL_AUTOWAH_PEAK_GAIN 0x0004 - -/* Compressor effect parameters */ -#define AL_COMPRESSOR_ONOFF 0x0001 - -/* Equalizer effect parameters */ -#define AL_EQUALIZER_LOW_GAIN 0x0001 -#define AL_EQUALIZER_LOW_CUTOFF 0x0002 -#define AL_EQUALIZER_MID1_GAIN 0x0003 -#define AL_EQUALIZER_MID1_CENTER 0x0004 -#define AL_EQUALIZER_MID1_WIDTH 0x0005 -#define AL_EQUALIZER_MID2_GAIN 0x0006 -#define AL_EQUALIZER_MID2_CENTER 0x0007 -#define AL_EQUALIZER_MID2_WIDTH 0x0008 -#define AL_EQUALIZER_HIGH_GAIN 0x0009 -#define AL_EQUALIZER_HIGH_CUTOFF 0x000A - -/* Effect type */ -#define AL_EFFECT_FIRST_PARAMETER 0x0000 -#define AL_EFFECT_LAST_PARAMETER 0x8000 -#define AL_EFFECT_TYPE 0x8001 - -/* Effect types, used with the AL_EFFECT_TYPE property */ -#define AL_EFFECT_NULL 0x0000 -#define AL_EFFECT_REVERB 0x0001 -#define AL_EFFECT_CHORUS 0x0002 -#define AL_EFFECT_DISTORTION 0x0003 -#define AL_EFFECT_ECHO 0x0004 -#define AL_EFFECT_FLANGER 0x0005 -#define AL_EFFECT_FREQUENCY_SHIFTER 0x0006 -#define AL_EFFECT_VOCAL_MORPHER 0x0007 -#define AL_EFFECT_PITCH_SHIFTER 0x0008 -#define AL_EFFECT_RING_MODULATOR 0x0009 -#define AL_EFFECT_AUTOWAH 0x000A -#define AL_EFFECT_COMPRESSOR 0x000B -#define AL_EFFECT_EQUALIZER 0x000C -#define AL_EFFECT_EAXREVERB 0x8000 - -/* Auxiliary Effect Slot properties. */ -#define AL_EFFECTSLOT_EFFECT 0x0001 -#define AL_EFFECTSLOT_GAIN 0x0002 -#define AL_EFFECTSLOT_AUXILIARY_SEND_AUTO 0x0003 - -/* NULL Auxiliary Slot ID to disable a source send. */ -#define AL_EFFECTSLOT_NULL 0x0000 - - -/* Filter properties. */ - -/* Lowpass filter parameters */ -#define AL_LOWPASS_GAIN 0x0001 -#define AL_LOWPASS_GAINHF 0x0002 - -/* Highpass filter parameters */ -#define AL_HIGHPASS_GAIN 0x0001 -#define AL_HIGHPASS_GAINLF 0x0002 - -/* Bandpass filter parameters */ -#define AL_BANDPASS_GAIN 0x0001 -#define AL_BANDPASS_GAINLF 0x0002 -#define AL_BANDPASS_GAINHF 0x0003 - -/* Filter type */ -#define AL_FILTER_FIRST_PARAMETER 0x0000 -#define AL_FILTER_LAST_PARAMETER 0x8000 -#define AL_FILTER_TYPE 0x8001 - -/* Filter types, used with the AL_FILTER_TYPE property */ -#define AL_FILTER_NULL 0x0000 -#define AL_FILTER_LOWPASS 0x0001 -#define AL_FILTER_HIGHPASS 0x0002 -#define AL_FILTER_BANDPASS 0x0003 - - -/* Effect object function types. */ -typedef void (AL_APIENTRY *LPALGENEFFECTS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEEFFECTS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISEFFECT)(ALuint); -typedef void (AL_APIENTRY *LPALEFFECTI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALEFFECTIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALEFFECTF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALEFFECTFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETEFFECTI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETEFFECTIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETEFFECTF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETEFFECTFV)(ALuint, ALenum, ALfloat*); - -/* Filter object function types. */ -typedef void (AL_APIENTRY *LPALGENFILTERS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEFILTERS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISFILTER)(ALuint); -typedef void (AL_APIENTRY *LPALFILTERI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALFILTERIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALFILTERF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALFILTERFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETFILTERI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETFILTERIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETFILTERF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETFILTERFV)(ALuint, ALenum, ALfloat*); - -/* Auxiliary Effect Slot object function types. */ -typedef void (AL_APIENTRY *LPALGENAUXILIARYEFFECTSLOTS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEAUXILIARYEFFECTSLOTS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISAUXILIARYEFFECTSLOT)(ALuint); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, ALfloat*); - -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects); -AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects); -AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect); -AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues); - -AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters); -AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters); -AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter); -AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues); - -AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots); -AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots); -AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues); -#endif - -/* Filter ranges and defaults. */ - -/* Lowpass filter */ -#define AL_LOWPASS_MIN_GAIN (0.0f) -#define AL_LOWPASS_MAX_GAIN (1.0f) -#define AL_LOWPASS_DEFAULT_GAIN (1.0f) - -#define AL_LOWPASS_MIN_GAINHF (0.0f) -#define AL_LOWPASS_MAX_GAINHF (1.0f) -#define AL_LOWPASS_DEFAULT_GAINHF (1.0f) - -/* Highpass filter */ -#define AL_HIGHPASS_MIN_GAIN (0.0f) -#define AL_HIGHPASS_MAX_GAIN (1.0f) -#define AL_HIGHPASS_DEFAULT_GAIN (1.0f) - -#define AL_HIGHPASS_MIN_GAINLF (0.0f) -#define AL_HIGHPASS_MAX_GAINLF (1.0f) -#define AL_HIGHPASS_DEFAULT_GAINLF (1.0f) - -/* Bandpass filter */ -#define AL_BANDPASS_MIN_GAIN (0.0f) -#define AL_BANDPASS_MAX_GAIN (1.0f) -#define AL_BANDPASS_DEFAULT_GAIN (1.0f) - -#define AL_BANDPASS_MIN_GAINHF (0.0f) -#define AL_BANDPASS_MAX_GAINHF (1.0f) -#define AL_BANDPASS_DEFAULT_GAINHF (1.0f) - -#define AL_BANDPASS_MIN_GAINLF (0.0f) -#define AL_BANDPASS_MAX_GAINLF (1.0f) -#define AL_BANDPASS_DEFAULT_GAINLF (1.0f) - - -/* Effect parameter ranges and defaults. */ - -/* Standard reverb effect */ -#define AL_REVERB_MIN_DENSITY (0.0f) -#define AL_REVERB_MAX_DENSITY (1.0f) -#define AL_REVERB_DEFAULT_DENSITY (1.0f) - -#define AL_REVERB_MIN_DIFFUSION (0.0f) -#define AL_REVERB_MAX_DIFFUSION (1.0f) -#define AL_REVERB_DEFAULT_DIFFUSION (1.0f) - -#define AL_REVERB_MIN_GAIN (0.0f) -#define AL_REVERB_MAX_GAIN (1.0f) -#define AL_REVERB_DEFAULT_GAIN (0.32f) - -#define AL_REVERB_MIN_GAINHF (0.0f) -#define AL_REVERB_MAX_GAINHF (1.0f) -#define AL_REVERB_DEFAULT_GAINHF (0.89f) - -#define AL_REVERB_MIN_DECAY_TIME (0.1f) -#define AL_REVERB_MAX_DECAY_TIME (20.0f) -#define AL_REVERB_DEFAULT_DECAY_TIME (1.49f) - -#define AL_REVERB_MIN_DECAY_HFRATIO (0.1f) -#define AL_REVERB_MAX_DECAY_HFRATIO (2.0f) -#define AL_REVERB_DEFAULT_DECAY_HFRATIO (0.83f) - -#define AL_REVERB_MIN_REFLECTIONS_GAIN (0.0f) -#define AL_REVERB_MAX_REFLECTIONS_GAIN (3.16f) -#define AL_REVERB_DEFAULT_REFLECTIONS_GAIN (0.05f) - -#define AL_REVERB_MIN_REFLECTIONS_DELAY (0.0f) -#define AL_REVERB_MAX_REFLECTIONS_DELAY (0.3f) -#define AL_REVERB_DEFAULT_REFLECTIONS_DELAY (0.007f) - -#define AL_REVERB_MIN_LATE_REVERB_GAIN (0.0f) -#define AL_REVERB_MAX_LATE_REVERB_GAIN (10.0f) -#define AL_REVERB_DEFAULT_LATE_REVERB_GAIN (1.26f) - -#define AL_REVERB_MIN_LATE_REVERB_DELAY (0.0f) -#define AL_REVERB_MAX_LATE_REVERB_DELAY (0.1f) -#define AL_REVERB_DEFAULT_LATE_REVERB_DELAY (0.011f) - -#define AL_REVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f) -#define AL_REVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f) -#define AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f) - -#define AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -#define AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -#define AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) - -#define AL_REVERB_MIN_DECAY_HFLIMIT AL_FALSE -#define AL_REVERB_MAX_DECAY_HFLIMIT AL_TRUE -#define AL_REVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE - -/* EAX reverb effect */ -#define AL_EAXREVERB_MIN_DENSITY (0.0f) -#define AL_EAXREVERB_MAX_DENSITY (1.0f) -#define AL_EAXREVERB_DEFAULT_DENSITY (1.0f) - -#define AL_EAXREVERB_MIN_DIFFUSION (0.0f) -#define AL_EAXREVERB_MAX_DIFFUSION (1.0f) -#define AL_EAXREVERB_DEFAULT_DIFFUSION (1.0f) - -#define AL_EAXREVERB_MIN_GAIN (0.0f) -#define AL_EAXREVERB_MAX_GAIN (1.0f) -#define AL_EAXREVERB_DEFAULT_GAIN (0.32f) - -#define AL_EAXREVERB_MIN_GAINHF (0.0f) -#define AL_EAXREVERB_MAX_GAINHF (1.0f) -#define AL_EAXREVERB_DEFAULT_GAINHF (0.89f) - -#define AL_EAXREVERB_MIN_GAINLF (0.0f) -#define AL_EAXREVERB_MAX_GAINLF (1.0f) -#define AL_EAXREVERB_DEFAULT_GAINLF (1.0f) - -#define AL_EAXREVERB_MIN_DECAY_TIME (0.1f) -#define AL_EAXREVERB_MAX_DECAY_TIME (20.0f) -#define AL_EAXREVERB_DEFAULT_DECAY_TIME (1.49f) - -#define AL_EAXREVERB_MIN_DECAY_HFRATIO (0.1f) -#define AL_EAXREVERB_MAX_DECAY_HFRATIO (2.0f) -#define AL_EAXREVERB_DEFAULT_DECAY_HFRATIO (0.83f) - -#define AL_EAXREVERB_MIN_DECAY_LFRATIO (0.1f) -#define AL_EAXREVERB_MAX_DECAY_LFRATIO (2.0f) -#define AL_EAXREVERB_DEFAULT_DECAY_LFRATIO (1.0f) - -#define AL_EAXREVERB_MIN_REFLECTIONS_GAIN (0.0f) -#define AL_EAXREVERB_MAX_REFLECTIONS_GAIN (3.16f) -#define AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN (0.05f) - -#define AL_EAXREVERB_MIN_REFLECTIONS_DELAY (0.0f) -#define AL_EAXREVERB_MAX_REFLECTIONS_DELAY (0.3f) -#define AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY (0.007f) - -#define AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ (0.0f) - -#define AL_EAXREVERB_MIN_LATE_REVERB_GAIN (0.0f) -#define AL_EAXREVERB_MAX_LATE_REVERB_GAIN (10.0f) -#define AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN (1.26f) - -#define AL_EAXREVERB_MIN_LATE_REVERB_DELAY (0.0f) -#define AL_EAXREVERB_MAX_LATE_REVERB_DELAY (0.1f) -#define AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY (0.011f) - -#define AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ (0.0f) - -#define AL_EAXREVERB_MIN_ECHO_TIME (0.075f) -#define AL_EAXREVERB_MAX_ECHO_TIME (0.25f) -#define AL_EAXREVERB_DEFAULT_ECHO_TIME (0.25f) - -#define AL_EAXREVERB_MIN_ECHO_DEPTH (0.0f) -#define AL_EAXREVERB_MAX_ECHO_DEPTH (1.0f) -#define AL_EAXREVERB_DEFAULT_ECHO_DEPTH (0.0f) - -#define AL_EAXREVERB_MIN_MODULATION_TIME (0.04f) -#define AL_EAXREVERB_MAX_MODULATION_TIME (4.0f) -#define AL_EAXREVERB_DEFAULT_MODULATION_TIME (0.25f) - -#define AL_EAXREVERB_MIN_MODULATION_DEPTH (0.0f) -#define AL_EAXREVERB_MAX_MODULATION_DEPTH (1.0f) -#define AL_EAXREVERB_DEFAULT_MODULATION_DEPTH (0.0f) - -#define AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f) -#define AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f) -#define AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f) - -#define AL_EAXREVERB_MIN_HFREFERENCE (1000.0f) -#define AL_EAXREVERB_MAX_HFREFERENCE (20000.0f) -#define AL_EAXREVERB_DEFAULT_HFREFERENCE (5000.0f) - -#define AL_EAXREVERB_MIN_LFREFERENCE (20.0f) -#define AL_EAXREVERB_MAX_LFREFERENCE (1000.0f) -#define AL_EAXREVERB_DEFAULT_LFREFERENCE (250.0f) - -#define AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -#define AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -#define AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) - -#define AL_EAXREVERB_MIN_DECAY_HFLIMIT AL_FALSE -#define AL_EAXREVERB_MAX_DECAY_HFLIMIT AL_TRUE -#define AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE - -/* Chorus effect */ -#define AL_CHORUS_WAVEFORM_SINUSOID (0) -#define AL_CHORUS_WAVEFORM_TRIANGLE (1) - -#define AL_CHORUS_MIN_WAVEFORM (0) -#define AL_CHORUS_MAX_WAVEFORM (1) -#define AL_CHORUS_DEFAULT_WAVEFORM (1) - -#define AL_CHORUS_MIN_PHASE (-180) -#define AL_CHORUS_MAX_PHASE (180) -#define AL_CHORUS_DEFAULT_PHASE (90) - -#define AL_CHORUS_MIN_RATE (0.0f) -#define AL_CHORUS_MAX_RATE (10.0f) -#define AL_CHORUS_DEFAULT_RATE (1.1f) - -#define AL_CHORUS_MIN_DEPTH (0.0f) -#define AL_CHORUS_MAX_DEPTH (1.0f) -#define AL_CHORUS_DEFAULT_DEPTH (0.1f) - -#define AL_CHORUS_MIN_FEEDBACK (-1.0f) -#define AL_CHORUS_MAX_FEEDBACK (1.0f) -#define AL_CHORUS_DEFAULT_FEEDBACK (0.25f) - -#define AL_CHORUS_MIN_DELAY (0.0f) -#define AL_CHORUS_MAX_DELAY (0.016f) -#define AL_CHORUS_DEFAULT_DELAY (0.016f) - -/* Distortion effect */ -#define AL_DISTORTION_MIN_EDGE (0.0f) -#define AL_DISTORTION_MAX_EDGE (1.0f) -#define AL_DISTORTION_DEFAULT_EDGE (0.2f) - -#define AL_DISTORTION_MIN_GAIN (0.01f) -#define AL_DISTORTION_MAX_GAIN (1.0f) -#define AL_DISTORTION_DEFAULT_GAIN (0.05f) - -#define AL_DISTORTION_MIN_LOWPASS_CUTOFF (80.0f) -#define AL_DISTORTION_MAX_LOWPASS_CUTOFF (24000.0f) -#define AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF (8000.0f) - -#define AL_DISTORTION_MIN_EQCENTER (80.0f) -#define AL_DISTORTION_MAX_EQCENTER (24000.0f) -#define AL_DISTORTION_DEFAULT_EQCENTER (3600.0f) - -#define AL_DISTORTION_MIN_EQBANDWIDTH (80.0f) -#define AL_DISTORTION_MAX_EQBANDWIDTH (24000.0f) -#define AL_DISTORTION_DEFAULT_EQBANDWIDTH (3600.0f) - -/* Echo effect */ -#define AL_ECHO_MIN_DELAY (0.0f) -#define AL_ECHO_MAX_DELAY (0.207f) -#define AL_ECHO_DEFAULT_DELAY (0.1f) - -#define AL_ECHO_MIN_LRDELAY (0.0f) -#define AL_ECHO_MAX_LRDELAY (0.404f) -#define AL_ECHO_DEFAULT_LRDELAY (0.1f) - -#define AL_ECHO_MIN_DAMPING (0.0f) -#define AL_ECHO_MAX_DAMPING (0.99f) -#define AL_ECHO_DEFAULT_DAMPING (0.5f) - -#define AL_ECHO_MIN_FEEDBACK (0.0f) -#define AL_ECHO_MAX_FEEDBACK (1.0f) -#define AL_ECHO_DEFAULT_FEEDBACK (0.5f) - -#define AL_ECHO_MIN_SPREAD (-1.0f) -#define AL_ECHO_MAX_SPREAD (1.0f) -#define AL_ECHO_DEFAULT_SPREAD (-1.0f) - -/* Flanger effect */ -#define AL_FLANGER_WAVEFORM_SINUSOID (0) -#define AL_FLANGER_WAVEFORM_TRIANGLE (1) - -#define AL_FLANGER_MIN_WAVEFORM (0) -#define AL_FLANGER_MAX_WAVEFORM (1) -#define AL_FLANGER_DEFAULT_WAVEFORM (1) - -#define AL_FLANGER_MIN_PHASE (-180) -#define AL_FLANGER_MAX_PHASE (180) -#define AL_FLANGER_DEFAULT_PHASE (0) - -#define AL_FLANGER_MIN_RATE (0.0f) -#define AL_FLANGER_MAX_RATE (10.0f) -#define AL_FLANGER_DEFAULT_RATE (0.27f) - -#define AL_FLANGER_MIN_DEPTH (0.0f) -#define AL_FLANGER_MAX_DEPTH (1.0f) -#define AL_FLANGER_DEFAULT_DEPTH (1.0f) - -#define AL_FLANGER_MIN_FEEDBACK (-1.0f) -#define AL_FLANGER_MAX_FEEDBACK (1.0f) -#define AL_FLANGER_DEFAULT_FEEDBACK (-0.5f) - -#define AL_FLANGER_MIN_DELAY (0.0f) -#define AL_FLANGER_MAX_DELAY (0.004f) -#define AL_FLANGER_DEFAULT_DELAY (0.002f) - -/* Frequency shifter effect */ -#define AL_FREQUENCY_SHIFTER_MIN_FREQUENCY (0.0f) -#define AL_FREQUENCY_SHIFTER_MAX_FREQUENCY (24000.0f) -#define AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY (0.0f) - -#define AL_FREQUENCY_SHIFTER_MIN_LEFT_DIRECTION (0) -#define AL_FREQUENCY_SHIFTER_MAX_LEFT_DIRECTION (2) -#define AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION (0) - -#define AL_FREQUENCY_SHIFTER_DIRECTION_DOWN (0) -#define AL_FREQUENCY_SHIFTER_DIRECTION_UP (1) -#define AL_FREQUENCY_SHIFTER_DIRECTION_OFF (2) - -#define AL_FREQUENCY_SHIFTER_MIN_RIGHT_DIRECTION (0) -#define AL_FREQUENCY_SHIFTER_MAX_RIGHT_DIRECTION (2) -#define AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION (0) - -/* Vocal morpher effect */ -#define AL_VOCAL_MORPHER_MIN_PHONEMEA (0) -#define AL_VOCAL_MORPHER_MAX_PHONEMEA (29) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA (0) - -#define AL_VOCAL_MORPHER_MIN_PHONEMEA_COARSE_TUNING (-24) -#define AL_VOCAL_MORPHER_MAX_PHONEMEA_COARSE_TUNING (24) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA_COARSE_TUNING (0) - -#define AL_VOCAL_MORPHER_MIN_PHONEMEB (0) -#define AL_VOCAL_MORPHER_MAX_PHONEMEB (29) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB (10) - -#define AL_VOCAL_MORPHER_MIN_PHONEMEB_COARSE_TUNING (-24) -#define AL_VOCAL_MORPHER_MAX_PHONEMEB_COARSE_TUNING (24) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB_COARSE_TUNING (0) - -#define AL_VOCAL_MORPHER_PHONEME_A (0) -#define AL_VOCAL_MORPHER_PHONEME_E (1) -#define AL_VOCAL_MORPHER_PHONEME_I (2) -#define AL_VOCAL_MORPHER_PHONEME_O (3) -#define AL_VOCAL_MORPHER_PHONEME_U (4) -#define AL_VOCAL_MORPHER_PHONEME_AA (5) -#define AL_VOCAL_MORPHER_PHONEME_AE (6) -#define AL_VOCAL_MORPHER_PHONEME_AH (7) -#define AL_VOCAL_MORPHER_PHONEME_AO (8) -#define AL_VOCAL_MORPHER_PHONEME_EH (9) -#define AL_VOCAL_MORPHER_PHONEME_ER (10) -#define AL_VOCAL_MORPHER_PHONEME_IH (11) -#define AL_VOCAL_MORPHER_PHONEME_IY (12) -#define AL_VOCAL_MORPHER_PHONEME_UH (13) -#define AL_VOCAL_MORPHER_PHONEME_UW (14) -#define AL_VOCAL_MORPHER_PHONEME_B (15) -#define AL_VOCAL_MORPHER_PHONEME_D (16) -#define AL_VOCAL_MORPHER_PHONEME_F (17) -#define AL_VOCAL_MORPHER_PHONEME_G (18) -#define AL_VOCAL_MORPHER_PHONEME_J (19) -#define AL_VOCAL_MORPHER_PHONEME_K (20) -#define AL_VOCAL_MORPHER_PHONEME_L (21) -#define AL_VOCAL_MORPHER_PHONEME_M (22) -#define AL_VOCAL_MORPHER_PHONEME_N (23) -#define AL_VOCAL_MORPHER_PHONEME_P (24) -#define AL_VOCAL_MORPHER_PHONEME_R (25) -#define AL_VOCAL_MORPHER_PHONEME_S (26) -#define AL_VOCAL_MORPHER_PHONEME_T (27) -#define AL_VOCAL_MORPHER_PHONEME_V (28) -#define AL_VOCAL_MORPHER_PHONEME_Z (29) - -#define AL_VOCAL_MORPHER_WAVEFORM_SINUSOID (0) -#define AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE (1) -#define AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH (2) - -#define AL_VOCAL_MORPHER_MIN_WAVEFORM (0) -#define AL_VOCAL_MORPHER_MAX_WAVEFORM (2) -#define AL_VOCAL_MORPHER_DEFAULT_WAVEFORM (0) - -#define AL_VOCAL_MORPHER_MIN_RATE (0.0f) -#define AL_VOCAL_MORPHER_MAX_RATE (10.0f) -#define AL_VOCAL_MORPHER_DEFAULT_RATE (1.41f) - -/* Pitch shifter effect */ -#define AL_PITCH_SHIFTER_MIN_COARSE_TUNE (-12) -#define AL_PITCH_SHIFTER_MAX_COARSE_TUNE (12) -#define AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE (12) - -#define AL_PITCH_SHIFTER_MIN_FINE_TUNE (-50) -#define AL_PITCH_SHIFTER_MAX_FINE_TUNE (50) -#define AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE (0) - -/* Ring modulator effect */ -#define AL_RING_MODULATOR_MIN_FREQUENCY (0.0f) -#define AL_RING_MODULATOR_MAX_FREQUENCY (8000.0f) -#define AL_RING_MODULATOR_DEFAULT_FREQUENCY (440.0f) - -#define AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF (0.0f) -#define AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF (24000.0f) -#define AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF (800.0f) - -#define AL_RING_MODULATOR_SINUSOID (0) -#define AL_RING_MODULATOR_SAWTOOTH (1) -#define AL_RING_MODULATOR_SQUARE (2) - -#define AL_RING_MODULATOR_MIN_WAVEFORM (0) -#define AL_RING_MODULATOR_MAX_WAVEFORM (2) -#define AL_RING_MODULATOR_DEFAULT_WAVEFORM (0) - -/* Autowah effect */ -#define AL_AUTOWAH_MIN_ATTACK_TIME (0.0001f) -#define AL_AUTOWAH_MAX_ATTACK_TIME (1.0f) -#define AL_AUTOWAH_DEFAULT_ATTACK_TIME (0.06f) - -#define AL_AUTOWAH_MIN_RELEASE_TIME (0.0001f) -#define AL_AUTOWAH_MAX_RELEASE_TIME (1.0f) -#define AL_AUTOWAH_DEFAULT_RELEASE_TIME (0.06f) - -#define AL_AUTOWAH_MIN_RESONANCE (2.0f) -#define AL_AUTOWAH_MAX_RESONANCE (1000.0f) -#define AL_AUTOWAH_DEFAULT_RESONANCE (1000.0f) - -#define AL_AUTOWAH_MIN_PEAK_GAIN (0.00003f) -#define AL_AUTOWAH_MAX_PEAK_GAIN (31621.0f) -#define AL_AUTOWAH_DEFAULT_PEAK_GAIN (11.22f) - -/* Compressor effect */ -#define AL_COMPRESSOR_MIN_ONOFF (0) -#define AL_COMPRESSOR_MAX_ONOFF (1) -#define AL_COMPRESSOR_DEFAULT_ONOFF (1) - -/* Equalizer effect */ -#define AL_EQUALIZER_MIN_LOW_GAIN (0.126f) -#define AL_EQUALIZER_MAX_LOW_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_LOW_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_LOW_CUTOFF (50.0f) -#define AL_EQUALIZER_MAX_LOW_CUTOFF (800.0f) -#define AL_EQUALIZER_DEFAULT_LOW_CUTOFF (200.0f) - -#define AL_EQUALIZER_MIN_MID1_GAIN (0.126f) -#define AL_EQUALIZER_MAX_MID1_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_MID1_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_MID1_CENTER (200.0f) -#define AL_EQUALIZER_MAX_MID1_CENTER (3000.0f) -#define AL_EQUALIZER_DEFAULT_MID1_CENTER (500.0f) - -#define AL_EQUALIZER_MIN_MID1_WIDTH (0.01f) -#define AL_EQUALIZER_MAX_MID1_WIDTH (1.0f) -#define AL_EQUALIZER_DEFAULT_MID1_WIDTH (1.0f) - -#define AL_EQUALIZER_MIN_MID2_GAIN (0.126f) -#define AL_EQUALIZER_MAX_MID2_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_MID2_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_MID2_CENTER (1000.0f) -#define AL_EQUALIZER_MAX_MID2_CENTER (8000.0f) -#define AL_EQUALIZER_DEFAULT_MID2_CENTER (3000.0f) - -#define AL_EQUALIZER_MIN_MID2_WIDTH (0.01f) -#define AL_EQUALIZER_MAX_MID2_WIDTH (1.0f) -#define AL_EQUALIZER_DEFAULT_MID2_WIDTH (1.0f) - -#define AL_EQUALIZER_MIN_HIGH_GAIN (0.126f) -#define AL_EQUALIZER_MAX_HIGH_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_HIGH_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_HIGH_CUTOFF (4000.0f) -#define AL_EQUALIZER_MAX_HIGH_CUTOFF (16000.0f) -#define AL_EQUALIZER_DEFAULT_HIGH_CUTOFF (6000.0f) - - -/* Source parameter value ranges and defaults. */ -#define AL_MIN_AIR_ABSORPTION_FACTOR (0.0f) -#define AL_MAX_AIR_ABSORPTION_FACTOR (10.0f) -#define AL_DEFAULT_AIR_ABSORPTION_FACTOR (0.0f) - -#define AL_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -#define AL_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -#define AL_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) - -#define AL_MIN_CONE_OUTER_GAINHF (0.0f) -#define AL_MAX_CONE_OUTER_GAINHF (1.0f) -#define AL_DEFAULT_CONE_OUTER_GAINHF (1.0f) - -#define AL_MIN_DIRECT_FILTER_GAINHF_AUTO AL_FALSE -#define AL_MAX_DIRECT_FILTER_GAINHF_AUTO AL_TRUE -#define AL_DEFAULT_DIRECT_FILTER_GAINHF_AUTO AL_TRUE - -#define AL_MIN_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_FALSE -#define AL_MAX_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE -#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE - -#define AL_MIN_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_FALSE -#define AL_MAX_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE -#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE - - -/* Listener parameter value ranges and defaults. */ -#define AL_MIN_METERS_PER_UNIT FLT_MIN -#define AL_MAX_METERS_PER_UNIT FLT_MAX -#define AL_DEFAULT_METERS_PER_UNIT (1.0f) - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* AL_EFX_H */ diff --git a/Plugins/Audio/alure/al.h b/Plugins/Audio/alure/al.h deleted file mode 100644 index 413b383..0000000 --- a/Plugins/Audio/alure/al.h +++ /dev/null @@ -1,656 +0,0 @@ -#ifndef AL_AL_H -#define AL_AL_H - -#if defined(__cplusplus) -extern "C" { -#endif - -#ifndef AL_API - #if defined(AL_LIBTYPE_STATIC) - #define AL_API - #elif defined(_WIN32) - #define AL_API __declspec(dllimport) - #else - #define AL_API extern - #endif -#endif - -#if defined(_WIN32) - #define AL_APIENTRY __cdecl -#else - #define AL_APIENTRY -#endif - - -/** Deprecated macro. */ -#define OPENAL -#define ALAPI AL_API -#define ALAPIENTRY AL_APIENTRY -#define AL_INVALID (-1) -#define AL_ILLEGAL_ENUM AL_INVALID_ENUM -#define AL_ILLEGAL_COMMAND AL_INVALID_OPERATION - -/** Supported AL version. */ -#define AL_VERSION_1_0 -#define AL_VERSION_1_1 - -/** 8-bit boolean */ -typedef char ALboolean; - -/** character */ -typedef char ALchar; - -/** signed 8-bit 2's complement integer */ -typedef signed char ALbyte; - -/** unsigned 8-bit integer */ -typedef unsigned char ALubyte; - -/** signed 16-bit 2's complement integer */ -typedef short ALshort; - -/** unsigned 16-bit integer */ -typedef unsigned short ALushort; - -/** signed 32-bit 2's complement integer */ -typedef int ALint; - -/** unsigned 32-bit integer */ -typedef unsigned int ALuint; - -/** non-negative 32-bit binary integer size */ -typedef int ALsizei; - -/** enumerated 32-bit value */ -typedef int ALenum; - -/** 32-bit IEEE754 floating-point */ -typedef float ALfloat; - -/** 64-bit IEEE754 floating-point */ -typedef double ALdouble; - -/** void type (for opaque pointers only) */ -typedef void ALvoid; - - -/* Enumerant values begin at column 50. No tabs. */ - -/** "no distance model" or "no buffer" */ -#define AL_NONE 0 - -/** Boolean False. */ -#define AL_FALSE 0 - -/** Boolean True. */ -#define AL_TRUE 1 - - -/** - * Relative source. - * Type: ALboolean - * Range: [AL_TRUE, AL_FALSE] - * Default: AL_FALSE - * - * Specifies if the Source has relative coordinates. - */ -#define AL_SOURCE_RELATIVE 0x202 - - -/** - * Inner cone angle, in degrees. - * Type: ALint, ALfloat - * Range: [0 - 360] - * Default: 360 - * - * The angle covered by the inner cone, where the source will not attenuate. - */ -#define AL_CONE_INNER_ANGLE 0x1001 - -/** - * Outer cone angle, in degrees. - * Range: [0 - 360] - * Default: 360 - * - * The angle covered by the outer cone, where the source will be fully - * attenuated. - */ -#define AL_CONE_OUTER_ANGLE 0x1002 - -/** - * Source pitch. - * Type: ALfloat - * Range: [0.5 - 2.0] - * Default: 1.0 - * - * A multiplier for the frequency (sample rate) of the source's buffer. - */ -#define AL_PITCH 0x1003 - -/** - * Source or listener position. - * Type: ALfloat[3], ALint[3] - * Default: {0, 0, 0} - * - * The source or listener location in three dimensional space. - * - * OpenAL, like OpenGL, uses a right handed coordinate system, where in a - * frontal default view X (thumb) points right, Y points up (index finger), and - * Z points towards the viewer/camera (middle finger). - * - * To switch from a left handed coordinate system, flip the sign on the Z - * coordinate. - */ -#define AL_POSITION 0x1004 - -/** - * Source direction. - * Type: ALfloat[3], ALint[3] - * Default: {0, 0, 0} - * - * Specifies the current direction in local space. - * A zero-length vector specifies an omni-directional source (cone is ignored). - */ -#define AL_DIRECTION 0x1005 - -/** - * Source or listener velocity. - * Type: ALfloat[3], ALint[3] - * Default: {0, 0, 0} - * - * Specifies the current velocity in local space. - */ -#define AL_VELOCITY 0x1006 - -/** - * Source looping. - * Type: ALboolean - * Range: [AL_TRUE, AL_FALSE] - * Default: AL_FALSE - * - * Specifies whether source is looping. - */ -#define AL_LOOPING 0x1007 - -/** - * Source buffer. - * Type: ALuint - * Range: any valid Buffer. - * - * Specifies the buffer to provide sound samples. - */ -#define AL_BUFFER 0x1009 - -/** - * Source or listener gain. - * Type: ALfloat - * Range: [0.0 - ] - * - * A value of 1.0 means unattenuated. Each division by 2 equals an attenuation - * of about -6dB. Each multiplicaton by 2 equals an amplification of about - * +6dB. - * - * A value of 0.0 is meaningless with respect to a logarithmic scale; it is - * silent. - */ -#define AL_GAIN 0x100A - -/** - * Minimum source gain. - * Type: ALfloat - * Range: [0.0 - 1.0] - * - * The minimum gain allowed for a source, after distance and cone attenation is - * applied (if applicable). - */ -#define AL_MIN_GAIN 0x100D - -/** - * Maximum source gain. - * Type: ALfloat - * Range: [0.0 - 1.0] - * - * The maximum gain allowed for a source, after distance and cone attenation is - * applied (if applicable). - */ -#define AL_MAX_GAIN 0x100E - -/** - * Listener orientation. - * Type: ALfloat[6] - * Default: {0.0, 0.0, -1.0, 0.0, 1.0, 0.0} - * - * Effectively two three dimensional vectors. The first vector is the front (or - * "at") and the second is the top (or "up"). - * - * Both vectors are in local space. - */ -#define AL_ORIENTATION 0x100F - -/** - * Source state (query only). - * Type: ALint - * Range: [AL_INITIAL, AL_PLAYING, AL_PAUSED, AL_STOPPED] - */ -#define AL_SOURCE_STATE 0x1010 - -/** Source state value. */ -#define AL_INITIAL 0x1011 -#define AL_PLAYING 0x1012 -#define AL_PAUSED 0x1013 -#define AL_STOPPED 0x1014 - -/** - * Source Buffer Queue size (query only). - * Type: ALint - * - * The number of buffers queued using alSourceQueueBuffers, minus the buffers - * removed with alSourceUnqueueBuffers. - */ -#define AL_BUFFERS_QUEUED 0x1015 - -/** - * Source Buffer Queue processed count (query only). - * Type: ALint - * - * The number of queued buffers that have been fully processed, and can be - * removed with alSourceUnqueueBuffers. - * - * Looping sources will never fully process buffers because they will be set to - * play again for when the source loops. - */ -#define AL_BUFFERS_PROCESSED 0x1016 - -/** - * Source reference distance. - * Type: ALfloat - * Range: [0.0 - ] - * Default: 1.0 - * - * The distance in units that no attenuation occurs. - * - * At 0.0, no distance attenuation ever occurs on non-linear attenuation models. - */ -#define AL_REFERENCE_DISTANCE 0x1020 - -/** - * Source rolloff factor. - * Type: ALfloat - * Range: [0.0 - ] - * Default: 1.0 - * - * Multiplier to exaggerate or diminish distance attenuation. - * - * At 0.0, no distance attenuation ever occurs. - */ -#define AL_ROLLOFF_FACTOR 0x1021 - -/** - * Outer cone gain. - * Type: ALfloat - * Range: [0.0 - 1.0] - * Default: 0.0 - * - * The gain attenuation applied when the listener is outside of the source's - * outer cone. - */ -#define AL_CONE_OUTER_GAIN 0x1022 - -/** - * Source maximum distance. - * Type: ALfloat - * Range: [0.0 - ] - * Default: +inf - * - * The distance above which the source is not attenuated any further with a - * clamped distance model, or where attenuation reaches 0.0 gain for linear - * distance models with a default rolloff factor. - */ -#define AL_MAX_DISTANCE 0x1023 - -/** Source buffer position, in seconds */ -#define AL_SEC_OFFSET 0x1024 -/** Source buffer position, in sample frames */ -#define AL_SAMPLE_OFFSET 0x1025 -/** Source buffer position, in bytes */ -#define AL_BYTE_OFFSET 0x1026 - -/** - * Source type (query only). - * Type: ALint - * Range: [AL_STATIC, AL_STREAMING, AL_UNDETERMINED] - * - * A Source is Static if a Buffer has been attached using AL_BUFFER. - * - * A Source is Streaming if one or more Buffers have been attached using - * alSourceQueueBuffers. - * - * A Source is Undetermined when it has the NULL buffer attached using - * AL_BUFFER. - */ -#define AL_SOURCE_TYPE 0x1027 - -/** Source type value. */ -#define AL_STATIC 0x1028 -#define AL_STREAMING 0x1029 -#define AL_UNDETERMINED 0x1030 - -/** Buffer format specifier. */ -#define AL_FORMAT_MONO8 0x1100 -#define AL_FORMAT_MONO16 0x1101 -#define AL_FORMAT_STEREO8 0x1102 -#define AL_FORMAT_STEREO16 0x1103 - -/** Buffer frequency (query only). */ -#define AL_FREQUENCY 0x2001 -/** Buffer bits per sample (query only). */ -#define AL_BITS 0x2002 -/** Buffer channel count (query only). */ -#define AL_CHANNELS 0x2003 -/** Buffer data size (query only). */ -#define AL_SIZE 0x2004 - -/** - * Buffer state. - * - * Not for public use. - */ -#define AL_UNUSED 0x2010 -#define AL_PENDING 0x2011 -#define AL_PROCESSED 0x2012 - - -/** No error. */ -#define AL_NO_ERROR 0 - -/** Invalid name paramater passed to AL call. */ -#define AL_INVALID_NAME 0xA001 - -/** Invalid enum parameter passed to AL call. */ -#define AL_INVALID_ENUM 0xA002 - -/** Invalid value parameter passed to AL call. */ -#define AL_INVALID_VALUE 0xA003 - -/** Illegal AL call. */ -#define AL_INVALID_OPERATION 0xA004 - -/** Not enough memory. */ -#define AL_OUT_OF_MEMORY 0xA005 - - -/** Context string: Vendor ID. */ -#define AL_VENDOR 0xB001 -/** Context string: Version. */ -#define AL_VERSION 0xB002 -/** Context string: Renderer ID. */ -#define AL_RENDERER 0xB003 -/** Context string: Space-separated extension list. */ -#define AL_EXTENSIONS 0xB004 - - -/** - * Doppler scale. - * Type: ALfloat - * Range: [0.0 - ] - * Default: 1.0 - * - * Scale for source and listener velocities. - */ -#define AL_DOPPLER_FACTOR 0xC000 -AL_API void AL_APIENTRY alDopplerFactor(ALfloat value); - -/** - * Doppler velocity (deprecated). - * - * A multiplier applied to the Speed of Sound. - */ -#define AL_DOPPLER_VELOCITY 0xC001 -AL_API void AL_APIENTRY alDopplerVelocity(ALfloat value); - -/** - * Speed of Sound, in units per second. - * Type: ALfloat - * Range: [0.0001 - ] - * Default: 343.3 - * - * The speed at which sound waves are assumed to travel, when calculating the - * doppler effect. - */ -#define AL_SPEED_OF_SOUND 0xC003 -AL_API void AL_APIENTRY alSpeedOfSound(ALfloat value); - -/** - * Distance attenuation model. - * Type: ALint - * Range: [AL_NONE, AL_INVERSE_DISTANCE, AL_INVERSE_DISTANCE_CLAMPED, - * AL_LINEAR_DISTANCE, AL_LINEAR_DISTANCE_CLAMPED, - * AL_EXPONENT_DISTANCE, AL_EXPONENT_DISTANCE_CLAMPED] - * Default: AL_INVERSE_DISTANCE_CLAMPED - * - * The model by which sources attenuate with distance. - * - * None - No distance attenuation. - * Inverse - Doubling the distance halves the source gain. - * Linear - Linear gain scaling between the reference and max distances. - * Exponent - Exponential gain dropoff. - * - * Clamped variations work like the non-clamped counterparts, except the - * distance calculated is clamped between the reference and max distances. - */ -#define AL_DISTANCE_MODEL 0xD000 -AL_API void AL_APIENTRY alDistanceModel(ALenum distanceModel); - -/** Distance model value. */ -#define AL_INVERSE_DISTANCE 0xD001 -#define AL_INVERSE_DISTANCE_CLAMPED 0xD002 -#define AL_LINEAR_DISTANCE 0xD003 -#define AL_LINEAR_DISTANCE_CLAMPED 0xD004 -#define AL_EXPONENT_DISTANCE 0xD005 -#define AL_EXPONENT_DISTANCE_CLAMPED 0xD006 - -/** Renderer State management. */ -AL_API void AL_APIENTRY alEnable(ALenum capability); -AL_API void AL_APIENTRY alDisable(ALenum capability); -AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability); - -/** State retrieval. */ -AL_API const ALchar* AL_APIENTRY alGetString(ALenum param); -AL_API void AL_APIENTRY alGetBooleanv(ALenum param, ALboolean *values); -AL_API void AL_APIENTRY alGetIntegerv(ALenum param, ALint *values); -AL_API void AL_APIENTRY alGetFloatv(ALenum param, ALfloat *values); -AL_API void AL_APIENTRY alGetDoublev(ALenum param, ALdouble *values); -AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum param); -AL_API ALint AL_APIENTRY alGetInteger(ALenum param); -AL_API ALfloat AL_APIENTRY alGetFloat(ALenum param); -AL_API ALdouble AL_APIENTRY alGetDouble(ALenum param); - -/** - * Error retrieval. - * - * Obtain the first error generated in the AL context since the last check. - */ -AL_API ALenum AL_APIENTRY alGetError(void); - -/** - * Extension support. - * - * Query for the presence of an extension, and obtain any appropriate function - * pointers and enum values. - */ -AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extname); -AL_API void* AL_APIENTRY alGetProcAddress(const ALchar *fname); -AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *ename); - - -/** Set Listener parameters */ -AL_API void AL_APIENTRY alListenerf(ALenum param, ALfloat value); -AL_API void AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); -AL_API void AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values); -AL_API void AL_APIENTRY alListeneri(ALenum param, ALint value); -AL_API void AL_APIENTRY alListener3i(ALenum param, ALint value1, ALint value2, ALint value3); -AL_API void AL_APIENTRY alListeneriv(ALenum param, const ALint *values); - -/** Get Listener parameters */ -AL_API void AL_APIENTRY alGetListenerf(ALenum param, ALfloat *value); -AL_API void AL_APIENTRY alGetListener3f(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); -AL_API void AL_APIENTRY alGetListenerfv(ALenum param, ALfloat *values); -AL_API void AL_APIENTRY alGetListeneri(ALenum param, ALint *value); -AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3); -AL_API void AL_APIENTRY alGetListeneriv(ALenum param, ALint *values); - - -/** Create Source objects. */ -AL_API void AL_APIENTRY alGenSources(ALsizei n, ALuint *sources); -/** Delete Source objects. */ -AL_API void AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources); -/** Verify a handle is a valid Source. */ -AL_API ALboolean AL_APIENTRY alIsSource(ALuint source); - -/** Set Source parameters. */ -AL_API void AL_APIENTRY alSourcef(ALuint source, ALenum param, ALfloat value); -AL_API void AL_APIENTRY alSource3f(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); -AL_API void AL_APIENTRY alSourcefv(ALuint source, ALenum param, const ALfloat *values); -AL_API void AL_APIENTRY alSourcei(ALuint source, ALenum param, ALint value); -AL_API void AL_APIENTRY alSource3i(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3); -AL_API void AL_APIENTRY alSourceiv(ALuint source, ALenum param, const ALint *values); - -/** Get Source parameters. */ -AL_API void AL_APIENTRY alGetSourcef(ALuint source, ALenum param, ALfloat *value); -AL_API void AL_APIENTRY alGetSource3f(ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); -AL_API void AL_APIENTRY alGetSourcefv(ALuint source, ALenum param, ALfloat *values); -AL_API void AL_APIENTRY alGetSourcei(ALuint source, ALenum param, ALint *value); -AL_API void AL_APIENTRY alGetSource3i(ALuint source, ALenum param, ALint *value1, ALint *value2, ALint *value3); -AL_API void AL_APIENTRY alGetSourceiv(ALuint source, ALenum param, ALint *values); - - -/** Play, replay, or resume (if paused) a list of Sources */ -AL_API void AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources); -/** Stop a list of Sources */ -AL_API void AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources); -/** Rewind a list of Sources */ -AL_API void AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources); -/** Pause a list of Sources */ -AL_API void AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources); - -/** Play, replay, or resume a Source */ -AL_API void AL_APIENTRY alSourcePlay(ALuint source); -/** Stop a Source */ -AL_API void AL_APIENTRY alSourceStop(ALuint source); -/** Rewind a Source (set playback postiton to beginning) */ -AL_API void AL_APIENTRY alSourceRewind(ALuint source); -/** Pause a Source */ -AL_API void AL_APIENTRY alSourcePause(ALuint source); - -/** Queue buffers onto a source */ -AL_API void AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei nb, const ALuint *buffers); -/** Unqueue processed buffers from a source */ -AL_API void AL_APIENTRY alSourceUnqueueBuffers(ALuint source, ALsizei nb, ALuint *buffers); - - -/** Create Buffer objects */ -AL_API void AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers); -/** Delete Buffer objects */ -AL_API void AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers); -/** Verify a handle is a valid Buffer */ -AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer); - -/** Specifies the data to be copied into a buffer */ -AL_API void AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq); - -/** Set Buffer parameters, */ -AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum param, ALfloat value); -AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); -AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum param, const ALfloat *values); -AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum param, ALint value); -AL_API void AL_APIENTRY alBuffer3i(ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3); -AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum param, const ALint *values); - -/** Get Buffer parameters. */ -AL_API void AL_APIENTRY alGetBufferf(ALuint buffer, ALenum param, ALfloat *value); -AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); -AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum param, ALfloat *values); -AL_API void AL_APIENTRY alGetBufferi(ALuint buffer, ALenum param, ALint *value); -AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3); -AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum param, ALint *values); - -/** Pointer-to-function type, useful for dynamically getting AL entry points. */ -typedef void (AL_APIENTRY *LPALENABLE)(ALenum capability); -typedef void (AL_APIENTRY *LPALDISABLE)(ALenum capability); -typedef ALboolean (AL_APIENTRY *LPALISENABLED)(ALenum capability); -typedef const ALchar* (AL_APIENTRY *LPALGETSTRING)(ALenum param); -typedef void (AL_APIENTRY *LPALGETBOOLEANV)(ALenum param, ALboolean *values); -typedef void (AL_APIENTRY *LPALGETINTEGERV)(ALenum param, ALint *values); -typedef void (AL_APIENTRY *LPALGETFLOATV)(ALenum param, ALfloat *values); -typedef void (AL_APIENTRY *LPALGETDOUBLEV)(ALenum param, ALdouble *values); -typedef ALboolean (AL_APIENTRY *LPALGETBOOLEAN)(ALenum param); -typedef ALint (AL_APIENTRY *LPALGETINTEGER)(ALenum param); -typedef ALfloat (AL_APIENTRY *LPALGETFLOAT)(ALenum param); -typedef ALdouble (AL_APIENTRY *LPALGETDOUBLE)(ALenum param); -typedef ALenum (AL_APIENTRY *LPALGETERROR)(void); -typedef ALboolean (AL_APIENTRY *LPALISEXTENSIONPRESENT)(const ALchar *extname); -typedef void* (AL_APIENTRY *LPALGETPROCADDRESS)(const ALchar *fname); -typedef ALenum (AL_APIENTRY *LPALGETENUMVALUE)(const ALchar *ename); -typedef void (AL_APIENTRY *LPALLISTENERF)(ALenum param, ALfloat value); -typedef void (AL_APIENTRY *LPALLISTENER3F)(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); -typedef void (AL_APIENTRY *LPALLISTENERFV)(ALenum param, const ALfloat *values); -typedef void (AL_APIENTRY *LPALLISTENERI)(ALenum param, ALint value); -typedef void (AL_APIENTRY *LPALLISTENER3I)(ALenum param, ALint value1, ALint value2, ALint value3); -typedef void (AL_APIENTRY *LPALLISTENERIV)(ALenum param, const ALint *values); -typedef void (AL_APIENTRY *LPALGETLISTENERF)(ALenum param, ALfloat *value); -typedef void (AL_APIENTRY *LPALGETLISTENER3F)(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); -typedef void (AL_APIENTRY *LPALGETLISTENERFV)(ALenum param, ALfloat *values); -typedef void (AL_APIENTRY *LPALGETLISTENERI)(ALenum param, ALint *value); -typedef void (AL_APIENTRY *LPALGETLISTENER3I)(ALenum param, ALint *value1, ALint *value2, ALint *value3); -typedef void (AL_APIENTRY *LPALGETLISTENERIV)(ALenum param, ALint *values); -typedef void (AL_APIENTRY *LPALGENSOURCES)(ALsizei n, ALuint *sources); -typedef void (AL_APIENTRY *LPALDELETESOURCES)(ALsizei n, const ALuint *sources); -typedef ALboolean (AL_APIENTRY *LPALISSOURCE)(ALuint source); -typedef void (AL_APIENTRY *LPALSOURCEF)(ALuint source, ALenum param, ALfloat value); -typedef void (AL_APIENTRY *LPALSOURCE3F)(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); -typedef void (AL_APIENTRY *LPALSOURCEFV)(ALuint source, ALenum param, const ALfloat *values); -typedef void (AL_APIENTRY *LPALSOURCEI)(ALuint source, ALenum param, ALint value); -typedef void (AL_APIENTRY *LPALSOURCE3I)(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3); -typedef void (AL_APIENTRY *LPALSOURCEIV)(ALuint source, ALenum param, const ALint *values); -typedef void (AL_APIENTRY *LPALGETSOURCEF)(ALuint source, ALenum param, ALfloat *value); -typedef void (AL_APIENTRY *LPALGETSOURCE3F)(ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); -typedef void (AL_APIENTRY *LPALGETSOURCEFV)(ALuint source, ALenum param, ALfloat *values); -typedef void (AL_APIENTRY *LPALGETSOURCEI)(ALuint source, ALenum param, ALint *value); -typedef void (AL_APIENTRY *LPALGETSOURCE3I)(ALuint source, ALenum param, ALint *value1, ALint *value2, ALint *value3); -typedef void (AL_APIENTRY *LPALGETSOURCEIV)(ALuint source, ALenum param, ALint *values); -typedef void (AL_APIENTRY *LPALSOURCEPLAYV)(ALsizei n, const ALuint *sources); -typedef void (AL_APIENTRY *LPALSOURCESTOPV)(ALsizei n, const ALuint *sources); -typedef void (AL_APIENTRY *LPALSOURCEREWINDV)(ALsizei n, const ALuint *sources); -typedef void (AL_APIENTRY *LPALSOURCEPAUSEV)(ALsizei n, const ALuint *sources); -typedef void (AL_APIENTRY *LPALSOURCEPLAY)(ALuint source); -typedef void (AL_APIENTRY *LPALSOURCESTOP)(ALuint source); -typedef void (AL_APIENTRY *LPALSOURCEREWIND)(ALuint source); -typedef void (AL_APIENTRY *LPALSOURCEPAUSE)(ALuint source); -typedef void (AL_APIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint source, ALsizei nb, const ALuint *buffers); -typedef void (AL_APIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint source, ALsizei nb, ALuint *buffers); -typedef void (AL_APIENTRY *LPALGENBUFFERS)(ALsizei n, ALuint *buffers); -typedef void (AL_APIENTRY *LPALDELETEBUFFERS)(ALsizei n, const ALuint *buffers); -typedef ALboolean (AL_APIENTRY *LPALISBUFFER)(ALuint buffer); -typedef void (AL_APIENTRY *LPALBUFFERDATA)(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq); -typedef void (AL_APIENTRY *LPALBUFFERF)(ALuint buffer, ALenum param, ALfloat value); -typedef void (AL_APIENTRY *LPALBUFFER3F)(ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); -typedef void (AL_APIENTRY *LPALBUFFERFV)(ALuint buffer, ALenum param, const ALfloat *values); -typedef void (AL_APIENTRY *LPALBUFFERI)(ALuint buffer, ALenum param, ALint value); -typedef void (AL_APIENTRY *LPALBUFFER3I)(ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3); -typedef void (AL_APIENTRY *LPALBUFFERIV)(ALuint buffer, ALenum param, const ALint *values); -typedef void (AL_APIENTRY *LPALGETBUFFERF)(ALuint buffer, ALenum param, ALfloat *value); -typedef void (AL_APIENTRY *LPALGETBUFFER3F)(ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); -typedef void (AL_APIENTRY *LPALGETBUFFERFV)(ALuint buffer, ALenum param, ALfloat *values); -typedef void (AL_APIENTRY *LPALGETBUFFERI)(ALuint buffer, ALenum param, ALint *value); -typedef void (AL_APIENTRY *LPALGETBUFFER3I)(ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3); -typedef void (AL_APIENTRY *LPALGETBUFFERIV)(ALuint buffer, ALenum param, ALint *values); -typedef void (AL_APIENTRY *LPALDOPPLERFACTOR)(ALfloat value); -typedef void (AL_APIENTRY *LPALDOPPLERVELOCITY)(ALfloat value); -typedef void (AL_APIENTRY *LPALSPEEDOFSOUND)(ALfloat value); -typedef void (AL_APIENTRY *LPALDISTANCEMODEL)(ALenum distanceModel); - -#if defined(__cplusplus) -} /* extern "C" */ -#endif - -#endif /* AL_AL_H */ diff --git a/Plugins/Audio/alure/alc.h b/Plugins/Audio/alure/alc.h deleted file mode 100644 index 294e8b3..0000000 --- a/Plugins/Audio/alure/alc.h +++ /dev/null @@ -1,237 +0,0 @@ -#ifndef AL_ALC_H -#define AL_ALC_H - -#if defined(__cplusplus) -extern "C" { -#endif - -#ifndef ALC_API - #if defined(AL_LIBTYPE_STATIC) - #define ALC_API - #elif defined(_WIN32) - #define ALC_API __declspec(dllimport) - #else - #define ALC_API extern - #endif -#endif - -#if defined(_WIN32) - #define ALC_APIENTRY __cdecl -#else - #define ALC_APIENTRY -#endif - - -/** Deprecated macro. */ -#define ALCAPI ALC_API -#define ALCAPIENTRY ALC_APIENTRY -#define ALC_INVALID 0 - -/** Supported ALC version? */ -#define ALC_VERSION_0_1 1 - -/** Opaque device handle */ -typedef struct ALCdevice_struct ALCdevice; -/** Opaque context handle */ -typedef struct ALCcontext_struct ALCcontext; - -/** 8-bit boolean */ -typedef char ALCboolean; - -/** character */ -typedef char ALCchar; - -/** signed 8-bit 2's complement integer */ -typedef signed char ALCbyte; - -/** unsigned 8-bit integer */ -typedef unsigned char ALCubyte; - -/** signed 16-bit 2's complement integer */ -typedef short ALCshort; - -/** unsigned 16-bit integer */ -typedef unsigned short ALCushort; - -/** signed 32-bit 2's complement integer */ -typedef int ALCint; - -/** unsigned 32-bit integer */ -typedef unsigned int ALCuint; - -/** non-negative 32-bit binary integer size */ -typedef int ALCsizei; - -/** enumerated 32-bit value */ -typedef int ALCenum; - -/** 32-bit IEEE754 floating-point */ -typedef float ALCfloat; - -/** 64-bit IEEE754 floating-point */ -typedef double ALCdouble; - -/** void type (for opaque pointers only) */ -typedef void ALCvoid; - - -/* Enumerant values begin at column 50. No tabs. */ - -/** Boolean False. */ -#define ALC_FALSE 0 - -/** Boolean True. */ -#define ALC_TRUE 1 - -/** Context attribute: Hz. */ -#define ALC_FREQUENCY 0x1007 - -/** Context attribute: Hz. */ -#define ALC_REFRESH 0x1008 - -/** Context attribute: AL_TRUE or AL_FALSE. */ -#define ALC_SYNC 0x1009 - -/** Context attribute: requested Mono (3D) Sources. */ -#define ALC_MONO_SOURCES 0x1010 - -/** Context attribute: requested Stereo Sources. */ -#define ALC_STEREO_SOURCES 0x1011 - -/** No error. */ -#define ALC_NO_ERROR 0 - -/** Invalid device handle. */ -#define ALC_INVALID_DEVICE 0xA001 - -/** Invalid context handle. */ -#define ALC_INVALID_CONTEXT 0xA002 - -/** Invalid enum parameter passed to an ALC call. */ -#define ALC_INVALID_ENUM 0xA003 - -/** Invalid value parameter passed to an ALC call. */ -#define ALC_INVALID_VALUE 0xA004 - -/** Out of memory. */ -#define ALC_OUT_OF_MEMORY 0xA005 - - -/** Runtime ALC version. */ -#define ALC_MAJOR_VERSION 0x1000 -#define ALC_MINOR_VERSION 0x1001 - -/** Context attribute list properties. */ -#define ALC_ATTRIBUTES_SIZE 0x1002 -#define ALC_ALL_ATTRIBUTES 0x1003 - -/** String for the default device specifier. */ -#define ALC_DEFAULT_DEVICE_SPECIFIER 0x1004 -/** - * String for the given device's specifier. - * - * If device handle is NULL, it is instead a null-char separated list of - * strings of known device specifiers (list ends with an empty string). - */ -#define ALC_DEVICE_SPECIFIER 0x1005 -/** String for space-separated list of ALC extensions. */ -#define ALC_EXTENSIONS 0x1006 - - -/** Capture extension */ -#define ALC_EXT_CAPTURE 1 -/** - * String for the given capture device's specifier. - * - * If device handle is NULL, it is instead a null-char separated list of - * strings of known capture device specifiers (list ends with an empty string). - */ -#define ALC_CAPTURE_DEVICE_SPECIFIER 0x310 -/** String for the default capture device specifier. */ -#define ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER 0x311 -/** Number of sample frames available for capture. */ -#define ALC_CAPTURE_SAMPLES 0x312 - - -/** Enumerate All extension */ -#define ALC_ENUMERATE_ALL_EXT 1 -/** String for the default extended device specifier. */ -#define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012 -/** - * String for the given extended device's specifier. - * - * If device handle is NULL, it is instead a null-char separated list of - * strings of known extended device specifiers (list ends with an empty string). - */ -#define ALC_ALL_DEVICES_SPECIFIER 0x1013 - - -/** Context management. */ -ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint* attrlist); -ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context); -ALC_API void ALC_APIENTRY alcProcessContext(ALCcontext *context); -ALC_API void ALC_APIENTRY alcSuspendContext(ALCcontext *context); -ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context); -ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void); -ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *context); - -/** Device management. */ -ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename); -ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device); - - -/** - * Error support. - * - * Obtain the most recent Device error. - */ -ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device); - -/** - * Extension support. - * - * Query for the presence of an extension, and obtain any appropriate - * function pointers and enum values. - */ -ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extname); -ALC_API void* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcname); -ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *enumname); - -/** Query function. */ -ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum param); -ALC_API void ALC_APIENTRY alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values); - -/** Capture function. */ -ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize); -ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device); -ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device); -ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device); -ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); - -/** Pointer-to-function type, useful for dynamically getting ALC entry points. */ -typedef ALCcontext* (ALC_APIENTRY *LPALCCREATECONTEXT)(ALCdevice *device, const ALCint *attrlist); -typedef ALCboolean (ALC_APIENTRY *LPALCMAKECONTEXTCURRENT)(ALCcontext *context); -typedef void (ALC_APIENTRY *LPALCPROCESSCONTEXT)(ALCcontext *context); -typedef void (ALC_APIENTRY *LPALCSUSPENDCONTEXT)(ALCcontext *context); -typedef void (ALC_APIENTRY *LPALCDESTROYCONTEXT)(ALCcontext *context); -typedef ALCcontext* (ALC_APIENTRY *LPALCGETCURRENTCONTEXT)(void); -typedef ALCdevice* (ALC_APIENTRY *LPALCGETCONTEXTSDEVICE)(ALCcontext *context); -typedef ALCdevice* (ALC_APIENTRY *LPALCOPENDEVICE)(const ALCchar *devicename); -typedef ALCboolean (ALC_APIENTRY *LPALCCLOSEDEVICE)(ALCdevice *device); -typedef ALCenum (ALC_APIENTRY *LPALCGETERROR)(ALCdevice *device); -typedef ALCboolean (ALC_APIENTRY *LPALCISEXTENSIONPRESENT)(ALCdevice *device, const ALCchar *extname); -typedef void* (ALC_APIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname); -typedef ALCenum (ALC_APIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname); -typedef const ALCchar* (ALC_APIENTRY *LPALCGETSTRING)(ALCdevice *device, ALCenum param); -typedef void (ALC_APIENTRY *LPALCGETINTEGERV)(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values); -typedef ALCdevice* (ALC_APIENTRY *LPALCCAPTUREOPENDEVICE)(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize); -typedef ALCboolean (ALC_APIENTRY *LPALCCAPTURECLOSEDEVICE)(ALCdevice *device); -typedef void (ALC_APIENTRY *LPALCCAPTURESTART)(ALCdevice *device); -typedef void (ALC_APIENTRY *LPALCCAPTURESTOP)(ALCdevice *device); -typedef void (ALC_APIENTRY *LPALCCAPTURESAMPLES)(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); - -#if defined(__cplusplus) -} -#endif - -#endif /* AL_ALC_H */ diff --git a/Plugins/Audio/alure/alure2.lib b/Plugins/Audio/alure/alure2.lib deleted file mode 100644 index 7de4347..0000000 Binary files a/Plugins/Audio/alure/alure2.lib and /dev/null differ diff --git a/Plugins/Audio/alure/mpark/LICENSE.md b/Plugins/Audio/alure/mpark/LICENSE.md deleted file mode 100644 index 36b7cd9..0000000 --- a/Plugins/Audio/alure/mpark/LICENSE.md +++ /dev/null @@ -1,23 +0,0 @@ -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/Plugins/Audio/alure/mpark/config.hpp b/Plugins/Audio/alure/mpark/config.hpp deleted file mode 100644 index 0d6f4ad..0000000 --- a/Plugins/Audio/alure/mpark/config.hpp +++ /dev/null @@ -1,74 +0,0 @@ -// MPark.Variant -// -// Copyright Michael Park, 2015-2017 -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - -#ifndef MPARK_CONFIG_HPP -#define MPARK_CONFIG_HPP - -// MSVC 2015 Update 3. -#if __cplusplus < 201103L && (!defined(_MSC_VER) || _MSC_FULL_VER < 190024210) -#error "MPark.Variant requires C++11 support." -#endif - -#ifndef __has_builtin -#define __has_builtin(x) 0 -#endif - -#ifndef __has_include -#define __has_include(x) 0 -#endif - -#ifndef __has_feature -#define __has_feature(x) 0 -#endif - -#if __has_builtin(__builtin_addressof) || \ - (defined(__GNUC__) && __GNUC__ >= 7) || defined(_MSC_VER) -#define MPARK_BUILTIN_ADDRESSOF -#endif - -#if __has_builtin(__builtin_unreachable) -#define MPARK_BUILTIN_UNREACHABLE -#endif - -#if __has_builtin(__type_pack_element) -#define MPARK_TYPE_PACK_ELEMENT -#endif - -#if defined(__cpp_constexpr) && __cpp_constexpr >= 201304 -#define MPARK_CPP14_CONSTEXPR -#endif - -#if __has_feature(cxx_exceptions) || defined(__cpp_exceptions) || \ - (defined(_MSC_VER) && defined(_CPPUNWIND)) -#define MPARK_EXCEPTIONS -#endif - -#if defined(__cpp_generic_lambdas) || defined(_MSC_VER) -#define MPARK_GENERIC_LAMBDAS -#endif - -#if defined(__cpp_lib_integer_sequence) -#define MPARK_INTEGER_SEQUENCE -#endif - -#if defined(__cpp_return_type_deduction) || defined(_MSC_VER) -#define MPARK_RETURN_TYPE_DEDUCTION -#endif - -#if defined(__cpp_lib_transparent_operators) || defined(_MSC_VER) -#define MPARK_TRANSPARENT_OPERATORS -#endif - -#if defined(__cpp_variable_templates) || defined(_MSC_VER) -#define MPARK_VARIABLE_TEMPLATES -#endif - -#if !defined(__GLIBCXX__) || __has_include() // >= libstdc++-5 -#define MPARK_TRIVIALITY_TYPE_TRAITS -#endif - -#endif // MPARK_CONFIG_HPP diff --git a/Plugins/Audio/alure/mpark/in_place.hpp b/Plugins/Audio/alure/mpark/in_place.hpp deleted file mode 100644 index 56cae13..0000000 --- a/Plugins/Audio/alure/mpark/in_place.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// MPark.Variant -// -// Copyright Michael Park, 2015-2017 -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - -#ifndef MPARK_IN_PLACE_HPP -#define MPARK_IN_PLACE_HPP - -#include - -#include "config.hpp" - -namespace mpark { - - struct in_place_t { explicit in_place_t() = default; }; - - template - struct in_place_index_t { explicit in_place_index_t() = default; }; - - template - struct in_place_type_t { explicit in_place_type_t() = default; }; - -#ifdef MPARK_VARIABLE_TEMPLATES - constexpr in_place_t in_place{}; - - template constexpr in_place_index_t in_place_index{}; - - template constexpr in_place_type_t in_place_type{}; -#endif - -} // namespace mpark - -#endif // MPARK_IN_PLACE_HPP diff --git a/Plugins/Audio/alure/mpark/lib.hpp b/Plugins/Audio/alure/mpark/lib.hpp deleted file mode 100644 index c3efdd9..0000000 --- a/Plugins/Audio/alure/mpark/lib.hpp +++ /dev/null @@ -1,442 +0,0 @@ -// MPark.Variant -// -// Copyright Michael Park, 2015-2017 -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - -#ifndef MPARK_LIB_HPP -#define MPARK_LIB_HPP - -#include -#include -#include -#include - -#include "config.hpp" - -#define RETURN(...) \ - noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) { \ - return __VA_ARGS__; \ - } - -namespace mpark { - namespace lib { - template - struct identity { using type = T; }; - - inline namespace cpp14 { - template - struct array { - constexpr const T &operator[](std::size_t index) const { - return data[index]; - } - - T data[N == 0 ? 1 : N]; - }; - - template - using add_pointer_t = typename std::add_pointer::type; - - template - using common_type_t = typename std::common_type::type; - - template - using decay_t = typename std::decay::type; - - template - using enable_if_t = typename std::enable_if::type; - - template - using remove_const_t = typename std::remove_const::type; - - template - using remove_reference_t = typename std::remove_reference::type; - - template - inline constexpr T &&forward(remove_reference_t &t) noexcept { - return static_cast(t); - } - - template - inline constexpr T &&forward(remove_reference_t &&t) noexcept { - static_assert(!std::is_lvalue_reference::value, - "can not forward an rvalue as an lvalue"); - return static_cast(t); - } - - template - inline constexpr remove_reference_t &&move(T &&t) noexcept { - return static_cast &&>(t); - } - -#ifdef MPARK_INTEGER_SEQUENCE - using std::integer_sequence; - using std::index_sequence; - using std::make_index_sequence; - using std::index_sequence_for; -#else - template - struct integer_sequence { - using value_type = T; - static constexpr std::size_t size() noexcept { return sizeof...(Is); } - }; - - template - using index_sequence = integer_sequence; - - template - struct make_index_sequence_concat; - - template - struct make_index_sequence_concat, - index_sequence> - : identity> {}; - - template - struct make_index_sequence_impl; - - template - using make_index_sequence = typename make_index_sequence_impl::type; - - template - struct make_index_sequence_impl - : make_index_sequence_concat, - make_index_sequence> {}; - - template <> - struct make_index_sequence_impl<0> : identity> {}; - - template <> - struct make_index_sequence_impl<1> : identity> {}; - - template - using index_sequence_for = make_index_sequence; -#endif - - // -#ifdef MPARK_TRANSPARENT_OPERATORS - using equal_to = std::equal_to<>; -#else - struct equal_to { - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - RETURN(lib::forward(lhs) == lib::forward(rhs)) - }; -#endif - -#ifdef MPARK_TRANSPARENT_OPERATORS - using not_equal_to = std::not_equal_to<>; -#else - struct not_equal_to { - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - RETURN(lib::forward(lhs) != lib::forward(rhs)) - }; -#endif - -#ifdef MPARK_TRANSPARENT_OPERATORS - using less = std::less<>; -#else - struct less { - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - RETURN(lib::forward(lhs) < lib::forward(rhs)) - }; -#endif - -#ifdef MPARK_TRANSPARENT_OPERATORS - using greater = std::greater<>; -#else - struct greater { - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - RETURN(lib::forward(lhs) > lib::forward(rhs)) - }; -#endif - -#ifdef MPARK_TRANSPARENT_OPERATORS - using less_equal = std::less_equal<>; -#else - struct less_equal { - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - RETURN(lib::forward(lhs) <= lib::forward(rhs)) - }; -#endif - -#ifdef MPARK_TRANSPARENT_OPERATORS - using greater_equal = std::greater_equal<>; -#else - struct greater_equal { - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - RETURN(lib::forward(lhs) >= lib::forward(rhs)) - }; -#endif - } // namespace cpp14 - - inline namespace cpp17 { - - // - template - using bool_constant = std::integral_constant; - - template - struct voider : identity {}; - - template - using void_t = typename voider::type; - - namespace detail { - namespace swappable { - - using std::swap; - - template - struct is_swappable { - private: - template (), - std::declval()))> - inline static std::true_type test(int); - - template - inline static std::false_type test(...); - - public: - static constexpr bool value = decltype(test(0))::value; - }; - - template ::value> - struct is_nothrow_swappable { - static constexpr bool value = - noexcept(swap(std::declval(), std::declval())); - }; - - template - struct is_nothrow_swappable : std::false_type {}; - - } // namespace swappable - } // namespace detail - - using detail::swappable::is_swappable; - using detail::swappable::is_nothrow_swappable; - - // -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#endif - template - inline constexpr auto invoke(F &&f, As &&... as) - RETURN(lib::forward(f)(lib::forward(as)...)) -#ifdef _MSC_VER -#pragma warning(pop) -#endif - - template - inline constexpr auto invoke(T B::*pmv, D &&d) - RETURN(lib::forward(d).*pmv) - - template - inline constexpr auto invoke(Pmv pmv, Ptr &&ptr) - RETURN((*lib::forward(ptr)).*pmv) - - template - inline constexpr auto invoke(T B::*pmf, D &&d, As &&... as) - RETURN((lib::forward(d).*pmf)(lib::forward(as)...)) - - template - inline constexpr auto invoke(Pmf pmf, Ptr &&ptr, As &&... as) - RETURN(((*lib::forward(ptr)).*pmf)(lib::forward(as)...)) - - namespace detail { - - template - struct invoke_result {}; - - template - struct invoke_result(), std::declval()...))>, - F, - Args...> - : identity(), std::declval()...))> {}; - - } // namespace detail - - template - using invoke_result = detail::invoke_result; - - template - using invoke_result_t = typename invoke_result::type; - - namespace detail { - - template - struct is_invocable : std::false_type {}; - - template - struct is_invocable>, F, Args...> - : std::true_type {}; - - template - struct is_invocable_r : std::false_type {}; - - template - struct is_invocable_r>, - R, - F, - Args...> - : std::is_convertible, R> {}; - - } // namespace detail - - template - using is_invocable = detail::is_invocable; - - template - using is_invocable_r = detail::is_invocable_r; - - // -#ifdef MPARK_BUILTIN_ADDRESSOF - template - inline constexpr T *addressof(T &arg) { - return __builtin_addressof(arg); - } -#else - namespace detail { - - namespace has_addressof_impl { - - struct fail; - - template - inline fail operator&(T &&); - - template - inline static constexpr bool impl() { - return (std::is_class::value || std::is_union::value) && - !std::is_same()), fail>::value; - } - - } // namespace has_addressof_impl - - template - using has_addressof = bool_constant()>; - - template - inline constexpr T *addressof(T &arg, std::true_type) { - return std::addressof(arg); - } - - template - inline constexpr T *addressof(T &arg, std::false_type) { - return &arg; - } - - } // namespace detail - - template - inline constexpr T *addressof(T &arg) { - return detail::addressof(arg, detail::has_addressof{}); - } -#endif - - template - inline constexpr T *addressof(const T &&) = delete; - - } // namespace cpp17 - - template - struct remove_all_extents : identity {}; - - template - struct remove_all_extents> : remove_all_extents {}; - - template - using remove_all_extents_t = typename remove_all_extents::type; - - template - using size_constant = std::integral_constant; - - template - struct indexed_type : size_constant, identity {}; - - template - using all = std::is_same, - integer_sequence>; - -#ifdef MPARK_TYPE_PACK_ELEMENT - template - using type_pack_element_t = __type_pack_element; -#else - template - struct type_pack_element_impl { - private: - template - struct set; - - template - struct set> : indexed_type... {}; - - template - inline static std::enable_if impl(indexed_type); - - inline static std::enable_if impl(...); - - public: - using type = decltype(impl(set>{})); - }; - - template - using type_pack_element = typename type_pack_element_impl::type; - - template - using type_pack_element_t = typename type_pack_element::type; -#endif - -#ifdef MPARK_TRIVIALITY_TYPE_TRAITS - using std::is_trivially_copy_constructible; - using std::is_trivially_move_constructible; - using std::is_trivially_copy_assignable; - using std::is_trivially_move_assignable; -#else - template - struct is_trivially_copy_constructible - : bool_constant< - std::is_copy_constructible::value && __has_trivial_copy(T)> {}; - - template - struct is_trivially_move_constructible : bool_constant<__is_trivial(T)> {}; - - template - struct is_trivially_copy_assignable - : bool_constant< - std::is_copy_assignable::value && __has_trivial_assign(T)> {}; - - template - struct is_trivially_move_assignable : bool_constant<__is_trivial(T)> {}; -#endif - - template - struct dependent_type : T {}; - - template - struct push_back; - - template - using push_back_t = typename push_back::type; - - template - struct push_back, J> { - using type = index_sequence; - }; - - } // namespace lib -} // namespace mpark - -#undef RETURN - -#endif // MPARK_LIB_HPP diff --git a/Plugins/Audio/alure/mpark/variant.hpp b/Plugins/Audio/alure/mpark/variant.hpp deleted file mode 100644 index 09ad644..0000000 --- a/Plugins/Audio/alure/mpark/variant.hpp +++ /dev/null @@ -1,1908 +0,0 @@ -// MPark.Variant -// -// Copyright Michael Park, 2015-2017 -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - -#ifndef MPARK_VARIANT_HPP -#define MPARK_VARIANT_HPP - -/* - variant synopsis - -namespace std { - - // 20.7.2, class template variant - template - class variant { - public: - - // 20.7.2.1, constructors - constexpr variant() noexcept(see below); - variant(const variant&); - variant(variant&&) noexcept(see below); - - template constexpr variant(T&&) noexcept(see below); - - template - constexpr explicit variant(in_place_type_t, Args&&...); - - template - constexpr explicit variant( - in_place_type_t, initializer_list, Args&&...); - - template - constexpr explicit variant(in_place_index_t, Args&&...); - - template - constexpr explicit variant( - in_place_index_t, initializer_list, Args&&...); - - // 20.7.2.2, destructor - ~variant(); - - // 20.7.2.3, assignment - variant& operator=(const variant&); - variant& operator=(variant&&) noexcept(see below); - - template variant& operator=(T&&) noexcept(see below); - - // 20.7.2.4, modifiers - template - T& emplace(Args&&...); - - template - T& emplace(initializer_list, Args&&...); - - template - variant_alternative& emplace(Args&&...); - - template - variant_alternative& emplace(initializer_list, Args&&...); - - // 20.7.2.5, value status - constexpr bool valueless_by_exception() const noexcept; - constexpr size_t index() const noexcept; - - // 20.7.2.6, swap - void swap(variant&) noexcept(see below); - }; - - // 20.7.3, variant helper classes - template struct variant_size; // undefined - - template - constexpr size_t variant_size_v = variant_size::value; - - template struct variant_size; - template struct variant_size; - template struct variant_size; - - template - struct variant_size>; - - template struct variant_alternative; // undefined - - template - using variant_alternative_t = typename variant_alternative::type; - - template struct variant_alternative; - template struct variant_alternative; - template struct variant_alternative; - - template - struct variant_alternative>; - - constexpr size_t variant_npos = -1; - - // 20.7.4, value access - template - constexpr bool holds_alternative(const variant&) noexcept; - - template - constexpr variant_alternative_t>& - get(variant&); - - template - constexpr variant_alternative_t>&& - get(variant&&); - - template - constexpr variant_alternative_t> const& - get(const variant&); - - template - constexpr variant_alternative_t> const&& - get(const variant&&); - - template - constexpr T& get(variant&); - - template - constexpr T&& get(variant&&); - - template - constexpr const T& get(const variant&); - - template - constexpr const T&& get(const variant&&); - - template - constexpr add_pointer_t>> - get_if(variant*) noexcept; - - template - constexpr add_pointer_t>> - get_if(const variant*) noexcept; - - template - constexpr add_pointer_t - get_if(variant*) noexcept; - - template - constexpr add_pointer_t - get_if(const variant*) noexcept; - - // 20.7.5, relational operators - template - constexpr bool operator==(const variant&, const variant&); - - template - constexpr bool operator!=(const variant&, const variant&); - - template - constexpr bool operator<(const variant&, const variant&); - - template - constexpr bool operator>(const variant&, const variant&); - - template - constexpr bool operator<=(const variant&, const variant&); - - template - constexpr bool operator>=(const variant&, const variant&); - - // 20.7.6, visitation - template - constexpr see below visit(Visitor&&, Variants&&...); - - // 20.7.7, class monostate - struct monostate; - - // 20.7.8, monostate relational operators - constexpr bool operator<(monostate, monostate) noexcept; - constexpr bool operator>(monostate, monostate) noexcept; - constexpr bool operator<=(monostate, monostate) noexcept; - constexpr bool operator>=(monostate, monostate) noexcept; - constexpr bool operator==(monostate, monostate) noexcept; - constexpr bool operator!=(monostate, monostate) noexcept; - - // 20.7.9, specialized algorithms - template - void swap(variant&, variant&) noexcept(see below); - - // 20.7.10, class bad_variant_access - class bad_variant_access; - - // 20.7.11, hash support - template struct hash; - template struct hash>; - template <> struct hash; - -} // namespace std - -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include "config.hpp" -#include "in_place.hpp" -#include "lib.hpp" - -namespace mpark { - -#ifdef MPARK_RETURN_TYPE_DEDUCTION - -#define AUTO auto -#define AUTO_RETURN(...) { return __VA_ARGS__; } - -#define AUTO_REFREF auto && -#define AUTO_REFREF_RETURN(...) { return __VA_ARGS__; } - -#define DECLTYPE_AUTO decltype(auto) -#define DECLTYPE_AUTO_RETURN(...) { return __VA_ARGS__; } - -#else - -#define AUTO auto -#define AUTO_RETURN(...) \ - -> lib::decay_t { return __VA_ARGS__; } - -#define AUTO_REFREF auto -#define AUTO_REFREF_RETURN(...) \ - -> decltype((__VA_ARGS__)) { \ - static_assert(std::is_reference::value, ""); \ - return __VA_ARGS__; \ - } - -#define DECLTYPE_AUTO auto -#define DECLTYPE_AUTO_RETURN(...) \ - -> decltype(__VA_ARGS__) { return __VA_ARGS__; } - -#endif - - class bad_variant_access : public std::exception { - public: - virtual const char *what() const noexcept { return "bad_variant_access"; } - }; - - [[noreturn]] inline void throw_bad_variant_access() { -#ifdef MPARK_EXCEPTIONS - throw bad_variant_access{}; -#else - std::terminate(); -#ifdef MPARK_BUILTIN_UNREACHABLE - __builtin_unreachable(); -#endif -#endif - } - - template - class variant; - - template - struct variant_size; - -#ifdef MPARK_VARIABLE_TEMPLATES - template - constexpr std::size_t variant_size_v = variant_size::value; -#endif - - template - struct variant_size : variant_size {}; - - template - struct variant_size : variant_size {}; - - template - struct variant_size : variant_size {}; - - template - struct variant_size> : lib::size_constant {}; - - template - struct variant_alternative; - - template - using variant_alternative_t = typename variant_alternative::type; - - template - struct variant_alternative - : std::add_const> {}; - - template - struct variant_alternative - : std::add_volatile> {}; - - template - struct variant_alternative - : std::add_cv> {}; - - template - struct variant_alternative> { - static_assert(I < sizeof...(Ts), - "Index out of bounds in std::variant_alternative<>"); - using type = lib::type_pack_element_t; - }; - - constexpr std::size_t variant_npos = static_cast(-1); - - namespace detail { - - constexpr std::size_t not_found = static_cast(-1); - constexpr std::size_t ambiguous = static_cast(-2); - -#ifdef MPARK_CPP14_CONSTEXPR - template - inline constexpr std::size_t find_index() { - constexpr lib::array matches = { - {std::is_same::value...} - }; - std::size_t result = not_found; - for (std::size_t i = 0; i < sizeof...(Ts); ++i) { - if (matches[i]) { - if (result != not_found) { - return ambiguous; - } - result = i; - } - } - return result; - } -#else - inline constexpr std::size_t find_index_impl(std::size_t result, - std::size_t) { - return result; - } - - template - inline constexpr std::size_t find_index_impl(std::size_t result, - std::size_t idx, - bool b, - Bs... bs) { - return b ? (result != not_found ? ambiguous - : find_index_impl(idx, idx + 1, bs...)) - : find_index_impl(result, idx + 1, bs...); - } - - template - inline constexpr std::size_t find_index() { - return find_index_impl(not_found, 0, std::is_same::value...); - } -#endif - - template - using find_index_sfinae_impl = - lib::enable_if_t>; - - template - using find_index_sfinae = find_index_sfinae_impl()>; - - template - struct find_index_checked_impl : lib::size_constant { - static_assert(I != not_found, "the specified type is not found."); - static_assert(I != ambiguous, "the specified type is ambiguous."); - }; - - template - using find_index_checked = find_index_checked_impl()>; - - struct valueless_t {}; - - enum class Trait { TriviallyAvailable, Available, Unavailable }; - - template class IsTriviallyAvailable, - template class IsAvailable> - inline constexpr Trait trait() { - return IsTriviallyAvailable::value - ? Trait::TriviallyAvailable - : IsAvailable::value ? Trait::Available - : Trait::Unavailable; - } - -#ifdef MPARK_CPP14_CONSTEXPR - template - inline constexpr Trait common_trait(Traits... traits) { - Trait result = Trait::TriviallyAvailable; - for (Trait t : {traits...}) { - if (static_cast(t) > static_cast(result)) { - result = t; - } - } - return result; - } -#else - inline constexpr Trait common_trait_impl(Trait result) { return result; } - - template - inline constexpr Trait common_trait_impl(Trait result, - Trait t, - Traits... ts) { - return static_cast(t) > static_cast(result) - ? common_trait_impl(t, ts...) - : common_trait_impl(result, ts...); - } - - template - inline constexpr Trait common_trait(Traits... ts) { - return common_trait_impl(Trait::TriviallyAvailable, ts...); - } -#endif - - template - struct traits { - static constexpr Trait copy_constructible_trait = - common_trait(trait()...); - - static constexpr Trait move_constructible_trait = - common_trait(trait()...); - - static constexpr Trait copy_assignable_trait = - common_trait(copy_constructible_trait, - trait()...); - - static constexpr Trait move_assignable_trait = - common_trait(move_constructible_trait, - trait()...); - - static constexpr Trait destructible_trait = - common_trait(trait()...); - }; - - namespace access { - - struct recursive_union { -#ifdef MPARK_RETURN_TYPE_DEDUCTION - template - inline static constexpr auto &&get_alt(V &&v, in_place_index_t<0>) { - return lib::forward(v).head_; - } - - template - inline static constexpr auto &&get_alt(V &&v, in_place_index_t) { - return get_alt(lib::forward(v).tail_, in_place_index_t{}); - } -#else - template - struct get_alt_impl { - template - inline constexpr AUTO_REFREF operator()(V &&v) const - AUTO_REFREF_RETURN(get_alt_impl{}(lib::forward(v).tail_)) - }; - - template - struct get_alt_impl<0, Dummy> { - template - inline constexpr AUTO_REFREF operator()(V &&v) const - AUTO_REFREF_RETURN(lib::forward(v).head_) - }; - - template - inline static constexpr AUTO_REFREF get_alt(V &&v, in_place_index_t) - AUTO_REFREF_RETURN(get_alt_impl{}(lib::forward(v))) -#endif - }; - - struct base { - template - inline static constexpr AUTO_REFREF get_alt(V &&v) - AUTO_REFREF_RETURN(recursive_union::get_alt( - data(lib::forward(v)), in_place_index_t{})) - }; - - struct variant { - template - inline static constexpr AUTO_REFREF get_alt(V &&v) - AUTO_REFREF_RETURN(base::get_alt(lib::forward(v).impl_)) - }; - - } // namespace access - - namespace visitation { - - struct base { - template - inline static constexpr const T &at(const T &elem) { - return elem; - } - - template - inline static constexpr const lib::remove_all_extents_t &at( - const lib::array &elems, std::size_t i, Is... is) { - return at(elems[i], is...); - } - - template - inline static constexpr int visit_visitor_return_type_check() { - static_assert(lib::all::value...>::value, - "`mpark::visit` requires the visitor to have a single " - "return type."); - return 0; - } - - template - inline static constexpr lib::array< - lib::common_type_t...>, - sizeof...(Fs)> - make_farray(Fs &&... fs) { - using result = lib::array...>, - sizeof...(Fs)>; - return visit_visitor_return_type_check...>(), - result{{lib::forward(fs)...}}; - } - - template - struct dispatcher { - template - struct impl { - inline static constexpr DECLTYPE_AUTO dispatch(F f, Vs... vs) - DECLTYPE_AUTO_RETURN(lib::invoke( - static_cast(f), - access::base::get_alt(static_cast(vs))...)) - }; - }; - - template - inline static constexpr AUTO make_dispatch(lib::index_sequence) - AUTO_RETURN(&dispatcher::template impl::dispatch) - - template - inline static constexpr AUTO make_fdiagonal_impl() - AUTO_RETURN(make_dispatch( - lib::index_sequence::value...>{})) - - template - inline static constexpr AUTO make_fdiagonal_impl( - lib::index_sequence) - AUTO_RETURN(make_farray(make_fdiagonal_impl()...)) - - template - inline static constexpr /* auto * */ auto make_fdiagonal() - -> decltype(make_fdiagonal_impl( - lib::make_index_sequence::size()>{})) { - static_assert(lib::all<(lib::decay_t::size() == - lib::decay_t::size())...>::value, - "all of the variants must be the same size."); - return make_fdiagonal_impl( - lib::make_index_sequence::size()>{}); - } - -#ifdef MPARK_RETURN_TYPE_DEDUCTION - template - inline static constexpr auto make_fmatrix_impl(Is is) { - return make_dispatch(is); - } - - template - inline static constexpr auto make_fmatrix_impl( - Is, lib::index_sequence, Ls... ls) { - return make_farray(make_fmatrix_impl( - lib::push_back_t{}, ls...)...); - } - - template - inline static constexpr auto make_fmatrix() { - return make_fmatrix_impl( - lib::index_sequence<>{}, - lib::make_index_sequence::size()>{}...); - } -#else - template - struct make_fmatrix_impl { - template - struct impl; - - template - struct impl { - inline constexpr AUTO operator()() const - AUTO_RETURN(make_dispatch(Is{})) - }; - - template - struct impl, Ls...> { - inline constexpr AUTO operator()() const - AUTO_RETURN( - make_farray(impl, Ls...>{}()...)) - }; - }; - - template - inline static constexpr AUTO make_fmatrix() - AUTO_RETURN( - typename make_fmatrix_impl::template impl< - lib::index_sequence<>, - lib::make_index_sequence::size()>...>{}()) -#endif - }; // namespace base - - template - using FDiagonal = decltype(base::make_fdiagonal()); - - template - struct fdiagonal { -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4268) -#endif - static constexpr FDiagonal value = - base::make_fdiagonal(); -#ifdef _MSC_VER -#pragma warning(pop) -#endif - }; - - template - constexpr FDiagonal fdiagonal::value; - - template - using FMatrix = decltype(base::make_fmatrix()); - - template - struct fmatrix { -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4268) -#endif - static constexpr FMatrix value = - base::make_fmatrix(); -#ifdef _MSC_VER -#pragma warning(pop) -#endif - }; - - template - constexpr FMatrix fmatrix::value; - - struct alt { - template - inline static constexpr DECLTYPE_AUTO visit_alt_at(std::size_t index, - Visitor &&visitor, - Vs &&... vs) - DECLTYPE_AUTO_RETURN(base::at( - fdiagonal(vs)))...>::value, - index)(lib::forward(visitor), - as_base(lib::forward(vs))...)) - - template - inline static constexpr DECLTYPE_AUTO visit_alt(Visitor &&visitor, - Vs &&... vs) - DECLTYPE_AUTO_RETURN(base::at( - fmatrix(vs)))...>::value, - vs.index()...)(lib::forward(visitor), - as_base(lib::forward(vs))...)) - }; - - struct variant { - private: - template - struct visit_exhaustive_visitor_check { - static_assert( - lib::is_invocable::value, - "`mpark::visit` requires the visitor to be exhaustive."); - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#endif - inline constexpr DECLTYPE_AUTO operator()(Visitor &&visitor, - Values &&... values) const - DECLTYPE_AUTO_RETURN(lib::invoke(lib::forward(visitor), - lib::forward(values)...)) -#ifdef _MSC_VER -#pragma warning(pop) -#endif - }; - - template - struct value_visitor { - Visitor &&visitor_; - - template - inline constexpr DECLTYPE_AUTO operator()(Alts &&... alts) const - DECLTYPE_AUTO_RETURN( - visit_exhaustive_visitor_check< - Visitor, - decltype((lib::forward(alts).value))...>{}( - lib::forward(visitor_), - lib::forward(alts).value...)) - }; - - template - inline static constexpr AUTO make_value_visitor(Visitor &&visitor) - AUTO_RETURN(value_visitor{lib::forward(visitor)}) - - public: - template - inline static constexpr DECLTYPE_AUTO visit_alt_at(std::size_t index, - Visitor &&visitor, - Vs &&... vs) - DECLTYPE_AUTO_RETURN( - alt::visit_alt_at(index, - lib::forward(visitor), - lib::forward(vs).impl_...)) - - template - inline static constexpr DECLTYPE_AUTO visit_alt(Visitor &&visitor, - Vs &&... vs) - DECLTYPE_AUTO_RETURN(alt::visit_alt(lib::forward(visitor), - lib::forward(vs).impl_...)) - - template - inline static constexpr DECLTYPE_AUTO visit_value_at(std::size_t index, - Visitor &&visitor, - Vs &&... vs) - DECLTYPE_AUTO_RETURN( - visit_alt_at(index, - make_value_visitor(lib::forward(visitor)), - lib::forward(vs)...)) - - template - inline static constexpr DECLTYPE_AUTO visit_value(Visitor &&visitor, - Vs &&... vs) - DECLTYPE_AUTO_RETURN( - visit_alt(make_value_visitor(lib::forward(visitor)), - lib::forward(vs)...)) - }; - - } // namespace visitation - - template - struct alt { - using value_type = T; - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4244) -#endif - template - inline explicit constexpr alt(in_place_t, Args &&... args) - : value(lib::forward(args)...) {} -#ifdef _MSC_VER -#pragma warning(pop) -#endif - - T value; - }; - - template - union recursive_union; - - template - union recursive_union {}; - -#define MPARK_VARIANT_RECURSIVE_UNION(destructible_trait, destructor) \ - template \ - union recursive_union { \ - public: \ - inline explicit constexpr recursive_union(valueless_t) noexcept \ - : dummy_{} {} \ - \ - template \ - inline explicit constexpr recursive_union(in_place_index_t<0>, \ - Args &&... args) \ - : head_(in_place_t{}, lib::forward(args)...) {} \ - \ - template \ - inline explicit constexpr recursive_union(in_place_index_t, \ - Args &&... args) \ - : tail_(in_place_index_t{}, lib::forward(args)...) {} \ - \ - recursive_union(const recursive_union &) = default; \ - recursive_union(recursive_union &&) = default; \ - \ - destructor \ - \ - recursive_union &operator=(const recursive_union &) = default; \ - recursive_union &operator=(recursive_union &&) = default; \ - \ - private: \ - char dummy_; \ - alt head_; \ - recursive_union tail_; \ - \ - friend struct access::recursive_union; \ - } - - MPARK_VARIANT_RECURSIVE_UNION(Trait::TriviallyAvailable, - ~recursive_union() = default;); - MPARK_VARIANT_RECURSIVE_UNION(Trait::Available, - ~recursive_union() {}); - MPARK_VARIANT_RECURSIVE_UNION(Trait::Unavailable, - ~recursive_union() = delete;); - -#undef MPARK_VARIANT_RECURSIVE_UNION - - using index_t = unsigned int; - - template - class base { - public: - inline explicit constexpr base(valueless_t tag) noexcept - : data_(tag), index_(static_cast(-1)) {} - - template - inline explicit constexpr base(in_place_index_t, Args &&... args) - : data_(in_place_index_t{}, lib::forward(args)...), - index_(I) {} - - inline constexpr bool valueless_by_exception() const noexcept { - return index_ == static_cast(-1); - } - - inline constexpr std::size_t index() const noexcept { - return valueless_by_exception() ? variant_npos : index_; - } - - protected: - using data_t = recursive_union; - - friend inline constexpr base &as_base(base &b) { return b; } - friend inline constexpr const base &as_base(const base &b) { return b; } - friend inline constexpr base &&as_base(base &&b) { return lib::move(b); } - friend inline constexpr const base &&as_base(const base &&b) { return lib::move(b); } - - friend inline constexpr data_t &data(base &b) { return b.data_; } - friend inline constexpr const data_t &data(const base &b) { return b.data_; } - friend inline constexpr data_t &&data(base &&b) { return lib::move(b).data_; } - friend inline constexpr const data_t &&data(const base &&b) { return lib::move(b).data_; } - - inline static constexpr std::size_t size() { return sizeof...(Ts); } - - data_t data_; - index_t index_; - - friend struct access::base; - friend struct visitation::base; - }; - - struct dtor { -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#endif - template - inline void operator()(Alt &alt) const noexcept { alt.~Alt(); } -#ifdef _MSC_VER -#pragma warning(pop) -#endif - }; - -#if defined(_MSC_VER) && _MSC_VER < 1910 -#define INHERITING_CTOR(type, base) \ - template \ - inline explicit constexpr type(Args &&... args) \ - : base(lib::forward(args)...) {} -#else -#define INHERITING_CTOR(type, base) using base::base; -#endif - - template - class destructor; - -#define MPARK_VARIANT_DESTRUCTOR(destructible_trait, definition, destroy) \ - template \ - class destructor, destructible_trait> \ - : public base { \ - using super = base; \ - \ - public: \ - INHERITING_CTOR(destructor, super) \ - using super::operator=; \ - \ - destructor(const destructor &) = default; \ - destructor(destructor &&) = default; \ - definition \ - destructor &operator=(const destructor &) = default; \ - destructor &operator=(destructor &&) = default; \ - \ - protected: \ - destroy \ - } - - MPARK_VARIANT_DESTRUCTOR( - Trait::TriviallyAvailable, - ~destructor() = default;, - inline void destroy() noexcept { - this->index_ = static_cast(-1); - }); - - MPARK_VARIANT_DESTRUCTOR( - Trait::Available, - ~destructor() { destroy(); }, - inline void destroy() noexcept { - if (!this->valueless_by_exception()) { - visitation::alt::visit_alt(dtor{}, *this); - } - this->index_ = static_cast(-1); - }); - - MPARK_VARIANT_DESTRUCTOR( - Trait::Unavailable, - ~destructor() = delete;, - inline void destroy() noexcept = delete;); - -#undef MPARK_VARIANT_DESTRUCTOR - - template - class constructor : public destructor { - using super = destructor; - - public: - INHERITING_CTOR(constructor, super) - using super::operator=; - - protected: -#ifndef MPARK_GENERIC_LAMBDAS - struct ctor { - template - inline void operator()(LhsAlt &lhs_alt, RhsAlt &&rhs_alt) const { - constructor::construct_alt(lhs_alt, - lib::forward(rhs_alt).value); - } - }; -#endif - - template - inline static T &construct_alt(alt &a, Args &&... args) { - ::new (static_cast(lib::addressof(a))) - alt(in_place_t{}, lib::forward(args)...); - return a.value; - } - - template - inline static void generic_construct(constructor &lhs, Rhs &&rhs) { - lhs.destroy(); - if (!rhs.valueless_by_exception()) { - visitation::alt::visit_alt_at( - rhs.index(), -#ifdef MPARK_GENERIC_LAMBDAS - [](auto &lhs_alt, auto &&rhs_alt) { - constructor::construct_alt( - lhs_alt, lib::forward(rhs_alt).value); - } -#else - ctor{} -#endif - , - lhs, - lib::forward(rhs)); - lhs.index_ = rhs.index_; - } - } - }; - - template - class move_constructor; - -#define MPARK_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, definition) \ - template \ - class move_constructor, move_constructible_trait> \ - : public constructor> { \ - using super = constructor>; \ - \ - public: \ - INHERITING_CTOR(move_constructor, super) \ - using super::operator=; \ - \ - move_constructor(const move_constructor &) = default; \ - definition \ - ~move_constructor() = default; \ - move_constructor &operator=(const move_constructor &) = default; \ - move_constructor &operator=(move_constructor &&) = default; \ - } - - MPARK_VARIANT_MOVE_CONSTRUCTOR( - Trait::TriviallyAvailable, - move_constructor(move_constructor &&that) = default;); - - MPARK_VARIANT_MOVE_CONSTRUCTOR( - Trait::Available, - move_constructor(move_constructor &&that) noexcept( - lib::all::value...>::value) - : move_constructor(valueless_t{}) { - this->generic_construct(*this, lib::move(that)); - }); - - MPARK_VARIANT_MOVE_CONSTRUCTOR( - Trait::Unavailable, - move_constructor(move_constructor &&) = delete;); - -#undef MPARK_VARIANT_MOVE_CONSTRUCTOR - - template - class copy_constructor; - -#define MPARK_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, definition) \ - template \ - class copy_constructor, copy_constructible_trait> \ - : public move_constructor> { \ - using super = move_constructor>; \ - \ - public: \ - INHERITING_CTOR(copy_constructor, super) \ - using super::operator=; \ - \ - definition \ - copy_constructor(copy_constructor &&) = default; \ - ~copy_constructor() = default; \ - copy_constructor &operator=(const copy_constructor &) = default; \ - copy_constructor &operator=(copy_constructor &&) = default; \ - } - - MPARK_VARIANT_COPY_CONSTRUCTOR( - Trait::TriviallyAvailable, - copy_constructor(const copy_constructor &that) = default;); - - MPARK_VARIANT_COPY_CONSTRUCTOR( - Trait::Available, - copy_constructor(const copy_constructor &that) - : copy_constructor(valueless_t{}) { - this->generic_construct(*this, that); - }); - - MPARK_VARIANT_COPY_CONSTRUCTOR( - Trait::Unavailable, - copy_constructor(const copy_constructor &) = delete;); - -#undef MPARK_VARIANT_COPY_CONSTRUCTOR - - template - class assignment : public copy_constructor { - using super = copy_constructor; - - public: - INHERITING_CTOR(assignment, super) - using super::operator=; - - template - inline /* auto & */ auto emplace(Args &&... args) - -> decltype(this->construct_alt(access::base::get_alt(*this), - lib::forward(args)...)) { - this->destroy(); - auto &result = this->construct_alt(access::base::get_alt(*this), - lib::forward(args)...); - this->index_ = I; - return result; - } - - protected: -#ifndef MPARK_GENERIC_LAMBDAS - template - struct assigner { - template - inline void operator()(ThisAlt &this_alt, ThatAlt &&that_alt) const { - self->assign_alt(this_alt, lib::forward(that_alt).value); - } - assignment *self; - }; -#endif - - template - inline void assign_alt(alt &a, Arg &&arg) { - if (this->index() == I) { -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4244) -#endif - a.value = lib::forward(arg); -#ifdef _MSC_VER -#pragma warning(pop) -#endif - } else { - struct { - void operator()(std::true_type) const { - this_->emplace(lib::forward(arg_)); - } - void operator()(std::false_type) const { - this_->emplace(T(lib::forward(arg_))); - } - assignment *this_; - Arg &&arg_; - } impl{this, lib::forward(arg)}; - impl(lib::bool_constant< - std::is_nothrow_constructible::value || - !std::is_nothrow_move_constructible::value>{}); - } - } - - template - inline void generic_assign(That &&that) { - if (this->valueless_by_exception() && that.valueless_by_exception()) { - // do nothing. - } else if (that.valueless_by_exception()) { - this->destroy(); - } else { - visitation::alt::visit_alt_at( - that.index(), -#ifdef MPARK_GENERIC_LAMBDAS - [this](auto &this_alt, auto &&that_alt) { - this->assign_alt( - this_alt, lib::forward(that_alt).value); - } -#else - assigner{this} -#endif - , - *this, - lib::forward(that)); - } - } - }; - - template - class move_assignment; - -#define MPARK_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, definition) \ - template \ - class move_assignment, move_assignable_trait> \ - : public assignment> { \ - using super = assignment>; \ - \ - public: \ - INHERITING_CTOR(move_assignment, super) \ - using super::operator=; \ - \ - move_assignment(const move_assignment &) = default; \ - move_assignment(move_assignment &&) = default; \ - ~move_assignment() = default; \ - move_assignment &operator=(const move_assignment &) = default; \ - definition \ - } - - MPARK_VARIANT_MOVE_ASSIGNMENT( - Trait::TriviallyAvailable, - move_assignment &operator=(move_assignment &&that) = default;); - - MPARK_VARIANT_MOVE_ASSIGNMENT( - Trait::Available, - move_assignment & - operator=(move_assignment &&that) noexcept( - lib::all<(std::is_nothrow_move_constructible::value && - std::is_nothrow_move_assignable::value)...>::value) { - this->generic_assign(lib::move(that)); - return *this; - }); - - MPARK_VARIANT_MOVE_ASSIGNMENT( - Trait::Unavailable, - move_assignment &operator=(move_assignment &&) = delete;); - -#undef MPARK_VARIANT_MOVE_ASSIGNMENT - - template - class copy_assignment; - -#define MPARK_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, definition) \ - template \ - class copy_assignment, copy_assignable_trait> \ - : public move_assignment> { \ - using super = move_assignment>; \ - \ - public: \ - INHERITING_CTOR(copy_assignment, super) \ - using super::operator=; \ - \ - copy_assignment(const copy_assignment &) = default; \ - copy_assignment(copy_assignment &&) = default; \ - ~copy_assignment() = default; \ - definition \ - copy_assignment &operator=(copy_assignment &&) = default; \ - } - - MPARK_VARIANT_COPY_ASSIGNMENT( - Trait::TriviallyAvailable, - copy_assignment &operator=(const copy_assignment &that) = default;); - - MPARK_VARIANT_COPY_ASSIGNMENT( - Trait::Available, - copy_assignment &operator=(const copy_assignment &that) { - this->generic_assign(that); - return *this; - }); - - MPARK_VARIANT_COPY_ASSIGNMENT( - Trait::Unavailable, - copy_assignment &operator=(const copy_assignment &) = delete;); - -#undef MPARK_VARIANT_COPY_ASSIGNMENT - - template - class impl : public copy_assignment> { - using super = copy_assignment>; - - public: - INHERITING_CTOR(impl, super) - using super::operator=; - - template - inline void assign(Arg &&arg) { - this->assign_alt(access::base::get_alt(*this), - lib::forward(arg)); - } - - inline void swap(impl &that) { - if (this->valueless_by_exception() && that.valueless_by_exception()) { - // do nothing. - } else if (this->index() == that.index()) { - visitation::alt::visit_alt_at(this->index(), -#ifdef MPARK_GENERIC_LAMBDAS - [](auto &this_alt, auto &that_alt) { - using std::swap; - swap(this_alt.value, - that_alt.value); - } -#else - swapper{} -#endif - , - *this, - that); - } else { - impl *lhs = this; - impl *rhs = lib::addressof(that); - if (lhs->move_nothrow() && !rhs->move_nothrow()) { - std::swap(lhs, rhs); - } - impl tmp(lib::move(*rhs)); -#ifdef MPARK_EXCEPTIONS - // EXTENSION: When the move construction of `lhs` into `rhs` throws - // and `tmp` is nothrow move constructible then we move `tmp` back - // into `rhs` and provide the strong exception safety guarantee. - try { - this->generic_construct(*rhs, lib::move(*lhs)); - } catch (...) { - if (tmp.move_nothrow()) { - this->generic_construct(*rhs, lib::move(tmp)); - } - throw; - } -#else - this->generic_construct(*rhs, lib::move(*lhs)); -#endif - this->generic_construct(*lhs, lib::move(tmp)); - } - } - - private: -#ifndef MPARK_GENERIC_LAMBDAS - struct swapper { - template - inline void operator()(ThisAlt &this_alt, ThatAlt &that_alt) const { - using std::swap; - swap(this_alt.value, that_alt.value); - } - }; -#endif - - inline constexpr bool move_nothrow() const { - return this->valueless_by_exception() || - lib::array{ - {std::is_nothrow_move_constructible::value...} - }[this->index()]; - } - }; - - template - struct overload_leaf { - using F = lib::size_constant (*)(T); - operator F() const { return nullptr; } - }; - - template - struct overload_impl { - private: - template - struct impl; - - template - struct impl> : overload_leaf... {}; - - public: - using type = impl>; - }; - - template - using overload = typename overload_impl::type; - - template - using best_match = lib::invoke_result_t, T &&>; - - template - struct is_in_place_index : std::false_type {}; - - template - struct is_in_place_index> : std::true_type {}; - - template - struct is_in_place_type : std::false_type {}; - - template - struct is_in_place_type> : std::true_type {}; - - } // detail - - template - class variant { - static_assert(0 < sizeof...(Ts), - "variant must consist of at least one alternative."); - - static_assert(lib::all::value...>::value, - "variant can not have an array type as an alternative."); - - static_assert(lib::all::value...>::value, - "variant can not have a reference type as an alternative."); - - static_assert(lib::all::value...>::value, - "variant can not have a void type as an alternative."); - - public: - template < - typename Front = lib::type_pack_element_t<0, Ts...>, - lib::enable_if_t::value, int> = 0> - inline constexpr variant() noexcept( - std::is_nothrow_default_constructible::value) - : impl_(in_place_index_t<0>{}) {} - - variant(const variant &) = default; - variant(variant &&) = default; - - template < - typename Arg, - typename Decayed = lib::decay_t, - lib::enable_if_t::value, int> = 0, - lib::enable_if_t::value, int> = 0, - lib::enable_if_t::value, int> = 0, - std::size_t I = detail::best_match::value, - typename T = lib::type_pack_element_t, - lib::enable_if_t::value, int> = 0> - inline constexpr variant(Arg &&arg) noexcept( - std::is_nothrow_constructible::value) - : impl_(in_place_index_t{}, lib::forward(arg)) {} - - template < - std::size_t I, - typename... Args, - typename T = lib::type_pack_element_t, - lib::enable_if_t::value, int> = 0> - inline explicit constexpr variant( - in_place_index_t, - Args &&... args) noexcept(std::is_nothrow_constructible::value) - : impl_(in_place_index_t{}, lib::forward(args)...) {} - - template < - std::size_t I, - typename Up, - typename... Args, - typename T = lib::type_pack_element_t, - lib::enable_if_t &, - Args...>::value, - int> = 0> - inline explicit constexpr variant( - in_place_index_t, - std::initializer_list il, - Args &&... args) noexcept(std:: - is_nothrow_constructible< - T, - std::initializer_list &, - Args...>::value) - : impl_(in_place_index_t{}, il, lib::forward(args)...) {} - - template < - typename T, - typename... Args, - std::size_t I = detail::find_index_sfinae::value, - lib::enable_if_t::value, int> = 0> - inline explicit constexpr variant( - in_place_type_t, - Args &&... args) noexcept(std::is_nothrow_constructible::value) - : impl_(in_place_index_t{}, lib::forward(args)...) {} - - template < - typename T, - typename Up, - typename... Args, - std::size_t I = detail::find_index_sfinae::value, - lib::enable_if_t &, - Args...>::value, - int> = 0> - inline explicit constexpr variant( - in_place_type_t, - std::initializer_list il, - Args &&... args) noexcept(std:: - is_nothrow_constructible< - T, - std::initializer_list &, - Args...>::value) - : impl_(in_place_index_t{}, il, lib::forward(args)...) {} - - ~variant() = default; - - variant &operator=(const variant &) = default; - variant &operator=(variant &&) = default; - - template , variant>::value, - int> = 0, - std::size_t I = detail::best_match::value, - typename T = lib::type_pack_element_t, - lib::enable_if_t<(std::is_assignable::value && - std::is_constructible::value), - int> = 0> - inline variant &operator=(Arg &&arg) noexcept( - (std::is_nothrow_assignable::value && - std::is_nothrow_constructible::value)) { - impl_.template assign(lib::forward(arg)); - return *this; - } - - template < - std::size_t I, - typename... Args, - typename T = lib::type_pack_element_t, - lib::enable_if_t::value, int> = 0> - inline T &emplace(Args &&... args) { - return impl_.template emplace(lib::forward(args)...); - } - - template < - std::size_t I, - typename Up, - typename... Args, - typename T = lib::type_pack_element_t, - lib::enable_if_t &, - Args...>::value, - int> = 0> - inline T &emplace(std::initializer_list il, Args &&... args) { - return impl_.template emplace(il, lib::forward(args)...); - } - - template < - typename T, - typename... Args, - std::size_t I = detail::find_index_sfinae::value, - lib::enable_if_t::value, int> = 0> - inline T &emplace(Args &&... args) { - return impl_.template emplace(lib::forward(args)...); - } - - template < - typename T, - typename Up, - typename... Args, - std::size_t I = detail::find_index_sfinae::value, - lib::enable_if_t &, - Args...>::value, - int> = 0> - inline T &emplace(std::initializer_list il, Args &&... args) { - return impl_.template emplace(il, lib::forward(args)...); - } - - inline constexpr bool valueless_by_exception() const noexcept { - return impl_.valueless_by_exception(); - } - - inline constexpr std::size_t index() const noexcept { - return impl_.index(); - } - - template , - Dummy>::value && - lib::dependent_type, - Dummy>::value)...>::value, - int> = 0> - inline void swap(variant &that) noexcept( - lib::all<(std::is_nothrow_move_constructible::value && - lib::is_nothrow_swappable::value)...>::value) { - impl_.swap(that.impl_); - } - - private: - detail::impl impl_; - - friend struct detail::access::variant; - friend struct detail::visitation::variant; - }; - - template - inline constexpr bool holds_alternative(const variant &v) noexcept { - return v.index() == I; - } - - template - inline constexpr bool holds_alternative(const variant &v) noexcept { - return holds_alternative::value>(v); - } - - namespace detail { - template - struct generic_get_impl { - constexpr generic_get_impl(int) {} - - constexpr AUTO_REFREF operator()(V &&v) const - AUTO_REFREF_RETURN( - access::variant::get_alt(lib::forward(v)).value) - }; - - template - inline constexpr AUTO_REFREF generic_get(V &&v) - AUTO_REFREF_RETURN(generic_get_impl( - holds_alternative(v) ? 0 : (throw_bad_variant_access(), 0))( - lib::forward(v))) - } // namespace detail - - template - inline constexpr variant_alternative_t> &get( - variant &v) { - return detail::generic_get(v); - } - - template - inline constexpr variant_alternative_t> &&get( - variant &&v) { - return detail::generic_get(lib::move(v)); - } - - template - inline constexpr const variant_alternative_t> &get( - const variant &v) { - return detail::generic_get(v); - } - - template - inline constexpr const variant_alternative_t> &&get( - const variant &&v) { - return detail::generic_get(lib::move(v)); - } - - template - inline constexpr T &get(variant &v) { - return get::value>(v); - } - - template - inline constexpr T &&get(variant &&v) { - return get::value>(lib::move(v)); - } - - template - inline constexpr const T &get(const variant &v) { - return get::value>(v); - } - - template - inline constexpr const T &&get(const variant &&v) { - return get::value>(lib::move(v)); - } - - namespace detail { - - template - inline constexpr /* auto * */ AUTO generic_get_if(V *v) noexcept - AUTO_RETURN(v && holds_alternative(*v) - ? lib::addressof(access::variant::get_alt(*v).value) - : nullptr) - - } // namespace detail - - template - inline constexpr lib::add_pointer_t>> - get_if(variant *v) noexcept { - return detail::generic_get_if(v); - } - - template - inline constexpr lib::add_pointer_t< - const variant_alternative_t>> - get_if(const variant *v) noexcept { - return detail::generic_get_if(v); - } - - template - inline constexpr lib::add_pointer_t - get_if(variant *v) noexcept { - return get_if::value>(v); - } - - template - inline constexpr lib::add_pointer_t - get_if(const variant *v) noexcept { - return get_if::value>(v); - } - - template - inline constexpr bool operator==(const variant &lhs, - const variant &rhs) { - using detail::visitation::variant; - using lib::equal_to; -#ifdef MPARK_CPP14_CONSTEXPR - if (lhs.index() != rhs.index()) return false; - if (lhs.valueless_by_exception()) return true; - return variant::visit_value_at(lhs.index(), equal_to{}, lhs, rhs); -#else - return lhs.index() == rhs.index() && - (lhs.valueless_by_exception() || - variant::visit_value_at(lhs.index(), equal_to{}, lhs, rhs)); -#endif - } - - template - inline constexpr bool operator!=(const variant &lhs, - const variant &rhs) { - using detail::visitation::variant; - using lib::not_equal_to; -#ifdef MPARK_CPP14_CONSTEXPR - if (lhs.index() != rhs.index()) return true; - if (lhs.valueless_by_exception()) return false; - return variant::visit_value_at(lhs.index(), not_equal_to{}, lhs, rhs); -#else - return lhs.index() != rhs.index() || - (!lhs.valueless_by_exception() && - variant::visit_value_at(lhs.index(), not_equal_to{}, lhs, rhs)); -#endif - } - - template - inline constexpr bool operator<(const variant &lhs, - const variant &rhs) { - using detail::visitation::variant; - using lib::less; -#ifdef MPARK_CPP14_CONSTEXPR - if (rhs.valueless_by_exception()) return false; - if (lhs.valueless_by_exception()) return true; - if (lhs.index() < rhs.index()) return true; - if (lhs.index() > rhs.index()) return false; - return variant::visit_value_at(lhs.index(), less{}, lhs, rhs); -#else - return !rhs.valueless_by_exception() && - (lhs.valueless_by_exception() || lhs.index() < rhs.index() || - (lhs.index() == rhs.index() && - variant::visit_value_at(lhs.index(), less{}, lhs, rhs))); -#endif - } - - template - inline constexpr bool operator>(const variant &lhs, - const variant &rhs) { - using detail::visitation::variant; - using lib::greater; -#ifdef MPARK_CPP14_CONSTEXPR - if (lhs.valueless_by_exception()) return false; - if (rhs.valueless_by_exception()) return true; - if (lhs.index() > rhs.index()) return true; - if (lhs.index() < rhs.index()) return false; - return variant::visit_value_at(lhs.index(), greater{}, lhs, rhs); -#else - return !lhs.valueless_by_exception() && - (rhs.valueless_by_exception() || lhs.index() > rhs.index() || - (lhs.index() == rhs.index() && - variant::visit_value_at(lhs.index(), greater{}, lhs, rhs))); -#endif - } - - template - inline constexpr bool operator<=(const variant &lhs, - const variant &rhs) { - using detail::visitation::variant; - using lib::less_equal; -#ifdef MPARK_CPP14_CONSTEXPR - if (lhs.valueless_by_exception()) return true; - if (rhs.valueless_by_exception()) return false; - if (lhs.index() < rhs.index()) return true; - if (lhs.index() > rhs.index()) return false; - return variant::visit_value_at(lhs.index(), less_equal{}, lhs, rhs); -#else - return lhs.valueless_by_exception() || - (!rhs.valueless_by_exception() && - (lhs.index() < rhs.index() || - (lhs.index() == rhs.index() && - variant::visit_value_at(lhs.index(), less_equal{}, lhs, rhs)))); -#endif - } - - template - inline constexpr bool operator>=(const variant &lhs, - const variant &rhs) { - using detail::visitation::variant; - using lib::greater_equal; -#ifdef MPARK_CPP14_CONSTEXPR - if (rhs.valueless_by_exception()) return true; - if (lhs.valueless_by_exception()) return false; - if (lhs.index() > rhs.index()) return true; - if (lhs.index() < rhs.index()) return false; - return variant::visit_value_at(lhs.index(), greater_equal{}, lhs, rhs); -#else - return rhs.valueless_by_exception() || - (!lhs.valueless_by_exception() && - (lhs.index() > rhs.index() || - (lhs.index() == rhs.index() && - variant::visit_value_at( - lhs.index(), greater_equal{}, lhs, rhs)))); -#endif - } - - struct monostate {}; - - inline constexpr bool operator<(monostate, monostate) noexcept { - return false; - } - - inline constexpr bool operator>(monostate, monostate) noexcept { - return false; - } - - inline constexpr bool operator<=(monostate, monostate) noexcept { - return true; - } - - inline constexpr bool operator>=(monostate, monostate) noexcept { - return true; - } - - inline constexpr bool operator==(monostate, monostate) noexcept { - return true; - } - - inline constexpr bool operator!=(monostate, monostate) noexcept { - return false; - } - -#ifdef MPARK_CPP14_CONSTEXPR - namespace detail { - - inline constexpr bool all(std::initializer_list bs) { - for (bool b : bs) { - if (!b) { - return false; - } - } - return true; - } - - } // namespace detail - - template - inline constexpr decltype(auto) visit(Visitor &&visitor, Vs &&... vs) { - return (detail::all({!vs.valueless_by_exception()...}) - ? (void)0 - : throw_bad_variant_access()), - detail::visitation::variant::visit_value( - lib::forward(visitor), lib::forward(vs)...); - } -#else - namespace detail { - - template - inline constexpr bool all_impl(const lib::array &bs, - std::size_t idx) { - return idx >= N || (bs[idx] && all_impl(bs, idx + 1)); - } - - template - inline constexpr bool all(const lib::array &bs) { - return all_impl(bs, 0); - } - - } // namespace detail - - template - inline constexpr DECLTYPE_AUTO visit(Visitor &&visitor, Vs &&... vs) - DECLTYPE_AUTO_RETURN( - (detail::all( - lib::array{{!vs.valueless_by_exception()...}}) - ? (void)0 - : throw_bad_variant_access()), - detail::visitation::variant::visit_value(lib::forward(visitor), - lib::forward(vs)...)) -#endif - - template - inline auto swap(variant &lhs, - variant &rhs) noexcept(noexcept(lhs.swap(rhs))) - -> decltype(lhs.swap(rhs)) { - lhs.swap(rhs); - } - - namespace detail { - - template - using enabled_type = T; - - namespace hash { - - template - constexpr bool meets_requirements() { - return std::is_copy_constructible::value && - std::is_move_constructible::value && - lib::is_invocable_r::value; - } - - template - constexpr bool is_enabled() { - using H = std::hash; - return meets_requirements() && - std::is_default_constructible::value && - std::is_copy_assignable::value && - std::is_move_assignable::value; - } - - } // namespace hash - - } // namespace detail - -#undef AUTO -#undef AUTO_RETURN - -#undef AUTO_REFREF -#undef AUTO_REFREF_RETURN - -#undef DECLTYPE_AUTO -#undef DECLTYPE_AUTO_RETURN - -} // namespace mpark - -namespace std { - - template - struct hash, - mpark::lib::enable_if_t>()...>::value>>> { - using argument_type = mpark::variant; - using result_type = std::size_t; - - inline result_type operator()(const argument_type &v) const { - using mpark::detail::visitation::variant; - std::size_t result = - v.valueless_by_exception() - ? 299792458 // Random value chosen by the universe upon creation - : variant::visit_alt( -#ifdef MPARK_GENERIC_LAMBDAS - [](const auto &alt) { - using alt_type = mpark::lib::decay_t; - using value_type = mpark::lib::remove_const_t< - typename alt_type::value_type>; - return hash{}(alt.value); - } -#else - hasher{} -#endif - , - v); - return hash_combine(result, hash{}(v.index())); - } - - private: -#ifndef MPARK_GENERIC_LAMBDAS - struct hasher { - template - inline std::size_t operator()(const Alt &alt) const { - using alt_type = mpark::lib::decay_t; - using value_type = - mpark::lib::remove_const_t; - return hash{}(alt.value); - } - }; -#endif - - static std::size_t hash_combine(std::size_t lhs, std::size_t rhs) { - return lhs ^= rhs + 0x9e3779b9 + (lhs << 6) + (lhs >> 2); - } - }; - - template <> - struct hash { - using argument_type = mpark::monostate; - using result_type = std::size_t; - - inline result_type operator()(const argument_type &) const noexcept { - return 66740831; // return a fundamentally attractive random value. - } - }; - -} // namespace std - -#endif // MPARK_VARIANT_HPP diff --git a/cdll_export.h b/cdll_export.h deleted file mode 100644 index 6ddabcf..0000000 --- a/cdll_export.h +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include - -typedef struct cl_exportfuncs_s -{ - INITIALIZE_FUNC Initialize; - HUD_INIT_FUNC HUD_Init; - HUD_VIDINIT_FUNC HUD_VidInit; - HUD_REDRAW_FUNC HUD_Redraw; - HUD_UPDATECLIENTDATA_FUNC HUD_UpdateClientData; - HUD_RESET_FUNC HUD_Reset; - HUD_CLIENTMOVE_FUNC HUD_PlayerMove; - HUD_CLIENTMOVEINIT_FUNC HUD_PlayerMoveInit; - HUD_TEXTURETYPE_FUNC HUD_PlayerMoveTexture; - HUD_IN_ACTIVATEMOUSE_FUNC IN_ActivateMouse; - HUD_IN_DEACTIVATEMOUSE_FUNC IN_DeactivateMouse; - HUD_IN_MOUSEEVENT_FUNC IN_MouseEvent; - HUD_IN_CLEARSTATES_FUNC IN_ClearStates; - HUD_IN_ACCUMULATE_FUNC IN_Accumulate; - HUD_CL_CREATEMOVE_FUNC CL_CreateMove; - HUD_CL_ISTHIRDPERSON_FUNC CL_IsThirdPerson; - HUD_CL_GETCAMERAOFFSETS_FUNC CL_CameraOffset; - HUD_KB_FIND_FUNC KB_Find; - HUD_CAMTHINK_FUNC CAM_Think; - HUD_CALCREF_FUNC V_CalcRefdef; - HUD_ADDENTITY_FUNC HUD_AddEntity; - HUD_CREATEENTITIES_FUNC HUD_CreateEntities; - HUD_DRAWNORMALTRIS_FUNC HUD_DrawNormalTriangles; - HUD_DRAWTRANSTRIS_FUNC HUD_DrawTransparentTriangles; - HUD_STUDIOEVENT_FUNC HUD_StudioEvent; - HUD_POSTRUNCMD_FUNC HUD_PostRunCmd; - HUD_SHUTDOWN_FUNC HUD_Shutdown; - HUD_TXFERLOCALOVERRIDES_FUNC HUD_TxferLocalOverrides; - HUD_PROCESSPLAYERSTATE_FUNC HUD_ProcessPlayerState; - HUD_TXFERPREDICTIONDATA_FUNC HUD_TxferPredictionData; - HUD_DEMOREAD_FUNC Demo_ReadBuffer; - HUD_CONNECTIONLESS_FUNC HUD_ConnectionlessPacket; - HUD_GETHULLBOUNDS_FUNC HUD_GetHullBounds; - HUD_FRAME_FUNC HUD_Frame; - HUD_KEY_EVENT_FUNC HUD_Key_Event; - HUD_TEMPENTUPDATE_FUNC HUD_TempEntUpdate; - HUD_GETUSERENTITY_FUNC HUD_GetUserEntity; - HUD_VOICESTATUS_FUNC HUD_VoiceStatus; - HUD_DIRECTORMESSAGE_FUNC HUD_DirectorMessage; - HUD_STUDIO_INTERFACE_FUNC HUD_GetStudioModelInterface; - HUD_CHATINPUTPOSITION_FUNC HUD_ChatInputPosition; - HUD_GETPLAYERTEAM HUD_GetPlayerTeam; - CLIENTFACTORY ClientFactory; -} -cl_exportfuncs_t; - -extern cl_exportfuncs_t gExportfuncs; \ No newline at end of file diff --git a/commandline.cpp b/commandline.cpp deleted file mode 100644 index a52d978..0000000 --- a/commandline.cpp +++ /dev/null @@ -1,534 +0,0 @@ -#include -#include "ICommandLine.h" - -#include -#include -#include -#include - -static const int MAX_PARAMETER_LEN = 128; - -class CCommandLine : public ICommandLine -{ -public: - CCommandLine(void); - virtual ~CCommandLine(void); - -public: - virtual void CreateCmdLine(const char *commandline); - virtual void CreateCmdLine(int argc, char **argv); - virtual const char *GetCmdLine(void) const; - virtual const char *CheckParm(const char *psz, const char **ppszValue = 0) const; - - virtual void RemoveParm(const char *parm); - virtual void AppendParm(const char *pszParm, const char *pszValues); - - virtual int ParmCount(void); - virtual int FindParm(const char *psz) const; - virtual const char *GetParm(int nIndex); - - virtual const char *ParmValue(const char *psz, const char *pDefaultVal = NULL); - virtual int ParmValue(const char *psz, int nDefaultVal); - virtual float ParmValue(const char *psz, float flDefaultVal); - - virtual void SetParm(const char *pszParm, const char *pszValues); - virtual void SetParm(const char *pszParm, int iValue); - -private: - enum - { - MAX_PARAMETER_LEN = 128, - MAX_PARAMETERS = 256, - }; - - void LoadParametersFromFile(const char *&pSrc, char *&pDst, size_t maxDestLen, bool bInQuotes); - void ParseCommandLine(void); - void CleanUpParms(void); - void AddArgument(const char *pFirst, const char *pLast); - -private: - char *m_pszCmdLine; - int m_nParmCount; - char *m_ppParms[MAX_PARAMETERS]; -}; - -static CCommandLine g_CmdLine; - -ICommandLine *CommandLine(void) -{ - return &g_CmdLine; -} - -CCommandLine::CCommandLine(void) -{ - m_pszCmdLine = NULL; - m_nParmCount = 0; -} - -CCommandLine::~CCommandLine(void) -{ - CleanUpParms(); - delete[] m_pszCmdLine; -} - -void CCommandLine::LoadParametersFromFile(const char *&pSrc, char *&pDst, size_t maxDestLen, bool bInQuotes) -{ - char szFileName[_MAX_PATH]; - char *pOut; - char *pDestStart = pDst; - - if (maxDestLen < 3) - return; - - pSrc++; - pOut = szFileName; - - char terminatingChar = ' '; - - if (bInQuotes) - terminatingChar = '\"'; - - while (*pSrc && *pSrc != terminatingChar) - { - *pOut++ = *pSrc++; - - if ((pOut - szFileName) >= (_MAX_PATH - 1)) - break; - } - - *pOut = '\0'; - - if (*pSrc) - pSrc++; - - FILE *fp = fopen(szFileName, "r"); - - if (fp) - { - char c = (char)fgetc(fp); - - while (c != EOF) - { - if (c == '\n') - c = ' '; - - *pDst++ = c; - - if ((size_t)(pDst - pDestStart) >= (maxDestLen - 2)) - break; - - c = (char)fgetc(fp); - } - - *pDst++ = ' '; - - fclose(fp); - } - else - { - printf("Parameter file '%s' not found, skipping...", szFileName); - } -} - -void CCommandLine::CreateCmdLine(int argc, char **argv) -{ - char cmdline[2048]; - cmdline[0] = 0; - - const int MAX_CHARS = sizeof(cmdline) - 1; - cmdline[MAX_CHARS] = 0; - - for (int i = 0; i < argc; ++i) - { - strncat(cmdline, "\"", MAX_CHARS); - strncat(cmdline, argv[i], MAX_CHARS); - strncat(cmdline, "\"", MAX_CHARS); - strncat(cmdline, " ", MAX_CHARS); - } - - CreateCmdLine(cmdline); -} - -void CCommandLine::CreateCmdLine(const char *commandline) -{ - if (m_pszCmdLine) - delete[] m_pszCmdLine; - - char szFull[4096]; - - char *pDst = szFull; - const char *pSrc = commandline; - - bool bInQuotes = false; - const char *pInQuotesStart = 0; - - while (*pSrc) - { - if (*pSrc == '"') - { - if (pSrc == commandline || (pSrc[-1] != '/' && pSrc[-1] != '\\')) - { - bInQuotes = !bInQuotes; - pInQuotesStart = pSrc + 1; - } - } - - if (*pSrc == '@') - { - if (pSrc == commandline || (!bInQuotes && isspace(pSrc[-1])) || (bInQuotes && pSrc == pInQuotesStart)) - { - LoadParametersFromFile(pSrc, pDst, sizeof(szFull) - (pDst - szFull), bInQuotes); - continue; - } - } - - if ((pDst - szFull) >= (sizeof(szFull) - 1)) - break; - - *pDst++ = *pSrc++; - } - - *pDst = '\0'; - - size_t len = strlen(szFull) + 1; - m_pszCmdLine = new char[len]; - memcpy(m_pszCmdLine, szFull, len); - - ParseCommandLine(); -} - -static char *_stristr(char *pStr, const char *pSearch) -{ - if (!pStr || !pSearch) - return 0; - - char *pLetter = pStr; - - while (*pLetter != 0) - { - if (tolower((unsigned char)*pLetter) == tolower((unsigned char)*pSearch)) - { - char const *pMatch = pLetter + 1; - char const *pTest = pSearch + 1; - - while (*pTest != 0) - { - if (*pMatch == 0) - return 0; - - if (tolower((unsigned char)*pMatch) != tolower((unsigned char)*pTest)) - break; - - ++pMatch; - ++pTest; - } - - if (*pTest == 0) - return pLetter; - } - - ++pLetter; - } - - return 0; -} - -void CCommandLine::RemoveParm(const char *pszParm) -{ - if (!m_pszCmdLine) - return; - - char *p, *found; - char *pnextparam; - size_t n; - size_t curlen; - - p = m_pszCmdLine; - - while (*p) - { - curlen = strlen(p); - found = _stristr(p, pszParm); - - if (!found) - break; - - pnextparam = found + 1; - - while (pnextparam && *pnextparam && (*pnextparam != ' ')) - pnextparam++; - - if (pnextparam && (static_cast(pnextparam - found) > strlen(pszParm))) - { - p = pnextparam; - continue; - } - - while (pnextparam && *pnextparam && (*pnextparam != '-') && (*pnextparam != '+')) - pnextparam++; - - if (pnextparam && *pnextparam) - { - n = curlen - (pnextparam - p); - memcpy(found, pnextparam, n); - found[n] = '\0'; - } - else - { - n = pnextparam - found; - memset(found, 0, n); - } - } - - while (1) - { - size_t len = strlen(m_pszCmdLine); - - if (len == 0 || m_pszCmdLine[len - 1] != ' ') - break; - - m_pszCmdLine[len - 1] = '\0'; - } - - ParseCommandLine(); -} - -void CCommandLine::AppendParm(const char *pszParm, const char *pszValues) -{ - size_t nNewLength = 0; - char *pCmdString; - - nNewLength = strlen(pszParm); - - if (pszValues) - nNewLength += strlen(pszValues) + 1; - - nNewLength++; - - if (!m_pszCmdLine) - { - m_pszCmdLine = new char[nNewLength]; - strcpy(m_pszCmdLine, pszParm); - - if (pszValues) - { - strcat(m_pszCmdLine, " "); - strcat(m_pszCmdLine, pszValues); - } - - ParseCommandLine(); - return; - } - - RemoveParm(pszParm); - - nNewLength += strlen(m_pszCmdLine) + 1 + 1; - - pCmdString = new char[nNewLength]; - memset(pCmdString, 0, nNewLength); - - strcpy(pCmdString, m_pszCmdLine); - strcat(pCmdString, " "); - strcat(pCmdString, pszParm); - - if (pszValues) - { - strcat(pCmdString, " "); - strcat(pCmdString, pszValues); - } - - delete[] m_pszCmdLine; - m_pszCmdLine = pCmdString; - - ParseCommandLine(); -} - -const char *CCommandLine::GetCmdLine(void) const -{ - return m_pszCmdLine; -} - -const char *CCommandLine::CheckParm(const char *psz, const char **ppszValue) const -{ - if (ppszValue) - *ppszValue = NULL; - - int i = FindParm(psz); - - if (i == 0) - return NULL; - - if (ppszValue) - { - if ((i + 1) >= m_nParmCount) - { - *ppszValue = NULL; - } - else - { - *ppszValue = m_ppParms[i + 1]; - } - } - - return m_ppParms[i]; -} - -void CCommandLine::AddArgument(const char *pFirst, const char *pLast) -{ - if (pLast == pFirst) - return; - - if (m_nParmCount >= MAX_PARAMETERS) - printf("CCommandLine::AddArgument: exceeded %d parameters", MAX_PARAMETERS); - - int nLen = (int)pLast - (int)pFirst + 1; - m_ppParms[m_nParmCount] = new char[nLen]; - memcpy(m_ppParms[m_nParmCount], pFirst, nLen - 1); - m_ppParms[m_nParmCount][nLen - 1] = 0; - - ++m_nParmCount; -} - -void CCommandLine::ParseCommandLine(void) -{ - CleanUpParms(); - - if (!m_pszCmdLine) - return; - - const char *pChar = m_pszCmdLine; - - while (*pChar && isspace(*pChar)) - ++pChar; - - bool bInQuotes = false; - const char *pFirstLetter = NULL; - - for (; *pChar; ++pChar) - { - if (bInQuotes) - { - if (*pChar != '\"') - continue; - - AddArgument(pFirstLetter, pChar); - pFirstLetter = NULL; - bInQuotes = false; - continue; - } - - if (!pFirstLetter) - { - if (*pChar == '\"') - { - bInQuotes = true; - pFirstLetter = pChar + 1; - continue; - } - - if (isspace(*pChar)) - continue; - - pFirstLetter = pChar; - continue; - } - - if (isspace(*pChar)) - { - AddArgument(pFirstLetter, pChar); - pFirstLetter = NULL; - } - } - - if (pFirstLetter) - { - AddArgument(pFirstLetter, pChar); - } -} - -void CCommandLine::CleanUpParms(void) -{ - for (int i = 0; i < m_nParmCount; ++i) - { - delete[] m_ppParms[i]; - m_ppParms[i] = NULL; - } - - m_nParmCount = 0; -} - -int CCommandLine::ParmCount(void) -{ - return m_nParmCount; -} - -int CCommandLine::FindParm(const char *psz) const -{ - for (int i = 1; i < m_nParmCount; ++i) - { - if (!_stricmp(psz, m_ppParms[i])) - return i; - } - - return 0; -} - -const char *CCommandLine::GetParm(int nIndex) -{ - if ((nIndex < 0) || (nIndex >= m_nParmCount)) - return ""; - - return m_ppParms[nIndex]; -} - -const char *CCommandLine::ParmValue(const char *psz, const char *pDefaultVal) -{ - int nIndex = FindParm(psz); - - if ((nIndex == 0) || (nIndex == m_nParmCount - 1)) - return pDefaultVal; - - if (m_ppParms[nIndex + 1][0] == '-' || m_ppParms[nIndex + 1][0] == '+') - return pDefaultVal; - - return m_ppParms[nIndex + 1]; -} - -int CCommandLine::ParmValue(const char *psz, int nDefaultVal) -{ - int nIndex = FindParm(psz); - - if ((nIndex == 0) || (nIndex == m_nParmCount - 1)) - return nDefaultVal; - - if (m_ppParms[nIndex + 1][0] == '-' || m_ppParms[nIndex + 1][0] == '+') - return nDefaultVal; - - return atoi(m_ppParms[nIndex + 1]); -} - -float CCommandLine::ParmValue(const char *psz, float flDefaultVal) -{ - int nIndex = FindParm(psz); - - if ((nIndex == 0) || (nIndex == m_nParmCount - 1)) - return flDefaultVal; - - if (m_ppParms[nIndex + 1][0] == '-' || m_ppParms[nIndex + 1][0] == '+') - return flDefaultVal; - - return (float)atof(m_ppParms[nIndex + 1]); -} - -void CCommandLine::SetParm(const char *pszParm, const char *pszValues) -{ - RemoveParm(pszParm); - AppendParm(pszParm, pszValues); -} - -void CCommandLine::SetParm(const char *pszParm, int iValue) -{ - char pszValue[64]; - _snprintf(pszValue, sizeof(pszValue), "%d", iValue); - SetParm(pszParm, iValue); -} \ No newline at end of file diff --git a/common/interface.h b/common/interface.h deleted file mode 100644 index b49d087..0000000 --- a/common/interface.h +++ /dev/null @@ -1,129 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// This header defines the interface convention used in the valve engine. -// To make an interface and expose it: -// 1. Derive from IBaseInterface. -// 2. The interface must be ALL pure virtuals, and have no data members. -// 3. Define a name for it. -// 4. In its implementation file, use EXPOSE_INTERFACE or EXPOSE_SINGLE_INTERFACE. - -// Versioning -// There are two versioning cases that are handled by this: -// 1. You add functions to the end of an interface, so it is binary compatible with the previous interface. In this case, -// you need two EXPOSE_INTERFACEs: one to expose your class as the old interface and one to expose it as the new interface. -// 2. You update an interface so it's not compatible anymore (but you still want to be able to expose the old interface -// for legacy code). In this case, you need to make a new version name for your new interface, and make a wrapper interface and -// expose it for the old interface. - -#ifndef INTERFACE_H -#define INTERFACE_H - -#ifdef __cplusplus - -// All interfaces derive from this. -class IBaseInterface -{ -public: - - virtual ~IBaseInterface() {} -}; - - -#define CREATEINTERFACE_PROCNAME "CreateInterface" -typedef IBaseInterface* (*CreateInterfaceFn)(const char *pName, int *pReturnCode); - - -typedef IBaseInterface* (*InstantiateInterfaceFn)(); - - -// Used internally to register classes. -class InterfaceReg -{ -public: - InterfaceReg(InstantiateInterfaceFn fn, const char *pName); - -public: - - InstantiateInterfaceFn m_CreateFn; - const char *m_pName; - - InterfaceReg *m_pNext; // For the global list. - static InterfaceReg *s_pInterfaceRegs; -}; - - -// Use this to expose an interface that can have multiple instances. -// e.g.: -// EXPOSE_INTERFACE( CInterfaceImp, IInterface, "MyInterface001" ) -// This will expose a class called CInterfaceImp that implements IInterface (a pure class) -// clients can receive a pointer to this class by calling CreateInterface( "MyInterface001" ) -// -// In practice, the shared header file defines the interface (IInterface) and version name ("MyInterface001") -// so that each component can use these names/vtables to communicate -// -// A single class can support multiple interfaces through multiple inheritance -// -#define EXPOSE_INTERFACE_FN(functionName, interfaceName, versionName) \ - static InterfaceReg __g_Create##className##_reg(functionName, versionName); - -#define EXPOSE_INTERFACE(className, interfaceName, versionName) \ - static IBaseInterface* __Create##className##_interface() {return (interfaceName *)new className;}\ - static InterfaceReg __g_Create##className##_reg(__Create##className##_interface, versionName ); - -// Use this to expose a singleton interface with a global variable you've created. -#define EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, globalVarName) \ - static IBaseInterface* __Create##className##interfaceName##_interface() {return (interfaceName *)&globalVarName;}\ - static InterfaceReg __g_Create##className##interfaceName##_reg(__Create##className##interfaceName##_interface, versionName); - -// Use this to expose a singleton interface. This creates the global variable for you automatically. -#define EXPOSE_SINGLE_INTERFACE(className, interfaceName, versionName) \ - static className __g_##className##_singleton;\ - EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, __g_##className##_singleton) - - -#ifdef WIN32 - #define EXPORT_FUNCTION __declspec(dllexport) -#else - #define EXPORT_FUNCTION -#endif - - -// This function is automatically exported and allows you to access any interfaces exposed with the above macros. -// if pReturnCode is set, it will return one of the following values -// extend this for other error conditions/code -enum -{ - IFACE_OK = 0, - IFACE_FAILED -}; - - -extern "C" -{ - EXPORT_FUNCTION IBaseInterface* CreateInterface(const char *pName, int *pReturnCode); -}; - - -// Handle to an interface (HInterfaceModule_t* is just there for type safety). -typedef struct HInterfaceModule_t* HINTERFACEMODULE; - - -// Use these to load and unload a module. -extern HINTERFACEMODULE Sys_LoadModule(const char *pModuleName); -extern void Sys_FreeModule(HINTERFACEMODULE hModule); - -// Use these to get the factory function from either a loaded module or the current module. -extern CreateInterfaceFn Sys_GetFactory( HINTERFACEMODULE hModule ); -extern CreateInterfaceFn Sys_GetFactoryThis( void ); - -#endif // __cplusplus - -#endif - - - diff --git a/externals/alure b/externals/alure new file mode 160000 index 0000000..5c504e1 --- /dev/null +++ b/externals/alure @@ -0,0 +1 @@ +Subproject commit 5c504e1fbb12d04fe3810ebd31a267c81bff0618 diff --git a/externals/metahook b/externals/metahook new file mode 160000 index 0000000..059c52b --- /dev/null +++ b/externals/metahook @@ -0,0 +1 @@ +Subproject commit 059c52b0826df6e984879096d83e522f8ba91678 diff --git a/externals/openal-soft b/externals/openal-soft new file mode 160000 index 0000000..d2608e4 --- /dev/null +++ b/externals/openal-soft @@ -0,0 +1 @@ +Subproject commit d2608e4bde41b3005a06346bea99bbe06404ef22 diff --git a/Plugins/Audio/FileSystem.h b/include/FileSystem.h similarity index 100% rename from Plugins/Audio/FileSystem.h rename to include/FileSystem.h diff --git a/Plugins/Audio/aud_int_internal.h b/include/aud_int_internal.h similarity index 62% rename from Plugins/Audio/aud_int_internal.h rename to include/aud_int_internal.h index ca22d63..bf2714e 100644 --- a/Plugins/Audio/aud_int_internal.h +++ b/include/aud_int_internal.h @@ -2,9 +2,8 @@ typedef struct { - }aud_export_t; extern aud_export_t gAudExports; -#define META_AUDIO_VERSION "Meta Audio 1.1c" \ No newline at end of file +#define META_AUDIO_VERSION "Meta Audio 0d2d2808" \ No newline at end of file diff --git a/Plugins/Audio/enginedef.h b/include/enginedef.h similarity index 99% rename from Plugins/Audio/enginedef.h rename to include/enginedef.h index 61d4b9d..d31ac73 100644 --- a/Plugins/Audio/enginedef.h +++ b/include/enginedef.h @@ -1,5 +1,5 @@ #pragma once -#include "alure/AL/alure2.h" +#include "alure2.h" #define MAX_QPATH 64 // max length of a quake game pathname diff --git a/Plugins/Audio/exportfuncs.h b/include/exportfuncs.h similarity index 100% rename from Plugins/Audio/exportfuncs.h rename to include/exportfuncs.h diff --git a/HLSDK/common/interface.h b/include/interface.h similarity index 100% rename from HLSDK/common/interface.h rename to include/interface.h diff --git a/Plugins/Audio/plat.h b/include/plat.h similarity index 100% rename from Plugins/Audio/plat.h rename to include/plat.h diff --git a/Plugins/Audio/plugins.h b/include/plugins.h similarity index 100% rename from Plugins/Audio/plugins.h rename to include/plugins.h diff --git a/Plugins/Audio/snd_fx.hpp b/include/snd_fx.hpp similarity index 98% rename from Plugins/Audio/snd_fx.hpp rename to include/snd_fx.hpp index fb62d33..ec4abb9 100644 --- a/Plugins/Audio/snd_fx.hpp +++ b/include/snd_fx.hpp @@ -1,6 +1,6 @@ #pragma once -#include "alure/AL/efx-presets.h" +#include "efx-presets.h" class EnvEffects final { diff --git a/Plugins/Audio/snd_loader.h b/include/snd_loader.h similarity index 87% rename from Plugins/Audio/snd_loader.h rename to include/snd_loader.h index 0866c4b..8758791 100644 --- a/Plugins/Audio/snd_loader.h +++ b/include/snd_loader.h @@ -1,7 +1,7 @@ #pragma once #include -#include "alure/AL/alure2.h" +#include "alure2.h" class GoldSrcFileFactory final : public alure::FileIOFactory { public: diff --git a/Plugins/Audio/snd_local.h b/include/snd_local.h similarity index 100% rename from Plugins/Audio/snd_local.h rename to include/snd_local.h diff --git a/Plugins/Audio/snd_voice.hpp b/include/snd_voice.hpp similarity index 100% rename from Plugins/Audio/snd_voice.hpp rename to include/snd_voice.hpp diff --git a/Plugins/Audio/snd_vox.hpp b/include/snd_vox.hpp similarity index 100% rename from Plugins/Audio/snd_vox.hpp rename to include/snd_vox.hpp diff --git a/Plugins/Audio/snd_wav.hpp b/include/snd_wav.hpp similarity index 100% rename from Plugins/Audio/snd_wav.hpp rename to include/snd_wav.hpp diff --git a/Plugins/Audio/zone.h b/include/zone.h similarity index 100% rename from Plugins/Audio/zone.h rename to include/zone.h diff --git a/launcher.cpp b/launcher.cpp deleted file mode 100644 index 4f98f21..0000000 --- a/launcher.cpp +++ /dev/null @@ -1,254 +0,0 @@ -#include "metahook.h" -#include -#include "LoadBlob.h" -#include "ExceptHandle.h" -#include "sys.h" - -#pragma warning(disable : 4733) -#pragma comment(lib, "ws2_32.lib") - -IFileSystem *g_pFileSystem; - -HINTERFACEMODULE LoadFilesystemModule(void) -{ - HINTERFACEMODULE hModule = Sys_LoadModule("filesystem_stdio.dll"); - - if (!hModule) - { - MessageBox(NULL, "Could not load filesystem dll.\nFileSystem crashed during construction.", "Fatal Error", MB_ICONERROR); - return NULL; - } - - return hModule; -} - -void SetEngineDLL(const char *&pszEngineDLL) -{ - pszEngineDLL = registry->ReadString("EngineDLL", "hw.dll"); - - if (CommandLine()->CheckParm("-soft") || CommandLine()->CheckParm("-software")) - pszEngineDLL = "sw.dll"; - else if (CommandLine()->CheckParm("-gl") || CommandLine()->CheckParm("-d3d")) - pszEngineDLL = "hw.dll"; - - registry->WriteString("EngineDLL", pszEngineDLL); -} - -BOOL OnVideoModeFailed(void) -{ - registry->WriteInt("ScreenWidth", 640); - registry->WriteInt("ScreenHeight", 480); - registry->WriteInt("ScreenBPP", 16); - registry->WriteString("EngineDLL", "sw.dll"); - - return (MessageBox(NULL, "The specified video mode is not supported.\nThe game will now run in software mode.", "Video mode change failure", MB_OKCANCEL | MB_ICONWARNING) == IDOK); -} - -BlobFootprint_t g_blobfootprintClient; - -int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) -{ - HANDLE hObject = NULL; - - CommandLine()->CreateCmdLine(GetCommandLine()); - CommandLine()->RemoveParm("-steam"); - -#ifndef _DEBUG - BOOL(*IsDebuggerPresent)(void) = (BOOL(*)(void))GetProcAddress(GetModuleHandle("kernel32.dll"), "IsDebuggerPresent"); - - if (!IsDebuggerPresent() && CommandLine()->CheckParm("-nomutex") == NULL) - { - hObject = CreateMutex(NULL, FALSE, "ValveHalfLifeLauncherMutex"); - - DWORD dwStatus = WaitForSingleObject(hObject, 0); - - if (dwStatus && dwStatus != WAIT_ABANDONED) - { - MessageBox(NULL, "Could not launch game.\nOnly one instance of this game can be run at a time.", "Error", MB_ICONERROR); - return 0; - } - } -#endif - - WSAData WSAData; - WSAStartup(2, &WSAData); - - registry->Init(); - - char szFileName[256]; - Sys_GetExecutableName(szFileName, sizeof(szFileName)); - char *szExeName = strrchr(szFileName, '\\') + 1; - - if (stricmp(szExeName, "hl.exe") && CommandLine()->CheckParm("-game") == NULL) - { - szExeName[strlen(szExeName) - 4] = '\0'; - CommandLine()->AppendParm("-game", szExeName); - } - - const char *_szGameName; - static char szGameName[32]; - const char *szGameStr = CommandLine()->CheckParm("-game", &_szGameName); - strcpy(szGameName, _szGameName); - - if (szGameStr && !strnicmp(&szGameStr[6], "czero", 5)) - CommandLine()->AppendParm("-forcevalve", NULL); - - if (registry->ReadInt("CrashInitializingVideoMode", FALSE)) - { - registry->WriteInt("CrashInitializingVideoMode", FALSE); - - if (strcmp(registry->ReadString("EngineDLL", "hw.dll"), "hw.dll")) - { - if (registry->ReadInt("EngineD3D", FALSE)) - { - registry->WriteInt("EngineD3D", FALSE); - - if (MessageBox(NULL, "The game has detected that the previous attempt to start in D3D video mode failed.\nThe game will now run attempt to run in openGL mode.", "Video mode change failure", MB_OKCANCEL | MB_ICONWARNING) != IDOK) - return 0; - } - else - { - registry->WriteString("EngineDLL", "sw.dll"); - - if (MessageBox(NULL, "The game has detected that the previous attempt to start in openGL video mode failed.\nThe game will now run in software mode.", "Video mode change failure", MB_OKCANCEL | MB_ICONWARNING) != IDOK) - return 0; - } - - registry->WriteInt("ScreenWidth", 640); - registry->WriteInt("ScreenHeight", 480); - registry->WriteInt("ScreenBPP", 16); - } - } - - while (1) - { - HINTERFACEMODULE hFileSystem = LoadFilesystemModule(); - - if (!hFileSystem) - break; - - MH_Init(szGameName); - - CreateInterfaceFn fsCreateInterface = (CreateInterfaceFn)Sys_GetFactory(hFileSystem); - g_pFileSystem = (IFileSystem *)fsCreateInterface(FILESYSTEM_INTERFACE_VERSION, NULL); - g_pFileSystem->Mount(); - g_pFileSystem->AddSearchPath(Sys_GetLongPathName(), "ROOT"); - - static char szNewCommandParams[2048]; - const char *pszEngineDLL; - int iResult = ENGINE_RESULT_NONE; - - SetEngineDLL(pszEngineDLL); - - szNewCommandParams[0] = 0; - g_blobfootprintClient.m_hDll = NULL; - - IEngine *engineAPI = NULL; - HINTERFACEMODULE hEngine; - bool bUseBlobDLL = false; - - if (FIsBlob(pszEngineDLL)) - { -#ifndef _USRDLL - Sys_CloseDEP(); - SetupExceptHandler3(); -#endif - NLoadBlobFile(pszEngineDLL, &g_blobfootprintClient, (void **)&engineAPI); - bUseBlobDLL = true; - } - else - { - hEngine = Sys_LoadModule(pszEngineDLL); - - if (!hEngine) - { - static char msg[512]; - wsprintf(msg, "Could not load %s.\nPlease try again at a later time.", pszEngineDLL); - MessageBox(NULL, msg, "Fatal Error", MB_ICONERROR); - break; - } - - CreateInterfaceFn engineCreateInterface = (CreateInterfaceFn)Sys_GetFactory(hEngine); - engineAPI = (IEngine *)engineCreateInterface(VENGINE_LAUNCHER_API_VERSION, NULL); - - if (!engineCreateInterface || !engineAPI) - Sys_FreeModule(hEngine); - } - - if (engineAPI) - { - MH_LoadEngine(bUseBlobDLL ? NULL : (HMODULE)hEngine); - iResult = engineAPI->Run(hInstance, Sys_GetLongPathName(), CommandLine()->GetCmdLine(), szNewCommandParams, Sys_GetFactoryThis(), Sys_GetFactory(hFileSystem)); - MH_ExitGame(iResult); - - if (bUseBlobDLL) - FreeBlob(&g_blobfootprintClient); - else - Sys_FreeModule(hEngine); - } - - if (iResult == ENGINE_RESULT_NONE || iResult > ENGINE_RESULT_UNSUPPORTEDVIDEO) - break; - - bool bContinue; - - switch (iResult) - { - case ENGINE_RESULT_RESTART: - { - bContinue = true; - break; - } - - case ENGINE_RESULT_UNSUPPORTEDVIDEO: - { - bContinue = OnVideoModeFailed() != FALSE; - break; - } - } - - CommandLine()->RemoveParm("-sw"); - CommandLine()->RemoveParm("-startwindowed"); - CommandLine()->RemoveParm("-windowed"); - CommandLine()->RemoveParm("-window"); - CommandLine()->RemoveParm("-full"); - CommandLine()->RemoveParm("-fullscreen"); - CommandLine()->RemoveParm("-soft"); - CommandLine()->RemoveParm("-software"); - CommandLine()->RemoveParm("-gl"); - CommandLine()->RemoveParm("-d3d"); - CommandLine()->RemoveParm("-w"); - CommandLine()->RemoveParm("-width"); - CommandLine()->RemoveParm("-h"); - CommandLine()->RemoveParm("-height"); - CommandLine()->RemoveParm("-novid"); - - if (strstr(szNewCommandParams, "-game")) - CommandLine()->RemoveParm("-game"); - - if (strstr(szNewCommandParams, "+load")) - CommandLine()->RemoveParm("+load"); - - CommandLine()->AppendParm(szNewCommandParams, NULL); - - g_pFileSystem->Unmount(); - Sys_FreeModule(hFileSystem); - MH_Shutdown(); - - if (!bContinue) - break; - } - - registry->Shutdown(); - - if (hObject) - { - ReleaseMutex(hObject); - CloseHandle(hObject); - } - - WSACleanup(); - MH_Shutdown(); - TerminateProcess(GetCurrentProcess(), 1); - return 1; -} \ No newline at end of file diff --git a/metahook.cpp b/metahook.cpp deleted file mode 100644 index 061217e..0000000 --- a/metahook.cpp +++ /dev/null @@ -1,850 +0,0 @@ -#include -#include -#include - -#include "metahook.h" -#include "LoadBlob.h" -#include "Detours\detours.h" -#include "interface.h" - -#include - -struct hook_s -{ - void *pOldFuncAddr; - void *pNewFuncAddr; - void *pClass; - int iTableIndex; - int iFuncIndex; - HMODULE hModule; - const char *pszModuleName; - const char *pszFuncName; - struct hook_s *pNext; - void *pInfo; -}; - -int(*g_pfnbuild_number)(void); -void *g_pClientDLL_Init; -int(*g_pfnClientDLL_Init)(void); -hook_t *g_phClientDLL_Init; - -BOOL g_bEngineIsBlob; -HMODULE g_hEngineModule; -DWORD g_dwEngineBase; -DWORD g_dwEngineSize; -hook_t *g_pHookBase; -cl_exportfuncs_t *g_pExportFuncs; -bool g_bSaveVideo; -char g_szTempFile[MAX_PATH]; -bool g_bIsNewEngine; - -hook_t *MH_FindInlineHooked(void *pOldFuncAddr); -hook_t *MH_FindVFTHooked(void *pClass, int iTableIndex, int iFuncIndex); -hook_t *MH_FindIATHooked(HMODULE hModule, const char *pszModuleName, const char *pszFuncName); -BOOL MH_UnHook(hook_t *pHook); -hook_t *MH_InlineHook(void *pOldFuncAddr, void *pNewFuncAddr, void *&pCallBackFuncAddr); -hook_t *MH_VFTHook(void *pClass, int iTableIndex, int iFuncIndex, void *pNewFuncAddr, void *&pCallBackFuncAddr); -hook_t *MH_IATHook(HMODULE hModule, const char *pszModuleName, const char *pszFuncName, void *pNewFuncAddr, void *&pCallBackFuncAddr); -void *MH_GetClassFuncAddr(...); -DWORD MH_GetModuleBase(HMODULE hModule); -DWORD MH_GetModuleSize(HMODULE hModule); -void *MH_SearchPattern(void *pStartSearch, DWORD dwSearchLen, char *pPattern, DWORD dwPatternLen); -void MH_WriteDWORD(void *pAddress, DWORD dwValue); -DWORD MH_ReadDWORD(void *pAddress); -void MH_WriteBYTE(void *pAddress, BYTE ucValue); -BYTE MH_ReadBYTE(void *pAddress); -void MH_WriteNOP(void *pAddress, DWORD dwCount); -DWORD MH_WriteMemory(void *pAddress, BYTE *pData, DWORD dwDataSize); -DWORD MH_ReadMemory(void *pAddress, BYTE *pData, DWORD dwDataSize); -DWORD MH_GetVideoMode(int *wide, int *height, int *bpp, bool *windowed); -DWORD MH_GetEngineVersion(void); - -#define BUILD_NUMBER_SIG "\xA1\x2A\x2A\x2A\x2A\x83\xEC\x08\x2A\x33\x2A\x85\xC0" -#define BUILD_NUMBER_SIG_NEW "\x55\x8B\xEC\x83\xEC\x08\xA1\x2A\x2A\x2A\x2A\x56\x33\xF6\x85\xC0\x0F\x85\x2A\x2A\x2A\x2A\x53\x33\xDB\x8B\x04\x9D" -#define CLIENTDLL_INIT_SIG "\x81\xEC\x00\x04\x00\x00\x8D\x44\x24\x00\x68\x2A\x2A\x2A\x2A\x68\x00\x02\x00\x00\x50\xE8\x2A\x2A\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x83\xC4\x0C\x85\xC0" -#define CLIENTDLL_INIT_SIG_NEW "\x55\x8B\xEC\x81\xEC\x00\x02\x00\x00\x68\x2A\x2A\x2A\x2A\x8D\x85\x00\xFE\xFF\xFF\x68\x00\x02\x00\x00\x50\xE8\x2A\x2A\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x83\xC4\x0C\x85\xC0\x74\x2A\xE8" - -typedef struct plugin_s -{ - char *filename; - HINTERFACEMODULE module; - IBaseInterface *pPluginAPI; - int iInterfaceVersion; - struct plugin_s *next; -} -plugin_t; - -plugin_t *g_pPluginBase; - -extern IFileSystem *g_pFileSystem; - -mh_interface_t gInterface; -mh_enginesave_t gMetaSave; - -extern metahook_api_t gMetaHookAPI; - -bool HM_LoadPlugins(char *filename, HINTERFACEMODULE hModule) -{ - plugin_t *plug = new plugin_t; - plug->module = hModule; - - CreateInterfaceFn fnCreateInterface = Sys_GetFactory(plug->module); - plug->pPluginAPI = fnCreateInterface(METAHOOK_PLUGIN_API_VERSION, nullptr); - - if (plug->pPluginAPI) - { - ((IPlugins *)plug->pPluginAPI)->Init(&gMetaHookAPI, &gInterface, &gMetaSave); - plug->iInterfaceVersion = 2; - } - else - { - plug->pPluginAPI = fnCreateInterface(METAHOOK_PLUGIN_API_VERSION_V1, nullptr); - - if (plug->pPluginAPI) - plug->iInterfaceVersion = 1; - else - plug->iInterfaceVersion = 0; - } - - plug->filename = strdup(filename); - plug->next = g_pPluginBase; - g_pPluginBase = plug; - return true; -} - -void MH_Init(const char *pszGameName) -{ - g_pfnbuild_number = nullptr; - g_pfnClientDLL_Init = nullptr; - g_phClientDLL_Init = nullptr; - - g_dwEngineBase = 0; - g_dwEngineSize = 0; - g_pHookBase = nullptr; - g_pExportFuncs = nullptr; - g_bSaveVideo = false; - g_szTempFile[0] = 0; - - gInterface.CommandLine = CommandLine(); - gInterface.FileSystem = g_pFileSystem; - gInterface.Registry = registry; - - std::string metapath(pszGameName); - metapath += "/metahook"; - - std::string filename(metapath); - filename += "/configs/plugins.lst"; - - std::ifstream plugin_list(filename); - - std::string plugin; - while (std::getline(plugin_list, plugin)) - { - if (!plugin.empty() && !std::all_of(plugin.begin(), plugin.end(), ::isspace)) - { - filename = metapath + "/plugins/" + plugin; - - HINTERFACEMODULE hModule = Sys_LoadModule(filename.c_str()); - if (!hModule) - { - DWORD dw = GetLastError(); - LPVOID lpMsgBuf; - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - dw, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&lpMsgBuf, - 0, NULL); - - MessageBox(NULL, ("Module name: " + filename + ". Error code: " + std::to_string(dw) + ". Message: " + static_cast(lpMsgBuf)).c_str(), "Problem loading module", MB_ICONWARNING); - LocalFree(lpMsgBuf); - continue; - } - - if (!HM_LoadPlugins(const_cast(filename.c_str()), hModule)) - { - MessageBox(NULL, ("Plugin name: " + filename).c_str(), "Problem loading plugin", MB_ICONWARNING); - continue; - } - } - } -} - -int ClientDLL_Initialize(struct cl_enginefuncs_s *pEnginefuncs, int iVersion) -{ - gMetaSave.pExportFuncs = new cl_exportfuncs_t; - gMetaSave.pEngineFuncs = new cl_enginefunc_t; - - memcpy(gMetaSave.pExportFuncs, g_pExportFuncs, sizeof(cl_exportfuncs_t)); - memcpy(gMetaSave.pEngineFuncs, pEnginefuncs, sizeof(cl_enginefunc_t)); - - for (plugin_t *plug = g_pPluginBase; plug; plug = plug->next) - { - if (plug->iInterfaceVersion > 1) - ((IPlugins *)plug->pPluginAPI)->LoadClient(g_pExportFuncs); - else - ((IPluginsV1 *)plug->pPluginAPI)->Init(g_pExportFuncs); - } - - return g_pExportFuncs->Initialize(pEnginefuncs, iVersion); -} - -void MH_ClientDLL_Init(void) -{ - DWORD dwResult = (DWORD)MH_SearchPattern((void *)((DWORD)g_pClientDLL_Init + 0xB0), 0xFF, "\x6A\x07\x68", 3); - - if (!dwResult) - return; - - g_pExportFuncs = *(cl_exportfuncs_t **)(dwResult + 0x9); - - static DWORD dwClientDLL_Initialize[1]; - dwClientDLL_Initialize[0] = (DWORD)&ClientDLL_Initialize; - MH_WriteDWORD((void *)(dwResult + 0x9), (DWORD)dwClientDLL_Initialize); - g_pfnClientDLL_Init(); -} - -void MH_LoadEngine(HMODULE hModule) -{ - gInterface.FileSystem = g_pFileSystem; - - if (hModule) - { - g_dwEngineBase = MH_GetModuleBase(hModule); - g_dwEngineSize = MH_GetModuleSize(hModule); - g_hEngineModule = hModule; - g_bEngineIsBlob = FALSE; - } - else - { - g_dwEngineBase = 0x1D01000; - g_dwEngineSize = 0x1000000; - g_hEngineModule = GetModuleHandle(NULL); - g_bEngineIsBlob = TRUE; - } - - g_bIsNewEngine = false; - g_pfnbuild_number = (int(*)(void))MH_SearchPattern((void *)g_dwEngineBase, g_dwEngineSize, BUILD_NUMBER_SIG, sizeof(BUILD_NUMBER_SIG) - 1); - - if (!g_pfnbuild_number) - { - g_pfnbuild_number = (int(*)(void))MH_SearchPattern((void *)g_dwEngineBase, g_dwEngineSize, BUILD_NUMBER_SIG_NEW, sizeof(BUILD_NUMBER_SIG_NEW) - 1); - g_bIsNewEngine = true; - } - - if (g_bIsNewEngine) - g_pClientDLL_Init = MH_SearchPattern((void *)g_dwEngineBase, g_dwEngineSize, CLIENTDLL_INIT_SIG_NEW, sizeof(CLIENTDLL_INIT_SIG_NEW) - 1); - else - g_pClientDLL_Init = MH_SearchPattern((void *)g_dwEngineBase, g_dwEngineSize, CLIENTDLL_INIT_SIG, sizeof(CLIENTDLL_INIT_SIG) - 1); - - g_phClientDLL_Init = MH_InlineHook(g_pClientDLL_Init, MH_ClientDLL_Init, (void *&)g_pfnClientDLL_Init); - - for (plugin_t *plug = g_pPluginBase; plug; plug = plug->next) - { - if (plug->iInterfaceVersion > 1) - ((IPlugins *)plug->pPluginAPI)->LoadEngine(); - } -} - -void MH_ExitGame(int iResult) -{ - for (plugin_t *plug = g_pPluginBase; plug; plug = plug->next) - { - if (plug->iInterfaceVersion > 1) - ((IPlugins *)plug->pPluginAPI)->ExitGame(iResult); - } -} - -void MH_FreeAllPlugin(void) -{ - plugin_t *plug = g_pPluginBase; - - while (plug) - { - plugin_t *pfree = plug; - plug = plug->next; - - if (pfree->pPluginAPI) - { - if (pfree->iInterfaceVersion > 1) - ((IPlugins *)pfree->pPluginAPI)->Shutdown(); - } - - free(pfree->filename); - Sys_FreeModule(pfree->module); - delete pfree; - } - - g_pPluginBase = NULL; -} - -void MH_ShutdownPlugins(void) -{ - plugin_t *plug = g_pPluginBase; - - while (plug) - { - plugin_t *pfree = plug; - plug = plug->next; - - if (pfree->pPluginAPI) - { - if (pfree->iInterfaceVersion > 1) - ((IPlugins *)pfree->pPluginAPI)->Shutdown(); - } - - free(pfree->filename); - FreeLibrary((HMODULE)pfree->module); - delete pfree; - } - - g_pPluginBase = NULL; -} - -void MH_Shutdown(void) -{ - if (g_pHookBase) - MH_FreeAllHook(); - - if (g_pPluginBase) - MH_ShutdownPlugins(); - - if (gMetaSave.pExportFuncs) - { - delete gMetaSave.pExportFuncs; - gMetaSave.pExportFuncs = NULL; - } - - if (gMetaSave.pEngineFuncs) - { - delete gMetaSave.pEngineFuncs; - gMetaSave.pEngineFuncs = NULL; - } -} - -hook_t *MH_NewHook(void) -{ - hook_t *h = new hook_t; - memset(h, 0, sizeof(hook_t)); - h->pNext = g_pHookBase; - g_pHookBase = h; - return h; -} - -hook_t *MH_FindInlineHooked(void *pOldFuncAddr) -{ - for (hook_t *h = g_pHookBase; h; h = h->pNext) - { - if (h->pOldFuncAddr == pOldFuncAddr) - return h; - } - - return NULL; -} - -hook_t *MH_FindVFTHooked(void *pClass, int iTableIndex, int iFuncIndex) -{ - for (hook_t *h = g_pHookBase; h; h = h->pNext) - { - if (h->pClass == pClass && h->iTableIndex == iTableIndex && h->iFuncIndex == iFuncIndex) - return h; - } - - return NULL; -} - -hook_t *MH_FindIATHooked(HMODULE hModule, const char *pszModuleName, const char *pszFuncName) -{ - for (hook_t *h = g_pHookBase; h; h = h->pNext) - { - if (h->hModule == hModule && h->pszModuleName == pszModuleName && h->pszFuncName == pszFuncName) - return h; - } - - return NULL; -} - -#pragma pack(push, 1) - -struct tagIATDATA -{ - void *pAPIInfoAddr; -}; - -struct tagCLASS -{ - DWORD *pVMT; -}; - -struct tagVTABLEDATA -{ - tagCLASS *pInstance; - void *pVFTInfoAddr; -}; - -#pragma pack(pop) - -void MH_FreeHook(hook_t *pHook) -{ - if (pHook->pClass) - { - tagVTABLEDATA *info = (tagVTABLEDATA *)pHook->pInfo; - MH_WriteMemory(info->pVFTInfoAddr, (BYTE *)pHook->pOldFuncAddr, sizeof(DWORD)); - } - else if (pHook->hModule) - { - tagIATDATA *info = (tagIATDATA *)pHook->pInfo; - MH_WriteMemory(info->pAPIInfoAddr, (BYTE *)pHook->pOldFuncAddr, sizeof(DWORD)); - } - else - { - DetourTransactionBegin(); - DetourUpdateThread(GetCurrentThread()); - DetourDetach(&(void *&)pHook->pOldFuncAddr, pHook->pNewFuncAddr); - DetourTransactionCommit(); - } - - if (pHook->pInfo) - delete pHook->pInfo; - - delete pHook; -} - -void MH_FreeAllHook(void) -{ - hook_t *next = nullptr; - - for (hook_t *h = g_pHookBase; h; h = next) - { - next = h->pNext; - MH_FreeHook(h); - } - - g_pHookBase = nullptr; -} - -BOOL MH_UnHook(hook_t *pHook) -{ - if (!g_pHookBase) - return false; - - hook_t *h, **back; - back = &g_pHookBase; - - while (1) - { - h = *back; - - if (!h) - break; - - if (h == pHook) - { - *back = h->pNext; - MH_FreeHook(h); - return true; - } - - back = &h->pNext; - } - - return false; -} - -hook_t *MH_InlineHook(void *pOldFuncAddr, void *pNewFuncAddr, void *&pCallBackFuncAddr) -{ - hook_t *h = MH_NewHook(); - h->pOldFuncAddr = pOldFuncAddr; - h->pNewFuncAddr = pNewFuncAddr; - - DetourTransactionBegin(); - DetourUpdateThread(GetCurrentThread()); - DetourAttach(&(void *&)h->pOldFuncAddr, pNewFuncAddr); - DetourTransactionCommit(); - - pCallBackFuncAddr = h->pOldFuncAddr; - return h; -} - -hook_t *MH_VFTHook(void *pClass, int iTableIndex, int iFuncIndex, void *pNewFuncAddr, void *&pCallBackFuncAddr) -{ - tagVTABLEDATA *info = new tagVTABLEDATA; - info->pInstance = (tagCLASS *)pClass; - - DWORD *pVMT = ((tagCLASS *)pClass + iTableIndex)->pVMT; - info->pVFTInfoAddr = pVMT + iFuncIndex; - - hook_t *h = MH_NewHook(); - h->pOldFuncAddr = (void *)pVMT[iFuncIndex]; - h->pNewFuncAddr = pNewFuncAddr; - h->pInfo = info; - h->pClass = pClass; - h->iTableIndex = iTableIndex; - h->iFuncIndex = iFuncIndex; - - pCallBackFuncAddr = h->pOldFuncAddr; - MH_WriteMemory(info->pVFTInfoAddr, (BYTE *)&pNewFuncAddr, sizeof(DWORD)); - return h; -} - -hook_t *MH_IATHook(HMODULE hModule, const char *pszModuleName, const char *pszFuncName, void *pNewFuncAddr, void *&pCallBackFuncAddr) -{ - IMAGE_NT_HEADERS *pHeader = (IMAGE_NT_HEADERS *)((DWORD)hModule + ((IMAGE_DOS_HEADER *)hModule)->e_lfanew); - IMAGE_IMPORT_DESCRIPTOR *pImport = (IMAGE_IMPORT_DESCRIPTOR *)((DWORD)hModule + pHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress); - - while (pImport->Name && stricmp((const char *)((DWORD)hModule + pImport->Name), pszModuleName)) - pImport++; - - DWORD dwFuncAddr = (DWORD)GetProcAddress(GetModuleHandle(pszModuleName), pszFuncName); - IMAGE_THUNK_DATA *pThunk = (IMAGE_THUNK_DATA *)((DWORD)hModule + pImport->FirstThunk); - - while (pThunk->u1.Function != dwFuncAddr) - pThunk++; - - tagIATDATA *info = new tagIATDATA; - info->pAPIInfoAddr = &pThunk->u1.Function; - - hook_t *h = MH_NewHook(); - h->pOldFuncAddr = (void *)pThunk->u1.Function; - h->pNewFuncAddr = pNewFuncAddr; - h->pInfo = info; - h->hModule = hModule; - h->pszModuleName = pszModuleName; - h->pszFuncName = pszFuncName; - - pCallBackFuncAddr = h->pOldFuncAddr; - MH_WriteMemory(info->pAPIInfoAddr, (BYTE *)&pNewFuncAddr, sizeof(DWORD)); - return h; -} - -void *MH_GetClassFuncAddr(...) -{ - DWORD address; - - __asm - { - lea eax, address - mov edx, [ebp + 8] - mov[eax], edx - } - - return (void *)address; -} - -DWORD MH_GetModuleBase(HMODULE hModule) -{ - MEMORY_BASIC_INFORMATION mem; - - if (!VirtualQuery(hModule, &mem, sizeof(MEMORY_BASIC_INFORMATION))) - return 0; - - return (DWORD)mem.AllocationBase; -} - -DWORD MH_GetModuleSize(HMODULE hModule) -{ - return ((IMAGE_NT_HEADERS *)((DWORD)hModule + ((IMAGE_DOS_HEADER *)hModule)->e_lfanew))->OptionalHeader.SizeOfImage; -} - -HMODULE MH_GetEngineModule(void) -{ - return g_hEngineModule; -} - -DWORD MH_GetEngineBase(void) -{ - return g_dwEngineBase; -} - -DWORD MH_GetEngineSize(void) -{ - return g_dwEngineSize; -} - -void *MH_SearchPattern(void *pStartSearch, DWORD dwSearchLen, char *pPattern, DWORD dwPatternLen) -{ - DWORD dwStartAddr = (DWORD)pStartSearch; - DWORD dwEndAddr = dwStartAddr + dwSearchLen - dwPatternLen; - - while (dwStartAddr < dwEndAddr) - { - bool found = true; - - for (DWORD i = 0; i < dwPatternLen; i++) - { - char code = *(char *)(dwStartAddr + i); - - if (pPattern[i] != 0x2A && pPattern[i] != code) - { - found = false; - break; - } - } - - if (found) - return (void *)dwStartAddr; - - dwStartAddr++; - } - - return 0; -} - -void MH_WriteDWORD(void *pAddress, DWORD dwValue) -{ - DWORD dwProtect; - - if (VirtualProtect((void *)pAddress, 4, PAGE_EXECUTE_READWRITE, &dwProtect)) - { - *(DWORD *)pAddress = dwValue; - VirtualProtect((void *)pAddress, 4, dwProtect, &dwProtect); - } -} - -DWORD MH_ReadDWORD(void *pAddress) -{ - DWORD dwProtect; - DWORD dwValue = 0; - - if (VirtualProtect((void *)pAddress, 4, PAGE_EXECUTE_READWRITE, &dwProtect)) - { - dwValue = *(DWORD *)pAddress; - VirtualProtect((void *)pAddress, 4, dwProtect, &dwProtect); - } - - return dwValue; -} - -void MH_WriteBYTE(void *pAddress, BYTE ucValue) -{ - DWORD dwProtect; - - if (VirtualProtect((void *)pAddress, 1, PAGE_EXECUTE_READWRITE, &dwProtect)) - { - *(BYTE *)pAddress = ucValue; - VirtualProtect((void *)pAddress, 1, dwProtect, &dwProtect); - } -} - -BYTE MH_ReadBYTE(void *pAddress) -{ - DWORD dwProtect; - BYTE ucValue = 0; - - if (VirtualProtect((void *)pAddress, 1, PAGE_EXECUTE_READWRITE, &dwProtect)) - { - ucValue = *(BYTE *)pAddress; - VirtualProtect((void *)pAddress, 1, dwProtect, &dwProtect); - } - - return ucValue; -} - -void MH_WriteNOP(void *pAddress, DWORD dwCount) -{ - static DWORD dwProtect; - - if (VirtualProtect(pAddress, dwCount, PAGE_EXECUTE_READWRITE, &dwProtect)) - { - for (DWORD i = 0; i < dwCount; i++) - *(BYTE *)((DWORD)pAddress + i) = 0x90; - - VirtualProtect(pAddress, dwCount, dwProtect, &dwProtect); - } -} - -DWORD MH_WriteMemory(void *pAddress, BYTE *pData, DWORD dwDataSize) -{ - static DWORD dwProtect; - - if (VirtualProtect(pAddress, dwDataSize, PAGE_EXECUTE_READWRITE, &dwProtect)) - { - memcpy(pAddress, pData, dwDataSize); - VirtualProtect(pAddress, dwDataSize, dwProtect, &dwProtect); - } - - return dwDataSize; -} - -DWORD MH_ReadMemory(void *pAddress, BYTE *pData, DWORD dwDataSize) -{ - static DWORD dwProtect; - - if (VirtualProtect(pAddress, dwDataSize, PAGE_EXECUTE_READWRITE, &dwProtect)) - { - memcpy(pData, pAddress, dwDataSize); - VirtualProtect(pAddress, dwDataSize, dwProtect, &dwProtect); - } - - return dwDataSize; -} - -DWORD MH_GetVideoMode(int *width, int *height, int *bpp, bool *windowed) -{ - static int iSaveMode; - static int iSaveWidth, iSaveHeight, iSaveBPP; - static bool bSaveWindowed; - - if (g_bSaveVideo) - { - if (width) - *width = iSaveWidth; - - if (height) - *height = iSaveHeight; - - if (bpp) - *bpp = iSaveBPP; - - if (windowed) - *windowed = bSaveWindowed; - } - else - { - const char *pszValues = registry->ReadString("EngineDLL", "hw.dll"); - int iEngineD3D = registry->ReadInt("EngineD3D"); - - if (!strcmp(pszValues, "hw.dll")) - { - if (CommandLine()->CheckParm("-d3d") || (!CommandLine()->CheckParm("-gl") && iEngineD3D)) - iSaveMode = VIDEOMODE_D3D; - else - iSaveMode = VIDEOMODE_OPENGL; - } - else - { - iSaveMode = VIDEOMODE_SOFTWARE; - } - - bSaveWindowed = registry->ReadInt("ScreenWindowed") != false; - - if (CommandLine()->CheckParm("-sw") || CommandLine()->CheckParm("-startwindowed") || CommandLine()->CheckParm("-windowed") || CommandLine()->CheckParm("-window")) - bSaveWindowed = true; - else if (CommandLine()->CheckParm("-full") || CommandLine()->CheckParm("-fullscreen")) - bSaveWindowed = false; - - iSaveWidth = registry->ReadInt("ScreenWidth", 640); - - if (CommandLine()->CheckParm("-width", &pszValues)) - iSaveWidth = atoi(pszValues); - - if (CommandLine()->CheckParm("-w", &pszValues)) - iSaveWidth = atoi(pszValues); - - iSaveHeight = registry->ReadInt("ScreenHeight", 480); - - if (CommandLine()->CheckParm("-height", &pszValues)) - iSaveHeight = atoi(pszValues); - - if (CommandLine()->CheckParm("-h", &pszValues)) - iSaveHeight = atoi(pszValues); - - iSaveBPP = registry->ReadInt("ScreenBPP", 32); - - if (CommandLine()->CheckParm("-16bpp")) - iSaveBPP = 16; - else if (CommandLine()->CheckParm("-24bpp")) - iSaveBPP = 24; - else if (CommandLine()->CheckParm("-32bpp")) - iSaveBPP = 32; - - if (width) - *width = iSaveWidth; - - if (height) - *height = iSaveHeight; - - if (bpp) - *bpp = iSaveBPP; - - if (windowed) - *windowed = bSaveWindowed; - - g_bSaveVideo = true; - } - - return iSaveMode; -} - -CreateInterfaceFn MH_GetEngineFactory(void) -{ - if (!g_bEngineIsBlob) - return (CreateInterfaceFn)GetProcAddress(g_hEngineModule, "CreateInterface"); - - static DWORD factoryAddr = 0; - - if (!factoryAddr) - { - BlobHeader_t *pHeader = GetBlobHeader(); - DWORD base = pHeader->m_dwExportPoint + 0x8; - factoryAddr = ((DWORD(*)(void))(base + *(DWORD *)base + 0x4))(); - } - - return (CreateInterfaceFn)factoryAddr; -} - -DWORD MH_GetNextCallAddr(void *pAddress, DWORD dwCount) -{ - static BYTE *pbAddress = NULL; - - if (pAddress) - pbAddress = (BYTE *)pAddress; - else - pbAddress = pbAddress + 5; - - for (DWORD i = 0; i < dwCount; i++) - { - BYTE code = *(BYTE *)pbAddress; - - if (code == 0xFF && *(BYTE *)(pbAddress + 1) == 0x15) - { - return *(DWORD *)(pbAddress + 2); - } - - if (code == 0xE8) - { - return (DWORD)(*(DWORD *)(pbAddress + 1) + pbAddress + 5); - } - - pbAddress++; - } - - return 0; -} - -DWORD MH_GetEngineVersion(void) -{ - if (!g_pfnbuild_number) - return 0; - - return g_pfnbuild_number(); -} - -metahook_api_t gMetaHookAPI = -{ - MH_UnHook, - MH_InlineHook, - MH_VFTHook, - MH_IATHook, - MH_GetClassFuncAddr, - MH_GetModuleBase, - MH_GetModuleSize, - MH_GetEngineModule, - MH_GetEngineBase, - MH_GetEngineSize, - MH_SearchPattern, - MH_WriteDWORD, - MH_ReadDWORD, - MH_WriteMemory, - MH_ReadMemory, - MH_GetVideoMode, - MH_GetEngineVersion, - MH_GetEngineFactory, - MH_GetNextCallAddr, - MH_WriteBYTE, - MH_ReadBYTE, - MH_WriteNOP, -}; \ No newline at end of file diff --git a/metahook.h b/metahook.h deleted file mode 100644 index 566e99b..0000000 --- a/metahook.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef _METAHOOK_H -#define _METAHOOK_H - -#include -#include -#include -#include - -typedef float vec_t; -typedef float vec2_t[2]; -typedef float vec3_t[3]; - -#include -#include - -typedef int(*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf); - -#include -#include - -typedef struct hook_s hook_t; - -#define VIDEOMODE_SOFTWARE 0 -#define VIDEOMODE_OPENGL 1 -#define VIDEOMODE_D3D 2 - -typedef struct metahook_api_s -{ - BOOL(*UnHook)(hook_t *pHook); - hook_t *(*InlineHook)(void *pOldFuncAddr, void *pNewFuncAddr, void *&pCallBackFuncAddr); - hook_t *(*VFTHook)(void *pClass, int iTableIndex, int iFuncIndex, void *pNewFuncAddr, void *&pCallBackFuncAddr); - hook_t *(*IATHook)(HMODULE hModule, const char *pszModuleName, const char *pszFuncName, void *pNewFuncAddr, void *&pCallBackFuncAddr); - void *(*GetClassFuncAddr)(...); - DWORD(*GetModuleBase)(HMODULE hModule); - DWORD(*GetModuleSize)(HMODULE hModule); - HMODULE(*GetEngineModule)(void); - DWORD(*GetEngineBase)(void); - DWORD(*GetEngineSize)(void); - void *(*SearchPattern)(void *pStartSearch, DWORD dwSearchLen, char *pPattern, DWORD dwPatternLen); - void(*WriteDWORD)(void *pAddress, DWORD dwValue); - DWORD(*ReadDWORD)(void *pAddress); - DWORD(*WriteMemory)(void *pAddress, BYTE *pData, DWORD dwDataSize); - DWORD(*ReadMemory)(void *pAddress, BYTE *pData, DWORD dwDataSize); - DWORD(*GetVideoMode)(int *width, int *height, int *bpp, bool *windowed); - DWORD(*GetEngineBuildnum)(void); - CreateInterfaceFn(*GetEngineFactory)(void); - DWORD(*GetNextCallAddr)(void *pAddress, DWORD dwCount); - void(*WriteBYTE)(void *pAddress, BYTE ucValue); - BYTE(*ReadBYTE)(void *pAddress); - void(*WriteNOP)(void *pAddress, DWORD dwCount); -} -metahook_api_t; - -typedef struct mh_enginesave_s -{ - cl_exportfuncs_t *pExportFuncs; - cl_enginefunc_t *pEngineFuncs; -} -mh_enginesave_t; - -void MH_FreeAllHook(void); -void MH_Init(const char *pszGameName); -void MH_LoadClient(cl_exportfuncs_t *pExportFuncs, cl_exportfuncs_t *pCallExportFuncs); -void MH_LoadEngine(HMODULE hModule); -void MH_ExitGame(int iResult); -void MH_Shutdown(void); - -#include -#include -#include - -typedef struct mh_interface_s -{ - ICommandLine *CommandLine; - IFileSystem *FileSystem; - IRegistry *Registry; -} -mh_interface_t; - -#include - -extern mh_interface_t *g_pInterface; -extern cl_enginefunc_t gEngfuncs; -extern metahook_api_t *g_pMetaHookAPI; -extern mh_enginesave_t *g_pMetaSave; - -#endif \ No newline at end of file diff --git a/registry.cpp b/registry.cpp deleted file mode 100644 index 7e04ab5..0000000 --- a/registry.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#include -#include "IRegistry.h" - -class CRegistry : public IRegistry -{ -public: - CRegistry(void); - virtual ~CRegistry(void); - -public: - void Init(void); - void Shutdown(void); - int ReadInt(const char *key, int defaultValue = 0); - void WriteInt(const char *key, int value); - const char *ReadString(const char *key, const char *defaultValue = NULL); - void WriteString(const char *key, const char *value); - -private: - bool m_bValid; - HKEY m_hKey; -}; - -static CRegistry g_Registry; -IRegistry *registry = (IRegistry *)&g_Registry; - -CRegistry::CRegistry(void) -{ - m_bValid = false; - m_hKey = 0; -} - -CRegistry::~CRegistry(void) -{ -} - -int CRegistry::ReadInt(const char *key, int defaultValue) -{ - LONG lResult; - DWORD dwType; - DWORD dwSize; - - int value; - - if (!m_bValid) - return defaultValue; - - dwSize = sizeof(DWORD); - lResult = RegQueryValueEx(m_hKey, key, 0, &dwType, (LPBYTE)&value, &dwSize); - - if (lResult != ERROR_SUCCESS) - return defaultValue; - - if (dwType != REG_DWORD) - return defaultValue; - - return value; -} - -void CRegistry::WriteInt(const char *key, int value) -{ - DWORD dwSize; - - if (!m_bValid) - return; - - dwSize = sizeof(DWORD); - RegSetValueEx(m_hKey, key, 0, REG_DWORD, (LPBYTE)&value, dwSize); -} - -const char *CRegistry::ReadString(const char *key, const char *defaultValue) -{ - LONG lResult; - DWORD dwType; - DWORD dwSize = 512; - - static char value[512]; - value[0] = 0; - - if (!m_bValid) - return defaultValue; - - lResult = RegQueryValueEx(m_hKey, key, 0, &dwType, (unsigned char *)value, &dwSize); - - if (lResult != ERROR_SUCCESS) - return defaultValue; - - if (dwType != REG_SZ) - return defaultValue; - - return value; -} - -void CRegistry::WriteString(const char *key, const char *value) -{ - DWORD dwSize; - - if (!m_bValid) - return; - - dwSize = (DWORD)(strlen(value) + 1); - RegSetValueEx(m_hKey, key, 0, REG_SZ, (LPBYTE)value, dwSize); -} - -static char *GetPlatformName(void) -{ - return "Half-Life"; -} - -void CRegistry::Init(void) -{ - LONG lResult; - DWORD dwDisposition; - - char szModelKey[1024]; - wsprintf(szModelKey, "Software\\Valve\\%s\\Settings\\", GetPlatformName()); - lResult = RegCreateKeyEx(HKEY_CURRENT_USER, szModelKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &m_hKey, &dwDisposition); - - if (lResult != ERROR_SUCCESS) - { - m_bValid = false; - return; - } - - m_bValid = true; -} - -void CRegistry::Shutdown(void) -{ - if (!m_bValid) - return; - - m_bValid = false; - RegCloseKey(m_hKey); -} \ No newline at end of file diff --git a/Plugins/Audio/exportfuncs.cpp b/src/exportfuncs.cpp similarity index 100% rename from Plugins/Audio/exportfuncs.cpp rename to src/exportfuncs.cpp diff --git a/common/interface.cpp b/src/interface.cpp similarity index 100% rename from common/interface.cpp rename to src/interface.cpp diff --git a/Plugins/Audio/plugins.cpp b/src/plugins.cpp similarity index 100% rename from Plugins/Audio/plugins.cpp rename to src/plugins.cpp diff --git a/Plugins/Audio/snd_dma.cpp b/src/snd_dma.cpp similarity index 99% rename from Plugins/Audio/snd_dma.cpp rename to src/snd_dma.cpp index e3e48c1..f166fd9 100644 --- a/Plugins/Audio/snd_dma.cpp +++ b/src/snd_dma.cpp @@ -968,19 +968,11 @@ qboolean OpenAL_Init(void) if (!al_device) { -#ifdef _DEBUG - al_device = al_dev_manager.openPlayback(""); -#else auto default_device = al_dev_manager.defaultDeviceName(alure::DefaultDeviceType::Full); al_device = al_dev_manager.openPlayback(default_device); -#endif } -#ifndef _DEBUG strncpy_s(al_device_name, al_device.getName().c_str(), sizeof(al_device_name)); -#else - strncpy_s(al_device_name, "Unable to get name in debug mode.", sizeof(al_device_name)); -#endif al_context = al_device.createContext(); @@ -1054,7 +1046,6 @@ void AL_ResetEFX(void) void AL_Devices_f(bool basic = true) { -#ifndef _DEBUG alure::Vector devices; if (basic) { @@ -1069,7 +1060,6 @@ void AL_Devices_f(bool basic = true) { gEngfuncs.Con_Printf(" %s\n", device.c_str()); } -#endif } void AL_DevicesBasic_f(void) diff --git a/Plugins/Audio/snd_fx.cpp b/src/snd_fx.cpp similarity index 100% rename from Plugins/Audio/snd_fx.cpp rename to src/snd_fx.cpp diff --git a/Plugins/Audio/snd_hook.cpp b/src/snd_hook.cpp similarity index 100% rename from Plugins/Audio/snd_hook.cpp rename to src/snd_hook.cpp diff --git a/Plugins/Audio/snd_loader.cpp b/src/snd_loader.cpp similarity index 99% rename from Plugins/Audio/snd_loader.cpp rename to src/snd_loader.cpp index 3559a74..ef279c0 100644 --- a/Plugins/Audio/snd_loader.cpp +++ b/src/snd_loader.cpp @@ -1,7 +1,7 @@ #include #include "FileSystem.h" -#include "alure/AL/alure2.h" +#include "alure2.h" #include "snd_loader.h" // Based on Alure's Stream class diff --git a/Plugins/Audio/snd_mem.cpp b/src/snd_mem.cpp similarity index 100% rename from Plugins/Audio/snd_mem.cpp rename to src/snd_mem.cpp diff --git a/Plugins/Audio/snd_voice.cpp b/src/snd_voice.cpp similarity index 100% rename from Plugins/Audio/snd_voice.cpp rename to src/snd_voice.cpp diff --git a/Plugins/Audio/snd_vox.cpp b/src/snd_vox.cpp similarity index 100% rename from Plugins/Audio/snd_vox.cpp rename to src/snd_vox.cpp diff --git a/Plugins/Audio/snd_wav.cpp b/src/snd_wav.cpp similarity index 100% rename from Plugins/Audio/snd_wav.cpp rename to src/snd_wav.cpp diff --git a/Plugins/Audio/zone.cpp b/src/zone.cpp similarity index 100% rename from Plugins/Audio/zone.cpp rename to src/zone.cpp diff --git a/sys.h b/sys.h deleted file mode 100644 index f624a12..0000000 --- a/sys.h +++ /dev/null @@ -1,3 +0,0 @@ -BOOL Sys_CloseDEP(void); -BOOL Sys_GetExecutableName(char *pszName, int nSize); -char *Sys_GetLongPathName(void); \ No newline at end of file diff --git a/sys_launcher.cpp b/sys_launcher.cpp deleted file mode 100644 index d276278..0000000 --- a/sys_launcher.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include - -typedef LONG NTSTATUS; -typedef NTSTATUS *PNTSTATUS; - -#define STATUS_SUCCESS ((NTSTATUS)0x00000000) - -#define MEM_EXECUTE_OPTION_DISABLE 0x1 -#define MEM_EXECUTE_OPTION_ENABLE 0x2 -#define MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION 0x4 -#define MEM_EXECUTE_OPTION_PERMANENT 0x8 -#define MEM_EXECUTE_OPTION_EXECUTE_DISPATCH_ENABLE 0x10 -#define MEM_EXECUTE_OPTION_IMAGE_DISPATCH_ENABLE 0x20 -#define MEM_EXECUTE_OPTION_VALID_FLAGS 0x3f - -typedef enum _PROCESSINFOCLASS -{ - ProcessBasicInformation, - ProcessQuotaLimits, - ProcessIoCounters, - ProcessVmCounters, - ProcessTimes, - ProcessBasePriority, - ProcessRaisePriority, - ProcessDebugPort, - ProcessExceptionPort, - ProcessAccessToken, - ProcessLdtInformation, - ProcessLdtSize, - ProcessDefaultHardErrorMode, - ProcessIoPortHandlers, - ProcessPooledUsageAndLimits, - ProcessWorkingSetWatch, - ProcessUserModeIOPL, - ProcessEnableAlignmentFaultFixup, - ProcessPriorityClass, - ProcessWx86Information, - ProcessHandleCount, - ProcessAffinityMask, - ProcessPriorityBoost, - ProcessDeviceMap, - ProcessSessionInformation, - ProcessForegroundInformation, - ProcessWow64Information, - ProcessImageFileName, - ProcessLUIDDeviceMapsEnabled, - ProcessBreakOnTermination, - ProcessDebugObjectHandle, - ProcessDebugFlags, - ProcessHandleTracing, - ProcessIoPriority, - ProcessExecuteFlags, - ProcessResourceManagement, - ProcessCookie, - ProcessImageInformation, - MaxProcessInfoClass -} -PROCESSINFOCLASS; - -BOOL Sys_CloseDEP(void) -{ - static NTSTATUS(WINAPI *pfnNtSetInformationProcess)(HANDLE ProcessHandle, PROCESSINFOCLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength) = (NTSTATUS(WINAPI *)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG))GetProcAddress(GetModuleHandle("ntdll.dll"), "NtSetInformationProcess"); - ULONG ExecuteFlags = MEM_EXECUTE_OPTION_ENABLE; - - return (pfnNtSetInformationProcess(GetCurrentProcess(), ProcessExecuteFlags, &ExecuteFlags, sizeof(ExecuteFlags)) == 0); -} - -BOOL Sys_GetExecutableName(char *pszName, int nSize) -{ - return GetModuleFileName(GetModuleHandle(NULL), pszName, nSize) != 0; -} - -char *Sys_GetLongPathName(void) -{ - char szShortPath[MAX_PATH]; - static char szLongPath[MAX_PATH]; - char *pszPath; - - szShortPath[0] = 0; - szLongPath[0] = 0; - - if (GetModuleFileName(NULL, szShortPath, sizeof(szShortPath))) - { - GetLongPathName(szShortPath, szLongPath, sizeof(szLongPath)); - pszPath = strrchr(szLongPath, '\\'); - - if (pszPath[0]) - pszPath[1] = 0; - - size_t len = strlen(szLongPath); - - if (len > 0) - { - if (szLongPath[len - 1] == '\\' || szLongPath[len - 1] == '/') - szLongPath[len - 1] = 0; - } - } - - return szLongPath; -} \ No newline at end of file