dcsimg
Results 1 to 9 of 9

Thread: Help in creating a DLL file to close some processes

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    245

    Help in creating a DLL file to close some processes

    Hello everyone!
    I am currently trying to create a basic AntiCheat for a game I made.
    Now, I would want a .dll coded in VB to basically check every 7 seconds to see if any malicious hacking processes are open, and if so. To close the process.

    What I have so far:
    Code:
    Public Class Class1
    
        For Each p As Process In Process.GetProcesses
        ListBox1.Items.Add(p.ProcessName.ToString)
        If p.ProcessName = "test" Then
            p.Kill()
        End If
    Next
    
    End Class
    I've never coded a .dll file before and I'm confused becuase this code would work if it was in a form.
    So can someone please help me out?:/
    Thank you in advanced.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,892

    Re: Help in creating a DLL file to close some processes

    Just get rid of the ListBox part. The rest of it will work just fine. Code in a library project is no different to code in an application project. The only difference is that you can't run a DLL directly but must reference it from an EXE.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    245

    Re: Help in creating a DLL file to close some processes

    Quote Originally Posted by jmcilhinney View Post
    Just get rid of the ListBox part. The rest of it will work just fine. Code in a library project is no different to code in an application project. The only difference is that you can't run a DLL directly but must reference it from an EXE.
    Alright so I got this so far

    Public Class fmod_handle

    Private Sub startUp()
    For Each p As Process In Process.GetProcesses
    If p.ProcessName.Contains("cheatengine") Then
    'p.Kill()
    Process.GetCurrentProcess.Kill()
    End If
    Next
    End Sub

    End Class

    And in my C++ game, I would like to call my .dll file by doing:
    if (LoadLibrary("fmod_handle.dll") == NULL) {
    MessageBoxA(0, "AntiCheat failed to load!", "AntiCheat", MB_ICONERROR);
    TerminateProcess(GetCurrentProcess(), 0);
    }
    but how does that calling know to run the startUp() sub inside it? (confused about this part of it)

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,242

    Re: Help in creating a DLL file to close some processes

    And in my C++ game
    Whoa there, cowboy! You want to load a VB library into a C++ program? Good luck with that! Why aren't you writing a C++ library (or simply including the routine in the game in the first place)?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    245

    Re: Help in creating a DLL file to close some processes

    Quote Originally Posted by dunfiddlin View Post
    Whoa there, cowboy! You want to load a VB library into a C++ program? Good luck with that! Why aren't you writing a C++ library (or simply including the routine in the game in the first place)?
    Well I have never made or tried to make a dll before :/
    Isn't DLLs universal?
    I thought I can say somewhere in my DLL that it will extend C++ or something around there?
    I am not sure exactly, but is this not possible or something? Would I need to create the dll in c++?

  6. #6
    Super Moderator Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Help in creating a DLL file to close some processes

    No DLLs are not universal, there are many different types of DLL files. You've got traditional DLLs which are basically just function libraries, you have COM components which are objects but needs to be registered before they are used, and you have .Net assembly DLLs which are also objects (or rather classes, which is basically also true for COM components but in COM they are called objects) which can be used from any .Net compatible language.
    Joacim Andersson
    If anyone's answer has helped you, please show your appreciation by rating that answer.
    I'd rather run ScriptBrix...
    Joacim's view on stuff.

    MVP

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    245

    Re: Help in creating a DLL file to close some processes

    Quote Originally Posted by Joacim Andersson View Post
    No DLLs are not universal, there are many different types of DLL files. You've got traditional DLLs which are basically just function libraries, you have COM components which are objects but needs to be registered before they are used, and you have .Net assembly DLLs which are also objects (or rather classes, which is basically also true for COM components but in COM they are called objects) which can be used from any .Net compatible language.
    Alright so how could I setup or say in my DLL to be executed in a C++ game on startup on the c++ game?
    I can call my DLL like this to hook it:
    Code:
    if (LoadLibrary("fmod_handle.dll") == NULL) {
    MessageBoxA(0, "AntiCheat failed to load!", "AntiCheat", MB_ICONERROR);
    TerminateProcess(GetCurrentProcess(), 0);
    }
    But how would it know to run a specific sub in my DLL?

  8. #8
    Super Moderator Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Help in creating a DLL file to close some processes

    No, you can't use LoadLibrary to load a .Net assembly. You need to create a classic DLL, with either cdecl or stdcall as the calling convention, for that to work. However you can't create a classic DLL using VB, you need to use C/C++ or Delphi for that.
    Joacim Andersson
    If anyone's answer has helped you, please show your appreciation by rating that answer.
    I'd rather run ScriptBrix...
    Joacim's view on stuff.

    MVP

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    245

    Re: Help in creating a DLL file to close some processes

    Quote Originally Posted by Joacim Andersson View Post
    No, you can't use LoadLibrary to load a .Net assembly. You need to create a classic DLL, with either cdecl or stdcall as the calling convention, for that to work. However you can't create a classic DLL using VB, you need to use C/C++ or Delphi for that.
    Alright damn:/ Gotta learn some more c++ then :c

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width