rtl.h 139 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444
  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. rtl.h
  9. Abstract:
  10. This header contains definitions for the common kernel runtime library.
  11. Author:
  12. Evan Green 24-Jul-2012
  13. --*/
  14. //
  15. // ------------------------------------------------------------------- Includes
  16. //
  17. #include <stdarg.h>
  18. //
  19. // --------------------------------------------------------------------- Macros
  20. //
  21. //
  22. // This macro reads a 64 bit value on a 32 bit processor whose value is updated
  23. // asynchronously. The value must be updated with the equivalent write macro.
  24. // The first argument is a pointer to the INT64_SYNC structure, and the second
  25. // is the address of the result to write it in to.
  26. //
  27. #define READ_INT64_SYNC(_Pointer, _Result) \
  28. do { \
  29. *(volatile ULONGLONG *)(_Result) = \
  30. (ULONGLONG)((_Pointer)->High1) << 32; \
  31. \
  32. *(volatile ULONGLONG *)(_Result) |= (ULONGLONG)((_Pointer)->Low); \
  33. \
  34. } while ((_Pointer)->High2 != (*(_Result) >> 32));
  35. //
  36. // This macro writes a 64 bit value on a 32 bit processor where readers are
  37. // simultaneously reading it. It updates the first high value, then the low
  38. // value, then the second high value to ensure that readers cannot observe a
  39. // torn read. The first parameter is a pointer to the INT64_SYNC structure,
  40. // the second parameter is the value to write.
  41. //
  42. #define WRITE_INT64_SYNC(_Pointer, _Value) \
  43. (_Pointer)->High1 = (ULONGLONG)(_Value) >> 32; \
  44. (_Pointer)->Low = (ULONG)(_Value); \
  45. (_Pointer)->High2 = (ULONGLONG)(_Value) >> 32; \
  46. //
  47. // This macro determines if the given year is a leap year. There's a leap year
  48. // every 4 years, except there's not a leap year every 100 years, except
  49. // there is a leap year every 400 years. Fun stuff.
  50. //
  51. #define IS_LEAP_YEAR(_Year) \
  52. ((((_Year) % 4) == 0) && ((((_Year) % 100) != 0) || (((_Year) % 400) == 0)))
  53. //
  54. // Character classification definitions
  55. //
  56. //
  57. // This macro returns non-zero if the given character is an upper case
  58. // character.
  59. //
  60. #define RtlIsCharacterUpperCase(_Character) \
  61. (((_Character) >= 'A') && ((_Character) <= 'Z'))
  62. //
  63. // This macro returns non-zero if the given character is a lower case character.
  64. //
  65. #define RtlIsCharacterLowerCase(_Character) \
  66. (((_Character) >= 'a') && ((_Character) <= 'z'))
  67. //
  68. // This macro returns non-zero if the given character is a digit.
  69. //
  70. #define RtlIsCharacterDigit(_Character) \
  71. (((_Character) >= '0') && ((_Character) <= '9'))
  72. //
  73. // This macro returns non-zero if the given character is in the alphabet.
  74. //
  75. #define RtlIsCharacterAlphabetic(_Character) \
  76. ((RtlIsCharacterUpperCase(_Character) || \
  77. RtlIsCharacterLowerCase(_Character)))
  78. //
  79. // This macro returns non-zero if the given character is alpha-numeric.
  80. //
  81. #define RtlIsCharacterAlphanumeric(_Character) \
  82. ((RtlIsCharacterAlphabetic(_Character) || RtlIsCharacterDigit(_Character)))
  83. //
  84. // This macro returns non-zero if the given character is in the ASCII character
  85. // set.
  86. //
  87. #define RtlIsCharacterAscii(_Character) (((_Character) & (~0x7F)) == 0)
  88. //
  89. // This macro returns non-zero if the given character is a blank character.
  90. //
  91. #define RtlIsCharacterBlank(_Character) \
  92. (((_Character) == ' ') || ((_Character) == '\t'))
  93. //
  94. // This macro returns non-zero if the given character is a control character.
  95. //
  96. #define RtlIsCharacterControl(_Character) \
  97. (((_Character) < ' ') || ((_Character) == 0x7F))
  98. //
  99. // This macro returns non-zero if the given character is whitespace.
  100. //
  101. #define RtlIsCharacterSpace(_Character) \
  102. (((_Character) == ' ') || ((_Character) == '\t') || \
  103. ((_Character) == '\n') || ((_Character) == '\r') || \
  104. ((_Character) == '\f') || ((_Character) == '\v'))
  105. //
  106. // This macro returns non-zero if the given character is a hexadecimal digit.
  107. //
  108. #define RtlIsCharacterHexDigit(_Character) \
  109. ((((_Character) >= '0') && ((_Character) <= '9')) || \
  110. (((_Character) >= 'A') && ((_Character) <= 'F')) || \
  111. (((_Character) >= 'a') && ((_Character) <= 'f')))
  112. //
  113. // This macro returns non-zero if the given character is punctuation.
  114. //
  115. #define RtlIsCharacterPunctuation(_Character) \
  116. ((RtlIsCharacterPrintable(_Character)) && \
  117. (!RtlIsCharacterAlphanumeric(_Character)) && \
  118. ((_Character) != ' '))
  119. //
  120. // This macro returns non-zero if the given character is a graphical character.
  121. //
  122. #define RtlIsCharacterGraphical(_Character) \
  123. ((RtlIsCharacterAlphanumeric(_Character)) || \
  124. (RtlIsCharacterPunctuation(_Character)))
  125. //
  126. // This macro returns non-zero if the given character is a printable character.
  127. //
  128. #define RtlIsCharacterPrintable(_Character) \
  129. ((RtlIsCharacterAlphanumeric(_Character)) || \
  130. (RtlIsCharacterPunctuation(_Character)) || \
  131. ((_Character) == ' '))
  132. //
  133. // This macro converts the given character into an ASCII character.
  134. //
  135. #define RtlConvertCharacterToAscii(_Character) ((_Character) & 0x7F)
  136. //
  137. // This macro converts the given character into a lower case character.
  138. //
  139. #define RtlConvertCharacterToLowerCase(_Character) \
  140. (RtlIsCharacterUpperCase(_Character) ? ((_Character) | 0x20) : (_Character))
  141. //
  142. // This macro converts the given character into an upper case character.
  143. //
  144. #define RtlConvertCharacterToUpperCase(_Character) \
  145. (RtlIsCharacterLowerCase(_Character) ? \
  146. ((_Character) & (~0x20)) : (_Character))
  147. //
  148. // Wide character classification definitions
  149. //
  150. //
  151. // This macro returns non-zero if the given character is an upper case
  152. // character.
  153. //
  154. #define RtlIsCharacterUpperCaseWide(_Character) \
  155. (((_Character) >= L'A') && ((_Character) <= L'Z'))
  156. //
  157. // This macro returns non-zero if the given character is a lower case character.
  158. //
  159. #define RtlIsCharacterLowerCaseWide(_Character) \
  160. (((_Character) >= L'a') && ((_Character) <= L'z'))
  161. //
  162. // This macro returns non-zero if the given character is a digit.
  163. //
  164. #define RtlIsCharacterDigitWide(_Character) \
  165. (((_Character) >= L'0') && ((_Character) <= L'9'))
  166. //
  167. // This macro returns non-zero if the given character is in the alphabet.
  168. //
  169. #define RtlIsCharacterAlphabeticWide(_Character) \
  170. ((RtlIsCharacterUpperCaseWide(_Character) || \
  171. RtlIsCharacterLowerCaseWide(_Character)))
  172. //
  173. // This macro returns non-zero if the given character is alpha-numeric.
  174. //
  175. #define RtlIsCharacterAlphanumericWide(_Character) \
  176. ((RtlIsCharacterAlphabeticWide(_Character) || \
  177. RtlIsCharacterDigitWide(_Character)))
  178. //
  179. // This macro returns non-zero if the given character is in the ASCII character
  180. // set.
  181. //
  182. #define RtlIsCharacterAsciiWide(_Character) (((_Character) & (~0x7F)) == 0)
  183. //
  184. // This macro returns non-zero if the given character is a blank character.
  185. //
  186. #define RtlIsCharacterBlankWide(_Character) \
  187. (((_Character) == L' ') || ((_Character) == L'\t'))
  188. //
  189. // This macro returns non-zero if the given character is a control character.
  190. //
  191. #define RtlIsCharacterControlWide(_Character) \
  192. (((_Character) < L' ') || ((_Character) == 0x7F))
  193. //
  194. // This macro returns non-zero if the given character is whitespace.
  195. //
  196. #define RtlIsCharacterSpaceWide(_Character) \
  197. (((_Character) == L' ') || ((_Character) == L'\t') || \
  198. ((_Character) == L'\n') || ((_Character) == L'\r') || \
  199. ((_Character) == L'\f') || ((_Character) == L'\v'))
  200. //
  201. // This macro returns non-zero if the given character is a hexadecimal digit.
  202. //
  203. #define RtlIsCharacterHexDigitWide(_Character) \
  204. ((((_Character) >= L'0') && ((_Character) <= L'9')) || \
  205. (((_Character) >= L'A') && ((_Character) <= L'F')) || \
  206. (((_Character) >= L'a') && ((_Character) <= L'f')))
  207. //
  208. // This macro returns non-zero if the given character is punctuation.
  209. //
  210. #define RtlIsCharacterPunctuationWide(_Character) \
  211. ((RtlIsCharacterPrintableWide(_Character)) && \
  212. (!RtlIsCharacterAlphanumericWide(_Character)) && \
  213. ((_Character) != L' '))
  214. //
  215. // This macro returns non-zero if the given character is a graphical character.
  216. //
  217. #define RtlIsCharacterGraphicalWide(_Character) \
  218. ((RtlIsCharacterAlphanumericWide(_Character)) || \
  219. (RtlIsCharacterPunctuationWide(_Character)))
  220. //
  221. // This macro returns non-zero if the given character is a printable character.
  222. //
  223. #define RtlIsCharacterPrintableWide(_Character) \
  224. ((RtlIsCharacterAlphanumericWide(_Character)) || \
  225. (RtlIsCharacterPunctuationWide(_Character)) || \
  226. ((_Character) == L' '))
  227. //
  228. // This macro converts the given character into an ASCII character.
  229. //
  230. #define RtlConvertCharacterToAsciiWide(_Character) ((_Character) & 0x7F)
  231. //
  232. // This macro converts the given character into a lower case character.
  233. //
  234. #define RtlConvertCharacterToLowerCaseWide(_Character) \
  235. (RtlIsCharacterUpperCaseWide(_Character) ? \
  236. ((_Character) | 0x20) : (_Character))
  237. //
  238. // This macro converts the given character into an upper case character.
  239. //
  240. #define RtlConvertCharacterToUpperCaseWide(_Character) \
  241. (RtlIsCharacterLowerCaseWide(_Character) ? \
  242. ((_Character) & (~0x20)) : (_Character))
  243. //
  244. // ---------------------------------------------------------------- Definitions
  245. //
  246. #ifndef RTL_API
  247. #define RTL_API __DLLIMPORT
  248. #endif
  249. #define STRING_TERMINATOR '\0'
  250. #define WIDE_STRING_TERMINATOR L'\0'
  251. //
  252. // Define the maximum number of bytes in a multibyte character.
  253. //
  254. #define MULTIBYTE_MAX 16
  255. //
  256. // Define the number of characters in the scan unput buffer. This must be as
  257. // large as both a DOUBLE_SCAN_STRING_SIZE and MULTIBYTE_MAX.
  258. //
  259. #define SCANNER_UNPUT_SIZE 16
  260. //
  261. // Defines the length of a string printing a UUID, not including the NULL
  262. // terminator.
  263. //
  264. #define UUID_STRING_LENGTH 37
  265. //
  266. // Define time unit constants.
  267. //
  268. #define NANOSECONDS_PER_SECOND 1000000000ULL
  269. #define MICROSECONDS_PER_SECOND 1000000ULL
  270. #define MILLISECONDS_PER_SECOND 1000ULL
  271. #define MICROSECONDS_PER_MILLISECOND 1000ULL
  272. #define NANOSECONDS_PER_MICROSECOND 1000ULL
  273. #define NANOSECONDS_PER_MILLISECOND 1000000ULL
  274. //
  275. // Define some constants used for manipulating float types.
  276. //
  277. #define FLOAT_SIGN_BIT 0x80000000
  278. #define FLOAT_SIGN_BIT_SHIFT 31
  279. #define FLOAT_NAN 0x7F800000
  280. #define FLOAT_NAN_EXPONENT 0xFF
  281. #define FLOAT_VALUE_MASK 0x007FFFFFUL
  282. #define FLOAT_EXPONENT_MASK 0x7F800000UL
  283. #define FLOAT_EXPONENT_SHIFT 23
  284. #define FLOAT_EXPONENT_BIAS 0x7F
  285. #define FLOAT_ONE_WORD 0x3F800000
  286. #define FLOAT_TRUNCATE_VALUE_MASK 0xFFFFF000
  287. //
  288. // Define some constants used for manipulating double floating point types.
  289. //
  290. #define DOUBLE_SIGN_BIT 0x8000000000000000ULL
  291. #define DOUBLE_SIGN_BIT_SHIFT 63
  292. #define DOUBLE_EXPONENT_MASK 0x7FF0000000000000ULL
  293. #define DOUBLE_EXPONENT_SHIFT 52
  294. #define DOUBLE_EXPONENT_BIAS 0x3FF
  295. #define DOUBLE_NAN_EXPONENT 0x7FF
  296. #define DOUBLE_VALUE_MASK 0x000FFFFFFFFFFFFFULL
  297. #define DOUBLE_HIGH_WORD_SHIFT (sizeof(ULONG) * BITS_PER_BYTE)
  298. #define DOUBLE_SIGNIFICAND_HEX_DIGITS 13
  299. #define DOUBLE_ONE_HIGH_WORD 0x3FF00000
  300. #define DOUBLE_HIGH_VALUE_MASK 0x000FFFFF
  301. #define NAN_HIGH_WORD 0x7FF00000
  302. //
  303. // Define macros to functions that will work on the native integer size of the
  304. // processors.
  305. //
  306. #if defined(__amd64)
  307. #define RtlAtomicExchange(_Pointer, _Value) \
  308. RtlAtomicExchange64((PULONGLONG)(_Pointer), (_Value))
  309. #define RtlAtomicCompareExchange(_Pointer, _Exchange, _Compare) \
  310. RtlAtomicCompareExchange64((PULONGLONG)(_Pointer), \
  311. (_Exchange), \
  312. (_Compare))
  313. #define RtlAtomicAdd(_Pointer, _Value) \
  314. RtlAtomicAdd64((PULONGLONG)(_Pointer), (_Value))
  315. #define RtlAtomicOr(_Pointer, _Value) \
  316. RtlAtomicAdd64((PULONGLONG)(_Pointer), (_Value))
  317. #define RtlCountLeadingZeros RtlCountLeadingZeros64
  318. #define RtlCountTrailingZeros RtlCountTrailingZeros64
  319. #else
  320. #define RtlAtomicExchange(_Pointer, _Value) \
  321. RtlAtomicExchange32((PULONG)(_Pointer), (_Value))
  322. #define RtlAtomicCompareExchange(_Pointer, _Exchange, _Compare) \
  323. RtlAtomicCompareExchange32((PULONG)(_Pointer), \
  324. (_Exchange), \
  325. (_Compare))
  326. #define RtlAtomicAdd(_Pointer, _Value) \
  327. RtlAtomicAdd32((PULONG)(_Pointer), (_Value))
  328. #define RtlAtomicOr(_Pointer, _Value) \
  329. RtlAtomicAdd32((PULONG)(_Pointer), (_Value))
  330. #define RtlCountLeadingZeros RtlCountLeadingZeros32
  331. #define RtlCountTrailingZeros RtlCountTrailingZeros32
  332. #endif
  333. #define DOUBLE_SCAN_STRING_SIZE 8
  334. //
  335. // Define some time constants.
  336. //
  337. #define SECONDS_PER_DAY (SECONDS_PER_HOUR * HOURS_PER_DAY)
  338. #define SECONDS_PER_HOUR (SECONDS_PER_MINUTE * MINUTES_PER_HOUR)
  339. #define SECONDS_PER_MINUTE 60
  340. #define MINUTES_PER_HOUR 60
  341. #define HOURS_PER_DAY 24
  342. #define DAYS_PER_WEEK 7
  343. #define DAYS_PER_YEAR 365
  344. #define DAYS_PER_LEAP_YEAR 366
  345. #define MONTHS_PER_YEAR 12
  346. #define YEARS_PER_CENTURY 100
  347. #define TIME_ZONE_ABBREVIATION_SIZE 5
  348. //
  349. // Define the difference between the system time epoch, January 1, 2001, and
  350. // the standard C library epoch, January 1, 1970.
  351. //
  352. #define SYSTEM_TIME_TO_EPOCH_DELTA (978307200LL)
  353. //
  354. // Define memory heap flags.
  355. //
  356. //
  357. // Set this flag to enable allocation tag statistics collection.
  358. //
  359. #define MEMORY_HEAP_FLAG_COLLECT_TAG_STATISTICS 0x00000001
  360. //
  361. // Set this flag to validate the heap periodically.
  362. //
  363. #define MEMORY_HEAP_FLAG_PERIODIC_VALIDATION 0x00000002
  364. //
  365. // Set this flag to disallow partial frees of underlying regions the heap has
  366. // allocated. Normally the heap assumes an interface where the heap can
  367. // allocate a bunch of memory and then free it in piecemeal if it likes.
  368. // Setting this flag forces the heap to only free complete areas it has
  369. // allocated.
  370. //
  371. #define MEMORY_HEAP_FLAG_NO_PARTIAL_FREES 0x00000004
  372. //
  373. // Define the number of small bins to use in the memory heap. Each bin holds
  374. // chunks with equal sizes, spaced 8 apart, less than HEAP_MIN_LARGE_SIZE
  375. // bytes.
  376. //
  377. #define HEAP_SMALL_BIN_COUNT 32U
  378. //
  379. // Define the number of heap bins to use in the heap. Each bin contains the
  380. // root of a tree holding a range of sizes. There are 2 equally spaced tree
  381. // bins for each power of two from HEAP_TREE_SHIFT to HEAP_TREE_SHIFT + 16. The
  382. // last bin holds anything larger.
  383. //
  384. #define HEAP_TREE_BIN_COUNT 32U
  385. //
  386. // Define Red-Black tree flags.
  387. //
  388. #define RED_BLACK_TREE_FLAG_PERIODIC_VALIDATION 0x00000001
  389. //
  390. // ------------------------------------------------------ Data Type Definitions
  391. //
  392. typedef enum _COMPARISON_RESULT {
  393. ComparisonResultInvalid,
  394. ComparisonResultSame,
  395. ComparisonResultAscending,
  396. ComparisonResultDescending,
  397. } COMPARISON_RESULT, *PCOMPARISON_RESULT;
  398. typedef enum _CHARACTER_ENCODING {
  399. CharacterEncodingDefault,
  400. CharacterEncodingAscii,
  401. CharacterEncodingMax
  402. } CHARACTER_ENCODING, *PCHARACTER_ENCODING;
  403. typedef enum _HEAP_CORRUPTION_CODE {
  404. HeapCorruptionInvalid,
  405. HeapCorruptionBufferOverrun,
  406. HeapCorruptionDoubleFree,
  407. HeapCorruptionCorruptStructures,
  408. HeapCorruptionDoubleDestroy
  409. } HEAP_CORRUPTION_CODE, *PHEAP_CORRUPTION_CODE;
  410. //
  411. // TODO: Make this just an integer on x64.
  412. //
  413. typedef struct _INT64_SYNC {
  414. volatile ULONG High1;
  415. volatile ULONG Low;
  416. volatile ULONG High2;
  417. } INT64_SYNC, *PINT64_SYNC;
  418. typedef struct _RED_BLACK_TREE_NODE RED_BLACK_TREE_NODE, *PRED_BLACK_TREE_NODE;
  419. typedef struct _RED_BLACK_TREE RED_BLACK_TREE, *PRED_BLACK_TREE;
  420. typedef
  421. COMPARISON_RESULT
  422. (*PCOMPARE_RED_BLACK_TREE_NODES) (
  423. PRED_BLACK_TREE Tree,
  424. PRED_BLACK_TREE_NODE FirstNode,
  425. PRED_BLACK_TREE_NODE SecondNode
  426. );
  427. /*++
  428. Routine Description:
  429. This routine compares two Red-Black tree nodes.
  430. Arguments:
  431. Tree - Supplies a pointer to the Red-Black tree that owns both nodes.
  432. FirstNode - Supplies a pointer to the left side of the comparison.
  433. SecondNode - Supplies a pointer to the second side of the comparison.
  434. Return Value:
  435. Same if the two nodes have the same value.
  436. Ascending if the first node is less than the second node.
  437. Descending if the second node is less than the first node.
  438. --*/
  439. typedef
  440. VOID
  441. (*PRED_BLACK_TREE_ITERATION_ROUTINE) (
  442. PRED_BLACK_TREE Tree,
  443. PRED_BLACK_TREE_NODE Node,
  444. ULONG Level,
  445. PVOID Context
  446. );
  447. /*++
  448. Routine Description:
  449. This routine is called once for each node in the tree (via an in order
  450. traversal). It assumes that the tree will not be modified during the
  451. traversal.
  452. Arguments:
  453. Tree - Supplies a pointer to the tree being enumerated.
  454. Node - Supplies a pointer to the node.
  455. Level - Supplies the depth into the tree that this node exists at. 0 is
  456. the root.
  457. Context - Supplies an optional opaque pointer of context that was provided
  458. when the iteration was requested.
  459. Return Value:
  460. None.
  461. --*/
  462. /*++
  463. Structure Description:
  464. This structure defines a node of a Red-Black tree node.
  465. Members:
  466. Red - Stores a boolean indicating if the node is colored red (TRUE) or
  467. black (FALSE).
  468. LeftChild - Stores a pointer to the left child of this node.
  469. RightChild - Stores a pointer to the right child of this node.
  470. Parent - Stores a pointer to the parent of this node.
  471. --*/
  472. struct _RED_BLACK_TREE_NODE {
  473. BOOL Red;
  474. PRED_BLACK_TREE_NODE LeftChild;
  475. PRED_BLACK_TREE_NODE RightChild;
  476. PRED_BLACK_TREE_NODE Parent;
  477. };
  478. /*++
  479. Structure Description:
  480. This structure defines a Red-Black Tree.
  481. Members:
  482. Flags - Stores a bitfield of flags about the tree. See
  483. RED_BLACK_TREE_FLAG_* definitions.
  484. CompareFunction - Stores a pointer to a function used to compare two nodes.
  485. Root - Stores the root node of the tree, which is a sentinal node. The real
  486. root is the left child of this guy.
  487. NullNode - Stores a NULL node, a sentinal, used to avoid tons of NULL checks
  488. throughout the algorithm. All leaf nodes point to this NULL node.
  489. CallCount - Stores the total number of calls to insert or delete.
  490. --*/
  491. struct _RED_BLACK_TREE {
  492. ULONG Flags;
  493. PCOMPARE_RED_BLACK_TREE_NODES CompareFunction;
  494. RED_BLACK_TREE_NODE Root;
  495. RED_BLACK_TREE_NODE NullNode;
  496. ULONG CallCount;
  497. };
  498. /*++
  499. Structure Description:
  500. This structure stores character encoding state used to convert multibyte
  501. characters to wide characters. Callers should treat this structure as
  502. opaque and not access members directly, as they are likely to change or
  503. be removed without notice.
  504. Members:
  505. Encoding - Stores the character encoding type.
  506. --*/
  507. typedef struct _MULTIBYTE_STATE {
  508. CHARACTER_ENCODING Encoding;
  509. } MULTIBYTE_STATE, *PMULTIBYTE_STATE;
  510. typedef struct _PRINT_FORMAT_CONTEXT
  511. PRINT_FORMAT_CONTEXT, *PPRINT_FORMAT_CONTEXT;
  512. typedef
  513. BOOL
  514. (*PPRINT_FORMAT_WRITE_CHARACTER) (
  515. INT Character,
  516. PPRINT_FORMAT_CONTEXT Context
  517. );
  518. /*++
  519. Routine Description:
  520. This routine writes a character to the output during a printf-style
  521. formatting operation.
  522. Arguments:
  523. Character - Supplies the character to be written.
  524. Context - Supplies a pointer to the printf-context.
  525. Return Value:
  526. TRUE on success.
  527. FALSE on failure.
  528. --*/
  529. /*++
  530. Structure Description:
  531. This structure defines the context handed to a printf format function.
  532. Members:
  533. WriteCharacter - Stores a pointer to a function used to write a
  534. character to the destination of the formatted string operation. Usually
  535. this is a file or string.
  536. Context - Stores a pointer's worth of additional context. This pointer is
  537. not touched by the format string function, it's generally used inside
  538. the write character routine.
  539. Limit - Stores the maximum number of characters that should be sent to
  540. the write character routine. If this value is zero, an unlimited number
  541. of characters will be sent to the write character routine.
  542. CharactersWritten - Stores the number of characters that have been
  543. written so far. The print format routine will increment this after each
  544. successful byte is written.
  545. State - Stores the multibyte character state.
  546. --*/
  547. struct _PRINT_FORMAT_CONTEXT {
  548. PPRINT_FORMAT_WRITE_CHARACTER WriteCharacter;
  549. PVOID Context;
  550. ULONG Limit;
  551. ULONG CharactersWritten;
  552. MULTIBYTE_STATE State;
  553. };
  554. typedef struct _SCAN_INPUT SCAN_INPUT, *PSCAN_INPUT;
  555. typedef
  556. BOOL
  557. (*PSCANNER_GET_INPUT) (
  558. PSCAN_INPUT Input,
  559. PCHAR Character
  560. );
  561. /*++
  562. Routine Description:
  563. This routine retrieves another byte of input from the input scanner.
  564. Arguments:
  565. Input - Supplies a pointer to the input scanner structure.
  566. Character - Supplies a pointer where the character will be returned on
  567. success.
  568. Return Value:
  569. TRUE if a character was read.
  570. FALSE if the end of the file or string was encountered.
  571. --*/
  572. typedef
  573. BOOL
  574. (*PSCANNER_GET_INPUT_WIDE) (
  575. PSCAN_INPUT Input,
  576. PWCHAR Character
  577. );
  578. /*++
  579. Routine Description:
  580. This routine retrieves another wide character of input from the input
  581. scanner.
  582. Arguments:
  583. Input - Supplies a pointer to the input scanner structure.
  584. Character - Supplies a pointer where the character will be returned on
  585. success.
  586. Return Value:
  587. TRUE if a character was read.
  588. FALSE if the end of the file or string was encountered.
  589. --*/
  590. /*++
  591. Structure Description:
  592. This structure defines a scanner input structure which is used to get input
  593. from either a string or file pointer.
  594. Members:
  595. GetInput - Stores a pointer to the function called to get another character.
  596. String - Stores a pointer to the string for string driven inputs.
  597. WideString - Stores a pointer to the wide string for string driven inputs.
  598. Context - Stores a context pointer associated with this scan operation
  599. (such as a stream pointer).
  600. StringSize - Stores the size of the string for string driven inputs.
  601. CharactersRead - Stores the number of characters read.
  602. UnputCharacters - Stores a buffer of characters that were put back into the
  603. input buffer.
  604. ValidUnputCharacters - Stores the number of valid unput characters in the
  605. buffer.
  606. State - Stores the multibyte state.
  607. --*/
  608. struct _SCAN_INPUT {
  609. union {
  610. PSCANNER_GET_INPUT GetInput;
  611. PSCANNER_GET_INPUT_WIDE GetInputWide;
  612. } ReadU;
  613. union {
  614. PCSTR String;
  615. PCWSTR WideString;
  616. PVOID Context;
  617. } DataU;
  618. ULONG StringSize;
  619. ULONG CharactersRead;
  620. WCHAR UnputCharacters[SCANNER_UNPUT_SIZE];
  621. ULONG ValidUnputCharacters;
  622. MULTIBYTE_STATE State;
  623. };
  624. /*++
  625. Structure Description:
  626. This union allows the user to pick at the bits inside of an unsigned long
  627. long.
  628. Members:
  629. Ulong - Stores the parts in ULONGs.
  630. Ulonglong - Stores the bits of the 64 bit double.
  631. --*/
  632. typedef union _ULONGLONG_PARTS {
  633. struct {
  634. ULONG Low;
  635. ULONG High;
  636. } Ulong;
  637. ULONGLONG Ulonglong;
  638. } ULONGLONG_PARTS, *PULONGLONG_PARTS;
  639. /*++
  640. Structure Description:
  641. This union allows the user to pick at the bits inside of a double.
  642. Members:
  643. Double - Stores the value in its natural floating point form.
  644. Ulong - Stores the parts of the double in ULONGs.
  645. Ulonglong - Stores the bits of the 64 bit double.
  646. --*/
  647. typedef union _DOUBLE_PARTS {
  648. double Double;
  649. struct {
  650. ULONG Low;
  651. ULONG High;
  652. } Ulong;
  653. ULONGLONG Ulonglong;
  654. } DOUBLE_PARTS, *PDOUBLE_PARTS;
  655. /*++
  656. Structure Description:
  657. This union allows the user to pick at the bits inside of a float.
  658. Members:
  659. Float - Stores the value in its natural floating point form.
  660. Ulong - Stores the bits of the float.
  661. --*/
  662. typedef union _FLOAT_PARTS {
  663. float Float;
  664. ULONG Ulong;
  665. } FLOAT_PARTS, *PFLOAT_PARTS;
  666. typedef
  667. VOID
  668. (*PTIME_ZONE_LOCK_FUNCTION) (
  669. );
  670. /*++
  671. Routine Description:
  672. This routine implements an acquire or release of the lock responsible for
  673. guarding the global time zone data.
  674. Arguments:
  675. None.
  676. Return Value:
  677. None.
  678. --*/
  679. typedef
  680. PVOID
  681. (*PTIME_ZONE_REALLOCATE_FUNCTION) (
  682. PVOID Memory,
  683. UINTN NewSize
  684. );
  685. /*++
  686. Routine Description:
  687. This routine allocates, reallocates, or frees memory for the time zone
  688. library.
  689. Arguments:
  690. Memory - Supplies the original active allocation. If this parameter is
  691. NULL, this routine will simply allocate memory.
  692. NewSize - Supplies the new required size of the allocation. If this is
  693. 0, then the original allocation will simply be freed.
  694. Return Value:
  695. Returns a pointer to a buffer with the new size (and original contents) on
  696. success. This may be a new buffer or the same one.
  697. NULL on failure or if the new size supplied was zero.
  698. --*/
  699. /*++
  700. Structure Description:
  701. This structure describes the system's concept of calendar time, which is
  702. represented as the number of seconds since midnight January 1, 2001 GMT.
  703. Members:
  704. Seconds - Stores the number of seconds since midnight January 1, 2001 GMT.
  705. Nanoseconds - Stores the nanoseconds portion of the time. This is usually
  706. a positive number, even for negative seconds values.
  707. --*/
  708. typedef struct _SYSTEM_TIME {
  709. LONGLONG Seconds;
  710. LONG Nanoseconds;
  711. } SYSTEM_TIME, *PSYSTEM_TIME;
  712. /*++
  713. Structure Description:
  714. This structure contains the broken down fields of a calendar date.
  715. Members:
  716. Year - Stores the year. Valid values are between 1 and 9999.
  717. Month - Stores the month. Valid values are between 0 and 11.
  718. Day - Stores the day of the month. Valid values are between 1 and 31.
  719. Hour - Stores the hour. Valid values are between 0 and 23.
  720. Minute - Stores the minute. Valid values are between 0 and 59.
  721. Second - Stores the second. Valid values are between 0 and 59. Arguably
  722. with leap seconds 60 is a valid value too, but the time functions will
  723. all roll that over into the next minute.
  724. Nanosecond - Stores the nanosecond. Valid values are between 0 and
  725. 999,999,999.
  726. Weekday - Stores the day of the week. Valid values are between 0 and 6,
  727. with 0 being Sunday and 6 being Saturday.
  728. YearDay - Stores the day of the year. Valid values are between 0 and 365.
  729. IsDaylightSaving - Stores a value indicating if the given time is
  730. represented in daylight saving time. Usually 0 indicates standard
  731. time, 1 indicates daylight saving time, and -1 indicates "unknown".
  732. GmtOffset - Stores the offset from Greenwich Mean Time in seconds that
  733. this time is interpreted in.
  734. TimeZone - Stores a pointer to a string containing the time zone name.
  735. --*/
  736. typedef struct _CALENDAR_TIME {
  737. LONG Year;
  738. LONG Month;
  739. LONG Day;
  740. LONG Hour;
  741. LONG Minute;
  742. LONG Second;
  743. LONG Nanosecond;
  744. LONG Weekday;
  745. LONG YearDay;
  746. LONG IsDaylightSaving;
  747. LONG GmtOffset;
  748. PCSTR TimeZone;
  749. } CALENDAR_TIME, *PCALENDAR_TIME;
  750. typedef struct _MEMORY_HEAP MEMORY_HEAP, *PMEMORY_HEAP;
  751. typedef
  752. PVOID
  753. (*PHEAP_ALLOCATE) (
  754. PMEMORY_HEAP Heap,
  755. UINTN Size,
  756. UINTN Tag
  757. );
  758. /*++
  759. Routine Description:
  760. This routine is called when the heap wants to expand and get more space.
  761. Arguments:
  762. Heap - Supplies a pointer to the heap to allocate from.
  763. Size - Supplies the size of the allocation request, in bytes.
  764. Tag - Supplies a 32-bit tag to associate with this allocation for debugging
  765. purposes. These are usually four ASCII characters so as to stand out
  766. when a poor developer is looking at a raw memory dump. It could also be
  767. a return address.
  768. Return Value:
  769. Returns a pointer to the allocation if successful, or NULL if the
  770. allocation failed.
  771. --*/
  772. typedef
  773. BOOL
  774. (*PHEAP_FREE) (
  775. PMEMORY_HEAP Heap,
  776. PVOID Memory,
  777. UINTN Size
  778. );
  779. /*++
  780. Routine Description:
  781. This routine is called when the heap wants to release space it had
  782. previously been allocated.
  783. Arguments:
  784. Heap - Supplies a pointer to the heap the memory was originally allocated
  785. from.
  786. Memory - Supplies the allocation returned by the allocation routine.
  787. Size - Supplies the size of the allocation to free.
  788. Return Value:
  789. TRUE if the memory was successfully freed.
  790. FALSE if the memory could not be freed.
  791. --*/
  792. typedef
  793. VOID
  794. (*PHEAP_CORRUPTION_ROUTINE) (
  795. PMEMORY_HEAP Heap,
  796. HEAP_CORRUPTION_CODE Code,
  797. PVOID Parameter
  798. );
  799. /*++
  800. Routine Description:
  801. This routine is called when the heap detects internal corruption.
  802. Arguments:
  803. Heap - Supplies a pointer to the heap containing the corruption.
  804. Code - Supplies the code detailing the problem.
  805. Parameter - Supplies an optional parameter pointing at a problem area.
  806. Return Value:
  807. None. This routine probably shouldn't return.
  808. --*/
  809. /*++
  810. Structure Description:
  811. This structure defines statistics for one allocation tag.
  812. Members:
  813. Node - Stores the Red-Black tree node information for this allocation
  814. statistic.
  815. Tag - Stores the allocation tag associated with this statistic.
  816. LargestAllocation - Stores the largest single allocation ever made under
  817. this tag, in bytes.
  818. ActiveSize - Stores the total number of bytes currently allocated under
  819. this tag.
  820. LargestActiveSize - Stores the largest number of bytes the active size has
  821. ever been.
  822. LifetimeAllocationSize - Stores the total number of bytes that have been
  823. allocated under this tag (not necessarily all at once).
  824. ActiveAllocationCount - Stores the current number of allocations under this
  825. allocation tag.
  826. LargestActiveAllocationCount - Stores the largest number the active
  827. allocation count has ever been for this tag.
  828. --*/
  829. typedef struct _MEMORY_HEAP_TAG_STATISTIC {
  830. RED_BLACK_TREE_NODE Node;
  831. ULONG Tag;
  832. ULONG LargestAllocation;
  833. ULONGLONG ActiveSize;
  834. ULONGLONG LargestActiveSize;
  835. ULONGLONG LifetimeAllocationSize;
  836. ULONG ActiveAllocationCount;
  837. ULONG LargestActiveAllocationCount;
  838. } MEMORY_HEAP_TAG_STATISTIC, *PMEMORY_HEAP_TAG_STATISTIC;
  839. /*++
  840. Structure Description:
  841. This structure defines heap-wide memory heap statistics.
  842. Members:
  843. TotalHeapSize - Stores the total size of the memory heap, in bytes.
  844. MaxHeapSize - Stores the maximum size the heap has ever been.
  845. FreeListSize - Stores the amount of free memory in the heap, in bytes.
  846. DirectAllocationSize - Stores the number of bytes of user allocations that
  847. were transparently allocated from the underlying allocator, and not
  848. within a heap segment.
  849. Allocations - Stores the number of outstanding allocations.
  850. TotalAllocationCalls - Stores the number of calls to allocate memory since
  851. the heap's initialization.
  852. FailedAllocations - Stores the number of calls to allocate memory that
  853. have been failed.
  854. TotalFreeCalls - Stores the number of calls to free memory since the heap's
  855. initialization.
  856. --*/
  857. typedef struct _MEMORY_HEAP_STATISTICS {
  858. UINTN TotalHeapSize;
  859. UINTN MaxHeapSize;
  860. UINTN FreeListSize;
  861. UINTN DirectAllocationSize;
  862. UINTN Allocations;
  863. UINTN TotalAllocationCalls;
  864. UINTN FailedAllocations;
  865. UINTN TotalFreeCalls;
  866. } MEMORY_HEAP_STATISTICS, *PMEMORY_HEAP_STATISTICS;
  867. /*++
  868. Structure Description:
  869. This structure defines optionally collected memory heap tag statistics.
  870. Members:
  871. Tree - Stores a pointer to the Red-Black tree storing the tags and their
  872. frequencies.
  873. StatisticEntry - Stores the built in entry for the statistic tag itself, to
  874. avoid infinite recursion.
  875. TagCount - Stores the number of unique tags that have been used for
  876. allocations.
  877. --*/
  878. typedef struct _MEMORY_HEAP_TAG_STATISTICS {
  879. RED_BLACK_TREE Tree;
  880. MEMORY_HEAP_TAG_STATISTIC StatisticEntry;
  881. UINTN TagCount;
  882. } MEMORY_HEAP_TAG_STATISTICS, *PMEMORY_HEAP_TAG_STATISTICS;
  883. typedef UINTN HEAP_BINMAP, *PHEAP_BINMAP;
  884. typedef UINTN HEAP_BINDEX, *PHEAP_BINDEX;
  885. typedef struct _HEAP_CHUNK HEAP_CHUNK, *PHEAP_CHUNK;
  886. typedef struct _HEAP_TREE_CHUNK HEAP_TREE_CHUNK, *PHEAP_TREE_CHUNK;
  887. typedef struct _HEAP_SEGMENT HEAP_SEGMENT, *PHEAP_SEGMENT;
  888. /*++
  889. Structure Description:
  890. This structure defines a segment of memory that the heap owns for carving
  891. up into allocations.
  892. Members:
  893. Base - Stores the base address of the segment.
  894. Size - Stores the size of the segment.
  895. Next - Stores a pointer to the next segment.
  896. Flags - Stores a bitfield of flags describing the segment.
  897. --*/
  898. struct _HEAP_SEGMENT {
  899. CHAR *Base;
  900. UINTN Size;
  901. PHEAP_SEGMENT Next;
  902. ULONG Flags;
  903. };
  904. /*++
  905. Structure Description:
  906. This structure defines a memory heap.
  907. Members:
  908. Magic - Stores a magic number, HEAP_MAGIC.
  909. Flags - Stores a bitfield of flags governing the behavior of the heap. See
  910. MEMORY_HEAP_FLAG_* definitions.
  911. AllocateFunction - Stores a pointer to a function called when the heap
  912. wants to expand and needs to allocate more memory.
  913. FreeFunction - Stores a pointer to a function called when the heap wants
  914. to a free a previously allocated region of memory.
  915. CorruptionFunction - Stores a pointer to a function to call if heap
  916. corruption is detected.
  917. AllocationTag - Stores the magic number to put into the magic field of
  918. each allocation. This is also the tag that gets passed to the
  919. allocation routine when expanding the heap.
  920. MinimumExpansionSize - Stores the minimum size, in bytes, for a heap
  921. expansion.
  922. ExpansionGranularity - Stores the granularity of the expansion size. This
  923. must be a power of two.
  924. ExpansionSize - Stores the size of the previous expansion.
  925. PreviousExpansionSize - Stores the size of the last expansion, for
  926. expansion doubling.
  927. Statistics - Stores heap-wide statistics.
  928. TagStatistics - Stores the tag statistics structure.
  929. SmallMap - Stores the bitmap of small bins that have valid entries in them.
  930. TreeMap - Stores the bitmap of tree bins that have valid entries in them.
  931. DirectAllocationThreshold - Stores the threshold value in bytes above which
  932. the heap just directly turns around and calls the allocator underneath.
  933. DesignatedVictimSize - Stores the size of the designated victim entry.
  934. TopSize - Stores the size of the heap wilderness.
  935. LeastAddress - Stores the lowest address the heap manages, or NULL if
  936. the heap has no memory at all.
  937. DesignatedVictim - Stores a pointer to the designated victim to carve
  938. memory out of.
  939. Top - Stores a pointer to the wilderness, the free region bordering the
  940. highest address the heap has known.
  941. TrimCheck - Stores the threshold value for the top. If the top wilderness
  942. exceeds this size, then the heap will be trimmed down to a more
  943. reasonable size.
  944. ReleaseChecks - Stores a countdown counter that is decremented during large
  945. free operations. When it reaches zero, any segments that are completely
  946. free are released back to the system, and the counter is reloaded.
  947. SmallBins - Stores the array of small bins where little free fragments are
  948. stored.
  949. TreeBins - Stores the array of trees where larger free fragments are
  950. stored.
  951. FootprintLimit - Stores a value that if non-zero limits the size that the
  952. heap can grow to.
  953. Segment - Stores the built-in first memory segment of the heap.
  954. --*/
  955. struct _MEMORY_HEAP {
  956. UINTN Magic;
  957. ULONG Flags;
  958. PHEAP_ALLOCATE AllocateFunction;
  959. PHEAP_FREE FreeFunction;
  960. PHEAP_CORRUPTION_ROUTINE CorruptionFunction;
  961. UINTN AllocationTag;
  962. UINTN MinimumExpansionSize;
  963. UINTN ExpansionGranularity;
  964. UINTN PreviousExpansionSize;
  965. MEMORY_HEAP_STATISTICS Statistics;
  966. MEMORY_HEAP_TAG_STATISTICS TagStatistics;
  967. HEAP_BINMAP SmallMap;
  968. HEAP_BINMAP TreeMap;
  969. UINTN DirectAllocationThreshold;
  970. UINTN DesignatedVictimSize;
  971. UINTN TopSize;
  972. PCHAR LeastAddress;
  973. PHEAP_CHUNK DesignatedVictim;
  974. PHEAP_CHUNK Top;
  975. UINTN TrimCheck;
  976. UINTN ReleaseChecks;
  977. PHEAP_CHUNK SmallBins[HEAP_SMALL_BIN_COUNT * 2];
  978. PHEAP_TREE_CHUNK TreeBins[HEAP_TREE_BIN_COUNT];
  979. UINTN FootprintLimit;
  980. HEAP_SEGMENT Segment;
  981. };
  982. typedef enum _SYSTEM_RELEASE_LEVEL {
  983. SystemReleaseInvalid,
  984. SystemReleaseDevelopment,
  985. SystemReleasePreAlpha,
  986. SystemReleaseAlpha,
  987. SystemReleaseBeta,
  988. SystemReleaseCandidate,
  989. SystemReleaseFinal,
  990. SystemReleaseLevelCount
  991. } SYSTEM_RELEASE_LEVEL, *PSYSTEM_RELEASE_LEVEL;
  992. typedef enum _SYSTEM_BUILD_DEBUG_LEVEL {
  993. SystemBuildInvalid,
  994. SystemBuildDebug,
  995. SystemBuildRelease,
  996. SystemBuildDebugLevelCount
  997. } SYSTEM_BUILD_DEBUG_LEVEL, *PSYSTEM_BUILD_DEBUG_LEVEL;
  998. typedef enum _SYSTEM_VERSION_STRING_VERBOSITY {
  999. SystemVersionStringMajorMinorOnly,
  1000. SystemVersionStringBasic,
  1001. SystemVersionStringComplete,
  1002. } SYSTEM_VERSION_STRING_VERBOSITY, *PSYSTEM_VERSION_STRING_VERBOSITY;
  1003. /*++
  1004. Structure Description:
  1005. This structure describes the system version information.
  1006. Members:
  1007. MajorVersion - Stores the major version number.
  1008. MinorVersion - Stores the minor version number.
  1009. Revision - Stores the sub-minor version number.
  1010. SerialVersion - Stores the globally increasing system version number. This
  1011. value will always be greater than any previous builds.
  1012. ReleaseLevel - Stores the release level of the build.
  1013. DebugLevel - Stores the debug compilation level of the build.
  1014. BuildTime - Stores the system build time.
  1015. ProductName - Stores a pointer to a string containing the name of the
  1016. product.
  1017. BuildString - Stores an optional pointer to a string containing an
  1018. identifier string for this build.
  1019. --*/
  1020. typedef struct _SYSTEM_VERSION_INFORMATION {
  1021. USHORT MajorVersion;
  1022. USHORT MinorVersion;
  1023. USHORT Revision;
  1024. ULONGLONG SerialVersion;
  1025. SYSTEM_RELEASE_LEVEL ReleaseLevel;
  1026. SYSTEM_BUILD_DEBUG_LEVEL DebugLevel;
  1027. SYSTEM_TIME BuildTime;
  1028. PSTR ProductName;
  1029. PSTR BuildString;
  1030. } SYSTEM_VERSION_INFORMATION, *PSYSTEM_VERSION_INFORMATION;
  1031. //
  1032. // --------------------------------------------------------------------- Macros
  1033. //
  1034. //
  1035. // The ASSERT macro evaluates the given expression. If it is false, then it
  1036. // raises an exception.
  1037. //
  1038. #if DEBUG
  1039. #define ASSERT(_Condition) \
  1040. if ((_Condition) == FALSE) { \
  1041. RtlRaiseAssertion(#_Condition, __FILE__, __LINE__); \
  1042. }
  1043. #else
  1044. //
  1045. // No asserts in non-debug builds.
  1046. //
  1047. #define ASSERT(_Condition)
  1048. #endif
  1049. //
  1050. // This macro determines the offset of the field in the given structure.
  1051. //
  1052. #define FIELD_OFFSET(_Structure, _Field) \
  1053. (UINTN)(&(((_Structure *)0L)->_Field))
  1054. //
  1055. // This macro retrieves the data structure associated with a particular Red
  1056. // Black Tree node entry. _Node is a PRED_BLACK_TREE_NODE that points to the
  1057. // node. _StructureName is the type of the containing record. _MemberName is
  1058. // the name of the RED_BLACK_TREE_NODE in the containing record.
  1059. #define RED_BLACK_TREE_VALUE(_Node, _StructureName, _MemberName) \
  1060. PARENT_STRUCTURE(_Node, _StructureName, _MemberName)
  1061. //
  1062. // This macros determines whether or not the given Red Black tree is empty.
  1063. //
  1064. #define RED_BLACK_TREE_EMPTY(_Tree) \
  1065. ((_Tree)->Root.LeftChild == &((_Tree)->NullNode))
  1066. //
  1067. //
  1068. // -------------------------------------------------------------------- Globals
  1069. //
  1070. //
  1071. // -------------------------------------------------------- Function Prototypes
  1072. //
  1073. RTL_API
  1074. ULONG
  1075. RtlComputeCrc32 (
  1076. ULONG InitialCrc,
  1077. PCVOID Buffer,
  1078. ULONG Size
  1079. );
  1080. /*++
  1081. Routine Description:
  1082. This routine computes the CRC-32 Cyclic Redundancy Check on the given
  1083. buffer of data.
  1084. Arguments:
  1085. InitialCrc - Supplies an initial CRC value to start with. Supply 0
  1086. initially.
  1087. Buffer - Supplies a pointer to the buffer to compute the CRC32 of.
  1088. Size - Supplies the size of the buffer, in bytes.
  1089. Return Value:
  1090. Returns the CRC32 hash of the buffer.
  1091. --*/
  1092. RTL_API
  1093. VOID
  1094. RtlRaiseAssertion (
  1095. PCSTR Expression,
  1096. PCSTR SourceFile,
  1097. ULONG SourceLine
  1098. );
  1099. /*++
  1100. Routine Description:
  1101. This routine raises an assertion failure. If a debugger is connected, it
  1102. will attempt to connect to the debugger.
  1103. Arguments:
  1104. Expression - Supplies the string containing the expression that failed.
  1105. SourceFile - Supplies the string describing the source file of the failure.
  1106. SourceLine - Supplies the source line number of the failure.
  1107. Return Value:
  1108. None.
  1109. --*/
  1110. RTL_API
  1111. VOID
  1112. RtlDebugPrint (
  1113. PCSTR Format,
  1114. ...
  1115. );
  1116. /*++
  1117. Routine Description:
  1118. This routine prints a printf-style string to the debugger.
  1119. Arguments:
  1120. Format - Supplies the printf-style format string to print. The contents of
  1121. this string determine the rest of the arguments passed.
  1122. ... - Supplies any arguments needed to convert the Format string.
  1123. Return Value:
  1124. None.
  1125. --*/
  1126. RTL_API
  1127. VOID
  1128. RtlInitializeMultibyteState (
  1129. PMULTIBYTE_STATE State,
  1130. CHARACTER_ENCODING Encoding
  1131. );
  1132. /*++
  1133. Routine Description:
  1134. This routine initializes a multibyte state structure.
  1135. Arguments:
  1136. State - Supplies the a pointer to the state to reset.
  1137. Encoding - Supplies the encoding to use for multibyte sequences. If the
  1138. default value is supplied here, then the current default system
  1139. encoding will be used.
  1140. Return Value:
  1141. None.
  1142. --*/
  1143. RTL_API
  1144. CHARACTER_ENCODING
  1145. RtlGetDefaultCharacterEncoding (
  1146. VOID
  1147. );
  1148. /*++
  1149. Routine Description:
  1150. This routine returns the system default character encoding.
  1151. Arguments:
  1152. None.
  1153. Return Value:
  1154. Returns the current system default character encoding.
  1155. --*/
  1156. RTL_API
  1157. KSTATUS
  1158. RtlSetDefaultCharacterEncoding (
  1159. CHARACTER_ENCODING NewEncoding,
  1160. PCHARACTER_ENCODING OriginalEncoding
  1161. );
  1162. /*++
  1163. Routine Description:
  1164. This routine sets the system default character encoding.
  1165. Arguments:
  1166. NewEncoding - Supplies the new encoding to use.
  1167. OriginalEncoding - Supplies an optional pointer where the previous
  1168. character encoding will be returned.
  1169. Return Value:
  1170. STATUS_SUCCESS on success.
  1171. STATUS_NOT_SUPPORTED if the given character encoding is not supported on
  1172. this system.
  1173. --*/
  1174. RTL_API
  1175. BOOL
  1176. RtlIsCharacterEncodingSupported (
  1177. CHARACTER_ENCODING Encoding
  1178. );
  1179. /*++
  1180. Routine Description:
  1181. This routine determines if the system supports a given character encoding.
  1182. Arguments:
  1183. Encoding - Supplies the encoding to query.
  1184. Return Value:
  1185. TRUE if the parameter is a valid encoding.
  1186. FALSE if the system does not recognize the given encoding.
  1187. --*/
  1188. RTL_API
  1189. BOOL
  1190. RtlIsCharacterEncodingStateDependent (
  1191. CHARACTER_ENCODING Encoding,
  1192. BOOL ToMultibyte
  1193. );
  1194. /*++
  1195. Routine Description:
  1196. This routine determines if the given character encoding is state-dependent
  1197. when converting between multibyte sequences and wide characters.
  1198. Arguments:
  1199. Encoding - Supplies the encoding to query.
  1200. ToMultibyte - Supplies a boolean indicating the direction of the character
  1201. encoding. State-dependence can vary between converting to multibyte and
  1202. converting to wide character.
  1203. Return Value:
  1204. TRUE if the given encoding is valid and state-dependent.
  1205. FALSE if the given encoding is invalid or not state-dependent.
  1206. --*/
  1207. RTL_API
  1208. VOID
  1209. RtlResetMultibyteState (
  1210. PMULTIBYTE_STATE State
  1211. );
  1212. /*++
  1213. Routine Description:
  1214. This routine resets the given multibyte state back to its initial state,
  1215. without clearing the character encoding.
  1216. Arguments:
  1217. State - Supplies a pointer to the state to reset.
  1218. Return Value:
  1219. None.
  1220. --*/
  1221. RTL_API
  1222. BOOL
  1223. RtlIsMultibyteStateReset (
  1224. PMULTIBYTE_STATE State
  1225. );
  1226. /*++
  1227. Routine Description:
  1228. This routine determines if the given multibyte state is in its initial
  1229. reset state.
  1230. Arguments:
  1231. State - Supplies a pointer to the state to query.
  1232. Return Value:
  1233. TRUE if the state is in the initial shift state.
  1234. FALSE if the state is not in the initial shift state.
  1235. --*/
  1236. RTL_API
  1237. KSTATUS
  1238. RtlConvertMultibyteCharacterToWide (
  1239. PCHAR *MultibyteCharacter,
  1240. PULONG MultibyteBufferSize,
  1241. PWCHAR WideCharacter,
  1242. PMULTIBYTE_STATE State
  1243. );
  1244. /*++
  1245. Routine Description:
  1246. This routine converts a multibyte sequence into a wide character.
  1247. Arguments:
  1248. MultibyteCharacter - Supplies a pointer that on input contains a pointer
  1249. to the multibyte character sequence. On successful output, this pointer
  1250. will be advanced beyond the character.
  1251. MultibyteBufferSize - Supplies a pointer that on input contains the size of
  1252. the multibyte buffer in bytes. This value will be updated if the
  1253. returned multibyte character buffer is advanced.
  1254. WideCharacter - Supplies an optional pointer where the wide character will
  1255. be returned on success.
  1256. State - Supplies a pointer to the state to use.
  1257. Return Value:
  1258. STATUS_SUCCESS if a wide character was successfully converted.
  1259. STATUS_INVALID_PARAMETER if the multibyte state is invalid.
  1260. STATUS_BUFFER_TOO_SMALL if only a portion of a character could be
  1261. constructed given the number of bytes in the buffer. The buffer will not
  1262. be advanced in this case.
  1263. STATUS_MALFORMED_DATA_STREAM if the byte sequence is not valid.
  1264. --*/
  1265. RTL_API
  1266. KSTATUS
  1267. RtlConvertWideCharacterToMultibyte (
  1268. WCHAR WideCharacter,
  1269. PCHAR MultibyteCharacter,
  1270. PULONG Size,
  1271. PMULTIBYTE_STATE State
  1272. );
  1273. /*++
  1274. Routine Description:
  1275. This routine converts a wide character into a multibyte sequence.
  1276. Arguments:
  1277. WideCharacter - Supplies the wide character to convert to a multibyte
  1278. sequence.
  1279. MultibyteCharacter - Supplies a pointer to the multibyte sequence.
  1280. Size - Supplies a pointer that on input contains the size of the buffer.
  1281. On output, it will return the number of bytes in the multibyte
  1282. character, even if the buffer provided was too small.
  1283. State - Supplies a pointer to the state to use.
  1284. Return Value:
  1285. STATUS_SUCCESS if a wide character was successfully converted.
  1286. STATUS_INVALID_PARAMETER if the multibyte state is invalid.
  1287. STATUS_BUFFER_TOO_SMALL if only a portion of a character could be
  1288. constructed given the remaining space in the buffer. The buffer will not
  1289. be advanced in this case.
  1290. STATUS_MALFORMED_DATA_STREAM if the byte sequence is not valid.
  1291. --*/
  1292. RTL_API
  1293. ULONG
  1294. RtlPrintToString (
  1295. PSTR Destination,
  1296. ULONG DestinationSize,
  1297. CHARACTER_ENCODING Encoding,
  1298. PCSTR Format,
  1299. ...
  1300. );
  1301. /*++
  1302. Routine Description:
  1303. This routine prints a formatted string out to a buffer.
  1304. Arguments:
  1305. Destination - Supplies a pointer to the buffer where the formatted string
  1306. will be placed.
  1307. DestinationSize - Supplies the size of the destination buffer, in bytes.
  1308. Encoding - Supplies the character encoding to use for any wide characters
  1309. or strings.
  1310. Format - Supplies the printf-style format string to print. The contents of
  1311. this string determine the rest of the arguments passed.
  1312. ... - Supplies any arguments needed to convert the Format string.
  1313. Return Value:
  1314. Returns the length of the final string after all formatting has been
  1315. completed. The length will be returned even if NULL is passed as the
  1316. destination.
  1317. --*/
  1318. RTL_API
  1319. ULONG
  1320. RtlFormatString (
  1321. PSTR Destination,
  1322. ULONG DestinationSize,
  1323. CHARACTER_ENCODING Encoding,
  1324. PCSTR Format,
  1325. va_list ArgumentList
  1326. );
  1327. /*++
  1328. Routine Description:
  1329. This routine converts a printf-style format string given the parameters.
  1330. Arguments:
  1331. Destination - Supplies a pointer to the buffer where the final string will
  1332. be printed. It is assumed that this string is allocated and is big
  1333. enough to hold the converted string. Pass NULL here to determine how big
  1334. a buffer is necessary to hold the string. If the buffer is not big
  1335. enough, it will be truncated but still NULL terminated.
  1336. DestinationSize - Supplies the size of the destination buffer. If NULL was
  1337. passed as the Destination argument, then this argument is ignored.
  1338. Encoding - Supplies the character encoding to use when converting any
  1339. wide strings or characters.
  1340. Format - Supplies a pointer to the printf-style format string.
  1341. ArgumentList - Supplies an initialized list of arguments to the format
  1342. string.
  1343. Return Value:
  1344. Returns the length of the final string after all formatting has been
  1345. completed, including the null terminator. The length will be returned even
  1346. if NULL is passed as the destination.
  1347. --*/
  1348. RTL_API
  1349. BOOL
  1350. RtlFormat (
  1351. PPRINT_FORMAT_CONTEXT Context,
  1352. PCSTR Format,
  1353. va_list ArgumentList
  1354. );
  1355. /*++
  1356. Routine Description:
  1357. This routine converts a printf-style format string given the parameters.
  1358. Arguments:
  1359. Context - Supplies a pointer to the initialized context structure.
  1360. Format - Supplies a pointer to the printf-style format string.
  1361. ArgumentList - Supplies an initialized list of arguments to the format
  1362. string.
  1363. Return Value:
  1364. TRUE if all characters were written to the destination.
  1365. FALSE if the destination or limit cut the conversion short.
  1366. --*/
  1367. RTL_API
  1368. ULONG
  1369. RtlPrintToStringWide (
  1370. PWSTR Destination,
  1371. ULONG DestinationSize,
  1372. CHARACTER_ENCODING Encoding,
  1373. PCWSTR Format,
  1374. ...
  1375. );
  1376. /*++
  1377. Routine Description:
  1378. This routine prints a formatted wide string out to a buffer.
  1379. Arguments:
  1380. Destination - Supplies a pointer to the buffer where the formatted string
  1381. will be placed.
  1382. DestinationSize - Supplies the size of the destination buffer, in bytes.
  1383. Encoding - Supplies the character encoding to use for any non-wide
  1384. characters or strings.
  1385. Format - Supplies the printf-style format string to print. The contents of
  1386. this string determine the rest of the arguments passed.
  1387. ... - Supplies any arguments needed to convert the Format string.
  1388. Return Value:
  1389. Returns the length of the final string (in characters) after all formatting
  1390. has been completed. The length will be returned even if NULL is passed as
  1391. the destination.
  1392. --*/
  1393. RTL_API
  1394. ULONG
  1395. RtlFormatStringWide (
  1396. PWSTR Destination,
  1397. ULONG DestinationSize,
  1398. CHARACTER_ENCODING Encoding,
  1399. PCWSTR Format,
  1400. va_list ArgumentList
  1401. );
  1402. /*++
  1403. Routine Description:
  1404. This routine converts a printf-style wide format string given the
  1405. parameters.
  1406. Arguments:
  1407. Destination - Supplies a pointer to the buffer where the final string will
  1408. be printed. It is assumed that this string is allocated and is big
  1409. enough to hold the converted string. Pass NULL here to determine how big
  1410. a buffer is necessary to hold the string. If the buffer is not big
  1411. enough, it will be truncated but still NULL terminated.
  1412. DestinationSize - Supplies the size of the destination buffer. If NULL was
  1413. passed as the Destination argument, then this argument is ignored.
  1414. Encoding - Supplies the character encoding to use for any non-wide
  1415. characters or strings.
  1416. Format - Supplies a pointer to the printf-style format string.
  1417. ArgumentList - Supplies an initialized list of arguments to the format
  1418. string.
  1419. Return Value:
  1420. Returns the length of the final string after all formatting has been
  1421. completed, including the null terminator. The length will be returned even
  1422. if NULL is passed as the destination.
  1423. --*/
  1424. RTL_API
  1425. BOOL
  1426. RtlFormatWide (
  1427. PPRINT_FORMAT_CONTEXT Context,
  1428. PCWSTR Format,
  1429. va_list ArgumentList
  1430. );
  1431. /*++
  1432. Routine Description:
  1433. This routine converts a printf-style wide format string given the
  1434. parameters.
  1435. Arguments:
  1436. Context - Supplies a pointer to the initialized context structure.
  1437. Format - Supplies a pointer to the printf-style format string.
  1438. ArgumentList - Supplies an initialized list of arguments to the format
  1439. string.
  1440. Return Value:
  1441. TRUE if all characters were written to the destination.
  1442. FALSE if the destination or limit cut the conversion short.
  1443. --*/
  1444. RTL_API
  1445. ULONG
  1446. RtlStringCopy (
  1447. PSTR Destination,
  1448. PCSTR Source,
  1449. UINTN BufferSize
  1450. );
  1451. /*++
  1452. Routine Description:
  1453. This routine copies a string from one buffer to another, including the NULL
  1454. terminator.
  1455. Arguments:
  1456. Destination - Supplies a pointer to the buffer where the string will be
  1457. copied to.
  1458. Source - Supplies a pointer to the string to copy.
  1459. BufferSize - Supplies the size of the destination buffer.
  1460. Return Value:
  1461. Returns the number of bytes copied, including the NULL terminator. If the
  1462. source string is longer than the destination buffer, the string will be
  1463. truncated but still NULL terminated.
  1464. --*/
  1465. RTL_API
  1466. VOID
  1467. RtlStringReverse (
  1468. PSTR String,
  1469. PSTR StringEnd
  1470. );
  1471. /*++
  1472. Routine Description:
  1473. This routine reverses the contents of a string. For example, the string
  1474. "abcd" would get reversed to "dcba".
  1475. Arguments:
  1476. String - Supplies a pointer to the beginning of the string to reverse.
  1477. StringEnd - Supplies a pointer to one beyond the end of the string. That is,
  1478. this pointer points to the first byte *not* in the string.
  1479. Return Value:
  1480. None.
  1481. --*/
  1482. RTL_API
  1483. ULONG
  1484. RtlStringLength (
  1485. PCSTR String
  1486. );
  1487. /*++
  1488. Routine Description:
  1489. This routine determines the length of the given string, not including its
  1490. NULL terminator.
  1491. Arguments:
  1492. String - Supplies a pointer to the beginning of the string.
  1493. Return Value:
  1494. Returns the length of the string, not including the NULL terminator.
  1495. --*/
  1496. RTL_API
  1497. BOOL
  1498. RtlAreStringsEqual (
  1499. PCSTR String1,
  1500. PCSTR String2,
  1501. ULONG MaxLength
  1502. );
  1503. /*++
  1504. Routine Description:
  1505. This routine determines if the contents of two strings are equal, up to a
  1506. maximum number of characters.
  1507. Arguments:
  1508. String1 - Supplies a pointer to the first string to compare.
  1509. String2 - Supplies a pointer to the second string to compare.
  1510. MaxLength - Supplies the minimum of either string's buffer size.
  1511. Return Value:
  1512. TRUE if the strings are equal up to the maximum length.
  1513. FALSE if the strings differ in some way.
  1514. --*/
  1515. RTL_API
  1516. BOOL
  1517. RtlAreStringsEqualIgnoringCase (
  1518. PCSTR String1,
  1519. PCSTR String2,
  1520. ULONG MaxLength
  1521. );
  1522. /*++
  1523. Routine Description:
  1524. This routine determines if the contents of two strings are equal, up to a
  1525. maximum number of characters. This routine is case insensitive.
  1526. Arguments:
  1527. String1 - Supplies a pointer to the first string to compare.
  1528. String2 - Supplies a pointer to the second string to compare.
  1529. MaxLength - Supplies the minimum of either string's buffer size.
  1530. Return Value:
  1531. TRUE if the strings are equal up to the maximum length.
  1532. FALSE if the strings differ in some way.
  1533. --*/
  1534. RTL_API
  1535. PSTR
  1536. RtlStringFindCharacter (
  1537. PCSTR String,
  1538. CHAR Character,
  1539. ULONG StringLength
  1540. );
  1541. /*++
  1542. Routine Description:
  1543. This routine searches a string for the first instance of the given
  1544. character, scanning from the left.
  1545. Arguments:
  1546. String - Supplies a pointer to the string to search.
  1547. Character - Supplies a pointer to the character to search for within the
  1548. string.
  1549. StringLength - Supplies the length of the string, in bytes, including the
  1550. NULL terminator.
  1551. Return Value:
  1552. Returns a pointer to the first instance of the character on success.
  1553. NULL if the character could not be found in the string.
  1554. --*/
  1555. RTL_API
  1556. PSTR
  1557. RtlStringFindCharacterRight (
  1558. PCSTR String,
  1559. CHAR Character,
  1560. ULONG StringLength
  1561. );
  1562. /*++
  1563. Routine Description:
  1564. This routine searches a string for the first instance of the given
  1565. character, scanning from the right backwards. The function will search
  1566. starting at the NULL terminator or string length, whichever comes first.
  1567. Arguments:
  1568. String - Supplies a pointer to the string to search.
  1569. Character - Supplies a pointer to the character to search for within the
  1570. string.
  1571. StringLength - Supplies the length of the string, in bytes, including the
  1572. NULL terminator.
  1573. Return Value:
  1574. Returns a pointer to the first instance of the character on success.
  1575. NULL if the character could not be found in the string.
  1576. --*/
  1577. RTL_API
  1578. PSTR
  1579. RtlStringSearch (
  1580. PSTR InputString,
  1581. UINTN InputStringLength,
  1582. PSTR QueryString,
  1583. UINTN QueryStringLength
  1584. );
  1585. /*++
  1586. Routine Description:
  1587. This routine searches a string for the first instance of the given string
  1588. within it.
  1589. Arguments:
  1590. InputString - Supplies a pointer to the string to search.
  1591. InputStringLength - Supplies the length of the string, in bytes, including
  1592. the NULL terminator.
  1593. QueryString - Supplies a pointer to the null terminated string to search
  1594. for.
  1595. QueryStringLength - Supplies the length of the query string in bytes
  1596. including the null terminator.
  1597. Return Value:
  1598. Returns a pointer to the first instance of the string on success.
  1599. NULL if the character could not be found in the string.
  1600. --*/
  1601. RTL_API
  1602. PSTR
  1603. RtlStringSearchIgnoringCase (
  1604. PSTR InputString,
  1605. UINTN InputStringLength,
  1606. PSTR QueryString,
  1607. UINTN QueryStringLength
  1608. );
  1609. /*++
  1610. Routine Description:
  1611. This routine searches a string for the first instance of the given string
  1612. within it. This routine is case insensitive.
  1613. Arguments:
  1614. InputString - Supplies a pointer to the string to search.
  1615. InputStringLength - Supplies the length of the string, in bytes, including
  1616. the NULL terminator.
  1617. QueryString - Supplies a pointer to the null terminated string to search
  1618. for.
  1619. QueryStringLength - Supplies the length of the query string in bytes
  1620. including the null terminator.
  1621. Return Value:
  1622. Returns a pointer to the first instance of the string on success.
  1623. NULL if the character could not be found in the string.
  1624. --*/
  1625. RTL_API
  1626. ULONG
  1627. RtlStringCopyWide (
  1628. PWSTR Destination,
  1629. PWSTR Source,
  1630. ULONG BufferSize
  1631. );
  1632. /*++
  1633. Routine Description:
  1634. This routine copies a wide string from one buffer to another, including the
  1635. NULL terminator.
  1636. Arguments:
  1637. Destination - Supplies a pointer to the buffer where the wide string will be
  1638. copied to.
  1639. Source - Supplies a pointer to the wide string to copy.
  1640. BufferSize - Supplies the size of the destination buffer.
  1641. Return Value:
  1642. Returns the number of characters copied, including the NULL terminator. If
  1643. the source string is longer than the destination buffer, the string will be
  1644. truncated but still NULL terminated.
  1645. --*/
  1646. RTL_API
  1647. VOID
  1648. RtlStringReverseWide (
  1649. PWSTR String,
  1650. PWSTR StringEnd
  1651. );
  1652. /*++
  1653. Routine Description:
  1654. This routine reverses the contents of a wide string. For example, the string
  1655. L"abcd" would get reversed to L"dcba".
  1656. Arguments:
  1657. String - Supplies a pointer to the beginning of the wide string to reverse.
  1658. StringEnd - Supplies a pointer to one beyond the end of the string. That is,
  1659. this pointer points to the first byte *not* in the string.
  1660. Return Value:
  1661. None.
  1662. --*/
  1663. RTL_API
  1664. ULONG
  1665. RtlStringLengthWide (
  1666. PWSTR String
  1667. );
  1668. /*++
  1669. Routine Description:
  1670. This routine determines the length of the given wide string, not including
  1671. its NULL terminator.
  1672. Arguments:
  1673. String - Supplies a pointer to the beginning of the string.
  1674. Return Value:
  1675. Returns the length of the string, not including the NULL terminator.
  1676. --*/
  1677. RTL_API
  1678. BOOL
  1679. RtlAreStringsEqualWide (
  1680. PWSTR String1,
  1681. PWSTR String2,
  1682. ULONG MaxLength
  1683. );
  1684. /*++
  1685. Routine Description:
  1686. This routine determines if the contents of two wide strings are equal, up
  1687. to a maximum number of characters.
  1688. Arguments:
  1689. String1 - Supplies a pointer to the first wide string to compare.
  1690. String2 - Supplies a pointer to the second wide string to compare.
  1691. MaxLength - Supplies the minimum of either string's buffer size.
  1692. Return Value:
  1693. TRUE if the strings are equal up to the maximum length.
  1694. FALSE if the strings differ in some way.
  1695. --*/
  1696. RTL_API
  1697. BOOL
  1698. RtlAreStringsEqualIgnoringCaseWide (
  1699. PWSTR String1,
  1700. PWSTR String2,
  1701. ULONG MaxLength
  1702. );
  1703. /*++
  1704. Routine Description:
  1705. This routine determines if the contents of two wide strings are equal, up
  1706. to a maximum number of characters. This routine is case insensitive.
  1707. Arguments:
  1708. String1 - Supplies a pointer to the first wide string to compare.
  1709. String2 - Supplies a pointer to the second wide string to compare.
  1710. MaxLength - Supplies the minimum of either string's buffer size, in
  1711. characters.
  1712. Return Value:
  1713. TRUE if the strings are equal up to the maximum length.
  1714. FALSE if the strings differ in some way.
  1715. --*/
  1716. RTL_API
  1717. PWSTR
  1718. RtlStringFindCharacterWide (
  1719. PWSTR String,
  1720. WCHAR Character,
  1721. ULONG StringLength
  1722. );
  1723. /*++
  1724. Routine Description:
  1725. This routine searches a wide string for the first instance of the given
  1726. character, scanning from the left.
  1727. Arguments:
  1728. String - Supplies a pointer to the wide string to search.
  1729. Character - Supplies a pointer to the wide character to search for within
  1730. the string.
  1731. StringLength - Supplies the length of the string, in characters, including
  1732. the NULL terminator.
  1733. Return Value:
  1734. Returns a pointer to the first instance of the character on success.
  1735. NULL if the character could not be found in the string.
  1736. --*/
  1737. RTL_API
  1738. PWSTR
  1739. RtlStringFindCharacterRightWide (
  1740. PWSTR String,
  1741. WCHAR Character,
  1742. ULONG StringLength
  1743. );
  1744. /*++
  1745. Routine Description:
  1746. This routine searches a wide string for the first instance of the given
  1747. character, scanning from the right backwards. The function will search
  1748. starting at the NULL terminator or string length, whichever comes first.
  1749. Arguments:
  1750. String - Supplies a pointer to the wide string to search.
  1751. Character - Supplies a pointer to the character to search for within the
  1752. wide string.
  1753. StringLength - Supplies the length of the string, in characters, including
  1754. the NULL terminator.
  1755. Return Value:
  1756. Returns a pointer to the first instance of the character on success.
  1757. NULL if the character could not be found in the string.
  1758. --*/
  1759. RTL_API
  1760. KSTATUS
  1761. RtlStringScan (
  1762. PCSTR Input,
  1763. ULONG InputSize,
  1764. PCSTR Format,
  1765. ULONG FormatSize,
  1766. CHARACTER_ENCODING Encoding,
  1767. PULONG ItemsScanned,
  1768. ...
  1769. );
  1770. /*++
  1771. Routine Description:
  1772. This routine scans in a string and converts it to a number of arguments
  1773. based on a format string.
  1774. Arguments:
  1775. Input - Supplies a pointer to the input string to scan.
  1776. InputSize - Supplies the size of the string in bytes including the null
  1777. terminator.
  1778. Format - Supplies the format string that specifies how to convert the input
  1779. to the arguments.
  1780. FormatSize - Supplies the size of the format string in bytes, including
  1781. the null terminator.
  1782. Encoding - Supplies the character encoding to use when scanning into
  1783. wide strings or characters.
  1784. ItemsScanned - Supplies a pointer where the number of items scanned will
  1785. be returned (not counting any %n specifiers).
  1786. ... - Supplies the remaining pointer arguments where the scanned data will
  1787. be returned.
  1788. Return Value:
  1789. STATUS_SUCCESS if the input was successfully scanned according to the
  1790. format.
  1791. STATUS_INVALID_SEQUENCE if the input did not match the format or the
  1792. format was invalid.
  1793. STATUS_ARGUMENT_EXPECTED if not enough arguments were supplied for the
  1794. format.
  1795. STATUS_END_OF_FILE if the input ended before any arguments were converted
  1796. or any matching failures occurred.
  1797. --*/
  1798. RTL_API
  1799. KSTATUS
  1800. RtlStringScanVaList (
  1801. PCSTR Input,
  1802. ULONG InputSize,
  1803. PCSTR Format,
  1804. ULONG FormatSize,
  1805. CHARACTER_ENCODING Encoding,
  1806. PULONG ItemsScanned,
  1807. va_list Arguments
  1808. );
  1809. /*++
  1810. Routine Description:
  1811. This routine scans in a string and converts it to a number of arguments
  1812. based on a format string.
  1813. Arguments:
  1814. Input - Supplies a pointer to the input string to scan.
  1815. InputSize - Supplies the size of the string in bytes including the null
  1816. terminator.
  1817. Format - Supplies the format string that specifies how to convert the input
  1818. to the arguments.
  1819. FormatSize - Supplies the size of the format string in bytes, including
  1820. the null terminator.
  1821. Encoding - Supplies the character encoding to use when scanning into
  1822. wide strings or characters.
  1823. ItemsScanned - Supplies a pointer where the number of items scanned will
  1824. be returned (not counting any %n specifiers).
  1825. Arguments - Supplies the initialized arguments list where various pieces
  1826. of the formatted string will be returned.
  1827. Return Value:
  1828. STATUS_SUCCESS if the input was successfully scanned according to the
  1829. format.
  1830. STATUS_INVALID_SEQUENCE if the input did not match the format or the
  1831. format was invalid.
  1832. STATUS_ARGUMENT_EXPECTED if not enough arguments were supplied for the
  1833. format.
  1834. STATUS_END_OF_FILE if the input ended before any arguments were converted
  1835. or any matching failures occurred.
  1836. --*/
  1837. RTL_API
  1838. KSTATUS
  1839. RtlStringScanInteger (
  1840. PCSTR *String,
  1841. PULONG StringSize,
  1842. ULONG Base,
  1843. BOOL Signed,
  1844. PLONGLONG Integer
  1845. );
  1846. /*++
  1847. Routine Description:
  1848. This routine converts a string into an integer. It scans past leading
  1849. whitespace.
  1850. Arguments:
  1851. String - Supplies a pointer that on input contains a pointer to the string
  1852. to scan. On output, the string advanced past the scanned value (if any)
  1853. will be returned. If the entire string is whitespace or starts with an
  1854. invalid character, this parameter will not be modified.
  1855. StringSize - Supplies a pointer that on input contains the size of the
  1856. string, in bytes, including the null terminator. On output, this will
  1857. contain the size of the string minus the number of bytes scanned by
  1858. this routine. Said differently, it will return the size of the output
  1859. to the string parameter in bytes including the null terminator.
  1860. Base - Supplies the base of the integer to scan. Valid values are zero and
  1861. two through thirty six. If zero is supplied, this routine will attempt
  1862. to automatically detect what the base is out of bases 8, 10, and 16.
  1863. Signed - Supplies a boolean indicating whether the integer to scan is
  1864. signed or not.
  1865. Integer - Supplies a pointer where the resulting integer is returned on
  1866. success.
  1867. Return Value:
  1868. STATUS_SUCCESS if an integer was successfully scanned.
  1869. STATUS_INVALID_SEQUENCE if a valid integer could not be scanned.
  1870. STATUS_INTEGER_OVERFLOW if the result overflowed. In this case the integer
  1871. returned will be MAX_LONGLONG, MIN_LONGLONG, or MAX_ULONGLONG depending on
  1872. the signedness and value.
  1873. STATUS_END_OF_FILE if the input ended before the value was converted
  1874. or a matching failure occurred.
  1875. --*/
  1876. RTL_API
  1877. KSTATUS
  1878. RtlStringScanDouble (
  1879. PCSTR *String,
  1880. PULONG StringSize,
  1881. double *Double
  1882. );
  1883. /*++
  1884. Routine Description:
  1885. This routine converts a string into a floating point double. It scans past
  1886. leading whitespace.
  1887. Arguments:
  1888. String - Supplies a pointer that on input contains a pointer to the string
  1889. to scan. On output, the string advanced past the scanned value (if any)
  1890. will be returned. If the entire string is whitespace or starts with an
  1891. invalid character, this parameter will not be modified.
  1892. StringSize - Supplies a pointer that on input contains the size of the
  1893. string, in bytes, including the null terminator. On output, this will
  1894. contain the size of the string minus the number of bytes scanned by
  1895. this routine. Said differently, it will return the size of the output
  1896. to the string parameter in bytes including the null terminator.
  1897. Double - Supplies a pointer where the resulting double is returned on
  1898. success.
  1899. Return Value:
  1900. STATUS_SUCCESS if an integer was successfully scanned.
  1901. STATUS_INVALID_SEQUENCE if a valid double could not be scanned.
  1902. STATUS_OUT_OF_BOUNDS if the exponent was out of range.
  1903. STATUS_END_OF_FILE if the input ended before the value was converted
  1904. or a matching failure occurred.
  1905. --*/
  1906. RTL_API
  1907. KSTATUS
  1908. RtlScan (
  1909. PSCAN_INPUT Input,
  1910. PCSTR Format,
  1911. ULONG FormatLength,
  1912. PULONG ItemsScanned,
  1913. va_list ArgumentList
  1914. );
  1915. /*++
  1916. Routine Description:
  1917. This routine scans from an input and converts the input to various
  1918. parameters according to a specified format.
  1919. Arguments:
  1920. Input - Supplies a pointer to the filled out scan input structure which
  1921. will be used to retrieve more input.
  1922. Format - Supplies the format string which specifies how to convert the
  1923. input to the argument list.
  1924. FormatLength - Supplies the size of the format length string in bytes,
  1925. including the null terminator.
  1926. ItemsScanned - Supplies a pointer where the number of parameters filled in
  1927. (not counting %n) will be returned.
  1928. ArgumentList - Supplies the list of arguments that will get filled out
  1929. based on the input and format string.
  1930. Return Value:
  1931. STATUS_SUCCESS if the input was successfully scanned according to the
  1932. format.
  1933. STATUS_INVALID_SEQUENCE if the input did not match the format or the
  1934. format was invalid.
  1935. STATUS_ARGUMENT_EXPECTED if not enough arguments were supplied for the
  1936. format.
  1937. STATUS_END_OF_FILE if the input ended before any arguments were converted
  1938. or any matching failures occurred.
  1939. --*/
  1940. RTL_API
  1941. KSTATUS
  1942. RtlStringScanWide (
  1943. PCWSTR Input,
  1944. ULONG InputSize,
  1945. PCWSTR Format,
  1946. ULONG FormatSize,
  1947. CHARACTER_ENCODING Encoding,
  1948. PULONG ItemsScanned,
  1949. ...
  1950. );
  1951. /*++
  1952. Routine Description:
  1953. This routine scans in a wide string and converts it to a number of arguments
  1954. based on a format string.
  1955. Arguments:
  1956. Input - Supplies a pointer to the input wide string to scan.
  1957. InputSize - Supplies the size of the string in characters including the
  1958. null terminator.
  1959. Format - Supplies the format string that specifies how to convert the input
  1960. to the arguments.
  1961. FormatSize - Supplies the size of the format string in characters,
  1962. including the null terminator.
  1963. Encoding - Supplies the character encoding to use when scanning non-wide
  1964. items.
  1965. ItemsScanned - Supplies a pointer where the number of items scanned will
  1966. be returned (not counting any %n specifiers).
  1967. ... - Supplies the remaining pointer arguments where the scanned data will
  1968. be returned.
  1969. Return Value:
  1970. STATUS_SUCCESS if the input was successfully scanned according to the
  1971. format.
  1972. STATUS_INVALID_SEQUENCE if the input did not match the format or the
  1973. format was invalid.
  1974. STATUS_ARGUMENT_EXPECTED if not enough arguments were supplied for the
  1975. format.
  1976. STATUS_END_OF_FILE if the input ended before any arguments were converted
  1977. or any matching failures occurred.
  1978. --*/
  1979. RTL_API
  1980. KSTATUS
  1981. RtlStringScanVaListWide (
  1982. PCWSTR Input,
  1983. ULONG InputSize,
  1984. PCWSTR Format,
  1985. ULONG FormatSize,
  1986. CHARACTER_ENCODING Encoding,
  1987. PULONG ItemsScanned,
  1988. va_list Arguments
  1989. );
  1990. /*++
  1991. Routine Description:
  1992. This routine scans in a wide string and converts it to a number of arguments
  1993. based on a format string.
  1994. Arguments:
  1995. Input - Supplies a pointer to the wide input string to scan.
  1996. InputSize - Supplies the size of the string in characters including the
  1997. null terminator.
  1998. Format - Supplies the wide format string that specifies how to convert the
  1999. input to the arguments.
  2000. FormatSize - Supplies the size of the format string in characters,
  2001. including the null terminator.
  2002. Encoding - Supplies the character encoding to use when scanning non-wide
  2003. items.
  2004. ItemsScanned - Supplies a pointer where the number of items scanned will
  2005. be returned (not counting any %n specifiers).
  2006. Arguments - Supplies the initialized arguments list where various pieces
  2007. of the formatted string will be returned.
  2008. Return Value:
  2009. STATUS_SUCCESS if the input was successfully scanned according to the
  2010. format.
  2011. STATUS_INVALID_SEQUENCE if the input did not match the format or the
  2012. format was invalid.
  2013. STATUS_ARGUMENT_EXPECTED if not enough arguments were supplied for the
  2014. format.
  2015. STATUS_END_OF_FILE if the input ended before any arguments were converted
  2016. or any matching failures occurred.
  2017. --*/
  2018. RTL_API
  2019. KSTATUS
  2020. RtlStringScanIntegerWide (
  2021. PCWSTR *String,
  2022. PULONG StringSize,
  2023. ULONG Base,
  2024. BOOL Signed,
  2025. PLONGLONG Integer
  2026. );
  2027. /*++
  2028. Routine Description:
  2029. This routine converts a wide string into an integer. It scans past leading
  2030. whitespace.
  2031. Arguments:
  2032. String - Supplies a pointer that on input contains a pointer to the string
  2033. to scan. On output, the string advanced past the scanned value (if any)
  2034. will be returned. If the entire string is whitespace or starts with an
  2035. invalid character, this parameter will not be modified.
  2036. StringSize - Supplies a pointer that on input contains the size of the
  2037. string, in characters , including the null terminator. On output, this
  2038. will contain the size of the string minus the number of bytes scanned by
  2039. this routine. Said differently, it will return the size of the output
  2040. to the string parameter in bytes including the null terminator.
  2041. Base - Supplies the base of the integer to scan. Valid values are zero and
  2042. two through thirty six. If zero is supplied, this routine will attempt
  2043. to automatically detect what the base is out of bases 8, 10, and 16.
  2044. Signed - Supplies a boolean indicating whether the integer to scan is
  2045. signed or not.
  2046. STATUS_INTEGER_OVERFLOW if the result overflowed. In this case the integer
  2047. returned will be MAX_LONGLONG, MIN_LONGLONG, or MAX_ULONGLONG depending on
  2048. the signedness and value.
  2049. Integer - Supplies a pointer where the resulting integer is returned on
  2050. success.
  2051. Return Value:
  2052. STATUS_SUCCESS if an integer was successfully scanned.
  2053. STATUS_INVALID_SEQUENCE if a valid integer could not be scanned.
  2054. STATUS_END_OF_FILE if the input ended before the value was converted
  2055. or a matching failure occurred.
  2056. --*/
  2057. RTL_API
  2058. KSTATUS
  2059. RtlStringScanDoubleWide (
  2060. PCWSTR *String,
  2061. PULONG StringSize,
  2062. double *Double
  2063. );
  2064. /*++
  2065. Routine Description:
  2066. This routine converts a wide string into a floating point double. It scans
  2067. past leading whitespace.
  2068. Arguments:
  2069. String - Supplies a pointer that on input contains a pointer to the wide
  2070. string to scan. On output, the string advanced past the scanned value
  2071. (if any) will be returned. If the entire string is whitespace or starts
  2072. with an invalid character, this parameter will not be modified.
  2073. StringSize - Supplies a pointer that on input contains the size of the
  2074. string, in characters, including the null terminator. On output, this
  2075. will contain the size of the string minus the number of bytes scanned
  2076. by this routine. Said differently, it will return the size of the output
  2077. to the string parameter in bytes including the null terminator.
  2078. Double - Supplies a pointer where the resulting double is returned on
  2079. success.
  2080. Return Value:
  2081. STATUS_SUCCESS if an integer was successfully scanned.
  2082. STATUS_INVALID_SEQUENCE if a valid integer could not be scanned.
  2083. STATUS_END_OF_FILE if the input ended before the value was converted
  2084. or a matching failure occurred.
  2085. --*/
  2086. RTL_API
  2087. KSTATUS
  2088. RtlScanWide (
  2089. PSCAN_INPUT Input,
  2090. PCWSTR Format,
  2091. ULONG FormatLength,
  2092. PULONG ItemsScanned,
  2093. va_list ArgumentList
  2094. );
  2095. /*++
  2096. Routine Description:
  2097. This routine scans from an input and converts the input to various
  2098. parameters according to a specified format.
  2099. Arguments:
  2100. Input - Supplies a pointer to the filled out scan input structure which
  2101. will be used to retrieve more input.
  2102. Format - Supplies the wide format string which specifies how to convert the
  2103. input to the argument list.
  2104. FormatLength - Supplies the size of the format length string in characters,
  2105. including the null terminator.
  2106. ItemsScanned - Supplies a pointer where the number of parameters filled in
  2107. (not counting %n) will be returned.
  2108. ArgumentList - Supplies the list of arguments that will get filled out
  2109. based on the input and format string.
  2110. Return Value:
  2111. STATUS_SUCCESS if the input was successfully scanned according to the
  2112. format.
  2113. STATUS_INVALID_SEQUENCE if the input did not match the format or the
  2114. format was invalid.
  2115. STATUS_ARGUMENT_EXPECTED if not enough arguments were supplied for the
  2116. format.
  2117. STATUS_END_OF_FILE if the input ended before any arguments were converted
  2118. or any matching failures occurred.
  2119. --*/
  2120. RTL_API
  2121. VOID
  2122. RtlZeroMemory (
  2123. PVOID Buffer,
  2124. UINTN ByteCount
  2125. );
  2126. /*++
  2127. Routine Description:
  2128. This routine zeroes out a section of memory.
  2129. Arguments:
  2130. Buffer - Supplies a pointer to the buffer to clear.
  2131. ByteCount - Supplies the number of bytes to zero out.
  2132. Return Value:
  2133. None.
  2134. --*/
  2135. RTL_API
  2136. VOID
  2137. RtlSetMemory (
  2138. PVOID Buffer,
  2139. INT Byte,
  2140. UINTN Count
  2141. );
  2142. /*++
  2143. Routine Description:
  2144. This routine writes the given byte value repeatedly into a region of memory.
  2145. Arguments:
  2146. Buffer - Supplies a pointer to the buffer to set.
  2147. Byte - Supplies the byte to set.
  2148. Count - Supplies the number of bytes to set.
  2149. Return Value:
  2150. None.
  2151. --*/
  2152. RTL_API
  2153. PVOID
  2154. RtlCopyMemory (
  2155. PVOID Destination,
  2156. PCVOID Source,
  2157. UINTN ByteCount
  2158. );
  2159. /*++
  2160. Routine Description:
  2161. This routine copies a section of memory.
  2162. Arguments:
  2163. Destination - Supplies a pointer to the buffer where the memory will be
  2164. copied to.
  2165. Source - Supplies a pointer to the buffer to be copied.
  2166. ByteCount - Supplies the number of bytes to copy.
  2167. Return Value:
  2168. Returns the destination pointer.
  2169. --*/
  2170. RTL_API
  2171. BOOL
  2172. RtlCompareMemory (
  2173. PCVOID FirstBuffer,
  2174. PCVOID SecondBuffer,
  2175. UINTN Size
  2176. );
  2177. /*++
  2178. Routine Description:
  2179. This routine compares two buffers for equality.
  2180. Arguments:
  2181. FirstBuffer - Supplies a pointer to the first buffer to compare.
  2182. SecondBuffer - Supplies a pointer to the second buffer to compare.
  2183. Size - Supplies the number of bytes to compare.
  2184. Return Value:
  2185. TRUE if the buffers are equal.
  2186. FALSE if the buffers are not equal.
  2187. --*/
  2188. RTL_API
  2189. BOOL
  2190. RtlAreUuidsEqual (
  2191. PUUID Uuid1,
  2192. PUUID Uuid2
  2193. );
  2194. /*++
  2195. Routine Description:
  2196. This routine compares two UUIDs.
  2197. Arguments:
  2198. Uuid1 - Supplies the first UUID.
  2199. Uuid2 - Supplies the second UUID.
  2200. Return Value:
  2201. TRUE if the UUIDs are equal.
  2202. FALSE if the UUIDs are not equal.
  2203. --*/
  2204. __USED
  2205. RTL_API
  2206. ULONGLONG
  2207. RtlDivideUnsigned64 (
  2208. ULONGLONG Dividend,
  2209. ULONGLONG Divisor,
  2210. PULONGLONG Remainder
  2211. );
  2212. /*++
  2213. Routine Description:
  2214. This routine performs a 64-bit divide of two unsigned numbers.
  2215. Arguments:
  2216. Dividend - Supplies the number that is going to be divided (the numerator).
  2217. Divisor - Supplies the number to divide into (the denominator).
  2218. Remainder - Supplies a pointer that receives the remainder of the
  2219. divide. This parameter may be NULL.
  2220. Return Value:
  2221. Returns the quotient.
  2222. --*/
  2223. __USED
  2224. RTL_API
  2225. LONGLONG
  2226. RtlDivide64 (
  2227. LONGLONG Dividend,
  2228. LONGLONG Divisor
  2229. );
  2230. /*++
  2231. Routine Description:
  2232. This routine performs a 64-bit divide of two signed numbers.
  2233. Arguments:
  2234. Dividend - Supplies the number that is going to be divided (the numerator).
  2235. Divisor - Supplies the number to divide into (the denominator).
  2236. Return Value:
  2237. Returns the quotient.
  2238. --*/
  2239. __USED
  2240. RTL_API
  2241. LONGLONG
  2242. RtlDivideModulo64 (
  2243. LONGLONG Dividend,
  2244. LONGLONG Divisor,
  2245. PLONGLONG Remainder
  2246. );
  2247. /*++
  2248. Routine Description:
  2249. This routine performs a 64-bit divide and modulo of two signed numbers.
  2250. Arguments:
  2251. Dividend - Supplies the number that is going to be divided (the numerator).
  2252. Divisor - Supplies the number to divide into (the denominator).
  2253. Remainder - Supplies a pointer where the remainder will be returned.
  2254. Return Value:
  2255. Returns the quotient.
  2256. --*/
  2257. __USED
  2258. RTL_API
  2259. ULONG
  2260. RtlDivideUnsigned32 (
  2261. ULONG Dividend,
  2262. ULONG Divisor,
  2263. PULONG Remainder
  2264. );
  2265. /*++
  2266. Routine Description:
  2267. This routine performs a 32-bit divide of two unsigned numbers.
  2268. Arguments:
  2269. Dividend - Supplies the number that is going to be divided (the numerator).
  2270. Divisor - Supplies the number to divide into (the denominator).
  2271. Remainder - Supplies an optional pointer where the remainder will be
  2272. returned.
  2273. Return Value:
  2274. Returns the quotient.
  2275. --*/
  2276. __USED
  2277. RTL_API
  2278. LONG
  2279. RtlDivide32 (
  2280. LONG Dividend,
  2281. LONG Divisor
  2282. );
  2283. /*++
  2284. Routine Description:
  2285. This routine performs a 32-bit divide of two signed numbers.
  2286. Arguments:
  2287. Dividend - Supplies the number that is going to be divided (the numerator).
  2288. Divisor - Supplies the number to divide into (the denominator).
  2289. Return Value:
  2290. Returns the quotient.
  2291. --*/
  2292. __USED
  2293. RTL_API
  2294. LONG
  2295. RtlDivideModulo32 (
  2296. LONG Dividend,
  2297. LONG Divisor,
  2298. PLONG Remainder
  2299. );
  2300. /*++
  2301. Routine Description:
  2302. This routine performs a 32-bit divide and modulo of two signed numbers.
  2303. Arguments:
  2304. Dividend - Supplies the number that is going to be divided (the numerator).
  2305. Divisor - Supplies the number to divide into (the denominator).
  2306. Remainder - Supplies a pointer where the remainder will be returned.
  2307. Return Value:
  2308. Returns the quotient.
  2309. --*/
  2310. RTL_API
  2311. ULONGLONG
  2312. RtlByteSwapUlonglong (
  2313. ULONGLONG Input
  2314. );
  2315. /*++
  2316. Routine Description:
  2317. This routine performs a byte-swap of a 64-bit integer, effectively changing
  2318. its endianness.
  2319. Arguments:
  2320. Input - Supplies the integer to byte swap.
  2321. Return Value:
  2322. Returns the byte-swapped integer.
  2323. --*/
  2324. RTL_API
  2325. ULONG
  2326. RtlByteSwapUlong (
  2327. ULONG Input
  2328. );
  2329. /*++
  2330. Routine Description:
  2331. This routine performs a byte-swap of a 32-bit integer, effectively changing
  2332. its endianness.
  2333. Arguments:
  2334. Input - Supplies the integer to byte swap.
  2335. Return Value:
  2336. Returns the byte-swapped integer.
  2337. --*/
  2338. RTL_API
  2339. USHORT
  2340. RtlByteSwapUshort (
  2341. USHORT Input
  2342. );
  2343. /*++
  2344. Routine Description:
  2345. This routine performs a byte-swap of a 16-bit integer, effectively changing
  2346. its endianness.
  2347. Arguments:
  2348. Input - Supplies the integer to byte swap.
  2349. Return Value:
  2350. Returns the byte-swapped integer.
  2351. --*/
  2352. RTL_API
  2353. INT
  2354. RtlCountTrailingZeros64 (
  2355. ULONGLONG Value
  2356. );
  2357. /*++
  2358. Routine Description:
  2359. This routine determines the number of trailing zero bits in the given
  2360. 64-bit value.
  2361. Arguments:
  2362. Value - Supplies the value to get the number of trailing zeros for. This
  2363. must not be zero.
  2364. Return Value:
  2365. Returns the number of trailing zero bits in the given value.
  2366. --*/
  2367. RTL_API
  2368. INT
  2369. RtlCountTrailingZeros32 (
  2370. ULONG Value
  2371. );
  2372. /*++
  2373. Routine Description:
  2374. This routine determines the number of trailing zero bits in the given
  2375. 32-bit value.
  2376. Arguments:
  2377. Value - Supplies the value to get the number of trailing zeros for. This
  2378. must not be zero.
  2379. Return Value:
  2380. Returns the number of trailing zero bits in the given value.
  2381. --*/
  2382. RTL_API
  2383. INT
  2384. RtlCountLeadingZeros64 (
  2385. ULONGLONG Value
  2386. );
  2387. /*++
  2388. Routine Description:
  2389. This routine determines the number of leading zero bits in the given 64-bit
  2390. value.
  2391. Arguments:
  2392. Value - Supplies the value to get the number of leading zeros for. This
  2393. must not be zero.
  2394. Return Value:
  2395. Returns the number of leading zero bits in the given value.
  2396. --*/
  2397. RTL_API
  2398. INT
  2399. RtlCountLeadingZeros32 (
  2400. ULONG Value
  2401. );
  2402. /*++
  2403. Routine Description:
  2404. This routine determines the number of leading zero bits in the given 32-bit
  2405. value.
  2406. Arguments:
  2407. Value - Supplies the value to get the number of leading zeros for. This
  2408. must not be zero.
  2409. Return Value:
  2410. Returns the number of leading zero bits in the given value.
  2411. --*/
  2412. RTL_API
  2413. INT
  2414. RtlCountSetBits64 (
  2415. ULONGLONG Value
  2416. );
  2417. /*++
  2418. Routine Description:
  2419. This routine determines the number of bits set to one in the given 64-bit
  2420. value.
  2421. Arguments:
  2422. Value - Supplies the value to count set bits for.
  2423. Return Value:
  2424. Returns the number of bits set to one.
  2425. --*/
  2426. RTL_API
  2427. INT
  2428. RtlCountSetBits32 (
  2429. ULONG Value
  2430. );
  2431. /*++
  2432. Routine Description:
  2433. This routine determines the number of bits set to one in the given 32-bit
  2434. value.
  2435. Arguments:
  2436. Value - Supplies the value to count set bits for.
  2437. Return Value:
  2438. Returns the number of bits set to one.
  2439. --*/
  2440. RTL_API
  2441. BOOL
  2442. RtlFloatIsNan (
  2443. float Value
  2444. );
  2445. /*++
  2446. Routine Description:
  2447. This routine determines if the given value is Not a Number.
  2448. Arguments:
  2449. Value - Supplies the floating point value to query.
  2450. Return Value:
  2451. TRUE if the given value is Not a Number.
  2452. FALSE otherwise.
  2453. --*/
  2454. RTL_API
  2455. double
  2456. RtlFloatConvertToDouble (
  2457. float Float
  2458. );
  2459. /*++
  2460. Routine Description:
  2461. This routine converts the given float into a double.
  2462. Arguments:
  2463. Float - Supplies the float to convert.
  2464. Return Value:
  2465. Returns the double equivalent.
  2466. --*/
  2467. RTL_API
  2468. float
  2469. RtlFloatAdd (
  2470. float Value1,
  2471. float Value2
  2472. );
  2473. /*++
  2474. Routine Description:
  2475. This routine adds two floats together.
  2476. Arguments:
  2477. Value1 - Supplies the first value.
  2478. Value2 - Supplies the second value.
  2479. Return Value:
  2480. Returns the sum of the two values.
  2481. --*/
  2482. RTL_API
  2483. float
  2484. RtlFloatSubtract (
  2485. float Value1,
  2486. float Value2
  2487. );
  2488. /*++
  2489. Routine Description:
  2490. This routine subtracts two floats from each other.
  2491. Arguments:
  2492. Value1 - Supplies the first value.
  2493. Value2 - Supplies the second value, the value to subtract.
  2494. Return Value:
  2495. Returns the difference of the two values.
  2496. --*/
  2497. RTL_API
  2498. float
  2499. RtlFloatMultiply (
  2500. float Value1,
  2501. float Value2
  2502. );
  2503. /*++
  2504. Routine Description:
  2505. This routine multiplies two floats together.
  2506. Arguments:
  2507. Value1 - Supplies the first value.
  2508. Value2 - Supplies the second value.
  2509. Return Value:
  2510. Returns the product of the two values.
  2511. --*/
  2512. RTL_API
  2513. float
  2514. RtlFloatDivide (
  2515. float Dividend,
  2516. float Divisor
  2517. );
  2518. /*++
  2519. Routine Description:
  2520. This routine divides one float into another.
  2521. Arguments:
  2522. Dividend - Supplies the numerator.
  2523. Divisor - Supplies the denominator.
  2524. Return Value:
  2525. Returns the quotient of the two values.
  2526. --*/
  2527. RTL_API
  2528. float
  2529. RtlFloatModulo (
  2530. float Dividend,
  2531. float Divisor
  2532. );
  2533. /*++
  2534. Routine Description:
  2535. This routine divides one float into another, and returns the remainder.
  2536. Arguments:
  2537. Dividend - Supplies the numerator.
  2538. Divisor - Supplies the denominator.
  2539. Return Value:
  2540. Returns the modulo of the two values.
  2541. --*/
  2542. RTL_API
  2543. float
  2544. RtlFloatSquareRoot (
  2545. float Value
  2546. );
  2547. /*++
  2548. Routine Description:
  2549. This routine returns the square root of the given float.
  2550. Arguments:
  2551. Value - Supplies the value to take the square root of.
  2552. Return Value:
  2553. Returns the square root of the given value.
  2554. --*/
  2555. RTL_API
  2556. BOOL
  2557. RtlFloatIsEqual (
  2558. float Value1,
  2559. float Value2
  2560. );
  2561. /*++
  2562. Routine Description:
  2563. This routine determines if the given floats are equal.
  2564. Arguments:
  2565. Value1 - Supplies the first value to compare.
  2566. Value2 - Supplies the second value to compare.
  2567. Return Value:
  2568. TRUE if the values are equal.
  2569. FALSE if the values are not equal. Note that NaN is not equal to anything,
  2570. including itself.
  2571. --*/
  2572. RTL_API
  2573. BOOL
  2574. RtlFloatIsLessThanOrEqual (
  2575. float Value1,
  2576. float Value2
  2577. );
  2578. /*++
  2579. Routine Description:
  2580. This routine determines if the given value is less than or equal to the
  2581. second value.
  2582. Arguments:
  2583. Value1 - Supplies the first value to compare, the left hand side of the
  2584. comparison.
  2585. Value2 - Supplies the second value to compare, the right hand side of the
  2586. comparison.
  2587. Return Value:
  2588. TRUE if the first value is less than or equal to the first.
  2589. FALSE if the first value is greater than the second.
  2590. --*/
  2591. RTL_API
  2592. BOOL
  2593. RtlFloatIsLessThan (
  2594. float Value1,
  2595. float Value2
  2596. );
  2597. /*++
  2598. Routine Description:
  2599. This routine determines if the given value is strictly less than the
  2600. second value.
  2601. Arguments:
  2602. Value1 - Supplies the first value to compare, the left hand side of the
  2603. comparison.
  2604. Value2 - Supplies the second value to compare, the right hand side of the
  2605. comparison.
  2606. Return Value:
  2607. TRUE if the first value is strictly less than to the first.
  2608. FALSE if the first value is greater than or equal to the second.
  2609. --*/
  2610. RTL_API
  2611. BOOL
  2612. RtlFloatSignalingIsEqual (
  2613. float Value1,
  2614. float Value2
  2615. );
  2616. /*++
  2617. Routine Description:
  2618. This routine determines if the given values are equal, generating an
  2619. invalid floating point exception if either is NaN.
  2620. Arguments:
  2621. Value1 - Supplies the first value to compare, the left hand side of the
  2622. comparison.
  2623. Value2 - Supplies the second value to compare, the right hand side of the
  2624. comparison.
  2625. Return Value:
  2626. TRUE if the first value is strictly less than to the first.
  2627. FALSE if the first value is greater than or equal to the second.
  2628. --*/
  2629. RTL_API
  2630. BOOL
  2631. RtlFloatIsLessThanOrEqualQuiet (
  2632. float Value1,
  2633. float Value2
  2634. );
  2635. /*++
  2636. Routine Description:
  2637. This routine determines if the given value is less than or equal to the
  2638. second value. Quiet NaNs do not generate floating point exceptions.
  2639. Arguments:
  2640. Value1 - Supplies the first value to compare, the left hand side of the
  2641. comparison.
  2642. Value2 - Supplies the second value to compare, the right hand side of the
  2643. comparison.
  2644. Return Value:
  2645. TRUE if the first value is less than or equal to the first.
  2646. FALSE if the first value is greater than the second.
  2647. --*/
  2648. RTL_API
  2649. BOOL
  2650. RtlFloatIsLessThanQuiet (
  2651. float Value1,
  2652. float Value2
  2653. );
  2654. /*++
  2655. Routine Description:
  2656. This routine determines if the given value is strictly less than the
  2657. second value. Quiet NaNs do not cause float point exceptions to be raised.
  2658. Arguments:
  2659. Value1 - Supplies the first value to compare, the left hand side of the
  2660. comparison.
  2661. Value2 - Supplies the second value to compare, the right hand side of the
  2662. comparison.
  2663. Return Value:
  2664. TRUE if the first value is strictly less than to the first.
  2665. FALSE if the first value is greater than or equal to the second.
  2666. --*/
  2667. RTL_API
  2668. float
  2669. RtlFloatConvertFromInteger32 (
  2670. LONG Integer
  2671. );
  2672. /*++
  2673. Routine Description:
  2674. This routine converts the given signed 32-bit integer into a float.
  2675. Arguments:
  2676. Integer - Supplies the integer to convert to a float.
  2677. Return Value:
  2678. Returns the float equivalent to the given integer.
  2679. --*/
  2680. RTL_API
  2681. float
  2682. RtlFloatConvertFromUnsignedInteger32 (
  2683. ULONG Integer
  2684. );
  2685. /*++
  2686. Routine Description:
  2687. This routine converts the given unsigned 32-bit integer into a float.
  2688. Arguments:
  2689. Integer - Supplies the integer to convert to a float.
  2690. Return Value:
  2691. Returns the float equivalent to the given integer.
  2692. --*/
  2693. RTL_API
  2694. float
  2695. RtlFloatConvertFromInteger64 (
  2696. LONGLONG Integer
  2697. );
  2698. /*++
  2699. Routine Description:
  2700. This routine converts the given signed 64-bit integer into a float.
  2701. Arguments:
  2702. Integer - Supplies the integer to convert to a float.
  2703. Return Value:
  2704. Returns the float equivalent to the given integer.
  2705. --*/
  2706. RTL_API
  2707. float
  2708. RtlFloatConvertFromUnsignedInteger64 (
  2709. ULONGLONG Integer
  2710. );
  2711. /*++
  2712. Routine Description:
  2713. This routine converts the given unsigned 64-bit integer into a float.
  2714. Arguments:
  2715. Integer - Supplies the unsigned integer to convert to a float.
  2716. Return Value:
  2717. Returns the float equivalent to the given integer.
  2718. --*/
  2719. RTL_API
  2720. LONG
  2721. RtlFloatConvertToInteger32 (
  2722. float Float
  2723. );
  2724. /*++
  2725. Routine Description:
  2726. This routine converts the given float into a signed 32 bit integer.
  2727. Arguments:
  2728. Float - Supplies the float to convert.
  2729. Return Value:
  2730. Returns the integer, rounded according to the current rounding mode.
  2731. --*/
  2732. RTL_API
  2733. LONG
  2734. RtlFloatConvertToInteger32RoundToZero (
  2735. float Float
  2736. );
  2737. /*++
  2738. Routine Description:
  2739. This routine converts the given float into a signed 32 bit integer. It
  2740. always rounds towards zero.
  2741. Arguments:
  2742. Float - Supplies the float to convert.
  2743. Return Value:
  2744. Returns the integer, rounded towards zero.
  2745. --*/
  2746. RTL_API
  2747. LONGLONG
  2748. RtlFloatConvertToInteger64 (
  2749. float Float
  2750. );
  2751. /*++
  2752. Routine Description:
  2753. This routine converts the given float into a signed 64 bit integer. If the
  2754. value is NaN, then the largest positive integer is returned.
  2755. Arguments:
  2756. Float - Supplies the float to convert.
  2757. Return Value:
  2758. Returns the integer, rounded according to the current rounding mode.
  2759. --*/
  2760. RTL_API
  2761. LONGLONG
  2762. RtlFloatConvertToInteger64RoundToZero (
  2763. float Float
  2764. );
  2765. /*++
  2766. Routine Description:
  2767. This routine converts the given float into a signed 64 bit integer. If the
  2768. value is NaN, then the largest positive integer is returned. This routine
  2769. always rounds towards zero.
  2770. Arguments:
  2771. Float - Supplies the float to convert.
  2772. Return Value:
  2773. Returns the integer, rounded towards zero.
  2774. --*/
  2775. RTL_API
  2776. BOOL
  2777. RtlDoubleIsNan (
  2778. double Value
  2779. );
  2780. /*++
  2781. Routine Description:
  2782. This routine determines if the given value is Not a Number.
  2783. Arguments:
  2784. Value - Supplies the floating point value to query.
  2785. Return Value:
  2786. TRUE if the given value is Not a Number.
  2787. FALSE otherwise.
  2788. --*/
  2789. RTL_API
  2790. double
  2791. RtlDoubleConvertFromInteger32 (
  2792. LONG Integer
  2793. );
  2794. /*++
  2795. Routine Description:
  2796. This routine converts the given signed 32-bit integer into a double.
  2797. Arguments:
  2798. Integer - Supplies the integer to convert to a double.
  2799. Return Value:
  2800. Returns the double equivalent to the given integer.
  2801. --*/
  2802. RTL_API
  2803. double
  2804. RtlDoubleConvertFromUnsignedInteger32 (
  2805. ULONG Integer
  2806. );
  2807. /*++
  2808. Routine Description:
  2809. This routine converts the given unsigned 32-bit integer into a double.
  2810. Arguments:
  2811. Integer - Supplies the integer to convert to a double.
  2812. Return Value:
  2813. Returns the double equivalent to the given integer.
  2814. --*/
  2815. RTL_API
  2816. double
  2817. RtlDoubleConvertFromInteger64 (
  2818. LONGLONG Integer
  2819. );
  2820. /*++
  2821. Routine Description:
  2822. This routine converts the given signed 64-bit integer into a double.
  2823. Arguments:
  2824. Integer - Supplies the integer to convert to a double.
  2825. Return Value:
  2826. Returns the double equivalent to the given integer.
  2827. --*/
  2828. RTL_API
  2829. double
  2830. RtlDoubleConvertFromUnsignedInteger64 (
  2831. ULONGLONG Integer
  2832. );
  2833. /*++
  2834. Routine Description:
  2835. This routine converts the given unsigned 64-bit integer into a double.
  2836. Arguments:
  2837. Integer - Supplies the unsigned integer to convert to a double.
  2838. Return Value:
  2839. Returns the double equivalent to the given integer.
  2840. --*/
  2841. RTL_API
  2842. LONG
  2843. RtlDoubleConvertToInteger32 (
  2844. double Double
  2845. );
  2846. /*++
  2847. Routine Description:
  2848. This routine converts the given double into a signed 32 bit integer.
  2849. Arguments:
  2850. Double - Supplies the double to convert.
  2851. Return Value:
  2852. Returns the integer, rounded according to the current rounding mode.
  2853. --*/
  2854. RTL_API
  2855. LONG
  2856. RtlDoubleConvertToInteger32RoundToZero (
  2857. double Double
  2858. );
  2859. /*++
  2860. Routine Description:
  2861. This routine converts the given double into a signed 32 bit integer. It
  2862. always rounds towards zero.
  2863. Arguments:
  2864. Double - Supplies the double to convert.
  2865. Return Value:
  2866. Returns the integer, rounded towards zero.
  2867. --*/
  2868. RTL_API
  2869. LONGLONG
  2870. RtlDoubleConvertToInteger64 (
  2871. double Double
  2872. );
  2873. /*++
  2874. Routine Description:
  2875. This routine converts the given double into a signed 64 bit integer. If the
  2876. value is NaN, then the largest positive integer is returned.
  2877. Arguments:
  2878. Double - Supplies the double to convert.
  2879. Return Value:
  2880. Returns the integer, rounded according to the current rounding mode.
  2881. --*/
  2882. RTL_API
  2883. LONGLONG
  2884. RtlDoubleConvertToInteger64RoundToZero (
  2885. double Double
  2886. );
  2887. /*++
  2888. Routine Description:
  2889. This routine converts the given double into a signed 64 bit integer. If the
  2890. value is NaN, then the largest positive integer is returned. This routine
  2891. always rounds towards zero.
  2892. Arguments:
  2893. Double - Supplies the double to convert.
  2894. Return Value:
  2895. Returns the integer, rounded towards zero.
  2896. --*/
  2897. RTL_API
  2898. float
  2899. RtlDoubleConvertToFloat (
  2900. double Double
  2901. );
  2902. /*++
  2903. Routine Description:
  2904. This routine converts the given double into a float (32 bit floating
  2905. point number).
  2906. Arguments:
  2907. Double - Supplies the double to convert.
  2908. Return Value:
  2909. Returns the float equivalent.
  2910. --*/
  2911. RTL_API
  2912. double
  2913. RtlDoubleAdd (
  2914. double Value1,
  2915. double Value2
  2916. );
  2917. /*++
  2918. Routine Description:
  2919. This routine adds two doubles together.
  2920. Arguments:
  2921. Value1 - Supplies the first value.
  2922. Value2 - Supplies the second value.
  2923. Return Value:
  2924. Returns the sum of the two values.
  2925. --*/
  2926. RTL_API
  2927. double
  2928. RtlDoubleSubtract (
  2929. double Value1,
  2930. double Value2
  2931. );
  2932. /*++
  2933. Routine Description:
  2934. This routine subtracts two doubles from each other.
  2935. Arguments:
  2936. Value1 - Supplies the first value.
  2937. Value2 - Supplies the second value, the value to subtract.
  2938. Return Value:
  2939. Returns the difference of the two values.
  2940. --*/
  2941. RTL_API
  2942. double
  2943. RtlDoubleMultiply (
  2944. double Value1,
  2945. double Value2
  2946. );
  2947. /*++
  2948. Routine Description:
  2949. This routine multiplies two doubles together.
  2950. Arguments:
  2951. Value1 - Supplies the first value.
  2952. Value2 - Supplies the second value.
  2953. Return Value:
  2954. Returns the product of the two values.
  2955. --*/
  2956. RTL_API
  2957. double
  2958. RtlDoubleDivide (
  2959. double Dividend,
  2960. double Divisor
  2961. );
  2962. /*++
  2963. Routine Description:
  2964. This routine divides one double into another.
  2965. Arguments:
  2966. Dividend - Supplies the numerator.
  2967. Divisor - Supplies the denominator.
  2968. Return Value:
  2969. Returns the quotient of the two values.
  2970. --*/
  2971. RTL_API
  2972. double
  2973. RtlDoubleModulo (
  2974. double Dividend,
  2975. double Divisor
  2976. );
  2977. /*++
  2978. Routine Description:
  2979. This routine divides one double into another, and returns the remainder.
  2980. Arguments:
  2981. Dividend - Supplies the numerator.
  2982. Divisor - Supplies the denominator.
  2983. Return Value:
  2984. Returns the modulo of the two values.
  2985. --*/
  2986. RTL_API
  2987. double
  2988. RtlDoubleSquareRoot (
  2989. double Value
  2990. );
  2991. /*++
  2992. Routine Description:
  2993. This routine returns the square root of the given double.
  2994. Arguments:
  2995. Value - Supplies the value to take the square root of.
  2996. Return Value:
  2997. Returns the square root of the given value.
  2998. --*/
  2999. RTL_API
  3000. BOOL
  3001. RtlDoubleIsEqual (
  3002. double Value1,
  3003. double Value2
  3004. );
  3005. /*++
  3006. Routine Description:
  3007. This routine determines if the given doubles are equal.
  3008. Arguments:
  3009. Value1 - Supplies the first value to compare.
  3010. Value2 - Supplies the second value to compare.
  3011. Return Value:
  3012. TRUE if the values are equal.
  3013. FALSE if the values are not equal. Note that NaN is not equal to anything,
  3014. including itself.
  3015. --*/
  3016. RTL_API
  3017. BOOL
  3018. RtlDoubleIsLessThanOrEqual (
  3019. double Value1,
  3020. double Value2
  3021. );
  3022. /*++
  3023. Routine Description:
  3024. This routine determines if the given value is less than or equal to the
  3025. second value.
  3026. Arguments:
  3027. Value1 - Supplies the first value to compare, the left hand side of the
  3028. comparison.
  3029. Value2 - Supplies the second value to compare, the right hand side of the
  3030. comparison.
  3031. Return Value:
  3032. TRUE if the first value is less than or equal to the first.
  3033. FALSE if the first value is greater than the second.
  3034. --*/
  3035. RTL_API
  3036. BOOL
  3037. RtlDoubleIsLessThan (
  3038. double Value1,
  3039. double Value2
  3040. );
  3041. /*++
  3042. Routine Description:
  3043. This routine determines if the given value is strictly less than the
  3044. second value.
  3045. Arguments:
  3046. Value1 - Supplies the first value to compare, the left hand side of the
  3047. comparison.
  3048. Value2 - Supplies the second value to compare, the right hand side of the
  3049. comparison.
  3050. Return Value:
  3051. TRUE if the first value is strictly less than to the first.
  3052. FALSE if the first value is greater than or equal to the second.
  3053. --*/
  3054. RTL_API
  3055. BOOL
  3056. RtlDoubleSignalingIsEqual (
  3057. double Value1,
  3058. double Value2
  3059. );
  3060. /*++
  3061. Routine Description:
  3062. This routine determines if the given values are equal, generating an
  3063. invalid floating point exception if either is NaN.
  3064. Arguments:
  3065. Value1 - Supplies the first value to compare, the left hand side of the
  3066. comparison.
  3067. Value2 - Supplies the second value to compare, the right hand side of the
  3068. comparison.
  3069. Return Value:
  3070. TRUE if the first value is strictly less than to the first.
  3071. FALSE if the first value is greater than or equal to the second.
  3072. --*/
  3073. RTL_API
  3074. BOOL
  3075. RtlDoubleIsLessThanOrEqualQuiet (
  3076. double Value1,
  3077. double Value2
  3078. );
  3079. /*++
  3080. Routine Description:
  3081. This routine determines if the given value is less than or equal to the
  3082. second value. Quiet NaNs do not generate floating point exceptions.
  3083. Arguments:
  3084. Value1 - Supplies the first value to compare, the left hand side of the
  3085. comparison.
  3086. Value2 - Supplies the second value to compare, the right hand side of the
  3087. comparison.
  3088. Return Value:
  3089. TRUE if the first value is less than or equal to the first.
  3090. FALSE if the first value is greater than the second.
  3091. --*/
  3092. RTL_API
  3093. BOOL
  3094. RtlDoubleIsLessThanQuiet (
  3095. double Value1,
  3096. double Value2
  3097. );
  3098. /*++
  3099. Routine Description:
  3100. This routine determines if the given value is strictly less than the
  3101. second value. Quiet NaNs do not cause float point exceptions to be raised.
  3102. Arguments:
  3103. Value1 - Supplies the first value to compare, the left hand side of the
  3104. comparison.
  3105. Value2 - Supplies the second value to compare, the right hand side of the
  3106. comparison.
  3107. Return Value:
  3108. TRUE if the first value is strictly less than to the first.
  3109. FALSE if the first value is greater than or equal to the second.
  3110. --*/
  3111. RTL_API
  3112. VOID
  3113. RtlDebugBreak (
  3114. VOID
  3115. );
  3116. /*++
  3117. Routine Description:
  3118. This routine causes a break into the debugger.
  3119. Arguments:
  3120. None.
  3121. Return Value:
  3122. None.
  3123. --*/
  3124. VOID
  3125. RtlDebugService (
  3126. UINTN ServiceRequest,
  3127. PVOID Parameter
  3128. );
  3129. /*++
  3130. Routine Description:
  3131. This routine enters the debugger for a service request.
  3132. Arguments:
  3133. ServiceRequest - Supplies the reason for entering the debugger.
  3134. Parameter - Supplies the parameter to pass to the debug service routine.
  3135. Return Value:
  3136. None.
  3137. --*/
  3138. RTL_API
  3139. ULONG
  3140. RtlAtomicExchange32 (
  3141. volatile ULONG *Address,
  3142. ULONG ExchangeValue
  3143. );
  3144. /*++
  3145. Routine Description:
  3146. This routine atomically exchanges the value at the given memory address
  3147. with the given value.
  3148. Arguments:
  3149. Address - Supplies the address of the value to exchange with.
  3150. ExchangeValue - Supplies the value to write to the address.
  3151. Return Value:
  3152. Returns the original value at the given address.
  3153. --*/
  3154. RTL_API
  3155. ULONGLONG
  3156. RtlAtomicExchange64 (
  3157. volatile ULONGLONG *Address,
  3158. ULONGLONG ExchangeValue
  3159. );
  3160. /*++
  3161. Routine Description:
  3162. This routine atomically exchanges the value at the given memory address
  3163. with the given value.
  3164. Arguments:
  3165. Address - Supplies the address of the value to exchange with.
  3166. ExchangeValue - Supplies the value to write to the address.
  3167. Return Value:
  3168. Returns the original value at the given address.
  3169. --*/
  3170. RTL_API
  3171. ULONGLONG
  3172. RtlAtomicCompareExchange64 (
  3173. volatile ULONGLONG *Address,
  3174. ULONGLONG ExchangeValue,
  3175. ULONGLONG CompareValue
  3176. );
  3177. /*++
  3178. Routine Description:
  3179. This routine atomically compares a 64-bit value at the given address with a
  3180. value and exchanges it with another value if they are equal.
  3181. Arguments:
  3182. Address - Supplies the address of the value to compare and potentially
  3183. exchange.
  3184. ExchangeValue - Supplies the value to write to Address if the comparison
  3185. returns equality.
  3186. CompareValue - Supplies the value to compare against.
  3187. Return Value:
  3188. Returns the original value at the given address.
  3189. --*/
  3190. RTL_API
  3191. ULONG
  3192. RtlAtomicCompareExchange32 (
  3193. volatile ULONG *Address,
  3194. ULONG ExchangeValue,
  3195. ULONG CompareValue
  3196. );
  3197. /*++
  3198. Routine Description:
  3199. This routine atomically compares memory at the given address with a value
  3200. and exchanges it with another value if they are equal.
  3201. Arguments:
  3202. Address - Supplies the address of the value to compare and potentially
  3203. exchange.
  3204. ExchangeValue - Supplies the value to write to Address if the comparison
  3205. returns equality.
  3206. CompareValue - Supplies the value to compare against.
  3207. Return Value:
  3208. Returns the original value at the given address.
  3209. --*/
  3210. RTL_API
  3211. ULONG
  3212. RtlAtomicAdd32 (
  3213. volatile ULONG *Address,
  3214. ULONG Increment
  3215. );
  3216. /*++
  3217. Routine Description:
  3218. This routine atomically adds the given amount to a 32-bit variable.
  3219. Arguments:
  3220. Address - Supplies the address of the value to atomically add to.
  3221. Increment - Supplies the amount to add.
  3222. Return Value:
  3223. Returns the value before the atomic addition was performed.
  3224. --*/
  3225. RTL_API
  3226. ULONGLONG
  3227. RtlAtomicAdd64 (
  3228. volatile ULONGLONG *Address,
  3229. ULONGLONG Increment
  3230. );
  3231. /*++
  3232. Routine Description:
  3233. This routine atomically adds the given amount to a 64-bit variable.
  3234. Arguments:
  3235. Address - Supplies the address of the value to atomically add to.
  3236. Increment - Supplies the amount to add.
  3237. Return Value:
  3238. Returns the value before the atomic addition was performed.
  3239. --*/
  3240. RTL_API
  3241. ULONG
  3242. RtlAtomicOr32 (
  3243. volatile ULONG *Address,
  3244. ULONG Mask
  3245. );
  3246. /*++
  3247. Routine Description:
  3248. This routine atomically ORs the given mask to a 32-bit variable.
  3249. Arguments:
  3250. Address - Supplies the address of the value to atomically OR with.
  3251. Mask - Supplies the bitmask to logically OR in to the value.
  3252. Return Value:
  3253. Returns the value before the atomic operation was performed.
  3254. --*/
  3255. RTL_API
  3256. ULONGLONG
  3257. RtlAtomicOr64 (
  3258. volatile ULONGLONG *Address,
  3259. ULONGLONG Mask
  3260. );
  3261. /*++
  3262. Routine Description:
  3263. This routine atomically ORs the given amount to a 64-bit variable.
  3264. Arguments:
  3265. Address - Supplies the address of the value to atomically OR with.
  3266. Mask - Supplies the bitmask to logically OR in to the value.
  3267. Return Value:
  3268. Returns the value before the atomic operation was performed.
  3269. --*/
  3270. RTL_API
  3271. ULONG
  3272. RtlAtomicAnd32 (
  3273. volatile ULONG *Address,
  3274. ULONG Mask
  3275. );
  3276. /*++
  3277. Routine Description:
  3278. This routine atomically ANDs the given mask to a 32-bit variable.
  3279. Arguments:
  3280. Address - Supplies the address of the value to atomically AND with.
  3281. Mask - Supplies the bitmask to logically AND in to the value.
  3282. Return Value:
  3283. Returns the value before the atomic operation was performed.
  3284. --*/
  3285. RTL_API
  3286. ULONG
  3287. RtlAtomicXor32 (
  3288. volatile ULONG *Address,
  3289. ULONG Mask
  3290. );
  3291. /*++
  3292. Routine Description:
  3293. This routine atomically exclusive ORs the given mask to a 32-bit variable.
  3294. Arguments:
  3295. Address - Supplies the address of the value to atomically XOR with.
  3296. Mask - Supplies the bitmask to logically XOR in to the value.
  3297. Return Value:
  3298. Returns the value before the atomic operation was performed.
  3299. --*/
  3300. RTL_API
  3301. VOID
  3302. RtlMemoryBarrier (
  3303. VOID
  3304. );
  3305. /*++
  3306. Routine Description:
  3307. This routine provides a full memory barrier, ensuring that all memory
  3308. accesses occurring before this function complete before any memory accesses
  3309. after this function start.
  3310. Arguments:
  3311. None.
  3312. Return Value:
  3313. None.
  3314. --*/
  3315. RTL_API
  3316. VOID
  3317. RtlRedBlackTreeInitialize (
  3318. PRED_BLACK_TREE Tree,
  3319. ULONG Flags,
  3320. PCOMPARE_RED_BLACK_TREE_NODES CompareFunction
  3321. );
  3322. /*++
  3323. Routine Description:
  3324. This routine initializes a Red-Black tree structure.
  3325. Arguments:
  3326. Tree - Supplies a pointer to a tree to initialize. Tree structures should
  3327. not be initialized more than once.
  3328. Flags - Supplies a bitmask of flags governing the behavior of the tree. See
  3329. RED_BLACK_TREE_FLAG_* definitions.
  3330. CompareFunction - Supplies a pointer to a function called to compare nodes
  3331. to each other. This routine is used on insertion, deletion, and search.
  3332. Return Value:
  3333. None.
  3334. --*/
  3335. RTL_API
  3336. VOID
  3337. RtlRedBlackTreeInsert (
  3338. PRED_BLACK_TREE Tree,
  3339. PRED_BLACK_TREE_NODE NewNode
  3340. );
  3341. /*++
  3342. Routine Description:
  3343. This routine inserts a node into the given Red-Black tree.
  3344. Arguments:
  3345. Tree - Supplies a pointer to a tree to insert the node into.
  3346. NewNode - Supplies a pointer to the new node to insert.
  3347. Return Value:
  3348. None.
  3349. --*/
  3350. RTL_API
  3351. PRED_BLACK_TREE_NODE
  3352. RtlRedBlackTreeSearch (
  3353. PRED_BLACK_TREE Tree,
  3354. PRED_BLACK_TREE_NODE Value
  3355. );
  3356. /*++
  3357. Routine Description:
  3358. This routine searches for a node in the tree with the given value. If there
  3359. are multiple nodes with the same value, then the first one found will be
  3360. returned.
  3361. Arguments:
  3362. Tree - Supplies a pointer to a tree that owns the node to search.
  3363. Value - Supplies a pointer to a dummy node that will be passed to the
  3364. compare function. This node only has to be filled in to the extent that
  3365. the compare function can be called to compare its value. Usually this
  3366. is a stack allocated variable of the parent structure with that value
  3367. filled in.
  3368. Return Value:
  3369. Returns a pointer to a node in the tree matching the desired value on
  3370. success.
  3371. NULL if a node matching the given value could not be found.
  3372. --*/
  3373. RTL_API
  3374. PRED_BLACK_TREE_NODE
  3375. RtlRedBlackTreeSearchClosest (
  3376. PRED_BLACK_TREE Tree,
  3377. PRED_BLACK_TREE_NODE Value,
  3378. BOOL GreaterThan
  3379. );
  3380. /*++
  3381. Routine Description:
  3382. This routine searches for a node in the tree with the given value. If there
  3383. are multiple nodes with the same value, then the first one found will be
  3384. returned. If no node matches the given value, then the closest node
  3385. greater than or less than the given value (depending on the parameter) will
  3386. be returned instead.
  3387. Arguments:
  3388. Tree - Supplies a pointer to a tree that owns the node to search.
  3389. Value - Supplies a pointer to a dummy node that will be passed to the
  3390. compare function. This node only has to be filled in to the extent that
  3391. the compare function can be called to compare its value. Usually this
  3392. is a stack allocated variable of the parent structure with that value
  3393. filled in.
  3394. GreaterThan - Supplies a boolean indicating whether the closest value
  3395. greater than the given value should be returned (TRUE) or the closest
  3396. value less than the given value shall be returned (FALSE).
  3397. Return Value:
  3398. Returns a pointer to a node in the tree matching the desired value on
  3399. success.
  3400. Returns a pointer to the closest node greater than the given value if the
  3401. greater than parameter is set and there is a node greater than the given
  3402. value.
  3403. Returns a pointer to the closest node less than the given node if the
  3404. greater than parameter is not set, and such a node exists.
  3405. NULL if the node cannot be found and there is no node greater than (or less
  3406. than, depending on the parameter) the given value.
  3407. --*/
  3408. RTL_API
  3409. PRED_BLACK_TREE_NODE
  3410. RtlRedBlackTreeGetLowestNode (
  3411. PRED_BLACK_TREE Tree
  3412. );
  3413. /*++
  3414. Routine Description:
  3415. This routine returns the node in the given Red-Black tree with the lowest
  3416. value.
  3417. Arguments:
  3418. Tree - Supplies a pointer to a tree.
  3419. Return Value:
  3420. Returns a pointer to the node with the lowest value.
  3421. NULL if the tree is empty.
  3422. --*/
  3423. RTL_API
  3424. PRED_BLACK_TREE_NODE
  3425. RtlRedBlackTreeGetHighestNode (
  3426. PRED_BLACK_TREE Tree
  3427. );
  3428. /*++
  3429. Routine Description:
  3430. This routine returns the node in the given Red-Black tree with the highest
  3431. value.
  3432. Arguments:
  3433. Tree - Supplies a pointer to a tree.
  3434. Return Value:
  3435. Returns a pointer to the node with the lowest value.
  3436. NULL if the tree is empty.
  3437. --*/
  3438. RTL_API
  3439. VOID
  3440. RtlRedBlackTreeRemove (
  3441. PRED_BLACK_TREE Tree,
  3442. PRED_BLACK_TREE_NODE Node
  3443. );
  3444. /*++
  3445. Routine Description:
  3446. This routine removes the given node from the Red-Black tree.
  3447. Arguments:
  3448. Tree - Supplies a pointer to a tree that the node is currently inserted
  3449. into.
  3450. Node - Supplies a pointer to the node to remove from the tree.
  3451. Return Value:
  3452. None.
  3453. --*/
  3454. RTL_API
  3455. VOID
  3456. RtlRedBlackTreeIterate (
  3457. PRED_BLACK_TREE Tree,
  3458. PRED_BLACK_TREE_ITERATION_ROUTINE Routine,
  3459. PVOID Context
  3460. );
  3461. /*++
  3462. Routine Description:
  3463. This routine iterates through all nodes in a Red-Black tree (via in in
  3464. order traversal) and calls the given routine for each node in the tree.
  3465. The routine passed must not modify the tree.
  3466. Arguments:
  3467. Tree - Supplies a pointer to a tree that the node is currently inserted
  3468. into.
  3469. Routine - Supplies a pointer to the routine that will be called for each
  3470. node encountered.
  3471. Context - Supplies an optional caller-provided context that will be passed
  3472. to the interation routine for each node.
  3473. Return Value:
  3474. None.
  3475. --*/
  3476. RTL_API
  3477. PRED_BLACK_TREE_NODE
  3478. RtlRedBlackTreeGetNextNode (
  3479. PRED_BLACK_TREE Tree,
  3480. BOOL Descending,
  3481. PRED_BLACK_TREE_NODE PreviousNode
  3482. );
  3483. /*++
  3484. Routine Description:
  3485. This routine gets the node in the Red-Black tree with the next highest
  3486. or lower value depending on the supplied boolean.
  3487. Arguments:
  3488. Tree - Supplies a pointer to a Red-Black tree.
  3489. Descending - Supplies a boolean indicating if the next node should be a
  3490. descending value or not.
  3491. PreviousNode - Supplies a pointer to the previous node on which to base the
  3492. search.
  3493. Return Value:
  3494. Returns a pointer to the node in the tree with the next highest value, or
  3495. NULL if the given previous node is the node with the highest value.
  3496. --*/
  3497. RTL_API
  3498. BOOL
  3499. RtlValidateRedBlackTree (
  3500. PRED_BLACK_TREE Tree
  3501. );
  3502. /*++
  3503. Routine Description:
  3504. This routine determines if the given Red-Black tree is valid.
  3505. Note: This function is recursive, and should not be used outside of debug
  3506. builds and test environments.
  3507. Arguments:
  3508. Tree - Supplies a pointer to the tree to validate.
  3509. Return Value:
  3510. TRUE if the tree is valid.
  3511. FALSE if the tree is corrupt or is breaking required rules of Red-Black
  3512. trees.
  3513. --*/
  3514. RTL_API
  3515. KSTATUS
  3516. RtlSystemTimeToGmtCalendarTime (
  3517. PSYSTEM_TIME SystemTime,
  3518. PCALENDAR_TIME CalendarTime
  3519. );
  3520. /*++
  3521. Routine Description:
  3522. This routine converts the given system time into calendar time in the
  3523. GMT time zone.
  3524. Arguments:
  3525. SystemTime - Supplies a pointer to the system time to convert.
  3526. CalendarTime - Supplies a pointer to the calendar time to initialize based
  3527. on the given system time.
  3528. Return Value:
  3529. STATUS_SUCCESS on success.
  3530. STATUS_OUT_OF_BOUNDS if the given system time is too funky.
  3531. --*/
  3532. RTL_API
  3533. KSTATUS
  3534. RtlCalendarTimeToSystemTime (
  3535. PCALENDAR_TIME CalendarTime,
  3536. PSYSTEM_TIME SystemTime
  3537. );
  3538. /*++
  3539. Routine Description:
  3540. This routine converts the given calendar time into its corresponding system
  3541. time.
  3542. Arguments:
  3543. CalendarTime - Supplies a pointer to the calendar time to convert.
  3544. SystemTime - Supplies a pointer where the system time will be returned.
  3545. Return Value:
  3546. STATUS_SUCCESS on success.
  3547. STATUS_OUT_OF_BOUNDS if the given calendar time is too funky.
  3548. --*/
  3549. RTL_API
  3550. KSTATUS
  3551. RtlGmtCalendarTimeToSystemTime (
  3552. PCALENDAR_TIME CalendarTime,
  3553. PSYSTEM_TIME SystemTime
  3554. );
  3555. /*++
  3556. Routine Description:
  3557. This routine converts the given calendar time, assumed to be a GMT data and
  3558. time, into its corresponding system time. On success, this routine will
  3559. update the supplied calendar time to fill out all fields.
  3560. Arguments:
  3561. CalendarTime - Supplies a pointer to the GMT calendar time to convert.
  3562. SystemTime - Supplies a pointer where the system time will be returned.
  3563. Return Value:
  3564. STATUS_SUCCESS on success.
  3565. STATUS_OUT_OF_BOUNDS if the given GMT calendar time is too funky.
  3566. --*/
  3567. RTL_API
  3568. UINTN
  3569. RtlFormatDate (
  3570. PSTR StringBuffer,
  3571. ULONG StringBufferSize,
  3572. PSTR Format,
  3573. PCALENDAR_TIME CalendarTime
  3574. );
  3575. /*++
  3576. Routine Description:
  3577. This routine converts the given calendar time into a string governed by
  3578. the given format string.
  3579. Arguments:
  3580. StringBuffer - Supplies a pointer where the converted string will be
  3581. returned, including the terminating null.
  3582. StringBufferSize - Supplies the size of the string buffer in bytes.
  3583. Format - Supplies the format string to govern the conversion. Ordinary
  3584. characters in the format string will be copied verbatim to the output
  3585. string. Conversions will be substituted for their corresponding value
  3586. in the provided calendar time. Conversions start with a '%' character,
  3587. followed by an optional E or O character, followed by a conversion
  3588. specifier. The conversion specifier can take the following values:
  3589. %a - Replaced by the abbreviated weekday.
  3590. %A - Replaced by the full weekday.
  3591. %b - Replaced by the abbreviated month name.
  3592. %B - Replaced by the full month name.
  3593. %c - Replaced by the locale's appropriate date and time representation.
  3594. %C - Replaced by the year divided by 100 (century) [00,99].
  3595. %d - Replaced by the day of the month [01,31].
  3596. %D - Equivalent to "%m/%d/%y".
  3597. %e - Replaced by the day of the month [ 1,31]. A single digit is
  3598. preceded by a space.
  3599. %F - Equivalent to "%Y-%m-%d" (the ISO 8601:2001 date format).
  3600. %G - The ISO 8601 week-based year [0001,9999]. The week-based year and
  3601. the Gregorian year can differ in the first week of January.
  3602. %h - Equivalent to %b (abbreviated month).
  3603. %H - Replaced by the 24 hour clock hour [00,23].
  3604. %I - Replaced by the 12 hour clock hour [01,12].
  3605. %J - Replaced by the nanosecond [0,999999999].
  3606. %j - Replaced by the day of the year [001,366].
  3607. %m - Replaced by the month number [01,12].
  3608. %M - Replaced by the minute [00,59].
  3609. %N - Replaced by the microsecond [0,999999]
  3610. %n - Replaced by a newline.
  3611. %p - Replaced by "AM" or "PM".
  3612. %P - Replaced by "am" or "pm".
  3613. %q - Replaced by the millisecond [0,999].
  3614. %r - Replaced by the time in AM/PM notation: "%I:%M:%S %p".
  3615. %R - Replaced by the time in 24 hour notation: "%H:%M".
  3616. %S - Replaced by the second [00,60].
  3617. %t - Replaced by a tab.
  3618. %T - Replaced by the time: "%H:%M:%S".
  3619. %u - Replaced by the weekday number, with 1 representing Monday [1,7].
  3620. %U - Replaced by the week number of the year [00,53]. The first Sunday
  3621. of January is the first day of week 1. Days before this are week 0.
  3622. %V - Replaced by the week number of the year with Monday as the first
  3623. day in the week [01,53]. If the week containing January 1st has 4
  3624. or more days in the new year, it is considered week 1. Otherwise,
  3625. it is the last week of the previous year, and the next week is 1.
  3626. %w - Replaced by the weekday number [0,6], with 0 representing Sunday.
  3627. %W - Replaced by the week number [00,53]. The first Monday of January
  3628. is the first day of week 1. Days before this are in week 0.
  3629. %x - Replaced by the locale's appropriate date representation.
  3630. %X - Replaced by the locale's appropriate time representation.
  3631. %y - Replaced by the last two digits of the year [00,99].
  3632. %Y - Replaced by the full four digit year [0001,9999].
  3633. %z - Replaced by the offset from UTC in the standard ISO 8601:2000
  3634. standard format (+hhmm or -hhmm), or by no characters if no
  3635. timezone is terminable. If the "is daylight saving" member of the
  3636. calendar structure is greater than zero, then the daylight saving
  3637. offset is used. If the dayslight saving member of the calendar
  3638. structure is negative, no characters are returned.
  3639. %Z - Replaced by the timezone name or abbreviation, or by no bytes if
  3640. no timezone information exists.
  3641. %% - Replaced by a literal '%'.
  3642. CalendarTime - Supplies a pointer to the calendar time value to use in the
  3643. substitution.
  3644. Return Value:
  3645. Returns the number of characters written to the output buffer, including
  3646. the null terminator.
  3647. --*/
  3648. RTL_API
  3649. UINTN
  3650. RtlFormatDateWide (
  3651. PWSTR StringBuffer,
  3652. ULONG StringBufferSize,
  3653. PWSTR Format,
  3654. PCALENDAR_TIME CalendarTime
  3655. );
  3656. /*++
  3657. Routine Description:
  3658. This routine converts the given calendar time into a wide string governed
  3659. by the given wide format string.
  3660. Arguments:
  3661. StringBuffer - Supplies a pointer where the converted wide string will be
  3662. returned, including the terminating null.
  3663. StringBufferSize - Supplies the size of the string buffer in characters.
  3664. Format - Supplies the wide format string to govern the conversion. Ordinary
  3665. characters in the format string will be copied verbatim to the output
  3666. string. Conversions will be substituted for their corresponding value
  3667. in the provided calendar time. The conversions are equivalent to the
  3668. non-wide format date function.
  3669. CalendarTime - Supplies a pointer to the calendar time value to use in the
  3670. substitution.
  3671. Return Value:
  3672. Returns the number of characters written to the output buffer, not
  3673. including the null terminator.
  3674. --*/
  3675. RTL_API
  3676. PSTR
  3677. RtlScanDate (
  3678. PCSTR StringBuffer,
  3679. PCSTR Format,
  3680. PCALENDAR_TIME CalendarTime
  3681. );
  3682. /*++
  3683. Routine Description:
  3684. This routine scans the given input string into values in the calendar time,
  3685. using the specified format.
  3686. Arguments:
  3687. StringBuffer - Supplies a pointer to the null terminated string to scan.
  3688. Format - Supplies the format string to govern the conversion. Ordinary
  3689. characters in the format string will be scanned verbatim from the input.
  3690. Whitespace characters in the format will cause all whitespace at the
  3691. current position in the input to be scanned. Conversions will be
  3692. scanned for their corresponding value in the provided calendar time.
  3693. Conversions start with a '%' character, followed by an optional E or O
  3694. character, followed by a conversion specifier. The conversion specifier
  3695. can take the following values:
  3696. %a - The day of the weekday name, either the full or abbreviated name.
  3697. %A - Equivalent to %a.
  3698. %b - The month name, either the full or abbreviated name.
  3699. %B - Equivalent to %b.
  3700. %c - Replaced by the locale's appropriate date and time representation.
  3701. %C - The year divided by 100 (century) [00,99].
  3702. %d - The day of the month [01,31].
  3703. %D - Equivalent to "%m/%d/%y".
  3704. %e - Equivalent to %d.
  3705. %h - Equivalent to %b (month name).
  3706. %H - The 24 hour clock hour [00,23].
  3707. %I - The 12 hour clock hour [01,12].
  3708. %J - Replaced by the nanosecond [0,999999999].
  3709. %j - The day of the year [001,366].
  3710. %m - The month number [01,12].
  3711. %M - The minute [00,59].
  3712. %N - The microsecond [0,999999]
  3713. %n - Any whitespace.
  3714. %p - The equivalent of "AM" or "PM".
  3715. %q - The millisecond [0,999].
  3716. %r - Replaced by the time in AM/PM notation: "%I:%M:%S %p".
  3717. %R - Replaced by the time in 24 hour notation: "%H:%M".
  3718. %S - The second [00,60].
  3719. %t - Any white space.
  3720. %T - Replaced by the time: "%H:%M:%S".
  3721. %u - Replaced by the weekday number, with 1 representing Monday [1,7].
  3722. %U - The week number of the year [00,53]. The first Sunday of January is
  3723. the first day of week 1. Days before this are week 0.
  3724. %w - The weekday number [0,6], with 0 representing Sunday.
  3725. %W - The week number [00,53]. The first Monday of January is the first
  3726. day of week 1. Days before this are in week 0.
  3727. %x - Replaced by the locale's appropriate date representation.
  3728. %X - Replaced by the locale's appropriate time representation.
  3729. %y - The last two digits of the year [00,99].
  3730. %Y - The full four digit year [0001,9999].
  3731. %% - Replaced by a literal '%'.
  3732. CalendarTime - Supplies a pointer to the calendar time value to place the
  3733. values in. Only the values that are scanned in are modified.
  3734. Return Value:
  3735. Returns the a pointer to the input string after the last character scanned.
  3736. NULL if the result coult not be scanned.
  3737. --*/
  3738. RTL_API
  3739. VOID
  3740. RtlInitializeTimeZoneSupport (
  3741. PTIME_ZONE_LOCK_FUNCTION AcquireTimeZoneLockFunction,
  3742. PTIME_ZONE_LOCK_FUNCTION ReleaseTimeZoneLockFunction,
  3743. PTIME_ZONE_REALLOCATE_FUNCTION ReallocateFunction
  3744. );
  3745. /*++
  3746. Routine Description:
  3747. This routine initializes library support functions needed by the time zone
  3748. code.
  3749. Arguments:
  3750. AcquireTimeZoneLockFunction - Supplies a pointer to the function called
  3751. to acquire access to the time zone data.
  3752. ReleaseTimeZoneLockFunction - Supplies a pointer to the function called to
  3753. relinquish access to the time zone data.
  3754. ReallocateFunction - Supplies a pointer to a function used to dynamically
  3755. allocate and free memory.
  3756. Return Value:
  3757. None.
  3758. --*/
  3759. RTL_API
  3760. KSTATUS
  3761. RtlFilterTimeZoneData (
  3762. PVOID TimeZoneData,
  3763. ULONG TimeZoneDataSize,
  3764. PCSTR TimeZoneName,
  3765. PVOID FilteredData,
  3766. PULONG FilteredDataSize
  3767. );
  3768. /*++
  3769. Routine Description:
  3770. This routine filters the given time zone data for one specific time zone.
  3771. Arguments:
  3772. TimeZoneData - Supplies a pointer to the buffer containing the unfiltered
  3773. time zone data.
  3774. TimeZoneDataSize - Supplies the size in bytes of the unfiltered time zone
  3775. data.
  3776. TimeZoneName - Supplies a pointer to the null terminated string containing
  3777. the name of the time zone to retrieve.
  3778. FilteredData - Supplies an optional pointer to the buffer where the
  3779. filtered data will be returned. If this pointer is NULL, then only the
  3780. size of the required data will be returned.
  3781. FilteredDataSize - Supplies a pointer that on input contains the size of
  3782. the filtered data buffer. On output, will return the required size of
  3783. the output buffer to contain the filtered data.
  3784. Return Value:
  3785. STATUS_SUCCESS on success.
  3786. STATUS_BUFFER_TOO_SMALL if the provided buffer was valid but too small.
  3787. STATUS_FILE_CORRUPT if the data is invalid.
  3788. --*/
  3789. RTL_API
  3790. KSTATUS
  3791. RtlGetTimeZoneData (
  3792. PVOID Data,
  3793. PULONG DataSize
  3794. );
  3795. /*++
  3796. Routine Description:
  3797. This routine copies the current time zone data into the given buffer.
  3798. Arguments:
  3799. Data - Supplies a pointer where the current time zone data will be copied
  3800. to.
  3801. DataSize - Supplies a pointer that on input contains the size of the
  3802. supplied data buffer. On output, will contain the size of the
  3803. current data (whether or not a buffer was supplied).
  3804. Return Value:
  3805. STATUS_SUCCESS if the time zone data was accepted.
  3806. STATUS_BUFFER_TOO_SMALL if the provided buffer was valid but too small.
  3807. STATUS_NO_DATA_AVAILABLE if there is no data or the data is empty.
  3808. --*/
  3809. RTL_API
  3810. KSTATUS
  3811. RtlSetTimeZoneData (
  3812. PVOID Data,
  3813. ULONG DataSize,
  3814. PCSTR ZoneName,
  3815. PVOID *OldData,
  3816. PULONG OldDataSize,
  3817. PSTR OriginalZoneBuffer,
  3818. PULONG OriginalZoneBufferSize
  3819. );
  3820. /*++
  3821. Routine Description:
  3822. This routine sets the current time zone data.
  3823. Arguments:
  3824. Data - Supplies a pointer to the time zone data to set. No copy will be
  3825. made, the caller must ensure the data is not modified or freed until
  3826. another call to set time zone data completes.
  3827. DataSize - Supplies the size of the data in bytes.
  3828. ZoneName - Supplies an optional pointer to the name of a time zone to
  3829. select within the data. If this pointer is NULL, the first time zone
  3830. in the data will be used.
  3831. OldData - Supplies a pointer where the original (now decommissioned) time
  3832. zone data will be returned.
  3833. OldDataSize - Supplies a pointer where the size of the original
  3834. decommissioned data will be returned.
  3835. OriginalZoneBuffer - Supplies an optional pointer where the original (or
  3836. current if no new time zone was provided) time zone will be returned.
  3837. OriginalZoneBufferSize - Supplies a pointer that on input contains the
  3838. size of the original zone buffer in bytes. On output, this value will
  3839. contain the size of the original zone buffer needed to contain the
  3840. name of the current time zone (even if no buffer was provided).
  3841. Return Value:
  3842. STATUS_SUCCESS if the time zone data was accepted.
  3843. STATUS_FILE_CORRUPT if the data is invalid.
  3844. STATUS_NOT_FOUND if the selected time zone could not be found in the new
  3845. data. If this is the case, the new data will not be activated.
  3846. --*/
  3847. RTL_API
  3848. KSTATUS
  3849. RtlListTimeZones (
  3850. PVOID Data,
  3851. ULONG DataSize,
  3852. PSTR ListBuffer,
  3853. PULONG ListBufferSize
  3854. );
  3855. /*++
  3856. Routine Description:
  3857. This routine creates a list of all time zones available in the given (or
  3858. currently in use) data.
  3859. Arguments:
  3860. Data - Supplies a pointer to the time zone data to debug print. If this
  3861. is NULL, the current data will be used.
  3862. DataSize - Supplies the size of the data in bytes.
  3863. ListBuffer - Supplies an optional pointer to a buffer where the null
  3864. terminated strings representing the names of the time zones will be
  3865. returned on success. The buffer will be terminated by an empty string.
  3866. ListBufferSize - Supplies a pointer that on input contains the size of the
  3867. list buffer in bytes. On output this will contain the size needed to
  3868. hold all the strings, regardless of whether a buffer was passed in.
  3869. Return Value:
  3870. STATUS_SUCCESS on success.
  3871. STATUS_BUFFER_TOO_SMALL if the provided buffer was too small.
  3872. STATUS_FILE_CORRUPT if the time zone data was not valid.
  3873. STATUS_NO_DATA_AVAILABLE if there is no data or the data is empty.
  3874. --*/
  3875. RTL_API
  3876. VOID
  3877. RtlGetTimeZoneNames (
  3878. PCSTR *StandardName,
  3879. PCSTR *DaylightName,
  3880. PLONG StandardGmtOffset,
  3881. PLONG DaylightGmtOffset
  3882. );
  3883. /*++
  3884. Routine Description:
  3885. This routine returns the names of the currently selected time zone.
  3886. Arguments:
  3887. StandardName - Supplies an optional pointer where a pointer to the standard
  3888. time zone name will be returned on success. The caller must not modify
  3889. this memory, and it may change if the time zone is changed.
  3890. DaylightName - Supplies an optional pointer where a pointer to the Daylight
  3891. Saving time zone name will be returned on success. The caller must not
  3892. modify this memory, and it may change if the time zone is changed.
  3893. StandardGmtOffset - Supplies an optional pointer where the offset from GMT
  3894. in seconds will be returned for the time zone.
  3895. DaylightGmtOffset - Supplies an optional pointer where the offset from GMT
  3896. in seconds during Daylight Saving will be returned.
  3897. Return Value:
  3898. None.
  3899. --*/
  3900. RTL_API
  3901. KSTATUS
  3902. RtlSelectTimeZone (
  3903. PSTR ZoneName,
  3904. PSTR OriginalZoneBuffer,
  3905. PULONG OriginalZoneBufferSize
  3906. );
  3907. /*++
  3908. Routine Description:
  3909. This routine selects a time zone from the current set of data.
  3910. Arguments:
  3911. ZoneName - Supplies an optional pointer to a null terminated string
  3912. containing the name of the time zone. If this parameter is NULL then
  3913. the current time zone will simply be returned.
  3914. OriginalZoneBuffer - Supplies an optional pointer where the original (or
  3915. current if no new time zone was provided) time zone will be returned.
  3916. OriginalZoneBufferSize - Supplies a pointer that on input contains the
  3917. size of the original zone buffer in bytes. On output, this value will
  3918. contain the size of the original zone buffer needed to contain the
  3919. name of the current time zone (even if no buffer was provided).
  3920. Return Value:
  3921. STATUS_SUCCESS on success.
  3922. STATUS_NOT_FOUND if a time zone with the given name could not be found.
  3923. STATUS_NO_DATA_AVAILABLE if no time zone data has been set yet.
  3924. STATUS_BUFFER_TOO_SMALL if the buffer provided to get the original time
  3925. zone name was too small. If this is the case, the new time zone will
  3926. not have been set.
  3927. --*/
  3928. RTL_API
  3929. KSTATUS
  3930. RtlSystemTimeToLocalCalendarTime (
  3931. PSYSTEM_TIME SystemTime,
  3932. PCALENDAR_TIME CalendarTime
  3933. );
  3934. /*++
  3935. Routine Description:
  3936. This routine converts the given system time into calendar time in the
  3937. current local time zone.
  3938. Arguments:
  3939. SystemTime - Supplies a pointer to the system time to convert.
  3940. CalendarTime - Supplies a pointer to the calendar time to initialize based
  3941. on the given system time.
  3942. Return Value:
  3943. STATUS_SUCCESS on success.
  3944. STATUS_OUT_OF_BOUNDS if the given system time is too funky.
  3945. --*/
  3946. RTL_API
  3947. KSTATUS
  3948. RtlLocalCalendarTimeToSystemTime (
  3949. PCALENDAR_TIME CalendarTime,
  3950. PSYSTEM_TIME SystemTime
  3951. );
  3952. /*++
  3953. Routine Description:
  3954. This routine converts the given calendar time, assumed to be a local date
  3955. and time, into its corresponding system time. On success, this routine will
  3956. update the supplied calendar time to fill out all fields. The GMT offset
  3957. of the supplied calendar time will be ignored in favor or the local time
  3958. zone's GMT offset.
  3959. Arguments:
  3960. CalendarTime - Supplies a pointer to the local calendar time to convert.
  3961. SystemTime - Supplies a pointer where the system time will be returned.
  3962. Return Value:
  3963. STATUS_SUCCESS on success.
  3964. STATUS_OUT_OF_BOUNDS if the given local calendar time is too funky.
  3965. --*/
  3966. RTL_API
  3967. VOID
  3968. RtlDebugPrintTimeZoneData (
  3969. PVOID Data,
  3970. ULONG DataSize
  3971. );
  3972. /*++
  3973. Routine Description:
  3974. This routine debug prints the given time zone data.
  3975. Arguments:
  3976. Data - Supplies a pointer to the time zone data to debug print. If this
  3977. is NULL, the current data will be used.
  3978. DataSize - Supplies the size of the data in bytes.
  3979. Return Value:
  3980. None.
  3981. --*/
  3982. RTL_API
  3983. VOID
  3984. RtlHeapInitialize (
  3985. PMEMORY_HEAP Heap,
  3986. PHEAP_ALLOCATE AllocateFunction,
  3987. PHEAP_FREE FreeFunction,
  3988. PHEAP_CORRUPTION_ROUTINE CorruptionFunction,
  3989. UINTN MinimumExpansionSize,
  3990. UINTN ExpansionGranularity,
  3991. UINTN AllocationTag,
  3992. ULONG Flags
  3993. );
  3994. /*++
  3995. Routine Description:
  3996. This routine initializes a memory heap. It does not initialize emergency
  3997. resources.
  3998. Arguments:
  3999. Heap - Supplies the heap to initialize.
  4000. AllocateFunction - Supplies a pointer to a function the heap calls when it
  4001. wants to expand and needs more memory.
  4002. FreeFunction - Supplies a pointer to a function the heap calls when it
  4003. wants to free a previously allocated segment.
  4004. CorruptionFunction - Supplies a pointer to a function to call if heap
  4005. corruption is detected.
  4006. MinimumExpansionSize - Supplies the minimum number of bytes to request
  4007. when expanding the heap.
  4008. ExpansionGranularity - Supplies the granularity of expansions, in bytes.
  4009. This must be a power of two.
  4010. AllocationTag - Supplies the magic number to put in each allocation. This
  4011. is also the tag supplied when the allocation function above is called.
  4012. Flags - Supplies a bitfield of flags governing the heap's behavior. See
  4013. MEMORY_HEAP_FLAG_* definitions.
  4014. Return Value:
  4015. None.
  4016. --*/
  4017. RTL_API
  4018. VOID
  4019. RtlHeapDestroy (
  4020. PMEMORY_HEAP Heap
  4021. );
  4022. /*++
  4023. Routine Description:
  4024. This routine destroys a memory heap, releasing all resources it was
  4025. managing. The structure itself is owned by the caller, so that isn't freed.
  4026. Arguments:
  4027. Heap - Supplies the heap to destroy.
  4028. Return Value:
  4029. None. The heap and all its allocations are no longer usable.
  4030. --*/
  4031. RTL_API
  4032. PVOID
  4033. RtlHeapAllocate (
  4034. PMEMORY_HEAP Heap,
  4035. UINTN Size,
  4036. UINTN Tag
  4037. );
  4038. /*++
  4039. Routine Description:
  4040. This routine allocates memory from a given heap.
  4041. Arguments:
  4042. Heap - Supplies the heap to allocate from.
  4043. Size - Supplies the size of the allocation request, in bytes.
  4044. Tag - Supplies an identification tag to mark this allocation with.
  4045. Return Value:
  4046. Returns a pointer to the allocation if successful, or NULL if the
  4047. allocation failed.
  4048. --*/
  4049. RTL_API
  4050. PVOID
  4051. RtlHeapReallocate (
  4052. PMEMORY_HEAP Heap,
  4053. PVOID Memory,
  4054. UINTN NewSize,
  4055. UINTN AllocationTag
  4056. );
  4057. /*++
  4058. Routine Description:
  4059. This routine resizes the given allocation, potentially creating a new
  4060. buffer and copying the old contents in.
  4061. Arguments:
  4062. Heap - Supplies a pointer to the heap to work with.
  4063. Memory - Supplies the original active allocation. If this parameter is
  4064. NULL, this routine will simply allocate memory.
  4065. NewSize - Supplies the new required size of the allocation. If this is
  4066. 0, then the original allocation will simply be freed.
  4067. AllocationTag - Supplies an identifier for this allocation.
  4068. Return Value:
  4069. Returns a pointer to a buffer with the new size (and original contents) on
  4070. success. This may be a new buffer or the same one.
  4071. NULL on failure or if the new size supplied was zero.
  4072. --*/
  4073. RTL_API
  4074. KSTATUS
  4075. RtlHeapAlignedAllocate (
  4076. PMEMORY_HEAP Heap,
  4077. PVOID *Memory,
  4078. UINTN Alignment,
  4079. UINTN Size,
  4080. UINTN Tag
  4081. );
  4082. /*++
  4083. Routine Description:
  4084. This routine allocates aligned memory from a given heap.
  4085. Arguments:
  4086. Heap - Supplies the heap to allocate from.
  4087. Memory - Supplies a pointer that receives the pointer to the aligned
  4088. allocation on success.
  4089. Alignment - Supplies the requested alignment for the allocation, in bytes.
  4090. Size - Supplies the size of the allocation request, in bytes.
  4091. Tag - Supplies an identification tag to mark this allocation with.
  4092. Return Value:
  4093. Status code.
  4094. --*/
  4095. RTL_API
  4096. VOID
  4097. RtlHeapFree (
  4098. PMEMORY_HEAP Heap,
  4099. PVOID Memory
  4100. );
  4101. /*++
  4102. Routine Description:
  4103. This routine frees memory, making it available for other users in the heap.
  4104. This routine may potentially contract the heap periodically.
  4105. Arguments:
  4106. Heap - Supplies the heap to free the memory back to.
  4107. Memory - Supplies the allocation created by the heap allocation routine.
  4108. Return Value:
  4109. None.
  4110. --*/
  4111. RTL_API
  4112. VOID
  4113. RtlHeapProfilerGetStatistics (
  4114. PMEMORY_HEAP Heap,
  4115. PVOID Buffer,
  4116. ULONG BufferSize
  4117. );
  4118. /*++
  4119. Routine Description:
  4120. This routine fills the given buffer with the current heap statistics.
  4121. Arguments:
  4122. Heap - Supplies a pointer to the heap.
  4123. Buffer - Supplies the buffer to fill with heap statistics.
  4124. BufferSize - Supplies the size of the buffer.
  4125. Return Value:
  4126. None.
  4127. --*/
  4128. RTL_API
  4129. VOID
  4130. RtlHeapDebugPrintStatistics (
  4131. PMEMORY_HEAP Heap
  4132. );
  4133. /*++
  4134. Routine Description:
  4135. This routine prints current heap statistics to the debugger.
  4136. Arguments:
  4137. Heap - Supplies a pointer to the heap to print.
  4138. Return Value:
  4139. None.
  4140. --*/
  4141. RTL_API
  4142. VOID
  4143. RtlValidateHeap (
  4144. PMEMORY_HEAP Heap,
  4145. PHEAP_CORRUPTION_ROUTINE CorruptionRoutine
  4146. );
  4147. /*++
  4148. Routine Description:
  4149. This routine validates a memory heap for consistency, ensuring that no
  4150. corruption or other errors are present in the heap.
  4151. Arguments:
  4152. Heap - Supplies a pointer to the heap to validate.
  4153. CorruptionRoutine - Supplies an optional pointer to a routine to call if
  4154. corruption is detected. If not supplied, the internal one supplied when
  4155. the heap was initialized will be used.
  4156. Return Value:
  4157. None.
  4158. --*/
  4159. RTL_API
  4160. ULONG
  4161. RtlGetSystemVersionString (
  4162. PSYSTEM_VERSION_INFORMATION VersionInformation,
  4163. SYSTEM_VERSION_STRING_VERBOSITY Level,
  4164. PCHAR Buffer,
  4165. ULONG BufferSize
  4166. );
  4167. /*++
  4168. Routine Description:
  4169. This routine gets the system string.
  4170. Arguments:
  4171. VersionInformation - Supplies a pointer to the initialized version
  4172. information to convert to a string.
  4173. Level - Supplies the level of detail to print.
  4174. Buffer - Supplies a pointer to the buffer that receives the version
  4175. information.
  4176. BufferSize - Supplies the size of the supplied buffer in bytes.
  4177. Return Value:
  4178. Returns the size of the string as written to the buffer, including the
  4179. null terminator.
  4180. --*/
  4181. RTL_API
  4182. PSTR
  4183. RtlGetReleaseLevelString (
  4184. SYSTEM_RELEASE_LEVEL Level
  4185. );
  4186. /*++
  4187. Routine Description:
  4188. This routine returns a string corresponding with the given release level.
  4189. Arguments:
  4190. Level - Supplies the release level.
  4191. Return Value:
  4192. Returns a pointer to a static the string describing the given release
  4193. level. The caller should not attempt to modify or free this memory.
  4194. --*/
  4195. RTL_API
  4196. PSTR
  4197. RtlGetBuildDebugLevelString (
  4198. SYSTEM_BUILD_DEBUG_LEVEL Level
  4199. );
  4200. /*++
  4201. Routine Description:
  4202. This routine returns a string corresponding with the given build debug
  4203. level.
  4204. Arguments:
  4205. Level - Supplies the build debug level.
  4206. Return Value:
  4207. Returns a pointer to a static the string describing the given build debug
  4208. level. The caller should not attempt to modify or free this memory.
  4209. --*/