summaryrefslogtreecommitdiffstats
path: root/DeDRM_plugin/mobidedrm.py
diff options
context:
space:
mode:
Diffstat (limited to 'DeDRM_plugin/mobidedrm.py')
-rwxr-xr-xDeDRM_plugin/mobidedrm.py41
1 files changed, 2 insertions, 39 deletions
diff --git a/DeDRM_plugin/mobidedrm.py b/DeDRM_plugin/mobidedrm.py
index 22cdb35..0374836 100755
--- a/DeDRM_plugin/mobidedrm.py
+++ b/DeDRM_plugin/mobidedrm.py
@@ -84,44 +84,7 @@ from alfcrypto import Pukall_Cipher
from utilities import SafeUnbuffered
-iswindows = sys.platform.startswith('win')
-isosx = sys.platform.startswith('darwin')
-
-def unicode_argv():
- if iswindows:
- # Uses shell32.GetCommandLineArgvW to get sys.argv as a list of Unicode
- # strings.
-
- # Versions 2.x of Python don't support Unicode in sys.argv on
- # Windows, with the underlying Windows API instead replacing multi-byte
- # characters with '?'.
-
-
- from ctypes import POINTER, byref, cdll, c_int, windll
- from ctypes.wintypes import LPCWSTR, LPWSTR
-
- GetCommandLineW = cdll.kernel32.GetCommandLineW
- GetCommandLineW.argtypes = []
- GetCommandLineW.restype = LPCWSTR
-
- CommandLineToArgvW = windll.shell32.CommandLineToArgvW
- CommandLineToArgvW.argtypes = [LPCWSTR, POINTER(c_int)]
- CommandLineToArgvW.restype = POINTER(LPWSTR)
-
- cmd = GetCommandLineW()
- argc = c_int(0)
- argv = CommandLineToArgvW(cmd, byref(argc))
- if argc.value > 0:
- # Remove Python executable and commands if present
- start = argc.value - len(sys.argv)
- return [argv[i] for i in
- range(start, argc.value)]
- # if we don't have any arguments at all, just pass back script name
- # this should never happen
- return ["mobidedrm.py"]
- else:
- argvencoding = sys.stdin.encoding or "utf-8"
- return [arg if (isinstance(arg, str) or isinstance(arg,unicode)) else str(arg, argvencoding) for arg in sys.argv]
+from argv_utils import unicode_argv
class DrmException(Exception):
@@ -481,7 +444,7 @@ def getUnencryptedBook(infile,pidlist):
def cli_main():
- argv=unicode_argv()
+ argv=unicode_argv("mobidedrm.py")
progname = os.path.basename(argv[0])
if len(argv)<3 or len(argv)>4:
print("MobiDeDrm v{0:s}.\nCopyright © 2008-2020 The Dark Reverser, Apprentice Harper et al.".format(__version__))