• Welcome to Valhalla Legends Archive.
 

Help!

Started by Michael, September 18, 2007, 07:13 PM

Previous topic - Next topic

Michael

Ok, i first off want to say... this is the first time i am using C++... second i don't wish to learn the entire c++ coding structure only want to get this one part to work so i can go about my happy gaming life.

before i get into any coding aspects, i want you to know what it is i plan to do.



I want to switch login counts with game time, i did this with visual studio 2005 and it complies but does not inject the .dll like it should.

I used visual studio 6 vc++ and i get 3 errors when attempting to build.


--------------------Configuration: PickLoad - Win32 Release--------------------
Compiling...
ManualMap.cpp
C:\Documents and Settings\Mike\My Documents\Downloads\Compressed\NH OOG\ManualMap.cpp(108) :
error C2065: 'DWORD_PTR' : undeclared identifier
C:\Documents and Settings\Mike\My Documents\Downloads\Compressed\NH OOG\ManualMap.cpp(254) :
error C2664: 'WriteProcessMemory' : cannot convert parameter 3 from 'const void *' to 'void *'
        Conversion loses qualifiers
C:\Documents and Settings\Mike\My Documents\Downloads\Compressed\NH OOG\ManualMap.cpp(306) :
error C2440: '=' : cannot convert from 'unsigned long' to 'unsigned long *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

OOG.exe - 3 error(s), 0 warning(s)


the source code to the program can be found at:
http://www.clangdn.com/mike/NH%20OOG.zip

Now why i do i want to just switch those two boxes?, i have written a visual basic program to get the text of the textbox, but sadly i have not found a way to get anything but the text of the first text box. This program has a few bugs which stop me from being able to run it overnight i want to make a vb program that monitors the game time and if it exceeds a certain number the vb program will restart it and press "Run" so this way i can run it while i sleep. (Why don't i fix the bugs and learn c++... because by the time i did that i'd probably end up having to write an entirely new program and i would spend a lot less time gaming.)

Basically how do i fix them 3 errors? i cant find it anywhere on google.

[Kp edit: broke up long lines.]

brew

#1
Quote from: -MichaeL- on September 18, 2007, 07:13 PM
Ok, i first off want to say... this is the first time i am using C++... second i don't wish to learn the entire c++ coding structure only want to get this one part to work so i can go about my happy gaming life.

before i get into any coding aspects, i want you to know what it is i plan to do.



I want to switch login counts with game time, i did this with visual studio 2005 and it complies but does not inject the .dll like it should.

I used visual studio 6 vc++ and i get 3 errors when attempting to build.


the source code to the program can be found at:
http://www.clangdn.com/mike/NH%20OOG.zip

Now why i do i want to just switch those two boxes?, i have written a visual basic program to get the text of the textbox, but sadly i have not found a way to get anything but the text of the first text box. This program has a few bugs which stop me from being able to run it overnight i want to make a vb program that monitors the game time and if it exceeds a certain number the vb program will restart it and press "Run" so this way i can run it while i sleep. (Why don't i fix the bugs and learn c++... because by the time i did that i'd probably end up having to write an entirely new program and i would spend a lot less time gaming.)

Basically how do i fix them 3 errors? i cant find it anywhere on google.
So I take it that you didn't make that application? Just added a few things..? Anyways, the problems you are having can easily be fixed by using something called casts. These statements have the syntax of "(newvariabletypehere)" and are placed before the statement you want to cast. Like so:

asdf = (unsigned long *)&asfgh;
or...
asdfg((char *)blah, &blah2, blah3);


What you need to do is, at line 306, add just what the error says-- a function style cast (first example in code). You're obviously trying to store an address in an unsigned long pointer, so either change the declaration for that variable to an unsigned long or you could cast it to an unsigned long by adding (unsigned long) right after the assignment operator.
The first error is because you didn't define the DWORD_PTR typedef. You can easily do this by putting....
typedef unsigned long * DWORD_PTR.
For the second error, add a parameter style cast (example 2.), just do (const void *).
see? EZ!
by the way, i didn't look at your code. So i don't know how good that explanation will work for you.

[Kp edit: deleted quote of code block with long lines.  brew should know better.]
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

UserLoser

No, brew, not (const void*), that wouldn't work.

Camel

Also, your typedef is broken.

brew

Quote from: UserLoser on September 18, 2007, 10:23 PM
No, brew, not (const void*), that wouldn't work.
Why not? The function isn't going to even attempt to write to it if it's passed as a const. I'm not sure about const void *s, but I know that works just honkey dorey for const char * parameters. I've done it many times.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

UserLoser

Quote from: brew on September 19, 2007, 02:20 PM
Quote from: UserLoser on September 18, 2007, 10:23 PM
No, brew, not (const void*), that wouldn't work.
Why not? The function isn't going to even attempt to write to it if it's passed as a const. I'm not sure about const void *s, but I know that works just honkey dorey for const char * parameters. I've done it many times.

You should probably re-read the error message

Quoteerror C2664: 'WriteProcessMemory' : cannot convert parameter 3 from 'const void *' to 'void *'

Michael

#6
Wow, i just went to try the mephbot (the one i didn't compile) sadly it gets to meph and says couldn't interact with object now which it never did before. so i think installing visual studio 6.0 messed up something damn it :( oh and i got it to compile fine in visual studio 2005 just the one i compile doesn't inject the memory handle... seems i now need to reformat and start all over with this i think i may have damaged something in my windows.

Kp

Let me start by saying that brew has no idea what he is talking about.  Adding casts to a program suppresses the compiler's ability to warn you of mistakes.  Adding casts blindly is a good way to turn compilation errors into runtime errors, because you force the compiler to compile incorrect code.  Casts do have a place, but if you cannot explain why you need a cast in a particular place, you probably should not be using a cast there.

Also, as noted, DWORD_PTR is not an unsigned long *.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

brew

Quote from: Kp on September 19, 2007, 08:51 PM
Let me start by saying that brew has no idea what he is talking about.  Adding casts to a program suppresses the compiler's ability to warn you of mistakes.  Adding casts blindly is a good way to turn compilation errors into runtime errors, because you force the compiler to compile incorrect code.  Casts do have a place, but if you cannot explain why you need a cast in a particular place, you probably should not be using a cast there.
He asked how to "fix those errors". That kinda fixes it... :P.
Blindly (not completely blindly though) adding casts usually helps. I, myself, can't explain why they needed to be added. I just said to add them. You are right-- I don't have any idea what I was talking about, I didn't look at the code at all. Instead I just suggested using casts and gave some simple examples. The *right* way to fix the code is to declare the variables with the proper types in the first place.

Quote
Also, as noted, DWORD_PTR is not an unsigned long *.
Oh yeah, I just remembered about that flame war I got in with myndfyre about that. Apparently a DWORD_PTR is supposed to be a variable the size of a pointer. Ummmm....
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

devcode

#define DWORD_PTR DWORD g00glez

Michael

#10
Well, i reformatted and the program works again (not the one i managed to compile using visual studio 2005). but i need to install visual studio 2005 again, as to fixing the problem i guess i will have to look more through google. and thanks to all so far that have attempted to help. I think installing visual studio 2005 first then visual studio 6.0 is what damaged my windows. as i kept getting memory errors afterwards. I will install visual studio 2005 either later tonight or tomorrow and attempt to fix the program again.

Camel

#11
Actually, I was trying to point out that the typedef was malformed. Either he fixed it, or I was drunk at the time.

Kp

Quote from: brew on September 19, 2007, 09:12 PM
Blindly (not completely blindly though) adding casts usually helps.

Yes, it helps the program compile and maybe even link.  It does not necessarily help the program run correctly.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Camel

I can't think of any condition where a cast would affect linking.

Kp

/* file1 */
extern int a(int *);
extern int a(float *);

void b(int x)
{
a(&x);
}
/* file 2 */
int a(float *f)
{
return 0;
}

int main()
{
return 0;
}

> g++  file1.cc file2.cc
ccavkdzI.o: In function `b(int)':
file1.cc:(.text+0xd): undefined reference to `a(int*)'


Change to:
/* file 1 */
extern int a(int *);
extern int a(float *);

void b(int x)
{
    a((float *) &x);
}   
> g++  file1.cc file2.cc
>
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!