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 


VB08 WriteMemory not working? WHY? PLEASE HELP!
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
. . ,
Master Cheater
Reputation: 3

Joined: 05 Nov 2009
Posts: 337

PostPosted: Wed Feb 10, 2010 10:12 am    Post subject: VB08 WriteMemory not working? WHY? PLEASE HELP! Reply with quote

I'm trying to make a hack for wow which controls the walls. 0 sets it to off, if the value is 0 then it will make you run up walls. heres what I have.

Forms x1
Modules x1
Buttons x2
LabelLinks x3
Labels x8
TabControl x1
Tabs x2

The code I have for form1.

FORM1.VB*

Code:
Public Class Form1

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Process.Start("www.youtube.com/megaforce300")
    End Sub

    Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
        Process.Start("www.google.co.uk")
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Process.Start("www.youtube.com/megaforce300")
    End Sub

    Private Sub LinkLabel3_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel3.LinkClicked
        Process.Start("http://forum.cheatengine.org/viewtopic.php?p=4661424#4661424")
    End Sub
    Private Sub TabPage2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage2.Click
        MsgBox("NOTICE: Megaforce300 AND ZURKEI IS NOT RESPONSIBLE FOR ANY BANNINGS OR SUSPENSIONS. IT IS ENTIRELY YOUR CHOICE TO USE HACKS.")
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WriteMemory(&H972F88, 0, 4)
    End Sub
End Class


The code I have for Module1.

MODULE1.VB*

Code:
Module Module1
    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
    Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
    Private Declare Function WriteFloatMemory Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Single, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
    Private Declare Function ReadFloat Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByRef buffer As Single, ByVal size As Int32, ByRef lpNumberOfBytesRead As Int32) As Boolean
    Private Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
    Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    Public RBuff As Long
    Public RBuff2 As Single
    Public RBuff3 As Integer
    Public Function WriteMemory(ByVal Address As Integer, ByVal Value As Long, ByVal Bytes As Integer)

        Dim WoWLookUp As Process() = Process.GetProcessesByName("World Of Warcraft")

        If WoWLookUp.Length = 4 Then

            End

        End If

        Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, WoWLookUp(0).Id)

        WriteProcessMemory(processHandle, Address, Value, Bytes, Nothing)

        CloseHandle(processHandle)

    [color=red]End Function[/color]
End Module


"End Function" I highlighted red because it is underlined green. :S

ERROR I GET!



PLEASE READ BEFORE POSTING!

The code was correct. I used that code to make a trainer in CE 5.5 and it worked. The patch is correct.
Back to top
View user's profile Send private message
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Wed Feb 10, 2010 10:28 am    Post subject: Reply with quote

That is a warning not an error.
_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
. . ,
Master Cheater
Reputation: 3

Joined: 05 Nov 2009
Posts: 337

PostPosted: Wed Feb 10, 2010 10:31 am    Post subject: Reply with quote

JesusLovesQlimax wrote:
That is a warning not an error.


It doesnt do anything thou. When I activate the hack it doesnt do anything
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Feb 10, 2010 4:46 pm    Post subject: Reply with quote

the debugger exists for a reason, step through your code to unravel whatever mysteries lie


ps:

http://msdn.microsoft.com/en-us/library/87x5f80y%28VS.80%29.aspx
Back to top
View user's profile Send private message
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Wed Feb 10, 2010 9:11 pm    Post subject: Reply with quote

Code:

Public Function WriteMemory(ByVal Address As Integer, ByVal Value As Long, ByVal Bytes As Integer)

        Dim WoWLookUp As Process() = Process.GetProcessesByName("World Of Warcraft")

        If WoWLookUp.Length = 4 Then

            End

        End If

        Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, WoWLookUp(0).Id)

        WriteProcessMemory(processHandle, Address, Value, Bytes, Nothing)

        CloseHandle(processHandle)

    [color=red]End Function[/color]
End Module


To

Code:

Public Function WriteMemory(ByVal Address As Integer, ByVal Value As Long, ByVal Bytes As Integer) As Integer

        Dim WoWLookUp As Process() = Process.GetProcessesByName("World Of Warcraft")

        If WoWLookUp.Length = 4 Then

            End

        End If

        Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, WoWLookUp(0).Id)

        WriteProcessMemory(processHandle, Address, Value, Bytes, Nothing)

        CloseHandle(processHandle)

    [color=red]End Function[/color]
End Module


The warning will go away..
Back to top
View user's profile Send private message MSN Messenger
FullyAwesome
I post too much
Reputation: 0

Joined: 05 Apr 2007
Posts: 4438
Location: Land Down Under

PostPosted: Thu Feb 11, 2010 12:08 am    Post subject: Reply with quote

change Function to Sub (both for "Public Function" and "End Function"). if you're going to return a value you'd use a Function. don't use iPromises way unless you actually want to return an integer. :\
_________________
Back to top
View user's profile Send private message MSN Messenger
. . ,
Master Cheater
Reputation: 3

Joined: 05 Nov 2009
Posts: 337

PostPosted: Fri Feb 12, 2010 8:55 am    Post subject: Reply with quote

iPromise wrote:
Code:

Public Function WriteMemory(ByVal Address As Integer, ByVal Value As Long, ByVal Bytes As Integer)

        Dim WoWLookUp As Process() = Process.GetProcessesByName("World Of Warcraft")

        If WoWLookUp.Length = 4 Then

            End

        End If

        Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, WoWLookUp(0).Id)

        WriteProcessMemory(processHandle, Address, Value, Bytes, Nothing)

        CloseHandle(processHandle)

    [color=red]End Function[/color]
End Module


To

Code:

Public Function WriteMemory(ByVal Address As Integer, ByVal Value As Long, ByVal Bytes As Integer) As Integer

        Dim WoWLookUp As Process() = Process.GetProcessesByName("World Of Warcraft")

        If WoWLookUp.Length = 4 Then

            End

        End If

        Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, WoWLookUp(0).Id)

        WriteProcessMemory(processHandle, Address, Value, Bytes, Nothing)

        CloseHandle(processHandle)

    [color=red]End Function[/color]
End Module


The warning will go away..


Thanks man, No warning. gonna test this out.

EDIT: I run debug and this happened when I activated the hack



Capture.JPG
 Description:
 Filesize:  216.92 KB
 Viewed:  10764 Time(s)

Capture.JPG


Back to top
View user's profile Send private message
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Fri Feb 12, 2010 9:45 am    Post subject: Reply with quote

Change

Code:

 Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer


To

Code:

 Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As IntPtr


+Rep me if i'm helping you.
Back to top
View user's profile Send private message MSN Messenger
AtheistCrusader
Grandmaster Cheater
Reputation: 6

Joined: 23 Sep 2006
Posts: 681

PostPosted: Fri Feb 12, 2010 12:52 pm    Post subject: Reply with quote

iPromise wrote:
Change

Code:

 Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer


To

Code:

 Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As IntPtr


+Rep me if i'm helping you.


Lmao rep whoring much?
Back to top
View user's profile Send private message
FullyAwesome
I post too much
Reputation: 0

Joined: 05 Apr 2007
Posts: 4438
Location: Land Down Under

PostPosted: Fri Feb 12, 2010 3:53 pm    Post subject: Reply with quote

yeah just skip over my comment and go to the guy who thinks rep means something. :\

FullyAwesome wrote:
change Function to Sub (both for "Public Function" and "End Function"). if you're going to return a value you'd use a Function. don't use iPromises way unless you actually want to return an integer. :\



i also seriously doubt the process name would be World Of Warcraft.exe, so WoWLookUp(0) won't exist, so it'll tell you index 0 is outside of the array's range. i'd assume that it'd be something like wow.exe (where the window title might be World of Warcraft). you have a check to see if the array is of length 4, why wouldn't you have a check to see if it's of length 0...?

lol @ iPromise's answer again. xD even though it should be IntPtr, it's not going to fix that error. :\

_________________
Back to top
View user's profile Send private message MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Feb 12, 2010 4:57 pm    Post subject: Reply with quote

MΣGŃσ& wrote:
EDIT: I run debug and this happened when I activated the hack


Use the debugger.

Set breakpoints (by clicking on the left margin) and step through your code.


BUT LETS SEE ANYWAY:

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.getprocessesbyname.aspx

Quote:
Return Value
Type: System.Diagnostics.Process[]
An array of type Process that represents the process resources running the specified application or file.

Use this method to create an array of new Process components and associate them with all the process resources that are running the same executable file on the local computer. The process resources must already exist on the computer, because GetProcessesByName does not create system resources but rather associates them with application-generated Process components. A processName can be specified for an executable file that is not currently running on the local computer, so the array the method returns can be empty.

and...

The process name is a friendly name for the process, such as Outlook, that does not include the .exe extension or the path. GetProcessesByName is helpful for getting and manipulating all the processes that are associated with the same executable file. For example, you can pass an executable file name as the processName parameter, in order to shut down all the running instances of that executable file.



Sure as shit:
Code:
            Process[] p     = Process.GetProcessesByName("OBVIOUSLY_FAKE_NAME");
            string dong     = p[0].ToString(); //OH FFF, nothing's there! (since there was no existing process)
            //'System.IndexOutOfRangeException', tried to access what doesn't exist.


Problem solved. You're trying to access what doesn't exist because there was no process by that name to retrieve info from.


HELP HOW DO I FIX IT:
Fix your process name, read above.

B-b-but what do I do if it's wrong again or it's not running!?
Check to make sure the array isn't empty. Exceptions are expensive, an easier and faster way is to just do:
Code:
if(arrayname.Length != 0)...
Back to top
View user's profile Send private message
. . ,
Master Cheater
Reputation: 3

Joined: 05 Nov 2009
Posts: 337

PostPosted: Sat Feb 13, 2010 10:18 pm    Post subject: Reply with quote

I changed the "World Of Warcraft" to Wow. And I get no error but it doesnt work

Heres taskmanager what it shows as


Processes Tab:

Wow.exe

Applications Tab:

World Of Warcraft
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Feb 13, 2010 10:20 pm    Post subject: Reply with quote

Use the debugger holy shit it's there for a reason

GET FAMILIAR WITH IT, IT WILL SAVE YOU AN INFINITE AMOUNT OF TIME AND GRIEF
Back to top
View user's profile Send private message
. . ,
Master Cheater
Reputation: 3

Joined: 05 Nov 2009
Posts: 337

PostPosted: Mon Feb 15, 2010 4:17 am    Post subject: Reply with quote

slovach wrote:
Use the debugger holy shit it's there for a reason

GET FAMILIAR WITH IT, IT WILL SAVE YOU AN INFINITE AMOUNT OF TIME AND GRIEF


debugger? wtf u on it doesnt work weather I use that or not.

FullyAwesome wrote:
yeah just skip over my comment and go to the guy who thinks rep means something. :\

FullyAwesome wrote:
change Function to Sub (both for "Public Function" and "End Function"). if you're going to return a value you'd use a Function. don't use iPromises way unless you actually want to return an integer. :\



i also seriously doubt the process name would be World Of Warcraft.exe, so WoWLookUp(0) won't exist, so it'll tell you index 0 is outside of the array's range. i'd assume that it'd be something like wow.exe (where the window title might be World of Warcraft). you have a check to see if the array is of length 4, why wouldn't you have a check to see if it's of length 0...?

lol @ iPromise's answer again. xD even though it should be IntPtr, it's not going to fix that error. :\


How do I check the lenght?
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Mon Feb 15, 2010 4:44 am    Post subject: Reply with quote

MΣGŃσ& wrote:
slovach wrote:
Use the debugger holy shit it's there for a reason

GET FAMILIAR WITH IT, IT WILL SAVE YOU AN INFINITE AMOUNT OF TIME AND GRIEF


debugger? wtf u on it doesnt work weather I use that or not.


it means learn to debug your programs you dope not just run a debug build and hope for magic.

how do you think you get a better look at what is actually happening in your code? just because you wrote it doesn't mean it works as expected.

the first hit for 'visual studio debug tutorial' on google brings:
http://dotnetperls.com/debugging-1 which looks like a decent enough crash course, though it doesn't go into detail


MΣGŃσ& wrote:
How do I check the lenght?


read my post.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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