io.h 183 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005
  1. /*++
  2. Copyright (c) 2012 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. io.h
  9. Abstract:
  10. This header contains definitions for the I/O Subsystem.
  11. Author:
  12. Evan Green 16-Sep-2012
  13. --*/
  14. //
  15. // ------------------------------------------------------------------- Includes
  16. //
  17. #include <minoca/kernel/devres.h>
  18. //
  19. // --------------------------------------------------------------------- Macros
  20. //
  21. //
  22. // This macro sets a driver specific error code on a device, automatically
  23. // generating the source file and line number parameters. The first parameter
  24. // is a PDEVICE, then second parameter is a PDRIVER, the third parameter is a
  25. // KSTATUS and the fourth parameter is a driver specific error code.
  26. //
  27. #define IoSetDeviceDriverError(_Device, _Driver, _Status, _DriverError) \
  28. IoSetDeviceDriverErrorEx((_Device), \
  29. (_Status), \
  30. (_Driver), \
  31. (_DriverError), \
  32. __FILE__, \
  33. __LINE__) \
  34. //
  35. // This macro initializes a path point structure.
  36. //
  37. #define IO_INITIALIZE_PATH_POINT(_PathPoint) \
  38. (_PathPoint)->PathEntry = NULL; \
  39. (_PathPoint)->MountPoint = NULL;
  40. //
  41. // This macro determines if two path points are equal. Both the path entry and
  42. // mount point must match.
  43. //
  44. #define IO_ARE_PATH_POINTS_EQUAL(_PathPoint1, _PathPoint2) \
  45. (((_PathPoint1)->PathEntry == (_PathPoint2)->PathEntry) && \
  46. ((_PathPoint1)->MountPoint == (_PathPoint2)->MountPoint))
  47. //
  48. // This macro adds a reference to both the path entry and mount point of a path
  49. // point.
  50. //
  51. #define IO_PATH_POINT_ADD_REFERENCE(_PathPoint) \
  52. IoPathEntryAddReference((_PathPoint)->PathEntry); \
  53. IoMountPointAddReference((_PathPoint)->MountPoint);
  54. //
  55. // This macros releases a reference from both the path entry and mount point of
  56. // a path point.
  57. //
  58. #define IO_PATH_POINT_RELEASE_REFERENCE(_PathPoint) \
  59. IoPathEntryReleaseReference((_PathPoint)->PathEntry); \
  60. IoMountPointReleaseReference((_PathPoint)->MountPoint);
  61. //
  62. // This macro copies the original path point to the copy.
  63. //
  64. #define IO_COPY_PATH_POINT(_Copy, _Original) \
  65. (_Copy)->PathEntry = (_Original)->PathEntry; \
  66. (_Copy)->MountPoint = (_Original)->MountPoint;
  67. //
  68. // ---------------------------------------------------------------- Definitions
  69. //
  70. #define DEVICE_STATE_HISTORY 10
  71. //
  72. // Define the current version number of the driver function table.
  73. //
  74. #define DRIVER_FUNCTION_TABLE_VERSION 1
  75. //
  76. // Define the name of the local terminal.
  77. //
  78. #define LOCAL_TERMINAL_PATH "/Terminal/Slave0"
  79. //
  80. // Define standard device class IDs.
  81. //
  82. #define DISK_CLASS_ID "Disk"
  83. #define PARTITION_CLASS_ID "Partition"
  84. #define CHARACTER_CLASS_ID "Character"
  85. //
  86. // Define maximum string lengths for drivers and device IDs. Strings will be
  87. // truncated at these lengths.
  88. //
  89. #define MAX_DRIVER_NAME 256
  90. #define MAX_DEVICE_ID 1024
  91. //
  92. // Define the maximum number of symbolic links that can be encountered
  93. // recursively during path resolution.
  94. //
  95. #define MAX_SYMBOLIC_LINK_RECURSION 32
  96. //
  97. // Define the delimiter character for the compatible ID string.
  98. //
  99. #define COMPATIBLE_ID_DELIMITER ';'
  100. #define PATH_SEPARATOR '/'
  101. //
  102. // Define the current version of the IO_CONNECT_INTERRUPT_PARAMETERS structure.
  103. //
  104. #define IO_CONNECT_INTERRUPT_PARAMETERS_VERSION 1
  105. //
  106. // Set this bit to grant execute permissions to the given I/O handle.
  107. //
  108. #define IO_ACCESS_EXECUTE 0x00000001
  109. //
  110. // Set this bit to grant write permissions to the given I/O handle.
  111. //
  112. #define IO_ACCESS_WRITE 0x00000002
  113. //
  114. // Set this bit to grant read permissions to the given I/O handle.
  115. //
  116. #define IO_ACCESS_READ 0x00000004
  117. #define IO_ACCESS_MASK \
  118. (IO_ACCESS_EXECUTE | IO_ACCESS_WRITE | IO_ACCESS_READ)
  119. //
  120. // Set this flag if the file (or object) should be created if it does not exist.
  121. //
  122. #define OPEN_FLAG_CREATE 0x00000001
  123. //
  124. // Set this flag if the file should be truncated to zero size.
  125. //
  126. #define OPEN_FLAG_TRUNCATE 0x00000002
  127. //
  128. // Set this flag to only create the file, failing if it already exists.
  129. //
  130. #define OPEN_FLAG_FAIL_IF_EXISTS 0x00000004
  131. //
  132. // Set this flag to have every write to the file append to the end of it.
  133. //
  134. #define OPEN_FLAG_APPEND 0x00000008
  135. //
  136. // Set this flag if attempting to open a directory.
  137. //
  138. #define OPEN_FLAG_DIRECTORY 0x00000010
  139. //
  140. // Set this flag to make any I/O return immediately if the call would have
  141. // otherwise blocked.
  142. //
  143. #define OPEN_FLAG_NON_BLOCKING 0x00000020
  144. //
  145. // Set this flag if attempting to open a shared memory object.
  146. //
  147. #define OPEN_FLAG_SHARED_MEMORY 0x00000040
  148. //
  149. // Set this flag to fail if the final component of the path to open is a
  150. // symbolic link.
  151. //
  152. #define OPEN_FLAG_NO_SYMBOLIC_LINK 0x00000080
  153. //
  154. // Set this flag to cause calls to write not to return until the data has been
  155. // written to the underlying medium.
  156. //
  157. #define OPEN_FLAG_SYNCHRONIZED 0x00000100
  158. //
  159. // Set this flag when opening a terminal to prevent it from becoming the
  160. // controlling terminal of the process.
  161. //
  162. #define OPEN_FLAG_NO_CONTROLLING_TERMINAL 0x00000200
  163. //
  164. // Set this flag to avoid updating the last access time of the file when it is
  165. // read.
  166. //
  167. #define OPEN_FLAG_NO_ACCESS_TIME 0x00000400
  168. //
  169. // Set this flag to receive signals whenever the descriptor is ready for read
  170. // or write. This does not take effect immediately, as the signal owner still
  171. // needs to be set.
  172. //
  173. #define OPEN_FLAG_ASYNCHRONOUS 0x00000800
  174. //
  175. // Set this flag if mount points should not be followed on the final component.
  176. //
  177. #define OPEN_FLAG_NO_MOUNT_POINT 0x08000000
  178. //
  179. // Set this flag if trying to open a symbolic link itself.
  180. //
  181. #define OPEN_FLAG_SYMBOLIC_LINK 0x10000000
  182. //
  183. // This flag is reserved for use only by the I/O manager. It indicates that the
  184. // given file or device will bypass the page cache for all I/O operations.
  185. //
  186. #define OPEN_FLAG_NO_PAGE_CACHE 0x20000000
  187. //
  188. // This flag is reserved for use only by the I/O manager. It indicates that the
  189. // given device will be used as a paging device.
  190. //
  191. #define OPEN_FLAG_PAGING_DEVICE 0x40000000
  192. //
  193. // This flag is reserved for use only by the memory manager. System crashes
  194. // will result if any other entities set this flag. It indicates that the given
  195. // file will be used as a page file.
  196. //
  197. #define OPEN_FLAG_PAGE_FILE 0x80000000
  198. //
  199. // Set this flag if attempting to delete a shared memory object.
  200. //
  201. #define DELETE_FLAG_SHARED_MEMORY 0x00000001
  202. //
  203. // Set this flag if attempting to delete a directory.
  204. //
  205. #define DELETE_FLAG_DIRECTORY 0x00000002
  206. //
  207. // This flag is reserved for use only by the memory manager. It indicates that
  208. // the I/O operation is to be performed in a no-allocate code path.
  209. //
  210. #define IO_FLAG_NO_ALLOCATE 0x80000000
  211. //
  212. // This flag is reserved for use only by the memory manager. It indicates that
  213. // the I/O operation was initiated to satisfy a page fault. Device drivers
  214. // need not perform any different behavior here, this is only used for updating
  215. // internal accounting numbers.
  216. //
  217. #define IO_FLAG_SERVICING_FAULT 0x40000000
  218. //
  219. // This flag is reserved for use by the page cache. It indicates that a write
  220. // I/O operation should preserve the data because the page cache is about to
  221. // release its copy of the data. The backing device may have previously been
  222. // acknowledging writes without actually writing to persistant storage.
  223. //
  224. #define IO_FLAG_HARD_FLUSH 0x20000000
  225. //
  226. // This flag is reserved for use by the page cache thread. It indicates that
  227. // hard flushes are allowed. Normal threads cannot perform hard flushes because
  228. // a hard flush may fail (e.g. there is no page file to back a shared memory
  229. // object). This failure should not be reported back to user mode, as it is
  230. // non-fatal.
  231. //
  232. #define IO_FLAG_HARD_FLUSH_ALLOWED 0x10000000
  233. //
  234. // This flag indicates that a write I/O operation should flush all the file
  235. // data provided before returning.
  236. //
  237. #define IO_FLAG_DATA_SYNCHRONIZED 0x00000002
  238. //
  239. // This flag, along with the data synchronized flag, indicates that the
  240. // file data and metadata should be flushed. It is illegal to set this flag
  241. // without also setting the data synchronized flag.
  242. //
  243. #define IO_FLAG_METADATA_SYNCHRONIZED 0x00000004
  244. //
  245. // This flag indicates that this request represents the file system fetching
  246. // data or metadata to service a request. It allows the physical memory to be
  247. // shared with the file layer request.
  248. //
  249. #define IO_FLAG_FS_DATA 0x00000008
  250. //
  251. // This flag indicates that this request represents the file system fetching
  252. // metadata to service a request. the FS data flag must also be set.
  253. //
  254. #define IO_FLAG_FS_METADATA 0x00000010
  255. //
  256. // Set this flag if the IRP needs to execute in a no-allocate code path. As a
  257. // result none of the data or code it touches can be pagable.
  258. //
  259. #define IRP_CREATE_FLAG_NO_ALLOCATE 0x00000001
  260. //
  261. // Set this flag if the flush operation should flush all data.
  262. //
  263. #define FLUSH_FLAG_ALL 0x00000001
  264. //
  265. // Set this flag if the flush operation should flush unread data. This only
  266. // applies to some file object types, like terminals.
  267. //
  268. #define FLUSH_FLAG_READ 0x00000002
  269. //
  270. // Set this flag if the flush operation should flush unwritten data. This only
  271. // applies to some file object types, like terminals.
  272. //
  273. #define FLUSH_FLAG_WRITE 0x00000004
  274. //
  275. // Set this flag to discard unflushed data instead of waiting for it to be
  276. // written. This only applies to some file object types, like terminals.
  277. //
  278. #define FLUSH_FLAG_DISCARD 0x00000008
  279. //
  280. // Set this flag if the flush operation should flush all cacheable data in the
  281. // entire system and not return until the data is written to disk.
  282. //
  283. #define FLUSH_FLAG_ALL_SYNCHRONOUS 0x80000000
  284. //
  285. // Define the mount flags.
  286. //
  287. #define MOUNT_FLAG_BIND 0x00000001
  288. #define MOUNT_FLAG_RECURSIVE 0x00000002
  289. #define MOUNT_FLAG_DETACH 0x00000004
  290. #define MOUNT_FLAG_LINKED 0x00000008
  291. //
  292. // Define file permission bits.
  293. //
  294. #define FILE_PERMISSION_OTHER_EXECUTE 0x00000001
  295. #define FILE_PERMISSION_OTHER_WRITE 0x00000002
  296. #define FILE_PERMISSION_OTHER_READ 0x00000004
  297. #define FILE_PERMISSION_OTHER_ALL \
  298. (FILE_PERMISSION_OTHER_EXECUTE | \
  299. FILE_PERMISSION_OTHER_WRITE | \
  300. FILE_PERMISSION_OTHER_READ)
  301. #define FILE_PERMISSION_GROUP_EXECUTE 0x00000008
  302. #define FILE_PERMISSION_GROUP_WRITE 0x00000010
  303. #define FILE_PERMISSION_GROUP_READ 0x00000020
  304. #define FILE_PERMISSION_GROUP_ALL \
  305. (FILE_PERMISSION_GROUP_EXECUTE | \
  306. FILE_PERMISSION_GROUP_WRITE | \
  307. FILE_PERMISSION_GROUP_READ)
  308. #define FILE_PERMISSION_USER_EXECUTE 0x00000040
  309. #define FILE_PERMISSION_USER_WRITE 0x00000080
  310. #define FILE_PERMISSION_USER_READ 0x00000100
  311. #define FILE_PERMISSION_USER_ALL \
  312. (FILE_PERMISSION_USER_EXECUTE | \
  313. FILE_PERMISSION_USER_WRITE | \
  314. FILE_PERMISSION_USER_READ)
  315. #define FILE_PERMISSION_ALL_EXECUTE \
  316. (FILE_PERMISSION_USER_EXECUTE | \
  317. FILE_PERMISSION_GROUP_EXECUTE | \
  318. FILE_PERMISSION_OTHER_EXECUTE)
  319. #define FILE_PERMISSION_ALL \
  320. (FILE_PERMISSION_OTHER_ALL | \
  321. FILE_PERMISSION_GROUP_ALL | \
  322. FILE_PERMISSION_USER_ALL)
  323. #define FILE_PERMISSION_NONE 0
  324. #define FILE_PERMISSION_RESTRICTED 0x00000200
  325. #define FILE_PERMISSION_SET_GROUP_ID 0x00000400
  326. #define FILE_PERMISSION_SET_USER_ID 0x00000800
  327. #define FILE_PERMISSION_MASK 0x00000FFF
  328. #define FILE_PERMISSION_ACCESS_MASK 0x00000007
  329. #define FILE_PERMISSION_OTHER_SHIFT 0
  330. #define FILE_PERMISSION_GROUP_SHIFT 3
  331. #define FILE_PERMISSION_USER_SHIFT 6
  332. //
  333. // Define file property fields that can be set.
  334. //
  335. #define FILE_PROPERTY_FIELD_USER_ID 0x00000001
  336. #define FILE_PROPERTY_FIELD_GROUP_ID 0x00000002
  337. #define FILE_PROPERTY_FIELD_PERMISSIONS 0x00000004
  338. #define FILE_PROPERTY_FIELD_ACCESS_TIME 0x00000008
  339. #define FILE_PROPERTY_FIELD_MODIFIED_TIME 0x00000010
  340. #define FILE_PROPERTY_FIELD_STATUS_CHANGE_TIME 0x00000020
  341. #define FILE_PROPERTY_FIELD_FILE_SIZE 0x00000040
  342. //
  343. // Define the set of properties that only the file owner or a privileged
  344. // user can change.
  345. //
  346. #define FILE_PROPERTY_OWNER_OWNED_FIELDS \
  347. (FILE_PROPERTY_FIELD_PERMISSIONS | \
  348. FILE_PROPERTY_FIELD_ACCESS_TIME | \
  349. FILE_PROPERTY_FIELD_MODIFIED_TIME | \
  350. FILE_PROPERTY_FIELD_STATUS_CHANGE_TIME)
  351. //
  352. // Define file descriptor flags.
  353. //
  354. #define FILE_DESCRIPTOR_CLOSE_ON_EXECUTE 0x00000001
  355. //
  356. // Define input control flags.
  357. //
  358. //
  359. // Set this flag to ignore break conditions.
  360. //
  361. #define TERMINAL_INPUT_IGNORE_BREAK 0x00000001
  362. //
  363. // Set this flag to signal an interrupt on break.
  364. //
  365. #define TERMINAL_INPUT_SIGNAL_ON_BREAK 0x00000002
  366. //
  367. // Set this flag to ignore characters with parity errors.
  368. //
  369. #define TERMINAL_INPUT_IGNORE_PARITY_ERRORS 0x0000004
  370. //
  371. // Set this flag to mark parity errors.
  372. //
  373. #define TERMINAL_INPUT_MARK_PARITY_ERRORS 0x00000008
  374. //
  375. // Set this flag to enable input parity checking.
  376. //
  377. #define TERMINAL_INPUT_ENABLE_PARITY_CHECK 0x00000010
  378. //
  379. // Set this flag to strip characters.
  380. //
  381. #define TERMINAL_INPUT_STRIP 0x00000020
  382. //
  383. // Set this flag to map newlines (\n) to carriage returns (\r) on input.
  384. //
  385. #define TERMINAL_INPUT_NEWLINE_TO_CR 0x00000040
  386. //
  387. // Set this flag to ignore carriage returns.
  388. //
  389. #define TERMINAL_INPUT_IGNORE_CR 0x00000080
  390. //
  391. // Set this flag to map carriage return (\r) characters to newlines (\n) on
  392. // input.
  393. //
  394. #define TERMINAL_INPUT_CR_TO_NEWLINE 0x00000100
  395. //
  396. // Set this flag to enable start/stop output control.
  397. //
  398. #define TERMINAL_INPUT_ENABLE_OUTPUT_FLOW_CONTROL 0x00000200
  399. //
  400. // Set this flag to enable start/stop input control.
  401. //
  402. #define TERMINAL_INPUT_ENABLE_INPUT_FLOW_CONTROL 0x00000400
  403. //
  404. // Set this flag to enable any character to restart output.
  405. //
  406. #define TERMINAL_INPUT_ANY_CHARACTER_RESTARTS_OUTPUT 0x00000800
  407. //
  408. // Set this flag to cause a bell character to be sent to the output if the
  409. // input buffer is full. If this flag is not set and a new character is
  410. // received when the input queue is full, then the entire current input and
  411. // output queue is discarded.
  412. //
  413. #define TERMINAL_INPUT_MAX_BELL 0x00001000
  414. //
  415. // Define terminal output control flags.
  416. //
  417. //
  418. // Set this flag to post-process output.
  419. //
  420. #define TERMINAL_OUTPUT_POST_PROCESS 0x00000001
  421. //
  422. // Set this flag to map newlines (\n) or CR-NL (\r\n) on output.
  423. //
  424. #define TERMINAL_OUTPUT_NEWLINE_TO_CRLF 0x00000002
  425. //
  426. // Set this flag to map carriage returns (\r) to newlines (\n) on output.
  427. //
  428. #define TERMINAL_OUTPUT_CR_TO_NEWLINE 0x00000004
  429. //
  430. // Set this flag to avoid carriage return output at column 0.
  431. //
  432. #define TERMINAL_OUTPUT_NO_CR_AT_COLUMN_ZERO 0x00000008
  433. //
  434. // Set this flag to have newline perform carriage return functionality.
  435. //
  436. #define TERMINAL_OUTPUT_NEWLINE_IS_CR 0x00000010
  437. //
  438. // Set this flag to use fill characters for delay.
  439. //
  440. #define TERMINAL_OUTPUT_USE_FILL_CHARACTERS 0x00000020
  441. //
  442. // Set this flag to enable newline delays, which lasts 0.1 seconds.
  443. //
  444. #define TERMINAL_OUTPUT_NEWLINE_DELAY 0x00000040
  445. //
  446. // Set this flag to select carriage return delays, types 0 through 3.
  447. // Type 1 delays for an amount dependent on column position. Type 2 is about
  448. // 0.1 seconds, and type 3 is about 0.15 seconds. If OFILL is set, type 1
  449. // transmits two fill characters and type 2 transmits four fill characters.
  450. //
  451. #define TERMINAL_OUTPUT_CR_DELAY_MASK 0x00000180
  452. #define TERMINAL_OUTPUT_CR_DELAY_1 0x00000080
  453. #define TERMINAL_OUTPUT_CR_DELAY_2 0x00000100
  454. #define TERMINAL_OUTPUT_CR_DELAY_3 0x00000180
  455. //
  456. // Set this flag to enable tab delays, types 0 through 3.
  457. // Type 1 is dependent on column positions, type 2 is 0.1 seconds, and type 3
  458. // is "expand tabs to spaces". If OFILL is set, any delay transmits two fill
  459. // characters.
  460. //
  461. #define TERMINAL_OUTPUT_TAB_DELAY_MASK 0x00000600
  462. #define TERMINAL_OUTPUT_TAB_DELAY_1 0x00000200
  463. #define TERMINAL_OUTPUT_TAB_DELAY_2 0x00000400
  464. #define TERMINAL_OUTPUT_TAB_DELAY_3 0x00000600
  465. //
  466. // Set this flag to enable backspace delays, which lasts 0.05 seconds or one
  467. // fill character.
  468. //
  469. #define TERMINAL_OUTPUT_BACKSPACE_DELAY 0x00000800
  470. //
  471. // Set this flag to enable vertical tab delays, which last two seconds.
  472. //
  473. #define TERMINAL_OUTPUT_VERTICAL_TAB_DELAY 0x00001000
  474. //
  475. // Set this flag to enable form feed delays, which last two seconds.
  476. //
  477. #define TERMINAL_OUTPUT_FORM_FEED_DELAY 0x00002000
  478. //
  479. // Set this flag to fill with DEL (127) characters. If not set, the fill
  480. // character is NUL (0).
  481. //
  482. #define TERMINAL_OUTPUT_FILL_DEL 0x00004000
  483. //
  484. // Define terminal control mode flags.
  485. //
  486. //
  487. // Set this field to set the number of bits per character.
  488. //
  489. #define TERMINAL_CONTROL_CHARACTER_SIZE_MASK 0x00000003
  490. #define TERMINAL_CONTROL_5_BITS_PER_CHARACTER 0x00000000
  491. #define TERMINAL_CONTROL_6_BITS_PER_CHARACTER 0x00000001
  492. #define TERMINAL_CONTROL_7_BITS_PER_CHARACTER 0x00000002
  493. #define TERMINAL_CONTROL_8_BITS_PER_CHARACTER 0x00000003
  494. //
  495. // Set this bit to send two stop bits (without it set one stop bit is sent).
  496. //
  497. #define TERMINAL_CONTROL_2_STOP_BITS 0x00000004
  498. //
  499. // Set this bit to enable the receiver.
  500. //
  501. #define TERMINAL_CONTROL_ENABLE_RECEIVE 0x00000008
  502. //
  503. // Set this bit to enable a parity bit.
  504. //
  505. #define TERMINAL_CONTROL_ENABLE_PARITY 0x00000010
  506. //
  507. // Set this bit to enable odd parity (without this bit set even parity is used).
  508. //
  509. #define TERMINAL_CONTROL_ODD_PARITY 0x00000020
  510. //
  511. // Set this bit to send a hangup signal when the terminal is closed.
  512. //
  513. #define TERMINAL_CONTROL_HANGUP_ON_CLOSE 0x00000040
  514. //
  515. // Set this bit to ignore modem status lines (and do not send a hangup signal).
  516. //
  517. #define TERMINAL_CONTROL_NO_HANGUP 0x00000080
  518. //
  519. // Define terminal local mode bits.
  520. //
  521. //
  522. // Set this bit to enable echo of terminal input directly to its output.
  523. //
  524. #define TERMINAL_LOCAL_ECHO 0x00000001
  525. //
  526. // Set this bit to enable echoing erase characters as BS-SP-BS. Otherwise, the
  527. // character erased is echoed to show what happened (suitable for a printer).
  528. //
  529. #define TERMINAL_LOCAL_ECHO_ERASE 0x00000002
  530. //
  531. // Set this bit to enable echoing the kill character and moving to a new line.
  532. // If this bit is not set, the kill character is simply echoed, which produces
  533. // no output, so the user must remember the line data is killed.
  534. //
  535. #define TERMINAL_LOCAL_ECHO_KILL_NEWLINE 0x00000004
  536. //
  537. // Set this bit to enable echoing the newline character.
  538. //
  539. #define TERMINAL_LOCAL_ECHO_NEWLINE 0x00000008
  540. //
  541. // Set this bit to enable canonical input (erase and kill processing).
  542. //
  543. #define TERMINAL_LOCAL_CANONICAL 0x00000010
  544. //
  545. // Set this bit to enable extended processing. With extended processing,
  546. // the erase, kill, and end of file characters can be preceded by a backslash
  547. // to remove their special meaning.
  548. //
  549. #define TERMINAL_LOCAL_EXTENDED 0x00000020
  550. //
  551. // Set this bit to enable signals to be generated to the controlling process
  552. // group when signal characters are seen at the input.
  553. //
  554. #define TERMINAL_LOCAL_SIGNALS 0x00000040
  555. //
  556. // Set this bit to disable flushing after an interrupt or quit.
  557. //
  558. #define TERMINAL_LOCAL_NO_FLUSH 0x00000080
  559. //
  560. // Set this bit to send a SIGTTOU signal when processes in the background try
  561. // to write to the terminal.
  562. //
  563. #define TERMINAL_LOCAL_STOP_BACKGROUND_WRITES 0x00000100
  564. //
  565. // Set this bit to enable visually erasing the current line when the kill
  566. // character comes in. If this bit is not set, the "echo kill" flag dictates
  567. // what is echoed when a kill character comes in.
  568. //
  569. #define TERMINAL_LOCAL_ECHO_KILL_EXTENDED 0x00000200
  570. //
  571. // Set this bit to enable echoing control characters as '^' followed by their
  572. // text equivalent.
  573. //
  574. #define TERMINAL_LOCAL_ECHO_CONTROL 0x00000400
  575. //
  576. // Define the flags for each field that are currnetly unimplemented.
  577. //
  578. #define TERMINAL_UNIMPLEMENTED_INPUT_FLAGS \
  579. (TERMINAL_INPUT_ENABLE_PARITY_CHECK | \
  580. TERMINAL_INPUT_MARK_PARITY_ERRORS)
  581. #define TERMINAL_UNIMPLEMENTED_OUTPUT_FLAGS \
  582. (TERMINAL_OUTPUT_NO_CR_AT_COLUMN_ZERO | \
  583. TERMINAL_OUTPUT_USE_FILL_CHARACTERS | \
  584. TERMINAL_OUTPUT_VERTICAL_TAB_DELAY | \
  585. TERMINAL_OUTPUT_FORM_FEED_DELAY)
  586. #define TERMINAL_UNIMPLEMENTED_CONTROL_FLAGS \
  587. (TERMINAL_CONTROL_2_STOP_BITS | \
  588. TERMINAL_CONTROL_ENABLE_PARITY)
  589. //
  590. // Define the number of control characters in the old terminal settings
  591. // (termio).
  592. //
  593. #define TERMINAL_SETTINGS_OLD_CONTROL_COUNT 8
  594. //
  595. // Define the default create permissions for a terminal device.
  596. //
  597. #define TERMINAL_DEFAULT_PERMISSIONS \
  598. (FILE_PERMISSION_USER_READ | FILE_PERMISSION_USER_WRITE | \
  599. FILE_PERMISSION_GROUP_READ | FILE_PERMISSION_GROUP_WRITE)
  600. //
  601. // Define the default atomic write size for pipes.
  602. //
  603. #define PIPE_ATOMIC_WRITE_SIZE 4096
  604. //
  605. // Define I/O test hook bits.
  606. //
  607. //
  608. // Set this bit to fail one attempt to queue a device work item.
  609. //
  610. #define IO_FAIL_QUEUE_DEVICE_WORK 0x1
  611. //
  612. // Define the file offsets used for reporting the relative directory entries
  613. // dot and dot-dot.
  614. //
  615. #define DIRECTORY_OFFSET_DOT 0
  616. #define DIRECTORY_OFFSET_DOT_DOT 1
  617. #define DIRECTORY_CONTENTS_OFFSET 2
  618. //
  619. // Set this flag in lookup if the device's data should not be stored in the
  620. // page cache.
  621. //
  622. #define LOOKUP_FLAG_NO_PAGE_CACHE 0x00000001
  623. //
  624. // Set this flag if the file's I/O state should be allocated from non-paged
  625. // pool. This is useful if the I/O state needs to be signaled from a DPC.
  626. //
  627. #define LOOKUP_FLAG_NON_PAGED_IO_STATE 0x00000002
  628. //
  629. // Define the version number for the I/O cache statistics.
  630. //
  631. #define IO_CACHE_STATISTICS_VERSION 0x1
  632. #define IO_CACHE_STATISTICS_MAX_VERSION 0x10000000
  633. //
  634. // Define the version number for the global cache statistics.
  635. //
  636. #define IO_GLOBAL_STATISTICS_VERSION 0x1
  637. #define IO_GLOBAL_STATISTICS_MAX_VERSION 0x10000000
  638. //
  639. // Define the device ID given to the object manager.
  640. //
  641. #define OBJECT_MANAGER_DEVICE_ID 1
  642. //
  643. // Define the invalid interrupt line. This can be supplied to the interrupt
  644. // connection routine if only the vector needs connecting.
  645. //
  646. #define INVALID_INTERRUPT_LINE (-1ULL)
  647. #define INVALID_INTERRUPT_VECTOR (-1ULL)
  648. //
  649. // Define the offset to use to specify the current file offset.
  650. //
  651. #define IO_OFFSET_NONE (-1LL)
  652. //
  653. // Define the maximum I/O offset.
  654. //
  655. #define IO_OFFSET_MAX MAX_LONGLONG
  656. //
  657. // Define the set of flags used for read/write IRP preparation and completion.
  658. //
  659. #define IRP_READ_WRITE_FLAG_PHYSICALLY_CONTIGUOUS 0x00000001
  660. #define IRP_READ_WRITE_FLAG_WRITE 0x00000002
  661. #define IRP_READ_WRITE_FLAG_DMA 0x00000004
  662. #define IRP_READ_WRITE_FLAG_POLLED 0x00000008
  663. //
  664. // Define the set of flags describing an I/O request's saved I/O buffer state.
  665. //
  666. #define IRP_IO_BUFFER_STATE_FLAG_LOCKED_COPY 0x00000001
  667. //
  668. // Define the current loaded file structure version.
  669. //
  670. #define LOADED_FILE_VERSION 1
  671. //
  672. // Define shared memory properties, stored in the permissions field of the
  673. // permissions structure.
  674. //
  675. //
  676. // Set this flag if the shared memory object is unlinked and will be destroyed
  677. // when the last reference is closed. This lines up with SHM_DEST in the C
  678. // library.
  679. //
  680. #define SHARED_MEMORY_PROPERTY_UNLINKED 0x00010000
  681. //
  682. // ------------------------------------------------------ Data Type Definitions
  683. //
  684. typedef ULONG FILE_PERMISSIONS, *PFILE_PERMISSIONS;
  685. typedef ULONGLONG FILE_ID, *PFILE_ID;
  686. typedef ULONGLONG DEVICE_ID, *PDEVICE_ID;
  687. typedef struct _PATH_ENTRY PATH_ENTRY, *PPATH_ENTRY;
  688. typedef struct _MOUNT_POINT MOUNT_POINT, *PMOUNT_POINT;
  689. typedef struct _VOLUME VOLUME, *PVOLUME;
  690. typedef struct _DRIVER DRIVER, *PDRIVER;
  691. typedef struct _IRP IRP, *PIRP;
  692. typedef struct _STREAM_BUFFER STREAM_BUFFER, *PSTREAM_BUFFER;
  693. typedef struct _IO_HANDLE IO_HANDLE, *PIO_HANDLE;
  694. typedef struct _PAGE_CACHE_ENTRY PAGE_CACHE_ENTRY, *PPAGE_CACHE_ENTRY;
  695. typedef enum _SEEK_COMMAND {
  696. SeekCommandInvalid,
  697. SeekCommandNop,
  698. SeekCommandFromBeginning,
  699. SeekCommandFromCurrentOffset,
  700. SeekCommandFromEnd,
  701. } SEEK_COMMAND, *PSEEK_COMMAND;
  702. typedef enum _TERMINAL_CONTROL_CHARACTER {
  703. TerminalCharacterEndOfFile,
  704. TerminalCharacterEndOfLine,
  705. TerminalCharacterErase,
  706. TerminalCharacterInterrupt,
  707. TerminalCharacterKill,
  708. TerminalCharacterFlushCount,
  709. TerminalCharacterQuit,
  710. TerminalCharacterStart,
  711. TerminalCharacterStop,
  712. TerminalCharacterSuspend,
  713. TerminalCharacterFlushTime,
  714. TerminalCharacterCount
  715. } TERMINAL_CONTROL_CHARACTER, *PTERMINAL_CONTROL_CHARACTER;
  716. typedef enum _TERMINAL_CHANGE_BEHAVIOR {
  717. TerminalChangeNone,
  718. TerminalChangeNow,
  719. TerminalChangeAfterOutput,
  720. TerminalChangeAfterOutputFlushInput
  721. } TERMINAL_CHANGE_BEHAVIOR, *PTERMINAL_CHANGE_BEHAVIOR;
  722. //
  723. // Define terminal user control (IOCTL) codes. These must line up with what's
  724. // defined in sys/ioctl.h in the C library.
  725. //
  726. typedef enum _TERMINAL_USER_CONTROL_CODE {
  727. TerminalControlGetAttributes = 0x7401,
  728. TerminalControlSetAttributes = 0x7402,
  729. TerminalControlSetAttributesDrain = 0x7403,
  730. TerminalControlSetAttributesFlush = 0x7404,
  731. TerminalControlGetAttributesOld = 0x7405,
  732. TerminalControlSetAttributesOld = 0x7406,
  733. TerminalControlSetAttributesDrainOld = 0x7407,
  734. TerminalControlSetAttributesFlushOld = 0x7408,
  735. TerminalControlSendBreak = 0x7409,
  736. TerminalControlFlowControl = 0x740A,
  737. TerminalControlFlush = 0x740B,
  738. TerminalControlSetExclusive = 0x740C,
  739. TerminalControlClearExclusive = 0x740D,
  740. TerminalControlSetControllingTerminal = 0x740E,
  741. TerminalControlGetProcessGroup = 0x740F,
  742. TerminalControlSetProcessGroup = 0x7410,
  743. TerminalControlGetOutputQueueSize = 0x7411,
  744. TerminalControlInsertInInputQueue = 0x7412,
  745. TerminalControlGetWindowSize = 0x7413,
  746. TerminalControlSetWindowSize = 0x7414,
  747. TerminalControlGetModemStatus = 0x7415,
  748. TerminalControlOrModemStatus = 0x7416,
  749. TerminalControlClearModemStatus = 0x7417,
  750. TerminalControlSetModemStatus = 0x7418,
  751. TerminalControlGetSoftCarrier = 0x7419,
  752. TerminalControlSetSoftCarrier = 0x741A,
  753. TerminalControlGetInputQueueSize = 0x741B,
  754. TerminalControlRedirectLocalConsole = 0x741D,
  755. TerminalControlSetPacketMode = 0x7420,
  756. TerminalControlGiveUpControllingTerminal = 0x7422,
  757. TerminalControlSendBreakPosix = 0x7425,
  758. TerminalControlStartBreak = 0x7427,
  759. TerminalControlStopBreak = 0x7428,
  760. TerminalControlGetCurrentSessionId = 0x7429,
  761. } TERMINAL_USER_CONTROL_CODE, *PTERMINAL_USER_CONTROL_CODE;
  762. //
  763. // Define file I/O user control (IOCTL) codes. These must line up with what's
  764. // defined in sys/ioctl.h in the C library.
  765. //
  766. typedef enum _FILE_IO_USER_CONTROL_CODE {
  767. FileIoControlNonBlocking = 0x7421,
  768. FileIoControlAsync = 0x7452,
  769. } FILE_IO_USER_CONTROL_CODE, *PFILE_IO_USER_CONTROL_CODE;
  770. typedef enum _CRASH_DRIVER_ERROR_CODE {
  771. DriverErrorInvalid,
  772. DriverErrorRemovingEnumeratedDevice,
  773. } CRASH_DRIVER_ERROR_CODE, *PCRASH_DRIVER_ERROR_CODE;
  774. typedef enum _IO_INFORMATION_TYPE {
  775. IoInformationInvalid,
  776. IoInformationBoot,
  777. IoInformationMountPoints,
  778. IoInformationCacheStatistics,
  779. } IO_INFORMATION_TYPE, *PIO_INFORMATION_TYPE;
  780. typedef enum _SHARED_MEMORY_COMMAND {
  781. SharedMemoryCommandInvalid,
  782. SharedMemoryCommandUnlink,
  783. SharedMemoryCommandSet,
  784. SharedMemoryCommandStat
  785. } SHARED_MEMORY_COMMAND, *PSHARED_MEMORY_COMMAND;
  786. /*++
  787. Structure Description:
  788. This structure defines a terminal configuration. Note that this structure
  789. must line up offset for offset with struct termios in the C library to
  790. support terminal IOCTLs.
  791. Members:
  792. InputFlags - Stores the terminal input flags. See TERMINAL_INPUT_*
  793. definitions.
  794. OutputFlags - Stores the terminal output flags. See TERMINAL_OUTPUT_*
  795. definitions.
  796. ControlFlags - Stores the terminal control flags. See TERMINAL_CONTROL_*
  797. definitions.
  798. LocalFlags - Stores the terminal local behavior flags. See TERMINAL_LOCAL_*
  799. definitions.
  800. ControlCharacters - Stores the recognized control characters.
  801. InputSpeed - Stores the baud rate for input going to the slave.
  802. OutputSpeed - Stores the baud rate for output coming from the slave.
  803. --*/
  804. typedef struct _TERMINAL_SETTINGS {
  805. ULONG InputFlags;
  806. ULONG OutputFlags;
  807. ULONG ControlFlags;
  808. ULONG LocalFlags;
  809. UCHAR ControlCharacters[TerminalCharacterCount];
  810. ULONG InputSpeed;
  811. ULONG OutputSpeed;
  812. } TERMINAL_SETTINGS, *PTERMINAL_SETTINGS;
  813. /*++
  814. Structure Description:
  815. This structure defines the old structure for terminal settings. This lines
  816. up byte for byte with struct termio in the C library.
  817. Members:
  818. InputFlags - Stores the terminal input flags. See TERMINAL_INPUT_*
  819. definitions.
  820. OutputFlags - Stores the terminal output flags. See TERMINAL_OUTPUT_*
  821. definitions.
  822. ControlFlags - Stores the terminal control flags. See TERMINAL_CONTROL_*
  823. definitions.
  824. LocalFlags - Stores the terminal local behavior flags. See TERMINAL_LOCAL_*
  825. definitions.
  826. LineDiscipline - Stores the line discipline. Set to zero to indicate TTY
  827. line discipline.
  828. ControlCharacters - Stores the recognized control characters.
  829. --*/
  830. typedef struct _TERMINAL_SETTINGS_OLD {
  831. USHORT InputFlags;
  832. USHORT OutputFlags;
  833. USHORT ControlFlags;
  834. USHORT LocalFlags;
  835. UCHAR LineDiscipline;
  836. CHAR ControlCharacters[TERMINAL_SETTINGS_OLD_CONTROL_COUNT];
  837. } TERMINAL_SETTINGS_OLD, *PTERMINAL_SETTINGS_OLD;
  838. /*++
  839. Structure Description:
  840. This structure defines the terminal window size structure passed back and
  841. forth in the window size user control (ioctl) messages. Note that this
  842. structure must line up with struct winsize for the ioctls to function in a
  843. compliant manner.
  844. Members:
  845. Rows - Stores the number of rows in the terminal.
  846. Columns - Stores the number of columns in the terminal.
  847. PixelsX - Stores the number of pixels in the horizontal direction. This may
  848. be unused.
  849. PixelsY - Stores the number of pixels in the vertical direction. This may
  850. be unused.
  851. --*/
  852. typedef struct _TERMINAL_WINDOW_SIZE {
  853. USHORT Rows;
  854. USHORT Columns;
  855. USHORT PixelsX;
  856. USHORT PixelsY;
  857. } TERMINAL_WINDOW_SIZE, *PTERMINAL_WINDOW_SIZE;
  858. typedef
  859. VOID
  860. (*PIRP_COMPLETION_ROUTINE) (
  861. PIRP Irp,
  862. PVOID Context
  863. );
  864. /*++
  865. Routine Description:
  866. This routine is called when an IRP completes. The routine is supplied by
  867. the sender of the IRP.
  868. Arguments:
  869. Irp - Supplies a pointer to the IRP that just completed.
  870. Context - Supplies a pointer supplied by the sender of the IRP. Presumably
  871. it contains state information relating to the reason this IRP was sent.
  872. Return Value:
  873. None.
  874. --*/
  875. typedef
  876. VOID
  877. (*PDRIVER_UNLOAD) (
  878. PVOID Driver
  879. );
  880. /*++
  881. Routine Description:
  882. This routine is called before a driver is about to be unloaded from memory.
  883. The driver should take this opportunity to free any resources it may have
  884. set up in the driver entry routine.
  885. Arguments:
  886. Driver - Supplies a pointer to the driver being torn down.
  887. Return Value:
  888. None.
  889. --*/
  890. typedef
  891. KSTATUS
  892. (*PDRIVER_ADD_DEVICE) (
  893. PVOID Driver,
  894. PCSTR DeviceId,
  895. PCSTR ClassId,
  896. PCSTR CompatibleIds,
  897. PVOID DeviceToken
  898. );
  899. /*++
  900. Routine Description:
  901. This routine is called when a device is detected that a given driver
  902. supports. The driver should attach itself to the device stack at this point.
  903. Arguments:
  904. Driver - Supplies a pointer to the driver being called.
  905. DeviceId - Supplies a pointer to a string with the device ID.
  906. ClassId - Supplies a pointer to a string containing the device's class ID.
  907. CompatibleIds - Supplies a pointer to a string containing device IDs
  908. that would be compatible with this device.
  909. DeviceToken - Supplies an opaque token that the driver can use to identify
  910. the device in the system. This token should be used when attaching to
  911. the stack.
  912. Return Value:
  913. STATUS_SUCCESS on success. The driver should return success in most cases,
  914. even if it chooses not to attach itself to the stack.
  915. Failure code if the driver encountered an error such as a resource
  916. allocation failure.
  917. --*/
  918. typedef
  919. VOID
  920. (*PDRIVER_DISPATCH) (
  921. PIRP Irp,
  922. PVOID DeviceContext,
  923. PVOID IrpContext
  924. );
  925. /*++
  926. Routine Description:
  927. This routine is called whenever an IRP is sent to a device.
  928. Arguments:
  929. Irp - Supplies a pointer to the I/O request packet.
  930. DeviceContext - Supplies the context pointer supplied by the driver when it
  931. attached itself to the driver stack. Presumably this pointer contains
  932. driver-specific device context.
  933. DeviceContext - Supplies the context pointer supplied by the driver when
  934. the IRP was created.
  935. Return Value:
  936. None.
  937. --*/
  938. typedef
  939. KSTATUS
  940. (*PDRIVER_CREATE_IRP) (
  941. PIRP Irp,
  942. PVOID DeviceContext,
  943. PVOID *IrpContext,
  944. ULONG Flags
  945. );
  946. /*++
  947. Routine Description:
  948. This routine is called when an IRP is being created. It gives the driver a
  949. chance to allocate any additional state it may need to associate with the
  950. IRP.
  951. Arguments:
  952. Irp - Supplies a pointer to the I/O request packet. The only variables the
  953. driver can count on staying constant are the device and the IRP Major
  954. Code. All other fields are subject to change throughout the lifetime of
  955. the IRP.
  956. DeviceContext - Supplies the context pointer supplied by the driver when it
  957. attached itself to the driver stack. Presumably this pointer contains
  958. driver-specific device context.
  959. DeviceContext - Supplies the context pointer supplied by the driver when
  960. the IRP was created.
  961. Flags - Supplies a bitmask of IRP creation flags. See IRP_FLAG_* for
  962. definitions.
  963. Return Value:
  964. None.
  965. --*/
  966. typedef
  967. VOID
  968. (*PINTERFACE_NOTIFICATION_CALLBACK) (
  969. PVOID Context,
  970. PDEVICE Device,
  971. PVOID InterfaceBuffer,
  972. ULONG InterfaceBufferSize,
  973. BOOL Arrival
  974. );
  975. /*++
  976. Routine Description:
  977. This routine is called to notify listeners that an interface has arrived
  978. or departed.
  979. Arguments:
  980. Context - Supplies the caller's context pointer, supplied when the caller
  981. requested interface notifications.
  982. Device - Supplies a pointer to the device exposing or deleting the
  983. interface.
  984. InterfaceBuffer - Supplies a pointer to the interface buffer of the
  985. interface.
  986. InterfaceBufferSize - Supplies the buffer size.
  987. Arrival - Supplies TRUE if a new interface is arriving, or FALSE if an
  988. interface is departing.
  989. Return Value:
  990. None.
  991. --*/
  992. /*++
  993. Structure Description:
  994. This structure defines a table of function pointers that the system uses to
  995. interact with drivers.
  996. Members:
  997. Version - Stores the version number of the table. Set this to
  998. DRIVER_FUNCTION_TABLE_VERSION.
  999. Unload - Stores a pointer to a function called before the driver is
  1000. unloaded from system memory.
  1001. AddDevice - Stores a pointer to the routine used to connect a driver with
  1002. a device.
  1003. CreateIrp - Stores an optional pointer to the routine to be called whenever
  1004. an IRP is allocated for a device in which the driver is involved.
  1005. DestroyIrp - Stores an optional pointer to the routine to be called
  1006. whenever an IRP is destroyed for a device in which the driver is
  1007. involved. If the CreateIrp function is non-NULL, then this routine is
  1008. required.
  1009. DispatchStateChange - Stores a pointer to the routine used to dispatch
  1010. state changing IRPs.
  1011. DispatchOpen - Stores a pointer to the routine used to dispatch Open IRPs.
  1012. DispatchClose - Stores a pointer to the routine used to dispatch Close IRPs.
  1013. DispatchIo - Stores a pointer to the routine used to dispatch I/O IRPs.
  1014. DispatchSystemControl - Stores a pointer to the routine used to dispatch
  1015. system control IRPs.
  1016. DispatchUserControl - Stores a pointer to the routine used to dispatch
  1017. user control IRPs.
  1018. --*/
  1019. typedef struct _DRIVER_FUNCTION_TABLE {
  1020. ULONG Version;
  1021. PDRIVER_UNLOAD Unload;
  1022. PDRIVER_ADD_DEVICE AddDevice;
  1023. PDRIVER_CREATE_IRP CreateIrp;
  1024. PDRIVER_DISPATCH DestroyIrp;
  1025. PDRIVER_DISPATCH DispatchStateChange;
  1026. PDRIVER_DISPATCH DispatchOpen;
  1027. PDRIVER_DISPATCH DispatchClose;
  1028. PDRIVER_DISPATCH DispatchIo;
  1029. PDRIVER_DISPATCH DispatchSystemControl;
  1030. PDRIVER_DISPATCH DispatchUserControl;
  1031. } DRIVER_FUNCTION_TABLE, *PDRIVER_FUNCTION_TABLE;
  1032. /*++
  1033. Structure Description:
  1034. This structure defines the parameters to the IoConnectInterrupt function.
  1035. Members:
  1036. Version - Stores the table version.
  1037. Device - Stores a pointer to the device whose interrupt is being connected.
  1038. LineNumber - Stores the Global System Interrupt number of the interrupt to
  1039. connect. The device must have this line in its resources.
  1040. Vector - Stores the software interrupt vector number to wire the interrupt
  1041. to. The device must have this vector it its resources.
  1042. InterruptServiceRoutine - Stores an optional pointer to a routine called
  1043. at an interrupt runlevel. This routine should be used simply to
  1044. query and quiesce the device. Actual processing of the interrupt should
  1045. be relegated to a lower level service routine. If this routine is not
  1046. supplied, then the lower level routines will be called back
  1047. automatically.
  1048. DispatchServiceRoutine - Stores an optional pointer to a routine to be
  1049. called at dispatch level to service the interrupt.
  1050. LowLevelServiceRoutine - Stores an optional pointer to a routine to be
  1051. called at low runlevel to service the interrupt. This routine will be
  1052. called from a work item on the system work queue, and therefore cannot
  1053. block on functions that wait for system work items to complete.
  1054. Context - Stores a context pointer that will be passed to each of the
  1055. service routines.
  1056. Interrupt - Stores a pointer where a handle will be returned on success.
  1057. --*/
  1058. typedef struct _IO_CONNECT_INTERRUPT_PARAMETERS {
  1059. ULONG Version;
  1060. PDEVICE Device;
  1061. ULONGLONG LineNumber;
  1062. ULONGLONG Vector;
  1063. PINTERRUPT_SERVICE_ROUTINE InterruptServiceRoutine;
  1064. PINTERRUPT_SERVICE_ROUTINE DispatchServiceRoutine;
  1065. PINTERRUPT_SERVICE_ROUTINE LowLevelServiceRoutine;
  1066. PVOID Context;
  1067. PHANDLE Interrupt;
  1068. } IO_CONNECT_INTERRUPT_PARAMETERS, *PIO_CONNECT_INTERRUPT_PARAMETERS;
  1069. typedef
  1070. KSTATUS
  1071. (*PDRIVER_ENTRY) (
  1072. PDRIVER Driver
  1073. );
  1074. /*++
  1075. Routine Description:
  1076. This routine is called when a driver is first loaded before any devices
  1077. have attached to it. It normally registers its dispatch routines with the
  1078. system, and performs any driver-wide initialization.
  1079. Arguments:
  1080. Driver - Supplies a pointer to the driver object. This structure should
  1081. not be modified by the driver directly.
  1082. Return Value:
  1083. STATUS_SUCCESS on success.
  1084. Failure code if the driver encountered an error such as a resource
  1085. allocation failure. If a driver fails this routine, it will get unloaded.
  1086. --*/
  1087. typedef enum _IO_OBJECT_TYPE {
  1088. IoObjectInvalid,
  1089. IoObjectRegularDirectory,
  1090. IoObjectRegularFile,
  1091. IoObjectBlockDevice,
  1092. IoObjectCharacterDevice,
  1093. IoObjectPipe,
  1094. IoObjectObjectDirectory,
  1095. IoObjectSocket,
  1096. IoObjectTerminalMaster,
  1097. IoObjectTerminalSlave,
  1098. IoObjectSharedMemoryObject,
  1099. IoObjectSymbolicLink,
  1100. IoObjectTypeCount
  1101. } IO_OBJECT_TYPE, *PIO_OBJECT_TYPE;
  1102. /*++
  1103. Structure Description:
  1104. This structure defines a directory entry, the listing of one file within a
  1105. directory. The null terminated name of the entry immediately follows this
  1106. structure.
  1107. Members:
  1108. FileId - Stores the serial number of the file.
  1109. NextOffset - Stores the file offset to the next directory entry. The dot
  1110. and dot-dot entries always occupy offsets 0 and 1, so the first offset
  1111. passed to a driver is DIRECTORY_CONTENTS_OFFSET.
  1112. Size - Stores the size of the entire entry, including the size of this
  1113. structure plus the size of the null-terminated name after it, including
  1114. the null terminator byte.
  1115. Type - Stores the type of the directory entry. This is of type
  1116. IO_OBJECT_TYPE. Other flags may be added to this field in the future.
  1117. --*/
  1118. typedef struct _DIRECTORY_ENTRY {
  1119. FILE_ID FileId;
  1120. ULONGLONG NextOffset;
  1121. USHORT Size;
  1122. UCHAR Type;
  1123. } PACKED DIRECTORY_ENTRY, *PDIRECTORY_ENTRY;
  1124. /*++
  1125. Structure Description:
  1126. This structure stores properties and characteristics of a file object.
  1127. Members:
  1128. DeviceId - Stores the device number on which this file exists.
  1129. FileId - Stores a unique number representing this file on this volume.
  1130. Generally this is the starting block on the disk where the file data
  1131. resides.
  1132. Type - Stores the type of file (regular file, directory, etc).
  1133. Permissions - Stores the file permissions.
  1134. HardLinkCount - Stores the number of hard links that exist for this file.
  1135. UserId - Stores the user ID of the file owner.
  1136. GroupId - Stores the group ID of the file owner.
  1137. RelatedDevice - Stores the device ID of the related device for certain
  1138. special device types.
  1139. Size - Stores the size of this file entity, in bytes.
  1140. AccessTime - Stores the last time this file was accessed.
  1141. ModifiedTime - Stores the last time this file was written to or truncated.
  1142. This is not updated for status updates like change of ownership,
  1143. permissions, hard link count.
  1144. StatusChangeTime - Stores the last time this file's status was changed.
  1145. This includes a change in the file's ownership, permissions, or
  1146. hard link count.
  1147. CreationTime - Stores the file creation time.
  1148. BlockSize - Stores the size of a block on this file system.
  1149. BlockCount - Stores the number of blocks allocated for this file.
  1150. Flags - Stores user defined flags.
  1151. Generation - Stores the file generation number.
  1152. --*/
  1153. typedef struct _FILE_PROPERTIES {
  1154. DEVICE_ID DeviceId;
  1155. FILE_ID FileId;
  1156. IO_OBJECT_TYPE Type;
  1157. FILE_PERMISSIONS Permissions;
  1158. LONG HardLinkCount;
  1159. USER_ID UserId;
  1160. GROUP_ID GroupId;
  1161. DEVICE_ID RelatedDevice;
  1162. IO_OFFSET Size;
  1163. SYSTEM_TIME AccessTime;
  1164. SYSTEM_TIME ModifiedTime;
  1165. SYSTEM_TIME StatusChangeTime;
  1166. SYSTEM_TIME CreationTime;
  1167. IO_OFFSET BlockSize;
  1168. IO_OFFSET BlockCount;
  1169. ULONG Flags;
  1170. ULONG Generation;
  1171. } FILE_PROPERTIES, *PFILE_PROPERTIES;
  1172. /*++
  1173. Structure Description:
  1174. This structure defines the parameters for a request to set file information.
  1175. Members:
  1176. FieldsToSet - Supplies the bitmask of fields to set. See
  1177. FILE_PROPERY_FIELD_* definitions. If this value is zero, then all the
  1178. fields will be retrieved rather than any being set.
  1179. FileProperties - Stores a pointer to the file properties to get or set.
  1180. --*/
  1181. typedef struct _SET_FILE_INFORMATION {
  1182. ULONG FieldsToSet;
  1183. PFILE_PROPERTIES FileProperties;
  1184. } SET_FILE_INFORMATION, *PSET_FILE_INFORMATION;
  1185. /*++
  1186. Structure Description:
  1187. This structure defines a link between an I/O object state and a particular
  1188. file descriptor that has signed up for asynchronous signals.
  1189. Members:
  1190. ListEntry - Stores pointers to the next and previous receivers in the I/O
  1191. state list.
  1192. Descriptor - Stores the descriptor number that signed up for notifications.
  1193. ProcessId - Stores the identifier of the process that signed up for
  1194. asynchronous I/O.
  1195. --*/
  1196. typedef struct _ASYNC_IO_RECEIVER {
  1197. LIST_ENTRY ListEntry;
  1198. HANDLE Descriptor;
  1199. PROCESS_ID ProcessId;
  1200. } ASYNC_IO_RECEIVER, *PASYNC_IO_RECEIVER;
  1201. /*++
  1202. Structure Description:
  1203. This structure defines the asynchronous state associated with an I/O
  1204. object.
  1205. Members:
  1206. Owner - Stores the owning process of this IO object state. This is the
  1207. process that receives signals when the IO object state changes.
  1208. SetterUserId - Stores the real user ID of the user that set the owner.
  1209. SetterEffectiveUserId - Stores the effective user ID of the user that set
  1210. the owner.
  1211. SetterPermissions - Stores the permission set of the process that set the
  1212. owner.
  1213. Signal - Stores the signal to send to the owner. If zero, then asynchronous
  1214. signaling is not enabled.
  1215. ReceiverList - Stores the head of the list of I/O handles that have agreed
  1216. to get asynchronous signals.
  1217. Lock - Stores a pointer to the lock protecting the list.
  1218. --*/
  1219. typedef struct _IO_ASYNC_STATE {
  1220. PROCESS_ID Owner;
  1221. USER_ID SetterUserId;
  1222. USER_ID SetterEffectiveUserId;
  1223. PERMISSION_SET SetterPermissions;
  1224. ULONG Signal;
  1225. LIST_ENTRY ReceiverList;
  1226. PQUEUED_LOCK Lock;
  1227. } IO_ASYNC_STATE, *PIO_ASYNC_STATE;
  1228. /*++
  1229. Structure Description:
  1230. This structure defines generic state associated with an I/O object.
  1231. Members:
  1232. ReadEvent - Stores a pointer to an event signaled when the I/O handle can
  1233. be read from without blocking.
  1234. ReadHighPriorityEvent - Stores a pointer to an event signaled when high
  1235. priority data can be read from the handle without blocking.
  1236. WriteEvent - Stores a pointer to an event signaled when the I/O handle can
  1237. be written to without blocking.
  1238. WriteHighPriorityEvent - Stores a pointer to an event signaled when high
  1239. priority data can be written to the I/O handle without blocking.
  1240. ErrorEvent - Stores a pointer to an event signaled when there is an error
  1241. regarding the I/O handle.
  1242. Events - Stores a bitmask of events that have occurred for the I/O handle.
  1243. See POLL_EVENT_* for definitions.
  1244. Async - Stores an optional pointer to the asynchronous object state.
  1245. --*/
  1246. typedef struct _IO_OBJECT_STATE {
  1247. PKEVENT ReadEvent;
  1248. PKEVENT ReadHighPriorityEvent;
  1249. PKEVENT WriteEvent;
  1250. PKEVENT WriteHighPriorityEvent;
  1251. PKEVENT ErrorEvent;
  1252. volatile ULONG Events;
  1253. PIO_ASYNC_STATE Async;
  1254. } IO_OBJECT_STATE, *PIO_OBJECT_STATE;
  1255. typedef enum _IRP_MAJOR_CODE {
  1256. IrpMajorInvalid,
  1257. IrpMajorStateChange,
  1258. IrpMajorOpen,
  1259. IrpMajorClose,
  1260. IrpMajorIo,
  1261. IrpMajorSystemControl,
  1262. IrpMajorUserControl
  1263. } IRP_MAJOR_CODE, *PIRP_MAJOR_CODE;
  1264. typedef enum _IRP_MINOR_CODE {
  1265. IrpMinorInvalid,
  1266. IrpMinorStateChangeInvalid = 0x1000,
  1267. IrpMinorQueryResources,
  1268. IrpMinorStartDevice,
  1269. IrpMinorQueryChildren,
  1270. IrpMinorQueryInterface,
  1271. IrpMinorRemoveDevice,
  1272. IrpMinorIdle,
  1273. IrpMinorSuspend,
  1274. IrpMinorResume,
  1275. IrpMinorOpenInvalid = 0x2000,
  1276. IrpMinorOpen,
  1277. IrpMinorCloseInvalid = 0x3000,
  1278. IrpMinorClose,
  1279. IrpMinorIoInvalid = 0x4000,
  1280. IrpMinorIoRead,
  1281. IrpMinorIoWrite,
  1282. IrpMinorSystemControlInvalid = 0x5000,
  1283. IrpMinorSystemControlLookup,
  1284. IrpMinorSystemControlCreate,
  1285. IrpMinorSystemControlWriteFileProperties,
  1286. IrpMinorSystemControlUnlink,
  1287. IrpMinorSystemControlRename,
  1288. IrpMinorSystemControlTruncate,
  1289. IrpMinorSystemControlDelete,
  1290. IrpMinorSystemControlDeviceInformation,
  1291. IrpMinorSystemControlGetBlockInformation,
  1292. IrpMinorSystemControlSynchronize,
  1293. } IRP_MINOR_CODE, *PIRP_MINOR_CODE;
  1294. typedef enum _IRP_DIRECTION {
  1295. IrpDirectionInvalid,
  1296. IrpDown,
  1297. IrpUp
  1298. } IRP_DIRECTION, *PIRP_DIRECTION;
  1299. /*++
  1300. Structure Description:
  1301. This structure defines a query resources request in an IRP.
  1302. Members:
  1303. ResourceRequirements - Stores a pointer to a list of possible resource
  1304. configurations. If this pointer is not filled in, the system assumes
  1305. the device needs no resources.
  1306. BootAllocation - Stores an optional pointer to the resources the device
  1307. has been assigned by the BIOS.
  1308. --*/
  1309. typedef struct _IRP_QUERY_RESOURCES {
  1310. PRESOURCE_CONFIGURATION_LIST ResourceRequirements;
  1311. PRESOURCE_ALLOCATION_LIST BootAllocation;
  1312. } IRP_QUERY_RESOURCES, *PIRP_QUERY_RESOURCES;
  1313. /*++
  1314. Structure Description:
  1315. This structure defines a start device request in an IRP.
  1316. Members:
  1317. ProcessorLocalResources - Stores the resources assigned to the device,
  1318. as seen from the perspective of the CPU complex. This will most
  1319. likely be used by the functional driver to interact with the device.
  1320. BusLocalResources - Stores the resources assigned to the device, as
  1321. seen from the perspective of the bus that enumerated the device.
  1322. This will most likely be used by the bus driver to program any
  1323. bus-specific aspects of the device.
  1324. --*/
  1325. typedef struct _IRP_START_DEVICE {
  1326. PRESOURCE_ALLOCATION_LIST ProcessorLocalResources;
  1327. PRESOURCE_ALLOCATION_LIST BusLocalResources;
  1328. } IRP_START_DEVICE, *PIRP_START_DEVICE;
  1329. /*++
  1330. Structure Description:
  1331. This structure defines a query children request in an IRP.
  1332. Members:
  1333. Children - Stores the address of an array of device pointers. This is
  1334. the list of children reported by the bus. This pointer is expected
  1335. to be allocated from paged pool, and will be freed by the I/O
  1336. manager itself.
  1337. ChildCount - Stores the number of device pointers that are in the list.
  1338. --*/
  1339. typedef struct _IRP_QUERY_CHILDREN {
  1340. PDEVICE *Children;
  1341. ULONG ChildCount;
  1342. } IRP_QUERY_CHILDREN, *PIRP_QUERY_CHILDREN;
  1343. /*++
  1344. Structure Description:
  1345. This structure defines a query interface request in an IRP.
  1346. Members:
  1347. Interface - Stores a pointer to the interface UUID being requested. The
  1348. caller sets this parameter.
  1349. InterfaceBuffer - Stores a pointer to a buffer allocated by the caller
  1350. where the interface will be returned on success. Note that the
  1351. entity requesting the interface is responsible for allocating and
  1352. managing this buffer.
  1353. InterfaceBufferSize - Stores the size of the interface buffer allocated.
  1354. This is set up by the entity requesting the interface.
  1355. --*/
  1356. typedef struct _IRP_QUERY_INTERFACE {
  1357. PUUID Interface;
  1358. PVOID InterfaceBuffer;
  1359. ULONG InterfaceBufferSize;
  1360. } IRP_QUERY_INTERFACE, *PIRP_QUERY_INTERFACE;
  1361. /*++
  1362. Structure Description:
  1363. This structure defines the parameters for an idle request IRP.
  1364. Members:
  1365. ExpectedDuration - Stores the expected duration of the idle period, in
  1366. time counter ticks.
  1367. --*/
  1368. typedef struct _IRP_IDLE {
  1369. ULONGLONG ExpectedDuration;
  1370. } IRP_IDLE, *PIRP_IDLE;
  1371. /*++
  1372. Structure Description:
  1373. This structure defines an open file or device request in an IRP.
  1374. Members:
  1375. FileProperties - Stores a pointer to the properties of the file to open.
  1376. IoState - Stores an optional pointer to the I/O object state for the file.
  1377. For the same device and file ID this will always be the same.
  1378. DesiredAccess - Stores the desired access flags. See IO_ACCESS_*
  1379. definitions.
  1380. OpenFlags - Stores additional flags about how the file or device should be
  1381. opened. See OPEN_FLAG_* definitions.
  1382. DeviceContext - Stores a pointer where the device driver can store a
  1383. pointer of context associated with this open operation. This
  1384. pointer will be passed to the device to uniquely identify it for
  1385. reads, writes, closes, and other operations.
  1386. IoHandle - Stores a pointer to the I/O handle being initialized with this
  1387. open.
  1388. --*/
  1389. typedef struct _IRP_OPEN {
  1390. PFILE_PROPERTIES FileProperties;
  1391. PIO_OBJECT_STATE IoState;
  1392. ULONG DesiredAccess;
  1393. ULONG OpenFlags;
  1394. PVOID DeviceContext;
  1395. PIO_HANDLE IoHandle;
  1396. } IRP_OPEN, *PIRP_OPEN;
  1397. /*++
  1398. Structure Description:
  1399. This structure defines a close file or device request in an IRP.
  1400. Members:
  1401. DeviceContext - Stores a pointer to the device context supplied by the
  1402. device driver upon opening the device. This is used to uniquely
  1403. identify the open file.
  1404. --*/
  1405. typedef struct _IRP_CLOSE {
  1406. PVOID DeviceContext;
  1407. } IRP_CLOSE, *PIRP_CLOSE;
  1408. /*++
  1409. Structure Description:
  1410. This structure defines an I/O request's saved I/O buffer state.
  1411. Members:
  1412. IoBuffer - Stores a pointer to the saved I/O buffer.
  1413. Flags - Stores a bitmask of flags describing the type of I/O buffer saved.
  1414. See IRP_IO_BUFFER_STATE_FLAG_* for definitions.
  1415. --*/
  1416. typedef struct _IRP_IO_BUFFER_STATE {
  1417. PIO_BUFFER IoBuffer;
  1418. ULONG Flags;
  1419. } IRP_IO_BUFFER_STATE, *PIRP_IO_BUFFER_STATE;
  1420. /*++
  1421. Structure Description:
  1422. This structure defines an I/O request in an IRP.
  1423. Members:
  1424. DeviceContext - Stores a pointer to the device context supplied by the
  1425. device driver upon opening the device. This is used to uniquely
  1426. identify the open file.
  1427. IoBuffer - Stores a pointer to the read or write buffer supplied by the
  1428. caller.
  1429. IoBufferState - Stoers a pointer to the internal state used for bounce
  1430. buffering.
  1431. IoFlags - Stores flags governing the behavior of the I/O. See
  1432. IO_FLAG_* definitions.
  1433. TimeoutInMilliseconds - Supplies the number of milliseconds that the I/O
  1434. operation should be waited on before timing out. Use
  1435. WAIT_TIME_INDEFINITE to wait forever on the I/O.
  1436. IoOffset - Stores the offset, in bytes, from the beginning of the file
  1437. where the read or write should be performed.
  1438. IoSizeInBytes - Stores the size of the I/O operation, in bytes.
  1439. IoBytesCompleted - Stores the number of bytes of I/O actually performed.
  1440. This number is to be filled out by the entity completing the IRP.
  1441. NewIoOffset - Stores the new current file position. Normally this is
  1442. just the offset plus the bytes completed, but sometimes (especially
  1443. for directories) it doesn't have to map that way.
  1444. FileProperties - Stores a pointer to the properties of the file on which
  1445. the I/O is to be completed.
  1446. --*/
  1447. typedef struct _IRP_READ_WRITE {
  1448. PVOID DeviceContext;
  1449. PIO_BUFFER IoBuffer;
  1450. IRP_IO_BUFFER_STATE IoBufferState;
  1451. ULONG IoFlags;
  1452. ULONG TimeoutInMilliseconds;
  1453. IO_OFFSET IoOffset;
  1454. UINTN IoSizeInBytes;
  1455. UINTN IoBytesCompleted;
  1456. IO_OFFSET NewIoOffset;
  1457. PFILE_PROPERTIES FileProperties;
  1458. } IRP_READ_WRITE, *PIRP_READ_WRITE;
  1459. /*++
  1460. Structure Description:
  1461. This structure defines a system control request in an IRP.
  1462. Members:
  1463. SystemContext - Stores a pointer to the system context storing the
  1464. information corresponding to the given IRP minor code.
  1465. --*/
  1466. typedef struct _IRP_SYSTEM_CONTROL {
  1467. PVOID SystemContext;
  1468. } IRP_SYSTEM_CONTROL, *PIRP_SYSTEM_CONTROL;
  1469. /*++
  1470. Structure Description:
  1471. This structure defines a user control request in an IRP.
  1472. Members:
  1473. FromKernelMode - Supplies a boolean indicating if the request comes from
  1474. user mode (FALSE) or kernel mode (TRUE). If it comes from user mode,
  1475. the driver must not access the user buffer directly, but instead use
  1476. MM copy routines to copy to and from user mode.
  1477. DeviceContext - Stores a pointer to the device context supplied by the
  1478. device driver upon opening the device. This is used to uniquely
  1479. identify the open file.
  1480. UserBuffer - Supplies a pointer to the buffer containing the context for
  1481. the user control IRP. This will be a user mode pointer and must be
  1482. treated with caution.
  1483. UserBufferSize - Supplies the size of the buffer as reported by user mode.
  1484. Again, this must be treated with suspicion by drivers.
  1485. --*/
  1486. typedef struct _IRP_USER_CONTROL {
  1487. BOOL FromKernelMode;
  1488. PVOID DeviceContext;
  1489. PVOID UserBuffer;
  1490. UINTN UserBufferSize;
  1491. } IRP_USER_CONTROL, *PIRP_USER_CONTROL;
  1492. /*++
  1493. Structure Description:
  1494. This structure defines an I/O Request Packet (IRP).
  1495. Members:
  1496. Header - Stores the standard object manager header.
  1497. Device - Stores a pointer to the device this IRP relates to.
  1498. MajorCode - Stores the major action code of the IRP.
  1499. MinorCode - Stores the minor action code of the IRP.
  1500. Direction - Stores the direction the IRP is travelling. "Down" means the
  1501. IRP is heading towards low-level drivers (the bus driver). "Up" means
  1502. the IRP has been completed and is heading back up towards higher level
  1503. functional drivers.
  1504. Status - Stores the completion status of the IRP.
  1505. CompletionRoutine - Stores a pointer to a routine to call once the IRP is
  1506. complete.
  1507. CompletionContext - Stores an opaque pointer that the sender of the IRP can
  1508. use to store context for the completion callback routine. It will be
  1509. passed to the completion routine.
  1510. ListEntry - Stores a list entry that the current driver processing the IRP
  1511. can use to put the IRP on a list. Drivers that have just gained control
  1512. of the IRP in either direction should not make assumptions about its
  1513. state.
  1514. QueryResources - Stores the results from a Query Resources IRP.
  1515. StartDevice - Stores the parameters to a Start Device IRP.
  1516. QueryChildren - Stores the results from a Query Children IRP.
  1517. QueryInterface - Stores the parameters and results from a Query Interface
  1518. IRP.
  1519. Idle - Stores the parameters for an Idle IRP.
  1520. Open - Stores the parameters and results from an Open IRP.
  1521. Close - Stores the parameters from a Close IRP.
  1522. ReadWrite - Stores the parameters for a Read or Write IRP.
  1523. SystemControl - Stores the parameters for a System Control IRP.
  1524. UserControl - Stores the parameters form a User Control IRP (with pointers
  1525. directly from user mode).
  1526. --*/
  1527. struct _IRP {
  1528. OBJECT_HEADER Header;
  1529. PDEVICE Device;
  1530. IRP_MAJOR_CODE MajorCode;
  1531. IRP_MINOR_CODE MinorCode;
  1532. IRP_DIRECTION Direction;
  1533. KSTATUS Status;
  1534. PIRP_COMPLETION_ROUTINE CompletionRoutine;
  1535. PVOID CompletionContext;
  1536. LIST_ENTRY ListEntry;
  1537. union {
  1538. IRP_QUERY_RESOURCES QueryResources;
  1539. IRP_START_DEVICE StartDevice;
  1540. IRP_QUERY_CHILDREN QueryChildren;
  1541. IRP_QUERY_INTERFACE QueryInterface;
  1542. IRP_IDLE Idle;
  1543. IRP_OPEN Open;
  1544. IRP_CLOSE Close;
  1545. IRP_READ_WRITE ReadWrite;
  1546. IRP_SYSTEM_CONTROL SystemControl;
  1547. IRP_USER_CONTROL UserControl;
  1548. } U;
  1549. };
  1550. /*++
  1551. Structure Description:
  1552. This structure describes a block I/O device.
  1553. Members:
  1554. DeviceToken - Stores an opaque pointer that uniquely identifies this device.
  1555. BlockSize - Stores the native block size, in bytes, of this device.
  1556. BlockCount - Stores the number of blocks contained in this device.
  1557. --*/
  1558. typedef struct _BLOCK_DEVICE_PARAMETERS {
  1559. PVOID DeviceToken;
  1560. ULONG BlockSize;
  1561. ULONGLONG BlockCount;
  1562. } BLOCK_DEVICE_PARAMETERS, *PBLOCK_DEVICE_PARAMETERS;
  1563. /*++
  1564. Structure Description:
  1565. This structure defines the information sent to a file system when the
  1566. system requests that the file system look up the ID of a file.
  1567. Members:
  1568. Root - Stores a boolean indicating if the system would like to look up the
  1569. root entry for this device. If so, the directory file ID, file name,
  1570. and file name size should be ignored.
  1571. Flags - Stores a bitmask of flags returned by lookup. See LOOKUP_FLAGS_*
  1572. for definitions.
  1573. MapFlags - Supplies a bitmask of additional map flags to apply when mapping
  1574. physical addresses returned from doing I/O on this file object. See
  1575. MAP_FLAG_* definitions.
  1576. DirectoryProperties - Stores a pointer to the properties of the directory
  1577. file that is to be searched.
  1578. FileName - Stores a pointer to the name of the file, which may not be
  1579. null terminated.
  1580. FileNameSize - Stores the size of the file name buffer including space
  1581. for a null terminator (which may be a null terminator or may be a
  1582. garbage character).
  1583. Properties - Stores a pointer where the file properties are returned by the
  1584. driver upon success.
  1585. --*/
  1586. typedef struct _SYSTEM_CONTROL_LOOKUP {
  1587. BOOL Root;
  1588. ULONG Flags;
  1589. ULONG MapFlags;
  1590. PFILE_PROPERTIES DirectoryProperties;
  1591. PCSTR FileName;
  1592. ULONG FileNameSize;
  1593. PFILE_PROPERTIES Properties;
  1594. } SYSTEM_CONTROL_LOOKUP, *PSYSTEM_CONTROL_LOOKUP;
  1595. /*++
  1596. Structure Description:
  1597. This structure defines the information sent to a file system for
  1598. flushing file properties and unlink.
  1599. Members:
  1600. File - Stores a pointer to the properties of the target file.
  1601. DeviceContext - Stores a pointer to the open device context for the file if
  1602. there is one. This is filled in for some operations (like truncate),
  1603. but not all.
  1604. Flags - Supplies a bitmask of I/O flags. See IO_FLAG_* for definitions.
  1605. --*/
  1606. typedef struct _SYSTEM_CONTROL_FILE_OPERATION {
  1607. PFILE_PROPERTIES FileProperties;
  1608. PVOID DeviceContext;
  1609. ULONG Flags;
  1610. } SYSTEM_CONTROL_FILE_OPERATION, *PSYSTEM_CONTROL_FILE_OPERATION;
  1611. /*++
  1612. Structure Description:
  1613. This structure defines the information sent to a file system when the
  1614. system requests that the file system create a new file or directory.
  1615. Members:
  1616. Directory - Stores a pointer to the file properties of the directory.
  1617. DirectorySize - Stores the extent of the directory written to create the
  1618. new file. This may be less than the actual directory size but the
  1619. system will only update the directory size if it is larger than the
  1620. currently recorded size.
  1621. Name - Stores a pointer to the name of the file or directory to create,
  1622. which may not be null terminated.
  1623. NameSize - Stores the size of the name buffer including space for a null
  1624. terminator (which may be a null terminator or may be a garbage
  1625. character).
  1626. Properties - Stores the file properties of the created file on success. The
  1627. permissions, object type, user ID, group ID, and access times are all
  1628. valid from the system.
  1629. --*/
  1630. typedef struct _SYSTEM_CONTROL_CREATE {
  1631. PFILE_PROPERTIES DirectoryProperties;
  1632. ULONGLONG DirectorySize;
  1633. PCSTR Name;
  1634. ULONG NameSize;
  1635. FILE_PROPERTIES FileProperties;
  1636. } SYSTEM_CONTROL_CREATE, *PSYSTEM_CONTROL_CREATE;
  1637. /*++
  1638. Structure Description:
  1639. This structure defines the information sent to a file system when the
  1640. system requests that the file system unlink a directory entry.
  1641. Members:
  1642. Directory - Stores a pointer to the file properties of the directory that
  1643. contains the entry to unlink.
  1644. File - Stores a pointer to the file properties of the file that is being
  1645. unlinked.
  1646. Name - Stores a pointer to the name of the file or directory to unlink,
  1647. which may not be null terminated.
  1648. NameSize - Stores the size of the name buffer including space for a null
  1649. terminator (which may be a null terminator or may be a garbage
  1650. character).
  1651. Unlinked - Stores a boolean indicating whether or not the directory entry
  1652. was successfully unlinked. An unlink can occur even in some failure
  1653. cases.
  1654. --*/
  1655. typedef struct _SYSTEM_CONTROL_UNLINK {
  1656. PFILE_PROPERTIES DirectoryProperties;
  1657. PFILE_PROPERTIES FileProperties;
  1658. PCSTR Name;
  1659. ULONG NameSize;
  1660. BOOL Unlinked;
  1661. } SYSTEM_CONTROL_UNLINK, *PSYSTEM_CONTROL_UNLINK;
  1662. /*++
  1663. Structure Description:
  1664. This structure defines the information sent to a file system when the
  1665. system requests that the file system rename a file or directory.
  1666. Members:
  1667. SourceDirectoryProperties - Stores a pointer to the file properties of the
  1668. directory containing the file to rename.
  1669. SourceFileProperties - Stores a pointer to the file properties of the file
  1670. to rename.
  1671. DestinationDirectoryProperties - Stores a pointer to the file properties of
  1672. the directory where the named file will reside.
  1673. DestinationFileProperties - Stores an optional pointer to the file
  1674. properties of the file currently sitting at the destination (that will
  1675. need to be unlinked). If there is no file or directory at the
  1676. destination, then this will be NULL.
  1677. DestinationDirectorySize - Stores the extent of the directory written to
  1678. create the new file. This may be less than the actual directory size
  1679. but the system will only update the directory size if it is larger than
  1680. the currently recorded size.
  1681. SourceFileHardLinkDelta - Stores a value indicating a delta (if any) in
  1682. hard links to the source file that was a result of the rename
  1683. operation. Callers should observe this value especially when the call
  1684. fails.
  1685. DestinationFileUnlinked - Stores a boolean indicating whether or not the
  1686. destination file (if any) was unlinked during the process of this
  1687. rename operation. Callers should observe this value especially when the
  1688. call fails.
  1689. Name - Stores a pointer to the string containing the destination
  1690. file/directory name, which may not be null terminated.
  1691. NameSize - Stores the size of the name buffer including space for a null
  1692. terminator (which may be a null terminator or may be a garbage
  1693. character).
  1694. --*/
  1695. typedef struct _SYSTEM_CONTROL_RENAME {
  1696. PFILE_PROPERTIES SourceDirectoryProperties;
  1697. PFILE_PROPERTIES SourceFileProperties;
  1698. PFILE_PROPERTIES DestinationDirectoryProperties;
  1699. PFILE_PROPERTIES DestinationFileProperties;
  1700. ULONGLONG DestinationDirectorySize;
  1701. ULONG SourceFileHardLinkDelta;
  1702. BOOL DestinationFileUnlinked;
  1703. PSTR Name;
  1704. ULONG NameSize;
  1705. } SYSTEM_CONTROL_RENAME, *PSYSTEM_CONTROL_RENAME;
  1706. /*++
  1707. Structure Description:
  1708. This structure defines the information sent to a file system for a truncate
  1709. operation.
  1710. Members:
  1711. File - Stores a pointer to the properties of the target file.
  1712. DeviceContext - Stores a pointer to the open device context for the file if
  1713. there is one. This is filled in for some operations (like truncate),
  1714. but not all.
  1715. NewSize - Stores the new size to truncate the file to.
  1716. --*/
  1717. typedef struct _SYSTEM_CONTROL_TRUNCATE {
  1718. PFILE_PROPERTIES FileProperties;
  1719. PVOID DeviceContext;
  1720. ULONGLONG NewSize;
  1721. } SYSTEM_CONTROL_TRUNCATE, *PSYSTEM_CONTROL_TRUNCATE;
  1722. /*++
  1723. Structure Description:
  1724. This structure defines a device information result returned as an array
  1725. from an enumeration.
  1726. Members:
  1727. Uuid - Stores the universally unique identifier of the device information
  1728. type.
  1729. Device - Stores the device ID of the device that enumerates this
  1730. information type.
  1731. --*/
  1732. typedef struct _DEVICE_INFORMATION_RESULT {
  1733. UUID Uuid;
  1734. DEVICE_ID DeviceId;
  1735. } DEVICE_INFORMATION_RESULT, *PDEVICE_INFORMATION_RESULT;
  1736. /*++
  1737. Structure Description:
  1738. This structure defines a device information header.
  1739. Members:
  1740. Uuid - Stores the universally unique identifier of the device information
  1741. type.
  1742. Data - Stores a pointer where the device information will be returned on
  1743. success for "get" operations or to the data to set for "set" operations.
  1744. DataSize - Stores a value that upon input contains the size of the data
  1745. buffer in bytes. On output, returns the required size of the data
  1746. buffer in bytes.
  1747. Set - Stores a boolean indicating whether to retrieve device information
  1748. (FALSE) or set device information (TRUE).
  1749. --*/
  1750. typedef struct _SYSTEM_CONTROL_DEVICE_INFORMATION {
  1751. UUID Uuid;
  1752. PVOID Data;
  1753. UINTN DataSize;
  1754. BOOL Set;
  1755. } SYSTEM_CONTROL_DEVICE_INFORMATION, *PSYSTEM_CONTROL_DEVICE_INFORMATION;
  1756. /*++
  1757. Structure Description:
  1758. This structure defines a run of contiguous blocks for a file or partition.
  1759. Members:
  1760. ListEntry - Stores pointers to the next and previous runs of contiguous
  1761. blocks.
  1762. Address - Stores the logical block start address of the run.
  1763. Count - Stores the number of blocks in the run.
  1764. --*/
  1765. typedef struct _FILE_BLOCK_ENTRY {
  1766. LIST_ENTRY ListEntry;
  1767. ULONGLONG Address;
  1768. ULONGLONG Count;
  1769. } FILE_BLOCK_ENTRY, *PFILE_BLOCK_ENTRY;
  1770. /*++
  1771. Structure Description:
  1772. This structure defines block information that can be retrieved for a file
  1773. or partition.
  1774. Members:
  1775. BlockList - Stores the head of a list of contiguous disk blocks that
  1776. comprise the file or partition.
  1777. --*/
  1778. typedef struct _FILE_BLOCK_INFORMATION {
  1779. LIST_ENTRY BlockList;
  1780. } FILE_BLOCK_INFORMATION, *PFILE_BLOCK_INFORMATION;
  1781. /*++
  1782. Structure Description:
  1783. This structure defines a block information request.
  1784. Members:
  1785. FileProperties - Supplies a pointer to the file properties of the file or
  1786. partition whose block information is being requested.
  1787. FileBlockInformation - Supplies a pointer that receives a block information
  1788. structure for the file or partition.
  1789. --*/
  1790. typedef struct _SYSTEM_CONTROL_GET_BLOCK_INFORMATION {
  1791. PFILE_PROPERTIES FileProperties;
  1792. PFILE_BLOCK_INFORMATION FileBlockInformation;
  1793. } SYSTEM_CONTROL_GET_BLOCK_INFORMATION, *PSYSTEM_CONTROL_GET_BLOCK_INFORMATION;
  1794. /*++
  1795. Structure Description:
  1796. This structure defines the information necessary to direct disk block-level
  1797. I/O to a file.
  1798. Members:
  1799. DiskToken - Stores an opaque token to disk device context.
  1800. BlockSize - Stores the size of each block on disk, in bytes.
  1801. BlockCount - Stores the total number of blocks on the disk.
  1802. BlockIoReset - Stores a pointer to a routine that allows the device to
  1803. reset any I/O paths in preparation for imminent block I/O.
  1804. BlockRead - Stores a pointer to a routine that can do direct block-level
  1805. reads from the disk.
  1806. BlockWrite - Stores a pointer to a routine that can do direct block-level
  1807. writes to a disk.
  1808. FileBlockInformation - Stores a pointer to the block information for the
  1809. file that is being read or written. This includes a list of contiguous
  1810. block runs.
  1811. --*/
  1812. typedef struct _FILE_BLOCK_IO_CONTEXT {
  1813. PVOID DiskToken;
  1814. ULONG BlockSize;
  1815. ULONGLONG BlockCount;
  1816. PVOID BlockIoReset;
  1817. PVOID BlockIoRead;
  1818. PVOID BlockIoWrite;
  1819. PFILE_BLOCK_INFORMATION FileBlockInformation;
  1820. } FILE_BLOCK_IO_CONTEXT, *PFILE_BLOCK_IO_CONTEXT;
  1821. /*++
  1822. Structure Description:
  1823. This structure defines an entry in an array of mount points.
  1824. Members:
  1825. Flags - Stores the flags associated with the mount point.
  1826. MountPointPathOffset - Stores the location of the mount point path string
  1827. as an offset from this structures base address.
  1828. TargetPathOffset - Stores the location of the target path string as an
  1829. offset from this structures base address.
  1830. --*/
  1831. typedef struct _MOUNT_POINT_ENTRY {
  1832. ULONG Flags;
  1833. UINTN MountPointPathOffset;
  1834. UINTN TargetPathOffset;
  1835. } MOUNT_POINT_ENTRY, *PMOUNT_POINT_ENTRY;
  1836. /*++
  1837. Structure Description:
  1838. This structure defines a set of I/O cache statistics.
  1839. Members:
  1840. Version - Stores the version information for this structure. Set this to
  1841. IO_CACHE_STATISTICS_VERSION.
  1842. HeadroomPagesTrigger - Stores the number of free physical pages in the
  1843. system below which the page count will begin evicting entries to
  1844. conserve memory.
  1845. HeadroomPagesRetreat - Stores the number of free physical pages in the
  1846. system the page cache will shoot for once it begins a headroom-based
  1847. eviction of pages.
  1848. MinimumPagesTarget - Stores the target minimum size of the page cache. The
  1849. page cache makes an effort to maintain this minimum by requesting other
  1850. pages be paged out when it falls below this size.
  1851. MinimumPages - Stores the size below which the page cache will not attempt
  1852. to shrink.
  1853. PhysicalPageCount - Stores the current number of physical pages consumed by
  1854. the cache.
  1855. DirtyPageCount - Stores the number of physical pages in the cache that are
  1856. currently dirty.
  1857. LastCleanTime - Stores a time counter value for the last time the page
  1858. cache was cleaned.
  1859. --*/
  1860. typedef struct _IO_CACHE_STATISTICS {
  1861. ULONG Version;
  1862. UINTN HeadroomPagesTrigger;
  1863. UINTN HeadroomPagesRetreat;
  1864. UINTN MinimumPagesTarget;
  1865. UINTN MinimumPages;
  1866. UINTN PhysicalPageCount;
  1867. UINTN DirtyPageCount;
  1868. ULONGLONG LastCleanTime;
  1869. } IO_CACHE_STATISTICS, *PIO_CACHE_STATISTICS;
  1870. /*++
  1871. Structure Description:
  1872. This structure defines a set of I/O cache statistics.
  1873. Members:
  1874. Version - Stores the version information for this structure. Set this to
  1875. IO_GLOBAL_STATISTICS_VERSION.
  1876. BytesRead - Stores the total number of bytes read in.
  1877. BytesWritten - Stores the total number of bytes written out.
  1878. PagingBytesRead - Stores the number of bytes read in from the page file.
  1879. PagingBytesWritten - Stores the number of bytes written to the page file.
  1880. --*/
  1881. typedef struct _IO_GLOBAL_STATISTICS {
  1882. ULONG Version;
  1883. ULONGLONG BytesRead;
  1884. ULONGLONG BytesWritten;
  1885. ULONGLONG PagingBytesRead;
  1886. ULONGLONG PagingBytesWritten;
  1887. } IO_GLOBAL_STATISTICS, *PIO_GLOBAL_STATISTICS;
  1888. /*++
  1889. Structure Description:
  1890. This structure defines system boot information.
  1891. Members:
  1892. SystemDiskIdentifier - Stores the identifier of the disk the running system
  1893. is located on.
  1894. SystemPartitionIdentifier - Stores the identifier of the partition the
  1895. running system is located on.
  1896. BootTime - Stores the time the system was booted.
  1897. --*/
  1898. typedef struct _IO_BOOT_INFORMATION {
  1899. UCHAR SystemDiskIdentifier[16];
  1900. UCHAR SystemPartitionIdentifier[16];
  1901. SYSTEM_TIME BootTime;
  1902. } IO_BOOT_INFORMATION, *PIO_BOOT_INFORMATION;
  1903. /*++
  1904. Structure Description:
  1905. This structure defines a path in the context of its mount point.
  1906. Members:
  1907. PathEntry - Stores a pointer to a path entry.
  1908. MountPoint - Stores a pointer to the mount point that governs the path
  1909. entry.
  1910. --*/
  1911. typedef struct _PATH_POINT {
  1912. PPATH_ENTRY PathEntry;
  1913. PMOUNT_POINT MountPoint;
  1914. } PATH_POINT, *PPATH_POINT;
  1915. /*++
  1916. Structure Description:
  1917. This structure defines a loaded file.
  1918. Members:
  1919. Version - Stores the structure version. Future revisions will be backwards
  1920. compatible. Set to LOADED_FILE_VERSION.
  1921. IoHandle - Stores an open handle to the loaded file.
  1922. Length - Stores the length of the loaded file.
  1923. IoBuffer - Stores a pointer to an I/O buffer that stores the loaded file's
  1924. data.
  1925. --*/
  1926. typedef struct _LOADED_FILE {
  1927. ULONG Version;
  1928. PIO_HANDLE IoHandle;
  1929. UINTN Length;
  1930. PIO_BUFFER IoBuffer;
  1931. } LOADED_FILE, *PLOADED_FILE;
  1932. typedef
  1933. VOID
  1934. (*PLOAD_FILE_COMPLETION_ROUTINE) (
  1935. PVOID Context,
  1936. PLOADED_FILE File
  1937. );
  1938. /*++
  1939. Routine Description:
  1940. This routine is called when a file load has completed.
  1941. Arguments:
  1942. Context - Supplies the context supplied by the caller who initiated the
  1943. file load.
  1944. File - Supplies a pointer to the loaded file.
  1945. Return Value:
  1946. None.
  1947. --*/
  1948. /*++
  1949. Structure Description:
  1950. This structure defines the permission set for a shared memory object. This
  1951. lines up with struct ipc_perm in the C library.
  1952. Members:
  1953. OwnerUserId - Stores the user ID of the owner.
  1954. OwnerGroupId - Stores the group ID of the owner.
  1955. CreatorUserId - Stores the user ID of the creator.
  1956. CreatorGroupId - Stores the group ID of the creator.
  1957. Permissions - Stores the permission set for this object.
  1958. --*/
  1959. typedef struct _SHARED_MEMORY_PERMISSIONS {
  1960. USER_ID OwnerUserId;
  1961. GROUP_ID OwnerGroupId;
  1962. USER_ID CreatorUserId;
  1963. GROUP_ID CreatorGroupId;
  1964. ULONG Permissions;
  1965. } SHARED_MEMORY_PERMISSIONS, *PSHARED_MEMORY_PERMISSIONS;
  1966. /*++
  1967. Structure Description:
  1968. This structure defines the properties of a shared memory object. This
  1969. structure lines up with struct shmid_ds in the C library.
  1970. Members:
  1971. Permissions - Stores the permissions information for the object.
  1972. Size - Stores the size of the shared memory object in bytes.
  1973. AttachTime - Stores the last time an attach occurred.
  1974. DetachTime - Stores the last time a detach occurred.
  1975. ChangeTime - Stores the last time the object was changed (via a set).
  1976. CreatorPid - Stores the process ID of the process that created this object.
  1977. LastPid - Stores the process ID of the last process to operate on this
  1978. object.
  1979. AttachCount - Stores the number of active attachments.
  1980. --*/
  1981. typedef struct _SHARED_MEMORY_PROPERTIES {
  1982. SHARED_MEMORY_PERMISSIONS Permissions;
  1983. IO_OFFSET Size;
  1984. SYSTEM_TIME AttachTime;
  1985. SYSTEM_TIME DetachTime;
  1986. SYSTEM_TIME ChangeTime;
  1987. PROCESS_ID CreatorPid;
  1988. PROCESS_ID LastPid;
  1989. UINTN AttachCount;
  1990. } SHARED_MEMORY_PROPERTIES, *PSHARED_MEMORY_PROPERTIES;
  1991. //
  1992. // -------------------------------------------------------------------- Globals
  1993. //
  1994. //
  1995. // -------------------------------------------------------- Function Prototypes
  1996. //
  1997. KERNEL_API
  1998. KSTATUS
  1999. IoCreateDevice (
  2000. PDRIVER BusDriver,
  2001. PVOID BusDriverContext,
  2002. PDEVICE ParentDevice,
  2003. PCSTR DeviceId,
  2004. PCSTR ClassId,
  2005. PCSTR CompatibleIds,
  2006. PDEVICE *NewDevice
  2007. );
  2008. /*++
  2009. Routine Description:
  2010. This routine creates a new device in the system. This device can be used in
  2011. subsequent calls to Query Children.
  2012. Arguments:
  2013. BusDriver - Supplies a pointer to the driver reporting this device.
  2014. BusDriverContext - Supplies the context pointer that will be passed to the
  2015. bus driver when IRPs are sent to the device.
  2016. ParentDevice - Supplies a pointer to the device enumerating this device.
  2017. Most devices are enumerated off of a bus, so this parameter will
  2018. contain a pointer to that bus device. For unenumerable devices, this
  2019. parameter can be NULL, in which case the device will be enumerated off
  2020. of the root device.
  2021. DeviceId - Supplies a pointer to a null terminated string identifying the
  2022. device. This memory does not have to be retained, a copy of it will be
  2023. created during this call.
  2024. ClassId - Supplies a pointer to a null terminated string identifying the
  2025. device class. This memory does not have to be retained, a copy of it
  2026. will be created during this call.
  2027. CompatibleIds - Supplies a semicolon-delimited list of device IDs that this
  2028. device is compatible with.
  2029. NewDevice - Supplies a pointer where the new device will be returned on
  2030. success.
  2031. Return Value:
  2032. Status code.
  2033. --*/
  2034. KERNEL_API
  2035. KSTATUS
  2036. IoRemoveUnreportedDevice (
  2037. PDEVICE Device
  2038. );
  2039. /*++
  2040. Routine Description:
  2041. This routine removes a device that was created but never reported. Devices
  2042. created on enumerable busses must be removed by not reporting them in
  2043. a query children request. This routine must only be called on devices whose
  2044. parent device is the root.
  2045. Arguments:
  2046. Device - Supplies a pointer to the device to remove.
  2047. Return Value:
  2048. Status code.
  2049. --*/
  2050. KERNEL_API
  2051. VOID
  2052. IoDeviceAddReference (
  2053. PDEVICE Device
  2054. );
  2055. /*++
  2056. Routine Description:
  2057. This routine increments the reference count on a device.
  2058. Arguments:
  2059. Device - Supplies a pointer to the device.
  2060. Return Value:
  2061. None.
  2062. --*/
  2063. KERNEL_API
  2064. VOID
  2065. IoDeviceReleaseReference (
  2066. PDEVICE Device
  2067. );
  2068. /*++
  2069. Routine Description:
  2070. This routine decrements the reference count on a device.
  2071. Arguments:
  2072. Device - Supplies a pointer to the device.
  2073. Return Value:
  2074. None.
  2075. --*/
  2076. KERNEL_API
  2077. KSTATUS
  2078. IoSetTargetDevice (
  2079. PDEVICE Device,
  2080. PDEVICE TargetDevice
  2081. );
  2082. /*++
  2083. Routine Description:
  2084. This routine sets the target device for a given device. IRPs flow through
  2085. a device and then through its target device (if not completed by an
  2086. earlier driver). Target devices allow the piling of stacks on one another.
  2087. Target device relations must be set either before the device is reported
  2088. by the bus, or during AddDevice. They cannot be changed after that. This
  2089. routine is not thread safe, as it's only expected to be called by drivers
  2090. on the device during early device initialization.
  2091. Arguments:
  2092. Device - Supplies a pointer to the device to set a target device for.
  2093. TargetDevice - Supplies a pointer to the target device.
  2094. Return Value:
  2095. STATUS_SUCCESS on success.
  2096. STATUS_TOO_LATE if the device is already too far through its initialization
  2097. to have a target device added to it.
  2098. --*/
  2099. KERNEL_API
  2100. PDEVICE
  2101. IoGetTargetDevice (
  2102. PDEVICE Device
  2103. );
  2104. /*++
  2105. Routine Description:
  2106. This routine returns the target device for the given device, if any.
  2107. Arguments:
  2108. Device - Supplies a pointer to the device to get the target device for.
  2109. Return Value:
  2110. Returns a pointer to the target device.
  2111. NULL if there is no target device.
  2112. --*/
  2113. PDEVICE
  2114. IoGetDiskDevice (
  2115. PDEVICE Device
  2116. );
  2117. /*++
  2118. Routine Description:
  2119. This routine returns the underlying disk device for a given device.
  2120. Arguments:
  2121. Device - Supplies a pointer to a device.
  2122. Return Value:
  2123. Returns a pointer to the disk device that backs the device.
  2124. NULL if the given device does not have a disk backing it.
  2125. --*/
  2126. KERNEL_API
  2127. VOID
  2128. IoSetDeviceMountable (
  2129. PDEVICE Device
  2130. );
  2131. /*++
  2132. Routine Description:
  2133. This routine indicates that the given device is mountable. A device cannot
  2134. be unmarked as mountable. This routine is not thread safe.
  2135. Arguments:
  2136. Device - Supplies a pointer to the device that the system could potentially
  2137. mount.
  2138. Return Value:
  2139. None.
  2140. --*/
  2141. KERNEL_API
  2142. BOOL
  2143. IoAreDeviceIdsEqual (
  2144. PCSTR DeviceIdOne,
  2145. PCSTR DeviceIdTwo
  2146. );
  2147. /*++
  2148. Routine Description:
  2149. This routine determines if the given device IDs match. This routine always
  2150. truncates the given device IDs at the last '#' character, if it exists. If
  2151. one of the supplied device IDs naturally has a '#' character within it,
  2152. then caller should append a second '#' character to the device ID.
  2153. Arguments:
  2154. DeviceIdOne - Supplies the first device ID.
  2155. DeviceIdTwo - Supplies the second device ID.
  2156. Return Value:
  2157. Returns TRUE if the given device IDs match. FALSE otherwise.
  2158. --*/
  2159. KERNEL_API
  2160. PCSTR
  2161. IoGetDeviceId (
  2162. PDEVICE Device
  2163. );
  2164. /*++
  2165. Routine Description:
  2166. This routine returns the device ID of the given system device.
  2167. Arguments:
  2168. Device - Supplies the device to get the ID of.
  2169. Return Value:
  2170. Returns a pionter to a string representing the device's Identifier.
  2171. --*/
  2172. KERNEL_API
  2173. PCSTR
  2174. IoGetCompatibleDeviceIds (
  2175. PDEVICE Device
  2176. );
  2177. /*++
  2178. Routine Description:
  2179. This routine returns a semilcolon-delimited list of device IDs that this
  2180. device is compatible with.
  2181. Arguments:
  2182. Device - Supplies the device to get the compatible IDs of.
  2183. Return Value:
  2184. Returns a pointer to a semicolon-delimited string of device IDs that this
  2185. device is compatible with, not including the actual device ID itself.
  2186. NULL if the compatible ID list is empty.
  2187. --*/
  2188. KERNEL_API
  2189. PCSTR
  2190. IoGetDeviceClassId (
  2191. PDEVICE Device
  2192. );
  2193. /*++
  2194. Routine Description:
  2195. This routine returns the class ID of the given device.
  2196. Arguments:
  2197. Device - Supplies the device to get the class ID of.
  2198. Return Value:
  2199. Returns the class ID of the given device.
  2200. NULL if the device was not created with a class ID.
  2201. --*/
  2202. KERNEL_API
  2203. BOOL
  2204. IoIsDeviceIdInCompatibleIdList (
  2205. PCSTR DeviceId,
  2206. PDEVICE Device
  2207. );
  2208. /*++
  2209. Routine Description:
  2210. This routine determines if the given device ID is present in the semicolon-
  2211. delimited list of compatible device IDs of the given device, or matches
  2212. the device ID itself.
  2213. This routine must be called at Low level.
  2214. Arguments:
  2215. DeviceId - Supplies the device ID in question.
  2216. Device - Supplies the device whose compatible IDs should be queried.
  2217. Return Value:
  2218. TRUE if the given device ID string is present in the device's compatible ID
  2219. list.
  2220. FALSE if the device ID string is not present in the compatible ID list.
  2221. --*/
  2222. KERNEL_API
  2223. DEVICE_ID
  2224. IoGetDeviceNumericId (
  2225. PDEVICE Device
  2226. );
  2227. /*++
  2228. Routine Description:
  2229. This routine gets the numeric device ID for the given device.
  2230. Arguments:
  2231. Device - Supplies a pointer to the device whose numeric ID is being queried.
  2232. Return Value:
  2233. Returns the numeric device ID for the device.
  2234. --*/
  2235. KERNEL_API
  2236. PDEVICE
  2237. IoGetDeviceByNumericId (
  2238. DEVICE_ID DeviceId
  2239. );
  2240. /*++
  2241. Routine Description:
  2242. This routine looks up a device given its numeric device ID. This routine
  2243. will increment the reference count of the device returned, it is the
  2244. caller's responsibility to release that reference. Only devices that are in
  2245. the started state will be returned. This routine must be called at low
  2246. level.
  2247. Arguments:
  2248. DeviceId - Supplies the numeric device ID of the device to get.
  2249. Return Value:
  2250. Returns a pointer to the device with the given numeric device ID on
  2251. success. This routine will add a reference to the device returned, it is
  2252. the caller's responsibility to release this reference when finished with
  2253. the device.
  2254. --*/
  2255. KERNEL_API
  2256. KSTATUS
  2257. IoMergeChildArrays (
  2258. PIRP QueryChildrenIrp,
  2259. PDEVICE *Children,
  2260. ULONG ChildCount,
  2261. ULONG AllocationTag
  2262. );
  2263. /*++
  2264. Routine Description:
  2265. This routine merges a device's enumerated children with the array that is
  2266. already present in the Query Children IRP. If needed, a new array containing
  2267. the merged list will be created and stored in the IRP, and the old list
  2268. will be freed. If the IRP has no list yet, a copy of the array passed in
  2269. will be created and set in the IRP.
  2270. Arguments:
  2271. QueryChildrenIrp - Supplies a pointer to the Query Children IRP.
  2272. Children - Supplies a pointer to the device children. This array will not be
  2273. used in the IRP, so this array can be temporarily allocated.
  2274. ChildCount - Supplies the number of elements in the pointer array.
  2275. AllocationTag - Supplies the allocate tag to use for the newly created
  2276. array.
  2277. Return Value:
  2278. STATUS_SUCCESS on success.
  2279. STATUS_INSUFFICIENT_RESOURCES if the new array could not be allocated.
  2280. --*/
  2281. KERNEL_API
  2282. KSTATUS
  2283. IoNotifyDeviceTopologyChange (
  2284. PDEVICE Device
  2285. );
  2286. /*++
  2287. Routine Description:
  2288. This routine notifies the system that the device topology has changed for
  2289. the given device. This routine is meant to be called by a device driver
  2290. when it notices a child device is missing or when a new device arrives.
  2291. Arguments:
  2292. Device - Supplies a pointer to the device whose topology has changed.
  2293. Return Value:
  2294. None.
  2295. --*/
  2296. KERNEL_API
  2297. BOOL
  2298. IoIsDeviceStarted (
  2299. PDEVICE Device
  2300. );
  2301. /*++
  2302. Routine Description:
  2303. This routine returns whether or not the device is in the started state.
  2304. Arguments:
  2305. Device - Supplies a pointer to the device in question.
  2306. Return Value:
  2307. Returns TRUE if the device is in the started state, or FALSE otherwise.
  2308. --*/
  2309. KERNEL_API
  2310. VOID
  2311. IoSetDeviceDriverErrorEx (
  2312. PDEVICE Device,
  2313. KSTATUS Status,
  2314. PDRIVER Driver,
  2315. ULONG DriverCode,
  2316. PCSTR SourceFile,
  2317. ULONG LineNumber
  2318. );
  2319. /*++
  2320. Routine Description:
  2321. This routine sets a driver specific error code on a given device. This
  2322. problem is preventing a device from making forward progress. Avoid calling
  2323. this function directly, use the non-Ex version.
  2324. Arguments:
  2325. Device - Supplies a pointer to the device with the error.
  2326. Status - Supplies the failure status generated by the error.
  2327. Driver - Supplies a pointer to the driver reporting the error.
  2328. DriverError - Supplies an optional driver specific error code.
  2329. SourceFile - Supplies a pointer to the source file where the problem
  2330. occurred. This is usually automatically generated by the compiler.
  2331. LineNumber - Supplies the line number in the source file where the problem
  2332. occurred. This is usually automatically generated by the compiler.
  2333. Return Value:
  2334. None.
  2335. --*/
  2336. KERNEL_API
  2337. KSTATUS
  2338. IoClearDeviceProblem (
  2339. PDEVICE Device
  2340. );
  2341. /*++
  2342. Routine Description:
  2343. This routine clears any problem code associated with a device, and attempts
  2344. to start the device if it is not already started.
  2345. Arguments:
  2346. Device - Supplies a pointer to the device to clear.
  2347. Return Value:
  2348. STATUS_SUCCESS if the problem was successfully cleared and the start device
  2349. work item was successfully queued (if needed).
  2350. Error code if the start work item needed to be queued and had a problem.
  2351. --*/
  2352. KERNEL_API
  2353. KSTATUS
  2354. IoRegisterDriverFunctions (
  2355. PDRIVER Driver,
  2356. PDRIVER_FUNCTION_TABLE FunctionTable
  2357. );
  2358. /*++
  2359. Routine Description:
  2360. This routine is called by a driver to register its function pointers with
  2361. the system. Drivers cannot be attached to the system until this is
  2362. complete. This routine is usually called by a driver in its entry point.
  2363. This routine should only be called once during the lifetime of a driver.
  2364. Arguments:
  2365. Driver - Supplies a pointer to the driver whose routines are being
  2366. registered.
  2367. FunctionTable - Supplies a pointer to the function pointer table containing
  2368. the drivers dispatch routines.
  2369. Return Value:
  2370. STATUS_SUCCESS on success.
  2371. STATUS_INVALID_PARAMETER if a required parameter or function was not
  2372. supplied.
  2373. --*/
  2374. KERNEL_API
  2375. KSTATUS
  2376. IoAttachDriverToDevice (
  2377. PDRIVER Driver,
  2378. PDEVICE Device,
  2379. PVOID Context
  2380. );
  2381. /*++
  2382. Routine Description:
  2383. This routine is called by a driver to attach itself to a device. Once
  2384. attached, the driver will participate in all IRPs that go through to the
  2385. device. This routine can only be called during a driver's AddDevice routine.
  2386. Arguments:
  2387. Driver - Supplies a pointer to the driver attaching to the device.
  2388. Device - Supplies a pointer to the device to attach to.
  2389. Context - Supplies an optional context pointer that will be passed to the
  2390. driver each time it is called in relation to this device.
  2391. Return Value:
  2392. STATUS_SUCCESS on success.
  2393. STATUS_TOO_EARLY or STATUS_TOO_LATE if the routine was called outside of a
  2394. driver's AddDevice routine.
  2395. STATUS_INSUFFICIENT_RESOURCES if allocations failed.
  2396. --*/
  2397. KERNEL_API
  2398. VOID
  2399. IoDriverAddReference (
  2400. PDRIVER Driver
  2401. );
  2402. /*++
  2403. Routine Description:
  2404. This routine increments the reference count on a driver.
  2405. Arguments:
  2406. Driver - Supplies a pointer to the driver.
  2407. Return Value:
  2408. None.
  2409. --*/
  2410. KERNEL_API
  2411. VOID
  2412. IoDriverReleaseReference (
  2413. PDRIVER Driver
  2414. );
  2415. /*++
  2416. Routine Description:
  2417. This routine decrements the reference count on a driver. This routine
  2418. must be balanced by a previous call to add a reference on the driver.
  2419. Arguments:
  2420. Driver - Supplies a pointer to the driver.
  2421. Return Value:
  2422. None.
  2423. --*/
  2424. KERNEL_API
  2425. KSTATUS
  2426. IoGetIrpStatus (
  2427. PIRP Irp
  2428. );
  2429. /*++
  2430. Routine Description:
  2431. This routine returns the IRP's completion status.
  2432. Arguments:
  2433. Irp - Supplies a pointer to the IRP to query.
  2434. Return Value:
  2435. Returns the IRP completion status. If no driver has completed the IRP,
  2436. STATUS_NOT_HANDLED will be returned (the initialization value put into the
  2437. IRP).
  2438. --*/
  2439. KERNEL_API
  2440. VOID
  2441. IoUpdateIrpStatus (
  2442. PIRP Irp,
  2443. KSTATUS StatusCode
  2444. );
  2445. /*++
  2446. Routine Description:
  2447. This routine updates the IRP's completion status if the current completion
  2448. status indicates success.
  2449. Arguments:
  2450. Irp - Supplies a pointer to the IRP to query.
  2451. StatusCode - Supplies a status code to associate with the completed IRP.
  2452. This will be returned back to the caller requesting the IRP.
  2453. Return Value:
  2454. None.
  2455. --*/
  2456. KERNEL_API
  2457. VOID
  2458. IoCompleteIrp (
  2459. PDRIVER Driver,
  2460. PIRP Irp,
  2461. KSTATUS StatusCode
  2462. );
  2463. /*++
  2464. Routine Description:
  2465. This routine is called by a driver to mark an IRP as completed. This
  2466. function can only be called from a driver's dispatch routine when the
  2467. driver owns the IRP. When the dispatch routine returns, the system will not
  2468. continue to move down the driver stack, but will switch directions and
  2469. move up the stack. Only one driver in the stack should complete the IRP.
  2470. This routine must be called at or below dispatch level.
  2471. Arguments:
  2472. Driver - Supplies a pointer to the driver completing the IRP.
  2473. Irp - Supplies a pointer to the IRP owned by the driver to mark as
  2474. completed.
  2475. StatusCode - Supplies a status code to associated with the completed IRP.
  2476. This will be returned back to the caller requesting the IRP.
  2477. Return Value:
  2478. None.
  2479. --*/
  2480. KERNEL_API
  2481. VOID
  2482. IoPendIrp (
  2483. PDRIVER Driver,
  2484. PIRP Irp
  2485. );
  2486. /*++
  2487. Routine Description:
  2488. This routine is called by a driver to mark an IRP as pending. This function
  2489. can only be called from a driver's dispatch routine when the driver owns
  2490. the IRP. When the dispatch routine returns, the system will not move to the
  2491. next stack location: the driver will continue to own the IRP until it
  2492. marks it completed or continues the IRP. This routine must be called at or
  2493. below dispatch level.
  2494. Arguments:
  2495. Driver - Supplies a pointer to the driver pending the IRP.
  2496. Irp - Supplies a pointer to the IRP owned by the driver to mark as pending.
  2497. Return Value:
  2498. None.
  2499. --*/
  2500. KERNEL_API
  2501. VOID
  2502. IoContinueIrp (
  2503. PDRIVER Driver,
  2504. PIRP Irp
  2505. );
  2506. /*++
  2507. Routine Description:
  2508. This routine is called by a driver to continue processing an IRP that was
  2509. previously marked pending. The driver that pended the IRP will get called
  2510. a second time in the same directon for this IRP. This routine must be
  2511. called at or below dispatch level.
  2512. Arguments:
  2513. Driver - Supplies a pointer to the driver unpending the IRP.
  2514. Irp - Supplies a pointer to the IRP owned by the driver to continue
  2515. processing.
  2516. Return Value:
  2517. None.
  2518. --*/
  2519. KERNEL_API
  2520. PIRP
  2521. IoCreateIrp (
  2522. PDEVICE Device,
  2523. IRP_MAJOR_CODE MajorCode,
  2524. ULONG Flags
  2525. );
  2526. /*++
  2527. Routine Description:
  2528. This routine creates and initializes an IRP. This routine must be called
  2529. at or below dispatch level.
  2530. Arguments:
  2531. Device - Supplies a pointer to the device the IRP will be sent to.
  2532. MajorCode - Supplies the major code of the IRP, which cannot be changed
  2533. once an IRP is allocated (or else disaster ensues).
  2534. Flags - Supplies a bitmask of IRP creation flags. See IRP_FLAG_* for
  2535. definitions.
  2536. Return Value:
  2537. Returns a pointer to the newly allocated IRP on success, or NULL on
  2538. failure.
  2539. --*/
  2540. KERNEL_API
  2541. VOID
  2542. IoDestroyIrp (
  2543. PIRP Irp
  2544. );
  2545. /*++
  2546. Routine Description:
  2547. This routine destroys an IRP, freeing all memory associated with it. This
  2548. routine must be called at or below dispatch level.
  2549. Arguments:
  2550. Irp - Supplies a pointer to the IRP to free.
  2551. Return Value:
  2552. None.
  2553. --*/
  2554. KERNEL_API
  2555. VOID
  2556. IoInitializeIrp (
  2557. PIRP Irp
  2558. );
  2559. /*++
  2560. Routine Description:
  2561. This routine initializes an IRP and prepares it to be sent to a device.
  2562. This routine does not mean that IRPs can be allocated randomly from pool
  2563. and initialized here; IRPs must still be allocated from IoCreateIrp. This
  2564. routine just resets an IRP back to its initialized state.
  2565. Arguments:
  2566. Irp - Supplies a pointer to the initialized IRP to initialize. This IRP
  2567. must already have a valid object header.
  2568. Return Value:
  2569. None.
  2570. --*/
  2571. KERNEL_API
  2572. KSTATUS
  2573. IoSendSynchronousIrp (
  2574. PIRP Irp
  2575. );
  2576. /*++
  2577. Routine Description:
  2578. This routine sends an initialized IRP down the device stack and does not
  2579. return until the IRP completed. This routine must be called at or below
  2580. dispatch level.
  2581. Arguments:
  2582. Irp - Supplies a pointer to the initialized IRP to send. All parameters
  2583. should already be filled out and ready to go.
  2584. Return Value:
  2585. STATUS_SUCCESS if the IRP was actually sent properly. This says nothing of
  2586. the completion status of the IRP, which may have failed spectacularly.
  2587. STATUS_INVALID_PARAMETER if the IRP was not properly initialized.
  2588. STATUS_INSUFFICIENT_RESOURCES if memory could not be allocated.
  2589. --*/
  2590. KERNEL_API
  2591. KSTATUS
  2592. IoPrepareReadWriteIrp (
  2593. PIRP_READ_WRITE IrpReadWrite,
  2594. UINTN Alignment,
  2595. PHYSICAL_ADDRESS MinimumPhysicalAddress,
  2596. PHYSICAL_ADDRESS MaximumPhysicalAddress,
  2597. ULONG Flags
  2598. );
  2599. /*++
  2600. Routine Description:
  2601. This routine prepares the given read/write IRP context for I/O based on the
  2602. given physical address, physical alignment, and flag requirements. It will
  2603. ensure that the IRP's I/O buffer is sufficient and preform any necessary
  2604. flushing that is needed to prepare for the I/O.
  2605. Arguments:
  2606. IrpReadWrite - Supplies a pointer to the IRP read/write context that needs
  2607. to be prepared for data transfer.
  2608. Alignment - Supplies the required physical alignment of the I/O buffer, in
  2609. bytes.
  2610. MinimumPhysicalAddress - Supplies the minimum allowed physical address for
  2611. the I/O buffer.
  2612. MaximumPhysicalAddress - Supplies the maximum allowed physical address for
  2613. the I/O buffer.
  2614. Flags - Supplies a bitmask of flags for the preparation. See
  2615. IRP_READ_WRITE_FLAG_* for definitions.
  2616. Return Value:
  2617. Status code.
  2618. --*/
  2619. KERNEL_API
  2620. KSTATUS
  2621. IoCompleteReadWriteIrp (
  2622. PIRP_READ_WRITE IrpReadWrite,
  2623. ULONG Flags
  2624. );
  2625. /*++
  2626. Routine Description:
  2627. This routine handles read/write IRP completion. It will perform any
  2628. necessary flushes based on the type of I/O (as indicated by the flags) and
  2629. destroy any temporary I/O buffers created for the operation during the
  2630. prepare step.
  2631. Arguments:
  2632. IrpReadWrite - Supplies a pointer to the read/write context for the
  2633. completed IRP.
  2634. Flags - Supplies a bitmask of flags for the completion. See
  2635. IRP_READ_WRITE_FLAG_* for definitions.
  2636. Return Value:
  2637. Status code.
  2638. --*/
  2639. KERNEL_API
  2640. KSTATUS
  2641. IoCreateInterface (
  2642. PUUID InterfaceUuid,
  2643. PDEVICE Device,
  2644. PVOID InterfaceBuffer,
  2645. ULONG InterfaceBufferSize
  2646. );
  2647. /*++
  2648. Routine Description:
  2649. This routine creates a device interface. Interfaces start out disabled. The
  2650. Interface/device pair must be unique, there cannot be two interfaces for
  2651. the same UUID and device.
  2652. Arguments:
  2653. Interface - Supplies a pointer to the UUID identifying the interface.
  2654. Device - Supplies a pointer to the device exposing the interface.
  2655. InterfaceBuffer - Supplies a pointer to the interface buffer.
  2656. InterfaceBufferSize - Supplies the size of the interface buffer, in bytes.
  2657. Return Value:
  2658. STATUS_SUCCESS on success.
  2659. STATUS_INVALID_PARAMETER if the interface or device were not specified.
  2660. STATUS_NO_MEMORY if allocations could not be made.
  2661. STATUS_DUPLICATE_ENTRY if an interface already exists for this device.
  2662. --*/
  2663. KERNEL_API
  2664. KSTATUS
  2665. IoDestroyInterface (
  2666. PUUID InterfaceUuid,
  2667. PDEVICE Device,
  2668. PVOID InterfaceBuffer
  2669. );
  2670. /*++
  2671. Routine Description:
  2672. This routine destroys a previously created interface. All parties
  2673. registered for notifications on this interface will be notified that the
  2674. interface is going down.
  2675. Arguments:
  2676. InterfaceUuid - Supplies a pointer to the UUID identifying the interface.
  2677. Device - Supplies a pointer to the device supplied on registration.
  2678. InterfaceBuffer - Supplies a pointer to the interface buffer for the
  2679. specific interface to tear down. This needs to match the interface
  2680. buffer used when the interface was created.
  2681. Return Value:
  2682. STATUS_SUCCESS on success.
  2683. STATUS_INVALID_PARAMETER if the interface or device is invalid.
  2684. STATUS_NOT_FOUND if the interface could not be found.
  2685. --*/
  2686. KERNEL_API
  2687. KSTATUS
  2688. IoRegisterForInterfaceNotifications (
  2689. PUUID Interface,
  2690. PINTERFACE_NOTIFICATION_CALLBACK CallbackRoutine,
  2691. PDEVICE Device,
  2692. PVOID Context,
  2693. BOOL NotifyForExisting
  2694. );
  2695. /*++
  2696. Routine Description:
  2697. This routine registers the given handler to be notified when the given
  2698. interface arrives or disappears. Callers are notified of both events.
  2699. Callers will be notified for all interface arrivals and removals of the
  2700. given interface.
  2701. Arguments:
  2702. Interface - Supplies a pointer to the UUID identifying the interface.
  2703. CallbackRoutine - Supplies a pointer to the callback routine to notify
  2704. when an interface arrives or is removed.
  2705. Device - Supplies an optional pointer to a device. If this device is
  2706. non-NULL, then interface notifications will be restricted to the given
  2707. device.
  2708. Context - Supplies an optional pointer to a context that will be passed
  2709. back to the caller during notifications.
  2710. NotifyForExisting - Supplies TRUE if the caller would like an arrival
  2711. notification for every pre-existing interface, or FALSE if the caller
  2712. only wants to be notified about future arrivals. The caller will be
  2713. notified about ALL removals no matter the state of this flag.
  2714. Return Value:
  2715. STATUS_SUCCESS on success.
  2716. STATUS_INVALID_PARAMETER if an invalid interface or callback routine was
  2717. supplied.
  2718. STATUS_NO_MEMORY if memory could not be allocated to satisfy the request.
  2719. STATUS_INSUFFICIENT_RESOURCES if general resources could not be allocated to
  2720. satisfy the request.
  2721. STATUS_DUPLICATE_ENTRY if the given routine is already registered for
  2722. notification on the device.
  2723. --*/
  2724. KERNEL_API
  2725. KSTATUS
  2726. IoUnregisterForInterfaceNotifications (
  2727. PUUID Interface,
  2728. PINTERFACE_NOTIFICATION_CALLBACK CallbackRoutine,
  2729. PDEVICE Device,
  2730. PVOID Context
  2731. );
  2732. /*++
  2733. Routine Description:
  2734. This routine de-registers the given handler from receiving device interface
  2735. notifications. Once this routine returns, the given handler will not
  2736. receive notifications for the given interface.
  2737. Arguments:
  2738. Interface - Supplies a pointer to the UUID identifying the interface.
  2739. CallbackRoutine - Supplies a pointer to the callback routine supplied on
  2740. registration for notifications.
  2741. Device - Supplies a pointer to the device supplied upon registration.
  2742. Context - Supplies a pointer to the context supplied upon registration.
  2743. Return Value:
  2744. STATUS_SUCCESS on success.
  2745. STATUS_INVALID_PARAMETER if an invalid interface or callback routine was
  2746. supplied.
  2747. STATUS_NOT_FOUND if no interface listener was found for the given callback
  2748. routine on the given UUID.
  2749. --*/
  2750. KERNEL_API
  2751. KSTATUS
  2752. IoRegisterFileSystem (
  2753. PDRIVER Driver
  2754. );
  2755. /*++
  2756. Routine Description:
  2757. This routine registers the given driver as a file system driver.
  2758. Arguments:
  2759. Driver - Supplies a pointer to the driver registering the file system
  2760. support.
  2761. Return Value:
  2762. Status code.
  2763. --*/
  2764. KERNEL_API
  2765. KSTATUS
  2766. IoOpen (
  2767. BOOL FromKernelMode,
  2768. PIO_HANDLE Directory,
  2769. PCSTR Path,
  2770. ULONG PathLength,
  2771. ULONG Access,
  2772. ULONG Flags,
  2773. FILE_PERMISSIONS CreatePermissions,
  2774. PIO_HANDLE *Handle
  2775. );
  2776. /*++
  2777. Routine Description:
  2778. This routine opens a file, device, pipe, or other I/O object.
  2779. Arguments:
  2780. FromKernelMode - Supplies a boolean indicating the request is coming from
  2781. kernel mode.
  2782. Directory - Supplies an optional pointer to an open handle to a directory
  2783. for relative paths. Supply NULL to use the current working directory.
  2784. Path - Supplies a pointer to the path to open.
  2785. PathLength - Supplies the length of the path buffer in bytes, including the
  2786. null terminator.
  2787. Access - Supplies the desired access permissions to the object. See
  2788. IO_ACCESS_* definitions.
  2789. Flags - Supplies a bitfield of flags governing the behavior of the handle.
  2790. See OPEN_FLAG_* definitions.
  2791. CreatePermissions - Supplies the permissions to apply for a created file.
  2792. Handle - Supplies a pointer where a pointer to the open I/O handle will be
  2793. returned on success.
  2794. Return Value:
  2795. Status code.
  2796. --*/
  2797. KERNEL_API
  2798. KSTATUS
  2799. IoOpenDevice (
  2800. PDEVICE Device,
  2801. ULONG Access,
  2802. ULONG Flags,
  2803. PIO_HANDLE *Handle,
  2804. PULONG IoOffsetAlignment,
  2805. PULONG IoSizeAlignment,
  2806. PULONGLONG IoCapacity
  2807. );
  2808. /*++
  2809. Routine Description:
  2810. This routine opens a device. If the given device is the device meant to
  2811. hold the page file, this routine does not prepare the returned I/O handle
  2812. for paging operations.
  2813. Arguments:
  2814. Device - Supplies a pointer to a device to open.
  2815. Access - Supplies the desired access permissions to the object. See
  2816. IO_ACCESS_* definitions.
  2817. Flags - Supplies a bitfield of flags governing the behavior of the handle.
  2818. See OPEN_FLAG_* definitions.
  2819. Handle - Supplies a pointer that receives the open I/O handle.
  2820. IoOffsetAlignment - Supplies a pointer where the alignment requirement in
  2821. bytes will be returned for all I/O offsets.
  2822. IoSizeAlignment - Supplies a pointer where the alignment requirement for
  2823. the size of all transfers (the block size) will be returned for all
  2824. I/O requests.
  2825. IoCapacity - Supplies the device's total size, in bytes.
  2826. Return Value:
  2827. Status code.
  2828. --*/
  2829. KERNEL_API
  2830. BOOL
  2831. IoIsPagingDevice (
  2832. PDEVICE Device
  2833. );
  2834. /*++
  2835. Routine Description:
  2836. This routine determines whether or not paging is enabled on the given
  2837. device.
  2838. Arguments:
  2839. Device - Supplies a pointer to a device.
  2840. Return Value:
  2841. Returns TRUE if paging is enabled on the device, or FALSE otherwise.
  2842. --*/
  2843. KERNEL_API
  2844. KSTATUS
  2845. IoClose (
  2846. PIO_HANDLE IoHandle
  2847. );
  2848. /*++
  2849. Routine Description:
  2850. This routine closes a file or device.
  2851. Arguments:
  2852. IoHandle - Supplies a pointer to the I/O handle returned when the file was
  2853. opened.
  2854. Return Value:
  2855. Status code. Close operations can fail if their associated flushes to
  2856. the file system fail.
  2857. --*/
  2858. KERNEL_API
  2859. KSTATUS
  2860. IoRead (
  2861. PIO_HANDLE Handle,
  2862. PIO_BUFFER IoBuffer,
  2863. UINTN SizeInBytes,
  2864. ULONG Flags,
  2865. ULONG TimeoutInMilliseconds,
  2866. PUINTN BytesCompleted
  2867. );
  2868. /*++
  2869. Routine Description:
  2870. This routine reads from an I/O object.
  2871. Arguments:
  2872. Handle - Supplies the open I/O handle.
  2873. IoBuffer - Supplies a pointer to an I/O buffer where the read data will be
  2874. returned on success.
  2875. SizeInBytes - Supplies the number of bytes to read.
  2876. Flags - Supplies flags regarding the I/O operation. See IO_FLAG_*
  2877. definitions.
  2878. TimeoutInMilliseconds - Supplies the number of milliseconds that the I/O
  2879. operation should be waited on before timing out. Use
  2880. WAIT_TIME_INDEFINITE to wait forever on the I/O.
  2881. BytesCompleted - Supplies the a pointer where the number of bytes actually
  2882. read will be returned.
  2883. Return Value:
  2884. Status code. A failing status code does not necessarily mean no I/O made it
  2885. in or out. Check the bytes completed value to find out how much occurred.
  2886. --*/
  2887. KERNEL_API
  2888. KSTATUS
  2889. IoWrite (
  2890. PIO_HANDLE Handle,
  2891. PIO_BUFFER IoBuffer,
  2892. UINTN SizeInBytes,
  2893. ULONG Flags,
  2894. ULONG TimeoutInMilliseconds,
  2895. PUINTN BytesCompleted
  2896. );
  2897. /*++
  2898. Routine Description:
  2899. This routine writes to an I/O object.
  2900. Arguments:
  2901. Handle - Supplies the open I/O handle.
  2902. IoBuffer - Supplies a pointer to an I/O buffer containing the data to write.
  2903. SizeInBytes - Supplies the number of bytes to write.
  2904. Flags - Supplies flags regarding the I/O operation. See IO_FLAG_*
  2905. definitions.
  2906. TimeoutInMilliseconds - Supplies the number of milliseconds that the I/O
  2907. operation should be waited on before timing out. Use
  2908. WAIT_TIME_INDEFINITE to wait forever on the I/O.
  2909. BytesCompleted - Supplies the a pointer where the number of bytes actually
  2910. written will be returned.
  2911. Return Value:
  2912. Status code. A failing status code does not necessarily mean no I/O made it
  2913. in or out. Check the bytes completed value to find out how much occurred.
  2914. --*/
  2915. KERNEL_API
  2916. KSTATUS
  2917. IoReadAtOffset (
  2918. PIO_HANDLE Handle,
  2919. PIO_BUFFER IoBuffer,
  2920. IO_OFFSET Offset,
  2921. UINTN SizeInBytes,
  2922. ULONG Flags,
  2923. ULONG TimeoutInMilliseconds,
  2924. PUINTN BytesCompleted,
  2925. PIRP Irp
  2926. );
  2927. /*++
  2928. Routine Description:
  2929. This routine reads from an I/O object at a specific offset.
  2930. Arguments:
  2931. Handle - Supplies the open I/O handle.
  2932. IoBuffer - Supplies a pointer to an I/O buffer where the read data will be
  2933. returned on success.
  2934. Offset - Supplies the offset from the beginning of the file or device where
  2935. the I/O should be done.
  2936. SizeInBytes - Supplies the number of bytes to read.
  2937. Flags - Supplies flags regarding the I/O operation. See IO_FLAG_*
  2938. definitions.
  2939. TimeoutInMilliseconds - Supplies the number of milliseconds that the I/O
  2940. operation should be waited on before timing out. Use
  2941. WAIT_TIME_INDEFINITE to wait forever on the I/O.
  2942. BytesCompleted - Supplies the a pointer where the number of bytes actually
  2943. read will be returned.
  2944. Irp - Supplies a pointer to the IRP to use for this I/O. This is required
  2945. when doing operations on the page file.
  2946. Return Value:
  2947. Status code. A failing status code does not necessarily mean no I/O made it
  2948. in or out. Check the bytes completed value to find out how much occurred.
  2949. --*/
  2950. KERNEL_API
  2951. KSTATUS
  2952. IoWriteAtOffset (
  2953. PIO_HANDLE Handle,
  2954. PIO_BUFFER IoBuffer,
  2955. IO_OFFSET Offset,
  2956. UINTN SizeInBytes,
  2957. ULONG Flags,
  2958. ULONG TimeoutInMilliseconds,
  2959. PUINTN BytesCompleted,
  2960. PIRP Irp
  2961. );
  2962. /*++
  2963. Routine Description:
  2964. This routine writes to an I/O object at a specific offset.
  2965. Arguments:
  2966. Handle - Supplies the open I/O handle.
  2967. IoBuffer - Supplies a pointer to an I/O buffer containing the data to write.
  2968. Offset - Supplies the offset from the beginning of the file or device where
  2969. the I/O should be done.
  2970. SizeInBytes - Supplies the number of bytes to write.
  2971. Flags - Supplies flags regarding the I/O operation. See IO_FLAG_*
  2972. definitions.
  2973. TimeoutInMilliseconds - Supplies the number of milliseconds that the I/O
  2974. operation should be waited on before timing out. Use
  2975. WAIT_TIME_INDEFINITE to wait forever on the I/O.
  2976. BytesCompleted - Supplies the a pointer where the number of bytes actually
  2977. written will be returned.
  2978. Irp - Supplies a pointer to the IRP to use for this I/O. This is required
  2979. when doing operations on the page file.
  2980. Return Value:
  2981. Status code. A failing status code does not necessarily mean no I/O made it
  2982. in or out. Check the bytes completed value to find out how much occurred.
  2983. --*/
  2984. KERNEL_API
  2985. KSTATUS
  2986. IoFlush (
  2987. PIO_HANDLE Handle,
  2988. IO_OFFSET Offset,
  2989. ULONGLONG Size,
  2990. ULONG Flags
  2991. );
  2992. /*++
  2993. Routine Description:
  2994. This routine flushes I/O data to its appropriate backing device.
  2995. Arguments:
  2996. Handle - Supplies an open I/O handle. This parameters is not required if
  2997. the FLUSH_FLAG_ALL flag is set.
  2998. Offset - Supplies the offset from the beginning of the file or device where
  2999. the flush should be done.
  3000. Size - Supplies the size, in bytes, of the region to flush. Supply a value
  3001. of -1 to flush from the given offset to the end of the file.
  3002. Flags - Supplies flags regarding the flush operation. See FLUSH_FLAG_*
  3003. definitions.
  3004. Return Value:
  3005. Status code.
  3006. --*/
  3007. KERNEL_API
  3008. KSTATUS
  3009. IoSeek (
  3010. PIO_HANDLE Handle,
  3011. SEEK_COMMAND SeekCommand,
  3012. IO_OFFSET Offset,
  3013. PIO_OFFSET NewOffset
  3014. );
  3015. /*++
  3016. Routine Description:
  3017. This routine seeks to the given position in a file. This routine is only
  3018. relevant for normal file or block based devices.
  3019. Arguments:
  3020. Handle - Supplies the open I/O handle.
  3021. SeekCommand - Supplies the reference point for the seek offset. Usual
  3022. reference points are the beginning of the file, current file position,
  3023. and the end of the file.
  3024. Offset - Supplies the offset from the reference point to move in bytes.
  3025. NewOffset - Supplies an optional pointer where the file position after the
  3026. move will be returned on success.
  3027. Return Value:
  3028. Status code.
  3029. --*/
  3030. KERNEL_API
  3031. KSTATUS
  3032. IoGetFileSize (
  3033. PIO_HANDLE Handle,
  3034. PULONGLONG FileSize
  3035. );
  3036. /*++
  3037. Routine Description:
  3038. This routine returns the current size of the given file or block device.
  3039. Arguments:
  3040. Handle - Supplies the open file handle.
  3041. FileSize - Supplies a pointer where the file size will be returned on
  3042. success.
  3043. Return Value:
  3044. Status code.
  3045. --*/
  3046. KERNEL_API
  3047. KSTATUS
  3048. IoGetFileInformation (
  3049. PIO_HANDLE Handle,
  3050. PFILE_PROPERTIES FileProperties
  3051. );
  3052. /*++
  3053. Routine Description:
  3054. This routine gets the file properties for the given I/O handle.
  3055. Arguments:
  3056. Handle - Supplies the open file handle.
  3057. FileProperties - Supplies a pointer where the file properties will be
  3058. returned on success.
  3059. Return Value:
  3060. Status code.
  3061. --*/
  3062. KERNEL_API
  3063. KSTATUS
  3064. IoSetFileInformation (
  3065. BOOL FromKernelMode,
  3066. PIO_HANDLE Handle,
  3067. PSET_FILE_INFORMATION Request
  3068. );
  3069. /*++
  3070. Routine Description:
  3071. This routine sets the file properties for the given I/O handle.
  3072. Only some properties can be set by this routine.
  3073. Arguments:
  3074. FromKernelMode - Supplies a boolean indicating whether the request
  3075. originated from user mode (FALSE) or kernel mode (TRUE). Kernel mode
  3076. requests bypass permission checks.
  3077. Handle - Supplies the open file handle.
  3078. Request - Supplies a pointer to the get/set information request.
  3079. Return Value:
  3080. Status code.
  3081. --*/
  3082. KERNEL_API
  3083. KSTATUS
  3084. IoDelete (
  3085. BOOL FromKernelMode,
  3086. PIO_HANDLE Directory,
  3087. PCSTR Path,
  3088. ULONG PathSize,
  3089. ULONG Flags
  3090. );
  3091. /*++
  3092. Routine Description:
  3093. This routine attempts to delete the object at the given path. If the path
  3094. points to a directory, the directory must be empty. If the path points to
  3095. a file object or shared memory object, its hard link count is decremented.
  3096. If the hard link count reaches zero and no processes have the object open,
  3097. the contents of the object are destroyed. If processes have open handles to
  3098. the object, the destruction of the object contents are deferred until the
  3099. last handle to the old file is closed. If the path points to a symbolic
  3100. link, the link itself is removed and not the destination. The removal of
  3101. the entry from the directory is immediate.
  3102. Arguments:
  3103. FromKernelMode - Supplies a boolean indicating the request is coming from
  3104. kernel mode.
  3105. Directory - Supplies an optional pointer to an open handle to a directory
  3106. for relative paths. Supply NULL to use the current working directory.
  3107. Path - Supplies a pointer to the path to delete.
  3108. PathSize - Supplies the length of the path buffer in bytes, including the
  3109. null terminator.
  3110. Flags - Supplies a bitfield of flags. See DELETE_FLAG_* definitions.
  3111. Return Value:
  3112. Status code.
  3113. --*/
  3114. KERNEL_API
  3115. KSTATUS
  3116. IoRename (
  3117. BOOL FromKernelMode,
  3118. PIO_HANDLE SourceStartDirectory,
  3119. PCSTR SourcePath,
  3120. ULONG SourcePathSize,
  3121. PIO_HANDLE DestinationStartDirectory,
  3122. PCSTR DestinationPath,
  3123. ULONG DestinationPathSize
  3124. );
  3125. /*++
  3126. Routine Description:
  3127. This routine attempts to rename the object at the given path. This routine
  3128. operates on symbolic links themselves, not the destinations of symbolic
  3129. links. If the source and destination paths are equal, this routine will do
  3130. nothing and return successfully. If the source path is not a directory, the
  3131. destination path must not be a directory. If the destination file exists,
  3132. it will be deleted. The caller must have write access in both the old and
  3133. new directories. If the source path is a directory, the destination path
  3134. must not exist or be an empty directory. The destination path must not have
  3135. a path prefix of the source (ie it's illegal to move /my/path into
  3136. /my/path/stuff).
  3137. Arguments:
  3138. FromKernelMode - Supplies a boolean indicating the request is coming from
  3139. kernel mode.
  3140. SourceStartDirectory - Supplies an optional pointer to a handle to the
  3141. directory to start at for relative source paths. If the source path is
  3142. not relative, this parameter is ignored. If this is not supplied, then
  3143. the current working directory of the process is used.
  3144. SourcePath - Supplies a pointer to the path of the file to rename.
  3145. SourcePathSize - Supplies the length of the source path buffer in bytes,
  3146. including the null terminator.
  3147. DestinationStartDirectory - Supplies an optional pointer to the directory
  3148. to start at for relative destination paths. If the destination path is
  3149. not relative, this parameter is ignored. If this is not supplied, then
  3150. the current working directory of the process is used.
  3151. DestinationPath - Supplies a pointer to the path to rename the file to.
  3152. DestinationPathSize - Supplies the size of the destination path buffer in
  3153. bytes, including the null terminator.
  3154. Return Value:
  3155. Status code.
  3156. --*/
  3157. KERNEL_API
  3158. KSTATUS
  3159. IoCreateSymbolicLink (
  3160. BOOL FromKernelMode,
  3161. PIO_HANDLE Directory,
  3162. PCSTR LinkName,
  3163. ULONG LinkNameSize,
  3164. PSTR LinkTarget,
  3165. ULONG LinkTargetSize
  3166. );
  3167. /*++
  3168. Routine Description:
  3169. This routine attempts to create a new symbolic link at the given path.
  3170. The target of the symbolic link is not required to exist. The link path
  3171. must not already exist.
  3172. Arguments:
  3173. FromKernelMode - Supplies a boolean indicating the request is coming from
  3174. kernel mode.
  3175. Directory - Supplies an optional pointer to an open handle to a directory
  3176. for relative paths. Supply NULL to use the current working directory.
  3177. LinkName - Supplies a pointer to the path of the new link to create.
  3178. LinkNameSize - Supplies the length of the link name buffer in bytes,
  3179. including the null terminator.
  3180. LinkTarget - Supplies a pointer to the target of the link, the location the
  3181. link points to.
  3182. LinkTargetSize - Supplies the size of the link target buffer in bytes,
  3183. including the null terminator.
  3184. Return Value:
  3185. Status code.
  3186. --*/
  3187. KERNEL_API
  3188. KSTATUS
  3189. IoReadSymbolicLink (
  3190. PIO_HANDLE Handle,
  3191. ULONG AllocationTag,
  3192. PSTR *LinkTarget,
  3193. PULONG LinkTargetSize
  3194. );
  3195. /*++
  3196. Routine Description:
  3197. This routine reads the destination of a given open symbolic link, and
  3198. returns the information in a newly allocated buffer. It is the caller's
  3199. responsibility to free this memory from paged pool.
  3200. Arguments:
  3201. Handle - Supplies the open file handle to the symbolic link itself.
  3202. AllocationTag - Supplies the paged pool tag to use when creating the
  3203. allocation.
  3204. LinkTarget - Supplies a pointer where a newly allocated string will be
  3205. returned on success containing the target the link is pointing at.
  3206. LinkTargetSize - Supplies a pointer where the size of the link target in
  3207. bytes (including the null terminator) will be returned.
  3208. Return Value:
  3209. STATUS_SUCCESS if the link target was successfully returned.
  3210. STATUS_INSUFFICIENT_RESOURCES on allocation failure.
  3211. STATUS_NOT_READY if the contents of the symbolic link are not valid.
  3212. Other status codes on other failures.
  3213. --*/
  3214. KERNEL_API
  3215. KSTATUS
  3216. IoUserControl (
  3217. PIO_HANDLE Handle,
  3218. ULONG MinorCode,
  3219. BOOL FromKernelMode,
  3220. PVOID ContextBuffer,
  3221. UINTN ContextBufferSize
  3222. );
  3223. /*++
  3224. Routine Description:
  3225. This routine performs a user control operation.
  3226. Arguments:
  3227. Handle - Supplies the open file handle.
  3228. MinorCode - Supplies the minor code of the request.
  3229. FromKernelMode - Supplies a boolean indicating whether or not this request
  3230. (and the buffer associated with it) originates from user mode (FALSE)
  3231. or kernel mode (TRUE).
  3232. ContextBuffer - Supplies a pointer to the context buffer allocated by the
  3233. caller for the request.
  3234. ContextBufferSize - Supplies the size of the supplied context buffer.
  3235. Return Value:
  3236. Status code.
  3237. --*/
  3238. KERNEL_API
  3239. KSTATUS
  3240. IoMount (
  3241. BOOL FromKernelMode,
  3242. PCSTR MountPointPath,
  3243. ULONG MountPointPathSize,
  3244. PCSTR TargetPath,
  3245. ULONG TargetPathSize,
  3246. ULONG MountFlags,
  3247. ULONG AccessFlags
  3248. );
  3249. /*++
  3250. Routine Description:
  3251. This routine attempts to mount the given target on the given mount point.
  3252. Arguments:
  3253. FromKernelMode - Supplies a boolean indicating the request is coming from
  3254. kernel mode.
  3255. MountPointPath - Supplies a pointer to the string containing the path to
  3256. where the target is to be mounted.
  3257. MountPointPathSize - Supplies the size of the mount point path string in
  3258. bytes, including the null terminator.
  3259. TargetPath - Supplies a pointer to the string containing the path to the
  3260. target file, directory, volume, pipe, socket, or device that is to be
  3261. mounted.
  3262. TargetPathSize - Supplies the size of the target path string in bytes,
  3263. including the null terminator.
  3264. MountFlags - Supplies the flags associated with the mount operation. See
  3265. MOUNT_FLAG_* for definitions.
  3266. AccessFlags - Supplies the flags associated with the mount point's access
  3267. permissions. See IO_ACCESS_FLAG_* for definitions.
  3268. Return Value:
  3269. Status code.
  3270. --*/
  3271. KERNEL_API
  3272. KSTATUS
  3273. IoUnmount (
  3274. BOOL FromKernelMode,
  3275. PCSTR MountPointPath,
  3276. ULONG MountPointPathSize,
  3277. ULONG MountFlags,
  3278. ULONG AccessFlags
  3279. );
  3280. /*++
  3281. Routine Description:
  3282. This routine attempts to remove a mount point at the given path.
  3283. Arguments:
  3284. FromKernelMode - Supplies a boolean indicating the request is coming from
  3285. kernel mode.
  3286. MountPointPath - Supplies a pointer to the string containing the path to
  3287. where the unmount should take place.
  3288. MountPointPathSize - Supplies the size of the mount point path string in
  3289. bytes, including the null terminator.
  3290. MountFlags - Supplies the flags associated with the mount operation. See
  3291. MOUNT_FLAG_* for definitions.
  3292. AccessFlags - Supplies the flags associated with the mount point's access
  3293. permissions. See IO_ACCESS_FLAG_* for definitions.
  3294. Return Value:
  3295. Status code.
  3296. --*/
  3297. KERNEL_API
  3298. KSTATUS
  3299. IoGetMountPoints (
  3300. PVOID Buffer,
  3301. PUINTN BufferSize
  3302. );
  3303. /*++
  3304. Routine Description:
  3305. This routine returns the list of mount points for the current process,
  3306. filling the supplied buffer with the data.
  3307. Arguments:
  3308. Buffer - Supplies a pointer to a buffer that receives the mount point data.
  3309. BufferSize - Supplies a pointer to the size of the buffer. Upon return this
  3310. either holds the number of bytes actually used or if the buffer is
  3311. to small, it receives the expected buffer size.
  3312. Return Value:
  3313. Status code.
  3314. --*/
  3315. VOID
  3316. IoMountPointAddReference (
  3317. PMOUNT_POINT MountPoint
  3318. );
  3319. /*++
  3320. Routine Description:
  3321. This routine increments the reference count for the given mount point.
  3322. Arguments:
  3323. MountPoint - Supplies a pointer to a mount point.
  3324. Return Value:
  3325. None.
  3326. --*/
  3327. VOID
  3328. IoMountPointReleaseReference (
  3329. PMOUNT_POINT MountPoint
  3330. );
  3331. /*++
  3332. Routine Description:
  3333. This routine decrements the reference count for the given mount point.
  3334. Arguments:
  3335. MountPoint - Supplies a pointer to a mount point.
  3336. Return Value:
  3337. None.
  3338. --*/
  3339. KERNEL_API
  3340. KSTATUS
  3341. IoGetDevice (
  3342. PIO_HANDLE Handle,
  3343. PDEVICE *Device
  3344. );
  3345. /*++
  3346. Routine Description:
  3347. This routine returns the actual device backing the given I/O object. Not
  3348. all I/O objects are actually backed by a single device. For file and
  3349. directory objects, this routine will return a pointer to the volume.
  3350. Arguments:
  3351. Handle - Supplies the open file handle.
  3352. Device - Supplies a pointer where the underlying I/O device will be
  3353. returned.
  3354. Return Value:
  3355. Status code.
  3356. --*/
  3357. KERNEL_API
  3358. BOOL
  3359. IoIsPageFileAccessSupported (
  3360. PIO_HANDLE Handle
  3361. );
  3362. /*++
  3363. Routine Description:
  3364. This routine determines whether or not page file access is supported on the
  3365. given handle.
  3366. Arguments:
  3367. Handle - Supplies a pointer to the I/O handle.
  3368. Return Value:
  3369. Returns TRUE if the handle supports page file I/O, or FALSE otherwise.
  3370. --*/
  3371. KERNEL_API
  3372. KSTATUS
  3373. IoGetGlobalStatistics (
  3374. PIO_GLOBAL_STATISTICS Statistics
  3375. );
  3376. /*++
  3377. Routine Description:
  3378. This routine returns a snap of the global I/O statistics counters.
  3379. Arguments:
  3380. Statistics - Supplies a pointer to the global I/O statistics.
  3381. Return Value:
  3382. STATUS_SUCCESS on success.
  3383. STATUS_INVALID_PARAMETER if the version is less than
  3384. IO_GLOBAL_STATISTICS_VERSION.
  3385. --*/
  3386. KERNEL_API
  3387. KSTATUS
  3388. IoGetFileBlockInformation (
  3389. PIO_HANDLE Handle,
  3390. PFILE_BLOCK_INFORMATION *FileBlockInformation
  3391. );
  3392. /*++
  3393. Routine Description:
  3394. This routine gets a list of logical block offsets for the given file or
  3395. partition, comprising the runs of contiguous disk space taken up by the
  3396. file or partition.
  3397. Arguments:
  3398. Handle - Supplies an I/O handle for the file or partition.
  3399. FileBlockInformation - Supplies a pointer that receives a pointer to the
  3400. block information for the file or partition. If this is non-null and a
  3401. partition is queried, then the partition will update the offsets in the
  3402. block information to be logical block offsets for the parent disk.
  3403. Return Value:
  3404. Status code.
  3405. --*/
  3406. KERNEL_API
  3407. VOID
  3408. IoDestroyFileBlockInformation (
  3409. PFILE_BLOCK_INFORMATION FileBlockInformation
  3410. );
  3411. /*++
  3412. Routine Description:
  3413. This routine destroys file block information for a file or partition.
  3414. Arguments:
  3415. FileBlockInformation - Supplies a pointer to file block information to be
  3416. destroyed.
  3417. Return Value:
  3418. Status code.
  3419. --*/
  3420. KSTATUS
  3421. IoWriteFileBlocks (
  3422. PFILE_BLOCK_IO_CONTEXT FileContext,
  3423. PIO_BUFFER IoBuffer,
  3424. ULONGLONG Offset,
  3425. UINTN SizeInBytes,
  3426. PUINTN BytesCompleted
  3427. );
  3428. /*++
  3429. Routine Description:
  3430. This routine write data directly to a file's disk blocks, bypassing the
  3431. filesystem. It is meant for critical code paths, such as writing out the
  3432. crash dump file during a system failure.
  3433. Arguments:
  3434. FileContext - Supplies a pointer to the file block context, including the
  3435. file's block information, the device's block level I/O routines and
  3436. block information.
  3437. IoBuffer - Supplies a pointer to an I/O buffer with the data to write.
  3438. Offset - Supplies the offset, in bytes, into the file where the data is to
  3439. be written.
  3440. SizeInBytes - Supplies the size of the data to write, in bytes.
  3441. BytesCompleted - Supplies a pointer that receives the total number of bytes
  3442. written to the disk.
  3443. Return Value:
  3444. Status code.
  3445. --*/
  3446. KERNEL_API
  3447. KSTATUS
  3448. IoLoadFile (
  3449. PCSTR Path,
  3450. ULONG PathLength,
  3451. PLOAD_FILE_COMPLETION_ROUTINE CompletionRoutine,
  3452. PVOID CompletionContext
  3453. );
  3454. /*++
  3455. Routine Description:
  3456. This routine asynchronously loads the file at the given path. The path can
  3457. either be absolute or relative. For the kernel process, relative paths are
  3458. in relative to the system volume's drivers directory. The supplied
  3459. completion routine is invoked when the load finishes.
  3460. Arguments:
  3461. Path - Supplies a pointer to the path to the file. It can either be an
  3462. absolute path or a path relative to the system partition's drivers
  3463. directory.
  3464. PathLength - Supplies the length of the path buffer in bytes, including the
  3465. null terminator.
  3466. CompletionRoutine - Supplies a pointer to the callback routine to notify
  3467. when the load is complete.
  3468. CompletionContext - Supplies a pointer to an opaque context that will be
  3469. passed to the completion routine along with the loaded file.
  3470. Return Value:
  3471. Status code.
  3472. --*/
  3473. KERNEL_API
  3474. VOID
  3475. IoUnloadFile (
  3476. PLOADED_FILE File
  3477. );
  3478. /*++
  3479. Routine Description:
  3480. This routine unloads the given file.
  3481. Arguments:
  3482. File - Supplies a pointer to the file to unload.
  3483. Return Value:
  3484. None.
  3485. --*/
  3486. KERNEL_API
  3487. KSTATUS
  3488. IoCreatePipe (
  3489. BOOL FromKernelMode,
  3490. PIO_HANDLE Directory,
  3491. PCSTR Path,
  3492. ULONG PathLength,
  3493. ULONG OpenFlags,
  3494. FILE_PERMISSIONS CreatePermissions,
  3495. PIO_HANDLE *ReadHandle,
  3496. PIO_HANDLE *WriteHandle
  3497. );
  3498. /*++
  3499. Routine Description:
  3500. This routine creates and opens a new pipe.
  3501. Arguments:
  3502. FromKernelMode - Supplies a boolean indicating whether this request is
  3503. originating from kernel mode (and should use the root path as a base)
  3504. or user mode.
  3505. Directory - Supplies an optional pointer to an open handle to a directory
  3506. for relative paths. Supply NULL to use the current working directory.
  3507. Path - Supplies an optional pointer to the path to open.
  3508. PathLength - Supplies the length of the path buffer in bytes, including the
  3509. null terminator.
  3510. OpenFlags - Supplies the open flags for the pipe. See OPEN_FLAG_*
  3511. definitions. OPEN_FLAG_CREATE and OPEN_FLAG_FAIL_IF_EXISTS are
  3512. automatically applied.
  3513. CreatePermissions - Supplies the permissions to apply to the created pipe.
  3514. ReadHandle - Supplies a pointer where a handle to the read side of the pipe
  3515. will be returned.
  3516. WriteHandle - Supplies a pointer where a handle to the write side of the
  3517. pipe will be returned.
  3518. Return Value:
  3519. Status code.
  3520. --*/
  3521. KERNEL_API
  3522. KSTATUS
  3523. IoCreateTerminal (
  3524. BOOL FromKernelMode,
  3525. PIO_HANDLE MasterDirectory,
  3526. PIO_HANDLE SlaveDirectory,
  3527. PCSTR MasterPath,
  3528. UINTN MasterPathLength,
  3529. PCSTR SlavePath,
  3530. UINTN SlavePathLength,
  3531. ULONG MasterAccess,
  3532. ULONG MasterOpenFlags,
  3533. FILE_PERMISSIONS MasterCreatePermissions,
  3534. FILE_PERMISSIONS SlaveCreatePermissions,
  3535. PIO_HANDLE *MasterHandle
  3536. );
  3537. /*++
  3538. Routine Description:
  3539. This routine creates and opens a new terminal master.
  3540. Arguments:
  3541. FromKernelMode - Supplies a boolean indicating whether this request is
  3542. originating from kernel mode (and should use the root path as a base)
  3543. or user mode.
  3544. MasterDirectory - Supplies an optional pointer to an open handle to a
  3545. directory for relative paths when creating the master. Supply NULL to
  3546. use the current working directory.
  3547. SlaveDirectory - Supplies an optional pointer to an open handle to a
  3548. directory for relative paths when creating the slave. Supply NULL to
  3549. use the current working directory.
  3550. MasterPath - Supplies an optional pointer to the path to create for the
  3551. master.
  3552. MasterPathLength - Supplies the length of the master side path buffer in
  3553. bytes, including the null terminator.
  3554. SlavePath - Supplies an optional pointer to the path to create for the
  3555. master.
  3556. SlavePathLength - Supplies the length of the slave side path buffer in
  3557. bytes, including the null terminator.
  3558. MasterAccess - Supplies the desired access permissions to the master side
  3559. handle. See IO_ACCESS_* definitions.
  3560. MasterOpenFlags - Supplies the open flags to use when opening the master.
  3561. MasterCreatePermissions - Supplies the permissions to apply to the created
  3562. master side.
  3563. SlaveCreatePermissions - Supplies the permission to apply to the created
  3564. slave side.
  3565. MasterHandle - Supplies a pointer where a handle to the master side of the
  3566. new terminal will be returned.
  3567. Return Value:
  3568. Status code.
  3569. --*/
  3570. KERNEL_API
  3571. KSTATUS
  3572. IoOpenLocalTerminalMaster (
  3573. PIO_HANDLE *TerminalMaster
  3574. );
  3575. /*++
  3576. Routine Description:
  3577. This routine opens the master side of the local console terminal. This
  3578. routine is intended to be used by the input and output devices that
  3579. actually service the local console (the user input driver and video
  3580. console driver).
  3581. Arguments:
  3582. TerminalMaster - Supplies a pointer where the I/O handle representing the
  3583. master side of the local console terminal will be returned.
  3584. Return Value:
  3585. Status code.
  3586. --*/
  3587. KERNEL_API
  3588. KSTATUS
  3589. IoOpenControllingTerminal (
  3590. PIO_HANDLE IoHandle
  3591. );
  3592. /*++
  3593. Routine Description:
  3594. This routine attempts to open the current process' controlling terminal.
  3595. Arguments:
  3596. IoHandle - Supplies a pointer to an already open or opening I/O handle. The
  3597. contents of that handle will be replaced with the controlling terminal.
  3598. Return Value:
  3599. Status code.
  3600. --*/
  3601. KERNEL_API
  3602. KSTATUS
  3603. IoSetTerminalSettings (
  3604. PIO_HANDLE TerminalHandle,
  3605. PTERMINAL_SETTINGS NewSettings,
  3606. PTERMINAL_SETTINGS OriginalSettings,
  3607. TERMINAL_CHANGE_BEHAVIOR When
  3608. );
  3609. /*++
  3610. Routine Description:
  3611. This routine gets or sets the current terminal settings.
  3612. Arguments:
  3613. TerminalHandle - Supplies a pointer to the I/O handle of the terminal to
  3614. change.
  3615. NewSettings - Supplies an optional pointer to the new terminal settings.
  3616. If this pointer is NULL, then the current settings will be retrieved
  3617. but no changes will be made.
  3618. OriginalSettings - Supplies an optional pointer where the current
  3619. settings will be returned.
  3620. When - Supplies when the new change should occur.
  3621. Return Value:
  3622. Status code.
  3623. --*/
  3624. KERNEL_API
  3625. KSTATUS
  3626. IoTerminalSetDevice (
  3627. PIO_HANDLE TerminalMaster,
  3628. PIO_HANDLE DeviceHandle
  3629. );
  3630. /*++
  3631. Routine Description:
  3632. This routine associates or disassociates a terminal object with a device.
  3633. Writes to the terminal slave will be forwarded to the associated terminal,
  3634. as will changes to the terminal settings. If a device is being associated
  3635. with the terminal, then the new settings will be sent to the device
  3636. immediately in this routine.
  3637. Arguments:
  3638. TerminalMaster - Supplies a handle to the terminal master.
  3639. DeviceHandle - Supplies a handle to the terminal hardware device. Any
  3640. previously associated handle will be closed. Supply NULL to
  3641. disassociate the terminal with a device. Upon success, this routine
  3642. takes ownership of this device handle, and the caller should not close
  3643. it manually.
  3644. Return Value:
  3645. Status code.
  3646. --*/
  3647. VOID
  3648. IoTerminalDisassociate (
  3649. PKPROCESS Process
  3650. );
  3651. /*++
  3652. Routine Description:
  3653. This routine is called when a session leader dies to disassociate the
  3654. terminal from the rest of the session.
  3655. Arguments:
  3656. Process - Supplies a pointer to the session leader that has exited.
  3657. Return Value:
  3658. None.
  3659. --*/
  3660. KERNEL_API
  3661. KSTATUS
  3662. IoLocateDeviceInformation (
  3663. PUUID Uuid,
  3664. PDEVICE Device,
  3665. PDEVICE_ID DeviceId,
  3666. PDEVICE_INFORMATION_RESULT Results,
  3667. PULONG ResultCount
  3668. );
  3669. /*++
  3670. Routine Description:
  3671. This routine returns instances of devices enumerating information. Callers
  3672. can get all devices enumerating the given information type, or all
  3673. information types enumerated by a given device. This routine must be called
  3674. at low level.
  3675. Arguments:
  3676. Uuid - Supplies an optional pointer to the information identifier to
  3677. filter on. If NULL, any information type will match.
  3678. Device - Supplies an optional pointer to the device to match against. If
  3679. NULL (and the device ID parameter is NULL), then any device will match.
  3680. DeviceId - Supplies an optional pointer to the device ID to match against.
  3681. If NULL (and the device ID parameter is NULL), then any device will
  3682. match.
  3683. Results - Supplies a pointer to a caller allocated buffer where the
  3684. results will be returned.
  3685. ResultCount - Supplies a pointer that upon input contains the size of the
  3686. buffer in information result elements. On output, returns the number
  3687. of elements in the query, even if the provided buffer was too small.
  3688. Do note however that the number of results can change between two
  3689. successive searches.
  3690. Return Value:
  3691. STATUS_SUCCESS on success.
  3692. STATUS_BUFFER_TOO_SMALL if the provided buffer was not large enough to
  3693. contain all the results. The result count will contain the required number
  3694. of elements to contain the results.
  3695. --*/
  3696. KERNEL_API
  3697. KSTATUS
  3698. IoGetSetDeviceInformation (
  3699. DEVICE_ID DeviceId,
  3700. PUUID Uuid,
  3701. PVOID Data,
  3702. PUINTN DataSize,
  3703. BOOL Set
  3704. );
  3705. /*++
  3706. Routine Description:
  3707. This routine gets or sets device information.
  3708. Arguments:
  3709. DeviceId - Supplies the device ID of the device to get or set information
  3710. for.
  3711. Uuid - Supplies a pointer to the identifier of the device information type
  3712. to get or set.
  3713. Data - Supplies a pointer to the data buffer that either contains the
  3714. information to set or will contain the information to get on success.
  3715. DataSize - Supplies a pointer that on input contains the size of the
  3716. data buffer. On output contains the actual size of the data.
  3717. Set - Supplies a boolean indicating whether to get information (FALSE) or
  3718. set information (TRUE).
  3719. Return Value:
  3720. Status code.
  3721. --*/
  3722. KERNEL_API
  3723. KSTATUS
  3724. IoRegisterDeviceInformation (
  3725. PDEVICE Device,
  3726. PUUID Uuid,
  3727. BOOL Register
  3728. );
  3729. /*++
  3730. Routine Description:
  3731. This routine registers or deregisters a device to respond to information
  3732. requests of the given universally unique identifier. This routine must be
  3733. called at low level.
  3734. Arguments:
  3735. Device - Supplies a pointer to the device.
  3736. Uuid - Supplies a pointer to the device information identifier.
  3737. Register - Supplies a boolean indcating if the device is registering (TRUE)
  3738. or de-registering (FALSE) for the information type.
  3739. Return Value:
  3740. STATUS_SUCCESS on success.
  3741. STATUS_INSUFFICIENT_RESOURCES on allocation failure.
  3742. --*/
  3743. INTN
  3744. IoSysOpen (
  3745. PVOID SystemCallParameter
  3746. );
  3747. /*++
  3748. Routine Description:
  3749. This routine opens a file or other I/O object on behalf of a user mode
  3750. application.
  3751. Arguments:
  3752. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3753. the system call. This structure will be a stack-local copy of the
  3754. actual parameters passed from user-mode.
  3755. Return Value:
  3756. STATUS_SUCCESS or positive integer on success.
  3757. Error status code on failure.
  3758. --*/
  3759. INTN
  3760. IoSysOpenDevice (
  3761. PVOID SystemCallParameter
  3762. );
  3763. /*++
  3764. Routine Description:
  3765. This routine opens a direct handle to a device on behalf of a user mode
  3766. application.
  3767. Arguments:
  3768. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3769. the system call. This structure will be a stack-local copy of the
  3770. actual parameters passed from user-mode.
  3771. Return Value:
  3772. STATUS_SUCCESS or positive integer on success.
  3773. Error status code on failure.
  3774. --*/
  3775. INTN
  3776. IoSysClose (
  3777. PVOID SystemCallParameter
  3778. );
  3779. /*++
  3780. Routine Description:
  3781. This routine closes an I/O handle opened in user mode.
  3782. Arguments:
  3783. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3784. the system call. This stores the user mode handle returned during the
  3785. open system call. It is passed to the kernel in a register.
  3786. Return Value:
  3787. STATUS_SUCCESS or positive integer on success.
  3788. Error status code on failure.
  3789. --*/
  3790. INTN
  3791. IoSysPerformIo (
  3792. PVOID SystemCallParameter
  3793. );
  3794. /*++
  3795. Routine Description:
  3796. This routine performs I/O for user mode.
  3797. Arguments:
  3798. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3799. the system call. This structure will be a stack-local copy of the
  3800. actual parameters passed from user-mode.
  3801. Return Value:
  3802. STATUS_SUCCESS or the number of bytes completed (a positive integer) on
  3803. success.
  3804. Error status code (a negative integer) on failure.
  3805. --*/
  3806. INTN
  3807. IoSysPerformVectoredIo (
  3808. PVOID SystemCallParameter
  3809. );
  3810. /*++
  3811. Routine Description:
  3812. This routine performs vectored I/O for user mode.
  3813. Arguments:
  3814. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3815. the system call. This structure will be a stack-local copy of the
  3816. actual parameters passed from user-mode.
  3817. Return Value:
  3818. STATUS_SUCCESS or the number of bytes completed (a positive integer) on
  3819. success.
  3820. Error status code (a negative integer) on failure.
  3821. --*/
  3822. INTN
  3823. IoSysFlush (
  3824. PVOID SystemCallParameter
  3825. );
  3826. /*++
  3827. Routine Description:
  3828. This routine flushes data to its backing device for user mode.
  3829. Arguments:
  3830. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3831. the system call. This structure will be a stack-local copy of the
  3832. actual parameters passed from user-mode.
  3833. Return Value:
  3834. STATUS_SUCCESS or positive integer on success.
  3835. Error status code on failure.
  3836. --*/
  3837. INTN
  3838. IoSysCreatePipe (
  3839. PVOID SystemCallParameter
  3840. );
  3841. /*++
  3842. Routine Description:
  3843. This routine creates a pipe on behalf of a user mode application.
  3844. Arguments:
  3845. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3846. the system call. This structure will be a stack-local copy of the
  3847. actual parameters passed from user-mode.
  3848. Return Value:
  3849. STATUS_SUCCESS or positive integer on success.
  3850. Error status code on failure.
  3851. --*/
  3852. INTN
  3853. IoSysGetCurrentDirectory (
  3854. PVOID SystemCallParameter
  3855. );
  3856. /*++
  3857. Routine Description:
  3858. This routine handles the system call requesting the path of the current
  3859. working directory.
  3860. Arguments:
  3861. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3862. the system call. This structure will be a stack-local copy of the
  3863. actual parameters passed from user-mode.
  3864. Return Value:
  3865. STATUS_SUCCESS or positive integer on success.
  3866. Error status code on failure.
  3867. --*/
  3868. INTN
  3869. IoSysChangeDirectory (
  3870. PVOID SystemCallParameter
  3871. );
  3872. /*++
  3873. Routine Description:
  3874. This routine handles the system call requesting to change the current
  3875. working directory.
  3876. Arguments:
  3877. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3878. the system call. This structure will be a stack-local copy of the
  3879. actual parameters passed from user-mode.
  3880. Return Value:
  3881. STATUS_SUCCESS or positive integer on success.
  3882. Error status code on failure.
  3883. --*/
  3884. INTN
  3885. IoSysPoll (
  3886. PVOID SystemCallParameter
  3887. );
  3888. /*++
  3889. Routine Description:
  3890. This routine handles the poll system call, which waits on several I/O
  3891. handles.
  3892. Arguments:
  3893. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3894. the system call. This structure will be a stack-local copy of the
  3895. actual parameters passed from user-mode.
  3896. Return Value:
  3897. STATUS_SUCCESS or the number of descriptors selected (a positive integer)
  3898. on success.
  3899. Error status code (a negative integer) on failure.
  3900. --*/
  3901. INTN
  3902. IoSysDuplicateHandle (
  3903. PVOID SystemCallParameter
  3904. );
  3905. /*++
  3906. Routine Description:
  3907. This routine implements the system call for duplicating a file handle.
  3908. Arguments:
  3909. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3910. the system call. This structure will be a stack-local copy of the
  3911. actual parameters passed from user-mode.
  3912. Return Value:
  3913. STATUS_SUCCESS or positive integer on success.
  3914. Error status code on failure.
  3915. --*/
  3916. INTN
  3917. IoSysFileControl (
  3918. PVOID SystemCallParameter
  3919. );
  3920. /*++
  3921. Routine Description:
  3922. This routine implements the file control system call.
  3923. Arguments:
  3924. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3925. the system call. This structure will be a stack-local copy of the
  3926. actual parameters passed from user-mode.
  3927. Return Value:
  3928. STATUS_SUCCESS or positive integer on success.
  3929. Error status code on failure.
  3930. --*/
  3931. INTN
  3932. IoSysGetSetFileInformation (
  3933. PVOID SystemCallParameter
  3934. );
  3935. /*++
  3936. Routine Description:
  3937. This routine implements the get/set file information system call.
  3938. Arguments:
  3939. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3940. the system call. This structure will be a stack-local copy of the
  3941. actual parameters passed from user-mode.
  3942. Return Value:
  3943. STATUS_SUCCESS or positive integer on success.
  3944. Error status code on failure.
  3945. --*/
  3946. INTN
  3947. IoSysSeek (
  3948. PVOID SystemCallParameter
  3949. );
  3950. /*++
  3951. Routine Description:
  3952. This routine implements the file seek system call.
  3953. Arguments:
  3954. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3955. the system call. This structure will be a stack-local copy of the
  3956. actual parameters passed from user-mode.
  3957. Return Value:
  3958. STATUS_SUCCESS or positive integer on success.
  3959. Error status code on failure.
  3960. --*/
  3961. INTN
  3962. IoSysCreateSymbolicLink (
  3963. PVOID SystemCallParameter
  3964. );
  3965. /*++
  3966. Routine Description:
  3967. This routine creates a symbolic link.
  3968. Arguments:
  3969. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3970. the system call. This structure will be a stack-local copy of the
  3971. actual parameters passed from user-mode.
  3972. Return Value:
  3973. STATUS_SUCCESS or positive integer on success.
  3974. Error status code on failure.
  3975. --*/
  3976. INTN
  3977. IoSysReadSymbolicLink (
  3978. PVOID SystemCallParameter
  3979. );
  3980. /*++
  3981. Routine Description:
  3982. This routine reads and returns the destination of a symbolic link.
  3983. Arguments:
  3984. SystemCallParameter - Supplies a pointer to the parameters supplied with
  3985. the system call. This structure will be a stack-local copy of the
  3986. actual parameters passed from user-mode.
  3987. Return Value:
  3988. STATUS_SUCCESS or positive integer on success.
  3989. Error status code on failure.
  3990. --*/
  3991. INTN
  3992. IoSysCreateHardLink (
  3993. PVOID SystemCallParameter
  3994. );
  3995. /*++
  3996. Routine Description:
  3997. This routine creates a hard link.
  3998. Arguments:
  3999. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4000. the system call. This structure will be a stack-local copy of the
  4001. actual parameters passed from user-mode.
  4002. Return Value:
  4003. STATUS_SUCCESS or positive integer on success.
  4004. Error status code on failure.
  4005. --*/
  4006. INTN
  4007. IoSysDelete (
  4008. PVOID SystemCallParameter
  4009. );
  4010. /*++
  4011. Routine Description:
  4012. This routine deletes an entry from a directory.
  4013. Arguments:
  4014. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4015. the system call. This structure will be a stack-local copy of the
  4016. actual parameters passed from user-mode.
  4017. Return Value:
  4018. STATUS_SUCCESS or positive integer on success.
  4019. Error status code on failure.
  4020. --*/
  4021. INTN
  4022. IoSysRename (
  4023. PVOID SystemCallParameter
  4024. );
  4025. /*++
  4026. Routine Description:
  4027. This routine renames a file or directory.
  4028. Arguments:
  4029. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4030. the system call. This structure will be a stack-local copy of the
  4031. actual parameters passed from user-mode.
  4032. Return Value:
  4033. STATUS_SUCCESS or positive integer on success.
  4034. Error status code on failure.
  4035. --*/
  4036. INTN
  4037. IoSysUserControl (
  4038. PVOID SystemCallParameter
  4039. );
  4040. /*++
  4041. Routine Description:
  4042. This routine implements the user control system call.
  4043. Arguments:
  4044. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4045. the system call. This structure will be a stack-local copy of the
  4046. actual parameters passed from user-mode.
  4047. Return Value:
  4048. STATUS_SUCCESS or positive integer on success.
  4049. Error status code on failure.
  4050. --*/
  4051. INTN
  4052. IoSysMountOrUnmount (
  4053. PVOID SystemCallParameter
  4054. );
  4055. /*++
  4056. Routine Description:
  4057. This routine mounts or unmounts a file, directory, volume, or device.
  4058. Arguments:
  4059. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4060. the system call. This structure will be a stack-local copy of the
  4061. actual parameters passed from user-mode.
  4062. Return Value:
  4063. STATUS_SUCCESS or positive integer on success.
  4064. Error status code on failure.
  4065. --*/
  4066. INTN
  4067. IoSysGetEffectiveAccess (
  4068. PVOID SystemCallParameter
  4069. );
  4070. /*++
  4071. Routine Description:
  4072. This routine implements the system call for getting the current user's
  4073. access permission to a given path.
  4074. Arguments:
  4075. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4076. the system call. This structure will be a stack-local copy of the
  4077. actual parameters passed from user-mode.
  4078. Return Value:
  4079. STATUS_SUCCESS or positive integer on success.
  4080. Error status code on failure.
  4081. --*/
  4082. INTN
  4083. IoSysCreateTerminal (
  4084. PVOID SystemCallParameter
  4085. );
  4086. /*++
  4087. Routine Description:
  4088. This routine implements the system call for creating and opening a new
  4089. terminal.
  4090. Arguments:
  4091. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4092. the system call. This structure will be a stack-local copy of the
  4093. actual parameters passed from user-mode.
  4094. Return Value:
  4095. STATUS_SUCCESS or positive integer on success.
  4096. Error status code on failure.
  4097. --*/
  4098. INTN
  4099. IoSysSocketCreatePair (
  4100. PVOID SystemCallParameter
  4101. );
  4102. /*++
  4103. Routine Description:
  4104. This routine handles the system call that creates a pair of connected
  4105. sockets.
  4106. Arguments:
  4107. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4108. the system call. This structure will be a stack-local copy of the
  4109. actual parameters passed from user-mode.
  4110. Return Value:
  4111. STATUS_SUCCESS or positive integer on success.
  4112. Error status code on failure.
  4113. --*/
  4114. INTN
  4115. IoSysSocketCreate (
  4116. PVOID SystemCallParameter
  4117. );
  4118. /*++
  4119. Routine Description:
  4120. This routine handles the system call that creates a new socket.
  4121. Arguments:
  4122. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4123. the system call. This structure will be a stack-local copy of the
  4124. actual parameters passed from user-mode.
  4125. Return Value:
  4126. STATUS_SUCCESS or positive integer on success.
  4127. Error status code on failure.
  4128. --*/
  4129. INTN
  4130. IoSysSocketBind (
  4131. PVOID SystemCallParameter
  4132. );
  4133. /*++
  4134. Routine Description:
  4135. This routine attempts to bind a socket to a local address.
  4136. Arguments:
  4137. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4138. the system call. This structure will be a stack-local copy of the
  4139. actual parameters passed from user-mode.
  4140. Return Value:
  4141. STATUS_SUCCESS or positive integer on success.
  4142. Error status code on failure.
  4143. --*/
  4144. INTN
  4145. IoSysSocketListen (
  4146. PVOID SystemCallParameter
  4147. );
  4148. /*++
  4149. Routine Description:
  4150. This routine handles the system call that makes a socket listen and become
  4151. eligible to accept new incoming connections.
  4152. Arguments:
  4153. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4154. the system call. This structure will be a stack-local copy of the
  4155. actual parameters passed from user-mode.
  4156. Return Value:
  4157. STATUS_SUCCESS or positive integer on success.
  4158. Error status code on failure.
  4159. --*/
  4160. INTN
  4161. IoSysSocketAccept (
  4162. PVOID SystemCallParameter
  4163. );
  4164. /*++
  4165. Routine Description:
  4166. This routine handles the system call that accepts a new incoming
  4167. connection on a socket and spins it off into another socket.
  4168. Arguments:
  4169. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4170. the system call. This structure will be a stack-local copy of the
  4171. actual parameters passed from user-mode.
  4172. Return Value:
  4173. STATUS_SUCCESS or positive integer on success.
  4174. Error status code on failure.
  4175. --*/
  4176. INTN
  4177. IoSysSocketConnect (
  4178. PVOID SystemCallParameter
  4179. );
  4180. /*++
  4181. Routine Description:
  4182. This routine handles the system call that reaches and and attempts to
  4183. connect with another socket.
  4184. Arguments:
  4185. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4186. the system call. This structure will be a stack-local copy of the
  4187. actual parameters passed from user-mode.
  4188. Return Value:
  4189. STATUS_SUCCESS or positive integer on success.
  4190. Error status code on failure.
  4191. --*/
  4192. INTN
  4193. IoSysSocketPerformIo (
  4194. PVOID SystemCallParameter
  4195. );
  4196. /*++
  4197. Routine Description:
  4198. This routine handles the system call that sends a packet to a specific
  4199. destination or receives data from a destination. Sockets may also use the
  4200. generic perform I/O operations if the identity of the remote address is
  4201. either already known or not needed.
  4202. Arguments:
  4203. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4204. the system call. This structure will be a stack-local copy of the
  4205. actual parameters passed from user-mode.
  4206. Return Value:
  4207. STATUS_SUCCESS or positive integer on success.
  4208. Error status code on failure.
  4209. --*/
  4210. INTN
  4211. IoSysSocketPerformVectoredIo (
  4212. PVOID SystemCallParameter
  4213. );
  4214. /*++
  4215. Routine Description:
  4216. This routine handles the system call that performs socket I/O using I/O
  4217. vectors.
  4218. Arguments:
  4219. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4220. the system call. This structure will be a stack-local copy of the
  4221. actual parameters passed from user-mode.
  4222. Return Value:
  4223. STATUS_SUCCESS or positive integer on success.
  4224. Error status code on failure.
  4225. --*/
  4226. INTN
  4227. IoSysSocketGetSetInformation (
  4228. PVOID SystemCallParameter
  4229. );
  4230. /*++
  4231. Routine Description:
  4232. This routine implements the system call for getting or setting socket
  4233. information.
  4234. Arguments:
  4235. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4236. the system call. This structure will be a stack-local copy of the
  4237. actual parameters passed from user-mode.
  4238. Return Value:
  4239. STATUS_SUCCESS or positive integer on success.
  4240. Error status code on failure.
  4241. --*/
  4242. INTN
  4243. IoSysSocketShutdown (
  4244. PVOID SystemCallParameter
  4245. );
  4246. /*++
  4247. Routine Description:
  4248. This routine implements the system call for shutting down communication to
  4249. a socket.
  4250. Arguments:
  4251. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4252. the system call. This structure will be a stack-local copy of the
  4253. actual parameters passed from user-mode.
  4254. Return Value:
  4255. STATUS_SUCCESS or positive integer on success.
  4256. Error status code on failure.
  4257. --*/
  4258. INTN
  4259. IoSysLoadDriver (
  4260. PVOID SystemCallParameter
  4261. );
  4262. /*++
  4263. Routine Description:
  4264. This routine loads a driver into the kernel's address space.
  4265. Arguments:
  4266. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4267. the system call. This structure will be a stack-local copy of the
  4268. actual parameters passed from user-mode.
  4269. Return Value:
  4270. STATUS_SUCCESS or positive integer on success.
  4271. Error status code on failure.
  4272. --*/
  4273. INTN
  4274. IoSysLocateDeviceInformation (
  4275. PVOID SystemCallParameter
  4276. );
  4277. /*++
  4278. Routine Description:
  4279. This routine implements the user mode system call for locating device
  4280. information registrations by UUID or device ID.
  4281. Arguments:
  4282. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4283. the system call. This structure will be a stack-local copy of the
  4284. actual parameters passed from user-mode.
  4285. Return Value:
  4286. STATUS_SUCCESS or positive integer on success.
  4287. Error status code on failure.
  4288. --*/
  4289. INTN
  4290. IoSysGetSetDeviceInformation (
  4291. PVOID SystemCallParameter
  4292. );
  4293. /*++
  4294. Routine Description:
  4295. This routine implements the user mode system call for getting and setting
  4296. device information.
  4297. Arguments:
  4298. SystemCallParameter - Supplies a pointer to the parameters supplied with
  4299. the system call. This structure will be a stack-local copy of the
  4300. actual parameters passed from user-mode.
  4301. Return Value:
  4302. STATUS_SUCCESS or positive integer on success.
  4303. Error status code on failure.
  4304. --*/
  4305. VOID
  4306. IoIoHandleAddReference (
  4307. PIO_HANDLE IoHandle
  4308. );
  4309. /*++
  4310. Routine Description:
  4311. This routine increments the reference count on an I/O handle.
  4312. Arguments:
  4313. IoHandle - Supplies a pointer to the I/O handle.
  4314. Return Value:
  4315. None.
  4316. --*/
  4317. KSTATUS
  4318. IoIoHandleReleaseReference (
  4319. PIO_HANDLE IoHandle
  4320. );
  4321. /*++
  4322. Routine Description:
  4323. This routine decrements the reference count on an I/O handle. If the
  4324. reference count becomes zero, the I/O handle will be destroyed.
  4325. Arguments:
  4326. IoHandle - Supplies a pointer to the I/O handle.
  4327. Return Value:
  4328. None.
  4329. --*/
  4330. PIMAGE_SECTION_LIST
  4331. IoGetImageSectionListFromIoHandle (
  4332. PIO_HANDLE IoHandle
  4333. );
  4334. /*++
  4335. Routine Description:
  4336. This routine gets the image section list for the given I/O handle.
  4337. Arguments:
  4338. IoHandle - Supplies a pointer to an I/O handle.
  4339. Return Value:
  4340. Returns a pointer to the I/O handles image section list or NULL on failure.
  4341. --*/
  4342. KERNEL_API
  4343. ULONG
  4344. IoGetIoHandleAccessPermissions (
  4345. PIO_HANDLE IoHandle
  4346. );
  4347. /*++
  4348. Routine Description:
  4349. This routine returns the access permissions for the given I/O handle. For
  4350. directories, no access is always returned.
  4351. Arguments:
  4352. IoHandle - Supplies a pointer to an I/O handle.
  4353. Return Value:
  4354. Returns the access permissions for the given I/O handle.
  4355. --*/
  4356. KERNEL_API
  4357. ULONG
  4358. IoGetIoHandleOpenFlags (
  4359. PIO_HANDLE IoHandle
  4360. );
  4361. /*++
  4362. Routine Description:
  4363. This routine returns the current open flags for a given I/O handle. Some
  4364. of these flags can change.
  4365. Arguments:
  4366. IoHandle - Supplies a pointer to an I/O handle.
  4367. Return Value:
  4368. Returns the current open flags for the I/O handle.
  4369. --*/
  4370. BOOL
  4371. IoIoHandleIsCacheable (
  4372. PIO_HANDLE IoHandle,
  4373. PULONG MapFlags
  4374. );
  4375. /*++
  4376. Routine Description:
  4377. This routine determines whether or not data for the I/O object specified by
  4378. the given handle is cached in the page cache.
  4379. Arguments:
  4380. IoHandle - Supplies a pointer to an I/O handle.
  4381. MapFlags - Supplies an optional pointer where any additional map flags
  4382. needed when mapping sections from this handle will be returned.
  4383. See MAP_FLAG_* definitions.
  4384. Return Value:
  4385. Returns TRUE if the I/O handle's object uses the page cache, FALSE
  4386. otherwise.
  4387. --*/
  4388. KSTATUS
  4389. IoCloseProcessHandles (
  4390. PKPROCESS Process,
  4391. HANDLE MinimumHandle
  4392. );
  4393. /*++
  4394. Routine Description:
  4395. This routine closes all remaining open handles in the given process.
  4396. Arguments:
  4397. Process - Supplies a pointer to the process being terminated.
  4398. MinimumHandle - Supplies the lowest handle to clean up to, inclusive.
  4399. Handles below this one will not be closed.
  4400. Return Value:
  4401. Status code.
  4402. --*/
  4403. KSTATUS
  4404. IoCopyProcessHandles (
  4405. PKPROCESS SourceProcess,
  4406. PKPROCESS DestinationProcess
  4407. );
  4408. /*++
  4409. Routine Description:
  4410. This routine copies all handles in the source process to the destination
  4411. process. This is used during process forking.
  4412. Arguments:
  4413. SourceProcess - Supplies a pointer to the process being copied.
  4414. DestinationProcess - Supplies a pointer to the fledgling destination
  4415. process. This process' handle hables must be empty.
  4416. Return Value:
  4417. Status code.
  4418. --*/
  4419. KSTATUS
  4420. IoCloseHandlesOnExecute (
  4421. PKPROCESS Process
  4422. );
  4423. /*++
  4424. Routine Description:
  4425. This routine closes any handles marked for "close on execute".
  4426. Arguments:
  4427. Process - Supplies a pointer to the process undergoing the execution
  4428. transformation.
  4429. Return Value:
  4430. Status code.
  4431. --*/
  4432. KSTATUS
  4433. IoOpenPageFile (
  4434. PCSTR Path,
  4435. ULONG PathSize,
  4436. ULONG Access,
  4437. ULONG Flags,
  4438. PIO_HANDLE *Handle,
  4439. PULONGLONG FileSize
  4440. );
  4441. /*++
  4442. Routine Description:
  4443. This routine opens a page file. This routine is to be used only
  4444. internally by MM.
  4445. Arguments:
  4446. Path - Supplies a pointer to the string containing the file path to open.
  4447. PathSize - Supplies the length of the path buffer in bytes, including
  4448. the null terminator.
  4449. Access - Supplies the desired access permissions to the object. See
  4450. IO_ACCESS_* definitions.
  4451. Flags - Supplies a bitfield of flags governing the behavior of the handle.
  4452. See OPEN_FLAG_* definitions.
  4453. Handle - Supplies a pointer where a pointer to the open I/O handle will be
  4454. returned on success.
  4455. FileSize - Supplies a pointer where the file size in bytes will be returned
  4456. on success.
  4457. Return Value:
  4458. Status code.
  4459. --*/
  4460. KSTATUS
  4461. IoNotifyFileMapping (
  4462. PIO_HANDLE Handle,
  4463. BOOL Mapping
  4464. );
  4465. /*++
  4466. Routine Description:
  4467. This routine is called to notify a file object that it is being mapped
  4468. into memory or unmapped.
  4469. Arguments:
  4470. Handle - Supplies the handle being mapped.
  4471. Mapping - Supplies a boolean indicating if a new mapping is being created
  4472. (TRUE) or an old mapping is being destroyed (FALSE).
  4473. Return Value:
  4474. Status code.
  4475. --*/
  4476. KSTATUS
  4477. IoPathAppend (
  4478. PCSTR Prefix,
  4479. ULONG PrefixSize,
  4480. PCSTR Component,
  4481. ULONG ComponentSize,
  4482. ULONG AllocationTag,
  4483. PSTR *AppendedPath,
  4484. PULONG AppendedPathSize
  4485. );
  4486. /*++
  4487. Routine Description:
  4488. This routine appends a path component to a path.
  4489. Arguments:
  4490. Prefix - Supplies the initial path string. This can be null.
  4491. PrefixSize - Supplies the size of the prefix string in bytes including the
  4492. null terminator.
  4493. Component - Supplies a pointer to the component string to add.
  4494. ComponentSize - Supplies the size of the component string in bytes
  4495. including a null terminator.
  4496. AllocationTag - Supplies the tag to use for the combined allocation.
  4497. AppendedPath - Supplies a pointer where the new path will be returned. The
  4498. caller is responsible for freeing this memory.
  4499. AppendedPathSize - Supplies a pointer where the size of the appended bath
  4500. buffer in bytes including the null terminator will be returned.
  4501. Return Value:
  4502. TRUE on success.
  4503. FALSE on failure.
  4504. --*/
  4505. PPATH_POINT
  4506. IoGetPathPoint (
  4507. PIO_HANDLE IoHandle
  4508. );
  4509. /*++
  4510. Routine Description:
  4511. This routine returns the path point for the given handle.
  4512. Arguments:
  4513. IoHandle - Supplies a pointer to the I/O handle to get the path point of.
  4514. Return Value:
  4515. Returns a pointer to the path point corresponding to the given handle.
  4516. --*/
  4517. VOID
  4518. IoPathEntryAddReference (
  4519. PPATH_ENTRY Entry
  4520. );
  4521. /*++
  4522. Routine Description:
  4523. This routine increments the reference count of the given path entry.
  4524. Arguments:
  4525. Entry - Supplies a pointer to the path entry.
  4526. Return Value:
  4527. None.
  4528. --*/
  4529. VOID
  4530. IoPathEntryReleaseReference (
  4531. PPATH_ENTRY Entry
  4532. );
  4533. /*++
  4534. Routine Description:
  4535. This routine decrements the reference count of the given path entry. If the
  4536. reference count drops to zero, the path entry will be destroyed.
  4537. Arguments:
  4538. Entry - Supplies a pointer to the path entry.
  4539. Return Value:
  4540. None.
  4541. --*/
  4542. KSTATUS
  4543. IoGetCurrentDirectory (
  4544. BOOL FromKernelMode,
  4545. BOOL Root,
  4546. PSTR *Path,
  4547. PUINTN PathSize
  4548. );
  4549. /*++
  4550. Routine Description:
  4551. This routine gets either the current working directory or the path of the
  4552. current chroot environment.
  4553. Arguments:
  4554. FromKernelMode - Supplies a boolean indicating whether or not a kernel mode
  4555. caller is requesting the directory information. This dictates how the
  4556. given path buffer is treated.
  4557. Root - Supplies a boolean indicating whether to get the path to the current
  4558. working directory (FALSE) or to get the path of the current chroot
  4559. environment (TRUE). If the caller does not have permission to escape a
  4560. changed root, or the root has not been changed, then / is returned in
  4561. the path argument.
  4562. Path - Supplies a pointer to a buffer that will contain the desired path on
  4563. output. If the call is from kernel mode and the pointer is NULL, then
  4564. a buffer will be allocated.
  4565. PathSize - Supplies a pointer to the size of the path buffer on input. On
  4566. output it stores the required size of the path buffer. This includes
  4567. the null terminator.
  4568. Return Value:
  4569. Status code.
  4570. --*/
  4571. KSTATUS
  4572. IoLoadDriver (
  4573. PCSTR DriverName,
  4574. PDRIVER *DriverOut
  4575. );
  4576. /*++
  4577. Routine Description:
  4578. This routine loads a driver into memory. This routine must be called at low
  4579. level.
  4580. Arguments:
  4581. DriverName - Supplies the name of the driver to load.
  4582. DriverOut - Supplies an optional pointer where the pointer to the newly
  4583. loaded driver can be returned.
  4584. Return Value:
  4585. Status code.
  4586. --*/
  4587. KSTATUS
  4588. IoAddDeviceDatabaseEntry (
  4589. PCSTR DeviceId,
  4590. PCSTR DriverName
  4591. );
  4592. /*++
  4593. Routine Description:
  4594. This routine adds a mapping between a device and a driver. Only one device
  4595. to driver mapping can exist in the database at once.
  4596. Arguments:
  4597. DeviceId - Supplies the device ID of the device to associate with a driver.
  4598. This memory does not need to be retained, a copy of this string will
  4599. be created.
  4600. DriverName - Supplies the name of the driver corresponding to the device.
  4601. This memory does not need to be retained, a copy of this string will be
  4602. created.
  4603. Return Value:
  4604. STATUS_SUCCESS on success.
  4605. STATUS_INVALID_PARAMETER if a required parameter or function was not
  4606. supplied.
  4607. STATUS_INSUFFICIENT_RESOURCE on allocation failure.
  4608. STATUS_DUPLICATE_ENTRY if the device ID already exists in the database.
  4609. --*/
  4610. KSTATUS
  4611. IoAddDeviceClassDatabaseEntry (
  4612. PCSTR ClassId,
  4613. PCSTR DriverName
  4614. );
  4615. /*++
  4616. Routine Description:
  4617. This routine adds a mapping between a device class and a driver. Only one
  4618. device class to driver mapping can exist in the database at once.
  4619. Arguments:
  4620. ClassId - Supplies the device class identifier of the device to associate
  4621. with a driver. This memory does not need to be retained, a copy of this
  4622. string will be created.
  4623. DriverName - Supplies the name of the driver corresponding to the device
  4624. class. This memory does not need to be retained, a copy of this string
  4625. will be created.
  4626. Return Value:
  4627. STATUS_SUCCESS on success.
  4628. STATUS_INVALID_PARAMETER if a required parameter or function was not
  4629. supplied.
  4630. STATUS_INSUFFICIENT_RESOURCES on allocation failure.
  4631. STATUS_DUPLICATE_ENTRY if the device ID already exists in the database.
  4632. --*/
  4633. KSTATUS
  4634. IoCreateDriverStructure (
  4635. PVOID LoadedImage
  4636. );
  4637. /*++
  4638. Routine Description:
  4639. This routine is called to create a new driver structure for a loaded image.
  4640. This routine should only be called internally by the system.
  4641. Arguments:
  4642. LoadedImage - Supplies a pointer to the image associated with the driver.
  4643. Return Value:
  4644. Status code.
  4645. --*/
  4646. VOID
  4647. IoDestroyDriverStructure (
  4648. PVOID LoadedImage
  4649. );
  4650. /*++
  4651. Routine Description:
  4652. This routine is called to destroy a driver structure in association with
  4653. a driver being torn down. This routine should only be called internally by
  4654. the system.
  4655. Arguments:
  4656. LoadedImage - Supplies a pointer to the image being destroyed.
  4657. Return Value:
  4658. None.
  4659. --*/
  4660. KSTATUS
  4661. IoCreateVolume (
  4662. PDEVICE Device,
  4663. PVOLUME *Volume
  4664. );
  4665. /*++
  4666. Routine Description:
  4667. This routine creates a new volume to be mounted by a file system.
  4668. Arguments:
  4669. Device - Supplies a pointer to the physical device upon which the file
  4670. system should be mounted.
  4671. Volume - Supplies a pointer that receives a pointer to the newly created
  4672. volume.
  4673. Return Value:
  4674. Status code.
  4675. --*/
  4676. VOID
  4677. IoVolumeAddReference (
  4678. PVOLUME Volume
  4679. );
  4680. /*++
  4681. Routine Description:
  4682. This routine increments a volume's reference count.
  4683. Arguments:
  4684. Volume - Supplies a pointer to a volume device.
  4685. Return Value:
  4686. None.
  4687. --*/
  4688. VOID
  4689. IoVolumeReleaseReference (
  4690. PVOLUME Volume
  4691. );
  4692. /*++
  4693. Routine Description:
  4694. This routine decrements a volume's reference count.
  4695. Arguments:
  4696. Volume - Supplies a pointer to a volume device.
  4697. Return Value:
  4698. None.
  4699. --*/
  4700. KERNEL_API
  4701. KSTATUS
  4702. IoCreateResourceArbiter (
  4703. PDEVICE Device,
  4704. RESOURCE_TYPE ResourceType
  4705. );
  4706. /*++
  4707. Routine Description:
  4708. This routine creates a resource arbiter for the given bus device between
  4709. a system resource and the device's children. This function is needed for
  4710. any device whose children access system resources (like physical address
  4711. space) through a window set up by the parent.
  4712. Arguments:
  4713. Device - Supplies a pointer to the parent bus device that provides
  4714. resources.
  4715. ResourceType - Supplies the type of resource that the device provides.
  4716. Return Value:
  4717. STATUS_SUCCESS if the new arbiter was created.
  4718. STATUS_INVALID_PARAMETER if an invalid resource type was specified.
  4719. STATUS_INSUFFICIENT_RESOURCES on allocation failure.
  4720. STATUS_ALREADY_INITIALIZED if the device has already has a resource arbiter
  4721. of this type.
  4722. --*/
  4723. KERNEL_API
  4724. KSTATUS
  4725. IoDestroyResourceArbiter (
  4726. PDEVICE Device,
  4727. RESOURCE_TYPE ResourceType
  4728. );
  4729. /*++
  4730. Routine Description:
  4731. This routine destroys a resource arbiter for the given bus device and type.
  4732. Arguments:
  4733. Device - Supplies a pointer to the device that owns resource arbitration.
  4734. ResourceType - Supplies the type of resource arbiter that is to be
  4735. destroyed.
  4736. Return Value:
  4737. Status code.
  4738. --*/
  4739. KERNEL_API
  4740. KSTATUS
  4741. IoAddFreeSpaceToArbiter (
  4742. PDEVICE Device,
  4743. RESOURCE_TYPE ResourceType,
  4744. ULONGLONG FreeSpaceBegin,
  4745. ULONGLONG FreeSpaceLength,
  4746. ULONGLONG FreeSpaceCharacteristics,
  4747. PRESOURCE_ALLOCATION SourcingAllocation,
  4748. ULONGLONG TranslationOffset
  4749. );
  4750. /*++
  4751. Routine Description:
  4752. This routine adds a regions of allocatable space to a previously created
  4753. resource arbiter.
  4754. Arguments:
  4755. Device - Supplies a pointer to the device that owns the arbiter (and the
  4756. free space).
  4757. ResourceType - Supplies the resource type that the arbiter can dole out.
  4758. An arbiter of this type must have been created by the device.
  4759. FreeSpaceBegin - Supplies the first address of the free region.
  4760. FreeSpaceLength - Supplies the length of the free region.
  4761. FreeSpaceCharacteristics - Supplies the characteristics of the free
  4762. region.
  4763. SourcingAllocation - Supplies a pointer to the parent resource allocation
  4764. that makes this range possible. This pointer is optional. Supplying
  4765. NULL here implies that the given resource is fixed in nature and
  4766. cannot be expanded.
  4767. TranslationOffset - Supplies the offset that has to be added to all
  4768. doled out allocations on the secondary side to get an address in the
  4769. source allocation space (primary side).
  4770. To recap: SecondaryAddress + TranslationOffset = PrimaryAddress, where
  4771. PrimaryAddress is closer to the CPU complex.
  4772. Return Value:
  4773. Status code.
  4774. --*/
  4775. KERNEL_API
  4776. PRESOURCE_ALLOCATION_LIST
  4777. IoGetProcessorLocalResources (
  4778. PDEVICE Device
  4779. );
  4780. /*++
  4781. Routine Description:
  4782. This routine returns the given device's processor local resources.
  4783. Arguments:
  4784. Device - Supplies a pointer to the device that owns the resources.
  4785. Return Value:
  4786. Returns a pointer to the processor local resource allocation list.
  4787. --*/
  4788. //
  4789. // Interrupt management routines.
  4790. //
  4791. KERNEL_API
  4792. KSTATUS
  4793. IoConnectInterrupt (
  4794. PIO_CONNECT_INTERRUPT_PARAMETERS Parameters
  4795. );
  4796. /*++
  4797. Routine Description:
  4798. This routine connects a device's interrupt.
  4799. Arguments:
  4800. Parameters - Supplies a pointer to a versioned table containing the
  4801. parameters of the connection.
  4802. Return Value:
  4803. STATUS_SUCCESS on success.
  4804. STATUS_NOT_READY if the device has no resources or is not started.
  4805. STATUS_RESOURCE_IN_USE if the device attempts to connect to an interrupt
  4806. it does not own.
  4807. Other errors on failure.
  4808. --*/
  4809. KERNEL_API
  4810. VOID
  4811. IoDisconnectInterrupt (
  4812. HANDLE InterruptHandle
  4813. );
  4814. /*++
  4815. Routine Description:
  4816. This routine disconnects a device's interrupt. The device must not
  4817. generate interrupts when this routine is called, as the interrupt line
  4818. may remain open to service other devices connected to the line.
  4819. Arguments:
  4820. InterruptHandle - Supplies the handle to the interrupt, returned when the
  4821. interrupt was connected.
  4822. Return Value:
  4823. None.
  4824. --*/
  4825. KERNEL_API
  4826. RUNLEVEL
  4827. IoRaiseToInterruptRunLevel (
  4828. HANDLE InterruptHandle
  4829. );
  4830. /*++
  4831. Routine Description:
  4832. This routine raises the current run level to that of the given connected
  4833. interrupt. Callers should use KeLowerRunLevel to return from the run level
  4834. raised to here.
  4835. Arguments:
  4836. InterruptHandle - Supplies the handle to the interrupt, returned when the
  4837. interrupt was connected.
  4838. Return Value:
  4839. Returns the run level of the current processor immediately before it was
  4840. raised by this function.
  4841. --*/
  4842. KERNEL_API
  4843. RUNLEVEL
  4844. IoGetInterruptRunLevel (
  4845. PHANDLE Handles,
  4846. UINTN HandleCount
  4847. );
  4848. /*++
  4849. Routine Description:
  4850. This routine determines the highest runlevel between all of the
  4851. connected interrupt handles given.
  4852. Arguments:
  4853. Handles - Supplies an pointer to an array of connected interrupt handles.
  4854. HandleCount - Supplies the number of elements in the array.
  4855. Return Value:
  4856. Returns the highest runlevel between all connected interrupts. This is
  4857. the runlevel to synchronize to if trying to synchronize a device with
  4858. multiple interrupts.
  4859. --*/
  4860. PSTREAM_BUFFER
  4861. IoCreateStreamBuffer (
  4862. PIO_OBJECT_STATE IoState,
  4863. ULONG Flags,
  4864. ULONG BufferSize,
  4865. ULONG AtomicWriteSize
  4866. );
  4867. /*++
  4868. Routine Description:
  4869. This routine allocates and initializes a new stream buffer.
  4870. Arguments:
  4871. IoState - Supplies an optional pointer to the I/O state structure to use
  4872. for this stream buffer.
  4873. Flags - Supplies a bitfield of flags governing the behavior of the stream
  4874. buffer. See STREAM_BUFFER_FLAG_* definitions.
  4875. BufferSize - Supplies the size of the buffer. Supply zero to use a default
  4876. system value.
  4877. AtomicWriteSize - Supplies the number of bytes that can always be written
  4878. to the stream atomically (without interleaving).
  4879. Return Value:
  4880. Returns a pointer to the buffer on success.
  4881. NULL on invalid parameter or allocation failure.
  4882. --*/
  4883. VOID
  4884. IoDestroyStreamBuffer (
  4885. PSTREAM_BUFFER StreamBuffer
  4886. );
  4887. /*++
  4888. Routine Description:
  4889. This routine destroys an allocated stream buffer. It assumes there are no
  4890. waiters on the events.
  4891. Arguments:
  4892. StreamBuffer - Supplies a pointer to the stream buffer to tear down.
  4893. Return Value:
  4894. None.
  4895. --*/
  4896. KSTATUS
  4897. IoReadStreamBuffer (
  4898. PSTREAM_BUFFER StreamBuffer,
  4899. PIO_BUFFER IoBuffer,
  4900. UINTN ByteCount,
  4901. ULONG TimeoutInMilliseconds,
  4902. BOOL NonBlocking,
  4903. PUINTN BytesRead
  4904. );
  4905. /*++
  4906. Routine Description:
  4907. This routine reads from a stream buffer. This routine must be called at low
  4908. level, unless the stream was set up to be read at dispatch.
  4909. Arguments:
  4910. StreamBuffer - Supplies a pointer to the stream buffer to read from.
  4911. IoBuffer - Supplies a pointer to the I/O buffer where the read data will be
  4912. returned on success.
  4913. ByteCount - Supplies the number of bytes to read.
  4914. TimeoutInMilliseconds - Supplies the number of milliseconds that the I/O
  4915. operation should be waited on before timing out. Use
  4916. WAIT_TIME_INDEFINITE to wait forever on the I/O.
  4917. NonBlocking - Supplies a boolean indicating if this read should avoid
  4918. blocking.
  4919. BytesRead - Supplies a pointer where the number of bytes actually read will
  4920. be returned.
  4921. Return Value:
  4922. Status code. If a failing status code is returned, then check the number of
  4923. bytes read to see if any valid data was returned.
  4924. --*/
  4925. KSTATUS
  4926. IoWriteStreamBuffer (
  4927. PSTREAM_BUFFER StreamBuffer,
  4928. PIO_BUFFER IoBuffer,
  4929. UINTN ByteCount,
  4930. ULONG TimeoutInMilliseconds,
  4931. BOOL NonBlocking,
  4932. PUINTN BytesWritten
  4933. );
  4934. /*++
  4935. Routine Description:
  4936. This routine writes to a stream buffer. This routine must be called at low
  4937. level, unless the stream was set up to be written at dispatch.
  4938. Arguments:
  4939. StreamBuffer - Supplies a pointer to the stream buffer to write to.
  4940. IoBuffer - Supplies a pointer to the I/O buffer containing the data to
  4941. write to the stream buffer.
  4942. ByteCount - Supplies the number of bytes to writes.
  4943. TimeoutInMilliseconds - Supplies the number of milliseconds that the I/O
  4944. operation should be waited on before timing out. Use
  4945. WAIT_TIME_INDEFINITE to wait forever on the I/O.
  4946. NonBlocking - Supplies a boolean indicating if this write should avoid
  4947. blocking.
  4948. BytesWritten - Supplies a pointer where the number of bytes actually written
  4949. will be returned.
  4950. Return Value:
  4951. Status code. If a failing status code is returned, then check the number of
  4952. bytes read to see if any valid data was written.
  4953. --*/
  4954. KSTATUS
  4955. IoStreamBufferConnect (
  4956. PSTREAM_BUFFER StreamBuffer
  4957. );
  4958. /*++
  4959. Routine Description:
  4960. This routine resets the I/O object state when someone connects to a stream
  4961. buffer.
  4962. Arguments:
  4963. StreamBuffer - Supplies a pointer to the stream buffer.
  4964. Return Value:
  4965. Status code.
  4966. --*/
  4967. PIO_OBJECT_STATE
  4968. IoStreamBufferGetIoObjectState (
  4969. PSTREAM_BUFFER StreamBuffer
  4970. );
  4971. /*++
  4972. Routine Description:
  4973. This routine returns the I/O state for a stream buffer.
  4974. Arguments:
  4975. StreamBuffer - Supplies a pointer to the stream buffer.
  4976. Return Value:
  4977. Returns a pointer to the stream buffer's I/O object state.
  4978. --*/
  4979. KSTATUS
  4980. IoGetCacheStatistics (
  4981. PIO_CACHE_STATISTICS Statistics
  4982. );
  4983. /*++
  4984. Routine Description:
  4985. This routine collects the cache statistics and returns them to the caller.
  4986. Arguments:
  4987. Statistics - Supplies a pointer that receives the cache statistics. The
  4988. caller should zero this buffer beforehand and set the version member to
  4989. IO_CACHE_STATISTICS_VERSION. Failure to zero the structure beforehand
  4990. may result in uninitialized data when a driver built for a newer OS is
  4991. run on an older OS.
  4992. Return Value:
  4993. Status code.
  4994. --*/
  4995. KERNEL_API
  4996. ULONG
  4997. IoGetCacheEntryDataSize (
  4998. VOID
  4999. );
  5000. /*++
  5001. Routine Description:
  5002. This routine returns the size of data stored in each cache entry.
  5003. Arguments:
  5004. None.
  5005. Return Value:
  5006. Returns the size of the data stored in each cache entry.
  5007. --*/
  5008. VOID
  5009. IoPageCacheEntryAddReference (
  5010. PPAGE_CACHE_ENTRY Entry
  5011. );
  5012. /*++
  5013. Routine Description:
  5014. This routine increments the reference count on the given page cache entry.
  5015. It is assumed that either the lock for the file object associated with the
  5016. page cache entry is held or the caller already has a reference on the given
  5017. page cache entry.
  5018. Arguments:
  5019. Entry - Supplies a pointer to the page cache entry whose reference count
  5020. should be incremented.
  5021. Return Value:
  5022. None.
  5023. --*/
  5024. VOID
  5025. IoPageCacheEntryReleaseReference (
  5026. PPAGE_CACHE_ENTRY Entry
  5027. );
  5028. /*++
  5029. Routine Description:
  5030. This routine decrements the reference count on the given page cache entry.
  5031. Arguments:
  5032. Entry - Supplies a pointer to the page cache entry whose reference count
  5033. should be incremented.
  5034. Return Value:
  5035. None.
  5036. --*/
  5037. PHYSICAL_ADDRESS
  5038. IoGetPageCacheEntryPhysicalAddress (
  5039. PPAGE_CACHE_ENTRY Entry,
  5040. PULONG MapFlags
  5041. );
  5042. /*++
  5043. Routine Description:
  5044. This routine returns the physical address of the page cache entry.
  5045. Arguments:
  5046. Entry - Supplies a pointer to a page cache entry.
  5047. MapFlags - Supplies an optional pointer to the additional mapping flags
  5048. mandated by the underlying file object.
  5049. Return Value:
  5050. Returns the physical address of the given page cache entry.
  5051. --*/
  5052. PVOID
  5053. IoGetPageCacheEntryVirtualAddress (
  5054. PPAGE_CACHE_ENTRY Entry
  5055. );
  5056. /*++
  5057. Routine Description:
  5058. This routine gets the given page cache entry's virtual address.
  5059. Arguments:
  5060. Entry - Supplies a pointer to a page cache entry.
  5061. Return Value:
  5062. Returns the virtual address of the given page cache entry.
  5063. --*/
  5064. BOOL
  5065. IoSetPageCacheEntryVirtualAddress (
  5066. PPAGE_CACHE_ENTRY Entry,
  5067. PVOID VirtualAddress
  5068. );
  5069. /*++
  5070. Routine Description:
  5071. This routine attempts to set the virtual address in the given page cache
  5072. entry. It is assumed that the page cache entry's physical address is mapped
  5073. at the given virtual address.
  5074. Arguments:
  5075. Entry - Supplies as pointer to the page cache entry.
  5076. VirtualAddress - Supplies the virtual address to set in the page cache
  5077. entry.
  5078. Return Value:
  5079. Returns TRUE if the set succeeds or FALSE if another virtual address is
  5080. already set for the page cache entry.
  5081. --*/
  5082. VOID
  5083. IoMarkPageCacheEntryDirty (
  5084. PPAGE_CACHE_ENTRY Entry
  5085. );
  5086. /*++
  5087. Routine Description:
  5088. This routine marks the given page cache entry as dirty.
  5089. Arguments:
  5090. Entry - Supplies a pointer to a page cache entry.
  5091. Return Value:
  5092. None.
  5093. --*/
  5094. KERNEL_API
  5095. VOID
  5096. IoSetTestHook (
  5097. ULONG TestHookMask
  5098. );
  5099. /*++
  5100. Routine Description:
  5101. This routine sets the provided test hook mask in the test hook bitmask.
  5102. Arguments:
  5103. TestHookMask - Supplies the test hook mask that is to be added to the test
  5104. hook bitmask.
  5105. Return Value:
  5106. None.
  5107. --*/
  5108. KERNEL_API
  5109. VOID
  5110. IoClearTestHook (
  5111. ULONG TestHookMask
  5112. );
  5113. /*++
  5114. Routine Description:
  5115. This routine unsets the provided test hook mask from the test hook bitmask.
  5116. Arguments:
  5117. TestHookMask - Supplies the test hook mast hat is to be removed from the
  5118. test hook bitmask.
  5119. Return Value:
  5120. None.
  5121. --*/
  5122. KERNEL_API
  5123. VOID
  5124. IoSetIoObjectState (
  5125. PIO_OBJECT_STATE IoState,
  5126. ULONG Events,
  5127. BOOL Set
  5128. );
  5129. /*++
  5130. Routine Description:
  5131. This routine sets or clears one or more events in the I/O object state.
  5132. Arguments:
  5133. IoState - Supplies a pointer to the I/O object state to change.
  5134. Events - Supplies a mask of poll events to change. See POLL_EVENT_*
  5135. definitions.
  5136. Set - Supplies a boolean indicating if the event(s) should be set (TRUE) or
  5137. cleared (FALSE).
  5138. Return Value:
  5139. None.
  5140. --*/
  5141. KERNEL_API
  5142. KSTATUS
  5143. IoWaitForIoObjectState (
  5144. PIO_OBJECT_STATE IoState,
  5145. ULONG Events,
  5146. BOOL Interruptible,
  5147. ULONG TimeoutInMilliseconds,
  5148. PULONG ReturnedEvents
  5149. );
  5150. /*++
  5151. Routine Description:
  5152. This routine waits for the given events to trigger on the I/O object state.
  5153. Arguments:
  5154. IoState - Supplies a pointer to the I/O object state to wait on.
  5155. Events - Supplies a mask of poll events to wait for. See POLL_EVENT_*
  5156. definitions. Errors are non-maskable and will always be returned.
  5157. Interruptible - Supplies a boolean indicating whether or not the wait can
  5158. be interrupted if a signal is sent to the process on which this thread
  5159. runs. If TRUE is supplied, the caller must check the return status
  5160. code to find out if the wait was really satisfied or just interrupted.
  5161. TimeoutInMilliseconds - Supplies the number of milliseconds that the given
  5162. objects should be waited on before timing out. Use WAIT_TIME_INDEFINITE
  5163. to wait forever on these objects.
  5164. ReturnedEvents - Supplies an optional pointer where the poll events that
  5165. satisfied the wait will be returned on success. If the wait was
  5166. interrupted this will return 0.
  5167. Return Value:
  5168. Status code.
  5169. --*/
  5170. KERNEL_API
  5171. PIO_OBJECT_STATE
  5172. IoCreateIoObjectState (
  5173. BOOL HighPriority,
  5174. BOOL NonPaged
  5175. );
  5176. /*++
  5177. Routine Description:
  5178. This routine creates a new I/O object state structure with a reference
  5179. count of one.
  5180. Arguments:
  5181. HighPriority - Supplies a boolean indicating whether or not the I/O object
  5182. state should be prepared for high priority events.
  5183. NonPaged - Supplies a boolean indicating whether or not the I/O object
  5184. state should be allocated from non-paged pool. Default is paged pool
  5185. (FALSE).
  5186. Return Value:
  5187. Returns a pointer to the new state structure on success.
  5188. NULL on allocation failure.
  5189. --*/
  5190. KERNEL_API
  5191. VOID
  5192. IoDestroyIoObjectState (
  5193. PIO_OBJECT_STATE State,
  5194. BOOL NonPaged
  5195. );
  5196. /*++
  5197. Routine Description:
  5198. This routine destroys the given I/O object state.
  5199. Arguments:
  5200. State - Supplies a pointer to the I/O object state to destroy.
  5201. NonPaged - Supplies a boolean indicating whether or not the I/O object
  5202. was allocated from non-paged pool. Default is paged pool (FALSE).
  5203. Return Value:
  5204. None.
  5205. --*/
  5206. PVOID
  5207. IoReferenceFileObjectForHandle (
  5208. PIO_HANDLE IoHandle
  5209. );
  5210. /*++
  5211. Routine Description:
  5212. This routine returns an opaque pointer to the file object opened by the
  5213. given handle. It also adds a reference to the file object, which the caller
  5214. is responsible for freeing.
  5215. Arguments:
  5216. IoHandle - Supplies a pointer to the I/O handle whose underlying file
  5217. object should be referenced.
  5218. Return Value:
  5219. Returns an opaque pointer to the file object, with an incremented reference
  5220. count. The caller is responsible for releasing this reference.
  5221. --*/
  5222. VOID
  5223. IoFileObjectReleaseReference (
  5224. PVOID FileObject
  5225. );
  5226. /*++
  5227. Routine Description:
  5228. This routine releases an external reference on a file object taken by
  5229. referencing the file object for a handle.
  5230. Arguments:
  5231. FileObject - Supplies the opaque pointer to the file object.
  5232. Return Value:
  5233. None. The caller should not count on this pointer remaining unique after
  5234. this call returns.
  5235. --*/
  5236. KSTATUS
  5237. IoSetHandleAsynchronous (
  5238. PIO_HANDLE IoHandle,
  5239. HANDLE Descriptor,
  5240. BOOL Asynchronous
  5241. );
  5242. /*++
  5243. Routine Description:
  5244. This routine enables or disables asynchronous mode for the given I/O
  5245. handle.
  5246. Arguments:
  5247. IoHandle - Supplies a pointer to the I/O handle.
  5248. Descriptor - Supplies the descriptor to associate with the asynchronous
  5249. receiver state. This descriptor is passed to the signal information
  5250. when an I/O signal occurs. Note that this descriptor may become stale
  5251. if the handle is duped and the original closed, so the kernel should
  5252. never access it.
  5253. Asynchronous - Supplies a boolean indicating whether to set asynchronous
  5254. mode (TRUE) or clear it (FALSE).
  5255. Return Value:
  5256. Status code.
  5257. --*/
  5258. KSTATUS
  5259. IoGetSetSystemInformation (
  5260. BOOL FromKernelMode,
  5261. IO_INFORMATION_TYPE InformationType,
  5262. PVOID Data,
  5263. PUINTN DataSize,
  5264. BOOL Set
  5265. );
  5266. /*++
  5267. Routine Description:
  5268. This routine gets or sets system information.
  5269. Arguments:
  5270. FromKernelMode - Supplies a boolean indicating whether or not this request
  5271. (and the buffer associated with it) originates from user mode (FALSE)
  5272. or kernel mode (TRUE).
  5273. InformationType - Supplies the information type.
  5274. Data - Supplies a pointer to the data buffer where the data is either
  5275. returned for a get operation or given for a set operation.
  5276. DataSize - Supplies a pointer that on input contains the size of the
  5277. data buffer. On output, contains the required size of the data buffer.
  5278. Set - Supplies a boolean indicating if this is a get operation (FALSE) or
  5279. a set operation (TRUE).
  5280. Return Value:
  5281. Status code.
  5282. --*/