Advertisement
djvj

Untitled

Dec 27th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.48 KB | None | 0 0
  1. MCRC=8F7D76E
  2. MVersion=1.0.3
  3.  
  4. ; Action: Can be get (get's the drive letter associated to the chosen drive type), mount (mount a disc), unmount (unmount a disc)
  5. ; File: Full path to file you want to mount (only need to provide this when using action type "mount"
  6. ; Type: Leave blank to use auto mode or what the user has chosen in RLUI for that system. To force a specific drive type, send "dt" or "scsi" in the module
  7. ; Drive: A drive number for DT can be sent in the scenario a user has multiple dt or scsi drives and prefers to not use the first one (0). This is not used in any module to date.
  8.  
  9. VirtualDrive(action,file="",type="",drive=0){
  10. Log("VirtualDrive - Started - action is " . action)
  11. Global vdFullPath,vdUseSCSI,vdAddDrive,vdDriveLetter,7zFormatsNoP,RLObject,DTAllowGDIQuotes
  12. Static vdExe,vdPath,vdFileInfo,vdFileProductName,vdFileProductVersion,vdMode,supportedExtensions
  13. vdMap:=Object(0,"A",1,"B",2,"C",3,"D",4,"E",5,"F",6,"G",7,"H",8,"I",9,"J",10,"K",11,"L",12,"M",13,"N",14,"O",15,"P",16,"Q",17,"R",18,"S",19,"T",20,"U",21,"V",22,"W",23,"X",24,"Y",25,"Z")
  14. If file ; only log file when one is used
  15. Log("VirtualDrive - Received file: " . file,4)
  16. SplitPath, file,,,ext
  17.  
  18. ; First run only checks and determine user's chosen VD application
  19. If !vdFileInfo {
  20. SplitPath, vdFullPath,vdExe,vdPath
  21. CheckFile(vdFullPath, "Could not find " . vdFullPath . "`nPlease fix the Virtual Drive Path key in RocketLauncherUI to point to your preferred Virtual Drive application executable or turn off Virtual Drive support.")
  22. vdFileInfo := FileGetVersionInfo_AW(vdFullPath, "ProductName|ProductVersion", "|")
  23. Loop, Parse, vdFileInfo, |
  24. { If A_Index = 1
  25. vdFileProductName := RegExReplace(A_Loopfield,"ProductName\s*")
  26. Else
  27. vdFileProductVersion := RegExReplace(A_Loopfield,"ProductVersion\s*")
  28. }
  29. Log("VirtualDrive - Using " . vdFileProductName . " version " . vdFileProductVersion . " found at: " . vdFullPath,4)
  30.  
  31. If InStr(vdFileProductName,"Daemon")
  32. {
  33. If SubStr(vdFileProductVersion,1,1) = 4
  34. { vdMode := "DT4"
  35. supportedExtensions := "ape,b5t,b6t,bin,bwt,ccd,cdi,cue,flac,iso,isz,mds,mdx,nrg"
  36. If InStr(vdFileProductName,"Ultra") {
  37. vdMode := "DT5"
  38. Log("VirtualDrive - Detected Ultra version of Daemon Tools: """ . vdFileProductName . """. Switching to DT5 mode as Ultra uses the same commands as DT5.",4)
  39. }
  40. } Else If SubStr(vdFileProductVersion,1,1) = 5
  41. { vdMode := "DT5"
  42. driveLetterCheck := 1
  43. supportedExtensions := "ape,b5t,b6t,bin,bwt,ccd,cdi,cue,flac,iso,isz,mds,mdx,nrg"
  44. } Else If SubStr(vdFileProductVersion,1,1) = 6 ; so far v6 is the Pro version of DT10 lite
  45. { vdMode := "DT6"
  46. driveLetterCheck := 1
  47. supportedExtensions := "ape,b5t,b6t,bwt,ccd,cdi,cue,flac,iscsi,iso,isz,mds,mdx,nrg,tc,vdh,vdi,vmdk,wav,zip"
  48. If (InStr(vdFileProductName,"Pro") && vdExe != "DTAgent.exe")
  49. ScriptError(vdFileProductName . " v" . vdFileProductVersion . " requires you to set your Virtual Drive Path to DTAgent.exe, not " . vdExe)
  50. } Else If SubStr(vdFileProductVersion,1,2) = 10
  51. { vdMode := "DT10"
  52. supportedExtensions := "ape,b5t,b6t,bwt,ccd,cdi,cue,flac,iscsi,iso,isz,mds,mdx,nrg,tc,vdh,vdi,vmdk,wav,zip"
  53. If (vdExe != "DTAgent.exe")
  54. ScriptError(vdFileProductName . " v" . vdFileProductVersion . " requires you to set your Virtual Drive Path to DTAgent.exe, not " . vdExe)
  55. } Else If SubStr(vdFileProductVersion,1,3) = 1.0
  56. ScriptError(vdFileProductName . " v" . vdFileProductVersion . " is a Virtual CloneDrive application. Please set RocketLauncherUI to use VCDMount.exe instead.")
  57. Else
  58. ScriptError("VirtualDrive - This version of " . vdFileProductName . " is untested and may not be supported correctly, please report this to the RocketLauncher Devs",3)
  59. }
  60. Else If InStr(vdFileProductName,"Alcohol")
  61. {
  62. vdMode := "Alcohol"
  63. driveLetterCheck := 1
  64. supportedExtensions := "b5t,b6t,bin,bwt,ccd,cdi,cue,iso,isz,mds,mdx,nrg,pdi"
  65. If (vdExe != "AxCmd.exe")
  66. ScriptError(vdMode . " only works when using ""AxCmd.exe"" as the executable. """ . vdExe . """ will not work. Please set your Virtual Drive Path to point to AxCmd.exe instead.")
  67. deviceCount := RegRead("HKEY_CURRENT_USER", "Software\Alcohol Soft\Alcohol 120%\Basic", "Virtual Device Count") ; first check registered version 120% key
  68. If !deviceCount
  69. deviceCount := RegRead("HKEY_CURRENT_USER", "Software\Alcohol Soft\Alcohol 52%\Basic", "Virtual Device Count") ; check trial 52% key
  70. If deviceCount >= 1
  71. Log("VirtualDrive - " . vdMode . " has " . deviceCount . " virtual drives on your system. Virtual_Drive_Drive_Letter general setting in RocketLauncherUI must match the letter you want to use.",4)
  72. Else
  73. ScriptError(vdMode . " has " . deviceCount . " virtual drives on your system. Please setup a virtual drive first in " . vdMode . " before using Virtual Drive support.")
  74. }
  75. Else If InStr(vdFileProductName,"VCDMount") ; Virtual CloneDrive settings stored in HKEY_CURRENT_USER\Software\Elaborate Bytes\VirtualCloneDrive
  76. {
  77. If SubStr(vdFileProductVersion,1,1) = "5"
  78. { vdMode := "CloneDrive"
  79. supportedExtensions := "bin,ccd,cdi,dvd,img,iso,udf" ; cue is not supported!
  80. deviceCount := RegRead("HKEY_CURRENT_USER", "Software\Elaborate Bytes\VirtualCloneDrive", "NumberOfDrives")
  81. If !deviceCount {
  82. Log("VirtualDrive - Could not find a device count in the registry for " . vdMode . " which means it was not manually ran first. Running it automatically so it is generated.",2)
  83. Run("VCDPrefs.exe", vdPath)
  84. WinWait("Virtual CloneDrive ahk_class TMainForm")
  85. WinWaitActive("Virtual CloneDrive ahk_class TMainForm")
  86. ControlSend,TButton1, {Enter}, Virtual CloneDrive ahk_class TMainForm ; Ok button
  87. deviceCount := RegRead("HKEY_CURRENT_USER", "Software\Elaborate Bytes\VirtualCloneDrive", "NumberOfDrives")
  88. }
  89. If deviceCount > 1
  90. Log("VirtualDrive - " . vdMode . " has " . deviceCount . " virtual drives on your system. RocketLauncher will only use the first drive.",2)
  91. Else If deviceCount = 0
  92. { deviceCount = 1
  93. RegWrite("REG_DWORD", "HKEY_CURRENT_USER", "Software\Elaborate Bytes\VirtualCloneDrive", "NumberOfDrives", deviceCount)
  94. Log("VirtualDrive - " . vdMode . " had its device count changed from 0 to 1. You may now use it with RocketLauncher",2)
  95. } Else If !deviceCount
  96. ScriptError("There was a problem finding the device count for " . vdFileProductVersion . ". Make sure a virtual drive exists first.")
  97. }
  98. }
  99. Else If InStr(vdFileProductName,"Virtual CD")
  100. {
  101. If SubStr(vdFileProductVersion,1,2) = 10
  102. { vdMode := "VirtualCD"
  103. driveLetterCheck := 1
  104. supportedExtensions := "b5i,bin,bwi,c2d,img,iso,mdf,nrg,vc4,xmf"
  105. }
  106. }
  107. Else If (InStr(vdFileProductName,"PowerISO") || foundPIso := (vdFileProductName = "" && vdExe = "piso.exe"))
  108. {
  109. If foundPIso ; must set this because piso contains no info on details and this code will run again on the next VD call
  110. vdFileInfo := 1
  111. If (SubStr(vdFileProductVersion,1,1) = 6 || foundPIso)
  112. { vdMode := "PowerISO"
  113. vdFileProductName := "PowerISO" ; forcing this because piso.exe has no info on it
  114. driveLetterCheck := 1
  115. supportedExtensions := "ashdisc,b5i,bin,bwi,c2d,cdi,cif,cue,daa,fcd,gi,img,iso,lcd,mdf,mds,ncd,nrg,p01,pdi,pxi,vcd"
  116. vdExe := "piso.exe" ; remapping to this exe as this is the CLI exe
  117. CheckFile(vdPath . "\" . vdExe, "You have PowerISO.exe as your VD application but the CLI utility piso.exe could not be found: " . vdPath . "\" . vdExe)
  118. deviceCount := RegRead("HKEY_CURRENT_USER", "Software\PowerISO\SCDEmu", "DiskCount")
  119. driveLetters := RegRead("HKEY_CURRENT_USER", "Software\PowerISO\SCDEmu", "DriveLetter")
  120. If !driveLetters
  121. ScriptError("Could not find your PowerISO DriveLetters. It appears you have not rebooted since installing PowerISO, so please do that first.")
  122. If (deviceCount = 1) {
  123. vdDriveLetter := SubStr(driveLetters,1,1) ; forcing drive letter set in PowerISO's setting
  124. Log("VirtualDrive - Changing your VD Drive Letter to " . vdDriveLetter . " because you only have one drive active in " . vdMode . ".",4)
  125. } Else If deviceCount > 1
  126. Log("VirtualDrive - " . vdMode . " has " . deviceCount . " virtual drives on your system. Please make sure RocketLauncherUI is set to use the correct drive.",2)
  127. If !InStr(driveLetters,vdDriveLetter)
  128. ScriptError("Please set RocketLauncherUI to use the same drive letter that " . vdMode . " is set to. You can find this in General Settings, Third Party tabs, and under Virtual Drive.")
  129. }
  130. }
  131. Else If InStr(vdFileProductName,"MagicISO")
  132. {
  133. If SubStr(vdFileProductVersion,1,1) = 3
  134. { vdMode := "MagicDisc"
  135. driveLetterCheck := 1
  136. supportedExtensions := "000,bin,bwi,bwt,c2d,ccd,cdi,cif,dao,ima,img,iso,md1,mdf,mds,nrg,p01,pdi,tao,uif,vaporcd,vc4,vcd,vdi,xa"
  137. } Else If SubStr(vdFileProductVersion,1,1) = 5
  138. ScriptError(vdFileProductName . " is the Maker application for MagicDisc. Point your Virtual Drive Path in RocketLauncherUI to ""miso.exe"" which is the command line utility.")
  139. Else
  140. ScriptError(vdFileProductName . " is an unknown and unsupported version of MagicISO. Only v3.x of miso.exe is supported.")
  141. }
  142. Else If InStr(vdFileProductName,"UltraISO") ; no apparent way to mount an image just through CLI on UltraISO...
  143. {
  144. ; If SubStr(vdFileProductVersion,1,2) = "V9"
  145. ; {
  146. vdMode := "UltraISO"
  147. supportedExtensions := "000,ashdisc,b5i,b5t,b6i,b6t,bif,bin,bwi,bwt,c2d,ccd,cdi,cif,cue,daa,dao,dmg,dvd,fcd,flp,gcd,gi,hfs,ima,img,iso,isz,ixa,lcd,md1,mdf,mds,ncd,nrg,p01,p2i,pdi,pxi,rdf,rif,tao,timg,uif,vaporcd,vc4,vcd,vdi,xa,xmd,xmf"
  148. ScriptError(vdFileProductName . " is an unsupported virtual drive application as it doesn't support simple mounting via CLI. Please choose another application.")
  149. ; }
  150. }
  151. Else
  152. ScriptError(vdFileProductName . " is a Virtual Drive application not supported by RocketLauncher at this time")
  153. If (driveLetterCheck && !vdDriveLetter && vdDriveLetter !=0)
  154. ScriptError(vdFileProductName . " requires that you set the Virtual Drive Drive Letter setting in RocketLauncherUI to the letter or number of the virtual drive you want to use.")
  155. If vdMode
  156. Log("VirtualDrive - All VirtualDrive calls will use mode " . vdMode,4)
  157. Else
  158. Log("VirtualDrive - There was an error starting VirtualDrive support",3)
  159. }
  160. If action not in get,mount,unmount
  161. ScriptError(action . " is an unsupported use of VirtualDrive. Only get, mount, and unmount actions are supported.")
  162.  
  163. ; Global VD checks
  164. If action = mount
  165. { If ext in %7zFormatsNoP%
  166. ScriptError("VirtualDrive was sent an archive extension """ . ext . """ which is not a mountable file type. Turn on 7z support or uncompress this game in order to mount it.")
  167. Else If ext not in %supportedExtensions%
  168. ScriptError("VirtualDrive was sent the extension """ . ext . """ which is not a supported file type for " . vdFileProductName . ".")
  169. If ext in cue,gdi
  170. { cueHasMp3s := RLObject.findCUETracksByExtension(file, "mp3") ; 0 = no mp3s, 1 = found mp3s, 2 = cant find cue, 3 = cue invalid. Multiple extensions can be | serparated
  171. If !cueHasMp3s {
  172. Log("VirtualDrive - This " . ext . " does not contain any mp3s.",4)
  173. If (ext = "cue") {
  174. validateCUE := RLObject.validateCUE(file) ; 0 = cue is invalid, 1 = cue is valid, 2 = cant find cue
  175. If validateCUE = 1
  176. Log("VirtualDrive - This " . ext . " was found valid.",4)
  177. Else If !validateCUE
  178. Log("VirtualDrive - validateCUE returned an invalid error code. Please check the RocketLauncher.DLL.log for additional info.",3)
  179. Else { ; 2
  180. Log("VirtualDrive - validateCUE returned an error code of """ . validateCUE . """. Please check the RocketLauncher.DLL.log for additional info.",3)
  181. ScriptError("You have an invalid " . ext . " file. Please check it for errors. Please check the RocketLauncher.DLL.log for additional info.")
  182. }
  183. } Else If (ext = "gdi") {
  184. If !DTAllowGDIQuotes ; by default, gdi files can contain double quotes. If a module contains "DTAllowGDIQuotes = false" it will be sent to the dll to error if they exist anywhere in the gdi.
  185. DTAllowGDIQuotes := "true"
  186. Else If DTAllowGDIQuotes not in true,false
  187. ScriptError(DTAllowGDIQuotes . " is an invalid option for DTAllowGDIQuotes. It must either be true or false.")
  188. validateGDI := RLObject.validateGDI(file, DTAllowGDIQuotes) ; 0 = gdi is invalid, 1 = gsi is valid, 2 = cant find gdi, 3 = invalid double quotes were found. DTAllowGDIQuotes when true tells the dll that the GDI can have double quotes. False it cannot have quotes.
  189. If validateGDI = 1
  190. Log("VirtualDrive - This " . ext . " was found valid.",4)
  191. Else If !(validateGDI) {
  192. Log("VirtualDrive - validateGDI returned an error code of " . validateGDI,4)
  193. ScriptError("You have an invalid " . ext . " file. Please check it for errors.")
  194. } Else If (validateGDI = 3) {
  195. Log("VirtualDrive - validateGDI returned an error code of " . validateGDI,4)
  196. ScriptError("Invalid double quotes were found in " . ext . " file.")
  197. } Else
  198. ScriptError("Can't find GDI """ . file . """")
  199. }
  200. } Else If cueHasMp3s = 1
  201. ScriptError("Your " . ext . " file contains links to mp3 files which is not supported by Virtual Drives. Please download another version of this game without MP3s or turn off Virtual Drive support to use the emulator's built-in image handler if supported.")
  202. Else If cueHasMp3s = 2
  203. ScriptError("There was a problem finding your " . ext . " file. Please check it exists at: " . file)
  204. Else If cueHasMp3s = 3
  205. ScriptError("You have an invalid " . ext . " file. Please check it for errors.")
  206. }
  207. }
  208.  
  209. ; Application-specific commands
  210. option :=
  211. If vdMode = DT4
  212. {
  213. vdFile := If file ? "`, """ . file . """" : ""
  214. type := If type ? type : (If vdUseSCSI = "true" ? "scsi" : "dt")
  215. If type not in dt,scsi
  216. ScriptError(type . " is an unsupported use of VirtualDrive. Only dt and scsi drives are supported.")
  217. If drive not in 0,1,2,3,4
  218. ScriptError(drive . " is an invalid virtual device number. Only 0 through 4 are supported.")
  219. If action != unmount
  220. { curErr := RunWait(vdExe . " -get_count " . type, vdPath) ; DT4 only. DT5 removes the drive when unmounted, so this will usually return 0
  221. If (curErr = 0 && vdAddDrive = "true"){
  222. Log("VirtualDrive - Did not find a " . type . " drive, creating one now. Please stand by as this can take a bit.",4)
  223. RunWait(vdFullPath . " -add " . type, vdPath) ; DT4 only. Not supported in DT5
  224. Sleep, 500
  225. }Else If curErr = 0
  226. ScriptError("You are trying to mount to a " . type . " virtual drive, yet one does not exist. Add a SCSI drive manually or Enable the General Setting ""Add Drive"" in RocketLauncherUI.")
  227. If action = get
  228. { curErr := RunWait(vdExe . " -get_letter " . type . "`, " . drive, vdPath) ; DT4 only
  229. vdDriveLetter:=vdMap[curErr] ; we do not use the user's defined drive letter as it's done internally in the DT4 application
  230. If !curErr
  231. ScriptError("A error occured finding the drive letter associated to your " . type . " drive. Please make sure you are using the latest Daemon Tools Lite v4.")
  232. Log("VirtualDrive ended - Retrieved your " . type . " drive letter: " . vdDriveLetter,4)
  233. Return
  234. }
  235. }
  236. Log("VirtualDrive - Running your " . vdMode . " Virtual Drive with: " . vdFullPath . " -" . action . " " . type . ", " . drive . vdFile)
  237. vdCommand := "-" . action . " " . type . "`, " . drive . vdFile
  238. }
  239. Else If vdMode in DT5,DT10
  240. {
  241. If action = mount
  242. { type := If type ? type : (If vdUseSCSI = "true" ? "scsi" : "dt")
  243. If type not in dt,scsi
  244. ScriptError(type . " is an unsupported use of VirtualDrive. Only dt and scsi drives are supported.")
  245. vdCommand := "-mount " . type . ", " . vdDriveLetter . ", """ . file . """"
  246. } Else If action = unmount
  247. vdCommand := "-unmount " . vdDriveLetter
  248. Else If action = get
  249. Log("VirtualDrive - " . vdMode . " does not require the ""get"" action")
  250. }
  251. Else If vdMode in DT6
  252. {
  253. type := If type ? type : (If vdUseSCSI = "true" ? "scsi" : "dt")
  254. If type not in dt,scsi
  255. ScriptError(type . " is an unsupported use of VirtualDrive. Only dt and scsi drives are supported.")
  256. If action = mount
  257. vdCommand := "-mount " . type . ", " . vdDriveLetter . ", """ . file . """"
  258. Else If action = unmount
  259. vdCommand := "-unmount " . type . ", " . vdDriveLetter ; DT6 Pro requires a number, not a drive letter that designates what drive to use
  260. Else If action = get
  261. Log("VirtualDrive - " . vdMode . " does not require the ""get"" action")
  262. }
  263. Else If vdMode = CloneDrive
  264. {
  265. If action = mount
  266. vdCommand := "/d=0 """ . file . """"
  267. Else If action = unmount
  268. vdCommand := "/u"
  269. Else If action = get
  270. Log("VirtualDrive - " . vdMode . " does not require the ""get"" action")
  271. }
  272. Else If vdMode = VirtualCD
  273. {
  274. If action = mount
  275. vdCommand := "/i """ . file . """ " . vdDriveLetter . ":"
  276. Else If action = unmount
  277. vdCommand := "/e " . vdDriveLetter . ":"
  278. Else If action = get
  279. Log("VirtualDrive - " . vdMode . " does not require the ""get"" action")
  280. }
  281. Else If vdMode = PowerISO
  282. {
  283. option := "Hide"
  284. If action = mount
  285. vdCommand := "mount """ . file . """ " . vdDriveLetter . ":" ; PowerISO pops up a console window if not hidden
  286. Else If action = unmount
  287. vdCommand := "unmount " . vdDriveLetter . ":"
  288. Else If action = get
  289. Log("VirtualDrive - " . vdMode . " does not require the ""get"" action")
  290. }
  291. Else If vdMode = MagicISO
  292. {
  293. If action = mount
  294. vdCommand := "NULL -mnt 1 """ . file . """"
  295. Else If action = unmount
  296. vdCommand := "NULL -umnt 1 " . vdDriveLetter
  297. Else If action = get
  298. Log("VirtualDrive - " . vdMode . " does not require the ""get"" action")
  299. }
  300. Else If vdMode = Alcohol
  301. {
  302. If action = mount
  303. vdCommand := vdDriveLetter . ": /M:""" . file . """" ; mounts to drive 0 which is the first configured drive in Alcohol
  304. Else If action = unmount
  305. vdCommand := vdDriveLetter . ": /U"
  306. Else If action = get
  307. Log("VirtualDrive - " . vdMode . " does not require the ""get"" action")
  308. }
  309. Else
  310. ScriptError(vdFileProductName . " v" . vdFileProductVersion . " is not currently supported, please request this application to be supported or stick with Daemon Tools Lite 4 or 5, or Alcohol.")
  311.  
  312. If action In mount,unmount
  313. { curErr := RunWait(vdExe . " " . vdCommand, vdPath, option)
  314. If curErr
  315. Log("VirtualDrive - Error reported by " . vdFileProductName . " during a " . action . " operation: " . curErr,2)
  316. }
  317. Log("VirtualDrive - Ended")
  318. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement