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