Arama butonu
Bu konudaki kullanıcılar: 1 misafir
6
Cevap
687
Tıklama
0
Öne Çıkarma
C Handle is invalid hatası (Kernel Module Driver Loader) (ÇÖZÜLDÜ!)
G
5 yıl
Yüzbaşı
Konu Sahibi

Bir kernel driver'ı yazdım ve processimi çalıştıracağım. Fakat loader'ımda "Handle is invalid" hatası alıyorum bu neden oluyor ? araştırdım ama bir şeyler bulamadım maalesef


int call_kernel_driver(char * pid,HANDLE hDevice){


printf("%s %d", "[+] Calling Driver, hiding PID:", atoi(pid));

DWORD bytes_returned;
char * retbuf;

BOOL call_result = DeviceIoControl(
hDevice,
0x815,
pid,
strlen(pid) + 1,
&retbuf,
sizeof(retbuf),
&bytes_returned,
(LPOVERLAPPED) NULL);

if (!call_result) {
printf("%d",call_result);

printf("Error Code : %d",GetLastError());

printf("[-] Error sending IRP to driver: %s ", GetLastErrorAsString());
return -1;
}

printf("[+] IRP Sent, look for your process!");

}



DeviceIoControl 0 döndürüyor ve "Error Code 6 : Handle is invalid"hatasını alıyorum.

int main de HANDLE hDevice oluşturup servis installer fonksiyonunu ona eşliyorum HANDLE hDevice = installer(); ve call_kernel_driver'ın hDevice değerine onu veriyorum.





< Bu mesaj bu kişi tarafından değiştirildi Guest-8F0924900 -- 4 Şubat 2020; 10:24:14 >


Bu mesajda bahsedilenler: @vonderplanitz
G
5 yıl
Yüzbaşı

kod sorunlu. DeviceIoControl api bildirimi

BOOL DeviceIoControl(

HANDLE hDevice, // handle to device of interest
DWORD dwIoControlCode, // control code of operation to perform
LPVOID lpInBuffer, // pointer to buffer to supply input data
DWORD nInBufferSize, // size of input buffer
LPVOID lpOutBuffer, // pointer to buffer to receive output data
DWORD nOutBufferSize, // size of output buffer
LPDWORD lpBytesReturned, // pointer to variable to receive output byte count
LPOVERLAPPED lpOverlapped // pointer to overlapped structure for asynchronous operation
);


win api yardım dosyası -https://sourceforge.net/projects/win32-help-chm/


Bu mesaja 1 cevap geldi.
G
5 yıl
Yüzbaşı

giriş ve çıkış bufferlar ve buffer boyutları sorunlu gibi. c++ deviceiocontrol example diye aratırsan örnek kodlar var -https://github.com/microsoft/Windows-driver-samples/blob/master/general/ioctl/wdm/exe/testapp.c




Bu mesajda bahsedilenler: @vonderplanitz
DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.