PDA

View Full Version : Using A PEF library.


xXIanXx
2007.06.09, 11:26 AM
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?

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:

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?

ThemsAllTook
2007.06.10, 11:32 AM
Presumably, HANDLE * would be equivalent to void ***, not void *.

xXIanXx
2007.06.10, 11:47 AM
Thank you I don't know if this helped but it now exits due to sig11 instead of sig10.

OneSadCookie
2007.06.10, 03:39 PM
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 :)

xXIanXx
2007.06.10, 04:03 PM
What is MinGW?

This is how I call it if it helps:

if ( FindSymbol(connID, "\pSFileOpenArchive", (Ptr*) &openArchive, symClass) == noErr )
{
// OpenArchive CFM to Mach-O
openArchive=(OpenArchive*)MachOFunctionPointerForC FMFunctionPointer(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,CFMFunctionPointerForMach OFunctionPointer(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.

xXIanXx
2007.06.10, 09:46 PM
fixed it I had to do:
charTest = "/games/map.scm"