CLI patch for TESArchive - CPTA
Adds new functionality to TESArchive (aka Archive.exe) in the official Skyrim SE Creation Kit. Completely automate the process of building BSA files by making TESArchive accept parameters passed to it from the Windows shell.
Screenshots 1 screenshots
About this mod Machine translation
Adds new functionality to TESArchive (aka Archive.exe) in the official Skyrim SE Creation Kit. Completely automate the process of building BSA files by making TESArchive accept arguments passed to it from the Windows shell.
TESArchive can be used in a batch file or using command line parameters.
It is a Windows DLL module that needs to be linked to the original TESArchive executable.
Open source, containing the source code of the project.
Patching TESArchive using DLL
Note: You don't need to do this yourself. Someone else may do this for you and patch the executable on its end using all the tools and steps listed below.
Required tools and utilities:
CFF Explorer VII - or another program that can repair Archive.exe to add a new DLL to its import. CFF Explorer VII is part of Daniel Pistelli's Explorer Suite and can be downloaded for free from here.
Archive.exe - Located in the following subdirectory of the game after installing the Creation Kit: "\Tools\Archive\Archive.exe". At this time, using Creation Kit v1.5.3.0 updated on 2019-01-29.
cpta_dll.dll - DLL file built with this project.
pace:
*Copy "cpta_dll.dll" to the folder/directory where "Archive.exe" is located.
*Launch CFF Explorer VII.
*Select "File" in the main menu, then "Open" and browse for "Archive.exe".
*Select "Import Adder" from the list on the left.
*In the middle of the main window. Find and press the "Add" button.
*Browse and select "cpta_dll.dll".
*In the list below, all buttons in the "Exported functions" list,
Select an individual item for it - if it's not already selected.
*Press the "Import by Name" button.
*Press the "Rebuild Import Table" button.
*Select "File" from the main menu, then select "Save As" and save
The directory where you started from "Archive_cpta.exe".
From now on, patching "Archive_cpta.exe" the old way, by clicking on its icon, you will get at least one of the following error messages:
- The DLL file named "cpta_dll.dll" is missing.
- The environment variable ASCP_INPUT_DIR has not been found.
CPTA DLL configuration
Once TESArchive is patched, or someone patches it for you, you can use it in a shell script or other external utility. The following environment variables are used by "cpta_dll.dll".
ASCP_INPUT_DIR - The input directory name contents from which the BSA archive will be created. This path should point to a directory named "Data". Initially, in unpatched versions, this was the Edit - Add Directory option.
ASCP_OUTPUT_BSA - Output BSA file name. Must end with '.bsa' extension.
ASCP_CONF - Optional configuration. Semicolon separated (";") key-value pairs to pre-configure the main TESArchive GUI window. See the batch file example for option names.
Typically, when using batch scripts (.BAT), the above environment variables are assigned using the "SET" command.
Batch script example
@echoClose
SET ASCP_INPUT_DIR = C:\ bsa_data \ Data
SET ASCP_OUTPUT_BSA = C:\ bsa_data \ output.bsa
SET ASCP_CONF = bRemoveBSL = 0; bCLIOnly = 0; bHidden = 0; bNoQuit = 0; types2 = eCompress,eMeshes,eTextures,eMisc
\ Archive_cpta.exe
Echo status: %ERRORLEVEL%
SET ASCP_INPUT_DIR =
SET ASCP_OUTPUT_BSA =
SET ASCP_CONF =
pause
Compile CPTA DLL project from source code
Note: You don't need to do this. You will find the compiled version in the downloads section.
Software used
*MS Visual C++ Compiler - Tested with Visual Studio 2017 (aka MSVC2017), should work with older versions
- Windows SDK - tested with v7.1 (normally use MSVC to install Windows SDK)
- Detours package - tested with v4.0.1. Link
Source code must be compiled for 64-bit Windows architecture.
Compiler option: /DDETOURS_TARGET_PROCESSOR=x64
Linker options: /dll
Detours build configuration
Some notes on the Detours package. Build the detour using the provided configuration makefile. Alternatively, use the following compiler flags:
/ MT / Gy / Od / DDETOURS_TARGET_PROCESSOR = x64
/ DWIN32_LEAN_AND_MEAN / D_WIN32_WINNT = 0x501
Links and References
My Github page:
Detours pack …
Install & use Install: follow the bundled instructions
- Unzip the archive from playbuff and read the bundled readme / instructions first.
- There is no universal mod manager for this game: some mods replace game files directly, some go into a game-specific Mods folder, and some need a game-specific community loader or tool first — follow the bundled readme.
- Place the files exactly as the readme says; mods with listed dependencies need those installed too.
- Launch the game to confirm it loaded; some games require enabling mods in settings or an in-game mod menu.
Install locations vary a lot between games and mods — the bundled readme is the most reliable guide.