تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
تصحيح هذا الكود
#1
كود :
<DllImport("kernel32", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)> _
    Private Shared Function ReadProcessMemory(ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
    End Function

    <DllImport("kernel32", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)> _
    Private Shared Function OpenProcess(ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
    End Function

    Private Function Hwnd() As Object
        Throw New NotImplementedException
    End Function
    <DllImport("kernel32", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)> _
    Private Shared Function CloseHandle(ByVal hObject As Integer) As Integer
    End Function

    <DllImport("kernel32", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)> _
    Private Shared Function WriteProcessMemory(ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
    End Function

    Public Function Tibia_Hwnd() As Long
        Dim processesByName As Process() = Process.GetProcessesByName("")
        If (processesByName.Length = 0) Then
            Return 0
        End If
        Return processesByName(0).Id
    End Function
    Private Function Memory_WriteLong(ByVal Address As Integer, ByVal vBuffer As Long) As Long
        Dim num As Long
        Dim ptr As IntPtr = DirectCast(Form1.OpenProcess(&H438, 0, CInt(Me.Tibia_Hwnd)), IntPtr)
        Dim lpBuffer As Integer = CInt(vBuffer)
        Dim lpNumberOfBytesWritten As Integer = 0
        Form1.WriteProcessMemory(CInt(ptr), Address, lpBuffer, 4, lpNumberOfBytesWritten)
        vBuffer = lpBuffer
        Return vBuffer
        Form1.CloseHandle(CInt(ptr))
        Return num
    End Function

    Private Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
        If Me.CheckBox1.Checked Then
            Me.Memory_WriteLong(&H478802, Conversions.ToLong("-1946401317"))
        Else
            Me.Memory_WriteLong(&H478802, Conversions.ToLong("-1946401319"))
        End If
    End Sub
الرد }}}}
تم الشكر بواسطة:
#2
عدلت على الكود حيث لا يوجد أخطاء في الـError List أما عن آلية عمل الكود فلم أختبرها، تركتها لك.
كود :
Imports System.Runtime.InteropServices

Public Class Form1
    Private Function Hwnd() As Object
        Throw New NotImplementedException
    End Function
    <DllImport("kernel32", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)> _
    Private Shared Function CloseHandle(ByVal hObject As Integer) As Integer
    End Function

    <DllImport("kernel32", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)> _
    Private Shared Function WriteProcessMemory(ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
    End Function

    <DllImport("kernel32.dll")> _
    Private Shared Function OpenProcess(ByVal dwDesiredAccess As ProcessAccessFlags, <MarshalAs(UnmanagedType.Bool)> ByVal bInheritHandle As Boolean, ByVal dwProcessId As Integer) As IntPtr
    End Function

    Public Function Tibia_Hwnd() As Long
        Dim processesByName As Process() = Process.GetProcessesByName("")
        If (processesByName.Length = 0) Then
            Return 0
        End If
        Return processesByName(0).Id
    End Function
    Private Function Memory_WriteLong(ByVal Address As Integer, ByVal vBuffer As Long) As Long
        Dim ptr As IntPtr = DirectCast(Form1.OpenProcess(&H438, 0, CInt(Me.Tibia_Hwnd)), IntPtr)
        Dim lpBuffer As Integer = CInt(vBuffer)
        Dim lpNumberOfBytesWritten As Integer = 0
        Form1.WriteProcessMemory(CInt(ptr), Address, lpBuffer, 4, lpNumberOfBytesWritten)
        vBuffer = lpBuffer
        Return vBuffer
        Form1.CloseHandle(CInt(ptr))
        Return Nothing
    End Function

    Private Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
        If Me.CheckBox1.Checked Then
            Me.Memory_WriteLong(&H478802, CLng("-1946401317"))
        Else
            Me.Memory_WriteLong(&H478802, CLng("-1946401319"))
        End If
    End Sub

    <Flags()> _
    Enum ProcessAccessFlags As UInteger
        All = &H1F0FFF
        Terminate = &H1
        CreateThread = &H2
        VMOperation = &H8
        VMRead = &H10
        VMWrite = &H20
        DupHandle = &H40
        SetInformation = &H200
        QueryInformation = &H400
        Synchronize = &H100000
    End Enum
End Class
الرد }}}}
تم الشكر بواسطة:
#3
Aly El-Haddad كتب :عدلت على الكود حيث لا يوجد أخطاء في الـError List أما عن آلية عمل الكود فلم أختبرها، تركتها لك.
كود :
Imports System.Runtime.InteropServices

Public Class Form1
    Private Function Hwnd() As Object
        Throw New NotImplementedException
    End Function
    <DllImport("kernel32", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)> _
    Private Shared Function CloseHandle(ByVal hObject As Integer) As Integer
    End Function

    <DllImport("kernel32", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)> _
    Private Shared Function WriteProcessMemory(ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
    End Function

    <DllImport("kernel32.dll")> _
    Private Shared Function OpenProcess(ByVal dwDesiredAccess As ProcessAccessFlags, <MarshalAs(UnmanagedType.Bool)> ByVal bInheritHandle As Boolean, ByVal dwProcessId As Integer) As IntPtr
    End Function

    Public Function Tibia_Hwnd() As Long
        Dim processesByName As Process() = Process.GetProcessesByName("")
        If (processesByName.Length = 0) Then
            Return 0
        End If
        Return processesByName(0).Id
    End Function
    Private Function Memory_WriteLong(ByVal Address As Integer, ByVal vBuffer As Long) As Long
        Dim ptr As IntPtr = DirectCast(Form1.OpenProcess(&H438, 0, CInt(Me.Tibia_Hwnd)), IntPtr)
        Dim lpBuffer As Integer = CInt(vBuffer)
        Dim lpNumberOfBytesWritten As Integer = 0
        Form1.WriteProcessMemory(CInt(ptr), Address, lpBuffer, 4, lpNumberOfBytesWritten)
        vBuffer = lpBuffer
        Return vBuffer
        Form1.CloseHandle(CInt(ptr))
        Return Nothing
    End Function

    Private Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
        If Me.CheckBox1.Checked Then
            Me.Memory_WriteLong(&H478802, CLng("-1946401317"))
        Else
            Me.Memory_WriteLong(&H478802, CLng("-1946401319"))
        End If
    End Sub

    <Flags()> _
    Enum ProcessAccessFlags As UInteger
        All = &H1F0FFF
        Terminate = &H1
        CreateThread = &H2
        VMOperation = &H8
        VMRead = &H10
        VMWrite = &H20
        DupHandle = &H40
        SetInformation = &H200
        QueryInformation = &H400
        Synchronize = &H100000
    End Enum
End Class
جزاك الله الف خير اخى و جعله فى مزان حاسناتك
الرد }}}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  [VB.NET] مشكلة نقل الكود من Form2 الي Form1 3asfa~mdmra 2 77 17-02-17, 02:44 AM
آخر رد: الماجيك مسعد
  توليد الادوات في FlowLayoutPanel بواسطة الكود وحذفها (تم ارفاق المشروع) اليوم مبتدئة وغداً محترفة 16 351 13-02-17, 07:43 AM
آخر رد: اليوم مبتدئة وغداً محترفة
  ما الفرق بين اضافة قاعدة البيانات عن طريق الكود و اضافى قاعدة البيانات عن طريق add ne noway 1 56 12-02-17, 08:06 PM
آخر رد: مساعدة
  تصحيح الامتحان برمجيا القيصر بيلا 3 132 12-02-17, 02:48 PM
آخر رد: القيصر بيلا
  [VB.NET] تعديل بيسط على الكود ليصيح جاهزآ 3asfa~mdmra 0 71 27-01-17, 06:01 PM
آخر رد: 3asfa~mdmra
  [VB.NET] رجاء تصحيح الكود التالي dubai.eig 4 107 25-01-17, 03:02 PM
آخر رد: مساعدة
  [VB.NET] ممكن حل مشكلة الكود MOSTAFA.KAMEL 1 174 22-01-17, 09:37 PM
آخر رد: MOSTAFA.KAMEL
  [سؤال] ما هو الخطأ في الكود التالي .. أرجو المساعدة abo_alaa315 0 69 22-01-17, 02:27 PM
آخر رد: abo_alaa315
  [VB.NET] يرجى التعديل على الكود dubai.eig 4 115 18-01-17, 05:25 PM
آخر رد: dubai.eig
  اريد تحول الكود لفيجوال 2008 abudawoodd 6 238 15-01-17, 02:11 PM
آخر رد: abudawoodd

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم