Fixes to hexsearch

Signed-off-by: Warmist <Warmist@gmail.com>
develop
Warmist 2011-08-03 16:27:04 +03:00
parent f4179652fa
commit e98e4a5111
4 changed files with 7 additions and 7 deletions

@ -25,7 +25,7 @@ public:
DEF_LUNE(Hexsearch); DEF_LUNE(Hexsearch);
}; };
void RegisterHexsearch(lua::state &st);//TODO remake into OO oriented thing void RegisterHexsearch(lua::state &st);
} }

@ -13,7 +13,7 @@ end
dofile("dfusion/common.lua") dofile("dfusion/common.lua")
print("Unlocking Df .text section...") print("Unlocking Df .text section...")
unlockDF() --unlockDF()
print("Done unlock") print("Done unlock")
text=GetTextRegion() text=GetTextRegion()
h=hexsearch(text.start,text["end"],0x73,0x02,0x8b,0xce,0x53,0x6a,0x01,0x6a,0x06) h=hexsearch(text.start,text["end"],0x73,0x02,0x8b,0xce,0x53,0x6a,0x01,0x6a,0x06)

@ -1,7 +1,7 @@
#include "hexsearch.h" #include "hexsearch.h"
Hexsearch::Hexsearch(const SearchArgType &args,uint64_t startpos,uint64_t endpos):args_(args),pos_(startpos_),startpos_(startpos),endpos_(endpos) Hexsearch::Hexsearch(const SearchArgType &args,uint64_t startpos,uint64_t endpos):args_(args),pos_(startpos),startpos_(startpos),endpos_(endpos)
{ {
} }
@ -36,7 +36,7 @@ uint64_t Hexsearch::FindNext() //TODO rewrite using Boyer-Moore algorithm
{ {
pos_+=args_.size(); pos_+=args_.size();
delete [] buf; delete [] buf;
return pos_; return pos_-args_.size();
} }
} }
pos_++; pos_++;

@ -24,9 +24,9 @@ lua::Hexsearch::Hexsearch(lua_State *L,int id):tblid(id)
lua::state st(L); lua::state st(L);
uint64_t start,end; uint64_t start,end;
::Hexsearch::SearchArgType args; ::Hexsearch::SearchArgType args;
start=st.as<uint32_t>(2); start=st.as<uint32_t>(1);
end=st.as<uint32_t>(3); end=st.as<uint32_t>(2);
for(int i=4;i<st.gettop();i++) for(int i=3;i<=st.gettop();i++)
{ {
args.push_back(st.as<int>(i)); args.push_back(st.as<int>(i));
} }