找回密码
 立即注册→加入我们

QQ登录

只需一步,快速开始

搜索
热搜: 下载 VB C 实现 编写
查看: 2186|回复: 0

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

[复制链接]

30

主题

210

回帖

2778

积分

用户组: 版主

UID
1821
精华
7
威望
69 点
宅币
2159 个
贡献
206 次
宅之契约
0 份
在线时间
480 小时
注册时间
2016-7-12
发表于 2017-6-12 13:26:37 | 显示全部楼层 |阅读模式

欢迎访问技术宅的结界,请注册或者登录吧。

您需要 登录 才可以下载或查看,没有账号?立即注册→加入我们

×


  1. /*simple.c*/
  2. #include <ntdef.h>
  3. #include <ntddk.h>
  4. #include <wchar.h>

  5. /*注册个 safecrt 回调函数*/
  6. void __cdecl _invalid_parameter(
  7.     const wchar_t *pszExpression,
  8.     const wchar_t *pszFunction,
  9.     const wchar_t *pszFile,
  10.     unsigned int nLine,
  11.     unsigned int  *pReserved
  12.     )
  13. {
  14.        
  15. }

  16. /*test */
  17. void foo()
  18. {
  19.         static wchar_t buf[256];
  20.         swprintf_s(&buf,L"%s\n",L"0xaa55.com");
  21. }


  22. /**/
  23. NTSTATUS __stdcall
  24. DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pRegistryPath)
  25. {
  26.         foo();
  27.         return STATUS_DEVICE_CONFIGURATION_ERROR;
  28. }
复制代码


  1. #sources
  2. MINORCOMP=simple
  3. TARGETNAME=simple
  4. TARGETTYPE=DRIVER
  5. #TARGETPATH=..\..\sys


  6. MSC_WARNING_LEVEL=/W3

  7. SOURCES=simple.c


  8. #BUFFER_OVERFLOW_CHECKS=0

  9. TARGETLIBS= $(CRT_LIB_PATH)\safecrtnt.lib

复制代码

本帖被以下淘专辑推荐:

回复

使用道具 举报

QQ|Archiver|小黑屋|技术宅的结界 ( 滇ICP备16008837号 )|网站地图

GMT+8, 2024-4-20 21:15 , Processed in 0.043000 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表