Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: naderST en 4 Febrero 2008, 04:10 am



Título: Duda con WriteProcessMemory
Publicado por: naderST en 4 Febrero 2008, 04:10 am
Bueno estaba probando para cambiar el nombre del jugador en el CS (Counter Strike) 1.6 y bueno lo logre con el CE (Cheat Engine) y quise hacerlo con VB6 hice lo siguiente pero no me da resultado pareciera que no escribe...

Código:
Option Explicit

Private Const PROCESS_ALL_ACCESS As Long = &H1F0FFF

Private Declare Function GetAsyncKeyState Lib "user32.dll" ( _
        ByVal vKey As Long) As Integer

Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
        ByVal lpClassName As String, _
        ByVal lpWindowName As String) As Long

Private Declare Function GetWindowThreadProcessId Lib "user32.dll" ( _
        ByVal hwnd As Long, _
        ByRef lpdwProcessId As Long) As Long
       
Private Declare Function OpenProcess Lib "kernel32.dll" ( _
        ByVal dwDesiredAccess As Long, _
        ByVal bInheritHandle As Long, _
        ByVal dwProcessId As Long) As Long
       
Private Declare Function WriteProcessMemory Lib "kernel32.dll" ( _
        ByVal hProcess As Long, _
        ByRef lpBaseAddress As Any, _
        ByRef lpBuffer As Any, _
        ByVal nSize As Long, _
        ByRef lpNumberOfBytesWritten As Long) As Long

Private Declare Function CloseHandle Lib "kernel32.dll" ( _
        ByVal hObject As Long) As Long
       
Private Sub CambiarNombre(Nombre As String)
Dim wHandle As Long
Dim pId     As Long
Dim pHandle As Long

wHandle = FindWindow(vbNullString, "Counter-Strike")

If wHandle = 0 Then Exit Sub

GetWindowThreadProcessId wHandle, pId

pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pId)

If pHandle = 0 Then Exit Sub

WriteProcessMemory pHandle, &H2F4DC28, StrPtr(Nombre), LenB(Nombre), 0&

CloseHandle pHandle
End Sub

Private Sub Form_Load()
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyF5) Then CambiarNombre ("NADER")
End Sub


Título: Re: Duda con WriteProcessMemory
Publicado por: Hendrix en 4 Febrero 2008, 12:49 pm
Con solamente WriteProcessMemory no te va a funcionar...necesitas reservar memoria para poder escribir...

Fijate en este post que hice, este reserva una región de memoria en un proceso remoto y leugo escribe en el.

http://foro.elhacker.net/index.php/topic,168272.0.html

Intenta extraer lo que necesites del codigo.

Un Saludo  :)


Título: Re: Duda con WriteProcessMemory
Publicado por: naderST en 4 Febrero 2008, 16:00 pm
Muchas gracias ya me pongo a verlo.


Título: Re: Duda con WriteProcessMemory
Publicado por: naderST en 4 Febrero 2008, 16:54 pm
Amigo pero deberia funcionar como yo lo puse porque fijate yo saque el codigo de un Trainer de el juego GTA: San Andreas con WriteProcessMemory y de ahi fue de donde me guie yo...

Este es parte del codigo del trainer:

Código:
Private Sub FreezeTime()
Dim hwnd As Long
Dim pid As Long
Dim pHandle As Long
Dim x As Integer

hwnd = FindWindow(vbNullString, "GTA: San Andreas")
If (hwnd = 0) Then hwnd = FindWindow(vbNullString, "GTA: San Andreas")

If (hwnd = 0) Then
    lblState.Caption = "State: Jeu non Lancer."
    Timer1.Enabled = False
    Exit Sub
End If

GetWindowThreadProcessId hwnd, pid

pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)

If (pHandle = 0) Then
    lblState.Caption = "State: Couldn't get a process handle."
    Timer1.Enabled = False
    Exit Sub
End If

WriteProcessMemory pHandle, Hex2Dec("52CF53"), Hex2ASCII("90 90 90 90 90 90"), Len(Hex2ASCII("90 90 90 90 90 90")), 0&

CloseHandle pHandle
End Sub


Título: Re: Duda con WriteProcessMemory
Publicado por: Hendrix en 5 Febrero 2008, 00:06 am
De la manera que te indico yo tiene que funcionar al 100%, prueba usando mi codigo  :-\

Sino no se porque no funciona.


Título: Re: Duda con WriteProcessMemory
Publicado por: Tughack en 5 Febrero 2008, 11:55 am
Hendrix, no siempre hay k reservar espacio en memoria. Pero si hay k revisar los permisos. naderST, has visto se hay permisos para escribir? Intenta usar el VirtualProtectEx. Ah, y mira nuevamente se los offsets estan correctos ^^

Saludos