選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

MessageSnifferRestorer2_1.nsi 314KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511
  1. !verbose 2
  2. !define TEMP1 $R0 ;Temp variable
  3. !define SNIFFER_SERVER_SPECIFIER "V3.2.1" ; This is the ending of the product specific server file.... not the default Server.exe file.
  4. ; MessageSnifferRestorer1_1_1.nsi
  5. ;
  6. ; This script produces an included installer file that is packed inside the MessageSniffer Installer utility.
  7. ; It is in charge of installing fresh files, and for restoring from an older pre-existing directory.
  8. ;--------------------------------
  9. ; The name of the installer
  10. Name "Message Sniffer Install/Restore Utility 1_0"
  11. ; The file to write
  12. OutFile "Restorer.exe"
  13. ; End word searching subroutine vars.
  14. ; Standard vars for the license page.
  15. LicenseText "Approve License Agreement:" ; title
  16. LicenseData "License.txt" ; pointer to set the target of the license file.
  17. VAR /GLOBAL SNFServerInstallDir ; Root to the $INSTDIR. ## ERROR... this note should read ROOT to the platform that is USING sniffer... ##.... confirm this.
  18. Var /GLOBAL LicenseID ; Holds user entered License ID.
  19. Var /GLOBAL Authentication ; Holds user entered Authentication ID
  20. Var /GLOBAL InstallerCompletedRestore ; A onetime bit flag that determines if the installer needs to jump to the restore success screen or
  21. ; move on into the License screen.
  22. Var /GLOBAL OpenGBUIgnoreFileOnClose ; Flag for determining if I should open GBUdbIgnoreList.txt on exit of installer.
  23. Var /GLOBAL HasStickyPots ; Flag for running the email entry list.
  24. Var /GLOBAL UseDetectedRulebase ; Flag for skipping download of huge rulebase if you have one existing.
  25. Var /GLOBAL DownloadFailed ; $DownloadFailed This Variable declared in on init and defaulted to "0".
  26. Var /GLOBAL AUTO_UPDATE_ONOFF_FLAG ; This is the flag to turn on or off the automatic upload file feature in the snfmdplugin.xml file
  27. Var /GLOBAL RetainExistingSettings ; flag for later logic to copy config files into new install folder.
  28. Var /GLOBAL CommandLineParameters ; flag to hold parameters send on the command line to the Restorer.exe program.
  29. Var /Global shortInstallPath ; used to shorten the pathnames for the variables for output.
  30. #################################################
  31. Var /GLOBAL localINSTDIR ; used in subs like editglobalCFG and editMXGuard.ini to hold the local
  32. Var /GLOBAL localSERVDIR ; and the intended install paths.
  33. Var /GLOBAL registryTempData ; tempvar to read in from registry for that purpose.
  34. #################################################
  35. #################################################
  36. ## These variables used for File management functions and for Get Time
  37. Var OUT1
  38. Var OUT2
  39. Var OUT3
  40. Var OUT4
  41. Var OUT5
  42. Var OUT6
  43. Var OUT7
  44. ; end File Managment subroutine vars.
  45. ########################
  46. ## Vars for the License and Authentication Display Screen
  47. VAR testInputLength
  48. Var EDITLicense
  49. Var EDITAuthentication
  50. Var CHECKBOX
  51. ########################
  52. ## Vars for the AlphaNumerical Test Function
  53. VAR /GLOBAL AlphanumericalTestString ; Holds the definition of all alpha numerical digits that are acceptable for the License and the Authentication String..
  54. VAR /GLOBAL AlphaNumericsSourceString ; local SourceString to test all char components.
  55. VAR /GLOBAL AlphaNumericalTestChar ; local working char
  56. VAR /GLOBAL AlphaNumericalResult ; 1 if ok, 0 if failed .
  57. VAR /GLOBAL AlphaNumericalSSLen ; local length counter
  58. VAR /GLOBAL SNF2Check ; local variable for holding the result of the snf2check call.
  59. ########################################################################################################################################################
  60. ## ADDINGPLATFORM ## 0 The block of variables below are used to point and source files that are being handled by the rollback function,
  61. ## but that need special handling. Its easier to be explicit so the code is readable. If you are going to need to hijack the stomping of a file
  62. ## during rollback and strip/replace data rather than replace/delete the entire file, then you will need to define all these items.
  63. # Vars used to determine the direction of edit functions.
  64. VAR /GLOBAL healFromOldFile ; used to flag putting stuff back.
  65. VAR /GLOBAL collectedArchiveData ; store these lines, collected from the file.
  66. VAR /GLOBAL succededAtPlacingArchivedData ; true if we have already written data to the new file.
  67. # Edit or Rollback Vars for GLOBAL.cfg
  68. VAR /GLOBAL archivedGLOBALcfgPath ; file to use for putting stuff back.
  69. VAR /GLOBAL archivedGLOBALcfgFileHandle ; handle for file to read in the stuff to put back....
  70. # Edit or Rollback Vars for MXGuard.ini
  71. VAR /GLOBAL archivedMXGUARDiniPath
  72. VAR /GLOBAL archivedMXGUARDiniFileHandle ; handle for file to read in the stuff to put back....
  73. VAR /GLOBAL archivedMDPluginsDatPath
  74. VAR /GLOBAL archivedMDPluginsDatFileHandle ; handle for file to read in the stuff to put back....
  75. VAR /GLOBAL UnpackedCURLStuff ; This is a flag so that if you go back to the screen that calls the unpacking of curl etc, it doesn't do it again,
  76. ; and continue to add it to the rollback file.
  77. !include "LogicLib.nsh" ; needed for if than do while.
  78. !include "FileFunc.nsh" ; needed for ifFileExists, FileOpen, FileWrite, FileClose
  79. !include "Sections.nsh" ; required.
  80. !include "WinMessages.nsh" ; needed for Word searching of the Plugins.dat file.
  81. !include "WordFunc.nsh" ; needed for Word searching of the Plugins.dat file.
  82. !include "nsDialogs.nsh" ; needed to dynamically handle custom page creation
  83. ; !include "StrRep.nsh"
  84. !insertmacro WordFind ; compiler macro... needed to call before use
  85. !insertmacro un.WordFind ; compiler macro... needed to call before use
  86. !insertmacro WordFind2X ; compiler macro... needed to call before use
  87. !insertmacro un.WordFind2X ; compiler macro... needed to call before use!insertmacro GetParameters
  88. !insertmacro GetOptions
  89. !insertmacro GetTime ; compiler macro... needed to call before use
  90. !insertmacro un.DirState ; compiler macro... needed to call before use
  91. !insertmacro un.GetTime ; compiler macro... needed to call before use
  92. !insertmacro un.GetParent ; replace the moveup directory function.....
  93. ########################################################################################################################################################
  94. ## ADDINGPLATFORM ## Notes 1 If you have completed the adding platform notes in the Installer.exe code, then you are now moving to the next step.
  95. ## The previous efforts were all about deciding WHERE to put the install, and ensuring that its in the right place. The Installer eventually will call
  96. ## the Restorer. A left over dichotomy from the original design. It does serve to break installer presentation/validation from installation. Since the
  97. ## installation is pretty much the same screens for all the platforms.
  98. ## The Installer.exe creates a .txt file that has server location, and the installer location defined. Those two vars are loaded onInit, and begin the
  99. ## install process.
  100. ##
  101. ## For files that are being edited, the automatic restore macro's will copy and manage putting files back, on uninstall. Besure to make the appropriate
  102. ## calls. There is a difference for a file that you are putting in place, vs, a file you are editing in place. It will make sense when you get to the code.
  103. ##
  104. ## Remember that even though you have a lot of conditional execution for all the multiple platforms, only one sniffer installation will be live at a time.
  105. ## If the Restorer detects via the registry that there is an old version, it uninstalls that first. Then will install the new version on the platform that
  106. ## was identified by the Installer.exe via the LocalRoot.txt file.
  107. ##
  108. ## Also, be careful to note when/if you need to put in file adjusting subroutines, that you will need to typically duplicate it for the un.installersubs
  109. ## if you need to manage the un-doing of those edits. Sometimes you won't if you're happy with file replacement of the old file.
  110. ## NSIS requires the namespace for subroutines be different, even though the declared global variables are all valid for the uninstaller as well.
  111. ########################################################################################################################################################
  112. ; Sets up the left side picture on the installer.
  113. AddBrandingImage left 140
  114. !macro BIMAGE IMAGE PARMS
  115. Push $0
  116. GetTempFileName $0
  117. File /oname=$0 "${IMAGE}"
  118. SetBrandingImage ${PARMS} $0
  119. Delete $0
  120. Pop $0
  121. !macroend
  122. ; Request application privileges for Windows Vista
  123. RequestExecutionLevel admin
  124. ;--------------------------------
  125. XPStyle on ; for custom page look.
  126. ; Pages
  127. Page license "nsSetupLicenseTitle" "" ""
  128. Page custom nsDialogsUserName nsDialogsUserName_leave "User name and Authentication:"
  129. Page custom nsDialogsGetRulebase nsDialogsGetRulebase_leave "Downloading Sniffer Rulebase File:"
  130. Page custom nsDialogsWaitingForRulebase "" "Downloading Sniffer Rulebase File:"
  131. Page components "nsSetupcomponentTitle" "" "nsinstfilesExitSub"
  132. Page instfiles "nsSetupInstallationTitle" "" ""
  133. Page custom finishedFilesDisplay finishedFilesQuit
  134. UninstallText "This will uninstall the previous version of Message Sniffer." "Location:"
  135. UninstPage uninstConfirm
  136. #UninstPage custom un.Restore "un.BeSure" ": Restore or Remove"
  137. UninstPage instfiles
  138. Function nsSetupLicenseTitle
  139. !insertmacro BIMAGE "SnifferBanner.bmp" ""
  140. SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:Approve License Before Continuing:"
  141. FunctionEnd
  142. Function nsSetupcomponentTitle
  143. !insertmacro BIMAGE "SnifferBanner.bmp" ""
  144. SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:Adjust Component Selection:"
  145. ;if We haven't been to this screen before, the case flag will be zero. And we leave teh Next button disabled.... otherwise we leave it enabled:
  146. ; Disable the next button until selection is made.
  147. Var /GLOBAL BackButton
  148. GetDlgItem $BackButton $HWNDPARENT 3
  149. EnableWindow $BackButton "0"
  150. FunctionEnd
  151. Function nsSetupInstallationTitle
  152. !insertmacro BIMAGE "SnifferBanner.bmp" ""
  153. SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:Completing Server Installation:"
  154. FunctionEnd
  155. ###############################################################################
  156. ##
  157. ## Open source functional additions from NSIS website. Provided by users.
  158. ##
  159. ##
  160. ###############################################################################
  161. ;----------------------------------------------------------------------------
  162. ; Title : Go to a NSIS page
  163. ; Short Name : RelGotoPage
  164. ; Last Changed : 22/Feb/2005
  165. ; Code Type : Function
  166. ; Code Sub-Type : Special Restricted Call, One-way StrCpy Input
  167. ;----------------------------------------------------------------------------
  168. ; Description : Makes NSIS to go to a specified page relatively from
  169. ; the current page. See this below for more information:
  170. ; "http://nsis.sf.net/wiki/Go to a NSIS page"
  171. ;----------------------------------------------------------------------------
  172. ; Function Call : StrCpy $R9 "(number|X)"
  173. ;
  174. ; - If a number > 0: Goes foward that number of
  175. ; pages. Code of that page will be executed, not
  176. ; returning to this point. If it excess the number of
  177. ; pages that are after that page, it simulates a
  178. ; "Cancel" click.
  179. ;
  180. ; - If a number < 0: Goes back that number of pages.
  181. ; Code of that page will be executed, not returning to
  182. ; this point. If it excess the number of pages that
  183. ; are before that page, it simulates a "Cancel" click.
  184. ;
  185. ; - If X: Simulates a "Cancel" click. Code will go to
  186. ; callback functions, not returning to this point.
  187. ;
  188. ; - If 0: Continues on the same page. Code will still
  189. ; be running after the call.
  190. ;
  191. ; Call RelGotoPage
  192. ;----------------------------------------------------------------------------
  193. ; Author : Diego Pedroso
  194. ; Author Reg. Name : deguix
  195. ;----------------------------------------------------------------------------
  196. Function RelGotoPage
  197. IntCmp $R9 0 0 Move Move
  198. StrCmp $R9 "X" 0 Move
  199. StrCpy $R9 "120"
  200. Move:
  201. SendMessage $HWNDPARENT "0x408" "$R9" ""
  202. FunctionEnd
  203. ###############################################################################
  204. ## This allows me to determine how many times I want to replace instead of it being recursive...
  205. ###############################################################################
  206. Function AdvReplaceInFile
  207. Exch $0 ;file to replace in
  208. Exch
  209. Exch $1 ;number to replace after
  210. Exch
  211. Exch 2
  212. Exch $2 ;replace and onwards
  213. Exch 2
  214. Exch 3
  215. Exch $3 ;replace with
  216. Exch 3
  217. Exch 4
  218. Exch $4 ;to replace
  219. Exch 4
  220. Push $5 ;minus count
  221. Push $6 ;universal
  222. Push $7 ;end string
  223. Push $8 ;left string
  224. Push $9 ;right string
  225. Push $R0 ;file1
  226. Push $R1 ;file2
  227. Push $R2 ;read
  228. Push $R3 ;universal
  229. Push $R4 ;count (onwards)
  230. Push $R5 ;count (after)
  231. Push $R6 ;temp file name
  232. GetTempFileName $R6
  233. FileOpen $R1 $0 r ;file to search in
  234. FileOpen $R0 $R6 w ;temp file
  235. StrLen $R3 $4
  236. StrCpy $R4 -1
  237. StrCpy $R5 -1
  238. loop_read:
  239. ClearErrors
  240. FileRead $R1 $R2 ;read line
  241. IfErrors exit
  242. StrCpy $5 0
  243. StrCpy $7 $R2
  244. loop_filter:
  245. IntOp $5 $5 - 1
  246. StrCpy $6 $7 $R3 $5 ;search
  247. StrCmp $6 "" file_write2
  248. StrCmp $6 $4 0 loop_filter
  249. StrCpy $8 $7 $5 ;left part
  250. IntOp $6 $5 + $R3
  251. IntCmp $6 0 is0 not0
  252. is0:
  253. StrCpy $9 ""
  254. Goto done
  255. not0:
  256. StrCpy $9 $7 "" $6 ;right part
  257. done:
  258. StrCpy $7 $8$3$9 ;re-join
  259. IntOp $R4 $R4 + 1
  260. StrCmp $2 all file_write1
  261. StrCmp $R4 $2 0 file_write2
  262. IntOp $R4 $R4 - 1
  263. IntOp $R5 $R5 + 1
  264. StrCmp $1 all file_write1
  265. StrCmp $R5 $1 0 file_write1
  266. IntOp $R5 $R5 - 1
  267. Goto file_write2
  268. file_write1:
  269. FileWrite $R0 $7 ;write modified line
  270. Goto loop_read
  271. file_write2:
  272. FileWrite $R0 $R2 ;write unmodified line
  273. Goto loop_read
  274. exit:
  275. FileClose $R0
  276. FileClose $R1
  277. SetDetailsPrint none
  278. Delete $0
  279. Rename $R6 $0
  280. Delete $R6
  281. SetDetailsPrint BOTH
  282. Pop $R6
  283. Pop $R5
  284. Pop $R4
  285. Pop $R3
  286. Pop $R2
  287. Pop $R1
  288. Pop $R0
  289. Pop $9
  290. Pop $8
  291. Pop $7
  292. Pop $6
  293. Pop $5
  294. Pop $0
  295. Pop $1
  296. Pop $2
  297. Pop $3
  298. Pop $4
  299. FunctionEnd
  300. ######################### End of Advanced Replace in File.
  301. ###############################################################################
  302. ; The following code is for finding strings inbetween two markers... reguardless of linefeeds.
  303. !macro GetBetween This AndThis In Return
  304. Push "${This}"
  305. Push "${AndThis}"
  306. Push "${In}"
  307. Call GetBetween
  308. Pop "${Return}"
  309. !macroend
  310. !define GetBetween "!insertmacro GetBetween"
  311. !macro un.GetBetween This AndThis In Return
  312. Push "${This}"
  313. Push "${AndThis}"
  314. Push "${In}"
  315. Call un.GetBetween
  316. Pop "${Return}"
  317. !macroend
  318. !define un.GetBetween "!insertmacro un.GetBetween"
  319. Function GetBetween
  320. Exch $R0 ; file ; $R0_Old + AndThis + This + Stack
  321. Exch ; AndThis + $R0_Old + This + Stack
  322. Exch $R1 ; before this (marker 2) ; $R1_Old + $R0_Old + This + Stack
  323. Exch 2 ; This + $R0_Old + $R1_Old + Stack
  324. Exch $R2 ; after this (marker 1) $R2_Old + $R0_OLD + $R1_Old + Stack
  325. Exch 2 ; $R1_Old + $R0_OLD + $R2_Old + Stack
  326. Exch ; $R0_Old + $R1_OLD + $R2_Old + Stack
  327. Exch 2 ; $R2_Old + $R1_OLD + $R0_Old + Stack
  328. Push $R3 ; marker 1 len R3,R2,R1,R0,Stack
  329. Push $R4 ; marker 2 len R4,R3,R2,R1,R0,Stack
  330. Push $R5 ; marker pos R5,R4,R3,R2,R1,R0,Stack
  331. Push $R6 ; file handle R6,R5,R4,R3,R2,R1,R0,Stack
  332. Push $R7 ; current line string R7,R6,R5,R4,R3,R2,R1,R0,Stack
  333. Push $R8 ; current chop R8,R7,R6,R5,R4,R3,R2,R1,R0,Stack
  334. FileOpen $R6 $R0 r
  335. StrLen $R4 $R2
  336. StrLen $R3 $R1
  337. StrCpy $R0 ""
  338. Read1:
  339. ClearErrors
  340. FileRead $R6 $R7
  341. IfErrors Done
  342. StrCpy $R5 0
  343. FindMarker1:
  344. IntOp $R5 $R5 - 1
  345. StrCpy $R8 $R7 $R4 $R5
  346. StrCmp $R8 "" Read1
  347. StrCmp $R8 $R2 0 FindMarker1
  348. IntOp $R5 $R5 + $R4
  349. StrCpy $R7 $R7 "" $R5
  350. StrCpy $R5 -1
  351. Goto FindMarker2
  352. Read2:
  353. ClearErrors
  354. FileRead $R6 $R7
  355. IfErrors Done
  356. StrCpy $R5 -1
  357. FindMarker2:
  358. IntOp $R5 $R5 + 1
  359. StrCpy $R8 $R7 $R3 $R5
  360. StrCmp $R8 "" 0 +3
  361. StrCpy $R0 $R0$R7
  362. Goto Read2
  363. StrCmp $R8 $R1 0 FindMarker2
  364. StrCpy $R7 $R7 $R5
  365. StrCpy $R0 $R0$R7
  366. Done:
  367. FileClose $R6
  368. Pop $R8
  369. Pop $R7
  370. Pop $R6
  371. Pop $R5
  372. Pop $R4
  373. Pop $R3
  374. Pop $R2
  375. Pop $R1
  376. Exch $R0
  377. FunctionEnd
  378. Function un.GetBetween
  379. Exch $R0 ; file ; $R0_Old + AndThis + This + Stack
  380. Exch ; AndThis + $R0_Old + This + Stack
  381. Exch $R1 ; before this (marker 2) ; $R1_Old + $R0_Old + This + Stack
  382. Exch 2 ; This + $R0_Old + $R1_Old + Stack
  383. Exch $R2 ; after this (marker 1) $R2_Old + $R0_OLD + $R1_Old + Stack
  384. Exch 2 ; $R1_Old + $R0_OLD + $R2_Old + Stack
  385. Exch ; $R0_Old + $R1_OLD + $R2_Old + Stack
  386. Exch 2 ; $R2_Old + $R1_OLD + $R0_Old + Stack
  387. Push $R3 ; marker 1 len R3,R2,R1,R0,Stack
  388. Push $R4 ; marker 2 len R4,R3,R2,R1,R0,Stack
  389. Push $R5 ; marker pos R5,R4,R3,R2,R1,R0,Stack
  390. Push $R6 ; file handle R6,R5,R4,R3,R2,R1,R0,Stack
  391. Push $R7 ; current line string R7,R6,R5,R4,R3,R2,R1,R0,Stack
  392. Push $R8 ; current chop R8,R7,R6,R5,R4,R3,R2,R1,R0,Stack
  393. FileOpen $R6 $R0 r
  394. StrLen $R4 $R2
  395. StrLen $R3 $R1
  396. StrCpy $R0 ""
  397. Read1:
  398. ClearErrors
  399. FileRead $R6 $R7
  400. IfErrors Done
  401. StrCpy $R5 0
  402. FindMarker1:
  403. IntOp $R5 $R5 - 1
  404. StrCpy $R8 $R7 $R4 $R5
  405. StrCmp $R8 "" Read1
  406. StrCmp $R8 $R2 0 FindMarker1
  407. IntOp $R5 $R5 + $R4
  408. StrCpy $R7 $R7 "" $R5
  409. StrCpy $R5 -1
  410. Goto FindMarker2
  411. Read2:
  412. ClearErrors
  413. FileRead $R6 $R7
  414. IfErrors Done
  415. StrCpy $R5 -1
  416. FindMarker2:
  417. IntOp $R5 $R5 + 1
  418. StrCpy $R8 $R7 $R3 $R5
  419. StrCmp $R8 "" 0 +3
  420. StrCpy $R0 $R0$R7
  421. Goto Read2
  422. StrCmp $R8 $R1 0 FindMarker2
  423. StrCpy $R7 $R7 $R5
  424. StrCpy $R0 $R0$R7
  425. Done:
  426. FileClose $R6
  427. Pop $R8
  428. Pop $R7
  429. Pop $R6
  430. Pop $R5
  431. Pop $R4
  432. Pop $R3
  433. Pop $R2
  434. Pop $R1
  435. Exch $R0
  436. FunctionEnd
  437. ; End code for FindBetween functions and macro
  438. ##############################
  439. ## ADDINGPLATFORM ## Step 1 ##
  440. ########################################################################################################################################################
  441. ## These functions are callbacks. When you're using the restore macros you can specifiy callbacks if you need to micromanage the restore .
  442. ## The call backs need to take the top item of the stack and put it in the expected global var for the function.
  443. ## then the function will note the state of healFromOldFile, and it knows to find that in the appropriate var specific to the subroutine.
  444. ##
  445. ## Yes, we could have just used the register, but it becomes so damn unreadable and confusing. We're not doing anyting so heavily memory intensive that
  446. ## a few globals affect the performance. But it DOES affect the readability of the code.
  447. ########################################################################################################################################################
  448. ##
  449. ##
  450. ## Sample:
  451. ##
  452. ## Function restoreMYNEWPLATFORM_ConfigFile
  453. ## ; Ok, if you're restoring from the old File we'll need to strip out the relevant section, and put it back without stomping any other changes
  454. ## ; to the MXGuard file.
  455. ## StrCpy $healFromOldFile "1" ; used to flag putting stuff back carefuly versus a complete revert.
  456. ## Exch $0 ; swap the top of the stack with the zero register.
  457. ## StrCpy $archivedMXGUARDiniPath $0 ; Put that in the archivedMYNEWPLATFORMPath var
  458. ## pop $0 ;restore ; put the top of the stack back into the register. ( Its original value. )
  459. ## call editMYNEWPLATFORM_ConfigFile ; call the callback that is expecting to handle $healFromOldFile and $archivedMYNEWPLATFORMPath
  460. ## FunctionEnd
  461. ########################################################################################################################################################
  462. Function restoreMDaemonDAT
  463. ; Ok, if you're restoring from the old Plugins.dat File we'll need to strip out the relevant section,
  464. ; and put it back without stomping any other changes
  465. ; to the Plugins.dat MDaemon file.
  466. StrCpy $healFromOldFile "1" ; used to flag putting stuff back.
  467. Exch $0 ;swap
  468. StrCpy $archivedMDPluginsDatPath $0 ; file to read for stripping SNF OUT and putting stuff back.
  469. pop $0 ;restore
  470. call editMDPluginsFile
  471. StrCpy $healFromOldFile "0" ; clear flag.
  472. FunctionEnd
  473. Function un.restoreMDaemonDAT
  474. ; Ok, if you're restoring from the old Plugins.dat File we'll need to strip out the relevant section,
  475. ; and put it back without stomping any other changes
  476. ; to the Plugins.dat MDaemon file.
  477. StrCpy $healFromOldFile "1" ; used to flag putting stuff back.
  478. Exch $0 ;swap
  479. StrCpy $archivedMDPluginsDatPath $0 ; file to read for stripping SNF OUT and putting stuff back.
  480. pop $0 ;restore
  481. call un.editMDPluginsFile
  482. StrCpy $healFromOldFile "0" ; clear flag.
  483. FunctionEnd
  484. Function restoreMXGuardINI
  485. ; Ok, if you're restoring from the old MXGuardFile we'll need to strip out the relevant section, and put it back without stomping any other changes
  486. ; to the MXGuard file.
  487. StrCpy $healFromOldFile "1" ; used to flag putting stuff back.
  488. Exch $0 ;swap
  489. StrCpy $archivedMDPluginsDatPath $0 ; file to use for putting stuff back.
  490. ;MessageBox MB_OK "INI File archived here:$archivedMXGUARDiniPath"
  491. pop $0 ;restore
  492. call editMXGuardINI
  493. StrCpy $healFromOldFile "0" ; clear flag.
  494. FunctionEnd
  495. Function un.restoreMXGuardINI
  496. ; Ok, if you're restoring from the old MXGuardFile we'll need to strip out the relevant section, and put it back without stomping any other changes
  497. ; to the MXGuard file.
  498. StrCpy $healFromOldFile "1" ; used to flag putting stuff back.
  499. Exch $0 ;swap
  500. StrCpy $archivedMXGUARDiniPath $0 ; file to use for putting stuff back.
  501. ;MessageBox MB_OK "INI File archived here:$archivedMXGUARDiniPath"
  502. pop $0 ;restore
  503. call un.editMXGuardINI
  504. StrCpy $healFromOldFile "0" ; clear flag.
  505. FunctionEnd
  506. Function restoreGLOBALcfg
  507. ; MessageBox MB_OK "Called restoreGLOBALcfg"
  508. ; In order for this to be complete, we need to strip the old file, and insert into the new file.
  509. StrCpy $healFromOldFile "1" ; used to flag putting stuff back.
  510. Exch $0 ;swap
  511. StrCpy $archivedGLOBALcfgPath $0 ; file to use for putting stuff back.
  512. pop $0 ;restore
  513. call editglobalCFG
  514. StrCpy $healFromOldFile "0" ; clear flag.
  515. FunctionEnd
  516. Function un.restoreGLOBALcfg
  517. ; MessageBox MB_OK "Called restoreGLOBALcfg"
  518. ; In order for this to be complete, we need to strip the old file, and insert into the new file.
  519. StrCpy $healFromOldFile "1" ; used to flag putting stuff back.
  520. Exch $0 ;swap
  521. StrCpy $archivedGLOBALcfgPath $0 ; file to use for putting stuff back.
  522. pop $0 ;restore
  523. call un.editglobalCFG
  524. StrCpy $healFromOldFile "0" ; clear flag.
  525. FunctionEnd
  526. Function restoreCONTENTxml
  527. call editContentXML
  528. FunctionEnd
  529. Function un.restoreCONTENTxml
  530. call un.editContentXML
  531. FunctionEnd
  532. Function restoreMINIMIini
  533. ; MessageBox MB_OK "Called restoreMINIMIini"
  534. FunctionEnd
  535. Function un.restoreMINIMIini
  536. ; MessageBox MB_OK "Called restoreMINIMIini"
  537. FunctionEnd
  538. Function restoreXYNTini
  539. ; MessageBox MB_OK "Called restoreXYNTini"
  540. FunctionEnd
  541. Function un.restoreXYNTini
  542. ; MessageBox MB_OK "Called restoreXYNTini"
  543. FunctionEnd
  544. Function restoreGETRULBASEcmd
  545. ; MessageBox MB_OK "Called restoreGETRULBASEcmd"
  546. FunctionEnd
  547. Function un.restoreGETRULBASEcmd
  548. ; MessageBox MB_OK "Called restoreGETRULBASEcmd"
  549. FunctionEnd
  550. #########################################################
  551. Function ResolveFunction
  552. ; This function abstracts a string into a function call. All strings that are known to be used as callbacks with files, need to be defined here
  553. ; as the response for the callback handler. It pushes the callback function name, and the file that the rollback WOULD be overwriting if it
  554. ; were to continue without the callback interrupt.
  555. push $R0 ; stack is $R0 CallbackFunction FilePath Stack
  556. Exch ; stack is CallbackFunction $R0 FilePath Stack
  557. pop $R0 ; stack is $R0 FilePath Stack
  558. push $R1 ; stack is $R1 $R0 FilePath Stack ; thought we might use it but not right now.....
  559. Exch 2 ; stack is FilePath $R0 $R1 Stack
  560. pop $R1 ; stack is $R0 $R1 Stack
  561. ##############################
  562. ## ADDINGPLATFORM ## Step 2 ##
  563. ########################################################################################################################################################
  564. ## Here is how we explicitly define the callback functions. If you NEED to handle the callback, you need to define it here.
  565. ## Sounds wierd but theren's no runtime binding to function vars in NSIS.
  566. ## i.e. You can't read a piece of text and say, call eval($myString)
  567. ## This is the best you can do.
  568. ##
  569. ## Note: If you desire to provide a reference to the file to use as the source, you need to push the file back onto the stack to be retrieved
  570. ## by the Step 1 Restore function.
  571. ${Switch} $R0
  572. ${Case} "restoreMXGuardINI"
  573. push $R1 ; Stack is now MXGuardiniFilePath + $R0 $R1 stack
  574. call restoreMXGuardINI
  575. goto doneResolving
  576. ${Case} "restoreGLOBALcfg"
  577. push $R1 ; Stack is now Global.cfgFilePath + $R0 $R1 stack
  578. call restoreGLOBALcfg ; This function pops for the filepath. Stack is now $R0 $R1 Stack
  579. goto doneResolving
  580. ${Case} "restoreMINIMIini"
  581. call restoreMINIMIini
  582. goto doneResolving
  583. ${Case} "restoreXYNTini"
  584. call restoreXYNTini
  585. goto doneResolving
  586. ${Case} "restoreGETRULBASEcmd"
  587. call restoreGETRULBASEcmd
  588. goto doneResolving
  589. ${Case} "restoreCONTENTxml"
  590. call restoreCONTENTxml
  591. goto doneResolving
  592. ${Case} "restoreMDaemonDAT"
  593. push $R1 ; Stack is now MDaemonDATFILEPATH + stack
  594. call restoreMDaemonDAT
  595. goto doneResolving
  596. ${EndSwitch}
  597. doneResolving:
  598. pop $R0 ;restore
  599. pop $R1 ;restore
  600. FunctionEnd
  601. #########################################################
  602. Function un.ResolveFunction
  603. ; This function abstracts a string into a function call. All strings that are known to be used as callbacks with files, need to be defined here
  604. ; as the response for the callback handler.
  605. push $R0 ; stack is $R0 CallbackFunction FilePath Stack
  606. Exch ; stack is CallbackFunction $R0 FilePath Stack
  607. pop $R0 ; stack is $R0 FilePath Stack
  608. push $R1 ; stack is $R1 $R0 FilePath Stack ; thought we might use it but not right now.....
  609. Exch 2 ; stack is FilePath $R0 $R1 Stack
  610. pop $R1 ; stack is $R0 $R1 Stack
  611. ##############################
  612. ## ADDINGPLATFORM ## Step 2 ##
  613. ########################################################################################################################################################
  614. ## Here is how we explicitly define the callback functions for the uninstaller. If you NEED to handle the callback, you need to define it here.
  615. ## Sounds wierd but theren's no runtime binding to function vars in NSIS.
  616. ## i.e. You can't read a piece of text and say, call eval($myString)
  617. ## This is the best you can do.
  618. ##
  619. ## Note: If you desire to provide a reference to the file to use as the source, you need to push the file back onto the stack to be retrieved
  620. ## by the Step 1 Restore function.
  621. ${Switch} $R0
  622. ${Case} "restoreMXGuardINI"
  623. push $R1 ; Stack is now MXGuardiniFilePath + stack
  624. call un.restoreMXGuardINI
  625. goto doneResolving
  626. ${Case} "restoreGLOBALcfg"
  627. push $R1 ; Stack is now Global.cfgFilePath + stack
  628. call un.restoreGLOBALcfg ; This function pops for the filepath. Stack is now $R0 $R1 Stack
  629. goto doneResolving
  630. ${Case} "restoreMINIMIini"
  631. call un.restoreMINIMIini
  632. goto doneResolving
  633. ${Case} "restoreXYNTini"
  634. call un.restoreXYNTini
  635. goto doneResolving
  636. ${Case} "restoreGETRULBASEcmd"
  637. call un.restoreGETRULBASEcmd
  638. goto doneResolving
  639. ${Case} "restoreCONTENTxml"
  640. call un.restoreCONTENTxml
  641. goto doneResolving
  642. ${Case} "restoreMDaemonDAT"
  643. push $R1 ; Stack is now MDaemonDATFILEPATH + stack
  644. call un.restoreMDaemonDAT
  645. goto doneResolving
  646. ${EndSwitch}
  647. doneResolving:
  648. pop $R0 ;restore
  649. pop $R1 ;restore
  650. FunctionEnd
  651. ########################################################## Utilities For Archiving purposes #################################################33
  652. ##
  653. ## Rollback.nsh - Written By Andrew Wallo for Microneil Research, Arm Research general permissions granted.
  654. ##
  655. ## Reqires the definition of the GetBetween macros.... ( NOTE: The macros shown on the NSIS website have a stack registry error as of Aug 18th 2008)
  656. ## Code was repaired and sent in.
  657. !include "rollback.nsh"
  658. ##################################################### End Utilities for Archiving. #######################################################
  659. ; StrReplace
  660. ; Replaces all ocurrences of a given needle within a haystack with another string
  661. ; Written by dandaman32
  662. Var STR_REPLACE_VAR_0
  663. Var STR_REPLACE_VAR_1
  664. Var STR_REPLACE_VAR_2
  665. Var STR_REPLACE_VAR_3
  666. Var STR_REPLACE_VAR_4
  667. Var STR_REPLACE_VAR_5
  668. Var STR_REPLACE_VAR_6
  669. Var STR_REPLACE_VAR_7
  670. Var STR_REPLACE_VAR_8
  671. Function StrReplace
  672. Exch $STR_REPLACE_VAR_2
  673. Exch 1
  674. Exch $STR_REPLACE_VAR_1
  675. Exch 2
  676. Exch $STR_REPLACE_VAR_0
  677. StrCpy $STR_REPLACE_VAR_3 -1
  678. StrLen $STR_REPLACE_VAR_4 $STR_REPLACE_VAR_1
  679. StrLen $STR_REPLACE_VAR_6 $STR_REPLACE_VAR_0
  680. loop:
  681. IntOp $STR_REPLACE_VAR_3 $STR_REPLACE_VAR_3 + 1
  682. StrCpy $STR_REPLACE_VAR_5 $STR_REPLACE_VAR_0 $STR_REPLACE_VAR_4 $STR_REPLACE_VAR_3
  683. StrCmp $STR_REPLACE_VAR_5 $STR_REPLACE_VAR_1 found
  684. StrCmp $STR_REPLACE_VAR_3 $STR_REPLACE_VAR_6 done
  685. Goto loop
  686. found:
  687. StrCpy $STR_REPLACE_VAR_5 $STR_REPLACE_VAR_0 $STR_REPLACE_VAR_3
  688. IntOp $STR_REPLACE_VAR_8 $STR_REPLACE_VAR_3 + $STR_REPLACE_VAR_4
  689. StrCpy $STR_REPLACE_VAR_7 $STR_REPLACE_VAR_0 "" $STR_REPLACE_VAR_8
  690. StrCpy $STR_REPLACE_VAR_0 $STR_REPLACE_VAR_5$STR_REPLACE_VAR_2$STR_REPLACE_VAR_7
  691. StrLen $STR_REPLACE_VAR_6 $STR_REPLACE_VAR_0
  692. Goto loop
  693. done:
  694. Pop $STR_REPLACE_VAR_1 ; Prevent "invalid opcode" errors and keep the
  695. Pop $STR_REPLACE_VAR_1 ; stack as it was before the function was called
  696. Exch $STR_REPLACE_VAR_0
  697. FunctionEnd
  698. Function un.StrReplace
  699. Exch $STR_REPLACE_VAR_2
  700. Exch 1
  701. Exch $STR_REPLACE_VAR_1
  702. Exch 2
  703. Exch $STR_REPLACE_VAR_0
  704. StrCpy $STR_REPLACE_VAR_3 -1
  705. StrLen $STR_REPLACE_VAR_4 $STR_REPLACE_VAR_1
  706. StrLen $STR_REPLACE_VAR_6 $STR_REPLACE_VAR_0
  707. loop:
  708. IntOp $STR_REPLACE_VAR_3 $STR_REPLACE_VAR_3 + 1
  709. StrCpy $STR_REPLACE_VAR_5 $STR_REPLACE_VAR_0 $STR_REPLACE_VAR_4 $STR_REPLACE_VAR_3
  710. StrCmp $STR_REPLACE_VAR_5 $STR_REPLACE_VAR_1 found
  711. StrCmp $STR_REPLACE_VAR_3 $STR_REPLACE_VAR_6 done
  712. Goto loop
  713. found:
  714. StrCpy $STR_REPLACE_VAR_5 $STR_REPLACE_VAR_0 $STR_REPLACE_VAR_3
  715. IntOp $STR_REPLACE_VAR_8 $STR_REPLACE_VAR_3 + $STR_REPLACE_VAR_4
  716. StrCpy $STR_REPLACE_VAR_7 $STR_REPLACE_VAR_0 "" $STR_REPLACE_VAR_8
  717. StrCpy $STR_REPLACE_VAR_0 $STR_REPLACE_VAR_5$STR_REPLACE_VAR_2$STR_REPLACE_VAR_7
  718. StrLen $STR_REPLACE_VAR_6 $STR_REPLACE_VAR_0
  719. Goto loop
  720. done:
  721. Pop $STR_REPLACE_VAR_1 ; Prevent "invalid opcode" errors and keep the
  722. Pop $STR_REPLACE_VAR_1 ; stack as it was before the function was called
  723. Exch $STR_REPLACE_VAR_0
  724. FunctionEnd
  725. !macro _strReplaceConstructor OUT NEEDLE NEEDLE2 HAYSTACK
  726. Push "${HAYSTACK}"
  727. Push "${NEEDLE}"
  728. Push "${NEEDLE2}"
  729. Call StrReplace
  730. Pop "${OUT}"
  731. !macroend
  732. !macro un._strReplaceConstructor OUT NEEDLE NEEDLE2 HAYSTACK
  733. Push "${HAYSTACK}"
  734. Push "${NEEDLE}"
  735. Push "${NEEDLE2}"
  736. Call un.StrReplace
  737. Pop "${OUT}"
  738. !macroend
  739. !define StrReplace '!insertmacro "_strReplaceConstructor"'
  740. !define un.StrReplace '!insertmacro "un._strReplaceConstructor"'
  741. !macro ReplaceInFile SOURCE_FILE SEARCH_TEXT REPLACEMENT
  742. Push "${SOURCE_FILE}"
  743. Push "${SEARCH_TEXT}"
  744. Push "${REPLACEMENT}"
  745. Call RIF
  746. !macroend
  747. !macro un.ReplaceInFile SOURCE_FILE SEARCH_TEXT REPLACEMENT
  748. Push "${SOURCE_FILE}"
  749. Push "${SEARCH_TEXT}"
  750. Push "${REPLACEMENT}"
  751. Call un.RIF
  752. !macroend
  753. Function RIF
  754. ClearErrors ; want to be a newborn
  755. Exch $0 ; REPLACEMENT
  756. Exch
  757. Exch $1 ; SEARCH_TEXT
  758. Exch 2
  759. Exch $2 ; SOURCE_FILE
  760. Push $R0 ; SOURCE_FILE file handle
  761. Push $R1 ; temporary file handle
  762. Push $R2 ; unique temporary file name
  763. Push $R3 ; a line to sar/save
  764. Push $R4 ; shift puffer
  765. IfFileExists $2 +1 RIF_error ; knock-knock
  766. FileOpen $R0 $2 "r" ; open the door
  767. GetTempFileName $R2 ; who's new?
  768. FileOpen $R1 $R2 "w" ; the escape, please!
  769. RIF_loop: ; round'n'round we go
  770. FileRead $R0 $R3 ; read one line
  771. IfErrors RIF_leaveloop ; enough is enough
  772. RIF_sar: ; sar - search and replace
  773. Push "$R3" ; (hair)stack
  774. Push "$1" ; needle
  775. Push "$0" ; blood
  776. Call StrReplace ; do the bartwalk
  777. StrCpy $R4 "$R3" ; remember previous state
  778. Pop $R3 ; gimme s.th. back in return!
  779. StrCmp "$R3" "$R4" +1 RIF_sar ; loop, might change again!
  780. FileWrite $R1 "$R3" ; save the newbie
  781. Goto RIF_loop ; gimme more
  782. RIF_leaveloop: ; over'n'out, Sir!
  783. FileClose $R1 ; S'rry, Ma'am - clos'n now
  784. FileClose $R0 ; me 2
  785. ;MessageBox MB_OK "Files Closed. $R1 , $R0"
  786. Delete "$2.old" ; go away, Sire
  787. ;MessageBox MB_OK "Deleete $2.old"
  788. Rename "$2" "$2.old" ; step aside, Ma'am
  789. ;MessageBox MB_OK "Rename $2 to $2.old"
  790. Rename "$R2" "$2" ; hi, baby!
  791. ;MessageBox MB_OK "Rename $R2 to $2"
  792. Delete "$2.old"
  793. ClearErrors ; now i AM a newborn
  794. Goto RIF_out ; out'n'away
  795. RIF_error: ; ups - s.th. went wrong...
  796. SetErrors ; ...so cry, boy!
  797. RIF_out: ; your wardrobe?
  798. Pop $R4
  799. Pop $R3
  800. Pop $R2
  801. Pop $R1
  802. Pop $R0
  803. Pop $2
  804. Pop $0
  805. Pop $1
  806. FunctionEnd
  807. Function un.RIF
  808. ClearErrors ; want to be a newborn
  809. Exch $0 ; REPLACEMENT
  810. Exch
  811. Exch $1 ; SEARCH_TEXT
  812. Exch 2
  813. Exch $2 ; SOURCE_FILE
  814. Push $R0 ; SOURCE_FILE file handle
  815. Push $R1 ; temporary file handle
  816. Push $R2 ; unique temporary file name
  817. Push $R3 ; a line to sar/save
  818. Push $R4 ; shift puffer
  819. IfFileExists $2 +1 RIF_error ; knock-knock
  820. FileOpen $R0 $2 "r" ; open the door
  821. GetTempFileName $R2 ; who's new?
  822. FileOpen $R1 $R2 "w" ; the escape, please!
  823. RIF_loop: ; round'n'round we go
  824. FileRead $R0 $R3 ; read one line
  825. IfErrors RIF_leaveloop ; enough is enough
  826. RIF_sar: ; sar - search and replace
  827. Push "$R3" ; (hair)stack
  828. Push "$1" ; needle
  829. Push "$0" ; blood
  830. Call un.StrReplace ; do the bartwalk
  831. StrCpy $R4 "$R3" ; remember previous state
  832. Pop $R3 ; gimme s.th. back in return!
  833. StrCmp "$R3" "$R4" +1 RIF_sar ; loop, might change again!
  834. FileWrite $R1 "$R3" ; save the newbie
  835. Goto RIF_loop ; gimme more
  836. RIF_leaveloop: ; over'n'out, Sir!
  837. FileClose $R1 ; S'rry, Ma'am - clos'n now
  838. FileClose $R0 ; me 2
  839. ;MessageBox MB_OK "Files Closed. $R1 , $R0"
  840. Delete "$2.old" ; go away, Sire
  841. ;MessageBox MB_OK "Deleete $2.old"
  842. Rename "$2" "$2.old" ; step aside, Ma'am
  843. ;MessageBox MB_OK "Rename $2 to $2.old"
  844. Rename "$R2" "$2" ; hi, baby!
  845. ;MessageBox MB_OK "Rename $R2 to $2"
  846. Delete "$2.old"
  847. ClearErrors ; now i AM a newborn
  848. Goto RIF_out ; out'n'away
  849. RIF_error: ; ups - s.th. went wrong...
  850. SetErrors ; ...so cry, boy!
  851. RIF_out: ; your wardrobe?
  852. Pop $R4
  853. Pop $R3
  854. Pop $R2
  855. Pop $R1
  856. Pop $R0
  857. Pop $2
  858. Pop $0
  859. Pop $1
  860. FunctionEnd
  861. Function nsinstfilesExitSub
  862. ;MessageBox MB_OK "I'm out."
  863. FunctionEnd
  864. #################################################################################################################################
  865. # This function tests to ensure that all the chars in its SourceString are included in its TestString.
  866. # Its output is in the AlphaNumericalResult which, as long as its > 0 indicates the validity of all chars in the string.
  867. # It depends on the WORDFIND library.
  868. Function TestAlphaNumerics
  869. ; load the alphanumerical test string
  870. StrCpy $AlphanumericalTestString "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz" ; for alphnumeric, char must be in here.
  871. ; Now test the words.
  872. ; Seed the testChar...
  873. StrCpy $AlphaNumericalTestChar $AlphaNumericsSourceString 1 0 ; take the first character from the working License string.
  874. ; ${WordFind} $AlphanumericalTestString $AlphaNumericalTestChar "*" $AlphaNumericalResult ; This will return in #R0 the number of times the delimiter was found in teh testString.
  875. TestAlphaNumerics_getchar: ${WordFind} $AlphanumericalTestString $AlphaNumericalTestChar "E+1{" $AlphaNumericalResult
  876. IfErrors AlphaNumerics_notfound AlphaNumerics_found
  877. AlphaNumerics_found: ; things are ok, handle next char.
  878. StrLen $AlphaNumericalSSLen $AlphaNumericsSourceString ; get the current length of the source string
  879. ${IF} $AlphaNumericalSSLen > 1 ; if we don't have any more chars... then we quit, otherwize continue.
  880. StrCpy $AlphaNumericsSourceString $AlphaNumericsSourceString "" 1 ; trim off the leading char.
  881. StrCpy $AlphaNumericalTestChar $AlphaNumericsSourceString 1 0 ; strip off the next one to test.
  882. Goto TestAlphaNumerics_getchar
  883. ${ELSE}
  884. ; exit test
  885. StrCpy $AlphaNumericalResult "1"
  886. return
  887. ${ENDIF}
  888. AlphaNumerics_notfound:
  889. ;MessageBox MB_OK "$AlphaNumericsSourceString,$AlphaNumericalTestChar,$AlphaNumericalResult"
  890. StrCpy $AlphaNumericalResult "0"
  891. return
  892. FunctionEnd
  893. Function nsDialogsUserName
  894. SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:Enter License and Authentication:"
  895. !insertmacro BIMAGE "SnifferBannerIdentity.bmp" ""
  896. nsDialogs::Create /NOUNLOAD 1018
  897. Pop $0
  898. ${NSD_CreateLabel} 0 20 60% 8u "Enter License (8 Chars)"
  899. Pop $0
  900. ${NSD_CreateText} 0 40 40% 12u $LicenseID
  901. Pop $EDITLicense
  902. GetFunctionAddress $0 OnChangeLicense
  903. nsDialogs::OnChange /NOUNLOAD $EDITLicense $0
  904. ${NSD_CreateLabel} 50% 20 60% 8u "Enter Authentication (16 Chars)"
  905. Pop $0
  906. ${NSD_CreateText} 50% 40 40% 12u $Authentication
  907. Pop $EDITAuthentication
  908. GetFunctionAddress $0 OnChangeAuthentication
  909. nsDialogs::OnChange /NOUNLOAD $EDITAuthentication $0
  910. ${NSD_CreateCheckbox} 0 50u 100% 16u " Select this if you have email accounts that intentionally receive spam.$\n ( Will automatically open file for editing email accounts after install. )"
  911. Pop $CHECKBOX
  912. GetFunctionAddress $0 OnCheckStickyPot
  913. nsDialogs::OnClick /NOUNLOAD $CHECKBOX $0
  914. ${NSD_CreateCheckbox} 0 80u 100% 16u " Select if you have gateways that need to be entered into the Ignore List.$\n ( Will automatically open file for editing Gateway IP's after install. )"
  915. Pop $CHECKBOX
  916. GetFunctionAddress $0 OnCheckboxGateway
  917. nsDialogs::OnClick /NOUNLOAD $CHECKBOX $0
  918. Var /GLOBAL HelpMeButton
  919. ${NSD_CreateButton} 0 110u 100% 16u "Help! I don't have a license key. Do you have a webpage to help me?"
  920. Pop $HelpMeButton
  921. ${NSD_OnClick} $HelpMeButton OpenHelpMePage
  922. nsDialogs::Show
  923. FunctionEnd
  924. Function OpenHelpMePage
  925. ExecShell "open" "http://www.armresearch.com/products/trial.jsp"
  926. FunctionEnd
  927. Function nsDialogsUserName_leave
  928. StrLen $testInputLength $LicenseID;
  929. ; test to ensure that we have a non-zero string length;
  930. ${If} $testInputLength != "9" ; Include one for the nullterminator. i.e. an 8char LicsenseID will read 9 for string lenght.
  931. MessageBox MB_OK "License Keys are eight characters in length. Please double check your License Key."
  932. abort
  933. ${EndIf}
  934. StrLen $testInputLength $Authentication;
  935. ; test to ensure that we have a non-zero string length;
  936. ${If} $testInputLength != "17" ; Include one for the nullterminator. i.e. an 16char LicsenseID will read 17 for string lenght.
  937. MessageBox MB_OK "Authentication Keys are sixteen characters in length. Please double check your Authentication String."
  938. abort
  939. ${EndIf}
  940. ; TODO TODO TODO : When a user hits back, the page loads unmarked checkboxes.... it doesnt' remember state. It should.
  941. ; LICENSE ID ALPHANUMERIAL TEST
  942. ; Now test to ensure that we are using alpha numerical characters not puncutation etc.
  943. StrCpy $AlphaNumericsSourceString $LicenseID 8 0 ; Copy the License String into a working string to be abused. Trim null terminator char for comparsion.
  944. Call TestAlphaNumerics ; test the string.
  945. StrCmp $AlphaNumericalResult "1" nextTest nextLine ; skip command if equal, otherwise fall through and abort.
  946. nextline:
  947. MessageBox MB_OK "License and Authentication strings must be alphanumerical. A-Z,a-Z,0-9"
  948. abort ; advance one command if not equal, and fail.
  949. ; system ok.
  950. nextTest: StrCpy $AlphaNumericsSourceString $Authentication 16 0 ; Copy the License String into a working string to be abused. Trim null terminator char for comparsion.
  951. Call TestAlphaNumerics ; test the string.
  952. StrCmp $AlphaNumericalResult "1" done nextAbort ; skip command if equal, otherwise fall through and abort.
  953. nextAbort:
  954. MessageBox MB_OK "License and Authentication strings must be alphanumerical. A-Z,a-Z,0-9"
  955. abort ; advance one command if not equal, and fail.
  956. ; system ok.
  957. done:
  958. ; clear flag for use rulebase
  959. StrCpy $UseDetectedRulebase "0"
  960. FunctionEnd
  961. Function nsDialogsGetRulebase
  962. !insertmacro BIMAGE "SnifferBannerFindingRulebase.bmp" ""
  963. SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:Finding Rulebase:"
  964. ;MessageBox MB_OK "inside nsDialogsGetRulebase"
  965. nsDialogs::Create /NOUNLOAD 1018
  966. Pop $0
  967. ; Ensure to set the global test variable to zero
  968. StrCpy $SNF2Check "1" ; Default to fail. If we come back to this page it will reset and test again anyway. That is good.
  969. ; This holds the result of the sniffer2check test.
  970. ; And clear the checkbox for reusing the rulebase too.
  971. StrCpy $UseDetectedRulebase "0" ; clear flag for use rulebase
  972. ; Set output path to the installation directory.
  973. SetOutPath $INSTDIR ;
  974. ; NOTE installing and unpacking the getRulebase.cmd was moved here to keep the relevant actions together. It was commented out in other places.
  975. ; ALL versions and installs must fire this page. So its version safe. Even if you don't download a new rulebase.
  976. StrCmp $UnpackedCURLStuff "1" SkipUnpacking 0 ; Don't continue to add this to the rollback file, if you are backing up in the user screens.
  977. ; Ok because of either retaining settings, or resetting settings,
  978. ; we'll either put the existing rulebase file back later ( In the section for handling this feature, or we'll
  979. ; leave this one in place. Either way, it doesn't hurt to just stomp it here and resolve the retain-settings later.
  980. ${Install_with_RollbackControl} "getRulebase.cmd" "" "" ; Before with callback... but not needed... file level ok for GetRulebase... "restoreGETRULBASEcmd" ""
  981. # If you delete it prior to installing with rollback control, it won't have a copy in rollback
  982. ;ifFileExists "curl.exe" 0 +2
  983. ;Delete "curl.exe" ; reinstore the newer version.
  984. ${Install_with_RollbackControl} "curl.exe" "" ""
  985. ;ifFileExists "gzip.exe" 0 +2
  986. ;Delete "gzip.exe"
  987. ;${Install_with_RollbackControl} "gzip.exe" "" ""
  988. ;ifFileExists "snf2Check.exe" 0 +2
  989. ;Delete "snf2Check.exe"
  990. ${Install_with_RollbackControl} "snf2Check.exe" "" ""
  991. StrCpy $UnpackedCURLStuff "1"
  992. SkipUnpacking:
  993. Call editGetRulebase ; Finds Opens edits the Path License and Authentication strings in the getRulebase file.
  994. ; This is done because you need it set propelry for executing the rulebase download.
  995. Var /GLOBAL DownloadText
  996. Var /GLOBAL NextButton
  997. ; If this is an upgrade from a previous state, we just copy the rulebase and we move on to the next page.
  998. ; Now find all the folders in the Archive Direcotry
  999. ;GetDlgItem $NextButton $HWNDPARENT 1
  1000. ;EnableWindow $NextButton "0"
  1001. ifFileExists "$INSTDIR\$LicenseID.snf" 0 NothingDetected
  1002. ; Default is to use the detected rulebase, so set the flag.
  1003. StrCpy $UseDetectedRulebase "1"
  1004. ${NSD_CreateLabel} 0 0 25% 30 "Rulebase detected."
  1005. Pop $0
  1006. ${NSD_CreateCheckbox} 100 00 15 20 ""
  1007. Pop $CHECKBOX
  1008. ${NSD_CreateLabel} 120 0 65% 40 "Check if you want to download the newest rulebase.$\nLeave unchecked to use the existing rulebase."
  1009. Pop $0
  1010. GetFunctionAddress $8 OnUseDetected
  1011. nsDialogs::OnClick /NOUNLOAD $CHECKBOX $8
  1012. Goto EndDetectionLabel
  1013. NothingDetected:
  1014. ${NSD_CreateLabel} 0 0 100% 15 "No Rulebase detected. { Download is required. }"
  1015. Pop $0
  1016. EndDetectionLabel:
  1017. ${NSD_CreateLabel} 0 35 100% 60 "Please be patient as this may take a few minutes depending upon your bandwidth.$\n$\nIf the installer cannot download a rulebase, your LicenseID or Authentication may$\nbe entered incorrectly."
  1018. Pop $0
  1019. ${NSD_CreateLabel} 0 100 100% 90 "Note: You may be so eager to use Message Sniffer that you have attempted to install it before our server could compile your first rulebase. $\n$\nIf this happens just wait a few minutes or check your email for the update notification to inform you that your first rulebase has been created. Thank you."
  1020. Pop $0
  1021. nsDialogs::Show
  1022. FunctionEnd
  1023. Function OnUseDetected
  1024. Pop $0 # HWND
  1025. ${IF} $UseDetectedRulebase == 1
  1026. StrCpy $UseDetectedRulebase "0";
  1027. ${ELSE}
  1028. StrCpy $UseDetectedRulebase "1";
  1029. ${ENDIF}
  1030. FunctionEnd
  1031. Function nsDialogsGetRulebase_leave
  1032. !insertmacro BIMAGE "SnifferBannerFindingRulebase.bmp" ""
  1033. SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:Downloading Rulebase:"
  1034. ;MessageBox MB_OK "inside nsDialogsGetRulebase"
  1035. ;MessageBox MB_OK "inside nsDialogsGetRulebase_leave"
  1036. ; Ok we're leaving but if we're using an existing rulebase, we still should test the sniffer2check test for the new authentication string..
  1037. StrCmp $UseDetectedRulebase "1" 0 GetTheRulebaseNow
  1038. ; Ok, well do the sniffer2check for concurrance....
  1039. ;ExecWait 'snf2check.exe $LicenseID.snf "$Authentication"' $9
  1040. ;pop $9
  1041. nsExec::ExecToLog '"$INSTDIR\snf2check.exe" "$LicenseID.snf" "$Authentication"'
  1042. pop $0
  1043. ;DetailPrint "Snf2Check Reports:$0$\r$\n"
  1044. ;MessageBox MB_OK "Snf2Check Reports:$0$\r$\n"
  1045. StrCpy $SNF2Check $0 ; Set this to determine the message for the next screen, or if we just pass through. ( 0 result is clean )
  1046. Return
  1047. GetTheRulebaseNow:
  1048. ; Else download and report.
  1049. ;nsDialogs::Create /NOUNLOAD 1018
  1050. ;Pop $0
  1051. ${NSD_CreateLabel} 0 180 100% 30 "Starting download attempt... Approximate Size of Rulebase: 20Mb"
  1052. Pop $DownloadText
  1053. StrCpy $DownloadFailed "0"
  1054. ; Now grey out the next until we complete or fail....
  1055. GetDlgItem $NextButton $HWNDPARENT 1
  1056. EnableWindow $NextButton "0"
  1057. Var /GLOBAL TempBatchFileHandle
  1058. Var /GLOBAL ThreadHandleExitCode
  1059. ifFileExists "$INSTDIR\$LicenseID.new" 0 +2 ; test for file.
  1060. Delete "$INSTDIR\$LicenseID.new" ; clean up old file.
  1061. ifFileExists "$INSTDIR\curlresult.txt" 0 +2 ; test for file.
  1062. Delete "$INSTDIR\curlresult.txt" ; clean up old file.
  1063. ;Curl new file.
  1064. FileOpen $TempBatchFileHandle "$INSTDIR\TempGetCall.cmd" w ; Removing the conditional on download. We ALWAYS want it to download. -z $LicenseID.snf
  1065. ;FileWrite $TempBatchFileHandle "wget -a wgetreport.txt http://www.sortmonster.net/Sniffer/Updates/$LicenseID.snf -O $LicenseID.new.gz --header=Accept-Encoding:gzip --http-user=sniffer --http-passwd=ki11sp8m"
  1066. FileWrite $TempBatchFileHandle 'curl -v "http://www.sortmonster.net/Sniffer/Updates/$LicenseID.snf" -o $LicenseID.new -S -R -H "Accept-Encoding:gzip" --compressed -u sniffer:ki11sp8m 2>> "$INSTDIR\curlresult.txt"'
  1067. FileClose $TempBatchFileHandle
  1068. ;ExecDos::Exec /NOUNLOAD /ASYNC 'curl -v "http://www.sortmonster.net/Sniffer/Updates/$LicenseID.snf" -o $LicenseID.new -S -R -H "Accept-Encoding:gzip" --compressed -u sniffer:ki11sp8m 2>> "$INSTDIR\curlresult.txt"'
  1069. ExecDos::Exec /NOUNLOAD /ASYNC "$INSTDIR\TempGetCall.cmd"
  1070. Pop $ThreadHandleExitCode ; exit code
  1071. ;ExecDos::Exec /NOUNLOAD /ASYNC "TempGetCall.cmd" "" ""
  1072. ;Pop $ThreadHandleExitCode ; exit code
  1073. Var /GLOBAL progressTextFile ; the handle to the file log 'wgetreport.txt'
  1074. Var /GLOBAL progressTextLine ; line handle
  1075. Var /GLOBAL progressLastLine ; last line string....
  1076. ifFileExists "$INSTDIR\TEMPcurlresult.txt" 0 +2
  1077. Delete "$INSTDIR\TEMPcurlresult.txt" ; Delete it.
  1078. LoopAgain:
  1079. Sleep 2000
  1080. ifFileExists "$INSTDIR\curlresult.txt" 0 CheckForExit ; Ok, if the file doesn't exist you can't get parameters.
  1081. CopyFiles /SILENT "$INSTDIR\curlresult.txt" "$INSTDIR\TEMPcurlresult.txt"
  1082. FileOpen $progressTextFile "$INSTDIR\TEMPcurlresult.txt" r
  1083. findEndOfFile:
  1084. FileSeek $progressTextFile -63 "END"
  1085. FileRead $progressTextFile $progressTextLine
  1086. StrCpy $progressLastLine $progressTextLine 6 0
  1087. ;FileRead $progressTextFile $progressTextLine [256]
  1088. ;ifErrors +3 0 ; If there are errors then we found the end, print the next to last line of text.
  1089. ; StrCpy $progressLastLine $progressTextLine "" -20 ; otherwise save next to last line, and loop again.
  1090. ; Goto findEndOfFile ; go back for more....
  1091. ; Now change the label on the screen.
  1092. SendMessage $DownloadText ${WM_SETTEXT} 0 "STR:File Progress: $progressLastLine byte"
  1093. ShowWindow $DownloadText ${SW_SHOW} ; show it.
  1094. FileClose $progressTextFile ; Close the working file.
  1095. Delete "$INSTDIR\TEMPcurlresult.txt"
  1096. CheckForExit:
  1097. ExecDos::isdone /NOUNLOAD $ThreadHandleExitCode
  1098. Pop $R9 ; keep stack clean
  1099. StrCmp $R9 1 0 LoopAgain
  1100. ; This will handle cleanup and failure.
  1101. Delete "$INSTDIR\curlresult.txt"
  1102. ;StrCmp $9 "error" CleanupMess 0
  1103. ;ifFileExists "$INSTDIR\$LicenseID.new.gz" 0 CleanupMess
  1104. ; ExecWait "gzip -d -f $LicenseID.new.gz" $9
  1105. ;nsExec::Exec 'gzip -d -f "$INSTDIR\$LicenseID.new.gz"'
  1106. ;pop $9
  1107. ;StrCmp $9 "1" CleanupMess 0 ; success is reported with a '0', failed-with-errors with a '1'.
  1108. ;ExecWait '"$INSTDIR\snf2check.exe" $LicenseID.new "$Authentication"' $0
  1109. nsExec::Exec '"$INSTDIR\snf2check.exe" $LicenseID.new "$Authentication"'
  1110. pop $0
  1111. VAR /GLOBAL snf2CheckERROR
  1112. ;MessageBox MB_OK "Snf2Check Reports:$0$\r$\n"
  1113. ${Switch} $0
  1114. ${Case} "0"
  1115. StrCpy $snf2CheckERROR " SNFClient successfuly connected with SNFServer."
  1116. Goto EndSNF2CheckTest
  1117. ${Case} "65"
  1118. StrCpy $snf2CheckERROR " {65} ERROR_CMDLINE. SNF was called improperly."
  1119. Goto EndSNF2CheckTest
  1120. ${Case} "66"
  1121. StrCpy $snf2CheckERROR " {66}ERROR_LOGFILE Cannot open logfile."
  1122. Goto EndSNF2CheckTest
  1123. ${Case} "67"
  1124. StrCpy $snf2CheckERROR " {67} ERROR RULE FILE. Cannot open rules file."
  1125. Goto EndSNF2CheckTest
  1126. ${Case} "68"
  1127. StrCpy $snf2CheckERROR " {68} ERROR_RULE_DATA Cannot create pattern matrix."
  1128. Goto EndSNF2CheckTest
  1129. ${Case} "69"
  1130. StrCpy $snf2CheckERROR " {69} ERROR_MSG_FILE Cannot open message file."
  1131. Goto EndSNF2CheckTest
  1132. ${Case} "70"
  1133. StrCpy $snf2CheckERROR " {70} ERROR_ALLOCATION Allocation error during processing."
  1134. Goto EndSNF2CheckTest
  1135. ${Case} "71"
  1136. StrCpy $snf2CheckERROR " {71} ERROR_BAD_MATRIX Pattern trace went out of range."
  1137. Goto EndSNF2CheckTest
  1138. ${Case} "72"
  1139. StrCpy $snf2CheckERROR " {72} ERROR_MAX_EVALS The maximum number of evaluation paths was exceeded."
  1140. Goto EndSNF2CheckTest
  1141. ${Case} "73"
  1142. StrCpy $snf2CheckERROR " {73} ERROR_RULE_AUTH The rulebase file did not authenticate properly."
  1143. Goto EndSNF2CheckTest
  1144. ${Case} "99"
  1145. StrCpy $snf2CheckERROR " {99} ERROR_UNKNOWN"
  1146. Goto EndSNF2CheckTest
  1147. ${EndSwitch}
  1148. EndSNF2CheckTest:
  1149. StrCpy $SNF2Check $0 ; set up flag for retaining the result fo this test.
  1150. StrCmp $SNF2Check "0" 0 CleanupMess
  1151. ;if errorlevel not zero goto CLEANUP
  1152. ifFileExists "$INSTDIR\$LicenseID.old" 0 +2
  1153. Delete "$INSTDIR\$LicenseID.old"
  1154. ifFileExists "$INSTDIR\$LicenseID.snf" 0 +2
  1155. rename "$INSTDIR\$LicenseID.snf" "$INSTDIR\$LicenseID.old"
  1156. ifFileExists "$INSTDIR\$LicenseID.new" 0 +2
  1157. rename "$INSTDIR\$LicenseID.new" "$INSTDIR\$LicenseID.snf"
  1158. ifFileExists "$INSTDIR\UpdateReady.txt" 0 +2
  1159. delete "$INSTDIR\UpdateReady.txt"
  1160. ifFileExists "$INSTDIR\UpdateReady.lck" 0 +2
  1161. delete "$INSTDIR\UpdateReady.lck"
  1162. ; Now trigger the system to enable the AutoUpdater to pull the next rulebase.
  1163. VAR /GLOBAL UpdateRulebaseHandle
  1164. FileOpen $UpdateRulebaseHandle "$INSTDIR\UpdateReady.txt" w
  1165. FileWrite $UpdateRulebaseHandle " "
  1166. FileClose $UpdateRulebaseHandle
  1167. StrCpy $DownloadFailed "0"
  1168. Delete "$INSTDIR\TempGetCall.cmd"
  1169. Return
  1170. CleanupMess:
  1171. ifFileExists "$INSTDIR\TempGetCall.cmd" 0 +2
  1172. Delete "$INSTDIR\TempGetCall.cmd"
  1173. ifFileExists "$INSTDIR\UpdateReady.txt" 0 +2
  1174. delete "$INSTDIR\UpdateReady.txt"
  1175. ifFileExists "$INSTDIR\TempGetCall.cmd" 0 +2
  1176. delete "$INSTDIR\TempGetCall.cmd"
  1177. ifFileExists "$INSTDIR\$LicenseID.new" 0 +2
  1178. delete "$INSTDIR\$LicenseID.new"
  1179. ifFileExists "$INSTDIR\UpdateReady.lck" 0 +2
  1180. delete "$INSTDIR\UpdateReady.lck"
  1181. ifFileExists "$INSTDIR\$LicenseID.new.gz" 0 +2
  1182. delete "$INSTDIR\$LicenseID.new.gz"
  1183. StrCpy $DownloadFailed "1"
  1184. Return
  1185. FunctionEnd
  1186. ## Unload the plugin so that the progress bar can be deleted!
  1187. ;Function .onGUIEnd
  1188. ; ;RealProgress::Unload
  1189. ;FunctionEnd
  1190. Function nsDialogsWaitingForRulebase
  1191. !insertmacro BIMAGE "SnifferBannerFindingRulebase.bmp" ""
  1192. ;MessageBox MB_OK "inside nsDialogsWaitingForRulebase"
  1193. SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:Downloading Rulebase:"
  1194. nsDialogs::Create /NOUNLOAD 1018
  1195. Pop $0
  1196. StrCmp $UseDetectedRulebase "1" 0 NotifyAll ; If we're not downloading, possibley just skip to components...
  1197. StrCmp $SNF2Check "0" 0 NofityAuthFailure ; but only if it passes authentication test.... opps... notify and refuse passage.
  1198. ;MessageBox MB_OK "SNF2Check: $SNF2Check " ; debug....
  1199. Return ; only get to here if all is good... this will progress to next page.
  1200. NotifyAll:
  1201. ; $DownloadFailed This Variable declared in ONinit and defaulted to "0".
  1202. ; If this is an upgrade from a previous state, we just copy the rulebase and we move on to the next page.
  1203. ; Now find all the folders in the Archive Direcotry
  1204. StrCmp $DownloadFailed "1" 0 AllowNext ; if the download HAS failed we must display a screen. We may also jump in here if the auth fails.
  1205. Var /GLOBAL ErrorMessage
  1206. StrCpy $ErrorMessage "Your rulebase file could not be authenticated:$\n$\n $snf2CheckERROR$\n$\n"
  1207. StrCpy $ErrorMessage "$ErrorMessage If the installer cannot download / update your rulebase then:$\n$\n"
  1208. StrCpy $ErrorMessage "$ErrorMessage * Your License ID and/or Authentication may be entered incorrectly.$\n Check your entries on the previous screen.$\n$\n"
  1209. StrCpy $ErrorMessage "$ErrorMessage * If you are new to Message Sniffer your rulebase might not be ready yet.$\n Check your email for your first update notification email.$\n"
  1210. StrCmp $SNF2Check "0" 0 NofityAuthFailure ; if snf2check was zero and error was because of something else...give normal notification.
  1211. ;GetDlgItem $NextButton $HWNDPARENT 1 ; stop next button from working
  1212. ;EnableWindow $NextButton "0"
  1213. ;${NSD_CreateLabel} 0 70 100% 65 "Download Failed: $snf2CheckERROR Check your License ID and try again. If you have not yet received an update notification, your rulebase file might not be ready."
  1214. ;Pop $DownloadText
  1215. ;nsDialogs::Show
  1216. ;Return
  1217. NofityAuthFailure: ; failed because of snf2check authroization failure.
  1218. GetDlgItem $NextButton $HWNDPARENT 1 ; stop next button from working
  1219. EnableWindow $NextButton "0"
  1220. ;${NSD_CreateLabel} 0 70 100% 65 "Your rulebase file could not be authenticated: $snf2CheckERROR Please go back and check your License Id and Authentication string and try again. If you do find a typo in your authentication string, try to use the existing rulebase you have downloaded before trying to download a second copy. Snf2check will probably authenticate correctly."
  1221. ${NSD_CreateLabel} 0 30 100% 130 $ErrorMessage
  1222. Pop $DownloadText
  1223. nsDialogs::Show
  1224. Return
  1225. AllowNext: ; only get to here if download didn't fail.
  1226. ${NSD_CreateLabel} 0 70 100% 30 "The download of your Message Sniffer Rulebase completed successfully. You may proceed with the rest of the installation."
  1227. Pop $DownloadText
  1228. nsDialogs::Show
  1229. return
  1230. FunctionEnd
  1231. Function OnChangeLicense
  1232. Pop $0 # HWND
  1233. System::Call user32::GetWindowText(i$EDITLicense,t.r0,i${NSIS_MAX_STRLEN})
  1234. StrCpy $LicenseID $0 ; Set the global variable to the new license ID.
  1235. FunctionEnd
  1236. Function OnChangeAuthentication
  1237. Pop $0 # HWND
  1238. System::Call user32::GetWindowText(i$EDITAuthentication,t.r0,i${NSIS_MAX_STRLEN})
  1239. StrCpy $Authentication $0 ; Set the global variable to the new authentication ID.
  1240. FunctionEnd
  1241. Function OnCheckStickyPot
  1242. Pop $0 # HWND
  1243. ${IF} $HasStickyPots == 1
  1244. StrCpy $HasStickyPots "0";
  1245. ${ELSE}
  1246. StrCpy $HasStickyPots "1";
  1247. ${ENDIF}
  1248. FunctionEnd
  1249. Function OnCheckboxGateway
  1250. Pop $0 # HWND
  1251. ${IF} $OpenGBUIgnoreFileOnClose == "1"
  1252. StrCpy $OpenGBUIgnoreFileOnClose "0";
  1253. ${ELSE}
  1254. StrCpy $OpenGBUIgnoreFileOnClose "1";
  1255. ${ENDIF}
  1256. FunctionEnd
  1257. Function editLicenseFile
  1258. ; In the case of a re-install we don't to stomp the file.. ( Though we did already in the file write... but we'll do this
  1259. ; as a good premtive measure.
  1260. IfFileExists "$INSTDIR\identity.xml" filedoesexist repairfile ; Skip to second instruction if it doesnt' exist.
  1261. repairfile:
  1262. ; This shouldn't happen unless you corrupt or fail in the install of the file from the packed installer.....
  1263. ClearErrors
  1264. FileOpen $0 "$INSTDIR\identity.xml" w
  1265. IfErrors FailedIdentityRepair ; otherwise clear for attempting to recreate.
  1266. FileWrite $0 "<snf><identity licenseid='$LicenseID' authentication='$Authentication'/></snf>" ;
  1267. FileClose $0
  1268. ; MessageBox MB_OK "Installer successfully rebuilt the identity.xml file."
  1269. Goto done
  1270. filedoesexist:
  1271. ; now rename and write new one.
  1272. Delete "$INSTDIR\identity.xml" ; Always stomp with new ID.
  1273. ; because this will always be operating with a newly upacked file, that is there only if the user
  1274. ; wants to do a manual install.
  1275. ; This will only be called after the archived folder has been moved,
  1276. ; and new files are installed. So stomp the identity.xml file so its ok.
  1277. ClearErrors
  1278. FileOpen $0 "$INSTDIR\identity.xml" w
  1279. IfErrors FailedIdentityArchive ; otherwise clear for writing
  1280. FileWrite $0 "<snf><identity licenseid='$LicenseID' authentication='$Authentication'/></snf>" ;
  1281. FileClose $0
  1282. Goto done
  1283. FailedIdentityRepair:
  1284. MessageBox MB_OK "Installer seemed unable to repair identity.xml file. Perhaps the file is locked. Please attempt to create this file manually with the xml contents: <snf><identity licenseid='$LicenseID' authentication='$Authentication'/></snf>"
  1285. Goto done
  1286. FailedIdentityArchive:
  1287. MessageBox MB_OK "Installer seemed unable to archive identity.xml file. Perhaps the file is locked. Please attempt to re/create this file manually with the xml contents: <snf><identity licenseid='$LicenseID' authentication='$Authentication'/></snf>"
  1288. done:
  1289. FunctionEnd
  1290. Function finishedFilesDisplay
  1291. FunctionEND
  1292. Function finishedFilesQuit
  1293. Quit ; Don't want to continue to the next page.
  1294. FunctionEND
  1295. Function finishedRestoreDisplay
  1296. Var /GLOBAL CancelButton
  1297. GetDlgItem $CancelButton $HWNDPARENT 2
  1298. EnableWindow $CancelButton "0"
  1299. StrCmp $InstallerCompletedRestore "1" 0 doneSplashScreen
  1300. nsDialogs::Create /NOUNLOAD 1018
  1301. Pop $0
  1302. Var /GLOBAL IMAGECTL
  1303. Var /GLOBAL IMAGE
  1304. nsDialogs::CreateItem /NOUNLOAD STATIC "" ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_BITMAP} 25 60 0 64 64
  1305. Pop $IMAGECTL
  1306. SetOutPath $INSTDIR
  1307. File "SuccessInstall.bmp"
  1308. StrCpy $0 "$INSTDIR\SuccessInstall.bmp"
  1309. System::Call 'user32::LoadImage(i 0, t r0, i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_LOADFROMFILE}) i.s'
  1310. Pop $IMAGE
  1311. SendMessage $IMAGECTL ${STM_SETIMAGE} ${IMAGE_BITMAP} $IMAGE
  1312. nsDialogs::Show
  1313. doneSplashScreen:
  1314. return
  1315. FunctionEND
  1316. Function finishedRestoreQuit
  1317. StrCmp $InstallerCompletedRestore "1" 0 +2
  1318. Quit ; The Installer is done.
  1319. Return
  1320. FunctionEND
  1321. !macro handleShortPath Result_Path Source_Path
  1322. Push "${Source_Path}"
  1323. Push "${Result_Path}"
  1324. Call handleShortFilePath
  1325. Pop "${Result_Path}"
  1326. !macroend
  1327. !define handleShortPath "!insertmacro handleShortPath"
  1328. Function handleShortFilePath
  1329. Var /Global local_sourcePath ; where we put the result
  1330. Var /Global local_resultPath ; what we work from
  1331. Var /Global local_searchResults ; WordFind temp var.
  1332. pop $local_resultPath
  1333. pop $local_sourcePath
  1334. ${WordFind} $local_sourcePath " " "E+1}" $local_searchResults
  1335. ifErrors 0 FoundSpaceInString ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  1336. push $local_sourcePath
  1337. return
  1338. FoundSpaceInString:
  1339. GetFullPathName /SHORT $local_resultPath $local_sourcePath
  1340. push $local_resultPath
  1341. return
  1342. FunctionEnd
  1343. !macro un.handleShortPath unResult_Path unSource_Path
  1344. Push "${unSource_Path}"
  1345. Push "${unResult_Path}"
  1346. Call un.handleShortFilePath
  1347. Pop "${unResult_Path}"
  1348. !macroend
  1349. !define un.handleShortPath "!insertmacro un.handleShortPath"
  1350. Function un.handleShortFilePath
  1351. Var /Global unlocal_sourcePath ; where we put the result
  1352. Var /Global unlocal_resultPath ; what we work from
  1353. Var /Global unlocal_searchResults ; WordFind temp var.
  1354. pop $unlocal_resultPath
  1355. pop $unlocal_sourcePath
  1356. ${un.WordFind} $unlocal_sourcePath " " "E+1}" $unlocal_searchResults
  1357. ifErrors 0 unFoundSpaceInString ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  1358. push $unlocal_sourcePath
  1359. return
  1360. unFoundSpaceInString:
  1361. GetFullPathName /SHORT $unlocal_resultPath $unlocal_sourcePath
  1362. push $unlocal_resultPath
  1363. return
  1364. FunctionEnd
  1365. ## This edits the service init file
  1366. ## so that when you call the XYNTService it will
  1367. ## Properly boot and start the SNFServer.
  1368. Function editXYNTServiceINI
  1369. ;MessageBox MB_OK "Installing XYNTSErviceINI"
  1370. ; Just easier to write it all out.
  1371. Var /GLOBAL iniHandle
  1372. FileOpen $iniHandle "$INSTDIR\XYNTService.ini" w
  1373. FileWrite $iniHandle "[Settings]$\r$\n"
  1374. FileWrite $iniHandle "ProcCount=1$\r$\n" ;
  1375. FileWrite $iniHandle "ServiceName=SNFService$\r$\n"
  1376. FileWrite $iniHandle "CheckProcessSeconds = 30$\r$\n"
  1377. FileWrite $iniHandle "[Process0]$\r$\n"
  1378. Var /GLOBAL ShortPathTempVar ; use this to hold the Short Windows Progr~1 path references...
  1379. ;GetFullPathName /SHORT $ShortPathTempVar $INSTDIR
  1380. ${handleShortPath} $ShortPathTempVar $INSTDIR
  1381. ;FileWrite $iniHandle "CommandLine = '$\"$INSTDIR\SNFServer.exe$\" $\"$INSTDIR\snf_engine.xml$\"'$\r$\n"
  1382. ;FileWrite $iniHandle "WorkingDir= $\"$INSTDIR$\"$\r$\n"
  1383. FileWrite $iniHandle "CommandLine = '$\"$ShortPathTempVar\SNFServer.exe$\" $\"$ShortPathTempVar\snf_engine.xml$\"'$\r$\n"
  1384. FileWrite $iniHandle "WorkingDir= $\"$ShortPathTempVar$\"$\r$\n"
  1385. FileWrite $iniHandle "PauseStart= 100$\r$\n"
  1386. FileWrite $iniHandle "PauseEnd= 100$\r$\n"
  1387. FileWrite $iniHandle "UserInterface = No$\r$\n"
  1388. FileWrite $iniHandle "Restart = Yes$\r$\n"
  1389. ;FileWrite $iniHandle "UserName =$\r$\n"
  1390. ;FileWrite $iniHandle "Domain =$\r$\n"
  1391. ;FileWrite $iniHandle "Password =$\r$\n"
  1392. FileClose $iniHandle
  1393. FunctionEnd
  1394. ##############################
  1395. ## ADDINGPLATFORM ## Step 3 ##
  1396. ########################################################################################################################################################
  1397. ## If the new platform requires complex service handeling, you can group that here to simplify. Don't forget to support the uninstaller.
  1398. ##
  1399. Function restartMDaemon
  1400. nsExec::Exec "NET STOP MDaemon" "" SH_HIDE
  1401. nsExec::Exec "NET START MDaemon" "" SH_HIDE
  1402. FunctionEND
  1403. Function un.restartMDaemon
  1404. nsExec::Exec "NET STOP MDaemon" "" SH_HIDE
  1405. nsExec::Exec "NET START MDaemon" "" SH_HIDE
  1406. FunctionEND
  1407. Function stopMDaemon
  1408. nsExec::Exec "NET STOP MDaemon" "" SH_HIDE
  1409. FunctionEnd
  1410. Function un.stopMDaemon
  1411. nsExec::Exec "NET STOP MDaemon" "" SH_HIDE
  1412. FunctionEnd
  1413. Function un.stopSNFServer
  1414. nsExec::Exec "NET STOP SNFService" "" SH_HIDE
  1415. FunctionEnd
  1416. Function stopSNFServer
  1417. nsExec::Exec "NET STOP SNFService" "" SH_HIDE
  1418. FunctionEnd
  1419. Function startSNFServer
  1420. ;MessageBox MB_OK "Entering Telemetry generator"
  1421. ;nsExec::Exec "NET START SNFService > '$INSTDIR\Telemetry.txt'" "" SH_HIDE
  1422. nsExec::Exec "NET START SNFService" "" SH_HIDE
  1423. pop $0
  1424. StrCmp $0 "0" 0 +2
  1425. return
  1426. ;MessageBox MB_OK "Staring SNFService return code:$0"
  1427. FunctionEnd
  1428. ## Call the XYNTService to start.
  1429. Function startXYNTService
  1430. ; presumes that the .ini file is in the same location.
  1431. nsExec::Exec "XYNTService -r" "" SH_HIDE
  1432. FunctionEnd
  1433. Function stopXYNTService
  1434. ; presumes that the .ini file is in the same location.
  1435. nsExec::Exec "XYNTService -k" "" SH_HIDE
  1436. FunctionEnd
  1437. Function un.UninstallXYNTService
  1438. ; This uninstalls the XYNTService
  1439. nsExec::Exec "NET STOP SNFService" "" SH_HIDE
  1440. nsExec::Exec "XYNTService -u" "" SH_HIDE
  1441. FunctionEnd
  1442. Function installXYNTService
  1443. # Function is deprecated because of the FILE Handling managed elsewhere in the flow... and of the new rollback scheme for files....
  1444. Call stopSNFServer ; if it there it will stop it.
  1445. Call stopXYNTService ; if its there, stop it.
  1446. ;MessageBox MB_OK "Starting SNFService"
  1447. SetOutPath $INSTDIR
  1448. File "XYNTService.exe" ; Unpack the files.
  1449. File "XYNTService.ini"
  1450. ; First properly handle the ini file.
  1451. call editXYNTServiceINI
  1452. nsExec::Exec "XYNTService -u" "" SH_HIDE ; uninstall it if it exists....
  1453. ; presumes that the .ini file is in the same location.
  1454. nsExec::Exec "XYNTService -i" "" SH_HIDE ; install XYNTService
  1455. nsExec::Exec "XYNTService -r" "" SH_HIDE ; restart XYNTService
  1456. call startSNFServer ;nsExec::Exec "NET START SNFService" "" SH_HIDE
  1457. Return
  1458. FunctionEnd
  1459. Function removeShortcuts
  1460. ##################
  1461. ## Shortcuts removed, from a different user context.
  1462. ; Remove shortcuts, if any
  1463. SetShellVarContext all ; this makes it backward/forwrad compatible Without it Vista will have problems removing shortcuts.
  1464. ; Essentially, we said put these shortcuts into the all-users profile of the machine
  1465. Delete "$SMPROGRAMS\MessageSniffer\*.*"
  1466. RMDir "$SMPROGRAMS\MessageSniffer"
  1467. Delete "$INSTDIR\shortcuts.xml"
  1468. ##################
  1469. FunctionEnd
  1470. Function un.removeShortcuts
  1471. ##################
  1472. ## Shortcuts removed, from a different user context.
  1473. ; Remove shortcuts, if any
  1474. SetShellVarContext all ; this makes it backward/forwrad compatible Without it Vista will have problems removing shortcuts.
  1475. ; Essentially, we said put these shortcuts into the all-users profile of the machine
  1476. Delete "$SMPROGRAMS\MessageSniffer\*.*"
  1477. RMDir "$SMPROGRAMS\MessageSniffer"
  1478. Delete "$INSTDIR\shortcuts.xml"
  1479. ##################
  1480. FunctionEnd
  1481. Function editGetRulebase
  1482. IfFileExists "$INSTDIR\getRulebase.cmd" 0 DoneWithErrors
  1483. ; This is what is getting edited.
  1484. ;REM ----- Edit This Section --------;
  1485. ;
  1486. ;SET SNIFFER_PATH=c:\SNF
  1487. ;SET AUTHENTICATION=authenticationxx
  1488. ;SET LICENSE_ID=licensid
  1489. ;
  1490. ;REM --------------------------------
  1491. ; Var /GLOBAL ShortPathTempVar ; Defined earlier ... use this to hold the Short Windows Progr~1 path references...
  1492. ; GetFullPathName /SHORT $ShortPathTempVar $INSTDIR ; for windows greeking.
  1493. ${handleShortPath} $ShortPathTempVar $INSTDIR
  1494. ${GetBetween} "SET SNIFFER_PATH=" "$\r$\n" "$INSTDIR\getRulebase.cmd" "$R0" ; This makes it not brittly dependant on the default value. i.e. It would
  1495. !insertmacro ReplaceInFile "$INSTDIR\getRulebase.cmd" "SET SNIFFER_PATH=$R0$\r$\n" "SET SNIFFER_PATH=$ShortPathTempVar$\r$\n"
  1496. ClearErrors
  1497. ${GetBetween} "SET AUTHENTICATION=" "$\r$\n" "$INSTDIR\getRulebase.cmd" "$R0" ; This makes it not brittly dependant on the default value. i.e. It would
  1498. !insertmacro ReplaceInFile "$INSTDIR\getRulebase.cmd" "SET AUTHENTICATION=$R0$\r$\n" "SET AUTHENTICATION=$Authentication$\r$\n"
  1499. ClearErrors
  1500. ${GetBetween} "SET LICENSE_ID=" "$\r$\n" "$INSTDIR\getRulebase.cmd" "$R0" ; This makes it not brittly dependant on the default value. i.e. It would
  1501. !insertmacro ReplaceInFile "$INSTDIR\getRulebase.cmd" "SET LICENSE_ID=$R0$\r$\n" "SET LICENSE_ID=$LicenseID$\r$\n"
  1502. ClearErrors
  1503. return
  1504. DoneWithErrors:
  1505. MessageBox MB_OK "Unable to edit getRulebase.cmd. Unexpected Installer Environment. Please notify Message Sniffer Support Personel Immediately. Thank you."
  1506. Quit
  1507. FunctionEnd
  1508. ##############################
  1509. ## ADDINGPLATFORM ## Step 4 ##
  1510. ########################################################################################################################################################
  1511. ## Write the editor function for inserting any code you need for manipulating text files. Decludes editglobalCFG has a lot of the appropriate comments
  1512. ## for building a fresh version. use editglobalCFG as a template of a very complex edit/replace example. It supports the healFromOldFile typology.
  1513. ## But lots of systems don't use the heal from old file requirements. It depends. Icewarp for example, rewrites and edits whats there each time and doens't
  1514. ## use the archive as a source.
  1515. #######################################
  1516. ## editMDPluginsFile function will search the existing plugins.dat file for a SNF or a SNIFFER section.
  1517. ## It will strip that section and insert its own new version. Either from the local Plugins.dat file on a fresh install.
  1518. ## or via the callback function during a rollback.
  1519. ##
  1520. ## If the ResolveFunction is using the Callback function from the Rollback feature to call editMDPluginsFile then
  1521. ## it will have set the flags for 'healing' the existing file and the source file to use. The challenge is that we don't really want to rollback the entire
  1522. ## file, because the Plugins.dat file may have changed, and we dont' want to break those changes. That's why the callback function
  1523. ## calls restoreMDPlugins which calls this, after setting the flags. This will then have interrupted the 'copying' of the rollback file, and
  1524. ## give the function the chance to pull the sourced path data out of the old file.
  1525. #######################################
  1526. Function editMDPluginsFile
  1527. ;Var /GLOBAL ShortPathTempVar ; Defined earlier ... use this to hold the Short Windows Progr~1 path references...
  1528. ${handleShortPath} $localINSTDIR $INSTDIR
  1529. ${handleShortPath} $localSERVDIR $SNFServerInstallDir
  1530. ## ? WHAT IS SRS_INSTDIR ?
  1531. ## ADDING sensitivity to the functions being called to enable them to look up the proper path values in the event that the
  1532. ## rollback sequence is not in the current INSTDIR and $SNFServerInstallDir locations. i.e. Those parsing functions need to be able
  1533. ## to find the correct file to be editing. If its rolling back an older version cross platform, then it needs to redefine the file its
  1534. ## targeting, not just assume that its in the INSTDIR or the $SNFServerInstallDir. I added two registry keys to the EndRollbackSequence
  1535. ## subroutine called SRS_INSTDIR and SRS_SERVDIR to cover the lookup during rollback....since by this point INSTDIR is defined,
  1536. ## just having SRS_INSTDIR different from INSTDIR should be enough key to use the SRS_INSTDIR.... and if the SRS_INSTDIR doesnt' exist,
  1537. ## ( because it wouldn't be entered until the end of the rollback sequence, then the functions will know they are in the new install, and
  1538. ## will use the current INSTDIR as their paths.....
  1539. Clearerrors
  1540. ReadRegStr $registryTempData HKLM "Software\MessageSniffer" "SRS_INSTDIR"
  1541. iferrors 0 handleReset
  1542. goto doneCheckingRollbackVars ; the keys didn't exist so don't hijack.
  1543. handleReset:
  1544. ; they exist so hijack. i.e. Anytime a rollback file exists, ITS local pointers to the relevant INSTDIR and SERVDIR will be valid.
  1545. ; because when you're done running the rollback, the markers are gone. And a fresh install will replace relevent markers. Even if its
  1546. ; in the same spot.
  1547. StrCpy $localINSTDIR $registryTempData
  1548. ReadRegStr $registryTempData HKLM "Software\MessageSniffer" "SRS_SERVDIR"
  1549. StrCpy $localSERVDIR $registryTempData
  1550. ## Handle the proper shortpaths if they need to be handled.
  1551. ${handleShortPath} $localSERVDIR $localSERVDIR
  1552. ${handleShortPath} $localINSTDIR $localINSTDIR
  1553. doneCheckingRollbackVars:
  1554. ## Ok, so we know what file we're editing, or un-editing.
  1555. Var /GLOBAL lineDataHandle ; these are the vars that will hold the line of text from the file.
  1556. Var /GLOBAL tempVariableReadLine
  1557. Var /GLOBAL SourcePluginsFileHandle ; File handles.
  1558. Var /GLOBAL TargetPluginsFileHandle
  1559. Var /GLOBAL insideSNFSectionFlag ; Loop/Section Flag.
  1560. StrCpy $insideSNFSectionFlag ""
  1561. Var /GLOBAL PresetPluginsFileData ; Blank Plugins file / snf section looks like this:
  1562. StrCpy $PresetPluginsFileData "" ; clear this or else it builds up.
  1563. StrCpy $collectedArchiveData "" ; clear this or else it builds up.
  1564. ## GET / FORMAT DATA FOR INSERTION INTO THE PLUGINS.DAT FILE This will either come from the rolledback version, or the
  1565. ## fresh formulation as depicted here, based on the healFromOldFile flag:
  1566. StrCmp $healFromOldFile "1" GetSourceFromRollbackFile 0
  1567. StrCpy $PresetPluginsFileData "$PresetPluginsFileData$\r$\n[SNF]"
  1568. StrCpy $PresetPluginsFileData "$PresetPluginsFileData$\r$\nMenuText=Configure SNF Plug-in"
  1569. StrCpy $PresetPluginsFileData "$PresetPluginsFileData$\r$\nEnable=Yes"
  1570. StrCpy $PresetPluginsFileData "$PresetPluginsFileData$\r$\nDllPath=$localINSTDIR\snfmdplugin.dll"
  1571. StrCpy $PresetPluginsFileData "$PresetPluginsFileData$\r$\nStartupFuncName=Startup@4"
  1572. StrCpy $PresetPluginsFileData "$PresetPluginsFileData$\r$\nConfigFuncName=ConfigFunc@4"
  1573. StrCpy $PresetPluginsFileData "$PresetPluginsFileData$\r$\nPostMessageFuncName=MessageFunc@8"
  1574. StrCpy $PresetPluginsFileData "$PresetPluginsFileData$\r$\nSMTPMessageFuncName=MessageIPFunc@8"
  1575. StrCpy $PresetPluginsFileData "$PresetPluginsFileData$\r$\nShutdownFuncName=Shutdown@4"
  1576. StrCpy $PresetPluginsFileData "$PresetPluginsFileData$\r$\nPluginDoesAllLogging=No"
  1577. StrCpy $PresetPluginsFileData "$PresetPluginsFileData$\r$\nNonAuthOnly=Yes$\r$\n"
  1578. Goto DataIsReady ; Don't do Read-From-Rollback... not relevant.
  1579. GetSourceFromRollbackFile: ## Ok, so its a callback then. Get the data from the rollback file.
  1580. ## Open File, strip out the SNF section into a variable, and store it. If none exists, leave empty.
  1581. ################################################## HEAL FROM ARCHIVE DATA COLLECTION PHASE #######################################
  1582. StrCmp $healFromOldFile "1" 0 NoDataMining
  1583. ## Then you need to strip the stuff to put back.
  1584. IfFileExists $archivedMDPluginsDatPath 0 DoneReadingArchiveFile ; if the file is valid.
  1585. FileOpen $archivedMDPluginsDatFileHandle $archivedMDPluginsDatPath r ; open file.
  1586. iferrors 0 +3
  1587. MessageBox MB_OK "Unable to restructure MDaemons Plugins.dat file from the rollback."
  1588. Goto DoneReadingArchiveFile
  1589. ReadArchiveLine:
  1590. FileRead $archivedMDPluginsDatFileHandle $lineDataHandle ; Master loop until we find our [SNF] marker in the Plugins.dat file.
  1591. ifErrors DoneReadingArchiveFile 0 ; If we get to end with no lines... ok...
  1592. ; Primary test is that this a live sniffer line.
  1593. ${WordFind2X} $lineDataHandle "[" "]" "E+1" $9
  1594. IfErrors 0 +2 ; no errors means it found a string, so skip over and test
  1595. Goto ReadArchiveLine ; if errors then get new line
  1596. StrCmp $9 "SNF" FoundLiveArchiveSnifferLine TestTagForOldSniffer ; Test for SNF tag...
  1597. TestTagForOldSniffer: StrCmp $9 "SNIFFER" FoundLiveArchiveSnifferLine ReadArchiveLine ; if not, then besure it isn't SNIFFER tag...
  1598. ; go back and get a newline to test.
  1599. ## IF here, then we broke out of the loop.
  1600. FoundLiveArchiveSnifferLine: ; we found the open tag for the SNF. So we read until we get another [] tag.
  1601. StrCpy $collectedArchiveData "$collectedArchiveData$lineDataHandle" ; If here the line is of interest, collect it.
  1602. GetanInsideLine: ; as long as were inside the sniffer section, get lines here.
  1603. FileRead $archivedMDPluginsDatFileHandle $lineDataHandle
  1604. IfErrors DoneReadingArchiveFile
  1605. ${WordFind2X} $lineDataHandle "[" "]" "E+1" $9
  1606. IfErrors 0 FoundNewBracketMarker ; Drop through if errors, ( No delimiter found ) If we have zero errors we've found
  1607. ; a new section so then you should goto FoundNewBracketMarker label.
  1608. ; If errors, then we keep going with more string compares..
  1609. ClearErrors ; must clear the error condition returned from the WordFind before next line...
  1610. StrCpy $collectedArchiveData "$collectedArchiveData$lineDataHandle" ; If here the line is still of interest, collect it.
  1611. Goto GetanInsideLine ; Go get more.
  1612. FoundNewBracketMarker: ; Break.
  1613. ; So we're done here then. Cause we don't care about the rest. We only what what the SNF section was. Any other changes to the target file stay in place.
  1614. DoneReadingArchiveFile: ; By this point, either $collectedArchiveData has a bunch of stuff or it doesn't......
  1615. FileClose $archivedGLOBALcfgFileHandle ; Close file.
  1616. StrCpy $lineDataHandle "" ; Clear line data.
  1617. NoDataMining:
  1618. ################################################### END HEAL FROM ARCHIVE DATA COLLECTION PHASE #################################
  1619. StrCpy $PresetPluginsFileData $collectedArchiveData
  1620. DataIsReady:
  1621. ## Data is now collected and ready for insertion, whether its new, old, or empty.
  1622. ;MessageBox MB_OK "$PresetPluginsFileData, $healFromOldFile, ::::::: $collectedArchiveData "
  1623. IfFileExists "$localSERVDIR\App\Plugins.dat" filedoesexist 0 ; Skip to second instruction if it doesn't exist.
  1624. ;filedoesNotExist: MessageBox MB_OK "No Plugins.dat file in the (expected) directory. Creating fresh file."
  1625. ; If the file is gone, it could have been deleted manually. So just because its gone dosn't mean you wouldn't put back the rollback data
  1626. ; into a new file. Since this is already defined for new and rollback, (above) we are clear for a new file in either case.
  1627. ClearErrors
  1628. ## IF no file exists, then we open file, write new file, and be done.
  1629. FileOpen $TargetPluginsFileHandle "$localSERVDIR\App\Plugins.dat" w
  1630. FileWrite $TargetPluginsFileHandle $PresetPluginsFileData ; dump the file....
  1631. FileClose $TargetPluginsFileHandle
  1632. IfErrors FailedRepair ; otherwise clear for attempting to recreate.
  1633. ;MessageBox MB_OK "Installer successfully inserted new Plugins.dat file."
  1634. Goto done
  1635. filedoesexist:
  1636. ClearErrors
  1637. ; So open the file that we're going to write INTO....
  1638. FileOpen $TargetPluginsFileHandle $localINSTDIR\WorkingPlugins.dat w ; rename and move new to old one
  1639. IfErrors FailedWorking
  1640. ; Now open the file we're going to read from.
  1641. FileOpen $SourcePluginsFileHandle $localSERVDIR\App\Plugins.dat r ; open a new file for reading
  1642. ;MessageBox MB_OK $SourcePluginsFileHandle
  1643. IfErrors FailedEdit
  1644. ; Here is where we need top copy everything from the first file, until we reach [SNF]
  1645. ; where we strip that out and will eventually add the new SNF data at the bottom...
  1646. ; then we copy everything again after we reach another open [
  1647. ; Ok, so while we read lines until the end of file,
  1648. ; we compare the line and look for [SNF].
  1649. ; if We dont' find it. we copy the line to the new file.
  1650. ; once we find it, we start looking for the next open bracket [
  1651. ; and we don't write any lines to the new file until we find the next [
  1652. ; Then we write all lines until the end of the file.
  1653. ; then we write the [SNF] code to the end of the file,
  1654. ; and we close the file.
  1655. ; No while necessary. Goto will loop to GetaLineHere: label if no SNF is identified.
  1656. GetaLineHere:
  1657. FileRead $SourcePluginsFileHandle $tempVariableReadLine ; read the next line into our temp var. from the handle $0 ( attached above with FileOpen )
  1658. ; NOW test for EOF.
  1659. IfErrors HandleEnding
  1660. ; then we have reached the end of the file without finding the SNF file.
  1661. ; go directly to writing the SNF information to the output file.
  1662. ; Now handle for being in the section where we have alredy detected the SNF flag.
  1663. ; The function jumps from this section to the Handle end flag, after it has finished copying the file.
  1664. StrCmp $insideSNFSectionFlag "1" 0 Not_In_SNF_Tagged_Section ; test to find new open '[' char and when we find it
  1665. ; take us out of SNF skip line mode.
  1666. ${WordFind2X} $tempVariableReadLine "[" "]" "E+1" $9
  1667. IfErrors 0 noerrors ; Drop through if errors, ( No delimiter found ) If we have zero errors we've found
  1668. ; a new section goto noerrors label.
  1669. FindNextTag: ; Since where INSIDE the SNF tag, we're NOT copying it to the temp file.
  1670. ClearErrors ; clear condition.
  1671. FileRead $SourcePluginsFileHandle $tempVariableReadLine ; read next line.
  1672. IfErrors HandleEnding
  1673. ${WordFind2X} $tempVariableReadLine "[" "]" "E+1" $9 ; Look for tag to kick us out of SNF/SNIFFER section.
  1674. IfErrors FindNextTag noerrors ; Go back if-errors, ( No delimiter found )
  1675. ;If we have zero errors we've found new section head.so goto noerrors label.
  1676. noerrors: ; then ( since we were IN the snf section ) and we found a DIFFERENT identified tag in the file... dump rest of file in a tight loop.
  1677. ClearErrors ; clear error flag if exists from the above string compare.
  1678. copyRestOfFile: FileWrite $TargetPluginsFileHandle $tempVariableReadLine ; Dump temp string into new file.
  1679. FileRead $SourcePluginsFileHandle $tempVariableReadLine ; read line.
  1680. IfErrors HandleEnding copyRestOfFile
  1681. ; An error will indicate end of file. loop of not EOF otherwise proceed to ending.
  1682. ; we've stripped out the old SNF section and copied the existing contents of the file.
  1683. Not_In_SNF_Tagged_Section:
  1684. ; we should never proceed directly from the above section to the next below.
  1685. ; if we enter the above section it only can exit into the HandleEnding area.
  1686. ; So if we're entering here. its because we read a line, and we need to test it because
  1687. ; we have not yet detected the SNF section.
  1688. ; Now we test to find the SNF
  1689. ${WordFind2X} $tempVariableReadLine "[" "]" "E+1" $9 ; stuff what we find in register nine.
  1690. IfErrors 0 +3 ; no errors means it found a string, so skip over and test
  1691. FileWrite $TargetPluginsFileHandle $tempVariableReadLine ; Dump nonflagged string into new file.
  1692. Goto GetaLineHere ; get new line
  1693. ; if errors we move get the next line to test.
  1694. StrCmp $9 "SNF" TagOK TestTagForOld ; check nine for SNF or SNIFFER Now.
  1695. TestTagForOld: StrCmp $9 "SNIFFER" TagOK TagNotSniffer
  1696. TagOK:
  1697. StrCpy $insideSNFSectionFlag "1"
  1698. Goto GetaLineHere ; This forces us into the top looping section where we srip it all out.
  1699. TagNotSniffer:
  1700. FileWrite $TargetPluginsFileHandle $tempVariableReadLine ; Dump temp string into new file.
  1701. Goto GetaLinehere ; Go back for more.
  1702. ; you should not just progress from this line to the Handle Ending. The condition to move to handle ending
  1703. ; will always be predicated on reaching the end of the file.
  1704. HandleEnding: ; We will always get to the end of the file.
  1705. ; Now we must output our SNF information, because
  1706. ; either we cut it out,
  1707. ; or we didn't find it at all and in either case we must add it now.
  1708. FileClose $SourcePluginsFileHandle ; Close this because we read it all.
  1709. ClearErrors
  1710. FileWrite $TargetPluginsFileHandle "$\r$\n"
  1711. # It doesn't matter at this point, if we're doing a rollback or a new.
  1712. # We've handled loading what should be in PresetFileData at the beginning
  1713. # of this sub, based on the flags, the old file, etc. If this $PresetPluginsFileData
  1714. # is empty here, then its supposed to be. Write and Close.
  1715. FileWrite $TargetPluginsFileHandle $PresetPluginsFileData ; dump the file....
  1716. FileClose $TargetPluginsFileHandle ; Close MDaemon Plugins file.
  1717. ifFileExists "$localSERVDIR\App\OLDPluginsDAT_PreSNFInstall.dat" 0 +2
  1718. Delete $localSERVDIR\App\OLDPluginsDAT_PreSNFInstall.dat ;
  1719. Rename $localSERVDIR\App\Plugins.dat $localSERVDIR\App\OLDPluginsDAT_PreSNFInstall.dat ; store the old version.
  1720. Rename $localINSTDIR\WorkingPlugins.dat $localSERVDIR\App\Plugins.dat ; move the working version.
  1721. Goto done
  1722. ; poorly simulated catch section.
  1723. FailedRepair:
  1724. MessageBox MB_OK "Installer seemed unable to create a new Plugins.dat file. Perhaps the file is locked. Please attempt to create/move this file manually into the MDaemon\App folder using the Plugins.dat file in the MDaemon\SNF directory according to the manual instructions: "
  1725. FileClose $TargetPluginsFileHandle ; Close MDaemon Plugins file.
  1726. FileClose $SourcePluginsFileHandle
  1727. ExecShell open notepad.exe $localINSTDIR\InstallInstructions_MDaemon.txt SW_SHOWNORMAL
  1728. Goto done
  1729. FailedWorking:
  1730. MessageBox MB_OK "Installer seemed unable to create a working file. Perhaps the folders permissions are not enabling file creation. "
  1731. FileClose $TargetPluginsFileHandle ; Close MDaemon Plugins file.
  1732. FileClose $SourcePluginsFileHandle
  1733. ExecShell open notepad.exe $localINSTDIR\InstallInstructions_MDaemon.txt SW_SHOWNORMAL
  1734. Goto done
  1735. FailedEdit:
  1736. FileClose $TargetPluginsFileHandle ; Close MDaemon Plugins file.
  1737. FileClose $SourcePluginsFileHandle
  1738. MessageBox MB_OK "Installer seemed unable to edit the $localSERVDIR\App\Plugins.dat file. Perhaps the file is locked. This installation is incomplete. "
  1739. done:
  1740. FunctionEnd
  1741. Function un.editMDPluginsFile
  1742. ;Var /GLOBAL ShortPathTempVar ; Defined earlier ... use this to hold the Short Windows Progr~1 path references...
  1743. ${un.handleShortPath} $localINSTDIR $INSTDIR
  1744. ${un.handleShortPath} $localSERVDIR $SNFServerInstallDir
  1745. ## ? WHAT IS SRS_INSTDIR ?
  1746. ## ADDING sensitivity to the functions being called to enable them to look up the proper path values in the event that the
  1747. ## rollback sequence is not in the current INSTDIR and $SNFServerInstallDir locations. i.e. Those parsing functions need to be able
  1748. ## to find the correct file to be editing. If its rolling back an older version cross platform, then it needs to redefine the file its
  1749. ## targeting, not just assume that its in the INSTDIR or the $SNFServerInstallDir. I added two registry keys to the EndRollbackSequence
  1750. ## subroutine called SRS_INSTDIR and SRS_SERVDIR to cover the lookup during rollback....since by this point INSTDIR is defined,
  1751. ## just having SRS_INSTDIR different from INSTDIR should be enough key to use the SRS_INSTDIR.... and if the SRS_INSTDIR doesnt' exist,
  1752. ## ( because it wouldn't be entered until the end of the rollback sequence, then the functions will know they are in the new install, and
  1753. ## will use the current INSTDIR as their paths.....
  1754. Clearerrors
  1755. ReadRegStr $registryTempData HKLM "Software\MessageSniffer" "SRS_INSTDIR"
  1756. iferrors 0 handleReset
  1757. goto doneCheckingRollbackVars ; the keys didn't exist so don't hijack.
  1758. handleReset:
  1759. ; they exist so hijack. i.e. Anytime a rollback file exists, ITS local pointers to the relevant INSTDIR and SERVDIR will be valid.
  1760. ; because when you're done running the rollback, the markers are gone. And a fresh install will replace relevent markers. Even if its
  1761. ; in the same spot.
  1762. StrCpy $localINSTDIR $registryTempData
  1763. ReadRegStr $registryTempData HKLM "Software\MessageSniffer" "SRS_SERVDIR"
  1764. StrCpy $localSERVDIR $registryTempData
  1765. ## Handle the proper shortpaths if they need to be handled.
  1766. ${un.handleShortPath} $localSERVDIR $localSERVDIR
  1767. ${un.handleShortPath} $localINSTDIR $localINSTDIR
  1768. doneCheckingRollbackVars:
  1769. ## Ok, so we know what file we're editing, or un-editing.
  1770. ;Var /GLOBAL lineDataHandle ; these are the vars that will hold the line of text from the file.
  1771. ;Var /GLOBAL tempVariableReadLine
  1772. ;Var /GLOBAL SourcePluginsFileHandle ; File handles.
  1773. ;Var /GLOBAL TargetPluginsFileHandle
  1774. ;Var /GLOBAL insideSNFSectionFlag ; Loop/Section Flag.
  1775. StrCpy $insideSNFSectionFlag ""
  1776. ;Var /GLOBAL PresetPluginsFileData ; Blank Plugins file / snf section looks like this:
  1777. StrCpy $PresetPluginsFileData "" ; clear this or else it builds up.
  1778. StrCpy $collectedArchiveData "" ; clear this or else it builds up.
  1779. ## GET / FORMAT DATA FOR INSERTION INTO THE PLUGINS.DAT FILE This will either come from the rolledback version, or the
  1780. ## fresh formulation as depicted here, based on the healFromOldFile flag:
  1781. StrCmp $healFromOldFile "1" GetSourceFromRollbackFile 0
  1782. StrCpy $PresetPluginsFileData "" ; this is either a call back to restore, or to remove... but its not putting it in.
  1783. Goto DataIsReady ; Don't do Read-From-Rollback... not relevant.
  1784. GetSourceFromRollbackFile: ## Ok, so its a callback then. Get the data from the rollback file.
  1785. ## Open File, strip out the SNF section into a variable, and store it. If none exists, leave empty.
  1786. ################################################## HEAL FROM ARCHIVE DATA COLLECTION PHASE #######################################
  1787. StrCmp $healFromOldFile "1" 0 NoDataMining
  1788. ## Then you need to strip the stuff to put back.
  1789. IfFileExists $archivedMDPluginsDatPath 0 DoneReadingArchiveFile ; if the file is valid.
  1790. FileOpen $archivedMDPluginsDatFileHandle $archivedMDPluginsDatPath r ; open file.
  1791. iferrors 0 +3
  1792. MessageBox MB_OK "Unable to restructure MDaemons Plugins.dat file from the rollback."
  1793. Goto DoneReadingArchiveFile
  1794. ReadArchiveLine:
  1795. FileRead $archivedMDPluginsDatFileHandle $lineDataHandle ; Master loop until we find our [SNF] marker in the Plugins.dat file.
  1796. ifErrors DoneReadingArchiveFile 0 ; If we get to end with no lines... ok...
  1797. ; Primary test is that this a live sniffer line.
  1798. ${un.WordFind2X} $lineDataHandle "[" "]" "E+1" $9
  1799. IfErrors 0 +2 ; no errors means it found a string, so skip over and test
  1800. Goto ReadArchiveLine ; if errors then get new line
  1801. StrCmp $9 "SNF" FoundLiveArchiveSnifferLine TestTagForOldSniffer ; Test for SNF tag...
  1802. TestTagForOldSniffer: StrCmp $9 "SNIFFER" FoundLiveArchiveSnifferLine ReadArchiveLine ; if not, then besure it isn't SNIFFER tag...
  1803. ; go back and get a newline to test.
  1804. ## IF here, then we broke out of the loop.
  1805. FoundLiveArchiveSnifferLine: ; we found the open tag for the SNF. So we read until we get another [] tag.
  1806. StrCpy $collectedArchiveData "$collectedArchiveData$lineDataHandle" ; If here the line is of interest, collect it.
  1807. GetanInsideLine: ; as long as were inside the sniffer section, get lines here.
  1808. FileRead $archivedMDPluginsDatFileHandle $lineDataHandle
  1809. IfErrors DoneReadingArchiveFile
  1810. ${un.WordFind2X} $lineDataHandle "[" "]" "E+1" $9
  1811. IfErrors 0 FoundNewBracketMarker ; Drop through if errors, ( No delimiter found ) If we have zero errors we've found
  1812. ; a new section so then you should goto FoundNewBracketMarker label.
  1813. ; If errors, then we keep going with more string compares..
  1814. ClearErrors ; must clear the error condition returned from the WordFind before next line...
  1815. StrCpy $collectedArchiveData "$collectedArchiveData$lineDataHandle" ; If here the line is still of interest, collect it.
  1816. Goto GetanInsideLine ; Go get more.
  1817. FoundNewBracketMarker: ; Break.
  1818. ; So we're done here then. Cause we don't care about the rest. We only what what the SNF section was. Any other changes to the target file stay in place.
  1819. DoneReadingArchiveFile: ; By this point, either $collectedArchiveData has a bunch of stuff or it doesn't......
  1820. FileClose $archivedGLOBALcfgFileHandle ; Close file.
  1821. StrCpy $lineDataHandle "" ; Clear line data.
  1822. NoDataMining:
  1823. ################################################### END HEAL FROM ARCHIVE DATA COLLECTION PHASE #################################
  1824. StrCpy $PresetPluginsFileData $collectedArchiveData
  1825. DataIsReady:
  1826. ## Data is now collected and ready for insertion, whether its new, old, or empty.
  1827. ;MessageBox MB_OK "$PresetPluginsFileData, $healFromOldFile, ::::::: $collectedArchiveData "
  1828. IfFileExists "$localSERVDIR\App\Plugins.dat" filedoesexist 0 ; Skip to second instruction if it doesn't exist.
  1829. ;filedoesNotExist: MessageBox MB_OK "No Plugins.dat file in the (expected) directory. Creating fresh file."
  1830. ; If the file is gone, it could have been deleted manually. So just because its gone dosn't mean you wouldn't put back the rollback data
  1831. ; into a new file. Since this is already defined for new and rollback, (above) we are clear for a new file in either case.
  1832. ClearErrors
  1833. ## IF no file exists, then we open file, write new file, and be done.
  1834. FileOpen $TargetPluginsFileHandle "$localSERVDIR\App\Plugins.dat" w
  1835. FileWrite $TargetPluginsFileHandle $PresetPluginsFileData ; dump the file....
  1836. FileClose $TargetPluginsFileHandle
  1837. IfErrors FailedRepair ; otherwise clear for attempting to recreate.
  1838. ;MessageBox MB_OK "Installer successfully inserted new Plugins.dat file."
  1839. Goto done
  1840. filedoesexist:
  1841. ClearErrors
  1842. ; So open the file that we're going to write INTO....
  1843. FileOpen $TargetPluginsFileHandle $localINSTDIR\WorkingPlugins.dat w ; rename and move new to old one
  1844. IfErrors FailedWorking
  1845. ; Now open the file we're going to read from.
  1846. FileOpen $SourcePluginsFileHandle $localSERVDIR\App\Plugins.dat r ; open a new file for reading
  1847. ;MessageBox MB_OK $SourcePluginsFileHandle
  1848. IfErrors FailedEdit
  1849. ; Here is where we need top copy everything from the first file, until we reach [SNF]
  1850. ; where we strip that out and will eventually add the new SNF data at the bottom...
  1851. ; then we copy everything again after we reach another open [
  1852. ; Ok, so while we read lines until the end of file,
  1853. ; we compare the line and look for [SNF].
  1854. ; if We dont' find it. we copy the line to the new file.
  1855. ; once we find it, we start looking for the next open bracket [
  1856. ; and we don't write any lines to the new file until we find the next [
  1857. ; Then we write all lines until the end of the file.
  1858. ; then we write the [SNF] code to the end of the file,
  1859. ; and we close the file.
  1860. ; No while necessary. Goto will loop to GetaLineHere: label if no SNF is identified.
  1861. GetaLineHere:
  1862. FileRead $SourcePluginsFileHandle $tempVariableReadLine ; read the next line into our temp var. from the handle $0 ( attached above with FileOpen )
  1863. ; NOW test for EOF.
  1864. IfErrors HandleEnding
  1865. ; then we have reached the end of the file without finding the SNF file.
  1866. ; go directly to writing the SNF information to the output file.
  1867. ; Now handle for being in the section where we have alredy detected the SNF flag.
  1868. ; The function jumps from this section to the Handle end flag, after it has finished copying the file.
  1869. StrCmp $insideSNFSectionFlag "1" 0 Not_In_SNF_Tagged_Section ; test to find new open '[' char and when we find it
  1870. ; take us out of SNF skip line mode.
  1871. ${un.WordFind2X} $tempVariableReadLine "[" "]" "E+1" $9
  1872. IfErrors 0 noerrors ; Drop through if errors, ( No delimiter found ) If we have zero errors we've found
  1873. ; a new section goto noerrors label.
  1874. FindNextTag: ; Since where INSIDE the SNF tag, we're NOT copying it to the temp file.
  1875. ClearErrors ; clear condition.
  1876. FileRead $SourcePluginsFileHandle $tempVariableReadLine ; read next line.
  1877. IfErrors HandleEnding
  1878. ${un.WordFind2X} $tempVariableReadLine "[" "]" "E+1" $9 ; Look for tag to kick us out of SNF/SNIFFER section.
  1879. IfErrors FindNextTag noerrors ; Go back if-errors, ( No delimiter found )
  1880. ;If we have zero errors we've found new section head.so goto noerrors label.
  1881. noerrors: ; then ( since we were IN the snf section ) and we found a DIFFERENT identified tag in the file... dump rest of file in a tight loop.
  1882. ClearErrors ; clear error flag if exists from the above string compare.
  1883. copyRestOfFile: FileWrite $TargetPluginsFileHandle $tempVariableReadLine ; Dump temp string into new file.
  1884. FileRead $SourcePluginsFileHandle $tempVariableReadLine ; read line.
  1885. IfErrors HandleEnding copyRestOfFile
  1886. ; An error will indicate end of file. loop of not EOF otherwise proceed to ending.
  1887. ; we've stripped out the old SNF section and copied the existing contents of the file.
  1888. Not_In_SNF_Tagged_Section:
  1889. ; we should never proceed directly from the above section to the next below.
  1890. ; if we enter the above section it only can exit into the HandleEnding area.
  1891. ; So if we're entering here. its because we read a line, and we need to test it because
  1892. ; we have not yet detected the SNF section.
  1893. ; Now we test to find the SNF
  1894. ${un.WordFind2X} $tempVariableReadLine "[" "]" "E+1" $9 ; stuff what we find in register nine.
  1895. IfErrors 0 +3 ; no errors means it found a string, so skip over and test
  1896. FileWrite $TargetPluginsFileHandle $tempVariableReadLine ; Dump nonflagged string into new file.
  1897. Goto GetaLineHere ; get new line
  1898. ; if errors we move get the next line to test.
  1899. StrCmp $9 "SNF" TagOK TestTagForOld ; check nine for SNF or SNIFFER Now.
  1900. TestTagForOld: StrCmp $9 "SNIFFER" TagOK TagNotSniffer
  1901. TagOK:
  1902. StrCpy $insideSNFSectionFlag "1"
  1903. Goto GetaLineHere ; This forces us into the top looping section where we srip it all out.
  1904. TagNotSniffer:
  1905. FileWrite $TargetPluginsFileHandle $tempVariableReadLine ; Dump temp string into new file.
  1906. Goto GetaLinehere ; Go back for more.
  1907. ; you should not just progress from this line to the Handle Ending. The condition to move to handle ending
  1908. ; will always be predicated on reaching the end of the file.
  1909. HandleEnding: ; We will always get to the end of the file.
  1910. ; Now we must output our SNF information, because
  1911. ; either we cut it out,
  1912. ; or we didn't find it at all and in either case we must add it now.
  1913. FileClose $SourcePluginsFileHandle ; Close this because we read it all.
  1914. ClearErrors
  1915. FileWrite $TargetPluginsFileHandle "$\r$\n"
  1916. # It doesn't matter at this point, if we're doing a rollback or a new.
  1917. # We've handled loading what should be in PresetFileData at the beginning
  1918. # of this sub, based on the flags, the old file, etc. If this $PresetPluginsFileData
  1919. # is empty here, then its supposed to be. Write and Close.
  1920. FileWrite $TargetPluginsFileHandle $PresetPluginsFileData ; dump the file....
  1921. FileClose $TargetPluginsFileHandle ; Close MDaemon Plugins file.
  1922. ifFileExists "$localSERVDIR\App\OLDPluginsDAT_PreSNFInstall.dat" 0 +2
  1923. Delete $localSERVDIR\App\OLDPluginsDAT_PreSNFInstall.dat ;
  1924. Rename $localSERVDIR\App\Plugins.dat $localSERVDIR\App\OLDPluginsDAT_PreSNFInstall.dat ; store the old version.
  1925. Rename $localINSTDIR\WorkingPlugins.dat $localSERVDIR\App\Plugins.dat ; move the working version.
  1926. Goto done
  1927. ; poorly simulated catch section.
  1928. FailedRepair:
  1929. MessageBox MB_OK "Uninstaller seemed unable to create a new Plugins.dat file. Perhaps the file is locked. Please attempt to create/move this file manually into the MDaemon\App folder using the Plugins.dat file in the MDaemon\SNF directory according to the manual instructions: "
  1930. FileClose $TargetPluginsFileHandle ; Close MDaemon Plugins file.
  1931. FileClose $SourcePluginsFileHandle
  1932. ExecShell open notepad.exe $localINSTDIR\InstallInstructions_MDaemon.txt SW_SHOWNORMAL
  1933. Goto done
  1934. FailedWorking:
  1935. MessageBox MB_OK "Uninstaller seemed unable to create a working file. Perhaps the folders permissions are not enabling file creation. "
  1936. FileClose $TargetPluginsFileHandle ; Close MDaemon Plugins file.
  1937. FileClose $SourcePluginsFileHandle
  1938. ExecShell open notepad.exe $localINSTDIR\InstallInstructions_MDaemon.txt SW_SHOWNORMAL
  1939. Goto done
  1940. FailedEdit:
  1941. FileClose $TargetPluginsFileHandle ; Close MDaemon Plugins file.
  1942. FileClose $SourcePluginsFileHandle
  1943. MessageBox MB_OK "Uninstaller seemed unable to edit the $localSERVDIR\App\Plugins.dat file. Perhaps the file is locked. This installation is incomplete. "
  1944. done:
  1945. FunctionEnd
  1946. ## Dont' need this now...
  1947. ## Rollback handleds this at restore...
  1948. Function un.cleanGlobalCFG
  1949. ;comment out every live line in the global.cfg file.
  1950. Var /GLOBAL sourceFileHandle
  1951. Var /GLOBAL targetFileHandle
  1952. Var /GLOBAL str_line
  1953. Var /GLOBAL results
  1954. FileOpen $sourceFileHandle "$SNFServerInstallDir\global.cfg" r
  1955. FileOpen $targetFileHandle "$SNFServerInstallDir\phase1global.cfg" w
  1956. NextLine:
  1957. FileRead $sourceFileHandle $str_line
  1958. iferrors cleanupFiles 0
  1959. StrCmp $LicenseID "" LookForBaseEXE 0 ; if for some reason the LicenseID is blank, we don't want to comment every ".exe"
  1960. ${un.WordFind} $str_line "$LicenseID.exe" "E+1}" $results
  1961. ifErrors LookForBaseEXE FoundLiveSnifferLine ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  1962. LookForBaseEXE:
  1963. ${un.WordFind} $str_line "SNFClient.exe" "E+1}" $results
  1964. ifErrors 0 FoundLiveSnifferLine ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  1965. FileWrite $targetFileHandle $str_line
  1966. Goto NextLine
  1967. FoundLiveSnifferLine:
  1968. FileWrite $targetFileHandle "#$str_line"
  1969. Goto NextLine
  1970. cleanupFiles:
  1971. FileClose $sourceFileHandle
  1972. FileClose $targetFileHandle
  1973. #Rename it now...
  1974. ifFileExists "$SNFServerInstallDir\pre_snifferUNINSTALL_global.cfg.log" 0 +2
  1975. Delete "$SNFServerInstallDir\pre_snifferUNINSTALL_global.cfg.log"
  1976. Rename "$SNFServerInstallDir\global.cfg" "$SNFServerInstallDir\pre_snifferUNINSTALL_global.cfg.log"
  1977. Rename "$SNFServerInstallDir\phase1global.cfg" "$SNFServerInstallDir\global.cfg"
  1978. ifFileExists "$SNFServerInstallDir\phase1global.cfg" 0 +2
  1979. Delete "$SNFServerInstallDir\phase1global.cfg"
  1980. Return
  1981. FunctionEND
  1982. Function editglobalCFG
  1983. ; MessageBox MB_OK "Inside editglobalCFG"
  1984. ; if we're here it means we checked for a global.cfg file, and it existed at the SNFServerInstallDir level... presumably decludes install pattern.
  1985. ; so we are going to edit / add / replace the values that we are interested in.
  1986. ; IF there is a file called cfgstring.xml in the folder, it means we are restoring from a previous archived version and we need to pull that string
  1987. ; and consume the file.
  1988. ; Adjustments to the parsing of the DECLUDE global.cfg are as follows:
  1989. ; Upon uninstall, we comment all sniffer lines.
  1990. ; Upon a reinstall/new install, we rip through and 'heal' or insert the sniffer directives.....
  1991. ; the priority will be: Just ahead of the first live sniffer line.
  1992. ; Just after the EXTERNAL TESTS marker if it exists.
  1993. ; If none of those apply, we insert them at the top of the file.
  1994. ;
  1995. ; Kicker is as follows, the NAME of the test is inconclusive to being able to identifiy it. i.e. beforeSniffer Sniffer afterSniffer are not
  1996. ; acceptible names to tag on... because they may be Spam Assasin before, or SA after or whatever....
  1997. ; The only acceptible tag to hit is the SNFClient.exe tag. And to further complicate it it can be inside quotes or whatever, and we
  1998. ; need to respect that when we heal the path.
  1999. ;
  2000. ; Process will utilize two temp files. The first temp file is the file we write all non-relevent lines to BEFORE we hit the EXTERNAL TESTS marker.
  2001. ; The second temp file will hold all lines after that, until we find a live sniffer line. Pending no sniffer lines, we insert after Eternal Tests
  2002. ; and append the second file and close.
  2003. #VAR /GLOBAL healFromOldFile ; used to flag putting stuff back.
  2004. #VAR /GLOBAL archivedGLOBALcfgPath ; file to use for putting stuff back.
  2005. #VAR /GLOBAL archivedGLOBALcfgFileHandle ; handle for file to read in the stuff to put back....
  2006. #VAR /GLOBAL collectedArchiveData ; store these lines, collected from the file.
  2007. #VAR /GLOBAL succededAtPlacingArchivedData ; true if we have already written data to the new file.
  2008. ; Var /GLOBAL ShortPathTempVar ; Defined earlier ... use this to hold the Short Windows Progr~1 path references...
  2009. ;GetFullPathName /SHORT $localINSTDIR $INSTDIR ; for windows greeking. ; Seed with the default values.
  2010. ${handleShortPath} $localINSTDIR $INSTDIR
  2011. ;StrCpy $localINSTDIR $INSTDIR ; Seed the default values.
  2012. ;GetFullPathName /SHORT $localSERVDIR $SNFServerInstallDir ; for windows greeking. ; Seed with the default values.
  2013. ${handleShortPath} $localSERVDIR $SNFServerInstallDir
  2014. ;StrCpy $localSERVDIR $SNFServerInstallDir ; Seed with the default values.
  2015. ## ADDING sensitivity to the functions being called to enable them to look up the proper path values in the event that the
  2016. ## rollback sequence is not in the current INSTDIR and $SNFServerInstallDir locations. i.e. Those parsing functions need to be able
  2017. ## to find the correct file to be editing. If its rolling back an older version cross platform, then it needs to redefine the file its
  2018. ## targeting, not just assume that its in the INSTDIR or the $SNFServerInstallDir. I added two registry keys to the EndRollbackSequence
  2019. ## subroutine called SRS_INSTDIR and SRS_SERVDIR to cover the lookup during rollback....since by this point INSTDIR is defined,
  2020. ## just having SRS_INSTDIR different from INSTDIR should be enough key to use the SRS_INSTDIR.... and if the SRS_INSTDIR doesnt' exist,
  2021. ## ( because it wouldn't be entered until the end of the rollback sequence, then the functions will know they are in the new install, and
  2022. ## will use the current INSTDIR as their paths.....
  2023. Clearerrors
  2024. ReadRegStr $registryTempData HKLM "Software\MessageSniffer" "SRS_INSTDIR"
  2025. iferrors 0 handleReset
  2026. goto doneCheckingRollbackVars ; the keys didn't exist so don't hijack.
  2027. handleReset:
  2028. ; they exist so hijack. i.e. Anytime a rollback file exists, ITS local pointers to the relevant INSTDIR and SERVDIR will be valid.
  2029. ; because when you're done running the rollback, the markers are gone. And a fresh install will replace relevent markers. Even if its
  2030. ; in the same spot.
  2031. StrCpy $localINSTDIR $registryTempData
  2032. ReadRegStr $registryTempData HKLM "Software\MessageSniffer" "SRS_SERVDIR"
  2033. StrCpy $localSERVDIR $registryTempData
  2034. ## Handle the proper shortpaths if they need to be handled.
  2035. ${handleShortPath} $localSERVDIR $localSERVDIR
  2036. ${handleShortPath} $localINSTDIR $localINSTDIR
  2037. doneCheckingRollbackVars:
  2038. StrCpy $collectedArchiveData "" ; set for default.
  2039. StrCpy $succededAtPlacingArchivedData "0"
  2040. VAR /GLOBAL decludeConfigFileHandle ; the existing live file....
  2041. VAR /GLOBAL phase_FileHandle ; holds the first half up to the External Tests or pending no External Test line... we have the entire file here.
  2042. VAR /GLOBAL phase
  2043. VAR /GLOBAL TargetSnifferString ; could be SNFClient.exe or $LicenseID.exe
  2044. StrCpy $phase "1" ; start in phase 1
  2045. # Identify live sniffer lines, and heal them if possible.
  2046. Var /GLOBAL foundAtLeastOneLiveSnifferLine
  2047. StrCpy $foundAtLeastOneLiveSnifferLine "0" ; defaults to no.....
  2048. ; Declared same var earlier.
  2049. ;Var /GLOBAL lineDataHandle
  2050. Var /GLOBAL WordFindResults
  2051. Var /GLOBAL FirstCharTestVar
  2052. Var /GLOBAL tempLineHandle ; holds a manipulated version of the line as we test it....
  2053. Var /GLOBAL secondHalfOfLine ; holds the other side to rejoin it after we replace....
  2054. Var /GLOBAL firstHalfOfLine ; holds all chars up to the encapsulator.
  2055. Var /GLOBAL encapsulator ; holds the type of quote if its quoted...
  2056. ################################################## HEAL FROM ARCHIVE DATA COLLECTION PHASE #######################################
  2057. ${IF} $healFromOldFile = "1"
  2058. ## Then you need to strip and make temporary file for the stuff to put back.
  2059. IfFileExists $archivedGLOBALcfgPath 0 DoneReadingArchiveFile
  2060. FileOpen $archivedGLOBALcfgFileHandle $archivedGLOBALcfgPath r
  2061. iferrors 0 +3
  2062. MessageBox MB_OK "Unable to restructure Decludes global.cfg file from the rollback."
  2063. Goto DoneReadingArchiveFile
  2064. ReadArchiveLine:
  2065. FileRead $archivedGLOBALcfgFileHandle $lineDataHandle
  2066. ifErrors DoneReadingArchiveFile 0
  2067. ; Primary test is that this a live sniffer line.
  2068. ${WordFind} $lineDataHandle "SNFClient.exe" "E+1}" $WordFindResults
  2069. ifErrors 0 FoundLiveArchiveSnifferLine ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2070. ${WordFind} $lineDataHandle "$LicenseID.exe" "E+1}" $WordFindResults
  2071. ifErrors 0 FoundLiveArchiveSnifferLine ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2072. Goto ReadArchiveLine ; go back and get a newline to test.
  2073. FoundLiveArchiveSnifferLine:
  2074. StrCpy $collectedArchiveData "$collectedArchiveData$lineDataHandle" ; If here the line is of interest, even if its just a comment. collect it.
  2075. Goto ReadArchiveLine
  2076. ${ENDIF}
  2077. DoneReadingArchiveFile: ; By this point, either $collectedArchiveData has a bunch of stuff or it doesn't......
  2078. FileClose $archivedGLOBALcfgFileHandle ; Close file.
  2079. StrCpy $lineDataHandle "" ; Clear line data.
  2080. ################################################### END HEAL FROM ARCHIVE DATA COLLECTION PHASE #################################
  2081. ################################################### BEGIN PHASE 1 of the Main Global.cfg File Read. #################################
  2082. clearerrors
  2083. FileOpen $decludeConfigFileHandle "$localSERVDIR\global.cfg" r
  2084. iferrors 0 OpenOK
  2085. clearerrors
  2086. MessageBox MB_OK "Error opening $localSERVDIR\global.cfg file. Do you have the file open?"
  2087. FileClose $decludeConfigFileHandle
  2088. FileOpen $decludeConfigFileHandle "$localSERVDIR\global.cfg" r
  2089. OpenOK:
  2090. FileOpen $phase_FileHandle "$localSERVDIR\phase1global.cfg" w
  2091. KeepReading:
  2092. FileRead $decludeConfigFileHandle $lineDataHandle ; get the first line.
  2093. ifErrors DoneReadingFile 0
  2094. ; Primary test is is this a live sniffer line.
  2095. ${WordFind} $lineDataHandle "SNFClient.exe" "E+1}" $WordFindResults
  2096. ifErrors 0 FoundLiveSnifferLine ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2097. clearerrors
  2098. ${WordFind} $lineDataHandle "$LicenseID.exe" "E+1}" $WordFindResults
  2099. ifErrors 0 FoundLiveOLDSnifferLine ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2100. clearerrors
  2101. ${WordFind} $lineDataHandle "EXTERNAL TEST" "E+1}" $WordFindResults
  2102. ifErrors 0 FoundExternalTestMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2103. clearerrors
  2104. FileWrite $phase_FileHandle $lineDataHandle ; dump line to phase1 file.
  2105. Goto KeepReading ; go back and get a newline to test.
  2106. FoundLiveSnifferLine: ; ok, set TargetSnifferString to be abstract and work for either the new or the old naming convention.
  2107. StrCpy $TargetSnifferString "SNFClient.exe" ; ok, set for regular sniffer....
  2108. Goto TestForWhitespace
  2109. FoundLiveOLDSnifferLine:
  2110. StrCpy $TargetSnifferString "$LicenseID.exe" ; ok, set for regular sniffer....
  2111. TestForWhitespace:
  2112. ; ok, line contains SNFClient.exe or $LicenseID.exe we need to be sure it isn't a comment.
  2113. StrCpy $tempLineHandle $lineDataHandle
  2114. testNextChar:
  2115. StrCpy $FirstCharTestVar $tempLineHandle 1 0
  2116. StrCmp $FirstCharTestVar " " 0 CheckForCommentMarker
  2117. StrCpy $tempLineHandle $tempLineHandle "" 1 ; cut off one char and test again.
  2118. goto testNextChar
  2119. CheckForCommentMarker:
  2120. ; Skipped here because not blank space... so check for comment.
  2121. StrCmp $FirstCharTestVar "#" 0 HandleValidLine
  2122. ; Is a comment. Dump to whatever phase is current.
  2123. ; We don't allow Sniffer commented lines to build up..... so we remove it on this pass.
  2124. ; FileWrite $phase_FileHandle $lineDataHandle ; dump line to phase1 file.
  2125. Goto KeepReading ; go back and get a newline to test.
  2126. HandleValidLine:
  2127. StrCpy $foundAtLeastOneLiveSnifferLine "1" ; set this to defer the phase change if it exists... and if it doesn't then thats ok.
  2128. ; NOTE: Special case..... we've found a valid line. But if we're in ROLLBACK mode... then we don't want to copy this line, in, all valid lines
  2129. ; have been collected from the old file, and will now be deposited. All further valid lines will be skipped. Thus:
  2130. StrCmp $succededAtPlacingArchivedData "1" KeepReading 0 ; This aborts any new information from getting into the file. Get next line.
  2131. StrCmp $healFromOldFile "1" 0 DealWithNormalConditions ; skip forward and handle data.
  2132. ; Ok, we're rolling back, but we haven't depositied data yet.
  2133. FileWrite $phase_FileHandle $collectedArchiveData ; This puts all the valid lines from the archived section in place at the first found
  2134. ; live line of the current page. Since the installer obeyd the protocol, its likely that its
  2135. ; in the correct spot. If not, we'll put it back at the end.
  2136. StrCpy $succededAtPlacingArchivedData "1"
  2137. Goto KeepReading
  2138. DealWithNormalConditions:
  2139. ; Ok, we're here. We have a good line... and we need to alter the path preceding the tag, and the name of the tag.
  2140. ; We MAY be in the same folder.... but we may be in an entirely different folder... it doesn't matter.
  2141. ${WordFind} $lineDataHandle $TargetSnifferString "+1}" $secondHalfOfLine ; load the last bit into the $secondHalfOfLine
  2142. ; now test if its frst char is a white space. If it is, then you're inside quotes, move forward till you find the quote, and then move back till you find it.
  2143. ; It would be nice to have the algorithem just juse this as its solution, but it breaks because the old sniffer versions
  2144. ; encapsulate the authentication inside the quotes.... and you could have 'Program Files' inside the quotes... so you can't trust
  2145. ; a blank to be the pure encapsulator... whats a hack to do...
  2146. ; So we suggest that we take a test to see if there is one ', one ", or one ` in the secondHalfOfLine
  2147. ; if there is we'll take a guess that the encapsulator isn't a blank, but that its a quote.....
  2148. ;${WordFind} $secondHalfOfLine $TargetSnifferString "+1}" $secondHalfOfLine ; load the last bit into the $secondHalfOfLine
  2149. ; Now we need to test to see if we have the authentication string in here.....
  2150. Var /GLOBAL toTheFarRight
  2151. ${WordFind} $secondHalfOfLine $Authentication "+1}" $toTheFarRight ; load the last far right bit into the $toTheFarRight
  2152. ifErrors 0 usefartherEncapsulator
  2153. ; ok, just find the one to the right of the targetSnifferString and use that on the left side.
  2154. StrCpy $encapsulator $secondHalfOfLine 1 0
  2155. Goto GrabLeft
  2156. usefartherEncapsulator: ; ok, well, then if the Authentication is there, then we need to use the quote type to the right of that.
  2157. StrCpy $encapsulator $toTheFarRight 1 0 ; ok, good to go unless its a space... which I don't think you can do if you're using the Auth....
  2158. GrabLeft:
  2159. ; Now we have a character in the encapsulator. Its either a quote, or a whitespace. If its whitespace, then the end of the path on
  2160. ; the other side will be another space..... and if its a quote, it will be a quote... etc....
  2161. ; So get the PRE-part of the line, and grab everything to the right of the last encapsulator var.....
  2162. ;MessageBox MB_OK "The encapsulator is:$encapsulator And the Cut is:$secondHalfOfLine"
  2163. ${WordFind} $lineDataHandle $TargetSnifferString "+1{" $tempLineHandle ; load the first bit into the tempLineHandle.
  2164. ; So tempLineHandle holds the entire preline....before the Name.exe
  2165. ${WordFind} $tempLineHandle $encapsulator "+1{" $firstHalfOfLine ; load the first bit into the tempLineHandle.
  2166. ; Naturally this needs to be rebuilt as..... firsthalf+encapsulator+NEWPATH\NEWEXE+ secondhalf (Which includes the 2nd encapsulator...
  2167. StrCpy $tempLineHandle "$firstHalfOfLine$encapsulator$localINSTDIR\SNFClient.exe$secondHalfOfLine"
  2168. ; Now we replace the previous valid line, with the new path and exe....
  2169. FileWrite $phase_FileHandle $tempLineHandle ; dump line to phase file. ; Since we're just fixing the lines... it should be ok....
  2170. ; MessageBox MB_OK "Inside the valid line: $tempLineHandle phase:$phase"
  2171. ; and at the end if we're in phase 1 then we never found an External test marker... and it doesn't matter.....
  2172. ; and if we're in phase two, then we need to append phase1 and phase2.... the only situation we need phase1 and phase2 sepearte
  2173. ; is if we never get into this part... and have to put in a fresh line somewhere.....
  2174. StrCpy $foundAtLeastOneLiveSnifferLine "1"
  2175. Goto KeepReading ; go back and get a newline to test.
  2176. FoundExternalTestMarker:
  2177. ; Here we've determined that we have found the end of phase one
  2178. ; but if we found a live line, that trumps putting lines after the external test marker....
  2179. StrCmp $foundAtLeastOneLiveSnifferLine "1" 0 Well_SplitPhasesThen
  2180. FileWrite $phase_FileHandle $lineDataHandle ; dump line to phase1 file.
  2181. ; IF thats the case then we just go back to keep reading and don't move the phase file pointer...
  2182. Goto KeepReading
  2183. ; but with no live sniffer lines yet... its a different story, cause we'll need to come back to this break if we don't
  2184. ; find ANY.....
  2185. Well_SplitPhasesThen:
  2186. ; put the external tests marker in phase1 file.
  2187. FileWrite $phase_FileHandle $lineDataHandle ; dump line to phase1 file.
  2188. ; Thus close the phase one marker. And use Phase Two.
  2189. StrCpy $phase "2"
  2190. FileClose $phase_FileHandle
  2191. FileOpen $phase_FileHandle "$localSERVDIR\phase2global.cfg" w
  2192. Goto KeepReading ; go back and get a newline to test.
  2193. DoneReadingFile:
  2194. FileClose $decludeConfigFileHandle ; ok, now we need to know how to reasemble it....
  2195. FileClose $phase_FileHandle
  2196. StrCmp $phase "1" 0 handleRejoinPhases
  2197. ; Ok, well that just means we didn't have a External Test marker... so test if we altered anything.
  2198. StrCmp $foundAtLeastOneLiveSnifferLine "1" 0 AddLineAtStart ; and if we drop in, then we handled live lines....
  2199. Rename "$localSERVDIR\phase1global.cfg" "$localSERVDIR\NEWglobal.cfg" ; set this up so its all the same for the RenamePhase.
  2200. goto RenamePhase ; ok, if so, then we're done then, handle file renaming.
  2201. AddLineAtStart:
  2202. Var /GLOBAL prependFileHandle
  2203. FileOpen $prependFileHandle "$localSERVDIR\NEWglobal.cfg" w
  2204. ${IF} $healFromOldFile = "1" ; then we dump the archived stuff.....
  2205. FileWrite $prependFileHandle "############################### SNIFFER TEST SECTION #################################$\r$\n"
  2206. FileWrite $prependFileHandle $collectedArchiveData ; This puts the old valid lines back..... Its the only extra condition
  2207. ${ELSE} ; then write the new data
  2208. FileWrite $prependFileHandle "############################### SNIFFER TEST SECTION #################################$\r$\n"
  2209. FileWrite $prependFileHandle 'SNIFFER external nonzero "$localINSTDIR\SNFClient.exe"$\t12$\t0$\r$\n'
  2210. ${ENDIF} ; if the data existed and a valid line was found, it would have been inserted.
  2211. ; now dump it all in after....
  2212. FileOpen $decludeConfigFileHandle "$localSERVDIR\global.cfg" r ; reopen..
  2213. ReadForPrePendNewLine:
  2214. FileRead $decludeConfigFileHandle $lineDataHandle ; get new line..
  2215. iferrors closeUpThePrepend 0 ; check for EOF
  2216. FileWrite $prependFileHandle $lineDataHandle ; NO? Ok write the line to the new file.
  2217. Goto ReadForPrePendNewLine ; go back for more.
  2218. closeUpThePrepend: ; time to lock up
  2219. FileClose $decludeConfigFileHandle
  2220. FileClose $prependFileHandle
  2221. Goto RenamePhase ; go and rename on top of the old file.
  2222. ; Ok, but if we were in a phase 2 read.... it meant
  2223. ; that we found an external test marker.... but we could have fond live lines....
  2224. handleRejoinPhases:
  2225. FileOpen $prependFileHandle "$localSERVDIR\NEWglobal.cfg" w ; open target....
  2226. FileOpen $phase_FileHandle "$localSERVDIR\phase1global.cfg" r ; reopen..
  2227. ReadForAppendPhaseOneLines:
  2228. FileRead $phase_FileHandle $lineDataHandle ; get new line..
  2229. iferrors closeUpPhaseOneAppend 0 ; check for EOF
  2230. FileWrite $prependFileHandle $lineDataHandle ; NO? Ok write the line to the new file.
  2231. Goto ReadForAppendPhaseOneLines ; go back for more.
  2232. closeUpPhaseOneAppend: ; time to lock up
  2233. FileClose $phase_FileHandle
  2234. ; ok,If we have a phase one with no sniffer reference, and may or may not have one in the phase2 file....
  2235. ; or a phase two that HAS the sniffer references.... then we just need to add 2 to 1 and rename.
  2236. ; So find if we need to INSERT or just append phase2
  2237. StrCmp $foundAtLeastOneLiveSnifferLine "1" FuseThePhaseBreak 0 ; if we jump then no extra is required....
  2238. ; but if we fall through we need to insert.....and either ROLLBACK or insert fresh....
  2239. ${IF} $healFromOldFile = "1" ; then we dump the archived stuff.....
  2240. FileWrite $prependFileHandle $collectedArchiveData ; This puts the old valid lines back..... Its the only extra condition
  2241. ${ELSE} ; then write the new data
  2242. FileWrite $prependFileHandle 'SNIFFER external nonzero "$localINSTDIR\SNFClient.exe"$\t12$\t0$\r$\n'
  2243. ${ENDIF} ; if the data existed and a valid line was found, it would have been inserted.
  2244. ; and drop into appending phase2
  2245. FuseThePhaseBreak:
  2246. FileOpen $phase_FileHandle "$localSERVDIR\phase2global.cfg" r ; reopen..
  2247. ReadForAppendPhaseTwoLines:
  2248. FileRead $phase_FileHandle $lineDataHandle ; get new line..
  2249. iferrors closeUpPhaseTwoAppend 0 ; check for EOF
  2250. FileWrite $prependFileHandle $lineDataHandle ; NO? Ok write the line to the new file.
  2251. Goto ReadForAppendPhaseTwoLines ; go back for more.
  2252. closeUpPhaseTwoAppend: ; time to lock up
  2253. FileClose $phase_FileHandle
  2254. FileClose $prependFileHandle
  2255. goto RenamePhase ; ok, if so, then we're done then, handle file renaming.
  2256. RenamePhase:
  2257. StrCpy $healFromOldFile "0" ; set this so that it doesn't try on the next call to this function.
  2258. ifFileExists "$localSERVDIR\pre_snifferinstall_global.cfg.log" 0 +2
  2259. Delete "$localSERVDIR\pre_snifferinstall_global.cfg.log"
  2260. Rename "$localSERVDIR\global.cfg" "$localSERVDIR\pre_snifferinstall_global.cfg.log"
  2261. Rename "$localSERVDIR\NEWglobal.cfg" "$localSERVDIR\global.cfg"
  2262. ifFileExists "$localSERVDIR\phase1global.cfg" 0 +2
  2263. Delete "$localSERVDIR\phase1global.cfg"
  2264. ifFileExists "$localSERVDIR\phase2global.cfg" 0 +2
  2265. Delete "$localSERVDIR\phase2global.cfg"
  2266. ifFileExists "$localSERVDIR\NEWglobal.cfg" 0 +2
  2267. Delete "$localSERVDIR\NEWglobal.cfg"
  2268. Return
  2269. FunctionEnd
  2270. # See editglobalCFG for documentation and explanation... this is the same but with a un. prepended.....
  2271. Function un.editglobalCFG
  2272. StrCpy $collectedArchiveData "" ; set for default.
  2273. StrCpy $succededAtPlacingArchivedData "0"
  2274. ;VAR /GLOBAL decludeConfigFileHandle ; the existing live file....
  2275. ;VAR /GLOBAL phase_FileHandle ; holds the first half up to the External Tests or pending no External Test line... we have the entire file here.
  2276. ;VAR /GLOBAL phase
  2277. ;VAR /GLOBAL TargetSnifferString ; could be SNFClient.exe or $LicenseID.exe
  2278. StrCpy $phase "1" ; start in phase 1
  2279. # Identify live sniffer lines, and heal them if possible.
  2280. ;Var /GLOBAL foundAtLeastOneLiveSnifferLine
  2281. StrCpy $foundAtLeastOneLiveSnifferLine "0" ; defaults to no.....
  2282. ; Var /GLOBAL ShortPathTempVar ; Defined earlier ... use this to hold the Short Windows Progr~1 path references...
  2283. ;GetFullPathName /SHORT $localINSTDIR $INSTDIR ; for windows greeking. ; Seed with the default values.
  2284. ${un.handleShortPath} $localINSTDIR $INSTDIR
  2285. ;StrCpy $localINSTDIR $INSTDIR ; Seed the default values.
  2286. ;GetFullPathName /SHORT $localSERVDIR $SNFServerInstallDir ; for windows greeking. ; Seed with the default values.
  2287. ${un.handleShortPath} $localSERVDIR $SNFServerInstallDir
  2288. ;StrCpy $localSERVDIR $SNFServerInstallDir ; Seed with the default values.
  2289. ;Var /GLOBAL lineDataHandle
  2290. ;Var /GLOBAL WordFindResults
  2291. ;Var /GLOBAL FirstCharTestVar
  2292. ;Var /GLOBAL tempLineHandle ; holds a manipulated version of the line as we test it....
  2293. ;Var /GLOBAL secondHalfOfLine ; holds the other side to rejoin it after we replace....
  2294. ;Var /GLOBAL firstHalfOfLine ; holds all chars up to the encapsulator.
  2295. ;Var /GLOBAL encapsulator ; holds the type of quote if its quoted...
  2296. ################################################## HEAL FROM ARCHIVE DATA COLLECTION PHASE #######################################
  2297. ${IF} $healFromOldFile = "1"
  2298. ## Then you need to strip and make temporary file for the stuff to put back.
  2299. IfFileExists $archivedGLOBALcfgPath 0 DoneReadingArchiveFile
  2300. FileOpen $archivedGLOBALcfgFileHandle $archivedGLOBALcfgPath r
  2301. iferrors 0 +3
  2302. MessageBox MB_OK "Unable to restructure Decludes global.cfg file from the rollback archive."
  2303. Goto DoneReadingArchiveFile
  2304. ReadArchiveLine:
  2305. FileRead $archivedGLOBALcfgFileHandle $lineDataHandle
  2306. ifErrors DoneReadingArchiveFile 0
  2307. ; Primary test is that this a live sniffer line.
  2308. ${un.WordFind} $lineDataHandle "SNFClient.exe" "E+1}" $WordFindResults
  2309. ifErrors 0 FoundLiveArchiveSnifferLine ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2310. ${un.WordFind} $lineDataHandle "$LicenseID.exe" "E+1}" $WordFindResults
  2311. ifErrors 0 FoundLiveArchiveSnifferLine ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2312. Goto ReadArchiveLine ; go back and get a newline to test.
  2313. FoundLiveArchiveSnifferLine:
  2314. StrCpy $collectedArchiveData "$collectedArchiveData$lineDataHandle" ; If here the line is of interest, even if its just a comment. collect it.
  2315. Goto ReadArchiveLine
  2316. ${ENDIF}
  2317. DoneReadingArchiveFile: ; By this point, either $collectedArchiveData has a bunch of stuff or it doesn't......
  2318. FileClose $archivedGLOBALcfgFileHandle ; Close file.
  2319. StrCpy $lineDataHandle "" ; Clear line data.
  2320. ################################################### END HEAL FROM ARCHIVE DATA COLLECTION PHASE #################################
  2321. ################################################### BEGIN PHASE 1 of the Main Global.cfg File Read. #################################
  2322. FileOpen $decludeConfigFileHandle "$SNFServerInstallDir\global.cfg" r
  2323. iferrors 0 OpenOK
  2324. clearerrors
  2325. MessageBox MB_OK "Error opening $SNFServerInstallDir\global.cfg file. Do you have the file open?"
  2326. FileClose $decludeConfigFileHandle
  2327. FileOpen $decludeConfigFileHandle "$SNFServerInstallDir\global.cfg" r
  2328. OpenOK:
  2329. FileOpen $phase_FileHandle "$SNFServerInstallDir\phase1global.cfg" w
  2330. KeepReading:
  2331. FileRead $decludeConfigFileHandle $lineDataHandle ; get the first line.
  2332. ifErrors DoneReadingFile 0
  2333. ; Primary test is is this a live sniffer line?
  2334. ${un.WordFind} $lineDataHandle "SNFClient.exe" "E+1}" $WordFindResults
  2335. ifErrors 0 FoundLiveSnifferLine ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2336. clearerrors
  2337. ${un.WordFind} $lineDataHandle "$LicenseID.exe" "E+1}" $WordFindResults
  2338. ifErrors 0 FoundLiveOLDSnifferLine ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2339. clearerrors
  2340. ${un.WordFind} $lineDataHandle "EXTERNAL TEST" "E+1}" $WordFindResults
  2341. ifErrors 0 FoundExternalTestMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2342. clearerrors
  2343. FileWrite $phase_FileHandle $lineDataHandle ; dump line to phase1 file.
  2344. Goto KeepReading ; go back and get a newline to test.
  2345. FoundLiveSnifferLine: ; ok, set TargetSnifferString to be abstract and work for either the new or the old naming convention.
  2346. StrCpy $TargetSnifferString "SNFClient.exe" ; ok, set for regular sniffer....
  2347. Goto TestForWhitespace
  2348. FoundLiveOLDSnifferLine:
  2349. StrCpy $TargetSnifferString "$LicenseID.exe" ; ok, set for regular sniffer....
  2350. TestForWhitespace:
  2351. ; ok, line contains SNFClient.exe or $LicenseID.exe we need to be sure it isn't a comment.
  2352. StrCpy $tempLineHandle $lineDataHandle
  2353. testNextChar:
  2354. StrCpy $FirstCharTestVar $tempLineHandle 1 0
  2355. StrCmp $FirstCharTestVar " " 0 CheckForCommentMarker
  2356. StrCpy $tempLineHandle $tempLineHandle "" 1 ; cut off one char and test again.
  2357. goto testNextChar
  2358. CheckForCommentMarker:
  2359. ; Skipped here because not blank space... so check for comment.
  2360. StrCmp $FirstCharTestVar "#" 0 HandleValidLine
  2361. ; Is a comment. Dump to whatever phase is current.
  2362. ; We don't allow Sniffer commented lines to build up..... so we remove it on this pass.
  2363. ; FileWrite $phase_FileHandle $lineDataHandle ; dump line to phase1 file.
  2364. Goto KeepReading ; go back and get a newline to test.
  2365. HandleValidLine:
  2366. StrCpy $foundAtLeastOneLiveSnifferLine "1" ; set this to defer the phase change if it exists... and if it doesn't then thats ok.
  2367. ; NOTE: Special case..... we've found a valid line. But if we're in ROLLBACK mode... then we don't want to copy this line, in, all valid lines
  2368. ; have been collected from the old file, and will now be deposited. All further valid lines will be skipped. Thus:
  2369. StrCmp $succededAtPlacingArchivedData "1" KeepReading 0 ; This aborts any new information from getting into the file. Get next line.
  2370. StrCmp $healFromOldFile "1" 0 DealWithNormalConditions ; skip forward and handle data.
  2371. ; Ok, we're rolling back, but we haven't depositied data yet.
  2372. FileWrite $phase_FileHandle $collectedArchiveData ; This puts all the valid lines from the archived section in place at the first found
  2373. ; live line of the current page. Since the installer obeyd the protocol, its likely that its
  2374. ; in the correct spot. If not, we'll put it back at the end.
  2375. StrCpy $succededAtPlacingArchivedData "1"
  2376. Goto KeepReading
  2377. DealWithNormalConditions:
  2378. ; Ok, we're here. We have a good line... and we need to alter the path preceding the tag, and the name of the tag.
  2379. ; We MAY be in the same folder.... but we may be in an entirely different folder... it doesn't matter.
  2380. ${un.WordFind} $lineDataHandle $TargetSnifferString "+1}" $secondHalfOfLine ; load the last bit into the $secondHalfOfLine
  2381. ; now test if its frst char is a white space. If it is, then you're inside quotes, move forward till you find the quote, and then move back till you find it.
  2382. ; It would be nice to have the algorithem just juse this as its solution, but it breaks because the old sniffer versions
  2383. ; encapsulate the authentication inside the quotes.... and you could have 'Program Files' inside the quotes... so you can't trust
  2384. ; a blank to be the pure encapsulator... whats a hack to do...
  2385. ; So we suggest that we take a test to see if there is one ', one ", or one ` in the secondHalfOfLine
  2386. ; if there is we'll take a guess that the encapsulator isn't a blank, but that its a quote.....
  2387. ;${WordFind} $secondHalfOfLine $TargetSnifferString "+1}" $secondHalfOfLine ; load the last bit into the $secondHalfOfLine
  2388. ; Now we need to test to see if we have the authentication string in here.....
  2389. ; Var /GLOBAL toTheFarRight
  2390. ${un.WordFind} $secondHalfOfLine $Authentication "+1}" $toTheFarRight ; load the last far right bit into the $toTheFarRight
  2391. ifErrors 0 usefartherEncapsulator
  2392. ; ok, just find the one to the right of the targetSnifferString and use that on the left side.
  2393. StrCpy $encapsulator $secondHalfOfLine 1 0
  2394. Goto GrabLeft
  2395. usefartherEncapsulator: ; ok, well, then if the Authentication is there, then we need to use the quote type to the right of that.
  2396. StrCpy $encapsulator $toTheFarRight 1 0 ; ok, good to go unless its a space... which I don't think you can do if you're using the Auth....
  2397. GrabLeft:
  2398. ; Now we have a character in the encapsulator. Its either a quote, or a whitespace. If its whitespace, then the end of the path on
  2399. ; the other side will be another space..... and if its a quote, it will be a quote... etc....
  2400. ; So get the PRE-part of the line, and grab everything to the right of the last encapsulator var.....
  2401. ;MessageBox MB_OK "The encapsulator is:$encapsulator And the Cut is:$secondHalfOfLine"
  2402. ${un.WordFind} $lineDataHandle $TargetSnifferString "+1{" $tempLineHandle ; load the first bit into the tempLineHandle.
  2403. ; So tempLineHandle holds the entire preline....before the Name.exe
  2404. ${un.WordFind} $tempLineHandle $encapsulator "+1{" $firstHalfOfLine ; load the first bit into the tempLineHandle.
  2405. ; Naturally this needs to be rebuilt as..... firsthalf+encapsulator+NEWPATH\NEWEXE+ secondhalf (Which includes the 2nd encapsulator...
  2406. StrCpy $tempLineHandle "$firstHalfOfLine$encapsulator$localINSTDIR\SNFClient.exe$secondHalfOfLine"
  2407. ; Now we replace the previous valid line, with the new path and exe....
  2408. FileWrite $phase_FileHandle $tempLineHandle ; dump line to phase file. ; Since we're just fixing the lines... it should be ok....
  2409. ;MessageBox MB_OK "Inside the valid line: $tempLineHandle phase:$phase"
  2410. ; and at the end if we're in phase 1 then we never found an External test marker... and it doesn't matter.....
  2411. ; and if we're in phase two, then we need to append phase1 and phase2.... the only situation we need phase1 and phase2 sepearte
  2412. ; is if we never get into this part... and have to put in a fresh line somewhere.....
  2413. StrCpy $foundAtLeastOneLiveSnifferLine "1"
  2414. Goto KeepReading ; go back and get a newline to test.
  2415. FoundExternalTestMarker:
  2416. ; Here we've determined that we have found the end of phase one
  2417. ; but if we found a live line, that trumps putting lines after the external test marker....
  2418. StrCmp $foundAtLeastOneLiveSnifferLine "1" 0 Well_SplitPhasesThen
  2419. FileWrite $phase_FileHandle $lineDataHandle ; dump line to phase1 file.
  2420. ; IF thats the case then we just go back to keep reading and don't move the phase file pointer...
  2421. Goto KeepReading
  2422. ; but with no live sniffer lines yet... its a different story, cause we'll need to come back to this break if we don't
  2423. ; find ANY.....
  2424. Well_SplitPhasesThen:
  2425. ; put the external tests marker in phase1 file.
  2426. FileWrite $phase_FileHandle $lineDataHandle ; dump line to phase1 file.
  2427. ; Thus close the phase one marker. And use Phase Two.
  2428. StrCpy $phase "2"
  2429. FileClose $phase_FileHandle
  2430. FileOpen $phase_FileHandle "$SNFServerInstallDir\phase2global.cfg" w
  2431. Goto KeepReading ; go back and get a newline to test.
  2432. DoneReadingFile:
  2433. FileClose $decludeConfigFileHandle ; ok, now we need to know how to reasemble it....
  2434. FileClose $phase_FileHandle
  2435. StrCmp $phase "1" 0 handleRejoinPhases
  2436. ; Ok, well that just means we didn't have a External Test marker... so test if we altered anything.
  2437. StrCmp $foundAtLeastOneLiveSnifferLine "1" 0 AddLineAtStart ; and if we drop in, then we handled live lines....
  2438. Rename "$SNFServerInstallDir\phase1global.cfg" "$SNFServerInstallDir\NEWglobal.cfg" ; set this up so its all the same for the RenamePhase.
  2439. goto RenamePhase ; ok, if so, then we're done then, handle file renaming.
  2440. AddLineAtStart:
  2441. ; Var /GLOBAL prependFileHandle
  2442. FileOpen $prependFileHandle "$SNFServerInstallDir\NEWglobal.cfg" w
  2443. ${IF} $healFromOldFile = "1" ; then we dump the archived stuff.....
  2444. FileWrite $prependFileHandle "############################### SNIFFER TEST SECTION #################################$\r$\n"
  2445. FileWrite $prependFileHandle $collectedArchiveData ; This puts the old valid lines back..... Its the only extra condition
  2446. ${ELSE} ; then write the new data
  2447. FileWrite $prependFileHandle "############################### SNIFFER TEST SECTION #################################$\r$\n"
  2448. FileWrite $prependFileHandle 'SNIFFER external nonzero "$INSTDIR\SNFClient.exe"$\t12$\t0$\r$\n'
  2449. ${ENDIF} ; if the data existed and a valid line was found, it would have been inserted.
  2450. ; now dump it all in after....
  2451. FileOpen $decludeConfigFileHandle "$SNFServerInstallDir\global.cfg" r ; reopen..
  2452. ReadForPrePendNewLine:
  2453. FileRead $decludeConfigFileHandle $lineDataHandle ; get new line..
  2454. iferrors closeUpThePrepend 0 ; check for EOF
  2455. FileWrite $prependFileHandle $lineDataHandle ; NO? Ok write the line to the new file.
  2456. Goto ReadForPrePendNewLine ; go back for more.
  2457. closeUpThePrepend: ; time to lock up
  2458. FileClose $decludeConfigFileHandle
  2459. FileClose $prependFileHandle
  2460. Goto RenamePhase ; go and rename on top of the old file.
  2461. ; Ok, but if we were in a phase 2 read.... it meant
  2462. ; that we found an external test marker.... but we could have fond live lines....
  2463. handleRejoinPhases:
  2464. FileOpen $prependFileHandle "$SNFServerInstallDir\NEWglobal.cfg" w ; open target....
  2465. FileOpen $phase_FileHandle "$SNFServerInstallDir\phase1global.cfg" r ; reopen..
  2466. ReadForAppendPhaseOneLines:
  2467. FileRead $phase_FileHandle $lineDataHandle ; get new line..
  2468. iferrors closeUpPhaseOneAppend 0 ; check for EOF
  2469. FileWrite $prependFileHandle $lineDataHandle ; NO? Ok write the line to the new file.
  2470. Goto ReadForAppendPhaseOneLines ; go back for more.
  2471. closeUpPhaseOneAppend: ; time to lock up
  2472. FileClose $phase_FileHandle
  2473. ; ok,If we have a phase one with no sniffer reference, and may or may not have one in the phase2 file....
  2474. ; or a phase two that HAS the sniffer references.... then we just need to add 2 to 1 and rename.
  2475. ; So find if we need to INSERT or just append phase2
  2476. StrCmp $foundAtLeastOneLiveSnifferLine "1" FuseThePhaseBreak 0 ; if we jump then no extra is required....
  2477. ; but if we fall through we need to insert.....and either ROLLBACK or insert fresh....
  2478. ${IF} $healFromOldFile = "1" ; then we dump the archived stuff.....
  2479. FileWrite $prependFileHandle $collectedArchiveData ; This puts the old valid lines back..... Its the only extra condition
  2480. ${ELSE} ; then write the new data
  2481. FileWrite $prependFileHandle 'SNIFFER external nonzero "$localINSTDIR\SNFClient.exe"$\t12$\t0$\r$\n'
  2482. ${ENDIF} ; if the data existed and a valid line was found, it would have been inserted.
  2483. ; and drop into appending phase2
  2484. FuseThePhaseBreak:
  2485. FileOpen $phase_FileHandle "$SNFServerInstallDir\phase2global.cfg" r ; reopen..
  2486. ReadForAppendPhaseTwoLines:
  2487. FileRead $phase_FileHandle $lineDataHandle ; get new line..
  2488. iferrors closeUpPhaseTwoAppend 0 ; check for EOF
  2489. FileWrite $prependFileHandle $lineDataHandle ; NO? Ok write the line to the new file.
  2490. Goto ReadForAppendPhaseTwoLines ; go back for more.
  2491. closeUpPhaseTwoAppend: ; time to lock up
  2492. FileClose $phase_FileHandle
  2493. FileClose $prependFileHandle
  2494. goto RenamePhase ; ok, if so, then we're done then, handle file renaming.
  2495. RenamePhase:
  2496. StrCpy $healFromOldFile "0" ; set this so that it doesn't try on the next call to this function.
  2497. ifFileExists "$SNFServerInstallDir\pre_snifferinstall_global.cfg.log" 0 +2
  2498. Delete "$SNFServerInstallDir\pre_snifferinstall_global.cfg.log"
  2499. Rename "$SNFServerInstallDir\global.cfg" "$SNFServerInstallDir\pre_snifferinstall_global.cfg.log"
  2500. Rename "$SNFServerInstallDir\NEWglobal.cfg" "$SNFServerInstallDir\global.cfg"
  2501. ifFileExists "$SNFServerInstallDir\phase1global.cfg" 0 +2
  2502. Delete "$SNFServerInstallDir\phase1global.cfg"
  2503. ifFileExists "$SNFServerInstallDir\phase2global.cfg" 0 +2
  2504. Delete "$SNFServerInstallDir\phase2global.cfg"
  2505. ifFileExists "$SNFServerInstallDir\NEWglobal.cfg" 0 +2
  2506. Delete "$SNFServerInstallDir\NEWglobal.cfg"
  2507. Return
  2508. FunctionEnd
  2509. Function editMXGuardINI
  2510. ; Ok we must have detected MXGuard's ini file. Therefore we are going to run a strip and fix on the MXGuard.ini file.
  2511. VAR /GLOBAL newMXGuardINIFileHandle
  2512. VAR /GLOBAL MXGuardINIFileHandle
  2513. VAR /GLOBAL InsertAuthenticationString ; format this initially, and stop it with the restore value if we execute that paragraph.
  2514. VAR /GLOBAL InsertPathString ; format this initially, and stop it with the restore value if we execute that paragraph.
  2515. ; declared in the global.cfg editor that uses the same construct
  2516. ;Var /GLOBAL registryTempData
  2517. ;Var /GLOBAL lineDataHandle
  2518. ;Var /GLOBAL WordFindResults
  2519. ;Var /Global FirstCharTestVar
  2520. ;Var /GLOBAL localINSTDIR
  2521. ;Var /GLOBAL localSERVDIR
  2522. ;StrCpy $localINSTDIR $INSTDIR ; Seed the default values.
  2523. ;StrCpy $localSERVDIR $SNFServerInstallDir ; Seed with the default values.
  2524. ; Var /GLOBAL ShortPathTempVar ; Defined earlier ... use this to hold the Short Windows Progr~1 path references...
  2525. ;GetFullPathName /SHORT $localINSTDIR $INSTDIR ; for windows greeking. ; Seed with the default values.
  2526. ${handleShortPath} $localINSTDIR $INSTDIR
  2527. ;StrCpy $localINSTDIR $INSTDIR ; Seed the default values.
  2528. ;GetFullPathName /SHORT $localSERVDIR $SNFServerInstallDir ; for windows greeking. ; Seed with the default values.
  2529. ${handleShortPath} $localSERVDIR $SNFServerInstallDir
  2530. ;StrCpy $localSERVDIR $SNFServerInstallDir ; Seed with the default values.
  2531. ## ADDING sensitivity to the functions being called to enable them to look up the proper path values in the event that the
  2532. ## rollback sequence is not in the current INSTDIR and $SNFServerInstallDir locations. i.e. Those parsing functions need to be able
  2533. ## to find the correct file to be editing. If its rolling back an older version cross platform, then it needs to redefine the file its
  2534. ## targeting, not just assume that its in the INSTDIR or the $SNFServerInstallDir. I added two registry keys to the EndRollbackSequence
  2535. ## subroutine called SRS_INSTDIR and SRS_SERVDIR to cover the lookup during rollback....since by this point INSTDIR is defined,
  2536. ## just having SRS_INSTDIR different from INSTDIR should be enough key to use the SRS_INSTDIR.... and if the SRS_INSTDIR doesnt' exist,
  2537. ## ( because it wouldn't be entered until the end of the rollback sequence, then the functions will know they are in the new install, and
  2538. ## will use the current INSTDIR as their paths.....
  2539. Clearerrors
  2540. ReadRegStr $registryTempData HKLM "Software\MessageSniffer" "SRS_INSTDIR"
  2541. iferrors 0 handleReset
  2542. goto doneCheckingRollbackVars ; the keys didn't exist so don't hijack.
  2543. handleReset:
  2544. ; they exist so hijack. i.e. Anytime a rollback file exists, ITS local pointers to the relevant INSTDIR and SERVDIR will be valid.
  2545. ; because when you're done running the rollback, the markers are gone. And a fresh install will replace relevent markers. Even if its
  2546. ; in the same spot.
  2547. StrCpy $localINSTDIR $registryTempData
  2548. ReadRegStr $registryTempData HKLM "Software\MessageSniffer" "SRS_SERVDIR"
  2549. StrCpy $localSERVDIR $registryTempData
  2550. ${handleShortPath} $localINSTDIR $localINSTDIR
  2551. ${handleShortPath} $localSERVDIR $localSERVDIR
  2552. doneCheckingRollbackVars:
  2553. # Initialize these to the normal values as if this was an install....
  2554. StrCpy $InsertAuthenticationString "$Authentication$\r$\n"
  2555. StrCpy $InsertPathString "$localINSTDIR\SNFClient.exe$\r$\n"
  2556. ## But if its a restore, then this will execute and overwrite the above two vars......
  2557. ## The strip and fix will either put the new values that are necessary for the .exe's to function, or it will
  2558. ## datamine the old file and insert into the existing file, the new values for the three editable line items pertaining
  2559. ## to sniffer.
  2560. ################################################## HEAL FROM ARCHIVE DATA COLLECTION PHASE #######################################
  2561. ${IF} $healFromOldFile = "1"
  2562. ## Then you need to strip and make temporary file for the stuff to put back.
  2563. clearerrors
  2564. IfFileExists $archivedMXGUARDiniPath 0 DoneReadingArchiveFile
  2565. FileOpen $archivedMXGUARDiniFileHandle $archivedMXGUARDiniPath r
  2566. iferrors 0 ReadArchiveLine
  2567. MessageBox MB_OK "Unable to read MXGuard's MXGuard.ini file from the rollback archive: $archivedMXGUARDiniPath"
  2568. Goto DoneReadingArchiveFile
  2569. ReadArchiveLine:
  2570. FileRead $archivedMXGUARDiniFileHandle $lineDataHandle
  2571. ifErrors DoneReadingArchiveFile 0
  2572. ${WordFind} $lineDataHandle "[Sniffer]" "E+1}" $WordFindResults
  2573. ifErrors 0 FoundArchivedTestMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2574. Goto ReadArchiveLine ; go back and get a newline to test.
  2575. FoundArchivedTestMarker:
  2576. ; Ok, we're here and we need to read until we get the old AuthCode..... and store it...
  2577. LookForAuth:
  2578. FileRead $archivedMXGUARDiniFileHandle $lineDataHandle
  2579. ${WordFind} $lineDataHandle "AuthCode=" "E+1}" $WordFindResults
  2580. ifErrors LookForAuth 0 ; errors meant not in line...go back and look for Auth If we found it, then go to handle. Otherwise drop through
  2581. StrCpy $InsertAuthenticationString $WordFindResults ; Save the insertable Authentication String.
  2582. LookForPath:
  2583. FileRead $archivedMXGUARDiniFileHandle $lineDataHandle
  2584. ${WordFind} $lineDataHandle "PathToEXE=" "E+1}" $WordFindResults
  2585. ifErrors LookForPath 0 ; errors meant not in line...go back and look for Auth If we found it, then go to handle. Otherwise drop through
  2586. StrCpy $InsertPathString $WordFindResults ; Save the insertable Authentication String.
  2587. ${ENDIF}
  2588. DoneReadingArchiveFile: ; By this point, either $collectedArchiveData has a bunch of stuff or it doesn't......
  2589. FileClose $archivedMXGUARDiniFileHandle ; Close file.
  2590. StrCpy $lineDataHandle "" ; Clear line data.
  2591. ################################################### END HEAL FROM ARCHIVE DATA COLLECTION PHASE #################################
  2592. # Open the current files.....
  2593. FileOpen $MXGuardINIFileHandle "$localSERVDIR\mxGuard.ini" r
  2594. ;MessageBox MB_OK "Opening $SNFServerInstallDir\mxGuard.ini"
  2595. # The soon to be edited file...
  2596. FileOpen $newMXGuardINIFileHandle "$localSERVDIR\NEWmxGuard.ini" w
  2597. ;MessageBox MB_OK "Opening $SNFServerInstallDir\NEWmxGuard.ini"
  2598. clearerrors
  2599. KeepReading:
  2600. FileRead $MXGuardINIFileHandle $lineDataHandle
  2601. ifErrors DoneReadingFile 0
  2602. ${WordFind} $lineDataHandle "[Sniffer]" "E+1}" $WordFindResults
  2603. ifErrors 0 FoundExternalTestMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2604. FileWrite $newMXGuardINIFileHandle $lineDataHandle ; dump line to new file.
  2605. Goto KeepReading ; go back and get a newline to test.
  2606. FoundExternalTestMarker:
  2607. ; First put the marker line. "[Sniffer]"
  2608. FileWrite $newMXGuardINIFileHandle $lineDataHandle ; dump line to new file.
  2609. ; Then write teh Auth line.
  2610. FileWrite $newMXGuardINIFileHandle "AuthCode=$InsertAuthenticationString"
  2611. ; Read the line off the file, but don't write it.....
  2612. FileRead $MXGuardINIFileHandle $lineDataHandle
  2613. ; Then write the Path line.
  2614. FileWrite $newMXGuardINIFileHandle "PathToEXE=$InsertPathString"
  2615. ; Read the line off the file, but don't write it.....
  2616. FileRead $MXGuardINIFileHandle $lineDataHandle
  2617. ; DoneWritingEntry:
  2618. ; now dump the rest of the file.
  2619. KeepDumping:
  2620. FileRead $MXGuardINIFileHandle $lineDataHandle
  2621. ifErrors DoneDumping 0
  2622. FileWrite $newMXGuardINIFileHandle $lineDataHandle ; dump line to new file.
  2623. Goto KeepDumping ; go back and get a newline to test.
  2624. DoneDumping:
  2625. ; this should be id. Go home.
  2626. FileClose $MXGuardINIFileHandle
  2627. FileClose $newMXGuardINIFileHandle
  2628. ifFileExists "$localSERVDIR\old_mxGuard.ini" 0 +2
  2629. Delete "$localSERVDIR\old_mxGuard.ini"
  2630. Rename "$localSERVDIR\mxGuard.ini" "$localSERVDIR\old_mxGuard.ini"
  2631. Rename "$localSERVDIR\NEWmxGuard.ini" "$localSERVDIR\mxGuard.ini"
  2632. Delete "$localSERVDIR\old_mxGuard.ini"
  2633. StrCpy $healFromOldFile "0" ; Clear flag
  2634. Return
  2635. DoneReadingFile:
  2636. ; this would be an error because no external SNIFFER marker was found. Add marker but notify.
  2637. MessageBox MB_OK "MXGuards INI file seems to be missing the [SNIFFER] section. Adding [SNIFFER] section. "
  2638. FileWrite $newMXGuardINIFileHandle "$\r$\n[SNIFFER]$\r$\n"
  2639. ; Then write teh Auth line.
  2640. FileWrite $newMXGuardINIFileHandle "AuthCode=$InsertAuthenticationString\r$\n"
  2641. ; Then write the Path line.
  2642. FileWrite $newMXGuardINIFileHandle "PathToEXE=$InsertPathString$\r$\n"
  2643. FileClose $newMXGuardINIFileHandle
  2644. FileClose $MXGuardINIFileHandle
  2645. ifFileExists "$localSERVDIR\old_mxGuard.ini" 0 +2
  2646. Delete "$localSERVDIR\old_mxGuard.ini"
  2647. Rename "$localSERVDIR\mxGuard.ini" "$localSERVDIR\old_mxGuard.ini"
  2648. Rename "$localSERVDIR\NEWmxGuard.ini" "$localSERVDIR\mxGuard.ini"
  2649. Delete "$localSERVDIR\old_mxGuard.ini"
  2650. StrCpy $healFromOldFile "0" ; Clear flag
  2651. Return
  2652. FunctionEnd
  2653. # Same as above but needs to re-declared for the uninstaller.
  2654. Function un.editMXGuardINI
  2655. ; Ok we must have detected MXGuard's ini file. Therefore we are going to run a strip and fix on the MXGuard.ini file.
  2656. ; VAR /GLOBAL newMXGuardINIFileHandle
  2657. ; VAR /GLOBAL MXGuardINIFileHandle
  2658. ; VAR /GLOBAL InsertAuthenticationString ; format this initially, and stop it with the restore value if we execute that paragraph.
  2659. ; VAR /GLOBAL InsertPathString ; format this initially, and stop it with the restore value if we execute that paragraph.
  2660. ; declared in the global.cfg editor that uses the same construct
  2661. ;Var /GLOBAL lineDataHandle
  2662. ;Var /GLOBAL WordFindResults
  2663. ;Var /Global FirstCharTestVar
  2664. ;GetFullPathName /SHORT $localINSTDIR $INSTDIR ; for windows greeking. ; Seed with the default values.
  2665. ${un.handleShortPath} $localINSTDIR $INSTDIR
  2666. ;StrCpy $localINSTDIR $INSTDIR ; Seed the default values.
  2667. ;GetFullPathName /SHORT $localSERVDIR $SNFServerInstallDir ; for windows greeking. ; Seed with the default values.
  2668. ${un.handleShortPath} $localSERVDIR $SNFServerInstallDir
  2669. ;StrCpy $localSERVDIR $SNFServerInstallDir ; Seed with the default values.
  2670. # Initialize these to the normal values as if this was an install....
  2671. StrCpy $InsertAuthenticationString "$Authentication$\r$\n"
  2672. StrCpy $InsertPathString "$localINSTDIR\SNFClient.exe$\r$\n"
  2673. ## But if its a restore, then this will execute and overwrite the above two vars......
  2674. ## The strip and fix will either put the new values that are necessary for the .exe's to function, or it will
  2675. ## datamine the old file and insert into the existing file, the new values for the three editable line items pertaining
  2676. ## to sniffer.
  2677. ################################################## HEAL FROM ARCHIVE DATA COLLECTION PHASE #######################################
  2678. ${IF} $healFromOldFile = "1"
  2679. ## Then you need to strip and make temporary file for the stuff to put back.
  2680. clearerrors
  2681. IfFileExists $archivedMXGUARDiniPath 0 DoneReadingArchiveFile
  2682. FileOpen $archivedMXGUARDiniFileHandle $archivedMXGUARDiniPath r
  2683. iferrors 0 ReadArchiveLine
  2684. MessageBox MB_OK "Unable to read MXGuard's MXGuard.ini file from the rollback archive: $archivedMXGUARDiniPath"
  2685. Goto DoneReadingArchiveFile
  2686. ReadArchiveLine:
  2687. FileRead $archivedMXGUARDiniFileHandle $lineDataHandle
  2688. ifErrors DoneReadingArchiveFile 0
  2689. ${un.WordFind} $lineDataHandle "[Sniffer]" "E+1}" $WordFindResults
  2690. ifErrors 0 FoundArchivedTestMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2691. Goto ReadArchiveLine ; go back and get a newline to test.
  2692. FoundArchivedTestMarker:
  2693. ; Ok, we're here and we need to read until we get the old AuthCode..... and store it...
  2694. LookForAuth:
  2695. FileRead $archivedMXGUARDiniFileHandle $lineDataHandle
  2696. ${un.WordFind} $lineDataHandle "AuthCode=" "E+1}" $WordFindResults
  2697. ifErrors LookForAuth 0 ; errors meant not in line...go back and look for Auth If we found it, then go to handle. Otherwise drop through
  2698. StrCpy $InsertAuthenticationString $WordFindResults ; Save the insertable Authentication String.
  2699. LookForPath:
  2700. FileRead $archivedMXGUARDiniFileHandle $lineDataHandle
  2701. ${un.WordFind} $lineDataHandle "PathToEXE=" "E+1}" $WordFindResults
  2702. ifErrors LookForPath 0 ; errors meant not in line...go back and look for Auth If we found it, then go to handle. Otherwise drop through
  2703. StrCpy $InsertPathString $WordFindResults ; Save the insertable Authentication String.
  2704. ${ENDIF}
  2705. DoneReadingArchiveFile: ; By this point, either $collectedArchiveData has a bunch of stuff or it doesn't......
  2706. FileClose $archivedMXGUARDiniFileHandle ; Close file.
  2707. StrCpy $lineDataHandle "" ; Clear line data.
  2708. ################################################### END HEAL FROM ARCHIVE DATA COLLECTION PHASE #################################
  2709. # Open the current files.....
  2710. FileOpen $MXGuardINIFileHandle "$SNFServerInstallDir\mxGuard.ini" r
  2711. ;MessageBox MB_OK "Opening $SNFServerInstallDir\mxGuard.ini"
  2712. # The soon to be edited file...
  2713. FileOpen $newMXGuardINIFileHandle "$SNFServerInstallDir\NEWmxGuard.ini" w
  2714. ;MessageBox MB_OK "Opening $SNFServerInstallDir\NEWmxGuard.ini"
  2715. clearerrors
  2716. KeepReading:
  2717. FileRead $MXGuardINIFileHandle $lineDataHandle
  2718. ifErrors DoneReadingFile 0
  2719. ${un.WordFind} $lineDataHandle "[Sniffer]" "E+1}" $WordFindResults
  2720. ifErrors 0 FoundExternalTestMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2721. FileWrite $newMXGuardINIFileHandle $lineDataHandle ; dump line to new file.
  2722. Goto KeepReading ; go back and get a newline to test.
  2723. FoundExternalTestMarker:
  2724. ; First put the marker line. "[Sniffer]"
  2725. FileWrite $newMXGuardINIFileHandle $lineDataHandle ; dump line to new file.
  2726. ; Then write teh Auth line.
  2727. FileWrite $newMXGuardINIFileHandle "AuthCode=$InsertAuthenticationString"
  2728. ; Read the line off the file, but don't write it.....
  2729. FileRead $MXGuardINIFileHandle $lineDataHandle
  2730. ; Then write the Path line.
  2731. FileWrite $newMXGuardINIFileHandle "PathToEXE=$InsertPathString"
  2732. ; Read the line off the file, but don't write it.....
  2733. FileRead $MXGuardINIFileHandle $lineDataHandle
  2734. ; DoneWritingEntry:
  2735. ; now dump the rest of the file.
  2736. KeepDumping:
  2737. FileRead $MXGuardINIFileHandle $lineDataHandle
  2738. ifErrors DoneDumping 0
  2739. FileWrite $newMXGuardINIFileHandle $lineDataHandle ; dump line to new file.
  2740. Goto KeepDumping ; go back and get a newline to test.
  2741. DoneDumping:
  2742. ; this should be id. Go home.
  2743. FileClose $MXGuardINIFileHandle
  2744. FileClose $newMXGuardINIFileHandle
  2745. ifFileExists "$SNFServerInstallDir\old_mxGuard.ini" 0 +2
  2746. Delete "$SNFServerInstallDir\old_mxGuard.ini"
  2747. Rename "$SNFServerInstallDir\mxGuard.ini" "$SNFServerInstallDir\old_mxGuard.ini"
  2748. Rename "$SNFServerInstallDir\NEWmxGuard.ini" "$SNFServerInstallDir\mxGuard.ini"
  2749. Delete "$SNFServerInstallDir\old_mxGuard.ini"
  2750. StrCpy $healFromOldFile "0" ; Clear flag
  2751. Return
  2752. DoneReadingFile:
  2753. ; this would be an error because no external SNIFFER marker was found. Add marker but notify.
  2754. MessageBox MB_OK "MXGuards INI file seems to be missing the [SNIFFER] section. Adding [SNIFFER] section. "
  2755. FileWrite $newMXGuardINIFileHandle "$\r$\n[SNIFFER]$\r$\n"
  2756. ; Then write teh Auth line.
  2757. FileWrite $newMXGuardINIFileHandle "AuthCode=$InsertAuthenticationString\r$\n"
  2758. ; Then write the Path line.
  2759. FileWrite $newMXGuardINIFileHandle "PathToEXE=$InsertPathString$\r$\n"
  2760. FileClose $newMXGuardINIFileHandle
  2761. FileClose $MXGuardINIFileHandle
  2762. ifFileExists "$SNFServerInstallDir\old_mxGuard.ini" 0 +2
  2763. Delete "$SNFServerInstallDir\old_mxGuard.ini"
  2764. Rename "$SNFServerInstallDir\mxGuard.ini" "$SNFServerInstallDir\old_mxGuard.ini"
  2765. Rename "$SNFServerInstallDir\NEWmxGuard.ini" "$SNFServerInstallDir\mxGuard.ini"
  2766. Delete "$SNFServerInstallDir\old_mxGuard.ini"
  2767. StrCpy $healFromOldFile "0" ; Clear flag
  2768. Return
  2769. FunctionEnd
  2770. Function un.editContentXML
  2771. ; Subroutine that REMOVES the XML to tie in Sniffer to the IceWarp merak\config\content.xml
  2772. ; There are three situations. First the file is empty, Second it doesn't have a sniffer tag, but there are other filters, third it has a sniffer tag.
  2773. ; if Sniffer was installed as an AV filter... then call stripScanDAT will remove that.
  2774. Call un.stripScanXML
  2775. ; and now hande if we're inside the content.xml file.
  2776. Var /GLOBAL IceWarpContentFileHandle ; handle to hold open read file.
  2777. Var /GLOBAL IceWarpAdjustedFileHandle ; new file.
  2778. Var /GLOBAL IceWarpSnifferXMLExists
  2779. Var /GLOBAL TempFilterXML ; this hold a filter paragraph until we're sure we want to commit it....
  2780. Var /GLOBAL didWeOutput ; flag for if we exited normally with output of XML or if we ended file strangely and terminated with no output.
  2781. StrCpy $didWeOutput "0"
  2782. StrCpy $IceWarpSnifferXMLExists "0" ; default flag to false.
  2783. Var /GLOBAL IceWarpContentXMLlinedata ; read data, line by line.
  2784. FileOpen $IceWarpAdjustedFileHandle "$SNFServerInstallDir\config\contentNEW.xml" w
  2785. clearerrors
  2786. IfFileExists "$SNFServerInstallDir\config\content.xml" 0 UnableToFindContentFileXML
  2787. FileOpen $IceWarpContentFileHandle "$SNFServerInstallDir\config\content.xml" r
  2788. iferrors 0 ReadContentLine
  2789. MessageBox MB_OK "Unable to read IceWarps Content.XML file from: $SNFServerInstallDir\config\content.xml"
  2790. Goto DoneReadingContentFile
  2791. ; You can have an empty file. With no headers... so first we either spin through without finding a valid header opener... and then
  2792. ; open and enter our own filter at the end... or we'll find one, and enter into the valid filter sections.
  2793. ReadForProperyHeaderedFilterFile:
  2794. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  2795. ifErrors DoneReadingEmptyFile 0
  2796. ${un.WordFind} $IceWarpContentXMLlinedata "<CONTENTFILTER>" "E+1}" $WordFindResults
  2797. ifErrors 0 ProperlyHeaderedFile ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2798. ; if were here and we're reading lines, then we're not in a SNIFFER FILTER... so we write the line to the new file.
  2799. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  2800. Goto ReadForProperyHeaderedFilterFile ; go back and get a newline to test.
  2801. ProperlyHeaderedFile:
  2802. ; dump header line.
  2803. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  2804. ;Ok, Next line SHOULD be FILTER object.... spin till we get one...
  2805. ReadContentLine:
  2806. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  2807. ifErrors DoneReadingContentFile 0
  2808. ${un.WordFind} $IceWarpContentXMLlinedata "<FILTER>" "E+1}" $WordFindResults
  2809. ifErrors 0 FoundFilterMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2810. ; if were here and we're reading lines, then we're not in a SNIFFER FILTER... so we write the line to the new file.
  2811. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  2812. Goto ReadContentLine ; go back and get a newline to test.
  2813. FoundFilterMarker:
  2814. ; Ok, we're here at a filter header, so its either the SNIFFER FILTER, or its not... so we write to a temp var till we read the title...
  2815. ; because the filter section has a couple lines ahead of the title tag... active y/n etc.... so we need to trap that till we get to
  2816. ; something distinctive.
  2817. StrCpy $TempFilterXML $IceWarpContentXMLlinedata
  2818. LookForTitle:
  2819. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  2820. ifErrors DoneReadingContentFile 0
  2821. ${un.WordFind} $IceWarpContentXMLlinedata "<TITLE>" "E+1}" $WordFindResults
  2822. ifErrors 0 FoundTitleMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2823. StrCpy $TempFilterXML "$TempFilterXML$IceWarpContentXMLlinedata" ; not in line, add to temp buffer.
  2824. Goto LookForTitle ; go back and get a newline to that might hold the title.
  2825. FoundTitleMarker:
  2826. ; Ok, if we popped out and were here, then if we find the title and it IS sniffer.... then we dont' write, and we loop to the next </FILTER>
  2827. ; but if we're NOT sniffer.... then we write the temp string and pop out and continue looping at the top.
  2828. ${un.WordFind} $IceWarpContentXMLlinedata "SNIFFER" "E+1}" $WordFindResults
  2829. ifErrors 0 FoundSnifferSection ; errors meant not in line... If we found it, then go to found-handle. Otherwise drop through
  2830. FileWrite $IceWarpAdjustedFileHandle $TempFilterXML ; Ok, we're not in a sniffer section, so dump the buffer
  2831. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump the current line...
  2832. StrCpy $TempFilterXML "" ; clear the buffer.
  2833. Goto ReadContentLine ; pop out and look for the next filter tag.
  2834. FoundSnifferSection:
  2835. ; if this is the case, we loop till we find the </FILTER> and then we insert the new sniffer code.
  2836. LookForCloseFilter:
  2837. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  2838. ifErrors DoneReadingContentFileWithErrors 0 ; if we exit here output is NOT done... and it probably means an error.
  2839. ${un.WordFind} $IceWarpContentXMLlinedata "</FILTER>" "E+1}" $WordFindResults
  2840. ifErrors 0 FoundCloseFilterMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2841. Goto LookForCloseFilter ; go back and get a newline to that might hold the title.
  2842. FoundCloseFilterMarker:
  2843. ; Ok, we stripped it.
  2844. ; From here on, we dump it all to the file.
  2845. ContinueDumpingFileLines:
  2846. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata ;Grap new line.
  2847. ifErrors DoneReadingContentFile 0 ; if not EOF then exit with output true. We're good and done.
  2848. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump the current line...
  2849. Goto ContinueDumpingFileLines ; and go back for more.
  2850. ; If were here then we called from the first loop section where we were checking for <CONTENTFILTER>
  2851. DoneReadingEmptyFile:
  2852. FileClose $IceWarpContentFileHandle ; Close file.
  2853. FileClose $IceWarpAdjustedFileHandle ; Close file.
  2854. Delete "$SNFServerInstallDir\config\contentNEW.xml"
  2855. Return ; fall through and close files up.
  2856. ; we could jump to here from anywere indicating EOF.... so if if thats the game. We store and swap.
  2857. DoneReadingContentFile:
  2858. FileClose $IceWarpContentFileHandle ; Close file.
  2859. FileClose $IceWarpAdjustedFileHandle ; Close file.
  2860. StrCpy $IceWarpContentXMLlinedata "" ; Clear line data.
  2861. ; Now swap out the files.
  2862. Var /GLOBAL var1
  2863. Var /GLOBAL var2
  2864. Var /GLOBAL var3
  2865. Var /GLOBAL var4
  2866. Var /GLOBAL var5
  2867. Var /GLOBAL var6
  2868. Var /GLOBAL var7
  2869. ${un.GetTime} "" "L" $var1 $var2 $var3 $var4 $var5 $var6 $var7
  2870. Rename "$SNFServerInstallDir\config\content.xml" "$SNFServerInstallDir\config\content_UnInstallLOG_$var1-$var2-$var4.xml"
  2871. Rename "$SNFServerInstallDir\config\contentNEW.xml" "$SNFServerInstallDir\config\content.xml"
  2872. Return
  2873. DoneReadingContentFileWithErrors:
  2874. FileClose $IceWarpContentFileHandle ; Close file.
  2875. FileClose $IceWarpAdjustedFileHandle ; Close file.
  2876. Delete "$SNFServerInstallDir\config\contentNEW.xml"
  2877. Return
  2878. UnableToFindContentFileXML:
  2879. Return
  2880. FunctionEnd
  2881. Function stripContentXML
  2882. ; Subroutine that REMOVES the XML to tie in Sniffer to the IceWarp merak\config\content.xml when installing as AV.. ( and it was pre-instaled )
  2883. ; as a Content Filter.
  2884. ; There are three situations. First the file is empty, Second it doesn't have a sniffer tag, but there are other filters, third it has a sniffer tag.
  2885. ; and now hande if we're inside the content.xml file.
  2886. ;Var /GLOBAL IceWarpContentFileHandle ; handle to hold open read file.
  2887. ;Var /GLOBAL IceWarpAdjustedFileHandle ; new file.
  2888. ;Var /GLOBAL IceWarpSnifferXMLExists
  2889. ;Var /GLOBAL TempFilterXML ; this hold a filter paragraph until we're sure we want to commit it....
  2890. ;Var /GLOBAL didWeOutput ; flag for if we exited normally with output of XML or if we ended file strangely and terminated with no output.
  2891. StrCpy $didWeOutput "0"
  2892. StrCpy $IceWarpSnifferXMLExists "0" ; default flag to false.
  2893. ;Var /GLOBAL IceWarpContentXMLlinedata ; read data, line by line.
  2894. FileOpen $IceWarpAdjustedFileHandle "$SNFServerInstallDir\config\contentNEW.xml" w
  2895. clearerrors
  2896. IfFileExists "$SNFServerInstallDir\config\content.xml" 0 UnableToFindContentFileXML
  2897. FileOpen $IceWarpContentFileHandle "$SNFServerInstallDir\config\content.xml" r
  2898. iferrors 0 ReadContentLine
  2899. MessageBox MB_OK "Unable to read IceWarps Content.XML file from: $SNFServerInstallDir\config\content.xml"
  2900. Goto DoneReadingContentFile
  2901. ; You can have an empty file. With no headers... so first we either spin through without finding a valid header opener... and then
  2902. ; open and enter our own filter at the end... or we'll find one, and enter into the valid filter sections.
  2903. ReadForProperyHeaderedFilterFile:
  2904. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  2905. ifErrors DoneReadingEmptyFile 0
  2906. ${WordFind} $IceWarpContentXMLlinedata "<CONTENTFILTER>" "E+1}" $WordFindResults
  2907. ifErrors 0 ProperlyHeaderedFile ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2908. ; if were here and we're reading lines, then we're not in a SNIFFER FILTER... so we write the line to the new file.
  2909. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  2910. Goto ReadForProperyHeaderedFilterFile ; go back and get a newline to test.
  2911. ProperlyHeaderedFile:
  2912. ; dump header line.
  2913. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  2914. ;Ok, Next line SHOULD be FILTER object.... spin till we get one...
  2915. ReadContentLine:
  2916. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  2917. ifErrors DoneReadingContentFile 0
  2918. ${WordFind} $IceWarpContentXMLlinedata "<FILTER>" "E+1}" $WordFindResults
  2919. ifErrors 0 FoundFilterMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2920. ; if were here and we're reading lines, then we're not in a SNIFFER FILTER... so we write the line to the new file.
  2921. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  2922. Goto ReadContentLine ; go back and get a newline to test.
  2923. FoundFilterMarker:
  2924. ; Ok, we're here at a filter header, so its either the SNIFFER FILTER, or its not... so we write to a temp var till we read the title...
  2925. ; because the filter section has a couple lines ahead of the title tag... active y/n etc.... so we need to trap that till we get to
  2926. ; something distinctive.
  2927. StrCpy $TempFilterXML $IceWarpContentXMLlinedata
  2928. LookForTitle:
  2929. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  2930. ifErrors DoneReadingContentFile 0
  2931. ${WordFind} $IceWarpContentXMLlinedata "<TITLE>" "E+1}" $WordFindResults
  2932. ifErrors 0 FoundTitleMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2933. StrCpy $TempFilterXML "$TempFilterXML$IceWarpContentXMLlinedata" ; not in line, add to temp buffer.
  2934. Goto LookForTitle ; go back and get a newline to that might hold the title.
  2935. FoundTitleMarker:
  2936. ; Ok, if we popped out and were here, then if we find the title and it IS sniffer.... then we dont' write, and we loop to the next </FILTER>
  2937. ; but if we're NOT sniffer.... then we write the temp string and pop out and continue looping at the top.
  2938. ${WordFind} $IceWarpContentXMLlinedata "SNIFFER" "E+1}" $WordFindResults
  2939. ifErrors 0 FoundSnifferSection ; errors meant not in line... If we found it, then go to found-handle. Otherwise drop through
  2940. FileWrite $IceWarpAdjustedFileHandle $TempFilterXML ; Ok, we're not in a sniffer section, so dump the buffer
  2941. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump the current line...
  2942. StrCpy $TempFilterXML "" ; clear the buffer.
  2943. Goto ReadContentLine ; pop out and look for the next filter tag.
  2944. FoundSnifferSection:
  2945. ; if this is the case, we loop till we find the </FILTER> and then we insert the new sniffer code.
  2946. LookForCloseFilter:
  2947. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  2948. ifErrors DoneReadingContentFileWithErrors 0 ; if we exit here output is NOT done... and it probably means an error.
  2949. ${WordFind} $IceWarpContentXMLlinedata "</FILTER>" "E+1}" $WordFindResults
  2950. ifErrors 0 FoundCloseFilterMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  2951. Goto LookForCloseFilter ; go back and get a newline to that might hold the title.
  2952. FoundCloseFilterMarker:
  2953. ; Ok, we stripped it.
  2954. ; From here on, we dump it all to the file.
  2955. ContinueDumpingFileLines:
  2956. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata ;Grap new line.
  2957. ifErrors DoneReadingContentFile 0 ; if not EOF then exit with output true. We're good and done.
  2958. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump the current line...
  2959. Goto ContinueDumpingFileLines ; and go back for more.
  2960. ; If were here then we called from the first loop section where we were checking for <CONTENTFILTER>
  2961. DoneReadingEmptyFile:
  2962. FileClose $IceWarpContentFileHandle ; Close file.
  2963. FileClose $IceWarpAdjustedFileHandle ; Close file.
  2964. Delete "$SNFServerInstallDir\config\contentNEW.xml"
  2965. Return ; fall through and close files up.
  2966. ; we could jump to here from anywere indicating EOF.... so if if thats the game. We store and swap.
  2967. DoneReadingContentFile:
  2968. FileClose $IceWarpContentFileHandle ; Close file.
  2969. FileClose $IceWarpAdjustedFileHandle ; Close file.
  2970. StrCpy $IceWarpContentXMLlinedata "" ; Clear line data.
  2971. ; Now swap out the files.
  2972. ;Var /GLOBAL var1
  2973. ;Var /GLOBAL var2
  2974. ;Var /GLOBAL var3
  2975. ;Var /GLOBAL var4
  2976. ;Var /GLOBAL var5
  2977. ;Var /GLOBAL var6
  2978. ;Var /GLOBAL var7
  2979. ${GetTime} "" "L" $var1 $var2 $var3 $var4 $var5 $var6 $var7
  2980. Rename "$SNFServerInstallDir\config\content.xml" "$SNFServerInstallDir\config\content_UnInstallLOG_$var1-$var2-$var4.xml"
  2981. Rename "$SNFServerInstallDir\config\contentNEW.xml" "$SNFServerInstallDir\config\content.xml"
  2982. Return
  2983. DoneReadingContentFileWithErrors:
  2984. FileClose $IceWarpContentFileHandle ; Close file.
  2985. FileClose $IceWarpAdjustedFileHandle ; Close file.
  2986. Delete "$SNFServerInstallDir\config\contentNEW.xml"
  2987. Return
  2988. UnableToFindContentFileXML:
  2989. Return
  2990. FunctionEnd
  2991. Function editContentXML
  2992. ; Subroutine that inserts the XML to tie in Sniffer to the IceWarp merak\config\content.xml
  2993. ; There are three situations. First the file is empty, Second it doesn't have a sniffer tag, but there are other filters, third it has a sniffer tag.
  2994. ;GetFullPathName /SHORT $localINSTDIR $INSTDIR ; for windows greeking. ; Seed with the default values.
  2995. ${handleShortPath} $localINSTDIR $INSTDIR
  2996. ;StrCpy $localINSTDIR $INSTDIR ; Seed the default values.
  2997. ;GetFullPathName /SHORT $localSERVDIR $SNFServerInstallDir ; for windows greeking. ; Seed with the default values.
  2998. ${handleShortPath} $localSERVDIR $SNFServerInstallDir
  2999. ;StrCpy $localSERVDIR $SNFServerInstallDir ; Seed with the default values.
  3000. Var /GLOBAL IceWarpType
  3001. ReadRegStr $IceWarpType HKLM "SOFTWARE\MessageSniffer" "IceWarpType"
  3002. ; possible types are AV, CF and SS
  3003. StrCmp $IceWarpType "AV" 0 useContentFilters
  3004. Call editScanXML ; not using ContentFilter tie in. Using Scan.dat file tie in. Very similar, but slightly different.
  3005. return
  3006. useContentFilters:
  3007. ; Ok, not inserting into AV position. So we'll do the contentfilter stuff.
  3008. ; but if we WE'RE installed there before... we need to strip it out from the AV tiein..
  3009. Call stripScanXML
  3010. Var /GLOBAL ContentXMLHeader
  3011. Var /GLOBAL ContentXMLFooter
  3012. Var /GLOBAL SnifferXMLContent
  3013. Var /GLOBAL SnifferXMLContent2
  3014. StrCpy $ContentXMLHeader '<?xml version="1.0" encoding="UTF-8"?>$\r$\n<CONTENTFILTER>$\r$\n' ; If nothing in file, when we need to write header and
  3015. StrCpy $ContentXMLFooter "</CONTENTFILTER>" ; footer.
  3016. StrCmp $IceWarpType "CF" 0 SetForSS ; Only other setting is SS
  3017. StrCpy $SnifferXMLContent "" ; Clear buffer.
  3018. StrCpy $SnifferXMLContent "$SnifferXMLContent<FILTER>$\r$\n"
  3019. StrCpy $SnifferXMLContent "$SnifferXMLContent <ACTIVE>1</ACTIVE>$\r$\n"
  3020. StrCpy $SnifferXMLContent "$SnifferXMLContent <TITLE>SNIFFER</TITLE>$\r$\n"
  3021. StrCpy $SnifferXMLContent "$SnifferXMLContent <READONLY>0</READONLY>$\r$\n"
  3022. StrCpy $SnifferXMLContent "$SnifferXMLContent <CONDITION>$\r$\n"
  3023. StrCpy $SnifferXMLContent "$SnifferXMLContent <AND>1</AND>$\r$\n"
  3024. StrCpy $SnifferXMLContent "$SnifferXMLContent <LOGICALNOT>0</LOGICALNOT>$\r$\n"
  3025. StrCpy $SnifferXMLContent "$SnifferXMLContent <EXPRESSION>6</EXPRESSION>$\r$\n"
  3026. StrCpy $SnifferXMLContent "$SnifferXMLContent <CONTAINTYPE>8</CONTAINTYPE>$\r$\n"
  3027. StrCpy $SnifferXMLContent "$SnifferXMLContent <MESSAGESIZESMALLER>0</MESSAGESIZESMALLER>$\r$\n"
  3028. StrCpy $SnifferXMLContent "$SnifferXMLContent <MESSAGESIZE>1</MESSAGESIZE>$\r$\n"
  3029. StrCpy $SnifferXMLContent "$SnifferXMLContent </CONDITION>$\r$\n"
  3030. StrCpy $SnifferXMLContent "$SnifferXMLContent <CONDITION>$\r$\n"
  3031. StrCpy $SnifferXMLContent "$SnifferXMLContent <AND>1</AND>$\r$\n"
  3032. StrCpy $SnifferXMLContent "$SnifferXMLContent <LOGICALNOT>0</LOGICALNOT>$\r$\n"
  3033. StrCpy $SnifferXMLContent "$SnifferXMLContent <EXPRESSION>4</EXPRESSION>$\r$\n"
  3034. StrCpy $SnifferXMLContent "$SnifferXMLContent <CONTAINTYPE>8</CONTAINTYPE>$\r$\n"
  3035. StrCpy $SnifferXMLContent "$SnifferXMLContent <CONTAIN>$localINSTDIR\SNFClient.exe</CONTAIN>$\r$\n"
  3036. StrCpy $SnifferXMLContent "$SnifferXMLContent <MESSAGESIZESMALLER>0</MESSAGESIZESMALLER>$\r$\n"
  3037. StrCpy $SnifferXMLContent "$SnifferXMLContent <MESSAGESIZE>2</MESSAGESIZE>$\r$\n"
  3038. StrCpy $SnifferXMLContent "$SnifferXMLContent </CONDITION>$\r$\n"
  3039. StrCpy $SnifferXMLContent "$SnifferXMLContent <ACCEPT>0</ACCEPT>$\r$\n"
  3040. StrCpy $SnifferXMLContent2 " <REJECT>0</REJECT>$\r$\n"
  3041. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <DELETE>0</DELETE>$\r$\n"
  3042. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <ENCRYPT>0</ENCRYPT>$\r$\n"
  3043. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <PRIORITY>0</PRIORITY>$\r$\n"
  3044. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <FLAGS>0</FLAGS>$\r$\n"
  3045. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <SCORE>500</SCORE>$\r$\n"
  3046. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <MARKSPAM>1</MARKSPAM>$\r$\n"
  3047. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <STOP>0</STOP>$\r$\n"
  3048. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <EXECUTE>0</EXECUTE>$\r$\n"
  3049. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <TARPITSENDER>0</TARPITSENDER>$\r$\n"
  3050. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <FIXRFC822>0</FIXRFC822>$\r$\n"
  3051. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <SMTPRESPONSE>0</SMTPRESPONSE>$\r$\n"
  3052. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <STRIPALL>1</STRIPALL>$\r$\n"
  3053. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <HEADER>$\r$\n"
  3054. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <VAL>0X-SNIFFER-FLAG: Yes </VAL>$\r$\n"
  3055. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 </HEADER>$\r$\n"
  3056. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2</FILTER>$\r$\n"
  3057. Goto FilterTextReady
  3058. SetForSS:
  3059. ; ok, not using the CF, we're using the spam score insertion method.
  3060. StrCpy $SnifferXMLContent "$SnifferXMLContent<FILTER>$\r$\n"
  3061. StrCpy $SnifferXMLContent "$SnifferXMLContent <ACTIVE>1</ACTIVE>$\r$\n"
  3062. StrCpy $SnifferXMLContent "$SnifferXMLContent <TITLE>SNIFFER</TITLE>$\r$\n"
  3063. StrCpy $SnifferXMLContent "$SnifferXMLContent <READONLY>0</READONLY>$\r$\n"
  3064. StrCpy $SnifferXMLContent "$SnifferXMLContent <CONDITION>$\r$\n"
  3065. StrCpy $SnifferXMLContent "$SnifferXMLContent <AND>1</AND>$\r$\n"
  3066. StrCpy $SnifferXMLContent "$SnifferXMLContent <LOGICALNOT>0</LOGICALNOT>$\r$\n"
  3067. StrCpy $SnifferXMLContent "$SnifferXMLContent <EXPRESSION>6</EXPRESSION>$\r$\n"
  3068. StrCpy $SnifferXMLContent "$SnifferXMLContent <CONTAINTYPE>8</CONTAINTYPE>$\r$\n"
  3069. StrCpy $SnifferXMLContent "$SnifferXMLContent <MESSAGESIZESMALLER>0</MESSAGESIZESMALLER>$\r$\n"
  3070. StrCpy $SnifferXMLContent "$SnifferXMLContent <MESSAGESIZE>1</MESSAGESIZE>$\r$\n"
  3071. StrCpy $SnifferXMLContent "$SnifferXMLContent </CONDITION>$\r$\n"
  3072. StrCpy $SnifferXMLContent "$SnifferXMLContent <CONDITION>$\r$\n"
  3073. StrCpy $SnifferXMLContent "$SnifferXMLContent <AND>1</AND>$\r$\n"
  3074. StrCpy $SnifferXMLContent "$SnifferXMLContent <LOGICALNOT>0</LOGICALNOT>$\r$\n"
  3075. StrCpy $SnifferXMLContent "$SnifferXMLContent <EXPRESSION>4</EXPRESSION>$\r$\n"
  3076. StrCpy $SnifferXMLContent "$SnifferXMLContent <CONTAINTYPE>8</CONTAINTYPE>$\r$\n"
  3077. StrCpy $SnifferXMLContent "$SnifferXMLContent <CONTAIN>$localINSTDIR\SNFClient.exe</CONTAIN>$\r$\n"
  3078. StrCpy $SnifferXMLContent "$SnifferXMLContent <MESSAGESIZESMALLER>0</MESSAGESIZESMALLER>$\r$\n"
  3079. StrCpy $SnifferXMLContent "$SnifferXMLContent <MESSAGESIZE>2</MESSAGESIZE>$\r$\n"
  3080. StrCpy $SnifferXMLContent "$SnifferXMLContent </CONDITION>$\r$\n"
  3081. StrCpy $SnifferXMLContent "$SnifferXMLContent <ACCEPT>0</ACCEPT>$\r$\n"
  3082. StrCpy $SnifferXMLContent2 " <REJECT>0</REJECT>$\r$\n"
  3083. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <DELETE>0</DELETE>$\r$\n"
  3084. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <ENCRYPT>0</ENCRYPT>$\r$\n"
  3085. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <PRIORITY>0</PRIORITY>$\r$\n"
  3086. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <FLAGS>0</FLAGS>$\r$\n"
  3087. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <SCORE>500</SCORE>$\r$\n"
  3088. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <MARKSPAM>0</MARKSPAM>$\r$\n"
  3089. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <STOP>0</STOP>$\r$\n"
  3090. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <EXECUTE>0</EXECUTE>$\r$\n"
  3091. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <TARPITSENDER>0</TARPITSENDER>$\r$\n"
  3092. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <FIXRFC822>0</FIXRFC822>$\r$\n"
  3093. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2 <SMTPRESPONSE>0</SMTPRESPONSE>$\r$\n"
  3094. StrCpy $SnifferXMLContent2 "$SnifferXMLContent2</FILTER>$\r$\n"
  3095. FilterTextReady:
  3096. #Var /GLOBAL IceWarpContentFileHandle ; handle to hold open read file. ALREADY DECLARED in un. function.
  3097. #Var /GLOBAL IceWarpAdjustedFileHandle ; new file.
  3098. #Var /GLOBAL IceWarpSnifferXMLExists
  3099. #Var /GLOBAL TempFilterXML ; this hold a filter paragraph until we're sure we want to commit it....
  3100. #Var /GLOBAL didWeOutput ; flag for if we exited normally with output of XML or if we ended file strangely and terminated with no output.
  3101. #Var /GLOBAL IceWarpContentXMLlinedata ; read data, line by line.
  3102. StrCpy $didWeOutput "0"
  3103. StrCpy $IceWarpSnifferXMLExists "0" ; default flag to false.
  3104. FileOpen $IceWarpAdjustedFileHandle "$SNFServerInstallDir\config\contentNEW.xml" w
  3105. clearerrors
  3106. IfFileExists "$SNFServerInstallDir\config\content.xml" 0 UnableToFindContentFileXML
  3107. FileOpen $IceWarpContentFileHandle "$SNFServerInstallDir\config\content.xml" r
  3108. iferrors 0 ReadContentLine
  3109. MessageBox MB_OK "Unable to read IceWarps Content.XML file from: $SNFServerInstallDir\config\content.xml"
  3110. Goto DoneReadingContentFile
  3111. ; You can have an empty file. With no headers... so first we either spin through without finding a valid header opener... and then
  3112. ; open and enter our own filter at the end... or we'll find one, and enter into the valid filter sections.
  3113. ReadForProperyHeaderedFilterFile:
  3114. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3115. ifErrors DoneReadingEmptyFile 0
  3116. ${WordFind} $IceWarpContentXMLlinedata "<CONTENTFILTER>" "E+1}" $WordFindResults
  3117. ifErrors 0 ProperlyHeaderedFile ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3118. ; if were here and we're reading lines, then we're not in a SNIFFER FILTER... so we write the line to the new file.
  3119. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  3120. Goto ReadForProperyHeaderedFilterFile ; go back and get a newline to test.
  3121. ProperlyHeaderedFile:
  3122. ; dump header line.
  3123. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  3124. ;Ok, Next line SHOULD be FILTER object.... spin till we get one...
  3125. ReadContentLine:
  3126. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3127. ifErrors DoneReadingContentFile 0
  3128. ${WordFind} $IceWarpContentXMLlinedata "<FILTER>" "E+1}" $WordFindResults
  3129. ifErrors 0 FoundFilterMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3130. ; if were here and we're reading lines, then we're not in a SNIFFER FILTER... so we write the line to the new file.
  3131. ; BUT we could be reading the last line, in which case, we need to output before we close the content filter tag...
  3132. ${WordFind} $IceWarpContentXMLlinedata "</CONTENTFILTER>" "E+1}" $WordFindResults
  3133. ifErrors NotEndingYet 0 ; errors meant not in line... If we found it, then drop through and handle trivial ending. Otherwise drop through
  3134. ; Ok here is where we put the new Sniffer... since we're about to end without finding one.
  3135. FileWrite $IceWarpAdjustedFileHandle $SnifferXMLContent ; and because this is a properly wrapped file, and there may be more filters after us.
  3136. FileWrite $IceWarpAdjustedFileHandle $SnifferXMLContent2
  3137. StrCpy $didWeOutput "1" ; we continue through and write the rest till EOF.
  3138. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; close the XML validily.
  3139. Goto DoneReadingContentFile
  3140. NotEndingYet: ; ok if its not the trivial ending, then output line, and go back for more.
  3141. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  3142. Goto ReadContentLine ; go back and get a newline to test.
  3143. FoundFilterMarker:
  3144. ; Ok, we're here at a filter header, so its either the SNIFFER FILTER, or its not... so we write to a temp var till we read the title...
  3145. ; because the filter section has a couple lines ahead of the title tag... active y/n etc.... so we need to trap that till we get to
  3146. ; something distinctive.
  3147. StrCpy $TempFilterXML $IceWarpContentXMLlinedata
  3148. LookForTitle:
  3149. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3150. ifErrors DoneReadingContentFile 0
  3151. ${WordFind} $IceWarpContentXMLlinedata "<TITLE>" "E+1}" $WordFindResults
  3152. ifErrors 0 FoundTitleMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3153. StrCpy $TempFilterXML "$TempFilterXML$IceWarpContentXMLlinedata" ; not in line, add to temp buffer.
  3154. Goto LookForTitle ; go back and get a newline to that might hold the title.
  3155. FoundTitleMarker:
  3156. ; Ok, if we popped out and were here, then if we find the title and it IS sniffer.... then we dont' write, and we loop to the next </FILTER>
  3157. ; but if we're NOT sniffer.... then we write the temp string and pop out and continue looping at the top.
  3158. ${WordFind} $IceWarpContentXMLlinedata "SNIFFER" "E+1}" $WordFindResults
  3159. ifErrors 0 FoundSnifferSection ; errors meant not in line... If we found it, then go to found-handle. Otherwise drop through
  3160. FileWrite $IceWarpAdjustedFileHandle $TempFilterXML ; Ok, we're not in a sniffer section, so dump the buffer
  3161. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump the current line...
  3162. StrCpy $TempFilterXML "" ; clear the buffer.
  3163. Goto ReadContentLine ; pop out and look for the next filter tag.
  3164. FoundSnifferSection:
  3165. ; if this is the case, we loop till we find the </FILTER> and then we insert the new sniffer code.
  3166. LookForCloseFilter:
  3167. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3168. ifErrors DoneReadingContentFileWithErrors 0 ; if we exit here output is NOT done... and it probably means an error.
  3169. ${WordFind} $IceWarpContentXMLlinedata "</FILTER>" "E+1}" $WordFindResults
  3170. ifErrors 0 FoundCloseFilterMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3171. Goto LookForCloseFilter ; go back and get a newline to that might hold the title.
  3172. FoundCloseFilterMarker:
  3173. ; Ok here is where we put the new Sniffer... since we just cut out the old sniffer.
  3174. FileWrite $IceWarpAdjustedFileHandle $SnifferXMLContent ; and because this is a properly wrapped file, and there may be more filters after us.
  3175. FileWrite $IceWarpAdjustedFileHandle $SnifferXMLContent2
  3176. StrCpy $didWeOutput "1" ; we continue through and write the rest till EOF.
  3177. ; Ok from here on, we dump it all to the file.
  3178. ContinueDumpingFileLines:
  3179. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata ;Grap new line.
  3180. ifErrors DoneReadingContentFile 0 ; if not EOF then exit with output true. We're good and done.
  3181. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump the current line...
  3182. Goto ContinueDumpingFileLines ; and go back for more.
  3183. ; If were here then we called from the first loop section where we were checking for <CONTENTFILTER>
  3184. DoneReadingEmptyFile: ; this means we head, fill and footer the file ourselves.
  3185. FileWrite $IceWarpAdjustedFileHandle $ContentXMLHeader ; If nothing in file, when we need to write header and
  3186. FileWrite $IceWarpAdjustedFileHandle $SnifferXMLContent
  3187. FileWrite $IceWarpAdjustedFileHandle $SnifferXMLContent2
  3188. FileWrite $IceWarpAdjustedFileHandle $ContentXMLFooter ; and footer
  3189. StrCpy $didWeOutput "1" ; footer.
  3190. ; fall through and close files up.
  3191. ; we could jump to here from anywere. If we needed to write it out in the middle, we would have done it.
  3192. DoneReadingContentFile: ; only the trivial EOF early would trip with no output.... so if thats the case
  3193. StrCmp $didWeOutput "0" 0 SkipOutputThisTime ; we need to dump it all in, headers and footers too, and then close.
  3194. FileWrite $IceWarpAdjustedFileHandle $ContentXMLHeader ; If nothing in file, when we need to write header and
  3195. FileWrite $IceWarpAdjustedFileHandle $SnifferXMLContent
  3196. FileWrite $IceWarpAdjustedFileHandle $SnifferXMLContent2
  3197. FileWrite $IceWarpAdjustedFileHandle $ContentXMLFooter ; and footer ; if we didn't have a chance, then we output here.
  3198. SkipOutputThisTime:
  3199. ; potential for corrupted file if file ended with errors....
  3200. FileClose $IceWarpContentFileHandle ; Close file.
  3201. FileClose $IceWarpAdjustedFileHandle ; Close file.
  3202. StrCpy $IceWarpContentXMLlinedata "" ; Clear line data.
  3203. ; Now swap out the files.
  3204. #Var /GLOBAL var1
  3205. #Var /GLOBAL var2
  3206. #Var /GLOBAL var3
  3207. #Var /GLOBAL var4
  3208. #Var /GLOBAL var5
  3209. #Var /GLOBAL var6
  3210. #Var /GLOBAL var7
  3211. ${GetTime} "" "L" $var1 $var2 $var3 $var4 $var5 $var6 $var7
  3212. ifFileExists "$SNFServerInstallDir\config\content_InstallLOG_$var1-$var2-$var4.xml" 0 +2
  3213. Delete "$SNFServerInstallDir\config\content_InstallLOG_$var1-$var2-$var4.xml"
  3214. Rename "$SNFServerInstallDir\config\content.xml" "$SNFServerInstallDir\config\content_InstallLOG_$var1-$var2-$var4.xml"
  3215. Rename "$SNFServerInstallDir\config\contentNEW.xml" "$SNFServerInstallDir\config\content.xml"
  3216. Return
  3217. DoneReadingContentFileWithErrors:
  3218. FileClose $IceWarpContentFileHandle ; Close file.
  3219. FileClose $IceWarpAdjustedFileHandle ; Close file.
  3220. Delete "$SNFServerInstallDir\config\contentNEW.xml"
  3221. MessageBox MB_OK "Attempting to edit XML in: $SNFServerInstallDir\config\content.xml resulted in finding a corrupted construction. Please check the new file, content.xml, manually."
  3222. Return
  3223. UnableToFindContentFileXML:
  3224. MessageBox MB_OK "Unable to find IceWarps Content.XML file from: $SNFServerInstallDir\config\content.xml You will have to tie-in manually with IceWarp."
  3225. Return
  3226. FunctionEND
  3227. Function un.stripScanXML
  3228. ; Subroutine that removes the XML to tie in Sniffer to the IceWarp merak\config\scan.dat file. ( As an AV filter )
  3229. ; There are three situations. First the file is empty, Second it doesn't have a SNFClient tag, but there are other filters, third it has a ClamAV tag.
  3230. ;Var /GLOBAL WordFindResults
  3231. ;Var /GLOBAL ContentXMLHeader
  3232. ;Var /GLOBAL ContentXMLFooter
  3233. ; Used for gettime functions.
  3234. ;Var /GLOBAL var1
  3235. ;Var /GLOBAL var2
  3236. ;Var /GLOBAL var3
  3237. ;Var /GLOBAL var4
  3238. ;Var /GLOBAL var5
  3239. ;Var /GLOBAL var6
  3240. ;Var /GLOBAL var7
  3241. Var /GLOBAL IceWarpInstallFolder
  3242. StrCpy $IceWarpInstallFolder $SNFServerInstallDir ; set as source for file.... ( filter code was ported from the ClamAid Script )
  3243. StrCpy $ContentXMLHeader '<FILTERS>$\r$\n' ; If nothing in file, when we need to write header and
  3244. StrCpy $ContentXMLFooter "</FILTERS>$\r$\n"
  3245. ; footer.
  3246. ;Var /GLOBAL IceWarpContentFileHandle ; handle to hold open read file. ALREADY DECLARED in un. function.
  3247. ;Var /GLOBAL IceWarpAdjustedFileHandle ; new file.
  3248. ;Var /GLOBAL TempFilterXML ; this hold a filter paragraph until we're sure we want to commit it....
  3249. ;Var /GLOBAL didWeOutput ; flag for if we exited normally with output of XML or if we ended file strangely and terminated with no output.
  3250. ;Var /GLOBAL IceWarpContentXMLlinedata ; read data, line by line.
  3251. StrCpy $didWeOutput "0"
  3252. FileOpen $IceWarpAdjustedFileHandle "$IceWarpInstallFolder\config\scanNEW.dat" w
  3253. clearerrors
  3254. IfFileExists "$IceWarpInstallFolder\config\scan.dat" 0 UnableToFindContentFileXML
  3255. FileOpen $IceWarpContentFileHandle "$IceWarpInstallFolder\config\scan.dat" r
  3256. iferrors 0 ReadContentLine
  3257. MessageBox MB_OK "Unable to read IceWarps scan.dat file from: $IceWarpInstallFolder\config\scan.dat"
  3258. Goto DoneReadingContentFile
  3259. ;Ok, Next line SHOULD be FILTER object.... spin till we get one...
  3260. ReadContentLine:
  3261. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3262. ifErrors DoneReadingContentFile 0
  3263. ${un.WordFind} $IceWarpContentXMLlinedata "<FILTER>" "E+1}" $WordFindResults
  3264. ifErrors 0 FoundFilterMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3265. ; if were here and we're reading lines, then we're not in a SNIFFER FILTER... so we write the line to the new file.
  3266. ; BUT we could be reading the last line, in which case, we need to output before we close the content filter tag...
  3267. ${un.WordFind} $IceWarpContentXMLlinedata "</FILTERS>" "E+1}" $WordFindResults
  3268. ifErrors NotEndingYet 0 ; errors meant not in line... If we found it, then drop through and handle trivial ending. Otherwise drop through
  3269. ; this is the strip, so we're done now
  3270. StrCpy $didWeOutput "1" ; we continue through and write the rest till EOF.
  3271. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; close the XML validily.
  3272. Goto DoneReadingContentFile
  3273. NotEndingYet: ; ok if its not the trivial ending, then output line, and go back for more.
  3274. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  3275. Goto ReadContentLine ; go back and get a newline to test.
  3276. FoundFilterMarker:
  3277. ; Ok, we're here at a filter header, so its either the SNIFFER FILTER, or its not... so we write to a temp var till we read the title...
  3278. ; because the filter section has a couple lines ahead of the title tag... active y/n etc.... so we need to trap that till we get to
  3279. ; something distinctive.
  3280. StrCpy $TempFilterXML $IceWarpContentXMLlinedata
  3281. LookForTitle:
  3282. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3283. ifErrors DoneReadingContentFile 0
  3284. ${un.WordFind} $IceWarpContentXMLlinedata "<FILENAME>" "E+1}" $WordFindResults
  3285. ifErrors 0 FoundTitleMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3286. StrCpy $TempFilterXML "$TempFilterXML$IceWarpContentXMLlinedata" ; not in line, add to temp buffer.
  3287. Goto LookForTitle ; go back and get a newline to that might hold the title.
  3288. FoundTitleMarker:
  3289. ; Ok, if we popped out and we're here, then if we find the title and it IS clamdscan then we dont' write, and we loop to the next </FILTER>
  3290. ; but if we're NOT sniffer.... then we write the temp string and pop out and continue looping at the top.
  3291. ${un.WordFind} $IceWarpContentXMLlinedata "SNFCLient.exe" "E+1}" $WordFindResults
  3292. ifErrors 0 FoundClamSection ; errors meant not in line... If we found it, then go to found-handle. Otherwise drop through
  3293. FileWrite $IceWarpAdjustedFileHandle $TempFilterXML ; Ok, we're not in a sniffer section, so dump the buffer
  3294. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump the current line...
  3295. StrCpy $TempFilterXML "" ; clear the buffer.
  3296. Goto ReadContentLine ; pop out and look for the next filter tag.
  3297. FoundClamSection:
  3298. ; if this is the case, we loop till we find the </FILTER> and then we insert the new sniffer code.
  3299. LookForCloseFilter:
  3300. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3301. ifErrors DoneReadingContentFileWithErrors 0 ; if we exit here output is NOT done... and it probably means an error.
  3302. ${un.WordFind} $IceWarpContentXMLlinedata "</FILTER>" "E+1}" $WordFindResults
  3303. ifErrors 0 FoundCloseFilterMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3304. Goto LookForCloseFilter ; go back and get a newline to that might hold the title.
  3305. FoundCloseFilterMarker:
  3306. ; Ok here is where we remove the Filter reference
  3307. StrCpy $didWeOutput "1" ; Now we continue through and write the rest till EOF.
  3308. ; Ok from here on, we dump it all to the file.
  3309. ContinueDumpingFileLines:
  3310. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata ;Grap new line.
  3311. ifErrors DoneReadingContentFile 0 ; if not EOF then exit with output true. We're good and done.
  3312. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump the current line...
  3313. Goto ContinueDumpingFileLines ; and go back for more.
  3314. ; If were here then we called from the first loop section where we were checking for <CONTENTFILTER>
  3315. DoneReadingEmptyFile: ; this means we don't need a header footer or anything.
  3316. ; In this case, since we're stripping, $didWeOutput merely means have we satisified our conditions to end.
  3317. StrCpy $didWeOutput "1" ; footer.
  3318. ; fall through and close files up.
  3319. ; we could jump to here from anywere. If we needed to write it out in the middle, we would have done it.
  3320. DoneReadingContentFile: ; only the trivial EOF early would trip with no output.... so if thats the case
  3321. StrCmp $didWeOutput "0" 0 SkipOutputThisTime ; we need to dump it all in, headers and footers too, and then close.
  3322. SkipOutputThisTime:
  3323. ; potential for corrupted file if file ended with errors....
  3324. FileClose $IceWarpContentFileHandle ; Close file.
  3325. FileClose $IceWarpAdjustedFileHandle ; Close file.
  3326. StrCpy $IceWarpContentXMLlinedata "" ; Clear line data.
  3327. ; Now swap out the files.
  3328. #Var /GLOBAL var1
  3329. #Var /GLOBAL var2
  3330. #Var /GLOBAL var3
  3331. #Var /GLOBAL var4
  3332. #Var /GLOBAL var5
  3333. #Var /GLOBAL var6
  3334. #Var /GLOBAL var7
  3335. ${un.GetTime} "" "L" $var1 $var2 $var3 $var4 $var5 $var6 $var7
  3336. ifFileExists "$IceWarpInstallFolder\config\scandat_InstallLOG_$var1-$var2-$var4.xml" 0 +2
  3337. Delete "$IceWarpInstallFolder\config\scandat_InstallLOG_$var1-$var2-$var4.xml"
  3338. Rename "$IceWarpInstallFolder\config\scan.dat" "$IceWarpInstallFolder\config\scandat_InstallLOG_$var1-$var2-$var4.xml"
  3339. Rename "$IceWarpInstallFolder\config\scanNEW.dat" "$IceWarpInstallFolder\config\scan.dat"
  3340. Return
  3341. DoneReadingContentFileWithErrors:
  3342. FileClose $IceWarpContentFileHandle ; Close file.
  3343. FileClose $IceWarpAdjustedFileHandle ; Close file.
  3344. Delete "$IceWarpInstallFolder\config\scanNew.dat"
  3345. MessageBox MB_OK "Attempting to edit XML in: $IceWarpInstallFolder\config\scan.dat resulted in finding a corrupted construction. Please check the new file, scan.dat, manually."
  3346. Return
  3347. UnableToFindContentFileXML:
  3348. MessageBox MB_OK "Unable to find IceWarps scan.dat file from: $IceWarpInstallFolder\config\scan.dat You will have to tie-in manually with IceWarp."
  3349. Return
  3350. FunctionEnd
  3351. Function stripScanXML
  3352. ; Subroutine that removes the XML to tie in Sniffer to the IceWarp merak\config\scan.dat file. ( As an AV filter )
  3353. ; There are three situations. First the file is empty, Second it doesn't have a SNFClient tag, but there are other filters, third it has a ClamAV tag.
  3354. ;Var /GLOBAL WordFindResults
  3355. ;Var /GLOBAL ContentXMLHeader
  3356. ;Var /GLOBAL ContentXMLFooter
  3357. ; Used for gettime functions.
  3358. ;Var /GLOBAL var1
  3359. ;Var /GLOBAL var2
  3360. ;Var /GLOBAL var3
  3361. ;Var /GLOBAL var4
  3362. ;Var /GLOBAL var5
  3363. ;Var /GLOBAL var6
  3364. ;Var /GLOBAL var7
  3365. ;Var /GLOBAL IceWarpInstallFolder
  3366. StrCpy $IceWarpInstallFolder $SNFServerInstallDir ; set as source for file.... ( filter code was ported from the ClamAid Script )
  3367. StrCpy $ContentXMLHeader '<FILTERS>$\r$\n' ; If nothing in file, when we need to write header and
  3368. StrCpy $ContentXMLFooter "</FILTERS>$\r$\n"
  3369. ; footer.
  3370. ;Var /GLOBAL IceWarpContentFileHandle ; handle to hold open read file. ALREADY DECLARED in un. function.
  3371. ;Var /GLOBAL IceWarpAdjustedFileHandle ; new file.
  3372. ;Var /GLOBAL TempFilterXML ; this hold a filter paragraph until we're sure we want to commit it....
  3373. ;Var /GLOBAL didWeOutput ; flag for if we exited normally with output of XML or if we ended file strangely and terminated with no output.
  3374. ;Var /GLOBAL IceWarpContentXMLlinedata ; read data, line by line.
  3375. StrCpy $didWeOutput "0"
  3376. FileOpen $IceWarpAdjustedFileHandle "$IceWarpInstallFolder\config\scanNEW.dat" w
  3377. clearerrors
  3378. IfFileExists "$IceWarpInstallFolder\config\scan.dat" 0 UnableToFindContentFileXML
  3379. FileOpen $IceWarpContentFileHandle "$IceWarpInstallFolder\config\scan.dat" r
  3380. iferrors 0 ReadContentLine
  3381. MessageBox MB_OK "Unable to read IceWarps scan.dat file from: $IceWarpInstallFolder\config\scan.dat"
  3382. Goto DoneReadingContentFile
  3383. ;Ok, Next line SHOULD be FILTER object.... spin till we get one...
  3384. ReadContentLine:
  3385. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3386. ifErrors DoneReadingContentFile 0
  3387. ${WordFind} $IceWarpContentXMLlinedata "<FILTER>" "E+1}" $WordFindResults
  3388. ifErrors 0 FoundFilterMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3389. ; if were here and we're reading lines, then we're not in a SNIFFER FILTER... so we write the line to the new file.
  3390. ; BUT we could be reading the last line, in which case, we need to output before we close the content filter tag...
  3391. ${WordFind} $IceWarpContentXMLlinedata "</FILTERS>" "E+1}" $WordFindResults
  3392. ifErrors NotEndingYet 0 ; errors meant not in line... If we found it, then drop through and handle trivial ending. Otherwise drop through
  3393. ; this is the strip, so we're done now
  3394. StrCpy $didWeOutput "1" ; we continue through and write the rest till EOF.
  3395. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; close the XML validily.
  3396. Goto DoneReadingContentFile
  3397. NotEndingYet: ; ok if its not the trivial ending, then output line, and go back for more.
  3398. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  3399. Goto ReadContentLine ; go back and get a newline to test.
  3400. FoundFilterMarker:
  3401. ; Ok, we're here at a filter header, so its either the SNIFFER FILTER, or its not... so we write to a temp var till we read the title...
  3402. ; because the filter section has a couple lines ahead of the title tag... active y/n etc.... so we need to trap that till we get to
  3403. ; something distinctive.
  3404. StrCpy $TempFilterXML $IceWarpContentXMLlinedata
  3405. LookForTitle:
  3406. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3407. ifErrors DoneReadingContentFile 0
  3408. ${WordFind} $IceWarpContentXMLlinedata "<FILENAME>" "E+1}" $WordFindResults
  3409. ifErrors 0 FoundTitleMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3410. StrCpy $TempFilterXML "$TempFilterXML$IceWarpContentXMLlinedata" ; not in line, add to temp buffer.
  3411. Goto LookForTitle ; go back and get a newline to that might hold the title.
  3412. FoundTitleMarker:
  3413. ; Ok, if we popped out and we're here, then if we find the title and it IS clamdscan then we dont' write, and we loop to the next </FILTER>
  3414. ; but if we're NOT sniffer.... then we write the temp string and pop out and continue looping at the top.
  3415. ${WordFind} $IceWarpContentXMLlinedata "SNFCLient.exe" "E+1}" $WordFindResults
  3416. ifErrors 0 FoundSnifferSection ; errors meant not in line... If we found it, then go to found-handle. Otherwise drop through
  3417. FileWrite $IceWarpAdjustedFileHandle $TempFilterXML ; Ok, we're not in a sniffer section, so dump the buffer
  3418. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump the current line...
  3419. StrCpy $TempFilterXML "" ; clear the buffer.
  3420. Goto ReadContentLine ; pop out and look for the next filter tag.
  3421. FoundSnifferSection:
  3422. ; if this is the case, we loop till we find the </FILTER> and then we insert the new sniffer code.
  3423. LookForCloseFilter:
  3424. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3425. ifErrors DoneReadingContentFileWithErrors 0 ; if we exit here output is NOT done... and it probably means an error.
  3426. ${WordFind} $IceWarpContentXMLlinedata "</FILTER>" "E+1}" $WordFindResults
  3427. ifErrors 0 FoundCloseFilterMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3428. Goto LookForCloseFilter ; go back and get a newline to that might hold the title.
  3429. FoundCloseFilterMarker:
  3430. ; Ok here is where we remove the Filter reference
  3431. StrCpy $didWeOutput "1" ; Now we continue through and write the rest till EOF.
  3432. ; Ok from here on, we dump it all to the file.
  3433. ContinueDumpingFileLines:
  3434. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata ;Grap new line.
  3435. ifErrors DoneReadingContentFile 0 ; if not EOF then exit with output true. We're good and done.
  3436. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump the current line...
  3437. Goto ContinueDumpingFileLines ; and go back for more.
  3438. ; If were here then we called from the first loop section where we were checking for <CONTENTFILTER>
  3439. DoneReadingEmptyFile: ; this means we don't need a header footer or anything.
  3440. ; In this case, since we're stripping, $didWeOutput merely means have we satisified our conditions to end.
  3441. StrCpy $didWeOutput "1" ; footer.
  3442. ; fall through and close files up.
  3443. ; we could jump to here from anywere. If we needed to write it out in the middle, we would have done it.
  3444. DoneReadingContentFile: ; only the trivial EOF early would trip with no output.... so if thats the case
  3445. StrCmp $didWeOutput "0" 0 SkipOutputThisTime ; we need to dump it all in, headers and footers too, and then close.
  3446. SkipOutputThisTime:
  3447. ; potential for corrupted file if file ended with errors....
  3448. FileClose $IceWarpContentFileHandle ; Close file.
  3449. FileClose $IceWarpAdjustedFileHandle ; Close file.
  3450. StrCpy $IceWarpContentXMLlinedata "" ; Clear line data.
  3451. ; Now swap out the files.
  3452. #Var /GLOBAL var1
  3453. #Var /GLOBAL var2
  3454. #Var /GLOBAL var3
  3455. #Var /GLOBAL var4
  3456. #Var /GLOBAL var5
  3457. #Var /GLOBAL var6
  3458. #Var /GLOBAL var7
  3459. ${GetTime} "" "L" $var1 $var2 $var3 $var4 $var5 $var6 $var7
  3460. ifFileExists "$IceWarpInstallFolder\config\scandat_InstallLOG_$var1-$var2-$var4.xml" 0 +2
  3461. Delete "$IceWarpInstallFolder\config\scandat_InstallLOG_$var1-$var2-$var4.xml"
  3462. Rename "$IceWarpInstallFolder\config\scan.dat" "$IceWarpInstallFolder\config\scandat_InstallLOG_$var1-$var2-$var4.xml"
  3463. Rename "$IceWarpInstallFolder\config\scanNEW.dat" "$IceWarpInstallFolder\config\scan.dat"
  3464. Return
  3465. DoneReadingContentFileWithErrors:
  3466. FileClose $IceWarpContentFileHandle ; Close file.
  3467. FileClose $IceWarpAdjustedFileHandle ; Close file.
  3468. Delete "$IceWarpInstallFolder\config\scanNew.dat"
  3469. MessageBox MB_OK "Attempting to edit XML in: $IceWarpInstallFolder\config\scan.dat resulted in finding a corrupted construction. Please check the new file, scan.dat, manually."
  3470. Return
  3471. UnableToFindContentFileXML:
  3472. #MessageBox MB_OK "Unable to find IceWarps scan.dat file from: $IceWarpInstallFolder\config\scan.dat You will have to tie-in manually with IceWarp."
  3473. Return
  3474. FunctionEnd
  3475. Function editScanXML
  3476. ; Subroutine that inserts the XML to tie in IceWarp to the IceWarp merak\config\scan.dat file as well as adjusting a couple line items in the ClamAV
  3477. ; config file.
  3478. ; We only want it installed in Icewarp one way at a time.
  3479. call stripContentXML ; Remove the installation XML if it was put in place as a Content Filter.
  3480. ; These are declared in the .UN version of the sub... globals cross the UN barrier.... functions don't... sigh.
  3481. ; There are three situations. First the file is empty, Second it doesn't have a ClamAV tag, but there are other filters, third it has a ClamAV tag.
  3482. ;Var /GLOBAL WordFindResults
  3483. ;Var /GLOBAL ContentXMLHeader
  3484. ;Var /GLOBAL ContentXMLFooter
  3485. Var /GLOBAL SnifferAVXMLContent
  3486. ; Used for gettime functions.
  3487. ;Var /GLOBAL var1
  3488. ;Var /GLOBAL var2
  3489. ;Var /GLOBAL var3
  3490. ;Var /GLOBAL var4
  3491. ;Var /GLOBAL var5
  3492. ;Var /GLOBAL var6
  3493. ;Var /GLOBAL var7
  3494. ;Var /GLOBAL IceWarpInstallFolder
  3495. StrCpy $IceWarpInstallFolder $SNFServerInstallDir ; set as source for file.... ( filter code was ported from the ClamAid Script )
  3496. ;GetFullPathName /SHORT $localINSTDIR $INSTDIR ; for windows greeking. ; Seed with the default values.
  3497. ${handleShortPath} $localINSTDIR $INSTDIR
  3498. ;StrCpy $localINSTDIR $INSTDIR ; Seed the default values.
  3499. ; GetFullPathName /SHORT $IceWarpInstallFolder $SNFServerInstallDir ; for windows greeking. ; Seed with the default values.
  3500. ${handleShortPath} $IceWarpInstallFolder $SNFServerInstallDir
  3501. ;StrCpy $localSERVDIR $SNFServerInstallDir ; Seed with the default values.
  3502. StrCpy $ContentXMLHeader '<FILTERS>$\r$\n' ; If nothing in file, when we need to write header and
  3503. StrCpy $ContentXMLFooter "</FILTERS>$\r$\n"
  3504. ; footer.
  3505. ; Filter looks like this:
  3506. ; <FILTER>
  3507. ; <FILENAME>&quot;C:/Program Files/clamAV/clamdscan.exe&quot;</FILENAME>
  3508. ; <PARAMETERS>-l &quot;C:/Program Files/clamAv/log/mylog.log&quot;</PARAMETERS>
  3509. ; <RETURNVALUES>1</RETURNVALUES>
  3510. ; <DELETECHECK>0</DELETECHECK>
  3511. ; <EXECTYPE>0</EXECTYPE>
  3512. ; </FILTER>
  3513. StrCpy $SnifferAVXMLContent "" ; Clear buffer.
  3514. StrCpy $SnifferAVXMLContent "$SnifferAVXMLContent<FILTER>$\r$\n"
  3515. StrCpy $SnifferAVXMLContent "$SnifferAVXMLContent <FILENAME>&quot;$localINSTDIR\SNFClient.exe&quot;</FILENAME>$\r$\n"
  3516. StrCpy $SnifferAVXMLContent "$SnifferAVXMLContent <PARAMETERS></PARAMETERS>$\r$\n"
  3517. StrCpy $SnifferAVXMLContent "$SnifferAVXMLContent <RETURNVALUES>20,21,22,23,2,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70</RETURNVALUES>$\r$\n"
  3518. StrCpy $SnifferAVXMLContent "$SnifferAVXMLContent <DELETECHECK>0</DELETECHECK>$\r$\n"
  3519. StrCpy $SnifferAVXMLContent "$SnifferAVXMLContent <EXECTYPE>0</EXECTYPE>$\r$\n"
  3520. StrCpy $SnifferAVXMLContent "$SnifferAVXMLContent</FILTER>$\r$\n"
  3521. ;Var /GLOBAL IceWarpContentFileHandle ; handle to hold open read file. ALREADY DECLARED in un. function.
  3522. ;Var /GLOBAL IceWarpAdjustedFileHandle ; new file.
  3523. ;Var /GLOBAL TempFilterXML ; this hold a filter paragraph until we're sure we want to commit it....
  3524. ;Var /GLOBAL didWeOutput ; flag for if we exited normally with output of XML or if we ended file strangely and terminated with no output.
  3525. ;Var /GLOBAL IceWarpContentXMLlinedata ; read data, line by line.
  3526. StrCpy $didWeOutput "0"
  3527. FileOpen $IceWarpAdjustedFileHandle "$IceWarpInstallFolder\config\scanNEW.dat" w
  3528. clearerrors
  3529. IfFileExists "$IceWarpInstallFolder\config\scan.dat" 0 DoneReadingContentFile
  3530. #MessageBox MB_OK "Unable to find IceWarps scan.dat file from: $IceWarpInstallFolder\config\scan.dat Creating New File."
  3531. FileOpen $IceWarpContentFileHandle "$IceWarpInstallFolder\config\scan.dat" r
  3532. iferrors 0 ReadForProperyHeaderedFilterFile
  3533. #MessageBox MB_OK "Unable to read IceWarps scan.dat file from: $IceWarpInstallFolder\config\scan.dat"
  3534. Goto DoneReadingContentFile
  3535. ; You can have an empty file. With no headers... so first we either spin through without finding a valid header opener... and then
  3536. ; open and enter our own filter at the end... or we'll find one, and enter into the valid filter sections.
  3537. ReadForProperyHeaderedFilterFile:
  3538. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3539. ifErrors DoneReadingEmptyFile 0
  3540. ${WordFind} $IceWarpContentXMLlinedata "<FILTERS>" "E+1}" $WordFindResults
  3541. ifErrors 0 ProperlyHeaderedFile ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3542. ; if were here and we're reading lines, then we're not in a CLAMAV FILTER... so we write the line to the new file.
  3543. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  3544. Goto ReadForProperyHeaderedFilterFile ; go back and get a newline to test.
  3545. ProperlyHeaderedFile:
  3546. ; dump header line.
  3547. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  3548. ; Sniffer goes in front of the AV filters.... for speed.
  3549. FileWrite $IceWarpAdjustedFileHandle $SnifferAVXMLContent ; and because this is a properly wrapped file, and there may be more filters after us.
  3550. StrCpy $didWeOutput "1" ; we continue through and write the rest till EOF.
  3551. ;Ok, Next line SHOULD be FILTER object.... spin till we get one...
  3552. ReadContentLine:
  3553. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3554. ifErrors DoneReadingContentFile 0
  3555. ${WordFind} $IceWarpContentXMLlinedata "<FILTER>" "E+1}" $WordFindResults
  3556. ifErrors 0 FoundFilterMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3557. ; if were here and we're reading lines, then we're not in a SNIFFER FILTER... so we write the line to the new file.
  3558. ; BUT we could be reading the last line, in which case, we need to output before we close the content filter tag...
  3559. ${WordFind} $IceWarpContentXMLlinedata "</FILTERS>" "E+1}" $WordFindResults
  3560. ifErrors NotEndingYet 0 ; errors meant not in line... If we found it, then drop through and handle trivial ending. Otherwise drop through
  3561. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; close the XML validily.
  3562. Goto DoneReadingContentFile
  3563. NotEndingYet: ; ok if its not the trivial ending, then output line, and go back for more.
  3564. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  3565. Goto ReadContentLine ; go back and get a newline to test.
  3566. FoundFilterMarker:
  3567. ; Ok, we're here at a filter header, so its either the SNIFFER FILTER, or its not... so we write to a temp var till we read the title...
  3568. ; because the filter section has a couple lines ahead of the title tag... active y/n etc.... so we need to trap that till we get to
  3569. ; something distinctive.
  3570. StrCpy $TempFilterXML $IceWarpContentXMLlinedata
  3571. LookForTitle:
  3572. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3573. ifErrors DoneReadingContentFile 0
  3574. ${WordFind} $IceWarpContentXMLlinedata "<FILENAME>" "E+1}" $WordFindResults
  3575. ifErrors 0 FoundTitleMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3576. StrCpy $TempFilterXML "$TempFilterXML$IceWarpContentXMLlinedata" ; not in line, add to temp buffer.
  3577. Goto LookForTitle ; go back and get a newline to that might hold the title.
  3578. FoundTitleMarker:
  3579. ; Ok, if we popped out and we're here, then if we find the title and it IS clamdscan then we dont' write, and we loop to the next </FILTER>
  3580. ; but if we're NOT sniffer.... then we write the temp string and pop out and continue looping at the top.
  3581. ${WordFind} $IceWarpContentXMLlinedata "SNFClient.exe" "E+1}" $WordFindResults
  3582. ifErrors 0 FoundSnifferSection ; errors meant not in line... If we found it, then go to found-handle. Otherwise drop through
  3583. FileWrite $IceWarpAdjustedFileHandle $TempFilterXML ; Ok, we're not in a sniffer section, so dump the buffer
  3584. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump the current line...
  3585. StrCpy $TempFilterXML "" ; clear the buffer.
  3586. Goto ReadContentLine ; pop out and look for the next filter tag.
  3587. FoundSnifferSection: ; consume an existing sniffer section.
  3588. ; if this is the case, we loop till we find the </FILTER> and then we insert the new sniffer code.
  3589. LookForCloseFilter:
  3590. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3591. ifErrors DoneReadingContentFileWithErrors 0 ; if we exit here output is NOT done... and it probably means an error.
  3592. ${WordFind} $IceWarpContentXMLlinedata "</FILTER>" "E+1}" $WordFindResults
  3593. ifErrors 0 FoundCloseFilterMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3594. Goto LookForCloseFilter ; go back and get a newline to that might hold the title.
  3595. FoundCloseFilterMarker:
  3596. ; Dont output here cause we put it in front.
  3597. ; Ok from here on, we dump it all to the file.
  3598. ContinueDumpingFileLines:
  3599. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata ;Grap new line.
  3600. ifErrors DoneReadingContentFile 0 ; if not EOF then exit with output true. We're good and done.
  3601. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump the current line...
  3602. Goto ContinueDumpingFileLines ; and go back for more.
  3603. ; If were here then we called from the first loop section where we were checking for <CONTENTFILTER>
  3604. DoneReadingEmptyFile: ; this means we head, fill and footer the file ourselves.
  3605. FileWrite $IceWarpAdjustedFileHandle $ContentXMLHeader ; If nothing in file, when we need to write header and
  3606. FileWrite $IceWarpAdjustedFileHandle $SnifferAVXMLContent
  3607. FileWrite $IceWarpAdjustedFileHandle $ContentXMLFooter ; and footer
  3608. StrCpy $didWeOutput "1" ; footer.
  3609. ; fall through and close files up.
  3610. ; we could jump to here from anywere. If we needed to write it out in the middle, we would have done it.
  3611. DoneReadingContentFile: ; only the trivial EOF early would trip with no output.... so if thats the case
  3612. StrCmp $didWeOutput "0" 0 SkipOutputThisTime ; we need to dump it all in, headers and footers too, and then close.
  3613. FileWrite $IceWarpAdjustedFileHandle $ContentXMLHeader ; If nothing in file, when we need to write header and
  3614. FileWrite $IceWarpAdjustedFileHandle $SnifferAVXMLContent
  3615. FileWrite $IceWarpAdjustedFileHandle $ContentXMLFooter ; and footer ; if we didn't have a chance, then we output here.
  3616. SkipOutputThisTime:
  3617. ; potential for corrupted file if file ended with errors....
  3618. FileClose $IceWarpContentFileHandle ; Close file.
  3619. FileClose $IceWarpAdjustedFileHandle ; Close file.
  3620. StrCpy $IceWarpContentXMLlinedata "" ; Clear line data.
  3621. ; Now swap out the files.
  3622. #Var /GLOBAL var1
  3623. #Var /GLOBAL var2
  3624. #Var /GLOBAL var3
  3625. #Var /GLOBAL var4
  3626. #Var /GLOBAL var5
  3627. #Var /GLOBAL var6
  3628. #Var /GLOBAL var7
  3629. ${GetTime} "" "L" $var1 $var2 $var3 $var4 $var5 $var6 $var7
  3630. ifFileExists "$IceWarpInstallFolder\config\scandat_InstallLOG_$var1-$var2-$var4.xml" 0 +2
  3631. Delete "$IceWarpInstallFolder\config\scandat_InstallLOG_$var1-$var2-$var4.xml"
  3632. Rename "$IceWarpInstallFolder\config\scan.dat" "$IceWarpInstallFolder\config\scandat_InstallLOG_$var1-$var2-$var4.xml"
  3633. Rename "$IceWarpInstallFolder\config\scanNEW.dat" "$IceWarpInstallFolder\config\scan.dat"
  3634. Return
  3635. DoneReadingContentFileWithErrors:
  3636. FileClose $IceWarpContentFileHandle ; Close file.
  3637. FileClose $IceWarpAdjustedFileHandle ; Close file.
  3638. Delete "$IceWarpInstallFolder\config\scanNew.dat"
  3639. MessageBox MB_OK "Attempting to edit XML in: $IceWarpInstallFolder\config\scan.dat resulted in finding a corrupted construction. Please check the new file, scan.dat, manually."
  3640. Return
  3641. UnableToFindContentFileXML:
  3642. MessageBox MB_OK "Unable to find IceWarps scan.dat file from: $IceWarpInstallFolder\config\scan.dat You will have to tie-in manually with IceWarp."
  3643. Return
  3644. FunctionEND ; end IceWarp scan.dat file edit.
  3645. #############################
  3646. ## SNIFFER's Config file. ######################################################################################################
  3647. ## This function doubles as an editor for the MDaemon's config file editor as well. Since this editor doesn't concern itself ##
  3648. ## with most of the other features.
  3649. Function editXMLConfig
  3650. ; Var /GLOBAL ShortPathTempVar ; Defined earier. ; use this to hold the Short Windows Progr~1 path references...
  3651. ;GetFullPathName /SHORT $ShortPathTempVar $INSTDIR
  3652. ${handleShortPath} $ShortPathTempVar $INSTDIR
  3653. ## MDaemon patch adjustment. The snfmdplugin.xml file is the same file, except for some initial settings. We can use the same edit code
  3654. ## for both files. Use the filename switch here.
  3655. Var /GLOBAL ConfigFileName ; We're using a switch to double the snfengine edit code to handle the snfmdplugin.xml code as well.
  3656. StrCpy $ConfigFileName "snf_engine.xml"
  3657. ifFileExists "$INSTDIR\snfmdplugin.xml" 0 +2
  3658. StrCpy $ConfigFileName "snfmdplugin.xml"
  3659. ## End MDaemon filename switch.
  3660. ${GetBetween} "<node identity='" "'>" "$INSTDIR\$ConfigFileName" "$R0" ; This makes it not brittly dependant on the default value. i.e. It would
  3661. !insertmacro ReplaceInFile "$INSTDIR\$ConfigFileName" "<node identity='$R0'>" "<node identity='$ShortPathTempVar\identity.xml'>"
  3662. ClearErrors
  3663. ${GetBetween} "<log path='" "'/>" "$INSTDIR\$ConfigFileName" "$R0" ; This makes it not brittly dependant on the default value.
  3664. !insertmacro ReplaceInFile "$INSTDIR\$ConfigFileName" "<log path='$R0'/>" "<log path='$ShortPathTempVar\'/>"
  3665. ClearErrors
  3666. ${GetBetween} "<rulebase path='" "'/>" "$INSTDIR\$ConfigFileName" "$R0" ; This makes it not brittly dependant on the default value.
  3667. !insertmacro ReplaceInFile "$INSTDIR\$ConfigFileName" "<rulebase path='$R0'/>" "<rulebase path='$ShortPathTempVar\'/>"
  3668. ClearErrors
  3669. ${GetBetween} "<workspace path='" "'/>" "$INSTDIR\$ConfigFileName" "$R0" ; This makes it not brittly dependant on the default value.
  3670. !insertmacro ReplaceInFile "$INSTDIR\$ConfigFileName" "<workspace path='$R0'/>" "<workspace path='$ShortPathTempVar\'/>"
  3671. ClearErrors
  3672. ; Now we gotta cut this out to work with it in order to have referential integrity. ( there are other tags named the same thing.... above the network block)
  3673. ${GetBetween} "<network>" "</network>" "$INSTDIR\$ConfigFileName" "$R0" ; This makes it not brittly dependant on the default value.
  3674. FileOpen $R1 "tempNetworkFile.txt" w
  3675. FileWrite $R1 $R0
  3676. FileClose $R1
  3677. ${GetBetween} "<update-script on-off='" "'" "$INSTDIR\tempNetworkFile.txt" "$R4" ; This makes it not brittly dependant on the default value.
  3678. StrCmp $R4 "" OutputEntireString 0 ; If $R0 returns empty in this instance, it means that the feature wasn't there in
  3679. ; this file version. So jump to the default and write the line.
  3680. ; Ok we need to determine if we are keeping the older setting of the auto on-off flag. Or if we are installing it fresh as default on or default off.
  3681. ; if you are using the update with existing settings, then the default for $AUTO_UPDATE_ONOFF_FLAG is off ( Set in the Section function prio to calling this sub )
  3682. ; leaving an install that didn't have these features installed previously, left to use their own mechanisms.
  3683. ; but if it was a fresh install, then it defaults to on. So if the line doesn't exist, then we just write the default line, and its either
  3684. ; fresh and on, or an update and off. But if the line does exist, then we need to trap the value in $R4 and use that one.....
  3685. ${GetBetween} "<update-script" "/>" "$INSTDIR\tempNetworkFile.txt" "$R0" ; This makes it not brittly dependant on the default value.
  3686. StrCmp $R0 "" OutputEntireString 0 ; If $R0 returns empty in this instance, it means that the feature wasn't there in
  3687. ; this file version. So jump to the default and write the line.
  3688. StrCpy $R6 "<update-script on-off='$R4' call='$ShortPathTempVar\getRulebase.cmd' guard-time='180'/>" ; R6 holds the new PUT value....
  3689. ; Typical update script looks like:
  3690. ; <update-script on-off='on' call='/MDaemon/$FolderPrefix/getRulebase.cmd' guard-time='180'/>
  3691. !insertmacro ReplaceInFile "$INSTDIR\$ConfigFileName" "<update-script$R0/>" "$R6"
  3692. ClearErrors
  3693. Delete "$INSTDIR\tempNetworkFile.txt"
  3694. Return
  3695. OutputEntireString: ; This handles if there was an empty search returned from searching for updateScript.
  3696. StrCpy $R6 "<update-script on-off='$AUTO_UPDATE_ONOFF_FLAG' call='$ShortPathTempVar\getRulebase.cmd' guard-time='180'/>"
  3697. ; Typical update script looks like:
  3698. ; <update-script on-off='on' call='/MDaemon/$FolderPrefix/getRulebase.cmd' guard-time='180'/>
  3699. ; !insertmacro ReplaceInFile "$SNFServerInstallDir\$FolderPrefix\snfmdplugin.xml" "</network>" "$R6$\r$\n</network>"
  3700. ; ClearErrors
  3701. Push "</network>" #text to be replaced
  3702. Push "$R6$\r$\n</network>" #replace with
  3703. Push 0 #replace command
  3704. Push 1 #replace but only one occurance.. not all close network references....
  3705. Push "$INSTDIR\$ConfigFileName" #file to replace in
  3706. Call AdvReplaceInFile ;; it reads the pushed variables as parameters.... ( Hey... I didn't design that interface... its confusing. )
  3707. Delete "$INSTDIR\tempNetworkFile.txt"
  3708. Return
  3709. FunctionEnd
  3710. Function .onInit
  3711. ############################ Semifor Code ###################
  3712. # Ensure we only run one instance.
  3713. System::Call 'kernel32::CreateMutexA(i 0, i 0, t "Message Sniffer") i .r1 ?e'
  3714. Pop $R0
  3715. StrCmp $R0 0 +3
  3716. MessageBox MB_OK|MB_ICONEXCLAMATION "The Message Sniffer installer is already running."
  3717. Abort
  3718. ############################ Semifor Code ###################
  3719. ; The master installer .exe should create a LocalRoot.txt file that indicates where the localroot of the mailserver is located.
  3720. ; To save us the trouble of finding it again.
  3721. ; Now identify the folder that we're in and get the local root.....
  3722. IfFileExists "$EXEDIR\LocalRoot.txt" 0 EndGracefully
  3723. ${GetBetween} '<root>' '</root>' "$EXEDIR\LocalRoot.txt" $SNFServerInstallDir ; if it was unpacked by the Installer than the file is there
  3724. ${GetBetween} '<cd>' '</cd>' "$EXEDIR\LocalRoot.txt" $INSTDIR ; if it was unpacked by the Installer than the file is there
  3725. Goto ContinueInstall
  3726. EndGracefully:
  3727. MessageBox MB_OK "Unable to resolve the local root installation directory for the mail server. Ending Installer."
  3728. Quit
  3729. ContinueInstall:
  3730. ################################################ Variable Initialization Phase ########################################################
  3731. ##
  3732. ##
  3733. #######################################################################################################################################
  3734. ; If possible, retrieve the license info from an this folder, the rollback folder or an old archived path. Not essential, but nice if we can.
  3735. ; Read the most recent archived snapshot path
  3736. IfFileExists "$INSTDIR\identity.xml" 0 TryAgain2
  3737. ${GetBetween} "licenseid='" "'" "$INSTDIR\identity.xml" $LicenseID
  3738. ${GetBetween} "authentication='" "'" "$INSTDIR\identity.xml" $Authentication
  3739. Goto MakeNew
  3740. TryAgain2:
  3741. IfFileExists "$SNFServerInstallDir\SNFRollback\identity.xml" 0 MakeNew
  3742. ${GetBetween} "licenseid='" "'" "$SNFServerInstallDir\SNFRollback\identity.xml" $LicenseID
  3743. ${GetBetween} "authentication='" "'" "$SNFServerInstallDir\SNFRollback\identity.xml" $Authentication
  3744. MakeNew: ; The system did not detect an older install or we've moved the existing one or we've chosen to install in an entirely differnt place..
  3745. ; So we will proceed with fresh folder creation.
  3746. ## Variable initilization for some flags.
  3747. StrCpy $UnpackedCURLStuff "0" ; set for first time.
  3748. StrCpy $InstallerCompletedRestore "0" ; Initialize variables to default false.
  3749. StrCpy $DownloadFailed "0" ; $DownloadFailed This Variable declared in ONinit and defaulted to "0" for use in the RulebaseDownload screens.
  3750. ################# Some Pre-Rollback housekeeping. #################################
  3751. ## Grabbing copy of current settings, before forced rollback occurs.
  3752. ## Remember, that if we CAN rollback, we must rollback to ground zero. Hence the need to grab a copy of the existing files
  3753. ## before rollback.
  3754. ; This paragraph determines if we passed the FreshInstall flag (/F) to the installer to confirm
  3755. ; the desire to ignore the existing configuration.
  3756. ${GetOptions} $CommandLineParameters "-F" $R0
  3757. IfErrors RetainExistingConfig IgnoreExistingConfig
  3758. RetainExistingConfig:
  3759. StrCpy $RetainExistingSettings "1"
  3760. ifFileExists "$INSTDIR\snfmdplugin.xml" 0 +2 ; Both MDaemons xml, and SNFServer's xml files need to
  3761. CopyFiles /SILENT "$INSTDIR\snfmdplugin.xml" "$TEMP\snfmdplugin.xml" ; be captured before we stomp them with an older install
  3762. ; if a previous install existed.
  3763. ifFileExists "$INSTDIR\snf_engine.xml" 0 Defaults ; If we need to do this, swap a copy over to temp
  3764. CopyFiles /SILENT "$INSTDIR\snf_engine.xml" "$TEMP\snf_engine.xml" ; before we rollback, so we can restore it....
  3765. ;MessageBox MB_OK "Retaining"
  3766. Goto Defaults
  3767. IgnoreExistingConfig:
  3768. StrCpy $RetainExistingSettings "0"
  3769. Defaults:
  3770. ;MessageBox MB_OK "Retaining settings:$RetainExistingSettings"
  3771. #######################################################################################################################################
  3772. ## We're installing. Therefore if there is an existing rollback file, run it.
  3773. #######################################################################################################################################
  3774. ## BlockFullUninstall is the flag for determining if there was an existing manual install
  3775. ## If we have this flag, then the uninstaller will never be allowed to
  3776. ## remove the install completely.
  3777. Var /GLOBAL localSRS_RollbackPath
  3778. ReadRegStr $localSRS_RollbackPath HKLM "Software\MessageSniffer" "SRS_RollbackPath"
  3779. ifErrors 0 SkipBlocking ; So only on teh condition that an installer hasn't run, do we consider blocking.
  3780. ifFileExists "$INSTDIR\snf2check.exe" 0 +2
  3781. WriteRegStr HKLM "Software\MessageSniffer" "BlockFullUninstall" "1"
  3782. ifFileExists "$INSTDIR\mingwm10.dll" 0 +2
  3783. WriteRegStr HKLM "Software\MessageSniffer" "BlockFullUninstall" "1"
  3784. ifFileExists "$INSTDIR\SNFClient.exe" 0 +2
  3785. WriteRegStr HKLM "Software\MessageSniffer" "BlockFullUninstall" "1" ; FULL Uninstall Prempted.
  3786. SkipBlocking:
  3787. ; We decided that we will always run an available rollback.
  3788. ReadRegStr $1 HKLM "Software\MessageSniffer" "SRS_LogName"
  3789. # If none of these trip, we'll presume safe.
  3790. StrCmp $localSRS_RollbackPath "" NoPreRoll 0 ; so exit if no rollback file.
  3791. StrCmp $1 "" NoPreRoll 0 ; and no log.....
  3792. ## IF there are ANY valid rollback scenarios we are going to execute them prior to running a new install.
  3793. ## Before we let the rollback put things back... presuming we have a service installed, we'll need to stop it....
  3794. Call stopSNFServer ; if it there it will stop it.
  3795. Call stopXYNTService ; if its there, stop it.
  3796. ## IN the possible scenarior that we are uninstalling and rolling back a previous install when we are installing a seperate platform..
  3797. ## Pull in the reg key from the old system:
  3798. Var /GLOBAL OLD_INSTALL_DIR ; possible old , but if its the same (current) install folder, its ok.... it will still be functional.
  3799. ReadRegStr $OLD_INSTALL_DIR HKLM "Software\MessageSniffer" "Install_Dir"
  3800. ## Use that folder to trip the uninstall of XYNTService to enable the rollback.... ( The reason for this is that the NEW InstallDIR could be
  3801. ## different because of the LocalRoot.txt file coming from the users selection of a different platform... i.e. The $INSTDIR is where its GOING
  3802. ## not where the registry said it WAS......
  3803. IfFileExists "$OLD_INSTALL_DIR\XYNTService.exe" 0 +2
  3804. nsExec::Exec "$OLD_INSTALL_DIR\XYNTService -u" "" SH_HIDE ; uninstall it if it exists....
  3805. ## Now we should be ready to fire... even if its over the bow, to an older platform...
  3806. ## ADDING sensitivity to the functions being called to enable them to look up the proper path values in the event that the
  3807. ## rollback sequence is not in the current INSTDIR and $SNFServerInstallDir locations. i.e. Those parsing functions need to be able
  3808. ## to find the correct file to be editing. If its rolling back an older version cross platform, then it needs to redefine the file its
  3809. ## targeting, not just assume that its in the INSTDIR or the $SNFServerInstallDir. I added two registry keys to the EndRollbackSequence
  3810. ## subroutine called SRS_INSTDIR and SRS_SERVDIR to cover the lookup during rollback....since by this point INSTDIR is defined,
  3811. ## just having SRS_INSTDIR different from INSTDIR should be enough key to use the SRS_INSTDIR.... and if the SRS_INSTDIR doesnt' exist,
  3812. ## ( because it wouldn't be entered until the end of the rollback sequence, then the functions will know they are in the new install, and
  3813. ## will use the current INSTDIR as their paths.....
  3814. ## Get this before its rolled back and gone.
  3815. Var /GLOBAL localSRS_INSTDIR
  3816. Var /GLOBAL localSRS_SERVDIR
  3817. ReadRegStr $localSRS_INSTDIR HKLM "Software\MessageSniffer" "SRS_INSTDIR"
  3818. ReadRegStr $localSRS_SERVDIR HKLM "Software\MessageSniffer" "localSRS_SERVDIR"
  3819. ${RollBackTo} $localSRS_RollbackPath $1 ; Put all the files back the way they were. ; Both those values come from registry....
  3820. RMDir /r $localSRS_RollbackPath
  3821. ## Finish cleanup.
  3822. ## IF there is no SNFServer.exe there should be nothing else
  3823. ifFileExists "$localSRS_INSTDIR\SNFClient.exe" SkipNow 0 ; otherwise cleanup.
  3824. ifFileExists "$localSRS_INSTDIR\Restorer.exe" 0 +2
  3825. Delete "$localSRS_INSTDIR\Restorer.exe"
  3826. ifFileExists "$localSRS_INSTDIR\oldsnifferversion.txt" 0 +2
  3827. Delete "$localSRS_INSTDIR\oldsnifferversion.txt"
  3828. ifFileExists "$localSRS_INSTDIR\getRulebase.cmd.old" 0 +2
  3829. Delete "$localSRS_INSTDIR\getRulebase.cmd.old"
  3830. ifFileExists "$localSRS_INSTDIR\shortcuts.xml" 0 +2
  3831. Delete "$localSRS_INSTDIR\shortcuts.xml" ; if exists ; Find other location
  3832. ifFileExists "$localSRS_INSTDIR\cfgstring.xml" 0 +2
  3833. Delete "$localSRS_INSTDIR\cfgstring.xml" ; if exists ; Find other location
  3834. ifFileExists "$localSRS_INSTDIR\XYNTService.ini" 0 +2
  3835. Delete "$localSRS_INSTDIR\XYNTService.ini"
  3836. ifFileExists "$localSRS_INSTDIR\LocalRoot.txt" 0 +2
  3837. Delete "$localSRS_INSTDIR\LocalRoot.txt"
  3838. ifFileExists "$localSRS_INSTDIR\SNFServer${SNIFFER_SERVER_SPECIFIER}.exe" 0 +2
  3839. Delete "$localSRS_INSTDIR\SNFServer${SNIFFER_SERVER_SPECIFIER}.exe"
  3840. ifFileExists "$localSRS_INSTDIR\UpdateReady.txt" 0 +2
  3841. Delete "$localSRS_INSTDIR\UpdateReady.txt"
  3842. ifFileExists "$localSRS_INSTDIR\mingwm10.dll" 0 +2
  3843. Delete "$localSRS_INSTDIR\mingwm10.dll"
  3844. Delete "$localSRS_INSTDIR\uninstall.exe"
  3845. ; since we couldn't edit the registry, we don't need to worry abou tit. Now Kill attempt:
  3846. ## For MINMI
  3847. ifFileExists "$localSRS_SERVDIR\SNFIMailShimNEW.xml" 0 +2
  3848. Delete "$localSRS_SERVDIR\SNFIMailShimNEW.xml"
  3849. ifFileExists "$localSRS_SERVDIR\SNFIMailShim.xml" 0 +2
  3850. Delete "$localSRS_SERVDIR\SNFIMailShim.xml"
  3851. ifFileExists "$localSRS_SERVDIR\SNFIMailShim.exe" 0 +2
  3852. Delete "$localSRS_SERVDIR\SNFIMailShim.exe"
  3853. ifFileExists "$localSRS_SERVDIR\MIMIMIreadme.txt" 0 +2
  3854. Delete "$localSRS_SERVDIR\MIMIMIreadme.txt"
  3855. ifFileExists "$localSRS_SERVDIR\OLD_SNFIMailShim.exe" 0 +2
  3856. Delete "$localSRS_SERVDIR\OLD_SNFIMailShim.exe"
  3857. ifFileExists "$localSRS_SERVDIR\OLD_SNFIMailShim.xml" 0 +2
  3858. Delete "$localSRS_SERVDIR\OLD_SNFIMailShim.xml"
  3859. ## For MDaemon
  3860. ifFileExists "$localSRS_SERVDIR\snfmdplugin.dll" 0 +2
  3861. Delete "$localSRS_SERVDIR\snfmdplugin.dll"
  3862. ifFileExists "$localSRS_SERVDIR\snfmdplugin.xml" 0 +2
  3863. Delete "$localSRS_SERVDIR\snfmdplugin.xml"
  3864. ;ifFileExists "$localSRS_SERVDIR\OLD_SNFIMailShim.xml" 0 +2 ; if we find the xml file, then we need to do checking...
  3865. ; Rename "$localSRS_SERVDIR\OLD_SNFIMailShim.xml" "$localSRS_SERVDIR\SNFIMailShim.xml"
  3866. ;ifFileExists "$localSRS_SERVDIR\OLD_SNFIMailShim.exe" 0 +2 ; if we find the xml file, then we need to do checking...
  3867. ; Rename "$localSRS_SERVDIR\OLD_SNFIMailShim.exe" "$localSRS_SERVDIR\SNFIMailShim.exe"
  3868. SkipNow:
  3869. ;MessageBox MB_OK "Breaking"
  3870. Goto NoPreRoll
  3871. NoPreRoll:
  3872. ;MessageBox MB_OK "Starting Rollback Transaction"
  3873. ################################################ Start Rollback.nsh ###################################################################
  3874. ## A Install requires a rollback build.
  3875. ##
  3876. ## First define the rollback folder:
  3877. !insertmacro StartRollbackSession "$SNFServerInstallDir\SNFRollBack" "Archive_rllbck.log" "HKLM" "Software\MessageSniffer" ; _ArchivePath _LogName
  3878. ## Registry USAGE: $SetRegistry_with_RollbackControl "HKLM" "Software\MessageSniffer" "RollbackSequence" "0121"
  3879. ## File USAGE: ${Install_with_RollbackControl} "License.txt" ""
  3880. ## !insertmacro StartRollbackSession - Starts the rollback session to begin recording file and registry data.
  3881. ## !insertmacro EndRollbackSession - closes the rollback session
  3882. ## ${SetRegistry_with_RollbackControl} _RootKey _RegistryKey _SubKey _Value - Records a registry change for rollback.
  3883. ## ${Install_with_RollbackControl} _someFileName _onFailCommand - Installs a file with archival of old file for rollback.
  3884. ## ${Copy_with_RollbackControl} _someFile _Path _onFailCommand - Makes a copy of an existing file and records it in log for rollback.
  3885. ## ${RollBackTo} _rollbackLocalPath _rollbackLogName - Runs the parser through the rollback log and puts everything back.
  3886. #################################################################################################################
  3887. ; Set output path to the installation directory.
  3888. SetOutPath $INSTDIR
  3889. ; Write the installation path into the registry
  3890. ; WriteRegStr HKLM Software\MessageSniffer "Install_Dir" "$SNFServerInstallDir\$FolderPrefix"
  3891. ${SetRegistry_with_RollbackControl} "HKLM" "Software\MessageSniffer" "Install_Dir" "$INSTDIR"
  3892. ${SetRegistry_with_RollbackControl} "HKLM" "Software\MessageSniffer" "SNFMailServer_DIR" "$SNFServerInstallDir"
  3893. ## Prime doesn't matter anymore because we will ALWAYS run an existing rollback file, thus ensuring that the only way a
  3894. ## last working install is available is if the user had one installed manually.
  3895. ;ReadRegStr $2 HKLM "Software\MessageSniffer" "Prime"
  3896. ;${IF} $2 = "1"
  3897. ; ${SetRegistry_with_RollbackControl} "HKLM" "Software\MessageSniffer" "Prime" "0"
  3898. ;${ELSE}
  3899. ; ${SetRegistry_with_RollbackControl} "HKLM" "Software\MessageSniffer" "Prime" "1"
  3900. ;${ENDIF}
  3901. ; Also... if the OLD install... ( if there was one.... ) had the shortcuts installed... and they didnt' call for them here....
  3902. ; then we need to remove them... ( and if they want them, they'll be put back when that section fire.s
  3903. ; but if they WERE installed... we need to put it back on a rollback....
  3904. ifFileExists "$INSTDIR\shortcuts.xml" 0 SkipShortCutRollback
  3905. ${Copy_with_RollbackControl} "shortcuts.xml" "$INSTDIR" "" "" ; Copy the old Server.exe
  3906. SkipShortCutRollback:
  3907. Call removeShortcuts ; This will be reinstalled with the shortcuts pointing at the newer files, in the Section reguarding shortcuts anyway...
  3908. Return
  3909. ############################################################### ROLLBACK CODE ############################################################
  3910. ## Handled by th $rollback macro in Rollback.nsh.
  3911. PerformRollback:
  3912. ;MessageBox MB_OK "Stubbed Code."
  3913. return
  3914. ; Before we let the rollback put things back... presuming we have a service installed, we'll need to stop it....
  3915. Call stopSNFServer ; if it there it will stop it.
  3916. Call stopXYNTService ; if its there, stop it.
  3917. ; Since this is not being executed from the SNF directory, we are not put here by the master utility for a fresh
  3918. ; install. Instead, we are being called remotely ( or by a click...) from an archived directory. It dosn't really mater
  3919. ; where the archive is, but it ususally will be in [SomeMailInstalDirectory]\SNFArchive\[WheteverDirName]
  3920. ; So the first thing is to empty the SNF Directory.
  3921. ${RollBackTo} "$SNFServerInstallDir\SNFRollBack" "Archive_rllbck.log" ; Put all the files back the way they were.
  3922. ; This simplified all the following code, because files that were NOT there on install are deleted, files that were are replaced to their original format
  3923. ; and files that weren't touched remain there.....
  3924. ## Won't need to do this cause we're not yanking the rulebase....
  3925. ##; We'll need the LicenseID in order to search and save the rulebase file if it exists.
  3926. ##${GetBetween} "licenseid='" "'" "$EXEDIR\identity.xml" $LicenseID ; This makes it not brittly dependant on the default value. i.e. It would
  3927. ##${GetBetween} "authentication='" "'" "$EXEDIR\identity.xml" $Authentication
  3928. ## INTENTIONALLY HARD TYPED.... reguardless of the target folder.
  3929. ##IfFileExists "$SNFServerInstallDir\SNF\$LicenseID.snf" 0 +2
  3930. ## Rename "$SNFServerInstallDir\SNF\$LicenseID.snf" "$SNFServerInstallDir\$LicenseID.snf" ; Move the existing rulebase out of the SNF directory.
  3931. ##IfFileExists "$SNFServerInstallDir\Sniffer\$LicenseID.snf" 0 +2
  3932. ## Rename "$SNFServerInstallDir\Sniffer\$LicenseID.snf" "$SNFServerInstallDir\$LicenseID.snf" ; Move the existing rulebase out of the SNF directory.
  3933. # Reguardless of $FolderPrefix, kill these existing folders.
  3934. ##IfFileExists "$SNFServerInstallDir\SNF\*.*" 0 DoSniffer
  3935. ## Delete "$SNFServerInstallDir\SNF\*.*" ; Kill all files in the SNF Dir. INTENTIONALLY HARD TYPED.....
  3936. ## RMDir "$SNFServerInstallDir\SNF"
  3937. ##DoSniffer:
  3938. ## IfFileExists "$SNFServerInstallDir\Sniffer\*.*" 0 +3
  3939. ## Delete "$SNFServerInstallDir\Sniffer\*" ; Kill all files in the sniffer Dir. INTENTIONALLY HARD TYPED.....
  3940. ## RMDir "$SNFServerInstallDir\Sniffer"
  3941. ##CreateDirectory "$SNFServerInstallDir\$FolderPrefix" ;Recreates target folder. Sniffer and SNF safe...
  3942. ##IfFileExists "$SNFServerInstallDir\$LicenseID.snf" 0 +2
  3943. ## Rename "$SNFServerInstallDir\$LicenseID.snf" "$SNFServerInstallDir\$FolderPrefix\$LicenseID.snf" ; Move the existing rulebase back into the SNF directory.
  3944. ## This is handled by teh rollback function....
  3945. ##; Now expressly copy all files to the SNF folder.
  3946. ##;MessageBox MB_OK "Restoring"
  3947. ## CopyFiles /SILENT "$EXEDIR\About-Wget-and-Gzip.txt" "$SNFServerInstallDir\$FolderPrefix\About-Wget-and-Gzip.txt"
  3948. ## CopyFiles /SILENT "$EXEDIR\AuthenticationProtocol.swf" "$SNFServerInstallDir\$FolderPrefix\AuthenticationProtocol.swf"
  3949. ## CopyFiles /SILENT "$EXEDIR\Archiver.exe" "$SNFServerInstallDir\$FolderPrefix\Archiver.exe"
  3950. ## CopyFiles /SILENT "$EXEDIR\ChangeLog.txt" "$SNFServerInstallDir\$FolderPrefix\ChangeLog.txt"
  3951. ## CopyFiles /SILENT "$EXEDIR\exchndl.dll" "$SNFServerInstallDir\$FolderPrefix\exchndl.dll"
  3952. ## CopyFiles /SILENT "$EXEDIR\GBUdbIgnoreList.txt" "$SNFServerInstallDir\$FolderPrefix\GBUdbIgnoreList.txt"
  3953. ## CopyFiles /SILENT "$EXEDIR\getRulebase.cmd" "$SNFServerInstallDir\$FolderPrefix\getRulebase.cmd"
  3954. ## CopyFiles /SILENT "$EXEDIR\gzip.exe" "$SNFServerInstallDir\$FolderPrefix\gzip.exe"
  3955. ## CopyFiles /SILENT "$EXEDIR\identity.xml" "$SNFServerInstallDir\$FolderPrefix\identity.xml"
  3956. ## CopyFiles /SILENT "$EXEDIR\License.txt" "$SNFServerInstallDir\$FolderPrefix\License.txt"
  3957. ## CopyFiles /SILENT "$EXEDIR\LocalRoot.txt" "$SNFServerInstallDir\$FolderPrefix\LocalRoot.txt"
  3958. ## CopyFiles /SILENT "$EXEDIR\mingwm10.dll" "$SNFServerInstallDir\$FolderPrefix\mingwm10.dll"
  3959. ## CopyFiles /SILENT "$EXEDIR\Restorer.exe" "$SNFServerInstallDir\$FolderPrefix\Restorer.exe"
  3960. ## CopyFiles /SILENT "$EXEDIR\send_shutdown.cmd" "$SNFServerInstallDir\$FolderPrefix\send_shutdown.cmd"
  3961. ## CopyFiles /SILENT "$EXEDIR\snf2check.exe" "$SNFServerInstallDir\$FolderPrefix\snf2check.exe"
  3962. ## CopyFiles /SILENT "$EXEDIR\snf_engine.xml" "$SNFServerInstallDir\$FolderPrefix\snf_engine.xml"
  3963. ## CopyFiles /SILENT "$EXEDIR\snf_xci.xml" "$SNFServerInstallDir\$FolderPrefix\snf_xci.xml"
  3964. ## CopyFiles /SILENT "$EXEDIR\SNFClient.exe" "$SNFServerInstallDir\$FolderPrefix\SNFClient.exe"
  3965. ## CopyFiles /SILENT "$EXEDIR\SNFClient_readme.txt" "$SNFServerInstallDir\$FolderPrefix\SNFClient_readme.txt"
  3966. ## CopyFiles /SILENT "$EXEDIR\SNFServer_readme.txt" "$SNFServerInstallDir\$FolderPrefix\SNFServer_readme.txt"
  3967. ## IFFileExists "$EXEDIR\SNFServer${SNIFFER_SERVER_SPECIFIER}.exe" 0 +2
  3968. ## CopyFiles /SILENT "$EXEDIR\SNFServer${SNIFFER_SERVER_SPECIFIER}.exe" "$SNFServerInstallDir\$FolderPrefix\SNFServer${SNIFFER_SERVER_SPECIFIER}.exe"
  3969. ## IFFileExists "$EXEDIR\SNFServer.exe" 0 +2
  3970. ## CopyFiles /SILENT "$EXEDIR\SNFServer.exe" "$SNFServerInstallDir\$FolderPrefix\SNFServer.exe"
  3971. ## IFFileExists "$EXEDIR\$LicenseID.exe" 0 +2
  3972. ## CopyFiles /SILENT "$EXEDIR\$LicenseID.exe" "$SNFServerInstallDir\$FolderPrefix\$LicenseID.exe"
  3973. ## CopyFiles /SILENT "$EXEDIR\wget.exe" "$SNFServerInstallDir\$FolderPrefix\wget.exe"
  3974. ## CopyFiles /SILENT "$EXEDIR\XYNTService.exe" "$SNFServerInstallDir\$FolderPrefix\XYNTService.exe"
  3975. ## CopyFiles /SILENT "$EXEDIR\XYNTService.ini" "$SNFServerInstallDir\$FolderPrefix\XYNTService.ini"
  3976. ## CopyFiles /SILENT "$EXEDIR\XYNTServiceReadMe.txt" "$SNFServerInstallDir\$FolderPrefix\XYNTServiceReadMe.txt"
  3977. ## IFFileExists "$EXEDIR\uninstall.bckup" 0 +2
  3978. ## CopyFiles /SILENT "$EXEDIR\uninstall.bckup" "$SNFServerInstallDir\$FolderPrefix\uninstall.exe"
  3979. ## IfFileExists "$EXEDIR\cfgstring.xml" 0 +2 ; this is used to restore the global.cfg entry line. it gets consumed as its mined.
  3980. ## CopyFiles /SILENT "$EXEDIR\cfgstring.xml" "$SNFServerInstallDir\$FolderPrefix\cfgstring.xml"
  3981. ##########################
  3982. ## ; Write the installation path into the registry
  3983. ## WriteRegStr HKLM Software\MessageSniffer "Install_Dir" "$SNFServerInstallDir\$FolderPrefix"
  3984. ##########################
  3985. ##; Declude Special
  3986. ##ifFileExists "$SNFServerInstallDir\global.cfg" 0 +2 ; replace line in existing cfg file with line from archived cfg command.
  3987. ## call editglobalCFG
  3988. ############################ MxGuard Special #####################
  3989. ## ifFileExists "$SNFServerInstallDir\mxGuard.ini" 0 +2
  3990. ## call editMXGuardINI
  3991. ##########################
  3992. ##; MINIMI Special. IF MINIMI was installed with this version then we need to restore from the archive....
  3993. ##Var /GLOBAL MINIMISpecial_KeyHandle
  3994. ##ifFileExists "$EXEDIR\OLD_SNFIMailShim.xml" 0 SkipMINIMISpecial
  3995. ## ; ok, well the file exists, so we need to make sure that the registry entrys are there....
  3996. ## ClearErrors
  3997. ## ReadRegStr $MINIMISpecial_KeyHandle HKLM "SOFTWARE\Ipswitch\IMail\Global" "TopDir" ; get IMails value.
  3998. ## StrCmp $MINIMISpecial_KeyHandle "" SkipMINIMISpecial 0 ; test for valid TopDir for Imail.
  3999. ## ; so we can presume that Imail should exist, and this setting is ON....
  4000. ## WriteRegStr HKLM "Software\MessageSniffer" "isMINIMIInstalled" "1" ; Since we have the file in the folder, we're resetting it back...
  4001. ## WriteRegStr HKLM "Software\MessageSniffer" "MINIMIInstallFolder" "$MINIMISpecial_KeyHandle" ; Since we have the file in the folder, we're resetting it back...
  4002. ## IfFileExists "$MINIMISpecial_KeyHandle\SNFIMailShim.xml" 0 +2
  4003. ## Delete "$MINIMISpecial_KeyHandle\SNFIMailShim.xml"
  4004. ## IfFileExists "$MINIMISpecial_KeyHandle\SNFIMailShim.exe" 0 +2
  4005. ## Delete "$MINIMISpecial_KeyHandle\SNFIMailShim.exe"
  4006. ## CopyFiles "$EXEDIR\OLD_SNFIMailShim.xml" "$MINIMISpecial_KeyHandle\SNFIMailShim.xml"
  4007. ## CopyFiles "$EXEDIR\SNFIMailShim.exe" "$MINIMISpecial_KeyHandle\SNFIMailShim.exe"
  4008. # Now you must re-tie-in IMail to the MINIMI Install.....
  4009. # If you're restoring an image onto somehting ( say DECLUDE ) that stompted the SendName anyway, then you need a new install of MINIMI....
  4010. # not a restored version of MINIMI. If you restore it, it will stomp the Declude.
  4011. ## WriteRegStr HKLM "SOFTWARE\Ipswitch\IMail\Global" "SendName" "$MINIMISpecial_KeyHandle\SNFIMailShim.exe"
  4012. ; We can presume its pointing at what it should have been pointing at. If you're restoring a MINIMI install and its target is gone...
  4013. ; oh well... not my problem....
  4014. # Last, verify that the hold folder exists for the installation and create it if it doesn't.
  4015. ## ${GetBetween} "<hold path='" "\'/>$\r$\n" "$MINIMISpecial_KeyHandle\SNFIMailShim.xml" "$R0" ; This makes it not brittly dependant on the default value. i.e. It would
  4016. ## IfFileExists "$R0\*.*" +2 0 ; if it exists then skip, otherwise, recreate the spam target directory
  4017. ## CreateDirectory "$R0\*.*"
  4018. ##SkipMINIMISpecial:
  4019. ################################################# End MINIMI INSTALL RESTORE ###########################################################
  4020. MessageBox MB_OK "Stubbed Code. This should never run."
  4021. ## Shortcuts only relevant for modern installed verions, not sniffy.....
  4022. ## Handle shortcut exception.
  4023. IfFileExists "$SNFServerInstallDir\SNFRollback\shortcuts.xml" 0 RemoveTheShortcuts
  4024. ##CopyFiles /SILENT "$EXEDIR\shortcuts.xml" "$SNFServerInstallDir\$FolderPrefix\shortcuts.xml"
  4025. ; But if it exists, it means that they were installed so put them back.
  4026. SetShellVarContext all ; this makes it backward/forwrad compatible Without it Vista will have problems removing shortcuts.
  4027. ; Essentially, we said put these shortcuts into the all-users profile of the machine
  4028. CreateDirectory "$SMPROGRAMS\MessageSniffer"
  4029. CreateShortCut "$SMPROGRAMS\MessageSniffer\InstallInstructions.lnk" "$INSTDIR\InstallInstructions.txt"
  4030. CreateShortCut "$SMPROGRAMS\MessageSniffer\MessageSniffer.lnk" "http://kb.armresearch.com/index.php?title=Message_Sniffer"
  4031. CreateShortCut "$SMPROGRAMS\MessageSniffer\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  4032. CreateShortCut "$SMPROGRAMS\MessageSniffer\GBUdbIgnoreList.lnk" "$INSTDIR\GBUdbIgnoreList.txt"
  4033. Goto SkipShortcuts
  4034. RemoveTheShortcuts:
  4035. ; if the files exists... and the restore says that they didn't have them for the restored version.... then they need to go away.
  4036. Call removeShortCuts
  4037. SkipShortcuts:
  4038. ;MessageBox MB_OK "Starting SNFService"
  4039. ## These would have been handled by the ROllBACK if they existed, and removed if they didn't.
  4040. ##SetOutPath $INSTDIR
  4041. ##File "XYNTService.exe" ; Unpack the files.
  4042. ##File "XYNTService.ini"
  4043. MessageBox MB_OK "Stubbed Code. This should never run."
  4044. call editXYNTServiceINI ; First properly handle the ini file.
  4045. ## HERE we say, if the file still exists after the rollback.... THEN... we can reinstall the XYNTService.
  4046. nsExec::Exec "XYNTService -u" "" SH_HIDE ; uninstall it if it exists....
  4047. ; presumes that the .ini file is in the same location.
  4048. nsExec::Exec "XYNTService -i" "" SH_HIDE ; install XYNTService
  4049. nsExec::Exec "XYNTService -r" "" SH_HIDE ; restart XYNTService
  4050. call startSNFServer ;nsExec::Exec "NET START SNFService" "" SH_HIDE
  4051. call onRestoreSuccess
  4052. Quit ; This will transfer control to the license page, which will determine if a restore was just completed
  4053. ; prior to displaying the license. If it IS we use the RelGotoPage function to move us to the restore-success screen and end.
  4054. FunctionEnd
  4055. ; The stuff to install
  4056. Section "MessageSniffer (required)"
  4057. ; MessageBox MB_OK "Entering sniffer reuqired section. "
  4058. SectionIN RO ; Required Option express declaration.
  4059. ; Set output path to the installation directory.
  4060. SetOutPath $INSTDIR ; even the rollback scripts depend on having this properly assigned in the installer. They'll put it where this is set.
  4061. ; presuming we have an existing service installed, we'll need to stop it.... ( doesn't hurt if its not there. )
  4062. Call stopSNFServer ; if its there it will stop it.
  4063. Call stopXYNTService ; if its there, stop it.
  4064. ## A lot of conditional branching needs to skip over things if this is an MDaemon install. As opposed to all other installs.
  4065. ## So its worth defining an MDaemon flag.
  4066. Var /GLOBAL isMDaemonInstalled
  4067. StrCpy $isMDaemonInstalled 0 ; default to no.
  4068. ifFileExists "$SNFServerInstallDir\App\MDaemon.exe" 0 NoDetectableMDaemon ; Would have to be there for MDaemon.
  4069. ifFileExists "$SNFServerInstallDir\SpamAssassin\rules\*.*" 0 NoDetectableMDaemon ; also dependant on the rules plugin.
  4070. StrCpy $isMDaemonInstalled 1 ;ok, its here, so use conditional branching on MDaemon flag.
  4071. ## The following calls to the CopyWithRollbackControl have the file, the location and the callback function name that needs to be defined
  4072. ## somewere above. Eventually, on restore, if a call back function is defined it will be called in order to trip a restore/strip function call.
  4073. ## MDaemon Special ## Note the MDaemon snfmdplugins.xml file is handled specially, alongside the snfengine.xml file code further down.
  4074. SetOutPath "$INSTDIR"
  4075. ${Install_with_RollbackControl} "InstallInstructions_MDaemon.txt" "" "" ; Install and remove this file on rollback.
  4076. ${Install_with_RollbackControl} "snfmdplugin.dll" "" "" ; Install and remove this file on rollback.
  4077. SetOutPath "$SNFServerInstallDir\SpamAssassin\rules"
  4078. ${Install_with_RollbackControl} "snf-groups.cf" "" "" ; Install and remove this file on rollback.
  4079. ## Handle the MDaemon Plugins file. If exists, copy old, if gone, insert new, then when done, call edit to validate/correct entries.
  4080. SetOutPath "$SNFServerInstallDir\App"
  4081. ifFileExists "$SNFServerInstallDir\App\Plugins.dat" 0 NewPluginsDatFile
  4082. ;MessageBox MB_OK "MDAEMONDEBUG:Plugins exists. Copying Rollback."
  4083. ${Copy_with_RollbackControl} "Plugins.dat" "$SNFServerInstallDir\App" "restoreMDaemonDAT" "" ; Copy the old PluginsFile if it exists file.
  4084. Goto DoneWithPluginsDatFile
  4085. NewPluginsDatFile:
  4086. ;MessageBox MB_OK "MDAEMONDEBUG: Plugins doesn't exist Install with Rollback."
  4087. ${Install_with_RollbackControl} "Plugins.dat" "restoreMDaemonDAT" "" ; Install and remove this file on rollback.
  4088. DoneWithPluginsDatFile:
  4089. SetOutPath "$INSTDIR"
  4090. NoDetectableMDaemon:
  4091. SetOutPath "$INSTDIR" ; even the rollback scripts depend on having this properly assigned in the installer. They'll put it where this is set.
  4092. ; If we got to here then we're ok to commit the files.
  4093. ; Put file there
  4094. ${Install_with_RollbackControl} "CURLREADME.rtf" "" ""
  4095. ${Install_with_RollbackControl} "CURLMANUAL.rtf" "" ""
  4096. ${Install_with_RollbackControl} "AuthenticationProtocol.swf" "" ""
  4097. #File /a "AuthenticationProtocol.swf"
  4098. ${Install_with_RollbackControl} "ChangeLog.txt" "" ""
  4099. #File /a "ChangeLog.txt"
  4100. ; File /a "getRulebase.cmd" This is handled during the init of the download rulebase page.
  4101. ; These files are handled during download of rulebase page also.
  4102. #${Install_with_RollbackControl} "gzip.exe" ""
  4103. #File /a "gzip.exe"
  4104. #${Install_with_RollbackControl} "snf2check.exe" ""
  4105. #File /a "snf2check.exe"
  4106. #${Install_with_RollbackControl} "curl.exe" ""
  4107. # File /a "curl.exe"
  4108. ${Install_with_RollbackControl} "License.txt" "" ""
  4109. #File /a "License.txt"
  4110. ${Install_with_RollbackControl} "SNFClient.exe" "" ""
  4111. #File /a "SNFClient.exe"
  4112. ${Install_with_RollbackControl} "SNFClient_readme.txt" "" ""
  4113. #File /a "SNFClient_readme.txt"
  4114. ${Install_with_RollbackControl} "mingwm10.dll" "" ""
  4115. #File /a "mingwm10.dll"
  4116. ## These files do NOT need to be installed if the MDaemon install is being utilized.
  4117. StrCmp $isMDaemonInstalled 0 0 SkipForMDaemon1
  4118. SetOutPath "$INSTDIR"
  4119. ${Install_with_RollbackControl} "exchndl.dll" "" ""
  4120. #File /a "exchndl.dll"
  4121. ${Install_with_RollbackControl} "send_shutdown.cmd" "" ""
  4122. #File /a "send_shutdown.cmd"
  4123. ${Install_with_RollbackControl} "snf_xci.xml" "" ""
  4124. #File /a "snf_xci.xml"
  4125. ${Install_with_RollbackControl} "SNFServer_readme.txt" "" ""
  4126. #File /a "SNFServer_readme.txt"
  4127. ${Install_with_RollbackControl} "SNFServer${SNIFFER_SERVER_SPECIFIER}.exe" "" "" ; Record and put the file name.
  4128. #File /a "SNFServer${SNIFFER_SERVER_SPECIFIER}.exe"
  4129. ${Install_with_RollbackControl} "SNFServer.exe" "" "" ; Record and put the file name.
  4130. ## InstallXYNTServiceFile
  4131. ${Install_with_RollbackControl} "XYNTService.exe" "" ""
  4132. #File /a "XYNTService.exe"
  4133. ${Install_with_RollbackControl} "XYNTService.ini" "restoreXYNTini" ""
  4134. #File /a "XYNTService.ini"
  4135. ${Install_with_RollbackControl} "XYNTServiceReadMe.txt" "" ""
  4136. #File /a "XYNTServiceReadMe.txt"
  4137. ${Install_with_RollbackControl} "InstallInstructions.txt" "" "" ; Install and remove this file on rollback.
  4138. SkipForMDaemon1:
  4139. SetOutPath "$INSTDIR"
  4140. ; THESE files are copied by default and then stomped if we find one in the archive if we are preserving settings.
  4141. ${Install_with_RollbackControl} "GBUdbIgnoreList.txt" "" ""
  4142. #File /a "GBUdbIgnoreList.txt"
  4143. ${Install_with_RollbackControl} "identity.xml" "" ""
  4144. #File /a "identity.xml"
  4145. ## Because of the rollback its possible that the snf_engine.xml file was removed. But if the user selected UPDATE ( retain settings ),
  4146. ## Then we will have put a copy in the temp folder: Copy it into the install directory and the new rollback engine will maintain it.
  4147. SetOutPath "$INSTDIR"
  4148. StrCmp $RetainExistingSettings "0" FreshSNFEngine HandleRetainingSNFENGINEFILE # ( Or the MDaemonDLL.xml file )....
  4149. FreshSNFEngine:
  4150. ;MessageBox MB_OK "Not retaining"
  4151. ; This situation is trivial. Just allow the files to be installed in the rollback log. If an older file exists,
  4152. ; keep a copy for rollback, but the new file goes in the new install spot.
  4153. StrCmp $isMDaemonInstalled 0 DoWinService DoMDaemonFreshInstead
  4154. DoWinService:
  4155. ${Install_with_RollbackControl} "snf_engine.xml" "" ""
  4156. Goto DoneWithSNFHandling
  4157. DoMDaemonFreshInstead:
  4158. ${Install_with_RollbackControl} "snfmdplugin.xml" "" "" ; Install and remove this file on rollback.
  4159. Goto DoneWithSNFHandling
  4160. HandleRetainingSNFENGINEFILE:
  4161. ; This is a little trickers. We need to retain all the settings from the older install, but we need to be sure that all the paths are correct
  4162. ; and that we're referencing the new file. SO... we need to use a Copy _with_Rollback
  4163. ; But there are issues. First, we rollback EVERY time, if there's a rolback to be had. So you need to look in .onInit BEFORE the rollback
  4164. ; triggers to find where we copied the snfmdplugin.xml and the snf_engine.xml file, for retrieval. ( TEMP folder ) Then we let teh rollback happen.
  4165. ; That puts either an old file, or it deletes and removes the only one that was there.
  4166. ; THEN we look for that file, below, and if we find it, we copy it in, and call the edit function to ensure path-compliance.
  4167. ; If its not there, then we put jump to the new-install path, and complete.
  4168. ; Because this behavior needs to be duplicated between the snfEngine file and the mdplugin.xml file... we effectively double it here.
  4169. StrCmp $isMDaemonInstalled 0 DoWinServiceRetaining DoMDaemonRetainingInstead
  4170. DoWinServiceRetaining:
  4171. ; Ok, so look for it where we stuffed the copy during onInit. ( Before rollback. )
  4172. ifFileExists "$TEMP\snf_engine.xml" 0 NotInTempDir ; If its there then we copy it back to the install directory.
  4173. ;MessageBox MB_OK "Existed"
  4174. CopyFiles "$TEMP\snf_engine.xml" "$INSTDIR\snf_engine.xml" ; joy
  4175. NotInTempDir: ; If it didn't exist, then somethings wierd, but recoverable.
  4176. ifFileExists "$INSTDIR\snf_engine.xml" 0 FreshSNFEngine ; Check to see if it exists IN the folder... if it does, then keep copy for rollback.
  4177. ; Otherwise, jump to fresh install path and put a new copy in place.
  4178. ${Copy_with_RollbackControl} "snf_engine.xml" $INSTDIR "" "" ; Copy the old snf_engine.xml file.
  4179. Delete "$TEMP\snf_engine.xml" ; Remove the temp if it exists.
  4180. Goto DoneWithSNFHandling ; Done with the SNF Windows Service retain-settings path.
  4181. DoMDaemonRetainingInstead: ; Ok, we're handling the MDaemon version...
  4182. ifFileExists "$TEMP\snfmdplugin.xml" 0 NotInTempDir2 ; Look for the MDaemon xml version in the Temp. ( Copied before onInit rolled back. )
  4183. CopyFiles "$TEMP\snfmdplugin.xml" "$INSTDIR\snfmdplugin.xml" ; Move file back if found.
  4184. NotInTempDir2: ; Nope, not in the temp.. look local just in case.
  4185. ifFileExists "$INSTDIR\snfmdplugin.xml" 0 FreshSNFEngine ; if Not in local, then call for fresh, and pump out new.
  4186. ${Copy_with_RollbackControl} "snfmdplugin.xml" $INSTDIR "" "" ; If it does exist, keep the backup in the rollback, who knows where it came from.
  4187. Delete "$TEMP\snf_engine.xml" ; Delete temp if exists.
  4188. Goto DoneWithSNFHandling ; done.
  4189. DoneWithSNFHandling:
  4190. #File /a "snf_engine.xml"
  4191. StrCmp $RetainExistingSettings "1" 0 callEdits
  4192. ifFileExists "$SNFServerInstallDir\SNFRollback\snfmdplugin.xml" 0 +2 ; Only if file exists.....
  4193. CopyFiles /SILENT "$SNFServerInstallDir\SNFRollback\snfmdplugin.xml" "$INSTDIR\snfmdplugin.xml"
  4194. ifFileExists "$SNFServerInstallDir\SNFRollback\getRulebase.cmd" 0 +2 ; Only if file exists.....
  4195. CopyFiles /SILENT "$SNFServerInstallDir\SNFRollback\getRulebase.cmd" "$INSTDIR\getRulebase.cmd"
  4196. ; no action fpr the getRulebase.cmd The Edit routine is called when the dialog page executes...
  4197. ; and if we're restoring the archived version here, then we don't need to call it anyway.
  4198. ifFileExists "$SNFServerInstallDir\SNFRollback\GBUdbIgnoreList.txt" 0 +2 ; Only if file exists.....
  4199. CopyFiles /SILENT "$SNFServerInstallDir\SNFRollback\GBUdbIgnoreList.txt" "$INSTDIR\GBUdbIgnoreList.txt"
  4200. ; no action fro the GBUdbIgnoreList.txt
  4201. ifFileExists "$SNFServerInstallDir\SNFRollback\identity.xml" 0 +2 ; If exists... copy.
  4202. CopyFiles /SILENT "$SNFServerInstallDir\SNFRollback\identity.xml" "$INSTDIR\identity.xml"
  4203. callEdits:
  4204. # snf_engine.xml and snfmdplugin.xml files handled further down; HAS SPECIAL CASE DOWN BELOW BECAUSE OF on-off setting needing to be retained or defaulted.
  4205. Call editGetRulebase ; ( Handle the paths )
  4206. Call editLicenseFile ; Always call this... Finds, Opens and edits the License.xml File with the License ID and Authentication strings.
  4207. ifFileExists "$SNFServerInstallDir\App\MDaemon.exe" 0 +2
  4208. Call editMDPluginsFile
  4209. ##########################
  4210. ## The following calls to the CopyWithRollbackControl have the file, the location and the callback function name that needs to be defined
  4211. ## somewere above. Eventually, on restore, if a call back function is defined it will be called in order to trip a restore feature.
  4212. ##########################
  4213. ; Declude Special
  4214. ifFileExists "$SNFServerInstallDir\global.cfg" 0 SkipDeclude_Special ; replace line in existing cfg file with line from archived cfg command.
  4215. ;messageBox MB_OK "Calling the Declude special $SNFServerInstallDir\global.cfg"
  4216. ${Copy_with_RollbackControl} "global.cfg" $SNFServerInstallDir "restoreGLOBALcfg" "" ; Copy the old Server.exe
  4217. call editglobalCFG ; then edit the declude config file.
  4218. SkipDeclude_Special:
  4219. ############################ MxGuard Special #####################
  4220. ifFileExists "$SNFServerInstallDir\mxGuard.ini" 0 SkipMXGuard_Special
  4221. ;messageBox MB_OK "Calling the MXGuard special $SNFServerInstallDir\mxGuard.ini"
  4222. ${Copy_with_RollbackControl} "mxGuard.ini" $SNFServerInstallDir "restoreMXGUARDini" "" ; Copy the old MXGuard.ini file.
  4223. call editMXGuardINI ; this should put the file pointing at SNF...
  4224. SkipMXGuard_Special:
  4225. ############################ Alligate Special #####################
  4226. ifFileExists "$SNFServerInstallDir\SNF4Alligate.exe" 0 SkipAlligate_Special
  4227. ; Nothing here right now. The shims are installed at the Installer layer, not the Restorer layer, and hence aren't
  4228. ; in the control of the rollback.
  4229. SkipAlligate_Special:
  4230. ############################ IceWarp Special #####################
  4231. ifFileExists "$SNFServerInstallDir\config\content.xml" 0 SkipIceWarp_Special
  4232. #${Copy_with_RollbackControl} "content.xml" "$SNFServerInstallDir\config\" "restoreContentXML" "" ; Copy the old MXGuard.ini file. ; Removed Callback.. redundent.
  4233. ; Why isn't this copied in rollback? Nothing to change from the customers perspective? Hmmmmmm.... they COULD edit it... this might be an error.
  4234. call editContentXML
  4235. SkipIceWarp_Special:
  4236. ############################ SNFClient.exe and snfmdaemon.dll Special ############################
  4237. # snf_engine.xml and snfmdplugin.xml files
  4238. # There is a slight detail.
  4239. # If the install parameters were set to overwrite previous files if they existed... vs.. using their settings if they do...
  4240. #
  4241. # NOTE: that editXMLConfig is smart enough to know if its editing the snfmddll.xml file, or the snf_engine.xml file. Same rules apply.
  4242. #
  4243. StrCmp $RetainExistingSettings "1" 0 JustUseAllNewFiles ; If we have a RETAIN flag set then use existing settings from file...
  4244. ## Note: If we retained settings, then we copied the old snfengine.xml/snfmddll.xml file to the temp and then back into the
  4245. ## INSTDIR, as well as storing it in the ROLLBACK. So At this point there is the previous copy's ( manual or installer based ) SNFENGINE.xml file in all places.
  4246. ## and the flag $RetainExistingSettings to determine what we are to do.
  4247. ##
  4248. ## So check the mdaemon version if that exists, or the snfengine.xml if that one exists.
  4249. ifFileExists "$INSTDIR\snfmdplugin.xml" UseMDaemonXMLFIle UseStdSNFEngineFile
  4250. ; So if this file exists then we mine it for the auto update flag, before calling the
  4251. UseMDaemonXMLFIle: ; editXMLConfig function. ( Because that will set it ON by default unless told not to. )
  4252. # So get the current value of whatever file is in place. ( If its old then fine, if its a new install it will be new file with the default set. So no big deal. )
  4253. ${GetBetween} "<update-script on-off='" "'" "$INSTDIR\snfmdplugin.xml" "$AUTO_UPDATE_ONOFF_FLAG" ; This makes it not brittly dependant on the default value. i.e. It would
  4254. ; if the setting is off, then its an old file.
  4255. StrCmp $AUTO_UPDATE_ONOFF_FLAG "" 0 adjustFileNow ; if not expressly false, then use default of ON
  4256. StrCpy $AUTO_UPDATE_ONOFF_FLAG "off" ; flag is set off.
  4257. goto adjustFileNow ; break out and run edit script.
  4258. UseStdSNFEngineFile: ; Ok, the snf_engine file is what were mining, not the mdaemon.
  4259. ${GetBetween} "<update-script on-off='" "'" "$INSTDIR\snf_engine.xml" "$AUTO_UPDATE_ONOFF_FLAG" ; This makes it not brittly dependant on the default value. i.e. It would
  4260. StrCmp $AUTO_UPDATE_ONOFF_FLAG "" 0 adjustFileNow ; if not expressly false, then use default of ON
  4261. StrCpy $AUTO_UPDATE_ONOFF_FLAG "off"
  4262. ; fall through now.
  4263. adjustFileNow:
  4264. Call editXMLConfig ; patching this function to hand off to use the snfmdplugin.xml file as source if necessary.
  4265. Goto DoneWithFiles
  4266. JustUseAllNewFiles:
  4267. ; Prior to calling editXMLConfig we need to set the flag that determines if we're using the AutoUpdate feature.
  4268. StrCpy $AUTO_UPDATE_ONOFF_FLAG "on" ; Defaults to yes.
  4269. Call editXMLConfig ; Handles altering the log and executible paths as well as the network instrument. ( If it exists. )
  4270. ; Don't need to parse it if we have it....
  4271. DoneWithFiles:
  4272. ; A similar command will be used to open the GUIEdit file with a notepad.exe
  4273. ${IF} $OpenGBUIgnoreFileOnClose == 1
  4274. ExecWait '"notepad.exe" "$INSTDIR\GBUdbIgnoreList.txt"'
  4275. ${ENDIF}
  4276. ; Write the uninstall keys for Windows For NSIS not SNF Install relevant
  4277. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MessageSniffer" "DisplayName" "Message Sniffer"
  4278. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MessageSniffer" "UninstallString" '"$INSTDIR\uninstall.exe"'
  4279. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MessageSniffer" "NoModify" 1
  4280. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MessageSniffer" "NoRepair" 1
  4281. SetOutPath $INSTDIR
  4282. ifFileExists "$INSTDIR\uninstall.exe" 0 +2
  4283. ${Copy_with_RollbackControl} "uninstall.exe" "$INSTDIR" "" "" ; Copy the old Uninstaller.exe
  4284. WriteUninstaller "uninstall.exe"
  4285. ## These calls aren't required for the MDaemon installation.
  4286. ## Skipp for MDaemon, the files won't be there, the service isn't going to be installed.
  4287. ifFileExists "$INSTDIR\snfmdplugin.xml" SkipAllServiceRelatedCalls RunServiceWrapperInstallMethods
  4288. RunServiceWrapperInstallMethods:
  4289. call editXYNTServiceINI ; First properly handle the ini file.
  4290. ## HERE we say, if the file still exists after the rollback.... THEN... we can uninstall and reinstall the XYNTService.
  4291. nsExec::Exec "$INSTDIR\XYNTService -u" "" SH_HIDE ; uninstall it if it exists....
  4292. ; presumes that the .ini file is in the same location.
  4293. nsExec::Exec "$INSTDIR\XYNTService -i" "" SH_HIDE ; install XYNTService
  4294. nsExec::Exec "$INSTDIR\XYNTService -r" "" SH_HIDE ; restart XYNTService
  4295. call startSNFServer ;nsExec::Exec "NET START SNFService" "" SH_HIDE
  4296. SkipAllServiceRelatedCalls:
  4297. ; Looks like were done.
  4298. ## Close rollback macro.
  4299. ${EndRollbackSession} "HKLM" "Software\MessageSniffer" ; Close this file, and end the rollback session. Provide strings for the resgistry handle.
  4300. SectionEnd
  4301. ; Optional section (can be disabled by the user)
  4302. Section "Start Menu Shortcuts"
  4303. SetOutPath $INSTDIR
  4304. VAR /GLOBAL FileHandle
  4305. ; NOTE we need to track if these were installed, for putting back on archive/restore.
  4306. FileOpen $FileHandle "$INSTDIR\shortcuts.xml" w
  4307. FileWrite $FileHandle "<snf><shortcuts>1</shortcuts></snf>"
  4308. FileClose $FileHandle
  4309. SetShellVarContext all ; this makes it backward/forwrad compatible Without it Vista will have problems removing shortcuts.
  4310. ; Essentially, we said put these shortcuts into the all-users profile of the machine
  4311. CreateDirectory "$SMPROGRAMS\MessageSniffer"
  4312. ifFileExists "$INSTDIR\snfmdplugin.dll" 0 InstallNormalInstructions
  4313. CreateShortCut "$SMPROGRAMS\MessageSniffer\InstallInstructions.lnk" "$INSTDIR\InstallInstructions_MDaemon.txt"
  4314. Goto AddSiteLink
  4315. InstallNormalInstructions:
  4316. CreateShortCut "$SMPROGRAMS\MessageSniffer\InstallInstructions.lnk" "$INSTDIR\InstallInstructions.txt"
  4317. AddSiteLink:
  4318. CreateShortCut "$SMPROGRAMS\MessageSniffer\MessageSniffer.lnk" "http://www.armresearch.com/"
  4319. CreateShortCut "$SMPROGRAMS\MessageSniffer\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  4320. CreateShortCut "$SMPROGRAMS\MessageSniffer\GBUdbIgnoreList.lnk" "$INSTDIR\GBUdbIgnoreList.txt"
  4321. SectionEnd
  4322. ;--------------------------------
  4323. ; Uninstaller
  4324. Function un.Restore
  4325. !insertmacro BIMAGE "SnifferStop.bmp" "" ; change banner image.
  4326. SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:Uninstall Message Sniffer Server 3.0:"
  4327. ; Page formation
  4328. nsDialogs::Create /NOUNLOAD 1018
  4329. Pop $0
  4330. ; now check restore options:
  4331. VAR /GLOBAL DeleteArchives ; flag to indicate yes/no
  4332. StrCpy $DeleteArchives "0" ; default to no.
  4333. ${NSD_CreateLabel} 0 10% 100% 40u "You are now going to uninstall the current working version of Message Sniffer. You may use the Message Sniffer Install Utility to Restore from a previous archived version, if you choose to not remove all archived folders. If you choose to remove all archives, this operation cannot be undone."
  4334. Pop $0
  4335. ;${NSD_CreateLabel} 30 50% 100% 20u ""
  4336. ;Pop $0
  4337. ${NSD_CreateCheckbox} 0 50% 100% 20 "Check this if you want to remove all archived Message Sniffer folders."
  4338. Pop $CHECKBOX
  4339. GetFunctionAddress $0 un.ToggleRestore
  4340. nsDialogs::OnClick /NOUNLOAD $CHECKBOX $0
  4341. nsDialogs::Show
  4342. FunctionEnd
  4343. Function un.BeSure
  4344. StrCpy $5 "This operation will remove the current restore/rollback of Message Sniffer from the Server 3.0 install."
  4345. StrCmp $DeleteArchives "1" 0 +2
  4346. StrCpy $5 "You have chosen to destroy your rollback files as well THE ROLLBACK ARCHIVE WILL BE DELETED. This operation cannot be undone."
  4347. MessageBox MB_YESNO "Are you sure? $5" IDYES true IDNO false
  4348. true:
  4349. Return
  4350. false:
  4351. Abort
  4352. FunctionEnd
  4353. Function un.ToggleRestore
  4354. Pop $0 # HWND
  4355. StrCmp $DeleteArchives "1" 0 ToggleStuff
  4356. StrCpy $DeleteArchives "0";
  4357. Push $0
  4358. GetTempFileName $0
  4359. File /oname=$0 "SnifferStop.bmp"
  4360. SetBrandingImage "" $0
  4361. Delete $0
  4362. Pop $0
  4363. Return
  4364. ToggleStuff:
  4365. StrCpy $DeleteArchives "1";
  4366. Push $0
  4367. GetTempFileName $0
  4368. File /oname=$0 "SnifferStop2.bmp"
  4369. SetBrandingImage "" $0
  4370. Delete $0
  4371. Pop $0
  4372. FunctionEnd
  4373. Function un.RemoveSNF4Alligate
  4374. ######################################################################### SNF4ALLIGATE UNINSTALL SECTION ############################################
  4375. ; If SNF4Alligate exists then we remove it.
  4376. Var /GLOBAL uninstallAlligate
  4377. ReadRegStr $uninstallAlligate HKLM "Software\MessageSniffer" "isSNF4AlligateInstalled" ; read the install folder for MINIMI.
  4378. StrCmp $uninstallAlligate "1" 0 NoAlligateHere
  4379. ; If we DO have SNF4Alligate installed we drop in here....
  4380. Var /GLOBAL UninstallAlligateFolder ; holds if and where MINIMI was installed.
  4381. Var /GLOBAL AlligateDelivery_Setting
  4382. Var /GLOBAL currentAlligateTarget
  4383. ReadRegStr $currentAlligateTarget HKLM "Software\SolidOak\Aligate\Settings" "FilterEXE" ; read alligates AGFILTSVC target....
  4384. StrCmp $currentAlligateTarget "SNF4Alligate.exe" 0 SkipFilterExeAdustment
  4385. ; Then we'll clear it, or set it to the next in the chain.
  4386. ; So we'll need to know if we're the ones in Alligates prime spot... otherwise we don't clear/or clean it.
  4387. ReadRegStr $UninstallAlligateFolder HKLM "Software\MessageSniffer" "SNF4AlligateInstallFolder" ; read the install folder for MINIMI.
  4388. ; Now we know where the files are:
  4389. ; So read out the delivery program setting:
  4390. ifFileExists "$UninstallAlligateFolder\SNF4Alligate.xml" 0 NoXMLFile ; if we find the xml file, then we need to do checking...
  4391. ; IF this is valid, then we read from OLD....
  4392. ; and if its anything other than the inert tag values, we put it back in.
  4393. ${un.GetBetween} "<delivery program='" "'/>$\r$\n" "$UninstallAlligateFolder\SNF4Alligate.xml" "$AlligateDelivery_Setting"
  4394. ${Switch} $AlligateDelivery_Setting
  4395. ${Case} ""
  4396. ExecWait 'net stop AGFILTSVC'
  4397. ExecWait '$UninstallAlligateFolder\AGFiltSvc.exe /uninstall'
  4398. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "FilterEXE" ""
  4399. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "DropDir" "\Spool"
  4400. goto doneResolvingAlligateDeliverySetting
  4401. ${Case} "none"
  4402. ExecWait 'net stop AGFILTSVC'
  4403. ExecWait '$UninstallAlligateFolder\AGFiltSvc.exe /uninstall'
  4404. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "FilterEXE" ""
  4405. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "DropDir" "\Spool"
  4406. goto doneResolvingAlligateDeliverySetting
  4407. ${Case} "NONE"
  4408. ExecWait 'net stop AGFILTSVC'
  4409. ExecWait '$UninstallAlligateFolder\AGFiltSvc.exe /uninstall'
  4410. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "FilterEXE" ""
  4411. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "DropDir" "\Spool"
  4412. goto doneResolvingAlligateDeliverySetting
  4413. ${Case} "None"
  4414. ExecWait 'net stop AGFILTSVC'
  4415. ExecWait '$UninstallAlligateFolder\AGFiltSvc.exe /uninstall'
  4416. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "FilterEXE" ""
  4417. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "DropDir" "\Spool"
  4418. goto doneResolvingAlligateDeliverySetting
  4419. ${Case} "SNF4Aligate"
  4420. ExecWait 'net stop AGFILTSVC'
  4421. ExecWait '$UninstallAlligateFolder\AGFiltSvc.exe /uninstall'
  4422. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "FilterEXE" ""
  4423. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "DropDir" "Spool\"
  4424. goto doneResolvingAlligateDeliverySetting
  4425. ${Default}
  4426. ExecWait 'net stop AGFILTSVC' ; this will stop it and release the SNF4Alligate.exe file.
  4427. MessageBox MB_OK "SNF4Alligate was set to hand messages downstream to $AlligateDelivery_Setting. The Uninstaller will try to restore the FilterEXE registry value to maintain the rest of the filter-call chain. Please confirm and test this before you're done with your settings."
  4428. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "FilterEXE" "$AlligateDelivery_Setting."
  4429. ExecWait 'net start AGFILTSVC' ; this will stop it and reset the new filter target.
  4430. goto doneResolvingAlligateDeliverySetting
  4431. ${EndSwitch}
  4432. NoXMLFile:
  4433. ;something was wrong here.....
  4434. ; but if there isn't anything to go buy, then if the FiltEXE is pointing at us, then we clear it.
  4435. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "FilterEXE" ""
  4436. doneResolvingAlligateDeliverySetting:
  4437. SkipFilterExeAdustment:
  4438. DeleteRegKey HKLM SOFTWARE\SolidOak\Alligate\Settings\Addins\MsgSniffer\ProcessDirHint ; this holds the verbage for the Alligate Inteface clue.
  4439. DeleteRegKey HKLM SOFTWARE\SolidOak\Alligate\Settings\Addins\MsgSniffer\ProcessDir ; This flags the directory.
  4440. DeleteRegKey HKLM SOFTWARE\SolidOak\Alligate\Settings\Addins\MsgSniffer\ProcessDirLabel ; This is "Sniffer"
  4441. ; In either case we need to remove isSNF4AlligateInstalled,SNF4AlligateInstallFolder,SNFMailServer_DIR from the MessageSniffer registry key.
  4442. ; and
  4443. DeleteRegKey HKLM HKEY_LOCAL_MACHINE\SOFTWARE\MessageSniffer\isSNF4AlligateInstalled
  4444. DeleteRegKey HKLM HKEY_LOCAL_MACHINE\SOFTWARE\MessageSniffer\SNF4AlligateInstallFolder
  4445. DeleteRegKey HKLM HKEY_LOCAL_MACHINE\SOFTWARE\MessageSniffer\SNFMailServer_DIR
  4446. ifFileExists "$UninstallAlligateFolder\SNF4Alligate.xml" 0 +2
  4447. Delete "$UninstallAlligateFolder\SNF4Alligate.xml"
  4448. ifFileExists "$UninstallAlligateFolder\SNF4Alligate.exe" 0 +2
  4449. Delete "$UninstallAlligateFolder\SNF4Alligate.exe"
  4450. ExecWait "net stop AgSMTPSvc" ; Now bounce the Alligate SMTP Server.
  4451. ExecWait "net start AgSMTPSvc"
  4452. NoAlligateHere:
  4453. ######################################################################### END Alligate UNINSTALL SECTION ############################################
  4454. return
  4455. FunctionEnd
  4456. Section "Uninstall"
  4457. ; Now we have two situations. The first is that this Uninstaller was called legitimately, in which case, this file
  4458. ; will be being run from the existing Message Sniffer install directory.
  4459. ; and $EXEDIR will be that directory..... or $EXEDIR will be in a directory inside the SnifferArchive directory, and be
  4460. ; an illigitimate version running..... SOLVED THIS BY CHANGING THE FILE EXTENSION to bck.. and then back to exe when its appropriate.
  4461. ; So read the registry key:
  4462. Call un.stopSNFServer
  4463. Call un.UninstallXYNTService
  4464. Var /GLOBAL localFileDirectory
  4465. Var /GLOBAL uninstallRollbackPath
  4466. Var /GLOBAL uninstallRollbackLogName
  4467. Call un.removeShortcuts ; if your uninstalling, then you're taking the installers work out. Shortcuts will always go away.
  4468. ; only manual installs might be left behind. Manual installs don't have shortcuts.
  4469. ReadRegStr $localFileDirectory HKLM "Software\MessageSniffer" "Install_Dir"
  4470. ReadRegStr $uninstallRollbackPath HKLM "Software\MessageSniffer" "SRS_RollbackPath"
  4471. ReadRegStr $uninstallRollbackLogName HKLM "Software\MessageSniffer" "SRS_LogName"
  4472. ReadRegStr $SNFServerInstallDir HKLM "Software\MessageSniffer" "SNFMailServer_DIR"
  4473. ## ROLLBACK WILL ALWAYS OCCUR ON UNINSTALL... mostly it will be on a fresh install... but if it has an existing install.... it will only remove
  4474. ## Files it inserted.
  4475. ${un.GetParent} $localFileDirectory $SNFServerInstallDir
  4476. #######################################################################################################################################
  4477. ## We're un-installing. Therefore if there is an existing rollback file, run it.
  4478. #######################################################################################################################################
  4479. StrCmp $uninstallRollbackPath "" NoPreRoll 0
  4480. StrCmp $uninstallRollbackLogName "" NoPreRoll 0
  4481. StrCmp $uninstallRollbackPath "$SNFServerInstallDir\SNFRollBack" 0 NoPreRoll ; Only roll this back if its the same folder as the source. i.e. Don't rollback an
  4482. ; Imail install ontop of a smartermail install.
  4483. ${un.RollBackTo} $uninstallRollbackPath $uninstallRollbackLogName ; Put all the files back the way they were.
  4484. # Do we end here?
  4485. NoPreRoll:
  4486. ######################################################################### MINIMI UNINSTALL SECTION ############################################
  4487. ; If MINIMI exists then we should roll it back, but first we need to replace the IMAIL SendName Registry Key with the target value in
  4488. ; the MINIMI xml config file.
  4489. Var /GLOBAL UninstallMINIMIFolder ; holds if and where MINIMI was installed.
  4490. Var /GLOBAL Delivery_Setting
  4491. Var /GLOBAL Current_Send_setting ; current IMAIL send target for the mail delivery.
  4492. Var /GLOBAL Current_UninstallTopDir ; Imail top directory
  4493. ReadRegStr $0 HKLM "Software\MessageSniffer" "isMINIMIInstalled"
  4494. StrCmp $0 "1" 0 ContinueWithRollback ; if it is, then drop in and handle the tests.....
  4495. ReadRegStr $UninstallMINIMIFolder HKLM "Software\MessageSniffer" "MINIMIInstallFolder" ; read the install folder for MINIMI.
  4496. # EXPLANATION: MINIMI might have been made irrelevant, so we first need to test if it was being used before we roll it back.
  4497. # then if this MINIMI was being used, but we'rerolling back to the OLD minimi version, then we're going to
  4498. # put the OLD MINIMI's target back as IMAILs send name target. If there is no OLD_SNIFIMailShim.xml, that means
  4499. # that the rollback is deleteing MINIMI and we should put the current MINIMI's target back as Imails sendName Target....
  4500. # Make sense? Good. All bets are off, if current MINIMI is not tied into IMAIL.
  4501. # Test for current xml file. Test for Imail's SendName and TopDir
  4502. ifFileExists "$UninstallMINIMIFolder\SNFIMailShim.xml" 0 ContinueWithRollback ; if we find the xml file, then we need to do checking...
  4503. ; if this file exists, then MINIMI was installed at some point. Check to see what IMAIL is pointing at:
  4504. ReadRegStr $Current_Send_setting HKLM "SOFTWARE\Ipswitch\IMail\Global" "SendName" ; this is what it was calling....
  4505. ReadRegStr $Current_UninstallTopDir HKLM "SOFTWARE\Ipswitch\IMail\Global" "TopDir" ; this is where MINIMI would be installed.
  4506. StrCmp "$Current_UninstallTopDir\SNFIMailShim.exe" $Current_Send_setting 0 IgnoreSendNameRollback
  4507. ## Dropping into here means that the IMAIL target is the same as the MINIMI executable.
  4508. ## So we're rolling back. Test to see if there is an OLD_SNIFI.xml file, or not.
  4509. ifFileExists "$UninstallMINIMIFolder\OLD_SNFIMailShim.xml" 0 ResetImail_WithCurrentMINIMIVALUE ; if we find the xml file, then we need to do checking...
  4510. ## IF this is valid, then we read from OLD....
  4511. ${un.GetBetween} "<delivery program='" "'/>$\r$\n" "$UninstallMINIMIFolder\OLD_SNFIMailShim.xml" "$Delivery_Setting"
  4512. Goto ResetImail
  4513. ResetImail_WithCurrentMINIMIVALUE:
  4514. ## IF THIS gets executed it means there was no OLD but we're still removing MINIMI from the chain....
  4515. ${un.GetBetween} "<delivery program='" "'/>$\r$\n" "$UninstallMINIMIFolder\SNFIMailShim.xml" "$Delivery_Setting"
  4516. Goto ResetImail
  4517. ResetImail:
  4518. ## Finally, reset the Imail setting to the target of MINIMI and take it out of the chain.
  4519. ClearErrors
  4520. WriteRegStr HKLM "SOFTWARE\Ipswitch\IMail\Global" "SendName" "$Delivery_Setting"
  4521. iferrors 0 IgnoreSendNameRollback
  4522. MessageBox MB_OK "MINIMI was set to hand cleared messages downstream. The Uninstaller tried to restore the SendName registry value for IMail to: '$Delivery_Setting' but the write was rejected. Please save this value and manually reset the SendName parameter."
  4523. IgnoreSendNameRollback:
  4524. # Not changing the target for Imail, but we're rolling back MINIMI's files.... ( theoretically, somethings pointing at it???? )
  4525. # Test for xml file. Test for Imail's SendName and TopDir
  4526. ifFileExists "$UninstallMINIMIFolder\OLD_SNFIMailShim.xml" 0 ContinueWithRollback ; if we find the xml file, then we need to do checking...
  4527. ifFileExists "$UninstallMINIMIFolder\SNFIMailShim.xml" 0 +2
  4528. Delete "$UninstallMINIMIFolder\SNFIMailShim.xml"
  4529. CopyFiles /SILENT "$UninstallMINIMIFolder\OLD_SNFIMailShim.xml" "$UninstallMINIMIFolder\SNFIMailShim.xml"
  4530. ifFileExists "$UninstallMINIMIFolder\OLD_SNFIMailShim.exe" 0 ContinueWithRollback ; if we find the xml file, then we need to do checking...
  4531. ifFileExists "$UninstallMINIMIFolder\SNFIMailShim.exe" 0 +2
  4532. Delete "$UninstallMINIMIFolder\SNFIMailShim.exe"
  4533. CopyFiles /SILENT "$UninstallMINIMIFolder\OLD_SNFIMailShim.exe" "$UninstallMINIMIFolder\SNFIMailShim.exe"
  4534. ContinueWithRollback:
  4535. ######################################################################### END MINIMI UNINSTALL SECTION ############################################
  4536. ######################################################################### Alligate UNINSTALL SECTION
  4537. Call un.RemoveSNF4Alligate ; remove SNF4Alligate if its installed.
  4538. ######################################################################### IceWarp UNINSTALL SECTION
  4539. ifFileExists "$SNFServerInstallDir\config\content.xml" 0 +2
  4540. Call un.editContentXML ; remove IceWarp if its installed.
  4541. ######################################################################### IceWarp UNINSTALL SECTION
  4542. ; Don't need this here cause it gets called on the Rollback. Twice will remove the rolled back references if there were any.
  4543. ; ifFileExists "$SNFServerInstallDir\App\Plugins.dat" 0 +2
  4544. ; Call un.editMDPluginsFile ; remove MDaemon SNF Call if its installed.
  4545. ## IF there is no SNFClient.exe there should be no uninstaller.exe or anything else.
  4546. ifFileExists "$localFileDirectory\SNFClient.exe" LeaveNow 0 ; otherwise cleanup.
  4547. ifFileExists "$localFileDirectory\Restorer.exe" 0 +2
  4548. Delete "$localFileDirectory\Restorer.exe"
  4549. ifFileExists "$localFileDirectory\oldsnifferversion.txt" 0 +2
  4550. Delete "$localFileDirectory\oldsnifferversion.txt"
  4551. ifFileExists "$localFileDirectory\getRulebase.cmd.old" 0 +2
  4552. Delete "$localFileDirectory\getRulebase.cmd.old"
  4553. ifFileExists "$localFileDirectory\shortcuts.xml" 0 +2
  4554. Delete "$localFileDirectory\shortcuts.xml" ; if exists ; Find other location
  4555. ifFileExists "$localFileDirectory\cfgstring.xml" 0 +2
  4556. Delete "$localFileDirectory\cfgstring.xml" ; if exists ; Find other location
  4557. ifFileExists "$localFileDirectory\XYNTService.ini" 0 +2
  4558. Delete "$localFileDirectory\XYNTService.ini"
  4559. ifFileExists "$localFileDirectory\LocalRoot.txt" 0 +2
  4560. Delete "$localFileDirectory\LocalRoot.txt"
  4561. ifFileExists "$localFileDirectory\SNFServer${SNIFFER_SERVER_SPECIFIER}.exe" 0 +2
  4562. Delete "$localFileDirectory\SNFServer${SNIFFER_SERVER_SPECIFIER}.exe"
  4563. ifFileExists "$localFileDirectory\UpdateReady.txt" 0 +2
  4564. Delete "$localFileDirectory\UpdateReady.txt"
  4565. ifFileExists "$localFileDirectory\mingwm10.dll" 0 +2
  4566. Delete "$localFileDirectory\mingwm10.dll"
  4567. Delete "$localFileDirectory\uninstall.exe"
  4568. ifFileExists "$localFileDirectory\snfmdplugin.xml" 0 +2
  4569. Delete "$localFileDirectory\snfmdplugin.xml"
  4570. ifFileExists "$localFileDirectory\snfmdplugin.dll" 0 +2
  4571. Delete "$localFileDirectory\snfmdplugin.dll"
  4572. ifFileExists "$localFileDirectory\Plugins.dat" 0 +2
  4573. Delete "$localFileDirectory\Plugins.dat"
  4574. ifFileExists "$SNFServerInstallDir\SpamAssassin\rules\snf-groups.cf" 0 +2
  4575. Delete "$SNFServerInstallDir\SpamAssassin\rules\snf-groups.cf"
  4576. LeaveNow:
  4577. ##################
  4578. ; Ok, lastly wipe all the registry keys because if the uninstaller has run, it isn't available anmore..
  4579. DeleteRegKey HKLM SOFTWARE\MessageSniffer
  4580. ifFileExists "$SNFServerInstallDir\SNFRollBack\*.*" 0 +2
  4581. RMDir /r "$SNFServerInstallDir\SNFRollBack"
  4582. Delete "$uninstallRollbackPath\$uninstallRollbackLogName"
  4583. ; Remove registry keys
  4584. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MessageSniffer"
  4585. ; don't delete the master RegKey Folder until the end. We might need to reference the archive path.
  4586. Return
  4587. ## END ROLLBACK
  4588. ########################################################### PRIME is 1 and No FULLUNNSTALLBLOCKER EXISTS ########################################
  4589. ## Massive chunk of uninstaller code was removed on Mar 02. Rollback should be handling all of these items. Need full test to confirm that.
  4590. SectionEnd
  4591. ;Function that calls a messagebox when installation finished correctly
  4592. Function .onInstSuccess
  4593. InitPluginsDir
  4594. SetOutPath "$PLUGINSDIR"
  4595. ; Modal banner sample: show
  4596. File "SuccessInstall.bmp"
  4597. newadvsplash::show 5000 100 500 0x04025C "$PLUGINSDIR\SuccessInstall.bmp" ;/NOCANCEL
  4598. Delete "$PLUGINSDIR\SuccessInstall.bmp"
  4599. FunctionEnd
  4600. ;Function that calls a messagebox when installation finished correctly
  4601. Function onRestoreSuccess
  4602. InitPluginsDir
  4603. SetOutPath "$PLUGINSDIR"
  4604. ; Modal banner sample: show
  4605. File "SuccessRestore.bmp"
  4606. newadvsplash::show 5000 100 500 0x04025C "$PLUGINSDIR\SuccessRestore.bmp" ; /NOCANCEL
  4607. Delete "$PLUGINSDIR\SuccessRestore.bmp"
  4608. FunctionEnd
  4609. Function un.onUninstSuccess
  4610. SetOutPath $SNFServerInstallDir ; To release any holds on folders.
  4611. ; SetOutPath "C:"
  4612. ; ifFileExists "C:\MessageSniffer\StandAlone" 0 +2
  4613. ; RmDir /r "C:\MessageSniffer\StandAlone"
  4614. ; ifFileExists "C:\MessageSniffer\MXGuard" 0 +2
  4615. ; RmDir /r "C:\MessageSniffer\MXGuard"
  4616. ; ifFileExists "C:\MessageSniffer" 0 +2
  4617. ; RmDir /r "C:\MessageSniffer"
  4618. ;ifFileExists "$INSTDIR\*.*" 0 +2
  4619. ; RmDir /r $INSTDIR
  4620. ;ifFileExists "$SNFServerInstallDir\Sniffer" 0 +2
  4621. ; RmDir /r "$SNFServerInstallDir\Sniffer"
  4622. ; And if the user said to delete ALL of the Archive folders, then we kill them all.
  4623. ;StrCmp $DeleteArchives "1" 0 SkippingDeleteOfArchives
  4624. ; Delete "$SNFServerInstallDir\SNFRollback\*.*"
  4625. ; RmDir /r "$SNFServerInstallDir\SNFRollback"
  4626. ;SkippingDeleteOfArchives:
  4627. ;MessageBox MB_OK "You have successfully uninstalled Message Sniffer."
  4628. InitPluginsDir
  4629. SetOutPath "$PLUGINSDIR"
  4630. ; Modal banner sample: show
  4631. File "SuccessUnInstall.bmp"
  4632. newadvsplash::show 5000 100 500 0x04025C /NOCANCEL "$PLUGINSDIR\SuccessUnInstall.bmp"
  4633. Delete "$PLUGINSDIR\SuccessUnInstall.bmp"
  4634. MessageBox MB_OK " Uninstall Complete!$\r$\nThe uninstaller has rolled back any changes made during the last installation.$\r$\nThe uninstaller does not delete files that it did not create (such as log files).$\r$\nIf you want to delete these files you will probably find them in your install$\r$\nfolder located here: $SNFServerInstallDir"
  4635. ;call un.restartMDaemon
  4636. FunctionEnd