开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (3)
标签 (3)
master
zadjii-msft-patch-readme
richturn/retarget-echocon
1904.29002
1810.02002
1708.14008
master
分支 (3)
标签 (3)
master
zadjii-msft-patch-readme
richturn/retarget-echocon
1904.29002
1810.02002
1708.14008
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (3)
标签 (3)
master
zadjii-msft-patch-readme
richturn/retarget-echocon
1904.29002
1810.02002
1708.14008
Terminal
/
src
/
server
/
ApiMessage.cpp
Terminal
/
src
/
server
/
ApiMessage.cpp
ApiMessage.cpp 6.95 KB
一键复制 编辑 原始数据 按行查看 历史
Dustin Howett 提交于 2019年05月03日 06:29 +08:00 . Initial release of the Windows Terminal source code
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "precomp.h"
#include <intsafe.h>
#include "ApiMessage.h"
#include "DeviceComm.h"
_CONSOLE_API_MSG::_CONSOLE_API_MSG() :
_pDeviceComm(nullptr),
_pApiRoutines(nullptr)
{
ZeroMemory(this, sizeof(_CONSOLE_API_MSG));
}
ConsoleProcessHandle* _CONSOLE_API_MSG::GetProcessHandle() const
{
return reinterpret_cast<ConsoleProcessHandle*>(Descriptor.Process);
}
ConsoleHandleData* _CONSOLE_API_MSG::GetObjectHandle() const
{
return reinterpret_cast<ConsoleHandleData*>(Descriptor.Object);
}
// Routine Description:
// - This routine reads some or all of the input payload of the given message (depending on the given offset).
// Arguments:
// - cbOffset - Supplies the offset in bytes from which to start reading the payload.
// - pvBuffer - Receives the payload.
// - cbSize - Supplies the number of bytes to be read into the buffer.
// Return Value:
// - HRESULT indicating if the payload was successfully read.
[[nodiscard]]
HRESULT _CONSOLE_API_MSG::ReadMessageInput(const ULONG cbOffset,
_Out_writes_bytes_(cbSize) PVOID pvBuffer,
const ULONG cbSize)
{
CD_IO_OPERATION IoOperation;
IoOperation.Identifier = Descriptor.Identifier;
IoOperation.Buffer.Offset = State.ReadOffset + cbOffset;
IoOperation.Buffer.Data = pvBuffer;
IoOperation.Buffer.Size = cbSize;
return _pDeviceComm->ReadInput(&IoOperation);
}
// Routine Description:
// - This routine retrieves the input buffer associated with this message. It will allocate one if needed.
// - Before completing the message, ReleaseMessageBuffers must be called to free any allocation performed by this routine.
// Arguments:
// - Message - Supplies the message whose input buffer will be retrieved.
// - Buffer - Receives a pointer to the input buffer.
// - Size - Receives the size, in bytes, of the input buffer.
// Return Value:
// - HRESULT indicating if the input buffer was successfully retrieved.
[[nodiscard]]
HRESULT _CONSOLE_API_MSG::GetInputBuffer(_Outptr_result_bytebuffer_(*pcbSize) void** const ppvBuffer,
_Out_ ULONG* const pcbSize)
{
// Initialize the buffer if it hasn't been initialized yet.
if (State.InputBuffer == nullptr)
{
RETURN_HR_IF(E_FAIL, State.ReadOffset > Descriptor.InputSize);
ULONG const cbReadSize = Descriptor.InputSize - State.ReadOffset;
wistd::unique_ptr<BYTE[]> pPayload = wil::make_unique_nothrow<BYTE[]>(cbReadSize);
RETURN_IF_NULL_ALLOC(pPayload);
RETURN_IF_FAILED(ReadMessageInput(0, pPayload.get(), cbReadSize));
State.InputBuffer = pPayload.release(); // TODO: MSFT: 9565140 - don't release, maintain as smart pointer.
State.InputBufferSize = cbReadSize;
}
// Return the buffer.
*ppvBuffer = State.InputBuffer;
*pcbSize = State.InputBufferSize;
return S_OK;
}
// Routine Description:
// - This routine retrieves the output buffer associated with this message. It will allocate one if needed.
// The allocated will be bigger than the actual output size by the requested factor.
// - Before completing the message, ReleaseMessageBuffers must be called to free any allocation performed by this routine.
// Arguments:
// - Factor - Supplies the factor to multiply the allocated buffer by.
// - Buffer - Receives a pointer to the output buffer.
// - Size - Receives the size, in bytes, of the output buffer.
// Return Value:
// - HRESULT indicating if the output buffer was successfully retrieved.
[[nodiscard]]
HRESULT _CONSOLE_API_MSG::GetAugmentedOutputBuffer(const ULONG cbFactor,
_Outptr_result_bytebuffer_(*pcbSize) PVOID * const ppvBuffer,
_Out_ PULONG pcbSize)
{
// Initialize the buffer if it hasn't been initialized yet.
if (State.OutputBuffer == nullptr)
{
RETURN_HR_IF(E_FAIL, State.WriteOffset > Descriptor.OutputSize);
ULONG cbWriteSize = Descriptor.OutputSize - State.WriteOffset;
RETURN_IF_FAILED(ULongMult(cbWriteSize, cbFactor, &cbWriteSize));
BYTE* pPayload = new(std::nothrow) BYTE[cbWriteSize];
RETURN_IF_NULL_ALLOC(pPayload);
ZeroMemory(pPayload, sizeof(BYTE) * cbWriteSize);
State.OutputBuffer = pPayload; // TODO: MSFT: 9565140 - maintain as smart pointer.
State.OutputBufferSize = cbWriteSize;
}
// Return the buffer.
*ppvBuffer = State.OutputBuffer;
*pcbSize = State.OutputBufferSize;
return S_OK;
}
// Routine Description:
// - This routine retrieves the output buffer associated with this message. It will allocate one if needed.
// - Before completing the message, ReleaseMessageBuffers must be called to free any allocation performed by this routine.
// Arguments:
// - Message - Supplies the message whose output buffer will be retrieved.
// - Buffer - Receives a pointer to the output buffer.
// - Size - Receives the size, in bytes, of the output buffer.
// Return Value:
// - HRESULT indicating if the output buffer was successfully retrieved.
[[nodiscard]]
HRESULT _CONSOLE_API_MSG::GetOutputBuffer(_Outptr_result_bytebuffer_(*pcbSize) void** const ppvBuffer,
_Out_ ULONG * const pcbSize)
{
return GetAugmentedOutputBuffer(1, ppvBuffer, pcbSize);
}
// Routine Description:
// - This routine releases output or input buffers that might have been allocated
// during the processing of the given message. If the current completion status
// of the message indicates success, this routine also writes the output buffer
// (if any) to the message.
// Arguments:
// - <none>
// Return Value:
// - HRESULT indicating if the payload was successfully written if applicable.
[[nodiscard]]
HRESULT _CONSOLE_API_MSG::ReleaseMessageBuffers()
{
HRESULT hr = S_OK;
if (State.InputBuffer != nullptr)
{
delete[] State.InputBuffer;
State.InputBuffer = nullptr;
}
if (State.OutputBuffer != nullptr)
{
if (NT_SUCCESS(Complete.IoStatus.Status))
{
CD_IO_OPERATION IoOperation;
IoOperation.Identifier = Descriptor.Identifier;
IoOperation.Buffer.Offset = State.WriteOffset;
IoOperation.Buffer.Data = State.OutputBuffer;
IoOperation.Buffer.Size = (ULONG)Complete.IoStatus.Information;
LOG_IF_FAILED(_pDeviceComm->WriteOutput(&IoOperation));
}
delete[] State.OutputBuffer;
State.OutputBuffer = nullptr;
}
return hr;
}
void _CONSOLE_API_MSG::SetReplyStatus(const NTSTATUS Status)
{
Complete.IoStatus.Status = Status;
}
void _CONSOLE_API_MSG::SetReplyInformation(const ULONG_PTR pInformation)
{
Complete.IoStatus.Information = pInformation;
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

The new Windows Terminal, and the original Windows console host -- all in the same place!
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/AbstractFactory/Terminal.git
git@gitee.com:AbstractFactory/Terminal.git
AbstractFactory
Terminal
Terminal
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /