html tool

显示标签为“vc”的博文。显示所有博文
显示标签为“vc”的博文。显示所有博文

2019年3月12日星期二

转:对COM 组件的调用返回了错误 HRESULT E_FAIL"的解决方法


https://blog.csdn.net/mr_wanter/article/details/8847898

调用SHDOCVW(web浏览器) COM组件的时候,返回了错误 HRESULT E_FAIL。总结如下:
  1. 在控制面板--->管理工具--->服务 中,开启Distributed Transaction Coordinator 服务。
【popexizhi: 原文中的第二步没有找到,但是设置这个就好了】

2019年3月3日星期日

ObReferenceObjectByHandle说明




参考:https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdm/nf-wdm-obreferenceobjectbyhandle

   

code: 


 status = ObReferenceObjectByHandle(\

                                          ThreadHandle,\  //这个是当前方法的input

                                          THREAD_ALL_ACCESS,\

                                          PsThreadType,\

                                          KernelMode,\

                                         &pTargetThread,\

                                         NULL);

 [popexizhi:

 参数中要go的

   *  PsThreadType
   *  KernelMode

 这里的 PsThreadType定义为

 extern POBJECT_TYPE NTSYSAPI PsThreadType;

 ]
 

参数说明 


 The ObReferenceObjectByHandle routine provides access validation on the object handle, and, if access can be granted, returns the corresponding pointer to the object's body.

 [popexizhi译: obReferenceObjectByHandle  常规的对象句柄的访问权限验证, 如果验证通过,返回对象体指针位置]

 NTSTATUSObReferenceObjectByHandle( HANDLE Handle, ACCESS_MASK DesiredAccess, POBJECT_TYPE ObjectType, KPROCESSOR_MODE AccessMode, PVOID *Object, POBJECT_HANDLE_INFORMATION HandleInformation );
        [ObjectType]

 Pointer to the object type. ObjectType can be *ExEventObjectType, *ExSemaphoreObjectType, *IoFileObjectType, *PsProcessType, *PsThreadType, *SeTokenObjectType, *TmEnlistmentObjectType, *TmResourceManagerObjectType, *TmTransactionManagerObjectType, or *TmTransactionObjectType.

 If ObjectType is not NULL, the operating system verifies that the supplied object type matches the object type of the object that Handle specifies.

 [pope译:

 如果ObjectType 不是NULL, 操作系统校验 提供的一个参数定义的Handle是否匹配为此对象的类型。

  ]
        [AccessMode]

 Specifies the access mode to use for the access check. It must be either UserMode or KernelMode. Drivers should always specify UserMode for handles they receive from user address space.

 [pope译:

 指定访问模式 ,此模式是用来进行访问检测的;它只能是UserMode 或者 KernelMode。

 驱动 应该使用UserMode 的handles,用来接受用户地址空间内容。 

 ]

2019年2月21日星期四

PsGetProcessImageFileName


PsGetProcessImageFileName
  • https://community.osr.com/discussion/109252/psgetprocessimagefilename

    问:in my filter driver, i would like to get the process name using PsGetProcessImageFileName. but it is not documented. can anyone tell me the pros and cons of using PsGetProcessImageFileName
    答:
    IIRC this only returns the short name (without directory path), it is ANSI
    and is limited to 8.3. These are the names you see in Task Manager.
    PsGetProcessImageFileName just returns the EPROCESS field, which has all of
    the above limitations.

    PS:
    1. PsGetProcessImageFileName 没有官方的文档说明
    2. PsGetProcessImageFileName 编码是ANSI,Task Manager中看到的名字返回,无路径说明。

    -ansi编码
    在简体中文Windows操作系统中,ANSI 编码代表GBK 编码;在繁体中文Windows操作系统中,ANSI编码代表Big5;在日文Windows操作系统中,ANSI 编码代表Shift_JIS 编码。



PsGetCurrentProcess



PsGetCurrentProcess
  • https://docs.microsoft.com/zh-cn/windows-hardware/drivers/kernel/mm-bad-pointer#psgetcurrentprocess
    Defined in: Ntddk.h
    Returns a pointer to the process of the current thread.

2019年2月20日星期三

NTSTATUS 和 NTAPI

源方法定义如下:

NTSTATUS
NTAPI
DetourNtResumeThread (
 IN HANDLE ThreadHandle,
 OUT PULONG PreviousSuspendCount
 )
{
 ...
}



NTSTATUS

  • 参见: https://baike.baidu.com/item/NTSTATUS
    NTSTATUS 是被定义为32位的无符号长整型。在驱动程序开发中,人们习惯用 NTSTATUS 返回状态。其中0~0X7FFFFFFF,被认为是正确的状态,而0X80000000~0XFFFFFFFF被认为是错误的状态。
    有一个非常有用的宏-----NT_SUCCESS,用来检测状态是否正确。   

NTAPI

  • 参见:https://bbs.csdn.net/topics/260042764
 NTAPI在winnt.h中有定义:
#if ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)) && !defined(_M_AMD64)
#define NTAPI __stdcall
#else
#define NTAPI
#endif
  • __stdcall
    • 参见: https://baike.baidu.com/item/__stdcall
      __stdcall是函数调用约定的一种,函数调用约定主要约束了两件事:
      1.参数传递顺序
      2.调用堆栈由谁(调用函数或被调用函数)清理
      常见的函数调用约定:stdcall cdecl fastcall thiscall naked call
      __stdcall表示
      1.参数从右向左压入堆栈
      2.函数被调用者修改堆栈
      3.函数名(在编译器这个层次)自动加前导的下划线,后面紧跟一个@符号,其后紧跟着参数的尺寸
      在win32应用程序里,宏APIENTRY,WINAPI,都表示_stdcall,非常常见
      (PS:关键字主要见于Microsoft Visual C、C++。GNU的C、C++是另外一种修饰方式:__attribute__((stdcall)))



2019年2月18日星期一

转:设置Visual Studio代码窗口背景颜色

https://blog.csdn.net/u010913001/article/details/50788308


打开Visual Studio,在菜单栏找到【工具】,【选项】,【环境】→【字体和颜色】
在右侧选择【纯文本】,【背景色】,【自定义】,

在颜色对话框中,右侧色调、饱和度、亮度栏,分别输入84、91、205

单击【添加到自定义颜色】→【确定】回到选项对话框中,点击【确定】,

好了,这时你应该会有惊喜,因为窗口已经变色啦

这种苹果绿,是保护视力最好的颜色哦

2019年1月29日星期二

转:关于编译器找不到stdafx.h头文件的问题


https://blog.csdn.net/ningz6610/article/details/8911767


用到stdafx这个预编译头文件,一定是在使用MFC的工程中。头文件预编译,就是把一个工程中使用的头文件预先编译,以后该工程编译时,不再编译这部分头文件,仅使用预编译的结果,这样可以加快编译速度,节省时间。一般该stdafx.cpp文件仅包含若干头文件,并没有其他代码。所有的MFC 的.cpp文件第一条语句都是#include“stdafx.h”.

首次编译时,选择 工程-属性-配置属性-C/C++-预编译头文件在预编译头选项中选择 创建 。编译过一次,已经正确创建预编译头文件之后,该选项选择 使用。之后就可以正常编译了。