[Plugin SDK] Some VCMP functions cause a segmentation fault

Started by EK.IceFlake, Aug 26, 2018, 07:41 AM

Previous topic - Next topic

EK.IceFlake

I'm trying to create a C# plugin. I have a PlugunFunctions struct but unfortunately a few functions in it don't work.

If, for example, I execute
pluginFuncs.LogMessage("%s", "Hello World");
it prints Hello World.
If I execute
error = pluginFuncs.GetLastError();
Console.WriteLine(error);
it prints None.

However, if I execute, for example
pluginFuncs.SetMaxPlayers(54);
it causes a segmentation fault somewhere (gdb can't figure it out. it just shows the address of the location)
and if I execute
StringBuilder serverNameBuilder = new StringBuilder(129);
            VcmpError error = pluginFuncs.GetServerName(serverNameBuilder, (UIntPtr) 128);
            Console.WriteLine("Error code: " + error.ToString());
            Console.WriteLine("Server name: " + serverNameBuilder.ToString());
it causes a segmentation fault at strcpy.

Here's the relevant code: https://gist.github.com/iFlake/d0bd57a293d92790480535483de84e74

Any idea? I'm summoning @Stormeus since they're working on VC.Net.

Thanks.

EK.IceFlake

Solved. These functions are available after the server is initialized and not in VcmpPluginInit.