mirror of
https://github.com/Alcaro/Flips.git
synced 2026-04-25 07:21:57 -05:00
Add manifest support to -I
This commit is contained in:
parent
ef813f6ce7
commit
37db058e14
45
flips.cpp
45
flips.cpp
|
|
@ -839,7 +839,7 @@ struct errorinfo CreatePatch(LPCWSTR inromname, LPCWSTR outromname, enum patchty
|
|||
return errinf;
|
||||
}
|
||||
|
||||
int patchinfo(LPCWSTR patchname)
|
||||
int patchinfo(LPCWSTR patchname, struct manifestinfo * manifestinfo)
|
||||
{
|
||||
GUIClaimConsole();
|
||||
|
||||
|
|
@ -860,6 +860,28 @@ int patchinfo(LPCWSTR patchname)
|
|||
return bpserrors[info.error].level;
|
||||
}
|
||||
|
||||
struct mem meta = {};
|
||||
if (info.meta_size)
|
||||
{
|
||||
meta.len = info.meta_size;
|
||||
meta.ptr = (uint8_t*)malloc(info.meta_size);
|
||||
patch->read(meta.ptr, info.meta_start, info.meta_size);
|
||||
|
||||
if (manifestinfo->required)
|
||||
{
|
||||
if (manifestinfo->name)
|
||||
{
|
||||
filewrite::write(manifestinfo->name, meta);
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite(meta.ptr, 1,meta.len, stdout);
|
||||
free(meta.ptr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LPCWSTR inromname = FindRomForPatch(patch, NULL);
|
||||
#ifdef FLIPS_WINDOWS
|
||||
#define z "I"
|
||||
|
|
@ -876,6 +898,25 @@ int patchinfo(LPCWSTR patchname)
|
|||
//Windows MulDiv could also work, but it's kinda nonportable.
|
||||
//printf("Change index: %i / 1000\n", (int)(info.change_num / (float)info.change_denom * 1000));
|
||||
|
||||
if (info.meta_size)
|
||||
{
|
||||
printf("Metadata: %" z "u bytes:\n", info.meta_size);
|
||||
char* meta_iter = (char*)meta.ptr;
|
||||
char* meta_end = meta_iter + meta.len;
|
||||
for (int i=0;i<3;i++)
|
||||
{
|
||||
int n_chars = meta_end-meta_iter;
|
||||
if (n_chars > 75) n_chars = 75;
|
||||
char* nextline = (char*)memchr(meta_iter, '\n', n_chars);
|
||||
if (nextline && nextline-meta_iter < n_chars) n_chars = nextline-meta_iter;
|
||||
if (!nextline && !n_chars) break; // wipe trailing linebreaks
|
||||
printf(" %.*s\n", n_chars, meta_iter);
|
||||
if (!nextline) break;
|
||||
meta_iter = nextline+1;
|
||||
}
|
||||
}
|
||||
|
||||
free(meta.ptr);
|
||||
return 0;
|
||||
}
|
||||
puts("No information available for this patch type");
|
||||
|
|
@ -1115,7 +1156,7 @@ int flipsmain(int argc, WCHAR * argv[])
|
|||
case a_info:
|
||||
{
|
||||
if (numargs!=1) usage();
|
||||
return patchinfo(arg[0]);
|
||||
return patchinfo(arg[0], &manifestinfo);
|
||||
}
|
||||
}
|
||||
return 99;//doesn't happen
|
||||
|
|
|
|||
2
global.h
2
global.h
|
|
@ -33,7 +33,7 @@ public:
|
|||
virtual size_t len() = 0;
|
||||
virtual bool read(uint8_t* target, size_t start, size_t len) = 0;
|
||||
|
||||
//these two add sizeof(WCHAR) 00s after the actual data, so you can cast it to LPCWSTR (assuming it's aligned)
|
||||
//these two add sizeof(WCHAR) 00s after the actual data, so you can cast it to LPCWSTR
|
||||
static struct mem read(LPCWSTR filename); // provided by Flips core
|
||||
struct mem read(); // provided by Flips core
|
||||
|
||||
|
|
|
|||
|
|
@ -410,6 +410,9 @@ struct bpsinfo bps_get_info(file* patch, bool changefrac)
|
|||
if (!decodenum(patchdat, ret.size_in)) error(bps_too_big);
|
||||
if (!decodenum(patchdat, ret.size_out)) error(bps_too_big);
|
||||
|
||||
if (!decodenum(patchdat, ret.meta_size)) error(bps_too_big);
|
||||
ret.meta_start = patchdat - top;
|
||||
|
||||
uint8_t checksums[12];
|
||||
if (!patch->read(checksums, len-12, 12)) error(bps_io);
|
||||
ret.crc_in = read32(checksums+0);
|
||||
|
|
|
|||
3
libbps.h
3
libbps.h
|
|
@ -74,6 +74,9 @@ struct bpsinfo {
|
|||
uint32_t crc_out;
|
||||
uint32_t crc_patch;
|
||||
|
||||
size_t meta_start;
|
||||
size_t meta_size;
|
||||
|
||||
//Tells approximately how much of the input ROM is changed compared to the output ROM.
|
||||
//It's quite heuristic. The algorithm may change with or without notice.
|
||||
//As of writing, I believe this is accurate to 2 significant digits in base 10.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user