123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444 |
- /*++
- Copyright (c) 2012 Minoca Corp.
- This file is licensed under the terms of the GNU General Public License
- version 3. Alternative licensing terms are available. Contact
- info@minocacorp.com for details. See the LICENSE file at the root of this
- project for complete licensing information.
- Module Name:
- rtl.h
- Abstract:
- This header contains definitions for the common kernel runtime library.
- Author:
- Evan Green 24-Jul-2012
- --*/
- //
- // ------------------------------------------------------------------- Includes
- //
- #include <stdarg.h>
- //
- // --------------------------------------------------------------------- Macros
- //
- //
- // This macro reads a 64 bit value on a 32 bit processor whose value is updated
- // asynchronously. The value must be updated with the equivalent write macro.
- // The first argument is a pointer to the INT64_SYNC structure, and the second
- // is the address of the result to write it in to.
- //
- #define READ_INT64_SYNC(_Pointer, _Result) \
- do { \
- *(volatile ULONGLONG *)(_Result) = \
- (ULONGLONG)((_Pointer)->High1) << 32; \
- \
- *(volatile ULONGLONG *)(_Result) |= (ULONGLONG)((_Pointer)->Low); \
- \
- } while ((_Pointer)->High2 != (*(_Result) >> 32));
- //
- // This macro writes a 64 bit value on a 32 bit processor where readers are
- // simultaneously reading it. It updates the first high value, then the low
- // value, then the second high value to ensure that readers cannot observe a
- // torn read. The first parameter is a pointer to the INT64_SYNC structure,
- // the second parameter is the value to write.
- //
- #define WRITE_INT64_SYNC(_Pointer, _Value) \
- (_Pointer)->High1 = (ULONGLONG)(_Value) >> 32; \
- (_Pointer)->Low = (ULONG)(_Value); \
- (_Pointer)->High2 = (ULONGLONG)(_Value) >> 32; \
- //
- // This macro determines if the given year is a leap year. There's a leap year
- // every 4 years, except there's not a leap year every 100 years, except
- // there is a leap year every 400 years. Fun stuff.
- //
- #define IS_LEAP_YEAR(_Year) \
- ((((_Year) % 4) == 0) && ((((_Year) % 100) != 0) || (((_Year) % 400) == 0)))
- //
- // Character classification definitions
- //
- //
- // This macro returns non-zero if the given character is an upper case
- // character.
- //
- #define RtlIsCharacterUpperCase(_Character) \
- (((_Character) >= 'A') && ((_Character) <= 'Z'))
- //
- // This macro returns non-zero if the given character is a lower case character.
- //
- #define RtlIsCharacterLowerCase(_Character) \
- (((_Character) >= 'a') && ((_Character) <= 'z'))
- //
- // This macro returns non-zero if the given character is a digit.
- //
- #define RtlIsCharacterDigit(_Character) \
- (((_Character) >= '0') && ((_Character) <= '9'))
- //
- // This macro returns non-zero if the given character is in the alphabet.
- //
- #define RtlIsCharacterAlphabetic(_Character) \
- ((RtlIsCharacterUpperCase(_Character) || \
- RtlIsCharacterLowerCase(_Character)))
- //
- // This macro returns non-zero if the given character is alpha-numeric.
- //
- #define RtlIsCharacterAlphanumeric(_Character) \
- ((RtlIsCharacterAlphabetic(_Character) || RtlIsCharacterDigit(_Character)))
- //
- // This macro returns non-zero if the given character is in the ASCII character
- // set.
- //
- #define RtlIsCharacterAscii(_Character) (((_Character) & (~0x7F)) == 0)
- //
- // This macro returns non-zero if the given character is a blank character.
- //
- #define RtlIsCharacterBlank(_Character) \
- (((_Character) == ' ') || ((_Character) == '\t'))
- //
- // This macro returns non-zero if the given character is a control character.
- //
- #define RtlIsCharacterControl(_Character) \
- (((_Character) < ' ') || ((_Character) == 0x7F))
- //
- // This macro returns non-zero if the given character is whitespace.
- //
- #define RtlIsCharacterSpace(_Character) \
- (((_Character) == ' ') || ((_Character) == '\t') || \
- ((_Character) == '\n') || ((_Character) == '\r') || \
- ((_Character) == '\f') || ((_Character) == '\v'))
- //
- // This macro returns non-zero if the given character is a hexadecimal digit.
- //
- #define RtlIsCharacterHexDigit(_Character) \
- ((((_Character) >= '0') && ((_Character) <= '9')) || \
- (((_Character) >= 'A') && ((_Character) <= 'F')) || \
- (((_Character) >= 'a') && ((_Character) <= 'f')))
- //
- // This macro returns non-zero if the given character is punctuation.
- //
- #define RtlIsCharacterPunctuation(_Character) \
- ((RtlIsCharacterPrintable(_Character)) && \
- (!RtlIsCharacterAlphanumeric(_Character)) && \
- ((_Character) != ' '))
- //
- // This macro returns non-zero if the given character is a graphical character.
- //
- #define RtlIsCharacterGraphical(_Character) \
- ((RtlIsCharacterAlphanumeric(_Character)) || \
- (RtlIsCharacterPunctuation(_Character)))
- //
- // This macro returns non-zero if the given character is a printable character.
- //
- #define RtlIsCharacterPrintable(_Character) \
- ((RtlIsCharacterAlphanumeric(_Character)) || \
- (RtlIsCharacterPunctuation(_Character)) || \
- ((_Character) == ' '))
- //
- // This macro converts the given character into an ASCII character.
- //
- #define RtlConvertCharacterToAscii(_Character) ((_Character) & 0x7F)
- //
- // This macro converts the given character into a lower case character.
- //
- #define RtlConvertCharacterToLowerCase(_Character) \
- (RtlIsCharacterUpperCase(_Character) ? ((_Character) | 0x20) : (_Character))
- //
- // This macro converts the given character into an upper case character.
- //
- #define RtlConvertCharacterToUpperCase(_Character) \
- (RtlIsCharacterLowerCase(_Character) ? \
- ((_Character) & (~0x20)) : (_Character))
- //
- // Wide character classification definitions
- //
- //
- // This macro returns non-zero if the given character is an upper case
- // character.
- //
- #define RtlIsCharacterUpperCaseWide(_Character) \
- (((_Character) >= L'A') && ((_Character) <= L'Z'))
- //
- // This macro returns non-zero if the given character is a lower case character.
- //
- #define RtlIsCharacterLowerCaseWide(_Character) \
- (((_Character) >= L'a') && ((_Character) <= L'z'))
- //
- // This macro returns non-zero if the given character is a digit.
- //
- #define RtlIsCharacterDigitWide(_Character) \
- (((_Character) >= L'0') && ((_Character) <= L'9'))
- //
- // This macro returns non-zero if the given character is in the alphabet.
- //
- #define RtlIsCharacterAlphabeticWide(_Character) \
- ((RtlIsCharacterUpperCaseWide(_Character) || \
- RtlIsCharacterLowerCaseWide(_Character)))
- //
- // This macro returns non-zero if the given character is alpha-numeric.
- //
- #define RtlIsCharacterAlphanumericWide(_Character) \
- ((RtlIsCharacterAlphabeticWide(_Character) || \
- RtlIsCharacterDigitWide(_Character)))
- //
- // This macro returns non-zero if the given character is in the ASCII character
- // set.
- //
- #define RtlIsCharacterAsciiWide(_Character) (((_Character) & (~0x7F)) == 0)
- //
- // This macro returns non-zero if the given character is a blank character.
- //
- #define RtlIsCharacterBlankWide(_Character) \
- (((_Character) == L' ') || ((_Character) == L'\t'))
- //
- // This macro returns non-zero if the given character is a control character.
- //
- #define RtlIsCharacterControlWide(_Character) \
- (((_Character) < L' ') || ((_Character) == 0x7F))
- //
- // This macro returns non-zero if the given character is whitespace.
- //
- #define RtlIsCharacterSpaceWide(_Character) \
- (((_Character) == L' ') || ((_Character) == L'\t') || \
- ((_Character) == L'\n') || ((_Character) == L'\r') || \
- ((_Character) == L'\f') || ((_Character) == L'\v'))
- //
- // This macro returns non-zero if the given character is a hexadecimal digit.
- //
- #define RtlIsCharacterHexDigitWide(_Character) \
- ((((_Character) >= L'0') && ((_Character) <= L'9')) || \
- (((_Character) >= L'A') && ((_Character) <= L'F')) || \
- (((_Character) >= L'a') && ((_Character) <= L'f')))
- //
- // This macro returns non-zero if the given character is punctuation.
- //
- #define RtlIsCharacterPunctuationWide(_Character) \
- ((RtlIsCharacterPrintableWide(_Character)) && \
- (!RtlIsCharacterAlphanumericWide(_Character)) && \
- ((_Character) != L' '))
- //
- // This macro returns non-zero if the given character is a graphical character.
- //
- #define RtlIsCharacterGraphicalWide(_Character) \
- ((RtlIsCharacterAlphanumericWide(_Character)) || \
- (RtlIsCharacterPunctuationWide(_Character)))
- //
- // This macro returns non-zero if the given character is a printable character.
- //
- #define RtlIsCharacterPrintableWide(_Character) \
- ((RtlIsCharacterAlphanumericWide(_Character)) || \
- (RtlIsCharacterPunctuationWide(_Character)) || \
- ((_Character) == L' '))
- //
- // This macro converts the given character into an ASCII character.
- //
- #define RtlConvertCharacterToAsciiWide(_Character) ((_Character) & 0x7F)
- //
- // This macro converts the given character into a lower case character.
- //
- #define RtlConvertCharacterToLowerCaseWide(_Character) \
- (RtlIsCharacterUpperCaseWide(_Character) ? \
- ((_Character) | 0x20) : (_Character))
- //
- // This macro converts the given character into an upper case character.
- //
- #define RtlConvertCharacterToUpperCaseWide(_Character) \
- (RtlIsCharacterLowerCaseWide(_Character) ? \
- ((_Character) & (~0x20)) : (_Character))
- //
- // ---------------------------------------------------------------- Definitions
- //
- #ifndef RTL_API
- #define RTL_API __DLLIMPORT
- #endif
- #define STRING_TERMINATOR '\0'
- #define WIDE_STRING_TERMINATOR L'\0'
- //
- // Define the maximum number of bytes in a multibyte character.
- //
- #define MULTIBYTE_MAX 16
- //
- // Define the number of characters in the scan unput buffer. This must be as
- // large as both a DOUBLE_SCAN_STRING_SIZE and MULTIBYTE_MAX.
- //
- #define SCANNER_UNPUT_SIZE 16
- //
- // Defines the length of a string printing a UUID, not including the NULL
- // terminator.
- //
- #define UUID_STRING_LENGTH 37
- //
- // Define time unit constants.
- //
- #define NANOSECONDS_PER_SECOND 1000000000ULL
- #define MICROSECONDS_PER_SECOND 1000000ULL
- #define MILLISECONDS_PER_SECOND 1000ULL
- #define MICROSECONDS_PER_MILLISECOND 1000ULL
- #define NANOSECONDS_PER_MICROSECOND 1000ULL
- #define NANOSECONDS_PER_MILLISECOND 1000000ULL
- //
- // Define some constants used for manipulating float types.
- //
- #define FLOAT_SIGN_BIT 0x80000000
- #define FLOAT_SIGN_BIT_SHIFT 31
- #define FLOAT_NAN 0x7F800000
- #define FLOAT_NAN_EXPONENT 0xFF
- #define FLOAT_VALUE_MASK 0x007FFFFFUL
- #define FLOAT_EXPONENT_MASK 0x7F800000UL
- #define FLOAT_EXPONENT_SHIFT 23
- #define FLOAT_EXPONENT_BIAS 0x7F
- #define FLOAT_ONE_WORD 0x3F800000
- #define FLOAT_TRUNCATE_VALUE_MASK 0xFFFFF000
- //
- // Define some constants used for manipulating double floating point types.
- //
- #define DOUBLE_SIGN_BIT 0x8000000000000000ULL
- #define DOUBLE_SIGN_BIT_SHIFT 63
- #define DOUBLE_EXPONENT_MASK 0x7FF0000000000000ULL
- #define DOUBLE_EXPONENT_SHIFT 52
- #define DOUBLE_EXPONENT_BIAS 0x3FF
- #define DOUBLE_NAN_EXPONENT 0x7FF
- #define DOUBLE_VALUE_MASK 0x000FFFFFFFFFFFFFULL
- #define DOUBLE_HIGH_WORD_SHIFT (sizeof(ULONG) * BITS_PER_BYTE)
- #define DOUBLE_SIGNIFICAND_HEX_DIGITS 13
- #define DOUBLE_ONE_HIGH_WORD 0x3FF00000
- #define DOUBLE_HIGH_VALUE_MASK 0x000FFFFF
- #define NAN_HIGH_WORD 0x7FF00000
- //
- // Define macros to functions that will work on the native integer size of the
- // processors.
- //
- #if defined(__amd64)
- #define RtlAtomicExchange(_Pointer, _Value) \
- RtlAtomicExchange64((PULONGLONG)(_Pointer), (_Value))
- #define RtlAtomicCompareExchange(_Pointer, _Exchange, _Compare) \
- RtlAtomicCompareExchange64((PULONGLONG)(_Pointer), \
- (_Exchange), \
- (_Compare))
- #define RtlAtomicAdd(_Pointer, _Value) \
- RtlAtomicAdd64((PULONGLONG)(_Pointer), (_Value))
- #define RtlAtomicOr(_Pointer, _Value) \
- RtlAtomicAdd64((PULONGLONG)(_Pointer), (_Value))
- #define RtlCountLeadingZeros RtlCountLeadingZeros64
- #define RtlCountTrailingZeros RtlCountTrailingZeros64
- #else
- #define RtlAtomicExchange(_Pointer, _Value) \
- RtlAtomicExchange32((PULONG)(_Pointer), (_Value))
- #define RtlAtomicCompareExchange(_Pointer, _Exchange, _Compare) \
- RtlAtomicCompareExchange32((PULONG)(_Pointer), \
- (_Exchange), \
- (_Compare))
- #define RtlAtomicAdd(_Pointer, _Value) \
- RtlAtomicAdd32((PULONG)(_Pointer), (_Value))
- #define RtlAtomicOr(_Pointer, _Value) \
- RtlAtomicAdd32((PULONG)(_Pointer), (_Value))
- #define RtlCountLeadingZeros RtlCountLeadingZeros32
- #define RtlCountTrailingZeros RtlCountTrailingZeros32
- #endif
- #define DOUBLE_SCAN_STRING_SIZE 8
- //
- // Define some time constants.
- //
- #define SECONDS_PER_DAY (SECONDS_PER_HOUR * HOURS_PER_DAY)
- #define SECONDS_PER_HOUR (SECONDS_PER_MINUTE * MINUTES_PER_HOUR)
- #define SECONDS_PER_MINUTE 60
- #define MINUTES_PER_HOUR 60
- #define HOURS_PER_DAY 24
- #define DAYS_PER_WEEK 7
- #define DAYS_PER_YEAR 365
- #define DAYS_PER_LEAP_YEAR 366
- #define MONTHS_PER_YEAR 12
- #define YEARS_PER_CENTURY 100
- #define TIME_ZONE_ABBREVIATION_SIZE 5
- //
- // Define the difference between the system time epoch, January 1, 2001, and
- // the standard C library epoch, January 1, 1970.
- //
- #define SYSTEM_TIME_TO_EPOCH_DELTA (978307200LL)
- //
- // Define memory heap flags.
- //
- //
- // Set this flag to enable allocation tag statistics collection.
- //
- #define MEMORY_HEAP_FLAG_COLLECT_TAG_STATISTICS 0x00000001
- //
- // Set this flag to validate the heap periodically.
- //
- #define MEMORY_HEAP_FLAG_PERIODIC_VALIDATION 0x00000002
- //
- // Set this flag to disallow partial frees of underlying regions the heap has
- // allocated. Normally the heap assumes an interface where the heap can
- // allocate a bunch of memory and then free it in piecemeal if it likes.
- // Setting this flag forces the heap to only free complete areas it has
- // allocated.
- //
- #define MEMORY_HEAP_FLAG_NO_PARTIAL_FREES 0x00000004
- //
- // Define the number of small bins to use in the memory heap. Each bin holds
- // chunks with equal sizes, spaced 8 apart, less than HEAP_MIN_LARGE_SIZE
- // bytes.
- //
- #define HEAP_SMALL_BIN_COUNT 32U
- //
- // Define the number of heap bins to use in the heap. Each bin contains the
- // root of a tree holding a range of sizes. There are 2 equally spaced tree
- // bins for each power of two from HEAP_TREE_SHIFT to HEAP_TREE_SHIFT + 16. The
- // last bin holds anything larger.
- //
- #define HEAP_TREE_BIN_COUNT 32U
- //
- // Define Red-Black tree flags.
- //
- #define RED_BLACK_TREE_FLAG_PERIODIC_VALIDATION 0x00000001
- //
- // ------------------------------------------------------ Data Type Definitions
- //
- typedef enum _COMPARISON_RESULT {
- ComparisonResultInvalid,
- ComparisonResultSame,
- ComparisonResultAscending,
- ComparisonResultDescending,
- } COMPARISON_RESULT, *PCOMPARISON_RESULT;
- typedef enum _CHARACTER_ENCODING {
- CharacterEncodingDefault,
- CharacterEncodingAscii,
- CharacterEncodingMax
- } CHARACTER_ENCODING, *PCHARACTER_ENCODING;
- typedef enum _HEAP_CORRUPTION_CODE {
- HeapCorruptionInvalid,
- HeapCorruptionBufferOverrun,
- HeapCorruptionDoubleFree,
- HeapCorruptionCorruptStructures,
- HeapCorruptionDoubleDestroy
- } HEAP_CORRUPTION_CODE, *PHEAP_CORRUPTION_CODE;
- //
- // TODO: Make this just an integer on x64.
- //
- typedef struct _INT64_SYNC {
- volatile ULONG High1;
- volatile ULONG Low;
- volatile ULONG High2;
- } INT64_SYNC, *PINT64_SYNC;
- typedef struct _RED_BLACK_TREE_NODE RED_BLACK_TREE_NODE, *PRED_BLACK_TREE_NODE;
- typedef struct _RED_BLACK_TREE RED_BLACK_TREE, *PRED_BLACK_TREE;
- typedef
- COMPARISON_RESULT
- (*PCOMPARE_RED_BLACK_TREE_NODES) (
- PRED_BLACK_TREE Tree,
- PRED_BLACK_TREE_NODE FirstNode,
- PRED_BLACK_TREE_NODE SecondNode
- );
- /*++
- Routine Description:
- This routine compares two Red-Black tree nodes.
- Arguments:
- Tree - Supplies a pointer to the Red-Black tree that owns both nodes.
- FirstNode - Supplies a pointer to the left side of the comparison.
- SecondNode - Supplies a pointer to the second side of the comparison.
- Return Value:
- Same if the two nodes have the same value.
- Ascending if the first node is less than the second node.
- Descending if the second node is less than the first node.
- --*/
- typedef
- VOID
- (*PRED_BLACK_TREE_ITERATION_ROUTINE) (
- PRED_BLACK_TREE Tree,
- PRED_BLACK_TREE_NODE Node,
- ULONG Level,
- PVOID Context
- );
- /*++
- Routine Description:
- This routine is called once for each node in the tree (via an in order
- traversal). It assumes that the tree will not be modified during the
- traversal.
- Arguments:
- Tree - Supplies a pointer to the tree being enumerated.
- Node - Supplies a pointer to the node.
- Level - Supplies the depth into the tree that this node exists at. 0 is
- the root.
- Context - Supplies an optional opaque pointer of context that was provided
- when the iteration was requested.
- Return Value:
- None.
- --*/
- /*++
- Structure Description:
- This structure defines a node of a Red-Black tree node.
- Members:
- Red - Stores a boolean indicating if the node is colored red (TRUE) or
- black (FALSE).
- LeftChild - Stores a pointer to the left child of this node.
- RightChild - Stores a pointer to the right child of this node.
- Parent - Stores a pointer to the parent of this node.
- --*/
- struct _RED_BLACK_TREE_NODE {
- BOOL Red;
- PRED_BLACK_TREE_NODE LeftChild;
- PRED_BLACK_TREE_NODE RightChild;
- PRED_BLACK_TREE_NODE Parent;
- };
- /*++
- Structure Description:
- This structure defines a Red-Black Tree.
- Members:
- Flags - Stores a bitfield of flags about the tree. See
- RED_BLACK_TREE_FLAG_* definitions.
- CompareFunction - Stores a pointer to a function used to compare two nodes.
- Root - Stores the root node of the tree, which is a sentinal node. The real
- root is the left child of this guy.
- NullNode - Stores a NULL node, a sentinal, used to avoid tons of NULL checks
- throughout the algorithm. All leaf nodes point to this NULL node.
- CallCount - Stores the total number of calls to insert or delete.
- --*/
- struct _RED_BLACK_TREE {
- ULONG Flags;
- PCOMPARE_RED_BLACK_TREE_NODES CompareFunction;
- RED_BLACK_TREE_NODE Root;
- RED_BLACK_TREE_NODE NullNode;
- ULONG CallCount;
- };
- /*++
- Structure Description:
- This structure stores character encoding state used to convert multibyte
- characters to wide characters. Callers should treat this structure as
- opaque and not access members directly, as they are likely to change or
- be removed without notice.
- Members:
- Encoding - Stores the character encoding type.
- --*/
- typedef struct _MULTIBYTE_STATE {
- CHARACTER_ENCODING Encoding;
- } MULTIBYTE_STATE, *PMULTIBYTE_STATE;
- typedef struct _PRINT_FORMAT_CONTEXT
- PRINT_FORMAT_CONTEXT, *PPRINT_FORMAT_CONTEXT;
- typedef
- BOOL
- (*PPRINT_FORMAT_WRITE_CHARACTER) (
- INT Character,
- PPRINT_FORMAT_CONTEXT Context
- );
- /*++
- Routine Description:
- This routine writes a character to the output during a printf-style
- formatting operation.
- Arguments:
- Character - Supplies the character to be written.
- Context - Supplies a pointer to the printf-context.
- Return Value:
- TRUE on success.
- FALSE on failure.
- --*/
- /*++
- Structure Description:
- This structure defines the context handed to a printf format function.
- Members:
- WriteCharacter - Stores a pointer to a function used to write a
- character to the destination of the formatted string operation. Usually
- this is a file or string.
- Context - Stores a pointer's worth of additional context. This pointer is
- not touched by the format string function, it's generally used inside
- the write character routine.
- Limit - Stores the maximum number of characters that should be sent to
- the write character routine. If this value is zero, an unlimited number
- of characters will be sent to the write character routine.
- CharactersWritten - Stores the number of characters that have been
- written so far. The print format routine will increment this after each
- successful byte is written.
- State - Stores the multibyte character state.
- --*/
- struct _PRINT_FORMAT_CONTEXT {
- PPRINT_FORMAT_WRITE_CHARACTER WriteCharacter;
- PVOID Context;
- ULONG Limit;
- ULONG CharactersWritten;
- MULTIBYTE_STATE State;
- };
- typedef struct _SCAN_INPUT SCAN_INPUT, *PSCAN_INPUT;
- typedef
- BOOL
- (*PSCANNER_GET_INPUT) (
- PSCAN_INPUT Input,
- PCHAR Character
- );
- /*++
- Routine Description:
- This routine retrieves another byte of input from the input scanner.
- Arguments:
- Input - Supplies a pointer to the input scanner structure.
- Character - Supplies a pointer where the character will be returned on
- success.
- Return Value:
- TRUE if a character was read.
- FALSE if the end of the file or string was encountered.
- --*/
- typedef
- BOOL
- (*PSCANNER_GET_INPUT_WIDE) (
- PSCAN_INPUT Input,
- PWCHAR Character
- );
- /*++
- Routine Description:
- This routine retrieves another wide character of input from the input
- scanner.
- Arguments:
- Input - Supplies a pointer to the input scanner structure.
- Character - Supplies a pointer where the character will be returned on
- success.
- Return Value:
- TRUE if a character was read.
- FALSE if the end of the file or string was encountered.
- --*/
- /*++
- Structure Description:
- This structure defines a scanner input structure which is used to get input
- from either a string or file pointer.
- Members:
- GetInput - Stores a pointer to the function called to get another character.
- String - Stores a pointer to the string for string driven inputs.
- WideString - Stores a pointer to the wide string for string driven inputs.
- Context - Stores a context pointer associated with this scan operation
- (such as a stream pointer).
- StringSize - Stores the size of the string for string driven inputs.
- CharactersRead - Stores the number of characters read.
- UnputCharacters - Stores a buffer of characters that were put back into the
- input buffer.
- ValidUnputCharacters - Stores the number of valid unput characters in the
- buffer.
- State - Stores the multibyte state.
- --*/
- struct _SCAN_INPUT {
- union {
- PSCANNER_GET_INPUT GetInput;
- PSCANNER_GET_INPUT_WIDE GetInputWide;
- } ReadU;
- union {
- PCSTR String;
- PCWSTR WideString;
- PVOID Context;
- } DataU;
- ULONG StringSize;
- ULONG CharactersRead;
- WCHAR UnputCharacters[SCANNER_UNPUT_SIZE];
- ULONG ValidUnputCharacters;
- MULTIBYTE_STATE State;
- };
- /*++
- Structure Description:
- This union allows the user to pick at the bits inside of an unsigned long
- long.
- Members:
- Ulong - Stores the parts in ULONGs.
- Ulonglong - Stores the bits of the 64 bit double.
- --*/
- typedef union _ULONGLONG_PARTS {
- struct {
- ULONG Low;
- ULONG High;
- } Ulong;
- ULONGLONG Ulonglong;
- } ULONGLONG_PARTS, *PULONGLONG_PARTS;
- /*++
- Structure Description:
- This union allows the user to pick at the bits inside of a double.
- Members:
- Double - Stores the value in its natural floating point form.
- Ulong - Stores the parts of the double in ULONGs.
- Ulonglong - Stores the bits of the 64 bit double.
- --*/
- typedef union _DOUBLE_PARTS {
- double Double;
- struct {
- ULONG Low;
- ULONG High;
- } Ulong;
- ULONGLONG Ulonglong;
- } DOUBLE_PARTS, *PDOUBLE_PARTS;
- /*++
- Structure Description:
- This union allows the user to pick at the bits inside of a float.
- Members:
- Float - Stores the value in its natural floating point form.
- Ulong - Stores the bits of the float.
- --*/
- typedef union _FLOAT_PARTS {
- float Float;
- ULONG Ulong;
- } FLOAT_PARTS, *PFLOAT_PARTS;
- typedef
- VOID
- (*PTIME_ZONE_LOCK_FUNCTION) (
- );
- /*++
- Routine Description:
- This routine implements an acquire or release of the lock responsible for
- guarding the global time zone data.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- typedef
- PVOID
- (*PTIME_ZONE_REALLOCATE_FUNCTION) (
- PVOID Memory,
- UINTN NewSize
- );
- /*++
- Routine Description:
- This routine allocates, reallocates, or frees memory for the time zone
- library.
- Arguments:
- Memory - Supplies the original active allocation. If this parameter is
- NULL, this routine will simply allocate memory.
- NewSize - Supplies the new required size of the allocation. If this is
- 0, then the original allocation will simply be freed.
- Return Value:
- Returns a pointer to a buffer with the new size (and original contents) on
- success. This may be a new buffer or the same one.
- NULL on failure or if the new size supplied was zero.
- --*/
- /*++
- Structure Description:
- This structure describes the system's concept of calendar time, which is
- represented as the number of seconds since midnight January 1, 2001 GMT.
- Members:
- Seconds - Stores the number of seconds since midnight January 1, 2001 GMT.
- Nanoseconds - Stores the nanoseconds portion of the time. This is usually
- a positive number, even for negative seconds values.
- --*/
- typedef struct _SYSTEM_TIME {
- LONGLONG Seconds;
- LONG Nanoseconds;
- } SYSTEM_TIME, *PSYSTEM_TIME;
- /*++
- Structure Description:
- This structure contains the broken down fields of a calendar date.
- Members:
- Year - Stores the year. Valid values are between 1 and 9999.
- Month - Stores the month. Valid values are between 0 and 11.
- Day - Stores the day of the month. Valid values are between 1 and 31.
- Hour - Stores the hour. Valid values are between 0 and 23.
- Minute - Stores the minute. Valid values are between 0 and 59.
- Second - Stores the second. Valid values are between 0 and 59. Arguably
- with leap seconds 60 is a valid value too, but the time functions will
- all roll that over into the next minute.
- Nanosecond - Stores the nanosecond. Valid values are between 0 and
- 999,999,999.
- Weekday - Stores the day of the week. Valid values are between 0 and 6,
- with 0 being Sunday and 6 being Saturday.
- YearDay - Stores the day of the year. Valid values are between 0 and 365.
- IsDaylightSaving - Stores a value indicating if the given time is
- represented in daylight saving time. Usually 0 indicates standard
- time, 1 indicates daylight saving time, and -1 indicates "unknown".
- GmtOffset - Stores the offset from Greenwich Mean Time in seconds that
- this time is interpreted in.
- TimeZone - Stores a pointer to a string containing the time zone name.
- --*/
- typedef struct _CALENDAR_TIME {
- LONG Year;
- LONG Month;
- LONG Day;
- LONG Hour;
- LONG Minute;
- LONG Second;
- LONG Nanosecond;
- LONG Weekday;
- LONG YearDay;
- LONG IsDaylightSaving;
- LONG GmtOffset;
- PCSTR TimeZone;
- } CALENDAR_TIME, *PCALENDAR_TIME;
- typedef struct _MEMORY_HEAP MEMORY_HEAP, *PMEMORY_HEAP;
- typedef
- PVOID
- (*PHEAP_ALLOCATE) (
- PMEMORY_HEAP Heap,
- UINTN Size,
- UINTN Tag
- );
- /*++
- Routine Description:
- This routine is called when the heap wants to expand and get more space.
- Arguments:
- Heap - Supplies a pointer to the heap to allocate from.
- Size - Supplies the size of the allocation request, in bytes.
- Tag - Supplies a 32-bit tag to associate with this allocation for debugging
- purposes. These are usually four ASCII characters so as to stand out
- when a poor developer is looking at a raw memory dump. It could also be
- a return address.
- Return Value:
- Returns a pointer to the allocation if successful, or NULL if the
- allocation failed.
- --*/
- typedef
- BOOL
- (*PHEAP_FREE) (
- PMEMORY_HEAP Heap,
- PVOID Memory,
- UINTN Size
- );
- /*++
- Routine Description:
- This routine is called when the heap wants to release space it had
- previously been allocated.
- Arguments:
- Heap - Supplies a pointer to the heap the memory was originally allocated
- from.
- Memory - Supplies the allocation returned by the allocation routine.
- Size - Supplies the size of the allocation to free.
- Return Value:
- TRUE if the memory was successfully freed.
- FALSE if the memory could not be freed.
- --*/
- typedef
- VOID
- (*PHEAP_CORRUPTION_ROUTINE) (
- PMEMORY_HEAP Heap,
- HEAP_CORRUPTION_CODE Code,
- PVOID Parameter
- );
- /*++
- Routine Description:
- This routine is called when the heap detects internal corruption.
- Arguments:
- Heap - Supplies a pointer to the heap containing the corruption.
- Code - Supplies the code detailing the problem.
- Parameter - Supplies an optional parameter pointing at a problem area.
- Return Value:
- None. This routine probably shouldn't return.
- --*/
- /*++
- Structure Description:
- This structure defines statistics for one allocation tag.
- Members:
- Node - Stores the Red-Black tree node information for this allocation
- statistic.
- Tag - Stores the allocation tag associated with this statistic.
- LargestAllocation - Stores the largest single allocation ever made under
- this tag, in bytes.
- ActiveSize - Stores the total number of bytes currently allocated under
- this tag.
- LargestActiveSize - Stores the largest number of bytes the active size has
- ever been.
- LifetimeAllocationSize - Stores the total number of bytes that have been
- allocated under this tag (not necessarily all at once).
- ActiveAllocationCount - Stores the current number of allocations under this
- allocation tag.
- LargestActiveAllocationCount - Stores the largest number the active
- allocation count has ever been for this tag.
- --*/
- typedef struct _MEMORY_HEAP_TAG_STATISTIC {
- RED_BLACK_TREE_NODE Node;
- ULONG Tag;
- ULONG LargestAllocation;
- ULONGLONG ActiveSize;
- ULONGLONG LargestActiveSize;
- ULONGLONG LifetimeAllocationSize;
- ULONG ActiveAllocationCount;
- ULONG LargestActiveAllocationCount;
- } MEMORY_HEAP_TAG_STATISTIC, *PMEMORY_HEAP_TAG_STATISTIC;
- /*++
- Structure Description:
- This structure defines heap-wide memory heap statistics.
- Members:
- TotalHeapSize - Stores the total size of the memory heap, in bytes.
- MaxHeapSize - Stores the maximum size the heap has ever been.
- FreeListSize - Stores the amount of free memory in the heap, in bytes.
- DirectAllocationSize - Stores the number of bytes of user allocations that
- were transparently allocated from the underlying allocator, and not
- within a heap segment.
- Allocations - Stores the number of outstanding allocations.
- TotalAllocationCalls - Stores the number of calls to allocate memory since
- the heap's initialization.
- FailedAllocations - Stores the number of calls to allocate memory that
- have been failed.
- TotalFreeCalls - Stores the number of calls to free memory since the heap's
- initialization.
- --*/
- typedef struct _MEMORY_HEAP_STATISTICS {
- UINTN TotalHeapSize;
- UINTN MaxHeapSize;
- UINTN FreeListSize;
- UINTN DirectAllocationSize;
- UINTN Allocations;
- UINTN TotalAllocationCalls;
- UINTN FailedAllocations;
- UINTN TotalFreeCalls;
- } MEMORY_HEAP_STATISTICS, *PMEMORY_HEAP_STATISTICS;
- /*++
- Structure Description:
- This structure defines optionally collected memory heap tag statistics.
- Members:
- Tree - Stores a pointer to the Red-Black tree storing the tags and their
- frequencies.
- StatisticEntry - Stores the built in entry for the statistic tag itself, to
- avoid infinite recursion.
- TagCount - Stores the number of unique tags that have been used for
- allocations.
- --*/
- typedef struct _MEMORY_HEAP_TAG_STATISTICS {
- RED_BLACK_TREE Tree;
- MEMORY_HEAP_TAG_STATISTIC StatisticEntry;
- UINTN TagCount;
- } MEMORY_HEAP_TAG_STATISTICS, *PMEMORY_HEAP_TAG_STATISTICS;
- typedef UINTN HEAP_BINMAP, *PHEAP_BINMAP;
- typedef UINTN HEAP_BINDEX, *PHEAP_BINDEX;
- typedef struct _HEAP_CHUNK HEAP_CHUNK, *PHEAP_CHUNK;
- typedef struct _HEAP_TREE_CHUNK HEAP_TREE_CHUNK, *PHEAP_TREE_CHUNK;
- typedef struct _HEAP_SEGMENT HEAP_SEGMENT, *PHEAP_SEGMENT;
- /*++
- Structure Description:
- This structure defines a segment of memory that the heap owns for carving
- up into allocations.
- Members:
- Base - Stores the base address of the segment.
- Size - Stores the size of the segment.
- Next - Stores a pointer to the next segment.
- Flags - Stores a bitfield of flags describing the segment.
- --*/
- struct _HEAP_SEGMENT {
- CHAR *Base;
- UINTN Size;
- PHEAP_SEGMENT Next;
- ULONG Flags;
- };
- /*++
- Structure Description:
- This structure defines a memory heap.
- Members:
- Magic - Stores a magic number, HEAP_MAGIC.
- Flags - Stores a bitfield of flags governing the behavior of the heap. See
- MEMORY_HEAP_FLAG_* definitions.
- AllocateFunction - Stores a pointer to a function called when the heap
- wants to expand and needs to allocate more memory.
- FreeFunction - Stores a pointer to a function called when the heap wants
- to a free a previously allocated region of memory.
- CorruptionFunction - Stores a pointer to a function to call if heap
- corruption is detected.
- AllocationTag - Stores the magic number to put into the magic field of
- each allocation. This is also the tag that gets passed to the
- allocation routine when expanding the heap.
- MinimumExpansionSize - Stores the minimum size, in bytes, for a heap
- expansion.
- ExpansionGranularity - Stores the granularity of the expansion size. This
- must be a power of two.
- ExpansionSize - Stores the size of the previous expansion.
- PreviousExpansionSize - Stores the size of the last expansion, for
- expansion doubling.
- Statistics - Stores heap-wide statistics.
- TagStatistics - Stores the tag statistics structure.
- SmallMap - Stores the bitmap of small bins that have valid entries in them.
- TreeMap - Stores the bitmap of tree bins that have valid entries in them.
- DirectAllocationThreshold - Stores the threshold value in bytes above which
- the heap just directly turns around and calls the allocator underneath.
- DesignatedVictimSize - Stores the size of the designated victim entry.
- TopSize - Stores the size of the heap wilderness.
- LeastAddress - Stores the lowest address the heap manages, or NULL if
- the heap has no memory at all.
- DesignatedVictim - Stores a pointer to the designated victim to carve
- memory out of.
- Top - Stores a pointer to the wilderness, the free region bordering the
- highest address the heap has known.
- TrimCheck - Stores the threshold value for the top. If the top wilderness
- exceeds this size, then the heap will be trimmed down to a more
- reasonable size.
- ReleaseChecks - Stores a countdown counter that is decremented during large
- free operations. When it reaches zero, any segments that are completely
- free are released back to the system, and the counter is reloaded.
- SmallBins - Stores the array of small bins where little free fragments are
- stored.
- TreeBins - Stores the array of trees where larger free fragments are
- stored.
- FootprintLimit - Stores a value that if non-zero limits the size that the
- heap can grow to.
- Segment - Stores the built-in first memory segment of the heap.
- --*/
- struct _MEMORY_HEAP {
- UINTN Magic;
- ULONG Flags;
- PHEAP_ALLOCATE AllocateFunction;
- PHEAP_FREE FreeFunction;
- PHEAP_CORRUPTION_ROUTINE CorruptionFunction;
- UINTN AllocationTag;
- UINTN MinimumExpansionSize;
- UINTN ExpansionGranularity;
- UINTN PreviousExpansionSize;
- MEMORY_HEAP_STATISTICS Statistics;
- MEMORY_HEAP_TAG_STATISTICS TagStatistics;
- HEAP_BINMAP SmallMap;
- HEAP_BINMAP TreeMap;
- UINTN DirectAllocationThreshold;
- UINTN DesignatedVictimSize;
- UINTN TopSize;
- PCHAR LeastAddress;
- PHEAP_CHUNK DesignatedVictim;
- PHEAP_CHUNK Top;
- UINTN TrimCheck;
- UINTN ReleaseChecks;
- PHEAP_CHUNK SmallBins[HEAP_SMALL_BIN_COUNT * 2];
- PHEAP_TREE_CHUNK TreeBins[HEAP_TREE_BIN_COUNT];
- UINTN FootprintLimit;
- HEAP_SEGMENT Segment;
- };
- typedef enum _SYSTEM_RELEASE_LEVEL {
- SystemReleaseInvalid,
- SystemReleaseDevelopment,
- SystemReleasePreAlpha,
- SystemReleaseAlpha,
- SystemReleaseBeta,
- SystemReleaseCandidate,
- SystemReleaseFinal,
- SystemReleaseLevelCount
- } SYSTEM_RELEASE_LEVEL, *PSYSTEM_RELEASE_LEVEL;
- typedef enum _SYSTEM_BUILD_DEBUG_LEVEL {
- SystemBuildInvalid,
- SystemBuildDebug,
- SystemBuildRelease,
- SystemBuildDebugLevelCount
- } SYSTEM_BUILD_DEBUG_LEVEL, *PSYSTEM_BUILD_DEBUG_LEVEL;
- typedef enum _SYSTEM_VERSION_STRING_VERBOSITY {
- SystemVersionStringMajorMinorOnly,
- SystemVersionStringBasic,
- SystemVersionStringComplete,
- } SYSTEM_VERSION_STRING_VERBOSITY, *PSYSTEM_VERSION_STRING_VERBOSITY;
- /*++
- Structure Description:
- This structure describes the system version information.
- Members:
- MajorVersion - Stores the major version number.
- MinorVersion - Stores the minor version number.
- Revision - Stores the sub-minor version number.
- SerialVersion - Stores the globally increasing system version number. This
- value will always be greater than any previous builds.
- ReleaseLevel - Stores the release level of the build.
- DebugLevel - Stores the debug compilation level of the build.
- BuildTime - Stores the system build time.
- ProductName - Stores a pointer to a string containing the name of the
- product.
- BuildString - Stores an optional pointer to a string containing an
- identifier string for this build.
- --*/
- typedef struct _SYSTEM_VERSION_INFORMATION {
- USHORT MajorVersion;
- USHORT MinorVersion;
- USHORT Revision;
- ULONGLONG SerialVersion;
- SYSTEM_RELEASE_LEVEL ReleaseLevel;
- SYSTEM_BUILD_DEBUG_LEVEL DebugLevel;
- SYSTEM_TIME BuildTime;
- PSTR ProductName;
- PSTR BuildString;
- } SYSTEM_VERSION_INFORMATION, *PSYSTEM_VERSION_INFORMATION;
- //
- // --------------------------------------------------------------------- Macros
- //
- //
- // The ASSERT macro evaluates the given expression. If it is false, then it
- // raises an exception.
- //
- #if DEBUG
- #define ASSERT(_Condition) \
- if ((_Condition) == FALSE) { \
- RtlRaiseAssertion(#_Condition, __FILE__, __LINE__); \
- }
- #else
- //
- // No asserts in non-debug builds.
- //
- #define ASSERT(_Condition)
- #endif
- //
- // This macro determines the offset of the field in the given structure.
- //
- #define FIELD_OFFSET(_Structure, _Field) \
- (UINTN)(&(((_Structure *)0L)->_Field))
- //
- // This macro retrieves the data structure associated with a particular Red
- // Black Tree node entry. _Node is a PRED_BLACK_TREE_NODE that points to the
- // node. _StructureName is the type of the containing record. _MemberName is
- // the name of the RED_BLACK_TREE_NODE in the containing record.
- #define RED_BLACK_TREE_VALUE(_Node, _StructureName, _MemberName) \
- PARENT_STRUCTURE(_Node, _StructureName, _MemberName)
- //
- // This macros determines whether or not the given Red Black tree is empty.
- //
- #define RED_BLACK_TREE_EMPTY(_Tree) \
- ((_Tree)->Root.LeftChild == &((_Tree)->NullNode))
- //
- //
- // -------------------------------------------------------------------- Globals
- //
- //
- // -------------------------------------------------------- Function Prototypes
- //
- RTL_API
- ULONG
- RtlComputeCrc32 (
- ULONG InitialCrc,
- PCVOID Buffer,
- ULONG Size
- );
- /*++
- Routine Description:
- This routine computes the CRC-32 Cyclic Redundancy Check on the given
- buffer of data.
- Arguments:
- InitialCrc - Supplies an initial CRC value to start with. Supply 0
- initially.
- Buffer - Supplies a pointer to the buffer to compute the CRC32 of.
- Size - Supplies the size of the buffer, in bytes.
- Return Value:
- Returns the CRC32 hash of the buffer.
- --*/
- RTL_API
- VOID
- RtlRaiseAssertion (
- PCSTR Expression,
- PCSTR SourceFile,
- ULONG SourceLine
- );
- /*++
- Routine Description:
- This routine raises an assertion failure. If a debugger is connected, it
- will attempt to connect to the debugger.
- Arguments:
- Expression - Supplies the string containing the expression that failed.
- SourceFile - Supplies the string describing the source file of the failure.
- SourceLine - Supplies the source line number of the failure.
- Return Value:
- None.
- --*/
- RTL_API
- VOID
- RtlDebugPrint (
- PCSTR Format,
- ...
- );
- /*++
- Routine Description:
- This routine prints a printf-style string to the debugger.
- Arguments:
- Format - Supplies the printf-style format string to print. The contents of
- this string determine the rest of the arguments passed.
- ... - Supplies any arguments needed to convert the Format string.
- Return Value:
- None.
- --*/
- RTL_API
- VOID
- RtlInitializeMultibyteState (
- PMULTIBYTE_STATE State,
- CHARACTER_ENCODING Encoding
- );
- /*++
- Routine Description:
- This routine initializes a multibyte state structure.
- Arguments:
- State - Supplies the a pointer to the state to reset.
- Encoding - Supplies the encoding to use for multibyte sequences. If the
- default value is supplied here, then the current default system
- encoding will be used.
- Return Value:
- None.
- --*/
- RTL_API
- CHARACTER_ENCODING
- RtlGetDefaultCharacterEncoding (
- VOID
- );
- /*++
- Routine Description:
- This routine returns the system default character encoding.
- Arguments:
- None.
- Return Value:
- Returns the current system default character encoding.
- --*/
- RTL_API
- KSTATUS
- RtlSetDefaultCharacterEncoding (
- CHARACTER_ENCODING NewEncoding,
- PCHARACTER_ENCODING OriginalEncoding
- );
- /*++
- Routine Description:
- This routine sets the system default character encoding.
- Arguments:
- NewEncoding - Supplies the new encoding to use.
- OriginalEncoding - Supplies an optional pointer where the previous
- character encoding will be returned.
- Return Value:
- STATUS_SUCCESS on success.
- STATUS_NOT_SUPPORTED if the given character encoding is not supported on
- this system.
- --*/
- RTL_API
- BOOL
- RtlIsCharacterEncodingSupported (
- CHARACTER_ENCODING Encoding
- );
- /*++
- Routine Description:
- This routine determines if the system supports a given character encoding.
- Arguments:
- Encoding - Supplies the encoding to query.
- Return Value:
- TRUE if the parameter is a valid encoding.
- FALSE if the system does not recognize the given encoding.
- --*/
- RTL_API
- BOOL
- RtlIsCharacterEncodingStateDependent (
- CHARACTER_ENCODING Encoding,
- BOOL ToMultibyte
- );
- /*++
- Routine Description:
- This routine determines if the given character encoding is state-dependent
- when converting between multibyte sequences and wide characters.
- Arguments:
- Encoding - Supplies the encoding to query.
- ToMultibyte - Supplies a boolean indicating the direction of the character
- encoding. State-dependence can vary between converting to multibyte and
- converting to wide character.
- Return Value:
- TRUE if the given encoding is valid and state-dependent.
- FALSE if the given encoding is invalid or not state-dependent.
- --*/
- RTL_API
- VOID
- RtlResetMultibyteState (
- PMULTIBYTE_STATE State
- );
- /*++
- Routine Description:
- This routine resets the given multibyte state back to its initial state,
- without clearing the character encoding.
- Arguments:
- State - Supplies a pointer to the state to reset.
- Return Value:
- None.
- --*/
- RTL_API
- BOOL
- RtlIsMultibyteStateReset (
- PMULTIBYTE_STATE State
- );
- /*++
- Routine Description:
- This routine determines if the given multibyte state is in its initial
- reset state.
- Arguments:
- State - Supplies a pointer to the state to query.
- Return Value:
- TRUE if the state is in the initial shift state.
- FALSE if the state is not in the initial shift state.
- --*/
- RTL_API
- KSTATUS
- RtlConvertMultibyteCharacterToWide (
- PCHAR *MultibyteCharacter,
- PULONG MultibyteBufferSize,
- PWCHAR WideCharacter,
- PMULTIBYTE_STATE State
- );
- /*++
- Routine Description:
- This routine converts a multibyte sequence into a wide character.
- Arguments:
- MultibyteCharacter - Supplies a pointer that on input contains a pointer
- to the multibyte character sequence. On successful output, this pointer
- will be advanced beyond the character.
- MultibyteBufferSize - Supplies a pointer that on input contains the size of
- the multibyte buffer in bytes. This value will be updated if the
- returned multibyte character buffer is advanced.
- WideCharacter - Supplies an optional pointer where the wide character will
- be returned on success.
- State - Supplies a pointer to the state to use.
- Return Value:
- STATUS_SUCCESS if a wide character was successfully converted.
- STATUS_INVALID_PARAMETER if the multibyte state is invalid.
- STATUS_BUFFER_TOO_SMALL if only a portion of a character could be
- constructed given the number of bytes in the buffer. The buffer will not
- be advanced in this case.
- STATUS_MALFORMED_DATA_STREAM if the byte sequence is not valid.
- --*/
- RTL_API
- KSTATUS
- RtlConvertWideCharacterToMultibyte (
- WCHAR WideCharacter,
- PCHAR MultibyteCharacter,
- PULONG Size,
- PMULTIBYTE_STATE State
- );
- /*++
- Routine Description:
- This routine converts a wide character into a multibyte sequence.
- Arguments:
- WideCharacter - Supplies the wide character to convert to a multibyte
- sequence.
- MultibyteCharacter - Supplies a pointer to the multibyte sequence.
- Size - Supplies a pointer that on input contains the size of the buffer.
- On output, it will return the number of bytes in the multibyte
- character, even if the buffer provided was too small.
- State - Supplies a pointer to the state to use.
- Return Value:
- STATUS_SUCCESS if a wide character was successfully converted.
- STATUS_INVALID_PARAMETER if the multibyte state is invalid.
- STATUS_BUFFER_TOO_SMALL if only a portion of a character could be
- constructed given the remaining space in the buffer. The buffer will not
- be advanced in this case.
- STATUS_MALFORMED_DATA_STREAM if the byte sequence is not valid.
- --*/
- RTL_API
- ULONG
- RtlPrintToString (
- PSTR Destination,
- ULONG DestinationSize,
- CHARACTER_ENCODING Encoding,
- PCSTR Format,
- ...
- );
- /*++
- Routine Description:
- This routine prints a formatted string out to a buffer.
- Arguments:
- Destination - Supplies a pointer to the buffer where the formatted string
- will be placed.
- DestinationSize - Supplies the size of the destination buffer, in bytes.
- Encoding - Supplies the character encoding to use for any wide characters
- or strings.
- Format - Supplies the printf-style format string to print. The contents of
- this string determine the rest of the arguments passed.
- ... - Supplies any arguments needed to convert the Format string.
- Return Value:
- Returns the length of the final string after all formatting has been
- completed. The length will be returned even if NULL is passed as the
- destination.
- --*/
- RTL_API
- ULONG
- RtlFormatString (
- PSTR Destination,
- ULONG DestinationSize,
- CHARACTER_ENCODING Encoding,
- PCSTR Format,
- va_list ArgumentList
- );
- /*++
- Routine Description:
- This routine converts a printf-style format string given the parameters.
- Arguments:
- Destination - Supplies a pointer to the buffer where the final string will
- be printed. It is assumed that this string is allocated and is big
- enough to hold the converted string. Pass NULL here to determine how big
- a buffer is necessary to hold the string. If the buffer is not big
- enough, it will be truncated but still NULL terminated.
- DestinationSize - Supplies the size of the destination buffer. If NULL was
- passed as the Destination argument, then this argument is ignored.
- Encoding - Supplies the character encoding to use when converting any
- wide strings or characters.
- Format - Supplies a pointer to the printf-style format string.
- ArgumentList - Supplies an initialized list of arguments to the format
- string.
- Return Value:
- Returns the length of the final string after all formatting has been
- completed, including the null terminator. The length will be returned even
- if NULL is passed as the destination.
- --*/
- RTL_API
- BOOL
- RtlFormat (
- PPRINT_FORMAT_CONTEXT Context,
- PCSTR Format,
- va_list ArgumentList
- );
- /*++
- Routine Description:
- This routine converts a printf-style format string given the parameters.
- Arguments:
- Context - Supplies a pointer to the initialized context structure.
- Format - Supplies a pointer to the printf-style format string.
- ArgumentList - Supplies an initialized list of arguments to the format
- string.
- Return Value:
- TRUE if all characters were written to the destination.
- FALSE if the destination or limit cut the conversion short.
- --*/
- RTL_API
- ULONG
- RtlPrintToStringWide (
- PWSTR Destination,
- ULONG DestinationSize,
- CHARACTER_ENCODING Encoding,
- PCWSTR Format,
- ...
- );
- /*++
- Routine Description:
- This routine prints a formatted wide string out to a buffer.
- Arguments:
- Destination - Supplies a pointer to the buffer where the formatted string
- will be placed.
- DestinationSize - Supplies the size of the destination buffer, in bytes.
- Encoding - Supplies the character encoding to use for any non-wide
- characters or strings.
- Format - Supplies the printf-style format string to print. The contents of
- this string determine the rest of the arguments passed.
- ... - Supplies any arguments needed to convert the Format string.
- Return Value:
- Returns the length of the final string (in characters) after all formatting
- has been completed. The length will be returned even if NULL is passed as
- the destination.
- --*/
- RTL_API
- ULONG
- RtlFormatStringWide (
- PWSTR Destination,
- ULONG DestinationSize,
- CHARACTER_ENCODING Encoding,
- PCWSTR Format,
- va_list ArgumentList
- );
- /*++
- Routine Description:
- This routine converts a printf-style wide format string given the
- parameters.
- Arguments:
- Destination - Supplies a pointer to the buffer where the final string will
- be printed. It is assumed that this string is allocated and is big
- enough to hold the converted string. Pass NULL here to determine how big
- a buffer is necessary to hold the string. If the buffer is not big
- enough, it will be truncated but still NULL terminated.
- DestinationSize - Supplies the size of the destination buffer. If NULL was
- passed as the Destination argument, then this argument is ignored.
- Encoding - Supplies the character encoding to use for any non-wide
- characters or strings.
- Format - Supplies a pointer to the printf-style format string.
- ArgumentList - Supplies an initialized list of arguments to the format
- string.
- Return Value:
- Returns the length of the final string after all formatting has been
- completed, including the null terminator. The length will be returned even
- if NULL is passed as the destination.
- --*/
- RTL_API
- BOOL
- RtlFormatWide (
- PPRINT_FORMAT_CONTEXT Context,
- PCWSTR Format,
- va_list ArgumentList
- );
- /*++
- Routine Description:
- This routine converts a printf-style wide format string given the
- parameters.
- Arguments:
- Context - Supplies a pointer to the initialized context structure.
- Format - Supplies a pointer to the printf-style format string.
- ArgumentList - Supplies an initialized list of arguments to the format
- string.
- Return Value:
- TRUE if all characters were written to the destination.
- FALSE if the destination or limit cut the conversion short.
- --*/
- RTL_API
- ULONG
- RtlStringCopy (
- PSTR Destination,
- PCSTR Source,
- UINTN BufferSize
- );
- /*++
- Routine Description:
- This routine copies a string from one buffer to another, including the NULL
- terminator.
- Arguments:
- Destination - Supplies a pointer to the buffer where the string will be
- copied to.
- Source - Supplies a pointer to the string to copy.
- BufferSize - Supplies the size of the destination buffer.
- Return Value:
- Returns the number of bytes copied, including the NULL terminator. If the
- source string is longer than the destination buffer, the string will be
- truncated but still NULL terminated.
- --*/
- RTL_API
- VOID
- RtlStringReverse (
- PSTR String,
- PSTR StringEnd
- );
- /*++
- Routine Description:
- This routine reverses the contents of a string. For example, the string
- "abcd" would get reversed to "dcba".
- Arguments:
- String - Supplies a pointer to the beginning of the string to reverse.
- StringEnd - Supplies a pointer to one beyond the end of the string. That is,
- this pointer points to the first byte *not* in the string.
- Return Value:
- None.
- --*/
- RTL_API
- ULONG
- RtlStringLength (
- PCSTR String
- );
- /*++
- Routine Description:
- This routine determines the length of the given string, not including its
- NULL terminator.
- Arguments:
- String - Supplies a pointer to the beginning of the string.
- Return Value:
- Returns the length of the string, not including the NULL terminator.
- --*/
- RTL_API
- BOOL
- RtlAreStringsEqual (
- PCSTR String1,
- PCSTR String2,
- ULONG MaxLength
- );
- /*++
- Routine Description:
- This routine determines if the contents of two strings are equal, up to a
- maximum number of characters.
- Arguments:
- String1 - Supplies a pointer to the first string to compare.
- String2 - Supplies a pointer to the second string to compare.
- MaxLength - Supplies the minimum of either string's buffer size.
- Return Value:
- TRUE if the strings are equal up to the maximum length.
- FALSE if the strings differ in some way.
- --*/
- RTL_API
- BOOL
- RtlAreStringsEqualIgnoringCase (
- PCSTR String1,
- PCSTR String2,
- ULONG MaxLength
- );
- /*++
- Routine Description:
- This routine determines if the contents of two strings are equal, up to a
- maximum number of characters. This routine is case insensitive.
- Arguments:
- String1 - Supplies a pointer to the first string to compare.
- String2 - Supplies a pointer to the second string to compare.
- MaxLength - Supplies the minimum of either string's buffer size.
- Return Value:
- TRUE if the strings are equal up to the maximum length.
- FALSE if the strings differ in some way.
- --*/
- RTL_API
- PSTR
- RtlStringFindCharacter (
- PCSTR String,
- CHAR Character,
- ULONG StringLength
- );
- /*++
- Routine Description:
- This routine searches a string for the first instance of the given
- character, scanning from the left.
- Arguments:
- String - Supplies a pointer to the string to search.
- Character - Supplies a pointer to the character to search for within the
- string.
- StringLength - Supplies the length of the string, in bytes, including the
- NULL terminator.
- Return Value:
- Returns a pointer to the first instance of the character on success.
- NULL if the character could not be found in the string.
- --*/
- RTL_API
- PSTR
- RtlStringFindCharacterRight (
- PCSTR String,
- CHAR Character,
- ULONG StringLength
- );
- /*++
- Routine Description:
- This routine searches a string for the first instance of the given
- character, scanning from the right backwards. The function will search
- starting at the NULL terminator or string length, whichever comes first.
- Arguments:
- String - Supplies a pointer to the string to search.
- Character - Supplies a pointer to the character to search for within the
- string.
- StringLength - Supplies the length of the string, in bytes, including the
- NULL terminator.
- Return Value:
- Returns a pointer to the first instance of the character on success.
- NULL if the character could not be found in the string.
- --*/
- RTL_API
- PSTR
- RtlStringSearch (
- PSTR InputString,
- UINTN InputStringLength,
- PSTR QueryString,
- UINTN QueryStringLength
- );
- /*++
- Routine Description:
- This routine searches a string for the first instance of the given string
- within it.
- Arguments:
- InputString - Supplies a pointer to the string to search.
- InputStringLength - Supplies the length of the string, in bytes, including
- the NULL terminator.
- QueryString - Supplies a pointer to the null terminated string to search
- for.
- QueryStringLength - Supplies the length of the query string in bytes
- including the null terminator.
- Return Value:
- Returns a pointer to the first instance of the string on success.
- NULL if the character could not be found in the string.
- --*/
- RTL_API
- PSTR
- RtlStringSearchIgnoringCase (
- PSTR InputString,
- UINTN InputStringLength,
- PSTR QueryString,
- UINTN QueryStringLength
- );
- /*++
- Routine Description:
- This routine searches a string for the first instance of the given string
- within it. This routine is case insensitive.
- Arguments:
- InputString - Supplies a pointer to the string to search.
- InputStringLength - Supplies the length of the string, in bytes, including
- the NULL terminator.
- QueryString - Supplies a pointer to the null terminated string to search
- for.
- QueryStringLength - Supplies the length of the query string in bytes
- including the null terminator.
- Return Value:
- Returns a pointer to the first instance of the string on success.
- NULL if the character could not be found in the string.
- --*/
- RTL_API
- ULONG
- RtlStringCopyWide (
- PWSTR Destination,
- PWSTR Source,
- ULONG BufferSize
- );
- /*++
- Routine Description:
- This routine copies a wide string from one buffer to another, including the
- NULL terminator.
- Arguments:
- Destination - Supplies a pointer to the buffer where the wide string will be
- copied to.
- Source - Supplies a pointer to the wide string to copy.
- BufferSize - Supplies the size of the destination buffer.
- Return Value:
- Returns the number of characters copied, including the NULL terminator. If
- the source string is longer than the destination buffer, the string will be
- truncated but still NULL terminated.
- --*/
- RTL_API
- VOID
- RtlStringReverseWide (
- PWSTR String,
- PWSTR StringEnd
- );
- /*++
- Routine Description:
- This routine reverses the contents of a wide string. For example, the string
- L"abcd" would get reversed to L"dcba".
- Arguments:
- String - Supplies a pointer to the beginning of the wide string to reverse.
- StringEnd - Supplies a pointer to one beyond the end of the string. That is,
- this pointer points to the first byte *not* in the string.
- Return Value:
- None.
- --*/
- RTL_API
- ULONG
- RtlStringLengthWide (
- PWSTR String
- );
- /*++
- Routine Description:
- This routine determines the length of the given wide string, not including
- its NULL terminator.
- Arguments:
- String - Supplies a pointer to the beginning of the string.
- Return Value:
- Returns the length of the string, not including the NULL terminator.
- --*/
- RTL_API
- BOOL
- RtlAreStringsEqualWide (
- PWSTR String1,
- PWSTR String2,
- ULONG MaxLength
- );
- /*++
- Routine Description:
- This routine determines if the contents of two wide strings are equal, up
- to a maximum number of characters.
- Arguments:
- String1 - Supplies a pointer to the first wide string to compare.
- String2 - Supplies a pointer to the second wide string to compare.
- MaxLength - Supplies the minimum of either string's buffer size.
- Return Value:
- TRUE if the strings are equal up to the maximum length.
- FALSE if the strings differ in some way.
- --*/
- RTL_API
- BOOL
- RtlAreStringsEqualIgnoringCaseWide (
- PWSTR String1,
- PWSTR String2,
- ULONG MaxLength
- );
- /*++
- Routine Description:
- This routine determines if the contents of two wide strings are equal, up
- to a maximum number of characters. This routine is case insensitive.
- Arguments:
- String1 - Supplies a pointer to the first wide string to compare.
- String2 - Supplies a pointer to the second wide string to compare.
- MaxLength - Supplies the minimum of either string's buffer size, in
- characters.
- Return Value:
- TRUE if the strings are equal up to the maximum length.
- FALSE if the strings differ in some way.
- --*/
- RTL_API
- PWSTR
- RtlStringFindCharacterWide (
- PWSTR String,
- WCHAR Character,
- ULONG StringLength
- );
- /*++
- Routine Description:
- This routine searches a wide string for the first instance of the given
- character, scanning from the left.
- Arguments:
- String - Supplies a pointer to the wide string to search.
- Character - Supplies a pointer to the wide character to search for within
- the string.
- StringLength - Supplies the length of the string, in characters, including
- the NULL terminator.
- Return Value:
- Returns a pointer to the first instance of the character on success.
- NULL if the character could not be found in the string.
- --*/
- RTL_API
- PWSTR
- RtlStringFindCharacterRightWide (
- PWSTR String,
- WCHAR Character,
- ULONG StringLength
- );
- /*++
- Routine Description:
- This routine searches a wide string for the first instance of the given
- character, scanning from the right backwards. The function will search
- starting at the NULL terminator or string length, whichever comes first.
- Arguments:
- String - Supplies a pointer to the wide string to search.
- Character - Supplies a pointer to the character to search for within the
- wide string.
- StringLength - Supplies the length of the string, in characters, including
- the NULL terminator.
- Return Value:
- Returns a pointer to the first instance of the character on success.
- NULL if the character could not be found in the string.
- --*/
- RTL_API
- KSTATUS
- RtlStringScan (
- PCSTR Input,
- ULONG InputSize,
- PCSTR Format,
- ULONG FormatSize,
- CHARACTER_ENCODING Encoding,
- PULONG ItemsScanned,
- ...
- );
- /*++
- Routine Description:
- This routine scans in a string and converts it to a number of arguments
- based on a format string.
- Arguments:
- Input - Supplies a pointer to the input string to scan.
- InputSize - Supplies the size of the string in bytes including the null
- terminator.
- Format - Supplies the format string that specifies how to convert the input
- to the arguments.
- FormatSize - Supplies the size of the format string in bytes, including
- the null terminator.
- Encoding - Supplies the character encoding to use when scanning into
- wide strings or characters.
- ItemsScanned - Supplies a pointer where the number of items scanned will
- be returned (not counting any %n specifiers).
- ... - Supplies the remaining pointer arguments where the scanned data will
- be returned.
- Return Value:
- STATUS_SUCCESS if the input was successfully scanned according to the
- format.
- STATUS_INVALID_SEQUENCE if the input did not match the format or the
- format was invalid.
- STATUS_ARGUMENT_EXPECTED if not enough arguments were supplied for the
- format.
- STATUS_END_OF_FILE if the input ended before any arguments were converted
- or any matching failures occurred.
- --*/
- RTL_API
- KSTATUS
- RtlStringScanVaList (
- PCSTR Input,
- ULONG InputSize,
- PCSTR Format,
- ULONG FormatSize,
- CHARACTER_ENCODING Encoding,
- PULONG ItemsScanned,
- va_list Arguments
- );
- /*++
- Routine Description:
- This routine scans in a string and converts it to a number of arguments
- based on a format string.
- Arguments:
- Input - Supplies a pointer to the input string to scan.
- InputSize - Supplies the size of the string in bytes including the null
- terminator.
- Format - Supplies the format string that specifies how to convert the input
- to the arguments.
- FormatSize - Supplies the size of the format string in bytes, including
- the null terminator.
- Encoding - Supplies the character encoding to use when scanning into
- wide strings or characters.
- ItemsScanned - Supplies a pointer where the number of items scanned will
- be returned (not counting any %n specifiers).
- Arguments - Supplies the initialized arguments list where various pieces
- of the formatted string will be returned.
- Return Value:
- STATUS_SUCCESS if the input was successfully scanned according to the
- format.
- STATUS_INVALID_SEQUENCE if the input did not match the format or the
- format was invalid.
- STATUS_ARGUMENT_EXPECTED if not enough arguments were supplied for the
- format.
- STATUS_END_OF_FILE if the input ended before any arguments were converted
- or any matching failures occurred.
- --*/
- RTL_API
- KSTATUS
- RtlStringScanInteger (
- PCSTR *String,
- PULONG StringSize,
- ULONG Base,
- BOOL Signed,
- PLONGLONG Integer
- );
- /*++
- Routine Description:
- This routine converts a string into an integer. It scans past leading
- whitespace.
- Arguments:
- String - Supplies a pointer that on input contains a pointer to the string
- to scan. On output, the string advanced past the scanned value (if any)
- will be returned. If the entire string is whitespace or starts with an
- invalid character, this parameter will not be modified.
- StringSize - Supplies a pointer that on input contains the size of the
- string, in bytes, including the null terminator. On output, this will
- contain the size of the string minus the number of bytes scanned by
- this routine. Said differently, it will return the size of the output
- to the string parameter in bytes including the null terminator.
- Base - Supplies the base of the integer to scan. Valid values are zero and
- two through thirty six. If zero is supplied, this routine will attempt
- to automatically detect what the base is out of bases 8, 10, and 16.
- Signed - Supplies a boolean indicating whether the integer to scan is
- signed or not.
- Integer - Supplies a pointer where the resulting integer is returned on
- success.
- Return Value:
- STATUS_SUCCESS if an integer was successfully scanned.
- STATUS_INVALID_SEQUENCE if a valid integer could not be scanned.
- STATUS_INTEGER_OVERFLOW if the result overflowed. In this case the integer
- returned will be MAX_LONGLONG, MIN_LONGLONG, or MAX_ULONGLONG depending on
- the signedness and value.
- STATUS_END_OF_FILE if the input ended before the value was converted
- or a matching failure occurred.
- --*/
- RTL_API
- KSTATUS
- RtlStringScanDouble (
- PCSTR *String,
- PULONG StringSize,
- double *Double
- );
- /*++
- Routine Description:
- This routine converts a string into a floating point double. It scans past
- leading whitespace.
- Arguments:
- String - Supplies a pointer that on input contains a pointer to the string
- to scan. On output, the string advanced past the scanned value (if any)
- will be returned. If the entire string is whitespace or starts with an
- invalid character, this parameter will not be modified.
- StringSize - Supplies a pointer that on input contains the size of the
- string, in bytes, including the null terminator. On output, this will
- contain the size of the string minus the number of bytes scanned by
- this routine. Said differently, it will return the size of the output
- to the string parameter in bytes including the null terminator.
- Double - Supplies a pointer where the resulting double is returned on
- success.
- Return Value:
- STATUS_SUCCESS if an integer was successfully scanned.
- STATUS_INVALID_SEQUENCE if a valid double could not be scanned.
- STATUS_OUT_OF_BOUNDS if the exponent was out of range.
- STATUS_END_OF_FILE if the input ended before the value was converted
- or a matching failure occurred.
- --*/
- RTL_API
- KSTATUS
- RtlScan (
- PSCAN_INPUT Input,
- PCSTR Format,
- ULONG FormatLength,
- PULONG ItemsScanned,
- va_list ArgumentList
- );
- /*++
- Routine Description:
- This routine scans from an input and converts the input to various
- parameters according to a specified format.
- Arguments:
- Input - Supplies a pointer to the filled out scan input structure which
- will be used to retrieve more input.
- Format - Supplies the format string which specifies how to convert the
- input to the argument list.
- FormatLength - Supplies the size of the format length string in bytes,
- including the null terminator.
- ItemsScanned - Supplies a pointer where the number of parameters filled in
- (not counting %n) will be returned.
- ArgumentList - Supplies the list of arguments that will get filled out
- based on the input and format string.
- Return Value:
- STATUS_SUCCESS if the input was successfully scanned according to the
- format.
- STATUS_INVALID_SEQUENCE if the input did not match the format or the
- format was invalid.
- STATUS_ARGUMENT_EXPECTED if not enough arguments were supplied for the
- format.
- STATUS_END_OF_FILE if the input ended before any arguments were converted
- or any matching failures occurred.
- --*/
- RTL_API
- KSTATUS
- RtlStringScanWide (
- PCWSTR Input,
- ULONG InputSize,
- PCWSTR Format,
- ULONG FormatSize,
- CHARACTER_ENCODING Encoding,
- PULONG ItemsScanned,
- ...
- );
- /*++
- Routine Description:
- This routine scans in a wide string and converts it to a number of arguments
- based on a format string.
- Arguments:
- Input - Supplies a pointer to the input wide string to scan.
- InputSize - Supplies the size of the string in characters including the
- null terminator.
- Format - Supplies the format string that specifies how to convert the input
- to the arguments.
- FormatSize - Supplies the size of the format string in characters,
- including the null terminator.
- Encoding - Supplies the character encoding to use when scanning non-wide
- items.
- ItemsScanned - Supplies a pointer where the number of items scanned will
- be returned (not counting any %n specifiers).
- ... - Supplies the remaining pointer arguments where the scanned data will
- be returned.
- Return Value:
- STATUS_SUCCESS if the input was successfully scanned according to the
- format.
- STATUS_INVALID_SEQUENCE if the input did not match the format or the
- format was invalid.
- STATUS_ARGUMENT_EXPECTED if not enough arguments were supplied for the
- format.
- STATUS_END_OF_FILE if the input ended before any arguments were converted
- or any matching failures occurred.
- --*/
- RTL_API
- KSTATUS
- RtlStringScanVaListWide (
- PCWSTR Input,
- ULONG InputSize,
- PCWSTR Format,
- ULONG FormatSize,
- CHARACTER_ENCODING Encoding,
- PULONG ItemsScanned,
- va_list Arguments
- );
- /*++
- Routine Description:
- This routine scans in a wide string and converts it to a number of arguments
- based on a format string.
- Arguments:
- Input - Supplies a pointer to the wide input string to scan.
- InputSize - Supplies the size of the string in characters including the
- null terminator.
- Format - Supplies the wide format string that specifies how to convert the
- input to the arguments.
- FormatSize - Supplies the size of the format string in characters,
- including the null terminator.
- Encoding - Supplies the character encoding to use when scanning non-wide
- items.
- ItemsScanned - Supplies a pointer where the number of items scanned will
- be returned (not counting any %n specifiers).
- Arguments - Supplies the initialized arguments list where various pieces
- of the formatted string will be returned.
- Return Value:
- STATUS_SUCCESS if the input was successfully scanned according to the
- format.
- STATUS_INVALID_SEQUENCE if the input did not match the format or the
- format was invalid.
- STATUS_ARGUMENT_EXPECTED if not enough arguments were supplied for the
- format.
- STATUS_END_OF_FILE if the input ended before any arguments were converted
- or any matching failures occurred.
- --*/
- RTL_API
- KSTATUS
- RtlStringScanIntegerWide (
- PCWSTR *String,
- PULONG StringSize,
- ULONG Base,
- BOOL Signed,
- PLONGLONG Integer
- );
- /*++
- Routine Description:
- This routine converts a wide string into an integer. It scans past leading
- whitespace.
- Arguments:
- String - Supplies a pointer that on input contains a pointer to the string
- to scan. On output, the string advanced past the scanned value (if any)
- will be returned. If the entire string is whitespace or starts with an
- invalid character, this parameter will not be modified.
- StringSize - Supplies a pointer that on input contains the size of the
- string, in characters , including the null terminator. On output, this
- will contain the size of the string minus the number of bytes scanned by
- this routine. Said differently, it will return the size of the output
- to the string parameter in bytes including the null terminator.
- Base - Supplies the base of the integer to scan. Valid values are zero and
- two through thirty six. If zero is supplied, this routine will attempt
- to automatically detect what the base is out of bases 8, 10, and 16.
- Signed - Supplies a boolean indicating whether the integer to scan is
- signed or not.
- STATUS_INTEGER_OVERFLOW if the result overflowed. In this case the integer
- returned will be MAX_LONGLONG, MIN_LONGLONG, or MAX_ULONGLONG depending on
- the signedness and value.
- Integer - Supplies a pointer where the resulting integer is returned on
- success.
- Return Value:
- STATUS_SUCCESS if an integer was successfully scanned.
- STATUS_INVALID_SEQUENCE if a valid integer could not be scanned.
- STATUS_END_OF_FILE if the input ended before the value was converted
- or a matching failure occurred.
- --*/
- RTL_API
- KSTATUS
- RtlStringScanDoubleWide (
- PCWSTR *String,
- PULONG StringSize,
- double *Double
- );
- /*++
- Routine Description:
- This routine converts a wide string into a floating point double. It scans
- past leading whitespace.
- Arguments:
- String - Supplies a pointer that on input contains a pointer to the wide
- string to scan. On output, the string advanced past the scanned value
- (if any) will be returned. If the entire string is whitespace or starts
- with an invalid character, this parameter will not be modified.
- StringSize - Supplies a pointer that on input contains the size of the
- string, in characters, including the null terminator. On output, this
- will contain the size of the string minus the number of bytes scanned
- by this routine. Said differently, it will return the size of the output
- to the string parameter in bytes including the null terminator.
- Double - Supplies a pointer where the resulting double is returned on
- success.
- Return Value:
- STATUS_SUCCESS if an integer was successfully scanned.
- STATUS_INVALID_SEQUENCE if a valid integer could not be scanned.
- STATUS_END_OF_FILE if the input ended before the value was converted
- or a matching failure occurred.
- --*/
- RTL_API
- KSTATUS
- RtlScanWide (
- PSCAN_INPUT Input,
- PCWSTR Format,
- ULONG FormatLength,
- PULONG ItemsScanned,
- va_list ArgumentList
- );
- /*++
- Routine Description:
- This routine scans from an input and converts the input to various
- parameters according to a specified format.
- Arguments:
- Input - Supplies a pointer to the filled out scan input structure which
- will be used to retrieve more input.
- Format - Supplies the wide format string which specifies how to convert the
- input to the argument list.
- FormatLength - Supplies the size of the format length string in characters,
- including the null terminator.
- ItemsScanned - Supplies a pointer where the number of parameters filled in
- (not counting %n) will be returned.
- ArgumentList - Supplies the list of arguments that will get filled out
- based on the input and format string.
- Return Value:
- STATUS_SUCCESS if the input was successfully scanned according to the
- format.
- STATUS_INVALID_SEQUENCE if the input did not match the format or the
- format was invalid.
- STATUS_ARGUMENT_EXPECTED if not enough arguments were supplied for the
- format.
- STATUS_END_OF_FILE if the input ended before any arguments were converted
- or any matching failures occurred.
- --*/
- RTL_API
- VOID
- RtlZeroMemory (
- PVOID Buffer,
- UINTN ByteCount
- );
- /*++
- Routine Description:
- This routine zeroes out a section of memory.
- Arguments:
- Buffer - Supplies a pointer to the buffer to clear.
- ByteCount - Supplies the number of bytes to zero out.
- Return Value:
- None.
- --*/
- RTL_API
- VOID
- RtlSetMemory (
- PVOID Buffer,
- INT Byte,
- UINTN Count
- );
- /*++
- Routine Description:
- This routine writes the given byte value repeatedly into a region of memory.
- Arguments:
- Buffer - Supplies a pointer to the buffer to set.
- Byte - Supplies the byte to set.
- Count - Supplies the number of bytes to set.
- Return Value:
- None.
- --*/
- RTL_API
- PVOID
- RtlCopyMemory (
- PVOID Destination,
- PCVOID Source,
- UINTN ByteCount
- );
- /*++
- Routine Description:
- This routine copies a section of memory.
- Arguments:
- Destination - Supplies a pointer to the buffer where the memory will be
- copied to.
- Source - Supplies a pointer to the buffer to be copied.
- ByteCount - Supplies the number of bytes to copy.
- Return Value:
- Returns the destination pointer.
- --*/
- RTL_API
- BOOL
- RtlCompareMemory (
- PCVOID FirstBuffer,
- PCVOID SecondBuffer,
- UINTN Size
- );
- /*++
- Routine Description:
- This routine compares two buffers for equality.
- Arguments:
- FirstBuffer - Supplies a pointer to the first buffer to compare.
- SecondBuffer - Supplies a pointer to the second buffer to compare.
- Size - Supplies the number of bytes to compare.
- Return Value:
- TRUE if the buffers are equal.
- FALSE if the buffers are not equal.
- --*/
- RTL_API
- BOOL
- RtlAreUuidsEqual (
- PUUID Uuid1,
- PUUID Uuid2
- );
- /*++
- Routine Description:
- This routine compares two UUIDs.
- Arguments:
- Uuid1 - Supplies the first UUID.
- Uuid2 - Supplies the second UUID.
- Return Value:
- TRUE if the UUIDs are equal.
- FALSE if the UUIDs are not equal.
- --*/
- __USED
- RTL_API
- ULONGLONG
- RtlDivideUnsigned64 (
- ULONGLONG Dividend,
- ULONGLONG Divisor,
- PULONGLONG Remainder
- );
- /*++
- Routine Description:
- This routine performs a 64-bit divide of two unsigned numbers.
- Arguments:
- Dividend - Supplies the number that is going to be divided (the numerator).
- Divisor - Supplies the number to divide into (the denominator).
- Remainder - Supplies a pointer that receives the remainder of the
- divide. This parameter may be NULL.
- Return Value:
- Returns the quotient.
- --*/
- __USED
- RTL_API
- LONGLONG
- RtlDivide64 (
- LONGLONG Dividend,
- LONGLONG Divisor
- );
- /*++
- Routine Description:
- This routine performs a 64-bit divide of two signed numbers.
- Arguments:
- Dividend - Supplies the number that is going to be divided (the numerator).
- Divisor - Supplies the number to divide into (the denominator).
- Return Value:
- Returns the quotient.
- --*/
- __USED
- RTL_API
- LONGLONG
- RtlDivideModulo64 (
- LONGLONG Dividend,
- LONGLONG Divisor,
- PLONGLONG Remainder
- );
- /*++
- Routine Description:
- This routine performs a 64-bit divide and modulo of two signed numbers.
- Arguments:
- Dividend - Supplies the number that is going to be divided (the numerator).
- Divisor - Supplies the number to divide into (the denominator).
- Remainder - Supplies a pointer where the remainder will be returned.
- Return Value:
- Returns the quotient.
- --*/
- __USED
- RTL_API
- ULONG
- RtlDivideUnsigned32 (
- ULONG Dividend,
- ULONG Divisor,
- PULONG Remainder
- );
- /*++
- Routine Description:
- This routine performs a 32-bit divide of two unsigned numbers.
- Arguments:
- Dividend - Supplies the number that is going to be divided (the numerator).
- Divisor - Supplies the number to divide into (the denominator).
- Remainder - Supplies an optional pointer where the remainder will be
- returned.
- Return Value:
- Returns the quotient.
- --*/
- __USED
- RTL_API
- LONG
- RtlDivide32 (
- LONG Dividend,
- LONG Divisor
- );
- /*++
- Routine Description:
- This routine performs a 32-bit divide of two signed numbers.
- Arguments:
- Dividend - Supplies the number that is going to be divided (the numerator).
- Divisor - Supplies the number to divide into (the denominator).
- Return Value:
- Returns the quotient.
- --*/
- __USED
- RTL_API
- LONG
- RtlDivideModulo32 (
- LONG Dividend,
- LONG Divisor,
- PLONG Remainder
- );
- /*++
- Routine Description:
- This routine performs a 32-bit divide and modulo of two signed numbers.
- Arguments:
- Dividend - Supplies the number that is going to be divided (the numerator).
- Divisor - Supplies the number to divide into (the denominator).
- Remainder - Supplies a pointer where the remainder will be returned.
- Return Value:
- Returns the quotient.
- --*/
- RTL_API
- ULONGLONG
- RtlByteSwapUlonglong (
- ULONGLONG Input
- );
- /*++
- Routine Description:
- This routine performs a byte-swap of a 64-bit integer, effectively changing
- its endianness.
- Arguments:
- Input - Supplies the integer to byte swap.
- Return Value:
- Returns the byte-swapped integer.
- --*/
- RTL_API
- ULONG
- RtlByteSwapUlong (
- ULONG Input
- );
- /*++
- Routine Description:
- This routine performs a byte-swap of a 32-bit integer, effectively changing
- its endianness.
- Arguments:
- Input - Supplies the integer to byte swap.
- Return Value:
- Returns the byte-swapped integer.
- --*/
- RTL_API
- USHORT
- RtlByteSwapUshort (
- USHORT Input
- );
- /*++
- Routine Description:
- This routine performs a byte-swap of a 16-bit integer, effectively changing
- its endianness.
- Arguments:
- Input - Supplies the integer to byte swap.
- Return Value:
- Returns the byte-swapped integer.
- --*/
- RTL_API
- INT
- RtlCountTrailingZeros64 (
- ULONGLONG Value
- );
- /*++
- Routine Description:
- This routine determines the number of trailing zero bits in the given
- 64-bit value.
- Arguments:
- Value - Supplies the value to get the number of trailing zeros for. This
- must not be zero.
- Return Value:
- Returns the number of trailing zero bits in the given value.
- --*/
- RTL_API
- INT
- RtlCountTrailingZeros32 (
- ULONG Value
- );
- /*++
- Routine Description:
- This routine determines the number of trailing zero bits in the given
- 32-bit value.
- Arguments:
- Value - Supplies the value to get the number of trailing zeros for. This
- must not be zero.
- Return Value:
- Returns the number of trailing zero bits in the given value.
- --*/
- RTL_API
- INT
- RtlCountLeadingZeros64 (
- ULONGLONG Value
- );
- /*++
- Routine Description:
- This routine determines the number of leading zero bits in the given 64-bit
- value.
- Arguments:
- Value - Supplies the value to get the number of leading zeros for. This
- must not be zero.
- Return Value:
- Returns the number of leading zero bits in the given value.
- --*/
- RTL_API
- INT
- RtlCountLeadingZeros32 (
- ULONG Value
- );
- /*++
- Routine Description:
- This routine determines the number of leading zero bits in the given 32-bit
- value.
- Arguments:
- Value - Supplies the value to get the number of leading zeros for. This
- must not be zero.
- Return Value:
- Returns the number of leading zero bits in the given value.
- --*/
- RTL_API
- INT
- RtlCountSetBits64 (
- ULONGLONG Value
- );
- /*++
- Routine Description:
- This routine determines the number of bits set to one in the given 64-bit
- value.
- Arguments:
- Value - Supplies the value to count set bits for.
- Return Value:
- Returns the number of bits set to one.
- --*/
- RTL_API
- INT
- RtlCountSetBits32 (
- ULONG Value
- );
- /*++
- Routine Description:
- This routine determines the number of bits set to one in the given 32-bit
- value.
- Arguments:
- Value - Supplies the value to count set bits for.
- Return Value:
- Returns the number of bits set to one.
- --*/
- RTL_API
- BOOL
- RtlFloatIsNan (
- float Value
- );
- /*++
- Routine Description:
- This routine determines if the given value is Not a Number.
- Arguments:
- Value - Supplies the floating point value to query.
- Return Value:
- TRUE if the given value is Not a Number.
- FALSE otherwise.
- --*/
- RTL_API
- double
- RtlFloatConvertToDouble (
- float Float
- );
- /*++
- Routine Description:
- This routine converts the given float into a double.
- Arguments:
- Float - Supplies the float to convert.
- Return Value:
- Returns the double equivalent.
- --*/
- RTL_API
- float
- RtlFloatAdd (
- float Value1,
- float Value2
- );
- /*++
- Routine Description:
- This routine adds two floats together.
- Arguments:
- Value1 - Supplies the first value.
- Value2 - Supplies the second value.
- Return Value:
- Returns the sum of the two values.
- --*/
- RTL_API
- float
- RtlFloatSubtract (
- float Value1,
- float Value2
- );
- /*++
- Routine Description:
- This routine subtracts two floats from each other.
- Arguments:
- Value1 - Supplies the first value.
- Value2 - Supplies the second value, the value to subtract.
- Return Value:
- Returns the difference of the two values.
- --*/
- RTL_API
- float
- RtlFloatMultiply (
- float Value1,
- float Value2
- );
- /*++
- Routine Description:
- This routine multiplies two floats together.
- Arguments:
- Value1 - Supplies the first value.
- Value2 - Supplies the second value.
- Return Value:
- Returns the product of the two values.
- --*/
- RTL_API
- float
- RtlFloatDivide (
- float Dividend,
- float Divisor
- );
- /*++
- Routine Description:
- This routine divides one float into another.
- Arguments:
- Dividend - Supplies the numerator.
- Divisor - Supplies the denominator.
- Return Value:
- Returns the quotient of the two values.
- --*/
- RTL_API
- float
- RtlFloatModulo (
- float Dividend,
- float Divisor
- );
- /*++
- Routine Description:
- This routine divides one float into another, and returns the remainder.
- Arguments:
- Dividend - Supplies the numerator.
- Divisor - Supplies the denominator.
- Return Value:
- Returns the modulo of the two values.
- --*/
- RTL_API
- float
- RtlFloatSquareRoot (
- float Value
- );
- /*++
- Routine Description:
- This routine returns the square root of the given float.
- Arguments:
- Value - Supplies the value to take the square root of.
- Return Value:
- Returns the square root of the given value.
- --*/
- RTL_API
- BOOL
- RtlFloatIsEqual (
- float Value1,
- float Value2
- );
- /*++
- Routine Description:
- This routine determines if the given floats are equal.
- Arguments:
- Value1 - Supplies the first value to compare.
- Value2 - Supplies the second value to compare.
- Return Value:
- TRUE if the values are equal.
- FALSE if the values are not equal. Note that NaN is not equal to anything,
- including itself.
- --*/
- RTL_API
- BOOL
- RtlFloatIsLessThanOrEqual (
- float Value1,
- float Value2
- );
- /*++
- Routine Description:
- This routine determines if the given value is less than or equal to the
- second value.
- Arguments:
- Value1 - Supplies the first value to compare, the left hand side of the
- comparison.
- Value2 - Supplies the second value to compare, the right hand side of the
- comparison.
- Return Value:
- TRUE if the first value is less than or equal to the first.
- FALSE if the first value is greater than the second.
- --*/
- RTL_API
- BOOL
- RtlFloatIsLessThan (
- float Value1,
- float Value2
- );
- /*++
- Routine Description:
- This routine determines if the given value is strictly less than the
- second value.
- Arguments:
- Value1 - Supplies the first value to compare, the left hand side of the
- comparison.
- Value2 - Supplies the second value to compare, the right hand side of the
- comparison.
- Return Value:
- TRUE if the first value is strictly less than to the first.
- FALSE if the first value is greater than or equal to the second.
- --*/
- RTL_API
- BOOL
- RtlFloatSignalingIsEqual (
- float Value1,
- float Value2
- );
- /*++
- Routine Description:
- This routine determines if the given values are equal, generating an
- invalid floating point exception if either is NaN.
- Arguments:
- Value1 - Supplies the first value to compare, the left hand side of the
- comparison.
- Value2 - Supplies the second value to compare, the right hand side of the
- comparison.
- Return Value:
- TRUE if the first value is strictly less than to the first.
- FALSE if the first value is greater than or equal to the second.
- --*/
- RTL_API
- BOOL
- RtlFloatIsLessThanOrEqualQuiet (
- float Value1,
- float Value2
- );
- /*++
- Routine Description:
- This routine determines if the given value is less than or equal to the
- second value. Quiet NaNs do not generate floating point exceptions.
- Arguments:
- Value1 - Supplies the first value to compare, the left hand side of the
- comparison.
- Value2 - Supplies the second value to compare, the right hand side of the
- comparison.
- Return Value:
- TRUE if the first value is less than or equal to the first.
- FALSE if the first value is greater than the second.
- --*/
- RTL_API
- BOOL
- RtlFloatIsLessThanQuiet (
- float Value1,
- float Value2
- );
- /*++
- Routine Description:
- This routine determines if the given value is strictly less than the
- second value. Quiet NaNs do not cause float point exceptions to be raised.
- Arguments:
- Value1 - Supplies the first value to compare, the left hand side of the
- comparison.
- Value2 - Supplies the second value to compare, the right hand side of the
- comparison.
- Return Value:
- TRUE if the first value is strictly less than to the first.
- FALSE if the first value is greater than or equal to the second.
- --*/
- RTL_API
- float
- RtlFloatConvertFromInteger32 (
- LONG Integer
- );
- /*++
- Routine Description:
- This routine converts the given signed 32-bit integer into a float.
- Arguments:
- Integer - Supplies the integer to convert to a float.
- Return Value:
- Returns the float equivalent to the given integer.
- --*/
- RTL_API
- float
- RtlFloatConvertFromUnsignedInteger32 (
- ULONG Integer
- );
- /*++
- Routine Description:
- This routine converts the given unsigned 32-bit integer into a float.
- Arguments:
- Integer - Supplies the integer to convert to a float.
- Return Value:
- Returns the float equivalent to the given integer.
- --*/
- RTL_API
- float
- RtlFloatConvertFromInteger64 (
- LONGLONG Integer
- );
- /*++
- Routine Description:
- This routine converts the given signed 64-bit integer into a float.
- Arguments:
- Integer - Supplies the integer to convert to a float.
- Return Value:
- Returns the float equivalent to the given integer.
- --*/
- RTL_API
- float
- RtlFloatConvertFromUnsignedInteger64 (
- ULONGLONG Integer
- );
- /*++
- Routine Description:
- This routine converts the given unsigned 64-bit integer into a float.
- Arguments:
- Integer - Supplies the unsigned integer to convert to a float.
- Return Value:
- Returns the float equivalent to the given integer.
- --*/
- RTL_API
- LONG
- RtlFloatConvertToInteger32 (
- float Float
- );
- /*++
- Routine Description:
- This routine converts the given float into a signed 32 bit integer.
- Arguments:
- Float - Supplies the float to convert.
- Return Value:
- Returns the integer, rounded according to the current rounding mode.
- --*/
- RTL_API
- LONG
- RtlFloatConvertToInteger32RoundToZero (
- float Float
- );
- /*++
- Routine Description:
- This routine converts the given float into a signed 32 bit integer. It
- always rounds towards zero.
- Arguments:
- Float - Supplies the float to convert.
- Return Value:
- Returns the integer, rounded towards zero.
- --*/
- RTL_API
- LONGLONG
- RtlFloatConvertToInteger64 (
- float Float
- );
- /*++
- Routine Description:
- This routine converts the given float into a signed 64 bit integer. If the
- value is NaN, then the largest positive integer is returned.
- Arguments:
- Float - Supplies the float to convert.
- Return Value:
- Returns the integer, rounded according to the current rounding mode.
- --*/
- RTL_API
- LONGLONG
- RtlFloatConvertToInteger64RoundToZero (
- float Float
- );
- /*++
- Routine Description:
- This routine converts the given float into a signed 64 bit integer. If the
- value is NaN, then the largest positive integer is returned. This routine
- always rounds towards zero.
- Arguments:
- Float - Supplies the float to convert.
- Return Value:
- Returns the integer, rounded towards zero.
- --*/
- RTL_API
- BOOL
- RtlDoubleIsNan (
- double Value
- );
- /*++
- Routine Description:
- This routine determines if the given value is Not a Number.
- Arguments:
- Value - Supplies the floating point value to query.
- Return Value:
- TRUE if the given value is Not a Number.
- FALSE otherwise.
- --*/
- RTL_API
- double
- RtlDoubleConvertFromInteger32 (
- LONG Integer
- );
- /*++
- Routine Description:
- This routine converts the given signed 32-bit integer into a double.
- Arguments:
- Integer - Supplies the integer to convert to a double.
- Return Value:
- Returns the double equivalent to the given integer.
- --*/
- RTL_API
- double
- RtlDoubleConvertFromUnsignedInteger32 (
- ULONG Integer
- );
- /*++
- Routine Description:
- This routine converts the given unsigned 32-bit integer into a double.
- Arguments:
- Integer - Supplies the integer to convert to a double.
- Return Value:
- Returns the double equivalent to the given integer.
- --*/
- RTL_API
- double
- RtlDoubleConvertFromInteger64 (
- LONGLONG Integer
- );
- /*++
- Routine Description:
- This routine converts the given signed 64-bit integer into a double.
- Arguments:
- Integer - Supplies the integer to convert to a double.
- Return Value:
- Returns the double equivalent to the given integer.
- --*/
- RTL_API
- double
- RtlDoubleConvertFromUnsignedInteger64 (
- ULONGLONG Integer
- );
- /*++
- Routine Description:
- This routine converts the given unsigned 64-bit integer into a double.
- Arguments:
- Integer - Supplies the unsigned integer to convert to a double.
- Return Value:
- Returns the double equivalent to the given integer.
- --*/
- RTL_API
- LONG
- RtlDoubleConvertToInteger32 (
- double Double
- );
- /*++
- Routine Description:
- This routine converts the given double into a signed 32 bit integer.
- Arguments:
- Double - Supplies the double to convert.
- Return Value:
- Returns the integer, rounded according to the current rounding mode.
- --*/
- RTL_API
- LONG
- RtlDoubleConvertToInteger32RoundToZero (
- double Double
- );
- /*++
- Routine Description:
- This routine converts the given double into a signed 32 bit integer. It
- always rounds towards zero.
- Arguments:
- Double - Supplies the double to convert.
- Return Value:
- Returns the integer, rounded towards zero.
- --*/
- RTL_API
- LONGLONG
- RtlDoubleConvertToInteger64 (
- double Double
- );
- /*++
- Routine Description:
- This routine converts the given double into a signed 64 bit integer. If the
- value is NaN, then the largest positive integer is returned.
- Arguments:
- Double - Supplies the double to convert.
- Return Value:
- Returns the integer, rounded according to the current rounding mode.
- --*/
- RTL_API
- LONGLONG
- RtlDoubleConvertToInteger64RoundToZero (
- double Double
- );
- /*++
- Routine Description:
- This routine converts the given double into a signed 64 bit integer. If the
- value is NaN, then the largest positive integer is returned. This routine
- always rounds towards zero.
- Arguments:
- Double - Supplies the double to convert.
- Return Value:
- Returns the integer, rounded towards zero.
- --*/
- RTL_API
- float
- RtlDoubleConvertToFloat (
- double Double
- );
- /*++
- Routine Description:
- This routine converts the given double into a float (32 bit floating
- point number).
- Arguments:
- Double - Supplies the double to convert.
- Return Value:
- Returns the float equivalent.
- --*/
- RTL_API
- double
- RtlDoubleAdd (
- double Value1,
- double Value2
- );
- /*++
- Routine Description:
- This routine adds two doubles together.
- Arguments:
- Value1 - Supplies the first value.
- Value2 - Supplies the second value.
- Return Value:
- Returns the sum of the two values.
- --*/
- RTL_API
- double
- RtlDoubleSubtract (
- double Value1,
- double Value2
- );
- /*++
- Routine Description:
- This routine subtracts two doubles from each other.
- Arguments:
- Value1 - Supplies the first value.
- Value2 - Supplies the second value, the value to subtract.
- Return Value:
- Returns the difference of the two values.
- --*/
- RTL_API
- double
- RtlDoubleMultiply (
- double Value1,
- double Value2
- );
- /*++
- Routine Description:
- This routine multiplies two doubles together.
- Arguments:
- Value1 - Supplies the first value.
- Value2 - Supplies the second value.
- Return Value:
- Returns the product of the two values.
- --*/
- RTL_API
- double
- RtlDoubleDivide (
- double Dividend,
- double Divisor
- );
- /*++
- Routine Description:
- This routine divides one double into another.
- Arguments:
- Dividend - Supplies the numerator.
- Divisor - Supplies the denominator.
- Return Value:
- Returns the quotient of the two values.
- --*/
- RTL_API
- double
- RtlDoubleModulo (
- double Dividend,
- double Divisor
- );
- /*++
- Routine Description:
- This routine divides one double into another, and returns the remainder.
- Arguments:
- Dividend - Supplies the numerator.
- Divisor - Supplies the denominator.
- Return Value:
- Returns the modulo of the two values.
- --*/
- RTL_API
- double
- RtlDoubleSquareRoot (
- double Value
- );
- /*++
- Routine Description:
- This routine returns the square root of the given double.
- Arguments:
- Value - Supplies the value to take the square root of.
- Return Value:
- Returns the square root of the given value.
- --*/
- RTL_API
- BOOL
- RtlDoubleIsEqual (
- double Value1,
- double Value2
- );
- /*++
- Routine Description:
- This routine determines if the given doubles are equal.
- Arguments:
- Value1 - Supplies the first value to compare.
- Value2 - Supplies the second value to compare.
- Return Value:
- TRUE if the values are equal.
- FALSE if the values are not equal. Note that NaN is not equal to anything,
- including itself.
- --*/
- RTL_API
- BOOL
- RtlDoubleIsLessThanOrEqual (
- double Value1,
- double Value2
- );
- /*++
- Routine Description:
- This routine determines if the given value is less than or equal to the
- second value.
- Arguments:
- Value1 - Supplies the first value to compare, the left hand side of the
- comparison.
- Value2 - Supplies the second value to compare, the right hand side of the
- comparison.
- Return Value:
- TRUE if the first value is less than or equal to the first.
- FALSE if the first value is greater than the second.
- --*/
- RTL_API
- BOOL
- RtlDoubleIsLessThan (
- double Value1,
- double Value2
- );
- /*++
- Routine Description:
- This routine determines if the given value is strictly less than the
- second value.
- Arguments:
- Value1 - Supplies the first value to compare, the left hand side of the
- comparison.
- Value2 - Supplies the second value to compare, the right hand side of the
- comparison.
- Return Value:
- TRUE if the first value is strictly less than to the first.
- FALSE if the first value is greater than or equal to the second.
- --*/
- RTL_API
- BOOL
- RtlDoubleSignalingIsEqual (
- double Value1,
- double Value2
- );
- /*++
- Routine Description:
- This routine determines if the given values are equal, generating an
- invalid floating point exception if either is NaN.
- Arguments:
- Value1 - Supplies the first value to compare, the left hand side of the
- comparison.
- Value2 - Supplies the second value to compare, the right hand side of the
- comparison.
- Return Value:
- TRUE if the first value is strictly less than to the first.
- FALSE if the first value is greater than or equal to the second.
- --*/
- RTL_API
- BOOL
- RtlDoubleIsLessThanOrEqualQuiet (
- double Value1,
- double Value2
- );
- /*++
- Routine Description:
- This routine determines if the given value is less than or equal to the
- second value. Quiet NaNs do not generate floating point exceptions.
- Arguments:
- Value1 - Supplies the first value to compare, the left hand side of the
- comparison.
- Value2 - Supplies the second value to compare, the right hand side of the
- comparison.
- Return Value:
- TRUE if the first value is less than or equal to the first.
- FALSE if the first value is greater than the second.
- --*/
- RTL_API
- BOOL
- RtlDoubleIsLessThanQuiet (
- double Value1,
- double Value2
- );
- /*++
- Routine Description:
- This routine determines if the given value is strictly less than the
- second value. Quiet NaNs do not cause float point exceptions to be raised.
- Arguments:
- Value1 - Supplies the first value to compare, the left hand side of the
- comparison.
- Value2 - Supplies the second value to compare, the right hand side of the
- comparison.
- Return Value:
- TRUE if the first value is strictly less than to the first.
- FALSE if the first value is greater than or equal to the second.
- --*/
- RTL_API
- VOID
- RtlDebugBreak (
- VOID
- );
- /*++
- Routine Description:
- This routine causes a break into the debugger.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- VOID
- RtlDebugService (
- UINTN ServiceRequest,
- PVOID Parameter
- );
- /*++
- Routine Description:
- This routine enters the debugger for a service request.
- Arguments:
- ServiceRequest - Supplies the reason for entering the debugger.
- Parameter - Supplies the parameter to pass to the debug service routine.
- Return Value:
- None.
- --*/
- RTL_API
- ULONG
- RtlAtomicExchange32 (
- volatile ULONG *Address,
- ULONG ExchangeValue
- );
- /*++
- Routine Description:
- This routine atomically exchanges the value at the given memory address
- with the given value.
- Arguments:
- Address - Supplies the address of the value to exchange with.
- ExchangeValue - Supplies the value to write to the address.
- Return Value:
- Returns the original value at the given address.
- --*/
- RTL_API
- ULONGLONG
- RtlAtomicExchange64 (
- volatile ULONGLONG *Address,
- ULONGLONG ExchangeValue
- );
- /*++
- Routine Description:
- This routine atomically exchanges the value at the given memory address
- with the given value.
- Arguments:
- Address - Supplies the address of the value to exchange with.
- ExchangeValue - Supplies the value to write to the address.
- Return Value:
- Returns the original value at the given address.
- --*/
- RTL_API
- ULONGLONG
- RtlAtomicCompareExchange64 (
- volatile ULONGLONG *Address,
- ULONGLONG ExchangeValue,
- ULONGLONG CompareValue
- );
- /*++
- Routine Description:
- This routine atomically compares a 64-bit value at the given address with a
- value and exchanges it with another value if they are equal.
- Arguments:
- Address - Supplies the address of the value to compare and potentially
- exchange.
- ExchangeValue - Supplies the value to write to Address if the comparison
- returns equality.
- CompareValue - Supplies the value to compare against.
- Return Value:
- Returns the original value at the given address.
- --*/
- RTL_API
- ULONG
- RtlAtomicCompareExchange32 (
- volatile ULONG *Address,
- ULONG ExchangeValue,
- ULONG CompareValue
- );
- /*++
- Routine Description:
- This routine atomically compares memory at the given address with a value
- and exchanges it with another value if they are equal.
- Arguments:
- Address - Supplies the address of the value to compare and potentially
- exchange.
- ExchangeValue - Supplies the value to write to Address if the comparison
- returns equality.
- CompareValue - Supplies the value to compare against.
- Return Value:
- Returns the original value at the given address.
- --*/
- RTL_API
- ULONG
- RtlAtomicAdd32 (
- volatile ULONG *Address,
- ULONG Increment
- );
- /*++
- Routine Description:
- This routine atomically adds the given amount to a 32-bit variable.
- Arguments:
- Address - Supplies the address of the value to atomically add to.
- Increment - Supplies the amount to add.
- Return Value:
- Returns the value before the atomic addition was performed.
- --*/
- RTL_API
- ULONGLONG
- RtlAtomicAdd64 (
- volatile ULONGLONG *Address,
- ULONGLONG Increment
- );
- /*++
- Routine Description:
- This routine atomically adds the given amount to a 64-bit variable.
- Arguments:
- Address - Supplies the address of the value to atomically add to.
- Increment - Supplies the amount to add.
- Return Value:
- Returns the value before the atomic addition was performed.
- --*/
- RTL_API
- ULONG
- RtlAtomicOr32 (
- volatile ULONG *Address,
- ULONG Mask
- );
- /*++
- Routine Description:
- This routine atomically ORs the given mask to a 32-bit variable.
- Arguments:
- Address - Supplies the address of the value to atomically OR with.
- Mask - Supplies the bitmask to logically OR in to the value.
- Return Value:
- Returns the value before the atomic operation was performed.
- --*/
- RTL_API
- ULONGLONG
- RtlAtomicOr64 (
- volatile ULONGLONG *Address,
- ULONGLONG Mask
- );
- /*++
- Routine Description:
- This routine atomically ORs the given amount to a 64-bit variable.
- Arguments:
- Address - Supplies the address of the value to atomically OR with.
- Mask - Supplies the bitmask to logically OR in to the value.
- Return Value:
- Returns the value before the atomic operation was performed.
- --*/
- RTL_API
- ULONG
- RtlAtomicAnd32 (
- volatile ULONG *Address,
- ULONG Mask
- );
- /*++
- Routine Description:
- This routine atomically ANDs the given mask to a 32-bit variable.
- Arguments:
- Address - Supplies the address of the value to atomically AND with.
- Mask - Supplies the bitmask to logically AND in to the value.
- Return Value:
- Returns the value before the atomic operation was performed.
- --*/
- RTL_API
- ULONG
- RtlAtomicXor32 (
- volatile ULONG *Address,
- ULONG Mask
- );
- /*++
- Routine Description:
- This routine atomically exclusive ORs the given mask to a 32-bit variable.
- Arguments:
- Address - Supplies the address of the value to atomically XOR with.
- Mask - Supplies the bitmask to logically XOR in to the value.
- Return Value:
- Returns the value before the atomic operation was performed.
- --*/
- RTL_API
- VOID
- RtlMemoryBarrier (
- VOID
- );
- /*++
- Routine Description:
- This routine provides a full memory barrier, ensuring that all memory
- accesses occurring before this function complete before any memory accesses
- after this function start.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- RTL_API
- VOID
- RtlRedBlackTreeInitialize (
- PRED_BLACK_TREE Tree,
- ULONG Flags,
- PCOMPARE_RED_BLACK_TREE_NODES CompareFunction
- );
- /*++
- Routine Description:
- This routine initializes a Red-Black tree structure.
- Arguments:
- Tree - Supplies a pointer to a tree to initialize. Tree structures should
- not be initialized more than once.
- Flags - Supplies a bitmask of flags governing the behavior of the tree. See
- RED_BLACK_TREE_FLAG_* definitions.
- CompareFunction - Supplies a pointer to a function called to compare nodes
- to each other. This routine is used on insertion, deletion, and search.
- Return Value:
- None.
- --*/
- RTL_API
- VOID
- RtlRedBlackTreeInsert (
- PRED_BLACK_TREE Tree,
- PRED_BLACK_TREE_NODE NewNode
- );
- /*++
- Routine Description:
- This routine inserts a node into the given Red-Black tree.
- Arguments:
- Tree - Supplies a pointer to a tree to insert the node into.
- NewNode - Supplies a pointer to the new node to insert.
- Return Value:
- None.
- --*/
- RTL_API
- PRED_BLACK_TREE_NODE
- RtlRedBlackTreeSearch (
- PRED_BLACK_TREE Tree,
- PRED_BLACK_TREE_NODE Value
- );
- /*++
- Routine Description:
- This routine searches for a node in the tree with the given value. If there
- are multiple nodes with the same value, then the first one found will be
- returned.
- Arguments:
- Tree - Supplies a pointer to a tree that owns the node to search.
- Value - Supplies a pointer to a dummy node that will be passed to the
- compare function. This node only has to be filled in to the extent that
- the compare function can be called to compare its value. Usually this
- is a stack allocated variable of the parent structure with that value
- filled in.
- Return Value:
- Returns a pointer to a node in the tree matching the desired value on
- success.
- NULL if a node matching the given value could not be found.
- --*/
- RTL_API
- PRED_BLACK_TREE_NODE
- RtlRedBlackTreeSearchClosest (
- PRED_BLACK_TREE Tree,
- PRED_BLACK_TREE_NODE Value,
- BOOL GreaterThan
- );
- /*++
- Routine Description:
- This routine searches for a node in the tree with the given value. If there
- are multiple nodes with the same value, then the first one found will be
- returned. If no node matches the given value, then the closest node
- greater than or less than the given value (depending on the parameter) will
- be returned instead.
- Arguments:
- Tree - Supplies a pointer to a tree that owns the node to search.
- Value - Supplies a pointer to a dummy node that will be passed to the
- compare function. This node only has to be filled in to the extent that
- the compare function can be called to compare its value. Usually this
- is a stack allocated variable of the parent structure with that value
- filled in.
- GreaterThan - Supplies a boolean indicating whether the closest value
- greater than the given value should be returned (TRUE) or the closest
- value less than the given value shall be returned (FALSE).
- Return Value:
- Returns a pointer to a node in the tree matching the desired value on
- success.
- Returns a pointer to the closest node greater than the given value if the
- greater than parameter is set and there is a node greater than the given
- value.
- Returns a pointer to the closest node less than the given node if the
- greater than parameter is not set, and such a node exists.
- NULL if the node cannot be found and there is no node greater than (or less
- than, depending on the parameter) the given value.
- --*/
- RTL_API
- PRED_BLACK_TREE_NODE
- RtlRedBlackTreeGetLowestNode (
- PRED_BLACK_TREE Tree
- );
- /*++
- Routine Description:
- This routine returns the node in the given Red-Black tree with the lowest
- value.
- Arguments:
- Tree - Supplies a pointer to a tree.
- Return Value:
- Returns a pointer to the node with the lowest value.
- NULL if the tree is empty.
- --*/
- RTL_API
- PRED_BLACK_TREE_NODE
- RtlRedBlackTreeGetHighestNode (
- PRED_BLACK_TREE Tree
- );
- /*++
- Routine Description:
- This routine returns the node in the given Red-Black tree with the highest
- value.
- Arguments:
- Tree - Supplies a pointer to a tree.
- Return Value:
- Returns a pointer to the node with the lowest value.
- NULL if the tree is empty.
- --*/
- RTL_API
- VOID
- RtlRedBlackTreeRemove (
- PRED_BLACK_TREE Tree,
- PRED_BLACK_TREE_NODE Node
- );
- /*++
- Routine Description:
- This routine removes the given node from the Red-Black tree.
- Arguments:
- Tree - Supplies a pointer to a tree that the node is currently inserted
- into.
- Node - Supplies a pointer to the node to remove from the tree.
- Return Value:
- None.
- --*/
- RTL_API
- VOID
- RtlRedBlackTreeIterate (
- PRED_BLACK_TREE Tree,
- PRED_BLACK_TREE_ITERATION_ROUTINE Routine,
- PVOID Context
- );
- /*++
- Routine Description:
- This routine iterates through all nodes in a Red-Black tree (via in in
- order traversal) and calls the given routine for each node in the tree.
- The routine passed must not modify the tree.
- Arguments:
- Tree - Supplies a pointer to a tree that the node is currently inserted
- into.
- Routine - Supplies a pointer to the routine that will be called for each
- node encountered.
- Context - Supplies an optional caller-provided context that will be passed
- to the interation routine for each node.
- Return Value:
- None.
- --*/
- RTL_API
- PRED_BLACK_TREE_NODE
- RtlRedBlackTreeGetNextNode (
- PRED_BLACK_TREE Tree,
- BOOL Descending,
- PRED_BLACK_TREE_NODE PreviousNode
- );
- /*++
- Routine Description:
- This routine gets the node in the Red-Black tree with the next highest
- or lower value depending on the supplied boolean.
- Arguments:
- Tree - Supplies a pointer to a Red-Black tree.
- Descending - Supplies a boolean indicating if the next node should be a
- descending value or not.
- PreviousNode - Supplies a pointer to the previous node on which to base the
- search.
- Return Value:
- Returns a pointer to the node in the tree with the next highest value, or
- NULL if the given previous node is the node with the highest value.
- --*/
- RTL_API
- BOOL
- RtlValidateRedBlackTree (
- PRED_BLACK_TREE Tree
- );
- /*++
- Routine Description:
- This routine determines if the given Red-Black tree is valid.
- Note: This function is recursive, and should not be used outside of debug
- builds and test environments.
- Arguments:
- Tree - Supplies a pointer to the tree to validate.
- Return Value:
- TRUE if the tree is valid.
- FALSE if the tree is corrupt or is breaking required rules of Red-Black
- trees.
- --*/
- RTL_API
- KSTATUS
- RtlSystemTimeToGmtCalendarTime (
- PSYSTEM_TIME SystemTime,
- PCALENDAR_TIME CalendarTime
- );
- /*++
- Routine Description:
- This routine converts the given system time into calendar time in the
- GMT time zone.
- Arguments:
- SystemTime - Supplies a pointer to the system time to convert.
- CalendarTime - Supplies a pointer to the calendar time to initialize based
- on the given system time.
- Return Value:
- STATUS_SUCCESS on success.
- STATUS_OUT_OF_BOUNDS if the given system time is too funky.
- --*/
- RTL_API
- KSTATUS
- RtlCalendarTimeToSystemTime (
- PCALENDAR_TIME CalendarTime,
- PSYSTEM_TIME SystemTime
- );
- /*++
- Routine Description:
- This routine converts the given calendar time into its corresponding system
- time.
- Arguments:
- CalendarTime - Supplies a pointer to the calendar time to convert.
- SystemTime - Supplies a pointer where the system time will be returned.
- Return Value:
- STATUS_SUCCESS on success.
- STATUS_OUT_OF_BOUNDS if the given calendar time is too funky.
- --*/
- RTL_API
- KSTATUS
- RtlGmtCalendarTimeToSystemTime (
- PCALENDAR_TIME CalendarTime,
- PSYSTEM_TIME SystemTime
- );
- /*++
- Routine Description:
- This routine converts the given calendar time, assumed to be a GMT data and
- time, into its corresponding system time. On success, this routine will
- update the supplied calendar time to fill out all fields.
- Arguments:
- CalendarTime - Supplies a pointer to the GMT calendar time to convert.
- SystemTime - Supplies a pointer where the system time will be returned.
- Return Value:
- STATUS_SUCCESS on success.
- STATUS_OUT_OF_BOUNDS if the given GMT calendar time is too funky.
- --*/
- RTL_API
- UINTN
- RtlFormatDate (
- PSTR StringBuffer,
- ULONG StringBufferSize,
- PSTR Format,
- PCALENDAR_TIME CalendarTime
- );
- /*++
- Routine Description:
- This routine converts the given calendar time into a string governed by
- the given format string.
- Arguments:
- StringBuffer - Supplies a pointer where the converted string will be
- returned, including the terminating null.
- StringBufferSize - Supplies the size of the string buffer in bytes.
- Format - Supplies the format string to govern the conversion. Ordinary
- characters in the format string will be copied verbatim to the output
- string. Conversions will be substituted for their corresponding value
- in the provided calendar time. Conversions start with a '%' character,
- followed by an optional E or O character, followed by a conversion
- specifier. The conversion specifier can take the following values:
- %a - Replaced by the abbreviated weekday.
- %A - Replaced by the full weekday.
- %b - Replaced by the abbreviated month name.
- %B - Replaced by the full month name.
- %c - Replaced by the locale's appropriate date and time representation.
- %C - Replaced by the year divided by 100 (century) [00,99].
- %d - Replaced by the day of the month [01,31].
- %D - Equivalent to "%m/%d/%y".
- %e - Replaced by the day of the month [ 1,31]. A single digit is
- preceded by a space.
- %F - Equivalent to "%Y-%m-%d" (the ISO 8601:2001 date format).
- %G - The ISO 8601 week-based year [0001,9999]. The week-based year and
- the Gregorian year can differ in the first week of January.
- %h - Equivalent to %b (abbreviated month).
- %H - Replaced by the 24 hour clock hour [00,23].
- %I - Replaced by the 12 hour clock hour [01,12].
- %J - Replaced by the nanosecond [0,999999999].
- %j - Replaced by the day of the year [001,366].
- %m - Replaced by the month number [01,12].
- %M - Replaced by the minute [00,59].
- %N - Replaced by the microsecond [0,999999]
- %n - Replaced by a newline.
- %p - Replaced by "AM" or "PM".
- %P - Replaced by "am" or "pm".
- %q - Replaced by the millisecond [0,999].
- %r - Replaced by the time in AM/PM notation: "%I:%M:%S %p".
- %R - Replaced by the time in 24 hour notation: "%H:%M".
- %S - Replaced by the second [00,60].
- %t - Replaced by a tab.
- %T - Replaced by the time: "%H:%M:%S".
- %u - Replaced by the weekday number, with 1 representing Monday [1,7].
- %U - Replaced by the week number of the year [00,53]. The first Sunday
- of January is the first day of week 1. Days before this are week 0.
- %V - Replaced by the week number of the year with Monday as the first
- day in the week [01,53]. If the week containing January 1st has 4
- or more days in the new year, it is considered week 1. Otherwise,
- it is the last week of the previous year, and the next week is 1.
- %w - Replaced by the weekday number [0,6], with 0 representing Sunday.
- %W - Replaced by the week number [00,53]. The first Monday of January
- is the first day of week 1. Days before this are in week 0.
- %x - Replaced by the locale's appropriate date representation.
- %X - Replaced by the locale's appropriate time representation.
- %y - Replaced by the last two digits of the year [00,99].
- %Y - Replaced by the full four digit year [0001,9999].
- %z - Replaced by the offset from UTC in the standard ISO 8601:2000
- standard format (+hhmm or -hhmm), or by no characters if no
- timezone is terminable. If the "is daylight saving" member of the
- calendar structure is greater than zero, then the daylight saving
- offset is used. If the dayslight saving member of the calendar
- structure is negative, no characters are returned.
- %Z - Replaced by the timezone name or abbreviation, or by no bytes if
- no timezone information exists.
- %% - Replaced by a literal '%'.
- CalendarTime - Supplies a pointer to the calendar time value to use in the
- substitution.
- Return Value:
- Returns the number of characters written to the output buffer, including
- the null terminator.
- --*/
- RTL_API
- UINTN
- RtlFormatDateWide (
- PWSTR StringBuffer,
- ULONG StringBufferSize,
- PWSTR Format,
- PCALENDAR_TIME CalendarTime
- );
- /*++
- Routine Description:
- This routine converts the given calendar time into a wide string governed
- by the given wide format string.
- Arguments:
- StringBuffer - Supplies a pointer where the converted wide string will be
- returned, including the terminating null.
- StringBufferSize - Supplies the size of the string buffer in characters.
- Format - Supplies the wide format string to govern the conversion. Ordinary
- characters in the format string will be copied verbatim to the output
- string. Conversions will be substituted for their corresponding value
- in the provided calendar time. The conversions are equivalent to the
- non-wide format date function.
- CalendarTime - Supplies a pointer to the calendar time value to use in the
- substitution.
- Return Value:
- Returns the number of characters written to the output buffer, not
- including the null terminator.
- --*/
- RTL_API
- PSTR
- RtlScanDate (
- PCSTR StringBuffer,
- PCSTR Format,
- PCALENDAR_TIME CalendarTime
- );
- /*++
- Routine Description:
- This routine scans the given input string into values in the calendar time,
- using the specified format.
- Arguments:
- StringBuffer - Supplies a pointer to the null terminated string to scan.
- Format - Supplies the format string to govern the conversion. Ordinary
- characters in the format string will be scanned verbatim from the input.
- Whitespace characters in the format will cause all whitespace at the
- current position in the input to be scanned. Conversions will be
- scanned for their corresponding value in the provided calendar time.
- Conversions start with a '%' character, followed by an optional E or O
- character, followed by a conversion specifier. The conversion specifier
- can take the following values:
- %a - The day of the weekday name, either the full or abbreviated name.
- %A - Equivalent to %a.
- %b - The month name, either the full or abbreviated name.
- %B - Equivalent to %b.
- %c - Replaced by the locale's appropriate date and time representation.
- %C - The year divided by 100 (century) [00,99].
- %d - The day of the month [01,31].
- %D - Equivalent to "%m/%d/%y".
- %e - Equivalent to %d.
- %h - Equivalent to %b (month name).
- %H - The 24 hour clock hour [00,23].
- %I - The 12 hour clock hour [01,12].
- %J - Replaced by the nanosecond [0,999999999].
- %j - The day of the year [001,366].
- %m - The month number [01,12].
- %M - The minute [00,59].
- %N - The microsecond [0,999999]
- %n - Any whitespace.
- %p - The equivalent of "AM" or "PM".
- %q - The millisecond [0,999].
- %r - Replaced by the time in AM/PM notation: "%I:%M:%S %p".
- %R - Replaced by the time in 24 hour notation: "%H:%M".
- %S - The second [00,60].
- %t - Any white space.
- %T - Replaced by the time: "%H:%M:%S".
- %u - Replaced by the weekday number, with 1 representing Monday [1,7].
- %U - The week number of the year [00,53]. The first Sunday of January is
- the first day of week 1. Days before this are week 0.
- %w - The weekday number [0,6], with 0 representing Sunday.
- %W - The week number [00,53]. The first Monday of January is the first
- day of week 1. Days before this are in week 0.
- %x - Replaced by the locale's appropriate date representation.
- %X - Replaced by the locale's appropriate time representation.
- %y - The last two digits of the year [00,99].
- %Y - The full four digit year [0001,9999].
- %% - Replaced by a literal '%'.
- CalendarTime - Supplies a pointer to the calendar time value to place the
- values in. Only the values that are scanned in are modified.
- Return Value:
- Returns the a pointer to the input string after the last character scanned.
- NULL if the result coult not be scanned.
- --*/
- RTL_API
- VOID
- RtlInitializeTimeZoneSupport (
- PTIME_ZONE_LOCK_FUNCTION AcquireTimeZoneLockFunction,
- PTIME_ZONE_LOCK_FUNCTION ReleaseTimeZoneLockFunction,
- PTIME_ZONE_REALLOCATE_FUNCTION ReallocateFunction
- );
- /*++
- Routine Description:
- This routine initializes library support functions needed by the time zone
- code.
- Arguments:
- AcquireTimeZoneLockFunction - Supplies a pointer to the function called
- to acquire access to the time zone data.
- ReleaseTimeZoneLockFunction - Supplies a pointer to the function called to
- relinquish access to the time zone data.
- ReallocateFunction - Supplies a pointer to a function used to dynamically
- allocate and free memory.
- Return Value:
- None.
- --*/
- RTL_API
- KSTATUS
- RtlFilterTimeZoneData (
- PVOID TimeZoneData,
- ULONG TimeZoneDataSize,
- PCSTR TimeZoneName,
- PVOID FilteredData,
- PULONG FilteredDataSize
- );
- /*++
- Routine Description:
- This routine filters the given time zone data for one specific time zone.
- Arguments:
- TimeZoneData - Supplies a pointer to the buffer containing the unfiltered
- time zone data.
- TimeZoneDataSize - Supplies the size in bytes of the unfiltered time zone
- data.
- TimeZoneName - Supplies a pointer to the null terminated string containing
- the name of the time zone to retrieve.
- FilteredData - Supplies an optional pointer to the buffer where the
- filtered data will be returned. If this pointer is NULL, then only the
- size of the required data will be returned.
- FilteredDataSize - Supplies a pointer that on input contains the size of
- the filtered data buffer. On output, will return the required size of
- the output buffer to contain the filtered data.
- Return Value:
- STATUS_SUCCESS on success.
- STATUS_BUFFER_TOO_SMALL if the provided buffer was valid but too small.
- STATUS_FILE_CORRUPT if the data is invalid.
- --*/
- RTL_API
- KSTATUS
- RtlGetTimeZoneData (
- PVOID Data,
- PULONG DataSize
- );
- /*++
- Routine Description:
- This routine copies the current time zone data into the given buffer.
- Arguments:
- Data - Supplies a pointer where the current time zone data will be copied
- to.
- DataSize - Supplies a pointer that on input contains the size of the
- supplied data buffer. On output, will contain the size of the
- current data (whether or not a buffer was supplied).
- Return Value:
- STATUS_SUCCESS if the time zone data was accepted.
- STATUS_BUFFER_TOO_SMALL if the provided buffer was valid but too small.
- STATUS_NO_DATA_AVAILABLE if there is no data or the data is empty.
- --*/
- RTL_API
- KSTATUS
- RtlSetTimeZoneData (
- PVOID Data,
- ULONG DataSize,
- PCSTR ZoneName,
- PVOID *OldData,
- PULONG OldDataSize,
- PSTR OriginalZoneBuffer,
- PULONG OriginalZoneBufferSize
- );
- /*++
- Routine Description:
- This routine sets the current time zone data.
- Arguments:
- Data - Supplies a pointer to the time zone data to set. No copy will be
- made, the caller must ensure the data is not modified or freed until
- another call to set time zone data completes.
- DataSize - Supplies the size of the data in bytes.
- ZoneName - Supplies an optional pointer to the name of a time zone to
- select within the data. If this pointer is NULL, the first time zone
- in the data will be used.
- OldData - Supplies a pointer where the original (now decommissioned) time
- zone data will be returned.
- OldDataSize - Supplies a pointer where the size of the original
- decommissioned data will be returned.
- OriginalZoneBuffer - Supplies an optional pointer where the original (or
- current if no new time zone was provided) time zone will be returned.
- OriginalZoneBufferSize - Supplies a pointer that on input contains the
- size of the original zone buffer in bytes. On output, this value will
- contain the size of the original zone buffer needed to contain the
- name of the current time zone (even if no buffer was provided).
- Return Value:
- STATUS_SUCCESS if the time zone data was accepted.
- STATUS_FILE_CORRUPT if the data is invalid.
- STATUS_NOT_FOUND if the selected time zone could not be found in the new
- data. If this is the case, the new data will not be activated.
- --*/
- RTL_API
- KSTATUS
- RtlListTimeZones (
- PVOID Data,
- ULONG DataSize,
- PSTR ListBuffer,
- PULONG ListBufferSize
- );
- /*++
- Routine Description:
- This routine creates a list of all time zones available in the given (or
- currently in use) data.
- Arguments:
- Data - Supplies a pointer to the time zone data to debug print. If this
- is NULL, the current data will be used.
- DataSize - Supplies the size of the data in bytes.
- ListBuffer - Supplies an optional pointer to a buffer where the null
- terminated strings representing the names of the time zones will be
- returned on success. The buffer will be terminated by an empty string.
- ListBufferSize - Supplies a pointer that on input contains the size of the
- list buffer in bytes. On output this will contain the size needed to
- hold all the strings, regardless of whether a buffer was passed in.
- Return Value:
- STATUS_SUCCESS on success.
- STATUS_BUFFER_TOO_SMALL if the provided buffer was too small.
- STATUS_FILE_CORRUPT if the time zone data was not valid.
- STATUS_NO_DATA_AVAILABLE if there is no data or the data is empty.
- --*/
- RTL_API
- VOID
- RtlGetTimeZoneNames (
- PCSTR *StandardName,
- PCSTR *DaylightName,
- PLONG StandardGmtOffset,
- PLONG DaylightGmtOffset
- );
- /*++
- Routine Description:
- This routine returns the names of the currently selected time zone.
- Arguments:
- StandardName - Supplies an optional pointer where a pointer to the standard
- time zone name will be returned on success. The caller must not modify
- this memory, and it may change if the time zone is changed.
- DaylightName - Supplies an optional pointer where a pointer to the Daylight
- Saving time zone name will be returned on success. The caller must not
- modify this memory, and it may change if the time zone is changed.
- StandardGmtOffset - Supplies an optional pointer where the offset from GMT
- in seconds will be returned for the time zone.
- DaylightGmtOffset - Supplies an optional pointer where the offset from GMT
- in seconds during Daylight Saving will be returned.
- Return Value:
- None.
- --*/
- RTL_API
- KSTATUS
- RtlSelectTimeZone (
- PSTR ZoneName,
- PSTR OriginalZoneBuffer,
- PULONG OriginalZoneBufferSize
- );
- /*++
- Routine Description:
- This routine selects a time zone from the current set of data.
- Arguments:
- ZoneName - Supplies an optional pointer to a null terminated string
- containing the name of the time zone. If this parameter is NULL then
- the current time zone will simply be returned.
- OriginalZoneBuffer - Supplies an optional pointer where the original (or
- current if no new time zone was provided) time zone will be returned.
- OriginalZoneBufferSize - Supplies a pointer that on input contains the
- size of the original zone buffer in bytes. On output, this value will
- contain the size of the original zone buffer needed to contain the
- name of the current time zone (even if no buffer was provided).
- Return Value:
- STATUS_SUCCESS on success.
- STATUS_NOT_FOUND if a time zone with the given name could not be found.
- STATUS_NO_DATA_AVAILABLE if no time zone data has been set yet.
- STATUS_BUFFER_TOO_SMALL if the buffer provided to get the original time
- zone name was too small. If this is the case, the new time zone will
- not have been set.
- --*/
- RTL_API
- KSTATUS
- RtlSystemTimeToLocalCalendarTime (
- PSYSTEM_TIME SystemTime,
- PCALENDAR_TIME CalendarTime
- );
- /*++
- Routine Description:
- This routine converts the given system time into calendar time in the
- current local time zone.
- Arguments:
- SystemTime - Supplies a pointer to the system time to convert.
- CalendarTime - Supplies a pointer to the calendar time to initialize based
- on the given system time.
- Return Value:
- STATUS_SUCCESS on success.
- STATUS_OUT_OF_BOUNDS if the given system time is too funky.
- --*/
- RTL_API
- KSTATUS
- RtlLocalCalendarTimeToSystemTime (
- PCALENDAR_TIME CalendarTime,
- PSYSTEM_TIME SystemTime
- );
- /*++
- Routine Description:
- This routine converts the given calendar time, assumed to be a local date
- and time, into its corresponding system time. On success, this routine will
- update the supplied calendar time to fill out all fields. The GMT offset
- of the supplied calendar time will be ignored in favor or the local time
- zone's GMT offset.
- Arguments:
- CalendarTime - Supplies a pointer to the local calendar time to convert.
- SystemTime - Supplies a pointer where the system time will be returned.
- Return Value:
- STATUS_SUCCESS on success.
- STATUS_OUT_OF_BOUNDS if the given local calendar time is too funky.
- --*/
- RTL_API
- VOID
- RtlDebugPrintTimeZoneData (
- PVOID Data,
- ULONG DataSize
- );
- /*++
- Routine Description:
- This routine debug prints the given time zone data.
- Arguments:
- Data - Supplies a pointer to the time zone data to debug print. If this
- is NULL, the current data will be used.
- DataSize - Supplies the size of the data in bytes.
- Return Value:
- None.
- --*/
- RTL_API
- VOID
- RtlHeapInitialize (
- PMEMORY_HEAP Heap,
- PHEAP_ALLOCATE AllocateFunction,
- PHEAP_FREE FreeFunction,
- PHEAP_CORRUPTION_ROUTINE CorruptionFunction,
- UINTN MinimumExpansionSize,
- UINTN ExpansionGranularity,
- UINTN AllocationTag,
- ULONG Flags
- );
- /*++
- Routine Description:
- This routine initializes a memory heap. It does not initialize emergency
- resources.
- Arguments:
- Heap - Supplies the heap to initialize.
- AllocateFunction - Supplies a pointer to a function the heap calls when it
- wants to expand and needs more memory.
- FreeFunction - Supplies a pointer to a function the heap calls when it
- wants to free a previously allocated segment.
- CorruptionFunction - Supplies a pointer to a function to call if heap
- corruption is detected.
- MinimumExpansionSize - Supplies the minimum number of bytes to request
- when expanding the heap.
- ExpansionGranularity - Supplies the granularity of expansions, in bytes.
- This must be a power of two.
- AllocationTag - Supplies the magic number to put in each allocation. This
- is also the tag supplied when the allocation function above is called.
- Flags - Supplies a bitfield of flags governing the heap's behavior. See
- MEMORY_HEAP_FLAG_* definitions.
- Return Value:
- None.
- --*/
- RTL_API
- VOID
- RtlHeapDestroy (
- PMEMORY_HEAP Heap
- );
- /*++
- Routine Description:
- This routine destroys a memory heap, releasing all resources it was
- managing. The structure itself is owned by the caller, so that isn't freed.
- Arguments:
- Heap - Supplies the heap to destroy.
- Return Value:
- None. The heap and all its allocations are no longer usable.
- --*/
- RTL_API
- PVOID
- RtlHeapAllocate (
- PMEMORY_HEAP Heap,
- UINTN Size,
- UINTN Tag
- );
- /*++
- Routine Description:
- This routine allocates memory from a given heap.
- Arguments:
- Heap - Supplies the heap to allocate from.
- Size - Supplies the size of the allocation request, in bytes.
- Tag - Supplies an identification tag to mark this allocation with.
- Return Value:
- Returns a pointer to the allocation if successful, or NULL if the
- allocation failed.
- --*/
- RTL_API
- PVOID
- RtlHeapReallocate (
- PMEMORY_HEAP Heap,
- PVOID Memory,
- UINTN NewSize,
- UINTN AllocationTag
- );
- /*++
- Routine Description:
- This routine resizes the given allocation, potentially creating a new
- buffer and copying the old contents in.
- Arguments:
- Heap - Supplies a pointer to the heap to work with.
- Memory - Supplies the original active allocation. If this parameter is
- NULL, this routine will simply allocate memory.
- NewSize - Supplies the new required size of the allocation. If this is
- 0, then the original allocation will simply be freed.
- AllocationTag - Supplies an identifier for this allocation.
- Return Value:
- Returns a pointer to a buffer with the new size (and original contents) on
- success. This may be a new buffer or the same one.
- NULL on failure or if the new size supplied was zero.
- --*/
- RTL_API
- KSTATUS
- RtlHeapAlignedAllocate (
- PMEMORY_HEAP Heap,
- PVOID *Memory,
- UINTN Alignment,
- UINTN Size,
- UINTN Tag
- );
- /*++
- Routine Description:
- This routine allocates aligned memory from a given heap.
- Arguments:
- Heap - Supplies the heap to allocate from.
- Memory - Supplies a pointer that receives the pointer to the aligned
- allocation on success.
- Alignment - Supplies the requested alignment for the allocation, in bytes.
- Size - Supplies the size of the allocation request, in bytes.
- Tag - Supplies an identification tag to mark this allocation with.
- Return Value:
- Status code.
- --*/
- RTL_API
- VOID
- RtlHeapFree (
- PMEMORY_HEAP Heap,
- PVOID Memory
- );
- /*++
- Routine Description:
- This routine frees memory, making it available for other users in the heap.
- This routine may potentially contract the heap periodically.
- Arguments:
- Heap - Supplies the heap to free the memory back to.
- Memory - Supplies the allocation created by the heap allocation routine.
- Return Value:
- None.
- --*/
- RTL_API
- VOID
- RtlHeapProfilerGetStatistics (
- PMEMORY_HEAP Heap,
- PVOID Buffer,
- ULONG BufferSize
- );
- /*++
- Routine Description:
- This routine fills the given buffer with the current heap statistics.
- Arguments:
- Heap - Supplies a pointer to the heap.
- Buffer - Supplies the buffer to fill with heap statistics.
- BufferSize - Supplies the size of the buffer.
- Return Value:
- None.
- --*/
- RTL_API
- VOID
- RtlHeapDebugPrintStatistics (
- PMEMORY_HEAP Heap
- );
- /*++
- Routine Description:
- This routine prints current heap statistics to the debugger.
- Arguments:
- Heap - Supplies a pointer to the heap to print.
- Return Value:
- None.
- --*/
- RTL_API
- VOID
- RtlValidateHeap (
- PMEMORY_HEAP Heap,
- PHEAP_CORRUPTION_ROUTINE CorruptionRoutine
- );
- /*++
- Routine Description:
- This routine validates a memory heap for consistency, ensuring that no
- corruption or other errors are present in the heap.
- Arguments:
- Heap - Supplies a pointer to the heap to validate.
- CorruptionRoutine - Supplies an optional pointer to a routine to call if
- corruption is detected. If not supplied, the internal one supplied when
- the heap was initialized will be used.
- Return Value:
- None.
- --*/
- RTL_API
- ULONG
- RtlGetSystemVersionString (
- PSYSTEM_VERSION_INFORMATION VersionInformation,
- SYSTEM_VERSION_STRING_VERBOSITY Level,
- PCHAR Buffer,
- ULONG BufferSize
- );
- /*++
- Routine Description:
- This routine gets the system string.
- Arguments:
- VersionInformation - Supplies a pointer to the initialized version
- information to convert to a string.
- Level - Supplies the level of detail to print.
- Buffer - Supplies a pointer to the buffer that receives the version
- information.
- BufferSize - Supplies the size of the supplied buffer in bytes.
- Return Value:
- Returns the size of the string as written to the buffer, including the
- null terminator.
- --*/
- RTL_API
- PSTR
- RtlGetReleaseLevelString (
- SYSTEM_RELEASE_LEVEL Level
- );
- /*++
- Routine Description:
- This routine returns a string corresponding with the given release level.
- Arguments:
- Level - Supplies the release level.
- Return Value:
- Returns a pointer to a static the string describing the given release
- level. The caller should not attempt to modify or free this memory.
- --*/
- RTL_API
- PSTR
- RtlGetBuildDebugLevelString (
- SYSTEM_BUILD_DEBUG_LEVEL Level
- );
- /*++
- Routine Description:
- This routine returns a string corresponding with the given build debug
- level.
- Arguments:
- Level - Supplies the build debug level.
- Return Value:
- Returns a pointer to a static the string describing the given build debug
- level. The caller should not attempt to modify or free this memory.
- --*/
|