Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

MessageSnifferRestorer2_1.nsi 314KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510
  1. !verbose 2
  2. !define TEMP1 $R0 ;Temp variable
  3. !define SNIFFER_SERVER_SPECIFIER "3.0" ; 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 UnableToFindContentFileXML
  3530. FileOpen $IceWarpContentFileHandle "$IceWarpInstallFolder\config\scan.dat" r
  3531. iferrors 0 ReadForProperyHeaderedFilterFile
  3532. MessageBox MB_OK "Unable to read IceWarps scan.dat file from: $IceWarpInstallFolder\config\scan.dat"
  3533. Goto DoneReadingContentFile
  3534. ; You can have an empty file. With no headers... so first we either spin through without finding a valid header opener... and then
  3535. ; open and enter our own filter at the end... or we'll find one, and enter into the valid filter sections.
  3536. ReadForProperyHeaderedFilterFile:
  3537. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3538. ifErrors DoneReadingEmptyFile 0
  3539. ${WordFind} $IceWarpContentXMLlinedata "<FILTERS>" "E+1}" $WordFindResults
  3540. ifErrors 0 ProperlyHeaderedFile ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3541. ; 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.
  3542. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  3543. Goto ReadForProperyHeaderedFilterFile ; go back and get a newline to test.
  3544. ProperlyHeaderedFile:
  3545. ; dump header line.
  3546. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  3547. ; Sniffer goes in front of the AV filters.... for speed.
  3548. FileWrite $IceWarpAdjustedFileHandle $SnifferAVXMLContent ; and because this is a properly wrapped file, and there may be more filters after us.
  3549. StrCpy $didWeOutput "1" ; we continue through and write the rest till EOF.
  3550. ;Ok, Next line SHOULD be FILTER object.... spin till we get one...
  3551. ReadContentLine:
  3552. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3553. ifErrors DoneReadingContentFile 0
  3554. ${WordFind} $IceWarpContentXMLlinedata "<FILTER>" "E+1}" $WordFindResults
  3555. ifErrors 0 FoundFilterMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3556. ; 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.
  3557. ; BUT we could be reading the last line, in which case, we need to output before we close the content filter tag...
  3558. ${WordFind} $IceWarpContentXMLlinedata "</FILTERS>" "E+1}" $WordFindResults
  3559. ifErrors NotEndingYet 0 ; errors meant not in line... If we found it, then drop through and handle trivial ending. Otherwise drop through
  3560. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; close the XML validily.
  3561. Goto DoneReadingContentFile
  3562. NotEndingYet: ; ok if its not the trivial ending, then output line, and go back for more.
  3563. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump line to the new file.
  3564. Goto ReadContentLine ; go back and get a newline to test.
  3565. FoundFilterMarker:
  3566. ; 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...
  3567. ; 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
  3568. ; something distinctive.
  3569. StrCpy $TempFilterXML $IceWarpContentXMLlinedata
  3570. LookForTitle:
  3571. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3572. ifErrors DoneReadingContentFile 0
  3573. ${WordFind} $IceWarpContentXMLlinedata "<FILENAME>" "E+1}" $WordFindResults
  3574. ifErrors 0 FoundTitleMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3575. StrCpy $TempFilterXML "$TempFilterXML$IceWarpContentXMLlinedata" ; not in line, add to temp buffer.
  3576. Goto LookForTitle ; go back and get a newline to that might hold the title.
  3577. FoundTitleMarker:
  3578. ; 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>
  3579. ; but if we're NOT sniffer.... then we write the temp string and pop out and continue looping at the top.
  3580. ${WordFind} $IceWarpContentXMLlinedata "SNFClient.exe" "E+1}" $WordFindResults
  3581. ifErrors 0 FoundSnifferSection ; errors meant not in line... If we found it, then go to found-handle. Otherwise drop through
  3582. FileWrite $IceWarpAdjustedFileHandle $TempFilterXML ; Ok, we're not in a sniffer section, so dump the buffer
  3583. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump the current line...
  3584. StrCpy $TempFilterXML "" ; clear the buffer.
  3585. Goto ReadContentLine ; pop out and look for the next filter tag.
  3586. FoundSnifferSection: ; consume an existing sniffer section.
  3587. ; if this is the case, we loop till we find the </FILTER> and then we insert the new sniffer code.
  3588. LookForCloseFilter:
  3589. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata
  3590. ifErrors DoneReadingContentFileWithErrors 0 ; if we exit here output is NOT done... and it probably means an error.
  3591. ${WordFind} $IceWarpContentXMLlinedata "</FILTER>" "E+1}" $WordFindResults
  3592. ifErrors 0 FoundCloseFilterMarker ; errors meant not in line... If we found it, then go to handle. Otherwise drop through
  3593. Goto LookForCloseFilter ; go back and get a newline to that might hold the title.
  3594. FoundCloseFilterMarker:
  3595. ; Dont output here cause we put it in front.
  3596. ; Ok from here on, we dump it all to the file.
  3597. ContinueDumpingFileLines:
  3598. FileRead $IceWarpContentFileHandle $IceWarpContentXMLlinedata ;Grap new line.
  3599. ifErrors DoneReadingContentFile 0 ; if not EOF then exit with output true. We're good and done.
  3600. FileWrite $IceWarpAdjustedFileHandle $IceWarpContentXMLlinedata ; dump the current line...
  3601. Goto ContinueDumpingFileLines ; and go back for more.
  3602. ; If were here then we called from the first loop section where we were checking for <CONTENTFILTER>
  3603. DoneReadingEmptyFile: ; this means we head, fill and footer the file ourselves.
  3604. FileWrite $IceWarpAdjustedFileHandle $ContentXMLHeader ; If nothing in file, when we need to write header and
  3605. FileWrite $IceWarpAdjustedFileHandle $SnifferAVXMLContent
  3606. FileWrite $IceWarpAdjustedFileHandle $ContentXMLFooter ; and footer
  3607. StrCpy $didWeOutput "1" ; footer.
  3608. ; fall through and close files up.
  3609. ; we could jump to here from anywere. If we needed to write it out in the middle, we would have done it.
  3610. DoneReadingContentFile: ; only the trivial EOF early would trip with no output.... so if thats the case
  3611. StrCmp $didWeOutput "0" 0 SkipOutputThisTime ; we need to dump it all in, headers and footers too, and then close.
  3612. FileWrite $IceWarpAdjustedFileHandle $ContentXMLHeader ; If nothing in file, when we need to write header and
  3613. FileWrite $IceWarpAdjustedFileHandle $SnifferAVXMLContent
  3614. FileWrite $IceWarpAdjustedFileHandle $ContentXMLFooter ; and footer ; if we didn't have a chance, then we output here.
  3615. SkipOutputThisTime:
  3616. ; potential for corrupted file if file ended with errors....
  3617. FileClose $IceWarpContentFileHandle ; Close file.
  3618. FileClose $IceWarpAdjustedFileHandle ; Close file.
  3619. StrCpy $IceWarpContentXMLlinedata "" ; Clear line data.
  3620. ; Now swap out the files.
  3621. #Var /GLOBAL var1
  3622. #Var /GLOBAL var2
  3623. #Var /GLOBAL var3
  3624. #Var /GLOBAL var4
  3625. #Var /GLOBAL var5
  3626. #Var /GLOBAL var6
  3627. #Var /GLOBAL var7
  3628. ${GetTime} "" "L" $var1 $var2 $var3 $var4 $var5 $var6 $var7
  3629. ifFileExists "$IceWarpInstallFolder\config\scandat_InstallLOG_$var1-$var2-$var4.xml" 0 +2
  3630. Delete "$IceWarpInstallFolder\config\scandat_InstallLOG_$var1-$var2-$var4.xml"
  3631. Rename "$IceWarpInstallFolder\config\scan.dat" "$IceWarpInstallFolder\config\scandat_InstallLOG_$var1-$var2-$var4.xml"
  3632. Rename "$IceWarpInstallFolder\config\scanNEW.dat" "$IceWarpInstallFolder\config\scan.dat"
  3633. Return
  3634. DoneReadingContentFileWithErrors:
  3635. FileClose $IceWarpContentFileHandle ; Close file.
  3636. FileClose $IceWarpAdjustedFileHandle ; Close file.
  3637. Delete "$IceWarpInstallFolder\config\scanNew.dat"
  3638. 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."
  3639. Return
  3640. UnableToFindContentFileXML:
  3641. MessageBox MB_OK "Unable to find IceWarps scan.dat file from: $IceWarpInstallFolder\config\scan.dat You will have to tie-in manually with IceWarp."
  3642. Return
  3643. FunctionEND ; end IceWarp scan.dat file edit.
  3644. #############################
  3645. ## SNIFFER's Config file. ######################################################################################################
  3646. ## This function doubles as an editor for the MDaemon's config file editor as well. Since this editor doesn't concern itself ##
  3647. ## with most of the other features.
  3648. Function editXMLConfig
  3649. ; Var /GLOBAL ShortPathTempVar ; Defined earier. ; use this to hold the Short Windows Progr~1 path references...
  3650. ;GetFullPathName /SHORT $ShortPathTempVar $INSTDIR
  3651. ${handleShortPath} $ShortPathTempVar $INSTDIR
  3652. ## MDaemon patch adjustment. The snfmdplugin.xml file is the same file, except for some initial settings. We can use the same edit code
  3653. ## for both files. Use the filename switch here.
  3654. Var /GLOBAL ConfigFileName ; We're using a switch to double the snfengine edit code to handle the snfmdplugin.xml code as well.
  3655. StrCpy $ConfigFileName "snf_engine.xml"
  3656. ifFileExists "$INSTDIR\snfmdplugin.xml" 0 +2
  3657. StrCpy $ConfigFileName "snfmdplugin.xml"
  3658. ## End MDaemon filename switch.
  3659. ${GetBetween} "<node identity='" "'>" "$INSTDIR\$ConfigFileName" "$R0" ; This makes it not brittly dependant on the default value. i.e. It would
  3660. !insertmacro ReplaceInFile "$INSTDIR\$ConfigFileName" "<node identity='$R0'>" "<node identity='$ShortPathTempVar\identity.xml'>"
  3661. ClearErrors
  3662. ${GetBetween} "<log path='" "'/>" "$INSTDIR\$ConfigFileName" "$R0" ; This makes it not brittly dependant on the default value.
  3663. !insertmacro ReplaceInFile "$INSTDIR\$ConfigFileName" "<log path='$R0'/>" "<log path='$ShortPathTempVar\'/>"
  3664. ClearErrors
  3665. ${GetBetween} "<rulebase path='" "'/>" "$INSTDIR\$ConfigFileName" "$R0" ; This makes it not brittly dependant on the default value.
  3666. !insertmacro ReplaceInFile "$INSTDIR\$ConfigFileName" "<rulebase path='$R0'/>" "<rulebase path='$ShortPathTempVar\'/>"
  3667. ClearErrors
  3668. ${GetBetween} "<workspace path='" "'/>" "$INSTDIR\$ConfigFileName" "$R0" ; This makes it not brittly dependant on the default value.
  3669. !insertmacro ReplaceInFile "$INSTDIR\$ConfigFileName" "<workspace path='$R0'/>" "<workspace path='$ShortPathTempVar\'/>"
  3670. ClearErrors
  3671. ; 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)
  3672. ${GetBetween} "<network>" "</network>" "$INSTDIR\$ConfigFileName" "$R0" ; This makes it not brittly dependant on the default value.
  3673. FileOpen $R1 "tempNetworkFile.txt" w
  3674. FileWrite $R1 $R0
  3675. FileClose $R1
  3676. ${GetBetween} "<update-script on-off='" "'" "$INSTDIR\tempNetworkFile.txt" "$R4" ; This makes it not brittly dependant on the default value.
  3677. StrCmp $R4 "" OutputEntireString 0 ; If $R0 returns empty in this instance, it means that the feature wasn't there in
  3678. ; this file version. So jump to the default and write the line.
  3679. ; 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.
  3680. ; 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 )
  3681. ; leaving an install that didn't have these features installed previously, left to use their own mechanisms.
  3682. ; 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
  3683. ; 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.....
  3684. ${GetBetween} "<update-script" "/>" "$INSTDIR\tempNetworkFile.txt" "$R0" ; This makes it not brittly dependant on the default value.
  3685. StrCmp $R0 "" OutputEntireString 0 ; If $R0 returns empty in this instance, it means that the feature wasn't there in
  3686. ; this file version. So jump to the default and write the line.
  3687. StrCpy $R6 "<update-script on-off='$R4' call='$ShortPathTempVar\getRulebase.cmd' guard-time='180'/>" ; R6 holds the new PUT value....
  3688. ; Typical update script looks like:
  3689. ; <update-script on-off='on' call='/MDaemon/$FolderPrefix/getRulebase.cmd' guard-time='180'/>
  3690. !insertmacro ReplaceInFile "$INSTDIR\$ConfigFileName" "<update-script$R0/>" "$R6"
  3691. ClearErrors
  3692. Delete "$INSTDIR\tempNetworkFile.txt"
  3693. Return
  3694. OutputEntireString: ; This handles if there was an empty search returned from searching for updateScript.
  3695. StrCpy $R6 "<update-script on-off='$AUTO_UPDATE_ONOFF_FLAG' call='$ShortPathTempVar\getRulebase.cmd' guard-time='180'/>"
  3696. ; Typical update script looks like:
  3697. ; <update-script on-off='on' call='/MDaemon/$FolderPrefix/getRulebase.cmd' guard-time='180'/>
  3698. ; !insertmacro ReplaceInFile "$SNFServerInstallDir\$FolderPrefix\snfmdplugin.xml" "</network>" "$R6$\r$\n</network>"
  3699. ; ClearErrors
  3700. Push "</network>" #text to be replaced
  3701. Push "$R6$\r$\n</network>" #replace with
  3702. Push 0 #replace command
  3703. Push 1 #replace but only one occurance.. not all close network references....
  3704. Push "$INSTDIR\$ConfigFileName" #file to replace in
  3705. Call AdvReplaceInFile ;; it reads the pushed variables as parameters.... ( Hey... I didn't design that interface... its confusing. )
  3706. Delete "$INSTDIR\tempNetworkFile.txt"
  3707. Return
  3708. FunctionEnd
  3709. Function .onInit
  3710. ############################ Semifor Code ###################
  3711. # Ensure we only run one instance.
  3712. System::Call 'kernel32::CreateMutexA(i 0, i 0, t "Message Sniffer") i .r1 ?e'
  3713. Pop $R0
  3714. StrCmp $R0 0 +3
  3715. MessageBox MB_OK|MB_ICONEXCLAMATION "The Message Sniffer installer is already running."
  3716. Abort
  3717. ############################ Semifor Code ###################
  3718. ; The master installer .exe should create a LocalRoot.txt file that indicates where the localroot of the mailserver is located.
  3719. ; To save us the trouble of finding it again.
  3720. ; Now identify the folder that we're in and get the local root.....
  3721. IfFileExists "$EXEDIR\LocalRoot.txt" 0 EndGracefully
  3722. ${GetBetween} '<root>' '</root>' "$EXEDIR\LocalRoot.txt" $SNFServerInstallDir ; if it was unpacked by the Installer than the file is there
  3723. ${GetBetween} '<cd>' '</cd>' "$EXEDIR\LocalRoot.txt" $INSTDIR ; if it was unpacked by the Installer than the file is there
  3724. Goto ContinueInstall
  3725. EndGracefully:
  3726. MessageBox MB_OK "Unable to resolve the local root installation directory for the mail server. Ending Installer."
  3727. Quit
  3728. ContinueInstall:
  3729. ################################################ Variable Initialization Phase ########################################################
  3730. ##
  3731. ##
  3732. #######################################################################################################################################
  3733. ; 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.
  3734. ; Read the most recent archived snapshot path
  3735. IfFileExists "$INSTDIR\identity.xml" 0 TryAgain2
  3736. ${GetBetween} "licenseid='" "'" "$INSTDIR\identity.xml" $LicenseID
  3737. ${GetBetween} "authentication='" "'" "$INSTDIR\identity.xml" $Authentication
  3738. Goto MakeNew
  3739. TryAgain2:
  3740. IfFileExists "$SNFServerInstallDir\SNFRollback\identity.xml" 0 MakeNew
  3741. ${GetBetween} "licenseid='" "'" "$SNFServerInstallDir\SNFRollback\identity.xml" $LicenseID
  3742. ${GetBetween} "authentication='" "'" "$SNFServerInstallDir\SNFRollback\identity.xml" $Authentication
  3743. 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..
  3744. ; So we will proceed with fresh folder creation.
  3745. ## Variable initilization for some flags.
  3746. StrCpy $UnpackedCURLStuff "0" ; set for first time.
  3747. StrCpy $InstallerCompletedRestore "0" ; Initialize variables to default false.
  3748. StrCpy $DownloadFailed "0" ; $DownloadFailed This Variable declared in ONinit and defaulted to "0" for use in the RulebaseDownload screens.
  3749. ################# Some Pre-Rollback housekeeping. #################################
  3750. ## Grabbing copy of current settings, before forced rollback occurs.
  3751. ## Remember, that if we CAN rollback, we must rollback to ground zero. Hence the need to grab a copy of the existing files
  3752. ## before rollback.
  3753. ; This paragraph determines if we passed the FreshInstall flag (/F) to the installer to confirm
  3754. ; the desire to ignore the existing configuration.
  3755. ${GetOptions} $CommandLineParameters "-F" $R0
  3756. IfErrors RetainExistingConfig IgnoreExistingConfig
  3757. RetainExistingConfig:
  3758. StrCpy $RetainExistingSettings "1"
  3759. ifFileExists "$INSTDIR\snfmdplugin.xml" 0 +2 ; Both MDaemons xml, and SNFServer's xml files need to
  3760. CopyFiles /SILENT "$INSTDIR\snfmdplugin.xml" "$TEMP\snfmdplugin.xml" ; be captured before we stomp them with an older install
  3761. ; if a previous install existed.
  3762. ifFileExists "$INSTDIR\snf_engine.xml" 0 Defaults ; If we need to do this, swap a copy over to temp
  3763. CopyFiles /SILENT "$INSTDIR\snf_engine.xml" "$TEMP\snf_engine.xml" ; before we rollback, so we can restore it....
  3764. ;MessageBox MB_OK "Retaining"
  3765. Goto Defaults
  3766. IgnoreExistingConfig:
  3767. StrCpy $RetainExistingSettings "0"
  3768. Defaults:
  3769. ;MessageBox MB_OK "Retaining settings:$RetainExistingSettings"
  3770. #######################################################################################################################################
  3771. ## We're installing. Therefore if there is an existing rollback file, run it.
  3772. #######################################################################################################################################
  3773. ## BlockFullUninstall is the flag for determining if there was an existing manual install
  3774. ## If we have this flag, then the uninstaller will never be allowed to
  3775. ## remove the install completely.
  3776. Var /GLOBAL localSRS_RollbackPath
  3777. ReadRegStr $localSRS_RollbackPath HKLM "Software\MessageSniffer" "SRS_RollbackPath"
  3778. ifErrors 0 SkipBlocking ; So only on teh condition that an installer hasn't run, do we consider blocking.
  3779. ifFileExists "$INSTDIR\snf2check.exe" 0 +2
  3780. WriteRegStr HKLM "Software\MessageSniffer" "BlockFullUninstall" "1"
  3781. ifFileExists "$INSTDIR\mingwm10.dll" 0 +2
  3782. WriteRegStr HKLM "Software\MessageSniffer" "BlockFullUninstall" "1"
  3783. ifFileExists "$INSTDIR\SNFClient.exe" 0 +2
  3784. WriteRegStr HKLM "Software\MessageSniffer" "BlockFullUninstall" "1" ; FULL Uninstall Prempted.
  3785. SkipBlocking:
  3786. ; We decided that we will always run an available rollback.
  3787. ReadRegStr $1 HKLM "Software\MessageSniffer" "SRS_LogName"
  3788. # If none of these trip, we'll presume safe.
  3789. StrCmp $localSRS_RollbackPath "" NoPreRoll 0 ; so exit if no rollback file.
  3790. StrCmp $1 "" NoPreRoll 0 ; and no log.....
  3791. ## IF there are ANY valid rollback scenarios we are going to execute them prior to running a new install.
  3792. ## Before we let the rollback put things back... presuming we have a service installed, we'll need to stop it....
  3793. Call stopSNFServer ; if it there it will stop it.
  3794. Call stopXYNTService ; if its there, stop it.
  3795. ## IN the possible scenarior that we are uninstalling and rolling back a previous install when we are installing a seperate platform..
  3796. ## Pull in the reg key from the old system:
  3797. Var /GLOBAL OLD_INSTALL_DIR ; possible old , but if its the same (current) install folder, its ok.... it will still be functional.
  3798. ReadRegStr $OLD_INSTALL_DIR HKLM "Software\MessageSniffer" "Install_Dir"
  3799. ## Use that folder to trip the uninstall of XYNTService to enable the rollback.... ( The reason for this is that the NEW InstallDIR could be
  3800. ## different because of the LocalRoot.txt file coming from the users selection of a different platform... i.e. The $INSTDIR is where its GOING
  3801. ## not where the registry said it WAS......
  3802. IfFileExists "$OLD_INSTALL_DIR\XYNTService.exe" 0 +2
  3803. nsExec::Exec "$OLD_INSTALL_DIR\XYNTService -u" "" SH_HIDE ; uninstall it if it exists....
  3804. ## Now we should be ready to fire... even if its over the bow, to an older platform...
  3805. ## ADDING sensitivity to the functions being called to enable them to look up the proper path values in the event that the
  3806. ## rollback sequence is not in the current INSTDIR and $SNFServerInstallDir locations. i.e. Those parsing functions need to be able
  3807. ## 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
  3808. ## targeting, not just assume that its in the INSTDIR or the $SNFServerInstallDir. I added two registry keys to the EndRollbackSequence
  3809. ## subroutine called SRS_INSTDIR and SRS_SERVDIR to cover the lookup during rollback....since by this point INSTDIR is defined,
  3810. ## just having SRS_INSTDIR different from INSTDIR should be enough key to use the SRS_INSTDIR.... and if the SRS_INSTDIR doesnt' exist,
  3811. ## ( 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
  3812. ## will use the current INSTDIR as their paths.....
  3813. ## Get this before its rolled back and gone.
  3814. Var /GLOBAL localSRS_INSTDIR
  3815. Var /GLOBAL localSRS_SERVDIR
  3816. ReadRegStr $localSRS_INSTDIR HKLM "Software\MessageSniffer" "SRS_INSTDIR"
  3817. ReadRegStr $localSRS_SERVDIR HKLM "Software\MessageSniffer" "localSRS_SERVDIR"
  3818. ${RollBackTo} $localSRS_RollbackPath $1 ; Put all the files back the way they were. ; Both those values come from registry....
  3819. RMDir /r $localSRS_RollbackPath
  3820. ## Finish cleanup.
  3821. ## IF there is no SNFServer.exe there should be nothing else
  3822. ifFileExists "$localSRS_INSTDIR\SNFClient.exe" SkipNow 0 ; otherwise cleanup.
  3823. ifFileExists "$localSRS_INSTDIR\Restorer.exe" 0 +2
  3824. Delete "$localSRS_INSTDIR\Restorer.exe"
  3825. ifFileExists "$localSRS_INSTDIR\oldsnifferversion.txt" 0 +2
  3826. Delete "$localSRS_INSTDIR\oldsnifferversion.txt"
  3827. ifFileExists "$localSRS_INSTDIR\getRulebase.cmd.old" 0 +2
  3828. Delete "$localSRS_INSTDIR\getRulebase.cmd.old"
  3829. ifFileExists "$localSRS_INSTDIR\shortcuts.xml" 0 +2
  3830. Delete "$localSRS_INSTDIR\shortcuts.xml" ; if exists ; Find other location
  3831. ifFileExists "$localSRS_INSTDIR\cfgstring.xml" 0 +2
  3832. Delete "$localSRS_INSTDIR\cfgstring.xml" ; if exists ; Find other location
  3833. ifFileExists "$localSRS_INSTDIR\XYNTService.ini" 0 +2
  3834. Delete "$localSRS_INSTDIR\XYNTService.ini"
  3835. ifFileExists "$localSRS_INSTDIR\LocalRoot.txt" 0 +2
  3836. Delete "$localSRS_INSTDIR\LocalRoot.txt"
  3837. ifFileExists "$localSRS_INSTDIR\SNFServer${SNIFFER_SERVER_SPECIFIER}.exe" 0 +2
  3838. Delete "$localSRS_INSTDIR\SNFServer${SNIFFER_SERVER_SPECIFIER}.exe"
  3839. ifFileExists "$localSRS_INSTDIR\UpdateReady.txt" 0 +2
  3840. Delete "$localSRS_INSTDIR\UpdateReady.txt"
  3841. ifFileExists "$localSRS_INSTDIR\mingwm10.dll" 0 +2
  3842. Delete "$localSRS_INSTDIR\mingwm10.dll"
  3843. Delete "$localSRS_INSTDIR\uninstall.exe"
  3844. ; since we couldn't edit the registry, we don't need to worry abou tit. Now Kill attempt:
  3845. ## For MINMI
  3846. ifFileExists "$localSRS_SERVDIR\SNFIMailShimNEW.xml" 0 +2
  3847. Delete "$localSRS_SERVDIR\SNFIMailShimNEW.xml"
  3848. ifFileExists "$localSRS_SERVDIR\SNFIMailShim.xml" 0 +2
  3849. Delete "$localSRS_SERVDIR\SNFIMailShim.xml"
  3850. ifFileExists "$localSRS_SERVDIR\SNFIMailShim.exe" 0 +2
  3851. Delete "$localSRS_SERVDIR\SNFIMailShim.exe"
  3852. ifFileExists "$localSRS_SERVDIR\MIMIMIreadme.txt" 0 +2
  3853. Delete "$localSRS_SERVDIR\MIMIMIreadme.txt"
  3854. ifFileExists "$localSRS_SERVDIR\OLD_SNFIMailShim.exe" 0 +2
  3855. Delete "$localSRS_SERVDIR\OLD_SNFIMailShim.exe"
  3856. ifFileExists "$localSRS_SERVDIR\OLD_SNFIMailShim.xml" 0 +2
  3857. Delete "$localSRS_SERVDIR\OLD_SNFIMailShim.xml"
  3858. ## For MDaemon
  3859. ifFileExists "$localSRS_SERVDIR\snfmdplugin.dll" 0 +2
  3860. Delete "$localSRS_SERVDIR\snfmdplugin.dll"
  3861. ifFileExists "$localSRS_SERVDIR\snfmdplugin.xml" 0 +2
  3862. Delete "$localSRS_SERVDIR\snfmdplugin.xml"
  3863. ;ifFileExists "$localSRS_SERVDIR\OLD_SNFIMailShim.xml" 0 +2 ; if we find the xml file, then we need to do checking...
  3864. ; Rename "$localSRS_SERVDIR\OLD_SNFIMailShim.xml" "$localSRS_SERVDIR\SNFIMailShim.xml"
  3865. ;ifFileExists "$localSRS_SERVDIR\OLD_SNFIMailShim.exe" 0 +2 ; if we find the xml file, then we need to do checking...
  3866. ; Rename "$localSRS_SERVDIR\OLD_SNFIMailShim.exe" "$localSRS_SERVDIR\SNFIMailShim.exe"
  3867. SkipNow:
  3868. ;MessageBox MB_OK "Breaking"
  3869. Goto NoPreRoll
  3870. NoPreRoll:
  3871. ;MessageBox MB_OK "Starting Rollback Transaction"
  3872. ################################################ Start Rollback.nsh ###################################################################
  3873. ## A Install requires a rollback build.
  3874. ##
  3875. ## First define the rollback folder:
  3876. !insertmacro StartRollbackSession "$SNFServerInstallDir\SNFRollBack" "Archive_rllbck.log" "HKLM" "Software\MessageSniffer" ; _ArchivePath _LogName
  3877. ## Registry USAGE: $SetRegistry_with_RollbackControl "HKLM" "Software\MessageSniffer" "RollbackSequence" "0121"
  3878. ## File USAGE: ${Install_with_RollbackControl} "License.txt" ""
  3879. ## !insertmacro StartRollbackSession - Starts the rollback session to begin recording file and registry data.
  3880. ## !insertmacro EndRollbackSession - closes the rollback session
  3881. ## ${SetRegistry_with_RollbackControl} _RootKey _RegistryKey _SubKey _Value - Records a registry change for rollback.
  3882. ## ${Install_with_RollbackControl} _someFileName _onFailCommand - Installs a file with archival of old file for rollback.
  3883. ## ${Copy_with_RollbackControl} _someFile _Path _onFailCommand - Makes a copy of an existing file and records it in log for rollback.
  3884. ## ${RollBackTo} _rollbackLocalPath _rollbackLogName - Runs the parser through the rollback log and puts everything back.
  3885. #################################################################################################################
  3886. ; Set output path to the installation directory.
  3887. SetOutPath $INSTDIR
  3888. ; Write the installation path into the registry
  3889. ; WriteRegStr HKLM Software\MessageSniffer "Install_Dir" "$SNFServerInstallDir\$FolderPrefix"
  3890. ${SetRegistry_with_RollbackControl} "HKLM" "Software\MessageSniffer" "Install_Dir" "$INSTDIR"
  3891. ${SetRegistry_with_RollbackControl} "HKLM" "Software\MessageSniffer" "SNFMailServer_DIR" "$SNFServerInstallDir"
  3892. ## Prime doesn't matter anymore because we will ALWAYS run an existing rollback file, thus ensuring that the only way a
  3893. ## last working install is available is if the user had one installed manually.
  3894. ;ReadRegStr $2 HKLM "Software\MessageSniffer" "Prime"
  3895. ;${IF} $2 = "1"
  3896. ; ${SetRegistry_with_RollbackControl} "HKLM" "Software\MessageSniffer" "Prime" "0"
  3897. ;${ELSE}
  3898. ; ${SetRegistry_with_RollbackControl} "HKLM" "Software\MessageSniffer" "Prime" "1"
  3899. ;${ENDIF}
  3900. ; Also... if the OLD install... ( if there was one.... ) had the shortcuts installed... and they didnt' call for them here....
  3901. ; then we need to remove them... ( and if they want them, they'll be put back when that section fire.s
  3902. ; but if they WERE installed... we need to put it back on a rollback....
  3903. ifFileExists "$INSTDIR\shortcuts.xml" 0 SkipShortCutRollback
  3904. ${Copy_with_RollbackControl} "shortcuts.xml" "$INSTDIR" "" "" ; Copy the old Server.exe
  3905. SkipShortCutRollback:
  3906. Call removeShortcuts ; This will be reinstalled with the shortcuts pointing at the newer files, in the Section reguarding shortcuts anyway...
  3907. Return
  3908. ############################################################### ROLLBACK CODE ############################################################
  3909. ## Handled by th $rollback macro in Rollback.nsh.
  3910. PerformRollback:
  3911. ;MessageBox MB_OK "Stubbed Code."
  3912. return
  3913. ; Before we let the rollback put things back... presuming we have a service installed, we'll need to stop it....
  3914. Call stopSNFServer ; if it there it will stop it.
  3915. Call stopXYNTService ; if its there, stop it.
  3916. ; Since this is not being executed from the SNF directory, we are not put here by the master utility for a fresh
  3917. ; install. Instead, we are being called remotely ( or by a click...) from an archived directory. It dosn't really mater
  3918. ; where the archive is, but it ususally will be in [SomeMailInstalDirectory]\SNFArchive\[WheteverDirName]
  3919. ; So the first thing is to empty the SNF Directory.
  3920. ${RollBackTo} "$SNFServerInstallDir\SNFRollBack" "Archive_rllbck.log" ; Put all the files back the way they were.
  3921. ; 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
  3922. ; and files that weren't touched remain there.....
  3923. ## Won't need to do this cause we're not yanking the rulebase....
  3924. ##; We'll need the LicenseID in order to search and save the rulebase file if it exists.
  3925. ##${GetBetween} "licenseid='" "'" "$EXEDIR\identity.xml" $LicenseID ; This makes it not brittly dependant on the default value. i.e. It would
  3926. ##${GetBetween} "authentication='" "'" "$EXEDIR\identity.xml" $Authentication
  3927. ## INTENTIONALLY HARD TYPED.... reguardless of the target folder.
  3928. ##IfFileExists "$SNFServerInstallDir\SNF\$LicenseID.snf" 0 +2
  3929. ## Rename "$SNFServerInstallDir\SNF\$LicenseID.snf" "$SNFServerInstallDir\$LicenseID.snf" ; Move the existing rulebase out of the SNF directory.
  3930. ##IfFileExists "$SNFServerInstallDir\Sniffer\$LicenseID.snf" 0 +2
  3931. ## Rename "$SNFServerInstallDir\Sniffer\$LicenseID.snf" "$SNFServerInstallDir\$LicenseID.snf" ; Move the existing rulebase out of the SNF directory.
  3932. # Reguardless of $FolderPrefix, kill these existing folders.
  3933. ##IfFileExists "$SNFServerInstallDir\SNF\*.*" 0 DoSniffer
  3934. ## Delete "$SNFServerInstallDir\SNF\*.*" ; Kill all files in the SNF Dir. INTENTIONALLY HARD TYPED.....
  3935. ## RMDir "$SNFServerInstallDir\SNF"
  3936. ##DoSniffer:
  3937. ## IfFileExists "$SNFServerInstallDir\Sniffer\*.*" 0 +3
  3938. ## Delete "$SNFServerInstallDir\Sniffer\*" ; Kill all files in the sniffer Dir. INTENTIONALLY HARD TYPED.....
  3939. ## RMDir "$SNFServerInstallDir\Sniffer"
  3940. ##CreateDirectory "$SNFServerInstallDir\$FolderPrefix" ;Recreates target folder. Sniffer and SNF safe...
  3941. ##IfFileExists "$SNFServerInstallDir\$LicenseID.snf" 0 +2
  3942. ## Rename "$SNFServerInstallDir\$LicenseID.snf" "$SNFServerInstallDir\$FolderPrefix\$LicenseID.snf" ; Move the existing rulebase back into the SNF directory.
  3943. ## This is handled by teh rollback function....
  3944. ##; Now expressly copy all files to the SNF folder.
  3945. ##;MessageBox MB_OK "Restoring"
  3946. ## CopyFiles /SILENT "$EXEDIR\About-Wget-and-Gzip.txt" "$SNFServerInstallDir\$FolderPrefix\About-Wget-and-Gzip.txt"
  3947. ## CopyFiles /SILENT "$EXEDIR\AuthenticationProtocol.swf" "$SNFServerInstallDir\$FolderPrefix\AuthenticationProtocol.swf"
  3948. ## CopyFiles /SILENT "$EXEDIR\Archiver.exe" "$SNFServerInstallDir\$FolderPrefix\Archiver.exe"
  3949. ## CopyFiles /SILENT "$EXEDIR\ChangeLog.txt" "$SNFServerInstallDir\$FolderPrefix\ChangeLog.txt"
  3950. ## CopyFiles /SILENT "$EXEDIR\exchndl.dll" "$SNFServerInstallDir\$FolderPrefix\exchndl.dll"
  3951. ## CopyFiles /SILENT "$EXEDIR\GBUdbIgnoreList.txt" "$SNFServerInstallDir\$FolderPrefix\GBUdbIgnoreList.txt"
  3952. ## CopyFiles /SILENT "$EXEDIR\getRulebase.cmd" "$SNFServerInstallDir\$FolderPrefix\getRulebase.cmd"
  3953. ## CopyFiles /SILENT "$EXEDIR\gzip.exe" "$SNFServerInstallDir\$FolderPrefix\gzip.exe"
  3954. ## CopyFiles /SILENT "$EXEDIR\identity.xml" "$SNFServerInstallDir\$FolderPrefix\identity.xml"
  3955. ## CopyFiles /SILENT "$EXEDIR\License.txt" "$SNFServerInstallDir\$FolderPrefix\License.txt"
  3956. ## CopyFiles /SILENT "$EXEDIR\LocalRoot.txt" "$SNFServerInstallDir\$FolderPrefix\LocalRoot.txt"
  3957. ## CopyFiles /SILENT "$EXEDIR\mingwm10.dll" "$SNFServerInstallDir\$FolderPrefix\mingwm10.dll"
  3958. ## CopyFiles /SILENT "$EXEDIR\Restorer.exe" "$SNFServerInstallDir\$FolderPrefix\Restorer.exe"
  3959. ## CopyFiles /SILENT "$EXEDIR\send_shutdown.cmd" "$SNFServerInstallDir\$FolderPrefix\send_shutdown.cmd"
  3960. ## CopyFiles /SILENT "$EXEDIR\snf2check.exe" "$SNFServerInstallDir\$FolderPrefix\snf2check.exe"
  3961. ## CopyFiles /SILENT "$EXEDIR\snf_engine.xml" "$SNFServerInstallDir\$FolderPrefix\snf_engine.xml"
  3962. ## CopyFiles /SILENT "$EXEDIR\snf_xci.xml" "$SNFServerInstallDir\$FolderPrefix\snf_xci.xml"
  3963. ## CopyFiles /SILENT "$EXEDIR\SNFClient.exe" "$SNFServerInstallDir\$FolderPrefix\SNFClient.exe"
  3964. ## CopyFiles /SILENT "$EXEDIR\SNFClient_readme.txt" "$SNFServerInstallDir\$FolderPrefix\SNFClient_readme.txt"
  3965. ## CopyFiles /SILENT "$EXEDIR\SNFServer_readme.txt" "$SNFServerInstallDir\$FolderPrefix\SNFServer_readme.txt"
  3966. ## IFFileExists "$EXEDIR\SNFServer${SNIFFER_SERVER_SPECIFIER}.exe" 0 +2
  3967. ## CopyFiles /SILENT "$EXEDIR\SNFServer${SNIFFER_SERVER_SPECIFIER}.exe" "$SNFServerInstallDir\$FolderPrefix\SNFServer${SNIFFER_SERVER_SPECIFIER}.exe"
  3968. ## IFFileExists "$EXEDIR\SNFServer.exe" 0 +2
  3969. ## CopyFiles /SILENT "$EXEDIR\SNFServer.exe" "$SNFServerInstallDir\$FolderPrefix\SNFServer.exe"
  3970. ## IFFileExists "$EXEDIR\$LicenseID.exe" 0 +2
  3971. ## CopyFiles /SILENT "$EXEDIR\$LicenseID.exe" "$SNFServerInstallDir\$FolderPrefix\$LicenseID.exe"
  3972. ## CopyFiles /SILENT "$EXEDIR\wget.exe" "$SNFServerInstallDir\$FolderPrefix\wget.exe"
  3973. ## CopyFiles /SILENT "$EXEDIR\XYNTService.exe" "$SNFServerInstallDir\$FolderPrefix\XYNTService.exe"
  3974. ## CopyFiles /SILENT "$EXEDIR\XYNTService.ini" "$SNFServerInstallDir\$FolderPrefix\XYNTService.ini"
  3975. ## CopyFiles /SILENT "$EXEDIR\XYNTServiceReadMe.txt" "$SNFServerInstallDir\$FolderPrefix\XYNTServiceReadMe.txt"
  3976. ## IFFileExists "$EXEDIR\uninstall.bckup" 0 +2
  3977. ## CopyFiles /SILENT "$EXEDIR\uninstall.bckup" "$SNFServerInstallDir\$FolderPrefix\uninstall.exe"
  3978. ## IfFileExists "$EXEDIR\cfgstring.xml" 0 +2 ; this is used to restore the global.cfg entry line. it gets consumed as its mined.
  3979. ## CopyFiles /SILENT "$EXEDIR\cfgstring.xml" "$SNFServerInstallDir\$FolderPrefix\cfgstring.xml"
  3980. ##########################
  3981. ## ; Write the installation path into the registry
  3982. ## WriteRegStr HKLM Software\MessageSniffer "Install_Dir" "$SNFServerInstallDir\$FolderPrefix"
  3983. ##########################
  3984. ##; Declude Special
  3985. ##ifFileExists "$SNFServerInstallDir\global.cfg" 0 +2 ; replace line in existing cfg file with line from archived cfg command.
  3986. ## call editglobalCFG
  3987. ############################ MxGuard Special #####################
  3988. ## ifFileExists "$SNFServerInstallDir\mxGuard.ini" 0 +2
  3989. ## call editMXGuardINI
  3990. ##########################
  3991. ##; MINIMI Special. IF MINIMI was installed with this version then we need to restore from the archive....
  3992. ##Var /GLOBAL MINIMISpecial_KeyHandle
  3993. ##ifFileExists "$EXEDIR\OLD_SNFIMailShim.xml" 0 SkipMINIMISpecial
  3994. ## ; ok, well the file exists, so we need to make sure that the registry entrys are there....
  3995. ## ClearErrors
  3996. ## ReadRegStr $MINIMISpecial_KeyHandle HKLM "SOFTWARE\Ipswitch\IMail\Global" "TopDir" ; get IMails value.
  3997. ## StrCmp $MINIMISpecial_KeyHandle "" SkipMINIMISpecial 0 ; test for valid TopDir for Imail.
  3998. ## ; so we can presume that Imail should exist, and this setting is ON....
  3999. ## WriteRegStr HKLM "Software\MessageSniffer" "isMINIMIInstalled" "1" ; Since we have the file in the folder, we're resetting it back...
  4000. ## WriteRegStr HKLM "Software\MessageSniffer" "MINIMIInstallFolder" "$MINIMISpecial_KeyHandle" ; Since we have the file in the folder, we're resetting it back...
  4001. ## IfFileExists "$MINIMISpecial_KeyHandle\SNFIMailShim.xml" 0 +2
  4002. ## Delete "$MINIMISpecial_KeyHandle\SNFIMailShim.xml"
  4003. ## IfFileExists "$MINIMISpecial_KeyHandle\SNFIMailShim.exe" 0 +2
  4004. ## Delete "$MINIMISpecial_KeyHandle\SNFIMailShim.exe"
  4005. ## CopyFiles "$EXEDIR\OLD_SNFIMailShim.xml" "$MINIMISpecial_KeyHandle\SNFIMailShim.xml"
  4006. ## CopyFiles "$EXEDIR\SNFIMailShim.exe" "$MINIMISpecial_KeyHandle\SNFIMailShim.exe"
  4007. # Now you must re-tie-in IMail to the MINIMI Install.....
  4008. # If you're restoring an image onto somehting ( say DECLUDE ) that stompted the SendName anyway, then you need a new install of MINIMI....
  4009. # not a restored version of MINIMI. If you restore it, it will stomp the Declude.
  4010. ## WriteRegStr HKLM "SOFTWARE\Ipswitch\IMail\Global" "SendName" "$MINIMISpecial_KeyHandle\SNFIMailShim.exe"
  4011. ; 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...
  4012. ; oh well... not my problem....
  4013. # Last, verify that the hold folder exists for the installation and create it if it doesn't.
  4014. ## ${GetBetween} "<hold path='" "\'/>$\r$\n" "$MINIMISpecial_KeyHandle\SNFIMailShim.xml" "$R0" ; This makes it not brittly dependant on the default value. i.e. It would
  4015. ## IfFileExists "$R0\*.*" +2 0 ; if it exists then skip, otherwise, recreate the spam target directory
  4016. ## CreateDirectory "$R0\*.*"
  4017. ##SkipMINIMISpecial:
  4018. ################################################# End MINIMI INSTALL RESTORE ###########################################################
  4019. MessageBox MB_OK "Stubbed Code. This should never run."
  4020. ## Shortcuts only relevant for modern installed verions, not sniffy.....
  4021. ## Handle shortcut exception.
  4022. IfFileExists "$SNFServerInstallDir\SNFRollback\shortcuts.xml" 0 RemoveTheShortcuts
  4023. ##CopyFiles /SILENT "$EXEDIR\shortcuts.xml" "$SNFServerInstallDir\$FolderPrefix\shortcuts.xml"
  4024. ; But if it exists, it means that they were installed so put them back.
  4025. SetShellVarContext all ; this makes it backward/forwrad compatible Without it Vista will have problems removing shortcuts.
  4026. ; Essentially, we said put these shortcuts into the all-users profile of the machine
  4027. CreateDirectory "$SMPROGRAMS\MessageSniffer"
  4028. CreateShortCut "$SMPROGRAMS\MessageSniffer\InstallInstructions.lnk" "$INSTDIR\InstallInstructions.txt"
  4029. CreateShortCut "$SMPROGRAMS\MessageSniffer\MessageSniffer.lnk" "http://kb.armresearch.com/index.php?title=Message_Sniffer"
  4030. CreateShortCut "$SMPROGRAMS\MessageSniffer\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  4031. CreateShortCut "$SMPROGRAMS\MessageSniffer\GBUdbIgnoreList.lnk" "$INSTDIR\GBUdbIgnoreList.txt"
  4032. Goto SkipShortcuts
  4033. RemoveTheShortcuts:
  4034. ; if the files exists... and the restore says that they didn't have them for the restored version.... then they need to go away.
  4035. Call removeShortCuts
  4036. SkipShortcuts:
  4037. ;MessageBox MB_OK "Starting SNFService"
  4038. ## These would have been handled by the ROllBACK if they existed, and removed if they didn't.
  4039. ##SetOutPath $INSTDIR
  4040. ##File "XYNTService.exe" ; Unpack the files.
  4041. ##File "XYNTService.ini"
  4042. MessageBox MB_OK "Stubbed Code. This should never run."
  4043. call editXYNTServiceINI ; First properly handle the ini file.
  4044. ## HERE we say, if the file still exists after the rollback.... THEN... we can reinstall the XYNTService.
  4045. nsExec::Exec "XYNTService -u" "" SH_HIDE ; uninstall it if it exists....
  4046. ; presumes that the .ini file is in the same location.
  4047. nsExec::Exec "XYNTService -i" "" SH_HIDE ; install XYNTService
  4048. nsExec::Exec "XYNTService -r" "" SH_HIDE ; restart XYNTService
  4049. call startSNFServer ;nsExec::Exec "NET START SNFService" "" SH_HIDE
  4050. call onRestoreSuccess
  4051. Quit ; This will transfer control to the license page, which will determine if a restore was just completed
  4052. ; prior to displaying the license. If it IS we use the RelGotoPage function to move us to the restore-success screen and end.
  4053. FunctionEnd
  4054. ; The stuff to install
  4055. Section "MessageSniffer (required)"
  4056. ; MessageBox MB_OK "Entering sniffer reuqired section. "
  4057. SectionIN RO ; Required Option express declaration.
  4058. ; Set output path to the installation directory.
  4059. SetOutPath $INSTDIR ; even the rollback scripts depend on having this properly assigned in the installer. They'll put it where this is set.
  4060. ; presuming we have an existing service installed, we'll need to stop it.... ( doesn't hurt if its not there. )
  4061. Call stopSNFServer ; if its there it will stop it.
  4062. Call stopXYNTService ; if its there, stop it.
  4063. ## A lot of conditional branching needs to skip over things if this is an MDaemon install. As opposed to all other installs.
  4064. ## So its worth defining an MDaemon flag.
  4065. Var /GLOBAL isMDaemonInstalled
  4066. StrCpy $isMDaemonInstalled 0 ; default to no.
  4067. ifFileExists "$SNFServerInstallDir\App\MDaemon.exe" 0 NoDetectableMDaemon ; Would have to be there for MDaemon.
  4068. ifFileExists "$SNFServerInstallDir\SpamAssassin\rules\*.*" 0 NoDetectableMDaemon ; also dependant on the rules plugin.
  4069. StrCpy $isMDaemonInstalled 1 ;ok, its here, so use conditional branching on MDaemon flag.
  4070. ## The following calls to the CopyWithRollbackControl have the file, the location and the callback function name that needs to be defined
  4071. ## 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.
  4072. ## MDaemon Special ## Note the MDaemon snfmdplugins.xml file is handled specially, alongside the snfengine.xml file code further down.
  4073. SetOutPath "$INSTDIR"
  4074. ${Install_with_RollbackControl} "InstallInstructions_MDaemon.txt" "" "" ; Install and remove this file on rollback.
  4075. ${Install_with_RollbackControl} "snfmdplugin.dll" "" "" ; Install and remove this file on rollback.
  4076. SetOutPath "$SNFServerInstallDir\SpamAssassin\rules"
  4077. ${Install_with_RollbackControl} "snf-groups.cf" "" "" ; Install and remove this file on rollback.
  4078. ## Handle the MDaemon Plugins file. If exists, copy old, if gone, insert new, then when done, call edit to validate/correct entries.
  4079. SetOutPath "$SNFServerInstallDir\App"
  4080. ifFileExists "$SNFServerInstallDir\App\Plugins.dat" 0 NewPluginsDatFile
  4081. ;MessageBox MB_OK "MDAEMONDEBUG:Plugins exists. Copying Rollback."
  4082. ${Copy_with_RollbackControl} "Plugins.dat" "$SNFServerInstallDir\App" "restoreMDaemonDAT" "" ; Copy the old PluginsFile if it exists file.
  4083. Goto DoneWithPluginsDatFile
  4084. NewPluginsDatFile:
  4085. ;MessageBox MB_OK "MDAEMONDEBUG: Plugins doesn't exist Install with Rollback."
  4086. ${Install_with_RollbackControl} "Plugins.dat" "restoreMDaemonDAT" "" ; Install and remove this file on rollback.
  4087. DoneWithPluginsDatFile:
  4088. SetOutPath "$INSTDIR"
  4089. NoDetectableMDaemon:
  4090. SetOutPath "$INSTDIR" ; even the rollback scripts depend on having this properly assigned in the installer. They'll put it where this is set.
  4091. ; If we got to here then we're ok to commit the files.
  4092. ; Put file there
  4093. ${Install_with_RollbackControl} "CURLREADME.rtf" "" ""
  4094. ${Install_with_RollbackControl} "CURLMANUAL.rtf" "" ""
  4095. ${Install_with_RollbackControl} "AuthenticationProtocol.swf" "" ""
  4096. #File /a "AuthenticationProtocol.swf"
  4097. ${Install_with_RollbackControl} "ChangeLog.txt" "" ""
  4098. #File /a "ChangeLog.txt"
  4099. ; File /a "getRulebase.cmd" This is handled during the init of the download rulebase page.
  4100. ; These files are handled during download of rulebase page also.
  4101. #${Install_with_RollbackControl} "gzip.exe" ""
  4102. #File /a "gzip.exe"
  4103. #${Install_with_RollbackControl} "snf2check.exe" ""
  4104. #File /a "snf2check.exe"
  4105. #${Install_with_RollbackControl} "curl.exe" ""
  4106. # File /a "curl.exe"
  4107. ${Install_with_RollbackControl} "License.txt" "" ""
  4108. #File /a "License.txt"
  4109. ${Install_with_RollbackControl} "SNFClient.exe" "" ""
  4110. #File /a "SNFClient.exe"
  4111. ${Install_with_RollbackControl} "SNFClient_readme.txt" "" ""
  4112. #File /a "SNFClient_readme.txt"
  4113. ${Install_with_RollbackControl} "mingwm10.dll" "" ""
  4114. #File /a "mingwm10.dll"
  4115. ## These files do NOT need to be installed if the MDaemon install is being utilized.
  4116. StrCmp $isMDaemonInstalled 0 0 SkipForMDaemon1
  4117. SetOutPath "$INSTDIR"
  4118. ${Install_with_RollbackControl} "exchndl.dll" "" ""
  4119. #File /a "exchndl.dll"
  4120. ${Install_with_RollbackControl} "send_shutdown.cmd" "" ""
  4121. #File /a "send_shutdown.cmd"
  4122. ${Install_with_RollbackControl} "snf_xci.xml" "" ""
  4123. #File /a "snf_xci.xml"
  4124. ${Install_with_RollbackControl} "SNFServer_readme.txt" "" ""
  4125. #File /a "SNFServer_readme.txt"
  4126. ${Install_with_RollbackControl} "SNFServer${SNIFFER_SERVER_SPECIFIER}.exe" "" "" ; Record and put the file name.
  4127. #File /a "SNFServer${SNIFFER_SERVER_SPECIFIER}.exe"
  4128. ${Install_with_RollbackControl} "SNFServer.exe" "" "" ; Record and put the file name.
  4129. ## InstallXYNTServiceFile
  4130. ${Install_with_RollbackControl} "XYNTService.exe" "" ""
  4131. #File /a "XYNTService.exe"
  4132. ${Install_with_RollbackControl} "XYNTService.ini" "restoreXYNTini" ""
  4133. #File /a "XYNTService.ini"
  4134. ${Install_with_RollbackControl} "XYNTServiceReadMe.txt" "" ""
  4135. #File /a "XYNTServiceReadMe.txt"
  4136. ${Install_with_RollbackControl} "InstallInstructions.txt" "" "" ; Install and remove this file on rollback.
  4137. SkipForMDaemon1:
  4138. SetOutPath "$INSTDIR"
  4139. ; THESE files are copied by default and then stomped if we find one in the archive if we are preserving settings.
  4140. ${Install_with_RollbackControl} "GBUdbIgnoreList.txt" "" ""
  4141. #File /a "GBUdbIgnoreList.txt"
  4142. ${Install_with_RollbackControl} "identity.xml" "" ""
  4143. #File /a "identity.xml"
  4144. ## Because of the rollback its possible that the snf_engine.xml file was removed. But if the user selected UPDATE ( retain settings ),
  4145. ## 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.
  4146. SetOutPath "$INSTDIR"
  4147. StrCmp $RetainExistingSettings "0" FreshSNFEngine HandleRetainingSNFENGINEFILE # ( Or the MDaemonDLL.xml file )....
  4148. FreshSNFEngine:
  4149. ;MessageBox MB_OK "Not retaining"
  4150. ; This situation is trivial. Just allow the files to be installed in the rollback log. If an older file exists,
  4151. ; keep a copy for rollback, but the new file goes in the new install spot.
  4152. StrCmp $isMDaemonInstalled 0 DoWinService DoMDaemonFreshInstead
  4153. DoWinService:
  4154. ${Install_with_RollbackControl} "snf_engine.xml" "" ""
  4155. Goto DoneWithSNFHandling
  4156. DoMDaemonFreshInstead:
  4157. ${Install_with_RollbackControl} "snfmdplugin.xml" "" "" ; Install and remove this file on rollback.
  4158. Goto DoneWithSNFHandling
  4159. HandleRetainingSNFENGINEFILE:
  4160. ; 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
  4161. ; and that we're referencing the new file. SO... we need to use a Copy _with_Rollback
  4162. ; 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
  4163. ; 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.
  4164. ; That puts either an old file, or it deletes and removes the only one that was there.
  4165. ; 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.
  4166. ; If its not there, then we put jump to the new-install path, and complete.
  4167. ; Because this behavior needs to be duplicated between the snfEngine file and the mdplugin.xml file... we effectively double it here.
  4168. StrCmp $isMDaemonInstalled 0 DoWinServiceRetaining DoMDaemonRetainingInstead
  4169. DoWinServiceRetaining:
  4170. ; Ok, so look for it where we stuffed the copy during onInit. ( Before rollback. )
  4171. ifFileExists "$TEMP\snf_engine.xml" 0 NotInTempDir ; If its there then we copy it back to the install directory.
  4172. ;MessageBox MB_OK "Existed"
  4173. CopyFiles "$TEMP\snf_engine.xml" "$INSTDIR\snf_engine.xml" ; joy
  4174. NotInTempDir: ; If it didn't exist, then somethings wierd, but recoverable.
  4175. ifFileExists "$INSTDIR\snf_engine.xml" 0 FreshSNFEngine ; Check to see if it exists IN the folder... if it does, then keep copy for rollback.
  4176. ; Otherwise, jump to fresh install path and put a new copy in place.
  4177. ${Copy_with_RollbackControl} "snf_engine.xml" $INSTDIR "" "" ; Copy the old snf_engine.xml file.
  4178. Delete "$TEMP\snf_engine.xml" ; Remove the temp if it exists.
  4179. Goto DoneWithSNFHandling ; Done with the SNF Windows Service retain-settings path.
  4180. DoMDaemonRetainingInstead: ; Ok, we're handling the MDaemon version...
  4181. ifFileExists "$TEMP\snfmdplugin.xml" 0 NotInTempDir2 ; Look for the MDaemon xml version in the Temp. ( Copied before onInit rolled back. )
  4182. CopyFiles "$TEMP\snfmdplugin.xml" "$INSTDIR\snfmdplugin.xml" ; Move file back if found.
  4183. NotInTempDir2: ; Nope, not in the temp.. look local just in case.
  4184. ifFileExists "$INSTDIR\snfmdplugin.xml" 0 FreshSNFEngine ; if Not in local, then call for fresh, and pump out new.
  4185. ${Copy_with_RollbackControl} "snfmdplugin.xml" $INSTDIR "" "" ; If it does exist, keep the backup in the rollback, who knows where it came from.
  4186. Delete "$TEMP\snf_engine.xml" ; Delete temp if exists.
  4187. Goto DoneWithSNFHandling ; done.
  4188. DoneWithSNFHandling:
  4189. #File /a "snf_engine.xml"
  4190. StrCmp $RetainExistingSettings "1" 0 callEdits
  4191. ifFileExists "$SNFServerInstallDir\SNFRollback\snfmdplugin.xml" 0 +2 ; Only if file exists.....
  4192. CopyFiles /SILENT "$SNFServerInstallDir\SNFRollback\snfmdplugin.xml" "$INSTDIR\snfmdplugin.xml"
  4193. ifFileExists "$SNFServerInstallDir\SNFRollback\getRulebase.cmd" 0 +2 ; Only if file exists.....
  4194. CopyFiles /SILENT "$SNFServerInstallDir\SNFRollback\getRulebase.cmd" "$INSTDIR\getRulebase.cmd"
  4195. ; no action fpr the getRulebase.cmd The Edit routine is called when the dialog page executes...
  4196. ; and if we're restoring the archived version here, then we don't need to call it anyway.
  4197. ifFileExists "$SNFServerInstallDir\SNFRollback\GBUdbIgnoreList.txt" 0 +2 ; Only if file exists.....
  4198. CopyFiles /SILENT "$SNFServerInstallDir\SNFRollback\GBUdbIgnoreList.txt" "$INSTDIR\GBUdbIgnoreList.txt"
  4199. ; no action fro the GBUdbIgnoreList.txt
  4200. ifFileExists "$SNFServerInstallDir\SNFRollback\identity.xml" 0 +2 ; If exists... copy.
  4201. CopyFiles /SILENT "$SNFServerInstallDir\SNFRollback\identity.xml" "$INSTDIR\identity.xml"
  4202. callEdits:
  4203. # 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.
  4204. Call editGetRulebase ; ( Handle the paths )
  4205. Call editLicenseFile ; Always call this... Finds, Opens and edits the License.xml File with the License ID and Authentication strings.
  4206. ifFileExists "$SNFServerInstallDir\App\MDaemon.exe" 0 +2
  4207. Call editMDPluginsFile
  4208. ##########################
  4209. ## The following calls to the CopyWithRollbackControl have the file, the location and the callback function name that needs to be defined
  4210. ## somewere above. Eventually, on restore, if a call back function is defined it will be called in order to trip a restore feature.
  4211. ##########################
  4212. ; Declude Special
  4213. ifFileExists "$SNFServerInstallDir\global.cfg" 0 SkipDeclude_Special ; replace line in existing cfg file with line from archived cfg command.
  4214. ;messageBox MB_OK "Calling the Declude special $SNFServerInstallDir\global.cfg"
  4215. ${Copy_with_RollbackControl} "global.cfg" $SNFServerInstallDir "restoreGLOBALcfg" "" ; Copy the old Server.exe
  4216. call editglobalCFG ; then edit the declude config file.
  4217. SkipDeclude_Special:
  4218. ############################ MxGuard Special #####################
  4219. ifFileExists "$SNFServerInstallDir\mxGuard.ini" 0 SkipMXGuard_Special
  4220. ;messageBox MB_OK "Calling the MXGuard special $SNFServerInstallDir\mxGuard.ini"
  4221. ${Copy_with_RollbackControl} "mxGuard.ini" $SNFServerInstallDir "restoreMXGUARDini" "" ; Copy the old MXGuard.ini file.
  4222. call editMXGuardINI ; this should put the file pointing at SNF...
  4223. SkipMXGuard_Special:
  4224. ############################ Alligate Special #####################
  4225. ifFileExists "$SNFServerInstallDir\SNF4Alligate.exe" 0 SkipAlligate_Special
  4226. ; Nothing here right now. The shims are installed at the Installer layer, not the Restorer layer, and hence aren't
  4227. ; in the control of the rollback.
  4228. SkipAlligate_Special:
  4229. ############################ IceWarp Special #####################
  4230. ifFileExists "$SNFServerInstallDir\config\content.xml" 0 SkipIceWarp_Special
  4231. #${Copy_with_RollbackControl} "content.xml" "$SNFServerInstallDir\config\" "restoreContentXML" "" ; Copy the old MXGuard.ini file. ; Removed Callback.. redundent.
  4232. ; Why isn't this copied in rollback? Nothing to change from the customers perspective? Hmmmmmm.... they COULD edit it... this might be an error.
  4233. call editContentXML
  4234. SkipIceWarp_Special:
  4235. ############################ SNFClient.exe and snfmdaemon.dll Special ############################
  4236. # snf_engine.xml and snfmdplugin.xml files
  4237. # There is a slight detail.
  4238. # If the install parameters were set to overwrite previous files if they existed... vs.. using their settings if they do...
  4239. #
  4240. # NOTE: that editXMLConfig is smart enough to know if its editing the snfmddll.xml file, or the snf_engine.xml file. Same rules apply.
  4241. #
  4242. StrCmp $RetainExistingSettings "1" 0 JustUseAllNewFiles ; If we have a RETAIN flag set then use existing settings from file...
  4243. ## Note: If we retained settings, then we copied the old snfengine.xml/snfmddll.xml file to the temp and then back into the
  4244. ## 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.
  4245. ## and the flag $RetainExistingSettings to determine what we are to do.
  4246. ##
  4247. ## So check the mdaemon version if that exists, or the snfengine.xml if that one exists.
  4248. ifFileExists "$INSTDIR\snfmdplugin.xml" UseMDaemonXMLFIle UseStdSNFEngineFile
  4249. ; So if this file exists then we mine it for the auto update flag, before calling the
  4250. UseMDaemonXMLFIle: ; editXMLConfig function. ( Because that will set it ON by default unless told not to. )
  4251. # 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. )
  4252. ${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
  4253. ; if the setting is off, then its an old file.
  4254. StrCmp $AUTO_UPDATE_ONOFF_FLAG "" 0 adjustFileNow ; if not expressly false, then use default of ON
  4255. StrCpy $AUTO_UPDATE_ONOFF_FLAG "off" ; flag is set off.
  4256. goto adjustFileNow ; break out and run edit script.
  4257. UseStdSNFEngineFile: ; Ok, the snf_engine file is what were mining, not the mdaemon.
  4258. ${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
  4259. StrCmp $AUTO_UPDATE_ONOFF_FLAG "" 0 adjustFileNow ; if not expressly false, then use default of ON
  4260. StrCpy $AUTO_UPDATE_ONOFF_FLAG "off"
  4261. ; fall through now.
  4262. adjustFileNow:
  4263. Call editXMLConfig ; patching this function to hand off to use the snfmdplugin.xml file as source if necessary.
  4264. Goto DoneWithFiles
  4265. JustUseAllNewFiles:
  4266. ; Prior to calling editXMLConfig we need to set the flag that determines if we're using the AutoUpdate feature.
  4267. StrCpy $AUTO_UPDATE_ONOFF_FLAG "on" ; Defaults to yes.
  4268. Call editXMLConfig ; Handles altering the log and executible paths as well as the network instrument. ( If it exists. )
  4269. ; Don't need to parse it if we have it....
  4270. DoneWithFiles:
  4271. ; A similar command will be used to open the GUIEdit file with a notepad.exe
  4272. ${IF} $OpenGBUIgnoreFileOnClose == 1
  4273. ExecWait '"notepad.exe" "$INSTDIR\GBUdbIgnoreList.txt"'
  4274. ${ENDIF}
  4275. ; Write the uninstall keys for Windows For NSIS not SNF Install relevant
  4276. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MessageSniffer" "DisplayName" "Message Sniffer"
  4277. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MessageSniffer" "UninstallString" '"$INSTDIR\uninstall.exe"'
  4278. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MessageSniffer" "NoModify" 1
  4279. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MessageSniffer" "NoRepair" 1
  4280. SetOutPath $INSTDIR
  4281. ifFileExists "$INSTDIR\uninstall.exe" 0 +2
  4282. ${Copy_with_RollbackControl} "uninstall.exe" "$INSTDIR" "" "" ; Copy the old Uninstaller.exe
  4283. WriteUninstaller "uninstall.exe"
  4284. ## These calls aren't required for the MDaemon installation.
  4285. ## Skipp for MDaemon, the files won't be there, the service isn't going to be installed.
  4286. ifFileExists "$INSTDIR\snfmdplugin.xml" SkipAllServiceRelatedCalls RunServiceWrapperInstallMethods
  4287. RunServiceWrapperInstallMethods:
  4288. call editXYNTServiceINI ; First properly handle the ini file.
  4289. ## HERE we say, if the file still exists after the rollback.... THEN... we can uninstall and reinstall the XYNTService.
  4290. nsExec::Exec "$INSTDIR\XYNTService -u" "" SH_HIDE ; uninstall it if it exists....
  4291. ; presumes that the .ini file is in the same location.
  4292. nsExec::Exec "$INSTDIR\XYNTService -i" "" SH_HIDE ; install XYNTService
  4293. nsExec::Exec "$INSTDIR\XYNTService -r" "" SH_HIDE ; restart XYNTService
  4294. call startSNFServer ;nsExec::Exec "NET START SNFService" "" SH_HIDE
  4295. SkipAllServiceRelatedCalls:
  4296. ; Looks like were done.
  4297. ## Close rollback macro.
  4298. ${EndRollbackSession} "HKLM" "Software\MessageSniffer" ; Close this file, and end the rollback session. Provide strings for the resgistry handle.
  4299. SectionEnd
  4300. ; Optional section (can be disabled by the user)
  4301. Section "Start Menu Shortcuts"
  4302. SetOutPath $INSTDIR
  4303. VAR /GLOBAL FileHandle
  4304. ; NOTE we need to track if these were installed, for putting back on archive/restore.
  4305. FileOpen $FileHandle "$INSTDIR\shortcuts.xml" w
  4306. FileWrite $FileHandle "<snf><shortcuts>1</shortcuts></snf>"
  4307. FileClose $FileHandle
  4308. SetShellVarContext all ; this makes it backward/forwrad compatible Without it Vista will have problems removing shortcuts.
  4309. ; Essentially, we said put these shortcuts into the all-users profile of the machine
  4310. CreateDirectory "$SMPROGRAMS\MessageSniffer"
  4311. ifFileExists "$INSTDIR\snfmdplugin.dll" 0 InstallNormalInstructions
  4312. CreateShortCut "$SMPROGRAMS\MessageSniffer\InstallInstructions.lnk" "$INSTDIR\InstallInstructions_MDaemon.txt"
  4313. Goto AddSiteLink
  4314. InstallNormalInstructions:
  4315. CreateShortCut "$SMPROGRAMS\MessageSniffer\InstallInstructions.lnk" "$INSTDIR\InstallInstructions.txt"
  4316. AddSiteLink:
  4317. CreateShortCut "$SMPROGRAMS\MessageSniffer\MessageSniffer.lnk" "http://www.armresearch.com/"
  4318. CreateShortCut "$SMPROGRAMS\MessageSniffer\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  4319. CreateShortCut "$SMPROGRAMS\MessageSniffer\GBUdbIgnoreList.lnk" "$INSTDIR\GBUdbIgnoreList.txt"
  4320. SectionEnd
  4321. ;--------------------------------
  4322. ; Uninstaller
  4323. Function un.Restore
  4324. !insertmacro BIMAGE "SnifferStop.bmp" "" ; change banner image.
  4325. SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:Uninstall Message Sniffer Server 3.0:"
  4326. ; Page formation
  4327. nsDialogs::Create /NOUNLOAD 1018
  4328. Pop $0
  4329. ; now check restore options:
  4330. VAR /GLOBAL DeleteArchives ; flag to indicate yes/no
  4331. StrCpy $DeleteArchives "0" ; default to no.
  4332. ${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."
  4333. Pop $0
  4334. ;${NSD_CreateLabel} 30 50% 100% 20u ""
  4335. ;Pop $0
  4336. ${NSD_CreateCheckbox} 0 50% 100% 20 "Check this if you want to remove all archived Message Sniffer folders."
  4337. Pop $CHECKBOX
  4338. GetFunctionAddress $0 un.ToggleRestore
  4339. nsDialogs::OnClick /NOUNLOAD $CHECKBOX $0
  4340. nsDialogs::Show
  4341. FunctionEnd
  4342. Function un.BeSure
  4343. StrCpy $5 "This operation will remove the current restore/rollback of Message Sniffer from the Server 3.0 install."
  4344. StrCmp $DeleteArchives "1" 0 +2
  4345. StrCpy $5 "You have chosen to destroy your rollback files as well THE ROLLBACK ARCHIVE WILL BE DELETED. This operation cannot be undone."
  4346. MessageBox MB_YESNO "Are you sure? $5" IDYES true IDNO false
  4347. true:
  4348. Return
  4349. false:
  4350. Abort
  4351. FunctionEnd
  4352. Function un.ToggleRestore
  4353. Pop $0 # HWND
  4354. StrCmp $DeleteArchives "1" 0 ToggleStuff
  4355. StrCpy $DeleteArchives "0";
  4356. Push $0
  4357. GetTempFileName $0
  4358. File /oname=$0 "SnifferStop.bmp"
  4359. SetBrandingImage "" $0
  4360. Delete $0
  4361. Pop $0
  4362. Return
  4363. ToggleStuff:
  4364. StrCpy $DeleteArchives "1";
  4365. Push $0
  4366. GetTempFileName $0
  4367. File /oname=$0 "SnifferStop2.bmp"
  4368. SetBrandingImage "" $0
  4369. Delete $0
  4370. Pop $0
  4371. FunctionEnd
  4372. Function un.RemoveSNF4Alligate
  4373. ######################################################################### SNF4ALLIGATE UNINSTALL SECTION ############################################
  4374. ; If SNF4Alligate exists then we remove it.
  4375. Var /GLOBAL uninstallAlligate
  4376. ReadRegStr $uninstallAlligate HKLM "Software\MessageSniffer" "isSNF4AlligateInstalled" ; read the install folder for MINIMI.
  4377. StrCmp $uninstallAlligate "1" 0 NoAlligateHere
  4378. ; If we DO have SNF4Alligate installed we drop in here....
  4379. Var /GLOBAL UninstallAlligateFolder ; holds if and where MINIMI was installed.
  4380. Var /GLOBAL AlligateDelivery_Setting
  4381. Var /GLOBAL currentAlligateTarget
  4382. ReadRegStr $currentAlligateTarget HKLM "Software\SolidOak\Aligate\Settings" "FilterEXE" ; read alligates AGFILTSVC target....
  4383. StrCmp $currentAlligateTarget "SNF4Alligate.exe" 0 SkipFilterExeAdustment
  4384. ; Then we'll clear it, or set it to the next in the chain.
  4385. ; So we'll need to know if we're the ones in Alligates prime spot... otherwise we don't clear/or clean it.
  4386. ReadRegStr $UninstallAlligateFolder HKLM "Software\MessageSniffer" "SNF4AlligateInstallFolder" ; read the install folder for MINIMI.
  4387. ; Now we know where the files are:
  4388. ; So read out the delivery program setting:
  4389. ifFileExists "$UninstallAlligateFolder\SNF4Alligate.xml" 0 NoXMLFile ; if we find the xml file, then we need to do checking...
  4390. ; IF this is valid, then we read from OLD....
  4391. ; and if its anything other than the inert tag values, we put it back in.
  4392. ${un.GetBetween} "<delivery program='" "'/>$\r$\n" "$UninstallAlligateFolder\SNF4Alligate.xml" "$AlligateDelivery_Setting"
  4393. ${Switch} $AlligateDelivery_Setting
  4394. ${Case} ""
  4395. ExecWait 'net stop AGFILTSVC'
  4396. ExecWait '$UninstallAlligateFolder\AGFiltSvc.exe /uninstall'
  4397. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "FilterEXE" ""
  4398. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "DropDir" "\Spool"
  4399. goto doneResolvingAlligateDeliverySetting
  4400. ${Case} "none"
  4401. ExecWait 'net stop AGFILTSVC'
  4402. ExecWait '$UninstallAlligateFolder\AGFiltSvc.exe /uninstall'
  4403. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "FilterEXE" ""
  4404. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "DropDir" "\Spool"
  4405. goto doneResolvingAlligateDeliverySetting
  4406. ${Case} "NONE"
  4407. ExecWait 'net stop AGFILTSVC'
  4408. ExecWait '$UninstallAlligateFolder\AGFiltSvc.exe /uninstall'
  4409. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "FilterEXE" ""
  4410. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "DropDir" "\Spool"
  4411. goto doneResolvingAlligateDeliverySetting
  4412. ${Case} "None"
  4413. ExecWait 'net stop AGFILTSVC'
  4414. ExecWait '$UninstallAlligateFolder\AGFiltSvc.exe /uninstall'
  4415. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "FilterEXE" ""
  4416. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "DropDir" "\Spool"
  4417. goto doneResolvingAlligateDeliverySetting
  4418. ${Case} "SNF4Aligate"
  4419. ExecWait 'net stop AGFILTSVC'
  4420. ExecWait '$UninstallAlligateFolder\AGFiltSvc.exe /uninstall'
  4421. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "FilterEXE" ""
  4422. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "DropDir" "Spool\"
  4423. goto doneResolvingAlligateDeliverySetting
  4424. ${Default}
  4425. ExecWait 'net stop AGFILTSVC' ; this will stop it and release the SNF4Alligate.exe file.
  4426. 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."
  4427. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "FilterEXE" "$AlligateDelivery_Setting."
  4428. ExecWait 'net start AGFILTSVC' ; this will stop it and reset the new filter target.
  4429. goto doneResolvingAlligateDeliverySetting
  4430. ${EndSwitch}
  4431. NoXMLFile:
  4432. ;something was wrong here.....
  4433. ; but if there isn't anything to go buy, then if the FiltEXE is pointing at us, then we clear it.
  4434. WriteRegStr HKLM "SOFTWARE\SolidOak\Alligate\Settings" "FilterEXE" ""
  4435. doneResolvingAlligateDeliverySetting:
  4436. SkipFilterExeAdustment:
  4437. DeleteRegKey HKLM SOFTWARE\SolidOak\Alligate\Settings\Addins\MsgSniffer\ProcessDirHint ; this holds the verbage for the Alligate Inteface clue.
  4438. DeleteRegKey HKLM SOFTWARE\SolidOak\Alligate\Settings\Addins\MsgSniffer\ProcessDir ; This flags the directory.
  4439. DeleteRegKey HKLM SOFTWARE\SolidOak\Alligate\Settings\Addins\MsgSniffer\ProcessDirLabel ; This is "Sniffer"
  4440. ; In either case we need to remove isSNF4AlligateInstalled,SNF4AlligateInstallFolder,SNFMailServer_DIR from the MessageSniffer registry key.
  4441. ; and
  4442. DeleteRegKey HKLM HKEY_LOCAL_MACHINE\SOFTWARE\MessageSniffer\isSNF4AlligateInstalled
  4443. DeleteRegKey HKLM HKEY_LOCAL_MACHINE\SOFTWARE\MessageSniffer\SNF4AlligateInstallFolder
  4444. DeleteRegKey HKLM HKEY_LOCAL_MACHINE\SOFTWARE\MessageSniffer\SNFMailServer_DIR
  4445. ifFileExists "$UninstallAlligateFolder\SNF4Alligate.xml" 0 +2
  4446. Delete "$UninstallAlligateFolder\SNF4Alligate.xml"
  4447. ifFileExists "$UninstallAlligateFolder\SNF4Alligate.exe" 0 +2
  4448. Delete "$UninstallAlligateFolder\SNF4Alligate.exe"
  4449. ExecWait "net stop AgSMTPSvc" ; Now bounce the Alligate SMTP Server.
  4450. ExecWait "net start AgSMTPSvc"
  4451. NoAlligateHere:
  4452. ######################################################################### END Alligate UNINSTALL SECTION ############################################
  4453. return
  4454. FunctionEnd
  4455. Section "Uninstall"
  4456. ; Now we have two situations. The first is that this Uninstaller was called legitimately, in which case, this file
  4457. ; will be being run from the existing Message Sniffer install directory.
  4458. ; and $EXEDIR will be that directory..... or $EXEDIR will be in a directory inside the SnifferArchive directory, and be
  4459. ; an illigitimate version running..... SOLVED THIS BY CHANGING THE FILE EXTENSION to bck.. and then back to exe when its appropriate.
  4460. ; So read the registry key:
  4461. Call un.stopSNFServer
  4462. Call un.UninstallXYNTService
  4463. Var /GLOBAL localFileDirectory
  4464. Var /GLOBAL uninstallRollbackPath
  4465. Var /GLOBAL uninstallRollbackLogName
  4466. Call un.removeShortcuts ; if your uninstalling, then you're taking the installers work out. Shortcuts will always go away.
  4467. ; only manual installs might be left behind. Manual installs don't have shortcuts.
  4468. ReadRegStr $localFileDirectory HKLM "Software\MessageSniffer" "Install_Dir"
  4469. ReadRegStr $uninstallRollbackPath HKLM "Software\MessageSniffer" "SRS_RollbackPath"
  4470. ReadRegStr $uninstallRollbackLogName HKLM "Software\MessageSniffer" "SRS_LogName"
  4471. ReadRegStr $SNFServerInstallDir HKLM "Software\MessageSniffer" "SNFMailServer_DIR"
  4472. ## 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
  4473. ## Files it inserted.
  4474. ${un.GetParent} $localFileDirectory $SNFServerInstallDir
  4475. #######################################################################################################################################
  4476. ## We're un-installing. Therefore if there is an existing rollback file, run it.
  4477. #######################################################################################################################################
  4478. StrCmp $uninstallRollbackPath "" NoPreRoll 0
  4479. StrCmp $uninstallRollbackLogName "" NoPreRoll 0
  4480. StrCmp $uninstallRollbackPath "$SNFServerInstallDir\SNFRollBack" 0 NoPreRoll ; Only roll this back if its the same folder as the source. i.e. Don't rollback an
  4481. ; Imail install ontop of a smartermail install.
  4482. ${un.RollBackTo} $uninstallRollbackPath $uninstallRollbackLogName ; Put all the files back the way they were.
  4483. # Do we end here?
  4484. NoPreRoll:
  4485. ######################################################################### MINIMI UNINSTALL SECTION ############################################
  4486. ; 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
  4487. ; the MINIMI xml config file.
  4488. Var /GLOBAL UninstallMINIMIFolder ; holds if and where MINIMI was installed.
  4489. Var /GLOBAL Delivery_Setting
  4490. Var /GLOBAL Current_Send_setting ; current IMAIL send target for the mail delivery.
  4491. Var /GLOBAL Current_UninstallTopDir ; Imail top directory
  4492. ReadRegStr $0 HKLM "Software\MessageSniffer" "isMINIMIInstalled"
  4493. StrCmp $0 "1" 0 ContinueWithRollback ; if it is, then drop in and handle the tests.....
  4494. ReadRegStr $UninstallMINIMIFolder HKLM "Software\MessageSniffer" "MINIMIInstallFolder" ; read the install folder for MINIMI.
  4495. # EXPLANATION: MINIMI might have been made irrelevant, so we first need to test if it was being used before we roll it back.
  4496. # then if this MINIMI was being used, but we'rerolling back to the OLD minimi version, then we're going to
  4497. # put the OLD MINIMI's target back as IMAILs send name target. If there is no OLD_SNIFIMailShim.xml, that means
  4498. # that the rollback is deleteing MINIMI and we should put the current MINIMI's target back as Imails sendName Target....
  4499. # Make sense? Good. All bets are off, if current MINIMI is not tied into IMAIL.
  4500. # Test for current xml file. Test for Imail's SendName and TopDir
  4501. ifFileExists "$UninstallMINIMIFolder\SNFIMailShim.xml" 0 ContinueWithRollback ; if we find the xml file, then we need to do checking...
  4502. ; if this file exists, then MINIMI was installed at some point. Check to see what IMAIL is pointing at:
  4503. ReadRegStr $Current_Send_setting HKLM "SOFTWARE\Ipswitch\IMail\Global" "SendName" ; this is what it was calling....
  4504. ReadRegStr $Current_UninstallTopDir HKLM "SOFTWARE\Ipswitch\IMail\Global" "TopDir" ; this is where MINIMI would be installed.
  4505. StrCmp "$Current_UninstallTopDir\SNFIMailShim.exe" $Current_Send_setting 0 IgnoreSendNameRollback
  4506. ## Dropping into here means that the IMAIL target is the same as the MINIMI executable.
  4507. ## So we're rolling back. Test to see if there is an OLD_SNIFI.xml file, or not.
  4508. ifFileExists "$UninstallMINIMIFolder\OLD_SNFIMailShim.xml" 0 ResetImail_WithCurrentMINIMIVALUE ; if we find the xml file, then we need to do checking...
  4509. ## IF this is valid, then we read from OLD....
  4510. ${un.GetBetween} "<delivery program='" "'/>$\r$\n" "$UninstallMINIMIFolder\OLD_SNFIMailShim.xml" "$Delivery_Setting"
  4511. Goto ResetImail
  4512. ResetImail_WithCurrentMINIMIVALUE:
  4513. ## IF THIS gets executed it means there was no OLD but we're still removing MINIMI from the chain....
  4514. ${un.GetBetween} "<delivery program='" "'/>$\r$\n" "$UninstallMINIMIFolder\SNFIMailShim.xml" "$Delivery_Setting"
  4515. Goto ResetImail
  4516. ResetImail:
  4517. ## Finally, reset the Imail setting to the target of MINIMI and take it out of the chain.
  4518. ClearErrors
  4519. WriteRegStr HKLM "SOFTWARE\Ipswitch\IMail\Global" "SendName" "$Delivery_Setting"
  4520. iferrors 0 IgnoreSendNameRollback
  4521. 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."
  4522. IgnoreSendNameRollback:
  4523. # Not changing the target for Imail, but we're rolling back MINIMI's files.... ( theoretically, somethings pointing at it???? )
  4524. # Test for xml file. Test for Imail's SendName and TopDir
  4525. ifFileExists "$UninstallMINIMIFolder\OLD_SNFIMailShim.xml" 0 ContinueWithRollback ; if we find the xml file, then we need to do checking...
  4526. ifFileExists "$UninstallMINIMIFolder\SNFIMailShim.xml" 0 +2
  4527. Delete "$UninstallMINIMIFolder\SNFIMailShim.xml"
  4528. CopyFiles /SILENT "$UninstallMINIMIFolder\OLD_SNFIMailShim.xml" "$UninstallMINIMIFolder\SNFIMailShim.xml"
  4529. ifFileExists "$UninstallMINIMIFolder\OLD_SNFIMailShim.exe" 0 ContinueWithRollback ; if we find the xml file, then we need to do checking...
  4530. ifFileExists "$UninstallMINIMIFolder\SNFIMailShim.exe" 0 +2
  4531. Delete "$UninstallMINIMIFolder\SNFIMailShim.exe"
  4532. CopyFiles /SILENT "$UninstallMINIMIFolder\OLD_SNFIMailShim.exe" "$UninstallMINIMIFolder\SNFIMailShim.exe"
  4533. ContinueWithRollback:
  4534. ######################################################################### END MINIMI UNINSTALL SECTION ############################################
  4535. ######################################################################### Alligate UNINSTALL SECTION
  4536. Call un.RemoveSNF4Alligate ; remove SNF4Alligate if its installed.
  4537. ######################################################################### IceWarp UNINSTALL SECTION
  4538. ifFileExists "$SNFServerInstallDir\config\content.xml" 0 +2
  4539. Call un.editContentXML ; remove IceWarp if its installed.
  4540. ######################################################################### IceWarp UNINSTALL SECTION
  4541. ; Don't need this here cause it gets called on the Rollback. Twice will remove the rolled back references if there were any.
  4542. ; ifFileExists "$SNFServerInstallDir\App\Plugins.dat" 0 +2
  4543. ; Call un.editMDPluginsFile ; remove MDaemon SNF Call if its installed.
  4544. ## IF there is no SNFClient.exe there should be no uninstaller.exe or anything else.
  4545. ifFileExists "$localFileDirectory\SNFClient.exe" LeaveNow 0 ; otherwise cleanup.
  4546. ifFileExists "$localFileDirectory\Restorer.exe" 0 +2
  4547. Delete "$localFileDirectory\Restorer.exe"
  4548. ifFileExists "$localFileDirectory\oldsnifferversion.txt" 0 +2
  4549. Delete "$localFileDirectory\oldsnifferversion.txt"
  4550. ifFileExists "$localFileDirectory\getRulebase.cmd.old" 0 +2
  4551. Delete "$localFileDirectory\getRulebase.cmd.old"
  4552. ifFileExists "$localFileDirectory\shortcuts.xml" 0 +2
  4553. Delete "$localFileDirectory\shortcuts.xml" ; if exists ; Find other location
  4554. ifFileExists "$localFileDirectory\cfgstring.xml" 0 +2
  4555. Delete "$localFileDirectory\cfgstring.xml" ; if exists ; Find other location
  4556. ifFileExists "$localFileDirectory\XYNTService.ini" 0 +2
  4557. Delete "$localFileDirectory\XYNTService.ini"
  4558. ifFileExists "$localFileDirectory\LocalRoot.txt" 0 +2
  4559. Delete "$localFileDirectory\LocalRoot.txt"
  4560. ifFileExists "$localFileDirectory\SNFServer${SNIFFER_SERVER_SPECIFIER}.exe" 0 +2
  4561. Delete "$localFileDirectory\SNFServer${SNIFFER_SERVER_SPECIFIER}.exe"
  4562. ifFileExists "$localFileDirectory\UpdateReady.txt" 0 +2
  4563. Delete "$localFileDirectory\UpdateReady.txt"
  4564. ifFileExists "$localFileDirectory\mingwm10.dll" 0 +2
  4565. Delete "$localFileDirectory\mingwm10.dll"
  4566. Delete "$localFileDirectory\uninstall.exe"
  4567. ifFileExists "$localFileDirectory\snfmdplugin.xml" 0 +2
  4568. Delete "$localFileDirectory\snfmdplugin.xml"
  4569. ifFileExists "$localFileDirectory\snfmdplugin.dll" 0 +2
  4570. Delete "$localFileDirectory\snfmdplugin.dll"
  4571. ifFileExists "$localFileDirectory\Plugins.dat" 0 +2
  4572. Delete "$localFileDirectory\Plugins.dat"
  4573. ifFileExists "$SNFServerInstallDir\SpamAssassin\rules\snf-groups.cf" 0 +2
  4574. Delete "$SNFServerInstallDir\SpamAssassin\rules\snf-groups.cf"
  4575. LeaveNow:
  4576. ##################
  4577. ; Ok, lastly wipe all the registry keys because if the uninstaller has run, it isn't available anmore..
  4578. DeleteRegKey HKLM SOFTWARE\MessageSniffer
  4579. ifFileExists "$SNFServerInstallDir\SNFRollBack\*.*" 0 +2
  4580. RMDir /r "$SNFServerInstallDir\SNFRollBack"
  4581. Delete "$uninstallRollbackPath\$uninstallRollbackLogName"
  4582. ; Remove registry keys
  4583. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MessageSniffer"
  4584. ; don't delete the master RegKey Folder until the end. We might need to reference the archive path.
  4585. Return
  4586. ## END ROLLBACK
  4587. ########################################################### PRIME is 1 and No FULLUNNSTALLBLOCKER EXISTS ########################################
  4588. ## Massive chunk of uninstaller code was removed on Mar 02. Rollback should be handling all of these items. Need full test to confirm that.
  4589. SectionEnd
  4590. ;Function that calls a messagebox when installation finished correctly
  4591. Function .onInstSuccess
  4592. InitPluginsDir
  4593. SetOutPath "$PLUGINSDIR"
  4594. ; Modal banner sample: show
  4595. File "SuccessInstall.bmp"
  4596. newadvsplash::show 5000 100 500 0x04025C "$PLUGINSDIR\SuccessInstall.bmp" ;/NOCANCEL
  4597. Delete "$PLUGINSDIR\SuccessInstall.bmp"
  4598. FunctionEnd
  4599. ;Function that calls a messagebox when installation finished correctly
  4600. Function onRestoreSuccess
  4601. InitPluginsDir
  4602. SetOutPath "$PLUGINSDIR"
  4603. ; Modal banner sample: show
  4604. File "SuccessRestore.bmp"
  4605. newadvsplash::show 5000 100 500 0x04025C "$PLUGINSDIR\SuccessRestore.bmp" ; /NOCANCEL
  4606. Delete "$PLUGINSDIR\SuccessRestore.bmp"
  4607. FunctionEnd
  4608. Function un.onUninstSuccess
  4609. SetOutPath $SNFServerInstallDir ; To release any holds on folders.
  4610. ; SetOutPath "C:"
  4611. ; ifFileExists "C:\MessageSniffer\StandAlone" 0 +2
  4612. ; RmDir /r "C:\MessageSniffer\StandAlone"
  4613. ; ifFileExists "C:\MessageSniffer\MXGuard" 0 +2
  4614. ; RmDir /r "C:\MessageSniffer\MXGuard"
  4615. ; ifFileExists "C:\MessageSniffer" 0 +2
  4616. ; RmDir /r "C:\MessageSniffer"
  4617. ;ifFileExists "$INSTDIR\*.*" 0 +2
  4618. ; RmDir /r $INSTDIR
  4619. ;ifFileExists "$SNFServerInstallDir\Sniffer" 0 +2
  4620. ; RmDir /r "$SNFServerInstallDir\Sniffer"
  4621. ; And if the user said to delete ALL of the Archive folders, then we kill them all.
  4622. ;StrCmp $DeleteArchives "1" 0 SkippingDeleteOfArchives
  4623. ; Delete "$SNFServerInstallDir\SNFRollback\*.*"
  4624. ; RmDir /r "$SNFServerInstallDir\SNFRollback"
  4625. ;SkippingDeleteOfArchives:
  4626. ;MessageBox MB_OK "You have successfully uninstalled Message Sniffer."
  4627. InitPluginsDir
  4628. SetOutPath "$PLUGINSDIR"
  4629. ; Modal banner sample: show
  4630. File "SuccessUnInstall.bmp"
  4631. newadvsplash::show 5000 100 500 0x04025C /NOCANCEL "$PLUGINSDIR\SuccessUnInstall.bmp"
  4632. Delete "$PLUGINSDIR\SuccessUnInstall.bmp"
  4633. 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"
  4634. ;call un.restartMDaemon
  4635. FunctionEnd