• Welcome to Valhalla Legends Archive.
 

MakeWORD Problem

Started by Zer0, September 26, 2006, 10:01 PM

Previous topic - Next topic

Zer0

ok i dont see anything wroung with this but mabey im just stupid or somthn? i am using VB.Net


Public Function MakeWORD(ByRef Value As Short) As String
Dim Result As New VB6.FixedLengthString(2)
CopyMemory(Result.Value, Value, 2)
MakeWORD = Result.Value
End Function


it is telling me there is a error in

CopyMemory(Result.Value, Value, 2)

FrostWraith

Don't scream at me if this doesnt work but in VB you only user parentheses when calling or setting to a variable. Try this:
CopyMemory Result.Value, Value, 2

topaz

Quote from: Zer0 on September 26, 2006, 10:01 PM
ok i dont see anything wroung with this but mabey im just stupid or somthn? i am using VB.Net


Public Function MakeWORD(ByRef Value As Short) As String
Dim Result As New VB6.FixedLengthString(2)
CopyMemory(Result.Value, Value, 2)
MakeWORD = Result.Value
End Function


it is telling me there is a error in

CopyMemory(Result.Value, Value, 2)


1. What's the error
2. The value you're trying to convert is probably not the right size
RLY...?

l2k-Shadow

try placing ByVal in front of Result.Value so

CopyMemory(ByVal Result.Value, Value, 2)
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

MyndFyre

The problem is that you're using CopyMemory in VB.NET where there are 30 better ways for you to do it.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Zer0

shadow when i tryed using ByVal i got...
Expression expected.

and MyndFyre u mind telling me a better one?

MyndFyre

In .NET, you should be treating your binary data as byte arrays, not as strings.  That's because they're handled efficiently in .NET, and the Framework Class Library has classes that support using byte arrays for data.  Not only that, but converting from a string back to a byte array to be sent via a Socket, NetworkStream, TcpClient, or any of the other classes will cause data loss and truncation.

To convert from a Short to a Byte(), use BitConverter.GetBytes(ByVal s As Short).  To convert two bytes at a specific byte array index, use BitConverter.ToInt16(ByVal arr() As Byte, ByVal index As Integer).  Alternatively, you may want to investigate the System.IO.MemoryStream class, which treats memory sort of like a pointer.

MBNCSUtil has packet buffers and data readers written in C# that demonstrate how to use this functionality in the class library.  I highly suggest that you check it out.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Zer0

wow lol from looking at what u just showd me im going to have to re-write almost the entire bot. Is there a source out there for a example of a working .Net bot so i can get a little clearer idea because i am still rather new to .Net. Thx for the help MyndFyre n everyone else who tried :)

FrOzeN

Quote from: Zer0 on September 27, 2006, 01:19 AM
Is there a source out there for a example of a working .Net bot so i can get a little clearer idea because i am still rather new to .Net. Thx for the help MyndFyre n everyone else who tried :)
Yeah, most likely. Though IMO, I think you'll find that trying to develop a bot yourself, you'll grasp a much better understand of how it works. You'll also gain more skills investigating and learning how to handle packets, debug better, etc. Having a source code as a reference takes away these things, and won't give you as much understanding of your code.
~ FrOzeN