本文整理汇总了C++中MemBlock类的典型用法代码示例。如果您正苦于以下问题:C++ MemBlock类的具体用法?C++ MemBlock怎么用?C++ MemBlock使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MemBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetWindowLong
BOOL QSQL_DEF::UpdateOptions /* ---- Update Options ------------------ */
( HWND hDlg // window handle
)
/* Updates options. */
{ MemBlock mb; // memblock class
OBJECTID qsqlObj; // qsql object
Qsql *qsql; // qsql core info
qsqlObj = (OBJECTID) GetWindowLong(hDlg, DWL_USER); // gets object id
qsql = (Qsql *) mb.GetPointer(qsqlObj, QSQLCORE);
/* ---- updates row count ---- */
qsql->rowCount = GetDlgItemInt(hDlg, IDE_ROWCOUNT, NULL, FALSE);
/* ---- updates column separator ---- */
if (IsDlgButtonChecked(hDlg, IDD_TAB))
qsql->colSprtr = TAB;
else
if (IsDlgButtonChecked(hDlg, IDD_COMMA))
qsql->colSprtr = COMMA;
/* else Fall Through */
/* ---- updates oem ---- */
qsql->isOEM = IsDlgButtonChecked(hDlg, IDD_OEM);
return TRUE;
} // UpdateOptions
示例2: SendQueuedMessages
static void SendQueuedMessages()
{
byte buf[MEMCOPY_THRESHOLD];
size_t dataLen;
MemBlock * block;
for (;;)
{
if (!gPipe)
return;
dataLen = 0;
block = GetDataToSend(buf, dimof(buf), &dataLen);
byte *dataToSend = buf;
if (block) {
dataToSend = block->UnsentData();
dataLen = block->UnsentLen();
}
if (0 == dataLen) {
CrashIf(block);
return;
}
//lf("memtrace.dll: sending %d bytes", (int)dataLen);
WriteToPipe(dataToSend, dataLen);
if (block) {
block->sent += dataLen;
FreeBlock(block);
}
}
}
示例3: SetWindowLong
BOOL QSQL_DEF::InitOptionsDialog/* ---- Init Options -------------------- */
( HWND hDlg, // window handle
OBJECTID qsqlObj // qsql object
)
/* Inits options. */
{ MemBlock mb; // memblock class
Qsql *qsql; // qsql core info
AUtlCenterDialog(hDlg, 0);
SetWindowLong(hDlg, DWL_USER, (DWORD) qsqlObj); // saves object id
qsql = (Qsql *) mb.GetPointer(qsqlObj, QSQLCORE);
/* ---- inits row count ---- */
SetDlgItemInt(hDlg, IDE_ROWCOUNT, (WORD) qsql->rowCount, FALSE);
/* ---- inits row separator ---- */
switch (qsql->colSprtr)
{ case TAB:
CheckRadioButton(hDlg, IDD_TAB, IDD_COMMA, IDD_TAB);
break;
case COMMA:
CheckRadioButton(hDlg, IDD_TAB, IDD_COMMA, IDD_COMMA);
break;
/* default: Fall Through */
} // switch
/* ---- inits oem ---- */
CheckDlgButton(hDlg, IDD_OEM, qsql->isOEM);
return TRUE;
} // InitOptions
示例4: while
/*------------------------------------------------------------------------*\
| METHOD : OQcncShutdownMeth |
| DESCRIPTION : ODBC Connection object's destructor. |
| Novell, Inc., November 1, 1993. mw |
\*------------------------------------------------------------------------*/
void ALMAPI OQcncShutdownMeth
( pAEvtInfo, // event pointer
pAObjMessage // system pointer
)
{ MemBlock mb; // memblock class
long objIdx; // object index
OBJECTID qcncObj; // qcnc object
QcncCore *qcncCore; // qcnc core info
QCNC_FNC fnc; // qcnc_fnc class
qeSTATUS errorCode; // error code
objIdx = AOBJ_GETFIRSTKEY;
while((qcncObj = AObjGetNextObject(OTYPE_QCNC, &objIdx)) != 0)
{ /* ---- releases resources ---- */
qcncCore = (QcncCore *) mb.GetPointer(qcncObj, QCNCCORE);
if (qcncCore->isConnected)
{ fnc.CloseCursor(qcncObj); // closes the qsql cursors
errorCode = (*qe_Disconnect)(qcncCore->hdbc);
if (fnc.RecordError(qcncCore, errorCode))
AEvtPostSignalAtMark(qcncObj, QCNCIFERROR);
else
qcncCore->isConnected = FALSE;
} // if
if (qcncCore->errorCode != qeSUCCESS)
{ qcncCore->errorCode = qeSUCCESS;
MBFree(qcncCore->errorMsg);
} // if
} // while
if (sqlLib.IsLoadLib())
(*qe_LibTerm)();
} // OQcncShutdownMeth
示例5: m_free_
/*-----------------------------------------------------------------------------
* free
*----------------------------------------------------------------------------*/
void m_free_( void *memptr, char *file, int lineno )
{
MemBlock *block = NULL;
Bool result;
init_module();
/* if input is NULL, do nothing */
if ( memptr == NULL )
return;
block = find_block( memptr, file, lineno );
check( block, "memory free at %s:%d failed", file, lineno );
/* delete from list to avoid recursion atexit() if overflow */
DL_DELETE(g_mem_blocks, block );
/* check fences */
result = check_fences( block );
check( result, "memory free at %s:%d failed", file, lineno );
error:
/* delete memory blocks */
if ( block ) {
if ( block->destructor ) /* destroy children */
block->destructor( memptr ); /* user destructor */
free( block ); /* destroy itself */
}
}
示例6: UnlinkVad
/// <summary>
/// Unlink memory VAD node
/// </summary>
/// <param name="imageMem">Image to purge</param>
/// <returns>bool on success</returns>
bool MMap::UnlinkVad( const MemBlock& imageMem )
{
HANDLE hFile = CreateFile( _T( "\\\\.\\VadPurge" ), GENERIC_ALL, 0, NULL, OPEN_EXISTING, 0, NULL );
// Load missing driver
if (hFile == INVALID_HANDLE_VALUE)
{
std::wstring drvPath = Utils::GetExeDirectory() + L"\\";
if (IsWindows8Point1OrGreater())
drvPath += L"VadPurge81.sys";
else if(IsWindows8OrGreater())
drvPath += L"VadPurge8.sys";
else if(IsWindows7OrGreater())
drvPath += L"VadPurge7.sys";
NTSTATUS status = Utils::LoadDriver( L"VadPurge", drvPath );
if (status != ERROR_SUCCESS && status != STATUS_IMAGE_ALREADY_LOADED)
return false;
hFile = CreateFile( _T( "\\\\.\\VadPurge" ), GENERIC_ALL, 0, NULL, OPEN_EXISTING, 0, NULL );
}
//
// Lock pages in working set before unlinking
// UserMode page faults can't be resolved without VAD record
//
if (hFile != INVALID_HANDLE_VALUE)
{
//
// Adjust working set and lock pages
//
SIZE_T sizeMin = 0, sizeMax = 0;
BOOL ret = FALSE;
GetProcessWorkingSetSize( _process.core().handle(), &sizeMin, &sizeMax );
SetProcessWorkingSetSize( _process.core().handle(), sizeMin + imageMem.size(), sizeMax + imageMem.size() );
PVOID pBase = imageMem.ptr<PVOID>();
ULONG size = static_cast<ULONG>(imageMem.size());
NTSTATUS status = GET_IMPORT( NtLockVirtualMemory )(_process.core().handle(), &pBase, &size, 1);
// Continue only if pages are locked
if (status == STATUS_SUCCESS)
{
PURGE_DATA data = { _process.core().pid(), 1, { imageMem.ptr<ULONGLONG>(), imageMem.size() } };
DWORD junk = 0;
ret = DeviceIoControl( hFile, static_cast<DWORD>(IOCTL_VADPURGE_PURGE), &data, sizeof(data), NULL, 0, &junk, NULL );
}
CloseHandle( hFile );
return (status == STATUS_SUCCESS && ret == TRUE) ? true : false;
}
return false;
}
示例7: WriteFile
int WriteFile(const TCHAR* filePath,const MemBlock& pMemBlock){
HANDLE hFile = CreateFile((TCHAR*) filePath, GENERIC_WRITE, FILE_SHARE_READ, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
UINT32 un32NumberOfBytesWritten;
if (hFile != INVALID_HANDLE_VALUE){
// Write the bitmap header and bitmap bits to the file
BOOL ret = ::WriteFile(hFile, (LPCVOID) pMemBlock.GetDataPointer(), pMemBlock.GetSize(), (LPDWORD)&un32NumberOfBytesWritten, 0);
if(ret==0) woodychang0611::diagnostics::SendWarning(_T("File Write Failed!"));
CloseHandle(hFile);// Close the file
}
return 0;
}
示例8: AFuncReportResult
/*------------------------------------------------------------------------*\
| FUNCTION : OQcncGetErrorFunc |
| DESCRIPTION : Returns the most recent ODBC error code, and the |
| associated error message. |
| INPUT 1 : ODBC Connection: ODBC CONNECTION -- The ODBC Connection |
| object to get the error from. |
| OUTPUT 1(OPT): Error Number: NUMBER -- The returned ODBC error code. |
| OUTPUT 2(OPT): Error Message: TEXT -- The returned ODBC error message. |
| FLOW 1 : Fetched. |
| FLOW 2 : No Error. |
| Novell, Inc., November 1, 1993. mw |
\*------------------------------------------------------------------------*/
void ALMAPI OQcncGetErrorFunc
( pAEvtInfo, // event pointer
pAObjMessage theSystem // system pointer
)
{ MemBlock mb; // memblock class
OBJECTID qcncObj; // qcnc object (I: 1)
QcncCore *qcncCore; // qcnc core info
OBJECTID errorNmbrObj; // number object [O: 1]
OBJECTID errorMsgObj; // text object [O: 2]
if (!sqlLib.IsLoadLib()) // no library
if (!sqlLib.LoadLib())
{ AFuncReportResult(theSystem, 0, "ODBC Connection\r\n"
"Get Error: Couldn't find the Q+E ODBC DLL.");
return;
} // if
/* ---- FUNCTION INPUT 1 ---- */
qcncObj = AFuncGetTypedParameter(1, OTYPE_QCNC);
if (!(qcncCore = (QcncCore *) mb.GetPointer(qcncObj, QCNCCORE)))
{ AFuncReportResult(theSystem, 0, "ODBC Connection\r\n"
"Get Error: Couldn't get the ODBC Connection input parameter.");
return;
} // if
if (qcncCore->errorCode == qeSUCCESS)
{ /* ---- FLOW 2 (No Error) ---- */
AFuncReportResult(theSystem, 2, "");
return;
} // if
/* ---- FUNCTION OUTPUT 1 ---- */
if (!(errorNmbrObj = AObjCreate(OTYPE_NUMBER)))
{ AFuncReportResult(theSystem, 0, "ODBC Connection\r\n"
"Get Error: Couldn't create the Error Code output parameter.");
return;
} // if
ONmbrSetInteger(errorNmbrObj, qcncCore->errorCode, TRUE);
AFuncSetParameter(1, errorNmbrObj);
/* ---- FUNCTION OUTPUT 2 ---- */
if (!(errorMsgObj = AObjCreate(OTYPE_TEXT)))
{ AFuncReportResult(theSystem, 0, "ODBC Connection\r\n"
"Get Error: Couldn't create the Error Message output parameter.");
return;
} // if
OTextSetValueFromBuffer(errorMsgObj, qcncCore->errorMsg);
AFuncSetParameter(2, errorMsgObj);
/* ---- FLOW 1 (Fetched) ---- */
AFuncReportResult(theSystem, 1, "");
} // OQcncGetErrorFunc
示例9:
MemBlock::MemBlock(const MemBlock & memBlock)
{
_allocator = memBlock._allocator;
size_t iCapacity = memBlock.TotalSpace();
_begin = (char*)_allocator->Create(iCapacity);
if ( _begin == NULL )
{
return;
}
_end = _begin;
_blockEnd = _begin + iCapacity;
Append(memBlock._begin, memBlock.Size());
}
示例10: QueueMessageForSending
// transfers the data to a thread that does the actual sending
static void QueueMessageForSending(Vec<byte>& msg)
{
size_t len = msg.Size();
if (0 == len)
return;
MemBlock *block = GetBlock(len);
if (block) {
block->Append(msg.LendData(), len);
SetEvent(gSendThreadEvent);
} else {
lf("memtrace.dll: QueueMessageForSending() couldn't queu %d bytes", (int)len);
}
}
示例11: MemBlock
MemBlock(const MemBlock& rv) {
memcpy(c, rv.c, size);
refcount = 1;
blocknum = blockcount++;
print("copied block");
out << endl;
rv.print("from block");
}
示例12: checkErrorPropogation
static
int checkErrorPropogation( const shared_ptr<Cipher> &cipher,
int size, int byteToChange, const CipherKey &key )
{
MemBlock orig;
orig.allocate(size);
MemBlock data;
data.allocate(size);
for(int i=0; i<size; ++i)
{
unsigned char tmp = rand();
orig.data[i] = tmp;
data.data[i] = tmp;
}
if(size != FSBlockSize)
cipher->streamEncode( data.data, size, 0, key );
else
cipher->blockEncode( data.data, size, 0, key );
// intoduce an error in the encoded data, so we can check error propogation
if(byteToChange >= 0 && byteToChange < size)
{
unsigned char previousValue = data.data[byteToChange];
do
{
data.data[byteToChange] = rand();
} while(data.data[byteToChange] == previousValue);
}
if(size != FSBlockSize)
cipher->streamDecode( data.data, size, 0, key );
else
cipher->blockDecode( data.data, size, 0, key );
int numByteErrors = 0;
for(int i=0; i<size; ++i)
{
if( data.data[i] != orig.data[i] )
++numByteErrors;
}
return numByteErrors;
}
示例13: AFuncGetTypedParameter
/*------------------------------------------------------------------------*\
| FUNCTION : OQcncStatusFunc |
| DESCRIPTION : Returns whether the ODBC Connection object is currently |
| connected to the DBMS. |
| INPUT 1 : ODBC Connection: ODBC CONNECTION -- The ODBC Connection |
| object to get the status from. |
| OUTPUT : None. |
| FLOW 1 : Connected. |
| FLOW 2 : Not Connected. |
| Novell, Inc., November 1, 1993. mw |
\*------------------------------------------------------------------------*/
void ALMAPI OQcncStatusFunc
( pAEvtInfo, // event pointer
pAObjMessage theSystem // system pointer
)
{ MemBlock mb; // memblock class
OBJECTID qcncObj; // qcnc object (I: 1)
QcncCore *qcncCore; // qcnc core info
/* ---- FUNCTION INPUT 1 ---- */
qcncObj = AFuncGetTypedParameter(1, OTYPE_QCNC);
if (!(qcncCore = (QcncCore *) mb.GetPointer(qcncObj, QCNCCORE)))
{ AFuncReportResult(theSystem, 0, "ODBC Connection\r\n"
"Status: Couldn't get the ODBC Connection input parameter.");
return;
} // if
/* ---- FLOW 1 (Connected), OR FLOW 2 (Not Connected) ---- */
AFuncReportResult(theSystem, 1 + (qcncCore->isConnected == FALSE), "");
} // OQcncStatusFunc
示例14: ReadFile
int ReadFile(const TCHAR* filePath,MemBlock& pMemBlock){
HANDLE hFile = CreateFile((TCHAR*) filePath, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (hFile != INVALID_HANDLE_VALUE){
//Maximum File Size 4GB (2^32);
UINT32 un32FileSize;
UINT32 un32NumberOfBytesRead ;
un32FileSize =GetFileSize(hFile,NULL);
if(un32FileSize){
pMemBlock.SetSize(un32FileSize);
}
BOOL ret = ::ReadFile(hFile,(LPVOID) pMemBlock.GetDataPointer(), un32FileSize,(LPDWORD) &un32NumberOfBytesRead,0);
//
if(ret==0) woodychang0611::diagnostics::SendWarning(_T("File Read Failed!"));
CloseHandle(hFile);// Close the file
return 0;
}
return -1;
}
示例15: ConcealVad
NTSTATUS MMap::ConcealVad(const MemBlock& imageMem) {
return Driver().ConcealVAD(_process.Id(), imageMem.Ptr(), static_cast<uint32_t>(imageMem.Size()));
}