Skip to content

Commit

Permalink
Improve options
Browse files Browse the repository at this point in the history
  • Loading branch information
pbatard committed Jul 28, 2020
1 parent 3b46cf7 commit dcba646
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 107 deletions.
6 changes: 0 additions & 6 deletions .vs/winpatch.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>false</ExceptionHandling>
<CompileAs>CompileAsC</CompileAs>
<UndefinePreprocessorDefinitions>NDEBUG</UndefinePreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -162,7 +161,6 @@
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>false</ExceptionHandling>
<CompileAs>CompileAsC</CompileAs>
<UndefinePreprocessorDefinitions>NDEBUG</UndefinePreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -177,7 +175,6 @@
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>false</ExceptionHandling>
<CompileAs>CompileAsC</CompileAs>
<UndefinePreprocessorDefinitions>NDEBUG</UndefinePreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -193,7 +190,6 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>false</ExceptionHandling>
<CompileAs>CompileAsC</CompileAs>
<UndefinePreprocessorDefinitions>NDEBUG</UndefinePreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -211,7 +207,6 @@
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>false</ExceptionHandling>
<CompileAs>CompileAsC</CompileAs>
<UndefinePreprocessorDefinitions>NDEBUG</UndefinePreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -229,7 +224,6 @@
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>false</ExceptionHandling>
<CompileAs>CompileAsC</CompileAs>
<UndefinePreprocessorDefinitions>NDEBUG</UndefinePreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down
8 changes: 4 additions & 4 deletions .vs/winpatch.vcxproj.user
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommandArguments>F:\Windows\System32\drivers\USBXHCI.SYS EA000037E8630091 EA000036E8630091 0A010037E8430091 0A010036E8430091</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>-o F:\Windows\System32\drivers\USBXHCI.SYS EA000037E8630091 EA000036E8630091 0A010037E8430091 0A010036E8430091</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerCommandArguments>F:\Windows\System32\drivers\USBXHCI.SYS EA000037E8630091 EA000036E8630091 0A010037E8430091 0A010036E8430091</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>-o F:\Windows\System32\drivers\USBXHCI.SYS EA000037E8630091 EA000036E8630091 0A010037E8430091 0A010036E8430091</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommandArguments>C:\tmp\USBXHCI.SYS EA000037E8630091 EA000036E8630091 0A010037E8430091 0A010036E8430091</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>-o C:\tmp\USBXHCI.SYS EA000037E8630091 EA000036E8630091 0A010037E8430091 0A010036E8430091</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommandArguments>C:\tmp\USBXHCI.SYS EA000037E8630091 EA000036E8630091 0A010037E8430091 0A010036E8430091</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>-o C:\tmp\USBXHCI.SYS EA000037E8630091 EA000036E8630091 0A010037E8430091 0A010036E8430091</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,36 @@ Usage
-----

```
winpatch target <SEARCH> <REPLACE> [<SEARCH> <REPLACE> [...]]
winpatch [-bhosw] FILE [HEXVAL HEXVAL [HEXVAL HEXVAL [...]]
```

Where:
* `target` is the path of the system file you want to patch.
* `<SEARCH>` is a hex string that matches the original data you want to patch.
* `<REPLACE>` is a hex string containing the data you want to replace it with.
Where HEXVALs are paired values containing the hexadecimal data to
search for, followed by the data you want to replace it with.

The hex strings can be of any length between 2 and 128 bytes, as long as the `<SEARCH>`
and `<REPLACE>` strings that make one pair are of the same length.
HEXVAL can be of any size between 2 and 128 bytes. You can mix and
match sizes, as long the value sizes in each pair are the same.

Subsequent pairs are not required to have the same length as the previous one, meaning
that you can issue something like `winpatch driver.sys ABCD 9090 12345678 00000000`.
No specific alignment is required for the HEXVALs, meaning that
winpatch can match a word value starting at an odd address.

The hex values should be provided in the same byte order as the one you see from a
hex-dump of the file, i.e. big-endian.
Values should be provided in big-endian mode i.e. in the same byte
order as the one they appear with in the hex-dump of the file.

No specific alignment is required on the data, meaning that `winpatch` will match and
patch data that start on a odd byte address for instance.
Unless you use option -w, winpatch will warn (once) if multiple
instances of a specific HEXVAL pair are patched.

The exit code of winpatch is the number of qwords that were successfully patched (`0`
if none) or a negative value on error.

Options
-------

* `-h`: Show help
* `-b`: __DON'T__ create a backup before patching the file (DANGEROUS).
* `-o`: Overwrite the source with the backup (if any) before patching.
* `-s`: Update the digital signature only (Don't patch).
* `-w`: Don't warn when multiple instances of a patch are applied.

Example
-------

Expand Down
Loading

0 comments on commit dcba646

Please sign in to comment.