Author Topic: Glitch in Bass_vst.h  (Read 110 times)

nadia

  • Posts: 334
Glitch in Bass_vst.h
« on: 8 Nov '24 - 22:06 »
Hello  ;D

I think that I've found a glitch inside the definition of the VSTPROC available inside the latest bass_vst.h that can be reproduced when using the x64 version of bass_vst.

According to the related comment, when the parameter "action" is set to BASS_VST_AUDIO_MASTER, the "param1" parameter should be a pointer to a BASS_VST_AUDIO_MASTER_PARAM structure; when running in 64 bits systems, pointers are 64 bits themselves but the "param1" parameter is declared as DWORD which is obviously a 32 bits value so this can cause a 0xc0000005 violation. Wouldn't it be better to define "param1" as a void* so the passed value will be automatically a 64 bits value for x64 systems and a 32 bits value for x86 systems?

Kind regards

nadia

Ian @ un4seen

  • Administrator
  • Posts: 26171
Re: Glitch in Bass_vst.h
« Reply #1 on: 11 Nov '24 - 12:20 »
The BASS_VST.H header in the current release doesn't mention it, but "param2" contains the high 32 bits of a 64-bit pointer. So the example code in that file can be modified like this:

Code: [Select]
*      DWORD myCallback(DWORD vstHandle, DWORD action, DWORD param1, DWORD param2, void* user)
 *      {
 *          if( action == BASS_VST_AUDIO_MASTER )
 *          {
 *              BASS_VST_AUDIO_MASTER_PARAM* audioMaster;
 *              if (sizeof(void*) == 8)
 *                  audioMaster = (BASS_VST_AUDIO_MASTER_PARAM*)(param1 + ((QWORD)param2 << 32));
 *              else
 *                  audioMaster = (BASS_VST_AUDIO_MASTER_PARAM*)param1;
 *              if( audioMaster->opcode == audioMasterOpenFileSelector )
 *              {
 *                  openMyFileSelector((VstFileSelect*)audioMaster->ptr);
 *                  audioMaster->doDefault = 0;
 *                  return 1;
 *              }
 *          }
 *          return 0;
 *      }