Package winappdbg :: Module search :: Class RegExpPattern
[hide private]
[frames] | no frames]

Class RegExpPattern

source code


Regular expression pattern.

Instance Methods [hide private]
 
__init__(self, regexp, flags=0, maxLength=None)
Class constructor.
source code
 
__len__(self)
Returns the maximum expected length of the strings matched by this pattern.
source code
tuple( int, int )
find(self, buffer, pos=None)
Searches for the pattern in the given buffer, optionally starting at the given position within the buffer.
source code
tuple( int, int, str )
found(self, address, size, data)
This method gets called when a match is found. (Inherited from winappdbg.search.Pattern)
source code
 
read(self, process, address, size)
Reads the requested number of bytes from the process memory at the given address. (Inherited from winappdbg.search.Pattern)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
int flags
Regular expression flags.
int maxLength
Maximum expected length of the strings matched by this regular expression.
str pattern
Regular expression in text form.
re.compile regexp
Regular expression in compiled form.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, regexp, flags=0, maxLength=None)
(Constructor)

source code 

Class constructor.

The only mandatory argument should be the pattern string.

This method MUST be reimplemented by subclasses of Pattern.

Parameters:
  • regexp (str) - Regular expression string.
  • flags (int) - Regular expression flags.
  • maxLength (int) - Maximum expected length of the strings matched by this regular expression.

    This value will be used to calculate the required buffer size when doing buffered searches.

    Ideally it should be an exact value, but in some cases it's not possible to calculate so an upper limit should be given instead.

    If that's not possible either, None should be used. That will cause an exception to be raised if this pattern is used in a buffered search.

Overrides: object.__init__

__len__(self)
(Length operator)

source code 

Returns the maximum expected length of the strings matched by this pattern. This value is taken from the maxLength argument of the constructor if this class.

Ideally it should be an exact value, but in some cases it's not possible to calculate so an upper limit should be returned instead.

If that's not possible either an exception must be raised.

This value will be used to calculate the required buffer size when doing buffered searches.

Overrides: Pattern.__len__

find(self, buffer, pos=None)

source code 

Searches for the pattern in the given buffer, optionally starting at the given position within the buffer.

This method MUST be reimplemented by subclasses of Pattern.

Parameters:
  • buffer - Buffer to search on.
  • pos - (Optional) Position within the buffer to start searching from.
Returns: tuple( int, int )
Tuple containing the following:
  • Position within the buffer where a match is found, or -1 if no match was found.
  • Length of the matched data if a match is found, or undefined if no match was found.
Overrides: Pattern.find
(inherited documentation)

Instance Variable Details [hide private]

maxLength

Maximum expected length of the strings matched by this regular expression.

This value will be used to calculate the required buffer size when doing buffered searches.

Ideally it should be an exact value, but in some cases it's not possible to calculate so an upper limit should be given instead.

If that's not possible either, None should be used. That will cause an exception to be raised if this pattern is used in a buffered search.

Type:
int