[VB]Draw time over bf3

Discussion in 'Mixed Languages' started by stevemk14ebr, Apr 30, 2012.

  1. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #1 stevemk14ebr, Apr 30, 2012
    Last edited by a moderator: Apr 20, 2017
    simple problem all i need to do is create a function to draw the system time over battlefield 3. i have this so far that will draw over firefox, but bf3 seems to just ignore this and it doesnt show up when ingame

    Code:
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim time As String = Now.ToShortTimeString
            Call DrawOverlay(time)
        End Sub
    Code:
    Private Shared Sub DrawOverlay(ByVal OverlayString As String)
            Dim Processes = Process.GetProcessesByName("firefox")
            Dim deviceContext As Graphics = Graphics.FromHwnd(Processes(0).MainWindowHandle)
            Dim drawFont As New Font("Arial", 14, FontStyle.Bold)
            Dim myBrush As New Drawing2D.LinearGradientBrush(deviceContext.ClipBounds, Color.Black, Color.SkyBlue, Drawing2D.LinearGradientMode.Horizontal)
            Dim drawFormat As New StringFormat()
            drawFormat.FormatFlags = StringFormatFlags.NoFontFallback
    
            deviceContext.DrawString(OverlayString, drawFont, myBrush, 100, 100, drawFormat)
        End Sub
    
    Code:
    Public Function IsProcessRunning(ByVal name As String) As Boolean
            'here we're going to get a list of all running processes on      'the computer
            For Each clsProcess As Process In Process.GetProcesses()
                If clsProcess.ProcessName.StartsWith(name) Then
                    'process found so it's running so return true
                    Return True
                End If
            Next
            'process not found, return false
            Return False
        End Function
    Code:
     Private Sub update_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles update.Tick
            If IsProcessRunning("firefox") = True Then
                Dim time As String = Now.ToShortTimeString
                Call DrawOverlay(time)
            End If
    
        End Sub
    End Class
    all of this is not my code it is the result of lots of googling and a few edits
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. QuantumBug

    QuantumBug MDL Developer

    Mar 7, 2012
    1,474
    1,293
    60
    Hmm, some Games with newer protection platforms have a tendancy to kick out unsigned code.

    Have you looked into this? And does it run on Games for Windows Live?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #3 stevemk14ebr, Apr 30, 2012
    Last edited: Apr 30, 2012
    (OP)
    i have not looked into the signed code any idea on implementation (i will look into), i do not run games for windows live so i would not know

    EDIT: alright just looked into this code signing thing and well, i don't get it, what would i have to do to call it "signed"
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
  5. QuantumBug

    QuantumBug MDL Developer

    Mar 7, 2012
    1,474
    1,293
    60
    Are you implimenting the code by placing it into the game, or drawing it in your code and forcing it on top of all active windows?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    my plan is to just draw over but if i could pace it into the game that would be ideal, but i have never done any type of injection
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. QuantumBug

    QuantumBug MDL Developer

    Mar 7, 2012
    1,474
    1,293
    60
    I think DLL injection would be the better option, but is always harder to do. It's not ususally to do with the game forcing it out but it's backend protection forcing out the unsigned code. I will look into this for you and get back to you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. QuantumBug

    QuantumBug MDL Developer

    Mar 7, 2012
    1,474
    1,293
    60
    #8 QuantumBug, May 1, 2012
    Last edited: May 1, 2012
    Wait, did you enable update.Tick(the timer) throught it's settings?

    I've just got it working in limbo, it was flickering badly but setting the Timer increment to 10 helped. Do you want me to send you the modified code?

    bftime.jpg < See here

    Also I renamed the timer(update) to (updatetimer) as it was conflicting with a Sub in the form.designer.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #9 stevemk14ebr, May 1, 2012
    Last edited: May 1, 2012
    (OP)
    yes the code would be helpfull, yes it flickers because of the method used since im not injecting the code the game refresh and code refresh is different. im wonder why this overlay doesnt work in bf3 though

    EDIT: ALRIGHT so this does infact work with bf3 BUT it only displays while not in fullscreen mode, so why then doesn't it work in fullscreen-have to play in fullscreen
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. QuantumBug

    QuantumBug MDL Developer

    Mar 7, 2012
    1,474
    1,293
    60
    #10 QuantumBug, May 1, 2012
    Last edited: May 1, 2012
    I'm downloading the Game to help you, I'll delete it afterwards. I'll .zip the code quickly and send it, all you have to do is change the Process name from limbo back to battlefield.

    I've added some new bits and commented what they are, one to detect if the corrent process is being loaded for you. If you get confused please feel free to quote the code and ask me for help. I'll PM you the new project link.

    EDIT: I had limbo in Windowed mode, I'll put it into FS and get back to you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    ok, the main problem i have is that stupid fs mode not working. im thinking maybe that process get like a sole use of the screen or sumthing
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. QuantumBug

    QuantumBug MDL Developer

    Mar 7, 2012
    1,474
    1,293
    60
    Right I've looked into it and I think DirectX isn't accepting it, so... We'll have to call gpcomms.dll and use your app, just replace the code in the timer to match gpcomms DirectX drawing.

    I'll write it up as soon as I can and send it to you, in the meantime continue playing with your version of the app.

    Do you dev with C#.NET or just VB.NET?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #13 stevemk14ebr, May 2, 2012
    Last edited: May 3, 2012
    (OP)
    im only practiced in vb.net but i can use tools to convert c# to vb. working code in any language would be amazing

    EDIT: take a look at this it's in vb and does overlays- im not able to analyze the source now though as it is late here http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4015&lngWId=10
    lol i just was able to review it- turns out it makes calls to gpcomms.dll

    EDIT2: alright so ive been searching up and it seem that punkbuster (the anticheat used for bf3) doesn't like the use of external dlls so im thinking now we'll have to use a directdraw or d3d function/solution now...ah more stuff i have no experience in :(
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  14. Zeus123456789

    Zeus123456789 MDL Novice

    May 2, 2012
    1
    0
    0
    hi, iam new here.

    I'm looking for the same thing (but for CS1.6), and more than a few months I could not find. Therefore, I would wait dave for publish your code.

    And if that matter, i write in vb.net too.

    Thank you.
     
  15. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    5,864
    20,049
    180
    #15 Alphawaves, May 3, 2012
    Last edited: May 3, 2012
    I think i can help you out here, ill download and install it to give you a working fix..:D;)
    Can you pm me a link to it ?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    link to wat, game or my program... and if u can fix i will love u forever :D
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    5,864
    20,049
    180
    :laie: game bro :D
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    sure lol- is a torrent ok
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  19. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    5,864
    20,049
    180
  20. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    i pmed u with a new link that probably wont be blocked
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...