Overwriting Blitz functions

Blitz3D Forums/Blitz3D Programming/Overwriting Blitz functions

bytecode77(Posted 2012) [#1]
Hi there,

is it somehow possible to overwrite a Blitz function, but still being able to call the original one like this:

 Function Graphics3D(width, height, mode, depth)
    CallOriginalFunction("Graphics3D", width, height, mode, depth)
    DoAdditionalStuff()
End Function


I could think of a way using CallDLL or WinAPI, but haven't found a way to do this yet. Any ideas?


Yasha(Posted 2012) [#2]
No, because the Blitz functions aren't actually exposed in any portable way. They're linked, mangled and hidden at compile-time. You can't even take function pointers to them safely.

But why would you want to do this? Specifically, why would you obscure the original if you still want to call it? Just... don't obscure the original. Since no B3D program ever exports names anyway, I can't really see why this would be a problem.


bytecode77(Posted 2012) [#3]
Well, actually I'm thinking of a re-invention of the old Devil-Engines into a more embedded way. Yet, all meshes have to be registered to the engine in some way and initialization / destruction has to be made. By overwriting functions like LoadMesh, CreateCube etc. I could simly gather a 'list' of all entities without the need of a 'registration function'. This offers a whole new level.

I wrote these engines several years ago, meanwhile I earned a lot of programming experience mainly in other languages like C# and PHP. But somehow I still like the engine of Blitz. Therefore I would like to make a valuable addition to the language.

Greetings.


bytecode77(Posted 2012) [#4]
From what I see, calling the function at least once, creates a string in the executable with this name:

_fgraphics3d


So it must be possible to call it. But what DLL name would I have to specify within CallDLL?


D4NM4N(Posted 2012) [#5]
The only way to do it is to create a second function with another identifier and call the first, or you can call the same function with a big case by parameteriszed ID to redirect it to the right "override"..
-neither of which is overriding at all, but that is what you get with non oop languages ;P


You can do it in max though

Last edited 2012