Author | Message | Time |
---|---|---|
-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. [img]http://www.clangdn.com/mike/oog.JPG[/img] 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. [code] --------------------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) [/code] 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.] | September 19, 2007, 12:13 AM |
BreW | [quote author=-MichaeL- link=topic=17029.msg172909#msg172909 date=1190160830] 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. [img]http://www.clangdn.com/mike/oog.JPG[/img] 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. [/quote] 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: [code] asdf = (unsigned long *)&asfgh; or... asdfg((char *)blah, &blah2, blah3); [/code] 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.] | September 19, 2007, 1:44 AM |
UserLoser | No, brew, not (const void*), that wouldn't work. | September 19, 2007, 3:23 AM |
Camel | Also, your typedef is broken. | September 19, 2007, 5:48 PM |
BreW | [quote author=UserLoser link=topic=17029.msg172913#msg172913 date=1190172185] No, brew, not (const void*), that wouldn't work. [/quote] 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. | September 19, 2007, 7:20 PM |
UserLoser | [quote author=brew link=topic=17029.msg172940#msg172940 date=1190229619] [quote author=UserLoser link=topic=17029.msg172913#msg172913 date=1190172185] No, brew, not (const void*), that wouldn't work. [/quote] 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. [/quote] You should probably re-read the error message [quote]error C2664: 'WriteProcessMemory' : cannot convert parameter 3 from 'const void *' to 'void *'[/quote] | September 19, 2007, 8:05 PM |
-MichaeL- | 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. | September 19, 2007, 8:35 PM |
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 *. | September 20, 2007, 1:51 AM |
BreW | [quote author=Kp link=topic=17029.msg172952#msg172952 date=1190253100] 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. [/quote] 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 *. [/quote] 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.... | September 20, 2007, 2:12 AM |
devcode | #define DWORD_PTR DWORD g00glez | September 20, 2007, 2:59 AM |
-MichaeL- | 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. | September 20, 2007, 3:04 AM |
Camel | Actually, I was trying to point out that the typedef was malformed. Either he fixed it, or I was drunk at the time. | September 20, 2007, 3:54 PM |
Kp | [quote author=brew link=topic=17029.msg172953#msg172953 date=1190254322] Blindly (not completely blindly though) adding casts usually helps. [/quote] Yes, it helps the program compile and maybe even link. It does not necessarily help the program run correctly. | September 21, 2007, 3:10 AM |
Camel | I can't think of any condition where a cast would affect linking. | September 21, 2007, 4:19 AM |
Kp | [code]/* file1 */ extern int a(int *); extern int a(float *); void b(int x) { a(&x); } [/code][code]/* file 2 */ int a(float *f) { return 0; } int main() { return 0; } [/code] [code]> g++ file1.cc file2.cc ccavkdzI.o: In function `b(int)': file1.cc:(.text+0xd): undefined reference to `a(int*)' [/code] Change to: [code]/* file 1 */ extern int a(int *); extern int a(float *); void b(int x) { a((float *) &x); } [/code][code]> g++ file1.cc file2.cc >[/code] | September 22, 2007, 4:51 AM |
Camel | Touche. I was thinking strictly in C, which does not support function overloading. | September 22, 2007, 7:03 AM |