| View previous topic :: View next topic |
| Author |
Message |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Thu Mar 20, 2008 7:18 pm Post subject: Write Byte in VB |
|
|
when I try writing a byte to the memory (opcodes) it gives me an error...
Can someone post an example?
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Thu Mar 20, 2008 8:08 pm Post subject: |
|
|
| You're just using WriteProcessMemory, and it works just as you imagine.
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Thu Mar 20, 2008 8:37 pm Post subject: |
|
|
| I did. It gaves me stupid error. I tryed every variation and it still errors. It works very well with dword, string etc but it doesn't work with byte.
|
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Fri Mar 21, 2008 3:29 am Post subject: |
|
|
| Please post the code and what language you use.
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Fri Mar 21, 2008 11:53 am Post subject: |
|
|
Visual Basic:
Function WriteByte(ByteWrite as Byte)
WriteProcessMemory(ProcHandle,&H00401003,"&H" & ByteWrite,1,&0)
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Mar 21, 2008 9:16 pm Post subject: |
|
|
From my VB6 Trainer Toolkit, use both functions, but only need to call WriteByte. WriteByte wraps WriteMemory to only write a byte to the given address.
The first param is the process id, you can change this if you want, but I prefer using the process ID over the handle as I dislike FindWindow.
Example:
Call WriteByte( &H100000, &HA )
| Code: | Private Function WriteMemory(dwProcId As Long, dwAddress As Long, ByVal pValue As Long, ByVal dwLength As Long) As Boolean
If dwAddress = 0 Then
WriteMemory = False
Exit Function
End If
Dim procHandle As Long
procHandle = OpenProcess(PROCESS_ALL_ACCESS, False, dwProcId)
If procHandle = 0 Then
WriteMemory = False
Exit Function
End If
Dim dwReturned As Long
dwReturned = WriteProcessMemory(procHandle, ByVal dwAddress, ByVal pValue, dwLength, 0&)
Call CloseHandle(procHandle)
If dwReturned > 0 Then
WriteMemory = True
Else
WriteMemory = False
End If
End Function
Public Function WriteByte(dwProcId As Long, dwAddress As Long, ByVal dwValue As Byte) As Boolean
If dwProcId = 0 Or dwAddress = 0 Then
WriteByte = False
Exit Function
End If
If WriteMemory(dwProcId, dwAddress, VarPtr(dwValue), LenB(dwValue)) = False Then
WriteByte = False
Exit Function
End If
WriteByte = True
End Function |
_________________
- Retired. |
|
| Back to top |
|
 |
|