| 115 | } |
| 116 | |
| 117 | HMODULE DllInjection::getModuleHandleByFilename( HANDLE hProcess, const WCHAR * filename ) |
| 118 | { |
| 119 | HMODULE * hMods = 0; |
| 120 | HMODULE hModResult = 0; |
| 121 | WCHAR target[MAX_PATH]; |
| 122 | |
| 123 | DWORD numHandles = ProcessAccessHelp::getModuleHandlesFromProcess(hProcess, &hMods); |
| 124 | if (numHandles == 0) |
| 125 | { |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | for (DWORD i = 0; i < numHandles; i++) |
| 130 | { |
| 131 | if (GetModuleFileNameExW(hProcess, hMods[i], target, _countof(target))) |
| 132 | { |
| 133 | if (!_wcsicmp(target, filename)) |
| 134 | { |
| 135 | hModResult = hMods[i]; |
| 136 | break; |
| 137 | } |
| 138 | } |
| 139 | else |
| 140 | { |
| 141 | #ifdef DEBUG_COMMENTS |
| 142 | Scylla::debugLog.log(L"DllInjection::getModuleHandle :: GetModuleFileNameExW failed 0x%X", GetLastError()); |
| 143 | #endif |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | if (!hModResult) |
| 148 | { |
| 149 | #ifdef DEBUG_COMMENTS |
| 150 | Scylla::debugLog.log(L"DllInjection::getModuleHandle :: Handle not found"); |
| 151 | #endif |
| 152 | } |
| 153 | |
| 154 | delete [] hMods; |
| 155 | |
| 156 | return hModResult; |
| 157 | } |
| 158 | |
| 159 | void DllInjection::specialThreadSettings( HANDLE hThread ) |
| 160 | { |