In MQL5 there is always room for an exploit ! ;)

 

I suggest to post and analyze all kind of mql5 "impossibilities", like this one: Conditional Compilation.

It is possible to show the possibility at first(without revealing the implementation) in order to torture inquisitive people and stimulate the reader's own creativity.

But in the end, it is necessary (obligatory!) to reveal the secret and provide a sample implementation.

Of course, such a "two-phase" form is fraught with hoaxes, but I'll rely on honest statements of miracle-workers, who are ready to "back off". :)

--

So........ HERE WE GO !

 
Итак........ НАЧАЛИ !

Here we go. Me first. :)

Though the most "magic" places slow down a lot - but... Maybe one of the mql5 wizards will find a way to speed it up?

// You can see for yourself how slow they are, the test is devoted to measuring their speed.

This code works according to the usual syntax of using two-dimensional arrays.

void OnStart()
  {
   float  FA[5][3];
   long st=GetTickCount();
   for(int t=0;t<1000000;t++)
     {
      for(int i=0;i<5;i++)
        {
         for(int j=0;j<3;j++)
           {
            FA[i][j] = (i+1.5)*(j+1.3);
           }
        }
     }
   Print("====",GetTickCount()-st," ms ====");
   
   st=GetTickCount();
   C2DMagicArray  MA(5,3);   
   for(int t=0;t<1000000;t++)
     {
      for(int i=0;i<MA.SizeL();i++)
        {
         for(long j=0;j<MA.MaxR();j++)
           {
            MA[i][j] = (i+1.5)*(j+1.3);  
            // ^  ^  Как это сделано ??? Можете повторить ? :))
           }
        }
     }
   Print("====",GetTickCount()-st," ms ====");
   st=GetTickCount();
   for(int t=0;t<1000000;t++)
     {
      for(int i=0;i<MA.SizeL();i++)
        {
         for(long j=0;j<MA.MaxR();j++)
           {
            MA.Set(i,j,float((i+1.5)*(j+1.3)));
           }
        }
     }
   Print("====",GetTickCount()-st," ms ====");

   for(int i=0;i<MA.SizeL();i++)
     {
      for(int j=0;j<MA.MaxR();j++)
        {
         Print( MA[i][j] );  
         //        ^  ^    Как это сделано???  :))  Жду Вашу версию!
        }
     }
  }

You won't be able to compile the code yet : the injectors will be available later... - otherwise it won't be so interesting. :)

So, who can repeat the feat?

 

While Vladimir is waiting for an answer from us, I have a question worthy of a feat ;)


How can we make one ex5 import functions from 32 and 64 DLLs?
Let's say to make one ex5 for two (32/64) terminals.


Документация по MQL5: Основы языка / Препроцессор / Импорт функций (#import)
Документация по MQL5: Основы языка / Препроцессор / Импорт функций (#import)
  • www.mql5.com
Основы языка / Препроцессор / Импорт функций (#import) - Документация по MQL5
 
sergeev:

While Vladimir is waiting for an answer from us, I have a question worthy of a feat ;)


How can we make one ex5 import functions from 32 and 64 DLLs?
Say, to make one ex5 for two (32/64) terminals.

Are you asking for exceptions again?
 
Urain:
Are you asking for exceptions again?

No, I've never asked for an exception before. It's probably not about that. It's more about #ifdef

I was hoping that if Vladimir was able to overload operations by code, his method could work for automatically enabling the required DLL o_O

A kind of #import inside #define

 
MetaDriver:

Here we go. Me first. :)

So, who can repeat the feat?

It's taking a long time to repeat your feat :) Although there is a similar example in the documentation.

//--- перебираем строки для сложения
   for(int i=0;i<rows;i++)
     {
      //--- запишем результаты сложений строк матриц в массив
      for(int k=0;k<cols;k++)
        {
         arr[k]=this[i][k]+m[i][k];
        }
      //--- поместим массив в строку матрицы
      res[i]=arr;
     }
 
Yurich:

It's taking a long time to repeat your feat :) Although there is a similar example in the documentation.

So do it by that analogy... no big deal!... :-))

And I'll have a look. ;)

 
sergeev:

How can I import functions from 32 and 64 DLLs into one ex5?
Let's say to make one ex5 for two (32/64) terminals.

The functions have different names. And in the code, put conditional calls, depending on the bit rate of the terminal, to different functions.

It seems to me that terminal loads DLL at first call. No calls - no attempt to load and no critical miscarriage.

I don't see other ways. Terminal bitness is returned by TerminalInfoInteger().

bool x64 = TerminalInfoInteger(TERMINAL_X64);

All this can be done directly in MyLib.ex5 library.



void MyLibMultibitFunc()  // библиотечная универсальная обёртка для DLL-функции
{
  if(x64) { MyDll64Func(); }
  else { MyDll32Func(); }
}
 
MetaDriver:

The functions have different names. And in the code, put conditional calls, depending on the bit rate of the terminal, to different functions.

It seems to me that terminal loads DLL at first call. No calls - no attempt to load and no critical miscarriage.

I don't see other ways. Terminal bitness is returned by TerminalInfoInteger().

All this can be done directly in MyLib.ex5 library.

Yeah, same opinion, that terminal creates dll-function object only on first call.

And about bitness it seems there were some mentions about different representation of numbers on forum, if bit field of variable gives one result but it will be 32 if other, it will be 64. It can be determined by experience.

 
MetaDriver:

The functions have different names. And in the code, put conditional calls, depending on the bit rate of the terminal, to different functions to refer to.

It seems to me that terminal loads DLL at first call. No calls - no attempt to load and critical miscarriage.

No, gentlemen, you don't understand the problem. The possibilities with TERMINAL_X64 or _Is64 are known.

But unfortunately the terminal does differently.

- When you rush to the chart it checks the list of DLLs used and displays the list of imported functions in the Dependencies window
On those DLL's that don't match the bitness it writes a warning MQL5\Libraries\somedll64.dll' is not 32-bit version

- But when you press OK and the Expert Advisor kind of starts, you are really in trouble.

The terminal generates error 193 and unloads EX5

Cannot open 'MQL5\Libraries\somedll64.dll' (193)
EX5 loading failed

And I want to draw your attention to the fact that this code contains only the DLL declaration and no functions are imported from it

#import "somedll64.dll"
#import
Документация по MQL5: Основы языка / Препроцессор / Импорт функций (#import)
Документация по MQL5: Основы языка / Препроцессор / Импорт функций (#import)
  • www.mql5.com
Основы языка / Препроцессор / Импорт функций (#import) - Документация по MQL5
 

And so there is question number one.

How do you import functions from 32 bit dlls like user32.dll etc. into a 64 application? Or are there copies for them in the system with that name and OOP space is created ?

Reason: