Advertisement
Terrah

GetString hook

Sep 29th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. void * (__fastcall *CNWSScriptVarTable__GetStringNext)(CNWSScriptVarTable * pThis, void*, void *a2, CExoString *str);
  2. void * __fastcall CNWSScriptVarTable__GetString(CNWSScriptVarTable * pThis, void*, void *a2, CExoString *str){
  3.    
  4.     if (!str || !str->text){
  5.  
  6.         CExoString * str = (CExoString*)a2;
  7.         if (!str){
  8.             str = (CExoString*)lua.mem.nwnx_malloc(sizeof(CExoString));
  9.         }
  10.  
  11.         memset(str, 0, sizeof(CExoString));
  12.  
  13.         return str;
  14.     }
  15.     else if (strncmp(str->text, "LUA!", 4) == 0){
  16.        
  17.         char * request = strstr(str->text, "!")+1;
  18.         char * params = strstr(request, "!");
  19.  
  20.         *params = '\0';
  21.         params++;
  22.  
  23.         char * back = lua.OnGetString(request, params);
  24.        
  25.         CExoString * str = (CExoString*)a2;// lua.mem.nwnx_malloc(sizeof(CExoString));
  26.         if (!str){
  27.             str = (CExoString*)lua.mem.nwnx_malloc(sizeof(CExoString));        
  28.         }
  29.  
  30.         memset(str, 0, sizeof(CExoString));
  31.  
  32.         if (back){
  33.             str->text = back;
  34.             str->len = strlen(back);
  35.         }
  36.  
  37.         //lua.Log("o %08X = %s\n", str, str->text);
  38.  
  39.         return str;
  40.     }
  41.  
  42.     return CNWSScriptVarTable__GetStringNext(pThis, NULL, a2, str);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement