Hello, my question - Pointers to the Functions. - page 2

 

Great.

A have 20-years experience of coding in Assembler you called

"binary container with code inside" - it's called EXE program, or EX4.

I have also written an multitasking operating system with there own file system.

It had 4kB of code you called "binary container..." and starts from FDD.

Can You do this?  Try in your HTML.


You are notepad programmers.  It wont be well in future.

You have no idea how it works on processor level.

There are on processor level stacks, registers, threads, process, descriptors,

selectors, code segment, data segment, stack segment, hardware interrupts, ports, tec.


Please read this:

https://www.mql5.com/en/forum/111748


Thanks.

Please do not answer on this topic if you dont know Assembler.

different results using a dll function
different results using a dll function
  • 2008.10.16
  • www.mql5.com
Hi, I've got a real strange problem using a dll with MetaTrader: I've written a 2 Indicators and 1 dll...
 

Interesting how you know about my skills.


Whatever. you have been refering me to a thread where you give a false answer. MT4 is single threaded, jsut to let you know.

And the solution you are giving is incomplete as well.

Maybe you want to read up this:

https://docs.microsoft.com/en-us/windows/win32/memory/sharing-files-and-memory

Just as a sidenote.

Sharing Files and Memory - Win32 apps
Sharing Files and Memory - Win32 apps
  • 2021.01.07
  • mikben
  • docs.microsoft.com
File mapping can be used to share a file or memory between two or more processes. To share a file or memory, all of the processes must use the name or the handle of the same file mapping object.
 
PawelMT5 #:

Great.

A have 20-years experience of coding in Assembler you called

You have "20 years" of experience and yet you didn't learn to read the manual, basic manners or use google,
otherwise you would've learned already that MQL has no real pointers like in other programming languages.
 

Thanks Alexandre - only You have been understand me.

Thanks for " MQL has no real pointers " - I know great.

But there are two kindes of pointers:

- pointers to data (not in tables like Table[i] where " i " is an pointer)

- pointers to code (I cant find, and this is my question)       <<<---      This is my question.

                                                                                                              I have no answer.

                                                                                                              Its not critical for me.  I can wait.

 
PawelMT5 #:

Thanks Alexandre - only You have been understand me.

Thanks for " MQL has no real pointers " - I know great.

But there are two kindes of pointers:

- pointers to data (not in tables like Table[i] where " i " is an pointer)

- pointers to code (I cant find, and this is my question)       <<<---      This is my question.

                                                                                                              I have no answer.

                                                                                                              Its not critical for me.  I can wait.

I know how pointers work in asm, c, c++... and I told you, MQL5 does not have it, you can't reference memory addresses,
you can't access heap, stack or the code part of the application through it.

In MQL5 even object pointers are not real pointers, they are just object descriptors that simulate pointers, as you can see in the manual:

"In contrast to C++, the hobject variable from example above is not a pointer to memory, but rather an object descriptor"

 

Thanks.  That problem is not solved, and is not possible to solve.


You can dump Table[] to File and its yours, byte by byte.

Other threads / tasks can use it, but carefull with critical section.

I'd recomand Ram Drive becouse SSD disks have finite writes number.

And You can pass even 10MB tables between tasks or process.


But its only data - FilePointer is an pointer in your shared data.

And there is no pointers to code.  Inside Indicator are many Functions()

and there is no pointer to the place in RAM memory, where Funcion() is placed.


And there is no possible to create:

int Table_Of_Pointers_To_Functions[100];       // 32-bit CPU


Thanks.

Problem is not solved.

And it is not possible to solve.

Please close.

 

It is very possible to have "pointers" to functions. In fact, I believe these are real pointers in the sense of a memory address. 

It goes like this:

// Definition
typedef string (*TUsrErrFunc)(const int);

// And here the dynamic array
static TUsrErrFunc error_groups[];


// And here how to use them
TUsrErrFunc func_ptr = error_groups[0x00];
string retval = func_ptr(error_code);



And here an example on how to get to real memory addresses:

// Memcpy function import
#import "ntdll.dll"
    ulong       memcpy                          (uchar& dest[],             ulong src, ulong len);
    ulong       memcpy                          (ulong& dest[],             ulong src, ulong len);
    ulong       memcpy                          (uint& dest[],              ulong src, ulong len);
#import

Knowing that memcpy returns the pointer of the address in memory is crucial to be able to utilize this functionality.....

Next time watch out on whos toes you step, maybe.
 

Prove it, wise guy.

In Your ClickAndPlay language - MQL5.


If you wise, it is 5 minutes of work.  Type me that and send source code in MQL5:


//========================================

void Function0(void) {};

int Function1(int) {};


Print(string(Address_Of_Ram_Memory_Where_Function0_Starts));

Result=Function1(Address_Of_Ram_Memory_Where_Function0_Starts);      // calling Function0 from int variable

//=========================================


Please type it in MQL5, and send me.  WIse guy.

 
PawelMT5 #:

Prove it, wise guy.

In Your ClickAndPlay language - MQL5.


If you wise, it is 5 minutes of work.  Type me that and send source code in MQL5:


//========================================

void Function0(void) {};

int Function1(int) {};


Print(string(Address_Of_Ram_Memory_Where_Function0_Starts));

Result=Function1(Address_Of_Ram_Memory_Where_Function0_Starts);      // calling Function0 from int variable

//=========================================


Please type it in MQL5, and send me.  WIse guy.

I love how you come here and insult everyone trying to help you.
Really shows how much of a Professional you are.

Asking a basic question, ignoring all relevant answers.. and then claiming to be really experienced.. nice.

If MQL5 is such a Plug and Play language, why can't you do it? Read the Manual or learn how to behave.


 
PawelMT5 #:

Prove it, wise guy.

In Your ClickAndPlay language - MQL5.


If you wise, it is 5 minutes of work.  Type me that and send source code in MQL5:


//========================================

void Function0(void) {};

int Function1(int) {};


Print(string(Address_Of_Ram_Memory_Where_Function0_Starts));

Result=Function1(Address_Of_Ram_Memory_Where_Function0_Starts);      // calling Function0 from int variable

//=========================================


Please type it in MQL5, and send me.  WIse guy.


It is possible to write a similar code in MQL5 that logically will execute the same as your example, but your attitude is
disgusting so I won't even bother to write an example, which is something you would be capable of doing if you were as
intelligent as you think you are or you just read the manual.