IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
Forum Rules GTA Modification Forums

This section is for obtaining help on creating and releasing tools

GTAGarage.com
free mod hosting from GTANet, simply login with your GTAForums account details

GTAModding.com
GTANet's modding wiki

GTA Modding Chatroom
provided by irc.gtanet.com (Don't have an IRC client? Click here)


Pages: (3) [1] 2 3   ( Go to first unread post ) Reply to this topicStart new topicStart Poll

 [REL|SA] Spooky-style SCM Hook

 
JGuntherS@NL  
Posted: Wednesday, Nov 14 2007, 17:58
Quote Post


Being a being
Group Icon
Group: Members
Joined: Nov 15, 2005

nl.gif

XXXXX



I have created an SCM hook for GTA: San Andreas that works like Spooky's SCM hook for VC, with script classes and such. However, it runs next to the original SCM so the original missions will still be available. It is based on my SA Injector, so it has full CRT functionality. It also has an GXT hook for custom text entries. A lot of code is just robbed from either op9080's SA SCM hook, spooky's VC SCM Hook and my own injector, credits to them!

I think it is quite self-explanatory, just look at CustomScript.cpp and CustomGXT.h

If you're having trouble with hash_map, change #define USE_HASH_MAP in commonincs.h into #define USE_HASH_MAP_IN_STDEXT, or if that doesn't work, just delete that line. Performance will drop sligthly in that case.

Download link (current version: v3): http://www.pawfectfilms.com/mods/SA_Injector3.zip

Changelog:

v1: initial version

v2: added an op9080-hook-like script class

v3: added support for using -1 instead of actor variable, fixed some issues in opcodes.h

This post has been edited by Dutchy3010 on Wednesday, Aug 26 2009, 09:05
PMMSN
  Top
 

 
Seemann  
Posted: Thursday, Nov 15 2007, 11:17
Quote Post


Ruhe
Group Icon
Group: Members
Joined: Sep 3, 2004

ru.gif

Member Award




Does it require the DirectX SDK to be compiled? If so, for what?
Users WebsitePM
  Top
 

 
JGuntherS@NL  
Posted: Thursday, Nov 15 2007, 16:10
Quote Post


Being a being
Group Icon
Group: Members
Joined: Nov 15, 2005

nl.gif

XXXXX



QUOTE (Seemann @ Nov 15 2007, 11:17)
Does it require the DirectX SDK to be compiled? If so, for what?

Nope, it doesn't need the DX SDK smile.gif.
PMMSN
  Top
 

 
ceedj  
Posted: Thursday, Nov 15 2007, 16:45
Quote Post


PEDS Creator
Group Icon
Group: Members
Joined: May 21, 2005

us.gif

Member Award




This is truly "All that." Seriously.

CRT stuff, multiple threads, GXT goodies ,existing SCM untouched. Egads, it's almost too good to be true. happy.gif I'll provide my updated Opcodes.h here for those that use this hook.

Great job, JGuntherS@NL!!!
Users WebsitePM
  Top
 

 
aad  
Posted: Thursday, Nov 15 2007, 19:01
Quote Post


3d artist
Group Icon
Group: Members
Joined: Mar 15, 2004

nl.gif

Member Award




QUOTE (JGuntherS@NL @ Nov 14 2007, 17:58)
I have created an SCM hook for GTA: San Andreas that works like Spooky's SCM hook for VC, with script classes and such. However, it runs next to the original SCM so the original missions will still be available. It is based on my SA Injector, so it has full CRT functionality. It also has an GXT hook for custom text entries. A lot of code is just robbed from either op9080's SA SCM hook, spooky's VC SCM Hook and my own injector, credits to them!

I think it is quite self-explanatory, just look at CustomScript.cpp and CustomGXT.h

If you're having trouble with hash_map, change #define USE_HASH_MAP in commonincs.h into #define USE_HASH_MAP_IN_STDEXT, or if that doesn't work, just delete that line. Performance will drop sligthly in that case.

Download link: http://jesse.thorbit.nl/sainject/scmhook.zip

Hope it works with Visual Studio 6, if not then i really need to get an other version right away.
PMYahoo
  Top
 

 
JGuntherS@NL  
Posted: Thursday, Nov 15 2007, 19:42
Quote Post


Being a being
Group Icon
Group: Members
Joined: Nov 15, 2005

nl.gif

XXXXX



QUOTE (aad @ Nov 15 2007, 19:01)
QUOTE (JGuntherS@NL @ Nov 14 2007, 17:58)
I have created an SCM hook for GTA: San Andreas that works like Spooky's SCM hook for VC, with script classes and such. However, it runs next to the original SCM so the original missions will still be available. It is based on my SA Injector, so it has full CRT functionality. It also has an GXT hook for custom text entries. A lot of code is just robbed from either op9080's SA SCM hook, spooky's VC SCM Hook and my own injector, credits to them!

I think it is quite self-explanatory, just look at CustomScript.cpp and CustomGXT.h

If you're having trouble with hash_map, change #define USE_HASH_MAP in commonincs.h into #define USE_HASH_MAP_IN_STDEXT, or if that doesn't work, just delete that line. Performance will drop sligthly in that case.

Download link: http://jesse.thorbit.nl/sainject/scmhook.zip

Hope it works with Visual Studio 6, if not then i really need to get an other version right away.

Everything should work, except MSVC++ 6 doesn't have the hash_map by default. You could implement it yourself, find the correct files somewhere or just update to MSVC2003, which is what I'd advise you to do tounge.gif. If you want to use it with MSVC6 without hash_map, comment out or delete the line #define USE_HASH_MAP in commonincs.h.

This post has been edited by JGuntherS@NL on Thursday, Nov 15 2007, 19:46
PMMSN
  Top
 

 
Seemann  
Posted: Friday, Nov 16 2007, 09:53
Quote Post


Ruhe
Group Icon
Group: Members
Joined: Sep 3, 2004

ru.gif

Member Award




OK, I can confirm that with some changes it works with Visual Studio 2005 (VS8). Good work! icon14.gif

However, CLEO 3 scripts seem to be more user-friendly even without object-oriented programming stuff, IMO.
Users WebsitePM
  Top
 

 
JGuntherS@NL  
Posted: Friday, Nov 16 2007, 16:18
Quote Post


Being a being
Group Icon
Group: Members
Joined: Nov 15, 2005

nl.gif

XXXXX



I've uploaded a new version, this version also supports to some extent the way op9080 uses to script in C++.

Example code:
CODE
theScript << interior_access << "PDOMES" << 1 << EXEC;


A bit of a 'best of both worlds' idea smile.gif.

PS: more examples are inside the box wink.gif.
PMMSN
  Top
 

 
ceedj  
Posted: Friday, Nov 16 2007, 23:06
Quote Post


PEDS Creator
Group Icon
Group: Members
Joined: May 21, 2005

us.gif

Member Award




CODE
DEFINE_OPCODE(put_player, 0x0055, "vfff");
DEFINE_OPCODE(create_coordinate, 0x0400, "vfffvvv");


No longer supported in SA. There are a few others; I'll weed 'em out as I go. smile.gif

EDIT: Just a reminder: with multiple threads now, make sure your "waits" are distributed properly; this impacts which threads get higher priority. Not new info by any stretch, but after using one thread with the C++ hooks for so long, you tend to forget. wink.gif

EDIT 2:
CODE
DEFINE_OPCODE(get_car_color, 0x03F3, "vii");   // var_car col1 col2


Change the "vii" to "vvv", or your game will crash if you try to get colors from cars.

This post has been edited by ceedj on Saturday, Nov 17 2007, 02:02
Users WebsitePM
  Top
 

 
JGuntherS@NL  
Posted: Saturday, Nov 24 2007, 13:43
Quote Post


Being a being
Group Icon
Group: Members
Joined: Nov 15, 2005

nl.gif

XXXXX



I've uploaded a new version that supports the substitution of an actor variable with -1, which is used in defining actor animation sequences. Things like
CODE
CallOpcode(&AT_look_around, -1);
should work now smile.gif.

I also used ceedj's suggestions to modify opcodes.h, thanks for that smile.gif

This post has been edited by JGuntherS@NL on Saturday, Nov 24 2007, 13:54
PMMSN
  Top
 

 
ceedj  
Posted: Tuesday, Nov 27 2007, 01:45
Quote Post


PEDS Creator
Group Icon
Group: Members
Joined: May 21, 2005

us.gif

Member Award




QUOTE (JGuntherS@NL @ Nov 24 2007, 08:43)
I've uploaded a new version that supports the substitution of an actor variable with -1, which is used in defining actor animation sequences. Things like
CODE
CallOpcode(&AT_look_around, -1);
should work now smile.gif.

I also used ceedj's suggestions to modify opcodes.h, thanks for that smile.gif

Just to clarify, it's not just for actors; this fix works with any opcode that takes either a handle or -1 as a parameter. smile.gif When setting up opcodes in Opcodes.h, just make the parameter in question a v.

Hey JGS, how can we add NOT to opcodes? Doing CallOpcode(!&blapcode); throws a compilation error. I'm just creating a second opcode for now:

(blahpcode, "0x0684", "")

(nblahpcode, "0x8684", "")

Any ideas?

This post has been edited by ceedj on Tuesday, Nov 27 2007, 01:48
Users WebsitePM
  Top
 

 
JGuntherS@NL  
Posted: Friday, Nov 30 2007, 17:28
Quote Post


Being a being
Group Icon
Group: Members
Joined: Nov 15, 2005

nl.gif

XXXXX



QUOTE (ceedj @ Nov 27 2007, 01:45)
QUOTE (JGuntherS@NL @ Nov 24 2007, 08:43)
I've uploaded a new version that supports the substitution of an actor variable with -1, which is used in defining actor animation sequences. Things like
CODE
CallOpcode(&AT_look_around, -1);
should work now smile.gif.

I also used ceedj's suggestions to modify opcodes.h, thanks for that smile.gif

Just to clarify, it's not just for actors; this fix works with any opcode that takes either a handle or -1 as a parameter. smile.gif When setting up opcodes in Opcodes.h, just make the parameter in question a v.

Hey JGS, how can we add NOT to opcodes? Doing CallOpcode(!&blapcode); throws a compilation error. I'm just creating a second opcode for now:

(blahpcode, "0x0684", "")

(nblahpcode, "0x8684", "")

Any ideas?

You could use
CODE
if (!CallOpcode(&..., ...))
That'll work, as it's just a C not wink.gif

This post has been edited by JGuntherS@NL on Friday, Nov 30 2007, 17:34
PMMSN
  Top
 

 
ceedj  
Posted: Saturday, Dec 1 2007, 13:20
Quote Post


PEDS Creator
Group Icon
Group: Members
Joined: May 21, 2005

us.gif

Member Award




You know, I hate it when you make it look SO easy. Jerk. tounge.gif

Thanks buddy. smile.gif

Oh yeah, can I use readSCMvar(blah) anywhere I need to? Would be useful for scm mods like Space's All in One, etc.
Users WebsitePM
  Top
 

 
JGuntherS@NL  
Posted: Saturday, Dec 1 2007, 14:00
Quote Post


Being a being
Group Icon
Group: Members
Joined: Nov 15, 2005

nl.gif

XXXXX



QUOTE (ceedj @ Dec 1 2007, 13:20)
You know, I hate it when you make it look SO easy. Jerk. tounge.gif

Thanks buddy. smile.gif

Oh yeah, can I use readSCMvar(blah) anywhere I need to? Would be useful for scm mods like Space's All in One, etc.

Yes, you can smile.gif
PMMSN
  Top
 

 
ceedj  
Posted: Tuesday, Dec 4 2007, 17:48
Quote Post


PEDS Creator
Group Icon
Group: Members
Joined: May 21, 2005

us.gif

Member Award




Sorry if this seems goofy, but I'm having a problem with this:

CODE
float* pfGravity = (float*)0x863984;
*pfGravity = 0.008f


Is crashing the game. Actually, it's just the second line. I tested it further by doing this:

CODE
CallOpcode(&toggle_hud, 0);
CallOpcode(&toggle_radar, 0);
SCRIPT_WAIT(5000);
*pfGravity = 0.008f;


Sure enough, crash after a 5 second wait. I know the addy is ok, but this is the same way I did it in Spookie's VC hook for LC. Is there something I'm missing?
Users WebsitePM
  Top
 

 
Peter  
Posted: Tuesday, Dec 4 2007, 18:21
Quote Post


Secretly Heroic
Group Icon
Group: Members
Joined: Sep 21, 2006

XXXXX



Check out VirtualProtect, the memory address you're trying to write to is write-protected, you need to get access first smile.gif
Users WebsitePM
  Top
 

 
ceedj  
Posted: Tuesday, Dec 4 2007, 18:28
Quote Post


PEDS Creator
Group Icon
Group: Members
Joined: May 21, 2005

us.gif

Member Award




I had a feeling, but wasn't sure how to do it with floats. I'll look into it some more. Thanks very much for the help. smile.gif

EDIT: Ok, I got it to work. A bit inelegant though. Sacky gave me this for my custom loading screens:

CODE
void Patch_DEF ( DWORD dwAddress,  BYTE *bRawData, int iSize )
{
DWORD dw[2];
VirtualProtect ( (PVOID) dwAddress, iSize, PAGE_EXECUTE_READWRITE, &dw[0] );
memcpy ( (PVOID) dwAddress, bRawData, iSize );
VirtualProtect ( (PVOID) dwAddress, iSize, dw[0], &dw[1] );
}


My code for gravity:
CODE

BYTE bGravity[] = { 0x6F, 0x12, 0x83, 0x3B };
Patch_DEF(0x863984, bGravity, 4);


That translates to 0.004, (3B83126F) or half-gravity. My question: can anyone suggest a way to use the float value instead? Not a huge deal, but I want to add gravity values to my config file; I think 1 float is easier to deal with than hex combos. Thanks. smile.gif

This post has been edited by ceedj on Tuesday, Dec 4 2007, 20:21
Users WebsitePM
  Top
 

 
UZI-I  
Posted: Tuesday, Dec 4 2007, 21:42
Quote Post


WPL Manager...
Group Icon
Group: Members
Joined: Aug 23, 2006

fr.gif

Member Award




CODE
DWORD dw[2];
VirtualProtect ( (PVOID) 0x863984 , 4, PAGE_EXECUTE_READWRITE, &dw[0] );
*(float*)0x863984 = 0.004f;
VirtualProtect ( (PVOID) 0x863984 , 4, dw[0], &dw[1] );


biggrin.gif
Users WebsitePMMSNXbox Live
  Top
 

 
ceedj  
Posted: Tuesday, Dec 4 2007, 21:55
Quote Post


PEDS Creator
Group Icon
Group: Members
Joined: May 21, 2005

us.gif

Member Award




Thanks for that; there's not nearly enough examples on how to best use SA memory stuff with C++. smile.gif

This post has been edited by ceedj on Tuesday, Dec 4 2007, 21:57
Users WebsitePM
  Top
 

 
UZI-I  
Posted: Tuesday, Dec 4 2007, 22:09
Quote Post


WPL Manager...
Group Icon
Group: Members
Joined: Aug 23, 2006

fr.gif

Member Award




np

In-process its better to use Pointer stuff biggrin.gif

This post has been edited by UZI-I on Tuesday, Dec 4 2007, 22:11
Users WebsitePMMSNXbox Live
  Top
 

 

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)

0 Members:

Pages: (3) [1] 2 3 

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG