News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

error msg?

Started by shankle, June 26, 2012, 12:49:14 AM

Previous topic - Next topic

wjr

Assuming you are simply trying to use a RECT called RC, the "forced dll" part would lead me to believe that in your source you have a reference to "RC:" (or "RCC:") with a colon (where one is not needed, or instead of a period).

shankle

#61
Got a clean compile and link.
When I click on MyProg.exe it blinks and nothing happens.
Major digging now. Have a test msg in WM_PRINT and it never gets there.
Will put a test msg in WM_CREATE  to see if it gets there.

Seems I am confused in GoAsm as to when to put in a Frame/Local
statement for ex: rc:RECT or rc?       
   
Will do more digging to see if I can figure this one out.

dedndave

Local msg, MSG, hWnd, hBrush, rc, wc_WNDCLASSEXA, cc:codecode

that's a bit of a mess, Jack   :biggrin:

local's need to be typed
MSG is a structure (which is a sort of a type)
try this
    LOCAL msg:MSG, hWnd:HWND, hBrush:HBRUSH, wc:WNDCLASSEX, cc:codecode
i am not sure about the last one
i assume you have defined the type (or structure) "codecode" somewhere previously in the source

MSG and WNDCLASSEX are structures that should be defined in the include files
HWND and HBRUSH are DWORD types that should be defined in the include files

shankle

In the testing phase of MyProg.exe I got this error message:
  " MyProg.exe has stopped working"
No 1st screen or anything. I put  messagebox  code right after the START
and it did not execute. So I assume  something else is happening.
     
.code
start:
;   test begin
;TM3              db   'at start',0
      invoke MessageBox, NULL,[TM3],[TM3],MB_YESNO     
       cmp eax,MB_YESNO
        je > Twrite
Twrite:
;   test end

   invoke GetModuleHandleA, NULL
   mov    [hInstance],eax
   invoke GetCommandLine
   invoke WinMain
   invoke ExitProcess,eax

WinMain:
    FRAME hInst,hPrevInst,CmdLine,CmdShow,hInstance;
   LOCAL msg,MSG,hWnd,hBrush,rc:RECT,wc:WNDCLASSEXA;,cc:codecode       

   mov   D[wc.cbSize], SIZEOF WNDCLASSEXA
   mov   D[wc.style], CS_BYTEALIGNWINDOW    
   mov   D[wc.lpfnWndProc], OFFSET WndProc
   mov   D[wc.cbClsExtra], NULL
   mov   D[wc.cbWndExtra], NULL
   push  [hInst]
   pop   [wc.hInstance]
   invoke LoadIcon, NULL,IDI_APPLICATION
   mov   D[wc.hIcon], eax
    invoke LoadCursor, NULL,IDC_ARROW
   mov   D[wc.hCursor], eax
   invoke CreateSolidBrush, [colorbk]          ; background color
    mov   D[hBrush], eax
   mov   D[wc.hbrBackground], eax
   mov   D[wc.lpszMenuName], NULL
   mov   D[wc.lpszClassName], OFFSET szDisplayName
   mov   D[wc.hIconSm], 0

   invoke RegisterClassExA, addr wc
    invoke SystemParametersInfoA, SPI_GETWORKAREA,0,addr rc,0       
     mov eax,[rc.left]
     mov [holdleft], eax
     mov eax,[rc.right]
     mov [holdright],eax
     mov eax,[rc.bottom]
     mov [holdbottom],eax
     mov eax,[rc.top]
     mov [holdtop],eax
     push edx               
     push ebx
     xor edx,edx     
     mov eax,[holdright]     
     mov ebx,2               
     div ebx
     mov [savemiddleofX],eax   
     pop ebx
     pop edx
   INVOKE CreateWindowExA, NULL,addr szDisplayName,addr AppName,\
           WS_OVERLAPPEDWINDOW,[rc.left],[rc.top],[rc.right],\
           [rc.bottom],NULL,NULL,[hInst],NULL       
      mov   [hWnd],eax     
 
   INVOKE ShowWindow, [hWnd], SW_SHOWNORMAL
   INVOKE UpdateWindow, [hWnd]

      .StartLoop
          INVOKE GetMessageA, addr msg,NULL,0,0
          cmp eax,0
          je >.ExitLoop
          INVOKE TranslateMessage, addr MSG
          INVOKE DispatchMessageA, addr MSG
          jmp .StartLoop
       .ExitLoop
       mov eax,[MSG.wParam]
          ret           
       ENDF
   

dedndave

try this program, Jack
.data
TM3              db   'at start',0
.code
start:
      invoke MessageBox, NULL,TM3,TM3,MB_YESNO
      invoke ExitProcess,0
end start

wjr

GoAsm syntax differs a bit from MASM for an address:

INVOKE MessageBox, NULL, ADDR TM3, ADDR TM3, MB_YESNO

Going further, you will need Dave's above corrections for LOCAL and the
WinMain FRAME should have 4 parameters:

WinMain:
FRAME hInst, hPrevInst, CmdLine, CmdShow


More importantly, when you call WinMain, you need to supply those arguments to the call, something like:

INVOKE GetCommandLine
mov [pCmdLine],eax

INVOKE WinMain, [hInstance], NULL, [pCmdLine], SW_SHOWDEFAULT


Also, in your message loop, change MSG (structure template) to msg (your locally defined instance of that structure).

dedndave

hi Wayne
i thought GoAsm syntax would yield the address of TM3 for "TM3"
and the contents at the address for "[TM3]"

shankle

Some progress.
I did get my info msg at START. Then moved it to WinMain and nothing.

To Dave- codecode is a struct I defined,  TM3 is a msg defined in the data section.

To WJR - I changed to LOCAL statement to the following:
   Local msg:MSG, hWnd:HWND, hBrush:HBRUSH, rc:RECT, wc:WNDCLASSEX, cc:codecode
Now I get the following error:  "data type given in local data declaration not recognized:-
  HWND"
I changed MSG to msg as directed in your last statement.
Here is the error msg I get: "The following symbol was not defined in the object file
or files:- msg.wParam"

Guess I'm confusing the Local statement with the Frame statement?

dedndave

if HWND is not defined in the include files, it probably should be
if one of the DWORD typedef's is missing, you can just use DWORD...
    Local   hWnd:DWORD

however, it may be that the name "hWnd" is used elsewhere in a visible scope

it might be easier if you'd attach the source, then Wayne or i could step through and clean it up in one pass

QuoteI changed MSG to msg as directed in your last statement.
Here is the error msg I get: "The following symbol was not defined in the object file
or files:- msg.wParam"

this problem may be related to the first
if it doesn't resolve all of the LOCAL declarations, it may not create any of them

wjr

Correction, the syntax difference is more on the memory addressing side which requires the square brackets for the contents at the address. For the address itself though, ADDR or OFFSET (either one for GoAsm, some differences between them for MASM) is still required in code (but not necessary as part of a data declaration).

A very quick look and I didn't see HWND defined in the header files, in WinDef.h at least, so you can also use HANDLE instead. Not sure why msg does not work for you if rc and wc do...

shankle

Thanks guys.
Made some progress and am now into the WM_CREATE.

       invoke  GlobalLock, eax      
       mov       [pinf04],eax      t
       mov       ebx,eax      
       push  ebx
        invoke  EnumPrintersA, PRINTER_ENUM_LOCAL,NULL,4,[pinf04],\
                                [dwNeeded],[dwNeeded],[dwReturned]
                 
        pop ebx                                                          
        invoke  CreateDC, NULL,[ebx+PRINTER_INFO_4.pPrinterName],NULL,NULL

The offending instruction is the CreateDC. The ones above it worked.
Most likely it is the ebx+PRINTER_INFO_4.pPrinterName



dedndave

see if this works
       invoke  GlobalLock, eax     
       mov       [pinf04],eax      t
       mov       ebx,eax     
        invoke  EnumPrintersA, PRINTER_ENUM_LOCAL,NULL,4,eax,\
                                [dwNeeded],[dwNeeded],[dwReturned]
        lea     eax,[ebx+PRINTER_INFO_4.pPrinterName]
        invoke  CreateDC, NULL,eax,NULL,NULL

shankle

Hi Dave.
The lea seemed to solve the problem. More testing will tell for sure

jj2007

Masm can do the lea for you:

invoke CreateDC, NULL, addr [ebx+PRINTER_INFO_4.pPrinterName], NULL, NULL

shankle

Hi JJ2007 and thanks for the reply.
GoAsm gives an error with your suggestion.

Now the ShowWindow gives an error in GoAsm.
It works fine in Masm32.
The CreateWindowEXA works.

hWnd    dd  0

   INVOKE CreateWindowExA, NULL,addr szDisplayName,addr AppName,\
           WS_OVERLAPPEDWINDOW,[rc.left],[rc.top],[rc.right],\
           [rc.bottom],NULL,NULL,[hInst],NULL       
      mov   [hWnd],eax     
 
   INVOKE ShowWindow, [hWnd], SW_SHOWNORMAL
   INVOKE UpdateWindow, [hWnd]