新增ocr
This commit is contained in:
1 parent
ab3780c413
commit
fd66a641f6
5 files changed
+154
-4
No files matched your search
+10
@@ -18,6 +18,7 @@
|
||||
#include "chat_room.h"
|
||||
#include "self_info.h"
|
||||
#include "hook_img.h"
|
||||
#include "ocr.h"
|
||||
|
||||
#pragma comment(lib, "ws2_32.lib")
|
||||
using namespace std;
|
||||
@@ -535,6 +536,15 @@ void api_handle(mg_http_message *hm, struct mg_connection *c, string &ret) {
|
||||
int success = GetImgByName(WS2LW(image_path),WS2LW(save_path));
|
||||
json ret_data = {{"code", success}, {"result", "OK"}};
|
||||
ret = ret_data.dump();
|
||||
break;
|
||||
}
|
||||
case WECHAT_DO_OCR:{
|
||||
wstring image_path = get_http_req_param(hm, j_param, "imagePath", is_post);
|
||||
string text("");
|
||||
int success = DoOCRTask(WS2LW(image_path),text);
|
||||
json ret_data = {{"code", success}, {"result", "OK"},{"text",text}};
|
||||
ret = ret_data.dump();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -63,6 +63,7 @@ typedef enum WECHAT_HTTP_APISTag
|
||||
WECHAT_GET_CONTACT_ALL,
|
||||
WECHAT_GET_CHATROOM_INFO,
|
||||
WECHAT_GET_IMG_BY_NAME,
|
||||
WECHAT_DO_OCR,
|
||||
} WECHAT_HTTP_APIS,
|
||||
*PWECHAT_HTTP_APIS;
|
||||
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
#include "pch.h"
|
||||
#include "ocr.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "wechat_data.h"
|
||||
|
||||
#define WX_INIT_OBJ_OFFSET 0x6cbab0
|
||||
#define WX_OCR_MANAGER_OFFSET 0x6cff00
|
||||
#define WX_DO_OCR_TASK_OFFSET 0x11e3210
|
||||
|
||||
int DoOCRTask(wchar_t *img_path, std::string &result) {
|
||||
int success = -1;
|
||||
WeChatString path(img_path);
|
||||
WeChatString null_obj = {0};
|
||||
WeChatString ocr_result = {0};
|
||||
DWORD base = GetWeChatWinBase();
|
||||
DWORD ocr_manager_addr = base + WX_OCR_MANAGER_OFFSET;
|
||||
DWORD do_ocr_task_addr = base + WX_DO_OCR_TASK_OFFSET;
|
||||
DWORD init_addr = base + WX_INIT_OBJ_OFFSET;
|
||||
__asm {
|
||||
PUSHAD
|
||||
PUSHFD
|
||||
LEA ECX,ocr_result
|
||||
CALL init_addr
|
||||
CALL ocr_manager_addr
|
||||
LEA ECX,null_obj
|
||||
PUSH ECX
|
||||
LEA ECX,ocr_result
|
||||
PUSH ECX
|
||||
PUSH ECX
|
||||
LEA ECX,path
|
||||
PUSH ECX
|
||||
MOV ECX,EAX
|
||||
CALL do_ocr_task_addr
|
||||
MOV success,EAX
|
||||
POPFD
|
||||
POPAD
|
||||
}
|
||||
|
||||
if (success == 0) {
|
||||
DWORD addr = (DWORD)&ocr_result;
|
||||
DWORD ptr = *(DWORD *)addr;
|
||||
DWORD num = *(DWORD *)(addr + 0x4);
|
||||
if (num <= 0) {
|
||||
return success;
|
||||
}
|
||||
|
||||
DWORD header = *(DWORD *)ptr;
|
||||
for (unsigned int i = 0; i < num -1; i++) {
|
||||
DWORD content = *(DWORD *)header;
|
||||
result += unicode_to_utf8((wchar_t *)READ_WSTRING(content, 0x14).c_str());
|
||||
|
||||
header = content;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
cout << "num:" << num << endl;
|
||||
cout << "all:" << result << endl;
|
||||
#endif
|
||||
}
|
||||
return success;
|
||||
}
|
||||
Reference in new issue
Block a user