高级VB问题 [英] Advanced VB Question
问题描述
此特定功能稍后.首先是一些背景知识,并且在一年前就奏效了.
This particular function later. first some background, This worked and as a year ago.
每个NTFS文件都有一个文件头.头文件是2048文件,用于描述称为主文件目录"的文件中的文件.这些标题具有属性.此函数采用标头并提取称为属性的描述符-因此该函数的名称为Getattributes.
Every NTFS file has a file header. A head is a 2048 file describing the file in a file called the Master File Directory. These headers have attributes. This function takes a header and extracts descriptors called attributes - hence the function's name Getattributes.
GetAttributes失败:
GetAttributes is failing:
私有 功能 GetAttributes( ByVal As 字节 ) As 列表 Of MFTAttribute
Private Function GetAttributes(ByVal Buffer1() As Byte) As List(Of MFTAttribute)
'如果Num = 37109 Then Debugger.Break()
' If Num = 37109 Then Debugger.Break()
暗 _属性 As 新 列表 Of MFTAttribute
Dim _Attributes As New List(Of MFTAttribute)
暗 _AttributeOffset As 长
Dim _AttributeOffset As Long
暗 intFileAttribute As 整数 = 0
Dim intFileAttribute As Integer = 0
暗 attributeTpeName = 错误
Dim attributeTpeName = False
_AttributeOffset = LittleEndianHEXToDecimal(Buffer1,AttributeOffset,2)+ 1
做
Do
暗 _intAttributePtr As IntPtr 元帅
Dim _intAttributePtr As IntPtr = Marshal.AllocHGlobal(24)
暗 _属性 As MFTAttribute
Dim _Attribute As MFTAttribute
尝试
Try
元帅 将非托管空间中的24个字节复制到托管空间中.
Marshal.Copy(Buffer1, _AttributeOffset - 1, _intAttributePtr, 24) ' Copy 24 bytes from unmanaged to managed space<----FAILS AT THIS MARSHAL.Copy
如果成功,则MFT标头中的前四个字节等于"FILE".在ascii中.
'If sucessful, the first four bytes in an MFT header equals "FILE" in ascii.
_Attribute = CType ( 元帅 MFTAttribute '
_Attribute = CType(Marshal.PtrToStructure(_intAttributePtr, _Attribute.GetType()), MFTAttribute) '
attributeTpeName = 错误
attributeTpeName = False
选择 案例 _Attribute.AttributeType 在病理情况下
Select Case _Attribute.AttributeType 'In pathological case
; 案例 FileNameAttribute
Case FileNameAttribute
&bb ; attributeTpeName = 真
attributeTpeName = True
; 案例 BitmapAttribute
Case BitmapAttribute
&bb ; 如果 _Attribute.Length> 2048 然后 _Attribute.Length = _Attribute.Length 还有 不是 & H97980000
If _Attribute.Length > 2048 Then _Attribute.Length = _Attribute.Length And Not &H97980000
结束 选择
End Select
元帅
Marshal.FreeHGlobal(_intAttributePtr)
捕获 前 As 异常
Catch ex As Exception
元帅
Marshal.FreeHGlobal(_intAttributePtr)
如果 _Attribute.Length< 0 然后 返回 _Attributes
If _Attribute.Length < 0 Then Return _Attributes
attributeTpeName = 错误
attributeTpeName = False
结束 尝试
End Try
如果 _Attribute.AttributeType = FileNameAttribute 然后
If _Attribute.AttributeType = FileNameAttribute Then
intFileAttribute + = 1
结束 如果
End If
_Attributes.Add(_Attribute)
_AttributeOffset + = _Attribute.Length '< -------
_AttributeOffset += _Attribute.Length '<-------
读取所有属性,然后返回
'Read all attributes and then return
如果 _Attribute.AttributeType = -1 然后 退出 做
If _Attribute.AttributeType = -1 Then Exit Do
环路 直到 _AttributeOffset> = 1024
Loop Until _AttributeOffset >= 1024
返回 _Attributes
Return _Attributes
结束 功能
End Function
到底是什么问题?即将提供更多信息.属性输出全部为零.
What on earth is the Problem? Will supply more info soon. The attributes output are all ZERO.
蕾妮
由于现代编程引入的问题,现代编程在基本方式上是不足的".我
"MODERN PROGRAMMING is deficient in elementary ways BECAUSE of problems INTRODUCED by MODERN PROGRAMMING." Me
推荐答案
带着微笑谈论服务....
Talk about service with a smile....
我敢打赌,这有点愚蠢,但很难找到,就像找不到缓冲区或真实缓冲区..... Marshal.Copy不会返回很多信息.
I'll bet it's something dumb but hard to find like the buffer wasn't found or real.....Marshal.Copy doesn't return a lot of information.
Renee
这篇关于高级VB问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!