pointer question lazarus / 62-General ---------------------------------------------------------------------- k1attila1 · 2021-10-31 06:15 Hi Friends ! How can i do it in pascal ? int* pMemory =  OX12AED567; *pMemory = 2345; thank you in advance attila ---------------------------------------------------------------------- SymbolicFrank · 2021-10-31 10:10 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; var  pMemory: ^integer absolute $12AED567;begin  pMemory^ := 2345;end. Ok, I didn't run it. This might make sense on a microcontroller, but not on a computer with an operating system. ---------------------------------------------------------------------- jamie · 2021-10-31 10:18 Quote from: k1attila1 on October 31, 2021, 07:15:18 amHi Friends ! How can i do it in pascal ? int* pMemory =  OX12AED567; *pMemory = 2345; thank you in advance attila The compiler allows me to do this, if it works I don't know atm but since it compiles I would say it works.. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Var pMemory:PInteger = Pointer($12AED567); ..............  pMemory[?] ???/or pMemory^ := 1234; does that work for you? ---------------------------------------------------------------------- Kays · 2021-10-31 10:20 Quote from: k1attila1 on October 31, 2021, 07:15:18 amHow can i do it in pascal ?You don’t. In Pascal the only allowed pointer literal is nil. The FPC allows you to typecast integer literals into pointers, but by doing so you are definitely leaving the realm of Pascal. Maybe programming in assembly or C is more suitable for your programming task at hand? ---------------------------------------------------------------------- jamie · 2021-10-31 13:35 maybe for the micro world the compiler can have a {$ ORIGIN
} like in the old assemblers ".ORG 
" ---------------------------------------------------------------------- SymbolicFrank · 2021-10-31 13:49 On a microcontroller with a static memory map, "absolute" will work. On a microcontroller with a Harvard architecture (segments), you probably cannot access program memory. On an ARM it is more complicated, depending on the model. And on an x86-AMD64 it probably won't work as expected. You could create named, shared memory or a memory-mapped file, but it's not that easy to find an existing location and access it. Outside of your own address space, you probably don't have the access rights either. Then again, Cheat Engine is written in Delphi. ---------------------------------------------------------------------- BobDog · 2021-10-31 15:15 Windows. You cannot specify an address, chances are something else is using it. But you could search for the next nearest on the way up perhaps. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i useswindows;{$macro on}{$define datatype:=integer} Var pMemory:^datatype;  p:int64=2000000;  tst:boolean=true;  begin writeln('searching for a slot . . .');  repeat  tst:= IsBadWritePtr(Pointer(p),sizeof(datatype)); if tst=false then  begin writeln('OK'); PMemory := Pointer(p); writeln(int64(PMemory)); pmemory^:=257; end; inc(p); until (tst=false);  writeln(pmemory^); writeln('Press enter to end'); readln;   end. ---------------------------------------------------------------------- SymbolicFrank · 2021-10-31 17:38 Quote from: BobDog on October 31, 2021, 04:15:35 pm Windows. You cannot specify an address, chances are something else is using it. Every process has it's own address space. ---------------------------------------------------------------------- jamie · 2021-10-31 18:04 Quote from: SymbolicFrank on October 31, 2021, 06:38:56 pmQuote from: BobDog on October 31, 2021, 04:15:35 pm Windows. You cannot specify an address, chances are something else is using it. Every process has it's own address space. More or less.  I have a DLL I use for 32 bit processes that uses the FG segment to share a common memory chunk among processes. The problem is I need to use a C compiler to create it because it involves compiler switches that are not supported with fpc or Delphi last time I checked. ---------------------------------------------------------------------- Thaddy · 2021-11-05 07:14 The code by Symbolicfrank is correct. Note the remarks about OS's is not really relevant, because that C code suffers the same limitations: probably only suitable for microcontrollers.