WinIoCtl.h 117 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452
  1. /*++ BUILD Version: 0015 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. winioctl.h
  5. Abstract:
  6. This module defines the 32-Bit Windows Device I/O control codes.
  7. Revision History:
  8. --*/
  9. //
  10. // Device interface class GUIDs.
  11. //
  12. // need these GUIDs outside conditional includes so that user can
  13. // #include <winioctl.h> in precompiled header
  14. // #include <initguid.h> in a single source file
  15. // #include <winioctl.h> in that source file a second time to instantiate the GUIDs
  16. //
  17. #ifdef DEFINE_GUID
  18. //
  19. // Make sure FAR is defined...
  20. //
  21. #ifndef FAR
  22. #ifdef _WIN32
  23. #define FAR
  24. #else
  25. #define FAR _far
  26. #endif
  27. #endif
  28. DEFINE_GUID(GUID_DEVINTERFACE_DISK, 0x53f56307L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  29. DEFINE_GUID(GUID_DEVINTERFACE_CDROM, 0x53f56308L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  30. DEFINE_GUID(GUID_DEVINTERFACE_PARTITION, 0x53f5630aL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  31. DEFINE_GUID(GUID_DEVINTERFACE_TAPE, 0x53f5630bL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  32. DEFINE_GUID(GUID_DEVINTERFACE_WRITEONCEDISK, 0x53f5630cL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  33. DEFINE_GUID(GUID_DEVINTERFACE_VOLUME, 0x53f5630dL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  34. DEFINE_GUID(GUID_DEVINTERFACE_MEDIUMCHANGER, 0x53f56310L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  35. DEFINE_GUID(GUID_DEVINTERFACE_FLOPPY, 0x53f56311L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  36. DEFINE_GUID(GUID_DEVINTERFACE_CDCHANGER, 0x53f56312L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  37. DEFINE_GUID(GUID_DEVINTERFACE_STORAGEPORT, 0x2accfe60L, 0xc130, 0x11d2, 0xb0, 0x82, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  38. DEFINE_GUID(GUID_DEVINTERFACE_COMPORT, 0x86e0d1e0L, 0x8089, 0x11d0, 0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73);
  39. DEFINE_GUID(GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR, 0x4D36E978L, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
  40. //
  41. // Obsolete device interface class GUID names.
  42. // (use of above GUID_DEVINTERFACE_* names is recommended).
  43. //
  44. #define DiskClassGuid GUID_DEVINTERFACE_DISK
  45. #define CdRomClassGuid GUID_DEVINTERFACE_CDROM
  46. #define PartitionClassGuid GUID_DEVINTERFACE_PARTITION
  47. #define TapeClassGuid GUID_DEVINTERFACE_TAPE
  48. #define WriteOnceDiskClassGuid GUID_DEVINTERFACE_WRITEONCEDISK
  49. #define VolumeClassGuid GUID_DEVINTERFACE_VOLUME
  50. #define MediumChangerClassGuid GUID_DEVINTERFACE_MEDIUMCHANGER
  51. #define FloppyClassGuid GUID_DEVINTERFACE_FLOPPY
  52. #define CdChangerClassGuid GUID_DEVINTERFACE_CDCHANGER
  53. #define StoragePortClassGuid GUID_DEVINTERFACE_STORAGEPORT
  54. #define GUID_CLASS_COMPORT GUID_DEVINTERFACE_COMPORT
  55. #define GUID_SERENUM_BUS_ENUMERATOR GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR
  56. #endif // DEFINE_GUID
  57. #ifndef _WINIOCTL_
  58. #define _WINIOCTL_
  59. #ifndef _DEVIOCTL_
  60. #define _DEVIOCTL_
  61. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  62. //
  63. // Define the various device type values. Note that values used by Microsoft
  64. // Corporation are in the range 0-32767, and 32768-65535 are reserved for use
  65. // by customers.
  66. //
  67. #define DEVICE_TYPE DWORD
  68. #define FILE_DEVICE_BEEP 0x00000001
  69. #define FILE_DEVICE_CD_ROM 0x00000002
  70. #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
  71. #define FILE_DEVICE_CONTROLLER 0x00000004
  72. #define FILE_DEVICE_DATALINK 0x00000005
  73. #define FILE_DEVICE_DFS 0x00000006
  74. #define FILE_DEVICE_DISK 0x00000007
  75. #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
  76. #define FILE_DEVICE_FILE_SYSTEM 0x00000009
  77. #define FILE_DEVICE_INPORT_PORT 0x0000000a
  78. #define FILE_DEVICE_KEYBOARD 0x0000000b
  79. #define FILE_DEVICE_MAILSLOT 0x0000000c
  80. #define FILE_DEVICE_MIDI_IN 0x0000000d
  81. #define FILE_DEVICE_MIDI_OUT 0x0000000e
  82. #define FILE_DEVICE_MOUSE 0x0000000f
  83. #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
  84. #define FILE_DEVICE_NAMED_PIPE 0x00000011
  85. #define FILE_DEVICE_NETWORK 0x00000012
  86. #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
  87. #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
  88. #define FILE_DEVICE_NULL 0x00000015
  89. #define FILE_DEVICE_PARALLEL_PORT 0x00000016
  90. #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
  91. #define FILE_DEVICE_PRINTER 0x00000018
  92. #define FILE_DEVICE_SCANNER 0x00000019
  93. #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
  94. #define FILE_DEVICE_SERIAL_PORT 0x0000001b
  95. #define FILE_DEVICE_SCREEN 0x0000001c
  96. #define FILE_DEVICE_SOUND 0x0000001d
  97. #define FILE_DEVICE_STREAMS 0x0000001e
  98. #define FILE_DEVICE_TAPE 0x0000001f
  99. #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
  100. #define FILE_DEVICE_TRANSPORT 0x00000021
  101. #define FILE_DEVICE_UNKNOWN 0x00000022
  102. #define FILE_DEVICE_VIDEO 0x00000023
  103. #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
  104. #define FILE_DEVICE_WAVE_IN 0x00000025
  105. #define FILE_DEVICE_WAVE_OUT 0x00000026
  106. #define FILE_DEVICE_8042_PORT 0x00000027
  107. #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
  108. #define FILE_DEVICE_BATTERY 0x00000029
  109. #define FILE_DEVICE_BUS_EXTENDER 0x0000002a
  110. #define FILE_DEVICE_MODEM 0x0000002b
  111. #define FILE_DEVICE_VDM 0x0000002c
  112. #define FILE_DEVICE_MASS_STORAGE 0x0000002d
  113. #define FILE_DEVICE_SMB 0x0000002e
  114. #define FILE_DEVICE_KS 0x0000002f
  115. #define FILE_DEVICE_CHANGER 0x00000030
  116. #define FILE_DEVICE_SMARTCARD 0x00000031
  117. #define FILE_DEVICE_ACPI 0x00000032
  118. #define FILE_DEVICE_DVD 0x00000033
  119. #define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
  120. #define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
  121. #define FILE_DEVICE_DFS_VOLUME 0x00000036
  122. #define FILE_DEVICE_SERENUM 0x00000037
  123. #define FILE_DEVICE_TERMSRV 0x00000038
  124. #define FILE_DEVICE_KSEC 0x00000039
  125. #define FILE_DEVICE_FIPS 0x0000003A
  126. //
  127. // Macro definition for defining IOCTL and FSCTL function control codes. Note
  128. // that function codes 0-2047 are reserved for Microsoft Corporation, and
  129. // 2048-4095 are reserved for customers.
  130. //
  131. #define CTL_CODE( DeviceType, Function, Method, Access ) ( \
  132. ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
  133. )
  134. //
  135. // Macro to extract device type out of the device io control code
  136. //
  137. #define DEVICE_TYPE_FROM_CTL_CODE(ctrlCode) (((DWORD)(ctrlCode & 0xffff0000)) >> 16)
  138. //
  139. // Define the method codes for how buffers are passed for I/O and FS controls
  140. //
  141. #define METHOD_BUFFERED 0
  142. #define METHOD_IN_DIRECT 1
  143. #define METHOD_OUT_DIRECT 2
  144. #define METHOD_NEITHER 3
  145. //
  146. // Define the access check value for any access
  147. //
  148. //
  149. // The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
  150. // ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
  151. // constants *MUST* always be in sync.
  152. //
  153. //
  154. // FILE_SPECIAL_ACCESS is checked by the NT I/O system the same as FILE_ANY_ACCESS.
  155. // The file systems, however, may add additional access checks for I/O and FS controls
  156. // that use this value.
  157. //
  158. #define FILE_ANY_ACCESS 0
  159. #define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS)
  160. #define FILE_READ_ACCESS ( 0x0001 ) // file & pipe
  161. #define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe
  162. // end_ntddk end_wdm end_nthal end_ntifs
  163. #endif // _DEVIOCTL_
  164. #ifndef _NTDDSTOR_H_
  165. #define _NTDDSTOR_H_
  166. #ifdef __cplusplus
  167. extern "C" {
  168. #endif
  169. //
  170. // IoControlCode values for storage devices
  171. //
  172. #define IOCTL_STORAGE_BASE FILE_DEVICE_MASS_STORAGE
  173. //
  174. // The following device control codes are common for all class drivers. They
  175. // should be used in place of the older IOCTL_DISK, IOCTL_CDROM and IOCTL_TAPE
  176. // common codes
  177. //
  178. #define IOCTL_STORAGE_CHECK_VERIFY CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  179. #define IOCTL_STORAGE_CHECK_VERIFY2 CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_ANY_ACCESS)
  180. #define IOCTL_STORAGE_MEDIA_REMOVAL CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  181. #define IOCTL_STORAGE_EJECT_MEDIA CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  182. #define IOCTL_STORAGE_LOAD_MEDIA CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  183. #define IOCTL_STORAGE_LOAD_MEDIA2 CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_ANY_ACCESS)
  184. #define IOCTL_STORAGE_RESERVE CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  185. #define IOCTL_STORAGE_RELEASE CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  186. #define IOCTL_STORAGE_FIND_NEW_DEVICES CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  187. #define IOCTL_STORAGE_EJECTION_CONTROL CTL_CODE(IOCTL_STORAGE_BASE, 0x0250, METHOD_BUFFERED, FILE_ANY_ACCESS)
  188. #define IOCTL_STORAGE_MCN_CONTROL CTL_CODE(IOCTL_STORAGE_BASE, 0x0251, METHOD_BUFFERED, FILE_ANY_ACCESS)
  189. #define IOCTL_STORAGE_GET_MEDIA_TYPES CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  190. #define IOCTL_STORAGE_GET_MEDIA_TYPES_EX CTL_CODE(IOCTL_STORAGE_BASE, 0x0301, METHOD_BUFFERED, FILE_ANY_ACCESS)
  191. #define IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER CTL_CODE(IOCTL_STORAGE_BASE, 0x0304, METHOD_BUFFERED, FILE_ANY_ACCESS)
  192. #define IOCTL_STORAGE_GET_HOTPLUG_INFO CTL_CODE(IOCTL_STORAGE_BASE, 0x0305, METHOD_BUFFERED, FILE_ANY_ACCESS)
  193. #define IOCTL_STORAGE_SET_HOTPLUG_INFO CTL_CODE(IOCTL_STORAGE_BASE, 0x0306, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  194. #define IOCTL_STORAGE_RESET_BUS CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
  195. #define IOCTL_STORAGE_RESET_DEVICE CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
  196. #define IOCTL_STORAGE_BREAK_RESERVATION CTL_CODE(IOCTL_STORAGE_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS)
  197. #define IOCTL_STORAGE_GET_DEVICE_NUMBER CTL_CODE(IOCTL_STORAGE_BASE, 0x0420, METHOD_BUFFERED, FILE_ANY_ACCESS)
  198. #define IOCTL_STORAGE_PREDICT_FAILURE CTL_CODE(IOCTL_STORAGE_BASE, 0x0440, METHOD_BUFFERED, FILE_ANY_ACCESS)
  199. //
  200. // These ioctl codes are obsolete. They are defined here to avoid resuing them
  201. // and to allow class drivers to respond to them more easily.
  202. //
  203. #define OBSOLETE_IOCTL_STORAGE_RESET_BUS CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  204. #define OBSOLETE_IOCTL_STORAGE_RESET_DEVICE CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  205. //
  206. // IOCTL_STORAGE_GET_HOTPLUG_INFO
  207. //
  208. typedef struct _STORAGE_HOTPLUG_INFO {
  209. DWORD Size; // version
  210. BOOLEAN MediaRemovable; // ie. zip, jaz, cdrom, mo, etc. vs hdd
  211. BOOLEAN MediaHotplug; // ie. does the device succeed a lock even though its not lockable media?
  212. BOOLEAN DeviceHotplug; // ie. 1394, USB, etc.
  213. BOOLEAN WriteCacheEnableOverride; // This field should not be relied upon because it is no longer used
  214. } STORAGE_HOTPLUG_INFO, *PSTORAGE_HOTPLUG_INFO;
  215. //
  216. // IOCTL_STORAGE_GET_DEVICE_NUMBER
  217. //
  218. // input - none
  219. //
  220. // output - STORAGE_DEVICE_NUMBER structure
  221. // The values in the STORAGE_DEVICE_NUMBER structure are guaranteed
  222. // to remain unchanged until the system is rebooted. They are not
  223. // guaranteed to be persistant across boots.
  224. //
  225. typedef struct _STORAGE_DEVICE_NUMBER {
  226. //
  227. // The FILE_DEVICE_XXX type for this device.
  228. //
  229. DEVICE_TYPE DeviceType;
  230. //
  231. // The number of this device
  232. //
  233. DWORD DeviceNumber;
  234. //
  235. // If the device is partitionable, the partition number of the device.
  236. // Otherwise -1
  237. //
  238. DWORD PartitionNumber;
  239. } STORAGE_DEVICE_NUMBER, *PSTORAGE_DEVICE_NUMBER;
  240. //
  241. // Define the structures for scsi resets
  242. //
  243. typedef struct _STORAGE_BUS_RESET_REQUEST {
  244. BYTE PathId;
  245. } STORAGE_BUS_RESET_REQUEST, *PSTORAGE_BUS_RESET_REQUEST;
  246. //
  247. // IOCTL_STORAGE_MEDIA_REMOVAL disables the mechanism
  248. // on a storage device that ejects media. This function
  249. // may or may not be supported on storage devices that
  250. // support removable media.
  251. //
  252. // TRUE means prevent media from being removed.
  253. // FALSE means allow media removal.
  254. //
  255. typedef struct _PREVENT_MEDIA_REMOVAL {
  256. BOOLEAN PreventMediaRemoval;
  257. } PREVENT_MEDIA_REMOVAL, *PPREVENT_MEDIA_REMOVAL;
  258. // begin_ntminitape
  259. typedef struct _TAPE_STATISTICS {
  260. DWORD Version;
  261. DWORD Flags;
  262. LARGE_INTEGER RecoveredWrites;
  263. LARGE_INTEGER UnrecoveredWrites;
  264. LARGE_INTEGER RecoveredReads;
  265. LARGE_INTEGER UnrecoveredReads;
  266. BYTE CompressionRatioReads;
  267. BYTE CompressionRatioWrites;
  268. } TAPE_STATISTICS, *PTAPE_STATISTICS;
  269. #define RECOVERED_WRITES_VALID 0x00000001
  270. #define UNRECOVERED_WRITES_VALID 0x00000002
  271. #define RECOVERED_READS_VALID 0x00000004
  272. #define UNRECOVERED_READS_VALID 0x00000008
  273. #define WRITE_COMPRESSION_INFO_VALID 0x00000010
  274. #define READ_COMPRESSION_INFO_VALID 0x00000020
  275. typedef struct _TAPE_GET_STATISTICS {
  276. DWORD Operation;
  277. } TAPE_GET_STATISTICS, *PTAPE_GET_STATISTICS;
  278. #define TAPE_RETURN_STATISTICS 0L
  279. #define TAPE_RETURN_ENV_INFO 1L
  280. #define TAPE_RESET_STATISTICS 2L
  281. //
  282. // IOCTL_STORAGE_GET_MEDIA_TYPES_EX will return an array of DEVICE_MEDIA_INFO
  283. // structures, one per supported type, embedded in the GET_MEDIA_TYPES struct.
  284. //
  285. typedef enum _STORAGE_MEDIA_TYPE {
  286. //
  287. // Following are defined in ntdddisk.h in the MEDIA_TYPE enum
  288. //
  289. // Unknown, // Format is unknown
  290. // F5_1Pt2_512, // 5.25", 1.2MB, 512 bytes/sector
  291. // F3_1Pt44_512, // 3.5", 1.44MB, 512 bytes/sector
  292. // F3_2Pt88_512, // 3.5", 2.88MB, 512 bytes/sector
  293. // F3_20Pt8_512, // 3.5", 20.8MB, 512 bytes/sector
  294. // F3_720_512, // 3.5", 720KB, 512 bytes/sector
  295. // F5_360_512, // 5.25", 360KB, 512 bytes/sector
  296. // F5_320_512, // 5.25", 320KB, 512 bytes/sector
  297. // F5_320_1024, // 5.25", 320KB, 1024 bytes/sector
  298. // F5_180_512, // 5.25", 180KB, 512 bytes/sector
  299. // F5_160_512, // 5.25", 160KB, 512 bytes/sector
  300. // RemovableMedia, // Removable media other than floppy
  301. // FixedMedia, // Fixed hard disk media
  302. // F3_120M_512, // 3.5", 120M Floppy
  303. // F3_640_512, // 3.5" , 640KB, 512 bytes/sector
  304. // F5_640_512, // 5.25", 640KB, 512 bytes/sector
  305. // F5_720_512, // 5.25", 720KB, 512 bytes/sector
  306. // F3_1Pt2_512, // 3.5" , 1.2Mb, 512 bytes/sector
  307. // F3_1Pt23_1024, // 3.5" , 1.23Mb, 1024 bytes/sector
  308. // F5_1Pt23_1024, // 5.25", 1.23MB, 1024 bytes/sector
  309. // F3_128Mb_512, // 3.5" MO 128Mb 512 bytes/sector
  310. // F3_230Mb_512, // 3.5" MO 230Mb 512 bytes/sector
  311. // F8_256_128, // 8", 256KB, 128 bytes/sector
  312. // F3_200Mb_512, // 3.5", 200M Floppy (HiFD)
  313. //
  314. DDS_4mm = 0x20, // Tape - DAT DDS1,2,... (all vendors)
  315. MiniQic, // Tape - miniQIC Tape
  316. Travan, // Tape - Travan TR-1,2,3,...
  317. QIC, // Tape - QIC
  318. MP_8mm, // Tape - 8mm Exabyte Metal Particle
  319. AME_8mm, // Tape - 8mm Exabyte Advanced Metal Evap
  320. AIT1_8mm, // Tape - 8mm Sony AIT
  321. DLT, // Tape - DLT Compact IIIxt, IV
  322. NCTP, // Tape - Philips NCTP
  323. IBM_3480, // Tape - IBM 3480
  324. IBM_3490E, // Tape - IBM 3490E
  325. IBM_Magstar_3590, // Tape - IBM Magstar 3590
  326. IBM_Magstar_MP, // Tape - IBM Magstar MP
  327. STK_DATA_D3, // Tape - STK Data D3
  328. SONY_DTF, // Tape - Sony DTF
  329. DV_6mm, // Tape - 6mm Digital Video
  330. DMI, // Tape - Exabyte DMI and compatibles
  331. SONY_D2, // Tape - Sony D2S and D2L
  332. CLEANER_CARTRIDGE, // Cleaner - All Drive types that support Drive Cleaners
  333. CD_ROM, // Opt_Disk - CD
  334. CD_R, // Opt_Disk - CD-Recordable (Write Once)
  335. CD_RW, // Opt_Disk - CD-Rewriteable
  336. DVD_ROM, // Opt_Disk - DVD-ROM
  337. DVD_R, // Opt_Disk - DVD-Recordable (Write Once)
  338. DVD_RW, // Opt_Disk - DVD-Rewriteable
  339. MO_3_RW, // Opt_Disk - 3.5" Rewriteable MO Disk
  340. MO_5_WO, // Opt_Disk - MO 5.25" Write Once
  341. MO_5_RW, // Opt_Disk - MO 5.25" Rewriteable (not LIMDOW)
  342. MO_5_LIMDOW, // Opt_Disk - MO 5.25" Rewriteable (LIMDOW)
  343. PC_5_WO, // Opt_Disk - Phase Change 5.25" Write Once Optical
  344. PC_5_RW, // Opt_Disk - Phase Change 5.25" Rewriteable
  345. PD_5_RW, // Opt_Disk - PhaseChange Dual Rewriteable
  346. ABL_5_WO, // Opt_Disk - Ablative 5.25" Write Once Optical
  347. PINNACLE_APEX_5_RW, // Opt_Disk - Pinnacle Apex 4.6GB Rewriteable Optical
  348. SONY_12_WO, // Opt_Disk - Sony 12" Write Once
  349. PHILIPS_12_WO, // Opt_Disk - Philips/LMS 12" Write Once
  350. HITACHI_12_WO, // Opt_Disk - Hitachi 12" Write Once
  351. CYGNET_12_WO, // Opt_Disk - Cygnet/ATG 12" Write Once
  352. KODAK_14_WO, // Opt_Disk - Kodak 14" Write Once
  353. MO_NFR_525, // Opt_Disk - Near Field Recording (Terastor)
  354. NIKON_12_RW, // Opt_Disk - Nikon 12" Rewriteable
  355. IOMEGA_ZIP, // Mag_Disk - Iomega Zip
  356. IOMEGA_JAZ, // Mag_Disk - Iomega Jaz
  357. SYQUEST_EZ135, // Mag_Disk - Syquest EZ135
  358. SYQUEST_EZFLYER, // Mag_Disk - Syquest EzFlyer
  359. SYQUEST_SYJET, // Mag_Disk - Syquest SyJet
  360. AVATAR_F2, // Mag_Disk - 2.5" Floppy
  361. MP2_8mm, // Tape - 8mm Hitachi
  362. DST_S, // Ampex DST Small Tapes
  363. DST_M, // Ampex DST Medium Tapes
  364. DST_L, // Ampex DST Large Tapes
  365. VXATape_1, // Ecrix 8mm Tape
  366. VXATape_2, // Ecrix 8mm Tape
  367. STK_9840, // STK 9840
  368. LTO_Ultrium, // IBM, HP, Seagate LTO Ultrium
  369. LTO_Accelis, // IBM, HP, Seagate LTO Accelis
  370. DVD_RAM, // Opt_Disk - DVD-RAM
  371. AIT_8mm, // AIT2 or higher
  372. ADR_1, // OnStream ADR Mediatypes
  373. ADR_2,
  374. STK_9940, // STK 9940
  375. SAIT // SAIT Tapes
  376. } STORAGE_MEDIA_TYPE, *PSTORAGE_MEDIA_TYPE;
  377. #define MEDIA_ERASEABLE 0x00000001
  378. #define MEDIA_WRITE_ONCE 0x00000002
  379. #define MEDIA_READ_ONLY 0x00000004
  380. #define MEDIA_READ_WRITE 0x00000008
  381. #define MEDIA_WRITE_PROTECTED 0x00000100
  382. #define MEDIA_CURRENTLY_MOUNTED 0x80000000
  383. //
  384. // Define the different storage bus types
  385. // Bus types below 128 (0x80) are reserved for Microsoft use
  386. //
  387. typedef enum _STORAGE_BUS_TYPE {
  388. BusTypeUnknown = 0x00,
  389. BusTypeScsi,
  390. BusTypeAtapi,
  391. BusTypeAta,
  392. BusType1394,
  393. BusTypeSsa,
  394. BusTypeFibre,
  395. BusTypeUsb,
  396. BusTypeRAID,
  397. BusTypeMaxReserved = 0x7F
  398. } STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE;
  399. typedef struct _DEVICE_MEDIA_INFO {
  400. union {
  401. struct {
  402. LARGE_INTEGER Cylinders;
  403. STORAGE_MEDIA_TYPE MediaType;
  404. DWORD TracksPerCylinder;
  405. DWORD SectorsPerTrack;
  406. DWORD BytesPerSector;
  407. DWORD NumberMediaSides;
  408. DWORD MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  409. } DiskInfo;
  410. struct {
  411. LARGE_INTEGER Cylinders;
  412. STORAGE_MEDIA_TYPE MediaType;
  413. DWORD TracksPerCylinder;
  414. DWORD SectorsPerTrack;
  415. DWORD BytesPerSector;
  416. DWORD NumberMediaSides;
  417. DWORD MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  418. } RemovableDiskInfo;
  419. struct {
  420. STORAGE_MEDIA_TYPE MediaType;
  421. DWORD MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  422. DWORD CurrentBlockSize;
  423. STORAGE_BUS_TYPE BusType;
  424. //
  425. // Bus specific information describing the medium supported.
  426. //
  427. union {
  428. struct {
  429. BYTE MediumType;
  430. BYTE DensityCode;
  431. } ScsiInformation;
  432. } BusSpecificData;
  433. } TapeInfo;
  434. } DeviceSpecific;
  435. } DEVICE_MEDIA_INFO, *PDEVICE_MEDIA_INFO;
  436. typedef struct _GET_MEDIA_TYPES {
  437. DWORD DeviceType; // FILE_DEVICE_XXX values
  438. DWORD MediaInfoCount;
  439. DEVICE_MEDIA_INFO MediaInfo[1];
  440. } GET_MEDIA_TYPES, *PGET_MEDIA_TYPES;
  441. //
  442. // IOCTL_STORAGE_PREDICT_FAILURE
  443. //
  444. // input - none
  445. //
  446. // output - STORAGE_PREDICT_FAILURE structure
  447. // PredictFailure returns zero if no failure predicted and non zero
  448. // if a failure is predicted.
  449. //
  450. // VendorSpecific returns 512 bytes of vendor specific information
  451. // if a failure is predicted
  452. //
  453. typedef struct _STORAGE_PREDICT_FAILURE
  454. {
  455. DWORD PredictFailure;
  456. BYTE VendorSpecific[512];
  457. } STORAGE_PREDICT_FAILURE, *PSTORAGE_PREDICT_FAILURE;
  458. // end_ntminitape
  459. #ifdef __cplusplus
  460. }
  461. #endif
  462. #endif // _NTDDSTOR_H_
  463. //
  464. // IoControlCode values for disk devices.
  465. //
  466. #define IOCTL_DISK_BASE FILE_DEVICE_DISK
  467. #define IOCTL_DISK_GET_DRIVE_GEOMETRY CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)
  468. #define IOCTL_DISK_GET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
  469. #define IOCTL_DISK_SET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  470. #define IOCTL_DISK_GET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
  471. #define IOCTL_DISK_SET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  472. #define IOCTL_DISK_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS)
  473. #define IOCTL_DISK_FORMAT_TRACKS CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  474. #define IOCTL_DISK_REASSIGN_BLOCKS CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  475. #define IOCTL_DISK_PERFORMANCE CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
  476. #define IOCTL_DISK_IS_WRITABLE CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS)
  477. #define IOCTL_DISK_LOGGING CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS)
  478. #define IOCTL_DISK_FORMAT_TRACKS_EX CTL_CODE(IOCTL_DISK_BASE, 0x000b, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  479. #define IOCTL_DISK_HISTOGRAM_STRUCTURE CTL_CODE(IOCTL_DISK_BASE, 0x000c, METHOD_BUFFERED, FILE_ANY_ACCESS)
  480. #define IOCTL_DISK_HISTOGRAM_DATA CTL_CODE(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, FILE_ANY_ACCESS)
  481. #define IOCTL_DISK_HISTOGRAM_RESET CTL_CODE(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, FILE_ANY_ACCESS)
  482. #define IOCTL_DISK_REQUEST_STRUCTURE CTL_CODE(IOCTL_DISK_BASE, 0x000f, METHOD_BUFFERED, FILE_ANY_ACCESS)
  483. #define IOCTL_DISK_REQUEST_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
  484. #define IOCTL_DISK_PERFORMANCE_OFF CTL_CODE(IOCTL_DISK_BASE, 0x0018, METHOD_BUFFERED, FILE_ANY_ACCESS)
  485. #if(_WIN32_WINNT >= 0x0400)
  486. #define IOCTL_DISK_CONTROLLER_NUMBER CTL_CODE(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS)
  487. //
  488. // IOCTL support for SMART drive fault prediction.
  489. //
  490. #define SMART_GET_VERSION CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS)
  491. #define SMART_SEND_DRIVE_COMMAND CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  492. #define SMART_RCV_DRIVE_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  493. #endif /* _WIN32_WINNT >= 0x0400 */
  494. #if (_WIN32_WINNT >= 0x500)
  495. //
  496. // New IOCTLs for GUID Partition tabled disks.
  497. //
  498. #define IOCTL_DISK_GET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE, 0x0012, METHOD_BUFFERED, FILE_ANY_ACCESS)
  499. #define IOCTL_DISK_SET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  500. #define IOCTL_DISK_GET_DRIVE_LAYOUT_EX CTL_CODE(IOCTL_DISK_BASE, 0x0014, METHOD_BUFFERED, FILE_ANY_ACCESS)
  501. #define IOCTL_DISK_SET_DRIVE_LAYOUT_EX CTL_CODE(IOCTL_DISK_BASE, 0x0015, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  502. #define IOCTL_DISK_CREATE_DISK CTL_CODE(IOCTL_DISK_BASE, 0x0016, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  503. #define IOCTL_DISK_GET_LENGTH_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0017, METHOD_BUFFERED, FILE_READ_ACCESS)
  504. #define IOCTL_DISK_GET_DRIVE_GEOMETRY_EX CTL_CODE(IOCTL_DISK_BASE, 0x0028, METHOD_BUFFERED, FILE_ANY_ACCESS)
  505. #endif /* _WIN32_WINNT >= 0x0500 */
  506. #if(_WIN32_WINNT >= 0x0500)
  507. #define IOCTL_DISK_UPDATE_DRIVE_SIZE CTL_CODE(IOCTL_DISK_BASE, 0x0032, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  508. #define IOCTL_DISK_GROW_PARTITION CTL_CODE(IOCTL_DISK_BASE, 0x0034, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  509. #define IOCTL_DISK_GET_CACHE_INFORMATION CTL_CODE(IOCTL_DISK_BASE, 0x0035, METHOD_BUFFERED, FILE_READ_ACCESS)
  510. #define IOCTL_DISK_SET_CACHE_INFORMATION CTL_CODE(IOCTL_DISK_BASE, 0x0036, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  511. #define IOCTL_DISK_GET_WRITE_CACHE_STATE CTL_CODE(IOCTL_DISK_BASE, 0x0037, METHOD_BUFFERED, FILE_READ_ACCESS)
  512. #define IOCTL_DISK_DELETE_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0040, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  513. //
  514. // Called to flush cached information that the driver may have about this
  515. // device's characteristics. Not all drivers cache characteristics, and not
  516. // cached properties can be flushed. This simply serves as an update to the
  517. // driver that it may want to do an expensive reexamination of the device's
  518. // characteristics now (fixed media size, partition table, etc...)
  519. //
  520. #define IOCTL_DISK_UPDATE_PROPERTIES CTL_CODE(IOCTL_DISK_BASE, 0x0050, METHOD_BUFFERED, FILE_ANY_ACCESS)
  521. //
  522. // Special IOCTLs needed to support PC-98 machines in Japan
  523. //
  524. #define IOCTL_DISK_FORMAT_DRIVE CTL_CODE(IOCTL_DISK_BASE, 0x00f3, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  525. #define IOCTL_DISK_SENSE_DEVICE CTL_CODE(IOCTL_DISK_BASE, 0x00f8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  526. #endif /* _WIN32_WINNT >= 0x0500 */
  527. //
  528. // The following device control codes are common for all class drivers. The
  529. // functions codes defined here must match all of the other class drivers.
  530. //
  531. // Warning: these codes will be replaced in the future by equivalent
  532. // IOCTL_STORAGE codes
  533. //
  534. #define IOCTL_DISK_CHECK_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  535. #define IOCTL_DISK_MEDIA_REMOVAL CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  536. #define IOCTL_DISK_EJECT_MEDIA CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  537. #define IOCTL_DISK_LOAD_MEDIA CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  538. #define IOCTL_DISK_RESERVE CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  539. #define IOCTL_DISK_RELEASE CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  540. #define IOCTL_DISK_FIND_NEW_DEVICES CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  541. #define IOCTL_DISK_GET_MEDIA_TYPES CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  542. //
  543. // Define the partition types returnable by known disk drivers.
  544. //
  545. #define PARTITION_ENTRY_UNUSED 0x00 // Entry unused
  546. #define PARTITION_FAT_12 0x01 // 12-bit FAT entries
  547. #define PARTITION_XENIX_1 0x02 // Xenix
  548. #define PARTITION_XENIX_2 0x03 // Xenix
  549. #define PARTITION_FAT_16 0x04 // 16-bit FAT entries
  550. #define PARTITION_EXTENDED 0x05 // Extended partition entry
  551. #define PARTITION_HUGE 0x06 // Huge partition MS-DOS V4
  552. #define PARTITION_IFS 0x07 // IFS Partition
  553. #define PARTITION_OS2BOOTMGR 0x0A // OS/2 Boot Manager/OPUS/Coherent swap
  554. #define PARTITION_FAT32 0x0B // FAT32
  555. #define PARTITION_FAT32_XINT13 0x0C // FAT32 using extended int13 services
  556. #define PARTITION_XINT13 0x0E // Win95 partition using extended int13 services
  557. #define PARTITION_XINT13_EXTENDED 0x0F // Same as type 5 but uses extended int13 services
  558. #define PARTITION_PREP 0x41 // PowerPC Reference Platform (PReP) Boot Partition
  559. #define PARTITION_LDM 0x42 // Logical Disk Manager partition
  560. #define PARTITION_UNIX 0x63 // Unix
  561. #define VALID_NTFT 0xC0 // NTFT uses high order bits
  562. //
  563. // The high bit of the partition type code indicates that a partition
  564. // is part of an NTFT mirror or striped array.
  565. //
  566. #define PARTITION_NTFT 0x80 // NTFT partition
  567. //
  568. // The following macro is used to determine which partitions should be
  569. // assigned drive letters.
  570. //
  571. //++
  572. //
  573. // BOOLEAN
  574. // IsRecognizedPartition(
  575. // IN DWORD PartitionType
  576. // )
  577. //
  578. // Routine Description:
  579. //
  580. // This macro is used to determine to which partitions drive letters
  581. // should be assigned.
  582. //
  583. // Arguments:
  584. //
  585. // PartitionType - Supplies the type of the partition being examined.
  586. //
  587. // Return Value:
  588. //
  589. // The return value is TRUE if the partition type is recognized,
  590. // otherwise FALSE is returned.
  591. //
  592. //--
  593. #define IsRecognizedPartition( PartitionType ) ( \
  594. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT_12)) || \
  595. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_IFS)) || \
  596. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_HUGE)) || \
  597. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32)) || \
  598. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32_XINT13)) || \
  599. ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_XINT13)) || \
  600. ((PartitionType) == PARTITION_FAT_12) || \
  601. ((PartitionType) == PARTITION_FAT_16) || \
  602. ((PartitionType) == PARTITION_IFS) || \
  603. ((PartitionType) == PARTITION_HUGE) || \
  604. ((PartitionType) == PARTITION_FAT32) || \
  605. ((PartitionType) == PARTITION_FAT32_XINT13) || \
  606. ((PartitionType) == PARTITION_XINT13) )
  607. //++
  608. //
  609. // BOOLEAN
  610. // IsContainerPartition(
  611. // IN DWORD PartitionType
  612. // )
  613. //
  614. // Routine Description:
  615. //
  616. // This macro is used to determine to which partition types are actually
  617. // containers for other partitions (ie, extended partitions).
  618. //
  619. // Arguments:
  620. //
  621. // PartitionType - Supplies the type of the partition being examined.
  622. //
  623. // Return Value:
  624. //
  625. // The return value is TRUE if the partition type is a container,
  626. // otherwise FALSE is returned.
  627. //
  628. //--
  629. #define IsContainerPartition( PartitionType ) \
  630. ((PartitionType == PARTITION_EXTENDED) || (PartitionType == PARTITION_XINT13_EXTENDED))
  631. //++
  632. //
  633. // BOOLEAN
  634. // IsFTPartition(
  635. // IN DWORD PartitionType
  636. // )
  637. //
  638. // Routine Description:
  639. //
  640. // This macro is used to determine if the given partition is an FT
  641. // partition.
  642. //
  643. // Arguments:
  644. //
  645. // PartitionType - Supplies the type of the partition being examined.
  646. //
  647. // Return Value:
  648. //
  649. // The return value is TRUE if the partition type is an FT partition,
  650. // otherwise FALSE is returned.
  651. //
  652. //--
  653. #define IsFTPartition( PartitionType ) \
  654. (((PartitionType)&PARTITION_NTFT) && IsRecognizedPartition(PartitionType))
  655. //
  656. // Define the media types supported by the driver.
  657. //
  658. typedef enum _MEDIA_TYPE {
  659. Unknown, // Format is unknown
  660. F5_1Pt2_512, // 5.25", 1.2MB, 512 bytes/sector
  661. F3_1Pt44_512, // 3.5", 1.44MB, 512 bytes/sector
  662. F3_2Pt88_512, // 3.5", 2.88MB, 512 bytes/sector
  663. F3_20Pt8_512, // 3.5", 20.8MB, 512 bytes/sector
  664. F3_720_512, // 3.5", 720KB, 512 bytes/sector
  665. F5_360_512, // 5.25", 360KB, 512 bytes/sector
  666. F5_320_512, // 5.25", 320KB, 512 bytes/sector
  667. F5_320_1024, // 5.25", 320KB, 1024 bytes/sector
  668. F5_180_512, // 5.25", 180KB, 512 bytes/sector
  669. F5_160_512, // 5.25", 160KB, 512 bytes/sector
  670. RemovableMedia, // Removable media other than floppy
  671. FixedMedia, // Fixed hard disk media
  672. F3_120M_512, // 3.5", 120M Floppy
  673. F3_640_512, // 3.5" , 640KB, 512 bytes/sector
  674. F5_640_512, // 5.25", 640KB, 512 bytes/sector
  675. F5_720_512, // 5.25", 720KB, 512 bytes/sector
  676. F3_1Pt2_512, // 3.5" , 1.2Mb, 512 bytes/sector
  677. F3_1Pt23_1024, // 3.5" , 1.23Mb, 1024 bytes/sector
  678. F5_1Pt23_1024, // 5.25", 1.23MB, 1024 bytes/sector
  679. F3_128Mb_512, // 3.5" MO 128Mb 512 bytes/sector
  680. F3_230Mb_512, // 3.5" MO 230Mb 512 bytes/sector
  681. F8_256_128, // 8", 256KB, 128 bytes/sector
  682. F3_200Mb_512, // 3.5", 200M Floppy (HiFD)
  683. F3_240M_512, // 3.5", 240Mb Floppy (HiFD)
  684. F3_32M_512 // 3.5", 32Mb Floppy
  685. } MEDIA_TYPE, *PMEDIA_TYPE;
  686. //
  687. // Define the input buffer structure for the driver, when
  688. // it is called with IOCTL_DISK_FORMAT_TRACKS.
  689. //
  690. typedef struct _FORMAT_PARAMETERS {
  691. MEDIA_TYPE MediaType;
  692. DWORD StartCylinderNumber;
  693. DWORD EndCylinderNumber;
  694. DWORD StartHeadNumber;
  695. DWORD EndHeadNumber;
  696. } FORMAT_PARAMETERS, *PFORMAT_PARAMETERS;
  697. //
  698. // Define the BAD_TRACK_NUMBER type. An array of elements of this type is
  699. // returned by the driver on IOCTL_DISK_FORMAT_TRACKS requests, to indicate
  700. // what tracks were bad during formatting. The length of that array is
  701. // reported in the `Information' field of the I/O Status Block.
  702. //
  703. typedef WORD BAD_TRACK_NUMBER;
  704. typedef WORD *PBAD_TRACK_NUMBER;
  705. //
  706. // Define the input buffer structure for the driver, when
  707. // it is called with IOCTL_DISK_FORMAT_TRACKS_EX.
  708. //
  709. typedef struct _FORMAT_EX_PARAMETERS {
  710. MEDIA_TYPE MediaType;
  711. DWORD StartCylinderNumber;
  712. DWORD EndCylinderNumber;
  713. DWORD StartHeadNumber;
  714. DWORD EndHeadNumber;
  715. WORD FormatGapLength;
  716. WORD SectorsPerTrack;
  717. WORD SectorNumber[1];
  718. } FORMAT_EX_PARAMETERS, *PFORMAT_EX_PARAMETERS;
  719. //
  720. // The following structure is returned on an IOCTL_DISK_GET_DRIVE_GEOMETRY
  721. // request and an array of them is returned on an IOCTL_DISK_GET_MEDIA_TYPES
  722. // request.
  723. //
  724. typedef struct _DISK_GEOMETRY {
  725. LARGE_INTEGER Cylinders;
  726. MEDIA_TYPE MediaType;
  727. DWORD TracksPerCylinder;
  728. DWORD SectorsPerTrack;
  729. DWORD BytesPerSector;
  730. } DISK_GEOMETRY, *PDISK_GEOMETRY;
  731. //
  732. // This wmi guid returns a DISK_GEOMETRY structure
  733. //
  734. #define WMI_DISK_GEOMETRY_GUID { 0x25007f51, 0x57c2, 0x11d1, { 0xa5, 0x28, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0x10 } }
  735. //
  736. // The following structure is returned on an IOCTL_DISK_GET_PARTITION_INFO
  737. // and an IOCTL_DISK_GET_DRIVE_LAYOUT request. It is also used in a request
  738. // to change the drive layout, IOCTL_DISK_SET_DRIVE_LAYOUT.
  739. //
  740. typedef struct _PARTITION_INFORMATION {
  741. LARGE_INTEGER StartingOffset;
  742. LARGE_INTEGER PartitionLength;
  743. DWORD HiddenSectors;
  744. DWORD PartitionNumber;
  745. BYTE PartitionType;
  746. BOOLEAN BootIndicator;
  747. BOOLEAN RecognizedPartition;
  748. BOOLEAN RewritePartition;
  749. } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
  750. //
  751. // The following structure is used to change the partition type of a
  752. // specified disk partition using an IOCTL_DISK_SET_PARTITION_INFO
  753. // request.
  754. //
  755. typedef struct _SET_PARTITION_INFORMATION {
  756. BYTE PartitionType;
  757. } SET_PARTITION_INFORMATION, *PSET_PARTITION_INFORMATION;
  758. //
  759. // The following structures is returned on an IOCTL_DISK_GET_DRIVE_LAYOUT
  760. // request and given as input to an IOCTL_DISK_SET_DRIVE_LAYOUT request.
  761. //
  762. typedef struct _DRIVE_LAYOUT_INFORMATION {
  763. DWORD PartitionCount;
  764. DWORD Signature;
  765. PARTITION_INFORMATION PartitionEntry[1];
  766. } DRIVE_LAYOUT_INFORMATION, *PDRIVE_LAYOUT_INFORMATION;
  767. //
  768. // The following structure is passed in on an IOCTL_DISK_VERIFY request.
  769. // The offset and length parameters are both given in bytes.
  770. //
  771. typedef struct _VERIFY_INFORMATION {
  772. LARGE_INTEGER StartingOffset;
  773. DWORD Length;
  774. } VERIFY_INFORMATION, *PVERIFY_INFORMATION;
  775. //
  776. // The following structure is passed in on an IOCTL_DISK_REASSIGN_BLOCKS
  777. // request.
  778. //
  779. typedef struct _REASSIGN_BLOCKS {
  780. WORD Reserved;
  781. WORD Count;
  782. DWORD BlockNumber[1];
  783. } REASSIGN_BLOCKS, *PREASSIGN_BLOCKS;
  784. #if(_WIN32_WINNT >= 0x500)
  785. //
  786. // Support for GUID Partition Table (GPT) disks.
  787. //
  788. //
  789. // There are currently two ways a disk can be partitioned. With a traditional
  790. // AT-style master boot record (PARTITION_STYLE_MBR) and with a new, GPT
  791. // partition table (PARTITION_STYLE_GPT). RAW is for an unrecognizable
  792. // partition style. There are a very limited number of things you can
  793. // do with a RAW partititon.
  794. //
  795. typedef enum _PARTITION_STYLE {
  796. PARTITION_STYLE_MBR,
  797. PARTITION_STYLE_GPT,
  798. PARTITION_STYLE_RAW
  799. } PARTITION_STYLE;
  800. //
  801. // The following structure defines information in a GPT partition that is
  802. // not common to both GPT and MBR partitions.
  803. //
  804. typedef struct _PARTITION_INFORMATION_GPT {
  805. GUID PartitionType; // Partition type. See table 16-3.
  806. GUID PartitionId; // Unique GUID for this partition.
  807. DWORD64 Attributes; // See table 16-4.
  808. WCHAR Name [36]; // Partition Name in Unicode.
  809. } PARTITION_INFORMATION_GPT, *PPARTITION_INFORMATION_GPT;
  810. //
  811. // The following are GPT partition attributes applicable for any
  812. // partition type. These attributes are not OS-specific
  813. //
  814. #define GPT_ATTRIBUTE_PLATFORM_REQUIRED (0x0000000000000001)
  815. //
  816. // The following are GPT partition attributes applicable when the
  817. // PartitionType is PARTITION_BASIC_DATA_GUID.
  818. //
  819. #define GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER (0x8000000000000000)
  820. #define GPT_BASIC_DATA_ATTRIBUTE_HIDDEN (0x4000000000000000)
  821. #define GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY (0x1000000000000000)
  822. //
  823. // The following structure defines information in an MBR partition that is not
  824. // common to both GPT and MBR partitions.
  825. //
  826. typedef struct _PARTITION_INFORMATION_MBR {
  827. BYTE PartitionType;
  828. BOOLEAN BootIndicator;
  829. BOOLEAN RecognizedPartition;
  830. DWORD HiddenSectors;
  831. } PARTITION_INFORMATION_MBR, *PPARTITION_INFORMATION_MBR;
  832. //
  833. // The structure SET_PARTITION_INFO_EX is used with the ioctl
  834. // IOCTL_SET_PARTITION_INFO_EX to set information about a specific
  835. // partition. Note that for MBR partitions, you can only set the partition
  836. // signature, whereas GPT partitions allow setting of all fields that
  837. // you can get.
  838. //
  839. typedef SET_PARTITION_INFORMATION SET_PARTITION_INFORMATION_MBR;
  840. typedef PARTITION_INFORMATION_GPT SET_PARTITION_INFORMATION_GPT;
  841. typedef struct _SET_PARTITION_INFORMATION_EX {
  842. PARTITION_STYLE PartitionStyle;
  843. union {
  844. SET_PARTITION_INFORMATION_MBR Mbr;
  845. SET_PARTITION_INFORMATION_GPT Gpt;
  846. };
  847. } SET_PARTITION_INFORMATION_EX, *PSET_PARTITION_INFORMATION_EX;
  848. //
  849. // The structure CREATE_DISK_GPT with the ioctl IOCTL_DISK_CREATE_DISK
  850. // to initialize an virgin disk with an empty GPT partition table.
  851. //
  852. typedef struct _CREATE_DISK_GPT {
  853. GUID DiskId; // Unique disk id for the disk.
  854. DWORD MaxPartitionCount; // Maximim number of partitions allowable.
  855. } CREATE_DISK_GPT, *PCREATE_DISK_GPT;
  856. //
  857. // The structure CREATE_DISK_MBR with the ioctl IOCTL_DISK_CREATE_DISK
  858. // to initialize an virgin disk with an empty MBR partition table.
  859. //
  860. typedef struct _CREATE_DISK_MBR {
  861. DWORD Signature;
  862. } CREATE_DISK_MBR, *PCREATE_DISK_MBR;
  863. typedef struct _CREATE_DISK {
  864. PARTITION_STYLE PartitionStyle;
  865. union {
  866. CREATE_DISK_MBR Mbr;
  867. CREATE_DISK_GPT Gpt;
  868. };
  869. } CREATE_DISK, *PCREATE_DISK;
  870. //
  871. // The structure GET_LENGTH_INFORMATION is used with the ioctl
  872. // IOCTL_DISK_GET_LENGTH_INFO to obtain the length, in bytes, of the
  873. // disk, partition, or volume.
  874. //
  875. typedef struct _GET_LENGTH_INFORMATION {
  876. LARGE_INTEGER Length;
  877. } GET_LENGTH_INFORMATION, *PGET_LENGTH_INFORMATION;
  878. //
  879. // The PARTITION_INFORMATION_EX structure is used with the
  880. // IOCTL_DISK_GET_DRIVE_LAYOUT_EX, IOCTL_DISK_SET_DRIVE_LAYOUT_EX,
  881. // IOCTL_DISK_GET_PARTITION_INFO_EX and IOCTL_DISK_GET_PARTITION_INFO_EX calls.
  882. //
  883. typedef struct _PARTITION_INFORMATION_EX {
  884. PARTITION_STYLE PartitionStyle;
  885. LARGE_INTEGER StartingOffset;
  886. LARGE_INTEGER PartitionLength;
  887. DWORD PartitionNumber;
  888. BOOLEAN RewritePartition;
  889. union {
  890. PARTITION_INFORMATION_MBR Mbr;
  891. PARTITION_INFORMATION_GPT Gpt;
  892. };
  893. } PARTITION_INFORMATION_EX, *PPARTITION_INFORMATION_EX;
  894. //
  895. // GPT specific drive layout information.
  896. //
  897. typedef struct _DRIVE_LAYOUT_INFORMATION_GPT {
  898. GUID DiskId;
  899. LARGE_INTEGER StartingUsableOffset;
  900. LARGE_INTEGER UsableLength;
  901. DWORD MaxPartitionCount;
  902. } DRIVE_LAYOUT_INFORMATION_GPT, *PDRIVE_LAYOUT_INFORMATION_GPT;
  903. //
  904. // MBR specific drive layout information.
  905. //
  906. typedef struct _DRIVE_LAYOUT_INFORMATION_MBR {
  907. DWORD Signature;
  908. } DRIVE_LAYOUT_INFORMATION_MBR, *PDRIVE_LAYOUT_INFORMATION_MBR;
  909. //
  910. // The structure DRIVE_LAYOUT_INFORMATION_EX is used with the
  911. // IOCTL_SET_DRIVE_LAYOUT_EX and IOCTL_GET_DRIVE_LAYOUT_EX calls.
  912. //
  913. typedef struct _DRIVE_LAYOUT_INFORMATION_EX {
  914. DWORD PartitionStyle;
  915. DWORD PartitionCount;
  916. union {
  917. DRIVE_LAYOUT_INFORMATION_MBR Mbr;
  918. DRIVE_LAYOUT_INFORMATION_GPT Gpt;
  919. };
  920. PARTITION_INFORMATION_EX PartitionEntry[1];
  921. } DRIVE_LAYOUT_INFORMATION_EX, *PDRIVE_LAYOUT_INFORMATION_EX;
  922. #endif // (_WIN32_WINNT >= 0x0500)
  923. #if(_WIN32_WINNT >= 0x0500)
  924. //
  925. // The DISK_GEOMETRY_EX structure is returned on issuing an
  926. // IOCTL_DISK_GET_DRIVE_GEOMETRY_EX ioctl.
  927. //
  928. typedef enum _DETECTION_TYPE {
  929. DetectNone,
  930. DetectInt13,
  931. DetectExInt13
  932. } DETECTION_TYPE;
  933. typedef struct _DISK_INT13_INFO {
  934. WORD DriveSelect;
  935. DWORD MaxCylinders;
  936. WORD SectorsPerTrack;
  937. WORD MaxHeads;
  938. WORD NumberDrives;
  939. } DISK_INT13_INFO, *PDISK_INT13_INFO;
  940. typedef struct _DISK_EX_INT13_INFO {
  941. WORD ExBufferSize;
  942. WORD ExFlags;
  943. DWORD ExCylinders;
  944. DWORD ExHeads;
  945. DWORD ExSectorsPerTrack;
  946. DWORD64 ExSectorsPerDrive;
  947. WORD ExSectorSize;
  948. WORD ExReserved;
  949. } DISK_EX_INT13_INFO, *PDISK_EX_INT13_INFO;
  950. typedef struct _DISK_DETECTION_INFO {
  951. DWORD SizeOfDetectInfo;
  952. DETECTION_TYPE DetectionType;
  953. union {
  954. struct {
  955. //
  956. // If DetectionType == DETECTION_INT13 then we have just the Int13
  957. // information.
  958. //
  959. DISK_INT13_INFO Int13;
  960. //
  961. // If DetectionType == DETECTION_EX_INT13, then we have the
  962. // extended int 13 information.
  963. //
  964. DISK_EX_INT13_INFO ExInt13; // If DetectionType == DetectExInt13
  965. };
  966. };
  967. } DISK_DETECTION_INFO, *PDISK_DETECTION_INFO;
  968. typedef struct _DISK_PARTITION_INFO {
  969. DWORD SizeOfPartitionInfo;
  970. PARTITION_STYLE PartitionStyle; // PartitionStyle = RAW, GPT or MBR
  971. union {
  972. struct { // If PartitionStyle == MBR
  973. DWORD Signature; // MBR Signature
  974. DWORD CheckSum; // MBR CheckSum
  975. } Mbr;
  976. struct { // If PartitionStyle == GPT
  977. GUID DiskId;
  978. } Gpt;
  979. };
  980. } DISK_PARTITION_INFO, *PDISK_PARTITION_INFO;
  981. //
  982. // The Geometry structure is a variable length structure composed of a
  983. // DISK_GEOMETRY_EX structure followed by a DISK_PARTITION_INFO structure
  984. // followed by a DISK_DETECTION_DATA structure.
  985. //
  986. #define DiskGeometryGetPartition(Geometry)\
  987. ((PDISK_PARTITION_INFO)((Geometry)+1))
  988. #define DiskGeometryGetDetect(Geometry)\
  989. ((PDISK_DETECTION_INFO)(((PBYTE)DiskGeometryGetPartition(Geometry)+\
  990. DiskGeometryGetPartition(Geometry)->SizeOfPartitionInfo)))
  991. typedef struct _DISK_GEOMETRY_EX {
  992. DISK_GEOMETRY Geometry; // Standard disk geometry: may be faked by driver.
  993. LARGE_INTEGER DiskSize; // Must always be correct
  994. BYTE Data[1]; // Partition, Detect info
  995. } DISK_GEOMETRY_EX, *PDISK_GEOMETRY_EX;
  996. #endif // (_WIN32_WINNT > 0x0500)
  997. #if(_WIN32_WINNT >= 0x0400)
  998. //
  999. // IOCTL_DISK_CONTROLLER_NUMBER returns the controller and disk
  1000. // number for the handle. This is used to determine if a disk
  1001. // is attached to the primary or secondary IDE controller.
  1002. //
  1003. typedef struct _DISK_CONTROLLER_NUMBER {
  1004. DWORD ControllerNumber;
  1005. DWORD DiskNumber;
  1006. } DISK_CONTROLLER_NUMBER, *PDISK_CONTROLLER_NUMBER;
  1007. #endif /* _WIN32_WINNT >= 0x0400 */
  1008. #if(_WIN32_WINNT >= 0x0500)
  1009. //
  1010. // IOCTL_DISK_SET_CACHE allows the caller to get or set the state of the disk
  1011. // read/write caches.
  1012. //
  1013. // If the structure is provided as the input buffer for the ioctl the read &
  1014. // write caches will be enabled or disabled depending on the parameters
  1015. // provided.
  1016. //
  1017. // If the structure is provided as an output buffer for the ioctl the state
  1018. // of the read & write caches will be returned. If both input and outut buffers
  1019. // are provided the output buffer will contain the cache state BEFORE any
  1020. // changes are made
  1021. //
  1022. typedef enum {
  1023. EqualPriority,
  1024. KeepPrefetchedData,
  1025. KeepReadData
  1026. } DISK_CACHE_RETENTION_PRIORITY;
  1027. typedef enum _DISK_WRITE_CACHE_STATE {
  1028. DiskWriteCacheNormal,
  1029. DiskWriteCacheForceDisable,
  1030. DiskWriteCacheDisableNotSupported
  1031. } DISK_WRITE_CACHE_STATE, *PDISK_WRITE_CACHE_STATE;
  1032. typedef struct _DISK_CACHE_INFORMATION {
  1033. //
  1034. // on return indicates that the device is capable of saving any parameters
  1035. // in non-volatile storage. On send indicates that the device should
  1036. // save the state in non-volatile storage.
  1037. //
  1038. BOOLEAN ParametersSavable;
  1039. //
  1040. // Indicates whether the write and read caches are enabled.
  1041. //
  1042. BOOLEAN ReadCacheEnabled;
  1043. BOOLEAN WriteCacheEnabled;
  1044. //
  1045. // Controls the likelyhood of data remaining in the cache depending on how
  1046. // it got there. Data cached from a READ or WRITE operation may be given
  1047. // higher, lower or equal priority to data entered into the cache for other
  1048. // means (like prefetch)
  1049. //
  1050. DISK_CACHE_RETENTION_PRIORITY ReadRetentionPriority;
  1051. DISK_CACHE_RETENTION_PRIORITY WriteRetentionPriority;
  1052. //
  1053. // Requests for a larger number of blocks than this may have prefetching
  1054. // disabled. If this value is set to 0 prefetch will be disabled.
  1055. //
  1056. WORD DisablePrefetchTransferLength;
  1057. //
  1058. // If TRUE then ScalarPrefetch (below) will be valid. If FALSE then
  1059. // the minimum and maximum values should be treated as a block count
  1060. // (BlockPrefetch)
  1061. //
  1062. BOOLEAN PrefetchScalar;
  1063. //
  1064. // Contains the minimum and maximum amount of data which will be
  1065. // will be prefetched into the cache on a disk operation. This value
  1066. // may either be a scalar multiplier of the transfer length of the request,
  1067. // or an abolute number of disk blocks. PrefetchScalar (above) indicates
  1068. // which interpretation is used.
  1069. //
  1070. union {
  1071. struct {
  1072. WORD Minimum;
  1073. WORD Maximum;
  1074. //
  1075. // The maximum number of blocks which will be prefetched - useful
  1076. // with the scalar limits to set definite upper limits.
  1077. //
  1078. WORD MaximumBlocks;
  1079. } ScalarPrefetch;
  1080. struct {
  1081. WORD Minimum;
  1082. WORD Maximum;
  1083. } BlockPrefetch;
  1084. };
  1085. } DISK_CACHE_INFORMATION, *PDISK_CACHE_INFORMATION;
  1086. //
  1087. // IOCTL_DISK_GROW_PARTITION will update the size of a partition
  1088. // by adding sectors to the length. The number of sectors must be
  1089. // predetermined by examining PARTITION_INFORMATION.
  1090. //
  1091. typedef struct _DISK_GROW_PARTITION {
  1092. DWORD PartitionNumber;
  1093. LARGE_INTEGER BytesToGrow;
  1094. } DISK_GROW_PARTITION, *PDISK_GROW_PARTITION;
  1095. #endif /* _WIN32_WINNT >= 0x0500 */
  1096. ///////////////////////////////////////////////////////
  1097. // //
  1098. // The following structures define disk performance //
  1099. // statistics: specifically the locations of all the //
  1100. // reads and writes which have occured on the disk. //
  1101. // //
  1102. // To use these structures, you must issue an IOCTL_ //
  1103. // DISK_HIST_STRUCTURE (with a DISK_HISTOGRAM) to //
  1104. // obtain the basic histogram information. The //
  1105. // number of buckets which must allocated is part of //
  1106. // this structure. Allocate the required number of //
  1107. // buckets and call an IOCTL_DISK_HIST_DATA to fill //
  1108. // in the data //
  1109. // //
  1110. ///////////////////////////////////////////////////////
  1111. #define HIST_NO_OF_BUCKETS 24
  1112. typedef struct _HISTOGRAM_BUCKET {
  1113. DWORD Reads;
  1114. DWORD Writes;
  1115. } HISTOGRAM_BUCKET, *PHISTOGRAM_BUCKET;
  1116. #define HISTOGRAM_BUCKET_SIZE sizeof(HISTOGRAM_BUCKET)
  1117. typedef struct _DISK_HISTOGRAM {
  1118. LARGE_INTEGER DiskSize;
  1119. LARGE_INTEGER Start;
  1120. LARGE_INTEGER End;
  1121. LARGE_INTEGER Average;
  1122. LARGE_INTEGER AverageRead;
  1123. LARGE_INTEGER AverageWrite;
  1124. DWORD Granularity;
  1125. DWORD Size;
  1126. DWORD ReadCount;
  1127. DWORD WriteCount;
  1128. PHISTOGRAM_BUCKET Histogram;
  1129. } DISK_HISTOGRAM, *PDISK_HISTOGRAM;
  1130. #define DISK_HISTOGRAM_SIZE sizeof(DISK_HISTOGRAM)
  1131. ///////////////////////////////////////////////////////
  1132. // //
  1133. // The following structures define disk debugging //
  1134. // capabilities. The IOCTLs are directed to one of //
  1135. // the two disk filter drivers. //
  1136. // //
  1137. // DISKPERF is a utilty for collecting disk request //
  1138. // statistics. //
  1139. // //
  1140. // SIMBAD is a utility for injecting faults in //
  1141. // IO requests to disks. //
  1142. // //
  1143. ///////////////////////////////////////////////////////
  1144. //
  1145. // The following structure is exchanged on an IOCTL_DISK_GET_PERFORMANCE
  1146. // request. This ioctl collects summary disk request statistics used
  1147. // in measuring performance.
  1148. //
  1149. typedef struct _DISK_PERFORMANCE {
  1150. LARGE_INTEGER BytesRead;
  1151. LARGE_INTEGER BytesWritten;
  1152. LARGE_INTEGER ReadTime;
  1153. LARGE_INTEGER WriteTime;
  1154. LARGE_INTEGER IdleTime;
  1155. DWORD ReadCount;
  1156. DWORD WriteCount;
  1157. DWORD QueueDepth;
  1158. DWORD SplitCount;
  1159. LARGE_INTEGER QueryTime;
  1160. DWORD StorageDeviceNumber;
  1161. WCHAR StorageManagerName[8];
  1162. } DISK_PERFORMANCE, *PDISK_PERFORMANCE;
  1163. //
  1164. // This structure defines the disk logging record. When disk logging
  1165. // is enabled, one of these is written to an internal buffer for each
  1166. // disk request.
  1167. //
  1168. typedef struct _DISK_RECORD {
  1169. LARGE_INTEGER ByteOffset;
  1170. LARGE_INTEGER StartTime;
  1171. LARGE_INTEGER EndTime;
  1172. PVOID VirtualAddress;
  1173. DWORD NumberOfBytes;
  1174. BYTE DeviceNumber;
  1175. BOOLEAN ReadRequest;
  1176. } DISK_RECORD, *PDISK_RECORD;
  1177. //
  1178. // The following structure is exchanged on an IOCTL_DISK_LOG request.
  1179. // Not all fields are valid with each function type.
  1180. //
  1181. typedef struct _DISK_LOGGING {
  1182. BYTE Function;
  1183. PVOID BufferAddress;
  1184. DWORD BufferSize;
  1185. } DISK_LOGGING, *PDISK_LOGGING;
  1186. //
  1187. // Disk logging functions
  1188. //
  1189. // Start disk logging. Only the Function and BufferSize fields are valid.
  1190. //
  1191. #define DISK_LOGGING_START 0
  1192. //
  1193. // Stop disk logging. Only the Function field is valid.
  1194. //
  1195. #define DISK_LOGGING_STOP 1
  1196. //
  1197. // Return disk log. All fields are valid. Data will be copied from internal
  1198. // buffer to buffer specified for the number of bytes requested.
  1199. //
  1200. #define DISK_LOGGING_DUMP 2
  1201. //
  1202. // DISK BINNING
  1203. //
  1204. // DISKPERF will keep counters for IO that falls in each of these ranges.
  1205. // The application determines the number and size of the ranges.
  1206. // Joe Lin wanted me to keep it flexible as possible, for instance, IO
  1207. // sizes are interesting in ranges like 0-4096, 4097-16384, 16385-65536, 65537+.
  1208. //
  1209. #define DISK_BINNING 3
  1210. //
  1211. // Bin types
  1212. //
  1213. typedef enum _BIN_TYPES {
  1214. RequestSize,
  1215. RequestLocation
  1216. } BIN_TYPES;
  1217. //
  1218. // Bin ranges
  1219. //
  1220. typedef struct _BIN_RANGE {
  1221. LARGE_INTEGER StartValue;
  1222. LARGE_INTEGER Length;
  1223. } BIN_RANGE, *PBIN_RANGE;
  1224. //
  1225. // Bin definition
  1226. //
  1227. typedef struct _PERF_BIN {
  1228. DWORD NumberOfBins;
  1229. DWORD TypeOfBin;
  1230. BIN_RANGE BinsRanges[1];
  1231. } PERF_BIN, *PPERF_BIN ;
  1232. //
  1233. // Bin count
  1234. //
  1235. typedef struct _BIN_COUNT {
  1236. BIN_RANGE BinRange;
  1237. DWORD BinCount;
  1238. } BIN_COUNT, *PBIN_COUNT;
  1239. //
  1240. // Bin results
  1241. //
  1242. typedef struct _BIN_RESULTS {
  1243. DWORD NumberOfBins;
  1244. BIN_COUNT BinCounts[1];
  1245. } BIN_RESULTS, *PBIN_RESULTS;
  1246. #if(_WIN32_WINNT >= 0x0400)
  1247. //
  1248. // Data structures for SMART drive fault prediction.
  1249. //
  1250. // GETVERSIONINPARAMS contains the data returned from the
  1251. // Get Driver Version function.
  1252. //
  1253. #include <pshpack1.h>
  1254. typedef struct _GETVERSIONINPARAMS {
  1255. BYTE bVersion; // Binary driver version.
  1256. BYTE bRevision; // Binary driver revision.
  1257. BYTE bReserved; // Not used.
  1258. BYTE bIDEDeviceMap; // Bit map of IDE devices.
  1259. DWORD fCapabilities; // Bit mask of driver capabilities.
  1260. DWORD dwReserved[4]; // For future use.
  1261. } GETVERSIONINPARAMS, *PGETVERSIONINPARAMS, *LPGETVERSIONINPARAMS;
  1262. #include <poppack.h>
  1263. //
  1264. // Bits returned in the fCapabilities member of GETVERSIONINPARAMS
  1265. //
  1266. #define CAP_ATA_ID_CMD 1 // ATA ID command supported
  1267. #define CAP_ATAPI_ID_CMD 2 // ATAPI ID command supported
  1268. #define CAP_SMART_CMD 4 // SMART commannds supported
  1269. //
  1270. // IDE registers
  1271. //
  1272. #include <pshpack1.h>
  1273. typedef struct _IDEREGS {
  1274. BYTE bFeaturesReg; // Used for specifying SMART "commands".
  1275. BYTE bSectorCountReg; // IDE sector count register
  1276. BYTE bSectorNumberReg; // IDE sector number register
  1277. BYTE bCylLowReg; // IDE low order cylinder value
  1278. BYTE bCylHighReg; // IDE high order cylinder value
  1279. BYTE bDriveHeadReg; // IDE drive/head register
  1280. BYTE bCommandReg; // Actual IDE command.
  1281. BYTE bReserved; // reserved for future use. Must be zero.
  1282. } IDEREGS, *PIDEREGS, *LPIDEREGS;
  1283. #include <poppack.h>
  1284. //
  1285. // Valid values for the bCommandReg member of IDEREGS.
  1286. //
  1287. #define ATAPI_ID_CMD 0xA1 // Returns ID sector for ATAPI.
  1288. #define ID_CMD 0xEC // Returns ID sector for ATA.
  1289. #define SMART_CMD 0xB0 // Performs SMART cmd.
  1290. // Requires valid bFeaturesReg,
  1291. // bCylLowReg, and bCylHighReg
  1292. //
  1293. // Cylinder register defines for SMART command
  1294. //
  1295. #define SMART_CYL_LOW 0x4F
  1296. #define SMART_CYL_HI 0xC2
  1297. //
  1298. // SENDCMDINPARAMS contains the input parameters for the
  1299. // Send Command to Drive function.
  1300. //
  1301. #include <pshpack1.h>
  1302. typedef struct _SENDCMDINPARAMS {
  1303. DWORD cBufferSize; // Buffer size in bytes
  1304. IDEREGS irDriveRegs; // Structure with drive register values.
  1305. BYTE bDriveNumber; // Physical drive number to send
  1306. // command to (0,1,2,3).
  1307. BYTE bReserved[3]; // Reserved for future expansion.
  1308. DWORD dwReserved[4]; // For future use.
  1309. BYTE bBuffer[1]; // Input buffer.
  1310. } SENDCMDINPARAMS, *PSENDCMDINPARAMS, *LPSENDCMDINPARAMS;
  1311. #include <poppack.h>
  1312. //
  1313. // Status returned from driver
  1314. //
  1315. #include <pshpack1.h>
  1316. typedef struct _DRIVERSTATUS {
  1317. BYTE bDriverError; // Error code from driver,
  1318. // or 0 if no error.
  1319. BYTE bIDEError; // Contents of IDE Error register.
  1320. // Only valid when bDriverError
  1321. // is SMART_IDE_ERROR.
  1322. BYTE bReserved[2]; // Reserved for future expansion.
  1323. DWORD dwReserved[2]; // Reserved for future expansion.
  1324. } DRIVERSTATUS, *PDRIVERSTATUS, *LPDRIVERSTATUS;
  1325. #include <poppack.h>
  1326. //
  1327. // bDriverError values
  1328. //
  1329. #define SMART_NO_ERROR 0 // No error
  1330. #define SMART_IDE_ERROR 1 // Error from IDE controller
  1331. #define SMART_INVALID_FLAG 2 // Invalid command flag
  1332. #define SMART_INVALID_COMMAND 3 // Invalid command byte
  1333. #define SMART_INVALID_BUFFER 4 // Bad buffer (null, invalid addr..)
  1334. #define SMART_INVALID_DRIVE 5 // Drive number not valid
  1335. #define SMART_INVALID_IOCTL 6 // Invalid IOCTL
  1336. #define SMART_ERROR_NO_MEM 7 // Could not lock user's buffer
  1337. #define SMART_INVALID_REGISTER 8 // Some IDE Register not valid
  1338. #define SMART_NOT_SUPPORTED 9 // Invalid cmd flag set
  1339. #define SMART_NO_IDE_DEVICE 10 // Cmd issued to device not present
  1340. // although drive number is valid
  1341. //
  1342. // SMART sub commands for execute offline diags
  1343. //
  1344. #define SMART_OFFLINE_ROUTINE_OFFLINE 0
  1345. #define SMART_SHORT_SELFTEST_OFFLINE 1
  1346. #define SMART_EXTENDED_SELFTEST_OFFLINE 2
  1347. #define SMART_ABORT_OFFLINE_SELFTEST 127
  1348. #define SMART_SHORT_SELFTEST_CAPTIVE 129
  1349. #define SMART_EXTENDED_SELFTEST_CAPTIVE 130
  1350. #include <pshpack1.h>
  1351. typedef struct _SENDCMDOUTPARAMS {
  1352. DWORD cBufferSize; // Size of bBuffer in bytes
  1353. DRIVERSTATUS DriverStatus; // Driver status structure.
  1354. BYTE bBuffer[1]; // Buffer of arbitrary length in which to store the data read from the // drive.
  1355. } SENDCMDOUTPARAMS, *PSENDCMDOUTPARAMS, *LPSENDCMDOUTPARAMS;
  1356. #include <poppack.h>
  1357. #define READ_ATTRIBUTE_BUFFER_SIZE 512
  1358. #define IDENTIFY_BUFFER_SIZE 512
  1359. #define READ_THRESHOLD_BUFFER_SIZE 512
  1360. #define SMART_LOG_SECTOR_SIZE 512
  1361. //
  1362. // Feature register defines for SMART "sub commands"
  1363. //
  1364. #define READ_ATTRIBUTES 0xD0
  1365. #define READ_THRESHOLDS 0xD1
  1366. #define ENABLE_DISABLE_AUTOSAVE 0xD2
  1367. #define SAVE_ATTRIBUTE_VALUES 0xD3
  1368. #define EXECUTE_OFFLINE_DIAGS 0xD4
  1369. #define SMART_READ_LOG 0xD5
  1370. #define SMART_WRITE_LOG 0xd6
  1371. #define ENABLE_SMART 0xD8
  1372. #define DISABLE_SMART 0xD9
  1373. #define RETURN_SMART_STATUS 0xDA
  1374. #define ENABLE_DISABLE_AUTO_OFFLINE 0xDB
  1375. #endif /* _WIN32_WINNT >= 0x0400 */
  1376. #define IOCTL_CHANGER_BASE FILE_DEVICE_CHANGER
  1377. #define IOCTL_CHANGER_GET_PARAMETERS CTL_CODE(IOCTL_CHANGER_BASE, 0x0000, METHOD_BUFFERED, FILE_READ_ACCESS)
  1378. #define IOCTL_CHANGER_GET_STATUS CTL_CODE(IOCTL_CHANGER_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
  1379. #define IOCTL_CHANGER_GET_PRODUCT_DATA CTL_CODE(IOCTL_CHANGER_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS)
  1380. #define IOCTL_CHANGER_SET_ACCESS CTL_CODE(IOCTL_CHANGER_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  1381. #define IOCTL_CHANGER_GET_ELEMENT_STATUS CTL_CODE(IOCTL_CHANGER_BASE, 0x0005, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  1382. #define IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS CTL_CODE(IOCTL_CHANGER_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS)
  1383. #define IOCTL_CHANGER_SET_POSITION CTL_CODE(IOCTL_CHANGER_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS)
  1384. #define IOCTL_CHANGER_EXCHANGE_MEDIUM CTL_CODE(IOCTL_CHANGER_BASE, 0x0008, METHOD_BUFFERED, FILE_READ_ACCESS)
  1385. #define IOCTL_CHANGER_MOVE_MEDIUM CTL_CODE(IOCTL_CHANGER_BASE, 0x0009, METHOD_BUFFERED, FILE_READ_ACCESS)
  1386. #define IOCTL_CHANGER_REINITIALIZE_TRANSPORT CTL_CODE(IOCTL_CHANGER_BASE, 0x000A, METHOD_BUFFERED, FILE_READ_ACCESS)
  1387. #define IOCTL_CHANGER_QUERY_VOLUME_TAGS CTL_CODE(IOCTL_CHANGER_BASE, 0x000B, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  1388. #define MAX_VOLUME_ID_SIZE 36
  1389. #define MAX_VOLUME_TEMPLATE_SIZE 40
  1390. #define VENDOR_ID_LENGTH 8
  1391. #define PRODUCT_ID_LENGTH 16
  1392. #define REVISION_LENGTH 4
  1393. #define SERIAL_NUMBER_LENGTH 32
  1394. //
  1395. // Common structures describing elements.
  1396. //
  1397. typedef enum _ELEMENT_TYPE {
  1398. AllElements, // As defined by SCSI
  1399. ChangerTransport, // As defined by SCSI
  1400. ChangerSlot, // As defined by SCSI
  1401. ChangerIEPort, // As defined by SCSI
  1402. ChangerDrive, // As defined by SCSI
  1403. ChangerDoor, // Front panel, used to access internal of cabinet.
  1404. ChangerKeypad, // Keypad/input on front panel.
  1405. ChangerMaxElement // Placeholder only. Not a valid type.
  1406. } ELEMENT_TYPE, *PELEMENT_TYPE;
  1407. typedef struct _CHANGER_ELEMENT {
  1408. ELEMENT_TYPE ElementType;
  1409. DWORD ElementAddress;
  1410. } CHANGER_ELEMENT, *PCHANGER_ELEMENT;
  1411. typedef struct _CHANGER_ELEMENT_LIST {
  1412. CHANGER_ELEMENT Element;
  1413. DWORD NumberOfElements;
  1414. } CHANGER_ELEMENT_LIST , *PCHANGER_ELEMENT_LIST;
  1415. //
  1416. // Definitions for IOCTL_CHANGER_GET_PARAMETERS
  1417. //
  1418. //
  1419. // Definitions for Features0 of GET_CHANGER_PARAMETERS
  1420. //
  1421. #define CHANGER_BAR_CODE_SCANNER_INSTALLED 0x00000001 // The medium-changer has a bar code scanner installed.
  1422. #define CHANGER_INIT_ELEM_STAT_WITH_RANGE 0x00000002 // The medium-changer has the ability to initialize elements within a specified range.
  1423. #define CHANGER_CLOSE_IEPORT 0x00000004 // The medium-changer has the ability to close the i/e port door.
  1424. #define CHANGER_OPEN_IEPORT 0x00000008 // The medium-changer can open the i/e port door.
  1425. #define CHANGER_STATUS_NON_VOLATILE 0x00000010 // The medium-changer uses non-volatile memory for element status information.
  1426. #define CHANGER_EXCHANGE_MEDIA 0x00000020 // The medium-changer supports exchange operations.
  1427. #define CHANGER_CLEANER_SLOT 0x00000040 // The medium-changer has a fixed slot designated for cleaner cartridges.
  1428. #define CHANGER_LOCK_UNLOCK 0x00000080 // The medium-changer can be (un)secured to (allow)prevent media removal.
  1429. #define CHANGER_CARTRIDGE_MAGAZINE 0x00000100 // The medium-changer uses cartridge magazines for some storage slots.
  1430. #define CHANGER_MEDIUM_FLIP 0x00000200 // The medium-changer can flip medium.
  1431. #define CHANGER_POSITION_TO_ELEMENT 0x00000400 // The medium-changer can position the transport to a particular element.
  1432. #define CHANGER_REPORT_IEPORT_STATE 0x00000800 // The medium-changer can determine whether media is present
  1433. // in the IE Port.
  1434. #define CHANGER_STORAGE_DRIVE 0x00001000 // The medium-changer can use a drive as an independent storage element.
  1435. #define CHANGER_STORAGE_IEPORT 0x00002000 // The medium-changer can use a i/e port as an independent storage element.
  1436. #define CHANGER_STORAGE_SLOT 0x00004000 // The medium-changer can use a slot as an independent storage element.
  1437. #define CHANGER_STORAGE_TRANSPORT 0x00008000 // The medium-changer can use a transport as an independent storage element.
  1438. #define CHANGER_DRIVE_CLEANING_REQUIRED 0x00010000 // The drives controlled by the medium changer require periodic cleaning
  1439. // initiated by an application.
  1440. #define CHANGER_PREDISMOUNT_EJECT_REQUIRED 0x00020000 // The medium-changer requires a drive eject command to be issued, before a changer
  1441. // move / exchange command can be issued to the drive.
  1442. #define CHANGER_CLEANER_ACCESS_NOT_VALID 0x00040000 // The access bit in GES isn't valid for cleaner cartridges.
  1443. #define CHANGER_PREMOUNT_EJECT_REQUIRED 0x00080000 // The medium-changer requires a drive eject command to be issued
  1444. // before a move / exchange command can be issued with the drive as src/dst.
  1445. #define CHANGER_VOLUME_IDENTIFICATION 0x00100000 // The medium-changer supports volume identification.
  1446. #define CHANGER_VOLUME_SEARCH 0x00200000 // The medium-changer can search for volume information.
  1447. #define CHANGER_VOLUME_ASSERT 0x00400000 // The medium-changer can verify volume information.
  1448. #define CHANGER_VOLUME_REPLACE 0x00800000 // The medium-changer can replace volume information.
  1449. #define CHANGER_VOLUME_UNDEFINE 0x01000000 // The medium-changer can undefine volume information.
  1450. #define CHANGER_SERIAL_NUMBER_VALID 0x04000000 // The serial number reported in GetProductData is valid
  1451. // and unique.
  1452. #define CHANGER_DEVICE_REINITIALIZE_CAPABLE 0x08000000 // The medium-changer can be issued a ChangerReinitializeUnit.
  1453. #define CHANGER_KEYPAD_ENABLE_DISABLE 0x10000000 // Indicates that the keypad can be enabled/disabled.
  1454. #define CHANGER_DRIVE_EMPTY_ON_DOOR_ACCESS 0x20000000 // Drives must be empty before access via the door is possible.
  1455. #define CHANGER_RESERVED_BIT 0x80000000 // Will be used to indicate Features1 capability bits.
  1456. //
  1457. // Definitions for Features1 of GET_CHANGER_PARAMETERS
  1458. //
  1459. #define CHANGER_PREDISMOUNT_ALIGN_TO_SLOT 0x80000001 // The transport must be prepositioned to the slot prior to ejecting the media.
  1460. #define CHANGER_PREDISMOUNT_ALIGN_TO_DRIVE 0x80000002 // The transport must be prepositioned to the drive prior to ejecting the media.
  1461. #define CHANGER_CLEANER_AUTODISMOUNT 0x80000004 // The device will move the cleaner cartridge back into the slot when cleaning has completed.
  1462. #define CHANGER_TRUE_EXCHANGE_CAPABLE 0x80000008 // Device can do src -> dest2 exchanges.
  1463. #define CHANGER_SLOTS_USE_TRAYS 0x80000010 // Slots have removable trays, requiring multiple moves for inject/eject.
  1464. #define CHANGER_RTN_MEDIA_TO_ORIGINAL_ADDR 0x80000020 // Media must be returned to the slot from which it originated after a move to another element.
  1465. #define CHANGER_CLEANER_OPS_NOT_SUPPORTED 0x80000040 // Automated cleaning operations are not supported on this device.
  1466. #define CHANGER_IEPORT_USER_CONTROL_OPEN 0x80000080 // Indicates that user action is necessary to open a closed ieport.
  1467. #define CHANGER_IEPORT_USER_CONTROL_CLOSE 0x80000100 // Indicates that user action is necessary to close an opened ieport.
  1468. #define CHANGER_MOVE_EXTENDS_IEPORT 0x80000200 // Indicates that a move media to the ieport extends the tray.
  1469. #define CHANGER_MOVE_RETRACTS_IEPORT 0x80000400 // Indicates that a move media from the ieport retracts the tray.
  1470. //
  1471. // Definitions for MoveFrom, ExchangeFrom, and PositionCapabilities
  1472. //
  1473. #define CHANGER_TO_TRANSPORT 0x01 // The device can carry out the operation to a transport from the specified element.
  1474. #define CHANGER_TO_SLOT 0x02 // The device can carry out the operation to a slot from the specified element.
  1475. #define CHANGER_TO_IEPORT 0x04 // The device can carry out the operation to an IE Port from the specified element.
  1476. #define CHANGER_TO_DRIVE 0x08 // The device can carry out the operation to a drive from the specified element.
  1477. //
  1478. // Definitions for LockUnlockCapabilities
  1479. //
  1480. #define LOCK_UNLOCK_IEPORT 0x01 // The device can lock/unlock the ieport(s).
  1481. #define LOCK_UNLOCK_DOOR 0x02 // The device can lock/unlock the door(s).
  1482. #define LOCK_UNLOCK_KEYPAD 0x04 // The device can lock/unlock the keypad.
  1483. typedef struct _GET_CHANGER_PARAMETERS {
  1484. //
  1485. // Size of the structure. Can be used for versioning.
  1486. //
  1487. DWORD Size;
  1488. //
  1489. // Number of N element(s) as defined by the Element Address Page (or equivalent...).
  1490. //
  1491. WORD NumberTransportElements;
  1492. WORD NumberStorageElements; // for data cartridges only
  1493. WORD NumberCleanerSlots; // for cleaner cartridges
  1494. WORD NumberIEElements;
  1495. WORD NumberDataTransferElements;
  1496. //
  1497. // Number of doors/front panels (allows user entry into the cabinet).
  1498. //
  1499. WORD NumberOfDoors;
  1500. //
  1501. // The device-specific address (from user manual of the device) of the first N element. Used
  1502. // by the UI to relate the various elements to the user.
  1503. //
  1504. WORD FirstSlotNumber;
  1505. WORD FirstDriveNumber;
  1506. WORD FirstTransportNumber;
  1507. WORD FirstIEPortNumber;
  1508. WORD FirstCleanerSlotAddress;
  1509. //
  1510. // Indicates the capacity of each magazine, if they exist.
  1511. //
  1512. WORD MagazineSize;
  1513. //
  1514. // Specifies the approximate number of seconds for when a cleaning should be completed.
  1515. // Only applicable if drive cleaning is supported. See Features0.
  1516. //
  1517. DWORD DriveCleanTimeout;
  1518. //
  1519. // See features bits, above.
  1520. //
  1521. DWORD Features0;
  1522. DWORD Features1;
  1523. //
  1524. // Bitmask defining Move from N element to element. Defined by Device Capabilities Page (or equivalent).
  1525. // AND-masking with the TO_XXX values will indicate legal destinations.
  1526. //
  1527. BYTE MoveFromTransport;
  1528. BYTE MoveFromSlot;
  1529. BYTE MoveFromIePort;
  1530. BYTE MoveFromDrive;
  1531. //
  1532. // Bitmask defining Exchange from N element to element. Defined by Device Capabilities Page (or equivalent).
  1533. // AND-masking with the TO_XXX values will indicate legal destinations.
  1534. //
  1535. BYTE ExchangeFromTransport;
  1536. BYTE ExchangeFromSlot;
  1537. BYTE ExchangeFromIePort;
  1538. BYTE ExchangeFromDrive;
  1539. //
  1540. // Bitmask defining which elements are capable of lock/unlock. Valid only if
  1541. // CHANGER_LOCK_UNLOCK is set in Features0.
  1542. //
  1543. BYTE LockUnlockCapabilities;
  1544. //
  1545. // Bitmask defining which elements valid for positioning operations. Valid only if
  1546. // CHANGER_POSITION_TO_ELEMENT is set in Features0.
  1547. //
  1548. BYTE PositionCapabilities;
  1549. //
  1550. // For future expansion.
  1551. //
  1552. BYTE Reserved1[2];
  1553. DWORD Reserved2[2];
  1554. } GET_CHANGER_PARAMETERS, * PGET_CHANGER_PARAMETERS;
  1555. //
  1556. // Definitions for IOCTL_CHANGER_GET_PRODUCT_DATA
  1557. //
  1558. typedef struct _CHANGER_PRODUCT_DATA {
  1559. //
  1560. // Device manufacturer's name - based on inquiry data
  1561. //
  1562. BYTE VendorId[VENDOR_ID_LENGTH];
  1563. //
  1564. // Product identification as defined by the vendor - based on Inquiry data
  1565. //
  1566. BYTE ProductId[PRODUCT_ID_LENGTH];
  1567. //
  1568. // Product revision as defined by the vendor.
  1569. //
  1570. BYTE Revision[REVISION_LENGTH];
  1571. //
  1572. // Vendor unique value used to globally identify this device. Can
  1573. // be from Vital Product Data, for example.
  1574. //
  1575. BYTE SerialNumber[SERIAL_NUMBER_LENGTH];
  1576. //
  1577. // Indicates device type of data transports, as defined by SCSI-2.
  1578. //
  1579. BYTE DeviceType;
  1580. } CHANGER_PRODUCT_DATA, *PCHANGER_PRODUCT_DATA;
  1581. //
  1582. // Definitions for IOCTL_CHANGER_SET_ACCESS
  1583. //
  1584. #define LOCK_ELEMENT 0
  1585. #define UNLOCK_ELEMENT 1
  1586. #define EXTEND_IEPORT 2
  1587. #define RETRACT_IEPORT 3
  1588. typedef struct _CHANGER_SET_ACCESS {
  1589. //
  1590. // Element can be ChangerIEPort, ChangerDoor, ChangerKeypad
  1591. //
  1592. CHANGER_ELEMENT Element;
  1593. //
  1594. // See above for possible operations.
  1595. //
  1596. DWORD Control;
  1597. } CHANGER_SET_ACCESS, *PCHANGER_SET_ACCESS;
  1598. //
  1599. // Definitions for IOCTL_CHANGER_GET_ELEMENT_STATUS
  1600. //
  1601. //
  1602. // Input buffer.
  1603. //
  1604. typedef struct _CHANGER_READ_ELEMENT_STATUS {
  1605. //
  1606. // List describing the elements and range on which to return information.
  1607. //
  1608. CHANGER_ELEMENT_LIST ElementList;
  1609. //
  1610. // Indicates whether volume tag information is to be returned.
  1611. //
  1612. BOOLEAN VolumeTagInfo;
  1613. } CHANGER_READ_ELEMENT_STATUS, *PCHANGER_READ_ELEMENT_STATUS;
  1614. //
  1615. // Output buffer.
  1616. //
  1617. typedef struct _CHANGER_ELEMENT_STATUS {
  1618. //
  1619. // Element to which this structure refers.
  1620. //
  1621. CHANGER_ELEMENT Element;
  1622. //
  1623. // Address of the element from which the media was originally moved.
  1624. // Valid if ELEMENT_STATUS_SVALID bit of Flags DWORD is set.
  1625. // Needs to be converted to a zero-based offset from the device-unique value.
  1626. //
  1627. CHANGER_ELEMENT SrcElementAddress;
  1628. //
  1629. // See below.
  1630. //
  1631. DWORD Flags;
  1632. //
  1633. // See below for possible values.
  1634. //
  1635. DWORD ExceptionCode;
  1636. //
  1637. // Scsi Target Id of this element.
  1638. // Valid only if ELEMENT_STATUS_ID_VALID is set in Flags.
  1639. //
  1640. BYTE TargetId;
  1641. //
  1642. // LogicalUnitNumber of this element.
  1643. // Valid only if ELEMENT_STATUS_LUN_VALID is set in Flags.
  1644. //
  1645. BYTE Lun;
  1646. WORD Reserved;
  1647. //
  1648. // Primary volume identification for the media.
  1649. // Valid only if ELEMENT_STATUS_PVOLTAG bit is set in Flags.
  1650. //
  1651. BYTE PrimaryVolumeID[MAX_VOLUME_ID_SIZE];
  1652. //
  1653. // Alternate volume identification for the media.
  1654. // Valid for two-sided media only, and pertains to the id. of the inverted side.
  1655. // Valid only if ELEMENT_STATUS_AVOLTAG bit is set in Flags.
  1656. //
  1657. BYTE AlternateVolumeID[MAX_VOLUME_ID_SIZE];
  1658. } CHANGER_ELEMENT_STATUS, *PCHANGER_ELEMENT_STATUS;
  1659. //
  1660. // Output buffer. This is same as CHANGER_ELEMENT_STATUS with
  1661. // the addition of product info fields. New applications should
  1662. // use this struct instead of the older CHANGER_ELEMENT_STATUS
  1663. //
  1664. typedef struct _CHANGER_ELEMENT_STATUS_EX {
  1665. //
  1666. // Element to which this structure refers.
  1667. //
  1668. CHANGER_ELEMENT Element;
  1669. //
  1670. // Address of the element from which the media was originally moved.
  1671. // Valid if ELEMENT_STATUS_SVALID bit of Flags DWORD is set.
  1672. // Needs to be converted to a zero-based offset from the device-unique value.
  1673. //
  1674. CHANGER_ELEMENT SrcElementAddress;
  1675. //
  1676. // See below.
  1677. //
  1678. DWORD Flags;
  1679. //
  1680. // See below for possible values.
  1681. //
  1682. DWORD ExceptionCode;
  1683. //
  1684. // Scsi Target Id of this element.
  1685. // Valid only if ELEMENT_STATUS_ID_VALID is set in Flags.
  1686. //
  1687. BYTE TargetId;
  1688. //
  1689. // LogicalUnitNumber of this element.
  1690. // Valid only if ELEMENT_STATUS_LUN_VALID is set in Flags.
  1691. //
  1692. BYTE Lun;
  1693. WORD Reserved;
  1694. //
  1695. // Primary volume identification for the media.
  1696. // Valid only if ELEMENT_STATUS_PVOLTAG bit is set in Flags.
  1697. //
  1698. BYTE PrimaryVolumeID[MAX_VOLUME_ID_SIZE];
  1699. //
  1700. // Alternate volume identification for the media.
  1701. // Valid for two-sided media only, and pertains to the id. of the inverted side.
  1702. // Valid only if ELEMENT_STATUS_AVOLTAG bit is set in Flags.
  1703. //
  1704. BYTE AlternateVolumeID[MAX_VOLUME_ID_SIZE];
  1705. //
  1706. // Vendor ID
  1707. //
  1708. BYTE VendorIdentification[VENDOR_ID_LENGTH];
  1709. //
  1710. // Product ID
  1711. //
  1712. BYTE ProductIdentification[PRODUCT_ID_LENGTH];
  1713. //
  1714. // Serial number
  1715. //
  1716. BYTE SerialNumber[SERIAL_NUMBER_LENGTH];
  1717. } CHANGER_ELEMENT_STATUS_EX, *PCHANGER_ELEMENT_STATUS_EX;
  1718. //
  1719. // Possible flag values
  1720. //
  1721. #define ELEMENT_STATUS_FULL 0x00000001 // Element contains a unit of media.
  1722. #define ELEMENT_STATUS_IMPEXP 0x00000002 // Media in i/e port was placed there by an operator.
  1723. #define ELEMENT_STATUS_EXCEPT 0x00000004 // Element is in an abnormal state; check ExceptionCode field for more information.
  1724. #define ELEMENT_STATUS_ACCESS 0x00000008 // Access to the i/e port from the medium changer is allowed.
  1725. #define ELEMENT_STATUS_EXENAB 0x00000010 // Export of media is supported.
  1726. #define ELEMENT_STATUS_INENAB 0x00000020 // Import of media is supported.
  1727. #define ELEMENT_STATUS_PRODUCT_DATA 0x00000040 // Serial number valid for the drive
  1728. #define ELEMENT_STATUS_LUN_VALID 0x00001000 // Lun information is valid.
  1729. #define ELEMENT_STATUS_ID_VALID 0x00002000 // SCSI Id information is valid.
  1730. #define ELEMENT_STATUS_NOT_BUS 0x00008000 // Lun and SCSI Id fields are not on same bus as medium changer.
  1731. #define ELEMENT_STATUS_INVERT 0x00400000 // Media in element was inverted (valid only if ELEMENT_STATUS_SVALID bit is set)
  1732. #define ELEMENT_STATUS_SVALID 0x00800000 // SourceElementAddress field and ELEMENT_STATUS_INVERT bit are valid.
  1733. #define ELEMENT_STATUS_PVOLTAG 0x10000000 // Primary volume information is valid.
  1734. #define ELEMENT_STATUS_AVOLTAG 0x20000000 // Alternate volume information is valid.
  1735. //
  1736. // ExceptionCode values.
  1737. //
  1738. #define ERROR_LABEL_UNREADABLE 0x00000001 // Bar code scanner could not read bar code label.
  1739. #define ERROR_LABEL_QUESTIONABLE 0x00000002 // Label could be invalid due to unit attention condition.
  1740. #define ERROR_SLOT_NOT_PRESENT 0x00000004 // Slot is currently not addressable in the device.
  1741. #define ERROR_DRIVE_NOT_INSTALLED 0x00000008 // Drive is not installed.
  1742. #define ERROR_TRAY_MALFUNCTION 0x00000010 // Media tray is malfunctioning/broken.
  1743. #define ERROR_INIT_STATUS_NEEDED 0x00000011 // An Initialize Element Status command is needed.
  1744. #define ERROR_UNHANDLED_ERROR 0xFFFFFFFF // Unknown error condition
  1745. //
  1746. // Definitions for IOCTL_CHANGER_INITIALIZE_ELEMENT_STATUS
  1747. //
  1748. typedef struct _CHANGER_INITIALIZE_ELEMENT_STATUS {
  1749. //
  1750. // List describing the elements and range on which to initialize.
  1751. //
  1752. CHANGER_ELEMENT_LIST ElementList;
  1753. //
  1754. // Indicates whether a bar code scan should be used. Only applicable if
  1755. // CHANGER_BAR_CODE_SCANNER_INSTALLED is set in Features0 of CHANGER_GET_PARAMETERS.
  1756. //
  1757. BOOLEAN BarCodeScan;
  1758. } CHANGER_INITIALIZE_ELEMENT_STATUS, *PCHANGER_INITIALIZE_ELEMENT_STATUS;
  1759. //
  1760. // Definitions for IOCTL_CHANGER_SET_POSITION
  1761. //
  1762. typedef struct _CHANGER_SET_POSITION {
  1763. //
  1764. // Indicates which transport to move.
  1765. //
  1766. CHANGER_ELEMENT Transport;
  1767. //
  1768. // Indicates the final destination of the transport.
  1769. //
  1770. CHANGER_ELEMENT Destination;
  1771. //
  1772. // Indicates whether the media currently carried by Transport, should be flipped.
  1773. //
  1774. BOOLEAN Flip;
  1775. } CHANGER_SET_POSITION, *PCHANGER_SET_POSITION;
  1776. //
  1777. // Definitions for IOCTL_CHANGER_EXCHANGE_MEDIUM
  1778. //
  1779. typedef struct _CHANGER_EXCHANGE_MEDIUM {
  1780. //
  1781. // Indicates which transport to use for the exchange operation.
  1782. //
  1783. CHANGER_ELEMENT Transport;
  1784. //
  1785. // Indicates the source for the media that is to be moved.
  1786. //
  1787. CHANGER_ELEMENT Source;
  1788. //
  1789. // Indicates the final destination of the media originally at Source.
  1790. //
  1791. CHANGER_ELEMENT Destination1;
  1792. //
  1793. // Indicates the destination of the media moved from Destination1.
  1794. //
  1795. CHANGER_ELEMENT Destination2;
  1796. //
  1797. // Indicates whether the medium should be flipped.
  1798. //
  1799. BOOLEAN Flip1;
  1800. BOOLEAN Flip2;
  1801. } CHANGER_EXCHANGE_MEDIUM, *PCHANGER_EXCHANGE_MEDIUM;
  1802. //
  1803. // Definitions for IOCTL_CHANGER_MOVE_MEDIUM
  1804. //
  1805. typedef struct _CHANGER_MOVE_MEDIUM {
  1806. //
  1807. // Indicates which transport to use for the move operation.
  1808. //
  1809. CHANGER_ELEMENT Transport;
  1810. //
  1811. // Indicates the source for the media that is to be moved.
  1812. //
  1813. CHANGER_ELEMENT Source;
  1814. //
  1815. // Indicates the destination of the media originally at Source.
  1816. //
  1817. CHANGER_ELEMENT Destination;
  1818. //
  1819. // Indicates whether the media should be flipped.
  1820. //
  1821. BOOLEAN Flip;
  1822. } CHANGER_MOVE_MEDIUM, *PCHANGER_MOVE_MEDIUM;
  1823. //
  1824. // Definitions for IOCTL_QUERY_VOLUME_TAGS
  1825. //
  1826. //
  1827. // Input buffer.
  1828. //
  1829. typedef struct _CHANGER_SEND_VOLUME_TAG_INFORMATION {
  1830. //
  1831. // Describes the starting element for which to return information.
  1832. //
  1833. CHANGER_ELEMENT StartingElement;
  1834. //
  1835. // Indicates the specific action to perform. See below.
  1836. //
  1837. DWORD ActionCode;
  1838. //
  1839. // Template used by the device to search for volume ids.
  1840. //
  1841. BYTE VolumeIDTemplate[MAX_VOLUME_TEMPLATE_SIZE];
  1842. } CHANGER_SEND_VOLUME_TAG_INFORMATION, *PCHANGER_SEND_VOLUME_TAG_INFORMATION;
  1843. //
  1844. // Output buffer.
  1845. //
  1846. typedef struct _READ_ELEMENT_ADDRESS_INFO {
  1847. //
  1848. // Number of elements matching criteria set forth by ActionCode.
  1849. //
  1850. DWORD NumberOfElements;
  1851. //
  1852. // Array of CHANGER_ELEMENT_STATUS structures, one for each element that corresponded
  1853. // with the information passed in with the CHANGER_SEND_VOLUME_TAG_INFORMATION structure.
  1854. //
  1855. CHANGER_ELEMENT_STATUS ElementStatus[1];
  1856. } READ_ELEMENT_ADDRESS_INFO, *PREAD_ELEMENT_ADDRESS_INFO;
  1857. //
  1858. // Possible ActionCode values. See Features0 of CHANGER_GET_PARAMETERS for compatibility with
  1859. // the current device.
  1860. //
  1861. #define SEARCH_ALL 0x0 // Translate - search all defined volume tags.
  1862. #define SEARCH_PRIMARY 0x1 // Translate - search only primary volume tags.
  1863. #define SEARCH_ALTERNATE 0x2 // Translate - search only alternate volume tags.
  1864. #define SEARCH_ALL_NO_SEQ 0x4 // Translate - search all defined volume tags but ignore sequence numbers.
  1865. #define SEARCH_PRI_NO_SEQ 0x5 // Translate - search only primary volume tags but ignore sequence numbers.
  1866. #define SEARCH_ALT_NO_SEQ 0x6 // Translate - search only alternate volume tags but ignore sequence numbers.
  1867. #define ASSERT_PRIMARY 0x8 // Assert - as the primary volume tag - if tag now undefined.
  1868. #define ASSERT_ALTERNATE 0x9 // Assert - as the alternate volume tag - if tag now undefined.
  1869. #define REPLACE_PRIMARY 0xA // Replace - the primary volume tag - current tag ignored.
  1870. #define REPLACE_ALTERNATE 0xB // Replace - the alternate volume tag - current tag ignored.
  1871. #define UNDEFINE_PRIMARY 0xC // Undefine - the primary volume tag - current tag ignored.
  1872. #define UNDEFINE_ALTERNATE 0xD // Undefine - the alternate volume tag - current tag ignored.
  1873. //
  1874. // Changer diagnostic test related definitions
  1875. //
  1876. typedef enum _CHANGER_DEVICE_PROBLEM_TYPE {
  1877. DeviceProblemNone,
  1878. DeviceProblemHardware,
  1879. DeviceProblemCHMError,
  1880. DeviceProblemDoorOpen,
  1881. DeviceProblemCalibrationError,
  1882. DeviceProblemTargetFailure,
  1883. DeviceProblemCHMMoveError,
  1884. DeviceProblemCHMZeroError,
  1885. DeviceProblemCartridgeInsertError,
  1886. DeviceProblemPositionError,
  1887. DeviceProblemSensorError,
  1888. DeviceProblemCartridgeEjectError,
  1889. DeviceProblemGripperError,
  1890. DeviceProblemDriveError
  1891. } CHANGER_DEVICE_PROBLEM_TYPE, *PCHANGER_DEVICE_PROBLEM_TYPE;
  1892. #define IOCTL_SERIAL_LSRMST_INSERT CTL_CODE(FILE_DEVICE_SERIAL_PORT,31,METHOD_BUFFERED,FILE_ANY_ACCESS)
  1893. #define IOCTL_SERENUM_EXPOSE_HARDWARE CTL_CODE(FILE_DEVICE_SERENUM,128,METHOD_BUFFERED,FILE_ANY_ACCESS)
  1894. #define IOCTL_SERENUM_REMOVE_HARDWARE CTL_CODE(FILE_DEVICE_SERENUM,129,METHOD_BUFFERED,FILE_ANY_ACCESS)
  1895. #define IOCTL_SERENUM_PORT_DESC CTL_CODE(FILE_DEVICE_SERENUM,130,METHOD_BUFFERED,FILE_ANY_ACCESS)
  1896. #define IOCTL_SERENUM_GET_PORT_NAME CTL_CODE(FILE_DEVICE_SERENUM,131,METHOD_BUFFERED,FILE_ANY_ACCESS)
  1897. //
  1898. // The following values follow the escape designator in the
  1899. // data stream if the LSRMST_INSERT mode has been turned on.
  1900. //
  1901. #define SERIAL_LSRMST_ESCAPE ((BYTE )0x00)
  1902. //
  1903. // Following this value is the contents of the line status
  1904. // register, and then the character in the RX hardware when
  1905. // the line status register was encountered.
  1906. //
  1907. #define SERIAL_LSRMST_LSR_DATA ((BYTE )0x01)
  1908. //
  1909. // Following this value is the contents of the line status
  1910. // register. No error character follows
  1911. //
  1912. #define SERIAL_LSRMST_LSR_NODATA ((BYTE )0x02)
  1913. //
  1914. // Following this value is the contents of the modem status
  1915. // register.
  1916. //
  1917. #define SERIAL_LSRMST_MST ((BYTE )0x03)
  1918. //
  1919. // Bit values for FIFO Control Register
  1920. //
  1921. #define SERIAL_IOC_FCR_FIFO_ENABLE ((DWORD)0x00000001)
  1922. #define SERIAL_IOC_FCR_RCVR_RESET ((DWORD)0x00000002)
  1923. #define SERIAL_IOC_FCR_XMIT_RESET ((DWORD)0x00000004)
  1924. #define SERIAL_IOC_FCR_DMA_MODE ((DWORD)0x00000008)
  1925. #define SERIAL_IOC_FCR_RES1 ((DWORD)0x00000010)
  1926. #define SERIAL_IOC_FCR_RES2 ((DWORD)0x00000020)
  1927. #define SERIAL_IOC_FCR_RCVR_TRIGGER_LSB ((DWORD)0x00000040)
  1928. #define SERIAL_IOC_FCR_RCVR_TRIGGER_MSB ((DWORD)0x00000080)
  1929. //
  1930. // Bit values for Modem Control Register
  1931. //
  1932. #define SERIAL_IOC_MCR_DTR ((DWORD)0x00000001)
  1933. #define SERIAL_IOC_MCR_RTS ((DWORD)0x00000002)
  1934. #define SERIAL_IOC_MCR_OUT1 ((DWORD)0x00000004)
  1935. #define SERIAL_IOC_MCR_OUT2 ((DWORD)0x00000008)
  1936. #define SERIAL_IOC_MCR_LOOP ((DWORD)0x00000010)
  1937. #ifndef _FILESYSTEMFSCTL_
  1938. #define _FILESYSTEMFSCTL_
  1939. //
  1940. // The following is a list of the native file system fsctls followed by
  1941. // additional network file system fsctls. Some values have been
  1942. // decommissioned.
  1943. //
  1944. #define FSCTL_REQUEST_OPLOCK_LEVEL_1 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1945. #define FSCTL_REQUEST_OPLOCK_LEVEL_2 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1946. #define FSCTL_REQUEST_BATCH_OPLOCK CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1947. #define FSCTL_OPLOCK_BREAK_ACKNOWLEDGE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 3, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1948. #define FSCTL_OPBATCH_ACK_CLOSE_PENDING CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1949. #define FSCTL_OPLOCK_BREAK_NOTIFY CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 5, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1950. #define FSCTL_LOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1951. #define FSCTL_UNLOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1952. #define FSCTL_DISMOUNT_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1953. // decommissioned fsctl value 9
  1954. #define FSCTL_IS_VOLUME_MOUNTED CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1955. #define FSCTL_IS_PATHNAME_VALID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 11, METHOD_BUFFERED, FILE_ANY_ACCESS) // PATHNAME_BUFFER,
  1956. #define FSCTL_MARK_VOLUME_DIRTY CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1957. // decommissioned fsctl value 13
  1958. #define FSCTL_QUERY_RETRIEVAL_POINTERS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 14, METHOD_NEITHER, FILE_ANY_ACCESS)
  1959. #define FSCTL_GET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1960. #define FSCTL_SET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
  1961. // decommissioned fsctl value 17
  1962. // decommissioned fsctl value 18
  1963. #define FSCTL_MARK_AS_SYSTEM_HIVE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 19, METHOD_NEITHER, FILE_ANY_ACCESS)
  1964. #define FSCTL_OPLOCK_BREAK_ACK_NO_2 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1965. #define FSCTL_INVALIDATE_VOLUMES CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1966. #define FSCTL_QUERY_FAT_BPB CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, FILE_ANY_ACCESS) // FSCTL_QUERY_FAT_BPB_BUFFER
  1967. #define FSCTL_REQUEST_FILTER_OPLOCK CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 23, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1968. #define FSCTL_FILESYSTEM_GET_STATISTICS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 24, METHOD_BUFFERED, FILE_ANY_ACCESS) // FILESYSTEM_STATISTICS
  1969. #if(_WIN32_WINNT >= 0x0400)
  1970. #define FSCTL_GET_NTFS_VOLUME_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 25, METHOD_BUFFERED, FILE_ANY_ACCESS) // NTFS_VOLUME_DATA_BUFFER
  1971. #define FSCTL_GET_NTFS_FILE_RECORD CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 26, METHOD_BUFFERED, FILE_ANY_ACCESS) // NTFS_FILE_RECORD_INPUT_BUFFER, NTFS_FILE_RECORD_OUTPUT_BUFFER
  1972. #define FSCTL_GET_VOLUME_BITMAP CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 27, METHOD_NEITHER, FILE_ANY_ACCESS) // STARTING_LCN_INPUT_BUFFER, VOLUME_BITMAP_BUFFER
  1973. #define FSCTL_GET_RETRIEVAL_POINTERS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 28, METHOD_NEITHER, FILE_ANY_ACCESS) // STARTING_VCN_INPUT_BUFFER, RETRIEVAL_POINTERS_BUFFER
  1974. #define FSCTL_MOVE_FILE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // MOVE_FILE_DATA,
  1975. #define FSCTL_IS_VOLUME_DIRTY CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1976. // decomissioned fsctl value 31
  1977. #define FSCTL_ALLOW_EXTENDED_DASD_IO CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 32, METHOD_NEITHER, FILE_ANY_ACCESS)
  1978. #endif /* _WIN32_WINNT >= 0x0400 */
  1979. #if(_WIN32_WINNT >= 0x0500)
  1980. // decommissioned fsctl value 33
  1981. // decommissioned fsctl value 34
  1982. #define FSCTL_FIND_FILES_BY_SID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 35, METHOD_NEITHER, FILE_ANY_ACCESS)
  1983. // decommissioned fsctl value 36
  1984. // decommissioned fsctl value 37
  1985. #define FSCTL_SET_OBJECT_ID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 38, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // FILE_OBJECTID_BUFFER
  1986. #define FSCTL_GET_OBJECT_ID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 39, METHOD_BUFFERED, FILE_ANY_ACCESS) // FILE_OBJECTID_BUFFER
  1987. #define FSCTL_DELETE_OBJECT_ID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 40, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
  1988. #define FSCTL_SET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // REPARSE_DATA_BUFFER,
  1989. #define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS) // REPARSE_DATA_BUFFER
  1990. #define FSCTL_DELETE_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // REPARSE_DATA_BUFFER,
  1991. #define FSCTL_ENUM_USN_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 44, METHOD_NEITHER, FILE_ANY_ACCESS) // MFT_ENUM_DATA,
  1992. #define FSCTL_SECURITY_ID_CHECK CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 45, METHOD_NEITHER, FILE_READ_DATA) // BULK_SECURITY_TEST_DATA,
  1993. #define FSCTL_READ_USN_JOURNAL CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 46, METHOD_NEITHER, FILE_ANY_ACCESS) // READ_USN_JOURNAL_DATA, USN
  1994. #define FSCTL_SET_OBJECT_ID_EXTENDED CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 47, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
  1995. #define FSCTL_CREATE_OR_GET_OBJECT_ID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 48, METHOD_BUFFERED, FILE_ANY_ACCESS) // FILE_OBJECTID_BUFFER
  1996. #define FSCTL_SET_SPARSE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
  1997. #define FSCTL_SET_ZERO_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, FILE_WRITE_DATA) // FILE_ZERO_DATA_INFORMATION,
  1998. #define FSCTL_QUERY_ALLOCATED_RANGES CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 51, METHOD_NEITHER, FILE_READ_DATA) // FILE_ALLOCATED_RANGE_BUFFER, FILE_ALLOCATED_RANGE_BUFFER
  1999. // decommissioned fsctl value 52
  2000. #define FSCTL_SET_ENCRYPTION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 53, METHOD_NEITHER, FILE_ANY_ACCESS) // ENCRYPTION_BUFFER, DECRYPTION_STATUS_BUFFER
  2001. #define FSCTL_ENCRYPTION_FSCTL_IO CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 54, METHOD_NEITHER, FILE_ANY_ACCESS)
  2002. #define FSCTL_WRITE_RAW_ENCRYPTED CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 55, METHOD_NEITHER, FILE_SPECIAL_ACCESS) // ENCRYPTED_DATA_INFO,
  2003. #define FSCTL_READ_RAW_ENCRYPTED CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 56, METHOD_NEITHER, FILE_SPECIAL_ACCESS) // REQUEST_RAW_ENCRYPTED_DATA, ENCRYPTED_DATA_INFO
  2004. #define FSCTL_CREATE_USN_JOURNAL CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 57, METHOD_NEITHER, FILE_ANY_ACCESS) // CREATE_USN_JOURNAL_DATA,
  2005. #define FSCTL_READ_FILE_USN_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 58, METHOD_NEITHER, FILE_ANY_ACCESS) // Read the Usn Record for a file
  2006. #define FSCTL_WRITE_USN_CLOSE_RECORD CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 59, METHOD_NEITHER, FILE_ANY_ACCESS) // Generate Close Usn Record
  2007. #define FSCTL_EXTEND_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2008. #define FSCTL_QUERY_USN_JOURNAL CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 61, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2009. #define FSCTL_DELETE_USN_JOURNAL CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 62, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2010. #define FSCTL_MARK_HANDLE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 63, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2011. #define FSCTL_SIS_COPYFILE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 64, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2012. #define FSCTL_SIS_LINK_FILES CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 65, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
  2013. #define FSCTL_HSM_MSG CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 66, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
  2014. // decommissioned fsctl value 67
  2015. #define FSCTL_HSM_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 68, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA)
  2016. #define FSCTL_RECALL_FILE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 69, METHOD_NEITHER, FILE_ANY_ACCESS)
  2017. // decommissioned fsctl value 70
  2018. #define FSCTL_READ_FROM_PLEX CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 71, METHOD_OUT_DIRECT, FILE_READ_DATA)
  2019. #define FSCTL_FILE_PREFETCH CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 72, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // FILE_PREFETCH
  2020. #endif /* _WIN32_WINNT >= 0x0500 */
  2021. //
  2022. // The following long list of structs are associated with the preceeding
  2023. // file system fsctls.
  2024. //
  2025. //
  2026. // Structure for FSCTL_IS_PATHNAME_VALID
  2027. //
  2028. typedef struct _PATHNAME_BUFFER {
  2029. DWORD PathNameLength;
  2030. WCHAR Name[1];
  2031. } PATHNAME_BUFFER, *PPATHNAME_BUFFER;
  2032. //
  2033. // Structure for FSCTL_QUERY_BPB_INFO
  2034. //
  2035. typedef struct _FSCTL_QUERY_FAT_BPB_BUFFER {
  2036. BYTE First0x24BytesOfBootSector[0x24];
  2037. } FSCTL_QUERY_FAT_BPB_BUFFER, *PFSCTL_QUERY_FAT_BPB_BUFFER;
  2038. #if(_WIN32_WINNT >= 0x0400)
  2039. //
  2040. // Structures for FSCTL_GET_NTFS_VOLUME_DATA.
  2041. // The user must pass the basic buffer below. Ntfs
  2042. // will return as many fields as available in the extended
  2043. // buffer which follows immediately after the VOLUME_DATA_BUFFER.
  2044. //
  2045. typedef struct {
  2046. LARGE_INTEGER VolumeSerialNumber;
  2047. LARGE_INTEGER NumberSectors;
  2048. LARGE_INTEGER TotalClusters;
  2049. LARGE_INTEGER FreeClusters;
  2050. LARGE_INTEGER TotalReserved;
  2051. DWORD BytesPerSector;
  2052. DWORD BytesPerCluster;
  2053. DWORD BytesPerFileRecordSegment;
  2054. DWORD ClustersPerFileRecordSegment;
  2055. LARGE_INTEGER MftValidDataLength;
  2056. LARGE_INTEGER MftStartLcn;
  2057. LARGE_INTEGER Mft2StartLcn;
  2058. LARGE_INTEGER MftZoneStart;
  2059. LARGE_INTEGER MftZoneEnd;
  2060. } NTFS_VOLUME_DATA_BUFFER, *PNTFS_VOLUME_DATA_BUFFER;
  2061. typedef struct {
  2062. DWORD ByteCount;
  2063. WORD MajorVersion;
  2064. WORD MinorVersion;
  2065. } NTFS_EXTENDED_VOLUME_DATA, *PNTFS_EXTENDED_VOLUME_DATA;
  2066. #endif /* _WIN32_WINNT >= 0x0400 */
  2067. #if(_WIN32_WINNT >= 0x0400)
  2068. //
  2069. // Structure for FSCTL_GET_VOLUME_BITMAP
  2070. //
  2071. typedef struct {
  2072. LARGE_INTEGER StartingLcn;
  2073. } STARTING_LCN_INPUT_BUFFER, *PSTARTING_LCN_INPUT_BUFFER;
  2074. typedef struct {
  2075. LARGE_INTEGER StartingLcn;
  2076. LARGE_INTEGER BitmapSize;
  2077. BYTE Buffer[1];
  2078. } VOLUME_BITMAP_BUFFER, *PVOLUME_BITMAP_BUFFER;
  2079. #endif /* _WIN32_WINNT >= 0x0400 */
  2080. #if(_WIN32_WINNT >= 0x0400)
  2081. //
  2082. // Structure for FSCTL_GET_RETRIEVAL_POINTERS
  2083. //
  2084. typedef struct {
  2085. LARGE_INTEGER StartingVcn;
  2086. } STARTING_VCN_INPUT_BUFFER, *PSTARTING_VCN_INPUT_BUFFER;
  2087. typedef struct RETRIEVAL_POINTERS_BUFFER {
  2088. DWORD ExtentCount;
  2089. LARGE_INTEGER StartingVcn;
  2090. struct {
  2091. LARGE_INTEGER NextVcn;
  2092. LARGE_INTEGER Lcn;
  2093. } Extents[1];
  2094. } RETRIEVAL_POINTERS_BUFFER, *PRETRIEVAL_POINTERS_BUFFER;
  2095. #endif /* _WIN32_WINNT >= 0x0400 */
  2096. #if(_WIN32_WINNT >= 0x0400)
  2097. //
  2098. // Structures for FSCTL_GET_NTFS_FILE_RECORD
  2099. //
  2100. typedef struct {
  2101. LARGE_INTEGER FileReferenceNumber;
  2102. } NTFS_FILE_RECORD_INPUT_BUFFER, *PNTFS_FILE_RECORD_INPUT_BUFFER;
  2103. typedef struct {
  2104. LARGE_INTEGER FileReferenceNumber;
  2105. DWORD FileRecordLength;
  2106. BYTE FileRecordBuffer[1];
  2107. } NTFS_FILE_RECORD_OUTPUT_BUFFER, *PNTFS_FILE_RECORD_OUTPUT_BUFFER;
  2108. #endif /* _WIN32_WINNT >= 0x0400 */
  2109. #if(_WIN32_WINNT >= 0x0400)
  2110. //
  2111. // Structure for FSCTL_MOVE_FILE
  2112. //
  2113. typedef struct {
  2114. HANDLE FileHandle;
  2115. LARGE_INTEGER StartingVcn;
  2116. LARGE_INTEGER StartingLcn;
  2117. DWORD ClusterCount;
  2118. } MOVE_FILE_DATA, *PMOVE_FILE_DATA;
  2119. #if defined(_WIN64)
  2120. //
  2121. // 32/64 Bit thunking support structure
  2122. //
  2123. typedef struct _MOVE_FILE_DATA32 {
  2124. UINT32 FileHandle;
  2125. LARGE_INTEGER StartingVcn;
  2126. LARGE_INTEGER StartingLcn;
  2127. DWORD ClusterCount;
  2128. } MOVE_FILE_DATA32, *PMOVE_FILE_DATA32;
  2129. #endif
  2130. #endif /* _WIN32_WINNT >= 0x0400 */
  2131. #if(_WIN32_WINNT >= 0x0500)
  2132. //
  2133. // Structure for FSCTL_FIND_FILES_BY_SID
  2134. //
  2135. typedef struct {
  2136. DWORD Restart;
  2137. SID Sid;
  2138. } FIND_BY_SID_DATA, *PFIND_BY_SID_DATA;
  2139. #endif /* _WIN32_WINNT >= 0x0500 */
  2140. #if(_WIN32_WINNT >= 0x0500)
  2141. //
  2142. // The following structures apply to Usn operations.
  2143. //
  2144. //
  2145. // Structure for FSCTL_ENUM_USN_DATA
  2146. //
  2147. typedef struct {
  2148. DWORDLONG StartFileReferenceNumber;
  2149. USN LowUsn;
  2150. USN HighUsn;
  2151. } MFT_ENUM_DATA, *PMFT_ENUM_DATA;
  2152. //
  2153. // Structure for FSCTL_CREATE_USN_JOURNAL
  2154. //
  2155. typedef struct {
  2156. DWORDLONG MaximumSize;
  2157. DWORDLONG AllocationDelta;
  2158. } CREATE_USN_JOURNAL_DATA, *PCREATE_USN_JOURNAL_DATA;
  2159. //
  2160. // Structure for FSCTL_READ_USN_JOURNAL
  2161. //
  2162. typedef struct {
  2163. USN StartUsn;
  2164. DWORD ReasonMask;
  2165. DWORD ReturnOnlyOnClose;
  2166. DWORDLONG Timeout;
  2167. DWORDLONG BytesToWaitFor;
  2168. DWORDLONG UsnJournalID;
  2169. } READ_USN_JOURNAL_DATA, *PREAD_USN_JOURNAL_DATA;
  2170. //
  2171. // The initial Major.Minor version of the Usn record will be 2.0.
  2172. // In general, the MinorVersion may be changed if fields are added
  2173. // to this structure in such a way that the previous version of the
  2174. // software can still correctly the fields it knows about. The
  2175. // MajorVersion should only be changed if the previous version of
  2176. // any software using this structure would incorrectly handle new
  2177. // records due to structure changes.
  2178. //
  2179. // The first update to this will force the structure to version 2.0.
  2180. // This will add the extended information about the source as
  2181. // well as indicate the file name offset within the structure.
  2182. //
  2183. // The following structure is returned with these fsctls.
  2184. //
  2185. // FSCTL_READ_USN_JOURNAL
  2186. // FSCTL_READ_FILE_USN_DATA
  2187. // FSCTL_ENUM_USN_DATA
  2188. //
  2189. typedef struct {
  2190. DWORD RecordLength;
  2191. WORD MajorVersion;
  2192. WORD MinorVersion;
  2193. DWORDLONG FileReferenceNumber;
  2194. DWORDLONG ParentFileReferenceNumber;
  2195. USN Usn;
  2196. LARGE_INTEGER TimeStamp;
  2197. DWORD Reason;
  2198. DWORD SourceInfo;
  2199. DWORD SecurityId;
  2200. DWORD FileAttributes;
  2201. WORD FileNameLength;
  2202. WORD FileNameOffset;
  2203. WCHAR FileName[1];
  2204. } USN_RECORD, *PUSN_RECORD;
  2205. #define USN_PAGE_SIZE (0x1000)
  2206. #define USN_REASON_DATA_OVERWRITE (0x00000001)
  2207. #define USN_REASON_DATA_EXTEND (0x00000002)
  2208. #define USN_REASON_DATA_TRUNCATION (0x00000004)
  2209. #define USN_REASON_NAMED_DATA_OVERWRITE (0x00000010)
  2210. #define USN_REASON_NAMED_DATA_EXTEND (0x00000020)
  2211. #define USN_REASON_NAMED_DATA_TRUNCATION (0x00000040)
  2212. #define USN_REASON_FILE_CREATE (0x00000100)
  2213. #define USN_REASON_FILE_DELETE (0x00000200)
  2214. #define USN_REASON_EA_CHANGE (0x00000400)
  2215. #define USN_REASON_SECURITY_CHANGE (0x00000800)
  2216. #define USN_REASON_RENAME_OLD_NAME (0x00001000)
  2217. #define USN_REASON_RENAME_NEW_NAME (0x00002000)
  2218. #define USN_REASON_INDEXABLE_CHANGE (0x00004000)
  2219. #define USN_REASON_BASIC_INFO_CHANGE (0x00008000)
  2220. #define USN_REASON_HARD_LINK_CHANGE (0x00010000)
  2221. #define USN_REASON_COMPRESSION_CHANGE (0x00020000)
  2222. #define USN_REASON_ENCRYPTION_CHANGE (0x00040000)
  2223. #define USN_REASON_OBJECT_ID_CHANGE (0x00080000)
  2224. #define USN_REASON_REPARSE_POINT_CHANGE (0x00100000)
  2225. #define USN_REASON_STREAM_CHANGE (0x00200000)
  2226. #define USN_REASON_CLOSE (0x80000000)
  2227. //
  2228. // Structure for FSCTL_QUERY_USN_JOUNAL
  2229. //
  2230. typedef struct {
  2231. DWORDLONG UsnJournalID;
  2232. USN FirstUsn;
  2233. USN NextUsn;
  2234. USN LowestValidUsn;
  2235. USN MaxUsn;
  2236. DWORDLONG MaximumSize;
  2237. DWORDLONG AllocationDelta;
  2238. } USN_JOURNAL_DATA, *PUSN_JOURNAL_DATA;
  2239. //
  2240. // Structure for FSCTL_DELETE_USN_JOURNAL
  2241. //
  2242. typedef struct {
  2243. DWORDLONG UsnJournalID;
  2244. DWORD DeleteFlags;
  2245. } DELETE_USN_JOURNAL_DATA, *PDELETE_USN_JOURNAL_DATA;
  2246. #define USN_DELETE_FLAG_DELETE (0x00000001)
  2247. #define USN_DELETE_FLAG_NOTIFY (0x00000002)
  2248. #define USN_DELETE_VALID_FLAGS (0x00000003)
  2249. //
  2250. // Structure for FSCTL_MARK_HANDLE
  2251. //
  2252. typedef struct {
  2253. DWORD UsnSourceInfo;
  2254. HANDLE VolumeHandle;
  2255. DWORD HandleInfo;
  2256. } MARK_HANDLE_INFO, *PMARK_HANDLE_INFO;
  2257. #if defined(_WIN64)
  2258. //
  2259. // 32/64 Bit thunking support structure
  2260. //
  2261. typedef struct {
  2262. DWORD UsnSourceInfo;
  2263. UINT32 VolumeHandle;
  2264. DWORD HandleInfo;
  2265. } MARK_HANDLE_INFO32, *PMARK_HANDLE_INFO32;
  2266. #endif
  2267. //
  2268. // Flags for the additional source information above.
  2269. //
  2270. // USN_SOURCE_DATA_MANAGEMENT - Service is not modifying the external view
  2271. // of any part of the file. Typical case is HSM moving data to
  2272. // and from external storage.
  2273. //
  2274. // USN_SOURCE_AUXILIARY_DATA - Service is not modifying the external view
  2275. // of the file with regard to the application that created this file.
  2276. // Can be used to add private data streams to a file.
  2277. //
  2278. // USN_SOURCE_REPLICATION_MANAGEMENT - Service is modifying a file to match
  2279. // the contents of the same file which exists in another member of the
  2280. // replica set.
  2281. //
  2282. #define USN_SOURCE_DATA_MANAGEMENT (0x00000001)
  2283. #define USN_SOURCE_AUXILIARY_DATA (0x00000002)
  2284. #define USN_SOURCE_REPLICATION_MANAGEMENT (0x00000004)
  2285. //
  2286. // Flags for the HandleInfo field above
  2287. //
  2288. // MARK_HANDLE_PROTECT_CLUSTERS - disallow any defragmenting (FSCTL_MOVE_FILE) until the
  2289. // the handle is closed
  2290. //
  2291. #define MARK_HANDLE_PROTECT_CLUSTERS (0x00000001)
  2292. #endif /* _WIN32_WINNT >= 0x0500 */
  2293. #if(_WIN32_WINNT >= 0x0500)
  2294. //
  2295. // Structure for FSCTL_SECURITY_ID_CHECK
  2296. //
  2297. typedef struct {
  2298. ACCESS_MASK DesiredAccess;
  2299. DWORD SecurityIds[1];
  2300. } BULK_SECURITY_TEST_DATA, *PBULK_SECURITY_TEST_DATA;
  2301. #endif /* _WIN32_WINNT >= 0x0500 */
  2302. #if(_WIN32_WINNT >= 0x0500)
  2303. //
  2304. // Output flags for the FSCTL_IS_VOLUME_DIRTY
  2305. //
  2306. #define VOLUME_IS_DIRTY (0x00000001)
  2307. #define VOLUME_UPGRADE_SCHEDULED (0x00000002)
  2308. #endif /* _WIN32_WINNT >= 0x0500 */
  2309. //
  2310. // Structures for FSCTL_FILE_PREFETCH
  2311. //
  2312. typedef struct _FILE_PREFETCH {
  2313. DWORD Type;
  2314. DWORD Count;
  2315. DWORDLONG Prefetch[1];
  2316. } FILE_PREFETCH, *PFILE_PREFETCH;
  2317. #define FILE_PREFETCH_TYPE_FOR_CREATE 0x1
  2318. // Structures for FSCTL_FILESYSTEM_GET_STATISTICS
  2319. //
  2320. // Filesystem performance counters
  2321. //
  2322. typedef struct _FILESYSTEM_STATISTICS {
  2323. WORD FileSystemType;
  2324. WORD Version; // currently version 1
  2325. DWORD SizeOfCompleteStructure; // must by a mutiple of 64 bytes
  2326. DWORD UserFileReads;
  2327. DWORD UserFileReadBytes;
  2328. DWORD UserDiskReads;
  2329. DWORD UserFileWrites;
  2330. DWORD UserFileWriteBytes;
  2331. DWORD UserDiskWrites;
  2332. DWORD MetaDataReads;
  2333. DWORD MetaDataReadBytes;
  2334. DWORD MetaDataDiskReads;
  2335. DWORD MetaDataWrites;
  2336. DWORD MetaDataWriteBytes;
  2337. DWORD MetaDataDiskWrites;
  2338. //
  2339. // The file system's private structure is appended here.
  2340. //
  2341. } FILESYSTEM_STATISTICS, *PFILESYSTEM_STATISTICS;
  2342. // values for FS_STATISTICS.FileSystemType
  2343. #define FILESYSTEM_STATISTICS_TYPE_NTFS 1
  2344. #define FILESYSTEM_STATISTICS_TYPE_FAT 2
  2345. //
  2346. // File System Specific Statistics Data
  2347. //
  2348. typedef struct _FAT_STATISTICS {
  2349. DWORD CreateHits;
  2350. DWORD SuccessfulCreates;
  2351. DWORD FailedCreates;
  2352. DWORD NonCachedReads;
  2353. DWORD NonCachedReadBytes;
  2354. DWORD NonCachedWrites;
  2355. DWORD NonCachedWriteBytes;
  2356. DWORD NonCachedDiskReads;
  2357. DWORD NonCachedDiskWrites;
  2358. } FAT_STATISTICS, *PFAT_STATISTICS;
  2359. typedef struct _NTFS_STATISTICS {
  2360. DWORD LogFileFullExceptions;
  2361. DWORD OtherExceptions;
  2362. //
  2363. // Other meta data io's
  2364. //
  2365. DWORD MftReads;
  2366. DWORD MftReadBytes;
  2367. DWORD MftWrites;
  2368. DWORD MftWriteBytes;
  2369. struct {
  2370. WORD Write;
  2371. WORD Create;
  2372. WORD SetInfo;
  2373. WORD Flush;
  2374. } MftWritesUserLevel;
  2375. WORD MftWritesFlushForLogFileFull;
  2376. WORD MftWritesLazyWriter;
  2377. WORD MftWritesUserRequest;
  2378. DWORD Mft2Writes;
  2379. DWORD Mft2WriteBytes;
  2380. struct {
  2381. WORD Write;
  2382. WORD Create;
  2383. WORD SetInfo;
  2384. WORD Flush;
  2385. } Mft2WritesUserLevel;
  2386. WORD Mft2WritesFlushForLogFileFull;
  2387. WORD Mft2WritesLazyWriter;
  2388. WORD Mft2WritesUserRequest;
  2389. DWORD RootIndexReads;
  2390. DWORD RootIndexReadBytes;
  2391. DWORD RootIndexWrites;
  2392. DWORD RootIndexWriteBytes;
  2393. DWORD BitmapReads;
  2394. DWORD BitmapReadBytes;
  2395. DWORD BitmapWrites;
  2396. DWORD BitmapWriteBytes;
  2397. WORD BitmapWritesFlushForLogFileFull;
  2398. WORD BitmapWritesLazyWriter;
  2399. WORD BitmapWritesUserRequest;
  2400. struct {
  2401. WORD Write;
  2402. WORD Create;
  2403. WORD SetInfo;
  2404. } BitmapWritesUserLevel;
  2405. DWORD MftBitmapReads;
  2406. DWORD MftBitmapReadBytes;
  2407. DWORD MftBitmapWrites;
  2408. DWORD MftBitmapWriteBytes;
  2409. WORD MftBitmapWritesFlushForLogFileFull;
  2410. WORD MftBitmapWritesLazyWriter;
  2411. WORD MftBitmapWritesUserRequest;
  2412. struct {
  2413. WORD Write;
  2414. WORD Create;
  2415. WORD SetInfo;
  2416. WORD Flush;
  2417. } MftBitmapWritesUserLevel;
  2418. DWORD UserIndexReads;
  2419. DWORD UserIndexReadBytes;
  2420. DWORD UserIndexWrites;
  2421. DWORD UserIndexWriteBytes;
  2422. //
  2423. // Additions for NT 5.0
  2424. //
  2425. DWORD LogFileReads;
  2426. DWORD LogFileReadBytes;
  2427. DWORD LogFileWrites;
  2428. DWORD LogFileWriteBytes;
  2429. struct {
  2430. DWORD Calls; // number of individual calls to allocate clusters
  2431. DWORD Clusters; // number of clusters allocated
  2432. DWORD Hints; // number of times a hint was specified
  2433. DWORD RunsReturned; // number of runs used to satisify all the requests
  2434. DWORD HintsHonored; // number of times the hint was useful
  2435. DWORD HintsClusters; // number of clusters allocated via the hint
  2436. DWORD Cache; // number of times the cache was useful other than the hint
  2437. DWORD CacheClusters; // number of clusters allocated via the cache other than the hint
  2438. DWORD CacheMiss; // number of times the cache wasn't useful
  2439. DWORD CacheMissClusters; // number of clusters allocated without the cache
  2440. } Allocate;
  2441. } NTFS_STATISTICS, *PNTFS_STATISTICS;
  2442. #if(_WIN32_WINNT >= 0x0500)
  2443. //
  2444. // Structure for FSCTL_SET_OBJECT_ID, FSCTL_GET_OBJECT_ID, and FSCTL_CREATE_OR_GET_OBJECT_ID
  2445. //
  2446. #if _MSC_VER >= 1200
  2447. #pragma warning(push)
  2448. #endif
  2449. #pragma warning(disable:4201) // unnamed struct
  2450. typedef struct _FILE_OBJECTID_BUFFER {
  2451. //
  2452. // This is the portion of the object id that is indexed.
  2453. //
  2454. BYTE ObjectId[16];
  2455. //
  2456. // This portion of the object id is not indexed, it's just
  2457. // some metadata for the user's benefit.
  2458. //
  2459. union {
  2460. struct {
  2461. BYTE BirthVolumeId[16];
  2462. BYTE BirthObjectId[16];
  2463. BYTE DomainId[16];
  2464. } ;
  2465. BYTE ExtendedInfo[48];
  2466. };
  2467. } FILE_OBJECTID_BUFFER, *PFILE_OBJECTID_BUFFER;
  2468. #if _MSC_VER >= 1200
  2469. #pragma warning(pop)
  2470. #else
  2471. #pragma warning( default : 4201 )
  2472. #endif
  2473. #endif /* _WIN32_WINNT >= 0x0500 */
  2474. #if(_WIN32_WINNT >= 0x0500)
  2475. //
  2476. // Structure for FSCTL_SET_SPARSE
  2477. //
  2478. typedef struct _FILE_SET_SPARSE_BUFFER {
  2479. BOOLEAN SetSparse;
  2480. } FILE_SET_SPARSE_BUFFER, *PFILE_SET_SPARSE_BUFFER;
  2481. #endif /* _WIN32_WINNT >= 0x0500 */
  2482. #if(_WIN32_WINNT >= 0x0500)
  2483. //
  2484. // Structure for FSCTL_SET_ZERO_DATA
  2485. //
  2486. typedef struct _FILE_ZERO_DATA_INFORMATION {
  2487. LARGE_INTEGER FileOffset;
  2488. LARGE_INTEGER BeyondFinalZero;
  2489. } FILE_ZERO_DATA_INFORMATION, *PFILE_ZERO_DATA_INFORMATION;
  2490. #endif /* _WIN32_WINNT >= 0x0500 */
  2491. #if(_WIN32_WINNT >= 0x0500)
  2492. //
  2493. // Structure for FSCTL_QUERY_ALLOCATED_RANGES
  2494. //
  2495. //
  2496. // Querying the allocated ranges requires an output buffer to store the
  2497. // allocated ranges and an input buffer to specify the range to query.
  2498. // The input buffer contains a single entry, the output buffer is an
  2499. // array of the following structure.
  2500. //
  2501. typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
  2502. LARGE_INTEGER FileOffset;
  2503. LARGE_INTEGER Length;
  2504. } FILE_ALLOCATED_RANGE_BUFFER, *PFILE_ALLOCATED_RANGE_BUFFER;
  2505. #endif /* _WIN32_WINNT >= 0x0500 */
  2506. #if(_WIN32_WINNT >= 0x0500)
  2507. //
  2508. // Structures for FSCTL_SET_ENCRYPTION, FSCTL_WRITE_RAW_ENCRYPTED, and FSCTL_READ_RAW_ENCRYPTED
  2509. //
  2510. //
  2511. // The input buffer to set encryption indicates whether we are to encrypt/decrypt a file
  2512. // or an individual stream.
  2513. //
  2514. typedef struct _ENCRYPTION_BUFFER {
  2515. DWORD EncryptionOperation;
  2516. BYTE Private[1];
  2517. } ENCRYPTION_BUFFER, *PENCRYPTION_BUFFER;
  2518. #define FILE_SET_ENCRYPTION 0x00000001
  2519. #define FILE_CLEAR_ENCRYPTION 0x00000002
  2520. #define STREAM_SET_ENCRYPTION 0x00000003
  2521. #define STREAM_CLEAR_ENCRYPTION 0x00000004
  2522. #define MAXIMUM_ENCRYPTION_VALUE 0x00000004
  2523. //
  2524. // The optional output buffer to set encryption indicates that the last encrypted
  2525. // stream in a file has been marked as decrypted.
  2526. //
  2527. typedef struct _DECRYPTION_STATUS_BUFFER {
  2528. BOOLEAN NoEncryptedStreams;
  2529. } DECRYPTION_STATUS_BUFFER, *PDECRYPTION_STATUS_BUFFER;
  2530. #define ENCRYPTION_FORMAT_DEFAULT (0x01)
  2531. #define COMPRESSION_FORMAT_SPARSE (0x4000)
  2532. //
  2533. // Request Encrypted Data structure. This is used to indicate
  2534. // the range of the file to read. It also describes the
  2535. // output buffer used to return the data.
  2536. //
  2537. typedef struct _REQUEST_RAW_ENCRYPTED_DATA {
  2538. //
  2539. // Requested file offset and requested length to read.
  2540. // The fsctl will round the starting offset down
  2541. // to a file system boundary. It will also
  2542. // round the length up to a file system boundary.
  2543. //
  2544. LONGLONG FileOffset;
  2545. DWORD Length;
  2546. } REQUEST_RAW_ENCRYPTED_DATA, *PREQUEST_RAW_ENCRYPTED_DATA;
  2547. //
  2548. // Encrypted Data Information structure. This structure
  2549. // is used to return raw encrypted data from a file in
  2550. // order to perform off-line recovery. The data will be
  2551. // encrypted or encrypted and compressed. The off-line
  2552. // service will need to use the encryption and compression
  2553. // format information to recover the file data. In the
  2554. // event that the data is both encrypted and compressed then
  2555. // the decryption must occur before decompression. All
  2556. // the data units below must be encrypted and compressed
  2557. // with the same format.
  2558. //
  2559. // The data will be returned in units. The data unit size
  2560. // will be fixed per request. If the data is compressed
  2561. // then the data unit size will be the compression unit size.
  2562. //
  2563. // This structure is at the beginning of the buffer used to
  2564. // return the encrypted data. The actual raw bytes from
  2565. // the file will follow this buffer. The offset of the
  2566. // raw bytes from the beginning of this structure is
  2567. // specified in the REQUEST_RAW_ENCRYPTED_DATA structure
  2568. // described above.
  2569. //
  2570. typedef struct _ENCRYPTED_DATA_INFO {
  2571. //
  2572. // This is the file offset for the first entry in the
  2573. // data block array. The file system will round
  2574. // the requested start offset down to a boundary
  2575. // that is consistent with the format of the file.
  2576. //
  2577. DWORDLONG StartingFileOffset;
  2578. //
  2579. // Data offset in output buffer. The output buffer
  2580. // begins with an ENCRYPTED_DATA_INFO structure.
  2581. // The file system will then store the raw bytes from
  2582. // disk beginning at the following offset within the
  2583. // output buffer.
  2584. //
  2585. DWORD OutputBufferOffset;
  2586. //
  2587. // The number of bytes being returned that are within
  2588. // the size of the file. If this value is less than
  2589. // (NumberOfDataBlocks << DataUnitShift), it means the
  2590. // end of the file occurs within this transfer. Any
  2591. // data beyond file size is invalid and was never
  2592. // passed to the encryption driver.
  2593. //
  2594. DWORD BytesWithinFileSize;
  2595. //
  2596. // The number of bytes being returned that are below
  2597. // valid data length. If this value is less than
  2598. // (NumberOfDataBlocks << DataUnitShift), it means the
  2599. // end of the valid data occurs within this transfer.
  2600. // After decrypting the data from this transfer, any
  2601. // byte(s) beyond valid data length must be zeroed.
  2602. //
  2603. DWORD BytesWithinValidDataLength;
  2604. //
  2605. // Code for the compression format as defined in
  2606. // ntrtl.h. Note that COMPRESSION_FORMAT_NONE
  2607. // and COMPRESSION_FORMAT_DEFAULT are invalid if
  2608. // any of the described chunks are compressed.
  2609. //
  2610. WORD CompressionFormat;
  2611. //
  2612. // The DataUnit is the granularity used to access the
  2613. // disk. It will be the same as the compression unit
  2614. // size for a compressed file. For an uncompressed
  2615. // file, it will be some cluster-aligned power of 2 that
  2616. // the file system deems convenient. A caller should
  2617. // not expect that successive calls will have the
  2618. // same data unit shift value as the previous call.
  2619. //
  2620. // Since chunks and compression units are expected to be
  2621. // powers of 2 in size, we express them log2. So, for
  2622. // example (1 << ChunkShift) == ChunkSizeInBytes. The
  2623. // ClusterShift indicates how much space must be saved
  2624. // to successfully compress a compression unit - each
  2625. // successfully compressed data unit must occupy
  2626. // at least one cluster less in bytes than an uncompressed
  2627. // data block unit.
  2628. //
  2629. BYTE DataUnitShift;
  2630. BYTE ChunkShift;
  2631. BYTE ClusterShift;
  2632. //
  2633. // The format for the encryption.
  2634. //
  2635. BYTE EncryptionFormat;
  2636. //
  2637. // This is the number of entries in the data block size
  2638. // array.
  2639. //
  2640. WORD NumberOfDataBlocks;
  2641. //
  2642. // This is an array of sizes in the data block array. There
  2643. // must be one entry in this array for each data block
  2644. // read from disk. The size has a different meaning
  2645. // depending on whether the file is compressed.
  2646. //
  2647. // A size of zero always indicates that the final data consists entirely
  2648. // of zeroes. There is no decryption or decompression to
  2649. // perform.
  2650. //
  2651. // If the file is compressed then the data block size indicates
  2652. // whether this block is compressed. A size equal to
  2653. // the block size indicates that the corresponding block did
  2654. // not compress. Any other non-zero size indicates the
  2655. // size of the compressed data which needs to be
  2656. // decrypted/decompressed.
  2657. //
  2658. // If the file is not compressed then the data block size
  2659. // indicates the amount of data within the block that
  2660. // needs to be decrypted. Any other non-zero size indicates
  2661. // that the remaining bytes in the data unit within the file
  2662. // consists of zeros. An example of this is when the
  2663. // the read spans the valid data length of the file. There
  2664. // is no data to decrypt past the valid data length.
  2665. //
  2666. DWORD DataBlockSize[ANYSIZE_ARRAY];
  2667. } ENCRYPTED_DATA_INFO;
  2668. typedef ENCRYPTED_DATA_INFO *PENCRYPTED_DATA_INFO;
  2669. #endif /* _WIN32_WINNT >= 0x0500 */
  2670. #if(_WIN32_WINNT >= 0x0500)
  2671. //
  2672. // FSCTL_READ_FROM_PLEX support
  2673. // Request Plex Read Data structure. This is used to indicate
  2674. // the range of the file to read. It also describes
  2675. // which plex to perform the read from.
  2676. //
  2677. typedef struct _PLEX_READ_DATA_REQUEST {
  2678. //
  2679. // Requested offset and length to read.
  2680. // The offset can be the virtual offset (vbo) in to a file,
  2681. // or a volume. In the case of a file offset,
  2682. // the fsd will round the starting offset down
  2683. // to a file system boundary. It will also
  2684. // round the length up to a file system boundary and
  2685. // enforce any other applicable limits.
  2686. //
  2687. LARGE_INTEGER ByteOffset;
  2688. DWORD ByteLength;
  2689. DWORD PlexNumber;
  2690. } PLEX_READ_DATA_REQUEST, *PPLEX_READ_DATA_REQUEST;
  2691. #endif /* _WIN32_WINNT >= 0x0500 */
  2692. #if(_WIN32_WINNT >= 0x0500)
  2693. //
  2694. // FSCTL_SIS_COPYFILE support
  2695. // Source and destination file names are passed in the FileNameBuffer.
  2696. // Both strings are null terminated, with the source name starting at
  2697. // the beginning of FileNameBuffer, and the destination name immediately
  2698. // following. Length fields include terminating nulls.
  2699. //
  2700. typedef struct _SI_COPYFILE {
  2701. DWORD SourceFileNameLength;
  2702. DWORD DestinationFileNameLength;
  2703. DWORD Flags;
  2704. WCHAR FileNameBuffer[1];
  2705. } SI_COPYFILE, *PSI_COPYFILE;
  2706. #define COPYFILE_SIS_LINK 0x0001 // Copy only if source is SIS
  2707. #define COPYFILE_SIS_REPLACE 0x0002 // Replace destination if it exists, otherwise don't.
  2708. #define COPYFILE_SIS_FLAGS 0x0003
  2709. #endif /* _WIN32_WINNT >= 0x0500 */
  2710. #endif // _FILESYSTEMFSCTL_
  2711. //
  2712. // These IOCTLs are handled by hard disk volumes.
  2713. //
  2714. #define IOCTL_VOLUME_BASE ((DWORD) 'V')
  2715. #define IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS CTL_CODE(IOCTL_VOLUME_BASE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2716. #define IOCTL_VOLUME_IS_CLUSTERED CTL_CODE(IOCTL_VOLUME_BASE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
  2717. //
  2718. // Disk extent definition.
  2719. //
  2720. typedef struct _DISK_EXTENT {
  2721. DWORD DiskNumber;
  2722. LARGE_INTEGER StartingOffset;
  2723. LARGE_INTEGER ExtentLength;
  2724. } DISK_EXTENT, *PDISK_EXTENT;
  2725. //
  2726. // Output structure for IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS.
  2727. //
  2728. typedef struct _VOLUME_DISK_EXTENTS {
  2729. DWORD NumberOfDiskExtents;
  2730. DISK_EXTENT Extents[1];
  2731. } VOLUME_DISK_EXTENTS, *PVOLUME_DISK_EXTENTS;
  2732. #endif // _WINIOCTL_