Example #1
0
void dxsi_annotationelement(DexAnnotationElement* obj, dx_shift* shift) {
  size_t old_size;
 
  old_size = obj->name_idx.size;

  UPDATE_ULEB(obj->name_idx);
  
  if (obj->name_idx.size != old_size)
    add_shift(shift,obj->meta.offset + 1,obj->name_idx.size - old_size);

  dxsi_encodedvalue(obj->value,shift);
}
Example #2
0
void dxsi_debuginfo(DexDebugInfo* obj, dx_shift* shift) {
  unsigned int i;
  size_t old_size;

  for (i=0; i<ul128toui(obj->parameters_size); i++) {
    old_size = obj->parameter_names[i].size;

    UPDATE_ULEBP1(obj->parameter_names[i]);
    
    if (obj->parameter_names[i].size != old_size)
      add_shift(shift,obj->meta.offset + 1,obj->parameter_names[i].size - old_size);
  }
}
Example #3
0
static void 
process_file(char *fn)
{
	int i;
	long n;
	int c;

	workf = fopen(fn, "r+");
	if (workf == NULL) {
		fprintf(stderr, "%s: cannot read %s\n", __progname, fn);
		return;
	}
	printf("(file: %s)\n", fn);
	current_file = fn;
	for (i = 0; i <= MAX_C_A; i++) {
		nls[i] = -1;
	}
	nls[MAX_C_A] = 0;
	tbeg = -1;
	if (wordmode) {
		bufp0 = &buf[1];
		rahead = s1l + 1;
		buf[0] = '\0';
	} else {
		bufp0 = &buf[0];
		rahead = s1l;
	}
	if (debugging) {
		printf("[rahead = %d, bufp0-buf = %ld]\n",
		    rahead, (long) (bufp0 - &buf[0]));
	}
	n = 0;
	bufp = bufp0;
	bufpmax = &buf[sizeof(buf) - s1l - 2];
	flying = allfly;
	flystate = 1;
	while (1) {
		c = getc(workf);
		if (c == EOF) {
			if (tbeg >= 0) {
				if (bufp > bufp0)
					fwrite(bufp0, 1, bufp - bufp0, tempf);
				fseek(workf, tbeg, 0);
				n = ftell(tempf);
				fseek(tempf, 0L, 0);
				for (; n; n--) {
					putc(getc(tempf), workf);
				}
				fflush(workf);
				ftruncate(fileno(workf), ftell(workf));
			}
			fclose(workf);
			return;
		}
		*bufp++ = c;
		n++;
		if (debugging) {
			printf("[got %c, n now %ld, bufp-buf %ld]\n",
			    c, n, (long) (bufp - bufp0));
		}
		if ((n >= rahead) && foundit() && doit()) {
			int wbehind;
			if (debugging) {
				printf("[doing change]\n");
			}
			wbehind = 1;
			if (tbeg < 0) {
				tbeg = ftell(workf) - rahead;
				fseek(tempf, 0L, 0);
				if (debugging) {
					printf("[tbeg set to %d]\n",
					    (int)tbeg);
				}
				wbehind = 0;
			}
			if (bufp[-1] == '\n')
				add_shift(nls, ftell(workf), MAX_C_A + 1);
			if ((n > rahead) && wbehind) {
				fwrite(bufp0, 1, n - rahead, tempf);
				if (debugging) {
					printf("[writing %ld from bufp0]\n",
					    n - rahead);
				}
			}
			fwrite(str2, 1, s2l, tempf);
			n = rahead - s1l;
			if (debugging) {
				printf("[n now %ld]\n", n);
			}
			if (n > 0) {
				bcopy(bufp - n, bufp0, n);
				if (debugging) {
					printf("[copying %ld back]\n", n);
				}
			}
			bufp = bufp0 + n;
		} else {
			if (bufp[-1] == '\n')
				add_shift(nls, ftell(workf), MAX_C_A + 1);
			if (bufp >= bufpmax) {
				if (tbeg >= 0) {
					fwrite(bufp0, 1, n - rahead, tempf);
					if (debugging) {
						printf("[flushing %ld]\n",
						    n - rahead);
					}
				}
				n = rahead;
				bcopy(bufp - n, bufp0, n);
				if (debugging) {
					printf("[n now %ld]\n[copying %ld back]\n", n, n);
				}
				bufp = bufp0 + n;
			}
		}
	}
}