private static unsafe IPamMessage ReadBinaryInfo(PamMessage *messagePtr) { var binaryPtr = messagePtr->Message; var binary = (PamBinaryMessageData *)binaryPtr; var length = IPAddress.NetworkToHostOrder((int)binary->Length); var control = binary->Type; var data = new byte[length - 5]; Marshal.Copy(binaryPtr + 5, data, 0, length - 5); return(new PamBinaryPromptMessage(control, data)); }
private static unsafe IPamMessage ReadTextInfo(PamMessage *messagePtr, Func <string, IPamMessage> createMessageFunc) { var text = Marshal.PtrToStringUTF8(messagePtr->Message) ?? string.Empty; return(createMessageFunc(text)); }