aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libwinmain/makefile3
-rw-r--r--libwinmain/winmain.c43
-rw-r--r--makefile.after8
-rw-r--r--tools/plink/winplink.c38
-rw-r--r--xorg-server/hw/xwin/xlaunch/main.cc40
5 files changed, 52 insertions, 80 deletions
diff --git a/libwinmain/makefile b/libwinmain/makefile
new file mode 100644
index 000000000..80292d3d3
--- /dev/null
+++ b/libwinmain/makefile
@@ -0,0 +1,3 @@
+LIBRARY = libwinmain
+
+CSRCS = winmain.c
diff --git a/libwinmain/winmain.c b/libwinmain/winmain.c
new file mode 100644
index 000000000..c4a8bf815
--- /dev/null
+++ b/libwinmain/winmain.c
@@ -0,0 +1,43 @@
+#include <windows.h>
+
+int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+{
+ int argc=1;
+ char ProgramName[255];
+ #define MAXNRARGS 100
+ char *argv[MAXNRARGS]={"plink"};
+ char *pTmp=lpCmdLine;
+
+ GetModuleFileName(NULL,ProgramName,255);
+ argv[0]=ProgramName;
+ while (*pTmp && argc<MAXNRARGS-1)
+ {
+ char *pEnd;
+ if (*pTmp=='"')
+ {
+ pEnd=strchr(pTmp+1,'"');
+ }
+ else if (*pTmp!=' ')
+ {
+ pEnd=strchr(pTmp,' ');
+ }
+ else
+ {
+ pTmp++;
+ continue;
+ }
+ if (pEnd)
+ {
+ *pEnd=0;
+ argv[argc++]=pTmp;
+ pTmp=pEnd+1;
+ }
+ else
+ {
+ argv[argc++]=pTmp;
+ break;
+ }
+ }
+
+ return main(argc,argv);
+} \ No newline at end of file
diff --git a/makefile.after b/makefile.after
index 600343e3e..4ceba2047 100644
--- a/makefile.after
+++ b/makefile.after
@@ -25,6 +25,10 @@ endif # End static library stuff
ifeq (1,$(call OR, $(call NE,$(WINAPP)_,_) $(call NE,$(TTYAPP)_,_)))
ifdef WINAPP
+
+load_makefile $(MHMAKECONF)\libwinmain\makefile MAKESERVER=$(MAKESERVER) DEBUG=$(DEBUG)
+EXTRALIB := $(MHMAKECONF)\libwinmain\$(OBJDIR)\libwinmain.lib
+
EXE := $(WINAPP:%=$(OBJDIR)\%.exe)
LINKFLAGS += /SUBSYSTEM:WINDOWS
else
@@ -41,8 +45,8 @@ all: $(EXE)
$(MANIFESTFILE):
$(MHMAKECONF)/tools/genruntimemanifest $@ $(DEBUG)
-$(EXE) : $(OBJS) $(INCLUDELIBFILES) $(RESOBJS) $(MANIFESTFILE)
- $(LINK) $(LINKFLAGS) /MANIFEST:NO /OUT:$(relpath $@) $(INCLUDELIBFILES) $(SYSTEMLIBS) $(LINKLIBS) $(OBJS) $(RESOBJS)
+$(EXE) : $(OBJS) $(INCLUDELIBFILES) $(RESOBJS) $(MANIFESTFILE) $(EXTRALIB)
+ $(LINK) $(LINKFLAGS) /MANIFEST:NO /OUT:$(relpath $@) $(INCLUDELIBFILES) $(SYSTEMLIBS) $(LINKLIBS) $(EXTRALIB) $(OBJS) $(RESOBJS)
mt -nologo -manifest $(MANIFESTFILE) -outputresource:$(relpath $@);\#1
endif # End WINAPP or TTYAPP stuff
diff --git a/tools/plink/winplink.c b/tools/plink/winplink.c
index 67ebd2af9..0d7c501fe 100644
--- a/tools/plink/winplink.c
+++ b/tools/plink/winplink.c
@@ -770,41 +770,3 @@ _Check_return_opt_ int __cdecl printf(_In_z_ _Printf_format_string_ const char *
va_start(arglist, pFmt );
return vfprintf(stderr, pFmt, arglist);
}
-
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
-{
- int argc=1;
- #define MAXNRARGS 20
- char *argv[MAXNRARGS]={"plink"};
- char *pTmp=lpCmdLine;
- while (*pTmp && argc<MAXNRARGS-1)
- {
- char *pEnd;
- if (*pTmp=='"')
- {
- pEnd=strchr(pTmp+1,'"');
- }
- else if (*pTmp!=' ')
- {
- pEnd=strchr(pTmp,' ');
- }
- else
- {
- pTmp++;
- continue;
- }
- if (pEnd)
- {
- *pEnd=0;
- argv[argc++]=pTmp;
- pTmp=pEnd+1;
- }
- else
- {
- argv[argc++]=pTmp;
- break;
- }
- }
-
- return main(argc,argv);
-} \ No newline at end of file
diff --git a/xorg-server/hw/xwin/xlaunch/main.cc b/xorg-server/hw/xwin/xlaunch/main.cc
index b3b1001ff..d20b788d7 100644
--- a/xorg-server/hw/xwin/xlaunch/main.cc
+++ b/xorg-server/hw/xwin/xlaunch/main.cc
@@ -763,43 +763,3 @@ int main(int argc, char **argv)
return -1;
}
}
-
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
-{
- int argc=1;
- #define MAXNRARGS 20
- char *argv[MAXNRARGS]={"plink"};
- char *pTmp=lpCmdLine;
- while (*pTmp && argc<MAXNRARGS-1)
- {
- char *pEnd;
- if (*pTmp=='"')
- {
- pEnd=strchr(pTmp+1,'"');
- }
- else if (*pTmp!=' ')
- {
- pEnd=strchr(pTmp,' ');
- }
- else
- {
- pTmp++;
- continue;
- }
- if (pEnd)
- {
- *pEnd=0;
- argv[argc++]=pTmp;
- pTmp=pEnd+1;
- }
- else
- {
- argv[argc++]=pTmp;
- break;
- }
- }
-
- return main(argc,argv);
-}
-
-