1
0
Fork 0

DBG: fixed a few warnings

DBG: updated pattern finder
This commit is contained in:
Mr. eXoDia 2014-05-21 00:20:31 +02:00
parent 259099f936
commit bf7c1fb8c3
8 changed files with 53 additions and 39 deletions

View File

@ -19,7 +19,7 @@
<ClInclude Include="_global.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{944D9923-CB1A-6F6C-BCBC-9E00A71954C1}</ProjectGuid>
<ProjectGuid>{944D9923-CB1A-6F6C-BCBC-9E00A71954C1}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@ -42,14 +42,14 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\x32</OutDir>
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\x32\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<TargetName>x32_bridge</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\x64</OutDir>
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\x64\</OutDir>
<TargetName>x64_bridge</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

View File

@ -126,41 +126,41 @@ extern "C" DLL_EXPORT bool _dbg_memmap(MEMMAP* memmap)
SectionName="";
int len=strlen(SectionName);
int escape_count=0;
for(int i=0; i<len; i++)
if(SectionName[i]=='\\' or SectionName[i]=='\"' or !isprint(SectionName[i]))
for(int k=0; k<len; k++)
if(SectionName[k]=='\\' or SectionName[k]=='\"' or !isprint(SectionName[k]))
escape_count++;
char* SectionNameEscaped=(char*)emalloc(len+escape_count+1, "_dbg_memmap:SectionNameEscaped");
memset(SectionNameEscaped, 0, len+escape_count+1);
for(int i=0,j=0; i<len; i++)
for(int k=0,l=0; k<len; k++)
{
switch(SectionName[i])
switch(SectionName[k])
{
case '\t':
j+=sprintf(SectionNameEscaped+j, "\\t");
l+=sprintf(SectionNameEscaped+l, "\\t");
break;
case '\f':
j+=sprintf(SectionNameEscaped+j, "\\f");
l+=sprintf(SectionNameEscaped+l, "\\f");
break;
case '\v':
j+=sprintf(SectionNameEscaped+j, "\\v");
l+=sprintf(SectionNameEscaped+l, "\\v");
break;
case '\n':
j+=sprintf(SectionNameEscaped+j, "\\n");
l+=sprintf(SectionNameEscaped+l, "\\n");
break;
case '\r':
j+=sprintf(SectionNameEscaped+j, "\\r");
l+=sprintf(SectionNameEscaped+l, "\\r");
break;
case '\\':
j+=sprintf(SectionNameEscaped+j, "\\\\");
l+=sprintf(SectionNameEscaped+l, "\\\\");
break;
case '\"':
j+=sprintf(SectionNameEscaped+j, "\\\"");
l+=sprintf(SectionNameEscaped+l, "\\\"");
break;
default:
if(!isprint(SectionName[i])) //unknown unprintable character
j+=sprintf(SectionNameEscaped+j, "\\x%.2X", SectionName[i]);
if(!isprint(SectionName[k])) //unknown unprintable character
l+=sprintf(SectionNameEscaped+l, "\\x%.2X", SectionName[k]);
else
j+=sprintf(SectionNameEscaped+j, "%c", SectionName[i]);
l+=sprintf(SectionNameEscaped+l, "%c", SectionName[k]);
break;
}
}

View File

@ -171,9 +171,9 @@ static bool HandleArgument(ARGTYPE* Argument, INSTRTYPE* Instruction, DISASM_ARG
{
arg->type=arg_memory;
arg->segment=ConvertBeaSeg(Argument->SegmentReg);
uint value=Argument->Memory.Displacement;
uint value=(uint)Argument->Memory.Displacement;
if((Argument->ArgType&RELATIVE_)==RELATIVE_)
value=Instruction->AddrValue;
value=(uint)Instruction->AddrValue;
arg->constant=value;
arg->value=0;
if(!valfromstring(argmnemonic, &value, true, true))

View File

@ -99,6 +99,20 @@ void memfree(HANDLE hProcess, uint addr)
VirtualFreeEx(hProcess, (void*)addr, 0, MEM_RELEASE);
}
static int formathexpattern(char* string)
{
int len=strlen(string);
_strupr(string);
char* new_string=(char*)emalloc(len+1, "formathexpattern:new_string");
memset(new_string, 0, len+1);
for(int i=0,j=0; i<len; i++)
if(string[i]=='?' or isxdigit(string[i]))
j+=sprintf(new_string+j, "%c", string[i]);
strcpy(string, new_string);
efree(new_string, "formathexpattern:new_string");
return strlen(string);
}
static bool patterntransform(const char* text, std::vector<PATTERNBYTE>* pattern)
{
if(!text or !pattern)
@ -109,6 +123,7 @@ static bool patterntransform(const char* text, std::vector<PATTERNBYTE>* pattern
return false;
char* newtext=(char*)emalloc(len+2, "transformpattern:newtext");
strcpy(newtext, text);
len=formathexpattern(newtext);
if(len%2) //not a multiple of 2
{
newtext[len]='?';
@ -118,7 +133,13 @@ static bool patterntransform(const char* text, std::vector<PATTERNBYTE>* pattern
PATTERNBYTE newByte;
for(int i=0,j=0; i<len; i++)
{
if(isxdigit(newtext[i])) //hex
if(newtext[i]=='?') //wildcard
{
newByte.n[j].all=true; //match anything
newByte.n[j].n=0;
j++;
}
else //hex
{
char x[2]="";
*x=newtext[i];
@ -128,14 +149,7 @@ static bool patterntransform(const char* text, std::vector<PATTERNBYTE>* pattern
newByte.n[j].n=val&0xF;
j++;
}
else if(newtext[i]=='?') //wildcard
{
newByte.n[j].all=true; //match anything
newByte.n[j].n=0;
j++;
}
else //dafug dude..
return false; //invalid pattern format
if(j==2) //two nibbles = one byte
{
j=0;

View File

@ -13,7 +13,7 @@ static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID
int len=strlen(pSymInfo->Name);
SYMBOLINFO curSymbol;
memset(&curSymbol, 0, sizeof(SYMBOLINFO));
curSymbol.addr=pSymInfo->Address;
curSymbol.addr=(duint)pSymInfo->Address;
curSymbol.decoratedSymbol=(char*)BridgeAlloc(len+1);
strcpy(curSymbol.decoratedSymbol, pSymInfo->Name);
curSymbol.undecoratedSymbol=(char*)BridgeAlloc(MAX_SYM_NAME);

View File

@ -22,7 +22,7 @@ void threadcreate(CREATE_THREAD_DEBUG_INFO* CreateThread)
void threadexit(DWORD dwThreadId)
{
for(int i=0; i<threadList.size(); i++)
for(unsigned int i=0; i<threadList.size(); i++)
if(threadList.at(i).dwThreadId==dwThreadId)
{
threadList.erase(threadList.begin()+i);

View File

@ -107,13 +107,13 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\x32\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<TargetName>x32_dbg</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>true</LinkIncremental>
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\x64\</OutDir>
<TargetName>x64_dbg</TargetName>
</PropertyGroup>

View File

@ -20,7 +20,7 @@
<ResourceCompile Include="resource.rc" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{3A22175E-6B72-FDCC-1603-C4A2163C7900}</ProjectGuid>
<ProjectGuid>{3A22175E-6B72-FDCC-1603-C4A2163C7900}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@ -43,14 +43,14 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\x32</OutDir>
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\x32\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<TargetName>x32_dbg</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\x64</OutDir>
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\x64\</OutDir>
<TargetName>x64_dbg</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">