flat assembler
Message board for the users of flat assembler.

Index > Tutorials and Examples > Trimmed Brand String

Thread Post new topic Reply to topic

Joined: 14 Feb 2013
Posts: 58
Location: Alberta
TightCoderEx 23 Jul 2013, 21:03
This is essentially an extension to this thread, but I've settled upon how I want it to work and how it's coded.

As this and subsequent posts are building blocks for my OS project, the first thing you'll notice is I'm using STDCALL rather than FASTCALL. Where stack need be aligned on 32 bit boundry, I'll code that into those procedures individually. Code is sensitive to following 5 conditions;
    (a) Null string
    (b) Blank string (47 spaces)
    (c) Leading spaces
    (d) Trailing spaces
    (e) Full string

Algo was tested with this. Null string can be simulated by placing a NULL in first postion of any entry. Procedure frame is superfluous.
    format PE64 GUI 5.0
    include 'win64a.inc'

                section '.text' code readable executable

  entry $

        enter   56, 0

        mov     esi, Buffer
        mov     edi, Dest
        mov     r8b, 5

   @@:  push    rsi
        push    rdi
        call    GetBrandString
        mov     cl, 6
        or      rax, -1
        push    rdi
        rep     stosq
        pop     rdi
        add     esi, 48
        dec     r8b
        jnz     @B


        align   16
        include 'GetBString.asm'

                 section '.data' data readable writeable
; ============================================================================================

  Dest:         rq      6

  Buffer:       db         'Whatever could this be that I cant see the ends', 0
                db         '                                               ', 0
                db         '                 Intel Core (3) i18 3.84 gz CPU', 0
                db         'Branding String                                ', 0
                db         '        Generic CPU in Bochs                   ', 0

                section '.idata' import data readable writeable
; ============================================================================================

  library  user32,'USER32.DLL', kernel32,'KERNEL32.DLL'

  include 'api\user32.inc'
  include 'api\kernel32.inc'                  

Filename: GetBString.ASM
Filesize: 2.78 KB
Downloaded: 895 Time(s)

Post 23 Jul 2013, 21:03
View user's profile Send private message Visit poster's website Reply with quote

Joined: 21 Jan 2021
Posts: 219
FlierMate 16 Oct 2021, 14:51
Hi, I have another code snippet by me which show processor brand.

Of course, you can easily change it to Windows version by using Win32 API.

; "AuthenticAMD"  AMD
; "GenuineIntel"  Intel
format ELF64 executable 3

segment readable executable

entry $

      xor     eax, eax
      mov     dword [cpu], ebx
      mov     dword [cpu + 4], edx
      mov     dword [cpu + 8], ecx
      mov     byte [cpu + 12],0xA      ;Append line feed

      mov     edx,13
      lea     rsi,[cpu]
      mov     edi,1    ; STDOUT
      mov     eax,1    ; sys_write

      xor     edi,edi
      mov     eax,60   ; sys_exit

segment readable writeable

cpu    rb      13    
Post 16 Oct 2021, 14:51
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.