Search found 2138 matches

by dbenham
28 Nov 2018 09:13
Forum: DOS Batch Forum
Topic: How to I replace " by ' " (at the start and end of a string in a variable)? Doubling Backslashes?
Replies: 4
Views: 73

Re: How to I replace " by ' " (at the start and end of a string in a variable)? Doubling Backslashes?

The body of the question asks for a result of 'D:\\foo\\bar\\aaa\\bbb.txt' , but the title implies he is looking for ' "D:\\foo\\bar\\aaa\\bbb.txt" ' . (Note extra space added to differentiate between the single and double quotes) To strip the double quotes, just modify Aacini's answer by one additi...
by dbenham
12 Nov 2018 14:07
Forum: DOS Batch Forum
Topic: Can I get access to an ascii character not in the standard set?
Replies: 36
Views: 3308

Re: Can I get access to an ascii character not in the standard set?

All the code-page changes and UTF-8, UTF-16, etc. file encodings stuff is used when a program wants to display a non-Ascii character on the screen. Just to be clear: an Ascii character is one in the 0-255 range that is correctly displayed in all code pages (although some code pages show some charac...
by dbenham
01 Nov 2018 04:57
Forum: DOS Batch Forum
Topic: Can I get access to an ascii character not in the standard set?
Replies: 36
Views: 3308

Re: Can I get access to an ascii character not in the standard set?

I'm pretty sure this is a planned feature of the new Windows 10 console, but I don't understand the rationale. It appears that certain code pages are incompatible with raster fonts within the new console unless you force the console into "legacy" mode. I reported this at https://www.dostips.com/foru...
by dbenham
30 Oct 2018 22:10
Forum: DOS Batch Forum
Topic: replacing a hex sequence in a binary file with a hybrid .bat?
Replies: 18
Views: 1927

Re: replacing a hex sequence in a binary file with a hybrid .bat?

Bad news about use of FINDSTR to output the remainder after the last substitution - it is unreliable because FINDSTR cannot process lines greater than 8191 bytes long when the input is piped or redirected. I've got a pair of patchBin scripts based on CERTUTIL that work very well, and are reasonably ...
by dbenham
25 Oct 2018 04:00
Forum: DOS Batch Forum
Topic: replacing a hex sequence in a binary file with a hybrid .bat?
Replies: 18
Views: 1927

Re: replacing a hex sequence in a binary file with a hybrid .bat?

Oops, I spoke too soon. I didn't read your code carefully enough to realize you rely on the offset address to identify the lines to modify. Also, those offsets don't work for my version of cmd.exe (Windows 10) When I ran your posted code it successfully made the changes at your offsets, but who know...
by dbenham
24 Oct 2018 22:35
Forum: DOS Batch Forum
Topic: replacing a hex sequence in a binary file with a hybrid .bat?
Replies: 18
Views: 1927

Re: replacing a hex sequence in a binary file with a hybrid .bat?

I like it :D Once I saw your idea to use CERTUTIL, I began thinking of all the optimizations that could be done, and you hit all that I could think of, especially the use of SET /P to read through all the changes, and FINDSTR to read/write the remainder. I'm not sure this makes a substantive differe...
by dbenham
24 Oct 2018 19:46
Forum: DOS Batch Forum
Topic: replacing a hex sequence in a binary file with a hybrid .bat?
Replies: 18
Views: 1927

Re: replacing a hex sequence in a binary file with a hybrid .bat?

Here is how JREPL could do your example task, assuming your offsets are 0 based:

Code: Select all

call jrepl "([\s\S]{84750})\x37\xAC([\s\S]*)" "$1\xB9\x92$2" /m /xseq /f original.ori /o egroff.bin
Dave Benham
by dbenham
24 Oct 2018 14:22
Forum: DOS Batch Forum
Topic: JREPL.BAT v7.15 - regex text processor now with Unicode and XRegExp support
Replies: 401
Views: 143099

Re: JREPL.BAT v7.15 - regex text processor now with Unicode and XRegExp support

Both the /EXC and /INC options are dependent on JREPL reading the input file one line at a time. But JScript does not read lines containing NULL properly. The /M option reads the entire file into memory, and is able to properly read NULL bytes, but is limited as to the size of the file that can be p...
by dbenham
24 Oct 2018 10:29
Forum: DOS Batch Forum
Topic: replacing a hex sequence in a binary file with a hybrid .bat?
Replies: 18
Views: 1927

Re: replacing a hex sequence in a binary file with a hybrid .bat?

@stondesign Please learn to use [ code][/code] blocks for showing code. It is much easier to read. The syntax is horribly wrong in the commands that you listed. For example, there is never a space after the / when specifying an option. For example, it should be "/m", not "/ m". And your hex strings ...
by dbenham
24 Oct 2018 05:36
Forum: DOS Batch Forum
Topic: replacing a hex sequence in a binary file with a hybrid .bat?
Replies: 18
Views: 1927

Re: replacing a hex sequence in a binary file with a hybrid .bat?

Of course - simply substitute the file name (file path) for the dash in the /O option. I assume you have not yet gotten a copy of JREPL. Before you ask too many questions, be sure you read the built in help. Below are a few useful help commands to get you started. JREPL /?? - All available help, one...
by dbenham
20 Oct 2018 21:36
Forum: DOS Batch Forum
Topic: JREPL.BAT v7.15 - regex text processor now with Unicode and XRegExp support
Replies: 401
Views: 143099

Re: JREPL.BAT v7.15 - regex text processor now with Unicode and XRegExp support

Here is version 7.15 JREPL7.15.zip Summary of Changes C:>jrepl /?history 2018-10-20 v7.15: Add a string literal syntax to the /INC and /EXC options. The new string literal syntax does not add any capability, but rather makes it easier to look for string literals because regular expression meta char...
by dbenham
19 Oct 2018 15:18
Forum: DOS Batch Forum
Topic: Multiple Echo statements within a Code Block crashing cmd.exe
Replies: 9
Views: 656

Re: Multiple Echo statements within a Code Block crashing cmd.exe

Here is a really simple script that uses CERTUTIL to encode any binary file as base64 and then embeds that into a batch file that will recreate the original file when run. The resultant batch file is only ~1.4 times the original binary size, and both the encode and decode operations are very fast. e...
by dbenham
17 Oct 2018 15:07
Forum: DOS Batch Forum
Topic: Multiple Echo statements within a Code Block crashing cmd.exe
Replies: 9
Views: 656

Re: Multiple Echo statements within a Code Block crashing cmd.exe

Perhaps the code block limit is not a constant. It could depend on available memory, .... ? I remember that the stack size limit for the total number of CALLs is also unpredictable.

How is the called :proc performance compared to the FOR performance?
by dbenham
17 Oct 2018 14:31
Forum: DOS Batch Forum
Topic: Multiple Echo statements within a Code Block crashing cmd.exe
Replies: 9
Views: 656

Re: Multiple Echo statements within a Code Block crashing cmd.exe

Have you tried the called :proc technique instead of the code block?