COMMON: Add a function to simplify loading Windows executables
This commit is contained in:
parent
532f382602
commit
a692905eb2
3 changed files with 30 additions and 19 deletions
|
@ -24,6 +24,8 @@
|
|||
#include "common/memstream.h"
|
||||
#include "common/str.h"
|
||||
#include "common/winexe.h"
|
||||
#include "common/winexe_ne.h"
|
||||
#include "common/winexe_pe.h"
|
||||
|
||||
namespace Common {
|
||||
|
||||
|
@ -160,4 +162,25 @@ bool WinResources::loadFromCompressedEXE(const String &fileName) {
|
|||
return loadFromEXE(stream);
|
||||
}
|
||||
|
||||
|
||||
WinResources *WinResources::createFromEXE(const String &fileName) {
|
||||
WinResources *exe;
|
||||
|
||||
// First try loading via the NE code
|
||||
exe = new Common::NEResources();
|
||||
if (exe->loadFromEXE(fileName)) {
|
||||
return exe;
|
||||
}
|
||||
delete exe;
|
||||
|
||||
// Then try loading via the PE code
|
||||
exe = new Common::PEResources();
|
||||
if (exe->loadFromEXE(fileName)) {
|
||||
return exe;
|
||||
}
|
||||
delete exe;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // End of namespace Common
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue