I'm trying to convert my simple script, to a C plugin...
First of all, I'm making an assumption that this is a Win32 plugin. Now, have you taken into consideration that the plugin executable code (or any type of Win32 executable or dll) must be wrapped by a PE (Portable Executable) structure which is used by the OS loader to manage the executable code? The PE format manages everything from API export/import tables to resource management to linking references.

If you haven't considered the PE format in your binary conversion, then you're really wasting your time on this conversion.