D
djcniay
Unregistered / Unconfirmed
GUEST, unregistred user!
delphi7 编译出来的程序 在英文OS会显示??<br><br>这个程序能够解决。有带源码是VC的。我想转成delphi不成功,谁有空帮我转转,谢谢。<br>http://www.cnblogs.com/hBifTs/articles/4521.html<br>VC的<br>#include "stdafx.h"<br><br>#pragma comment(linker,"/INCREMENTAL:NO")<br><br>struct apc_parameter{<br> TCHAR x[24];<br> LCID local;<br> BOOL (WINAPI*SetThreadLocaleA) (LCID Locale);<br> int (WINAPI*MessageBoxA)(HWND hWnd ,LPCSTR lpText, LPCSTR lpCaption,UINT uType);<br>};<br><br>void CALLBACK apc_routine(int _ap)<br>{<br> struct apc_parameter * ap = (struct apc_parameter*)_ap;<br><br> // if(!ap->SetThreadLocaleA(LOCALE_SYSTEM_DEFAULT))<br> if(!ap->SetThreadLocaleA(ap->local))<br> {<br> // ap->MessageBoxA(NULL,ap->x,ap->x,MB_OK);<br> }<br>}<br><br>int Reverse(LPTSTR filepath)<br>{<br> STARTUPINFO si;<br> PROCESS_INFORMATION pi;<br> PVOID codeSeg, dataSeg;<br> DWORD cbWritten;<br> struct apc_parameter ap;<br><br> ZeroMemory(&si, sizeof(si));<br> si.cb = sizeof(si);<br><br> // TCHAR appPath[] = _T("G://Tools//Network//QQ//QQRTF//QQRTF.exe");<br>/* TCHAR *fullPath = GetCommandLine();<br> strlwr(fullPath);<br> TCHAR par[] = _T("/file:");<br> TCHAR *appPath = strstr(fullPath,par);<br> if(appPath == NULL)<br> {<br> return 0;<br> }<br> appPath += strlen(par);<br>*/<br>// TCHAR appPath[] = _T("D://Program Files//Bradbury//FeedDemon//FeedDemon.exe");<br> <br> CreateProcess( 0, filepath, 0, 0, 0, CREATE_SUSPENDED, 0, 0, &si, &pi );<br> if(!pi.hThread){<br> return -1;<br> }<br><br> // DWORD codeSize = (DWORD)Func_End - (DWORD)Func_Begin;<br><br> codeSeg = VirtualAllocEx(pi.hProcess,0, 1024, MEM_COMMIT, PAGE_EXECUTE_READWRITE );<br> dataSeg = VirtualAllocEx(pi.hProcess,0, 1024, MEM_COMMIT, PAGE_READWRITE );<br><br> ap.local = MAKELCID(MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED),SORT_CHINESE_PRC);<br> strcpy(ap.x,_T("Error"));<br><br> *((FARPROC*)&ap.SetThreadLocaleA) = GetProcAddress( GetModuleHandle("kernel32.dll"), "SetThreadLocale");<br>// *((FARPROC*)&ap.MessageBoxA) = GetProcAddress( GetModuleHandle("user32.dll"), "MessageBoxA");<br><br> WriteProcessMemory( pi.hProcess, codeSeg, apc_routine, 1024, &cbWritten );<br><br> WriteProcessMemory( pi.hProcess, dataSeg, &ap, sizeof(ap), &cbWritten );<br><br><br> if(!QueueUserAPC((PAPCFUNC)codeSeg, pi.hThread, (DWORD)dataSeg)){<br><br> return -1;<br> }<br> ResumeThread(pi.hThread);<br> CloseHandle(pi.hThread);<br> CloseHandle(pi.hProcess);<br> return 0;<br>}<br><br><br>我转的程序:<br>//----------------<br>program Project3;<br><br><br>uses<br> Windows,SysUtils;<br><br>type<br> apc_parameter=packed record<br>// x:array[0..23] of char;<br> local:LCID;<br><br> p: function (Locale: LCID): BOOL; stdcall;<br>// m: function (hWnd: HWND; lpText, lpCaption: PAnsiChar; uType: UINT): Integer; stdcall;<br> end;<br> procedure apc_routine(_ap:Integer);<br> begin<br> with apc_parameter(Pointer(_ap)^) do<br> begin<br>// m(0,x,x,0);<br> p(local)<br> end<br> end;<br><br> procedure temp ;<br> begin<br> ;<br> end;<br>// ap.p(ap.local)<br>// if not ap.p(ap.local) then ap.m(0,ap.x,ap.x,0);<br> function PatchFile(aFilenameChar):Boolean;<br> var<br> vStartupInfo:TStartupInfo;<br> vProcessInfo:TProcessInformation;<br> vCodeSeg,vDataSegointer;<br> vAp:apc_parameter;<br> lpNumberOfBytesWritten: DWORD;<br> begin<br> FillChar(vStartupInfo,SizeOf(vStartupInfo),#0);<br> vStartupInfo.cb:=SizeOf(vStartupInfo);<br>// vStartupInfo.dwFlags:=STARTF_USESHOWWINDOW;<br>// vStartupInfo.wShowWindow:=SW_SHOWNORMAL;<br> if not CreateProcess(nil,aFilename,nil,nil,False,CREATE_SUSPENDED,nil,nil,vStartupInfo,vProcessInfo) then<br> Result:=False<br> else<br> begin<br> vCodeSeg := VirtualAllocEx(vProcessInfo.hProcess,nil,1024,MEM_COMMIT, PAGE_EXECUTE_READWRITE );<br> vDataSeg := VirtualAllocEx(vProcessInfo.hProcess,nil,1024,MEM_COMMIT, PAGE_READWRITE );<br> with vAp do<br> begin<br> local :=$0804;<br>// x :='ERROR';<br> @p:=GetProcAddress(GetModuleHandle('kernel32.dll'),'SetThreadLocale');<br>// @m:=GetProcAddress(GetModuleHandle('user32.dll'),'MessageBoxA');<br> end;<br><br> WriteProcessMemory(vProcessInfo.hProcess,vCodeSeg,@apc_routine,Integer(@temp)-Integer(@apc_routine),lpNumberOfBytesWritten);<br> WriteProcessMemory(vProcessInfo.hProcess,vDataSeg,@vAp,SizeOf(vAp),lpNumberOfBytesWritten);<br> if not (QueueUserAPC(vCodeSeg,vProcessInfo.hThread,DWORD(vDataSeg))) then<br> begin<br>// MessageBox(0,'','',0);<br>// Result :=False;<br> end;<br> ResumeThread(vProcessInfo.hThread);<br> CloseHandle(vProcessInfo.hThread);<br> CloseHandle(vProcessInfo.hProcess);<br> Result :=True;<br> end;<br> end;<br>begin<br> PatchFile('c:/1.exe');<br> { TODO -oUser -cConsole Main : Insert code here }<br>end.