| View previous topic :: View next topic |
| Author |
Message |
Sharel972 Newbie cheater
Reputation: 0
Joined: 02 Nov 2009 Posts: 24 Location: israel
|
Posted: Sun Jan 03, 2010 12:14 pm Post subject: [C++] Read Double Pointer |
|
|
here's my pointer reader :
| Code: |
//Reads a Pointer
__inline ULONG_PTR ReadPointer(ULONG_PTR* ulBase, INT nOffset)
{
if ( !IsBadReadPtr((VOID*)ulBase, sizeof(ULONG_PTR)) )
if ( !IsBadReadPtr((VOID*)((*(ULONG_PTR*)ulBase)+nOffset), sizeof(ULONG_PTR)) )
return *(ULONG_PTR*)((*(ULONG_PTR*)ulBase)+nOffset);
return 0;
}
// Read Double Pointers
__inline DOUBLE ReadDouble(ULONG_PTR* ulBase, INT nOffset)
{
if(!IsBadReadPtr((VOID*)ulBase, sizeof(double)))
if(!IsBadReadPtr((VOID*)((*(ULONG_PTR*)ulBase)+nOffset), sizeof(DOUBLE)))
return *(DOUBLE*)((*(ULONG_PTR*)ulBase)+nOffset);
return 0;
}
|
when i do this :
| Code: | SetDlgItemText(hWnd, IDC_MP, _itoa(ReadDouble((ULONG_PTR*)StatBase, StatMP), buf, 10));
|
i am get an warrning :
| Quote: |
warning C4244: 'argument' : conversion from 'DOUBLE' to 'int', possible loss of data |
and the reader not works .
HELP>.<
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jan 03, 2010 12:25 pm Post subject: |
|
|
| _stprintf()
|
|
| Back to top |
|
 |
Sharel972 Newbie cheater
Reputation: 0
Joined: 02 Nov 2009 Posts: 24 Location: israel
|
Posted: Sun Jan 03, 2010 12:31 pm Post subject: |
|
|
didn't relly understand
what do u mean?
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jan 03, 2010 12:35 pm Post subject: |
|
|
use that function to format your double as a string. at the moment you're trying to convert it as an int when it is a double
_itoa is for integers
|
|
| Back to top |
|
 |
Sharel972 Newbie cheater
Reputation: 0
Joined: 02 Nov 2009 Posts: 24 Location: israel
|
Posted: Sun Jan 03, 2010 12:42 pm Post subject: |
|
|
| it;s not it , i succeed befor to do that but i don't remember how . ...
|
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Sun Jan 03, 2010 1:22 pm Post subject: |
|
|
| Sharel972 wrote: | | it;s not it , i succeed befor to do that but i don't remember how . ... |
You won't be able to itoa a double..yes it is it.
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun Jan 03, 2010 2:09 pm Post subject: |
|
|
Since you're using C++, you should probably make use of some of its features.
| Code: | #include <windows.h>
#include <iostream>
using namespace std;
template <typename T>
bool CrashProgramRandomly(const T *ptr) {
return ::IsBadReadPtr(ptr, sizeof(T)) ? true : false;
}
template <typename T>
bool Read(const T ** base, unsigned int offset, T & out)
{
if(!CrashProgramRandomly<const T*>(base)) {
if(!CrashProgramRandomly<T>((const T *)((char*)(*base) + offset))) {
out = *(T*)((char*)(*base) + offset);
return true;
}
}
return false;
}
int someNumber = 1337;
int magicNumber = 42;
int main()
{
const int *somePtr = &someNumber;
int anotherNumber;
if(Read(&somePtr, sizeof(int), anotherNumber)) {
cout << anotherNumber << endl;
}
return 0;
} |
(You should probably replace those C style casts with proper C++ casts. I didn't because it would make the example look like a cluster fuck, and I'm lazy.)
|
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Sun Jan 03, 2010 2:19 pm Post subject: |
|
|
| Flyte: The program clearly has a dialog as its GUI, and that is his main issue. Can you help him with that instead of unnecessary examples?
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jan 03, 2010 2:21 pm Post subject: |
|
|
| smartz993 wrote: | | Flyte: The program clearly has a dialog as its GUI, and that is his main issue. Can you help him with that instead of unnecessary examples? |
It's his job to impart wisdom. See here : http://forum.cheatengine.org/viewtopic.php?t=479428&postdays=0&postorder=asc&start=0
Despite Flyte having been given tens of thousands of dollars in scholarship money, numerous awards, and even attending a university that essentially pays him to go there, he is still full of shit. He has no interest in helping people, only showing off what little he knows.
OP : here is an example how to convert a hex address for example :
| Code: | | swprintf_s( szAddress, _countof( szAddress ), _T("%08X"), i ); |
Same principle applies
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun Jan 03, 2010 2:25 pm Post subject: |
|
|
| smartz993 wrote: | | Flyte: The program clearly has a dialog as its GUI, and that is his main issue. Can you help him with that instead of unnecessary examples? |
Clearly his issue is not understanding the difference between primitive types.
| Code: | <Flyte> !right
<nolyc> http://adrinael.net/youreright.jpg |
No one else here seems to be capable of doing it.
| Slugsnack wrote: |
OP : here is an example how to convert a hex address for example :
| Code: | | swprintf_s( szAddress, _countof( szAddress ), _T("%08X"), i ); |
|
Giving him C code when he is programming in C++... see above.
|
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Sun Jan 03, 2010 2:28 pm Post subject: |
|
|
| Flyte wrote: | | smartz993 wrote: | | Flyte: The program clearly has a dialog as its GUI, and that is his main issue. Can you help him with that instead of unnecessary examples? |
Clearly his issue is not understanding the difference between primitive types.
| Code: | <Flyte> !right
<nolyc> http://adrinael.net/youreright.jpg |
No one else here seems to be capable of doing it.
| Slugsnack wrote: |
OP : here is an example how to convert a hex address for example :
| Code: | | swprintf_s( szAddress, _countof( szAddress ), _T("%08X"), i ); |
|
Giving him C code when he is programming in C++... see above. |
I don't see how you can criticize other replies to his problem, if you yourself have not given a valid response.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Jan 03, 2010 2:32 pm Post subject: |
|
|
| Flyte wrote: | | smartz993 wrote: | | Flyte: The program clearly has a dialog as its GUI, and that is his main issue. Can you help him with that instead of unnecessary examples? |
Clearly his issue is not understanding the difference between primitive types. |
Are you blind.. ? That clearly is his issue
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun Jan 03, 2010 2:33 pm Post subject: |
|
|
| smartz993 wrote: | | I don't see how you can criticize other replies to his problem, if you yourself have not given a valid response. |
There are many ways to do this. The easiest would be to use boost::lexical_cast.
| Slugsnack wrote: | | Are you blind.. ? That clearly is his issue |
His problem is not related to his GUI at all. Replace SetDlgItemText with any function that wants a 'const char *' and he will end up with the exact same error.
I reiterate: his problem is not understanding the differences between the primitive types.
Last edited by Flyte on Sun Jan 03, 2010 2:35 pm; edited 1 time in total |
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Sun Jan 03, 2010 2:35 pm Post subject: |
|
|
| Flyte wrote: | | smartz993 wrote: | | I don't see how you can criticize other replies to his problem, if you yourself have not given a valid response. |
There are many ways to do this. The easiest would be to use boost::lexical_cast. |
With this, you can just cast a double right to a char*?
I'll have to start reading more about boost APIs.
| Code: | | boost::lexical_cast<std::string>(doublevalue) |
Last edited by smartz993 on Sun Jan 03, 2010 2:38 pm; edited 1 time in total |
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun Jan 03, 2010 2:37 pm Post subject: |
|
|
| smartz993 wrote: | With this, you can just cast a double right to a char*?
I'll have to start reading more about boost APIs. |
No, you would cast to std::string then use string::c_str(). I would hope something this simple would be obvious.
|
|
| Back to top |
|
 |
|