Skip to content

Commit

Permalink
Version 14.8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
bri committed Aug 29, 2023
1 parent 5363ae5 commit 38f63d9
Show file tree
Hide file tree
Showing 19 changed files with 385 additions and 79 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,5 @@ OmniMIDIv2/Debug/
OmniMIDIv2/Release/
OmniMIDIv2/packages/
OmniMIDIv2/lib/
OmniMIDIv2/Release (MSVC++)/
OmniMIDIv2/Release (WINNTCRT)/
Binary file modified DeveloperContent/LIB32/OmniMIDI_Win32.exp
Binary file not shown.
Binary file modified DeveloperContent/LIB32/OmniMIDI_Win32.lib
Binary file not shown.
Binary file modified DeveloperContent/LIB64/OmniMIDI_Win64.exp
Binary file not shown.
Binary file modified DeveloperContent/LIB64/OmniMIDI_Win64.lib
Binary file not shown.
Binary file modified DeveloperContent/LIBARM64/OmniMIDI_ARM64.exp
Binary file not shown.
Binary file modified DeveloperContent/LIBARM64/OmniMIDI_ARM64.lib
Binary file not shown.
Binary file modified OmniMIDI/Resource.aps
Binary file not shown.
Binary file modified OmniMIDI/Resource.rc
Binary file not shown.
52 changes: 44 additions & 8 deletions OmniMIDI/WinMMWRP/WinMM.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ HMODULE KERNEL32 = NULL;
DWORD(WINAPI* INtimeGetTime)() = 0;

// Wine check
const char* (WINAPI* WGBI)(void) = 0;
typedef const char* (WINAPI* WGBI)(void);
INT WDummy = 0xFFFFF;
HMIDI OMDummy = (HMIDI)0x1001;
DWORD_PTR OMUser;
Expand Down Expand Up @@ -450,6 +450,10 @@ MMImports[] =

// Functions start -> HERE <-

MMRESULT WINAPI xxx32Message(UINT_PTR, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR) {
return MMSYSERR_ERROR;
}

HDRVR WINAPI WINMM_OpenDriver(_In_ LPCWSTR lpDN, _In_ LPCWSTR lpSN, _In_ LPARAM lp) {
return MMOpenDriver(lpDN, lpSN, lp);
}
Expand Down Expand Up @@ -1129,20 +1133,20 @@ MMRESULT WINAPI WINMM_wod32Message(UINT_PTR uDeviceID, UINT uMsg, DWORD_PTR hMid
}
#endif

BOOL ImportFromWinMM(int i, TCHAR* ErrorBuf) {
BOOL ImportFromWinMM(int i, char* ErrorBuf) {
*(MMImports[i].ptr) = (void*)GetProcAddress(OWINMM, MMImports[i].name);

if (!*(MMImports[i].ptr)) {
swprintf_s(
sprintf_s(
ErrorBuf,
1024,
L"An error has occured while loading \"%s\" from the Windows Multimedia Extension API library.\n\nFailed to load the required functions, press OK to exit.",
"An error has occured while loading \"%s\" from the Windows Multimedia Extension API library.\n\nFailed to load the required functions, press OK to exit.",
MMImports[i].name);

MessageBox(
MessageBoxA(
NULL,
ErrorBuf,
L"KDMAPI ERROR",
"KDMAPI ERROR",
MB_ICONERROR | MB_OK | MB_SYSTEMMODAL
);
return FALSE;
Expand All @@ -1165,10 +1169,20 @@ void GetSpeedHack() {
RegCloseKey(RegKey);
}

BOOL IsOMRunningUnderWine() {
HMODULE hntdll = GetModuleHandleA("ntdll");
if (!hntdll) return FALSE;

WGBI test = (WGBI)GetProcAddress(hntdll, "wine_get_build_id");
return (test != NULL) ? TRUE : FALSE;
}

BOOL InitializeWinMM() {
if (OWINMM)
return TRUE;

BOOL IOMRUW = IsOMRunningUnderWine();

if (!OWINMM) {
// Load WinMM from system directory if copy isn't found in the app's directory
if (INVALID_FILE_ATTRIBUTES == GetFileAttributes(L"owinmm.dll") && GetLastError() == ERROR_FILE_NOT_FOUND)
Expand Down Expand Up @@ -1207,7 +1221,23 @@ BOOL InitializeWinMM() {
}
}

TCHAR ErrorBuf[1024];
char ErrorBuf[1024];

#ifdef _M_IX86
if (IOMRUW) {
MMaux32Message = xxx32Message;
MMjoy32Message = xxx32Message;
MMmci32Message = xxx32Message;
MMmid32Message = xxx32Message;
MMmod32Message = xxx32Message;
MMmxd32Message = xxx32Message;
MMtid32Message = xxx32Message;
MMwid32Message = xxx32Message;
MMwod32Message = xxx32Message;

printf("Detected Wine.");
}
#endif

// LOAD EVERYTHING!
for (int i = 0; i < sizeof(MMImports) / sizeof(MMImports[0]); i++)
Expand All @@ -1223,7 +1253,13 @@ BOOL InitializeWinMM() {
if (!*(MMImports[i].ptr))
ImportFromWinMM(i, ErrorBuf);
}
else ImportFromWinMM(i, ErrorBuf);
else {
if (*(MMImports[i].ptr) == xxx32Message)
continue;

if (!ImportFromWinMM(i, ErrorBuf))
break;
}
}

return TRUE;
Expand Down
2 changes: 1 addition & 1 deletion OmniMIDISetup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define MixerWindow "OmniMIDIMixerWindow"
#define OutputName "OmniMIDISetup"
#define ProductName "OmniMIDI"
#define Version '14.8.3.0'
#define Version '14.8.4.0'

#define MIDIMapper 'OmniMapper'
#define lib32 'external_packages\lib'
Expand Down
24 changes: 16 additions & 8 deletions OmniMIDIv2/BASSSynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void OmniMIDI::BASSSynth::EventsThread() {
}
}

bool OmniMIDI::BASSSynth::ProcessEvBuf() {
bool OmniMIDI::BASSSynth::ProcessEvent(unsigned int tev) {
/*
For more info about how an event is structured, read this doc from Microsoft:
Expand Down Expand Up @@ -62,15 +62,8 @@ bool OmniMIDI::BASSSynth::ProcessEvBuf() {
*/

unsigned int tev = 0;
unsigned int sysev = 0;

if (!Events->Pop(tev) || !AudioStream)
return false;

if (CHKLRS(GETSTATUS(tev)) != 0) LastRunningStatus = GETSTATUS(tev);
else tev = tev << 8 | LastRunningStatus;

unsigned int evt = MIDI_SYSTEM_DEFAULT;
unsigned int ev = 0;
unsigned char status = GETSTATUS(tev);
Expand Down Expand Up @@ -172,6 +165,18 @@ bool OmniMIDI::BASSSynth::ProcessEvBuf() {
return true;
}

bool OmniMIDI::BASSSynth::ProcessEvBuf() {
unsigned int tev = 0;

if (!Events->Pop(tev) || !AudioStream)
return false;

if (CHKLRS(GETSTATUS(tev)) != 0) LastRunningStatus = GETSTATUS(tev);
else tev = tev << 8 | LastRunningStatus;

return ProcessEvent(tev);
}

bool OmniMIDI::BASSSynth::LoadFuncs() {
void* ptr = nullptr;

Expand Down Expand Up @@ -709,5 +714,8 @@ int OmniMIDI::BASSSynth::TalkToSynthDirectly(unsigned int evt, unsigned int chan
if (!BMidLib || !BMidLib->IsOnline())
return 0;

if (!evt && !chan)
return ProcessEvent(param) ? SYNTH_OK : SYNTH_INVALPARAM;

return BASS_MIDI_StreamEvent(AudioStream, chan, evt, param);
}
1 change: 1 addition & 0 deletions OmniMIDIv2/BASSSynth.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ namespace OmniMIDI {
bool UnloadFuncs();
void StreamSettings(bool restart);
bool ProcessEvBuf();
bool ProcessEvent(unsigned int ev);

public:
bool LoadSynthModule();
Expand Down
28 changes: 21 additions & 7 deletions OmniMIDIv2/NtFuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,49 @@
namespace NT {
class Funcs {
private:
HMODULE ntdll = nullptr;
bool LL = false;
unsigned int (WINAPI* pNtDelayExecution)(unsigned char, signed long long*) = nullptr;
unsigned int (WINAPI* pNtQuerySystemTime)(signed long long*) = nullptr;
bool Ready = false;

public:
Funcs() {
auto mod = GetModuleHandleA("ntdll");
assert(mod != 0);
ntdll = GetModuleHandleA("ntdll");

if (ntdll) {
// ... How?
LL = true;
ntdll = LoadLibraryA("ntdll");
}

if (!mod)
assert(ntdll != 0);
if (!ntdll)
return;

auto v1 = (unsigned int (WINAPI*)(unsigned char, signed long long*))GetProcAddress(mod, "NtDelayExecution");
auto v1 = (unsigned int (WINAPI*)(unsigned char, signed long long*))GetProcAddress(ntdll, "NtDelayExecution");
assert(v1 != 0);

if (v1 == nullptr)
return;

pNtDelayExecution = v1;

auto v2 = (unsigned int (WINAPI*)(signed long long*))GetProcAddress(mod, "NtQuerySystemTime");
auto v2 = (unsigned int (WINAPI*)(signed long long*))GetProcAddress(ntdll, "NtQuerySystemTime");
assert(v2 != 0);

if (v2 == nullptr)
return;

pNtQuerySystemTime = v2;
}

~Funcs() {
if (LL) {
if (!FreeLibrary(ntdll))
throw;

Ready = true;
ntdll = nullptr;
}
}

unsigned int uSleep(signed long long v) {
Expand Down
36 changes: 24 additions & 12 deletions OmniMIDIv2/OmniMIDI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ Global
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
Release (MSVC++)|ARM = Release (MSVC++)|ARM
Release (MSVC++)|ARM64 = Release (MSVC++)|ARM64
Release (MSVC++)|x64 = Release (MSVC++)|x64
Release (MSVC++)|x86 = Release (MSVC++)|x86
Release (WINNTCRT)|ARM = Release (WINNTCRT)|ARM
Release (WINNTCRT)|ARM64 = Release (WINNTCRT)|ARM64
Release (WINNTCRT)|x64 = Release (WINNTCRT)|x64
Release (WINNTCRT)|x86 = Release (WINNTCRT)|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{042EAA44-6BE1-4D89-882B-058828E659D7}.Debug|ARM.ActiveCfg = Debug|ARM
Expand All @@ -25,14 +29,22 @@ Global
{042EAA44-6BE1-4D89-882B-058828E659D7}.Debug|x64.Build.0 = Debug|x64
{042EAA44-6BE1-4D89-882B-058828E659D7}.Debug|x86.ActiveCfg = Debug|Win32
{042EAA44-6BE1-4D89-882B-058828E659D7}.Debug|x86.Build.0 = Debug|Win32
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release|ARM.ActiveCfg = Release|ARM
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release|ARM.Build.0 = Release|ARM
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release|ARM64.ActiveCfg = Release|ARM64
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release|ARM64.Build.0 = Release|ARM64
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release|x64.ActiveCfg = Release|x64
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release|x64.Build.0 = Release|x64
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release|x86.ActiveCfg = Release|Win32
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release|x86.Build.0 = Release|Win32
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (MSVC++)|ARM.ActiveCfg = Release (MSVC++)|ARM
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (MSVC++)|ARM.Build.0 = Release (MSVC++)|ARM
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (MSVC++)|ARM64.ActiveCfg = Release (MSVC++)|ARM64
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (MSVC++)|ARM64.Build.0 = Release (MSVC++)|ARM64
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (MSVC++)|x64.ActiveCfg = Release (MSVC++)|x64
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (MSVC++)|x64.Build.0 = Release (MSVC++)|x64
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (MSVC++)|x86.ActiveCfg = Release (MSVC++)|Win32
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (MSVC++)|x86.Build.0 = Release (MSVC++)|Win32
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (WINNTCRT)|ARM.ActiveCfg = Release (WINNTCRT)|ARM
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (WINNTCRT)|ARM.Build.0 = Release (WINNTCRT)|ARM
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (WINNTCRT)|ARM64.ActiveCfg = Release (WINNTCRT)|ARM64
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (WINNTCRT)|ARM64.Build.0 = Release (WINNTCRT)|ARM64
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (WINNTCRT)|x64.ActiveCfg = Release (WINNTCRT)|x64
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (WINNTCRT)|x64.Build.0 = Release (WINNTCRT)|x64
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (WINNTCRT)|x86.ActiveCfg = Release (WINNTCRT)|Win32
{042EAA44-6BE1-4D89-882B-058828E659D7}.Release (WINNTCRT)|x86.Build.0 = Release (WINNTCRT)|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading

0 comments on commit 38f63d9

Please sign in to comment.