Hi, I show my code below, my device is SP2003SE, I have previliged. I was unable to put any dll in \windows because it is rom. I know any dll rely on coredll.dll, so I put coredll.dll with my dll, but things no changes.
DLL:
//Head file, dll1.h
#ifdef DLL1_EXPORTS
#define DLL1_API __declspec(dllexport)
#else
#define DLL1_API __declspec(dllimport)
#endif
// This class is exported from the dll1.dll
//class DLL1_API CDll1 {
//public:
// CDll1(void);
// TODO: add your methods here.
//};
//extern STDAPI nDll1;
extern "C"
{
DLL1_API int fnDll1(void);
}
end of head file, then body file
// dll1.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "dll1.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
// This is an example of an exported variable
//DLL1_API int nDll1=0;
// This is an example of an exported function.
int fnDll1(void)
{
return 1 ;
}
Here is the client code running on PC:
// dllclient.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <rapi.h>
int main(int argc, char* argv[])
{
printf("Hello World!\n");
HRESULT hr= 0;
DWORD cbOut=0;;
BYTE* pOut=NULL;
DWORD cbIn=1;
char *pIn="\0";
hr = CeRapiInit();
if(hr!=S_OK)
{
printf("rapi init failed, please check cable\r\n");
return 0;
}
//hr = CeRapiInvoke(L"\\Storage Card\\My Documents\\APP\\dll\\dll1.dll", L"fnDll1", cbIn,(BYTE*)pIn, &cbOut, &pOut, NULL, 0);//test with sime input, but nothing change
//hr = CeRapiInvoke(L"\\Storage Card\\My Documents\\APP\\dll\\cellcore.dll", L"SimInitialize", 0, NULL, &cbOut, &pOut, NULL, 0); //this was success.
hr = CeRapiInvoke(L"\\Storage Card\\Application Data\\Volatile\\dll1.dll", L"fnDll1", 0,NULL, &cbOut, &pOut, NULL, 0);//error 0x80004005
if(hr!=S_OK)
{
printf("Failed to r-invoke, err=%08x\r\n",hr);
}
DWORD dwerr= CeGetLastError();
printf("Ce get last err=%08x\r\n",dwerr);//err is 0
hr = CeRapiUninit();
return 0;
}