Rizin
unix-like reverse engineering framework and cli tools
assembler.h File Reference
#include <rz_types.h>
#include <rz_util.h>
#include "bytecode.h"

Go to the source code of this file.

Functions

bool java_assembler (const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, st32 *written)
 

Function Documentation

◆ java_assembler()

bool java_assembler ( const char *  input,
st32  input_size,
ut8 output,
st32  output_size,
ut64  pc,
st32 written 
)

Definition at line 472 of file assembler.c.

472  {
473  rz_return_val_if_fail(input && output && input_size > 0 && output_size > 0, false);
474 
475  for (ut32 i = 0; i < RZ_ARRAY_SIZE(instructions); ++i) {
476  if (input_size < instructions[i].length) {
477  continue;
478  }
480  const char *p = rz_str_trim_head_ro(input + instructions[i].length);
481  st32 used = p ? (p - input) : input_size;
482  return instructions[i].encode(instructions[i].bytecode, p, input_size - used, output, output_size, pc, written);
483  }
484  }
485 
486  RZ_LOG_ERROR("[!] java_assembler: invalid assembly.\n");
487  return false;
488 }
lzma_index ** i
Definition: index.h:629
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 static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
uint32_t ut32
static const JavaAsm instructions[205]
Definition: assembler.c:263
void * p
Definition: libc.cpp:67
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
RZ_API const char * rz_str_trim_head_ro(const char *str)
Definition: str_trim.c:86
RZ_API int rz_str_ncasecmp(const char *dst, const char *orig, size_t n)
Definition: str.c:129
#define RZ_ARRAY_SIZE(x)
Definition: rz_types.h:300
#define st32
Definition: rz_types_base.h:12
AsmEncoder encode
Definition: assembler.c:29
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)
diff_output_t output
Definition: zipcmp.c:237

References _jasm::encode, i, input(), instructions, length, output, p, pc, RZ_ARRAY_SIZE, RZ_LOG_ERROR, rz_return_val_if_fail, rz_str_ncasecmp(), rz_str_trim_head_ro(), and st32.

Referenced by java_assemble().