LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // PE (Portable Executable) file writing | 5 // PE (Portable Executable) file writing |
6 // http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx | 6 // http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx |
7 | 7 |
8 #include <time.h> | 8 #include <time.h> |
9 | 9 |
10 #include "l.h" | 10 #include "l.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 default: | 79 default: |
80 break; | 80 break; |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 static void | 84 static void |
85 pewrite(void) | 85 pewrite(void) |
86 { | 86 { |
87 int i, j; | 87 int i, j; |
88 | 88 |
89 » for (i=0; i<sizeof(dosstub); i++) | 89 » write(cout, dosstub, sizeof dosstub); |
90 » » cput(dosstub[i]); | |
91 strnput("PE", 4); | 90 strnput("PE", 4); |
92 | 91 |
93 for (i=0; i<sizeof(fh); i++) | 92 for (i=0; i<sizeof(fh); i++) |
94 cput(((char*)&fh)[i]); | 93 cput(((char*)&fh)[i]); |
95 for (i=0; i<sizeof(oh); i++) | 94 for (i=0; i<sizeof(oh); i++) |
96 cput(((char*)&oh)[i]); | 95 cput(((char*)&oh)[i]); |
97 for (i=0; i<nsect; i++) | 96 for (i=0; i<nsect; i++) |
98 for (j=0; j<sizeof(sh[i]); j++) | 97 for (j=0; j<sizeof(sh[i]); j++) |
99 cput(((char*)&sh[i])[j]); | 98 cput(((char*)&sh[i])[j]); |
100 } | 99 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 oh.SizeOfHeaders = PERESERVE; | 243 oh.SizeOfHeaders = PERESERVE; |
245 oh.Subsystem = 3; // WINDOWS_CUI | 244 oh.Subsystem = 3; // WINDOWS_CUI |
246 oh.SizeOfStackReserve = 0x00200000; | 245 oh.SizeOfStackReserve = 0x00200000; |
247 oh.SizeOfStackCommit = 0x00001000; | 246 oh.SizeOfStackCommit = 0x00001000; |
248 oh.SizeOfHeapReserve = 0x00100000; | 247 oh.SizeOfHeapReserve = 0x00100000; |
249 oh.SizeOfHeapCommit = 0x00001000; | 248 oh.SizeOfHeapCommit = 0x00001000; |
250 oh.NumberOfRvaAndSizes = 16; | 249 oh.NumberOfRvaAndSizes = 16; |
251 | 250 |
252 pewrite(); | 251 pewrite(); |
253 } | 252 } |
LEFT | RIGHT |