Quantcast

Jump to content

» «
Photo

[REL/OpenSrc] GTA ASI Injector

55 replies to this topic
The_GTA
  • The_GTA

    revenclaw

  • Members
  • Joined: 27 Dec 2012
  • Germany
  • Modding Milestone [Magic.TXD]

#1

Posted 09 April 2017 - 01:56 AM Edited by The_GTA, 16 April 2017 - 11:49 AM.

wqkasZJ.png

 
Hello GTA modders!

here is a small tool for embedding GTA ASI files directly into your GTA .EXE file. By doing so you do not require any ASI loader anymore; the ASI code is "installed" directly into the EXE!

GTAGarage: http://www.gtagarage...ow.php?id=28541
GTAinside: http://www.gtainside...ta-asi-injector

I call it pefrmdllembed. It works by placing the PE image sections of the DLL file into the EXE file + linking in imports.

In the .zip are example EXE files, example DLL files, two sample ASIs from plugin-sdk by DK22Pac and the tool itself.
 
Command-line usage:​ pefrmdllembed.exe *gta.exe* *plugin.asi* *output_gta.exe*
 
The tool generates a new EXE file with the ASI injected into. Note that not all ASI files will work with this.
 
Source code: http://pefrm-units.o...rmdllembed.html

SA_CreateCar.asi: Press tab to spawn an Infernus.
VC_PedPainting.asi: Tommy will be painted red.

Changelog:
- 09.04.2017 14:00: fixed a bug for ASIs with static TLS initialization callbacks
- 09.04.2017 15:01: cleaned-up the codebase a bit; removed unnecessary import directory
- 10.04.2017 16:05: fixed "floating point support not loaded" error in certain ASIs
- 10.04.2017 20:49: added basic C++ exception handling to error out less violenty
- 10.04.2017 21:23: more clean-up; added good error message for file-creation error
- 11.04.2017 19:42: fixed embedding of ASI resources; now SilentPatchSA/SkyGFX work for 1.0 US
- 15.04.2017 13:32: support for embedding multiple ASI at once
- 16.04.2017 13:48: now ASI exports go into EXE aswell
  • Wesser, ural, -Anti- and 23 others like this

Blackbird88
  • Blackbird88

    DualShock 3 Buttons EVERYWHERE

  • Members
  • Joined: 21 Jul 2008
  • Czech-Republic

#2

Posted 09 April 2017 - 01:07 PM

That's nice screenshot you have there. As a member of ant colony I'm glad you thought of us.

  • Mega, Alexander, Gummy  and 2 others like this

The_Human
  • The_Human

    The Eye

  • Members
  • Joined: 31 Dec 2015
  • Mars

#3

Posted 09 April 2017 - 01:32 PM Edited by The_Human, 09 April 2017 - 01:34 PM.

Second! :pp

 

I've a couple of questions which may be stupid, will it affect the compatibility of mods such as FLA, considering that FLA only supports HOODLUM exe but if we inject an ASI mod directly into the exe, will the mod become incompatible?

 

If a mod has an ini file, do we have to make any changes to the ini file like renaming it to something else?

 

To be honest, this is a fantastic idea.


The_GTA
  • The_GTA

    revenclaw

  • Members
  • Joined: 27 Dec 2012
  • Germany
  • Modding Milestone [Magic.TXD]

#4

Posted 09 April 2017 - 03:24 PM Edited by The_GTA, 09 April 2017 - 03:27 PM.

That's nice screenshot you have there. As a member of ant colony I'm glad you thought of us.

Glad you like it.
 

Second! :pp
 
I've a couple of questions which may be stupid, will it affect the compatibility of mods such as FLA, considering that FLA only supports HOODLUM exe but if we inject an ASI mod directly into the exe, will the mod become incompatible?
 
If a mod has an ini file, do we have to make any changes to the ini file like renaming it to something else?
 
To be honest, this is a fantastic idea.

I just generated my very own fastman92_sa.exe

ibCZcBx.png

Here is what happens:

FbAgL1S.png

Maybe we need a special version of limit adjuster.

Similarly modloader puts out error. I think it is because these ASIs check EXE size.
  • Blackbird88 likes this

The_Human
  • The_Human

    The Eye

  • Members
  • Joined: 31 Dec 2015
  • Mars

#5

Posted 09 April 2017 - 03:26 PM

YEAS, my question is ain't sh*t.


MrGTAmodsgerman
  • MrGTAmodsgerman

    Inventor

  • Members
  • Joined: 02 Jan 2012
  • Germany

#6

Posted 09 April 2017 - 05:54 PM

What about GTA V support?


The_GTA
  • The_GTA

    revenclaw

  • Members
  • Joined: 27 Dec 2012
  • Germany
  • Modding Milestone [Magic.TXD]

#7

Posted 09 April 2017 - 07:15 PM Edited by The_GTA, 09 April 2017 - 07:18 PM.

What about GTA V support?

Should work. I assume you know about the quirks. GetModuleHandle to get the memory base address of GTA V executable, etc.

Important: avoid __declspec( thread ) like a plague, it screws up the embedding (pretty sure also the C++11 thead_local thing?)

I am speaking about: 64bit exe GTA V is no problem. No experience in anti-cheat for new R* games.
  • MrGTAmodsgerman likes this

Ash_735
  • Ash_735

  • Members
  • Joined: 15 Nov 2005
  • None
  • Contribution Award [Mods]
    Most Knowledgeable [GTA] 2013
    Best Map 2013 "ViceCityStories PC Edition"

#8

Posted 09 April 2017 - 10:20 PM

Now we can LITERALLY SilentPatch EXEs.

tenor.gif
  • lpgunit, Blackbird88, B Dawg and 13 others like this

BlackScout
  • BlackScout

    A Ninja

  • Members
  • Joined: 08 Sep 2013
  • None

#9

Posted 10 April 2017 - 02:14 AM Edited by BlackScout, 10 April 2017 - 02:14 AM.

Some of these posts are the funniest thing ever...  :lol:

 

This sounds interesting!! Like Ash said, now we can have them SilentPatched EXEs  :catspider:


thalilmythos
  • thalilmythos

    Rat

  • Members
  • Joined: 26 Dec 2012

#10

Posted 10 April 2017 - 03:48 AM

Would this make possible to inject outfit asi into the exe and using silent patch at the same time with both working?


Tomasak
  • Tomasak

    Pray 4 OpenIV

  • The Yardies
  • Joined: 04 Jan 2009
  • None
  • Spam Commando 2017
    Best Conversion 2016 [GTA: Underground] [Contribution]

#11

Posted 10 April 2017 - 01:18 PM

If a mod has an ini file, do we have to make any changes to the ini file like renaming it to something else?

i second this question.
You only answered FLA question.
 

  • The_Human likes this

The_GTA
  • The_GTA

    revenclaw

  • Members
  • Joined: 27 Dec 2012
  • Germany
  • Modding Milestone [Magic.TXD]

#12

Posted 10 April 2017 - 02:04 PM Edited by The_GTA, 11 April 2017 - 10:41 AM.

If a mod has an ini file, do we have to make any changes to the ini file like renaming it to something else?

i second this question.
You only answered FLA question.

No change to .ini layout required. Put it like in regular ASI. Unless you depend on behavior of ASI loader (maybe it uses scripts/ folder). Is this ok? :)
 

Would this make possible to inject outfit asi into the exe and using silent patch at the same time with both working?

outfit.asi embedded into gta_sa.exe 1.0 US (ignore text, it is wrong):

zR9nQ4wm.png

SilentPatchSA.asi embedded into gta-sa.exe (Steam):

Iar04Jfm.png

If outfit.asi would support steam, it could work because you can chain embedding up to ten times? Depends on NT loader behavior.
SilentPatchSA.asi seems to depend on special ASI loader, so it crashes in my 1.0 US executable.

Btw, update to the tool; fixed a bug that prevented outfit.asi from working.

EDIT: currently fixing bug that prevents SilentPatch from working!
  • Tomasak and Crspy like this

Silent
  • Silent

    Chief Vision™ Alterer

  • GTA Mods Staff
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [Modding] 2016
    Contribution Award [Mods]
    Best Script/Plugin 2014 [SilentPatch]
    Most Respected 2014
    Most Helpful [Mods] 2014
    Most Helpful [GTA] 2013
    Most Helpful [Mods] 2013
    Most Talented [Modding] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Best Vehicle 2013 [III Aircraft]
    Most Helpful [Mods] 2012
    Modder of the Year 2012

#13

Posted 10 April 2017 - 02:12 PM

SilentPatchSA.asi seems to depend on special ASI loader, so it crashes in my 1.0 US executable.


w-what
  • dkluin and The_Human like this

The_GTA
  • The_GTA

    revenclaw

  • Members
  • Joined: 27 Dec 2012
  • Germany
  • Modding Milestone [Magic.TXD]

#14

Posted 10 April 2017 - 02:48 PM Edited by The_GTA, 10 April 2017 - 02:49 PM.

w-what

No idea, Silent. But this is what MSVC says (with debug symbols, pe_debug):

hdzgF7Om.png

Would be great if this issue would not exist because it happens in SkyGFX aswell. :)
Or am I just doing something wrong? forgetting something? this is just done pretty quickly tbh.

Null-ptr crash inside d3d9.dll.

fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009
  • Poland
  • Best Conversion 2016 [GTA: Underground] [Contribution]
    Contribution Award [Mods]

#15

Posted 10 April 2017 - 07:24 PM Edited by fastman92, 10 April 2017 - 07:26 PM.

I've done something similar for Android SO libraries.

Plugin Loader Installer

modifies the game library e.g libGTASA.so and make it possible to combine together with libFastman92pluginLoader.so

Silent
  • Silent

    Chief Vision™ Alterer

  • GTA Mods Staff
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [Modding] 2016
    Contribution Award [Mods]
    Best Script/Plugin 2014 [SilentPatch]
    Most Respected 2014
    Most Helpful [Mods] 2014
    Most Helpful [GTA] 2013
    Most Helpful [Mods] 2013
    Most Talented [Modding] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Best Vehicle 2013 [III Aircraft]
    Most Helpful [Mods] 2012
    Modder of the Year 2012

#16

Posted 10 April 2017 - 07:27 PM

Vertex shader is created from a data resource in the ASI, maybe that's where the problem is?

bool ShaderAttach()
{
	// CGame::InitialiseRenderWare
	if ( InitialiseRenderWare() )
	{
		HMODULE thisModule;
		GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCWSTR)ShaderAttach, &thisModule);

		HRSRC		resource = FindResourceW(thisModule, MAKEINTRESOURCE(IDR_NVCSHADER), RT_RCDATA);
		RwUInt32*	shader = static_cast<RwUInt32*>(LockResource( LoadResource(thisModule, resource) ));

		RwD3D9CreateVertexShader(shader, reinterpret_cast<void**>(&pNVCShader));

		bXMSupported = XMVerifyCPUSupport() != FALSE;
		return true;
	}
	return false;
}
NOTE: Currently released Build 28 does not call LockResource but I changed it recently to conform to MSDN specs more. If you wanna know if this was the issue, try this test version which loads the shader this (correct) way:
http://gtaforums.com...h/?p=1069507640
  • The_GTA and Crspy like this

thalilmythos
  • thalilmythos

    Rat

  • Members
  • Joined: 26 Dec 2012

#17

Posted 11 April 2017 - 03:47 AM

This seems really interesting, but i don't have a clue on how to use it, having a readme for people without scripting knowledge, would be good, or maybe i'm just dumb and can't really understand the instructions on the first post

  • The_Human likes this

The_GTA
  • The_GTA

    revenclaw

  • Members
  • Joined: 27 Dec 2012
  • Germany
  • Modding Milestone [Magic.TXD]

#18

Posted 11 April 2017 - 05:41 PM Edited by The_GTA, 11 April 2017 - 05:53 PM.

Vertex shader is created from a data resource in the ASI, maybe that's where the problem is?
 
NOTE: Currently released Build 28 does not call LockResource but I changed it recently to conform to MSDN specs more. If you wanna know if this was the issue, try this test version which loads the shader this (correct) way:
http://gtaforums.com...h/?p=1069507640

Thank you very much, Silent! Support for SilentPatchSA.asi for all GTA:SA versions has been added :)
I can even embed both SilentPatch and SkyGFX into one EXE now, topkek.

iR6yFiwm.png

gcBdUgTm.png
 

This seems really interesting, but i don't have a clue on how to use it, having a readme for people without scripting knowledge, would be good, or maybe i'm just dumb and can't really understand the instructions on the first post

Please try opening cmd.exe and run "pefrmdllembed.exe". It gives you instructions in console window. If you do it correctly it will generate a new EXE, if not it wont do anything. :)

Maybe we need ASI installer? GUI window with input.exe and input.asi paths?

If anything does not work please post screenshot of pefrmdllembed.exe console log. We can help you figure it out.
  • Silent, BlackScout and Crspy like this

DubHaMlg777
  • DubHaMlg777

    Proud member of the Killuminati Soldiers.

  • Members
  • Joined: 04 Dec 2016
  • Egypt

#19

Posted 13 April 2017 - 08:20 AM

your tool shocked me.

  • The_GTA likes this

DubHaMlg777
  • DubHaMlg777

    Proud member of the Killuminati Soldiers.

  • Members
  • Joined: 04 Dec 2016
  • Egypt

#20

Posted 13 April 2017 - 08:28 AM Edited by DubHaMlg777, 13 April 2017 - 09:07 AM.

After testing it seems that it doesn't work very well with cleo.asi

Spoiler

Oh and also, is there is any limit for the asi files i can embed to the executable?

P.S : this is one of the most useful tools I've ever seen by far, really great job.


Crspy
  • Crspy

    Obsessed with Modding

  • Members
  • Joined: 14 May 2015
  • None

#21

Posted 13 April 2017 - 10:02 AM Edited by crspo2020, 13 April 2017 - 10:05 AM.

just embedded SilentPatchSA , Ragdoll_physics ..... working fine :lol:  thanks for this amazing tool.

skygfx isn't really working , after i embed it and start the game after 5 seconds of gameplay  it crashes. and  not working with cleo.asi  xD

but the positive thing is that it works with most asi plugins :p
one question : does this tool optimize gta sa somehow by making the asi code load directly from gta_sa.exe as if it were built-in the game itself?

  • DubHaMlg777 likes this

The_GTA
  • The_GTA

    revenclaw

  • Members
  • Joined: 27 Dec 2012
  • Germany
  • Modding Milestone [Magic.TXD]

#22

Posted 13 April 2017 - 11:47 AM Edited by The_GTA, 13 April 2017 - 11:53 AM.

After testing it seems that it doesn't work very well with cleo.asi

Spoiler

Oh and also, is there is any limit for the asi files i can embed to the executable?
P.S : this is one of the most useful tools I've ever seen by far, really great job.

Thank you, I appreciate your nice statement :)

About 10 .asi is the limit. I just tested it. Beyond that Windows NT will refuse to run EXE.
If you mean limit inside ASI, no known limit. ASI can be as complex as you want ;)

About CLEO.ASI limit: yes, unfortunately plugins to CLEO need "CLEO.ASI" file. But not many ASI plugins are this complicated, no? It is unfortunate.
 

just embedded SilentPatchSA , Ragdoll_physics ..... working fine :lol:  thanks for this amazing tool.
skygfx isn't really working , after i embed it and start the game after 5 seconds of gameplay  it crashes. and  not working with cleo.asi  xD
but the positive thing is that it works with most asi plugins :p
one question : does this tool optimize gta sa somehow by making the asi code load directly from gta_sa.exe as if it were built-in the game itself?

I am happy that you appreciate this tool :)
There was a random crash when I embedded both SkyGFX and SilentPatchSA because my framerate was too high. (I embedded skygfx.asi first, then SilentPatchSA.asi, order sometimes is important).

Optimization? This tool guarrantees that .ASI code is executed before any GTA code.
1) because the .asi is part of gta_sa.exe, the OS does not have to load the .asi separately, resulting in faster load time

======================

I made a video that demonstrates embedding MTA core into gta_sa.exe. Who knew that it works just like an .ASI? :)

  • Mega, Crspy and DubHaMlg777 like this

DubHaMlg777
  • DubHaMlg777

    Proud member of the Killuminati Soldiers.

  • Members
  • Joined: 04 Dec 2016
  • Egypt

#23

Posted 14 April 2017 - 09:44 AM

 

About 10 .asi is the limit.

 

This is great!!!


Crspy
  • Crspy

    Obsessed with Modding

  • Members
  • Joined: 14 May 2015
  • None

#24

Posted 14 April 2017 - 01:27 PM Edited by Crspy, 16 April 2017 - 08:46 PM.

Also open limit adjuster checks exe size  which is essential for project 2dfx.

:(  so we actually have to ask Link2012 (ModLoader and OLA author)  and other modders who made indispensable plugins to make their asi plugins compatible...... maybe it's not hard after all. ;)

  • DubHaMlg777 likes this

The_GTA
  • The_GTA

    revenclaw

  • Members
  • Joined: 27 Dec 2012
  • Germany
  • Modding Milestone [Magic.TXD]

#25

Posted 14 April 2017 - 02:59 PM Edited by The_GTA, 14 April 2017 - 03:31 PM.

This is great!!!

:)


so we actually have to ask ThirteenAG(OLA author) and Link2012 (ModLoader author) to make their asi plugins compatible...... maybe it's not hard after all. ;)

Those programmers are very talented so not hard, yes. Idea: check what PE sections exist and perform check-sum check per-section, check if all sections match a GTA exe version. Ignore additional sections (added by pefrmdllembed + other tools).

Done by MTA (anti-cheat) and CLEO.asi
  • Crspy and DubHaMlg777 like this

Classic_93
  • Classic_93

    Player Hater

  • Members
  • Joined: 10 Dec 2016
  • Russia

#26

Posted 15 April 2017 - 04:47 AM Edited by Classic_93, 15 April 2017 - 04:48 AM.

Can I inject multiple .asi and .dll files at once?

The_GTA
  • The_GTA

    revenclaw

  • Members
  • Joined: 27 Dec 2012
  • Germany
  • Modding Milestone [Magic.TXD]

#27

Posted 15 April 2017 - 11:31 AM Edited by The_GTA, 16 April 2017 - 11:46 AM.

Can I inject multiple .asi and .dll files at once?

Yes, tool updated. Put multiple ASI paths at once.

pefrmdllembed.exe gta_sa.exe skygfx.asi SilentPatchSA.asi sky_silent_sa.exe

Download: https://osdn.net/pro...i_injector.zip/

btw dont buy seagate HDD, mine failed today
  • Crspy and DubHaMlg777 like this

Crspy
  • Crspy

    Obsessed with Modding

  • Members
  • Joined: 14 May 2015
  • None

#28

Posted 15 April 2017 - 03:05 PM

 

Can I inject multiple .asi and .dll files at once?

Yes, tool updated. Put multiple ASI paths at once.

pefrmdllembed.exe gta_sa.exe skygfx.asi SilentPatchSA.asi sky_silent_sa.exe

Download: https://osdn.net/pro...i_injector.zip/

btw dont buy seagate HDD, mine failed today

 

Nice work man :)  ...... check this, my way of injecting asi files

  • The_GTA likes this

The_GTA
  • The_GTA

    revenclaw

  • Members
  • Joined: 27 Dec 2012
  • Germany
  • Modding Milestone [Magic.TXD]

#29

Posted 15 April 2017 - 07:15 PM Edited by The_GTA, 15 April 2017 - 07:17 PM.

Nice work man :)  ...... check this, my way of injecting asi files

Spoiler

Wow, nice trick, Crspy! Was not aware that you could just drag&drop, too. Seems much easier. But do not drag&drop more than two ASI because the last would be overwritten (output exe path). ;)

And thank you for putting the tool in your signature. I appreciate it a lot!
  • Crspy and DubHaMlg777 like this

B Dawg
  • B Dawg

    Victory for modding!

  • Members
  • Joined: 15 Dec 2008
  • Bosnia-and-Herzegovina

#30

Posted 15 April 2017 - 09:53 PM

Ooh, gonna test this with the latest version of IV/EFLC and Simple Native Trainer tomorrow.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users