Anyone know how to make an attribute in C# that will work for an external function?
I need to write an attribute to import shared objects (This is NOT for windows, I am developing a kernel in C# using a project called Cosmos, I recently finished my ELF32 loader and dynamic linker and which to write an attribute that will do this)
[SOImport("/lib/screen.so")]
extern void print(string text);
I have never really had to write my own attribute before, but I looked up some tutorials and could not find anything relating to external methods. I am assuming it returns some sort function pointer.
Assuming your
SOImportattribute would function like theDllImportattribute, you will not be able to use it. Cosmos does not support any P/Invoke operations. Anything used in a Cosmos OS must be written in a .NET language, not natively.