首页
社区
课程
招聘
[求助]打印出来的进程名,中文乱码
发表于: 2010-5-31 12:01 6150

[求助]打印出来的进程名,中文乱码

2010-5-31 12:01
6150
PID = *(PULONG)(pEProcess + PROCESS_ID_OFFSET);
    pFileName = (PUCHAR)(pEProcess + FILE_NAME_OFFSET);
    pProcessPtr[nProcessCount].pEProcess = pEProcess;
    pProcessPtr[nProcessCount].PId = PID;
    strcpy( pProcessPtr[nProcessCount].Name , pFileName);
    DbgPrint("0x%08X  %04d   %s\n",pEProcess,PID,(char*)pEProcess+FILE_NAME_OFFSET);
不管怎么打印都是 中文名进程都是乱码,转换到 ANSI_STRING 也是乱码

[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

收藏
免费 0
支持
分享
最新回复 (5)
雪    币: 773
活跃值: (442)
能力值: ( LV9,RANK:200 )
在线值:
发帖
回帖
粉丝
2
传回应用层也是乱码
2010-5-31 13:08
0
雪    币: 217
活跃值: (68)
能力值: ( LV12,RANK:210 )
在线值:
发帖
回帖
粉丝
3
%S吧 大写
2010-5-31 13:41
0
雪    币: 773
活跃值: (442)
能力值: ( LV9,RANK:200 )
在线值:
发帖
回帖
粉丝
4
我主要是想 把R0枚举的进程信息,进程名 传递到 RING3 ,在R0 下打印 是乱码 ,传递到 RING3 也是乱码
如何才能接收到正确的信息 怎么转换。。。。
2010-5-31 13:59
0
雪    币: 170
活跃值: (90)
能力值: ( LV12,RANK:210 )
在线值:
发帖
回帖
粉丝
5
void GetProcessPath(ULONG eprocess,CHAR ProcessPath[256])
{
	ULONG object;
	PFILE_OBJECT FilePointer;
	UNICODE_STRING path;  //路径
	UNICODE_STRING name;  //盘符
	ANSI_STRING  string;
	path.Length=0;
    path.MaximumLength=256;
	path.Buffer=(PWCHAR)ExAllocatePoolWithTag(NonPagedPool,256,MEM_TAG);     //必须释放
	if(MmIsAddressValid((PULONG)(eprocess+0x138)))//Eprocess->sectionobject(0x138)
	{
		object=(*(PULONG)(eprocess+0x138));
        KdPrint(("[GetProcessFileName] sectionobject :0x%x\n",object));
		if(MmIsAddressValid((PULONG)((ULONG)object+0x014)))
		{
			object=*(PULONG)((ULONG)object+0x014);
			KdPrint(("[GetProcessFileName] Segment :0x%x\n",object));
			if(MmIsAddressValid((PULONG)((ULONG)object+0x0)))
			{
				object=*(PULONG)((ULONG_PTR)object+0x0);
				KdPrint(("[GetProcessFileName] ControlAera :0x%x\n",object));
				if(MmIsAddressValid((PULONG)((ULONG)object+0x024)))
				{
					object=*(PULONG)((ULONG)object+0x024);
					KdPrint(("[GetProcessFileName] FilePointer :0x%x\n",object));
				}
				else
					return ;
			}
			else
				return ;
		}
		else
			return ;
	}
	else
		return ;
    FilePointer=(PFILE_OBJECT)object;
    //KdPrint(("[GetProcessFileName] FilePointer :%wZ\n",&FilePointer->FileName));
	ObReferenceObjectByPointer((PVOID)FilePointer,0,NULL,KernelMode);//引用计数+1,操作对象
	RtlVolumeDeviceToDosName(FilePointer->DeviceObject,&name); //获取盘符名
	//KdPrint(("[GetProcessFileName] FilePointer :%wZ\n",&name));
    RtlCopyUnicodeString(&path,&name);//盘符连接
	RtlAppendUnicodeStringToString(&path,&FilePointer->FileName);//路径连接
	//KdPrint(("[GetProcessFileName] FilePointer :%wZ\n",&path));
	ObDereferenceObject(FilePointer);         //关闭对象引用
	//需要转换成ANSI_STRING,然后在转换成char输出给ring3
	RtlUnicodeStringToAnsiString(&string,&path,TRUE);    //释放内存
	if(string.Length >= 256 ) //保证以\0结尾
	{ 
		memcpy(ProcessPath, string.Buffer, 256); 
		*(ProcessPath + 255) = 0; 
	} 
	else 
	{ 
		memcpy(ProcessPath, string.Buffer, string.Length); 
		ProcessPath[string.Length] = 0; 
	}
	ExFreePool(path.Buffer); //释放
	RtlFreeAnsiString(&string);//释放
}
用这个函数  依据eprocess得到进程全路径
2010-5-31 14:21
0
雪    币: 773
活跃值: (442)
能力值: ( LV9,RANK:200 )
在线值:
发帖
回帖
粉丝
6
谢谢了,竹君
2010-5-31 15:05
0
游客
登录 | 注册 方可回帖
返回
//