The MASM Forum

Specialised Projects => CoderStudio => Topic started by: Manos on February 09, 2019, 06:22:42 AM

Title: Windows Projects
Post by: Manos on February 09, 2019, 06:22:42 AM
I upload three simple projects.
To help you, put the files of each project in the bin folder,
as I describe in my post :Using CoderStudio Tools
After build each project, delete its files from the bin folder
and put the files of the other project.

Manos.
Title: Re: Windows Projects
Post by: Vortex on February 09, 2019, 09:07:35 PM
Thanks for the examples. Here is how to build the dialog box example with a batch file :

Code: [Select]
\pcc32\bin\pcc32.exe /I\pcc32\include /c Frame.c
\pcc32\bin\rc32.exe /I\pcc32\include Dialog.rc
\pcc32\bin\link32 /LIBPATH:\pcc32\lib /SUBSYSTEM:WINDOWS Frame.obj Dialog.res kernel32.lib user32.lib shell32.lib gdi32.lib comctl32.lib msvcrt.lib
Title: Re: Windows Projects
Post by: Vortex on February 09, 2019, 10:33:40 PM
Here is a classical window example.
Title: Re: Windows Projects
Post by: Vortex on February 12, 2019, 06:26:24 AM
Bitmap from file example.
Title: Re: Windows Projects
Post by: Manos on February 12, 2019, 07:35:56 AM
Very good example Vortex.

Note:
With CoderStudio IDE you can mix assembly and C modules.
Soon I 'll upload your project using CoderStudio IDE.

Manos.
Title: Re: Windows Projects
Post by: Manos on February 13, 2019, 08:33:58 PM
Open with CoderStudio IDE the BmpFromFile.sdp file
and build the project.

Manos.
Title: Re: Windows Projects
Post by: Vortex on February 14, 2019, 06:44:59 AM
Hi Manos,

Thanks, it works as expected.
Title: Re: Windows Projects
Post by: TimoVJL on February 14, 2019, 08:28:04 AM
When we see that the pcc32 is able to compile UASM from source  ?
Now, missing headers, hanging,...
Title: Re: Windows Projects
Post by: Manos on February 14, 2019, 08:45:06 AM
When we see that the pcc32 is able to compile UASM from source  ?
Now, missing headers, hanging,...

Could you send me the 32 bit source to try it ?

Manos.
Title: Re: Windows Projects
Post by: TimoVJL on February 14, 2019, 08:48:04 AM
This well known site:
https://github.com/Terraspace/UASM
Title: Re: Windows Projects
Post by: Vortex on February 16, 2019, 06:29:19 AM
An example to save the icon of an executable :
Code: [Select]
#include <windows.h>
#include <olectl.h>

const IID __cdecl IID__IPicture =
    { 0x7BF80980, 0xBF32, 0x101A, { 0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB } };

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
PICTDESC pd;
HICON hIcon;
HMODULE hModule;
IPicture *pBitmap;
IStream  *pStream;
LONG pcbSize;
HGLOBAL hGlobal;
LPVOID IconAddr;
HANDLE hFile;
DWORD bWritten;

// load the test executable and the associated icon

hModule = LoadLibrary("Test.exe");
hIcon = LoadIcon(hModule,MAKEINTRESOURCE(100));

// initialize the PICTDESC structure

pd.cbSizeofstruct = sizeof(PICTDESC);
pd.picType = PICTYPE_ICON;
pd.icon.hicon = hIcon;

// create the OLE image

OleCreatePictureIndirect(&pd,&IID__IPicture,TRUE,(void **)&pBitmap);

// create the destination stream to save the icon
                                                   
CreateStreamOnHGlobal(NULL,TRUE,(LPSTREAM *)&pStream);

// save the icon to the stream
                                                   
pBitmap->lpVtbl->SaveAsFile(pBitmap,(LPSTREAM)pStream,TRUE,&pcbSize);

// get the address of the icon in memory

GetHGlobalFromStream(pStream,&hGlobal);
IconAddr = GlobalLock(hGlobal);

// write the icon to disc

hFile= CreateFile("Smiley.ico",GENERIC_WRITE,0,0,
CREATE_ALWAYS,0,0);

WriteFile(hFile,IconAddr,pcbSize,&bWritten,0);

CloseHandle(hFile);

// release the pointers

pBitmap->lpVtbl->Release(pBitmap);
pStream->lpVtbl->Release(pStream);

return 0;
}
Title: Re: Windows Projects
Post by: Manos on February 17, 2019, 10:40:06 PM
When we see that the pcc32 is able to compile UASM from source  ?
Now, missing headers, hanging,...

Download the Additional Includes and put the new header files
in the include folder.

Manos.
Title: Re: Windows Projects
Post by: TimoVJL on February 17, 2019, 11:27:53 PM
missing signal.h io.h sys/stat.h
pcc32.exe hangs in equate.c
Title: Re: Windows Projects
Post by: Manos on February 18, 2019, 12:03:18 AM
missing signal.h io.h sys/stat.h
pcc32.exe hangs in equate.c

Today I 'll upload an updated include folder.

Manos.
Title: Re: Windows Projects
Post by: Manos on February 18, 2019, 05:16:38 AM
missing signal.h io.h sys/stat.h
pcc32.exe hangs in equate.c


The include files and the pcc32 are updated to avoid hanging.

Downlad pcc32 from: http://www.manoscoder.gr/mysite/coderstudio.htm

Manos.
Title: Re: Windows Projects
Post by: TimoVJL on February 18, 2019, 05:41:54 AM
Still some errors and equate.c hangs.
Code: [Select]
C:\code\UAsm\UASM-master\H\codegenv2.h(112):  error:
More than 25 errors. Compilation stoped.
251 errors

C:\code\UAsm\UASM-master\hll.c
22 errors

C:\code\UAsm\UASM-masterX\macro.c(66):  error: Syntax error: ; expected
1 errors
Code: [Select]
#ifdef __WATCOMC__
static _inline char HexDigit( char x )
#elif defined(_MSC_VER)
static _inline char HexDigit( char x )   // line 66
#else
static char HexDigit( char x )
#endif
{
    x &= 0xF;
    return((x > 9) ? (x - 10 + 'A') : (x + '0'));
}
Title: Re: Windows Projects
Post by: Manos on February 18, 2019, 05:48:51 AM
pcc32 is for Windows projects.
If UASM has been builded with another compiler, you should do changes in the source.

Manos.
Title: Re: Windows Projects
Post by: Manos on February 18, 2019, 06:36:02 AM
As I found in your code there is: static _inline etc.
pcc32 accepts inline functions when enable the switch: /C99
Also instead of _inline you must write: inline

Manos.
Title: Re: Windows Projects
Post by: TimoVJL on February 18, 2019, 06:58:43 AM
OK. -D_inline=inline helps with macro.c and hll.c
equate.c hangs and codegen.c have errors
Code: [Select]
C:\code\UAsm\UASM-masterX\H\codegenv2.h(8):  error: Enumerated type 'instr_group' previously defined
C:\code\UAsm\UASM-masterX\H\codegenv2.h(7):  warning: Previous declaration of 'instr_group' here
C:\code\UAsm\UASM-masterX\H\codegenv2.h(9):  error: Multiple declaration of 'GP1'
...
C:\code\UAsm\UASM-masterX\H\codegenv2.h(111):  error: Multiple declaration of 'M32UINT'
C:\code\UAsm\UASM-masterX\H\codegenv2.h(112):  error: Multiple declaration of 'M64UINT'
C:\code\UAsm\UASM-masterX\H\codegenv2.h(112):  error:
More than 25 errors. Compilation stoped.
251 errors
So pcc32 don't support #pragma once ?
Title: Re: Windows Projects
Post by: Manos on February 18, 2019, 07:05:59 AM
pcc32 support #pragma once
But #pragma once must include in header files.

Manos.
Title: Re: Windows Projects
Post by: TimoVJL on February 18, 2019, 07:29:46 AM
equate.c + headers for testing.
pcc32 support #pragma once
But #pragma once must include in header files.

Manos.
This fixed it
Code: [Select]
#pragma once
#ifndef _CODEGENV2_H_INCLUDED
#define _CODEGENV2_H_INCLUDED
...
#endif  // _CODEGENV2_H_INCLUDED
Title: Re: Windows Projects
Post by: Manos on February 18, 2019, 07:54:32 AM
OK.

Manos.
Title: Re: Windows Projects
Post by: Manos on February 18, 2019, 04:37:43 PM
You forgot to include the equate.c file for testing.

Manos.
Title: Re: Windows Projects
Post by: TimoVJL on February 18, 2019, 07:36:44 PM
It should be in test_equate.zip

In test2.zip that #pragma once issue.
Title: Re: Windows Projects
Post by: Vortex on February 20, 2019, 05:17:27 AM
An inline assembly example based on the Nasm syntax :

Code: [Select]
#include <windows.h>
#include <stdio.h>

char msg[] = "Hello world!";
char title[] = "pcc32";

void WriteMessage(void)
{

asm{
    push    0
    push    title
    push    msg
    push    0
    call    MessageBox
    }

}

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    LPSTR lpCmdLine, int nCmdShow)
{
    WriteMessage();
    return 0;
}
Title: Re: Windows Projects
Post by: Manos on February 20, 2019, 05:45:41 AM
Good example.

The option: /SUBSYSTEM:WINDOWS is unnecessary
because Link32 has it as default.
Have a look at: http://masm32.com/board/index.php?topic=7681.0

Manos.
Title: Re: Windows Projects
Post by: Vortex on March 19, 2019, 06:20:55 AM
Creating an MD5 Hash from File Content :

https://docs.microsoft.com/en-us/windows/desktop/SecCrypto/example-c-program--creating-an-md-5-hash-from-file-content

Source code built with pcc32
Title: Re: Windows Projects
Post by: Vortex on March 22, 2019, 04:53:48 AM
liblzg built with pcc32

Quote
liblzg is a minimal implementation of an LZ77 class compression library. The main characteristic of the library is that the decoding routine is very simple, fast, and requires no memory.

In general, liblzg does not compress as well as zlib, for instance. On the other hand the decoder is very simple and very fast - ideal for systems with tight memory limits or limited processing capabilities.

Also, the decompression routine is easliy ported to just about any conceivable programming language (assembly language, JavaScript, etc).

http://liblzg.bitsnbites.eu
Title: Re: Windows Projects
Post by: Vortex on March 24, 2019, 08:51:36 PM
Simple dialog box example.
Title: Re: Windows Projects
Post by: Vortex on April 12, 2019, 04:16:11 AM
Quick example using msvcrt.lib supplied with pcc32 :

Code: [Select]
.386
.model flat,stdcall
option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\user32.inc
include     \masm32\include\masm32.inc

includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\user32.lib
includelib  \masm32\lib\masm32.lib

printf PROTO C :DWORD,:VARARG

.data

string  db '%s',13,10,0

.code

main PROC C uses esi ebx argc:DWORD,argv:DWORD

    mov     ebx,argc
    mov     esi,argv
@@:
    invoke  printf,ADDR string,DWORD PTR [esi]
    add     esi,4
    dec     ebx
    jnz     @b
    ret

main ENDP

END