News:

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

Alloc.asm / Malloc

Started by ic2, February 01, 2007, 04:05:38 AM

Previous topic - Next topic

ic2

Alloc.asm problem

I'm using window95.  would anyone have an basic sample program that shows how
alloc.asm works or is there an replacement for it that has the same capability of working with shared memory of another precess like VirtualAllocEx which don't work for 9x.    I can't seem to get it to work
it crash my program at the 2nd line to the bottom of the code below.  I did a extensive search but even here there is only one thread with concern.

Thanks in advance



.IF !Alloc_pIMalloc
    invoke CoGetMalloc,1 , ADDR Alloc_pIMalloc


        .IF eax
            ; failed getting pIMalloc

            xor eax, eax    ;  NULL return pointer
            ret
        .ENDIF
    .ENDIF
    ; now request the memory
    push cb
    mov ecx, Alloc_pIMalloc

    mov ecx, [ecx]
    call DWORD PTR [ecx] + 12        ;  ..............  Program crash here

invoke MessageBox, 0,  Alloc_pIMalloc,  0, 0[\code]


akane

Hello ic2
You forget to push object instance:
push <all parameters>
mov ecx, Alloc_pIMalloc
push ecx ; push pointer to IMalloc private variables // here
mov ecx, [ecx] ; get the jumptable
call DWORD PTR [ecx] + 12 ; call a method

ic2

Thanks akane, I already was Pushing something on the stack from a seprate procudure.  Anyway,  what i did was replace it with CoTaskMem and it seem to be working, I'll know for sure latter.    I don't think nothing is wrong with Alloc.   I think it's in the way I set up my  program *hardheaded madman style crazy sh*t* or either i placed something in the  wrong place.  I'll sovle that problem on another day...  right now i got to catch forty winks to make up for those 40 hours of searching and reading.  I learn a lot.  Here some great threads for whoever may stumble upon here these grounds.  They are more than just interesting.

http://www.masm32.com/board/index.php?PHPSESSID=020d7c6325c36e93baa3d58d2a50d396&topic=2149.msg17031#msg17031


http://www.masm32.com/board/index.php?PHPSESSID=f57d56067e24ad799189b31e9808c04e&topic=5786.0


http://www.masm32.com/board/index.php?PHPSESSID=97c1ce999f842944b02e713142d39fc5&topic=1424.0


http://www.asmcommunity.net/board/index.php?topic=12776.0