The MASM Forum

Projects => Rarely Used Projects => GoAsm => Topic started by: jorgon on June 18, 2012, 12:29:13 AM

Title: GO TOOLS TUTORIALS, ARTICLES and SAMPLE CODE
Post by: jorgon on June 18, 2012, 12:29:13 AM
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 (http://www.godevtool.com).  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.

(http://www.godevtool.com/cake.gif)"GO" TUTORIALS and SAMPLE CODE(http://www.godevtool.com/sample.gif)

These tutorials are from

the (http://www.godevtool.com/red.gif)GoBug manual (http://www.godevtool.com/GobugFrame.htm), the (http://www.godevtool.com/amber.gif)Testbug manual (http://www.godevtool.com/TestbugFrame.htm) or the (http://www.godevtool.com/green.gif)GoAsm manual (http://www.godevtool.com/GoasmFrame.htm)
(http://www.godevtool.com/beginner.gif) Beginners


(http://www.godevtool.com/green.gif)Quick start to .. writing a simple Windows program (http://www.godevtool.com/GoasmHelp/quickstart1.htm) Step-by-step guide to making simple Windows programs.

(http://www.godevtool.com/green.gif)For those new to programming (http://www.godevtool.com/GoasmHelp/newprog.htm) The basic build process and the files you use.

(http://www.godevtool.com/green.gif)For those new to assembly language (http://www.godevtool.com/GoasmHelp/newass.htm) An introduction to the various assembler instructions (mnemonics) and what they do.

(http://www.godevtool.com/green.gif)For those new to Windows (http://www.godevtool.com/GoasmHelp/newwin.htm) A basic description of what Windows does and how it works.

(http://www.godevtool.com/green.gif)For those new to symbolic debugging (http://www.godevtool.com/GoasmHelp/newsymb.htm) What debugging is and how to use it to find errors in your programs.

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/green.gif)Simple Windows console program (http://www.godevtool.com/GoasmHelp/HelloWorld1) Source code for a program writing "Hello World" to the console.

(http://www.godevtool.com/green.gif)Simple Windows GUI program (http://www.godevtool.com/GoasmHelp/HelloWorld2) Source code for a program writing "Hello World" to a window.

(http://www.godevtool.com/green.gif)Simple Windows GUI program (http://www.godevtool.com/GoasmHelp/HelloWorld3)
 Source code for a program writing "Hello World" to a window, but demonstrating automated stack frames, structures, INVOKE, locally scoped labels and redefinitions (macros).

(http://www.godevtool.com/green.gif)Simple Dialog program (http://www.godevtool.com/GoasmHelp/HelloDialog) Source code for a program creating a dialog, and showing various ways of writing to it.

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/green.gif)Understand bits, binary and bytes (http://www.godevtool.com/GoasmHelp/usbyte.htm)

(http://www.godevtool.com/green.gif)Understand hex numbers (http://www.godevtool.com/GoasmHelp/ushex.htm)

(http://www.godevtool.com/green.gif)Understand finite, negative, signed and two's complement numbers (http://www.godevtool.com/GoasmHelp/usnumbers.htm)

(http://www.godevtool.com/green.gif)Understand registers (http://www.godevtool.com/GoasmHelp/usreg.htm)

(http://www.godevtool.com/green.gif)Understand the stack - Part 1 (http://www.godevtool.com/GoasmHelp/usstack1.htm)

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/green.gif)FAQ (http://www.godevtool.com/GoasmHelp/msdos.htm)
"When I click on the GoAsm or GoLink or GoRC icon something just flashes on the screen but nothing else happens".

(http://www.godevtool.com/intermediate.gif) Intermediate

(http://www.godevtool.com/green.gif)Some programming hints and tips (http://www.godevtool.com/GoasmHelp/progtips.htm)

(http://www.godevtool.com/amber.gif)Size of code - keep it compact! (http://www.godevtool.com/TestbugHelp/SizeofCode.htm)

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/green.gif)Understand flags and conditional jumps (http://www.godevtool.com/GoasmHelp/usflags.htm)

(http://www.godevtool.com/amber.gif)Real-time conditional jump test (Testbug) (http://www.godevtool.com/TestbugHelp/Conditional.htm)

(http://www.godevtool.com/amber.gif)Real-time flag test (Testbug) (http://www.godevtool.com/TestbugHelp/Flagdemo.htm)

(http://www.godevtool.com/green.gif)Understand reverse storage (http://www.godevtool.com/GoasmHelp/usreverse.htm)

(http://www.godevtool.com/green.gif)Understand the stack - Part 2 (http://www.godevtool.com/GoasmHelp/usstack2.htm)

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/amber.gif)Use of NEG and NOT (http://www.godevtool.com/TestbugHelp/Negandnot.htm)

(http://www.godevtool.com/amber.gif)Use of BT (and variants) and BSWAP (http://www.godevtool.com/TestbugHelp/BitControl.htm)

(http://www.godevtool.com/amber.gif)Use of REP SCASB (http://www.godevtool.com/TestbugHelp/UseofRepscas.htm)

(http://www.godevtool.com/amber.gif)Types of JMPs & CALLs to unique labels (http://www.godevtool.com/TestbugHelp/TypesJMPCALL.htm)

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/green.gif)Standardized window and dialog procedure (http://www.godevtool.com/GoasmHelp/callback)

(http://www.godevtool.com/amber.gif)Optimising the loop instruction (http://www.godevtool.com/TestbugHelp/Optimisation.htm#loop)

(http://www.godevtool.com/amber.gif)Optimising REP STOS MOVS and STAS (http://www.godevtool.com/TestbugHelp/Optimisation.htm#rep)

(http://www.godevtool.com/amber.gif)Alignment of oft-called functions (http://www.godevtool.com/TestbugHelp/Optimisation.htm#alf)

(http://www.godevtool.com/amber.gif)Alignment of memory reads, writes and compares (http://www.godevtool.com/TestbugHelp/Optimisation.htm#alm)

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/amber.gif)Writing a 32-bit number in hex (http://www.godevtool.com/TestbugHelp/Writinghex.htm)

(http://www.godevtool.com/amber.gif)Writing a 32-bit number in ascii (http://www.godevtool.com/TestbugHelp/Writingdecimal.htm)

(http://www.godevtool.com/amber.gif)Writing a 64-bit number in ascii (http://www.godevtool.com/TestbugHelp/FPUvCPU.htm#ascii)

(http://www.godevtool.com/amber.gif)Dividing a 64-bit number (http://www.godevtool.com/TestbugHelp/FPUvCPU.htm#div)

(http://www.godevtool.com/amber.gif)Data in the code section - effect on speed (http://www.godevtool.com/TestbugHelp/Dataincode.htm)

(http://www.godevtool.com/amber.gif)Using VirtualAlloc and HeapCreate (http://www.godevtool.com/TestbugHelp/MemoryAPI.htm)

(http://www.godevtool.com/amber.gif)HeapCreate v VirtualAlloc, comparing speed (http://www.godevtool.com/TestbugHelp/Memoryheap.htm)

(http://www.godevtool.com/amber.gif)Drawing text to screen using Windows (http://www.godevtool.com/TestbugHelp/Drawingtext.htm)

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/amber.gif)What Dlls are and why they are useful (http://www.godevtool.com/TestbugHelp/Dynamic.htm#whatandwhy)

(http://www.godevtool.com/amber.gif)Dll loading, memory, stack and threads (http://www.godevtool.com/TestbugHelp/Dynamic.htm#load)

(http://www.godevtool.com/amber.gif)Calling Dlls with no arguments (http://www.godevtool.com/TestbugHelp/Dynamic.htm#dll1)

(http://www.godevtool.com/amber.gif)Calling Dlls with arguments via the stack (http://www.godevtool.com/TestbugHelp/Dynamic.htm#dll2)

(http://www.godevtool.com/amber.gif)Dll sending data to the calling exe (http://www.godevtool.com/TestbugHelp/Dynamic.htm#dll4)

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/green.gif)Do nothing Linux program by V.Krishnakumar (http://www.godevtool.com/GoasmHelp/LinuxT)

(http://www.godevtool.com/advanced.gif) Advanced

(http://www.godevtool.com/amber.gif)Conditional jump branch hints (http://www.godevtool.com/TestbugHelp/Optimisation.htm#hint)

(http://www.godevtool.com/amber.gif)Use of IDIV (http://www.godevtool.com/TestbugHelp/UseofIDIV.htm)

(http://www.godevtool.com/amber.gif)Use of IMUL (http://www.godevtool.com/TestbugHelp/UseofIMUL.htm)

(http://www.godevtool.com/amber.gif)BCD coding: AAA and DAA (http://www.godevtool.com/TestbugHelp/BCDcoding.htm)

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/amber.gif)Using the FPU (http://www.godevtool.com/TestbugHelp/FPIns.htm)

(http://www.godevtool.com/amber.gif)Using the MMX registers (http://www.godevtool.com/TestbugHelp/MMXins.htm)

(http://www.godevtool.com/amber.gif)Using the 3DNow! instructions (http://www.godevtool.com/TestbugHelp/3DNow.htm)

(http://www.godevtool.com/amber.gif)Using the XMM integer instructions (http://www.godevtool.com/TestbugHelp/XMMintins.htm)

(http://www.godevtool.com/amber.gif)Using the XMM SSE instructions (http://www.godevtool.com/TestbugHelp/XMMfpins.htm)

(http://www.godevtool.com/amber.gif)Using the XMM SSE2 instructions (http://www.godevtool.com/TestbugHelp/XMMfpins2.htm)

(http://www.godevtool.com/amber.gif)SIMD floating point control (http://www.godevtool.com/TestbugHelp/FPcontrol.htm)

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/amber.gif)Dlls: Start-up code and run-time link (http://www.godevtool.com/TestbugHelp/Dynamic.htm#dll3)

(http://www.godevtool.com/amber.gif)Dlls: Exporting data pointers (http://www.godevtool.com/TestbugHelp/Dynamic.htm#dll5)

(http://www.godevtool.com/amber.gif)Dll using a function in the calling exe (http://www.godevtool.com/TestbugHelp/Dynamic.htm#dll6)

(http://www.godevtool.com/amber.gif)Calling a Dll function by ordinal using GetProcAddress (http://www.godevtool.com/TestbugHelp/Dynamic.htm#dll7)

(http://www.godevtool.com/amber.gif)Calling a Dll function directly by ordinal (http://www.godevtool.com/TestbugHelp/Dynamic.htm#dll8)

(http://www.godevtool.com/amber.gif)Calling a Dll function by name-load (http://www.godevtool.com/TestbugHelp/Dynamic.htm#dll9)

(http://www.godevtool.com/amber.gif)Testing who called Dll start-up code (http://www.godevtool.com/TestbugHelp/Dynamic.htm#dll10)

(http://www.godevtool.com/amber.gif)Addressing arguments using ebp (http://www.godevtool.com/TestbugHelp/StackTests.htm#ebp)

(http://www.godevtool.com/amber.gif)Addressing arguments using esp (http://www.godevtool.com/TestbugHelp/StackTests.htm#esp)

(http://www.godevtool.com/amber.gif)Addressing local data in home-made stack frames (http://www.godevtool.com/TestbugHelp/StackTests.htm#local)

(http://www.godevtool.com/amber.gif)Ways of saving return address in stack frames (http://www.godevtool.com/TestbugHelp/StackTests.htm#return)

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/amber.gif)Making temporary on-screen notices (http://www.godevtool.com/TestbugHelp/Temporary.htm)

(http://www.godevtool.com/amber.gif)Clipping - control using the device context (http://www.godevtool.com/TestbugHelp/ClippingDC.htm)

(http://www.godevtool.com/amber.gif)Clipping - control using other methods (http://www.godevtool.com/TestbugHelp/ClippingWnd.htm)

(http://www.godevtool.com/amber.gif)Using different languages in resources (http://www.godevtool.com/TestbugHelp/Language.htm)

(http://www.godevtool.com/amber.gif)Different types of window procedures (http://www.godevtool.com/TestbugHelp/WndProc.htm)

(http://www.godevtool.com/amber.gif)Recursion in window procedures (http://www.godevtool.com/TestbugHelp/WndProcRecursion.htm)

(http://www.godevtool.com/amber.gif)Simulating a dialog (http://www.godevtool.com/TestbugHelp/Simdlg.htm)

(http://www.godevtool.com/amber.gif)Making and debugging multi-threaded programs (http://www.godevtool.com/TestbugHelp/DebuggingThreads.htm)

(http://www.godevtool.com/amber.gif)Causing and debugging exceptions (http://www.godevtool.com/TestbugHelp/Exceptions.htm)

(http://www.godevtool.com/amber.gif)Messages around the system (http://www.godevtool.com/TestbugHelp/Messages.htm)

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/green.gif)Writing 64-bit programs (http://www.godevtool.com/GoasmHelp/64bits.htm)

(http://www.godevtool.com/green.gif)Hello 64World 1 (http://www.godevtool.com/GoasmHelp/Hello64World1) a simple 64-bit console program

(http://www.godevtool.com/green.gif)Hello 64World 2 (http://www.godevtool.com/GoasmHelp/Hello64World2) a simple 64-bit windows program

(http://www.godevtool.com/green.gif)Hello 64World 3 (http://www.godevtool.com/GoasmHelp/Hello64World3) switchable 32-bit or 64-bit windows program

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/green.gif)Writing Unicode programs (http://www.godevtool.com/GoasmHelp/Unicode.htm)

(http://www.godevtool.com/green.gif)Hello Unicode 1 (http://www.godevtool.com/GoasmHelp/HelloUnicode1) 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.

(http://www.godevtool.com/green.gif)Hello Unicode 2 (http://www.godevtool.com/GoasmHelp/HelloUnicode2) 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.

(http://www.godevtool.com/green.gif)Hello Unicode 3 (http://www.godevtool.com/GoasmHelp/HelloUnicode3) A Unicode UTF-8 source script, which draws Unicode characters using TextOutW, and also demonstrates Unicode/ANSI switching using the Microsoft Layer for Unicode.

(http://www.godevtool.com/green.gif)Run Time Loading (http://www.godevtool.com/GoasmHelp/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.

(http://www.godevtool.com/grey.gif) Microsoft Layer for Unicode ("mslu") (http://www.godevtool.com/GolinkHelp/MSLU.htm)
Describes what the mslu is, how it works, and how to use it with the "Go" tools.

(http://www.godevtool.com/amber.gif) Demonstrations of the mslu in practice (http://www.godevtool.com/TestbugHelp/UniLang.htm#mslu)

(http://www.godevtool.com/amber.gif) Demonstrations of what W9x/ME and NT/2000/XP can do to draw non-Roman characters (http://www.godevtool.com/TestbugHelp/UniLang.htm)

(http://www.godevtool.com/line200.gif)

(http://www.godevtool.com/grey.gif)Structured Exception Handling (view) (http://www.godevtool.com/ExceptFrame.htm)

(http://www.godevtool.com/grey.gif)Structured Exception Handling (download 56K) (http://www.godevtool.com/Except32.zip)
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.

(http://www.godevtool.com/line200.gif)
(http://www.godevtool.com/GobugHelp/GoBug.gif) Debugging


(http://www.godevtool.com/green.gif)For those new to symbolic debugging (http://www.godevtool.com/GoasmHelp/newsymb.htm)

(http://www.godevtool.com/red.gif)Debugging: what, when and how (GoBug) (http://www.godevtool.com/GobugHelp/ContWhatWhenHow.htm)

(http://www.godevtool.com/red.gif)Around GoBug (http://www.godevtool.com/GobugHelp/ContAround.htm)

(http://www.godevtool.com/red.gif)Using GoBug (http://www.godevtool.com/GobugHelp/ContUsing.htm)

(http://www.godevtool.com/red.gif)Getting system and debuggee information (http://www.godevtool.com/GobugHelp/ContInf.htm)

(http://www.godevtool.com/amber.gif)Testing GoBug using Testbug - various tests (http://www.godevtool.com/TestbugHelp/GoBug.htm)

(http://www.godevtool.com/red.gif)View the complete GoBug manual (http://www.godevtool.com/GobugFrame.htm)

(http://www.godevtool.com/grey.gif)The "RSDS" or "DS" pdb symbol file format (http://www.godevtool.com/Other/pdb.htm)
Title: Re: GO TOOLS TUTORIALS, ARTICLES and SAMPLE CODE
Post by: Magnum on March 05, 2013, 02:03:18 AM
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.

Code: [Select]

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

Title: Re: GO TOOLS TUTORIALS, ARTICLES and SAMPLE CODE
Post by: Magnum on March 05, 2013, 02:09:45 AM
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.

Code: [Select]

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

Title: Re: GO TOOLS TUTORIALS, ARTICLES and SAMPLE CODE
Post by: dedndave on March 05, 2013, 02:16:11 AM
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

Code: [Select]
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
Title: Re: GO TOOLS TUTORIALS, ARTICLES and SAMPLE CODE
Post by: dedndave on March 05, 2013, 02:41:21 AM
http://web.archive.org/web/20121105083043/http://www.godevtool.com/ (http://web.archive.org/web/20121105083043/http://www.godevtool.com/)