The_GTA Posted April 9, 2017 Share Posted April 9, 2017 (edited) 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=28541GTAinside: http://www.gtainside.com/sanandreas/tools/103942-gta-asi-injectorI 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.htmlSA_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 August 14, 2017 by The_GTA Claude_Lib, Jago, Agem and 28 others 31 Link to comment Share on other sites More sharing options...
Blackbird88 Posted April 9, 2017 Share Posted April 9, 2017 That's nice screenshot you have there. As a member of ant colony I'm glad you thought of us. Agem, BS_BlackScout, TheArtemMaps and 4 others 7 Link to comment Share on other sites More sharing options...
vizs Posted April 9, 2017 Share Posted April 9, 2017 (edited) Second! 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 April 9, 2017 by The_Human Link to comment Share on other sites More sharing options...
The_GTA Posted April 9, 2017 Author Share Posted April 9, 2017 (edited) 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! 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 Here is what happens: 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 April 9, 2017 by The_GTA Blackbird88 1 Link to comment Share on other sites More sharing options...
vizs Posted April 9, 2017 Share Posted April 9, 2017 YEAS, my question is ain't sh*t. Link to comment Share on other sites More sharing options...
MrGTAmodsgerman Posted April 9, 2017 Share Posted April 9, 2017 What about GTA V support? Link to comment Share on other sites More sharing options...
The_GTA Posted April 9, 2017 Author Share Posted April 9, 2017 (edited) 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 April 9, 2017 by The_GTA MrGTAmodsgerman 1 Link to comment Share on other sites More sharing options...
Ash_735 Posted April 9, 2017 Share Posted April 9, 2017 Now we can LITERALLY SilentPatch EXEs. Alvarez, Ruvix, lpgunit and 16 others 19 Link to comment Share on other sites More sharing options...
BS_BlackScout Posted April 10, 2017 Share Posted April 10, 2017 (edited) Some of these posts are the funniest thing ever... This sounds interesting!! Like Ash said, now we can have them SilentPatched EXEs Edited April 10, 2017 by BlackScout Link to comment Share on other sites More sharing options...
thalilmythos Posted April 10, 2017 Share Posted April 10, 2017 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 More sharing options...
Igor Bogdanoff Posted April 10, 2017 Share Posted April 10, 2017 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. vizs 1 Link to comment Share on other sites More sharing options...
The_GTA Posted April 10, 2017 Author Share Posted April 10, 2017 (edited) 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): SilentPatchSA.asi embedded into gta-sa.exe (Steam): 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 April 11, 2017 by The_GTA Crspy and Igor Bogdanoff 2 Link to comment Share on other sites More sharing options...
Silent Posted April 10, 2017 Share Posted April 10, 2017 SilentPatchSA.asi seems to depend on special ASI loader, so it crashes in my 1.0 US executable. w-what dkluin and vizs 2 Link to comment Share on other sites More sharing options...
The_GTA Posted April 10, 2017 Author Share Posted April 10, 2017 (edited) w-whatNo idea, Silent. But this is what MSVC says (with debug symbols, pe_debug): 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 April 10, 2017 by The_GTA Link to comment Share on other sites More sharing options...
fastman92 Posted April 10, 2017 Share Posted April 10, 2017 (edited) 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 April 10, 2017 by fastman92 Link to comment Share on other sites More sharing options...
Silent Posted April 10, 2017 Share Posted April 10, 2017 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 Crspy and The_GTA 2 Link to comment Share on other sites More sharing options...
thalilmythos Posted April 11, 2017 Share Posted April 11, 2017 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 vizs 1 Link to comment Share on other sites More sharing options...
The_GTA Posted April 11, 2017 Author Share Posted April 11, 2017 (edited) 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. 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 postPlease 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 April 11, 2017 by The_GTA BS_BlackScout, Silent and Crspy 3 Link to comment Share on other sites More sharing options...
DubHaMlg777 Posted April 13, 2017 Share Posted April 13, 2017 your tool shocked me. The_GTA 1 Link to comment Share on other sites More sharing options...
DubHaMlg777 Posted April 13, 2017 Share Posted April 13, 2017 (edited) After testing it seems that it doesn't work very well with cleo.asi 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 April 13, 2017 by DubHaMlg777 Link to comment Share on other sites More sharing options...
Crspy Posted April 13, 2017 Share Posted April 13, 2017 (edited) just embedded SilentPatchSA , Ragdoll_physics ..... working fine 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 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 April 13, 2017 by crspo2020 DubHaMlg777 1 Link to comment Share on other sites More sharing options...
The_GTA Posted April 13, 2017 Author Share Posted April 13, 2017 (edited) After testing it seems that it doesn't work very well with cleo.asi 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 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 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 April 13, 2017 by The_GTA Agem, DubHaMlg777 and Crspy 3 Link to comment Share on other sites More sharing options...
DubHaMlg777 Posted April 14, 2017 Share Posted April 14, 2017 About 10 .asi is the limit. This is great!!! Link to comment Share on other sites More sharing options...
Crspy Posted April 14, 2017 Share Posted April 14, 2017 (edited) 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 April 16, 2017 by Crspy DubHaMlg777 1 Link to comment Share on other sites More sharing options...
The_GTA Posted April 14, 2017 Author Share Posted April 14, 2017 (edited) 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 April 14, 2017 by The_GTA DubHaMlg777 and Crspy 2 Link to comment Share on other sites More sharing options...
Classic_93 Posted April 15, 2017 Share Posted April 15, 2017 (edited) Can I inject multiple .asi and .dll files at once? Edited April 15, 2017 by Classic_93 Link to comment Share on other sites More sharing options...
The_GTA Posted April 15, 2017 Author Share Posted April 15, 2017 (edited) 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 April 16, 2017 by The_GTA Crspy and DubHaMlg777 2 Link to comment Share on other sites More sharing options...
Crspy Posted April 15, 2017 Share Posted April 15, 2017 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 The_GTA 1 Link to comment Share on other sites More sharing options...
The_GTA Posted April 15, 2017 Author Share Posted April 15, 2017 (edited) Nice work man ...... check this, my way of injecting asi files https://youtu.be/pSdZtqCII0w 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 April 15, 2017 by The_GTA DubHaMlg777 and Crspy 2 Link to comment Share on other sites More sharing options...
B Dawg Posted April 15, 2017 Share Posted April 15, 2017 Ooh, gonna test this with the latest version of IV/EFLC and Simple Native Trainer tomorrow. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now