能力值:
( LV12,RANK:210 )
|
-
-
16 楼
BYTE flowCode1[] = {......};
BYTE flowCode2[] = { ........};
BYTE flowCode3[] = { .........};
f:\src\wg\src\common\dbginfo\dbginfo.cpp(17) : error C2466: cannot allocate an array of constant size 0
f:\src\wg\src\common\dbginfo\dbginfo.cpp(17) : error C2143: syntax error : missing '}' before '...'
f:\src\wg\src\common\dbginfo\dbginfo.cpp(17) : error C2143: syntax error : missing ';' before '...'
f:\src\wg\src\common\dbginfo\dbginfo.cpp(17) : error C2059: syntax error : '...'
f:\src\wg\src\common\dbginfo\dbginfo.cpp(17) : error C2143: syntax error : missing ';' before '}'
f:\src\wg\src\common\dbginfo\dbginfo.cpp(17) : error C2059: syntax error : '}'
f:\src\wg\src\common\dbginfo\dbginfo.cpp(19) : error C2466: cannot allocate an array of constant size 0
f:\src\wg\src\common\dbginfo\dbginfo.cpp(19) : error C2143: syntax error : missing '}' before '...'
f:\src\wg\src\common\dbginfo\dbginfo.cpp(19) : error C2143: syntax error : missing ';' before '...'
f:\src\wg\src\common\dbginfo\dbginfo.cpp(19) : error C2059: syntax error : '...'
f:\src\wg\src\common\dbginfo\dbginfo.cpp(19) : error C2143: syntax error : missing ';' before '}'
f:\src\wg\src\common\dbginfo\dbginfo.cpp(19) : error C2059: syntax error : '}'
f:\src\wg\src\common\dbginfo\dbginfo.cpp(21) : error C2466: cannot allocate an array of constant size 0
f:\src\wg\src\common\dbginfo\dbginfo.cpp(21) : error C2143: syntax error : missing '}' before '...'
f:\src\wg\src\common\dbginfo\dbginfo.cpp(21) : error C2143: syntax error : missing ';' before '...'
f:\src\wg\src\common\dbginfo\dbginfo.cpp(21) : error C2059: syntax error : '...'
f:\src\wg\src\common\dbginfo\dbginfo.cpp(21) : error C2143: syntax error : missing ';' before '}'
f:\src\wg\src\common\dbginfo\dbginfo.cpp(21) : error C2059: syntax error : '}'
|
能力值:
( LV12,RANK:210 )
|
-
-
20 楼
有个奇怪的问题:
mov ecx,nflwLen
mov esi,flw
repz cmp**
or ecx,ecx
jnz MYLOOP
对于memcmp(src, dest, size)的代码是这样的
xor eax, eax
mov ecx, size
mov esi, src
mov edi, dest
repz cmp**
jz __equ
**b eax, eax
**b eax, 0xffffffff
__equ:
就是说这个or ecx, ecx是多余的吧, 而且影响到判断,
如果最后一个字节不等, 那么ecx还是0, 毕竟所有的字节都扫描过了,
但他们却不相等。
cmp** 会根据设置的条件 rep(z) 来结束循环, 所以只需
在结束后判断flag就行。
一直对这个指令有迷糊, 刚参考了下intel, 感觉应该是这样的
Operation
temp ←SRC1 − SRC2;
SetStatusFlags(temp);
IF (byte comparison)
THEN IF DF = 0
THEN
(E)SI ← (E)SI + 1;
(E)DI ← (E)DI + 1;
ELSE
(E)SI ← (E)SI – 1;
(E)DI ← (E)DI – 1;
FI;
ELSE IF (word comparison)
THEN IF DF = 0
(E)SI ← (E)SI + 2;
(E)DI ← (E)DI + 2;
ELSE
(E)SI ← (E)SI – 2;
(E)DI ← (E)DI – 2;
FI;
ELSE (* doubleword comparison*)
THEN IF DF = 0
(E)SI ← (E)SI + 4;
(E)DI ← (E)DI + 4;
ELSE
(E)SI ← (E)SI – 4;
(E)DI ← (E)DI – 4;
FI;
FI;
|
能力值:
( LV12,RANK:210 )
|
-
-
23 楼
// A Test Simple
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
//找出花指令的位置并去掉花指令
void FindFlowerCodeAndRemove2(LPVOID src, LPVOID flw, int nSrcLen,int nflwLen)
{
__asm
{
xor eax,eax
push esi
push edi
push ecx
cld
mov esi,flw
mov edi,src
mov ecx,nSrcLen
lodsb
Start:
repnz scasb
or ecx,ecx
jz NotFindFlower
push eax
push ecx
push esi
push edi
lea edi,[edi - 1]
mov ecx,nflwLen
mov esi,flw
repz cmpsb
// or ecx,ecx // comment this BUG line
jnz MYLOOP
mov ecx,nflwLen
sub edi,nflwLen
mov al,0x90
rep stosb
MYLOOP:
pop edi
pop esi
pop ecx
pop eax
jmp Start
NotFindFlower:
pop ecx
pop edi
pop esi
}
}
void FindFlowerCodeAndRemove(LPVOID src, LPVOID flw, int nSrcLen,int nflwLen)
{
__asm
{
xor eax,eax
push esi
push edi
push ecx
cld
mov esi,flw
mov edi,src
mov ecx,nSrcLen
lodsb
Start:
repnz scasb
or ecx,ecx
jz NotFindFlower
push eax
push ecx
push esi
push edi
lea edi,[edi - 1]
mov ecx,nflwLen
mov esi,flw
repz cmpsb
or ecx,ecx
jnz MYLOOP
mov ecx,nflwLen
sub edi,nflwLen
mov al,0x90
rep stosb
MYLOOP:
pop edi
pop esi
pop ecx
pop eax
jmp Start
NotFindFlower:
pop ecx
pop edi
pop esi
}
}
BYTE flowCode1[] = {0x30, 0x31, 0x32}; // ......表示你的花指令组合,这个需要你自己替换了。
BYTE src[14] = {'a', 'b', 'c', '0', '1', 'd', 'e', 'f', '0', '1', '2', 'g', 'h', 'i' };
BYTE expect_result[14] = {'a', 'b', 'c', '0', '1', 'd', 'e', 'f', 0x90, 0x90, 0x90, 'g', 'h', 'i' };
void hex_print(BYTE *buf, size_t size)
{
while(size --)
printf("%.2x ", *buf++);
printf("\n");
}
void check_it(BYTE *result)
{
if (0 == memcmp(result, expect_result, 14))
printf("Right!\n");
else
printf("Wrong!\n");
}
int main(int argc, char* argv[])
{
BYTE buf[14];
// method 1: test ecx
memcpy(buf, src, sizeof(buf));
printf("src is :");
hex_print(buf, sizeof(buf));
printf("flower is:");
hex_print(flowCode1, sizeof(flowCode1));
printf("FindFlowerCodeAndRemove with test ecx>>>>>>\n");
FindFlowerCodeAndRemove(buf, flowCode1, sizeof(buf),sizeof(flowCode1));
printf("now src is:");
hex_print(buf, sizeof(buf));
check_it(buf);
// again
printf("\n\nAnother test\n\n\n");
// method 2: test flag
memcpy(buf, src, sizeof(buf));
printf("src is :");
hex_print(buf, sizeof(buf));
printf("flower is:");
hex_print(flowCode1, sizeof(flowCode1));
printf("FindFlowerCodeAndRemove with test flag>>>>>>\n");
FindFlowerCodeAndRemove2(buf, flowCode1, sizeof(buf),sizeof(flowCode1));
printf("now src is:");
hex_print(buf, sizeof(buf));
check_it(buf);
return 0;
}
|