mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-26 04:39:51 -04:00
Update loader
This commit is contained in:
parent
827c28ad38
commit
f95daab2fe
7 changed files with 40 additions and 92 deletions
.github/workflows
installer/windows
loader/launcher/windows
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
@ -287,7 +287,7 @@ jobs:
|
|||
- name: Zip Windows Artifacts
|
||||
uses: vimtor/action-zip@v1.1
|
||||
with:
|
||||
files: geode-win/XInput9_1_0.dll geode-win/Geode.dll geode-win/GeodeUpdater.exe geode-win/Geode.lib geode-win/Geode.pdb
|
||||
files: geode-win/dinput8.dll geode-win/Geode.dll geode-win/GeodeUpdater.exe geode-win/Geode.lib geode-win/Geode.pdb
|
||||
dest: geode-${{ steps.ref.outputs.hash }}-win.zip
|
||||
|
||||
- name: Zip Android32 Artifacts
|
||||
|
|
|
@ -409,7 +409,7 @@ Function .onVerifyInstDir
|
|||
IfFileExists $INSTDIR\hackpro.dll other_hackpro
|
||||
IfFileExists $INSTDIR\ToastedMarshmellow.dll other_gdhm
|
||||
IfFileExists $INSTDIR\quickldr.dll other_quickldr
|
||||
IfFileExists $INSTDIR\XInput9_1_0.dll other_xinput
|
||||
IfFileExists $INSTDIR\dinput8.dll other_dinput
|
||||
IfFileExists $INSTDIR\mimalloc.dll other_mimalloc
|
||||
IfFileExists $INSTDIR\GDH.dll other_GDH
|
||||
|
||||
|
@ -431,8 +431,8 @@ Function .onVerifyInstDir
|
|||
other_quickldr:
|
||||
StrCpy $0 "quickldr.dll"
|
||||
Goto other
|
||||
other_xinput:
|
||||
StrCpy $0 "XInput9_1_0.dll"
|
||||
other_dinput:
|
||||
StrCpy $0 "dinput8.dll"
|
||||
Goto other
|
||||
other_mimalloc:
|
||||
StrCpy $0 "mimalloc.dll"
|
||||
|
@ -459,7 +459,7 @@ SectionGroup "Geode"
|
|||
File ${BINDIR}\Geode.dll
|
||||
File ${BINDIR}\Geode.pdb
|
||||
File ${BINDIR}\GeodeUpdater.exe
|
||||
File ${BINDIR}\XInput9_1_0.dll
|
||||
File ${BINDIR}\dinput8.dll
|
||||
|
||||
WriteUninstaller "GeodeUninstaller.exe"
|
||||
SectionEnd
|
||||
|
@ -511,8 +511,8 @@ Function un.onInit
|
|||
IfFileExists $INSTDIR\*.exe 0 invalid
|
||||
IfFileExists $INSTDIR\libcocos2d.dll 0 invalid
|
||||
|
||||
; check if xinput and geode exist
|
||||
IfFileExists $INSTDIR\XInput9_1_0.dll 0 invalid
|
||||
; check if dinput and geode exist
|
||||
IfFileExists $INSTDIR\dinput8.dll 0 invalid
|
||||
IfFileExists $INSTDIR\Geode.dll 0 invalid
|
||||
Return
|
||||
|
||||
|
@ -527,7 +527,7 @@ Section "Uninstall"
|
|||
Delete $INSTDIR\Geode.pdb
|
||||
Delete $INSTDIR\Geode.lib
|
||||
Delete $INSTDIR\GeodeUpdater.exe
|
||||
Delete $INSTDIR\XInput9_1_0.dll
|
||||
Delete $INSTDIR\dinput8.dll
|
||||
|
||||
# default value of DATA is an empty string
|
||||
# if DATA is empty, keep user data
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
cmake_minimum_required(VERSION 3.21)
|
||||
|
||||
add_library(ProxyLoader SHARED proxyLoader.c)
|
||||
add_library(ProxyLoader SHARED proxyLoader.cpp)
|
||||
set_target_properties(ProxyLoader PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME "XInput9_1_0"
|
||||
OUTPUT_NAME "dinput8"
|
||||
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${GEODE_BIN_PATH}/nightly"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${GEODE_BIN_PATH}/nightly"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${GEODE_BIN_PATH}/nightly"
|
||||
|
|
|
@ -105,7 +105,7 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
if (std::filesystem::exists(geodeDir) && std::filesystem::exists(updatesDir)) {
|
||||
bool updateSuccess = true;
|
||||
updateSuccess &= updateFile("XInput9_1_0.dll");
|
||||
updateSuccess &= updateFile("dinput8.dll");
|
||||
updateSuccess &= updateFile("Geode.dll");
|
||||
updateSuccess &= updateFile("Geode.pdb");
|
||||
updateResources();
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
__declspec(dllexport) void fake() { }
|
|
@ -1,80 +0,0 @@
|
|||
#include <Windows.h>
|
||||
#include <Xinput.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 260
|
||||
#endif
|
||||
|
||||
HMODULE xinput = NULL;
|
||||
DWORD(WINAPI* getState)(DWORD, XINPUT_STATE*) = NULL;
|
||||
DWORD(WINAPI* setState)(DWORD, XINPUT_VIBRATION*) = NULL;
|
||||
DWORD(WINAPI* getCapabilities)(DWORD, DWORD, XINPUT_CAPABILITIES*) = NULL;
|
||||
DWORD(WINAPI* getDSoundAudioDeviceGuids)(DWORD, GUID*, GUID*) = NULL;
|
||||
void lazyLoadXInput() {
|
||||
if (xinput)
|
||||
return;
|
||||
char path[MAX_PATH];
|
||||
GetSystemDirectoryA(path, MAX_PATH);
|
||||
strcat_s(path, MAX_PATH, "\\XInput9_1_0.dll");
|
||||
xinput = LoadLibraryA(path);
|
||||
getState = (DWORD(WINAPI*)(DWORD, XINPUT_STATE*))GetProcAddress(xinput, "XInputGetState");
|
||||
setState = (DWORD(WINAPI*)(DWORD, XINPUT_VIBRATION*))GetProcAddress(xinput, "XInputSetState");
|
||||
getCapabilities = (DWORD(WINAPI*)(DWORD, DWORD, XINPUT_CAPABILITIES*))GetProcAddress(xinput, "XInputGetCapabilities");
|
||||
getDSoundAudioDeviceGuids = (DWORD(WINAPI*)(DWORD, GUID*, GUID*))GetProcAddress(xinput, "XInputGetDSoundAudioDeviceGuids");
|
||||
}
|
||||
|
||||
DWORD WINAPI xinputGetState(DWORD dwUserIndex, XINPUT_STATE* pState) {
|
||||
lazyLoadXInput();
|
||||
return getState(dwUserIndex, pState);
|
||||
}
|
||||
DWORD WINAPI xinputSetState(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration) {
|
||||
lazyLoadXInput();
|
||||
return setState(dwUserIndex, pVibration);
|
||||
}
|
||||
DWORD WINAPI xinputGetCapabilities(DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities) {
|
||||
lazyLoadXInput();
|
||||
return getCapabilities(dwUserIndex, dwFlags, pCapabilities);
|
||||
}
|
||||
DWORD WINAPI xinputGetDSoundAudioDeviceGuids(DWORD dwUserIndex, GUID* pDSoundRenderGuid, GUID* pDSoundCaptureGuid) {
|
||||
lazyLoadXInput();
|
||||
return getDSoundAudioDeviceGuids(dwUserIndex, pDSoundRenderGuid, pDSoundCaptureGuid);
|
||||
}
|
||||
|
||||
// https://github.com/mrexodia/perfect-dll-proxy
|
||||
#if defined(_WIN64)
|
||||
#define PROXY_PATH(export) \
|
||||
"/export:" #export "=\\\\.\\GLOBALROOT\\SystemRoot\\System32\\XInput9_1_0.dll." #export
|
||||
#else
|
||||
#define PROXY_PATH(export) \
|
||||
"/export:" #export "=\\\\.\\GLOBALROOT\\SystemRoot\\SysWOW64\\XInput9_1_0.dll." #export
|
||||
#endif
|
||||
|
||||
#pragma comment(linker, PROXY_PATH(XInputGetState))
|
||||
#pragma comment(linker, PROXY_PATH(XInputSetState))
|
||||
#pragma comment(linker, PROXY_PATH(XInputGetCapabilities))
|
||||
#pragma comment(linker, PROXY_PATH(XInputGetDSoundAudioDeviceGuids))
|
||||
|
||||
BOOL fileExists(char const* path) {
|
||||
DWORD attrib = GetFileAttributesA(path);
|
||||
return (attrib != INVALID_FILE_ATTRIBUTES && !(attrib & FILE_ATTRIBUTE_DIRECTORY));
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE module, DWORD reason, LPVOID _) {
|
||||
if (reason != DLL_PROCESS_ATTACH)
|
||||
return TRUE;
|
||||
DisableThreadLibraryCalls(module);
|
||||
|
||||
if (fileExists("Geode.dll")) {
|
||||
// somehow, this works fine inside of dllmain :-)
|
||||
// yes, even on wine.
|
||||
/* * * * * * * * * * * * * * * * * *\
|
||||
* The Shadows Shall Smite You 01 *
|
||||
* - ConfiG *
|
||||
\* * * * * * * * * * * * * * * * * */
|
||||
LoadLibraryA("Geode.dll");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
29
loader/launcher/windows/proxyLoader.cpp
Normal file
29
loader/launcher/windows/proxyLoader.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <Windows.h>
|
||||
#include <string>
|
||||
|
||||
// https://github.com/mrexodia/perfect-dll-proxy
|
||||
#define PROXY_PATH(export) \
|
||||
"/export:" #export "=\\\\.\\GLOBALROOT\\SystemRoot\\System32\\dinput8.dll." #export
|
||||
|
||||
#pragma comment(linker, PROXY_PATH(DirectInput8Create))
|
||||
#pragma comment(linker, PROXY_PATH(DllCanUnloadNow))
|
||||
#pragma comment(linker, PROXY_PATH(DllGetClassObject))
|
||||
#pragma comment(linker, PROXY_PATH(DllRegisterServer))
|
||||
#pragma comment(linker, PROXY_PATH(DllUnregisterServer))
|
||||
#pragma comment(linker, PROXY_PATH(GetdfDIJoystick))
|
||||
|
||||
static std::wstring getErrorString() {
|
||||
return L"Could not load Geode. Error code: " + std::to_wstring(GetLastError());
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE module, DWORD reason, LPVOID _) {
|
||||
if (reason == DLL_PROCESS_ATTACH) {
|
||||
DisableThreadLibraryCalls(module);
|
||||
|
||||
// This is UB.
|
||||
if (LoadLibraryW(L"Geode.dll") == NULL)
|
||||
MessageBoxW(NULL, getErrorString().c_str(), L"Load failed" , MB_OK | MB_ICONWARNING);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
Loading…
Add table
Reference in a new issue