If you did not consent to a search of your body he can only pat you down for weapons. He can't search your pockets if he doesn't have cause to believe there is a weapon. I'd say you have a good case if properly represented.
As the previous poster states, you cannot be searched unless you consented to it. Your friend would not have had the authority to consent to you being searched You should contact an attorney immediately to review your case in greater detail and get the best possible outcome for you.
Feel free to contact me if you wish.
Legal disclaimer: Mr. Tabaku may be reached at (240) 750-4663 or email@example.com. Mr. Tabaku is an attorney licensed in the state of Maryland. This answer is for general information only based upon the facts stated in the question and does not create an attorney client relationship between Mr. Tabaku or Tabaku Law Firm, LLC and any person. You should schedule a consultation with an attorney to discuss the specifics of your legal issues.
It sounds like a really bad search, way past the allowable pat down for officer safety. These cases can be handled many ways, first by your lawyer convincing the State's Attorney's Office to drop the charges based on the incident report which may, or may not, show the unreasonable basis for the search; or, failing that, a motion to suppress the search made at trial, with a favorable ruling by the judge. then again, police officers are known to lie, or embellish the facts enough, so as to establish a probable cause basis for, or even allege that you consented to, the extended search. Assuming that this case is in Montgomery County, and is a first offense, you would also be eligible to complete a diversion program without having to risk going to trial, and will result in the dismissal of the charges in exchange for you completing community service hours and a drug class. Even were you to go to trial and be found guilty, you would almost certainly be able to avoid a conviction or record of guilt. Call a criminal defense lawyer and take care of these charges so that you do not end up with a record and you get these charges expunged from public view and removed from any background checks.