阅读:3996回复:21
wowocock大佬帮忙
能告诉我怎么将相应DLL的Import LIB加入工程中吗
|
|
最新喜欢:aasa2 |
沙发#
发布于:2005-01-31 10:15
能告诉我怎么将相应DLL的Import LIB加入工程中吗 1、在代码中加入#pragma comment(lib, "xxx.lib" 2、或者在工程设置中修改 |
|
|
板凳#
发布于:2005-01-31 10:22
allenzh老大,俺在程序开头加入了:
#pragma comment(lib,"D:\\NTDDK\\libfre\\i386\\ntoskrnl.lib")后,仍然报LNK2001错误 |
|
地板#
发布于:2005-01-31 10:30
allenzh老大,俺在程序开头加入了: 你是使用驱动呀? 你要说清楚点,驱动修改source文件才可以,或者在编译连接的时候给参数(我从来不使用这种方法) TARGETLIBS=D:\\NTDDK\\libfre\\i386\\ntoskrnl.lib 这样就可以了 |
|
|
地下室#
发布于:2005-01-31 10:38
[quote]allenzh老大,俺在程序开头加入了: 你是使用驱动呀? 你要说清楚点,驱动修改source文件才可以,或者在编译连接的时候给参数(我从来不使用这种方法) TARGETLIBS=D:\NTDDK\libfre\i386\ntoskrnl.lib 这样就可以了 [/quote] 其实你在SOURCE中和代码中加都是可以的.... |
|
|
5楼#
发布于:2005-01-31 11:20
对呀,俺就是用的驱动,但是我在加入“Targetlibs”的时候,又报错说“TARGETLIBS”不认识,
|
|
6楼#
发布于:2005-01-31 11:42
对呀,俺就是用的驱动,但是我在加入“Targetlibs”的时候,又报错说“TARGETLIBS”不认识, 是source文件,有个叫这个的配置文件,不是source code的source(源代码) |
|
|
7楼#
发布于:2005-01-31 11:52
我把:
#ifdef DBG TARGETLIBS="D:\NTDDK\libchk\i386\ntoskrnl.lib" #else TARGETLIBS="D:\NTDDK\libfre\i386\ntoskrnl.lib" #endif 加入了source文件中的: TARGETLIBS=$(DRIVRERWORKS)\lib\*\$(BUILDTYPE)\vdw.lib之后,但好像还是一样的错误。 |
|
8楼#
发布于:2005-01-31 11:58
我把:
#ifdef DBG TARGETLIBS=D:\NTDDK\libchk\i386\ntoskrnl.lib #else TARGETLIBS=D:\NTDDK\libfre\i386\ntoskrnl.lib #endif 加入了source文件中的: TARGETLIBS=$(DRIVRERWORKS)lib*$(BUILDTYPE)vdw.lib之后,但好像还是一样的错误。 |
|
9楼#
发布于:2005-01-31 15:15
把整个工程贴出来看看.....
|
|
|
10楼#
发布于:2005-01-31 17:13
把整个工程贴出来看看..... 对,这样比较好定位什么原因 |
|
|
11楼#
发布于:2005-01-31 17:18
好的,各位大虾,看看吧,下面是原代码:
这开头有个文件“ntifs.h”,是干嘛的啊,麻烦大家帮忙找找问题吧,为什么下面这段代码在VC+DDK+DriverStudio里调不通呢。谢谢! #include "ntddk.h" #include "ntifs.h" #include "stdio.h" #include "stdarg.h" typedef struct _DEVICE_EXTENSION { HANDLE hWorkerThread; KEVENT ExitEvent; PDEVICE_OBJECT pDeviceObject; BOOLEAN bExit; }DEVICE_EXTENSION, *PDEVICE_EXTENSION; typedef struct _FAKE_ETHREAD{ DISPATCHER_HEADER Header; LIST_ENTRY MutantListHead; PVOID InitialStack; PVOID StackLimit; struct _TEB *Teb; PVOID TlsArray; PVOID KernelStack; BOOLEAN DebugActive; UCHAR State; USHORT Alerted; UCHAR Iopl; UCHAR NpxState; UCHAR Saturation; UCHAR Priority; KAPC_STATE ApcState; ULONG ContextSwitches; NTSTATUS WaitStatus; UCHAR WaitIrql; UCHAR WaitMode; UCHAR WaitNext; UCHAR WaitReason; PKWAIT_BLOCK WaitBlockList; LIST_ENTRY WaitListEntry; ULONG WaitTime; UCHAR BasePriority; UCHAR DecrementCount; UCHAR PriorityDecrement; UCHAR Quantum; KWAIT_BLOCK WaitBlock[4]; ULONG LegoData; ULONG KernelApcDisable; ULONG UserAffinity; BOOLEAN SystemAffinityActive; UCHAR PowerState; UCHAR NpxIrql; UCHAR Pad[1]; PSERVICE_DESCRIPTOR_TABLE ServiceDescriptorTable; PKQUEUE Queue; KSPIN_LOCK ApcQueueLock; KTIMER Timer; LIST_ENTRY QueueListEntry; ULONG Affinity; BOOLEAN Preempted; BOOLEAN ProcessReadyQueue; BOOLEAN KernelStackResident; UCHAR NextProcessor; PVOID CallbackStack; PVOID Win32Thread; PKTRAP_FRAME TrapFrame; PKAPC_STATE ApcStatePointer[2]; UCHAR PreviousMode; BOOLEAN EnableStackSwap; BOOLEAN LargeStack; UCHAR ResourceIndex; ULONG KernelTime; ULONG UserTime; KAPC_STATE SavedApcState; BOOLEAN Alertable; UCHAR ApcStateIndex; BOOLEAN ApcQueueable; BOOLEAN AutoAlignment; PVOID StackBase; KAPC SuspendApc; KSEMAPHORE SuspendSemaphore; LIST_ENTRY ThreadListEntry; UCHAR FreezeCount; UCHAR SuspendCount; UCHAR IdealProcessor; BOOLEAN DisableBoost; LARGE_INTEGER CreateTime; union { LARGE_INTEGER ExitTime; LIST_ENTRY LpcReplyChain; }; union { NTSTATUS ExitStatus; PVOID OfsChain; }; LIST_ENTRY PostBlockList; LIST_ENTRY TerminationPortList; KSPIN_LOCK ActiveTimerListLock; LIST_ENTRY ActiveTimerListHead; CLIENT_ID Cid; }FAKE_ETHREAD, *PFAKE_ETHREAD; VOID ReplaceList(PVOID pContext) { PLIST_ENTRY pFirstEntry, pLastEntry, pPrevEntry, pNextEntry, pEntry; PLIST_ENTRY pNewKiDispatcherReadyListHead,pNewKiWaitInListHead,pNewKiWaitOutListHead; PLIST_ENTRY pKiDispatcherReadyListHead,pKiWaitInListHead,pKiWaitOutListHead; int i, ChangeList; int SysKiWaitInListHeadAddr[] = {0x8042d90b, 0x8042db78, 0x8042de57, 0x8042f176, 0x8046443b, 0x80464441, 0x804644d6}; int SysKiWaitOutListHeadAddr[] = {0x8042d921, 0x8042db90, 0x8042de6f, 0x8042f18e, 0x80464494}; int SysKiWaitOutListHeadAdd4Addr[] = {0x8046448e, 0x804644a1}; int SysKiDispatcherReadyListHeadAddr[] = {0x804041ff, 0x8042faad, 0x804313de, 0x80431568, 0x8043164f, 0x80431672, 0x8043379f, 0x8046462d}; int SysKiDispatcherReadyListHeadAdd4Addr = 0x8043166b; KIRQL OldIrql; KSPIN_LOCK DpcSpinLock; LARGE_INTEGER DelayTime; NTSTATUS Status; PDEVICE_EXTENSION pDevExt; PEPROCESS pEPROCESS; PETHREAD pETHREAD; ULONG PID; PFAKE_ETHREAD pFakeETHREAD; pDevExt = (PDEVICE_EXTENSION)pContext; DelayTime.QuadPart = -(10 * 1000 * 10000); pKiWaitInListHead = (PLIST_ENTRY)0x80482258; pKiWaitOutListHead = (PLIST_ENTRY)0x80482808; pKiDispatcherReadyListHead = (PLIST_ENTRY)0x804822e0; pNewKiWaitInListHead = (PLIST_ENTRY)ExAllocatePool(NonPagedPool,sizeof(LIST_ENTRY)); pNewKiWaitOutListHead = (PLIST_ENTRY)ExAllocatePool(NonPagedPool, sizeof(LIST_ENTRY)); pNewKiDispatcherReadyListHead = (PLIST_ENTRY)ExAllocatePool(NonPagedPool, 32 * sizeof(LIST_ENTRY)); InitializeListHead(pNewKiWaitInListHead); InitializeListHead(pNewKiWaitOutListHead); for(i = 0; i < 32; i++) { InitializeListHead(&pNewKiDispatcherReadyListHead); } KeInitializeSpinLock(&DpcSpinLock); __try { OldIrql = KeRaiseIrqlToDpcLevel(); KeAcquireSpinLockAtDpcLevel(&DpcSpinLock); pFirstEntry = pKiWaitInListHead->Flink; pLastEntry = pKiWaitInListHead->Blink; pNewKiWaitInListHead->Flink = pFirstEntry; pNewKiWaitInListHead->Blink = pLastEntry; pFirstEntry->Blink = pNewKiWaitInListHead; pLastEntry->Flink = pNewKiWaitInListHead; for(i = 0; i < 7; i++) { ChangeList = SysKiWaitInListHeadAddr; *(PULONG)ChangeList = (ULONG)pNewKiWaitInListHead; DbgPrint("NewWaitIn:%8x",*(PULONG)ChangeList); } pFirstEntry = pKiWaitOutListHead->Flink; pLastEntry = pKiWaitOutListHead->Blink; pNewKiWaitOutListHead->Flink = pFirstEntry; pNewKiWaitOutListHead->Blink = pLastEntry; pFirstEntry->Blink = pNewKiWaitOutListHead; pLastEntry->Flink = pNewKiWaitOutListHead; for(i = 0; i < 5; i++) { ChangeList = SysKiWaitOutListHeadAddr; *(PULONG)ChangeList = (ULONG)pNewKiWaitOutListHead; DbgPrint("NewWaitOut:%8x",*(PULONG)ChangeList); } for(i = 0; i < 2; i++) { ChangeList = SysKiWaitOutListHeadAdd4Addr; *(PULONG)ChangeList = (ULONG)pNewKiWaitOutListHead + 0x4; DbgPrint("NewWaitOut+4:%8x",*(PULONG)ChangeList); } for(i = 0; i < 32; i++) { if(pKiDispatcherReadyListHead.Flink != &pKiDispatcherReadyListHead) { pFirstEntry = pKiDispatcherReadyListHead.Flink; pLastEntry = pKiDispatcherReadyListHead.Blink; pNewKiDispatcherReadyListHead.Flink = pFirstEntry; pNewKiDispatcherReadyListHead.Blink = pLastEntry; pFirstEntry->Blink = &pNewKiDispatcherReadyListHead; pLastEntry->Flink = &pNewKiDispatcherReadyListHead; } } for(i = 0; i < 8; i++) { ChangeList = SysKiDispatcherReadyListHeadAddr; *(PULONG)ChangeList = (ULONG)pNewKiDispatcherReadyListHead; DbgPrint("NewDispatcher:%8x", *(PULONG)ChangeList); } ChangeList = SysKiDispatcherReadyListHeadAdd4Addr; *(PULONG)ChangeList = (ULONG)pNewKiDispatcherReadyListHead + 0x4; DbgPrint("NewDispatcher+4:%8x", *(PULONG)ChangeList); KeReleaseSpinLockFromDpcLevel(&DpcSpinLock); KeLowerIrql(OldIrql); for(;;) { InitializeListHead(pKiWaitInListHead); InitializeListHead(pKiWaitOutListHead); for(i = 0; i < 32; i++) { InitializeListHead(&pKiDispatcherReadyListHead); } for(pEntry = pNewKiWaitInListHead->Flink; pEntry && pEntry != pNewKiWaitInListHead; pEntry = pEntry->Flink) { pETHREAD = (PETHREAD)(((PCHAR)pEntry)-0x5c); pEPROCESS = (PEPROCESS)(pETHREAD->Tcb.ApcState.Process); PID = *(PULONG)(((PCHAR)pEPROCESS)+0x9c); if(PID == 0x8) { continue; } pFakeETHREAD = ExAllocatePool(PagedPool, sizeof(FAKE_ETHREAD)); memcpy(pFakeETHREAD, pETHREAD, sizeof(FAKE_ETHREAD)); InsertHeadList(pKiWaitInListHead, &pFakeETHREAD->WaitListEntry); } for(pEntry = pNewKiWaitOutListHead->Flink; pEntry && pEntry != pNewKiWaitOutListHead; pEntry = pEntry->Flink) { pETHREAD = (PETHREAD)(((PCHAR)pEntry)-0x5c); pEPROCESS = (PEPROCESS)(pETHREAD->Tcb.ApcState.Process); PID = *(PULONG)(((PCHAR)pEPROCESS)+0x9c); if(PID == 0x8) { continue; } pFakeETHREAD = ExAllocatePool(PagedPool, sizeof(FAKE_ETHREAD)); memcpy(pFakeETHREAD, pETHREAD, sizeof(FAKE_ETHREAD)); InsertHeadList(pKiWaitOutListHead, &pFakeETHREAD->WaitListEntry); } for(i = 0; i < 32 ; i++) { for(pEntry = pNewKiDispatcherReadyListHead.Flink; pEntry && pEntry != &pNewKiDispatcherReadyListHead; pEntry = pEntry->Flink) { pETHREAD = (PETHREAD)(((char *)pEntry)-0x5c); pEPROCESS = (PEPROCESS)(pETHREAD->Tcb.ApcState.Process); PID = *(ULONG *)(((char *)pEPROCESS)+0x9c); if(PID == 0x8) { continue; } pFakeETHREAD = ExAllocatePool(PagedPool, sizeof(FAKE_ETHREAD)); memcpy(pFakeETHREAD, pETHREAD, sizeof(FAKE_ETHREAD)); InsertHeadList(&pKiDispatcherReadyListHead, &pFakeETHREAD->WaitListEntry); } } DbgPrint("pKiWaitInListHead->Flink:%8x", pKiWaitInListHead->Flink); DbgPrint("pKiWaitInListHead->Blink:%8x", pKiWaitInListHead->Blink); DbgPrint("pKiWaitOutListHead->Flink:%8x", pKiWaitOutListHead->Flink); DbgPrint("pKiWaitOutListHead->Blink:%8x", pKiWaitOutListHead->Blink); DbgPrint("pKiDispatcherReadyListHead[0].Flink:%8x", pKiDispatcherReadyListHead[0].Flink); DbgPrint("pKiDispatcherReadyListHead[0].Blink:%8x", pKiDispatcherReadyListHead[0].Blink); Status = KeWaitForSingleObject(&pDevExt->ExitEvent, Executive, KernelMode, FALSE, &DelayTime); if(Status == STATUS_SUCCESS) break; } OldIrql = KeRaiseIrqlToDpcLevel(); KeAcquireSpinLockAtDpcLevel(&DpcSpinLock); pFirstEntry = pNewKiWaitInListHead->Flink; pLastEntry = pNewKiWaitInListHead->Blink; pKiWaitInListHead->Flink = pFirstEntry; pKiWaitInListHead->Blink = pLastEntry; pFirstEntry->Blink = pKiWaitInListHead; pLastEntry->Flink = pKiWaitInListHead; for(i = 0; i < 7; i++) { ChangeList = SysKiWaitInListHeadAddr; *(PULONG)ChangeList = (ULONG)pKiWaitInListHead; DbgPrint("OrgWaitIn:%8x",*(PULONG)ChangeList); } pFirstEntry = pNewKiWaitOutListHead->Flink; pLastEntry = pNewKiWaitOutListHead->Blink; pKiWaitOutListHead->Flink = pFirstEntry; pKiWaitOutListHead->Blink = pLastEntry; pFirstEntry->Blink = pKiWaitOutListHead; pLastEntry->Flink = pKiWaitOutListHead; for(i = 0; i < 5; i++) { ChangeList = SysKiWaitOutListHeadAddr; *(PULONG)ChangeList = (ULONG)pKiWaitOutListHead; DbgPrint("OrgWaitOut:%8x",*(PULONG)ChangeList); } for(i = 0; i < 2; i++) { ChangeList = SysKiWaitOutListHeadAdd4Addr; *(PULONG)ChangeList = (ULONG)pKiWaitOutListHead + 0x4; DbgPrint("OrgWaitOut+4:%8x",*(PULONG)ChangeList); } for(i = 0; i < 32; i++) { if(pNewKiDispatcherReadyListHead.Flink != &pNewKiDispatcherReadyListHead) { pFirstEntry = pNewKiDispatcherReadyListHead.Flink; pLastEntry = pNewKiDispatcherReadyListHead.Blink; pKiDispatcherReadyListHead.Flink = pFirstEntry; pKiDispatcherReadyListHead.Blink = pLastEntry; pFirstEntry->Blink = &pKiDispatcherReadyListHead; pLastEntry->Flink = &pKiDispatcherReadyListHead; } } for(i = 0; i < 8; i++) { ChangeList = SysKiDispatcherReadyListHeadAddr; *(PULONG)ChangeList = (ULONG)pKiDispatcherReadyListHead; DbgPrint("NewDispatcher:%8x", *(PULONG)ChangeList); } ChangeList = SysKiDispatcherReadyListHeadAdd4Addr; *(PULONG)ChangeList = (ULONG)pKiDispatcherReadyListHead + 0x4; DbgPrint("NewDispatcher+4:%8x", *(PULONG)ChangeList); KeReleaseSpinLockFromDpcLevel(&DpcSpinLock); KeLowerIrql(OldIrql); ExFreePool(pNewKiWaitInListHead); ExFreePool(pNewKiWaitOutListHead); ExFreePool(pNewKiDispatcherReadyListHead); DbgPrint("Now terminate system thread.\n"); PsTerminateSystemThread(STATUS_SUCCESS); } __except(EXCEPTION_EXECUTE_HANDLER) { DbgPrint("Error occured in ReplaceList().\n"); } return; } NTSTATUS DriverUnload(IN PDRIVER_OBJECT pDriObj) { WCHAR DevLinkBuf[] = L"\\??\\SchList"; UNICODE_STRING uniDevLink; PDEVICE_OBJECT pDevObj; PVOID pWorkerThread; PDEVICE_EXTENSION pDevExt; NTSTATUS Status; LARGE_INTEGER WaitTime; WaitTime.QuadPart = -(8 * 1000 * 10000); pDevObj = pDriObj->DeviceObject; pDevExt = (PDEVICE_EXTENSION)pDevObj->DeviceExtension; pDevExt->bExit = TRUE; __try { KeSetEvent(&pDevExt->ExitEvent, 0, FALSE); KeDelayExecutionThread(KernelMode, FALSE, &WaitTime); DbgPrint("SchList:Worker thread killed.\n"); } __except(EXCEPTION_EXECUTE_HANDLER) { DbgPrint("Error occured in Unload().\n"); } if(pDevObj) { RtlInitUnicodeString(&uniDevLink,DevLinkBuf); IoDeleteSymbolicLink(&uniDevLink); IoDeleteDevice(pDevObj); DbgPrint(("SchList.sys:Driver Unload successfully.\n")); return STATUS_SUCCESS; } DbgPrint(("SchList.sys:Detect device failed.\n")); return STATUS_SUCCESS; } NTSTATUS DriverEntry(IN PDRIVER_OBJECT pDriObj, IN PUNICODE_STRING puniRegPath) { WCHAR DevNameBuf[] = L"\\Device\\SchList"; UNICODE_STRING uniDevName; WCHAR DevLinkBuf[] = L"\\??\\SchList"; UNICODE_STRING uniDevLink; PDEVICE_OBJECT pDevObj; PDEVICE_EXTENSION pDevExt; NTSTATUS status; int pKiDispatcherReadyListHeadAddr = 0x804822e0; int pKiWaitInListHeadAddr = 0x80482258; int pKiWaitOutListHeadAddr = 0x80482808; DbgPrint(("SchList:Enter DriverEntry.\n")); RtlInitUnicodeString(&uniDevName,DevNameBuf); status = IoCreateDevice(pDriObj, sizeof(DEVICE_EXTENSION), &uniDevName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDevObj); if(!NT_SUCCESS(status)) { DbgPrint(("SchList.sys:Create device failed.\n")); return status; } DbgPrint(("SchList.sys:Create device successfully.\n")); pDevExt = (PDEVICE_EXTENSION) pDevObj->DeviceExtension; pDevExt->pDeviceObject = pDevObj; KeInitializeEvent(&pDevExt->ExitEvent, SynchronizationEvent, 0); RtlInitUnicodeString(&uniDevLink,DevLinkBuf); status = IoCreateSymbolicLink(&uniDevLink, &uniDevName); if(!NT_SUCCESS(status)) { DbgPrint(("SchList.sys:Create symbolic link failed.\n")); return status; } pDriObj->DriverUnload = DriverUnload; PsCreateSystemThread(&pDevExt->hWorkerThread, (ACCESS_MASK)0L, NULL, (HANDLE)0L, NULL, ReplaceList, pDevExt); return STATUS_SUCCESS; } |
|
12楼#
发布于:2005-01-31 17:36
你还是放附件吧,这样子很乱,并且还有 :D
|
|
|
13楼#
发布于:2005-02-01 08:22
好的,各位大虾,看看吧,附件里面是原代码,这开头有个文件“ntifs.h”,是干嘛的啊,麻烦大家帮忙找找问题吧,为什么下面这段代码在VC+DDK+DriverStudio里调不通呢。谢谢!
|
|
|
14楼#
发布于:2005-02-01 10:06
同时用NTIFS.H和NTDDK.H,强啊.....
简单编译了下,我的错误和你的不一样,奇怪..... |
|
|
15楼#
发布于:2005-02-01 10:09
有些地方我用了硬编码,可能会有问题,由于我没有2K,所以只有你自己测试看看了......
|
|
|
16楼#
发布于:2005-02-01 10:24
我现在仍然是调用“psterminatesystemthread”时发生LNK2001错误,
我在cpp文件开头加入了#pragma comment(lib,"ntoskrnl.lib")后仍然是LNK2001;在工程->设置->link中的“对象/库模块”中加入ntoskrnl.lib还是这样, 怎么办呢??? |
|
17楼#
发布于:2005-02-01 10:38
我现在仍然是调用“psterminatesystemthread”时发生LNK2001错误, 使用一下的source文件 注意 1、修改D:\\NTDDK为你的DDK目录 2、SOURCES=TestHide.c为你的文件 3、TARGETNAME=HideProc为你需要的sys文件 |
|
|
18楼#
发布于:2005-02-01 10:41
int SysKiWaitInListHeadAddr[] = {0x8042d90b, 0x8042db78, 0x8042de57, 0x8042f176, 0x8046443b, 0x80464441, 0x804644d6};
int SysKiWaitOutListHeadAddr[] = {0x8042d921, 0x8042db90, 0x8042de6f, 0x8042f18e, 0x80464494}; int SysKiWaitOutListHeadAdd4Addr[] = {0x8046448e, 0x804644a1}; int SysKiDispatcherReadyListHeadAddr[] = {0x804041ff, 0x8042faad, 0x804313de, 0x80431568, 0x8043164f, 0x80431672, 0x8043379f, 0x8046462d}; int SysKiDispatcherReadyListHeadAdd4Addr = 0x8043166b; 这样的代码不好,最好不要这样使用,否则后果不堪设想 |
|
|
19楼#
发布于:2005-02-01 11:30
这是我现在的source文件,我的工程名称为prochiding,dsp和cpp文件都是prochiding
帮忙看看有啥子问题吧,谢谢! |
|
|
上一页
下一页