]>
Commit | Line | Data |
---|---|---|
d25c4bf0 | 1 | /*++\r |
2 | \r | |
cf171110 | 3 | Copyright (c) 2004-2006 Intel Corporation. All rights reserved\r |
56fe62ce | 4 | This program and the accompanying materials are licensed and made available\r |
5 | under the terms and conditions of the BSD License which accompanies this\r | |
6 | distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
d25c4bf0 | 12 | \r |
d25c4bf0 | 13 | Module Name:\r |
14 | \r | |
15 | Strip.c\r | |
16 | \r | |
17 | Abstract:\r | |
18 | \r | |
19 | Quick Exe2Bin equivalent.\r | |
20 | \r | |
21 | --*/\r | |
22 | \r | |
23 | #include <stdio.h>\r | |
24 | #include <memory.h>\r | |
25 | #include <string.h>\r | |
9776330c | 26 | #include <stdlib.h>\r |
d25c4bf0 | 27 | \r |
28 | int\r | |
29 | main (\r | |
30 | int argc,\r | |
31 | char *argv[]\r | |
32 | )\r | |
33 | /*++\r | |
34 | \r | |
35 | Routine Description:\r | |
36 | \r | |
37 | Converts executable files to binary files.\r | |
38 | \r | |
39 | Arguments:\r | |
40 | \r | |
41 | argc - Number of command line arguments\r | |
42 | argv[] - Array of pointers to the command line arguments\r | |
43 | \r | |
44 | Returns:\r | |
45 | \r | |
46 | Zero - Function completed successfully.\r | |
56fe62ce | 47 | Non-zero - Function exited with errors.\r |
d25c4bf0 | 48 | \r |
49 | --*/\r | |
50 | {\r | |
51 | FILE *InFile;\r | |
52 | FILE *OutFile;\r | |
53 | int Index;\r | |
54 | int FileSize;\r | |
55 | char *Buffer;\r | |
56 | char *Ptrx;\r | |
57 | \r | |
58 | if (argc < 3) {\r | |
59 | printf ("Need more args, such as file name to convert and output name\n");\r | |
60 | return -1;\r | |
61 | }\r | |
62 | \r | |
63 | InFile = fopen (argv[1], "rb");\r | |
64 | OutFile = fopen (argv[2], "wb");\r | |
65 | \r | |
66 | if (!InFile) {\r | |
67 | printf ("no file, exit\n");\r | |
68 | return -1;\r | |
69 | }\r | |
70 | \r | |
71 | if (OutFile == NULL) {\r | |
72 | printf ("Unable to open output file.\n");\r | |
73 | return -1;\r | |
74 | }\r | |
75 | \r | |
76 | fseek (InFile, 0, SEEK_END);\r | |
77 | FileSize = ftell (InFile);\r | |
78 | \r | |
79 | if (FileSize < 0x200) {\r | |
80 | printf ("%d is not a legal size, exit\n", FileSize);\r | |
81 | return -1;\r | |
82 | }\r | |
83 | \r | |
84 | fseek (InFile, 0, SEEK_SET);\r | |
85 | \r | |
ce53a8c3 | 86 | Buffer = (char *) malloc (FileSize);\r |
d25c4bf0 | 87 | if (Buffer == NULL) {\r |
88 | printf ("Error: Out of resources.\n");\r | |
89 | return -1;\r | |
90 | }\r | |
91 | \r | |
92 | fread (Buffer, 1, FileSize, InFile);\r | |
93 | \r | |
94 | Ptrx = Buffer + 0x200;\r | |
95 | \r | |
96 | Index = FileSize - 0x200;\r | |
97 | \r | |
98 | fwrite (Ptrx, Index, 1, OutFile);\r | |
99 | \r | |
100 | fclose (InFile);\r | |
101 | fclose (OutFile);\r | |
102 | free (Buffer);\r | |
103 | \r | |
104 | return 0;\r | |
105 | }\r |