News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Problem with compiling a code.

Started by Devv, May 26, 2006, 07:46:20 PM

Previous topic - Next topic

Devv

I have a example code for using a dll. I want to try the example program just to see that it works and then I'm planning on making my own program that calls the functions of the dll the way I want rather than just calling the functions to chow they work.

When I try to compile using either masm32 or chrome IDE I get the same error:
C:\ebot\ebot.asm(13) : fatal error A1000: cannot open file : windows.inc
I have searched and I found somthing about writing the include like this: masm32/include/windows.inc. I tried compiling and got the same error. I even tried to write C: first in the line. What is wrong? I figured that if I can't even get this to compile I will never ever get to compile my own c++/c/masm application in windows.

Code:
;-------------------------------------
; "Example"-Bot using MacLib Alpha 2
; Whipped up by Drikkz, @ M-Hacks
; programmed in teh asm, using teh Chrome IDE
;_____________________________________

; --------------- File model
         .486
         .model   flat, stdcall
         option   casemap:none

; --------------- Includes
         include windows.inc
          include kernel32.inc
          include user32.inc
          include masm32.inc

; --------------- Libraries
         includelib kernel32.lib
         includelib user32.lib
         includelib masm32.lib

; --------------- Procedures declarations
Main         proto

; --------------- Datas section
         .data

AppName         db "MacLib 'Example' Bot v1.0", 0         
WelcomeMsg      db "Will simulate SendInput through GameGuard to simulate moving right + left. Press OK to start.", 0
MacLib         db "MacAPI.dll",0
QuitMsg         db "Cool, eh? 'Program will now terminate...' Or something like that ;P",0
MKeybd_Event      db "MKeybd_Event",0
ErrMsg         db "Uh-Oh...",0

         .data?

loopc BYTE ?

; --------------- Code section
                   .code

; ---------------------
; --- Program start ---
; ---------------------
start:         invoke   Main
         invoke   ExitProcess, 0             ; Quit

; --------------
; --- Main() ---
; --------------
Main         proc

   LOCAL mlModule:DWORD
   LOCAL aKeybd_Event:DWORD

   invoke MessageBox, NULL, addr WelcomeMsg, addr AppName,MB_OK    ; Introduce
   
   invoke LoadLibrary,addr MacLib                ; Load the DLL
   
   .if eax == NULL
      invoke MessageBox, NULL, addr ErrMsg, addr AppName,MB_OK
      ret   
   .endif
   
   mov mlModule, eax                   ; Store the Module Handle into mlModule
   
   invoke GetProcAddress, mlModule, addr MKeybd_Event      ; Grab the address to MKeybd_Event
   mov aKeybd_Event, eax                  ; Store the address into aKeybd_Event
   
   .WHILE loopc != 10                  ; Start movement loop
      
   push 0                        ; Parameters to pass to aKeybd_Event
   push 0
   mov eax, 0CDh
   push eax
   mov eax, VK_RIGHT
   push eax
      
   call [aKeybd_Event]                  ; Simulate moving right. Refer to: www.codeproject.com/system/keyboard.asp
   invoke Sleep, 1000                  ; Small delay
   
   inc loopc                     ; Looped++

   .ENDW                        ; End Loop
   
   mov loopc, 0                     ; Clear Loop
   
   push 0                        ; Parameters to pass to aKeybd_Event
   mov eax, KEYEVENTF_KEYUP
   push eax
   mov eax, 0CDh
   push eax
   mov eax, VK_RIGHT
   push eax
   
   call [aKeybd_Event]                  ; Turn it off.
   
   .WHILE loopc != 10                  ; Start movement loop
      
   push 0                        ; Parameters to pass to aKeybd_Event
   push 0
   mov eax, 0CBh
   push eax
   mov eax, VK_LEFT
   push eax      

   call [aKeybd_Event]                  ; Simulate moving left.
   invoke Sleep, 1000                  ; Small delay
   
   inc loopc                     ; Looped++

   .ENDW                        ; End Loop
   
   push 0                        ; Parameters to pass to aKeybd_Event
   mov eax, KEYEVENTF_KEYUP
   push eax
   mov eax, 0CBh
   push eax
   mov eax, VK_LEFT
   push eax
   
   call [aKeybd_Event]                  ; Turn it off.
   
   invoke MessageBox, NULL, addr QuitMsg, addr AppName,MB_OK    ; Quitting Message
   
   invoke FreeLibrary, mlModule
   
   ret                         ; Return to Quit
Main         endp

end start

Ossa

Try changing:

Quote; --------------- Includes
         include windows.inc
          include kernel32.inc
          include user32.inc
          include masm32.inc

; --------------- Libraries
         includelib kernel32.lib
         includelib user32.lib
         includelib masm32.lib

to

; --------------- Includes
         include \masm32\include\windows.inc
          include \masm32\include\kernel32.inc
          include \masm32\include\user32.inc
          include \masm32\include\masm32.inc

; --------------- Libraries
         includelib \masm32\lib\kernel32.lib
         includelib \masm32\lib\user32.lib
         includelib \masm32\lib\masm32.lib


(I assume you installed MASM32 to the c:\masm32\ (or similar) directory)

Ossa
Website (very old): ossa.the-wot.co.uk

Devv

I tried that. didn't work. I moved all the needed inc files to the folder of the code and then it worked but this was not the kind of soloution I was looking for. I don't really know what option I should use when compiling this. And do I need to somehow create an .obj first?

Mark Jones

Quote from: Devv on May 27, 2006, 08:03:42 AM
I tried that. didn't work.

Hi Devv, did you install MASM32 v9.0 to c:\masm32?

When I first installed MASM32 I moved it into another folder, which caused countless problems.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Devv

Quote from: Mark Jones on May 27, 2006, 08:28:51 AM
Quote from: Devv on May 27, 2006, 08:03:42 AM
I tried that. didn't work.

Hi Devv, did you install MASM32 v9.0 to c:\masm32?

When I first installed MASM32 I moved it into another folder, which caused countless problems.

I first installed it to another partition but I thought that might be bad. I didn't find uninstaller so I just deleted it. Then I installed to C:\ which is my main drive. Problem might or might not be it's looking for the inc's at F:\ because I didn't wipe any registry it might have created during the installation. Question is now: What should I do about it and what is likely to be the problem with the oher error?

When I moved all the files to the folder I got some error like: The volume in drive C: doesn't have a label. That's when I tried to assemble ASM file.

Thanks for all the help so far!  :clap:

Ossa

The MASM32 package makes no changes to the registry, so your problem is not there. Have you tried setting the PATH environment variable to point to the include directory?

Ossa
Website (very old): ossa.the-wot.co.uk

mnemonic

If the MASM32 package resides on partition C: your code should reside in C: too because if your code resides on e.g. D: and you write

include \masm32\include\windows.inc

then ML will look for "D:\masm32\include\windows.inc" and not for "C:\masm32\include\windows.inc".

If you don't want any trouble, keep the MASM32 package and your code on the same partition.
Thats the way I keep it and I never experience any problems like you.
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

Devv

Path enviroment? Where do I change that?  :eek

The code is in C:/ebot and masm32 is in c:/masm32 so that shouldn't be the problem.

And what about the label error?

Ossa

Quote from: Devv on May 27, 2006, 07:44:18 PM
Path enviroment? Where do I change that? :eek

Well, I really don't think it will help (I don't need to have it set on my comp)... but it can't hurt:

(I'm assuming that you are running windows XP, if not, this might be different)

1) right click on "My Computer"
2) select "Properties"
3) go to the "Advanced" tab
4) Click the "Environment Variables" button at the bottom
5) In the top or bottom box (it should be in both, but either will do), select the "PATH" or "path" (or something similar) variable (without quotes).
6) Click the "Edit" button (there are 2 - make sure that you pick the right one)
7) In the bottom box, add the following to the end of the line:

Quote;c:\masm32\include\

Once again, I doubt this will work, but I really can't think of anythign else that might help.

Ossa
Website (very old): ossa.the-wot.co.uk

stanhebben

You can't get it compiling?

Extract these files to some place. (at your c: drive) and run bldall.bat - does that work?

[attachment deleted by admin]

Devv

What does the .bat do and where do I find it? Can someone else try to compile this code and see if it works?

Ossa

The .bat is a batch file, it contains the command line instructions to build the file. It works for me ("works" in this case means that it assembles and links fine, I run it... it doesnt crash, but it doesn't exactly work either... stanhebben, that was far too complex an example to check a build works), so instructions:

1) Download the ZIP file, extract the files to a folder
2) Open the folder, and double click bldall.bat
3) see if the build completes without error
4) if so, there should be a test.exe in the folder (your choice to run it or not... it doesnt matter if it works or not)

Ossa
Website (very old): ossa.the-wot.co.uk