AJUDA COM WRITESTRING

GUGUSINBANSAI 06/01/2012 22:22:58
#392601
Bom galera é o seguinte, eu estou desenvolvendo um IP-Changer para Tibia e ao meu ver esta tudo correto porem os caracteres ao serem convertidos para bytes retornam um valor absurdo.

A seguir meu código:

Citação:

[ô]Form
[ô]--------------------------------------------------------------------------------------------------------------
Private Declare Function FindWindow Lib [Ô]user32[Ô] Alias [Ô]FindWindowA[Ô] (ByVal Classname As String, ByVal WindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib [Ô]user32[Ô] (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Sub Command1_Click()
Dim hwnd As Long
Dim pid As Long
hwnd = FindWindow(vbNullString, [Ô]Tibia[Ô])
GetWindowThreadProcessId hwnd, pid
changeip (pid)
End Sub




Citação:

[ô]Módulo
[ô]--------------------------------------------------------------------------------------------------------------
Private Declare Function OpenProcess Lib [Ô]kernel32[Ô] (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function WriteProcessMemory Lib [Ô]kernel32[Ô] (ByVal hProcess As Long, ByVal lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function CloseHandle Lib [Ô]kernel32[Ô] (ByVal hObject As Long) As Long
Public Function changeip(ByVal IDofProcess As Long) As Boolean
Const PROCESS_ALL_ACCESS = &H1F0FFF
Dim ax1 As Long
Dim ax2 As String
Dim phandle As Long
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, IDofProcess)
For ax1 = 1 To Len(frmIP.Text1.Text)
ax2 = ax2 & Asc(Mid$(frmIP.Text1.Text, ax1, 1))
Next
ax1 = 0
If Not frmIP.Text1.Text = [Ô][Ô] Then
WriteProcessMemory phandle, &H7947F8, ax2 & Chr(0), Len(ax2) + 1, 0&
WriteProcessMemory phandle, &H7947F8, ax2 & Chr(0), Len(ax2) + 1, 0&
WriteProcessMemory phandle, &H794868, ax2 & Chr(0), Len(ax2) + 1, 0&
WriteProcessMemory phandle, &H7948D8, ax2 & Chr(0), Len(ax2) + 1, 0&
WriteProcessMemory phandle, &H794948, ax2 & Chr(0), Len(ax2) + 1, 0&
WriteProcessMemory phandle, &H7949B8, ax2 & Chr(0), Len(ax2) + 1, 0&
WriteProcessMemory phandle, &H794A28, ax2 & Chr(0), Len(ax2) + 1, 0&
WriteProcessMemory phandle, &H794A98, ax2 & Chr(0), Len(ax2) + 1, 0&
WriteProcessMemory phandle, &H794B08, ax2 & Chr(0), Len(ax2) + 1, 0&
WriteProcessMemory phandle, &H794B78, ax2 & Chr(0), Len(ax2) + 1, 0&
WriteProcessMemory phandle, &H794BE8, ax2 & Chr(0), Len(ax2) + 1, 0&
Else
MsgBox [Ô]Digite um IP primeiro![Ô], vbCritical, [Ô]Erro![Ô]
End If
CloseHandle phandle
End Function




------------------------------------------------------------------------------------------------------------------



Desde já agradeço.
ASHKATCHUP 06/01/2012 23:03:34
#392606
Não entendi.. o teu código não está funcionando?
GUGUSINBANSAI 07/01/2012 00:19:49
#392611
Citação:

:
Não entendi.. o teu código não está funcionando?



é assim, o tibia tem alguns endereços de memória onde o ip é gravado. Primeiro o programa converte a escrita da textbox para bytes. Depois ela muda estes endereços do tibia para o valor em bytes da textbox, porém esse valor é mudado para caracteres estranhos e não o texto que escrevi na textbox (Verifiquei pelo cheat engine).

Acho que o erro esta aqui:

Citação:

For ax1 = 1 To Len(frmIP.Text1.Text)
ax2 = ax2 & Asc(Mid$(frmIP.Text1.Text, ax1, 1))
Next
ax1 = 0

GUGUSINBANSAI 07/01/2012 00:22:22
#392612
Onde esta escrito errado é como fica depois de executar a função e o certo é como deveria ficar!
ASHKATCHUP 07/01/2012 01:07:24
#392613
Tenta assim

  bytes = StrConv(txt, vbFromUnicode)
Tópico encerrado , respostas não são mais permitidas