Closed ZeroLP closed 2 years ago
Solved it by abstractly having a null-terminated string and by pointing the char* into the pinvoke argument. Although I would like to know if there is another way of doing so. (As far as my theoretical knowledge goes, I can't figure out other than what I've done)
You can consider the source/project files in this repo public domain.
You can marshal things manually this way:
But since you're on Windows, consider calling into the W versions of APIs instead of the A variants - the *W expect null-terminated UTF-16, which happens to match how strings are laid out in .NET.
If you do that, you can just pass them with the fixed
keyword like it's done here:
As I was delving myself with building a simple driver with the combination of samples of noruntime and noruntime-efi, I was a bit stranded with having to marshal C# string to for case of to a c string (LPCSTR). Would it even be possible to marshal without a runtime? If it is, any suggestion or an idea of how to approach this issue?
Linking my project here for a more visual reference: https://github.com/ZeroLP/ZeroKernel (Hopefully I'm not violating any OSP license since I can't really find it in the official repo if there is one)