線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1472
推到 Plurk!
推到 Facebook!

wchar_t與char的問題

尚未結案
guardian635
一般會員


發表:19
回覆:6
積分:5
註冊:2009-11-21

發送簡訊給我
#1 引用回覆 回覆 發表時間:2011-04-30 14:27:38 IP:114.41.xxx.xxx 訂閱
[code cpp]
int EnableDebugPriv(const char * name)
{
HANDLE hToken;
TOKEN_PRIVILEGES tp;
LUID luid;
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &hToken);
LookupPrivilegeValue(NULL,name,&luid);
tp.PrivilegeCount = 1;
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
tp.Privileges[0].Luid = luid;
AdjustTokenPrivileges(hToken, 0, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL);
return 0;
}
//---------------------------------------------------------------------------
BOOL InjectDll(const wchar_t *DllFullPath, const DWORD dwRemoteProcessId)
{
HANDLE hRemoteProcess;
EnableDebugPriv(SE_DEBUG_NAME);
hRemoteProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, dwRemoteProcessId );
char *pszLibFileRemote;
pszLibFileRemote = (char *) VirtualAllocEx( hRemoteProcess, NULL, lstrlen(DllFullPath) 1, MEM_COMMIT, PAGE_READWRITE);
WriteProcessMemory(hRemoteProcess, pszLibFileRemote, (void *) DllFullPath, lstrlen(DllFullPath) 1, NULL);
PTHREAD_START_ROUTINE pfnStartAddr = (PTHREAD_START_ROUTINE)
GetProcAddress(GetModuleHandle(TEXT("Kernel32")), "LoadLibraryA");
HANDLE hRemoteThread;
if( (hRemoteThread = CreateRemoteThread( hRemoteProcess, NULL, 0, pfnStartAddr, pszLibFileRemote, 0, NULL) ) == NULL)
{
return FALSE;
}
CloseHandle(hRemoteProcess);
CloseHandle(hRemoteThread);
return TRUE;
}
[/code]
[code cpp]
BOOL InjectDll(const char *DllFullPath, const DWORD dwRemoteProcessId)
{
HANDLE hRemoteProcess;
EnableDebugPriv(SE_DEBUG_NAME);
hRemoteProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, dwRemoteProcessId );
char *pszLibFileRemote;
pszLibFileRemote = (char *) VirtualAllocEx( hRemoteProcess, NULL, lstrlen(DllFullPath) 1, MEM_COMMIT, PAGE_READWRITE);
WriteProcessMemory(hRemoteProcess, pszLibFileRemote, (void *) DllFullPath, lstrlen(DllFullPath) 1, NULL);
PTHREAD_START_ROUTINE pfnStartAddr = (PTHREAD_START_ROUTINE)
GetProcAddress(GetModuleHandle(TEXT("Kernel32")), "LoadLibraryA");
HANDLE hRemoteThread;
if( (hRemoteThread = CreateRemoteThread( hRemoteProcess, NULL, 0, pfnStartAddr, pszLibFileRemote, 0, NULL) ) == NULL)
{
return FALSE;
}
CloseHandle(hRemoteProcess);
CloseHandle(hRemoteThread);
return TRUE;
}
[/code]
以上是我在2007版本編釋成功
但在XE版卻失敗
XE版我把他修改成wchar_t
編釋成功
InjectDll(bsSkinEdit1->Text.c_str(),StrToInt(bsSkinComboBox2->Text));
但是效果卻沒出來
若不改wchar_t爆出來的錯誤是
[code cpp]
[BCC32 Error] Unit1.cpp(46): E2034 Cannot convert 'const char *' to 'const wchar_t *'
[BCC32 Error] Unit1.cpp(46): E2342 Type mismatch in parameter 'lpName' (wanted 'const wchar_t *', got 'const char *')
[BCC32 Error] Unit1.cpp(59): E2034 Cannot convert 'wchar_t const[17]' to 'const char *'
[BCC32 Error] Unit1.cpp(59): E2342 Type mismatch in parameter 'name' (wanted 'const char *', got 'const wchar_t *')
[BCC32 Error] Unit1.cpp(65): E2034 Cannot convert 'const char *' to 'const wchar_t *'
[BCC32 Error] Unit1.cpp(65): E2342 Type mismatch in parameter 'lpString' (wanted 'const wchar_t *', got 'const char *')
[BCC32 Error] Unit1.cpp(67): E2034 Cannot convert 'const char *' to 'const wchar_t *'
[BCC32 Error] Unit1.cpp(67): E2342 Type mismatch in parameter 'lpString' (wanted 'const wchar_t *', got 'const char *')
[/code]
編輯記錄
guardian635 重新編輯於 2011-04-30 00:28:06, 註解 無‧
guardian635 重新編輯於 2011-04-30 00:28:22, 註解 無‧
系統時間:2017-12-14 12:24:51
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!