#include <windows.h>
#include <stdio.h>

int main() {
    DWORD processId;
    HANDLE hProcess;

    printf("Enter Process ID: ");
    scanf("%lu", &processId);

    // Step 1: Open the process with desired access rights
    hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);

    if (hProcess == NULL) {
        printf("Failed to open process. Error: %lu\n", GetLastError());
        return 1;
        }

        printf("Successfully opened process with handle: %p\n", hProcess);

        // Step 2: Close the handle once done
        CloseHandle(hProcess);
        return 0;
    }
    
