コード例 #1
0
ファイル: RtlReAllocateHeap.c プロジェクト: GYGit/reactos
static
BOOLEAN
ReAllocBuffer(
    PUCHAR *Buffer,
    SIZE_T Size,
    SIZE_T *OldSizePtr,
    PCSTR Action)
{
    PUCHAR NewBuffer;
    SIZE_T OldSize = *OldSizePtr;

    RtlFillMemory(*Buffer, OldSize, 0x7a);
    NewBuffer = RtlReAllocateHeap(RtlGetProcessHeap(),
                                  HEAP_ZERO_MEMORY,
                                  *Buffer,
                                  Size);
    if (!NewBuffer)
    {
        skip("RtlReAllocateHeap failed for size %lu (%s)\n", Size, Action);
        return FALSE;
    }
    *Buffer = NewBuffer;
    ok_hex(RtlSizeHeap(RtlGetProcessHeap(), 0, NewBuffer), Size);
    if (OldSize < Size)
    {
        ok(CheckBuffer(NewBuffer, OldSize, 0x7a), "CheckBuffer failed at size 0x%lx -> 0x%lx\n", OldSize, Size);
        ok(CheckBuffer(NewBuffer + OldSize, Size - OldSize, 0), "HEAP_ZERO_MEMORY not respected for 0x%lx -> 0x%lx\n", OldSize, Size);
    }
    else
    {
        ok(CheckBuffer(NewBuffer, Size, 0x7a), "CheckBuffer failed at size 0x%lx -> 0x%lx\n", OldSize, Size);
    }
    *OldSizePtr = Size;
    return TRUE;
}
コード例 #2
0
static
VOID
TestGetCurrentDirectoryW(VOID)
{
    WCHAR Buffer[MAX_PATH];
    DWORD Length;
    BOOL Ret;
    BOOLEAN Okay;

    Ret = SetCurrentDirectoryW(L"C:\\");
    ok(Ret == TRUE, "SetCurrentDirectory failed with %lu\n", GetLastError());

    Length = GetCurrentDirectoryW(0, NULL);
    ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);

    RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
    Length = GetCurrentDirectoryW(sizeof(Buffer) / sizeof(WCHAR), Buffer);
    ok(Length == sizeof("C:\\") - 1, "Length = %lu\n", Length);
    Okay = CheckStringBufferW(Buffer, sizeof(Buffer), L"C:\\", 0x55);
    ok(Okay, "CheckStringBufferW failed\n");

    RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
    Length = GetCurrentDirectoryW(0, Buffer);
    ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
    Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
    ok(Okay, "CheckBuffer failed\n");

    RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
    Length = GetCurrentDirectoryW(1, Buffer);
    ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
    Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
    ok(Okay, "CheckBuffer failed\n");

    RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
    Length = GetCurrentDirectoryW(2, Buffer);
    ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
    Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
    ok(Okay, "CheckBuffer failed\n");

    RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
    Length = GetCurrentDirectoryW(3, Buffer);
    ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
    Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
    ok(Okay, "CheckBuffer failed\n");

    RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
    Length = GetCurrentDirectoryW(4, Buffer);
    ok(Length == sizeof("C:\\") - 1, "Length = %lu\n", Length);
    Okay = CheckStringBufferW(Buffer, sizeof(Buffer), L"C:\\", 0x55);
    ok(Okay, "CheckStringBufferW failed\n");
}
コード例 #3
0
ファイル: if_python3.c プロジェクト: tonymagro/viw
static Py_ssize_t
BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val)
{
	if (PyLong_Check(idx)) {
		long n = PyLong_AsLong(idx);
		return RBAsItem((BufferObject *)(self), n, val, 1,
						(Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count,
						NULL);
	} else if (PySlice_Check(idx)) {
		Py_ssize_t start, stop, step, slicelen;

		if (CheckBuffer((BufferObject *) self))
			return -1;

		if (PySlice_GetIndicesEx((PySliceObject_T *)idx,
								 (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count,
								 &start, &stop,
								 &step, &slicelen) < 0) {
			return -1;
		}
		return RBAsSlice((BufferObject *)(self), start, stop, val, 1,
						 (PyInt)((BufferObject *)(self))->buf->b_ml.ml_line_count,
						 NULL);
	} else {
		RAISE_INVALID_INDEX_TYPE(idx);
		return -1;
	}
}
コード例 #4
0
ファイル: if_python.c プロジェクト: aosm/vim
    static PyInt
RBAssSlice(BufferObject *self, PyInt lo, PyInt hi, PyObject *val, PyInt start, PyInt end, PyInt *new_end)
{
    PyInt size;
    PyInt len_change;

    /* Self must be a valid buffer */
    if (CheckBuffer(self))
	return -1;

    /* Sort out the slice range */
    size = end - start + 1;

    if (lo < 0)
	lo = 0;
    else if (lo > size)
	lo = size;
    if (hi < 0)
	hi = 0;
    if (hi < lo)
	hi = lo;
    else if (hi > size)
	hi = size;

    if (SetBufferLineList(self->buf, lo + start, hi + start,
						    val, &len_change) == FAIL)
	return -1;

    if (new_end)
	*new_end = end + len_change;

    return 0;
}
コード例 #5
0
vncBuffer::vncBuffer(vncDesktop *desktop)
{
	m_desktop = desktop;
	m_encoder = NULL;
	zlib_encoder_in_use = false;
	m_hold_zlib_encoder = NULL;
	tight_encoder_in_use = false;
	m_hold_tight_encoder = NULL;
	zlibhex_encoder_in_use = false;
	m_hold_zlibhex_encoder = NULL;

	m_compresslevel = 6;
	m_qualitylevel = -1;
	m_use_xcursor = FALSE;
	m_use_richcursor = FALSE;
	m_use_lastrect = FALSE;

	m_hcursor = NULL;

	m_mainbuff = NULL;
	m_mainsize = 0;
	
	m_clientbuff = NULL;
	m_clientbuffsize = 0;
	m_clientfmtset = FALSE;

	// Initialise the screen buffers
	CheckBuffer();
}
コード例 #6
0
ファイル: ffApp.cpp プロジェクト: frimin/FancyFramework
char *ffBuffer::CheckBuffer(size_t needSize) {
    if (needSize > m_bufferSize) {
        /*首次申请*/
        if (m_pBuffer == 0) {
            m_bufferSize = 1024;
            m_pBuffer = new char[m_bufferSize];
            return CheckBuffer(needSize);
        }
        else {
            delete m_pBuffer;
            m_bufferSize *= 2;
            m_pBuffer = new char[m_bufferSize];
            return CheckBuffer(needSize);
        }
    }
    return m_pBuffer;
}
コード例 #7
0
void
vncBuffer::UpdateLocalFormat() {
	CheckBuffer();
	m_encoder->SetLocalFormat(
			m_scrinfo.format,
			m_scrinfo.framebufferWidth,
			m_scrinfo.framebufferHeight);
}
コード例 #8
0
    static Py_ssize_t
BufferLength(PyObject *self)
{
    if (CheckBuffer((BufferObject *)(self)))
	return -1;

    return (Py_ssize_t)(((BufferObject *)(self))->buf->b_ml.ml_line_count);
}
コード例 #9
0
ファイル: if_python.c プロジェクト: aosm/vim
    static PyInt
BufferLength(PyObject *self)
{
    /* HOW DO WE SIGNAL AN ERROR FROM THIS FUNCTION? */
    if (CheckBuffer((BufferObject *)(self)))
	return -1; /* ??? */

    return (((BufferObject *)(self))->buf->b_ml.ml_line_count);
}
コード例 #10
0
ファイル: 4SPEAKER.C プロジェクト: ddionisio/TaTaMahatta
/* play buffered sample data (right) */
DWORD CALLBACK stream_right(HSTREAM handle, short *buffer, DWORD length, BUFSTUFF *b)
{
	DWORD l;
	length/=2;
	CheckBuffer(b,b->readposr+length);
	if (length>b->writepos-b->readposr) length=b->writepos-b->readposr;
	for (l=0;l<length;l++) *buffer++=b->buf[(b->readposr+l)*2+1];
	b->readposr+=length;
	return length*2;
}
コード例 #11
0
ファイル: 4SPEAKER.C プロジェクト: ddionisio/TaTaMahatta
/* play buffered sample data (left) */
DWORD CALLBACK stream_left(HSTREAM handle, short *buffer, DWORD length, BUFSTUFF *b)
{
	DWORD l;
	length/=2; // bytes -> samples
	CheckBuffer(b,b->readposl+length);
	if (length>b->writepos-b->readposl) length=b->writepos-b->readposl;
	for (l=0;l<length;l++) *buffer++=b->buf[(b->readposl+l)*2];
	b->readposl+=length;
	return length*2;
}
コード例 #12
0
bool DrawBuffersIndexedBase::BlendMaskStateMachine::CheckAll()
{
	for (unsigned int i = 0; i < state.size(); ++i)
	{
		if (!CheckBuffer(i))
		{
			return false;
		}
	}
	return true;
}
コード例 #13
0
    static PyObject *
BufferGetattr(PyObject *self, char *name)
{
    PyObject *r;

    if (CheckBuffer((BufferObject *)(self)))
	return NULL;

    r = BufferAttr((BufferObject *)(self), name);
    if (r || PyErr_Occurred())
	return r;
    else
	return Py_FindMethod(BufferMethods, self, name);
}
コード例 #14
0
ファイル: haFile.hpp プロジェクト: brett19/mapimprose
	haReal32 ReadReal32( )
	{
		haReal32 tmp;
		if( !m_BufferEnabled )
		{
			fread( &tmp, 4, 1, m_File );
		}
		else
		{
			CheckBuffer( 4 );
			tmp = *((haReal32*)&m_Buffer[m_BufferCurrent-m_BufferOffset]);
			m_BufferCurrent += 4;
		}
		return tmp;
	};
コード例 #15
0
ファイル: haFile.hpp プロジェクト: brett19/mapimprose
	haInt16 ReadInt16( )
	{
		haInt16 tmp;
		if( !m_BufferEnabled )
		{
			fread( &tmp, 2, 1, m_File );
		}
		else
		{
			CheckBuffer( 2 );
			tmp = *((haInt16*)&m_Buffer[m_BufferCurrent-m_BufferOffset]);
			m_BufferCurrent += 2;
		}
		return tmp;
	};
コード例 #16
0
ファイル: haFile.hpp プロジェクト: brett19/mapimprose
	haInt8 ReadInt8( )
	{
		haInt8 tmp;
		if( !m_BufferEnabled )
		{
			fread( &tmp, 1, 1, m_File );
		}
		else
		{
			CheckBuffer( 1 );
			tmp = *((haInt8*)&m_Buffer[m_BufferCurrent-m_BufferOffset]);
			m_BufferCurrent += 1;
		}
		return tmp;
	};
コード例 #17
0
void InterdictionConnection::OnReceive(CAsyncSocket* src,byte *data,UINT length)
{
	MetaSpooferReference ref;
	CString log_msg;
	log_msg.Format("InterdictionConnection::OnReceive() %s STARTED.",m_ip.c_str());
	ref.System()->LogToFile(log_msg);
	//TRACE("Interdiction Connection %s hash %s: OnReceive()\n",m_ip.c_str(),m_str_target_hash.c_str());
	if(!mb_abort){
		m_idle_timer.Refresh();
		m_buffer.WriteBytes(data,length);
		CheckBuffer();
	}

	log_msg.Format("InterdictionConnection::OnReceive() %s FINISHED.",m_ip.c_str());
	ref.System()->LogToFile(log_msg);
}
コード例 #18
0
ファイル: haFile.hpp プロジェクト: brett19/mapimprose
	void EnableBuffer( haBool32 value )
	{
		if( value == m_BufferEnabled )
			return;

		if( value )
		{
			m_BufferEnabled = true;
			m_BufferOffset = 0;
			m_BufferCurrent = ftell( m_File );
			CheckBuffer( -1 );
		}
		else
		{
			m_BufferEnabled = false;
		}
	};
コード例 #19
0
BOOL
vncBuffer::SetClientFormat(rfbPixelFormat &format)
{
	// Save the desired format
	m_clientfmtset = TRUE;
	m_clientformat = format;

	// Tell the encoder of the new format
	if (m_encoder != NULL)
		m_encoder->SetRemoteFormat(format);

	// Check that the output buffer is sufficient
	if (!CheckBuffer())
		return FALSE;

	return TRUE;
}
コード例 #20
0
ファイル: if_python.c プロジェクト: aosm/vim
    static PyObject *
BufferGetattr(PyObject *self, char *name)
{
    BufferObject *this = (BufferObject *)(self);

    if (CheckBuffer(this))
	return NULL;

    if (strcmp(name, "name") == 0)
	return Py_BuildValue("s", this->buf->b_ffname);
    else if (strcmp(name, "number") == 0)
	return Py_BuildValue(Py_ssize_t_fmt, this->buf->b_fnum);
    else if (strcmp(name,"__members__") == 0)
	return Py_BuildValue("[ss]", "name", "number");
    else
	return Py_FindMethod(BufferMethods, self, name);
}
コード例 #21
0
ファイル: if_python3.c プロジェクト: tonymagro/viw
static PyObject *
BufferGetattro(PyObject *self, PyObject *nameobj)
{
	PyObject *r;

	GET_ATTR_STRING(name, nameobj);

	if ((r = BufferAttrValid((BufferObject *)(self), name)))
		return r;

	if (CheckBuffer((BufferObject *)(self)))
		return NULL;

	r = BufferAttr((BufferObject *)(self), name);
	if (r || PyErr_Occurred())
		return r;
	else
		return PyObject_GenericGetAttr(self, nameobj);
}
コード例 #22
0
ファイル: haFile.hpp プロジェクト: brett19/mapimprose
	haBool32 Seek( haInt32 value, haInt32 dir = SEEK_CUR )
	{
		if( !m_BufferEnabled )
		{
			fseek( m_File, value, dir );
		}
		else
		{
			if( dir == SEEK_SET )
			{
				m_BufferCurrent = value;
			}
			else if( dir == SEEK_CUR )
			{
				m_BufferCurrent += value;
			}
			CheckBuffer( 0 );
		}
		return true;
	};
コード例 #23
0
ファイル: ShmSystemV.cpp プロジェクト: Bella42/ADIOS2
void ShmSystemV::Open(const std::string &name, const Mode openMode)
{
    m_Name = name;
    CheckName();
    m_OpenMode = openMode;

    // not using const
    key_t key = ftok(m_Name.c_str(), static_cast<int>(m_ProjectID));

    switch (m_OpenMode)
    {
    case (Mode::Write):
        ProfilerStart("open");
        m_ShmID = shmget(key, m_Size, IPC_CREAT | 0666);
        ProfilerStop("open");
        break;

    case (Mode::Append):
        ProfilerStart("open");
        m_ShmID = shmget(key, m_Size, 0);
        ProfilerStop("open");
        break;

    case (Mode::Read):
        ProfilerStart("open");
        m_ShmID = shmget(key, m_Size, 0);
        ProfilerStop("open");
        break;

    default:
        throw std::invalid_argument(
            "ERROR: unknown open mode for shared memory segment " + m_Name +
            ", in call to SystemV Open");
    }

    CheckShmID("in call to ShmSystemV shmget at Open");

    m_Buffer = static_cast<char *>(shmat(m_ShmID, nullptr, 0));
    CheckBuffer("in call to SystemV shmat at Open");
    m_IsOpen = false;
}
コード例 #24
0
    static PyObject *
BufferGetattro(PyObject *self, PyObject*nameobj)
{
    BufferObject *this = (BufferObject *)(self);

    char *name = "";
    if (PyUnicode_Check(nameobj))
	name = _PyUnicode_AsString(nameobj);

    if (CheckBuffer(this))
	return NULL;

    if (strcmp(name, "name") == 0)
	return Py_BuildValue("s", this->buf->b_ffname);
    else if (strcmp(name, "number") == 0)
	return Py_BuildValue("n", this->buf->b_fnum);
    else if (strcmp(name,"__members__") == 0)
	return Py_BuildValue("[ss]", "name", "number");
    else
	return PyObject_GenericGetAttr(self, nameobj);
}
コード例 #25
0
ファイル: if_python3.c プロジェクト: tonymagro/viw
static PyObject *
BufferSubscript(PyObject *self, PyObject* idx)
{
	if (PyLong_Check(idx)) {
		long _idx = PyLong_AsLong(idx);
		return BufferItem((BufferObject *)(self), _idx);
	} else if (PySlice_Check(idx)) {
		Py_ssize_t start, stop, step, slicelen;

		if (CheckBuffer((BufferObject *) self))
			return NULL;

		if (PySlice_GetIndicesEx((PySliceObject_T *)idx,
								 (Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count,
								 &start, &stop,
								 &step, &slicelen) < 0) {
			return NULL;
		}
		return BufferSlice((BufferObject *)(self), start, stop);
	} else {
		RAISE_INVALID_INDEX_TYPE(idx);
		return NULL;
	}
}
コード例 #26
0
ファイル: haFile.hpp プロジェクト: brett19/mapimprose
	haBool32 Read( void* buffer, haInt32 amount )
	{
		if( !m_BufferEnabled )
		{
			fread( buffer, 1, amount, m_File );
		}
		else
		{
			if( amount < HAFILE_BUFFERSIZE )
			{
				CheckBuffer( amount );
				memcpy( buffer, &m_Buffer[m_BufferCurrent-m_BufferOffset], amount );
				m_BufferCurrent += amount;
			}
			else
			{
				fseek( m_File, m_BufferCurrent, SEEK_SET );
				fread( buffer, 1, amount, m_File );
				m_BufferCurrent += amount;
				m_BufferOffset = m_BufferCurrent;
			}
		}
		return true;
	};
コード例 #27
0
GLDEF_C TInt E32Main()
    {
	TBuf16<512> cmd;
	User::CommandLine(cmd);
	if(cmd.Length() && TChar(cmd[0]).IsDigit())
		{
		TInt function = -1;
		TInt arg1 = -1;
		TInt arg2 = -1;
		TLex lex(cmd);
		lex.Val(function);
		lex.SkipSpace();
		lex.Val(arg1);
		lex.SkipSpace();
		lex.Val(arg2);
		return DoTestProcess(function,arg1,arg2);
		}

	MemModelAttributes=UserSvr::HalFunction(EHalGroupKernel, EKernelHalMemModelInfo, NULL, NULL);
	TUint mm=MemModelAttributes&EMemModelTypeMask;
	PhysicalCommitSupported = mm!=EMemModelTypeDirect && mm!=EMemModelTypeEmul;

// Turn off lazy dll unloading
	RLoader l;
	test(l.Connect()==KErrNone);
	test(l.CancelLazyDllUnload()==KErrNone);
	l.Close();

	test.Title();

#if defined(__FIXED__) || defined(__SECOND_FIXED__) || defined(__MOVING_FIXED__)
	if(mm!=EMemModelTypeMoving)
		{
		test.Printf(_L("TESTS NOT RUN - Only applicable to moving memory model\r\n"));
		return 0;
		}
#endif

	test.Start(_L("Loading test driver..."));

	TInt r;
	r=User::LoadLogicalDevice(KSharedIoTestLddName);
	test(r==KErrNone || r==KErrAlreadyExists);
	r=User::LoadLogicalDevice(KSharedIoTestLddName);
	test(r==KErrAlreadyExists);
	r=ldd.Open();
	test(r==KErrNone);

	TAny* buffer;
	TUint32 size;
	TUint32 key;

	TInt testBufferSize=0;
	for(; TestBufferSizes[testBufferSize]!=0; ++testBufferSize)
		{
		test.Printf(_L("Test buffer size = %08x\n"),TestBufferSizes[testBufferSize]);

		test.Next(_L("Create buffer"));
		r=ldd.CreateBuffer(TestBufferSizes[testBufferSize]);
		if(r!=KErrNone)
			test.Printf(_L("Creating buffer failed client r=%d"), r);
		test(r==KErrNone);

		test.Next(_L("Map In Buffer"));
		r=ldd.MapInBuffer(&buffer,&size);
		
		test.Next(_L("CheckBuffer"));
		test(CheckBuffer(buffer,size));
		test(r==KErrNone);
		test.Next(_L("Fill and check shared buffer"));
		key=Math::Random();
		fillBuffer(buffer,size,key);
		test(ldd.CheckBuffer(key)==KErrNone);

		key=Math::Random();
		test(ldd.FillBuffer(key)==KErrNone);
		test(checkBuffer(buffer,size,key)==KErrNone);

		test.Next(_L("Map Out Buffer"));
		r=ldd.MapOutBuffer();
		test(r==KErrNone);

		test.Next(_L("Destroy Buffer"));
		r=ldd.DestroyBuffer();
		test(r==KErrNone);

		test.Next(_L("Create a buffer under OOM conditions"));
		CreateWithOOMCheck(TestBufferSizes[testBufferSize], EFalse);

		if(PhysicalCommitSupported)
			{
			test.Next(_L("Create a buffer with a physical address under OOM conditions"));
			CreateWithOOMCheck(TestBufferSizes[testBufferSize], ETrue);

			test.Next(_L("Create a buffer with a physical address"));
			r=ldd.CreateBufferPhysAddr(0x1000);
			test(r==KErrNone);

			test.Next(_L("Map In physical address Buffer"));
			r=ldd.MapInBuffer(&buffer,&size);
			test(r==KErrNone);

			test.Next(_L("Fill and check physical address shared buffer"));
			key=Math::Random();
			fillBuffer(buffer,size,key);
			test(ldd.CheckBuffer(key)==KErrNone);

			key=Math::Random();
			test(ldd.FillBuffer(key)==KErrNone);
			test(checkBuffer(buffer,size,key)==KErrNone);

			test.Next(_L("Map Out physical address Buffer"));
			r=ldd.MapOutBuffer();
			test(r==KErrNone);

			test.Next(_L("Destroy a buffer with a physical address"));
			r=ldd.DestroyBufferPhysAddr();
			test(r==KErrNone);
		}

		test.Next(_L("Check using the same buffer by 2 different user processes"));
		TAny* gbuffer;
		TUint32 gsize;
		r=ldd.MapInGlobalBuffer(RProcess().Id(),gbuffer,gsize);
		test(r==KErrNone);

		fillBuffer(gbuffer,gsize,23454);

		r=ldd.MapOutGlobalBuffer();
		test(r==KErrNone);

		r=ldd.CreateBuffer(TestBufferSizes[testBufferSize]);
		test(r==KErrNone);

		r=ldd.MapInBuffer(&buffer,&size);
		test(r==KErrNone);

		test(CheckBuffer(buffer,size));

		key=Math::Random();
		fillBuffer(buffer,size,key);
		test(ldd.CheckBuffer(key)==KErrNone);

		RTestProcess rogueP;
		TRequestStatus rendezvous;
		TRequestStatus logon;

		if(MemModelAttributes&EMemModelAttrProcessProt)
			{
			test.Next(_L("Checking buffers are protected at context switching"));
			rogueP.Create(ETestProcess2,(TInt)buffer,(TInt)size);
			rogueP.Logon(logon);
			rogueP.Rendezvous(rendezvous);
			rogueP.Resume();
			User::WaitForRequest(rendezvous);
			test(rendezvous==KProcessRendezvous);
			User::WaitForRequest(logon);
			test(rogueP.ExitType()==EExitPanic);
			test(logon==3);
			test(ldd.CheckBuffer(key)==KErrNone);
			}

		r=ldd.MapOutBuffer();
		test(r==KErrNone);

		r=ldd.DestroyBuffer();
		test(r==KErrNone);

		RTestProcess process;

		if((MemModelAttributes&EMemModelAttrKernProt) && (MemModelAttributes&EMemModelTypeMask)!=EMemModelTypeDirect)
			{
			test.Next(_L("Checking writing to unmapped buffer"));
			process.Create(ETestProcess1);
			process.Logon(logon);
			process.Rendezvous(rendezvous);
			test(ldd.MapInGlobalBuffer(process.Id(),gbuffer,gsize)==KErrNone);
			test(process.SetParameter(1,(TInt)gbuffer)==KErrNone);
			test(process.SetParameter(2,(TInt)gsize)==KErrNone);
			process.Resume();
			User::WaitForRequest(rendezvous);
			test(rendezvous==KProcessRendezvous);
			User::WaitForRequest(logon);
			test(process.ExitType()==EExitPanic);
			test(logon==3);
			process.Close();
			}

		r=ldd.CreateBuffer(TestBufferSizes[testBufferSize]);
		if(r!=KErrNone)
			return r;

		r=ldd.MapInBuffer(&buffer,&size);
		if(r!=KErrNone)
			return r;

		if(!CheckBuffer(buffer,size))
			return KErrGeneral;

		*(TInt*)buffer=KMagic1;
		TPckg<TInt> buf(*(TInt*)buffer);

		RTestProcess proc;
		test.Next(_L("Checking address lookup is implemented"));
		proc.Create(ETestProcess3,(TInt)&buf,RThread().Id());
		proc.Logon(logon);
		proc.Resume();
		User::WaitForRequest(logon);

		test(proc.ExitType()==EExitKill);
		test(logon==0);
		test(*(TInt*)buffer==KMagic2);

		ldd.DestroyBuffer();

		// Check process death whilst buffer is mapped in
		// Test case for defect DEF051851 - Shared IO Buffer fault when process dies
		test.Next(_L("Checking process death whilst buffer is mapped in"));
			process.Create(ETestProcess1);
			process.Logon(logon);
			test.Start(_L("Map buffer into another process"));
			test(ldd.MapInGlobalBuffer(process.Id(),gbuffer,gsize)==KErrNone);
			test.Next(_L("Kill other process"));
			process.Kill(99);
			User::WaitForRequest(logon);
			test(process.ExitType()==EExitKill);
			test(logon==99);
			process.Close();
			test.Next(_L("Map out buffer"));
			r=ldd.MapOutGlobalBuffer();
			test.Printf(_L("result = %d\n"),r);
			test(r==KErrNone);

			test.Next(_L("Map buffer into this process"));
			test(ldd.MapInGlobalBuffer(RProcess().Id(),gbuffer,gsize)==KErrNone);
			test.Next(_L("Map out buffer from this process"));
			r=ldd.MapOutGlobalBuffer();
			test.Printf(_L("result = %d\n"),r);
			test(r==KErrNone);

			process.Create(ETestProcess1);
			process.Logon(logon);
			test.Next(_L("Map buffer into another process"));
			test(ldd.MapInGlobalBuffer(process.Id(),gbuffer,gsize)==KErrNone);
			test.Next(_L("Kill other process"));
			process.Kill(99);
			User::WaitForRequest(logon);
			test(process.ExitType()==EExitKill);
			test(logon==99);
			process.Close();
			test.Next(_L("Map out buffer"));
			r=ldd.MapOutGlobalBuffer();
			test.Printf(_L("result = %d\n"),r);
			test(r==KErrNone);
			test.End();
	} // loop for next buffer size

	test.Next(_L("Create and map in buffer"));
	r=ldd.CreateBuffer(KTestBufferSize);
	test(r==KErrNone);
	r=ldd.MapInBuffer(&buffer,&size);
	test(r==KErrNone);

//  Test for DEF053512 - Can't delete SharedIo buffers in DLogicalDevice destructor 

	test.Next(_L("Map in global buffer"));
	TAny* gbuffer;
	TUint32 gsize;
	test(ldd.MapInGlobalBuffer(RProcess().Id(),gbuffer,gsize)==KErrNone);

	test.Next(_L("Closing channel (with a buffer still mapped in)"));
	ldd.Close();

//  Test for DEF053512 - Can't delete SharedIo buffers in DLogicalDevice destructor 

	test.Next(_L("Unload driver (whilst global buffer still mapped in)"));
	r=User::FreeLogicalDevice(KSharedIoTestLddName);
	test(r==KErrNone);

	test.End();



	return(0);
    }
コード例 #28
0
ファイル: SymbianSockets.cpp プロジェクト: cdcarter/io
	void StartReadLineL()
	{
		SetActive();
		CheckBuffer();
	}
コード例 #29
0
BOOL vncBuffer::SetEncoding(CARD32 encoding)
{

	//m_desktop->FillDisplayInfo(&m_scrinfo);

	// Delete the old encoder
	if (m_encoder != NULL)
	{
		// If a Zlib-like encoders were in use, save corresponding object
		// (with dictionaries) for possible later use on this connection.
		if ( zlib_encoder_in_use )
		{
			m_hold_zlib_encoder = m_encoder;
		}
		else if ( tight_encoder_in_use )
		{
			m_hold_tight_encoder = m_encoder;
		}
		else if ( zlibhex_encoder_in_use )
		{
			m_hold_zlibhex_encoder = m_encoder;
		}
		else
		{
			m_encoder->LogStats();
			delete m_encoder;
		}
		m_encoder = NULL;
	}

	// Expect to not use the zlib encoder below.  However, this
	// is overriden if zlib was selected.
	zlib_encoder_in_use = false;
	tight_encoder_in_use = false;
	zlibhex_encoder_in_use = false;

	// Returns FALSE if the desired encoding cannot be used
	switch(encoding)
	{

	case rfbEncodingRaw:

		// Create a RAW encoder
		m_encoder = new vncEncoder;
		if (m_encoder == NULL)
			return FALSE;
		break;

	case rfbEncodingRRE:

		// Create a RRE encoder
		m_encoder = new vncEncodeRRE;
		if (m_encoder == NULL)
			return FALSE;
		break;

	case rfbEncodingCoRRE:

		// Create a CoRRE encoder
		m_encoder = new vncEncodeCoRRE;
		if (m_encoder == NULL)
			return FALSE;
		break;

	case rfbEncodingHextile:

		// Create a Hextile encoder
		m_encoder = new vncEncodeHexT;
		if (m_encoder == NULL)
			return FALSE;
		break;

	case rfbEncodingZlib:
		// Create a Zlib encoder, if needed.
		// If a Zlib encoder was used previously, then reuse it here
		// to maintain zlib dictionary synchronization with the viewer.
		if ( m_hold_zlib_encoder == NULL )
		{
			m_encoder = new vncEncodeZlib;
		}
		else
		{
			m_encoder = m_hold_zlib_encoder;
		}
		if (m_encoder == NULL)
			return FALSE;
		zlib_encoder_in_use = true;
		break;

	case rfbEncodingTight:

		// Create a Tight encoder, if needed.
		// If a Tight encoder was used previously, then reuse it here
		// to maintain zlib dictionaries synchronization with the viewer.
		if ( m_hold_tight_encoder == NULL )
		{
			m_encoder = new vncEncodeTight;
		}
		else
		{
			m_encoder = m_hold_tight_encoder;
		}
		if (m_encoder == NULL)
			return FALSE;
		tight_encoder_in_use = true;
		break;

	case rfbEncodingZlibHex:

		// Create a ZlibHex encoder, if needed.
		// If a ZlibHex encoder was used previously, then reuse it here
		// to maintain zlib dictionary synchronization with the viewer.
		if ( m_hold_zlibhex_encoder == NULL )
		{
			m_encoder = new vncEncodeZlibHex;
		}
		else
		{
			m_encoder = m_hold_zlibhex_encoder;
		}
		if (m_encoder == NULL)
			return FALSE;
		zlibhex_encoder_in_use = true;
		break;

	default:
		// An unknown encoding was specified

		return FALSE;
	}

	// Initialise it and give it the pixel format
	m_encoder->Init();
	m_encoder->SetLocalFormat(
			m_scrinfo.format,
			m_scrinfo.framebufferWidth,
			m_scrinfo.framebufferHeight);

	// Duplicate our member fields in new Encoder.
	m_encoder->SetCompressLevel(m_compresslevel);
	m_encoder->SetQualityLevel(m_qualitylevel);
	m_encoder->EnableXCursor(m_use_xcursor);
	m_encoder->EnableRichCursor(m_use_richcursor);
	m_encoder->EnableLastRect(m_use_lastrect);

	if (m_clientfmtset)
		if (!m_encoder->SetRemoteFormat(m_clientformat))
		{
			return FALSE;
		}

	// Check that the client buffer is compatible
	return CheckBuffer();
}
コード例 #30
0
static
VOID
RunTestCases(
    PCWSTR CustomPath)
{
    struct
    {
        PCWSTR SearchPath;
        PCWSTR FileName;
        PCWSTR Extension;
        PCWSTR ResultPath;
        PCWSTR ResultFileName;
    } Tests[] =
    {
        { L"",                 L"",                     NULL,    NULL,                           NULL },
        { L"C:\\%ls\\Folder1", L"File1",                NULL,    L"C:\\%ls\\Folder1\\",          L"File1" },
        /* No path: current directory */
        { L"",                 L"File1",                NULL,    L"C:\\%ls\\CurrentDirectory\\", L"File1" },
        /* Full path as FileName */
        { L"",                 L"C:\\",                 NULL,    L"C:\\",                        NULL },
        { L"",                 L"C:\\%ls\\Folder1",     NULL,    L"C:\\%ls\\",                   L"Folder1" },
        /* No FileName */
        { L"C:\\",             L"",                     NULL,    L"C:\\",                        NULL },
        { L"C:\\%ls\\Folder1", L"",                     NULL,    L"C:\\%ls\\Folder1\\",          NULL },
        /* Full path as FileName */
        { L"", L"C:\\%ls\\Folder1\\SomeProgram.exe",    NULL,    L"C:\\%ls\\Folder1\\",          L"SomeProgram.exe" },
        { L"", L"C:\\%ls\\Folder1\\SomeProgram.exe",    L".exe", L"C:\\%ls\\Folder1\\",          L"SomeProgram.exe" },
        { L"", L"C:\\%ls\\Folder1\\SomeProgram",        NULL,    NULL,                           NULL },
        // 10
        { L"", L"C:\\%ls\\Folder1\\SomeProgram",        L".exe", NULL,                           NULL },
        /* Both SearchPath and FileName */
        { L"C:\\%ls\\Folder1\\", L"SomeProgram.exe",    NULL,    L"C:\\%ls\\Folder1\\",          L"SomeProgram.exe" },
        { L"C:\\%ls\\Folder1\\", L"SomeProgram.exe",    L".exe", L"C:\\%ls\\Folder1\\",          L"SomeProgram.exe" },
        { L"C:\\%ls\\Folder1\\", L"SomeProgram",        NULL,    NULL,                           NULL },
        { L"C:\\%ls\\Folder1\\", L"SomeProgram",        L".exe", L"C:\\%ls\\Folder1\\",          L"SomeProgram.exe" },
        { L"C:\\%ls\\Folder1",   L"SomeProgram.exe",    NULL,    L"C:\\%ls\\Folder1\\",          L"SomeProgram.exe" },
        { L"C:\\%ls\\Folder1",   L"SomeProgram.exe",    L".exe", L"C:\\%ls\\Folder1\\",          L"SomeProgram.exe" },
        { L"C:\\%ls\\Folder1",   L"SomeProgram",        NULL,    NULL,                           NULL },
        { L"C:\\%ls\\Folder1",   L"SomeProgram",        L".exe", L"C:\\%ls\\Folder1\\",          L"SomeProgram.exe" },
        /* Full path to file in SearchPath doesn't work */
        { L"C:\\%ls\\Folder1\\SomeProgram.exe", L"",    NULL,    NULL,                           NULL },
        // 20
        { L"C:\\%ls\\Folder1\\SomeProgram.exe", L"",    L".exe", NULL,                           NULL },
        { L"C:\\%ls\\Folder1\\SomeProgram",     L"",    NULL,    NULL,                           NULL },
        { L"C:\\%ls\\Folder1\\SomeProgram",     L"",    L".exe", NULL,                           NULL },
        /* */
        { L"C:\\%ls\\Folder1",          L"File1",       NULL,    L"C:\\%ls\\Folder1\\",          L"File1" },
        { L"C:\\%ls\\CurrentDirectory", L"File1",       NULL,    L"C:\\%ls\\CurrentDirectory\\", L"File1" },
        { L"C:\\%ls\\Folder1 ",         L"File1",       NULL,    NULL,                           NULL },
        { L"C:\\%ls\\CurrentDirectory ",L"File1",       NULL,    NULL,                           NULL },
        { L" C:\\%ls\\Folder1",         L"File1",       NULL,    NULL,                           NULL },
        { L" C:\\%ls\\CurrentDirectory",L"File1",       NULL,    NULL,                           NULL },
        { L" C:\\%ls\\Folder1 ",        L"File1",       NULL,    NULL,                           NULL },
        // 30
        { L" C:\\%ls\\CurrentDirectory ",L"File1",      NULL,    NULL,                           NULL },
        /* Multiple search paths */
        { L"C:\\%ls\\Folder1;C:\\%ls\\CurrentDirectory",
                                        L"File1",       NULL,    L"C:\\%ls\\Folder1\\",          L"File1" },
        { L"C:\\%ls\\CurrentDirectory;C:\\%ls\\Folder1",
                                        L"File1",       NULL,    L"C:\\%ls\\CurrentDirectory\\", L"File1" },
        { L"C:\\%ls\\CurrentDirectory ; C:\\%ls\\Folder1",
                                        L"File1",       NULL,    NULL,                           NULL },
        { L"C:\\%ls\\CurrentDirectory ;C:\\%ls\\Folder1",
                                        L"File1",       NULL,    L"C:\\%ls\\Folder1\\",          L"File1" },
        { L"C:\\%ls\\CurrentDirectory; C:\\%ls\\Folder1",
                                        L"File1",       NULL,    L"C:\\%ls\\CurrentDirectory\\", L"File1" },
        { L";C:\\%ls\\Folder1",         L"File1",       NULL,    L"C:\\%ls\\CurrentDirectory\\", L"File1" },
        { L";C:\\%ls\\Folder1;",        L"File1",       NULL,    L"C:\\%ls\\CurrentDirectory\\", L"File1" },
        { L";C:\\%ls\\Folder1;",        L"File1",       NULL,    L"C:\\%ls\\CurrentDirectory\\", L"File1" },
        { L"C:\\%ls\\Folder1",          L"OnlyInCurr",  NULL,    NULL,                           NULL },
        // 40
        { L"",                          L"OnlyInCurr",  NULL,    L"C:\\%ls\\CurrentDirectory\\", L"OnlyInCurr" },
        { L"",                          L"OnlyInCurr ", NULL,    L"C:\\%ls\\CurrentDirectory\\", L"OnlyInCurr" },
        { L"",                          L" OnlyInCurr", NULL,    NULL,                           NULL },
        { L" ",                         L"OnlyInCurr",  NULL,    NULL,                           NULL },
        { L";",                         L"OnlyInCurr",  NULL,    L"C:\\%ls\\CurrentDirectory\\", L"OnlyInCurr" },
        { L"; ",                        L"OnlyInCurr",  NULL,    L"C:\\%ls\\CurrentDirectory\\", L"OnlyInCurr" },
        { L" ;",                        L"OnlyInCurr",  NULL,    NULL,                           NULL },
        { L" ; ",                       L"OnlyInCurr",  NULL,    NULL,                           NULL },
        { L";C:\\%ls\\Folder1",         L"OnlyInCurr",  NULL,    L"C:\\%ls\\CurrentDirectory\\", L"OnlyInCurr" },
        { L"C:\\%ls\\Folder1;",         L"OnlyInCurr",  NULL,    NULL,                           NULL },
        // 50
        { L"C:\\%ls\\Folder1;;",        L"OnlyInCurr",  NULL,    L"C:\\%ls\\CurrentDirectory\\", L"OnlyInCurr" },
        { L";C:\\%ls\\Folder1;",        L"OnlyInCurr",  NULL,    L"C:\\%ls\\CurrentDirectory\\", L"OnlyInCurr" },
        { L"C:\\%ls\\Folder1;C:\\%ls\\Folder2",
                                        L"OnlyInCurr",  NULL,    NULL,                           NULL },
        { L";C:\\%ls\\Folder1;C:\\%ls\\Folder2",
                                        L"OnlyInCurr",  NULL,    L"C:\\%ls\\CurrentDirectory\\", L"OnlyInCurr" },
        { L"C:\\%ls\\Folder1;;C:\\%ls\\Folder2",
                                        L"OnlyInCurr",  NULL,    L"C:\\%ls\\CurrentDirectory\\", L"OnlyInCurr" },
        { L"C:\\%ls\\Folder1;C:\\%ls\\Folder2;",
                                        L"OnlyInCurr",  NULL,    NULL,                           NULL },
        { L"C:\\%ls\\Folder1;C:\\%ls\\Folder2;;",
                                        L"OnlyInCurr",  NULL,    L"C:\\%ls\\CurrentDirectory\\", L"OnlyInCurr" },
        /* Spaces in FileName! */
        { L"", L"C:\\%ls\\Folder1\\SomeProgram With Spaces",
                                                        L".exe", NULL,                           NULL },
        { L"", L"C:\\%ls\\Folder1\\SomeProgram With Spaces.exe",
                                                        L".exe", NULL,                           NULL },
        { L"", L"C:\\%ls\\Folder1\\Program",            L".exe", NULL,                           NULL },
        // 60
        { L"", L"C:\\%ls\\Folder1\\Program.exe",        L".exe", L"C:\\%ls\\Folder1\\",          L"Program.exe" },
        { L"", L"C:\\%ls\\Folder1\\Program With",       L".exe", NULL,                           NULL },
        { L"", L"C:\\%ls\\Folder1\\Program With.exe",   L".exe", L"C:\\%ls\\Folder1\\",          L"Program With.exe" },
        { L"", L"C:\\%ls\\Folder1\\Program With Spaces",L".exe", NULL,                           NULL },
        { L"", L"C:\\%ls\\Folder1\\Program With Spaces.exe",
                                                        L".exe", L"C:\\%ls\\Folder1\\",          L"Program With Spaces.exe" },
        /* Same tests with path in SearchPath - now extensions are appended */
        { L"C:\\%ls\\Folder1", L"SomeProgram With Spaces",
                                                        L".exe", NULL,                           NULL },
        { L"C:\\%ls\\Folder1", L"SomeProgram With Spaces.exe",
                                                        L".exe", NULL,                           NULL },
        { L"C:\\%ls\\Folder1", L"Program",              L".exe", L"C:\\%ls\\Folder1\\",          L"Program.exe" },
        { L"C:\\%ls\\Folder1", L"Program.exe",          L".exe", L"C:\\%ls\\Folder1\\",          L"Program.exe" },
        { L"C:\\%ls\\Folder1", L"Program With",         L".exe", L"C:\\%ls\\Folder1\\",          L"Program With.exe" },
        // 70
        { L"C:\\%ls\\Folder1", L"Program With.exe",     L".exe", L"C:\\%ls\\Folder1\\",          L"Program With.exe" },
        { L"C:\\%ls\\Folder1", L"Program With Spaces",  L".exe", L"C:\\%ls\\Folder1\\",          L"Program With Spaces.exe" },
        { L"C:\\%ls\\Folder1", L"Program With Spaces.exe",
                                                        L".exe", L"C:\\%ls\\Folder1\\",          L"Program With Spaces.exe" },
    };

    ULONG i;
    ULONG Length;
    PWSTR PartName;
    WCHAR SearchPath[MAX_PATH];
    WCHAR FileName[MAX_PATH];
    WCHAR ResultPath[MAX_PATH];
    WCHAR Buffer[MAX_PATH];
    BOOLEAN Okay;

    for (i = 0; i < sizeof(Tests) / sizeof(Tests[0]); i++)
    {
        swprintf(SearchPath, Tests[i].SearchPath, CustomPath, CustomPath, CustomPath, CustomPath);
        swprintf(FileName, Tests[i].FileName, CustomPath, CustomPath, CustomPath, CustomPath);
        RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
        PartName = InvalidPointer;

        StartSeh()
            Length = RtlDosSearchPath_U(SearchPath,
                                        FileName,
                                        Tests[i].Extension,
                                        sizeof(Buffer),
                                        Buffer,
                                        &PartName);
        EndSeh(STATUS_SUCCESS);

        if (Tests[i].ResultPath)
        {
            swprintf(ResultPath, Tests[i].ResultPath, CustomPath, CustomPath, CustomPath, CustomPath);
            if (Tests[i].ResultFileName)
            {
                ok(PartName == &Buffer[wcslen(ResultPath)],
                   "PartName = %p (%ls), expected %p\n",
                   PartName, PrintablePointer(PartName), &Buffer[wcslen(ResultPath)]);
                wcscat(ResultPath, Tests[i].ResultFileName);
            }
            else
            {
                ok(PartName == NULL,
                   "PartName = %p (%ls), expected NULL\n",
                   PartName, PrintablePointer(PartName));
            }
            Okay = CheckStringBuffer(Buffer, Length, sizeof(Buffer), ResultPath);
            ok(Okay == TRUE, "CheckStringBuffer failed. Got '%ls', expected '%ls'\n", Buffer, ResultPath);
        }
        else
        {
            Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
            ok(Okay == TRUE, "CheckBuffer failed\n");
            ok(Length == 0, "Length = %lu\n", Length);
            ok(PartName == InvalidPointer,
               "PartName = %p (%ls), expected %p\n",
               PartName, PrintablePointer(PartName), InvalidPointer);
        }
    }
}