push 27a9569132e9fc3a545aded7efca0a004a7b7ea9
[wine/hacks.git] / dlls / kernel32 / tests / loader.c
blobcb232994befb751f42a760b19deb8e8e514ba40d
1 /*
2 * Unit test suite for the PE loader.
4 * Copyright 2006 Dmitry Timoshkov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <assert.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wine/test.h"
28 #define ALIGN_SIZE(size, alignment) (((size) + (alignment - 1)) & ~((alignment - 1)))
30 static const struct
32 WORD e_magic; /* 00: MZ Header signature */
33 WORD unused[29];
34 DWORD e_lfanew; /* 3c: Offset to extended header */
35 } dos_header =
37 IMAGE_DOS_SIGNATURE, { 0 }, sizeof(dos_header)
40 static IMAGE_NT_HEADERS nt_header =
42 IMAGE_NT_SIGNATURE, /* Signature */
43 #if defined __i386__
44 { IMAGE_FILE_MACHINE_I386, /* Machine */
45 #elif defined __x86_64__
46 { IMAGE_FILE_MACHINE_AMD64, /* Machine */
47 #else
48 # error You must specify the machine type
49 #endif
50 1, /* NumberOfSections */
51 0, /* TimeDateStamp */
52 0, /* PointerToSymbolTable */
53 0, /* NumberOfSymbols */
54 sizeof(IMAGE_OPTIONAL_HEADER), /* SizeOfOptionalHeader */
55 IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_DLL /* Characteristics */
57 { IMAGE_NT_OPTIONAL_HDR_MAGIC, /* Magic */
58 1, /* MajorLinkerVersion */
59 0, /* MinorLinkerVersion */
60 0, /* SizeOfCode */
61 0, /* SizeOfInitializedData */
62 0, /* SizeOfUninitializedData */
63 0, /* AddressOfEntryPoint */
64 0x10, /* BaseOfCode, also serves as e_lfanew in the truncated MZ header */
65 0, /* BaseOfData */
66 0x10000000, /* ImageBase */
67 0, /* SectionAlignment */
68 0, /* FileAlignment */
69 4, /* MajorOperatingSystemVersion */
70 0, /* MinorOperatingSystemVersion */
71 1, /* MajorImageVersion */
72 0, /* MinorImageVersion */
73 4, /* MajorSubsystemVersion */
74 0, /* MinorSubsystemVersion */
75 0, /* Win32VersionValue */
76 sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0x1000, /* SizeOfImage */
77 sizeof(dos_header) + sizeof(nt_header), /* SizeOfHeaders */
78 0, /* CheckSum */
79 IMAGE_SUBSYSTEM_WINDOWS_CUI, /* Subsystem */
80 0, /* DllCharacteristics */
81 0, /* SizeOfStackReserve */
82 0, /* SizeOfStackCommit */
83 0, /* SizeOfHeapReserve */
84 0, /* SizeOfHeapCommit */
85 0, /* LoaderFlags */
86 0, /* NumberOfRvaAndSizes */
87 { { 0 } } /* DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] */
91 static IMAGE_SECTION_HEADER section =
93 ".rodata", /* Name */
94 { 0x10 }, /* Misc */
95 0, /* VirtualAddress */
96 0x0a, /* SizeOfRawData */
97 0, /* PointerToRawData */
98 0, /* PointerToRelocations */
99 0, /* PointerToLinenumbers */
100 0, /* NumberOfRelocations */
101 0, /* NumberOfLinenumbers */
102 IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ, /* Characteristics */
105 START_TEST(loader)
107 static const struct test_data
109 const void *dos_header;
110 DWORD size_of_dos_header;
111 WORD number_of_sections, size_of_optional_header;
112 DWORD section_alignment, file_alignment;
113 DWORD size_of_image, size_of_headers;
114 DWORD error; /* 0 means LoadLibrary should succeed */
115 } td[] =
117 { &dos_header, sizeof(dos_header),
118 1, 0, 0, 0, 0, 0,
119 ERROR_BAD_EXE_FORMAT
121 { &dos_header, sizeof(dos_header),
122 1, sizeof(IMAGE_OPTIONAL_HEADER), 0x1000, 0x1000,
123 sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0xe00,
124 sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER),
125 ERROR_BAD_EXE_FORMAT /* XP doesn't like too small image size */
127 { &dos_header, sizeof(dos_header),
128 1, sizeof(IMAGE_OPTIONAL_HEADER), 0x1000, 0x1000,
129 sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0x1000,
130 sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER),
131 ERROR_SUCCESS
133 { &dos_header, sizeof(dos_header),
134 1, sizeof(IMAGE_OPTIONAL_HEADER), 0x1000, 0x1000,
135 0x1f00,
136 0x1000,
137 ERROR_SUCCESS
139 { &dos_header, sizeof(dos_header),
140 1, sizeof(IMAGE_OPTIONAL_HEADER), 0x200, 0x200,
141 sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0x1000,
142 sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER),
143 ERROR_SUCCESS
145 { &dos_header, sizeof(dos_header),
146 1, sizeof(IMAGE_OPTIONAL_HEADER), 0x200, 0x1000,
147 sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0x1000,
148 sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER),
149 ERROR_BAD_EXE_FORMAT /* XP doesn't like aligments */
151 { &dos_header, sizeof(dos_header),
152 1, sizeof(IMAGE_OPTIONAL_HEADER), 0x1000, 0x200,
153 sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0x1000,
154 sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER),
155 ERROR_SUCCESS
157 { &dos_header, sizeof(dos_header),
158 1, sizeof(IMAGE_OPTIONAL_HEADER), 0x1000, 0x200,
159 sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0x1000,
160 0x200,
161 ERROR_SUCCESS
163 /* Mandatory are all fields up to SizeOfHeaders, everything else
164 * is really optional (at least that's true for XP).
166 { &dos_header, sizeof(dos_header),
167 1, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 0x200, 0x200,
168 sizeof(dos_header) + sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER) + FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum) + sizeof(IMAGE_SECTION_HEADER) + 0x10,
169 sizeof(dos_header) + sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER) + FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum) + sizeof(IMAGE_SECTION_HEADER),
170 ERROR_SUCCESS
172 { &dos_header, sizeof(dos_header),
173 0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 0x200, 0x200,
174 0xd0, /* beyond of the end of file */
175 0xc0, /* beyond of the end of file */
176 ERROR_SUCCESS
178 { &dos_header, sizeof(dos_header),
179 0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 0x200, 0x200,
180 0x1000,
182 ERROR_SUCCESS
184 { &dos_header, sizeof(dos_header),
185 0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 0x200, 0x200,
188 ERROR_SUCCESS
190 #if 0 /* not power of 2 alignments need more test cases */
191 { &dos_header, sizeof(dos_header),
192 0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 0x300, 0x300,
195 ERROR_BAD_EXE_FORMAT /* alignment is not power of 2 */
197 #endif
198 { &dos_header, sizeof(dos_header),
199 0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 4, 4,
202 ERROR_SUCCESS
204 { &dos_header, sizeof(dos_header),
205 0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 1, 1,
208 ERROR_SUCCESS
210 { &dos_header, sizeof(dos_header),
211 0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 0x200, 0x200,
214 ERROR_BAD_EXE_FORMAT /* image size == 0 -> failure */
216 /* the following data mimics the PE image which upack creates */
217 { &dos_header, 0x10,
218 1, 0x148, 0x1000, 0x200,
219 sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0x1000,
220 0x200,
221 ERROR_SUCCESS
223 /* Minimal PE image that XP is able to load: 92 bytes */
224 { &dos_header, 0x04,
225 0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum),
226 0x04 /* also serves as e_lfanew in the truncated MZ header */, 0x04,
229 ERROR_SUCCESS
232 static const char filler[0x1000];
233 static const char section_data[0x10] = "section data";
234 int i;
235 DWORD dummy, file_size, file_align;
236 HANDLE hfile;
237 HMODULE hlib, hlib_as_data_file;
238 SYSTEM_INFO si;
239 char temp_path[MAX_PATH];
240 char dll_name[MAX_PATH];
242 GetSystemInfo(&si);
243 trace("system page size 0x%04x\n", si.dwPageSize);
245 /* prevent displaying of the "Unable to load this DLL" message box */
246 SetErrorMode(SEM_FAILCRITICALERRORS);
248 GetTempPath(MAX_PATH, temp_path);
250 for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
252 GetTempFileName(temp_path, "ldr", 0, dll_name);
254 /*trace("creating %s\n", dll_name);*/
255 hfile = CreateFileA(dll_name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
256 if (hfile == INVALID_HANDLE_VALUE)
258 ok(0, "could not create %s\n", dll_name);
259 break;
262 SetLastError(0xdeadbeef);
263 ok(WriteFile(hfile, td[i].dos_header, td[i].size_of_dos_header, &dummy, NULL),
264 "WriteFile error %d\n", GetLastError());
266 nt_header.FileHeader.NumberOfSections = td[i].number_of_sections;
267 nt_header.FileHeader.SizeOfOptionalHeader = td[i].size_of_optional_header;
269 nt_header.OptionalHeader.SectionAlignment = td[i].section_alignment;
270 nt_header.OptionalHeader.FileAlignment = td[i].file_alignment;
271 nt_header.OptionalHeader.SizeOfImage = td[i].size_of_image;
272 nt_header.OptionalHeader.SizeOfHeaders = td[i].size_of_headers;
273 SetLastError(0xdeadbeef);
274 ok(WriteFile(hfile, &nt_header, sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER), &dummy, NULL),
275 "WriteFile error %d\n", GetLastError());
277 if (nt_header.FileHeader.SizeOfOptionalHeader)
279 SetLastError(0xdeadbeef);
280 ok(WriteFile(hfile, &nt_header.OptionalHeader,
281 min(nt_header.FileHeader.SizeOfOptionalHeader, sizeof(IMAGE_OPTIONAL_HEADER)),
282 &dummy, NULL),
283 "WriteFile error %d\n", GetLastError());
284 if (nt_header.FileHeader.SizeOfOptionalHeader > sizeof(IMAGE_OPTIONAL_HEADER))
286 file_align = nt_header.FileHeader.SizeOfOptionalHeader - sizeof(IMAGE_OPTIONAL_HEADER);
287 assert(file_align < sizeof(filler));
288 SetLastError(0xdeadbeef);
289 ok(WriteFile(hfile, filler, file_align, &dummy, NULL),
290 "WriteFile error %d\n", GetLastError());
294 assert(nt_header.FileHeader.NumberOfSections <= 1);
295 if (nt_header.FileHeader.NumberOfSections)
297 if (nt_header.OptionalHeader.SectionAlignment >= si.dwPageSize)
299 section.PointerToRawData = td[i].size_of_dos_header;
300 section.VirtualAddress = nt_header.OptionalHeader.SectionAlignment;
301 section.Misc.VirtualSize = section.SizeOfRawData * 10;
303 else
305 section.PointerToRawData = nt_header.OptionalHeader.SizeOfHeaders;
306 section.VirtualAddress = nt_header.OptionalHeader.SizeOfHeaders;
307 section.Misc.VirtualSize = 5;
310 SetLastError(0xdeadbeef);
311 ok(WriteFile(hfile, &section, sizeof(section), &dummy, NULL),
312 "WriteFile error %d\n", GetLastError());
314 /* section data */
315 SetLastError(0xdeadbeef);
316 ok(WriteFile(hfile, section_data, sizeof(section_data), &dummy, NULL),
317 "WriteFile error %d\n", GetLastError());
320 file_size = GetFileSize(hfile, NULL);
321 CloseHandle(hfile);
323 SetLastError(0xdeadbeef);
324 hlib = LoadLibrary(dll_name);
325 if (td[i].error == ERROR_SUCCESS)
327 MEMORY_BASIC_INFORMATION info;
329 ok(hlib != 0, "%d: LoadLibrary error %d\n", i, GetLastError());
331 SetLastError(0xdeadbeef);
332 ok(VirtualQuery(hlib, &info, sizeof(info)) == sizeof(info),
333 "%d: VirtualQuery error %d\n", i, GetLastError());
334 ok(info.BaseAddress == hlib, "%d: %p != %p\n", i, info.BaseAddress, hlib);
335 ok(info.AllocationBase == hlib, "%d: %p != %p\n", i, info.AllocationBase, hlib);
336 ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%d: %x != PAGE_EXECUTE_WRITECOPY\n", i, info.AllocationProtect);
337 ok(info.RegionSize == ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, si.dwPageSize), "%d: got %lx != expected %x\n",
338 i, info.RegionSize, ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, si.dwPageSize));
339 ok(info.State == MEM_COMMIT, "%d: %x != MEM_COMMIT\n", i, info.State);
340 if (nt_header.OptionalHeader.SectionAlignment < si.dwPageSize)
341 ok(info.Protect == PAGE_EXECUTE_WRITECOPY, "%d: %x != PAGE_EXECUTE_WRITECOPY\n", i, info.Protect);
342 else
343 ok(info.Protect == PAGE_READONLY, "%d: %x != PAGE_READONLY\n", i, info.Protect);
344 ok(info.Type == SEC_IMAGE, "%d: %x != SEC_IMAGE\n", i, info.Type);
346 SetLastError(0xdeadbeef);
347 ok(VirtualQuery((char *)hlib + info.RegionSize, &info, sizeof(info)) == sizeof(info),
348 "%d: VirtualQuery error %d\n", i, GetLastError());
349 if (nt_header.OptionalHeader.SectionAlignment == si.dwPageSize ||
350 nt_header.OptionalHeader.SectionAlignment == nt_header.OptionalHeader.FileAlignment)
352 ok(info.BaseAddress == (char *)hlib + ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, si.dwPageSize), "%d: got %p != expected %p\n",
353 i, info.BaseAddress, (char *)hlib + ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, si.dwPageSize));
354 ok(info.AllocationBase == 0, "%d: %p != 0\n", i, info.AllocationBase);
355 ok(info.AllocationProtect == 0, "%d: %x != 0\n", i, info.AllocationProtect);
356 /*ok(info.RegionSize == not_practical_value, "%d: %lx != not_practical_value\n", i, info.RegionSize);*/
357 ok(info.State == MEM_FREE, "%d: %x != MEM_FREE\n", i, info.State);
358 ok(info.Type == 0, "%d: %x != 0\n", i, info.Type);
359 ok(info.Protect == PAGE_NOACCESS, "%d: %x != PAGE_NOACCESS\n", i, info.Protect);
361 else
363 ok(info.Protect == PAGE_EXECUTE_WRITECOPY, "%d: %x != PAGE_EXECUTE_WRITECOPY\n", i, info.Protect);
364 ok(info.BaseAddress == hlib, "%d: got %p != expected %p\n", i, info.BaseAddress, hlib);
365 ok(info.AllocationBase == hlib, "%d: %p != %p\n", i, info.AllocationBase, hlib);
366 ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%d: %x != PAGE_EXECUTE_WRITECOPY\n", i, info.AllocationProtect);
367 ok(info.RegionSize == ALIGN_SIZE(file_size, si.dwPageSize), "%d: got %lx != expected %x\n",
368 i, info.RegionSize, ALIGN_SIZE(file_size, si.dwPageSize));
369 ok(info.State == MEM_COMMIT, "%d: %x != MEM_COMMIT\n", i, info.State);
370 ok(info.Protect == PAGE_READONLY, "%d: %x != PAGE_READONLY\n", i, info.Protect);
371 ok(info.Type == SEC_IMAGE, "%d: %x != SEC_IMAGE\n", i, info.Type);
374 /* header: check the zeroing of alignment */
375 if (nt_header.OptionalHeader.SectionAlignment >= si.dwPageSize)
377 const char *start;
378 int size;
380 start = (const char *)hlib + nt_header.OptionalHeader.SizeOfHeaders;
381 size = ALIGN_SIZE((ULONG_PTR)start, si.dwPageSize) - (ULONG_PTR)start;
382 ok(!memcmp(start, filler, size), "%d: header alignment is not cleared\n", i);
385 if (nt_header.FileHeader.NumberOfSections)
387 SetLastError(0xdeadbeef);
388 ok(VirtualQuery((char *)hlib + section.VirtualAddress, &info, sizeof(info)) == sizeof(info),
389 "%d: VirtualQuery error %d\n", i, GetLastError());
390 if (nt_header.OptionalHeader.SectionAlignment < si.dwPageSize)
392 ok(info.BaseAddress == (char *)hlib, "%d: got %p != expected %p\n", i, info.BaseAddress, (char *)hlib);
393 ok(info.RegionSize == ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, si.dwPageSize), "%d: got %lx != expected %x\n",
394 i, info.RegionSize, ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, si.dwPageSize));
395 ok(info.Protect == PAGE_EXECUTE_WRITECOPY, "%d: %x != PAGE_EXECUTE_WRITECOPY\n", i, info.Protect);
397 else
399 ok(info.BaseAddress == (char *)hlib + section.VirtualAddress, "%d: got %p != expected %p\n", i, info.BaseAddress, (char *)hlib + section.VirtualAddress);
400 ok(info.RegionSize == ALIGN_SIZE(section.Misc.VirtualSize, si.dwPageSize), "%d: got %lx != expected %x\n",
401 i, info.RegionSize, ALIGN_SIZE(section.Misc.VirtualSize, si.dwPageSize));
402 ok(info.Protect == PAGE_READONLY, "%d: %x != PAGE_READONLY\n", i, info.Protect);
404 ok(info.AllocationBase == hlib, "%d: %p != %p\n", i, info.AllocationBase, hlib);
405 ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%d: %x != PAGE_EXECUTE_WRITECOPY\n", i, info.AllocationProtect);
406 ok(info.State == MEM_COMMIT, "%d: %x != MEM_COMMIT\n", i, info.State);
407 ok(info.Type == SEC_IMAGE, "%d: %x != SEC_IMAGE\n", i, info.Type);
409 if (nt_header.OptionalHeader.SectionAlignment >= si.dwPageSize)
410 ok(!memcmp((const char *)hlib + section.VirtualAddress + section.PointerToRawData, &nt_header, section.SizeOfRawData), "wrong section data\n");
411 else
412 ok(!memcmp((const char *)hlib + section.PointerToRawData, section_data, section.SizeOfRawData), "wrong section data\n");
414 /* check the zeroing of alignment */
415 if (nt_header.OptionalHeader.SectionAlignment >= si.dwPageSize)
417 const char *start;
418 int size;
420 start = (const char *)hlib + section.VirtualAddress + section.PointerToRawData + section.SizeOfRawData;
421 size = ALIGN_SIZE((ULONG_PTR)start, si.dwPageSize) - (ULONG_PTR)start;
422 ok(memcmp(start, filler, size), "%d: alignment should not be cleared\n", i);
426 SetLastError(0xdeadbeef);
427 hlib_as_data_file = LoadLibraryEx(dll_name, 0, LOAD_LIBRARY_AS_DATAFILE);
428 ok(hlib_as_data_file != 0, "LoadLibraryEx error %u\n", GetLastError());
429 ok(hlib_as_data_file == hlib, "hlib_as_file and hlib are different\n");
431 SetLastError(0xdeadbeef);
432 ok(FreeLibrary(hlib), "FreeLibrary error %d\n", GetLastError());
434 SetLastError(0xdeadbeef);
435 hlib = GetModuleHandle(dll_name);
436 ok(hlib != 0, "GetModuleHandle error %u\n", GetLastError());
438 SetLastError(0xdeadbeef);
439 ok(FreeLibrary(hlib_as_data_file), "FreeLibrary error %d\n", GetLastError());
441 hlib = GetModuleHandle(dll_name);
442 ok(!hlib, "GetModuleHandle should fail\n");
444 SetLastError(0xdeadbeef);
445 hlib_as_data_file = LoadLibraryEx(dll_name, 0, LOAD_LIBRARY_AS_DATAFILE);
446 ok(hlib_as_data_file != 0, "LoadLibraryEx error %u\n", GetLastError());
447 ok((ULONG_PTR)hlib_as_data_file & 1, "hlib_as_data_file is even\n");
449 hlib = GetModuleHandle(dll_name);
450 ok(!hlib, "GetModuleHandle should fail\n");
452 SetLastError(0xdeadbeef);
453 ok(FreeLibrary(hlib_as_data_file), "FreeLibrary error %d\n", GetLastError());
455 else
456 { /* LoadLibrary is expected to fail */
457 ok(!hlib, "%d: LoadLibrary should fail\n", i);
459 if (GetLastError() == ERROR_GEN_FAILURE) /* Win9x, broken behaviour */
461 trace("skipping the loader test on Win9x\n");
462 DeleteFile(dll_name);
463 return;
466 ok(td[i].error == GetLastError(), "%d: expected error %d, got %d\n",
467 i, td[i].error, GetLastError());
470 SetLastError(0xdeadbeef);
471 ok(DeleteFile(dll_name), "DeleteFile error %d\n", GetLastError());