新手学VC问题 void UINT问题

前面一段时间用:
void DecodeShellCode(unsigned char * ShellCode, int LEN, unsigned char SEED)
{
for(int i=0;i<LEN;i++)
{
ShellCode[i] ^= SEED;
}
}
做一个XOR解密,没有问题

最近新加了一个函数调用
UINT API_RegDeleteKey(LPSTR lpBuffer,UINT uSize)
{
UINT result;
typedef UINT (WINAPI *lpAddFun)(LPSTR,UINT); //返回值,形参类型参考函数定义
HINSTANCE hDll=LoadLibrary("advapi32.dll"); //函数所在的DLL
lpAddFun addFun=(lpAddFun)GetProcAddress(hDll,"RegDeleteKeyA"); //函数名字
if (addFun != NULL)
{
addFun(lpBuffer,uSize); //调用函数
FreeLibrary(hDll); //释放句柄
}
return result;
}
调用RegDeleteKey
两者分开用,都可以编译,但是合在一个程序里面就不行了。老出错。请大家帮帮忙!
hello.c
\C程序\hello.c(318) : error C2143: syntax error : missing ';' before 'type'
\C程序\hello.c(318) : error C2143: syntax error : missing ';' before 'type'
C程序\hello.c(318) : error C2143: syntax error : missing ')' before 'type'
C程序\hello.c(318) : error C2143: syntax error : missing ';' before 'type'
\C程序\hello.c(318) : error C2065: 'i' : undeclared identifier
\C程序\hello.c(318) : warning C4552: '<' : operator has no effect; expected operator with side-effect
C程序\hello.c(318) : error C2059: syntax error : ')'
\C程序\hello.c(319) : error C2143: syntax error : missing ';' before '{'
\C程序\hello.c(342) : warning C4133: 'function' : incompatible types - from 'struct HKEY__ *' to 'char *'
C程序\hello.c(342) : warning C4047: 'function' : 'unsigned int ' differs in levels of indirection from 'char [92]'
\C程序\hello.c(342) : warning C4024: 'API_RegDeleteKey' : different types for formal and actual parameter 2
执行 cl.exe 时出错.
hello.exe - 1 error(s), 0 warning(s)

由于你的源文件是C语言的,不是C++的,所以变量的声明要在函数的开头进行

void DecodeShellCode(unsigned char * ShellCode, int LEN, unsigned char SEED)
{
for(int i=0;i<LEN;i++)
{
ShellCode[i] ^= SEED;
}
}

改为:
void DecodeShellCode(unsigned char * ShellCode, int LEN, unsigned char SEED)
{
int i;

for(i=0;i<LEN;i++)
{
ShellCode[i] ^= SEED;
}
}
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网