Im not sure if I should put this here or in the general forum, but its got Direct X so.... Im still getting used to MASM, so this might be a very stupid question. I am trying to tranlate a c program to assembly. I am using Iczelion tut#3 for my Winmain stuff. Heres the c I'm trying to translate: static HMODULE library = 0; static LPDIRECTDRAW lpDD = 0; static LPDIRECTDRAWSURFACE lpDDS = 0; static LPDIRECTDRAWSURFACE lpDDS_back; this is how some of it is used: library = (HMODULE) LoadLibrary("ddraw.dll"); DirectDrawCreate = (DIRECTDRAWCREATE) GetProcAddress(library,"DirectDrawCreate"); now my code: (the important part)
First I would like to know if I have all the incs/libs I need. The program Im tranlating only uses winmain.h and ddraw.h. Second HMODULE and the ddraw stuff is declared globally in the c program, so I figure I sould do it that way in my assem program. I dont know how to declare a variable to a windows data type globally in MASM. I've tried many ways but MASM always tells me that HMODULE and LPDIRECTDRAW are not (forgot the word, when you use a varible thats not defined, some special word for it) Now to browse the net and see if I can find some applicable code.....
.386 .model flat,stdcall option casemap:none include \masm32\include\windows.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc include \masm32\include\ddraw.inc includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib includelib \masm32\lib\ddraw.lib WinMain proto :DWORD,:DWORD,:DWORD,:DWORD .data ClassName db "SimpleWinClass",0 AppName db "assem PTC v0.01",0 ;HMODULE = library <---LOOK HERE!!! ;LPDIRECTDRAW = lpDD; <---AND HERE!!! Yes I used c style
You should download the DirectDraw example (not the one from Mike Bibby, but the one from X-Calibre). He has a very impressive include file for Assembly which makes DirectDraw easier. I wish I could tell you what the file is called, but I don't remember. :)
Hi don't know what includes are needed for Directdraw but for the other problem...read on
the above code defines four static variables (library,lpDD,lpDDS,lpDDS_back) i.e their values are preserved for subsequent funcion calls... the capitalised words HMODULE,LPDIRECTDRAW...etc are all windows defines(not program variables!) Global variables are declared in the .data and .data? sections. so to put it all together...
static HMODULE library = 0; static LPDIRECTDRAW lpDD = 0; static LPDIRECTDRAWSURFACE lpDDS = 0; static LPDIRECTDRAWSURFACE lpDDS_back;
.data ClassName db "SimpleWinClass",0 AppName db "assem PTC v0.01",0 ;HMODULE = library <---LOOK HERE!!! ;LPDIRECTDRAW = lpDD; <---AND HERE!!! Yes I used c style
In 32bit windows handles and pointers are defined as DWORD so you could just as well have used
.data ClassName db "SimpleWinClass",0 AppName db "assem PTC v0.01",0 library HMODULE 0 lpDD LPDIRECTDRAW 0
.data library dword 0 ;handle lpDD dword 0 ;pointer
Thanks for showing me how to declare global varables with crazy windows defines. I did figure out more last night. Got DirectDrawCreate() working, but maybe not quite right. I traced thru the c program and watched what the registers where on procedure exit. The way I did it the vtable start seems a little bit off. But now I'm more prepared to look at someone elses code.