|
|
@@ -367,60 +367,56 @@ void loc_eventProc(void *xevent) { |
|
|
|
// PropModeReplace, (unsigned char*)temp, 2); |
|
|
|
// } |
|
|
|
|
|
|
|
#ifdef BUILD_64 |
|
|
|
// GPL code pulled from the amsynth example <https://github.com/amsynth/amsynth/blob/4a87798e650c6d71d70274a961c9b8d98fc6da7e/src/amsynth_vst.cpp> |
|
|
|
// Simply swapped out the function names, crashes Ardour in the same was as the others |
|
|
|
void loc_setEventProc (Display *display, Window window) { |
|
|
|
// |
|
|
|
// JUCE calls XGetWindowProperty with long_length = 1 which means it only fetches the lower 32 bits of the address. |
|
|
|
// Therefore we need to ensure we return an address in the lower 32-bits of address space. |
|
|
|
// |
|
|
|
|
|
|
|
// based on mach_override |
|
|
|
static const unsigned char kJumpInstructions[] = { |
|
|
|
0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, |
|
|
|
0x00, 0x00, 0x00, 0x00, |
|
|
|
0x00, 0x00, 0x00, 0x00 |
|
|
|
}; |
|
|
|
static const int kJumpAddress = 6; |
|
|
|
|
|
|
|
static char *ptr = 0; |
|
|
|
if (!ptr) { |
|
|
|
ptr = (char *)mmap(0, |
|
|
|
PAGE_SIZE, |
|
|
|
PROT_READ | PROT_WRITE | PROT_EXEC, |
|
|
|
MAP_ANONYMOUS | MAP_PRIVATE | MAP_32BIT, |
|
|
|
0, 0); |
|
|
|
if (ptr == MAP_FAILED) { |
|
|
|
perror("mmap"); |
|
|
|
ptr = 0; |
|
|
|
return; |
|
|
|
} else { |
|
|
|
memcpy(ptr, kJumpInstructions, sizeof(kJumpInstructions)); |
|
|
|
*((uint64_t *)(ptr + kJumpAddress)) = (uint64_t)(&loc_eventProc); |
|
|
|
msync(ptr, sizeof(kJumpInstructions), MS_INVALIDATE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
long temp[2] = {(long)ptr, 0}; |
|
|
|
Atom atom = XInternAtom(display, "_XEventProc", False); |
|
|
|
XChangeProperty(display, window, atom, atom, 32, PropModeReplace, (unsigned char *)temp, 2); |
|
|
|
} |
|
|
|
#else |
|
|
|
// Pulled from the eXT2 example |
|
|
|
// TODO: 32-bit support |
|
|
|
void loc_setEventProc (Display *display, Window window) { |
|
|
|
void loc_setEventProc_32bit (Display *display, Window window) { |
|
|
|
void* data = (void*)&loc_eventProc; // swapped the function name here |
|
|
|
|
|
|
|
Atom atom = XInternAtom(display, "_XEventProc", False); |
|
|
|
XChangeProperty(display, window, atom, atom, 32, |
|
|
|
PropModeReplace, (unsigned char*)&data, 1); // 1 instead of 2 will crash Ardour, 2 will not do anything |
|
|
|
} |
|
|
|
|
|
|
|
// Pulled from the amsynth example |
|
|
|
// Simply swapped out the function names, crashes Ardour in the same was as the others |
|
|
|
// void loc_setEventProc (Display *display, Window window) { |
|
|
|
// #ifdef BUILD_64 |
|
|
|
// // |
|
|
|
// // JUCE calls XGetWindowProperty with long_length = 1 which means it only fetches the lower 32 bits of the address. |
|
|
|
// // Therefore we need to ensure we return an address in the lower 32-bits of address space. |
|
|
|
// // |
|
|
|
|
|
|
|
// // based on mach_override |
|
|
|
// static const unsigned char kJumpInstructions[] = { |
|
|
|
// 0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, |
|
|
|
// 0x00, 0x00, 0x00, 0x00, |
|
|
|
// 0x00, 0x00, 0x00, 0x00 |
|
|
|
// }; |
|
|
|
// static const int kJumpAddress = 6; |
|
|
|
|
|
|
|
// static char *ptr; |
|
|
|
// if (!ptr) { |
|
|
|
// ptr = (char *)mmap(0, |
|
|
|
// PAGE_SIZE, |
|
|
|
// PROT_READ | PROT_WRITE | PROT_EXEC, |
|
|
|
// MAP_ANONYMOUS | MAP_PRIVATE | MAP_32BIT, |
|
|
|
// 0, 0); |
|
|
|
// if (ptr == MAP_FAILED) { |
|
|
|
// perror("mmap"); |
|
|
|
// ptr = 0; |
|
|
|
// return; |
|
|
|
// } else { |
|
|
|
// memcpy(ptr, kJumpInstructions, sizeof(kJumpInstructions)); |
|
|
|
// *((uint64_t *)(ptr + kJumpAddress)) = (uint64_t)(&loc_eventProc); |
|
|
|
// msync(ptr, sizeof(kJumpInstructions), MS_INVALIDATE); |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
// long temp[2] = {(long)ptr, 0}; |
|
|
|
// Atom atom = XInternAtom(display, "_XEventProc", False); |
|
|
|
// XChangeProperty(display, window, atom, atom, 32, PropModeReplace, (unsigned char *)temp, 2); |
|
|
|
// #else |
|
|
|
// long temp[1] = {(long)(void *)(&loc_eventProc)}; |
|
|
|
// Atom atom = XInternAtom(display, "_XEventProc", False); |
|
|
|
// XChangeProperty(display, window, atom, atom, 32, PropModeReplace, (unsigned char *)temp, 1); |
|
|
|
// #endif |
|
|
|
// } |
|
|
|
#endif // BUILD_64 |
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------- lglw_window_open |
|
|
|