コード例 #1
0
        public static void CreateRpc(string name, NtRpcDefinition def, RpcCallback callback)
        {
            Interop.NT_RPCCallback modCallback =
                (IntPtr data, IntPtr ptr, UIntPtr len, IntPtr intPtr, UIntPtr paramsLen, out UIntPtr resultsLen) =>
            {
                string retName = CoreMethods.ReadUTF8String(ptr, len);
                byte[] param   = CoreMethods.GetRawDataFromPtr(intPtr, paramsLen);
                byte[] cb      = callback(retName, param);
                resultsLen = (UIntPtr)cb.Length;
                IntPtr retPtr = Interop.NT_AllocateCharArray(resultsLen);
                Marshal.Copy(cb, 0, retPtr, cb.Length);
                return(retPtr);
            };

            UIntPtr packedLen;

            byte[]  packed = PackRpcDefinition(def, out packedLen);
            UIntPtr nameLen;

            byte[] nameB = CoreMethods.CreateUTF8String(name, out nameLen);
            Interop.NT_CreateRpc(nameB, nameLen, packed, packedLen, IntPtr.Zero, modCallback);
            s_rpcCallbacks.Add(modCallback);
        }