Permalink
Browse files

Implemented PGD and DLC (Drm) on-the-fly decryption: this avoids

creating temporary files under tmp and is also supporting the decryption
of very large EDAT files.
Fixed sceIoChstat: some operations always fail on windows.
  • Loading branch information...
gid15 committed Jul 28, 2015
1 parent 2550e23 commit e8ca352a90edeee73847f4108864933a8fd53aaf
@@ -16,7 +16,10 @@
*/
package jpcsp.HLE.VFS;
import org.apache.log4j.Logger;
import jpcsp.HLE.TPointer;
import jpcsp.util.Utilities;
/**
* Proxy all the IVirtualFile interface calls to another virtual file.
@@ -25,6 +28,7 @@
*
*/
public abstract class AbstractProxyVirtualFile implements IVirtualFile {
protected static Logger log = AbstractVirtualFileSystem.log;
protected IVirtualFile vFile;
protected AbstractProxyVirtualFile() {
@@ -48,6 +52,21 @@ public int ioRead(TPointer outputPointer, int outputLength) {
return vFile.ioRead(outputPointer, outputLength);
}
/*
* Perform the ioRead in PSP memory using the ioRead for a byte array.
*/
protected int ioReadBuf(TPointer outputPointer, int outputLength) {
if (outputLength <= 0) {
return 0;
}
byte[] outputBuffer = new byte[outputLength];
int readLength = ioRead(outputBuffer, 0, outputLength);
Utilities.writeBytes(outputPointer.getAddress(), readLength, outputBuffer, 0);
return readLength;
}
@Override
public int ioRead(byte[] outputBuffer, int outputOffset, int outputLength) {
return vFile.ioRead(outputBuffer, outputOffset, outputLength);
@@ -33,9 +33,18 @@
private int bufferIndex;
private int bufferLength;
protected BufferedVirtualFile() {
}
public BufferedVirtualFile(IVirtualFile vFile, int bufferSize) {
super(vFile);
setBufferedVirtualFile(vFile, bufferSize);
}
protected void setBufferedVirtualFile(IVirtualFile vFile, int bufferSize) {
setProxyVirtualFile(vFile);
buffer = new byte[bufferSize];
bufferIndex = 0;
bufferLength = 0;
}
private void copyFromBuffer(int outputAddr, int length) {
@@ -61,8 +70,10 @@ private void checkPopulateBuffer() {
return;
}
if (bufferLength > 0) {
bufferIndex = 0;
}
bufferLength = vFile.ioRead(buffer, 0, buffer.length);
bufferIndex = 0;
}
@Override
@@ -124,7 +135,6 @@ public long ioLseek(long offset) {
bufferLength = 0;
bufferIndex = 0;
if (offset > virtualFileOffset) {
checkPopulateBuffer();
bufferIndex = (int) (offset - virtualFileOffset);
}

This file was deleted.

Oops, something went wrong.
@@ -14,14 +14,12 @@
You should have received a copy of the GNU General Public License
along with Jpcsp. If not, see <http://www.gnu.org/licenses/>.
*/
package jpcsp.connector;
package jpcsp.HLE.VFS;
/**
* @author gid15
*
*/
public class Connector {
public static final String basePSPDirectory = "ms0:/tmp/";
public static final String jpcspConnectorName = "Jpcsp Connector 3xx";
public static final String commandFileName = "command.txt";
import jpcsp.filesystems.SeekableDataInput;
public class SeekableDataInputVirtualFile extends AbstractVirtualFile {
public SeekableDataInputVirtualFile(SeekableDataInput file) {
super(file);
}
}
@@ -20,7 +20,6 @@
public class VirtualFileSystemManager {
protected HashMap<String, IVirtualFileSystem> virtualFileSystems = new HashMap<String, IVirtualFileSystem>();
protected ITmpVirtualFileSystem tmpVfs;
public void register(String name, IVirtualFileSystem vfs) {
name = name.toLowerCase();
@@ -32,10 +31,6 @@ public void unregister(String name) {
virtualFileSystems.remove(name);
}
public void register(ITmpVirtualFileSystem tmpVfs) {
this.tmpVfs = tmpVfs;
}
public IVirtualFileSystem getVirtualFileSystem(String absoluteFileName, StringBuilder localFileName) {
int colon = absoluteFileName.indexOf(':');
if (colon < 0) {
@@ -55,10 +50,6 @@ public IVirtualFileSystem getVirtualFileSystem(String absoluteFileName, StringBu
return virtualFileSystems.get(name);
}
public ITmpVirtualFileSystem getTmpVirtualFileSystem() {
return tmpVfs;
}
/**
* Normalize the given local file name:
* - resolve ".." and "." special notation
@@ -0,0 +1,45 @@
/*
This file is part of jpcsp.
Jpcsp is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Jpcsp is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Jpcsp. If not, see <http://www.gnu.org/licenses/>.
*/
package jpcsp.HLE.VFS.crypto;
import jpcsp.HLE.VFS.IVirtualFile;
public class EDATVirtualFile extends PGDVirtualFile {
private static final int edatHeaderSize = 0x90;
public EDATVirtualFile(IVirtualFile pgdFile) {
super(null, pgdFile, edatHeaderSize);
}
@Override
protected boolean isHeaderValid(IVirtualFile pgdFile) {
byte[] header = new byte[edatHeaderSize];
int length = pgdFile.ioRead(header, 0, edatHeaderSize);
if (length != edatHeaderSize) {
return false;
}
if (header[0] != 0 || header[1] != 'P' || header[2] != 'S' || header[3] != 'P' || header[4] != 'E' || header[5] != 'D' || header[6] != 'A' || header[7] != 'T') {
// No "EDAT" found in the header,
log.warn("PSPEDAT header not found!");
return false;
}
return super.isHeaderValid(pgdFile);
}
}
Oops, something went wrong.

2 comments on commit e8ca352

@sum2012

This comment has been minimized.

Show comment
Hide comment
@sum2012
Contributor

sum2012 replied Jan 21, 2016

@sum2012

This comment has been minimized.

Show comment
Hide comment
@sum2012

sum2012 Jan 31, 2016

Contributor

Fixed in 2525f8e

Contributor

sum2012 replied Jan 31, 2016

Fixed in 2525f8e

Please sign in to comment.