[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
    #21 stevemk14ebr, May 7, 2012
    Last edited: May 9, 2012
    (OP)
    any ideas this is by far unsolved
    EDIT: still, really i need help here
     
  2. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,222
    22,280
    210
  3. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    yes i actually stumbled upon the same site, there are however 2 reasons this wont work for me
    1) i can't figure out how to get a working solution, as i have zero experience with dlls or anytype of dx/directdraw
    2) if i could manage to get it working it wouldn't matter because bf3 would call that dll a hack as it is similar to how hacks draw to the screen as well
     
  4. master131

    master131 MDL Novice

    Apr 12, 2011
    45
    22
    0
    #24 master131, May 18, 2012
    Last edited by a moderator: Apr 20, 2017
    Flickering is from the fact that you're drawing on the window's handle and DirectX renders faster than what you're drawing, causing the flicker. Your possible options are to create a form with a transparent background and draw on the form, simulating an overlay. Note that it won't display in fullscreen. You can achieve this by using APIs like FindWindow to get the window's handle (or just use the Process class) and using GetWindowRect/GetClientRect to find the window's size and position (this is to make sure your overlay is always covering over the game's window). Here's some sample code for a simple overlay:
    Code:
    Me.TransparencyKey = Me.BackColor
    Me.FormBorderStyle = FormBorderStyle.None
    
    'In a timer with a interval of your choice
    Me.TopMost = True
    You can also get an overlay working using the 'DwmExtendframeIntoClientArea' function in dwmapi.dll, assuming that Aero is enabled (you can check by using DwmIsCompositionEnabled) and that you're running an OS >= Vista.

    Another alternative would be hook DirectX with the help of EasyHook, spazzarama has written a great example (Google it, you'll find it on his blog & on Github) on achieving that in C# (which can be converted to VB.NET). The good thing is that this method does work in fullscreen, the only drawback is that this method can cause problems with Anti-Cheats as they might not like DLLs hooking stuff like EndScene and whatnot. Also, this method would require some serious knowledge of coding, specifically with DirectX wrappers (and DirectX in general) like SlimDX or SharpDX. I'm not sure that you should venture here if you don't know what you're doing. :p

    Lastly, you can use a DirectDraw overlay as another method to achieve this. I remember fiddling with this a while ago but wasn't able to achieve the result I wanted so yeah.

    I'm sure there are other options out there, I'm just highlighting a few.

    ~ master131
     
  5. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    thank you very much for your post i'm taking a look at the dwmextendframeintoclient as anything with dll hooking is a no go for anticheat, and i fail at directdraw
     
  6. master131

    master131 MDL Novice

    Apr 12, 2011
    45
    22
    0
    #26 master131, May 19, 2012
    Last edited: May 19, 2012
    I've created an example for you (it's been a while since I've coded in VB.NET), I'd give you a screenshot but I don't enough posts to do that yet. :p I've attached the example project below, enjoy. If you have any questions, let me know.

    Just build and run the project. Launch Notepad and the overlay will appear. Try resizing and moving the window, the overlay will adjust accordingly (might be slow, this can be fixed by reducing the timer's interval). Also, I should note that you shouldn't use any non-solid colors, that is any color that does not have an alpha of 255, it won't turn out how you'd expect it to. :D You can fix this though by adding: g.Clear(Color.FromArgb(0, 0, 0, 0)). However, this adds a terrible flicker, I'm working on that now.

    Oh and if anybody uses this code in any of their projects, credits would be nice.
     

    Attached Files:

  7. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #27 stevemk14ebr, May 19, 2012
    Last edited: May 19, 2012
    (OP)
    thank you so much, this is much more than i could of ever asked for.But how is the window name fetched, i see that notepad shows "untitled - notepad" and when i say change that line to [VB]Draw time over bf3 - Page 3 the same effect of an overlay over firefox on this page and effect isn't achieved. how is the window actually found and could it instead be process based instead of window name, i would disect it myself but i don't completely understand your code. :worthy::confused:
     
  8. master131

    master131 MDL Novice

    Apr 12, 2011
    45
    22
    0
    #28 master131, May 19, 2012
    Last edited by a moderator: Apr 20, 2017
    The example uses FindWindow to obtain the window handle by using the window's title. I created an overload for your convenience which accepts a window handle (IntPtr) directly.

    Replace this line:
    Code:
    If Not OverlayWindow("Untitled - Notepad", True) Then
    with this instead:
    Code:
    Dim p() As Process = Process.GetProcessesByName("firefox")
    If p.Length = 0 OrElse Not OverlayWindow(p(0).MainWindowHandle, True) Then
    Also, you can remove this line from Main_Load, I left it there by accident. :p
    Code:
    Location = New Point(500, 100)
     
  9. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #29 stevemk14ebr, May 19, 2012
    Last edited by a moderator: Apr 20, 2017
    (OP)
    a few error show when i replace that line such as process is a type and can't be used as an expression
    p is not declared it may be inaccessible due to its protection level
    do u have a declare statement or import that u didn't show ?

    Edit: alright it was a quick fix
    Code:
     Dim Processes = Process.GetProcessesByName("firefox")
            If Processes.Length = 0 OrElse Not OverlayWindow(Processes(0).MainWindowHandle, True) Then
    I have ran this in bf and it works beautifully windowed but not in fullscreen, i believe u already said that, is there a way to run a program 99% maximized and remove the border that way it would appear fullscreen and not have a border but still be technically windowed therefore allowing overlay? or even some sort of way to force it to work in fullscreen, because that is were it will be used 99% of the time

    Edit2: think i found a good way of pretending to run in fullscreen
     
  10. master131

    master131 MDL Novice

    Apr 12, 2011
    45
    22
    0
    #30 master131, May 20, 2012
    Last edited: May 20, 2012
    Woops, I wasn't at home and accidently wrote the code like I was coding in C#. :biggrin: I've fixed it now. You can try removing the border if you want, the taskbar will still be there though. Like I said previously, there's no way (that I know of) to make it work in fullscreen.
     
  11. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,515
    7,170
    120
    DirectX overlay is possible when the game allow this...

    The most of online games have an security to prevent it (Anti-Hack engine).

    The non-fullscreen overlay is possible because you can replace any form into the window with a always on top config.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    yea bf3 has anti-hack so probably a no go on the dx, there seems to be no way to do this. without being banned for a hack (which it isnt)
     
  13. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,515
    7,170
    120
    You have the "Dll Injection" method. But always an good anti-hack engine detects the abnormal memory access.

    The cool method is disable this anti-hack in the memory, but isn't legal..
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  14. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    if you want to venture down that avenue feel free to pm me, i probably wouldn't be of any help but hey legality is just a theory in the end
     
  15. master131

    master131 MDL Novice

    Apr 12, 2011
    45
    22
    0
    #35 master131, Jul 3, 2012
    Last edited: Jul 4, 2012
    I know this thread is quite old now but I thought I'd revisit it since I'm currently out of the country and bored. I've fixed the problem where transparency is not possible when painting. Enjoy guys.
     

    Attached Files:

  16. master131

    master131 MDL Novice

    Apr 12, 2011
    45
    22
    0
    Sorry for the double post but I fixed the revised version again, added the code to reduce CPU usage and fixed the bug where the overlay wouldn't clear when the target window had closed.

    Remember that you can make it render faster by changing the TimerRender's Interval to a lower value and that you can change what is drawn onto the window at the bottom of the Paint event Sub that's already there.

    If you want to overlay over a specific process rather than the target window's name, refer to the third page (post #28).
     
  17. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    nice work im sure alot of people look for little apps like this you should post in the softwares section for fun