News:

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

Main Menu

Irvine32 library problem

Started by ieee2, June 16, 2013, 10:36:29 AM

Previous topic - Next topic

dedndave

my appologies
Kip has a file named "SmallWindows.inc", i believe
he has a short version of windows.inc

in order to use a lot of code in here, you will want to install the masm32 package
if you just want to make that routine work, you need to define the structures

the INPUT_RECORD structure is a union of a few others
in order to use that one, you need to define all of them

there are probably easier ways to go about this - lol

put these at the beginning of the program (or in an include file)
notice, they are only structure definitions, and do not generate any code
i also included the UINT typedef, as Hutch suggested
you may have to add a similar line for HANDLE (also a DWORD)

UINT    TYPEDEF DWORD

;----------------------------------------------------

MOUSE_EVENT_RECORD STRUCT
  dwMousePosition    COORD <>
  dwButtonState      dd ?
  dwControlKeyState  dd ?
  dwEventFlags       dd ?
MOUSE_EVENT_RECORD ENDS

;----------------------------------------------------

KEY_EVENT_RECORD  STRUCT
  bKeyDown          dd ?
  wRepeatCount      dw ?
  wVirtualKeyCode   dw ?
  wVirtualScanCode  dw ?
  UNION
    UnicodeChar       dw ?
    AsciiChar         db ?
  ENDS
  dwControlKeyState dd ?
KEY_EVENT_RECORD  ENDS

;----------------------------------------------------

WINDOW_BUFFER_SIZE_RECORD STRUCT
  dwSize                    COORD <>
WINDOW_BUFFER_SIZE_RECORD ENDS

;----------------------------------------------------

MENU_EVENT_RECORD STRUCT
  dwCommandId       dd ?
MENU_EVENT_RECORD ENDS

;----------------------------------------------------

FOCUS_EVENT_RECORD STRUCT
  bSetFocus          dd ?
FOCUS_EVENT_RECORD ENDS

;----------------------------------------------------

INPUT_RECORD          STRUCT
  EventType             dw ?
  alignment             db ?,?
  UNION
    KeyEvent              KEY_EVENT_RECORD <>
    MouseEvent            MOUSE_EVENT_RECORD <>
    WindowBufferSizeEvent WINDOW_BUFFER_SIZE_RECORD <>
    MenuEvent             MENU_EVENT_RECORD <>
    FocusEvent            FOCUS_EVENT_RECORD <>
  ENDS
INPUT_RECORD          ENDS

;----------------------------------------------------


Michael's method is shorter, but may leave you wanting, later

dedndave

ok - i took another look at Kip's include files

it seems that he does have the structures defined
if you "include Irvine32.inc", that file includes SmallWin.inc
SmallWin.inc has them

so - all you should need is HANDLE and UINT
they are both DWORD-sized types
so - you can replace HANDLE and UINT with DWORD
or, add the typedef's
HANDLE  TYPEDEF DWORD
UINT    TYPEDEF DWORD

you should place them near the beginning of the program, just after the include's/includelib's

MichaelW

Dave,

The Irvine smallwin.inc structure follows the Microsoft declaration:

typedef struct _KEY_EVENT_RECORD {
    BOOL bKeyDown;
    WORD wRepeatCount;
    WORD wVirtualKeyCode;
    WORD wVirtualScanCode;
    union {
        WCHAR UnicodeChar;
        CHAR   AsciiChar;
    } uChar;
    DWORD dwControlKeyState;
} KEY_EVENT_RECORD, *PKEY_EVENT_RECORD;


And in C/C++ (or any language where the header files follow the Microsoft declaration) the union name is required to access the union members:

#include <windows.h>
#include <stdio.h>
#include <conio.h>
void main( void )
{
    KEY_EVENT_RECORD ker;

    // ker.AsciiChar = 'X';
 
    // CL:
    // error C2039: 'AsciiChar' : is not a member of '_KEY_EVENT_RECORD'
    // C:\Program Files\Microsoft Platform SDK\Include\WinCon.h(41) :
    // see declaration of '_KEY_EVENT_RECORD'
 
    // GCC:
    // error: 'KEY_EVENT_RECORD' has no member named 'AsciiChar'
 
    // But this works as expected:
 
    ker.uChar.AsciiChar = 'X';

    printf("%c\n", ker.uChar.AsciiChar);
    getch();
}


A structure that does not conform to the published and widely distributed Microsoft documentation is a hidden problem that anyone using the structure, and the Microsoft documentation as a reference, will have to deal with at least once.

I have been compiling a list of such structures in the MASM32 windows.inc, and this makes 6 so far.
Well Microsoft, here's another nice mess you've gotten us into.

TWell

There seems to be online help for Irvine lib here

blobue

Thanks again for all the help on this.  Is anyone able to get console or terminal output for the program?  As I said, I have my suspicions that my output issue might be related to windows 8 permissions or terminal model issues.  I'll give it a little more effort today before I throw in the towel.

Thanks

sinsi

Are you building it as a console app (/subsystem:console)?
Tá fuinneoga a haon déag níos fearr :biggrin:

dedndave

ok - going back to the original post of this thread.....

i wanted to see if i could make it work without using the masm32 package   :P

so, i went to Kip's site and downloaded the VS2005 version of his library with examples

http://www.kipirvine.com/asm/examples/index.htm

i removed the double quotes from the includes to assemble the program
you may have to adjust the inc/lib paths to suit your needs
it gave me an unresolved external message with a decorated name
that told me that the library was missing from the source - user32.lib

        include     Irvine32.inc
        includelib  Irvine32.lib
        includelib  kernel32.lib
        includelib  user32.lib

        .code

main    PROC

        mov     eax,10000h ; EAX = 10000h
        add     eax,40000h ; EAX = 50000h
        sub     eax,20000h ; EAX = 30000h
        call    DumpRegs   ; display registers
        call    WaitMsg    ; wait for a keypress
        exit

main    ENDP

        END     main


to assemble...
ml /c /coff test.asm
link /SUBSYSTEM:CONSOLE test.obj

notice that some of the switches are case-sensitive

the output....
  EAX=00030000  EBX=7FFD4000  ECX=0012FFB0  EDX=7C90E514
  ESI=00000000  EDI=00000010  EBP=0012FFF0  ESP=0012FFC4
  EIP=00401014  EFL=00000206  CF=0  SF=0  ZF=0  OF=0  AF=0  PF=1

Press any key to continue...


EDIT:
i looked a little further, and i see that Kip has a routine named "WaitMsg", which is like our inkey macro
i added that to the source above

blobue

Thanks all!  That works beautifully.  I missed the linker option to create a console program.  That's a big difference coming from UNIX coding.  Thanks Microsoft! 

chth96

Though I'm novice in the field of assembly, I have Kip R.Irvine's assembly book and want to follow this source code example on MASM32 editor
[ My computer's operation system is Windows 7 professional and using MASM32 SDK Version 11 currently.  I supercited below code and made a main.asm file on MASM32 subdirectory of C drive(c:\MASM32)].



Whenever I select Assemble&Link option from Project tab,It shows building result of console windows questionless but Whenever I select run program option,There is no response at all.
[Even in console windows(select cmd prompt from file tab), Main.exe execution show no response.]


TITLE This program adds and subtracts 32-bit integers.

include C:\irvine\Irvine32.inc
includelib C:\irvine\irvine32.lib
includelib c:\masm32\lib\kernel32.lib
includelib C:\irvine\user32.lib


.code
main    PROC


        mov     eax,10000h ; EAX = 10000h
        add     eax,40000h ; EAX = 50000h
        sub     eax,20000h ; EAX = 30000h
        call    DumpRegs   ; display registers
       
        exit


main    ENDP
END     main

But strangely, Whenever I type below assemble building code on console windows(selecting Cmd Prompt or shortcut key Ctrl+D)  ,then Select run program from project tab or Execute main.exe on console windows,  Both of two execution method normally shows register output.

ml /c /coff main.asm
link /SUBSYSTEM:CONSOLE main.obj

It is out of the question for me Why it won't be executed Whenever I build asm file with Assemble&Link option .
Is there anyone who know what cause this irritating build disorder and Let me know How I can fix this problem?

I'm sorry My poor English may cause you some[/size][/font] kind of misunderstand and Thanks in advance. :bgrin:



rrr314159

Hello chth96, welcome,

Use Console Assemble & Link, farther down on the same menu
I am NaN ;)

chth96

Quote from: rrr314159 on February 22, 2015, 10:52:27 PM
Hello chth96, welcome,

Use Console Assemble & Link, farther down on the same menu

Thanks very much for your reply! It works perfectly.I seems to have overlooked that There is console  Assemble & Link option.
BTW,What is crucial difference between "Console Assemble & Link option" and primary Assemble & Link?

rrr314159

It uses this link option:

link /SUBSYSTEM:CONSOLE yourprog.obj

Use the other one when you don't want a console, e.g. Windows program. That's why it worked when you typed the lines into the cmd window.

c u later ...
I am NaN ;)

chth96

Thanks you again for your confirmation reply. :t
I noticed that MASM32 classify build type into two options(windows and cmd console mode),and It is very unfamiliar for me who are accustomed to MS Visual basic which provide only one building and execute.
Anyway,now I tried to  accustom myself to Ollydbg debugger in order to observe  Flag and stack and value of memory address during Real-time execution of given source code.
I hope that you don't mind me If I happen to asking much of basic instructions about MASM32 which might seems like needless question  on your end.

rrr314159

chth96:
QuoteI hope that you don't mind me If I happen to asking much of basic instructions about MASM32 ...
Certainly I don't mind at all, ask away. But I hope that you don't mind me If I happen to not answer :biggrin:
Quote...which might seems like needless question  on your end.
I was tripped up also by that menu. I saw "Assemble & Link" and figured that's what I wanted ... that "console a&l" was some advanced option ... took me a while to figure it out.
Quotenow I tried to  accustom myself to Ollydbg debugger in order to observe  Flag and stack and value of memory address during Real-time execution of given source code.
Actually I find WinDbg easier to deal with. Olly has various advanced options, e.g. a lot of stuff to do with Windows function calls, that I don't care about ... I don't want all the info displayed, takes up 2 much real estate on the screen, and usually I need only a register value or a few lines disassembly ... but everybody loves it, so probably u will too.

Good luck, c u later!
I am NaN ;)

John T

Hey yall - sorry to intrude but didnt wany to start a topic since I'm trying to get theings working too
I'm having trouble with BeginPaint, specifically PAINTSTRUCT is unrecognized when I try to set up my local variable of that type.
Is there anything like a struct.inc for masm or can it be found somewhere else?
(I can define it myself but I'd rather get into the swing or doing things right.)
John.