Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.6KB

  1. /*
  2. * Carla Interposer for unsafe backend functions
  3. * Copyright (C) 2014-2022 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "CarlaUtils.hpp"
  18. #include <cerrno>
  19. #include <dlfcn.h>
  20. #include <sched.h>
  21. #include <spawn.h>
  22. #define PREVENTED_FUNC_MSG carla_stderr2("Carla prevented a plugin from calling '%s', bad plugin!", __FUNCTION__)
  23. // -----------------------------------------------------------------------
  24. // Gtk stuff
  25. CARLA_PLUGIN_EXPORT void gtk_init(int*, char***);
  26. CARLA_PLUGIN_EXPORT int gtk_init_check(int*, char***);
  27. CARLA_PLUGIN_EXPORT int gtk_init_with_args(int*, char***, const char*, void*, const char*, void**);
  28. // -----------------------------------------------------------------------
  29. // Our custom functions
  30. CARLA_PLUGIN_EXPORT
  31. pid_t fork()
  32. {
  33. PREVENTED_FUNC_MSG;
  34. errno = ENOSYS;
  35. return -1;
  36. }
  37. CARLA_PLUGIN_EXPORT
  38. int clone(int (*)(void*), void*, int, void*, ...)
  39. {
  40. PREVENTED_FUNC_MSG;
  41. errno = ENOSYS;
  42. return -1;
  43. }
  44. CARLA_PLUGIN_EXPORT
  45. int posix_spawn(pid_t*, const char*, const posix_spawn_file_actions_t*, const posix_spawnattr_t*, char* const[], char* const[])
  46. {
  47. PREVENTED_FUNC_MSG;
  48. return ENOSYS;
  49. }
  50. CARLA_PLUGIN_EXPORT
  51. int posix_spawnp(pid_t*, const char*, const posix_spawn_file_actions_t*, const posix_spawnattr_t*, char* const[], char* const[])
  52. {
  53. PREVENTED_FUNC_MSG;
  54. return ENOSYS;
  55. }
  56. // -----------------------------------------------------------------------
  57. CARLA_PLUGIN_EXPORT
  58. void exit(int status)
  59. {
  60. carla_stderr2("Carla prevented a plugin from calling 'exit', redirecting to '_exit' instead, bad plugin!");
  61. _exit(status);
  62. }
  63. // -----------------------------------------------------------------------
  64. CARLA_PLUGIN_EXPORT
  65. void gtk_init(int*, char***)
  66. {
  67. PREVENTED_FUNC_MSG;
  68. }
  69. CARLA_PLUGIN_EXPORT
  70. int gtk_init_check(int*, char***)
  71. {
  72. PREVENTED_FUNC_MSG;
  73. return 0;
  74. }
  75. CARLA_PLUGIN_EXPORT
  76. int gtk_init_with_args(int*, char***, const char*, void*, const char*, void**)
  77. {
  78. PREVENTED_FUNC_MSG;
  79. return 0;
  80. }
  81. // -----------------------------------------------------------------------