fixed bug #1083492 - resource editor unicode conversion is lossy
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4878 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
92229d0a82
commit
c037ecfeed
6 changed files with 143 additions and 87 deletions
|
@ -148,8 +148,14 @@ typedef WORD LANGID;
|
|||
# ifndef FIELD_OFFSET
|
||||
# define FIELD_OFFSET(t,f) ((LONG)&(((t*)0)->f))
|
||||
# endif
|
||||
# ifndef MAKEINTRESOURCEA
|
||||
# define MAKEINTRESOURCEA(i) ((LPSTR)((DWORD)((WORD)(i))))
|
||||
# endif
|
||||
# ifndef MAKEINTRESOURCEW
|
||||
# define MAKEINTRESOURCEW(i) ((LPWSTR)((DWORD)((WORD)(i))))
|
||||
# endif
|
||||
# ifndef MAKEINTRESOURCE
|
||||
# define MAKEINTRESOURCE(i) (LPSTR)((DWORD)((WORD)(i)))
|
||||
# define MAKEINTRESOURCE MAKEINTRESOURCEA
|
||||
# endif
|
||||
# ifndef IMAGE_FIRST_SECTION
|
||||
# define IMAGE_FIRST_SECTION(h) ( PIMAGE_SECTION_HEADER( (DWORD) h + \
|
||||
|
|
|
@ -151,7 +151,7 @@ CResourceEditor::~CResourceEditor() {
|
|||
|
||||
// Adds/Replaces/Removes a resource.
|
||||
// If lpData is 0 UpdateResource removes the resource.
|
||||
bool CResourceEditor::UpdateResource(char* szType, char* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize) {
|
||||
bool CResourceEditor::UpdateResourceW(WCHAR* szType, WCHAR* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize) {
|
||||
CResourceDirectory* nameDir = 0;
|
||||
CResourceDirectory* langDir = 0;
|
||||
CResourceDataEntry* data = 0;
|
||||
|
@ -191,7 +191,7 @@ bool CResourceEditor::UpdateResource(char* szType, char* szName, LANGID wLanguag
|
|||
if (!data) {
|
||||
// Language doesn't yet exist, hence data nither
|
||||
data = new CResourceDataEntry(lpData, dwSize);
|
||||
langDir->AddEntry(new CResourceDirectoryEntry(MAKEINTRESOURCE(wLanguage), data));
|
||||
langDir->AddEntry(new CResourceDirectoryEntry(MAKEINTRESOURCEW(wLanguage), data));
|
||||
}
|
||||
}
|
||||
else if (data) {
|
||||
|
@ -212,21 +212,66 @@ bool CResourceEditor::UpdateResource(char* szType, char* szName, LANGID wLanguag
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CResourceEditor::UpdateResource(WORD szType, char* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize) {
|
||||
return UpdateResource(MAKEINTRESOURCE(szType), szName, wLanguage, lpData, dwSize);
|
||||
static WCHAR* CreateUnicodeString(const char* szString) {
|
||||
int iLen = MultiByteToWideChar(CP_ACP, 0, szString, -1, 0, 0);
|
||||
if (iLen == 0)
|
||||
throw runtime_error("Unicode conversion failed");
|
||||
|
||||
WCHAR* szwString = new WCHAR[iLen + 1];
|
||||
|
||||
if (MultiByteToWideChar(CP_ACP, 0, szString, -1, szwString, iLen + 1) == 0)
|
||||
throw runtime_error("Unicode conversion failed");
|
||||
|
||||
return szwString;
|
||||
}
|
||||
|
||||
bool CResourceEditor::UpdateResource(char* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize) {
|
||||
return UpdateResource(szType, MAKEINTRESOURCE(szName), wLanguage, lpData, dwSize);
|
||||
static WCHAR* ResStringToUnicode(const char *szString) {
|
||||
if (IS_INTRESOURCE(szString))
|
||||
return MAKEINTRESOURCEW(szString);
|
||||
else
|
||||
return CreateUnicodeString(szString);
|
||||
}
|
||||
|
||||
static void FreeUnicodeResString(WCHAR* szwString) {
|
||||
if (!IS_INTRESOURCE(szwString))
|
||||
delete [] szwString;
|
||||
}
|
||||
|
||||
bool CResourceEditor::UpdateResourceW(WORD szType, WCHAR* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize) {
|
||||
return UpdateResourceW(MAKEINTRESOURCEW(szType), szName, wLanguage, lpData, dwSize);
|
||||
}
|
||||
|
||||
bool CResourceEditor::UpdateResourceW(WCHAR* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize) {
|
||||
return UpdateResourceW(szType, MAKEINTRESOURCEW(szName), wLanguage, lpData, dwSize);
|
||||
}
|
||||
|
||||
bool CResourceEditor::UpdateResourceA(char* szType, char* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize) {
|
||||
WCHAR* szwType = ResStringToUnicode(szType);
|
||||
WCHAR* szwName = ResStringToUnicode(szName);
|
||||
|
||||
bool result = UpdateResourceW(szwType, szwName, wLanguage, lpData, dwSize);
|
||||
|
||||
FreeUnicodeResString(szwType);
|
||||
FreeUnicodeResString(szwName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CResourceEditor::UpdateResourceA(WORD szType, char* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize) {
|
||||
return UpdateResourceA(MAKEINTRESOURCE(szType), szName, wLanguage, lpData, dwSize);
|
||||
}
|
||||
|
||||
bool CResourceEditor::UpdateResourceA(char* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize) {
|
||||
return UpdateResourceA(szType, MAKEINTRESOURCE(szName), wLanguage, lpData, dwSize);
|
||||
}
|
||||
|
||||
bool CResourceEditor::UpdateResource(WORD szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize) {
|
||||
return UpdateResource(MAKEINTRESOURCE(szType), MAKEINTRESOURCE(szName), wLanguage, lpData, dwSize);
|
||||
return UpdateResourceW(MAKEINTRESOURCEW(szType), MAKEINTRESOURCEW(szName), wLanguage, lpData, dwSize);
|
||||
}
|
||||
|
||||
// Returns a copy of the requested resource
|
||||
// Returns 0 if the requested resource can't be found
|
||||
BYTE* CResourceEditor::GetResource(char* szType, char* szName, LANGID wLanguage) {
|
||||
BYTE* CResourceEditor::GetResourceW(WCHAR* szType, WCHAR* szName, LANGID wLanguage) {
|
||||
CResourceDirectory* nameDir = 0;
|
||||
CResourceDirectory* langDir = 0;
|
||||
CResourceDataEntry* data = 0;
|
||||
|
@ -255,9 +300,21 @@ BYTE* CResourceEditor::GetResource(char* szType, char* szName, LANGID wLanguage)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
BYTE* CResourceEditor::GetResourceA(char* szType, char* szName, LANGID wLanguage) {
|
||||
WCHAR* szwType = ResStringToUnicode(szType);
|
||||
WCHAR* szwName = ResStringToUnicode(szName);
|
||||
|
||||
BYTE* result = GetResourceW(szwType, szwName, wLanguage);
|
||||
|
||||
FreeUnicodeResString(szwType);
|
||||
FreeUnicodeResString(szwName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Returns the size of the requested resource
|
||||
// Returns -1 if the requested resource can't be found
|
||||
int CResourceEditor::GetResourceSize(char* szType, char* szName, LANGID wLanguage) {
|
||||
int CResourceEditor::GetResourceSize(WCHAR* szType, WCHAR* szName, LANGID wLanguage) {
|
||||
CResourceDirectory* nameDir = 0;
|
||||
CResourceDirectory* langDir = 0;
|
||||
CResourceDataEntry* data = 0;
|
||||
|
@ -462,7 +519,7 @@ bool CResourceEditor::AddExtraVirtualSize2PESection(const char* pszSectionName,
|
|||
CResourceDirectory* CResourceEditor::ScanDirectory(PRESOURCE_DIRECTORY rdRoot, PRESOURCE_DIRECTORY rdToScan) {
|
||||
// Create CResourceDirectory from rdToScan
|
||||
CResourceDirectory* rdc = new CResourceDirectory(PIMAGE_RESOURCE_DIRECTORY(rdToScan));
|
||||
char* szName;
|
||||
WCHAR* szName;
|
||||
PIMAGE_RESOURCE_DATA_ENTRY rde = NULL;
|
||||
|
||||
// Go through all entries of this resource directory
|
||||
|
@ -482,16 +539,14 @@ CResourceDirectory* CResourceEditor::ScanDirectory(PRESOURCE_DIRECTORY rdRoot, P
|
|||
if (rd.NameString.NameIsString) {
|
||||
PIMAGE_RESOURCE_DIR_STRING_U rds = PIMAGE_RESOURCE_DIR_STRING_U(rd.NameString.NameOffset + (char*)rdRoot);
|
||||
|
||||
int mbsSize = WideCharToMultiByte(CP_ACP, 0, rds->NameString, ConvertEndianness(rds->Length), 0, 0, 0, 0);
|
||||
szName = new char[mbsSize+1];
|
||||
if (!WideCharToMultiByte(CP_ACP, 0, rds->NameString, ConvertEndianness(rds->Length), szName, mbsSize, 0, 0)) {
|
||||
throw runtime_error("Unicode conversion failed");
|
||||
}
|
||||
szName[mbsSize] = 0;
|
||||
size_t nameSize = ConvertEndianness(rds->Length);
|
||||
szName = new WCHAR[nameSize+1];
|
||||
wcsncpy(szName, rds->NameString, nameSize);
|
||||
szName[nameSize] = 0;
|
||||
}
|
||||
// Else, set the name to this entry's id
|
||||
else
|
||||
szName = MAKEINTRESOURCE(ConvertEndianness(rdToScan->Entries[i].Id));
|
||||
szName = MAKEINTRESOURCEW(ConvertEndianness(rdToScan->Entries[i].Id));
|
||||
|
||||
if (rd.DirectoryOffset.DataIsDirectory)
|
||||
rdc->AddEntry(
|
||||
|
@ -594,18 +649,12 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
|
|||
|
||||
PMY_IMAGE_RESOURCE_DIRECTORY_ENTRY(cRDirE->m_dwWrittenAt)->NameString.NameOffset = ConvertEndianness(DWORD(seeker) - DWORD(pbRsrcSec));
|
||||
|
||||
char* szName = cRDirE->GetName();
|
||||
WORD iLen = strlen(szName) + 1;
|
||||
WCHAR *szwName = new WCHAR[iLen];
|
||||
|
||||
// MultiByteToWideChar return value includes the null char, so -1
|
||||
iLen = MultiByteToWideChar(CP_ACP, 0, szName, iLen, szwName, iLen) - 1;
|
||||
if (iLen == (WORD) -1)
|
||||
throw runtime_error("Unicode conversion failed");
|
||||
WCHAR* szName = cRDirE->GetName();
|
||||
WORD iLen = wcslen(szName) + 1;
|
||||
|
||||
*(WORD*)seeker = ConvertEndianness(iLen);
|
||||
seeker += sizeof(WORD);
|
||||
CopyMemory(seeker, szwName, iLen*sizeof(WCHAR));
|
||||
CopyMemory(seeker, szName, iLen*sizeof(WCHAR));
|
||||
seeker += iLen*sizeof(WCHAR);
|
||||
|
||||
// Even though the number of chars is predefined a null termination is required
|
||||
|
@ -613,7 +662,6 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
|
|||
seeker += sizeof(WORD);
|
||||
|
||||
delete [] szName;
|
||||
delete [] szwName;
|
||||
|
||||
qStrings.pop();
|
||||
}
|
||||
|
@ -711,10 +759,10 @@ CResourceDirectoryEntry* CResourceDirectory::GetEntry(unsigned int i) {
|
|||
void CResourceDirectory::AddEntry(CResourceDirectoryEntry* entry) {
|
||||
int i = 0;
|
||||
if (entry->HasName()) {
|
||||
char* szEntName = entry->GetName();
|
||||
WCHAR* szEntName = entry->GetName();
|
||||
for (i = 0; i < m_rdDir.NumberOfNamedEntries; i++) {
|
||||
char* szName = m_vEntries[i]->GetName();
|
||||
int cmp = strcmp(szName, szEntName);
|
||||
WCHAR* szName = m_vEntries[i]->GetName();
|
||||
int cmp = wcscmp(szName, szEntName);
|
||||
delete [] szName;
|
||||
if (cmp == 0) {
|
||||
delete [] szEntName;
|
||||
|
@ -754,19 +802,19 @@ int CResourceDirectory::CountEntries() {
|
|||
// Returns the index of a directory entry with the specified name
|
||||
// Name can be a string or an id
|
||||
// Returns -1 if can not be found
|
||||
int CResourceDirectory::Find(char* szName) {
|
||||
int CResourceDirectory::Find(WCHAR* szName) {
|
||||
if (IS_INTRESOURCE(szName))
|
||||
return Find((WORD) (DWORD) szName);
|
||||
else
|
||||
if (szName[0] == '#')
|
||||
return Find(WORD(atoi(szName + 1)));
|
||||
return Find(WORD(wcstol(szName + 1, NULL, 10)));
|
||||
|
||||
for (unsigned int i = 0; i < m_vEntries.size(); i++) {
|
||||
if (!m_vEntries[i]->HasName())
|
||||
continue;
|
||||
|
||||
char* szEntName = m_vEntries[i]->GetName();
|
||||
int cmp = strcmp(szName, szEntName);
|
||||
WCHAR* szEntName = m_vEntries[i]->GetName();
|
||||
int cmp = wcscmp(szName, szEntName);
|
||||
delete [] szEntName;
|
||||
|
||||
if (!cmp)
|
||||
|
@ -830,7 +878,7 @@ void CResourceDirectory::Destroy() {
|
|||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CResourceDirectoryEntry::CResourceDirectoryEntry(char* szName, CResourceDirectory* rdSubDir) {
|
||||
CResourceDirectoryEntry::CResourceDirectoryEntry(WCHAR* szName, CResourceDirectory* rdSubDir) {
|
||||
if (IS_INTRESOURCE(szName)) {
|
||||
m_bHasName = false;
|
||||
m_szName = 0;
|
||||
|
@ -838,14 +886,14 @@ CResourceDirectoryEntry::CResourceDirectoryEntry(char* szName, CResourceDirector
|
|||
}
|
||||
else {
|
||||
m_bHasName = true;
|
||||
m_szName = new char[strlen(szName)+1];
|
||||
strcpy(m_szName, szName);
|
||||
m_szName = new WCHAR[wcslen(szName)+1];
|
||||
wcscpy(m_szName, szName);
|
||||
}
|
||||
m_bIsDataDirectory = true;
|
||||
m_rdSubDir = rdSubDir;
|
||||
}
|
||||
|
||||
CResourceDirectoryEntry::CResourceDirectoryEntry(char* szName, CResourceDataEntry* rdeData) {
|
||||
CResourceDirectoryEntry::CResourceDirectoryEntry(WCHAR* szName, CResourceDataEntry* rdeData) {
|
||||
if (IS_INTRESOURCE(szName)) {
|
||||
m_bHasName = false;
|
||||
m_szName = 0;
|
||||
|
@ -853,8 +901,8 @@ CResourceDirectoryEntry::CResourceDirectoryEntry(char* szName, CResourceDataEntr
|
|||
}
|
||||
else {
|
||||
m_bHasName = true;
|
||||
m_szName = new char[strlen(szName)+1];
|
||||
strcpy(m_szName, szName);
|
||||
m_szName = new WCHAR[wcslen(szName)+1];
|
||||
wcscpy(m_szName, szName);
|
||||
}
|
||||
m_bIsDataDirectory = false;
|
||||
m_rdeData = rdeData;
|
||||
|
@ -874,17 +922,17 @@ bool CResourceDirectoryEntry::HasName() {
|
|||
}
|
||||
|
||||
// Don't forget to free the memory used by the string after usage!
|
||||
char* CResourceDirectoryEntry::GetName() {
|
||||
WCHAR* CResourceDirectoryEntry::GetName() {
|
||||
if (!m_bHasName)
|
||||
return 0;
|
||||
char* szName = 0;
|
||||
szName = new char[strlen(m_szName)+1];
|
||||
strcpy(szName, m_szName);
|
||||
WCHAR* szName = 0;
|
||||
szName = new WCHAR[wcslen(m_szName)+1];
|
||||
wcscpy(szName, m_szName);
|
||||
return szName;
|
||||
}
|
||||
|
||||
int CResourceDirectoryEntry::GetNameLength() {
|
||||
return strlen(m_szName);
|
||||
return wcslen(m_szName);
|
||||
}
|
||||
|
||||
WORD CResourceDirectoryEntry::GetId() {
|
||||
|
|
|
@ -107,12 +107,16 @@ public:
|
|||
CResourceEditor(BYTE* pbPE, int iSize);
|
||||
virtual ~CResourceEditor();
|
||||
|
||||
bool UpdateResource(char* szType, char* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||
bool UpdateResource(WORD szType, char* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||
bool UpdateResource(char* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||
bool UpdateResource(WORD szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||
BYTE* GetResource(char* szType, char* szName, LANGID wLanguage);
|
||||
int GetResourceSize(char* szType, char* szName, LANGID wLanguage);
|
||||
bool UpdateResourceW(WCHAR* szType, WCHAR* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||
bool UpdateResourceW(WORD szType, WCHAR* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||
bool UpdateResourceW(WCHAR* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||
bool UpdateResourceA(char* szType, char* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||
bool UpdateResourceA(WORD szType, char* szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||
bool UpdateResourceA(char* szType, WORD szName, LANGID wLanguage, BYTE* lpData, DWORD dwSize);
|
||||
BYTE* GetResourceW(WCHAR* szType, WCHAR* szName, LANGID wLanguage);
|
||||
BYTE* GetResourceA(char* szType, char* szName, LANGID wLanguage);
|
||||
int GetResourceSize(WCHAR* szType, WCHAR* szName, LANGID wLanguage);
|
||||
void FreeResource(BYTE* pbResource);
|
||||
|
||||
bool AddExtraVirtualSize2PESection(const char* pszSectionName, int addsize);
|
||||
|
@ -160,7 +164,7 @@ public:
|
|||
void AddEntry(CResourceDirectoryEntry* entry);
|
||||
void RemoveEntry(int i);
|
||||
int CountEntries();
|
||||
int Find(char* szName);
|
||||
int Find(WCHAR* szName);
|
||||
int Find(WORD wId);
|
||||
|
||||
DWORD GetSize();
|
||||
|
@ -176,12 +180,12 @@ private:
|
|||
|
||||
class CResourceDirectoryEntry {
|
||||
public:
|
||||
CResourceDirectoryEntry(char* szName, CResourceDirectory* rdSubDir);
|
||||
CResourceDirectoryEntry(char* szName, CResourceDataEntry* rdeData);
|
||||
CResourceDirectoryEntry(WCHAR* szName, CResourceDirectory* rdSubDir);
|
||||
CResourceDirectoryEntry(WCHAR* szName, CResourceDataEntry* rdeData);
|
||||
virtual ~CResourceDirectoryEntry();
|
||||
|
||||
bool HasName();
|
||||
char* GetName();
|
||||
WCHAR* GetName();
|
||||
int GetNameLength();
|
||||
|
||||
WORD GetId();
|
||||
|
@ -195,10 +199,8 @@ public:
|
|||
|
||||
private:
|
||||
bool m_bHasName;
|
||||
union {
|
||||
char* m_szName;
|
||||
WORD m_wId;
|
||||
};
|
||||
WCHAR* m_szName;
|
||||
WORD m_wId;
|
||||
|
||||
bool m_bIsDataDirectory;
|
||||
union {
|
||||
|
|
|
@ -1613,7 +1613,7 @@ int CEXEBuild::AddVersionInfo()
|
|||
warning("Generating version information for language \"%04d-%s\" without standard key \"LegalCopyright\"", lang_id, lang_name);
|
||||
|
||||
rVersionInfo.ExportToStream(VerInfoStream, i);
|
||||
res_editor->UpdateResource(RT_VERSION, 1, lang_id, (BYTE*)VerInfoStream.get(), VerInfoStream.getlen());
|
||||
res_editor->UpdateResourceA(RT_VERSION, 1, lang_id, (BYTE*)VerInfoStream.get(), VerInfoStream.getlen());
|
||||
}
|
||||
}
|
||||
catch (exception& err) {
|
||||
|
@ -1952,7 +1952,7 @@ again:
|
|||
SCRIPT_MSG("Done!\n");
|
||||
|
||||
#define REMOVE_ICON(id) if (disable_window_icon) { \
|
||||
BYTE* dlg = res_editor->GetResource(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG); \
|
||||
BYTE* dlg = res_editor->GetResourceA(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG); \
|
||||
if (dlg) { \
|
||||
CDialogTemplate dt(dlg,uDefCodePage); \
|
||||
res_editor->FreeResource(dlg); \
|
||||
|
@ -1970,7 +1970,7 @@ again:
|
|||
\
|
||||
DWORD dwSize; \
|
||||
dlg = dt.Save(dwSize); \
|
||||
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG, dlg, dwSize); \
|
||||
res_editor->UpdateResourceA(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG, dlg, dwSize); \
|
||||
delete [] dlg; \
|
||||
} \
|
||||
} \
|
||||
|
@ -1981,43 +1981,43 @@ again:
|
|||
init_res_editor();
|
||||
#ifdef NSIS_CONFIG_LICENSEPAGE
|
||||
if (!license_normal) {
|
||||
res_editor->UpdateResource(RT_DIALOG, IDD_LICENSE, NSIS_DEFAULT_LANG, 0, 0);
|
||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_LICENSE, NSIS_DEFAULT_LANG, 0, 0);
|
||||
}
|
||||
else REMOVE_ICON(IDD_LICENSE);
|
||||
if (!license_fsrb) {
|
||||
res_editor->UpdateResource(RT_DIALOG, IDD_LICENSE_FSRB, NSIS_DEFAULT_LANG, 0, 0);
|
||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_LICENSE_FSRB, NSIS_DEFAULT_LANG, 0, 0);
|
||||
}
|
||||
else REMOVE_ICON(IDD_LICENSE_FSRB);
|
||||
if (!license_fscb) {
|
||||
res_editor->UpdateResource(RT_DIALOG, IDD_LICENSE_FSCB, NSIS_DEFAULT_LANG, 0, 0);
|
||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_LICENSE_FSCB, NSIS_DEFAULT_LANG, 0, 0);
|
||||
}
|
||||
else REMOVE_ICON(IDD_LICENSE_FSCB);
|
||||
#endif // NSIS_CONFIG_LICENSEPAGE
|
||||
#ifdef NSIS_CONFIG_COMPONENTPAGE
|
||||
if (!selcom) {
|
||||
res_editor->UpdateResource(RT_DIALOG, IDD_SELCOM, NSIS_DEFAULT_LANG, 0, 0);
|
||||
res_editor->UpdateResource(RT_BITMAP, IDB_BITMAP1, NSIS_DEFAULT_LANG, 0, 0);
|
||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_SELCOM, NSIS_DEFAULT_LANG, 0, 0);
|
||||
res_editor->UpdateResourceA(RT_BITMAP, IDB_BITMAP1, NSIS_DEFAULT_LANG, 0, 0);
|
||||
}
|
||||
else REMOVE_ICON(IDD_SELCOM);
|
||||
#endif // NSIS_CONFIG_COMPONENTPAGE
|
||||
if (!dir) {
|
||||
res_editor->UpdateResource(RT_DIALOG, IDD_DIR, NSIS_DEFAULT_LANG, 0, 0);
|
||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_DIR, NSIS_DEFAULT_LANG, 0, 0);
|
||||
}
|
||||
else REMOVE_ICON(IDD_DIR);
|
||||
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||
if (!uninstconfirm) {
|
||||
res_editor->UpdateResource(RT_DIALOG, IDD_UNINST, NSIS_DEFAULT_LANG, 0, 0);
|
||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_UNINST, NSIS_DEFAULT_LANG, 0, 0);
|
||||
}
|
||||
else REMOVE_ICON(IDD_UNINST);
|
||||
#endif // NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||
if (!instlog) {
|
||||
res_editor->UpdateResource(RT_DIALOG, IDD_INSTFILES, NSIS_DEFAULT_LANG, 0, 0);
|
||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_INSTFILES, NSIS_DEFAULT_LANG, 0, 0);
|
||||
}
|
||||
else REMOVE_ICON(IDD_INSTFILES);
|
||||
if (!main) {
|
||||
res_editor->UpdateResource(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG, 0, 0);
|
||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG, 0, 0);
|
||||
if (!build_compress_whole && !build_crcchk)
|
||||
res_editor->UpdateResource(RT_DIALOG, IDD_VERIFY, NSIS_DEFAULT_LANG, 0, 0);
|
||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_VERIFY, NSIS_DEFAULT_LANG, 0, 0);
|
||||
}
|
||||
|
||||
SCRIPT_MSG("Done!\n");
|
||||
|
@ -2143,7 +2143,7 @@ int CEXEBuild::SetManifest()
|
|||
if (manifest == "")
|
||||
return PS_OK;
|
||||
|
||||
res_editor->UpdateResource(MAKEINTRESOURCE(24), MAKEINTRESOURCE(1), NSIS_DEFAULT_LANG, (LPBYTE) manifest.c_str(), manifest.length());
|
||||
res_editor->UpdateResourceA(MAKEINTRESOURCE(24), MAKEINTRESOURCE(1), NSIS_DEFAULT_LANG, (LPBYTE) manifest.c_str(), manifest.length());
|
||||
}
|
||||
catch (exception& err) {
|
||||
ERROR_MSG("Error while setting manifest: %s\n", err.what());
|
||||
|
|
|
@ -512,14 +512,14 @@ int CEXEBuild::GenerateLangTables() {
|
|||
init_res_editor();
|
||||
|
||||
#define ADD_FONT(id) { \
|
||||
BYTE* dlg = res_editor->GetResource(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG); \
|
||||
BYTE* dlg = res_editor->GetResourceA(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG); \
|
||||
if (dlg) { \
|
||||
CDialogTemplate td(dlg); \
|
||||
res_editor->FreeResource(dlg); \
|
||||
td.SetFont(build_font, build_font_size); \
|
||||
DWORD dwSize; \
|
||||
dlg = td.Save(dwSize); \
|
||||
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG, dlg, dwSize); \
|
||||
res_editor->UpdateResourceA(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG, dlg, dwSize); \
|
||||
delete [] dlg; \
|
||||
} \
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ int CEXEBuild::GenerateLangTables() {
|
|||
init_res_editor();
|
||||
|
||||
#define ADD_FONT(id) { \
|
||||
BYTE* dlg = res_editor->GetResource(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG); \
|
||||
BYTE* dlg = res_editor->GetResourceA(RT_DIALOG, MAKEINTRESOURCE(id), NSIS_DEFAULT_LANG); \
|
||||
if (dlg) { \
|
||||
CDialogTemplate td(dlg,lt[i].nlf.m_uCodePage); \
|
||||
res_editor->FreeResource(dlg); \
|
||||
|
@ -582,7 +582,7 @@ int CEXEBuild::GenerateLangTables() {
|
|||
} \
|
||||
DWORD dwSize; \
|
||||
dlg = td.Save(dwSize); \
|
||||
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(id+cur_offset), NSIS_DEFAULT_LANG, dlg, dwSize); \
|
||||
res_editor->UpdateResourceA(RT_DIALOG, MAKEINTRESOURCE(id+cur_offset), NSIS_DEFAULT_LANG, dlg, dwSize); \
|
||||
delete [] dlg; \
|
||||
} \
|
||||
}
|
||||
|
|
|
@ -2105,7 +2105,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
try {
|
||||
init_res_editor();
|
||||
|
||||
BYTE* dlg = res_editor->GetResource(RT_DIALOG, MAKEINTRESOURCE(IDD_INSTFILES), NSIS_DEFAULT_LANG);
|
||||
BYTE* dlg = res_editor->GetResourceA(RT_DIALOG, MAKEINTRESOURCE(IDD_INSTFILES), NSIS_DEFAULT_LANG);
|
||||
if (!dlg) throw runtime_error("IDD_INSTFILES doesn't exist!");
|
||||
CDialogTemplate dt(dlg,uDefCodePage);
|
||||
free(dlg);
|
||||
|
@ -2121,7 +2121,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
|
||||
DWORD dwSize;
|
||||
dlg = dt.Save(dwSize);
|
||||
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(IDD_INSTFILES), NSIS_DEFAULT_LANG, dlg, dwSize);
|
||||
res_editor->UpdateResourceA(RT_DIALOG, MAKEINTRESOURCE(IDD_INSTFILES), NSIS_DEFAULT_LANG, dlg, dwSize);
|
||||
delete [] dlg;
|
||||
}
|
||||
catch (exception& err) {
|
||||
|
@ -2400,9 +2400,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
init_res_editor();
|
||||
|
||||
// Search for required items
|
||||
#define GET(x) dlg = uire->GetResource(RT_DIALOG, MAKEINTRESOURCE(x), 0); if (!dlg) return PS_ERROR; CDialogTemplate UIDlg(dlg, uDefCodePage);
|
||||
#define GET(x) dlg = uire->GetResourceA(RT_DIALOG, MAKEINTRESOURCE(x), 0); if (!dlg) return PS_ERROR; CDialogTemplate UIDlg(dlg, uDefCodePage);
|
||||
#define SEARCH(x) if (!UIDlg.GetItem(x)) {ERROR_MSG("Error: Can't find %s (%u) in the custom UI!\n", #x, x);delete [] dlg;delete uire;return PS_ERROR;}
|
||||
#define SAVE(x) dwSize = UIDlg.GetSize(); res_editor->UpdateResource(RT_DIALOG, x, NSIS_DEFAULT_LANG, dlg, dwSize); delete [] dlg;
|
||||
#define SAVE(x) dwSize = UIDlg.GetSize(); res_editor->UpdateResourceA(RT_DIALOG, x, NSIS_DEFAULT_LANG, dlg, dwSize); delete [] dlg;
|
||||
|
||||
LPBYTE dlg = NULL;
|
||||
|
||||
|
@ -2509,7 +2509,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
padding = line.gettoken_int(3);
|
||||
|
||||
init_res_editor();
|
||||
BYTE* dlg = res_editor->GetResource(RT_DIALOG, MAKEINTRESOURCE(IDD_INST), NSIS_DEFAULT_LANG);
|
||||
BYTE* dlg = res_editor->GetResourceA(RT_DIALOG, MAKEINTRESOURCE(IDD_INST), NSIS_DEFAULT_LANG);
|
||||
|
||||
CDialogTemplate dt(dlg, uDefCodePage);
|
||||
|
||||
|
@ -2557,7 +2557,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
DWORD dwDlgSize;
|
||||
dlg = dt.Save(dwDlgSize);
|
||||
|
||||
res_editor->UpdateResource(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG, dlg, dwDlgSize);
|
||||
res_editor->UpdateResourceA(RT_DIALOG, IDD_INST, NSIS_DEFAULT_LANG, dlg, dwDlgSize);
|
||||
|
||||
delete [] dlg;
|
||||
|
||||
|
@ -3409,7 +3409,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
if (trim) try {
|
||||
init_res_editor();
|
||||
|
||||
BYTE* dlg = res_editor->GetResource(RT_DIALOG, MAKEINTRESOURCE(IDD_INST), NSIS_DEFAULT_LANG);
|
||||
BYTE* dlg = res_editor->GetResourceA(RT_DIALOG, MAKEINTRESOURCE(IDD_INST), NSIS_DEFAULT_LANG);
|
||||
CDialogTemplate td(dlg,uDefCodePage);
|
||||
free(dlg);
|
||||
|
||||
|
@ -3436,7 +3436,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
|
||||
DWORD dwSize;
|
||||
dlg = td.Save(dwSize);
|
||||
res_editor->UpdateResource(RT_DIALOG, MAKEINTRESOURCE(IDD_INST), NSIS_DEFAULT_LANG, dlg, dwSize);
|
||||
res_editor->UpdateResourceA(RT_DIALOG, MAKEINTRESOURCE(IDD_INST), NSIS_DEFAULT_LANG, dlg, dwSize);
|
||||
res_editor->FreeResource(dlg);
|
||||
}
|
||||
catch (exception& err) {
|
||||
|
@ -4707,8 +4707,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
try
|
||||
{
|
||||
CResourceEditor *dllre = new CResourceEditor(dll, len);
|
||||
LPBYTE ver = dllre->GetResource(VS_FILE_INFO, MAKEINTRESOURCE(VS_VERSION_INFO), 0);
|
||||
int versize = dllre->GetResourceSize(VS_FILE_INFO, MAKEINTRESOURCE(VS_VERSION_INFO), 0);
|
||||
LPBYTE ver = dllre->GetResourceA(VS_FILE_INFO, MAKEINTRESOURCE(VS_VERSION_INFO), 0);
|
||||
int versize = dllre->GetResourceASize(VS_FILE_INFO, MAKEINTRESOURCE(VS_VERSION_INFO), 0);
|
||||
|
||||
if (ver)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue