Skip to content

Commit

Permalink
Update Version to V1.1\nFix SI Bug,Crashes On Ctrl+F On Chinese Chars
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Aug 17, 2015
1 parent 5382bc4 commit 6bcc3a2
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
56 changes: 56 additions & 0 deletions patch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <windows.h>
#include "utils.h"
#include "patch.h"


static void PatchCode(PBYTE addr,BYTE* patch,int size)
{
DWORD OldProtect = 0;
VirtualProtect(addr,size,PAGE_EXECUTE_READWRITE,&OldProtect);
RtlCopyMemory(addr,patch,size);
VirtualProtect(addr,size,OldProtect,&OldProtect);
FlushInstructionCache((HANDLE)-1,addr,size);
}


//ÐÞ¸´SI Ctrl+FµÄbug
//reference:http://bbs.pediy.com/showthread.php?t=185736
int PatchSI(void)
{
//004055E1 806405 F4 00 and byte ptr [ebp+eax-0xC], 0x0
BYTE TARGET[5] = {0x80,0x64,0x05,0xF4,0x00};
BYTE PATCH[5] = {0x90,0x90,0x90,0x90,0x90};
PBYTE exemod = GetModuleHandle(NULL);
PBYTE address = exemod;
PBYTE start;
MEMORY_BASIC_INFORMATION mbi;

while(TRUE)
{
if(VirtualQueryEx(GetCurrentProcess(),address,&mbi,sizeof(mbi)) != sizeof(mbi))
{
break;
}
if(mbi.AllocationBase != exemod)
{
break;
}
if((mbi.Protect&PAGE_EXECUTE_READ) && (mbi.State == MEM_COMMIT))
{
for(start = mbi.BaseAddress;start < mbi.BaseAddress+mbi.RegionSize-5;start++)
{
if(memcmp(start,TARGET,sizeof(TARGET)) == 0)
{
OutputDebugStringEx("BaseAddress[%08x] RegionSize[%08x]",mbi.BaseAddress,mbi.RegionSize);
OutputDebugStringEx("Find Patch Address %08x",start);
PatchCode(start,PATCH,sizeof(PATCH));
return 0;
}

}
}
address = ((PBYTE)mbi.BaseAddress+mbi.RegionSize);
}

return -1;
}
6 changes: 6 additions & 0 deletions patch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __PATCH__H__
#define __PATCH__H__

int PatchSI(void);

#endif

0 comments on commit 6bcc3a2

Please sign in to comment.