C++
1#include <iostream>
2
3using func_ptr = int(*)(int,int);
4int func_def(int a, int b){return a + b;}
5int func_dll(int a, int b){return a * b;}
6static func_ptr ptr = func_def;
7
8int func(int a, int b){
9 return ptr(a, b);
10}
11
12void load(){
13 ptr = func_dll;
14}
15int main(){
16 std::cout << func(2, 3) << std::endl;
17 load();
18 std::cout << func(2, 3) << std::endl;
19}
方法論としては、こんな感じ
もし、DLLをライブラリの機能を使わずに読み込んだ場合もライブラリの機能を書き換えたい
ならば、ライブラリをDLLにし追加DLL読み込み時にライブラリがエクスポートする関数を呼び出して、みたいな感じ