windows 杂项

本文介绍了Windows系统编程中的关键技术,如工作队列IoQueueWorkItemEx、内存管理(MDL和内存锁定)、原子操作、中断处理、时间函数、Win11改造、驱动开发中的互斥与同步,以及常用的调试工具如DbgPrint、windbg等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

源码

WRK

工作队列

IoQueueWorkItemEx 

voidIoQueueWorkItemEx(
  [in]           __drv_aliasesMem PIO_WORKITEM IoWorkItem,
  [in]           PIO_WORKITEM_ROUTINE_EX       WorkerRoutine,
  [in]           WORK_QUEUE_TYPE               QueueType,
  [in, optional] __drv_aliasesMem PVOID        Context
)
;

常用打印

DbgPrint

DbgPrintEx

KdPrint

KdPrintEx

vDbgPrintEx

原子操作

InterlockedIncrement

InterlockedDecrement64

InterlockedDecrement

InterlockedExchange

InterlockedCompareStore

InterlockedCompareExchange

InterlockedCompareExchangePointer

diable 警告

#pragma warning(disable : 4996)

Windows 锁

Fast mutexes

Guarded mutexes

注册表脚本

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI\xxx\Sriov]
"xxx"=dword:00000000

MDL

第一,MDL的一个用法是提供驱动程序访问用户模式数据缓冲区的一种方式:直接I/O。也就是说通过MDL告诉驱动程序如何访问用户模式的数据缓冲区,这很好理解;

第二,第二个用法是这样的,一些驱动程序在执行直接 I/O 来满足设备 I/O 控制请求时也使用 MDL,常用的方式如下:

1,分配一个buf,可能是分页或者非分页的;

2,调用IoAllocateMdl,指向这个buf;

3,对于分页内存来说,调用MmProbeAndLockPages以及MmGetSystemAddressForMdlSafe来锁定内存页,以防止被page out出去;

  对于非分页内存而言,调用MmBuildMdlForNonPagedPool映射到物理内存上。

Intel 64系统编程手册

Intel® 64 and IA-32 Architectures
Software Developer’s Manual

IRQL

ExAcquireFastMutex  提升到APC

系统callback 有可能变成APC 或者 Dispatch

时间函数

GetTickCount

KeQueryPerformanceCounter

windows上获取系统时间_windows获取1970-1-1时间戳命令-优快云博客

Win11 改造

reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve  右键

任务栏设置 任务栏行为 居左

分配pin的内存

VirtualAllocExNuma

常见的互斥

临界区

互斥器

信号量

CRITICAL_SECTION

InitializeCriticalSection()

CreateMutex()

OpenMutex()

CreateSemaphore

EnterCriticalSection()

WaitForSingleObject()

WaitForMultipleObjects()

MsgWaitForMultipleObjects()

WaitForSingleObject()

WaitForMultipleObjects()

MsgWaitForMultipleObjects()

...

LeaveCriticalSection()

ReleaseMutex()

ReleaseSemaphore()

DeleteCriticalSection()

CloseHandle()

CloseHandle()

内核同步对象-优快云博客  内核同步

https://blog.youkuaiyun.com/u012410612/category_1775195.html windows 驱动开发

数据长度

类型

win32

win64

linux32

linux64

char

1

1

1

1

short

2

2

2

2

int

4

4

4

4

long

4

4

4

8

long long

8

8

8

8

float

4

4

4

4

double

8

8

8

8

void*

4

8

4

8

D0,D1,D2,D3.正常的工作状态就是D0.D3是耗电最少的状态

Linux(centos7)历史命令UP/DOWN自动补全

Linux(centos7)历史命令UP/DOWN自动补全-腾讯云开发者社区-腾讯云

Linux内核里struct pci_dev里有一个叫is_physfn的域段, 从名字上来看,这个域段可以

用来表示一个pci设备是不是PF。对应的有一个is_virtfn的域段。

常用工具

depends22_x64.zip 

processhacker-2.39-bin.zip

TraceView

SysinternalsSuite.zip

DeviceTree-64bit.zip

查看静态库的信息要用命令行来实现:

dumpbin   /LINKERMEMBER   *.lib   >   1.txt

查看动态库的信息要用命令行来实现:

dumpbin   /EXPORTS  *.dll  >1.txt

 fsutil file createnew 文件名 文件大

procexp64.exe 查看已经加载的内核模式驱动

Msinfo32

Regsnap 注册表监控

Process Monitor 监控文件变化

获取hash

Get-FileHash .\xxx.zip* -Algorithm SHA512

Get-FileHash xxx -Algorithm MD5

获取设备信息

dmidecode -t memory | grep "^\sSize.*[0-9]\|^\sLocator"

Get-WmiObject win32_physicalmemory

wmic MemoryChip get DeviceLocator

wmic cpu list brief

wmic diskdrive get serialnumber

wmic memorychip get SerialNumber

wmic csproduct get IdentifyingNumber

Windows  dump 文件保存

Windows手动蓝屏触发方法_hklm\system\currentcontrolset\control\crashcontrol-优快云博客

reg add "HKLM\System\CurrentControlSet\Control\Session Manager\Memory Management" /v PagingFiles /t REG_MULTI_SZ /d "C:\pagefile.sys 8392 8392" /f

reg add "HKLM\System\CurrentControlSet\Control\CrashControl" /v DumpFile /t REG_EXPAND_SZ /d "C:\Windows\Memory.dmp" /f

reg add "HKLM\System\CurrentControlSet\Control\CrashControl" /v CrashDumpEnabled /t REG_DWORD /d 1 /f

reg add "HKLM\SYSTEM\CurrentControlSet\Services\kbdhid\Parameters" /v CrashOnCtrlScroll /t REG_DWORD /d 1 /f

reg add "HKLM\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters" /v CrashOnCtrlScroll /t REG_DWORD /d 1 /f

Pause

方法2: windbg .crash

Winddb 学习

Basic debugger commands/usage:

Defrag Tools: #20 - WinDbg - Basic Commands | Microsoft Learn (42:37 - 42.62)

Defrag Tools: #22 - WinDbg - Memory Kernel Mode | Microsoft Learn (45:23 45.38)

Defrag Tools #138 - Debugging - 'dx' Command Part 1 | Microsoft Learn (23:44 23.73)

Defrag Tools #139 - Debugging - 'dx' Command Part 2 | Microsoft Learn (20:28 20.47)

Defrag Tools: #27 - WinDbg - Configure Kernel Debugging | Microsoft Learn (37:15 37.25)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

luopandeng

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值