本文整理汇总了C++中framework::CMemStream类的典型用法代码示例。如果您正苦于以下问题:C++ CMemStream类的具体用法?C++ CMemStream怎么用?C++ CMemStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CMemStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CoMarshalInterface
void CWin32EmbedServer::WriteInterfaceToConsole()
{
Framework::CMemStream marshalStream;
{
auto comStream = Framework::Win32::CComPtr<Framework::Win32::CComStreamAdapter>(
new Framework::Win32::CComStreamAdapter(marshalStream));
DWORD dstContext = 0;
HRESULT result = S_OK;
result = CoMarshalInterface(comStream, IID_IEmbedApplication, this, MSHCTX_LOCAL, NULL, 0);
assert(SUCCEEDED(result));
}
{
BOOL result = FALSE;
DWORD numberWritten = 0;
HANDLE stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
assert(stdoutHandle != 0);
DWORD marshalSize = marshalStream.GetLength();
result = WriteFile(stdoutHandle, &marshalSize, sizeof(DWORD), &numberWritten, nullptr);
assert(result);
assert(numberWritten == sizeof(DWORD));
result = WriteFile(stdoutHandle, marshalStream.GetBuffer(), marshalSize, &numberWritten, nullptr);
assert(result);
assert(numberWritten == marshalSize);
}
}
示例2: Compile
void CMemAccessRefTest::Compile(Jitter::CJitter& jitter)
{
Framework::CMemStream codeStream;
jitter.SetStream(&codeStream);
jitter.Begin();
{
//Read ref test
{
jitter.PushRelRef(offsetof(CONTEXT, memory));
jitter.PushCst(LOAD_IDX * sizeof(void*));
jitter.AddRef();
jitter.LoadRefFromRef();
jitter.LoadFromRef();
jitter.PullRel(offsetof(CONTEXT, readValueResult));
}
EmitNullTest(jitter, NULLCHECK_IDX, offsetof(CONTEXT, nullCheck0));
EmitNullTest(jitter, LOAD_IDX, offsetof(CONTEXT, nullCheck1));
EmitNullComparison(jitter, NULLCHECK_IDX, offsetof(CONTEXT, nullCheck2));
EmitNullComparison(jitter, LOAD_IDX, offsetof(CONTEXT, nullCheck3));
}
jitter.End();
m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
示例3: Compile
void CFpIntMixTest::Compile(Jitter::CJitter& jitter)
{
Framework::CMemStream codeStream;
jitter.SetStream(&codeStream);
jitter.Begin();
{
//number1 = 100.f
jitter.PushCst(0x42C80000);
jitter.PullRel(offsetof(CONTEXT, number1));
//number2 = toFloat(multiplier)
jitter.FP_PushWord(offsetof(CONTEXT, multiplier));
jitter.FP_PullSingle(offsetof(CONTEXT, number2));
//number1 = number1 * number2
jitter.FP_PushSingle(offsetof(CONTEXT, number1));
jitter.FP_PushSingle(offsetof(CONTEXT, number2));
jitter.FP_Mul();
jitter.FP_PullSingle(offsetof(CONTEXT, number1));
//number1 = toInt(number1)
jitter.FP_PushSingle(offsetof(CONTEXT, number1));
jitter.FP_PullWordTruncate(offsetof(CONTEXT, number1));
//result = number1
jitter.PushRel(offsetof(CONTEXT, number1));
jitter.PullRel(offsetof(CONTEXT, result));
}
jitter.End();
m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
示例4: dialogTemplateStream
CDialog::CDialog(const TCHAR* resourceName, HWND parentWnd)
: m_isModal(false)
{
DIALOGTEMPLATE dialogTemplate;
{
HRSRC resourceSrc = FindResource(GetModuleHandle(NULL), resourceName, RT_DIALOG);
DWORD resourceSize = SizeofResource(GetModuleHandle(NULL), resourceSrc);
HGLOBAL resourceHandle = LoadResource(GetModuleHandle(NULL), resourceSrc);
DLGTEMPLATE* dialogTemplateSrc = reinterpret_cast<DLGTEMPLATE*>(LockResource(resourceHandle));
Framework::CPtrStream dialogTemplateStream(dialogTemplateSrc, resourceSize);
dialogTemplate = ReadDialogTemplate(dialogTemplateStream);
UnlockResource(resourceHandle);
}
NONCLIENTMETRICS metrics;
CDefaultFonts::GetNonClientMetrics(metrics);
dialogTemplate.pointsize = -MulDiv(metrics.lfMessageFont.lfHeight, 72, GetDeviceCaps(GetDC(NULL), LOGPIXELSY));
dialogTemplate.weight = static_cast<WORD>(metrics.lfMessageFont.lfWeight);
dialogTemplate.italic = metrics.lfMessageFont.lfItalic;
dialogTemplate.charset = metrics.lfMessageFont.lfCharSet;
dialogTemplate.typeface = metrics.lfMessageFont.lfFaceName;
{
Framework::CMemStream dialogTemplateStream;
WriteDialogTemplate(dialogTemplate, dialogTemplateStream);
m_hWnd = CreateDialogIndirect(GetModuleHandle(NULL),
reinterpret_cast<LPDLGTEMPLATE>(dialogTemplateStream.GetBuffer()), parentWnd, &CDialog::DialogProc);
}
}
示例5: CMemoryFunction
void CAliasTest2::Compile(Jitter::CJitter& jitter)
{
Framework::CMemStream codeStream;
jitter.SetStream(&codeStream);
jitter.Begin();
{
jitter.PushCst(CONSTANT_1);
jitter.PullRel(offsetof(CONTEXT, value1[0]));
jitter.PushCst(CONSTANT_2);
jitter.PullRel(offsetof(CONTEXT, value1[1]));
jitter.PushCst(CONSTANT_3);
jitter.PullRel(offsetof(CONTEXT, value1[2]));
jitter.PushCst(CONSTANT_4);
jitter.PullRel(offsetof(CONTEXT, value1[3]));
jitter.MD_PushRel(offsetof(CONTEXT, value2));
jitter.MD_PushRelExpand(offsetof(CONTEXT, value1[2]));
jitter.MD_AddS();
jitter.MD_PullRel(offsetof(CONTEXT, value1), true, true, true, false);
//Here value1 should be (3, 3, 3, 4)
jitter.MD_PushRel(offsetof(CONTEXT, value2));
jitter.MD_PushRelExpand(offsetof(CONTEXT, value1[2]));
jitter.MD_AddS();
jitter.MD_PullRel(offsetof(CONTEXT, value3));
//Here value3 should be (4, 4, 4, 4)
}
jitter.End();
m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
示例6: Compile
void CSimpleMdTest::Compile(Jitter::CJitter& jitter)
{
Framework::CMemStream codeStream;
jitter.SetStream(&codeStream);
jitter.Begin();
{
jitter.MD_PushRel(offsetof(CONTEXT, op1));
jitter.MD_PushRel(offsetof(CONTEXT, op2));
jitter.MD_AddW();
jitter.MD_PullRel(offsetof(CONTEXT, result));
}
jitter.End();
m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
示例7: CompileFunction
unsigned int CompileFunction(CPsfVm& virtualMachine, CMipsJitter* jitter, const std::vector<uint32>& blockCode, Jitter::CObjectFile& objectFile, const std::string& functionName, uint32 begin, uint32 end)
{
auto& context = virtualMachine.GetCpu();
uint8* ram = virtualMachine.GetRam();
for(uint32 address = begin; address <= end; address += 4)
{
*reinterpret_cast<uint32*>(&ram[address]) = blockCode[(address - begin) / 4];
}
{
Framework::CMemStream outputStream;
Jitter::CObjectFile::INTERNAL_SYMBOL func;
jitter->GetCodeGen()->SetExternalSymbolReferencedHandler(
[&] (void* symbol, uint32 offset)
{
Jitter::CObjectFile::SYMBOL_REFERENCE ref;
ref.offset = offset;
ref.type = Jitter::CObjectFile::SYMBOL_TYPE_EXTERNAL;
ref.symbolIndex = objectFile.GetExternalSymbolIndexByValue(symbol);
func.symbolReferences.push_back(ref);
}
);
jitter->SetStream(&outputStream);
jitter->Begin();
for(uint32 address = begin; address <= end; address += 4)
{
context.m_pArch->CompileInstruction(address, jitter, &context);
//Sanity check
assert(jitter->IsStackEmpty());
}
jitter->End();
func.name = functionName;
func.data = std::vector<uint8>(outputStream.GetBuffer(), outputStream.GetBuffer() + outputStream.GetSize());
func.location = Jitter::CObjectFile::INTERNAL_SYMBOL_LOCATION_TEXT;
return objectFile.AddInternalSymbol(func);
}
}
示例8: HasPacket
bool CPacketUtils::HasPacket(Framework::CMemStream& stream)
{
if (stream.GetSize() < sizeof(PACKETHEADER))
{
return false;
}
stream.Seek(0, Framework::STREAM_SEEK_SET);
PACKETHEADER header;
stream.Read(&header, sizeof(PACKETHEADER));
stream.Seek(0, Framework::STREAM_SEEK_END);
if (stream.GetSize() < header.packetSize)
{
return false;
}
return true;
}
示例9: Compile
void CMemAccessTest::Compile(Jitter::CJitter& jitter)
{
Framework::CMemStream codeStream;
jitter.SetStream(&codeStream);
jitter.Begin();
{
//Store test
jitter.PushRelRef(offsetof(CONTEXT, memory));
jitter.PushRel(offsetof(CONTEXT, offset));
jitter.AddRef();
jitter.PushCst(CONSTANT_1);
jitter.StoreAtRef();
//Read test
jitter.PushRelRef(offsetof(CONTEXT, memory));
jitter.PushCst(0x08);
jitter.AddRef();
jitter.LoadFromRef();
jitter.PullRel(offsetof(CONTEXT, result0));
//Write array test
jitter.PushRelAddrRef(offsetof(CONTEXT, array0));
jitter.PushCst(ARRAY_IDX_0 * 4);
jitter.AddRef();
jitter.PushCst(CONSTANT_2);
jitter.StoreAtRef();
//Read array test
jitter.PushRelAddrRef(offsetof(CONTEXT, array0));
jitter.PushCst(ARRAY_IDX_1 * 4);
jitter.AddRef();
jitter.LoadFromRef();
jitter.PullRel(offsetof(CONTEXT, result1));
}
jitter.End();
m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
示例10: ToString
std::string CEmbedRemoteCall::ToString() const
{
auto rpcParamsNode = new Framework::Xml::CNode("Params", true);
for(const auto& param : m_params)
{
auto rpcParamNode = new Framework::Xml::CNode("Param", true);
rpcParamNode->InsertAttribute(Framework::Xml::CreateAttributeStringValue("Name", param.first.c_str()));
rpcParamNode->InsertAttribute(Framework::Xml::CreateAttributeStringValue("Value", param.second.c_str()));
rpcParamsNode->InsertNode(rpcParamNode);
}
auto rpcNode = std::make_unique<Framework::Xml::CNode>("Call", true);
rpcNode->InsertAttribute(Framework::Xml::CreateAttributeStringValue("Method", m_method.c_str()));
rpcNode->InsertNode(rpcParamsNode);
Framework::CMemStream rpcNodeStream;
Framework::Xml::CWriter::WriteDocument(rpcNodeStream, rpcNode.get());
return std::string(rpcNodeStream.GetBuffer(), rpcNodeStream.GetBuffer() + rpcNodeStream.GetSize());
}
示例11: CMemoryFunction
void CAlu64Test::Compile(Jitter::CJitter& jitter)
{
Framework::CMemStream codeStream;
jitter.SetStream(&codeStream);
jitter.Begin();
{
jitter.PushRel64(offsetof(CONTEXT, value0));
jitter.PushRel64(offsetof(CONTEXT, value1));
jitter.Add64();
jitter.PullRel64(offsetof(CONTEXT, resultAdd0));
jitter.PushRel64(offsetof(CONTEXT, value2));
jitter.PushRel64(offsetof(CONTEXT, value3));
jitter.Add64();
jitter.PullRel64(offsetof(CONTEXT, resultAdd1));
jitter.PushRel64(offsetof(CONTEXT, value0));
jitter.PushCst64(CONSTANT_5);
jitter.Add64();
jitter.PullRel64(offsetof(CONTEXT, resultAddCst));
jitter.PushRel64(offsetof(CONTEXT, value0));
jitter.PushRel64(offsetof(CONTEXT, value1));
jitter.Sub64();
jitter.PullRel64(offsetof(CONTEXT, resultSub0));
jitter.PushRel64(offsetof(CONTEXT, value2));
jitter.PushRel64(offsetof(CONTEXT, value3));
jitter.Sub64();
jitter.PullRel64(offsetof(CONTEXT, resultSub1));
jitter.PushCst64(CONSTANT_5);
jitter.PushRel64(offsetof(CONTEXT, value0));
jitter.Sub64();
jitter.PullRel64(offsetof(CONTEXT, resultSubCst));
}
jitter.End();
m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
示例12: Compile
void CMdMemAccessTest::Compile(Jitter::CJitter& jitter)
{
Framework::CMemStream codeStream;
jitter.SetStream(&codeStream);
jitter.Begin();
{
jitter.PushRelRef(offsetof(CONTEXT, array));
jitter.MD_LoadFromRef();
jitter.MD_PullRel(offsetof(CONTEXT, result));
jitter.PushRelRef(offsetof(CONTEXT, array));
jitter.PushCst(0x10);
jitter.AddRef();
jitter.MD_PushRel(offsetof(CONTEXT, op));
jitter.MD_StoreAtRef();
}
jitter.End();
m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
示例13: sizeof
std::vector<uint8> CPacketUtils::ReadPacket(Framework::CMemStream& stream)
{
std::vector<uint8> result;
if(!CPacketUtils::HasPacket(stream))
{
assert(0);
return result;
}
stream.Seek(0, Framework::STREAM_SEEK_SET);
PACKETHEADER header;
stream.Read(&header, sizeof(PACKETHEADER));
if(header.packetSize < sizeof(PACKETHEADER))
{
//Invalid packet
CLog::GetInstance().LogError(LOG_NAME, "Packet size in header is invalid.\r\n");
return result;
}
stream.Seek(0, Framework::STREAM_SEEK_SET);
result.resize(header.packetSize);
stream.Read(&result[0], header.packetSize);
stream.Truncate();
stream.Seek(0, Framework::STREAM_SEEK_END);
return result;
}
示例14: CMemoryFunction
void CRandomAluTest3::Compile(Jitter::CJitter& jitter)
{
Framework::CMemStream codeStream;
jitter.SetStream(&codeStream);
jitter.Begin();
{
//a = b ^ a
if(m_useConstant)
{
jitter.PushCst(TEST_NUMBER1);
}
else
{
jitter.PushRel(offsetof(CONTEXT, number1));
}
if(m_useConstant)
{
jitter.PushCst(TEST_NUMBER2);
}
else
{
jitter.PushRel(offsetof(CONTEXT, number2));
}
jitter.Xor();
//b = a
jitter.PullRel(offsetof(CONTEXT, number1));
jitter.PushRel(offsetof(CONTEXT, number1));
jitter.PullRel(offsetof(CONTEXT, number2));
}
jitter.End();
m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}
示例15: Compile
void CMdFpFlagTest::Compile(Jitter::CJitter& jitter)
{
Framework::CMemStream codeStream;
jitter.SetStream(&codeStream);
jitter.Begin();
{
//0
jitter.MD_PushRel(offsetof(CONTEXT, src0));
jitter.MD_IsNegative();
jitter.PullRel(offsetof(CONTEXT, dstIsNegative0));
jitter.MD_PushRel(offsetof(CONTEXT, src0));
jitter.MD_IsZero();
jitter.PullRel(offsetof(CONTEXT, dstIsZero0));
//1
jitter.MD_PushRel(offsetof(CONTEXT, src1));
jitter.MD_IsNegative();
jitter.PullRel(offsetof(CONTEXT, dstIsNegative1));
jitter.MD_PushRel(offsetof(CONTEXT, src1));
jitter.MD_IsZero();
jitter.PullRel(offsetof(CONTEXT, dstIsZero1));
//2
jitter.MD_PushRel(offsetof(CONTEXT, src2));
jitter.MD_IsNegative();
jitter.PullRel(offsetof(CONTEXT, dstIsNegative2));
jitter.MD_PushRel(offsetof(CONTEXT, src2));
jitter.MD_IsZero();
jitter.PullRel(offsetof(CONTEXT, dstIsZero2));
}
jitter.End();
m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize());
}