oneocr / _archive /attempts /frida_loader.py
OneOCR Dev
OneOCR - reverse engineering complete, ONNX pipeline 53% match rate
ce847d4
import ctypes
from ctypes import c_int64, c_char_p, POINTER, byref
import time
import sys
import os
DLL_DIR = r"c:\Users\MattyMroz\Desktop\PROJECTS\ONEOCR\ocr_data"
MODEL_PATH = os.path.join(DLL_DIR, "oneocr.onemodel")
KEY = b'kj)TGtrK>f]b[Piow.gU+nC@s""""""4'
# Load DLLs
kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)
kernel32.SetDllDirectoryW(DLL_DIR)
dll = ctypes.WinDLL(os.path.join(DLL_DIR, "oneocr.dll"))
# Setup function types
dll.CreateOcrInitOptions.argtypes = [POINTER(c_int64)]
dll.CreateOcrInitOptions.restype = c_int64
dll.OcrInitOptionsSetUseModelDelayLoad.argtypes = [c_int64, ctypes.c_char]
dll.OcrInitOptionsSetUseModelDelayLoad.restype = c_int64
dll.CreateOcrPipeline.argtypes = [c_char_p, c_char_p, c_int64, POINTER(c_int64)]
dll.CreateOcrPipeline.restype = c_int64
# Create init options
init_options = c_int64()
ret = dll.CreateOcrInitOptions(byref(init_options))
print(f"LOADER: CreateOcrInitOptions -> {ret}", flush=True)
assert ret == 0
ret = dll.OcrInitOptionsSetUseModelDelayLoad(init_options, 0)
print(f"LOADER: SetUseModelDelayLoad -> {ret}", flush=True)
assert ret == 0
# Create pipeline (this triggers decryption!)
pipeline = c_int64()
model_buf = ctypes.create_string_buffer(MODEL_PATH.encode())
key_buf = ctypes.create_string_buffer(KEY)
print("LOADER: Creating OCR pipeline (triggers decryption)...", flush=True)
ret = dll.CreateOcrPipeline(model_buf, key_buf, init_options, byref(pipeline))
print(f"LOADER: CreateOcrPipeline returned {ret}, pipeline={pipeline.value}", flush=True)
if ret != 0:
print(f"LOADER: ERROR - return code {ret}", flush=True)
sys.exit(1)
print("LOADER: Pipeline created successfully! Waiting...", flush=True)
time.sleep(5)
print("LOADER: Done.", flush=True)