Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct text code size #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions MagikoopaUI/patchmaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,15 @@ void PatchMaker::insert()
delete newCodeFile;

emit updateStatus("Fixing Exheader");
fixExheader(loaderDataEnd + m_hookLinker.extraDataSize() - m_newCodeOffset);
quint32 newTextCodeSize = loaderTextEnd + m_loaderHookLinker.extraDataSize() - 0x100000;
fixExheader(loaderDataEnd + m_hookLinker.extraDataSize() - m_newCodeOffset, newTextCodeSize);
}

void PatchMaker::fixExheader(quint32 newCodeSize)
void PatchMaker::fixExheader(quint32 newCodeSize, quint32 newTextCodeSize)
{
Exheader exHeader(new ExternalFile(m_path + "/exheader.bin"));

exHeader.data.sci.textCodeSetInfo.size = exHeader.data.sci.textCodeSetInfo.physicalRegionSize << 12;
exHeader.data.sci.textCodeSetInfo.size = newTextCodeSize;

qDebug() << QString("Data size: %1").arg(exHeader.data.sci.dataCodeSetInfo.physicalRegionSize << 12, 8, 0x10, QChar('0')).toLatin1().data();;
qDebug() << QString("BSS size: %1").arg(((exHeader.data.sci.bssSize + 0xFFF) & ~0xFFF), 8, 0x10, QChar('0')).toLatin1().data();;
Expand Down
2 changes: 1 addition & 1 deletion MagikoopaUI/patchmaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private slots:
void restoreFromBackup();

void insert();
void fixExheader(quint32 newCodeSize);
void fixExheader(quint32 newCodeSize, quint32 newTextCodeSize);
void postHook();
void allDone();

Expand Down