|
@@ -1,29 +1,33 @@
|
|
|
#include "bizchan.h"
|
|
|
#include "quicklz.h"
|
|
|
|
|
|
-#define WIN32_LEAN_AND_MEAN
|
|
|
-#include <Windows.h>
|
|
|
-#include <WinSock2.h>
|
|
|
-#include <WinSock.h>
|
|
|
+//#define WIN32_LEAN_AND_MEAN
|
|
|
+//#include <Windows.h>
|
|
|
+//#include <WinSock2.h>
|
|
|
+//#include <WinSock.h>
|
|
|
+//#include <process.h>
|
|
|
+#include "SpBase.h"
|
|
|
+#include <winpr/file.h>
|
|
|
+#include <winpr/winsock.h>
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
#include <stdio.h>
|
|
|
-#include <process.h>
|
|
|
#include <assert.h>
|
|
|
|
|
|
-#include "..\..\Module\mod_assistantchannel\chan_protocol.h"
|
|
|
+#include "chan_protocol.h"
|
|
|
|
|
|
//#include "acmstrdec.h"
|
|
|
//#include "acmstrenc.h"
|
|
|
-#include "openssl\\rc4.h"
|
|
|
+#include "openssl/rc4.h"
|
|
|
|
|
|
#include "ListEntry.h"
|
|
|
#include <screencodec.h>
|
|
|
#include "jpeg2k.h"
|
|
|
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
#include <DbgHelp.h>
|
|
|
-
|
|
|
#pragma comment(lib, "dbghelp.lib")
|
|
|
+#endif
|
|
|
|
|
|
#define PING_INTERVAL 10000 // 10s
|
|
|
#define MAX_TIMEOUT 60000 //超时时间60S,20170313修改,解决排队机闪呼的问题
|
|
@@ -137,6 +141,7 @@ static __inline int check_hash(char *key, int size, int hash_code)
|
|
|
|
|
|
static __inline void GetTick(LARGE_INTEGER *last, LARGE_INTEGER *lt)
|
|
|
{
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
DWORD dwNow = GetTickCount();
|
|
|
if (last->LowPart > dwNow) {
|
|
|
lt->LowPart = dwNow;
|
|
@@ -145,6 +150,17 @@ static __inline void GetTick(LARGE_INTEGER *last, LARGE_INTEGER *lt)
|
|
|
lt->LowPart = dwNow;
|
|
|
lt->HighPart = last->HighPart;
|
|
|
}
|
|
|
+#else
|
|
|
+ DWORD dwNow = GetTickCount();
|
|
|
+ if (last->u.LowPart > dwNow) {
|
|
|
+ lt->u.LowPart = dwNow;
|
|
|
+ lt->u.HighPart = last->u.HighPart + 1;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ lt->u.LowPart = dwNow;
|
|
|
+ lt->u.HighPart = last->u.HighPart;
|
|
|
+ }
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
BIZCHAN_API(int) bizchan_lib_init()
|
|
@@ -494,6 +510,7 @@ static int prepare_socket(SOCKET s, HANDLE evt)
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
static void dump_exception(PEXCEPTION_POINTERS ExceptionInfo)
|
|
|
{
|
|
|
char tmp[MAX_PATH];
|
|
@@ -518,6 +535,7 @@ static void dump_exception(PEXCEPTION_POINTERS ExceptionInfo)
|
|
|
CloseHandle( hDumpFile );
|
|
|
}
|
|
|
}
|
|
|
+#endif
|
|
|
|
|
|
static void process(bizchan_t *chan)
|
|
|
{
|
|
@@ -748,14 +766,19 @@ on_error:
|
|
|
static unsigned int __stdcall work_proc(void *arg)
|
|
|
{
|
|
|
bizchan_t *chan = (bizchan_t *)arg;
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
__try {
|
|
|
process(chan);
|
|
|
} __except(dump_exception(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) {
|
|
|
//....
|
|
|
}
|
|
|
+#else
|
|
|
+ process(chan);
|
|
|
+#endif
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
static int init_decode_func()
|
|
|
{
|
|
|
int ret = -1;
|
|
@@ -799,6 +822,51 @@ static int init_decode_func()
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+#else
|
|
|
+static int init_decode_func()
|
|
|
+{
|
|
|
+ int ret = -1;
|
|
|
+ if (!encodestring) {
|
|
|
+ HMODULE hInst = LoadLibraryA("acmstrenc.so");
|
|
|
+ if (hInst) {
|
|
|
+ encodestring = (lpfn_cryptionfun)GetProcAddress(hInst, "encodestring");
|
|
|
+ }
|
|
|
+ if (!encodestring)
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ if (!decodestring) {
|
|
|
+ HMODULE hInst = LoadLibraryA("acmstrdec.so");
|
|
|
+ if (hInst) {
|
|
|
+ decodestring = (lpfn_cryptionfun)GetProcAddress(hInst, "decodestring");
|
|
|
+ }
|
|
|
+ if (!decodestring)
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!encodestring_mobile) {
|
|
|
+ HMODULE hInst = LoadLibraryA("acmstrenc_mobile.so");
|
|
|
+ if (hInst) {
|
|
|
+ encodestring_mobile = (lpfn_cryptionfun)GetProcAddress(hInst, "encodestring");
|
|
|
+ }
|
|
|
+ if (!encodestring_mobile)
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ if (!decodestring_mobile) {
|
|
|
+ HMODULE hInst = LoadLibraryA("acmstrdec_mobile.so");
|
|
|
+ if (hInst) {
|
|
|
+ decodestring_mobile = (lpfn_cryptionfun)GetProcAddress(hInst, "decodestring");
|
|
|
+ }
|
|
|
+ if (!decodestring_mobile)
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (encodestring && decodestring && encodestring_mobile && decodestring_mobile) {
|
|
|
+ ret = 0;
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
BIZCHAN_API(int) bizchan_create(const bizchan_config_t *config, const bizchan_callback_t *cb, bizchan_t **p_chan)
|
|
|
{
|
|
|
bizchan_t *chan = NULL;
|