53 lines
1.9 KiB
C++
Raw Normal View History

2024-04-02 15:36:52 +08:00
extern "C"
{
typedef DWORD(__stdcall *StartSession)(wchar_t *path, void *bufferStart, void *bufferStop, const wchar_t *app);
typedef DWORD(__stdcall *OpenEngine)(int key);
typedef DWORD(__stdcall *SimpleTransSentM)(int key, const wchar_t *fr, wchar_t *t, int, int);
typedef DWORD(__stdcall *SetBasicDictPathW)(int key, const wchar_t *fr);
2024-01-08 23:37:00 +08:00
}
2024-04-02 15:36:52 +08:00
int kingsoftwmain(int argc, wchar_t *argv[])
2024-01-08 23:37:00 +08:00
{
//_setmode(_fileno(stdout), _O_U16TEXT);
2024-04-02 15:36:52 +08:00
// wchar_t path[] = L"C:\\dataH\\<5C><>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD>.2009.רҵ<D7A8><D2B5>\\FastAIT09_Setup.25269.4101\\GTS\\JapaneseSChinese\\DCT";
wchar_t *path = argv[2];
2024-01-08 23:37:00 +08:00
HMODULE h = LoadLibrary(argv[1]);
2024-04-02 15:36:52 +08:00
enum
{
key = 0x4f4
};
if (h)
{
2024-01-08 23:37:00 +08:00
StartSession startSession = (StartSession)::GetProcAddress(h, "StartSession");
OpenEngine openEngine = (OpenEngine)::GetProcAddress(h, "OpenEngine");
SimpleTransSentM simpleTransSentM = (SimpleTransSentM)::GetProcAddress(h, "SimpleTransSentM");
SetBasicDictPathW setBasicDictPathW = (SetBasicDictPathW)::GetProcAddress(h, "SetBasicDictPathW");
2024-04-02 15:36:52 +08:00
enum
{
bufferSize = key
};
2024-01-08 23:37:00 +08:00
char buffer[bufferSize];
int ret = startSession(path, buffer, buffer + bufferSize, L"DCT");
ret = openEngine(key);
ret = setBasicDictPathW(key, path);
2024-04-02 15:36:52 +08:00
HANDLE hPipe = CreateNamedPipe(argv[3], PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, 65535, 65535, NMPWAIT_WAIT_FOREVER, 0);
2024-05-03 17:50:26 +08:00
2024-01-08 23:37:00 +08:00
SetEvent(CreateEvent(&allAccess, FALSE, FALSE, argv[4]));
ConnectNamedPipe(hPipe, NULL);
2024-04-02 15:36:52 +08:00
while (true)
{
wchar_t fr[1024] = {0};
2024-01-08 23:37:00 +08:00
DWORD _;
2024-04-02 15:36:52 +08:00
if (!ReadFile(hPipe, fr, 1024, &_, NULL))
break;
2024-01-08 23:37:00 +08:00
wchar_t to[0x400] = {};
ret = simpleTransSentM(key, fr, to, 0x28, 0x4);
WriteFile(hPipe, to, wcslen(to) * 2, &_, NULL);
}
}
return 0;
}