📄 ramdisk.cod
字号:
; Listing generated by Microsoft (R) Optimizing Compiler Version 13.00.9178
TITLE .\ramdisk.c
.386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA ENDS
CONST SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST ENDS
_BSS SEGMENT DWORD USE32 PUBLIC 'BSS'
_BSS ENDS
$$SYMBOLS SEGMENT BYTE USE32 'DEBSYM'
$$SYMBOLS ENDS
$$TYPES SEGMENT BYTE USE32 'DEBTYP'
$$TYPES ENDS
_TLS SEGMENT DWORD USE32 PUBLIC 'TLS'
_TLS ENDS
PAGE SEGMENT PARA USE32 PUBLIC ''
PAGE ENDS
INIT SEGMENT PARA USE32 PUBLIC ''
INIT ENDS
; COMDAT _RtlLargeIntegerAdd@16
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
; COMDAT _RtlConvertUlongToLargeInteger@4
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
; COMDAT _DriverEntry@8
INIT SEGMENT PARA USE32 PUBLIC ''
INIT ENDS
; COMDAT _RamDiskCreateClose@8
PAGE SEGMENT PARA USE32 PUBLIC ''
PAGE ENDS
; COMDAT _RamDiskUnload@4
PAGE SEGMENT PARA USE32 PUBLIC ''
PAGE ENDS
; COMDAT _RamDiskIOCtl@8
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
; COMDAT _RamDiskReadWrite@8
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
; COMDAT _RamDiskQueryDiskRegParameters@8
PAGE SEGMENT PARA USE32 PUBLIC ''
PAGE ENDS
; COMDAT _RamDiskFormatDisk@4
PAGE SEGMENT PARA USE32 PUBLIC ''
PAGE ENDS
FLAT GROUP _DATA, CONST, _BSS
ASSUME CS: FLAT, DS: FLAT, SS: FLAT
endif
INCLUDELIB LIBC
INCLUDELIB OLDNAMES
PUBLIC _RtlLargeIntegerAdd@16
; Function compile flags: /Ogsy
; File f:\winddk\2600\inc\ddk\wxp\ntddk.h
; COMDAT _RtlLargeIntegerAdd@16
_TEXT SEGMENT
_Addend1$ = 8
_Addend2$ = 16
_RtlLargeIntegerAdd@16 PROC NEAR ; COMDAT
; 2922 : LARGE_INTEGER Sum;
; 2923 :
; 2924 : Sum.QuadPart = Addend1.QuadPart + Addend2.QuadPart;
00000 8b 44 24 04 mov eax, DWORD PTR _Addend1$[esp-4]
00004 03 44 24 0c add eax, DWORD PTR _Addend2$[esp-4]
00008 8b 54 24 08 mov edx, DWORD PTR _Addend1$[esp]
0000c 13 54 24 10 adc edx, DWORD PTR _Addend2$[esp]
; 2925 : return Sum;
; 2926 : }
00010 c2 10 00 ret 16 ; 00000010H
_RtlLargeIntegerAdd@16 ENDP
_TEXT ENDS
PUBLIC _RtlConvertUlongToLargeInteger@4
; Function compile flags: /Ogsy
; COMDAT _RtlConvertUlongToLargeInteger@4
_TEXT SEGMENT
_UnsignedInteger$ = 8
_RtlConvertUlongToLargeInteger@4 PROC NEAR ; COMDAT
; 3226 : LARGE_INTEGER Result;
; 3227 :
; 3228 : Result.QuadPart = UnsignedInteger;
00000 8b 44 24 04 mov eax, DWORD PTR _UnsignedInteger$[esp-4]
00004 33 d2 xor edx, edx
; 3229 : return Result;
; 3230 : }
00006 c2 04 00 ret 4
_RtlConvertUlongToLargeInteger@4 ENDP
_TEXT ENDS
PUBLIC _RamDiskCreateClose@8
EXTRN __imp_@IofCompleteRequest@8:NEAR
; Function compile flags: /Ogsy
; File f:\winddk\2600\src\storage\ramdisk\sys\ramdisk.c
; COMDAT _RamDiskCreateClose@8
PAGE SEGMENT
_DeviceObject$ = 8
_Irp$ = 12
_RamDiskCreateClose@8 PROC NEAR ; COMDAT
; 201 : PIO_STACK_LOCATION irpStack;
; 202 : NTSTATUS status = STATUS_SUCCESS;
; 203 :
; 204 : PAGED_CODE();
; 205 :
; 206 : DBGPRINT( DBG_COMP_INIT, DBG_LEVEL_VERBOSE, ("CreateClose - IN\n") );
; 207 :
; 208 : irpStack = IoGetCurrentIrpStackLocation( Irp );
00000 8b 4c 24 08 mov ecx, DWORD PTR _Irp$[esp-4]
00004 8b 41 60 mov eax, DWORD PTR [ecx+96]
; 209 :
; 210 : switch ( irpStack->MajorFunction ) {
00007 0f b6 00 movzx eax, BYTE PTR [eax]
0000a 33 d2 xor edx, edx
0000c 56 push esi
0000d 33 f6 xor esi, esi
0000f 2b c2 sub eax, edx
; 215 : break;
; 216 :
; 217 : case IRP_MJ_CLOSE:
; 218 : DBGPRINT( DBG_COMP_INIT, DBG_LEVEL_INFO, ("IRP_MJ_CLOSE (%p)\n", Irp) );
; 219 : COMPLETE_REQUEST( Irp, status, 0 );
; 220 : break;
; 221 :
; 222 : default:
; 223 : status = STATUS_NOT_IMPLEMENTED;
; 224 : COMPLETE_REQUEST( Irp, status, 0 );
00011 89 51 1c mov DWORD PTR [ecx+28], edx
00014 74 10 je SHORT $L14306
00016 48 dec eax
00017 48 dec eax
00018 74 0c je SHORT $L14306
0001a b8 02 00 00 c0 mov eax, -1073741822 ; c0000002H
0001f 8b f0 mov esi, eax
00021 89 41 18 mov DWORD PTR [ecx+24], eax
; 225 : ASSERTMSG("BUG: we should never get here", 0);
; 226 : break;
00024 eb 03 jmp SHORT $L14601
$L14306:
; 211 :
; 212 : case IRP_MJ_CREATE:
; 213 : DBGPRINT( DBG_COMP_INIT, DBG_LEVEL_INFO, ("IRP_MJ_CREATE (%p)\n", Irp) );
; 214 : COMPLETE_REQUEST( Irp, status, 0 );
00026 89 51 18 mov DWORD PTR [ecx+24], edx
$L14601:
00029 32 d2 xor dl, dl
0002b ff 15 00 00 00
00 call DWORD PTR __imp_@IofCompleteRequest@8
; 227 :
; 228 : } // switch
; 229 :
; 230 : DBGPRINT( DBG_COMP_INIT, DBG_LEVEL_VERBOSE, ("CreateClose - OUT\n") );
; 231 : return status;
00031 8b c6 mov eax, esi
00033 5e pop esi
; 232 : } // End of RamDiskCreateClose()
00034 c2 08 00 ret 8
_RamDiskCreateClose@8 ENDP
PAGE ENDS
PUBLIC _RamDiskIOCtl@8
EXTRN __imp__IoAcquireRemoveLockEx@20:NEAR
EXTRN __imp__IoReleaseRemoveLockEx@12:NEAR
; COMDAT _RamDiskIOCtl@8
; File f:\winddk\2600\inc\ddk\wxp\ntddk.h
_TEXT SEGMENT
$SG14337 DB 'f:\winddk\2600\src\storage\ramdisk\sys\ramdisk.c', 00H
ORG $+3
$SG14416 DB 'R', 00H, 'A', 00H, 'M', 00H, 'D', 00H, 'i', 00H, 's', 00H
DB 'k', 00H, 00H, 00H
; Function compile flags: /Ogsy
; File f:\winddk\2600\src\storage\ramdisk\sys\ramdisk.c
tv227 = 8
_DeviceObject$ = 8
_Irp$ = 12
_RamDiskIOCtl@8 PROC NEAR ; COMDAT
; 292 :
; 293 : PIO_STACK_LOCATION irpStack;
; 294 : NTSTATUS status = STATUS_INVALID_DEVICE_REQUEST;
; 295 : ULONG command;
; 296 : ULONG information = 0;
; 297 :
; 298 : PDEVICE_EXTENSION devExt = DeviceObject->DeviceExtension;
00044 8b 44 24 04 mov eax, DWORD PTR _DeviceObject$[esp-4]
00048 53 push ebx
00049 55 push ebp
; 299 :
; 300 : status = IoAcquireRemoveLock(&devExt->RemoveLock, Irp);
0004a 8b 6c 24 10 mov ebp, DWORD PTR _Irp$[esp+4]
0004e 56 push esi
0004f 8b 70 28 mov esi, DWORD PTR [eax+40]
00052 57 push edi
00053 6a 18 push 24 ; 00000018H
00055 68 2c 01 00 00 push 300 ; 0000012cH
0005a 68 00 00 00 00 push OFFSET FLAT:$SG14337
0005f 8d 46 10 lea eax, DWORD PTR [esi+16]
00062 55 push ebp
00063 50 push eax
00064 33 ff xor edi, edi
00066 89 44 24 28 mov DWORD PTR tv227[esp+32], eax
0006a ff 15 00 00 00
00 call DWORD PTR __imp__IoAcquireRemoveLockEx@20
00070 8b d8 mov ebx, eax
; 301 : if (!NT_SUCCESS(status)) {
00072 33 d2 xor edx, edx
00074 3b da cmp ebx, edx
00076 7d 17 jge SHORT $L14339
; 302 : DBGPRINT( DBG_COMP_IOCTL, DBG_LEVEL_ERROR, ("Acquire RemoveLock failed\n" ) );
; 303 : COMPLETE_REQUEST( Irp, status, 0 );
00078 89 55 1c mov DWORD PTR [ebp+28], edx
0007b 32 d2 xor dl, dl
0007d 8b cd mov ecx, ebp
0007f 89 5d 18 mov DWORD PTR [ebp+24], ebx
00082 ff 15 00 00 00
00 call DWORD PTR __imp_@IofCompleteRequest@8
; 304 : return status;
00088 8b c3 mov eax, ebx
0008a e9 49 01 00 00 jmp $L14329
$L14339:
; 305 : }
; 306 :
; 307 : irpStack = IoGetCurrentIrpStackLocation(Irp);
0008f 8b 45 60 mov eax, DWORD PTR [ebp+96]
; 308 : command = irpStack->Parameters.DeviceIoControl.IoControlCode;
00092 8b 48 0c mov ecx, DWORD PTR [eax+12]
; 309 :
; 310 : DBGPRINT( DBG_COMP_IOCTL, DBG_LEVEL_VERBOSE, ("IOCtl- IN : command = 0x%08lX\n" , command ) );
; 311 :
; 312 : switch ( command )
; 313 : {
00095 bb 08 c0 07 00 mov ebx, 507912 ; 0007c008H
0009a 3b cb cmp ecx, ebx
0009c 0f 87 d7 00 00
00 ja $L14605
000a2 0f 84 e1 00 00
00 je $L14428
000a8 81 e9 00 00 07
00 sub ecx, 458752 ; 00070000H
000ae 0f 84 ac 00 00
00 je $L14379
000b4 83 e9 24 sub ecx, 36 ; 00000024H
000b7 0f 84 fa 00 00
00 je $L14425
000bd 81 e9 dc 0b 00
00 sub ecx, 3036 ; 00000bdcH
000c3 74 6e je SHORT $L14364
000c5 81 e9 04 34 00
00 sub ecx, 13316 ; 00003404H
000cb 74 11 je SHORT $L14348
000cd 81 e9 fc 07 00
00 sub ecx, 2044 ; 000007fcH
000d3 0f 85 b0 00 00
00 jne $L14428
; 402 : }
; 403 :
; 404 : case IOCTL_DISK_CHECK_VERIFY: {
; 405 :
; 406 : DBGPRINT( DBG_COMP_IOCTL, DBG_LEVEL_INFO, ("IOCTL_DISK_CHECK_VERIFY \n" ) );
; 407 : //
; 408 : // Return status success
; 409 : //
; 410 : status = STATUS_SUCCESS;
; 411 : break;
000d9 e9 d9 00 00 00 jmp $L14425
$L14348:
; 314 :
; 315 : case IOCTL_DISK_GET_PARTITION_INFO: {
; 316 :
; 317 : DBGPRINT( DBG_COMP_IOCTL, DBG_LEVEL_INFO, ("IOCTL_DISK_GET_PARTITION_INFO \n" ) );
; 318 : if (irpStack->Parameters.DeviceIoControl.OutputBufferLength <
; 319 : sizeof(PARTITION_INFORMATION)) {
000de 6a 20 push 32 ; 00000020H
000e0 5f pop edi
000e1 39 78 04 cmp DWORD PTR [eax+4], edi
000e4 73 0a jae SHORT $L14351
; 320 : DBGPRINT( DBG_COMP_IOCTL, DBG_LEVEL_INFO, ("Output buffer too small... \n" ) );
; 321 : status = STATUS_BUFFER_TOO_SMALL; // Inform the caller we need bigger buffer
000e6 be 23 00 00 c0 mov esi, -1073741789 ; c0000023H
; 322 : information = sizeof(PARTITION_INFORMATION);
; 323 : } else {
000eb e9 c9 00 00 00 jmp $L14345
$L14351:
; 324 : PPARTITION_INFORMATION outputBuffer;
; 325 : PBOOT_SECTOR bootSector = (PBOOT_SECTOR) devExt->DiskImage;
; 326 :
; 327 : outputBuffer = ( PPARTITION_INFORMATION )Irp->AssociatedIrp.SystemBuffer;
; 328 :
; 329 : outputBuffer->PartitionType =
; 330 : (bootSector->bsFileSystemType[4] == '6') ? PARTITION_FAT_16 : PARTITION_FAT_12;
000f0 8b 4e 2c mov ecx, DWORD PTR [esi+44]
000f3 80 79 3a 36 cmp BYTE PTR [ecx+58], 54 ; 00000036H
000f7 8b 45 0c mov eax, DWORD PTR [ebp+12]
000fa 0f 95 c1 setne cl
; 331 :
; 332 : outputBuffer->BootIndicator = FALSE;
000fd 80 60 19 00 and BYTE PTR [eax+25], 0
; 333 : outputBuffer->RecognizedPartition = TRUE;
; 334 : outputBuffer->RewritePartition = FALSE;
00101 80 60 1b 00 and BYTE PTR [eax+27], 0
00105 fe c9 dec cl
00107 80 e1 03 and cl, 3
0010a fe c1 inc cl
0010c 88 48 18 mov BYTE PTR [eax+24], cl
0010f c6 40 1a 01 mov BYTE PTR [eax+26], 1
; 335 : outputBuffer->StartingOffset = RtlConvertUlongToLargeInteger(0);
00113 89 10 mov DWORD PTR [eax], edx
00115 89 50 04 mov DWORD PTR [eax+4], edx
; 336 : outputBuffer->PartitionLength = RtlConvertUlongToLargeInteger(devExt->DiskRegInfo.DiskSize);
00118 8b 76 48 mov esi, DWORD PTR [esi+72]
0011b 33 c9 xor ecx, ecx
; 337 : outputBuffer->HiddenSectors = (ULONG) (1L);
; 338 : outputBuffer->PartitionNumber = (ULONG) (-1L);
0011d 83 48 14 ff or DWORD PTR [eax+20], -1
00121 89 70 08 mov DWORD PTR [eax+8], esi
00124 89 48 0c mov DWORD PTR [eax+12], ecx
00127 c7 40 10 01 00
00 00 mov DWORD PTR [eax+16], 1
; 339 :
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -