error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

VS2013新建一个空的win32应用程序时 出现了链接错误 

1>------ Build started: Project: AutoUpdate, Configuration: Debug Win32 ------
1>  Main.cpp
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>D:\Projects\AutoUpdate\Debug\AutoUpdate.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

具体过程及其解决方法如下


1、新建一个空的WIN32应用程序:



2、加入main函数:



3、直接编译链接出错:




4、加入代码:#include <tchar.h>后编译成功

完成代码如下:

#include <Windows.h>
#include <tchar.h>


int APIENTRY _tWinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPTSTR    lpCmdLine,
	int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hInstance);
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);
	UNREFERENCED_PARAMETER(nCmdShow);


	return 0;
}



: unresolved external symbol _WinMain@16

10-09

#include rnrn#include rnrnstatic OPENFILENAME ofn ;rnrnvoid PopFileInitialize (HWND hwnd) rn rnTCHAR szFilter[] = TEXT("文本文件(*.txt)\0*.text\0")TEXT("All Files (*.*)\0*.*\0\0");rn TCHAR szFileName[MAX_PATH + 1];rn OPENFILENAME ofn;rn memset(szFileName, 0, sizeof(MAX_PATH + 1));rn memset(&ofn, 0, sizeof(OPENFILENAME));rn ofn.lpstrFile = szFileName;rn ofn.lStructSize = sizeof (OPENFILENAME);rn ofn.hwndOwner = hwnd;rn ofn.hInstance = NULL;rn ofn.lpstrFilter = szFilter;rn ofn.lpstrCustomFilter = NULL;rn ofn.nMaxCustFilter = 0;rn ofn.nFilterIndex = 0;rn ofn.nMaxFile = MAX_PATH;rn ofn.nMaxFileTitle = MAX_PATH;rn ofn.lpstrInitialDir = NULL;rn ofn.lpstrTitle = NULL;rn ofn.Flags = 0;rn ofn.nFileOffset = 0;rn ofn.nFileExtension = 0;rn ofn.lpstrDefExt = TEXT("bmp");rn ofn.lCustData = 0;rn ofn.lpfnHook = NULL;rn ofn.lpTemplateName = NULL;rn GetOpenFileName(&ofn);rn MessageBox(hwnd, szFileName, 0, MB_OK); rn rn rn memset(szFileName, 0, sizeof(MAX_PATH + 1));rn memset(&ofn, 0, sizeof(OPENFILENAME));rn ofn.lpstrFile = szFileName;rn ofn.lStructSize = sizeof (OPENFILENAME);rn ofn.hwndOwner = hwnd;rn ofn.hInstance = NULL;rn ofn.lpstrFilter = szFilter;rn ofn.lpstrCustomFilter = NULL;rn ofn.nMaxCustFilter = 0;rn ofn.nFilterIndex = 0;rn ofn.nMaxFile = MAX_PATH;rn ofn.nMaxFileTitle = MAX_PATH;rn ofn.lpstrInitialDir = NULL;rn ofn.lpstrTitle = NULL;rn ofn.Flags = 0;rn ofn.nFileOffset = 0;rn ofn.nFileExtension = 0;rn ofn.lpstrDefExt = TEXT("bmp");rn ofn.lCustData = 0;rn ofn.lpfnHook = NULL;rn ofn.lpTemplateName = NULL;rn GetOpenFileName(&ofn);rn MessageBox(hwnd, szFileName, 0, MB_OK);rn;rn出现错误Linking...rnLIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16rnDebug/1237.exe : fatal error LNK1120: 1 unresolved externalsrnError executing link.exe.rnrn1237.exe - 2 error(s), 0 warning(s)rn更多 0

wdk编译出错LNK2019:unresolved external symbol _DriverEntry@8 referenced in function

05-29

inline hook ObReferenceObjectByHandle保护进程,看雪上的例子,c语言写的,编译错误LNK2019:unresolved external symbol _DriverEntry@8 referenced in function _GsDriverEntry@8。rnrn#include rn#include rnrnrnrnBYTE OriginalBytes[5]=0; rnBYTE JmpAddress[5]=0xE9,0,0,0,0;rnULONG CR0VALUE;rnrnextern POBJECT_TYPE *PsProcessType;rnrnrnNTSTATUS ObReferenceObjectByHandle(rn __in HANDLE Handle,rn __in ACCESS_MASK DesiredAccess,rn __in_opt POBJECT_TYPE ObjectType,rn __in KPROCESSOR_MODE AccessMode,rn __out PVOID *Object,rn __out_opt POBJECT_HANDLE_INFORMATION HandleInformationrn);rnrnNTSTATUS MidObReferenceObjectByHandle(rn __in HANDLE Handle,rn __in ACCESS_MASK DesiredAccess,rn __in_opt POBJECT_TYPE ObjectType,rn __in KPROCESSOR_MODE AccessMode,rn __out PVOID *Object,rn __out_opt POBJECT_HANDLE_INFORMATION HandleInformationrn);rnrnInlineHook()rnrn KIRQL Irql;rn rn DbgPrint("Original ObReferenceObjectByHandle Address is 0x%x",ObReferenceObjectByHandle);rn //保存原函数前5字节rn RtlCopyMemory(rn __in OriginalBytes,rn __in ObReferenceObjectByHandle,rn __in 5);rn*(BYTE*)JmpAddress=(ULONG)MidObReferenceObjectByHandle-(ULONG)ObReferenceObjectByHandle+5;rnrn//关闭内存写保护rn _asm rn rn rn push eaxrn rn mov eax, cr0 rn mov CR0VALUE, eax rn and eax, 0fffeffffh rn mov cr0, eaxrn pop eaxrn rn rn Irql=KeRaiseIrqlToDpcLevel();rnRtlCopyMemory(rn __in (BYTE*)ObReferenceObjectByHandle,rn __in JmpAddress,rn __in 5rn);rn KeLowerIrql(Irql);rn rn//开启内存写保护 rn __asmrn rn rn rn push eaxrn rn mov eax, CR0VALUE rn rn mov cr0, eaxrn rn pop eaxrn rn rnrnrnrn_declspec (naked) NTSTATUS OriginalObReferenceObjectByHandle(rn __in HANDLE Handle,rn __in ACCESS_MASK DesiredAccess,rn __in_opt POBJECT_TYPE ObjectType,rn __in KPROCESSOR_MODE AccessMode,rn __out PVOID *Object,rn __out_opt POBJECT_HANDLE_INFORMATION HandleInformationrn)rnrn _asmrn mov edi,edirn push ebprn mov ebp,esprn mov eax,ObReferenceObjectByHandlern add eax,5rn jmp eaxrn rn rnrnNTSTATUS MidObReferenceObjectByHandle(rn __in HANDLE Handle,rn __in ACCESS_MASK DesiredAccess,rn __in_opt POBJECT_TYPE ObjectType,rn __in KPROCESSOR_MODE AccessMode,rn __out PVOID *Object,rn __out_opt POBJECT_HANDLE_INFORMATION HandleInformationrn)rnrn NTSTATUS status;rn status=OriginalObReferenceObjectByHandle(Handle,DesiredAccess,ObjectType,AccessMode,Object,HandleInformation);rn if(status==STATUS_SUCCESS&&DesiredAccess==0x0001)rn rn if(ObjectType==*PsProcessType)rn rn if(_stricmp((char*)((ULONG)(*Object)+0x174),"notepad.exe")==0)rn rn ObDereferenceObject(*Object);rn return STATUS_INVALID_HANDLE;rn rn rn rn return status;rnrnrnrnInlineUnHook()rnrn KIRQL Irql;rn _asmrn rn rn rn push eaxrn rn mov eax, cr0 rn rn mov CR0VALUE, eax rn rn and eax, 0fffeffffh rn rn mov cr0, eaxrn rn pop eaxrn rn rn Irql=KeRaiseIrqlToDpcLevel();rnrn RtlCopyMemory((BYTE*)ObReferenceObjectByHandle,OriginalBytes,5);rn rn KeLowerIrql(Irql);rn rn //开启写保护rn rn __asmrn rn rn rn push eaxrn mov eax, CR0VALUE rn mov cr0, eaxrn rn pop eaxrn rn rnrnrnrnrnUnload(PDRIVER_OBJECT dricer)rnrn InlineUnHook();rn DbgPrint("Driver is Unloaded...\r\n");rnrnrn NTSTATUS DriverEmpty(PDRIVER_OBJECT driver,PUNICODE_STRING reg_string)rnrn InlineHook();rn driver->DriverUnload=Unload;rnrn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试