call function in unrelated executable linux

可紊 提交于 2019-12-01 11:45:43

If you have control over the other executable (the one you want to call a function from), then build it as a PIE (position-independent executable), and load it into the first executable's address space.

In C, you would build with -fPIC -pie, then use dlopen(3) and dlsym(3).

In BASIC, I have no clue ;-(

It's not so much that you're "not allowed to access" the address space of the other function, but rather that that space is a totally different and unrelated address space. Each process has its own virtual address space, so the numeric value of your pointer has no meaning inside another functions address space, even if you were able to exchange it somehow.

For general inter-process communication you usually request shared memory explicitly from the system, but I'm not sure if FreeBasic exposes such functionality. Why not look up some existing remote procedure call libraries?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!