]>
Commit | Line | Data |
---|---|---|
d25c4bf0 | 1 | /*++\r |
2 | \r | |
cf171110 | 3 | Copyright (c) 2004-2006 Intel Corporation. All rights reserved\r |
d25c4bf0 | 4 | This software and associated documentation (if any) is furnished\r |
5 | under a license and may only be used or copied in accordance\r | |
6 | with the terms of the license. Except as permitted by such\r | |
7 | license, no part of this software or documentation may be\r | |
8 | reproduced, stored in a retrieval system, or transmitted in any\r | |
9 | form or by any means without the express written consent of\r | |
10 | Intel Corporation.\r | |
11 | \r | |
d25c4bf0 | 12 | Module Name:\r |
13 | \r | |
14 | Strip.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Quick Exe2Bin equivalent.\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #include <stdio.h>\r | |
23 | #include <memory.h>\r | |
24 | #include <string.h>\r | |
d25c4bf0 | 25 | \r |
26 | int\r | |
27 | main (\r | |
28 | int argc,\r | |
29 | char *argv[]\r | |
30 | )\r | |
31 | /*++\r | |
32 | \r | |
33 | Routine Description:\r | |
34 | \r | |
35 | Converts executable files to binary files.\r | |
36 | \r | |
37 | Arguments:\r | |
38 | \r | |
39 | argc - Number of command line arguments\r | |
40 | argv[] - Array of pointers to the command line arguments\r | |
41 | \r | |
42 | Returns:\r | |
43 | \r | |
44 | Zero - Function completed successfully.\r | |
45 | Non-zero - Function exited with errors. \r | |
46 | \r | |
47 | --*/\r | |
48 | {\r | |
49 | FILE *InFile;\r | |
50 | FILE *OutFile;\r | |
51 | int Index;\r | |
52 | int FileSize;\r | |
53 | char *Buffer;\r | |
54 | char *Ptrx;\r | |
55 | \r | |
56 | if (argc < 3) {\r | |
57 | printf ("Need more args, such as file name to convert and output name\n");\r | |
58 | return -1;\r | |
59 | }\r | |
60 | \r | |
61 | InFile = fopen (argv[1], "rb");\r | |
62 | OutFile = fopen (argv[2], "wb");\r | |
63 | \r | |
64 | if (!InFile) {\r | |
65 | printf ("no file, exit\n");\r | |
66 | return -1;\r | |
67 | }\r | |
68 | \r | |
69 | if (OutFile == NULL) {\r | |
70 | printf ("Unable to open output file.\n");\r | |
71 | return -1;\r | |
72 | }\r | |
73 | \r | |
74 | fseek (InFile, 0, SEEK_END);\r | |
75 | FileSize = ftell (InFile);\r | |
76 | \r | |
77 | if (FileSize < 0x200) {\r | |
78 | printf ("%d is not a legal size, exit\n", FileSize);\r | |
79 | return -1;\r | |
80 | }\r | |
81 | \r | |
82 | fseek (InFile, 0, SEEK_SET);\r | |
83 | \r | |
ce53a8c3 | 84 | Buffer = (char *) malloc (FileSize);\r |
d25c4bf0 | 85 | if (Buffer == NULL) {\r |
86 | printf ("Error: Out of resources.\n");\r | |
87 | return -1;\r | |
88 | }\r | |
89 | \r | |
90 | fread (Buffer, 1, FileSize, InFile);\r | |
91 | \r | |
92 | Ptrx = Buffer + 0x200;\r | |
93 | \r | |
94 | Index = FileSize - 0x200;\r | |
95 | \r | |
96 | fwrite (Ptrx, Index, 1, OutFile);\r | |
97 | \r | |
98 | fclose (InFile);\r | |
99 | fclose (OutFile);\r | |
100 | free (Buffer);\r | |
101 | \r | |
102 | return 0;\r | |
103 | }\r |