| 729 | } |
| 730 | |
| 731 | nullres nullcSetFunction(const char* name, NULLCFuncPtr func) |
| 732 | { |
| 733 | using namespace NULLC; |
| 734 | NULLC_CHECK_INITIALIZED(false); |
| 735 | |
| 736 | unsigned int index = nullcFindFunctionIndex(name); |
| 737 | if(index == ~0u) |
| 738 | return false; |
| 739 | if(linker->exFunctions[func.id].funcCat != ExternFuncInfo::NORMAL) |
| 740 | { |
| 741 | nullcLastError = "ERROR: source function uses context, which is unavailable"; |
| 742 | return false; |
| 743 | } |
| 744 | if(nullcGetCurrentExecutor(NULL) == NULLC_X86) |
| 745 | { |
| 746 | linker->UpdateFunctionPointer(index, func.id); |
| 747 | if(linker->exFunctions[index].funcPtr && !linker->exFunctions[func.id].funcPtr) |
| 748 | { |
| 749 | nullcLastError = "Internal function cannot be overridden with external function on x86"; |
| 750 | return false; |
| 751 | } |
| 752 | if(linker->exFunctions[func.id].funcPtr && !linker->exFunctions[index].funcPtr) |
| 753 | { |
| 754 | nullcLastError = "External function cannot be overridden with internal function on x86"; |
| 755 | return false; |
| 756 | } |
| 757 | } |
| 758 | linker->exFunctions[index].address = linker->exFunctions[func.id].address; |
| 759 | linker->exFunctions[index].funcPtr = linker->exFunctions[func.id].funcPtr; |
| 760 | linker->exFunctions[index].codeSize = linker->exFunctions[func.id].codeSize; |
| 761 | return true; |
| 762 | } |
| 763 | |
| 764 | nullres nullcIsStackPointer(void* ptr) |
| 765 | { |