|
[推荐]计算机密码学及其应用.pdf
中间少了几页,希望楼主添加上。 |
|
[招聘]广州欢聚时代[美国纳斯达克上市, YY语音/多玩游戏网] 招聘安全攻防工程师
要在北京,可以考虑。 |
|
|
|
[招聘]软件逆向分析工程师
估计没人去搭理你 |
|
[原创]我的学写外挂之路
写外挂是犯法的。 |
|
[求助]DLL 使用 LoadLibrary加载不成功的原因
大家别误会,纯属技术讨论。 |
|
[求助]DLL 使用 LoadLibrary加载不成功的原因
哪位大侠给我点提示?什么原因加载不了? |
|
[求助]DLL 使用 LoadLibrary加载不成功的原因
导入表需要修正? |
|
[求助]DLL 使用 LoadLibrary加载不成功的原因
HMODULE LoadDll( LPCSTR lpFileName ) { HMODULE hntdll = NULL; if (hntdll == NULL) { hntdll = GetModuleHandleA("ntdll.dll"); } if (_LdrLoadDll == NULL) { _LdrLoadDll = (fLdrLoadDll) GetProcAddress ( hntdll, "LdrLoadDll"); } if (_RtlInitUnicodeString == NULL) { _RtlInitUnicodeString = (fRtlInitUnicodeString) GetProcAddress ( hntdll, "RtlInitUnicodeString"); } int StrLen = lstrlenA(lpFileName); BSTR WideStr = SysAllocStringLen(NULL, StrLen); MultiByteToWideChar(CP_ACP, 0, lpFileName, StrLen, WideStr, StrLen); UNICODE_STRING usDllName; _RtlInitUnicodeString(&usDllName, WideStr); SysFreeString(WideStr); HANDLE DllHandle; _LdrLoadDll(0, 0, &usDllName, &DllHandle); return (HMODULE)DllHandle; } |
|
[求助]DLL 使用 LoadLibrary加载不成功的原因
HMODULE __stdcall MyLoadLibraryA(const char *szDllName) { void *pFileAddr;//文件隐射基地址 void *pImageBase;//加载DLL的基地址,作为返回数 IMAGE_DOS_HEADER *pDosHead; IMAGE_OPTIONAL_HEADER *pOPHead; IMAGE_FILE_HEADER *pFileHead; DWORD dwSecNum; IMAGE_SECTION_HEADER *pSecInfo; IMAGE_IMPORT_DESCRIPTOR *pIID; LPTHREAD_START_ROUTINE OEP; IMAGE_BASE_RELOCATION *pIBR; DWORD dwDllRVA; //实际装载地址与建议装载地址差。 DWORD i = 0; do { HANDLE hFile = ::CreateFileA(szDllName,GENERIC_READ,0,NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL); if (hFile==INVALID_HANDLE_VALUE) break; HANDLE hMaping = CreateFileMapping(hFile,NULL,PAGE_READONLY,0,0,NULL); pFileAddr = MapViewOfFile(hMaping,FILE_MAP_READ,0,0,0); pDosHead = (IMAGE_DOS_HEADER*)pFileAddr; pFileHead = (IMAGE_FILE_HEADER*)(pDosHead->e_lfanew+4 +(DWORD)pFileAddr); pOPHead = (IMAGE_OPTIONAL_HEADER*)((DWORD)pFileHead + sizeof(_IMAGE_FILE_HEADER)); //申请内存,建立DLL内存空间,并COPY DLL pImageBase = VirtualAlloc(NULL,pOPHead->SizeOfImage,MEM_COMMIT ,PAGE_EXECUTE_READWRITE); if (pImageBase == NULL) break; dwDllRVA = (DWORD)pImageBase - pOPHead->ImageBase; pSecInfo = (IMAGE_SECTION_HEADER*)((DWORD)pOPHead + pFileHead->SizeOfOptionalHeader) ; dwSecNum = pFileHead->NumberOfSections; //COPY文件头 DWORD dwFileSize = pOPHead->SizeOfHeaders; memcpy(pImageBase,pFileAddr,dwFileSize); //COPY区段 for (i = 0; i < dwSecNum; i++) { void *des,*sour; des = (void*)(pSecInfo->VirtualAddress + (DWORD)pImageBase); sour = (void*)(pSecInfo->PointerToRawData + (DWORD)pFileAddr); memcpy(des,sour,pSecInfo->Misc.VirtualSize); pSecInfo++; } OEP = (LPTHREAD_START_ROUTINE)(pOPHead->AddressOfEntryPoint + (DWORD)pImageBase); // 修正重定位表。 pIBR = (IMAGE_BASE_RELOCATION*)(pOPHead->DataDirectory[5].VirtualAddress + (DWORD)pImageBase); while (pIBR->VirtualAddress) { WORD *pTypeOffset = (WORD*)((DWORD)pIBR+ 8); for (i = 0; i < pIBR->SizeOfBlock - 8; i += 2) { //pTypeOffset[i] & 0Xf000 == 0x3000 结果不对,郁闷。 if (pTypeOffset[i] >>12 == 3) { DWORD nTmp =((DWORD) pTypeOffset[i]) & 0xfff; DWORD *pReloc = (DWORD*)(nTmp +(DWORD) pImageBase + pIBR->VirtualAddress); *pReloc = *pReloc + dwDllRVA; } } pIBR = (IMAGE_BASE_RELOCATION*)(pIBR->SizeOfBlock + (DWORD)pIBR); } //填充IAT表 pIID = (IMAGE_IMPORT_DESCRIPTOR*)((pOPHead->DataDirectory[1].VirtualAddress) + (DWORD)pImageBase); while (pIID->Name != 0) { char *pDllName; char *pFacName; HMODULE hDll; IMAGE_THUNK_DATA32 *pIDT,*pIAT; PIMAGE_IMPORT_BY_NAME *pImByName; pDllName = (char*)((DWORD)(pIID->Name) + (DWORD)pImageBase); hDll = LoadLibraryA((LPCSTR)pDllName); pIDT = (IMAGE_THUNK_DATA32*)(pIID->OriginalFirstThunk + (DWORD)pImageBase); pIAT = (IMAGE_THUNK_DATA32*)(pIID->FirstThunk + (DWORD)pImageBase); while (*(DWORD*)pIDT != 0) { pImByName = NULL; pImByName = (PIMAGE_IMPORT_BY_NAME*)((DWORD)(pIDT->u1.AddressOfData) + (DWORD)pImageBase); pFacName =(char*)pImByName+2; pIAT->u1.Function = (DWORD)GetProcAddress(hDll,pFacName); pIDT++ ; } pIID++; } //调用DLLMAIN _asm { pushad; push 0; push DLL_PROCESS_ATTACH; push pImageBase; call OEP; add esp,0x4; //DLLMAIN未平衡堆栈。 popad } } while (false); return (HMODULE)pImageBase; } |
|
[求助]DLL 使用 LoadLibrary加载不成功的原因
使用LdrLoadDll和内存自己加载方式,均不成功 |
|
[原创]使用VIM查看内核代码
vim是个好东东,强制你使用键盘操作。 |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值