Giter Site home page Giter Site logo

Comments (4)

DerPopo avatar DerPopo commented on August 14, 2024 1

The test code works in release mode. It seems like the debug and release versions of msvc redist don't like each other.
Note that TextAssets aren't .txt files. Export the raw data from a patched .assets file with the imported .txt (it needs to be reopened in UABE after saving to see the change) and use the .dat in the patcher instead of a .txt file.
The AssetsReplacer has the same effect as using Import raw in UABE.

from uabe.

DerPopo avatar DerPopo commented on August 14, 2024

Here's a short summary of all steps. I hope I didn't forget anything important.

First, create an AssetsFile using AssetsReaderFromFile as reader and (LPARAM)pFile (opened through fopen with "rb") as readerPar.
Then create an AssetsFileTable with the AssetsFile. It allows you to search by the name (not completely reliable, uses the m_Name field of specific asset types) or by the path id. Alternatively, you can also find the asset through the pAssetFileInfo array (which has assetFileInfoCount elements).
Use the index value (= pathID), curFileType and inheritedUnityClass (all from the AssetFileInfo) and 0 for the fileID to create an AssetsReplacer through one of the MakeAssetModifier* functions.
Put that AssetsReplacer into a std::vector through push_back and pass it to AssetsFile::Write with AssetsWriterToFile, the output .assets file opened through fopen with "wb", 0 as filePos, the replacers vector and 0 as fileID.

Note that the API only works with VC++ 2010, simply because FILE or std::vector are different between different versions.

from uabe.

DarthAffe avatar DarthAffe commented on August 14, 2024

Thanks for the fast response and sorry to bother you again.
I tried to follow what you described and came up with the test code below.

The problem right now is, that I get an 'Access violation writing location 0x00000014' while creating the AssetsFile (second line). I get the same exception with both, the 2010 compiler (I set up a VM with VS C++ 2010 Express) and the 2015 compiler (but since you hint that, I didn't expect it to work) .
The FILE seems to be fine (fgetc works and leads to correct results).

I don't know if this information is of any use, but I messed around a bit and found out, that replacing 'AssetReaderFromFile' with 'AssetReaderFromSplitFile' doesn't lead to that error but eating up the CPU and running forever.

The test-code I used:

    FILE *pFile = fopen("D:\\tmp\\resources.assets", "rb");
    AssetsFile assetsFile(AssetsReaderFromFile, (LPARAM)pFile); // I tried &AssetsReaderFromFile too since I'm not sure what's right here but it makes no difference
    AssetsFileTable assetsFileTable(&assetsFile);
    AssetFileInfoEx* assetsFileInfo = assetsFileTable.getAssetInfo(673); // I know the ID - no need to search

    FILE *pReplaceFile = fopen("D:\\tmp\\go2.txt", "rb");
    AssetsReplacer* assetReplacer = MakeAssetModifierFromFile(0, (*assetsFileInfo).index, (*assetsFileInfo).curFileType, (*assetsFileInfo).inheritedUnityClass,
        pReplaceFile, 0, (QWORD)filesize("D:\\tmp\\go2.txt")); // I expect that the size parameter refers to the file size but I couldn't check this until now

    std::vector<AssetsReplacer*> replacors;
    replacors.push_back(assetReplacer);

    FILE *pOutputFile = fopen("D:\\tmp\\resources_tmp.assets", "wb"); // Output in a temp-file and replace the original one afterwards since the original file should be locked right now
    assetsFile.Write(AssetsWriterToFile, (LPARAM)pOutputFile, 0, replacors, 0);

    fclose(pFile);
    fclose(pReplaceFile);
    fclose(pOutputFile);

from uabe.

DarthAffe avatar DarthAffe commented on August 14, 2024

I feel somehow bad that I didn't consider that ...
Everything is working now. Thank you very much!

from uabe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.