• Welcome to OS2World OLD-STATIC-BACKUP Forum.
 

News:

This is an old OS2World backup forum for reference only. IT IS READ ONLY!!!

If you need help with OS/2 - eComStation visit http://www.os2world.com/forum

Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - dirckm

#1
Programming / Re: GCC and DosQueryProcAddr
2009.10.15, 21:29:20

I was too optimistic ;-) Unfortunatly..

its about this call ->

my_viogetansi(&ret,HANDLE);

Seems somehow gcc give me always a SEGV on that point..
If I define the Far function with APIENTRY or _Far16 or whatever.. It doesnt eat the call to the function..
Opening and reading the function from the DLL works no problem.. But calling the alternative function by address doesnt..

Its probably my rusty C..

Any hints are still welcome ;-)


#2
Programming / Re: GCC and DosQueryProcAddr
2009.10.15, 19:34:08

Aaaa thanks Silvan... I did seek lots of code examples and they all did it
differently.. But none actualy based on the os2emx.h..
Looking at the code I expect that will work ;-)


#3
Programming / GCC and DosQueryProcAddr
2009.10.15, 17:57:32
Hello All,

Im trying to get a DosQueryProcAddr return address to execute its function.
Im compiling with gcc. Im trying now for some days to get this working but without luck..
(I compile with gcc -Wall -Zomf -los2 test.c -o test)

A simple example on VIOCALLS calling VIOGETANSI..which isnt working..


#define  INCL_DOSMODULEMGR
#include <os2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void (* _Far16 my_viogetansi)( unsigned short, unsigned short);

int main(void)
{
   unsigned int  ret;
   unsigned int    rc = 0, HANDLE = 0;
   unsigned char    error[256]="";
   HMODULE hmod;

  rc = DosLoadModule((PSZ)error,sizeof(error),"VIOCALLS", &hmod);
    if (rc) { printf("%s\n", (PSZ)error); exit(-1); }

   rc = DosQueryProcAddr(hmod, 0L ,"VIOGETANSI",(PFN *) &my_viogetansi);
     if (rc) { printf("%d\n", rc); exit(-1); }

   my_viogetansi(&ret,HANDLE);
   printf("VIOGETANSI returned: %d\n", ret);

   rc = DosFreeModule(hmod);
     if (rc) { printf("%d\n", rc); exit(-1); }
   
   return(0);
}


The output is a SEGV..

I tried different ways in creating a Function with Far, Im used to the old Turbo C and Microsoft C versions
and it seems that the only way to call in gcc is using (* _Far16 _Pascal func) to get the function going.

Now my question:
* Why it the above code not working (its it possible at all from within gcc?)? Do I realy do something wrong?
* Is there a quicker/better way in calling loaded-addresses from DLL's within C/gcc under OS/2?
(I mean..putting it all on the data-stack and then calling the function is an option but i dont want to use ASM..)

Any help is very appriciated..

Dirck.