-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Version to V1.1\nFix SI Bug,Crashes On Ctrl+F On Chinese Chars
- Loading branch information
root
committed
Aug 17, 2015
1 parent
5382bc4
commit 6bcc3a2
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef __PATCH__H__ | ||
#define __PATCH__H__ | ||
|
||
int PatchSI(void); | ||
|
||
#endif |