2008-07-22 20:23:32 +02:00
% i g n o r e n m S e r E A ;
% i g n o r e n m S e r N ;
% i g n o r e m a x S e r i a l N a m e ;
2010-03-05 12:18:25 +01:00
% i g n o r e g e t _ i m p o r t _ m o d u l e _ n a m e ;
% r e n a m e ( g e t _ i m p o r t _ m o d u l e _ n a m e ) p y _ g e t _ i m p o r t _ m o d u l e _ n a m e ;
2007-10-20 09:03:51 +02:00
% i g n o r e N A L T _ E A ;
2010-03-05 12:18:25 +01:00
% i g n o r e e n u m _ i m p o r t _ n a m e s ;
% r e n a m e ( e n u m _ i m p o r t _ n a m e s ) p y _ e n u m _ i m p o r t _ n a m e s ;
2013-03-06 08:44:10 +01:00
% i g n o r e c u s t o m _ r e f i n f o _ h a n d l e r _ t ;
% i g n o r e c u s t o m _ r e f i n f o _ h a n d l e r s _ t ;
% i g n o r e r e g i s t e r _ c u s t o m _ r e f i n f o ;
% i g n o r e u n r e g i s t e r _ c u s t o m _ r e f i n f o ;
% i g n o r e g e t _ c u s t o m _ r e f i n f o s ;
2010-03-05 12:18:25 +01:00
% i n c l u d e "nalt.hpp"
% {
//<code(py_nalt)>
//-------------------------------------------------------------------------
// callback for enumerating imports
// ea: import address
// name: import name (NULL if imported by ordinal)
// ord: import ordinal (0 for imports by name)
// param: user parameter passed to enum_import_names()
// return: 1-ok, 0-stop enumeration
static int i d a a p i p y _ i m p o r t _ e n u m _ c b (
2010-03-17 12:30:28 +01:00
e a _ t e a ,
c o n s t char * name ,
u v a l _ t o r d ,
2010-03-05 12:18:25 +01:00
void * param )
{
2011-04-18 18:07:00 +02:00
// If no name, try to get the name associated with the 'ea'. It may be coming from IDS
char n a m e _ b u f [ M A X S T R ] ;
if ( name = = NULL )
name = g e t _ t r u e _ n a m e ( B A D A D D R , e a , n a m e _ b u f , s i z e o f ( n a m e _ b u f ) ) ;
2010-03-17 12:30:28 +01:00
P y O b j e c t * p y _ n a m e ;
if ( name = = NULL )
{
p y _ n a m e = P y _ N o n e ;
P y _ I N C R E F ( P y _ N o n e ) ;
}
else
{
p y _ n a m e = P y S t r i n g _ F r o m S t r i n g ( name ) ;
}
2011-04-18 18:07:00 +02:00
2010-03-05 12:18:25 +01:00
P y O b j e c t * p y _ o r d = P y _ B u i l d V a l u e ( P Y _ F M T 64 , p y u l _ t ( o r d ) ) ;
2011-04-18 18:07:00 +02:00
P y O b j e c t * p y _ e a = P y _ B u i l d V a l u e ( P Y _ F M T 64 , p y u l _ t ( e a ) ) ;
P Y W _ G I L _ E N S U R E ;
P y O b j e c t * p y _ r e s u l t = P y O b j e c t _ C a l l F u n c t i o n O b j A r g s (
( P y O b j e c t * ) param ,
p y _ e a ,
p y _ n a m e ,
p y _ o r d ,
NULL ) ;
P Y W _ G I L _ R E L E A S E ;
2010-03-05 12:18:25 +01:00
int r = p y _ r e s u l t ! = NULL && PyObject_IsTrue(py_result) ? 1 : 0;
2011-04-18 18:07:00 +02:00
2010-03-05 12:18:25 +01:00
P y _ D E C R E F ( p y _ e a ) ;
P y _ D E C R E F ( p y _ n a m e ) ;
P y _ D E C R E F ( p y _ o r d ) ;
2010-03-05 12:35:28 +01:00
P y _ X D E C R E F ( p y _ r e s u l t ) ;
2011-04-18 18:07:00 +02:00
2010-03-05 12:18:25 +01:00
return r ;
}
2010-06-28 14:36:40 +02:00
//-------------------------------------------------------------------------
s w i t c h _ i n f o _ e x _ t * s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( P y O b j e c t * self )
{
if ( ! P y O b j e c t _ H a s A t t r S t r i n g ( self , S _ C L I N K _ N A M E ) )
return NULL ;
s w i t c h _ i n f o _ e x _ t * r ;
P y O b j e c t * attr = P y O b j e c t _ G e t A t t r S t r i n g ( self , S _ C L I N K _ N A M E ) ;
if ( P y C O b j e c t _ C h e c k ( attr ) )
r = ( s w i t c h _ i n f o _ e x _ t * ) P y C O b j e c t _ A s V o i d P t r ( attr ) ;
else
r = NULL ;
P y _ D E C R E F ( attr ) ;
return r ;
}
2010-03-05 12:18:25 +01:00
//</code(py_nalt)>
% }
2010-06-28 14:36:40 +02:00
% r e n a m e ( g e t _ s w i t c h _ i n f o _ e x ) p y _ g e t _ s w i t c h _ i n f o _ e x ;
% r e n a m e ( s e t _ s w i t c h _ i n f o _ e x ) p y _ s e t _ s w i t c h _ i n f o _ e x ;
% r e n a m e ( d e l _ s w i t c h _ i n f o _ e x ) p y _ d e l _ s w i t c h _ i n f o _ e x ;
% r e n a m e ( c r e a t e _ s w i t c h _ x r e f s ) p y _ c r e a t e _ s w i t c h _ x r e f s ;
% r e n a m e ( c r e a t e _ s w i t c h _ t a b l e ) p y _ c r e a t e _ s w i t c h _ t a b l e ;
2010-03-05 12:18:25 +01:00
% i n l i n e % {
//<inline(py_nalt)>
2010-06-28 14:36:40 +02:00
2010-03-05 12:18:25 +01:00
//-------------------------------------------------------------------------
2010-06-28 14:36:40 +02:00
/*
# < p y d o c >
def g e t _ i m p o r t _ m o d u l e _ n a m e ( p a t h , f n a m e , c a l l b a c k ) :
"" "
Returns t h e name of a n i m p o r t e d m o d u l e g i v e n i t s index
@ return : None or t h e m o d u l e name
"" "
p a s s
# < / p y d o c >
* /
static P y O b j e c t * p y _ g e t _ i m p o r t _ m o d u l e _ n a m e ( int m o d _ i n d e x )
2010-03-05 12:18:25 +01:00
{
char b u f [ M A X S T R ] ;
if ( ! g e t _ i m p o r t _ m o d u l e _ n a m e ( m o d _ i n d e x , b u f , s i z e o f ( b u f ) ) )
P y _ R E T U R N _ N O N E ;
2011-04-18 18:07:00 +02:00
2010-03-05 12:18:25 +01:00
return P y S t r i n g _ F r o m S t r i n g ( b u f ) ;
}
//-------------------------------------------------------------------------
2010-06-28 14:36:40 +02:00
/*
# < p y d o c >
def g e t _ s w i t c h _ i n f o _ e x ( e a ) :
"" "
Returns t h e a s w i t c h _ i n f o _ e x _ t s t r u c t u r e c o n t a i n i n g t h e information a b o u t t h e s w i t c h .
P l e a s e r e f e r to t h e S D K s a m p l e 'uiswitch'
@ return : None or s w i t c h _ i n f o _ e x _ t i n s t a n c e
"" "
p a s s
# < / p y d o c >
* /
P y O b j e c t * p y _ g e t _ s w i t c h _ i n f o _ e x ( e a _ t e a )
{
s w i t c h _ i n f o _ e x _ t * e x = new s w i t c h _ i n f o _ e x _ t ( ) ;
P y O b j e c t * p y _ o b j ;
if ( : : g e t _ s w i t c h _ i n f o _ e x ( e a , e x , s i z e o f ( s w i t c h _ i n f o _ e x _ t ) ) < = 0
| | ( p y _ o b j = c r e a t e _ i d a a p i _ l i n k e d _ c l a s s _ i n s t a n c e ( S _ P Y _ S W I E X _ C L S N A M E , e x ) ) = = NULL )
{
delete e x ;
P y _ R E T U R N _ N O N E ;
}
return p y _ o b j ;
}
//-------------------------------------------------------------------------
/*
# < p y d o c >
def c r e a t e _ s w i t c h _ x r e f s ( i n s n _ e a , s i ) :
"" "
T h i s function c r e a t e s x r e f s from t h e i n d i r e c t j u m p .
U s u a l l y t h e r e is no n e e d to call t h i s function d i r e c t l y b e c a u s e t h e k e r n e l
w i l l call i t for s w i t c h t a b l e s
N o t e : C u s t o m s w i t c h information a r e not s u p p o r t e d y e t .
2010-09-17 14:06:30 +02:00
2010-06-28 14:36:40 +02:00
@ param i n s n _ e a : a d d r e s s of t h e 'indirect jump' i n s t r u c t i o n
@ param s i : s w i t c h information
@ return : B o o l e a n
"" "
p a s s
# < / p y d o c >
* /
i d a m a n b o o l i d a _ e x p o r t p y _ c r e a t e _ s w i t c h _ x r e f s (
e a _ t i n s n _ e a ,
P y O b j e c t * p y _ s w i )
{
s w i t c h _ i n f o _ e x _ t * s w i = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( p y _ s w i ) ;
if ( s w i = = NULL )
return false ;
c r e a t e _ s w i t c h _ x r e f s ( i n s n _ e a , s w i ) ;
return true ;
}
//-------------------------------------------------------------------------
/*
# < p y d o c >
def c r e a t e _ s w i t c h _ t a b l e ( i n s n _ e a , s i ) :
"" "
Create s w i t c h table from t h e s w i t c h information
2010-09-17 14:06:30 +02:00
2010-06-28 14:36:40 +02:00
@ param i n s n _ e a : a d d r e s s of t h e 'indirect jump' i n s t r u c t i o n
@ param s i : s w i t c h information
@ return : B o o l e a n
"" "
p a s s
# < / p y d o c >
* /
i d a m a n b o o l i d a _ e x p o r t p y _ c r e a t e _ s w i t c h _ t a b l e (
e a _ t i n s n _ e a ,
P y O b j e c t * p y _ s w i )
{
s w i t c h _ i n f o _ e x _ t * s w i = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( p y _ s w i ) ;
if ( s w i = = NULL )
return false ;
2010-09-17 14:06:30 +02:00
2010-06-28 14:36:40 +02:00
c r e a t e _ s w i t c h _ t a b l e ( i n s n _ e a , s w i ) ;
return true ;
}
//-------------------------------------------------------------------------
/*
# < p y d o c >
def s e t _ s w i t c h _ i n f o _ e x ( e a , s w i t c h _ i n f o _ e x ) :
"" "
S a v e s t h e s w i t c h information in t h e database
P l e a s e r e f e r to t h e S D K s a m p l e 'uiswitch'
@ return : B o o l e a n
"" "
p a s s
# < / p y d o c >
* /
b o o l p y _ s e t _ s w i t c h _ i n f o _ e x ( e a _ t e a , P y O b j e c t * p y _ s w i )
{
s w i t c h _ i n f o _ e x _ t * s w i = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( p y _ s w i ) ;
if ( s w i = = NULL )
return false ;
s e t _ s w i t c h _ i n f o _ e x ( e a , s w i ) ;
return true ;
}
//-------------------------------------------------------------------------
/*
# < p y d o c >
def d e l _ s w i t c h _ i n f o _ e x ( e a ) :
"" "
D e l e t e s s t o r e d s w i t c h information
"" "
p a s s
# < / p y d o c >
* /
void p y _ d e l _ s w i t c h _ i n f o _ e x ( e a _ t e a )
{
d e l _ s w i t c h _ i n f o _ e x ( e a ) ;
}
//-------------------------------------------------------------------------
/*
# < p y d o c >
def e n u m _ i m p o r t _ n a m e s ( m o d _ i n d e x , c a l l b a c k ) :
"" "
E n u m e r a t e i m p o r t s from a s p e c i f i c m o d u l e .
P l e a s e r e f e r to e x _ i m p o r t s . p y e x a m p l e .
@ param m o d _ i n d e x : T h e m o d u l e index
@ param c a l l b a c k : A c a l l a b l e o b j e c t t h a t w i l l b e i n v o k e d with a n e a , name ( c o u l d b e None ) and ordinal .
@ return : 1 - f i n i s h e d ok , - 1 on error , otherwise c a l l b a c k return value ( < = 0 )
"" "
p a s s
# < / p y d o c >
* /
static int p y _ e n u m _ i m p o r t _ n a m e s ( int m o d _ i n d e x , P y O b j e c t * p y _ c b )
2010-03-05 12:18:25 +01:00
{
if ( ! P y C a l l a b l e _ C h e c k ( p y _ c b ) )
return - 1 ;
2011-04-18 18:07:00 +02:00
2010-03-05 12:18:25 +01:00
return e n u m _ i m p o r t _ n a m e s ( m o d _ i n d e x , p y _ i m p o r t _ e n u m _ c b , p y _ c b ) ;
}
2007-10-20 09:03:51 +02:00
2010-06-28 14:36:40 +02:00
//-------------------------------------------------------------------------
static P y O b j e c t * s w i t c h _ i n f o _ e x _ t _ c r e a t e ( )
{
s w i t c h _ i n f o _ e x _ t * i n s t = new s w i t c h _ i n f o _ e x _ t ( ) ;
return P y C O b j e c t _ F r o m V o i d P t r ( i n s t , NULL ) ;
}
2011-04-18 18:07:00 +02:00
//---------------------------------------------------------------------------
2010-06-28 14:36:40 +02:00
static b o o l s w i t c h _ i n f o _ e x _ t _ d e s t r o y ( P y O b j e c t * p y _ o b j )
{
if ( ! P y C O b j e c t _ C h e c k ( p y _ o b j ) )
return false ;
s w i t c h _ i n f o _ e x _ t * i n s t = ( s w i t c h _ i n f o _ e x _ t * ) P y C O b j e c t _ A s V o i d P t r ( p y _ o b j ) ;
delete i n s t ;
return true ;
}
static b o o l s w i t c h _ i n f o _ e x _ t _ a s s i g n ( P y O b j e c t * self , P y O b j e c t * o t h e r )
{
s w i t c h _ i n f o _ e x _ t * l h s = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
s w i t c h _ i n f o _ e x _ t * r h s = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( o t h e r ) ;
if ( l h s = = NULL | | r h s = = NULL )
return false ;
* l h s = * r h s ;
return true ;
}
//-------------------------------------------------------------------------
// Auto generated - begin
//
static P y O b j e c t * s w i t c h _ i n f o _ e x _ t _ g e t _ r e g d t y p ( P y O b j e c t * self )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
P y _ R E T U R N _ N O N E ;
return P y _ B u i l d V a l u e ( "b" , ( char ) l i n k - > r e g d t y p ) ;
}
static void s w i t c h _ i n f o _ e x _ t _ s e t _ r e g d t y p ( P y O b j e c t * self , P y O b j e c t * value )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
return ;
l i n k - > r e g d t y p = ( char ) P y I n t _ A s L o n g ( value ) ;
}
static P y O b j e c t * s w i t c h _ i n f o _ e x _ t _ g e t _ f l a g s 2 ( P y O b j e c t * self )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
P y _ R E T U R N _ N O N E ;
return P y _ B u i l d V a l u e ( "i" , l i n k - > f l a g s 2 ) ;
}
static void s w i t c h _ i n f o _ e x _ t _ s e t _ f l a g s 2 ( P y O b j e c t * self , P y O b j e c t * value )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
return ;
l i n k - > f l a g s 2 = ( int ) P y I n t _ A s L o n g ( value ) ;
}
static P y O b j e c t * s w i t c h _ i n f o _ e x _ t _ g e t _ j c a s e s ( P y O b j e c t * self )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
P y _ R E T U R N _ N O N E ;
return P y _ B u i l d V a l u e ( "i" , l i n k - > j c a s e s ) ;
}
static void s w i t c h _ i n f o _ e x _ t _ s e t _ j c a s e s ( P y O b j e c t * self , P y O b j e c t * value )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
return ;
l i n k - > j c a s e s = ( int ) P y I n t _ A s L o n g ( value ) ;
}
static P y O b j e c t * s w i t c h _ i n f o _ e x _ t _ g e t _ r e g n u m ( P y O b j e c t * self )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
P y _ R E T U R N _ N O N E ;
return P y _ B u i l d V a l u e ( "i" , ( int ) l i n k - > r e g n u m ) ;
}
static void s w i t c h _ i n f o _ e x _ t _ s e t _ r e g n u m ( P y O b j e c t * self , P y O b j e c t * value )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
return ;
l i n k - > r e g n u m = ( int ) P y I n t _ A s L o n g ( value ) ;
}
static P y O b j e c t * s w i t c h _ i n f o _ e x _ t _ g e t _ f l a g s ( P y O b j e c t * self )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
P y _ R E T U R N _ N O N E ;
return P y _ B u i l d V a l u e ( "H" , ( u s h o r t ) l i n k - > f l a g s ) ;
}
static void s w i t c h _ i n f o _ e x _ t _ s e t _ f l a g s ( P y O b j e c t * self , P y O b j e c t * value )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
return ;
l i n k - > f l a g s = ( u i n t 16 ) P y I n t _ A s L o n g ( value ) ;
}
static P y O b j e c t * s w i t c h _ i n f o _ e x _ t _ g e t _ n c a s e s ( P y O b j e c t * self )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
P y _ R E T U R N _ N O N E ;
return P y _ B u i l d V a l u e ( "H" , ( u i n t 16 ) l i n k - > n c a s e s ) ;
}
static void s w i t c h _ i n f o _ e x _ t _ s e t _ n c a s e s ( P y O b j e c t * self , P y O b j e c t * value )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
return ;
l i n k - > n c a s e s = ( u s h o r t ) P y I n t _ A s L o n g ( value ) ;
}
static P y O b j e c t * s w i t c h _ i n f o _ e x _ t _ g e t _ d e f j u m p ( P y O b j e c t * self )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
P y _ R E T U R N _ N O N E ;
return P y _ B u i l d V a l u e ( P Y _ F M T 64 , ( p y u l _ t ) l i n k - > d e f j u m p ) ;
}
static void s w i t c h _ i n f o _ e x _ t _ s e t _ d e f j u m p ( P y O b j e c t * self , P y O b j e c t * value )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
return ;
2010-07-13 18:43:53 +02:00
u i n t 64 v ( 0 ) ; P y W _ G e t N u m b e r ( value , &v);
2010-06-28 14:36:40 +02:00
l i n k - > d e f j u m p = ( p y u l _ t ) v ;
}
static P y O b j e c t * s w i t c h _ i n f o _ e x _ t _ g e t _ j u m p s ( P y O b j e c t * self )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
P y _ R E T U R N _ N O N E ;
return P y _ B u i l d V a l u e ( P Y _ F M T 64 , ( p y u l _ t ) l i n k - > j u m p s ) ;
}
static void s w i t c h _ i n f o _ e x _ t _ s e t _ j u m p s ( P y O b j e c t * self , P y O b j e c t * value )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
return ;
2010-07-13 18:43:53 +02:00
u i n t 64 v ( 0 ) ; P y W _ G e t N u m b e r ( value , &v);
2010-06-28 14:36:40 +02:00
l i n k - > j u m p s = ( p y u l _ t ) v ;
}
static P y O b j e c t * s w i t c h _ i n f o _ e x _ t _ g e t _ e l b a s e ( P y O b j e c t * self )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
P y _ R E T U R N _ N O N E ;
return P y _ B u i l d V a l u e ( P Y _ F M T 64 , ( p y u l _ t ) l i n k - > e l b a s e ) ;
}
static void s w i t c h _ i n f o _ e x _ t _ s e t _ e l b a s e ( P y O b j e c t * self , P y O b j e c t * value )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
return ;
u i n t 64 v ( 0 ) ;
2010-07-13 18:43:53 +02:00
P y W _ G e t N u m b e r ( value , &v);
2010-06-28 14:36:40 +02:00
l i n k - > e l b a s e = ( p y u l _ t ) v ;
}
static P y O b j e c t * s w i t c h _ i n f o _ e x _ t _ g e t _ s t a r t e a ( P y O b j e c t * self )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
P y _ R E T U R N _ N O N E ;
return P y _ B u i l d V a l u e ( P Y _ F M T 64 , ( p y u l _ t ) l i n k - > s t a r t e a ) ;
}
static void s w i t c h _ i n f o _ e x _ t _ s e t _ s t a r t e a ( P y O b j e c t * self , P y O b j e c t * value )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
return ;
u i n t 64 v ( 0 ) ;
2010-07-13 18:43:53 +02:00
P y W _ G e t N u m b e r ( value , &v);
2010-06-28 14:36:40 +02:00
l i n k - > s t a r t e a = ( p y u l _ t ) v ;
}
static P y O b j e c t * s w i t c h _ i n f o _ e x _ t _ g e t _ c u s t o m ( P y O b j e c t * self )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
P y _ R E T U R N _ N O N E ;
return P y _ B u i l d V a l u e ( P Y _ F M T 64 , ( p y u l _ t ) l i n k - > c u s t o m ) ;
}
static void s w i t c h _ i n f o _ e x _ t _ s e t _ c u s t o m ( P y O b j e c t * self , P y O b j e c t * value )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
return ;
u i n t 64 v ( 0 ) ;
2010-07-13 18:43:53 +02:00
P y W _ G e t N u m b e r ( value , &v);
2010-06-28 14:36:40 +02:00
l i n k - > c u s t o m = ( p y u l _ t ) v ;
}
static P y O b j e c t * s w i t c h _ i n f o _ e x _ t _ g e t _ i n d _ l o w c a s e ( P y O b j e c t * self )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
P y _ R E T U R N _ N O N E ;
return P y _ B u i l d V a l u e ( P Y _ F M T 64 , ( p y u l _ t ) l i n k - > i n d _ l o w c a s e ) ;
}
static void s w i t c h _ i n f o _ e x _ t _ s e t _ i n d _ l o w c a s e ( P y O b j e c t * self , P y O b j e c t * value )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
return ;
u i n t 64 v ( 0 ) ;
2010-07-13 18:43:53 +02:00
P y W _ G e t N u m b e r ( value , &v);
2010-06-28 14:36:40 +02:00
l i n k - > i n d _ l o w c a s e = ( p y u l _ t ) v ;
}
static P y O b j e c t * s w i t c h _ i n f o _ e x _ t _ g e t _ v a l u e s _ l o w c a s e ( P y O b j e c t * self )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
P y _ R E T U R N _ N O N E ;
return P y _ B u i l d V a l u e ( P Y _ F M T 64 , ( p y u l _ t ) l i n k - > values ) ;
}
static void s w i t c h _ i n f o _ e x _ t _ s e t _ v a l u e s _ l o w c a s e ( P y O b j e c t * self , P y O b j e c t * value )
{
s w i t c h _ i n f o _ e x _ t * l i n k = s w i t c h _ i n f o _ e x _ t _ g e t _ c l i n k ( self ) ;
if ( l i n k = = NULL )
return ;
u i n t 64 v ( 0 ) ;
2010-07-13 18:43:53 +02:00
P y W _ G e t N u m b e r ( value , &v);
2010-06-28 14:36:40 +02:00
l i n k - > values = ( p y u l _ t ) v ;
}
//
// Auto generated - end
//
//-------------------------------------------------------------------------
2010-03-05 12:18:25 +01:00
//</inline(py_nalt)>
2010-06-28 14:36:40 +02:00
% }
% p y t h o n c o d e % {
# < p y c o d e ( p y _ n a l t ) >
S W I _ S P A R S E = 0x1
"" "sparse switch ( value table present ) otherwise lowcase present" ""
S W I _ V 32 = 0x2
"" "32-bit values in table" ""
S W I _ J 32 = 0x4
"" "32-bit jump offsets" ""
S W I _ V S P L I T = 0x8
"" "value table is split (only for 32-bit values)" ""
S W I _ D E F A U L T = 0x10
"" "default case is present" ""
S W I _ E N D _ I N _ T B L = 0x20
"" "switchend in table (default entry)" ""
S W I _ J M P _ I N V = 0x40
"" "jumptable is inversed (last entry is for first entry in values table)" ""
S W I _ S H I F T _ M A S K = 0x180
"" "use formula (element*shift + elbase) to find jump targets" ""
S W I _ E L B A S E = 0x200
"" "elbase is present (if not and shift!=0, endof(jumpea) is used)" ""
S W I _ J S I Z E = 0x400
"" "jump offset expansion bit" ""
S W I _ V S I Z E = 0x800
"" "value table element size expansion bit" ""
S W I _ S E P A R A T E = 0x1000
"" "do not create an array of individual dwords" ""
S W I _ S I G N E D = 0x2000
"" "jump table entries are signed" ""
S W I _ C U S T O M = 0x4000
"" "custom jump table - ph.create_switch_xrefs will be called to create code xrefs for the table. it must return 2. custom jump table must be created by the module" ""
S W I _ E X T E N D E D = 0x8000
"" "this is switch_info_ex_t" ""
S W I 2 _ I N D I R E C T = 0x0001
"" "value table elements are used as indexes into the jump table" ""
S W I 2 _ S U B T R A C T = 0x0002
"" "table values are subtracted from the elbase instead of being addded" ""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
class s w i t c h _ i n f o _ e x _ t ( p y _ c l i n k e d _ o b j e c t _ t ) :
def _ _ i n i t _ _ ( self , l n k = None ) :
p y _ c l i n k e d _ o b j e c t _ t . _ _ i n i t _ _ ( self , l n k )
def _ c r e a t e _ c l i n k ( self ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ c r e a t e ( )
def _ d e l _ c l i n k ( self , l n k ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ d e s t r o y ( l n k )
def assign ( self , o t h e r ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ a s s i g n ( self , o t h e r )
def i s _ i n d i r e c t ( self ) :
return ( self . f l a g s & SWI_EXTENDED) != 0 and (self.flags2 & SWI2_INDIRECT) != 0
def i s _ s u b t r a c t ( self ) :
return ( self . f l a g s & SWI_EXTENDED) != 0 and (self.flags2 & SWI2_SUBTRACT) != 0
def g e t _ j t a b l e _ s i z e ( self ) :
2011-10-14 16:24:38 +02:00
return self . j c a s e s if self . i s _ i n d i r e c t ( ) else self . n c a s e s
2010-06-28 14:36:40 +02:00
def g e t _ l o w c a s e ( self ) :
2011-10-14 16:24:38 +02:00
return self . i n d _ l o w c a s e if self . i s _ i n d i r e c t ( ) else self . l o w c a s e
2010-06-28 14:36:40 +02:00
def s e t _ e x p r ( self , r , d t ) :
self . r e g n u m = r
self . r e g d t y p = d t
def g e t _ s h i f t ( self ) :
return ( self . f l a g s & SWI_SHIFT_MASK) >> 7
def s e t _ s h i f t ( self , s h i f t ) :
self . f l a g s &= ~SWI_SHIFT_MASK
self . f l a g s | = ( ( s h i f t & 3) << 7)
def g e t _ j t a b l e _ e l e m e n t _ s i z e ( self ) :
code = self . f l a g s & (SWI_J32|SWI_JSIZE)
if code = = 0 : return 2
e l i f code = = S W I _ J 32 : return 4
e l i f code = = S W I _ J S I Z E : return 1
else : return 8
def s e t _ j t a b l e _ e l e m e n t _ s i z e ( self , size ) :
self . f l a g s &= ~(SWI_J32|SWI_JSIZE)
if size = = 4 : self . f l a g s | = S W I _ J 32
e l i f size = = 1 : self . f l a g s | = S W I _ J S I Z E
e l i f size = = 8 : self . f l a g s | = S W I _ J 32 | S W I _ J S I Z E
e l i f size ! = 2 : return False
return True
def g e t _ v t a b l e _ e l e m e n t _ s i z e ( self ) :
code = self . f l a g s & (SWI_V32|SWI_VSIZE)
if code = = 0 : return 2
e l i f code = = S W I _ V 32 : return 4
e l i f code = = S W I _ V S I Z E : return 1
return 8
def s e t _ v t a b l e _ e l e m e n t _ s i z e ( self , size ) :
self . f l a g s &= ~SWI_V32|SWI_VSIZE
if size = = 4 : self . f l a g s | = S W I _ V 32
e l i f size = = 1 : self . f l a g s | = S W I _ V S I Z E
e l i f size = = 8 : self . f l a g s | = S W I _ V 32 | S W I _ V S I Z E
e l i f size ! = 2 : return False
return True
#
# A u t o g e n e r a t e d
#
def _ _ g e t _ r e g d t y p _ _ ( self ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ g e t _ r e g d t y p ( self )
def _ _ s e t _ r e g d t y p _ _ ( self , v ) :
_ i d a a p i . s w i t c h _ i n f o _ e x _ t _ s e t _ r e g d t y p ( self , v )
def _ _ g e t _ f l a g s 2 _ _ ( self ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ g e t _ f l a g s 2 ( self )
def _ _ s e t _ f l a g s 2 _ _ ( self , v ) :
_ i d a a p i . s w i t c h _ i n f o _ e x _ t _ s e t _ f l a g s 2 ( self , v )
def _ _ g e t _ j c a s e s _ _ ( self ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ g e t _ j c a s e s ( self )
def _ _ s e t _ j c a s e s _ _ ( self , v ) :
_ i d a a p i . s w i t c h _ i n f o _ e x _ t _ s e t _ j c a s e s ( self , v )
def _ _ g e t _ r e g n u m _ _ ( self ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ g e t _ r e g n u m ( self )
def _ _ s e t _ r e g n u m _ _ ( self , v ) :
_ i d a a p i . s w i t c h _ i n f o _ e x _ t _ s e t _ r e g n u m ( self , v )
def _ _ g e t _ f l a g s _ _ ( self ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ g e t _ f l a g s ( self )
def _ _ s e t _ f l a g s _ _ ( self , v ) :
_ i d a a p i . s w i t c h _ i n f o _ e x _ t _ s e t _ f l a g s ( self , v )
def _ _ g e t _ n c a s e s _ _ ( self ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ g e t _ n c a s e s ( self )
def _ _ s e t _ n c a s e s _ _ ( self , v ) :
_ i d a a p i . s w i t c h _ i n f o _ e x _ t _ s e t _ n c a s e s ( self , v )
def _ _ g e t _ d e f j u m p _ _ ( self ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ g e t _ d e f j u m p ( self )
def _ _ s e t _ d e f j u m p _ _ ( self , v ) :
_ i d a a p i . s w i t c h _ i n f o _ e x _ t _ s e t _ d e f j u m p ( self , v )
def _ _ g e t _ j u m p s _ _ ( self ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ g e t _ j u m p s ( self )
def _ _ s e t _ j u m p s _ _ ( self , v ) :
_ i d a a p i . s w i t c h _ i n f o _ e x _ t _ s e t _ j u m p s ( self , v )
def _ _ g e t _ e l b a s e _ _ ( self ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ g e t _ e l b a s e ( self )
def _ _ s e t _ e l b a s e _ _ ( self , v ) :
_ i d a a p i . s w i t c h _ i n f o _ e x _ t _ s e t _ e l b a s e ( self , v )
def _ _ g e t _ s t a r t e a _ _ ( self ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ g e t _ s t a r t e a ( self )
def _ _ s e t _ s t a r t e a _ _ ( self , v ) :
_ i d a a p i . s w i t c h _ i n f o _ e x _ t _ s e t _ s t a r t e a ( self , v )
def _ _ g e t _ c u s t o m _ _ ( self ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ g e t _ c u s t o m ( self )
def _ _ s e t _ c u s t o m _ _ ( self , v ) :
_ i d a a p i . s w i t c h _ i n f o _ e x _ t _ s e t _ c u s t o m ( self , v )
def _ _ g e t _ i n d _ l o w c a s e _ _ ( self ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ g e t _ i n d _ l o w c a s e ( self )
def _ _ s e t _ i n d _ l o w c a s e _ _ ( self , v ) :
_ i d a a p i . s w i t c h _ i n f o _ e x _ t _ s e t _ i n d _ l o w c a s e ( self , v )
def _ _ g e t _ v a l u e s _ l o w c a s e _ _ ( self ) :
return _ i d a a p i . s w i t c h _ i n f o _ e x _ t _ g e t _ v a l u e s _ l o w c a s e ( self )
def _ _ s e t _ v a l u e s _ l o w c a s e _ _ ( self , v ) :
_ i d a a p i . s w i t c h _ i n f o _ e x _ t _ s e t _ v a l u e s _ l o w c a s e ( self , v )
r e g d t y p = property ( _ _ g e t _ r e g d t y p _ _ , _ _ s e t _ r e g d t y p _ _ )
"" "size of the switch expression register as dtyp" ""
f l a g s 2 = property ( _ _ g e t _ f l a g s 2 _ _ , _ _ s e t _ f l a g s 2 _ _ )
j c a s e s = property ( _ _ g e t _ j c a s e s _ _ , _ _ s e t _ j c a s e s _ _ )
"" "number of entries in the jump table (SWI2_INDIRECT)" ""
r e g n u m = property ( _ _ g e t _ r e g n u m _ _ , _ _ s e t _ r e g n u m _ _ )
"" "the switch expression as a register number" ""
f l a g s = property ( _ _ g e t _ f l a g s _ _ , _ _ s e t _ f l a g s _ _ )
"" "the switch expression as a register number" ""
n c a s e s = property ( _ _ g e t _ n c a s e s _ _ , _ _ s e t _ n c a s e s _ _ )
"" "number of cases (excluding default)" ""
d e f j u m p = property ( _ _ g e t _ d e f j u m p _ _ , _ _ s e t _ d e f j u m p _ _ )
"" "default jump address" ""
j u m p s = property ( _ _ g e t _ j u m p s _ _ , _ _ s e t _ j u m p s _ _ )
"" "jump table address" ""
e l b a s e = property ( _ _ g e t _ e l b a s e _ _ , _ _ s e t _ e l b a s e _ _ )
"" "element base" ""
s t a r t e a = property ( _ _ g e t _ s t a r t e a _ _ , _ _ s e t _ s t a r t e a _ _ )
"" "start of switch idiom" ""
c u s t o m = property ( _ _ g e t _ c u s t o m _ _ , _ _ s e t _ c u s t o m _ _ )
"" "information for custom tables (filled and used by modules)" ""
i n d _ l o w c a s e = property ( _ _ g e t _ i n d _ l o w c a s e _ _ , _ _ s e t _ i n d _ l o w c a s e _ _ )
values = property ( _ _ g e t _ v a l u e s _ l o w c a s e _ _ , _ _ s e t _ v a l u e s _ l o w c a s e _ _ )
l o w c a s e = property ( _ _ g e t _ v a l u e s _ l o w c a s e _ _ , _ _ s e t _ v a l u e s _ l o w c a s e _ _ )
# < / p y c o d e ( p y _ n a l t ) >
2010-03-05 12:18:25 +01:00
% }