asm restoressdt.docx
- 文档编号:1725337
- 上传时间:2023-05-01
- 格式:DOCX
- 页数:25
- 大小:18.51KB
asm restoressdt.docx
《asm restoressdt.docx》由会员分享,可在线阅读,更多相关《asm restoressdt.docx(25页珍藏版)》请在冰点文库上搜索。
asmrestoressdt
;@echooff
002;gotomake
003
004;:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
005;
006;ssdtrestore-KernelModeDriver
007;
008;Restoreallssdthooks-requiresfour-f'skmdkittobeinstalled
009;
010;WrittenbyXOR@rohitab
011;
012;:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
013
014.386
015.modelflat,stdcall
016optioncasemap:
none
017
018;:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
019;INCLUDEFILES
020;:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
021
022include\masm32\include\w2k\ntstatus.inc
023include\masm32\include\w2k\ntddk.inc
024include\masm32\include\w2k\ntoskrnl.inc
025include\masm32\include\w2k\w2kundoc.inc
026
027includelib\masm32\lib\w2k\ntoskrnl.lib
028
029include\masm32\Macros\Strings.mac
030
031include..\common.inc
032
033includeseh0.inc
034
035;:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
036;STRUCTURES
037;:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
038
039SSDTSTRUCT
040pSSATPVOID?
041dwCounterTableBaseDWORD?
042dwNumOfEntriesDWORD?
043pArgsPVOID?
044SSDTENDS
045
046;:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
047;CONSTANTS
048;:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
049
050.const
051CCOUNTED_UNICODE_STRING"\\Device\\devssdtrestore",g_usDeviceName,4
052CCOUNTED_UNICODE_STRING"\\?
?
\\slssdtrestore",g_usSymbolicLinkName,4
053
054;Maybeyouhavetousethislineinsteadofaboveone
055;ifyourWindowsNTversionis<=4.0
056;Itwillworkalsounder2K&XP
057;CCOUNTED_UNICODE_STRING"\\DosDevices\\slssdtrestore",g_usSymbolicLinkName,4
058
059.code
060
061;:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
062;Getntoskrnlbaseaddress
063;:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
064
065GetNtBaseproc
066
067assumefs:
nothing
068push38h
069popebx
070moveax,fs:
[ebx]
071moveax,[eax+4h]
072andax,0f001h
073deceax
074cmpwordptr[eax],5a4dh
075jnz$-10
076
077ret
078
079GetNtBaseendp
080
081;:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
082;EnumerateRunningSSDTindexentriesandrestoreifhooked
083;:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
084
085SetSSDTIndexValuesprocdwRawSSDTValue:
DWORD,dwNtbase:
DWORD,dwSSDTIndexNum:
DWORD
086
087localdwSSDTAddr:
DWORD
088
089movecx,dwSSDTIndexNum
090
091moveax,KeServiceDescriptorTable
092movebx,[eax]
093movebx,[ebx].SSDT.pSSAT
094leaeax,dwordptr[ebx+ecx*4]
095pusheax
096movdwSSDTAddr,eax
097movebx,eax
098subebx,dwNtbase
099
100.ifebx!
=dwRawSSDTValue
101
102popeax
103
104invokeMmGetPhysicalAddress,eax
105
106invokeMmMapIoSpace,eax,edx,4,0
107
108movedx,dwRawSSDTValue
109anddwNtbase,0ff0fffffh
110addedx,dwNtbase
111mov[eax],edx
112
113invokeMmUnmapIoSpace,eax,4
114
115.endif
116
117ret
118
119SetSSDTIndexValuesendp
120
121;:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
122;GetSSDTbaseaddressoffset
123;:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
124
125DispatchReadprocpDeviceObject:
PDEVICE_OBJECT,pIrp:
PIRP
126
127;SSDTbaseoffsetwasrequested
128
129localstatus:
NTSTATUS
130localdwBytesReturned:
DWORD
131localdwNtBaseAddress:
DWORD
132
133anddwBytesReturned,0
134
135movesi,pIrp
136assumeesi:
ptr_IRP
137
138IoGetCurrentIrpStackLocationesi
139movedi,eax
140assumeedi:
ptrIO_STACK_LOCATION
141
142.if[edi].Parameters.Read._Length>=RDATA_SIZE
143
144moveax,[esi].UserBuffer
145
146_try
147
148moveax,MmUserProbeAddress
149moveax,[eax]
150moveax,[eax]
151
152.if[esi].UserBuffer 153 154moveax,KeServiceDescriptorTable 155moveax,[eax] 156moveax,[eax].SSDT.pSSAT 157 158pushad 159 160invokeGetNtBase 161 162movdwNtBaseAddress,eax 163 164popad 165 166subeax,dwNtBaseAddress 167pusheax 168xoreax,eax 169moveax,[esi].UserBuffer 170pop[eax] 171movdwBytesReturned,RDATA_SIZE 172movstatus,STATUS_SUCCESS 173 174.else 175 176movstatus,STATUS_INVALID_PARAMETER 177 178.endif 179 180_finally 181 182.else 183movstatus,STATUS_BUFFER_TOO_SMALL 184.endif 185 186assumeedi: nothing 187 188pushstatus 189pop[esi].IoStatus.Status 190 191pushdwBytesReturned 192pop[esi].IoStatus.Information 193 194assumeesi: nothing 195 196fastcallIofCompleteRequest,esi,IO_NO_INCREMENT 197 198moveax,status 199ret 200 201DispatchReadendp 202 203;: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 204;DispatchCreateClose 205;: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 206 207DispatchCreateCloseprocpDeviceObject: PDEVICE_OBJECT,pIrp: PIRP 208 209moveax,pIrp 210assumeeax: ptr_IRP 211mov[eax].IoStatus.Status,STATUS_SUCCESS 212and[eax].IoStatus.Information,0 213assumeeax: nothing 214 215fastcallIofCompleteRequest,pIrp,IO_NO_INCREMENT 216 217moveax,STATUS_SUCCESS 218ret 219 220DispatchCreateCloseendp 221 222;: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 223;DispatchControl 224;: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 225 226DispatchControlprocpDeviceObject: PDEVICE_OBJECT,pIrp: PIRP 227 228localstatus: NTSTATUS 229localdwBytesReturned: DWORD 230 231anddwBytesReturned,0 232 233movesi,pIrp 234assumeesi: ptr_IRP 235 236IoGetCurrentIrpStackLocationesi 237movedi,eax 238assumeedi: ptrIO_STACK_LOCATION 239 240.if[edi].Parameters.DeviceIoControl.IoControlCode==IOCTL_SET_SSDT_ENTRIES 241 242movstatus,STATUS_BUFFER_TOO_SMALL 243.if([edi].Parameters.DeviceIoControl.OutputBufferLength>=DATA_SIZE) 244.if([edi].Parameters.DeviceIoControl.InputBufferLength>=DATA_SIZE) 245 246movedi,[esi].AssociatedIrp.SystemBuffer 247assumeedi: ptrDWORD 248 249xorebx,ebx 250movecx,ebx 251 252invokeGetNtBase 253 254.whileebx<154h 255 256pushebx 257pusheax 258 259invokeSetSSDTIndexValues,[edi],eax,[edi+4] 260 261popeax 262addedi,8h 263popebx 264incebx 265 266.endw 267 268movdwBytesReturned,DATA_SIZE 269movstatus,STATUS_SUCCESS 270 271.endif 272.endif 273 274.else 275movstatus,STATUS_INVALID_DEVICE_REQUEST 276.endif 277 278assumeedi: nothing 279 280pushstatus 281pop[esi].IoStatus.Status 282 283pushdwBytesReturned 284pop[esi].IoStatus.Information 285 286assumeesi: nothing 287 288fastcallIofCompleteRequest,pIrp,IO_NO_INCREMENT 289 290moveax,status 291ret 292 293DispatchControlendp 294 295;: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 296;DriverUnload 297;: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 298 299DriverUnloadprocpDriverObject: PDRIVER_OBJECT 300 301invokeIoDeleteSymbolicLink,addrg_usSymbolicLinkName 302 303moveax,pDriverObject 304 305invokeIoDeleteDevice,(DRIVER_OBJECTPTR[eax]).DeviceObject 306 307ret 308 309DriverUnloadendp 310 311.codeINIT 312 313;: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 314;DriverEntry 315;: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 316 317DriverEntryprocpDriverObject: PDRIVER_OBJECT,pusRegistryPath: PUNICODE_STRING 318 319 320localstatus: NTSTATUS 321localpDeviceObject: PDEVICE_OBJECT 322 323movstatus,STATUS_DEVICE_CONFIGURATION_ERROR 324 325invokeIoCreateDevice,pDriverObject,0,addrg_usDeviceName,FILE_DEVICE_UNKNOWN,0,FALSE,addrpDeviceObject 326.ifeax==STATUS_SUCCESS 327invokeIoCreateSymbolicLink,addrg_usSymbolicLinkName,addrg_usDeviceName 328.ifeax==STATUS_SUCCESS 329moveax,pDriverObject 330assumeeax: ptrDRIVER_OBJECT 331mov[eax].DriverUnload,offsetDriverUnload 332mov[eax].MajorFunction[IRP_MJ_CREATE*(s
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- asm restoressdt