VERSION 5.00
Begin VB.Form Form15 
   Caption         =   " Linux Ext2 (Ext3, Ext4) File System - Group Descriptor Table"
   ClientHeight    =   3900
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6360
   Icon            =   "ext4grpdescs.frx":0000
   LinkTopic       =   "Form15"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3900
   ScaleWidth      =   6360
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdLast 
      DownPicture     =   "ext4grpdescs.frx":0442
      Height          =   345
      Left            =   5790
      MaskColor       =   &H00FFFFFF&
      Picture         =   "ext4grpdescs.frx":0562
      Style           =   1  'Graphical
      TabIndex        =   27
      ToolTipText     =   "Last"
      Top             =   120
      UseMaskColor    =   -1  'True
      Width           =   315
   End
   Begin VB.CommandButton cmdNext 
      DownPicture     =   "ext4grpdescs.frx":0682
      Height          =   345
      Left            =   5460
      MaskColor       =   &H00FFFFFF&
      Picture         =   "ext4grpdescs.frx":07BE
      Style           =   1  'Graphical
      TabIndex        =   26
      ToolTipText     =   "Next"
      Top             =   120
      UseMaskColor    =   -1  'True
      Width           =   315
   End
   Begin VB.CommandButton cmdPrev 
      DownPicture     =   "ext4grpdescs.frx":08FA
      Height          =   345
      Left            =   5130
      MaskColor       =   &H00FFFFFF&
      Picture         =   "ext4grpdescs.frx":0A36
      Style           =   1  'Graphical
      TabIndex        =   25
      ToolTipText     =   "Previous"
      Top             =   120
      UseMaskColor    =   -1  'True
      Width           =   315
   End
   Begin VB.CommandButton cmdFirst 
      DownPicture     =   "ext4grpdescs.frx":0B72
      Height          =   345
      Left            =   4800
      MaskColor       =   &H00FFFFFF&
      Picture         =   "ext4grpdescs.frx":0CAE
      Style           =   1  'Graphical
      TabIndex        =   24
      ToolTipText     =   "First"
      Top             =   120
      UseMaskColor    =   -1  'True
      Width           =   315
   End
   Begin VB.OptionButton Option2 
      Caption         =   "EXT4"
      Height          =   375
      Left            =   3840
      TabIndex        =   23
      Top             =   120
      Width           =   735
   End
   Begin VB.OptionButton Option1 
      Caption         =   "EXT3 "
      Height          =   375
      Left            =   2880
      TabIndex        =   22
      Top             =   120
      Value           =   -1  'True
      Width           =   735
   End
   Begin VB.Label Label11 
      Caption         =   "Reserved (32 bit) 2:"
      Height          =   255
      Left            =   240
      TabIndex        =   35
      Top             =   2520
      Width           =   1605
   End
   Begin VB.Label Label8 
      Caption         =   "Reserved (16 bit) 0:"
      Height          =   255
      Left            =   240
      TabIndex        =   34
      Top             =   2040
      Width           =   1600
   End
   Begin VB.Label Label18 
      Height          =   1815
      Left            =   4080
      TabIndex        =   33
      Top             =   1440
      Width           =   2175
   End
   Begin VB.Label Label17 
      Caption         =   "0"
      Height          =   255
      Left            =   4800
      TabIndex        =   32
      Top             =   1080
      Width           =   855
   End
   Begin VB.Label Label16 
      Caption         =   "Offset :"
      Height          =   255
      Left            =   4200
      TabIndex        =   31
      Top             =   1080
      Width           =   615
   End
   Begin VB.Label Label15 
      Caption         =   "0"
      Height          =   255
      Left            =   4800
      TabIndex        =   30
      Top             =   720
      Width           =   1455
   End
   Begin VB.Label Label14 
      Caption         =   "Sector:"
      Height          =   255
      Left            =   4200
      TabIndex        =   29
      Top             =   720
      Width           =   615
   End
   Begin VB.Label Label9 
      Caption         =   "NOTE"
      Height          =   495
      Left            =   240
      TabIndex        =   28
      Top             =   3360
      Width           =   5895
   End
   Begin VB.Label Label23 
      Caption         =   "0"
      Height          =   255
      Index           =   10
      Left            =   1920
      TabIndex        =   21
      Top             =   3000
      Width           =   1965
   End
   Begin VB.Label Label23 
      Caption         =   "0"
      Height          =   255
      Index           =   9
      Left            =   1920
      TabIndex        =   20
      Top             =   2760
      Width           =   1965
   End
   Begin VB.Label Label23 
      Caption         =   "0"
      Height          =   255
      Index           =   8
      Left            =   1920
      TabIndex        =   19
      Top             =   2520
      Width           =   1965
   End
   Begin VB.Label Label23 
      Caption         =   "0"
      Height          =   255
      Index           =   7
      Left            =   1920
      TabIndex        =   18
      Top             =   2280
      Width           =   1965
   End
   Begin VB.Label Label23 
      Caption         =   "0"
      Height          =   255
      Index           =   6
      Left            =   1920
      TabIndex        =   17
      Top             =   2040
      Width           =   1965
   End
   Begin VB.Label Label23 
      Caption         =   "0"
      Height          =   255
      Index           =   5
      Left            =   1920
      TabIndex        =   16
      Top             =   1800
      Width           =   1965
   End
   Begin VB.Label Label23 
      Caption         =   "0"
      Height          =   255
      Index           =   4
      Left            =   1920
      TabIndex        =   15
      Top             =   1560
      Width           =   1965
   End
   Begin VB.Label Label23 
      Caption         =   "0"
      Height          =   255
      Index           =   3
      Left            =   1920
      TabIndex        =   14
      Top             =   1320
      Width           =   1965
   End
   Begin VB.Label Label23 
      Caption         =   "0"
      Height          =   255
      Index           =   2
      Left            =   1920
      TabIndex        =   13
      Top             =   1080
      Width           =   1995
   End
   Begin VB.Label Label23 
      Caption         =   "0"
      Height          =   255
      Index           =   1
      Left            =   1920
      TabIndex        =   12
      Top             =   840
      Width           =   1965
   End
   Begin VB.Label Label23 
      Caption         =   "0"
      Height          =   255
      Index           =   0
      Left            =   1920
      TabIndex        =   11
      Top             =   600
      Width           =   1965
   End
   Begin VB.Label Label22 
      Caption         =   "PhysicalDrive0:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   162
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   1080
      TabIndex        =   1
      Top             =   120
      Width           =   1695
   End
   Begin VB.Label Label13 
      Caption         =   "Checksum"
      Height          =   255
      Left            =   240
      TabIndex        =   10
      Top             =   3000
      Width           =   1605
   End
   Begin VB.Label Label12 
      Caption         =   "Reserved (32 bit) 3:"
      Height          =   255
      Left            =   240
      TabIndex        =   9
      Top             =   2760
      Width           =   1605
   End
   Begin VB.Label Label10 
      Caption         =   "Reserved (32 bit) 1:"
      Height          =   255
      Left            =   240
      TabIndex        =   8
      Top             =   2280
      Width           =   1605
   End
   Begin VB.Label Label7 
      Caption         =   "Directories Count:"
      Height          =   255
      Left            =   240
      TabIndex        =   7
      Top             =   1800
      Width           =   1600
   End
   Begin VB.Label Label6 
      Caption         =   "Free Inodes Count:"
      Height          =   255
      Left            =   240
      TabIndex        =   6
      Top             =   1560
      Width           =   1600
   End
   Begin VB.Label Label5 
      Caption         =   "Free Blocks Count:"
      Height          =   255
      Left            =   240
      TabIndex        =   5
      Top             =   1320
      Width           =   1600
   End
   Begin VB.Label Label4 
      Caption         =   "Inodes Table Block:"
      Height          =   255
      Left            =   240
      TabIndex        =   4
      Top             =   1080
      Width           =   1600
   End
   Begin VB.Label Label3 
      Caption         =   "Inodes Bitmap Block:"
      Height          =   255
      Left            =   240
      TabIndex        =   3
      Top             =   840
      Width           =   1600
   End
   Begin VB.Label Label2 
      Caption         =   "Blocks Bitmap Block:"
      Height          =   255
      Left            =   240
      TabIndex        =   2
      Top             =   600
      Width           =   1600
   End
   Begin VB.Label Label1 
      Caption         =   "Drive"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   162
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   240
      TabIndex        =   0
      Top             =   120
      Width           =   735
   End
End
Attribute VB_Name = "Form15"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim N As Integer
Rem /* Blocks bitmap block */ (_le32)
Rem Dim bg_block_bitmap As Long
Dim bg_block_bitmap As Double
Rem /* Inodes bitmap block */ (_le32)
Rem Dim bg_inode_bitmap As Long
Dim bg_inode_bitmap As Double
Rem /* Inodes table block */ (_le32)
Rem Dim bg_inode_table As Long
Dim bg_inode_table As Double
Rem /* Free blocks count */ (_le16)
Dim bg_free_blocks_count As Long
Rem /* Free inodes count */ (_le16)
Dim bg_free_inodes_count As Long
Rem /* Directories count */ (_le16)
Dim bg_used_dirs_count As Long
Rem Reserved (_u16)
Dim bg_pad As Long
Rem bg_flags (_le16) Ext4
Dim bg_flags As Long
Rem Reserved (_le32)
Dim bg_reserved(1 To 3) As Long
Rem /* Unused inodes count */ (_le16) Ext4
Dim bg_itable_unused As Long
Rem /* crc16(sb_uuid+group+desc) */ (_le16) Ext4
Dim bg_checksum As Long
Dim S1 As Long
Dim S2 As Long
Dim S3 As Long
Dim S4 As Double

Private Sub cmdFirst_Click()
N = 0
Call GRP_Desc_Table_Show(N)
End Sub

Private Sub cmdLast_Click()
If Option1.Value = True Then
   N = 480
Else
   N = 448
End If
Call GRP_Desc_Table_Show(N)
End Sub

Private Sub cmdNext_Click()
If Option1.Value = True Then
   If N < 480 Then N = N + 32
Else
   If N Mod 64 = 0 Then
      If N < 448 Then N = N + 64
   Else
      N = N + 32
   End If
End If
Call GRP_Desc_Table_Show(N)
End Sub

Private Sub cmdPrev_Click()
If Option1.Value = True Then
   If N >= 32 Then N = N - 32
Else
   If N Mod 64 = 0 Then
      If N >= 64 Then N = N - 64
   Else
      N = N - 32
   End If
End If
Call GRP_Desc_Table_Show(N)
End Sub

Private Sub Form_Load()
Label22.Caption = DRV
Label18.Caption = "Block numbers are from beginning of the file system." + Chr$(13) + Chr$(10) + "See block size and group details on super block " + Chr$(13) + "(1024 bytes after the Linux partition's boot sector)..." + Chr$(13) + Chr$(10) + "The Group Descriptor Table is on the next block after the super block..."
Call GRP_Desc_Table_Show(N)
Label15.Caption = CStr(Sector + CInt((FP - 1) / 512))
Label17.Caption = 0
End Sub

Private Sub Option1_Click()
Call GRP_Desc_Table_Show(N)
End Sub

Private Sub Option2_Click()
Call GRP_Desc_Table_Show(N)
End Sub

Private Sub GRP_Desc_Table_Show(C As Integer)
On Error GoTo Hata
Label15.Caption = CStr(Sector + CInt((FP - 1) / 512))
Label17.Caption = CStr(C)
S1 = CLng(BSBuffer(C + 0))
S2 = CLng(BSBuffer(C + 1))
S3 = CLng(BSBuffer(C + 2))
S4 = CLng(BSBuffer(C + 3))
bg_block_bitmap = CLng((S4 * 16777216) + (S3 * 65536) + (S2 * 256) + S1)
Label23(0).Caption = CStr(bg_block_bitmap)
S1 = CLng(BSBuffer(C + 4))
S2 = CLng(BSBuffer(C + 5))
S3 = CLng(BSBuffer(C + 6))
S4 = CLng(BSBuffer(C + 7))
bg_inode_bitmap = (S4 * 16777216) + (S3 * 65536) + (S2 * 256) + S1
Label23(1).Caption = CStr(bg_inode_bitmap)
S1 = CLng(BSBuffer(C + 8))
S2 = CLng(BSBuffer(C + 9))
S3 = CLng(BSBuffer(C + 10))
S4 = CLng(BSBuffer(C + 11))
bg_inode_table = CLng((S4 * 16777216) + (S3 * 65536) + (S2 * 256) + S1)
Label23(2).Caption = CStr(bg_inode_table)
bg_free_blocks_count = CLng(BSBuffer(C + 13))
bg_free_blocks_count = bg_free_blocks_count * 256
bg_free_blocks_count = bg_free_blocks_count + BSBuffer(C + 12)
Label23(3).Caption = CStr(bg_free_blocks_count)
bg_free_inodes_count = CLng(BSBuffer(C + 15) * 256)
bg_free_inodes_count = bg_free_inodes_count + BSBuffer(C + 14)
Label23(4).Caption = CStr(bg_free_inodes_count)
bg_used_dirs_count = CLng(BSBuffer(C + 17))
bg_used_dirs_count = bg_used_dirs_count * 256
bg_used_dirs_count = bg_used_dirs_count + BSBuffer(C + 16)
Label23(5).Caption = CStr(bg_used_dirs_count)
bg_pad = CLng(BSBuffer(C + 19) * 256)
bg_pad = bg_pad + BSBuffer(C + 18)
bg_flags = bg_pad
If Option1.Value = True Then
   Label8.Caption = "Reserved (16 bit) 0:"
   Label23(6).Caption = CStr(bg_pad)
Else
   Label8.Caption = "EXT4_BG_Flags:"
   Label23(6).Caption = CStr(bg_flags) + "   [ " + Hex(bg_flags) + " h ]"
End If
Label23(6).Caption = CStr(bg_pad)
S1 = CLng(BSBuffer(C + 20))
S2 = CLng(BSBuffer(C + 21))
S3 = CLng(BSBuffer(C + 22))
S4 = CLng(BSBuffer(C + 23))
bg_reserved(1) = CLng((S4 * 16777216) + (S3 * 65536) + (S2 * 256) + S1)
Label23(7).Caption = CStr(bg_reserved(1))
S1 = CLng(BSBuffer(C + 24))
S2 = CLng(BSBuffer(C + 25))
S3 = CLng(BSBuffer(C + 26))
S4 = CLng(BSBuffer(C + 27))
bg_reserved(2) = CLng((S4 * 16777216) + (S3 * 65536) + (S2 * 256) + S1)
Label23(8).Caption = CStr(bg_reserved(2))
S1 = CLng(BSBuffer(C + 28))
S2 = CLng(BSBuffer(C + 29))
S3 = CLng(BSBuffer(C + 30))
S4 = CLng(BSBuffer(C + 31))
bg_reserved(3) = CLng((S4 * 16777216) + (S3 * 65536) + (S2 * 256) + S1)
bg_itable_unused = CLng((S2 * 256) + S1)
bg_checksum = CLng((S4 * 256) + S3)
If Option1.Value = True Then
   Label12.Caption = "Reserved (32 bit) 3:"
   Label23(9).Caption = CStr(bg_reserved(3))
   Label13.Caption = ""
   Label23(10).Caption = ""
   Label9.Caption = ""
Else
   Label12.Caption = "Unused Inodes Count:"
   Label23(9).Caption = CStr(bg_itable_unused)
   Label13.Caption = "BG_Checksum:"
   Label23(10).Caption = CStr(bg_checksum)
   Label9.Caption = "NOTE: This table shows the first 32 bit of 64 bit Group Descriptor Entry"
End If
Cikis:
Exit Sub
Hata:
MsgBox ("Group Descriptor Table Entry is Invalid (wrong block) or there is an overflow (very big number) problem..."), 48, "Group Descriptor Table ! ERROR !"
Resume Cikis
End Sub
