ERCP is performed using a flexible tube called an endoscope, which is passed through the mouth into the duodenum. A contrast dye is injected into the bile and pancreatic ducts, allowing for detailed imaging. This process helps in identifying blockages, strictures, or tumors that may indicate the presence of cancer.