Вы находитесь на странице: 1из 7

AccessingMSVBVM60APIfromVBIDE. I'mwritingthismoreasaninformativethingthanarealusefultechnique.I'mgonnatrytoexplainhow topatch/modvbfilesinordertohaveaccesstoanyAPIexportedbyMSVBVM60withoutdeclaringor addinganythingelsetoyourproject. ThetoolsI'mgoingtobeusingtodothisare: 1PEExplorer PEExploreristhemostfeaturepackedprogramforinspectingtheinnerworkingsofyourown software,andmoreimportantly,thirdpartyWindowsapplicationsandlibrariesforwhichyoudonot havesourcecode. Link:http://www.heaventools.com/ 2TypeLibraryEditor ThePowerVBTypeLibraryEditorcontrolisusedinallofthetypelibraryeditingtoolsprovidedwith AdvancedVisualBasic6:PowerTechniquesforEverydayPrograms.Editingelementsinatypelibrary isessentiallythesameregardlessoftheexe/addinthatthecontrolishostedin.

Theeditingoperations fallintotwocategories,thosedonebyeditingfieldsintherighthandsideofthecontrol,and commandsexecutedfromthecontextmenuinthetreecontrol.Thisdocumentexplainsthecontext menucommandsforeachtypeofselection. Link:http://www.powervb.com/ Letsstartwiththis.ThefirstthingwehavetodoisfindMSVBVM60.dll(locatedinthesytem32 folder)andseewhatfunctionsexports.TodothisopenPEExplorer,File>Open>navigatetothe system32folderandselectMSVBVM60.dll,oncewehavethefileopenwegotoview>exportor Ctrl+E. Youshouldseealistwithalltheexportedfunctionsantheirordinals.Someofthisfunctionsare commonlyusedinvbandwelldocumented,butmostofthemareamystery.YoucanGoogleforinfo aboutthem.

Letssavethisinfoforfutureuse.Clickonsavesyntaxdetails,navigatetoyourdesktopandcreatea foldercalledMSVBVM_Testandsavethetextfilethere.NowwecanclosePEExp. BeforestartmoddingourVB,IhighlyrecommendtoinstalltheSP6becauseifyouinstallthispatch lateritwilloverwriteallourwork. Timetostartdoingfunnystuff.FirstnavigatetoyouVBfolder,findafilecalledVBA6.DLLandmake abackupofit,justincasesomethinggoeswrongorwewanttorestoreourVB. Letsstartwithasimplechange,closeallVBinstancesthatmightberunning,nowopenTypeLibrary Editor,File>Open>navigatetotheVBfolderandselectVBA6.DLL. Youshouldseesomethinglikethis

NowletssavetheTLBinthefolderwecreatedpreviouslyinthedesktopMSVBVM_Testnamethe fileVBA6.tlb. Forthefirstmodwegonnadosomethingsimpleinordertounderstandhowitworks.Wegonnaadda newconstanttoVBcalledvbQuotethisnewconstantwillrepresenta,inthatwaywecanuse vbQuoteinsteadofchr$(34)or.

GotothelefthadsidetreeviewandfindamodulecalledConstants,Expandthatmoduleandyouwill seeabunchofknownVBconstants(vbBack,vbCr,etc).RightClickontheconstantmoduleandclick AddConstantthiswilladdanewconstantcalledConstant1. NowselectthatconstantRightClick>RenameandtypevbQuote.Ontherightpanelchooseconstant typeLPSTRandintheConstantValuefieldtype,clickupdateandsavethefile.

Itshouldlooklikethis

IstimetoupdatetheVBA6.DLLfiletoreflectthechanges.OpenPEExplorerFile>Open>naviagteto theVBfolderandselectVBA6.DLLnowopentheresourceview,View>ResourcesorCtrl+R

SelectthefirstTypeLibrary. ClickResourceEditor NavigatetotheTLBfilelocatedinthefolderwecreatedpreviouslyandreplacetheresourcewiththe newfile.ClosePEExplorerandrunyourVB,nowyoushouldhaveanewconstantavailable.

AddingnewAPIs. Thisprocedureisprettymuchsimilartothefirstonebut,thistimeinsteadofaddingaconstantwe gonnaaddanewAPI. FirstwegonnacreateanewmoduletostoreallyournewAPIs,rightclickonVBAAddType>Module ,renamethemoduletoMemory. RightclickonthemodulejustcreatedandAddFunction>Function. NowwegonnarenamethisnewfunctiontoGetByte,thisisgonnabeacalltoGetMem1exportedby MSVBVM60,InthispictureyoucanseeI'musingtheordinal#317(checkthetextwesavedatthe beginningwithalltheexportedfunctionstoverifythis)

Atthispointyoujustneedtosaveandrepeatthefirstprocessagain(replaceTLB),thisisself explanatory,butI'mpastingsomemorescreencapssoyoucanseeallthevalues.

Usingthistechniqueyoucanaddawholesetofmemoryfunctions,oranyotherapiyouwantfrom MSVBVM60. Well,IhopeyoufindthisusefuloratleastFUNNY! Havefunk!Cobein.

Вам также может понравиться