extracted SetVarsSection

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4750 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2006-09-16 11:35:43 +00:00
parent 676158b826
commit f4bfa52981
2 changed files with 26 additions and 11 deletions

View file

@ -2091,6 +2091,28 @@ void CEXEBuild::PrepareHeaders(IGrowBuf *hdrbuf)
sink2.write_growbuf(&blocks_buf);
}
int CEXEBuild::SetVarsSection()
{
try {
init_res_editor();
VerifyDeclaredUserVarRefs(&m_UserVarNames);
int MaxUserVars = m_UserVarNames.getnum();
// -1 because the default size is 1
if (!res_editor->AddExtraVirtualSize2PESection(NSIS_VARS_SECTION, (MaxUserVars - 1) * sizeof(NSIS_STRING)))
{
ERROR_MSG("Internal compiler error #12346: invalid exehead cannot find section \"%s\"!\n", NSIS_VARS_SECTION);
return PS_ERROR;
}
}
catch (exception& err) {
ERROR_MSG("\nError: %s\n", err.what());
return PS_ERROR;
}
return PS_OK;
}
int CEXEBuild::check_write_output_errors() const
{
if (has_called_write_output)
@ -2248,18 +2270,10 @@ int CEXEBuild::write_output(void)
// Generate language tables
RET_UNLESS_OK( GenerateLangTables() );
// Setup user variables PE section
RET_UNLESS_OK( SetVarsSection() );
try {
init_res_editor();
VerifyDeclaredUserVarRefs(&m_UserVarNames);
int MaxUserVars = m_UserVarNames.getnum();
// -1 because the default size is 1
if (!res_editor->AddExtraVirtualSize2PESection(NSIS_VARS_SECTION, (MaxUserVars - 1) * sizeof(NSIS_STRING)))
{
ERROR_MSG("Internal compiler error #12346: invalid exehead cannot find section \"%s\"!\n", NSIS_VARS_SECTION);
return PS_ERROR;
}
// Save all changes to the exe header
close_res_editor();
}

View file

@ -216,6 +216,7 @@ class CEXEBuild {
int ProcessPages();
void PrepareInstTypes();
void PrepareHeaders(IGrowBuf *hdrbuf);
int SetVarsSection();
int resolve_jump_int(const char *fn, int *a, int offs, int start, int end);
int resolve_call_int(const char *fn, const char *str, int fptr, int *ofs);