Beginner Guide to OpenIV, Scripthook, and Friends
Not too long after its release, back in 2015, some very talented and creative people in Russia and a chap named Alexander Blade created the tools necessary to extend the new 5/V addition to the GTA franchise, allowing the community to create mods as they had done for GTAIV.
One major breakthrough was cracking the encryption in the GTA5 files that contain all the good stuff like 3D models, textures, sounds, and data. These assets are bundled in the rage package files (.rpf), which are archives (think zip) and can not be edited without very special tools. The Russian crew had successfully done this with GTAIV with what we all now know and install as OpenIV. So it was now possible to edit GTA5 rpfs as well, with an updated version of their tool. They could have named the new version OpenV, but they didn't since it can be used for other games as well including RDR.
The other accomplishment, by Alexander Blade, was Scripthook, the file we all wait for after each game update. The Scripthook download included the legendary "asi loader", aka dinput8.dll, which is Blade's modified version of the Windows dinput8.dll. The asi loader was also packaged with OpenIV as an optional install (optional because it was likely already installed on your system with Scripthook). Asi files are essentially identical or very similar to dll (dynamic link libraries). On a historical note, at first a file called dsound.dll (also part of DirectX) was used for the same purpose.
And finally we had the Scripthook Dot Net files, which using Scripthook, allowed coders to write some magic using native and SHVDN functions.
So how does this all work? Well, I'll give you my take and hopefully someone will correct me on what I screwed up.
When GTA5.exe runs, and the same applies for any game using DirectX (most PC games period i guess), it looks for dinput8.dll starting in its own GTA5 folder. So it finds the Blade version first, not the Microsoft version. Having said that, the dinput8.dll does reference the microsoft one. The asi loader (dinput8.dll) then loads your asi files. You can see this in its log file.
// GTA V ASI LOADER (build May 2 2015)
// (C) Alexander Blade 2015
LIB: "C:\WINDOWS\system32\dinput8.dll" => 00007FFCAD500000
API: "DirectInput8Create" => 00007FFCAD502230
Examples of the asi files loaded are OpenIV.asi, Menyoo.asi, TrainerV.asi, and your PackfileLimitAdjuster, HeapAdjuster, ScriptHookVDotNet, etc.
When ScriptHookV loads, it will register, load, and starts certain files that are already loaded by dinput8, including your trainers and ScriptHookVDotNet.
OpenIV.asi, once loaded by dinput8.dll will open and get attributes from your modded archives (rpf files) hopefully which you did only in your mods folder while ScriptHookVDotNet will load its 2 dlls (version 2 and version 3) as well as LemonUI and Native UI (if installed).
That's the basic gist. Feel free to add, comment, or correct.