# Import __init__.py from the standalone folder so we can have all the
# standalone / non-Calibre code in that subfolder.
-
-import standalone.__init__ as mdata
+try:
+ import standalone.__init__ as mdata
+ mn=mdata.main
+except:
+ from . import standalone
+ mdata=standalone.main
+ mn=mdata
import sys
-
-mdata.main(sys.argv)
\ No newline at end of file
+mn(sys.argv)
\ No newline at end of file
if b'ProtectedData' in data:
break # found DRM voucher
else:
- raise Exception("The .kfx-zip archive contains an encrypted DRMION file without a DRM voucher")
-
+ #raise Exception("The .kfx-zip archive contains an encrypted DRMION file without a DRM voucher")
+ print("The .kfx-zip archive contains an encrypted DRMION file without a DRM voucher. Just in case it is a rare decrypted KFX, we continue")
+ self.voucher = None
+ return
print("Decrypting KFX DRM voucher: {0}".format(info.filename))
for pid in [''] + totalpids:
global config_file_path
config_file_path = "dedrm.json"
-# Path to a Kindle voucher key file passed via --keyfile
-kfx_skeyfile = None
+# Path to a Kindle voucher key file passed via --keyfile now in remove_drm
def print_fname(f, info):
print(" " + f.ljust(15) + " " + info)
used_up = 0
global _additional_params
global config_file_path
-
- global kfx_skeyfile
-
if arg in ["--username", "--password", "--output", "--outputdir", "--keyfile"]:
used_up = 1
_additional_params.append(arg)
else:
val = next[0]
if arg == "--keyfile":
- kfx_skeyfile = val
+ _additional_params.append(val)
else:
_additional_params.append(val)
skip_opts = False
# First element is always the ZIP name, remove that.
- if not arguments[0].lower().endswith(".zip") and not "calibre" in sys.modules:
- print("Warning: File name does not end in .zip ...")
- print(arguments)
+ #if not arguments[0].lower().endswith(".zip") and not "calibre" in sys.modules:
+ # print("Warning: File name does not end in .zip ...")
+ # print(arguments)
arguments.pop(0)
while len(arguments) > 0:
arg = arguments.pop(0)
-
if arg == "--":
skip_opts = True
continue
-def dedrm_single_file(input_file, output_file):
+def dedrm_single_file(input_file, output_file,skeyfile=None):
# When this runs, all the stupid file handling is done.
# Just take the file at the absolute path "input_file"
# and export it, DRM-free, to "output_file".
if ftype == "KFX-ZIP":
from ..kfxdedrm import KFXZipBook
- from .__init__ import kfx_skeyfile
- keyfile = kfx_skeyfile
+ keyfile = skeyfile
+ print(f"Using keyfile {keyfile}")
temp_keyfile = None
try:
book = KFXZipBook(input_file, keyfile)
outputdir = None
force = False
overwrite_original = False
-
+ skeyfile=None
if len(files) == 0:
print_removedrm_help()
output = params.pop(0)
elif p == "--outputdir":
outputdir = params.pop(0)
+ elif p == "--keyfile":
+ skeyfile = params.pop(0)
elif p == "--force":
force = True
elif p == "--overwrite":
- dedrm_single_file(file, output_filename)
+ dedrm_single_file(file, output_filename,skeyfile)
}
-
int tryOpeningBook(KrfAccessFunctions* ctx, const std::string& serial, const std::string& secret, DrmParameters* params,KeyData* out)
{
keydataAccumulator.reset();
secrets.push_back(secret);
ctx->DrmDataProvider((void*)sub, serial, secrets, params->vouchers);
void* bookFactory = ctx->GetBookFactory();
- int rebook[2];
+ //int rebook[2] = { 0 };
+ std::shared_ptr<void*> rebook;
krfErr err;
err.code = 0;
- ctx->OpenBook(bookFactory, rebook, params->bookFile, sub, &err, params->resources);
+ ctx->OpenBook(bookFactory, &rebook, params->bookFile, sub, &err, params->resources);
std::cout << "BookOpen error " << err.code << " " << err.msg << std::endl;
if (err.code == 0)
{
out->aggregate( &keydataAccumulator);
//return true;
}
+ //std::cout << rebook[0]<< std::endl;
+ if (rebook != nullptr)
+ {
+ rebook.reset();
+ }
+
return err.code;
}
{
std::cout << "Usage: executable <memdump path> <kindle documents path> <output file>" << std::endl;
std::cout << "This program needs accress to Kindle dlls, so it is easiest to run it in the folder with kindle executable or copied dlls" << std::endl;
- std::cout << "Please ensure that KRFDynamic.dll is of the appropriate version (currently md5 22ccc712f186e3f03567e2bec2189d6a, kindle 2.7.1(70978)" << std::endl;
+ std::cout << "Please ensure that KRFDynamic.dll is of the appropriate version (currently md5 22ccc712f186e3f03567e2bec2189d6a, kindle 2.7.1(70978))" << std::endl;
return 1;
}
HINSTANCE hinstLib;
std::string dump_path = argv[1];
std::string folder_path = argv[2];
std::string out_path = argv[3];
+ std::cout << folder_path << std:: endl;
//this is a bit dumb but I don't know of good ways of flipping between char types
std::basic_string<TCHAR> wfolder_path = std::basic_string<wchar_t>(folder_path.begin(),folder_path.end());
if (hinstLib)
import threading
import sys
import signal
+import numbers
##copied out from ion.py and subtly modified
TID_NULL = 0
else:
if host=="local":
self._host=None
- self._device_type="local"
+ self._device_type=None#"local"
else:
self._host=host
self._device_type="remote"
- self._host=host
self._device_id=None
self._keepalive_interval=None
self._schedule_on_output = lambda pid, fd, data: self._reactor.schedule(lambda: self._on_output(pid, fd, data))
return
elif (self._host is not None) or (self._device_type == "remote"):
host = self._host
-
+ print("remote")
options = {}
if self._keepalive_interval is not None:
options["keepalive_interval"] = self._keepalive_interval