I tried using a function called NTCreateFile . When I compiled, he gave me an error saying "The identifier _NTCreateFile was not found." I included the winternl.h header. So I tried using ZwCreatFile , since MSDN included ntifs.h , but I can not include this header. It says: "Unable to open / find directory." I am using V @ 2008. What is the problem? Did I miss something?
EDIT1:
typedef NTSTATUS (*fp_CreatFile)( OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength ); OBJECT_ATTRIBUTES myAttributes; int _tmain(int argc, _TCHAR* argv[]) { fp_CreatFile myFunction; HMODULE module = LoadLibrary(L"ntdll.dll"); if(NULL != module) { myFunction = (fp_CreatFile)GetProcAddress(module,"NtCreateFile"); } UNICODE_STRING string; IO_STATUS_BLOCK fileStatus; string.Length = 56; string.Buffer = L"C:\\user\\kiddo\\Desktop\\7zFM.exe"; string.MaximumLength = 56; HANDLE fileHandle; myAttributes.ObjectName = &string; myAttributes.Length = sizeof(OBJECT_ATTRIBUTES); long mystatus = myFunction(&fileHandle,FILE_GENERIC_READ,&myAttributes ,&fileStatus,NULL,FILE_ATTRIBUTE_NORMAL,FILE_SHARE_READ, NULL,NULL,NULL,NULL); return 0; }
When he tries to cause what he gives the following error in the message box. ERROR: Runtime Check Error # 0 - The ESP value was not properly stored during the function call. This is usually the result of calling a function declared with one call, with a function pointer declared with another calling convention.
kiddo source share