-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathconnect.nm
140 lines (101 loc) · 3.61 KB
/
connect.nm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!nmake /f
CC = cl /nologo
CXX = cl /nologo /TP
LBD = lib /nologo
CFLAGS = /EHsc /DSYS_NT
LIB_DIR=lib
SRC_DIR=src
OUT_DIR=out
OUT_LIB_DIR=$(OUT_DIR)
OUT_BIN_DIR=$(OUT_DIR)
DIST_DIR=dist
LIB_NAME=connect
LIB_CONNECT=$(LIB_DIR)\socket.c $(LIB_DIR)\packet.c $(LIB_DIR)\platform\sys_nt.c # add lib source files here
LIB_CONNECT_O=$(OUT_LIB_DIR)\socket.obj $(OUT_LIB_DIR)\packet.obj $(OUT_LIB_DIR)\sys_nt.obj # add obj binary files here
BIN_SRC=$(SRC_DIR)\connect_api.c # add bin source files here for input
BIN=$(SRC_DIR)\connect_api # add binary files here for output compilation
BIN_OUT=$(OUT_DIR)\connect_api # add binary files for running after compilation
all: dir lib-dynamic bin-dynamic run-dynamic
full: dir compile run dist
compile: lib bin
lib: lib-dynamic lib-static
bin: bin-dynamic bin-static
run: run-dynamic run-static
dir: clean
MD $(OUT_DIR)
dir-dist:
-RD /Q /S $(DIST_DIR)
MD $(DIST_DIR)
lib-dynamic: dir $(LIB_CONNECT)
@echo " LD " $@
$(CXX) $(LIB_CONNECT) $(CFLAGS) /LD /Fe$(OUT_LIB_DIR)\$(LIB_NAME) /Fo$(OUT_LIB_DIR)\\
lib-static: $(LIB_CONNECT)
@echo " LS " $@
$(CXX) /c $(LIB_CONNECT) $(CFLAGS) /Fo$(OUT_LIB_DIR)\\
$(LBD) $(LIB_CONNECT_O) /OUT:$(OUT_LIB_DIR)\$(LIB_NAME)S.lib
bin-dynamic: lib-dynamic $(BIN_SRC)
@echo " CD " $@
$(CXX) $(SRC_DIR)\connect_api.c $(CFLAGS) /Fe$(OUT_BIN_DIR)\connect_api.exe /Fo$(OUT_BIN_DIR)\\ /link $(OUT_LIB_DIR)\$(LIB_NAME).lib
bin-static: lib-static $(BIN_SRC)
@echo " CS " $@
$(CXX) /EHsc $(SRC_DIR)\connect_api.c $(CFLAGS) /Fe$(OUT_BIN_DIR)\connect_api_static.exe /Fo$(OUT_BIN_DIR)\\ /link $(OUT_LIB_DIR)\$(LIB_NAME)S.lib
run-dynamic: lib-dynamic bin-dynamic
@echo " RD " $@
$(OUT_BIN_DIR)\connect_api.exe
run-static: lib-static bin-static
@echo " RS " $@
$(OUT_BIN_DIR)\connect_api_static.exe
dist:
-RD /Q /S $(DIST_DIR)
MD $(DIST_DIR)
copy $(OUT_LIB_DIR)\$(LIB_NAME).dll $(DIST_DIR)\\
copy $(OUT_LIB_DIR)\$(LIB_NAME).lib $(DIST_DIR)\\
copy $(OUT_LIB_DIR)\$(LIB_NAME)S.lib $(DIST_DIR)\\
ndis-dev: ndis-clean-all ndis-build ndis-dist ndis-sign ndis-start
ndis-build:
cd $(LIB_DIR)\platform && build
ndis-dist: dir-dist
-copy $(OUT_BIN_DIR)\amd64\cpf.sys $(DIST_DIR)\cpf_x64.sys
-copy $(OUT_BIN_DIR)\i386\cpf.sys $(DIST_DIR)\cpf_x86.sys
-copy $(LIB_DIR)\platform\sys_nt.cer $(DIST_DIR)\cpf.cer
ndis-cert-init:
makecert -r -n "CN=cpf_cert" -ss cpf_store -sr LocalMachine
ndis-cert:
certmgr.exe -add $(DIST_DIR)\cpf.cer -c -s -r localMachine trustedpublisher
certmgr.exe -add $(DIST_DIR)\cpf.cer -c -s -r localMachine root
ndis-sign:
-SignTool sign /v /s cpf_store /n cpf_cert /t http://timestamp.verisign.com/scripts/timstamp.dll $(DIST_DIR)\cpf_x64.sys
-SignTool sign /v /s cpf_store /n cpf_cert /t http://timestamp.verisign.com/scripts/timstamp.dll $(DIST_DIR)\cpf_x86.sys
ndis-start:
sc create cpf type= kernel binpath= $(MAKEDIR)\$(DIST_DIR)\cpf_x64.sys
sc start cpf
ndis-stop:
-sc stop cpf
-sc delete cpf
ndis-clean:
-del $(LIB_DIR)\platform\buildchk_*
-del $(LIB_DIR)\platform\buildfre_*
-for /d %%p in ($(LIB_DIR)\platform\objchk_*) do RD /S /Q "%%p"
-for /d %%p in ($(LIB_DIR)\platform\objfre_*) do RD /S /Q "%%p"
ndis-clean-all: ndis-stop ndis-clean
-RD /S /Q $(OUT_DIR)
-RD /S /Q $(DIST_DIR)
test-mode-on:
bcdedit -set loadoptions DISABLE_INTEGRITY_CHECKS
bcdedit -set TESTSIGNING ON
test-mode-off:
bcdedit -set loadoptions ENABLE_INTEGRITY_CHECKS
bcdedit -set TESTSIGNING OFF
#install:
# install cert
# copy sys to program files
#remove:
# remove cert
# clean program files
clean: ndis-clean
-del *.obj
-del *.exp
-del *.lib
-RD /Q /S $(OUT_DIR)
-RD /Q /S $(DIST_DIR)
.PHONY: all dir lib bin run dist clean