flat assembler
Message board for the users of flat assembler.
Index
> Windows > iStream structure |
Author |
|
JohnFound 07 Aug 2003, 11:27
Actually IMHO all is OK with 3-th parameter - pStream, you must set address of dword memory variable to receive pointer for new Stream. Only your pStream variable must not be local.
Try to set pGlobal to NULL: Code: invoke CreateStreamOnHGlobal, NULL, TRUE, pStream In this case Windows will allocate needed memory automatically. Windows have some requirements for allocated block if you allocate it manually. So let the Windows make it the way it likes. Regards. |
|||
07 Aug 2003, 11:27 |
|
alonso 07 Aug 2003, 14:13
Thank very much John for your prompt reply.
What i'm trying to do is translate a MASM program to FASM, but some things are so diferent that some times it's very hard, specially when you don't have alot of Assembly Language skills, but any way here is the orignal Masm code: IPicture STRUCT ; IUnknown methods QueryInterface DWORD ? AddRef DWORD ? Release DWORD ? ; IPicture methods get_Handle DWORD ? get_hPal DWORD ? get_Type DWORD ? get_Width DWORD ? get_Height DWORD ? Render DWORD ? set_hPal DWORD ? get_CurDC DWORD ? SelectPicture DWORD ? get_KeepOriginalFormat DWORD ? put_KeepOriginalFormat DWORD ? PictureChanged DWORD ? SaveAsFile DWORD ? get_Attributes DWORD ? IPicture ENDS sIID_IPicture TEXTEQU <{07BF80980H, 0BF32H, 0101AH, \ {08BH, 0BBH, 000H, 0AAH, 000H, 030H, 00CH, 0ABH}}> IID_IPicture GUID sIID_IPicture I translate the following code to FASM like this: struc IPicture STRUCT { .handle dd ? virtual at 0 ; IUnknown methods .QueryInterface dw ? .AddRef dw ? .Release dw ? ; IPicture methods .get_Handle dw ? .get_hPal dw ? .get_Type dw ? .get_Width dw ? .get_Height dw ? .Render dw ? .set_hPal dw ? .get_CurDC dw ? .SelectPicture dw ? .get_KeepOriginalFormat dw ? .put_KeepOriginalFormat dw ? .PictureChanged dw ? .SaveAsFile dw ? .get_Attributes dw ? end virtual } struc GUID { Data1 dd ? Data2 dw ? Data3 dw ? Data4 rb 8 } struc sIID_IPicture { Data1 dd 7BF80980h Data2 dw 0BF32h Data3 dw 101Ah Data4 equ 8BBB00AA00300CABh } And to code in Masm was: invoke CreateStreamOnHGlobal, pGlobal, TRUE, ADDR pStream invoke OleLoadPicture, pStream, NULL, TRUE, ADDR IID_IPicture, ADDR pPicture And the translation i did was: invoke CreateStreamOnHGlobal,pGlobal,TRUE,pStream invoke OleLoadPicture,[pStream],NULL,TRUE,[IID_IPicture],[pPicture] All this code compile just fine, but when it runs, OleLoadPicture return the message The address in pStream or ppvObj is not valid. For example, either may be NULL. So this means that either pStream, IID_IPicture or pPicture structures are wrong, can you please help me I would really appreciate it. Thanks alot and may God bless you. Sincerely, Alonso M.M |
|||
07 Aug 2003, 14:13 |
|
wanderer 07 Aug 2003, 17:57
Quote: And to code in Masm was: Here is at least one error - translation should be: Code: invoke CreateStreamOnHGlobal, [pGlobal], TRUE, pStream invoke OleLoadPicture, [pStream], NULL, TRUE, IID_IPicture, pPicture _________________ Best regards, Antoch Victor |
|||
07 Aug 2003, 17:57 |
|
alonso 07 Aug 2003, 20:02
Thanks for your hekp Victor
I try your translation but it return Invalid Value and a message like this pushd ..arg?000018B6, but if I do: invoke OleLoadPicture,[pStream],NULL,TRUE,IID_IPicture,[pPicture] Then it compiles just fine but when i run it return the same error: The address in pStream or ppvObj is not valid. For example, either may be NULL. CAN YOU OR SOME BODY HELP ME PLEASE Sincerely, Alonso M.M wanderer wrote:
|
|||
07 Aug 2003, 20:02 |
|
inskipp 07 Aug 2003, 21:32
Hello alonso. I have found few errors in your translation:
Quote: I translate the following code to FASM like this: The pointers are of course dword (not word) value, so you have to use dd ? (instead dw ?) in all fields: Code: struc IPicture STRUCT { .handle dd ? virtual at 0 ; IUnknown methods .QueryInterface dd ? .AddRef dd ? .Release dd ? ; IPicture methods .get_Handle dd ? .get_hPal dd ? .get_Type dd ? .get_Width dd ? and so on. Next: Quote: struc sIID_IPicture equ is only costant declaration, so you have to use dq in Data4 declaration: Code: Data4 dq 8BBB00AA00300CABh
I'm not sure, if byte order will be correct with dq. If not try this: Code: Data4 db 08Bh,0BBh,000h,0AAh,000h,030h,00Ch,0ABh |
|||
07 Aug 2003, 21:32 |
|
wanderer 07 Aug 2003, 22:27
Quote: I try your translation but it return Invalid Value and a message like this pushd ..arg?000018B6, but if I do: Probably you have pPicture on stack. In that case you can't obtain it's address the way that works for variables in data section. You'll have to write something like: Code: lea eax, [pPicture] invoke OleLoadPicture,[pStream],NULL,TRUE,IID_IPicture,eax Remember, when you write [<var name>] in fasm you mean the content of a variable, not it's address. So when you passed content of pPicture to procedure that interpreted it as address of pPicture you got error. Also, you can look how to make work OleLoadPicture in my "teeth" example in examples section of fasm website. Sorry, that I can't help you better, but my hard drive have recently been broken, and now (until it will be repaired) I use old 530MB HDD, and I just can't install all documentation. _________________ Best regards, Antoch Victor |
|||
07 Aug 2003, 22:27 |
|
alonso 12 Aug 2003, 16:25
How do I know if IPicture is on the stack what I did was:
section '.data' data readable writeable pPicture IPicture And on the IPicture.inc file this: struc IPicture { .handle dd ? ; virtual at 0 ; IUnknown methods .QueryInterface dd ? .AddRef dd ? .Release dd ? ; IPicture methods .get_Handle dd ? .get_hPal dd ? .get_Type dd ? .get_Width dd ? .get_Height dd ? .Render dd ? .set_hPal dd ? .get_CurDC dd ? .SelectPicture dd ? .get_KeepOriginalFormat dd ? .put_KeepOriginalFormat dd ? .PictureChanged dd ? .SaveAsFile dd ? .get_Attributes dd ? ; end virtual } Now with the code you give me: lea eax, [pPicture] invoke OleLoadPicture,[pStream],NULL,TRUE,IID_IPicture,eax It return E_UNEXPECTED error. I check with OllyDebuger the program Paint.exe created with Masm and the IID_IPicture data is ok. And finally I download the sample program you created teeth, I think you did a very nice job on it, but there are some things I do NOT understand like: In Ole32.inc virtual at 0 IPicture: .QueryInterface dd ? .. .. Why don't you use the struc statement, why virtual at 0 is before the struc name and why when i try to do something like this: pPicture IPicture I get a illegal instruction error message??? And If I try to compile your source program i get Out of memory error message (i have Flat Assembler 1.48 for Win). What is going on? Can you explain please Sincerly, Alonso M.M |
|||
12 Aug 2003, 16:25 |
|
wanderer 12 Aug 2003, 22:13
Quote: How do I know if IPicture is on the stack what I did was: Well, let's begin from the beginning . First of all, pPicture is a pointer to object, therefore it should be declared like any other pointer: Code: pPicture dd ? Also, .handle field is not needed in this definition and you have to write struct IPicture after struc IPicture {...} definition. Quote: Now with the code you give me: In the attachment you'll find a simple program based on teeth , that shows only how to use IPicture. Sorry, it displays resulting bitmap as monochrome, but I don't have time now to figure out the right sequence of CreateCompatibleDC and CreateCompatibleBitmap. It always takes me a lot of time (again and again, I don't know why, I tryed to copy the right order from teeth, however it didn't work). Anyway, it correctly works with CreateStreamOnHGlobal and OleLoadPicture, so it solves your problem. Quote:
Here are defined offsets of methods relative to the beginning of the virtual methods table. All we need here are offsets in the table. You can use the struc statement, but the method I used seems to be more clear for me. And, you get illegal instruction message because IPicture in this case is just label with the offset 0. It's not description of some structure. Quote: And If I try to compile your source program i get Out of memory error message (i have Flat Assembler 1.48 for Win). Go to Options|Compiler Setup in FasmW's menu and set Memory to a bigger value. Teeth is rather big project with a lot of macro calls, that's why it needs 32MB of memory to compile. Quote:
Hope, I explained .
_________________ Best regards, Antoch Victor |
|||||||||||
12 Aug 2003, 22:13 |
|
alonso 13 Aug 2003, 16:52
Thank you Victor I download the IPicture sample and will play with it!!!
|
|||
13 Aug 2003, 16:52 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.