Sixem

.NET SAMP Cheat API

Aug 3rd, 2013
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 19.63 KB | None | 0 0
  1. 'A .NET Wrapper created for San Andreas Multiplayer (Works in SP though).
  2. 'Written By Shaqways / Sixem
  3. 'Using Cless' @ CEF (Cheat Engine Forums) Memory Class
  4. 'Version 1.0.3
  5. Public Class SAMP
  6.     Public Class Cheats
  7.         Public Shared Sub Mega_Jump()
  8.             WriteByte("gta_sa", &H96916C, 1)
  9.         End Sub
  10.         Public Shared Sub All_Cars_Have_Nitro()
  11.             WriteByte("gta_sa", &H969165, 1)
  12.         End Sub
  13.     End Class
  14.     Public Class Vehicle
  15.         Public Shared Function Set_Stripe_Color(ByVal ColorID As Integer)
  16.             WritePointerByte("gta_sa", &HB6F980, ColorID, 1077)
  17.             Return ColorID
  18.         End Function
  19.         Public Shared Function Get_Stripe_Color()
  20.             Return ReadPointerByte("gta_sa", &HB6F980, 1077)
  21.         End Function
  22.         Public Shared Function Set_Body_Color(ByVal ColorID As Integer)
  23.             WritePointerByte("gta_sa", &HB6F980, ColorID, 1076)
  24.             Return ColorID
  25.         End Function
  26.         Public Shared Function Get_Body_Color(ByVal ColorID As Integer)
  27.             Return ReadPointerByte("gta_sa", &HB6F980, 1076)
  28.         End Function
  29.         Public Shared Function Passenger_Driver_Health()
  30.             Return ReadPointerFloat("gta_sa", &HB6F980, 1120, &H540)
  31.         End Function
  32.         Public Shared Function Passenger_1_Health()
  33.             Return ReadPointerFloat("gta_sa", &HB6F980, 1124, &H540)
  34.         End Function
  35.         Public Shared Function Passenger_2_Health()
  36.             Return ReadPointerFloat("gta_sa", &HB6F980, 1128, &H540)
  37.         End Function
  38.         Public Shared Function Passenger_3_Health()
  39.             Return ReadPointerFloat("gta_sa", &HB6F980, 1132, &H540)
  40.         End Function
  41.         Public Shared Function Teleport(ByVal X As Integer, ByVal Y As Integer, ByVal Z As Integer)
  42.             WritePointerInteger("gta_sa", &HB6F5F0, X, &H14, &H30)
  43.             WritePointerInteger("gta_sa", &HB6F5F0, Y, &H14, &H34)
  44.             WritePointerInteger("gta_sa", &HB6F5F0, Z, &H14, &H38)
  45.             WritePointerInteger("gta_sa", &HB6F980, X, 20, 48)
  46.             WritePointerInteger("gta_sa", &HB6F980, Y, 20, 52)
  47.             WritePointerInteger("gta_sa", &HB6F980, Z, 20, 56)
  48.             Return 0
  49.         End Function
  50.         Public Shared Sub Restore_Car_Health()
  51.             WritePointerInteger("gta_sa", &HB6F980, 1148846080, 1216)
  52.             Set_Car_Tires(0)
  53.         End Sub
  54.         Public Shared Function Get_Vehicle_Position_X()
  55.             Return ReadPointerInteger("gta_sa", &HB6F980, 20, 48)
  56.         End Function
  57.         Public Shared Function Get_Vehicle_Position_Y()
  58.             Return ReadPointerInteger("gta_sa", &HB6F980, 20, 52)
  59.         End Function
  60.         Public Shared Function Get_Vehicle_Position_Z()
  61.             Return ReadPointerInteger("gta_sa", &HB6F980, 20, 56)
  62.         End Function
  63.         Public Shared Function Set_Car_Tires(ByVal X As Integer)
  64.             WritePointerInteger("gta_sa", &HB6F980, X, &H5A5)
  65.             WritePointerInteger("gta_sa", &HB6F980, X, &H5A6)
  66.             WritePointerInteger("gta_sa", &HB6F980, X, &H5A7)
  67.             WritePointerInteger("gta_sa", &HB6F980, X, &H5A8)
  68.             Return 0
  69.         End Function
  70.         Public Shared Function Set_Car_Door_Lock(ByVal State As Integer)
  71.             If State = 1 Or State = 2 Then
  72.                 WritePointerInteger("gta_sa", &H969084, "2", &H4F8)
  73.             Else
  74.                 WritePointerInteger("gta_sa", &H969084, "1", &H4F8)
  75.             End If
  76.             Return 0
  77.         End Function
  78.         Public Shared Function Is_Player_Driving()
  79.             If ReadPointerByte("gta_sa", &HB6F5F0, &H534) = 0 Then
  80.                 Return 1
  81.             Else
  82.                 Return 0
  83.             End If
  84.         End Function
  85.     End Class
  86.     Public Class Player
  87.         Public Shared Infinite_Sprint_Status As Integer = CInt(0)
  88.         Public Shared Sub Toggle_Infinite_Sprint()
  89.             If Infinite_Sprint_Status = (0) Then
  90.                 WriteByte("gta_sa", &HB7CEE4, 1)
  91.                 Infinite_Sprint_Status = CInt(1)
  92.             Else
  93.                 WriteByte("gta_sa", &HB7CEE4, 0)
  94.                 Infinite_Sprint_Status = CInt(0)
  95.             End If
  96.         End Sub
  97.         Public Shared Function Get_Player_Health()
  98.             Return ReadPointerFloat("gta_sa", &HB6F5F0, &H540)
  99.         End Function
  100.         Public Shared Function Get_Player_Armor()
  101.             Return ReadPointerFloat("gta_sa", &HB6F5F0, &H548)
  102.         End Function
  103.         Public Shared Function Get_Current_Weapon()
  104.             Return ReadPointerInteger("gta_sa", &HB6F5F0, &H740)
  105.         End Function
  106.         Public Shared Function Teleport(ByVal X As Integer, ByVal Y As Integer, ByVal Z As Integer)
  107.             WritePointerInteger("gta_sa", &HB6F5F0, X, &H14, &H30)
  108.             WritePointerInteger("gta_sa", &HB6F5F0, Y, &H14, &H34)
  109.             WritePointerInteger("gta_sa", &HB6F5F0, Z, &H14, &H38)
  110.             WritePointerInteger("gta_sa", &HB6F980, X, 20, 48)
  111.             WritePointerInteger("gta_sa", &HB6F980, Y, 20, 52)
  112.             WritePointerInteger("gta_sa", &HB6F980, Z, 20, 56)
  113.             Return 0
  114.         End Function
  115.         Public Shared Sub Restore_Player_Health()
  116.             WritePointerInteger("gta_sa", &HB6F5F0, 1120403456, &H540)
  117.         End Sub
  118.         Public Shared Sub Restore_Player_Armor()
  119.             WritePointerInteger("gta_sa", &HB6F5F0, 1120403456, &H548)
  120.         End Sub
  121.         Public Shared Function Get_Player_Position_X()
  122.             Return ReadPointerInteger("gta_sa", &HB6F5F0, &H14, &H30)
  123.         End Function
  124.         Public Shared Function Get_Player_Position_Y()
  125.             Return ReadPointerInteger("gta_sa", &HB6F5F0, &H14, &H34)
  126.         End Function
  127.         Public Shared Function Get_Player_Position_Z()
  128.             Return ReadPointerInteger("gta_sa", &HB6F5F0, &H14, &H38)
  129.         End Function
  130.     End Class
  131.     Public Shared Function Get_Money()
  132.         Return ReadInteger("gta_sa", &HB7CE50)
  133.     End Function
  134.     Public Shared Function Set_Money(ByVal Money As Integer)
  135.         WriteInteger("gta_sa", &HB7CE50, Money)
  136.         Return Money
  137.     End Function
  138.     Public Shared Sub Force_Crash()
  139.         WritePointerFloat("gta_sa", &HB6F980, 9918521992, 0)
  140.     End Sub
  141.     Public Shared Function Set_Weather(ByVal WCode As Integer)
  142.         WriteInteger("gta_sa", &HC81320, WCode)
  143.         Return WCode
  144.     End Function
  145. #Region "Module Const"
  146.     Private Declare Function ReadMemoryByte Lib "kernel32" Alias "ReadProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Byte, Optional ByVal Size As Integer = 2, Optional ByRef Bytes As Integer = 0) As Byte
  147.     Private Declare Function ReadMemoryInteger Lib "kernel32" Alias "ReadProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Integer, Optional ByVal Size As Integer = 4, Optional ByRef Bytes As Integer = 0) As Integer
  148.     Private Declare Function ReadMemoryFloat Lib "kernel32" Alias "ReadProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Single, Optional ByVal Size As Integer = 4, Optional ByRef Bytes As Integer = 0) As Single
  149.     Private Declare Function ReadMemoryDouble Lib "kernel32" Alias "ReadProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Double, Optional ByVal Size As Integer = 8, Optional ByRef Bytes As Integer = 0) As Double
  150.     Private Declare Function ReadMemoryString Lib "kernel32" Alias "ReadProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As IntPtr, Optional ByVal Size As Integer = 8, Optional ByRef Bytes As Integer = 0) As IntPtr
  151.     Private Declare Function WriteMemoryByteArray Lib "kernel32" Alias "WriteProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Byte(), Optional ByVal Size As Integer = 2, Optional ByRef Bytes As Integer = 0) As Byte()
  152.     Private Declare Function WriteMemoryByte Lib "kernel32" Alias "WriteProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Byte, Optional ByVal Size As Integer = 2, Optional ByRef Bytes As Integer = 0) As Byte
  153.     Private Declare Function WriteMemoryInteger Lib "kernel32" Alias "WriteProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Integer, Optional ByVal Size As Integer = 4, Optional ByRef Bytes As Integer = 0) As Integer
  154.     Private Declare Function WriteMemoryFloat Lib "kernel32" Alias "WriteProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Single, Optional ByVal Size As Integer = 2, Optional ByRef Bytes As Integer = 0) As Single
  155.     Private Declare Function WriteMemoryDouble Lib "kernel32" Alias "WriteProcessMemory" (ByVal Handle As Integer, ByVal Address As Integer, ByRef Value As Double, Optional ByVal Size As Integer = 2, Optional ByRef Bytes As Integer = 0) As Double
  156.     Public Shared Function ReadText(ByVal EXENAME As String, ByVal Address As Integer) As IntPtr
  157.         Dim Value As String
  158.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  159.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  160.             If Handle <> 0 Then
  161.                 ReadMemoryString(Handle, Address, Value)
  162.             End If
  163.         End If
  164.         Return Value
  165.     End Function
  166.  
  167.     Public Shared Function ReadByte(ByVal EXENAME As String, ByVal Address As Integer) As Byte
  168.         Dim Value As Byte
  169.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  170.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  171.             If Handle <> 0 Then
  172.                 ReadMemoryByte(Handle, Address, Value)
  173.             End If
  174.         End If
  175.         Return Value
  176.     End Function
  177.  
  178.     Public Shared Function ReadInteger(ByVal EXENAME As String, ByVal Address As Integer) As Integer
  179.         Dim Value As Integer
  180.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  181.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  182.             If Handle <> 0 Then
  183.                 ReadMemoryInteger(Handle, Address, Value)
  184.             End If
  185.         End If
  186.         Return Value
  187.     End Function
  188.  
  189.     Public Shared Function ReadFloat(ByVal EXENAME As String, ByVal Address As Integer) As Single
  190.         Dim Value As Single
  191.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  192.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  193.             If Handle <> 0 Then
  194.                 ReadMemoryFloat(Handle, Address, Value)
  195.             End If
  196.         End If
  197.         Return Value
  198.     End Function
  199.  
  200.     Public Shared Function ReadDouble(ByVal EXENAME As String, ByVal Address As Integer) As Double
  201.         Dim Value As Double
  202.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  203.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  204.             If Handle <> 0 Then
  205.                 ReadMemoryByte(Handle, Address, Value)
  206.             End If
  207.         End If
  208.         Return Value
  209.     End Function
  210.  
  211.     Public Shared Function ReadPointerByte(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal ParamArray Offset As Integer()) As Byte
  212.         Dim Value As Byte
  213.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  214.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  215.             If Handle <> 0 Then
  216.                 For Each I As Integer In Offset
  217.                     ReadMemoryInteger(Handle, Pointer, Pointer)
  218.                     Pointer += I
  219.                 Next
  220.                 ReadMemoryByte(Handle, Pointer, Value)
  221.             End If
  222.         End If
  223.         Return Value
  224.     End Function
  225.  
  226.     Public Shared Function ReadPointerInteger(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal ParamArray Offset As Integer()) As Integer
  227.         Dim Value As Integer
  228.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  229.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  230.             If Handle <> 0 Then
  231.                 For Each I As Integer In Offset
  232.                     ReadMemoryInteger(Handle, Pointer, Pointer)
  233.                     Pointer += I
  234.                 Next
  235.                 ReadMemoryInteger(Handle, Pointer, Value)
  236.             End If
  237.         End If
  238.         Return Value
  239.     End Function
  240.  
  241.     Public Shared Function ReadPointerFloat(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal ParamArray Offset As Integer()) As Single
  242.         Dim Value As Single
  243.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  244.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  245.             If Handle <> 0 Then
  246.                 For Each I As Integer In Offset
  247.                     ReadMemoryInteger(Handle, Pointer, Pointer)
  248.                     Pointer += I
  249.                 Next
  250.                 ReadMemoryFloat(Handle, Pointer, Value)
  251.             End If
  252.         End If
  253.         Return Value
  254.     End Function
  255.  
  256.     Public Shared Function ReadPointerDouble(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal ParamArray Offset As Integer()) As Double
  257.         Dim Value As Double
  258.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  259.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  260.             If Handle <> 0 Then
  261.                 For Each I As Integer In Offset
  262.                     ReadMemoryInteger(Handle, Pointer, Pointer)
  263.                     Pointer += I
  264.                 Next
  265.                 ReadMemoryDouble(Handle, Pointer, Value)
  266.             End If
  267.         End If
  268.         Return Value
  269.     End Function
  270.  
  271.     Public Shared Sub WriteByte(ByVal EXENAME As String, ByVal Address As Integer, ByVal Value As Byte)
  272.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  273.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  274.             If Handle <> 0 Then
  275.                 WriteMemoryByte(Handle, Address, Value)
  276.             End If
  277.         End If
  278.     End Sub
  279.     Public Shared Sub WriteByteArray(ByVal EXENAME As String, ByVal Address As Integer, ByVal Value As Byte())
  280.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  281.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  282.             If Handle <> 0 Then
  283.                 WriteMemoryByteArray(Handle, Address, Value)
  284.             End If
  285.         End If
  286.     End Sub
  287.  
  288.     Public Shared Sub WriteInteger(ByVal EXENAME As String, ByVal Address As Integer, ByVal Value As Integer)
  289.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  290.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  291.             If Handle <> 0 Then
  292.                 WriteMemoryInteger(Handle, Address, Value)
  293.             End If
  294.         End If
  295.     End Sub
  296.  
  297.     Public Shared Sub WriteFloat(ByVal EXENAME As String, ByVal Address As Integer, ByVal Value As Single)
  298.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  299.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  300.             If Handle <> 0 Then
  301.                 WriteMemoryFloat(Handle, Address, Value)
  302.             End If
  303.         End If
  304.     End Sub
  305.  
  306.     Public Shared Sub WriteDouble(ByVal EXENAME As String, ByVal Address As Integer, ByVal Value As Double)
  307.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  308.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  309.             If Handle <> 0 Then
  310.                 WriteMemoryDouble(Handle, Address, Value)
  311.             End If
  312.         End If
  313.     End Sub
  314.  
  315.     Public Shared Sub WritePointerByte(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal Value As Byte, ByVal ParamArray Offset As Integer())
  316.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  317.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  318.             If Handle <> 0 Then
  319.                 For Each I As Integer In Offset
  320.                     ReadMemoryInteger(Handle, Pointer, Pointer)
  321.                     Pointer += I
  322.                 Next
  323.                 WriteMemoryByte(Handle, Pointer, Value)
  324.             End If
  325.         End If
  326.     End Sub
  327.  
  328.     Public Shared Sub WritePointerInteger(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal Value As Integer, ByVal ParamArray Offset As Integer())
  329.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  330.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  331.             If Handle <> 0 Then
  332.                 For Each I As Integer In Offset
  333.                     ReadMemoryInteger(Handle, Pointer, Pointer)
  334.                     Pointer += I
  335.                 Next
  336.                 WriteMemoryInteger(Handle, Pointer, Value)
  337.             End If
  338.         End If
  339.     End Sub
  340.  
  341.     Public Shared Sub WritePointerFloat(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal Value As Single, ByVal ParamArray Offset As Integer())
  342.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  343.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  344.             If Handle <> 0 Then
  345.                 For Each I As Integer In Offset
  346.                     ReadMemoryInteger(Handle, Pointer, Pointer)
  347.                     Pointer += I
  348.                 Next
  349.                 WriteMemoryFloat(Handle, Pointer, Value)
  350.             End If
  351.         End If
  352.     End Sub
  353.     Public Shared Sub WritePointerDouble(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal Value As Double, ByVal ParamArray Offset As Integer())
  354.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  355.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  356.             If Handle <> 0 Then
  357.                 For Each I As Integer In Offset
  358.                     ReadMemoryInteger(Handle, Pointer, Pointer)
  359.                     Pointer += I
  360.                 Next
  361.                 WriteMemoryDouble(Handle, Pointer, Value)
  362.             End If
  363.         End If
  364.  
  365.     End Sub
  366.     Public Shared Function ReadPointerLong(ByVal EXENAME As String, ByVal Pointer As Integer, ByVal ParamArray Offset As Integer()) As Long
  367.         Dim Value As Single
  368.         If Process.GetProcessesByName(EXENAME).Length <> 0 Then
  369.             Dim Handle As Integer = Process.GetProcessesByName(EXENAME)(0).Handle
  370.             If Handle <> 0 Then
  371.                 For Each I As Integer In Offset
  372.                     ReadMemoryInteger(Handle, Pointer, Pointer)
  373.                     Pointer += I
  374.                 Next
  375.                 ReadMemoryFloat(Handle, Pointer, Value)
  376.             End If
  377.         End If
  378.         Return Value
  379.     End Function
  380. #End Region
  381. End Class
  382. Public Class EXE
  383.     Public Shared Function Get_PID()
  384.         Try
  385.             Dim Process_Handle() As Process = Process.GetProcessesByName("gta_sa")
  386.             Dim cURL As Integer = CInt(0)
  387.             For Each Proc As Process In Process_Handle
  388.                 cURL += CInt(1)
  389.                 Return Proc.Id
  390.             Next
  391.             If cURL = CInt(0) Then
  392.                 Return 0
  393.             End If
  394.         Catch ex As Exception
  395.             Return 0
  396.         End Try
  397.     End Function
  398.     Public Shared Function Is_GTA_Running()
  399.         Dim Process_Handle() As Process = Process.GetProcessesByName("gta_sa")
  400.         Dim cURL As Integer = CInt(0)
  401.         For Each Proc As Process In Process_Handle
  402.             cURL += CInt(1)
  403.             Return 1
  404.         Next
  405.         If cURL = CInt(0) Then
  406.             Return 0
  407.         End If
  408.     End Function
  409.     Public Shared Sub Kill()
  410.         Dim Process_Handle() As Process = Process.GetProcessesByName("gta_sa")
  411.         Dim cURL As Integer = CInt(0)
  412.         For Each Proc As Process In Process_Handle
  413.             Proc.Kill()
  414.         Next
  415.     End Sub
  416. End Class
Advertisement
Add Comment
Please, Sign In to add comment