| 324 | } |
| 325 | |
| 326 | void CustomFunctionInjector::OnAfterGetFunctionMappings(void * Osiris, MappingInfo ** Mappings, uint32_t * MappingCount) |
| 327 | { |
| 328 | Debug("CustomFunctionInjector::OnAfterGetFunctionMappings(): No. funcs: %d", *MappingCount); |
| 329 | |
| 330 | CreateOsirisSymbolMap(Mappings, MappingCount); |
| 331 | gOsirisProxy->GetExtensionState().Reset(); |
| 332 | |
| 333 | // Remove local functions |
| 334 | auto outputIndex = 0; |
| 335 | osiToDivMappings_.clear(); |
| 336 | divToOsiMappings_.clear(); |
| 337 | for (unsigned i = 0; i < *MappingCount; i++) { |
| 338 | auto const & mapping = (*Mappings)[i]; |
| 339 | FunctionNameAndArity sig{ mapping.Name, mapping.NumParams }; |
| 340 | auto mapped = functions_.Find(sig); |
| 341 | if (mapped == nullptr) { |
| 342 | (*Mappings)[outputIndex++] = mapping; |
| 343 | } else { |
| 344 | osiToDivMappings_.insert(std::make_pair(mapping.Id, mapped->Handle())); |
| 345 | divToOsiMappings_.insert(std::make_pair(mapped->Handle(), mapping.Id)); |
| 346 | Debug("Function mapping (%s): %08x --> %08x", mapping.Name, mapping.Id, (unsigned int)mapped->Handle()); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | *MappingCount = outputIndex; |
| 351 | Debug("CustomFunctionInjector::OnAfterGetFunctionMappings(): No. funcs after filtering: %d", *MappingCount); |
| 352 | } |
| 353 | |
| 354 | bool CustomFunctionInjector::CallWrapper(std::function<bool (uint32_t, OsiArgumentDesc *)> const & next, uint32_t handle, OsiArgumentDesc * params) |
| 355 | { |