Quantcast

Jump to content

» «
Photo

Directx 8 hook problem

9 replies to this topic
HackMan128
  • HackMan128

    alovelyday

  • Members
  • Joined: 09 Jul 2006
  • None
  • Best Map 2013 "ViceCityStories PC Edition"

#1

Posted 05 January 2014 - 03:27 PM Edited by HackMan128, 09 January 2014 - 11:53 PM.

Hey, can anyone help me with d3d8 hook?

I found nice mod about drawing textures in GTA Vice City

 

I think that anyone who want to create a mod with drawing textures on the screen should have it working, so here is this topic.

Years ago Squiddy created nice mod called SA HUD for Vice City based on old Spooky's speedometer.

He put source code, but unfortunately it wont work. here is fixed and working version.

 

If you compile not working version, you probably will get 0xc0000005 Access Violation error after running it with the game.

 

If you want to compile it with DirectX 8.1 SDK, you will get errors in compilation described bellow, so you should compile it with DirectX 9 SDK, which including d3dx8.

 

IDirect3DDevice8Hook.h

    STDMETHOD_(void, SetCursorPosition)(THIS_ int X,int Y,DWORD Flags);

IDirect3DDevice8Hook.cpp

void __stdcall IDirect3DDevice8Hook::SetCursorPosition(int X, int Y, DWORD Flags)
{
    pD3DDevice->SetCursorPosition(X, Y, Flags);
}

It will compile when
int types are replaces by UINT (case sensitive!)

 

//Edit

Go to the last post, I have fixed this bug. Thanks to everyone on this forum for trying to help :)

  • DonMatteuzzo likes this

HackMan128
  • HackMan128

    alovelyday

  • Members
  • Joined: 09 Jul 2006
  • None
  • Best Map 2013 "ViceCityStories PC Edition"

#2

Posted 05 January 2014 - 10:04 PM Edited by HackMan128, 05 January 2014 - 10:05 PM.

Really there are no any programmers here? I'm not doing it for myself. (Maybe I can treat is as some sort of education).

  • DonMatteuzzo likes this

NTAuthority
  • NTAuthority

    member_title

  • The Yardies
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"

#3

Posted 05 January 2014 - 11:33 PM Edited by NTAuthority, 05 January 2014 - 11:34 PM.

I'd recommend using an ASI anyway, and maybe a hooking library (EasyHook?) to generate hooks for the RwD3D8* functions; I just don't know if there's base addresses for them anywhere public, FLIRT from IDA might be able to find them if they're similar enough to the 'public' RW SDK.

 

As for this, why not look up the crash details by attaching a debugger?

  • DonMatteuzzo likes this

HackMan128
  • HackMan128

    alovelyday

  • Members
  • Joined: 09 Jul 2006
  • None
  • Best Map 2013 "ViceCityStories PC Edition"

#4

Posted 06 January 2014 - 01:01 PM Edited by HackMan128, 06 January 2014 - 01:02 PM.

People say that it's some access violation error.

Something blocks this hook to access the game?

  • DonMatteuzzo likes this

fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009

#5

Posted 06 January 2014 - 01:29 PM Edited by fastman92, 06 January 2014 - 01:30 PM.

People say that it's some access violation error.
Something blocks this hook to access the game?

0xc0000005 occurs when the executed ASM instruction attempts to read/write from address to which there are no permissions - most likely invalid memory address.
  • DonMatteuzzo likes this

HackMan128
  • HackMan128

    alovelyday

  • Members
  • Joined: 09 Jul 2006
  • None
  • Best Map 2013 "ViceCityStories PC Edition"

#6

Posted 06 January 2014 - 02:19 PM Edited by HackMan128, 06 January 2014 - 04:09 PM.

Strange because this open source code should be OK.

Anyone has tried to compile it?

  • DonMatteuzzo likes this

HackMan128
  • HackMan128

    alovelyday

  • Members
  • Joined: 09 Jul 2006
  • None
  • Best Map 2013 "ViceCityStories PC Edition"

#7

Posted 07 January 2014 - 02:33 PM Edited by HackMan128, 08 January 2014 - 03:24 PM.

Very odd.

I found DirectX 9.0 SDK, which is in Spooky's post, but here are main DirectX files (Libraries and Headers). This DX SDK contains libs and headers which current version hasn't.

 

Now the best part: Compare

Both are compiled in MS Visual Studio 6.0

 

Code from original Squiddy's Workspace file of SA HUD for Vice City:

Microsoft Developer Studio Workspace File, Format Version 6.00

Click to see differences in Exescope Resource Editor

Spoiler

The same sizes, the same Import libs, Export, only small addressing shift and mine Release output has fcking 0xC0000005 bug.

Maybe it's Regional Settings and Language, decimal character, or even processor instructions problems?

 

//EDIT:

I checked some crash dump:

Click to see LOG from ntsd

Spoiler

I'm trying to sort this out to let people create mods with drawing textures on game screen.

Unfortunately authors of "Spedoo" and "SA HUD" didn't met these problems or never documented how to solve it.

  • DonMatteuzzo likes this

NTAuthority
  • NTAuthority

    member_title

  • The Yardies
  • Joined: 09 Sep 2008
  • European-Union
  • Most Knowledgeable [Technology] 2013
    Best Map 2013 "ViceCityStories PC Edition"

#8

Posted 09 January 2014 - 06:24 PM Edited by NTAuthority, 09 January 2014 - 06:32 PM.

symbols for your d3d8.dll don't seem to be loaded, that's obviously going to be of no help :) I don't know if ntsd/other low-level debuggers use the symbol path in the module file, if they do, make sure you're compiled with /DEBUG (Linker -> Debugging) and /Zi or /ZI (C++ -> General) and try again, you should see the function name where it crashes instead of 'd3d8+0x4c51'.

 

also didn't both III and VC still support the sprite-drawing commands similar to SA, albeit slightly more limited?

  • DonMatteuzzo likes this

HackMan128
  • HackMan128

    alovelyday

  • Members
  • Joined: 09 Jul 2006
  • None
  • Best Map 2013 "ViceCityStories PC Edition"

#9

Posted 09 January 2014 - 06:53 PM Edited by HackMan128, 09 January 2014 - 11:26 PM.

I have found something with IDA. Original d3d8 hook in DllMain(x,x,x) loads d3d8.dll from system directory, but my compiled d3d8 hook loads some common.cfg. Function which load it is stored in Speedo.cpp.

Original d3d8 hook hasn't any common file name in its resources so it's weird.

Did Squiddy used a trick and packed wrong Speedo library to fool us?

 

Anyway, I made a small test of files which going with this hook like textures, so I have removed txd file and then the original hook has similar problems with loading.

 

//EDIT:

Wow, I have added file common.cfg to main Vice City folder and have different type of game crash bug, yay, now Unhandled Exception.

 

//EDIT:

It's almost working! I copied Speedo.cpp from original Speedo mod and I'm able to compile in Debug mode and I can see textures on the screen. But it still crash because there are still some bugs.

  • DonMatteuzzo likes this

HackMan128
  • HackMan128

    alovelyday

  • Members
  • Joined: 09 Jul 2006
  • None
  • Best Map 2013 "ViceCityStories PC Edition"

#10

Posted 09 January 2014 - 07:53 PM Edited by HackMan128, 30 January 2014 - 12:44 AM.

The bug is fixed

 

dwpj.png

 

And it works pretty nice.

 

What you need to get these things to work:

 

 

Here's the fixed code of Speedo.cpp which able to run SA HUD mod for Vice City.

Spoiler

 

//EDIT:

Small bonus

I have created Stories HUD (based on these samples).

 

StoriesHUD for GTA Vice City

The mod including two versions of bars and colors of LCS HUD and VCS HUD.

 

VCS version:

jlaw.png

 

  • Health bar is flashing when player has less than 20 health, armor too
  • Wanted Level Stars are flashing when wanted level is changing
  • Added sized Pluses to bars which depends to amount of health and armour
  • Added colors palette for bars, so user can easily change colors in txd file
  • Replay bug fixed, no errors anymore
  • Added camera weapon
  • HUD is hidden when game screen fading or player targets with weapon
  • fixed HUD fading
  • fixed bug with other texts on game screen
  • HD weapon icons (most) and HUD elements
  • More clear fonts

Download

  • sharpie_eastern, Silent, theNGclan and 2 others like this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users