Ayala 发表于 2017-6-12 13:26:37

【C】源代码兼容 xp驱动中使用safecrt



/*simple.c*/
#include <ntdef.h>
#include <ntddk.h>
#include <wchar.h>

/*注册个 safecrt 回调函数*/
void __cdecl _invalid_parameter(
    const wchar_t *pszExpression,
    const wchar_t *pszFunction,
    const wchar_t *pszFile,
    unsigned int nLine,
    unsigned int*pReserved
    )
{
       
}

/*test */
void foo()
{
        static wchar_t buf;
        swprintf_s(&buf,L"%s\n",L"0xaa55.com");
}


/**/
NTSTATUS __stdcall
DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pRegistryPath)
{
        foo();
        return STATUS_DEVICE_CONFIGURATION_ERROR;
}


#sources
MINORCOMP=simple
TARGETNAME=simple
TARGETTYPE=DRIVER
#TARGETPATH=..\..\sys


MSC_WARNING_LEVEL=/W3

SOURCES=simple.c


#BUFFER_OVERFLOW_CHECKS=0

TARGETLIBS= $(CRT_LIB_PATH)\safecrtnt.lib

页: [1]
查看完整版本: 【C】源代码兼容 xp驱动中使用safecrt