Jump to content

[REL/OpenSrc] GTA ASI Injector


The_GTA

Recommended Posts

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.com/mods/show.php?id=28541
GTAinside: http://www.gtainside.com/sanandreas/tools/103942-gta-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.osdn.jp/pefrmdllembed.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
- 02.08.2017 23:31: added "-impinj" commandline option for PE import redirection
- 14.08.2017 21:15: added "-noexp" commandline option for PE export ignoring; binary size optimizations Edited by The_GTA
Link to comment
Share on other sites

Blackbird88

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

Link to comment
Share on other sites

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.

Edited by The_Human
Link to comment
Share on other sites

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.

Edited by The_GTA
  • Like 1
Link to comment
Share on other sites

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.

Edited by The_GTA
  • Like 1
Link to comment
Share on other sites

Now we can LITERALLY SilentPatch EXEs.

 

tenor.gif

Link to comment
Share on other sites

BS_BlackScout

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

 

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

Edited by BlackScout
Link to comment
Share on other sites

thalilmythos

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

Link to comment
Share on other sites

Igor Bogdanoff

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.

 

Link to comment
Share on other sites

 

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!

Edited by The_GTA
  • Like 2
Link to comment
Share on other sites

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

w-what

  • Like 2
Link to comment
Share on other sites

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.

Edited by The_GTA
Link to comment
Share on other sites

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

Edited by fastman92
Link to comment
Share on other sites

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(LockResource( LoadResource(thisModule, resource) ));		RwD3D9CreateVertexShader(shader, reinterpret_cast(&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/topic/669045-silentpatch/?p=1069507640

  • Like 2
Link to comment
Share on other sites

thalilmythos

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

Link to comment
Share on other sites

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/topic/669045-silentpatch/?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.

Edited by The_GTA
  • Like 3
Link to comment
Share on other sites

DubHaMlg777

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

 

Untitled.jpg

Untitled2.jpg

gta1.jpg

 

 

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.

Edited by DubHaMlg777
Link to comment
Share on other sites

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?

Edited by crspo2020
  • Like 1
Link to comment
Share on other sites

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

 

Untitled.jpg

Untitled2.jpg

gta1.jpg

 

 

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? :)

 

 

Edited by The_GTA
  • Like 3
Link to comment
Share on other sites

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. ;)

Edited by Crspy
  • Like 1
Link to comment
Share on other sites

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

Edited by The_GTA
  • Like 2
Link to comment
Share on other sites

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

Edited by Classic_93
Link to comment
Share on other sites

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/projects/pefrm-units/downloads/67523/gta_asi_injector.zip/

 

btw dont buy seagate HDD, mine failed today

Edited by The_GTA
  • Like 2
Link to comment
Share on other sites

 

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/projects/pefrm-units/downloads/67523/gta_asi_injector.zip/

 

btw dont buy seagate HDD, mine failed today

 

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

https://youtu.be/pSdZtqCII0w

Link to comment
Share on other sites

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

 

 

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!

Edited by The_GTA
  • Like 2
Link to comment
Share on other sites

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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.