dmi: check both the AC and ID flags at the same time
[syslinux.git] / win / ntfssect.h
blobf260af02231f1a94f241d886f17dede8b7893b1a
1 /* -------------------------------------------------------------------------- *
3 * Copyright 2011 Shao Miller - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ------------------------------------------------------------------------- */
12 #ifndef M_NTFSSECT_H_
14 /****
15 * ntfssect.h
17 * Fetch NTFS file cluster & sector information via Windows
19 * With special thanks to Mark Roddy for his article:
20 * http://www.wd-3.com/archive/luserland.htm
23 /*** Macros */
24 #define M_NTFSSECT_H_
25 #define M_NTFSSECT_API
27 /*** Object types */
29 /* An "extent;" a contiguous range of file data */
30 typedef struct S_NTFSSECT_EXTENT_ S_NTFSSECT_EXTENT;
32 /* Volume info relevant to file cluster & sector info */
33 typedef struct S_NTFSSECT_VOLINFO_ S_NTFSSECT_VOLINFO;
35 /* Stores function pointers to some Windows functions */
36 typedef struct S_NTFSSECT_XPFUNCS_ S_NTFSSECT_XPFUNCS;
38 /*** Function types */
40 /* The function type for Kernel32.dll's GetDiskFreeSpace() */
41 typedef BOOL WINAPI F_KERNEL32_GETDISKFREESPACE(
42 LPCSTR,
43 LPDWORD,
44 LPDWORD,
45 LPDWORD,
46 LPDWORD
49 /* The function type for Kernel32.dll's GetVolumePathName() */
50 typedef BOOL WINAPI F_KERNEL32_GETVOLUMEPATHNAME(LPCSTR, LPCSTR, DWORD);
52 /*** Function declarations */
54 /**
55 * Fetch the extent containing a particular VCN
57 * @v File
58 * @v Vcn
59 * @v Extent
60 * @ret DWORD
62 DWORD M_NTFSSECT_API NtfsSectGetFileVcnExtent(
63 HANDLE File,
64 LARGE_INTEGER * Vcn,
65 S_NTFSSECT_EXTENT * Extent
68 /**
69 * Populate a volume info object
71 * @v VolumeName
72 * @v VolumeInfo
73 * @ret DWORD
75 DWORD M_NTFSSECT_API NtfsSectGetVolumeInfo(
76 CHAR * VolumeName,
77 S_NTFSSECT_VOLINFO * VolumeInfo
80 /**
81 * Populate a volume info object
83 * @v FileName
84 * @v VolumeInfo
85 * @ret DWORD
87 DWORD M_NTFSSECT_API NtfsSectGetVolumeInfoFromFileName(
88 CHAR * FileName,
89 S_NTFSSECT_VOLINFO * VolumeInfo
92 /**
93 * Convert a volume LCN to an absolute disk LBA
95 * @v VolumeInfo
96 * @v Lcn
97 * @v Lba
98 * @ret DWORD
100 DWORD M_NTFSSECT_API NtfsSectLcnToLba(
101 const S_NTFSSECT_VOLINFO * VolumeInfo,
102 const LARGE_INTEGER * Lcn,
103 LARGE_INTEGER * Lba
107 * Load some helper XP functions
109 * @v XpFuncs
110 * @ret DWORD
112 DWORD M_NTFSSECT_API NtfsSectLoadXpFuncs(S_NTFSSECT_XPFUNCS * XpFuncs);
115 * Unload some helper XP functions
117 * @v XpFuncs
118 * @ret DWORD
120 VOID M_NTFSSECT_API NtfsSectUnloadXpFuncs(S_NTFSSECT_XPFUNCS * XpFuncs);
122 /*** Object declarations */
125 * The last error message set by one of our functions.
126 * Obviously not per-thread
128 extern CHAR * NtfsSectLastErrorMessage;
130 /*** Struct/union definitions */
131 struct S_NTFSSECT_EXTENT_ {
132 LARGE_INTEGER FirstVcn;
133 LARGE_INTEGER NextVcn;
134 LARGE_INTEGER FirstLcn;
137 struct S_NTFSSECT_VOLINFO_ {
138 DWORD Size;
139 HANDLE Handle;
140 DWORD BytesPerSector;
141 DWORD SectorsPerCluster;
142 LARGE_INTEGER PartitionLba;
145 struct S_NTFSSECT_XPFUNCS_ {
146 DWORD Size;
147 HMODULE Kernel32;
148 F_KERNEL32_GETVOLUMEPATHNAME * GetVolumePathName;
149 F_KERNEL32_GETDISKFREESPACE * GetDiskFreeSpace;
152 #endif /* M_NTFSSECT_H_ */