新手学VC问题 void UINT问题

来源:百度知道 编辑:UC知道 时间:2024/06/29 20:55:27
前面一段时间用:
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

由于你的源文件是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;
}
}