readFloat support (to be checked for SHM builds !)

develop
simon 2010-04-20 18:13:00 +02:00
parent ae01bfe18e
commit 22b703e085
6 changed files with 88 additions and 5 deletions

@ -704,6 +704,25 @@ void SHMProcess::readDWord (const uint32_t offset, uint32_t &val)
val = D_SHMHDR->value; val = D_SHMHDR->value;
} }
float SHMProcess::readFloat (const uint32_t offset)
{
if(!d->locked) throw Error::MemoryAccessDenied();
D_SHMHDR->address = offset;
gcc_barrier
d->SetAndWait(CORE_READ_DWORD);
return D_SHMHDR->value;
}
void SHMProcess::readFloat (const uint32_t offset, float &val)
{
if(!d->locked) throw Error::MemoryAccessDenied();
D_SHMHDR->address = offset;
gcc_barrier
d->SetAndWait(CORE_READ_DWORD);
val = D_SHMHDR->value;
}
/* /*
* WRITING * WRITING
*/ */
@ -890,4 +909,4 @@ bool SHMProcess::Private::Aux_Core_Attach(bool & versionOK, pid_t & PID)
if(useYield) cerr << "Using Yield!" << endl; if(useYield) cerr << "Using Yield!" << endl;
#endif #endif
return true; return true;
} }

@ -430,6 +430,17 @@ void WineProcess::readDWord (const uint32_t offset, uint32_t &val)
read(offset, 4, (uint8_t *) &val); read(offset, 4, (uint8_t *) &val);
} }
float WineProcess::readFloat (const uint32_t offset)
{
float val;
read(offset, 4, (uint8_t *) &val);
return val;
}
void WineProcess::readFloat (const uint32_t offset, float &val)
{
read(offset, 4, (uint8_t *) &val);
}
/* /*
* WRITING * WRITING
*/ */
@ -588,4 +599,4 @@ string WineProcess::readClassName (uint32_t vptr)
string raw = readCString(typeinfo + 0xC); // skips the .?AV string raw = readCString(typeinfo + 0xC); // skips the .?AV
raw.resize(raw.length() - 2);// trim @@ from end raw.resize(raw.length() - 2);// trim @@ from end
return raw; return raw;
} }

@ -417,6 +417,17 @@ void NormalProcess::readDWord (const uint32_t offset, uint32_t &val)
read(offset, 4, (uint8_t *) &val); read(offset, 4, (uint8_t *) &val);
} }
float NormalProcess::readFloat (const uint32_t offset)
{
float val;
read(offset, 4, (uint8_t *) &val);
return val;
}
void NormalProcess::readFloat (const uint32_t offset, float &val)
{
read(offset, 4, (uint8_t *) &val);
}
/* /*
* WRITING * WRITING
*/ */
@ -540,4 +551,4 @@ string NormalProcess::readClassName (uint32_t vptr)
size_t start = raw.find_first_of("abcdefghijklmnopqrstuvwxyz");// trim numbers size_t start = raw.find_first_of("abcdefghijklmnopqrstuvwxyz");// trim numbers
size_t end = raw.length(); size_t end = raw.length();
return raw.substr(start,end-start); return raw.substr(start,end-start);
} }

@ -762,6 +762,26 @@ void SHMProcess::readDWord (const uint32_t offset, uint32_t &val)
val = D_SHMHDR->value; val = D_SHMHDR->value;
} }
float SHMProcess::readFloat (const uint32_t offset)
{
if(!d->locked) throw Error::MemoryAccessDenied();
D_SHMHDR->address = offset;
full_barrier
d->SetAndWait(CORE_READ_DWORD);
return D_SHMHDR->value;
}
void SHMProcess::readFloat (const uint32_t offset, float &val)
{
if(!d->locked) throw Error::MemoryAccessDenied();
D_SHMHDR->address = offset;
full_barrier
d->SetAndWait(CORE_READ_DWORD);
val = D_SHMHDR->value;
}
/* /*
* WRITING * WRITING
*/ */
@ -944,4 +964,4 @@ bool SHMProcess::Private::Aux_Core_Attach(bool & versionOK, uint32_t & PID)
if(useYield) cerr << "Using Yield!" << endl; if(useYield) cerr << "Using Yield!" << endl;
#endif #endif
return true; return true;
} }

@ -365,6 +365,20 @@ void NormalProcess::readDWord (const uint32_t offset, uint32_t &result)
throw Error::MemoryAccessDenied(); throw Error::MemoryAccessDenied();
} }
float NormalProcess::readFloat (const uint32_t offset)
{
float result;
if(!ReadProcessMemory(d->my_handle, (int*) offset, &result, sizeof(float), NULL))
throw Error::MemoryAccessDenied();
return result;
}
void NormalProcess::readFloat (const uint32_t offset, float &result)
{
if(!ReadProcessMemory(d->my_handle, (int*) offset, &result, sizeof(float), NULL))
throw Error::MemoryAccessDenied();
}
void NormalProcess::read (const uint32_t offset, uint32_t size, uint8_t *target) void NormalProcess::read (const uint32_t offset, uint32_t size, uint8_t *target)
{ {
if(!ReadProcessMemory(d->my_handle, (int*) offset, target, size, NULL)) if(!ReadProcessMemory(d->my_handle, (int*) offset, target, size, NULL))
@ -489,4 +503,4 @@ string NormalProcess::readClassName (uint32_t vptr)
string raw = readCString(typeinfo + 0xC); // skips the .?AV string raw = readCString(typeinfo + 0xC); // skips the .?AV
raw.resize(raw.length() - 2);// trim @@ from end raw.resize(raw.length() - 2);// trim @@ from end
return raw; return raw;
} }

@ -81,7 +81,9 @@ namespace DFHack
virtual bool forceresume() = 0; virtual bool forceresume() = 0;
virtual uint32_t readDWord(const uint32_t address) = 0; virtual uint32_t readDWord(const uint32_t address) = 0;
virtual float readFloat(const uint32_t address) = 0;
virtual void readDWord(const uint32_t address, uint32_t & value) = 0; virtual void readDWord(const uint32_t address, uint32_t & value) = 0;
virtual void readFloat(const uint32_t address, float & value) = 0;
virtual uint16_t readWord(const uint32_t address) = 0; virtual uint16_t readWord(const uint32_t address) = 0;
virtual void readWord(const uint32_t address, uint16_t & value) = 0; virtual void readWord(const uint32_t address, uint16_t & value) = 0;
virtual uint8_t readByte(const uint32_t address) = 0; virtual uint8_t readByte(const uint32_t address) = 0;
@ -150,7 +152,9 @@ namespace DFHack
bool forceresume(); bool forceresume();
uint32_t readDWord(const uint32_t address); uint32_t readDWord(const uint32_t address);
float readFloat(const uint32_t address);
void readDWord(const uint32_t address, uint32_t & value); void readDWord(const uint32_t address, uint32_t & value);
void readFloat(const uint32_t address, float & value);
uint16_t readWord(const uint32_t address); uint16_t readWord(const uint32_t address);
void readWord(const uint32_t address, uint16_t & value); void readWord(const uint32_t address, uint16_t & value);
uint8_t readByte(const uint32_t address); uint8_t readByte(const uint32_t address);
@ -213,7 +217,9 @@ namespace DFHack
bool forceresume(); bool forceresume();
uint32_t readDWord(const uint32_t address); uint32_t readDWord(const uint32_t address);
float readFloat(const uint32_t address);
void readDWord(const uint32_t address, uint32_t & value); void readDWord(const uint32_t address, uint32_t & value);
void readFloat(const uint32_t address, float & value);
uint16_t readWord(const uint32_t address); uint16_t readWord(const uint32_t address);
void readWord(const uint32_t address, uint16_t & value); void readWord(const uint32_t address, uint16_t & value);
uint8_t readByte(const uint32_t address); uint8_t readByte(const uint32_t address);
@ -275,7 +281,9 @@ namespace DFHack
bool forceresume(); bool forceresume();
uint32_t readDWord(const uint32_t address); uint32_t readDWord(const uint32_t address);
float readFloat(const uint32_t address);
void readDWord(const uint32_t address, uint32_t & value); void readDWord(const uint32_t address, uint32_t & value);
void readFloat(const uint32_t address, float & value);
uint16_t readWord(const uint32_t address); uint16_t readWord(const uint32_t address);
void readWord(const uint32_t address, uint16_t & value); void readWord(const uint32_t address, uint16_t & value);
uint8_t readByte(const uint32_t address); uint8_t readByte(const uint32_t address);