From 9de0c2d847a13c22ea37a9f03b33d3a209b7c29f Mon Sep 17 00:00:00 2001 From: Zero3K Date: Sun, 14 Oct 2018 11:19:24 -0400 Subject: [PATCH] Replacing with Katayama Hirofumi MZ's (ReactOS Developer) translated source code --- src/eramnt.c | 2526 ++++++++++++++++++++++++------------------------- src/eramnt.h | 234 ++--- src/eramnt.rc | 14 +- 3 files changed, 1387 insertions(+), 1387 deletions(-) diff --git a/src/eramnt.c b/src/eramnt.c index c29696d..b7f49cc 100644 --- a/src/eramnt.c +++ b/src/eramnt.c @@ -1,121 +1,122 @@ -/* ERAMNT.C  RAMディスクERAM for WindowsNT/2000/XP -   Copyright (c) 1999-2004 by *Error15 +/* ERAMNT.C RAM disk ERAM for WindowsNT/2000/XP + Copyright (c) 1999-2004 by *Error15 + Translated into English by Katayama Hirofumi MZ. */ -/* 更新履歴 +/* Update History: v1.00 - 新規作成 + Initial creation. v1.01 - over32MB対応(64MBまで) - Win2000β3対応 + over 32MB support (upto 64MB). + Win2000 beta 3 support. v1.10 - Win2000動作確認 + Win2000 operation check. v1.11 - メモリ確保失敗時、RAM量の目安を出すようにした - FAT12とFAT16の境界あたりのクラスタ数計算にミスがあったのを修正 + When failure of memory allocation, make the RAM amount indication dumped + Fixed calculation of the number of clusters around boundary of FAT12 and FAT16. v2.00 - MAXMEM=nn以降のメモリを64KB単位で切り替えして扱う + Handle the memory after MAXMEM=nn with switching in 64KB units. v2.01 - アロケーションユニット32を増やして1GB確保可能… + Enabled 1GB allocation by increasing allocation unit 32. v2.02 - MAXMEM=nn以降のメモリの開始アドレスを指定可能にした - ドライブタイプをローカルディスク扱いにしてスワップ可能にもできる - イベントログメッセージ追加 + You can specify the start address of memory starting from MAXMEM=nn. + It can also be swappable by treating the Drive type as a local disk. + Event log message added. v2.10 - FAT32対応 - FAT16 over32MBでパーテーションを正しく返すように変更 - FAT16でもアロケーションユニット64を増やして2GB確保可能… - ボリュームシリアル番号に現在日付を設定するよう変更 + FAT32 support. + Made it return the partition at "FAT16 over 32MB". + Able to allocate 2GB even in FAT16 by increasing Allocation Unit64... + Made it set the current date to the volume serial number. v2.11 - WinXP対応 + WinXP support. v2.12 - スタンバイ対応 - IoReportResourceUsage呼ぶとスタンバイできなくなる(後で開放しても) - IoReportResourceForDetectionでは、over16MBな内部メモリ要求が通らない - IoReportResourceUsage呼ばなくてもHalTranslateBusAddressできる - HalTranslateBusAddressしなくても内部メモリは同一アドレスを示す - スタンバイ(電源ONのまま)…RAMはOS管理外でもok - 休止状態(電源OFF)…RAMはOS管理外では不可(OS管理ならok) + Stand-by support. + Calling IoReportResourceUsage makes it impossible to standby (even if you later release it). + IoReportResourceForDetection does not pass over 16MB of internal memory request. + You can HalTranslateBusAddress without calling IoReportResourceUsage. + Even without HalTranslateBusAddress, the internal memory shows the same address. + Standby (power remains on): RAM is ok even outside OS management. + Hibernate (power off): RAM is not allowed under OS management (ok for OS management). v2.20 - 外部メモリ量の計算が符号付きになってたのを修正(実害無し) - 外部メモリの検出のあたりで4GBラップしないよう計算追加 - オプション文字比較部が正しくUNICODE対応してなかったのを修正 - FAT16最大クラスタを65535→65525に修正 - FAT32最大クラスタを未検査→268435455(=0xFFFFFFF)に修正 (Win2000=4177918) - 最大容量を最大クラスタxアロケーションユニット分に制限(厳密には余裕あるが無視) - 最大容量を4GBに制限 - NT系ではFAT16最大容量は4GBだが、chkdsk等の表示が変 - クラスタ制限で切り上げしてたのをやめ、切り捨てに変更 - FAT32クラスタが65527〜だったのを65526〜に変更 - メモリの少ない機種でもテスト可能なように改造 - 外部メモリ使用設定時、無理矢理確保できるようにした - (古いハードではアドレスバスが32bitフルデコードされていないことがある) - メモリマップトファイルを使ってテスト可能なように改造(ファイルシステムドライバのロード前提) - ファイルI/OではZwXXXでは競合にうまく対応できないようなのでマップトファイル使用 - 出力ファイル変更対応 - 起動時の領域クリアで管理領域のみを対象にするよう変更 - オプション32bit化 - Windows2000以降で自動でFAT32を有効化するよう変更 - ベリファイ処理を無効化(大きさチェックのみ実装) - セクタ/トラック情報が誤っていたのを修正 - Windows Server 2003対応 - IOCTL_DISK_GET_LENGTH_INFO処理追加 - XP以降ではディスク容量を計算してくれなくてこの対応必須の模様 - IOCTL_DISK_SET_PARTITION_INFO処理追加 - NTFSへのconvertとかformatができるようなので一応 - FAT12最大クラスタを4087→4086に修正 - ボリュームラベル変更対応 - *?/|.,;:+=[]()&^<>" とコントロールコードは指定不可 - イベントログ出力で、UNICODE→ANSI[→UNICODE]変換してたのをANSI→UNICODEに改善 - スワップ関係無く実デバイス設定可能にした - 複数メモリ選択時の補正機能追加 - FAT12/16:ルートディレクトリセクタが全セクタを上回るとき誤動作してたのを修正 - TEMPディレクトリ作成機能追加 - 今回(は)も落ちた機能 - NTFSフォーマット - いろいろ面倒なのでformatかconvertで逃げてもらう - 起動時にformatする場合、以下の設定で回避できるかもしれない - Runあたりに + Fixed that calculation of external memory amount was signed (no actual damage). + Add the calculation not to wrap 4GB around detection of external memory. + Fixed that option character comparator didn't correctly support Unicode. + Fixed the FAT16 max cluster from 65535 to 65525. + Corrected the FAT32 maximum clusters to 268435455 (= 0xFFFFFFF) (Win2000=4177918). + Maximum capacity limited to maximum cluster x Allocation Unit (Strictly afford but ignored). + Maximum capacity limited to 4GB. + On NT systems, the maximum capacity of FAT16 is 4GB, but the display of chkdsk etc. was strange. + Stop rounding up by cluster restriction and change to rounding down. + Changed FAT32 clusters from 65527 to 65526. + Modified to be testable even with models with less memory. + Made it possible to forcibly allocate it when forced to use external memory. + (On older hardware, the address bus might not be fully 32bit-decoded). + Modified to be testable using memory-mapped file (Filesystem driver load premise). + In file I/O, ZwXXX seems to be unable to cope with conflicts well, so I used mapped file. + Output file change support. + Changed to target only the management area by clearing the area at startup. + Option 32bit-nized. + Made it automatically enable FAT32 at Windows2000+. + Disabled "Verify processing" (Implemented the size check only) + Fixed wrong sector/drive info. + Windows Server 2003 support. + IOCTL_DISK_GET_LENGTH_INFO processing added. + XP and later don't calculate the disk capacity, so this correspondence was likely needed. + IOCTL_DISK_SET_PARTITION_INFO processing added. + It seems that conversion or formatting to NTFS seems to work. + Fix the FAT12 max clusters from 4087 to 4086. + Volume label change support. + Unable to specify *?/|.,;:+=[]()&^<>" and control codes. + Simplified the conversion from UNICODE-to-ANSI-to-UNICODE to ANSI-to-UNICODE. + Made it possible to set the real device without swap relation. + Addition of correction function when selecting multiple memories. + FAT12/16: Corrected malfunctioning when the root directory sector exceeded all sectors. + TEMP directory creation feature added. + This time (again?) lacking the following features: + NTFS format. + Because it is troublesome, please escape with formatting or conversion. + When formatting at startup, it may be possible to avoid it with the following settings: + Around "Run": cmd.exe /c convert drv: /fs:ntfs < %systemroot%\system32\eramconv.txt - system32\eramconv.txtあたりに + Around system32\eramconv.txt: volume-label y n - フォルダが開かれててconvertできないことがある - HDD(=スワップ使用可能)にすればformatも使用可能 - ボリュームマネージャ連携 - PnPドライバでないと困難っぽいので放置 - マウントポイント(NTFS5)は使えない - ハードリンクが使えない symlink rktools linkd - XP:ページファイルを置けない - マウントマネージャに認識されてない状態では対処不能の模様 - Startを0に、Primary diskにしても駄目 - XP以降ページファイル無しにできるので、それで回避願う - /BURNMEMORY=n対応 + Sometimes folders are opened and conversion can not be done. + If you set HDD (=swappable) formatting can also be used. + Corporation with volume manager. + I left it as it if not a PnP driver because it seems difficult. + Mount point (NTFS 5) can not be used. + Unable to use hardlink (symlink rktools linkd) + XP: Unable to put the page file. + It seemed impossible to deal with it unrecognized by the mount manager. + "Start" can not be set to 0, even if it is set to Primary Disk. + In XP and later, you can do without page file, so wish to avoid it. + /BURNMEMORY=n support. http://msdn.microsoft.com/library/en-us/ddtools/hh/ddtools/bootini_9omr.asp - ドライバロード時にメモリ実装量を取得する普遍的な手段が不明 - HKLM\HARDWARE\RESOURCEMAP\System Resources\Physical Memory\はまだできてない - v2.21暫定版 - ACPI:ACPI Reclaim/NVSメモリ除外 - NTデバイス名をレジストリから取得できるようにした(無理矢理複数ERAMを使う場合向け) - HKLM\System\CurrentControlSet\Services\ERAM のあたりを ERAM2 とかにして - 値 DevName (REG_SZ)に \Device\ERAM2 とか入れてリブート - Win2000以降ではデバイスマネージャに表示されないがNT用のINFで入れる - v2.22暫定版 - ACPI:ACPI Reclaim/NVSメモリ除外でエラー処理追加 - over4GB:/MAXMEM=nと/NOLOWMEM混在時はMAXMEMがover4GBに効くことの対策(天夢 森流彩さん指摘感謝) - プールの物理アドレスがover4GBのとき、/PAE指定とみなす - /PAE指定とみなしたとき、/NOLOWMEM指定も探す - /NOLOWMEM指定時は/MAXMEM=16と同等と見なす - v2.23暫定版 - over4GB:/MAXMEM=nと/NOLOWMEM混在時はMAXMEMがover4GBに効くことの対策(天夢 森流彩さん指摘感謝) - /PAE:v2.22で16にしたが、16はチェックではじいてたので17に修正 - 未:over4GB:/PAE無くても/NOLOWMEMが効くことの対策(天夢 森流彩さん指摘) - /PAE指定無くても/NOLOWMEM指定を探せる? - PagedPoolに使われているので限界値が検出できないようだが… - 未:over4GB:LME状態でのRAMを確保? - 未:SMBIOS:メモリ最大量取得 - 未:SUMチェック + The means of acquiring memory mounting amount at driver loading is unknown. + HKLM\HARDWARE\RESOURCEMAP\System Resources\Physical Memory\ is not done at all. + v2.21 (preliminary version) + ACPI:ACPI Reclaim/NVS memory exclusion. + Enabled to get the NT device name from the registry (for forcibly for the case of using multiple ERAMs). + You can make HKLM\System\CurrentControlSet\Services\ERAM ERAM2 or similar, and + reboot with setting value "DevName" (REG_SZ) to \Device\ERAM2. + In Win2000 or later, it is not displayed in the device manager but it can be put in INF for NT. + v2.22 (preliminary version) + ACPI: Added error processing at ACPI Reclaim/NVS memory exclusion. + over4GB: The measures against MAXMEM working over 4GB when /MAXMEM=n and /NOLOWMEM coexisted (Thanks for TENMU SHINRYUUSAI) + When the physical address of the pool is over 4GB, it is regarded as /PAE designation. + When /PAE designation is taken, the /NOLOWMEM specification is also searched. + When /NOLOWMEM is specified, it is regarded as equivalent to /MAXMEM=16. + v2.23 (preliminary version) + over4GB: The measures against MAXMEM working over 4GB When /MAXMEM=n and /NOLOWMEM coexist (Thanks for TENMU SHINRYUUSAI). + /PAE:v2.22 made it 16, but 16 was repaired by check so it was fixed to 17. + YET:over4GB: The measures against the effect of /NOLOWMEM even without /PAE (Pointed out by TENMU SHINRYUUSAI). + We can search the /NOLOWMEM designation without /PAE designation? + It seems that it can not detect the limit value because it is used for PagedPool... + YET:over4GB: allocate RAM in LME status (?) + YET:SMBIOS:get maximum amount of memory + YET:SUM check */ @@ -131,13 +132,13 @@ -/* EramCreateClose - オープン/クローズ要求エントリ - 引数 - pDevObj 装置オブジェクトへのポインタ - pIrp IRPパケットへのポインタ - 戻り値 - 結果 +/* EramCreateClose + Open/Close Request Entry + Parameters + pDevObj The pointer to device object. + pIrp The pointer to IRP packet. + Return Value + Results. */ NTSTATUS EramCreateClose( @@ -146,7 +147,7 @@ NTSTATUS EramCreateClose( ) { KdPrint(("EramCreateClose start\n")); - /* 成功をセット */ + /* Set success */ pIrp->IoStatus.Status = STATUS_SUCCESS; pIrp->IoStatus.Information = 0; IoCompleteRequest(pIrp, IO_NO_INCREMENT); @@ -155,13 +156,13 @@ NTSTATUS EramCreateClose( } -/* EramDeviceControl - デバイスコントロール要求エントリ - 引数 - pDevObj 装置オブジェクトへのポインタ - pIrp IRPパケットへのポインタ - 戻り値 - 結果 +/* EramDeviceControl + Device Control Request Entry + Parameters + pDevObj The pointer to device object. + pIrp The pointer to IRP packet. + Return Value + Results. */ NTSTATUS EramDeviceControl( @@ -169,51 +170,51 @@ NTSTATUS EramDeviceControl( IN PIRP pIrp ) { - /* ローカル変数 */ + /* local variables */ PERAM_EXTENSION pEramExt; PIO_STACK_LOCATION pIrpSp; NTSTATUS ntStat; //KdPrint(("EramDeviceControl start\n")); - /* 構造体先頭ポインタ取得 */ + /* Get the head pointer of the structure */ pEramExt = pDevObj->DeviceExtension; - /* スタックへのポインタ取得 */ + /* Get the pointer to the stack */ pIrpSp = IoGetCurrentIrpStackLocation(pIrp); - /* 失敗をセット */ + /* Set failure */ pIrp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST; pIrp->IoStatus.Information = 0; - switch (pIrpSp->Parameters.DeviceIoControl.IoControlCode) /* 要求タイプにより分岐 */ + switch (pIrpSp->Parameters.DeviceIoControl.IoControlCode) /* Branching by request types */ { - case IOCTL_DISK_GET_MEDIA_TYPES: /* メディアタイプ取得(配列) */ - case IOCTL_DISK_GET_DRIVE_GEOMETRY: /* メディアタイプ取得(1) */ - /* ジオメトリ取得処理 */ + case IOCTL_DISK_GET_MEDIA_TYPES: /* media type getting (array) */ + case IOCTL_DISK_GET_DRIVE_GEOMETRY: /* media type getting (1) */ + /* geometry getting */ EramDeviceControlGeometry(pEramExt, pIrp, pIrpSp->Parameters.DeviceIoControl.OutputBufferLength); break; - case IOCTL_DISK_GET_PARTITION_INFO: /* パーテーション情報取得 */ - /* パーテーション情報取得処理 */ + case IOCTL_DISK_GET_PARTITION_INFO: /* Get the partition info */ + /* Partition info getting processing */ EramDeviceControlGetPartInfo(pEramExt, pIrp, pIrpSp->Parameters.DeviceIoControl.OutputBufferLength); break; - case IOCTL_DISK_SET_PARTITION_INFO: /* パーテーション情報取得 */ - /* パーテーション情報設定処理 */ + case IOCTL_DISK_SET_PARTITION_INFO: /* Get the partition info */ + /* Partition Info Settings processing */ EramDeviceControlSetPartInfo(pEramExt, pIrp, pIrpSp->Parameters.DeviceIoControl.InputBufferLength); break; - case IOCTL_DISK_VERIFY: /* ベリファイ */ - /* ベリファイ処理 */ + case IOCTL_DISK_VERIFY: /* Verify */ + /* Verify processing */ EramDeviceControlVerify(pEramExt, pIrp, pIrpSp->Parameters.DeviceIoControl.InputBufferLength); break; - case IOCTL_DISK_CHECK_VERIFY: /* ディスク検査(Win2000β3以降) */ - /* ベリファイ処理 */ + case IOCTL_DISK_CHECK_VERIFY: /* Disk check (Win2000 beta3+) */ + /* Verify processing */ EramDeviceControlDiskCheckVerify(pEramExt, pIrp, pIrpSp->Parameters.DeviceIoControl.OutputBufferLength); break; - case IOCTL_DISK_GET_LENGTH_INFO: /* ディスクサイズ取得(Win2000〜 [WinXP以降format/convert時必須]) */ - /* ディスクサイズ取得処理 */ + case IOCTL_DISK_GET_LENGTH_INFO: /* Disk size getting (Win2000+ [necessary when formatting/conversion at WinXP and later]) */ + /* Disk size getting processing */ EramDeviceControlGetLengthInfo(pEramExt, pIrp, pIrpSp->Parameters.DeviceIoControl.OutputBufferLength); break; - default: /* その他 */ - /* 無視 */ + default: /* misc. */ + /* Ignore */ KdPrint(("IOCTL 0x%x\n", (UINT)(pIrpSp->Parameters.DeviceIoControl.IoControlCode))); break; } - /* ステータスをセット */ + /* Set status */ ntStat = pIrp->IoStatus.Status; IoCompleteRequest(pIrp, IO_NO_INCREMENT); //KdPrint(("EramDeviceControl end\n")); @@ -221,14 +222,14 @@ NTSTATUS EramDeviceControl( } -/* EramDeviceControlGeometry - ジオメトリ取得処理 - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pIrp IRPパケットへのポインタ - uLen バッファサイズ - 戻り値 - なし +/* EramDeviceControlGeometry + Geometry Getting Process + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pIrp The pointer to IRP packet. + uLen The buffer size. + Return Value + No return value. */ VOID EramDeviceControlGeometry( @@ -237,34 +238,34 @@ VOID EramDeviceControlGeometry( IN ULONG uLen ) { - /* ローカル変数 */ + /* local variables */ PDISK_GEOMETRY pGeom; - if (uLen < sizeof(*pGeom)) /* サイズ不足 */ + if (uLen < sizeof(*pGeom)) /* size lacking */ { pIrp->IoStatus.Status = STATUS_INVALID_PARAMETER; KdPrint(("EramDeviceControlGeometry:size too small\n")); return; } - /* ディスクジオメトリ設定 */ + /* Disk Geometry setting */ pGeom = (PDISK_GEOMETRY)(pIrp->AssociatedIrp.SystemBuffer); - pGeom->MediaType = FixedMedia; /* メディアタイプ:固定ディスク */ + pGeom->MediaType = FixedMedia; /* Media type: Fixed disk */ pGeom->Cylinders.QuadPart = (ULONGLONG)(pEramExt->uAllSector); pGeom->TracksPerCylinder = 1; - pGeom->SectorsPerTrack = 1; /* 1バンクあたりのセクタ数 */ + pGeom->SectorsPerTrack = 1; /* sectors per bank */ pGeom->BytesPerSector = SECTOR; pIrp->IoStatus.Status = STATUS_SUCCESS; pIrp->IoStatus.Information = sizeof(*pGeom); } -/* EramDeviceControlGetPartInfo - パーテーション情報取得処理 - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pIrp IRPパケットへのポインタ - uLen バッファサイズ - 戻り値 - なし +/* EramDeviceControlGetPartInfo + Partition info getting processing. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pIrp The pointer to IRP packet. + uLen The buffer size. + Return Value + No return value. */ VOID EramDeviceControlGetPartInfo( @@ -273,37 +274,37 @@ VOID EramDeviceControlGetPartInfo( IN ULONG uLen ) { - /* ローカル変数 */ + /* local variables */ PPARTITION_INFORMATION pPart; - if (uLen < sizeof(*pPart)) /* サイズ不足 */ + if (uLen < sizeof(*pPart)) /* lacking size */ { pIrp->IoStatus.Status = STATUS_INVALID_PARAMETER; KdPrint(("EramDeviceControlGetPartInfo:size too small\n")); return; } - /* パーテーション情報設定 */ + /* Partition Info Settings */ pPart = (PPARTITION_INFORMATION)(pIrp->AssociatedIrp.SystemBuffer); pPart->PartitionType = pEramExt->FAT_size; - pPart->BootIndicator = FALSE; /* ブート不可 */ - pPart->RecognizedPartition = TRUE; /* パーテーション認識 */ - pPart->RewritePartition = FALSE; /* 再書き込み不可パーテーション */ - pPart->StartingOffset.QuadPart = (ULONGLONG)(0); /* パーテーション開始位置 */ - pPart->PartitionLength.QuadPart = UInt32x32To64(pEramExt->uAllSector, SECTOR); /* 長さ */ - pPart->HiddenSectors = pEramExt->bsHiddenSecs; /* 隠しセクタ数 */ - pPart->PartitionNumber = 1; /* パーテーション数 */ + pPart->BootIndicator = FALSE; /* Refuse boot */ + pPart->RecognizedPartition = TRUE; /* Partition detected */ + pPart->RewritePartition = FALSE; /* unrewritable partition */ + pPart->StartingOffset.QuadPart = (ULONGLONG)(0); /* Partition starting position */ + pPart->PartitionLength.QuadPart = UInt32x32To64(pEramExt->uAllSector, SECTOR); /* the length */ + pPart->HiddenSectors = pEramExt->bsHiddenSecs; /* the number of hidden sectors */ + pPart->PartitionNumber = 1; /* The number of partitions */ pIrp->IoStatus.Status = STATUS_SUCCESS; pIrp->IoStatus.Information = sizeof(PARTITION_INFORMATION); } -/* EramDeviceControlSetPartInfo - パーテーション情報設定処理 - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pIrp IRPパケットへのポインタ - uLen バッファサイズ - 戻り値 - なし +/* EramDeviceControlSetPartInfo + Partition info setting processing. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pIrp The poitner to IRP packet. + uLen The buffer size. + Return Value + No return value. */ VOID EramDeviceControlSetPartInfo( @@ -312,29 +313,29 @@ VOID EramDeviceControlSetPartInfo( IN ULONG uLen ) { - /* ローカル変数 */ + /* local variables */ PSET_PARTITION_INFORMATION pPart; - if (uLen < sizeof(*pPart)) /* サイズ不足 */ + if (uLen < sizeof(*pPart)) /* lacking size */ { pIrp->IoStatus.Status = STATUS_INVALID_PARAMETER; KdPrint(("EramDeviceControlSetPartInfo:size too small\n")); return; } - /* パーテーション情報設定 */ + /* Partition Info Settings */ pPart = (PSET_PARTITION_INFORMATION)(pIrp->AssociatedIrp.SystemBuffer); pEramExt->FAT_size = pPart->PartitionType; pIrp->IoStatus.Status = STATUS_SUCCESS; } -/* EramDeviceControlVerify - ベリファイ処理 - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pIrp IRPパケットへのポインタ - uLen バッファサイズ - 戻り値 - なし +/* EramDeviceControlVerify + Verify processing. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pIrp The pointer to IRP packet. + uLen The buffer size. + Return Value + No return value. */ VOID EramDeviceControlVerify( @@ -343,29 +344,29 @@ VOID EramDeviceControlVerify( IN ULONG uLen ) { - /* ローカル変数 */ + /* local variables */ PVERIFY_INFORMATION pVerify; //KdPrint(("EramDeviceControlVerify start\n")); - if (uLen < sizeof(*pVerify)) /* サイズ不足 */ + if (uLen < sizeof(*pVerify)) /* lacking size */ { pIrp->IoStatus.Status = STATUS_INVALID_PARAMETER; KdPrint(("EramDeviceControlVerify:size too small\n")); return; } - /* ベリファイ情報設定 */ + /* Verify Info Settings */ pVerify = pIrp->AssociatedIrp.SystemBuffer; //KdPrint(("offset 0x%x%08x, len 0x%x\n", pVerify->StartingOffset.HighPart, pVerify->StartingOffset.LowPart, pVerify->Length)); if ((((ULONGLONG)(pVerify->StartingOffset.QuadPart) + (ULONGLONG)(pVerify->Length)) > UInt32x32To64(pEramExt->uAllSector, SECTOR))|| ((pVerify->StartingOffset.LowPart & (SECTOR-1)) != 0)|| - ((pVerify->Length & (SECTOR-1)) != 0)) /* ディスク容量を超えたor開始位置/長さがセクタサイズの倍数でない */ + ((pVerify->Length & (SECTOR-1)) != 0)) /* Disk capacity exceeded or the starting position or the length is not a multiple of the sector size */ { - /* エラーを返す */ + /* Return error */ KdPrint(("Invalid I/O parameter\n")); pIrp->IoStatus.Status = STATUS_INVALID_PARAMETER; return; } - if ((pEramExt->uOptflag.Bits.External != 0)&& /* OS管理外メモリ使用 */ - (pEramExt->uExternalStart != 0)&& /* OS管理外メモリ設定 */ + if ((pEramExt->uOptflag.Bits.External != 0)&& /* OS outside memory usage */ + (pEramExt->uExternalStart != 0)&& /* OS outside memory setting */ ((pEramExt->uExternalStart + (ULONGLONG)(pVerify->StartingOffset.QuadPart) + (ULONGLONG)(pVerify->Length)) >= pEramExt->uExternalEnd)) { @@ -378,14 +379,14 @@ pEramExt->uExternalEnd)) } -/* EramDeviceControlDiskCheckVerify - ディスク交換確認処理 - 引数 - pEdskExt EDSK_EXTENTION構造体へのポインタ - pIrp IRPパケットへのポインタ - uLen バッファサイズ - 戻り値 - なし +/* EramDeviceControlDiskCheckVerify + Disk Replacement Confirming Process. + Parameters + pEdskExt The pointer to an EDSK_EXTENTION structure. + pIrp The pointer to IRP packet. + uLen The buffer size. + Return Value + No return value. */ VOID EramDeviceControlDiskCheckVerify( @@ -394,34 +395,34 @@ VOID EramDeviceControlDiskCheckVerify( IN ULONG uLen ) { - /* ローカル変数 */ + /* local variables */ PULONG puOpt; pIrp->IoStatus.Status = STATUS_SUCCESS; - if (uLen == 0) /* 補足情報不要 */ + if (uLen == 0) /* aux info not needed */ { return; } - if (uLen < sizeof(*puOpt)) /* サイズ不足 */ + if (uLen < sizeof(*puOpt)) /* lacking size */ { pIrp->IoStatus.Status = STATUS_INVALID_PARAMETER; KdPrint(("EramDeviceControlDiskCheckVerify:size too small\n")); return; } - /* 補足情報設定 */ + /* Aux info settings */ puOpt = (PULONG)(pIrp->AssociatedIrp.SystemBuffer); *puOpt = 0; pIrp->IoStatus.Information = sizeof(*puOpt); } -/* EramDeviceControlGetLengthInfo - ディスクサイズ取得処理 - 引数 - pEdskExt EDSK_EXTENTION構造体へのポインタ - pIrp IRPパケットへのポインタ - uLen バッファサイズ - 戻り値 - なし +/* EramDeviceControlGetLengthInfo + Disk Size Getting Process. + Parameters + pEdskExt The pointer to an EDSK_EXTENTION structure. + pIrp The pointer to IRP packet. + uLen The buffer size. + Return Value + No return value. */ VOID EramDeviceControlGetLengthInfo( @@ -430,30 +431,30 @@ VOID EramDeviceControlGetLengthInfo( IN ULONG uLen ) { - /* ローカル変数 */ + /* local variables */ PGET_LENGTH_INFORMATION pInfo; - if (uLen < sizeof(*pInfo)) /* サイズ不足 */ + if (uLen < sizeof(*pInfo)) /* lacking size */ { pIrp->IoStatus.Status = STATUS_INVALID_PARAMETER; KdPrint(("EramDeviceControlGetLengthInfo:size too small\n")); return; } - /* サイズ情報設定 */ + /* Size Info Settings */ pInfo = (PGET_LENGTH_INFORMATION)(pIrp->AssociatedIrp.SystemBuffer); - pInfo->Length.QuadPart = UInt32x32To64(pEramExt->uAllSector, SECTOR); /* 長さ */ + pInfo->Length.QuadPart = UInt32x32To64(pEramExt->uAllSector, SECTOR); /* the length */ pIrp->IoStatus.Status = STATUS_SUCCESS; pIrp->IoStatus.Information = sizeof(*pInfo); KdPrint(("EramDeviceControlGetLengthInfo length 0x%x\n", (pEramExt->uAllSector * SECTOR))); } -/* EramReadWrite - リード/ライト/ベリファイ要求エントリ - 引数 - pDevObj 装置オブジェクトへのポインタ - pIrp IRPパケットへのポインタ - 戻り値 - 結果 +/* EramReadWrite + Read/Write/Verify Request Entry. + Parameters + pDevObj The pointer to device object. + pIrp The pointer to IRP packet. + Return Value + Results. */ NTSTATUS EramReadWrite( @@ -461,66 +462,66 @@ NTSTATUS EramReadWrite( IN PIRP pIrp ) { - /* ローカル変数 */ + /* local variables */ PERAM_EXTENSION pEramExt; PIO_STACK_LOCATION pIrpSp; PUCHAR pTransAddr; NTSTATUS ntStat; //KdPrint(("EramReadWrite start\n")); - /* 構造体先頭ポインタ取得 */ + /* Get the pointer to the first structure */ pEramExt = pDevObj->DeviceExtension; - /* スタックへのポインタ取得 */ + /* Get the pointer to the stack */ pIrpSp = IoGetCurrentIrpStackLocation(pIrp); if ((((ULONGLONG)(pIrpSp->Parameters.Read.ByteOffset.QuadPart) + (ULONGLONG)(pIrpSp->Parameters.Read.Length)) > UInt32x32To64(pEramExt->uAllSector, SECTOR))|| ((pIrpSp->Parameters.Read.ByteOffset.LowPart & (SECTOR-1)) != 0)|| - ((pIrpSp->Parameters.Read.Length & (SECTOR-1)) != 0)) /* ディスク容量を超えたor開始位置/長さがセクタサイズの倍数でない */ + ((pIrpSp->Parameters.Read.Length & (SECTOR-1)) != 0)) /* Disk capacity exceeded or the starting position / the length is not a multiple of the sector size */ { KdPrint(("Invalid I/O parameter, offset 0x%x, length 0x%x, OP=0x%x(R=0x%x, W=0x%x), limit=0x%x\n", pIrpSp->Parameters.Read.ByteOffset.LowPart, pIrpSp->Parameters.Read.Length, pIrpSp->MajorFunction, IRP_MJ_READ, IRP_MJ_WRITE, (pEramExt->uAllSector * SECTOR))); - /* エラーを返す */ + /* Return error */ pIrp->IoStatus.Status = STATUS_INVALID_PARAMETER; IoCompleteRequest(pIrp, IO_NO_INCREMENT); return STATUS_INVALID_PARAMETER; } - /* アドレス初期化 */ + /* address initialization */ pTransAddr = NULL; - if (pIrp->MdlAddress != NULL) /* アドレスあり */ + if (pIrp->MdlAddress != NULL) /* with address */ { - /* アドレス変換 */ + /* address translation */ pTransAddr = MmGetSystemAddressForMdl(pIrp->MdlAddress); } - /* 成功をセット */ + /* Set success */ ntStat = STATUS_SUCCESS; - /* データ長を設定 */ + /* Set the data length */ pIrp->IoStatus.Information = 0; - switch (pIrpSp->MajorFunction) /* ファンクションによる分岐 */ + switch (pIrpSp->MajorFunction) /* Branch by functions */ { - case IRP_MJ_READ: /* リード */ + case IRP_MJ_READ: /* reading */ //KdPrint(("Read start\n")); - /* アドレスが有効なことを確認 */ + /* Validate the address */ if (pTransAddr == NULL) { KdPrint(("MmGetSystemAddressForMdl failed\n")); ntStat = STATUS_INVALID_PARAMETER; break; } - /* リード長を設定 */ + /* Set the length of reading */ pIrp->IoStatus.Information = pIrpSp->Parameters.Read.Length; - /* リード */ + /* reading */ ntStat = (*(pEramExt->EramRead))(pEramExt, pIrp, pIrpSp, pTransAddr); //KdPrint(("Read end\n")); break; - case IRP_MJ_WRITE: /* ライト */ + case IRP_MJ_WRITE: /* writing */ //KdPrint(("Write start\n")); - /* アドレスが有効なことを確認 */ + /* Validate the address */ if (pTransAddr == NULL) { KdPrint(("MmGetSystemAddressForMdl failed\n")); ntStat = STATUS_INVALID_PARAMETER; break; } - /* リード長を設定 */ + /* Set the length of reading */ pIrp->IoStatus.Information = pIrpSp->Parameters.Write.Length; - /* ライト */ + /* writing */ ntStat = (*(pEramExt->EramWrite))(pEramExt, pIrp, pIrpSp, pTransAddr); //KdPrint(("Write end\n")); break; @@ -529,11 +530,11 @@ NTSTATUS EramReadWrite( pIrp->IoStatus.Information = 0; break; } - if (ntStat != STATUS_PENDING) /* 保留以外 */ + if (ntStat != STATUS_PENDING) /* Not pending */ { - /* ステータスをセット */ + /* Set status */ pIrp->IoStatus.Status = ntStat; - /* I/O完了 */ + /* I/O complete */ IoCompleteRequest(pIrp, IO_NO_INCREMENT); } //KdPrint(("EramReadWrite end\n")); @@ -541,38 +542,38 @@ NTSTATUS EramReadWrite( } -/* EramUnloadDriver - ドライバ停止時のエントリポイント - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - 戻り値 - なし +/* EramUnloadDriver + Entry Point for the time of Device Stop + Parameters + pDrvObj The pointert to device representative object. + Return Value + No return value. */ VOID EramUnloadDriver( IN PDRIVER_OBJECT pDrvObj ) { - /* ローカル変数 */ + /* local variables */ PDEVICE_OBJECT pDevObj; PERAM_EXTENSION pEramExt; KdPrint(("EramUnloadDriver start\n")); pDevObj = pDrvObj->DeviceObject; pEramExt = (pDevObj != NULL) ? pDevObj->DeviceExtension : NULL; - /* デバイス削除 */ + /* Delete the device */ EramUnloadDevice(pDrvObj, pDevObj, pEramExt); KdPrint(("EramUnloadDriver end\n")); } -/* EramUnloadDevice - デバイス削除 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - pDevObj 装置オブジェクトへのポインタ - pEramExt ERAM_EXTENTION構造体へのポインタ - 戻り値 - なし +/* EramUnloadDevice + Device Deletion + Parameters + pDrvObj The pointer to device representative object. + pDevObj The pointer to device object. + pEramExt The pointer to an ERAM_EXTENTION structure. + Return Value + No return value. */ VOID EramUnloadDevice( @@ -581,27 +582,27 @@ VOID EramUnloadDevice( IN PERAM_EXTENSION pEramExt ) { - /* ローカル変数 */ + /* local variables */ LARGE_INTEGER llTime; KdPrint(("EramUnloadDevice start\n")); - if (pEramExt != NULL) /* デバイス作成済み */ + if (pEramExt != NULL) /* Device has already created */ { KdPrint(("Device exist\n")); - /* スレッド終了を通知 */ + /* Notify thread termination */ pEramExt->bThreadStop = TRUE; - if (pEramExt->pThreadObject != NULL) /* スレッド存在 */ + if (pEramExt->pThreadObject != NULL) /* Thread exists */ { - /* セマフォ1つ減らす */ + /* Decrement semaphore */ KeReleaseSemaphore(&(pEramExt->IrpSem), 0, 1, TRUE); - /* スレッド終了待ち30秒 */ + /* Wait 30 seconds for thread termination */ llTime.QuadPart = (LONGLONG)(-30 * 10000000); - /* スレッド終了待ち */ + /* Wait for thread termination */ KeWaitForSingleObject(&(pEramExt->pThreadObject), Executive, KernelMode, FALSE, &llTime); - /* スレッドの参照カウントを減らす */ + /* Decrement the reference count of thread */ ObDereferenceObject(&(pEramExt->pThreadObject)); pEramExt->pThreadObject = NULL; } - /* 外部ファイルクローズ */ + /* external file closing */ if (pEramExt->hSection != NULL) { KdPrint(("File section close\n")); @@ -614,33 +615,33 @@ VOID EramUnloadDevice( ZwClose(pEramExt->hFile); pEramExt->hFile = NULL; } - /* メモリマップ解放 */ + /* memory map release */ ResourceRelease(pDrvObj, pEramExt); - if (pEramExt->Win32Name.Buffer != NULL) /* Win32名作成済 */ + if (pEramExt->Win32Name.Buffer != NULL) /* Win32 name has already created */ { - /* Win32リンク解放 */ + /* Win32 link release */ IoDeleteSymbolicLink(&(pEramExt->Win32Name)); - /* Win32名領域解放 */ + /* Win32 name area release */ ExFreePool(pEramExt->Win32Name.Buffer); pEramExt->Win32Name.Buffer = NULL; } } - if (pDevObj != NULL) /* デバイス存在 */ + if (pDevObj != NULL) /* Device exists */ { - /* デバイス削除 */ + /* Delete the device */ IoDeleteDevice(pDevObj); } KdPrint(("EramUnloadDevice end\n")); } -/* ResourceRelease - メモリマップ削除 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - pEramExt ERAM_EXTENTION構造体へのポインタ - 戻り値 - なし +/* ResourceRelease + Memory Map Deletion. + Parameters + pDrvObj The pointer to device representative object. + pEramExt The pointer to an ERAM_EXTENTION structure. + Return Value + No return value. */ VOID ResourceRelease( @@ -649,14 +650,14 @@ VOID ResourceRelease( ) { KdPrint(("ResourceRelease start\n")); - if (pEramExt->uOptflag.Bits.External != 0) /* OS管理外メモリ使用 */ + if (pEramExt->uOptflag.Bits.External != 0) /* OS outside memory usage */ { - /* 資源解放 */ + /* Resource release */ ReleaseMemResource(pDrvObj, pEramExt); } - else if (pEramExt->pPageBase != NULL) /* メモリ確保中 */ + else if (pEramExt->pPageBase != NULL) /* Memory allocating */ { - /* メモリ解放 */ + /* memory release */ ExFreePool(pEramExt->pPageBase); pEramExt->pPageBase = NULL; } @@ -664,13 +665,13 @@ VOID ResourceRelease( } -/* ReleaseMemResource - OS管理外メモリマップ削除 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - pEramExt ERAM_EXTENTION構造体へのポインタ - 戻り値 - なし +/* ReleaseMemResource + OS Outside Management Memory Map Deletion. + Parameters + pDrvObj The pointer to device representative object. + pEramExt The pointer to an ERAM_EXTENTION structure. + Return Value + No return value. */ VOID ReleaseMemResource( @@ -678,14 +679,14 @@ VOID ReleaseMemResource( IN PERAM_EXTENSION pEramExt ) { - /* ローカル変数 */ - CM_RESOURCE_LIST ResList; /* リソースリスト */ + /* local variables */ + CM_RESOURCE_LIST ResList; /* Resource list */ BOOLEAN bResConf; - /* アンマップ */ + /* Unmap */ ExtUnmap(pEramExt); if (pEramExt->uOptflag.Bits.SkipReportUsage == 0) { - /* ドライバ資源解放(2000では解放されないようだ) */ + /* Driver resource release (Not likely released in 2000) */ RtlZeroBytes(&ResList, sizeof(ResList)); IoReportResourceUsage(NULL, pDrvObj, &ResList, sizeof(ResList), NULL, NULL, 0, FALSE, &bResConf); RtlZeroBytes(&(pEramExt->MapAdr), sizeof(pEramExt->MapAdr)); @@ -693,14 +694,14 @@ VOID ReleaseMemResource( } -/* EramReportEvent - システムイベントログ出力 - 引数 - pIoObject デバイスオブジェクトpDevObj または ドライバオブジェクトpDrvObj - ntErrorCode イベントID - pszString 付加文字列 省略時NULL - 戻り値 - 結果 +/* EramReportEvent + System Event Log Output. + Parameters + pIoObject Device object pDevObj or driver object pDrvObj. + ntErrorCode The event ID. + pszString The string to be appended. NULL if omitted. + Return Value + Results. */ BOOLEAN EramReportEvent( @@ -709,7 +710,7 @@ BOOLEAN EramReportEvent( IN PSTR pszString ) { - /* ローカル変数 */ + /* local variables */ ANSI_STRING AnsiStr; UNICODE_STRING UniStr; BOOLEAN bStat; @@ -717,7 +718,7 @@ BOOLEAN EramReportEvent( (*pszString != L'\0')) { RtlInitAnsiString(&AnsiStr, pszString); - /* UNICODE文字列化してダンプ */ + /* UNICODE-stringify and dump */ if (RtlAnsiStringToUnicodeString(&UniStr, &AnsiStr, TRUE) == STATUS_SUCCESS) { bStat = EramReportEventW(pIoObject, ntErrorCode, UniStr.Buffer); @@ -729,14 +730,14 @@ BOOLEAN EramReportEvent( } -/* EramReportEventW - システムイベントログ出力 - 引数 - pIoObject デバイスオブジェクトpDevObj または ドライバオブジェクトpDrvObj - ntErrorCode イベントID - pwStr 付加文字列(UNICODE) 省略時NULL - 戻り値 - 結果 +/* EramReportEventW + System Event Log Output. + Parameters + pIoObject Device object pDevObj or driver object pDrvObj. + ntErrorCode The event ID. + pwStr The Unicode string to be appended. NULL if omitted. + Return Value + Results. */ BOOLEAN EramReportEventW( @@ -745,59 +746,59 @@ BOOLEAN EramReportEventW( IN PWSTR pwStr ) { - /* ローカル変数 */ + /* local variables */ PIO_ERROR_LOG_PACKET pPacket; ULONG uSize; UNICODE_STRING UniStr; KdPrint(("EramReportEventW start, event:%ls\n", (PWSTR)((pwStr != NULL) ? pwStr : (PWSTR)(L"")))); - /* パケットサイズ初期化 */ + /* packet size initialization */ uSize = sizeof(IO_ERROR_LOG_PACKET); - if (pwStr != NULL) /* 付加文字列あり */ + if (pwStr != NULL) /* With appending string */ { RtlInitUnicodeString(&UniStr, pwStr); - /* パケットサイズ加算 */ + /* packet size adding */ uSize += (UniStr.Length + sizeof(WCHAR)); } - if (uSize > ERROR_LOG_MAXIMUM_SIZE) /* 文字列が長すぎる */ + if (uSize > ERROR_LOG_MAXIMUM_SIZE) /* string too long */ { KdPrint(("String too long\n")); return FALSE; } - /* パケット確保 */ + /* packet allocation */ pPacket = IoAllocateErrorLogEntry(pIoObject, (UCHAR)uSize); - if (pPacket == NULL) /* 確保失敗 */ + if (pPacket == NULL) /* allocation failed */ { KdPrint(("IoAllocateErrorLogEntry failed\n")); return FALSE; } - /* 標準データ部初期化 */ + /* standard data part initialization */ RtlZeroBytes(pPacket, uSize); pPacket->ErrorCode = ntErrorCode; - if (pwStr != NULL) /* 付加文字列あり */ + if (pwStr != NULL) /* with appending string */ { - /* 文字列数を設定 */ + /* Set the number of strings */ pPacket->NumberOfStrings = 1; - /* 文字列開始位置を設定 */ + /* Set the starting position of string */ pPacket->StringOffset = sizeof(IO_ERROR_LOG_PACKET); - /* UNICODE文字列をコピー */ + /* Copy the Unicode string */ RtlCopyBytes(&(pPacket[1]), UniStr.Buffer, UniStr.Length); } - /* ログ出力 */ + /* Log output */ IoWriteErrorLogEntry(pPacket); KdPrint(("EramReportEventW end\n")); return TRUE; } -/* ReadPool - OS管理メモリ読み込み - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pIrp IRPパケットへのポインタ - pIrpSp スタック情報へのポインタ - lpDest 格納領域へのポインタ - 戻り値 - 結果 +/* ReadPool + OS Management Memory Reading. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pIrp The pointer to IRP packet. + pIrpSp The pointer to stack info. + lpDest The pointer to storage area. + Return Value + Results. */ NTSTATUS ReadPool( @@ -807,7 +808,7 @@ NTSTATUS ReadPool( IN PUCHAR lpDest ) { - /* ローカル変数 */ + /* local variables */ PUCHAR lpSrc; lpSrc = (PUCHAR)((ULONG)pEramExt->pPageBase + (ULONG)pIrpSp->Parameters.Read.ByteOffset.LowPart); RtlCopyBytes(lpDest, lpSrc, pIrpSp->Parameters.Read.Length); @@ -815,15 +816,15 @@ NTSTATUS ReadPool( } -/* WritePool - OS管理メモリ書き込み - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pIrp IRPパケットへのポインタ - pIrpSp スタック情報へのポインタ - lpSrc データ領域へのポインタ - 戻り値 - 結果 +/* WritePool + OS Management Memory Writing. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pIrp The pointer to IRP packet. + pIrpSp The pointer to stack info. + lpSrc The pointer to data area. + Return Value + Results. */ NTSTATUS WritePool( @@ -833,7 +834,7 @@ NTSTATUS WritePool( IN PUCHAR lpSrc ) { - /* ローカル変数 */ + /* local variables */ PUCHAR lpDest; lpDest = (PUCHAR)((ULONG)pEramExt->pPageBase + (ULONG)pIrpSp->Parameters.Write.ByteOffset.LowPart); RtlCopyBytes(lpDest, lpSrc, pIrpSp->Parameters.Write.Length); @@ -841,15 +842,15 @@ NTSTATUS WritePool( } -/* ExtRead1 - OS管理外メモリ読み込み(checkなし) - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pIrp IRPパケットへのポインタ - pIrpSp スタック情報へのポインタ - lpDest 格納領域へのポインタ - 戻り値 - 結果 +/* ExtRead1 + OS Outside Management Memory Reading (without check). + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pIrp The pointer to IRP packet. + pIrpSp The pointer to stack info. + lpDest The pointer to storage area. + Return Value + Results. */ NTSTATUS ExtRead1( @@ -859,7 +860,7 @@ NTSTATUS ExtRead1( IN PUCHAR lpDest ) { - /* ローカル変数 */ + /* local variables */ PUCHAR lpSrc; UINT uLen; DWORD eax, ebx; @@ -867,22 +868,22 @@ NTSTATUS ExtRead1( ULONG uMemAdr; ASSERT(pEramExt->uExternalStart != 0); ASSERT(pEramExt->uExternalEnd != 0); - /* Mutex待ち */ + /* Mutex wait */ ExAcquireFastMutex(&(pEramExt->FastMutex)); - uLen = pIrpSp->Parameters.Read.Length; /* 転送サイズ(セクタサイズの倍数) */ - /* セクタ番号を計算 */ + uLen = pIrpSp->Parameters.Read.Length; /* Transfer size (a multiples of sector size) */ + /* Calculate the sector number */ ebx = pIrpSp->Parameters.Read.ByteOffset.LowPart >> SECTOR_LOG2; - /* メモリ位置を計算 */ + /* Calculate the memory position */ uMemAdr = pEramExt->uExternalStart + pIrpSp->Parameters.Read.ByteOffset.LowPart; ntStat = STATUS_SUCCESS; while (uLen != 0) { - if (uMemAdr >= pEramExt->uExternalEnd) /* 実メモリを超えている */ + if (uMemAdr >= pEramExt->uExternalEnd) /* Beyond real memory */ { ntStat = STATUS_DISK_CORRUPT_ERROR; break; } - /* 64KB割り当て */ + /* 64KB allocation */ if (ExtNext1(pEramExt, &eax, &ebx) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "ExtNext1"); @@ -890,29 +891,29 @@ NTSTATUS ExtRead1( break; } lpSrc = (PUCHAR)((ULONG)(pEramExt->pExtPage + eax)); - /* データ転送 */ + /* data transfer */ RtlCopyBytes(lpDest, lpSrc, SECTOR); lpDest += SECTOR; uLen -= SECTOR; uMemAdr += SECTOR; } - /* アンマップ */ + /* Unmap */ ExtUnmap(pEramExt); - /* Mutex解放 */ + /* Mutex release */ ExReleaseFastMutex(&(pEramExt->FastMutex)); return ntStat; } -/* ExtWrite1 - OS管理外メモリ書き込み(checkなし) - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pIrp IRPパケットへのポインタ - pIrpSp スタック情報へのポインタ - lpSrc データ領域へのポインタ - 戻り値 - 結果 +/* ExtWrite1 + OS Outside Memory Writing (without check). + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pIrp The pointer to IRP packet. + pIrpSp The pointer to stack info. + lpSrc The pointer to data area. + Return Value + Results. */ NTSTATUS ExtWrite1( @@ -922,7 +923,7 @@ NTSTATUS ExtWrite1( IN PUCHAR lpSrc ) { - /* ローカル変数 */ + /* local variables */ PUCHAR lpDest; UINT uLen; DWORD eax, ebx; @@ -930,22 +931,22 @@ NTSTATUS ExtWrite1( ULONG uMemAdr; ASSERT(pEramExt->uExternalStart != 0); ASSERT(pEramExt->uExternalEnd != 0); - /* Mutex待ち */ + /* Mutex wait */ ExAcquireFastMutex(&(pEramExt->FastMutex)); uLen = pIrpSp->Parameters.Write.Length; - /* セクタ番号を計算 */ + /* Calculate the sector number */ ebx = pIrpSp->Parameters.Write.ByteOffset.LowPart >> SECTOR_LOG2; - /* メモリ位置を計算 */ + /* Calculate the memory position */ uMemAdr = pEramExt->uExternalStart + pIrpSp->Parameters.Write.ByteOffset.LowPart; ntStat = STATUS_SUCCESS; while (uLen != 0) { - if (uMemAdr >= pEramExt->uExternalEnd) /* 実メモリを超えている */ + if (uMemAdr >= pEramExt->uExternalEnd) /* Beyond real memory */ { ntStat = STATUS_DISK_CORRUPT_ERROR; break; } - /* 64KB割り当て */ + /* 64KB allocation */ if (ExtNext1(pEramExt, &eax, &ebx) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "ExtNext1"); @@ -953,28 +954,28 @@ NTSTATUS ExtWrite1( break; } lpDest = (PUCHAR)((ULONG)(pEramExt->pExtPage + eax)); - /* データ転送 */ + /* data transfer */ RtlCopyBytes(lpDest, lpSrc, SECTOR); lpSrc += SECTOR; uLen -= SECTOR; uMemAdr += SECTOR; } - /* アンマップ */ + /* Unmap */ ExtUnmap(pEramExt); - /* Mutex解放 */ + /* Mutex release */ ExReleaseFastMutex(&(pEramExt->FastMutex)); return ntStat; } -/* ExtNext1 - OS管理外:該当セクタの割り当て(checkなし時) - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - lpeax ページ内オフセットを返す領域へのポインタ - lpebx セクタ番号へのポインタ(+1される) - 戻り値 - 結果 +/* ExtNext1 + OS Outside Management: The corresponding sector allocation (without check) + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + lpeax The pointer to the area to return the inner page offset. + lpebx The pointer to the sector number (incremented). + Return Value + Results. */ BOOLEAN ExtNext1( @@ -983,21 +984,21 @@ BOOLEAN ExtNext1( IN OUT LPDWORD lpebx ) { - /* ローカル変数 */ + /* local variables */ DWORD eax, ebx, uMapAdr; ebx = *lpebx; - /* マップすべきバンク番号を計算 */ + /* calculate the bank number to be mapped */ uMapAdr = (ebx >> EXT_PAGE_SEC_LOG2) << EXT_PAGE_SIZE_LOG2; - /* マップ */ + /* map */ if (ExtMap(pEramExt, uMapAdr) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "ExtMap"); return FALSE; } - /* オフセット算出 */ + /* calculate the offset */ eax = ebx & (EXT_PAGE_SECTOR - 1); eax <<= SECTOR_LOG2; - /* セクタ番号を進める */ + /* proceed the sector number */ ebx++; *lpeax = eax; *lpebx = ebx; @@ -1005,13 +1006,13 @@ BOOLEAN ExtNext1( } -/* ExtMap - OS管理外メモリのマップ - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - uMapAdr マップする相対バイト位置(64KB単位) - 戻り値 - 結果 +/* ExtMap + OS Outside Memory Mapping. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + uMapAdr The relative byte offset to be mapped (64KB unit). + Return Value + Results. */ BOOLEAN ExtMap( @@ -1019,25 +1020,25 @@ BOOLEAN ExtMap( IN ULONG uMapAdr ) { - /* ローカル変数 */ + /* local variables */ PHYSICAL_ADDRESS MapAdr; - if ((pEramExt->pExtPage == NULL)|| /* 未マップ */ - (pEramExt->uNowMapAdr != uMapAdr)) /* 現在マップ中のページと異なる */ + if ((pEramExt->pExtPage == NULL)|| /* unmapped */ + (pEramExt->uNowMapAdr != uMapAdr)) /* different page from the currently mapped page */ { - /* 現在のページをアンマップ */ + /* Unmap the current page */ ExtUnmap(pEramExt); - /* マップ位置補正 */ + /* fix the mapping position */ MapAdr = pEramExt->MapAdr; - if (MapAdr.LowPart == 0) /* 解放済み */ + if (MapAdr.LowPart == 0) /* Already released */ { KdPrint(("Already resource released\n")); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_MAXMEM_ALREADY_FREE, NULL); return FALSE; } MapAdr.LowPart += uMapAdr; - /* マップ(キャッシュ許可) */ + /* map (allow cache) */ pEramExt->pExtPage = (PBYTE)MmMapIoSpace(MapAdr, EXT_PAGE_SIZE, TRUE); - if (pEramExt->pExtPage == NULL) /* 失敗 */ + if (pEramExt->pExtPage == NULL) /* failed */ { KdPrint(("MmMapIoSpace failed\n")); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_MAXMEM_MAP_FAILED, NULL); @@ -1049,21 +1050,21 @@ BOOLEAN ExtMap( } -/* ExtUnmap - OS管理外メモリのアンマップ - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - 戻り値 - なし +/* ExtUnmap + OS Outside Memory Unmapping. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + Return Value + No return value. */ VOID ExtUnmap( IN PERAM_EXTENSION pEramExt ) { - if (pEramExt->pExtPage != NULL) /* マップ中のページあり */ + if (pEramExt->pExtPage != NULL) /* with the mapping page(s) */ { - /* 64KBアンマップ */ + /* 64KB unmapping */ MmUnmapIoSpace(pEramExt->pExtPage, EXT_PAGE_SIZE); pEramExt->pExtPage = NULL; pEramExt->uNowMapAdr = 0; @@ -1071,15 +1072,15 @@ VOID ExtUnmap( } -/* ExtFilePendingRw - 外部ファイル読み込み(保留) - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pIrp IRPパケットへのポインタ - pIrpSp スタック情報へのポインタ - pTransAddr 格納領域へのポインタ - 戻り値 - 結果 +/* ExtFilePendingRw + External File Reading (Pending). + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pIrp The pointer to IRP packet. + pIrpSp The pointer to stack info. + pTransAddr The pointer to storage area. + Return Value + Results. */ NTSTATUS ExtFilePendingRw( @@ -1090,88 +1091,88 @@ NTSTATUS ExtFilePendingRw( ) { //KdPrint(("ExtFilePendingRw start\n")); - if (pEramExt->bThreadStop != 0) /* 終了指示済み */ + if (pEramExt->bThreadStop != 0) /* Instructed termination */ { KdPrint(("stop sequence\n")); pIrp->IoStatus.Information = 0; return STATUS_DEVICE_NOT_READY; } - if (pEramExt->pThreadObject == NULL) /* スレッド無い */ + if (pEramExt->pThreadObject == NULL) /* without thread */ { KdPrint(("Thread not exist\n")); pIrp->IoStatus.Information = 0; return STATUS_DEVICE_NOT_READY; } - /* I/O保留 */ + /* Pending I/O */ IoMarkIrpPending(pIrp); pIrp->IoStatus.Status = STATUS_PENDING; - /* キューに載せる */ + /* Queue */ ExInterlockedInsertTailList(&(pEramExt->IrpList), &(pIrp->Tail.Overlay.ListEntry), &(pEramExt->IrpSpin)); - /* セマフォ1つ減らす */ + /* Decrement semaphores */ KeReleaseSemaphore(&(pEramExt->IrpSem), 0, 1, FALSE); //KdPrint(("ExtFilePendingRw end\n")); return STATUS_PENDING; } -/* EramRwThread - 外部ファイルリード/ライト要求エントリ(DISPATCH_LEVEL) - 引数 - pContext 引き渡し情報へのポインタ - 戻り値 - なし +/* EramRwThread + External File Reading/Writing Request Entry (DISPATCH_LEVEL) + Parameters + pContext The pointer to the delivery info. + Return Value + No return value. */ VOID EramRwThread( IN PVOID pContext ) { - /* ローカル変数 */ + /* local variables */ PERAM_EXTENSION pEramExt; PIRP pIrp; NTSTATUS ntStat; PLIST_ENTRY pIrpList; KdPrint(("EramRwThread start\n")); - /* 先頭ポインタ取得 */ + /* Get the leading pointer */ pEramExt = pContext; ASSERT(pEramExt != NULL); - /* 優先化 */ - KeSetPriorityThread(KeGetCurrentThread(), LOW_REALTIME_PRIORITY); // 標準はPrior8 - while (pEramExt->bThreadStop == 0) /* スレッド活動中 */ + /* Make priority */ + KeSetPriorityThread(KeGetCurrentThread(), LOW_REALTIME_PRIORITY); // Standard is Prior8 + while (pEramExt->bThreadStop == 0) /* thread in active */ { //KdPrint(("Waiting\n")); - /* 要求待ち 兼 カウンタ戻し */ + /* Wait the request and resume the counter */ KeWaitForSingleObject(&(pEramExt->IrpSem), Executive, KernelMode, FALSE, NULL); - if (pEramExt->bThreadStop != 0) /* スレッド停止要求 */ + if (pEramExt->bThreadStop != 0) /* thread stop request */ { KdPrint(("thread should stop\n")); break; } //KdPrint(("Wake\n")); - /* IRPリストの先頭を取得 */ + /* Get the head of the IRP list */ pIrpList = ExInterlockedRemoveHeadList(&(pEramExt->IrpList), &(pEramExt->IrpSpin)); //KdPrint(("Get list\n")); - if (pIrpList != NULL) /* リスト有効 */ + if (pIrpList != NULL) /* The list is valid */ { ntStat = EramRwThreadIrp(pEramExt, pIrpList); //KdPrint(("EramRwThreadIrp return 0x%x\n", ntStat)); } } - /* 残りのIRPをキャンセル */ + /* Cancel the remainder IRPs */ for (;;) { - /* IRPリストの先頭を取得 */ + /* Get the head of the IRP list */ pIrpList = ExInterlockedRemoveHeadList(&(pEramExt->IrpList), &(pEramExt->IrpSpin)); - if (pIrpList == NULL) /* これ以上は無い */ + if (pIrpList == NULL) /* No more data */ { break; } - /* IRPを取得 */ + /* get IRP */ pIrp = CONTAINING_RECORD(pIrpList, IRP, Tail.Overlay.ListEntry); ASSERT(pIrp != NULL); pIrp->IoStatus.Information = 0; pIrp->IoStatus.Status = STATUS_DEVICE_NOT_READY; - /* I/O完了 */ + /* I/O complete */ IoCompleteRequest(pIrp, IO_NO_INCREMENT); } if (pEramExt->hSection != NULL) @@ -1190,13 +1191,13 @@ VOID EramRwThread( } -/* EramRwThreadIrp - 外部ファイルリード/ライト要求(1IRP) - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pIrpList IRPリスト情報へのポインタ - 戻り値 - 結果 +/* EramRwThreadIrp + External File Reading/Writing Request (1IRP) + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pIrpList The pointer to IRP list info. + Return Value + Results. */ NTSTATUS EramRwThreadIrp( @@ -1204,7 +1205,7 @@ NTSTATUS EramRwThreadIrp( PLIST_ENTRY pIrpList ) { - /* ローカル変数 */ + /* local variables */ PIRP pIrp; PIO_STACK_LOCATION pIrpSp; NTSTATUS ntStat; @@ -1212,36 +1213,36 @@ NTSTATUS EramRwThreadIrp( //KdPrint(("EramRwThreadIrp start\n")); ASSERT(pEramExt != NULL); ASSERT(pIrpList != NULL); - /* IRPを取得 */ + /* get IRP */ pIrp = CONTAINING_RECORD(pIrpList, IRP, Tail.Overlay.ListEntry); ASSERT(pIrp != NULL); pIrp->IoStatus.Information = 0; pTransAddr = NULL; - if (pIrp->MdlAddress != NULL) /* アドレスあり */ + if (pIrp->MdlAddress != NULL) /* with address */ { - /* アドレス変換 */ + /* address translation */ pTransAddr = MmGetSystemAddressForMdl(pIrp->MdlAddress); } - if (pTransAddr == NULL) /* 変換失敗 */ + if (pTransAddr == NULL) /* conversion failure */ { KdPrint(("MmGetSystemAddressForMdl failed\n")); - /* ステータスをセット */ + /* Set status */ pIrp->IoStatus.Status = STATUS_INVALID_PARAMETER; - /* I/O完了 */ + /* I/O complete */ IoCompleteRequest(pIrp, IO_NO_INCREMENT); return STATUS_INVALID_PARAMETER; } pIrpSp = IoGetCurrentIrpStackLocation(pIrp); ASSERT(pIrpSp != NULL); - switch (pIrpSp->MajorFunction) /* ファンクションによる分岐 */ + switch (pIrpSp->MajorFunction) /* Branch by functions */ { - case IRP_MJ_READ: /* リード */ - /* リード長を設定 */ + case IRP_MJ_READ: /* reading */ + /* Set the length of reading */ pIrp->IoStatus.Information = pIrpSp->Parameters.Read.Length; ntStat = ExtFileRead1(pEramExt, pIrp, pIrpSp, pTransAddr); break; - case IRP_MJ_WRITE: /* ライト */ - /* ライト長を設定 */ + case IRP_MJ_WRITE: /* writing */ + /* Set the length of writing */ pIrp->IoStatus.Information = pIrpSp->Parameters.Write.Length; ntStat = ExtFileWrite1(pEramExt, pIrp, pIrpSp, pTransAddr); break; @@ -1250,24 +1251,24 @@ NTSTATUS EramRwThreadIrp( ntStat = STATUS_SUCCESS; break; } - /* ステータスをセット */ + /* Set status */ pIrp->IoStatus.Status = ntStat; - /* I/O完了 */ + /* I/O complete */ IoCompleteRequest(pIrp, IO_NO_INCREMENT); //KdPrint(("EramRwThreadIrp end\n")); return ntStat; } -/* ExtFileRead1 - 外部ファイル読み込み(checkなし) - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pIrp IRPパケットへのポインタ - pIrpSp スタック情報へのポインタ - lpDest 格納領域へのポインタ - 戻り値 - 結果 +/* ExtFileRead1 + External File Reading (without check). + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pIrp The pointer to IRP packet. + pIrpSp The pointer to stack info. + lpDest The pointer to storage area. + Return Value + Results. */ NTSTATUS ExtFileRead1( @@ -1277,19 +1278,19 @@ NTSTATUS ExtFileRead1( IN PUCHAR lpDest ) { - /* ローカル変数 */ + /* local variables */ PUCHAR lpSrc; UINT uLen; DWORD eax, ebx; NTSTATUS ntStat; ASSERT(pEramExt != NULL); - uLen = pIrpSp->Parameters.Read.Length; /* 転送サイズ(セクタサイズの倍数) */ - /* セクタ番号を計算 */ + uLen = pIrpSp->Parameters.Read.Length; /* Transfer size (a multiples of sector size) */ + /* Calculate the sector number */ ebx = pIrpSp->Parameters.Read.ByteOffset.LowPart >> SECTOR_LOG2; ntStat = STATUS_SUCCESS; while (uLen != 0) { - /* 64KB割り当て */ + /* 64KB allocation */ if (ExtFileNext1(pEramExt, &eax, &ebx) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "ExtFileNext1"); @@ -1297,26 +1298,26 @@ NTSTATUS ExtFileRead1( break; } lpSrc = (PUCHAR)((ULONG)(pEramExt->pExtPage + eax)); - /* データ転送 */ + /* data transfer */ RtlCopyBytes(lpDest, lpSrc, SECTOR); lpDest += SECTOR; uLen -= SECTOR; } - /* アンマップ */ + /* Unmap */ ExtFileUnmap(pEramExt); return ntStat; } -/* ExtFileWrite1 - 外部ファイル書き込み(checkなし) - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pIrp IRPパケットへのポインタ - pIrpSp スタック情報へのポインタ - lpSrc データ領域へのポインタ - 戻り値 - 結果 +/* ExtFileWrite1 + External File Writing (without check). + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pIrp The pointer to IRP packet. + pIrpSp The pointer to stack info. + lpSrc The pointer to data area. + Return Value + Results. */ NTSTATUS ExtFileWrite1( @@ -1326,19 +1327,19 @@ NTSTATUS ExtFileWrite1( IN PUCHAR lpSrc ) { - /* ローカル変数 */ + /* local variables */ PUCHAR lpDest; UINT uLen; DWORD eax, ebx; NTSTATUS ntStat; ASSERT(pEramExt != NULL); uLen = pIrpSp->Parameters.Write.Length; - /* セクタ番号を計算 */ + /* Calculate the sector number */ ebx = pIrpSp->Parameters.Write.ByteOffset.LowPart >> SECTOR_LOG2; ntStat = STATUS_SUCCESS; while (uLen != 0) { - /* 64KB割り当て */ + /* 64KB allocation */ if (ExtFileNext1(pEramExt, &eax, &ebx) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "ExtFileNext1"); @@ -1346,25 +1347,25 @@ NTSTATUS ExtFileWrite1( break; } lpDest = (PUCHAR)((ULONG)(pEramExt->pExtPage + eax)); - /* データ転送 */ + /* data transfer */ RtlCopyBytes(lpDest, lpSrc, SECTOR); lpSrc += SECTOR; uLen -= SECTOR; } - /* アンマップ */ + /* Unmap */ ExtFileUnmap(pEramExt); return ntStat; } -/* ExtFileNext1 - 外部ファイル:該当セクタの割り当て(checkなし時) - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - lpeax ページ内オフセットを返す領域へのポインタ - lpebx セクタ番号へのポインタ(+1される) - 戻り値 - 結果 +/* ExtFileNext1 + External File: The corresponding sector allocation (without check). + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + lpeax The pointer to the area to return the inner page offset. + lpebx The pointer to the sector number (incremented). + Return Value + Results. */ BOOLEAN ExtFileNext1( @@ -1373,23 +1374,23 @@ BOOLEAN ExtFileNext1( IN OUT LPDWORD lpebx ) { - /* ローカル変数 */ + /* local variables */ DWORD eax, ebx, uMapAdr; ASSERT(pEramExt != NULL); ebx = *lpebx; - /* マップすべきバンク番号を計算 */ + /* Calculate the bank number to be mapped */ uMapAdr = (ebx >> EXT_PAGE_SEC_LOG2) << EXT_PAGE_SIZE_LOG2; - /* マップ */ + /* map */ if (ExtFileMap(pEramExt, uMapAdr) == FALSE) { KdPrint(("ExtFileMap failed, MapAdr=0x%x, sector=0x%x, SizeSec=0x%x, SizeBytes=0x%x\n", uMapAdr, ebx, (pEramExt->uAllSector << SECTOR_LOG2), (pEramExt->uSizeTotal << PAGE_SIZE_LOG2))); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "ExtFileMap"); return FALSE; } - /* オフセット算出 */ + /* Offset calculation */ eax = ebx & (EXT_PAGE_SECTOR - 1); eax <<= SECTOR_LOG2; - /* セクタ番号を進める */ + /* Proceed the sector number */ ebx++; *lpeax = eax; *lpebx = ebx; @@ -1397,13 +1398,13 @@ BOOLEAN ExtFileNext1( } -/* ExtFileMap - 外部ファイルのマップ - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - uMapAdr マップする相対バイト位置(64KB単位) - 戻り値 - 結果 +/* ExtFileMap + External File Mapping. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + uMapAdr The relative byte offset to be mapped (64KB unit). + Return Value + Results. */ BOOLEAN ExtFileMap( @@ -1411,26 +1412,26 @@ BOOLEAN ExtFileMap( IN ULONG uMapAdr ) { - /* ローカル変数 */ + /* local variables */ LARGE_INTEGER llOfs; ULONG uView; NTSTATUS ntStat; ASSERT(pEramExt != NULL); - if ((pEramExt->pExtPage == NULL)|| /* 未マップ */ - (pEramExt->uNowMapAdr != uMapAdr)) /* 現在マップ中のページと異なる */ + if ((pEramExt->pExtPage == NULL)|| /* unmapped */ + (pEramExt->uNowMapAdr != uMapAdr)) /* different page from the current mapping page */ { - /* 現在のページをアンマップ */ + /* Unmap the current page */ ExtFileUnmap(pEramExt); - /* マップ位置準備 */ + /* Prepare for mapping position */ llOfs.QuadPart = (LONGLONG)uMapAdr; uView = ((pEramExt->uSizeTotal << PAGE_SIZE_LOG2) - uMapAdr); if (uView > EXT_PAGE_SIZE) { uView = EXT_PAGE_SIZE; } - /* マップ(キャッシュ許可) */ + /* map (allow cache) */ ntStat = ZwMapViewOfSection(pEramExt->hSection, NtCurrentProcess(), &(pEramExt->pExtPage), 0, uView, &llOfs, &uView, ViewShare, 0, PAGE_READWRITE); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { KdPrint(("ZwMapViewOfSection failed, 0x%x, MapAdr=0x%x, size=0x%x\n", ntStat, uMapAdr, uView)); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_MAP_EXT_FILE, NULL); @@ -1443,26 +1444,26 @@ BOOLEAN ExtFileMap( } -/* ExtFileUnmap - 外部ファイルのアンマップ - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - 戻り値 - なし +/* ExtFileUnmap + External File Unmapping. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + Return Value + No return value. */ VOID ExtFileUnmap( IN PERAM_EXTENSION pEramExt ) { - /* ローカル変数 */ + /* local variables */ NTSTATUS ntStat; ASSERT(pEramExt != NULL); - if (pEramExt->pExtPage == NULL) /* マップ中のページなし */ + if (pEramExt->pExtPage == NULL) /* no page in the map */ { return; } - /* 64KBアンマップ */ + /* 64KB unmapping */ ntStat = ZwUnmapViewOfSection(NtCurrentProcess(), pEramExt->pExtPage); pEramExt->pExtPage = NULL; pEramExt->uNowMapAdr = 0; @@ -1473,13 +1474,13 @@ VOID ExtFileUnmap( } -/* EramShutdown - シャットダウン要求エントリ - 引数 - pDevObj 装置オブジェクトへのポインタ - pIrp IRPパケットへのポインタ - 戻り値 - 結果 +/* EramShutdown + Shutdown Request Entry. + Parameters + pDevObj The pointer to device object. + pIrp The pointer to IRP packet. + Return Value + Results. */ NTSTATUS EramShutdown( @@ -1487,25 +1488,25 @@ NTSTATUS EramShutdown( IN PIRP pIrp ) { - /* ローカル変数 */ + /* local variables */ PERAM_EXTENSION pEramExt; LARGE_INTEGER llTime; KdPrint(("EramShutdown start\n")); pEramExt = pDevObj->DeviceExtension; - /* スレッド終了を通知 */ + /* Notify thread termination */ pEramExt->bThreadStop = TRUE; - if (pEramExt->pThreadObject != NULL) /* スレッド存在 */ + if (pEramExt->pThreadObject != NULL) /* Thread exists */ { - /* セマフォ1つ減らす */ + /* Decrement semaphore */ KeReleaseSemaphore(&(pEramExt->IrpSem), 0, 1, TRUE); - /* スレッド終了待ち5秒 */ + /* Wait 5 seconds for thread termination */ llTime.QuadPart = (LONGLONG)(-5 * 10000000); KeWaitForSingleObject(&(pEramExt->pThreadObject), Executive, KernelMode, FALSE, &llTime); - /* スレッドの参照カウントを減らす */ + /* Decrement the reference count of thread(s) */ ObDereferenceObject(&(pEramExt->pThreadObject)); pEramExt->pThreadObject = NULL; } - /* 外部ファイルクローズ */ + /* External File Closing */ if (pEramExt->hSection != NULL) { KdPrint(("File section close\n")); @@ -1518,7 +1519,7 @@ NTSTATUS EramShutdown( ZwClose(pEramExt->hFile); pEramExt->hFile = NULL; } - /* 成功をセット */ + /* Set success */ pIrp->IoStatus.Status = STATUS_SUCCESS; pIrp->IoStatus.Information = 0; IoCompleteRequest(pIrp, IO_NO_INCREMENT); @@ -1527,16 +1528,16 @@ NTSTATUS EramShutdown( } -//------ これ以降は初期化時に使用する関数群 +//------ Below is functions used at initialization -/* DriverEntry - ドライバ初期化時のエントリポイント - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - pRegPath レジストリキーへのポインタ - 戻り値 - 結果 +/* DriverEntry + The Entry Point When Driver Initialization. + Parameters + pDrvObj The pointer to device representative object. + pRegPath The pointer to registry key. + Return Value + Results. */ NTSTATUS DriverEntry( @@ -1544,68 +1545,68 @@ NTSTATUS DriverEntry( IN PUNICODE_STRING pRegPath ) { - /* ローカル変数 */ + /* local variables */ NTSTATUS ntStat; - UNICODE_STRING RegParam; /* UNICODEを用いたレジストリパス */ - UNICODE_STRING RegParamAdd; /* UNICODEを用いたレジストリパス */ + UNICODE_STRING RegParam; /* Registry path (using Unicode) */ + UNICODE_STRING RegParamAdd; /* Registry path (using Unicode) */ PVOID pPool; - PFAT_ID pFatId; /* BPB作業領域 */ + PFAT_ID pFatId; /* BPB work area */ KdPrint(("DriverEntry start\n")); - /* レジストリパス最大長を取得 */ + /* Get the max length of registry path */ RegParam.MaximumLength = (WORD)(pRegPath->Length + sizeof(SUBKEY_WSTRING)); - /* 作業用メモリ確保 */ + /* memory allocation for work */ pPool = ExAllocatePool(PagedPool, sizeof(*pFatId) + RegParam.MaximumLength); - if (pPool == NULL) /* 確保失敗 */ + if (pPool == NULL) /* allocation failed */ { KdPrint(("ExAllocatePool failed\n")); EramReportEvent(pDrvObj, ERAMNT_ERROR_WORK_ALLOC_FAILED, NULL); - /* エラーを返す */ + /* Return error */ return STATUS_INSUFFICIENT_RESOURCES; } - /* ポインタ設定 */ + /* Pointer setting */ pFatId = (PFAT_ID)pPool; RegParam.Buffer = (PWSTR)(&(pFatId[1])); - /* レジストリキー文字列をコピー */ + /* Copy the registry key string */ RtlCopyUnicodeString(&RegParam, pRegPath); - /* レジストリサブキー文字列をコピー */ + /* Copy the registry subkey string */ RtlInitUnicodeString(&RegParamAdd, (PWSTR)SUBKEY_WSTRING); - if (RtlAppendUnicodeStringToString(&RegParam, &RegParamAdd) != STATUS_SUCCESS) /* 合成失敗 */ + if (RtlAppendUnicodeStringToString(&RegParam, &RegParamAdd) != STATUS_SUCCESS) /* 蜷域仙、ア謨 */ { KdPrint(("RtlAppendUnicodeStringToString failed\n")); EramReportEvent(pDrvObj, ERAMNT_ERROR_REG_KEY_APPEND_FAILED, NULL); - /* 作業用メモリを解放 */ + /* Release the memory for work */ ExFreePool(pPool); - /* エラーを返す */ + /* Return error */ return STATUS_INSUFFICIENT_RESOURCES; } - /* FatId構造体の初期化 */ + /* FatId structure initialization */ InitFatId(pFatId); - /* ドライバのエントリポイントを初期化 */ + /* Driver entry point initialization */ pDrvObj->MajorFunction[IRP_MJ_CREATE] = EramCreateClose; pDrvObj->MajorFunction[IRP_MJ_CLOSE] = EramCreateClose; pDrvObj->MajorFunction[IRP_MJ_READ] = EramReadWrite; pDrvObj->MajorFunction[IRP_MJ_WRITE] = EramReadWrite; pDrvObj->MajorFunction[IRP_MJ_DEVICE_CONTROL] = EramDeviceControl; pDrvObj->MajorFunction[IRP_MJ_SHUTDOWN] = EramShutdown; - /* 解放時のエントリを初期化 */ + /* initialize the entry/entries when releasing */ pDrvObj->DriverUnload = EramUnloadDriver; - /* RAMディスクを初期化 */ + /* RAM disk initialization */ ntStat = EramInitDisk(pDrvObj, pFatId, &RegParam); ASSERT(pPool != NULL); - /* 作業用メモリを解放 */ + /* Release the memory for work */ ExFreePool(pPool); KdPrint(("DriverEntry end\n")); - /* 初期化終了 */ + /* 蛻晄悄蛹也オゆコ */ return ntStat; } -/* InitFatId - FatId構造体の初期化 - 引数 - pFatId FAT-ID構造体へのポインタ - 戻り値 - なし +/* InitFatId + FatId Structure Initialization. + Parameters + pFatId The pointer to FAT-ID structure. + Return Value + No return value. */ VOID InitFatId( @@ -1614,29 +1615,29 @@ VOID InitFatId( { KdPrint(("InitFatId start\n")); RtlZeroBytes(pFatId, sizeof(*pFatId)); - pFatId->BPB.wNumSectorByte = SECTOR; /* セクタバイト数(BPB, =SECTOR) */ - pFatId->BPB.byAllocUnit = 1024 / SECTOR; /* アロケーションユニット(alloc, =1024/SECTOR) */ - pFatId->BPB.wNumResvSector = 1; /* 予約セクタ数(=1) */ - pFatId->BPB.byNumFat = 1; /* FAT数(=1) */ - pFatId->BPB.wNumDirectory = 128; /* ルートディレクトリエントリ数(dir, =128) */ - pFatId->BPB.byMediaId = RAMDISK_MEDIA_TYPE; /* メディアID(media, =f8) */ - pFatId->BPB_ext.bsSecPerTrack = 1; /* 1バンクあたりのセクタ数(=PAGE_SECTOR) */ - pFatId->BPB_ext.bsHeads = 1; /* ヘッド数(=1) */ - pFatId->BPB_fat32.dwRootCluster = 2; /* ルートディレクトリの開始クラスタ */ - pFatId->BPB_fat32.wFsInfoSector = 1; /* FSINFOのセクタ */ - pFatId->BPB_fat32.wBackupBootSector = 0xffff; /* バックアップブートセクタ */ + pFatId->BPB.wNumSectorByte = SECTOR; /* The number of sector bytes (BPB, =SECTOR) */ + pFatId->BPB.byAllocUnit = 1024 / SECTOR; /* Allocation Unit(alloc, =1024/SECTOR) */ + pFatId->BPB.wNumResvSector = 1; /* The number of reserved sectors (=1) */ + pFatId->BPB.byNumFat = 1; /* The number of FATs (=1) */ + pFatId->BPB.wNumDirectory = 128; /* The number of root directory entries (dir, =128) */ + pFatId->BPB.byMediaId = RAMDISK_MEDIA_TYPE; /* Media ID (media, =f8) */ + pFatId->BPB_ext.bsSecPerTrack = 1; /* Sectors per bank (=PAGE_SECTOR) */ + pFatId->BPB_ext.bsHeads = 1; /* The number of heads (=1) */ + pFatId->BPB_fat32.dwRootCluster = 2; /* The starting cluster of root directory */ + pFatId->BPB_fat32.wFsInfoSector = 1; /* The sector of FSINFO */ + pFatId->BPB_fat32.wBackupBootSector = 0xffff; /* backup boot sector */ KdPrint(("InitFatId end\n")); } -/* EramInitDisk - ERAM初期化 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - pFatId FAT-ID構造体へのポインタ - pRegParam レジストリパス文字列へのポインタ - 戻り値 - 結果 +/* EramInitDisk + ERAM Initialization. + Parameters + pDrvObj The pointer to device representative object. + pFatId The pointer to FAT-ID structure. + pRegParam The pointer to the registry path string. + Return Value + Results. */ NTSTATUS EramInitDisk( @@ -1645,26 +1646,26 @@ NTSTATUS EramInitDisk( IN PUNICODE_STRING pRegParam ) { - /* ローカル変数 */ - UNICODE_STRING NtDevName; /* NTデバイス名 "\Device\Eram" */ - UNICODE_STRING Win32Name; /* Win32名 "\DosDevices\Z:" */ - UNICODE_STRING DrvStr; /* ドライブ文字 */ - WCHAR DrvBuf[3]; /* ドライブ文字取得用バッファ */ + /* local variables */ + UNICODE_STRING NtDevName; /* NT device name "\Device\Eram" */ + UNICODE_STRING Win32Name; /* Win32 name "\DosDevices\Z:" */ + UNICODE_STRING DrvStr; /* Drive character */ + WCHAR DrvBuf[3]; /* The buffer to get the drive character */ PDEVICE_OBJECT pDevObj = NULL; PERAM_EXTENSION pEramExt = NULL; NTSTATUS ntStat; ULONG uMemSize; DEVICE_TYPE dType; KdPrint(("EramInitDisk start\n")); - /* スワップ可能デバイスにするかどうか確認 */ + /* Check whether it is a swappable device */ dType = CheckSwapable(pRegParam); - /* 文字列を初期化 */ + /* Initialize string */ RtlInitUnicodeString(&NtDevName, (PWSTR)NT_DEVNAME); - /* デバイス名を差し替えるかどうか確認 */ + /* Confirm whether to replace the device name */ CheckDeviceName(pRegParam, &NtDevName); - /* デバイス作成 */ + /* device creation */ ntStat = IoCreateDevice(pDrvObj, sizeof(*pEramExt), &NtDevName, dType, 0, FALSE, &pDevObj); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { KdPrint(("IoCreateDevice failed, 0x%x\n", ntStat)); { @@ -1678,104 +1679,104 @@ NTSTATUS EramInitDisk( EramReportEvent(pDrvObj, ERAMNT_ERROR_CREATE_DEVICE_FAILED, NULL); return ntStat; } - /* 情報ポインタ取得 */ + /* Get the info pointer */ pEramExt = (PERAM_EXTENSION)(pDevObj->DeviceExtension); - /* ERAM情報領域初期化 */ + /* ERAM info area initialization */ RtlZeroBytes(pEramExt, sizeof(*pEramExt)); - /* ドライブ文字バッファクリア */ + /* Drive character buffer clear */ DrvBuf[0] = UNICODE_NULL; RtlInitUnicodeString(&DrvStr, DrvBuf); DrvStr.MaximumLength = sizeof(DrvBuf); - /* レジストリから情報取得 */ + /* Get info from registry */ CheckSwitch(pEramExt, pFatId, pRegParam, &DrvStr); pEramExt->uOptflag.Bits.Swapable = (BYTE)((dType == FILE_DEVICE_DISK) ? 1 : 0); - /* デバイス情報初期化 */ + /* 繝繝舌う繧ケ諠蝣ア蛻晄悄蛹 */ pDevObj->Flags |= DO_DIRECT_IO; pDevObj->AlignmentRequirement = FILE_WORD_ALIGNMENT; pEramExt->pDevObj = pDevObj; - if (pEramExt->uOptflag.Bits.External != 0) /* OS管理外メモリ使用 */ + if (pEramExt->uOptflag.Bits.External != 0) /* OS outside memory usage */ { - if (GetExternalStart(pDrvObj, pEramExt) == FALSE) /* OS管理外メモリ無し */ + if (GetExternalStart(pDrvObj, pEramExt) == FALSE) /* without OS outside memory */ { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_MAXMEM_NOT_DETECTED, NULL); return STATUS_INSUFFICIENT_RESOURCES; } - if ((pEramExt->uOptflag.Bits.SkipExternalCheck == 0)&& /* チェック飛ばさない */ - (CheckExternalSize(pDrvObj, pEramExt) == FALSE)) /* チェック失敗 */ + if ((pEramExt->uOptflag.Bits.SkipExternalCheck == 0)&& /* don't skip check */ + (CheckExternalSize(pDrvObj, pEramExt) == FALSE)) /* check failure */ { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "CheckExternalSize"); return STATUS_INSUFFICIENT_RESOURCES; } - /* ミューテックス初期化 */ + /* mutex initialization */ ExInitializeFastMutex(&(pEramExt->FastMutex)); } - /* メモリ確保 */ + /* memory allocation */ uMemSize = pEramExt->uSizeTotal << PAGE_SIZE_LOG2; - if (pEramExt->uSizeTotal < DISKMINPAGE) /* メモリなし */ + if (pEramExt->uSizeTotal < DISKMINPAGE) /* Without memory */ { KdPrint(("Memory size too small, %d\n", pEramExt->uSizeTotal)); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_DISK_SIZE_TOO_SMALL, NULL); ntStat = STATUS_INSUFFICIENT_RESOURCES; goto EramInitDiskExit; } - /* メモリ領域確保 */ + /* memory area allocation */ ntStat = MemSetup(pDrvObj, pEramExt, pFatId, uMemSize); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "MemSetup"); goto EramInitDiskExit; } - /* FATフォーマット */ + /* FAT format */ if (EramFormatFat(pEramExt, pFatId) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "EramFormatFat"); ntStat = STATUS_INSUFFICIENT_RESOURCES; goto EramInitDiskExit; } - /* ERAM情報設定 */ + /* ERAM Info Settings */ pEramExt->bsHiddenSecs = pFatId->BPB_ext.bsHiddenSecs; - /* Win32デバイス名領域確保 */ + /* Win32 device name area allocation */ pEramExt->Win32Name.Buffer = ExAllocatePool(PagedPool, (sizeof(WIN32_PATH) + sizeof(DEFAULT_DRV))); - if (pEramExt->Win32Name.Buffer == NULL) /* 確保失敗 */ + if (pEramExt->Win32Name.Buffer == NULL) /* allocation failed */ { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_DEVICE_NAME_ALLOC_FAILED, NULL); ntStat = STATUS_INSUFFICIENT_RESOURCES; goto EramInitDiskExit; } pEramExt->Win32Name.MaximumLength = sizeof(WIN32_PATH) + sizeof(DEFAULT_DRV); - /* ドライブ文字列不正の場合はZ:にする */ + /* Use Z: when drive string was invalid */ if (DrvStr.Buffer[0] == UNICODE_NULL) { DrvStr.Buffer[0] = L'Z'; } DrvStr.Buffer[1] = L':'; DrvStr.Buffer[2] = UNICODE_NULL; - DrvStr.Length = sizeof(DEFAULT_DRV) - sizeof(WCHAR); /* "Z:"で2文字 */ + DrvStr.Length = sizeof(DEFAULT_DRV) - sizeof(WCHAR); /* two characters of "Z:" */ KdPrint(("Drive %ls\n", DrvStr.Buffer)); - /* Win32デバイス名合成 */ + /* Win32 device name integration */ RtlInitUnicodeString(&Win32Name, (PWSTR)WIN32_PATH); RtlCopyUnicodeString(&(pEramExt->Win32Name), &Win32Name); RtlAppendUnicodeStringToString(&(pEramExt->Win32Name), &DrvStr); - /* リンク作成 */ + /* link creation */ ntStat = IoCreateSymbolicLink(&(pEramExt->Win32Name), &NtDevName); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_CREATE_SYMBOLIC_LINK_FAILED, NULL); - /* Win32名領域解放 */ + /* Win32 name area release */ ExFreePool(pEramExt->Win32Name.Buffer); pEramExt->Win32Name.Buffer = NULL; } -EramInitDiskExit: /* エラー時エントリ */ - if (ntStat != STATUS_SUCCESS) /* 失敗 */ +EramInitDiskExit: /* entry on error */ + if (ntStat != STATUS_SUCCESS) /* failed */ { - if (pEramExt->uOptflag.Bits.External != 0) /* OS管理外メモリ使用 */ + if (pEramExt->uOptflag.Bits.External != 0) /* OS outside memory usage */ { - /* メモリ資源解放 */ + /* Free the memory resource */ ReleaseMemResource(pDrvObj, pEramExt); } - if (pDevObj != NULL) /* デバイス作成済 */ + if (pDevObj != NULL) /* Device already created */ { - /* デバイス削除 */ + /* Delete the device */ EramUnloadDevice(pDrvObj, pDevObj, pEramExt); } } @@ -1784,15 +1785,15 @@ NTSTATUS EramInitDisk( } -/* MemSetup - メモリ領域の確保 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - pEramExt ERAM_EXTENTION構造体へのポインタ - pFatId FAT-ID構造体へのポインタ - uMemSize 要求メモリ量 - 戻り値 - 結果 +/* MemSetup + Memory Area Reservation. + Parameters + pDrvObj The pointer to device representative object. + pEramExt The pointer to an ERAM_EXTENTION structure. + pFatId The pointer to FAT-ID structure. + uMemSize The memory size to request. + Return Value + Results. */ NTSTATUS MemSetup( @@ -1802,7 +1803,7 @@ NTSTATUS MemSetup( IN ULONG uMemSize ) { - /* ローカル変数 */ + /* local variables */ FILE_END_OF_FILE_INFORMATION EofInfo; NTSTATUS ntStat; IO_STATUS_BLOCK IoStat; @@ -1810,9 +1811,9 @@ NTSTATUS MemSetup( UNICODE_STRING uniStr; HANDLE hThread; KdPrint(("MemSetup start\n")); - if (pEramExt->uOptflag.Bits.External != 0) /* OS管理外メモリ */ + if (pEramExt->uOptflag.Bits.External != 0) /* OS outside memory */ { - /* 資源使用を通知 */ + /* Notify resource usage */ if (ExtReport(pDrvObj, pEramExt) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "ExtReport"); @@ -1820,12 +1821,12 @@ NTSTATUS MemSetup( } return STATUS_SUCCESS; } - if (pEramExt->uOptflag.Bits.UseExtFile != 0) /* 外部ファイル使用 */ + if (pEramExt->uOptflag.Bits.UseExtFile != 0) /* External File Usage */ { - /* とりあえずファイル名を用意 */ + /* Firstly prepare filename */ RtlInitUnicodeString(&uniStr, (PWSTR)(pFatId->wszExtFile)); InitializeObjectAttributes(&ObjAttr, &uniStr, OBJ_CASE_INSENSITIVE, NULL, NULL); - /* ファイル開く */ + /* File open */ ntStat = ZwCreateFile(&(pEramExt->hFile), GENERIC_READ | GENERIC_WRITE, &ObjAttr, @@ -1838,58 +1839,58 @@ NTSTATUS MemSetup( NULL, 0 ); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { KdPrint(("ZwCreateFile failed, 0x%x\n", ntStat)); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_CREATE_EXT_FILE, NULL); return ntStat; } - /* ファイルサイズ確保 */ + /* file size allocation */ EofInfo.EndOfFile.QuadPart = (LONGLONG)uMemSize; ntStat = ZwSetInformationFile(pEramExt->hFile, &IoStat, &EofInfo, sizeof(EofInfo), FileEndOfFileInformation); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { KdPrint(("ZwSetInformationFile failed, 0x%x\n", ntStat)); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_SET_INFO_EXT_FILE, NULL); return ntStat; } - /* マッピングオブジェクト作成 */ + /* mapping object creation */ ntStat = ZwCreateSection(&(pEramExt->hSection), SECTION_ALL_ACCESS, NULL, NULL, PAGE_READWRITE, SEC_COMMIT, pEramExt->hFile); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { KdPrint(("ZwCreateSection failed, 0x%x\n", ntStat)); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_CREATE_EXT_FILE_SECTION, NULL); return ntStat; } - /* スピンロック初期化 */ + /* spinlock initialization */ KeInitializeSpinLock(&(pEramExt->IrpSpin)); - /* リスト初期化 */ + /* list initialization */ InitializeListHead(&(pEramExt->IrpList)); - /* セマフォ初期化 */ + /* semaphore initialization */ KeInitializeSemaphore(&(pEramExt->IrpSem), 0, MAXLONG); - /* システムスレッド作成 */ + /* system thread creation */ ntStat = PsCreateSystemThread(&hThread, THREAD_ALL_ACCESS, NULL, NULL, NULL, EramRwThread, pEramExt); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { KdPrint(("PsCreateSystemThread failed\n")); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_CREATE_THREAD, NULL); return ntStat; } - /* スレッドオブジェクト取得 */ + /* Get the thread object */ ntStat = ObReferenceObjectByHandle(hThread, THREAD_ALL_ACCESS, NULL, KernelMode, &(pEramExt->pThreadObject), NULL); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { KdPrint(("ObReferenceObjectByHandle failed\n")); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_GET_THREAD_OBJECT, NULL); return ntStat; } - /* スレッドハンドル解放 */ + /* Release the thread handle */ ZwClose(hThread); - /* シャットダウン通知を有効化 */ + /* Enable shutdown notification */ IoRegisterShutdownNotification(pEramExt->pDevObj); return STATUS_SUCCESS; } - /* OS管理メモリ使用 */ + /* Use OS management memory */ if (OsAlloc(pDrvObj, pEramExt, uMemSize) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "OsAlloc"); @@ -1900,14 +1901,14 @@ NTSTATUS MemSetup( } -/* OsAlloc - OS管理メモリの確保 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - pEramExt ERAM_EXTENTION構造体へのポインタ - uMemSize 要求メモリ量 - 戻り値 - 結果 +/* OsAlloc + OS Management Memory Reservation. + Parameters + pDrvObj The pointer to device representative object. + pEramExt The pointer to an ERAM_EXTENTION structure. + uMemSize The memory size to request. + Return Value + Results. */ BOOLEAN OsAlloc( @@ -1916,11 +1917,11 @@ BOOLEAN OsAlloc( IN ULONG uMemSize ) { - /* ローカル変数 */ + /* local variables */ POOL_TYPE fPool; fPool = (pEramExt->uOptflag.Bits.NonPaged != 0) ? NonPagedPool : PagedPool; pEramExt->pPageBase = ExAllocatePool(fPool, uMemSize); - if (pEramExt->pPageBase == NULL) /* 確保失敗 */ + if (pEramExt->pPageBase == NULL) /* allocation failed */ { KdPrint(("ExAllocatePool failed, %d bytes, nonpaged=%d\n", uMemSize, (UINT)(pEramExt->uOptflag.Bits.NonPaged))); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_DISK_ALLOC_FAILED, NULL); @@ -1931,14 +1932,14 @@ BOOLEAN OsAlloc( } -/* CalcAvailSize - 確保できそうなメモリ量の報告 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - fPool メモリタイプ - uMemSize 要求メモリ量 - 戻り値 - なし +/* CalcAvailSize + Report the Memory Size Likely Reservable. + Parameters + pDrvObj The pointer to device representative object. + fPool The memory type. + uMemSize The memory size to request. + Return Value + No return value. */ VOID CalcAvailSize( @@ -1947,26 +1948,26 @@ VOID CalcAvailSize( IN ULONG uMemSize ) { - /* ローカル変数 */ + /* local variables */ PVOID pBuf; UNICODE_STRING UniStr; WCHAR wcBuf[32]; pBuf = NULL; while ((uMemSize > (DISKMINPAGE << PAGE_SIZE_LOG2))&&(pBuf == NULL)) { - /* メモリ確保 */ + /* memory allocation */ uMemSize -= (DISKMINPAGE << PAGE_SIZE_LOG2); pBuf = ExAllocatePool(fPool, uMemSize); } - if (pBuf == NULL) /* 確保失敗 */ + if (pBuf == NULL) /* allocation failed */ { return; } - /* メモリ解放 */ + /* memory release */ ExFreePool(pBuf); - /* 75%くらいに制限 */ + /* Limit to about 75% */ uMemSize = (uMemSize >> 2) * 3; - /* メモリ量を報告 */ + /* Report the memory amount */ wcBuf[0] = UNICODE_NULL; RtlInitUnicodeString(&UniStr, wcBuf); UniStr.MaximumLength = sizeof(wcBuf); @@ -1977,69 +1978,69 @@ VOID CalcAvailSize( } -/* CheckSwapable - レジストリの参照:スワップ可能デバイスにするかどうかの選択 - 引数 - pRegParam レジストリパス文字列へのポインタ - 戻り値 - デバイスタイプ - レジストリパラメータ - Option オプション +/* CheckSwapable + Registry Reference: Select Whether Swappable Device Or Not + Parameters + pRegParam The pointer to the registry path string. + Return Value + The device type. + Registry Parameter + Option The option(s). */ DEVICE_TYPE CheckSwapable( IN PUNICODE_STRING pRegParam ) { - /* ローカル変数 */ + /* local variables */ RTL_QUERY_REGISTRY_TABLE ParamTable[2]; ULONG Option, defOption = 0; NTSTATUS ntStat; ERAM_OPTFLAG uOptflag; KdPrint(("CheckSwapable start\n")); - /* レジストリ確認領域初期化 */ + /* registry confirmation area initialization */ RtlZeroBytes(&(ParamTable[0]), sizeof(ParamTable)); - /* 一括問い合わせ領域初期化(最後はNULL) */ + /* collective inquiry area initialization (the last one is NULL) */ ParamTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; ParamTable[0].DefaultType = REG_DWORD; ParamTable[0].DefaultLength = sizeof(ULONG); ParamTable[0].Name = (PWSTR)L"Option"; ParamTable[0].EntryContext = &Option; ParamTable[0].DefaultData = &defOption; - /* レジストリ値問い合わせ */ + /* registry values inquiry */ ntStat = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL, pRegParam->Buffer, &(ParamTable[0]), NULL, NULL); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { KdPrint(("Warning:RtlQueryRegistryValues failed\n")); - /* 既定値を採用 */ + /* Adapt the default value */ Option = defOption; } uOptflag.dwOptflag = Option; - if (uOptflag.Bits.Swapable != 0) /* スワップ可能な設定 */ + if (uOptflag.Bits.Swapable != 0) /* Swappable settings */ { KdPrint(("CheckSwapable end, local disk\n")); - /* スワップされないようロックする */ + /* Lock it not to be swapped */ #pragma warning(disable : 4054) MmLockPagableCodeSection((PVOID)EramCreateClose); #pragma warning(default : 4054) - /* ローカルディスク扱いにする:スワップ可能 */ + /* Treat as a local disk: swappable */ return FILE_DEVICE_DISK; } - /* RAMディスク扱いにする */ + /* Treat it as a RAM disk */ KdPrint(("CheckSwapable end, virtual disk\n")); return FILE_DEVICE_VIRTUAL_DISK; } -/* CheckDeviceName - レジストリの参照(デバイス名) - 引数 - pRegParam レジストリパス文字列へのポインタ - pNtDevName NTデバイス名へのポインタ - 戻り値 - なし - レジストリパラメータ - DeviceName デバイス名 +/* CheckDeviceName + Registry Reference (Device Name) + Parameters + pRegParam The pointer to the registry path string. + pNtDevName The pointer to NT device name. + Return Value + No return value. + Registry Parameter + DeviceName The device name */ VOID CheckDeviceName( @@ -2047,33 +2048,33 @@ VOID CheckDeviceName( IN OUT PUNICODE_STRING pNtDevName ) { - /* ローカル変数 */ + /* local variables */ static WCHAR wszDef[] = L""; - static WCHAR wszDev[32] = L""; /* \\Device\\〜 */ + static WCHAR wszDev[32] = L""; /* \\Device\\ス */ RTL_QUERY_REGISTRY_TABLE ParamTable[2]; NTSTATUS ntStat; UNICODE_STRING UniDev; KdPrint(("CheckDeviceName start\n")); - /* 問い合わせ用初期値準備 */ + /* prepare for the initial valus for inquiry */ RtlInitUnicodeString(&UniDev, wszDev); UniDev.MaximumLength = sizeof(wszDev); - /* レジストリ確認領域初期化 */ + /* registry confirmation area initialization */ RtlZeroBytes(&ParamTable, sizeof(ParamTable)); - /* 一括問い合わせ領域初期化(最後はNULL) */ + /* collective inquiry area initialization (the last one is NULL) */ ParamTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; ParamTable[0].Name = (PWSTR)L"DeviceName"; ParamTable[0].EntryContext = &UniDev; ParamTable[0].DefaultType = REG_SZ; ParamTable[0].DefaultData = (LPWSTR)wszDef; ParamTable[0].DefaultLength = sizeof(wszDef); - /* レジストリ値一括問い合わせ */ + /* registry values collective inquiry */ ntStat = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL, pRegParam->Buffer, &(ParamTable[0]), NULL, NULL); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { KdPrint(("Warning:RtlQueryRegistryValues failed, 0x%x\n", ntStat)); return; } - if (UniDev.Length == 0) /* 指定無し */ + if (UniDev.Length == 0) /* No body */ { KdPrint(("No value set\n")); return; @@ -2083,22 +2084,22 @@ VOID CheckDeviceName( } -/* CheckSwitch - レジストリの参照とオプション設定 - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pFatId FAT-ID構造体へのポインタ - pRegParam レジストリパス文字列へのポインタ - pDrvStr ドライブ文字へのポインタ - 戻り値 - なし - レジストリパラメータ - AllocUnit クラスタサイズ - DriveLetter ドライブ指定 - RootDirEntries ルートディレクトリエントリ数 - MediaId メディアID - Option オプション - Page 4KBページ数 +/* CheckSwitch + Registry Reference and Option Settings. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pFatId The pointer to FAT-ID structure. + pRegParam The pointer to the registry path string. + pDrvStr The pointer to the drive character. + Return Value + No return value. + Registry Parameter + AllocUnit The cluster size. + DriveLetter Specify the drive. + RootDirEntries The number of root directory entries. + MediaId The media ID. + Option The option(s). + Page The page number (4KB unit). */ VOID CheckSwitch( @@ -2108,7 +2109,7 @@ VOID CheckSwitch( IN OUT PUNICODE_STRING pDrvStr ) { - /* ローカル変数 */ + /* local variables */ PRTL_QUERY_REGISTRY_TABLE pParamTable; ULONG AllocUnit, defAllocUnit = 1024 / SECTOR; ULONG RootDir, defRootDir = 128; @@ -2124,13 +2125,13 @@ VOID CheckSwitch( bDefault = TRUE; #define REGOPTNUM (8) #define REGOPTSIZE (REGOPTNUM * sizeof(*pParamTable)) - /* 問い合わせ用メモリ確保 */ + /* Allocate the memory for inquiry */ pParamTable = ExAllocatePool(PagedPool, REGOPTSIZE); - if (pParamTable != NULL) /* 成功 */ + if (pParamTable != NULL) /* Success */ { - /* レジストリ確認領域初期化 */ + /* registry confirmation area initialization */ RtlZeroBytes(pParamTable, REGOPTSIZE); - /* 一括問い合わせ領域初期化(最後はNULL) */ + /* collective inquiry area initialization (the last one is NULL) */ for (loopi=0; loopi<(REGOPTNUM-1); loopi++) { pParamTable[loopi].Flags = RTL_QUERY_REGISTRY_DIRECT; @@ -2160,19 +2161,19 @@ VOID CheckSwitch( pParamTable[6].EntryContext = &ExtStart; pParamTable[6].DefaultData = &defExtStart; bDefault = FALSE; - /* レジストリ値一括問い合わせ */ + /* registry values collective inquiry */ ntStat = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL, pRegParam->Buffer, pParamTable, NULL, NULL); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { KdPrint(("Warning:RtlQueryRegistryValues failed\n")); bDefault = TRUE; } - /* 問い合わせ用メモリ解放 */ + /* Release the memory for inquiry */ ExFreePool(pParamTable); } - if (bDefault != FALSE) /* 完全に読めなかった */ + if (bDefault != FALSE) /* Incompletely read */ { - /* 既定値を採用 */ + /* Adapt the default value */ AllocUnit = defAllocUnit; RootDir = defRootDir; MediaId = defMediaId; @@ -2182,7 +2183,7 @@ VOID CheckSwitch( } #undef REGOPTNUM #undef REGOPTSIZE - /* アロケーションユニット検査 */ + /* Allocation unit check */ switch (AllocUnit) { case 1: @@ -2195,35 +2196,35 @@ VOID CheckSwitch( pFatId->BPB.byAllocUnit = (BYTE)AllocUnit; break; } - /* ディレクトリエントリ設定 */ - RootDir = (RootDir + 31) & 0xffe0; /* 32の倍数にする */ + /* Set directory entry */ + RootDir = (RootDir + 31) & 0xffe0; /* Make it a multiple of 32 */ if (RootDir != 0) { pFatId->BPB.wNumDirectory = (WORD)RootDir; } - /* メディアIDセット */ + /* Set media ID */ if (MediaId <= 0xff) { pFatId->BPB.byMediaId = (BYTE)MediaId; } - /* オプション */ - pEramExt->uOptflag.dwOptflag |= Option; /* オプション制御 */ - /* オプション補正 */ - if (pEramExt->uOptflag.Bits.UseExtFile != 0) /* 外部ファイル使用 */ + /* option */ + pEramExt->uOptflag.dwOptflag |= Option; /* option control */ + /* option adjustment */ + if (pEramExt->uOptflag.Bits.UseExtFile != 0) /* External File Usage */ { pEramExt->uOptflag.Bits.NonPaged = 0; pEramExt->uOptflag.Bits.External = 0; } - else if (pEramExt->uOptflag.Bits.External != 0) /* OS管理外メモリ使用 */ + else if (pEramExt->uOptflag.Bits.External != 0) /* OS outside memory usage */ { pEramExt->uOptflag.Bits.NonPaged = 0; pEramExt->uExternalStart = ExtStart; - /* OS管理外メモリ最大アドレスの準備 */ + /* prepare for OS outside memory max address */ GetMaxAddress(pEramExt, pRegParam); } - if ((WORD)NtBuildNumber >= BUILD_NUMBER_NT50) /* Windows2000以降 */ + if ((WORD)NtBuildNumber >= BUILD_NUMBER_NT50) /* Windows2000+ */ { - /* FAT32有効化 */ + /* FAT32 enabled */ pEramExt->uOptflag.Bits.EnableFat32 = 1; } if (Page > LIMIT_4GBPAGES) @@ -2231,44 +2232,44 @@ VOID CheckSwitch( Page = LIMIT_4GBPAGES; KdPrint(("4GB limit over, adjust %d pages\n", Page)); } - /* ページ設定 */ - if (pEramExt->uOptflag.Bits.EnableFat32 == 0) /* FAT32使わない */ + /* Page setting */ + if (pEramExt->uOptflag.Bits.EnableFat32 == 0) /* Without using FAT32 */ { ulPageT = ((ULONGLONG)DISKMAXCLUSTER_16 * SECTOR * pFatId->BPB.byAllocUnit) / PAGE_SIZE_4K ; - if ((ULONGLONG)Page > ulPageT) /* FAT16制限を超えている(若干余裕あり) */ + if ((ULONGLONG)Page > ulPageT) /* beyond FAT16 limit (There is some margin) */ { Page = (ULONG)ulPageT; KdPrint(("FAT16 limit over, adjust %d pages\n", Page)); } } - else /* FAT32使う */ + else /* Use FAT32 */ { ulPageT = ((ULONGLONG)DISKMAXCLUSTER_32 * SECTOR * pFatId->BPB.byAllocUnit) / PAGE_SIZE_4K; - if ((ULONGLONG)Page > ulPageT) /* FAT32制限を超えている */ + if ((ULONGLONG)Page > ulPageT) /* beyond FAT32 limit */ { Page = (ULONG)ulPageT; KdPrint(("FAT32 limit over, adjust %d pages\n", Page)); } } pEramExt->uSizeTotal = Page; - /* ボリュームラベルの準備 */ + /* prepare for volume label */ PrepareVolumeLabel(pEramExt, pFatId, pRegParam); - /* 外部ファイル名の準備 */ + /* Prepare for external filename */ PrepareExtFileName(pEramExt, pFatId, pRegParam); KdPrint(("CheckSwitch end\n")); } -/* GetMaxAddress - レジストリの参照(最大アドレス) - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pRegParam レジストリパス文字列へのポインタ - 戻り値 - なし - レジストリパラメータ - MaxAddress アクセス制限する最大アドレス +/* GetMaxAddress + Registry Reference (Max. Address) + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pRegParam The pointer to the registry path string. + Return Value + No return value. + Registry Parameter + MaxAddress The maximum address to restrict access. */ VOID GetMaxAddress( @@ -2276,26 +2277,26 @@ VOID GetMaxAddress( IN PUNICODE_STRING pRegParam ) { - /* ローカル変数 */ + /* local variables */ RTL_QUERY_REGISTRY_TABLE ParamTable[2]; ULONG uMaxAdr, defMaxAdr = 0xffffffff; NTSTATUS ntStat; KdPrint(("GetMaxAddress start\n")); - /* レジストリ確認領域初期化 */ + /* registry confirmation area initialization */ RtlZeroBytes(&(ParamTable[0]), sizeof(ParamTable)); - /* 一括問い合わせ領域初期化(最後はNULL) */ + /* collective inquiry area initialization (the last one is NULL) */ ParamTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; ParamTable[0].DefaultType = REG_DWORD; ParamTable[0].DefaultLength = sizeof(ULONG); ParamTable[0].Name = (PWSTR)L"MaxAddress"; ParamTable[0].EntryContext = &uMaxAdr; ParamTable[0].DefaultData = &defMaxAdr; - /* レジストリ値問い合わせ */ + /* registry value inquiry */ ntStat = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL, pRegParam->Buffer, &(ParamTable[0]), NULL, NULL); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { KdPrint(("Warning:RtlQueryRegistryValues failed\n")); - /* 既定値を採用 */ + /* Adapt default value */ uMaxAdr = defMaxAdr; } if (pEramExt->uExternalStart > uMaxAdr) @@ -2307,16 +2308,16 @@ VOID GetMaxAddress( } -/* PrepareVolumeLabel - レジストリの参照(ボリュームラベル) - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pFatId FAT-ID構造体へのポインタ - pRegParam レジストリパス文字列へのポインタ - 戻り値 - なし - レジストリパラメータ - VolumeLabel ボリュームラベル +/* PrepareVolumeLabel + Registry Reference (Volume Label) + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pFatId The pointer to FAT-ID structure. + pRegParam The pointer to the registry path string. + Return Value + No return value. + Registry Parameter + VolumeLabel The volume label. */ VOID PrepareVolumeLabel( @@ -2325,36 +2326,36 @@ VOID PrepareVolumeLabel( IN PUNICODE_STRING pRegParam ) { - /* ローカル変数 */ + /* local variables */ static WCHAR wszDef[] = L""; RTL_QUERY_REGISTRY_TABLE ParamTable[2]; NTSTATUS ntStat; UNICODE_STRING UniVol; WCHAR wszVol[12]; KdPrint(("PrepareVolumeLabel start\n")); - /* 問い合わせ用初期値準備 */ + /* prepare for the initial valus for inquiry */ wszVol[0] = UNICODE_NULL; RtlInitUnicodeString(&UniVol, wszVol); UniVol.MaximumLength = sizeof(wszVol); - /* レジストリ確認領域初期化 */ + /* registry confirmation area initialization */ RtlZeroBytes(&ParamTable, sizeof(ParamTable)); - /* 一括問い合わせ領域初期化(最後はNULL) */ + /* collective inquiry area initialization (the last one is NULL) */ ParamTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; ParamTable[0].Name = (PWSTR)L"VolumeLabel"; ParamTable[0].EntryContext = &UniVol; ParamTable[0].DefaultType = REG_SZ; ParamTable[0].DefaultData = (LPWSTR)wszDef; ParamTable[0].DefaultLength = sizeof(wszDef); - /* レジストリ値一括問い合わせ */ + /* registry values collective inquiry */ ntStat = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL, pRegParam->Buffer, &(ParamTable[0]), NULL, NULL); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { KdPrint(("Warning:RtlQueryRegistryValues failed, 0x%x\n", ntStat)); } - /* ボリュームラベル */ + /* Volume label */ RtlFillMemory(pFatId->bsLabel, sizeof(pFatId->bsLabel), ' '); - if ((UniVol.Length == 0)|| /* 指定無し */ - (CheckVolumeLabel(pEramExt, pFatId, &UniVol) == FALSE)) /* 指定文字列無効 */ + if ((UniVol.Length == 0)|| /* No body */ + (CheckVolumeLabel(pEramExt, pFatId, &UniVol) == FALSE)) /* Invalid string specified */ { #pragma warning(disable : 4127) ASSERT((sizeof(pFatId->bsLabel)+1) == sizeof(VOLUME_LABEL_LOCALDISK)); @@ -2366,14 +2367,14 @@ VOID PrepareVolumeLabel( } -/* CheckVolumeLabel - ボリュームラベルの正当性確認と準備 - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pFatId FAT-ID構造体へのポインタ - pUniVol レジストリから読んだボリュームラベル文字列へのポインタ - 戻り値 - 結果 TRUE:準備済み +/* CheckVolumeLabel + Volume Label Validation and Preparation. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pFatId The pointer to FAT-ID structure. + pUniVol The pointer to the volume label string that was read from registry. + Return Value + Results. TRUE: Ready. */ BOOLEAN CheckVolumeLabel( @@ -2382,11 +2383,11 @@ BOOLEAN CheckVolumeLabel( IN PUNICODE_STRING pUniVol ) { - /* ローカル変数 */ + /* local variables */ static CHAR cBadChars[] = "*?/|.,;:+=[]()&^<>\""; ANSI_STRING AnsiVol; DWORD loopi, loopj; - /* 不正文字検索 */ + /* 荳肴ュ」譁蟄玲、懃エ「 */ for (loopi=0; loopi<(pUniVol->Length / sizeof(WCHAR)); loopi++) { if (HIBYTE(pUniVol->Buffer[loopi]) == 0) @@ -2406,19 +2407,19 @@ BOOLEAN CheckVolumeLabel( } } } - /* ANSI文字列化 */ + /* ANSI譁蟄怜怜喧 */ if (RtlUnicodeStringToAnsiString(&AnsiVol, pUniVol, TRUE) != STATUS_SUCCESS) { KdPrint(("RtlUnicodeStringToAnsiString failed\n")); return FALSE; } - if (AnsiVol.Length == 0) /* 実体無し */ + if (AnsiVol.Length == 0) /* without body */ { KdPrint(("Ansi string 0 byte\n")); RtlFreeAnsiString(&AnsiVol); return FALSE; } - /* 準備 */ + /* 貅門y */ RtlCopyBytes(pFatId->bsLabel, AnsiVol.Buffer, (AnsiVol.Length > sizeof(pFatId->bsLabel)) ? sizeof(pFatId->bsLabel) : AnsiVol.Length); RtlFreeAnsiString(&AnsiVol); KdPrint(("CheckVolumeLabel end, Volume label \"%s\"\n", pFatId->bsLabel)); @@ -2426,16 +2427,16 @@ BOOLEAN CheckVolumeLabel( } -/* PrepareExtFileName - レジストリの参照(外部ファイル名) - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pFatId FAT-ID構造体へのポインタ - pRegParam レジストリパス文字列へのポインタ - 戻り値 - なし - レジストリパラメータ - ExtFileName 外部ファイル名 +/* PrepareExtFileName + Registry Reference (External Filename). + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pFatId The pointer to FAT-ID structure. + pRegParam The pointer to the registry path string. + Return Value + No return value. + Registry Parameter + ExtFileName External Filename. */ VOID PrepareExtFileName( @@ -2444,7 +2445,7 @@ VOID PrepareExtFileName( IN PUNICODE_STRING pRegParam ) { - /* ローカル変数 */ + /* local variables */ static WCHAR wszDef[] = L""; static WCHAR wszExtStub[] = L"\\??\\"; static WCHAR wszExtPath[] = ERAMEXTFILEPATH; @@ -2452,31 +2453,31 @@ VOID PrepareExtFileName( NTSTATUS ntStat; UNICODE_STRING UniExtFile; KdPrint(("PrepareExtFileName start\n")); - /* 問い合わせ用初期値準備 */ + /* prepare for the initial valus for inquiry */ pFatId->wszExtFileMain[0] = UNICODE_NULL; RtlInitUnicodeString(&UniExtFile, pFatId->wszExtFileMain); UniExtFile.MaximumLength = sizeof(pFatId->wszExtFileMain); - /* レジストリ確認領域初期化 */ + /* registry confirmation area initialization */ RtlZeroBytes(&ParamTable, sizeof(ParamTable)); - /* 一括問い合わせ領域初期化(最後はNULL) */ + /* collective area initialization (the last one is NULL) */ ParamTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; ParamTable[0].Name = (PWSTR)L"ExtFileName"; ParamTable[0].EntryContext = &UniExtFile; ParamTable[0].DefaultType = REG_SZ; ParamTable[0].DefaultData = (LPWSTR)wszDef; ParamTable[0].DefaultLength = sizeof(wszDef); - /* レジストリ値一括問い合わせ */ + /* registry values collective inquiry */ ntStat = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL, pRegParam->Buffer, &(ParamTable[0]), NULL, NULL); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { KdPrint(("Warning:RtlQueryRegistryValues failed\n")); } - /* 外部ファイル名 */ + /* External File Name */ #pragma warning(disable : 4127) ASSERT(sizeof(pFatId->wszExtFile) == (sizeof(wszExtStub) - sizeof(WCHAR))); #pragma warning(default : 4127) RtlCopyBytes(pFatId->wszExtFile, wszExtStub, sizeof(pFatId->wszExtFile)); - if (UniExtFile.Length == 0) /* 外部ファイル名指定無し */ + if (UniExtFile.Length == 0) /* Without External Filename setting */ { RtlCopyBytes(pFatId->wszExtFileMain, wszExtPath, sizeof(wszExtPath)); } @@ -2484,13 +2485,13 @@ VOID PrepareExtFileName( } -/* EramFormatFat - ERAM初期化 - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pFatId FAT-ID構造体へのポインタ - 戻り値 - 結果 +/* EramFormatFat + ERAM Initialization. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pFatId The pointer to FAT-ID structure. + Return Value + Results. */ BOOLEAN EramFormatFat( @@ -2499,11 +2500,11 @@ BOOLEAN EramFormatFat( ) { KdPrint(("EramFormatFat start\n")); - /* FAT情報セットアップ */ + /* FAT info setup */ EramSetup(pEramExt, pFatId); - /* ルーチンの動的配置 */ + /* dynamic relocation of routine */ EramLocate(pEramExt); - /* ERAMフォーマット */ + /* ERAM Format */ if (EramFormat(pEramExt, pFatId) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "EramFormat"); @@ -2514,13 +2515,13 @@ BOOLEAN EramFormatFat( } -/* EramSetup - ディスク情報セットアップ - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pFatId FAT-ID構造体へのポインタ - 戻り値 - なし +/* EramSetup + Disk Info Setup. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pFatId The pointer to FAT-ID structure. + Return Value + No return value. */ VOID EramSetup( @@ -2528,11 +2529,11 @@ VOID EramSetup( IN PFAT_ID pFatId ) { - /* ローカル変数 */ + /* local variables */ UINT AllocLog2; DWORD eax, esi, edi, ebx, edx, dwFatSectorCount, dwFatEntries; KdPrint(("EramSetup start\n")); - /* log2(アロケーションサイズ)計算 */ + /* log2(allocation size) calculation */ switch (pFatId->BPB.byAllocUnit) { case 2: @@ -2557,79 +2558,79 @@ VOID EramSetup( AllocLog2 = 0; } edi = pEramExt->uSizeTotal << PAGE_SEC_LOG2; - pEramExt->uAllSector = edi; /* 全セクタ数 */ - pFatId->BPB.wNumAllSector = (WORD)edi; /* 全セクタ数 */ - if (edi >= 0x10000) /* over32MB */ + pEramExt->uAllSector = edi; /* The total number of sectors */ + pFatId->BPB.wNumAllSector = (WORD)edi; /* The total number of sectors */ + if (edi >= 0x10000) /* over 32MB */ { pFatId->BPB.wNumAllSector = 0; - pFatId->BPB_ext.bsHugeSectors = edi; /* 全セクタ数 */ - if (pEramExt->uOptflag.Bits.EnableFat32 != 0) /* FAT32有効 */ + pFatId->BPB_ext.bsHugeSectors = edi; /* The total number of sectors */ + if (pEramExt->uOptflag.Bits.EnableFat32 != 0) /* FAT32 enabled */ { - /* BootSectorとFsInfoセクタを除いて予約エントリ2つを加える */ + /* Add the reserved 2 entries excluding boot sectors and FsInfo sectors */ dwFatEntries = ((edi - RESV_SECTOR_FAT32) >> AllocLog2) + 2; - if (dwFatEntries > DISKMAXCLUSTER_16) /* クラスタ数大 */ + if (dwFatEntries > DISKMAXCLUSTER_16) /* The number of clusters is large */ { dwFatSectorCount = (dwFatEntries * 4 + (SECTOR - 1)) / SECTOR; dwFatEntries -= dwFatSectorCount; - if (dwFatEntries > DISKMAXCLUSTER_16) /* クラスタ数大 */ + if (dwFatEntries > DISKMAXCLUSTER_16) /* The number of clusters is large */ { - /* FAT32使用を設定 */ + /* Set FAT32 usage */ pEramExt->FAT_size = PARTITION_FAT32; pFatId->BPB.wNumDirectory = 0; pFatId->BPB_fat32.dwNumFatSector32 = dwFatSectorCount; - pFatId->BPB.wNumResvSector = RESV_SECTOR_FAT32; /* 予約セクタ数(=BootSector+FsInfo) */ + pFatId->BPB.wNumResvSector = RESV_SECTOR_FAT32; /* The number of reserved sectors (=BootSector+FsInfo) */ KdPrint(("EramSetup end(FAT32)\n")); return; } } } } - esi = pFatId->BPB.wNumDirectory; /* ディレクトリエントリ数 */ - esi >>= (SECTOR_LOG2 - 5); /* 1セクタに16個入る…SI=ディレクトリセクタ数 */ - if ((esi == 0)|| /* ディレクトリ指定無し */ - ((edi >> 1) <= esi)) /* ディレクトリ指定が全セクタの半分を上回る */ + esi = pFatId->BPB.wNumDirectory; /* The number of directory entries */ + esi >>= (SECTOR_LOG2 - 5); /* 16 items in 1 sectors ... SI = The number of directory sectors */ + if ((esi == 0)|| /* without specifying directory */ + ((edi >> 1) <= esi)) /* Directory specification exceeds half of all sectors */ { - pFatId->BPB.wNumDirectory = 128; /* 強制的に既定値に変更 */ - esi = pFatId->BPB.wNumDirectory >> (SECTOR_LOG2 - 5); /* 1セクタに16個入る…SI=ディレクトリセクタ数 */ + pFatId->BPB.wNumDirectory = 128; /* Forcibly change to default value */ + esi = pFatId->BPB.wNumDirectory >> (SECTOR_LOG2 - 5); /* 16 items in 1 sector ... SI = The number of directory sectors */ } - edi -= (esi + 1); /* di = 全セクタ数 - ディレクトリセクタ数 - 予約セクタ数 */ - edx = edi; /* 利用可能セクタ数 */ - edi >>= AllocLog2; /* 概算クラスタ数 = di / クラスタ当りのセクタ */ - edi++; /* 概算クラスタ数+1 */ + edi -= (esi + 1); /* di = The total number of sectors - The number of directory sectors - The number of reserved sectors */ + edx = edi; /* The number of sectors available */ + edi >>= AllocLog2; /* The estimated number of clusters = di / sectors per cluster */ + edi++; /* The estimated number of clusters +1 */ pEramExt->FAT_size = PARTITION_FAT_12; - /* AllocLog2 = log2 アロケーション・サイズ - dx = 利用可能セクタ数 - si = ルートディレクトリ用のセクタ数 - di = 概算クラスタ数 + 1 + /* AllocLog2 = log2 allocation size + dx = The number of sectors available + si = The number of sectors for the root directory + di = The estimated number of clusters + 1 */ do { - edi--; /* 概算クラスタ数-1 */ - if (edi > DISKMAXCLUSTER_12) /* 0FF7h以上なら16bit FAT */ + edi--; /* The estimated number of clusters -1 */ + if (edi > DISKMAXCLUSTER_12) /* 16bit FAT if 0FF7h or more */ { pEramExt->FAT_size = PARTITION_FAT_16; eax = edi; - eax <<= 1; /* eax=FATバイト数(2倍) */ + eax <<= 1; /* eax = The number o FAT bytes (twice) */ eax += (SECTOR + 3); - eax >>= SECTOR_LOG2;/* eax=FAT セクタ数 */ + eax >>= SECTOR_LOG2;/* eax = The number of FAT sectors */ pFatId->BPB.wNumFatSector = (WORD)eax; } - else /* 12bit FAT */ + else /* 12bit FAT */ { pEramExt->FAT_size = PARTITION_FAT_12; eax = edi; eax *= 3; - eax >>= 1; /* ax=FATバイト数(1.5倍) */ + eax >>= 1; /* ax = The number of FAT bytes (x 1.5) */ eax += (SECTOR + 2); - eax >>= SECTOR_LOG2; /* ax=FAT セクタ数 */ + eax >>= SECTOR_LOG2; /* ax = The number of FAT sectors */ pFatId->BPB.wNumFatSector = (WORD)eax; } - ebx = edi; /* bx = データ・セクタ数 */ + ebx = edi; /* bx = The number of data sectors */ ebx <<= AllocLog2; - ebx += eax; /* + FAT セクタ数 */ + ebx += eax; /* + The number of FAT sectors */ } while (ebx > edx); - /* 12bit FATでの使用領域の調整 - 0FF5h:FD が16bit FATと誤認 + /* Adjustment of usage area with 12bit FAT. + 0FF5h:FD mistaken as 16bit FAT. */ if ((pEramExt->FAT_size == PARTITION_FAT_12)&& (edi > (DISKMAXCLUSTER_12 - 3))) @@ -2638,10 +2639,10 @@ VOID EramSetup( edi <<= AllocLog2; edi <<= (SECTOR_LOG2 - 5); #pragma warning(disable : 4244) - pFatId->BPB.wNumDirectory += (WORD)edi; /* ルートディレクトリ数で調整 */ + pFatId->BPB.wNumDirectory += (WORD)edi; /* Fix by the number of root directories */ #pragma warning(default : 4244) } - /* 16bit FATでの使用領域の調整 + /* Adjustment of usage area in 16bit FAT 0FFF6h:FAT32 */ if ((pEramExt->FAT_size == PARTITION_FAT_16)&& @@ -2651,11 +2652,11 @@ VOID EramSetup( edi <<= AllocLog2; edi <<= (SECTOR_LOG2 - 5); #pragma warning(disable : 4244) - pFatId->BPB.wNumDirectory += (WORD)edi; /* ルートディレクトリ数で調整 */ + pFatId->BPB.wNumDirectory += (WORD)edi; /* Fix by the number of root directories */ #pragma warning(default : 4244) } - edx -= ebx; /* bx=実使用セクタ数 */ - if (edx != 0) /* 端数セクタはdirにまわす */ + edx -= ebx; /* bx = the number of real usage sectors */ + if (edx != 0) /* Extra sectors will be passed to dir */ { edx <<= (SECTOR_LOG2 - 5); #pragma warning(disable : 4244) @@ -2663,7 +2664,7 @@ VOID EramSetup( #pragma warning(default : 4244) } if ((pEramExt->FAT_size == PARTITION_FAT_16)&& - (pFatId->BPB.wNumAllSector == 0)) /* FAT16 over 32MB */ + (pFatId->BPB.wNumAllSector == 0)) /* FAT16 over 32MB */ { pEramExt->FAT_size = PARTITION_HUGE; } @@ -2671,12 +2672,12 @@ VOID EramSetup( } -/* EramLocate - ルーチンの動的配置 - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - 戻り値 - なし +/* EramLocate + Routine Dynamic Arrangement. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + Return Value + No return value. */ VOID EramLocate( @@ -2684,21 +2685,21 @@ VOID EramLocate( ) { KdPrint(("EramLocate start\n")); - if (pEramExt->uOptflag.Bits.External != 0) /* OS管理外メモリ使用 */ + if (pEramExt->uOptflag.Bits.External != 0) /* Use OS outside memory */ { pEramExt->EramRead = (ERAM_READ)ExtRead1; pEramExt->EramWrite = (ERAM_WRITE)ExtWrite1; pEramExt->EramNext = (ERAM_NEXT)ExtNext1; pEramExt->EramUnmap = (ERAM_UNMAP)ExtUnmap; } - else if (pEramExt->uOptflag.Bits.UseExtFile != 0) /* ファイル使用 */ + else if (pEramExt->uOptflag.Bits.UseExtFile != 0) /* Use file */ { pEramExt->EramRead = (ERAM_READ)ExtFilePendingRw; pEramExt->EramWrite = (ERAM_WRITE)ExtFilePendingRw; pEramExt->EramNext = (ERAM_NEXT)ExtFileNext1; pEramExt->EramUnmap = (ERAM_UNMAP)ExtFileUnmap; } - else /* 通常 */ + else /* normal */ { pEramExt->EramRead = (ERAM_READ)ReadPool; pEramExt->EramWrite = (ERAM_WRITE)WritePool; @@ -2707,13 +2708,13 @@ VOID EramLocate( } -/* EramFormat - フォーマット - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pFatId FAT-ID構造体へのポインタ - 戻り値 - 結果 +/* EramFormat + Formatting. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pFatId The pointer to FAT-ID structure. + Return Value + Results. */ BOOLEAN EramFormat( @@ -2722,19 +2723,19 @@ BOOLEAN EramFormat( ) { KdPrint(("EramFormat start\n")); - /* 管理領域の初期化 */ + /* management area initialization */ if (EramClearInfo(pEramExt, pFatId) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "EramClearInfo"); return FALSE; } - /* FAT初期化 */ + /* FAT initialization */ if (EramMakeFAT(pEramExt, pFatId) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "EramMakeFAT"); return FALSE; } - /* ボリュームラベルをセット */ + /* Set the volume label */ if (EramSetLabel(pEramExt, pFatId) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "EramSetLabel"); @@ -2745,13 +2746,13 @@ BOOLEAN EramFormat( } -/* EramClearInfo - 領域クリア - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pFatId FAT-ID構造体へのポインタ - 戻り値 - 結果 +/* EramClearInfo + Area Clear. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pFatId The pointer to FAT-ID structure. + Return Value + Results. */ BOOLEAN EramClearInfo( @@ -2759,13 +2760,13 @@ BOOLEAN EramClearInfo( IN PFAT_ID pFatId ) { - /* ローカル変数 */ + /* local variables */ ULONG uSize; - /* 管理領域サイズ計算 */ + /* management area size calculation */ uSize = CalcEramInfoPage(pEramExt, pFatId); - if (pEramExt->uOptflag.Bits.External != 0) /* OS管理外メモリ */ + if (pEramExt->uOptflag.Bits.External != 0) /* OS outside memory */ { - /* OS管理外メモリ初期化 */ + /* OS outside memory initialization */ if (ExtClear(pEramExt, uSize) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "ExtClear"); @@ -2773,9 +2774,9 @@ BOOLEAN EramClearInfo( } return TRUE; } - if (pEramExt->uOptflag.Bits.UseExtFile != 0) /* 外部ファイル使用 */ + if (pEramExt->uOptflag.Bits.UseExtFile != 0) /* External File Usage */ { - /* ファイル初期化 */ + /* file initialization */ if (ExtFileClear(pEramExt, uSize) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "ExtFileClear"); @@ -2783,19 +2784,19 @@ BOOLEAN EramClearInfo( } return TRUE; } - /* OS管理メモリ初期化 */ + /* OS management memory initialization */ RtlZeroBytes(pEramExt->pPageBase, uSize); return TRUE; } -/* ExtClear - OS管理外メモリ初期化 - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - uSize 管理情報領域のバイト数 - 戻り値 - 結果 +/* ExtClear + OS Outside Memory Initialization. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + uSize The byte number of management info area. + Return Value + Results. */ BOOLEAN ExtClear( @@ -2803,42 +2804,42 @@ BOOLEAN ExtClear( IN ULONG uSize ) { - /* ローカル変数 */ + /* local variables */ ULONG loopi; KdPrint(("ExtClear start\n")); ASSERT(pEramExt->uExternalStart != 0); ASSERT(pEramExt->uExternalEnd != 0); for (loopi=0; loopiuExternalStart + loopi) >= pEramExt->uExternalEnd) /* 実メモリを超えている */ + if ((pEramExt->uExternalStart + loopi) >= pEramExt->uExternalEnd) /* Beyond real memory */ { KdPrint(("Warning:Address limited\n")); break; } - /* マップ */ + /* map */ if (ExtMap(pEramExt, loopi) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "ExtMap"); return FALSE; } //KdPrint(("loop 0x%x, phys 0x%X\n", loopi, (pEramExt->uExternalStart + loopi))); - /* 0クリア */ + /* zero clear */ RtlZeroBytes(pEramExt->pExtPage, ((uSize - loopi) > EXT_PAGE_SIZE ? EXT_PAGE_SIZE : (uSize - loopi))); } - /* アンマップ */ + /* Unmap */ ExtUnmap(pEramExt); KdPrint(("ExtClear end\n")); return TRUE; } -/* ExtFileClear - ファイル初期化 - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - uSize 管理情報領域のバイト数 - 戻り値 - 結果 +/* ExtFileClear + File Initialization. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + uSize The byte number of management info area. + Return Value + Results. */ BOOLEAN ExtFileClear( @@ -2846,35 +2847,35 @@ BOOLEAN ExtFileClear( IN ULONG uSize ) { - /* ローカル変数 */ + /* local variables */ ULONG loopi; KdPrint(("ExtFileClear start\n")); for (loopi=0; loopipDevObj, ERAMNT_ERROR_FUNCTIONERROR, "ExtFileMap"); return FALSE; } //KdPrint(("loop 0x%x, phys 0x%X\n", loopi, (pEramExt->uExternalStart + loopi))); - /* 0クリア */ + /* zero clear */ RtlZeroBytes(pEramExt->pExtPage, ((uSize - loopi) > EXT_PAGE_SIZE ? EXT_PAGE_SIZE : (uSize - loopi))); } - /* アンマップ */ + /* Unmap */ ExtFileUnmap(pEramExt); KdPrint(("ExtFileClear end\n")); return TRUE; } -/* CalcEramInfoPage - 管理領域サイズ計算 - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pFatId FAT-ID構造体へのポインタ - 戻り値 - 結果 +/* CalcEramInfoPage + Management Area Size Calculation. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pFatId The pointer to FAT-ID structure. + Return Value + Results. */ DWORD CalcEramInfoPage( @@ -2882,29 +2883,29 @@ DWORD CalcEramInfoPage( IN PFAT_ID pFatId ) { - /* ローカル変数 */ + /* local variables */ DWORD dwBytes, dwPage, dwTmp; KdPrint(("CalcEramInfoPage start\n")); - if (pEramExt->FAT_size == PARTITION_FAT32) /* FAT32 */ + if (pEramExt->FAT_size == PARTITION_FAT32) /* FAT32 */ { dwPage = pFatId->BPB_fat32.dwNumFatSector32 + pFatId->BPB.wNumResvSector + pFatId->BPB_fat32.dwRootCluster * (pFatId->BPB.byAllocUnit); } - else /* FAT12/16 */ + else /* FAT12/16 */ { - dwPage = pFatId->BPB.wNumFatSector + pFatId->BPB_fat32.dwNumFatSector32; /* FATセクタ数 */ - dwTmp = pFatId->BPB.wNumDirectory; /* ディレクトリエントリ数 */ - dwTmp >>= (SECTOR_LOG2 - 5); /* ディレクトリセクタ数 */ - dwPage += dwTmp; /* FAT+ディレクトリ */ - dwPage += pFatId->BPB.wNumResvSector; /* 予約セクタ数 */ + dwPage = pFatId->BPB.wNumFatSector + pFatId->BPB_fat32.dwNumFatSector32; /* The number of FAT sectors */ + dwTmp = pFatId->BPB.wNumDirectory; /* The number of directory entries */ + dwTmp >>= (SECTOR_LOG2 - 5); /* The number of directory sectors */ + dwPage += dwTmp; /* FAT + directory */ + dwPage += pFatId->BPB.wNumResvSector; /* The number of reserved sectors */ } - if (pEramExt->uOptflag.Bits.MakeTempDir != 0) /* TEMPディレクトリ作成 */ + if (pEramExt->uOptflag.Bits.MakeTempDir != 0) /* TEMP directory creation */ { - /* 1クラスタ分増やす */ + /* Increment clusters */ dwPage += pFatId->BPB.byAllocUnit; } - dwPage += (PAGE_SECTOR - 1); /* 切り上げ用 */ - dwPage >>= PAGE_SEC_LOG2; /* ページ数 */ - dwBytes = (dwPage << PAGE_SIZE_LOG2); /* 初期化バイト数 */ + dwPage += (PAGE_SECTOR - 1); /* For round-up */ + dwPage >>= PAGE_SEC_LOG2; /* The number of pages */ + dwBytes = (dwPage << PAGE_SIZE_LOG2); /* The number of byte for initialization */ if (dwBytes > (pEramExt->uSizeTotal * PAGE_SIZE_4K)) { dwBytes = pEramExt->uSizeTotal * PAGE_SIZE_4K; @@ -2914,13 +2915,13 @@ DWORD CalcEramInfoPage( } -/* EramMakeFAT - FAT作成 - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pFatId FAT-ID構造体へのポインタ - 戻り値 - 結果 +/* EramMakeFAT + FAT Creation. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pFatId The pointer to FAT-ID structure. + Return Value + Results. */ BOOLEAN EramMakeFAT( @@ -2928,7 +2929,7 @@ BOOLEAN EramMakeFAT( IN PFAT_ID pFatId ) { - /* ローカル変数 */ + /* local variables */ WORD wVal; PBYTE pDisk; PDWORD pdwFatSector; @@ -2938,16 +2939,16 @@ BOOLEAN EramMakeFAT( LARGE_INTEGER SystemTime, LocalTime; DWORD eax, ebx; KdPrint(("EramMakeFAT start\n")); - /* 日付、時刻を取得 */ - KeQuerySystemTime(&SystemTime); /* システム時刻取得 */ - ExSystemTimeToLocalTime(&SystemTime, &LocalTime); /* ローカル時刻に変換 */ - RtlTimeToTimeFields(&LocalTime, &(pFatId->TimeInfo)); /* 構造体に変換 */ - if ((pFatId->TimeInfo.Year < 1980)||(pFatId->TimeInfo.Year > 2079)) /* 年がDOSの範囲を越えた */ + /* Get the date and time */ + KeQuerySystemTime(&SystemTime); /* Get the system time */ + ExSystemTimeToLocalTime(&SystemTime, &LocalTime); /* Convert to local time */ + RtlTimeToTimeFields(&LocalTime, &(pFatId->TimeInfo)); /* Convert to the structure */ + if ((pFatId->TimeInfo.Year < 1980)||(pFatId->TimeInfo.Year > 2079)) /* the year is beyond the limit of DOS */ { - /* 2004年をセット */ + /* Set the year 2004 */ pFatId->TimeInfo.Year = 2004; } - /* ボリュームシリアル番号を準備 */ + /* Prepare for volume serial number */ wVal = pFatId->TimeInfo.Year; pFatId->BPB_ext2.bsVolumeID = (wVal / 1000) << 28; wVal %= 1000; @@ -2960,10 +2961,10 @@ BOOLEAN EramMakeFAT( pFatId->BPB_ext2.bsVolumeID |= ((pFatId->TimeInfo.Day / 10) << 4); pFatId->BPB_ext2.bsVolumeID |= (pFatId->TimeInfo.Day % 10); pDisk = pEramExt->pPageBase; - if ((pEramExt->uOptflag.Bits.External != 0)|| /* OS管理外メモリ使用 */ - (pEramExt->uOptflag.Bits.UseExtFile != 0)) /* 外部ファイル使用 */ + if ((pEramExt->uOptflag.Bits.External != 0)|| /* OS outside memory usage */ + (pEramExt->uOptflag.Bits.UseExtFile != 0)) /* External File Usage */ { - /* ブートセクタ割り当て */ + /* boot sector allocation */ ebx = 0; ASSERT((pEramExt->EramNext) != NULL); if ((*(pEramExt->EramNext))(pEramExt, &eax, &ebx) == FALSE) @@ -2973,7 +2974,7 @@ BOOLEAN EramMakeFAT( } pDisk = (PBYTE)((ULONG)(pEramExt->pExtPage + eax)); } - /* ブートセクタ共通部の書き込み */ + /* Write the boot sector common part */ pBootFat16 = (PBOOTSECTOR_FAT16)pDisk; pBootFat16->bsJump[0] = 0xeb; pBootFat16->bsJump[1] = 0xfe; @@ -2982,75 +2983,75 @@ BOOLEAN EramMakeFAT( RtlCopyBytes(&(pBootFat16->BPB), &(pFatId->BPB), sizeof(pBootFat16->BPB)); RtlCopyBytes(&(pBootFat16->BPB_ext), &(pFatId->BPB_ext), sizeof(pBootFat16->BPB_ext)); RtlCopyBytes(pBootFat16->szMsg, FATID_MSG, sizeof(FATID_MSG)); - if (pEramExt->FAT_size != PARTITION_FAT32) /* FAT12,16 */ + if (pEramExt->FAT_size != PARTITION_FAT32) /* FAT12,16 */ { - /* ブートセクタ(FAT12,16)の書き込み */ + /* Write the boot sector (FAT12, 16) */ RtlCopyBytes(&(pBootFat16->BPB_ext2), &(pFatId->BPB_ext2), sizeof(pBootFat16->BPB_ext2)); } - else /* FAT32 */ + else /* FAT32 */ { - /* ブートセクタ(FAT32)の書き込み */ + /* Write the boot sector (FAT32) */ pBootFat32 = (PBOOTSECTOR_FAT32)pDisk; RtlCopyBytes(&(pBootFat32->BPB_fat32), &(pFatId->BPB_fat32), sizeof(pBootFat32->BPB_fat32)); RtlCopyBytes(&(pBootFat32->BPB_ext2), &(pFatId->BPB_ext2), sizeof(pBootFat32->BPB_ext2)); - /* FSINFOセクタの書き込み */ + /* Write the FSINFO sector */ pFsInfoSector = (PFSINFO_SECTOR)((ULONG)pBootFat32 + pBootFat32->BPB_fat32.wFsInfoSector * SECTOR); - pFsInfoSector->FSInfo_Sig = 0x41615252; /* RRaA */ - pFsInfoSector->FsInfo.bfFSInf_Sig = 0x61417272; /* rrAa */ + pFsInfoSector->FSInfo_Sig = 0x41615252; /* RRaA */ + pFsInfoSector->FsInfo.bfFSInf_Sig = 0x61417272; /* rrAa */ pFsInfoSector->FsInfo.bfFSInf_free_clus_cnt = 0xffffffff; pFsInfoSector->FsInfo.bfFSInf_next_free_clus = 2; pFsInfoSector->bsSig2[0] = 0x55; pFsInfoSector->bsSig2[1] = 0xaa; - if ((pBootFat32->BPB_fat32.wBackupBootSector != 0xffff)&& /* バックアップブートセクタ存在 */ + if ((pBootFat32->BPB_fat32.wBackupBootSector != 0xffff)&& /* Backup boot sector exists */ (pBootFat32->BPB.wNumResvSector > (pBootFat32->BPB_fat32.wBackupBootSector + pBootFat32->BPB_fat32.wFsInfoSector))&& ((pBootFat32->BPB_fat32.wBackupBootSector + pBootFat32->BPB_fat32.wFsInfoSector) < (EXT_PAGE_SIZE / SECTOR))) { - /* ブートセクタをバックアップ */ + /* Do backup the boot sector */ RtlCopyBytes((PBYTE)((ULONG)pBootFat32 + pBootFat32->BPB_fat32.wBackupBootSector * SECTOR), pBootFat32, sizeof(*pBootFat32)); - /* FSINFOセクタをバックアップ */ + /* Do backup the FSINFO sector */ RtlCopyBytes((PBYTE)((ULONG)pFsInfoSector + pBootFat32->BPB_fat32.wBackupBootSector * SECTOR), pFsInfoSector, sizeof(*pFsInfoSector)); } } - /* FATセクタの書き込み */ + /* Write the FAT sector */ pdwFatSector = (PDWORD)((ULONG)pBootFat16 + pBootFat16->BPB.wNumResvSector * SECTOR); pdwFatSector[0] = 0xffffff00 + pFatId->BPB.byMediaId; - if (pEramExt->FAT_size == PARTITION_FAT_12) /* FAT12 */ + if (pEramExt->FAT_size == PARTITION_FAT_12) /* FAT12 */ { - if (pEramExt->uOptflag.Bits.MakeTempDir != 0) /* TEMP作成 */ + if (pEramExt->uOptflag.Bits.MakeTempDir != 0) /* TEMP creation */ { - /* クラスタ2を使用中にする(計36bit) */ + /* Make cluster 2 in use (total 36bits) */ ((PBYTE)pdwFatSector)[4] = 0xf; } else { - /* 24bitに絞る */ + /* Limit to 24bit */ ((PBYTE)pdwFatSector)[3] = 0; } } - else if (pEramExt->FAT_size == PARTITION_FAT32) /* FAT32 */ + else if (pEramExt->FAT_size == PARTITION_FAT32) /* FAT32 */ { pdwFatSector[1] = 0xffffffff; - /* ルートディレクトリも設定 */ + /* Set root directory also */ pdwFatSector[pFatId->BPB_fat32.dwRootCluster] = 0x0fffffff; - if (pEramExt->uOptflag.Bits.MakeTempDir != 0) /* TEMP作成 */ + if (pEramExt->uOptflag.Bits.MakeTempDir != 0) /* TEMP creation */ { - /* ルートディレクトリの次のクラスタを使用中にする(計96bit) */ + /* Make the next cluster of the root directory in use (total 96bits) */ pdwFatSector[pFatId->BPB_fat32.dwRootCluster + 1] = 0x0fffffff; } } - else if (pEramExt->uOptflag.Bits.MakeTempDir != 0) /* FAT16でTEMP作成 */ + else if (pEramExt->uOptflag.Bits.MakeTempDir != 0) /* TEMP creation in FAT16 */ { - /* クラスタ2を使用中にする(計48bit) */ + /* Make cluster 2 in use (total 48bits) */ pdwFatSector[1] = 0xffff; } - if (pEramExt->uOptflag.Bits.External != 0) /* OS管理外メモリ使用 */ + if (pEramExt->uOptflag.Bits.External != 0) /* OS outside memory usage */ { - /* アンマップ */ + /* Unmap */ ExtUnmap(pEramExt); } - else if (pEramExt->uOptflag.Bits.UseExtFile != 0) /* 外部ファイル使用 */ + else if (pEramExt->uOptflag.Bits.UseExtFile != 0) /* External File Usage */ { - /* アンマップ */ + /* Unmap */ ExtFileUnmap(pEramExt); } KdPrint(("EramMakeFAT end\n")); @@ -3058,13 +3059,13 @@ BOOLEAN EramMakeFAT( } -/* EramSetLabel - ボリュームラベルのセット - 引数 - pEramExt ERAM_EXTENTION構造体へのポインタ - pFatId FAT-ID構造体へのポインタ - 戻り値 - 結果 +/* EramSetLabel + Volume Label Setting. + Parameters + pEramExt The pointer to an ERAM_EXTENTION structure. + pFatId The pointer to FAT-ID structure. + Return Value + Results. */ BOOLEAN EramSetLabel( @@ -3072,105 +3073,105 @@ BOOLEAN EramSetLabel( IN PFAT_ID pFatId ) { - /* ローカル変数 */ + /* local variables */ vol_label VOL_L; dir_init DirInit; DWORD eax, dwDirSector, dwTempSector; KdPrint(("EramSetLabel start\n")); - /* 初期化 */ + /* Initialization */ RtlZeroBytes(&VOL_L, sizeof(VOL_L)); RtlZeroBytes(&DirInit, sizeof(DirInit)); - /* ボリュームラベルを準備 */ + /* Prepare for volume label */ RtlCopyBytes(VOL_L.vol.sName, pFatId->bsLabel, sizeof(VOL_L.vol.sName)); KdPrint(("Volume label \"%s\"\n", VOL_L.vol.sName)); - /* 属性を設定 */ + /* Set attributes */ VOL_L.vol.uAttr.Bits.byVol = 1; VOL_L.vol.uAttr.Bits.byA = 1; - /* 日付、時刻を設定 */ - VOL_L.vol.wUpdMinute |= (pFatId->TimeInfo.Second >> 1); /* 秒は1ビット落ちる */ - VOL_L.vol.wUpdMinute |= (pFatId->TimeInfo.Minute << 5); /* 分のセット */ - VOL_L.vol.wUpdMinute |= (pFatId->TimeInfo.Hour << (5+6)); /* 時のセット */ + /* Set date and time */ + VOL_L.vol.wUpdMinute |= (pFatId->TimeInfo.Second >> 1); /* Chop 1 bit from seconds */ + VOL_L.vol.wUpdMinute |= (pFatId->TimeInfo.Minute << 5); /* Set minutes */ + VOL_L.vol.wUpdMinute |= (pFatId->TimeInfo.Hour << (5+6)); /* Set seconds */ VOL_L.vol.wUpdDate |= pFatId->TimeInfo.Day; VOL_L.vol.wUpdDate |= (pFatId->TimeInfo.Month << 5); VOL_L.vol.wUpdDate |= ((pFatId->TimeInfo.Year - 1980) << (5+4)); - /* ディレクトリセクタ位置を取得 */ + /* Get the directory sector position */ dwDirSector = pFatId->BPB.wNumFatSector + pFatId->BPB.wNumResvSector; - if (pEramExt->FAT_size == PARTITION_FAT32) /* FAT32 */ + if (pEramExt->FAT_size == PARTITION_FAT32) /* FAT32 */ { dwDirSector = pFatId->BPB_fat32.dwNumFatSector32 + pFatId->BPB.wNumResvSector + (pFatId->BPB_fat32.dwRootCluster - 2) * (pFatId->BPB.byAllocUnit); } - if (pEramExt->uOptflag.Bits.MakeTempDir != 0) /* TEMPディレクトリ作成 */ + if (pEramExt->uOptflag.Bits.MakeTempDir != 0) /* TEMP directory creation */ { - /* ディレクトリを準備 */ + /* Prepare for directory */ RtlCopyBytes(VOL_L.temp.sName, TEMPDIR_NAME, sizeof(VOL_L.temp.sName)); - /* 属性を設定 */ + /* Set attributes */ VOL_L.temp.uAttr.Bits.byDir = 1; VOL_L.temp.uAttr.Bits.byA = 1; - /* 日付、時刻を設定 */ + /* Set date and time */ VOL_L.temp.wUpdMinute = VOL_L.vol.wUpdMinute; VOL_L.temp.wUpdDate = VOL_L.vol.wUpdDate; - if (pEramExt->FAT_size == PARTITION_FAT32) /* FAT32 */ + if (pEramExt->FAT_size == PARTITION_FAT32) /* FAT32 */ { - /* 先頭クラスタ番号を設定 */ + /* The first sector number setting */ VOL_L.temp.wCluster = (WORD)(pFatId->BPB_fat32.dwRootCluster + 1); - /* 先頭セクタ数を計算 */ + /* The number of first sectors calculation */ dwTempSector = pFatId->BPB_fat32.dwNumFatSector32 + pFatId->BPB.wNumResvSector + (VOL_L.temp.wCluster - 2) * (pFatId->BPB.byAllocUnit); } else { - /* 先頭クラスタ番号を設定 */ + /* The first sector number setting */ VOL_L.temp.wCluster = 2; - /* 先頭セクタ数を計算 */ + /* The number of first sectors calculation */ dwTempSector = dwDirSector + (pFatId->BPB.wNumDirectory >> (SECTOR_LOG2 - 5)); } - /* ディレクトリを準備 */ + /* Prepare for directory */ RtlCopyBytes(DirInit.own.sName, OWNDIR_NAME, sizeof(DirInit.own.sName)); RtlCopyBytes(DirInit.parent.sName, PARENTDIR_NAME, sizeof(DirInit.parent.sName)); - /* 属性を設定 */ + /* Set attributes */ DirInit.own.uAttr.byAttr = VOL_L.temp.uAttr.byAttr; DirInit.parent.uAttr.byAttr = VOL_L.temp.uAttr.byAttr; - /* 日付、時刻を設定 */ + /* Set date and time */ DirInit.own.wUpdMinute = VOL_L.vol.wUpdMinute; DirInit.own.wUpdDate = VOL_L.vol.wUpdDate; DirInit.parent.wUpdMinute = VOL_L.vol.wUpdMinute; DirInit.parent.wUpdDate = VOL_L.vol.wUpdDate; - /* 先頭クラスタ番号を設定 */ + /* The first sector number setting */ DirInit.own.wCluster = VOL_L.temp.wCluster; } - if ((pEramExt->uOptflag.Bits.External != 0)|| /* OS管理外メモリ使用 */ - (pEramExt->uOptflag.Bits.UseExtFile != 0)) /* 外部ファイル使用 */ + if ((pEramExt->uOptflag.Bits.External != 0)|| /* OS outside memory usage */ + (pEramExt->uOptflag.Bits.UseExtFile != 0)) /* External File Usage */ { - /* ディレクトリセクタを割り当て */ + /* allocate directory sector */ ASSERT((pEramExt->EramNext) != NULL); if ((*(pEramExt->EramNext))(pEramExt, &eax, &dwDirSector) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "EramNext"); return FALSE; } - /* ボリュームラベル書き込み */ + /* Write the volume label */ RtlCopyBytes((LPBYTE)((ULONG)(pEramExt->pExtPage) + eax), &VOL_L, sizeof(VOL_L)); - if (pEramExt->uOptflag.Bits.MakeTempDir != 0) /* TEMPディレクトリ作成 */ + if (pEramExt->uOptflag.Bits.MakeTempDir != 0) /* TEMP directory creation */ { - /* TEMPディレクトリセクタを割り当て */ + /* Allocate the TEMP directory sector */ if ((*(pEramExt->EramNext))(pEramExt, &eax, &dwTempSector) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "EramNext"); return FALSE; } - /* ディレクトリ書き込み */ + /* Write directory */ RtlCopyBytes((LPBYTE)((ULONG)(pEramExt->pExtPage) + eax), &DirInit, sizeof(DirInit)); } - /* アンマップ */ + /* Unmap */ ASSERT((pEramExt->EramUnmap) != NULL); (*(pEramExt->EramUnmap))(pEramExt); } else { - /* ディレクトリセクタにボリュームラベル書き込み */ + /* Write the volume label to the directory sector */ RtlCopyBytes((LPBYTE)((ULONG)(pEramExt->pPageBase) + (dwDirSector << SECTOR_LOG2)), &VOL_L, sizeof(VOL_L)); - if (pEramExt->uOptflag.Bits.MakeTempDir != 0) /* TEMPディレクトリ作成 */ + if (pEramExt->uOptflag.Bits.MakeTempDir != 0) /* TEMP directory creation */ { - /* TEMPディレクトリセクタにディレクトリ書き込み */ + /* Write the directory to TEMP directory sector */ RtlCopyBytes((LPBYTE)((ULONG)(pEramExt->pPageBase) + (dwTempSector << SECTOR_LOG2)), &DirInit, sizeof(DirInit)); } } @@ -3179,13 +3180,13 @@ BOOLEAN EramSetLabel( } -/* GetExternalStart - OS管理外メモリ開始位置検出 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - pEramExt ERAM_EXTENTION構造体へのポインタ - 戻り値 - 結果 TRUE:OS管理外メモリあり +/* GetExternalStart + OS Outside Memory Starting Position Detection. + Parameters + pDrvObj The pointer to device representative object. + pEramExt The pointer to an ERAM_EXTENTION structure. + Return Value + Results. TRUE: With OS outside memory. */ BOOLEAN GetExternalStart( @@ -3193,7 +3194,7 @@ BOOLEAN GetExternalStart( IN PERAM_EXTENSION pEramExt ) { - /* ローカル変数 */ + /* local variables */ RTL_QUERY_REGISTRY_TABLE ParamTable[2]; NTSTATUS ntStat; UNICODE_STRING uniOption, uniOptionUp; @@ -3206,49 +3207,49 @@ BOOLEAN GetExternalStart( KdPrint(("GetExternalStart start\n")); uSize = 512 * sizeof(WCHAR); pBuf = ExAllocatePool(PagedPool, uSize); - if (pBuf == NULL) /* 確保失敗 */ + if (pBuf == NULL) /* allocation failed */ { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_OPTION_WORK_ALLOC_FAILED, NULL); return FALSE; } - /* 情報取得領域準備 */ + /* prepare for info area */ RtlInitUnicodeString(&uniOption, UNICODE_NULL); uniOption.Buffer = pBuf; uniOption.MaximumLength = (USHORT)uSize; - /* レジストリ確認領域初期化 */ + /* registry confirmation area initialization */ RtlZeroBytes(&(ParamTable[0]), sizeof(ParamTable)); ParamTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; ParamTable[0].Name = (PWSTR)L"SystemStartOptions"; ParamTable[0].EntryContext = &uniOption; - /* レジストリ値一括問い合わせ */ + /* registry values collective inquiry */ ntStat = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, NULL, &(ParamTable[0]), NULL, NULL); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_OPTION_GET_FAILED, NULL); - /* メモリ解放 */ + /* memory release */ ExFreePool(pBuf); return FALSE; } - if (uniOption.Length == 0) /* オプション無し */ + if (uniOption.Length == 0) /* Without option */ { KdPrint(("No startup option\n")); - /* メモリ解放 */ + /* memory release */ ExFreePool(pBuf); return FALSE; } - /* 物理アドレスから/PAE判断 */ + /* / PAE judgment from physical address */ uNoLowMem = 0; phys = MmGetPhysicalAddress(pBuf); - if (phys.HighPart != 0) /* over4GB */ + if (phys.HighPart != 0) /* over4GB */ { - /* 少なくとも/PAEは存在しているので、/NOLOWMEMを探す */ + /* At least /PAE does exist, so do search /NOLOWMEM */ uNoLowMem = sizeof(szwNoLowMem) - sizeof(WCHAR); } uMaxMem = sizeof(szwMaxMem) - sizeof(WCHAR); - if (max(uMaxMem, uNoLowMem) >= uniOption.Length) /* オプションにMAXMEM/NOLOWMEMは含まれない */ + if (max(uMaxMem, uNoLowMem) >= uniOption.Length) /* MAXMEM / NOLOWMEM not included in option */ { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_MAXMEM_NO_OPTION, NULL); - /* メモリ解放 */ + /* memory release */ ExFreePool(pBuf); return FALSE; } @@ -3257,15 +3258,15 @@ BOOLEAN GetExternalStart( uNoLowMem = MAXDWORD; } KdPrint(("Startup option exist\n")); - /* 大文字変換(NT4では既にされているようだ) */ + /* Capitalize (already done at NT4) */ if (RtlUpcaseUnicodeString(&uniOptionUp , &uniOption, TRUE) != STATUS_SUCCESS) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_MAXMEM_CAPITAL_FAILED, NULL); - /* メモリ解放 */ + /* memory release */ ExFreePool(pBuf); return FALSE; } - /* メモリ解放 */ + /* memory release */ ExFreePool(pBuf); KdPrint(("Start Parse\n")); pwStr = uniOptionUp.Buffer; @@ -3276,11 +3277,11 @@ BOOLEAN GetExternalStart( for (loopi=0; loopi<(uniOptionUp.Length /sizeof(WCHAR)); loopi++, pwStr++, uRemain-=sizeof(WCHAR)) { if ((uMaxMem < uRemain)&& - (RtlCompareMemory(pwStr, szwMaxMem, uMaxMem) == uMaxMem)) /* 一致 */ + (RtlCompareMemory(pwStr, szwMaxMem, uMaxMem) == uMaxMem)) /* matched */ { KdPrint(("Match, MAXMEM\n")); pwStr += (uMaxMem / sizeof(WCHAR)); - /* MAXMEM=nのnを取得 */ + /* Get n of MAXMEM=n */ if (GetMaxMem(pDrvObj, pEramExt, pwStr, &uStart) == FALSE) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "GetMaxMem"); @@ -3291,7 +3292,7 @@ BOOLEAN GetExternalStart( } } if ((uNoLowMem < uRemain)&& - (RtlCompareMemory(pwStr, szwNoLowMem, uNoLowMem) == uNoLowMem)) /* 一致 */ + (RtlCompareMemory(pwStr, szwNoLowMem, uNoLowMem) == uNoLowMem)) /* matched */ { KdPrint(("Match, NOLOWMEM\n")); bNoLowMem = TRUE; @@ -3299,12 +3300,12 @@ BOOLEAN GetExternalStart( } } KdPrint(("loop end\n")); - if (bNoLowMem != FALSE) /* /NOLOWMEM */ + if (bNoLowMem != FALSE) /* /NOLOWMEM */ { - /* 17MBあたりから使ってみる */ + /* Try around 17MB */ uStart = 17; } - if (uStart != 0) /* MAXMEM=nまたはNOLOWMEMあり */ + if (uStart != 0) /* with MAXMEM=n or NOLOWMEM */ { bStat = CheckMaxMem(pDrvObj, pEramExt, uStart); if (bStat == FALSE) @@ -3312,7 +3313,7 @@ BOOLEAN GetExternalStart( EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "CheckMaxMem"); } } - /* メモリ解放 */ + /* memory release */ RtlFreeUnicodeString(&uniOptionUp); if (bStat == FALSE) { @@ -3323,15 +3324,15 @@ BOOLEAN GetExternalStart( } -/* GetMaxMem - MAXMEM=nオプション解析 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - pEramExt ERAM_EXTENTION構造体へのポインタ - pwStr MAXMEM=nのnの文字列へのポインタ - puSize nを格納する領域へのポインタ - 戻り値 - 結果 +/* GetMaxMem + MAXMEM=n Option Analysis. + Parameters + pDrvObj The pointer to device representative object. + pEramExt The pointer to an ERAM_EXTENTION structure. + pwStr The pointer to the string of n of MAXMEM=n. + puSize The pointer to the area to store n. + Return Value + Results. */ BOOLEAN GetMaxMem( @@ -3341,7 +3342,7 @@ BOOLEAN GetMaxMem( OUT PULONG puSize ) { - /* ローカル変数 */ + /* local variables */ UNICODE_STRING uniOptionMem; PWSTR pwStrSp; pwStrSp = pwStr; @@ -3351,7 +3352,7 @@ BOOLEAN GetMaxMem( } *pwStrSp = L'\0'; RtlInitUnicodeString(&uniOptionMem, pwStr); - /* 数値化 */ + /* Numerization */ if (RtlUnicodeStringToInteger(&uniOptionMem, 0, puSize) != STATUS_SUCCESS) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_MAXMEM_ATOU, NULL); @@ -3361,14 +3362,14 @@ BOOLEAN GetMaxMem( } -/* CheckMaxMem - MAXMEM=nオプション解析 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - pEramExt ERAM_EXTENTION構造体へのポインタ - uSize MAXMEM=nのn - 戻り値 - 結果 TRUE:OS管理外メモリあり +/* CheckMaxMem + MAXMEM=n Option Analysis. + Parameters + pDrvObj The pointer to device representative object. + pEramExt The pointer to an ERAM_EXTENTION structure. + uSize n of MAXMEM=n. + Return Value + Results. TRUE: With OS outside memory. */ BOOLEAN CheckMaxMem( @@ -3377,48 +3378,48 @@ BOOLEAN CheckMaxMem( IN ULONG uSize ) { - if (uSize <= 16) /* 小さすぎ */ + if (uSize <= 16) /* too small */ { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_MAXMEM_TOO_SMALL, NULL); return FALSE; } - if (uSize >= 4095) /* 大きすぎ */ + if (uSize >= 4095) /* too large */ { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_MAXMEM_TOO_BIG, NULL); return FALSE; } - /* MB単位補正 */ + /* Fix into MB units */ pEramExt->uExternalStart /= SIZE_MEGABYTE; if (pEramExt->uExternalStart >= 4095) { EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_EXTSTART_TOO_BIG, NULL); return FALSE; } - if (pEramExt->uExternalStart >= uSize) /* 後ろ側に補正必要 */ + if (pEramExt->uExternalStart >= uSize) /* backward fix required */ { - /* 後ろ側に補正 */ + /* backward fix */ KdPrint(("System %dMB\n", uSize)); uSize = pEramExt->uExternalStart; } pEramExt->uExternalStart = uSize * SIZE_MEGABYTE; KdPrint(("System %dMB, External start 0x%x\n", uSize, pEramExt->uExternalStart)); uSize = pEramExt->uExternalStart / PAGE_SIZE_4K; - if ((uSize + pEramExt->uSizeTotal) > (4096 * (SIZE_MEGABYTE / PAGE_SIZE_4K))) /* over4GB */ + if ((uSize + pEramExt->uSizeTotal) > (4096 * (SIZE_MEGABYTE / PAGE_SIZE_4K))) /* over4GB */ { - /* 4GBに収める(末尾1MBは除外…) */ + /* Fit in 4GB (the tail 1MB will be excluded) */ pEramExt->uSizeTotal = (4096 * (SIZE_MEGABYTE / PAGE_SIZE_4K)) - uSize; } return TRUE; } -/* CheckExternalSize - OS管理外メモリ開始位置検出 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - pEramExt ERAM_EXTENTION構造体へのポインタ - 戻り値 - 結果 TRUE:OS管理外メモリあり +/* CheckExternalSize + OS Outside Memory Starting Position Detection. + Parameters + pDrvObj The pointer to device representative object. + pEramExt The pointer to an ERAM_EXTENTION structure. + Return Value + Results. TRUE: With OS outside memory. */ BOOLEAN CheckExternalSize( @@ -3426,54 +3427,54 @@ BOOLEAN CheckExternalSize( IN PERAM_EXTENSION pEramExt ) { - /* ローカル変数 */ - CM_RESOURCE_LIST ResList; /* リソースリスト */ + /* local variables */ + CM_RESOURCE_LIST ResList; /* Resource list */ ULONG uSize, uRealSize; BOOLEAN bResConf, bStat; NTSTATUS ntStat; DWORD dwMaxAddr; ULARGE_INTEGER ulMix; KdPrint(("CheckExternalSize start\n")); - /* 確保すべきバイト数を計算 */ + /* Calculate the byte number to be reserved */ uSize = pEramExt->uSizeTotal * PAGE_SIZE_4K; - if (uSize == 0) /* 不正 */ + if (uSize == 0) /* invalid */ { KdPrint(("Total is 0\n")); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_DISK_SIZE_IS_0, NULL); return FALSE; } ulMix.QuadPart = (ULONGLONG)(pEramExt->uExternalStart) + (ULONGLONG)uSize; - if (ulMix.HighPart != 0) /* over4GB */ + if (ulMix.HighPart != 0) /* over4GB */ { uSize = (DWORD)(0 - (pEramExt->uExternalStart)); pEramExt->uSizeTotal = uSize / PAGE_SIZE_4K; KdPrint(("Wrap 4GB, limit size 0x%x (%dpages)\n", uSize, pEramExt->uSizeTotal)); } - /* ACPI予約メモリ推測 */ + /* ACPI reserved memory guessing */ dwMaxAddr = GetAcpiReservedMemory(pDrvObj); KdPrint(("ACPI max 0x%x\n", dwMaxAddr)); - if (pEramExt->uExternalStart >= dwMaxAddr) /* 開始位置がACPIメモリより後 */ + if (pEramExt->uExternalStart >= dwMaxAddr) /* The starting position is after ACPI memory */ { KdPrint(("Invalid start address\n")); EramReportEvent(pDrvObj, ERAMNT_ERROR_MAXMEM_NO_MEMORY, NULL); return FALSE; } - if (ulMix.LowPart > dwMaxAddr) /* ACPIと重なる */ + if (ulMix.LowPart > dwMaxAddr) /* It overlaps ACPI */ { - /* ACPIの前までに制限 */ + /* Restricted upto ACPI */ uSize -= (ulMix.LowPart - dwMaxAddr); pEramExt->uSizeTotal = uSize / PAGE_SIZE_4K; ulMix.LowPart = dwMaxAddr; KdPrint(("Wrap ACPI, limit size 0x%x (%dpages)\n", uSize, pEramExt->uSizeTotal)); } - /* リソース要求設定 */ + /* Resource Request Settings */ ResourceInitTiny(pDrvObj, &ResList, pEramExt->uExternalStart, uSize); bResConf = FALSE; - /* 資源が使用可能かどうか調べる */ + /* Check if resources are available */ if (pEramExt->uOptflag.Bits.SkipReportUsage == 0) { ntStat = IoReportResourceUsage(NULL, pDrvObj, &ResList, sizeof(ResList), NULL, NULL, 0, TRUE, &bResConf); - if (ntStat != STATUS_SUCCESS) /* 失敗 */ + if (ntStat != STATUS_SUCCESS) /* failed */ { KdPrint(("IoReportResourceUsage failed, %x\n", ntStat)); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_MAXMEM_REPORT_USAGE_FAILED, NULL); @@ -3481,7 +3482,7 @@ BOOLEAN CheckExternalSize( } } bStat = FALSE; - if (bResConf != FALSE) /* 競合あり */ + if (bResConf != FALSE) /* conflicted */ { KdPrint(("Conflict\n")); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_MAXMEM_REPORT_USAGE_CONFLICT, NULL); @@ -3496,9 +3497,9 @@ BOOLEAN CheckExternalSize( else { KdPrint(("extend memory 0x%08X - 0x%08X (0x%X bytes)\n", pEramExt->uExternalStart, (pEramExt->uExternalStart)+uRealSize-1, uRealSize)); - if (uSize > uRealSize) /* メモリ不足 */ + if (uSize > uRealSize) /* out of memory */ { - /* 実メモリの範囲にとどめる */ + /* Stay within the range of real memory */ pEramExt->uSizeTotal = uRealSize / PAGE_SIZE_4K; KdPrint(("size compress\n")); EramReportEvent(pEramExt->pDevObj, ERAMNT_WARN_MAXMEM_DISK_SIZE_FIXED, NULL); @@ -3506,7 +3507,7 @@ BOOLEAN CheckExternalSize( bStat = TRUE; } } - /* ドライバ資源解放 */ + /* driver resource release */ if (pEramExt->uOptflag.Bits.SkipReportUsage == 0) { RtlZeroBytes(&ResList, sizeof(ResList)); @@ -3517,15 +3518,15 @@ BOOLEAN CheckExternalSize( } -/* ResourceInitTiny - リソースマップ初期化 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - pResList リソース構造体へのポインタ - uStart OS管理外メモリ開始位置 - uSize ディスクに回す容量 - 戻り値 - なし +/* ResourceInitTiny + Resource Map Initialization. + Parameters + pDrvObj The pointer to device representative object. + pResList The pointer to the resource structure. + uStart OS outside memory starting position. + uSize The size to handed over to the disk. + Return Value + No return value. */ VOID ResourceInitTiny( @@ -3535,19 +3536,19 @@ VOID ResourceInitTiny( IN ULONG uSize ) { - /* ローカル変数 */ + /* local variables */ PCM_PARTIAL_RESOURCE_DESCRIPTOR pDesc; PHYSICAL_ADDRESS PortAdr; KdPrint(("ResourceInitTiny start\n")); PortAdr.HighPart = 0; - /* ヘッダ部設定 */ - pResList->Count = 1; /* Internalのみ */ + /* header settings */ + pResList->Count = 1; /* Internal Only */ pResList->List[0].InterfaceType = Internal; pResList->List[0].BusNumber = 0; - pResList->List[0].PartialResourceList.Count = 1; /* メモリ */ - /* ディスクリプタ先頭へのポインタを取得 */ + pResList->List[0].PartialResourceList.Count = 1; /* memory */ + /* Get the pointer to the top descriptor */ pDesc = &(pResList->List[0].PartialResourceList.PartialDescriptors[0]); - /* 内部メモリ要求のための設定 */ + /* Settingss for inner memory request */ pDesc->Type = CmResourceTypeMemory; pDesc->ShareDisposition = CmResourceShareDriverExclusive; pDesc->Flags = CM_RESOURCE_MEMORY_READ_WRITE; @@ -3558,16 +3559,16 @@ VOID ResourceInitTiny( } -/* CheckExternalMemoryExist - メモリ検査本体 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - uStart OS管理外メモリ開始位置 - uDiskSize ディスクに回す容量 - puSize メモリ容量 - dwMaxAddr ACPI使用メモリの最下位アドレス - 戻り値 - 結果 +/* CheckExternalMemoryExist + Memory Test Main Body. + Parameters + pDrvObj The pointer to device representative object. + uStart OS outside memory starting position. + uDiskSize The size to handed over to the disk. + puSize The memory capacity. + dwMaxAddr The lowest address of ACPI usage memory. + Return Value + Results. */ BOOLEAN CheckExternalMemoryExist( @@ -3578,14 +3579,14 @@ BOOLEAN CheckExternalMemoryExist( IN ULONG dwMaxAddr ) { - /* ローカル変数 */ + /* local variables */ ULONG loopi, loopj; BOOLEAN bExist; PHYSICAL_ADDRESS MapAdr; volatile PBYTE pBase; static BYTE byTests[] = { 0, 0x55, 0xaa, 0 }; KdPrint(("CheckExternalMemoryExist start\n")); - /* 資源使用設定 */ + /* resource usage settings */ if (ResourceSetupTiny(pDrvObj, uStart, &MapAdr) == FALSE) { KdPrint(("ResourceSetupTiny failed\n")); @@ -3596,41 +3597,41 @@ BOOLEAN CheckExternalMemoryExist( *puSize = 0; for (loopi=0; loopi= dwMaxAddr) /* 1MBは空き無い */ + if ((uStart + loopi + SIZE_MEGABYTE) >= dwMaxAddr) /* No 1MB space */ { KdPrint(("ACPI memory detected, adjusted\n")); *puSize += (dwMaxAddr - (uStart + loopi)); break; } - /* 次の1MBに進める */ + /* Next 1MB */ *puSize += SIZE_MEGABYTE; MapAdr.LowPart += SIZE_MEGABYTE; } - if (*puSize == 0) /* 検出できず */ + if (*puSize == 0) /* Not detected */ { KdPrint(("extend memory 0 bytes\n")); EramReportEvent(pDrvObj, ERAMNT_ERROR_MAXMEM_NO_MEMORY, NULL); @@ -3641,14 +3642,14 @@ BOOLEAN CheckExternalMemoryExist( } -/* ResourceSetupTiny - I/Oリソース初期設定 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - uStart OS管理外メモリ開始位置 - pMapAdr 変換アドレスへのポインタ - 戻り値 - 結果 +/* ResourceSetupTiny + I/O Resource Initial Setting + Parameters + pDrvObj The pointer to device representative object. + uStart OS outside memory starting position. + pMapAdr The pointer to the conversion address. + Return Value + Results. */ BOOLEAN ResourceSetupTiny( @@ -3657,22 +3658,22 @@ BOOLEAN ResourceSetupTiny( OUT PPHYSICAL_ADDRESS pMapAdr ) { - /* ローカル変数 */ + /* local variables */ PHYSICAL_ADDRESS PortAdr; ULONG MemType; KdPrint(("ResourceSetupTiny start\n")); PortAdr.HighPart = 0; - /* 内部メモリ設定 */ - MemType = 0; /* メモリ空間 */ + /* Internal memory settings */ + MemType = 0; /* Memory space */ PortAdr.LowPart = uStart; - /* 一応Translateしているが結果は同じ模様 */ + /* It has translated at least, but, the results were likely same */ if (HalTranslateBusAddress(Internal, 0, PortAdr, &MemType, pMapAdr) == FALSE) { KdPrint(("Memory 0x%x, HalTranslateBusAddress failed\n", PortAdr.LowPart)); EramReportEvent(pDrvObj, ERAMNT_ERROR_TRANSLATE_ADDRESS_FAILED, NULL); return FALSE; } - if (MemType != 0) /* マップ */ + if (MemType != 0) /* map */ { KdPrint(("!Map type\n")); EramReportEvent(pDrvObj, ERAMNT_ERROR_PORT_MAPPED, NULL); @@ -3683,13 +3684,13 @@ BOOLEAN ResourceSetupTiny( } -/* ExtReport - OS管理外メモリ開始位置検出 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - pEramExt ERAM_EXTENTION構造体へのポインタ - 戻り値 - 結果 +/* ExtReport + OS Outside Memory Starting Position Detection. + Parameters + pDrvObj The pointer to device representative object. + pEramExt The pointer to an ERAM_EXTENTION structure. + Return Value + Results. */ BOOLEAN ExtReport( @@ -3697,46 +3698,46 @@ BOOLEAN ExtReport( IN PERAM_EXTENSION pEramExt ) { - /* ローカル変数 */ - CM_RESOURCE_LIST ResList; /* リソースリスト */ + /* local variables */ + CM_RESOURCE_LIST ResList; /* Resource list */ ULONG uSize; BOOLEAN bResConf; NTSTATUS ntStat; KdPrint(("ExtReport start\n")); - /* 確保すべきバイト数を計算 */ + /* Calculate the byte number to be reserved */ uSize = pEramExt->uSizeTotal * PAGE_SIZE_4K; - if (uSize == 0) /* 不正 */ + if (uSize == 0) /* invalid */ { KdPrint(("Total is 0\n")); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_DISK_SIZE_IS_0, NULL); return FALSE; } - /* リソース要求設定 */ + /* Resource Request Settings */ ResourceInitTiny(pDrvObj, &ResList, pEramExt->uExternalStart, uSize); - /* 資源使用を通知 */ + /* Notify resource usage */ if (pEramExt->uOptflag.Bits.SkipReportUsage == 0) { ntStat = IoReportResourceUsage(NULL, pDrvObj, &ResList, sizeof(ResList), NULL, NULL, 0, FALSE, &bResConf); if ((ntStat == STATUS_SUCCESS)&& - (bResConf != FALSE)) /* 競合発生 */ + (bResConf != FALSE)) /* conflict happens */ { KdPrint(("Conflict\n")); - /* エラーを設定 */ + /* Set error */ ntStat = STATUS_DEVICE_CONFIGURATION_ERROR; } - if (ntStat != STATUS_SUCCESS) /* 使用不可 */ + if (ntStat != STATUS_SUCCESS) /* unusable */ { KdPrint(("IoReportResourceUsage failed, %x\n", ntStat)); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_MAXMEM_REPORT_USAGE_FAILED, NULL); return FALSE; } } - /* 資源使用設定 */ + /* resource usage settings */ if (ResourceSetupTiny(pDrvObj, pEramExt->uExternalStart, &(pEramExt->MapAdr)) == FALSE) { KdPrint(("ResourceSetupTiny failed\n")); EramReportEvent(pEramExt->pDevObj, ERAMNT_ERROR_FUNCTIONERROR, "ResourceSetupTiny"); - /* ドライバ資源解放 */ + /* driver resource release */ if (pEramExt->uOptflag.Bits.SkipReportUsage == 0) { RtlZeroBytes(&ResList, sizeof(ResList)); @@ -3749,19 +3750,19 @@ BOOLEAN ExtReport( } -/* GetAcpiReservedMemory - ACPI予約メモリ検査 - 引数 - pDrvObj 装置の代表オブジェクトへのポインタ - 戻り値 - ACPI使用メモリの最下位アドレス +/* GetAcpiReservedMemory + ACPI Reserved Memory Test. + Parameters + pDrvObj The pointer to device representative object. + Return Value + The lowest address of ACPI usage memory. */ DWORD GetAcpiReservedMemory( IN PDRIVER_OBJECT pDrvObj ) { - /* ローカル変数 */ + /* local variables */ ULONG loopi; PHYSICAL_ADDRESS MapAdr; PBYTE pBase; @@ -3769,16 +3770,16 @@ DWORD GetAcpiReservedMemory( DWORD dwMaxAdr; KdPrint(("GetAcpiReservedMemory start\n")); dwMaxAdr = 0xffff0000; - /* 資源使用設定 */ + /* resource usage settings */ if (ResourceSetupTiny(pDrvObj, BIOS_ADDRESS_START, &MapAdr) == FALSE) { KdPrint(("ResourceSetupTiny failed\n")); EramReportEvent(pDrvObj, ERAMNT_ERROR_FUNCTIONERROR, "ResourceSetupTiny"); return dwMaxAdr; } - /* マップ(キャッシュ許可) */ + /* map (allow cache) */ pBase = (PBYTE)MmMapIoSpace(MapAdr, BIOS_SIZE, TRUE); - if (pBase == NULL) /* マップ以外orマップ失敗 */ + if (pBase == NULL) /* Not map or mapping failure */ { EramReportEvent(pDrvObj, ERAMNT_ERROR_MAXMEM_MAP_FAILED, NULL); return dwMaxAdr; @@ -3786,33 +3787,33 @@ DWORD GetAcpiReservedMemory( pdwBios = (PDWORD)pBase; for (loopi=0; loopi dwRsdtElement) ? dwRsdtElement : dwMinValue; - /* 資源使用設定 */ + /* resource usage settings */ if (ResourceSetupTiny(pDrvObj, dwRsdtBase, &MapAdr) == FALSE) { KdPrint(("ResourceSetupTiny failed\n")); EramReportEvent(pDrvObj, ERAMNT_ERROR_FUNCTIONERROR, "ResourceSetupTiny"); return dwMinValue; } - /* マップ(キャッシュ許可) */ + /* Map (allow cache) */ pBase = (PBYTE)MmMapIoSpace(MapAdr, uRsdtSize, TRUE); - if (pBase == NULL) /* マップ以外orマップ失敗 */ + if (pBase == NULL) /* not map or failure */ { EramReportEvent(pDrvObj, ERAMNT_ERROR_MAXMEM_MAP_FAILED, NULL); return dwMinValue; } pdwRsdt = (PDWORD)((DWORD)pBase + dwRsdtOfs); KdPrint(("Element 0x%X\n", *pdwRsdt)); - if ((pdwRsdt[0] == 0x50434146)&& /* 'FACP' */ + if ((pdwRsdt[0] == 0x50434146)&& /* 'FACP' */ (pdwRsdt[1] >= 0x74)) { - /* FADT発見 */ + /* FADT found */ if (pdwRsdt[9] != 0) { dwMinValue = (dwMinValue > pdwRsdt[9]) ? pdwRsdt[9] : dwMinValue; @@ -3928,9 +3929,8 @@ DWORD CheckRsdtElements( } KdPrint(("FADT found, FACS=0x%X, DSDT=0x%X\n", pdwRsdt[9], pdwRsdt[10])); } - /* アンマップ */ + /* Unmap */ MmUnmapIoSpace(pBase, uRsdtSize); KdPrint(("CheckRsdtElements end, min 0x%X\n", dwMinValue)); return dwMinValue; } - diff --git a/src/eramnt.h b/src/eramnt.h index 654b794..948ad41 100644 --- a/src/eramnt.h +++ b/src/eramnt.h @@ -1,5 +1,6 @@ -/* ERAMNT.H  RAMディスクERAM for WindowsNT/2000/XP -   Copyright (c) 1999-2004 by *Error15 +/* ERAMNT.H RAM disk ERAM for WindowsNT/2000/XP + Copyright (c) 1999-2004 by *Error15 + Translated into English by Katayama Hirofumi MZ. */ #pragma pack(1) @@ -41,9 +42,9 @@ typedef VOID (*ERAM_UNMAP)(PVOID); #define NT_DEVNAME L"\\Device\\Eram" #define WIN32_PATH L"\\DosDevices\\" #define DEFAULT_DRV L"Z:" -#define DISKMAXCLUSTER_12 (4086) /* FAT12の最大クラスタ */ -#define DISKMAXCLUSTER_16 (65525) /* FAT16の最大クラスタ */ -#define DISKMAXCLUSTER_32 (268435455) /* FAT32の最大クラスタ */ +#define DISKMAXCLUSTER_12 (4086) /* FAT12 Max Cluster */ +#define DISKMAXCLUSTER_16 (65525) /* FAT16 Max Cluster */ +#define DISKMAXCLUSTER_32 (268435455) /* FAT32 Max Cluster */ #define RAMDISK_MEDIA_TYPE 0xf8 #define VOLUME_LABEL_RAMDISK "MS-RAMDRIVE" #define VOLUME_LABEL_LOCALDISK "ERAM-DRIVE " @@ -53,114 +54,114 @@ typedef VOID (*ERAM_UNMAP)(PVOID); #define ERAMEXTFILEPATH L"C:\\ERAMSWAP.$$$" #define DISKMINPAGE (16) -/* ↑データ領域が確保できない;アロケーション2では2が最小 */ +/* Unable to allocate data area; 2 is minimum at allocation 2 */ #define SECTOR (512) #define SECTOR_LOG2 (9) #define RESV_SECTOR_FAT32 (2) -#define SIZE_KILOBYTE (1024) /* 1KB */ -#define SIZE_MEGABYTE (SIZE_KILOBYTE * 1024) /* 1MB */ -#define PAGE_SIZE_4K (SIZE_KILOBYTE * 4) /* 1ページの大きさ */ +#define SIZE_KILOBYTE (1024) /* 1KB */ +#define SIZE_MEGABYTE (SIZE_KILOBYTE * 1024) /* 1MB */ +#define PAGE_SIZE_4K (SIZE_KILOBYTE * 4) /* The size of one page */ #define PAGE_SIZE_LOG2 (12) -#define PAGE_SECTOR (PAGE_SIZE_4K / SECTOR) /* 1ページ中のセクタ数 */ +#define PAGE_SECTOR (PAGE_SIZE_4K / SECTOR) /* Sectors per page */ #define PAGE_SEC_LOG2 (PAGE_SIZE_LOG2 - SECTOR_LOG2) -#define EXT_PAGE_SIZE (SIZE_KILOBYTE * 64) /* 64KB単位切り替え */ +#define EXT_PAGE_SIZE (SIZE_KILOBYTE * 64) /* 64KB unit switch */ #define EXT_PAGE_SIZE_LOG2 (16) -#define EXT_PAGE_SECTOR (EXT_PAGE_SIZE / SECTOR) /* 1バンク中のセクタ数 */ +#define EXT_PAGE_SECTOR (EXT_PAGE_SIZE / SECTOR) /* sectors per bank */ #define EXT_PAGE_SEC_LOG2 (EXT_PAGE_SIZE_LOG2 - SECTOR_LOG2) -#define LIMIT_2GBPAGES (0x7ffff) /* 2GBページ */ -#define LIMIT_4GBPAGES (0xfffff) /* 4GBページ */ -#define BIOS_ADDRESS_START ((DWORD)(0xe0000)) /* E0000〜FFFFF */ -#define BIOS_ADDRESS_END ((DWORD)(0xfffff)) /* E0000〜FFFFF */ +#define LIMIT_2GBPAGES (0x7ffff) /* 2GB pages */ +#define LIMIT_4GBPAGES (0xfffff) /* 4GB pages */ +#define BIOS_ADDRESS_START ((DWORD)(0xe0000)) /* E0000..FFFFF */ +#define BIOS_ADDRESS_END ((DWORD)(0xfffff)) /* E0000..FFFFF */ #define BIOS_SIZE ((DWORD)(BIOS_ADDRESS_END - BIOS_ADDRESS_START + 1)) -/* BPB配列(FAT12,16) */ +/* BPB array (FAT12,16) */ typedef struct { - WORD wNumSectorByte; // セクタバイト数(BPB, =SECTOR) - BYTE byAllocUnit; // アロケーションユニット(alloc) - WORD wNumResvSector; // 予約セクタ数 FAT12/16=1, FAT32=32 - BYTE byNumFat; // FAT数(=1) - WORD wNumDirectory; // ルートディレクトリエントリ数(dir, =128) - WORD wNumAllSector; // 全セクタ数(sectors) under32MB - BYTE byMediaId; // メディアID(media, =f8) - WORD wNumFatSector; // FATセクタ数(FAT) + WORD wNumSectorByte; // The number of sector bytes (BPB, =SECTOR) + BYTE byAllocUnit; // Allocation unit (alloc) + WORD wNumResvSector; // The number of reserved sectors, FAT12/16=1, FAT32=32 + BYTE byNumFat; // The number of FATs (=1) + WORD wNumDirectory; // The number of root directory entries (dir, =128) + WORD wNumAllSector; // The number of all sectors (under 32MB) + BYTE byMediaId; // Media ID(media, =f8) + WORD wNumFatSector; // The number of FAT sectors (FAT) } bpb_struc1; typedef struct { - WORD bsSecPerTrack; // 1バンクあたりのセクタ数(=PAGE_SECTOR) - WORD bsHeads; // ヘッド数(=1) - ULONG bsHiddenSecs; // 隠れたセクタ数(=0) - ULONG bsHugeSectors; // over32MBセクタ + WORD bsSecPerTrack; // Sectors per bank (=PAGE_SECTOR) + WORD bsHeads; // The number of heads (=1) + ULONG bsHiddenSecs; // The number of hidden sectors (=0) + ULONG bsHugeSectors; // The sectors over 32MB } bpb_struc2; typedef struct { - BYTE bsDriveNumber; // ドライブ番号 - BYTE bsReserved1; // 予約 - BYTE bsBootSignature; // 識別子 - ULONG bsVolumeID; // ボリュームID - CHAR bsLabel[11]; // ラベル - CHAR bsFileSystemType[8];// ファイルシステムタイプ + BYTE bsDriveNumber; // Drive number + BYTE bsReserved1; // Reserved + BYTE bsBootSignature; // Signature + ULONG bsVolumeID; // Volume ID + CHAR bsLabel[11]; // Label + CHAR bsFileSystemType[8];// File system type } bpb_struc3; -/* BPB配列(FAT32) */ +/* BPB array (FAT32) */ typedef struct { - DWORD dwNumFatSector32; // FATセクタ数(FAT32) - WORD wExtFlags; // 拡張フラグ - WORD wFileSystemVersion; // ファイルシステムバージョン - DWORD dwRootCluster; // ルートクラスタ番号(=2) - WORD wFsInfoSector; // FSINFOセクタ番号(=1) - WORD wBackupBootSector; // バックアップブートセクタ番号(=6) - BYTE byResv[12]; // 予約 + DWORD dwNumFatSector32; // The number of FAT sectors (FAT32) + WORD wExtFlags; // Extended flags + WORD wFileSystemVersion; // Filesystem version + DWORD dwRootCluster; // Root cluster number (=2) + WORD wFsInfoSector; // FSINFO sector number (=1) + WORD wBackupBootSector; // Backup boot sector number (=6) + BYTE byResv[12]; // Reserved } bpb_struc4; typedef union { - DWORD dwOptflag; // ERAM制御 + DWORD dwOptflag; // ERAM control struct { - BYTE NonPaged:1; // bit 0:NonPagedPool使用 - BYTE External:1; // bit 1:外部メモリ使用 - BYTE SkipExternalCheck:1; // bit 2:外部メモリ使用時メモリ検査しない - BYTE Swapable:1; // bit 3:ローカルディスクとして扱う - BYTE EnableFat32:1; // bit 4:FAT32の使用を許可 - BYTE SkipReportUsage:1; // bit 5:外部メモリ使用時Reportしない=2000:スタンバイ可 - BYTE MakeTempDir:1; // bit 6:TEMPディレクトリ作成 + BYTE NonPaged:1; // bit 0:NonPagedPool usage + BYTE External:1; // bit 1:External memory usage + BYTE SkipExternalCheck:1; // bit 2:Don't test memory when using external memory + BYTE Swapable:1; // bit 3:Local disk flag + BYTE EnableFat32:1; // bit 4:Allow FAT32 usage + BYTE SkipReportUsage:1; // bit 5:Don't report when using external memory = 2000:Allow stand-by + BYTE MakeTempDir:1; // bit 6:TEMP directory creation BYTE byResv7:1; // bit 7: BYTE byResv8:8; // bit 8: BYTE byResv16:8; // bit16: BYTE byResv24:7; // bit24: - BYTE UseExtFile:1; // bit31:外部ファイル使用 + BYTE UseExtFile:1; // bit31:External file usage } Bits; } ERAM_OPTFLAG, *PERAM_OPTFLAG; -/* ERAMディスクデバイス固有情報 */ +/* ERAM disk device specific info */ typedef struct { PDEVICE_OBJECT pDevObj; ERAM_READ EramRead; ERAM_WRITE EramWrite; ERAM_NEXT EramNext; ERAM_UNMAP EramUnmap; - ULONG uNowMapAdr; // OS管理外/ファイル 現在マップ中のアドレス - LPBYTE pExtPage; // OS管理外/ファイル メモリマップアドレス - LPBYTE pPageBase; // OS管理メモリ - ULONG uSizeTotal; // トータルサイズ(4KB単位) + ULONG uNowMapAdr; // OS management outside/file, the currently mapping address + LPBYTE pExtPage; // OS management outside/file, the memory mapping address + LPBYTE pPageBase; // OS management memory + ULONG uSizeTotal; // Total size (4KB unit) UNICODE_STRING Win32Name; - ULONG uAllSector; // セクタ数 - ULONG uExternalStart; // 外部メモリ開始位置 - ULONG uExternalEnd; // 外部メモリ終了位置(検出された分) - FAST_MUTEX FastMutex; // 高速mutex - PHYSICAL_ADDRESS MapAdr; // OS管理外メモリマップ位置先頭 - ULONG bsHiddenSecs; // 隠れたセクタ数(=0) - HANDLE hFile; // 外部ファイルハンドル (システムプロセス内) - HANDLE hSection; // 外部ファイルマップハンドル (システムプロセス内) - LIST_ENTRY IrpList; // Irpリスト先頭 - KSPIN_LOCK IrpSpin; // Irpリスト用spinlock - KSEMAPHORE IrpSem; // Irpリスト用semaphore - PVOID pThreadObject; // Irpリスト用スレッドオブジェクト - ERAM_OPTFLAG uOptflag; // オプション - BYTE FAT_size; // PARTITION_〜 FAT_12,FAT_16,HUGE,FAT32 - BYTE bThreadStop; // スレッド停止要求 + ULONG uAllSector; // The number of all sectors + ULONG uExternalStart; // External memory starting position + ULONG uExternalEnd; // External memory ending position (of detected) + FAST_MUTEX FastMutex; // Fast mutex + PHYSICAL_ADDRESS MapAdr; // OS management outside memory map position top + ULONG bsHiddenSecs; // The number of hidden sectors (=0) + HANDLE hFile; // External file handle (in system process) + HANDLE hSection; // External file mapping handle (in system process) + LIST_ENTRY IrpList; // Irp list top + KSPIN_LOCK IrpSpin; // Irp list spinlock + KSEMAPHORE IrpSem; // Irp list semaphore + PVOID pThreadObject; // Irp list thred object + ERAM_OPTFLAG uOptflag; // Option + BYTE FAT_size; // PARTITION_... FAT_12,FAT_16,HUGE,FAT32 + BYTE bThreadStop; // Thread Stop Request } ERAM_EXTENSION, *PERAM_EXTENSION; -/* MBR内パーテーションテーブル(PC/AT) */ +/* MBR-inside partitoin table (PC/AT) */ typedef struct { BYTE byBootInd; BYTE byFirstHead; @@ -174,65 +175,65 @@ typedef struct { DWORD dwNumSectors; } MBR_PARTITION, *PMBR_PARTITION; -/* ブートセクタ用情報 */ +/* Info for boot sector */ typedef struct { - bpb_struc1 BPB; /* BPB配列 */ - bpb_struc2 BPB_ext; /* DOS5拡張領域 */ - bpb_struc3 BPB_ext2; /* 拡張領域 */ - bpb_struc4 BPB_fat32; /* FAT32専用 */ - TIME_FIELDS TimeInfo; /* 日時 */ - CHAR bsLabel[11]; /* ラベル */ - WCHAR wszExtFile[4]; /* \\??\\ */ - WCHAR wszExtFileMain[260]; /* C:\\ERAMSWAP.$$$ */ + bpb_struc1 BPB; /* BPB array */ + bpb_struc2 BPB_ext; /* DOS5 extended area */ + bpb_struc3 BPB_ext2; /* Extended area */ + bpb_struc4 BPB_fat32; /* FAT32 only */ + TIME_FIELDS TimeInfo; /* date and time */ + CHAR bsLabel[11]; /* label */ + WCHAR wszExtFile[4]; /* \\??\\ */ + WCHAR wszExtFileMain[260]; /* C:\\ERAMSWAP.$$$ */ } FAT_ID, *PFAT_ID; typedef struct { BYTE bsJump[3]; // jmp $(=eb, fe, 90) - BYTE bsOemName[8]; // デバイス名(='ERAM ') - bpb_struc1 BPB; // BPB配列 - bpb_struc2 BPB_ext; // DOS5拡張領域 - bpb_struc3 BPB_ext2; // 拡張領域 + BYTE bsOemName[8]; // Device name (='ERAM ') + bpb_struc1 BPB; // BPB array + bpb_struc2 BPB_ext; // DOS5 extended area + bpb_struc3 BPB_ext2; // Extended area BYTE byResv1[194]; BYTE szMsg[128]; // 0x100 BYTE byResv2[126]; // 0x180 - BYTE bsSig2[2]; /* 55,AA */ + BYTE bsSig2[2]; /* 55,AA */ } BOOTSECTOR_FAT16, *PBOOTSECTOR_FAT16; typedef struct { BYTE bsJump[3]; // jmp $(=eb, fe, 90) - BYTE bsOemName[8]; // デバイス名(='ERAM ') - bpb_struc1 BPB; // BPB配列 - bpb_struc2 BPB_ext; // DOS5拡張領域 - bpb_struc4 BPB_fat32; // FAT32専用 - bpb_struc3 BPB_ext2; // 拡張領域 + BYTE bsOemName[8]; // Device name (='ERAM ') + bpb_struc1 BPB; // BPB array + bpb_struc2 BPB_ext; // DOS5 extended area + bpb_struc4 BPB_fat32; // FAT32 only + bpb_struc3 BPB_ext2; // Extended area BYTE byResv1[166]; BYTE szMsg[128]; // 0x100 BYTE byResv[62]; // 0x180 MBR_PARTITION Parts[4]; // 0x1BE, 1CE, 1DE, 1EE - BYTE bsSig2[2]; /* 55,AA */ + BYTE bsSig2[2]; /* 55,AA */ } BOOTSECTOR_FAT32, *PBOOTSECTOR_FAT32; -/* FSINFO (FAT32) */ +/* FSINFO (FAT32) */ typedef struct { - DWORD bfFSInf_Sig; /* "rrAa" */ - DWORD bfFSInf_free_clus_cnt; /* 空きクラスタ -1:不明 */ - DWORD bfFSInf_next_free_clus; /* 前回確保したクラスタ */ + DWORD bfFSInf_Sig; /* "rrAa" */ + DWORD bfFSInf_free_clus_cnt; /* Free clusters -1:Unknown */ + DWORD bfFSInf_next_free_clus; /* Cluster reserved last time */ DWORD bfFSInf_resvd[3]; } BIGFATBOOTFSINFO, *PBIGFATBOOTFSINFO; typedef struct { - DWORD FSInfo_Sig; /* "RRaA" */ + DWORD FSInfo_Sig; /* "RRaA" */ BYTE byResv[480]; - BIGFATBOOTFSINFO FsInfo; /* 1E4〜 */ + BIGFATBOOTFSINFO FsInfo; /* 1E4.. */ BYTE byResv2[2]; - BYTE bsSig2[2]; /* 55,AA */ + BYTE bsSig2[2]; /* 55,AA */ } FSINFO_SECTOR, *PFSINFO_SECTOR; -/* ディレクトリエントリ */ +/* Directory entry */ typedef struct { - CHAR sName[11]; /* ファイル名 */ + CHAR sName[11]; /* Filename */ union { - BYTE byAttr; /* ファイル属性 */ + BYTE byAttr; /* File attributes */ struct { BYTE byR:1; BYTE byH:1; @@ -243,28 +244,28 @@ typedef struct { } Bits; } uAttr; BYTE byResv1[10]; - WORD wUpdMinute; /* 更新時刻 */ - WORD wUpdDate; /* 更新日付 */ - WORD wCluster; /* 先頭クラスタ */ - DWORD dwFileSize; /* ファイルサイズ */ + WORD wUpdMinute; /* Update Time */ + WORD wUpdDate; /* Update Date */ + WORD wCluster; /* First cluster */ + DWORD dwFileSize; /* The file size */ } DIR_ENTRY, *PDIR_ENTRY; -/* ルートディレクトリエントリ */ +/* Root Directory Entry */ typedef struct { DIR_ENTRY vol; DIR_ENTRY temp; } vol_label; -/* サブディレクトリエントリ */ +/* Subdirectory Entry */ typedef struct { DIR_ENTRY own; DIR_ENTRY parent; } dir_init; -/* プロトタイプ */ +/* Prototypes */ -//------ 昔の隠れAPI +//------ Oldie hidden API extern __declspec(dllimport) ULONG NtBuildNumber; @@ -287,7 +288,7 @@ ZwCreateSection( #define SEC_COMMIT (0x8000000) #endif -//------ 通常使用時に常時使用する関数群 +//------ Functions to be used at all times in normal use NTSTATUS EramCreateClose( IN PDEVICE_OBJECT pDevObj, @@ -465,9 +466,9 @@ NTSTATUS EramShutdown( IN PIRP pIrp ); -/* ページングするための定義 */ +/* Definitions for paging */ #ifdef ALLOC_PRAGMA -//------ 通常使用時に常時使用する関数群 +//------ Functions to be used at all times in normal use #pragma alloc_text(PAGE, EramCreateClose) #pragma alloc_text(PAGE, EramDeviceControl) #pragma alloc_text(PAGE, EramDeviceControlGeometry) @@ -502,8 +503,7 @@ NTSTATUS EramShutdown( #pragma alloc_text(PAGE, EramShutdown) #endif // ALLOC_PRAGMA - -//------ これ以降は初期化時に使用する関数群 +//------ Below are the functions used at initialization NTSTATUS DriverEntry( IN OUT PDRIVER_OBJECT pDrvObj, @@ -692,7 +692,7 @@ DWORD CheckRsdtElements( IN DWORD dwRsdtElement ); -/* 初期化後解放するための定義 */ +/* Definitions for releasing after initialization */ #ifdef ALLOC_PRAGMA #pragma alloc_text(INIT, DriverEntry) #pragma alloc_text(INIT, InitFatId) diff --git a/src/eramnt.rc b/src/eramnt.rc index d616bbf..b96fb9b 100644 --- a/src/eramnt.rc +++ b/src/eramnt.rc @@ -1,5 +1,5 @@ -/* ERAMNT.RC  RAMディスクERAM for WindowsNT/2000/XP -   Copyright (c) 1999-2004 by *Error15 +/* ERAMNT.RC RAM Disk ERAM for WindowsNT/2000/XP + Copyright (c) 1999-2004 by *Error15 */ #include @@ -7,7 +7,7 @@ #ifdef RC_INVOKED ///////////////////////////////////////////////////////////////////////////// -// 日本語 resources +// Japanese resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN) #ifdef _WIN32 @@ -26,7 +26,7 @@ VS_VERSION_INFO VERSIONINFO BEGIN BLOCK "StringFileInfo" BEGIN - BLOCK "041104b0" //日本語 + BLOCK "041104b0" //Japanese BEGIN VALUE "Comments", "ERAM for Windows NT/2000/XP" VALUE "CompanyName", "*Error15" @@ -45,12 +45,12 @@ BEGIN END END -#endif // 日本語 resources +#endif // Japanese resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// 英語 (アメリカ) resources +// English (America) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 @@ -88,6 +88,6 @@ BEGIN END END -#endif // 英語 (アメリカ) resources +#endif // English (America) resources #endif //RC_INVOKED