+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> \r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
-\r
- Strip.c\r
-\r
-Abstract:\r
-\r
- Quick Exe2Bin equivalent.\r
-\r
---*/\r
-\r
-#include <stdio.h>\r
-#include <memory.h>\r
-#include <string.h>\r
-#include <malloc.h>\r
-\r
-#define UTILITY_NAME "Strip"\r
-#define UTILITY_VERSION "v1.0"\r
-\r
-static\r
-void\r
-Usage (\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Print usage information for this utility.\r
- \r
-Arguments:\r
-\r
- None.\r
-\r
-Returns:\r
-\r
- Nothing.\r
- \r
---*/\r
-{\r
- int Index;\r
- const char *Str[] = {\r
- UTILITY_NAME" "UTILITY_VERSION" - Intel Strip Utility",\r
- " Copyright (C), 2006 - 2008 Intel Corporation",\r
- \r
-#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
- " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
-#endif\r
- "",\r
- "Usage:",\r
- " "UTILITY_NAME" SOURCE DEST",\r
- "Description:",\r
- " Convert executable files to binary files.",\r
- NULL\r
- };\r
-\r
- for (Index = 0; Str[Index] != NULL; Index++) {\r
- fprintf (stdout, "%s\n", Str[Index]);\r
- }\r
-}\r
-\r
-int\r
-main (\r
- int argc,\r
- char *argv[]\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Converts executable files to binary files.\r
-\r
-Arguments:\r
-\r
- argc - Number of command line arguments\r
- argv[] - Array of pointers to the command line arguments\r
-\r
-Returns:\r
-\r
- Zero - Function completed successfully.\r
- Non-zero - Function exited with errors. \r
-\r
---*/\r
-{\r
- FILE *InFile;\r
- FILE *OutFile;\r
- int Index;\r
- int FileSize;\r
- char *Buffer;\r
- char *Ptrx;\r
-\r
- if (argc < 3) {\r
- Usage ();\r
- return -1;\r
- }\r
-\r
- InFile = fopen (argv[1], "rb");\r
- OutFile = fopen (argv[2], "wb");\r
-\r
- if (!InFile) {\r
- printf ("no file, exit\n");\r
- return -1;\r
- }\r
-\r
- if (OutFile == NULL) {\r
- printf ("Unable to open output file.\n");\r
- return -1;\r
- }\r
-\r
- fseek (InFile, 0, SEEK_END);\r
- FileSize = ftell (InFile);\r
-\r
- if (FileSize < 0x200) {\r
- printf ("%d is not a legal size, exit\n", FileSize);\r
- return -1;\r
- }\r
-\r
- fseek (InFile, 0, SEEK_SET);\r
-\r
- Buffer = malloc (FileSize);\r
- if (Buffer == NULL) {\r
- printf ("Error: Out of resources.\n");\r
- return -1;\r
- }\r
-\r
- fread (Buffer, 1, FileSize, InFile);\r
-\r
- Ptrx = Buffer + 0x200;\r
-\r
- Index = FileSize - 0x200;\r
-\r
- fwrite (Ptrx, Index, 1, OutFile);\r
-\r
- fclose (InFile);\r
- fclose (OutFile);\r
- free (Buffer);\r
-\r
- return 0;\r
-}\r