ts-soft wrote:This example works only with purifier enabled? Without purifier i become a empty string

LOL, so that's the reason why I wrote above "I don't know why". After all I believied to have checked the returned pointers were the same... The purifier seem to alter something, and after all considering these are pb internals it can have all the rights to do so.
So, this code (the original one) seems correct after all:
Code: Select all
Macro PB_StrToPtr(var, ptr)
ptr = @var
ptr = @ptr - SizeOf(Integer)
EndMacro
CompilerIf (#PB_Compiler_Processor = #PB_Processor_x86)
Macro ASM_StrToPtr( var, ptr )
EnableASM
LEA eax, var
MOV ptr, eax
DisableASM
EndMacro
CompilerElse
Macro ASM_StrToPtr( var, ptr )
EnableASM
LEA rax, var
MOV ptr, rax
DisableASM
EndMacro
CompilerEndIf
mystr.s = "ASM_"
*pstr.String = 0
ASM_StrToPtr( mystr, *pstr )
Debug *pstr
*pstr\s + "Hello"
Debug mystr ; "Hello"
mystr.s = "PB_"
*pstr.String = 0
PB_StrToPtr( mystr, *pstr )
Debug *pstr
*pstr\s + "Hello"
Debug mystr ; "Hello"
It works ok and results in the same pointer returned from the assembly macro, but using PB code instead of asm seem to make it "tamper-able" by the purifier.
In the end, considering the purifier it's a nice thing to have, it's better to stick to the asm version.
Interesting nevertheless.
Hey, I could be wrong but it seem that way!