阅读:5794回复:21
TrueCrypt 开源软件安装程序及源码, 欢迎下载研究
源码工程组织的非常不错, 有很多值得借鉴的地方.
|
|
|
沙发#
发布于:2007-06-22 15:09
怎么感觉每次只能上传一个附件
|
|
|
板凳#
发布于:2007-06-22 16:30
可能都研究透了。不过新版和以前的实现有了相对大的改动。
|
|
|
地板#
发布于:2007-06-22 17:16
先取取经
|
|
|
地下室#
发布于:2007-06-22 17:31
这里的读写方法非常值得借鉴,可以实现加密标志置于文件头和文件尾。
|
|
|
5楼#
发布于:2007-06-23 16:14
不错,看看
|
|
6楼#
发布于:2007-06-23 16:23
NTSTATUS
TCReadWrite (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension, PIRP Irp) { PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp); PUCHAR currentAddress; PUCHAR tmpBuffer; NTSTATUS ntStatus; BOOL lowerPriority = (OsMajorVersion >= 6); #if EXTRA_INFO Dump ("USER BUFFER IS 0x%08x MDL ADDRESS IS 0x%08x\n", Irp->UserBuffer, Irp->MdlAddress); Dump ("Irp->Tail.Overlay.OriginalFileObject = 0x%08x\n", Irp->Tail.Overlay.OriginalFileObject); Dump ("irpSp->FileObject = 0x%08x\n", irpSp->FileObject); if (Irp->Tail.Overlay.OriginalFileObject != NULL) { if (Irp->Tail.Overlay.OriginalFileObject->FileName.Length != 0) Dump ("Irp->Tail.Overlay.OriginalFileObject = %ls\n", Irp->Tail.Overlay.OriginalFileObject->FileName.Buffer); else Dump ("Irp->Tail.Overlay.OriginalFileObject = %ls\n", WIDE ("null value")); } if (irpSp->FileObject != NULL) { if (irpSp->FileObject->FileName.Length != 0) Dump ("irpSp->FileObject = %ls\n", irpSp->FileObject->FileName.Buffer); else Dump ("irpSp->FileObject = %ls\n", WIDE ("null value")); } #endif currentAddress = (PUCHAR) MmGetSystemAddressForMdlSafe (Irp->MdlAddress, HighPagePriority); if (currentAddress == NULL) return COMPLETE_IRP (DeviceObject, Irp, STATUS_INSUFFICIENT_RESOURCES, 0); if (irpSp->MajorFunction == IRP_MJ_READ) { LARGE_INTEGER readOffset; readOffset.QuadPart = irpSp->Parameters.Read.ByteOffset.QuadPart; if (irpSp->Parameters.Read.Length == 0 || (irpSp->Parameters.Read.Length & (SECTOR_SIZE - 1)) || readOffset.QuadPart + irpSp->Parameters.Read.Length > Extension->DiskLength) { return COMPLETE_IRP (DeviceObject, Irp, STATUS_INVALID_PARAMETER, 0); } if (Extension->cryptoInfo->hiddenVolume) readOffset.QuadPart += Extension->cryptoInfo->hiddenVolumeOffset; else readOffset.QuadPart += HEADER_SIZE; tmpBuffer = TCalloc (irpSp->Parameters.Read.Length); if (tmpBuffer == NULL) return COMPLETE_IRP (DeviceObject, Irp, STATUS_INSUFFICIENT_RESOURCES, 0); ntStatus = ZwReadFile (Extension->hDeviceFile, NULL, NULL, NULL, &Irp->IoStatus, tmpBuffer, irpSp->Parameters.Read.Length, &readOffset, NULL); Irp->IoStatus.Status = ntStatus; if (NT_SUCCESS(ntStatus)) { Extension->TotalBytesRead += irpSp->Parameters.Read.Length; memcpy (currentAddress, tmpBuffer, irpSp->Parameters.Read.Length); if (lowerPriority) KeSetPriorityThread (KeGetCurrentThread (), LOW_REALTIME_PRIORITY - TC_PRIORITY_DECREASE); DecryptSectors ((ULONG *) currentAddress, readOffset.QuadPart / SECTOR_SIZE, irpSp->Parameters.Read.Length / SECTOR_SIZE, Extension->cryptoInfo); if (lowerPriority) KeSetPriorityThread (KeGetCurrentThread (), LOW_REALTIME_PRIORITY); } TCfree (tmpBuffer); } else if (irpSp->MajorFunction == IRP_MJ_WRITE) { LARGE_INTEGER writeOffset; if (Extension->bReadOnly) return COMPLETE_IRP (DeviceObject, Irp, STATUS_MEDIA_WRITE_PROTECTED, 0); writeOffset.QuadPart = irpSp->Parameters.Write.ByteOffset.QuadPart; if (irpSp->Parameters.Write.Length == 0 || (irpSp->Parameters.Write.Length & (SECTOR_SIZE - 1)) || writeOffset.QuadPart + irpSp->Parameters.Write.Length > Extension->DiskLength) { return COMPLETE_IRP (DeviceObject, Irp, STATUS_INVALID_PARAMETER, 0); } // Hidden volume protection if (Extension->cryptoInfo->bProtectHiddenVolume) { // If there has already been a write operation denied in order to protect the // hidden volume (since the volume mount time) if (Extension->cryptoInfo->bHiddenVolProtectionAction) { // Do not allow writing to this volume anymore. This is to fake a complete volume // or system failure (otherwise certain kinds of inconsistency within the file // system could indicate that this volume has used hidden volume protection). return COMPLETE_IRP (DeviceObject, Irp, STATUS_INVALID_PARAMETER, 0); } // Verify that no byte is going to be written to the hidden volume area if (RegionsOverlap ((unsigned __int64) irpSp->Parameters.Write.ByteOffset.QuadPart + HEADER_SIZE, (unsigned __int64) irpSp->Parameters.Write.ByteOffset.QuadPart + HEADER_SIZE + irpSp->Parameters.Write.Length - 1, Extension->cryptoInfo->hiddenVolumeOffset, (unsigned __int64) Extension->DiskLength + HEADER_SIZE - (HIDDEN_VOL_HEADER_OFFSET - HEADER_SIZE) - 1)) { Extension->cryptoInfo->bHiddenVolProtectionAction = TRUE; // Deny this write operation to prevent the hidden volume from being overwritten return COMPLETE_IRP (DeviceObject, Irp, STATUS_INVALID_PARAMETER, 0); } } if (Extension->cryptoInfo->hiddenVolume) writeOffset.QuadPart += Extension->cryptoInfo->hiddenVolumeOffset; else writeOffset.QuadPart += HEADER_SIZE; tmpBuffer = TCalloc (irpSp->Parameters.Write.Length); if (tmpBuffer == NULL) return COMPLETE_IRP (DeviceObject, Irp, STATUS_INSUFFICIENT_RESOURCES, 0); memcpy (tmpBuffer, currentAddress, irpSp->Parameters.Write.Length); if (lowerPriority) KeSetPriorityThread (KeGetCurrentThread (), LOW_REALTIME_PRIORITY - TC_PRIORITY_DECREASE); EncryptSectors ((ULONG *) tmpBuffer, writeOffset.QuadPart / SECTOR_SIZE, irpSp->Parameters.Write.Length / SECTOR_SIZE, Extension->cryptoInfo); if (lowerPriority) KeSetPriorityThread (KeGetCurrentThread (), LOW_REALTIME_PRIORITY); ntStatus = ZwWriteFile (Extension->hDeviceFile, NULL, NULL, NULL, &Irp->IoStatus, tmpBuffer, irpSp->Parameters.Write.Length, &writeOffset, NULL); Irp->IoStatus.Status = ntStatus; if (NT_SUCCESS(ntStatus)) Extension->TotalBytesWritten += irpSp->Parameters.Write.Length; TCfree (tmpBuffer); } else return COMPLETE_IRP (DeviceObject, Irp, STATUS_INVALID_PARAMETER, 0); IoCompleteRequest (Irp, NT_SUCCESS(ntStatus) ? IO_DISK_INCREMENT : IO_NO_INCREMENT); return ntStatus; } |
|
7楼#
发布于:2007-06-23 20:15
如果编译
|
|
8楼#
发布于:2007-06-23 22:40
楼上的,你看一下readme,如何编译介绍的很详细。
|
|
|
9楼#
发布于:2007-06-25 21:07
如何像Truecrypt一样管理自己的代码?如何和.net结合?感觉非常方便
|
|
10楼#
发布于:2007-06-26 08:24
工程组织的不错
|
|
11楼#
发布于:2007-06-28 08:07
刚刚开始学习Truecrypt,我想问一下不同项目之间如何协同工作,Driver项目包含了Crypto.h,而这个文件在Common中,我自己包含的时候就出错,这是什么原因?
|
|
12楼#
发布于:2007-06-28 08:13
如何像Truecrypt一样使用vs2005的编译器呢? 如何创建这种项目,我没有找到能自己写makefile的方法,哪位能提示一下?
|
|
13楼#
发布于:2007-06-29 07:55
又一个版本的filedisk
|
|
|
14楼#
发布于:2008-08-20 14:48
如何编译它呢?
|
|
15楼#
发布于:2008-08-20 15:06
楼主做过密组件没有.
现在有个头疼的问题,怕自己购买的GIS地图被 用户所非法拷贝. |
|
16楼#
发布于:2008-08-20 17:31
没看到代码啊,在哪里?
|
|
17楼#
发布于:2008-08-28 17:31
编译汇编的时候还必须要16位的编译器,提示什么Visual C++ 1.52,现在去哪儿弄这个,大家是怎么处理的
|
|
|
18楼#
发布于:2010-03-08 17:03
|
|
19楼#
发布于:2010-04-09 20:02
不错的软件。
|
|
上一页
下一页