| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Calling 32-Bit Dll From 1 |
AL>I need to call a DLL with 32-bit functions from a DLL which has to have
AL>16-bit functions.So simply put: some 16-bit functions need to call 32-bit
AL>functions. Someone in OS2BBS said that this would be possible, and mentioned
AL>C-Set/2 as a specific compiler that'd be able to do it.Anybody have any
AL>specifics, samples, experience?Cya! Agl.
When I bought Borland's C++ for OS/2 v1.5 it came with an example of
exactly how to do this. However, their example was in assembler. I
don't think their compiler is capable. You have to write an assembler
routine (16 bit) to call from the DLL (16 bit) that, in turn, calls the
DLL (32 bit). It doesn't seem to be too hard after reading through the
code, but it is not obvious how to do it without a specific example.
Basically, you write a 16 bit assembler routine to be called from the 16
bit DLL, this routine converts the parameters to 32 bit and pushes them
onto the stack. It then jumps to a 32 bit assembler routine that you
supply which calls the 32 bit DLL. When the 32 bit DLL returns to the
32 bit assembler routine, it jumps back into the 16 bit assembler
routine which then returns to the 16 bit DLL. The tricky part is
converting the 16 bit stack to a 32 bit stack for the 32 bit DLL.
Basically you do the following:
mov ax,seg flat: _data ; build and push 16:32 ss:esp,
push ax ; assume you're not on 64K
mov ax,ss ; boundary
shr ax,3
rol eax,16
mov ax,sp
add eax,2 ; so after lss, ss on the stack
push eax ; is skipped
movzx esp,sp
lss esp,fword ptr [esp] ; set up ss:esp for 32-bit
mov ax,seg flat: _data
mov ds,ax ; set up ds and ss for 32-bit
mov es,ax
; this is how I have to jmp to 32-bit seg with masm386
db 66h ; operand size override
db 67h ; address size override
db 0eah ; jmp through 16:32 pointer
df flat: Test$32Func ; this is the 32 bit routine
return_point:
lss sp,flat: [esp] ; restore the 16-bit ss:sp
pop ds
pop bp
ret 4 ; geeet outta heeer
Then the 32 bit assembly routine just JMP's to return_point.
---
þ MR/2 2.0 #99 þ Internet: XTJX59A{at}PRODIGY.COM RIME: ->7 Prodigy: XTJX59A
--- QScan v1.11b / 01-0169
* Origin: The Party Line * Memphis * 901-755-4531 (1:123/5)SEEN-BY: 12/2442 54/54 620/243 624/50 632/348 640/820 690/660 711/409 410 413 SEEN-BY: 711/430 807 808 809 934 712/353 623 713/888 800/1 @PATH: 123/5 4 301 3615/50 229/2 12/2442 711/409 54/54 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.