forked from Public-Mirror/Textractor
fix wrong output for non utf text
This commit is contained in:
parent
3c33d11d80
commit
1782292662
@ -307,7 +307,7 @@ int TextHook::GetLength(uintptr_t base, uintptr_t in)
|
|||||||
else {
|
else {
|
||||||
if (hp.type & BIG_ENDIAN)
|
if (hp.type & BIG_ENDIAN)
|
||||||
in >>= 8;
|
in >>= 8;
|
||||||
len = LeadByteTable[in & 0xff]; //Slightly faster than IsDBCSLeadByte
|
len = !!IsDBCSLeadByteEx(hp.codepage, in & 0xff) + 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -9,32 +9,6 @@
|
|||||||
#include "ithsys/ithsys.h"
|
#include "ithsys/ithsys.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
|
|
||||||
// - Global variables -
|
|
||||||
|
|
||||||
// jichi 6/12/2015: https://en.wikipedia.org/wiki/Shift_JIS
|
|
||||||
// Leading table for SHIFT-JIS encoding
|
|
||||||
BYTE LeadByteTable[0x100] = {
|
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
||||||
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
|
||||||
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
|
||||||
2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
||||||
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
|
||||||
2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1
|
|
||||||
};
|
|
||||||
|
|
||||||
// - API functions -
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
/**
|
/**
|
||||||
* Return the address of the first matched pattern.
|
* Return the address of the first matched pattern.
|
||||||
* Artikash 7/14/2018: changed implementation, hopefully it behaves the same
|
* Artikash 7/14/2018: changed implementation, hopefully it behaves the same
|
||||||
@ -70,15 +44,25 @@ DWORD IthGetMemoryRange(LPCVOID mem, DWORD *base, DWORD *size)
|
|||||||
return info.Protect > PAGE_NOACCESS;
|
return info.Protect > PAGE_NOACCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DWORD GetHash(LPSTR str)
|
// jichi 6/12/2015: https://en.wikipedia.org/wiki/Shift_JIS
|
||||||
{
|
// Leading table for SHIFT-JIS encoding
|
||||||
DWORD hash = 0;
|
BYTE LeadByteTable[0x100] = {
|
||||||
//for (; *str; str++)
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
while (*str)
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
hash = ((hash >> 7) | (hash << 25)) + *str++;
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
return hash;
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
}
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
} // extern "C"
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
||||||
|
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
||||||
|
2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
||||||
|
2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1
|
||||||
|
};
|
||||||
|
|
||||||
// EOF
|
// EOF
|
@ -10,14 +10,10 @@
|
|||||||
//#include "ntdll/ntdll.h"
|
//#include "ntdll/ntdll.h"
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
// jichi 8/24/2013: Why extern "C"? Any specific reason to use C instead of C++ naming?
|
|
||||||
extern "C" {
|
|
||||||
|
|
||||||
// jichi 10/1/2013: Return 0 if failed. So, it is ambiguous if the search pattern starts at 0
|
// jichi 10/1/2013: Return 0 if failed. So, it is ambiguous if the search pattern starts at 0
|
||||||
DWORD SearchPattern(DWORD base, DWORD base_length, LPCVOID search, DWORD search_length); // KMP
|
DWORD SearchPattern(DWORD base, DWORD base_length, LPCVOID search, DWORD search_length); // KMP
|
||||||
|
|
||||||
DWORD IthGetMemoryRange(LPCVOID mem, DWORD *base, DWORD *size);
|
DWORD IthGetMemoryRange(LPCVOID mem, DWORD *base, DWORD *size);
|
||||||
} // extern "C"
|
|
||||||
|
|
||||||
extern BYTE LeadByteTable[];
|
extern BYTE LeadByteTable[];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user