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

Fill rectangle/ primitive drawing
Old 08-22-2010, 11:40 AM   #1
Senior Member

Kosaki's Avatar

Join Date: Aug 2009
Posts: 89
Reputation: 2974
Rep Power: 60
Kosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating community
Disc Dash Champion
Points: 3,422, Level: 5
Points: 3,422, Level: 5 Points: 3,422, Level: 5 Points: 3,422, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
Fill rectangle/ primitive drawing

I am currently working on creating a personal graphics toolkit for the major d3d versions. The purpose is to use this toolkit to make my hack graphics to easily adapt to every game and every graphics settings in game.

I am currently working on the d3d9 implementation and I am optimizing it.
The problem is my fill rectangle function which is now based on primitives instead D3DXLine or textures.

I am testing my toolkit in BF 2142 (because it is so easy to unban yourself if you fuck up)

The problem is really really weird. It only draws the solid rectangle when the game is "thinking". It draws it in the time between you click login and until you get the "Your soldiers" list. But when running normal it does not draw.

Here is a few screens of the problem. (The sprite and outlined rectangle are just there for testing that other stuff worked)

Not working at this state:


Working at this state:


The code I use for the FillRect

PHP Code:
HRESULT GFXToolkit9::FillRectfloat xfloat yfloat widthfloat heightDWORD color )
{
    
RHWVERTEX vertices[4];
    
vertices[0].x;
    
vertices[0].y;
    
vertices[0].0.0f;
    
vertices[0].rhw 1.0f;
    
vertices[0].color color;

    
vertices[1].x+width;
    
vertices[1].y;
    
vertices[1].0.0f;
    
vertices[1].rhw 1.0f;
    
vertices[1].color color;

    
vertices[2].x;
    
vertices[2].y+height;
    
vertices[2].0.0f;
    
vertices[2].rhw 1.0f;
    
vertices[2].color color;

    
vertices[3].x+width;
    
vertices[3].y+height;
    
vertices[3].0.0f;
    
vertices[3].rhw 1.0f;
    
vertices[3].color color;

    if(!
m_pRectVertexBuffer)
        return 
E_FAIL;

    
void pData NULL;
    if(
FAILED(m_pRectVertexBuffer->Lock(0sizeof(vertices), &pData0)))
    {
        return 
E_FAIL;
    }

    
memcpy(pDataverticessizeof(vertices));
    
m_pRectVertexBuffer->Unlock();

    
LPDIRECT3DVERTEXBUFFER9 oldBuffer NULL;
    
UINT oldOffset 0;
    
UINT oldStride 0;
    
m_pDevice->GetStreamSource(0, &oldBuffer, &oldOffset, &oldStride);
    
DWORD oldFVF 0;
    
m_pDevice->GetFVF(&oldFVF);

    
m_pDevice->SetStreamSource(0m_pRectVertexBuffer0sizeof(RHWVERTEX));
    
m_pDevice->SetFVF(RHWVERTEX_FORMAT);

    
m_pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP02);

    
m_pDevice->SetStreamSource(0oldBufferoldOffsetoldStride);
    
m_pDevice->SetFVF(oldFVF);
    return 
S_OK;

Any ideas what causes this and how I would go about making it work all the time?

Thanks in advance

PS:
If you use this fillrect method in your project give Roverturbo some credits. I peeked at his GradientBox method to save some time.

[Auto Merged - 19:21:40 Europe/Moscow]

Edit:

Managed to get it working with playing with the texture states.
Here is a working function for reference

Code:
HRESULT GFXToolkit9::FillRect( float x, float y, float width, float height, DWORD color )
{

	SetTextureStatesFor(TextureStateTemplate::BASIC_COLOR);

	RHWVERTEX vertices[4];
	vertices[0].x = x;
	vertices[0].y = y;
	vertices[0].z = 0.0f;
	vertices[0].rhw = 1.0f;
	vertices[0].color = color;

	vertices[1].x = x+width;
	vertices[1].y = y;
	vertices[1].z = 0.0f;
	vertices[1].rhw = 1.0f;
	vertices[1].color = color;

	vertices[2].x = x;
	vertices[2].y = y+height;
	vertices[2].z = 0.0f;
	vertices[2].rhw = 1.0f;
	vertices[2].color = color;

	vertices[3].x = x+width;
	vertices[3].y = y+height;
	vertices[3].z = 0.0f;
	vertices[3].rhw = 1.0f;
	vertices[3].color = color;

	if(!m_pRectVertexBuffer)
		return E_FAIL;

	void * pData = NULL;
	if(FAILED(m_pRectVertexBuffer->Lock(0, sizeof(vertices), &pData, 0)))
	{
		return E_FAIL;
	}

	memcpy(pData, vertices, sizeof(vertices));
	m_pRectVertexBuffer->Unlock();


	LPDIRECT3DVERTEXBUFFER9 oldBuffer = NULL;
	UINT oldOffset = 0;
	UINT oldStride = 0;
	m_pDevice->GetStreamSource(0, &oldBuffer, &oldOffset, &oldStride);
	DWORD oldFVF = 0;
	m_pDevice->GetFVF(&oldFVF);

	m_pDevice->SetStreamSource(0, m_pRectVertexBuffer, 0, sizeof(RHWVERTEX));
	m_pDevice->SetFVF(RHWVERTEX_FORMAT);

	m_pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

	m_pDevice->SetStreamSource(0, oldBuffer, oldOffset, oldStride);
	m_pDevice->SetFVF(oldFVF);

	SetTextureStatesFor(TextureStateTemplate::NORMAL);
	return S_OK;
}

void GFXToolkit9::SetTextureStatesFor(TextureStateTemplate templ)
{
	if(templ == BASIC_COLOR)
	{
		m_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
		m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
		m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
		m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
	}
	else if(templ == NORMAL)
	{
		m_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, m_gameTextureStates[D3DTSS_COLOROP]);
		m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, m_gameTextureStates[D3DTSS_COLORARG1]);
		m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, m_gameTextureStates[D3DTSS_ALPHAOP]);
		m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, m_gameTextureStates[D3DTSS_ALPHAARG1]);
	}

}
Edit the original values are gathered in my Begin() function like this
Code:
DWORD state = 0;
	m_pDevice->GetTextureStageState(0, D3DTSS_COLOROP, &state);
	m_gameTextureStates[D3DTSS_COLOROP] = state;
	m_pDevice->GetTextureStageState(0, D3DTSS_COLORARG1, &state);
	m_gameTextureStates[D3DTSS_COLORARG1] = state;
	m_pDevice->GetTextureStageState(0, D3DTSS_ALPHAOP, &state);
	m_gameTextureStates[D3DTSS_ALPHAOP] = state;
	m_pDevice->GetTextureStageState(0, D3DTSS_ALPHAARG1, &state);
	m_gameTextureStates[D3DTSS_ALPHAARG1] = state;

Last edited by Kosaki; 08-22-2010 at 04:29 PM.
Kosaki is offline

Reply With Quote


Old 08-22-2010, 05:51 PM   #2
A God

Tatez's Avatar

Join Date: Nov 2009
Location: NC
Posts: 195
Reputation: 3189
Rep Power: 62
Tatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating community
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (1)
When are you drawing? EndScene, BeginScene, or DIP? Make sure you're drawing in EndScene.
Tatez is offline

Reply With Quote

Old 08-22-2010, 07:34 PM   #3
Senior Member

Kosaki's Avatar

Threadstarter
Join Date: Aug 2009
Posts: 89
Reputation: 2974
Rep Power: 60
Kosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating communityKosaki is a legend in the cheating community
Disc Dash Champion
Points: 3,422, Level: 5
Points: 3,422, Level: 5 Points: 3,422, Level: 5 Points: 3,422, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Last Achievements
I am drawing in EndScene I have also resolved the problem.

It is caused by the texture state of the game.
When the game is "bussy" it fills the screen with a semi transparent grey color. Then it has already changed the texture state flags back. However in when the game is not "bussy" the last thing it drew was a textured primitive. Thus I have to change the texture state myself
Kosaki is offline

Reply With Quote

Old 08-23-2010, 08:03 AM   #4
Donator

raiders's Avatar

Join Date: Nov 2007
Posts: 1,494
Reputation: 72055
Rep Power: 802
raiders has a huge epeen!raiders has a huge epeen!raiders has a huge epeen!raiders has a huge epeen!raiders has a huge epeen!raiders has a huge epeen!raiders has a huge epeen!raiders has a huge epeen!raiders has a huge epeen!raiders has a huge epeen!raiders has a huge epeen!
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (5)
The UC Member of the Month award is a prestigious award given to a single community member on a monthly basis. Based on a vote by UnKnoWnCheaTs staff, the award is given to the forum member that has shown exemplary achievement and potential in the UnKnoWnCheaTs community, and has shown great commitment to upholding the principles upon which UnKnoWnCheaTs stands for. A member who has been awarded the Member of the Month award has been distinguished as an asset to the UnKnoWnCheaTs community. Member of the Month
Points: 44,627, Level: 32
Points: 44,627, Level: 32 Points: 44,627, Level: 32 Points: 44,627, Level: 32
Activity: 20.0%
Activity: 20.0% Activity: 20.0% Activity: 20.0%
Last Achievements
Quote:
Originally Posted by Tatez View Post
When are you drawing? EndScene, BeginScene, or DIP? Make sure you're drawing in EndScene.
um...

__________________
[22:22] monster64: yo dawg i heard u like chams so i put chams in your chams so you can see through shit while you see through shit

[09:07] Tally: grab your ak47 and put on your bomb jacket.... its gonna be a long morning

09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
raiders is offline

Reply With Quote

Old 08-23-2010, 09:49 PM   #5
A God

Tatez's Avatar

Join Date: Nov 2009
Location: NC
Posts: 195
Reputation: 3189
Rep Power: 62
Tatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating communityTatez is a legend in the cheating community
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (1)
Quote:
Originally Posted by raiders View Post
um...

Believe it or not some people don't know to draw in EndScene, and they copy and paste their shit into DIP.
Tatez is offline

Reply With Quote

Old 08-25-2010, 04:10 AM   #6
Donator

Kozmo's Avatar

Join Date: Sep 2007
Posts: 718
Reputation: 26481
Rep Power: 332
Kozmo has reputation that takes up 2GB of server space!Kozmo has reputation that takes up 2GB of server space!Kozmo has reputation that takes up 2GB of server space!Kozmo has reputation that takes up 2GB of server space!Kozmo has reputation that takes up 2GB of server space!Kozmo has reputation that takes up 2GB of server space!Kozmo has reputation that takes up 2GB of server space!Kozmo has reputation that takes up 2GB of server space!Kozmo has reputation that takes up 2GB of server space!Kozmo has reputation that takes up 2GB of server space!Kozmo has reputation that takes up 2GB of server space!
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (2)
Points: 20,308, Level: 19
Points: 20,308, Level: 19 Points: 20,308, Level: 19 Points: 20,308, Level: 19
Activity: 6.6%
Activity: 6.6% Activity: 6.6% Activity: 6.6%
Last Achievements
EDIT*** I got it working...Forgot to set the texture to null.


I am trying this on Bad Company 2... I can Draw my Box fine (using
D3DPT_LINELIST as I dont want it filled in)

However I can not get my lines colored at all. I am guessing the game is clobbering - and I need to set the renderstates.

I tried your TextureStateTemplate::BASIC_COLOR and it didnt help.

I define my Vertex struct:

#define D3DFVF_MYVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)

struct RHWVERTEX
{
float x, y, z, rhw;
DWORD color;
};



Anyone had this issue? or offer some advice?
__________________
KozmoK

Last edited by Kozmo; 08-25-2010 at 06:48 AM.
Kozmo is online now

Reply With Quote

Old 08-25-2010, 06:51 AM   #7
Donator

sgtmattbaker's Avatar

Join Date: Jan 2008
Posts: 249
Reputation: 7516
Rep Power: 129
sgtmattbaker DEFINES UNKNOWNCHEATSsgtmattbaker DEFINES UNKNOWNCHEATSsgtmattbaker DEFINES UNKNOWNCHEATSsgtmattbaker DEFINES UNKNOWNCHEATSsgtmattbaker DEFINES UNKNOWNCHEATSsgtmattbaker DEFINES UNKNOWNCHEATSsgtmattbaker DEFINES UNKNOWNCHEATSsgtmattbaker DEFINES UNKNOWNCHEATSsgtmattbaker DEFINES UNKNOWNCHEATSsgtmattbaker DEFINES UNKNOWNCHEATSsgtmattbaker DEFINES UNKNOWNCHEATS
Recognitions:
Members who have contributed financial support towards UnKnoWnCheaTs. Donation (1)
Points: 7,745, Level: 10
Points: 7,745, Level: 10 Points: 7,745, Level: 10 Points: 7,745, Level: 10
Activity: 18.8%
Activity: 18.8% Activity: 18.8% Activity: 18.8%
Last Achievements
DrawPrimitiveUp doesn't show ingame?
Maybe that could help.
sgtmattbaker 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
drawing, primitive, rectangle or
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 04:26 PM.