📄 ramdisk.cod
字号:
; 819 : rtlQueryRegTbl[1].DefaultData = &defDiskRegInfo.DiskSize;
; 820 : rtlQueryRegTbl[1].DefaultLength = sizeof(ULONG);
000e4 89 45 e8 mov DWORD PTR _rtlQueryRegTbl$[ebp+52], eax
; 821 :
; 822 : rtlQueryRegTbl[2].Flags = RTL_QUERY_REGISTRY_DIRECT;
; 823 : rtlQueryRegTbl[2].Name = L"RootDirEntries";
; 824 : rtlQueryRegTbl[2].EntryContext = &DiskRegInfo->RootDirEntries;
; 825 : rtlQueryRegTbl[2].DefaultType = REG_DWORD;
000e7 89 45 fc mov DWORD PTR _rtlQueryRegTbl$[ebp+72], eax
; 826 : rtlQueryRegTbl[2].DefaultData = &defDiskRegInfo.RootDirEntries;
; 827 : rtlQueryRegTbl[2].DefaultLength = sizeof(ULONG);
000ea 89 45 04 mov DWORD PTR _rtlQueryRegTbl$[ebp+80], eax
; 828 :
; 829 : rtlQueryRegTbl[3].Flags = RTL_QUERY_REGISTRY_DIRECT;
; 830 : rtlQueryRegTbl[3].Name = L"SectorsPerCluster";
; 831 : rtlQueryRegTbl[3].EntryContext = &DiskRegInfo->SectorsPerCluster;
; 832 : rtlQueryRegTbl[3].DefaultType = REG_DWORD;
000ed 89 45 18 mov DWORD PTR _rtlQueryRegTbl$[ebp+100], eax
; 833 : rtlQueryRegTbl[3].DefaultData = &defDiskRegInfo.SectorsPerCluster;
; 834 : rtlQueryRegTbl[3].DefaultLength = sizeof(ULONG);
000f0 89 45 20 mov DWORD PTR _rtlQueryRegTbl$[ebp+108], eax
; 835 :
; 836 : rtlQueryRegTbl[4].Flags = RTL_QUERY_REGISTRY_DIRECT;
; 837 : rtlQueryRegTbl[4].Name = L"DriveLetter";
; 838 : rtlQueryRegTbl[4].EntryContext = &DiskRegInfo->DriveLetter;
000f3 8d 46 0c lea eax, DWORD PTR [esi+12]
000f6 89 45 7c mov DWORD PTR tv226[ebp], eax
000f9 89 45 30 mov DWORD PTR _rtlQueryRegTbl$[ebp+124], eax
; 839 : rtlQueryRegTbl[4].DefaultType = REG_SZ;
; 840 : rtlQueryRegTbl[4].DefaultData = defDiskRegInfo.DriveLetter.Buffer;
000fc 8b 45 6c mov eax, DWORD PTR _defDiskRegInfo$[ebp+16]
000ff 89 45 38 mov DWORD PTR _rtlQueryRegTbl$[ebp+132], eax
; 841 : rtlQueryRegTbl[4].DefaultLength = 0;
00102 33 c0 xor eax, eax
; 842 :
; 843 :
; 844 : status = RtlQueryRegistryValues(
; 845 : RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL,
; 846 : RegistryPath->Buffer,
; 847 : rtlQueryRegTbl,
; 848 : NULL,
; 849 : NULL
; 850 : );
00104 50 push eax
00105 50 push eax
00106 89 45 3c mov DWORD PTR _rtlQueryRegTbl$[ebp+136], eax
00109 8d 45 b4 lea eax, DWORD PTR _rtlQueryRegTbl$[ebp]
0010c 50 push eax
0010d 8b 45 78 mov eax, DWORD PTR _RegistryPath$[ebp]
00110 ff 70 04 push DWORD PTR [eax+4]
00113 8d 55 5c lea edx, DWORD PTR _defDiskRegInfo$[ebp]
00116 89 55 e4 mov DWORD PTR _rtlQueryRegTbl$[ebp+48], edx
00119 8d 55 60 lea edx, DWORD PTR _defDiskRegInfo$[ebp+4]
0011c 89 55 00 mov DWORD PTR _rtlQueryRegTbl$[ebp+76], edx
0011f 8d 55 64 lea edx, DWORD PTR _defDiskRegInfo$[ebp+8]
00122 8d 7e 04 lea edi, DWORD PTR [esi+4]
00125 8d 5e 08 lea ebx, DWORD PTR [esi+8]
00128 68 00 00 00 80 push -2147483648 ; 80000000H
0012d c7 45 b8 01 00
00 00 mov DWORD PTR _rtlQueryRegTbl$[ebp+4], 1
00134 c7 45 bc 00 00
00 00 mov DWORD PTR _rtlQueryRegTbl$[ebp+8], OFFSET FLAT:$SG14500
0013b 89 4d d4 mov DWORD PTR _rtlQueryRegTbl$[ebp+32], ecx
0013e c7 45 d8 00 00
00 00 mov DWORD PTR _rtlQueryRegTbl$[ebp+36], OFFSET FLAT:$SG14507
00145 89 75 dc mov DWORD PTR _rtlQueryRegTbl$[ebp+40], esi
00148 89 4d f0 mov DWORD PTR _rtlQueryRegTbl$[ebp+60], ecx
0014b c7 45 f4 00 00
00 00 mov DWORD PTR _rtlQueryRegTbl$[ebp+64], OFFSET FLAT:$SG14509
00152 89 7d f8 mov DWORD PTR _rtlQueryRegTbl$[ebp+68], edi
00155 89 4d 0c mov DWORD PTR _rtlQueryRegTbl$[ebp+88], ecx
00158 c7 45 10 00 00
00 00 mov DWORD PTR _rtlQueryRegTbl$[ebp+92], OFFSET FLAT:$SG14511
0015f 89 5d 14 mov DWORD PTR _rtlQueryRegTbl$[ebp+96], ebx
00162 89 55 1c mov DWORD PTR _rtlQueryRegTbl$[ebp+104], edx
00165 89 4d 28 mov DWORD PTR _rtlQueryRegTbl$[ebp+116], ecx
00168 c7 45 2c 00 00
00 00 mov DWORD PTR _rtlQueryRegTbl$[ebp+120], OFFSET FLAT:$SG14513
0016f c7 45 34 01 00
00 00 mov DWORD PTR _rtlQueryRegTbl$[ebp+128], 1
00176 ff 15 00 00 00
00 call DWORD PTR __imp__RtlQueryRegistryValues@20
; 851 :
; 852 : if ( !NT_SUCCESS( status ) ) {
0017c 85 c0 test eax, eax
0017e 7d 1c jge SHORT $L14517
; 853 : DBGPRINT( DBG_COMP_INIT, DBG_LEVEL_WARN, ("RrlQueryRegistryValues returned 0x%x\n", status ) );
; 854 : DiskRegInfo->DiskSize = defDiskRegInfo.DiskSize;
00180 8b 45 5c mov eax, DWORD PTR _defDiskRegInfo$[ebp]
00183 89 06 mov DWORD PTR [esi], eax
; 855 : DiskRegInfo->RootDirEntries = defDiskRegInfo.RootDirEntries;
00185 8b 45 60 mov eax, DWORD PTR _defDiskRegInfo$[ebp+4]
00188 89 07 mov DWORD PTR [edi], eax
; 856 : DiskRegInfo->SectorsPerCluster = defDiskRegInfo.SectorsPerCluster;
0018a 8b 45 64 mov eax, DWORD PTR _defDiskRegInfo$[ebp+8]
0018d 89 03 mov DWORD PTR [ebx], eax
; 857 : RtlCopyUnicodeString( &DiskRegInfo->DriveLetter, &defDiskRegInfo.DriveLetter );
0018f 8d 45 68 lea eax, DWORD PTR _defDiskRegInfo$[ebp+12]
00192 50 push eax
00193 ff 75 7c push DWORD PTR tv226[ebp]
00196 ff 15 00 00 00
00 call DWORD PTR __imp__RtlCopyUnicodeString@8
$L14517:
0019c 5f pop edi
0019d 5e pop esi
0019e 5b pop ebx
; 858 : }
; 859 :
; 860 : DBGPRINT( DBG_COMP_INIT, DBG_LEVEL_INFO, ("DiskSize = 0x%lx\n", DiskRegInfo->DiskSize) );
; 861 : DBGPRINT( DBG_COMP_INIT, DBG_LEVEL_INFO, ("RootDirEntries = 0x%lx\n", DiskRegInfo->RootDirEntries) );
; 862 : DBGPRINT( DBG_COMP_INIT, DBG_LEVEL_INFO, ("SectorsPerCluster = 0x%lx\n", DiskRegInfo->SectorsPerCluster) );
; 863 : DBGPRINT( DBG_COMP_INIT, DBG_LEVEL_INFO, ("DriveLetter = %wZ\n", &(DiskRegInfo->DriveLetter)) );
; 864 : return;
; 865 : } // End of RamDiskQueryRegParameters()
0019f 83 c5 70 add ebp, 112 ; 00000070H
001a2 c9 leave
001a3 c2 08 00 ret 8
_RamDiskQueryDiskRegParameters@8 ENDP
PAGE ENDS
PUBLIC _RamDiskFormatDisk@4
EXTRN __imp__strncpy:NEAR
; COMDAT _RamDiskFormatDisk@4
PAGE SEGMENT
$SG14545 DB 'QSoftRam ', 00H
ORG $+2
$SG14555 DB 'RamDisk ', 00H
$SG14556 DB 'FAT1? ', 00H
ORG $+3
$SG14561 DB 'RAMDisk ', 00H
ORG $+3
$SG14562 DB ' ', 00H
; Function compile flags: /Ogsy
_fatType$ = 8
_sectorsPerCluster$ = 8
_DeviceObject$ = 8
_RamDiskFormatDisk@4 PROC NEAR ; COMDAT
; 891 :
; 892 : PDEVICE_EXTENSION devExt = DeviceObject->DeviceExtension;
00034 8b 44 24 04 mov eax, DWORD PTR _DeviceObject$[esp-4]
00038 53 push ebx
00039 55 push ebp
0003a 8b 68 28 mov ebp, DWORD PTR [eax+40]
; 893 : PBOOT_SECTOR bootSector = (PBOOT_SECTOR) devExt->DiskImage;
; 894 : PUCHAR firstFatSector;
; 895 : ULONG rootDirEntries;
; 896 : ULONG sectorsPerCluster;
; 897 : USHORT fatType; // Type FAT 12 or 16
; 898 : USHORT fatEntries; // Number of cluster entries in FAT
; 899 : USHORT fatSectorCnt; // Number of sectors for FAT
; 900 : PDIR_ENTRY rootDir; // Pointer to first entry in root dir
; 901 : NTSTATUS status = STATUS_SUCCESS;
; 902 :
; 903 : DBGPRINT( DBG_COMP_INIT, DBG_LEVEL_VERBOSE, ("FormatDisk\n" ) );
; 904 :
; 905 : PAGED_CODE();
; 906 : ASSERT( sizeof(BOOT_SECTOR) == 512);
; 907 : ASSERT( devExt->DiskImage != NULL );
; 908 :
; 909 : RtlZeroMemory( devExt->DiskImage, devExt->DiskRegInfo.DiskSize );
0003d 8b 4d 48 mov ecx, DWORD PTR [ebp+72]
00040 8b d1 mov edx, ecx
00042 56 push esi
00043 8b 75 2c mov esi, DWORD PTR [ebp+44]
00046 33 c0 xor eax, eax
00048 c1 e9 02 shr ecx, 2
0004b 57 push edi
0004c 8b fe mov edi, esi
0004e f3 ab rep stosd
00050 8b ca mov ecx, edx
00052 83 e1 03 and ecx, 3
00055 f3 aa rep stosb
; 910 :
; 911 : devExt->DiskGeometry.BytesPerSector = 512;
; 912 : devExt->DiskGeometry.SectorsPerTrack = 32; // Using Ramdisk value
; 913 : devExt->DiskGeometry.TracksPerCylinder = 2; // Using Ramdisk value
; 914 :
; 915 : //
; 916 : // Calculate number of cylinders.
; 917 : //
; 918 :
; 919 : devExt->DiskGeometry.Cylinders.QuadPart = devExt->DiskRegInfo.DiskSize / 512 / 32 / 2;
00057 8b 45 48 mov eax, DWORD PTR [ebp+72]
; 920 :
; 921 : //
; 922 : // Our media type is RAMDISK_MEDIA_TYPE
; 923 : //
; 924 :
; 925 : devExt->DiskGeometry.MediaType = RAMDISK_MEDIA_TYPE;
; 926 :
; 927 : DBGPRINT( DBG_COMP_INIT, DBG_LEVEL_INFO,
; 928 : ("Cylinders: %ld\n TracksPerCylinder: %ld\n SectorsPerTrack: %ld\n BytesPerSector: %ld\n",
; 929 : devExt->DiskGeometry.Cylinders.QuadPart, devExt->DiskGeometry.TracksPerCylinder,
; 930 : devExt->DiskGeometry.SectorsPerTrack, devExt->DiskGeometry.BytesPerSector ) );
; 931 :
; 932 : rootDirEntries = devExt->DiskRegInfo.RootDirEntries;
0005a 8b 5d 4c mov ebx, DWORD PTR [ebp+76]
0005d 83 65 34 00 and DWORD PTR [ebp+52], 0
00061 c1 e8 0f shr eax, 15 ; 0000000fH
; 933 : sectorsPerCluster = devExt->DiskRegInfo.SectorsPerCluster;
; 934 :
; 935 : //
; 936 : // Round Root Directory entries up if necessary
; 937 : //
; 938 : if (rootDirEntries & (DIR_ENTRIES_PER_SECTOR - 1)) {
00064 f6 c3 0f test bl, 15 ; 0000000fH
00067 89 45 30 mov DWORD PTR [ebp+48], eax
0006a 8b 45 50 mov eax, DWORD PTR [ebp+80]
0006d c7 45 44 00 02
00 00 mov DWORD PTR [ebp+68], 512 ; 00000200H
00074 c7 45 40 20 00
00 00 mov DWORD PTR [ebp+64], 32 ; 00000020H
0007b c7 45 3c 02 00
00 00 mov DWORD PTR [ebp+60], 2
00082 c7 45 38 f8 00
00 00 mov DWORD PTR [ebp+56], 248 ; 000000f8H
00089 89 44 24 14 mov DWORD PTR _sectorsPerCluster$[esp+12], eax
0008d 74 06 je SHORT $L14542
; 939 : DBGPRINT( DBG_COMP_INIT, DBG_LEVEL_WARN, ("Adjusting RootDirEntries \n" ) );
; 940 :
; 941 : rootDirEntries =
; 942 : (rootDirEntries + ( DIR_ENTRIES_PER_SECTOR - 1 )) &
; 943 : ~ ( DIR_ENTRIES_PER_SECTOR - 1 );
0008f 83 c3 0f add ebx, 15 ; 0000000fH
00092 83 e3 f0 and ebx, -16 ; fffffff0H
$L14542:
; 944 : }
; 945 :
; 946 : DBGPRINT( DBG_COMP_INIT, DBG_LEVEL_INFO,
; 947 : ("Root dir entries: %ld\n Sectors/cluster: %ld\n",
; 948 : rootDirEntries, sectorsPerCluster ) );
; 949 : //
; 950 : // We need to have the 0xeb and 0x90 since this is one of the
; 951 : // checks the file system recognizer uses
; 952 : //
; 953 : bootSector->bsJump[0] = 0xeb;
; 954 : bootSector->bsJump[1] = 0x3c;
; 955 : bootSector->bsJump[2] = 0x90;
; 956 :
; 957 : strncpy(bootSector->bsOemName, "QSoftRam ", 8);
00095 8b 3d 00 00 00
00 mov edi, DWORD PTR __imp__strncpy
0009b 6a 08 push 8
0009d 8d 46 03 lea eax, DWORD PTR [esi+3]
000a0 68 00 00 00 00 push OFFSET FLAT:$SG14545
000a5 50 push eax
000a6 c6 06 eb mov BYTE PTR [esi], 235 ; 000000ebH
000a9 c6 46 01 3c mov BYTE PTR [esi+1], 60 ; 0000003cH
000ad c6 46 02 90 mov BYTE PTR [esi+2], 144 ; 00000090H
000b1 ff d7 call edi
; 958 : bootSector->bsBytesPerSec = (SHORT)devExt->DiskGeometry.BytesPerSector;
000b3 66 8b 45 44 mov ax, WORD PTR [ebp+68]
000b7 66 89 46 0b mov WORD PTR [esi+11], ax
; 959 : bootSector->bsResSectors = 1;
; 960 : bootSector->bsFATs = 1;
; 961 : bootSector->bsRootDirEnts = (USHORT)rootDirEntries;
; 962 :
; 963 : bootSector->bsSectors = (USHORT)( devExt->DiskRegInfo.DiskSize / devExt->DiskGeometry.BytesPerSector );
000bb 33 d2 xor edx, edx
000bd 66 89 5e 11 mov WORD PTR [esi+17], bx
000c1 66 c7 46 0e 01
00 mov WORD PTR [esi+14], 1
000c7 c6 46 10 01 mov BYTE PTR [esi+16], 1
000cb 8b 45 48 mov eax, DWORD PTR [ebp+72]
000ce f7 75 44 div DWORD PTR [ebp+68]
; 964 : bootSector->bsMedia = (UCHAR) devExt->DiskGeometry.MediaType;
; 965 : bootSector->bsSecPerClus = (UCHAR)sectorsPerCluster;
000d1 8a 4c 24 20 mov cl, BYTE PTR _sectorsPerCluster$[esp+24]
; 966 :
; 967 : //
; 968 : // Calculate number of sectors required for FAT
; 969 : //
; 970 : fatEntries =
; 971 : (bootSector->bsSectors - bootSector->bsResSectors -
; 972 : bootSector->bsRootDirEnts / DIR_ENTRIES_PER_SECTOR) /
; 973 : bootSector->bsSecPerClus + 2;
000d5 0f b7 d3 movzx edx, bx
000d8 c1 ea 04 shr edx, 4
000db 83 c4 0c add esp, 12 ; 0000000cH
; 974 :
; 975 : //
; 976 : // Choose between 12 and 16 bit FAT based on number of clusters we
; 977 : // need to map
; 978 : //
; 979 : if (fatEntries > 4087) {
; 980 : fatType = 16;
; 981 : fatSectorCnt = (fatEntries * 2 + 511) / 512;
000de bb 00 02 00 00 mov ebx, 512 ; 00000200H
000e3 66 89 46 13 mov WORD PTR [esi+19], ax
000e7 8a 45 38 mov al, BYTE PTR [ebp+56]
000ea 88 46 15 mov BYTE PTR [esi+21], al
000ed 0f b7 46 13 movzx eax, WORD PTR [esi+19]
000f1 2b c2 sub eax, edx
000f3 48 dec eax
000f4 88 4e 0d mov BYTE PTR [esi+13], cl
000f7 0f b6 c9 movzx ecx, cl
000fa 99 cdq
000fb f7 f9 idiv ecx
000fd 8b c8 mov ecx, eax
000ff 41 inc ecx
00100 41 inc ecx
00101 66 81 f9 f7 0f cmp cx, 4087 ; 00000ff7H
; 982 : fatEntries -= fatSectorCnt;
; 983 : fatSectorCnt = (fatEntries * 2 + 511) / 512;
00106 0f b7 c1 movzx eax, cx
00109 76 20 jbe SHORT $L14551
0010b 8d 84 00 ff 01
00 00 lea eax, DWORD PTR [eax+eax+511]
00112 99 cdq
00113 f7 fb idiv ebx
00115 c7 44 24 14 10
00 00 00 mov DWORD PTR _fatType$[esp+12], 16 ; 00000010H
0011d 2b c8 sub ecx, eax
0011f 0f b7 c1 movzx eax, cx
00122 8d 84 00 ff 01
00 00 lea eax, DWORD PTR [eax+eax+511]
; 984 : }
; 985 : else {
00129 eb 2c jmp SHORT $L14676
$L14551:
; 986 : fatType = 12;
; 987 : fatSectorCnt = (((fatEntries * 3 + 1) / 2) + 511) / 512;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -