Chinese garbled code in LUA script。Waiting for reply Online

Issues related to VMProtect
paituo
Posts: 2
Joined: Thu Dec 03, 2020 12:44 am

Chinese garbled code in LUA script。Waiting for reply Online

Postby paituo » Thu Dec 03, 2020 4:42 am

The current operating system is WIN10,Locale is Chinese。
Illustration:
区域语言.png
区域语言.png (55.08 KiB) Viewed 1005 times



.vmp file path is : E:\工作内容\test.dll.vmp

Call “print("Path:\t"..stripfilename(vmpCore:projectFileName()))” in script,print "E:\工作内容\test.dll.vmp" is ok。

But there is a mistake in the other use(configFile = io.open(vmpCore:projectFileName(), "r")). the "configFile" is nil。

Sample code:

Code: Select all

function OnBeforeCompilation()

   vmpCore:inputArchitecture():file()
   
   print("Path:\t"..vmpCore:projectFileName())

   configFilePath = vmpCore:projectFileName()
   print("Path:"..configFilePath)  -- is ok
      
   configFile = io.open(configFilePath, "r") --is error
   if configFile == nil then
      print("Open config text file \""..configFilePath.."\" error!No such config file or directory!")
      return
   end
end


How to solve this problem。

proposal:
1、Allow running script to abort;
2、Allow script control “Lock To Serial Number”;

Admin
Site Admin
Posts: 2021
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: Chinese garbled code in LUA script。Waiting for reply Online

Postby Admin » Thu Dec 03, 2020 6:00 am

"vmpCore" is unitialized variable. Anyway, it seems LUA doesn't support unicode file names for "io.open":

Code: Select all

static int io_open (lua_State *L) {
  const char *filename = luaL_checkstring(L, 1);
  const char *mode = luaL_optstring(L, 2, "r");
  LStream *p = newfile(L);
  const char *md = mode;  /* to traverse/check mode */
  luaL_argcheck(L, l_checkmode(md), 2, "invalid mode");
  p->f = fopen(filename, mode);
  return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1;
}


1、Allow running script to abort;


Just use it:

Code: Select all

error("ERROR MESSAGE")


2、Allow script control “Lock To Serial Number”;


Code: Select all

   local file = vmprotect.core():inputFile():item(1)
   local function = file:functions():itemByName("FUNCTION NAME")
   if function then
      function:setLockToKey(true)
   end

paituo
Posts: 2
Joined: Thu Dec 03, 2020 12:44 am

Re: Chinese garbled code in LUA script。Waiting for reply Online

Postby paituo » Fri Dec 04, 2020 3:31 am

Can conversion functions be provided:

Examples:

Code: Select all

int MultiByteToWideChar(unsigned int CodePage,
    unsigned long dwFlags,
    const char* lpMultiByteStr,
    int cbMultiByte,
    wchar_t* lpWideCharStr,
    int cchWideChar);

int WideCharToMultiByte(unsigned int CodePage,
    unsigned long dwFlags,
    const wchar_t* lpWideCharStr,
    int cchWideChar,
    char* lpMultiByteStr,
    int cchMultiByte,
    const char* lpDefaultChar,
    int* pfUsedDefaultChar);


proposal:
1、Can external script files be referenced? Examples:“XXX.vmp” Support like “LicenseDataFileName="licencemanager.vmp”;
2、Can FFI library be supported?http://luajit.org/ext_ffi.html
3、Can BitOp library be supported? http://bitop.luajit.org

Admin
Site Admin
Posts: 2021
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: Chinese garbled code in LUA script。Waiting for reply Online

Postby Admin » Sat Dec 05, 2020 7:06 am

2、Can FFI library be supported?http://luajit.org/ext_ffi.html

Code: Select all

function OnBeforeCompilation()
   MessageBox(0, 'OnBeforeCompilation', 'MessageBox from user32.dll', 0x40)
end

function OnAfterCompilation()
   MessageBox(0, 'OnAfterCompilation', 'MessageBox from user32.dll', 0x40)
end

user32 = vmprotect.openLib('user32.dll')
MessageBox = user32:getFunction('MessageBoxA', {ret = 'int', 'size_t', 'string', 'string', 'uint'})


3、Can BitOp library be supported?

Bitwise operations are already supported:
https://www.lua.org/manual/5.2/manual.html#6.7

Admin
Site Admin
Posts: 2021
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: Chinese garbled code in LUA script。Waiting for reply Online

Postby Admin » Sun Dec 06, 2020 9:41 am

"oi.open" fixed in the 1261 build:
http://vmpsoft.com/files/VMProtectDemo.exe