Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: iNsaNe on March 05, 2007, 10:09 PM

Title: CopyMemory with Visual Basic Express 2005
Post by: iNsaNe on March 05, 2007, 10:09 PM
In Visual Basic Express 2005,  declaring a parameter as 'Any' isn't allowed. How could I change this declaration..

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal numbytes As Long)
Title: Re: CopyMemory with Visual Basic Express 2005
Post by: Spilled on March 05, 2007, 10:21 PM
Never used 2005 but try this:

Public Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (ByRef Destination As Object, ByRef Source As Object, ByVal Length As Short)
Title: Re: CopyMemory with Visual Basic Express 2005
Post by: l2k-Shadow on March 05, 2007, 11:04 PM
Quote from: iNsaNe on March 05, 2007, 10:09 PM
In Visual Basic Express 2005,  declaring a parameter as 'Any' isn't allowed. How could I change this declaration..

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal numbytes As Long)

Public Declare Sub CopyMemoryToInt lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Integer, ByRef Source As String, ByVal numbytes As Integer)

Public Declare Sub CopyMemoryToStr lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As String, ByRef Source As Integer, ByVal numbytes As Integer)
Title: Re: CopyMemory with Visual Basic Express 2005
Post by: iNsaNe on March 05, 2007, 11:07 PM
Quote from: l2k-Shadow on March 05, 2007, 11:04 PM

Public Declare Sub CopyMemoryToInt lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Integer, ByRef Source As String, ByVal numbytes As Integer)

Public Declare Sub CopyMemoryToStr lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As String, ByRef Source As Integer, ByVal numbytes As Integer)


I'm kind of noob to this.. what would CopyMemoryToInt and CopyMemoryToStr be used for instead of just using CopyMemory
Title: Re: CopyMemory with Visual Basic Express 2005
Post by: l2k-Shadow on March 05, 2007, 11:08 PM
Quote from: iNsaNe on March 05, 2007, 11:07 PM
Quote from: l2k-Shadow on March 05, 2007, 11:04 PM

Public Declare Sub CopyMemoryToInt lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Integer, ByRef Source As String, ByVal numbytes As Integer)

Public Declare Sub CopyMemoryToStr lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As String, ByRef Source As Integer, ByVal numbytes As Integer)


I'm kind of noob to this.. what would CopyMemoryToInt and CopyMemoryToStr be used for instead of just using CopyMemory

Look at the declarations of both and figure it out.

EDIT: In order to help you understand this, it's because in C++, the function is declared as memcpy(void*, const void*, size_t) so in VB noob terms: take void as something like Any in VB... but since VB.NET doesn't have Any, you have to specify which type of variable you'd like to copy into instead of just "Any variable I want at the time".
Title: Re: CopyMemory with Visual Basic Express 2005
Post by: MyndFyre on March 06, 2007, 12:06 AM
Please see this thread (http://forum.valhallalegends.com/index.php?topic=12683.0).