Advertisement
djvj

Untitled

Sep 18th, 2015
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.86 KB | None | 0 0
  1. MCRC=DF2A7C78
  2. MVersion=1.0.1
  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. } Else If SubStr(vdFileProductVersion,1,1) = 5
  37. { vdMode := "DT5"
  38. driveLetterCheck := 1
  39. supportedExtensions := "ape,b5t,b6t,bin,bwt,ccd,cdi,cue,flac,iso,isz,mds,mdx,nrg"
  40. } Else If SubStr(vdFileProductVersion,1,1) = 6 ; so far v6 is the Pro version of DT10 lite
  41. { vdMode := "DT6"
  42. driveLetterCheck := 1
  43. supportedExtensions := "ape,b5t,b6t,bwt,ccd,cdi,cue,flac,iscsi,iso,isz,mds,mdx,nrg,tc,vdh,vdi,vmdk,wav,zip"
  44. If (InStr(vdFileProductName,"Pro") && vdExe != "DTAgent.exe")
  45. ScriptError(vdFileProductName . " v" . vdFileProductVersion . " requires you to set your Virtual Drive Path to DTAgent.exe, not " . vdExe)
  46. } Else If SubStr(vdFileProductVersion,1,2) = 10
  47. { vdMode := "DT10"
  48. supportedExtensions := "ape,b5t,b6t,bwt,ccd,cdi,cue,flac,iscsi,iso,isz,mds,mdx,nrg,tc,vdh,vdi,vmdk,wav,zip"
  49. If (vdExe != "DTAgent.exe")
  50. ScriptError(vdFileProductName . " v" . vdFileProductVersion . " requires you to set your Virtual Drive Path to DTAgent.exe, not " . vdExe)
  51. } Else If SubStr(vdFileProductVersion,1,3) = 1.0
  52. ScriptError(vdFileProductName . " v" . vdFileProductVersion . " is a Virtual CloneDrive application. Please set RocketLauncherUI to use VCDMount.exe instead.")
  53. Else
  54. ScriptError("VirtualDrive - This version of " . vdFileProductName . " is untested and may not be supported correctly, please report this to the RocketLauncher Devs",3)
  55. }
  56. Else If InStr(vdFileProductName,"Alcohol")
  57. {
  58. vdMode := "Alcohol"
  59. driveLetterCheck := 1
  60. supportedExtensions := "b5t,b6t,bin,bwt,ccd,cdi,cue,iso,isz,mds,mdx,nrg,pdi"
  61. If (vdExe != "AxCmd.exe")
  62. 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.")
  63. deviceCount := RegRead("HKEY_CURRENT_USER", "Software\Alcohol Soft\Alcohol 120%\Basic", "Virtual Device Count") ; first check registered version 120% key
  64. If !deviceCount
  65. deviceCount := RegRead("HKEY_CURRENT_USER", "Software\Alcohol Soft\Alcohol 52%\Basic", "Virtual Device Count") ; check trial 52% key
  66. If deviceCount >= 1
  67. 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)
  68. Else
  69. ScriptError(vdMode . " has " . deviceCount . " virtual drives on your system. Please setup a virtual drive first in " . vdMode . " before using Virtual Drive support.")
  70. }
  71. Else If InStr(vdFileProductName,"VCDMount") ; Virtual CloneDrive settings stored in HKEY_CURRENT_USER\Software\Elaborate Bytes\VirtualCloneDrive
  72. {
  73. If SubStr(vdFileProductVersion,1,4) = "5, 4"
  74. { vdMode := "CloneDrive"
  75. supportedExtensions := "bin,ccd,cdi,dvd,img,iso,udf" ; cue is not supported!
  76. deviceCount := RegRead("HKEY_CURRENT_USER", "Software\Elaborate Bytes\VirtualCloneDrive", "NumberOfDrives")
  77. If !deviceCount {
  78. 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)
  79. Run("VCDPrefs.exe", vdPath)
  80. WinWait("Virtual CloneDrive ahk_class TMainForm")
  81. WinWaitActive("Virtual CloneDrive ahk_class TMainForm")
  82. ControlSend,TButton1, {Enter}, Virtual CloneDrive ahk_class TMainForm ; Ok button
  83. deviceCount := RegRead("HKEY_CURRENT_USER", "Software\Elaborate Bytes\VirtualCloneDrive", "NumberOfDrives")
  84. }
  85. If deviceCount > 1
  86. Log("VirtualDrive - " . vdMode . " has " . deviceCount . " virtual drives on your system. RocketLauncher will only use the first drive.",2)
  87. Else If deviceCount = 0
  88. { deviceCount = 1
  89. RegWrite("REG_DWORD", "HKEY_CURRENT_USER", "Software\Elaborate Bytes\VirtualCloneDrive", "NumberOfDrives", deviceCount)
  90. Log("VirtualDrive - " . vdMode . " had its device count changed from 0 to 1. You may now use it with RocketLauncher",2)
  91. } Else If !deviceCount
  92. ScriptError("There was a problem finding the device count for " . vdFileProductVersion . ". Make sure a virtual drive exists first.")
  93. }
  94. }
  95. Else If InStr(vdFileProductName,"Virtual CD")
  96. {
  97. If SubStr(vdFileProductVersion,1,2) = 10
  98. { vdMode := "VirtualCD"
  99. driveLetterCheck := 1
  100. supportedExtensions := "b5i,bin,bwi,c2d,img,iso,mdf,nrg,vc4,xmf"
  101. }
  102. }
  103. Else If (InStr(vdFileProductName,"PowerISO") || foundPIso := (vdFileProductName = "" && vdExe = "piso.exe"))
  104. {
  105. If foundPIso ; must set this because piso contains no info on details and this code will run again on the next VD call
  106. vdFileInfo := 1
  107. If (SubStr(vdFileProductVersion,1,1) = 6 || foundPIso)
  108. { vdMode := "PowerISO"
  109. vdFileProductName := "PowerISO" ; forcing this because piso.exe has no info on it
  110. driveLetterCheck := 1
  111. supportedExtensions := "ashdisc,b5i,bin,bwi,c2d,cdi,cif,cue,daa,fcd,gi,img,iso,lcd,mdf,mds,ncd,nrg,p01,pdi,pxi,vcd"
  112. vdExe := "piso.exe" ; remapping to this exe as this is the CLI exe
  113. CheckFile(vdPath . "\" . vdExe, "You have PowerISO.exe as your VD application but the CLI utility piso.exe could not be found: " . vdPath . "\" . vdExe)
  114. deviceCount := RegRead("HKEY_CURRENT_USER", "Software\PowerISO\SCDEmu", "DiskCount")
  115. driveLetters := RegRead("HKEY_CURRENT_USER", "Software\PowerISO\SCDEmu", "DriveLetter")
  116. If !driveLetters
  117. ScriptError("Could not find your PowerISO DriveLetters. It appears you have not rebooted since installing PowerISO, so please do that first.")
  118. If (deviceCount = 1) {
  119. vdDriveLetter := SubStr(driveLetters,1,1) ; forcing drive letter set in PowerISO's setting
  120. Log("VirtualDrive - Changing your VD Drive Letter to " . vdDriveLetter . " because you only have one drive active in " . vdMode . ".",4)
  121. } Else If deviceCount > 1
  122. Log("VirtualDrive - " . vdMode . " has " . deviceCount . " virtual drives on your system. Please make sure RocketLauncherUI is set to use the correct drive.",2)
  123. If !InStr(driveLetters,vdDriveLetter)
  124. 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.")
  125. }
  126. }
  127. Else If InStr(vdFileProductName,"MagicISO")
  128. {
  129. If SubStr(vdFileProductVersion,1,1) = 3
  130. { vdMode := "MagicDisc"
  131. driveLetterCheck := 1
  132. 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"
  133. } Else If SubStr(vdFileProductVersion,1,1) = 5
  134. ScriptError(vdFileProductName . " is the Maker application for MagicDisc. Point your Virtual Drive Path in RocketLauncherUI to ""miso.exe"" which is the command line utility.")
  135. Else
  136. ScriptError(vdFileProductName . " is an unknown and unsupported version of MagicISO. Only v3.x of miso.exe is supported.")
  137. }
  138. Else If InStr(vdFileProductName,"UltraISO") ; no apparent way to mount an image just through CLI on UltraISO...
  139. {
  140. ; If SubStr(vdFileProductVersion,1,2) = "V9"
  141. ; {
  142. vdMode := "UltraISO"
  143. 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"
  144. ScriptError(vdFileProductName . " is an unsupported virtual drive application as it doesn't support simple mounting via CLI. Please choose another application.")
  145. ; }
  146. }
  147. Else
  148. ScriptError(vdFileProductName . " is a Virtual Drive application not supported by RocketLauncher at this time")
  149. If (driveLetterCheck && !vdDriveLetter && vdDriveLetter !=0)
  150. 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.")
  151. If vdMode
  152. Log("VirtualDrive - All VirtualDrive calls will use mode " . vdMode,4)
  153. Else
  154. Log("VirtualDrive - There was an error starting VirtualDrive support",3)
  155. }
  156. If action not in get,mount,unmount
  157. ScriptError(action . " is an unsupported use of VirtualDrive. Only get, mount, and unmount actions are supported.")
  158.  
  159. ; Global VD checks
  160. If action = mount
  161. { If ext in %7zFormatsNoP%
  162. 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.")
  163. Else If ext not in %supportedExtensions%
  164. ScriptError("VirtualDrive was sent the extension """ . ext . """ which is not a supported file type for " . vdFileProductName . ".")
  165. If ext in cue,gdi
  166. { cueHasMp3s := RLObject.findCUETracksByExtension(file, "mp3") ; 0 = no mp3s, 1 = found mp3s, 2 = cant find cue, 3 = cue invalid. Multiple extensions can be | serparated
  167. If !cueHasMp3s {
  168. Log("VirtualDrive - This " . ext . " does not contain any mp3s.",4)
  169. If (ext = "cue") {
  170. validateCUE := RLObject.validateCUE(file) ; 0 = cue is invalid, 1 = cue is valid, 2 = cant find cue
  171. If validateCUE = 1
  172. Log("VirtualDrive - This " . ext . " was found valid.",4)
  173. Else {
  174. Log("VirtualDrive - validateCUE returned an error code of " . validateCUE,4)
  175. ScriptError("You have an invalid " . ext . " file. Please check it for errors.")
  176. }
  177. } Else If (ext = "gdi") {
  178. 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.
  179. DTAllowGDIQuotes := "true"
  180. Else If DTAllowGDIQuotes not in true,false
  181. ScriptError(DTAllowGDIQuotes . " is an invalid option for DTAllowGDIQuotes. It must either be true or false.")
  182. 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.
  183. If validateGDI = 1
  184. Log("VirtualDrive - This " . ext . " was found valid.",4)
  185. Else If !(validateGDI) {
  186. Log("VirtualDrive - validateGDI returned an error code of " . validateGDI,4)
  187. ScriptError("You have an invalid " . ext . " file. Please check it for errors.")
  188. } Else If (validateGDI = 3) {
  189. Log("VirtualDrive - validateGDI returned an error code of " . validateGDI,4)
  190. ScriptError("Invalid double quotes were found in " . ext . " file.")
  191. }
  192. }
  193. } Else If cueHasMp3s = 1
  194. 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.")
  195. Else If cueHasMp3s = 2
  196. ScriptError("There was a problem finding your " . ext . " file. Please check it exists at: " . file)
  197. Else If cueHasMp3s = 3
  198. ScriptError("You have an invalid " . ext . " file. Please check it for errors.")
  199. }
  200. }
  201.  
  202. ; Application-specific commands
  203. option :=
  204. If vdMode = DT4
  205. {
  206. vdFile := If file ? "`, """ . file . """" : ""
  207. type := If type ? type : (If vdUseSCSI = "true" ? "scsi" : "dt")
  208. If type not in dt,scsi
  209. ScriptError(type . " is an unsupported use of VirtualDrive. Only dt and scsi drives are supported.")
  210. If drive not in 0,1,2,3,4
  211. ScriptError(drive . " is an invalid virtual device number. Only 0 through 4 are supported.")
  212. If action != unmount
  213. { curErr := RunWait(vdExe . " -get_count " . type, vdPath) ; DT4 only. DT5 removes the drive when unmounted, so this will usually return 0
  214. If (curErr = 0 && vdAddDrive = "true"){
  215. Log("VirtualDrive - Did not find a " . type . " drive, creating one now. Please stand by as this can take a bit.",4)
  216. RunWait(vdFullPath . " -add " . type, vdPath) ; DT4 only. Not supported in DT5
  217. Sleep, 500
  218. }Else If curErr = 0
  219. 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.")
  220. If action = get
  221. { curErr := RunWait(vdExe . " -get_letter " . type . "`, " . drive, vdPath) ; DT4 only
  222. vdDriveLetter:=vdMap[curErr] ; we do not use the user's defined drive letter as it's done internally in the DT4 application
  223. If !curErr
  224. 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.")
  225. Log("VirtualDrive ended - Retrieved your " . type . " drive letter: " . vdDriveLetter,4)
  226. Return
  227. }
  228. }
  229. Log("VirtualDrive - Running your " . vdMode . " Virtual Drive with: " . vdFullPath . " -" . action . " " . type . ", " . drive . vdFile)
  230. vdCommand := "-" . action . " " . type . "`, " . drive . vdFile
  231. }
  232. Else If vdMode in DT5,DT10
  233. {
  234. If action = mount
  235. { type := If type ? type : (If vdUseSCSI = "true" ? "scsi" : "dt")
  236. If type not in dt,scsi
  237. ScriptError(type . " is an unsupported use of VirtualDrive. Only dt and scsi drives are supported.")
  238. vdCommand := "-mount " . type . ", " . vdDriveLetter . ", """ . file . """"
  239. } Else If action = unmount
  240. vdCommand := "-unmount " . vdDriveLetter
  241. Else If action = get
  242. Log("VirtualDrive - " . vdMode . " does not require the ""get"" action")
  243. }
  244. Else If vdMode in DT6
  245. {
  246. type := If type ? type : (If vdUseSCSI = "true" ? "scsi" : "dt")
  247. If type not in dt,scsi
  248. ScriptError(type . " is an unsupported use of VirtualDrive. Only dt and scsi drives are supported.")
  249. If action = mount
  250. vdCommand := "-mount " . type . ", " . vdDriveLetter . ", """ . file . """"
  251. Else If action = unmount
  252. vdCommand := "-unmount " . type . ", " . vdDriveLetter ; only the 0 or first drive is supported
  253. Else If action = get
  254. Log("VirtualDrive - " . vdMode . " does not require the ""get"" action")
  255. }
  256. Else If vdMode = CloneDrive
  257. {
  258. If action = mount
  259. vdCommand := "/d=0 """ . file . """"
  260. Else If action = unmount
  261. vdCommand := "/u"
  262. Else If action = get
  263. Log("VirtualDrive - " . vdMode . " does not require the ""get"" action")
  264. }
  265. Else If vdMode = VirtualCD
  266. {
  267. If action = mount
  268. vdCommand := "/i """ . file . """ " . vdDriveLetter . ":"
  269. Else If action = unmount
  270. vdCommand := "/e " . vdDriveLetter . ":"
  271. Else If action = get
  272. Log("VirtualDrive - " . vdMode . " does not require the ""get"" action")
  273. }
  274. Else If vdMode = PowerISO
  275. {
  276. option := "Hide"
  277. If action = mount
  278. vdCommand := "mount """ . file . """ " . vdDriveLetter . ":" ; PowerISO pops up a console window if not hidden
  279. Else If action = unmount
  280. vdCommand := "unmount " . vdDriveLetter . ":"
  281. Else If action = get
  282. Log("VirtualDrive - " . vdMode . " does not require the ""get"" action")
  283. }
  284. Else If vdMode = MagicISO
  285. {
  286. If action = mount
  287. vdCommand := "NULL -mnt 1 """ . file . """"
  288. Else If action = unmount
  289. vdCommand := "NULL -umnt 1 " . vdDriveLetter
  290. Else If action = get
  291. Log("VirtualDrive - " . vdMode . " does not require the ""get"" action")
  292. }
  293. Else If vdMode = Alcohol
  294. {
  295. If action = mount
  296. vdCommand := vdDriveLetter . ": /M:""" . file . """" ; mounts to drive 0 which is the first configured drive in Alcohol
  297. Else If action = unmount
  298. vdCommand := vdDriveLetter . ": /U"
  299. Else If action = get
  300. Log("VirtualDrive - " . vdMode . " does not require the ""get"" action")
  301. }
  302. Else
  303. 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.")
  304.  
  305. If action In mount,unmount
  306. { curErr := RunWait(vdExe . " " . vdCommand, vdPath, option)
  307. If curErr
  308. Log("VirtualDrive - Error reported by " . vdFileProductName . " during a " . action . " operation: " . curErr,2)
  309. }
  310. Log("VirtualDrive - Ended")
  311. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement