... | ... |
@@ -1670,9 +1670,10 @@ static uint8_t *disasm_x86(uint8_t *command, unsigned int len, struct DISASMED * |
1670 | 1670 |
} |
1671 | 1671 |
|
1672 | 1672 |
|
1673 |
-void disasmbuf(uint8_t *buff, unsigned int len, int fd) { |
|
1673 |
+int disasmbuf(uint8_t *buff, unsigned int len, int fd) { |
|
1674 | 1674 |
uint8_t *next = buff; |
1675 | 1675 |
unsigned int counter=0; |
1676 |
+ int gotsome=0; |
|
1676 | 1677 |
struct DISASMED s; |
1677 | 1678 |
struct MARIO { |
1678 | 1679 |
uint16_t real_op; |
... | ... |
@@ -1691,7 +1692,7 @@ void disasmbuf(uint8_t *buff, unsigned int len, int fd) { |
1691 | 1691 |
int i; |
1692 | 1692 |
if(!(next = disasm_x86(next, len, &s))) { |
1693 | 1693 |
/* TODO: invd opcode or buff over */ |
1694 |
- return; |
|
1694 |
+ return gotsome; |
|
1695 | 1695 |
} |
1696 | 1696 |
if(cli_debug_flag) { |
1697 | 1697 |
char hr[128]; |
... | ... |
@@ -1726,6 +1727,8 @@ void disasmbuf(uint8_t *buff, unsigned int len, int fd) { |
1726 | 1726 |
} |
1727 | 1727 |
} |
1728 | 1728 |
cli_writen(fd, &w, sizeof(w)); |
1729 |
+ gotsome = 1; |
|
1729 | 1730 |
} |
1731 |
+ return gotsome; |
|
1730 | 1732 |
} |
1731 | 1733 |
|
... | ... |
@@ -978,8 +978,8 @@ int cli_scanpe(cli_ctx *ctx) |
978 | 978 |
epsize = fmap_readn(map, epbuff, ep, 4096); |
979 | 979 |
|
980 | 980 |
CLI_UNPTEMP("DISASM",(exe_sections,0)); |
981 |
- disasmbuf((unsigned char*)epbuff, epsize, ndesc); |
|
982 |
- ret = cli_scandesc(ndesc, ctx, CL_TYPE_PE_DISASM, 1, NULL, AC_SCAN_VIR); |
|
981 |
+ if(disasmbuf((unsigned char*)epbuff, epsize, ndesc)) |
|
982 |
+ ret = cli_scandesc(ndesc, ctx, CL_TYPE_PE_DISASM, 1, NULL, AC_SCAN_VIR); |
|
983 | 983 |
close(ndesc); |
984 | 984 |
CLI_TMPUNLK(); |
985 | 985 |
free(tempfile); |
... | ... |
@@ -1428,11 +1428,6 @@ int cli_scanpe(cli_ctx *ctx) |
1428 | 1428 |
break; |
1429 | 1429 |
} |
1430 | 1430 |
|
1431 |
- if((src = (char *) cli_malloc(ssize)) == NULL) { |
|
1432 |
- free(exe_sections); |
|
1433 |
- return CL_EMEM; |
|
1434 |
- } |
|
1435 |
- |
|
1436 | 1431 |
if(!exe_sections[i + 1].rsz || !(src = fmap_need_off_once(map, exe_sections[i + 1].raw, ssize))) { |
1437 | 1432 |
cli_dbgmsg("Can't read raw data of section %d\n", i + 1); |
1438 | 1433 |
free(exe_sections); |
... | ... |
@@ -1672,12 +1667,6 @@ int cli_scanpe(cli_ctx *ctx) |
1672 | 1672 |
sections[t+1].rva = (((support[t*2]|(support[t*2+1]<<8))-2)<<12)-EC32(optional_hdr32.ImageBase); |
1673 | 1673 |
} |
1674 | 1674 |
|
1675 |
- if((src = (char *) cli_malloc(ssize)) == NULL) { |
|
1676 |
- free(exe_sections); |
|
1677 |
- free(sections); |
|
1678 |
- return CL_EMEM; |
|
1679 |
- } |
|
1680 |
- |
|
1681 | 1675 |
if(!exe_sections[i + 1].rsz || !(src = fmap_need_off_once(map, exe_sections[i + 1].raw, ssize))) { |
1682 | 1676 |
cli_dbgmsg("FSG: Can't read raw data of section %d\n", i); |
1683 | 1677 |
free(exe_sections); |