58 lines
2.2 KiB
C
58 lines
2.2 KiB
C
/* *****************************************************************************
|
|
* p7os/prepare.c -- p7os update.exe uploading utility.
|
|
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
|
|
*
|
|
* This file is part of p7utils.
|
|
* p7utils is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2.0 of the License,
|
|
* or (at your option) any later version.
|
|
*
|
|
* p7utils is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with p7utils; if not, see <http://www.gnu.org/licenses/>.
|
|
* ************************************************************************** */
|
|
#include "main.h"
|
|
|
|
/* ************************************************************************** */
|
|
/* Embedded update.exe */
|
|
/* ************************************************************************** */
|
|
#define cake_exe_str ((char*)&_binary_cake_exe_bin_start)
|
|
#define cake_exe_end ((char*)&_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)(cake_exe_end - cake_exe_str),
|
|
0x88030000, 0x88030000, disp);
|
|
fclose(uexe);
|
|
}
|
|
|
|
/* done! */
|
|
return (err);
|
|
}
|