Exemplo n.º 1
0
        public void DeviceIOControl(NtHandle handle, uint ctlCode, byte[] input, out byte[]?output, int maxOutputLength)
        {
            output = null;

            IOCtlRequest request = new IOCtlRequest
            {
                Header            = { CreditCharge = (ushort)Math.Ceiling((double)maxOutputLength / BytesPerCredit) },
                CtlCode           = ctlCode,
                IsFSCtl           = true,
                FileId            = (FileID)handle,
                Input             = input,
                MaxOutputResponse = (uint)maxOutputLength
            };

            SendCommand(request);
            SMB2Command response = WaitForCommand(request.MessageID);

            response.IsSuccessOrBufferOverflowElseThrow();
            if (response is IOCtlResponse ioCtlResponse)
            {
                output = ioCtlResponse.Output;
            }
        }