最近在学习看雪论坛出版的0day安全:软件漏洞分析技术,在第二第三章的例子实践中总是出现这样的错误:
Compiling...
search_opcode.cpp
d:\winddk\2600\inc\wxp\winreg.h(107) : error C2146: syntax error : missing ';' before identifier 've_valueptr'
d:\winddk\2600\inc\wxp\winreg.h(107) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
d:\winddk\2600\inc\wxp\winreg.h(107) : error C2501: 've_valueptr' : missing storage-class or type specifiers
d:\winddk\2600\inc\wxp\winreg.h(113) : error C2146: syntax error : missing ';' before identifier 've_valueptr'
d:\winddk\2600\inc\wxp\winreg.h(113) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
d:\winddk\2600\inc\wxp\winreg.h(113) : error C2501: 've_valueptr' : missing storage-class or type specifiers
d:\winddk\2600\inc\wxp\winreg.h(145) : error C2065: 'HKEY' : undeclared identifier
d:\winddk\2600\inc\wxp\winreg.h(146) : error C2146: syntax error : missing ')' before identifier 'hKey'
d:\winddk\2600\inc\wxp\winreg.h(146) : warning C4229: anachronism used : modifiers on data are ignored
d:\winddk\2600\inc\wxp\winreg.h(146) : error C2491: 'RegCloseKey' : definition of dllimport data not allowed
希望大神们出手相助,感激不尽!
源代码:
#include <windows.h>
#include <stdio.h>
#define DLL_NAME "user32.dll"
main()
{
BYTE* ptr;
int position,address;
HINSTANCE handle;
BOOL done_flag = FALSE;
handle=LoadLibrary(DLL_NAME);
if(!handle)
{
printf(" load dll erro !");
exit(0);
}
ptr = (BYTE*)handle;
for(position = 0; !done_flag; position++)
{
try
{
if(ptr[position] == 0xFF && ptr[position+1] == 0xE4)
{
//0xFFE4 is the opcode of jmp esp
int address = (int)ptr + position;
printf("OPCODE found at 0x%x\n",address);
}
}
catch(...)
{
int address = (int)ptr + position;
printf("END OF 0x%x\n", address);
done_flag = true;
}
}
}
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!