iop.h 104 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862
  1. /*++
  2. Copyright (c) 2012 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. iop.h
  5. Abstract:
  6. This header contains private definitions for the I/O Subsystem.
  7. Author:
  8. Evan Green 16-Sep-2012
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. //
  14. // --------------------------------------------------------------------- Macros
  15. //
  16. //
  17. // This macro evaluates to non-zero if the given object is a device or a
  18. // volume.
  19. //
  20. #define IS_DEVICE_OR_VOLUME(_Object) \
  21. ((((POBJECT_HEADER)(_Object))->Type == ObjectDevice) || \
  22. (((POBJECT_HEADER)(_Object))->Type == ObjectVolume))
  23. //
  24. // This macro evaluates to non-zero if the given file object has no dirty data
  25. // and no dirty properties.
  26. //
  27. #define IS_FILE_OBJECT_CLEAN(_FileObject) \
  28. (((_FileObject)->Flags & \
  29. (FILE_OBJECT_FLAG_DIRTY_DATA | FILE_OBJECT_FLAG_DIRTY_PROPERTIES)) == 0)
  30. //
  31. // ---------------------------------------------------------------- Definitions
  32. //
  33. #define IO_ALLOCATION_TAG 0x21216F49 // '!!oI'
  34. #define FI_ALLOCATION_TAG 0x656C6946 // 'eliF'
  35. #define DEVICE_ALLOCATION_TAG 0x21766544 // '!veD'
  36. #define DEVICE_WORK_ALLOCATION_TAG 0x57766544 // 'WveD'
  37. #define IRP_ALLOCATION_TAG 0x21707249 // '!prI'
  38. #define DEVICE_INTERFACE_ALLOCATION_TAG 0x49766544 // 'IveD'
  39. #define DEVICE_INFORMATION_ALLOCATION_TAG 0x666E4944 // 'fnID'
  40. #define DEVICE_INFORMATION_REQUEST_ALLOCATION_TAG 0x526E4944 // 'RnID'
  41. #define PATH_ALLOCATION_TAG 0x68746150 // 'htaP'
  42. #define FILE_LOCK_ALLOCATION_TAG 0x6B434C46 // 'kcLF'
  43. #define SOCKET_INFORMATION_ALLOCATION_TAG 0x666E4953 // 'fnIS'
  44. #define UNIX_SOCKET_ALLOCATION_TAG 0x6F536E55 // 'oSnU'
  45. #define IRP_MAGIC_VALUE (USHORT)IRP_ALLOCATION_TAG
  46. //
  47. // This flag is set once the DriverEntry routine has been called for a driver.
  48. //
  49. #define DRIVER_FLAG_ENTRY_CALLED 0x00000001
  50. //
  51. // This flag is set if a driver returns a failing status code to its
  52. // DriverEntry routine.
  53. //
  54. #define DRIVER_FLAG_FAILED_DRIVER_ENTRY 0x00000002
  55. //
  56. // This flag is set if a driver was loaded by the boot environment.
  57. //
  58. #define DRIVER_FLAG_LOADED_AT_BOOT 0x00000004
  59. //
  60. // This flag is set on a device action if the action is to be sent down to the
  61. // entire subtree below this device. This performs a pre-order traversal.
  62. //
  63. #define DEVICE_ACTION_SEND_TO_SUBTREE 0x00000001
  64. //
  65. // This flag is set on a device action if the action is to be sent to the device
  66. // and its children. Only the children will receive the action, not
  67. // grandchildren.
  68. //
  69. #define DEVICE_ACTION_SEND_TO_CHILDREN 0x00000002
  70. //
  71. // This flag is set on a device action if the action should open the queue.
  72. //
  73. #define DEVICE_ACTION_OPEN_QUEUE 0x00000004
  74. //
  75. // This flag is set on a device action if the action should close the queue.
  76. //
  77. #define DEVICE_ACTION_CLOSE_QUEUE 0x00000008
  78. //
  79. // This flag is set when an IRP has been marked as complete.
  80. //
  81. #define IRP_COMPLETE 0x00000001
  82. //
  83. // This flag is set in an IRP when it's been marked as pending.
  84. //
  85. #define IRP_PENDING 0x00000002
  86. //
  87. // This flag is set in an IRP when it's active.
  88. //
  89. #define IRP_ACTIVE 0x00000004
  90. //
  91. // This flag is used during processing Query Children to mark pre-existing
  92. // devices and notice missing ones.
  93. //
  94. #define DEVICE_FLAG_ENUMERATED 0x00000001
  95. //
  96. // This flag is used to indicate that the device represents a volume that
  97. // should be mounted by a file system.
  98. //
  99. #define DEVICE_FLAG_MOUNTABLE 0x00000002
  100. //
  101. // This flag is set when a file system has successfully been mounted on the
  102. // device.
  103. //
  104. #define DEVICE_FLAG_MOUNTED 0x00000004
  105. //
  106. // This flag is set when a device is set to act as the paging device.
  107. //
  108. #define DEVICE_FLAG_PAGING_DEVICE 0x00000008
  109. //
  110. // This flag is set when a device isn't using its boot resources, or it has
  111. // no boot resources.
  112. //
  113. #define DEVICE_FLAG_NOT_USING_BOOT_RESOURCES 0x00000010
  114. //
  115. // This flag is set when a volume is in the process of being removed.
  116. //
  117. #define VOLUME_FLAG_UNMOUNTING 0x00000001
  118. //
  119. // This flag is set in the file object if it is closing.
  120. //
  121. #define FILE_OBJECT_FLAG_CLOSING 0x00000001
  122. //
  123. // This flag is set in the file object if it failed to close.
  124. //
  125. #define FILE_OBJECT_FLAG_CLOSE_FAILED 0x00000002
  126. //
  127. // This flag is set in the file object if it has been opened.
  128. //
  129. #define FILE_OBJECT_FLAG_OPEN 0x00000004
  130. //
  131. // This flag is set in the file object if its properties are dirty.
  132. //
  133. #define FILE_OBJECT_FLAG_DIRTY_PROPERTIES 0x00000008
  134. //
  135. // This flag is set in the file object if its data should not be cached.
  136. //
  137. #define FILE_OBJECT_FLAG_NON_CACHED 0x00000010
  138. //
  139. // This flag is set if the file object gets its I/O state from elsewhere, and
  140. // should not try to free it.
  141. //
  142. #define FILE_OBJECT_FLAG_EXTERNAL_IO_STATE 0x00000020
  143. //
  144. // This flag is set if the file object has any dirty page cache entries.
  145. //
  146. #define FILE_OBJECT_FLAG_DIRTY_DATA 0x00000040
  147. //
  148. // The resource allocation work is currently assigned to the system work queue.
  149. //
  150. #define IoResourceAllocationWorkQueue NULL
  151. //
  152. // Define the size of read-aheads.
  153. //
  154. #define IO_READ_AHEAD_SIZE _128KB
  155. //
  156. // --------------------------------------------------------------------- Macros
  157. //
  158. //
  159. // This macro sets a problem code on a device, automatically generating the
  160. // source file and line number parameters. The first parameter is a PDEVICE,
  161. // the second parameter is a DEVICE_PROBLEM, and the third parameter is a
  162. // KSTATUS.
  163. //
  164. #define IopSetDeviceProblem(_Device, _Problem, _Status) \
  165. IopSetDeviceProblemEx((_Device), \
  166. (_Problem), \
  167. (_Status), \
  168. NULL, \
  169. 0, \
  170. __FILE__, \
  171. __LINE__) \
  172. //
  173. // This macro determines whether or not the device is in a state where it is
  174. // able to accept work. The parameter should be of type PDEVICE.
  175. //
  176. #define IO_IS_DEVICE_ALIVE(_Device) \
  177. (((_Device)->State != DeviceStateInvalid) && \
  178. ((_Device)->State != DeviceUnreported) && \
  179. ((_Device)->State != DeviceRemoved))
  180. //
  181. // This macro determines whether or not the device queue is in a state to be
  182. // accepting new work. The parameter should be of type PDEVICE.
  183. //
  184. #define IO_IS_DEVICE_QUEUE_OPEN(_Device) \
  185. (((_Device)->QueueState == DeviceQueueOpen) || \
  186. ((_Device)->QueueState == DeviceQueueActive))
  187. //
  188. // This macro determines if the given path point is a mount point. This is the
  189. // case if the path entry is equal to the owning mount point's target path
  190. // entry.
  191. //
  192. #define IO_IS_MOUNT_POINT(_PathPoint) \
  193. ((_PathPoint)->PathEntry == (_PathPoint)->MountPoint->TargetEntry)
  194. //
  195. // This macro determines whether this is a cacheable file-ish object. It
  196. // excludes block and character devices.
  197. //
  198. #define IO_IS_CACHEABLE_FILE(_IoObjectType) \
  199. ((_IoObjectType == IoObjectRegularFile) || \
  200. (_IoObjectType == IoObjectSymbolicLink) || \
  201. (_IoObjectType == IoObjectSharedMemoryObject))
  202. //
  203. // This macro determines whether or not a file type is cacheable.
  204. //
  205. #define IO_IS_CACHEABLE_TYPE(_IoObjectType) \
  206. ((_IoObjectType == IoObjectBlockDevice) || \
  207. IO_IS_CACHEABLE_FILE(_IoObjectType))
  208. //
  209. // This macro determines whether or not a file object is cacheable.
  210. //
  211. #define IO_IS_FILE_OBJECT_CACHEABLE(_FileObject) \
  212. ((IO_IS_CACHEABLE_TYPE(_FileObject->Properties.Type) != FALSE) && \
  213. ((_FileObject->Flags & FILE_OBJECT_FLAG_NON_CACHED) == 0))
  214. //
  215. // ------------------------------------------------------ Data Type Definitions
  216. //
  217. typedef enum _FILE_OBJECT_TIME_TYPE {
  218. FileObjectAccessTime,
  219. FileObjectModifiedTime,
  220. FileObjectStatusTime,
  221. } FILE_OBJECT_TIME_TYPE, *PFILE_OBJECT_TIME_TYPE;
  222. typedef struct _DEVICE_POWER DEVICE_POWER, *PDEVICE_POWER;
  223. /*++
  224. Structure Description:
  225. This structure defines a file object.
  226. Members:
  227. TreeEntry - Stores the Red-Black tree node information for this file object,
  228. used internally. Never access these members directly.
  229. ListEntry - Stores an entry into the list of file objects.
  230. PageCacheTree - Stores a tree root for the page cache entries that
  231. belong to this file object.
  232. DirtyPageList - Stores the head of the list of dirty page cache entries
  233. in this file object. This list is synchronized by the global page
  234. cache list lock.
  235. ReferenceCount - Stores the memory reference count on this structure, used
  236. internally. Never manipulate this member directly.
  237. PathEntryCount - Stores the count of path entries that are using this file
  238. object. This accounts for all ways that a file object whose hard link
  239. count has gone to zero can still be accessed. If a path entry is using
  240. it, I/O can still be done on the file object.
  241. Device - Stores a pointer to the device or volume that owns the file serial
  242. number.
  243. Directory - Stores a pointer to an open handle to the file's directory,
  244. which is used to synchronize deletes, opens, and metadata updates.
  245. Lock - Stores a pointer to the lock that serializes I/O operations on
  246. this file object and child path entry lookup, creation, and insertion.
  247. IoState - Stores a pointer to the I/O object state for this file object.
  248. SpecialIo - Stores a pointer to the context needed to do I/O if this is a
  249. special object (like a pipe, terminal, socket, or shared memory object).
  250. ReadyEvent - Stores a pointer to an event that must be waited on before
  251. using this file object.
  252. ImageSectionList - Stores a pointer to a list of image setions that map
  253. portions of this file object.
  254. DeviceContext - Stores a pointer to context supplied by the device with the
  255. file was opened.
  256. Flags - Stores a set of flags describing the file object state. See
  257. FILE_OBJECT_FLAG_* for definitions. This must be modified with atomic
  258. operations.
  259. Properties - Stores the characteristics for this file.
  260. FileLockList - Stores the head of the list of file locks held on this
  261. file object. This is a user mode thing.
  262. FileLockEvent - Stores a pointer to the event that's signalled when a file
  263. object lock is released.
  264. --*/
  265. typedef struct _FILE_OBJECT FILE_OBJECT, *PFILE_OBJECT;
  266. struct _FILE_OBJECT {
  267. RED_BLACK_TREE_NODE TreeEntry;
  268. LIST_ENTRY ListEntry;
  269. RED_BLACK_TREE PageCacheTree;
  270. LIST_ENTRY DirtyPageList;
  271. volatile ULONG ReferenceCount;
  272. volatile ULONG PathEntryCount;
  273. PDEVICE Device;
  274. PSHARED_EXCLUSIVE_LOCK Lock;
  275. PIO_OBJECT_STATE IoState;
  276. PVOID SpecialIo;
  277. PKEVENT ReadyEvent;
  278. volatile PIMAGE_SECTION_LIST ImageSectionList;
  279. volatile PVOID DeviceContext;
  280. volatile ULONG Flags;
  281. FILE_PROPERTIES Properties;
  282. LIST_ENTRY FileLockList;
  283. PKEVENT FileLockEvent;
  284. };
  285. /*++
  286. Structure Description:
  287. This structure defines a path entry.
  288. Members:
  289. SiblingListEntry - Stores pointers to the next and previous entries in
  290. the parent directory.
  291. CacheListEntry - Stores pointers to the next and previous entries in the
  292. LRU list of the path entry cache.
  293. ReferenceCount - Stores the reference count of the entry.
  294. MountCount - Stores the number of mount points mounted on this path entry.
  295. MountFlags - Stores a bitmaks of mount related flags that get inherited
  296. from a path entry's parent.
  297. Negative - Stores a boolean indicating that is is a negative path entry,
  298. which caches the lack of a file here.
  299. DoNotCache - Stores a boolean indicating that this path entry should not
  300. be cached.
  301. Name - Stores a pointer to the name of the path entry, allocated in paged
  302. pool.
  303. NameSize - Stores the size of the name buffer in bytes including the null
  304. terminator.
  305. Hash - Stores a hash of the name, used for quick negative comparisons.
  306. SequenceNumber - Stores a sequence number to keep track of whether or not
  307. the path entry is in sync with the underlying file object.
  308. Parent - Stores a pointer to the parent node.
  309. ChildList - Stores the list of children for this node.
  310. FileObject - Stores a pointer to the file object backing this path entry.
  311. --*/
  312. struct _PATH_ENTRY {
  313. LIST_ENTRY SiblingListEntry;
  314. LIST_ENTRY CacheListEntry;
  315. volatile ULONG ReferenceCount;
  316. volatile ULONG MountCount;
  317. BOOL Negative;
  318. BOOL DoNotCache;
  319. PSTR Name;
  320. ULONG NameSize;
  321. ULONG Hash;
  322. PPATH_ENTRY Parent;
  323. LIST_ENTRY ChildList;
  324. PFILE_OBJECT FileObject;
  325. };
  326. /*++
  327. Struction Description:
  328. This structure defines a mount point.
  329. Members:
  330. SiblingListEntry - Stores pointers to the next and previous entries in
  331. the parent mount's list of children.
  332. ChildListHead- Stores the list head for its child mount points.
  333. Parent - Stores a pointer to the parent mount point. If set to NULL, then
  334. the parent has been unmounted.
  335. MountEntry - Stores a pointer to the path entry that the mount point is
  336. mounted on.
  337. TargetEntry - Stores a pointer to the path entry that is the target path
  338. entry to traverse for this mount point.
  339. TargetPath - Store a string to the original target path specified during
  340. the mount request.
  341. ReferenceCount - Stores the reference count of the mount point.
  342. Flags - Stores a bitmask of flags for this mount point. See MOUNT_FLAG_*
  343. for definitions.
  344. --*/
  345. struct _MOUNT_POINT {
  346. LIST_ENTRY SiblingListEntry;
  347. LIST_ENTRY ChildListHead;
  348. PMOUNT_POINT Parent;
  349. PPATH_ENTRY MountEntry;
  350. PPATH_ENTRY TargetEntry;
  351. PSTR TargetPath;
  352. volatile ULONG ReferenceCount;
  353. ULONG Flags;
  354. };
  355. /*++
  356. Enumeration Description:
  357. This enumeration describes the various I/O handle types.
  358. Values:
  359. IoHandleTypeDefault - Indicates a default I/O handle.
  360. IoHandleTypePaging - Indicates a paging I/O handle.
  361. --*/
  362. typedef enum _IO_HANDLE_TYPE {
  363. IoHandleTypeDefault,
  364. IoHandleTypePaging
  365. } IO_HANDLE_TYPE, *PIO_HANDLE_TYPE;
  366. /*++
  367. Structure Description:
  368. This structure defines the context behind a generic I/O handle.
  369. Members:
  370. HandleType - Stores the type of I/O handle. All I/O handle types must begin
  371. with a member of this type.
  372. Type - Stores the type of I/O object this handle represents.
  373. OpenFlags - Stores the flags the handle was opened with.
  374. Access - Stores the access permissions for the handle.
  375. ReferenceCount - Stores the current reference count on the I/O handle.
  376. Never manipulate this value directly, use the APIs provided to add
  377. or release a reference.
  378. Device - Stores a pointer to the underlying device or object that performs
  379. the I/O.
  380. DeviceContext - Stores a context pointer supplied by the device when the
  381. handle was opened.
  382. PathPoint - Stores the path context (path entry and mount point) for the
  383. file or object.
  384. FileObject - Stores a pointer to the file object to interact with for I/O
  385. purposes.
  386. CurrentOffset - Stores the current file pointer.
  387. Async - Stores an optional pointer to the asynchronous receiver state.
  388. --*/
  389. struct _IO_HANDLE {
  390. IO_HANDLE_TYPE HandleType;
  391. ULONG OpenFlags;
  392. ULONG Access;
  393. volatile ULONG ReferenceCount;
  394. PVOID DeviceContext;
  395. PATH_POINT PathPoint;
  396. PFILE_OBJECT FileObject;
  397. IO_OFFSET CurrentOffset;
  398. PASYNC_IO_RECEIVER Async;
  399. };
  400. /*++
  401. Structure Description:
  402. This structure defines the stripped down basic paging I/O handle. There
  403. is no locking, no reference counting, more or less just enough information
  404. to pass requests directly to the file system or block device.
  405. Members:
  406. HandleType - Stores the type of I/O handle. All I/O handle types must begin
  407. with a member of this type.
  408. IoHandle - Stores a pointer to the normal I/O handle.
  409. Device - Stores a pointer to the device this I/O handle points to.
  410. DeviceContext - Stores the context pointer returned by the file system or
  411. device when the object was opened.
  412. Capacity - Stores the total size of the file or block device, in bytes.
  413. OffsetAlignment - Stores the required alignment of all I/O offsets.
  414. SizeAlignment - Stores the required physical alignment of all I/O buffers.
  415. --*/
  416. typedef struct _PAGING_IO_HANDLE {
  417. IO_HANDLE_TYPE HandleType;
  418. PIO_HANDLE IoHandle;
  419. PDEVICE Device;
  420. PVOID DeviceContext;
  421. ULONGLONG Capacity;
  422. ULONG OffsetAlignment;
  423. ULONG SizeAlignment;
  424. } PAGING_IO_HANDLE, *PPAGING_IO_HANDLE;
  425. /*++
  426. Structure Description:
  427. This structure defines the context used for an I/O operation.
  428. Members:
  429. IoBuffer - Stores a pointer to an I/O buffer that either contains the data
  430. to write or will contain the read data.
  431. Offset - Stores the offset from the beginning of the file or device where
  432. the I/O should be done.
  433. SizeInBytes - Stores the number of bytes to read or write.
  434. BytesCompleted - Stores the number of bytes of I/O actually performed.
  435. Flags - Stores the flags regarding the I/O operation. See IO_FLAG_*
  436. definitions.
  437. TimeoutInMilliseconds - Stores the number of milliseconds that the I/O
  438. operation should be waited on before timing out. Use
  439. WAIT_TIME_INDEFINITE to wait forever on the I/O.
  440. Write - Stores a boolean value indicating if the I/O operation is a write
  441. (TRUE) or a read (FALSE).
  442. --*/
  443. typedef struct _IO_CONTEXT {
  444. PIO_BUFFER IoBuffer;
  445. IO_OFFSET Offset;
  446. UINTN SizeInBytes;
  447. UINTN BytesCompleted;
  448. ULONG Flags;
  449. ULONG TimeoutInMilliseconds;
  450. BOOL Write;
  451. } IO_CONTEXT, *PIO_CONTEXT;
  452. /*++
  453. Structure Description:
  454. This structure defines an entry in the device database, which associates
  455. devices or device classes with drivers. These structures are generally
  456. paged.
  457. Members:
  458. ListEntry - Supplies pointers to the next and previous entries in the
  459. database.
  460. DeviceId - Supplies a string containing the device ID, in the case of a
  461. device to driver association.
  462. ClassId - Supplies a string containing the class ID, in the case of a
  463. device class to driver association.
  464. DriverName - Supplies a string containing the driver associated with this
  465. device or device class.
  466. --*/
  467. typedef struct _DEVICE_DATABASE_ENTRY {
  468. LIST_ENTRY ListEntry;
  469. union {
  470. PSTR DeviceId;
  471. PSTR ClassId;
  472. } U;
  473. PSTR DriverName;
  474. } DEVICE_DATABASE_ENTRY, *PDEVICE_DATABASE_ENTRY;
  475. /*++
  476. Enumeration Description:
  477. This enumeration describes the various device actions.
  478. Values:
  479. DeviceActionInvalid - Indicates an invalid device action.
  480. DeviceActionStart - Indicates that the device should be started.
  481. DeviceActionQueryChildren - Indicates that the devices children should be
  482. queried.
  483. DeviceActionPrepareRemove - Indicates that the device should prepare for
  484. removal.
  485. DeviceActionRemove - Indicates that the device should be removed.
  486. DeviceActionPowerTransition - Indicates that the device will undergo a
  487. power state change.
  488. --*/
  489. typedef enum _DEVICE_ACTION {
  490. DeviceActionInvalid,
  491. DeviceActionStart,
  492. DeviceActionQueryChildren,
  493. DeviceActionPrepareRemove,
  494. DeviceActionRemove,
  495. DeviceActionPowerTransition
  496. } DEVICE_ACTION, *PDEVICE_ACTION;
  497. /*++
  498. Structure Description:
  499. This structure defines a unit of work on a device. A queue of these work
  500. items are queued on a per-device basis.
  501. Members:
  502. ListEntry - Stores pointers to the next and previous entries in the
  503. queue.
  504. Action - Stores the action to perform on the device.
  505. Flags - Stores properties and options for the action. See DEVICE_ACTION_*
  506. definitions.
  507. Parameter - Stores a caller-supplied parameter that has different meanings
  508. depending on the type of work requested.
  509. --*/
  510. typedef struct _DEVICE_WORK_ENTRY {
  511. LIST_ENTRY ListEntry;
  512. DEVICE_ACTION Action;
  513. ULONG Flags;
  514. PVOID Parameter;
  515. } DEVICE_WORK_ENTRY, *PDEVICE_WORK_ENTRY;
  516. /*++
  517. Structure Description:
  518. This structure defines an entry in the driver stack for a device. A device
  519. contains one or more drivers from the functional driver to various filters,
  520. with a bus driver at the bottom.
  521. Members:
  522. ListEntry - Stores pointers to the next and previous entries in the
  523. stack.
  524. Driver - Stores a pointer to the driver associated with this driver
  525. stack entry.
  526. DriverContext - Stores a pointer supplied by the driver on AddDevice.
  527. This pointer will be passed to the driver each time it is asked to
  528. operate on this device. It is typically used to store device context.
  529. Flags - Stores a set of flags associated with this stack entry. See
  530. DRIVER_STACK_* definitions.
  531. --*/
  532. typedef struct _DRIVER_STACK_ENTRY {
  533. LIST_ENTRY ListEntry;
  534. PDRIVER Driver;
  535. PVOID DriverContext;
  536. ULONG Flags;
  537. } DRIVER_STACK_ENTRY, *PDRIVER_STACK_ENTRY;
  538. typedef enum _DEVICE_STATE {
  539. DeviceStateInvalid,
  540. DeviceUnreported,
  541. DeviceInitialized,
  542. DeviceDriversAdded,
  543. DeviceResourcesQueried,
  544. DeviceResourceAssignmentQueued,
  545. DeviceResourcesAssigned,
  546. DeviceAwaitingEnumeration,
  547. DeviceEnumerated,
  548. DeviceStarted,
  549. DeviceAwaitingRemoval,
  550. DeviceRemoved
  551. } DEVICE_STATE, *PDEVICE_STATE;
  552. typedef enum _DEVICE_QUEUE_STATE {
  553. DeviceQueueInvalid,
  554. DeviceQueueOpen,
  555. DeviceQueueActive,
  556. DeviceQueueActiveClosing,
  557. DeviceQueueClosed
  558. } DEVICE_QUEUE_STATE, *PDEVICE_QUEUE_STATE;
  559. typedef enum _DEVICE_PROBLEM {
  560. DeviceProblemNone,
  561. DeviceProblemNoDrivers,
  562. DeviceProblemFailedDriverLoad,
  563. DeviceProblemNoAddDevice,
  564. DeviceProblemNoFileSystem,
  565. DeviceProblemFailedAddDevice,
  566. DeviceProblemInvalidState,
  567. DeviceProblemFailedToQueueResourceAssignmentWork,
  568. DeviceProblemFailedQueryResources,
  569. DeviceProblemResourceConflict,
  570. DeviceProblemFailedStart,
  571. DeviceProblemFailedQueryChildren,
  572. DeviceProblemFailedToQueueStart,
  573. DeviceProblemFailedToQueueQueryChildren,
  574. DeviceProblemFailedToQueuePrepareRemove,
  575. DeviceProblemFailedToQueueRemove,
  576. DeviceProblemFailedToSendRemoveIrp,
  577. DeviceProblemFailedVolumeArrival,
  578. DeviceProblemFailedVolumeRemoval,
  579. DeviceProblemFailedPathRemoval,
  580. DeviceProblemDriverError
  581. } DEVICE_PROBLEM, *PDEVICE_PROBLEM;
  582. /*++
  583. Structure Description:
  584. This structure defines a device problem state.
  585. Members:
  586. Problem - Stores a device problem code.
  587. Status - Stores the failure status associated with the device problem.
  588. DriverCode - Stores a driver-specific error code.
  589. ProblemLine - Stores the line number of the source file where the problem
  590. was set.
  591. ProblemFile - Stores a pointer to a string containing the name of the
  592. source file where the problem was set.
  593. Driver - Stores a pointer to the driver that reported the device problem.
  594. The field is NULL if the system reported the problem.
  595. --*/
  596. typedef struct _DEVICE_PROBLEM_STATE {
  597. DEVICE_PROBLEM Problem;
  598. KSTATUS Status;
  599. ULONG DriverCode;
  600. ULONG Line;
  601. PSTR File;
  602. PDRIVER Driver;
  603. } DEVICE_PROBLEM_STATE, *PDEVICE_PROBLEM_STATE;
  604. /*++
  605. Structure Description:
  606. This structure defines a device.
  607. Members:
  608. Header - Stores the object header for this device, including the device's
  609. name.
  610. ListEntry - Stores pointers to the next and previous devices in the global
  611. list.
  612. State - Stores the current state of the device.
  613. StateHistoryNextIndex - Stores the index of where the next device state
  614. should be written to. The state history is a circular buffer.
  615. StateHistory - Stores a log containing the history of the last few device
  616. states.
  617. DeviceId - Stores the numeric identifier for the device.
  618. ActiveChildList - Store the head of the list of this device's active
  619. children.
  620. ActiveListEntry - Stores the list entry for the device's place in its
  621. parent's list of active children.
  622. Lock - Stores a pointer to a shared exclusive lock that synchronizes
  623. device removal with IRPs. Lock order is always parent, then child.
  624. ParentDevice - Stores a pointer to the device that created this device, aka
  625. the device's parent. Usually this points to the parent bus. This can
  626. be NULL for unenumerable devices.
  627. TargetDevice - Stores a pointer to a device that IRPs continue through
  628. if they've not been completed by this device stack.
  629. ClassId - Stores a pointer to a string containing the class ID for the
  630. device.
  631. CompatibleIds - Stores a pointer to a string containing the compatible IDs
  632. for this device.
  633. QueueLock - Stores a pointer to a queued lock that protects the work
  634. queue's state and list.
  635. QueueState - Stores the state of the work queue, describing whether or not
  636. it is accepting new requests. Writes of this variable are protected by
  637. the QueueLock.
  638. WorkQueue - Stores the list head of the device work queue. Access to this
  639. list is protected by the QueueLock. See the DEVICE_WORK_ENTRY
  640. definition.
  641. DriverStackHead - Stores the list head for the driver stack. The Next link
  642. of this head points to the top of the driver stack (the functional
  643. driver or uppermost filter).
  644. DriverStackSize - Stores the number of drivers in the driver stack.
  645. Flags - Stores device flags. See DEVICE_FLAG_* definitions.
  646. ProblemState - Stores device problem information reported by the system or
  647. a device driver.
  648. ArbiterListHead - Stores the head of the list of arbiters this device is
  649. responsible for.
  650. ResourceRequirements - Stores a pointer to set of possible resource
  651. configurations for the device.
  652. ArbiterAllocationListHead - Stores the head of the list of allocations
  653. assigned to the device by the arbiter.
  654. SelectedConfiguration - Stores a pointer to the configuration that was
  655. selected in the device's resource configuration list.
  656. BusLocalResources - Stores a pointer to the device's committed resources, as
  657. seen from the point of view of the device itself. These
  658. are the resources that the bus driver is likely use when programming
  659. things like the device's Base Address Registers.
  660. ProcessorLocalResources - Stores a pointer to the device's committed
  661. resources, as seen from the CPU complex. These are the resources the
  662. device driver would use to communicate with the device.
  663. BootResources - Stores a pointer to the resources the BIOS assigned to the
  664. device at boot.
  665. Power - Stores the power management information for the device.
  666. --*/
  667. struct _DEVICE {
  668. OBJECT_HEADER Header;
  669. LIST_ENTRY ListEntry;
  670. DEVICE_STATE State;
  671. ULONG StateHistoryNextIndex;
  672. DEVICE_STATE StateHistory[DEVICE_STATE_HISTORY];
  673. DEVICE_ID DeviceId;
  674. LIST_ENTRY ActiveChildListHead;
  675. LIST_ENTRY ActiveListEntry;
  676. PSHARED_EXCLUSIVE_LOCK Lock;
  677. PDEVICE ParentDevice;
  678. PDEVICE TargetDevice;
  679. PSTR ClassId;
  680. PSTR CompatibleIds;
  681. PQUEUED_LOCK QueueLock;
  682. DEVICE_QUEUE_STATE QueueState;
  683. LIST_ENTRY WorkQueue;
  684. LIST_ENTRY DriverStackHead;
  685. ULONG DriverStackSize;
  686. ULONG Flags;
  687. DEVICE_PROBLEM_STATE ProblemState;
  688. LIST_ENTRY ArbiterListHead;
  689. PRESOURCE_CONFIGURATION_LIST ResourceRequirements;
  690. LIST_ENTRY ArbiterAllocationListHead;
  691. PRESOURCE_REQUIREMENT_LIST SelectedConfiguration;
  692. PRESOURCE_ALLOCATION_LIST BusLocalResources;
  693. PRESOURCE_ALLOCATION_LIST ProcessorLocalResources;
  694. PRESOURCE_ALLOCATION_LIST BootResources;
  695. PDEVICE_POWER Power;
  696. };
  697. /*++
  698. Structure Description:
  699. This structure defines a volume device.
  700. Members:
  701. Device - Stores the data required for a standard device.
  702. Flags - Stores a bitmask of volume specific flags.
  703. ReferenceCount - Stores the number of references taken on the volume. This
  704. is used to track the number of mount points that target the volume.
  705. As such, volume creation does not set a reference count of 1.
  706. PathEntry - Stores a pointer to the anonymous path entry associated with
  707. the volume.
  708. --*/
  709. struct _VOLUME {
  710. DEVICE Device;
  711. ULONG Flags;
  712. volatile ULONG ReferenceCount;
  713. PPATH_ENTRY PathEntry;
  714. };
  715. /*++
  716. Structure Description:
  717. This structure defines a driver object.
  718. Members:
  719. Image - Stores a pointer to the driver's image.
  720. FunctionTable - Stores the driver's registered function pointers.
  721. Flags - Stores various state of the driver. See DRIVER_FLAG_* definitions.
  722. --*/
  723. struct _DRIVER {
  724. PVOID Image;
  725. DRIVER_FUNCTION_TABLE FunctionTable;
  726. ULONG Flags;
  727. };
  728. typedef
  729. KSTATUS
  730. (*PFILE_OBJECT_ITERATION_ROUTINE) (
  731. PFILE_OBJECT FileObject,
  732. PVOID Context
  733. );
  734. /*++
  735. Routine Description:
  736. This routine is called once for every file object in the file object list.
  737. Arguments:
  738. FileObject - Supplies a pointer to the current file object.
  739. Context - Supplies an optional opaque pointer of context that was provided
  740. when the iteration was requested.
  741. Return Value:
  742. Status code.
  743. --*/
  744. //
  745. // -------------------------------------------------------------------- Globals
  746. //
  747. //
  748. // Store list heads to the device databases. These list entries are of type
  749. // DEVICE_DATABASE_ENTRY, and store the mappings between devices and drivers
  750. // or device classes and drivers. All memory in these databases is paged.
  751. //
  752. extern LIST_ENTRY IoDeviceDatabaseHead;
  753. extern LIST_ENTRY IoDeviceClassDatabaseHead;
  754. extern PQUEUED_LOCK IoDeviceDatabaseLock;
  755. //
  756. // Store a pointer to the device work queue.
  757. //
  758. extern PWORK_QUEUE IoDeviceWorkQueue;
  759. //
  760. // Define the object that roots the device tree.
  761. //
  762. extern PDEVICE IoRootDevice;
  763. extern LIST_ENTRY IoDeviceList;
  764. extern PQUEUED_LOCK IoDeviceListLock;
  765. //
  766. // Store the number of active work items flowing around.
  767. //
  768. extern UINTN IoDeviceWorkItemsQueued;
  769. //
  770. // Store the array of devices that were delayed until the initial enumeration
  771. // was complete.
  772. //
  773. extern PDEVICE *IoDelayedDevices;
  774. extern UINTN IoDelayedDeviceCount;
  775. //
  776. // Store a pointer to the directory of all exposed interfaces.
  777. //
  778. extern POBJECT_HEADER IoInterfaceDirectory;
  779. extern PQUEUED_LOCK IoInterfaceLock;
  780. //
  781. // Keep the list of registered file systems.
  782. //
  783. extern LIST_ENTRY IoFileSystemList;
  784. //
  785. // This lock synchronizes access to the list of file systems.
  786. //
  787. extern PQUEUED_LOCK IoFileSystemListLock;
  788. //
  789. // Store a pointer to the volumes directory and the number of volumes in the
  790. // system.
  791. //
  792. extern POBJECT_HEADER IoVolumeDirectory;
  793. //
  794. // Store a pointer to the parent object of all IRPs.
  795. //
  796. extern POBJECT_HEADER IoIrpDirectory;
  797. //
  798. // Store a pointer to the pipes directory.
  799. //
  800. extern POBJECT_HEADER IoPipeDirectory;
  801. //
  802. // Store a pointer to the shared memory object directory.
  803. //
  804. extern POBJECT_HEADER IoSharedMemoryObjectDirectory;
  805. //
  806. // Store the saved boot information.
  807. //
  808. extern IO_BOOT_INFORMATION IoBootInformation;
  809. //
  810. // Store the global I/O statistics.
  811. //
  812. extern IO_GLOBAL_STATISTICS IoGlobalStatistics;
  813. //
  814. // Store a pointer to the root path point.
  815. //
  816. extern PATH_POINT IoPathPointRoot;
  817. //
  818. // Store a pointer to the mount lock.
  819. //
  820. extern PSHARED_EXCLUSIVE_LOCK IoMountLock;
  821. //
  822. // Store the path to the system directory on the system volume.
  823. //
  824. extern PSTR IoSystemDirectoryPath;
  825. //
  826. // -------------------------------------------------------- Function Prototypes
  827. //
  828. KSTATUS
  829. IopInitializeDriver (
  830. PVOID LoadedImage
  831. );
  832. /*++
  833. Routine Description:
  834. This routine is called to initialize a newly loaded driver. This routine
  835. should only be called internally by the system.
  836. Arguments:
  837. LoadedImage - Supplies a pointer to the image associated with the driver.
  838. Return Value:
  839. Status code.
  840. --*/
  841. KSTATUS
  842. IopCreateDevice (
  843. PDRIVER BusDriver,
  844. PVOID BusDriverContext,
  845. PDEVICE ParentDevice,
  846. PSTR DeviceId,
  847. PSTR ClassId,
  848. PSTR CompatibleIds,
  849. OBJECT_TYPE DeviceType,
  850. ULONG DeviceSize,
  851. PDEVICE *NewDevice
  852. );
  853. /*++
  854. Routine Description:
  855. This routine creates a new device or volume.
  856. Arguments:
  857. BusDriver - Supplies a pointer to the driver reporting this device.
  858. BusDriverContext - Supplies the context pointer that will be passed to the
  859. bus driver when IRPs are sent to the device.
  860. ParentDevice - Supplies a pointer to the device enumerating this device.
  861. Most devices are enumerated off of a bus, so this parameter will
  862. contain a pointer to that bus device. For unenumerable devices, this
  863. parameter can be NULL, in which case the device will be enumerated off
  864. of the root device.
  865. DeviceId - Supplies a pointer to a null terminated string identifying the
  866. device. This memory does not have to be retained, a copy of it will be
  867. created during this call.
  868. ClassId - Supplies a pointer to a null terminated string identifying the
  869. device class. This memory does not have to be retained, a copy of it
  870. will be created during this call.
  871. CompatibleIds - Supplies a semicolon-delimited list of device IDs that this
  872. device is compatible with.
  873. DeviceType - Supplies the type of the new device.
  874. DeviceSize - Supplies the size of the new device's data structure.
  875. NewDevice - Supplies a pointer where the new device or volume will be
  876. returned on success.
  877. Return Value:
  878. Status code.
  879. --*/
  880. VOID
  881. IopSetDeviceState (
  882. PDEVICE Device,
  883. DEVICE_STATE NewState
  884. );
  885. /*++
  886. Routine Description:
  887. This routine sets the device to a new state.
  888. Arguments:
  889. Device - Supplies a pointer to the device whose state is to be changed.
  890. NewState - Supplies a pointer to the new device state.
  891. Return Value:
  892. None.
  893. --*/
  894. KSTATUS
  895. IopQueueDeviceWork (
  896. PDEVICE Device,
  897. DEVICE_ACTION Action,
  898. PVOID Parameter,
  899. ULONG Flags
  900. );
  901. /*++
  902. Routine Description:
  903. This routine queues work on a device.
  904. Arguments:
  905. Device - Supplies a pointer to the device to queue work on.
  906. Action - Supplies the work to be done on that device.
  907. Parameter - Supplies a parameter that accompanies the action. The meaning
  908. of this parameter changes with the type of work queued.
  909. Flags - Supplies a set of flags and options about the work.
  910. See DEVICE_ACTION_* definitions.
  911. Return Value:
  912. STATUS_SUCCESS if the request was queued on at least one device.
  913. STATUS_NO_ELIGIBLE_DEVICES if the request could not be queued because the
  914. devices are not accepting work.
  915. STATUS_INSUFFICIENT_RESOURCES if memory could not be allocated.
  916. Other error codes on other failures.
  917. --*/
  918. VOID
  919. IopHandleDeviceQueueFailure (
  920. PDEVICE Device,
  921. DEVICE_ACTION Action
  922. );
  923. /*++
  924. Routine Description:
  925. This routine handles a failure to add a work item to a device queue.
  926. Arguments:
  927. Device - Supplies a pointer to the device that could not accept the action.
  928. Action - Supplies the action that failed to be added to the given device's
  929. work queue.
  930. Return Value:
  931. None.
  932. --*/
  933. VOID
  934. IopSetDeviceProblemEx (
  935. PDEVICE Device,
  936. DEVICE_PROBLEM Problem,
  937. KSTATUS Status,
  938. PDRIVER Driver,
  939. ULONG DriverCode,
  940. PSTR SourceFile,
  941. ULONG LineNumber
  942. );
  943. /*++
  944. Routine Description:
  945. This routine sets a device problem code on a given device. This problem is
  946. usually preventing a device from starting or otherwise making forward
  947. progress. Avoid calling this function directly, use the non-Ex version.
  948. Arguments:
  949. Device - Supplies a pointer to the device with the problem.
  950. Problem - Supplies the problem with the device.
  951. Status - Supplies the failure status generated by the error.
  952. Driver - Supplies a pointer to the driver reporting the error. This
  953. parameter is optional.
  954. DriverCode - Supplies an optional problem driver-specific error code.
  955. SourceFile - Supplies a pointer to the source file where the problem
  956. occurred. This is usually automatically generated by the compiler.
  957. LineNumber - Supplies the line number in the source file where the problem
  958. occurred. This is usually automatically generated by the compiler.
  959. Return Value:
  960. None.
  961. --*/
  962. VOID
  963. IopClearDeviceProblem (
  964. PDEVICE Device
  965. );
  966. /*++
  967. Routine Description:
  968. This routine clears any problem code associated with a device.
  969. Arguments:
  970. Device - Supplies a pointer to the device whose problem code should be
  971. cleared.
  972. Return Value:
  973. None.
  974. --*/
  975. VOID
  976. IopPrepareRemoveDevice (
  977. PDEVICE Device,
  978. PDEVICE_WORK_ENTRY Work
  979. );
  980. /*++
  981. Routine Description:
  982. This routine prepares a device for removal. It puts the device in the
  983. awaiting removal state. If it has no children, it queues the removal work
  984. item on itself. If this routine discovers that the device is already in the
  985. awaiting removal state, it exits.
  986. Arguments:
  987. Device - Supplies a pointer to the device that is preparing to be removed.
  988. Work - Supplies a pointer to the work request.
  989. Return Value:
  990. None.
  991. --*/
  992. VOID
  993. IopRemoveDevice (
  994. PDEVICE Device,
  995. PDEVICE_WORK_ENTRY Work
  996. );
  997. /*++
  998. Routine Description:
  999. This routine removes a device by sending a removal IRP and then removing
  1000. the device reference added during device creation. The removal IRP allows
  1001. the driver to clean up any necessary state that cannot be cleaned up by the
  1002. object manager's destruction call-back.
  1003. Arguments:
  1004. Device - Supplies a pointer to the device that is to be removed.
  1005. Work - Supplies a pointer to the work request.
  1006. Return Value:
  1007. None.
  1008. --*/
  1009. VOID
  1010. IopAbortDeviceRemoval (
  1011. PDEVICE Device,
  1012. DEVICE_PROBLEM DeviceProblem,
  1013. BOOL RollbackDevice
  1014. );
  1015. /*++
  1016. Routine Description:
  1017. This routine aborts the device removal process for the given device. It
  1018. also walks back up the device tree reverting the removal process for any
  1019. ancestor devices that were awaiting the given device's removal.
  1020. Arguments:
  1021. Device - Supplies a pointer to the device that failed the removal process
  1022. and requires rollback.
  1023. DeviceProblem - Supplies the devices problem (i.e. the reason for the
  1024. abort).
  1025. RollbackDevice - Supplies a boolean indicating whether or not the supplied
  1026. device should be included in the rollback.
  1027. Return Value:
  1028. None.
  1029. --*/
  1030. VOID
  1031. IopDestroyDevice (
  1032. PVOID Object
  1033. );
  1034. /*++
  1035. Routine Description:
  1036. This routine destroys a device and its resources. The object manager will
  1037. clean up the object header, leaving this routine to clean up the device
  1038. specific elements of the object. This routine is meant only as a callback
  1039. for the object manager.
  1040. Arguments:
  1041. Object - Supplies a pointer to the object to be destroyed.
  1042. Return Value:
  1043. None.
  1044. --*/
  1045. DEVICE_ID
  1046. IopGetNextDeviceId (
  1047. VOID
  1048. );
  1049. /*++
  1050. Routine Description:
  1051. This routine allocates and returns a device ID.
  1052. Arguments:
  1053. None.
  1054. Return Value:
  1055. Returns a unique device ID number.
  1056. --*/
  1057. KSTATUS
  1058. IopInitializeDeviceInformationSupport (
  1059. VOID
  1060. );
  1061. /*++
  1062. Routine Description:
  1063. This routine initializes device information support.
  1064. Arguments:
  1065. None.
  1066. Return Value:
  1067. Status code.
  1068. --*/
  1069. KSTATUS
  1070. IopAddFileSystem (
  1071. PDEVICE Device
  1072. );
  1073. /*++
  1074. Routine Description:
  1075. This routine adds a file system to the given volume.
  1076. Arguments:
  1077. Device - Supplies a pointer to the volume to attach a file system to.
  1078. Return Value:
  1079. Status code.
  1080. --*/
  1081. KSTATUS
  1082. IopCreateOrLookupVolume (
  1083. PDEVICE Device,
  1084. PVOLUME *Volume
  1085. );
  1086. /*++
  1087. Routine Description:
  1088. This routine returns the volume associated with the given device, if such
  1089. a volume exists. A reference is taken on the volume, which the caller is
  1090. expected to release.
  1091. Arguments:
  1092. Device - Supplies a pointer to the device whose volume is to be returned.
  1093. Volume - Supplies a pointer that receives a pointer to the created or found
  1094. volume.
  1095. Return Value:
  1096. Status code.
  1097. --*/
  1098. VOID
  1099. IopVolumeArrival (
  1100. PVOID Parameter
  1101. );
  1102. /*++
  1103. Routine Description:
  1104. This routine performs work associated with a new volume coming online.
  1105. Arguments:
  1106. Parameter - Supplies a pointer to the arriving volume.
  1107. Return Value:
  1108. None.
  1109. --*/
  1110. KSTATUS
  1111. IopRemoveDevicePaths (
  1112. PDEVICE Device
  1113. );
  1114. /*++
  1115. Routine Description:
  1116. This routine takes the device's paths offline.
  1117. Arguments:
  1118. Device - Supplies a pointer to the departing device.
  1119. Return Value:
  1120. Status code.
  1121. --*/
  1122. KSTATUS
  1123. IopInitializeMountPointSupport (
  1124. VOID
  1125. );
  1126. /*++
  1127. Routine Description:
  1128. This routine initializes the support for mount points.
  1129. Arguments:
  1130. None.
  1131. Return Value:
  1132. Status code.
  1133. --*/
  1134. KSTATUS
  1135. IopGetSetMountPointInformation (
  1136. PVOID Data,
  1137. PUINTN DataSize,
  1138. BOOL Set
  1139. );
  1140. /*++
  1141. Routine Description:
  1142. This routine gets or sets mount point information.
  1143. Arguments:
  1144. Data - Supplies a pointer to the data buffer where the data is either
  1145. returned for a get operation or given for a set operation.
  1146. DataSize - Supplies a pointer that on input contains the size of the
  1147. data buffer. On output, contains the required size of the data buffer.
  1148. Set - Supplies a boolean indicating if this is a get operation (FALSE) or
  1149. a set operation (TRUE).
  1150. Return Value:
  1151. Status code.
  1152. --*/
  1153. VOID
  1154. IopRemoveMountPoints (
  1155. PPATH_POINT RootPath
  1156. );
  1157. /*++
  1158. Routine Description:
  1159. This routine lazily unmounts all the mount points that exist under the
  1160. given root path point, including itself.
  1161. Arguments:
  1162. RootPath - Supplies a pointer to the root path point, under which all
  1163. mount points will be removed.
  1164. Return Value:
  1165. None.
  1166. --*/
  1167. PMOUNT_POINT
  1168. IopFindMountPoint (
  1169. PMOUNT_POINT Parent,
  1170. PPATH_ENTRY PathEntry
  1171. );
  1172. /*++
  1173. Routine Description:
  1174. This routine searches for a child mount point of the given parent whose
  1175. mount path entry matches the given path entry. If found, a reference is
  1176. taken on the returned mount point.
  1177. Arguments:
  1178. Parent - Supplies a pointer to a parent mount point whose children are
  1179. searched for a mount point that matches the path entry.
  1180. PathEntry - Supplies a pointer to a path entry to search for.
  1181. Return Value:
  1182. Returns a pointer to the found mount point on success, or NULL on failure.
  1183. --*/
  1184. PMOUNT_POINT
  1185. IopGetMountPointParent (
  1186. PMOUNT_POINT MountPoint
  1187. );
  1188. /*++
  1189. Routine Description:
  1190. This routine gets a mount point's parent. The parent can disappear at any
  1191. moment with a lazy unmount, so this routine acquires the mount lock in
  1192. shared mode to check the parent.
  1193. Arguments:
  1194. MountPoint - Supplies a pointer to a mount point.
  1195. Return Value:
  1196. Returns a pointer to the parent mount point on success, or NULL otherwise.
  1197. --*/
  1198. KSTATUS
  1199. IopOpen (
  1200. BOOL FromKernelMode,
  1201. PIO_HANDLE Directory,
  1202. PSTR Path,
  1203. ULONG PathLength,
  1204. ULONG Access,
  1205. ULONG Flags,
  1206. IO_OBJECT_TYPE TypeOverride,
  1207. PVOID OverrideParameter,
  1208. FILE_PERMISSIONS CreatePermissions,
  1209. PIO_HANDLE *Handle
  1210. );
  1211. /*++
  1212. Routine Description:
  1213. This routine opens a file, device, pipe, or other I/O object.
  1214. Arguments:
  1215. FromKernelMode - Supplies a boolean indicating the request is coming from
  1216. kernel mode.
  1217. Directory - Supplies an optional pointer to a handle to a directory to use
  1218. if the given path is relative. Supply NULL to use the current working
  1219. directory.
  1220. Path - Supplies a pointer to the path to open.
  1221. PathLength - Supplies the length of the path buffer in bytes, including the
  1222. null terminator.
  1223. Access - Supplies the desired access permissions to the object. See
  1224. IO_ACCESS_* definitions.
  1225. Flags - Supplies a bitfield of flags governing the behavior of the handle.
  1226. See OPEN_FLAG_* definitions.
  1227. TypeOverride - Supplies an object type that the regular file should be
  1228. converted to. Supply the invalid object type to specify no override.
  1229. OverrideParameter - Supplies an optional parameter to send along with the
  1230. override type.
  1231. CreatePermissions - Supplies the permissions to apply for created object
  1232. on create operations.
  1233. Handle - Supplies a pointer where a pointer to the open I/O handle will be
  1234. returned on success.
  1235. Return Value:
  1236. Status code.
  1237. --*/
  1238. KSTATUS
  1239. IopOpenPathPoint (
  1240. PPATH_POINT PathPoint,
  1241. ULONG Access,
  1242. ULONG Flags,
  1243. PIO_HANDLE *Handle
  1244. );
  1245. /*++
  1246. Routine Description:
  1247. This routine opens a path point object. This routine must be called
  1248. carefully by internal functions, as it skips all permission checks.
  1249. Arguments:
  1250. PathPoint - Supplies a pointer to the path point to open. Upon success this
  1251. routine will add a reference to the path point's path entry and mount
  1252. point.
  1253. Access - Supplies the desired access permissions to the object. See
  1254. IO_ACCESS_* definitions.
  1255. Flags - Supplies a bitfield of flags governing the behavior of the handle.
  1256. See OPEN_FLAG_* definitions.
  1257. Handle - Supplies a pointer where a pointer to the open I/O handle will be
  1258. returned on success.
  1259. Return Value:
  1260. Status code.
  1261. --*/
  1262. KSTATUS
  1263. IopOpenDevice (
  1264. PDEVICE Device,
  1265. ULONG Access,
  1266. ULONG Flags,
  1267. PIO_HANDLE *Handle
  1268. );
  1269. /*++
  1270. Routine Description:
  1271. This routine opens a device or volume.
  1272. Arguments:
  1273. Device - Supplies a pointer to a device to open.
  1274. Access - Supplies the desired access permissions to the object. See
  1275. IO_ACCESS_* definitions.
  1276. Flags - Supplies a bitfield of flags governing the behavior of the handle.
  1277. See OPEN_FLAG_* definitions.
  1278. Handle - Supplies a pointer where a pointer to the open I/O handle will be
  1279. returned on success.
  1280. Return Value:
  1281. Status code.
  1282. --*/
  1283. KSTATUS
  1284. IopCreateSpecialIoObject (
  1285. ULONG Flags,
  1286. IO_OBJECT_TYPE Type,
  1287. PVOID OverrideParameter,
  1288. FILE_PERMISSIONS CreatePermissions,
  1289. PFILE_OBJECT *FileObject
  1290. );
  1291. /*++
  1292. Routine Description:
  1293. This routine creates a special file object.
  1294. Arguments:
  1295. Type - Supplies the type of special object to create.
  1296. Flags - Supplies a bitfield of flags governing the behavior of the handle.
  1297. See OPEN_FLAG_* definitions.
  1298. OverrideParameter - Supplies an optional parameter to send along with the
  1299. override type.
  1300. CreatePermissions - Supplies the permissions to assign to the new file.
  1301. FileObject - Supplies a pointer where a pointer to the new file object
  1302. will be returned on success.
  1303. Return Value:
  1304. Status code.
  1305. --*/
  1306. KSTATUS
  1307. IopClose (
  1308. PIO_HANDLE IoHandle
  1309. );
  1310. /*++
  1311. Routine Description:
  1312. This routine shuts down an I/O handle that is about to be destroyed.
  1313. Arguments:
  1314. IoHandle - Supplies a pointer to the I/O handle returned when the file was
  1315. opened.
  1316. Return Value:
  1317. Status code.
  1318. --*/
  1319. KSTATUS
  1320. IopDelete (
  1321. BOOL FromKernelMode,
  1322. PIO_HANDLE Directory,
  1323. PSTR Path,
  1324. ULONG PathSize,
  1325. ULONG Flags
  1326. );
  1327. /*++
  1328. Routine Description:
  1329. This routine attempts to delete the object at the given path. If the path
  1330. points to a directory, the directory must be empty. If the path points to
  1331. a file object or shared memory object, its hard link count is decremented.
  1332. If the hard link count reaches zero and no processes have the object open,
  1333. the contents of the object are destroyed. If processes have open handles to
  1334. the object, the destruction of the object contents are deferred until the
  1335. last handle to the old file is closed. If the path points to a symbolic
  1336. link, the link itself is removed and not the destination. The removal of
  1337. the entry from the directory is immediate.
  1338. Arguments:
  1339. FromKernelMode - Supplies a boolean indicating the request is coming from
  1340. kernel mode.
  1341. Directory - Supplies an optional pointer to an open handle to a directory
  1342. for relative paths. Supply NULL to use the current working directory.
  1343. Path - Supplies a pointer to the path to delete.
  1344. PathSize - Supplies the length of the path buffer in bytes, including the
  1345. null terminator.
  1346. Flags - Supplies a bitfield of flags. See DELETE_FLAG_* definitions.
  1347. Return Value:
  1348. Status code.
  1349. --*/
  1350. KSTATUS
  1351. IopDeleteByHandle (
  1352. BOOL FromKernelMode,
  1353. PIO_HANDLE Handle,
  1354. ULONG Flags
  1355. );
  1356. /*++
  1357. Routine Description:
  1358. This routine attempts to delete the the object open by the given I/O
  1359. handle. This does not close or invalidate the handle, but it does attempt
  1360. to unlink the object so future path walks will not find it at that location.
  1361. Arguments:
  1362. FromKernelMode - Supplies a boolean indicating the request is coming from
  1363. kernel mode.
  1364. Handle - Supplies the open handle to the device.
  1365. Flags - Supplies a bitfield of flags. See DELETE_FLAG_* definitions.
  1366. Return Value:
  1367. Status code.
  1368. --*/
  1369. KSTATUS
  1370. IopDeletePathPoint (
  1371. BOOL FromKernelMode,
  1372. PPATH_POINT PathPoint,
  1373. ULONG Flags
  1374. );
  1375. /*++
  1376. Routine Description:
  1377. This routine attempts to delete the object at the given path. If the path
  1378. points to a directory, the directory must be empty. If the path point is
  1379. a file object or shared memory object, its hard link count is decremented.
  1380. If the hard link count reaches zero and no processes have the object open,
  1381. the contents of the object are destroyed. If processes have open handles to
  1382. the object, the destruction of the object contents are deferred until the
  1383. last handle to the old file is closed.
  1384. Arguments:
  1385. FromKernelMode - Supplies a boolean indicating the request is coming from
  1386. kernel mode.
  1387. PathPoint - Supplies a pointer to the path point to delete. The caller
  1388. should already have a reference on this path point, which will need to
  1389. be released by the caller when finished.
  1390. Flags - Supplies a bitfield of flags. See DELETE_FLAG_* definitions.
  1391. Return Value:
  1392. Status code.
  1393. --*/
  1394. KSTATUS
  1395. IopSendFileOperationIrp (
  1396. IRP_MINOR_CODE MinorCode,
  1397. PFILE_OBJECT FileObject,
  1398. PVOID DeviceContext,
  1399. ULONG Flags
  1400. );
  1401. /*++
  1402. Routine Description:
  1403. This routine sends a file operation IRP.
  1404. Arguments:
  1405. MinorCode - Supplies the minor code of the IRP to send.
  1406. FileObject - Supplies a pointer to the file object of the file being
  1407. operated on.
  1408. DeviceContext - Supplies a pointer to the device context to send down.
  1409. Flags - Supplies a bitmask of I/O flags. See IO_FLAG_* for definitions.
  1410. Return Value:
  1411. Status code.
  1412. --*/
  1413. KSTATUS
  1414. IopSendLookupRequest (
  1415. PDEVICE Device,
  1416. PFILE_OBJECT Directory,
  1417. PSTR FileName,
  1418. ULONG FileNameSize,
  1419. PFILE_PROPERTIES Properties
  1420. );
  1421. /*++
  1422. Routine Description:
  1423. This routine sends a lookup request IRP.
  1424. Arguments:
  1425. Device - Supplies a pointer to the device to send the request to.
  1426. Directory - Supplies a pointer to the file object of the directory to
  1427. search in.
  1428. FileName - Supplies a pointer to the name of the file, which may not be
  1429. null terminated.
  1430. FileNameSize - Supplies the size of the file name buffer including space
  1431. for a null terminator (which may be a null terminator or may be a
  1432. garbage character).
  1433. Properties - Supplies a pointer where the file properties will be returned
  1434. if the file was found.
  1435. Return Value:
  1436. Status code.
  1437. --*/
  1438. KSTATUS
  1439. IopSendRootLookupRequest (
  1440. PDEVICE Device,
  1441. PFILE_PROPERTIES Properties,
  1442. PULONG Flags
  1443. );
  1444. /*++
  1445. Routine Description:
  1446. This routine sends a lookup request IRP for the device's root.
  1447. Arguments:
  1448. Device - Supplies a pointer to the device to send the request to.
  1449. Properties - Supplies the file properties if the file was found.
  1450. Flags - Supplies a pointer that receives the flags returned by the root
  1451. lookup call. See LOOKUP_FLAG_* for definitions.
  1452. Return Value:
  1453. Status code.
  1454. --*/
  1455. KSTATUS
  1456. IopSendCreateRequest (
  1457. PDEVICE Device,
  1458. PFILE_OBJECT Directory,
  1459. PSTR Name,
  1460. ULONG NameSize,
  1461. PFILE_PROPERTIES Properties
  1462. );
  1463. /*++
  1464. Routine Description:
  1465. This routine sends a creation request to the device.
  1466. Arguments:
  1467. Device - Supplies a pointer to the device to send the request to.
  1468. Directory - Supplies a pointer to the file object of the directory to
  1469. create the file in.
  1470. Name - Supplies a pointer to the name of the file or directory to create,
  1471. which may not be null terminated.
  1472. NameSize - Supplies the size of the name buffer including space for a null
  1473. terminator (which may be a null terminator or may be a garbage
  1474. character).
  1475. Properties - Supplies a pointer to the file properties of the created file
  1476. on success. The permissions, object type, user ID, group ID, and access
  1477. times are all valid from the system.
  1478. Return Value:
  1479. Status code.
  1480. --*/
  1481. KSTATUS
  1482. IopSendUnlinkRequest (
  1483. PDEVICE Device,
  1484. PFILE_OBJECT FileObject,
  1485. PFILE_OBJECT DirectoryObject,
  1486. PSTR Name,
  1487. ULONG NameSize,
  1488. PBOOL Unlinked
  1489. );
  1490. /*++
  1491. Routine Description:
  1492. This routine sends an unlink request to the device. This routine assumes
  1493. that the directory's lock is held exclusively.
  1494. Arguments:
  1495. Device - Supplies a pointer to the device to send the request to.
  1496. FileObject - Supplies a pointer to the file object of the file that is to
  1497. be unlinked.
  1498. DirectoryObject - Supplies a pointer to the file object of the directory
  1499. from which the file will be unlinked.
  1500. Name - Supplies a pointer to the name of the file or directory to create,
  1501. which may not be null terminated.
  1502. NameSize - Supplies the size of the name buffer including space for a null
  1503. terminator (which may be a null terminator or may be a garbage
  1504. character).
  1505. Unlinked - Supplies a boolean that receives whether or not the file was
  1506. unlinked. The file may be unlinked even if the call fails.
  1507. Return Value:
  1508. Status code.
  1509. --*/
  1510. KSTATUS
  1511. IopPerformCacheableIoOperation (
  1512. PIO_HANDLE Handle,
  1513. PIO_CONTEXT IoContext
  1514. );
  1515. /*++
  1516. Routine Description:
  1517. This routine reads from or writes to the given handle. The I/O object type
  1518. of the given handle must be cacheable.
  1519. Arguments:
  1520. Handle - Supplies a pointer to the I/O handle.
  1521. IoContext - Supplies a pointer to the I/O context.
  1522. Return Value:
  1523. Status code. A failing status code does not necessarily mean no I/O made it
  1524. in or out. Check the bytes completed value in the I/O context to find out
  1525. how much occurred.
  1526. --*/
  1527. KSTATUS
  1528. IopPerformNonCachedRead (
  1529. PFILE_OBJECT FileObject,
  1530. PIO_CONTEXT IoContext,
  1531. PVOID DeviceContext
  1532. );
  1533. /*++
  1534. Routine Description:
  1535. This routine performs a non-cached read from a cacheable file object. It is
  1536. assumed that the file lock is held.
  1537. Arguments:
  1538. FileObject - Supplies a pointer to a cacheable file object.
  1539. IoContext - Supplies a pointer to the I/O context.
  1540. DeviceContext - Supplies a pointer to the device context to use when
  1541. writing to the backing device.
  1542. Return Value:
  1543. Status code.
  1544. --*/
  1545. KSTATUS
  1546. IopPerformNonCachedWrite (
  1547. PFILE_OBJECT FileObject,
  1548. PIO_CONTEXT IoContext,
  1549. PVOID DeviceContext
  1550. );
  1551. /*++
  1552. Routine Description:
  1553. This routine performs a non-cached write to a cacheable file object. It is
  1554. assumed that the file lock is held. This routine will always modify the
  1555. file size in the the file properties and conditionally modify the file size
  1556. in the file object.
  1557. Arguments:
  1558. FileObject - Supplies a pointer to the file object for the device or file.
  1559. IoContext - Supplies a pointer to the I/O context.
  1560. DeviceContext - Supplies a pointer to the device context to use when
  1561. writing to the backing device.
  1562. Return Value:
  1563. Status code.
  1564. --*/
  1565. KSTATUS
  1566. IopPerformObjectIoOperation (
  1567. PIO_HANDLE IoHandle,
  1568. PIO_CONTEXT IoContext
  1569. );
  1570. /*++
  1571. Routine Description:
  1572. This routine reads from an object directory.
  1573. Arguments:
  1574. IoHandle - Supplies a pointer to the I/O handle.
  1575. IoContext - Supplies a pointer to the I/O context.
  1576. Return Value:
  1577. Status code. A failing status code does not necessarily mean no I/O made it
  1578. in or out. Check the bytes completed value in the I/O context to find out
  1579. how much occurred.
  1580. --*/
  1581. KSTATUS
  1582. IopCreateIoHandle (
  1583. PIO_HANDLE *Handle
  1584. );
  1585. /*++
  1586. Routine Description:
  1587. This routine creates a new I/O handle with a reference count of one.
  1588. Arguments:
  1589. Handle - Supplies a pointer where a pointer to the new I/O handle will be
  1590. returned on success.
  1591. Return Value:
  1592. Status code.
  1593. --*/
  1594. VOID
  1595. IopOverwriteIoHandle (
  1596. PIO_HANDLE Destination,
  1597. PIO_HANDLE IoSource
  1598. );
  1599. /*++
  1600. Routine Description:
  1601. This routine takes the contents of the given source handle and overwrites
  1602. the destination handle with it. I/O actions performed on the destination
  1603. handle appear as if they were done to the I/O object of the source handle.
  1604. This replacement does not replace any information about the original path
  1605. opened in the destination. It also does not modify the access and open
  1606. flags in the destination. This routine is not thread safe.
  1607. Arguments:
  1608. Destination - Supplies a pointer to the I/O handle that should magically
  1609. redirect elsewhere.
  1610. IoSource - Supplies a pointer to the I/O handle that contains the
  1611. underlying I/O object the destination should interact with.
  1612. Return Value:
  1613. None.
  1614. --*/
  1615. KSTATUS
  1616. IopInitializeFileObjectSupport (
  1617. VOID
  1618. );
  1619. /*++
  1620. Routine Description:
  1621. This routine performs global initialization for file object support.
  1622. Arguments:
  1623. None.
  1624. Return Value:
  1625. Status code.
  1626. --*/
  1627. KSTATUS
  1628. IopCreateOrLookupFileObject (
  1629. PFILE_PROPERTIES Properties,
  1630. PDEVICE Device,
  1631. ULONG Flags,
  1632. PFILE_OBJECT *FileObject,
  1633. PBOOL ObjectCreated
  1634. );
  1635. /*++
  1636. Routine Description:
  1637. This routine attempts to look up a file object with the given properties
  1638. (specifically the I-Node number and volume). If one does not exist, it
  1639. is created and inserted in the global list. If a special file object is
  1640. created, the ready event is left unsignaled so the remainder of the state
  1641. can be created.
  1642. Arguments:
  1643. Properties - Supplies a pointer to the file object properties.
  1644. Device - Supplies a pointer to the device that owns the file serial number.
  1645. This may also be a volume or an object directory.
  1646. Flags - Supplies a bitmask of file object flags. See FILE_OBJECT_FLAG_* for
  1647. definitions.
  1648. FileObject - Supplies a pointer where the file object will be returned on
  1649. success.
  1650. ObjectCreated - Supplies a pointer where a boolean will be returned
  1651. indicating whether or not the object was just created. If it was just
  1652. created, the caller is responsible for signaling the ready event when
  1653. the object is fully set up.
  1654. Return Value:
  1655. Status code.
  1656. --*/
  1657. ULONG
  1658. IopFileObjectAddReference (
  1659. PFILE_OBJECT Object
  1660. );
  1661. /*++
  1662. Routine Description:
  1663. This routine increments the reference count on a file object.
  1664. Arguments:
  1665. Object - Supplies a pointer to the object to retain.
  1666. Return Value:
  1667. Returns the reference count before the addition.
  1668. --*/
  1669. KSTATUS
  1670. IopFileObjectReleaseReference (
  1671. PFILE_OBJECT Object
  1672. );
  1673. /*++
  1674. Routine Description:
  1675. This routine decrements the reference count on a file object. If the
  1676. reference count hits zero, then the file object will be destroyed.
  1677. Arguments:
  1678. Object - Supplies a pointer to the object to release.
  1679. FailIfLastReference - Supplies a boolean that if set causes the reference
  1680. count not to be decremented if this would involve releasing the very
  1681. last reference on the file object. Callers that set this flag must be
  1682. able to take responsibility for the reference they continue to own in
  1683. the failure case. Set this to FALSE.
  1684. Return Value:
  1685. STATUS_SUCCESS on success.
  1686. Other error codes on failure to write out the file properties to the file
  1687. system or device.
  1688. --*/
  1689. VOID
  1690. IopFileObjectAddPathEntryReference (
  1691. PFILE_OBJECT FileObject
  1692. );
  1693. /*++
  1694. Routine Description:
  1695. This routine increments the path entry reference count on a file object.
  1696. Arguments:
  1697. FileObject - Supplies a pointer to a file object.
  1698. Return Value:
  1699. None.
  1700. --*/
  1701. VOID
  1702. IopFileObjectReleasePathEntryReference (
  1703. PFILE_OBJECT FileObject
  1704. );
  1705. /*++
  1706. Routine Description:
  1707. This routine decrements the path entry reference count on a file object.
  1708. Arguments:
  1709. FileObject - Supplies a pointer to a file object.
  1710. Return Value:
  1711. None.
  1712. --*/
  1713. KSTATUS
  1714. IopFlushFileObject (
  1715. PFILE_OBJECT FileObject,
  1716. IO_OFFSET Offset,
  1717. ULONGLONG Size,
  1718. ULONG Flags,
  1719. BOOL FlushExclusive,
  1720. PUINTN PageCount
  1721. );
  1722. /*++
  1723. Routine Description:
  1724. This routine flushes all file object data to the next lowest cache layer.
  1725. If the flags request synchronized I/O, then all file data and meta-data
  1726. will be flushed to the backing media.
  1727. Arguments:
  1728. FileObject - Supplies a pointer to a file object for the device or file.
  1729. Offset - Supplies the offset from the beginning of the file or device where
  1730. the flush should be done.
  1731. Size - Supplies the size, in bytes, of the region to flush. Supply a value
  1732. of -1 to flush from the given offset to the end of the file.
  1733. Flags - Supplies a bitmask of I/O flags. See IO_FLAG_* for definitions.
  1734. FlushExclusive - Supplies a boolean indicating if this was an explicit
  1735. flush. If so, then the flush lock is acquired exclusively to prevent
  1736. partial flushes due to dirty page cache entries being on a local list.
  1737. PageCount - Supplies an optional pointer describing how many pages to flush.
  1738. On output this value will be decreased by the number of pages actually
  1739. flushed. Supply NULL to flush all pages in the size range.
  1740. Return Value:
  1741. Status code.
  1742. --*/
  1743. KSTATUS
  1744. IopFlushFileObjects (
  1745. DEVICE_ID DeviceId,
  1746. ULONG Flags,
  1747. PUINTN PageCount
  1748. );
  1749. /*++
  1750. Routine Description:
  1751. This routine iterates over file objects in the global dirty file objects
  1752. list, flushing each one that belongs to the given device or to all entries
  1753. if a device ID of 0 is specified.
  1754. Arguments:
  1755. DeviceId - Supplies an optional device ID filter. Supply 0 to iterate over
  1756. dirty file objects for all devices.
  1757. Flags - Supplies a bitmask of I/O flags. See IO_FLAG_* for definitions.
  1758. PageCount - Supplies an optional pointer describing how many pages to flush.
  1759. On output this value will be decreased by the number of pages actually
  1760. flushed. Supply NULL to flush all pages.
  1761. Return Value:
  1762. STATUS_SUCCESS if all file object were successfully iterated.
  1763. STATUS_TRY_AGAIN if the iteration quit early for some reason (i.e. the page
  1764. cache was found to be too dirty when flushing file objects).
  1765. Other status codes for other errors.
  1766. --*/
  1767. VOID
  1768. IopEvictFileObjects (
  1769. DEVICE_ID DeviceId,
  1770. ULONG Flags
  1771. );
  1772. /*++
  1773. Routine Description:
  1774. This routine iterates over all file objects evicting page cache entries for
  1775. each one that belongs to the given device.
  1776. Arguments:
  1777. DeviceId - Supplies an optional device ID filter. Supply 0 to iterate over
  1778. file objects for all devices.
  1779. Flags - Supplies a bitmask of eviction flags. See
  1780. PAGE_CACHE_EVICTION_FLAG_* for definitions.
  1781. Return Value:
  1782. None.
  1783. --*/
  1784. KSTATUS
  1785. IopFlushAllFileObjectsProperties (
  1786. BOOL StopIfTooDirty
  1787. );
  1788. /*++
  1789. Routine Description:
  1790. This routine flushes all dirty file object properties.
  1791. Arguments:
  1792. StopIfTooDirty - Supplies a boolean that if set indicates this routine
  1793. should stop flushing file object properties if the page cache is too
  1794. dirty.
  1795. Return Value:
  1796. STATUS_SUCCESS if all file object properties were successfully flushed, or
  1797. the device ID was zero.
  1798. STATUS_TRY_AGAIN if the page cache became too dirty and the function quit
  1799. early.
  1800. Other status codes for other errors.
  1801. --*/
  1802. KSTATUS
  1803. IopFlushFileObjectPropertiesByDevice (
  1804. DEVICE_ID DeviceId,
  1805. BOOL StopIfTooDirty
  1806. );
  1807. /*++
  1808. Routine Description:
  1809. This routine flushes the file properties for all the file objects that
  1810. belong to a given device. If no device ID is specified, it flushes the file
  1811. objects for all devices.
  1812. Arguments:
  1813. DeviceId - Supplies the ID of the device whose file objects' properties are
  1814. to be flushed.
  1815. StopIfTooDirty - Supplies a boolean that if set indicates this routine
  1816. should stop flushing file object properties if the page cache is too
  1817. dirty.
  1818. Return Value:
  1819. STATUS_SUCCESS if all file object properties were successfully flushed, or
  1820. the device ID was zero.
  1821. STATUS_TRY_AGAIN if the page cache became too dirty and the function quit
  1822. early.
  1823. --*/
  1824. VOID
  1825. IopUpdateFileObjectTime (
  1826. PFILE_OBJECT FileObject,
  1827. FILE_OBJECT_TIME_TYPE TimeType
  1828. );
  1829. /*++
  1830. Routine Description:
  1831. This routine updates the given file object's access and modified times. The
  1832. latter is only updated upon request.
  1833. Arguments:
  1834. FileObject - Supplies a pointer to a file object.
  1835. TimeType - Supplies the type of time to update. Updating modified time also
  1836. updates status change time.
  1837. Return Value:
  1838. None.
  1839. --*/
  1840. VOID
  1841. IopUpdateFileObjectFileSize (
  1842. PFILE_OBJECT FileObject,
  1843. ULONGLONG NewSize
  1844. );
  1845. /*++
  1846. Routine Description:
  1847. This routine will make sure the file object file size is at least the
  1848. given size. If it is not, it will be set to the given size. If it is, no
  1849. change will be performed. Use the modify file object size function to
  1850. forcibly set a new size (eg for truncate).
  1851. Arguments:
  1852. FileObject - Supplies a pointer to a file object.
  1853. NewSize - Supplies the new file size.
  1854. Return Value:
  1855. None.
  1856. --*/
  1857. KSTATUS
  1858. IopModifyFileObjectSize (
  1859. PFILE_OBJECT FileObject,
  1860. PVOID DeviceContext,
  1861. ULONGLONG NewFileSize
  1862. );
  1863. /*++
  1864. Routine Description:
  1865. This routine modifies the given file object's size. It will either increase
  1866. or decrease the file size. If the size is decreased then the file object's
  1867. driver will be notified, any existing page cache entries for the file will
  1868. be evicted and any image sections that map the file will be unmapped.
  1869. Arguments:
  1870. FileObject - Supplies a pointer to the file object whose size will be
  1871. modified.
  1872. DeviceContext - Supplies an optional pointer to the device context to use
  1873. when doing file operations. Not every file object has a built-in device
  1874. context.
  1875. NewFileSize - Supplies the desired new size of the file object.
  1876. Return Value:
  1877. Status code.
  1878. --*/
  1879. VOID
  1880. IopFileObjectIncrementHardLinkCount (
  1881. PFILE_OBJECT FileObject
  1882. );
  1883. /*++
  1884. Routine Description:
  1885. This routine decrements the hard link count for a file object.
  1886. Arguments:
  1887. FileObject - Supplies a pointer to a file object.
  1888. Return Value:
  1889. None.
  1890. --*/
  1891. VOID
  1892. IopFileObjectDecrementHardLinkCount (
  1893. PFILE_OBJECT FileObject
  1894. );
  1895. /*++
  1896. Routine Description:
  1897. This routine decrements the hard link count for a file object.
  1898. Arguments:
  1899. FileObject - Supplies a pointer to a file object.
  1900. Return Value:
  1901. None.
  1902. --*/
  1903. VOID
  1904. IopCleanupFileObjects (
  1905. VOID
  1906. );
  1907. /*++
  1908. Routine Description:
  1909. This routine releases any lingering file objects that were left around as a
  1910. result of I/O failures during the orignal release attempt.
  1911. Arguments:
  1912. None.
  1913. Return Value:
  1914. None.
  1915. --*/
  1916. VOID
  1917. IopAcquireFileObjectLocksExclusive (
  1918. PFILE_OBJECT Object1,
  1919. PFILE_OBJECT Object2
  1920. );
  1921. /*++
  1922. Routine Description:
  1923. This routine acquires two file object locks exclusive in the right order.
  1924. The order is to sort first by file object type, then by file object pointer.
  1925. Arguments:
  1926. Object1 - Supplies a pointer to the first file object.
  1927. Object2 - Supplies a pointer to the second file object.
  1928. Return Value:
  1929. None.
  1930. --*/
  1931. PIMAGE_SECTION_LIST
  1932. IopGetImageSectionListFromFileObject (
  1933. PFILE_OBJECT FileObject
  1934. );
  1935. /*++
  1936. Routine Description:
  1937. This routine gets the image section for the given file object.
  1938. Arguments:
  1939. FileObject - Supplies a pointer to a file object.
  1940. Return Value:
  1941. Returns a pointer to the file object's image section list or NULL on
  1942. failure.
  1943. --*/
  1944. VOID
  1945. IopMarkFileObjectDirty (
  1946. PFILE_OBJECT FileObject
  1947. );
  1948. /*++
  1949. Routine Description:
  1950. This routine marks the given file object as dirty, moving it to the list of
  1951. dirty file objects if it is not already on a list.
  1952. Arguments:
  1953. FileObject - Supplies a pointer to the dirty file object.
  1954. Return Value:
  1955. None.
  1956. --*/
  1957. VOID
  1958. IopMarkFileObjectPropertiesDirty (
  1959. PFILE_OBJECT FileObject
  1960. );
  1961. /*++
  1962. Routine Description:
  1963. This routine marks that the given file object's properties are dirty.
  1964. Arguments:
  1965. FileObject - Supplies a pointer to the file object whose properties are
  1966. dirty.
  1967. Return Value:
  1968. None.
  1969. --*/
  1970. VOID
  1971. IopCheckDirtyFileObjectsList (
  1972. VOID
  1973. );
  1974. /*++
  1975. Routine Description:
  1976. This routine iterates over all file objects, checking to make sure they're
  1977. properly marked dirty and in the dirty list if they have dirty entries.
  1978. This routine is slow and should only be used while actively debugging
  1979. dirty data that won't flush.
  1980. Arguments:
  1981. None.
  1982. Return Value:
  1983. None.
  1984. --*/
  1985. PIO_ASYNC_STATE
  1986. IopGetAsyncState (
  1987. PIO_OBJECT_STATE State
  1988. );
  1989. /*++
  1990. Routine Description:
  1991. This routine returns or attempts to create the asynchronous state for an
  1992. I/O object state.
  1993. Arguments:
  1994. State - Supplies a pointer to the I/O object state.
  1995. Return Value:
  1996. Returns a pointer to the async state on success. This may have just been
  1997. created.
  1998. NULL if no async state exists and none could be created.
  1999. --*/
  2000. POBJECT_HEADER
  2001. IopGetPipeDirectory (
  2002. VOID
  2003. );
  2004. /*++
  2005. Routine Description:
  2006. This routine returns the pipe root directory in the object system. This is
  2007. the only place in the object system pipe creation is allowed.
  2008. Arguments:
  2009. None.
  2010. Return Value:
  2011. Returns a pointer to the pipe directory.
  2012. --*/
  2013. KSTATUS
  2014. IopCreatePipe (
  2015. PSTR Name,
  2016. ULONG NameSize,
  2017. FILE_PERMISSIONS Permissions,
  2018. PFILE_OBJECT *FileObject
  2019. );
  2020. /*++
  2021. Routine Description:
  2022. This routine actually creates a new pipe.
  2023. Arguments:
  2024. Name - Supplies an optional pointer to the pipe name. This is only used for
  2025. named pipes created in the pipe directory.
  2026. NameSize - Supplies the size of the name in bytes including the null
  2027. terminator.
  2028. Permissions - Supplies the permissions to give to the file object.
  2029. FileObject - Supplies a pointer where a pointer to a newly created pipe
  2030. file object will be returned on success.
  2031. Return Value:
  2032. Status code.
  2033. --*/
  2034. KSTATUS
  2035. IopUnlinkPipe (
  2036. PFILE_OBJECT FileObject,
  2037. PBOOL Unlinked
  2038. );
  2039. /*++
  2040. Routine Description:
  2041. This routine unlinks a pipe from the accessible namespace.
  2042. Arguments:
  2043. FileObject - Supplies a pointer to the pipe's file object.
  2044. Unlinked - Supplies a pointer to a boolean that receives whether or not the
  2045. terminal was successfully unlinked.
  2046. Return Value:
  2047. Status code.
  2048. --*/
  2049. KSTATUS
  2050. IopOpenPipe (
  2051. PIO_HANDLE IoHandle
  2052. );
  2053. /*++
  2054. Routine Description:
  2055. This routine is called when a pipe is opened.
  2056. Arguments:
  2057. IoHandle - Supplies a pointer to the new I/O handle.
  2058. Return Value:
  2059. Status code.
  2060. --*/
  2061. KSTATUS
  2062. IopClosePipe (
  2063. PIO_HANDLE IoHandle
  2064. );
  2065. /*++
  2066. Routine Description:
  2067. This routine is called when a pipe is closed.
  2068. Arguments:
  2069. IoHandle - Supplies a pointer to the I/O handle being closed.
  2070. Return Value:
  2071. Status code.
  2072. --*/
  2073. KSTATUS
  2074. IopPerformPipeIoOperation (
  2075. PIO_HANDLE Handle,
  2076. PIO_CONTEXT IoContext
  2077. );
  2078. /*++
  2079. Routine Description:
  2080. This routine reads from or writes to a pipe.
  2081. Arguments:
  2082. Handle - Supplies a pointer to the pipe I/O handle.
  2083. IoContext - Supplies a pointer to the I/O context.
  2084. Return Value:
  2085. Status code. A failing status code does not necessarily mean no I/O made it
  2086. in or out. Check the bytes completed value in the I/O context to find out
  2087. how much occurred.
  2088. --*/
  2089. KSTATUS
  2090. IopInitializeTerminalSupport (
  2091. VOID
  2092. );
  2093. /*++
  2094. Routine Description:
  2095. This routine is called during system initialization to set up support for
  2096. terminals.
  2097. Arguments:
  2098. None.
  2099. Return Value:
  2100. Status code.
  2101. --*/
  2102. KSTATUS
  2103. IopTerminalOpenMaster (
  2104. PIO_HANDLE IoHandle
  2105. );
  2106. /*++
  2107. Routine Description:
  2108. This routine is called when a master terminal was just opened.
  2109. Arguments:
  2110. IoHandle - Supplies a pointer to the I/O handle for the terminal.
  2111. Return Value:
  2112. Status code.
  2113. --*/
  2114. KSTATUS
  2115. IopTerminalCloseMaster (
  2116. PIO_HANDLE IoHandle
  2117. );
  2118. /*++
  2119. Routine Description:
  2120. This routine is called when a master terminal was just closed.
  2121. Arguments:
  2122. IoHandle - Supplies a pointer to the handle to close.
  2123. Return Value:
  2124. Status code.
  2125. --*/
  2126. KSTATUS
  2127. IopTerminalOpenSlave (
  2128. PIO_HANDLE IoHandle
  2129. );
  2130. /*++
  2131. Routine Description:
  2132. This routine opens the slave side of a terminal object.
  2133. Arguments:
  2134. IoHandle - Supplies a pointer to the I/O handle for the terminal.
  2135. Return Value:
  2136. Status code.
  2137. --*/
  2138. KSTATUS
  2139. IopTerminalCloseSlave (
  2140. PIO_HANDLE IoHandle
  2141. );
  2142. /*++
  2143. Routine Description:
  2144. This routine is called when a master terminal was just closed.
  2145. Arguments:
  2146. IoHandle - Supplies a pointer to the handle to close.
  2147. Return Value:
  2148. Status code.
  2149. --*/
  2150. KSTATUS
  2151. IopPerformTerminalMasterIoOperation (
  2152. PIO_HANDLE Handle,
  2153. PIO_CONTEXT IoContext
  2154. );
  2155. /*++
  2156. Routine Description:
  2157. This routine reads from or writes to the master end of a terminal.
  2158. Arguments:
  2159. Handle - Supplies a pointer to the master terminal I/O handle.
  2160. IoContext - Supplies a pointer to the I/O context.
  2161. Return Value:
  2162. Status code. A failing status code does not necessarily mean no I/O made it
  2163. in or out. Check the bytes completed value in the I/O context to find out
  2164. how much occurred.
  2165. --*/
  2166. KSTATUS
  2167. IopPerformTerminalSlaveIoOperation (
  2168. PIO_HANDLE Handle,
  2169. PIO_CONTEXT IoContext
  2170. );
  2171. /*++
  2172. Routine Description:
  2173. This routine reads from or writes to the slave end of a terminal.
  2174. Arguments:
  2175. Handle - Supplies a pointer to the slave terminal I/O handle.
  2176. IoContext - Supplies a pointer to the I/O context.
  2177. Return Value:
  2178. Status code. A failing status code does not necessarily mean no I/O made it
  2179. in or out. Check the bytes completed value in the I/O context to find out
  2180. how much occurred.
  2181. --*/
  2182. KSTATUS
  2183. IopCreateTerminal (
  2184. IO_OBJECT_TYPE Type,
  2185. PVOID OverrideParameter,
  2186. FILE_PERMISSIONS CreatePermissions,
  2187. PFILE_OBJECT *FileObject
  2188. );
  2189. /*++
  2190. Routine Description:
  2191. This routine creates a terminal master or slave.
  2192. Arguments:
  2193. Type - Supplies the type of special object to create.
  2194. OverrideParameter - Supplies an optional parameter to send along with the
  2195. override type.
  2196. CreatePermissions - Supplies the permissions to assign to the new file.
  2197. FileObject - Supplies a pointer where a pointer to the new file object
  2198. will be returned on success.
  2199. Return Value:
  2200. Status code.
  2201. --*/
  2202. KSTATUS
  2203. IopUnlinkTerminal (
  2204. PFILE_OBJECT FileObject,
  2205. PBOOL Unlinked
  2206. );
  2207. /*++
  2208. Routine Description:
  2209. This routine unlinks a terminal from the accessible namespace.
  2210. Arguments:
  2211. FileObject - Supplies a pointer to the terminal's file object.
  2212. Unlinked - Supplies a pointer to a boolean that receives whether or not the
  2213. terminal was successfully unlinked.
  2214. Return Value:
  2215. Status code.
  2216. --*/
  2217. KSTATUS
  2218. IopTerminalUserControl (
  2219. PIO_HANDLE Handle,
  2220. TERMINAL_USER_CONTROL_CODE CodeNumber,
  2221. BOOL FromKernelMode,
  2222. PVOID ContextBuffer,
  2223. UINTN ContextBufferSize
  2224. );
  2225. /*++
  2226. Routine Description:
  2227. This routine handles user control requests destined for a terminal object.
  2228. Arguments:
  2229. Handle - Supplies the open file handle.
  2230. CodeNumber - Supplies the minor code of the request.
  2231. FromKernelMode - Supplies a boolean indicating whether or not this request
  2232. (and the buffer associated with it) originates from user mode (FALSE)
  2233. or kernel mode (TRUE).
  2234. ContextBuffer - Supplies a pointer to the context buffer allocated by the
  2235. caller for the request.
  2236. ContextBufferSize - Supplies the size of the supplied context buffer.
  2237. Return Value:
  2238. Status code.
  2239. --*/
  2240. KSTATUS
  2241. IopTerminalFlush (
  2242. PFILE_OBJECT FileObject,
  2243. ULONG Flags
  2244. );
  2245. /*++
  2246. Routine Description:
  2247. This routine flushes a terminal object, discarding unwritten and unread
  2248. data.
  2249. Arguments:
  2250. FileObject - Supplies a pointer to the terminal to flush.
  2251. Flags - Supplies the flags governing the flush operation. See FLUSH_FLAG_*
  2252. definitions.
  2253. Return Value:
  2254. Status code.
  2255. --*/
  2256. KSTATUS
  2257. IopCreateSocket (
  2258. PVOID Parameter,
  2259. FILE_PERMISSIONS CreatePermissions,
  2260. PFILE_OBJECT *FileObject
  2261. );
  2262. /*++
  2263. Routine Description:
  2264. This routine allocates resources associated with a new socket.
  2265. Arguments:
  2266. Parameter - Supplies the parameters the socket was created with.
  2267. CreatePermissions - Supplies the permissions to create the file with.
  2268. FileObject - Supplies a pointer where the new file object representing the
  2269. socket will be returned on success.
  2270. Return Value:
  2271. Status code.
  2272. --*/
  2273. KSTATUS
  2274. IopPerformSocketIoOperation (
  2275. PIO_HANDLE Handle,
  2276. PIO_CONTEXT IoContext
  2277. );
  2278. /*++
  2279. Routine Description:
  2280. This routine reads from or writes to a socket.
  2281. Arguments:
  2282. Handle - Supplies a pointer to the socket I/O handle.
  2283. IoContext - Supplies a pointer to the I/O context.
  2284. Return Value:
  2285. Status code. A failing status code does not necessarily mean no I/O made it
  2286. in or out. Check the bytes completed value in the I/O context to find out
  2287. how much occurred.
  2288. --*/
  2289. KSTATUS
  2290. IopOpenSocket (
  2291. PIO_HANDLE IoHandle
  2292. );
  2293. /*++
  2294. Routine Description:
  2295. This routine opens a socket connection.
  2296. Arguments:
  2297. IoHandle - Supplies a pointer to the I/O handle for the socket being opened.
  2298. Return Value:
  2299. Status code.
  2300. --*/
  2301. KSTATUS
  2302. IopCloseSocket (
  2303. PIO_HANDLE IoHandle
  2304. );
  2305. /*++
  2306. Routine Description:
  2307. This routine closes a socket connection.
  2308. Arguments:
  2309. IoHandle - Supplies a pointer to the socket handle to close.
  2310. Return Value:
  2311. Status code.
  2312. --*/
  2313. KSTATUS
  2314. IopOpenSharedMemoryObject (
  2315. PSTR Path,
  2316. ULONG PathLength,
  2317. ULONG Access,
  2318. ULONG Flags,
  2319. FILE_PERMISSIONS CreatePermissions,
  2320. PIO_HANDLE *Handle
  2321. );
  2322. /*++
  2323. Routine Description:
  2324. This routine opens a shared memory objeect.
  2325. Arguments:
  2326. Path - Supplies a pointer to the path to open.
  2327. PathLength - Supplies the length of the path buffer in bytes, including the
  2328. null terminator.
  2329. Access - Supplies the desired access permissions to the object. See
  2330. IO_ACCESS_* definitions.
  2331. Flags - Supplies a bitfield of flags governing the behavior of the handle.
  2332. See OPEN_FLAG_* definitions.
  2333. CreatePermissions - Supplies the permissions to apply for a created file.
  2334. Handle - Supplies a pointer where a pointer to the open I/O handle will be
  2335. returned on success.
  2336. Return Value:
  2337. Status code.
  2338. --*/
  2339. KSTATUS
  2340. IopDeleteSharedMemoryObject (
  2341. PSTR Path,
  2342. ULONG PathLength
  2343. );
  2344. /*++
  2345. Routine Description:
  2346. This routine deletes a shared memory object. It does not handle deletion of
  2347. unnamed anonymous shared memory objects.
  2348. Arguments:
  2349. Path - Supplies a pointer to the path of the shared memory object within
  2350. the shared memory object namespace.
  2351. PathLength - Supplies the length of the path, in bytes, including the null
  2352. terminator.
  2353. Return Value:
  2354. Status code.
  2355. --*/
  2356. POBJECT_HEADER
  2357. IopGetSharedMemoryObjectDirectory (
  2358. VOID
  2359. );
  2360. /*++
  2361. Routine Description:
  2362. This routine returns the shared memory objects' root directory in the
  2363. object manager's system. This is the only place in the object system
  2364. shared memory object creation is allowed.
  2365. Arguments:
  2366. None.
  2367. Return Value:
  2368. Returns a pointer to the shared memory object directory.
  2369. --*/
  2370. KSTATUS
  2371. IopCreateSharedMemoryObject (
  2372. PSTR Name,
  2373. ULONG NameSize,
  2374. ULONG Flags,
  2375. FILE_PERMISSIONS Permissions,
  2376. PFILE_OBJECT *FileObject
  2377. );
  2378. /*++
  2379. Routine Description:
  2380. This routine actually creates a new shared memory object.
  2381. Arguments:
  2382. Name - Supplies an optional pointer to the shared memory object name. This
  2383. is only used for shared memory objects created in the shared memory
  2384. directory.
  2385. NameSize - Supplies the size of the name in bytes including the null
  2386. terminator.
  2387. Flags - Supplies a bitfield of flags governing the behavior of the handle.
  2388. See OPEN_FLAG_* definitions.
  2389. Permissions - Supplies the permissions to give to the file object.
  2390. FileObject - Supplies a pointer where a pointer to a newly created pipe
  2391. file object will be returned on success.
  2392. Return Value:
  2393. Status code.
  2394. --*/
  2395. KSTATUS
  2396. IopTruncateSharedMemoryObject (
  2397. PFILE_OBJECT FileObject,
  2398. ULONGLONG NewSize
  2399. );
  2400. /*++
  2401. Routine Description:
  2402. This routine truncates a shared memory object. It assumes that the file's
  2403. lock is held exclusively.
  2404. Arguments:
  2405. FileObject - Supplies a pointer to the file object that owns the shared
  2406. memory object.
  2407. NewSize - Supplies the new size to set.
  2408. Return Value:
  2409. Status code.
  2410. --*/
  2411. KSTATUS
  2412. IopUnlinkSharedMemoryObject (
  2413. PFILE_OBJECT FileObject,
  2414. PBOOL Unlinked
  2415. );
  2416. /*++
  2417. Routine Description:
  2418. This routine unlinks a shared memory object from the accessible namespace.
  2419. Arguments:
  2420. FileObject - Supplies a pointer to the file object that owns the shared
  2421. memory object.
  2422. Unlinked - Supplies a pointer to a boolean that receives whether or not the
  2423. shared memory object was successfully unlinked.
  2424. Return Value:
  2425. Status code.
  2426. --*/
  2427. KSTATUS
  2428. IopPerformSharedMemoryIoOperation (
  2429. PFILE_OBJECT FileObject,
  2430. PIO_CONTEXT IoContext
  2431. );
  2432. /*++
  2433. Routine Description:
  2434. This routine performs a non-cached I/O operation on a shared memory object.
  2435. It is assumed that the file lock is held. This routine will always modify
  2436. the file size in the the file properties and conditionally modify the file
  2437. size in the file object.
  2438. Arguments:
  2439. FileObject - Supplies a pointer to the file object for the device or file.
  2440. IoContext - Supplies a pointer to the I/O context.
  2441. Return Value:
  2442. Status code.
  2443. --*/
  2444. KSTATUS
  2445. IopInitializePathSupport (
  2446. VOID
  2447. );
  2448. /*++
  2449. Routine Description:
  2450. This routine is called at system initialization time to initialize support
  2451. for path traversal. It connects the root of the object manager to the root
  2452. of the path system.
  2453. Arguments:
  2454. None.
  2455. Return Value:
  2456. Status code.
  2457. --*/
  2458. KSTATUS
  2459. IopPathWalk (
  2460. BOOL FromKernelMode,
  2461. PPATH_POINT Directory,
  2462. PSTR *Path,
  2463. PULONG PathSize,
  2464. ULONG OpenFlags,
  2465. IO_OBJECT_TYPE TypeOverride,
  2466. PVOID OverrideParameter,
  2467. FILE_PERMISSIONS CreatePermissions,
  2468. PPATH_POINT Result
  2469. );
  2470. /*++
  2471. Routine Description:
  2472. This routine attempts to walk the given path.
  2473. Arguments:
  2474. FromKernelMode - Supplies a boolean indicating whether or not this request
  2475. is coming directly from kernel mode (and should use the kernel's root).
  2476. Directory - Supplies an optional pointer to a path point containing the
  2477. directory to start from if the path is relative. Supply NULL to use the
  2478. current working directory.
  2479. Path - Supplies a pointer that on input contains a pointer to the string
  2480. of the path to walk. This pointer will be advanced beyond the portion
  2481. of the path that was successfully walked.
  2482. PathSize - Supplies a pointer that on input contains the size of the
  2483. input path string in bytes. This value will be updated to reflect the
  2484. new size of the updated path string.
  2485. OpenFlags - Supplies a bitfield of flags governing the behavior of the
  2486. handle. See OPEN_FLAG_* definitions.
  2487. TypeOverride - Supplies the type of object to create. If this is invalid,
  2488. then this routine will try to open an existing object. If this type is
  2489. valid, then this routine will attempt to create an object of the given
  2490. type.
  2491. OverrideParameter - Supplies an optional parameter to send along with the
  2492. override type.
  2493. CreatePermissions - Supplies the permissions to assign to a created file.
  2494. Result - Supplies a pointer to a path point that receives the resulting
  2495. path entry and mount point on success. The path entry and mount point
  2496. will come with an extra reference on them, so the caller must be sure
  2497. to release the references when finished.
  2498. Return Value:
  2499. Status code.
  2500. --*/
  2501. VOID
  2502. IopFillOutFilePropertiesForObject (
  2503. PFILE_PROPERTIES Properties,
  2504. POBJECT_HEADER Object
  2505. );
  2506. /*++
  2507. Routine Description:
  2508. This routine fills out the file properties structure for an object manager
  2509. object.
  2510. Arguments:
  2511. Properties - Supplies a pointer to the file properties.
  2512. Object - Supplies a pointer to the object.
  2513. Return Value:
  2514. TRUE if the paths are equals.
  2515. FALSE if the paths differ in some way.
  2516. --*/
  2517. PPATH_ENTRY
  2518. IopCreateAnonymousPathEntry (
  2519. PFILE_OBJECT FileObject
  2520. );
  2521. /*++
  2522. Routine Description:
  2523. This routine creates a new path entry structure that is not connected to
  2524. the global path tree.
  2525. Arguments:
  2526. FileObject - Supplies a pointer to the file object backing this entry. This
  2527. routine takes ownership of an assumed reference on the file object.
  2528. Return Value:
  2529. Returns a pointer to the path entry on success.
  2530. NULL on allocation failure.
  2531. --*/
  2532. KSTATUS
  2533. IopPathSplit (
  2534. PSTR Path,
  2535. ULONG PathSize,
  2536. PSTR *DirectoryComponent,
  2537. PULONG DirectoryComponentSize,
  2538. PSTR *LastComponent,
  2539. PULONG LastComponentSize
  2540. );
  2541. /*++
  2542. Routine Description:
  2543. This routine creates a new string containing the last component of the
  2544. given path.
  2545. Arguments:
  2546. Path - Supplies a pointer to the null terminated path string.
  2547. PathSize - Supplies the size of the path string in bytes including the
  2548. null terminator.
  2549. DirectoryComponent - Supplies a pointer where a newly allocated string
  2550. containing only the directory component will be returned on success.
  2551. The caller is responsible for freeing this memory from paged pool.
  2552. DirectoryComponentSize - Supplies a pointer where the size of the directory
  2553. component buffer in bytes including the null terminator will be
  2554. returned.
  2555. LastComponent - Supplies a pointer where a newly allocated string
  2556. containing only the last component will be returned on success. The
  2557. caller is responsible for freeing this memory from paged pool.
  2558. LastComponentSize - Supplies a pointer where the size of the last component
  2559. buffer in bytes including the null terminator will be returned.
  2560. Return Value:
  2561. Status code.
  2562. --*/
  2563. PPATH_ENTRY
  2564. IopCreatePathEntry (
  2565. PSTR Name,
  2566. ULONG NameSize,
  2567. ULONG Hash,
  2568. PPATH_ENTRY Parent,
  2569. PFILE_OBJECT FileObject
  2570. );
  2571. /*++
  2572. Routine Description:
  2573. This routine creates a new path entry structure.
  2574. Arguments:
  2575. Name - Supplies an optional pointer to the name to give this path entry. A
  2576. copy of this name will be made.
  2577. NameSize - Supplies the size of the name buffer in bytes including the
  2578. null terminator.
  2579. Hash - Supplies the hash of the name string.
  2580. Parent - Supplies a pointer to the parent of this entry.
  2581. FileObject - Supplies an optional pointer to the file object backing this
  2582. entry. This routine takes ownership of an assumed reference on the file
  2583. object.
  2584. Return Value:
  2585. Returns a pointer to the path entry on success.
  2586. NULL on allocation failure.
  2587. --*/
  2588. ULONG
  2589. IopHashPathString (
  2590. PSTR String,
  2591. ULONG StringSize
  2592. );
  2593. /*++
  2594. Routine Description:
  2595. This routine generates the hash associated with a path name. This hash is
  2596. used to speed up comparisons.
  2597. Arguments:
  2598. String - Supplies a pointer to the string to hash.
  2599. StringSize - Supplies the size of the string, including the null terminator.
  2600. Return Value:
  2601. Returns the hash of the given string.
  2602. --*/
  2603. BOOL
  2604. IopIsDescendantPath (
  2605. PPATH_ENTRY Ancestor,
  2606. PPATH_ENTRY DescendantEntry
  2607. );
  2608. /*++
  2609. Routine Description:
  2610. This routine determines whether or not the given descendant path entry is a
  2611. descendent of the given path entry. This does not take mount points into
  2612. account.
  2613. Arguments:
  2614. Ancestor - Supplies a pointer to the possible ancestor path entry.
  2615. DescendantEntry - Supplies a pointer to the possible descendant path entry.
  2616. Return Value:
  2617. Returns TRUE if it is a descendant, or FALSE otherwise.
  2618. --*/
  2619. VOID
  2620. IopPathUnlink (
  2621. PPATH_ENTRY Entry
  2622. );
  2623. /*++
  2624. Routine Description:
  2625. This routine unlinks the given path entry from the path hierarchy. This
  2626. assumes the caller hold both the path entry's file object lock (if it
  2627. exists) and the parent path entry's file object lock exclusively.
  2628. Arguments:
  2629. Entry - Supplies a pointer to the path entry that is to be unlinked from
  2630. the path hierarchy.
  2631. Return Value:
  2632. None.
  2633. --*/
  2634. KSTATUS
  2635. IopGetPathFromRoot (
  2636. PPATH_POINT Entry,
  2637. PPATH_POINT Root,
  2638. PSTR *Path,
  2639. PULONG PathSize
  2640. );
  2641. /*++
  2642. Routine Description:
  2643. This routine creates a string representing the path from the given root to
  2644. the given entry. If the entry is not a descendent of the given root, then
  2645. the full path is printed.
  2646. Arguments:
  2647. Entry - Supplies a pointer to the path point where to stop the string.
  2648. Root - Supplies a optional pointer to the path point to treat as root.
  2649. Path - Supplies a pointer that receives the full path string.
  2650. PathSize - Supplies a pointer that receives the size of the full path
  2651. string, in bytes.
  2652. Return Value:
  2653. Status code.
  2654. --*/
  2655. KSTATUS
  2656. IopGetPathFromRootUnlocked (
  2657. PPATH_POINT Entry,
  2658. PPATH_POINT Root,
  2659. PSTR *Path,
  2660. PULONG PathSize
  2661. );
  2662. /*++
  2663. Routine Description:
  2664. This routine creates a string representing the path from the given root to
  2665. the given entry. If the entry is not a descendent of the given root, then
  2666. the full path is printed. This routine assumes that the mount lock is held
  2667. in shared mode.
  2668. Arguments:
  2669. Entry - Supplies a pointer to the path point where to stop the string.
  2670. Root - Supplies a optional pointer to the path point to treat as root.
  2671. Path - Supplies a pointer that receives the full path string.
  2672. PathSize - Supplies a pointer that receives the size of the full path
  2673. string, in bytes.
  2674. Return Value:
  2675. Status code.
  2676. --*/
  2677. KSTATUS
  2678. IopPathLookup (
  2679. BOOL FromKernelMode,
  2680. PPATH_POINT Root,
  2681. PPATH_POINT Directory,
  2682. BOOL DirectoryLockHeld,
  2683. PSTR Name,
  2684. ULONG NameSize,
  2685. ULONG OpenFlags,
  2686. IO_OBJECT_TYPE TypeOverride,
  2687. PVOID OverrideParameter,
  2688. FILE_PERMISSIONS CreatePermissions,
  2689. PPATH_POINT Result
  2690. );
  2691. /*++
  2692. Routine Description:
  2693. This routine attempts to look up a child with the given name in a directory.
  2694. Arguments:
  2695. FromKernelMode - Supplies a boolean indicating whether this request is
  2696. originating from kernel mode (TRUE) or user mode (FALSE). Kernel mode
  2697. requests are not subjected to permission checks.
  2698. Root - Supplies a pointer to the caller's root path point.
  2699. Directory - Supplies a pointer to the path point to search.
  2700. DirectoryLockHeld - Supplies a boolean indicating whether or not the caller
  2701. had already acquired the directory's lock (exclusively).
  2702. Name - Supplies a pointer to the name string.
  2703. NameSize - Supplies a pointer to the size of the string in bytes
  2704. including an assumed null terminator.
  2705. OpenFlags - Supplies a bitfield of flags governing the behavior of the
  2706. handle. See OPEN_FLAG_* definitions.
  2707. TypeOverride - Supplies the type of object to create. If this is invalid,
  2708. then this routine will try to open an existing object. If this type is
  2709. valid, then this routine will attempt to create an object of the given
  2710. type.
  2711. OverrideParameter - Supplies an optional parameter to send along with the
  2712. override type.
  2713. CreatePermissions - Supplies the permissions to assign to a created file.
  2714. Result - Supplies a pointer to a path point that receives the resulting
  2715. path entry and mount point on success. The path entry and mount point
  2716. will come with an extra reference on them, so the caller must be sure
  2717. to release the references when finished. This routine may return a
  2718. path entry even on failing status codes, such as a negative path entry.
  2719. Return Value:
  2720. Status code.
  2721. --*/
  2722. KSTATUS
  2723. IopPathLookupUnlocked (
  2724. PPATH_POINT Root,
  2725. PPATH_POINT Directory,
  2726. BOOL DirectoryLockHeld,
  2727. PSTR Name,
  2728. ULONG NameSize,
  2729. ULONG OpenFlags,
  2730. IO_OBJECT_TYPE TypeOverride,
  2731. PVOID OverrideParameter,
  2732. FILE_PERMISSIONS CreatePermissions,
  2733. PPATH_POINT Result
  2734. );
  2735. /*++
  2736. Routine Description:
  2737. This routine attempts to look up a child with the given name in a directory
  2738. without acquiring the mount lock in shared mode.
  2739. Arguments:
  2740. Root - Supplies a pointer to the caller's root path point.
  2741. Directory - Supplies a pointer to the path point to search.
  2742. DirectoryLockHeld - Supplies a boolean indicating whether or not the caller
  2743. had already acquired the directory's lock (exclusively).
  2744. Name - Supplies a pointer to the name string.
  2745. NameSize - Supplies a pointer to the size of the string in bytes
  2746. including an assumed null terminator.
  2747. OpenFlags - Supplies a bitfield of flags governing the behavior of the
  2748. handle. See OPEN_FLAG_* definitions.
  2749. TypeOverride - Supplies the type of object to create. If this is invalid,
  2750. then this routine will try to open an existing object. If this type is
  2751. valid, then this routine will attempt to create an object of the given
  2752. type.
  2753. OverrideParameter - Supplies an optional parameter to send along with the
  2754. override type.
  2755. CreatePermissions - Supplies the permissions to assign to a created file.
  2756. Result - Supplies a pointer to a path point that receives the resulting
  2757. path entry and mount point on success. The path entry and mount point
  2758. will come with an extra reference on them, so the caller must be sure
  2759. to release this references when finished. This routine may return a
  2760. path entry even on failing status codes, such as a negative path entry.
  2761. Return Value:
  2762. Status code.
  2763. --*/
  2764. VOID
  2765. IopPathCleanCache (
  2766. PPATH_ENTRY RootPath
  2767. );
  2768. /*++
  2769. Routine Description:
  2770. This routine attempts to destroy any cached path entries below the given
  2771. root path.
  2772. Arguments:
  2773. RootPath - Supplies a pointer to the root path entry.
  2774. DoNotCache - Supplies a boolean indicating whether or not to mark open
  2775. path entries as non-cacheable or not.
  2776. Return Value:
  2777. None.
  2778. --*/
  2779. VOID
  2780. IopPathEntryIncrementMountCount (
  2781. PPATH_ENTRY PathEntry
  2782. );
  2783. /*++
  2784. Routine Description:
  2785. This routine increments the mount count for the given path entry.
  2786. Arguments:
  2787. PathEntry - Supplies a pointer to a path entry.
  2788. Return Value:
  2789. None.
  2790. --*/
  2791. VOID
  2792. IopPathEntryDecrementMountCount (
  2793. PPATH_ENTRY PathEntry
  2794. );
  2795. /*++
  2796. Routine Description:
  2797. This routine decrements the mount count for the given path entry.
  2798. Arguments:
  2799. PathEntry - Supplies a pointer to a path entry.
  2800. Return Value:
  2801. None.
  2802. --*/
  2803. VOID
  2804. IopGetParentPathPoint (
  2805. PPATH_POINT Root,
  2806. PPATH_POINT PathPoint,
  2807. PPATH_POINT ParentPathPoint
  2808. );
  2809. /*++
  2810. Routine Description:
  2811. This routine gets the parent path point of the given path point, correctly
  2812. traversing mount points. This routine takes references on the parent path
  2813. point's path entry and mount point.
  2814. Arguments:
  2815. Root - Supplies an optional pointer to the caller's path point root. If
  2816. supplied, then the parent will never be lower in the path tree than
  2817. the root.
  2818. PathPoint - Supplies a pointer to the path point whose parent is being
  2819. queried.
  2820. ParentPathPoint - Supplies a pointer to a path point that receives the
  2821. parent path point's information.
  2822. Return Value:
  2823. None.
  2824. --*/
  2825. KSTATUS
  2826. IopCheckPermissions (
  2827. BOOL FromKernelMode,
  2828. PPATH_POINT PathPoint,
  2829. ULONG Access
  2830. );
  2831. /*++
  2832. Routine Description:
  2833. This routine performs a permission check for the current user at the given
  2834. path point.
  2835. Arguments:
  2836. FromKernelMode - Supplies a boolean indicating whether the request actually
  2837. originates from kernel mode or not.
  2838. PathPoint - Supplies a pointer to the path point to check.
  2839. Access - Supplies the desired access the user needs.
  2840. Return Value:
  2841. STATUS_SUCCESS if the user has permission to access the given object in
  2842. the requested way.
  2843. STATUS_ACCESS_DENIED if the permission was not granted.
  2844. --*/
  2845. KSTATUS
  2846. IopCheckDeletePermission (
  2847. BOOL FromKernelMode,
  2848. PPATH_POINT DirectoryPathPoint,
  2849. PPATH_POINT FilePathPoint
  2850. );
  2851. /*++
  2852. Routine Description:
  2853. This routine performs a permission check for the current user at the given
  2854. path point, in preparation for removing a directory entry during a rename
  2855. or unlink operation.
  2856. Arguments:
  2857. FromKernelMode - Supplies a boolean indicating whether or not this
  2858. request actually originated from kernel mode.
  2859. DirectoryPathPoint - Supplies a pointer to the directory path point the
  2860. file resides in.
  2861. FilePathPoint - Supplies a pointer to the file path point being deleted or
  2862. renamed.
  2863. Return Value:
  2864. STATUS_SUCCESS if the user has permission to access the given object in
  2865. the requested way.
  2866. STATUS_ACCESS_DENIED if the permission was not granted.
  2867. --*/
  2868. KSTATUS
  2869. IopSendStateChangeIrp (
  2870. PDEVICE Device,
  2871. IRP_MINOR_CODE MinorCode,
  2872. PVOID IrpBody,
  2873. UINTN IrpBodySize
  2874. );
  2875. /*++
  2876. Routine Description:
  2877. This routine sends a state change IRP.
  2878. Arguments:
  2879. Device - Supplies a pointer to the device to send the IRP to.
  2880. MinorCode - Supplies the IRP minor code.
  2881. IrpBody - Supplies a pointer to a buffer that will be copied into the IRP
  2882. data union on input. On output, this buffer will receive the altered
  2883. data.
  2884. IrpBodySize - Supplies the size of the IRP body in bytes.
  2885. Return Value:
  2886. Status code.
  2887. --*/
  2888. KSTATUS
  2889. IopSendOpenIrp (
  2890. PDEVICE Device,
  2891. PIRP_OPEN OpenRequest
  2892. );
  2893. /*++
  2894. Routine Description:
  2895. This routine sends an open IRP.
  2896. Arguments:
  2897. Device - Supplies a pointer to the device to send the IRP to.
  2898. OpenRequest - Supplies a pointer that on input contains the open request
  2899. parameters. The contents of the IRP will also be copied here upon
  2900. returning.
  2901. Return Value:
  2902. Status code.
  2903. --*/
  2904. KSTATUS
  2905. IopSendCloseIrp (
  2906. PDEVICE Device,
  2907. PIRP_CLOSE CloseRequest
  2908. );
  2909. /*++
  2910. Routine Description:
  2911. This routine sends a close IRP to the given device.
  2912. Arguments:
  2913. Device - Supplies a pointer to the device to send the close IRP to.
  2914. CloseRequest - Supplies a pointer to the IRP close context.
  2915. Return Value:
  2916. Status code.
  2917. --*/
  2918. KSTATUS
  2919. IopSendIoIrp (
  2920. PDEVICE Device,
  2921. IRP_MINOR_CODE MinorCodeNumber,
  2922. PIRP_READ_WRITE Request
  2923. );
  2924. /*++
  2925. Routine Description:
  2926. This routine sends an I/O IRP.
  2927. Arguments:
  2928. Device - Supplies a pointer to the device to send the IRP to.
  2929. MinorCodeNumber - Supplies the minor code number to send to the IRP.
  2930. Request - Supplies a pointer that on input contains the I/O request
  2931. parameters.
  2932. Return Value:
  2933. Status code.
  2934. --*/
  2935. KSTATUS
  2936. IopSendIoReadIrp (
  2937. PDEVICE Device,
  2938. PIRP_READ_WRITE Request
  2939. );
  2940. /*++
  2941. Routine Description:
  2942. This routine sends an I/O read IRP to the given device. It makes sure that
  2943. the bytes completed that are returned do not extend beyond the file size.
  2944. Here the file size is that which is currently on the device and not in the
  2945. system's cached view of the world.
  2946. Arguments:
  2947. Device - Supplies a pointer to the device to send the IRP to.
  2948. Request - Supplies a pointer that on input contains the I/O request
  2949. parameters.
  2950. Return Value:
  2951. Status code.
  2952. --*/
  2953. KSTATUS
  2954. IopSendSystemControlIrp (
  2955. PDEVICE Device,
  2956. IRP_MINOR_CODE ControlNumber,
  2957. PVOID SystemContext
  2958. );
  2959. /*++
  2960. Routine Description:
  2961. This routine sends a system control request to the given device. This
  2962. routine must be called at low level.
  2963. Arguments:
  2964. Device - Supplies a pointer to the device to send the system control
  2965. request to.
  2966. ControlNumber - Supplies the system control number to send.
  2967. SystemContext - Supplies a pointer to the request details, which are
  2968. dependent on the control number.
  2969. Return Value:
  2970. Status code.
  2971. --*/
  2972. KSTATUS
  2973. IopSendUserControlIrp (
  2974. PDEVICE Device,
  2975. ULONG MinorCode,
  2976. BOOL FromKernelMode,
  2977. PVOID UserContext,
  2978. UINTN UserContextSize
  2979. );
  2980. /*++
  2981. Routine Description:
  2982. This routine sends a user control request to the given device. This
  2983. routine must be called at low level.
  2984. Arguments:
  2985. Device - Supplies a pointer to the device to send the user control
  2986. request to.
  2987. MinorCode - Supplies the minor code of the request.
  2988. FromKernelMode - Supplies a boolean indicating whether or not this request
  2989. (and the buffer associated with it) originates from user mode (FALSE)
  2990. or kernel mode (TRUE).
  2991. UserContext - Supplies a pointer to the context buffer allocated by the
  2992. caller for the request.
  2993. UserContextSize - Supplies the size of the supplied context buffer.
  2994. Return Value:
  2995. Status code.
  2996. --*/
  2997. KSTATUS
  2998. IopQueueResourceAssignment (
  2999. PDEVICE Device
  3000. );
  3001. /*++
  3002. Routine Description:
  3003. This routine puts this device in the resource assignment queue.
  3004. Arguments:
  3005. Device - Supplies a pointer to the device to queue for resource assignment.
  3006. Return Value:
  3007. Status code indicating whether or not the device was successfully queued.
  3008. (Not that it successfully made it through the queue or was processed in
  3009. any way).
  3010. --*/
  3011. KSTATUS
  3012. IopQueueDelayedResourceAssignment (
  3013. VOID
  3014. );
  3015. /*++
  3016. Routine Description:
  3017. This routine queues resource assignment for devices that were delayed to
  3018. allow devices with boot resources to go first.
  3019. Arguments:
  3020. None.
  3021. Return Value:
  3022. Status code.
  3023. --*/
  3024. KSTATUS
  3025. IopProcessResourceRequirements (
  3026. PDEVICE Device
  3027. );
  3028. /*++
  3029. Routine Description:
  3030. This routine attempts to find the best set of resources for a given device.
  3031. Arguments:
  3032. Device - Supplies a pointer to the device that will be receiving the
  3033. resource allocation.
  3034. Return Value:
  3035. Status code.
  3036. --*/
  3037. KSTATUS
  3038. IopArchInitializeKnownArbiterRegions (
  3039. VOID
  3040. );
  3041. /*++
  3042. Routine Description:
  3043. This routine performs any architecture-specific initialization of the
  3044. resource arbiters.
  3045. Arguments:
  3046. None.
  3047. Return Value:
  3048. Status code.
  3049. --*/
  3050. VOID
  3051. IopDestroyArbiterList (
  3052. PDEVICE Device
  3053. );
  3054. /*++
  3055. Routine Description:
  3056. This routine destroys the arbiter list of the given device.
  3057. Arguments:
  3058. Device - Supplies a pointer to a device whose arbiter list is to be
  3059. destroyed.
  3060. Return Value:
  3061. None.
  3062. --*/
  3063. BOOL
  3064. IopIsTestHookSet (
  3065. ULONG TestHookMask
  3066. );
  3067. /*++
  3068. Routine Description:
  3069. This routine checks to see if the given test hook field is currently set in
  3070. the test hook bitmask.
  3071. Arguments:
  3072. TestHookMask - Supplies the test hook field this routine will check the
  3073. test hook bitmask against.
  3074. Return Value:
  3075. Returns TRUE if the test hook is set, or FALSE otherwise.
  3076. --*/
  3077. KSTATUS
  3078. IopGetFileLock (
  3079. PIO_HANDLE IoHandle,
  3080. PFILE_LOCK Lock
  3081. );
  3082. /*++
  3083. Routine Description:
  3084. This routine gets information about a file lock. Existing locks are not
  3085. reported if they are compatible with making a new lock in the given region.
  3086. So set the lock type to write if both read and write locks should be
  3087. reported.
  3088. Arguments:
  3089. IoHandle - Supplies a pointer to the open I/O handle.
  3090. Lock - Supplies a pointer to the lock information.
  3091. Return Value:
  3092. Status code.
  3093. --*/
  3094. KSTATUS
  3095. IopSetFileLock (
  3096. PIO_HANDLE IoHandle,
  3097. PFILE_LOCK Lock,
  3098. BOOL Blocking
  3099. );
  3100. /*++
  3101. Routine Description:
  3102. This routine locks or unlocks a portion of a file. If the process already
  3103. has a lock on any part of the region, the old lock is replaced with this
  3104. new region. Remove a lock by specifying a lock type of unlock.
  3105. Arguments:
  3106. IoHandle - Supplies a pointer to the open I/O handle.
  3107. Lock - Supplies a pointer to the lock information.
  3108. Blocking - Supplies a boolean indicating if this should block until a
  3109. determination is made.
  3110. Return Value:
  3111. Status code.
  3112. --*/
  3113. VOID
  3114. IopRemoveFileLocks (
  3115. PIO_HANDLE IoHandle,
  3116. PKPROCESS Process
  3117. );
  3118. /*++
  3119. Routine Description:
  3120. This routine destroys any locks the given process has on the file object
  3121. pointed to by the given I/O handle. This routine is called anytime any
  3122. file descriptor is closed by a process, even if other file descriptors
  3123. to the same file in the process remain open.
  3124. Arguments:
  3125. IoHandle - Supplies a pointer to the I/O handle being closed.
  3126. Process - Supplies the process closing the handle.
  3127. Return Value:
  3128. None.
  3129. --*/
  3130. KSTATUS
  3131. IopSynchronizeBlockDevice (
  3132. PDEVICE Device
  3133. );
  3134. /*++
  3135. Routine Description:
  3136. This routine sends a sync request to a block device to ensure all data is
  3137. written out to permanent storage.
  3138. Arguments:
  3139. Device - Supplies a pointer to the device to send the synchronize request
  3140. to.
  3141. Return Value:
  3142. Status code.
  3143. --*/