- Mesaj
- 877
- Çözümler
- 21
- Beğeni
- 123
- Puan
- 559
- Ticaret Puanı
- 0
Cython kullanan dosyalarım var ve onu kaldırmak istedim, cython'u istemci kaynağından çıkardıktan ve system.py'yi düzenledikten sonra, "client traceback trace" hatası ve komut satırı hatası veriyor, bu hatayı düzeltmeme yardım eder misiniz?
@Whistle @Yeniceri @Trashy
@Whistle @Yeniceri @Trashy
system.py:
import sys
import imp
import marshal
import cStringIO
import __builtin__
import yWp8YWaB4m5N2glpnses as app
import dbg
# Debug Chat
def dbg_chat(message = ""):
chat_str = ""
try:
previous_file = "<unknown>"
previous_line = "<unknown>"
previous_function = "<unknown>"
import inspect
previous_entry = inspect.stack()[1]
if previous_entry:
previous_file = previous_entry[1]
previous_line = str(previous_entry[2])
previous_function = previous_entry[3]
chat_str = "[{}:{} <{}>] {}".format(previous_file, previous_line, previous_function, message)
except ImportError:
chat_str = "debug_chat: {}".format(message)
import chat
chat.AppendChat(3, chat_str)
__builtins__.dbg_chat = dbg_chat
# End
sys.path.append("stdlib")
lang_tab = [
"pl",
"de",
"ro",
"tr",
"en"
]
__builtin__.lang_tab = lang_tab
class TraceFile:
def write(self, msg):
dbg.Tracen(msg)
class TraceErrorFile:
def write(self, msg):
dbg.TraceError(msg)
dbg.RegisterExceptionString(msg)
class LogBoxFile:
def __init__(self):
self.stderrSave=sys.stderr
self.msg=""
def __del__(self):
self.restore()
def restore(self):
sys.stderr=self.stderrSave
def write(self, msg):
self.msg=self.msg + msg
def show(self):
dbg.LogBox(self.msg,"Error")
sys.stdout=TraceFile()
sys.stderr=TraceErrorFile()
# Import handling
import pack
# def GetVfsFile(filename):
# data = PackGet(filename)
# if data == None:
# raise IOError("No file or directory ({0})".format(filename))
# return data
# def OpenVfsFile(filename):
# return cStringIO.StringIO(GetVfsFile(filename))
class EterPackModuleLoader(object):
def __init__(self, filename, code, is_package):
self.filename = filename
self.code = code
self.is_package = is_package
def load_module(self, fullname):
mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
mod.__file__ = self.filename
mod.__loader__ = self
if self.is_package:
mod.__path__ = []
mod.__package__ = fullname
else:
mod.__package__ = fullname.rpartition('.')[0]
exec(self.code, mod.__dict__)
return mod
class EterPackModuleFinder(object):
def find_module(self, fullname, path=None):
if imp.is_builtin(fullname):
return None
path = fullname.replace('.', '/')
loader = self.__MakeLoader(path + ".py", False, False)
if loader:
dbg.Tracen("Found and loaded module {0}".format(fullname))
return loader
loader = self.__MakeLoader(path + ".pyc", True, False)
if loader:
dbg.Tracen("Found and loaded module {0}".format(fullname))
return loader
loader = self.__MakeLoader(path + "/__init__.py", False, True)
if loader:
dbg.Tracen("Found and loaded package {0}".format(fullname))
return loader
loader = self.__MakeLoader(path + "/__init__.pyc", True, True)
if loader:
dbg.Tracen("Found and loaded package {0}".format(fullname))
return loader
dbg.Tracen("Failed to find {0}".format(fullname))
return None
def __MakeLoader(self, filename, is_compiled, is_package):
try:
data = GetVfsFile(filename)
except IOError:
return None
if is_compiled:
if data[:4] != imp.get_magic():
raise ImportError("Bad magic")
code = marshal.loads(data[8:])
else:
code = compile(data, filename, "exec")
return EterPackModuleLoader(filename, code, is_package)
sys.meta_path.append(EterPackModuleFinder())
def execfile(fileName, dict=None):
data = GetVfsFile(fileName)
if fileName.endswith(".pyc") or fileName.endswith(".pyo"):
if data[:4] != imp.get_magic():
raise ImportError("Invalid magic")
code = marshal.loads(data[8:])
else:
code = compile(data, fileName, "exec")
exec code in dict
__builtin__.execfile = execfile
def RunMainScript(name):
import __main__
execfile(name, __main__.__dict__)
cmd_args = [arg.replace("'", "") for arg in __COMMAND_LINE__.split()]
if "offline" in cmd_args:
RunMainScript("interfaceModule.py")
elif "offscript" in cmd_args:
RunMainScript(cmd_args[1]+".py")
else:
import Prototype
userinterface.cpp:
#include "StdAfx.h"
#include "PythonApplication.h"
#include <detours/detours.h>
#include <Shellapi.h>
#include "resource.h"
#include "HWIDManager.h"
#ifdef CEF_BROWSER
#include "CefWebBrowser.h"
#else
#include "../CWebBrowser/CWebBrowser.h"
#endif
#include "../EterBase/lzo.h"
#include "../EterBase/error.h"
#include "../EterPack/EterPackManager.h"
#include "../EterLib/Util.h"
#include <tlhelp32.h>
#include <Psapi.h>
#include <ppl.h>
#ifdef _DEBUG
#include <crtdbg.h>
#endif
#include <cstdlib>
#include "PythonPlayerSettingsModule.h"
#include <fstream>
#ifdef ENABLE_VOICE_CHAT
#include "_portaudiomodule.h"
#endif
#pragma comment( lib, "detours.lib" )
#pragma comment( lib, "version.lib" )
#pragma comment( lib, "imagehlp.lib" )
#pragma comment( lib, "devil.lib" )
#pragma comment( lib, "mss32.lib" )
#pragma comment( lib, "imm32.lib" )
#pragma comment( lib, "dinput8.lib" )
#pragma comment( lib, "dxguid.lib" )
#pragma comment( lib, "ws2_32.lib" )
#pragma comment( lib, "strmiids.lib" )
#pragma comment( lib, "psapi.lib" )
#ifdef ENABLE_CRASHRPT
#pragma comment( lib, "crashrpt.lib")
#endif
#pragma comment( lib, "ddraw.lib" )
#pragma comment( lib, "dmoguids.lib" )
#ifdef ENABLE_FOX_FS
#pragma comment( lib, "_LibLz4.lib" )
#endif
#ifdef __ENABLE_NEW_OFFLINESHOP__
#pragma comment( lib, "shlwapi.lib" )
#endif
#ifdef ENABLE_DISCORD_RPC
//#pragma comment(lib, "EterDiscordLib.lib")
#endif
extern "C"
{
extern int _fltused;
volatile int _AVOID_FLOATING_POINT_LIBRARY_BUG = _fltused;
};
extern "C"
{
_declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
extern bool SetDefaultCodePage(DWORD codePage);
#ifdef BLOCK_WRITE_PROCESS_MEMORY
#include <windows.h>
#include <cstdint>
PVOID* find (const char* szFunc, HMODULE hModule)
{
if (!hModule)
{
hModule = GetModuleHandle (0);
}
PIMAGE_DOS_HEADER img_dos_headers = (PIMAGE_DOS_HEADER)hModule;
PIMAGE_NT_HEADERS img_nt_headers = (PIMAGE_NT_HEADERS) ((byte*)img_dos_headers + img_dos_headers->e_lfanew);
PIMAGE_IMPORT_DESCRIPTOR img_import_desc = (PIMAGE_IMPORT_DESCRIPTOR) ((byte*)img_dos_headers + img_nt_headers->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
if (img_dos_headers->e_magic != IMAGE_DOS_SIGNATURE)
{
printf ("e_magic dos sig\n");
}
for (IMAGE_IMPORT_DESCRIPTOR* iid = img_import_desc; iid->Name != 0; iid++)
{
for (int func_idx = 0; * (func_idx + (void**) (iid->FirstThunk + (size_t)hModule)) != nullptr; func_idx++)
{
char* mod_func_name = (char*) (* (func_idx + (size_t*) (iid->OriginalFirstThunk + (size_t)hModule)) + (size_t)hModule + 2);
const intptr_t nmod_func_name = (intptr_t)mod_func_name;
if (nmod_func_name >= 0)
{
if (!::strcmp (szFunc, mod_func_name))
{
return func_idx + (void**) (iid->FirstThunk + (size_t)hModule);
}
}
}
}
return 0;
}
std::uint32_t detour_ptr (const char* szFunc, PVOID newfunction, HMODULE module)
{
void**&& func_ptr = find (szFunc, module);
if (*func_ptr == newfunction || *func_ptr == nullptr)
{
return 0;
}
DWORD old_rights;
DWORD new_rights = PAGE_READWRITE;
VirtualProtect (func_ptr, sizeof (uintptr_t), new_rights, &old_rights);
uintptr_t ret = (uintptr_t) * func_ptr;
*func_ptr = newfunction;
VirtualProtect (func_ptr, sizeof (uintptr_t), old_rights, &new_rights);
return ret;
}
using WriteProcessMemoryFn = bool (__stdcall*) (HANDLE, LPVOID, LPCVOID, SIZE_T, SIZE_T*);
WriteProcessMemoryFn oWriteProcessMemory;
bool __stdcall hkWriteProcessMemory (HANDLE hProcess, LPVOID lpBaseAddress, LPCVOID lpBuffer, SIZE_T nSize, SIZE_T* lpNumberOfBytesWritten)
{
return oWriteProcessMemory (nullptr, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten);
}
#endif
#ifdef ENABLE_FOX_FS
std::vector<std::wstring> packFiles = {
L"pack/snower2",
L"pack/snower2p1",
L"pack/snower2p2",
L"pack/pack_bgm",
L"pack/pack_effects_etc",
L"pack/pack_guild",
L"pack/pack_icon",
L"pack/pack_item",
L"pack/pack_maps",
L"pack/pack_monster",
L"pack/pack_npc",
L"pack/pack_pc",
L"pack/pack_sound",
L"pack/pack_texture",
L"pack/pack_textureset",
L"pack/pack_zone_1",
L"pack/pack_zone_2",
L"pack/property",
L"pack/pack_terrain",
L"pack/root",
};
void PackUninitialize()
{
concurrency::parallel_for_each(packFiles.rbegin(), packFiles.rend(), [&](const std::wstring& packname) { CFileSystem::Instance().UnloadArchive(packname); });
}
bool PackInitialize(const char* c_pszFolder)
{
if (_access(c_pszFolder, 0) != 0)
{
return true;
}
CTextFileLoader::SetCacheMode();
CSoundData::SetPackMode();
concurrency::parallel_for_each(packFiles.rbegin(), packFiles.rend(), [&](const std::wstring& packname) { CFileSystem::Instance().LoadArchive(packname); });
return true;
}
#endif
void RegisterCommandLine( const char * lpCmdLine, PyObject * builtins )
{
const char* loginMark = "-cs";
const char* loginMark_NonEncode = "-ncs";
const char* seperator = " ";
std::string stCmdLine;
const int CmdSize = 3;
vector<std::string> stVec;
SplitLine(lpCmdLine, seperator, &stVec);
if (CmdSize == stVec.size() && stVec[0] == loginMark)
{
char buf[MAX_PATH];
base64_decode(stVec[2].c_str(), buf);
stVec[2] = buf;
string_join(seperator, stVec, &stCmdLine);
}
else if (CmdSize <= stVec.size() && stVec[0] == loginMark_NonEncode)
{
stVec[0] = loginMark;
string_join(" ", stVec, &stCmdLine);
}
else
{
stCmdLine = lpCmdLine;
}
std::string stWrappedCmdLine = "'" + stCmdLine + "'";
PyModule_AddStringConstant(builtins, "__COMMAND_LINE__", stWrappedCmdLine.c_str());
}
#ifndef ENABLE_FOX_FS
static const char* sc_apszPythonLibraryFilenames[] =
{
"UserDict.pyc",
"linecache.pyc",
"ntpath.pyc",
"os.pyc",
"site.pyc",
"stat.pyc",
"string.pyc",
"traceback.pyc",
"types.pyc",
"\n",
};
bool CheckPythonLibraryFilenames()
{
for (int i = 0; *sc_apszPythonLibraryFilenames[i] != '\n'; ++i)
{
std::string stFilename = "lib\\";
stFilename += sc_apszPythonLibraryFilenames[i];
if (_access(stFilename.c_str(), 0) != 0)
{
return false;
}
MoveFile(stFilename.c_str(), stFilename.c_str());
}
return true;
}
bool PackInitialize(const char* c_pszFolder)
{
std::string strFolder = c_pszFolder;
strFolder += "/";
std::string strIndex = strFolder + "Index";
std::ifstream kIndex(strIndex, std::ios_base::in);
if (!kIndex.good())
{
return false;
}
std::string strPack;
while (std::getline(kIndex, strPack))
{
std::string strFileName = strFolder + strPack;
CEterPackManager::Instance().RegisterPack(strFileName.c_str(), "");
}
CHAR strNameROOT[] = { 'p', 'r', 'o', 'p', 'e', 'r', 't', 'y', 0x0 };
std::string strRoot = strFolder + strNameROOT;
CEterPackManager::Instance().RegisterRootPack(strRoot.c_str());
CSoundData::SetPackMode();
return true;
}
#endif
bool RunMainScript(CPythonLauncher &pyLauncher, const char* lpCmdLine)
{
initpack();
initdbg();
initime();
initgrp();
initgrpImage();
initgrpText();
initwndMgr();
initapp();
initsystemSetting();
initchr();
initchrmgr();
initPlayerModule();
initItem();
initNonPlayer();
initTrade();
initChat();
initTextTail();
initnet();
initMiniMap();
initProfiler();
initEvent();
initeffect();
initfly();
initsnd();
initeventmgr();
initshop();
initskill();
initquest();
initBackground();
initMessenger();
initsafebox();
initguild();
initServerStateChecker();
initPlayerSettingsModule();
initWhisper();
#ifdef ENABLE_SWITCHBOT
initSwitchbot();
#endif
#ifdef ENABLE_CUBE_RENEWAL_WORLDARD
intcuberenewal();
#endif
#ifdef __ENABLE_NEW_OFFLINESHOP__
initofflineshop();
#endif
#ifdef __ENABLE_EMOTICON_SYSTEM__
initemoticon();
#endif
#ifdef ENABLE_NEW_MODULE_CONFIG
initcfg();
#endif
#ifdef ENABLE_NEW_PET_SYSTEM
initskillpet();
#endif
#ifdef ENABLE_SHOULDER_SASH_SYSTEM
initSash();
#endif
#ifdef ENABLE_ADMIN_MANAGER
initAdmin();
#endif
#ifdef ENABLE_RENDER_TARGET
initRenderTarget();
#endif
#ifdef ENABLE_INGAME_WIKI
initWiki();
#endif
#ifdef ENABLE_BIOLOG_SYSTEM
initBiologManager();
#endif
#ifdef ENABLE_VOICE_CHAT
init_portaudio();
#endif
PyObject* builtins = PyImport_ImportModule("__builtin__");
#ifdef NDEBUG
PyModule_AddIntConstant(builtins, "__DEBUG__", 0);
#else
PyModule_AddIntConstant(builtins, "__DEBUG__", 1);
#endif
if (!pyLauncher.RunFile("system.py"))
{
TraceError("RunMain Error");
return false;
}
}
std::string exec(const char* cmd)
{
FILE* pipe = _popen(cmd, "r");
if (!pipe) return "ERROR";
char buffer[128];
std::string result = "";
while (!feof(pipe))
{
if (fgets(buffer, 128, pipe) != NULL)
{
result += buffer;
}
}
_pclose(pipe);
return result;
}
int Setup(LPSTR lpCmdLine);
bool Main(HINSTANCE hInstance, LPSTR lpCmdLine)
{
#ifdef BLOCK_WRITE_PROCESS_MEMORY
oWriteProcessMemory = (WriteProcessMemoryFn)detour_ptr ("WriteProcessMemory", (PVOID)hkWriteProcessMemory, GetModuleHandleA ("Kernel32.dll"));
#endif
bool ret = false;
SetLogLevel(1);
ilInit();
if (!Setup(lpCmdLine))
{
return false;
}
#if defined( _DEBUG ) || defined(ENABLE_DEBUGGING)
OpenConsoleWindow();
OpenLogFile(true);
#endif
#ifdef NDEBUG
OpenLogFile(false);
#endif
static CLZO lzo;
#ifdef ENABLE_FOX_FS
static CFileSystem EterPackManager;
#else
static CEterPackManager EterPackManager;
#endif
#ifdef ENABLE_HWID
static HWIDMANAGER hwidManager;
#endif
if (!PackInitialize("pack"))
{
LogBox("Pack Initialization failed. Check log.txt file...");
return false;
}
std::unique_ptr<CPythonApplication> app = std::make_unique<CPythonApplication>();
#ifdef ENABLE_NEW_MODULE_CONFIG
static CPythonConfig m_pyConfig;
m_pyConfig.Initialize("lib/encodings/config.cfg");
#endif
app->Initialize(hInstance);
app->SetSecKey(2051998);
{
CPythonLauncher pyLauncher;
if (pyLauncher.Create("rb.python"))
{
ret = RunMainScript(pyLauncher, lpCmdLine);
}
app->Clear();
timeEndPeriod(1);
pyLauncher.Clear();
}
app->Destroy();
return ret;
}
struct ApplicationStringTable
{
HINSTANCE m_hInstance;
std::map<DWORD, std::string> m_kMap_dwID_stLocale;
} gs_kAppStrTable;
void ApplicationStringTable_Initialize(HINSTANCE hInstance)
{
gs_kAppStrTable.m_hInstance = hInstance;
}
const std::string& ApplicationStringTable_GetString(DWORD dwID, LPCSTR szKey)
{
char szBuffer[512];
char szIniFileName[256];
char szLocale[256];
::GetCurrentDirectory(sizeof(szIniFileName), szIniFileName);
if (szIniFileName[lstrlen(szIniFileName) - 1] != '\\')
{
strcat(szIniFileName, "\\");
}
strcpy(szLocale, LocaleService_GetLocalePath());
if (strnicmp(szLocale, "locale/", strlen("locale/")) == 0)
{
strcpy(szLocale, LocaleService_GetLocalePath() + strlen("locale/"));
}
::GetPrivateProfileString(szLocale, szKey, NULL, szBuffer, sizeof(szBuffer) - 1, szIniFileName);
if (szBuffer[0] == '\0')
{
LoadString(gs_kAppStrTable.m_hInstance, dwID, szBuffer, sizeof(szBuffer) - 1);
}
if (szBuffer[0] == '\0')
{
::GetPrivateProfileString("en", szKey, NULL, szBuffer, sizeof(szBuffer) - 1, szIniFileName);
}
if (szBuffer[0] == '\0')
{
strcpy(szBuffer, szKey);
}
std::string& rstLocale = gs_kAppStrTable.m_kMap_dwID_stLocale[dwID];
rstLocale = szBuffer;
return rstLocale;
}
const std::string& ApplicationStringTable_GetString(DWORD dwID)
{
char szBuffer[512];
LoadString(gs_kAppStrTable.m_hInstance, dwID, szBuffer, sizeof(szBuffer) - 1);
std::string& rstLocale = gs_kAppStrTable.m_kMap_dwID_stLocale[dwID];
rstLocale = szBuffer;
return rstLocale;
}
const char* ApplicationStringTable_GetStringz(DWORD dwID, LPCSTR szKey)
{
return ApplicationStringTable_GetString(dwID, szKey).c_str();
}
const char* ApplicationStringTable_GetStringz(DWORD dwID)
{
return ApplicationStringTable_GetString(dwID).c_str();
}
std::wstring encryptDecrypt(std::wstring toEncrypt)
{
wchar_t key[3] = { L'B', L'O', L'T' };
std::wstring output = toEncrypt;
for (int i = 0; i < toEncrypt.size(); i++)
{
output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(wchar_t))];
}
return output;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
#ifdef ENABLE_CRASHRPT
SetEterExceptionHandler();
#endif
if ( IsInsideVMWare() || IsInsideVPC() )
{
return 0;
}
#ifdef ENABLE_GLOBAL_LANGUAGE
LocaleService_LoadMyLanguageConfig("lib/language.pyc");
LocaleService_LoadConfig("lib/locale_language.pyc");
if (stricmp(LocaleService_GetMyLanguage(), "de") == 0)
{
SetDefaultCodePage(LocaleService_GetCodePageDe());
}
else if (stricmp(LocaleService_GetMyLanguage(), "tr") == 0)
{
SetDefaultCodePage(LocaleService_GetCodePageTr());
}
else if (stricmp(LocaleService_GetMyLanguage(), "pl") == 0)
{
SetDefaultCodePage(LocaleService_GetCodePagePl());
}
else if (stricmp(LocaleService_GetMyLanguage(), "ro") == 0)
{
SetDefaultCodePage(LocaleService_GetCodePageRo());
}
else if (stricmp(LocaleService_GetMyLanguage(), "en") == 0)
{
SetDefaultCodePage(LocaleService_GetCodePageEn());
}
else
{
SetDefaultCodePage(LocaleService_GetCodePageEn());
}
#else
SetDefaultCodePage(LocaleService_GetCodePage());
#endif
bool ignore = true;
#ifdef CEF_BROWSER
CefWebBrowser_Startup(hInstance);
#else
WebBrowser_Startup(hInstance);
#endif
#ifndef ENABLE_FOX_FS
if (!CheckPythonLibraryFilenames())
{
LogBoxf("FATAL ERROR!! Python Library file not exist!");
goto Clean;
}
#endif
Main(hInstance, lpCmdLine);
#ifdef ENABLE_FOX_FS
PackUninitialize();
#endif
#ifdef CEF_BROWSER
CefWebBrowser_Cleanup();
#else
WebBrowser_Cleanup();
#endif
::CoUninitialize();
#ifndef ENABLE_FOX_FS
Clean:
return 0;
#endif
}
static void GrannyError(granny_log_message_type Type, granny_log_message_origin Origin, char const* File, granny_int32x Line, char const *Error, void *UserData) {}
int Setup(LPSTR lpCmdLine)
{
TIMECAPS tc;
UINT wTimerRes;
if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
{
return 0;
}
wTimerRes = MINMAX(tc.wPeriodMin, 1, tc.wPeriodMax);
timeBeginPeriod(wTimerRes);
granny_log_callback Callback;
Callback.Function = GrannyError;
Callback.UserData = 0;
GrannySetLogCallback(&Callback);
return 1;
}
Son düzenleme: