0

I have QML file that has been embedded into a dll. I think it was done something like this

How can I embed a Qt resource into a .dll file? (The second answer).

Is there anyway to split out the QML file to obtain the source code? I am not very familiar with QT framework

ackbar03
  • 77
  • 1
  • 8
  • As the QML files are just compiled in as is, you should be able to extract them with an resource extraction program, maybe [nirsoft](https://www.nirsoft.net/utils/resources_extract.html) can do it, otherwise there should be enough available on google – Amfasis Jan 13 '20 at 08:31

1 Answers1

1

If it's embedded via *.qrc, then it's NOT compatible with standard windows/linux (.dll/.so) resource formats. qrc is compiled as xxx_qrc.cpp file and embedded by linker as .obj file with static initialization code. I.e. it's just part of the binary. You can access "contents" of qrc via QFile with "qrc:/." URL. But for that, you have to load DLL with resources embedded in current process, because qrc is hooked up in static initialization (aka DllMain in Windows). Something like:

QLibrary lib("./library.dll");
if (!lib.load()) 
    throw exception(lib.errorString().toStdString());
QFile resource(":/resource.qml");
if (!resource.open(QIODevice::ReadOnly))
    throw exception(resource.errorString().toStdString());
resource.copy("./exported.qml");

To explore currently loaded virtual qrc file system tree, you can use QDir(":/"). I guess it's pretty easy to figure out the rest from here.

And of course - you have to be aware what sort of DLLs you are loading into your process, as they may contain arbitrary code that will be executed as you call QLibrary::load!