Quantcast

Jump to content

» «
Photo

[REL|SRC] SCM and DirectX Hooking Source Code

285 replies to this topic
Cowpat
  • Cowpat

    web schmeb

  • Members
  • Joined: 12 Feb 2004

#211

Posted 18 March 2005 - 08:48 PM

CODE
int* PlayerPtr = (int*)0x7E4B8C;
.
.
float* fvalue = (float*)*PlayerPtr;
BYTE* bvalue = (BYTE*)*PlayerPtr;
...etc

Trixleh
  • Trixleh

    Player Hater

  • Members
  • Joined: 26 Feb 2005

#212

Posted 18 March 2005 - 08:52 PM

thanks cowpat biggrin.gif biggrin.gif

Trixleh
  • Trixleh

    Player Hater

  • Members
  • Joined: 26 Feb 2005

#213

Posted 18 March 2005 - 09:00 PM

CODE
float fX, fY, fZ;
float* testfY2 = (float*)*(PlayerPtr + 56);
ScriptCommand(&get_player_coords, PLAYER_CHAR, &fX, &fY, &fZ);
   sprintf((char*)&coords,"Player is at [%f, %f, %f]", fX, testfY2, fZ);


the Y Axis seems to be returning a extremely long number which is causing a buffer overflow, any ideas why it could be doing that?

Squiddy
  • Squiddy

    Back!

  • The Connection
  • Joined: 06 Oct 2004

#214

Posted 18 March 2005 - 09:15 PM

CODE
sprintf((char*)&coords,"Player is at [%f, %f, %f]", fX, [b]*[/b]testfY2, fZ);

You have to use *testfY2, to get the value from memory testfY2 is pointing to.

Cowpat
  • Cowpat

    web schmeb

  • Members
  • Joined: 12 Feb 2004

#215

Posted 18 March 2005 - 09:23 PM

CODE
ScriptCommand(&get_player_coords, PLAYER_CHAR, &fX, &fY, &fZ);

I couldn't get the above to work and quickly switched to reading the player coords by DMA. However, someone else may have better luck.

Trixleh
  • Trixleh

    Player Hater

  • Members
  • Joined: 26 Feb 2005

#216

Posted 18 March 2005 - 09:24 PM

hey, i got it working, so heres the code if anyone else wants it:

CODE

DWORD* dwPlrPointer  = (DWORD*)0x94AD28;  // VC 1.0
...
float* testfY2 = (float*)((*dwPlrPointer)+56);


then return the coordinant by *testfY2 biggrin.gif

Kryptos
  • Kryptos

    Hacker

  • Members
  • Joined: 05 Nov 2003

#217

Posted 18 March 2005 - 10:19 PM

Download the source code and start over Jacob. Make sure you include all the appropriate files, update the build settings, and it should work fine. If all else fails, reinstall MSVC++ 6.0, but first try compiling some simple console applications just to make sure it's not an internal error (your STL may be corrupt, especially if you're using a downloaded version).

And on a side note, get control of your forums, your beta tester is out of control, he's now hijacking people's posts and sporadically deleting any posts the infringe upon his position. If Linx doesn't see the apparent problem with him then perhaps you would be wise to leave; I don't see what's so important about an arrogant beta tester. If anything, visiting your forums provides a cheap laugh.

Trixleh
  • Trixleh

    Player Hater

  • Members
  • Joined: 26 Feb 2005

#218

Posted 18 March 2005 - 10:22 PM

ill have to agree there, eh, from what ive heard about lance, hes an up tight arrogent bastard.

You should really have a vote on your forums for him to stay or get the boot, anyway, this topic is going off-topic nervous.gif

The_Grudge
  • The_Grudge

    The_Grudge

  • BUSTED!
  • Joined: 08 Jan 2005

#219

Posted 18 March 2005 - 10:24 PM

QUOTE (Kryptos @ Mar 18 2005, 23:19)
Download the source code and start over Jacob. Make sure you include all the appropriate files, update the build settings, and it should work fine. If all else fails, reinstall MSVC++ 6.0, but first try compiling some simple console applications just to make sure it's not an internal error (your STL may be corrupt, especially if you're using a downloaded version).

And on a side note, get control of your forums, your beta tester is out of control, he's now hijacking people's posts and sporadically deleting any posts the infringe upon his position. If Linx doesn't see the apparent problem with him then perhaps you would be wise to leave; I don't see what's so important about an arrogant beta tester. If anything, visiting your forums provides a cheap laugh.

You mean that K4IN idiot?

Kryptos
  • Kryptos

    Hacker

  • Members
  • Joined: 05 Nov 2003

#220

Posted 18 March 2005 - 10:31 PM

I said "hijacking posts", i.e. K4IN's post was hijacked by the person I was talking about. Try to keep it on topic, no need to start varying this great resource off the beaten path.

jacob.
  • jacob.

    Homie

  • Members
  • Joined: 27 Jun 2004

#221

Posted 19 March 2005 - 04:17 AM

Seems to be a problem solved long overdue.
Lance is now banned from www.gtasyncd.co.uk/* and removed from the roster.

I reinstalled the dx sdk and for some reason it worked. Hell if I know why, ReplaceTerm doesn't sound anything related to directx, but thanks for the help anyway.

DexX
  • DexX

    Black Hat

  • Feroci Racing
  • Joined: 16 May 2002

#222

Posted 13 April 2005 - 07:48 AM

/* i didnt *want* to bump this, but i recently re-aquired the DX9 sdk (summer 2005), and the speedo code, and for the life of me, i can NOT get this to compile;

Error message:
[code=auto:0]fatal error C1083: Cannot open include file: 'd3dx8.h': No such file or directory[/quote]
I looked through the first few pages here, and nothing seemed to solve this problem for me (ive tried every solution posted in the first few pages). Also of note, neither d3dx8.h or d3dx8.lib are actually present in my directx sdk. i tried pointing it to the d3dx9.lib/h, but that produced the same error message as above. my brain is dead and i need sleep.

help!!

oh yea, i'm using ms visual studio c++ 6.0 if it makes a difference.
sleepy.gif */

DominionSpy
  • DominionSpy

    Man with a plan!

  • Members
  • Joined: 13 Feb 2004

#223

Posted 13 April 2005 - 09:21 AM

QUOTE (ashdexx @ Apr 13 2005, 07:48)
/* i didnt *want* to bump this, but i recently re-aquired the DX9 sdk (summer 2005), and the speedo code, and for the life of me, i can NOT get this to compile;

Error message:
CODE
fatal error C1083: Cannot open include file: 'd3dx8.h': No such file or directory

I looked through the first few pages here, and nothing seemed to solve this problem for me (ive tried every solution posted in the first few pages). Also of note, neither d3dx8.h or d3dx8.lib are actually present in my directx sdk. i tried pointing it to the d3dx9.lib/h, but that produced the same error message as above. my brain is dead and i need sleep.

help!!

oh yea, i'm using ms visual studio c++ 6.0 if it makes a difference.
sleepy.gif */

First, make sure you have the latest SDK update (DirectX 9.0 SDK Update - (April 2005)).

If you install that, you should have a folder in your program files with the same name and the dxd8 files should be included with that.

DexX
  • DexX

    Black Hat

  • Feroci Racing
  • Joined: 16 May 2002

#224

Posted 13 April 2005 - 05:49 PM Edited by ashdexx, 13 April 2005 - 06:12 PM.

/* yea, i have the 2005 one. But there is no dx8-specific folder. All the dx8 files i have, are in the same folder as the dx9 files (include and lib). And there are no d3dx8 files at all. */

NM, i figured it out;
QUOTE (Program Files\Microsoft DirectX 9.0 SDK (February 2005)\dxreadme.htm)
Other

      D3DX for DirectX8 was removed from the SDK in December. This was not mentioned in the release notes for the December SDK.


So what do i do now? revert to an old sdk (which i dont have atm), or try to use d3d9? if i use d3d9, what changes do i need to make to the code?

Spooky
  • Spooky

    Prince of the Yolkfolk

  • Members
  • Joined: 13 Jan 2002

#225

Posted 14 April 2005 - 03:44 AM

QUOTE (ashdexx @ Apr 13 2005, 18:49)
So what do i do now? revert to an old sdk (which i dont have atm), or try to use d3d9? if i use d3d9, what changes do i need to make to the code?

You can't use Direct3D 9 code because we're working with an already compiled Direct3D 8 game. Using an older SDK version is your only option afaik sad.gif.

jacob.
  • jacob.

    Homie

  • Members
  • Joined: 27 Jun 2004

#226

Posted 14 April 2005 - 04:55 AM

I thought you couldn't install a lower version of DirectX over a higher one? Oh well, its just an sdk, might still work.

Cowpat
  • Cowpat

    web schmeb

  • Members
  • Joined: 12 Feb 2004

#227

Posted 15 April 2005 - 11:14 PM


I've got the dx 9.0c (Summer release, 2004) SDK installed and it works just fine with both GTAIII and Vice City. Compiling with MSVC++ 6.0

Hammer83
  • Hammer83

    Hustler

  • Members
  • Joined: 11 Jan 2003

#228

Posted 16 April 2005 - 01:40 AM

QUOTE (Cowpat @ Apr 15 2005, 18:14)
I've got the dx 9.0c (Summer release, 2004) SDK installed and it works just fine with both GTAIII and Vice City. Compiling with MSVC++ 6.0

MS moved all D3DX into a dll starting from February 2005.

jacob.
  • jacob.

    Homie

  • Members
  • Joined: 27 Jun 2004

#229

Posted 01 May 2005 - 10:34 AM Edited by !cMc! Jacob, 01 May 2005 - 11:05 AM.

Hey.. I'm trying to draw this triangle here, but it seems to be screwing up the sky or something.
I'm using this code:


CODE

custominitialize {
..
..
VOID* pVertices;
   
   //Store each point of the triangle together with it's colour
   CUSTOMVERTEX cvVertices[] =
   {
       {250.0f, 100.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 1 - Red (250, 100)
       {400.0f, 350.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0),}, //Vertex 2 - Green (400, 350)
       {100.0f, 350.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255),}, //Vertex 3 - Blue (100, 350)
   };

   //Create the vertex buffer from our device
pDevice->CreateVertexBuffer(3 * sizeof(CUSTOMVERTEX),
                                              0, D3DFVF_CUSTOMVERTEX,
                                              D3DPOOL_DEFAULT, &g_pVertexBuffer);
   


   //Get a pointer to the vertex buffer vertices and lock the vertex buffer
   g_pVertexBuffer->Lock(0, sizeof(cvVertices), (BYTE**)&pVertices, 0);


   //Copy our stored vertices values into the vertex buffer
   memcpy(pVertices, cvVertices, sizeof(cvVertices));

   //Unlock the vertex buffer
   g_pVertexBuffer->Unlock();
..
..
}


CODE
customrender {
..
..
pDevice->SetStreamSource(0, g_pVertexBuffer, sizeof(CUSTOMVERTEX));
   pDevice->SetVertexShader(D3DFVF_CUSTOMVERTEX);
   pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
..
..
}


user posted image

The sky just doesnt seem to 'update'. It repeats itself when I move and stuff, its hard to explain. Its almost like the sky buffer is getting paused or something. The tutorial I got it from instructs me to do this:

QUOTE (tutorial)
//Clear the backbuffer to black
    g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
   
    //Begin the scene
    g_pD3DDevice->BeginScene();
   

    //Rendering our triangle
    g_pD3DDevice->SetStreamSource(0, g_pVertexBuffer, sizeof(CUSTOMVERTEX));
    g_pD3DDevice->SetVertexShader(D3DFVF_CUSTOMVERTEX);
    g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);


    //End the scene
    g_pD3DDevice->EndScene();
   
    //Filp the back and front buffers so that whatever has been rendered on the back buffer
    //will now be visible on screen (front buffer).
    g_pD3DDevice->Present(NULL, NULL, NULL, NULL);

But obviously I'm not going to Clear the device, and I'm not going to Present it either, because doesnt GTA do that stuff for me?
I'm stuck.


EDIT] I also tried hooking the BeginScene and placing the code in there but all that did was made the triangle non-transparent, the sky was still screwing up.

dontgetit.gif

Squiddy
  • Squiddy

    Back!

  • The Connection
  • Joined: 06 Oct 2004

#230

Posted 01 May 2005 - 12:06 PM

I tried this too and ended with something like you did. You have to set some render states to draw polygons, because we are drawing right after vc finished drawing the hud etc.
There are 2 things you have to do: First one is saving the current renderstates you're going to change to reset them when you finished, second point is actually setting your states to draw.

That's how spookie made it:
CODE
DWORD m_pMenuStateBlock;
DWORD m_pCurrentStateBlock;

[...]

// If the Menu State Block isn't created, create it.
if (!m_pMenuStateBlock)
{
 pD3DDevice8->BeginStateBlock();
 pD3DDevice8->SetRenderState(D3DRS_LIGHTING, FALSE);
 pD3DDevice8->SetRenderState(D3DRS_FOGENABLE, FALSE);
 pD3DDevice8->SetRenderState(D3DRS_ZENABLE, 0);
 pD3DDevice8->SetRenderState(D3DRS_FILLMODE, 3);
 pD3DDevice8->SetRenderState(D3DRS_CULLMODE, 1);
 pD3DDevice8->SetRenderState(D3DRS_WRAP0, 0);
 pD3DDevice8->SetRenderState(D3DRS_CLIPPING, 1);
 pD3DDevice8->SetRenderState(D3DRS_VERTEXBLEND, 0);
 pD3DDevice8->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
 pD3DDevice8->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, 0);
 pD3DDevice8->SetRenderState(D3DRS_COLORWRITEENABLE, 15);
 pD3DDevice8->SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
 pD3DDevice8->SetRenderState(D3DRS_SRCBLEND, 5);
 pD3DDevice8->SetRenderState(D3DRS_DESTBLEND, 6);
 pD3DDevice8->SetRenderState(D3DRS_BLENDOP, 1);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_COLOROP, 4);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_COLORARG1, 2);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_COLORARG2, 0);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_ALPHAOP, 4);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
 pD3DDevice8->SetTextureStageState(1, D3DTSS_COLOROP, 1);
 pD3DDevice8->SetTextureStageState(1, D3DTSS_ALPHAOP, 1);
 pD3DDevice8->SetVertexShader(D3DFVF_XYZRHW|D3DFVF_TEX1);
 pD3DDevice8->SetStreamSource(0, NULL, 0);
 pD3DDevice8->SetTexture(0, m_pMenuTexture);
 pD3DDevice8->EndStateBlock(&m_pMenuStateBlock);
}

// If the Current State Block isn't created, create it.
if (!m_pCurrentStateBlock)
{
 pD3DDevice8->BeginStateBlock();
 pD3DDevice8->SetRenderState(D3DRS_LIGHTING, FALSE);
 pD3DDevice8->SetRenderState(D3DRS_FOGENABLE, FALSE);
 pD3DDevice8->SetRenderState(D3DRS_ZENABLE, 0);
 pD3DDevice8->SetRenderState(D3DRS_FILLMODE, 3);
 pD3DDevice8->SetRenderState(D3DRS_CULLMODE, 1);
 pD3DDevice8->SetRenderState(D3DRS_WRAP0, 0);
 pD3DDevice8->SetRenderState(D3DRS_CLIPPING, 1);
 pD3DDevice8->SetRenderState(D3DRS_VERTEXBLEND, 0);
 pD3DDevice8->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
 pD3DDevice8->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, 0);
 pD3DDevice8->SetRenderState(D3DRS_COLORWRITEENABLE, 15);
 pD3DDevice8->SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
 pD3DDevice8->SetRenderState(D3DRS_SRCBLEND, 5);
 pD3DDevice8->SetRenderState(D3DRS_DESTBLEND, 6);
 pD3DDevice8->SetRenderState(D3DRS_BLENDOP, 1);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_COLOROP, 4);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_COLORARG1, 2);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_COLORARG2, 0);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_ALPHAOP, 4);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
 pD3DDevice8->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
 pD3DDevice8->SetTextureStageState(1, D3DTSS_COLOROP, 1);
 pD3DDevice8->SetTextureStageState(1, D3DTSS_ALPHAOP, 1);
 pD3DDevice8->SetVertexShader(D3DFVF_XYZRHW|D3DFVF_TEX1);
 pD3DDevice8->SetStreamSource(0, NULL, 0);
 pD3DDevice8->SetTexture(0, m_pMenuTexture);
 pD3DDevice8->EndStateBlock(&m_pCurrentStateBlock);
}


You have to adjust some things as spookie used texture mapped triangles, but that's the way it should work.
The rendering should look like this:

CODE
pD3DDevice8->CaptureStateBlock(m_pCurrentStateBlock);
pD3DDevice8->ApplyStateBlock(m_pMenuStateBlock);


We need to know the renderstates that are currently set so we can reset them after we finished our stuff. CaptureStateBlock fills all renderstates set in our block with those values in the device, see it as a backup. After that we set our renderstates, ApplyStateBlock.
Now just do whatever you want to do.

After you finished we reset those renderstates by applying our 'backup'.
CODE
pD3DDevice8->ApplyStateBlock(m_pCurrentStateBlock);


It worked for me some time ago, so feel free to ask, hope I can help. smile.gif

jacob.
  • jacob.

    Homie

  • Members
  • Joined: 27 Jun 2004

#231

Posted 01 May 2005 - 12:25 PM

That worked perfect! You are a genius, thanks a lot.

Sobeit
  • Sobeit

    mta ninja

  • BUSTED!
  • Joined: 11 May 2004

#232

Posted 07 May 2005 - 05:36 AM

Squiddy : SA hud link is down.

Squiddy
  • Squiddy

    Back!

  • The Connection
  • Joined: 06 Oct 2004

#233

Posted 07 May 2005 - 09:27 AM Edited by Squiddy, 08 May 2005 - 10:02 AM.

I think a PM would have suffit, but anyways thanks for mentioning it. I'll upload them to my actual webspace and update the links. smile.gif

Edit
Here you go: http://squiddy.marway.org/gta/files/

Update:
SA Hud Source
Didn't know you were talking about the source, sorry.

Sobeit
  • Sobeit

    mta ninja

  • BUSTED!
  • Joined: 11 May 2004

#234

Posted 07 May 2005 - 11:06 PM Edited by Sobeit, 07 May 2005 - 11:11 PM.

and thank you for posting it back up wink.gif

now, this is a silly question, but...

is there any chance i can use this with Dev C++?

(any suggestions welcome)

EDIT: Squiddy, i might be wrong but i thought ur last post was of the SA HUD SRC?

if i am, ok, if im not, the src is not included in that folder

jacob.
  • jacob.

    Homie

  • Members
  • Joined: 27 Jun 2004

#235

Posted 08 May 2005 - 10:01 PM

user posted image

Excuse the language - here I am with another problem. I'm giving a shot at 3D Sprites, specifically for my player tags/healthbars/etc, and for some whatever reason - VC is drawing bizarre letters on it. I am drawing no texture on it, it is formatted with the color 0xFF000000 (ARGB). When I move around these letters are stretched in all kinds of weird directions. I have no idea where they are coming from. My game is posessed. dontgetit.gif

Cowpat
  • Cowpat

    web schmeb

  • Members
  • Joined: 12 Feb 2004

#236

Posted 08 May 2005 - 10:44 PM

QUOTE (Sobeit @ May 7 2005, 23:06)
is there any chance i can use this with Dev C++?

You can download the directX header files as a package for DevC++. They're on the DevC++ site if I remember correctly. I'll bet they are a bitch to get working though.

illspirit
  • illspirit

    lycanthroplasty

  • Moderator
  • Joined: 01 May 1976
  • None

#237

Posted 09 May 2005 - 01:15 AM

QUOTE (!cMc! Jacob @ May 8 2005, 18:01)
http://img.photobucket.com/albums/v683/cmcjacob/oddglitch.gif

Excuse the language - here I am with another problem. I'm giving a shot at 3D Sprites, specifically for my player tags/healthbars/etc, and for some whatever reason - VC is drawing bizarre letters on it. I am drawing no texture on it, it is formatted with the color 0xFF000000 (ARGB). When I move around these letters are stretched in all kinds of weird directions. I have no idea where they are coming from. My game is posessed. dontgetit.gif

I'm no programmer, but it looks to me like like your sprite is conflicting/sharing the memory location and/or Zbuffer layer of the regular HUD, thereby inheriting the font texture. The stretching of the letters might then be caused by a lack of UV coord's on the triangles.

jacob.
  • jacob.

    Homie

  • Members
  • Joined: 27 Jun 2004

#238

Posted 09 May 2005 - 02:35 AM

QUOTE (illspirit @ May 9 2005, 01:15)
QUOTE (!cMc! Jacob @ May 8 2005, 18:01)
http://img.photobucket.com/albums/v683/cmcjacob/oddglitch.gif

Excuse the language - here I am with another problem. I'm giving a shot at 3D Sprites, specifically for my player tags/healthbars/etc, and for some whatever reason - VC is drawing bizarre letters on it. I am drawing no texture on it, it is formatted with the color 0xFF000000 (ARGB). When I move around these letters are stretched in all kinds of weird directions. I have no idea where they are coming from. My game is posessed.  dontgetit.gif

I'm no programmer, but it looks to me like like your sprite is conflicting/sharing the memory location and/or Zbuffer layer of the regular HUD, thereby inheriting the font texture. The stretching of the letters might then be caused by a lack of UV coord's on the triangles.

That's probably the problem, but I have no idea on how to prevent such things from happening.
Here's a little 500kb WMV demonstration of this sprite's odd behaviour: http://download.gtas...ob/messedup.rar

steve-m
  • steve-m

  • Members
  • Joined: 26 Jul 2002

#239

Posted 09 May 2005 - 09:44 AM

D3D is a state machine. Everything that was set by the game is still present when you render your stuff. I assume the last thing the game renders is the hud, so the font texture is still set. You'd have to disable it, or set your own one. Same goes for colors, UVs, normals, ...
But if you are already using the code Squiddy posted, those things should theoretically be dealt with, unless something is missing...

Sobeit
  • Sobeit

    mta ninja

  • BUSTED!
  • Joined: 11 May 2004

#240

Posted 10 May 2005 - 03:22 PM

thanks squiddy,, now i can get started....as soon as i reinstall GTA, damned mods messed up my game, and crashes...




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users