首页
社区
课程
招聘
[求助]这段代码哪里错了呀?
发表于: 2011-4-13 02:44 4342

[求助]这段代码哪里错了呀?

2011-4-13 02:44
4342
#include <ntddk.h>
#include <windef.h>
#include <stdlib.h>
NTSTATUS HookNtReadMemory( IN HANDLE ProcessHandle,
IN PVOID BaseAddress,
OUT PVOID Buffer,
IN ULONG NumberOfBytesToRead,
OUT PULONG NumberOfBytesReaded OPTIONAL );

NTSTATUS Hook_NtWriteVirtualMemory( IN HANDLE ProcessHandle,
IN PVOID BaseAddress,
IN PVOID Buffer,
IN ULONG NumberOfBytesToWrite,
OUT PULONG NumberOfBytesWritten OPTIONAL );
void FuncitonHook();
BYTE OriginalBytes[7]={0}; //保存原始函数前五个字节
BYTE JmpAddress[7]={0xB8,0,0,0,0,0xFF,0xE0}; //跳转到HOOK函数的地址
ULONG Read_Address;
typedef struct ServiceDescriptorEntry {
unsigned int *ServiceTableBase; //指向系统服务程序的地址(SSDT)
//指向另一个索引表,该表包含了每个服务表项被调用的次数;不过这个值只在Checkd Build的内核中有效,在Free Build的内核中,这个

值总为NULL
unsigned int *ServiceCounterTableBase;
unsigned int NumberOfServices; //表示当前系统所支持的服务个数
unsigned char *ParamTableBase; //指向SSPT中的参数地址,它们都包含了NumberOfService这么多个数组单元
} ServiceDescriptorTableEntry , *PServiceDescriptorTableEntry;

extern PServiceDescriptorTableEntry KeServiceDescriptorTable;

ULONG RetFunctionAddress(ULONG id)
{
ULONG UAddress=(ULONG)KeServiceDescriptorTable->ServiceTableBase+id*4;
return UAddress;

}

void UnDriverload(IN PDRIVER_OBJECT DriverObject)
{
KdPrint(("驱动卸载成功!"));
}
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegPath)
{
KdPrint(("驱动加载成功"));
FuncitonHook();
DriverObject->DriverUnload=UnDriverload;
return STATUS_SUCCESS;
}

void FuncitonHook()
{
Read_Address =(ULONG)RetFunctionAddress(186);
RtlCopyMemory(OriginalBytes,Read_Address,7);
*(ULONG *)(JmpAddress+1)=(ULONG)HookNtReadMemory-(*(ULONG*)Read_Address+5);

}

姥姥的!怎么改都没法子编译通过!
inline HOOK前的代码没写 HOOK的时候是能编译通过的!@
谁知道写了破代码后,就怎么搞都痛不了!不知道代码什么地方错了问题呀?


1>d:\winddk\7600.16385.1\1\test_inline1.c(51) : warning C4022: 'memcpy' : pointer mismatch for actual parameter 2
1>warnings in directory d:\winddk\7600.16385.1\1
1>d:\winddk\7600.16385.1\1\test_inline1.c(51) : warning C4022: 'memcpy' : pointer mismatch for actual parameter 2
1> D:\WinDDK\7600.16385.1\Bin\x86\oacr\oacrlink /out:SYS\i386\Test_inline.sys /machine:ix86 @d:\winddk\7600.16385.1\1\objchk_wxp_x86\i386\lnk.rsp

[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

收藏
免费 0
支持
分享
最新回复 (4)
雪    币: 349
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
无论怎样也要把编译错误信息发一下啊,直接看得蛋疼。
2011-4-13 07:55
0
雪    币: 2362
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
没有错误提示吗?
2011-4-13 07:56
0
雪    币: 7
活跃值: (22)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
刚测试了好像是

*(ULONG *)(JmpAddress+1)=(ULONG)HookNtReadMemory-((ULONG)Read_Address +5);
这句代码错了问题,但是我砸看见好像没有写错啊?
2011-4-13 09:24
0
雪    币: 7
活跃值: (22)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
明白了,我的只声明了未进行函数的实例功能
所以的话,导致了上面的错误,!!娘的,原本打算后面添加的,谁知道这个鬼错误搞了好几个小时!
吸收经验呀@!!
2011-4-13 09:49
0
游客
登录 | 注册 方可回帖
返回
//