added user module

This commit is contained in:
2022-09-03 18:17:51 +08:00
parent 44ccc0b835
commit 4321422b4f
12 changed files with 60 additions and 29 deletions
+6
View File
@@ -80,6 +80,10 @@ void Context::init_session(){
void* Context::get_module_function(const char* fname){
auto fmap = static_cast<std::unordered_map<std::string, void*>*>
(this->module_function_maps);
//printf("%p\n", fmap->find("mydiv")->second);
for (const auto& [key, value] : *fmap){
printf("%s %p\n", key.c_str(), value);
}
auto ret = fmap->find(fname);
return ret == fmap->end() ? nullptr : ret->second;
}
@@ -141,7 +145,9 @@ int dll_main(int argc, char** argv, Context* cxt){
case 'F':
{
auto fname = n_recvd[i] + 1;
printf("%s: %p, %p\n", fname, user_module_handle, dlsym(user_module_handle, fname));
module_fn_map->insert_or_assign(fname, dlsym(user_module_handle, fname));
printf("%p\n", module_fn_map->find("mydiv") != module_fn_map->end() ? module_fn_map->find("mydiv")->second : nullptr);
}
break;
case 'U':