Skip to content

Update /validator/v1/validate to handle payload types 1 and 2 - #7

Draft
jonbarrow wants to merge 4 commits into
masterfrom
feat/validator-structures
Draft

Update /validator/v1/validate to handle payload types 1 and 2#7
jonbarrow wants to merge 4 commits into
masterfrom
feat/validator-structures

Conversation

@jonbarrow

@jonbarrow jonbarrow commented Jul 29, 2026

Copy link
Copy Markdown
Member

Resolves #XXX

Changes:

Updates ValidatorV1Validate to match my latest findings in Pokemon X. This endpoint is used for at least 2 operations. The current implementation only supports payload type 1, this adds support for type 2

The following changes were made:

  • Moved the POST body parsing to dedicated functions that populate classes, rather than reading the fields out one by one
  • Add support for the "type 2" payload structure. Note that I actually couldn't get this to accept any payloads I gave it. I'm not sure why, it SHOULD be encrypted Pokemon data just like type 1 but it always says the team is illegal (the data parses, it's just marked as illegal). The data is valid though, the official server responds that it's fine. Unsure if this is an issue with PKHeX or with our server? Either way, I tested the same requests against the current version of the server and they also fail there for the same reasons, so I'm not counting this as a regression. I can attach some example payloads if that would help?
  • Add support for more than 1 set of Pokemon data. This is a bit of a guess, since the response handler seems to handle things as a list. I assume the request is also a list, and it lines up so I'm going with it
  • Create the responses correctly, populating the list as expected and such

I used Charles to replay existing requests to test these changes and didn't see any regressions, but I have not tested in-game, as a disclaimer. But the Charles testing should be enough? I'll still leave that box unchecked though

@jonbarrow

Copy link
Copy Markdown
Member Author

Hold off on merging this, marking as draft. Someone on Discord just sent in a dump that has a payload type 3 now too. I want to look into that

@jonbarrow
jonbarrow marked this pull request as draft July 29, 2026 03:28
@jonbarrow

Copy link
Copy Markdown
Member Author

Okay I did some digging in Azahar because I kept running into a wall in Ghidra. In Ghidra when checking the main executable, I could actually only find a reference to payload type 0x400, yet another unseen type. After getting GDB Stub working in Azahar I learned that there's other calls to these functions inside some CROs, and I started poking around there. I managed to find what I think are all the payload types? I haven't tested most of these at runtime, I only checked the files in Ghidra and looked for the call patterns

  • 0x100 - I personally saw this when doing a Wonder Trade in Azahar (and is the only one I've personally seen at runtime), I believe this is triggered in DllRandomTrade. Also appears to be used by DllGts
  • 0x200 - Appears to be used by DllGts
  • 0x300 - Appears to be used by DllTradelist. Discord user watermelongoburin also submitted a dump last night showing this being used in a non-Wonder Trade trade
  • 0x400 - Appears to be used by DllBattleMatch
  • 0x500 - Appears to be used by DllBattleVideoPlayer

Additionally, it seems like every single payload is just the plain encrypted Pokemon data except for type 1. The game seems to have an explict check for that. So I think I can simplify some things relatively easily

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant