Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted
https://dzone.com/articles/windows-api-hooking-and-dll-injection

 

spacer.png

 

This code and accompanying article is worse than most ConfuserEx mods written by script kiddies... Where do I start?

 

Quote

we imply the hook setup code is located in DllMain function of the external DLL

Holy f*ck, have you ever heard of things you should never ever do inside DllMain? Loading another DLL from DllMain is one of the basic ones - it virtually guarantees a deadlock.

Quote

Passing a pointer to the DLL hook (the one we initialized using VirtualAllocEx and WriteProcessMemory) as a lpParameter.

"DLL hook"... You mean DLL name? Like, I don't know... a string?

Quote

Microsoft Detour, ... requires a paid subscription for hooking on x64

Not since year 2018... And it's called "Detours"

 

And the cherry on the top!

Quote

    HANDLE hThread = CreateRemoteThread(processInformation.hProcess, NULL, NULL, (LPTHREAD_START_ROUTINE)lpLoadLibraryW, lpRemoteString, NULL, NULL);
    if (!hThread) {
        PrintError(TEXT("CreateRemoteThread failed"));
    }
    else {
        WaitForSingleObject(hThread, 4000);
        //resume suspended process
        ResumeThread(processInformation.hThread);
    }
    //  free allocated memory
    VirtualFreeEx(processInformation.hProcess, lpRemoteString, 0, MEM_RELEASE);
    // close process handle
    CloseHandle(processInformation.hProcess);
    return TRUE;

 

Just 4 problems in 9 lines of code! Must be a world record or something! :)

1) if CreateRemoteThread fails, child process is left hanging;
2) WaitForSingleObject with 4000ms timeout assumes that remote thread runs immediately and that hook DLL loads and does its stuff immediately. You just created a race condition between hooking thread and main process thread.
3) WaitForSingleObject with timeout + VirtualFreeEx creates another nasty race condition.
4) You should close the thread handle for the process you created:  CloseHandle(processInformation.hThread);

  • 7 months later...
On 8/4/2020 at 12:36 AM, kao said:

spacer.png

 

This code and accompanying article is worse than most ConfuserEx mods written by script kiddies... Where do I start?

 

Holy f*ck, have you ever heard of things you should never ever do inside DllMain? Loading another DLL from DllMain is one of the basic ones - it virtually guarantees a deadlock.

"DLL hook"... You mean DLL name? Like, I don't know... a string?

Not since year 2018... And it's called "Detours"

 

And the cherry on the top!

Just 4 problems in 9 lines of code! Must be a world record or something! :)

1) if CreateRemoteThread fails, child process is left hanging;
2) WaitForSingleObject with 4000ms timeout assumes that remote thread runs immediately and that hook DLL loads and does its stuff immediately. You just created a race condition between hooking thread and main process thread.
3) WaitForSingleObject with timeout + VirtualFreeEx creates another nasty race condition.
4) You should close the thread handle for the process you created:  CloseHandle(processInformation.hThread);

Good catch, im learning about api hooking and dll injections i wouldn't want to learn from some 'lazyly' written article

 

  • 2 years later...

These are very friendly tutorials, which provide some references for beginners... 😏

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.