+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2004-2006 Intel Corporation. All rights reserved\r
-This program and the accompanying materials are licensed and made available\r
-under the terms and conditions of the BSD License which accompanies this\r
-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
-\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 <stdlib.h>\r
-\r
-#define UTILITY_NAME "Strip"\r
-#define UTILITY_MAJOR_VERSION 1\r
-#define UTILITY_MINOR_VERSION 1\r
-\r
-\r
-void \r
-Version(\r
- void\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Print out version information for Strip.\r
-\r
-Arguments:\r
-\r
- None\r
- \r
-Returns:\r
-\r
- None\r
- \r
---*/ \r
-{\r
- printf ("%s v%d.%d -EDK Utility to Convert EXE to BIN\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);\r
- printf ("Copyright (c) 2005-2006 Intel Corporation. All rights reserved.\n");\r
-}\r
-\r
-void \r
-Usage(\r
- void\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Print out usage information for Strip.\r
-\r
-Arguments:\r
-\r
- None\r
- \r
-Returns:\r
-\r
- None\r
- \r
---*/ \r
-{\r
- Version();\r
- printf ("\nUsage: %s InputFile OutputFile\n", UTILITY_NAME);\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 == 1) {\r
- Usage();\r
- return -1;\r
- }\r
- \r
- if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||\r
- (strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {\r
- Usage();\r
- return 0;\r
- }\r
- \r
- if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) {\r
- Version();\r
- return 0;\r
- }\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 ("Unable to open input file, exit\n");\r
- return -1;\r
- }\r
-\r
- if (OutFile == NULL) {\r
- printf ("Unable to open output file, exit.\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 file size, exit\n", FileSize);\r
- return -1;\r
- }\r
-\r
- fseek (InFile, 0, SEEK_SET);\r
-\r
- Buffer = (char *) 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