flat assembler
Message board for the users of flat assembler.

Index > Tutorials and Examples > Byte Locate

Author
Thread Post new topic Reply to topic
greco558



Joined: 21 Jul 2016
Posts: 35
greco558 30 Nov 2017, 19:44
I had an idea the other day, kind of a companion program to my Byte Count program posted here.

I don't know if the program is much use for anything, but it was something I thought
someone might be interested in so I am posting it here.

Program will give you the byte locations in file that hex byte entered on command line
appears in file.

To run from Linux Terminal: ./bytelc [-f filename] [-x HexByte]
./bytelc -f bytect -x e8

I wrote the command line procedure to work with or without space after switchs, so the
above command line can be written ./bytelc -fbytect -xe8

As always feed back good or bad is welcome.

Best Regards
John


Last edited by greco558 on 04 Dec 2017, 20:27; edited 1 time in total
Post 30 Nov 2017, 19:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20621
Location: In your JS exploiting you and your system
revolution 30 Nov 2017, 23:28
I assume this is for Linux?

Maybe you could extend it to a byte sequence locator.
Post 30 Nov 2017, 23:28
View user's profile Send private message Visit poster's website Reply with quote
greco558



Joined: 21 Jul 2016
Posts: 35
greco558 30 Nov 2017, 23:57
Yes it is for Linux.
Good idea about sequence locater.
I will have to get to work on it.




Thanks
John
Post 30 Nov 2017, 23:57
View user's profile Send private message Reply with quote
greco558



Joined: 21 Jul 2016
Posts: 35
greco558 04 Dec 2017, 20:34
Cleaned up old version noticed some of the comments in source code were from bytect program.

Added the ability to search for BYTE, WORD or DWORD in file.

Still need to add more error checking.

using command line option switchs:
-b for byte search
-w fro word search
-d for double word search.

./bytelc -f filename -b e8
./bytelc -f filename -w e8ff
./bytelc -f filename -d e8ff3479

Best Regards
John


Description:
Download
Filename: 2017-12-04-bytelc.tar.gz
Filesize: 6.93 KB
Downloaded: 998 Time(s)

Post 04 Dec 2017, 20:34
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20621
Location: In your JS exploiting you and your system
revolution 04 Dec 2017, 23:40
Good.

Can it search for arbitrary length strings?
Post 04 Dec 2017, 23:40
View user's profile Send private message Visit poster's website Reply with quote
greco558



Joined: 21 Jul 2016
Posts: 35
greco558 04 Dec 2017, 23:57
Hi Revolution,

I am working on that and will post update.
I figured I would post the version that can search for up to a double
Word length.
It will take me a few days to implement arbitrary lengths.
I don't get to program in assembly often and working on this will help
me to stay involved in Assembly language.

Best Regards
John
Post 04 Dec 2017, 23:57
View user's profile Send private message Reply with quote
greco558



Joined: 21 Jul 2016
Posts: 35
greco558 05 Dec 2017, 19:22
Ok here it is the revised version to replace bytelc.

I eliminated the -b byte, -w word, and -d dword options and replaced
with 1 switch option for byte sequence search -s.

This program bytesq will take arbitrary length hex bytes entered on command line.

You can have your byte sequence on command line first as in the 2nd example
shown below it does not matter.
Example: ./btyesq -f filename -s e83d789723eff856636d646c696e
./bytesq -s 45ffef586c -f filename
./bytesq -f filename -s e8

you can enter 1 hex byte or 15 hex bytes or more on command line after -s switch.
you are limited to 128 hex byte sequence but that is pretty long sequence of bytes to
search for.

Best Regards
John


Description:
Download
Filename: 2017-12-05-bytesq.tar.gz
Filesize: 6.08 KB
Downloaded: 985 Time(s)

Post 05 Dec 2017, 19:22
View user's profile Send private message Reply with quote
donn



Joined: 05 Mar 2010
Posts: 321
donn 05 Dec 2017, 22:37
Cool, one use may be to compute the size of a sequence of instructions. I can't calculate them in my head yet. This might be possible by defining a searchable string before the instructions and a separate one after, then subtracting..? I've been subtracting them with labels then writing to a file, which requires some overhead.

I'm not using Linux at the moment, but found out that the new Win 10 update supports Linux installs such as Ubuntu and OpenSUSE. I tried running the executable but got

Code:
donn@PC:/mnt/c/Users/donn/Downloads/bytesq> ./bytesq
-bash: ./bytesq: cannot execute binary file: Exec format error    


The Win 10 Linux doesn't include the Linux kernel I think, so this might not be possible. May just be a matter of porting or re-assembling, can take another look later.
Post 05 Dec 2017, 22:37
View user's profile Send private message Reply with quote
greco558



Joined: 21 Jul 2016
Posts: 35
greco558 06 Dec 2017, 12:01
Thanks donn,

I don't do a lot of programming in windows anymore, for a while if i wrote something in Linux i
would write the same program for Windows have not done that for a while now.

If I find some time maybe I will try to re-write this for Windows, its not a very big program to
have to translate to Windows platform.



Best Regards
John
Post 06 Dec 2017, 12:01
View user's profile Send private message Reply with quote
greco558



Joined: 21 Jul 2016
Posts: 35
greco558 25 Jul 2018, 18:04
Updated bytesq program and added option -t to search for text in binary file.

Linux command line options:
-t <text to look for>
-x <hex byte sequence to look for>

examples:
./bytesq -f filename -t version
./bytesq -f filename -x 04FFAD864C

with -t option if you are searching for a string of text, place string in
quotation marks exp. -t "i am looking for this"

you can enter "./bytesq -h" to get help about command line options


Best Regards
John


Description:
Download
Filename: 2018-07-17-bytesq.tar.gz
Filesize: 6.77 KB
Downloaded: 940 Time(s)

Post 25 Jul 2018, 18:04
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.