تقييم الموضوع :
  • 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] تصحيح مشكلة في المشروع dubai.eig 2 44 17-10-17, 12:41 PM
آخر رد: dubai.eig
  [VB.NET] اريد تعديل ع هذا الكود الرجاء مساعدتـي e-coder 0 37 13-10-17, 06:39 PM
آخر رد: e-coder
Thumbs Up كيفية تشغيل وإغلاق الادوات الذكية لويندوز 7 عن طريق الكود رمضان محمد 6 901 11-10-17, 08:48 PM
آخر رد: رمضان محمد
  [VB.NET] مطلوب التعديل علي الكود التالي محمد اسماعيل 2 63 11-10-17, 01:08 PM
آخر رد: محمد اسماعيل
  [VB.NET] التعديل على الكود - رقم التسلسلي dubai.eig 4 132 08-10-17, 11:30 PM
آخر رد: dubai.eig
  استشارة في الكود hikmat 1 57 28-09-17, 01:33 AM
آخر رد: wale90
  مساعدة في الكود hikmat 0 42 27-09-17, 10:08 AM
آخر رد: hikmat
  كيف اجعل البرنامج ينفذ الكود الى فى الtextbox aliomar333 1 109 23-09-17, 05:32 PM
آخر رد: محمود صالح
  [VB.NET] ممكن تعديل الكود التالي D-Z 0 65 21-09-17, 06:34 PM
آخر رد: D-Z
  احتاج الكود المناسب لاغلاق فورم وفتح فورم آخر Abdelazez.Ahmad 4 111 20-09-17, 04:00 PM
آخر رد: alsouf

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


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