-
Sep 12th, 2014, 03:58 PM
#1
Thread Starter
New Member
Visual Studio: How to write a float to an address using WriteDMAFloat?
Didn't know the proper forum to post this, so this seemed the most acceptable.
In Visual Studio, I can't figure out why my script isn't working properly. All the offsets are correct, and I'm using ReadWriteMemory of course, but for whatever reason, the Float fails to write.
Code:
Private Sub Button25_Click(sender As Object, e As EventArgs) Handles Button25.Click
Dim sus1 As String = TextBox7.Text
Dim sus1a As Single
Try
sus1a = Convert.ToSingle(sus1)
WriteDMAFloat("Next Car Game", Base + &H3CC1C4, Offsets:={&H0, &H6A8, &H10, &H4, &H584}, Value:=sus1a, Level:=5, nsize:=4)
My.Computer.Audio.PlaySystemSound(System.Media.SystemSounds.Asterisk)
Catch
End Try
End Sub
This is my first time working with Floats, and I've tried nearly everything to try and just convert the string to a decimal, etc. Nothing is working.
EDIT: updated code
Last edited by Aerotactics; Sep 16th, 2014 at 09:37 PM.
-
Sep 13th, 2014, 07:30 AM
#2
Re: Visual Studio: How to write a float to an address using WriteDMAFloat?
Welcome to VBForums
Thread moved from the 'General Developer' forum to the 'VB.Net' (VB2002 and later) forum
-
Sep 13th, 2014, 07:48 AM
#3
Thread Starter
New Member
Re: Visual Studio: How to write a float to an address using WriteDMAFloat?
Originally Posted by si_the_geek
Welcome to VBForums
Thread moved from the 'General Developer' forum to the 'VB.Net' (VB2002 and later) forum
Thanks for the welcome, and thanks for the thread move.
-
Sep 15th, 2014, 01:52 PM
#4
Thread Starter
New Member
Re: Visual Studio: How to write a float to an address using WriteDMAFloat?
-
Sep 15th, 2014, 04:33 PM
#5
Re: Visual Studio: How to write a float to an address using WriteDMAFloat?
Are the values usually strings?
It looks like all the parameters except the first are numbers.
Perhaps sus1, sus2,... should be a number also, i.e a float value (aka. Single) instead of string.
-
Sep 16th, 2014, 01:00 AM
#6
Thread Starter
New Member
Re: Visual Studio: How to write a float to an address using WriteDMAFloat?
Originally Posted by passel
Are the values usually strings?
It looks like all the parameters except the first are numbers.
Perhaps sus1, sus2,... should be a number also, i.e a float value (aka. Single) instead of string.
I've tried converting the strings to single, integer, you name it. I was originally taught that you could just input the string, and it would read the input directly. Nothing I tried worked.
-
Sep 16th, 2014, 09:38 PM
#7
Thread Starter
New Member
Re: Visual Studio: How to write a float to an address using WriteDMAFloat?
-
Sep 16th, 2014, 10:16 PM
#8
Re: Visual Studio: How to write a float to an address using WriteDMAFloat?
It may help if you told us what this WriteDMAFloat function is. The only reference I found to it was in another forum's posting where it is a user defined function that calls various kernel32 functions and the code shown there looks like VB6 code using integers instead of Intptr and what not.
-
Sep 17th, 2014, 06:31 AM
#9
Re: Visual Studio: How to write a float to an address using WriteDMAFloat?
I had found the same code as TnTinMN and am sure it's what you are trying to use. It's badly written .NET code.
I think that what's going to give you grief from the outset is that the WriteDMAFloat method calls the ReadFloat method to fetch the next "pointer" address. Addresses are usually stored in memory as either 32bit or 64bit integers. The ReadFloat method reads 32 bits from memory and treats them as a Float/Single at the bit level, not as an integer. That means the addresses being used in your "pointer" chain will be way off.
Probably the easiest thing to try as a first attempt to get this working would be to find the WriteDMAFloat method in the ReadWritingMemory Module and change the call to ReadFloat into a call to ReadInteger as highlighted in red below:
Code:
Public Function WriteDMAFloat(ByVal Process As String, ByVal Address As Integer, ByVal Offsets As Integer(), ByVal Value As Single, ByVal Level As Integer, Optional ByVal nsize As Integer = 4) As Boolean
Try
Dim lvl As Integer = Address
For i As Integer = 1 To Level
lvl = ReadInteger(Process, lvl, nsize) + Offsets(i - 1)
Next
WriteFloat(Process, lvl, Value, nsize)
Return True
Catch ex As Exception
Return False
End Try
End Function
There are lots of other things that could trip you up here, especially if the process you are targeting is a 64 bit process that is large address aware.
If it were me, I'd make the change as outlined above, make sure to compile my VB app to x86 (if running on a 64bit OS), and keep my fingers crossed. If that didn't work, I'd try to rewrite the code using the proper Types .
-
Sep 17th, 2014, 12:55 PM
#10
Thread Starter
New Member
Re: Visual Studio: How to write a float to an address using WriteDMAFloat?
Thanks Inferrd, I'll be sure to add the additional code parts as well in future posts, as pointed out by TnTinMN, and I also plan on learning VB from scratch some day.
EDIT: that f***ing worked! Much thanks!
Last edited by Aerotactics; Sep 17th, 2014 at 01:01 PM.
-
Sep 18th, 2015, 12:54 PM
#11
New Member
Re: Visual Studio: How to write a float to an address using WriteDMAFloat?
Originally Posted by Aerotactics
Didn't know the proper forum to post this, so this seemed the most acceptable.
In Visual Studio, I can't figure out why my script isn't working properly. All the offsets are correct, and I'm using ReadWriteMemory of course, but for whatever reason, the Float fails to write.
Code:
Private Sub Button25_Click(sender As Object, e As EventArgs) Handles Button25.Click
Dim sus1 As String = TextBox7.Text
Dim sus1a As Single
Try
sus1a = Convert.ToSingle(sus1)
WriteDMAFloat("Next Car Game", Base + &H3CC1C4, Offsets:={&H0, &H6A8, &H10, &H4, &H584}, Value:=sus1a, Level:=5, nsize:=4)
My.Computer.Audio.PlaySystemSound(System.Media.SystemSounds.Asterisk)
Catch
End Try
End Sub
This is my first time working with Floats, and I've tried nearly everything to try and just convert the string to a decimal, etc. Nothing is working.
EDIT: updated code
Sorry to bump this but I just wanted to thank you for your post!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|