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

Added various features #655

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 5 additions & 4 deletions tools/cxbe/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ int main(int argc, char *argv[])

bool bRetail;
uint32 dwTitleId = 0xFFFF0002;
uint32 dwRegions;
uint32 dwRegions = XBEIMAGE_GAME_REGION_NA | XBEIMAGE_GAME_REGION_JAPAN |
XBEIMAGE_GAME_REGION_RESTOFWORLD | XBEIMAGE_GAME_REGION_MANUFACTURING;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably belongs into the commit that introduced being able to specify the region flags.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah more leftovers from the incinerated commit

uint32 dwVersion;

const char *program = argv[0];
Expand Down Expand Up @@ -91,7 +92,7 @@ int main(int argc, char *argv[])
{
char titlechar[2];
unsigned titleno;
if (sscanf(szXbeTitleID, "%c%c-%u", &titlechar[0], &titlechar[1], &titleno) != 3)
if(sscanf(szXbeTitleID, "%c%c-%u", &titlechar[0], &titlechar[1], &titleno) != 3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formatting change does not belong here.

{
strncpy(szErrorMessage, "invalid TITLEID", ERROR_LEN);
goto cleanup;
Expand Down Expand Up @@ -192,8 +193,8 @@ int main(int argc, char *argv[])
LogoPtr = &logo;
}

Xbe *XbeFile =
new Xbe(ExeFile, szXbeTitle, dwTitleId, dwRegions, dwVersion, bRetail, LogoPtr, szDebugPath);
Xbe *XbeFile = new Xbe(
ExeFile, szXbeTitle, dwTitleId, dwRegions, dwVersion, bRetail, LogoPtr, szDebugPath);
Comment on lines +196 to +197
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formatting change does not belong here.


if(XbeFile->GetError() != 0)
{
Expand Down
9 changes: 7 additions & 2 deletions tools/cxbe/Xbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ static size_t BasenameOffset(const std::string &path)

// construct via Exe file object
Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, uint32 x_dwTitleID, uint32 x_dwRegions,
uint32 x_dwVersion, bool x_bRetail, const std::vector<uint08> *logo, const char *x_szDebugPath)
uint32 x_dwVersion, bool x_bRetail, const std::vector<uint08> *logo,
const char *x_szDebugPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formatting change does not belong here.

{
ConstructorInit();

Expand Down Expand Up @@ -394,7 +395,11 @@ Xbe::Xbe(class Exe *x_Exe, const char *x_szTitle, uint32 x_dwTitleID, uint32 x_d
(characteristics & IMAGE_SCN_CNT_CODE))
m_SectionHeader[v].dwFlags.bExecutable = true;

m_SectionHeader[v].dwFlags.bPreload = true;
char *name = (x_Exe->m_SectionHeader_longname[v].m_longname)
? x_Exe->m_SectionHeader_longname[v].m_longname
: (char *)x_Exe->m_SectionHeader[v].m_name;
m_SectionHeader[v].dwFlags.bPreload =
(strcmp(name, ".debug") && strncmp(name, ".debug_", 7));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just strncmp(name, ".debug", 6)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.debugTest is not a real debug section name while .debug is and anything starting with .debug_ is

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which .debugTest? That is not a section I've ever seen nxdk produce (and nothing else should because the dot prefix is reserved for system sections)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be user generated. I only did it for completeness and it's not like it would hurt performance terribly. The more performance-oriented option would be to check if the first 6 matched .debug and then check if the 7th was \0 or _

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be user generated

The dot prefix is reserved. I don't care about performance here as much as clean code.

}

m_SectionHeader[v].dwVirtualAddr =
Expand Down
3 changes: 2 additions & 1 deletion tools/cxbe/Xbe.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class Xbe : public Error
public:
// construct via Exe file object
Xbe(class Exe *x_Exe, const char *x_szTitle, uint32 x_dwTitleID, uint32 x_dwRegions,
uint32 x_dwVersion, bool x_bRetail, const std::vector<uint08> *logo = nullptr, const char *x_szDebugPath = nullptr);
uint32 x_dwVersion, bool x_bRetail, const std::vector<uint08> *logo = nullptr,
const char *x_szDebugPath = nullptr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formatting change does not belong here.


// deconstructor
~Xbe();
Expand Down