public static byte[] PackRpcDefinition(NtRpcDefinition def, out UIntPtr packedLen)
        {
            RpcEncoder enc = new RpcEncoder();
            enc.Write8((byte)def.Version);
            enc.WriteString(def.Name);

            int paramsSize = def.ParamsArray.Length;
            if (paramsSize > 0xff) paramsSize = 0xff;
            enc.Write8((byte)paramsSize);
            for (int i = 0; i < paramsSize; ++i)
            {
                enc.WriteType(def.ParamsArray[i].Value.Type);
                enc.WriteString(def.ParamsArray[i].Name);
                enc.WriteValue(def.ParamsArray[i].Value);
            }

            int resultsSize = def.ResultsArray.Length;
            if (resultsSize > 0xff) resultsSize = 0xff;
            enc.Write8((byte)resultsSize);
            for (int i = 0; i < resultsSize; ++i)
            {
                enc.WriteType(def.ResultsArray[i].Type);
                enc.WriteString(def.ResultsArray[i].Name);
            }
            packedLen = (UIntPtr)enc.Buffer.Length;
            return enc.Buffer;
        }
 public static byte[] PackRpcValues(params RpcValue[] values)
 {
     RpcEncoder enc = new RpcEncoder();
     foreach (var value in values)
     {
         enc.WriteValue(value);
     }
     return enc.Buffer;
 }