Imagine a magic spell could allow to negate the firearms we know (edited) AND USE TODAY: what would be the one chemical process that operating in all of them needs to be blocked? If not, what would the exceptions or alternatives be? Which one the simplest?
The TL;DR answer is to prevent the oxidizer from reacting with the fuel in the bullet and/or gun, preventing combustion and thus the gun from firing.
The full answer is a bit more complicated because there are multiple ways to create the pressure needed to shoot a firearm. The general way a firearm does its thing is through combustion and it is that reaction that our anti-gun magus wants to target.
Common gunpowder, or black powder, commonly uses three things to make the reaction: Saltpetre (potassium nitrate), charcoal (carbon), and sulphur. When ignited, chemistry happens -- the reactants burn and release energy, which allows the reaction to continue until there is nothing left. The pressure has nowhere to go but out the barrel, pushing the projectile that is in its way out of the barrel at the same time.
In the Wikipedia article for gunpowder, there are a couple of reactions using the three components of gunpowder in different ratios. The solid products might be different, but both of the reactions generates carbon dioxide and nitrogen gas. The oxidation of the carbon is the thing you want to stop in this case. The nitrogen is a side effect of the nitrate being broken apart.
In this particular case, your spell needs to stop the saltpetre part of the powder from reacting. If the potassium nitrate in the powder can't react, then there is no bullet flying out.
If we use the idea of "Prevent Saltpetre from reacting chemically" as the base of the spell, then the first problem that can be seen is that any firearm that does not use that particular chemical as the oxidizer will work just fine. This might be an acceptable risk because gunpowder is the only thing firearms use in your world and it should always use it. It can also become an issue at a later date as people try to work around your anti-firearm spell by using different propellants for their arms, like guncotton for one.
If you make the spell too broad, say "Prevent oxygen from reacting chemically", then the spell will not be just be used to prevent firearms from firing, but it will be used to kill people by preventing the oxygen in the blood from reacting with the body. IT would be a lot of collateral damage just to make sure a gun can't go off.
The other concern is that depending on the knowledge of the caster, and/or the setting, the people that are creating the anti-firearm spell might not even know the proper way to refer to what they want to stop. This is neither a good nor bad thing, but something to take into account. If all the wizard knows is that gunpowder burns, and his spell is "Prevent things from burning themselves", then more than just firearms could be affected by the spell.
What your spell can and can't do based on its parameters is going to be a function of your magic system. While not perfectly relevant, it will determine how specific one will need to be to get the effect desired -- an anti-firearms spell.
From my limited research, if the tool uses compressed gasses to fire a projectile, it is an considered an air gun and not a firearm. However, it is noted that air guns can shoot things and cause real damage too. Along with that, there is no chemical reaction in an air gun that can be stopped to prevent them from firing unlike a firearm.
Water and oxidation
If you stop combustion, you'll keep the gun from shooting. In olden times, soldiers put considerable effort into keeping their gunpowder dry. That's because it's hard to ignite wet powder. Modern bullets are much better protected against moisture than powder horns, but they're still vulnerable. If you could cast a spell to put water inside of a bullet, most firearms would be rendered useless.
Here are two other considerations that might be useful in your story.
Another approach would be to oxidize the primer in the bullet. Basically damage it so the hammer strike from the firearm doesn't cause it to detonate.
If you're looking for a magically weak point in the firearm and not the bullet, damage the firing pin. It's often much weaker than other parts of the weapon. Anything that could damage the piece in the photo would disable a military M-16.
The Trigger by Arthur C Clarke and Michael Kube-McDowell is a sci-fi book which explores the implications of a similar 'spell' - a device which causes the premature detonation of (nitrate-based) explosives in its vicinity. Being Clarke and hence very hard sci-fi, the ramifications - and limitations - are quite carefully determined. Firstly as noted elsewhere, this is not the only chemical structure used in modern explosives (although it does cover the overwhelming majority of common firearms), and alternatives are quickly developed that are not susceptible, merely perpetuating the eternal arms race between offence and defence. Secondly, it only requires the application of human ingenuity to transform a defensive tool into an offensive one.
A spell which had the effect of exciting nitrate bonds just enough to detonate explosives, without causing substantial disruption to more stable nitrate-laden structures (like animals) is perfectly plausible, and this would have the effect of neutralising most current firearms. The fact that such a spell is not a universal panacea is probably a good thing, from a storytelling perspective.
As the name indicates, the gunpowder is oxidized. You need to stop that.
(As a sideline, oxidizing fats, proteins and carbs is how your body fuels itself, so if you want to stop the gun and not gunner, you need to inhibit not oxidization in general, but that of gunpowder.)
Alternate approach: change the properties of air. Thixotropic or 'shear-thickening' materials like a mix of cornflour and water famously behave differently in response to impacts at different speeds. A spell that increased the binding energy of air would not impair normal movement or microscale movements, but would meant that any bullet-sized projectile moving at more than (say ) 30 m/s would be trying to move through treacle and would immediately become ineffective after a few metres.
Such liquid materials are already being used experimentally for bullet-proffer protection (for example, making batteries bulletproof), a shear-thickening gas would be an extension.
Fooling around with smokeless powder
A modern cartridge is a brass case with primer, a metal bullet (often containing lead) and a filling of granulated nitrated organic compound(s). If your spell, targeted to such cartridges, converts the filling to a fine powder, it enhances the pressure rise at combustion, destroying the weapon and injuring the user. On the other hand, you could solidify the powder, creating a solid rocket engine. It could create just enough pressure to push the bullet out of the barrel, dropping it harmless on the ground, followed by another second of flame.
How to deactivate gunpowder
Sulphur, charcoal and saltpetre are mixed physically. They are loaded into a gun behind a lead bullet. Your spell targets this exact situation and orders the components to separate. If you have some energy to spare, melt the sulphur and solidify it as a membrane separating the other components. If someone wants to blast your fortification with a mine, create a guardian spell with similar workings.
A spell to limit the rate of reactions, or the rate of the change in pressure, or perhaps just not allow the pressure to go over a certain value - perhaps several atmospheres.
If you still want chemistry to work, perhaps something just changes the rate at which reactions occur, could still allow reactions up to a certain energy to work, but limit other ones. That could still potentially have some pretty bad side effects since a lot of reactions are limited by the amount of materials that come into contact with each other, for example being limited by diffusion.
So an alternative would be to target the rate of change of pressure and not allow it to change faster than a certain amount. Just when the gun-powder explodes instead of the pressure building up in the barrel, the magic in the area relieves the excess pressure to another dimension or something. Everything would kind of still work, but the bullet might not have enough force to leave the barrel, or just pop out at a fairly low velocity.
Rust Never Sleeps
Neither does Entropy. Accelerate entropy and you can kiss that firearm problem goodbye.
One thing almost all firearms have in common is the barrel. This is almost always made of steel. It may be protected in various ways, because rust can either cause problems in the barrel or may weaken the entire structure. There is all kinds of materials in firearms from plastics to aluminum, but the barrel is almost always steel and therefore at least partially iron.
So tailor an entropy spell that rusts iron. Even better if you can make it target Lead and Copper too. Rusting out the barrel will weaken the structure making the weapon dangerous to the person trying to fire it. It will may cause the barrel to swell, making it potentially explode behind a blockage. Not a good thing.
In addition, targeting the metals most often used in projectiles is a good thing. Lead is what gives a slug mass, but it's a soft metal. That's why it is often jacketed in copper, so it will hold it's shape as it flies so you have more range and better penetration, or to get it to do thing on impact, like mushrooming out like a hollow point. Sometimes it will also have steel incorporated to make it armor piercing. Sometime environmentally conscious hunters will use steel shot in shotgun shells when hunting, so as not to cause lead problems in the wetlands. The purpose of using entropy on these metals is to make them too weak to hold together as a coherent projectile. The energy will get dispersed over thousands of particles rather than one cohesive whole. It will likely make the round sting, but not be lethal. Also, if the triggermen are cheap, they may try to save a few bucks, they may be silly enough to buy rounds with steel casings. Degrade the casing and the powder dribbles out and it won't have a good chamber to burn in propelling the projectile down the barrel.
So target the 3 metals. Oxidize them, and your problem gets dramatically reduced.
To prevent modern firearms from firing use a spell to transmute the mercury fulminate used in primers. Without a working prime the guns will not fire. This would not affect more primitive firearms like flintlocks or matchlocks. Eventually other type of primers would be developed.
Water is the enemy of flintlocks and matchlocks. Wet gunpowder in the firing pans will not ignite. A sudden rain storm will make them much less likely to fire.
You could also cast a spell to simply plug the barrel. The gun would explode when fired.
more subtle would be a spell to warp the barrel. The gun would still fire, but most likely miss. This would not be effective at short ranges and would be less effective against weapons like shotguns or automatic weapons where the fire could be walked on to the target.
Similar would be spells creating high winds or altering gravity.
Another possibility is to cast a shield against fast moving objects. Thinks of the personal shields used in "Dune".
A microportal is a tiny
wormhole sphere-shaped portal that leads to the plane of air, small enough to be invisible to the unaided eye. The spell creates an array of such microportals throughout the space. They are big enough for gases to pass through, but they automatically close when they detect a solid or a liquid. The spell has a variety of uses:
- In the
default settingmost commonly taught form, they operate as a pressure relief valve. That is, while they won't prevent any fire from generating excess gas, they will happily remove that gas from the material plane as soon as it is produced. This wastes the would-be shooter's ammo, notifies everyone to their intent (it's not as loud as regular gunshot, but still very perceptible), and nullifies the deadly effect of any firearm or airgun within the affected area. Because of its general beneficial use, this version of the spell is also available in a totem form. Still expensive, but less so than hiring a human mage.
- If the pressure differential needed to open the valve is reduced, this allows free exchange of gas between the two planes, and allows the spell to be used for general purpose ventilation. It's still expensive to maintain (can't maintain concentration 24/7) so it doesn't replace regular windows, but for an underground bunker for a couple of VIPs, it will do.
- When the area of effect is reduced, this makes the cost more manageable. Small arrays will have found use as a form of water breathing for advanced mages - and, much later in the future, in the medical field.
- Blood mages have learned how to make bigger portals, big enough to let liquids through, and how to make them spawn inside the liquids. As kids, they use it to empty people's cups, produce bubbles in bathhouses, and other minor nuisance, but soon they figure out where the most interesting liquids are. Remove blood from a person's arm and it hurts like hell, but remove blood from their head and they fall unconscious. Naturally, this practice is punishable by death in every civilized kingdom, considered a form of torture by the UN, and forbidden multiple times in the Geneva convention. Also, it is the preferred way of slaughtering animals for food, though still economically nonviable for the vast majority of producers due to extremely tight governmental regulations for the casters.