Using A PEF library.

xXIanXx
Unregistered
 
Post: #1
I am trying to use a PEF shared library. I think I've gotten it to work but the function I'm using breaks at exe_bad_access. I am using GetDiskFragment and FindSymbol then running it through a CFM to Mach-o function.
This is the function in windows and it's the same in the mac library am I converting it to C right?
Code:
BOOL WINAPI SFileOpenArchive(LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, HANDLE *hMPQ);

//mac
bool SFileOpenArchive(const char* lpFileName, short dwPriority, short dwFlags, void *hMPQ);
After I run openArchive which is the symbol I'm trying to use it breaks at the function openArchive in the debugger:
Code:
    openArchive(charTest,0,0,testVoid);
I think it's the void I'm sending in it has to be a tvector right? How do I do that?
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
Presumably, HANDLE * would be equivalent to void ***, not void *.
Quote this message in a reply
xXIanXx
Unregistered
 
Post: #3
Thank you I don't know if this helped but it now exits due to sig11 instead of sig10.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
11 is SIGSEGV, it usually means you did the equivalent of *NULL. 10 is SIGBUS, it usually means you overran a heap-allocated array, freed a pointer you didn't malloc, etc.

I'm pretty sure that a Windows HANDLE is a void*, but you can check in your windows headers. Get windows headers from MinGW if you don't have any Smile
Quote this message in a reply
xXIanXx
Unregistered
 
Post: #5
What is MinGW?

This is how I call it if it helps:
Code:
if ( FindSymbol(connID, "\pSFileOpenArchive", (Ptr*) &openArchive, symClass) == noErr )
        {
// OpenArchive CFM to Mach-O
openArchive=(OpenArchive*)MachOFunctionPointerForCFMFunctionPointer(openArchive)​;
//allocate the holder and fake tvector
        void *testVoid;
        TVector *tvec;
        //testVoid = CFMFunctionPointerForMachOFunctionPointer(testVoid);
        //tvec = (TVector*) malloc( sizeof(TVector) );
        //tvec->fProcPtr = testVoid;
        //tvec->fTOC = 0;
        
        char *charTest = 'games/map.scm';

        openArchive(charTest,0,0,CFMFunctionPointerForMachOFunctionPointer(testVoid​));

        }


EDIT: I found out what's causing it it's the char. Now it's the void. My big problem now is faking a TVector.
Quote this message in a reply
xXIanXx
Unregistered
 
Post: #6
fixed it I had to do:
charTest = "/games/map.scm"
Quote this message in a reply
Post Reply