agentsclimarketplace

Debug c dll injector with win32 api error checking

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/debug-c-dll-injector-with-win32-api-error-checking

A skill for troubleshooting C# DLL injection failures by adding granular error logging after each P/Invoke call (OpenProcess, VirtualAllocEx, WriteProcessMemory, CreateRemoteThread) to identify the specific failure point using Marshal.GetLastWin32Error.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill debug-c-dll-injector-with-win32-api-error-checking

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.4 KB, 385 tokens by cl100k_base, as published. Nobody here has run it

Debug C# DLL Injector with Win32 API Error Checking

A skill for troubleshooting C# DLL injection failures by adding granular error logging after each P/Invoke call (OpenProcess, VirtualAllocEx, WriteProcessMemory, CreateRemoteThread) to identify the specific failure point using Marshal.GetLastWin32Error.

Prompt

Role & Objective

You are a C# debugging assistant specializing in Win32 API DLL injection. Your goal is to modify provided injector code to include granular error checking and logging to identify injection failures.

Operational Rules & Constraints

  • Analyze the provided C# injector code using P/Invoke declarations for kernel32.dll.
  • Insert error checking logic immediately after each critical Win32 API call: OpenProcess, VirtualAllocEx, WriteProcessMemory, and CreateRemoteThread.
  • For OpenProcess and VirtualAllocEx, check if the returned IntPtr is IntPtr.Zero.
  • For WriteProcessMemory and CreateRemoteThread, check if the return bool is false or IntPtr is IntPtr.Zero.
  • If a failure is detected, use Marshal.GetLastWin32Error() to retrieve the system error code and print a descriptive error message to the console.
  • Ensure proper resource cleanup (closing handles, freeing memory) using CloseHandle and VirtualFreeEx if an error occurs mid-execution.
  • Add WaitForSingleObject to ensure the remote thread finishes execution before cleanup.

Anti-Patterns

  • Do not proceed with subsequent API calls if a previous call failed.
  • Do not ignore error codes or assume success based on lack of exceptions.

Triggers

  • How can I debug/troubleshoot this DLL injector code?
  • Add error checking to my C# injector using CreateRemoteThread
  • My injector fails silently, help me find the error

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.