Initial re-upload of spice2x-24-08-24
This commit is contained in:
16
stubs/nvEncodeAPI64.cpp
Normal file
16
stubs/nvEncodeAPI64.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <cstdint>
|
||||
|
||||
#define EXPORT __declspec(dllexport)
|
||||
#define IMPORT
|
||||
|
||||
typedef uint32_t NVENCSTATUS;
|
||||
#define NV_ENC_SUCCESS 0
|
||||
#define NV_ENC_ERR_INVALID_PTR 6
|
||||
|
||||
extern "C" NVENCSTATUS EXPORT __cdecl NvEncodeAPIGetMaxSupportedVersion(uint32_t* version) {
|
||||
return NV_ENC_ERR_INVALID_PTR;
|
||||
}
|
||||
|
||||
extern "C" NVENCSTATUS EXPORT __cdecl NvEncodeAPICreateInstance(void *functionList) {
|
||||
return NV_ENC_ERR_INVALID_PTR;
|
||||
}
|
||||
3
stubs/nvEncodeAPI64.def
Normal file
3
stubs/nvEncodeAPI64.def
Normal file
@@ -0,0 +1,3 @@
|
||||
EXPORTS
|
||||
NvEncodeAPIGetMaxSupportedVersion
|
||||
NvEncodeAPICreateInstance
|
||||
88
stubs/nvcuda.cpp
Normal file
88
stubs/nvcuda.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
#include <cstdint>
|
||||
|
||||
#define EXPORT __declspec(dllexport)
|
||||
#define IMPORT
|
||||
|
||||
// https://docs.nvidia.com/cuda/cuda-driver-api/index.html
|
||||
|
||||
#define CUDA_ERROR_NOT_SUPPORTED 801
|
||||
|
||||
typedef void *CUcontext;
|
||||
typedef void *CUdevice;
|
||||
typedef void *CUgraphicsResource;
|
||||
typedef void *CUstream;
|
||||
typedef void *CUdeviceptr;
|
||||
typedef void *CUarray;
|
||||
typedef void *CUDA_MEMCPY2D;
|
||||
typedef void *IDirect3DResource9;
|
||||
typedef uint32_t CUresult;
|
||||
|
||||
extern "C" CUresult EXPORT __cdecl cuCtxPushCurrent_v2(CUcontext ctx) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuDeviceGet(char *pciBusId, int len, CUdevice dev) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuInit(unsigned int Flags) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuGraphicsMapResources(
|
||||
unsigned int count, CUgraphicsResource *resources, CUstream hStream) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuMemAlloc_v2(CUdeviceptr *dptr, size_t bytesize) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuCtxPopCurrent_v2(CUcontext *pctx) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuGetErrorName(CUresult error, const char **pStr) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuCtxCreate_v2(CUcontext *pctx, unsigned int flags, CUdevice dev) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuCtxDestroy_v2(CUcontext ctx) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuGraphicsResourceSetMapFlags_v2(
|
||||
CUgraphicsResource resource, unsigned int flags) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuGraphicsUnregisterResource(CUgraphicsResource resource) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuMemAllocPitch_v2(
|
||||
CUdeviceptr *dptr, size_t *pPitch, size_t WidthInBytes, size_t Height, unsigned int ElementSizeBytes) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuGraphicsUnmapResources(
|
||||
unsigned int count, CUgraphicsResource *resources, CUstream hStream) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuStreamSynchronize(CUstream hStream) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuMemcpy2DAsync_v2(const CUDA_MEMCPY2D *pCopy, CUstream hStream) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuGraphicsSubResourceGetMappedArray(
|
||||
CUarray *pArray, CUgraphicsResource resource, unsigned int arrayIndex, unsigned int mipLevel) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuMemFree_v2(CUdeviceptr dptr) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuMemcpy2D_v2(const CUDA_MEMCPY2D *pCopy) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuGraphicsD3D9RegisterResource(
|
||||
CUgraphicsResource *pCudaResource, IDirect3DResource9 *pD3DResource, unsigned int Flags) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuStreamCreate(CUstream *phStream, unsigned int Flags) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
extern "C" CUresult EXPORT __cdecl cuStreamDestroy_v2(CUstream hStream){
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
22
stubs/nvcuda.def
Normal file
22
stubs/nvcuda.def
Normal file
@@ -0,0 +1,22 @@
|
||||
EXPORTS
|
||||
cuCtxPushCurrent_v2
|
||||
cuDeviceGet
|
||||
cuInit
|
||||
cuGraphicsMapResources
|
||||
cuMemAlloc_v2
|
||||
cuCtxPopCurrent_v2
|
||||
cuGetErrorName
|
||||
cuCtxCreate_v2
|
||||
cuCtxDestroy_v2
|
||||
cuGraphicsResourceSetMapFlags_v2
|
||||
cuGraphicsUnregisterResource
|
||||
cuMemAllocPitch_v2
|
||||
cuGraphicsUnmapResources
|
||||
cuStreamSynchronize
|
||||
cuMemcpy2DAsync_v2
|
||||
cuGraphicsSubResourceGetMappedArray
|
||||
cuMemFree_v2
|
||||
cuMemcpy2D_v2
|
||||
cuGraphicsD3D9RegisterResource
|
||||
cuStreamCreate
|
||||
cuStreamDestroy_v2
|
||||
75
stubs/nvcuvid.cpp
Normal file
75
stubs/nvcuvid.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
#include <cstdint>
|
||||
|
||||
#define EXPORT __declspec(dllexport)
|
||||
#define IMPORT
|
||||
|
||||
typedef void *CUVIDDECODECAPS;
|
||||
typedef void *CUVIDGETDECODESTATUS;
|
||||
typedef void *CUVIDRECONFIGUREDECODERINFO;
|
||||
typedef void *CUVIDPROCPARAMS;
|
||||
typedef void *CUVIDSOURCEDATAPACKET;
|
||||
typedef void *CUcontext;
|
||||
typedef void *CUvideodecoder;
|
||||
typedef void *CUvideoparser;
|
||||
typedef void *CUVIDDECODECREATEINFO;
|
||||
typedef void *CUVIDPARSERPARAMS;
|
||||
typedef void *CUVIDPICPARAMS;
|
||||
typedef void *CUvideoctxlock;
|
||||
|
||||
#define CUDA_ERROR_NOT_SUPPORTED 801
|
||||
|
||||
// https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1gc6c391505e117393cc2558fff6bfc2e9
|
||||
typedef uint32_t CUresult;
|
||||
|
||||
extern "C" CUresult EXPORT __cdecl cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
extern "C" CUresult EXPORT __cdecl cuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
extern "C" CUresult EXPORT __cdecl cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
extern "C" CUresult EXPORT __cdecl cuvidCtxLockDestroy(CUvideoctxlock lck) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
extern "C" CUresult EXPORT __cdecl cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
extern "C" CUresult EXPORT __cdecl cuvidDestroyDecoder(CUvideodecoder hDecoder) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
extern "C" CUresult EXPORT __cdecl cuvidDestroyVideoParser(CUvideoparser obj) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
extern "C" CUresult EXPORT __cdecl cuvidGetDecodeStatus(CUvideodecoder hDecoder, int nPicIdx, CUVIDGETDECODESTATUS* pDecodeStatus) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
extern "C" CUresult EXPORT __cdecl cuvidGetDecoderCaps(CUVIDDECODECAPS *pdc) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
extern "C" CUresult EXPORT __cdecl cuvidMapVideoFrame64(
|
||||
CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS *pVPP) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
extern "C" CUresult EXPORT __cdecl cuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
extern "C" CUresult EXPORT __cdecl cuvidReconfigureDecoder(CUvideodecoder hDecoder, CUVIDRECONFIGUREDECODERINFO *pDecReconfigParams) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
extern "C" CUresult EXPORT __cdecl cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr) {
|
||||
return CUDA_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
14
stubs/nvcuvid.def
Normal file
14
stubs/nvcuvid.def
Normal file
@@ -0,0 +1,14 @@
|
||||
EXPORTS
|
||||
cuvidCreateDecoder
|
||||
cuvidCreateVideoParser
|
||||
cuvidCtxLockCreate
|
||||
cuvidCtxLockDestroy
|
||||
cuvidDecodePicture
|
||||
cuvidDestroyDecoder
|
||||
cuvidDestroyVideoParser
|
||||
cuvidGetDecodeStatus
|
||||
cuvidGetDecoderCaps
|
||||
cuvidMapVideoFrame64
|
||||
cuvidParseVideoData
|
||||
cuvidReconfigureDecoder
|
||||
cuvidUnmapVideoFrame64
|
||||
120
stubs/stubs.cpp
Normal file
120
stubs/stubs.cpp
Normal file
@@ -0,0 +1,120 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include "hooks/libraryhook.h"
|
||||
#include "util/logging.h"
|
||||
|
||||
#ifndef STUB
|
||||
#include <mutex>
|
||||
|
||||
#include "avs/game.h"
|
||||
#include "launcher/signal.h"
|
||||
#endif
|
||||
|
||||
#include "stubs.h"
|
||||
|
||||
|
||||
/*
|
||||
* export/import macros
|
||||
*/
|
||||
|
||||
#if defined(STUB)
|
||||
#define EXPORT __declspec(dllexport)
|
||||
#define IMPORT
|
||||
#else
|
||||
// needs to be __cdecl if we hook stuff at runtime
|
||||
#define EXPORT
|
||||
#define IMPORT
|
||||
#endif
|
||||
|
||||
/*
|
||||
* implementations
|
||||
*/
|
||||
|
||||
extern "C" int EXPORT __cdecl bt_fcheck_finish() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int EXPORT __cdecl bt_fcheck_init(bool spawn_thread, bool quick_check) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int EXPORT __cdecl bt_fcheck_main(void *a1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int EXPORT __cdecl bt_get_ikey_status(stubs::ikey_status* status) {
|
||||
#ifndef STUB
|
||||
static std::once_flag printed;
|
||||
std::call_once(printed, []() {
|
||||
log_info("kbt", "bt_get_ikey_status");
|
||||
});
|
||||
#endif
|
||||
|
||||
memset(status, 0, 32);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
status[i].v2 = 1;
|
||||
status[i].v4 = 1;
|
||||
status[i].v7 = ~0u;
|
||||
|
||||
#ifndef STUB
|
||||
// JMA is weird in that it expects this to be equal *exactly* to one
|
||||
if (avs::game::is_model("JMA")) {
|
||||
status[i].v7 = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef STUB
|
||||
// JMA is weird in that it will keep cycling backup data initialization if this field is not 0
|
||||
if (avs::game::is_model("JMA")) {
|
||||
status[1].v2 = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int EXPORT __cdecl k_bt0001(stubs::ikey_status* status) {
|
||||
return bt_get_ikey_status(status);
|
||||
}
|
||||
|
||||
extern "C" void EXPORT __cdecl k_bt0002(void (__cdecl *func)(void *), void *arg) {
|
||||
if (func != nullptr) {
|
||||
func(arg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* DLL entry function
|
||||
* for standalone stubs
|
||||
*/
|
||||
#ifdef STUB
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
|
||||
DisableThreadLibraryCalls(hinstDLL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dynamic hooks for use without kbt/kld DLL stubs
|
||||
* Should be called after all game DLLs are loaded in memory.
|
||||
* This works because most (all?) games use GetModuleHandle for those two.
|
||||
*/
|
||||
#ifndef STUB
|
||||
void stubs::attach() {
|
||||
log_info("stubs", "attaching...");
|
||||
|
||||
libraryhook_hook_library("kbt.dll", GetModuleHandle(NULL));
|
||||
libraryhook_hook_library("kld.dll", GetModuleHandle(NULL));
|
||||
libraryhook_hook_proc("bt_fcheck_finish", bt_fcheck_finish);
|
||||
libraryhook_hook_proc("bt_fcheck_init", bt_fcheck_init);
|
||||
libraryhook_hook_proc("bt_fcheck_main", bt_fcheck_main);
|
||||
libraryhook_hook_proc("bt_get_ikey_status", bt_get_ikey_status);
|
||||
libraryhook_hook_proc("k_bt0001", k_bt0001);
|
||||
libraryhook_hook_proc("k_bt0002", k_bt0002);
|
||||
libraryhook_enable();
|
||||
|
||||
log_info("stubs", "attached");
|
||||
}
|
||||
#endif
|
||||
9
stubs/stubs.def
Normal file
9
stubs/stubs.def
Normal file
@@ -0,0 +1,9 @@
|
||||
LIBRARY "stub.dll" BASE=0x10000000
|
||||
|
||||
EXPORTS
|
||||
bt_fcheck_finish @1
|
||||
bt_fcheck_init @2
|
||||
bt_fcheck_main @3
|
||||
bt_get_ikey_status @4
|
||||
k_bt0001 @5
|
||||
k_bt0002 @6
|
||||
18
stubs/stubs.h
Normal file
18
stubs/stubs.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace stubs {
|
||||
|
||||
struct ikey_status {
|
||||
uint32_t v1;
|
||||
uint8_t v2;
|
||||
uint8_t v3;
|
||||
uint8_t v4;
|
||||
uint8_t v5;
|
||||
uint32_t v6;
|
||||
uint32_t v7;
|
||||
};
|
||||
|
||||
void attach();
|
||||
}
|
||||
Reference in New Issue
Block a user