From 604371b98d3ad2472e96be8d126df92b2fcf68df Mon Sep 17 00:00:00 2001 From: lhauch Date: Thu, 5 Oct 2006 23:24:16 +0000 Subject: More moves for Tool Packages git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1676 6f19259b-4bc3-4df7-8a09-765794883524 --- Tools/CCode/Source/Strip/Strip.c | 105 +++++++++++++++++++++++++++++++++++++ Tools/CCode/Source/Strip/build.xml | 69 ++++++++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 Tools/CCode/Source/Strip/Strip.c create mode 100644 Tools/CCode/Source/Strip/build.xml (limited to 'Tools/CCode/Source/Strip') diff --git a/Tools/CCode/Source/Strip/Strip.c b/Tools/CCode/Source/Strip/Strip.c new file mode 100644 index 0000000000..bccdffb55a --- /dev/null +++ b/Tools/CCode/Source/Strip/Strip.c @@ -0,0 +1,105 @@ +/*++ + +Copyright (c) 2004-2006 Intel Corporation. All rights reserved +This program and the accompanying materials are licensed and made available +under the terms and conditions of the BSD License which accompanies this +distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + +Module Name: + + Strip.c + +Abstract: + + Quick Exe2Bin equivalent. + +--*/ + +#include +#include +#include +#include + +int +main ( + int argc, + char *argv[] + ) +/*++ + +Routine Description: + + Converts executable files to binary files. + +Arguments: + + argc - Number of command line arguments + argv[] - Array of pointers to the command line arguments + +Returns: + + Zero - Function completed successfully. + Non-zero - Function exited with errors. + +--*/ +{ + FILE *InFile; + FILE *OutFile; + int Index; + int FileSize; + char *Buffer; + char *Ptrx; + + if (argc < 3) { + printf ("Need more args, such as file name to convert and output name\n"); + return -1; + } + + InFile = fopen (argv[1], "rb"); + OutFile = fopen (argv[2], "wb"); + + if (!InFile) { + printf ("no file, exit\n"); + return -1; + } + + if (OutFile == NULL) { + printf ("Unable to open output file.\n"); + return -1; + } + + fseek (InFile, 0, SEEK_END); + FileSize = ftell (InFile); + + if (FileSize < 0x200) { + printf ("%d is not a legal size, exit\n", FileSize); + return -1; + } + + fseek (InFile, 0, SEEK_SET); + + Buffer = (char *) malloc (FileSize); + if (Buffer == NULL) { + printf ("Error: Out of resources.\n"); + return -1; + } + + fread (Buffer, 1, FileSize, InFile); + + Ptrx = Buffer + 0x200; + + Index = FileSize - 0x200; + + fwrite (Ptrx, Index, 1, OutFile); + + fclose (InFile); + fclose (OutFile); + free (Buffer); + + return 0; +} diff --git a/Tools/CCode/Source/Strip/build.xml b/Tools/CCode/Source/Strip/build.xml new file mode 100644 index 0000000000..9ead28d16f --- /dev/null +++ b/Tools/CCode/Source/Strip/build.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3