x64dbg / x64dbgpy

Automating x64dbg using Python, Snapshots:
https://ci.appveyor.com/project/mrexodia/x64dbg-python/build/artifacts
MIT License
1.47k stars 70 forks source link

Should append current script directory to sys.path for local importing #63

Open manfeel opened 3 years ago

manfeel commented 3 years ago

modify py.cpp

bool pyInit(PLUG_INITSTRUCT* initStruct) {
    // ...
    // Add 'plugins' (current directory) to sys.path
    GetCurrentDirectoryW(_countof(dir), dir);
    if(dir[wcslen(dir) - 1] != L'\\')
        wcsncat_s(dir, L"\\", _TRUNCATE);
    wcsncat_s(dir, token_paste(L, module_name), _TRUNCATE);
    GetShortPathNameW(dir, dir, _countof(dir));
    _plugin_logputs(Utf16ToUtf8(dir).c_str());
    PyList_Insert(PySys_GetObject("path"), 0, PyString_FromString(Utf16ToUtf8(dir).c_str()));
    // Append current script directory to sys.path for local importing
    PyList_Append(PySys_GetObject("path"), PyString_FromString("."));
}