views:

348

answers:

2

As discussed in another question, it's possible to patch cmd.exe to suppress the "Terminate batch job (Y/N)?" message. Patching instructions are available for Windows XP.

Unfortunately, these patching directions are out of date for Windows 7, and I don't know enough assembly to update them. (I do know how to use a hex editor, and was able to follow the directions for WinXP.)

Based on those WinXP directions, how can I update cmd.exe in Windows 7 to fix this obnoxious bug?

+1  A: 

Write a real executable that then runs your bat file and pipes input and output back and forth, obviously not passing Ctrl+Break?

hova
A: 

The author of the webpage gave me replacement offsets:

.text:000000004AD1CF53 48 83 3D 8D 02 01 00 00                 cmp     cs:CurrentBatchFile, 0
.text:000000004AD1CF5B 74 3D                                   jz      short loc_4AD1CF9A
.....
.text:000000004AD1CF5D BA 7B 23 00 00                          mov     edx, 237Bh
.text:000000004AD1CF62 33 C9                                   xor     ecx, ecx
.text:000000004AD1CF64 44 8D 42 AD                             lea     r8d, [rdx-53h]
.text:000000004AD1CF68 E8 E3 7B 00 00                          call    PromptUser
.text:000000004AD1CF6D 83 F8 01                                cmp     eax, 1
.text:000000004AD1CF70 74 0B                                   jz      short loc_4AD1CF7D
.text:000000004AD1CF72 E8 B9 51 FE FF                          call    ResetCtrlC
^F.text:000000004AD1CF77 90                                      nop
.text:000000004AD1CF78 E9 46 54 FE FF                          jmp     loc_4AD023C3
.....
.text:000000004AD1CF7D                         loc_4AD1CF7D:                           ; CODE XREF:
CheckCtrlC+1ABC0^Xj
.text:000000004AD1CF7D 48 8B 1D 64 02 01 00                    mov     rbx, cs:CurrentBatchFile
.text:000000004AD1CF84 EB 0F                                   jmp     short loc_4AD1CF95

In the 64bit win7 cmd.exe that is 0x20 bytes starting at offset 0x1c35d

Dan Fabulich