Package pype32 :: Module excep |
[hide private]
[frames] | no frames]

# Source Code for Module pype32.excep

      1  #!/usr/bin/python
      2  # -*- coding: utf-8 -*-
      3
      4  # Copyright (c) 2013, Nahuel Riva
      5  # All rights reserved.
      6  #
      7  # Redistribution and use in source and binary forms, with or without
      8  # modification, are permitted provided that the following conditions are met:
      9  #
     10  #     * Redistributions of source code must retain the above copyright notice,
     11  #       this list of conditions and the following disclaimer.
     12  #     * Redistributions in binary form must reproduce the above copyright
     13  #       notice,this list of conditions and the following disclaimer in the
     14  #       documentation and/or other materials provided with the distribution.
     15  #     * Neither the name of the copyright holder nor the names of its
     16  #       contributors may be used to endorse or promote products derived from
     17  #       this software without specific prior written permission.
     18  #
     19  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     20  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22  # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     23  # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  # POSSIBILITY OF SUCH DAMAGE.
     30
     31  """
     32  Exceptions used by the entire library.
     33
     34  @group Base exceptions:
     35      PyPe32Exception, PyPe32Warning
     36
     37  @group Warnings:
     38      PEWarning
     39
     40  @group Exceptions:
     41      PEException,NotValidPathException,WrongOffsetValueException,DirectoryEntriesLengthException,
     42      TypeNotSupportedException,ArrayTypeException,DataLengthException,ReadDataOffsetException,
     43      WriteDataOffsetException,InstanceErrorException,DataMismatchException,SectionHeadersException,
     44      DirectoryEntryException,InvalidParameterException
     45  """
     46
     47  __revision__ = "$Id$"
     48
     49  __all__ = [
     50             "PyPe32Exception",
     51              "PyPe32Warning",
     52              "PEWarning",
     53              "PEException",
     54              "NotValidPathException",
     55              "WrongOffsetValueException",
     56              "DirectoryEntriesLengthException",
     57              "TypeNotSupportedException",
     58              "ArrayTypeException",
     59              "DataLengthException",
     60              "ReadDataOffsetException",
     61              "WriteDataOffsetException",
     62              "InstanceErrorException",
     63              "DataMismatchException",
     64              "SectionHeadersException",
     65              "DirectoryEntryException",
     66              "InvalidParameterException",
     67             ]
     68
     69 -class PyPe32Exception(Exception):
     70      """Base exception class."""
     71      pass
     72
     73 -class PyPe32Warning(Exception):
     74      """Base warning class."""
     75      pass
     76
     77 -class PEWarning(PyPe32Warning):
     78      """Raised when a suspicious value is found into the PE instance."""
     79      pass
     80
     81 -class PEException(PyPe32Exception):
     82      """Raised when an invalid field on the PE instance was found."""
     83      pass
     84
     85 -class NotValidPathException(PyPe32Exception):
     86      """Raised when a path wasn't found or it is an invalid path."""
     87      pass
     88
     89 -class WrongOffsetValueException(PyPe32Exception):
     90      """
     91      Used primary by the L{ReadData} and L{WriteData} object in read/write operations when an invalid
     92      offset value was used.
     93      """
     94      pass
     95
     96 -class DirectoryEntriesLengthException(PyPe32Exception):
     97      """Raised when the the number of entries in a L{DataDirectory} object is different from L{consts.IMAGE_NUMBEROF_DIRECTORY_ENTRIES}."""
     98      pass
     99
    100 -class TypeNotSupportedException(PyPe32Exception):
    101      """This exception must be used when an invalid data type is used within the library."""
    102      pass
    103
    104 -class ArrayTypeException(PyPe32Exception):
    105      """Raised when creating an unsupported type of array."""
    106      pass
    107
    108 -class DataLengthException(PyPe32Exception):
    109      """Raised when data lengths does not match."""
    110      pass
    111
    112 -class ReadDataOffsetException(PyPe32Exception):
    113      """This exception must be raised when reading from an invalid offset."""
    114      pass
    115
    116 -class WriteDataOffsetException(PyPe32Exception):
    117      """This exception must be raised when writing to an invalid offset."""
    118      pass
    119
    120 -class InstanceErrorException(PyPe32Exception):
    121      """This exception is raised when an instance parameter was not specified."""
    122      pass
    123
    124 -class DataMismatchException(PyPe32Exception):
    125      """Raised when two different types of data does not match."""
    126      pass
    127
    128 -class SectionHeadersException(PyPe32Exception):
    129      """Raised when an error related to a L{pype32.SectionHeader} or L{pype32.SectionHeaders} is found."""
    130      pass
    131
    132 -class DirectoryEntryException(PyPe32Exception):
    133      """This exception must be raised when an error with the L{Directory} is found."""
    134      pass
    135
    136 -class InvalidParameterException(PyPe32Exception):
    137      """Raised when an invalid parameter is received."""
    138      pass
    139