You have a wrong declaration of RtlGetLastErrorString in your PInvoke signature which leads to heap corruptions.
In your C implementation you return the unicode string pointer which is wrong because .NET assumes that it was allocated with CoTaskMemAlloc and will try to free it which will lead to process terminations.
The fix is easy. Return a copy with the right allocator:
int len = (wcslen(LastError)+1)*sizeof(TCHAR);
PWCHAR pBuffer = (PWCHAR) CoTaskMemAlloc(len);
CopyMemory(pBuffer, LastError, len);
That will fix the issue.