File: ddru_ntfscommon.h

package info (click to toggle)
ddrutility 2.8-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 808 kB
  • sloc: ansic: 6,087; sh: 2,412; makefile: 132
file content (173 lines) | stat: -rw-r--r-- 4,121 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
Copyright (C) 2016 Scott Dwyer

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

// version 1.1 20140525
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <getopt.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
#include <stdint.h>
#include <time.h>
#include <sys/time.h>
#include <math.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <iconv.h>

time_t start_time, end_time;

struct timeval tvBegin, tvEnd, tvDiff;

typedef unsigned char BYTE;
typedef uint16_t WORD;
typedef uint32_t DWORD;
typedef int32_t LONG;
typedef int64_t LONGLONG;

union {
  struct {
    char attribute_location[64];
  } raw, *p_raw;
  struct __attribute__ ((__packed__)) {
    DWORD dwType;
    DWORD dwFullLength;
    BYTE uchNonResFlag;
    BYTE uchNameLength;
    WORD wNameOffset;
    WORD wFlags;
    WORD wID;
    union {
      struct {
	DWORD dwLength;
	WORD wAttrOffset;
	BYTE uchIndexedTag;
	BYTE uchPadding;
      } Resident;
      struct {
	LONGLONG n64StartVCN;
	LONGLONG n64EndVCN;
	WORD wDatarunOffset;
	WORD wCompressionSize;
	BYTE uchPadding[4];
	LONGLONG n64AllocSize;
	LONGLONG n64RealSize;
	LONGLONG n64StreamSize;
      } NonResident;
    } Attr;
  } items, *p_items;
} ntfs_attribute, *p_ntfs_attribute;

union {
  struct {
    char mftfile[65336];
  } raw, *p_raw;
  struct __attribute__ ((__packed__)) {
    char chFileSignature[4];
    WORD wFixupOffset;
    WORD wFixupSize;
    LONGLONG n64LogSeqNumber;
    WORD wSequence;
    WORD wHardLinks;
    WORD wAttribOffset;
    WORD wFlags;
    DWORD dwRecLength;
    DWORD dwAllLength;
    LONGLONG n64BaseMftRec;
    WORD wNextAttrID;
    WORD wUnknown;
    DWORD dwMFTRecNumber;
    WORD wFixupPattern; // next byte is at offset 460
    WORD wFixupCheck[32738];
  } items, *p_items;
} mft_mft, *p_mft_mft;

union {
  struct {
    char bootsectfile[512];
  } raw, *p_raw;
  struct __attribute__ ((__packed__)) {
    char chJumpInstruction[3];
    char chOemID[4];
    char chDummy[4];
    WORD wBytesPerSec;
    BYTE uchSecPerClust;
    WORD wReservedSec;
    BYTE uchReserved[3];
    WORD wUnused1;
    BYTE uchMediaDescriptor;
    WORD wUnused2;
    WORD wSecPerTrack;
    WORD wNumberOfHeads;
    DWORD dwHiddenSec;
    DWORD dwUnused3;
    DWORD dwUnused4;
    LONGLONG n64TotalSec;
    LONGLONG n64MFTLogicalClustNum; // ( cluster for MFT
    LONGLONG n64MFTMirrLogicalClustNum;
    LONG nClustPerMFTRecord;
    LONG nClustPerIndexRecord;
    LONGLONG n64VolumeSerialNum;
    DWORD dwChecksum;
    char chBootstrapCode[426];
    WORD wSecMark;
  } items, *p_items;
}boot_sector, *p_boot_sector;

union {
  struct {
    char filenamedata[576];
  } raw, *p_raw;
  struct __attribute__ ((__packed__)) {
    uint32_t dwParentDirectory;
    int32_t UnusedPartOfParentDirectory;
    int64_t n64DAteCreated;
    int64_t n64DateModified;
    int64_t n64DateMFTModified;
    int64_t n64DateAccessed;
    int64_t n64LogicalFileSize;
    int64_t n64SizeOnDisk;
    int32_t Flags;
    int32_t ReparseValue;
    unsigned char NameLength;
    unsigned char NameType;
    uint8_t Name[510];
  } items, *p_items;
}file_attribute, *p_fileattribute;



unsigned long inode_count;
char *outtype;
char *inchar;
char *inchar_start;
char *converted;
char *converted_start;
iconv_t cd;
bool no_convert;
char file_name[1024];
unsigned long mft_record_size;
unsigned char file_name_type;
int getname(unsigned long offset);