0
@@ -61,7 +61,7 @@ typedef struct {
0
unsigned int namestart, datastart, datapos, dataend, vdelta;
0
@@ -87,6 +87,7 @@ binject_exe_alloc(VALUE klass)
0
binject_exe_t *binj = ALLOC(binject_exe_t);
0
MEMZERO(binj, binject_exe_t, 1);
0
binj->adds = rb_ary_new();
0
return Data_Wrap_Struct(klass, binject_exe_mark, binject_exe_free, binj);
0
@@ -272,16 +273,18 @@ binject_exe_data_len(binject_exe_t *binj)
0
-binject_exe_string_copy(binject_exe_t *binj, char *str, unsigned int size, unsigned int pos
)
0
+binject_exe_string_copy(binject_exe_t *binj, char *str, unsigned int size, unsigned int pos
, VALUE proc)
0
int mark = ftell(binj->out);
0
fseek(binj->out, pos, SEEK_SET);
0
fwrite(str, sizeof(char), size, binj->out);
0
+ rb_funcall(proc, rb_intern("call"), 1, INT2NUM(size));
0
fseek(binj->out, mark, SEEK_SET);
0
-binject_exe_file_copy(FILE *file, FILE *out, unsigned int size, unsigned int pos1, unsigned int pos2
)
0
+binject_exe_file_copy(FILE *file, FILE *out, unsigned int size, unsigned int pos1, unsigned int pos2
, VALUE proc)
0
int mark1 = ftell(file), mark2 = ftell(out);
0
@@ -292,6 +295,8 @@ binject_exe_file_copy(FILE *file, FILE *out, unsigned int size, unsigned int pos
0
unsigned int len = size > BUFSIZE ? BUFSIZE : size;
0
fread(buf, sizeof(char), len, file);
0
fwrite(buf, sizeof(char), len, out);
0
+ rb_funcall(proc, rb_intern("call"), 1, INT2NUM(len));
0
fseek(file, mark1, SEEK_SET);
0
@@ -402,20 +407,20 @@ binject_exe_rewrite(binject_exe_t *binj, char *buf, char *out, int offset, int o
0
if (ctype == rb_cString)
0
rdat->Size = RSTRING_LEN(obj);
0
- binject_exe_string_copy(binj, RSTRING_PTR(obj), RSTRING_LEN(obj), binj->datapos
);
0
+ binject_exe_string_copy(binj, RSTRING_PTR(obj), RSTRING_LEN(obj), binj->datapos
, binj->proc);
0
rdat->Size = binject_exe_file_size(obj);
0
GetOpenFile(obj, fptr);
0
- binject_exe_file_copy(GetReadFile(fptr), binj->out, rdat->Size, 0, binj->datapos
);
0
+ binject_exe_file_copy(GetReadFile(fptr), binj->out, rdat->Size, 0, binj->datapos
, binj->proc);
0
binj->datapos += rdat->Size;
0
padlen = BINJ_PAD(rdat->Size, 4) - rdat->Size;
0
- binject_exe_string_copy(binj, pe_pad, padlen, binj->datapos
);
0
+ binject_exe_string_copy(binj, pe_pad, padlen, binj->datapos
, binj->proc);
0
binj->datapos += padlen;
0
@@ -438,7 +443,7 @@ binject_exe_rewrite(binject_exe_t *binj, char *buf, char *out, int offset, int o
0
// printf("RESDATA: %x TO %x AT %x / %x\n", rde->OffsetToData, rde2->OffsetToData,
0
// binj->namestart, binj->datastart);
0
binject_exe_file_copy(binj->file, binj->out, rdat->Size,
0
- rdat->OffsetToData - binj->vdelta, binj->datapos
);
0
+ rdat->OffsetToData - binj->vdelta, binj->datapos
, binj->proc);
0
// printf("DATA: %x TO %x\n", rdat->OffsetToData, binj->datapos);
0
binj->datapos += rdat->Size;
0
binj->dataend = (rdat->OffsetToData - binj->vdelta) + rdat->Size;
0
@@ -514,6 +519,7 @@ binject_exe_save(VALUE self, VALUE file)
0
+ binj->proc = rb_block_proc();
0
fseek(binj->file, 0, SEEK_SET);
Comments
No one has commented yet.