首页
社区
课程
招聘
19KX币了,帮忙翻译下C代码转到delphi
发表于: 2016-3-6 13:43 4301

19KX币了,帮忙翻译下C代码转到delphi

2016-3-6 13:43
4301
DWORD SUNDAY(unsigned char *lpBase, unsigned char *lpCmp,DWORD len,DWORD maxSize)
{
    size_t temp[256]; 
    size_t *shift = temp; 
    size_t i, patt_size = len, text_size = maxSize; 
	
    for( i=0; i < 256; i++ ) 
        *(shift+i) = patt_size+1; 
	
    for( i=0; i < patt_size; i++ ) 
        *(shift+unsigned char(*(lpCmp+i))) = patt_size-i; 
    size_t limit = text_size-patt_size+1; 
    for( i=0; i < limit; i += shift[ lpBase[i+patt_size] ] ) 
    { 
        if( lpBase[i] == *lpCmp ) 
        { 
            unsigned char *match_text = lpBase+i+1; 
            size_t match_size = 1; 
            do 
            {
                if( match_size == patt_size )
				{
                    return (DWORD)lpBase+i;
				}
            } 
            while( (*match_text++) == lpCmp[match_size++] ); 
        } 
    } 
	return NULL;
}

/*
EngineSingCode
{
  szProcName   进程名
  szSearchCode 内存特征码
  dwLen        内存分页特征码长度
  (此函数采用最快的内存字符特征匹配算法SunDay,搜索2GB内存只需1秒)
}
*/
DWORD WINAPI EngineSingCode(LPSTR szProcName,char * szSearchCode,DWORD dwlen)
{
	DWORD PID=GetCurrentProcessId();
	DWORD pBase,dwSize;
	if (!GetModuleInfo(PID,szProcName,&pBase,&dwSize))
		return NULL;
	DWORD pAddr=SUNDAY((unsigned char *)pBase,(unsigned char *)szSearchCode,dwlen,dwSize);
	return pAddr;
}

[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 1088
活跃值: (30)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
2
Sunday?
2016-3-6 14:05
0
雪    币: 8
活跃值: (21)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
恩sunday
function PosEx(KeyStr, TextStr: string): Integer;  
var
 I: Integer;
 KeyLen, BuffLen: Integer;

 function Match(N: Integer): Boolean;
 var
  J: Integer;
 begin
  Result := True;
 for J := 0 to KeyLen - 1 do
   if TextStr[J + N] <> KeyStr[J + 1] then begin
     Result := False;
      Exit;
   end;
 end;

begin
Result := 0;
 I := 1;
  KeyLen := Length(KeyStr);
 BuffLen := Length(TextStr);
while not Match(I) do
begin
  if I > BuffLen then Break;
 if Pos(TextStr[I + KeyLen], KeyStr) <> 0 then begin
   I := I + 1 + KeyLen - Pos(TextStr[I + KeyLen], KeyStr);
  end else begin
    I := I + KeyLen;
   end;
  end;
  if Match(I) then
 Result := I;
end; 
2016-3-6 15:26
0
游客
登录 | 注册 方可回帖
返回
//