pal.h 176 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929
  1. //
  2. // Copyright (c) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
  4. //
  5. /*++
  6. Module Name:
  7. pal.h
  8. Abstract:
  9. Rotor Platform Adaptation Layer (PAL) header file. This file
  10. defines all types and API calls required by the Rotor port of
  11. the Microsoft Common Language Runtime.
  12. Defines which control the behavior of this include file:
  13. UNICODE - define it to set the Ansi/Unicode neutral names to
  14. be the ...W names. Otherwise the neutral names default
  15. to be the ...A names.
  16. PAL_IMPLEMENTATION - define it when implementing the PAL. Otherwise
  17. leave it undefined when consuming the PAL.
  18. Note: some fields in structs have been renamed from the original
  19. SDK documentation names, with _PAL_Undefined appended. This leaves
  20. the structure layout identical to its Win32 version, but prevents
  21. PAL consumers from inadvertently referencing undefined fields.
  22. If you want to add a PAL_ wrapper function to a native function in
  23. here, you also need to edit palinternal.h and win32pal.h.
  24. --*/
  25. #ifndef __PAL_H__
  26. #define __PAL_H__
  27. #ifdef PAL_STDCPP_COMPAT
  28. #include <stddef.h>
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <stdarg.h>
  32. #include <string.h>
  33. #include <errno.h>
  34. #include <ctype.h>
  35. #endif
  36. #if defined(__APPLE__)
  37. #ifndef __IOS__
  38. #include "TargetConditionals.h"
  39. #if TARGET_IPHONE_SIMULATOR
  40. #define __IOS__
  41. #elif TARGET_OS_IPHONE
  42. #define __IOS__
  43. #elif TARGET_OS_MAC
  44. // macOS
  45. #endif
  46. #endif // __IOS__ ?
  47. #ifndef INCLUDE_PAL_INTERNAL_
  48. namespace std {
  49. typedef decltype(nullptr) nullptr_t;
  50. }
  51. #endif
  52. #endif // __APPLE__ ?
  53. #ifdef __ANDROID__
  54. #define S_IREAD 0000400
  55. #define S_IWRITE 0000200
  56. #define S_IEXEC 0000100
  57. #ifndef CC_AND_TAG
  58. #define CC_AND_TAG "chakracore-log"
  59. #endif
  60. #include <android/log.h>
  61. #include <stdarg.h>
  62. #define PRINT_LOG(...) \
  63. __android_log_print(ANDROID_LOG_INFO, CC_AND_TAG, __VA_ARGS__)
  64. #define PRINT_ERROR(...) \
  65. __android_log_print(ANDROID_LOG_ERROR, CC_AND_TAG, __VA_ARGS__)
  66. #else
  67. typedef __builtin_va_list va_list;
  68. #define PRINT_LOG(...) \
  69. fprintf(stdout, __VA_ARGS__)
  70. #define PRINT_ERROR(...) \
  71. fprintf(stderr, __VA_ARGS__)
  72. #endif
  73. #ifdef __cplusplus
  74. extern "C" {
  75. #endif
  76. #if defined (PLATFORM_UNIX)
  77. // This macro is used to standardize the wide character string literals between UNIX and Windows.
  78. // Unix L"" is UTF32, and on windows it's UTF16. Because of built-in assumptions on the size
  79. // of string literals, it's important to match behaviour between Unix and Windows. Unix will be defined
  80. // as u"" (char16_t)
  81. #define W(str) u##str
  82. // Undefine the QUOTE_MACRO_L helper and redefine it in terms of u.
  83. // The reason that we do this is that quote macro is defined in ndp\common\inc,
  84. // not inside of coreclr sources.
  85. #define QUOTE_MACRO_L(x) QUOTE_MACRO_u(x)
  86. #define QUOTE_MACRO_u_HELPER(x) u###x
  87. #define QUOTE_MACRO_u(x) QUOTE_MACRO_u_HELPER(x)
  88. #endif
  89. #include <pal_error.h>
  90. #include <pal_mstypes.h>
  91. /******************* Processor-specific glue *****************************/
  92. #ifndef _MSC_VER
  93. #if defined(__i686__) && !defined(_M_IX86)
  94. #define _M_IX86 600
  95. #elif defined(__i586__) && !defined(_M_IX86)
  96. #define _M_IX86 500
  97. #elif defined(__i486__) && !defined(_M_IX86)
  98. #define _M_IX86 400
  99. #elif defined(__i386__) && !defined(_M_IX86)
  100. #define _M_IX86 300
  101. #elif defined(__ppc__) && !defined(_M_PPC)
  102. #define _M_PPC 100
  103. #elif defined(_AIX) && defined(_POWER) && !defined(_M_PPC)
  104. #define _M_PPC 100
  105. #elif defined(__sparc__) && !defined(_M_SPARC)
  106. #define _M_SPARC 100
  107. #elif defined(__hppa__) && !defined(_M_PARISC)
  108. #define _M_PARISC 100
  109. #elif defined(__ia64__) && !defined(_M_IA64)
  110. #define _M_IA64 64100
  111. #elif defined(__x86_64__) && !defined(_M_AMD64)
  112. #define _M_AMD64 100
  113. #elif defined(__arm__) && !defined(_M_ARM)
  114. #define _M_ARM 7
  115. #elif defined(__aarch64__) && !defined(_M_ARM64)
  116. #define _M_ARM64 1
  117. #endif
  118. #if defined(_M_IX86) && !defined(_X86_)
  119. #define _X86_
  120. #elif defined(_M_ALPHA) && !defined(_ALPHA_)
  121. #define _ALPHA_
  122. #elif defined(_M_PPC) && !defined(_PPC_)
  123. #define _PPC_
  124. #elif defined(_M_SPARC) && !defined(_SPARC_)
  125. #define _SPARC_
  126. #elif defined(_M_PARISC) && !defined(_PARISC_)
  127. #define _PARISC_
  128. #elif defined(_M_MRX000) && !defined(_MIPS_)
  129. #define _MIPS_
  130. #elif defined(_M_M68K) && !defined(_68K_)
  131. #define _68K_
  132. #elif defined(_M_IA64) && !defined(_IA64_)
  133. #define _IA64_
  134. #elif defined(_M_AMD64) && !defined(_AMD64_)
  135. #define _AMD64_
  136. #elif defined(_M_ARM) && !defined(_ARM_)
  137. #define _ARM_
  138. #elif defined(_M_ARM64) && !defined(_ARM64_)
  139. #define _ARM64_
  140. #endif
  141. #endif // !_MSC_VER
  142. /******************* ABI-specific glue *******************************/
  143. #if defined(_PPC_) || defined(_PPC64_) || defined(_SPARC_) || defined(_PARISC_) || defined(_IA64_)
  144. #define BIGENDIAN 1
  145. #endif
  146. #ifdef __APPLE__
  147. // Both PowerPC, i386 and x86_64 on Mac OS X use 16-byte alignment.
  148. #define STACK_ALIGN_BITS 4
  149. #define STACK_ALIGN_REQ (1 << STACK_ALIGN_BITS)
  150. #endif
  151. #define MAX_PATH 260
  152. #define _MAX_PATH 260
  153. #define _MAX_DRIVE 3 /* max. length of drive component */
  154. #define _MAX_DIR 256 /* max. length of path component */
  155. #define _MAX_FNAME 256 /* max. length of file name component */
  156. #define _MAX_EXT 256 /* max. length of extension component */
  157. // In some Win32 APIs MAX_PATH is used for file names (even though 256 is the normal file system limit)
  158. // use _MAX_PATH_FNAME to indicate these cases
  159. #define MAX_PATH_FNAME MAX_PATH
  160. #define MAX_LONGPATH 1024 /* max. length of full pathname */
  161. #define MAXSHORT 0x7fff
  162. #define MAXLONG 0x7fffffff
  163. #define MAXCHAR 0x7f
  164. #define MAXDWORD 0xffffffff
  165. // Sorting IDs.
  166. //
  167. // Note that the named locale APIs (eg CompareStringExEx) are recommended.
  168. //
  169. #define LANG_CHINESE 0x04
  170. #define LANG_ENGLISH 0x09
  171. #define LANG_JAPANESE 0x11
  172. #define LANG_KOREAN 0x12
  173. #define LANG_THAI 0x1e
  174. /******************* Compiler-specific glue *******************************/
  175. #define FEATURE_PAL_SXS 1
  176. #define DECLSPEC_ALIGN(x) __declspec(align(x))
  177. #define DECLSPEC_NORETURN PAL_NORETURN
  178. #define __assume(x) (void)0
  179. #define __annotation(x)
  180. #define UNALIGNED
  181. #ifndef FORCEINLINE
  182. #if _MSC_VER < 1200
  183. #define FORCEINLINE inline
  184. #else
  185. #define FORCEINLINE __forceinline
  186. #endif
  187. #endif
  188. #define PAL_GLOBAL __attribute__((init_priority(200)))
  189. /******************* PAL-Specific Entrypoints *****************************/
  190. #define IsDebuggerPresent PAL_IsDebuggerPresent
  191. PALIMPORT
  192. BOOL
  193. PALAPI
  194. PAL_IsDebuggerPresent();
  195. #define MAXIMUM_SUSPEND_COUNT MAXCHAR
  196. #define CHAR_BIT 8
  197. #define SCHAR_MIN (-128)
  198. #define SCHAR_MAX 127
  199. #define UCHAR_MAX 0xff
  200. #define SHRT_MIN (-32768)
  201. #define SHRT_MAX 32767
  202. #define USHRT_MAX 0xffff
  203. #define INT_MIN (-2147483647 - 1)
  204. #define INT_MAX 2147483647
  205. #define UINT_MAX 0xffffffff
  206. #define LONG_MIN (-2147483647L - 1)
  207. #define LONG_MAX 2147483647L
  208. #define ULONG_MAX 0xffffffffUL
  209. #define LONGLONG_MIN (-9223372036854775807i64 - 1)
  210. #define LONG64_MIN (-9223372036854775807i64 - 1)
  211. #define INT64_MIN (-9223372036854775807i64 - 1)
  212. #define LONGLONG_MAX 9223372036854775807i64
  213. #define LONG64_MAX 9223372036854775807i64
  214. #define INT64_MAX 9223372036854775807i64
  215. #define ULONGLONG_MAX 0xffffffffffffffffui64
  216. #define DWORDLONG_MAX 0xffffffffffffffffui64
  217. #define ULONG64_MAX 0xffffffffffffffffui64
  218. #define DWORD64_MAX 0xffffffffffffffffui64
  219. #define UINT64_MAX 0xffffffffffffffffui64
  220. #define FLT_MAX 3.402823466e+38F
  221. #define DBL_MAX 1.7976931348623157e+308
  222. /* minimum signed 64 bit value */
  223. #define _I64_MIN (I64(-9223372036854775807) - 1)
  224. /* maximum signed 64 bit value */
  225. #define _I64_MAX I64(9223372036854775807)
  226. /* maximum unsigned 64 bit value */
  227. #define _UI64_MAX UI64(0xffffffffffffffff)
  228. #define _I8_MAX SCHAR_MAX
  229. #define _I8_MIN SCHAR_MIN
  230. #define _I16_MAX SHRT_MAX
  231. #define _I16_MIN SHRT_MIN
  232. #define _I32_MAX INT_MAX
  233. #define _I32_MIN INT_MIN
  234. #define _UI8_MAX UCHAR_MAX
  235. #define _UI8_MIN UCHAR_MIN
  236. #define _UI16_MAX USHRT_MAX
  237. #define _UI16_MIN USHRT_MIN
  238. #define _UI32_MAX UINT_MAX
  239. #define _UI32_MIN UINT_MIN
  240. #ifdef PAL_STDCPP_COMPAT
  241. #undef NULL
  242. #endif
  243. #ifndef NULL
  244. #if defined(__cplusplus)
  245. #define NULL 0
  246. #else
  247. #define NULL ((void *)0)
  248. #endif
  249. #endif
  250. #if defined(PAL_STDCPP_COMPAT) && !defined(__cplusplus)
  251. #define nullptr NULL
  252. #endif // defined(PAL_STDCPP_COMPAT) && !defined(__cplusplus)
  253. #ifndef PAL_STDCPP_COMPAT
  254. typedef ULONG64 fpos_t;
  255. #if _WIN64 || _MSC_VER >= 1400
  256. typedef __int64 time_t;
  257. #else
  258. typedef long time_t;
  259. #endif
  260. #define _TIME_T_DEFINED
  261. #endif // !PAL_STDCPP_COMPAT
  262. #if ENABLE_DOWNLEVEL_FOR_NLS
  263. #define MAKELCID(lgid, srtid) ((DWORD)((((DWORD)((WORD )(srtid))) << 16) | \
  264. ((DWORD)((WORD )(lgid)))))
  265. #define LANGIDFROMLCID(lcid) ((WORD)(lcid))
  266. #define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0xf))
  267. #define LANG_NEUTRAL 0x00
  268. #define LANG_INVARIANT 0x7f
  269. #define SUBLANG_NEUTRAL 0x00 // language neutral
  270. #define SUBLANG_DEFAULT 0x01 // user default
  271. #define SORT_DEFAULT 0x0 // sorting default
  272. #define SUBLANG_SYS_DEFAULT 0x02 // system default
  273. #define MAKELANGID(p, s) ((((WORD )(s)) << 10) | (WORD )(p))
  274. #define PRIMARYLANGID(lgid) ((WORD )(lgid) & 0x3ff)
  275. #define SUBLANGID(lgid) ((WORD )(lgid) >> 10)
  276. #define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
  277. #define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
  278. #define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
  279. #define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
  280. #define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), SORT_DEFAULT))
  281. #define LOCALE_US_ENGLISH (MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT))
  282. #define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT, SUBLANG_NEUTRAL), SORT_DEFAULT))
  283. #define SUBLANG_ENGLISH_US 0x01
  284. #define SUBLANG_CHINESE_TRADITIONAL 0x01 /* Chinese (Traditional) */
  285. #endif // ENABLE_DOWNLEVEL_FOR_NLS
  286. #define CT_CTYPE1 0x00000001 /* ctype 1 information */
  287. #define CT_CTYPE2 0x00000002 /* ctype 2 information */
  288. #define CT_CTYPE3 0x00000004 /* ctype 3 information */
  289. #define C1_UPPER 0x0001 /* upper case */
  290. #define C1_LOWER 0x0002 /* lower case */
  291. #define C1_DIGIT 0x0004 /* decimal digits */
  292. #define C1_SPACE 0x0008 /* spacing characters */
  293. #define C1_PUNCT 0x0010 /* punctuation characters */
  294. #define C1_CNTRL 0x0020 /* control characters */
  295. #define C1_BLANK 0x0040 /* blank characters */
  296. #define C1_XDIGIT 0x0080 /* other digits */
  297. #define C1_ALPHA 0x0100 /* any linguistic character */
  298. #define C2_LEFTTORIGHT 0x0001 /* left to right */
  299. #define C2_RIGHTTOLEFT 0x0002 /* right to left */
  300. #define C2_EUROPENUMBER 0x0003 /* European number, digit */
  301. #define C2_EUROPESEPARATOR 0x0004 /* European numeric separator */
  302. #define C2_EUROPETERMINATOR 0x0005 /* European numeric terminator */
  303. #define C2_ARABICNUMBER 0x0006 /* Arabic number */
  304. #define C2_COMMONSEPARATOR 0x0007 /* common numeric separator */
  305. #define C2_BLOCKSEPARATOR 0x0008 /* block separator */
  306. #define C2_SEGMENTSEPARATOR 0x0009 /* segment separator */
  307. #define C2_WHITESPACE 0x000A /* white space */
  308. #define C2_OTHERNEUTRAL 0x000B /* other neutrals */
  309. #define C2_NOTAPPLICABLE 0x0000 /* no implicit directionality */
  310. #define C3_NONSPACING 0x0001 /* nonspacing character */
  311. #define C3_DIACRITIC 0x0002 /* diacritic mark */
  312. #define C3_VOWELMARK 0x0004 /* vowel mark */
  313. #define C3_SYMBOL 0x0008 /* symbols */
  314. #define C3_KATAKANA 0x0010 /* katakana character */
  315. #define C3_HIRAGANA 0x0020 /* hiragana character */
  316. #define C3_HALFWIDTH 0x0040 /* half width character */
  317. #define C3_FULLWIDTH 0x0080 /* full width character */
  318. #define C3_IDEOGRAPH 0x0100 /* ideographic character */
  319. #define C3_KASHIDA 0x0200 /* Arabic kashida character */
  320. #define C3_LEXICAL 0x0400 /* lexical character */
  321. #define C3_ALPHA 0x8000 /* any ling. char (C1_ALPHA) */
  322. #define C3_NOTAPPLICABLE 0x0000 /* ctype 3 is not applicable */
  323. #define DLL_PROCESS_ATTACH 1
  324. #define DLL_THREAD_ATTACH 2
  325. #define DLL_THREAD_DETACH 3
  326. #define DLL_PROCESS_DETACH 0
  327. typedef DWORD (PALAPI *PTHREAD_START_ROUTINE)(LPVOID lpThreadParameter);
  328. typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
  329. /******************* PAL-Specific Entrypoints *****************************/
  330. int
  331. PALAPI
  332. PAL_InitializeChakraCore();
  333. /// <summary>
  334. /// This function shuts down PAL WITHOUT exiting the current process.
  335. /// </summary>
  336. PALIMPORT
  337. void
  338. PALAPI
  339. PAL_Shutdown(
  340. void);
  341. /// <summary>
  342. /// This function shuts down PAL and exits the current process.
  343. /// </summary>
  344. PALIMPORT
  345. void
  346. PALAPI
  347. PAL_Terminate(
  348. void);
  349. /// <summary>
  350. /// This function shuts down PAL and exits the current process with
  351. /// the specified exit code.
  352. /// </summary>
  353. PALIMPORT
  354. void
  355. PALAPI
  356. PAL_TerminateEx(
  357. int exitCode);
  358. PALIMPORT
  359. VOID
  360. PALAPI
  361. PAL_UnregisterModule(
  362. IN HINSTANCE hInstance);
  363. PALIMPORT
  364. BOOL
  365. PALAPI
  366. PAL_GetPALDirectoryW(
  367. OUT LPWSTR lpDirectoryName,
  368. IN UINT cchDirectoryName);
  369. PALIMPORT
  370. BOOL
  371. PALAPI
  372. PAL_GetPALDirectoryA(
  373. OUT LPSTR lpDirectoryName,
  374. IN UINT cchDirectoryName);
  375. #ifdef UNICODE
  376. #define PAL_GetPALDirectory PAL_GetPALDirectoryW
  377. #else
  378. #define PAL_GetPALDirectory PAL_GetPALDirectoryA
  379. #endif
  380. PALIMPORT
  381. BOOL
  382. PALAPI
  383. PAL_Random(
  384. IN BOOL bStrong,
  385. IN OUT LPVOID lpBuffer,
  386. IN DWORD dwLength);
  387. #ifdef PLATFORM_UNIX
  388. PALIMPORT
  389. DWORD
  390. PALAPI
  391. PAL_CreateExecWatchpoint(
  392. HANDLE hThread,
  393. PVOID pvInstruction
  394. );
  395. PALIMPORT
  396. DWORD
  397. PALAPI
  398. PAL_DeleteExecWatchpoint(
  399. HANDLE hThread,
  400. PVOID pvInstruction
  401. );
  402. #endif
  403. /******************* winuser.h Entrypoints *******************************/
  404. PALIMPORT
  405. LPSTR
  406. PALAPI
  407. CharNextA(
  408. IN LPCSTR lpsz);
  409. PALIMPORT
  410. LPSTR
  411. PALAPI
  412. CharNextExA(
  413. IN WORD CodePage,
  414. IN LPCSTR lpCurrentChar,
  415. IN DWORD dwFlags);
  416. #ifndef UNICODE
  417. #define CharNext CharNextA
  418. #define CharNextEx CharNextExA
  419. #endif
  420. extern int sprintf_s(char *_Dst, size_t _SizeInBytes, const char *_Format, ...);
  421. typedef int errno_t;
  422. extern errno_t _ultow_s(unsigned long inValue, WCHAR* outBuffer, size_t inDestBufferSize, int inRadix );
  423. extern errno_t _ui64tow_s(unsigned long long inValue, WCHAR* outBuffer, size_t inDestBufferSize, int inRadix );
  424. PALIMPORT
  425. int
  426. PALAPIV
  427. wsprintfA(
  428. OUT LPSTR,
  429. IN LPCSTR,
  430. ...);
  431. PALIMPORT
  432. int
  433. PALAPIV
  434. wsprintfW(
  435. OUT LPWSTR,
  436. IN LPCWSTR,
  437. ...);
  438. #ifdef UNICODE
  439. #define wsprintf wsprintfW
  440. #else
  441. #define wsprintf wsprintfA
  442. #endif
  443. // From win32.h
  444. #ifndef _CRTIMP
  445. #ifdef __llvm__
  446. #define _CRTIMP
  447. #else // __llvm__
  448. #define _CRTIMP __declspec(dllimport)
  449. #endif // __llvm__
  450. #endif // _CRTIMP
  451. /******************* winbase.h Entrypoints and defines ************************/
  452. PALIMPORT
  453. BOOL
  454. PALAPI
  455. AreFileApisANSI(
  456. VOID);
  457. typedef struct _SECURITY_ATTRIBUTES {
  458. DWORD nLength;
  459. LPVOID lpSecurityDescriptor;
  460. BOOL bInheritHandle;
  461. } SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
  462. #define _SH_DENYWR 0x20 /* deny write mode */
  463. #define FILE_READ_DATA ( 0x0001 ) // file & pipe
  464. #define FILE_APPEND_DATA ( 0x0004 ) // file
  465. #define GENERIC_READ (0x80000000L)
  466. #define GENERIC_WRITE (0x40000000L)
  467. #define FILE_SHARE_READ 0x00000001
  468. #define FILE_SHARE_WRITE 0x00000002
  469. #define FILE_SHARE_DELETE 0x00000004
  470. #define CREATE_NEW 1
  471. #define CREATE_ALWAYS 2
  472. #define OPEN_EXISTING 3
  473. #define OPEN_ALWAYS 4
  474. #define TRUNCATE_EXISTING 5
  475. #define FILE_ATTRIBUTE_READONLY 0x00000001
  476. #define FILE_ATTRIBUTE_HIDDEN 0x00000002
  477. #define FILE_ATTRIBUTE_SYSTEM 0x00000004
  478. #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
  479. #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
  480. #define FILE_ATTRIBUTE_DEVICE 0x00000040
  481. #define FILE_ATTRIBUTE_NORMAL 0x00000080
  482. #define FILE_FLAG_WRITE_THROUGH 0x80000000
  483. #define FILE_FLAG_NO_BUFFERING 0x20000000
  484. #define FILE_FLAG_RANDOM_ACCESS 0x10000000
  485. #define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000
  486. #define FILE_FLAG_BACKUP_SEMANTICS 0x02000000
  487. #define FILE_BEGIN 0
  488. #define FILE_CURRENT 1
  489. #define FILE_END 2
  490. #define STILL_ACTIVE (0x00000103L)
  491. #define INVALID_SET_FILE_POINTER ((DWORD)-1)
  492. PALIMPORT
  493. HANDLE
  494. PALAPI
  495. CreateFileA(
  496. IN LPCSTR lpFileName,
  497. IN DWORD dwDesiredAccess,
  498. IN DWORD dwShareMode,
  499. IN LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  500. IN DWORD dwCreationDisposition,
  501. IN DWORD dwFlagsAndAttributes,
  502. IN HANDLE hTemplateFile);
  503. PALIMPORT
  504. HANDLE
  505. PALAPI
  506. CreateFileW(
  507. IN LPCWSTR lpFileName,
  508. IN DWORD dwDesiredAccess,
  509. IN DWORD dwShareMode,
  510. IN LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  511. IN DWORD dwCreationDisposition,
  512. IN DWORD dwFlagsAndAttributes,
  513. IN HANDLE hTemplateFile);
  514. #ifdef UNICODE
  515. #define CreateFile CreateFileW
  516. #else
  517. #define CreateFile CreateFileA
  518. #endif
  519. PALIMPORT
  520. BOOL
  521. PALAPI
  522. LockFile(
  523. IN HANDLE hFile,
  524. IN DWORD dwFileOffsetLow,
  525. IN DWORD dwFileOffsetHigh,
  526. IN DWORD nNumberOfBytesToLockLow,
  527. IN DWORD nNumberOfBytesToLockHigh
  528. );
  529. PALIMPORT
  530. BOOL
  531. PALAPI
  532. UnlockFile(
  533. IN HANDLE hFile,
  534. IN DWORD dwFileOffsetLow,
  535. IN DWORD dwFileOffsetHigh,
  536. IN DWORD nNumberOfBytesToUnlockLow,
  537. IN DWORD nNumberOfBytesToUnlockHigh
  538. );
  539. PALIMPORT
  540. DWORD
  541. PALAPI
  542. SearchPathA(
  543. IN LPCSTR lpPath,
  544. IN LPCSTR lpFileName,
  545. IN LPCSTR lpExtension,
  546. IN DWORD nBufferLength,
  547. OUT LPSTR lpBuffer,
  548. OUT LPSTR *lpFilePart
  549. );
  550. PALIMPORT
  551. DWORD
  552. PALAPI
  553. SearchPathW(
  554. IN LPCWSTR lpPath,
  555. IN LPCWSTR lpFileName,
  556. IN LPCWSTR lpExtension,
  557. IN DWORD nBufferLength,
  558. OUT LPWSTR lpBuffer,
  559. OUT LPWSTR *lpFilePart
  560. );
  561. #ifdef UNICODE
  562. #define SearchPath SearchPathW
  563. #else
  564. #define SearchPath SearchPathA
  565. #endif // !UNICODE
  566. PALIMPORT
  567. BOOL
  568. PALAPI
  569. CopyFileA(
  570. IN LPCSTR lpExistingFileName,
  571. IN LPCSTR lpNewFileName,
  572. IN BOOL bFailIfExists);
  573. PALIMPORT
  574. BOOL
  575. PALAPI
  576. CopyFileW(
  577. IN LPCWSTR lpExistingFileName,
  578. IN LPCWSTR lpNewFileName,
  579. IN BOOL bFailIfExists);
  580. #ifdef UNICODE
  581. #define CopyFile CopyFileW
  582. #else
  583. #define CopyFile CopyFileA
  584. #endif
  585. PALIMPORT
  586. BOOL
  587. PALAPI
  588. DeleteFileA(
  589. IN LPCSTR lpFileName);
  590. PALIMPORT
  591. BOOL
  592. PALAPI
  593. DeleteFileW(
  594. IN LPCWSTR lpFileName);
  595. #ifdef UNICODE
  596. #define DeleteFile DeleteFileW
  597. #else
  598. #define DeleteFile DeleteFileA
  599. #endif
  600. PALIMPORT
  601. BOOL
  602. PALAPI
  603. MoveFileA(
  604. IN LPCSTR lpExistingFileName,
  605. IN LPCSTR lpNewFileName);
  606. PALIMPORT
  607. BOOL
  608. PALAPI
  609. MoveFileW(
  610. IN LPCWSTR lpExistingFileName,
  611. IN LPCWSTR lpNewFileName);
  612. #ifdef UNICODE
  613. #define MoveFile MoveFileW
  614. #else
  615. #define MoveFile MoveFileA
  616. #endif
  617. #define MOVEFILE_REPLACE_EXISTING 0x00000001
  618. #define MOVEFILE_COPY_ALLOWED 0x00000002
  619. PALIMPORT
  620. BOOL
  621. PALAPI
  622. MoveFileExA(
  623. IN LPCSTR lpExistingFileName,
  624. IN LPCSTR lpNewFileName,
  625. IN DWORD dwFlags);
  626. PALIMPORT
  627. BOOL
  628. PALAPI
  629. MoveFileExW(
  630. IN LPCWSTR lpExistingFileName,
  631. IN LPCWSTR lpNewFileName,
  632. IN DWORD dwFlags);
  633. #ifdef UNICODE
  634. #define MoveFileEx MoveFileExW
  635. #else
  636. #define MoveFileEx MoveFileExA
  637. #endif
  638. PALIMPORT
  639. BOOL
  640. PALAPI
  641. CreateDirectoryA(
  642. IN LPCSTR lpPathName,
  643. IN LPSECURITY_ATTRIBUTES lpSecurityAttributes);
  644. PALIMPORT
  645. BOOL
  646. PALAPI
  647. CreateDirectoryW(
  648. IN LPCWSTR lpPathName,
  649. IN LPSECURITY_ATTRIBUTES lpSecurityAttributes);
  650. #ifdef UNICODE
  651. #define CreateDirectory CreateDirectoryW
  652. #else
  653. #define CreateDirectory CreateDirectoryA
  654. #endif
  655. PALIMPORT
  656. BOOL
  657. PALAPI
  658. RemoveDirectoryW(
  659. IN LPCWSTR lpPathName);
  660. PALIMPORT
  661. BOOL
  662. PALAPI
  663. RemoveDirectoryA(
  664. IN LPCSTR lpPathName);
  665. #ifdef UNICODE
  666. #define RemoveDirectory RemoveDirectoryW
  667. #else
  668. #define RemoveDirectory RemoveDirectoryA
  669. #endif
  670. typedef struct _BY_HANDLE_FILE_INFORMATION {
  671. DWORD dwFileAttributes;
  672. FILETIME ftCreationTime;
  673. FILETIME ftLastAccessTime;
  674. FILETIME ftLastWriteTime;
  675. DWORD dwVolumeSerialNumber;
  676. DWORD nFileSizeHigh;
  677. DWORD nFileSizeLow;
  678. DWORD nNumberOfLinks;
  679. DWORD nFileIndexHigh;
  680. DWORD nFileIndexLow;
  681. } BY_HANDLE_FILE_INFORMATION, *PBY_HANDLE_FILE_INFORMATION, *LPBY_HANDLE_FILE_INFORMATION;
  682. typedef struct _WIN32_FIND_DATAA {
  683. DWORD dwFileAttributes;
  684. FILETIME ftCreationTime;
  685. FILETIME ftLastAccessTime;
  686. FILETIME ftLastWriteTime;
  687. DWORD nFileSizeHigh;
  688. DWORD nFileSizeLow;
  689. DWORD dwReserved0;
  690. DWORD dwReserved1;
  691. CHAR cFileName[ MAX_PATH_FNAME ];
  692. CHAR cAlternateFileName[ 14 ];
  693. } WIN32_FIND_DATAA, *PWIN32_FIND_DATAA, *LPWIN32_FIND_DATAA;
  694. typedef struct _WIN32_FIND_DATAW {
  695. DWORD dwFileAttributes;
  696. FILETIME ftCreationTime;
  697. FILETIME ftLastAccessTime;
  698. FILETIME ftLastWriteTime;
  699. DWORD nFileSizeHigh;
  700. DWORD nFileSizeLow;
  701. DWORD dwReserved0;
  702. DWORD dwReserved1;
  703. WCHAR cFileName[ MAX_PATH_FNAME ];
  704. WCHAR cAlternateFileName[ 14 ];
  705. } WIN32_FIND_DATAW, *PWIN32_FIND_DATAW, *LPWIN32_FIND_DATAW;
  706. #ifdef UNICODE
  707. typedef WIN32_FIND_DATAW WIN32_FIND_DATA;
  708. typedef PWIN32_FIND_DATAW PWIN32_FIND_DATA;
  709. typedef LPWIN32_FIND_DATAW LPWIN32_FIND_DATA;
  710. #else
  711. typedef WIN32_FIND_DATAA WIN32_FIND_DATA;
  712. typedef PWIN32_FIND_DATAA PWIN32_FIND_DATA;
  713. typedef LPWIN32_FIND_DATAA LPWIN32_FIND_DATA;
  714. #endif
  715. PALIMPORT
  716. HANDLE
  717. PALAPI
  718. FindFirstFileA(
  719. IN LPCSTR lpFileName,
  720. OUT LPWIN32_FIND_DATAA lpFindFileData);
  721. PALIMPORT
  722. HANDLE
  723. PALAPI
  724. FindFirstFileW(
  725. IN LPCWSTR lpFileName,
  726. OUT LPWIN32_FIND_DATAW lpFindFileData);
  727. #ifdef UNICODE
  728. #define FindFirstFile FindFirstFileW
  729. #else
  730. #define FindFirstFile FindFirstFileA
  731. #endif
  732. PALIMPORT
  733. BOOL
  734. PALAPI
  735. FindNextFileA(
  736. IN HANDLE hFindFile,
  737. OUT LPWIN32_FIND_DATAA lpFindFileData);
  738. PALIMPORT
  739. BOOL
  740. PALAPI
  741. FindNextFileW(
  742. IN HANDLE hFindFile,
  743. OUT LPWIN32_FIND_DATAW lpFindFileData);
  744. #ifdef UNICODE
  745. #define FindNextFile FindNextFileW
  746. #else
  747. #define FindNextFile FindNextFileA
  748. #endif
  749. PALIMPORT
  750. BOOL
  751. PALAPI
  752. FindClose(
  753. IN OUT HANDLE hFindFile);
  754. PALIMPORT
  755. DWORD
  756. PALAPI
  757. GetFileAttributesA(
  758. IN LPCSTR lpFileName);
  759. PALIMPORT
  760. DWORD
  761. PALAPI
  762. GetFileAttributesW(
  763. IN LPCWSTR lpFileName);
  764. #ifdef UNICODE
  765. #define GetFileAttributes GetFileAttributesW
  766. #else
  767. #define GetFileAttributes GetFileAttributesA
  768. #endif
  769. typedef enum _GET_FILEEX_INFO_LEVELS {
  770. GetFileExInfoStandard
  771. } GET_FILEEX_INFO_LEVELS;
  772. typedef struct _WIN32_FILE_ATTRIBUTE_DATA {
  773. DWORD dwFileAttributes;
  774. FILETIME ftCreationTime;
  775. FILETIME ftLastAccessTime;
  776. FILETIME ftLastWriteTime;
  777. DWORD nFileSizeHigh;
  778. DWORD nFileSizeLow;
  779. } WIN32_FILE_ATTRIBUTE_DATA, *LPWIN32_FILE_ATTRIBUTE_DATA;
  780. PALIMPORT
  781. BOOL
  782. PALAPI
  783. GetFileAttributesExW(
  784. IN LPCWSTR lpFileName,
  785. IN GET_FILEEX_INFO_LEVELS fInfoLevelId,
  786. OUT LPVOID lpFileInformation);
  787. #ifdef UNICODE
  788. #define GetFileAttributesEx GetFileAttributesExW
  789. #endif
  790. PALIMPORT
  791. BOOL
  792. PALAPI
  793. SetFileAttributesA(
  794. IN LPCSTR lpFileName,
  795. IN DWORD dwFileAttributes);
  796. PALIMPORT
  797. BOOL
  798. PALAPI
  799. SetFileAttributesW(
  800. IN LPCWSTR lpFileName,
  801. IN DWORD dwFileAttributes);
  802. #ifdef UNICODE
  803. #define SetFileAttributes SetFileAttributesW
  804. #else
  805. #define SetFileAttributes SetFileAttributesA
  806. #endif
  807. typedef LPVOID LPOVERLAPPED; // diff from winbase.h
  808. PALIMPORT
  809. BOOL
  810. PALAPI
  811. WriteFile(
  812. IN HANDLE hFile,
  813. IN LPCVOID lpBuffer,
  814. IN DWORD nNumberOfBytesToWrite,
  815. OUT LPDWORD lpNumberOfBytesWritten,
  816. IN LPOVERLAPPED lpOverlapped);
  817. PALIMPORT
  818. BOOL
  819. PALAPI
  820. ReadFile(
  821. IN HANDLE hFile,
  822. OUT LPVOID lpBuffer,
  823. IN DWORD nNumberOfBytesToRead,
  824. OUT LPDWORD lpNumberOfBytesRead,
  825. IN LPOVERLAPPED lpOverlapped);
  826. #define STD_INPUT_HANDLE ((DWORD)-10)
  827. #define STD_OUTPUT_HANDLE ((DWORD)-11)
  828. #define STD_ERROR_HANDLE ((DWORD)-12)
  829. PALIMPORT
  830. HANDLE
  831. PALAPI
  832. GetStdHandle(
  833. IN DWORD nStdHandle);
  834. PALIMPORT
  835. BOOL
  836. PALAPI
  837. SetEndOfFile(
  838. IN HANDLE hFile);
  839. PALIMPORT
  840. DWORD
  841. PALAPI
  842. SetFilePointer(
  843. IN HANDLE hFile,
  844. IN LONG lDistanceToMove,
  845. IN PLONG lpDistanceToMoveHigh,
  846. IN DWORD dwMoveMethod);
  847. PALIMPORT
  848. BOOL
  849. PALAPI
  850. SetFilePointerEx(
  851. IN HANDLE hFile,
  852. IN LARGE_INTEGER liDistanceToMove,
  853. OUT PLARGE_INTEGER lpNewFilePointer,
  854. IN DWORD dwMoveMethod);
  855. PALIMPORT
  856. DWORD
  857. PALAPI
  858. GetFileSize(
  859. IN HANDLE hFile,
  860. OUT LPDWORD lpFileSizeHigh);
  861. PALIMPORT
  862. BOOL
  863. PALAPI GetFileSizeEx(
  864. IN HANDLE hFile,
  865. OUT PLARGE_INTEGER lpFileSize);
  866. PALIMPORT
  867. BOOL
  868. PALAPI
  869. GetFileInformationByHandle(
  870. IN HANDLE hFile,
  871. OUT BY_HANDLE_FILE_INFORMATION* lpFileInformation);
  872. PALIMPORT
  873. LONG
  874. PALAPI
  875. CompareFileTime(
  876. IN CONST FILETIME *lpFileTime1,
  877. IN CONST FILETIME *lpFileTime2);
  878. PALIMPORT
  879. BOOL
  880. PALAPI
  881. SetFileTime(
  882. IN HANDLE hFile,
  883. IN CONST FILETIME *lpCreationTime,
  884. IN CONST FILETIME *lpLastAccessTime,
  885. IN CONST FILETIME *lpLastWriteTime);
  886. PALIMPORT
  887. BOOL
  888. PALAPI
  889. GetFileTime(
  890. IN HANDLE hFile,
  891. OUT LPFILETIME lpCreationTime,
  892. OUT LPFILETIME lpLastAccessTime,
  893. OUT LPFILETIME lpLastWriteTime);
  894. PALIMPORT
  895. VOID
  896. PALAPI
  897. GetSystemTimeAsFileTime(
  898. OUT LPFILETIME lpSystemTimeAsFileTime);
  899. typedef struct _SYSTEMTIME {
  900. WORD wYear;
  901. WORD wMonth;
  902. WORD wDayOfWeek;
  903. WORD wDay;
  904. WORD wHour;
  905. WORD wMinute;
  906. WORD wSecond;
  907. WORD wMilliseconds;
  908. } SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
  909. PALIMPORT
  910. BOOL
  911. PALAPI
  912. FileTimeToSystemTime(
  913. IN CONST FILETIME *lpFileTime,
  914. OUT LPSYSTEMTIME lpSystemTime);
  915. PALIMPORT
  916. BOOL
  917. PALAPI
  918. FileTimeToDosDateTime(
  919. IN CONST FILETIME *lpFileTime,
  920. OUT LPWORD lpFatDate,
  921. OUT LPWORD lpFatTime
  922. );
  923. PALIMPORT
  924. BOOL
  925. PALAPI
  926. FlushFileBuffers(
  927. IN HANDLE hFile);
  928. #define FILE_TYPE_UNKNOWN 0x0000
  929. #define FILE_TYPE_DISK 0x0001
  930. #define FILE_TYPE_CHAR 0x0002
  931. #define FILE_TYPE_PIPE 0x0003
  932. #define FILE_TYPE_REMOTE 0x8000
  933. PALIMPORT
  934. DWORD
  935. PALAPI
  936. GetFileType(
  937. IN HANDLE hFile);
  938. PALIMPORT
  939. UINT
  940. PALAPI
  941. GetConsoleCP(
  942. VOID);
  943. PALIMPORT
  944. UINT
  945. PALAPI
  946. GetConsoleOutputCP(
  947. VOID);
  948. PALIMPORT
  949. DWORD
  950. PALAPI
  951. GetFullPathNameA(
  952. IN LPCSTR lpFileName,
  953. IN DWORD nBufferLength,
  954. OUT LPSTR lpBuffer,
  955. OUT LPSTR *lpFilePart);
  956. PALIMPORT
  957. DWORD
  958. PALAPI
  959. GetFullPathNameW(
  960. IN LPCWSTR lpFileName,
  961. IN DWORD nBufferLength,
  962. OUT LPWSTR lpBuffer,
  963. OUT LPWSTR *lpFilePart);
  964. #ifdef UNICODE
  965. #define GetFullPathName GetFullPathNameW
  966. #else
  967. #define GetFullPathName GetFullPathNameA
  968. #endif
  969. PALIMPORT
  970. DWORD
  971. PALAPI
  972. GetLongPathNameW(
  973. IN LPCWSTR lpszShortPath,
  974. OUT LPWSTR lpszLongPath,
  975. IN DWORD cchBuffer);
  976. #ifdef UNICODE
  977. #define GetLongPathName GetLongPathNameW
  978. #endif
  979. PALIMPORT
  980. DWORD
  981. PALAPI
  982. GetShortPathNameW(
  983. IN LPCWSTR lpszLongPath,
  984. OUT LPWSTR lpszShortPath,
  985. IN DWORD cchBuffer);
  986. #ifdef UNICODE
  987. #define GetShortPathName GetShortPathNameW
  988. #endif
  989. PALIMPORT
  990. UINT
  991. PALAPI
  992. GetTempFileNameA(
  993. IN LPCSTR lpPathName,
  994. IN LPCSTR lpPrefixString,
  995. IN UINT uUnique,
  996. OUT LPSTR lpTempFileName);
  997. PALIMPORT
  998. UINT
  999. PALAPI
  1000. GetTempFileNameW(
  1001. IN LPCWSTR lpPathName,
  1002. IN LPCWSTR lpPrefixString,
  1003. IN UINT uUnique,
  1004. OUT LPWSTR lpTempFileName);
  1005. #ifdef UNICODE
  1006. #define GetTempFileName GetTempFileNameW
  1007. #else
  1008. #define GetTempFileName GetTempFileNameA
  1009. #endif
  1010. PALIMPORT
  1011. DWORD
  1012. PALAPI
  1013. GetTempPathA(
  1014. IN DWORD nBufferLength,
  1015. OUT LPSTR lpBuffer);
  1016. PALIMPORT
  1017. DWORD
  1018. PALAPI
  1019. GetTempPathW(
  1020. IN DWORD nBufferLength,
  1021. OUT LPWSTR lpBuffer);
  1022. #ifdef UNICODE
  1023. #define GetTempPath GetTempPathW
  1024. #else
  1025. #define GetTempPath GetTempPathA
  1026. #endif
  1027. PALIMPORT
  1028. DWORD
  1029. PALAPI
  1030. GetCurrentDirectoryA(
  1031. IN DWORD nBufferLength,
  1032. OUT LPSTR lpBuffer);
  1033. PALIMPORT
  1034. DWORD
  1035. PALAPI
  1036. GetCurrentDirectoryW(
  1037. IN DWORD nBufferLength,
  1038. OUT LPWSTR lpBuffer);
  1039. #ifdef UNICODE
  1040. #define GetCurrentDirectory GetCurrentDirectoryW
  1041. #else
  1042. #define GetCurrentDirectory GetCurrentDirectoryA
  1043. #endif
  1044. PALIMPORT
  1045. BOOL
  1046. PALAPI
  1047. SetCurrentDirectoryA(
  1048. IN LPCSTR lpPathName);
  1049. PALIMPORT
  1050. BOOL
  1051. PALAPI
  1052. SetCurrentDirectoryW(
  1053. IN LPCWSTR lpPathName);
  1054. #ifdef UNICODE
  1055. #define SetCurrentDirectory SetCurrentDirectoryW
  1056. #else
  1057. #define SetCurrentDirectory SetCurrentDirectoryA
  1058. #endif
  1059. PALIMPORT
  1060. BOOL
  1061. PALAPI
  1062. GetUserNameW(
  1063. OUT LPWSTR lpBuffer, // address of name buffer
  1064. IN OUT LPDWORD nSize ); // address of size of name buffer
  1065. PALIMPORT
  1066. BOOL
  1067. PALAPI
  1068. GetComputerNameW(
  1069. OUT LPWSTR lpBuffer, // address of name buffer
  1070. IN OUT LPDWORD nSize); // address of size of name buffer
  1071. #ifdef UNICODE
  1072. #define GetUserName GetUserNameW
  1073. #define GetComputerName GetComputerNameW
  1074. #endif // UNICODE
  1075. PALIMPORT
  1076. HANDLE
  1077. PALAPI
  1078. CreateSemaphoreA(
  1079. IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
  1080. IN LONG lInitialCount,
  1081. IN LONG lMaximumCount,
  1082. IN LPCSTR lpName);
  1083. PALIMPORT
  1084. HANDLE
  1085. PALAPI
  1086. CreateSemaphoreExA(
  1087. IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
  1088. IN LONG lInitialCount,
  1089. IN LONG lMaximumCount,
  1090. IN LPCSTR lpName,
  1091. IN /*_Reserved_*/ DWORD dwFlags,
  1092. IN DWORD dwDesiredAccess);
  1093. PALIMPORT
  1094. HANDLE
  1095. PALAPI
  1096. CreateSemaphoreW(
  1097. IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
  1098. IN LONG lInitialCount,
  1099. IN LONG lMaximumCount,
  1100. IN LPCWSTR lpName);
  1101. PALIMPORT
  1102. HANDLE
  1103. PALAPI
  1104. CreateSemaphoreExW(
  1105. IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
  1106. IN LONG lInitialCount,
  1107. IN LONG lMaximumCount,
  1108. IN LPCWSTR lpName,
  1109. IN /*_Reserved_*/ DWORD dwFlags,
  1110. IN DWORD dwDesiredAccess);
  1111. PALIMPORT
  1112. HANDLE
  1113. PALAPI
  1114. OpenSemaphoreW(
  1115. IN DWORD dwDesiredAccess,
  1116. IN BOOL bInheritHandle,
  1117. IN LPCWSTR lpName);
  1118. #ifdef UNICODE
  1119. #define CreateSemaphore CreateSemaphoreW
  1120. #define CreateSemaphoreEx CreateSemaphoreExW
  1121. #else
  1122. #define CreateSemaphore CreateSemaphoreA
  1123. #define CreateSemaphoreEx CreateSemaphoreExA
  1124. #endif
  1125. PALIMPORT
  1126. BOOL
  1127. PALAPI
  1128. ReleaseSemaphore(
  1129. IN HANDLE hSemaphore,
  1130. IN LONG lReleaseCount,
  1131. OUT LPLONG lpPreviousCount);
  1132. PALIMPORT
  1133. HANDLE
  1134. PALAPI
  1135. CreateEventA(
  1136. IN LPSECURITY_ATTRIBUTES lpEventAttributes,
  1137. IN BOOL bManualReset,
  1138. IN BOOL bInitialState,
  1139. IN LPCSTR lpName);
  1140. PALIMPORT
  1141. HANDLE
  1142. PALAPI
  1143. CreateEventW(
  1144. IN LPSECURITY_ATTRIBUTES lpEventAttributes,
  1145. IN BOOL bManualReset,
  1146. IN BOOL bInitialState,
  1147. IN LPCWSTR lpName);
  1148. #ifdef UNICODE
  1149. #define CreateEvent CreateEventW
  1150. #else
  1151. #define CreateEvent CreateEventA
  1152. #endif
  1153. PALIMPORT
  1154. BOOL
  1155. PALAPI
  1156. SetEvent(
  1157. IN HANDLE hEvent);
  1158. PALIMPORT
  1159. BOOL
  1160. PALAPI
  1161. ResetEvent(
  1162. IN HANDLE hEvent);
  1163. PALIMPORT
  1164. HANDLE
  1165. PALAPI
  1166. OpenEventW(
  1167. IN DWORD dwDesiredAccess,
  1168. IN BOOL bInheritHandle,
  1169. IN LPCWSTR lpName);
  1170. #ifdef UNICODE
  1171. #define OpenEvent OpenEventW
  1172. #endif
  1173. PALIMPORT
  1174. HANDLE
  1175. PALAPI
  1176. CreateMutexW(
  1177. IN LPSECURITY_ATTRIBUTES lpMutexAttributes,
  1178. IN BOOL bInitialOwner,
  1179. IN LPCWSTR lpName);
  1180. PALIMPORT
  1181. HANDLE
  1182. PALAPI
  1183. CreateMutexA(
  1184. IN LPSECURITY_ATTRIBUTES lpMutexAttributes,
  1185. IN BOOL bInitialOwner,
  1186. IN LPCSTR lpName);
  1187. #ifdef UNICODE
  1188. #define CreateMutex CreateMutexW
  1189. #else
  1190. #define CreateMutex CreateMutexA
  1191. #endif
  1192. PALIMPORT
  1193. HANDLE
  1194. PALAPI
  1195. OpenMutexW(
  1196. IN DWORD dwDesiredAccess,
  1197. IN BOOL bInheritHandle,
  1198. IN LPCWSTR lpName);
  1199. PALIMPORT
  1200. HANDLE
  1201. PALAPI
  1202. OpenMutexA(
  1203. IN DWORD dwDesiredAccess,
  1204. IN BOOL bInheritHandle,
  1205. IN LPCSTR lpName);
  1206. #ifdef UNICODE
  1207. #define OpenMutex OpenMutexW
  1208. #else
  1209. #define OpenMutex OpenMutexA
  1210. #endif // UNICODE
  1211. PALIMPORT
  1212. BOOL
  1213. PALAPI
  1214. ReleaseMutex(
  1215. IN HANDLE hMutex);
  1216. PALIMPORT
  1217. DWORD
  1218. PALAPI
  1219. GetCurrentProcessId(
  1220. VOID);
  1221. PALIMPORT
  1222. HANDLE
  1223. PALAPI
  1224. GetCurrentProcess(
  1225. VOID);
  1226. PALIMPORT
  1227. DWORD
  1228. PALAPI
  1229. GetCurrentThreadId(
  1230. VOID);
  1231. PALIMPORT
  1232. DWORD
  1233. PALAPI
  1234. GetThreadId(
  1235. HANDLE hThread);
  1236. // To work around multiply-defined symbols in the Carbon framework.
  1237. #define GetCurrentThread PAL_GetCurrentThread
  1238. PALIMPORT
  1239. HANDLE
  1240. PALAPI
  1241. GetCurrentThread(
  1242. VOID);
  1243. #define STARTF_USESTDHANDLES 0x00000100
  1244. typedef struct _STARTUPINFOW {
  1245. DWORD cb;
  1246. LPWSTR lpReserved_PAL_Undefined;
  1247. LPWSTR lpDesktop_PAL_Undefined;
  1248. LPWSTR lpTitle_PAL_Undefined;
  1249. DWORD dwX_PAL_Undefined;
  1250. DWORD dwY_PAL_Undefined;
  1251. DWORD dwXSize_PAL_Undefined;
  1252. DWORD dwYSize_PAL_Undefined;
  1253. DWORD dwXCountChars_PAL_Undefined;
  1254. DWORD dwYCountChars_PAL_Undefined;
  1255. DWORD dwFillAttribute_PAL_Undefined;
  1256. DWORD dwFlags;
  1257. WORD wShowWindow_PAL_Undefined;
  1258. WORD cbReserved2_PAL_Undefined;
  1259. LPBYTE lpReserved2_PAL_Undefined;
  1260. HANDLE hStdInput;
  1261. HANDLE hStdOutput;
  1262. HANDLE hStdError;
  1263. } STARTUPINFOW, *LPSTARTUPINFOW;
  1264. typedef struct _STARTUPINFOA {
  1265. DWORD cb;
  1266. LPSTR lpReserved_PAL_Undefined;
  1267. LPSTR lpDesktop_PAL_Undefined;
  1268. LPSTR lpTitle_PAL_Undefined;
  1269. DWORD dwX_PAL_Undefined;
  1270. DWORD dwY_PAL_Undefined;
  1271. DWORD dwXSize_PAL_Undefined;
  1272. DWORD dwYSize_PAL_Undefined;
  1273. DWORD dwXCountChars_PAL_Undefined;
  1274. DWORD dwYCountChars_PAL_Undefined;
  1275. DWORD dwFillAttribute_PAL_Undefined;
  1276. DWORD dwFlags;
  1277. WORD wShowWindow_PAL_Undefined;
  1278. WORD cbReserved2_PAL_Undefined;
  1279. LPBYTE lpReserved2_PAL_Undefined;
  1280. HANDLE hStdInput;
  1281. HANDLE hStdOutput;
  1282. HANDLE hStdError;
  1283. } STARTUPINFOA, *LPSTARTUPINFOA;
  1284. #ifdef UNICODE
  1285. typedef STARTUPINFOW STARTUPINFO;
  1286. typedef LPSTARTUPINFOW LPSTARTUPINFO;
  1287. #else
  1288. typedef STARTUPINFOA STARTUPINFO;
  1289. typedef LPSTARTUPINFOW LPSTARTUPINFO;
  1290. #endif
  1291. #define CREATE_NEW_CONSOLE 0x00000010
  1292. #define NORMAL_PRIORITY_CLASS 0x00000020
  1293. typedef struct _PROCESS_INFORMATION {
  1294. HANDLE hProcess;
  1295. HANDLE hThread;
  1296. DWORD dwProcessId;
  1297. DWORD dwThreadId_PAL_Undefined;
  1298. } PROCESS_INFORMATION, *PPROCESS_INFORMATION, *LPPROCESS_INFORMATION;
  1299. PALIMPORT
  1300. BOOL
  1301. PALAPI
  1302. CreateProcessA(
  1303. IN LPCSTR lpApplicationName,
  1304. IN LPSTR lpCommandLine,
  1305. IN LPSECURITY_ATTRIBUTES lpProcessAttributes,
  1306. IN LPSECURITY_ATTRIBUTES lpThreadAttributes,
  1307. IN BOOL bInheritHandles,
  1308. IN DWORD dwCreationFlags,
  1309. IN LPVOID lpEnvironment,
  1310. IN LPCSTR lpCurrentDirectory,
  1311. IN LPSTARTUPINFOA lpStartupInfo,
  1312. OUT LPPROCESS_INFORMATION lpProcessInformation);
  1313. PALIMPORT
  1314. BOOL
  1315. PALAPI
  1316. CreateProcessW(
  1317. IN LPCWSTR lpApplicationName,
  1318. IN LPWSTR lpCommandLine,
  1319. IN LPSECURITY_ATTRIBUTES lpProcessAttributes,
  1320. IN LPSECURITY_ATTRIBUTES lpThreadAttributes,
  1321. IN BOOL bInheritHandles,
  1322. IN DWORD dwCreationFlags,
  1323. IN LPVOID lpEnvironment,
  1324. IN LPCWSTR lpCurrentDirectory,
  1325. IN LPSTARTUPINFOW lpStartupInfo,
  1326. OUT LPPROCESS_INFORMATION lpProcessInformation);
  1327. #ifdef UNICODE
  1328. #define CreateProcess CreateProcessW
  1329. #else
  1330. #define CreateProcess CreateProcessA
  1331. #endif
  1332. PALIMPORT
  1333. PAL_NORETURN
  1334. VOID
  1335. PALAPI
  1336. ExitProcess(
  1337. IN UINT uExitCode);
  1338. PALIMPORT
  1339. BOOL
  1340. PALAPI
  1341. TerminateProcess(
  1342. IN HANDLE hProcess,
  1343. IN UINT uExitCode);
  1344. PALIMPORT
  1345. BOOL
  1346. PALAPI
  1347. GetExitCodeProcess(
  1348. IN HANDLE hProcess,
  1349. IN LPDWORD lpExitCode);
  1350. PALIMPORT
  1351. BOOL
  1352. PALAPI
  1353. GetProcessTimes(
  1354. IN HANDLE hProcess,
  1355. OUT LPFILETIME lpCreationTime,
  1356. OUT LPFILETIME lpExitTime,
  1357. OUT LPFILETIME lpKernelTime,
  1358. OUT LPFILETIME lpUserTime);
  1359. #define MAXIMUM_WAIT_OBJECTS 64
  1360. #define WAIT_OBJECT_0 0
  1361. #define WAIT_ABANDONED 0x00000080
  1362. #define WAIT_ABANDONED_0 0x00000080
  1363. #define WAIT_TIMEOUT 258
  1364. #define WAIT_FAILED ((DWORD)0xFFFFFFFF)
  1365. #define INFINITE 0xFFFFFFFF // Infinite timeout
  1366. PALIMPORT
  1367. DWORD
  1368. PALAPI
  1369. WaitForSingleObject(
  1370. IN HANDLE hHandle,
  1371. IN DWORD dwMilliseconds);
  1372. PALIMPORT
  1373. DWORD
  1374. PALAPI
  1375. WaitForSingleObjectEx(
  1376. IN HANDLE hHandle,
  1377. IN DWORD dwMilliseconds,
  1378. IN BOOL bAlertable);
  1379. PALIMPORT
  1380. DWORD
  1381. PALAPI
  1382. WaitForMultipleObjects(
  1383. IN DWORD nCount,
  1384. IN CONST HANDLE *lpHandles,
  1385. IN BOOL bWaitAll,
  1386. IN DWORD dwMilliseconds);
  1387. PALIMPORT
  1388. DWORD
  1389. PALAPI
  1390. WaitForMultipleObjectsEx(
  1391. IN DWORD nCount,
  1392. IN CONST HANDLE *lpHandles,
  1393. IN BOOL bWaitAll,
  1394. IN DWORD dwMilliseconds,
  1395. IN BOOL bAlertable);
  1396. PALIMPORT
  1397. RHANDLE
  1398. PALAPI
  1399. PAL_LocalHandleToRemote(
  1400. IN HANDLE hLocal);
  1401. PALIMPORT
  1402. HANDLE
  1403. PALAPI
  1404. PAL_RemoteHandleToLocal(
  1405. IN RHANDLE hRemote);
  1406. #define DUPLICATE_CLOSE_SOURCE 0x00000001
  1407. #define DUPLICATE_SAME_ACCESS 0x00000002
  1408. PALIMPORT
  1409. BOOL
  1410. PALAPI
  1411. DuplicateHandle(
  1412. IN HANDLE hSourceProcessHandle,
  1413. IN HANDLE hSourceHandle,
  1414. IN HANDLE hTargetProcessHandle,
  1415. OUT LPHANDLE lpTargetHandle,
  1416. IN DWORD dwDesiredAccess,
  1417. IN BOOL bInheritHandle,
  1418. IN DWORD dwOptions);
  1419. PALIMPORT
  1420. VOID
  1421. PALAPI
  1422. Sleep(
  1423. IN DWORD dwMilliseconds);
  1424. PALIMPORT
  1425. DWORD
  1426. PALAPI
  1427. SleepEx(
  1428. IN DWORD dwMilliseconds,
  1429. IN BOOL bAlertable);
  1430. PALIMPORT
  1431. BOOL
  1432. PALAPI
  1433. SwitchToThread(
  1434. VOID);
  1435. #define DEBUG_PROCESS 0x00000001
  1436. #define DEBUG_ONLY_THIS_PROCESS 0x00000002
  1437. #define CREATE_SUSPENDED 0x00000004
  1438. #define STACK_SIZE_PARAM_IS_A_RESERVATION 0x00010000
  1439. PALIMPORT
  1440. HANDLE
  1441. PALAPI
  1442. CreateThread(
  1443. IN LPSECURITY_ATTRIBUTES lpThreadAttributes,
  1444. IN DWORD dwStackSize,
  1445. IN LPTHREAD_START_ROUTINE lpStartAddress,
  1446. IN LPVOID lpParameter,
  1447. IN DWORD dwCreationFlags,
  1448. OUT LPDWORD lpThreadId);
  1449. PALIMPORT
  1450. PAL_NORETURN
  1451. VOID
  1452. PALAPI
  1453. ExitThread(
  1454. IN DWORD dwExitCode);
  1455. PALIMPORT
  1456. BOOL
  1457. PALAPI
  1458. GetExitCodeThread(
  1459. IN HANDLE hThread,
  1460. IN LPDWORD lpExitCode);
  1461. PALIMPORT
  1462. DWORD
  1463. PALAPI
  1464. ResumeThread(
  1465. IN HANDLE hThread);
  1466. typedef VOID (PALAPI *PAPCFUNC)(ULONG_PTR dwParam);
  1467. PALIMPORT
  1468. DWORD
  1469. PALAPI
  1470. QueueUserAPC(
  1471. IN PAPCFUNC pfnAPC,
  1472. IN HANDLE hThread,
  1473. IN ULONG_PTR dwData);
  1474. #ifdef _X86_
  1475. //
  1476. // ***********************************************************************************
  1477. //
  1478. // NOTE: These context definitions are replicated in ndp/clr/src/debug/inc/DbgTargetContext.h (for the
  1479. // purposes manipulating contexts from different platforms during remote debugging). Be sure to keep those
  1480. // definitions in sync if you make any changes here.
  1481. //
  1482. // ***********************************************************************************
  1483. //
  1484. #define SIZE_OF_80387_REGISTERS 80
  1485. #define CONTEXT_i386 0x00010000
  1486. #define CONTEXT_CONTROL (CONTEXT_i386 | 0x00000001L) // SS:SP, CS:IP, FLAGS, BP
  1487. #define CONTEXT_INTEGER (CONTEXT_i386 | 0x00000002L) // AX, BX, CX, DX, SI, DI
  1488. #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x00000004L)
  1489. #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x00000008L) // 387 state
  1490. #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x00000010L)
  1491. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
  1492. #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386 | 0x00000020L)
  1493. #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS)
  1494. #define MAXIMUM_SUPPORTED_EXTENSION 512
  1495. typedef struct _FLOATING_SAVE_AREA {
  1496. DWORD ControlWord;
  1497. DWORD StatusWord;
  1498. DWORD TagWord;
  1499. DWORD ErrorOffset;
  1500. DWORD ErrorSelector;
  1501. DWORD DataOffset;
  1502. DWORD DataSelector;
  1503. BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
  1504. DWORD Cr0NpxState;
  1505. } FLOATING_SAVE_AREA;
  1506. typedef FLOATING_SAVE_AREA *PFLOATING_SAVE_AREA;
  1507. typedef struct _CONTEXT {
  1508. ULONG ContextFlags;
  1509. ULONG Dr0_PAL_Undefined;
  1510. ULONG Dr1_PAL_Undefined;
  1511. ULONG Dr2_PAL_Undefined;
  1512. ULONG Dr3_PAL_Undefined;
  1513. ULONG Dr6_PAL_Undefined;
  1514. ULONG Dr7_PAL_Undefined;
  1515. FLOATING_SAVE_AREA FloatSave;
  1516. ULONG SegGs_PAL_Undefined;
  1517. ULONG SegFs_PAL_Undefined;
  1518. ULONG SegEs_PAL_Undefined;
  1519. ULONG SegDs_PAL_Undefined;
  1520. ULONG Edi;
  1521. ULONG Esi;
  1522. ULONG Ebx;
  1523. ULONG Edx;
  1524. ULONG Ecx;
  1525. ULONG Eax;
  1526. ULONG Ebp;
  1527. ULONG Eip;
  1528. ULONG SegCs;
  1529. ULONG EFlags;
  1530. ULONG Esp;
  1531. ULONG SegSs;
  1532. UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
  1533. } CONTEXT, *PCONTEXT, *LPCONTEXT;
  1534. // To support saving and loading xmm register context we need to know the offset in the ExtendedRegisters
  1535. // section at which they are stored. This has been determined experimentally since I have found no
  1536. // documentation thus far but it corresponds to the offset we'd expect if a fxsave instruction was used to
  1537. // store the regular FP state along with the XMM registers at the start of the extended registers section.
  1538. // Technically the offset doesn't really matter if no code in the PAL or runtime knows what the offset should
  1539. // be either (as long as we're consistent across GetThreadContext() and SetThreadContext() and we don't
  1540. // support any other values in the ExtendedRegisters) but we might as well be as accurate as we can.
  1541. #define CONTEXT_EXREG_XMM_OFFSET 160
  1542. #elif defined(_PPC_)
  1543. //
  1544. // ***********************************************************************************
  1545. //
  1546. // NOTE: These context definitions are replicated in ndp/clr/src/debug/inc/DbgTargetContext.h (for the
  1547. // purposes manipulating contexts from different platforms during remote debugging). Be sure to keep those
  1548. // definitions in sync if you make any changes here.
  1549. //
  1550. // ***********************************************************************************
  1551. //
  1552. #define CONTEXT_CONTROL 0x00000001L
  1553. #define CONTEXT_FLOATING_POINT 0x00000002L
  1554. #define CONTEXT_INTEGER 0x00000004L
  1555. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
  1556. #define CONTEXT_ALL CONTEXT_FULL
  1557. typedef struct _CONTEXT {
  1558. //
  1559. // This section is specified/returned if the ContextFlags word contains
  1560. // the flag CONTEXT_FLOATING_POINT.
  1561. //
  1562. double Fpr0; // Floating registers 0..31
  1563. double Fpr1;
  1564. double Fpr2;
  1565. double Fpr3;
  1566. double Fpr4;
  1567. double Fpr5;
  1568. double Fpr6;
  1569. double Fpr7;
  1570. double Fpr8;
  1571. double Fpr9;
  1572. double Fpr10;
  1573. double Fpr11;
  1574. double Fpr12;
  1575. double Fpr13;
  1576. double Fpr14;
  1577. double Fpr15;
  1578. double Fpr16;
  1579. double Fpr17;
  1580. double Fpr18;
  1581. double Fpr19;
  1582. double Fpr20;
  1583. double Fpr21;
  1584. double Fpr22;
  1585. double Fpr23;
  1586. double Fpr24;
  1587. double Fpr25;
  1588. double Fpr26;
  1589. double Fpr27;
  1590. double Fpr28;
  1591. double Fpr29;
  1592. double Fpr30;
  1593. double Fpr31;
  1594. double Fpscr; // Floating point status/control reg
  1595. //
  1596. // This section is specified/returned if the ContextFlags word contains
  1597. // the flag CONTEXT_INTEGER.
  1598. //
  1599. ULONG Gpr0; // General registers 0..31
  1600. ULONG Gpr1; // StackPointer
  1601. ULONG Gpr2;
  1602. ULONG Gpr3;
  1603. ULONG Gpr4;
  1604. ULONG Gpr5;
  1605. ULONG Gpr6;
  1606. ULONG Gpr7;
  1607. ULONG Gpr8;
  1608. ULONG Gpr9;
  1609. ULONG Gpr10;
  1610. ULONG Gpr11;
  1611. ULONG Gpr12;
  1612. ULONG Gpr13;
  1613. ULONG Gpr14;
  1614. ULONG Gpr15;
  1615. ULONG Gpr16;
  1616. ULONG Gpr17;
  1617. ULONG Gpr18;
  1618. ULONG Gpr19;
  1619. ULONG Gpr20;
  1620. ULONG Gpr21;
  1621. ULONG Gpr22;
  1622. ULONG Gpr23;
  1623. ULONG Gpr24;
  1624. ULONG Gpr25;
  1625. ULONG Gpr26;
  1626. ULONG Gpr27;
  1627. ULONG Gpr28;
  1628. ULONG Gpr29;
  1629. ULONG Gpr30;
  1630. ULONG Gpr31;
  1631. ULONG Cr; // Condition register
  1632. ULONG Xer; // Fixed point exception register
  1633. //
  1634. // This section is specified/returned if the ContextFlags word contains
  1635. // the flag CONTEXT_CONTROL.
  1636. //
  1637. ULONG Msr; // Machine status register
  1638. ULONG Iar; // Instruction address register
  1639. ULONG Lr; // Link register
  1640. ULONG Ctr; // Count register
  1641. //
  1642. // The flags values within this flag control the contents of
  1643. // a CONTEXT record.
  1644. //
  1645. // If the context record is used as an input parameter, then
  1646. // for each portion of the context record controlled by a flag
  1647. // whose value is set, it is assumed that that portion of the
  1648. // context record contains valid context. If the context record
  1649. // is being used to modify a thread's context, then only that
  1650. // portion of the threads context will be modified.
  1651. //
  1652. // If the context record is used as an IN OUT parameter to capture
  1653. // the context of a thread, then only those portions of the thread's
  1654. // context corresponding to set flags will be returned.
  1655. //
  1656. // The context record is never used as an OUT only parameter.
  1657. //
  1658. ULONG ContextFlags;
  1659. ULONG Fill[3]; // Pad out to multiple of 16 bytes
  1660. //
  1661. // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
  1662. // set in ContextFlags. Note that CONTEXT_DEBUG_REGISTERS is NOT
  1663. // included in CONTEXT_FULL.
  1664. //
  1665. ULONG Dr0; // Breakpoint Register 1
  1666. ULONG Dr1; // Breakpoint Register 2
  1667. ULONG Dr2; // Breakpoint Register 3
  1668. ULONG Dr3; // Breakpoint Register 4
  1669. ULONG Dr4; // Breakpoint Register 5
  1670. ULONG Dr5; // Breakpoint Register 6
  1671. ULONG Dr6; // Debug Status Register
  1672. ULONG Dr7; // Debug Control Register
  1673. } CONTEXT, *PCONTEXT, *LPCONTEXT;
  1674. #elif defined(_SPARC_)
  1675. #define CONTEXT_CONTROL 0x00000001L
  1676. #define CONTEXT_FLOATING_POINT 0x00000002L
  1677. #define CONTEXT_INTEGER 0x00000004L
  1678. #define COUNT_FLOATING_REGISTER 32
  1679. #define COUNT_DOUBLE_REGISTER 16
  1680. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
  1681. #define CONTEXT_ALL CONTEXT_FULL
  1682. typedef struct _CONTEXT {
  1683. //
  1684. // This section is specified/returned if the ContextFlags word contains
  1685. // the flag CONTEXT_INTEGER.
  1686. //
  1687. ULONG g0;
  1688. ULONG g1;
  1689. ULONG g2;
  1690. ULONG g3;
  1691. ULONG g4;
  1692. ULONG g5;
  1693. ULONG g6;
  1694. ULONG g7;
  1695. ULONG o0;
  1696. ULONG o1;
  1697. ULONG o2;
  1698. ULONG o3;
  1699. ULONG o4;
  1700. ULONG o5;
  1701. ULONG sp;
  1702. ULONG o7;
  1703. ULONG l0;
  1704. ULONG l1;
  1705. ULONG l2;
  1706. ULONG l3;
  1707. ULONG l4;
  1708. ULONG l5;
  1709. ULONG l6;
  1710. ULONG l7;
  1711. ULONG i0;
  1712. ULONG i1;
  1713. ULONG i2;
  1714. ULONG i3;
  1715. ULONG i4;
  1716. ULONG i5;
  1717. ULONG fp;
  1718. ULONG i7;
  1719. ULONG y;
  1720. //
  1721. // This section is specified/returned if the ContextFlags word contains
  1722. // the flag CONTEXT_CONTROL.
  1723. //
  1724. #if defined(__sparcv9)
  1725. ULONG ccr;
  1726. #else
  1727. ULONG psr;
  1728. #endif
  1729. ULONG pc; // program counter
  1730. ULONG npc; // next address to be executed
  1731. ULONG ContextFlags;
  1732. //
  1733. // This section is specified/returned if the ContextFlags word contains
  1734. // the flag CONTEXT_FLOATING_POINT.
  1735. //
  1736. ULONGLONG fsr;
  1737. union {
  1738. float f[COUNT_FLOATING_REGISTER];
  1739. double d[COUNT_DOUBLE_REGISTER];
  1740. } fprs;
  1741. } CONTEXT, *PCONTEXT, *LPCONTEXT;
  1742. #elif defined(_PARISC_)
  1743. // ToDo: Get this correct for PARISC architecture
  1744. #define CONTEXT_CONTROL 0x00000001L
  1745. #define CONTEXT_FLOATING_POINT 0x00000002L
  1746. #define CONTEXT_INTEGER 0x00000004L
  1747. #define COUNT_FLOATING_REGISTER 32
  1748. #define COUNT_DOUBLE_REGISTER 16
  1749. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
  1750. #define CONTEXT_ALL CONTEXT_FULL
  1751. typedef struct _CONTEXT {
  1752. //
  1753. // This section is specified/returned if the ContextFlags word contains
  1754. // the flag CONTEXT_INTEGER.
  1755. //
  1756. ULONG g0;
  1757. ULONG g1;
  1758. ULONG g2;
  1759. ULONG g3;
  1760. ULONG g4;
  1761. ULONG g5;
  1762. ULONG g6;
  1763. ULONG g7;
  1764. ULONG o0;
  1765. ULONG o1;
  1766. ULONG o2;
  1767. ULONG o3;
  1768. ULONG o4;
  1769. ULONG o5;
  1770. ULONG sp;
  1771. ULONG o7;
  1772. ULONG l0;
  1773. ULONG l1;
  1774. ULONG l2;
  1775. ULONG l3;
  1776. ULONG l4;
  1777. ULONG l5;
  1778. ULONG l6;
  1779. ULONG l7;
  1780. ULONG i0;
  1781. ULONG i1;
  1782. ULONG i2;
  1783. ULONG i3;
  1784. ULONG i4;
  1785. ULONG i5;
  1786. ULONG fp;
  1787. ULONG i7;
  1788. ULONG y;
  1789. //
  1790. // This section is specified/returned if the ContextFlags word contains
  1791. // the flag CONTEXT_CONTROL.
  1792. //
  1793. ULONG psr;
  1794. ULONG pc; // program counter
  1795. ULONG npc; // next address to be executed
  1796. ULONG ContextFlags;
  1797. //
  1798. // This section is specified/returned if the ContextFlags word contains
  1799. // the flag CONTEXT_FLOATING_POINT.
  1800. //
  1801. ULONGLONG fsr;
  1802. union {
  1803. float f[COUNT_FLOATING_REGISTER];
  1804. double d[COUNT_DOUBLE_REGISTER];
  1805. } fprs;
  1806. } CONTEXT, *PCONTEXT, *LPCONTEXT;
  1807. #elif defined(_IA64_)
  1808. // copied from winnt.h
  1809. typedef struct _FLOAT128 {
  1810. __int64 LowPart;
  1811. __int64 HighPart;
  1812. } FLOAT128;
  1813. typedef FLOAT128 *PFLOAT128;
  1814. // begin_ntddk begin_nthal
  1815. //
  1816. // The following flags control the contents of the CONTEXT structure.
  1817. //
  1818. #if !defined(RC_INVOKED)
  1819. #define CONTEXT_IA64 0x00080000
  1820. #define CONTEXT_CONTROL (CONTEXT_IA64 | 0x00000001L)
  1821. #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | 0x00000002L)
  1822. #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | 0x00000004L)
  1823. #define CONTEXT_INTEGER (CONTEXT_IA64 | 0x00000008L)
  1824. #define CONTEXT_DEBUG (CONTEXT_IA64 | 0x00000010L)
  1825. #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | 0x00000020L) // Includes StIPSR
  1826. #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
  1827. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
  1828. #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_DEBUG | CONTEXT_IA32_CONTROL)
  1829. #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
  1830. #define CONTEXT_SERVICE_ACTIVE 0x10000000
  1831. #define CONTEXT_EXCEPTION_REQUEST 0x40000000
  1832. #define CONTEXT_EXCEPTION_REPORTING 0x80000000
  1833. #endif // !defined(RC_INVOKED)
  1834. //
  1835. // Context Frame
  1836. //
  1837. // This frame has a several purposes: 1) it is used as an argument to
  1838. // NtContinue, 2) it is used to construct a call frame for APC delivery,
  1839. // 3) it is used to construct a call frame for exception dispatching
  1840. // in user mode, 4) it is used in the user level thread creation
  1841. // routines, and 5) it is used to to pass thread state to debuggers.
  1842. //
  1843. // N.B. Because this record is used as a call frame, it must be EXACTLY
  1844. // a multiple of 16 bytes in length and aligned on a 16-byte boundary.
  1845. //
  1846. typedef struct _CONTEXT {
  1847. //
  1848. // The flags values within this flag control the contents of
  1849. // a CONTEXT record.
  1850. //
  1851. // If the context record is used as an input parameter, then
  1852. // for each portion of the context record controlled by a flag
  1853. // whose value is set, it is assumed that that portion of the
  1854. // context record contains valid context. If the context record
  1855. // is being used to modify a thread's context, then only that
  1856. // portion of the threads context will be modified.
  1857. //
  1858. // If the context record is used as an IN OUT parameter to capture
  1859. // the context of a thread, then only those portions of the thread's
  1860. // context corresponding to set flags will be returned.
  1861. //
  1862. // The context record is never used as an OUT only parameter.
  1863. //
  1864. DWORD ContextFlags;
  1865. DWORD Fill1[3]; // for alignment of following on 16-byte boundary
  1866. //
  1867. // This section is specified/returned if the ContextFlags word contains
  1868. // the flag CONTEXT_DEBUG.
  1869. //
  1870. // N.B. CONTEXT_DEBUG is *not* part of CONTEXT_FULL.
  1871. //
  1872. ULONGLONG DbI0;
  1873. ULONGLONG DbI1;
  1874. ULONGLONG DbI2;
  1875. ULONGLONG DbI3;
  1876. ULONGLONG DbI4;
  1877. ULONGLONG DbI5;
  1878. ULONGLONG DbI6;
  1879. ULONGLONG DbI7;
  1880. ULONGLONG DbD0;
  1881. ULONGLONG DbD1;
  1882. ULONGLONG DbD2;
  1883. ULONGLONG DbD3;
  1884. ULONGLONG DbD4;
  1885. ULONGLONG DbD5;
  1886. ULONGLONG DbD6;
  1887. ULONGLONG DbD7;
  1888. //
  1889. // This section is specified/returned if the ContextFlags word contains
  1890. // the flag CONTEXT_LOWER_FLOATING_POINT.
  1891. //
  1892. FLOAT128 FltS0;
  1893. FLOAT128 FltS1;
  1894. FLOAT128 FltS2;
  1895. FLOAT128 FltS3;
  1896. FLOAT128 FltT0;
  1897. FLOAT128 FltT1;
  1898. FLOAT128 FltT2;
  1899. FLOAT128 FltT3;
  1900. FLOAT128 FltT4;
  1901. FLOAT128 FltT5;
  1902. FLOAT128 FltT6;
  1903. FLOAT128 FltT7;
  1904. FLOAT128 FltT8;
  1905. FLOAT128 FltT9;
  1906. //
  1907. // This section is specified/returned if the ContextFlags word contains
  1908. // the flag CONTEXT_HIGHER_FLOATING_POINT.
  1909. //
  1910. FLOAT128 FltS4;
  1911. FLOAT128 FltS5;
  1912. FLOAT128 FltS6;
  1913. FLOAT128 FltS7;
  1914. FLOAT128 FltS8;
  1915. FLOAT128 FltS9;
  1916. FLOAT128 FltS10;
  1917. FLOAT128 FltS11;
  1918. FLOAT128 FltS12;
  1919. FLOAT128 FltS13;
  1920. FLOAT128 FltS14;
  1921. FLOAT128 FltS15;
  1922. FLOAT128 FltS16;
  1923. FLOAT128 FltS17;
  1924. FLOAT128 FltS18;
  1925. FLOAT128 FltS19;
  1926. FLOAT128 FltF32;
  1927. FLOAT128 FltF33;
  1928. FLOAT128 FltF34;
  1929. FLOAT128 FltF35;
  1930. FLOAT128 FltF36;
  1931. FLOAT128 FltF37;
  1932. FLOAT128 FltF38;
  1933. FLOAT128 FltF39;
  1934. FLOAT128 FltF40;
  1935. FLOAT128 FltF41;
  1936. FLOAT128 FltF42;
  1937. FLOAT128 FltF43;
  1938. FLOAT128 FltF44;
  1939. FLOAT128 FltF45;
  1940. FLOAT128 FltF46;
  1941. FLOAT128 FltF47;
  1942. FLOAT128 FltF48;
  1943. FLOAT128 FltF49;
  1944. FLOAT128 FltF50;
  1945. FLOAT128 FltF51;
  1946. FLOAT128 FltF52;
  1947. FLOAT128 FltF53;
  1948. FLOAT128 FltF54;
  1949. FLOAT128 FltF55;
  1950. FLOAT128 FltF56;
  1951. FLOAT128 FltF57;
  1952. FLOAT128 FltF58;
  1953. FLOAT128 FltF59;
  1954. FLOAT128 FltF60;
  1955. FLOAT128 FltF61;
  1956. FLOAT128 FltF62;
  1957. FLOAT128 FltF63;
  1958. FLOAT128 FltF64;
  1959. FLOAT128 FltF65;
  1960. FLOAT128 FltF66;
  1961. FLOAT128 FltF67;
  1962. FLOAT128 FltF68;
  1963. FLOAT128 FltF69;
  1964. FLOAT128 FltF70;
  1965. FLOAT128 FltF71;
  1966. FLOAT128 FltF72;
  1967. FLOAT128 FltF73;
  1968. FLOAT128 FltF74;
  1969. FLOAT128 FltF75;
  1970. FLOAT128 FltF76;
  1971. FLOAT128 FltF77;
  1972. FLOAT128 FltF78;
  1973. FLOAT128 FltF79;
  1974. FLOAT128 FltF80;
  1975. FLOAT128 FltF81;
  1976. FLOAT128 FltF82;
  1977. FLOAT128 FltF83;
  1978. FLOAT128 FltF84;
  1979. FLOAT128 FltF85;
  1980. FLOAT128 FltF86;
  1981. FLOAT128 FltF87;
  1982. FLOAT128 FltF88;
  1983. FLOAT128 FltF89;
  1984. FLOAT128 FltF90;
  1985. FLOAT128 FltF91;
  1986. FLOAT128 FltF92;
  1987. FLOAT128 FltF93;
  1988. FLOAT128 FltF94;
  1989. FLOAT128 FltF95;
  1990. FLOAT128 FltF96;
  1991. FLOAT128 FltF97;
  1992. FLOAT128 FltF98;
  1993. FLOAT128 FltF99;
  1994. FLOAT128 FltF100;
  1995. FLOAT128 FltF101;
  1996. FLOAT128 FltF102;
  1997. FLOAT128 FltF103;
  1998. FLOAT128 FltF104;
  1999. FLOAT128 FltF105;
  2000. FLOAT128 FltF106;
  2001. FLOAT128 FltF107;
  2002. FLOAT128 FltF108;
  2003. FLOAT128 FltF109;
  2004. FLOAT128 FltF110;
  2005. FLOAT128 FltF111;
  2006. FLOAT128 FltF112;
  2007. FLOAT128 FltF113;
  2008. FLOAT128 FltF114;
  2009. FLOAT128 FltF115;
  2010. FLOAT128 FltF116;
  2011. FLOAT128 FltF117;
  2012. FLOAT128 FltF118;
  2013. FLOAT128 FltF119;
  2014. FLOAT128 FltF120;
  2015. FLOAT128 FltF121;
  2016. FLOAT128 FltF122;
  2017. FLOAT128 FltF123;
  2018. FLOAT128 FltF124;
  2019. FLOAT128 FltF125;
  2020. FLOAT128 FltF126;
  2021. FLOAT128 FltF127;
  2022. //
  2023. // This section is specified/returned if the ContextFlags word contains
  2024. // the flag CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT | CONTEXT_CONTROL.
  2025. //
  2026. ULONGLONG StFPSR; // FP status
  2027. //
  2028. // This section is specified/returned if the ContextFlags word contains
  2029. // the flag CONTEXT_INTEGER.
  2030. //
  2031. // N.B. The registers gp, sp, rp are part of the control context
  2032. //
  2033. ULONGLONG IntGp; // r1, volatile
  2034. ULONGLONG IntT0; // r2-r3, volatile
  2035. ULONGLONG IntT1; //
  2036. ULONGLONG IntS0; // r4-r7, preserved
  2037. ULONGLONG IntS1;
  2038. ULONGLONG IntS2;
  2039. ULONGLONG IntS3;
  2040. ULONGLONG IntV0; // r8, volatile
  2041. ULONGLONG IntT2; // r9-r11, volatile
  2042. ULONGLONG IntT3;
  2043. ULONGLONG IntT4;
  2044. ULONGLONG IntSp; // stack pointer (r12), special
  2045. ULONGLONG IntTeb; // teb (r13), special
  2046. ULONGLONG IntT5; // r14-r31, volatile
  2047. ULONGLONG IntT6;
  2048. ULONGLONG IntT7;
  2049. ULONGLONG IntT8;
  2050. ULONGLONG IntT9;
  2051. ULONGLONG IntT10;
  2052. ULONGLONG IntT11;
  2053. ULONGLONG IntT12;
  2054. ULONGLONG IntT13;
  2055. ULONGLONG IntT14;
  2056. ULONGLONG IntT15;
  2057. ULONGLONG IntT16;
  2058. ULONGLONG IntT17;
  2059. ULONGLONG IntT18;
  2060. ULONGLONG IntT19;
  2061. ULONGLONG IntT20;
  2062. ULONGLONG IntT21;
  2063. ULONGLONG IntT22;
  2064. ULONGLONG IntNats; // Nat bits for r1-r31
  2065. // r1-r31 in bits 1 thru 31.
  2066. ULONGLONG Preds; // predicates, preserved
  2067. ULONGLONG BrRp; // return pointer, b0, preserved
  2068. ULONGLONG BrS0; // b1-b5, preserved
  2069. ULONGLONG BrS1;
  2070. ULONGLONG BrS2;
  2071. ULONGLONG BrS3;
  2072. ULONGLONG BrS4;
  2073. ULONGLONG BrT0; // b6-b7, volatile
  2074. ULONGLONG BrT1;
  2075. //
  2076. // This section is specified/returned if the ContextFlags word contains
  2077. // the flag CONTEXT_CONTROL.
  2078. //
  2079. // Other application registers
  2080. ULONGLONG ApUNAT; // User Nat collection register, preserved
  2081. ULONGLONG ApLC; // Loop counter register, preserved
  2082. ULONGLONG ApEC; // Epilog counter register, preserved
  2083. ULONGLONG ApCCV; // CMPXCHG value register, volatile
  2084. ULONGLONG ApDCR; // Default control register (TBD)
  2085. // Register stack info
  2086. ULONGLONG RsPFS; // Previous function state, preserved
  2087. ULONGLONG RsBSP; // Backing store pointer, preserved
  2088. ULONGLONG RsBSPSTORE;
  2089. ULONGLONG RsRSC; // RSE configuration, volatile
  2090. ULONGLONG RsRNAT; // RSE Nat collection register, preserved
  2091. // Trap Status Information
  2092. ULONGLONG StIPSR; // Interruption Processor Status
  2093. ULONGLONG StIIP; // Interruption IP
  2094. ULONGLONG StIFS; // Interruption Function State
  2095. // iA32 related control registers
  2096. ULONGLONG StFCR; // copy of Ar21
  2097. ULONGLONG Eflag; // Eflag copy of Ar24
  2098. ULONGLONG SegCSD; // iA32 CSDescriptor (Ar25)
  2099. ULONGLONG SegSSD; // iA32 SSDescriptor (Ar26)
  2100. ULONGLONG Cflag; // Cr0+Cr4 copy of Ar27
  2101. ULONGLONG StFSR; // x86 FP status (copy of AR28)
  2102. ULONGLONG StFIR; // x86 FP status (copy of AR29)
  2103. ULONGLONG StFDR; // x86 FP status (copy of AR30)
  2104. ULONGLONG UNUSEDPACK; // added to pack StFDR to 16-bytes
  2105. } CONTEXT, *PCONTEXT, *LPCONTEXT;
  2106. #elif defined(_AMD64_)
  2107. // copied from winnt.h
  2108. #define CONTEXT_AMD64 0x100000
  2109. #define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L)
  2110. #define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L)
  2111. #define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L)
  2112. #define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L)
  2113. #define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L)
  2114. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
  2115. #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
  2116. #define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x40L)
  2117. #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
  2118. #define CONTEXT_SERVICE_ACTIVE 0x10000000
  2119. #define CONTEXT_EXCEPTION_REQUEST 0x40000000
  2120. #define CONTEXT_EXCEPTION_REPORTING 0x80000000
  2121. typedef struct _M128U {
  2122. ULONGLONG Low;
  2123. LONGLONG High;
  2124. } M128U, *PM128U;
  2125. // Same as _M128U but aligned to a 16-byte boundary
  2126. typedef DECLSPEC_ALIGN(16) M128U M128A, *PM128A;
  2127. typedef struct _XMM_SAVE_AREA32 {
  2128. WORD ControlWord;
  2129. WORD StatusWord;
  2130. BYTE TagWord;
  2131. BYTE Reserved1;
  2132. WORD ErrorOpcode;
  2133. DWORD ErrorOffset;
  2134. WORD ErrorSelector;
  2135. WORD Reserved2;
  2136. DWORD DataOffset;
  2137. WORD DataSelector;
  2138. WORD Reserved3;
  2139. DWORD MxCsr;
  2140. DWORD MxCsr_Mask;
  2141. M128A FloatRegisters[8];
  2142. M128A XmmRegisters[16];
  2143. BYTE Reserved4[96];
  2144. } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32;
  2145. #define LEGACY_SAVE_AREA_LENGTH sizeof(XMM_SAVE_AREA32)
  2146. //
  2147. // Context Frame
  2148. //
  2149. // This frame has a several purposes: 1) it is used as an argument to
  2150. // NtContinue, 2) is is used to constuct a call frame for APC delivery,
  2151. // and 3) it is used in the user level thread creation routines.
  2152. //
  2153. //
  2154. // The flags field within this record controls the contents of a CONTEXT
  2155. // record.
  2156. //
  2157. // If the context record is used as an input parameter, then for each
  2158. // portion of the context record controlled by a flag whose value is
  2159. // set, it is assumed that that portion of the context record contains
  2160. // valid context. If the context record is being used to modify a threads
  2161. // context, then only that portion of the threads context is modified.
  2162. //
  2163. // If the context record is used as an output parameter to capture the
  2164. // context of a thread, then only those portions of the thread's context
  2165. // corresponding to set flags will be returned.
  2166. //
  2167. // CONTEXT_CONTROL specifies SegSs, Rsp, SegCs, Rip, and EFlags.
  2168. //
  2169. // CONTEXT_INTEGER specifies Rax, Rcx, Rdx, Rbx, Rbp, Rsi, Rdi, and R8-R15.
  2170. //
  2171. // CONTEXT_SEGMENTS specifies SegDs, SegEs, SegFs, and SegGs.
  2172. //
  2173. // CONTEXT_DEBUG_REGISTERS specifies Dr0-Dr3 and Dr6-Dr7.
  2174. //
  2175. // CONTEXT_MMX_REGISTERS specifies the floating point and extended registers
  2176. // Mm0/St0-Mm7/St7 and Xmm0-Xmm15).
  2177. //
  2178. typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
  2179. //
  2180. // Register parameter home addresses.
  2181. //
  2182. // N.B. These fields are for convience - they could be used to extend the
  2183. // context record in the future.
  2184. //
  2185. DWORD64 P1Home;
  2186. DWORD64 P2Home;
  2187. DWORD64 P3Home;
  2188. DWORD64 P4Home;
  2189. DWORD64 P5Home;
  2190. DWORD64 P6Home;
  2191. //
  2192. // Control flags.
  2193. //
  2194. DWORD ContextFlags;
  2195. DWORD MxCsr;
  2196. //
  2197. // Segment Registers and processor flags.
  2198. //
  2199. WORD SegCs;
  2200. WORD SegDs;
  2201. WORD SegEs;
  2202. WORD SegFs;
  2203. WORD SegGs;
  2204. WORD SegSs;
  2205. DWORD EFlags;
  2206. //
  2207. // Debug registers
  2208. //
  2209. DWORD64 Dr0;
  2210. DWORD64 Dr1;
  2211. DWORD64 Dr2;
  2212. DWORD64 Dr3;
  2213. DWORD64 Dr6;
  2214. DWORD64 Dr7;
  2215. //
  2216. // Integer registers.
  2217. //
  2218. DWORD64 Rax;
  2219. DWORD64 Rcx;
  2220. DWORD64 Rdx;
  2221. DWORD64 Rbx;
  2222. DWORD64 Rsp;
  2223. DWORD64 Rbp;
  2224. DWORD64 Rsi;
  2225. DWORD64 Rdi;
  2226. DWORD64 R8;
  2227. DWORD64 R9;
  2228. DWORD64 R10;
  2229. DWORD64 R11;
  2230. DWORD64 R12;
  2231. DWORD64 R13;
  2232. DWORD64 R14;
  2233. DWORD64 R15;
  2234. //
  2235. // Program counter.
  2236. //
  2237. DWORD64 Rip;
  2238. //
  2239. // Floating point state.
  2240. //
  2241. union {
  2242. XMM_SAVE_AREA32 FltSave;
  2243. struct {
  2244. M128A Header[2];
  2245. M128A Legacy[8];
  2246. M128A Xmm0;
  2247. M128A Xmm1;
  2248. M128A Xmm2;
  2249. M128A Xmm3;
  2250. M128A Xmm4;
  2251. M128A Xmm5;
  2252. M128A Xmm6;
  2253. M128A Xmm7;
  2254. M128A Xmm8;
  2255. M128A Xmm9;
  2256. M128A Xmm10;
  2257. M128A Xmm11;
  2258. M128A Xmm12;
  2259. M128A Xmm13;
  2260. M128A Xmm14;
  2261. M128A Xmm15;
  2262. };
  2263. };
  2264. //
  2265. // Vector registers.
  2266. //
  2267. M128A VectorRegister[26];
  2268. DWORD64 VectorControl;
  2269. //
  2270. // Special debug control registers.
  2271. //
  2272. DWORD64 DebugControl;
  2273. DWORD64 LastBranchToRip;
  2274. DWORD64 LastBranchFromRip;
  2275. DWORD64 LastExceptionToRip;
  2276. DWORD64 LastExceptionFromRip;
  2277. } CONTEXT, *PCONTEXT, *LPCONTEXT;
  2278. //
  2279. // Nonvolatile context pointer record.
  2280. //
  2281. typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
  2282. union {
  2283. PM128A FloatingContext[16];
  2284. struct {
  2285. PM128A Xmm0;
  2286. PM128A Xmm1;
  2287. PM128A Xmm2;
  2288. PM128A Xmm3;
  2289. PM128A Xmm4;
  2290. PM128A Xmm5;
  2291. PM128A Xmm6;
  2292. PM128A Xmm7;
  2293. PM128A Xmm8;
  2294. PM128A Xmm9;
  2295. PM128A Xmm10;
  2296. PM128A Xmm11;
  2297. PM128A Xmm12;
  2298. PM128A Xmm13;
  2299. PM128A Xmm14;
  2300. PM128A Xmm15;
  2301. } ;
  2302. } ;
  2303. union {
  2304. PDWORD64 IntegerContext[16];
  2305. struct {
  2306. PDWORD64 Rax;
  2307. PDWORD64 Rcx;
  2308. PDWORD64 Rdx;
  2309. PDWORD64 Rbx;
  2310. PDWORD64 Rsp;
  2311. PDWORD64 Rbp;
  2312. PDWORD64 Rsi;
  2313. PDWORD64 Rdi;
  2314. PDWORD64 R8;
  2315. PDWORD64 R9;
  2316. PDWORD64 R10;
  2317. PDWORD64 R11;
  2318. PDWORD64 R12;
  2319. PDWORD64 R13;
  2320. PDWORD64 R14;
  2321. PDWORD64 R15;
  2322. } ;
  2323. } ;
  2324. } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
  2325. #elif defined(_ARM_)
  2326. #define CONTEXT_ARM 0x00200000L
  2327. // end_wx86
  2328. #define CONTEXT_CONTROL (CONTEXT_ARM | 0x1L)
  2329. #define CONTEXT_INTEGER (CONTEXT_ARM | 0x2L)
  2330. #define CONTEXT_FLOATING_POINT (CONTEXT_ARM | 0x4L)
  2331. #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM | 0x8L)
  2332. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
  2333. #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
  2334. #define CONTEXT_EXCEPTION_ACTIVE 0x8000000L
  2335. #define CONTEXT_SERVICE_ACTIVE 0x10000000L
  2336. #define CONTEXT_EXCEPTION_REQUEST 0x40000000L
  2337. #define CONTEXT_EXCEPTION_REPORTING 0x80000000L
  2338. //
  2339. // This flag is set by the unwinder if it has unwound to a call
  2340. // site, and cleared whenever it unwinds through a trap frame.
  2341. // It is used by language-specific exception handlers to help
  2342. // differentiate exception scopes during dispatching.
  2343. //
  2344. #define CONTEXT_UNWOUND_TO_CALL 0x20000000
  2345. //
  2346. // Specify the number of breakpoints and watchpoints that the OS
  2347. // will track. Architecturally, ARM supports up to 16. In practice,
  2348. // however, almost no one implements more than 4 of each.
  2349. //
  2350. #define ARM_MAX_BREAKPOINTS 8
  2351. #define ARM_MAX_WATCHPOINTS 1
  2352. typedef struct _NEON128 {
  2353. ULONGLONG Low;
  2354. LONGLONG High;
  2355. } NEON128, *PNEON128;
  2356. //
  2357. // Context Frame
  2358. //
  2359. // This frame has a several purposes: 1) it is used as an argument to
  2360. // NtContinue, 2) it is used to constuct a call frame for APC delivery,
  2361. // and 3) it is used in the user level thread creation routines.
  2362. //
  2363. //
  2364. // The flags field within this record controls the contents of a CONTEXT
  2365. // record.
  2366. //
  2367. // If the context record is used as an input parameter, then for each
  2368. // portion of the context record controlled by a flag whose value is
  2369. // set, it is assumed that that portion of the context record contains
  2370. // valid context. If the context record is being used to modify a threads
  2371. // context, then only that portion of the threads context is modified.
  2372. //
  2373. // If the context record is used as an output parameter to capture the
  2374. // context of a thread, then only those portions of the thread's context
  2375. // corresponding to set flags will be returned.
  2376. //
  2377. // CONTEXT_CONTROL specifies Sp, Lr, Pc, and Cpsr
  2378. //
  2379. // CONTEXT_INTEGER specifies R0-R12
  2380. //
  2381. // CONTEXT_FLOATING_POINT specifies Q0-Q15 / D0-D31 / S0-S31
  2382. //
  2383. // CONTEXT_DEBUG_REGISTERS specifies up to 16 of DBGBVR, DBGBCR, DBGWVR,
  2384. // DBGWCR.
  2385. //
  2386. typedef struct DECLSPEC_ALIGN(8) _CONTEXT {
  2387. //
  2388. // Control flags.
  2389. //
  2390. DWORD ContextFlags;
  2391. //
  2392. // Integer registers
  2393. //
  2394. DWORD R0;
  2395. DWORD R1;
  2396. DWORD R2;
  2397. DWORD R3;
  2398. DWORD R4;
  2399. DWORD R5;
  2400. DWORD R6;
  2401. DWORD R7;
  2402. DWORD R8;
  2403. DWORD R9;
  2404. DWORD R10;
  2405. DWORD R11;
  2406. DWORD R12;
  2407. //
  2408. // Control Registers
  2409. //
  2410. DWORD Sp;
  2411. DWORD Lr;
  2412. DWORD Pc;
  2413. DWORD Cpsr;
  2414. //
  2415. // Floating Point/NEON Registers
  2416. //
  2417. DWORD Fpscr;
  2418. DWORD Padding;
  2419. union {
  2420. NEON128 Q[16];
  2421. ULONGLONG D[32];
  2422. DWORD S[32];
  2423. };
  2424. //
  2425. // Debug registers
  2426. //
  2427. DWORD Bvr[ARM_MAX_BREAKPOINTS];
  2428. DWORD Bcr[ARM_MAX_BREAKPOINTS];
  2429. DWORD Wvr[ARM_MAX_WATCHPOINTS];
  2430. DWORD Wcr[ARM_MAX_WATCHPOINTS];
  2431. DWORD Padding2[2];
  2432. } CONTEXT, *PCONTEXT, *LPCONTEXT;
  2433. //
  2434. // Nonvolatile context pointer record.
  2435. //
  2436. typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
  2437. PDWORD R4;
  2438. PDWORD R5;
  2439. PDWORD R6;
  2440. PDWORD R7;
  2441. PDWORD R8;
  2442. PDWORD R9;
  2443. PDWORD R10;
  2444. PDWORD R11;
  2445. PDWORD Lr;
  2446. PULONGLONG D8;
  2447. PULONGLONG D9;
  2448. PULONGLONG D10;
  2449. PULONGLONG D11;
  2450. PULONGLONG D12;
  2451. PULONGLONG D13;
  2452. PULONGLONG D14;
  2453. PULONGLONG D15;
  2454. } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
  2455. typedef struct _IMAGE_ARM_RUNTIME_FUNCTION_ENTRY {
  2456. DWORD BeginAddress;
  2457. union {
  2458. DWORD UnwindData;
  2459. struct {
  2460. DWORD Flag : 2;
  2461. DWORD FunctionLength : 11;
  2462. DWORD Ret : 2;
  2463. DWORD H : 1;
  2464. DWORD Reg : 3;
  2465. DWORD R : 1;
  2466. DWORD L : 1;
  2467. DWORD C : 1;
  2468. DWORD StackAdjust : 10;
  2469. };
  2470. };
  2471. } IMAGE_ARM_RUNTIME_FUNCTION_ENTRY, * PIMAGE_ARM_RUNTIME_FUNCTION_ENTRY;
  2472. #elif defined(_ARM64_)
  2473. #define CONTEXT_ARM64 0x00400000L
  2474. #define CONTEXT_CONTROL (CONTEXT_ARM64 | 0x1L)
  2475. #define CONTEXT_INTEGER (CONTEXT_ARM64 | 0x2L)
  2476. #define CONTEXT_FLOATING_POINT (CONTEXT_ARM64 | 0x4L)
  2477. #define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x8L)
  2478. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
  2479. #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
  2480. #define CONTEXT_EXCEPTION_ACTIVE 0x8000000L
  2481. #define CONTEXT_SERVICE_ACTIVE 0x10000000L
  2482. #define CONTEXT_EXCEPTION_REQUEST 0x40000000L
  2483. #define CONTEXT_EXCEPTION_REPORTING 0x80000000L
  2484. //
  2485. // This flag is set by the unwinder if it has unwound to a call
  2486. // site, and cleared whenever it unwinds through a trap frame.
  2487. // It is used by language-specific exception handlers to help
  2488. // differentiate exception scopes during dispatching.
  2489. //
  2490. #define CONTEXT_UNWOUND_TO_CALL 0x20000000
  2491. //
  2492. // Define initial Cpsr/Fpscr value
  2493. //
  2494. #define INITIAL_CPSR 0x10
  2495. #define INITIAL_FPSCR 0
  2496. // begin_ntoshvp
  2497. //
  2498. // Specify the number of breakpoints and watchpoints that the OS
  2499. // will track. Architecturally, ARM64 supports up to 16. In practice,
  2500. // however, almost no one implements more than 4 of each.
  2501. //
  2502. #define ARM64_MAX_BREAKPOINTS 8
  2503. #define ARM64_MAX_WATCHPOINTS 2
  2504. //
  2505. // Context Frame
  2506. //
  2507. // This frame has a several purposes: 1) it is used as an argument to
  2508. // NtContinue, 2) it is used to constuct a call frame for APC delivery,
  2509. // and 3) it is used in the user level thread creation routines.
  2510. //
  2511. //
  2512. // The flags field within this record controls the contents of a CONTEXT
  2513. // record.
  2514. //
  2515. // If the context record is used as an input parameter, then for each
  2516. // portion of the context record controlled by a flag whose value is
  2517. // set, it is assumed that that portion of the context record contains
  2518. // valid context. If the context record is being used to modify a threads
  2519. // context, then only that portion of the threads context is modified.
  2520. //
  2521. // If the context record is used as an output parameter to capture the
  2522. // context of a thread, then only those portions of the thread's context
  2523. // corresponding to set flags will be returned.
  2524. //
  2525. // CONTEXT_CONTROL specifies Sp, Lr, Pc, and Cpsr
  2526. //
  2527. // CONTEXT_INTEGER specifies R0-R12
  2528. //
  2529. // CONTEXT_FLOATING_POINT specifies Q0-Q15 / D0-D31 / S0-S31
  2530. //
  2531. // CONTEXT_DEBUG_REGISTERS specifies up to 16 of DBGBVR, DBGBCR, DBGWVR,
  2532. // DBGWCR.
  2533. //
  2534. typedef struct _NEON128 {
  2535. ULONGLONG Low;
  2536. LONGLONG High;
  2537. } NEON128, *PNEON128;
  2538. typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
  2539. //
  2540. // Control flags.
  2541. //
  2542. /* +0x000 */ DWORD ContextFlags;
  2543. //
  2544. // Integer registers
  2545. //
  2546. /* +0x004 */ DWORD Cpsr; // NZVF + DAIF + CurrentEL + SPSel
  2547. /* +0x008 */ union {
  2548. struct {
  2549. DWORD64 X0;
  2550. DWORD64 X1;
  2551. DWORD64 X2;
  2552. DWORD64 X3;
  2553. DWORD64 X4;
  2554. DWORD64 X5;
  2555. DWORD64 X6;
  2556. DWORD64 X7;
  2557. DWORD64 X8;
  2558. DWORD64 X9;
  2559. DWORD64 X10;
  2560. DWORD64 X11;
  2561. DWORD64 X12;
  2562. DWORD64 X13;
  2563. DWORD64 X14;
  2564. DWORD64 X15;
  2565. DWORD64 X16;
  2566. DWORD64 X17;
  2567. DWORD64 X18;
  2568. DWORD64 X19;
  2569. DWORD64 X20;
  2570. DWORD64 X21;
  2571. DWORD64 X22;
  2572. DWORD64 X23;
  2573. DWORD64 X24;
  2574. DWORD64 X25;
  2575. DWORD64 X26;
  2576. DWORD64 X27;
  2577. DWORD64 X28;
  2578. };
  2579. DWORD64 X[29];
  2580. };
  2581. /* +0x0f0 */ DWORD64 Fp;
  2582. /* +0x0f8 */ DWORD64 Lr;
  2583. /* +0x100 */ DWORD64 Sp;
  2584. /* +0x108 */ DWORD64 Pc;
  2585. //
  2586. // Floating Point/NEON Registers
  2587. //
  2588. /* +0x110 */ NEON128 V[32];
  2589. /* +0x310 */ DWORD Fpcr;
  2590. /* +0x314 */ DWORD Fpsr;
  2591. //
  2592. // Debug registers
  2593. //
  2594. /* +0x318 */ DWORD Bcr[ARM64_MAX_BREAKPOINTS];
  2595. /* +0x338 */ DWORD64 Bvr[ARM64_MAX_BREAKPOINTS];
  2596. /* +0x378 */ DWORD Wcr[ARM64_MAX_WATCHPOINTS];
  2597. /* +0x380 */ DWORD64 Wvr[ARM64_MAX_WATCHPOINTS];
  2598. /* +0x390 */
  2599. } CONTEXT, *PCONTEXT, *LPCONTEXT;
  2600. //
  2601. // Nonvolatile context pointer record.
  2602. //
  2603. typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
  2604. PDWORD64 X19;
  2605. PDWORD64 X20;
  2606. PDWORD64 X21;
  2607. PDWORD64 X22;
  2608. PDWORD64 X23;
  2609. PDWORD64 X24;
  2610. PDWORD64 X25;
  2611. PDWORD64 X26;
  2612. PDWORD64 X27;
  2613. PDWORD64 X28;
  2614. PDWORD64 Fp;
  2615. PDWORD64 Lr;
  2616. PDWORD64 D8;
  2617. PDWORD64 D9;
  2618. PDWORD64 D10;
  2619. PDWORD64 D11;
  2620. PDWORD64 D12;
  2621. PDWORD64 D13;
  2622. PDWORD64 D14;
  2623. PDWORD64 D15;
  2624. } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
  2625. #else
  2626. #error Unknown architecture for defining CONTEXT.
  2627. #endif
  2628. PALIMPORT
  2629. BOOL
  2630. PALAPI
  2631. GetThreadContext(
  2632. IN HANDLE hThread,
  2633. IN OUT LPCONTEXT lpContext);
  2634. PALIMPORT
  2635. BOOL
  2636. PALAPI
  2637. SetThreadContext(
  2638. IN HANDLE hThread,
  2639. IN CONST CONTEXT *lpContext);
  2640. #define THREAD_BASE_PRIORITY_LOWRT 15
  2641. #define THREAD_BASE_PRIORITY_MAX 2
  2642. #define THREAD_BASE_PRIORITY_MIN (-2)
  2643. #define THREAD_BASE_PRIORITY_IDLE (-15)
  2644. #define THREAD_PRIORITY_LOWEST THREAD_BASE_PRIORITY_MIN
  2645. #define THREAD_PRIORITY_BELOW_NORMAL (THREAD_PRIORITY_LOWEST+1)
  2646. #define THREAD_PRIORITY_NORMAL 0
  2647. #define THREAD_PRIORITY_HIGHEST THREAD_BASE_PRIORITY_MAX
  2648. #define THREAD_PRIORITY_ABOVE_NORMAL (THREAD_PRIORITY_HIGHEST-1)
  2649. #define THREAD_PRIORITY_ERROR_RETURN (MAXLONG)
  2650. #define THREAD_PRIORITY_TIME_CRITICAL THREAD_BASE_PRIORITY_LOWRT
  2651. #define THREAD_PRIORITY_IDLE THREAD_BASE_PRIORITY_IDLE
  2652. PALIMPORT
  2653. int
  2654. PALAPI
  2655. GetThreadPriority(
  2656. IN HANDLE hThread);
  2657. PALIMPORT
  2658. BOOL
  2659. PALAPI
  2660. SetThreadPriority(
  2661. IN HANDLE hThread,
  2662. IN int nPriority);
  2663. PALIMPORT
  2664. BOOL
  2665. PALAPI
  2666. GetThreadTimes(
  2667. IN HANDLE hThread,
  2668. OUT LPFILETIME lpCreationTime,
  2669. OUT LPFILETIME lpExitTime,
  2670. OUT LPFILETIME lpKernelTime,
  2671. OUT LPFILETIME lpUserTime);
  2672. PALIMPORT
  2673. void *
  2674. PALAPI
  2675. PAL_GetStackBase();
  2676. PALIMPORT
  2677. void *
  2678. PALAPI
  2679. PAL_GetStackLimit();
  2680. PALIMPORT
  2681. DWORD
  2682. PALAPI
  2683. PAL_GetLogicalCpuCountFromOS();
  2684. PALIMPORT
  2685. size_t
  2686. PALAPI
  2687. PAL_GetLogicalProcessorCacheSizeFromOS();
  2688. typedef BOOL (*ReadMemoryWordCallback)(SIZE_T address, SIZE_T *value);
  2689. #if defined(_AMD64_) || defined(_ARM_) || defined(_ARM64_)
  2690. PALIMPORT BOOL PALAPI PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers);
  2691. PALIMPORT BOOL PALAPI PAL_VirtualUnwindOutOfProc(CONTEXT *context,
  2692. KNONVOLATILE_CONTEXT_POINTERS *contextPointers,
  2693. DWORD pid,
  2694. ReadMemoryWordCallback readMemCallback);
  2695. #endif
  2696. #define GetLogicalProcessorCacheSizeFromOS PAL_GetLogicalProcessorCacheSizeFromOS
  2697. #ifdef PLATFORM_UNIX
  2698. #if defined(__FreeBSD__) && defined(_X86_)
  2699. #define PAL_CS_NATIVE_DATA_SIZE 12
  2700. #elif defined(__FreeBSD__) && defined(__x86_64__)
  2701. #define PAL_CS_NATIVE_DATA_SIZE 24
  2702. #elif defined(__sun__)
  2703. #define PAL_CS_NATIVE_DATA_SIZE 48
  2704. #elif defined(__hpux__) && (defined(__hppa__) || defined (__ia64__))
  2705. #define PAL_CS_NATIVE_DATA_SIZE 148
  2706. #elif defined(_AIX)
  2707. #define PAL_CS_NATIVE_DATA_SIZE 100
  2708. #elif defined(__APPLE__) && defined(__i386__)
  2709. #define PAL_CS_NATIVE_DATA_SIZE 76
  2710. #elif defined(__APPLE__) && defined(__x86_64__)
  2711. #define PAL_CS_NATIVE_DATA_SIZE 120
  2712. #elif defined(__LINUX__) && defined(__i386__)
  2713. #define PAL_CS_NATIVE_DATA_SIZE 56
  2714. #elif defined(__LINUX__) && defined(__x86_64__)
  2715. #define PAL_CS_NATIVE_DATA_SIZE 96
  2716. #elif defined(__ANDROID__) && defined(_ARM_)
  2717. #define PAL_CS_NATIVE_DATA_SIZE 12
  2718. #elif defined(__LINUX__) && defined(_ARM_)
  2719. #define PAL_CS_NATIVE_DATA_SIZE 80
  2720. #elif defined(__LINUX__) && defined(_ARM64_)
  2721. #define PAL_CS_NATIVE_DATA_SIZE 116
  2722. #else
  2723. #warning
  2724. #error PAL_CS_NATIVE_DATA_SIZE is not defined for this architecture
  2725. #endif
  2726. #endif // PLATFORM_UNIX
  2727. //
  2728. typedef struct _CRITICAL_SECTION {
  2729. PVOID DebugInfo;
  2730. LONG LockCount;
  2731. LONG RecursionCount;
  2732. HANDLE OwningThread;
  2733. HANDLE LockSemaphore;
  2734. ULONG_PTR SpinCount;
  2735. #ifdef PLATFORM_UNIX
  2736. BOOL bInternal;
  2737. volatile DWORD dwInitState;
  2738. union CSNativeDataStorage
  2739. {
  2740. BYTE rgNativeDataStorage[PAL_CS_NATIVE_DATA_SIZE];
  2741. VOID * pvAlign; // make sure the storage is machine-pointer-size aligned
  2742. } csnds;
  2743. #endif // PLATFORM_UNIX
  2744. } CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION;
  2745. PALIMPORT VOID PALAPI EnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
  2746. PALIMPORT VOID PALAPI LeaveCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
  2747. PALIMPORT VOID PALAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection);
  2748. PALIMPORT BOOL PALAPI InitializeCriticalSectionEx(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount, DWORD Flags);
  2749. PALIMPORT BOOL PALAPI InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount);
  2750. PALIMPORT VOID PALAPI DeleteCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
  2751. PALIMPORT BOOL PALAPI TryEnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
  2752. #define SEM_FAILCRITICALERRORS 0x0001
  2753. #define SEM_NOOPENFILEERRORBOX 0x8000
  2754. PALIMPORT
  2755. UINT
  2756. PALAPI
  2757. SetErrorMode(
  2758. IN UINT uMode);
  2759. #define PAGE_NOACCESS 0x01
  2760. #define PAGE_READONLY 0x02
  2761. #define PAGE_READWRITE 0x04
  2762. #define PAGE_WRITECOPY 0x08
  2763. #define PAGE_EXECUTE 0x10
  2764. #define PAGE_EXECUTE_READ 0x20
  2765. #define PAGE_EXECUTE_READWRITE 0x40
  2766. #define PAGE_EXECUTE_WRITECOPY 0x80
  2767. #define MEM_COMMIT 0x1000
  2768. #define MEM_RESERVE 0x2000
  2769. #define MEM_DECOMMIT 0x4000
  2770. #define MEM_RELEASE 0x8000
  2771. #define MEM_RESET 0x80000
  2772. #define MEM_FREE 0x10000
  2773. #define MEM_PRIVATE 0x20000
  2774. #define MEM_MAPPED 0x40000
  2775. #define MEM_TOP_DOWN 0x100000
  2776. #define MEM_WRITE_WATCH 0x200000
  2777. #define MEM_RESERVE_EXECUTABLE 0x40000000 // reserve memory using executable memory allocator
  2778. PALIMPORT
  2779. HANDLE
  2780. PALAPI
  2781. CreateFileMappingA(
  2782. IN HANDLE hFile,
  2783. IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
  2784. IN DWORD flProtect,
  2785. IN DWORD dwMaximumSizeHigh,
  2786. IN DWORD dwMaximumSizeLow,
  2787. IN LPCSTR lpName);
  2788. PALIMPORT
  2789. HANDLE
  2790. PALAPI
  2791. CreateFileMappingW(
  2792. IN HANDLE hFile,
  2793. IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
  2794. IN DWORD flProtect,
  2795. IN DWORD dwMaxmimumSizeHigh,
  2796. IN DWORD dwMaximumSizeLow,
  2797. IN LPCWSTR lpName);
  2798. #ifdef UNICODE
  2799. #define CreateFileMapping CreateFileMappingW
  2800. #else
  2801. #define CreateFileMapping CreateFileMappingA
  2802. #endif
  2803. #define SECTION_QUERY 0x0001
  2804. #define SECTION_MAP_WRITE 0x0002
  2805. #define SECTION_MAP_READ 0x0004
  2806. #define SECTION_ALL_ACCESS (SECTION_MAP_READ | SECTION_MAP_WRITE) // diff from winnt.h
  2807. #define FILE_MAP_WRITE SECTION_MAP_WRITE
  2808. #define FILE_MAP_READ SECTION_MAP_READ
  2809. #define FILE_MAP_ALL_ACCESS SECTION_ALL_ACCESS
  2810. #define FILE_MAP_COPY SECTION_QUERY
  2811. PALIMPORT
  2812. HANDLE
  2813. PALAPI
  2814. OpenFileMappingA(
  2815. IN DWORD dwDesiredAccess,
  2816. IN BOOL bInheritHandle,
  2817. IN LPCSTR lpName);
  2818. PALIMPORT
  2819. HANDLE
  2820. PALAPI
  2821. OpenFileMappingW(
  2822. IN DWORD dwDesiredAccess,
  2823. IN BOOL bInheritHandle,
  2824. IN LPCWSTR lpName);
  2825. #ifdef UNICODE
  2826. #define OpenFileMapping OpenFileMappingW
  2827. #else
  2828. #define OpenFileMapping OpenFileMappingA
  2829. #endif
  2830. PALIMPORT
  2831. LPVOID
  2832. PALAPI
  2833. MapViewOfFile(
  2834. IN HANDLE hFileMappingObject,
  2835. IN DWORD dwDesiredAccess,
  2836. IN DWORD dwFileOffsetHigh,
  2837. IN DWORD dwFileOffsetLow,
  2838. IN SIZE_T dwNumberOfBytesToMap);
  2839. PALIMPORT
  2840. LPVOID
  2841. PALAPI
  2842. MapViewOfFileEx(
  2843. IN HANDLE hFileMappingObject,
  2844. IN DWORD dwDesiredAccess,
  2845. IN DWORD dwFileOffsetHigh,
  2846. IN DWORD dwFileOffsetLow,
  2847. IN SIZE_T dwNumberOfBytesToMap,
  2848. IN LPVOID lpBaseAddress);
  2849. PALIMPORT
  2850. BOOL
  2851. PALAPI
  2852. FlushViewOfFile(
  2853. IN LPVOID lpBaseAddress,
  2854. IN SIZE_T dwNumberOfBytesToFlush);
  2855. PALIMPORT
  2856. BOOL
  2857. PALAPI
  2858. UnmapViewOfFile(
  2859. IN LPCVOID lpBaseAddress);
  2860. PALIMPORT
  2861. HMODULE
  2862. PALAPI
  2863. LoadLibraryA(
  2864. IN LPCSTR lpLibFileName);
  2865. PALIMPORT
  2866. HMODULE
  2867. PALAPI
  2868. LoadLibraryW(
  2869. IN LPCWSTR lpLibFileName);
  2870. PALIMPORT
  2871. HMODULE
  2872. PALAPI
  2873. LoadLibraryExA(
  2874. IN LPCSTR lpLibFileName,
  2875. IN /*Reserved*/ HANDLE hFile,
  2876. IN DWORD dwFlags);
  2877. PALIMPORT
  2878. HMODULE
  2879. PALAPI
  2880. LoadLibraryExW(
  2881. IN LPCWSTR lpLibFileName,
  2882. IN /*Reserved*/ HANDLE hFile,
  2883. IN DWORD dwFlags);
  2884. PALIMPORT
  2885. void *
  2886. PALAPI
  2887. PAL_LoadLibraryDirect(
  2888. IN LPCWSTR lpLibFileName);
  2889. PALIMPORT
  2890. HMODULE
  2891. PALAPI
  2892. PAL_RegisterLibraryDirect(
  2893. IN void *dl_handle,
  2894. IN LPCWSTR lpLibFileName);
  2895. /*++
  2896. Function:
  2897. PAL_LOADLoadPEFile
  2898. Abstract
  2899. Loads a PE file into memory. Properly maps all of the sections in the PE file. Returns a pointer to the
  2900. loaded base.
  2901. Parameters:
  2902. IN hFile - The file to load
  2903. Return value:
  2904. A valid base address if successful.
  2905. 0 if failure
  2906. --*/
  2907. void *
  2908. PALAPI
  2909. PAL_LOADLoadPEFile(HANDLE hFile);
  2910. /*++
  2911. PAL_LOADUnloadPEFile
  2912. Unload a PE file that was loaded by PAL_LOADLoadPEFile().
  2913. Parameters:
  2914. IN ptr - the file pointer returned by PAL_LOADLoadPEFile()
  2915. Return value:
  2916. TRUE - success
  2917. FALSE - failure (incorrect ptr, etc.)
  2918. --*/
  2919. BOOL
  2920. PALAPI
  2921. PAL_LOADUnloadPEFile(void * ptr);
  2922. #ifdef UNICODE
  2923. #define LoadLibrary LoadLibraryW
  2924. #define LoadLibraryEx LoadLibraryExW
  2925. #else
  2926. #define LoadLibrary LoadLibraryA
  2927. #define LoadLibraryEx LoadLibraryExA
  2928. #endif
  2929. typedef INT_PTR (PALAPI *FARPROC)();
  2930. PALIMPORT
  2931. FARPROC
  2932. PALAPI
  2933. GetProcAddress(
  2934. IN HMODULE hModule,
  2935. IN LPCSTR lpProcName);
  2936. PALIMPORT
  2937. BOOL
  2938. PALAPI
  2939. FreeLibrary(
  2940. IN OUT HMODULE hLibModule);
  2941. PALIMPORT
  2942. PAL_NORETURN
  2943. VOID
  2944. PALAPI
  2945. FreeLibraryAndExitThread(
  2946. IN HMODULE hLibModule,
  2947. IN DWORD dwExitCode);
  2948. PALIMPORT
  2949. BOOL
  2950. PALAPI
  2951. DisableThreadLibraryCalls(
  2952. IN HMODULE hLibModule);
  2953. PALIMPORT
  2954. DWORD
  2955. PALAPI
  2956. GetModuleFileNameA(
  2957. IN HMODULE hModule,
  2958. OUT LPSTR lpFileName,
  2959. IN DWORD nSize);
  2960. PALIMPORT
  2961. DWORD
  2962. PALAPI
  2963. GetModuleFileNameW(
  2964. IN HMODULE hModule,
  2965. OUT LPWSTR lpFileName,
  2966. IN DWORD nSize);
  2967. #ifdef UNICODE
  2968. #define GetModuleFileName GetModuleFileNameW
  2969. #else
  2970. #define GetModuleFileName GetModuleFileNameA
  2971. #endif
  2972. PALIMPORT
  2973. DWORD
  2974. PALAPI
  2975. GetModuleFileNameExW(
  2976. IN HANDLE hProcess,
  2977. IN HMODULE hModule,
  2978. OUT LPWSTR lpFilename,
  2979. IN DWORD nSize
  2980. );
  2981. #ifdef UNICODE
  2982. #define GetModuleFileNameEx GetModuleFileNameExW
  2983. #endif
  2984. PALIMPORT
  2985. HMODULE
  2986. PALAPI
  2987. GetModuleHandleW(
  2988. IN OPTIONAL LPCWSTR lpModuleName
  2989. );
  2990. #ifdef UNICODE
  2991. #define GetModuleHandle GetModuleHandleW
  2992. #endif
  2993. PALIMPORT
  2994. BOOL
  2995. PALAPI
  2996. GetModuleHandleExW(
  2997. IN DWORD dwFlags,
  2998. IN OPTIONAL LPCWSTR lpModuleName,
  2999. OUT HMODULE *phModule);
  3000. #ifdef UNICODE
  3001. #define GetModuleHandleEx GetModuleHandleExW
  3002. #endif
  3003. // Get base address of the module containing a given symbol
  3004. PALAPI
  3005. LPCVOID
  3006. PAL_GetSymbolModuleBase(void *symbol);
  3007. PALIMPORT
  3008. LPVOID
  3009. PALAPI
  3010. VirtualAlloc(
  3011. IN LPVOID lpAddress,
  3012. IN SIZE_T dwSize,
  3013. IN DWORD flAllocationType,
  3014. IN DWORD flProtect);
  3015. PALIMPORT
  3016. LPVOID
  3017. PALAPI
  3018. VirtualAllocEx(
  3019. IN HANDLE hProcess,
  3020. IN LPVOID lpAddress,
  3021. IN SIZE_T dwSize,
  3022. IN DWORD flAllocationType,
  3023. IN DWORD flProtect);
  3024. PALIMPORT
  3025. BOOL
  3026. PALAPI
  3027. VirtualFree(
  3028. IN LPVOID lpAddress,
  3029. IN SIZE_T dwSize,
  3030. IN DWORD dwFreeType);
  3031. PALIMPORT
  3032. BOOL
  3033. PALAPI
  3034. VirtualFreeEx(
  3035. IN HANDLE hProcess,
  3036. IN LPVOID lpAddress,
  3037. IN SIZE_T dwSize,
  3038. IN DWORD dwFreeType);
  3039. PALIMPORT
  3040. BOOL
  3041. PALAPI
  3042. VirtualProtect(
  3043. IN LPVOID lpAddress,
  3044. IN SIZE_T dwSize,
  3045. IN DWORD flNewProtect,
  3046. OUT PDWORD lpflOldProtect);
  3047. PALIMPORT
  3048. BOOL
  3049. PALAPI
  3050. VirtualProtectEx(
  3051. IN HANDLE hProcess,
  3052. IN LPVOID lpAddress,
  3053. IN SIZE_T dwSize,
  3054. IN DWORD flNewProtect,
  3055. OUT PDWORD lpflOldProtect);
  3056. typedef struct _MEMORYSTATUSEX {
  3057. DWORD dwLength;
  3058. DWORD dwMemoryLoad;
  3059. DWORDLONG ullTotalPhys;
  3060. DWORDLONG ullAvailPhys;
  3061. DWORDLONG ullTotalPageFile;
  3062. DWORDLONG ullAvailPageFile;
  3063. DWORDLONG ullTotalVirtual;
  3064. DWORDLONG ullAvailVirtual;
  3065. DWORDLONG ullAvailExtendedVirtual;
  3066. } MEMORYSTATUSEX, *LPMEMORYSTATUSEX;
  3067. PALIMPORT
  3068. BOOL
  3069. PALAPI
  3070. GlobalMemoryStatusEx(
  3071. IN OUT LPMEMORYSTATUSEX lpBuffer);
  3072. typedef struct _MEMORY_BASIC_INFORMATION {
  3073. PVOID BaseAddress;
  3074. PVOID AllocationBase_PAL_Undefined;
  3075. DWORD AllocationProtect;
  3076. SIZE_T RegionSize;
  3077. DWORD State;
  3078. DWORD Protect;
  3079. DWORD Type;
  3080. } MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
  3081. PALIMPORT
  3082. SIZE_T
  3083. PALAPI
  3084. VirtualQuery(
  3085. IN LPCVOID lpAddress,
  3086. OUT PMEMORY_BASIC_INFORMATION lpBuffer,
  3087. IN SIZE_T dwLength);
  3088. PALIMPORT
  3089. SIZE_T
  3090. PALAPI
  3091. VirtualQueryEx(
  3092. IN HANDLE hProcess,
  3093. IN LPCVOID lpAddress,
  3094. OUT PMEMORY_BASIC_INFORMATION lpBuffer,
  3095. IN SIZE_T dwLength);
  3096. PALIMPORT
  3097. BOOL
  3098. PALAPI
  3099. ReadProcessMemory(
  3100. IN HANDLE hProcess,
  3101. IN LPCVOID lpBaseAddress,
  3102. OUT LPVOID lpBuffer,
  3103. IN SIZE_T nSize,
  3104. OUT SIZE_T * lpNumberOfBytesRead);
  3105. PALIMPORT
  3106. VOID
  3107. PALAPI
  3108. RtlMoveMemory(
  3109. IN PVOID Destination,
  3110. IN CONST VOID *Source,
  3111. IN SIZE_T Length);
  3112. PALIMPORT
  3113. VOID
  3114. PALAPI
  3115. RtlZeroMemory(
  3116. IN PVOID Destination,
  3117. IN SIZE_T Length);
  3118. #define MoveMemory memmove
  3119. #define CopyMemory memcpy
  3120. #define FillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
  3121. #define ZeroMemory(Destination,Length) memset((Destination),0,(Length))
  3122. PALIMPORT
  3123. HANDLE
  3124. PALAPI
  3125. GetProcessHeap(
  3126. VOID);
  3127. #define HEAP_ZERO_MEMORY 0x00000008
  3128. PALIMPORT
  3129. HANDLE
  3130. PALAPI
  3131. HeapCreate(
  3132. IN DWORD flOptions,
  3133. IN SIZE_T dwInitialSize,
  3134. IN SIZE_T dwMaximumSize);
  3135. PALIMPORT
  3136. LPVOID
  3137. PALAPI
  3138. HeapAlloc(
  3139. IN HANDLE hHeap,
  3140. IN DWORD dwFlags,
  3141. IN SIZE_T dwBytes);
  3142. PALIMPORT
  3143. LPVOID
  3144. PALAPI
  3145. HeapReAlloc(
  3146. IN HANDLE hHeap,
  3147. IN DWORD dwFlags,
  3148. IN LPVOID lpMem,
  3149. IN SIZE_T dwBytes
  3150. );
  3151. PALIMPORT
  3152. BOOL
  3153. PALAPI
  3154. HeapFree(
  3155. IN HANDLE hHeap,
  3156. IN DWORD dwFlags,
  3157. IN LPVOID lpMem);
  3158. typedef enum _HEAP_INFORMATION_CLASS {
  3159. HeapCompatibilityInformation,
  3160. HeapEnableTerminationOnCorruption
  3161. } HEAP_INFORMATION_CLASS;
  3162. PALIMPORT
  3163. BOOL
  3164. PALAPI
  3165. HeapSetInformation(
  3166. IN OPTIONAL HANDLE HeapHandle,
  3167. IN HEAP_INFORMATION_CLASS HeapInformationClass,
  3168. IN PVOID HeapInformation,
  3169. IN SIZE_T HeapInformationLength);
  3170. #define LMEM_FIXED 0x0000
  3171. #define LMEM_MOVEABLE 0x0002
  3172. #define LMEM_ZEROINIT 0x0040
  3173. #define LPTR (LMEM_FIXED | LMEM_ZEROINIT)
  3174. PALIMPORT
  3175. HLOCAL
  3176. PALAPI
  3177. LocalAlloc(
  3178. IN UINT uFlags,
  3179. IN SIZE_T uBytes);
  3180. PALIMPORT
  3181. HLOCAL
  3182. PALAPI
  3183. LocalReAlloc(
  3184. IN HLOCAL hMem,
  3185. IN SIZE_T uBytes,
  3186. IN UINT uFlags);
  3187. PALIMPORT
  3188. HLOCAL
  3189. PALAPI
  3190. LocalFree(
  3191. IN HLOCAL hMem);
  3192. PALIMPORT
  3193. BOOL
  3194. PALAPI
  3195. FlushInstructionCache(
  3196. IN HANDLE hProcess,
  3197. IN LPCVOID lpBaseAddress,
  3198. IN SIZE_T dwSize);
  3199. #if ENABLE_DOWNLEVEL_FOR_NLS
  3200. PALIMPORT
  3201. BOOL
  3202. PALAPI
  3203. GetStringTypeExW(
  3204. IN LCID Locale,
  3205. IN DWORD dwInfoType,
  3206. IN LPCWSTR lpSrcStr,
  3207. IN int cchSrc,
  3208. OUT LPWORD lpCharType);
  3209. #ifdef UNICODE
  3210. #define GetStringTypeEx GetStringTypeExW
  3211. #endif
  3212. #endif // ENABLE_DOWNLEVEL_FOR_NLS
  3213. #define NORM_IGNORECASE 0x00000001 // ignore case
  3214. #define NORM_IGNOREWIDTH 0x00020000 // ignore width
  3215. #define NORM_LINGUISTIC_CASING 0x08000000 // use linguistic rules for casing
  3216. #ifdef __APPLE__
  3217. #define NORM_IGNORENONSPACE 0x00000002 // ignore nonspacing chars
  3218. #define NORM_IGNORESYMBOLS 0x00000004 // ignore symbols
  3219. #define NORM_IGNOREKANATYPE 0x00010000 // ignore kanatype
  3220. #define SORT_STRINGSORT 0x00001000 // use string sort method
  3221. #else // LINUX
  3222. // Flags with no value on a given platform are given 0 so that program logic can be unaltered (a|0==a)
  3223. #define NORM_IGNORENONSPACE 0x00000000 // ignore nonspacing chars
  3224. #define NORM_IGNORESYMBOLS 0x00000000 // ignore symbols
  3225. #define NORM_IGNOREKANATYPE 0x00000000 // ignore kanatype
  3226. #define SORT_STRINGSORT 0x00000000 // use string sort method
  3227. #endif // __APPLE__
  3228. // __APPLE__ and LINUX
  3229. // Flags with no value on a given platform are given 0 so that program logic can be unaltered (a|0==a)
  3230. #define LINGUISTIC_IGNOREDIACRITIC 0x00000000 // linguistically appropriate 'ignore case'
  3231. #define LINGUISTIC_IGNORECASE 0x00000000 // linguistically appropriate 'ignore nonspace'
  3232. #define SORT_DIGITSASNUMBERS 0x00000000 // Sort digits as numbers (ie: 2 comes before 10)
  3233. typedef struct nlsversioninfo {
  3234. DWORD dwNLSVersionInfoSize;
  3235. DWORD dwNLSVersion;
  3236. DWORD dwDefinedVersion;
  3237. } NLSVERSIONINFO, *LPNLSVERSIONINFO;
  3238. #define CSTR_LESS_THAN 1
  3239. #define CSTR_EQUAL 2
  3240. #define CSTR_GREATER_THAN 3
  3241. #if ENABLE_DOWNLEVEL_FOR_NLS
  3242. PALIMPORT
  3243. int
  3244. PALAPI
  3245. CompareStringA(
  3246. IN LCID Locale,
  3247. IN DWORD dwCmpFlags,
  3248. IN LPCSTR lpString1,
  3249. IN int cchCount1,
  3250. IN LPCSTR lpString2,
  3251. IN int cchCount2);
  3252. PALIMPORT
  3253. int
  3254. PALAPI
  3255. CompareStringW(
  3256. IN LCID Locale,
  3257. IN DWORD dwCmpFlags,
  3258. IN LPCWSTR lpString1,
  3259. IN int cchCount1,
  3260. IN LPCWSTR lpString2,
  3261. IN int cchCount2);
  3262. #endif // ENABLE_DOWNLEVEL_FOR_NLS
  3263. PALIMPORT
  3264. int
  3265. PALAPI
  3266. CompareStringEx(
  3267. IN LPCWSTR lpLocaleName,
  3268. IN DWORD dwCmpFlags,
  3269. IN LPCWSTR lpString1,
  3270. IN int cchCount1,
  3271. IN LPCWSTR lpString2,
  3272. IN int cchCount2,
  3273. IN LPNLSVERSIONINFO lpVersionInformation,
  3274. IN LPVOID lpReserved,
  3275. IN LPARAM lParam);
  3276. #ifdef UNICODE
  3277. #define CompareString CompareStringW
  3278. #endif
  3279. #define MAX_LEADBYTES 12
  3280. #define MAX_DEFAULTCHAR 2
  3281. PALIMPORT
  3282. UINT
  3283. PALAPI
  3284. GetACP(void);
  3285. typedef struct _cpinfo {
  3286. UINT MaxCharSize;
  3287. BYTE DefaultChar[MAX_DEFAULTCHAR];
  3288. BYTE LeadByte[MAX_LEADBYTES];
  3289. } CPINFO, *LPCPINFO;
  3290. PALIMPORT
  3291. BOOL
  3292. PALAPI
  3293. GetCPInfo(
  3294. IN UINT CodePage,
  3295. OUT LPCPINFO lpCPInfo);
  3296. PALIMPORT
  3297. BOOL
  3298. PALAPI
  3299. IsDBCSLeadByteEx(
  3300. IN UINT CodePage,
  3301. IN BYTE TestChar);
  3302. PALIMPORT
  3303. BOOL
  3304. PALAPI
  3305. IsDBCSLeadByte(
  3306. IN BYTE TestChar);
  3307. PALIMPORT
  3308. BOOL
  3309. PALAPI
  3310. IsValidCodePage(
  3311. IN UINT CodePage);
  3312. #define MB_PRECOMPOSED 0x00000001
  3313. #define MB_ERR_INVALID_CHARS 0x00000008
  3314. PALIMPORT
  3315. int
  3316. PALAPI
  3317. MultiByteToWideChar(
  3318. IN UINT CodePage,
  3319. IN DWORD dwFlags,
  3320. IN LPCSTR lpMultiByteStr,
  3321. IN int cbMultiByte,
  3322. OUT LPWSTR lpWideCharStr,
  3323. IN int cchWideChar);
  3324. #define WC_NO_BEST_FIT_CHARS 0x00000400
  3325. PALIMPORT
  3326. int
  3327. PALAPI
  3328. WideCharToMultiByte(
  3329. IN UINT CodePage,
  3330. IN DWORD dwFlags,
  3331. IN LPCWSTR lpWideCharStr,
  3332. IN int cchWideChar,
  3333. OUT LPSTR lpMultiByteStr,
  3334. IN int cbMultyByte,
  3335. IN LPCSTR lpDefaultChar,
  3336. OUT LPBOOL lpUsedDefaultChar);
  3337. #if ENABLE_DOWNLEVEL_FOR_NLS
  3338. PALIMPORT
  3339. LANGID
  3340. PALAPI
  3341. GetSystemDefaultLangID(
  3342. void);
  3343. PALIMPORT
  3344. LANGID
  3345. PALAPI
  3346. GetUserDefaultLangID(
  3347. void);
  3348. PALIMPORT
  3349. BOOL
  3350. PALAPI
  3351. SetThreadLocale(
  3352. IN LCID Locale);
  3353. PALIMPORT
  3354. LCID
  3355. PALAPI
  3356. GetThreadLocale(
  3357. void);
  3358. #endif //ENABLE_DOWNLEVEL_FOR_NLS
  3359. //
  3360. // Locale Types.
  3361. //
  3362. // These types are used for the GetLocaleInfo NLS API routine.
  3363. //
  3364. #ifdef __APPLE__
  3365. //
  3366. // The following LCTypes may be used in combination with any other LCTypes.
  3367. //
  3368. // LOCALE_NOUSEROVERRIDE is also used in GetTimeFormat and
  3369. // GetDateFormat.
  3370. //
  3371. // LOCALE_RETURN_NUMBER will return the result from GetLocaleInfo as a
  3372. // number instead of a string. This flag is only valid for the LCTypes
  3373. // beginning with LOCALE_I.
  3374. //
  3375. #define LOCALE_NOUSEROVERRIDE 0x80000000 /* do not use user overrides */
  3376. #define LOCALE_RETURN_NUMBER 0x20000000 /* return number instead of string */
  3377. #define LOCALE_RETURN_GENITIVE_NAMES 0x10000000 //Flag to return the Genitive forms of month names
  3378. #define LOCALE_SLOCALIZEDDISPLAYNAME 0x00000002 // localized name of locale, eg "German (Germany)" in UI language
  3379. #define LOCALE_SENGLISHDISPLAYNAME 0x00000072 // Display name (language + country usually) in English, eg "German (Germany)"
  3380. #define LOCALE_SNATIVEDISPLAYNAME 0x00000073 // Display name in native locale language, eg "Deutsch (Deutschland)
  3381. #define LOCALE_SLOCALIZEDLANGUAGENAME 0x0000006f // Language Display Name for a language, eg "German" in UI language
  3382. #define LOCALE_SENGLISHLANGUAGENAME 0x00001001 // English name of language, eg "German"
  3383. #define LOCALE_SNATIVELANGUAGENAME 0x00000004 // native name of language, eg "Deutsch"
  3384. #define LOCALE_SLOCALIZEDCOUNTRYNAME 0x00000006 // localized name of country, eg "Germany" in UI language
  3385. #define LOCALE_SENGLISHCOUNTRYNAME 0x00001002 // English name of country, eg "Germany"
  3386. #define LOCALE_SNATIVECOUNTRYNAME 0x00000008 // native name of country, eg "Deutschland"
  3387. //
  3388. // The following LCTypes are mutually exclusive in that they may NOT
  3389. // be used in combination with each other.
  3390. //
  3391. #define LOCALE_ILANGUAGE 0x00000001 /* language id */
  3392. #define LOCALE_SLANGUAGE 0x00000002 /* localized name of language */
  3393. #define LOCALE_SENGLANGUAGE 0x00001001 /* English name of language */
  3394. #define LOCALE_SABBREVLANGNAME 0x00000003 /* abbreviated language name */
  3395. #define LOCALE_SNATIVELANGNAME 0x00000004 /* native name of language */
  3396. #define LOCALE_ICOUNTRY 0x00000005 /* country code */
  3397. #define LOCALE_SCOUNTRY 0x00000006 /* localized name of country */
  3398. #define LOCALE_SENGCOUNTRY 0x00001002 /* English name of country */
  3399. #define LOCALE_SABBREVCTRYNAME 0x00000007 /* abbreviated country name */
  3400. #define LOCALE_SNATIVECTRYNAME 0x00000008 /* native name of country */
  3401. #define LOCALE_SLIST 0x0000000C /* list item separator */
  3402. #define LOCALE_IMEASURE 0x0000000D /* 0 = metric, 1 = US */
  3403. #define LOCALE_SDECIMAL 0x0000000E /* decimal separator */
  3404. #define LOCALE_STHOUSAND 0x0000000F /* thousand separator */
  3405. #define LOCALE_SGROUPING 0x00000010 /* digit grouping */
  3406. #define LOCALE_IDIGITS 0x00000011 /* number of fractional digits */
  3407. #define LOCALE_ILZERO 0x00000012 /* leading zeros for decimal */
  3408. #define LOCALE_INEGNUMBER 0x00001010 /* negative number mode */
  3409. #define LOCALE_SNATIVEDIGITS 0x00000013 /* native ascii 0-9 */
  3410. #define LOCALE_SCURRENCY 0x00000014 /* local monetary symbol */
  3411. #define LOCALE_SINTLSYMBOL 0x00000015 /* intl monetary symbol */
  3412. #define LOCALE_SMONDECIMALSEP 0x00000016 /* monetary decimal separator */
  3413. #define LOCALE_SMONTHOUSANDSEP 0x00000017 /* monetary thousand separator */
  3414. #define LOCALE_SMONGROUPING 0x00000018 /* monetary grouping */
  3415. #define LOCALE_ICURRDIGITS 0x00000019 /* # local monetary digits */
  3416. #define LOCALE_IINTLCURRDIGITS 0x0000001A /* # intl monetary digits */
  3417. #define LOCALE_ICURRENCY 0x0000001B /* positive currency mode */
  3418. #define LOCALE_INEGCURR 0x0000001C /* negative currency mode */
  3419. #define LOCALE_SSHORTDATE 0x0000001F /* short date format string */
  3420. #define LOCALE_SLONGDATE 0x00000020 /* long date format string */
  3421. #define LOCALE_STIMEFORMAT 0x00001003 /* time format string */
  3422. #define LOCALE_S1159 0x00000028 /* AM designator */
  3423. #define LOCALE_S2359 0x00000029 /* PM designator */
  3424. #define LOCALE_ICALENDARTYPE 0x00001009 /* type of calendar specifier */
  3425. #define LOCALE_IFIRSTDAYOFWEEK 0x0000100C /* first day of week specifier */
  3426. #define LOCALE_IFIRSTWEEKOFYEAR 0x0000100D /* first week of year specifier */
  3427. #define LOCALE_SDAYNAME1 0x0000002A /* long name for Monday */
  3428. #define LOCALE_SDAYNAME2 0x0000002B /* long name for Tuesday */
  3429. #define LOCALE_SDAYNAME3 0x0000002C /* long name for Wednesday */
  3430. #define LOCALE_SDAYNAME4 0x0000002D /* long name for Thursday */
  3431. #define LOCALE_SDAYNAME5 0x0000002E /* long name for Friday */
  3432. #define LOCALE_SDAYNAME6 0x0000002F /* long name for Saturday */
  3433. #define LOCALE_SDAYNAME7 0x00000030 /* long name for Sunday */
  3434. #define LOCALE_SABBREVDAYNAME1 0x00000031 /* abbreviated name for Monday */
  3435. #define LOCALE_SABBREVDAYNAME2 0x00000032 /* abbreviated name for Tuesday */
  3436. #define LOCALE_SABBREVDAYNAME3 0x00000033 /* abbreviated name for Wednesday */
  3437. #define LOCALE_SABBREVDAYNAME4 0x00000034 /* abbreviated name for Thursday */
  3438. #define LOCALE_SABBREVDAYNAME5 0x00000035 /* abbreviated name for Friday */
  3439. #define LOCALE_SABBREVDAYNAME6 0x00000036 /* abbreviated name for Saturday */
  3440. #define LOCALE_SABBREVDAYNAME7 0x00000037 /* abbreviated name for Sunday */
  3441. #define LOCALE_SMONTHNAME1 0x00000038 /* long name for January */
  3442. #define LOCALE_SMONTHNAME2 0x00000039 /* long name for February */
  3443. #define LOCALE_SMONTHNAME3 0x0000003A /* long name for March */
  3444. #define LOCALE_SMONTHNAME4 0x0000003B /* long name for April */
  3445. #define LOCALE_SMONTHNAME5 0x0000003C /* long name for May */
  3446. #define LOCALE_SMONTHNAME6 0x0000003D /* long name for June */
  3447. #define LOCALE_SMONTHNAME7 0x0000003E /* long name for July */
  3448. #define LOCALE_SMONTHNAME8 0x0000003F /* long name for August */
  3449. #define LOCALE_SMONTHNAME9 0x00000040 /* long name for September */
  3450. #define LOCALE_SMONTHNAME10 0x00000041 /* long name for October */
  3451. #define LOCALE_SMONTHNAME11 0x00000042 /* long name for November */
  3452. #define LOCALE_SMONTHNAME12 0x00000043 /* long name for December */
  3453. #define LOCALE_SMONTHNAME13 0x0000100E /* long name for 13th month (if exists) */
  3454. #define LOCALE_SABBREVMONTHNAME1 0x00000044 /* abbreviated name for January */
  3455. #define LOCALE_SABBREVMONTHNAME2 0x00000045 /* abbreviated name for February */
  3456. #define LOCALE_SABBREVMONTHNAME3 0x00000046 /* abbreviated name for March */
  3457. #define LOCALE_SABBREVMONTHNAME4 0x00000047 /* abbreviated name for April */
  3458. #define LOCALE_SABBREVMONTHNAME5 0x00000048 /* abbreviated name for May */
  3459. #define LOCALE_SABBREVMONTHNAME6 0x00000049 /* abbreviated name for June */
  3460. #define LOCALE_SABBREVMONTHNAME7 0x0000004A /* abbreviated name for July */
  3461. #define LOCALE_SABBREVMONTHNAME8 0x0000004B /* abbreviated name for August */
  3462. #define LOCALE_SABBREVMONTHNAME9 0x0000004C /* abbreviated name for September */
  3463. #define LOCALE_SABBREVMONTHNAME10 0x0000004D /* abbreviated name for October */
  3464. #define LOCALE_SABBREVMONTHNAME11 0x0000004E /* abbreviated name for November */
  3465. #define LOCALE_SABBREVMONTHNAME12 0x0000004F /* abbreviated name for December */
  3466. #define LOCALE_SABBREVMONTHNAME13 0x0000100F /* abbreviated name for 13th month (if exists) */
  3467. #define LOCALE_SPOSITIVESIGN 0x00000050 /* positive sign */
  3468. #define LOCALE_SNEGATIVESIGN 0x00000051 /* negative sign */
  3469. #define LOCALE_FONTSIGNATURE 0x00000058 /* font signature */
  3470. #define LOCALE_SISO639LANGNAME 0x00000059 /* ISO abbreviated language name */
  3471. #define LOCALE_SISO3166CTRYNAME 0x0000005A /* ISO abbreviated country name */
  3472. #define LOCALE_SENGCURRNAME 0x00001007 /* english name of currency */
  3473. #define LOCALE_SNATIVECURRNAME 0x00001008 /* native name of currency */
  3474. #define LOCALE_SYEARMONTH 0x00001006 /* year month format string */
  3475. #define LOCALE_IDIGITSUBSTITUTION 0x00001014 /* 0 = context, 1 = none, 2 = national */
  3476. #define LOCALE_SNAME 0x0000005C /* locale name <language>[-<Script>][-<REGION>[_<sort order>]] */
  3477. #define LOCALE_SDURATION 0x0000005d /* time duration format */
  3478. #define LOCALE_SKEYBOARDSTOINSTALL 0x0000005e /* (windows only) keyboards to install */
  3479. #define LOCALE_SSHORTESTDAYNAME1 0x00000060 /* Shortest day name for Monday */
  3480. #define LOCALE_SSHORTESTDAYNAME2 0x00000061 /* Shortest day name for Tuesday */
  3481. #define LOCALE_SSHORTESTDAYNAME3 0x00000062 /* Shortest day name for Wednesday */
  3482. #define LOCALE_SSHORTESTDAYNAME4 0x00000063 /* Shortest day name for Thursday */
  3483. #define LOCALE_SSHORTESTDAYNAME5 0x00000064 /* Shortest day name for Friday */
  3484. #define LOCALE_SSHORTESTDAYNAME6 0x00000065 /* Shortest day name for Saturday */
  3485. #define LOCALE_SSHORTESTDAYNAME7 0x00000066 /* Shortest day name for Sunday */
  3486. #define LOCALE_SISO639LANGNAME2 0x00000067 /* 3 character ISO abbreviated language name */
  3487. #define LOCALE_SISO3166CTRYNAME2 0x00000068 /* 3 character ISO country name */
  3488. #define LOCALE_SNAN 0x00000069 /* Not a Number */
  3489. #define LOCALE_SPOSINFINITY 0x0000006a /* + Infinity */
  3490. #define LOCALE_SNEGINFINITY 0x0000006b /* - Infinity */
  3491. #define LOCALE_SSCRIPTS 0x0000006c /* Typical scripts in the locale */
  3492. #define LOCALE_SPARENT 0x0000006d /* Fallback name for resources */
  3493. #define LOCALE_SCONSOLEFALLBACKNAME 0x0000006e /* Fallback name for within the console */
  3494. #define LOCALE_SLANGDISPLAYNAME 0x0000006f /* Language Display Name for a language */
  3495. #define LOCALE_IREADINGLAYOUT 0x00000070 // Returns one of the following 4 reading layout values:
  3496. // 0 - Left to right (eg en-US)
  3497. // 1 - Right to left (eg arabic locales)
  3498. // 2 - Vertical top to bottom with columns to the left and also left to right (ja-JP locales)
  3499. // 3 - Vertical top to bottom with columns proceeding to the right
  3500. #define LOCALE_INEUTRAL 0x00000071 // Returns 0 for specific cultures, 1 for neutral cultures.
  3501. #define LOCALE_INEGATIVEPERCENT 0x00000074 // Returns 0-11 for the negative percent format
  3502. #define LOCALE_IPOSITIVEPERCENT 0x00000075 // Returns 0-3 for the positive percent formatIPOSITIVEPERCENT
  3503. #define LOCALE_SPERCENT 0x00000076 // Returns the percent symbol
  3504. #define LOCALE_SPERMILLE 0x00000077 // Returns the permille (U+2030) symbol
  3505. #define LOCALE_SMONTHDAY 0x00000078 // Returns the preferred month/day format
  3506. #define LOCALE_SSHORTTIME 0x00000079 // Returns the preferred short time format (ie: no seconds, just h:mm)
  3507. #define LOCALE_SOPENTYPELANGUAGETAG 0x0000007a // Open type language tag, eg: "latn" or "dflt"
  3508. #define LOCALE_SSORTLOCALE 0x0000007b // Name of locale to use for sorting/collation/casing behavior.
  3509. #define LCMAP_LINGUISTIC_CASING 0x01000000 /* Use linguistic casing */
  3510. #define CAL_RETURN_GENITIVE_NAMES LOCALE_RETURN_GENITIVE_NAMES // return genitive forms of month names
  3511. #define CAL_SSHORTESTDAYNAME1 0x00000031
  3512. #define CAL_SSHORTESTDAYNAME2 0x00000032
  3513. #define CAL_SSHORTESTDAYNAME3 0x00000033
  3514. #define CAL_SSHORTESTDAYNAME4 0x00000034
  3515. #define CAL_SSHORTESTDAYNAME5 0x00000035
  3516. #define CAL_SSHORTESTDAYNAME6 0x00000036
  3517. #define CAL_SSHORTESTDAYNAME7 0x00000037
  3518. #define CAL_SMONTHDAY 0x00000038 // Month/day pattern (reserve for potential inclusion in a future version)
  3519. #define CAL_SERASTRING 0x00000004 // era name for IYearOffsetRanges, eg A.D.
  3520. #define CAL_SABBREVERASTRING 0x00000039 // Abbreviated era string (eg: AD)
  3521. #define CAL_SSHORTDATE 0x00000005 /* short date format string */
  3522. #define CAL_SLONGDATE 0x00000006 /* long date format string */
  3523. #define CAL_SDAYNAME1 0x00000007 /* native name for Monday */
  3524. #define CAL_SDAYNAME2 0x00000008 /* native name for Tuesday */
  3525. #define CAL_SDAYNAME3 0x00000009 /* native name for Wednesday */
  3526. #define CAL_SDAYNAME4 0x0000000a /* native name for Thursday */
  3527. #define CAL_SDAYNAME5 0x0000000b /* native name for Friday */
  3528. #define CAL_SDAYNAME6 0x0000000c /* native name for Saturday */
  3529. #define CAL_SDAYNAME7 0x0000000d /* native name for Sunday */
  3530. #define CAL_SABBREVDAYNAME1 0x0000000e /* abbreviated name for Monday */
  3531. #define CAL_SABBREVDAYNAME2 0x0000000f /* abbreviated name for Tuesday */
  3532. #define CAL_SABBREVDAYNAME3 0x00000010 /* abbreviated name for Wednesday */
  3533. #define CAL_SABBREVDAYNAME4 0x00000011 /* abbreviated name for Thursday */
  3534. #define CAL_SABBREVDAYNAME5 0x00000012 /* abbreviated name for Friday */
  3535. #define CAL_SABBREVDAYNAME6 0x00000013 /* abbreviated name for Saturday */
  3536. #define CAL_SABBREVDAYNAME7 0x00000014 /* abbreviated name for Sunday */
  3537. #define CAL_SMONTHNAME1 0x00000015 /* native name for January */
  3538. #define CAL_SMONTHNAME2 0x00000016 /* native name for February */
  3539. #define CAL_SMONTHNAME3 0x00000017 /* native name for March */
  3540. #define CAL_SMONTHNAME4 0x00000018 /* native name for April */
  3541. #define CAL_SMONTHNAME5 0x00000019 /* native name for May */
  3542. #define CAL_SMONTHNAME6 0x0000001a /* native name for June */
  3543. #define CAL_SMONTHNAME7 0x0000001b /* native name for July */
  3544. #define CAL_SMONTHNAME8 0x0000001c /* native name for August */
  3545. #define CAL_SMONTHNAME9 0x0000001d /* native name for September */
  3546. #define CAL_SMONTHNAME10 0x0000001e /* native name for October */
  3547. #define CAL_SMONTHNAME11 0x0000001f /* native name for November */
  3548. #define CAL_SMONTHNAME12 0x00000020 /* native name for December */
  3549. #define CAL_SMONTHNAME13 0x00000021 /* native name for 13th month (if any) */
  3550. #define CAL_SABBREVMONTHNAME1 0x00000022 /* abbreviated name for January */
  3551. #define CAL_SABBREVMONTHNAME2 0x00000023 /* abbreviated name for February */
  3552. #define CAL_SABBREVMONTHNAME3 0x00000024 /* abbreviated name for March */
  3553. #define CAL_SABBREVMONTHNAME4 0x00000025 /* abbreviated name for April */
  3554. #define CAL_SABBREVMONTHNAME5 0x00000026 /* abbreviated name for May */
  3555. #define CAL_SABBREVMONTHNAME6 0x00000027 /* abbreviated name for June */
  3556. #define CAL_SABBREVMONTHNAME7 0x00000028 /* abbreviated name for July */
  3557. #define CAL_SABBREVMONTHNAME8 0x00000029 /* abbreviated name for August */
  3558. #define CAL_SABBREVMONTHNAME9 0x0000002a /* abbreviated name for September */
  3559. #define CAL_SABBREVMONTHNAME10 0x0000002b /* abbreviated name for October */
  3560. #define CAL_SABBREVMONTHNAME11 0x0000002c /* abbreviated name for November */
  3561. #define CAL_SABBREVMONTHNAME12 0x0000002d /* abbreviated name for December */
  3562. #define CAL_SABBREVMONTHNAME13 0x0000002e /* abbreviated name for 13th month (if any) */
  3563. #define CAL_SYEARMONTH 0x0000002f /* year month format string */
  3564. #else // __APPLE__
  3565. #define LOCALE_SDECIMAL 0x0000000E /* decimal separator */
  3566. #define LOCALE_STHOUSAND 0x0000000F /* thousand separator */
  3567. #define LOCALE_ILZERO 0x00000012 /* leading zeros for decimal */
  3568. #define LOCALE_SCURRENCY 0x00000014 /* local monetary symbol */
  3569. #define LOCALE_SMONDECIMALSEP 0x00000016 /* monetary decimal separator */
  3570. #define LOCALE_SMONTHOUSANDSEP 0x00000017 /* monetary thousand separator */
  3571. #endif // __APPLE__
  3572. #if ENABLE_DOWNLEVEL_FOR_NLS
  3573. PALIMPORT
  3574. int
  3575. PALAPI
  3576. GetLocaleInfoW(
  3577. IN LCID Locale,
  3578. IN LCTYPE LCType,
  3579. OUT LPWSTR lpLCData,
  3580. IN int cchData);
  3581. #endif // ENABLE_DOWNLEVEL_FOR_NLS
  3582. PALIMPORT
  3583. int
  3584. PALAPI
  3585. GetLocaleInfoEx(
  3586. IN LPCWSTR lpLocaleName,
  3587. IN LCTYPE LCType,
  3588. OUT LPWSTR lpLCData,
  3589. IN int cchData);
  3590. PALIMPORT
  3591. int
  3592. PALAPI
  3593. CompareStringOrdinal(
  3594. IN LPCWSTR lpString1,
  3595. IN int cchCount1,
  3596. IN LPCWSTR lpString2,
  3597. IN int cchCount2,
  3598. IN BOOL bIgnoreCase);
  3599. typedef struct _nlsversioninfoex {
  3600. DWORD dwNLSVersionInfoSize;
  3601. DWORD dwNLSVersion;
  3602. DWORD dwDefinedVersion;
  3603. DWORD dwEffectiveId;
  3604. GUID guidCustomVersion;
  3605. } NLSVERSIONINFOEX, *LPNLSVERSIONINFOEX;
  3606. PALIMPORT
  3607. int
  3608. PALAPI
  3609. FindNLSStringEx(
  3610. IN LPCWSTR lpLocaleName,
  3611. IN DWORD dwFindNLSStringFlags,
  3612. IN LPCWSTR lpStringSource,
  3613. IN int cchSource,
  3614. IN LPCWSTR lpStringValue,
  3615. IN int cchValue,
  3616. OUT LPINT pcchFound,
  3617. IN LPNLSVERSIONINFOEX lpVersionInformation,
  3618. IN LPVOID lpReserved,
  3619. IN LPARAM lParam );
  3620. typedef enum {
  3621. COMPARE_STRING = 0x0001,
  3622. } NLS_FUNCTION;
  3623. PALIMPORT
  3624. BOOL
  3625. PALAPI
  3626. IsNLSDefinedString(
  3627. IN NLS_FUNCTION Function,
  3628. IN DWORD dwFlags,
  3629. IN LPNLSVERSIONINFOEX lpVersionInfo,
  3630. IN LPCWSTR lpString,
  3631. IN int cchStr );
  3632. PALIMPORT
  3633. int
  3634. PALAPI
  3635. ResolveLocaleName(
  3636. IN LPCWSTR lpNameToResolve,
  3637. OUT LPWSTR lpLocaleName,
  3638. IN int cchLocaleName );
  3639. PALIMPORT
  3640. BOOL
  3641. PALAPI
  3642. GetThreadPreferredUILanguages(
  3643. IN DWORD dwFlags,
  3644. OUT PULONG pulNumLanguages,
  3645. OUT PWSTR pwszLanguagesBuffer,
  3646. IN OUT PULONG pcchLanguagesBuffer);
  3647. PALIMPORT
  3648. int
  3649. PALAPI
  3650. GetSystemDefaultLocaleName(
  3651. OUT LPWSTR lpLocaleName,
  3652. IN int cchLocaleName);
  3653. #ifdef UNICODE
  3654. #define GetLocaleInfo GetLocaleInfoW
  3655. #endif
  3656. #if ENABLE_DOWNLEVEL_FOR_NLS
  3657. PALIMPORT
  3658. LCID
  3659. PALAPI
  3660. GetUserDefaultLCID(
  3661. void);
  3662. #endif
  3663. PALIMPORT
  3664. int
  3665. PALAPI
  3666. GetUserDefaultLocaleName(
  3667. OUT LPWSTR lpLocaleName,
  3668. IN int cchLocaleName);
  3669. #define LCID_INSTALLED 0x00000001 // installed locale ids
  3670. #define LCID_SUPPORTED 0x00000002 // supported locale ids
  3671. #ifdef __APPLE__
  3672. #define LCID_ALTERNATE_SORTS 0x00000004 // alternate sort locale ids
  3673. #endif // __APPLE__
  3674. #if ENABLE_DOWNLEVEL_FOR_NLS
  3675. PALIMPORT
  3676. BOOL
  3677. PALAPI
  3678. IsValidLocale(
  3679. IN LCID Locale,
  3680. IN DWORD dwFlags);
  3681. #endif // ENABLE_DOWNLEVEL_FOR_NLS
  3682. typedef DWORD CALID;
  3683. typedef DWORD CALTYPE;
  3684. #define CAL_ITWODIGITYEARMAX 0x00000030 // two digit year max
  3685. #define CAL_RETURN_NUMBER 0x20000000 // return number instead of string
  3686. #define CAL_GREGORIAN 1 // Gregorian (localized) calendar
  3687. #define CAL_GREGORIAN_US 2 // Gregorian (U.S.) calendar
  3688. #define CAL_JAPAN 3 // Japanese Emperor Era calendar
  3689. #define CAL_TAIWAN 4 // Taiwan Era calendar
  3690. #define CAL_KOREA 5 // Korean Tangun Era calendar
  3691. #define CAL_HIJRI 6 // Hijri (Arabic Lunar) calendar
  3692. #define CAL_THAI 7 // Thai calendar
  3693. #define CAL_HEBREW 8 // Hebrew (Lunar) calendar
  3694. #define CAL_GREGORIAN_ME_FRENCH 9 // Gregorian Middle East French calendar
  3695. #define CAL_GREGORIAN_ARABIC 10 // Gregorian Arabic calendar
  3696. #define CAL_GREGORIAN_XLIT_ENGLISH 11 // Gregorian Transliterated English calendar
  3697. #define CAL_GREGORIAN_XLIT_FRENCH 12 // Gregorian Transliterated French calendar
  3698. #define CAL_JULIAN 13
  3699. #if ENABLE_DOWNLEVEL_FOR_NLS
  3700. PALIMPORT
  3701. int
  3702. PALAPI
  3703. GetCalendarInfoW(
  3704. IN LCID Locale,
  3705. IN CALID Calendar,
  3706. IN CALTYPE CalType,
  3707. OUT LPWSTR lpCalData,
  3708. IN int cchData,
  3709. OUT LPDWORD lpValue);
  3710. #ifdef UNICODE
  3711. #define GetCalendarInfo GetCalendarInfoW
  3712. #endif
  3713. #endif // ENABLE_DOWNLEVEL_FOR_NLS
  3714. PALIMPORT
  3715. int
  3716. PALAPI
  3717. GetCalendarInfoEx(
  3718. IN LPCWSTR lpLocaleName,
  3719. IN CALID Calendar,
  3720. IN LPCWSTR lpReserved,
  3721. IN CALTYPE CalType,
  3722. OUT LPWSTR lpCalData,
  3723. IN int cchData,
  3724. OUT LPDWORD lpValue);
  3725. #if ENABLE_DOWNLEVEL_FOR_NLS
  3726. typedef BOOL (CALLBACK* LOCALE_ENUMPROCW)(LPWSTR);
  3727. PALIMPORT
  3728. BOOL
  3729. PALAPI
  3730. EnumSystemLocalesW(
  3731. IN LOCALE_ENUMPROCW lpLocaleEnumProc,
  3732. IN DWORD dwFlags);
  3733. #endif // ENABLE_DOWNLEVEL_FOR_NLS
  3734. #define DATE_SHORTDATE 0x00000001 // use short date picture
  3735. #define DATE_LONGDATE 0x00000002 // use long date picture
  3736. #define DATE_YEARMONTH 0x00000008 // use year month picture
  3737. typedef BOOL (CALLBACK* DATEFMT_ENUMPROCEXW)(LPWSTR, CALID);
  3738. #if ENABLE_DOWNLEVEL_FOR_NLS
  3739. PALIMPORT
  3740. BOOL
  3741. PALAPI
  3742. EnumDateFormatsExW(
  3743. IN DATEFMT_ENUMPROCEXW lpDateFmtEnumProcEx,
  3744. IN LCID Locale,
  3745. IN DWORD dwFlags);
  3746. #else // ENABLE_DOWNLEVEL_FOR_NLS
  3747. typedef BOOL (CALLBACK* DATEFMT_ENUMPROCEXEXW)(LPWSTR, CALID, LPARAM);
  3748. PALIMPORT
  3749. BOOL
  3750. PALAPI
  3751. EnumDateFormatsExEx(
  3752. IN DATEFMT_ENUMPROCEXEXW lpDateFmtEnumProcEx,
  3753. IN LPCWSTR lpLocaleName,
  3754. IN DWORD dwFlags,
  3755. IN LPARAM lParam);
  3756. #endif // ENABLE_DOWNLEVEL_FOR_NLS
  3757. typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCW)(LPWSTR);
  3758. #if ENABLE_DOWNLEVEL_FOR_NLS
  3759. PALIMPORT
  3760. BOOL
  3761. PALAPI
  3762. EnumTimeFormatsW(
  3763. IN TIMEFMT_ENUMPROCW lpTimeFmtEnumProc,
  3764. IN LCID Locale,
  3765. IN DWORD dwFlags);
  3766. #else // ENABLE_DOWNLEVEL_FOR_NLS
  3767. typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCEXW)(LPWSTR, LPARAM);
  3768. PALIMPORT
  3769. BOOL
  3770. PALAPI
  3771. EnumTimeFormatsEx(
  3772. IN TIMEFMT_ENUMPROCEXW lpTimeFmtEnumProc,
  3773. IN LPCWSTR lpLocaleName,
  3774. IN DWORD dwFlags,
  3775. IN LPARAM lParam);
  3776. #endif // ENABLE_DOWNLEVEL_FOR_NLS
  3777. #define ENUM_ALL_CALENDARS 0xffffffff // enumerate all calendars
  3778. #define CAL_ICALINTVALUE 0x00000001 // calendar type
  3779. #define CAL_NOUSEROVERRIDE LOCALE_NOUSEROVERRIDE // do not use user overrides
  3780. #define CAL_SCALNAME 0x00000002 // native name of calendar
  3781. typedef BOOL (CALLBACK* CALINFO_ENUMPROCEXW)(LPWSTR,CALID);
  3782. #if ENABLE_DOWNLEVEL_FOR_NLS
  3783. PALIMPORT
  3784. BOOL
  3785. PALAPI
  3786. EnumCalendarInfoExW(
  3787. IN CALINFO_ENUMPROCEXW lpCalInfoEnumProc,
  3788. IN LCID Locale,
  3789. IN CALID Calendar,
  3790. IN CALTYPE CalType);
  3791. #else // ENABLE_DOWNLEVEL_FOR_NLS
  3792. typedef BOOL (CALLBACK* CALINFO_ENUMPROCEXEXW)(LPWSTR, CALID, LPWSTR, LPARAM);
  3793. PALIMPORT
  3794. BOOL
  3795. PALAPI
  3796. EnumCalendarInfoExEx(
  3797. IN CALINFO_ENUMPROCEXEXW lpCalInfoEnumProc,
  3798. IN LPCWSTR lpLocaleName,
  3799. IN CALID Calendar,
  3800. IN LPCWSTR lpReserved,
  3801. IN CALTYPE CalType,
  3802. IN LPARAM lParam);
  3803. #endif // ENABLE_DOWNLEVEL_FOR_NLS
  3804. #define LCMAP_LOWERCASE 0x00000100
  3805. #define LCMAP_UPPERCASE 0x00000200
  3806. #if ENABLE_DOWNLEVEL_FOR_NLS
  3807. PALIMPORT
  3808. int
  3809. PALAPI
  3810. LCMapStringW(
  3811. IN LCID Locale,
  3812. IN DWORD dwMapFlags,
  3813. IN LPCWSTR lpSrcStr,
  3814. IN int cchSrc,
  3815. OUT LPWSTR lpDestStr,
  3816. IN int cchDest);
  3817. #ifdef UNICODE
  3818. #define LCMapString LCMapStringW
  3819. #endif
  3820. #endif // ENABLE_DOWNLEVEL_FOR_NLS
  3821. PALIMPORT
  3822. int
  3823. PALAPI
  3824. LCMapStringEx(
  3825. IN LPCWSTR lpLocaleName,
  3826. IN DWORD dwMapFlags,
  3827. IN LPCWSTR lpSrcStr,
  3828. IN int cchSrc,
  3829. OUT LPWSTR lpDestStr,
  3830. IN int cchDest,
  3831. IN LPNLSVERSIONINFO lpVersionInformation,
  3832. IN LPVOID lpReserved,
  3833. IN LPARAM lParam );
  3834. PALIMPORT
  3835. int
  3836. PALAPI
  3837. PAL_LCMapCharW(
  3838. IN LPCWSTR lpLocaleName,
  3839. IN DWORD dwMapFlags,
  3840. IN WCHAR srcChar,
  3841. OUT WCHAR *destChar,
  3842. LPNLSVERSIONINFO lpVersionInformation,
  3843. LPVOID lpReserved,
  3844. LPARAM lParam );
  3845. PALIMPORT
  3846. int
  3847. PALAPI
  3848. PAL_NormalizeStringExW(
  3849. IN LPCWSTR lpLocaleName,
  3850. IN DWORD dwMapFlags,
  3851. IN LPCWSTR lpSrcStr,
  3852. IN int cchSrc,
  3853. OUT LPWSTR lpDestStr,
  3854. IN int cchDest);
  3855. PALIMPORT
  3856. int
  3857. PALAPI
  3858. PAL_ParseDateW(
  3859. IN LPCWSTR lpLocaleName,
  3860. IN LPCWSTR lpFormat,
  3861. IN LPCWSTR lpString,
  3862. OUT LPSYSTEMTIME lpTime);
  3863. PALIMPORT
  3864. int
  3865. PALAPI
  3866. PAL_GetCalendar(
  3867. IN LPCWSTR lpLocaleName,
  3868. OUT CALID* pCalendar);
  3869. #define GEOID_NOT_AVAILABLE -1
  3870. // "a number", might represent different types
  3871. typedef struct PALNUMBER__* PALNUMBER;
  3872. // return NULL on OOM
  3873. PALIMPORT PALNUMBER PALAPI PAL_DoubleToNumber(double);
  3874. PALIMPORT PALNUMBER PALAPI PAL_Int64ToNumber(INT64);
  3875. PALIMPORT PALNUMBER PALAPI PAL_UInt64ToNumber(UINT64);
  3876. PALIMPORT PALNUMBER PALAPI PAL_IntToNumber(int);
  3877. PALIMPORT PALNUMBER PALAPI PAL_UIntToNumber(unsigned int);
  3878. PALIMPORT void PALAPI PAL_ReleaseNumber(PALNUMBER);
  3879. // return string length if Buffer is NULL or the result fits in cchBuffer, otherwise -1
  3880. PALIMPORT int PALAPI PAL_FormatScientific(LPCWSTR sLocale, LPWSTR pBuffer, SIZE_T cchBuffer, PALNUMBER number, int nMinDigits, int nMaxDigits,
  3881. LPCWSTR sExponent, LPCWSTR sNumberDecimal, LPCWSTR sPositive, LPCWSTR sNegative, LPCWSTR sZero);
  3882. PALIMPORT int PALAPI PAL_FormatCurrency(LPCWSTR sLocale, LPWSTR pBuffer, SIZE_T cchBuffer, PALNUMBER number, int nMinDigits, int nMaxDigits, int iNegativeFormat, int iPositiveFormat,
  3883. int iPrimaryGroup, int iSecondaryGroup, LPCWSTR sCurrencyDecimal, LPCWSTR sCurrencyGroup, LPCWSTR sNegative, LPCWSTR sCurrency, LPCWSTR sZero);
  3884. PALIMPORT int PALAPI PAL_FormatPercent(LPCWSTR sLocale, LPWSTR pBuffer, SIZE_T cchBuffer, PALNUMBER number, int nMinDigits, int nMaxDigits,int iNegativeFormat, int iPositiveFormat,
  3885. int iPrimaryGroup, int iSecondaryGroup, LPCWSTR sPercentDecimal, LPCWSTR sPercentGroup, LPCWSTR sNegative, LPCWSTR sPercent, LPCWSTR sZero);
  3886. PALIMPORT int PALAPI PAL_FormatDecimal(LPCWSTR sLocale, LPWSTR pBuffer, SIZE_T cchBuffer, PALNUMBER number, int nMinDigits, int nMaxDigits, int iNegativeFormat,
  3887. int iPrimaryGroup, int iSecondaryGroup, LPCWSTR sDecimal, LPCWSTR sGroup, LPCWSTR sNegative, LPCWSTR sZero);
  3888. #define DATE_USE_ALT_CALENDAR 0x00000004
  3889. #if ENABLE_DOWNLEVEL_FOR_NLS
  3890. PALIMPORT
  3891. int
  3892. PALAPI
  3893. GetDateFormatW(
  3894. IN LCID Locale,
  3895. IN DWORD dwFlags,
  3896. IN CONST SYSTEMTIME *lpDate,
  3897. IN LPCWSTR lpFormat,
  3898. OUT LPWSTR lpDateStr,
  3899. IN int cchDate);
  3900. #else
  3901. PALIMPORT
  3902. int
  3903. PALAPI
  3904. GetDateFormatEx(
  3905. IN LPCWSTR Locale,
  3906. IN DWORD dwFlags,
  3907. IN CONST SYSTEMTIME *lpDate,
  3908. IN LPCWSTR lpFormat,
  3909. OUT LPWSTR lpDateStr,
  3910. IN int cchDate,
  3911. IN LPCWSTR lpCalendar);
  3912. #endif // ENABLE_DOWNLEVEL_FOR_NLS
  3913. PALIMPORT
  3914. int
  3915. PALAPI
  3916. GetDateFormatEx(
  3917. IN LPCWSTR lpLocaleName,
  3918. IN DWORD dwFlags,
  3919. IN CONST SYSTEMTIME *lpDate,
  3920. IN LPCWSTR lpFormat,
  3921. OUT LPWSTR lpDateStr,
  3922. IN int cchDate,
  3923. LPCWSTR lpCalendar);
  3924. #ifdef UNICODE
  3925. #define GetDateFormat GetDateFormatW
  3926. #endif
  3927. PALIMPORT
  3928. int
  3929. PALAPI
  3930. PAL_GetResourceString(
  3931. IN LPCSTR lpDomain,
  3932. IN LPCSTR lpResourceStr,
  3933. OUT LPWSTR lpWideCharStr,
  3934. IN int cchWideChar);
  3935. PALIMPORT
  3936. BOOL
  3937. PALAPI
  3938. PAL_BindResources(IN LPCSTR lpDomain);
  3939. #define EXCEPTION_NONCONTINUABLE 0x1
  3940. #define EXCEPTION_UNWINDING 0x2
  3941. #ifdef FEATURE_PAL_SXS
  3942. #define EXCEPTION_EXIT_UNWIND 0x4 // Exit unwind is in progress (not used by PAL SEH)
  3943. #define EXCEPTION_NESTED_CALL 0x10 // Nested exception handler call
  3944. #define EXCEPTION_TARGET_UNWIND 0x20 // Target unwind in progress
  3945. #define EXCEPTION_COLLIDED_UNWIND 0x40 // Collided exception handler call
  3946. #define EXCEPTION_SKIP_VEH 0x200
  3947. #define EXCEPTION_UNWIND (EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND | \
  3948. EXCEPTION_TARGET_UNWIND | EXCEPTION_COLLIDED_UNWIND)
  3949. #define IS_DISPATCHING(Flag) ((Flag & EXCEPTION_UNWIND) == 0)
  3950. #define IS_UNWINDING(Flag) ((Flag & EXCEPTION_UNWIND) != 0)
  3951. #define IS_TARGET_UNWIND(Flag) (Flag & EXCEPTION_TARGET_UNWIND)
  3952. #endif // FEATURE_PAL_SXS
  3953. #define EXCEPTION_IS_SIGNAL 0x100
  3954. #define EXCEPTION_MAXIMUM_PARAMETERS 15
  3955. // Index in the ExceptionInformation array where we will keep the reference
  3956. // to the native exception that needs to be deleted when dispatching
  3957. // exception in managed code.
  3958. #define NATIVE_EXCEPTION_ASYNC_SLOT (EXCEPTION_MAXIMUM_PARAMETERS-1)
  3959. typedef struct _EXCEPTION_RECORD {
  3960. DWORD ExceptionCode;
  3961. DWORD ExceptionFlags;
  3962. struct _EXCEPTION_RECORD *ExceptionRecord;
  3963. PVOID ExceptionAddress;
  3964. DWORD NumberParameters;
  3965. ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
  3966. } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
  3967. typedef struct _EXCEPTION_POINTERS {
  3968. PEXCEPTION_RECORD ExceptionRecord;
  3969. PCONTEXT ContextRecord;
  3970. } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS, *LPEXCEPTION_POINTERS;
  3971. #ifdef FEATURE_PAL_SXS
  3972. typedef LONG EXCEPTION_DISPOSITION;
  3973. enum {
  3974. ExceptionContinueExecution,
  3975. ExceptionContinueSearch,
  3976. ExceptionNestedException,
  3977. ExceptionCollidedUnwind,
  3978. };
  3979. #endif // FEATURE_PAL_SXS
  3980. //
  3981. // A function table entry is generated for each frame function.
  3982. //
  3983. typedef struct _RUNTIME_FUNCTION {
  3984. DWORD BeginAddress;
  3985. DWORD EndAddress;
  3986. DWORD UnwindData;
  3987. } RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
  3988. PALIMPORT
  3989. BOOL
  3990. PALAPI
  3991. WriteProcessMemory(IN HANDLE hProcess,
  3992. IN LPVOID lpBaseAddress,
  3993. IN LPCVOID lpBuffer,
  3994. IN SIZE_T nSize,
  3995. OUT SIZE_T * lpNumberOfBytesWritten);
  3996. #define STANDARD_RIGHTS_REQUIRED (0x000F0000L)
  3997. #define SYNCHRONIZE (0x00100000L)
  3998. #define READ_CONTROL (0x00020000L)
  3999. #define EVENT_MODIFY_STATE (0x0002)
  4000. #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
  4001. 0x3)
  4002. #define MUTANT_QUERY_STATE (0x0001)
  4003. #define MUTANT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
  4004. MUTANT_QUERY_STATE)
  4005. #define MUTEX_ALL_ACCESS MUTANT_ALL_ACCESS
  4006. #define SEMAPHORE_MODIFY_STATE (0x0002)
  4007. #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
  4008. 0x3)
  4009. #define PROCESS_TERMINATE (0x0001)
  4010. #define PROCESS_CREATE_THREAD (0x0002)
  4011. #define PROCESS_SET_SESSIONID (0x0004)
  4012. #define PROCESS_VM_OPERATION (0x0008)
  4013. #define PROCESS_VM_READ (0x0010)
  4014. #define PROCESS_VM_WRITE (0x0020)
  4015. #define PROCESS_DUP_HANDLE (0x0040)
  4016. #define PROCESS_CREATE_PROCESS (0x0080)
  4017. #define PROCESS_SET_QUOTA (0x0100)
  4018. #define PROCESS_SET_INFORMATION (0x0200)
  4019. #define PROCESS_QUERY_INFORMATION (0x0400)
  4020. #define PROCESS_SUSPEND_RESUME (0x0800)
  4021. #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
  4022. 0xFFF)
  4023. PALIMPORT
  4024. HANDLE
  4025. PALAPI
  4026. OpenProcess(
  4027. IN DWORD dwDesiredAccess, /* PROCESS_DUP_HANDLE or PROCESS_ALL_ACCESS */
  4028. IN BOOL bInheritHandle,
  4029. IN DWORD dwProcessId
  4030. );
  4031. PALIMPORT
  4032. BOOL
  4033. PALAPI
  4034. EnumProcessModules(
  4035. IN HANDLE hProcess,
  4036. OUT HMODULE *lphModule,
  4037. IN DWORD cb,
  4038. OUT LPDWORD lpcbNeeded
  4039. );
  4040. PALIMPORT
  4041. VOID
  4042. PALAPI
  4043. OutputDebugStringA(
  4044. IN LPCSTR lpOutputString);
  4045. PALIMPORT
  4046. VOID
  4047. PALAPI
  4048. OutputDebugStringW(
  4049. IN LPCWSTR lpOutputStrig);
  4050. #ifdef UNICODE
  4051. #define OutputDebugString OutputDebugStringW
  4052. #else
  4053. #define OutputDebugString OutputDebugStringA
  4054. #endif
  4055. PALIMPORT
  4056. VOID
  4057. PALAPI
  4058. DebugBreak(
  4059. VOID);
  4060. PALIMPORT
  4061. LPWSTR
  4062. PALAPI
  4063. lstrcatW(
  4064. IN OUT LPWSTR lpString1,
  4065. IN LPCWSTR lpString2);
  4066. #ifdef UNICODE
  4067. #define lstrcat lstrcatW
  4068. #endif
  4069. PALIMPORT
  4070. LPWSTR
  4071. PALAPI
  4072. lstrcpyW(
  4073. OUT LPWSTR lpString1,
  4074. IN LPCWSTR lpString2);
  4075. #ifdef UNICODE
  4076. #define lstrcpy lstrcpyW
  4077. #endif
  4078. PALIMPORT
  4079. int
  4080. PALAPI
  4081. lstrlenA(
  4082. IN LPCSTR lpString);
  4083. PALIMPORT
  4084. int
  4085. PALAPI
  4086. lstrlenW(
  4087. IN LPCWSTR lpString);
  4088. #ifdef UNICODE
  4089. #define lstrlen lstrlenW
  4090. #else
  4091. #define lstrlen lstrlenA
  4092. #endif
  4093. PALIMPORT
  4094. LPWSTR
  4095. PALAPI
  4096. lstrcpynW(
  4097. OUT LPWSTR lpString1,
  4098. IN LPCWSTR lpString2,
  4099. IN int iMaxLength);
  4100. #ifdef UNICODE
  4101. #define lstrcpyn lstrcpynW
  4102. #endif
  4103. PALIMPORT
  4104. DWORD
  4105. PALAPI
  4106. GetEnvironmentVariableA(
  4107. IN LPCSTR lpName,
  4108. OUT LPSTR lpBuffer,
  4109. IN DWORD nSize);
  4110. PALIMPORT
  4111. DWORD
  4112. PALAPI
  4113. GetEnvironmentVariableW(
  4114. IN LPCWSTR lpName,
  4115. OUT LPWSTR lpBuffer,
  4116. IN DWORD nSize);
  4117. #ifdef UNICODE
  4118. #define GetEnvironmentVariable GetEnvironmentVariableW
  4119. #else
  4120. #define GetEnvironmentVariable GetEnvironmentVariableA
  4121. #endif
  4122. PALIMPORT
  4123. BOOL
  4124. PALAPI
  4125. SetEnvironmentVariableA(
  4126. IN LPCSTR lpName,
  4127. IN LPCSTR lpValue);
  4128. PALIMPORT
  4129. BOOL
  4130. PALAPI
  4131. SetEnvironmentVariableW(
  4132. IN LPCWSTR lpName,
  4133. IN LPCWSTR lpValue);
  4134. #ifdef UNICODE
  4135. #define SetEnvironmentVariable SetEnvironmentVariableW
  4136. #else
  4137. #define SetEnvironmentVariable SetEnvironmentVariableA
  4138. #endif
  4139. PALIMPORT
  4140. LPSTR
  4141. PALAPI
  4142. GetEnvironmentStringsA(
  4143. VOID);
  4144. PALIMPORT
  4145. LPWSTR
  4146. PALAPI
  4147. GetEnvironmentStringsW(
  4148. VOID);
  4149. #ifdef UNICODE
  4150. #define GetEnvironmentStrings GetEnvironmentStringsW
  4151. #else
  4152. #define GetEnvironmentStrings GetEnvironmentStringsA
  4153. #endif
  4154. PALIMPORT
  4155. BOOL
  4156. PALAPI
  4157. FreeEnvironmentStringsA(
  4158. IN LPSTR);
  4159. PALIMPORT
  4160. BOOL
  4161. PALAPI
  4162. FreeEnvironmentStringsW(
  4163. IN LPWSTR);
  4164. #ifdef UNICODE
  4165. #define FreeEnvironmentStrings FreeEnvironmentStringsW
  4166. #else
  4167. #define FreeEnvironmentStrings FreeEnvironmentStringsA
  4168. #endif
  4169. PALIMPORT
  4170. BOOL
  4171. PALAPI
  4172. CloseHandle(
  4173. IN OUT HANDLE hObject);
  4174. PALIMPORT
  4175. VOID
  4176. PALAPI
  4177. RaiseException(
  4178. IN DWORD dwExceptionCode,
  4179. IN DWORD dwExceptionFlags,
  4180. IN DWORD nNumberOfArguments,
  4181. IN CONST ULONG_PTR *lpArguments);
  4182. #ifdef FEATURE_PAL_SXS
  4183. PALIMPORT
  4184. PAL_NORETURN
  4185. VOID
  4186. PALAPI
  4187. PAL_RaiseException(
  4188. IN PEXCEPTION_POINTERS ExceptionPointers);
  4189. #endif // FEATURE_PAL_SXS
  4190. PALIMPORT
  4191. DWORD
  4192. PALAPI
  4193. GetTickCount(
  4194. VOID);
  4195. PALIMPORT
  4196. ULONGLONG
  4197. PALAPI
  4198. GetTickCount64();
  4199. PALIMPORT
  4200. BOOL
  4201. PALAPI
  4202. QueryPerformanceCounter(
  4203. OUT LARGE_INTEGER *lpPerformanceCount
  4204. );
  4205. PALIMPORT
  4206. BOOL
  4207. PALAPI
  4208. QueryPerformanceFrequency(
  4209. OUT LARGE_INTEGER *lpFrequency
  4210. );
  4211. PALIMPORT
  4212. BOOL
  4213. PALAPI
  4214. QueryThreadCycleTime(
  4215. IN HANDLE ThreadHandle,
  4216. OUT PULONG64 CycleTime);
  4217. #ifndef FEATURE_PAL_SXS
  4218. typedef LONG (PALAPI *PTOP_LEVEL_EXCEPTION_FILTER)(
  4219. struct _EXCEPTION_POINTERS *ExceptionInfo);
  4220. typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
  4221. PALIMPORT
  4222. LPTOP_LEVEL_EXCEPTION_FILTER
  4223. PALAPI
  4224. SetUnhandledExceptionFilter(
  4225. IN LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter);
  4226. PALIMPORT
  4227. LONG
  4228. UnhandledExceptionFilter(
  4229. IN struct _EXCEPTION_POINTERS *ExceptionInfo);
  4230. PALIMPORT
  4231. LPEXCEPTION_POINTERS
  4232. GetExceptionInformation();
  4233. #else // FEATURE_PAL_SXS
  4234. typedef EXCEPTION_DISPOSITION (PALAPI *PVECTORED_EXCEPTION_HANDLER)(
  4235. struct _EXCEPTION_POINTERS *ExceptionPointers);
  4236. #endif // FEATURE_PAL_SXS
  4237. // Define BitScanForward64 and BitScanForward
  4238. // Per MSDN, BitScanForward64 will search the mask data from LSB to MSB for a set bit.
  4239. // If one is found, its bit position is returned in the out PDWORD argument and 1 is returned.
  4240. // Otherwise, 0 is returned.
  4241. //
  4242. // On GCC, the equivalent function is __builtin_ffsl. It returns 1+index of the least
  4243. // significant set bit, or 0 if if mask is zero.
  4244. //
  4245. // The same is true for BitScanForward, except that the GCC function is __builtin_ffs.
  4246. EXTERN_C
  4247. PALIMPORT
  4248. inline
  4249. unsigned char
  4250. PALAPI
  4251. BitScanForward(
  4252. IN OUT PDWORD Index,
  4253. IN UINT qwMask)
  4254. {
  4255. unsigned char bRet = FALSE;
  4256. static_assert(sizeof(qwMask) <= sizeof(int),
  4257. "use correct __builtin_ffs??? variant");
  4258. int iIndex = __builtin_ffs(qwMask);
  4259. if (iIndex != 0)
  4260. {
  4261. // Set the Index after deducting unity
  4262. *Index = (DWORD)(iIndex - 1);
  4263. bRet = TRUE;
  4264. }
  4265. return bRet;
  4266. }
  4267. EXTERN_C
  4268. PALIMPORT
  4269. inline
  4270. unsigned char
  4271. PALAPI
  4272. BitScanForward64(
  4273. IN OUT PDWORD Index,
  4274. IN UINT64 qwMask)
  4275. {
  4276. unsigned char bRet = FALSE;
  4277. static_assert(sizeof(qwMask) <= sizeof(long long),
  4278. "use correct __builtin_ffs??? variant");
  4279. int iIndex = __builtin_ffsll(qwMask);
  4280. if (iIndex != 0)
  4281. {
  4282. // Set the Index after deducting unity
  4283. *Index = (DWORD)(iIndex - 1);
  4284. bRet = TRUE;
  4285. }
  4286. return bRet;
  4287. }
  4288. // xplat-todo: review this implementation
  4289. EXTERN_C
  4290. PALIMPORT
  4291. inline
  4292. unsigned char
  4293. PALAPI
  4294. BitScanReverse(
  4295. IN OUT PDWORD Index,
  4296. IN UINT qwMask)
  4297. {
  4298. unsigned char bRet = FALSE;
  4299. if (qwMask != 0)
  4300. {
  4301. static_assert(sizeof(qwMask) <= sizeof(unsigned int),
  4302. "use correct __builtin_clz??? variant");
  4303. int countLeadingZero = __builtin_clz(qwMask);
  4304. *Index = (DWORD)(sizeof(qwMask) * 8 - 1 - countLeadingZero);
  4305. bRet = TRUE;
  4306. }
  4307. return bRet;
  4308. }
  4309. // xplat-todo: review this implementation
  4310. EXTERN_C
  4311. PALIMPORT
  4312. inline
  4313. unsigned char
  4314. PALAPI
  4315. BitScanReverse64(
  4316. IN OUT PDWORD Index,
  4317. IN UINT64 qwMask)
  4318. {
  4319. unsigned char bRet = FALSE;
  4320. if (qwMask != 0)
  4321. {
  4322. static_assert(sizeof(qwMask) <= sizeof(unsigned long long),
  4323. "use correct __builtin_clz??? variant");
  4324. int countLeadingZero = __builtin_clzll(qwMask);
  4325. *Index = (DWORD)(sizeof(qwMask) * 8 - 1 - countLeadingZero);
  4326. bRet = TRUE;
  4327. }
  4328. return bRet;
  4329. }
  4330. /*++
  4331. Function:
  4332. InterlockedIncrement
  4333. The InterlockedIncrement function increments (increases by one) the
  4334. value of the specified variable and checks the resulting value. The
  4335. function prevents more than one thread from using the same variable
  4336. simultaneously.
  4337. Parameters
  4338. lpAddend
  4339. [in/out] Pointer to the variable to increment.
  4340. Return Values
  4341. The return value is the resulting incremented value.
  4342. --*/
  4343. EXTERN_C
  4344. PALIMPORT
  4345. inline
  4346. LONG
  4347. PALAPI
  4348. InterlockedIncrement(
  4349. IN OUT LONG volatile *lpAddend)
  4350. {
  4351. return __sync_add_and_fetch(lpAddend, (LONG)1);
  4352. }
  4353. EXTERN_C
  4354. PALIMPORT
  4355. inline
  4356. LONGLONG
  4357. PALAPI
  4358. InterlockedIncrement16(
  4359. IN OUT SHORT volatile *lpAddend)
  4360. {
  4361. return __sync_add_and_fetch(lpAddend, (SHORT)1);
  4362. }
  4363. EXTERN_C
  4364. PALIMPORT
  4365. inline
  4366. LONGLONG
  4367. PALAPI
  4368. InterlockedIncrement64(
  4369. IN OUT LONGLONG volatile *lpAddend)
  4370. {
  4371. return __sync_add_and_fetch(lpAddend, (LONGLONG)1);
  4372. }
  4373. /*++
  4374. Function:
  4375. InterlockedDecrement
  4376. The InterlockedDecrement function decrements (decreases by one) the
  4377. value of the specified variable and checks the resulting value. The
  4378. function prevents more than one thread from using the same variable
  4379. simultaneously.
  4380. Parameters
  4381. lpAddend
  4382. [in/out] Pointer to the variable to decrement.
  4383. Return Values
  4384. The return value is the resulting decremented value.
  4385. --*/
  4386. EXTERN_C
  4387. PALIMPORT
  4388. inline
  4389. LONG
  4390. PALAPI
  4391. InterlockedDecrement(
  4392. IN OUT LONG volatile *lpAddend)
  4393. {
  4394. return __sync_sub_and_fetch(lpAddend, (LONG)1);
  4395. }
  4396. EXTERN_C
  4397. PALIMPORT
  4398. inline
  4399. LONGLONG
  4400. PALAPI
  4401. InterlockedDecrement64(
  4402. IN OUT LONGLONG volatile *lpAddend)
  4403. {
  4404. return __sync_sub_and_fetch(lpAddend, (LONGLONG)1);
  4405. }
  4406. /*++
  4407. Function:
  4408. InterlockedExchange
  4409. The InterlockedExchange function atomically exchanges a pair of
  4410. values. The function prevents more than one thread from using the same
  4411. variable simultaneously.
  4412. Parameters
  4413. Target
  4414. [in/out] Pointer to the value to exchange. The function sets
  4415. this variable to Value, and returns its prior value.
  4416. Value
  4417. [in] Specifies a new value for the variable pointed to by Target.
  4418. Return Values
  4419. The function returns the initial value pointed to by Target.
  4420. --*/
  4421. EXTERN_C
  4422. PALIMPORT
  4423. inline
  4424. char
  4425. PALAPI
  4426. InterlockedExchange8(
  4427. IN OUT char volatile *Target,
  4428. IN char Value)
  4429. {
  4430. return __sync_swap(Target, Value);
  4431. }
  4432. EXTERN_C
  4433. PALIMPORT
  4434. inline
  4435. short
  4436. PALAPI
  4437. InterlockedExchange16(
  4438. IN OUT short volatile *Target,
  4439. IN short Value)
  4440. {
  4441. return __sync_swap(Target, Value);
  4442. }
  4443. EXTERN_C
  4444. PALIMPORT
  4445. inline
  4446. LONG
  4447. PALAPI
  4448. InterlockedExchange(
  4449. IN OUT LONG volatile *Target,
  4450. IN LONG Value)
  4451. {
  4452. return __sync_swap(Target, Value);
  4453. }
  4454. EXTERN_C
  4455. PALIMPORT
  4456. inline
  4457. LONGLONG
  4458. PALAPI
  4459. InterlockedExchange64(
  4460. IN OUT LONGLONG volatile *Target,
  4461. IN LONGLONG Value)
  4462. {
  4463. return __sync_swap(Target, Value);
  4464. }
  4465. /*++
  4466. Function:
  4467. InterlockedCompareExchange
  4468. The InterlockedCompareExchange function performs an atomic comparison
  4469. of the specified values and exchanges the values, based on the outcome
  4470. of the comparison. The function prevents more than one thread from
  4471. using the same variable simultaneously.
  4472. If you are exchanging pointer values, this function has been
  4473. superseded by the InterlockedCompareExchangePointer function.
  4474. Parameters
  4475. Destination [in/out] Specifies the address of the destination value. The sign is ignored.
  4476. Exchange [in] Specifies the exchange value. The sign is ignored.
  4477. Comperand [in] Specifies the value to compare to Destination. The sign is ignored.
  4478. Return Values
  4479. The return value is the initial value of the destination.
  4480. --*/
  4481. EXTERN_C
  4482. PALIMPORT
  4483. inline
  4484. char
  4485. PALAPI
  4486. InterlockedCompareExchange8(
  4487. IN OUT char volatile *Destination,
  4488. IN char Exchange,
  4489. IN char Comperand)
  4490. {
  4491. return __sync_val_compare_and_swap(
  4492. Destination, /* The pointer to a variable whose value is to be compared with. */
  4493. Comperand, /* The value to be compared */
  4494. Exchange /* The value to be stored */);
  4495. }
  4496. EXTERN_C
  4497. PALIMPORT
  4498. inline
  4499. short
  4500. PALAPI
  4501. InterlockedCompareExchange16(
  4502. IN OUT short volatile *Destination,
  4503. IN short Exchange,
  4504. IN short Comperand)
  4505. {
  4506. return __sync_val_compare_and_swap(
  4507. Destination, /* The pointer to a variable whose value is to be compared with. */
  4508. Comperand, /* The value to be compared */
  4509. Exchange /* The value to be stored */);
  4510. }
  4511. EXTERN_C
  4512. PALIMPORT
  4513. inline
  4514. LONG
  4515. PALAPI
  4516. InterlockedCompareExchange(
  4517. IN OUT LONG volatile *Destination,
  4518. IN LONG Exchange,
  4519. IN LONG Comperand)
  4520. {
  4521. return __sync_val_compare_and_swap(
  4522. Destination, /* The pointer to a variable whose value is to be compared with. */
  4523. Comperand, /* The value to be compared */
  4524. Exchange /* The value to be stored */);
  4525. }
  4526. EXTERN_C
  4527. PALIMPORT
  4528. inline
  4529. LONG
  4530. PALAPI
  4531. InterlockedCompareExchangeAcquire(
  4532. IN OUT LONG volatile *Destination,
  4533. IN LONG Exchange,
  4534. IN LONG Comperand)
  4535. {
  4536. // TODO: implement the version with only the acquire semantics
  4537. return __sync_val_compare_and_swap(
  4538. Destination, /* The pointer to a variable whose value is to be compared with. */
  4539. Comperand, /* The value to be compared */
  4540. Exchange /* The value to be stored */);
  4541. }
  4542. EXTERN_C
  4543. PALIMPORT
  4544. inline
  4545. LONG
  4546. PALAPI
  4547. InterlockedCompareExchangeRelease(
  4548. IN OUT LONG volatile *Destination,
  4549. IN LONG Exchange,
  4550. IN LONG Comperand)
  4551. {
  4552. // TODO: implement the version with only the release semantics
  4553. return __sync_val_compare_and_swap(
  4554. Destination, /* The pointer to a variable whose value is to be compared with. */
  4555. Comperand, /* The value to be compared */
  4556. Exchange /* The value to be stored */);
  4557. }
  4558. // See the 32-bit variant in interlock2.s
  4559. EXTERN_C
  4560. PALIMPORT
  4561. inline
  4562. LONGLONG
  4563. PALAPI
  4564. InterlockedCompareExchange64(
  4565. IN OUT LONGLONG volatile *Destination,
  4566. IN LONGLONG Exchange,
  4567. IN LONGLONG Comperand)
  4568. {
  4569. return __sync_val_compare_and_swap(
  4570. Destination, /* The pointer to a variable whose value is to be compared with. */
  4571. Comperand, /* The value to be compared */
  4572. Exchange /* The value to be stored */);
  4573. }
  4574. /*++
  4575. Function:
  4576. InterlockedExchangeAdd
  4577. The InterlockedExchangeAdd function atomically adds the value of 'Value'
  4578. to the variable that 'Addend' points to.
  4579. Parameters
  4580. lpAddend
  4581. [in/out] Pointer to the variable to to added.
  4582. Return Values
  4583. The return value is the original value that 'Addend' pointed to.
  4584. --*/
  4585. EXTERN_C
  4586. PALIMPORT
  4587. inline
  4588. char
  4589. PALAPI
  4590. InterlockedExchangeAdd8(
  4591. IN OUT char volatile *Addend,
  4592. IN char Value)
  4593. {
  4594. return __sync_fetch_and_add(Addend, Value);
  4595. }
  4596. EXTERN_C
  4597. PALIMPORT
  4598. inline
  4599. short
  4600. PALAPI
  4601. InterlockedExchangeAdd16(
  4602. IN OUT short volatile *Addend,
  4603. IN short Value)
  4604. {
  4605. return __sync_fetch_and_add(Addend, Value);
  4606. }
  4607. EXTERN_C
  4608. PALIMPORT
  4609. inline
  4610. LONG
  4611. PALAPI
  4612. InterlockedExchangeAdd(
  4613. IN OUT LONG volatile *Addend,
  4614. IN LONG Value)
  4615. {
  4616. return __sync_fetch_and_add(Addend, Value);
  4617. }
  4618. EXTERN_C
  4619. PALIMPORT
  4620. inline
  4621. LONG
  4622. PALAPI
  4623. InterlockedAdd(
  4624. IN OUT LONG volatile *Addend,
  4625. IN LONG Value)
  4626. {
  4627. return InterlockedExchangeAdd(Addend, Value) + Value;
  4628. }
  4629. EXTERN_C
  4630. PALIMPORT
  4631. inline
  4632. LONGLONG
  4633. PALAPI
  4634. InterlockedExchangeAdd64(
  4635. IN OUT LONGLONG volatile *Addend,
  4636. IN LONGLONG Value)
  4637. {
  4638. return __sync_fetch_and_add(Addend, Value);
  4639. }
  4640. EXTERN_C
  4641. PALIMPORT
  4642. inline
  4643. char
  4644. PALAPI
  4645. InterlockedAnd8(
  4646. IN OUT char volatile *Destination,
  4647. IN char Value)
  4648. {
  4649. return __sync_fetch_and_and(Destination, Value);
  4650. }
  4651. EXTERN_C
  4652. PALIMPORT
  4653. inline
  4654. short
  4655. PALAPI
  4656. InterlockedAnd16(
  4657. IN OUT short volatile *Destination,
  4658. IN short Value)
  4659. {
  4660. return __sync_fetch_and_and(Destination, Value);
  4661. }
  4662. EXTERN_C
  4663. PALIMPORT
  4664. inline
  4665. LONG
  4666. PALAPI
  4667. InterlockedAnd(
  4668. IN OUT LONG volatile *Destination,
  4669. IN LONG Value)
  4670. {
  4671. return __sync_fetch_and_and(Destination, Value);
  4672. }
  4673. EXTERN_C
  4674. PALIMPORT
  4675. inline
  4676. LONGLONG
  4677. PALAPI
  4678. InterlockedAnd64(
  4679. IN OUT LONGLONG volatile *Destination,
  4680. IN LONGLONG Value)
  4681. {
  4682. return __sync_fetch_and_and(Destination, Value);
  4683. }
  4684. EXTERN_C
  4685. PALIMPORT
  4686. inline
  4687. char
  4688. PALAPI
  4689. InterlockedOr8(
  4690. IN OUT char volatile *Destination,
  4691. IN char Value)
  4692. {
  4693. return __sync_fetch_and_or(Destination, Value);
  4694. }
  4695. EXTERN_C
  4696. PALIMPORT
  4697. inline
  4698. short
  4699. PALAPI
  4700. InterlockedOr16(
  4701. IN OUT short volatile *Destination,
  4702. IN short Value)
  4703. {
  4704. return __sync_fetch_and_or(Destination, Value);
  4705. }
  4706. EXTERN_C
  4707. PALIMPORT
  4708. inline
  4709. LONG
  4710. PALAPI
  4711. InterlockedOr(
  4712. IN OUT LONG volatile *Destination,
  4713. IN LONG Value)
  4714. {
  4715. return __sync_fetch_and_or(Destination, Value);
  4716. }
  4717. EXTERN_C
  4718. PALIMPORT
  4719. inline
  4720. LONGLONG
  4721. PALAPI
  4722. InterlockedOr64(
  4723. IN OUT LONGLONG volatile *Destination,
  4724. IN LONGLONG Value)
  4725. {
  4726. return __sync_fetch_and_or(Destination, Value);
  4727. }
  4728. EXTERN_C
  4729. PALIMPORT
  4730. inline
  4731. char
  4732. PALAPI
  4733. InterlockedXor8(
  4734. IN OUT char volatile *Destination,
  4735. IN char Value)
  4736. {
  4737. return __sync_fetch_and_xor(Destination, Value);
  4738. }
  4739. EXTERN_C
  4740. PALIMPORT
  4741. inline
  4742. short
  4743. PALAPI
  4744. InterlockedXor16(
  4745. IN OUT short volatile *Destination,
  4746. IN short Value)
  4747. {
  4748. return __sync_fetch_and_xor(Destination, Value);
  4749. }
  4750. EXTERN_C
  4751. PALIMPORT
  4752. inline
  4753. LONG
  4754. PALAPI
  4755. InterlockedXor(
  4756. IN OUT LONG volatile *Destination,
  4757. IN LONG Value)
  4758. {
  4759. return __sync_fetch_and_xor(Destination, Value);
  4760. }
  4761. EXTERN_C
  4762. PALIMPORT
  4763. inline
  4764. LONGLONG
  4765. PALAPI
  4766. InterlockedXor64(
  4767. IN OUT LONGLONG volatile *Destination,
  4768. IN LONGLONG Value)
  4769. {
  4770. return __sync_fetch_and_xor(Destination, Value);
  4771. }
  4772. #define BITS_IN_BYTE 8
  4773. #define BITS_IN_LONG (sizeof(LONG) * BITS_IN_BYTE)
  4774. EXTERN_C
  4775. PALIMPORT
  4776. inline
  4777. UCHAR
  4778. PALAPI
  4779. InterlockedBitTestAndReset(
  4780. IN OUT LONG volatile *Base,
  4781. IN LONG Bit)
  4782. {
  4783. // The BitTestAndReset family of functions allow for arbitrary bit
  4784. // indices- so a bit index can be greater than the number of bits in
  4785. // LONG. We need to account for this in all BitTest/BitTestAndSet
  4786. // related functions.
  4787. volatile LONG* longToTest = Base + (Bit / BITS_IN_LONG);
  4788. LONG bitToTest = Bit % BITS_IN_LONG;
  4789. return (InterlockedAnd(longToTest, ~(1 << bitToTest)) & (1 << bitToTest)) != 0;
  4790. }
  4791. EXTERN_C
  4792. PALIMPORT
  4793. inline
  4794. UCHAR
  4795. PALAPI
  4796. InterlockedBitTestAndSet(
  4797. IN OUT LONG volatile *Base,
  4798. IN LONG Bit)
  4799. {
  4800. volatile LONG* longToTest = Base + (Bit / BITS_IN_LONG);
  4801. LONG bitToTest = Bit % BITS_IN_LONG;
  4802. return (InterlockedOr(longToTest, (1 << bitToTest)) & (1 << bitToTest)) != 0;
  4803. }
  4804. EXTERN_C
  4805. PALIMPORT
  4806. inline
  4807. UCHAR
  4808. PALAPI
  4809. BitTest(
  4810. IN LONG *Base,
  4811. IN LONG Bit)
  4812. {
  4813. LONG* longToTest = Base + (Bit / BITS_IN_LONG);
  4814. LONG bitToTest = Bit % BITS_IN_LONG;
  4815. return ((*longToTest) & (1 << bitToTest)) != 0;
  4816. }
  4817. EXTERN_C
  4818. PALIMPORT
  4819. inline
  4820. UCHAR
  4821. PALAPI
  4822. BitTestAndSet(
  4823. IN OUT LONG *Base,
  4824. IN LONG Bit)
  4825. {
  4826. // xplat-todo: Benchmark whether this is better than
  4827. // using the inline assembler to generate a bts instruction
  4828. LONG* longToTest = Base + (Bit / BITS_IN_LONG);
  4829. LONG bitToTest = Bit % BITS_IN_LONG;
  4830. // Save whether the bit was set or not. Then, unconditionally set the
  4831. // bit. Return whether the bit was set or not.
  4832. UCHAR wasBitSet = (((*longToTest) & (1 << bitToTest)) != 0);
  4833. *longToTest = *longToTest | (1 << bitToTest);
  4834. return wasBitSet;
  4835. }
  4836. #if defined(BIT64)
  4837. #define InterlockedExchangePointer(Target, Value) \
  4838. ((PVOID)InterlockedExchange64((PLONG64)(Target), (LONGLONG)(Value)))
  4839. #define InterlockedCompareExchangePointer(Destination, ExChange, Comperand) \
  4840. ((PVOID)InterlockedCompareExchange64((PLONG64)(Destination), (LONGLONG)(ExChange), (LONGLONG)(Comperand)))
  4841. #else
  4842. #define InterlockedExchangePointer(Target, Value) \
  4843. ((PVOID)(UINT_PTR)InterlockedExchange((PLONG)(UINT_PTR)(Target), (LONG)(UINT_PTR)(Value)))
  4844. #define InterlockedCompareExchangePointer(Destination, ExChange, Comperand) \
  4845. ((PVOID)(UINT_PTR)InterlockedCompareExchange((PLONG)(UINT_PTR)(Destination), (LONG)(UINT_PTR)(ExChange), (LONG)(UINT_PTR)(Comperand)))
  4846. #endif
  4847. /*++
  4848. Function:
  4849. MemoryBarrier
  4850. The MemoryBarrier function creates a full memory barrier.
  4851. --*/
  4852. EXTERN_C
  4853. PALIMPORT
  4854. inline
  4855. VOID
  4856. PALAPI
  4857. MemoryBarrier(
  4858. VOID)
  4859. {
  4860. __sync_synchronize();
  4861. }
  4862. PALIMPORT
  4863. VOID
  4864. PALAPI
  4865. YieldProcessor(
  4866. VOID);
  4867. PALIMPORT
  4868. DWORD
  4869. PALAPI
  4870. GetCurrentProcessorNumber();
  4871. /*++
  4872. Function:
  4873. PAL_HasGetCurrentProcessorNumber
  4874. Checks if GetCurrentProcessorNumber is available in the current environment
  4875. --*/
  4876. PALIMPORT
  4877. BOOL
  4878. PALAPI
  4879. PAL_HasGetCurrentProcessorNumber();
  4880. #define FORMAT_MESSAGE_ALLOCATE_BUFFER 0x00000100
  4881. #define FORMAT_MESSAGE_IGNORE_INSERTS 0x00000200
  4882. #define FORMAT_MESSAGE_FROM_STRING 0x00000400
  4883. #define FORMAT_MESSAGE_FROM_SYSTEM 0x00001000
  4884. #define FORMAT_MESSAGE_ARGUMENT_ARRAY 0x00002000
  4885. #define FORMAT_MESSAGE_MAX_WIDTH_MASK 0x000000FF
  4886. PALIMPORT
  4887. DWORD
  4888. PALAPI
  4889. FormatMessageW(
  4890. IN DWORD dwFlags,
  4891. IN LPCVOID lpSource,
  4892. IN DWORD dwMessageId,
  4893. IN DWORD dwLanguageId,
  4894. OUT LPWSTR lpBffer,
  4895. IN DWORD nSize,
  4896. IN va_list *Arguments);
  4897. #ifdef UNICODE
  4898. #define FormatMessage FormatMessageW
  4899. #endif
  4900. PALIMPORT
  4901. DWORD
  4902. PALAPI
  4903. GetLastError(
  4904. VOID);
  4905. PALIMPORT
  4906. VOID
  4907. PALAPI
  4908. SetLastError(
  4909. IN DWORD dwErrCode);
  4910. PALIMPORT
  4911. LPWSTR
  4912. PALAPI
  4913. GetCommandLineW(
  4914. VOID);
  4915. #ifdef UNICODE
  4916. #define GetCommandLine GetCommandLineW
  4917. #endif
  4918. PALIMPORT
  4919. VOID
  4920. PALAPI
  4921. RtlRestoreContext(
  4922. IN PCONTEXT ContextRecord,
  4923. IN PEXCEPTION_RECORD ExceptionRecord
  4924. );
  4925. PALIMPORT
  4926. VOID
  4927. PALAPI
  4928. RtlCaptureContext(
  4929. OUT PCONTEXT ContextRecord
  4930. );
  4931. PALIMPORT
  4932. VOID
  4933. PALAPI
  4934. FlushProcessWriteBuffers();
  4935. typedef void (*PAL_ActivationFunction)(CONTEXT *context);
  4936. typedef BOOL (*PAL_SafeActivationCheckFunction)(SIZE_T ip, BOOL checkingCurrentThread);
  4937. PALIMPORT
  4938. VOID
  4939. PALAPI
  4940. PAL_SetActivationFunction(
  4941. IN PAL_ActivationFunction pActivationFunction,
  4942. IN PAL_SafeActivationCheckFunction pSafeActivationCheckFunction);
  4943. PALIMPORT
  4944. BOOL
  4945. PALAPI
  4946. PAL_InjectActivation(
  4947. IN HANDLE hThread
  4948. );
  4949. #define VER_PLATFORM_WIN32_WINDOWS 1
  4950. #define VER_PLATFORM_WIN32_NT 2
  4951. #define VER_PLATFORM_UNIX 10
  4952. #define VER_PLATFORM_MACOSX 11
  4953. typedef struct _OSVERSIONINFOA {
  4954. DWORD dwOSVersionInfoSize;
  4955. DWORD dwMajorVersion;
  4956. DWORD dwMinorVersion;
  4957. DWORD dwBuildNumber;
  4958. DWORD dwPlatformId;
  4959. CHAR szCSDVersion[ 128 ];
  4960. } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
  4961. typedef struct _OSVERSIONINFOW {
  4962. DWORD dwOSVersionInfoSize;
  4963. DWORD dwMajorVersion;
  4964. DWORD dwMinorVersion;
  4965. DWORD dwBuildNumber;
  4966. DWORD dwPlatformId;
  4967. WCHAR szCSDVersion[ 128 ];
  4968. } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW;
  4969. #ifdef UNICODE
  4970. typedef OSVERSIONINFOW OSVERSIONINFO;
  4971. typedef POSVERSIONINFOW POSVERSIONINFO;
  4972. typedef LPOSVERSIONINFOW LPOSVERSIONINFO;
  4973. #else
  4974. typedef OSVERSIONINFOA OSVERSIONINFO;
  4975. typedef POSVERSIONINFOA POSVERSIONINFO;
  4976. typedef LPOSVERSIONINFOA LPOSVERSIONINFO;
  4977. #endif
  4978. typedef struct _OSVERSIONINFOEXA {
  4979. DWORD dwOSVersionInfoSize;
  4980. DWORD dwMajorVersion;
  4981. DWORD dwMinorVersion;
  4982. DWORD dwBuildNumber;
  4983. DWORD dwPlatformId;
  4984. CHAR szCSDVersion[ 128 ];
  4985. WORD wServicePackMajor;
  4986. WORD wServicePackMinor;
  4987. WORD wSuiteMask;
  4988. BYTE wProductType;
  4989. BYTE wReserved;
  4990. } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA;
  4991. typedef struct _OSVERSIONINFOEXW {
  4992. DWORD dwOSVersionInfoSize;
  4993. DWORD dwMajorVersion;
  4994. DWORD dwMinorVersion;
  4995. DWORD dwBuildNumber;
  4996. DWORD dwPlatformId;
  4997. WCHAR szCSDVersion[ 128 ];
  4998. WORD wServicePackMajor;
  4999. WORD wServicePackMinor;
  5000. WORD wSuiteMask;
  5001. BYTE wProductType;
  5002. BYTE wReserved;
  5003. } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW;
  5004. #ifdef UNICODE
  5005. typedef OSVERSIONINFOEXW OSVERSIONINFOEX;
  5006. typedef POSVERSIONINFOEXW POSVERSIONINFOEX;
  5007. typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX;
  5008. #else
  5009. typedef OSVERSIONINFOEXA OSVERSIONINFOEX;
  5010. typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
  5011. typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
  5012. #endif
  5013. PALIMPORT
  5014. BOOL
  5015. PALAPI
  5016. GetVersionExA(
  5017. IN OUT LPOSVERSIONINFOA lpVersionInformation);
  5018. PALIMPORT
  5019. BOOL
  5020. PALAPI
  5021. GetVersionExW(
  5022. IN OUT LPOSVERSIONINFOW lpVersionInformation);
  5023. #ifdef UNICODE
  5024. #define GetVersionEx GetVersionExW
  5025. #else
  5026. #define GetVersionEx GetVersionExA
  5027. #endif
  5028. #define IMAGE_FILE_MACHINE_I386 0x014c
  5029. #define IMAGE_FILE_MACHINE_ARM64 0xAA64 // ARM64 Little-Endian
  5030. typedef struct _SYSTEM_INFO {
  5031. WORD wProcessorArchitecture_PAL_Undefined;
  5032. WORD wReserved_PAL_Undefined; // NOTE: diff from winbase.h - no obsolete dwOemId union
  5033. DWORD dwPageSize;
  5034. LPVOID lpMinimumApplicationAddress;
  5035. LPVOID lpMaximumApplicationAddress;
  5036. DWORD_PTR dwActiveProcessorMask_PAL_Undefined;
  5037. DWORD dwNumberOfProcessors;
  5038. DWORD dwProcessorType_PAL_Undefined;
  5039. DWORD dwAllocationGranularity;
  5040. WORD wProcessorLevel_PAL_Undefined;
  5041. WORD wProcessorRevision_PAL_Undefined;
  5042. } SYSTEM_INFO, *LPSYSTEM_INFO;
  5043. PALIMPORT
  5044. VOID
  5045. PALAPI
  5046. GetSystemInfo(
  5047. OUT LPSYSTEM_INFO lpSystemInfo);
  5048. PALIMPORT
  5049. BOOL
  5050. PALAPI
  5051. GetDiskFreeSpaceW(
  5052. LPCWSTR lpDirectoryName,
  5053. LPDWORD lpSectorsPerCluster,
  5054. LPDWORD lpBytesPerSector,
  5055. LPDWORD lpNumberOfFreeClusters,
  5056. LPDWORD lpTotalNumberOfClusters);
  5057. #ifdef UNICODE
  5058. #define GetDiskFreeSpace GetDiskFreeSpaceW
  5059. #endif
  5060. PALIMPORT
  5061. BOOL
  5062. PALAPI
  5063. CreatePipe(
  5064. OUT PHANDLE hReadPipe,
  5065. OUT PHANDLE hWritePipe,
  5066. IN LPSECURITY_ATTRIBUTES lpPipeAttributes,
  5067. IN DWORD nSize
  5068. );
  5069. PALIMPORT
  5070. BOOL
  5071. PALAPI
  5072. DeregisterEventSource (
  5073. IN HANDLE hEventLog
  5074. );
  5075. PALIMPORT
  5076. HANDLE
  5077. PALAPI
  5078. RegisterEventSourceA (
  5079. IN OPTIONAL LPCSTR lpUNCServerName,
  5080. IN LPCSTR lpSourceName
  5081. );
  5082. PALIMPORT
  5083. HANDLE
  5084. PALAPI
  5085. RegisterEventSourceW (
  5086. IN OPTIONAL LPCWSTR lpUNCServerName,
  5087. IN LPCWSTR lpSourceName
  5088. );
  5089. #ifdef UNICODE
  5090. #define RegisterEventSource RegisterEventSourceW
  5091. #else
  5092. #define RegisterEventSource RegisterEventSourceA
  5093. #endif // !UNICODE
  5094. //
  5095. // The types of events that can be logged.
  5096. //
  5097. #define EVENTLOG_SUCCESS 0x0000
  5098. #define EVENTLOG_ERROR_TYPE 0x0001
  5099. #define EVENTLOG_WARNING_TYPE 0x0002
  5100. #define EVENTLOG_INFORMATION_TYPE 0x0004
  5101. #define EVENTLOG_AUDIT_SUCCESS 0x0008
  5102. #define EVENTLOG_AUDIT_FAILURE 0x0010
  5103. PALIMPORT
  5104. BOOL
  5105. PALAPI
  5106. ReportEventA (
  5107. IN HANDLE hEventLog,
  5108. IN WORD wType,
  5109. IN WORD wCategory,
  5110. IN DWORD dwEventID,
  5111. IN OPTIONAL PSID lpUserSid,
  5112. IN WORD wNumStrings,
  5113. IN DWORD dwDataSize,
  5114. IN OPTIONAL LPCSTR *lpStrings,
  5115. IN OPTIONAL LPVOID lpRawData
  5116. );
  5117. PALIMPORT
  5118. BOOL
  5119. PALAPI
  5120. ReportEventW (
  5121. IN HANDLE hEventLog,
  5122. IN WORD wType,
  5123. IN WORD wCategory,
  5124. IN DWORD dwEventID,
  5125. IN OPTIONAL PSID lpUserSid,
  5126. IN WORD wNumStrings,
  5127. IN DWORD dwDataSize,
  5128. IN OPTIONAL LPCWSTR *lpStrings,
  5129. IN OPTIONAL LPVOID lpRawData
  5130. );
  5131. #ifdef UNICODE
  5132. #define ReportEvent ReportEventW
  5133. #else
  5134. #define ReportEvent ReportEventA
  5135. #endif // !UNICODE
  5136. PALIMPORT
  5137. HRESULT
  5138. PALAPI
  5139. CoCreateGuid(OUT GUID * pguid);
  5140. /******************* C Runtime Entrypoints *******************************/
  5141. /* Some C runtime functions needs to be reimplemented by the PAL.
  5142. To avoid name collisions, those functions have been renamed using
  5143. defines */
  5144. #ifdef PLATFORM_UNIX
  5145. #if !defined(PAL_STDCPP_COMPAT) || defined(USING_PAL_STDLIB)
  5146. #define exit PAL_exit
  5147. #define atexit PAL_atexit
  5148. #define printf PAL_printf
  5149. #define vprintf PAL_vprintf
  5150. #define wprintf PAL_wprintf
  5151. #define sprintf PAL_sprintf
  5152. #define swprintf PAL_swprintf
  5153. #define sscanf PAL_sscanf
  5154. #define wcsspn PAL_wcsspn
  5155. #define wcstod PAL_wcstod
  5156. #define wcstol PAL_wcstol
  5157. #define wcstoll PAL_wcstoll
  5158. #define wcstoul PAL_wcstoul
  5159. #define wcscat PAL_wcscat
  5160. #define wcscpy PAL_wcscpy
  5161. #define wcslen PAL_wcslen
  5162. #define wmemcmp PAL_wmemcmp
  5163. #define wcsncmp PAL_wcsncmp
  5164. #define wcschr PAL_wcschr
  5165. #define wcsrchr PAL_wcsrchr
  5166. #define wcsstr PAL_wcsstr
  5167. #define swscanf PAL_swscanf
  5168. #define wcspbrk PAL_wcspbrk
  5169. #define wcscmp PAL_wcscmp
  5170. #define wcsncat PAL_wcsncat
  5171. #define wcsncpy PAL_wcsncpy
  5172. #define wcstok PAL_wcstok
  5173. #define wcscspn PAL_wcscspn
  5174. #define iswprint PAL_iswprint
  5175. #define iswalpha PAL_iswalpha
  5176. #define iswdigit PAL_iswdigit
  5177. #define iswspace PAL_iswspace
  5178. #define iswupper PAL_iswupper
  5179. #define iswxdigit PAL_iswxdigit
  5180. #define towlower PAL_towlower
  5181. #define towupper PAL_towupper
  5182. #define vsprintf PAL_vsprintf
  5183. #define vswprintf PAL_vswprintf
  5184. #define realloc PAL_realloc
  5185. #define fopen PAL_fopen
  5186. #define strtok PAL_strtok
  5187. #define strtoul PAL_strtoul
  5188. #define fprintf PAL_fprintf
  5189. #define fwprintf PAL_fwprintf
  5190. #define vfprintf PAL_vfprintf
  5191. #define vfwprintf PAL_vfwprintf
  5192. #define ctime PAL_ctime
  5193. #define rand PAL_rand
  5194. #define getenv PAL_getenv
  5195. #define fgets PAL_fgets
  5196. #define fgetws PAL_fgetws
  5197. #define fputc PAL_fputc
  5198. #define putchar PAL_putchar
  5199. #define bsearch PAL_bsearch
  5200. #define ferror PAL_ferror
  5201. #define fread PAL_fread
  5202. #define fwrite PAL_fwrite
  5203. #define feof PAL_feof
  5204. #define ftell PAL_ftell
  5205. #define fclose PAL_fclose
  5206. #define setbuf PAL_setbuf
  5207. #define fflush PAL_fflush
  5208. #define fputs PAL_fputs
  5209. #define fseek PAL_fseek
  5210. #define fgetpos PAL_fgetpos
  5211. #define fsetpos PAL_fsetpos
  5212. #define getc PAL_getc
  5213. #define fgetc PAL_getc // not a typo
  5214. #define ungetc PAL_ungetc
  5215. #define setvbuf PAL_setvbuf
  5216. #define atol PAL_atol
  5217. #define acos PAL_acos
  5218. #define asin PAL_asin
  5219. #define atan2 PAL_atan2
  5220. #define exp PAL_exp
  5221. #define labs PAL_labs
  5222. #define log PAL_log
  5223. #define log10 PAL_log10
  5224. #define malloc PAL_malloc
  5225. #define memmove memmove_xplat
  5226. #define free PAL_free
  5227. #define mkstemp PAL_mkstemp
  5228. #define rename PAL_rename
  5229. #define unlink PAL_unlink
  5230. #define _strdup PAL__strdup
  5231. #define _getcwd PAL__getcwd
  5232. #define _open PAL__open
  5233. #define _close PAL__close
  5234. #define _wcstoui64 PAL__wcstoui64
  5235. #define _flushall PAL__flushall
  5236. #endif // !PAL_STDCPP_COMPAT
  5237. #endif // PLATFORM_UNIX
  5238. #ifndef _CONST_RETURN
  5239. #ifdef __cplusplus
  5240. #define _CONST_RETURN const
  5241. #define _CRT_CONST_CORRECT_OVERLOADS
  5242. #else
  5243. #define _CONST_RETURN
  5244. #endif
  5245. #endif
  5246. /* For backwards compatibility */
  5247. #define _WConst_return _CONST_RETURN
  5248. #define EOF (-1)
  5249. typedef int errno_t;
  5250. #ifndef PAL_STDCPP_COMPAT
  5251. typedef struct {
  5252. int quot;
  5253. int rem;
  5254. } div_t;
  5255. PALIMPORT div_t div(int numer, int denom);
  5256. PALIMPORT void * __cdecl memcpy(void *, const void *, size_t);
  5257. PALIMPORT int __cdecl memcmp(const void *, const void *, size_t);
  5258. PALIMPORT void * __cdecl memset(void *, int, size_t);
  5259. PALIMPORT void * __cdecl memchr(const void *, int, size_t);
  5260. PALIMPORT size_t __cdecl strlen(const char *);
  5261. PALIMPORT int __cdecl strcmp(const char*, const char *);
  5262. PALIMPORT int __cdecl strncmp(const char*, const char *, size_t);
  5263. PALIMPORT int __cdecl _strnicmp(const char *, const char *, size_t);
  5264. PALIMPORT char * __cdecl strcat(char *, const char *);
  5265. PALIMPORT char * __cdecl strncat(char *, const char *, size_t);
  5266. PALIMPORT char * __cdecl strcpy(char *, const char *);
  5267. PALIMPORT char * __cdecl strncpy(char *, const char *, size_t);
  5268. PALIMPORT char * __cdecl strchr(const char *, int);
  5269. PALIMPORT char * __cdecl strrchr(const char *, int);
  5270. PALIMPORT char * __cdecl strpbrk(const char *, const char *);
  5271. PALIMPORT char * __cdecl strstr(const char *, const char *);
  5272. PALIMPORT char * __cdecl strtok(char *, const char *);
  5273. PALIMPORT size_t __cdecl strspn(const char *, const char *);
  5274. PALIMPORT size_t __cdecl strcspn(const char *, const char *);
  5275. PALIMPORT int __cdecl sprintf(char *, const char *, ...);
  5276. PALIMPORT int __cdecl vsprintf(char *, const char *, va_list);
  5277. PALIMPORT int __cdecl sscanf(const char *, const char *, ...);
  5278. PALIMPORT int __cdecl atoi(const char *);
  5279. PALIMPORT LONG __cdecl atol(const char *);
  5280. PALIMPORT long long int __cdecl atoll(const char *);
  5281. PALIMPORT ULONG __cdecl strtoul(const char *, char **, int);
  5282. PALIMPORT double __cdecl atof(const char *);
  5283. PALIMPORT double __cdecl strtod(const char *, char **);
  5284. PALIMPORT int __cdecl isprint(int);
  5285. PALIMPORT int __cdecl isspace(int);
  5286. PALIMPORT int __cdecl isalpha(int);
  5287. PALIMPORT int __cdecl isalnum(int);
  5288. PALIMPORT int __cdecl isdigit(int);
  5289. PALIMPORT int __cdecl isxdigit(int);
  5290. PALIMPORT int __cdecl isupper(int);
  5291. PALIMPORT int __cdecl islower(int);
  5292. PALIMPORT int __cdecl tolower(int);
  5293. PALIMPORT int __cdecl toupper(int);
  5294. #endif // PAL_STDCPP_COMPAT
  5295. PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t);
  5296. PALIMPORT errno_t __cdecl memmove_s(void *, size_t, const void *, size_t);
  5297. PALIMPORT void * __cdecl memmove_xplat(void *, const void *, size_t);
  5298. PALIMPORT char * __cdecl _strlwr(char *);
  5299. PALIMPORT int __cdecl _stricmp(const char *, const char *);
  5300. PALIMPORT int __cdecl _snprintf(char *, size_t, const char *, ...);
  5301. PALIMPORT char * __cdecl _gcvt_s(char *, int, double, int);
  5302. PALIMPORT char * __cdecl _ecvt(double, int, int *, int *);
  5303. PALIMPORT int __cdecl __iscsym(int);
  5304. PALIMPORT size_t __cdecl _mbslen(const unsigned char *);
  5305. PALIMPORT unsigned char * __cdecl _mbsinc(const unsigned char *);
  5306. PALIMPORT unsigned char * __cdecl _mbsninc(const unsigned char *, size_t);
  5307. PALIMPORT unsigned char * __cdecl _mbsdec(const unsigned char *, const unsigned char *);
  5308. PALIMPORT int __cdecl _wcsicmp(const WCHAR *, const WCHAR*);
  5309. PALIMPORT int __cdecl _wcsnicmp(const WCHAR *, const WCHAR *, size_t);
  5310. PALIMPORT int __cdecl _vsnprintf(char *, size_t, const char *, va_list);
  5311. PALIMPORT int __cdecl _vsnwprintf(WCHAR *, size_t, const WCHAR *, va_list);
  5312. PALIMPORT WCHAR * __cdecl _itow(int, WCHAR *, int);
  5313. PALIMPORT WCHAR * __cdecl _ltow(long, WCHAR *, int);
  5314. PALIMPORT size_t __cdecl PAL_wcslen(const WCHAR *);
  5315. PALIMPORT int __cdecl PAL_wcscmp(const WCHAR*, const WCHAR*);
  5316. PALIMPORT int __cdecl PAL_wmemcmp(const WCHAR *, const WCHAR *, size_t);
  5317. PALIMPORT int __cdecl PAL_wcsncmp(const WCHAR *, const WCHAR *, size_t);
  5318. PALIMPORT WCHAR * __cdecl PAL_wcscat(WCHAR *, const WCHAR *);
  5319. PALIMPORT WCHAR * __cdecl PAL_wcsncat(WCHAR *, const WCHAR *, size_t);
  5320. PALIMPORT WCHAR * __cdecl PAL_wcscpy(WCHAR *, const WCHAR *);
  5321. PALIMPORT WCHAR * __cdecl PAL_wcsncpy(WCHAR *, const WCHAR *, size_t);
  5322. PALIMPORT const WCHAR * __cdecl PAL_wcschr(const WCHAR *, WCHAR);
  5323. PALIMPORT const WCHAR * __cdecl PAL_wcsrchr(const WCHAR *, WCHAR);
  5324. PALIMPORT WCHAR _WConst_return * __cdecl PAL_wcspbrk(const WCHAR *, const WCHAR *);
  5325. PALIMPORT WCHAR _WConst_return * __cdecl PAL_wcsstr(const WCHAR *, const WCHAR *);
  5326. PALIMPORT WCHAR * __cdecl PAL_wcstok(WCHAR *, const WCHAR *);
  5327. PALIMPORT size_t __cdecl PAL_wcscspn(const WCHAR *, const WCHAR *);
  5328. PALIMPORT int __cdecl PAL_swprintf(WCHAR *, const WCHAR *, ...);
  5329. PALIMPORT int __cdecl PAL_vswprintf(WCHAR *, const WCHAR *, va_list);
  5330. PALIMPORT int __cdecl _snwprintf(WCHAR *, size_t, const WCHAR *, ...);
  5331. PALIMPORT int __cdecl PAL_swscanf(const WCHAR *, const WCHAR *, ...);
  5332. PALIMPORT LONG __cdecl PAL_wcstol(const WCHAR *, WCHAR **, int);
  5333. PALIMPORT ULONG __cdecl PAL_wcstoul(const WCHAR *, WCHAR **, int);
  5334. PALIMPORT LONGLONG __cdecl PAL_wcstoll(const WCHAR *, WCHAR **, int);
  5335. PALIMPORT size_t __cdecl PAL_wcsspn (const WCHAR *, const WCHAR *);
  5336. PALIMPORT double __cdecl PAL_wcstod(const WCHAR *, WCHAR **);
  5337. PALIMPORT int __cdecl PAL_iswalpha(WCHAR);
  5338. PALIMPORT int __cdecl PAL_iswprint(WCHAR);
  5339. PALIMPORT int __cdecl PAL_iswupper(WCHAR);
  5340. PALIMPORT int __cdecl PAL_iswspace(WCHAR);
  5341. PALIMPORT int __cdecl PAL_iswdigit(WCHAR);
  5342. PALIMPORT int __cdecl PAL_iswxdigit(WCHAR);
  5343. PALIMPORT WCHAR __cdecl PAL_towlower(WCHAR);
  5344. PALIMPORT WCHAR __cdecl PAL_towupper(WCHAR);
  5345. PALIMPORT WCHAR * __cdecl _wcslwr(WCHAR *);
  5346. PALIMPORT ULONGLONG _wcstoui64(const WCHAR *, WCHAR **, int);
  5347. PALIMPORT WCHAR * __cdecl _i64tow(__int64, WCHAR *, int);
  5348. PALIMPORT WCHAR * __cdecl _ui64tow(unsigned __int64, WCHAR *, int);
  5349. PALIMPORT int __cdecl _wtoi(const WCHAR *);
  5350. #ifdef __cplusplus
  5351. extern "C++" {
  5352. inline WCHAR *PAL_wcschr(WCHAR *_S, WCHAR _C)
  5353. {return ((WCHAR *)PAL_wcschr((const WCHAR *)_S, _C)); }
  5354. inline WCHAR *PAL_wcsrchr(WCHAR *_S, WCHAR _C)
  5355. {return ((WCHAR *)PAL_wcsrchr((const WCHAR *)_S, _C)); }
  5356. inline WCHAR *PAL_wcspbrk(WCHAR *_S, const WCHAR *_P)
  5357. {return ((WCHAR *)PAL_wcspbrk((const WCHAR *)_S, _P)); }
  5358. inline WCHAR *PAL_wcsstr(WCHAR *_S, const WCHAR *_P)
  5359. {return ((WCHAR *)PAL_wcsstr((const WCHAR *)_S, _P)); }
  5360. }
  5361. #endif
  5362. #ifndef __has_builtin
  5363. #define __has_builtin(x) 0
  5364. #endif
  5365. #if !__has_builtin(_rotl)
  5366. /*++
  5367. Function:
  5368. _rotl
  5369. See MSDN doc.
  5370. --*/
  5371. EXTERN_C
  5372. PALIMPORT
  5373. inline
  5374. unsigned int __cdecl _rotl(unsigned int value, int shift)
  5375. {
  5376. unsigned int retval = 0;
  5377. shift &= 0x1f;
  5378. retval = (value << shift) | (value >> (sizeof(int) * CHAR_BIT - shift));
  5379. return retval;
  5380. }
  5381. #endif
  5382. // On 64 bit unix, make the long an int.
  5383. #ifdef BIT64
  5384. #define _lrotl _rotl
  5385. #endif // BIT64
  5386. #if !__has_builtin(_rotl64)
  5387. /*++
  5388. Function:
  5389. _rotl64
  5390. See MSDN doc.
  5391. --*/
  5392. EXTERN_C
  5393. PALIMPORT
  5394. inline
  5395. unsigned long long __cdecl _rotl64(unsigned long long value, int shift)
  5396. {
  5397. unsigned long long retval = 0;
  5398. shift &= 0x3f;
  5399. retval = (value << shift) | (value >> (sizeof(unsigned long long) * CHAR_BIT - shift));
  5400. return retval;
  5401. }
  5402. #endif
  5403. #if !__has_builtin(_rotr)
  5404. /*++
  5405. Function:
  5406. _rotr
  5407. See MSDN doc.
  5408. --*/
  5409. EXTERN_C
  5410. PALIMPORT
  5411. inline
  5412. unsigned int __cdecl _rotr(unsigned int value, int shift)
  5413. {
  5414. unsigned int retval;
  5415. shift &= 0x1f;
  5416. retval = (value >> shift) | (value << (sizeof(int) * CHAR_BIT - shift));
  5417. return retval;
  5418. }
  5419. #endif
  5420. #if !__has_builtin(_rotr64)
  5421. /*++
  5422. Function:
  5423. _rotr64
  5424. See MSDN doc.
  5425. --*/
  5426. EXTERN_C
  5427. PALIMPORT
  5428. inline
  5429. unsigned long long __cdecl _rotr64(unsigned long long value, int shift)
  5430. {
  5431. unsigned long long retval;
  5432. shift &= 0x3f;
  5433. retval = (value >> shift) | (value << (sizeof(unsigned long long) * CHAR_BIT - shift));
  5434. return retval;
  5435. }
  5436. #endif
  5437. PALIMPORT int __cdecl abs(int);
  5438. PALIMPORT double __cdecl fabs(double);
  5439. #ifndef PAL_STDCPP_COMPAT
  5440. PALIMPORT LONG __cdecl labs(LONG);
  5441. PALIMPORT double __cdecl fabs(double);
  5442. #endif // !PAL_STDCPP_COMPAT
  5443. // clang complains if this is declared with __int64
  5444. PALIMPORT long long __cdecl llabs(long long);
  5445. PALIMPORT double __cdecl sqrt(double);
  5446. PALIMPORT double __cdecl log(double);
  5447. PALIMPORT double __cdecl log10(double);
  5448. PALIMPORT double __cdecl exp(double);
  5449. PALIMPORT double __cdecl acos(double);
  5450. PALIMPORT double __cdecl asin(double);
  5451. PALIMPORT double __cdecl atan(double);
  5452. PALIMPORT double __cdecl atan2(double,double);
  5453. PALIMPORT double __cdecl cos(double);
  5454. PALIMPORT double __cdecl sin(double);
  5455. PALIMPORT double __cdecl tan(double);
  5456. PALIMPORT double __cdecl cosh(double);
  5457. PALIMPORT double __cdecl sinh(double);
  5458. PALIMPORT double __cdecl tanh(double);
  5459. PALIMPORT double __cdecl fmod(double, double);
  5460. PALIMPORT float __cdecl fmodf(float, float);
  5461. PALIMPORT double __cdecl floor(double);
  5462. PALIMPORT float __cdecl floorf(float);
  5463. PALIMPORT double __cdecl ceil(double);
  5464. PALIMPORT float __cdecl ceilf(float);
  5465. PALIMPORT float __cdecl fabsf(float);
  5466. PALIMPORT double __cdecl modf(double, double *);
  5467. PALIMPORT float __cdecl modff(float, float *);
  5468. PALIMPORT int __cdecl _finite(double);
  5469. PALIMPORT int __cdecl _isnan(double);
  5470. PALIMPORT double __cdecl _copysign(double, double);
  5471. PALIMPORT float __cdecl _copysignf(float, float);
  5472. #if !defined(PAL_STDCPP_COMPAT) || defined(USING_PAL_STDLIB)
  5473. #ifdef PLATFORM_ACCEPTS_ABS_OVERLOAD
  5474. #ifdef __cplusplus
  5475. extern "C++" {
  5476. inline __int64 abs(__int64 _X) {
  5477. return llabs(_X);
  5478. }
  5479. }
  5480. #endif
  5481. #endif
  5482. PALIMPORT void * __cdecl malloc(size_t);
  5483. PALIMPORT void __cdecl free(void *);
  5484. PALIMPORT void * __cdecl realloc(void *, size_t);
  5485. PALIMPORT char * __cdecl _strdup(const char *);
  5486. #if defined(_MSC_VER)
  5487. #define alloca _alloca
  5488. #elif defined(PLATFORM_UNIX)
  5489. #define _alloca alloca
  5490. #else
  5491. // MingW
  5492. #define _alloca __builtin_alloca
  5493. #define alloca __builtin_alloca
  5494. #endif //_MSC_VER
  5495. #if defined(__GNUC__) && defined(PLATFORM_UNIX)
  5496. // we set -fno-builtin on the command line. This requires that if
  5497. // we use alloca, with either have to call __builtin_alloca, or
  5498. // ensure that the alloca call doesn't happen in code which is
  5499. // modifying the stack (such as "memset (alloca(x), y, z)"
  5500. #define alloca __builtin_alloca
  5501. #endif // __GNUC__
  5502. #endif // !PAL_STDCPP_COMPAT
  5503. PALIMPORT PAL_NORETURN void __cdecl exit(int);
  5504. int __cdecl atexit(void (__cdecl *function)(void));
  5505. PALIMPORT void * __cdecl bsearch(const void *, const void *, size_t, size_t,
  5506. int (__cdecl *)(const void *, const void *));
  5507. PALIMPORT void __cdecl _splitpath(const char *, char *, char *, char *, char *);
  5508. PALIMPORT void __cdecl _wsplitpath(const WCHAR *, WCHAR *, WCHAR *, WCHAR *, WCHAR *);
  5509. PALIMPORT void __cdecl _makepath(char *, const char *, const char *, const char *, const char *);
  5510. PALIMPORT void __cdecl _wmakepath(WCHAR *, const WCHAR *, const WCHAR *, const WCHAR *, const WCHAR *);
  5511. PALIMPORT char * __cdecl _fullpath(char *, const char *, size_t);
  5512. #ifndef PAL_STDCPP_COMPAT
  5513. PALIMPORT time_t __cdecl time(time_t *);
  5514. struct tm {
  5515. int tm_sec; /* seconds after the minute - [0,59] */
  5516. int tm_min; /* minutes after the hour - [0,59] */
  5517. int tm_hour; /* hours since midnight - [0,23] */
  5518. int tm_mday; /* day of the month - [1,31] */
  5519. int tm_mon; /* months since January - [0,11] */
  5520. int tm_year; /* years since 1900 */
  5521. int tm_wday; /* days since Sunday - [0,6] */
  5522. int tm_yday; /* days since January 1 - [0,365] */
  5523. int tm_isdst; /* daylight savings time flag */
  5524. };
  5525. PALIMPORT char * __cdecl ctime(const time_t *);
  5526. #endif // !PAL_STDCPP_COMPAT
  5527. PALIMPORT int __cdecl _open_osfhandle(INT_PTR, int);
  5528. PALIMPORT int __cdecl _close(int);
  5529. PALIMPORT int __cdecl _flushall();
  5530. #ifdef PAL_STDCPP_COMPAT
  5531. struct _PAL_FILE;
  5532. typedef struct _PAL_FILE PAL_FILE;
  5533. #else // PAL_STDCPP_COMPAT
  5534. struct _FILE;
  5535. typedef struct _FILE FILE;
  5536. typedef struct _FILE PAL_FILE;
  5537. #define SEEK_SET 0
  5538. #define SEEK_CUR 1
  5539. #define SEEK_END 2
  5540. /* Locale categories */
  5541. #define LC_ALL 0
  5542. #define LC_COLLATE 1
  5543. #define LC_CTYPE 2
  5544. #define LC_MONETARY 3
  5545. #define LC_NUMERIC 4
  5546. #define LC_TIME 5
  5547. #define _IOFBF 0 /* setvbuf should set fully buffered */
  5548. #define _IOLBF 1 /* setvbuf should set line buffered */
  5549. #define _IONBF 2 /* setvbuf should set unbuffered */
  5550. #endif // PAL_STDCPP_COMPAT
  5551. PALIMPORT int __cdecl PAL_fclose(PAL_FILE *);
  5552. PALIMPORT void __cdecl PAL_setbuf(PAL_FILE *, char*);
  5553. PALIMPORT int __cdecl PAL_fflush(PAL_FILE *);
  5554. PALIMPORT size_t __cdecl PAL_fwrite(const void *, size_t, size_t, PAL_FILE *);
  5555. PALIMPORT size_t __cdecl PAL_fread(void *, size_t, size_t, PAL_FILE *);
  5556. PALIMPORT char * __cdecl PAL_fgets(char *, int, PAL_FILE *);
  5557. PALIMPORT int __cdecl PAL_fputs(const char *, PAL_FILE *);
  5558. PALIMPORT int __cdecl PAL_fputc(int c, PAL_FILE *stream);
  5559. PALIMPORT int __cdecl PAL_putchar(int c);
  5560. PALIMPORT int __cdecl PAL_fprintf(PAL_FILE *, const char *, ...);
  5561. PALIMPORT int __cdecl PAL_vfprintf(PAL_FILE *, const char *, va_list);
  5562. PALIMPORT int __cdecl PAL_fseek(PAL_FILE *, LONG, int);
  5563. PALIMPORT int __cdecl PAL_fgetpos(PAL_FILE *, fpos_t *);
  5564. PALIMPORT int __cdecl PAL_fsetpos(PAL_FILE *, const fpos_t *);
  5565. PALIMPORT LONG __cdecl PAL_ftell(PAL_FILE *);
  5566. PALIMPORT int __cdecl PAL_feof(PAL_FILE *);
  5567. PALIMPORT int __cdecl PAL_ferror(PAL_FILE *);
  5568. PALIMPORT PAL_FILE * __cdecl PAL_fopen(const char *, const char *);
  5569. PALIMPORT char * __cdecl PAL_strtok(char *, const char *);
  5570. PALIMPORT int __cdecl PAL_getc(PAL_FILE *stream);
  5571. PALIMPORT int __cdecl PAL_fgetc(PAL_FILE *stream);
  5572. PALIMPORT int __cdecl PAL_ungetc(int c, PAL_FILE *stream);
  5573. PALIMPORT int __cdecl PAL_setvbuf(PAL_FILE *stream, char *, int, size_t);
  5574. PALIMPORT WCHAR * __cdecl PAL_fgetws(WCHAR *, int, PAL_FILE *);
  5575. PALIMPORT int __cdecl PAL_fwprintf(PAL_FILE *, const WCHAR *, ...);
  5576. PALIMPORT int __cdecl PAL_vfwprintf(PAL_FILE *, const WCHAR *, va_list);
  5577. PALIMPORT int __cdecl PAL_wprintf(const WCHAR*, ...);
  5578. PALIMPORT int __cdecl _getw(PAL_FILE *);
  5579. PALIMPORT int __cdecl _putw(int, PAL_FILE *);
  5580. PALIMPORT PAL_FILE * __cdecl _fdopen(int, const char *);
  5581. PALIMPORT PAL_FILE * __cdecl _wfopen(const WCHAR *, const WCHAR *);
  5582. PALIMPORT PAL_FILE * __cdecl _wfsopen(const WCHAR *, const WCHAR *, int);
  5583. /* Maximum value that can be returned by the rand function. */
  5584. #ifndef PAL_STDCPP_COMPAT
  5585. #define RAND_MAX 0x7fff
  5586. #endif // !PAL_STDCPP_COMPAT
  5587. PALIMPORT int __cdecl rand(void);
  5588. PALIMPORT void __cdecl srand(unsigned int);
  5589. PALIMPORT errno_t __cdecl rand_s(unsigned int*);
  5590. PALIMPORT int __cdecl printf(const char *, ...);
  5591. PALIMPORT int __cdecl vprintf(const char *, va_list);
  5592. #ifdef _MSC_VER
  5593. #define PAL_get_caller _MSC_VER
  5594. #else
  5595. #define PAL_get_caller 0
  5596. #endif
  5597. PALIMPORT PAL_FILE * __cdecl PAL_get_stdout(int caller);
  5598. PALIMPORT PAL_FILE * __cdecl PAL_get_stdin(int caller);
  5599. PALIMPORT PAL_FILE * __cdecl PAL_get_stderr(int caller);
  5600. PALIMPORT int * __cdecl PAL_errno(int caller);
  5601. #if defined(PAL_STDCPP_COMPAT) && !defined(USING_PAL_STDLIB)
  5602. #define PAL_stdout (PAL_get_stdout(PAL_get_caller))
  5603. #define PAL_stdin (PAL_get_stdin(PAL_get_caller))
  5604. #define PAL_stderr (PAL_get_stderr(PAL_get_caller))
  5605. #define PAL_errno (*PAL_errno(PAL_get_caller))
  5606. #else // PAL_STDCPP_COMPAT
  5607. #define stdout (PAL_get_stdout(PAL_get_caller))
  5608. #define stdin (PAL_get_stdin(PAL_get_caller))
  5609. #define stderr (PAL_get_stderr(PAL_get_caller))
  5610. #define errno (*PAL_errno(PAL_get_caller))
  5611. #endif // PAL_STDCPP_COMPAT
  5612. PALIMPORT char * __cdecl getenv(const char *);
  5613. PALIMPORT int __cdecl _putenv(const char *);
  5614. #define ERANGE 34
  5615. /******************* PAL-specific I/O completion port *****************/
  5616. typedef struct _PAL_IOCP_CPU_INFORMATION {
  5617. union {
  5618. FILETIME ftLastRecordedIdleTime;
  5619. FILETIME ftLastRecordedCurrentTime;
  5620. } LastRecordedTime;
  5621. FILETIME ftLastRecordedKernelTime;
  5622. FILETIME ftLastRecordedUserTime;
  5623. } PAL_IOCP_CPU_INFORMATION;
  5624. PALIMPORT
  5625. INT
  5626. PALAPI
  5627. PAL_GetCPUBusyTime(
  5628. IN OUT PAL_IOCP_CPU_INFORMATION *lpPrevCPUInfo);
  5629. /****************PAL Perf functions for PInvoke*********************/
  5630. #if PAL_PERF
  5631. PALIMPORT
  5632. VOID
  5633. PALAPI
  5634. PAL_EnableProcessProfile(VOID);
  5635. PALIMPORT
  5636. VOID
  5637. PALAPI
  5638. PAL_DisableProcessProfile(VOID);
  5639. PALIMPORT
  5640. BOOL
  5641. PALAPI
  5642. PAL_IsProcessProfileEnabled(VOID);
  5643. PALIMPORT
  5644. INT64
  5645. PALAPI
  5646. PAL_GetCpuTickCount(VOID);
  5647. #endif // PAL_PERF
  5648. /******************* PAL side-by-side support ************************/
  5649. #ifdef FEATURE_PAL_SXS
  5650. //
  5651. // Some versions of the PAL support several PALs side-by-side
  5652. // in the process. To avoid those PALs interfering with one
  5653. // another, they need to be told by clients when they are active
  5654. // and when they are not.
  5655. //
  5656. // To avoid performance problems incurred by swapping thread
  5657. // exception ports every time we leave the PAL, there's also
  5658. // the concept of entering/leaving the PAL at its top boundary
  5659. // (entering down/leaving up) or at the bottom boundary
  5660. // (leaving down/entering up).
  5661. typedef enum _PAL_Boundary {
  5662. PAL_BoundaryTop, // closer to main()
  5663. PAL_BoundaryBottom, // closer to execution
  5664. PAL_BoundaryEH, // out-of-band during EH
  5665. PAL_BoundaryMax = PAL_BoundaryEH
  5666. } PAL_Boundary;
  5667. // This function needs to be called on a thread when it enters
  5668. // a region of code that depends on this instance of the PAL
  5669. // in the process, and the current thread may or may not be
  5670. // known to the PAL. This function can fail (for something else
  5671. // than an internal error) if this is the first time that the
  5672. // current thread entered this PAL. Note that PAL_Initialize
  5673. // implies a call to this function. Does not modify LastError.
  5674. PALIMPORT
  5675. DWORD
  5676. PALAPI
  5677. PAL_Enter(PAL_Boundary boundary);
  5678. // Returns TRUE if we this thread has already entered the PAL,
  5679. // returns FALSE if we have not entered the PAL.
  5680. PALIMPORT
  5681. BOOL
  5682. PALAPI
  5683. PAL_HasEntered();
  5684. // Equivalent to PAL_Enter(PAL_BoundaryTop) and is for stub
  5685. // code generation use.
  5686. PALIMPORT
  5687. DWORD
  5688. PALAPI
  5689. PAL_EnterTop();
  5690. // This function needs to be called on a thread when it enters
  5691. // a region of code that depends on this instance of the PAL
  5692. // in the process, and the current thread is already known to
  5693. // the PAL. Does not modify LastError.
  5694. PALIMPORT
  5695. VOID
  5696. PALAPI
  5697. PAL_Reenter(PAL_Boundary boundary);
  5698. // This function needs to be called on a thread when it leaves
  5699. // a region of code that depends on this instance of the PAL
  5700. // in the process. Does not modify LastError.
  5701. PALIMPORT
  5702. VOID
  5703. PALAPI
  5704. PAL_Leave(PAL_Boundary boundary);
  5705. // This function is equivalent to PAL_Leave(PAL_BoundaryBottom)
  5706. // and is available to limit the creation of stub code.
  5707. PALIMPORT
  5708. VOID
  5709. PALAPI
  5710. PAL_LeaveBottom();
  5711. // This function is equivalent to PAL_Leave(PAL_BoundaryTop)
  5712. // and is available to limit the creation of stub code.
  5713. PALIMPORT
  5714. VOID
  5715. PALAPI
  5716. PAL_LeaveTop();
  5717. #ifdef __cplusplus
  5718. //
  5719. // A holder to enter the PAL for a specific region of code.
  5720. // Previously, we must have been executing outside the PAL
  5721. // (unless fEnter is set to FALSE).
  5722. //
  5723. class PAL_EnterHolder
  5724. {
  5725. private:
  5726. BOOL m_fEntered;
  5727. DWORD m_palError;
  5728. public:
  5729. PAL_EnterHolder(BOOL fEnter = TRUE) : m_palError(ERROR_SUCCESS)
  5730. {
  5731. if (fEnter)
  5732. {
  5733. m_palError = PAL_Enter(PAL_BoundaryTop);
  5734. m_fEntered = m_palError == ERROR_SUCCESS;
  5735. }
  5736. else
  5737. {
  5738. m_fEntered = FALSE;
  5739. }
  5740. }
  5741. ~PAL_EnterHolder()
  5742. {
  5743. if (m_fEntered)
  5744. {
  5745. PAL_Leave(PAL_BoundaryTop);
  5746. }
  5747. }
  5748. DWORD GetError()
  5749. {
  5750. return m_palError;
  5751. }
  5752. void SuppressRelease()
  5753. {
  5754. // Used to avoid calling PAL_Leave() when
  5755. // another code path will explicitly do so.
  5756. m_fEntered = FALSE;
  5757. }
  5758. };
  5759. class PAL_LeaveHolder
  5760. {
  5761. public:
  5762. PAL_LeaveHolder()
  5763. {
  5764. PAL_Leave(PAL_BoundaryBottom);
  5765. }
  5766. ~PAL_LeaveHolder()
  5767. {
  5768. PAL_Reenter(PAL_BoundaryBottom);
  5769. }
  5770. };
  5771. #endif // __cplusplus
  5772. #else // FEATURE_PAL_SXS
  5773. #define PAL_Enter(boundary) ERROR_SUCCESS
  5774. #define PAL_Reenter(boundary)
  5775. #define PAL_Leave(boundary)
  5776. #ifdef __cplusplus
  5777. class PAL_EnterHolder {
  5778. public:
  5779. // using constructor to suppress the "unused variable" warnings
  5780. PAL_EnterHolder() {}
  5781. };
  5782. class PAL_LeaveHolder {
  5783. public:
  5784. // using constructor to suppress the "unused variable" warnings
  5785. PAL_LeaveHolder() {}
  5786. };
  5787. #endif // __cplusplus
  5788. #endif // FEATURE_PAL_SXS
  5789. #define EXCEPTION_CONTINUE_SEARCH 0
  5790. #define EXCEPTION_EXECUTE_HANDLER 1
  5791. #define EXCEPTION_CONTINUE_EXECUTION -1
  5792. // Platform-specific library naming
  5793. //
  5794. #ifdef PLATFORM_UNIX
  5795. #ifdef __APPLE__
  5796. #define MAKEDLLNAME_W(name) u"lib" name u".dylib"
  5797. #define MAKEDLLNAME_A(name) "lib" name ".dylib"
  5798. #elif defined(_AIX)
  5799. #define MAKEDLLNAME_W(name) L"lib" name L".a"
  5800. #define MAKEDLLNAME_A(name) "lib" name ".a"
  5801. #elif defined(__hppa__) || defined(_IA64_)
  5802. #define MAKEDLLNAME_W(name) L"lib" name L".sl"
  5803. #define MAKEDLLNAME_A(name) "lib" name ".sl"
  5804. #else
  5805. #define MAKEDLLNAME_W(name) u"lib" name u".so"
  5806. #define MAKEDLLNAME_A(name) "lib" name ".so"
  5807. #endif
  5808. #else
  5809. #define MAKEDLLNAME_W(name) name L".dll"
  5810. #define MAKEDLLNAME_A(name) name ".dll"
  5811. #endif
  5812. #ifdef UNICODE
  5813. #define MAKEDLLNAME(x) MAKEDLLNAME_W(x)
  5814. #else
  5815. #define MAKEDLLNAME(x) MAKEDLLNAME_A(x)
  5816. #endif
  5817. #define PAL_SHLIB_PREFIX "lib"
  5818. #if __APPLE__
  5819. #define PAL_SHLIB_SUFFIX ".dylib"
  5820. #elif _AIX
  5821. #define PAL_SHLIB_SUFFIX ".a"
  5822. #elif _HPUX_
  5823. #define PAL_SHLIB_SUFFIX ".sl"
  5824. #else
  5825. #define PAL_SHLIB_SUFFIX ".so"
  5826. #endif
  5827. #define DBG_EXCEPTION_HANDLED ((DWORD )0x00010001L)
  5828. #define DBG_CONTINUE ((DWORD )0x00010002L)
  5829. #define DBG_EXCEPTION_NOT_HANDLED ((DWORD )0x80010001L)
  5830. #define DBG_TERMINATE_THREAD ((DWORD )0x40010003L)
  5831. #define DBG_TERMINATE_PROCESS ((DWORD )0x40010004L)
  5832. #define DBG_CONTROL_C ((DWORD )0x40010005L)
  5833. #define DBG_RIPEXCEPTION ((DWORD )0x40010007L)
  5834. #define DBG_CONTROL_BREAK ((DWORD )0x40010008L)
  5835. #define DBG_COMMAND_EXCEPTION ((DWORD )0x40010009L)
  5836. #define STATUS_USER_APC ((DWORD )0x000000C0L)
  5837. #define STATUS_GUARD_PAGE_VIOLATION ((DWORD )0x80000001L)
  5838. #define STATUS_DATATYPE_MISALIGNMENT ((DWORD )0x80000002L)
  5839. #define STATUS_BREAKPOINT ((DWORD )0x80000003L)
  5840. #define STATUS_SINGLE_STEP ((DWORD )0x80000004L)
  5841. #define STATUS_LONGJUMP ((DWORD )0x80000026L)
  5842. #define STATUS_UNWIND_CONSOLIDATE ((DWORD )0x80000029L)
  5843. #define STATUS_ACCESS_VIOLATION ((DWORD )0xC0000005L)
  5844. #define STATUS_IN_PAGE_ERROR ((DWORD )0xC0000006L)
  5845. #define STATUS_INVALID_HANDLE ((DWORD )0xC0000008L)
  5846. #define STATUS_NO_MEMORY ((DWORD )0xC0000017L)
  5847. #define STATUS_ILLEGAL_INSTRUCTION ((DWORD )0xC000001DL)
  5848. #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD )0xC0000025L)
  5849. #define STATUS_INVALID_DISPOSITION ((DWORD )0xC0000026L)
  5850. #define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD )0xC000008CL)
  5851. #define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD )0xC000008DL)
  5852. #define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD )0xC000008EL)
  5853. #define STATUS_FLOAT_INEXACT_RESULT ((DWORD )0xC000008FL)
  5854. #define STATUS_FLOAT_INVALID_OPERATION ((DWORD )0xC0000090L)
  5855. #define STATUS_FLOAT_OVERFLOW ((DWORD )0xC0000091L)
  5856. #define STATUS_FLOAT_STACK_CHECK ((DWORD )0xC0000092L)
  5857. #define STATUS_FLOAT_UNDERFLOW ((DWORD )0xC0000093L)
  5858. #define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD )0xC0000094L)
  5859. #define STATUS_INTEGER_OVERFLOW ((DWORD )0xC0000095L)
  5860. #define STATUS_PRIVILEGED_INSTRUCTION ((DWORD )0xC0000096L)
  5861. #define STATUS_STACK_OVERFLOW ((DWORD )0xC00000FDL)
  5862. #define STATUS_CONTROL_C_EXIT ((DWORD )0xC000013AL)
  5863. #define WAIT_IO_COMPLETION STATUS_USER_APC
  5864. #define EXCEPTION_ACCESS_VIOLATION STATUS_ACCESS_VIOLATION
  5865. #define EXCEPTION_DATATYPE_MISALIGNMENT STATUS_DATATYPE_MISALIGNMENT
  5866. #define EXCEPTION_BREAKPOINT STATUS_BREAKPOINT
  5867. #define EXCEPTION_SINGLE_STEP STATUS_SINGLE_STEP
  5868. #define EXCEPTION_ARRAY_BOUNDS_EXCEEDED STATUS_ARRAY_BOUNDS_EXCEEDED
  5869. #define EXCEPTION_FLT_DENORMAL_OPERAND STATUS_FLOAT_DENORMAL_OPERAND
  5870. #define EXCEPTION_FLT_DIVIDE_BY_ZERO STATUS_FLOAT_DIVIDE_BY_ZERO
  5871. #define EXCEPTION_FLT_INEXACT_RESULT STATUS_FLOAT_INEXACT_RESULT
  5872. #define EXCEPTION_FLT_INVALID_OPERATION STATUS_FLOAT_INVALID_OPERATION
  5873. #define EXCEPTION_FLT_OVERFLOW STATUS_FLOAT_OVERFLOW
  5874. #define EXCEPTION_FLT_STACK_CHECK STATUS_FLOAT_STACK_CHECK
  5875. #define EXCEPTION_FLT_UNDERFLOW STATUS_FLOAT_UNDERFLOW
  5876. #define EXCEPTION_INT_DIVIDE_BY_ZERO STATUS_INTEGER_DIVIDE_BY_ZERO
  5877. #define EXCEPTION_INT_OVERFLOW STATUS_INTEGER_OVERFLOW
  5878. #define EXCEPTION_PRIV_INSTRUCTION STATUS_PRIVILEGED_INSTRUCTION
  5879. #define EXCEPTION_IN_PAGE_ERROR STATUS_IN_PAGE_ERROR
  5880. #define EXCEPTION_ILLEGAL_INSTRUCTION STATUS_ILLEGAL_INSTRUCTION
  5881. #define EXCEPTION_NONCONTINUABLE_EXCEPTION STATUS_NONCONTINUABLE_EXCEPTION
  5882. #define EXCEPTION_STACK_OVERFLOW STATUS_STACK_OVERFLOW
  5883. #define EXCEPTION_INVALID_DISPOSITION STATUS_INVALID_DISPOSITION
  5884. #define EXCEPTION_GUARD_PAGE STATUS_GUARD_PAGE_VIOLATION
  5885. #define EXCEPTION_INVALID_HANDLE STATUS_INVALID_HANDLE
  5886. #define CONTROL_C_EXIT STATUS_CONTROL_C_EXIT
  5887. /* These are from the <FCNTL.H> file in windows.
  5888. They are needed for _open_osfhandle.*/
  5889. #define _O_RDONLY 0x0000
  5890. #define _O_APPEND 0x0008
  5891. #define _O_TEXT 0x4000
  5892. #define _O_BINARY 0x8000
  5893. ULONG_PTR __stdcall GetCurrentSP();
  5894. // xplat-todo: implement me
  5895. #define IsProcessorFeaturePresent(x) false
  5896. #if defined(_ARM_)
  5897. #define _ARM_BARRIER_SY 0xF
  5898. #define _InstructionSynchronizationBarrier() __isb(_ARM_BARRIER_SY)
  5899. #endif
  5900. #ifndef MAXUINT16
  5901. #define MAXUINT16 ((unsigned short)-1)
  5902. #endif
  5903. #ifndef MAXUINT8
  5904. #define MAXUINT8 ((unsigned char)-1)
  5905. #endif
  5906. #ifdef __cplusplus
  5907. }
  5908. #include "cclock.hpp"
  5909. #endif
  5910. #endif // __PAL_H__