mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[0.2.x] added: ptrFloat, ptrDouble, loadFloats, loadDoubles routines ( reading floating point data )
git-svn-id: https://pykd.svn.codeplex.com/svn@82308 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
e4b34e1236
commit
23244e1eb8
@ -130,6 +130,28 @@ LONG64 ptrSignMWord( ULONG64 offset )
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
double ptrSingleFloat( ULONG64 offset )
|
||||
{
|
||||
float val = 0;
|
||||
|
||||
readMemory( offset, &val, sizeof(val), false );
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
double ptrDoubleFloat( ULONG64 offset )
|
||||
{
|
||||
double val = 0;
|
||||
|
||||
readMemory( offset, &val, sizeof(val), false );
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename T>
|
||||
struct PyListType
|
||||
{
|
||||
@ -217,6 +239,20 @@ python::list loadSignQWords( ULONG64 offset, ULONG count, bool phyAddr )
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
python::list loadFloats( ULONG64 offset, ULONG count, bool phyAddr )
|
||||
{
|
||||
return loadArray<float>( offset, count, phyAddr );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
python::list loadDoubles( ULONG64 offset, ULONG count, bool phyAddr )
|
||||
{
|
||||
return loadArray<double>( offset, count, phyAddr );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string loadChars( ULONG64 offset, ULONG number, bool phyAddr )
|
||||
{
|
||||
std::vector<char> buffer(number);
|
||||
|
@ -28,6 +28,9 @@ LONG64 ptrSignQWord( ULONG64 offset );
|
||||
LONG64 ptrSignMWord( ULONG64 offset );
|
||||
ULONG64 ptrPtr( ULONG64 offset );
|
||||
|
||||
double ptrSingleFloat( ULONG64 offset );
|
||||
double ptrDoubleFloat( ULONG64 offset );
|
||||
|
||||
python::list loadBytes( ULONG64 offset, ULONG count, bool phyAddr = FALSE );
|
||||
python::list loadWords( ULONG64 offset, ULONG count, bool phyAddr = FALSE );
|
||||
python::list loadDWords( ULONG64 offset, ULONG count, bool phyAddr = FALSE );
|
||||
@ -37,6 +40,9 @@ python::list loadSignWords( ULONG64 offset, ULONG count, bool phyAddr = FALSE );
|
||||
python::list loadSignDWords( ULONG64 offset, ULONG count, bool phyAddr = FALSE );
|
||||
python::list loadSignQWords( ULONG64 offset, ULONG count, bool phyAddr = FALSE );
|
||||
|
||||
python::list loadFloats( ULONG64 offset, ULONG count, bool phyAddr = FALSE );
|
||||
python::list loadDoubles( ULONG64 offset, ULONG count, bool phyAddr = FALSE );
|
||||
|
||||
python::list loadPtrList( ULONG64 offset );
|
||||
python::list loadPtrArray( ULONG64 offset, ULONG number );
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define PYKD_VERSION_MAJOR 0
|
||||
#define PYKD_VERSION_MINOR 2
|
||||
#define PYKD_VERSION_SUBVERSION 0
|
||||
#define PYKD_VERSION_BUILDNO 14
|
||||
#define PYKD_VERSION_BUILDNO 15
|
||||
|
||||
|
||||
#define __VER_STR2__(x) #x
|
||||
|
@ -53,6 +53,8 @@ BOOST_PYTHON_FUNCTION_OVERLOADS( loadSignBytes_, loadSignBytes, 2, 3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( loadSignWords_, loadSignWords, 2, 3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( loadSignDWords_, loadSignDWords, 2, 3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( loadSignQWords_, loadSignQWords, 2, 3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( loadFloats_, loadFloats, 2, 3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( loadDoubles_, loadDoubles, 2, 3 );
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( compareMemory_, compareMemory, 3, 4 );
|
||||
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS( getSourceLine_, getSourceLine, 0, 1 );
|
||||
@ -176,9 +178,13 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
"Read an signed mashine's word wide integer from the target memory" );
|
||||
python::def( "ptrPtr", (ULONG64(*)(ULONG64))&ptrPtr,
|
||||
"Read an pointer value from the target memory" );
|
||||
python::def( "ptrFloat", &ptrSingleFloat,
|
||||
"Read a float with single precision from the target memory" );
|
||||
python::def( "ptrDouble", &ptrDoubleFloat,
|
||||
"Read a float with single precision from the target memory" );
|
||||
|
||||
python::def( "loadBytes", &loadBytes, loadBytes_( python::args( "offset", "count", "phyAddr" ),
|
||||
"Read the block of the target's memory and return it as liat of unsigned bytes" ) );
|
||||
"Read the block of the target's memory and return it as list of unsigned bytes" ) );
|
||||
python::def( "loadWords", &loadWords, loadWords_( python::args( "offset", "count", "phyAddr" ),
|
||||
"Read the block of the target's memory and return it as list of unsigned shorts" ) );
|
||||
python::def( "loadDWords", &loadDWords, loadDWords_( python::args( "offset", "count", "phyAddr" ),
|
||||
@ -209,6 +215,10 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
"Return list of pointers, each points to next" );
|
||||
python::def( "loadPtrs", &loadPtrArray,
|
||||
"Read the block of the target's memory and return it as a list of pointers" );
|
||||
python::def( "loadFloats", &loadFloats, loadFloats_( python::args( "offset", "count", "phyAddr" ),
|
||||
"Read the block of the target's memory and return it as list of floats" ) );
|
||||
python::def( "loadDoubles", &loadDoubles, loadDoubles_( python::args( "offset", "count", "phyAddr" ),
|
||||
"Read the block of the target's memory and return it as list of doubles" ) );
|
||||
|
||||
// types and vaiables
|
||||
python::def( "getSourceFile", &getSourceFile, getSourceFile_( python::args( "offset"),
|
||||
|
@ -5,6 +5,7 @@
|
||||
import unittest
|
||||
import target
|
||||
import pykd
|
||||
import math
|
||||
|
||||
class MemoryTest( unittest.TestCase ):
|
||||
|
||||
@ -104,4 +105,20 @@ class MemoryTest( unittest.TestCase ):
|
||||
pykd.loadSignBytes( 0xDEADBEEF, 5 )
|
||||
except pykd.MemoryException:
|
||||
self.assertTrue( True )
|
||||
|
||||
|
||||
def testPtrFloat(self):
|
||||
self.assertTrue( math.fabs( pykd.ptrFloat( target.module.g_float) - 5.123456 ) < 0.001 )
|
||||
self.assertTrue( math.fabs( pykd.ptrDouble( target.module.g_double) - 5.1234567891 ) < 0.0000001 )
|
||||
|
||||
def testLoadFloats(self):
|
||||
testArray = [ 1.0, 2.001, -3.0004 ];
|
||||
readArray = pykd.loadFloats( target.module.floatArray, 3 );
|
||||
for i in range(0,3):
|
||||
self.assertTrue( math.fabs( testArray[i] - readArray[i] ) < 0.001 )
|
||||
|
||||
def testLoadDoubles(self):
|
||||
testArray = [ 1.0, 2.0000001, -3.0000004 ];
|
||||
readArray = pykd.loadDoubles( target.module.doubleArray, 3 );
|
||||
print readArray
|
||||
for i in range(0,3):
|
||||
self.assertTrue( math.fabs( testArray[i] - readArray[i] ) < 0.0000001 )
|
||||
|
@ -65,11 +65,11 @@ class ModuleTest( unittest.TestCase ):
|
||||
fileName = pykd.getSourceFile(target.module.FuncWithName0 )
|
||||
self.assertTrue( re.search('targetapp\\.cpp', fileName ) )
|
||||
fileName, lineNo, displacement = pykd.getSourceLine( target.module.FuncWithName0 + 2)
|
||||
self.assertEqual( 395, lineNo )
|
||||
self.assertEqual( 400, lineNo )
|
||||
self.assertTrue( re.search('targetapp\\.cpp', fileName ) )
|
||||
self.assertEqual( 2, displacement )
|
||||
fileName, lineNo, displacement = pykd.getSourceLine()
|
||||
self.assertEqual( 653, lineNo )
|
||||
self.assertEqual( 663, lineNo )
|
||||
|
||||
def testEnumSymbols( self ):
|
||||
lst = target.module.enumSymbols()
|
||||
|
@ -36,6 +36,9 @@ SHORT g_shortValue = -2;
|
||||
LONG g_longValue = -4;
|
||||
LONGLONG g_longlongValue = -8;
|
||||
|
||||
float g_float = 5.123456f;
|
||||
double g_double = 5.1234567891;
|
||||
|
||||
std::string g_string;
|
||||
|
||||
struct structWithBits {
|
||||
@ -114,6 +117,8 @@ unsigned long ulongArray[] = {0, 0xFF, 0x8000, 0x80000000, 0xFFFFFFFF };
|
||||
long longArray[] = {0, -10, -2000, -100000, 0xFFFFFFFF };
|
||||
unsigned __int64 ulonglongArray[] = {0, 0xFF, 0xFFFFFFFF, 0x8000000000000000, 0xFFFFFFFFFFFFFFFF };
|
||||
long long longlongArray[] = {0, -10, -2000, -100000, -10000000000 };
|
||||
float floatArray[] = { 1.0f, 2.001f, -3.0004f };
|
||||
double doubleArray[] = { 1.0, 2.0000001, -3.0000004 };
|
||||
|
||||
int intMatrix[2][3] = { { 0, 1, 2}, { 3, 4, 5 } };
|
||||
int intMatrix2[2][3] = { { 0, 1, 2}, { 3, 4, 5 } };
|
||||
@ -421,6 +426,8 @@ void FuncWithName0()
|
||||
std::cout << ushortArray[2];
|
||||
std::cout << ulongArray[2];
|
||||
std::cout << ulonglongArray[2];
|
||||
std::cout << floatArray[2];
|
||||
std::cout << doubleArray[2];
|
||||
|
||||
std::cout << intMatrix[1][1];
|
||||
std::cout << strArray[0];
|
||||
@ -450,6 +457,9 @@ void FuncWithName0()
|
||||
std::cout << g_nullSizeArray;
|
||||
std::cout << g_structAbstract;
|
||||
|
||||
std::cout << g_float;
|
||||
std::cout << g_double;
|
||||
|
||||
//std::cout << g_virtChild.VirtualBaseClass1::m_baseField;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user