phecdaDia / PyNTR

PyNTR
8 stars 2 forks source link

Unable to read data. #1

Open shadowofdarkness opened 7 years ago

shadowofdarkness commented 7 years ago

edit I realized even though I had python3 installed I was accidentally using python27 but I still can't get it to work but with a different error so I'm changing this. Now I just need to know how to not have it convert anything and just show the hex data or even a way to have it dump the data to a file.

I'm trying to get this to read a u16 value and just display the original hex value for me. But I can't even get it to read correctly. I have it working with the original NTR debugger but want this script so that I can have it loop automatically in a bash script to watch the value change.

My script so far

from PyNTR import PyNTR client = PyNTR('10.0.0.4') client.start_connection() client.set_game_name('trl') data = client.ReadU16(0x0892fd19)

New output when running it

Connecting to 10.0.0.4 Sending Heartbeat Packet Sending Processes Packet Sending Heartbeat Packet Sending RMemory Packet -1 0892fd19 2 Traceback (most recent call last): File "blue.py", line 20, in data = client.ReadU16(0x0892fd19) File "/home/user/PyNTR/PyNTR.py", line 155, in ReadU16 return self.ReadCustom(addr, 2) File "/home/user/PyNTR/PyNTR.py", line 149, in ReadCustom self.send_read_memory_packet(addr, length) File "/home/user/PyNTR/PyNTR.py", line 115, in send_read_memory_packet self.send_packet(0, 9, [self.pid, addr, length]) File "/home/user/PyNTR/PyNTR.py", line 79, in send_packet packet_header.extend(args) OverflowError: can't convert negative value to unsigned int

phecdaDia commented 7 years ago

Made an update that added the methods Read16 that will return a signed number. I can't test it at the moment so I'd be happy to hear some feedback if the update worked for you.

shadowofdarkness commented 7 years ago

I'll test as soon as I get home and hopefully I get useful info. Technically what I'm reading isn't a 16 bit value but four 4 bit ones.

What I'm reading is in the generation 1 Pokemon VC games. It's specifically the wild encounters DV's (old version of IVs) with reach but being two different ones. It I saw a f6 a3 in a hex editor depending on byte order it would mean a 15 in attack 6 in defense a 10 in speed and 3 in special

phecdaDia commented 7 years ago

You could try to get the raw bytearray if you want to by doing PyNTR.send_read_memory_packet(addr, length) and then to read the actual data PyNTR.read_packet()

shadowofdarkness commented 7 years ago

I'm trying to figure out how to do that now, but since I'm not a programmer of any language I'm not having much luck.

shadowofdarkness commented 7 years ago

I have it working now, not the cleanest way but after figuring out it wasn't even connecting to the right pid I got it working by editing PyNTR.py and changing the default self.pid from "-1" to "0x29" then it did output a result that was converted to decimal. I did want raw bytes though and couldn't figure that out so I found how to convert it back after the fact. I just run the following on the Linux command line

printf '%x\n' python3 dv.py | tail -1

phecdaDia commented 7 years ago

I was just trying to write a small program as example and noticed that your pid wasn't set properly. Make sure the games name is correct. You have to use the internal name.

shadowofdarkness commented 7 years ago

How would I find that correctly then I assumed it was the pname from a listprocess() since when I loaded the m4hu demo as a test case the redgiant from the example was in that spot.

pid: 0x00000029, pname: trl, tid: 0004000000171100, kpobj: fff7bb40

phecdaDia commented 7 years ago

Hmm. that's weird.. Which game is "trl"?

shadowofdarkness commented 7 years ago

That is the Pokemon Blue VC release.

PS I have already had luck and this setup has already got me a shiny from soft resetting. My script pulls the data from RAM with PyNTR then compares it against a preset list and if it matches any it plays a shiny sound audio file. If not just loops to the beginning of the script.

shadowofdarkness commented 7 years ago

I figured some of it out apparently the name is not "trl" it is " trl" with the extra white space. I also got it to print out the hex using the following, I needed to add a ".hex()" to make it readable and to stop the regular output from sometimes showing only partial info for some strange reason.

client.send_read_memory_packet(0x0892fd19, 2) print(client.read_packet().hex())

The only thing that now confuses me is that the byte order isn't consistent across games. For Blue it showed the proper byte order but when I tried a similar setup for Moon to quickly extract the egg RNG seed it shows it in reverse byte order.

Why the inconsistency outputting it when both games have it in reverse in RAM