Results 1 to 11 of 11

Thread: Visual Studio: How to write a float to an address using WriteDMAFloat?

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2014
    Posts
    6

    Question 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.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2014
    Posts
    6

    Re: Visual Studio: How to write a float to an address using WriteDMAFloat?

    Quote Originally Posted by si_the_geek View Post
    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.

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2014
    Posts
    6

    Re: Visual Studio: How to write a float to an address using WriteDMAFloat?

    Bump

  5. #5
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    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.

  6. #6

    Thread Starter
    New Member
    Join Date
    Sep 2014
    Posts
    6

    Re: Visual Studio: How to write a float to an address using WriteDMAFloat?

    Quote Originally Posted by passel View Post
    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.

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2014
    Posts
    6

    Re: Visual Studio: How to write a float to an address using WriteDMAFloat?

    Bump

  8. #8
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    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.

  9. #9
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    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 .

  10. #10

    Thread Starter
    New Member
    Join Date
    Sep 2014
    Posts
    6

    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.

  11. #11
    New Member
    Join Date
    Sep 2015
    Posts
    1

    Re: Visual Studio: How to write a float to an address using WriteDMAFloat?

    Quote Originally Posted by Aerotactics View Post
    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
  •  



Click Here to Expand Forum to Full Width