]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/TianoTools/Strip/Strip.c
Updated ReleaseNotes.txt since the issue of build CompressDll.dll in cygwin is fixed...
[mirror_edk2.git] / Tools / Source / TianoTools / Strip / Strip.c
CommitLineData
d25c4bf0 1/*++\r
2\r
cf171110 3Copyright (c) 2004-2006 Intel Corporation. All rights reserved\r
56fe62ce 4This program and the accompanying materials are licensed and made available\r
5under the terms and conditions of the BSD License which accompanies this\r
6distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
d25c4bf0 12\r
d25c4bf0 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
56fe62ce 46 Non-zero - Function exited with errors.\r
d25c4bf0 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