Pointer types! Help!
BlitzMax Forums/BlitzMax Beginners Area/Pointer types! Help!
| ||
i decided to work on blitzmax because Blitzplus cannot handle pointers. But its not without troubles =O This is mainly to display some values stored in my computer, out of my program. (I hope you will understand, i am not speaking english very well) Local MyPointer:Int Ptr = 1500 The error is : Unable to convert from 'Int' to 'Int Ptr' What should i do? EDIT : solved, the new problem is to find a way to retrieve a value stored out of the BMX process ... check the lasts posts for details. Impossible? could htmlview bypass that problem, seeing the game i play is a java online game? |
| ||
From the doc : Pointers Pointers are intended for use by code that must perform low level interaction with the operating system and/or speed sensitive code. Pointers are not recommended for general use, as misuse of pointers can easily result in memory corruption causing all sorts of bugs and headaches! Pointers are declared by appending Ptr to the type of a variable or function parameter declaration: Local int_ptr:Int Ptr The VarPtr operator allows you to find the address of a variable, yielding a pointer: Local an_int=10 int_ptr=VarPtr an_int Array style indexing is used to dereference pointers: Print int_ptr[0] BlitzMax also supports pointer arithmetic, using the standard + and - operators. Is this what you're after? If not you can cast the int to an int ptr.. Local pointer:int ptr = int ptr(1500) |
| ||
yes i found that part of the doc, but actually you just have been more helpful than it :) wow, pretty simple, thanks! And by the way what is the simplest way to convert an hexadecimal value to a decimal value? [Edit] found the '$' symbol for coding, is there any simple way to convert a hex in a string to a decimal value? |
| ||
n = "$FF".ToInt() |
| ||
Wow! This is awesome! thanks again :D [EDIT] Sometime i get the message : "Unhandled Exception:Unhandled Memory Exception Error" Does this mean i am unable to read everything i want? |
| ||
Yes. If you are using my casting example then, effectively, you are trying to find the value pointed to by 1500 which does not exist. |
| ||
I have proven the existence of a certain value using another software ( Artmoney ) i can see the actual value changing in this software as well as seeing it changing it in my game. but i still get that Unhandled Memory Exception Error in blitzmax. |
| ||
OK, this is getting confusing. Post the code you are using and what you're trying to do. |
| ||
This is pretty simple Sometimes when playing a mmorpg game an important value must be watched on critical situations. If it falls to 0 you are more likely to die before attempting to raise it back. The problem is : i oftenly forget to watch this value! the aim is : create a program which beep when this value get close to 0! and to be started, i only need to retrieve this value into my program using Artmoney, i can easily find the adress of that value. i then use it into my program (very short and simple, for a start) Strict Local pointer:Int Ptr = Int Ptr(284079592) Print pointer[0] i get the message : "Unhandled Exception:Unhandled Memory Exception Error". |
| ||
Local pointer:Int Ptr = Int Ptr(284079592) Aren't you trying to cast an int as an int ptr here rather than a pointer to an int? SuperStrict Global value:Int = 284079592 Local pointer:Int Ptr = Varptr(value) Print pointer[0] |
| ||
So the address you have is not the address of a Bmax variable in your Bmax program and your Bmax addressable area? Is the address an Int? I don't even think Bmax can address memory outside it's own address space. |
| ||
284079592 is the current pointer to the value which should return 70 when my ingame bonus is full. 284079592 is $10EEB5E8 which i believe is the same thing. they are both the adress to the value i wish to retrieve from my game. Edit : you may be right, its writen to be a 4 octet var. let me check the doc... Its not a Blitzmax variable indeed. =( Edit : if Bmax can't do it, can C do it? and in this case, can i import a C function to bypass the problem? Edit3: My brother yelled me to play with him, i will take a break for now ;) thanks for your help. |
| ||
You need to have proper access to be able to read/write to memory outside your own process. If your on windows, check out these: VirtualQueryEx ReadProcessMemory |
| ||
"out of process" hum? what if the game is played using htmlview like i did with B+? (Its a java game) |
| ||
What makes you certain the address will never change? |
| ||
I previously studied carfully with Artmoney how everything is going. |
| ||
what if the game is played using htmlview like i did with B+? (Its a java game) Java programs runs inside the JVM, so still another process. You should be extra careful when doing this to Java programs, as the JVM can move memory around at any time to make room for other stuff, so there is no guarantee the variable will stay at the same place. |
| ||
Studied on every computer? The operating system decides where programs are run in the memory, you're just asking for trouble by using absolute addressing. |
| ||
grable > I selected my own bmax process to search the value for and found it :/ I am absolutly sure its the right adress i find, because Artmoney refresh its finds and the value found exactly match the real one. Azathoth > Its ok, i am searching the value each time i log in the game. I do not wish to give it away, its only a personal feature i would like to use beside the game. |