News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

GO TOOLS TUTORIALS, ARTICLES and SAMPLE CODE

Started by jorgon, June 18, 2012, 12:29:13 AM

Previous topic - Next topic

jorgon

INDEX OF GO TOOLS TUTORIALS, ARTICLES and SAMPLE CODE
Here you will find links to the tutorials, articles and sample code for the Go Tools including the GoAsm assembler, from the Go Tools site.  For an extensive list of tutorials, articles and sample code published by a number of GoAsm users please see the next article. If you would like to add anything please send directly to me (Jeremy Gordon) at jg@jgnet.co.uk.

"GO" TUTORIALS and SAMPLE CODE

These tutorials are from

the GoBug manual, the Testbug manual or the GoAsm manual
Beginners



Quick start to .. writing a simple Windows program Step-by-step guide to making simple Windows programs.

For those new to programming The basic build process and the files you use.

For those new to assembly language An introduction to the various assembler instructions (mnemonics) and what they do.

For those new to Windows A basic description of what Windows does and how it works.

For those new to symbolic debugging What debugging is and how to use it to find errors in your programs.



Simple Windows console program Source code for a program writing "Hello World" to the console.

Simple Windows GUI program Source code for a program writing "Hello World" to a window.

Simple Windows GUI program
Source code for a program writing "Hello World" to a window, but demonstrating automated stack frames, structures, INVOKE, locally scoped labels and redefinitions (macros).

Simple Dialog program Source code for a program creating a dialog, and showing various ways of writing to it.



Understand bits, binary and bytes

Understand hex numbers

Understand finite, negative, signed and two's complement numbers

Understand registers

Understand the stack - Part 1



FAQ
"When I click on the GoAsm or GoLink or GoRC icon something just flashes on the screen but nothing else happens".


Intermediate

Some programming hints and tips

Size of code - keep it compact!



Understand flags and conditional jumps

Real-time conditional jump test (Testbug)

Real-time flag test (Testbug)

Understand reverse storage

Understand the stack - Part 2



Use of NEG and NOT

Use of BT (and variants) and BSWAP

Use of REP SCASB

Types of JMPs & CALLs to unique labels



Standardized window and dialog procedure

Optimising the loop instruction

Optimising REP STOS MOVS and STAS

Alignment of oft-called functions

Alignment of memory reads, writes and compares



Writing a 32-bit number in hex

Writing a 32-bit number in ascii

Writing a 64-bit number in ascii

Dividing a 64-bit number

Data in the code section - effect on speed

Using VirtualAlloc and HeapCreate

HeapCreate v VirtualAlloc, comparing speed

Drawing text to screen using Windows



What Dlls are and why they are useful

Dll loading, memory, stack and threads

Calling Dlls with no arguments

Calling Dlls with arguments via the stack

Dll sending data to the calling exe



Do nothing Linux program by V.Krishnakumar


Advanced

Conditional jump branch hints

Use of IDIV

Use of IMUL

BCD coding: AAA and DAA



Using the FPU

Using the MMX registers

Using the 3DNow! instructions

Using the XMM integer instructions

Using the XMM SSE instructions

Using the XMM SSE2 instructions

SIMD floating point control



Dlls: Start-up code and run-time link

Dlls: Exporting data pointers

Dll using a function in the calling exe

Calling a Dll function by ordinal using GetProcAddress

Calling a Dll function directly by ordinal

Calling a Dll function by name-load

Testing who called Dll start-up code

Addressing arguments using ebp

Addressing arguments using esp

Addressing local data in home-made stack frames

Ways of saving return address in stack frames



Making temporary on-screen notices

Clipping - control using the device context

Clipping - control using other methods

Using different languages in resources

Different types of window procedures

Recursion in window procedures

Simulating a dialog

Making and debugging multi-threaded programs

Causing and debugging exceptions

Messages around the system



Writing 64-bit programs

Hello 64World 1 a simple 64-bit console program

Hello 64World 2 a simple 64-bit windows program

Hello 64World 3 switchable 32-bit or 64-bit windows program



Writing Unicode programs

Hello Unicode 1 A simple program with a Unicode UTF-8 source script, which draws Unicode characters to the console and which demonstrates how to get the strings in the correct format using the natural format of the source script, the STRINGS directive and the A" and L" overrides.

Hello Unicode 2 A Unicode UTF-8 source script, which draws Unicode characters in a dialog made using a template in data and also in a message box.  It demonstrates the use of Unicode strings in data.

Hello Unicode 3 A Unicode UTF-8 source script, which draws Unicode characters using TextOutW, and also demonstrates Unicode/ANSI switching using the Microsoft Layer for Unicode.

Run Time Loading Demonstrates how to use run-time loading in large application running on both W9x/ME and NT/2000/XP and using both ANSI and Unicode APIs.

Microsoft Layer for Unicode ("mslu")
Describes what the mslu is, how it works, and how to use it with the "Go" tools.

Demonstrations of the mslu in practice

Demonstrations of what W9x/ME and NT/2000/XP can do to draw non-Roman characters



Structured Exception Handling (view)

Structured Exception Handling (download 56K)
This is analysis of Structured Exception Handling in Win32 from an assembler viewpoint, with demo programs and source code examples. It includes two samples. One is a simple example demonstrating both final and per-thread handlers.  The second is more complex, demonstrating exception handling in detail.


Debugging



For those new to symbolic debugging

Debugging: what, when and how (GoBug)

Around GoBug

Using GoBug

Getting system and debuggee information

Testing GoBug using Testbug - various tests

View the complete GoBug manual

The "RSDS" or "DS" pdb symbol file format

Magnum

When I try to go to Jeremy's site, I get this.

If you are the account holder, please contact the billing or support department as soon as possible.

I think this came from his site, I don't understand exactly what this code is doing ?

Thanks.



include \masm32\include\masm32rt.inc   

.CONST

.data
   
WaterMark   db  "SiegeWorks 2013 ð__ð" ; Alt 240 char
%Date       db  " &@Date " ; Compile date
%time       db  " &@Time"

KERNEL_NAME  DB 'KERNEL32.DLL',0
NAME_STRINGS DB 'CopyFileA',0
             DB 'DeleteFileA',0
             DB 'lstrlen',0
             DB 'lstrcat',0
             DB 'GetSystemDirectoryA',0
             DB 'GetWindowsDirectoryA',0
             DB 'GetTickCount',0
             DB 0FFh
;****** and where the addresses will be put
       CALLS DD 7 DUP (0)

.data?

.code

start:

DLL_TEST9:              ;calling function by name-load

PUSH OFFSET KERNEL_NAME

CALL GetModuleHandleA   ;get handle of Kernel32.dll

MOV EBX,EAX                    ;keep in ebx
MOV EDI,OFFSET CALLS           ;get place to put API addresses
MOV ESI,OFFSET NAME_STRINGS    ;get list of API names

L1:

PUSH ESI
PUSH EBX
CALL GetProcAddress
OR EAX,EAX              ;see if successful
JZ L4                   ;no
STOSD                   ;insert API address into CALLS

L2:

LODSB                   ;get to end of this API name
OR AL,AL                ;see if end of string yet
JNZ L2                  ;no
LODSB
CMP AL,0FFh             ;see if finished function list
JZ L3                   ;yes
DEC ESI
JMP L1

L3:

CALL [CALLS+18h]        ;ie. GetTickCount
CALL GetTickCount       ;proof correct thing was called

L4:

RET

invoke ExitProcess,0

end     start

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

Magnum

When I try to go to Jeremy's site, I get this.

If you are the account holder, please contact the billing or support department as soon as possible.

I think this came from his site, I don't understand exactly what this code is doing ?

Thanks.



include \masm32\include\masm32rt.inc   

.CONST

.data
   
WaterMark   db  "SiegeWorks 2013 ð__ð" ; Alt 240 char
%Date       db  " &@Date " ; Compile date
%time       db  " &@Time"

KERNEL_NAME  DB 'KERNEL32.DLL',0
NAME_STRINGS DB 'CopyFileA',0
             DB 'DeleteFileA',0
             DB 'lstrlen',0
             DB 'lstrcat',0
             DB 'GetSystemDirectoryA',0
             DB 'GetWindowsDirectoryA',0
             DB 'GetTickCount',0
             DB 0FFh
;****** and where the addresses will be put
       CALLS DD 7 DUP (0)

.data?

.code

start:

DLL_TEST9:              ;calling function by name-load

PUSH OFFSET KERNEL_NAME

CALL GetModuleHandleA   ;get handle of Kernel32.dll

MOV EBX,EAX                    ;keep in ebx
MOV EDI,OFFSET CALLS           ;get place to put API addresses
MOV ESI,OFFSET NAME_STRINGS    ;get list of API names

L1:

PUSH ESI
PUSH EBX
CALL GetProcAddress
OR EAX,EAX              ;see if successful
JZ L4                   ;no
STOSD                   ;insert API address into CALLS

L2:

LODSB                   ;get to end of this API name
OR AL,AL                ;see if end of string yet
JNZ L2                  ;no
LODSB
CMP AL,0FFh             ;see if finished function list
JZ L3                   ;yes
DEC ESI
JMP L1

L3:

CALL [CALLS+18h]        ;ie. GetTickCount
CALL GetTickCount       ;proof correct thing was called

L4:

RET

invoke ExitProcess,0

end     start

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

Jeremy needs to pay his bill   :P

the code simply gets the addresses for a few API proc's and adds them to an array

i would have done it a little differently
rather than finding the end of each string, just create a table of string addresses   :t

NAME_TABLE   DD NAME_STRING0,NAME_STRING1,NAME_STRING2,NAME_STRING3,NAME_STRING4,NAME_STRING5,NAME_STRING6,0

NAME_STRING0 DB 'CopyFileA',0
NAME_STRING1 DB 'DeleteFileA',0
NAME_STRING2 DB 'lstrlen',0
NAME_STRING3 DB 'lstrcat',0
NAME_STRING4 DB 'GetSystemDirectoryA',0
NAME_STRING5 DB 'GetWindowsDirectoryA',0
NAME_STRING6 DB 'GetTickCount',0