Changeset 16225

Show
Ignore:
Timestamp:
11/18/2008 07:28:55 PM (7 weeks ago)
Author:
jmarshallnz
Message:

added: Win32 dll loader initial code.

Location:
branches/win32dllloader/xbmc
Files:
19 modified

Legend:

Unmodified
Added
Removed
  • branches/win32dllloader/xbmc/FileSystem/FileCurl.cpp

    r16106 r16225  
    4242#define XMIN(a,b) ((a)<(b)?(a):(b)) 
    4343 
    44 #if defined(__APPLE__) 
    45 extern "C" int __stdcall dllselect(int ntfs, fd_set *readfds, fd_set *writefds, fd_set *errorfds, const timeval *timeout); 
    4644#define dllselect select 
    47 #elif defined(WIN32) 
    48 extern "C" int __stdcall dllselect(int ntfs, fd_set *readfds, fd_set *writefds, fd_set *errorfds, const timeval *timeout); 
    49 #else 
    50 #define dllselect select 
    51 #endif 
    5245 
    5346// curl calls this routine to debug 
  • branches/win32dllloader/xbmc/Util.cpp

    r16166 r16225  
    22102210} 
    22112211 
    2212 #ifndef _LINUX 
    2213 void CUtil::Stat64ToStat(struct _stat *result, struct __stat64 *stat) 
    2214 #else 
    22152212void CUtil::Stat64ToStat(struct stat *result, struct __stat64 *stat) 
    2216 #endif 
    22172213{ 
    22182214  result->st_dev = stat->st_dev; 
  • branches/win32dllloader/xbmc/Util.h

    r15523 r16225  
    286286  static void Stat64ToStatI64(struct _stati64 *result, struct __stat64 *stat); 
    287287  static void StatI64ToStat64(struct __stat64 *result, struct _stati64 *stat); 
    288 #ifndef _LINUX 
    289   static void Stat64ToStat(struct _stat *result, struct __stat64 *stat); 
    290 #else 
    291288  static void Stat64ToStat(struct stat *result, struct __stat64 *stat); 
    292 #endif 
    293289  static bool CreateDirectoryEx(const CStdString& strPath); 
    294290  static CStdString MakeLegalFileName(const CStdString &strFile); 
  • branches/win32dllloader/xbmc/cores/DllLoader/DllLoader.cpp

    r16038 r16225  
    574574} 
    575575 
    576 int DllLoader::ResolveExport(unsigned long ordinal, void **pAddr) 
     576int DllLoader::ResolveOrdinal(unsigned long ordinal, void **pAddr) 
    577577{ 
    578578  Export* pExport=GetExportByOrdinal(ordinal); 
  • branches/win32dllloader/xbmc/cores/DllLoader/DllLoader.h

    r13101 r16225  
    6666 
    6767  virtual int ResolveExport(const char*, void** ptr); 
    68   virtual int ResolveExport(unsigned long ordinal, void** ptr); 
     68  virtual int ResolveOrdinal(unsigned long ordinal, void** ptr); 
    6969  virtual bool HasSymbols() { return m_bLoadSymbols && !m_bUnloadSymbols; } 
    7070  virtual bool IsSystemDll() { return m_bSystemDll; } 
    7171  virtual HMODULE GetHModule() { return (HMODULE)hModule; }   
    7272   
     73  Export* GetExportByFunctionName(const char* sFunctionName); 
     74  Export* GetExportByOrdinal(unsigned long ordinal); 
    7375protected:   
    7476  int Parse(); 
    7577  int ResolveImports(); 
    76  
    77   Export* GetExportByOrdinal(unsigned long ordinal); 
    78   Export* GetExportByFunctionName(const char* sFunctionName); 
    7978   
    8079  void AddExport(unsigned long ordinal, void* function, void* track_function = NULL); 
  • branches/win32dllloader/xbmc/cores/DllLoader/DllLoaderContainer.cpp

    r16143 r16225  
    278278  else 
    279279#elif defined(_WIN32PC) 
    280   if (strlen(sName) >= 4 && !strnicmp(sName + (strlen(sName) - 18), "ProjectM_win32.vis", 18)) 
    281   { 
     280  if (1) 
    282281    pLoader = new Win32DllLoader(sName); 
    283   } 
    284282  else 
    285283#endif 
  • branches/win32dllloader/xbmc/cores/DllLoader/LibraryLoader.cpp

    r14120 r16225  
    8383  return m_iRefCount; 
    8484} 
     85 
     86int LibraryLoader::ResolveOrdinal(unsigned long ordinal, void** ptr) 
     87{ 
     88  CLog::Log(LOGWARNING, "%s - Unable to resolve %lu in dll %s", __FUNCTION__, ordinal, GetName()); 
     89  return 0; 
     90} 
  • branches/win32dllloader/xbmc/cores/DllLoader/LibraryLoader.h

    r14126 r16225  
    4141   
    4242  virtual int ResolveExport(const char* symbol, void** ptr) = 0; 
     43  virtual int ResolveOrdinal(unsigned long ordinal, void** ptr); 
    4344  virtual bool IsSystemDll() = 0; 
    4445  virtual HMODULE GetHModule() = 0; 
  • branches/win32dllloader/xbmc/cores/DllLoader/Win32DllLoader.cpp

    r14120 r16225  
    2222#include "stdafx.h" 
    2323#include "Win32DllLoader.h" 
     24#include "DllLoader.h" 
     25#include "DllLoaderContainer.h" 
    2426#include "StdString.h" 
    2527#include "Util.h" 
    2628#include "utils/log.h" 
    2729 
     30#include "dll_tracker_library.h" 
     31#include "dll_tracker_file.h" 
     32#include "exports/emu_kernel32.h" 
     33#include "exports/emu_msvcrt.h" 
     34 
     35// our exports 
     36Export win32_exports[] = 
     37{ 
     38  // kernel32 
     39  { "FindFirstFileA",                               -1, (void*)dllFindFirstFileA,                               NULL }, 
     40  { "GetFileAttributesA",                           -1, (void*)dllGetFileAttributesA,                        NULL }, 
     41  { "LoadLibraryA",                                 -1, (void*)dllLoadLibraryA,                              (void*)track_LoadLibraryA }, 
     42  { "FreeLibrary",                                  -1, (void*)dllFreeLibrary,                               (void*)track_FreeLibrary }, 
     43  { "GetProcAddress",                               -1, (void*)dllGetProcAddress,                            NULL }, 
     44  { "SetEvent",                                     -1, (void*)SetEvent,                                     NULL }, 
     45  { "GetModuleHandleA",                             -1, (void*)dllGetModuleHandleA,                          NULL }, 
     46  { "CreateFileA",                                  -1, (void*)dllCreateFileA,                               NULL }, 
     47  { "LoadLibraryExA",                               -1, (void*)dllLoadLibraryExA,                            (void*)track_LoadLibraryExA },  
     48  { "GetModuleFileNameA",                           -1, (void*)dllGetModuleFileNameA,                        NULL }, 
     49// potential vfs stuff 
     50//  { "CreateDirectoryA",                             -1, (void*)dllCreateDirectoryA,                          NULL }, 
     51//  { "LockFile",                                     -1, (void*)dllLockFile,                                  NULL }, 
     52//  { "LockFileEx",                                   -1, (void*)dllLockFileEx,                                NULL }, 
     53//  { "UnlockFile",                                   -1, (void*)dllUnlockFile,                                NULL }, 
     54//  { "CreateFileW",                                  -1, (void*)CreateFileW,                                  NULL }, 
     55//  { "GetFullPathNameW",                             -1, (void*)GetFullPathNameW,                             NULL }, 
     56//  { "GetTempPathW",                                 -1, (void*)GetTempPathW,                                 NULL }, 
     57//  { "GetFileAttributesW",                           -1, (void*)GetFileAttributesW,                           NULL }, 
     58//  { "DeleteFileW",                                  -1, (void*)DeleteFileW,                                  NULL }, 
     59//  { "GetFileSize",                                  -1, (void*)GetFileSize,                                  NULL }, 
     60 
     61// msvcrt 
     62  { "_close",                     -1, (void*)dll_close,                     (void*)track_close}, 
     63  { "_lseek",                     -1, (void*)dll_lseek,                     NULL }, 
     64  { "_read",                      -1, (void*)dll_read,                      NULL }, 
     65  { "_write",                     -1, (void*)dll_write,                     NULL }, 
     66  { "_lseeki64",                  -1, (void*)dll_lseeki64,                  NULL }, 
     67  { "_open",                      -1, (void*)dll_open,                      (void*)track_open }, 
     68  { "fflush",                     -1, (void*)dll_fflush,                    NULL }, 
     69  { "fprintf",                    -1, (void*)dll_fprintf,                   NULL }, 
     70  { "fwrite",                     -1, (void*)dll_fwrite,                    NULL }, 
     71  { "putchar",                    -1, (void*)dll_putchar,                   NULL }, 
     72  { "_fstat",                     -1, (void*)dll_fstat,                     NULL }, 
     73  { "_mkdir",                     -1, (void*)dll_mkdir,                     NULL }, 
     74  { "_stat",                      -1, (void*)dll_stat,                      NULL }, 
     75  { "_findclose",                 -1, (void*)dll_findclose,                 NULL }, 
     76  { "_findfirst",                 -1, (void*)dll_findfirst,                 NULL }, 
     77  { "_findnext",                  -1, (void*)dll_findnext,                  NULL }, 
     78  { "fclose",                     -1, (void*)dll_fclose,                    (void*)track_fclose}, 
     79  { "feof",                       -1, (void*)dll_feof,                      NULL }, 
     80  { "fgets",                      -1, (void*)dll_fgets,                     NULL }, 
     81  { "fopen",                      -1, (void*)dll_fopen,                     (void*)track_fopen}, 
     82  { "putc",                       -1, (void*)dll_putc,                      NULL }, 
     83  { "fputc",                      -1, (void*)dll_fputc,                     NULL }, 
     84  { "fputs",                      -1, (void*)dll_fputs,                     NULL }, 
     85  { "fread",                      -1, (void*)dll_fread,                     NULL }, 
     86  { "fseek",                      -1, (void*)dll_fseek,                     NULL }, 
     87  { "ftell",                      -1, (void*)dll_ftell,                     NULL }, 
     88  { "getc",                       -1, (void*)dll_getc,                      NULL }, 
     89  { "fgetc",                      -1, (void*)dll_getc,                      NULL }, 
     90  { "rewind",                     -1, (void*)dll_rewind,                    NULL }, 
     91  { "vfprintf",                   -1, (void*)dll_vfprintf,                  NULL }, 
     92  { "fgetpos",                    -1, (void*)dll_fgetpos,                   NULL }, 
     93  { "fsetpos",                    -1, (void*)dll_fsetpos,                   NULL }, 
     94  { "_stati64",                   -1, (void*)dll_stati64,                   NULL }, 
     95  { "_fstati64",                  -1, (void*)dll_fstati64,                  NULL }, 
     96  { "_telli64",                   -1, (void*)dll_telli64,                   NULL }, 
     97  { "_tell",                      -1, (void*)dll_tell,                      NULL }, 
     98  { "_fileno",                    -1, (void*)dll_fileno,                    NULL }, 
     99  { "ferror",                     -1, (void*)dll_ferror,                    NULL }, 
     100  { "freopen",                    -1, (void*)dll_freopen,                   (void*)track_freopen}, 
     101  { "fscanf",                     -1, (void*)fscanf,                        NULL }, 
     102  { "ungetc",                     -1, (void*)dll_ungetc,                    NULL }, 
     103  { "_fdopen",                    -1, (void*)dll_fdopen,                    NULL }, 
     104  { "clearerr",                   -1, (void*)dll_clearerr,                  NULL }, 
     105  // for debugging 
     106  { "printf",                     -1, (void*)dllprintf,                     NULL }, 
     107  { "vprintf",                    -1, (void*)dllvprintf,                    NULL }, 
     108  { "perror",                     -1, (void*)dllperror,                     NULL }, 
     109  { "puts",                       -1, (void*)dllputs,                       NULL }, 
     110  // workarounds for non-win32 signals 
     111  { "signal",                     -1, (void*)dll_signal,                    NULL }, 
     112  { NULL,                          -1, NULL,                                NULL } 
     113}; 
     114 
     115// stuff for python 
     116extern "C" 
     117{ 
     118  char* xbp_getcwd(char *buf, int size); 
     119  int xbp_chdir(const char *dirname); 
     120  int xbp_access(const char *path, int mode); 
     121  int xbp_unlink(const char *filename); 
     122  int xbp_chmod(const char *filename, int pmode); 
     123  int xbp_rmdir(const char *dirname); 
     124  int xbp_utime(const char *filename, struct utimbuf *times); 
     125  int xbp_rename(const char *oldname, const char *newname); 
     126  int xbp_mkdir(const char *dirname); 
     127  int xbp_open(const char *filename, int oflag, int pmode); 
     128}; 
     129 
     130extern "C" void* _iob(); 
     131 
     132Export win32_python_exports[] = 
     133{ 
     134  // these just correct for path separators and call the base 
     135  { "access",                               -1, (void*)xbp_access,                               NULL }, 
     136  { "unlink",                               -1, (void*)xbp_unlink,                               NULL }, 
     137  { "chmod",                               -1, (void*)xbp_chmod,                               NULL }, 
     138  { "rmdir",                               -1, (void*)xbp_rmdir,                               NULL }, 
     139  { "utime",                               -1, (void*)xbp_utime,                               NULL }, 
     140  { "rename",                               -1, (void*)xbp_rename,                               NULL }, 
     141  { "mkdir",                               -1, (void*)xbp_mkdir,                               NULL }, 
     142  { "open",                               -1, (void*)xbp_open,                               NULL }, 
     143//  { "opendir",                               -1, (void*)xbp_opendir,                               NULL }, _LINUX only 
     144 
     145  // special workaround just for python 
     146  { "_chdir",                               -1, (void*)xbp_chdir,                               NULL }, 
     147  { "_getcwd",                              -1, (void*)xbp_getcwd,                               NULL }, 
     148  { "_putenv",                              -1, (void*)dll_putenv,                              NULL }, 
     149  { "getenv",                              -1, (void*)dll_getenv,                              NULL }, 
     150  { "__p__environ",               -1, (void*)dll___p__environ,              NULL }, 
     151 
     152  // for stdin/stdout etc. 
     153  { "_iob",                       -1, (void*)_iob,                          NULL }, 
     154  { NULL,                          -1, NULL,                                NULL } 
     155}; 
     156 
    28157Win32DllLoader::Win32DllLoader(const char *dll) : LibraryLoader(dll) 
    29158{ 
    30159  m_dllHandle = NULL; 
     160  DllLoaderContainer::RegisterDll(this); 
    31161} 
    32162 
     
    35165  if (m_dllHandle) 
    36166    Unload(); 
     167  DllLoaderContainer::UnRegisterDll(this); 
    37168} 
    38169 
     
    54185  } 
    55186 
     187  // handle functions that the dll imports 
     188  OverrideImports(strFileName); 
     189 
    56190  return true; 
    57191} 
     
    60194{ 
    61195  CLog::Log(LOGDEBUG, "NativeDllLoader: Unloading: %s\n", GetName()); 
     196 
     197  // restore our imports 
     198  RestoreImports(); 
    62199 
    63200  if (m_dllHandle) 
     
    104241  return false; 
    105242} 
     243 
     244void Win32DllLoader::OverrideImports(const CStdString &dll) 
     245{ 
     246  BYTE* image_base = (BYTE*)GetModuleHandle(dll.c_str()); 
     247 
     248  if (!image_base) 
     249  { 
     250    CLog::Log(LOGERROR, "%s - unable to GetModuleHandle for dll %s", dll.c_str()); 
     251    return; 
     252  } 
     253 
     254  PIMAGE_DOS_HEADER dos_header = (PIMAGE_DOS_HEADER)image_base; 
     255  PIMAGE_NT_HEADERS nt_header = (PIMAGE_NT_HEADERS)(image_base + dos_header->e_lfanew); // e_lfanew = value at 0x3c 
     256 
     257  PIMAGE_IMPORT_DESCRIPTOR imp_desc = (PIMAGE_IMPORT_DESCRIPTOR)( 
     258    image_base + nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress); 
     259 
     260  if (!imp_desc) 
     261  { 
     262    CLog::Log(LOGERROR, "%s - unable to get import directory for dll %s", dll.c_str()); 
     263    return; 
     264  } 
     265 
     266  // loop over all imported dlls  
     267  for (int i = 0; imp_desc[i].Characteristics != 0; i++) 
     268  { 
     269    char *dllName = (char*)(image_base + imp_desc[i].Name); 
     270 
     271    PIMAGE_THUNK_DATA orig_first_thunk = (PIMAGE_THUNK_DATA)(image_base + imp_desc[i].OriginalFirstThunk); 
     272    PIMAGE_THUNK_DATA first_thunk = (PIMAGE_THUNK_DATA)(image_base + imp_desc[i].FirstThunk); 
     273 
     274    // and then loop over all imported functions 
     275    for (int j = 0; orig_first_thunk[j].u1.Function != 0; j++) 
     276    { 
     277      void *fixup = NULL; 
     278      if (orig_first_thunk[j].u1.Function & 0x80000000) 
     279        ResolveOrdinal(dllName, (orig_first_thunk[j].u1.Ordinal & 0x7fffffff), &fixup); 
     280      else 
     281      { // resolve by name 
     282        PIMAGE_IMPORT_BY_NAME orig_imports_by_name = (PIMAGE_IMPORT_BY_NAME)( 
     283          image_base + orig_first_thunk[j].u1.AddressOfData); 
     284 
     285        ResolveImport(dllName, (char*)orig_imports_by_name->Name, &fixup); 
     286      }/* 
     287      if (!fixup) 
     288      { // create a dummy function for tracking purposes 
     289        PIMAGE_IMPORT_BY_NAME orig_imports_by_name = (PIMAGE_IMPORT_BY_NAME)( 
     290          image_base + orig_first_thunk[j].u1.AddressOfData); 
     291        fixup = CreateDummyFunction(dllName, (char*)orig_imports_by_name->Name); 
     292      }*/ 
     293      if (fixup) 
     294      { 
     295        // save the old function 
     296        Import import; 
     297        import.table = &first_thunk[j].u1.Function; 
     298        import.function = first_thunk[j].u1.Function; 
     299        m_overriddenImports.push_back(import); 
     300 
     301        DWORD old_prot = 0; 
     302 
     303        // change to protection settings so we can write to memory area 
     304        VirtualProtect((PVOID)&first_thunk[j].u1.Function, 4, PAGE_EXECUTE_READWRITE, &old_prot); 
     305 
     306        // patch the address of function to point to our overridden version 
     307        first_thunk[j].u1.Function = (DWORD)fixup; 
     308 
     309        // reset to old settings 
     310        VirtualProtect((PVOID)&first_thunk[j].u1.Function, 4, old_prot, &old_prot); 
     311      } 
     312    } 
     313  } 
     314} 
     315 
     316void Win32DllLoader::RestoreImports() 
     317{ 
     318  for (unsigned int i = 0; i < m_overriddenImports.size(); i++) 
     319  { 
     320    Import &import = m_overriddenImports[i]; 
     321 
     322    // change to protection settings so we can write to memory area 
     323    DWORD old_prot = 0; 
     324    VirtualProtect(import.table, 4, PAGE_EXECUTE_READWRITE, &old_prot); 
     325 
     326    *(DWORD *)import.table = import.function; 
     327 
     328    // reset to old settings 
     329    VirtualProtect(import.table, 4, old_prot, &old_prot); 
     330  } 
     331} 
     332 
     333bool Win32DllLoader::ResolveImport(const char *dllName, const char *functionName, void **fixup) 
     334{ 
     335  char *dll = GetName(); 
     336  if (strstr(dll, "python24.dll") || strstr(dll, ".pyd")) 
     337  { // special case for python 
     338    Export *exp = win32_python_exports; 
     339    while (exp->name) 
     340    { 
     341      if (strcmp(exp->name, functionName) == 0) 
     342      { 
     343        *fixup = exp->function; 
     344        return true; 
     345      } 
     346      exp++; 
     347    } 
     348  } 
     349  Export *exp = win32_exports; 
     350  while (exp->name) 
     351  { 
     352    if (strcmp(exp->name, functionName) == 0) 
     353    { // TODO: Should we be tracking stuff? 
     354      if (0) 
     355        *fixup = exp->track_function; 
     356      else 
     357        *fixup = exp->function; 
     358      return true; 
     359    } 
     360    exp++; 
     361  } 
     362  return false; 
     363} 
     364 
     365bool Win32DllLoader::ResolveOrdinal(const char *dllName, unsigned long ordinal, void **fixup) 
     366{ 
     367  Export *exp = win32_exports; 
     368  while (exp->name) 
     369  { 
     370    if (exp->ordinal == ordinal) 
     371    { // TODO: Should we be tracking stuff? 
     372      if (0) 
     373        *fixup = exp->track_function; 
     374      else 
     375        *fixup = exp->function; 
     376      return true; 
     377    } 
     378    exp++; 
     379  } 
     380  return false; 
     381} 
  • branches/win32dllloader/xbmc/cores/DllLoader/Win32DllLoader.h

    r14120 r16225  
    2828{ 
    2929public: 
     30  class Import 
     31  { 
     32  public: 
     33    void *table; 
     34    DWORD function; 
     35  }; 
     36 
    3037  Win32DllLoader(const char *dll); 
    3138  ~Win32DllLoader(); 
     
    4047 
    4148private: 
     49  void OverrideImports(const CStdString &dll); 
     50  void RestoreImports(); 
     51  bool ResolveImport(const char *dllName, const char *functionName, void **fixup); 
     52  bool ResolveOrdinal(const char *dllName, unsigned long ordinal, void **fixup); 
     53 
    4254  HMODULE m_dllHandle; 
     55 
     56  std::vector<Import> m_overriddenImports; 
    4357}; 
    4458 
  • branches/win32dllloader/xbmc/cores/DllLoader/dll.cpp

    r13101 r16225  
    169169  if( HIGH_WORD(function) == 0 && LOW_WORD(function) < 1000) 
    170170  { 
    171     if( ((DllLoader*) dll)->ResolveExport(LOW_WORD(function), &address) ) 
     171    if( dll->ResolveOrdinal(LOW_WORD(function), &address) ) 
    172172    { 
    173173      CLog::Log(LOGDEBUG, "%s(%p(%s), %d) => %p", __FUNCTION__, hModule, dll->GetName(), LOW_WORD(function), address); 
  • branches/win32dllloader/xbmc/cores/DllLoader/exports/emu_kernel32.cpp

    r16153 r16225  
    8181{ 
    8282  return FindClose(hFile); 
     83} 
     84 
     85#ifdef _WIN32 
     86#define CORRECT_SEP_STR(str) \ 
     87    int iSize_##str = strlen(str); \ 
     88    for (int pos = 0; pos < iSize_##str; pos++) if (str[pos] == '/') str[pos] = '\\'; 
     89#else 
     90#define CORRECT_SEP_STR(str) 
     91#endif 
     92 
     93extern "C" HANDLE WINAPI dllFindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData) 
     94{ 
     95  char* p = strdup(lpFileName); 
     96  CORRECT_SEP_STR(p); 
     97   
     98  // change default \\*.* into \\* which the xbox is using 
     99  char* e = strrchr(p, '.'); 
     100  if (e != NULL && strlen(e) > 1 && e[1] == '*') 
     101  { 
     102    e[0] = '\0'; 
     103  } 
     104 
     105  int test = sizeof(WIN32_FIND_DATA); 
     106   
     107  HANDLE res = FindFirstFile(_P(p).c_str(), lpFindFileData); 
     108  free(p); 
     109  return res; 
    83110} 
    84111 
  • branches/win32dllloader/xbmc/cores/DllLoader/exports/emu_kernel32.h

    r13101 r16225  
    590590//When doing emulation or interception, the calling convention should 
    591591//match exactly the target dlls suppose to use.   Monkeyhappy 
     592extern "C" HANDLE WINAPI dllFindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData); 
    592593extern "C" BOOL WINAPI dllFindClose(HANDLE hFile); 
    593594extern "C" UINT WINAPI dllGetAtomNameA( ATOM nAtom, LPTSTR lpBuffer, int nSize); 
  • branches/win32dllloader/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp

    r15884 r16225  
    126126  dll_putenv("PATH=.;Q:\\;Q:\\system\\python"); 
    127127  //dll_putenv("PYTHONCASEOK=1"); 
    128   //dll_putenv("PYTHONDEBUG=1"); 
    129   //dll_putenv("PYTHONVERBOSE=2"); // "1" for normal verbose, "2" for more verbose ? 
     128  dll_putenv("PYTHONDEBUG=1"); 
     129  dll_putenv("PYTHONVERBOSE=2"); // "1" for normal verbose, "2" for more verbose ? 
    130130  dll_putenv("PYTHONOPTIMIZE=1"); 
    131131  //dll_putenv("PYTHONDUMPREFS=1"); 
     
    14191419 
    14201420  //SLOW CODE SHOULD BE REVISED 
    1421   int dll_stat(const char *path, struct _stat *buffer) 
     1421  int dll_stat(const char *path, struct stat *buffer) 
    14221422  { 
    14231423#ifndef _LINUX 
     
    15261526    if (pFile != NULL) 
    15271527    { 
    1528       CLog::Log(LOGINFO, "Stating open file"); 
    1529      
    1530       __int64 size = pFile->GetLength(); 
    1531 #ifdef _WIN32PC 
    1532       if (size <= LONG_MAX)  
    1533 #else 
    1534       if (sizeof(size) <= sizeof(buffer->st_size) ) 
    1535 #endif 
    1536         buffer->st_size = (_off_t)size; 
    1537       else 
    1538       { 
    1539         buffer->st_size = 0; 
    1540         CLog::Log(LOGWARNING, "WARNING: File is larger than 32bit stat can handle, file size will be reported as 0 bytes"); 
    1541       } 
    1542       buffer->st_mode = _S_IFREG; 
    1543  
    1544       return 0; 
     1528      struct __stat64 tStat; 
     1529      if (pFile->Stat(&tStat) == 0) 
     1530      { 
     1531        CUtil::Stat64ToStat(buffer, &tStat); 
     1532        return 0; 
     1533      } 
    15451534    } 
    15461535    else if (!IS_STD_DESCRIPTOR(fd)) 
  • branches/win32dllloader/xbmc/cores/DllLoader/exports/emu_msvcrt.h

    r14624 r16225  
    117117  int dll_stati64(const char *path, struct _stati64 *buffer); 
    118118  int dll_stat64(const char *path, struct __stat64 *buffer); 
    119   int dll_stat(const char *path, struct _stat *buffer); 
     119  int dll_stat(const char *path, struct stat *buffer); 
    120120  int dll_fstat(int fd, struct stat *buffer); 
    121121  int dll_fstati64(int fd, struct _stati64 *buffer); 
  • branches/win32dllloader/xbmc/lib/libPython/Python/PC/pyconfig.h

    r14120 r16225  
    205205/* For Windows the Python core is in a DLL by default.  Test 
    206206Py_NO_ENABLE_SHARED to find out.  Also support MS_NO_COREDLL for b/w compat */ 
    207 #if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED) && !defined(_XBOX) && !defined(_WIN32) 
     207#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED) && !defined(_XBOX)