Go Back   UnKnoWnCheaTs - Multiplayer Game Hacks and Cheats > Anti-Cheat Software & Programming > Direct3D

- Sponsored Advertisement -
http://www.myfpscheats.com/

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.    
Reply
 
Thread Tools

DrawText function in d3d
Old 08-31-2010, 01:28 PM   #1
Level 3

sentilas's Avatar

Join Date: Jul 2010
Posts: 473
Reputation: 26146
Rep Power: 289
sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!
DrawText function in d3d

Hey there,

got a small problem with drawing text in d3d.

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 Xint YD3DCOLOR Colorchar *format)
{
   
char buffer[256];
   
va_list args// deswegen: #include <cstdio>
   
va_start (argsformat);
   
vsprintf (buffer,formatargs);
   
RECT FontRect = { XY12016 };
   
g_pFont->DrawText(NULLbuffer, -1, &FontRectDT_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!!!

Thanks already !!!
sentilas is offline

Reply With Quote


Old 08-31-2010, 01:29 PM   #2
Retired Admin

learn_more's Avatar

Join Date: Sep 2006
Posts: 5,249
Reputation: 93628
Rep Power: 1106
learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (2)
sieg heil Nazi
Points: 70,490, Level: 39
Points: 70,490, Level: 39 Points: 70,490, Level: 39 Points: 70,490, Level: 39
Activity: 24.7%
Activity: 24.7% Activity: 24.7% Activity: 24.7%
Last Achievements
Award-Showcase
drawtextA

ps: if you dont use variable arguments,
dont call vsprintf
__________________
learn_more is offline

Reply With Quote

Old 08-31-2010, 01:46 PM   #3
Level 3

sentilas's Avatar

Threadstarter
Join Date: Jul 2010
Posts: 473
Reputation: 26146
Rep Power: 289
sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

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

Thanks again
sentilas is offline

Reply With Quote

Old 08-31-2010, 01:52 PM   #4
h4x0!2

thelick's Avatar

Join Date: Jul 2010
Posts: 95
Reputation: 1050
Rep Power: 31
thelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of rep
Points: 1,473, Level: 3
Points: 1,473, Level: 3 Points: 1,473, Level: 3 Points: 1,473, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
If i'm not wrong DrawText is unicode DrawTextA ansi
thelick is offline

Reply With Quote

Old 08-31-2010, 02:30 PM   #5
Retired Admin

learn_more's Avatar

Join Date: Sep 2006
Posts: 5,249
Reputation: 93628
Rep Power: 1106
learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (2)
sieg heil Nazi
Points: 70,490, Level: 39
Points: 70,490, Level: 39 Points: 70,490, Level: 39 Points: 70,490, Level: 39
Activity: 24.7%
Activity: 24.7% Activity: 24.7% Activity: 24.7%
Last Achievements
Award-Showcase
Quote:
Originally Posted by thelick View Post
If i'm not wrong DrawTextW is unicode DrawTextA ansi
fixed
sentilas, the vsprintf is if u wanna use a function like this:

DrawFont( x, y, "%s: %i", menu_name, menu_value );
__________________
learn_more is offline

Reply With Quote

Old 08-31-2010, 03:04 PM   #6
Level 3

sentilas's Avatar

Threadstarter
Join Date: Jul 2010
Posts: 473
Reputation: 26146
Rep Power: 289
sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!
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 !!!
sentilas is offline

Reply With Quote

Old 08-31-2010, 03:27 PM   #7
Retired Admin

learn_more's Avatar

Join Date: Sep 2006
Posts: 5,249
Reputation: 93628
Rep Power: 1106
learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!learn_more has a huge epeen!
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (2)
sieg heil Nazi
Points: 70,490, Level: 39
Points: 70,490, Level: 39 Points: 70,490, Level: 39 Points: 70,490, Level: 39
Activity: 24.7%
Activity: 24.7% Activity: 24.7% Activity: 24.7%
Last Achievements
Award-Showcase
Quote:
Originally Posted by sentilas View Post
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.
__________________
learn_more is offline

Reply With Quote

Old 08-31-2010, 05:45 PM   #8
h4x0!2

thelick's Avatar

Join Date: Jul 2010
Posts: 95
Reputation: 1050
Rep Power: 31
thelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of repthelick -- I am the Godfather of rep
Points: 1,473, Level: 3
Points: 1,473, Level: 3 Points: 1,473, Level: 3 Points: 1,473, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
Quote:
Originally Posted by learn_more View Post
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.
I love this guy
thelick is offline

Reply With Quote

Old 08-31-2010, 10:03 PM   #9
Level 3

sentilas's Avatar

Threadstarter
Join Date: Jul 2010
Posts: 473
Reputation: 26146
Rep Power: 289
sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!sentilas has reputation that takes up 2GB of server space!
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 ^^
sentilas is offline

Reply With Quote

Old 08-31-2010, 11:54 PM   #10
UnKnoWnCheaTeR

disavow's Avatar

Join Date: Jul 2009
Posts: 1,069
Reputation: 49844
Rep Power: 551
disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!disavow has a huge epeen!
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (2)
Points: 31,281, Level: 26
Points: 31,281, Level: 26 Points: 31,281, Level: 26 Points: 31,281, Level: 26
Activity: 14.9%
Activity: 14.9% Activity: 14.9% Activity: 14.9%
Last Achievements
Only useful imo if you want multi language support and/or oddball characters.
But yes, DrawText is just a macro for selecting DrawTextA/W functions.
__________________

Shad0w_'s Alter Ego
disavow is online now

Reply With Quote
Reply  

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit



Tags
d3d, drawtext, function
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT +1. The time now is 09:54 AM.