cake
/
p7utils
Archived
1
0
Fork 0
This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
p7utils/src/p7os/prepare.c

49 lines
2.0 KiB
C

/* ************************************************************************** */
/* _____ _ */
/* p7os/prepare.c |_ _|__ _ _| |__ ___ _ _ */
/* | Project: p7utils | |/ _ \| | | | '_ \ / _ \ | | | */
/* | | (_) | |_| | | | | __/ |_| | */
/* By: thomas <thomas@touhey.fr> |_|\___/ \__,_|_| |_|\___|\__, |.fr */
/* Last updated: 2017/01/16 23:56:41 |___/ */
/* */
/* ************************************************************************** */
#include "main.h"
/* ************************************************************************** */
/* Embedded update.exe */
/* ************************************************************************** */
#define cake_exe_str (_binary_cake_exe_bin_start)
#define cake_exe_end (_binary_cake_exe_bin_end)
extern char _binary_cake_exe_bin_start[];
extern char _binary_cake_exe_bin_end[];
/* ************************************************************************** */
/* Main function */
/* ************************************************************************** */
/**
* prepare_ops:
* Prepare the operation, by uploading the update.exe.
*
* @arg handle the libp7 handle.
* @arg uexe the update.exe to use (NULL if use the embedded one).
* @return the error (-1 if not a libp7 error, 0 if ok)
*/
int prepare_ops(p7_handle_t *handle, FILE *uexe, p7_disp_t disp)
{
int err;
/* send the update.exe */
if (uexe)
err = p7_sendexe_file(handle, uexe, 0x88030000, 0x88030000, disp);
else {
err = p7_sendexe_mem(handle, cake_exe_str,
(size_t)((char*)&cake_exe_end - (char*)&cake_exe_str),
0x88030000, 0x88030000, disp);
fclose(uexe);
}
/* done! */
return (err);
}