Ds is like this, has been since he was about 18mths old.
He cries so much that i cannot give him any meds orally as he brings them straight back up. We took him to the gp and she examined him very well, watched him walk etc and said that she was sure it was either growing pains or cramps and to make sure he had a good diet. She also gave us ibuprofen gel to use on his legs if he wakes in the night, but you can only use a tiny tiny amount and it doesn't always work.
I am almost 100% he has the same thing i used to get. From when i was about 5 i can remember getting pains in my legs, they would ache from my feet up to my knee, with my knees being the worst, and i could get it in one or both legs, and i used to wrap my leg in my dressing gown and stuff it down the side of my matress and eventually the pain would go. I am positive this is what ds has.
I think it is restless leg syndrome, and i googled it once and a study was done in america that showed that it can run in families, particularly when the mother of the child has had it.
Tbh i don't think there is alot you can do, but i know ds always gets it if he does certain things like, have socks on all day and then have an hour of running around bare foot. Sounds odd but can garuntee then that on the night he will have restless, painful legs. Oh and ds now wears socks to bed every night which helps.
If he wakes with it, i put him in with me and i have to rub or hold his legs very tightly before he can drop off again.