Hook libamv
This commit is contained in:
parent
800b6f28e1
commit
b88e279b32
62
src/micetools/dll/amvStub/amv.c
Normal file
62
src/micetools/dll/amvStub/amv.c
Normal file
@ -0,0 +1,62 @@
|
||||
#include <Windows.h>
|
||||
|
||||
DWORD NvidiaDebugLevel = 0;
|
||||
|
||||
__declspec(dllexport) int amvFinalize_Nvidia() { return 0; }
|
||||
__declspec(dllexport) int amvGetAvailableDriverEx_Nvidia(LPVOID pGpuHandle, DWORD dwGpuHandleSize) {
|
||||
return 0;
|
||||
}
|
||||
__declspec(dllexport) int amvGetAvailableDriver_Nvidia() {
|
||||
return amvGetAvailableDriverEx_Nvidia(NULL, 4);
|
||||
}
|
||||
__declspec(dllexport) int amvGetConnectedDisplaysEx_Nvidia(LPVOID pGpuHandle, DWORD dwGpuHandleSize,
|
||||
LPBYTE displayType) {
|
||||
// TODO: Find a use of this to figure out what we should spoof!
|
||||
if (displayType) *displayType = 0;
|
||||
return 0;
|
||||
}
|
||||
__declspec(dllexport) int amvGetConnectedDisplays_Nvidia(LPBYTE displayType) {
|
||||
return amvGetConnectedDisplays_Nvidia(NULL, 4, displayType);
|
||||
}
|
||||
__declspec(dllexport) int amvGetCurrentPstateEx_Nvidia(LPVOID pGpuHandle, DWORD dwGpuHandleSize,
|
||||
DWORD* pPstate) {
|
||||
// TODO: Find a use of this to figure out what we should spoof!
|
||||
if (pPstate) *pPstate = 0;
|
||||
return 0;
|
||||
}
|
||||
__declspec(dllexport) int amvGetCurrentPstate_Nvidia(DWORD* pPstate) {
|
||||
return amvGetCurrentPstateEx_Nvidia(NULL, 4, pPstate);
|
||||
}
|
||||
__declspec(dllexport) int amvGetamvNvidiaDebugLevel() { return NvidiaDebugLevel; }
|
||||
__declspec(dllexport) char* amvGetamvNvidiaVersion() {
|
||||
return "\namv_nvidia Ver.1.05 Build:Jul 22 2011 13:53:26\n";
|
||||
}
|
||||
__declspec(dllexport) int amvInitialize_Nvidia(LPVOID pGpuHandle, DWORD dwGpuHandleSize) {
|
||||
return 0;
|
||||
}
|
||||
__declspec(dllexport) int amvSetCustomDisplaySetting2ndEx_Nvidia(
|
||||
LPVOID pGpuHandle, DWORD dwGpuHandleSize, LPWORD NV_SetCustomDisplaySetting) {
|
||||
return 0;
|
||||
}
|
||||
__declspec(dllexport) int amvSetCustomDisplaySetting2nd_Nvidia(LPVOID pGpuHandle) {
|
||||
return amvSetCustomDisplaySetting2ndEx_Nvidia(NULL, 4, pGpuHandle);
|
||||
}
|
||||
__declspec(dllexport) int amvSetCustomDisplaySettingEx_Nvidia(LPVOID pGpuHandle,
|
||||
DWORD dwGpuHandleSize,
|
||||
LPWORD NV_SetCustomDisplaySetting) {
|
||||
return 0;
|
||||
}
|
||||
__declspec(dllexport) int amvSetCustomDisplaySetting_Nvidia(LPVOID pGpuHandle) {
|
||||
return amvSetCustomDisplaySettingEx_Nvidia(NULL, 4, pGpuHandle);
|
||||
}
|
||||
__declspec(dllexport) int amvSetDisplayModeEx_Nvidia(LPVOID pGpuHandle, DWORD dwGpuHandleSize,
|
||||
BYTE displayMode) {
|
||||
return 0;
|
||||
}
|
||||
__declspec(dllexport) int amvSetDisplayMode_Nvidia(BYTE displayMode) {
|
||||
return amvSetDisplayModeEx_Nvidia(NULL, 4, displayMode);
|
||||
}
|
||||
__declspec(dllexport) int amvSetamvNvidiaDebugLevel(DWORD debugLevel) {
|
||||
NvidiaDebugLevel = debugLevel;
|
||||
return NvidiaDebugLevel;
|
||||
}
|
@ -64,6 +64,22 @@ LONG WINAPI FakeRtlGetVersion(PRTL_OSVERSIONINFOW lpVersionInformation) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO: We should probably handle libamv_amd.dll at some point too
|
||||
HMODULE WINAPI FakeLoadLibraryA(LPCSTR lpLibFileName) {
|
||||
if (strcmp(lpLibFileName, "libamv_nvidia.dll") == 0) {
|
||||
return TrueLoadLibraryA(MICELIB);
|
||||
}
|
||||
return TrueLoadLibraryA(lpLibFileName);
|
||||
}
|
||||
#define WIDEN2(x) L ## x
|
||||
#define WIDEN(x) WIDEN2(x)
|
||||
HMODULE WINAPI FakeLoadLibraryW(LPCWSTR lpLibFileName) {
|
||||
if (wcscmp(lpLibFileName, L"libamv_nvidia.dll") == 0) {
|
||||
return TrueLoadLibraryW(WIDEN(MICELIB));
|
||||
}
|
||||
return TrueLoadLibraryW(lpLibFileName);
|
||||
}
|
||||
|
||||
void hook_system() {
|
||||
// TODO: This should be part of drives/hooks.c
|
||||
hook("Kernel32.dll", "GetVolumeInformationW", FakeGetVolumeInformationW, NULL);
|
||||
@ -71,6 +87,8 @@ void hook_system() {
|
||||
// hook("Kernel32.dll", "GetVersionExA", FakeGetVersionExA, NULL);
|
||||
// hook("Kernel32.dll", "GetProcAddress", FakeGetProcAddress, (void*)&TrueGetProcAddress);
|
||||
// hook("Kernel32.dll", "GetModuleHandleA", FakeGetModuleHandleA, (void*)&TrueGetModuleHandleA);
|
||||
hook("Kernel32.dll", "LoadLibraryA", FakeLoadLibraryA, (void*)&TrueLoadLibraryA);
|
||||
hook("Kernel32.dll", "LoadLibraryW", FakeLoadLibraryW, (void*)&TrueLoadLibraryW);
|
||||
|
||||
// hook("ntdll.dll", "RtlGetVersion", FakeRtlGetVersion, NULL);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user