[Development] How to modify the hard code paths built in QtCoreX.dll

Loaden loaden at gmail.com
Mon Apr 30 07:39:29 CEST 2012


I just write a tool use plain c++.

> #include <iostream>
> #include <string>
> #include <fstream>
> #include <algorithm>
> #include <vector>
>
> int main(int argc, char *argv[])
> {
>     if (argc != 4) {
>         std::cerr << "Usage: replstr targetFile oldString newString" <<
> std::endl;
>         return EXIT_FAILURE;
>     }
>
>     const std::string targetFile(argv[1]);
>     const std::string oldString(argv[2]);
>     const std::string newString(argv[3]);
>     if (oldString.size() < newString.size()) {
>         std::cerr << "replstr: error: newString needs to be less than " <<
> oldString.size()
>                   << " characters." << std::endl;
>         std::cout << "Do you want force to fix? (y/n)" << std::endl;
>         std::string i;
>         std::cin >> i;
>         if (i != "Y" && i != "y")
>             return EXIT_FAILURE;
>     }
>
>     std::fstream fs(targetFile, std::ios::in | std::ios::out |
> std::ios::binary);
>     if (!fs.is_open()) {
>         std::cerr << "replstr: error: file not found" << std::endl;
>         return EXIT_FAILURE;
>     } else {
>         std::cout << "TARGET: " << targetFile << std::endl;
>     }
>
>     fs.seekg(0, std::ios::end);
>     std::vector<char> buffer(static_cast<unsigned int>(fs.tellg()));
>     fs.seekg(0, std::ios::beg);
>     fs.read(&buffer.front(), buffer.size());
>
>     std::vector<char>::iterator iter = buffer.begin();
>     bool replaced = false;
>     for (; ;) {
>         iter = std::search(iter, buffer.end(), oldString.begin(),
> oldString.end());
>         if (iter == buffer.end())
>             break;
>         const char * const p = &buffer[iter - buffer.begin()];
>         std::cout << "OLD: ";
>         std::cout.write(p - 11, std::max(oldString.length(),
> newString.length()) + 11);
>         std::cout << std::endl;
>         iter = std::copy(newString.begin(), newString.end(), iter);
>         *iter = '\0';
>         std::cout << "NEW: ";
>         std::cout.write(p - 11, std::max(oldString.length(),
> newString.length()) + 11);
>         std::cout << std::endl;
>         replaced = true;
>     }
>
>     if (replaced) {
>         fs.seekp(0, std::ios::beg);
>         fs.write(&buffer.front(), buffer.size());
>     }
>     fs.close();
>     return 0;
> }
>
>
2012/4/26 1+1=2 <dbzhang800 at gmail.com>

> My fault, it has been removed  from QtCreator in July last year.
>
> As Andreas said, qtpatch.cpp can be found in installer framework.
>
> Debao
>
> On Wed, Apr 25, 2012 at 5:46 PM, cat fa <boost.subscribing at gmail.com>
> wrote:
> >
> >
> > 在 2012年4月26日 上午1:20,1+1=2 <dbzhang800 at gmail.com>写道:
> >
> >> In addition, a tool called qpatch is designed to do such a thing.
> >>
> >> Qpatch 's source code can be found in QtCreator's repository.
> >>
> >> src/tools/qpatch/qpatch.cpp
> >
> >
> > I didn't see it there. Moved to somewhere else?
>  >
> >>
> >> 2012/4/25 Thiago Macieira <thiago.macieira at intel.com>:
> >> > On quarta-feira, 25 de abril de 2012 18.50.01, Loaden wrote:
> >> >> There have any way to modify (replace)  the hard code paths built in
> >> >> QtCore5.dll ?
> >> >
> >> > Just edit the binary file with a binary editor. You'll notice that the
> >> > variables have 512 bytes of space, so it should be enough to change it
> >> > to
> >> > almost anything.
> >> >
> >> > --
> >> > Thiago Macieira - thiago.macieira (AT) intel.com
> >> >  Software Architect - Intel Open Source Technology Center
> >> >     Intel Sweden AB - Registration Number: 556189-6027
> >> >     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
> >> >
> >> > _______________________________________________
> >> > Development mailing list
> >> > Development at qt-project.org
> >> > http://lists.qt-project.org/mailman/listinfo/development
> >> >
> >> _______________________________________________
> >> Development mailing list
> >> Development at qt-project.org
> >> http://lists.qt-project.org/mailman/listinfo/development
> >
> >
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>



-- 
Please don't ask where I come from, It's a shame!
Best Regards
Yuchen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120430/02c6d4b8/attachment.html>


More information about the Development mailing list