#include "Resource/MilesRuntime.h" #include // Host integration helper, not a recovered original constructor. The reference // imports Miles Sound System directly; this loader has no original function address. MilesRuntime& MilesRuntime::Get() { static MilesRuntime instance; return instance; } MilesRuntime::MilesRuntime() : m_module(LoadLibraryA("Mss32.dll")) { if (!this->m_module) { throw std::system_error(GetLastError(), std::system_category(), "Mss32.dll"); } this->startup = reinterpret_caststartup)>(GetProcAddress(this->m_module, "_AIL_startup@0")); this->shutdown = reinterpret_castshutdown)>(GetProcAddress(this->m_module, "_AIL_shutdown@0")); this->setRedistDirectory = reinterpret_castsetRedistDirectory)>(GetProcAddress(this->m_module, "_AIL_set_redist_directory@4")); this->setPreference = reinterpret_castsetPreference)>(GetProcAddress(this->m_module, "_AIL_set_preference@8")); this->openDigitalDriver = reinterpret_castopenDigitalDriver)>(GetProcAddress(this->m_module, "_AIL_open_digital_driver@16")); this->closeDigitalDriver = reinterpret_castcloseDigitalDriver)>(GetProcAddress(this->m_module, "_AIL_close_digital_driver@4")); this->allocateSample = reinterpret_castallocateSample)>(GetProcAddress(this->m_module, "_AIL_allocate_sample_handle@4")); this->releaseSample = reinterpret_castreleaseSample)>(GetProcAddress(this->m_module, "_AIL_release_sample_handle@4")); this->initSample = reinterpret_castinitSample)>(GetProcAddress(this->m_module, "_AIL_init_sample@4")); this->setSampleFile = reinterpret_castsetSampleFile)>(GetProcAddress(this->m_module, "_AIL_set_sample_file@12")); this->sampleStatus = reinterpret_castsampleStatus)>(GetProcAddress(this->m_module, "_AIL_sample_status@4")); this->setSampleVolume = reinterpret_castsetSampleVolume)>(GetProcAddress(this->m_module, "_AIL_set_sample_volume@8")); this->startSample = reinterpret_caststartSample)>(GetProcAddress(this->m_module, "_AIL_start_sample@4")); this->endSample = reinterpret_castendSample)>(GetProcAddress(this->m_module, "_AIL_end_sample@4")); this->openStream = reinterpret_castopenStream)>(GetProcAddress(this->m_module, "_AIL_open_stream@12")); this->closeStream = reinterpret_castcloseStream)>(GetProcAddress(this->m_module, "_AIL_close_stream@4")); this->streamStatus = reinterpret_caststreamStatus)>(GetProcAddress(this->m_module, "_AIL_stream_status@4")); this->setStreamLoopCount = reinterpret_castsetStreamLoopCount)>( GetProcAddress(this->m_module, "_AIL_set_stream_loop_count@8") ); this->streamVolume = reinterpret_caststreamVolume)>(GetProcAddress(this->m_module, "_AIL_stream_volume@4")); this->setStreamVolume = reinterpret_castsetStreamVolume)>(GetProcAddress(this->m_module, "_AIL_set_stream_volume@8")); this->pauseStream = reinterpret_castpauseStream)>(GetProcAddress(this->m_module, "_AIL_pause_stream@8")); this->startStream = reinterpret_caststartStream)>(GetProcAddress(this->m_module, "_AIL_start_stream@4")); this->enumerate3DProviders = reinterpret_castenumerate3DProviders)>( GetProcAddress(this->m_module, "_AIL_enumerate_3D_providers@12") ); this->open3DProvider = reinterpret_castopen3DProvider)>(GetProcAddress(this->m_module, "_AIL_open_3D_provider@4")); this->close3DProvider = reinterpret_castclose3DProvider)>(GetProcAddress(this->m_module, "_AIL_close_3D_provider@4")); this->speakerType = reinterpret_castspeakerType)>(GetProcAddress(this->m_module, "_AIL_3D_speaker_type@4")); this->setSpeakerType = reinterpret_castsetSpeakerType)>(GetProcAddress(this->m_module, "_AIL_set_3D_speaker_type@8")); this->open3DListener = reinterpret_castopen3DListener)>(GetProcAddress(this->m_module, "_AIL_open_3D_listener@4")); this->close3DListener = reinterpret_castclose3DListener)>(GetProcAddress(this->m_module, "_AIL_close_3D_listener@4")); this->allocate3DSample = reinterpret_castallocate3DSample)>( GetProcAddress(this->m_module, "_AIL_allocate_3D_sample_handle@4") ); this->release3DSample = reinterpret_castrelease3DSample)>( GetProcAddress(this->m_module, "_AIL_release_3D_sample_handle@4") ); this->set3DSampleFile = reinterpret_castset3DSampleFile)>(GetProcAddress(this->m_module, "_AIL_set_3D_sample_file@8")); this->sample3DStatus = reinterpret_castsample3DStatus)>(GetProcAddress(this->m_module, "_AIL_3D_sample_status@4")); this->set3DSampleVolume = reinterpret_castset3DSampleVolume)>(GetProcAddress(this->m_module, "_AIL_set_3D_sample_volume@8")); this->start3DSample = reinterpret_caststart3DSample)>(GetProcAddress(this->m_module, "_AIL_start_3D_sample@4")); this->end3DSample = reinterpret_castend3DSample)>(GetProcAddress(this->m_module, "_AIL_end_3D_sample@4")); this->roomType = reinterpret_castroomType)>(GetProcAddress(this->m_module, "_AIL_3D_room_type@4")); this->setRoomType = reinterpret_castsetRoomType)>(GetProcAddress(this->m_module, "_AIL_set_3D_room_type@8")); this->set3DSampleDistances = reinterpret_castset3DSampleDistances)>( GetProcAddress(this->m_module, "_AIL_set_3D_sample_distances@12") ); this->set3DSampleEffectsLevel = reinterpret_castset3DSampleEffectsLevel)>( GetProcAddress(this->m_module, "_AIL_set_3D_sample_effects_level@8") ); this->set3DPosition = reinterpret_castset3DPosition)>(GetProcAddress(this->m_module, "_AIL_set_3D_position@16")); this->set3DOrientation = reinterpret_castset3DOrientation)>(GetProcAddress(this->m_module, "_AIL_set_3D_orientation@28")); this->fileType = reinterpret_castfileType)>(GetProcAddress(this->m_module, "_AIL_file_type@8")); this->wavInfo = reinterpret_castwavInfo)>(GetProcAddress(this->m_module, "_AIL_WAV_info@8")); this->decompressADPCM = reinterpret_castdecompressADPCM)>(GetProcAddress(this->m_module, "_AIL_decompress_ADPCM@12")); this->decompressASI = reinterpret_castdecompressASI)>(GetProcAddress(this->m_module, "_AIL_decompress_ASI@24")); this->freeLocked = reinterpret_castfreeLocked)>(GetProcAddress(this->m_module, "_AIL_mem_free_lock@4")); if ( !this->startup || !this->shutdown || !this->setRedistDirectory || !this->setPreference || !this->openDigitalDriver || !this->closeDigitalDriver || !this->allocateSample || !this->releaseSample || !this->initSample || !this->setSampleFile || !this->sampleStatus || !this->setSampleVolume || !this->startSample || !this->endSample || !this->openStream || !this->closeStream || !this->streamStatus || !this->setStreamLoopCount || !this->streamVolume || !this->setStreamVolume || !this->pauseStream || !this->startStream || !this->enumerate3DProviders || !this->open3DProvider || !this->close3DProvider || !this->speakerType || !this->setSpeakerType || !this->open3DListener || !this->close3DListener || !this->allocate3DSample || !this->release3DSample || !this->set3DSampleFile || !this->sample3DStatus || !this->set3DSampleVolume || !this->start3DSample || !this->end3DSample || !this->roomType || !this->setRoomType || !this->set3DSampleDistances || !this->set3DSampleEffectsLevel || !this->set3DPosition || !this->set3DOrientation || !this->fileType || !this->wavInfo || !this->decompressADPCM || !this->decompressASI || !this->freeLocked ) { FreeLibrary(this->m_module); throw std::system_error(ERROR_PROC_NOT_FOUND, std::system_category(), "Mss32 exports"); } } MilesRuntime::~MilesRuntime() { FreeLibrary(this->m_module); }