mirror of
https://github.com/Thesola10/umd-livepatch.git
synced 2025-04-19 22:13:22 +00:00
Add in-memory patch reading support
This commit is contained in:
parent
8f3dd9c61b
commit
21d43920da
@ -13,7 +13,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "usage.rl.h"
|
#include "usage.rl.h"
|
||||||
#include "rdiff.h"
|
#include "compare.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
umdiff_delta(char *source, char *target, char *output)
|
umdiff_delta(char *source, char *target, char *output)
|
||||||
@ -33,6 +33,7 @@ umdiff_delta(char *source, char *target, char *output)
|
|||||||
int
|
int
|
||||||
umdiff_patch(char *source, char *umdiff, char *output)
|
umdiff_patch(char *source, char *umdiff, char *output)
|
||||||
{
|
{
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,11 @@
|
|||||||
|
|
||||||
#include "umdiff.h"
|
#include "umdiff.h"
|
||||||
|
|
||||||
static long
|
#include <string.h>
|
||||||
|
|
||||||
|
static umdiff_File *current_file;
|
||||||
|
|
||||||
|
static int
|
||||||
_impl_umdiff_Command_read(umdiff_Command cmd, void *dest, long count, long offset,
|
_impl_umdiff_Command_read(umdiff_Command cmd, void *dest, long count, long offset,
|
||||||
umdiff_ReadCallback read_source,
|
umdiff_ReadCallback read_source,
|
||||||
umdiff_ReadCallback read_patchFile)
|
umdiff_ReadCallback read_patchFile)
|
||||||
@ -48,17 +52,40 @@ _impl_umdiff_File_readIndexCmds(umdiff_File *file, long offset_sector,
|
|||||||
file->last_index = index;
|
file->last_index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtual read callback for @ref umdiff_File with @ref umdiff_FileFlags_LOAD_FULL.
|
||||||
|
*
|
||||||
|
* Automatically set by @ref umdiff_File_readPatched as needed.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
_impl_umdiff_ReadCallback_fullFile(void *dest, long count, long offset)
|
||||||
|
{
|
||||||
|
// Undo relative-to-absolute translation from _impl_umdiff_Command_read
|
||||||
|
long ds = current_file->hdr.data_start;
|
||||||
|
long real_offset = offset - ds;
|
||||||
|
|
||||||
|
memcpy(dest, current_file->data + real_offset, count);
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
umdiff_File_readPatched(umdiff_File *file, void *dest, long count, long offset,
|
umdiff_File_readPatched(umdiff_File *file, void *dest, long count, long offset,
|
||||||
umdiff_ReadCallback read_source,
|
umdiff_ReadCallback read_source,
|
||||||
umdiff_ReadCallback read_patchFile)
|
umdiff_ReadCallback read_patchFile)
|
||||||
{
|
{
|
||||||
long res;
|
int res;
|
||||||
umdiff_Command *commands;
|
umdiff_Command *commands;
|
||||||
umdiff_Command *curCommand;
|
umdiff_Command *curCommand;
|
||||||
|
|
||||||
#define $offset_sectors (offset / ISO_SECTOR_SIZE)
|
#define $offset_sectors (offset / ISO_SECTOR_SIZE)
|
||||||
|
|
||||||
|
current_file = file;
|
||||||
|
|
||||||
|
if (file->mode == umdiff_FileFlags_LOAD_FULL) {
|
||||||
|
read_patchFile = _impl_umdiff_ReadCallback_fullFile;
|
||||||
|
}
|
||||||
|
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
commands = _impl_umdiff_File_readIndexCmds(file, $offset_sectors,
|
commands = _impl_umdiff_File_readIndexCmds(file, $offset_sectors,
|
||||||
read_patchFile);
|
read_patchFile);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user