تقييم الموضوع :
  • 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
جزاك الله الف خير اخى و جعله فى مزان حاسناتك
الرد }}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  ممكن حل المشكلة فى الكود التالي - من مشاركة استاذنا القدير / عبدالله الدوسري new_programer 4 169 02-03-24, 07:36 PM
آخر رد: new_programer
  ماهو حل هذا الخطأ في الكود melad2002 7 264 25-02-24, 12:25 AM
آخر رد: justforit
  كيفية انشاء سكريبت لقاعدة بيانات من خلال الكود heem1986 1 194 20-02-24, 12:00 AM
آخر رد: Kamil
  [VB.NET] أرغب فى استخدام هذا الكود بالتحديد على الإصدار 10 AmeenRashed 3 206 19-01-24, 12:42 PM
آخر رد: Taha Okla
  [VB.NET] ما الخطأ فى هذا الكود - كود البحث المتعدد Ashraf Elafify 7 464 27-12-23, 10:50 PM
آخر رد: Ashraf Elafify
  [VB.NET] مطلوب تصحيح سطر فى هذا الــ Function AhmedEissa 3 498 13-12-23, 12:55 AM
آخر رد: العتيق
  [VB.NET] اريد تعديل في الكود عند طباعة DGV abu_hisham7 1 431 03-12-23, 02:40 AM
آخر رد: abu_hisham7
  رجاء التعديل على الكود المرفق - كلاس لعرض كود المورد new_programer 4 357 13-10-23, 01:47 AM
آخر رد: new_programer
  كيفية التحكم فى حجم الفورم من خلال الكود Ahmed.vb 4 510 11-10-23, 07:17 PM
آخر رد: bidaya
  اريد ارسال pdf عبر واتساب عن طريق ال API محتاج تعديل على الكود moh61 0 518 03-08-23, 03:41 PM
آخر رد: moh61

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


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