View unanswered posts | View active topics It is currently May 25th, '13, 13:47




Reply to topic  [ 1 post ] 
 anti-hack code 
Author Message

Joined: Sep 5th, '10, 11:00
Posts: 5
Post anti-hack code
Ok so I have some anti-hack code but I cannot seem to get it to work.

Error 1 Value of type '1-dimensional array of Byte' cannot be converted to 'System.IntPtr'.

Code:
Imports System.Runtime.InteropServices
Module Antihack
    Dim MAX_DUMPS As Integer = 2
    Dim MAX_DUMP_SIZE As Integer = 32
    Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, <MarshalAs(UnmanagedType.AsAny)> ByVal lpBaseAddress As Object, <MarshalAs(UnmanagedType.AsAny)> ByRef lpBuffer As Object, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
    Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal pDst As IntPtr, ByVal pSrc As String, ByVal ByteLen As Long)

    ' Dim Offsets(MAX_DUMPS) As Integer = {"0x4C8259"}

    Public Sub SystemProcessScan()
        Dim psList() As Process
        Try
            psList = Process.GetProcesses()

            For Each p As Process In psList
                If (Scan(p.Id) > 0) Then
                    MsgBox("Found hack software in your system.\n\nHint: Close all illegal programs and run application again.", "Software guard")
                    CloseProc("MU")
                End If

            Next p

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Public Function Scan(ByVal hProcess As Int32)
        Dim Buf(MAX_DUMP_SIZE) As Byte
        Dim BytesRead As Int32 = 0
        Dim B = Convert.ToByte(Buf)
        For Int As Integer = 0 To MAX_DUMPS
            ReadProcessMemory(hProcess, "Offset", Buf, System.Runtime.InteropServices.Marshal.SizeOf(Buf), BytesRead)
            If CopyMemory(Buf, "32byte DUMP", MAX_DUMP_SIZE) = 0 Then
                Return 1
            End If
        Next
        Return 0
    End Function

    Function CloseProc(ByVal sProcName As String) As String
        Dim Proc() As Process = Process.GetProcessesByName(sProcName)
        Try
            Proc(0).Kill()
            Return "Process killed"
        Catch
            Return "Can't find process"
        End Try
    End Function
End Module


if you can see " If CopyMemory(Buf, "32byte DUMP", MAX_DUMP_SIZE) = 0 Then"

The int32 field used where buf is; is invalid. please help xD i cant find a solution


Sep 24th, '10, 09:19
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Based on design by STSoftware, modded by Sirmabus Copyright© 2009-2011