| View previous topic :: View next topic |
| Author |
Message |
MeLLo Advanced Cheater
Reputation: 0
Joined: 22 Oct 2005 Posts: 60
|
Posted: Wed Feb 11, 2009 7:47 am Post subject: [Delphi] WriteProcessMemory and float [Solved] |
|
|
I can use WriteProcessMemory, but if i try to use a float value it writes 0 as value, what should i do to write float values to the memory?
here is my code
| Code: | function wpm(processo:string; data,endereco:integer; valor:real):boolean; stdcall; export;
begin
result:=false;
if GetID(processo) then
begin
Pidhandle := OpenProcess(PROCESS_ALL_ACCESS,False,ProcessId);
WriteProcessMemory(Pidhandle, Pointer(endereco), @valor, Data, Written);
closehandle(Pidhandle);
result:=true;
end;
end; |
Thanks in advance and sory for my poor english.
Last edited by MeLLo on Thu Feb 12, 2009 8:36 am; edited 1 time in total |
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Wed Feb 11, 2009 8:52 am Post subject: Re: [Delphi] WriteProcessMemory and float |
|
|
| MeLLo wrote: | I can use WriteProcessMemory, but if i try to use a float value it writes 0 as value, what should i do to write float values to the memory?
here is my code
| Code: | function wpm(processo:string; data,endereco:integer; valor:real):boolean; stdcall; export;
begin
result:=false;
if GetID(processo) then
begin
Pidhandle := OpenProcess(PROCESS_ALL_ACCESS,False,ProcessId);
WriteProcessMemory(Pidhandle, Pointer(endereco), @valor, Data, Written);
closehandle(Pidhandle);
result:=true;
end;
end; |
Thanks in advance and sory for my poor english. |
I dont understand this. So must be another version of delphi but....
Why is it data? it should be sizeof(valor)
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Wed Feb 11, 2009 11:00 am Post subject: |
|
|
| Code: | Remove stdcall;
Replace Pointer with Ptr()
Check if PidHandle (no such thing) != INVALID_HANDLE_VALUE
Replace Begin/End with Try/Finally |
|
|
| Back to top |
|
 |
MeLLo Advanced Cheater
Reputation: 0
Joined: 22 Oct 2005 Posts: 60
|
Posted: Wed Feb 11, 2009 1:36 pm Post subject: |
|
|
Justr tryed, but i had the same results, sometimes i can change the value, but it doesn't change to the value i want.
But thanks for the help, if i manage to find the problem i'll post the solution here.
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Wed Feb 11, 2009 2:09 pm Post subject: |
|
|
Open calc, (Dec) and type the Float (in Delphi it's Extended, but i rather use Double) and convert it to Hex, then use $ with it.
leave feedback! (just a theory)
Edit: post your @Buffer source, maybe you did something wrong.
|
|
| Back to top |
|
 |
MeLLo Advanced Cheater
Reputation: 0
Joined: 22 Oct 2005 Posts: 60
|
Posted: Wed Feb 11, 2009 4:21 pm Post subject: |
|
|
man, i'll try the hex, but the code is ok.
i can write 4 bytes 8 bytes, 2 bytes, 1byte with no problem.
may i ask u a favor? could u try to use writeprocessmemory with a float value an see with ce if it worked.
Because its weird, i try with a float, i get 0 or a weird number. If i get an address with a float value in ce, then change the type to 4 bytes and use that value, i can change the value just fine with my code (using integer not real...)
Man... thanks for the help.
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Wed Feb 11, 2009 5:47 pm Post subject: |
|
|
| You do know that float numbers are bigger than 4 bytes right?
|
|
| Back to top |
|
 |
MeLLo Advanced Cheater
Reputation: 0
Joined: 22 Oct 2005 Posts: 60
|
Posted: Wed Feb 11, 2009 6:49 pm Post subject: |
|
|
Sure do.
That's why i think it's weird... because with 4 bytes it works fine, but once i try more bytes and float a a value... i cant get the right value.
|
|
| Back to top |
|
 |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Wed Feb 11, 2009 9:28 pm Post subject: |
|
|
| define endereco at the top to float
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Wed Feb 11, 2009 11:43 pm Post subject: |
|
|
| dnsi0 wrote: | | You do know that float numbers are bigger than 4 bytes right? |
Since when? Floats are 4 bytes in length, and doubles (which is probably what you are thinking about) are 8 bytes in length.
|
|
| Back to top |
|
 |
MeLLo Advanced Cheater
Reputation: 0
Joined: 22 Oct 2005 Posts: 60
|
Posted: Thu Feb 12, 2009 6:56 am Post subject: |
|
|
Just solved the problem.
It was an easy one, the fact is that delphi uses single for floats of 32 bits and double for floats of 64 bits... (so single = 4 bytes, double = 8 bytes).
So... i just had to change the real type to single.
Thanks for the help.
|
|
| Back to top |
|
 |
|