Home > other >  To solve the Dx drawing black problem
To solve the Dx drawing black problem

Time:09-22

My situation is: inject a dx program hook to draw a shape in the upper left corner here Present online pulled a demo found that the color is black unanswered for a long time

The code is as follows:
 
Struct CUSTOMVERTEX
{
FLOAT x, y, z, RHW;
DWORD color;
};

# define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW | D3DFVF_DIFFUSE)//FVF flexible vertex format

LPDIRECT3DVERTEXBUFFER9 g_pVertexBuffer=NULL;

Void DrawRandom (LPDIRECT3DDEVICE9 pD3dDevice)
{
if (! G_pVertexBuffer)
{
PD3dDevice - & gt; CreateVertexBuffer (6 * sizeof (CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, & amp; G_pVertexBuffer, NULL);
}

PVOID pVertices=NULL;
CUSTOMVERTEX are []=
{
//use the rand function, give a vertex with random color and position of
F {300.0, 100.0 f, f 0.0, 1.0, f D3DCOLOR_XRGB (rand () %, 256 rand () % 256, 256 rand () %),},
F {500.0, 100.0 f, f 0.0, 1.0, f D3DCOLOR_XRGB (rand () %, 256 rand () % 256, 256 rand () %),},
F {300.0, 300.0 f, f 0.0, 1.0, f D3DCOLOR_XRGB (rand () %, 256 rand () % 256, 256 rand () %),},
F {300.0, 300.0 f, f 0.0, 1.0, f D3DCOLOR_XRGB (rand () %, 256 rand () % 256, 256 rand () %),},
{(float) (800.0 * rand ()/(1.0) RAND_MAX +), (float) (600.0 * rand ()/(1.0) RAND_MAX +), 0.0 f, 1.0 f, D3DCOLOR_XRGB (rand () %, 256 rand () % 256, 256 rand () %),},
{(float) (800.0 * rand ()/(1.0) RAND_MAX +), (float) (600.0 * rand ()/(1.0) RAND_MAX +), 0.0 f, 1.0 f, D3DCOLOR_XRGB (rand () %, 256 rand () % 256, 256 rand () %),}
};

G_pVertexBuffer - & gt; The Lock (0, sizeof (are) (void * *) & amp; PVertices, 0);
Memcpy (pVertices, are drawn, sizeof (are));
G_pVertexBuffer - & gt; Unlock ();

PD3dDevice - & gt; BeginScene ();

PD3dDevice - & gt; G_pVertexBuffer SetStreamSource (0, 0, sizeof (CUSTOMVERTEX));
PD3dDevice - & gt; SetFVF (D3DFVF_CUSTOMVERTEX);
PD3dDevice - & gt; DrawPrimitive (D3DPT_TRIANGLELIST, 0, 2);

PD3dDevice - & gt; EndScene ();
}

Actually received is not random but black color but when I click on the part of the program what color will become normal

Ps: the source is in shallow ink color is the result of my teacher blog down can't normal... Very depressed...

CodePudding user response:

Here said the two triangles are normal just draw the color has been the only black in color when rendering something TargetDx program will be normal...

This is because after injection test on ret several function so the background is black triangle drew has been nothing but black:


This is something TargetDx procedures apply colours to a drawing of a triangle:


Ps: don't be entangled with the number of triangles just when I was in reverse object dx program directly ret some functions... But however there is no use
  • Related