Running the injection on Windows 10 64-bit worked without problem, but running it on a Windows XP 32-bit the line:
WriteProcessMemory(process, (PVOID)((loaderdata*)LoaderMemory + 1), LibraryLoader, LoaderCodeSize, NULL);
returned error 87 (ERROR_INVALID_PARAMETER).
The error was solved by changing the LoaderCodeSize parameter of the above mentioned line to:
ntHeaders->OptionalHeader.SizeOfHeapCommit - sizeof(loaderdata)
Now it works as expected on both systems.