35 #include <locale>
36 #include <codecvt>
37
38 using namespace std;
39
40 /*
41 * [Property file] contains key/value pairs
42 * The swap tool uses these pairs to create new version resource
43 *
44 * See MSDN docs for VS_VERSIONINFO structure that
45 * depicts organization of data in this version resource
46 * https://msdn.microsoft.com/en-us/library/ms647001(v=vs.85).aspx
47 *
48 * The swap tool makes changes in [Executable file]
49 * The tool assumes that the executable file has no version resource
50 * and it adds new resource in the executable file.
51 * If the executable file has an existing version resource, then
52 * the existing version resource will be replaced with new one.
53 */
54
55 VersionInfoSwap::VersionInfoSwap(wstring executableProperties, wstring launcher) {
56 m_executableProperties = executableProperties;
57 m_launcher = launcher;
58 }
59
60 bool VersionInfoSwap::PatchExecutable() {
61 bool b = LoadFromPropertyFile();
62 if (!b) {
63 return false;
64 }
65
66 ByteBuffer buf;
67 b = CreateNewResource(&buf);
68 if (!b) {
69 return false;
70 }
71
72 b = this->UpdateResource(buf.getPtr(), static_cast<DWORD> (buf.getPos()));
73 if (!b) {
74 return false;
75 }
|
35 #include <locale>
36 #include <codecvt>
37
38 using namespace std;
39
40 /*
41 * [Property file] contains key/value pairs
42 * The swap tool uses these pairs to create new version resource
43 *
44 * See MSDN docs for VS_VERSIONINFO structure that
45 * depicts organization of data in this version resource
46 * https://msdn.microsoft.com/en-us/library/ms647001(v=vs.85).aspx
47 *
48 * The swap tool makes changes in [Executable file]
49 * The tool assumes that the executable file has no version resource
50 * and it adds new resource in the executable file.
51 * If the executable file has an existing version resource, then
52 * the existing version resource will be replaced with new one.
53 */
54
55 VersionInfoSwap::VersionInfoSwap(wstring executableProperties,
56 wstring launcher) {
57 m_executableProperties = executableProperties;
58 m_launcher = launcher;
59 }
60
61 bool VersionInfoSwap::PatchExecutable() {
62 bool b = LoadFromPropertyFile();
63 if (!b) {
64 return false;
65 }
66
67 ByteBuffer buf;
68 b = CreateNewResource(&buf);
69 if (!b) {
70 return false;
71 }
72
73 b = this->UpdateResource(buf.getPtr(), static_cast<DWORD> (buf.getPos()));
74 if (!b) {
75 return false;
76 }
|