Vault7: CIA Hacking Tools Revealed
Navigation: » Directory » User #3375374 » User #3375374's Wiki Page
Owner: User #3375374
Funny Code 2012
Funny Code post from 2012.
While working on a project, I ran into this error and it as tricky to resolve.
"//fatal error C1905: Front end and back end not compatible (must target same processor).
LINK : fatal error LNK1257: code generation failed//"
Which module was responsible? Using the /VERBOSE switch can help as it
often shows the last library searched which most likely contains the code. My project had a large number of linked components that I wanted to test to ensure that the architecture matched so I used the following batch command.
for /r %f in (tmp\media\x64\*.lib) do @echo %f && dumpbin /headers %f | findstr /c:"machine (x64)" for /r %f in (tmp\media\x64\*.lib) do @echo %f && dumpbin /headers %f | findstr /c:"machine (x86)" |
---|
They were all correct and clean rebuilding did not clear up the problem. Turned off 'Link Time Code Generation' on the library that was searched last as identified by the /VERBOSE switch. Problem fixed!
I ran into a tricky scenario with the error code convention below. In each file I wanted unqiueness in the error code. A global enum would work but then the same header has to be included in each file. It is straight forward to generate a list via grep. Unfortunately they came back unordered so its difficult to see if they are unique.
C:\Work\rdb\elsa\src\baes.cpp(113):#define BASE_ERROR(ln) RC_ERROR(5000, ln) C:\Work\rdb\elsa\src\baes.cpp(113):#define BASE_ERROR(ln) RC_ERROR(5000, ln) C:\Work\rdb\elsa\src\elsa.cpp(94):#define ELSA_ERROR(ln) RC_ERROR(451, ln) C:\Work\rdb\elsa\src\elsa_io.cpp(11):#define ELSA_IO_ERROR(ln) RC_ERROR(453,ln) C:\Work\rdb\elsa\src\elsa_io.cpp(11):#define ELSA_IO_ERROR(ln) RC_ERROR(453,ln) |
---|
Using python here is how ended up having to sort them.
def key(x): return x[x.find("RC_ERROR(")+9:x.find(",")] fd = open(r"C:\Work\unsorted.txt", "rb") |
---|
This snippet of code makes it easy to attach a debugger to a starting service.
#ifdef USE_BREAK_ON_SERVICE_START // In WinXP at service start, on breakpoint hit cancel and select debugger // In Vista at service start, Services are launched in the session 0 desktop // while the interactive debugger is in the session 1 desktop. When the // debugger is not attached the breakpoint is handled as an application // exception e.g. exit process. // Remote debugging at application start up, use the debug break to pause // until the debugger is connected. for (int bContinue = 1; bContinue && !IsDebuggerPresent(); ) Sleep(1000); DebugBreak(); #endif // USE_BREAK_ON_SERVICE_START |
---|
Proof of concept code to generate unique error codes and instrument a code path in a circular buffer.
#ifndef RC_BITS
|
---|
Use the code as follows.
#define MAIN_ERROR(ln) RC_ERROR(10, ln) int _tmain(int argc, _TCHAR* argv[]) // default if (0 == strcmp(argv[0], "test1")) return retval; |
---|
- On the low side, clear the apt cache in '/var/cache/apt'
- Run apt in download only mode 'sudo apt-get install --download-only kdbg=2.2.1-2_i386'
- On the high side, run 'sudo dpkg --install kdbg_2.2.1-2_i386.User #77134'
Run the following commands
yum install mlocate /etc/cron.daily/mlocate.cron yum install redhat-lsb yum install gcc-g++ |
---|
Previous versions:
| 1 |