Dynamic memory
This commit is contained in:
@@ -4,7 +4,9 @@ extern MicroData* Index;
|
||||
extern MicroBinary* Data;
|
||||
extern "C" extern DLLAPI double saveProcess;
|
||||
extern HMODULE hMod;
|
||||
|
||||
extern "C" extern DLLAPI wchar_t ms_str[3096];
|
||||
extern "C" extern DLLAPI wchar_t cn_str[1024];
|
||||
extern "C" extern DLLAPI int nID;
|
||||
extern "C" extern DLLAPI DWORD tPid;
|
||||
extern "C" extern DLLAPI bool blockRestoreSrc;
|
||||
@@ -18,23 +20,24 @@ DWORD CreateDataExportEx(LPVOID data)
|
||||
ExportParam* bData = (ExportParam*)data;
|
||||
if (!blockRestoreSrc) {
|
||||
// MessageBoxW(0, data,L"",0);
|
||||
WCHAR sjp[3096];
|
||||
WCHAR scn[3096];
|
||||
WCHAR sjp[1024];
|
||||
WCHAR scn[1024];
|
||||
int lasger = GEtLargestID();
|
||||
if (nID == 0) {
|
||||
MessageBox(0, L"the ID value seems not available,therefore this action has been refused", L"error", MB_ICONERROR);
|
||||
if (nID == -1) {
|
||||
MessageBox(0, L"the ID value seems not available,therefore this action has been refused", L"error", MB_ICONERROR | MB_MODEMASK);
|
||||
saveProcess = 1.0;
|
||||
return 1;
|
||||
}
|
||||
if (nID - lasger > 2) {
|
||||
MessageBox(0, L"the ID value seems not available,therefore this action has been refused", L"error", MB_ICONERROR);
|
||||
if (nID - lasger > 1) {
|
||||
MessageBox(0, L"the ID value seems not available,therefore this action has been refused", L"error", MB_ICONERROR | MB_MODEMASK);
|
||||
saveProcess = 1.0;
|
||||
return 1;
|
||||
}
|
||||
if (!GetDataByID(nID - 1, sjp, scn)) {
|
||||
CreateDataByID(nID - 1, bData->src, 2 * (lstrlenW(bData->src) + 1), bData->data, 2 * (lstrlenW(bData->data) + 1));
|
||||
if (!GetDataByID(nID, sjp, scn)) {
|
||||
|
||||
CreateDataByID(nID, bData->src, 2 * (lstrlenW(bData->src) + 1), bData->data, 2 * (lstrlenW(bData->data) + 1));
|
||||
WCHAR abv[16];
|
||||
_itow_s(nID - 1, abv, 10);
|
||||
_itow_s(nID, abv, 10);
|
||||
wstring str;
|
||||
str += L"Apply ID:";
|
||||
str += abv;
|
||||
@@ -42,20 +45,20 @@ DWORD CreateDataExportEx(LPVOID data)
|
||||
str += bData->src;
|
||||
str += L"->";
|
||||
str += bData->data;
|
||||
MessageBoxW(NULL, str.c_str(), L"successed to add rule", MB_ICONINFORMATION);
|
||||
// MessageBoxW(NULL, str.c_str(), L"successed to add rule", MB_ICONINFORMATION | MB_MODEMASK);
|
||||
saveProcess = 1.0;
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
wstring nString = L"This rule is already exist,do you want still to replace it?(according to your PC,it may take you a short time)\n";
|
||||
WCHAR abv[16];
|
||||
_itow_s(nID - 1, abv, 10);
|
||||
_itow_s(nID, abv, 10);
|
||||
nString += L"ID:";
|
||||
nString += abv;
|
||||
nString += L"\n";
|
||||
nString += sjp;
|
||||
saveProcess = 0.0;
|
||||
int result = MessageBoxW(NULL, nString.c_str(), L"information", MB_ICONINFORMATION | MB_OKCANCEL);
|
||||
int result = MessageBoxW(NULL, nString.c_str(), L"information", MB_ICONINFORMATION | MB_OKCANCEL | MB_MODEMASK);
|
||||
if (result != IDOK) {
|
||||
saveProcess = 1.0;
|
||||
return 1;
|
||||
@@ -65,7 +68,7 @@ DWORD CreateDataExportEx(LPVOID data)
|
||||
MicroBinary* _Data = new MicroBinary(L"~Data.ax");
|
||||
IndexData createData;
|
||||
while (GetDataByID(p, sjp, scn)) {
|
||||
if (p == (nID - 1)) {
|
||||
if (p == nID) {
|
||||
createData.Id = p;
|
||||
createData.JpLength = 2 * (lstrlenW(sjp) + 1);
|
||||
createData.CnLength = 2 * (lstrlenW(bData->data) + 1);
|
||||
@@ -128,7 +131,7 @@ DWORD CreateDataExportEx(LPVOID data)
|
||||
str += bData->src;
|
||||
str += L"->";
|
||||
str += bData->data;
|
||||
MessageBoxW(NULL, str.c_str(), L"successed to add rule", MB_ICONINFORMATION);
|
||||
MessageBoxW(NULL, str.c_str(), L"successed to add rule", MB_ICONINFORMATION | MB_MODEMASK);
|
||||
saveProcess = 1.0;
|
||||
return 1;
|
||||
}
|
||||
@@ -141,7 +144,7 @@ DWORD CreateDataExportEx(LPVOID data)
|
||||
nString += L"\n";
|
||||
nString += bData->src;
|
||||
|
||||
int result = MessageBoxW(NULL, nString.c_str(), L"information", MB_ICONINFORMATION | MB_OKCANCEL);
|
||||
int result = MessageBoxW(NULL, nString.c_str(), L"information", MB_ICONINFORMATION | MB_OKCANCEL | MB_MODEMASK);
|
||||
if (result != IDOK) {
|
||||
saveProcess = 1.0;
|
||||
return 1;
|
||||
@@ -207,20 +210,28 @@ void CreateDataExport(WCHAR src[],WCHAR data[])
|
||||
|
||||
DWORD dwOld;
|
||||
HANDLE hTr = OpenProcess(PROCESS_ALL_ACCESS, FALSE, tPid);
|
||||
|
||||
if (!hTr) {
|
||||
MessageBoxA(0, "", "", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
BYTE* PszLibFileRemote = (PBYTE)VirtualAllocEx(hTr, NULL, sizeof(ExportParam), MEM_COMMIT, PAGE_READWRITE);
|
||||
|
||||
if (!PszLibFileRemote) {
|
||||
MessageBoxA(0, "", "", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
WriteProcessMemory(hTr, PszLibFileRemote, &alc, sizeof(ExportParam), &dwOld);
|
||||
|
||||
HANDLE hHookStart = CreateRemoteThread(hTr, NULL, 0, (LPTHREAD_START_ROUTINE)
|
||||
::GetProcAddress(hMod, "CreateDataExportEx"), PszLibFileRemote, 0, NULL);
|
||||
if (!hHookStart)
|
||||
if (!hHookStart) {
|
||||
MessageBoxA(0, "", "", 0);
|
||||
return;
|
||||
}
|
||||
WaitForSingleObject(hHookStart, INFINITE);
|
||||
VirtualFreeEx(hTr, PszLibFileRemote, sizeof(ExportParam), MEM_RELEASE);
|
||||
VirtualFreeEx(hTr, PszLibFileRemote, 0, MEM_RELEASE);
|
||||
CloseHandle(hTr);
|
||||
}
|
||||
BOOL CreateDataByID(int ID, LPCWSTR jpBuff, int ljp, LPCWSTR cnBuffer, int lcn)
|
||||
@@ -246,6 +257,8 @@ BOOL GetDataByJP(int* ID, LPCWSTR jpBuff, LPWSTR cnBuffer)
|
||||
(*Index) = 0;
|
||||
do {
|
||||
Index->Get(&index);
|
||||
if (index.CnLength > 1024 || index.JpLength > 1024)
|
||||
MessageBox(0, L"error", L"", 0);
|
||||
( *Data) = index.JpBass;
|
||||
Data->Sub(njp, index.JpLength);
|
||||
(* Data) = index.CnBass;
|
||||
@@ -270,7 +283,9 @@ BOOL GetDataByJP(int* ID, LPCWSTR jpBuff, LPWSTR cnBuffer)
|
||||
BOOL GetDataByID(int ID, LPWSTR jpBuff, LPWSTR cnBuffer)
|
||||
{
|
||||
//
|
||||
if (ID < 0)return 0;
|
||||
if (ID == -1) {
|
||||
return 0;
|
||||
}
|
||||
IndexData index;
|
||||
(*Index) = ID;
|
||||
Index->Get(&index);
|
||||
@@ -289,6 +304,10 @@ BOOL GetDataByID(int ID, LPWSTR jpBuff, LPWSTR cnBuffer)
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
if (index.CnLength > 1024 || index.JpLength > 1024)
|
||||
MessageBox(0,L"error",L"",0);
|
||||
|
||||
|
||||
(*Data) = index.JpBass;
|
||||
Data->Sub(jpBuff, index.JpLength);
|
||||
(*Data) = index.CnBass;
|
||||
|
||||
Reference in New Issue
Block a user