View Single Post
  #28  
Old September 23rd 18, 08:04 AM posted to alt.msdos.batch,alt.windows7.general
Herbert Kleebauer
external usenet poster
 
Posts: 27
Default how to get the title into task manger 'window'?

On 23.09.2018 03:07, pyotr filipivich wrote:

I already posted the few lines of source code. Here the
listing from the assembler which explains the meaning
of every byte in the 1024 byte exe:


Wow.

One more reason I don't like programming at the assembler level.
B-)



What's wrong with this source code? It calls "GetCommandLine"
to get a pointer to the command line, then skips the program
name to get the pointer to the new title string given on
the command line. Then it gets the handle to the console
window (GetConsoleWindow), sets the new title (SetWindowTextA)
and terminates the program (ExitProcess). Anything else you see
in the list file is normally generated by the assembler and linker
(but if I want a small exe file to include it in a batch program,
I do it by hand). You can also write it as a two line C program, but
don't expect to get a 1 kByte binary.



winmain::

jsr.l (GetCommandLine)
; skip program name
eor.l r1,r1 ; not within "" flag
dec.l r0
_20: inc.l r0
cmp.b #0,(r0)
beq.b _10
cmp.b #'"',(r0)
bne.b _30
not.l r1
_30: or.l r1,r1
bne.b _20
cmp.b #' ',(r0)
bne.b _20
inc.l r0

_10: move.l r0,-(sp)
jsr.l (GetConsoleWindow)
move.l r0,-(sp)
jsr.l (SetWindowTextA)
moveq.l #0,-(sp)
jsr.l (ExitProcess) ; exit program
Ads