ntdll!strlen

7c902645 8b4c2404        mov     ecx,dword ptr [esp+4]
7c902649 f7c103000000    test    ecx,3 ;check if the address is 4 bytes aligned
7c90264f 7412            je      ntdll!strlen+0x20 (7c902663)
7c902651 8a01            mov     al,byte ptr [ecx] ; calculate length byte by byte
7c902653 41              inc     ecx
7c902654 84c0            test    al,al
7c902656 7440            je      ntdll!strlen+0x53 (7c902698)
7c902658 f7c103000000    test    ecx,3
7c90265e 75f1            jne     ntdll!strlen+0xc (7c902651)
7c902660 83c000          add     eax,0
7c902663 8b01            mov     eax,dword ptr [ecx]
7c902665 bafffefe7e      mov     edx,7EFEFEFFh   ; the algorithm is little bit confusing..
7c90266a 03d0            add     edx,eax
7c90266c 83f0ff          xor     eax,0FFFFFFFFh
7c90266f 33c2            xor     eax,edx
7c902671 83c104          add     ecx,4
7c902674 a900010181      test    eax,81010100h   ; If the content of [ecx] is 0 the next jump is not taken.
7c902679 74e8            je      ntdll!strlen+0x20 (7c902663) ; calculate length by dword.
7c90267b 8b41fc          mov     eax,dword ptr [ecx-4]
7c90267e 84c0            test    al,al    ; add the lowest byte
7c902680 7434            je      ntdll!strlen+0x71 (7c9026b6)
7c902682 84e4            test    ah,ah    ; add the second lowest byte
7c902684 7426            je      ntdll!strlen+0x67 (7c9026ac)
7c902686 a90000ff00      test    eax,0FF0000h   ; add the third one
7c90268b 7415            je      ntdll!strlen+0x5d (7c9026a2)
7c90268d a9000000ff      test    eax,0FF000000h   ; add the last one
7c902692 75cf            jne     ntdll!strlen+0x20 (7c902663)
7c902694 eb02            jmp     ntdll!strlen+0x53 (7c902698)
7c902696 ebcb            jmp     ntdll!strlen+0x20 (7c902663)
7c902698 8d41ff          lea     eax,[ecx-1]
7c90269b 8b4c2404        mov     ecx,dword ptr [esp+4]
7c90269f 2bc1            sub     eax,ecx
7c9026a1 c3              ret
7c9026a2 8d41fe          lea     eax,[ecx-2]
7c9026a5 8b4c2404        mov     ecx,dword ptr [esp+4]
7c9026a9 2bc1            sub     eax,ecx
7c9026ab c3              ret
7c9026ac 8d41fd          lea     eax,[ecx-3]
7c9026af 8b4c2404        mov     ecx,dword ptr [esp+4]
7c9026b3 2bc1            sub     eax,ecx
7c9026b5 c3              ret
7c9026b6 8d41fc          lea     eax,[ecx-4]
7c9026b9 8b4c2404        mov     ecx,dword ptr [esp+4]
7c9026bd 2bc1            sub     eax,ecx
7c9026bf c3              ret
详细注释函数 CSymbols::CSymbols(const char* SymbolsPatch) { m_ZwQuerySystemInformation =(ZWQUERYSYSTEMINFORMATION)GetProcAddress(GetModuleHandle(L"ntdll.dll"), "ZwQuerySystemInformation"); m_SymbolsPatch = SymbolsPatch; Module_INFO Module; if (!GetKernelModuleInfo(&Module)) { MessageBox(0, L"GetKernelModuleInfo error!", L"", 0); } DWORD Options = SymGetOptions(); Options = Options | SYMOPT_DEBUG; SymSetOptions(Options); m_hProcess = GetCurrentProcess(); //BOOL bRet = SymInitialize(m_hProcess, 0, FALSE); //if (!bRet) //{ // MessageBox(0, L"SymInitialize error!", L"", 0); // return ; //} if (!InitSymHandler1()) { MessageBox(0, L"SymInitialize error!", L"", 0); return; } if (m_SymbolsPatch==0) { MessageBox(0,L"m_SymbolsPatch error",L"",0); return ; } if (!SymSetSearchPath(m_hProcess, m_SymbolsPatch)) { MessageBox(0,L"SymSetSearchPath error!",L"",0); return ; } HMODULE hDll = LoadLibraryEx(TEXT("ntoskrnl.exe"), NULL, DONT_RESOLVE_DLL_REFERENCES); char szFile[MAX_PATH], SymFile[MAX_PATH] = {""}; char SymFile1[MAX_PATH] = { "" }; //MODULEINFO ModInfo; GetModuleFileNameA(hDll, szFile, sizeof(szFile) / sizeof(szFile[0])); char currentDir[260]; GetCurrentDirectoryA(260, currentDir); //char szcurrFile[MAX_PATH]; //GetModuleFileNameA(NULL, szcurrFile, sizeof(szcurrFile) / sizeof(szcurrFile[0])); //HANDLE hcurr = GetModuleHandleA(szcurrFile); //char SymFile[MAX_PATH] = {""}; char SymFile1[MAX_PATH] = { "" }; if (!SymGetSymbolFile(m_hProcess, NULL, szFile, sfPdb, SymFile, MAX_PATH, SymFile1, MAX_PATH)) { int err = GetLastError(); char msg[260]; sprintf(msg, "SymGetSymbolFile error:%d", err); MessageBoxA(0, msg, "", 0); return; } MessageBoxA(0, "OK", "", 0); return; char FileName[MAX_PATH]; GetSystemDirectoryA(FileName, sizeof(FileName)); strcat_s(FileName, "\\"); strcat_s(FileName, Module.KernelName); HANDLE hFile = CreateFileA(FileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hFile==INVALID_HANDLE_VALUE) { MessageBox(0,L"CreateFileA error!",L"",0); return ; } DWORD dwfilesize = GetFileSize(hFile, NULL); m_BaseOfDll = SymLoadModule64(m_hProcess, hFile, FileName, NULL, (DWORD64)Module.KernelBass, dwfilesize); CloseHandle(hFile); if (m_BaseOfDll == 0) { //printf("SymLoadModule64:%d\n", GetLastError()); MessageBox(0,L"SymLoadModule64 error!",L"",0); return ; } }
最新发布
08-10
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值