Rocksolid Light

groups  faq  privacy  How to post  login

Message-ID:  

English literature's performing flea. -- Sean O'Casey on P. G. Wodehouse


rocksolid / de.comp.lang.assembler / MZ + PE + Code := Flat Image für Windows 10 64-Bit - NASM / YASM

SubjectAuthor
* MZ + PE + Code := Flat Image für Windows 10 64-Bit - NASM / YASMJens Kallup
`* Re: MZ + PE + Code := Flat Image für Windows 10 64-Bit - NASM / YASMHerbert Kleebauer
 `* Re: MZ + PE + Code := Flat Image für Windows 10 64-Bit - NASM / YASMJens Kallup
  +- kleiner TypoJens Kallup
  `- Re: MZ + PE + Code := Flat Image für Windows 10 64-Bit - NASM / YASMHerbert Kleebauer

1
Subject: MZ + PE + Code := Flat Image für Windows 10 64-Bit - NASM / YASM
From: Jens Kallup
Newsgroups: de.comp.lang.assembler
Organization: kallup non-profit
Date: Sun, 29 Oct 2023 08:37 UTC
Path: i2pn2.org!i2pn.org!news.1d4.us!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: paule32...@gmail.com (Jens Kallup)
Newsgroups: de.comp.lang.assembler
Subject: MZ_+_PE_+_Code_:=_Flat_Image_für_Windows_10_64-B
it_-_NASM_/_YASM
Date: Sun, 29 Oct 2023 09:37:28 +0100
Organization: kallup non-profit
Lines: 168
Message-ID: <kq6ju5F6i5U1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net bzyCsMm4mjMr8loTfmyAAwB47T6AWWNyccxncH9XGXWqgSRSIa
Cancel-Lock: sha1:UHPs0LUQABOpHWn1sq2rJbEfhLo= sha256:eZvZfx+eH+g62ZS1Xl06Ctdogp8ND8Fm4inPQ3qD2F0=
User-Agent: Mozilla Thunderbird
Content-Language: en-US
X-Antivirus: Avast (VPS 231028-4, 28.10.2023), Outbound message
X-Antivirus-Status: Clean
View all headers

Hallo,

kann auf Grundlage des unten aufgeführten Codes, mehr als eine Funktion
der win32api für Windows 64-Bit Systeme verwenden ?
Wenn ja, wie kann man den Code so erweitern ?

Bei dem vorliegenden Code handelt es sich um einen FLAT-Image Code, der
mittels:

nasm -f bin -o win.exe win.asm # oder:
yasm -f bin -o win.exe win.asm

zu einer .EXE assembliert werden kann.
Das heißt, es werden kein Linker oder andere Import-Bibliotheken zur
Erstellung benötigt.

BITS 64

%define align(n,r) (((n+(r-1))/r)*r)

; DOS Header
dw 'MZ' ; e_magic
dw 0 ; [UNUSED] e_cblp
dw 0 ; [UNUSED] c_cp
dw 0 ; [UNUSED] e_crlc
dw 0 ; [UNUSED] e_cparhdr
dw 0 ; [UNUSED] e_minalloc
dw 0 ; [UNUSED] e_maxalloc
dw 0 ; [UNUSED] e_ss
dw 0 ; [UNUSED] e_sp
dw 0 ; [UNUSED] e_csum
dw 0 ; [UNUSED] e_ip
dw 0 ; [UNUSED] e_cs
dw 0 ; [UNUSED] e_lfarlc
dw 0 ; [UNUSED] e_ovno
times 4 dw 0 ; [UNUSED] e_res
dw 0 ; [UNUSED] e_oemid
dw 0 ; [UNUSED] e_oeminfo
times 10 dw 0 ; [UNUSED] e_res2
dd pe_hdr ; e_lfanew

; PE Header
pe_hdr:
dw 'PE', 0 ; Signature

; Image File Header
dw 0x8664 ; Machine
dw 0x01 ; NumberOfSections
dd 0 ; [UNUSED] TimeDateStamp
dd 0 ; PointerToSymbolTable
dd 0 ; NumberOfSymbols
dw opt_hdr_size ; SizeOfOptionalHeader
dw 0x22 ; Characteristics

; Optional Header, COFF Standard Fields
opt_hdr:
dw 0x020b ; Magic (PE32+)
db 0x0e ; MajorLinkerVersion
db 0x16 ; MinorLinkerVersion
dd code_size ; SizeOfCode
dd 0 ; SizeOfInitializedData
dd 0 ; SizeOfUninitializedData
dd entry ; AddressOfEntryPoint
dd iatbl ; BaseOfCode

; Optional Header, NT Additional Fields
dq 0x000140000000 ; ImageBase
dd 0x10 ; SectionAlignment
dd 0x10 ; FileAlignment
dw 0x06 ; MajorOperatingSystemVersion
dw 0 ; MinorOperatingSystemVersion
dw 0 ; MajorImageVersion
dw 0 ; MinorImageVersion
dw 0x06 ; MajorSubsystemVersion
dw 0 ; MinorSubsystemVersion
dd 0 ; Reserved1
dd file_size ; SizeOfImage
dd hdr_size ; SizeOfHeaders
dd 0 ; CheckSum
dw 0x02 ; Subsystem (Windows GUI)
dw 0x8160 ; DllCharacteristics
dq 0x100000 ; SizeOfStackReserve
dq 0x1000 ; SizeOfStackCommit
dq 0x100000 ; SizeOfHeapReserve
dq 0x1000 ; SizeOfHeapCommit
dd 0 ; LoaderFlags
dd 0x02 ; NumberOfRvaAndSizes

; Optional Header, Data Directories
dd 0 ; Export, RVA
dd 0 ; Export, Size
dd itbl ; Import, RVA
dd itbl_size ; Import, Size

opt_hdr_size equ $-opt_hdr

; Section Table
section_name db '.' ; Name
times 8-($-section_name) db 0
dd sect_size ; VirtualSize
dd iatbl ; VirtualAddress
dd code_size ; SizeOfRawData
dd iatbl ; PointerToRawData
dd 0 ; PointerToRelocations
dd 0 ; PointerToLinenumbers
dw 0 ; NumberOfRelocations
dw 0 ; NumberOfLinenumbers
dd 0x60000020 ; Characteristics

hdr_size equ $-$$

code:
; Import Address Directory
iatbl:
dq symbol
dq 0

iatbl_size equ $-iatbl

; Strings
title:
db "Hallo Welt !!!", 0
content:
db "ABCDEFGHIJKL", 0

; Entry
entry:
mov r9d, 0x00240040 ; uType
lea r8, [rel title] ; lpCaption
lea rdx, [rel content] ; lpText
xor ecx, ecx ; hWnd
jmp [rel iatbl] ; MessageBoxN

times align($-$$,16)-($-$$) db 0xcc

; Import Directory
itbl:
dq intbl ; OriginalFirstThunk
dd 0 ; TimeDateStamp
dd dll_name ; ForwarderChain
dd iatbl ; Name
dq 0 ; FirstThunk

itbl_size equ $-itbl

; Import Name Table
intbl:
dq symbol
dq 0

; Symbol
symbol:
dw 0x0294 ; [UNUSED] Function Order
db 'MessageBoxA', 0 ; Function Name
dll_name:
db 'USER32.dll', 0
db 0

sect_size equ $-code

times align($-$$,16)-($-$$) db 0

code_size equ $-code
file_size equ $-$$

--
Diese E-Mail wurde von Avast-Antivirussoftware auf Viren geprüft.
www.avast.com

Subject: Re: MZ + PE + Code := Flat Image für Windows 10 64-Bit - NASM / YASM
From: Herbert Kleebauer
Newsgroups: de.comp.lang.assembler
Organization: A noiseless patient Spider
Date: Sun, 29 Oct 2023 12:44 UTC
References: 1
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: kle...@unibwm.de (Herbert Kleebauer)
Newsgroups: de.comp.lang.assembler
Subject: Re:_MZ_+_PE_+_Code_:=_Flat_Image_für_Windows_1
0_64-Bit_-_NASM_/_YASM
Date: Sun, 29 Oct 2023 13:44:32 +0100
Organization: A noiseless patient Spider
Lines: 507
Message-ID: <uhlk3i$3shdj$1@dont-email.me>
References: <kq6ju5F6i5U1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 29 Oct 2023 12:44:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2954836d6ea1500ec2a03efbb653c7fd";
logging-data="4081075"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Z5AwguF42FU4uazGj8g2u8zz+fFE5Um0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:zni9vzq+EUyCJRfA6UQ21Jq2Em0=
In-Reply-To: <kq6ju5F6i5U1@mid.individual.net>
Content-Language: de-DE
View all headers

On 29.10.2023 09:37, Jens Kallup wrote:

> kann auf Grundlage des unten aufgeführten Codes, mehr als eine Funktion
> der win32api für Windows 64-Bit Systeme verwenden ?
> Wenn ja, wie kann man den Code so erweitern ?

Ich kann nichts zu 64 Bit Code sagen, da ich mir bisher
keinen Fall vorstellen kann bei dem es einen Vorteil
gegenüber 32 Bit Code gibt (bei kleinen Assemblerprogrammen).
Aber warum nutzt du die win32api für 64 Bit Windows Programme?

Hier ist das Grundgerüst das ich für 32 Bit Programm
verwende. Ich passe nur immer die Tabellen mit den
importierten Funktionen und den Assemblercode selbst an.
Der Aufbau ist sehr ähnlich deinem Code, vielleicht
hilft es dir ja weiter.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; popup.mac: display commandline in a popup window ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

UseIdatSection=0 ; 0 if no idat section is used
UseUdatSection=0 ; 0 if no udat section is used

;#==================================================================#
;# Start of Headers #
;#==================================================================#

; +--------------------------------------------+
; | Start of DOS Header |
; +--------------------------------------------+

; DOS .EXE header
dc.b 'MZ' ; Magic number
dc.w dosfilesize\512 ; Bytes on last page of file (0->512)
dc.w (dosfilesize-1)/512+1
; Pages in file (Page=512 byte)
dc.w 0 ; Relocations (nr of entries)
dc.w doshead_end/16 ; Size of header size in paragraphs (16 byte)
dc.w 0 ; Minimum extra paragraphs needed
dc.w $ffff ; Maximum extra paragraphs needed
dc.w 0 ; Initial (relative) SS value (ss=load_adr+nr)
dc.w dosstack ; Initial SP value
dc.w 0 ; Checksum
dc.w dosmain ; Initial IP value
dc.w 0 ; Initial (relative) CS value (cs=load_adr+nr)
dc.w reloc ; File address of relocation table
dc.w 0 ; Overlay number
dc.w 0,0,0,0 ; Reserved words
dc.w 0 ; OEM identifier (for e_oeminfo)
dc.w 0 ; OEM information; e_oemid specific
dc.l 0,0,0,0,0 ; Reserved words
dc.l WinHeader ; File address of new exe header
reloc:
doshead_end:

@=$0
dosmain:move.w s6,-(sp)
move.w (sp)+,s0
move.w #_text,r1
move.b #$09,m0
trap #$21
move.w #$4c01,r0
trap #$21
_text: dc.b 'Nice to meet somebody who is still using DOS,',13,10
dc.b 'but this program requires Win32.',13,10,'$'
even 16

dosstack=@+256 ; 256 Byte stack
dosfilesize=@+256

; +--------------------------------------------+
; | End of DOS Header |
; +--------------------------------------------+

; +--------------------------------------------+
; | Start of Windows Header |
; +--------------------------------------------+

ImageBase== $00400000
SectionAlignment== 4096
FileAlignment== 512

WinHeader=@@
@=ImageBase

; see WINNT.H for information
dc.b 'PE',0,0 ; magic word
; _IMAGE_FILE_HEADER:
dc.w $014c ; Machine ($014c=Intel x86 processor)
dc.w NumberOfSections ; NumberOfSections
dc.l $36a57950 ; TimeDateStamp (seconds since 31.12.69 16:00)
dc.l 0 ; PointerToSymbolTable
dc.l 0 ; NumberOfSymbols
dc.w SizeOfOptionalHeader ; SizeOfOptionalHeader
dc.w $010f ; Charcteristics

; 0x0001 Relocation info stripped from file.
; 0x0002 File is executable (i.e. no unresolved externel references).
; 0x0004 Line nunbers stripped from file.
; 0x0008 Local symbols stripped from file.
; 0x0010 Agressively trim working set
; 0x0080 Bytes of machine word are reversed.
; 0x0100 32 bit word machine.
; 0x0200 Debugging info stripped from file in .DBG file
; 0x0400 If Image is on removable media, copy and run from the swap file.
; 0x0800 If Image is on Net, copy and run from the swap file.
; 0x1000 System File.
; 0x2000 File is a DLL.
; 0x4000 File should only be run on a UP machine
; 0x8000 Bytes of machine word are reversed.

@a=@ ; _IMAGE_OPTIONAL_HEADER
dc.w $010b ; Magic
dc.b 5 ; MajorLinkerVersion
dc.b 12 ; MinorLinkerVersion
dc.l SizeOfCode ; SizeOfCode
dc.l SizeOfInitializedData ; SizeOfInitializedData
dc.l SizeOfUninitializedData ; SizeOfUninitializedData
dc.l winmain-ImageBase ; AddressOfEntryPoint
dc.l BaseOfCode ; BaseOfCode
dc.l BaseOfData ; BaseOfData
dc.l ImageBase ; ImageBase
dc.l SectionAlignment ; SectionAlignment
dc.l FileAlignment ; FileAlignment
dc.w 5 ; MajorOperatingSystemVersion
dc.w 0 ; MinorOperatingSystemVersion
dc.w 0 ; MajorImageVersion
dc.w 0 ; MinorImageVersion
dc.w 4 ; MajorSubsystemVersion
dc.w 0 ; MinorSubsystemVersion
dc.l 0 ; Win32VersionValue
dc.l SizeOfImage ; SizeOfImage
dc.l SizeOfHeaders ; SizeOfHeaders
dc.l 0 ; CheckSum
dc.w 3 ; Subsystem
; 0: Unknown subsystem.
; 1: Image doesn't require a subsystem.
; 2: Image runs in the Windows GUI subsystem.
; 3: Image runs in the Windows character subsystem.
; 5: image runs in the OS/2 character subsystem.
; 7: image run in the Posix character subsystem.
; 8: image run in the 8 subsystem.
dc.w $0000 ; DllCharacteristics
dc.l $00100000 ; SizeOfStackReserve
dc.l $00001000 ; SizeOfStackCommit
dc.l $00100000 ; SizeOfHeapReserve
dc.l $00001000 ; SizeOfHeapCommit
dc.l $00000000 ; LoaderFlags
dc.l NumberOfRvaAndSize ; NumberOfRvaAndSize (entries
; in the data dir)

; ..............................................
; : Start of Image Data Directory :
; ..............................................

; virtual address, size
@b=@
dc.l 0,0 ; Export Directory
dc.l imp_start,imp_size ; Import Directory
dc.l 0,0 ; Resource Directory
dc.l 0,0 ; Exception Directory
dc.l 0,0 ; Security Directory
dc.l 0,0 ; Base Relocation Table
dc.l 0,0 ; Debug Directory
dc.l 0,0 ; Description String
dc.l 0,0 ; Machine Value (MIPS GP)
dc.l 0,0 ; TLS Directory
dc.l 0,0 ; Load Configuration Directory
dc.l 0,0 ; Bound Import Directory in headers
dc.l iat_start,iat_size ; Import Address Table
dc.l 0,0 ; 14
dc.l 0,0 ; 15
dc.l 0,0 ; 16

NumberOfRvaAndSize = (@-@b)/8
SizeOfOptionalHeader = @-@a

; ..............................................
; : End of Image Data Directory :
; ..............................................

; ..............................................
; : Start of Image Sections Header :
; ..............................................

@a=@

dc.b '.text',0,0,0 ; name
dc.l VSizeOf_text ; virtual size
dc.l VBaseOf_text ; virtual address
dc.l FSizeOf_text ; size of raw data
dc.l FBaseOf_text ; pointer to raw data
dc.l 0 ; pointer to relocatins
dc.l 0 ; pointer to line numbers
dc.w 0 ; number of relocations
dc.w 0 ; number of line numbers
dc.l $e0000020 ; characteristics


Click here to read the complete article
Subject: Re: MZ + PE + Code := Flat Image für Windows 10 64-Bit - NASM / YASM
From: Jens Kallup
Newsgroups: de.comp.lang.assembler
Organization: kallup non-profit
Date: Sun, 29 Oct 2023 15:38 UTC
References: 1 2
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder2.eternal-september.org!eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: paule32...@gmail.com (Jens Kallup)
Newsgroups: de.comp.lang.assembler
Subject: Re:_MZ_+_PE_+_Code_:=_Flat_Image_für_Windows_1
0_64-Bit_-_NASM_/_YASM
Date: Sun, 29 Oct 2023 16:38:13 +0100
Organization: kallup non-profit
Lines: 201
Message-ID: <kq7cj5F60lqU1@mid.individual.net>
References: <kq6ju5F6i5U1@mid.individual.net> <uhlk3i$3shdj$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net SuxhlNTkomX9xYSPdyVHBQ41AjDxgYk+3gAfoVXJ4ZJh+QvWn7
Cancel-Lock: sha1:YGvJN/IV/l+0t2yVALK3IcHX9oY= sha256:AQauMoDW0ZE+syfmuPPMnoL/yikrGiiMHv7aHDa9e6Y=
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <uhlk3i$3shdj$1@dont-email.me>
X-Antivirus: Avast (VPS 231029-2, 29.10.2023), Outbound message
X-Antivirus-Status: Clean
View all headers

Hallo Herbert,

welchen Assembler nutzt Du?
sieht fast so aus, also wäre das für Ardunio...

Ich habe in der Zwischenzeit den Code abgeändert, aber da ist
noch irgendwo der Wurm drinn.
Möglicherweise ein Array-Problem.
Aber das konnte ich jetzt nicht hinbiegen, weil ich damit dann
voodoo Programming betreibe - was nicht sehr prikelnd sein kann.

Ich starte das Programm, aber die DLL scheint nicht geladen zu
werden, da sonst die MessageBoxA im DLL begin main Block aufpoppen
müsste ...

Ich habe zusätzlich eine DLL in FPC (Free Pascal Compiler) ge-
schrieben:

library kalle32;
uses windows;
procedure kalli(h: HWND; t,c: PChar; u: UINT); stdcall; export;
begin
MessageBoxA(h,t,c,u);
end;
begin
MessageBoxA(0,'xxxxx','tttt',0);
end.
--------------------
BITS 64

%define align(n,r) (((n+(r-1))/r)*r)

; DOS Header
dw 'MZ' ; e_magic
dw 0 ; [UNUSED] e_cblp
dw 0 ; [UNUSED] c_cp
dw 0 ; [UNUSED] e_crlc
dw 0 ; [UNUSED] e_cparhdr
dw 0 ; [UNUSED] e_minalloc
dw 0 ; [UNUSED] e_maxalloc
dw 0 ; [UNUSED] e_ss
dw 0 ; [UNUSED] e_sp
dw 0 ; [UNUSED] e_csum
dw 0 ; [UNUSED] e_ip
dw 0 ; [UNUSED] e_cs
dw 0 ; [UNUSED] e_lfarlc
dw 0 ; [UNUSED] e_ovno
times 4 dw 0 ; [UNUSED] e_res
dw 0 ; [UNUSED] e_oemid
dw 0 ; [UNUSED] e_oeminfo
times 10 dw 0 ; [UNUSED] e_res2
dd pe_hdr ; e_lfanew

; PE Header
pe_hdr:
dw 'PE', 0 ; Signature

; Image File Header
dw 0x8664 ; Machine
dw 0x01 ; NumberOfSections
dd 0 ; [UNUSED] TimeDateStamp
dd 0 ; PointerToSymbolTable
dd 0 ; NumberOfSymbols
dw opt_hdr_size ; SizeOfOptionalHeader
dw 0x22 ; Characteristics

; Optional Header, COFF Standard Fields
opt_hdr:
dw 0x020b ; Magic (PE32+)
db 0x0e ; MajorLinkerVersion
db 0x16 ; MinorLinkerVersion
dd code_size ; SizeOfCode
dd 0 ; SizeOfInitializedData
dd 0 ; SizeOfUninitializedData
dd entry ; AddressOfEntryPoint
dd iatbl ; BaseOfCode

; Optional Header, NT Additional Fields
dq 0x000140000000 ; ImageBase
dd 0x10 ; SectionAlignment
dd 0x10 ; FileAlignment
dw 0x06 ; MajorOperatingSystemVersion
dw 0 ; MinorOperatingSystemVersion
dw 0 ; MajorImageVersion
dw 0 ; MinorImageVersion
dw 0x06 ; MajorSubsystemVersion
dw 0 ; MinorSubsystemVersion
dd 0 ; Reserved1
dd file_size ; SizeOfImage
dd hdr_size ; SizeOfHeaders
dd 0 ; CheckSum
dw 0x02 ; Subsystem (Windows GUI)
dw 0x8160 ; DllCharacteristics
dq 0x100000 ; SizeOfStackReserve
dq 0x1000 ; SizeOfStackCommit
dq 0x100000 ; SizeOfHeapReserve
dq 0x1000 ; SizeOfHeapCommit
dd 0 ; LoaderFlags
dd 0x02 ; NumberOfRvaAndSizes

; Optional Header, Data Directories
dd 0 ; Export, RVA
dd 0 ; Export, Size
dd itbl ; Import, RVA
dd itbl_size ; Import, Size

opt_hdr_size equ $-opt_hdr

; Section Table
section_name db '.' ; Name
times 8-($-section_name) db 0
dd sect_size ; VirtualSize
dd iatbl ; VirtualAddress
dd code_size ; SizeOfRawData
dd iatbl ; PointerToRawData
dd 0 ; PointerToRelocations
dd 0 ; PointerToLinenumbers
dw 0 ; NumberOfRelocations
dw 0 ; NumberOfLinenumbers
dd 0x60000020 ; Characteristics

hdr_size equ $-$$

code:
; Import Address Directory
iatbl:
dq symbol_1
dq symbol_2
dq 0
iatbl_size equ $-iatbl

; Strings
title:
db "Hallo Welt !!!", 0
content:
db "ABCDEFGHIJKL", 0

; Entry
entry:
mov r9d, 0x00240040 ; uType
lea r8, [rel title] ; lpCaption
lea rdx, [rel content] ; lpText
xor ecx, ecx ; hWnd
mov rax, [rel iatbl + 8] ; MessageBoxN
call rax

times align($-$$,16)-($-$$) db 0xcc

; Import Directory 1
itbl:
dq intbl_1 ; OriginalFirstThunk
dd 0 ; TimeDateStamp
dd dll_name_1 ; ForwarderChain
dd iatbl ; Name
dq 0 ; FirstThunk

; Import Directory 2
itbl_2:
dq intbl_2 ; OriginalFirstThunk
dd 0 ; TimeDateStamp
dd dll_name_2 ; ForwarderChain
dd iatbl + 8 ; Name
dq 0 ; FirstThunk

itbl_size equ $-itbl

; Import Name Table 1
intbl_1:
dq symbol_1
dq 0

; Import Name Table 2
intbl_2:
dq symbol_2
dq 0

; Symbol 1
symbol_1:
dw 0 ; [UNUSED] Function Order
db 'MessageBoxA', 0 ; Function Name

; Symbol 2
symbol_2:
dw 0
db 'kalli', 0

dll_name_2: db 'kalle32.dll', 0
dll_name_1: db 'USER32.dll' , 0

sect_size equ $-code

times align($-$$,16)-($-$$) db 0

code_size equ $-code
file_size equ $-$$

--
Diese E-Mail wurde von Avast-Antivirussoftware auf Viren geprüft.
www.avast.com

Subject: kleiner Typo
From: Jens Kallup
Newsgroups: de.comp.lang.assembler
Organization: kallup non-profit
Date: Sun, 29 Oct 2023 15:40 UTC
References: 1 2 3
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: paule32...@gmail.com (Jens Kallup)
Newsgroups: de.comp.lang.assembler
Subject: kleiner Typo
Date: Sun, 29 Oct 2023 16:40:05 +0100
Organization: kallup non-profit
Lines: 27
Message-ID: <kq7cmlF60lqU2@mid.individual.net>
References: <kq6ju5F6i5U1@mid.individual.net> <uhlk3i$3shdj$1@dont-email.me>
<kq7cj5F60lqU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Trace: individual.net 7GbKagIKTY+TUIMBosDflQDjjV/yj0BpUaTCea+fMVmZ/K6SHU
Cancel-Lock: sha1:kFhMQA/WZ1tQ7NbXYVv8kaXOEF8= sha256:S6P9aeh/ZaWRKxkUieWZ2nyQNSk/91SRC3Lyd+6YIlw=
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <kq7cj5F60lqU1@mid.individual.net>
X-Antivirus: Avast (VPS 231029-2, 29.10.2023), Outbound message
X-Antivirus-Status: Clean
View all headers

Am 2023-10-29 um 16:38 schrieb Jens Kallup:
> library kalle32;
> uses windows;
> procedure kalli(h: HWND; t,c: PChar; u: UINT); stdcall; export;
> begin
> MessageBoxA(h,t,c,u);
> end;
> begin
> MessageBoxA(0,'xxxxx','tttt',0);
> end.

library kalle32;
uses windows;
procedure kalli(h: HWND; t,c: PChar; u: UINT); stdcall; export;
begin
MessageBoxA(h,t,c,u);
end;
exports kalli;
begin
MessageBoxA(0,'xxxxx','tttt',0);
end.

--
Diese E-Mail wurde von Avast-Antivirussoftware auf Viren geprüft.
www.avast.com

Subject: Re: MZ + PE + Code := Flat Image für Windows 10 64-Bit - NASM / YASM
From: Herbert Kleebauer
Newsgroups: de.comp.lang.assembler
Organization: A noiseless patient Spider
Date: Sun, 29 Oct 2023 16:29 UTC
References: 1 2 3
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!gandalf.srv.welterde.de!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: kle...@unibwm.de (Herbert Kleebauer)
Newsgroups: de.comp.lang.assembler
Subject: Re:_MZ_+_PE_+_Code_:=_Flat_Image_für_Windows_1
0_64-Bit_-_NASM_/_YASM
Date: Sun, 29 Oct 2023 17:29:59 +0100
Organization: A noiseless patient Spider
Lines: 1512
Message-ID: <uhm1a9$3visr$1@dont-email.me>
References: <kq6ju5F6i5U1@mid.individual.net> <uhlk3i$3shdj$1@dont-email.me>
<kq7cj5F60lqU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 29 Oct 2023 16:30:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2954836d6ea1500ec2a03efbb653c7fd";
logging-data="4180891"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19XwOKgI9IhuoKK9B7HZghNMM5ziNjLZ7E="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:4XoN+yausnc8bm1u+t5HUDpPcQk=
In-Reply-To: <kq7cj5F60lqU1@mid.individual.net>
Content-Language: de-DE
View all headers

On 29.10.2023 16:38, Jens Kallup wrote:

Bei 64 Bit kann ich dir leider nicht helfen. Kannst ja mal
im Nasm Forum (https://forum.nasm.us/) nachfragen.

> welchen Assembler nutzt Du?
> sieht fast so aus, also wäre das für Ardunio...

Ist mein eigener, bin PDP11 und 68k Fan. Intel Syntax
kommt für mich nicht in Frage. Hab es aber auch
mal für NASM umgeschrieben:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; MINI.mac: display a message box ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; nasm -O99 -f bin -o mini.exe mini.asm
%include "mac.inc"

UseIdatSection equ 0 ; 0 if no idat section is used
UseUdatSection equ 0 ; 0 if no udat section is used

;#==================================================================#
;# Start of Headers #
;#==================================================================#

; +--------------------------------------------+
; | Start of DOS Header |
; +--------------------------------------------+

section .text vstart=0

doshead_start:
; DOS .EXE header
dc.b 'MZ' ; Magic number
dc.w dosfilesize % 512 ; Bytes on last page of file (0->512)
dc.w (dosfilesize-1)/512+1
; Pages in file (Page=512 byte)
dc.w 0 ; Relocations (nr of entries)
dc.w doshead_size/16 ; Size of header size in paragraphs (16 byte)
dc.w 0 ; Minimum extra paragraphs needed
dc.w $0ffff ; Maximum extra paragraphs needed
dc.w 0 ; Initial (relative) SS value (ss=load_adr+nr)
dc.w dosstack ; Initial SP value
dc.w 0 ; Checksum
dc.w dosmain ; Initial IP value
dc.w 0 ; Initial (relative) CS value (cs=load_adr+nr)
dc.w reloc ; File address of relocation table
dc.w 0 ; Overlay number
dc.w 0,0,0,0 ; Reserved words
dc.w 0 ; OEM identifier (for e_oeminfo)
dc.w 0 ; OEM information; e_oemid specific
dc.l 0,0,0,0,0 ; Reserved words
dc.l WinHeader ; File address of new exe header
reloc:
doshead_end:
doshead_size equ doshead_end-doshead_start

@@0 equ $-$$ ; current file position

section .text0 vstart=0

dosstart:
dosmain:move.w s6,-[sp]
move.w [sp]+,s0
move.w .text,r1
move.b $09,m0
trap $21
move.w $4c01,r0
trap $21
..text: dc.b 'Nice to meet somebody who is still using DOS,',13,10
dc.b 'but his program requires Win32.',13,10,'$'
align 16, db 0

dosstack equ $+256 ; 256 Byte stack
dosfilesize equ $-dosstart+256

; +--------------------------------------------+
; | End of DOS Header |
; +--------------------------------------------+

; +--------------------------------------------+
; | Start of Windows Header |
; +--------------------------------------------+

ImageBase equ $00400000
SectionAlignment equ 4096
FileAlignment equ 512

@@1 equ @@0 + $-$$ ; current file position
WinHeader equ @@1

section .text1 vstart=ImageBase
ImageBase1 equ $
; ImageBase1 has same value as ImageBase but is nonrelatve

; see WINNT.H for information
dc.b 'PE',0,0 ; magic word
; _IMAGE_FILE_HEADER:
dc.w $014c ; Machine ($014c=Intel x86 processor)
dc.w NumberOfSections ; NumberOfSections
dc.l $36a57950 ; TimeDateStamp (seconds since 31.12.69 16:00)
dc.l 0 ; PointerToSymbolTable
dc.l 0 ; NumberOfSymbols
dc.w SizeOfOptionalHeader ; SizeOfOptionalHeader
dc.w $010f ; Charcteristics

; 0x0001 Relocation info stripped from file.
; 0x0002 File is executable (i.e. no unresolved externel references).
; 0x0004 Line nunbers stripped from file.
; 0x0008 Local symbols stripped from file.
; 0x0010 Agressively trim working set
; 0x0080 Bytes of machine word are reversed.
; 0x0100 32 bit word machine.
; 0x0200 Debugging info stripped from file in .DBG file
; 0x0400 If Image is on removable media, copy and run from the swap file.
; 0x0800 If Image is on Net, copy and run from the swap file.
; 0x1000 System File.
; 0x2000 File is a DLL.
; 0x4000 File should only be run on a UP machine
; 0x8000 Bytes of machine word are reversed.

@a1 equ $ ; _IMAGE_OPTIONAL_HEADER
dc.w $010b ; Magic
dc.b 5 ; MajorLinkerVersion
dc.b 12 ; MinorLinkerVersion
dc.l SizeOfCode ; SizeOfCode
dc.l SizeOfInitializedData ; SizeOfInitializedData
dc.l SizeOfUninitializedData ; SizeOfUninitializedData
dc.l winmain-ImageBase ; AddressOfEntryPoint
dc.l BaseOfCode ; BaseOfCode
dc.l BaseOfData ; BaseOfData
dc.l ImageBase ; ImageBase
dc.l SectionAlignment ; SectionAlignment
dc.l FileAlignment ; FileAlignment
dc.w 4 ; MajorOperatingSystemVersion
dc.w 0 ; MinorOperatingSystemVersion
dc.w 0 ; MajorImageVersion
dc.w 0 ; MinorImageVersion
dc.w 4 ; MajorSubsystemVersion
dc.w 0 ; MinorSubsystemVersion
dc.l 0 ; Win32VersionValue
dc.l SizeOfImage ; SizeOfImage
dc.l SizeOfHeaders ; SizeOfHeaders
dc.l 0 ; CheckSum
dc.w 2 ; Subsystem
; 0: Unknown subsystem.
; 1: Image doesn't require a subsystem.
; 2: Image runs in the Windows GUI subsystem.
; 3: Image runs in the Windows character subsystem.
; 5: image runs in the OS/2 character subsystem.
; 7: image run in the Posix character subsystem.
; 8: image run in the 8 subsystem.
dc.w $0000 ; DllCharacteristics
dc.l $00100000 ; SizeOfStackReserve
dc.l $00001000 ; SizeOfStackCommit
dc.l $00100000 ; SizeOfHeapReserve
dc.l $00001000 ; SizeOfHeapCommit
dc.l $00000000 ; LoaderFlags
dc.l NumberOfRvaAndSize ; NumberOfRvaAndSize (entries
; in the data dir)

; ..............................................
; : Start of Image Data Directory :
; ..............................................

; virtual address, size
@b equ $
dc.l 0,0 ; Export Directory
dc.l imp_start,imp_size ; Import Directory
dc.l 0,0 ; Resource Directory
dc.l 0,0 ; Exception Directory
dc.l 0,0 ; Security Directory
dc.l 0,0 ; Base Relocation Table
dc.l 0,0 ; Debug Directory
dc.l 0,0 ; Description String
dc.l 0,0 ; Machine Value (MIPS GP)
dc.l 0,0 ; TLS Directory
dc.l 0,0 ; Load Configuration Directory
dc.l 0,0 ; Bound Import Directory in headers
dc.l iat_start,iat_size ; Import Address Table
dc.l 0,0 ; 14
dc.l 0,0 ; 15
dc.l 0,0 ; 16

NumberOfRvaAndSize equ ($-@b)/8
SizeOfOptionalHeader equ $-@a1

; ..............................................
; : End of Image Data Directory :
; ..............................................

; ..............................................
; : Start of Image Sections Header :
; ..............................................

@a2 equ $

dc.b '.text',0,0,0 ; name
dc.l VSizeOf_text ; virtual size
dc.l VBaseOf_text ; virtual address
dc.l FSizeOf_text ; size of raw data
dc.l FBaseOf_text ; pointer to raw data
dc.l 0 ; pointer to relocatins
dc.l 0 ; pointer to line numbers
dc.w 0 ; number of relocations
dc.w 0 ; number of line numbers
dc.l $0e0000020 ; characteristics


Click here to read the complete article

rocksolid / de.comp.lang.assembler / MZ + PE + Code := Flat Image für Windows 10 64-Bit - NASM / YASM

1
server_pubkey.txt

rocksolid light 0.9.136
clearnet tor