41 _In_ PIMAGE_ARCHIVE_MEMBER_HEADER Header,
54 start = (PCHAR)ViewBase;
57 MappedArchive->ViewBase = ViewBase;
58 MappedArchive->Size =
Size;
66 if (memcmp(start, IMAGE_ARCHIVE_START, IMAGE_ARCHIVE_START_SIZE) != 0)
69 __except (EXCEPTION_EXECUTE_HANDLER)
71 return GetExceptionCode();
81 (PIMAGE_ARCHIVE_MEMBER_HEADER)(start + IMAGE_ARCHIVE_START_SIZE),
82 &MappedArchive->FirstLinkerMember
89 return STATUS_INVALID_PARAMETER;
91 MappedArchive->FirstStandardMember = &MappedArchive->FirstLinkerMember;
96 &MappedArchive->FirstLinkerMember,
97 &MappedArchive->SecondLinkerMember
104 return STATUS_INVALID_PARAMETER;
112 &MappedArchive->SecondLinkerMember,
113 &MappedArchive->LongnamesMember
121 MappedArchive->HasLongnamesMember =
TRUE;
122 MappedArchive->LastStandardMember = &MappedArchive->LongnamesMember;
126 MappedArchive->LastStandardMember = &MappedArchive->SecondLinkerMember;
129 return STATUS_SUCCESS;
133 _In_opt_ PWSTR FileName,
134 _In_opt_ HANDLE FileHandle,
135 _In_ BOOLEAN ReadOnly,
145 &MappedArchive->ViewBase,
153 MappedArchive->ViewBase,
172 MappedArchive->ViewBase
182 PhProbeAddress(Address, Length, MappedArchive->ViewBase, MappedArchive->Size, 1);
198 PIMAGE_ARCHIVE_MEMBER_HEADER nextHeader;
206 if ((ULONG_PTR)nextHeader & 0x1)
207 nextHeader = (PIMAGE_ARCHIVE_MEMBER_HEADER)
PTR_ADD_OFFSET(nextHeader, 1);
210 Member->MappedArchive,
218 _In_ PIMAGE_ARCHIVE_MEMBER_HEADER Header,
222 WCHAR integerString[11];
228 if ((ULONG_PTR)Header >= (ULONG_PTR)MappedArchive->ViewBase + MappedArchive->Size)
229 return STATUS_NO_MORE_ENTRIES;
235 __except (EXCEPTION_EXECUTE_HANDLER)
237 return GetExceptionCode();
240 Member->MappedArchive = MappedArchive;
241 Member->Header = Header;
242 Member->Data =
PTR_ADD_OFFSET(Header,
sizeof(IMAGE_ARCHIVE_MEMBER_HEADER));
248 return STATUS_INVALID_PARAMETER;
250 string.Buffer = integerString;
252 digit =
string.Buffer;
254 while (iswdigit(*digit++))
255 string.Length +=
sizeof(WCHAR);
258 return STATUS_INVALID_PARAMETER;
260 Member->Size = (ULONG)size;
266 __except (EXCEPTION_EXECUTE_HANDLER)
268 return GetExceptionCode();
273 if (!
PhCopyBytesZ(Header->Name, 16, Member->NameBuffer, 20, NULL))
274 return STATUS_INVALID_PARAMETER;
276 Member->Name = Member->NameBuffer;
278 slash = strchr(Member->NameBuffer,
'/');
281 return STATUS_INVALID_PARAMETER;
290 if (slash == Member->NameBuffer)
292 if (Member->NameBuffer[1] ==
'/')
295 Member->NameBuffer[0] =
'/';
296 Member->NameBuffer[1] = 0;
303 Member->NameBuffer[0] = 0;
310 if (isdigit(slash[1]))
319 if (!MappedArchive->LongnamesMember.Header)
320 return STATUS_INVALID_PARAMETER;
326 while (isdigit(*digita))
335 return STATUS_INVALID_PARAMETER;
338 return STATUS_INVALID_PARAMETER;
340 offset = (ULONG)offset64;
342 if (offset >= MappedArchive->LongnamesMember.Size)
343 return STATUS_INVALID_PARAMETER;
346 Member->Name = (PSTR)
PTR_ADD_OFFSET(MappedArchive->LongnamesMember.Data, offset);
355 return STATUS_SUCCESS;
362 PIMAGE_FILE_HEADER header;
364 header = (PIMAGE_FILE_HEADER)Member->Data;
366 return header->Machine != IMAGE_FILE_MACHINE_UNKNOWN;
374 IMPORT_OBJECT_HEADER *importHeader;
376 importHeader = (IMPORT_OBJECT_HEADER *)Member->Data;
379 return STATUS_INVALID_PARAMETER;
381 importHeader->Sig1 != IMAGE_FILE_MACHINE_UNKNOWN ||
382 importHeader->Sig2 != IMPORT_OBJECT_HDR_SIG2
384 return STATUS_INVALID_PARAMETER;
386 Entry->Type = (BYTE)importHeader->Type;
387 Entry->NameType = (BYTE)importHeader->NameType;
388 Entry->Machine = importHeader->Machine;
391 Entry->Name = (PSTR)
PTR_ADD_OFFSET(importHeader,
sizeof(IMPORT_OBJECT_HEADER));
392 Entry->DllName = (PSTR)
PTR_ADD_OFFSET(Entry->Name, strlen(Entry->Name) + 1);
396 if (Entry->NameType == IMPORT_OBJECT_ORDINAL)
398 Entry->Ordinal = importHeader->Ordinal;
402 Entry->NameHint = importHeader->Hint;
405 return STATUS_SUCCESS;