feat: Provide DMO functionality using dsdmo blob
> fetch dsdmo.dll blobs and embed into spicetools > unpack and register overriding relevant COM server on runtime > may be replaced in the future, see #12
This commit is contained in:
+31
-6
@@ -167,15 +167,39 @@ void attach(HINSTANCE hmodule)
|
||||
|
||||
namespace hooks::wmisc::dmoeffector
|
||||
{
|
||||
typedef HRESULT (STDAPICALLTYPE *DllRegisterServer_t)();
|
||||
|
||||
HMODULE LoadLibraryRsrc(const char *rsrcname) {
|
||||
// Unpack library blob
|
||||
HRSRC hrsrc = FindResourceA(nullptr, rsrcname, RT_RCDATA);
|
||||
void* rsrcdata = LockResource(LoadResource(nullptr, hrsrc));
|
||||
DWORD rsrcsz = SizeofResource(nullptr, hrsrc);
|
||||
|
||||
// _REV: could use tmpfs instead if bmsound_wine provides tempfile wrapper in future
|
||||
// Store as temporary file (no direct way to in-memory load without involving custom loaders like MemoryModule)
|
||||
char tempPath[MAX_PATH];
|
||||
char tempFile[MAX_PATH];
|
||||
GetTempPathA(MAX_PATH, tempPath);
|
||||
GetTempFileNameA(tempPath, rsrcname, 0, tempFile);
|
||||
MoveFileExA(tempFile, nullptr, MOVEFILE_DELAY_UNTIL_REBOOT); // wine blocks DeleteFileA operations on LoadLibraryA filepaths
|
||||
FILE *fh = fopen(tempFile, "wb");
|
||||
fwrite(rsrcdata, rsrcsz, 1, fh);
|
||||
fclose(fh);
|
||||
|
||||
// Map temporary library buffer
|
||||
HMODULE hmodule = LoadLibraryA(tempFile);
|
||||
return hmodule;
|
||||
}
|
||||
void attach(HINSTANCE hmodule)
|
||||
{
|
||||
//_REM: Disable dmoeffector error printing for line55, could not find unique pattern (9 matches, but patching all of them is harmless)
|
||||
intptr_t next = (intptr_t) hmodule;
|
||||
while (next)
|
||||
HMODULE libdmo = LoadLibraryRsrc("DMO_BLOB");
|
||||
if(libdmo)
|
||||
{
|
||||
next = replace_pattern_from(hmodule, "793ae8????????895424??4c8d05????????488bc8488d15????????41b937000000e8????????ff15????????", "eb3ae8????????895424??4c8d05????????488bc8488d15????????41b937000000e8????????ff15????????", 0, 0, next - reinterpret_cast<intptr_t>(hmodule));
|
||||
if (next) log_info("hooks::wmisc::dmoeffector", "Muting error message({})", reinterpret_cast<void *>(next));
|
||||
log_info("hooks::wmisc::dmoeffector", "Registering COM server for DMO({})", reinterpret_cast<void *>(libdmo));
|
||||
auto DllRegisterServer = (DllRegisterServer_t)GetProcAddress(libdmo, "DllRegisterServer");
|
||||
if(DllRegisterServer && SUCCEEDED(DllRegisterServer())) return;
|
||||
}
|
||||
log_warning("hooks::wmisc::dmoeffector", "Loading embedded dsdmo.dll failed, error code: {}", GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,6 +219,7 @@ void apply_performance_hacks(HINSTANCE hmodule, const char *model, const char *e
|
||||
switch (to_hash(model))
|
||||
{
|
||||
case to_hash("LDJ"):
|
||||
dmoeffector::attach(hmodule);
|
||||
thumbnail::attach(hmodule);
|
||||
msacm::attach(hmodule);
|
||||
bmsound::attach(hmodule);
|
||||
@@ -204,12 +229,12 @@ void apply_performance_hacks(HINSTANCE hmodule, const char *model, const char *e
|
||||
bmsound::attach(hmodule);
|
||||
break;
|
||||
case to_hash("KFC"):
|
||||
dmoeffector::attach(hmodule);
|
||||
msacm::attach(hmodule);
|
||||
bmsound::attach(hmodule);
|
||||
if (extl > 2019020600 && extl < 2021011800) // SDVX5
|
||||
{
|
||||
cmovieplayer::attach(hmodule);
|
||||
dmoeffector::attach(hmodule);
|
||||
}
|
||||
break;
|
||||
case to_hash("FORCE"):
|
||||
|
||||
Reference in New Issue
Block a user