Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Vb.net float

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
KareZ
How do I cheat?
Reputation: 0

Joined: 18 Dec 2012
Posts: 7

PostPosted: Wed Dec 19, 2012 6:38 am    Post subject: Vb.net float Reply with quote

I've the static address + offset of health value that is float .. when i try to make a trainer with vb.net ..

Code:

...blabla code blabla...
Dim val as Double = Textbox1.text
WriteProcessMemory(pHandle,Address, val, 2, 4)


It doesnt "edit" the health value for example from 10 to 99 but if i write in textbox -> 999999 ... the hp in game go up to, for example, 11 -> 11.003456

Shocked Shocked Shocked
Back to top
View user's profile Send private message
Pingo
Grandmaster Cheater
Reputation: 8

Joined: 12 Jul 2007
Posts: 571

PostPosted: Wed Dec 19, 2012 2:38 pm    Post subject: Reply with quote

Maybe cause your defining the value as a double instead of a float?

Try
Code:
Dim val As Single = TextBox1.Text

_________________
Back to top
View user's profile Send private message
KareZ
How do I cheat?
Reputation: 0

Joined: 18 Dec 2012
Posts: 7

PostPosted: Thu Dec 20, 2012 2:07 am    Post subject: Reply with quote

I've tryed also with Single ... and if i write in textbox 999 on cheatengine i get something like 1.2398329E-23 (float) Crying or Very sad
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Dec 20, 2012 10:37 am    Post subject: Reply with quote

Parse the text into your float instead of just attempting to assign it.

Code:
Dim val As Single
If Single.TryParse(Textbox1.text, val) Then
   WriteProcessMemory(pHandle,Address, val, 2, 4)
End If


Also it would help to post your definition of WriteProcessMemory too since the protoype you give of it here does not match what it should be and appears that you are trying to write two bytes instead of the proper four for a single (float).

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Pingo
Grandmaster Cheater
Reputation: 8

Joined: 12 Jul 2007
Posts: 571

PostPosted: Thu Dec 20, 2012 2:43 pm    Post subject: Reply with quote

Haha i was also gonna post that!
About tryparse and see what his api looked like, strange.

Anyway post more code. Looks like it'l be an easy fix but without knowing more about whats going on, i can't say for sure.

_________________
Back to top
View user's profile Send private message
KareZ
How do I cheat?
Reputation: 0

Joined: 18 Dec 2012
Posts: 7

PostPosted: Sat Dec 22, 2012 2:34 am    Post subject: Reply with quote

Code:
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Long, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer


It keeps add value like 0.0001526 if i write 10 in textbox ... so if i've 200 hp i get 200.0001526 Crying or Very sad

Im using this table -> forum(.)cheatengine(.)org/viewtopic(.)php?t=557431&sid=ba2fc5ee1cea105fa6ca85507b3d4b60
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25832
Location: The netherlands

PostPosted: Sat Dec 22, 2012 2:50 am    Post subject: Reply with quote

a float is 4 bytes long, not 2, so change the 2 to 4
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
KareZ
How do I cheat?
Reputation: 0

Joined: 18 Dec 2012
Posts: 7

PostPosted: Sat Dec 22, 2012 4:46 am    Post subject: Reply with quote

Dark Byte wrote:
a float is 4 bytes long, not 2, so change the 2 to 4


333 Health -> 4.666323886E-43 Shocked
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25832
Location: The netherlands

PostPosted: Sat Dec 22, 2012 6:00 pm    Post subject: Reply with quote

I just noticed that you declared lpBuffer as a long, which is a normal integer type.
This means that visual basic converts the float to a integer, and then passes the pointer to that
meaning that it writes the integer 333 to the memory instead of the float

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun Dec 23, 2012 7:37 am    Post subject: Reply with quote

KareZ wrote:
Code:
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Long, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer


It keeps add value like 0.0001526 if i write 10 in textbox ... so if i've 200 hp i get 200.0001526 Crying or Very sad

Im using this table -> forum(.)cheatengine(.)org/viewtopic(.)php?t=557431&sid=ba2fc5ee1cea105fa6ca85507b3d4b60


Uhm, this is a VB6 method of importing an API.
So which are you using? VB.NET or VB6?

If you are using VB.NET you should import the API like this:
Code:

<DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function WriteProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal lpBuffer As Byte(), ByVal nSize As System.UInt32, <Out()> ByRef lpNumberOfBytesWritten As IntPtr) As Boolean
End Function

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites