here is a problem i am facing,
well, i thought since i code in asm why should i use a byte-eater-setup program like installshield!?!?:)

so, here is the problem..i use the function LockResource to obtain a pointer to my DLL in mem, and now i need to write that dll to disk.
I use the OpenFile to create the file (with create flag) and then WriteFile to write the data to disk.

1) the pointer i get from LockResource does not point to the begining of my dll code. Instead it points 40 bytes before the begining of the dll and i adjust it manually. i haven't tested this setup yet and i am asking your advice. is this 40 byte-difference normal?!

2) what is the best way to copy the dll from mem to disk? is my way satisfactory?

Thanks !
Posted on 2001-09-24 03:11:55 by Ray
if you have attached the dll as resource with
RCDATA "mydll.dll"
then you should have no problem while reading it
and strore it to file.

There is another special thing to know about windows 95
and embedding of large binary data as resource, its a
bug in Win9x, if you think this could be, search at MS for
"fixres95".

The LockRsource will point to the begin of the dll file, f.e.
"MZ ..." not to the begin of the code.
Posted on 2001-09-24 03:42:51 by beaster
dont know about the bug but the dll is not that big! only 25k.

By saying 'the begining of the code' i meant the 'MZ.....' etc and not the entry code.

sorry if i wasn't very clear.

thanks.
Posted on 2001-09-24 03:57:00 by Ray
Try it with a bitmap, there was a discussion about how to save a bmp from resource to a file. The same method can then be applied to any file.

check here
Posted on 2001-09-24 05:08:49 by Eóin
Eoin,
thats exactly what i am doing..
my problem is that the pointer i get from LockResource is not correct..for some reason!..

i ll check it again.
Posted on 2001-09-24 06:36:00 by Ray
Are you using the three functions properly. Did you check the return values to ensure that there where no errors?

Its a very strang problem you're having, its probably a silly bug in the code. Post the source for that section of you're code. Someone here might spot something
Posted on 2001-09-24 07:50:04 by Eóin
Ray check this thread's last post. its my example i've where i've write some exe from the resource, and it works
Posted on 2001-09-24 07:50:35 by NEMO
Ray,

there should be no offset to the data. Your resouce item should be defined like:




222 RCDATA DISCARDABLE "asmctrl.ocx"



and the return value of LoadResource/LockResource should point to the "MZ".

japheth
Posted on 2001-09-24 07:52:01 by japheth
here is part of the source code :



My Resource:
My_Rc RCDATA "mydll.dll"

----------------

RcName db "My_Rc",0
.................

invoke FindResource,NULL,ADDR RcName,RT_RCDATA
.if eax != NULL
mov RcHandle, eax
invoke LoadResource,NULL,RcHandle
.if eax != NULL
invoke LockResource, RcHandle
.if eax != NULL
add eax,40 ; Here !!why??
mov PtrToData, eax
invoke SizeofResource,NULL,RcHandle
mov RcSize, eax
;###### Write to disk #####
mov ofs.cBytes, SIZEOF ofs
invoke OpenFile,ADDR FileName,ADDR ofs,OF_CREATE
mov hFile, eax
invoke WriteFile,hFile,PtrToData, RcSize,ADDR PtrWritten,NULL
invoke CloseHandle,hFile
invoke FreeResource,RcHandle
.....etc etc..


i have tested it and it works..
if anyone knows why the pointer (PtrToData) is not precise please let me know..
Posted on 2001-10-02 05:58:56 by Ray
Heres your problem; invoke LockResource, RcHandle

Then handle returned by FinResourrce is not the one you pass to LockResource. You have to pass the handle returned by LoadResource.

See how easier it is to help when you post the code.
Posted on 2001-10-02 08:15:13 by Eóin
Indeed..!

Thanks:)

(and maybe next time i will just paste the code in the first time:)
Posted on 2001-10-03 01:55:08 by Ray