| h4344 (43) | |||
|
Im trying to read a memory address that contains text. However when i do
My program just crashes on startup The array in my struct is char race1[3];I have no idea what im doing here since i rarely use "char". But pretty much im just trying to get the data from that memory address into a string variable. (The actual address is different from all zero's) | |||
|
Last edited on
|
|||
| webJose (2948) | |
| You are trying to read memory address zero, and that's illegal. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms680553(v=vs.85).aspx for proper usage of the ReadProcessMemory() function. | |
|
|
|
| andywestken (1966) | ||||
#1 This
makes is sound like your program crashes immediately after launch. Before it could have gotten to your code. I take it this is not the case? #2 If you want to set a char buffer to "Non" then you need memcpy(datakey.race1, "Non", 3); or
Note: that if you want to display "Non" as a C-string, you need to add space for a null terminator. And then you can use strcpy() instead of memcpy() #3 Is the string you're trying to copy null terminated? Andy PS changing the example address to something other than zero might space some confusion? or use a variable (e.g. mem_addr?) | ||||
|
Last edited on
|
||||
| Computergeek01 (2874) | |
| If "datakey.race1" is an array then you shouldn't have to pass it by reference. This function only needs a pointer that is cast to void, not a pointer to a pointer. | |
|
|
|
| andywestken (1966) | |
|
@Computergeek01 Isn't it the address-of operator in this context, rather than a reference? | |
|
|
|
| Computergeek01 (2874) | |
| @ andywestken: Yeah, it would mean the OP is passing the pointer to the pointer of the beginning of the array. Did I write that wrong? It's one of those things I have trouble putting into words. The OP still needs to delete it right? | |
|
Last edited on
|
|
| andywestken (1966) | |
|
Write it wrong? No. I don't think delete is needed here. ReadProcessMemory will copy into the memory provided (the 3 bytes in the race1 array) if the & is lost (or &datakey.race1[0] is used) But I think you're right that the address is needed rather than the address of the address. | |
|
Last edited on
|
|