Source code of samsung-touchwiz is not available to public to download and use. But there are custom roms which have touchwiz UI available .How do touch-wiz based roms like Salman rom work without having samsung touch-wiz code?
Samsung allegedly releases the kernel sources, allowing a developer to customize and compile a kernel. Since they can also download the binary ROM (or copy it from their device), they can use their kernel as a drop-in replacement in the TouchWiz ROM--providing their changes didn't break the communication with the drivers. They normally don't touch the drivers or the userland apps, just the kernel.
Alternatively a user can tweak the default ROM by adding apps and/or themes ('kitchen work'). This has little real value to consumers and is not considered original development.
In the days I used to play with ROMs, there used to be some system folder (I think
system/app) that contains .apk files (installer files). You'd need root and access to these folders to replace a non-working Market/vending/Play or Camera application, or TouchWiz (if memory didn't fail me).
So, I think it's just a matter of copying the .apk and including it in the system folder.