Welcome to the UnKnoWnCheaTs - Multiplayer Game Hacks and Cheats.
You have to register before you can post and see and access any of the advanced forum features, please click the register link to proceed to the registration form. To start viewing threads or posts, select a forum that you want to visit from the selection below.
Direct3D hacking programming reversing
You are Unregistered, please register to gain Full access.
I got the code from a tutorial, but of course it won't work that way
I have the following DrawFont Function, that i call in Endscene. I pass a string to DrawFont (called like: DrawFont (300, 50, txtgreen, "Hello World" )).
NOW, DrawText refuses to accept my "buffer" in this way, but even when i replace buffer by a simple string (e.g. i call g_pFont->DrawText(NULL, "hello", ...) it still won't accept it.
VC++ 2010 tells me that:
"argument of type "char*" is incompatible with parameter of type LPCWSTR"
Or respectivaly, arg. of type "const char*" is ....
If i lookup the defn of LPCWSTR (Windows Data Types (Windows)) then it says: "A pointer to a constant null-terminated string of 16-bit Unicode characters.". So it should accept a simple string right?
I checked many other tut's but they all use the draw Function with a const. string inside, where i get an error as well.
I also tried to cast my "buffer" directly into a LCPWSTR by using
g_pFont ->DrawText(NULL, (LCPWSTR)buffer, ...)
and it compiled, but when i injected the dll i only got some chinese characters and the game crashed! xD
PHP Code:
void DrawFont (int X, int Y, D3DCOLOR Color, char *format) { char buffer[256]; va_list args; // deswegen: #include <cstdio> va_start (args, format); vsprintf (buffer,format, args); RECT FontRect = { X, Y, X + 120, Y + 16 }; g_pFont->DrawText(NULL, buffer, -1, &FontRect, DT_NOCLIP , Color ); //Zeichnen va_end (args); }
I'm sorry im buggin you guys with such a thing, but i really dont know what could solve it and even though i searched for like 2 hours, i couldn't find any help!!!
Thank you so much learn_more!
what's even the difference between DrawText and DrawTextA? oh well nvm, i just glad it works now!
Thanks! you saved my day
about the va_list, yes i never rly understood why he used them, doesn't make a difference to me in this simple case of using DrawFont... i left it out now
mhhhh...
well DrawTextW & DrawTextA makes sense with unicode & ansi.
so i guess if i just say DrawText, then it should choose W or A, depending on which is defined.... still doesn't explain why DrawTextA accepts a string and DrawText does not, but as long as i can print im fine (maybe i'll find some docu on it ^^)
@learn_more ... i don't really get what you mean with your DrawFont func, dont really get your idea,
just looked up smth on va_lists... Seems like (more or less) a list of variables, and you won't have to define the number of arguments in your function, you can just write foo(char buffer, ... ) Well, i guess im gonna look into that maybe later? For now im just gonna try to get some kind of esp or smth
Btw, i think it was my fault, cause if i look at the tut again it says:
void DrawFont (int X, int Y, D3DCOLOR Color, char *format, ...)
so i really forgot the ... in the function, guess then the va_list stuff would make sense or?
mhhhh...
well DrawTextW & DrawTextA makes sense with unicode & ansi.
so i guess if i just say DrawText, then it should choose W or A, depending on which is defined.... still doesn't explain why DrawTextA accepts a string and DrawText does not, but as long as i can print im fine (maybe i'll find some docu on it ^^)
@learn_more ... i don't really get what you mean with your DrawFont func, dont really get your idea,
just looked up smth on va_lists... Seems like (more or less) a list of variables, and you won't have to define the number of arguments in your function, you can just write foo(char buffer, ... ) Well, i guess im gonna look into that maybe later? For now im just gonna try to get some kind of esp or smth
Btw, i think it was my fault, cause if i look at the tut again it says:
void DrawFont (int X, int Y, D3DCOLOR Color, char *format, ...)
so i really forgot the ... in the function, guess then the va_list stuff would make sense or?
Well thanks again !!!
yes, the ,... is needed for va_ stuff.
as for why it didnt accept:
in your compiler settings is unicode set,
so DrawText resolves to DrawTextW automatically.
If you would give it a unicode string (wchar_t), it will accept it.
lol i see..... i didn't even knew that there was a special "unicode" string xD
well i guess it makes sense that the normal strings are ansi... but no not really! argh
ok i did a little search:
Quote:
Unicode is an encoding standard in which all characters are two bytes long.A Unicode string is terminated by two zero bytes
Well makes sense now! Good to know that for the future! unicode & ansi strings.... I'll remember that for the next d3d stuff ^^
Thanks again learn_more, i guess theres so much more to learn from you xD ^^