- 注册时间
- 2011-3-6
- 最后登录
- 1970-1-1
该用户从未签到
|
- ULONG MyReadMemory(IN PVOID BaseAddress,IN SIZE_T BufferSize,IN HANDLE pid)
- {
- PEPROCESS EProcess;
- KAPC_STATE ApcState;
- PVOID readbuffer;
- NTSTATUS status;
- status = PsLookupProcessByProcessId((HANDLE)pid,&EProcess);
- if(!NT_SUCCESS(status))
- {
- DbgPrint("failed to get the EPROCESS!!/n");
- return 0;
- }
- readbuffer = ExAllocatePoolWithTag (NonPagedPool, BufferSize, 'Sys');
- if(readbuffer==NULL)
- {
- DbgPrint("failed to alloc memory!/n");
- return 0;
- }
- *(ULONG*)readbuffer=(ULONG)0x1;
- KeStackAttachProcess (EProcess, &ApcState);
- __try
- {
- ProbeForRead ((CONST PVOID)BaseAddress, BufferSize, sizeof(CHAR));
- RtlCopyMemory (readbuffer, BaseAddress, BufferSize);
- KeUnstackDetachProcess (&ApcState);
-
- } __except(EXCEPTION_EXECUTE_HANDLER)
- {
- KeUnstackDetachProcess (&ApcState);
- }
-
- DbgPrint("%x/n",*(ULONG*)readbuffer);
- ExFreePool (readbuffer);
- return 1;
-
- }
复制代码 |
|