Are you trying to say that if you know all the legal moves, then all other moves are illegal? I don't see how it's possible to make an illegal move in this game unless if a column is completely filled.
So if legal moves are known then the illegal moves are all moves- legal moves
You can use a similar method to what I wrote above for using strings. Start at the last row string and test each char against the value that represents an empty space. Then, I guess take these moves found and test them for the legal status, whatever that is.