9 #define MAX_METADATA_STRING_LENGTH 256
26 while (covered % 4 != 0) {
55 biggest = (
x > biggest) ?
x : biggest;
71 ut8 buf[(32 + (8 * 4) + 64 + 64) / 8];
91 memset(&index_sizes, 2,
sizeof(index_sizes));
101 index_sizes.
blob = 4;
108 int matched_bits = 0;
110 for (
int bit_check = 0; bit_check < 64; ++bit_check) {
111 if (!((tilde->
Valid >> bit_check) & 0x1)) {
115 if (!
rz_buf_read(
b, rowcountbuf,
sizeof(rowcountbuf))) {
119 #define ROW_READ(name) \
120 rowcounts->name = rz_read_le32(rowcountbuf);
122 #define ROW_READ_WITH_INDEX(name) \
124 if (rowcounts->name > 0xFFFF) { \
125 index_sizes.name = 4; \
269 for (
int bit_check = 0; bit_check < 64; ++bit_check) {
270 if (!((tilde->
Valid >> bit_check) & 0x1)) {
274 #define TRY_SEEK(rowsize, rowcountname) \
275 if (rz_buf_seek(b, (rowsize) * (st64)rowcounts->rowcountname, RZ_BUF_CUR) < 0) { \
276 RZ_LOG_WARN("seeking #rowcountname (size %d)", rowsize); \
280 #define READ_BUF_INDEX_SIZE(var, index_size) \
281 var = (index_size == 2) ? rz_read_le16(buf) : rz_read_le32(buf); \
284 #define INDEX_SIZE_FROM_TAG(name, tag_size) \
285 ut32 name = (index_count > (0xFFFF >> tag_size)) ? 4 : 2;
300 (index_sizes.
guid * 3),
308 rowcounts->moduleref,
309 rowcounts->assemblyref,
321 rowcounts->typespec);
327 ut32 rowcount = rowcounts->typedef_;
336 for (
int i = 0;
i < rowcount; ++
i) {
372 ut32 rowsize = 4 + 2 + 2 + index_sizes.
string +
374 ut32 rowcount = rowcounts->methoddef;
383 for (
int i = 0;
i < rowcount; ++
i) {
409 rowcounts->typespec);
418 rowcounts->methoddef,
419 rowcounts->moduleref,
421 rowcounts->typespec);
434 rowcounts->property);
446 rowcounts->methoddef,
451 rowcounts->interfaceimpl,
452 rowcounts->memberref,
456 rowcounts->standalonesig,
457 rowcounts->moduleref,
460 rowcounts->assemblyref,
462 rowcounts->exportedtype,
463 rowcounts->manifestresource,
464 rowcounts->genericparam,
465 rowcounts->genericparamconstraint,
466 rowcounts->methodspec);
471 rowcounts->methoddef,
472 rowcounts->memberref);
473 ut32 index_size2 = (index_count > (0xFFFF >> 0x03)) ? 4 : 2;
494 rowcounts->methoddef,
495 rowcounts->assembly);
527 rowcounts->typespec);
550 rowcounts->property);
559 rowcounts->methoddef,
560 rowcounts->memberref);
579 rowcounts->methoddef);
604 ut32 row_size = (4 + 2 + 2 + 2 + 2 + 4 + index_sizes.
blob +
605 (index_sizes.
string * 2));
620 ut32 row_size = (2 + 2 + 2 + 2 + 4 +
621 (index_sizes.
blob * 2) +
622 (index_sizes.
string * 2));
643 rowcounts->assemblyref,
644 rowcounts->exportedtype);
655 rowcounts->assemblyref);
660 TRY_SEEK(row_size, manifestresource)
671 rowcounts->methoddef);
680 rowcounts->methoddef,
681 rowcounts->memberref);
692 rowcounts->typespec);
700 RZ_LOG_WARN(
"Unknown bit in metatable: %i\n", bit_check);
756 if ((
buf[0] & 0x03) == 0x02) {
760 }
else if ((
buf[0] & 0x03) == 0x03) {
788 if (!metadata_directory) {
794 (
ut8 *)metadata, big_endian ?
"1I2S" :
"1i2s", 1);
800 (
ut8 *)(&metadata->
Reserved), big_endian ?
"1I" :
"1i", 1);
821 RZ_LOG_WARN(
"read (metadata header) - cannot parse version string\n");
830 (
ut8 *)(&metadata->
Flags), big_endian ?
"2S" :
"2s", 1);
847 while (count < metadata->NumberOfStreams) {
881 stream->Name = stream_name;
883 start_of_stream += 8 +
c;
889 }
else if (strncmp(stream_name,
"#~", 2) == 0 && clr->
tilde_stream ==
NULL) {
891 }
else if (strncmp(stream_name,
"#Blob", 5) == 0) {
945 if (
header->HeaderSize != 0x48) {
static ut64 rva(RzBinObject *o, ut64 paddr, ut64 vaddr, int va)
static lzma_vli index_size(lzma_vli count, lzma_vli index_list_size)
Calculate the size of the Index field including Index Padding.
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
int bin_pe_dotnet_read_method_header(Pe_image_clr *clr, RzBuffer *b, RzBinSymbol *sym)
static void _free_stream(Pe_image_metadata_stream *stream)
static int read_image_clr_header(RzBuffer *b, ut64 addr, Pe_image_clr_header *header)
#define READ_BUF_INDEX_SIZE(var, index_size)
#define INDEX_SIZE_FROM_TAG(name, tag_size)
static int read_image_metadata_tilde_header(RzBuffer *b, ut64 addr, Pe_image_clr *clr)
static ut32 clr_max_rows(int count,...)
static int bin_pe_read_metadata_string(char *to, RzBuffer *frombuf, ut64 fromoff)
#define MAX_METADATA_STRING_LENGTH
#define TRY_SEEK(rowsize, rowcountname)
int bin_pe_dotnet_init_clr(Pe_image_clr *clr, RzBuffer *b, ut64 image_clr_hdr_paddr)
int bin_pe_dotnet_init_metadata(Pe_image_clr *clr, bool big_endian, RzBuffer *b, ut64 metadata_directory)
static void free_metadata_header(Pe_image_metadata_header *metadata)
#define ROW_READ_WITH_INDEX(name)
void bin_pe_dotnet_destroy_clr(Pe_image_clr *clr)
#define BIT_STANDALONESIG
#define BIT_GENERICPARAMCONSTRAINT
#define BIT_INTERFACEIMPL
#define BIT_ASSEMBLYREFOS
#define BIT_CUSTOMATTRIBUTE
#define BIT_MANIFESTRESOURCE
#define BIT_ASSEMBLYREFPROCESSOR
#define BIT_METHODSEMANTICS
#define BIT_ASSEMBLYPROCESSOR
checking print the parsed form of the magic use in n conjunction with m to debug a new magic file n before installing it n output MIME type strings(--mime-type and\n"
" --mime-encoding)\n") OPT('s'
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * calloc(size_t number, size_t size)
#define header(is_bt, len_min, ret_op)
#define PE_READ_STRUCT_FIELD(var, struct_type, field, size)
#define rz_warn_if_reached()
#define rz_warn_if_fail(expr)
RZ_API st64 rz_buf_seek(RZ_NONNULL RzBuffer *b, st64 addr, int whence)
Modify the current cursor position in the buffer.
RZ_API bool rz_buf_read8_at(RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *result)
Read a byte at the specified address in the buffer.
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
RZ_API bool rz_buf_read8(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut8 *result)
Read a byte at the cursor in the buffer.
RZ_API st64 rz_buf_fread_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL ut8 *buf, RZ_NONNULL const char *fmt, int n)
...
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
RZ_API RZ_OWN RzBuffer * rz_buf_new_slice(RzBuffer *b, ut64 offset, ut64 size)
Creates a new buffer from a slice of another buffer.
RZ_API st64 rz_buf_read(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
void(* RzListFree)(void *ptr)
#define RZ_LOG_WARN(fmtstr,...)
RZ_API RzPVector * rz_pvector_new(RzPVectorFree free)
static void ** rz_pvector_push(RzPVector *vec, void *x)
RZ_API void rz_pvector_free(RzPVector *vec)
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
static struct sockaddr static addrlen static backlog const void static flags void flags
Pe_image_metadata_stream * tilde_stream
Pe_image_metadata_header * metadata_header
Pe_image_clr_header * header
Pe_image_metadata_stream * strings_stream
Pe_image_metadata_stream * blob_stream
Pe_image_metadata_tilde_header * tilde
void error(const char *msg)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()