Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Write Byte in VB

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Thu Mar 20, 2008 7:18 pm    Post subject: Write Byte in VB Reply with quote

when I try writing a byte to the memory (opcodes) it gives me an error...

Can someone post an example?
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu Mar 20, 2008 8:08 pm    Post subject: Reply with quote

You're just using WriteProcessMemory, and it works just as you imagine.
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Thu Mar 20, 2008 8:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Fri Mar 21, 2008 3:29 am    Post subject: Reply with quote

Please post the code and what language you use.
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Fri Mar 21, 2008 11:53 am    Post subject: Reply with quote

Visual Basic:
Function WriteByte(ByteWrite as Byte)
WriteProcessMemory(ProcHandle,&H00401003,"&H" & ByteWrite,1,&0)
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Mar 21, 2008 9:16 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites