Initial MSVC 2008 projects workspace

This commit is contained in:
alexey.min
2012-02-01 05:25:08 +00:00
commit 03de3bdc95
1446 changed files with 476853 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
#include "stdafx.h"
#include "L2Packets_xcpt.h"
L2P_Exception::~L2P_Exception()
{
if( m_what )
{
free( m_what );
m_what = NULL;
}
}
const char *L2P_Exception::what() const { return m_what; }
const L2P_Exception& L2P_Exception::operator=( const L2P_Exception& other )
{
if( this == &other ) return (*this);
if( m_what ) free( m_what );
m_what = NULL;
if( other.m_what )
{
size_t ssize = strlen( other.m_what ) + 1;
m_what = (char *)malloc( ssize );
if( m_what ) strncpy( m_what, other.m_what, ssize-1 );
}
return (*this);
}
L2P_MemoryError::L2P_MemoryError( const char *comment, size_t bytes )
{
m_what = (char *)malloc( 256 );
if( m_what )
{
sprintf( m_what, "%s: Tried to allocate: %u bytes", comment, (unsigned int)bytes );
}
}
L2P_ReadException::L2P_ReadException( const char *comment, int nBytesTriedToRead, int nPos, int nSize )
{
m_what = (char *)malloc( 256 );
if( m_what )
{
sprintf( m_what, "%s: Tried to read: %d bytes; pos: %d/%d", comment, nBytesTriedToRead, nPos, nSize );
}
}
L2P_WriteException::L2P_WriteException( const char *comment, int nBytesTriedToWrite, int nPos, int nSize )
{
m_what = (char *)malloc( 256 );
if( m_what )
{
sprintf( m_what, "%s: Tried to write: %d bytes; pos: %d/%d", comment, nBytesTriedToWrite, nPos, nSize );
}
}
L2P_ObfuscateException::L2P_ObfuscateException( int size, unsigned int wrong_opcode, int error_code )
{
m_what = (char *)malloc( 256 );
if( m_what )
{
sprintf( m_what, "Obfuscation failed (%d): opcode 0x%02X (table size %d)", error_code, wrong_opcode, size );
}
}
L2P_DeObfuscateException::L2P_DeObfuscateException( int size, unsigned int wrong_opcode, int error_code )
{
m_what = (char *)malloc( 256 );
if( m_what )
{
sprintf( m_what, "Deobfuscation failed (%d): opcode 0x%02X (table size %d)", error_code, wrong_opcode, size );
}
}

View File

@@ -0,0 +1,66 @@
#ifndef L2P_XCPT
#define L2P_XCPT
/** \class L2P_Exception
* Base class for exceptions that may be thrown from deep inside functions from library
* (ByteArray, L2BasePacket) */
class L2P_Exception
{
public:
/** Default constructor, no comments */
L2P_Exception(): m_what(NULL) {}
/** Copy constructor */
L2P_Exception( const L2P_Exception& other ): m_what(NULL)
{
this->operator=( other );
}
/** Destructor, frees internal string buffer if needed */
virtual ~L2P_Exception();
/** Returns pointer to string comment buffer
\ return pointer to string comment buffer or NULL, if no comment
*/
virtual const char *what() const;
/** Assigns comment from other L2P_Exception object to this
* \param other - source to copy from */
virtual const L2P_Exception& operator=( const L2P_Exception& other );
protected:
char *m_what; ///< pointer to buffer to keep comment string
};
/** \class L2P_Exception Will be thrown when malloc()/realloc() fails */
class L2P_MemoryError: public L2P_Exception
{
public:
L2P_MemoryError( const char *comment, size_t bytes );
};
/** \class L2P_Exception Will be thrown when reading past end of packet OR calling
* getByteAt() with index not in range of packet size */
class L2P_ReadException: public L2P_Exception
{
public:
L2P_ReadException( const char *comment, int nBytesTriedToRead, int nPos, int nSize );
};
/** \class L2P_Exception Will be thrown when writing past end of packet (almost impossible situation) OR
* by calling setByteAt() with index not in range of packet size */
class L2P_WriteException: public L2P_Exception
{
public:
L2P_WriteException( const char *comment, int nBytesTriedToWrite, int nPos, int nSize );
};
class L2P_ObfuscateException: public L2P_Exception
{
public:
L2P_ObfuscateException( int size, unsigned int wrong_opcode, int error_code );
};
class L2P_DeObfuscateException: public L2P_Exception
{
public:
L2P_DeObfuscateException( int size, unsigned int wrong_opcode, int error_code );
};
#endif